Subversion Repositories Kolibri OS

Rev

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

Rev 5984 Rev 6078
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: 5842 $
19
$Revision: 6011 $
20
 
20
 
Line 21... Line 21...
21
IPv4_MAX_FRAGMENTS              = 64
21
IPv4_MAX_FRAGMENTS              = 64
Line 90... Line 90...
90
        IPv4_ROUTES             rd IPv4_MAX_ROUTES * sizeof.IPv4_ROUTE
90
        IPv4_ROUTES             rd IPv4_MAX_ROUTES * sizeof.IPv4_ROUTE
Line 91... Line 91...
91
 
91
 
Line 92... Line 92...
92
endg
92
endg
93
 
-
 
94
 
93
 
95
;-----------------------------------------------------------------
-
 
96
;
94
 
97
; IPv4_init
-
 
-
 
95
;-----------------------------------------------------------------;
98
;
96
;                                                                 ;
99
;  This function resets all IP variables
97
; ipv4_init: Resets all IPv4 variables                            ;
Line 100... Line 98...
100
;
98
;                                                                 ;
101
;-----------------------------------------------------------------
99
;-----------------------------------------------------------------;
102
macro   IPv4_init {
100
macro   ipv4_init {
103
 
101
 
Line 104... Line 102...
104
        xor     eax, eax
102
        xor     eax, eax
Line 105... Line 103...
105
        mov     edi, IP_LIST
103
        mov     edi, IP_LIST
106
        mov     ecx, 7*NET_DEVICES_MAX + (sizeof.IPv4_FRAGMENT_slot*IPv4_MAX_FRAGMENTS)/4
-
 
-
 
104
        mov     ecx, 7*NET_DEVICES_MAX + (sizeof.IPv4_FRAGMENT_slot*IPv4_MAX_FRAGMENTS)/4
107
        rep stosd
105
        rep stosd
108
 
-
 
-
 
106
 
109
}
107
}
110
 
108
 
Line 111... Line 109...
111
 
109
 
Line 112... Line 110...
112
;-----------------------------------------------------------------
110
;-----------------------------------------------------------------;
113
;
111
;                                                                 ;
Line 139... Line 137...
139
  .done:
137
  .done:
140
}
138
}
Line 141... Line 139...
141
 
139
 
Line 142... Line 140...
142
 
140
 
143
 
141
 
144
macro IPv4_checksum ptr {
142
macro ipv4_checksum ptr {
Line 203... Line 201...
203
 
201
 
Line 204... Line 202...
204
}
202
}
205
 
-
 
206
 
203
 
207
 
-
 
208
;-----------------------------------------------------------------
204
 
209
;
205
 
210
; IPv4_input:
-
 
211
;
206
;-----------------------------------------------------------------;
212
;  Will check if IPv4 Packet isnt damaged
-
 
-
 
207
;                                                                 ;
213
;  and call appropriate handler. (TCP/UDP/ICMP/..)
208
; ipv4_input: Check if IPv4 Packet isnt damaged and call          ;
214
;
209
; appropriate handler. (TCP/UDP/ICMP/..)                          ;
215
;  It will also re-construct fragmented packets
210
; We will also re-construct fragmented packets.                   ;
216
;
211
;                                                                 ;
-
 
212
;  IN:  Pointer to buffer in [esp]                                ;
217
;  IN:  Pointer to buffer in [esp]
213
;       pointer to device struct in ebx                           ;
218
;       pointer to device struct in ebx
-
 
-
 
214
;       pointer to IPv4 header in edx                             ;
219
;       pointer to IPv4 header in edx
215
;       size of IPv4 packet in ecx                                ;
220
;       size of IPv4 packet in ecx
216
;                                                                 ;
221
;  OUT: /
217
;  OUT: /                                                         ;
Line 222... Line 218...
222
;
218
;                                                                 ;
223
;-----------------------------------------------------------------
219
;-----------------------------------------------------------------;
224
align 4
220
align 4
225
IPv4_input:
221
ipv4_input:
226
 
222
 
227
        DEBUGF  DEBUG_NETWORK_VERBOSE, "IPv4_input: packet from %u.%u.%u.%u ",\
223
        DEBUGF  DEBUG_NETWORK_VERBOSE, "IPv4_input: packet from %u.%u.%u.%u ",\
Line 228... Line 224...
228
        [edx + IPv4_header.SourceAddress + 0]:1,[edx + IPv4_header.SourceAddress + 1]:1,\
