diff options
author | Denys Vlasenko | 2010-04-04 15:28:49 +0200 |
---|---|---|
committer | Denys Vlasenko | 2010-04-04 15:28:49 +0200 |
commit | c03602baa483ed07230c88075121e0f56a4c0428 (patch) | |
tree | 4185c42418e667ce8aae969faf198bc858f24071 /networking/udhcp | |
parent | 9c0ea86caa2170aee0638b9a8120aeb0f66ca5be (diff) | |
download | busybox-c03602baa483ed07230c88075121e0f56a4c0428.zip busybox-c03602baa483ed07230c88075121e0f56a4c0428.tar.gz |
udhcp: s/dhcp_option/dhcp_optflag/g
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/udhcp')
-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 77d7fd5..fb4f8d1 100644 --- a/networking/udhcp/common.c +++ b/networking/udhcp/common.c @@ -18,7 +18,7 @@ const uint8_t MAC_BCAST_ADDR[6] ALIGN2 = { * See RFC2132 for more options. * OPTION_REQ: these options are requested by udhcpc (unless -o). */ -const struct dhcp_option dhcp_options[] = { +const struct dhcp_optflag dhcp_optflags[] = { /* flags code */ { OPTION_IP | OPTION_REQ, 0x01 }, /* DHCP_SUBNET */ { OPTION_S32 , 0x02 }, /* DHCP_TIME_OFFSET */ @@ -76,7 +76,7 @@ const struct dhcp_option dhcp_options[] = { * for udhcpc stript, and for setting options for udhcpd via * "opt OPTION_NAME OPTION_VALUE" directives in udhcpd.conf file. */ -/* Must match dhcp_options[] order */ +/* Must match dhcp_optflags[] order */ const char dhcp_option_strings[] ALIGN1 = "subnet" "\0" /* DHCP_SUBNET */ "timezone" "\0" /* DHCP_TIME_OFFSET */ @@ -278,9 +278,9 @@ void FAST_FUNC udhcp_add_binary_option(struct dhcp_packet *packet, uint8_t *addo /* Add an one to four byte option to a packet */ void FAST_FUNC udhcp_add_simple_option(struct dhcp_packet *packet, uint8_t code, uint32_t data) { - const struct dhcp_option *dh; + const struct dhcp_optflag *dh; - for (dh = dhcp_options; dh->code; dh++) { + for (dh = dhcp_optflags; dh->code; dh++) { if (dh->code == code) { uint8_t option[6], len; @@ -330,7 +330,7 @@ int FAST_FUNC udhcp_str2nip(const char *str, void *arg) /* helper: add an option to the opt_list */ static NOINLINE void attach_option( struct option_set **opt_list, - const struct dhcp_option *option, + const struct dhcp_optflag *optflag, char *buffer, int length) { @@ -339,11 +339,11 @@ static NOINLINE void attach_option( char *allocated = NULL; #endif - existing = udhcp_find_option(*opt_list, option->code); + existing = udhcp_find_option(*opt_list, optflag->code); if (!existing) { - log2("Attaching option %02x to list", option->code); + log2("Attaching option %02x to list", optflag->code); #if ENABLE_FEATURE_UDHCP_RFC3397 - if ((option->flags & OPTION_TYPE_MASK) == OPTION_DNS_STRING) { + if ((optflag->flags & OPTION_TYPE_MASK) == OPTION_DNS_STRING) { /* reuse buffer and length for RFC1035-formatted string */ allocated = buffer = (char *)dname_enc(NULL, 0, buffer, &length); } @@ -351,12 +351,12 @@ static NOINLINE void attach_option( /* make a new option */ new = xmalloc(sizeof(*new)); new->data = xmalloc(length + OPT_DATA); - new->data[OPT_CODE] = option->code; + new->data[OPT_CODE] = optflag->code; new->data[OPT_LEN] = length; memcpy(new->data + OPT_DATA, buffer, length); curr = opt_list; - while (*curr && (*curr)->data[OPT_CODE] < option->code) + while (*curr && (*curr)->data[OPT_CODE] < optflag->code) curr = &(*curr)->next; new->next = *curr; @@ -364,14 +364,14 @@ static NOINLINE void attach_option( goto ret; } - if (option->flags & OPTION_LIST) { + if (optflag->flags & OPTION_LIST) { unsigned old_len; /* add it to an existing option */ - log1("Attaching option %02x to existing member of list", option->code); + log1("Attaching option %02x to existing member of list", optflag->code); old_len = existing->data[OPT_LEN]; #if ENABLE_FEATURE_UDHCP_RFC3397 - if ((option->flags & OPTION_TYPE_MASK) == OPTION_DNS_STRING) { + if ((optflag->flags & OPTION_TYPE_MASK) == OPTION_DNS_STRING) { /* reuse buffer and length for RFC1035-formatted string */ allocated = buffer = (char *)dname_enc(existing->data + OPT_DATA, old_len, buffer, &length); } @@ -380,7 +380,7 @@ static NOINLINE void attach_option( /* actually 255 is ok too, but adding a space can overlow it */ existing->data = xrealloc(existing->data, OPT_DATA + 1 + old_len + length); - if ((option->flags & OPTION_TYPE_MASK) == OPTION_STRING) { + if ((optflag->flags & OPTION_TYPE_MASK) == OPTION_STRING) { /* add space separator between STRING options in a list */ existing->data[OPT_DATA + old_len] = ' '; old_len++; @@ -401,7 +401,7 @@ int FAST_FUNC udhcp_str2optset(const char *const_str, void *arg) struct option_set **opt_list = arg; char *opt, *val, *endptr; char *str; - const struct dhcp_option *option; + const struct dhcp_optflag *optflag; int retval, length; char buffer[8] ALIGNED(4); uint16_t *result_u16 = (uint16_t *) buffer; @@ -413,17 +413,17 @@ int FAST_FUNC udhcp_str2optset(const char *const_str, void *arg) if (!opt) return 0; - option = &dhcp_options[udhcp_option_idx(opt)]; + optflag = &dhcp_optflags[udhcp_option_idx(opt)]; retval = 0; do { val = strtok(NULL, ", \t"); if (!val) break; - length = dhcp_option_lengths[option->flags & OPTION_TYPE_MASK]; + length = dhcp_option_lengths[optflag->flags & OPTION_TYPE_MASK]; retval = 0; opt = buffer; /* new meaning for variable opt */ - switch (option->flags & OPTION_TYPE_MASK) { + switch (optflag->flags & OPTION_TYPE_MASK) { case OPTION_IP: retval = udhcp_str2nip(val, buffer); break; @@ -486,8 +486,8 @@ int FAST_FUNC udhcp_str2optset(const char *const_str, void *arg) break; } if (retval) - attach_option(opt_list, option, opt, length); - } while (retval && option->flags & OPTION_LIST); + attach_option(opt_list, optflag, opt, length); + } while (retval && optflag->flags & OPTION_LIST); return retval; } diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h index 28e3471..7dd1f11 100644 --- a/networking/udhcp/common.h +++ b/networking/udhcp/common.h @@ -157,7 +157,7 @@ enum { #define DHCP_MINTYPE DHCPDISCOVER #define DHCP_MAXTYPE DHCPINFORM -struct dhcp_option { +struct dhcp_optflag { uint8_t flags; uint8_t code; }; @@ -167,7 +167,7 @@ struct option_set { struct option_set *next; }; -extern const struct dhcp_option dhcp_options[]; +extern const struct dhcp_optflag dhcp_optflags[]; extern const char dhcp_option_strings[]; extern const uint8_t dhcp_option_lengths[]; diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index 1caf895..24ff82d 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c @@ -81,7 +81,7 @@ static int mton(uint32_t mask) } /* Create "opt_name=opt_value" string */ -static NOINLINE char *xmalloc_optname_optval(uint8_t *option, const struct dhcp_option *type_p, const char *opt_name) +static NOINLINE char *xmalloc_optname_optval(uint8_t *option, const struct dhcp_optflag *optflag, const char *opt_name) { unsigned upper_length; int len, type, optlen; @@ -89,7 +89,7 @@ static NOINLINE char *xmalloc_optname_optval(uint8_t *option, const struct dhcp_ /* option points to OPT_DATA, need to go back and get OPT_LEN */ len = option[OPT_LEN - OPT_DATA]; - type = type_p->flags & OPTION_TYPE_MASK; + type = optflag->flags & OPTION_TYPE_MASK; optlen = dhcp_option_lengths[type]; upper_length = len_of_option_as_string[type] * ((unsigned)len / (unsigned)optlen); @@ -105,7 +105,7 @@ static NOINLINE char *xmalloc_optname_optval(uint8_t *option, const struct dhcp_ optlen = 4; case OPTION_IP: dest += sprint_nip(dest, "", option); -// TODO: it can be a list only if (type_p->flags & OPTION_LIST). +// TODO: it can be a list only if (optflag->flags & OPTION_LIST). // Should we bail out/warn if we see multi-ip option which is // not allowed to be such? For example, DHCP_BROADCAST... break; @@ -237,10 +237,10 @@ static char **fill_envp(struct dhcp_packet *packet) uint8_t over = 0; if (packet) { - for (i = 0; dhcp_options[i].code; i++) { - if (udhcp_get_option(packet, dhcp_options[i].code)) { + for (i = 0; dhcp_optflags[i].code; i++) { + if (udhcp_get_option(packet, dhcp_optflags[i].code)) { num_options++; - if (dhcp_options[i].code == DHCP_SUBNET) + if (dhcp_optflags[i].code == DHCP_SUBNET) num_options++; /* for mton */ } } @@ -269,14 +269,14 @@ static char **fill_envp(struct dhcp_packet *packet) opt_name = dhcp_option_strings; i = 0; while (*opt_name) { - temp = udhcp_get_option(packet, dhcp_options[i].code); + temp = udhcp_get_option(packet, dhcp_optflags[i].code); if (!temp) goto next; - *curr = xmalloc_optname_optval(temp, &dhcp_options[i], opt_name); + *curr = xmalloc_optname_optval(temp, &dhcp_optflags[i], opt_name); putenv(*curr++); /* Fill in a subnet bits option for things like /24 */ - if (dhcp_options[i].code == DHCP_SUBNET) { + if (dhcp_optflags[i].code == DHCP_SUBNET) { uint32_t subnet; move_from_unaligned32(subnet, temp); *curr = xasprintf("mask=%d", mton(subnet)); @@ -366,8 +366,8 @@ static void add_client_options(struct dhcp_packet *packet) int end = udhcp_end_option(packet->options); int i, len = 0; - for (i = 0; (c = dhcp_options[i].code) != 0; i++) { - if (( (dhcp_options[i].flags & OPTION_REQ) + for (i = 0; (c = dhcp_optflags[i].code) != 0; i++) { + if (( (dhcp_optflags[i].flags & OPTION_REQ) && !client_config.no_default_options ) || (client_config.opt_mask[c >> 3] & (1 << (c & 7))) @@ -905,7 +905,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) while (list_O) { char *optstr = llist_pop(&list_O); unsigned n = udhcp_option_idx(optstr); - n = dhcp_options[n].code; + n = dhcp_optflags[n].code; client_config.opt_mask[n >> 3] |= 1 << (n & 7); } while (list_x) { |