Skip to content

Commit 7d7ef0e

Browse files
author
brentru
committed
run buf til pointer is at end
1 parent e0b3d23 commit 7d7ef0e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

adafruit_wiznet5k/adafruit_wiznet5k_dhcp.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,7 @@ def parse_dhcp_response(self, response_timeout): # pylint: disable=too-many-bran
264264

265265
# -- Parse Packet, VARIABLE -- #
266266
ptr = 240
267-
buff_remaining = len(_BUFF[240:])
268-
while buff_remaining > 0:
267+
while _BUFF[ptr] != OPT_END:
269268
if _BUFF[ptr] == MSG_TYPE:
270269
ptr += 1
271270
opt_len = _BUFF[ptr]
@@ -314,16 +313,17 @@ def parse_dhcp_response(self, response_timeout): # pylint: disable=too-many-bran
314313
ptr += 1
315314
self._t2 = int.from_bytes(_BUFF[ptr:ptr+opt_len], 'l')
316315
ptr += opt_len
317-
elif _BUFF[ptr] == OPT_END:
318-
break
319316
else:
320317
# We're not interested in this option
321318
ptr += 1
322319
opt_len = _BUFF[ptr]
323320
ptr += 1
324321
# no-op
325322
ptr += opt_len
326-
buff_remaining = ptr - buff_remaining
323+
324+
if self._debug:
325+
print("Msg Type: {}\nSubnet Mask: {}\n\
326+
DHCP Server ID:{}\n".format(msg_type, self.subnet_mask, self.dhcp_server_ip))
327327

328328
gc.collect()
329329
return msg_type, xid

0 commit comments

Comments
 (0)