224
        [edx + IPv4_header.SourceAddress + 0]:1,[edx + IPv4_header.SourceAddress + 1]:1,\
229
        [edx + IPv4_header.SourceAddress + 2]:1,[edx + IPv4_header.SourceAddress + 3]:1
225
        [edx + IPv4_header.SourceAddress + 2]:1,[edx + IPv4_header.SourceAddress + 3]:1
230
        DEBUGF  DEBUG_NETWORK_VERBOSE, "to %u.%u.%u.%u\n",\
226
        DEBUGF  DEBUG_NETWORK_VERBOSE, "to %u.%u.%u.%u\n",\
Line 231... Line 227...
231
        [edx + IPv4_header.DestinationAddress + 0]:1,[edx + IPv4_header.DestinationAddress + 1]:1,\
227
        [edx + IPv4_header.DestinationAddress + 0]:1,[edx + IPv4_header.DestinationAddress + 1]:1,\
232
        [edx + IPv4_header.DestinationAddress + 2]:1,[edx + IPv4_header.DestinationAddress + 3]:1
228
        [edx + IPv4_header.DestinationAddress + 2]:1,[edx + IPv4_header.DestinationAddress + 3]:1
Line 233... Line 229...
233
 
229
 
234
        call    NET_ptr_to_num4
230
        call    net_ptr_to_num4
Line 235... Line 231...
235
        cmp     edi, -1
231
        cmp     edi, -1
Line 236... Line 232...
236
        je      .invalid_device
232
        je      .invalid_device
Line 302... Line 298...
302
 
298
 
303
        mov     al, [edx + IPv4_header.Protocol]
299
        mov     al, [edx + IPv4_header.Protocol]
Line 304... Line 300...
304
        add     esi, edx                                        ; make esi ptr to data
300
        add     esi, edx                                        ; make esi ptr to data
305
 
301
 
Line 306... Line 302...
306
        cmp     al, IP_PROTO_TCP
302
        cmp     al, IP_PROTO_TCP
307
        je      TCP_input
303
        je      tcp_input
Line 308... Line 304...
308
 
304
 
309
        cmp     al, IP_PROTO_UDP
305
        cmp     al, IP_PROTO_UDP
Line 310... Line 306...
310
        je      UDP_input
306
        je      udp_input
311
 
307
 
312
        cmp     al, IP_PROTO_ICMP
308
        cmp     al, IP_PROTO_ICMP
313
        je      ICMP_input
309
        je      icmp_input
Line 345... Line 341...
345
        pusha
341
        pusha
346
        lea     ecx, [eax + SOCKET.mutex]
342
        lea     ecx, [eax + SOCKET.mutex]
347
        call    mutex_lock
343
        call    mutex_lock
348
        popa
344
        popa
Line 349... Line 345...
349
 
345
 
Line 350... Line 346...
350
        jmp     SOCKET_input
346
        jmp     socket_input
Line 351... Line 347...
351
 
347
 
352
  .dump_unlock:
348
  .dump_unlock:
Line 359... Line 355...
359
        DEBUGF  DEBUG_NETWORK_VERBOSE, "IPv4_input: unknown protocol %u\n", al
355
        DEBUGF  DEBUG_NETWORK_VERBOSE, "IPv4_input: unknown protocol %u\n", al
Line 360... Line 356...
360
 
356
 
361
  .dump:
357
  .dump:
362
        DEBUGF  DEBUG_NETWORK_VERBOSE, "IPv4_input: dumping\n"
358
        DEBUGF  DEBUG_NETWORK_VERBOSE, "IPv4_input: dumping\n"
363
        inc     [IPv4_packets_dumped + edi]
359
        inc     [IPv4_packets_dumped + edi]
364
        call    NET_BUFF_free
360
        call    net_buff_free
Line 365... Line 361...
365
        ret
361
        ret
366
 
362
 
367
  .invalid_device:
363
  .invalid_device:
368
        DEBUGF  DEBUG_NETWORK_ERROR, "IPv4_input: packet originated from invalid device\n"
364
        DEBUGF  DEBUG_NETWORK_ERROR, "IPv4_input: packet originated from invalid device\n"
Line 369... Line 365...
369
        call    NET_BUFF_free
365
        call    net_buff_free
370
        ret
366
        ret
