Refactored recent ARP code a bit.
git-svn-id: svn://kolibrios.org@3160 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
72dc4ba124
commit
3341bc3ceb
@ -164,12 +164,28 @@ local .exit
|
|||||||
align 4
|
align 4
|
||||||
ARP_input:
|
ARP_input:
|
||||||
|
|
||||||
|
;-----------------------------------------
|
||||||
|
; Check validity and print some debug info
|
||||||
|
|
||||||
|
cmp ecx, sizeof.ARP_header
|
||||||
|
jb .exit
|
||||||
|
|
||||||
call NET_ptr_to_num
|
call NET_ptr_to_num
|
||||||
cmp edi, -1
|
cmp edi, -1
|
||||||
jz .exit
|
jz .exit
|
||||||
|
|
||||||
cmp ecx, sizeof.ARP_header
|
inc [ARP_PACKETS_RX + 4*edi] ; update stats
|
||||||
jb .exit
|
|
||||||
|
DEBUGF 1,"ARP_input: got packet from %u.%u.%u.%u through device %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
|
||||||
|
|
||||||
|
;------------------------------
|
||||||
|
; First, check for IP collision
|
||||||
|
|
||||||
|
mov eax, [edx + ARP_header.SenderIP]
|
||||||
|
cmp eax, [IP_LIST + 4*edi]
|
||||||
|
je .collision
|
||||||
|
|
||||||
;---------------------
|
;---------------------
|
||||||
; Handle reply packets
|
; Handle reply packets
|
||||||
@ -177,19 +193,12 @@ ARP_input:
|
|||||||
cmp [edx + ARP_header.Opcode], ARP_REP_OPCODE
|
cmp [edx + ARP_header.Opcode], ARP_REP_OPCODE
|
||||||
jne .maybe_request
|
jne .maybe_request
|
||||||
|
|
||||||
DEBUGF 1,"ARP_input: got reply packet from %u.%u.%u.%u\n",\
|
DEBUGF 1,"ARP_input: It's a reply\n"
|
||||||
[edx + ARP_header.SenderIP]:1, [edx + ARP_header.SenderIP + 1]:1,\
|
|
||||||
[edx + ARP_header.SenderIP + 2]:1, [edx + ARP_header.SenderIP + 3]:1
|
|
||||||
|
|
||||||
inc [ARP_PACKETS_RX + 4*edi]
|
|
||||||
|
|
||||||
mov ecx, [NumARP]
|
mov ecx, [NumARP]
|
||||||
test ecx, ecx
|
test ecx, ecx
|
||||||
jz .exit
|
jz .exit
|
||||||
|
|
||||||
mov eax, [edx + ARP_header.SenderIP]
|
|
||||||
cmp eax, [IP_LIST + 4*edi] ; check for IP collision
|
|
||||||
je .collision
|
|
||||||
mov esi, ARP_table
|
mov esi, ARP_table
|
||||||
.loop:
|
.loop:
|
||||||
cmp [esi + ARP_entry.IP], eax
|
cmp [esi + ARP_entry.IP], eax
|
||||||
@ -219,11 +228,6 @@ ARP_input:
|
|||||||
|
|
||||||
jmp .exit
|
jmp .exit
|
||||||
|
|
||||||
.collision:
|
|
||||||
DEBUGF 1,"ARP_input: IP address conflict detected!\n"
|
|
||||||
|
|
||||||
jmp .exit
|
|
||||||
|
|
||||||
;-----------------------
|
;-----------------------
|
||||||
; Handle request packets
|
; Handle request packets
|
||||||
|
|
||||||
@ -231,8 +235,7 @@ ARP_input:
|
|||||||
cmp [edx + ARP_header.Opcode], ARP_REQ_OPCODE
|
cmp [edx + ARP_header.Opcode], ARP_REQ_OPCODE
|
||||||
jne .exit
|
jne .exit
|
||||||
|
|
||||||
DEBUGF 1,"ARP_input: got request packet through device: %u\n", edi
|
DEBUGF 1,"ARP_input: its a request\n"
|
||||||
inc [ARP_PACKETS_RX + 4*edi]
|
|
||||||
|
|
||||||
mov eax, [IP_LIST + 4*edi]
|
mov eax, [IP_LIST + 4*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?
|
||||||
@ -278,6 +281,9 @@ ARP_input:
|
|||||||
call [ebx + NET_DEVICE.transmit]
|
call [ebx + NET_DEVICE.transmit]
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
.collision:
|
||||||
|
DEBUGF 1,"ARP_input: IP address conflict detected!\n"
|
||||||
|
|
||||||
.exit:
|
.exit:
|
||||||
call kernel_free
|
call kernel_free
|
||||||
add esp, 4 ; pop (balance stack)
|
add esp, 4 ; pop (balance stack)
|
||||||
|
Loading…
Reference in New Issue
Block a user