Zeroconf: try 3 times to contact DHCP server before giving up.

git-svn-id: svn://kolibrios.org@3632 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2013-06-10 13:25:07 +00:00
parent afab73e955
commit 256b125f00

View File

@ -20,8 +20,9 @@ format binary as ""
; CONFIGURATION ; CONFIGURATION
TIMEOUT = 60 ; in seconds TIMEOUT = 3 ; in seconds
BUFFER = 1024 ; in bytes BUFFER = 1024 ; in bytes
DHCP_TRIES = 3 ; number of times to try contacting DHCP server
__DEBUG__ = 1 ; enable/disable __DEBUG__ = 1 ; enable/disable
__DEBUG_LEVEL__ = 1 ; 1 = all, 2 = errors __DEBUG_LEVEL__ = 1 ; 1 = all, 2 = errors
@ -194,6 +195,8 @@ START:
try_dhcp: try_dhcp:
mov [tries], DHCP_TRIES
DEBUGF 1,"->Trying DHCP\n" DEBUGF 1,"->Trying DHCP\n"
mcall 75, 0, AF_INET4, SOCK_DGRAM, 0 ; open socket (parameters: domain, type, reserved) mcall 75, 0, AF_INET4, SOCK_DGRAM, 0 ; open socket (parameters: domain, type, reserved)
@ -287,21 +290,21 @@ request_options:
mov [dhcpMsgLen], dword 268 mov [dhcpMsgLen], dword 268
send_dhcpmsg: send_dhcpmsg:
DEBUGF 1,"Sending DHCP request\n"
mcall 75, 6, [socketNum], [dhcpMsg], [dhcpMsgLen] ; write to socket ( send broadcast request ) mcall 75, 6, [socketNum], [dhcpMsg], [dhcpMsgLen] ; write to socket ( send broadcast request )
mcall 23, TIMEOUT*100 ; wait for data
mov eax, [dhcpMsg] ; Setup the DHCP buffer to receive response
mov [dhcpMsgLen], eax ; Used as a pointer to the data
mcall 23, TIMEOUT*10 ; wait for data
read_data: ; we have data - this will be the response read_data: ; we have data - this will be the response
mcall 75, 7, [socketNum], [dhcpMsg], BUFFER, 0 ; read data from socket mcall 75, 7, [socketNum], [dhcpMsg], BUFFER, 0 ; read data from socket
DEBUGF 1,"->%d bytes received\n", eax
cmp eax, -1 cmp eax, -1
je dhcp_error jne @f
DEBUGF 1,"No answer from DHCP server\n"
dec [tries]
jnz send_dhcpmsg ; try again
jmp dhcp_error ; fail
@@:
DEBUGF 1,"->%d bytes received\n", eax
mov [dhcpMsgLen], eax mov [dhcpMsgLen], eax
; depending on which msg we sent, handle the response ; depending on which msg we sent, handle the response
@ -612,6 +615,7 @@ IM_END:
device db 1 device db 1
inibuf rb 16 inibuf rb 16
tries db ?
dhcpMsgType db ? dhcpMsgType db ?
dhcpLease dd ? dhcpLease dd ?