Line 388... Line 384...
388
;-------------------------------------------------------
384
;-------------------------------------------------------
389
; We have a fragmented IP packet, but it's not the first
385
; We have a fragmented IP packet, but it's not the first
Line 390... Line 386...
390
 
386
 
Line 391... Line 387...
391
        DEBUGF  DEBUG_NETWORK_VERBOSE, "IPv4_input: Middle fragment packet received!\n"
387
        DEBUGF  DEBUG_NETWORK_VERBOSE, "IPv4_input: Middle fragment packet received!\n"
392
 
388
 
393
        call    IPv4_find_fragment_slot
389
        call    ipv4_find_fragment_slot
Line 394... Line 390...
394
        cmp     esi, -1
390
        cmp     esi, -1
395
        je      .dump
391
        je      .dump
Line 453... Line 449...
453
; We have received the last fragment
449
; We have received the last fragment
Line 454... Line 450...
454
 
450
 
455
  .is_last_fragment:
451
  .is_last_fragment:
Line 456... Line 452...
456
        DEBUGF  DEBUG_NETWORK_VERBOSE, "IPv4_input: Last fragment packet received!\n"
452
        DEBUGF  DEBUG_NETWORK_VERBOSE, "IPv4_input: Last fragment packet received!\n"
457
 
453
 
458
        call    IPv4_find_fragment_slot
454
        call    ipv4_find_fragment_slot
Line 459... Line 455...
459
        cmp     esi, -1
455
        cmp     esi, -1
460
        je      .dump
456
        je      .dump
Line 544... Line 540...
544
        push    eax
540
        push    eax
545
        push    [edx + IPv4_FRAGMENT_entry.Owner]                                       ; we need to remeber the owner, in case this is the last packet
541
        push    [edx + IPv4_FRAGMENT_entry.Owner]                                       ; we need to remeber the owner, in case this is the last packet
546
        push    [edx + IPv4_FRAGMENT_entry.NextPtr]                                     ; Set edx to the next pointer
542
        push    [edx + IPv4_FRAGMENT_entry.NextPtr]                                     ; Set edx to the next pointer
547
        push    edx                                                                     ; Push pointer to fragment onto stack
543
        push    edx                                                                     ; Push pointer to fragment onto stack
548
        DEBUGF  DEBUG_NETWORK_VERBOSE, "IPv4_input: Next Fragment: 0x%x\n", edx
544
        DEBUGF  DEBUG_NETWORK_VERBOSE, "IPv4_input: Next Fragment: 0x%x\n", edx
549
        call    NET_BUFF_free                                                          ; free the previous fragment buffer (this uses the value from stack)
545
        call    net_buff_free                                                          ; free the previous fragment buffer (this uses the value from stack)
550
        pop     edx ebx eax
546
        pop     edx ebx eax
551
        cmp     edx, -1                                                                 ; Check if it is last fragment in chain
547
        cmp     edx, -1                                                                 ; Check if it is last fragment in chain
552
        jne     .rebuild_packet_loop
548
        jne     .rebuild_packet_loop
Line 553... Line 549...
553
 
549
 
Line 569... Line 565...
569
 
565
 
570
 
-
 
-
 
566
 
571
 
567
 
572
 
-
 
-
 
568
 
573
 
569
 
-
 
570
;-----------------------------------------------------------------;
574
;-----------------------------------------------------------------
571
;                                                                 ;
575
;
-
 
-
 
572
; ipv4_find_fragment_slot                                         ;
576
; find fragment slot
573
;                                                                 ;
577
;
574
; IN: pointer to fragmented packet in edx                         ;
578
; IN: pointer to fragmented packet in edx
575
;                                                                 ;
Line 579... Line 576...
579
; OUT: pointer to slot in esi, -1 on error
576
; OUT: pointer to slot in esi, -1 on error                        ;
Line 580... Line 577...
580
;
577
;                                                                 ;
581
;-----------------------------------------------------------------
578
;-----------------------------------------------------------------;
Line 605... Line 602...
605
  .found_slot:
602
  .found_slot:
606
        pop     edx ecx ebx eax
603
        pop     edx ecx ebx eax
607
        ret
604
        ret
Line 608... Line 605...
608
 
605
 
609
 
-
 
-
 
606
 
610
;------------------------------------------------------------------
607
;------------------------------------------------------------------;
611
;
-
 
-
 
