diff options
Diffstat (limited to 'networking/udhcp/options.c')
-rw-r--r-- | networking/udhcp/options.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/networking/udhcp/options.c b/networking/udhcp/options.c index 29a264047..b4d2d2de3 100644 --- a/networking/udhcp/options.c +++ b/networking/udhcp/options.c | |||
@@ -7,8 +7,6 @@ | |||
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include "common.h" | 9 | #include "common.h" |
10 | #include "dhcpd.h" | ||
11 | #include "options.h" | ||
12 | 10 | ||
13 | 11 | ||
14 | /* Supported options are easily added here. | 12 | /* Supported options are easily added here. |
@@ -111,7 +109,6 @@ const char dhcp_option_strings[] ALIGN1 = | |||
111 | "wpad" "\0" /* DHCP_WPAD */ | 109 | "wpad" "\0" /* DHCP_WPAD */ |
112 | ; | 110 | ; |
113 | 111 | ||
114 | |||
115 | /* Lengths of the different option types */ | 112 | /* Lengths of the different option types */ |
116 | const uint8_t dhcp_option_lengths[] ALIGN1 = { | 113 | const uint8_t dhcp_option_lengths[] ALIGN1 = { |
117 | [OPTION_IP] = 4, | 114 | [OPTION_IP] = 4, |
@@ -144,9 +141,8 @@ static void log_option(const char *pfx, const uint8_t *opt) | |||
144 | # define log_option(pfx, opt) ((void)0) | 141 | # define log_option(pfx, opt) ((void)0) |
145 | #endif | 142 | #endif |
146 | 143 | ||
147 | |||
148 | /* get an option with bounds checking (warning, result is not aligned). */ | 144 | /* get an option with bounds checking (warning, result is not aligned). */ |
149 | uint8_t* FAST_FUNC get_option(struct dhcp_packet *packet, int code) | 145 | uint8_t* FAST_FUNC udhcp_get_option(struct dhcp_packet *packet, int code) |
150 | { | 146 | { |
151 | uint8_t *optionptr; | 147 | uint8_t *optionptr; |
152 | int len; | 148 | int len; |
@@ -162,7 +158,7 @@ uint8_t* FAST_FUNC get_option(struct dhcp_packet *packet, int code) | |||
162 | rem = sizeof(packet->options); | 158 | rem = sizeof(packet->options); |
163 | while (1) { | 159 | while (1) { |
164 | if (rem <= 0) { | 160 | if (rem <= 0) { |
165 | bb_error_msg("bogus packet, malformed option field"); | 161 | bb_error_msg("bad packet, malformed option field"); |
166 | return NULL; | 162 | return NULL; |
167 | } | 163 | } |
168 | if (optionptr[OPT_CODE] == DHCP_PADDING) { | 164 | if (optionptr[OPT_CODE] == DHCP_PADDING) { |
@@ -209,9 +205,8 @@ uint8_t* FAST_FUNC get_option(struct dhcp_packet *packet, int code) | |||
209 | return NULL; | 205 | return NULL; |
210 | } | 206 | } |
211 | 207 | ||
212 | |||
213 | /* return the position of the 'end' option (no bounds checking) */ | 208 | /* return the position of the 'end' option (no bounds checking) */ |
214 | int FAST_FUNC end_option(uint8_t *optionptr) | 209 | int FAST_FUNC udhcp_end_option(uint8_t *optionptr) |
215 | { | 210 | { |
216 | int i = 0; | 211 | int i = 0; |
217 | 212 | ||
@@ -223,12 +218,11 @@ int FAST_FUNC end_option(uint8_t *optionptr) | |||
223 | return i; | 218 | return i; |
224 | } | 219 | } |
225 | 220 | ||
226 | |||
227 | /* add an option string to the options */ | 221 | /* add an option string to the options */ |
228 | /* option bytes: [code][len][data1][data2]..[dataLEN] */ | 222 | /* option bytes: [code][len][data1][data2]..[dataLEN] */ |
229 | void FAST_FUNC add_option_string(uint8_t *optionptr, uint8_t *string) | 223 | void FAST_FUNC udhcp_add_option_string(uint8_t *optionptr, uint8_t *string) |
230 | { | 224 | { |
231 | int end = end_option(optionptr); | 225 | int end = udhcp_end_option(optionptr); |
232 | 226 | ||
233 | /* end position + string length + option code/length + end option */ | 227 | /* end position + string length + option code/length + end option */ |
234 | if (end + string[OPT_LEN] + 2 + 1 >= DHCP_OPTIONS_BUFSIZE) { | 228 | if (end + string[OPT_LEN] + 2 + 1 >= DHCP_OPTIONS_BUFSIZE) { |
@@ -241,9 +235,8 @@ void FAST_FUNC add_option_string(uint8_t *optionptr, uint8_t *string) | |||
241 | optionptr[end + string[OPT_LEN] + 2] = DHCP_END; | 235 | optionptr[end + string[OPT_LEN] + 2] = DHCP_END; |
242 | } | 236 | } |
243 | 237 | ||
244 | |||
245 | /* add a one to four byte option to a packet */ | 238 | /* add a one to four byte option to a packet */ |
246 | void FAST_FUNC add_simple_option(uint8_t *optionptr, uint8_t code, uint32_t data) | 239 | void FAST_FUNC udhcp_add_simple_option(uint8_t *optionptr, uint8_t code, uint32_t data) |
247 | { | 240 | { |
248 | const struct dhcp_option *dh; | 241 | const struct dhcp_option *dh; |
249 | 242 | ||
@@ -258,7 +251,7 @@ void FAST_FUNC add_simple_option(uint8_t *optionptr, uint8_t code, uint32_t data | |||
258 | data <<= 8 * (4 - len); | 251 | data <<= 8 * (4 - len); |
259 | /* Assignment is unaligned! */ | 252 | /* Assignment is unaligned! */ |
260 | move_to_unaligned32(&option[OPT_DATA], data); | 253 | move_to_unaligned32(&option[OPT_DATA], data); |
261 | add_option_string(optionptr, option); | 254 | udhcp_add_option_string(optionptr, option); |
262 | return; | 255 | return; |
263 | } | 256 | } |
264 | } | 257 | } |