diff --git a/dhcptest.py b/dhcptest.py index a52803d..6300a5c 100644 --- a/dhcptest.py +++ b/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(), ('',67)) + #packet = DHCPPack(); + #s.sendto(packet.pack(), ('',67)) - data, addr = sock.recvfrom(1024) + data, addr = s.recvfrom(1024) packet2 = DHCPPack(data) if packet2.op == 2: