1 | #!/usr/bin/env python |
---|
2 | # |
---|
3 | # pydhcplib |
---|
4 | # Copyright (C) 2005,2006 Mathieu Ignacio -- mignacio@april.org |
---|
5 | # |
---|
6 | # This file is part of pydhcplib. |
---|
7 | # Pydhcplib is free software; you can redistribute it and/or modify |
---|
8 | # it under the terms of the GNU General Public License as published by |
---|
9 | # the Free Software Foundation; either version 2 of the License, or |
---|
10 | # (at your option) any later version. |
---|
11 | # |
---|
12 | # This program is distributed in the hope that it will be useful, |
---|
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | # GNU General Public License for more details. |
---|
16 | # |
---|
17 | # You should have received a copy of the GNU General Public License |
---|
18 | # along with this program; if not, write to the Free Software |
---|
19 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
---|
20 | |
---|
21 | from pydhcplib.dhcp_packet import * |
---|
22 | from pydhcplib.dhcp_network import * |
---|
23 | |
---|
24 | |
---|
25 | netopt = {'client_listen_port':68, |
---|
26 | 'server_listen_port':67, |
---|
27 | 'listen_address':"0.0.0.0"} |
---|
28 | |
---|
29 | class Client(DhcpClient): |
---|
30 | def __init__(self, options): |
---|
31 | DhcpClient.__init__(self,options["listen_address"], |
---|
32 | options["client_listen_port"], |
---|
33 | options["server_listen_port"]) |
---|
34 | |
---|
35 | def HandleDhcpOffer(self, packet): |
---|
36 | packet.PrintHeaders() |
---|
37 | packet.PrintOptions() |
---|
38 | |
---|
39 | def HandleDhcpAck(self, packet): |
---|
40 | packet.PrintHeaders() |
---|
41 | packet.PrintOptions() |
---|
42 | |
---|
43 | def HandleDhcpNack(self, packet): |
---|
44 | packet.PrintHeaders() |
---|
45 | packet.PrintOptions() |
---|
46 | |
---|
47 | |
---|
48 | client = Client(netopt) |
---|
49 | |
---|
50 | while True : |
---|
51 | client.GetNextDhcpPacket() |
---|