diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2012-07-27 13:25:07 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2012-07-27 13:25:07 +0200 |
commit | 293c94564ccee60c8e954bb6347fd36034cb7590 (patch) | |
tree | 0d715c33a883762b22b010fa4cb13d8d74ea7b11 /networking/udhcp | |
parent | 0e941d542736dc5eb69add1d3377a4601536eb97 (diff) | |
download | busybox-293c94564ccee60c8e954bb6347fd36034cb7590.tar.gz |
udhcpc: make -O <numeric_opt> work. Closes 5402
function old new delta
udhcpc_main 2642 2685 +43
udhcp_recv_raw_packet 414 415 +1
d6_recv_raw_packet 248 249 +1
udhcpc6_main 2430 2413 -17
add_client_options 239 213 -26
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/2 up/down: 45/-43) Total: 2 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/udhcp')
-rw-r--r-- | networking/udhcp/d6_dhcpc.c | 12 | ||||
-rw-r--r-- | networking/udhcp/dhcpc.c | 21 | ||||
-rw-r--r-- | networking/udhcp/dhcpc.h | 1 |
3 files changed, 21 insertions, 13 deletions
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c index d9d8b9b56..dda4a9112 100644 --- a/networking/udhcp/d6_dhcpc.c +++ b/networking/udhcp/d6_dhcpc.c @@ -965,8 +965,6 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) SERVER_PORT = CLIENT_PORT - 1; } #endif - if (opt & OPT_o) - client_config.no_default_options = 1; while (list_O) { char *optstr = llist_pop(&list_O); unsigned n = bb_strtou(optstr, NULL, 0); @@ -976,6 +974,16 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) } client_config.opt_mask[n >> 3] |= 1 << (n & 7); } + if (!(opt & OPT_o)) { + /* + unsigned i, n; + for (i = 0; (n = dhcp_optflags[i].code) != 0; i++) { + if (dhcp_optflags[i].flags & OPTION_REQ) { + client_config.opt_mask[n >> 3] |= 1 << (n & 7); + } + } + */ + } while (list_x) { char *optstr = llist_pop(&list_x); char *colon = strchr(optstr, ':'); diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index 4e7bd4bbc..bc1db7087 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c @@ -589,7 +589,6 @@ static void init_packet(struct dhcp_packet *packet, char type) static void add_client_options(struct dhcp_packet *packet) { - uint8_t c; int i, end, len; udhcp_add_simple_option(packet, DHCP_MAX_SIZE, htons(IP_UDP_DHCP_SIZE)); @@ -599,13 +598,9 @@ static void add_client_options(struct dhcp_packet *packet) * No bounds checking because it goes towards the head of the packet. */ end = udhcp_end_option(packet->options); len = 0; - for (i = 0; (c = dhcp_optflags[i].code) != 0; i++) { - if (( (dhcp_optflags[i].flags & OPTION_REQ) - && !client_config.no_default_options - ) - || (client_config.opt_mask[c >> 3] & (1 << (c & 7))) - ) { - packet->options[end + OPT_DATA + len] = c; + for (i = 1; i < DHCP_END; i++) { + if (client_config.opt_mask[i >> 3] & (1 << (i & 7))) { + packet->options[end + OPT_DATA + len] = i; len++; } } @@ -1257,8 +1252,6 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) SERVER_PORT = CLIENT_PORT - 1; } #endif - if (opt & OPT_o) - client_config.no_default_options = 1; while (list_O) { char *optstr = llist_pop(&list_O); unsigned n = bb_strtou(optstr, NULL, 0); @@ -1268,6 +1261,14 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) } client_config.opt_mask[n >> 3] |= 1 << (n & 7); } + if (!(opt & OPT_o)) { + unsigned i, n; + for (i = 0; (n = dhcp_optflags[i].code) != 0; i++) { + if (dhcp_optflags[i].flags & OPTION_REQ) { + client_config.opt_mask[n >> 3] |= 1 << (n & 7); + } + } + } while (list_x) { char *optstr = llist_pop(&list_x); char *colon = strchr(optstr, ':'); diff --git a/networking/udhcp/dhcpc.h b/networking/udhcp/dhcpc.h index 2b3599120..2859a0772 100644 --- a/networking/udhcp/dhcpc.h +++ b/networking/udhcp/dhcpc.h @@ -9,7 +9,6 @@ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN struct client_config_t { uint8_t client_mac[6]; /* Our mac address */ - char no_default_options; /* Do not include default options in request */ IF_FEATURE_UDHCP_PORT(uint16_t port;) int ifindex; /* Index number of the interface to use */ uint8_t opt_mask[256 / 8]; /* Bitmask of options to send (-O option) */ |