aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/options.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-03-25 20:32:38 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2010-03-25 20:32:38 +0100
commit7e6add1dfca95183bf409820066fab975979bf06 (patch)
tree0da56954d93e9b10e956235a32f0d0644a60063b /networking/udhcp/options.c
parent0454d9d6c314f381eee8022ad4e7447d2fa1dcf1 (diff)
downloadbusybox-7e6add1dfca95183bf409820066fab975979bf06.tar.gz
udhcpc: add -x OPT:VAL option
function old new delta udhcp_str2optset - 443 +443 add_client_options - 160 +160 udhcpc_main 2753 2857 +104 packed_usage 26670 26689 +19 attach_option 380 385 +5 udhcpd_main 1964 1965 +1 udhcp_add_option_string 94 86 -8 add_param_req_option 128 - -128 read_opt 443 - -443 ------------------------------------------------------------------------------ (add/remove: 2/2 grow/shrink: 4/1 up/down: 732/-579) Total: 153 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/udhcp/options.c')
-rw-r--r--networking/udhcp/options.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/networking/udhcp/options.c b/networking/udhcp/options.c
index b4d2d2de3..af3c217e8 100644
--- a/networking/udhcp/options.c
+++ b/networking/udhcp/options.c
@@ -212,7 +212,7 @@ int FAST_FUNC udhcp_end_option(uint8_t *optionptr)
while (optionptr[i] != DHCP_END) {
if (optionptr[i] != DHCP_PADDING)
- i += optionptr[i + OPT_LEN] + 1;
+ i += optionptr[i + OPT_LEN] + OPT_DATA-1;
i++;
}
return i;
@@ -222,7 +222,8 @@ int FAST_FUNC udhcp_end_option(uint8_t *optionptr)
/* option bytes: [code][len][data1][data2]..[dataLEN] */
void FAST_FUNC udhcp_add_option_string(uint8_t *optionptr, uint8_t *string)
{
- int end = udhcp_end_option(optionptr);
+ unsigned len;
+ unsigned end = udhcp_end_option(optionptr);
/* end position + string length + option code/length + end option */
if (end + string[OPT_LEN] + 2 + 1 >= DHCP_OPTIONS_BUFSIZE) {
@@ -231,8 +232,9 @@ void FAST_FUNC udhcp_add_option_string(uint8_t *optionptr, uint8_t *string)
return;
}
log_option("Adding option", string);
- memcpy(optionptr + end, string, string[OPT_LEN] + 2);
- optionptr[end + string[OPT_LEN] + 2] = DHCP_END;
+ len = OPT_DATA + string[OPT_LEN];
+ memcpy(optionptr + end, string, len);
+ optionptr[end + len] = DHCP_END;
}
/* add a one to four byte option to a packet */