forked from KolibriOS/kolibrios
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
|
||||
jb .exit
|
||||
|
||||
call NET_ptr_to_num
|
||||
call NET_ptr_to_num4
|
||||
cmp edi, -1
|
||||
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 + 2]:1, [edx + ARP_header.SenderIP + 3]:1, edi
|
||||
|
||||
@ -190,7 +190,7 @@ ARP_input:
|
||||
; First, check for IP collision
|
||||
|
||||
mov eax, [edx + ARP_header.SenderIP]
|
||||
cmp eax, [IP_LIST + 4*edi]
|
||||
cmp eax, [IP_LIST + edi]
|
||||
je .collision
|
||||
|
||||
;---------------------
|
||||
@ -201,12 +201,12 @@ ARP_input:
|
||||
|
||||
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
|
||||
jz .exit
|
||||
|
||||
mov esi, (ARP_TABLE_SIZE * sizeof.ARP_entry)
|
||||
imul esi, edi
|
||||
mov esi, edi
|
||||
imul esi, (ARP_TABLE_SIZE * sizeof.ARP_entry)/4
|
||||
add esi, ARP_table
|
||||
.loop:
|
||||
cmp [esi + ARP_entry.IP], eax
|
||||
@ -245,7 +245,7 @@ ARP_input:
|
||||
|
||||
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?
|
||||
jne .exit
|
||||
|
||||
@ -262,7 +262,7 @@ ARP_input:
|
||||
movsd ; Move sender IP to Dest IP
|
||||
|
||||
pop esi
|
||||
mov esi, [NET_DRV_LIST + 4*esi]
|
||||
mov esi, [NET_DRV_LIST + esi]
|
||||
lea esi, [esi + ETH_DEVICE.mac]
|
||||
lea edi, [edx + ARP_header.SenderMAC]
|
||||
movsd ; Copy MAC address from in MAC_LIST
|
||||
@ -290,7 +290,7 @@ ARP_input:
|
||||
ret
|
||||
|
||||
.collision:
|
||||
inc [ARP_CONFLICTS + 4*edi]
|
||||
inc [ARP_CONFLICTS + edi]
|
||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: IP address conflict detected!\n"
|
||||
|
||||
.exit:
|
||||
|
@ -223,8 +223,7 @@ IPv4_input: ; TODO: add IPv4
|
||||
;-----------------------------------
|
||||
; Check if destination IP is correct
|
||||
|
||||
call NET_ptr_to_num
|
||||
shl edi, 2
|
||||
call NET_ptr_to_num4
|
||||
|
||||
; check if it matches local ip (Using RFC1122 strong end system model)
|
||||
|
||||
|
@ -57,9 +57,8 @@ ETH_input:
|
||||
mov ecx, [esp+4]
|
||||
|
||||
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
|
||||
jb .dump
|
||||
|
||||
lea edx, [eax + sizeof.ETH_header]
|
||||
mov ax, [eax + ETH_header.Type]
|
||||
|
@ -156,9 +156,17 @@ ICMP_input:
|
||||
pop ecx edx
|
||||
jne .checksum_mismatch
|
||||
|
||||
; Check packet type
|
||||
|
||||
cmp [edx + ICMP_header.Type], ICMP_ECHO ; Is this an echo request?
|
||||
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
|
||||
; 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 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
|
||||
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!)
|
||||
call [ebx + NET_DEVICE.transmit]
|
||||
test eax, eax
|
||||
jnz @f
|
||||
call NET_ptr_to_num4
|
||||
inc [UDP_PACKETS_TX + edi]
|
||||
@@:
|
||||
ret
|
||||
|
||||
|
||||
@ -254,10 +259,11 @@ ICMP_input:
|
||||
; cmp [eax + ICMP_SOCKET.Identifier],
|
||||
; jne .next_socket
|
||||
|
||||
; call IPv4_dest_to_dev
|
||||
; cmp edi,-1
|
||||
; je .dump
|
||||
; inc [ICMP_PACKETS_RX+edi]
|
||||
; Update stats (and validate device ptr)
|
||||
call NET_ptr_to_num4
|
||||
cmp edi, -1
|
||||
je .dump
|
||||
inc [ICMP_PACKETS_RX + edi]
|
||||
|
||||
DEBUGF DEBUG_NETWORK_VERBOSE, "socket=%x\n", eax
|
||||
|
||||
@ -336,6 +342,11 @@ ICMP_output:
|
||||
push edx edi
|
||||
DEBUGF DEBUG_NETWORK_VERBOSE, "Sending ICMP Packet\n"
|
||||
call [ebx + NET_DEVICE.transmit]
|
||||
test eax, eax
|
||||
jnz @f
|
||||
call NET_ptr_to_num4
|
||||
inc [ICMP_PACKETS_TX + edi]
|
||||
@@:
|
||||
ret
|
||||
.exit:
|
||||
DEBUGF DEBUG_NETWORK_ERROR, "Creating ICMP Packet failed\n"
|
||||
@ -386,6 +397,11 @@ ICMP_output_raw:
|
||||
|
||||
DEBUGF DEBUG_NETWORK_VERBOSE, "Sending ICMP Packet\n"
|
||||
call [ebx + NET_DEVICE.transmit]
|
||||
test eax, eax
|
||||
jnz @f
|
||||
call NET_ptr_to_num4
|
||||
inc [ICMP_PACKETS_TX + edi]
|
||||
@@:
|
||||
ret
|
||||
.exit:
|
||||
DEBUGF DEBUG_NETWORK_ERROR, "Creating ICMP Packet failed\n"
|
||||
|
@ -450,29 +450,33 @@ NET_remove_device:
|
||||
;-----------------------------------------------------------------
|
||||
align 4
|
||||
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
|
||||
|
||||
mov ecx, NET_DEVICES_MAX
|
||||
mov edi, NET_DRV_LIST
|
||||
|
||||
.loop:
|
||||
cmp ebx, [edi]
|
||||
jz .found
|
||||
je .found
|
||||
add edi, 4
|
||||
dec ecx
|
||||
jnz .loop
|
||||
|
||||
; repnz scasd could work too if eax is used instead of ebx!
|
||||
|
||||
or edi, -1
|
||||
|
||||
pop ecx
|
||||
ret
|
||||
|
||||
.found:
|
||||
sub edi, NET_DRV_LIST
|
||||
shr edi, 2
|
||||
|
||||
pop ecx
|
||||
ret
|
||||
|
||||
|
@ -182,7 +182,8 @@ UDP_input:
|
||||
popa
|
||||
|
||||
.updatesock:
|
||||
inc [UDP_PACKETS_RX] ; Fixme: correct interface?
|
||||
call NET_ptr_to_num4
|
||||
inc [UDP_PACKETS_RX + edi]
|
||||
|
||||
movzx ecx, [esi + UDP_header.Length]
|
||||
sub ecx, sizeof.UDP_header
|
||||
@ -274,7 +275,8 @@ UDP_output:
|
||||
call [ebx + NET_DEVICE.transmit]
|
||||
test eax, eax
|
||||
jnz @f
|
||||
inc [UDP_PACKETS_TX] ; FIXME: correct device?
|
||||
call NET_ptr_to_num4
|
||||
inc [UDP_PACKETS_TX + edi]
|
||||
@@:
|
||||
|
||||
ret
|
||||
|
Loading…
Reference in New Issue
Block a user