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
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user