source: trunk/packages/sipb-xen-python-pydhcplib/examples/server_example.py @ 650

Last change on this file since 650 was 361, checked in by broder, 17 years ago

Splitting pydhcplib off into its own package

Hold onto your hats, folks - this could get messy

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