update in ARP_IP_to_MAC function, if it needs to send an ARP request packet, the routine will change task until the reply is received, or the request has timed-out.

git-svn-id: svn://kolibrios.org@1258 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2009-11-09 16:52:58 +00:00
parent adec2ac083
commit 9206b5fc97

View File

@ -71,6 +71,7 @@ align 4
uglobal uglobal
NumARP dd ? NumARP dd ?
ARPTable rb ARP_ENTRY.size * ARP_TABLE_SIZE ARPTable rb ARP_ENTRY.size * ARP_TABLE_SIZE
ARP_PACKETS_TX rd MAX_NET_DEVICES ARP_PACKETS_TX rd MAX_NET_DEVICES
@ -162,27 +163,50 @@ ARP_IP_to_MAC:
push eax push eax
push word ARP_REQUEST_TTL pushw ARP_REQUEST_TTL
push word ARP_AWAITING_RESPONSE pushw ARP_AWAITING_RESPONSE
push dword 0 pushd 0
push word 0 pushw 0
push eax pushd eax
call ARP_add_entry call ARP_add_entry
cmp eax, -1 cmp eax, -1
je .full je .full
; <Some dirty test code>
; This piece of code waits for an ARP reply
mov ebx, eax
pop eax pop eax
push ebx
call ARP_create_request call ARP_create_request
push [timer_ticks]
add dword[esp], 100*ARP_REQUEST_TTL
DEBUGF 1,"Waiting for ARP reply, time: %x, entry:%u\n",[timer_ticks], [esp + 4]
.dirty_loop:
call change_task ; The ARP reply hasnt been received yet, tell the processor to do some other stuff first
mov eax, [esp + 4]
imul eax, ARP_ENTRY.size
add eax, ARPTable
cmp [eax + ARP_ENTRY.Status], ARP_VALID_MAPPING
je .gogogo
mov eax, [esp] ; Check if the reply hasnt timed-out yet
cmp [timer_ticks], eax
jl .dirty_loop
; </Some dirty test code>
or eax, -1
add esp, 8
ret ret
.found_it: .found_it:
add esi, ARP_ENTRY.MAC DEBUGF 1,"found MAC in ARPTable\n"
DEBUGF 1,"Found MAC! (%x-%x-%x-%x-%x-%x)\n",[esi+0]:2,[esi+1]:2,[esi+2]:2,[esi+3]:2,[esi+4]:2,[esi+5]:2 movzx eax, word [esi+ARP_ENTRY.MAC]
movzx eax, word [esi] mov ebx, dword[esi+ARP_ENTRY.MAC+2]
mov ebx, [esi+2]
ret ret
.full: .full:
@ -190,10 +214,17 @@ ARP_IP_to_MAC:
mov eax, -1 mov eax, -1
ret ret
.gogogo:
DEBUGF 1,"got ARP reply, time: %x\n",[timer_ticks]
mov ebx, dword[eax+ARP_ENTRY.MAC+2]
movzx eax, word [eax+ARP_ENTRY.MAC]
add esp, 8
ret
;--------------------------------------------------------------------------- ;---------------------------------------------------------------------------
; ;
; ARP_create_packet ; ARP_create_request
; ;
; IN: ip in eax ; IN: ip in eax
; ;
@ -376,7 +407,7 @@ ARP_add_entry:
inc [NumARP] inc [NumARP]
pop eax pop eax
DEBUGF 1,"New entry created: %u\n", eax
.exit: .exit:
DEBUGF 1,"Exiting\n" DEBUGF 1,"Exiting\n"
ret ARP_ENTRY.size ret ARP_ENTRY.size