diff options
author | Denis Vlasenko | 2008-04-02 13:04:19 +0000 |
---|---|---|
committer | Denis Vlasenko | 2008-04-02 13:04:19 +0000 |
commit | 2e4c3c4cc3c2f6bdd3bfbafe9980f46b24971009 (patch) | |
tree | e7e729631b8b8150cb25349534ae16c2d7f12562 /networking/udhcp/clientpacket.c | |
parent | 0edbdd8ac8c0add7902d73a7ef921abba9f5752a (diff) | |
download | busybox-2e4c3c4cc3c2f6bdd3bfbafe9980f46b24971009.zip busybox-2e4c3c4cc3c2f6bdd3bfbafe9980f46b24971009.tar.gz |
udhcpc: add -o "do not request options by default" switch
(by L. Gabriel Somlo <somlo AT cmu.edu>)
function old new delta
udhcpc_main 2513 2554 +41
static.udhcpc_longopts 226 247 +21
add_param_req_option 119 132 +13
packed_usage 23952 23964 +12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 87/0) Total: 87 bytes
Diffstat (limited to 'networking/udhcp/clientpacket.c')
-rw-r--r-- | networking/udhcp/clientpacket.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/networking/udhcp/clientpacket.c b/networking/udhcp/clientpacket.c index 29d0d9a..f826c1b 100644 --- a/networking/udhcp/clientpacket.c +++ b/networking/udhcp/clientpacket.c @@ -62,17 +62,20 @@ static void add_param_req_option(struct dhcpMessage *packet) int end = end_option(packet->options); int i, len = 0; - packet->options[end + OPT_CODE] = DHCP_PARAM_REQ; for (i = 0; (c = dhcp_options[i].code) != 0; i++) { - if ((dhcp_options[i].flags & OPTION_REQ) + if (((dhcp_options[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; len++; } } - packet->options[end + OPT_LEN] = len; - packet->options[end + OPT_DATA + len] = DHCP_END; + if (len) { + packet->options[end + OPT_CODE] = DHCP_PARAM_REQ; + packet->options[end + OPT_LEN] = len; + packet->options[end + OPT_DATA + len] = DHCP_END; + } } @@ -107,7 +110,9 @@ int send_discover(uint32_t xid, uint32_t requested) /* Explicitly saying that we want RFC-compliant packets helps * some buggy DHCP servers to NOT send bigger packets */ add_simple_option(packet.options, DHCP_MAX_SIZE, htons(576)); + add_param_req_option(&packet); + bb_info_msg("Sending discover..."); return udhcp_send_raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST, SERVER_PORT, MAC_BCAST_ADDR, client_config.ifindex); @@ -125,8 +130,8 @@ int send_selecting(uint32_t xid, uint32_t server, uint32_t requested) add_simple_option(packet.options, DHCP_REQUESTED_IP, requested); add_simple_option(packet.options, DHCP_SERVER_ID, server); - add_param_req_option(&packet); + addr.s_addr = requested; bb_info_msg("Sending select for %s...", inet_ntoa(addr)); return udhcp_send_raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST, |