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-w32-7e6add1dfca95183bf409820066fab975979bf06.tar.gz
busybox-w32-7e6add1dfca95183bf409820066fab975979bf06.tar.bz2
busybox-w32-7e6add1dfca95183bf409820066fab975979bf06.zip
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)
212 212
213 while (optionptr[i] != DHCP_END) { 213 while (optionptr[i] != DHCP_END) {
214 if (optionptr[i] != DHCP_PADDING) 214 if (optionptr[i] != DHCP_PADDING)
215 i += optionptr[i + OPT_LEN] + 1; 215 i += optionptr[i + OPT_LEN] + OPT_DATA-1;
216 i++; 216 i++;
217 } 217 }
218 return i; 218 return i;
@@ -222,7 +222,8 @@ int FAST_FUNC udhcp_end_option(uint8_t *optionptr)
222/* option bytes: [code][len][data1][data2]..[dataLEN] */ 222/* option bytes: [code][len][data1][data2]..[dataLEN] */
223void FAST_FUNC udhcp_add_option_string(uint8_t *optionptr, uint8_t *string) 223void FAST_FUNC udhcp_add_option_string(uint8_t *optionptr, uint8_t *string)
224{ 224{
225 int end = udhcp_end_option(optionptr); 225 unsigned len;
226 unsigned end = udhcp_end_option(optionptr);
226 227
227 /* end position + string length + option code/length + end option */ 228 /* end position + string length + option code/length + end option */
228 if (end + string[OPT_LEN] + 2 + 1 >= DHCP_OPTIONS_BUFSIZE) { 229 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)
231 return; 232 return;
232 } 233 }
233 log_option("Adding option", string); 234 log_option("Adding option", string);
234 memcpy(optionptr + end, string, string[OPT_LEN] + 2); 235 len = OPT_DATA + string[OPT_LEN];
235 optionptr[end + string[OPT_LEN] + 2] = DHCP_END; 236 memcpy(optionptr + end, string, len);
237 optionptr[end + len] = DHCP_END;
236} 238}
237 239
238/* add a one to four byte option to a packet */ 240/* add a one to four byte option to a packet */