diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-05-14 11:06:35 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-05-14 11:11:08 +0200 |
commit | 6027597fd1a1a9293818db4729625fff375bf907 (patch) | |
tree | a8a38d8459b6a87f0c2132a5c05c779d8c1f4eca /networking/udhcp/common.c | |
parent | 30f4d52ed17112f4fa340afe3bcaf305eeed36d9 (diff) | |
download | busybox-w32-6027597fd1a1a9293818db4729625fff375bf907.tar.gz busybox-w32-6027597fd1a1a9293818db4729625fff375bf907.tar.bz2 busybox-w32-6027597fd1a1a9293818db4729625fff375bf907.zip |
udhcpc6: set -x options in request
Last foru commits:
function old new delta
option_to_env 621 791 +170
.rodata 168351 168505 +154
attach_option 431 506 +75
add_d6_client_options 112 167 +55
d6_option_strings 30 84 +54
udhcp_str2optset 644 660 +16
d6_optflags 12 20 +8
udhcpc6_main 2590 2596 +6
udhcpc_main 2648 2651 +3
read_optset 15 18 +3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 10/0 up/down: 544/0) Total: 544 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/udhcp/common.c')
-rw-r--r-- | networking/udhcp/common.c | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/networking/udhcp/common.c b/networking/udhcp/common.c index b7c04da73..52ef875f0 100644 --- a/networking/udhcp/common.c +++ b/networking/udhcp/common.c | |||
@@ -379,12 +379,18 @@ int FAST_FUNC udhcp_str2nip(const char *str, void *arg) | |||
379 | * and to parse udhcpd.conf's "opt OPTNAME OPTVAL" directives. | 379 | * and to parse udhcpd.conf's "opt OPTNAME OPTVAL" directives. |
380 | */ | 380 | */ |
381 | /* helper: add an option to the opt_list */ | 381 | /* helper: add an option to the opt_list */ |
382 | #if !ENABLE_UDHCPC6 | ||
383 | #define attach_option(opt_list, optflag, buffer, length, dhcpv6) \ | ||
384 | attach_option(opt_list, optflag, buffer, length) | ||
385 | #endif | ||
382 | static NOINLINE void attach_option( | 386 | static NOINLINE void attach_option( |
383 | struct option_set **opt_list, | 387 | struct option_set **opt_list, |
384 | const struct dhcp_optflag *optflag, | 388 | const struct dhcp_optflag *optflag, |
385 | char *buffer, | 389 | char *buffer, |
386 | int length) | 390 | int length, |
391 | bool dhcpv6) | ||
387 | { | 392 | { |
393 | IF_NOT_UDHCPC6(bool dhcpv6 = 0;) | ||
388 | struct option_set *existing; | 394 | struct option_set *existing; |
389 | char *allocated = NULL; | 395 | char *allocated = NULL; |
390 | 396 | ||
@@ -410,10 +416,21 @@ static NOINLINE void attach_option( | |||
410 | /* make a new option */ | 416 | /* make a new option */ |
411 | log2("attaching option %02x to list", optflag->code); | 417 | log2("attaching option %02x to list", optflag->code); |
412 | new = xmalloc(sizeof(*new)); | 418 | new = xmalloc(sizeof(*new)); |
413 | new->data = xmalloc(length + OPT_DATA); | 419 | if (!dhcpv6) { |
414 | new->data[OPT_CODE] = optflag->code; | 420 | new->data = xmalloc(length + OPT_DATA); |
415 | new->data[OPT_LEN] = length; | 421 | new->data[OPT_CODE] = optflag->code; |
416 | memcpy(new->data + OPT_DATA, (allocated ? allocated : buffer), length); | 422 | new->data[OPT_LEN] = length; |
423 | memcpy(new->data + OPT_DATA, (allocated ? allocated : buffer), | ||
424 | length); | ||
425 | } else { | ||
426 | new->data = xmalloc(length + D6_OPT_DATA); | ||
427 | new->data[D6_OPT_CODE] = optflag->code >> 8; | ||
428 | new->data[D6_OPT_CODE + 1] = optflag->code & 0xff; | ||
429 | new->data[D6_OPT_LEN] = length >> 8; | ||
430 | new->data[D6_OPT_LEN + 1] = length & 0xff; | ||
431 | memcpy(new->data + D6_OPT_DATA, (allocated ? allocated : buffer), | ||
432 | length); | ||
433 | } | ||
417 | 434 | ||
418 | curr = opt_list; | 435 | curr = opt_list; |
419 | while (*curr && (*curr)->data[OPT_CODE] < optflag->code) | 436 | while (*curr && (*curr)->data[OPT_CODE] < optflag->code) |
@@ -450,7 +467,9 @@ static NOINLINE void attach_option( | |||
450 | free(allocated); | 467 | free(allocated); |
451 | } | 468 | } |
452 | 469 | ||
453 | int FAST_FUNC udhcp_str2optset(const char *const_str, void *arg, const struct dhcp_optflag *optflags, const char *option_strings) | 470 | int FAST_FUNC udhcp_str2optset(const char *const_str, void *arg, |
471 | const struct dhcp_optflag *optflags, const char *option_strings, | ||
472 | bool dhcpv6) | ||
454 | { | 473 | { |
455 | struct option_set **opt_list = arg; | 474 | struct option_set **opt_list = arg; |
456 | char *opt; | 475 | char *opt; |
@@ -602,7 +621,7 @@ case_OPTION_STRING: | |||
602 | } | 621 | } |
603 | 622 | ||
604 | if (retval) | 623 | if (retval) |
605 | attach_option(opt_list, optflag, opt, length); | 624 | attach_option(opt_list, optflag, opt, length, dhcpv6); |
606 | } while (retval && (optflag->flags & OPTION_LIST)); | 625 | } while (retval && (optflag->flags & OPTION_LIST)); |
607 | 626 | ||
608 | return retval; | 627 | return retval; |