diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-04-04 15:28:49 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-04-04 15:28:49 +0200 |
commit | c03602baa483ed07230c88075121e0f56a4c0428 (patch) | |
tree | 4185c42418e667ce8aae969faf198bc858f24071 | |
parent | 9c0ea86caa2170aee0638b9a8120aeb0f66ca5be (diff) | |
download | busybox-w32-c03602baa483ed07230c88075121e0f56a4c0428.tar.gz busybox-w32-c03602baa483ed07230c88075121e0f56a4c0428.tar.bz2 busybox-w32-c03602baa483ed07230c88075121e0f56a4c0428.zip |
udhcp: s/dhcp_option/dhcp_optflag/g
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/udhcp/common.c | 40 | ||||
-rw-r--r-- | networking/udhcp/common.h | 4 | ||||
-rw-r--r-- | networking/udhcp/dhcpc.c | 24 |
3 files changed, 34 insertions, 34 deletions
diff --git a/networking/udhcp/common.c b/networking/udhcp/common.c index 77d7fd5d4..fb4f8d16c 100644 --- a/networking/udhcp/common.c +++ b/networking/udhcp/common.c | |||
@@ -18,7 +18,7 @@ const uint8_t MAC_BCAST_ADDR[6] ALIGN2 = { | |||
18 | * See RFC2132 for more options. | 18 | * See RFC2132 for more options. |
19 | * OPTION_REQ: these options are requested by udhcpc (unless -o). | 19 | * OPTION_REQ: these options are requested by udhcpc (unless -o). |
20 | */ | 20 | */ |
21 | const struct dhcp_option dhcp_options[] = { | 21 | const struct dhcp_optflag dhcp_optflags[] = { |
22 | /* flags code */ | 22 | /* flags code */ |
23 | { OPTION_IP | OPTION_REQ, 0x01 }, /* DHCP_SUBNET */ | 23 | { OPTION_IP | OPTION_REQ, 0x01 }, /* DHCP_SUBNET */ |
24 | { OPTION_S32 , 0x02 }, /* DHCP_TIME_OFFSET */ | 24 | { OPTION_S32 , 0x02 }, /* DHCP_TIME_OFFSET */ |
@@ -76,7 +76,7 @@ const struct dhcp_option dhcp_options[] = { | |||
76 | * for udhcpc stript, and for setting options for udhcpd via | 76 | * for udhcpc stript, and for setting options for udhcpd via |
77 | * "opt OPTION_NAME OPTION_VALUE" directives in udhcpd.conf file. | 77 | * "opt OPTION_NAME OPTION_VALUE" directives in udhcpd.conf file. |
78 | */ | 78 | */ |
79 | /* Must match dhcp_options[] order */ | 79 | /* Must match dhcp_optflags[] order */ |
80 | const char dhcp_option_strings[] ALIGN1 = | 80 | const char dhcp_option_strings[] ALIGN1 = |
81 | "subnet" "\0" /* DHCP_SUBNET */ | 81 | "subnet" "\0" /* DHCP_SUBNET */ |
82 | "timezone" "\0" /* DHCP_TIME_OFFSET */ | 82 | "timezone" "\0" /* DHCP_TIME_OFFSET */ |
@@ -278,9 +278,9 @@ void FAST_FUNC udhcp_add_binary_option(struct dhcp_packet *packet, uint8_t *addo | |||
278 | /* Add an one to four byte option to a packet */ | 278 | /* Add an one to four byte option to a packet */ |
279 | void FAST_FUNC udhcp_add_simple_option(struct dhcp_packet *packet, uint8_t code, uint32_t data) | 279 | void FAST_FUNC udhcp_add_simple_option(struct dhcp_packet *packet, uint8_t code, uint32_t data) |
280 | { | 280 | { |
281 | const struct dhcp_option *dh; | 281 | const struct dhcp_optflag *dh; |
282 | 282 | ||
283 | for (dh = dhcp_options; dh->code; dh++) { | 283 | for (dh = dhcp_optflags; dh->code; dh++) { |
284 | if (dh->code == code) { | 284 | if (dh->code == code) { |
285 | uint8_t option[6], len; | 285 | uint8_t option[6], len; |
286 | 286 | ||
@@ -330,7 +330,7 @@ int FAST_FUNC udhcp_str2nip(const char *str, void *arg) | |||
330 | /* helper: add an option to the opt_list */ | 330 | /* helper: add an option to the opt_list */ |
331 | static NOINLINE void attach_option( | 331 | static NOINLINE void attach_option( |
332 | struct option_set **opt_list, | 332 | struct option_set **opt_list, |
333 | const struct dhcp_option *option, | 333 | const struct dhcp_optflag *optflag, |
334 | char *buffer, | 334 | char *buffer, |
335 | int length) | 335 | int length) |
336 | { | 336 | { |
@@ -339,11 +339,11 @@ static NOINLINE void attach_option( | |||
339 | char *allocated = NULL; | 339 | char *allocated = NULL; |
340 | #endif | 340 | #endif |
341 | 341 | ||
342 | existing = udhcp_find_option(*opt_list, option->code); | 342 | existing = udhcp_find_option(*opt_list, optflag->code); |
343 | if (!existing) { | 343 | if (!existing) { |
344 | log2("Attaching option %02x to list", option->code); | 344 | log2("Attaching option %02x to list", optflag->code); |
345 | #if ENABLE_FEATURE_UDHCP_RFC3397 | 345 | #if ENABLE_FEATURE_UDHCP_RFC3397 |
346 | if ((option->flags & OPTION_TYPE_MASK) == OPTION_DNS_STRING) { | 346 | if ((optflag->flags & OPTION_TYPE_MASK) == OPTION_DNS_STRING) { |
347 | /* reuse buffer and length for RFC1035-formatted string */ | 347 | /* reuse buffer and length for RFC1035-formatted string */ |
348 | allocated = buffer = (char *)dname_enc(NULL, 0, buffer, &length); | 348 | allocated = buffer = (char *)dname_enc(NULL, 0, buffer, &length); |
349 | } | 349 | } |
@@ -351,12 +351,12 @@ static NOINLINE void attach_option( | |||
351 | /* make a new option */ | 351 | /* make a new option */ |
352 | new = xmalloc(sizeof(*new)); | 352 | new = xmalloc(sizeof(*new)); |
353 | new->data = xmalloc(length + OPT_DATA); | 353 | new->data = xmalloc(length + OPT_DATA); |
354 | new->data[OPT_CODE] = option->code; | 354 | new->data[OPT_CODE] = optflag->code; |
355 | new->data[OPT_LEN] = length; | 355 | new->data[OPT_LEN] = length; |
356 | memcpy(new->data + OPT_DATA, buffer, length); | 356 | memcpy(new->data + OPT_DATA, buffer, length); |
357 | 357 | ||
358 | curr = opt_list; | 358 | curr = opt_list; |
359 | while (*curr && (*curr)->data[OPT_CODE] < option->code) | 359 | while (*curr && (*curr)->data[OPT_CODE] < optflag->code) |
360 | curr = &(*curr)->next; | 360 | curr = &(*curr)->next; |
361 | 361 | ||
362 | new->next = *curr; | 362 | new->next = *curr; |
@@ -364,14 +364,14 @@ static NOINLINE void attach_option( | |||
364 | goto ret; | 364 | goto ret; |
365 | } | 365 | } |
366 | 366 | ||
367 | if (option->flags & OPTION_LIST) { | 367 | if (optflag->flags & OPTION_LIST) { |
368 | unsigned old_len; | 368 | unsigned old_len; |
369 | 369 | ||
370 | /* add it to an existing option */ | 370 | /* add it to an existing option */ |
371 | log1("Attaching option %02x to existing member of list", option->code); | 371 | log1("Attaching option %02x to existing member of list", optflag->code); |
372 | old_len = existing->data[OPT_LEN]; | 372 | old_len = existing->data[OPT_LEN]; |
373 | #if ENABLE_FEATURE_UDHCP_RFC3397 | 373 | #if ENABLE_FEATURE_UDHCP_RFC3397 |
374 | if ((option->flags & OPTION_TYPE_MASK) == OPTION_DNS_STRING) { | 374 | if ((optflag->flags & OPTION_TYPE_MASK) == OPTION_DNS_STRING) { |
375 | /* reuse buffer and length for RFC1035-formatted string */ | 375 | /* reuse buffer and length for RFC1035-formatted string */ |
376 | allocated = buffer = (char *)dname_enc(existing->data + OPT_DATA, old_len, buffer, &length); | 376 | allocated = buffer = (char *)dname_enc(existing->data + OPT_DATA, old_len, buffer, &length); |
377 | } | 377 | } |
@@ -380,7 +380,7 @@ static NOINLINE void attach_option( | |||
380 | /* actually 255 is ok too, but adding a space can overlow it */ | 380 | /* actually 255 is ok too, but adding a space can overlow it */ |
381 | 381 | ||
382 | existing->data = xrealloc(existing->data, OPT_DATA + 1 + old_len + length); | 382 | existing->data = xrealloc(existing->data, OPT_DATA + 1 + old_len + length); |
383 | if ((option->flags & OPTION_TYPE_MASK) == OPTION_STRING) { | 383 | if ((optflag->flags & OPTION_TYPE_MASK) == OPTION_STRING) { |
384 | /* add space separator between STRING options in a list */ | 384 | /* add space separator between STRING options in a list */ |
385 | existing->data[OPT_DATA + old_len] = ' '; | 385 | existing->data[OPT_DATA + old_len] = ' '; |
386 | old_len++; | 386 | old_len++; |
@@ -401,7 +401,7 @@ int FAST_FUNC udhcp_str2optset(const char *const_str, void *arg) | |||
401 | struct option_set **opt_list = arg; | 401 | struct option_set **opt_list = arg; |
402 | char *opt, *val, *endptr; | 402 | char *opt, *val, *endptr; |
403 | char *str; | 403 | char *str; |
404 | const struct dhcp_option *option; | 404 | const struct dhcp_optflag *optflag; |
405 | int retval, length; | 405 | int retval, length; |
406 | char buffer[8] ALIGNED(4); | 406 | char buffer[8] ALIGNED(4); |
407 | uint16_t *result_u16 = (uint16_t *) buffer; | 407 | uint16_t *result_u16 = (uint16_t *) buffer; |
@@ -413,17 +413,17 @@ int FAST_FUNC udhcp_str2optset(const char *const_str, void *arg) | |||
413 | if (!opt) | 413 | if (!opt) |
414 | return 0; | 414 | return 0; |
415 | 415 | ||
416 | option = &dhcp_options[udhcp_option_idx(opt)]; | 416 | optflag = &dhcp_optflags[udhcp_option_idx(opt)]; |
417 | 417 | ||
418 | retval = 0; | 418 | retval = 0; |
419 | do { | 419 | do { |
420 | val = strtok(NULL, ", \t"); | 420 | val = strtok(NULL, ", \t"); |
421 | if (!val) | 421 | if (!val) |
422 | break; | 422 | break; |
423 | length = dhcp_option_lengths[option->flags & OPTION_TYPE_MASK]; | 423 | length = dhcp_option_lengths[optflag->flags & OPTION_TYPE_MASK]; |
424 | retval = 0; | 424 | retval = 0; |
425 | opt = buffer; /* new meaning for variable opt */ | 425 | opt = buffer; /* new meaning for variable opt */ |
426 | switch (option->flags & OPTION_TYPE_MASK) { | 426 | switch (optflag->flags & OPTION_TYPE_MASK) { |
427 | case OPTION_IP: | 427 | case OPTION_IP: |
428 | retval = udhcp_str2nip(val, buffer); | 428 | retval = udhcp_str2nip(val, buffer); |
429 | break; | 429 | break; |
@@ -486,8 +486,8 @@ int FAST_FUNC udhcp_str2optset(const char *const_str, void *arg) | |||
486 | break; | 486 | break; |
487 | } | 487 | } |
488 | if (retval) | 488 | if (retval) |
489 | attach_option(opt_list, option, opt, length); | 489 | attach_option(opt_list, optflag, opt, length); |
490 | } while (retval && option->flags & OPTION_LIST); | 490 | } while (retval && optflag->flags & OPTION_LIST); |
491 | 491 | ||
492 | return retval; | 492 | return retval; |
493 | } | 493 | } |
diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h index 28e34718a..7dd1f119a 100644 --- a/networking/udhcp/common.h +++ b/networking/udhcp/common.h | |||
@@ -157,7 +157,7 @@ enum { | |||
157 | #define DHCP_MINTYPE DHCPDISCOVER | 157 | #define DHCP_MINTYPE DHCPDISCOVER |
158 | #define DHCP_MAXTYPE DHCPINFORM | 158 | #define DHCP_MAXTYPE DHCPINFORM |
159 | 159 | ||
160 | struct dhcp_option { | 160 | struct dhcp_optflag { |
161 | uint8_t flags; | 161 | uint8_t flags; |
162 | uint8_t code; | 162 | uint8_t code; |
163 | }; | 163 | }; |
@@ -167,7 +167,7 @@ struct option_set { | |||
167 | struct option_set *next; | 167 | struct option_set *next; |
168 | }; | 168 | }; |
169 | 169 | ||
170 | extern const struct dhcp_option dhcp_options[]; | 170 | extern const struct dhcp_optflag dhcp_optflags[]; |
171 | extern const char dhcp_option_strings[]; | 171 | extern const char dhcp_option_strings[]; |
172 | extern const uint8_t dhcp_option_lengths[]; | 172 | extern const uint8_t dhcp_option_lengths[]; |
173 | 173 | ||
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index 1caf89559..24ff82d2f 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
@@ -81,7 +81,7 @@ static int mton(uint32_t mask) | |||
81 | } | 81 | } |
82 | 82 | ||
83 | /* Create "opt_name=opt_value" string */ | 83 | /* Create "opt_name=opt_value" string */ |
84 | static NOINLINE char *xmalloc_optname_optval(uint8_t *option, const struct dhcp_option *type_p, const char *opt_name) | 84 | static NOINLINE char *xmalloc_optname_optval(uint8_t *option, const struct dhcp_optflag *optflag, const char *opt_name) |
85 | { | 85 | { |
86 | unsigned upper_length; | 86 | unsigned upper_length; |
87 | int len, type, optlen; | 87 | int len, type, optlen; |
@@ -89,7 +89,7 @@ static NOINLINE char *xmalloc_optname_optval(uint8_t *option, const struct dhcp_ | |||
89 | 89 | ||
90 | /* option points to OPT_DATA, need to go back and get OPT_LEN */ | 90 | /* option points to OPT_DATA, need to go back and get OPT_LEN */ |
91 | len = option[OPT_LEN - OPT_DATA]; | 91 | len = option[OPT_LEN - OPT_DATA]; |
92 | type = type_p->flags & OPTION_TYPE_MASK; | 92 | type = optflag->flags & OPTION_TYPE_MASK; |
93 | optlen = dhcp_option_lengths[type]; | 93 | optlen = dhcp_option_lengths[type]; |
94 | upper_length = len_of_option_as_string[type] * ((unsigned)len / (unsigned)optlen); | 94 | upper_length = len_of_option_as_string[type] * ((unsigned)len / (unsigned)optlen); |
95 | 95 | ||
@@ -105,7 +105,7 @@ static NOINLINE char *xmalloc_optname_optval(uint8_t *option, const struct dhcp_ | |||
105 | optlen = 4; | 105 | optlen = 4; |
106 | case OPTION_IP: | 106 | case OPTION_IP: |
107 | dest += sprint_nip(dest, "", option); | 107 | dest += sprint_nip(dest, "", option); |
108 | // TODO: it can be a list only if (type_p->flags & OPTION_LIST). | 108 | // TODO: it can be a list only if (optflag->flags & OPTION_LIST). |
109 | // Should we bail out/warn if we see multi-ip option which is | 109 | // Should we bail out/warn if we see multi-ip option which is |
110 | // not allowed to be such? For example, DHCP_BROADCAST... | 110 | // not allowed to be such? For example, DHCP_BROADCAST... |
111 | break; | 111 | break; |
@@ -237,10 +237,10 @@ static char **fill_envp(struct dhcp_packet *packet) | |||
237 | uint8_t over = 0; | 237 | uint8_t over = 0; |
238 | 238 | ||
239 | if (packet) { | 239 | if (packet) { |
240 | for (i = 0; dhcp_options[i].code; i++) { | 240 | for (i = 0; dhcp_optflags[i].code; i++) { |
241 | if (udhcp_get_option(packet, dhcp_options[i].code)) { | 241 | if (udhcp_get_option(packet, dhcp_optflags[i].code)) { |
242 | num_options++; | 242 | num_options++; |
243 | if (dhcp_options[i].code == DHCP_SUBNET) | 243 | if (dhcp_optflags[i].code == DHCP_SUBNET) |
244 | num_options++; /* for mton */ | 244 | num_options++; /* for mton */ |
245 | } | 245 | } |
246 | } | 246 | } |
@@ -269,14 +269,14 @@ static char **fill_envp(struct dhcp_packet *packet) | |||
269 | opt_name = dhcp_option_strings; | 269 | opt_name = dhcp_option_strings; |
270 | i = 0; | 270 | i = 0; |
271 | while (*opt_name) { | 271 | while (*opt_name) { |
272 | temp = udhcp_get_option(packet, dhcp_options[i].code); | 272 | temp = udhcp_get_option(packet, dhcp_optflags[i].code); |
273 | if (!temp) | 273 | if (!temp) |
274 | goto next; | 274 | goto next; |
275 | *curr = xmalloc_optname_optval(temp, &dhcp_options[i], opt_name); | 275 | *curr = xmalloc_optname_optval(temp, &dhcp_optflags[i], opt_name); |
276 | putenv(*curr++); | 276 | putenv(*curr++); |
277 | 277 | ||
278 | /* Fill in a subnet bits option for things like /24 */ | 278 | /* Fill in a subnet bits option for things like /24 */ |
279 | if (dhcp_options[i].code == DHCP_SUBNET) { | 279 | if (dhcp_optflags[i].code == DHCP_SUBNET) { |
280 | uint32_t subnet; | 280 | uint32_t subnet; |
281 | move_from_unaligned32(subnet, temp); | 281 | move_from_unaligned32(subnet, temp); |
282 | *curr = xasprintf("mask=%d", mton(subnet)); | 282 | *curr = xasprintf("mask=%d", mton(subnet)); |
@@ -366,8 +366,8 @@ static void add_client_options(struct dhcp_packet *packet) | |||
366 | int end = udhcp_end_option(packet->options); | 366 | int end = udhcp_end_option(packet->options); |
367 | int i, len = 0; | 367 | int i, len = 0; |
368 | 368 | ||
369 | for (i = 0; (c = dhcp_options[i].code) != 0; i++) { | 369 | for (i = 0; (c = dhcp_optflags[i].code) != 0; i++) { |
370 | if (( (dhcp_options[i].flags & OPTION_REQ) | 370 | if (( (dhcp_optflags[i].flags & OPTION_REQ) |
371 | && !client_config.no_default_options | 371 | && !client_config.no_default_options |
372 | ) | 372 | ) |
373 | || (client_config.opt_mask[c >> 3] & (1 << (c & 7))) | 373 | || (client_config.opt_mask[c >> 3] & (1 << (c & 7))) |
@@ -905,7 +905,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
905 | while (list_O) { | 905 | while (list_O) { |
906 | char *optstr = llist_pop(&list_O); | 906 | char *optstr = llist_pop(&list_O); |
907 | unsigned n = udhcp_option_idx(optstr); | 907 | unsigned n = udhcp_option_idx(optstr); |
908 | n = dhcp_options[n].code; | 908 | n = dhcp_optflags[n].code; |
909 | client_config.opt_mask[n >> 3] |= 1 << (n & 7); | 909 | client_config.opt_mask[n >> 3] |= 1 << (n & 7); |
910 | } | 910 | } |
911 | while (list_x) { | 911 | while (list_x) { |