From 4e5d780fbda718cc6adaa480b4ed27f4e836f555 Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Mon, 31 Mar 2008 19:47:09 -0400 Subject: [PATCH] Fix the DHCP server (fixes #44) svn path=/trunk/packages/sipb-xen-dhcp/; revision=377 --- code/dhcpserver.py | 23 +++++++++++++++++++---- debian/changelog | 7 +++++++ debian/control | 2 +- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/code/dhcpserver.py b/code/dhcpserver.py index bcc02d4..b4f39af 100755 --- a/code/dhcpserver.py +++ b/code/dhcpserver.py @@ -22,7 +22,6 @@ from sqlalchemy import create_engine dhcp_options = {'subnet_mask': '255.255.0.0', 'router': '18.181.0.1', 'domain_name_server': '18.70.0.160,18.71.0.151,18.72.0.3', - 'domain_name': 'mit.edu', 'ip_address_lease_time': 60*60*24} class DhcpBackend: @@ -95,7 +94,16 @@ class DhcpBackend: elif option_type == "string" : options[parameter] = strlist(value).list() + + elif option_type == "RFC3397" : + parsed_value = "" + for item in value: + components = item.split('.') + item_fmt = "".join(chr(len(elt)) + elt for elt in components) + "\x00" + parsed_value += item_fmt + options[parameter] = strlist(parsed_value).list() + else : options[parameter] = strlist(value).list() return options @@ -109,16 +117,23 @@ class DhcpBackend: ip = nic.ip if ip is None: #Deactivated? return False + + options = {} if nic.hostname and '.' in nic.hostname: - hostname = nic.hostname + options['host_name'], options['domain_name'] = nic.hostname.split('.', 1) elif nic.machine.name: - hostname = nic.machine.name + '.servers.csail.mit.edu' + options['host_name'] = nic.machine.name + options['domain_name'] = 'servers.csail.mit.edu' else: hostname = None + if DhcpOptions['domain_search'] in packet.GetOption('parameter_request_list'): + options['host_name'] += '.' + options['domain_name'] + del options['domain_name'] + options['domain_search'] = ['mit.edu'] if ip is not None: ip = ipv4(ip) Log.Output(Log.debug,"dhcp_backend : Discover result = "+str(ip)) - packet_parameters = self.getParameters(host_name=hostname) + packet_parameters = self.getParameters(**options) # FIXME: Other offer parameters go here packet_parameters["yiaddr"] = ip.list() diff --git a/debian/changelog b/debian/changelog index bf1f318..8763b09 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +sipb-xen-dhcp (2) unstable; urgency=low + + * DHCP server should send information to set correct information + (fixes #44) + + -- SIPB Xen Projet Mon, 31 Mar 2008 19:43:00 -0400 + sipb-xen-dhcp (1.1) unstable; urgency=low * Split off pydhcplib into its own package and add that as a dependency diff --git a/debian/control b/debian/control index bf2a18e..fae2da7 100644 --- a/debian/control +++ b/debian/control @@ -7,5 +7,5 @@ Standards-Version: 3.7.2 Package: sipb-xen-dhcp Architecture: all -Depends: ${misc:Depends}, daemon, sipb-xen-database-common, sipb-xen-python-pydhcplib +Depends: ${misc:Depends}, daemon, sipb-xen-database-common, sipb-xen-python-pydhcplib (>= 0.3.2-2) Description: Install and enable the DHCP server -- 1.7.9.5