From 4e24bd0f6307064414fc7eef4df0aaef778e0841 Mon Sep 17 00:00:00 2001 From: Valentin Gehrke Date: Mon, 30 May 2016 13:20:54 +0200 Subject: [PATCH] Small fixes with dhcptest.py --- dhcptest.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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: