Correct stats for UDP and ICMP.
git-svn-id: svn://kolibrios.org@3643 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
2d3f4f397a
commit
2b3ee8e109
@ -176,13 +176,13 @@ ARP_input:
|
|||||||
cmp ecx, sizeof.ARP_header
|
cmp ecx, sizeof.ARP_header
|
||||||
jb .exit
|
jb .exit
|
||||||
|
|
||||||
call NET_ptr_to_num
|
call NET_ptr_to_num4
|
||||||
cmp edi, -1
|
cmp edi, -1
|
||||||
jz .exit
|
jz .exit
|
||||||
|
|
||||||
inc [ARP_PACKETS_RX + 4*edi] ; update stats
|
inc [ARP_PACKETS_RX + edi] ; update stats
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: got packet from %u.%u.%u.%u through device %u\n",\
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: got packet from %u.%u.%u.%u (device*4=%u)\n",\
|
||||||
[edx + ARP_header.SenderIP]:1, [edx + ARP_header.SenderIP + 1]:1,\
|
[edx + ARP_header.SenderIP]:1, [edx + ARP_header.SenderIP + 1]:1,\
|
||||||
[edx + ARP_header.SenderIP + 2]:1, [edx + ARP_header.SenderIP + 3]:1, edi
|
[edx + ARP_header.SenderIP + 2]:1, [edx + ARP_header.SenderIP + 3]:1, edi
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ ARP_input:
|
|||||||
; First, check for IP collision
|
; First, check for IP collision
|
||||||
|
|
||||||
mov eax, [edx + ARP_header.SenderIP]
|
mov eax, [edx + ARP_header.SenderIP]
|
||||||
cmp eax, [IP_LIST + 4*edi]
|
cmp eax, [IP_LIST + edi]
|
||||||
je .collision
|
je .collision
|
||||||
|
|
||||||
;---------------------
|
;---------------------
|
||||||
@ -201,12 +201,12 @@ ARP_input:
|
|||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: It's a reply\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: It's a reply\n"
|
||||||
|
|
||||||
mov ecx, [ARP_entries_num + 4*edi]
|
mov ecx, [ARP_entries_num + edi]
|
||||||
test ecx, ecx
|
test ecx, ecx
|
||||||
jz .exit
|
jz .exit
|
||||||
|
|
||||||
mov esi, (ARP_TABLE_SIZE * sizeof.ARP_entry)
|
mov esi, edi
|
||||||
imul esi, edi
|
imul esi, (ARP_TABLE_SIZE * sizeof.ARP_entry)/4
|
||||||
add esi, ARP_table
|
add esi, ARP_table
|
||||||
.loop:
|
.loop:
|
||||||
cmp [esi + ARP_entry.IP], eax
|
cmp [esi + ARP_entry.IP], eax
|
||||||
@ -245,7 +245,7 @@ ARP_input:
|
|||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: its a request\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: its a request\n"
|
||||||
|
|
||||||
mov eax, [IP_LIST + 4*edi]
|
mov eax, [IP_LIST + edi]
|
||||||
cmp eax, [edx + ARP_header.TargetIP] ; Is it looking for my IP address?
|
cmp eax, [edx + ARP_header.TargetIP] ; Is it looking for my IP address?
|
||||||
jne .exit
|
jne .exit
|
||||||
|
|
||||||
@ -262,7 +262,7 @@ ARP_input:
|
|||||||
movsd ; Move sender IP to Dest IP
|
movsd ; Move sender IP to Dest IP
|
||||||
|
|
||||||
pop esi
|
pop esi
|
||||||
mov esi, [NET_DRV_LIST + 4*esi]
|
mov esi, [NET_DRV_LIST + esi]
|
||||||
lea esi, [esi + ETH_DEVICE.mac]
|
lea esi, [esi + ETH_DEVICE.mac]
|
||||||
lea edi, [edx + ARP_header.SenderMAC]
|
lea edi, [edx + ARP_header.SenderMAC]
|
||||||
movsd ; Copy MAC address from in MAC_LIST
|
movsd ; Copy MAC address from in MAC_LIST
|
||||||
@ -290,7 +290,7 @@ ARP_input:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
.collision:
|
.collision:
|
||||||
inc [ARP_CONFLICTS + 4*edi]
|
inc [ARP_CONFLICTS + edi]
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: IP address conflict detected!\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: IP address conflict detected!\n"
|
||||||
|
|
||||||
.exit:
|
.exit:
|
||||||
|
@ -223,8 +223,7 @@ IPv4_input: ; TODO: add IPv4
|
|||||||
;-----------------------------------
|
;-----------------------------------
|
||||||
; Check if destination IP is correct
|
; Check if destination IP is correct
|
||||||
|
|
||||||
call NET_ptr_to_num
|
call NET_ptr_to_num4
|
||||||
shl edi, 2
|
|
||||||
|
|
||||||
; check if it matches local ip (Using RFC1122 strong end system model)
|
; check if it matches local ip (Using RFC1122 strong end system model)
|
||||||
|
|
||||||
|
@ -57,9 +57,8 @@ ETH_input:
|
|||||||
mov ecx, [esp+4]
|
mov ecx, [esp+4]
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE,"ETH_input: size=%u\n", ecx
|
DEBUGF DEBUG_NETWORK_VERBOSE,"ETH_input: size=%u\n", ecx
|
||||||
cmp ecx, sizeof.ETH_header ;ETH_FRAME_MINIMUM
|
|
||||||
jb .dump
|
|
||||||
sub ecx, sizeof.ETH_header
|
sub ecx, sizeof.ETH_header
|
||||||
|
jb .dump
|
||||||
|
|
||||||
lea edx, [eax + sizeof.ETH_header]
|
lea edx, [eax + sizeof.ETH_header]
|
||||||
mov ax, [eax + ETH_header.Type]
|
mov ax, [eax + ETH_header.Type]
|
||||||
|
@ -156,9 +156,17 @@ ICMP_input:
|
|||||||
pop ecx edx
|
pop ecx edx
|
||||||
jne .checksum_mismatch
|
jne .checksum_mismatch
|
||||||
|
|
||||||
|
; Check packet type
|
||||||
|
|
||||||
cmp [edx + ICMP_header.Type], ICMP_ECHO ; Is this an echo request?
|
cmp [edx + ICMP_header.Type], ICMP_ECHO ; Is this an echo request?
|
||||||
jne .check_sockets
|
jne .check_sockets
|
||||||
|
|
||||||
|
; Update stats (and validate device ptr)
|
||||||
|
call NET_ptr_to_num4
|
||||||
|
cmp edi, -1
|
||||||
|
je .dump
|
||||||
|
inc [ICMP_PACKETS_RX + edi]
|
||||||
|
|
||||||
; We well re-use the packet so we can create the response as fast as possible
|
; We well re-use the packet so we can create the response as fast as possible
|
||||||
; Notice: this only works on pure ethernet
|
; Notice: this only works on pure ethernet
|
||||||
|
|
||||||
@ -166,14 +174,6 @@ ICMP_input:
|
|||||||
mov [edx + ICMP_header.Type], ICMP_ECHOREPLY ; Change Packet type to reply
|
mov [edx + ICMP_header.Type], ICMP_ECHOREPLY ; Change Packet type to reply
|
||||||
|
|
||||||
mov esi, [esp] ; Start of buffer
|
mov esi, [esp] ; Start of buffer
|
||||||
|
|
||||||
; Update stats (and validate device ptr)
|
|
||||||
call NET_ptr_to_num
|
|
||||||
cmp edi, -1
|
|
||||||
je .dump
|
|
||||||
inc [ICMP_PACKETS_RX + 4*edi]
|
|
||||||
inc [ICMP_PACKETS_TX + 4*edi]
|
|
||||||
|
|
||||||
cmp ebx, LOOPBACK_DEVICE
|
cmp ebx, LOOPBACK_DEVICE
|
||||||
je .loopback
|
je .loopback
|
||||||
|
|
||||||
@ -225,6 +225,11 @@ ICMP_input:
|
|||||||
|
|
||||||
; Transmit the packet (notice that packet ptr and packet size have been on stack since start of the procedure!)
|
; Transmit the packet (notice that packet ptr and packet size have been on stack since start of the procedure!)
|
||||||
call [ebx + NET_DEVICE.transmit]
|
call [ebx + NET_DEVICE.transmit]
|
||||||
|
test eax, eax
|
||||||
|
jnz @f
|
||||||
|
call NET_ptr_to_num4
|
||||||
|
inc [UDP_PACKETS_TX + edi]
|
||||||
|
@@:
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
@ -254,10 +259,11 @@ ICMP_input:
|
|||||||
; cmp [eax + ICMP_SOCKET.Identifier],
|
; cmp [eax + ICMP_SOCKET.Identifier],
|
||||||
; jne .next_socket
|
; jne .next_socket
|
||||||
|
|
||||||
; call IPv4_dest_to_dev
|
; Update stats (and validate device ptr)
|
||||||
; cmp edi,-1
|
call NET_ptr_to_num4
|
||||||
; je .dump
|
cmp edi, -1
|
||||||
; inc [ICMP_PACKETS_RX+edi]
|
je .dump
|
||||||
|
inc [ICMP_PACKETS_RX + edi]
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "socket=%x\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "socket=%x\n", eax
|
||||||
|
|
||||||
@ -336,6 +342,11 @@ ICMP_output:
|
|||||||
push edx edi
|
push edx edi
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "Sending ICMP Packet\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "Sending ICMP Packet\n"
|
||||||
call [ebx + NET_DEVICE.transmit]
|
call [ebx + NET_DEVICE.transmit]
|
||||||
|
test eax, eax
|
||||||
|
jnz @f
|
||||||
|
call NET_ptr_to_num4
|
||||||
|
inc [ICMP_PACKETS_TX + edi]
|
||||||
|
@@:
|
||||||
ret
|
ret
|
||||||
.exit:
|
.exit:
|
||||||
DEBUGF DEBUG_NETWORK_ERROR, "Creating ICMP Packet failed\n"
|
DEBUGF DEBUG_NETWORK_ERROR, "Creating ICMP Packet failed\n"
|
||||||
@ -386,6 +397,11 @@ ICMP_output_raw:
|
|||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "Sending ICMP Packet\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "Sending ICMP Packet\n"
|
||||||
call [ebx + NET_DEVICE.transmit]
|
call [ebx + NET_DEVICE.transmit]
|
||||||
|
test eax, eax
|
||||||
|
jnz @f
|
||||||
|
call NET_ptr_to_num4
|
||||||
|
inc [ICMP_PACKETS_TX + edi]
|
||||||
|
@@:
|
||||||
ret
|
ret
|
||||||
.exit:
|
.exit:
|
||||||
DEBUGF DEBUG_NETWORK_ERROR, "Creating ICMP Packet failed\n"
|
DEBUGF DEBUG_NETWORK_ERROR, "Creating ICMP Packet failed\n"
|
||||||
|
@ -450,29 +450,33 @@ NET_remove_device:
|
|||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------
|
||||||
align 4
|
align 4
|
||||||
NET_ptr_to_num:
|
NET_ptr_to_num:
|
||||||
|
|
||||||
|
call NET_ptr_to_num4
|
||||||
|
ror edi, 2 ; If -1, stay -1
|
||||||
|
; valid device numbers have last two bits 0, so do just shr
|
||||||
|
|
||||||
|
ret
|
||||||
|
|
||||||
|
align 4
|
||||||
|
NET_ptr_to_num4: ; Todo, place number in device structure so we only need to verify?
|
||||||
|
|
||||||
push ecx
|
push ecx
|
||||||
|
|
||||||
mov ecx, NET_DEVICES_MAX
|
mov ecx, NET_DEVICES_MAX
|
||||||
mov edi, NET_DRV_LIST
|
mov edi, NET_DRV_LIST
|
||||||
|
|
||||||
.loop:
|
.loop:
|
||||||
cmp ebx, [edi]
|
cmp ebx, [edi]
|
||||||
jz .found
|
je .found
|
||||||
add edi, 4
|
add edi, 4
|
||||||
dec ecx
|
dec ecx
|
||||||
jnz .loop
|
jnz .loop
|
||||||
|
|
||||||
; repnz scasd could work too if eax is used instead of ebx!
|
|
||||||
|
|
||||||
or edi, -1
|
or edi, -1
|
||||||
|
|
||||||
pop ecx
|
pop ecx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.found:
|
.found:
|
||||||
sub edi, NET_DRV_LIST
|
sub edi, NET_DRV_LIST
|
||||||
shr edi, 2
|
|
||||||
|
|
||||||
pop ecx
|
pop ecx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
@ -182,7 +182,8 @@ UDP_input:
|
|||||||
popa
|
popa
|
||||||
|
|
||||||
.updatesock:
|
.updatesock:
|
||||||
inc [UDP_PACKETS_RX] ; Fixme: correct interface?
|
call NET_ptr_to_num4
|
||||||
|
inc [UDP_PACKETS_RX + edi]
|
||||||
|
|
||||||
movzx ecx, [esi + UDP_header.Length]
|
movzx ecx, [esi + UDP_header.Length]
|
||||||
sub ecx, sizeof.UDP_header
|
sub ecx, sizeof.UDP_header
|
||||||
@ -274,7 +275,8 @@ UDP_output:
|
|||||||
call [ebx + NET_DEVICE.transmit]
|
call [ebx + NET_DEVICE.transmit]
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jnz @f
|
jnz @f
|
||||||
inc [UDP_PACKETS_TX] ; FIXME: correct device?
|
call NET_ptr_to_num4
|
||||||
|
inc [UDP_PACKETS_TX + edi]
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
Loading…
Reference in New Issue
Block a user