Busy-box udhcpc with option URL (option 114) patch
06/05/2014, 23:29 - Open Source
Here is my patch to busy box-1.21.1 udhcpc to get the DHCP option 114 from DHCP server.


diff -Naur networking/udhcp/common.c networking/udhcp.new/common.c
--- networking/udhcp/common.c 2013-06-29 22:58:06.000000000 +0800
+++ networking/udhcp.new/common.c 2014-06-04 16:37:41.942075154 +0800
@@ -53,6 +53,7 @@
{ OPTION_STRING , 0x43 }, /* DHCP_BOOT_FILE */
//TODO: not a string, but a set of LASCII strings:
// { OPTION_STRING , 0x4D }, /* DHCP_USER_CLASS */
+ { OPTION_URL_STRING | OPTION_REQ , 0x72 }, /* DHCP_URL ( option 114 ) */
#if ENABLE_FEATURE_UDHCP_RFC3397
{ OPTION_DNS_STRING | OPTION_LIST , 0x77 }, /* DHCP_DOMAIN_SEARCH */
{ OPTION_SIP_SERVERS , 0x78 }, /* DHCP_SIP_SERVERS */
@@ -117,6 +118,7 @@
"tftp" "\0" /* DHCP_TFTP_SERVER_NAME */
"bootfile" "\0" /* DHCP_BOOT_FILE */
// "userclass" "\0" /* DHCP_USER_CLASS */
+ "url" "\0" /* DHCP_URL (option 114) */
#if ENABLE_FEATURE_UDHCP_RFC3397
"search" "\0" /* DHCP_DOMAIN_SEARCH */
// doesn't work in udhcpd.conf since OPTION_SIP_SERVERS
@@ -147,6 +149,7 @@
// [OPTION_BOOLEAN] = 1,
[OPTION_STRING] = 1, /* ignored by udhcp_str2optset */
[OPTION_STRING_HOST] = 1, /* ignored by udhcp_str2optset */
+ [OPTION_URL_STRING] = 1,
#if ENABLE_FEATURE_UDHCP_RFC3397
[OPTION_DNS_STRING] = 1, /* ignored by both udhcp_str2optset and xmalloc_optname_optval */
[OPTION_SIP_SERVERS] = 1,
diff -Naur networking/udhcp/common.h networking/udhcp.new/common.h
--- networking/udhcp/common.h 2013-05-12 07:30:44.000000000 +0800
+++ networking/udhcp.new/common.h 2014-06-04 16:37:41.942075154 +0800
@@ -92,6 +92,7 @@
OPTION_BIN,
OPTION_STATIC_ROUTES,
OPTION_6RD,
+ OPTION_URL_STRING,
#if ENABLE_FEATURE_UDHCP_RFC3397
OPTION_DNS_STRING, /* RFC1035 compressed domain name list */
OPTION_SIP_SERVERS,
@@ -146,6 +147,7 @@
//#define DHCP_BOOT_FILE 0x43 /* same as 'file' field */
//#define DHCP_USER_CLASS 0x4d /* RFC 3004. set of LASCII strings. "I am a printer" etc */
#define DHCP_FQDN 0x51 /* client asks to update DNS to map its FQDN to its new IP */
+#define DHCP_URL_STRING 0x72 /* option 114 */
//#define DHCP_DOMAIN_SEARCH 0x77 /* RFC 3397. set of ASCIZ string, DNS-style compressed */
//#define DHCP_SIP_SERVERS 0x78 /* RFC 3361. flag byte, then: 0: domain names, 1: IP addrs */
//#define DHCP_STATIC_ROUTES 0x79 /* RFC 3442. (mask,ip,router) tuples */
diff -Naur networking/udhcp/dhcpc.c networking/udhcp.new/dhcpc.c
--- networking/udhcp/dhcpc.c 2013-05-12 07:30:44.000000000 +0800
+++ networking/udhcp.new/dhcpc.c 2014-06-04 16:37:41.942075154 +0800
@@ -102,6 +102,7 @@
[OPTION_6RD ] = sizeof("32 128 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff 255.255.255.255 "),
[OPTION_STRING ] = 1,
[OPTION_STRING_HOST ] = 1,
+ [OPTION_URL_STRING ] = 1,
#if ENABLE_FEATURE_UDHCP_RFC3397
[OPTION_DNS_STRING ] = 1, /* unused */
/* Hmmm, this severely overestimates size if SIP_SERVERS option
@@ -251,6 +252,10 @@
if (type == OPTION_STRING_HOST && !good_hostname(dest))
safe_strncpy(dest, "bad", len);
return ret;
+ case OPTION_URL_STRING:
+ memcpy(dest, option, len);
+ dest[len] = '\0';
+ return ret;
case OPTION_STATIC_ROUTES: {
/* Option binary format:
* mask [one byte, 0..32]


After patch and compile the busy box, now the udhcpc default send out URL request, and expect the DHCP server will response URL back.

The ISC-DHCP server config also need to add in dhcpd.conf :

options default-utl "http://this.is.a.test/test-path";


If do not like the busy box udhcpc and prefer ISC-DHCP client then also need add in dhclient.conf, because the DHCP server must receive the URL request the response back to clients:

request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, domain-search, host-name,
netbios-name-servers, betbios-scope, interface-mtu,
rfx3442-classless-static-routes, ntp-servers,
default-url;



回應

發表回應

填寫下面來發表回應。









插入項目:


遊覽已上傳的圖片








回應需經過管理人員認可後才會出現在網頁上.