Beispiel #1
0
void initialize_server_option_spaces()
{
	int i;
	unsigned code;

	/* Set up the Relay Agent Information Option suboption space... */
	agent_universe.name = "agent";
	agent_universe.option_state_dereference =
		linked_option_state_dereference;
	agent_universe.lookup_func = lookup_linked_option;
	agent_universe.save_func = save_linked_option;
	agent_universe.delete_func = delete_linked_option;
	agent_universe.encapsulate = linked_option_space_encapsulate;
	agent_universe.foreach = linked_option_space_foreach;
	agent_universe.decode = parse_option_buffer;
	agent_universe.index = universe_count++;
	agent_universe.length_size = 1;
	agent_universe.tag_size = 1;
	agent_universe.get_tag = getUChar;
	agent_universe.store_tag = putUChar;
	agent_universe.get_length = getUChar;
	agent_universe.store_length = putUChar;
	universes [agent_universe.index] = &agent_universe;
	if (!option_name_new_hash(&agent_universe.name_hash,
				  AGENT_HASH_SIZE, MDL) ||
	    !option_code_new_hash(&agent_universe.code_hash,
				  AGENT_HASH_SIZE, MDL))
		log_fatal ("Can't allocate agent option hash table.");
	for (i = 0 ; agent_options[i].name ; i++) {
		option_code_hash_add(agent_universe.code_hash,
				     &agent_options[i].code, 0,
				     &agent_options[i], MDL);
		option_name_hash_add(agent_universe.name_hash,
				     agent_options[i].name, 0,
				     &agent_options[i], MDL);
	}
#if defined(REPORT_HASH_PERFORMANCE)
	log_info("Relay Agent name hash: %s",
		 option_name_hash_report(agent_universe.name_hash));
	log_info("Relay Agent code hash: %s",
		 option_code_hash_report(agent_universe.code_hash));
#endif
	code = DHO_DHCP_AGENT_OPTIONS;
	option_code_hash_lookup(&agent_universe.enc_opt,
				dhcp_universe.code_hash, &code, 0, MDL);

	/* Set up the server option universe... */
	server_universe.name = "server";
	server_universe.lookup_func = lookup_hashed_option;
	server_universe.option_state_dereference =
		hashed_option_state_dereference;
	server_universe.save_func = save_hashed_option;
	server_universe.delete_func = delete_hashed_option;
	server_universe.encapsulate = hashed_option_space_encapsulate;
	server_universe.foreach = hashed_option_space_foreach;
	server_universe.length_size = 1; /* Never used ... */
	server_universe.tag_size = 4;
	server_universe.store_tag = putUChar;
	server_universe.store_length = putUChar;
	server_universe.index = universe_count++;
	universes [server_universe.index] = &server_universe;
	if (!option_name_new_hash(&server_universe.name_hash,
				  SERVER_HASH_SIZE, MDL) ||
	    !option_code_new_hash(&server_universe.code_hash,
				  SERVER_HASH_SIZE, MDL))
		log_fatal ("Can't allocate server option hash table.");
	for (i = 0 ; server_options[i].name ; i++) {
		option_code_hash_add(server_universe.code_hash,
				     &server_options[i].code, 0,
				     &server_options[i], MDL);
		option_name_hash_add(server_universe.name_hash,
				     server_options[i].name, 0,
				     &server_options[i], MDL);
	}
#if defined(REPORT_HASH_PERFORMANCE)
	log_info("Server-Config Option name hash: %s",
		 option_name_hash_report(server_universe.name_hash));
	log_info("Server-Config Option code hash: %s",
		 option_code_hash_report(server_universe.code_hash));
#endif

	/* Add the server and agent option spaces to the option space hash. */
	universe_hash_add (universe_hash,
			   agent_universe.name, 0, &agent_universe, MDL);
	universe_hash_add (universe_hash,
			   server_universe.name, 0, &server_universe, MDL);

	/* Make the server universe the configuration option universe. */
	config_universe = &server_universe;

	code = SV_VENDOR_OPTION_SPACE;
	option_code_hash_lookup(&vendor_cfg_option, server_universe.code_hash,
				&code, 0, MDL);
}
Beispiel #2
0
void initialize_common_option_spaces()
{
	unsigned code;
	int i;

	/* The 'universes' table is dynamically grown to contain
	 * universe as they're configured - except during startup.
	 * Since we know how many we put down in .c files, we can
	 * allocate a more-than-right-sized buffer now, leaving some
	 * space for user-configured option spaces.
	 *
	 * 1: dhcp_universe (dhcpv4 options)
	 * 2: nwip_universe (dhcpv4 NWIP option)
	 * 3: fqdn_universe (dhcpv4 fqdn option - reusable for v6)
	 * 4: vendor_class_universe (VIVCO)
	 * 5: vendor_universe (VIVSO)
	 * 6: isc_universe (dhcpv4 isc config space)
	 * 7: dhcpv6_universe (dhcpv6 options)
	 * 8: vsio_universe (DHCPv6 Vendor-Identified space)
	 * 9: isc6_universe (ISC's Vendor universe in DHCPv6 VSIO)
	 * 10: fqdn6_universe (dhcpv6 fqdn option shill to v4)
	 * 11: agent_universe (dhcpv4 relay agent - see server/stables.c)
	 * 12: server_universe (server's config, see server/stables.c)
	 * 13: user-config
	 * 14: more user-config
	 * 15: more user-config
	 * 16: more user-config
	 */
	universe_max = 16;
	i = universe_max * sizeof(struct universe *);
	if (i <= 0)
		log_fatal("Ludicrous initial size option space table.");
	universes = dmalloc(i, MDL);
	if (universes == NULL)
		log_fatal("Can't allocate option space table.");
	memset(universes, 0, i);

	/* Set up the DHCP option universe... */
	dhcp_universe.name = "dhcp";
	dhcp_universe.concat_duplicates = 1;
	dhcp_universe.lookup_func = lookup_hashed_option;
	dhcp_universe.option_state_dereference =
		hashed_option_state_dereference;
	dhcp_universe.save_func = save_hashed_option;
	dhcp_universe.delete_func = delete_hashed_option;
	dhcp_universe.encapsulate = hashed_option_space_encapsulate;
	dhcp_universe.foreach = hashed_option_space_foreach;
	dhcp_universe.decode = parse_option_buffer;
	dhcp_universe.length_size = 1;
	dhcp_universe.tag_size = 1;
	dhcp_universe.get_tag = getUChar;
	dhcp_universe.store_tag = putUChar;
	dhcp_universe.get_length = getUChar;
	dhcp_universe.store_length = putUChar;
	dhcp_universe.site_code_min = 0;
	dhcp_universe.end = DHO_END;
	dhcp_universe.index = universe_count++;
	universes [dhcp_universe.index] = &dhcp_universe;
	if (!option_name_new_hash(&dhcp_universe.name_hash,
				  BYTE_NAME_HASH_SIZE, MDL) ||
	    !option_code_new_hash(&dhcp_universe.code_hash,
				  BYTE_CODE_HASH_SIZE, MDL))
		log_fatal ("Can't allocate dhcp option hash table.");
	for (i = 0 ; dhcp_options[i].name ; i++) {
		option_code_hash_add(dhcp_universe.code_hash,
				     &dhcp_options[i].code, 0,
				     &dhcp_options[i], MDL);
		option_name_hash_add(dhcp_universe.name_hash,
				     dhcp_options [i].name, 0,
				     &dhcp_options [i], MDL);
	}
#if defined(REPORT_HASH_PERFORMANCE)
	log_info("DHCP name hash: %s",
		 option_name_hash_report(dhcp_universe.name_hash));
	log_info("DHCP code hash: %s",
		 option_code_hash_report(dhcp_universe.code_hash));
#endif

	/* Set up the Novell option universe (for option 63)... */
	nwip_universe.name = "nwip";
	nwip_universe.concat_duplicates = 0; /* XXX: reference? */
	nwip_universe.lookup_func = lookup_linked_option;
	nwip_universe.option_state_dereference =
		linked_option_state_dereference;
	nwip_universe.save_func = save_linked_option;
	nwip_universe.delete_func = delete_linked_option;
	nwip_universe.encapsulate = nwip_option_space_encapsulate;
	nwip_universe.foreach = linked_option_space_foreach;
	nwip_universe.decode = parse_option_buffer;
	nwip_universe.length_size = 1;
	nwip_universe.tag_size = 1;
	nwip_universe.get_tag = getUChar;
	nwip_universe.store_tag = putUChar;
	nwip_universe.get_length = getUChar;
	nwip_universe.store_length = putUChar;
	nwip_universe.site_code_min = 0;
	nwip_universe.end = 0;
	code = DHO_NWIP_SUBOPTIONS;
	nwip_universe.enc_opt = NULL;
	if (!option_code_hash_lookup(&nwip_universe.enc_opt,
				     dhcp_universe.code_hash, &code, 0, MDL))
		log_fatal("Unable to find NWIP parent option (%s:%d).", MDL);
	nwip_universe.index = universe_count++;
	universes [nwip_universe.index] = &nwip_universe;
	if (!option_name_new_hash(&nwip_universe.name_hash,
				  NWIP_HASH_SIZE, MDL) ||
	    !option_code_new_hash(&nwip_universe.code_hash,
				  NWIP_HASH_SIZE, MDL))
		log_fatal ("Can't allocate nwip option hash table.");
	for (i = 0 ; nwip_options[i].name ; i++) {
		option_code_hash_add(nwip_universe.code_hash,
				     &nwip_options[i].code, 0,
				     &nwip_options[i], MDL);
		option_name_hash_add(nwip_universe.name_hash,
				     nwip_options[i].name, 0,
				     &nwip_options[i], MDL);
	}
#if defined(REPORT_HASH_PERFORMANCE)
	log_info("NWIP name hash: %s",
		 option_name_hash_report(nwip_universe.name_hash));
	log_info("NWIP code hash: %s",
		 option_code_hash_report(nwip_universe.code_hash));
#endif

	/* Set up the FQDN option universe... */
	fqdn_universe.name = "fqdn";
	fqdn_universe.concat_duplicates = 0;
	fqdn_universe.lookup_func = lookup_linked_option;
	fqdn_universe.option_state_dereference =
		linked_option_state_dereference;
	fqdn_universe.save_func = save_linked_option;
	fqdn_universe.delete_func = delete_linked_option;
	fqdn_universe.encapsulate = fqdn_option_space_encapsulate;
	fqdn_universe.foreach = linked_option_space_foreach;
	fqdn_universe.decode = fqdn_universe_decode;
	fqdn_universe.length_size = 1;
	fqdn_universe.tag_size = 1;
	fqdn_universe.get_tag = getUChar;
	fqdn_universe.store_tag = putUChar;
	fqdn_universe.get_length = getUChar;
	fqdn_universe.store_length = putUChar;
	fqdn_universe.site_code_min = 0;
	fqdn_universe.end = 0;
	fqdn_universe.index = universe_count++;
	code = DHO_FQDN;
	fqdn_universe.enc_opt = NULL;
	if (!option_code_hash_lookup(&fqdn_universe.enc_opt,
				     dhcp_universe.code_hash, &code, 0, MDL))
		log_fatal("Unable to find FQDN parent option (%s:%d).", MDL);
	universes [fqdn_universe.index] = &fqdn_universe;
	if (!option_name_new_hash(&fqdn_universe.name_hash,
				  FQDN_HASH_SIZE, MDL) ||
	    !option_code_new_hash(&fqdn_universe.code_hash,
				  FQDN_HASH_SIZE, MDL))
		log_fatal ("Can't allocate fqdn option hash table.");
	for (i = 0 ; fqdn_options[i].name ; i++) {
		option_code_hash_add(fqdn_universe.code_hash,
				     &fqdn_options[i].code, 0,
				     &fqdn_options[i], MDL);
		option_name_hash_add(fqdn_universe.name_hash,
				     fqdn_options[i].name, 0,
				     &fqdn_options[i], MDL);
	}
#if defined(REPORT_HASH_PERFORMANCE)
	log_info("FQDN name hash: %s",
		 option_name_hash_report(fqdn_universe.name_hash));
	log_info("FQDN code hash: %s",
		 option_code_hash_report(fqdn_universe.code_hash));
#endif

        /* Set up the Vendor Identified Vendor Class options (for option
	 * 125)...
	 */
        vendor_class_universe.name = "vendor-class";
	vendor_class_universe.concat_duplicates = 0; /* XXX: reference? */
        vendor_class_universe.lookup_func = lookup_hashed_option;
        vendor_class_universe.option_state_dereference =
                hashed_option_state_dereference;
        vendor_class_universe.save_func = save_hashed_option;
        vendor_class_universe.delete_func = delete_hashed_option;
        vendor_class_universe.encapsulate = hashed_option_space_encapsulate;
        vendor_class_universe.foreach = hashed_option_space_foreach;
        vendor_class_universe.decode = parse_option_buffer;
        vendor_class_universe.length_size = 1;
        vendor_class_universe.tag_size = 4;
	vendor_class_universe.get_tag = getULong;
        vendor_class_universe.store_tag = putULong;
	vendor_class_universe.get_length = getUChar;
        vendor_class_universe.store_length = putUChar;
	vendor_class_universe.site_code_min = 0;
	vendor_class_universe.end = 0;
	code = DHO_VIVCO_SUBOPTIONS;
	vendor_class_universe.enc_opt = NULL;
	if (!option_code_hash_lookup(&vendor_class_universe.enc_opt,
				     dhcp_universe.code_hash, &code, 0, MDL))
		log_fatal("Unable to find VIVCO parent option (%s:%d).", MDL);
        vendor_class_universe.index = universe_count++;
        universes[vendor_class_universe.index] = &vendor_class_universe;
        if (!option_name_new_hash(&vendor_class_universe.name_hash,
				  VIVCO_HASH_SIZE, MDL) ||
	    !option_code_new_hash(&vendor_class_universe.code_hash,
				  VIVCO_HASH_SIZE, MDL))
                log_fatal("Can't allocate Vendor Identified Vendor Class "
			  "option hash table.");
        for (i = 0 ; vendor_class_options[i].name ; i++) {
		option_code_hash_add(vendor_class_universe.code_hash,
				     &vendor_class_options[i].code, 0,
				     &vendor_class_options[i], MDL);
                option_name_hash_add(vendor_class_universe.name_hash,
                                     vendor_class_options[i].name, 0,
                                     &vendor_class_options[i], MDL);
        }
#if defined(REPORT_HASH_PERFORMANCE)
	log_info("VIVCO name hash: %s",
		 option_name_hash_report(vendor_class_universe.name_hash));
	log_info("VIVCO code hash: %s",
		 option_code_hash_report(vendor_class_universe.code_hash));
#endif

        /* Set up the Vendor Identified Vendor Sub-options (option 126)... */
        vendor_universe.name = "vendor";
	vendor_universe.concat_duplicates = 0; /* XXX: reference? */
        vendor_universe.lookup_func = lookup_hashed_option;
        vendor_universe.option_state_dereference =
                hashed_option_state_dereference;
        vendor_universe.save_func = save_hashed_option;
        vendor_universe.delete_func = delete_hashed_option;
        vendor_universe.encapsulate = hashed_option_space_encapsulate;
        vendor_universe.foreach = hashed_option_space_foreach;
        vendor_universe.decode = parse_option_buffer;
        vendor_universe.length_size = 1;
        vendor_universe.tag_size = 4;
	vendor_universe.get_tag = getULong;
        vendor_universe.store_tag = putULong;
	vendor_universe.get_length = getUChar;
        vendor_universe.store_length = putUChar;
	vendor_universe.site_code_min = 0;
	vendor_universe.end = 0;
	code = DHO_VIVSO_SUBOPTIONS;
	vendor_universe.enc_opt = NULL;
	if (!option_code_hash_lookup(&vendor_universe.enc_opt,
				     dhcp_universe.code_hash, &code, 0, MDL))
		log_fatal("Unable to find VIVSO parent option (%s:%d).", MDL);
        vendor_universe.index = universe_count++;
        universes[vendor_universe.index] = &vendor_universe;
        if (!option_name_new_hash(&vendor_universe.name_hash,
				  VIVSO_HASH_SIZE, MDL) ||
	    !option_code_new_hash(&vendor_universe.code_hash,
				  VIVSO_HASH_SIZE, MDL))
                log_fatal("Can't allocate Vendor Identified Vendor Sub-"
			  "options hash table.");
        for (i = 0 ; vendor_options[i].name ; i++) {
                option_code_hash_add(vendor_universe.code_hash,
				     &vendor_options[i].code, 0,
				     &vendor_options[i], MDL);
                option_name_hash_add(vendor_universe.name_hash,
				     vendor_options[i].name, 0,
				     &vendor_options[i], MDL);
        }
#if defined(REPORT_HASH_PERFORMANCE)
	log_info("VIVSO name hash: %s",
		 option_name_hash_report(vendor_universe.name_hash));
	log_info("VIVSO code hash: %s",
		 option_code_hash_report(vendor_universe.code_hash));
#endif

        /* Set up the ISC Vendor-option universe (for option 125.2495)... */
        isc_universe.name = "isc";
	isc_universe.concat_duplicates = 0; /* XXX: check VIVSO ref */
        isc_universe.lookup_func = lookup_linked_option;
        isc_universe.option_state_dereference =
                linked_option_state_dereference;
        isc_universe.save_func = save_linked_option;
        isc_universe.delete_func = delete_linked_option;
        isc_universe.encapsulate = linked_option_space_encapsulate;
        isc_universe.foreach = linked_option_space_foreach;
        isc_universe.decode = parse_option_buffer;
        isc_universe.length_size = 2;
        isc_universe.tag_size = 2;
	isc_universe.get_tag = getUShort;
        isc_universe.store_tag = putUShort;
	isc_universe.get_length = getUShort;
        isc_universe.store_length = putUShort;
	isc_universe.site_code_min = 0;
	isc_universe.end = 0;
	code = VENDOR_ISC_SUBOPTIONS;
	isc_universe.enc_opt = NULL;
	if (!option_code_hash_lookup(&isc_universe.enc_opt,
				     vendor_universe.code_hash, &code, 0, MDL))
		log_fatal("Unable to find ISC parent option (%s:%d).", MDL);
        isc_universe.index = universe_count++;
        universes[isc_universe.index] = &isc_universe;
        if (!option_name_new_hash(&isc_universe.name_hash,
				  VIV_ISC_HASH_SIZE, MDL) ||
	    !option_code_new_hash(&isc_universe.code_hash,
				  VIV_ISC_HASH_SIZE, MDL))
                log_fatal("Can't allocate ISC Vendor options hash table.");
        for (i = 0 ; isc_options[i].name ; i++) {
		option_code_hash_add(isc_universe.code_hash,
				     &isc_options[i].code, 0,
				     &isc_options[i], MDL);
                option_name_hash_add(isc_universe.name_hash,
                                     isc_options[i].name, 0,
                                     &isc_options[i], MDL);
        }
#if defined(REPORT_HASH_PERFORMANCE)
	log_info("ISC name hash: %s",
		 option_name_hash_report(isc_universe.name_hash));
	log_info("ISC code hash: %s",
		 option_code_hash_report(isc_universe.code_hash));
#endif

	/* Set up the DHCPv6 root universe. */
	dhcpv6_universe.name = "dhcp6";
	dhcpv6_universe.concat_duplicates = 0;
	dhcpv6_universe.lookup_func = lookup_hashed_option;
	dhcpv6_universe.option_state_dereference =
		hashed_option_state_dereference;
	dhcpv6_universe.save_func = save_hashed_option;
	dhcpv6_universe.delete_func = delete_hashed_option;
	dhcpv6_universe.encapsulate = hashed_option_space_encapsulate;
	dhcpv6_universe.foreach = hashed_option_space_foreach;
	dhcpv6_universe.decode = parse_option_buffer;
	dhcpv6_universe.length_size = 2;
	dhcpv6_universe.tag_size = 2;
	dhcpv6_universe.get_tag = getUShort;
	dhcpv6_universe.store_tag = putUShort;
	dhcpv6_universe.get_length = getUShort;
	dhcpv6_universe.store_length = putUShort;
	dhcpv6_universe.site_code_min = 0;
	/* DHCPv6 has no END option. */
	dhcpv6_universe.end = 0x00;
	dhcpv6_universe.index = universe_count++;
	universes[dhcpv6_universe.index] = &dhcpv6_universe;
	if (!option_name_new_hash(&dhcpv6_universe.name_hash,
				  WORD_NAME_HASH_SIZE, MDL) ||
	    !option_code_new_hash(&dhcpv6_universe.code_hash,
				  WORD_CODE_HASH_SIZE, MDL))
		log_fatal("Can't allocate dhcpv6 option hash tables.");
	for (i = 0 ; dhcpv6_options[i].name ; i++) {
		option_code_hash_add(dhcpv6_universe.code_hash,
				     &dhcpv6_options[i].code, 0,
				     &dhcpv6_options[i], MDL);
		option_name_hash_add(dhcpv6_universe.name_hash,
				     dhcpv6_options[i].name, 0,
				     &dhcpv6_options[i], MDL);
	}

	/* Add DHCPv6 protocol enumeration sets. */
	add_enumeration(&dhcpv6_duid_types);
	add_enumeration(&dhcpv6_status_codes);
	add_enumeration(&dhcpv6_messages);

	/* Set up DHCPv6 VSIO universe. */
	vsio_universe.name = "vsio";
	vsio_universe.concat_duplicates = 0;
	vsio_universe.lookup_func = lookup_hashed_option;
	vsio_universe.option_state_dereference =
		hashed_option_state_dereference;
	vsio_universe.save_func = save_hashed_option;
	vsio_universe.delete_func = delete_hashed_option;
	vsio_universe.encapsulate = hashed_option_space_encapsulate;
	vsio_universe.foreach = hashed_option_space_foreach;
	vsio_universe.decode = parse_option_buffer;
	vsio_universe.length_size = 0;
	vsio_universe.tag_size = 4;
	vsio_universe.get_tag = getULong;
	vsio_universe.store_tag = putULong;
	vsio_universe.get_length = NULL;
	vsio_universe.store_length = NULL;
	vsio_universe.site_code_min = 0;
	/* No END option. */
	vsio_universe.end = 0x00;
	code = D6O_VENDOR_OPTS;
	if (!option_code_hash_lookup(&vsio_universe.enc_opt,
				     dhcpv6_universe.code_hash, &code, 0, MDL))
		log_fatal("Unable to find VSIO parent option (%s:%d).", MDL);
	vsio_universe.index = universe_count++;
	universes[vsio_universe.index] = &vsio_universe;
	if (!option_name_new_hash(&vsio_universe.name_hash,
				  VSIO_HASH_SIZE, MDL) ||
	    !option_code_new_hash(&vsio_universe.code_hash,
				  VSIO_HASH_SIZE, MDL))
		log_fatal("Can't allocate Vendor Specific Information "
			  "Options space.");
	for (i = 0 ; vsio_options[i].name != NULL ; i++) {
		option_code_hash_add(vsio_universe.code_hash,
				     &vsio_options[i].code, 0,
				     &vsio_options[i], MDL);
		option_name_hash_add(vsio_universe.name_hash,
				     vsio_options[i].name, 0,
				     &vsio_options[i], MDL);
	}

	/* Add ISC VSIO sub-sub-option space. */
	isc6_universe.name = "isc6";
	isc6_universe.concat_duplicates = 0;
	isc6_universe.lookup_func = lookup_hashed_option;
	isc6_universe.option_state_dereference =
		hashed_option_state_dereference;
	isc6_universe.save_func = save_hashed_option;
	isc6_universe.delete_func = delete_hashed_option;
	isc6_universe.encapsulate = hashed_option_space_encapsulate;
	isc6_universe.foreach = hashed_option_space_foreach;
	isc6_universe.decode = parse_option_buffer;
	isc6_universe.length_size = 0;
	isc6_universe.tag_size = 4;
	isc6_universe.get_tag = getULong;
	isc6_universe.store_tag = putULong;
	isc6_universe.get_length = NULL;
	isc6_universe.store_length = NULL;
	isc6_universe.site_code_min = 0;
	/* No END option. */
	isc6_universe.end = 0x00;
	code = 2495;
	if (!option_code_hash_lookup(&isc6_universe.enc_opt,
				     vsio_universe.code_hash, &code, 0, MDL))
		log_fatal("Unable to find ISC parent option (%s:%d).", MDL);
	isc6_universe.index = universe_count++;
	universes[isc6_universe.index] = &isc6_universe;
	if (!option_name_new_hash(&isc6_universe.name_hash,
				  VIV_ISC_HASH_SIZE, MDL) ||
	    !option_code_new_hash(&isc6_universe.code_hash,
				  VIV_ISC_HASH_SIZE, MDL))
		log_fatal("Can't allocate Vendor Specific Information "
			  "Options space.");
	for (i = 0 ; isc6_options[i].name != NULL ; i++) {
		option_code_hash_add(isc6_universe.code_hash,
				     &isc6_options[i].code, 0,
				     &isc6_options[i], MDL);
		option_name_hash_add(isc6_universe.name_hash,
				     isc6_options[i].name, 0,
				     &isc6_options[i], MDL);
	}

	/* The fqdn6 option space is a protocol-wrapper shill for the
	 * old DHCPv4 space.
	 */
	fqdn6_universe.name = "fqdn6-if-you-see-me-its-a-bug-bug-bug";
	fqdn6_universe.lookup_func = lookup_fqdn6_option;
	fqdn6_universe.option_state_dereference = NULL; /* Covered by v4. */
	fqdn6_universe.save_func = save_fqdn6_option;
	fqdn6_universe.delete_func = delete_fqdn6_option;
	fqdn6_universe.encapsulate = fqdn6_option_space_encapsulate;
	fqdn6_universe.foreach = fqdn6_option_space_foreach;
	fqdn6_universe.decode = fqdn6_universe_decode;
	/* This is not a 'normal' encapsulated space, so these values are
	 * meaningless.
	 */
	fqdn6_universe.length_size = 0;
	fqdn6_universe.tag_size = 0;
	fqdn6_universe.get_tag = NULL;
	fqdn6_universe.store_tag = NULL;
	fqdn6_universe.get_length = NULL;
	fqdn6_universe.store_length = NULL;
	fqdn6_universe.site_code_min = 0;
	fqdn6_universe.end = 0;
	fqdn6_universe.index = universe_count++;
	code = D6O_CLIENT_FQDN;
	fqdn6_universe.enc_opt = NULL;
	if (!option_code_hash_lookup(&fqdn6_universe.enc_opt,
				     dhcpv6_universe.code_hash, &code, 0, MDL))
		log_fatal("Unable to find FQDN v6 parent option. (%s:%d).",
			  MDL);
	universes[fqdn6_universe.index] = &fqdn6_universe;
	/* The fqdn6 space shares the same option space as the v4 space.
	 * So there are no name or code hashes on the v6 side.
	 */
	fqdn6_universe.name_hash = NULL;
	fqdn6_universe.code_hash = NULL;


	/* Set up the hash of DHCPv4 universes. */
	universe_new_hash(&universe_hash, UNIVERSE_HASH_SIZE, MDL);
	universe_hash_add(universe_hash, dhcp_universe.name, 0,
			  &dhcp_universe, MDL);
	universe_hash_add(universe_hash, nwip_universe.name, 0,
			  &nwip_universe, MDL);
	universe_hash_add(universe_hash, fqdn_universe.name, 0,
			  &fqdn_universe, MDL);
	universe_hash_add(universe_hash, vendor_class_universe.name, 0,
			  &vendor_class_universe, MDL);
	universe_hash_add(universe_hash, vendor_universe.name, 0,
			  &vendor_universe, MDL);
	universe_hash_add(universe_hash, isc_universe.name, 0,
			  &isc_universe, MDL);

	/* Set up hashes for DHCPv6 universes. */
	universe_hash_add(universe_hash, dhcpv6_universe.name, 0,
			  &dhcpv6_universe, MDL);
	universe_hash_add(universe_hash, vsio_universe.name, 0,
			  &vsio_universe, MDL);
	universe_hash_add(universe_hash, isc6_universe.name, 0,
			  &isc6_universe, MDL);
/* This should not be necessary.  Listing here just for consistency.
 *	universe_hash_add(universe_hash, fqdn6_universe.name, 0,
 *			  &fqdn6_universe, MDL);
 */
}
Beispiel #3
0
void initialize_common_option_spaces()
{
	unsigned code;
	int i;

	universe_max = 10;
	universes = ((struct universe **)
		     dmalloc (universe_max * sizeof (struct universe *), MDL));
	if (!universes)
		log_fatal ("Can't allocate option space table.");
	memset (universes, 0, universe_max * sizeof (struct universe *));

	/* Set up the DHCP option universe... */
	dhcp_universe.name = "dhcp";
	dhcp_universe.lookup_func = lookup_hashed_option;
	dhcp_universe.option_state_dereference =
		hashed_option_state_dereference;
	dhcp_universe.save_func = save_hashed_option;
	dhcp_universe.delete_func = delete_hashed_option;
	dhcp_universe.encapsulate = hashed_option_space_encapsulate;
	dhcp_universe.foreach = hashed_option_space_foreach;
	dhcp_universe.decode = parse_option_buffer;
	dhcp_universe.length_size = 1;
	dhcp_universe.tag_size = 1;
	dhcp_universe.get_tag = getUChar;
	dhcp_universe.store_tag = putUChar;
	dhcp_universe.get_length = getUChar;
	dhcp_universe.store_length = putUChar;
	dhcp_universe.end = DHO_END;
	dhcp_universe.index = universe_count++;
	universes [dhcp_universe.index] = &dhcp_universe;
	if (!option_name_new_hash(&dhcp_universe.name_hash,
				  BYTE_NAME_HASH_SIZE, MDL) ||
	    !option_code_new_hash(&dhcp_universe.code_hash,
				  BYTE_CODE_HASH_SIZE, MDL))
		log_fatal ("Can't allocate dhcp option hash table.");
	for (i = 0 ; dhcp_options[i].name ; i++) {
		option_code_hash_add(dhcp_universe.code_hash,
				     &dhcp_options[i].code, 0,
				     &dhcp_options[i], MDL);
		option_name_hash_add(dhcp_universe.name_hash,
				     dhcp_options [i].name, 0,
				     &dhcp_options [i], MDL);
	}
#if defined(REPORT_HASH_PERFORMANCE)
	log_info("DHCP name hash: %s",
		 option_name_hash_report(dhcp_universe.name_hash));
	log_info("DHCP code hash: %s",
		 option_code_hash_report(dhcp_universe.code_hash));
#endif

	/* Set up the Novell option universe (for option 63)... */
	nwip_universe.name = "nwip";
	nwip_universe.lookup_func = lookup_linked_option;
	nwip_universe.option_state_dereference =
		linked_option_state_dereference;
	nwip_universe.save_func = save_linked_option;
	nwip_universe.delete_func = delete_linked_option;
	nwip_universe.encapsulate = nwip_option_space_encapsulate;
	nwip_universe.foreach = linked_option_space_foreach;
	nwip_universe.decode = parse_option_buffer;
	nwip_universe.length_size = 1;
	nwip_universe.tag_size = 1;
	nwip_universe.get_tag = getUChar;
	nwip_universe.store_tag = putUChar;
	nwip_universe.get_length = getUChar;
	nwip_universe.store_length = putUChar;
	nwip_universe.end = 0;
	code = DHO_NWIP_SUBOPTIONS;
	nwip_universe.enc_opt = NULL;
	if (!option_code_hash_lookup(&nwip_universe.enc_opt,
				     dhcp_universe.code_hash, &code, 0, MDL))
		log_fatal("Unable to find NWIP parent option (%s:%d).", MDL);
	nwip_universe.index = universe_count++;
	universes [nwip_universe.index] = &nwip_universe;
	if (!option_name_new_hash(&nwip_universe.name_hash,
				  NWIP_HASH_SIZE, MDL) ||
	    !option_code_new_hash(&nwip_universe.code_hash,
				  NWIP_HASH_SIZE, MDL))
		log_fatal ("Can't allocate nwip option hash table.");
	for (i = 0 ; nwip_options[i].name ; i++) {
		option_code_hash_add(nwip_universe.code_hash,
				     &nwip_options[i].code, 0,
				     &nwip_options[i], MDL);
		option_name_hash_add(nwip_universe.name_hash,
				     nwip_options[i].name, 0,
				     &nwip_options[i], MDL);
	}
#if defined(REPORT_HASH_PERFORMANCE)
	log_info("NWIP name hash: %s",
		 option_name_hash_report(nwip_universe.name_hash));
	log_info("NWIP code hash: %s",
		 option_code_hash_report(nwip_universe.code_hash));
#endif

	/* Set up the FQDN option universe... */
	fqdn_universe.name = "fqdn";
	fqdn_universe.lookup_func = lookup_linked_option;
	fqdn_universe.option_state_dereference =
		linked_option_state_dereference;
	fqdn_universe.save_func = save_linked_option;
	fqdn_universe.delete_func = delete_linked_option;
	fqdn_universe.encapsulate = fqdn_option_space_encapsulate;
	fqdn_universe.foreach = linked_option_space_foreach;
	fqdn_universe.decode = fqdn_universe_decode;
	fqdn_universe.length_size = 1;
	fqdn_universe.tag_size = 1;
	fqdn_universe.get_tag = getUChar;
	fqdn_universe.store_tag = putUChar;
	fqdn_universe.get_length = getUChar;
	fqdn_universe.store_length = putUChar;
	fqdn_universe.end = 0;
	fqdn_universe.index = universe_count++;
	code = DHO_FQDN;
	fqdn_universe.enc_opt = NULL;
	if (!option_code_hash_lookup(&fqdn_universe.enc_opt,
				     dhcp_universe.code_hash, &code, 0, MDL))
		log_fatal("Unable to find FQDN parent option (%s:%d).", MDL);
	universes [fqdn_universe.index] = &fqdn_universe;
	if (!option_name_new_hash(&fqdn_universe.name_hash,
				  FQDN_HASH_SIZE, MDL) ||
	    !option_code_new_hash(&fqdn_universe.code_hash,
				  FQDN_HASH_SIZE, MDL))
		log_fatal ("Can't allocate fqdn option hash table.");
	for (i = 0 ; fqdn_options[i].name ; i++) {
		option_code_hash_add(fqdn_universe.code_hash,
				     &fqdn_options[i].code, 0,
				     &fqdn_options[i], MDL);
		option_name_hash_add(fqdn_universe.name_hash,
				     fqdn_options[i].name, 0,
				     &fqdn_options[i], MDL);
	}
#if defined(REPORT_HASH_PERFORMANCE)
	log_info("FQDN name hash: %s",
		 option_name_hash_report(fqdn_universe.name_hash));
	log_info("FQDN code hash: %s",
		 option_code_hash_report(fqdn_universe.code_hash));
#endif

        /* Set up the Vendor Identified Vendor Class options (for option
	 * 125)...
	 */
        vendor_class_universe.name = "vendor-class";
        vendor_class_universe.lookup_func = lookup_hashed_option;
        vendor_class_universe.option_state_dereference =
                hashed_option_state_dereference;
        vendor_class_universe.save_func = save_hashed_option;
        vendor_class_universe.delete_func = delete_hashed_option;
        vendor_class_universe.encapsulate = hashed_option_space_encapsulate;
        vendor_class_universe.foreach = hashed_option_space_foreach;
        vendor_class_universe.decode = parse_option_buffer;
        vendor_class_universe.length_size = 1;
        vendor_class_universe.tag_size = 4;
	vendor_class_universe.get_tag = getULong;
        vendor_class_universe.store_tag = putULong;
	vendor_class_universe.get_length = getUChar;
        vendor_class_universe.store_length = putUChar;
	vendor_class_universe.end = 0;
	code = DHO_VIVCO_SUBOPTIONS;
	vendor_class_universe.enc_opt = NULL;
	if (!option_code_hash_lookup(&vendor_class_universe.enc_opt,
				     dhcp_universe.code_hash, &code, 0, MDL))
		log_fatal("Unable to find VIVCO parent option (%s:%d).", MDL);
        vendor_class_universe.index = universe_count++;
        universes[vendor_class_universe.index] = &vendor_class_universe;
        if (!option_name_new_hash(&vendor_class_universe.name_hash,
				  VIVCO_HASH_SIZE, MDL) ||
	    !option_code_new_hash(&vendor_class_universe.code_hash,
				  VIVCO_HASH_SIZE, MDL))
                log_fatal("Can't allocate Vendor Identified Vendor Class "
			  "option hash table.");
        for (i = 0 ; vendor_class_options[i].name ; i++) {
		option_code_hash_add(vendor_class_universe.code_hash,
				     &vendor_class_options[i].code, 0,
				     &vendor_class_options[i], MDL);
                option_name_hash_add(vendor_class_universe.name_hash,
                                     vendor_class_options[i].name, 0,
                                     &vendor_class_options[i], MDL);
        }
#if defined(REPORT_HASH_PERFORMANCE)
	log_info("VIVCO name hash: %s",
		 option_name_hash_report(vendor_class_universe.name_hash));
	log_info("VIVCO code hash: %s",
		 option_code_hash_report(vendor_class_universe.code_hash));
#endif

        /* Set up the Vendor Identified Vendor Sub-options (option 126)... */
        vendor_universe.name = "vendor";
        vendor_universe.lookup_func = lookup_hashed_option;
        vendor_universe.option_state_dereference =
                hashed_option_state_dereference;
        vendor_universe.save_func = save_hashed_option;
        vendor_universe.delete_func = delete_hashed_option;
        vendor_universe.encapsulate = hashed_option_space_encapsulate;
        vendor_universe.foreach = hashed_option_space_foreach;
        vendor_universe.decode = parse_option_buffer;
        vendor_universe.length_size = 1;
        vendor_universe.tag_size = 4;
	vendor_universe.get_tag = getULong;
        vendor_universe.store_tag = putULong;
	vendor_universe.get_length = getUChar;
        vendor_universe.store_length = putUChar;
	vendor_universe.end = 0;
	code = DHO_VIVSO_SUBOPTIONS;
	vendor_universe.enc_opt = NULL;
	if (!option_code_hash_lookup(&vendor_universe.enc_opt,
				     dhcp_universe.code_hash, &code, 0, MDL))
		log_fatal("Unable to find VIVSO parent option (%s:%d).", MDL);
        vendor_universe.index = universe_count++;
        universes[vendor_universe.index] = &vendor_universe;
        if (!option_name_new_hash(&vendor_universe.name_hash,
				  VIVSO_HASH_SIZE, MDL) ||
	    !option_code_new_hash(&vendor_universe.code_hash,
				  VIVSO_HASH_SIZE, MDL))
                log_fatal("Can't allocate Vendor Identified Vendor Sub-"
			  "options hash table.");
        for (i = 0 ; vendor_options[i].name ; i++) {
                option_code_hash_add(vendor_universe.code_hash,
				     &vendor_options[i].code, 0,
				     &vendor_options[i], MDL);
                option_name_hash_add(vendor_universe.name_hash,
				     vendor_options[i].name, 0,
				     &vendor_options[i], MDL);
        }
#if defined(REPORT_HASH_PERFORMANCE)
	log_info("VIVSO name hash: %s",
		 option_name_hash_report(vendor_universe.name_hash));
	log_info("VIVSO code hash: %s",
		 option_code_hash_report(vendor_universe.code_hash));
#endif

        /* Set up the ISC Vendor-option universe (for option 125.2495)... */
        isc_universe.name = "isc";
        isc_universe.lookup_func = lookup_linked_option;
        isc_universe.option_state_dereference =
                linked_option_state_dereference;
        isc_universe.save_func = save_linked_option;
        isc_universe.delete_func = delete_linked_option;
        isc_universe.encapsulate = linked_option_space_encapsulate;
        isc_universe.foreach = linked_option_space_foreach;
        isc_universe.decode = parse_option_buffer;
        isc_universe.length_size = 2;
        isc_universe.tag_size = 2;
	isc_universe.get_tag = getUShort;
        isc_universe.store_tag = putUShort;
	isc_universe.get_length = getUShort;
        isc_universe.store_length = putUShort;
	isc_universe.end = 0;
	code = VENDOR_ISC_SUBOPTIONS;
	isc_universe.enc_opt = NULL;
	if (!option_code_hash_lookup(&isc_universe.enc_opt,
				     vendor_universe.code_hash, &code, 0, MDL))
		log_fatal("Unable to find ISC parent option (%s:%d).", MDL);
        isc_universe.index = universe_count++;
        universes[isc_universe.index] = &isc_universe;
        if (!option_name_new_hash(&isc_universe.name_hash,
				  VIV_ISC_HASH_SIZE, MDL) ||
	    !option_code_new_hash(&isc_universe.code_hash,
				  VIV_ISC_HASH_SIZE, MDL))
                log_fatal("Can't allocate ISC Vendor options hash table.");
        for (i = 0 ; isc_options[i].name ; i++) {
		option_code_hash_add(isc_universe.code_hash,
				     &isc_options[i].code, 0,
				     &isc_options[i], MDL);
                option_name_hash_add(isc_universe.name_hash,
                                     isc_options[i].name, 0,
                                     &isc_options[i], MDL);
        }
#if defined(REPORT_HASH_PERFORMANCE)
	log_info("ISC name hash: %s",
		 option_name_hash_report(isc_universe.name_hash));
	log_info("ISC code hash: %s",
		 option_code_hash_report(isc_universe.code_hash));
#endif

	/* Set up the hash of universes. */
	universe_new_hash(&universe_hash, UNIVERSE_HASH_SIZE, MDL);
	universe_hash_add(universe_hash, dhcp_universe.name, 0,
			  &dhcp_universe, MDL);
	universe_hash_add(universe_hash, nwip_universe.name, 0,
			  &nwip_universe, MDL);
	universe_hash_add(universe_hash, fqdn_universe.name, 0,
			  &fqdn_universe, MDL);
	universe_hash_add(universe_hash, vendor_class_universe.name, 0,
			  &vendor_class_universe, MDL);
	universe_hash_add(universe_hash, vendor_universe.name, 0,
			  &vendor_universe, MDL);
	universe_hash_add(universe_hash, isc_universe.name, 0,
			  &isc_universe, MDL);
}