MCPcopy Create free account
hub / github.com/ActiveState/code / unpack

Method unpack

recipes/Python/577649_dhcp_query/recipe-577649.py:69–79  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

67 self.unpack()
68
69 def unpack(self):
70 if self.data[4:8] == self.transID :
71 self.offerIP = '.'.join(map(lambda x:str(x), data[16:20]))
72 self.nextServerIP = '.'.join(map(lambda x:str(x), data[20:24])) #c'est une option
73 self.DHCPServerIdentifier = '.'.join(map(lambda x:str(x), data[245:249]))
74 self.leaseTime = str(struct.unpack('!L', data[251:255])[0])
75 self.router = '.'.join(map(lambda x:str(x), data[257:261]))
76 self.subnetMask = '.'.join(map(lambda x:str(x), data[263:267]))
77 dnsNB = int(data[268]/4)
78 for i in range(0, 4 * dnsNB, 4):
79 self.DNS.append('.'.join(map(lambda x:str(x), data[269 + i :269 + i + 4])))
80
81 def printOffer(self):
82 key = ['DHCP Server', 'Offered IP address', 'subnet mask', 'lease time (s)' , 'default gateway']

Callers 9

__init__Method · 0.95
readMethod · 0.45
unpack_pycFunction · 0.45
_ip42intFunction · 0.45
recipe-577546.pyFile · 0.45
handleMethod · 0.45
_get_recordMethod · 0.45
serveclientFunction · 0.45
getStatsFunction · 0.45

Calls 5

mapFunction · 0.85
strFunction · 0.85
rangeFunction · 0.85
joinMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected