diff options
Diffstat (limited to 'networking/udhcp/common.c')
-rw-r--r-- | networking/udhcp/common.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/networking/udhcp/common.c b/networking/udhcp/common.c index 31e525cb0..8e9b93655 100644 --- a/networking/udhcp/common.c +++ b/networking/udhcp/common.c | |||
@@ -404,14 +404,29 @@ void FAST_FUNC udhcp_add_simple_option(struct dhcp_packet *packet, uint8_t code, | |||
404 | #endif | 404 | #endif |
405 | 405 | ||
406 | /* Find option 'code' in opt_list */ | 406 | /* Find option 'code' in opt_list */ |
407 | struct option_set* FAST_FUNC udhcp_find_option(struct option_set *opt_list, uint8_t code) | 407 | struct option_set* FAST_FUNC udhcp_find_option(struct option_set *opt_list, uint8_t code, bool dhcpv6) |
408 | { | 408 | { |
409 | while (opt_list && opt_list->data[OPT_CODE] < code) | 409 | IF_NOT_UDHCPC6(bool dhcpv6 = 0;) |
410 | opt_list = opt_list->next; | 410 | uint8_t cur_code; |
411 | 411 | ||
412 | if (opt_list && opt_list->data[OPT_CODE] == code) | 412 | for (;;) { |
413 | return opt_list; | 413 | if (!opt_list) |
414 | return NULL; | 414 | return opt_list; /* NULL */ |
415 | if (!dhcpv6) { | ||
416 | cur_code = opt_list->data[OPT_CODE]; | ||
417 | } else { | ||
418 | //FIXME: add support for code > 0xff | ||
419 | if (opt_list->data[D6_OPT_CODE] != 0) | ||
420 | return NULL; | ||
421 | cur_code = opt_list->data[D6_OPT_CODE + 1]; | ||
422 | } | ||
423 | if (cur_code >= code) { | ||
424 | if (cur_code == code) | ||
425 | return opt_list; | ||
426 | return NULL; | ||
427 | } | ||
428 | opt_list = opt_list->next; | ||
429 | } | ||
415 | } | 430 | } |
416 | 431 | ||
417 | /* Parse string to IP in network order */ | 432 | /* Parse string to IP in network order */ |
@@ -499,7 +514,7 @@ static NOINLINE void attach_option( | |||
499 | } | 514 | } |
500 | #endif | 515 | #endif |
501 | 516 | ||
502 | existing = udhcp_find_option(*opt_list, optflag->code); | 517 | existing = udhcp_find_option(*opt_list, optflag->code, dhcpv6); |
503 | if (!existing) { | 518 | if (!existing) { |
504 | /* make a new option */ | 519 | /* make a new option */ |
505 | uint8_t *p = udhcp_insert_new_option(opt_list, optflag->code, length, dhcpv6); | 520 | uint8_t *p = udhcp_insert_new_option(opt_list, optflag->code, length, dhcpv6); |