diff options
Diffstat (limited to 'networking/udhcp/dhcpc.c')
-rw-r--r-- | networking/udhcp/dhcpc.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index 4565d7fd2..2c7608048 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
@@ -49,10 +49,10 @@ static const uint8_t len_of_option_as_string[] = { | |||
49 | #if ENABLE_FEATURE_UDHCP_RFC3397 | 49 | #if ENABLE_FEATURE_UDHCP_RFC3397 |
50 | [OPTION_STR1035] = 1, | 50 | [OPTION_STR1035] = 1, |
51 | #endif | 51 | #endif |
52 | [OPTION_BOOLEAN] = sizeof("yes "), | 52 | // [OPTION_BOOLEAN] = sizeof("yes "), |
53 | [OPTION_U8] = sizeof("255 "), | 53 | [OPTION_U8] = sizeof("255 "), |
54 | [OPTION_U16] = sizeof("65535 "), | 54 | [OPTION_U16] = sizeof("65535 "), |
55 | [OPTION_S16] = sizeof("-32768 "), | 55 | // [OPTION_S16] = sizeof("-32768 "), |
56 | [OPTION_U32] = sizeof("4294967295 "), | 56 | [OPTION_U32] = sizeof("4294967295 "), |
57 | [OPTION_S32] = sizeof("-2147483684 "), | 57 | [OPTION_S32] = sizeof("-2147483684 "), |
58 | }; | 58 | }; |
@@ -81,7 +81,6 @@ static NOINLINE char *xmalloc_optname_optval(uint8_t *option, const struct dhcp_ | |||
81 | unsigned upper_length; | 81 | unsigned upper_length; |
82 | int len, type, optlen; | 82 | int len, type, optlen; |
83 | uint16_t val_u16; | 83 | uint16_t val_u16; |
84 | int16_t val_s16; | ||
85 | uint32_t val_u32; | 84 | uint32_t val_u32; |
86 | int32_t val_s32; | 85 | int32_t val_s32; |
87 | char *dest, *ret; | 86 | char *dest, *ret; |
@@ -108,9 +107,9 @@ static NOINLINE char *xmalloc_optname_optval(uint8_t *option, const struct dhcp_ | |||
108 | // Should we bail out/warn if we see multi-ip option which is | 107 | // Should we bail out/warn if we see multi-ip option which is |
109 | // not allowed to be such? For example, DHCP_BROADCAST... | 108 | // not allowed to be such? For example, DHCP_BROADCAST... |
110 | break; | 109 | break; |
111 | case OPTION_BOOLEAN: | 110 | // case OPTION_BOOLEAN: |
112 | dest += sprintf(dest, *option ? "yes" : "no"); | 111 | // dest += sprintf(dest, *option ? "yes" : "no"); |
113 | break; | 112 | // break; |
114 | case OPTION_U8: | 113 | case OPTION_U8: |
115 | dest += sprintf(dest, "%u", *option); | 114 | dest += sprintf(dest, "%u", *option); |
116 | break; | 115 | break; |
@@ -118,10 +117,12 @@ static NOINLINE char *xmalloc_optname_optval(uint8_t *option, const struct dhcp_ | |||
118 | move_from_unaligned16(val_u16, option); | 117 | move_from_unaligned16(val_u16, option); |
119 | dest += sprintf(dest, "%u", ntohs(val_u16)); | 118 | dest += sprintf(dest, "%u", ntohs(val_u16)); |
120 | break; | 119 | break; |
121 | case OPTION_S16: | 120 | // case OPTION_S16: { |
122 | move_from_unaligned16(val_s16, option); | 121 | // int16_t val_s16; |
123 | dest += sprintf(dest, "%d", ntohs(val_s16)); | 122 | // move_from_unaligned16(val_s16, option); |
124 | break; | 123 | // dest += sprintf(dest, "%d", ntohs(val_s16)); |
124 | // break; | ||
125 | // } | ||
125 | case OPTION_U32: | 126 | case OPTION_U32: |
126 | move_from_unaligned32(val_u32, option); | 127 | move_from_unaligned32(val_u32, option); |
127 | dest += sprintf(dest, "%lu", (unsigned long) ntohl(val_u32)); | 128 | dest += sprintf(dest, "%lu", (unsigned long) ntohl(val_u32)); |
@@ -318,23 +319,23 @@ static void init_packet(struct dhcp_packet *packet, char type) | |||
318 | udhcp_init_header(packet, type); | 319 | udhcp_init_header(packet, type); |
319 | memcpy(packet->chaddr, client_config.client_mac, 6); | 320 | memcpy(packet->chaddr, client_config.client_mac, 6); |
320 | if (client_config.clientid) | 321 | if (client_config.clientid) |
321 | udhcp_add_option_string(packet->options, client_config.clientid); | 322 | udhcp_add_binary_option(packet->options, client_config.clientid); |
322 | if (client_config.hostname) | 323 | if (client_config.hostname) |
323 | udhcp_add_option_string(packet->options, client_config.hostname); | 324 | udhcp_add_binary_option(packet->options, client_config.hostname); |
324 | if (client_config.fqdn) | 325 | if (client_config.fqdn) |
325 | udhcp_add_option_string(packet->options, client_config.fqdn); | 326 | udhcp_add_binary_option(packet->options, client_config.fqdn); |
326 | if (type != DHCPDECLINE | 327 | if (type != DHCPDECLINE |
327 | && type != DHCPRELEASE | 328 | && type != DHCPRELEASE |
328 | && client_config.vendorclass | 329 | && client_config.vendorclass |
329 | ) { | 330 | ) { |
330 | udhcp_add_option_string(packet->options, client_config.vendorclass); | 331 | udhcp_add_binary_option(packet->options, client_config.vendorclass); |
331 | } | 332 | } |
332 | } | 333 | } |
333 | 334 | ||
334 | static void add_client_options(struct dhcp_packet *packet) | 335 | static void add_client_options(struct dhcp_packet *packet) |
335 | { | 336 | { |
336 | /* Add am "param req" option with the list of options we'd like to have | 337 | /* Add am "param req" option with the list of options we'd like to have |
337 | * from stubborn DHCP servers. Pull the data from the struct in options.c. | 338 | * from stubborn DHCP servers. Pull the data from the struct in common.c. |
338 | * No bounds checking because it goes towards the head of the packet. */ | 339 | * No bounds checking because it goes towards the head of the packet. */ |
339 | uint8_t c; | 340 | uint8_t c; |
340 | int end = udhcp_end_option(packet->options); | 341 | int end = udhcp_end_option(packet->options); |
@@ -360,7 +361,7 @@ static void add_client_options(struct dhcp_packet *packet) | |||
360 | { | 361 | { |
361 | struct option_set *curr = client_config.options; | 362 | struct option_set *curr = client_config.options; |
362 | while (curr) { | 363 | while (curr) { |
363 | udhcp_add_option_string(packet->options, curr->data); | 364 | udhcp_add_binary_option(packet->options, curr->data); |
364 | curr = curr->next; | 365 | curr = curr->next; |
365 | } | 366 | } |
366 | // if (client_config.sname) | 367 | // if (client_config.sname) |