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-w32-293c94564ccee60c8e954bb6347fd36034cb7590.tar.gz busybox-w32-293c94564ccee60c8e954bb6347fd36034cb7590.tar.bz2 busybox-w32-293c94564ccee60c8e954bb6347fd36034cb7590.zip |
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) | |||
965 | SERVER_PORT = CLIENT_PORT - 1; | 965 | SERVER_PORT = CLIENT_PORT - 1; |
966 | } | 966 | } |
967 | #endif | 967 | #endif |
968 | if (opt & OPT_o) | ||
969 | client_config.no_default_options = 1; | ||
970 | while (list_O) { | 968 | while (list_O) { |
971 | char *optstr = llist_pop(&list_O); | 969 | char *optstr = llist_pop(&list_O); |
972 | unsigned n = bb_strtou(optstr, NULL, 0); | 970 | unsigned n = bb_strtou(optstr, NULL, 0); |
@@ -976,6 +974,16 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
976 | } | 974 | } |
977 | client_config.opt_mask[n >> 3] |= 1 << (n & 7); | 975 | client_config.opt_mask[n >> 3] |= 1 << (n & 7); |
978 | } | 976 | } |
977 | if (!(opt & OPT_o)) { | ||
978 | /* | ||
979 | unsigned i, n; | ||
980 | for (i = 0; (n = dhcp_optflags[i].code) != 0; i++) { | ||
981 | if (dhcp_optflags[i].flags & OPTION_REQ) { | ||
982 | client_config.opt_mask[n >> 3] |= 1 << (n & 7); | ||
983 | } | ||
984 | } | ||
985 | */ | ||
986 | } | ||
979 | while (list_x) { | 987 | while (list_x) { |
980 | char *optstr = llist_pop(&list_x); | 988 | char *optstr = llist_pop(&list_x); |
981 | char *colon = strchr(optstr, ':'); | 989 | 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) | |||
589 | 589 | ||
590 | static void add_client_options(struct dhcp_packet *packet) | 590 | static void add_client_options(struct dhcp_packet *packet) |
591 | { | 591 | { |
592 | uint8_t c; | ||
593 | int i, end, len; | 592 | int i, end, len; |
594 | 593 | ||
595 | udhcp_add_simple_option(packet, DHCP_MAX_SIZE, htons(IP_UDP_DHCP_SIZE)); | 594 | 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) | |||
599 | * No bounds checking because it goes towards the head of the packet. */ | 598 | * No bounds checking because it goes towards the head of the packet. */ |
600 | end = udhcp_end_option(packet->options); | 599 | end = udhcp_end_option(packet->options); |
601 | len = 0; | 600 | len = 0; |
602 | for (i = 0; (c = dhcp_optflags[i].code) != 0; i++) { | 601 | for (i = 1; i < DHCP_END; i++) { |
603 | if (( (dhcp_optflags[i].flags & OPTION_REQ) | 602 | if (client_config.opt_mask[i >> 3] & (1 << (i & 7))) { |
604 | && !client_config.no_default_options | 603 | packet->options[end + OPT_DATA + len] = i; |
605 | ) | ||
606 | || (client_config.opt_mask[c >> 3] & (1 << (c & 7))) | ||
607 | ) { | ||
608 | packet->options[end + OPT_DATA + len] = c; | ||
609 | len++; | 604 | len++; |
610 | } | 605 | } |
611 | } | 606 | } |
@@ -1257,8 +1252,6 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
1257 | SERVER_PORT = CLIENT_PORT - 1; | 1252 | SERVER_PORT = CLIENT_PORT - 1; |
1258 | } | 1253 | } |
1259 | #endif | 1254 | #endif |
1260 | if (opt & OPT_o) | ||
1261 | client_config.no_default_options = 1; | ||
1262 | while (list_O) { | 1255 | while (list_O) { |
1263 | char *optstr = llist_pop(&list_O); | 1256 | char *optstr = llist_pop(&list_O); |
1264 | unsigned n = bb_strtou(optstr, NULL, 0); | 1257 | unsigned n = bb_strtou(optstr, NULL, 0); |
@@ -1268,6 +1261,14 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
1268 | } | 1261 | } |
1269 | client_config.opt_mask[n >> 3] |= 1 << (n & 7); | 1262 | client_config.opt_mask[n >> 3] |= 1 << (n & 7); |
1270 | } | 1263 | } |
1264 | if (!(opt & OPT_o)) { | ||
1265 | unsigned i, n; | ||
1266 | for (i = 0; (n = dhcp_optflags[i].code) != 0; i++) { | ||
1267 | if (dhcp_optflags[i].flags & OPTION_REQ) { | ||
1268 | client_config.opt_mask[n >> 3] |= 1 << (n & 7); | ||
1269 | } | ||
1270 | } | ||
1271 | } | ||
1271 | while (list_x) { | 1272 | while (list_x) { |
1272 | char *optstr = llist_pop(&list_x); | 1273 | char *optstr = llist_pop(&list_x); |
1273 | char *colon = strchr(optstr, ':'); | 1274 | 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 | |||
9 | 9 | ||
10 | struct client_config_t { | 10 | struct client_config_t { |
11 | uint8_t client_mac[6]; /* Our mac address */ | 11 | uint8_t client_mac[6]; /* Our mac address */ |
12 | char no_default_options; /* Do not include default options in request */ | ||
13 | IF_FEATURE_UDHCP_PORT(uint16_t port;) | 12 | IF_FEATURE_UDHCP_PORT(uint16_t port;) |
14 | int ifindex; /* Index number of the interface to use */ | 13 | int ifindex; /* Index number of the interface to use */ |
15 | uint8_t opt_mask[256 / 8]; /* Bitmask of options to send (-O option) */ | 14 | uint8_t opt_mask[256 / 8]; /* Bitmask of options to send (-O option) */ |