608
;                                                                  ;
612
; IPv4_output
609
; ipv4_output                                                      ;
613
;
610
;                                                                  ;
614
; IN:    al = protocol
611
;  IN:  al = protocol                                              ;
615
;        ah = TTL
612
;       ah = TTL                                                   ;
616
;       ebx = device ptr (or 0 to let IP layer decide)
613
;       ebx = device ptr (or 0 to let IP layer decide)             ;
617
;       ecx = data length
614
;       ecx = data length                                          ;
618
;       edx = Source IP
-
 
-
 
615
;       edx = Source IP                                            ;
619
;       edi = Destination IP
616
;       edi = Destination IP                                       ;
-
 
617
;                                                                  ;
620
;
618
; OUT:  eax = pointer to buffer start                              ;
621
; OUT:  eax = pointer to buffer start / 0 on error
619
;       eax = 0 on error                                           ;
622
;       ebx = device ptr (send packet through this device)
620
;       ebx = device ptr (send packet through this device)         ;
623
;       ecx = data length
621
;       ecx = data length                                          ;
624
;       edx = size of complete frame
-
 
-
 
622
;       edx = size of complete frame                               ;
625
;       edi = start of IPv4 payload
623
;       edi = start of IPv4 payload                                ;
626
;
624
;                                                                  ;
627
;------------------------------------------------------------------
625
;------------------------------------------------------------------;
Line 628... Line 626...
628
align 4
626
align 4
Line 629... Line 627...
629
IPv4_output:
627
ipv4_output:
630
 
628
 
Line 631... Line 629...
631
        DEBUGF  DEBUG_NETWORK_VERBOSE, "IPv4_output: size=%u ip=0x%x\n", ecx, eax
629
        DEBUGF  DEBUG_NETWORK_VERBOSE, "IPv4_output: size=%u ip=0x%x\n", ecx, eax
632
 
630
 
633
        cmp     ecx, 65500              ; Max IPv4 packet size
631
        cmp     ecx, 65500              ; Max IPv4 packet size
634
        ja      .too_large
632
        ja      .too_large
635
 
633
 
636
        push    ecx ax edi
634
        push    ecx ax edi
Line 637... Line 635...
637
        mov     eax, edi
635
        mov     eax, edi
638
        call    IPv4_route              ; outputs device number in edi, dest ip in eax, source IP in edx
636
        call    ipv4_route              ; outputs device number in edi, dest ip in eax, source IP in edx
639
        push    edx
637
        push    edx
640
        test    edi, edi
638
        test    edi, edi
641
        jz      .loopback
639
        jz      .loopback
Line 651... Line 649...
651
        mov     ax, ETHER_PROTO_IPv4
649
        mov     ax, ETHER_PROTO_IPv4
652
        mov     ebx, [NET_DRV_LIST + edi]
650
        mov     ebx, [NET_DRV_LIST + edi]
653
        mov     ecx, [esp + 6 + 8 + 2]
651
        mov     ecx, [esp + 6 + 8 + 2]
654
        add     ecx, sizeof.IPv4_header
652
        add     ecx, sizeof.IPv4_header
655
        mov     edx, esp
653
        mov     edx, esp
656
        call    ETH_output
654
        call    eth_output
657
        jz      .eth_error
655
        jz      .eth_error
658
        add     esp, 6                  ; pop the mac out of the stack
656
        add     esp, 6                  ; pop the mac out of the stack
Line 659... Line 657...
659
 
657
 
660
  .continue:
658
  .continue:
Line 672... Line 670...
672
        pop     word[edi + IPv4_header.TimeToLive]      ; ttl shl 8 + protocol
670
        pop     word[edi + IPv4_header.TimeToLive]      ; ttl shl 8 + protocol
673
;               [edi + IPv4_header.Protocol]
671
;               [edi + IPv4_header.Protocol]
Line 674... Line 672...
674
 
672
 
Line 675... Line 673...
675
        pop     ecx
673
        pop     ecx
676
 
674
 
677
        IPv4_checksum edi
675
        ipv4_checksum edi
678
        add     edi, sizeof.IPv4_header
676
        add     edi, sizeof.IPv4_header
Line 679... Line 677...
679
        DEBUGF  DEBUG_NETWORK_VERBOSE, "IPv4_output: success!\n"
677
        DEBUGF  DEBUG_NETWORK_VERBOSE, "IPv4_output: success!\n"
Line 702... Line 700...
702
  .loopback:
700
  .loopback:
703
        mov     dword [esp], eax                        ; set source IP to dest IP
701
        mov     dword [esp], eax                        ; set source IP to dest IP
