udhcpc: add support for long options

Duplicate options are currently overridden (only the last option is kept).
This leads to unexpected behavior when using long options.

The patch adds support for long options in compliance with RFC 3396.

Fixes #13136.

function                                             old     new   delta
udhcp_run_script                                     601     725    +124
optitem_unset_env_and_free                             -      38     +38
putenvp                                               46      59     +13
static.xmalloc_optname_optval                        718     717      -1
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/1 up/down: 175/-1)            Total: 174 bytes

Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Martin Lewis
2020-08-04 17:27:16 -05:00
committed by Denys Vlasenko
parent 8a485b0a36
commit 9914d8b861
2 changed files with 104 additions and 35 deletions

View File

@@ -21,6 +21,7 @@ struct client_data_t {
uint8_t *vendorclass; /* Optional vendor class-id to use */
uint8_t *hostname; /* Optional hostname to use */
uint8_t *fqdn; /* Optional fully qualified domain name to use */
llist_t *envp; /* list of DHCP options used for env vars */
unsigned first_secs;
unsigned last_secs;