- ether = rxq.recv(2)
-
- if ether is None:
- raise RuntimeError('DHCP DISCOVER timeout')
-
- if ether[UDP].dport != UDP_SERVICES.bootps:
- raise RuntimeError("UDP destination port error.")
- print "UDP destination port: OK."
-
- if ether[UDP].sport != UDP_SERVICES.bootpc:
- raise RuntimeError("UDP source port error.")
- print "UDP source port: OK."
-
- if ether[DHCP].options[0][1] != 1: # 1 - DISCOVER message
- raise RuntimeError("DHCP DISCOVER message error.")
- print "DHCP DISCOVER message OK."
+ for _ in range(10):
+ dhcp_discover = rxq.recv(2)
+ if is_discover(dhcp_discover):
+ break
+ else:
+ raise RuntimeError("DHCP DISCOVER Rx timeout")