704
        mov     ecx, [esp + 10]
702
        mov     ecx, [esp + 10]
705
        add     ecx, sizeof.IPv4_header
703
        add     ecx, sizeof.IPv4_header
706
        mov     edi, AF_INET4
704
        mov     edi, AF_INET4
707
        call    LOOP_output
705
        call    loop_output
708
        jmp     .continue
706
        jmp     .continue
Line 709... Line 707...
709
 
707
 
710
 
-
 
-
 
708
 
711
 
709
 
712
 
-
 
-
 
710
 
713
;------------------------------------------------------------------
711
;------------------------------------------------------------------;
714
;
712
;                                                                  ;
715
; IPv4_output_raw
713
; ipv4_output_raw                                                  ;
716
;
-
 
-
 
714
;                                                                  ;
717
; IN: eax = socket ptr
715
;  IN: eax = socket ptr                                            ;
718
;     ecx = data length
-
 
-
 
716
;      ecx = data length                                           ;
719
;     esi = data ptr
717
;      esi = data ptr                                              ;
720
;
718
;                                                                  ;
721
; OUT: eax = -1 on error
719
; OUT: eax = -1 on error                                           ;
Line 722... Line 720...
722
;
720
;                                                                  ;
Line 723... Line 721...
723
;------------------------------------------------------------------
721
;------------------------------------------------------------------;
724
align 4
722
align 4
Line 725... Line 723...
725
IPv4_output_raw:
723
ipv4_output_raw:
726
 
724
 
Line 727... Line 725...
727
        DEBUGF 1,"IPv4_output_raw: size=%u ptr=%x socket=%x\n", ecx, esi, eax
725
        DEBUGF 1,"IPv4_output_raw: size=%u ptr=%x socket=%x\n", ecx, esi, eax
728
 
726
 
Line 729... Line 727...
729
        sub     esp, 8
727
        sub     esp, 8
Line 742... Line 740...
742
        mov     ax, ETHER_PROTO_IPv4
740
        mov     ax, ETHER_PROTO_IPv4
743
        mov     ebx, [NET_DRV_LIST + 4*edi]
741
        mov     ebx, [NET_DRV_LIST + 4*edi]
744
        mov     ecx, [esp + 6 + 4]
742
        mov     ecx, [esp + 6 + 4]
745
        add     ecx, sizeof.IPv4_header
743
        add     ecx, sizeof.IPv4_header
746
        mov     edx, esp
744
        mov     edx, esp
747
        call    ETH_output
745
        call    eth_output
748
        jz      .error
746
        jz      .error
749
        add     esp, 6  ; pop the mac
747
        add     esp, 6  ; pop the mac
Line 750... Line 748...
750
 
748
 
751
        mov     dword[esp+4+4], edx
749
        mov     dword[esp+4+4], edx
Line 770... Line 768...
770
;        [edi + IPv4_header.Protocol]
768
;        [edi + IPv4_header.Protocol]
771
;        [edi + IPv4_header.Identification]             ; fragment id
769
;        [edi + IPv4_header.Identification]             ; fragment id
772
;        [edi + IPv4_header.SourceAddress]
770
;        [edi + IPv4_header.SourceAddress]
773
;        [edi + IPv4_header.DestinationAddress]
771
;        [edi + IPv4_header.DestinationAddress]
Line 774... Line 772...
774
 
772
 
775
        IPv4_checksum edi                       ;;;; todo: checksum for IP packet with options!
773
        ipv4_checksum edi                       ;;;; todo: checksum for IP packet with options!
776
        add     edi, sizeof.IPv4_header
774
        add     edi, sizeof.IPv4_header
777
        DEBUGF  DEBUG_NETWORK_VERBOSE, "IPv4_output_raw: device=%x\n", ebx
775
        DEBUGF  DEBUG_NETWORK_VERBOSE, "IPv4_output_raw: device=%x\n", ebx
778
        call    [ebx + NET_DEVICE.transmit]
776
        call    [ebx + NET_DEVICE.transmit]
Line 789... Line 787...
789
        mov     ebx, ENOTCONN
787
        mov     ebx, ENOTCONN
790
        or      eax, -1
788
        or      eax, -1
791
        ret
789
        ret
Line 792... Line 790...
792
 
790
 
793
 
-
 
794
;--------------------------------------------------------
-
 
-
 
791
 
-
 
792
;-----------------------------------------------------------------;
-
 
793
;                                                                 ;
795
;
794
; ipv4_fragment                                                   ;
796
;
795
;                                                                 ;
797
; IN: [esp] = pointer to buffer containing ipv4 packet to be fragmented
796
;  IN:  [esp] = ptr to packet buffer to fragment                  ;
798
;     edi = pointer to ip header in that buffer
-
 
-
 
797
;       edi = ptrr to ip header in that buffer                    ;
799
;     ebx = device ptr
798
;       ebx = device ptr                                          ;
800
;
-
 
-
 
799
;                                                                 ;
801
; OUT: /
800
;  OUT: /                                                         ;
802
;
801
;                                                                 ;
Line 803... Line 802...
803
;--------------------------------------------------------
802
;-----------------------------------------------------------------;
804
proc IPv4_fragment stdcall buffer
803
proc ipv4_fragment stdcall buffer
805
 
804
 
806
locals
805
locals
Line 908... Line 907...
908
 
907
 
Line 909... Line 908...
909
endp
908
endp
910
 
-
 
-
 
909
 
911
 
910
 
912
 
-
 
-
 
911
 
913
;---------------------------------------------------------------------------
912
;-----------------------------------------------------------------;
914
;
913
;                                                                 ;
915
; IPv4_route
914
; ipv4_route                                                      ;
-
 
915
;                                                                 ;
916
;
916
; IN:   eax = Destination IP                                      ;
917
; IN:   eax = Destination IP
917
;       ebx = outgoing device / 0                                 ;
918
;       ebx = outgoing device / 0
918
;       edx = Source IP                                           ;
-
 
919
;                                                                 ;
919
;       edx = Source IP
920
; OUT:  eax = Destination IP (or gateway IP)                      ;
920
; OUT:  eax = Destination IP (or gateway IP)
921
;       edx = Source IP                                           ;
921
;       edx = Source IP
-
 
-
 
922
;       edi = device number*4                                     ;
922
;       edi = device number*4
923
;                                                                 ;
923
; DESTROYED:
924
; DESTROYED:                                                      ;
924
;       ecx
925
;       ecx                                                       ;
Line 925... Line 926...
925
;
926
;                                                                 ;
926
;---------------------------------------------------------------------------
927
;-----------------------------------------------------------------;
Line 927... Line 928...
927
align 4
928
align 4
Line 959... Line 960...
959
 
960
 
Line 960... Line 961...
960
        ret
961
        ret
961
 
962
 
962
  .got_device:
963
  .got_device:
963
; Validate device ptr and convert to device number
964
; Validate device ptr and convert to device number
964
        call    NET_ptr_to_num4
965
        call    net_ptr_to_num4
Line 965... Line 966...
965
        cmp     edi, -1
966
        cmp     edi, -1
Line 980... Line 981...
980
  .fail:
981
  .fail:
981
        ret
982
        ret
Line 982... Line 983...
982
 
983
 
983
 
-
 
-
 
984
 
984
 
985
 
985
;---------------------------------------------------------------------------
-
 
-
 
986
;-----------------------------------------------------------------;
986
;
987
;                                                                 ;
-
 
988
; ipv4_get_frgmnt_num                                             ;
987
; IPv4_get_frgmnt_num
989
;                                                                 ;
988
;
-
 
-
 
990
;  IN: /                                                          ;
989
; IN: /
991
;                                                                 ;
990
; OUT: fragment number in ax
992
; OUT: ax = fragment number                                       ;
991
;
993
;                                                                 ;
992
;---------------------------------------------------------------------------
994
;-----------------------------------------------------------------;
Line 993... Line 995...
993
align 4
995
align 4
Line 994... Line 996...
994
IPv4_get_frgmnt_num:
996
ipv4_get_frgmnt_num:
995
        xor     ax, ax  ;;; TODO: replace this with real code
-
 
-
 
997
        xor     ax, ax  ;;; TODO: replace this with real code
996
 
998
 
997
        ret
-
 
-
 
999
        ret
998
 
1000
 
-
 
1001
 
999
 
1002
;-----------------------------------------------------------------;
-
 
1003
;                                                                 ;
1000
;-----------------------------------------------------------------
1004
; ipv4_connect                                                    ;
1001
;
-
 
-
 
