diff options
Diffstat (limited to 'networking/udhcp/d6_dhcpc.c')
-rw-r--r-- | networking/udhcp/d6_dhcpc.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c index 85d9da724..fa1568b5f 100644 --- a/networking/udhcp/d6_dhcpc.c +++ b/networking/udhcp/d6_dhcpc.c | |||
@@ -195,6 +195,34 @@ static char** new_env(void) | |||
195 | return &client6_data.env_ptr[client6_data.env_idx++]; | 195 | return &client6_data.env_ptr[client6_data.env_idx++]; |
196 | } | 196 | } |
197 | 197 | ||
198 | static char *string_option_to_env(uint8_t *option, uint8_t *option_end) | ||
199 | { | ||
200 | const char *ptr, *name = NULL; | ||
201 | unsigned val_len; | ||
202 | int i; | ||
203 | |||
204 | ptr = d6_option_strings; | ||
205 | i = 0; | ||
206 | while (*ptr) { | ||
207 | if (d6_optflags[i].code == option[1]) { | ||
208 | name = ptr; | ||
209 | goto found; | ||
210 | } | ||
211 | ptr += strlen(ptr) + 1; | ||
212 | i++; | ||
213 | } | ||
214 | bb_error_msg("can't find option name for 0x%x, skipping", option[1]); | ||
215 | return NULL; | ||
216 | |||
217 | found: | ||
218 | val_len = (option[2] << 8) | option[3]; | ||
219 | if (val_len + &option[D6_OPT_DATA] > option_end) { | ||
220 | bb_error_msg("option data exceeds option length"); | ||
221 | return NULL; | ||
222 | } | ||
223 | return xasprintf("%s=%.*s", name, val_len, (char*)option + 4); | ||
224 | } | ||
225 | |||
198 | /* put all the parameters into the environment */ | 226 | /* put all the parameters into the environment */ |
199 | static void option_to_env(uint8_t *option, uint8_t *option_end) | 227 | static void option_to_env(uint8_t *option, uint8_t *option_end) |
200 | { | 228 | { |