OpenWrt Forum Archive

Topic: [patch] adding options to udhcpc

The content of this topic has been archived on 2 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi all,

Dnsmasq supports the "vendorclass" (60), "clientid" (61) and "userclass" (77) DHCP options being sent from DHCP clients.  But the busybox udhcp client by default does not support sending these options to the server.

It would be nice if the udhcp client has these options as it would be then possible to set up dnsmasq to serve different dhcp paramaters based upon what kind of client it was talking to (as long as the client is set up to identify itself to the server).  For instance, in a mesh network where some clients may be other OpenWRT boxes, some may be i386 Linux boxes and some Windows boxes.

This patch adds these options to the udhcp client:

--- busybox-1.00_orig/networking/udhcp/options.c        2004-03-15 19:29:01.000000000 +1100
+++ busybox-1.00/networking/udhcp/options.c     2005-09-15 15:51:56.000000000 +1000
@@ -39,8 +39,11 @@
        {"dhcptype",    OPTION_U8,                              0x35},
        {"serverid",    OPTION_IP,                              0x36},
        {"message",     OPTION_STRING,                          0x38},
+       {"vendorclass", OPTION_STRING,                          0x3C},
+       {"clientid",    OPTION_STRING,                          0x3D},
        {"tftp",        OPTION_STRING,                          0x42},
-       {"bootfile",    OPTION_STRING,                          0x43},
+       {"bootfile",    OPTION_STRING,                          0x43},
+       ("userclass",   OPTION_STRING,                          0x4D},
        {"",            0x00,                           0x00}
 };

committed a correct version of your patch. thx.

(see "(") ...

Oops - that's embarrassing.  But thanks for committing it. smile

can you send the fixed patch to upstream? thx in advance.

Not for udhcp and not a patch, but maybe this'll help someone with adding dhcp options within dnsmasq.

Here is what I did to add options to dnsmasq:

# Save the download time for the boot load of a Mitel IP Phone.
# Get it from our local tftp server instead of the otherside.
# TFTP Server Name
dhcp-option=66,"10.1.0.1"
# TFTP Server
dhcp-option=128,10.1.0.1
# RTC - IP Node or Teleworker Server
dhcp-option=129,192.168.0.1
# IP Phone Load
dhcp-option=130,"MITEL IP PHONE"

Dan

wbx, sorry I haven't checked the forums for a couple of days.  What do you mean by "send the fixed patch to upstream?".  I'm sorry but I don't quite speak the lingo... smile

"upstream" means in this context, the original authors. This means prepare a nice bugreport with your patch to the busybox project.
I think you will need to make a patch for their latest CVS version.
Then in one of the next releases of OpenWrt, there is a good chance, that this local patch will be obsolete.

This is how open source works wink

Thanks for the explanation wbx.  Although from reading the udhcpc docs I get the impression that the busybox maintainers have intentionally not added those DHCP options - they point to the options.c file and basically say "if you want more options, add them yourself".  I thought those particular options would be useful to OpenWRT - and it seems you agree with me. smile  But I'll submit the patch to busybox anyway and see what they say.

The discussion might have continued from here.