|
@@ -1,4 +1,3 @@
|
1
|
|
-#! /usr/bin/env python
|
2
|
1
|
from dhcp_packet import *
|
3
|
2
|
import socket
|
4
|
3
|
import random
|
|
@@ -11,13 +10,13 @@ import time
|
11
|
10
|
class DhcpClient:
|
12
|
11
|
def send_packet(self, mac, iface, xid):
|
13
|
12
|
dhcp = DhcpPacket()
|
14
|
|
- dhcp.SetOption('op', [1]);
|
15
|
|
- dhcp.SetOption('htype', [1]);
|
16
|
|
- dhcp.SetOption('hlen', [6]);
|
17
|
|
- dhcp.SetOption('xid', xid);
|
18
|
|
- dhcp.SetOption('chaddr', hwmac(mac).list());
|
19
|
|
- dhcp.SetOption('dhcp_message_type', [1]);
|
20
|
|
- dhcp.SetOption('parameter_request_list', [12]);
|
|
13
|
+ dhcp.SetOption('op', [1])
|
|
14
|
+ dhcp.SetOption('htype', [1])
|
|
15
|
+ dhcp.SetOption('hlen', [6])
|
|
16
|
+ dhcp.SetOption('xid', xid)
|
|
17
|
+ dhcp.SetOption('chaddr', hwmac(mac).list())
|
|
18
|
+ dhcp.SetOption('dhcp_message_type', [1])
|
|
19
|
+ dhcp.SetOption('parameter_request_list', [12])
|
21
|
20
|
|
22
|
21
|
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
23
|
22
|
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|