@@ -296,9 +296,9 @@ def parse_dhcp_response(self, response_timeout): # pylint: disable=too-many-bran
296
296
self .gateway_ip = _BUFF [ptr :ptr + opt_len ]
297
297
ptr += opt_len
298
298
elif _BUFF [ptr ] == DNS_SERVERS :
299
- ptr += 2 # move past length
300
- # NOTE: we're only using the first DNS server
299
+ ptr += 1
301
300
opt_len = _BUFF [ptr ]
301
+ ptr += 1
302
302
self .dns_server_ip = _BUFF [ptr :ptr + 4 ]
303
303
ptr += opt_len # still increment even though we only read 1 addr.
304
304
elif _BUFF [ptr ] == T1_VAL :
@@ -333,7 +333,7 @@ def parse_dhcp_response(self, response_timeout): # pylint: disable=too-many-bran
333
333
gc .collect ()
334
334
return msg_type , xid
335
335
336
- def request_dhcp_lease (self ): # pylint: disable=too-many-branches
336
+ def request_dhcp_lease (self ): # pylint: disable=too-many-branches, too-many-statements
337
337
"""Request to renew or acquire a DHCP lease.
338
338
339
339
"""
@@ -365,6 +365,8 @@ def request_dhcp_lease(self): # pylint: disable=too-many-branches
365
365
print ("* DHCP: Request" )
366
366
self .send_dhcp_message (DHCP_REQUEST , ((time .monotonic () - start_time ) / 1000 ))
367
367
self ._dhcp_state = STATE_DHCP_REQUEST
368
+ else :
369
+ print ("* Received DHCP Message is not OFFER" )
368
370
elif STATE_DHCP_REQUEST :
369
371
if self ._debug :
370
372
print ("* DHCP: Parsing ACK" )
@@ -384,6 +386,8 @@ def request_dhcp_lease(self): # pylint: disable=too-many-branches
384
386
self ._rebind_in_sec = self ._t2
385
387
elif msg_type == DHCP_NAK :
386
388
self ._dhcp_state = STATE_DHCP_START
389
+ else :
390
+ print ("* Received DHCP Message is not OFFER" )
387
391
388
392
if msg_type == 255 :
389
393
msg_type = 0
0 commit comments