diff options
author | Denis Vlasenko | 2007-12-10 07:03:38 +0000 |
---|---|---|
committer | Denis Vlasenko | 2007-12-10 07:03:38 +0000 |
commit | 191836845e4551fe6191dc0d43b45a0232bff8be (patch) | |
tree | e6fd859b756304842334d0e0603856be2a5948e6 /networking/udhcp/dhcpc.c | |
parent | 75aa615bef478622cd0695b95adcf182fbbc3d95 (diff) | |
download | busybox-191836845e4551fe6191dc0d43b45a0232bff8be.zip busybox-191836845e4551fe6191dc0d43b45a0232bff8be.tar.gz |
udhcpc: support for -O <option>.
Two important notes:
* nissrv and nisdomain are not requested by default anymore!
* inconsistency between "XXXsvr" and "XXsrv" in option names resolved,
all are "XXXsrv" now.
function old new delta
udhcpc_main 2494 2600 +106
packed_usage 23023 23067 +44
add_requests 91 119 +28
static.udhcpc_longopts 209 226 +17
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 195/0) Total: 195 bytes
Diffstat (limited to 'networking/udhcp/dhcpc.c')
-rw-r--r-- | networking/udhcp/dhcpc.c | 61 |
1 files changed, 36 insertions, 25 deletions
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index d8077f7..69c35ca 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c @@ -133,6 +133,7 @@ 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_A, *str_t; + llist_t *list_O = NULL; #if ENABLE_FEATURE_UDHCPC_ARPING char *str_W; #endif @@ -183,28 +184,29 @@ int udhcpc_main(int argc, char **argv) }; #if ENABLE_GETOPT_LONG static const char udhcpc_longopts[] ALIGN1 = - "clientid\0" Required_argument "c" - "clientid-none\0" No_argument "C" - "vendorclass\0" Required_argument "V" - "foreground\0" No_argument "f" - "background\0" No_argument "b" - "hostname\0" Required_argument "H" - "fqdn\0" Required_argument "F" - "interface\0" Required_argument "i" - "now\0" No_argument "n" - "pidfile\0" Required_argument "p" - "quit\0" No_argument "q" - "release\0" No_argument "R" - "request\0" Required_argument "r" - "script\0" Required_argument "s" - "timeout\0" Required_argument "T" - "version\0" No_argument "v" - "retries\0" Required_argument "t" - "tryagain\0" Required_argument "A" - "syslog\0" No_argument "S" + "clientid\0" Required_argument "c" + "clientid-none\0" No_argument "C" + "vendorclass\0" Required_argument "V" + "foreground\0" No_argument "f" + "background\0" No_argument "b" + "hostname\0" Required_argument "H" + "fqdn\0" Required_argument "F" + "interface\0" Required_argument "i" + "now\0" No_argument "n" + "pidfile\0" Required_argument "p" + "quit\0" No_argument "q" + "release\0" No_argument "R" + "request\0" Required_argument "r" + "script\0" Required_argument "s" + "timeout\0" Required_argument "T" + "version\0" No_argument "v" + "retries\0" Required_argument "t" + "tryagain\0" Required_argument "A" + "syslog\0" No_argument "S" #if ENABLE_FEATURE_UDHCPC_ARPING - "arping\0" No_argument "a" + "arping\0" No_argument "a" #endif + "request-option\0" Required_argument "O" ; #endif /* Default options. */ @@ -212,16 +214,18 @@ int udhcpc_main(int argc, char **argv) client_config.script = DEFAULT_SCRIPT; /* Parse command line */ - opt_complementary = "c--C:C--c"; // mutually exclusive + opt_complementary = "c--C:C--c:O::"; // Cc: mutually exclusive; O: list #if ENABLE_GETOPT_LONG applet_long_options = udhcpc_longopts; #endif opt = getopt32(argv, "c:CV:fbH:h:F:i:np:qRr:s:T:t:vSA:" USE_FEATURE_UDHCPC_ARPING("aW:") - , &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, &str_A + "O:" + , &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, &str_A USE_FEATURE_UDHCPC_ARPING(, &str_W) + , &list_O ); if (opt & OPT_c) @@ -268,11 +272,18 @@ int udhcpc_main(int argc, char **argv) puts("version "BB_VER); return 0; } - if (opt & OPT_S) { openlog(applet_name, LOG_PID, LOG_LOCAL0); logmode |= LOGMODE_SYSLOG; } + while (list_O) { + int n = index_in_strings(dhcp_option_strings, list_O->data); + if (n < 0) + bb_error_msg_and_die("unknown option '%s'", list_O->data); + n = dhcp_options[n].code; + client_config.opt_mask[n >> 3] |= 1 << (n & 7); + list_O = list_O->link; + } if (read_interface(client_config.interface, &client_config.ifindex, NULL, client_config.arp)) |