aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/files.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/udhcp/files.c')
-rw-r--r--networking/udhcp/files.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/networking/udhcp/files.c b/networking/udhcp/files.c
index 5026598d7..63c90647d 100644
--- a/networking/udhcp/files.c
+++ b/networking/udhcp/files.c
@@ -71,7 +71,7 @@ static int read_yn(const char *line, void *arg)
71 71
72 72
73/* find option 'code' in opt_list */ 73/* find option 'code' in opt_list */
74struct option_set *find_option(struct option_set *opt_list, char code) 74struct option_set *find_option(struct option_set *opt_list, uint8_t code)
75{ 75{
76 while (opt_list && opt_list->data[OPT_CODE] < code) 76 while (opt_list && opt_list->data[OPT_CODE] < code)
77 opt_list = opt_list->next; 77 opt_list = opt_list->next;
@@ -154,31 +154,29 @@ static int read_opt(const char *const_line, void *arg)
154{ 154{
155 struct option_set **opt_list = arg; 155 struct option_set **opt_list = arg;
156 char *opt, *val, *endptr; 156 char *opt, *val, *endptr;
157 const struct dhcp_option *option;
158 int retval = 0, length;
159 char buffer[8];
160 char *line; 157 char *line;
158 const struct dhcp_option *option;
159 int retval, length, idx;
160 char buffer[8] __attribute__((aligned(4)));
161 uint16_t *result_u16 = (uint16_t *) buffer; 161 uint16_t *result_u16 = (uint16_t *) buffer;
162 uint32_t *result_u32 = (uint32_t *) buffer; 162 uint32_t *result_u32 = (uint32_t *) buffer;
163 163
164 /* Cheat, the only const line we'll actually get is "" */ 164 /* Cheat, the only const line we'll actually get is "" */
165 line = (char *) const_line; 165 line = (char *) const_line;
166 opt = strtok(line, " \t="); 166 opt = strtok(line, " \t=");
167 if (!opt) return 0; 167 if (!opt)
168 return 0;
168 169
169 option = dhcp_options; 170 idx = index_in_strings(opt, dhcp_option_strings); /* NB: was strcasecmp! */
170 while (1) { 171 if (idx < 0)
171 if (!option->code) 172 return 0;
172 return 0; 173 option = &dhcp_options[idx];
173 if (!strcasecmp(option->opt_name, opt))
174 break;
175 option++;
176 }
177 174
175 retval = 0;
178 do { 176 do {
179 val = strtok(NULL, ", \t"); 177 val = strtok(NULL, ", \t");
180 if (!val) break; 178 if (!val) break;
181 length = option_lengths[option->flags & TYPE_MASK]; 179 length = dhcp_option_lengths[option->flags & TYPE_MASK];
182 retval = 0; 180 retval = 0;
183 opt = buffer; /* new meaning for variable opt */ 181 opt = buffer; /* new meaning for variable opt */
184 switch (option->flags & TYPE_MASK) { 182 switch (option->flags & TYPE_MASK) {