Small fixes with dhcptest.py
This commit is contained in:
parent
80f6837d72
commit
4e24bd0f63
1 changed files with 8 additions and 8 deletions
16
dhcptest.py
16
dhcptest.py
|
@ -39,7 +39,7 @@ class DHCPPack:
|
|||
self.file = ""
|
||||
|
||||
def pack(self):
|
||||
return struct.unpack(DHCPPack.fmt,
|
||||
return struct.pack(DHCPPack.fmt,
|
||||
self.op,
|
||||
self.htype,
|
||||
self.hlen,
|
||||
|
@ -71,19 +71,19 @@ class DHCPPack:
|
|||
self.chaddr[5],
|
||||
self.chaddr[6],
|
||||
self.chaddr[7],
|
||||
self.sname,
|
||||
self.file)
|
||||
str.encode(self.sname),
|
||||
str.encode(self.file))
|
||||
|
||||
|
||||
def main():
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
s.bind(('',68))
|
||||
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
|
||||
s.bind(('',67))
|
||||
#s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
|
||||
|
||||
packet = DHCPPack();
|
||||
s.sendto(packet.pack(), ('<broadcast>',67))
|
||||
#packet = DHCPPack();
|
||||
#s.sendto(packet.pack(), ('<broadcast>',67))
|
||||
|
||||
data, addr = sock.recvfrom(1024)
|
||||
data, addr = s.recvfrom(1024)
|
||||
|
||||
packet2 = DHCPPack(data)
|
||||
if packet2.op == 2:
|
||||
|
|
Loading…
Reference in a new issue