1005
;                                                                 ;
1002
; IPv4_connect
1006
;   IN: eax = socket pointer                                      ;
1003
;
1007
;                                                                 ;
1004
;   IN: eax = socket pointer
1008
;  OUT: eax = 0 on success                                        ;
Line 1005... Line 1009...
1005
;  OUT: eax = 0 ok / -1 error
1009
;       eax = -1 on error                                         ;
1006
;       ebx = error code
1010
;       ebx = error code on error                                 ;
1007
;
1011
;                                                                 ;
1008
;-------------------------
1012
;-----------------------------------------------------------------;
Line 1029... Line 1033...
1029
 
1033
 
1030
        xor     eax, eax
1034
        xor     eax, eax
Line 1031... Line 1035...
1031
        ret
1035
        ret
1032
 
-
 
-
 
1036
 
1033
 
1037
 
1034
;---------------------------------------------------------------------------
-
 
1035
;
1038
;-----------------------------------------------------------------;
1036
; IPv4_API
-
 
1037
;
1039
;                                                                 ;
1038
; This function is called by system function 75
1040
; ipv4_API: Part of system function 76.                           ;
1039
;
1041
;                                                                 ;
1040
; IN:  subfunction number in bl
-
 
-
 
1042
;  IN:  bl = subfunction number                                   ;
1041
;      device number in bh
1043
;       bh = device number                                        ;
1042
;      ecx, edx, .. depends on subfunction
-
 
-
 
1044
;       ecx, edx, .. depends on subfunction                       ;
1043
;
1045
;                                                                 ;
1044
; OUT:
1046
; OUT:  depends on subfunction                                    ;
1045
;
1047
;                                                                 ;
Line 1046... Line 1048...
1046
;---------------------------------------------------------------------------
1048
;-----------------------------------------------------------------;
1047
align 4
1049
align 4
Line 1048... Line 1050...
1048
IPv4_api:
1050
ipv4_api:
Line 1094... Line 1096...
1094
        or      ebx, ecx
1096
        or      ebx, ecx
1095
        mov     [BROADCAST_LIST + eax], ebx
1097
        mov     [BROADCAST_LIST + eax], ebx
Line 1096... Line 1098...
1096
 
1098
 
1097
        mov     ebx, [NET_DRV_LIST + eax]
1099
        mov     ebx, [NET_DRV_LIST + eax]
1098
        mov     eax, [IP_LIST + eax]
1100
        mov     eax, [IP_LIST + eax]
Line 1099... Line 1101...
1099
        call    ARP_output_request              ; now send a gratuitous ARP
1101
        call    arp_output_request              ; now send a gratuitous ARP
1100
 
1102
 
1101
        call    NET_send_event
1103
        call    net_send_event
Line 1102... Line 1104...
1102
        xor     eax, eax
1104
        xor     eax, eax
1103
        ret
1105
        ret
1104
 
1106
 
Line 1105... Line 1107...
1105
  .read_dns:
1107
  .read_dns:
1106
        mov     eax, [DNS_LIST + eax]
1108
        mov     eax, [DNS_LIST + eax]
1107
        ret
1109
        ret
1108
 
1110
 
1109
  .write_dns:
1111
  .write_dns:
Line 1110... Line 1112...
1110
        mov     [DNS_LIST + eax], ecx
1112
        mov     [DNS_LIST + eax], ecx
1111
        call    NET_send_event
1113
        call    net_send_event
Line 1123... Line 1125...
1123
        mov     ebx, [IP_LIST + eax]
1125
        mov     ebx, [IP_LIST + eax]
1124
        not     ecx
1126
        not     ecx
1125
        or      ecx, ebx
1127
        or      ecx, ebx
1126
        mov     [BROADCAST_LIST + eax], ecx
1128
        mov     [BROADCAST_LIST + eax], ecx
Line 1127... Line 1129...
1127
 
1129
 
1128
        call    NET_send_event
1130
        call    net_send_event
1129
        xor     eax, eax
1131
        xor     eax, eax
Line 1130... Line 1132...
1130
        ret
1132
        ret
1131
 
1133
 
1132
  .read_gateway:
1134
  .read_gateway:
Line 1133... Line 1135...
1133
        mov     eax, [GATEWAY_LIST + eax]
1135
        mov     eax, [GATEWAY_LIST + eax]
1134
        ret
1136
        ret
Line 1135... Line 1137...
1135
 
1137
 
1136
  .write_gateway:
1138
  .write_gateway:
1137
        mov     [GATEWAY_LIST + eax], ecx
1139
        mov     [GATEWAY_LIST + eax], ecx
1138
 
1140