1,6 → 1,6 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;; |
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;; IPv4.INC ;; |
16,7 → 16,7 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|
$Revision: 5015 $ |
$Revision: 3515 $ |
|
IPv4_MAX_FRAGMENTS = 64 |
IPv4_MAX_ROUTES = 64 |
576,11 → 576,11 |
; edx = Source IP |
; di = TTL shl 8 + protocol |
; |
; OUT: eax = pointer to buffer start / 0 on error |
; ebx = device ptr (send packet through this device) |
; ecx = data length |
; edx = size of complete frame |
; edi = start of IPv4 payload |
; OUT: eax = pointer to buffer start |
; ebx = pointer to device struct (needed for sending procedure) |
; ecx = unchanged (packet size of embedded data) |
; edx = size of complete buffer |
; edi = pointer to start of data (0 on error) |
; |
;------------------------------------------------------------------ |
align 4 |
594,6 → 594,7 |
push ecx di eax |
call IPv4_route ; outputs device number in edi, dest ip in eax, source IP in edx |
push edx |
|
test edi, edi |
jz .loopback |
|
605,11 → 606,12 |
|
inc [IPv4_packets_tx + edi] ; update stats |
|
mov ax, ETHER_PROTO_IPv4 |
mov ebx, [NET_DRV_LIST + edi] |
lea eax, [ebx + ETH_DEVICE.mac] |
mov edx, esp |
mov ecx, [esp + 6 + 8 + 2] |
add ecx, sizeof.IPv4_header |
mov edx, esp |
mov di, ETHER_PROTO_IPv4 |
call ETH_output |
jz .eth_error |
add esp, 6 ; pop the mac out of the stack |
639,18 → 641,18 |
.eth_error: |
DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output: ethernet error\n" |
add esp, 3*4+2+6 |
xor eax, eax |
xor edi, edi |
ret |
|
.arp_error: |
DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output: ARP error=%x\n", eax |
add esp, 3*4+2 |
xor eax, eax |
xor edi, edi |
ret |
|
.too_large: |
DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output: Packet too large!\n" |
xor eax, eax |
xor edi, edi |
ret |
|
.loopback: |
672,7 → 674,7 |
; ecx = data length |
; esi = data ptr |
; |
; OUT: eax = -1 on error |
; OUT: / |
; |
;------------------------------------------------------------------ |
align 4 |
696,13 → 698,15 |
push ax |
|
inc [IPv4_packets_tx + 4*edi] |
mov ax, ETHER_PROTO_IPv4 |
mov ebx, [NET_DRV_LIST + 4*edi] |
lea eax, [ebx + ETH_DEVICE.mac] |
mov edx, esp |
mov ecx, [esp + 6 + 4] |
add ecx, sizeof.IPv4_header |
mov edx, esp |
mov di, ETHER_PROTO_IPv4 |
call ETH_output |
jz .error |
|
add esp, 6 ; pop the mac |
|
mov dword[esp+4+4], edx |
741,7 → 745,7 |
add esp, 8+4+4 |
.too_large: |
DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output_raw: Failed\n" |
or eax, -1 |
sub edi, edi |
ret |
|
|
790,9 → 794,13 |
.new_fragment: |
DEBUGF DEBUG_NETWORK_VERBOSE, "Ipv4_fragment: new fragment" |
|
mov ax, ETHER_PROTO_IPv4 |
|
mov eax, [esp + 3*4] |
lea ebx, [esp + 4*4] |
mov di , ETHER_PROTO_IPv4 |
call ETH_output |
|
cmp edi, -1 |
jz .err |
|
; copy header |