--- busybox-1.5.0/networking/udhcp/dhcpc.c 2007-03-22 21:21:23.000000000 +0100 +++ busybox-1.5.0_new/networking/udhcp/dhcpc.c 2007-06-02 21:15:34.000000000 +0200 @@ -126,7 +126,7 @@ int udhcpc_main(int argc, char *argv[]); int udhcpc_main(int argc, char *argv[]) { uint8_t *temp, *message; - char *str_c, *str_V, *str_h, *str_F, *str_r, *str_T, *str_t; + char *str_c, *str_V, *str_h, *str_F, *str_r, *str_T, *str_t, *str_O; unsigned long t1 = 0, t2 = 0, xid = 0; unsigned long start = 0, lease = 0; long now; @@ -160,6 +160,7 @@ int udhcpc_main(int argc, char *argv[]) OPT_T = 1 << 15, OPT_t = 1 << 16, OPT_v = 1 << 17, + OPT_O = 1 << 18, }; #if ENABLE_GETOPT_LONG static const struct option arg_options[] = { @@ -181,6 +182,7 @@ int udhcpc_main(int argc, char *argv[]) { "timeout", required_argument, 0, 'T' }, { "version", no_argument, 0, 'v' }, { "retries", required_argument, 0, 't' }, + { "request-option", required_argument, 0, 'O' }, { 0, 0, 0, 0 } }; #endif @@ -196,10 +198,10 @@ int udhcpc_main(int argc, char *argv[]) #if ENABLE_GETOPT_LONG applet_long_options = arg_options; #endif - opt = getopt32(argc, argv, "c:CV:fbH:h:F:i:np:qRr:s:T:t:v", + opt = getopt32(argc, argv, "c:CV:fbH:h:F:i:np:qRr:s:T:t:vO:", &str_c, &str_V, &str_h, &str_h, &str_F, &client_config.interface, &client_config.pidfile, &str_r, - &client_config.script, &str_T, &str_t + &client_config.script, &str_T, &str_t, &str_O ); if (opt & OPT_c) @@ -245,6 +247,11 @@ int udhcpc_main(int argc, char *argv[]) printf("version %s\n\n", BB_VER); return 0; } + if (opt & OPT_O) + if (require_option(str_O)) { + printf("Option: %s unknown/not-supported\n", str_O); + return 1; + } /* Start the log, sanitize fd's, and write a pid file */ udhcp_start_log_and_pid(client_config.pidfile); --- busybox-1.5.0/networking/udhcp/options.c 2007-03-22 21:21:23.000000000 +0100 +++ busybox-1.5.0_new/networking/udhcp/options.c 2007-06-02 20:42:42.000000000 +0200 @@ -10,7 +10,7 @@ /* supported options are easily added here */ -const struct dhcp_option dhcp_options[] = { +struct dhcp_option dhcp_options[] = { /* name[12] flags code */ {"subnet", OPTION_IP | OPTION_REQ, 0x01}, {"timezone", OPTION_S32, 0x02}, @@ -67,7 +67,18 @@ const unsigned char option_lengths[] = { [OPTION_S32] = 4 }; - +/* find and mark requested item as required */ +int require_option(char *name) +{ + int i; + for (i = 0; dhcp_options[i].code; i++) + if( strcmp( name, dhcp_options[i].name ) == 0 ){ + dhcp_options[i].flags |= OPTION_REQ; + return 0; + } + return 1; +} + /* get an option with bounds checking (warning, not aligned). */ uint8_t *get_option(struct dhcpMessage *packet, int code) { --- busybox-1.5.0/networking/udhcp/options.h 2007-03-22 21:21:23.000000000 +0100 +++ busybox-1.5.0_new/networking/udhcp/options.h 2007-06-02 19:51:40.000000000 +0200 @@ -29,9 +29,10 @@ struct dhcp_option { uint8_t code; }; -extern const struct dhcp_option dhcp_options[]; +extern struct dhcp_option dhcp_options[]; extern const unsigned char option_lengths[]; +int require_option(char *name); uint8_t *get_option(struct dhcpMessage *packet, int code); int end_option(uint8_t *optionptr); int add_option_string(uint8_t *optionptr, uint8_t *string); --- busybox-1.5.0/include/usage.h 2007-03-22 21:21:35.000000000 +0100 +++ busybox-1.5.0_new/include/usage.h 2007-06-02 20:08:51.000000000 +0200 @@ -3410,7 +3410,7 @@ "Adjust filesystem options on ext[23] filesystems" #define udhcpc_trivial_usage \ - "[-Cfbnqtv] [-c CID] [-V VCLS] [-H HOSTNAME] [-i INTERFACE]\n[-p pidfile] [-r IP] [-s script]" + "[-Cfbnqtv] [-c CID] [-V VCLS] [-H HOSTNAME] [-i INTERFACE]\n[-p pidfile] [-r IP] [-s script] [-O dhcp-option]" #define udhcpc_full_usage \ " -V,--vendorclass=CLASSID Set vendor class identifier\n" \ " -i,--interface=INTERFACE Interface to use (default: eth0)\n" \ @@ -3426,7 +3426,8 @@ " -n,--now Exit with failure if lease cannot be immediately negotiated\n" \ " -q,--quit Quit after obtaining lease\n" \ " -R,--release Release IP on quit\n" \ - " -v,--version Display version" \ + " -v,--version Display version\n" \ + " -O,--request-option=NAME Request also NAME DHCP-Option" \ #define udhcpd_trivial_usage \ "[configfile]\n" \