Subversion Repositories Kolibri OS

Rev

Rev 6011 | Rev 6220 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6011 Rev 6122
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
2
;;                                                                 ;;
3
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved.    ;;
3
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved.    ;;
4
;; Distributed under terms of the GNU General Public License       ;;
4
;; Distributed under terms of the GNU General Public License       ;;
5
;;                                                                 ;;
5
;;                                                                 ;;
6
;;  IPv4.INC                                                       ;;
6
;;  IPv4.INC                                                       ;;
7
;;                                                                 ;;
7
;;                                                                 ;;
8
;;  Part of the TCP/IP network stack for KolibriOS                 ;;
8
;;  Part of the TCP/IP network stack for KolibriOS                 ;;
Line 14... Line 14...
14
;;          GNU GENERAL PUBLIC LICENSE                             ;;
14
;;          GNU GENERAL PUBLIC LICENSE                             ;;
15
;;             Version 2, June 1991                                ;;
15
;;             Version 2, June 1991                                ;;
16
;;                                                                 ;;
16
;;                                                                 ;;
17
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
17
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 18... Line 18...
18
 
18
 
Line 19... Line 19...
19
$Revision: 6011 $
19
$Revision: 6122 $
20
 
20
 
Line 21... Line 21...
21
IPv4_MAX_FRAGMENTS              = 64
21
IPv4_MAX_FRAGMENTS              = 64
Line 632... Line 632...
632
        ja      .too_large
632
        ja      .too_large
Line 633... Line 633...
633
 
633
 
634
        push    ecx ax edi
634
        push    ecx ax edi
635
        mov     eax, edi
635
        mov     eax, edi
-
 
636
        call    ipv4_route              ; outputs device number in edi, dest ip in eax, source IP in edx
-
 
637
        test    eax, eax
636
        call    ipv4_route              ; outputs device number in edi, dest ip in eax, source IP in edx
638
        jz      .no_route
637
        push    edx
639
        push    edx
638
        test    edi, edi
640
        test    edi, edi
Line 639... Line 641...
639
        jz      .loopback
641
        jz      .loopback
Line 681... Line 683...
681
        DEBUGF  DEBUG_NETWORK_ERROR, "IPv4_output: ethernet error\n"
683
        DEBUGF  DEBUG_NETWORK_ERROR, "IPv4_output: ethernet error\n"
682
        add     esp, 3*4+2+6
684
        add     esp, 3*4+2+6
683
        xor     eax, eax
685
        xor     eax, eax
684
        ret
686
        ret
Line -... Line 687...
-
 
687
 
-
 
688
  .no_route:
-
 
689
        DEBUGF  DEBUG_NETWORK_ERROR, "IPv4_output: No route to host!\n"
-
 
690
        add     esp, 2*4+2
-
 
691
        xor     eax, eax
-
 
692
        ret
685
 
693
 
686
  .arp_error:
694
  .arp_error:
687
        DEBUGF  DEBUG_NETWORK_ERROR, "IPv4_output: ARP error=%x\n", eax
695
        DEBUGF  DEBUG_NETWORK_ERROR, "IPv4_output: ARP error=%x\n", eax
688
        add     esp, 4
696
        add     esp, 4
689
        pop     eax
697
        pop     eax
Line 915... Line 923...
915
;                                                                 ;
923
;                                                                 ;
916
; IN:   eax = Destination IP                                      ;
924
; IN:   eax = Destination IP                                      ;
917
;       ebx = outgoing device / 0                                 ;
925
;       ebx = outgoing device / 0                                 ;
918
;       edx = Source IP                                           ;
926
;       edx = Source IP                                           ;
919
;                                                                 ;
927
;                                                                 ;
920
; OUT:  eax = Destination IP (or gateway IP)                      ;
928
; OUT:  eax = Destination IP (may be gateway), 0 on error         ;
921
;       edx = Source IP                                           ;
929
;       edx = Source IP                                           ;
922
;       edi = device number*4                                     ;
930
;       edi = device number*4                                     ;
923
;                                                                 ;
931
;                                                                 ;
924
; DESTROYED:                                                      ;
932
; DESTROYED:                                                      ;
925
;       ecx                                                       ;
933
;       ecx                                                       ;
926
;                                                                 ;
934
;                                                                 ;
927
;-----------------------------------------------------------------;
935
;-----------------------------------------------------------------;
928
align 4
936
align 4
929
ipv4_route:     ; TODO: return error if no valid route found
937
ipv4_route:
Line 930... Line 938...
930
 
938
 
931
        test    ebx, ebx
939
        test    ebx, ebx
Line 932... Line 940...
932
        jnz     .got_device
940
        jnz     .got_device
Line 977... Line 985...
977
        mov     eax, [GATEWAY_LIST + edi]
985
        mov     eax, [GATEWAY_LIST + edi]
978
  @@:
986
  @@:
979
        ret
987
        ret
Line 980... Line 988...
980
 
988
 
-
 
989
  .fail:
981
  .fail:
990
        xor     eax, eax
Line 982... Line 991...
982
        ret
991
        ret