forked from KolibriOS/kolibrios
ARP will now wait for reply/timeout if it needed to send an ARP request packet.
git-svn-id: svn://kolibrios.org@3203 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
edce644b61
commit
2d54529003
@ -363,6 +363,7 @@ ARP_output_request:
|
|||||||
;
|
;
|
||||||
; IN: esi = ptr to entry (can easily be made on the stack)
|
; IN: esi = ptr to entry (can easily be made on the stack)
|
||||||
; OUT: eax = entry #, -1 on error
|
; OUT: eax = entry #, -1 on error
|
||||||
|
; edi = ptr to newly created entry
|
||||||
;
|
;
|
||||||
;----------------------------------------------------------------- ; TODO: use a mutex
|
;----------------------------------------------------------------- ; TODO: use a mutex
|
||||||
align 4
|
align 4
|
||||||
@ -398,6 +399,7 @@ ARP_add_entry:
|
|||||||
mov ecx, sizeof.ARP_entry/2
|
mov ecx, sizeof.ARP_entry/2
|
||||||
rep movsw
|
rep movsw
|
||||||
inc [NumARP]
|
inc [NumARP]
|
||||||
|
sub edi, sizeof.ARP_entry
|
||||||
DEBUGF 1,"entry=%u\n", eax
|
DEBUGF 1,"entry=%u\n", eax
|
||||||
|
|
||||||
ret
|
ret
|
||||||
@ -498,36 +500,42 @@ ARP_IP_to_MAC:
|
|||||||
pushd eax ; ip
|
pushd eax ; ip
|
||||||
mov esi, esp
|
mov esi, esp
|
||||||
call ARP_add_entry
|
call ARP_add_entry
|
||||||
add esp, sizeof.ARP_entry
|
add esp, sizeof.ARP_entry ; clear the entry from stack
|
||||||
|
|
||||||
cmp eax, -1
|
cmp eax, -1 ; did ARP_add_entry fail?
|
||||||
je .full
|
je .full
|
||||||
|
|
||||||
; And send a request
|
mov esi, edi
|
||||||
pop edi eax
|
pop edi eax ; IP in eax, device number in edi, for ARP_output_request
|
||||||
call ARP_output_request ; IP in eax
|
|
||||||
;; TODO: check if driver could transmit packet
|
|
||||||
|
|
||||||
mov eax, -2 ; request send
|
push esi edi
|
||||||
ret
|
call ARP_output_request ; And send a request
|
||||||
|
pop edi esi
|
||||||
|
|
||||||
|
;-----------------------------------------------
|
||||||
|
; At this point, we got an ARP entry in the list
|
||||||
.found_it:
|
.found_it:
|
||||||
DEBUGF 1,"ARP_IP_to_MAC: found IP\n"
|
cmp [esi + ARP_entry.Status], ARP_VALID_MAPPING ; Does it have a MAC assigned?
|
||||||
cmp [esi + ARP_entry.Status], ARP_VALID_MAPPING
|
je .valid
|
||||||
jne .invalid
|
cmp [esi + ARP_entry.Status], ARP_AWAITING_RESPONSE ; Are we waiting for reply from remote end?
|
||||||
|
jne .give_up
|
||||||
|
push esi
|
||||||
|
mov esi, 10 ; wait 10 ms
|
||||||
|
call delay_ms
|
||||||
|
pop esi
|
||||||
|
jmp .found_it ; now check again
|
||||||
|
|
||||||
movzx eax, word [esi + ARP_entry.MAC]
|
.valid:
|
||||||
|
DEBUGF 1,"ARP_IP_to_MAC: found MAC\n"
|
||||||
|
movzx eax, word[esi + ARP_entry.MAC]
|
||||||
mov ebx, dword[esi + ARP_entry.MAC + 2]
|
mov ebx, dword[esi + ARP_entry.MAC + 2]
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.invalid:
|
|
||||||
DEBUGF 1,"ARP_IP_to_MAC: entry has no valid mapping!\n"
|
|
||||||
mov eax, -1
|
|
||||||
ret
|
|
||||||
|
|
||||||
.full:
|
.full:
|
||||||
DEBUGF 1,"ARP_IP_to_MAC: table is full!\n"
|
DEBUGF 1,"ARP_IP_to_MAC: table is full!\n"
|
||||||
add esp, 8
|
add esp, 8
|
||||||
|
.give_up:
|
||||||
|
DEBUGF 1,"ARP_IP_to_MAC: entry has no valid mapping!\n"
|
||||||
mov eax, -1
|
mov eax, -1
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user