Changes to get Bootp working with udhcpd

Zachary P. Landau kapheine at gmail.com
Wed Mar 8 01:32:19 UTC 2006


Hello,

Today I tried to get the bootp support working in udhcpd and had some
trouble.  The problem came down to dhcpd.c calling get_option with
DHCP_MESSAGE_TYPE.  get_option looks in the option field of the bootp
packet, which obviously doesn't include this.  I wrote a little kludge
that will send a BOOTREQUEST message in its place if a
DHCP_MESSAGE_TYPE isn't found in the packet.  I'm hoping someone
here might have a better idea for how to handle this?

I did basic testing with both bootp and dhcp with this patch applied and both
work.

--
Zachary P. Landau <kapheine at gmail.com>
-------------- next part --------------
diff -urN busybox-1.1.0.orig/networking/udhcp/options.c busybox-1.1.0/networking/udhcp/options.c
--- busybox-1.1.0.orig/networking/udhcp/options.c	2006-01-11 00:43:50.000000000 -0500
+++ busybox-1.1.0/networking/udhcp/options.c	2006-03-07 19:25:29.000000000 -0500
@@ -60,6 +60,8 @@
 };
 
 
+uint8_t state[1];
+
 /* get an option with bounds checking (warning, not aligned). */
 uint8_t *get_option(struct dhcpMessage *packet, int code)
 {
@@ -111,7 +113,15 @@
 			i += optionptr[OPT_LEN + i] + 2;
 		}
 	}
-	return NULL;
+
+    /* If we didn't find a match for a DHCP_MESSAGE_TYPE, assume it
+     * was a BOOTP request */
+    if (code == DHCP_MESSAGE_TYPE) {
+        state[0] = BOOTREQUEST;
+        return state;
+    } else {
+        return NULL;
+    }
 }
 
 









More information about the busybox mailing list