diff options
author | Denis Vlasenko | 2007-11-29 08:17:45 +0000 |
---|---|---|
committer | Denis Vlasenko | 2007-11-29 08:17:45 +0000 |
commit | b539c8452f823a377bf629cf0e44ccda4a16c6c4 (patch) | |
tree | e131460f8227136ba2a76b1cc57efb491bd2f548 /networking/udhcp/files.c | |
parent | 64309f8669f08f2c3c16a3b5bf82d9cae84ec388 (diff) | |
download | busybox-b539c8452f823a377bf629cf0e44ccda4a16c6c4.zip busybox-b539c8452f823a377bf629cf0e44ccda4a16c6c4.tar.gz |
dhcp: heed TODO item - divorced options from their string descriptions
code shrink while at it.
function old new delta
dhcp_option_strings - 258 +258
udhcp_run_script 1135 1174 +39
dhcp_option_lengths - 11 +11
udhcp_add_simple_option 93 92 -1
packet_num 4 - -4
read_opt 746 739 -7
udhcp_option_lengths 11 - -11
udhcpc_main 2590 2494 -96
dhcp_options 490 70 -420
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 1/4 up/down: 308/-539) Total: -231 bytes
text data bss dec hex filename
775309 929 9100 785338 bfbba busybox_old
775098 929 9084 785111 bfad7 busybox_unstripped
Diffstat (limited to 'networking/udhcp/files.c')
-rw-r--r-- | networking/udhcp/files.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/networking/udhcp/files.c b/networking/udhcp/files.c index 5026598..63c9064 100644 --- a/networking/udhcp/files.c +++ b/networking/udhcp/files.c @@ -71,7 +71,7 @@ static int read_yn(const char *line, void *arg) /* find option 'code' in opt_list */ -struct option_set *find_option(struct option_set *opt_list, char code) +struct option_set *find_option(struct option_set *opt_list, uint8_t code) { while (opt_list && opt_list->data[OPT_CODE] < code) opt_list = opt_list->next; @@ -154,31 +154,29 @@ static int read_opt(const char *const_line, void *arg) { struct option_set **opt_list = arg; char *opt, *val, *endptr; - const struct dhcp_option *option; - int retval = 0, length; - char buffer[8]; char *line; + const struct dhcp_option *option; + int retval, length, idx; + char buffer[8] __attribute__((aligned(4))); uint16_t *result_u16 = (uint16_t *) buffer; uint32_t *result_u32 = (uint32_t *) buffer; /* Cheat, the only const line we'll actually get is "" */ line = (char *) const_line; opt = strtok(line, " \t="); - if (!opt) return 0; + if (!opt) + return 0; - option = dhcp_options; - while (1) { - if (!option->code) - return 0; - if (!strcasecmp(option->opt_name, opt)) - break; - option++; - } + idx = index_in_strings(opt, dhcp_option_strings); /* NB: was strcasecmp! */ + if (idx < 0) + return 0; + option = &dhcp_options[idx]; + retval = 0; do { val = strtok(NULL, ", \t"); if (!val) break; - length = option_lengths[option->flags & TYPE_MASK]; + length = dhcp_option_lengths[option->flags & TYPE_MASK]; retval = 0; opt = buffer; /* new meaning for variable opt */ switch (option->flags & TYPE_MASK) { |