FreeBSD/sbin/dhclient/options.c
/*
 * Parse all available options out of the specified packet.
 */
Parse all available options out of the specified packet.
Parse all available options out of the specified packet .
void
parse_options(struct packet *packet)
{
	memset(packet->options, 0, sizeof(packet->options));
	if (memcmp(packet->raw->options, DHCP_OPTIONS_COOKIE, 4)) {
		packet->options_valid = 0;
		return;
	}
	parse_option_buffer(packet, &packet->raw->options[4],
	    packet->packet_length - DHCP_FIXED_NON_UDP - 4);
	if (packet->options_valid &&
	    packet->options[DHO_DHCP_OPTION_OVERLOAD].data) {
		if (packet->options[DHO_DHCP_OPTION_OVERLOAD].data[0] & 1)
			parse_option_buffer(packet,
			    (unsigned char *)packet->raw->file,
			    sizeof(packet->raw->file));
		if (packet->options[DHO_DHCP_OPTION_OVERLOAD].data[0] & 2)
			parse_option_buffer(packet,
			    (unsigned char *)packet->raw->sname,
			    sizeof(packet->raw->sname));
	}
	if (packet->options_valid) {
		expand_domain_search(packet);
	}
}
void parse_options ( struct packet * packet ) { memset ( packet -> options , 0 , sizeof ( packet -> options ) ) ; if ( memcmp ( packet -> raw -> options , DHCP_OPTIONS_COOKIE , 4 ) ) { packet -> options_valid = 0 ; return ; } parse_option_buffer ( packet , & packet -> raw -> options [ 4 ] , packet -> packet_length - DHCP_FIXED_NON_UDP - 4 ) ; if ( packet -> options_valid && packet -> options [ DHO_DHCP_OPTION_OVERLOAD ] . data ) { if ( packet -> options [ DHO_DHCP_OPTION_OVERLOAD ] . data [ 0 ] & 1 ) parse_option_buffer ( packet , ( unsigned char * ) packet -> raw -> file , sizeof ( packet -> raw -> file ) ) ; if ( packet -> options [ DHO_DHCP_OPTION_OVERLOAD ] . data [ 0 ] & 2 ) parse_option_buffer ( packet , ( unsigned char * ) packet -> raw -> sname , sizeof ( packet -> raw -> sname ) ) ; } if ( packet -> options_valid ) { expand_domain_search ( packet ) ; } }
Parse all available options out of the specified packet.
Parse all available options out of the specified packet .
/* Initially, zero all option pointers. */ /* If we don't see the magic cookie, there's nothing to parse. */ /*
	 * Go through the options field, up to the end of the packet or
	 * the End field.
	 */ /*
	 * If we parsed a DHCP Option Overload option, parse more
	 * options out of the buffer(s) containing them.
	 */ /* Expand DHCP Domain Search option. */