source: trunk/packages/python-pydhcplib/examples/client_example.py @ 3039

Last change on this file since 3039 was 1191, checked in by broder, 16 years ago

Strip the sipb-xen prefix from packages we didn't write

  • Property svn:executable set to *
File size: 1.6 KB
Line 
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
21from pydhcplib.dhcp_packet import *
22from pydhcplib.dhcp_network import *
23
24
25netopt = {'client_listen_port':68,
26           'server_listen_port':67,
27           'listen_address':"0.0.0.0"}
28
29class 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
48client = Client(netopt)
49
50while True :
51    client.GetNextDhcpPacket()
Note: See TracBrowser for help on using the repository browser.