Lines Matching full:options
1 /* $OpenBSD: options.c,v 1.35 2017/02/13 22:33:39 krw Exp $ */
3 /* DHCP options parsing and reassembly. */
72 * Parse all available options out of the specified packet.
78 memset(packet->options, 0, sizeof(packet->options)); in parse_options()
81 if (memcmp(packet->raw->options, DHCP_OPTIONS_COOKIE, 4)) { in parse_options()
87 * Go through the options field, up to the end of the packet or in parse_options()
90 parse_option_buffer(packet, &packet->raw->options[4], in parse_options()
95 * options out of the buffer(s) containing them. in parse_options()
98 packet->options[DHO_DHCP_OPTION_OVERLOAD].data) { in parse_options()
99 if (packet->options[DHO_DHCP_OPTION_OVERLOAD].data[0] & 1) in parse_options()
103 if (packet->options[DHO_DHCP_OPTION_OVERLOAD].data[0] & 2) in parse_options()
111 * Parse options out of the specified buffer, storing addresses of
112 * option values in packet->options and setting packet->options_valid if
127 /* Pad options don't have a length - just skip them. */ in parse_option_buffer()
160 log_warnx("Many bogus options seen in " in parse_option_buffer()
164 log_warnx("options - hope for the best!"); in parse_option_buffer()
175 if (!packet->options[code].data) { in parse_option_buffer()
186 packet->options[code].len = len; in parse_option_buffer()
187 packet->options[code].data = t; in parse_option_buffer()
194 t = calloc(1, len + packet->options[code].len + 1); in parse_option_buffer()
198 memcpy(t, packet->options[code].data, in parse_option_buffer()
199 packet->options[code].len); in parse_option_buffer()
200 memcpy(t + packet->options[code].len, in parse_option_buffer()
202 packet->options[code].len += len; in parse_option_buffer()
203 t[packet->options[code].len] = 0; in parse_option_buffer()
204 free(packet->options[code].data); in parse_option_buffer()
205 packet->options[code].data = t; in parse_option_buffer()
213 * Fill priority_list with a complete list of DHCP options sorted by
215 * 1) Mandatory options.
216 * 2) Options from prl that are not already present.
217 * 3) Options from the default list that are not already present.
229 /* Some options we don't want on the priority list. */ in create_priority_list()
233 /* Mandatory options. */ in create_priority_list()
268 * cons options into a big buffer, and then split them out into the
270 * vendor options using the same routine.
274 int mms, struct tree_cache **options, in cons_options() argument
292 inpacket->options[DHO_DHCP_MAX_MESSAGE_SIZE].data && in cons_options()
293 (inpacket->options[DHO_DHCP_MAX_MESSAGE_SIZE].len >= in cons_options()
296 inpacket->options[DHO_DHCP_MAX_MESSAGE_SIZE].data); in cons_options()
308 if (main_buffer_size > sizeof(outpacket->options)) in cons_options()
309 main_buffer_size = sizeof(outpacket->options); in cons_options()
315 memset(outpacket->options, DHO_PAD, sizeof(outpacket->options)); in cons_options()
324 * Get complete list of possible options in priority order. Use the in cons_options()
325 * list provided in the options. Lacking that use the list provided by in cons_options()
330 inpacket->options[DHO_DHCP_PARAMETER_REQUEST_LIST].data) in cons_options()
332 inpacket->options[DHO_DHCP_PARAMETER_REQUEST_LIST].data, in cons_options()
333 inpacket->options[DHO_DHCP_PARAMETER_REQUEST_LIST].len); in cons_options()
340 * Copy the options into the big buffer, including leading cookie and in cons_options()
344 option_size = store_options(buffer, main_buffer_size, options, in cons_options()
350 memcpy(&outpacket->options[0], buffer, main_buffer_size); in cons_options()
393 * Store all the requested options into the requested buffer. Insert the
394 * required cookie, DHO_DHCP_OPTION_OVERLOAD options and append a DHO_END if
399 struct tree_cache **options, unsigned char *priority_list, int overload, in store_options() argument
422 * Store options in the order they appear in the priority list. in store_options()
430 if (!options[code] || !tree_evaluate(options[code])) in store_options()
439 * DHCP server is sending Classless Static Routes options in store_options()
441 * Router or Static Routes options. in store_options()
448 length = options[code]->len; in store_options()
456 options[code]->value + ix); in store_options()
496 /* Didn't manage to store any options. */ in store_options()
502 /* Fill in overload option value based on space used for options. */ in store_options()
518 * choke on DHO_PAD options there. in store_options()
551 tp.options[DHO_DHCP_MESSAGE_TYPE].data) in do_packet()
552 tp.packet_type = tp.options[DHO_DHCP_MESSAGE_TYPE].data[0]; in do_packet()
559 /* Free the data associated with the options. */ in do_packet()
561 free(tp.options[i].data); in do_packet()