Exemplo n.º 1
0
void
setconfig (char *name, char *value, struct config_data *cfg)
{
	int len, dstlen;
	void *src, *dst;
	char tmpname[128];
	int i;

#define CONF0(NAMESTR, CFG) \
	setdst (name, NAMESTR, &CFG, sizeof CFG, &dst, &dstlen)
#define CONF(NAME) \
	CONF0 (#NAME, cfg->NAME)
#define CONF1(NAMEFMT, ARG1, CFG) \
	snprintf (tmpname, sizeof tmpname, NAMEFMT, ARG1), \
	CONF0 (tmpname, CFG)

	name = strdup (name);
	len = strlen (value);
	src = strdup (value);
	dst = NULL;
	dstlen = 0;
	/* idman */
	ss (file, &name, &src, &len, "idman.crl01File", "idman.crl01");
	ss (file, &name, &src, &len, "idman.crl02File", "idman.crl02");
	ss (file, &name, &src, &len, "idman.crl03File", "idman.crl03");
	ss (file, &name, &src, &len, "idman.pkc01File", "idman.pkc01");
	ss (file, &name, &src, &len, "idman.pkc02File", "idman.pkc02");
	ss (file, &name, &src, &len, "idman.pkc03File", "idman.pkc03");
	ss (uintnum, &name, &src, &len, "idman.randomSeedSize",
	    "idman.randomSeedSize");
	ss (uintnum, &name, &src, &len, "idman.maxPinLen", "idman.maxPinLen");
	ss (uintnum, &name, &src, &len, "idman.minPinLen", "idman.minPinLen");
	ss (authmethod, &name, &src, &len, "idman.authenticationMethod",
	    "idman.authenticationMethod");
	/* VPN */
	ss (file, &name, &src, &len, "vpn.vpnCertFileV4", "vpn.vpnCertV4");
	ss (file, &name, &src, &len, "vpn.vpnCaCertFileV4", "vpn.vpnCaCertV4");
	ss (file, &name, &src, &len, "vpn.vpnRsaKeyFileV4", "vpn.vpnRsaKeyV4");
	ss (file, &name, &src, &len, "vpn.vpnCertFileV6", "vpn.vpnCertV6");
	ss (file, &name, &src, &len, "vpn.vpnCaCertFileV6", "vpn.vpnCaCertV6");
	ss (file, &name, &src, &len, "vpn.vpnRsaKeyFileV6", "vpn.vpnRsaKeyV6");
	/* storage */
	for (i = 0; i < NUM_OF_STORAGE_KEYS; i++)
		ssi (keyplace, &name, &src, &len,
		     "storage.encryptionKey%d.place", "storage.keys[%d]", i);
	for (i = 0; i < NUM_OF_STORAGE_KEYS_CONF; i++) {
		ssi (storage_conf_guid, &name, &src, &len,
		     "storage.conf%d.guid", "storage.keys_conf[%d].guid", i);
		ssi (storage_conf_type, &name, &src, &len,
		     "storage.conf%d.type", "storage.keys_conf[%d].type", i);
		ssi (u8num, &name, &src, &len, "storage.conf%d.host_id",
		     "storage.keys_conf[%d].host_id", i);
		ssi (u16num, &name, &src, &len, "storage.conf%d.device_id",
		     "storage.keys_conf[%d].device_id", i);
		ssi (u64num, &name, &src, &len, "storage.conf%d.lba_low",
		     "storage.keys_conf[%d].lba_low", i);
		ssi (u64num, &name, &src, &len, "storage.conf%d.lba_high",
		     "storage.keys_conf[%d].lba_high", i);
		ssi (noconv, &name, &src, &len, "storage.conf%d.crypto_name",
		     "storage.keys_conf[%d].crypto_name", i);
		ssi (u8num, &name, &src, &len, "storage.conf%d.keyindex",
		     "storage.keys_conf[%d].keyindex", i);
		ssi (u16num, &name, &src, &len, "storage.conf%d.keybits",
		     "storage.keys_conf[%d].keybits", i);
		ssi (noconv, &name, &src, &len, "storage.conf%d.extend",
		     "storage.keys_conf[%d].extend", i);
	}
	/* vmm */
	ss (uintnum, &name, &src, &len, "vmm.f11panic", "vmm.f11panic");
	ss (uintnum, &name, &src, &len, "vmm.f12msg", "vmm.f12msg");
	ss (uintnum, &name, &src, &len, "vmm.auto_reboot", "vmm.auto_reboot");
	ss (uintnum, &name, &src, &len, "vmm.shell", "vmm.shell");
	ss (uintnum, &name, &src, &len, "vmm.dbgsh", "vmm.dbgsh");
	ss (uintnum, &name, &src, &len, "vmm.status", "vmm.status");
	ss (uintnum, &name, &src, &len, "vmm.boot_active", "vmm.boot_active");
	ss (uintnum, &name, &src, &len, "vmm.tty_pro1000", "vmm.tty_pro1000");
	ss (mac_addr, &name, &src, &len, "vmm.tty_pro1000_mac_address",
	    "vmm.tty_pro1000_mac_address");
	ss (uintnum, &name, &src, &len, "vmm.tty_rtl8169", "vmm.tty_rtl8169");
	ss (mac_addr, &name, &src, &len, "vmm.tty_rtl8169_mac_address",
	    "vmm.tty_rtl8169_mac_address");
	ss (uintnum, &name, &src, &len, "vmm.driver.ata", "vmm.driver.ata");
	ss (uintnum, &name, &src, &len, "vmm.driver.usb.uhci", "vmm.driver.usb.uhci");
	ss (uintnum, &name, &src, &len, "vmm.driver.usb.ehci", "vmm.driver.usb.ehci");
	ss (uintnum, &name, &src, &len, "vmm.driver.concealEHCI",
	    "vmm.driver.concealEHCI");
	ss (uintnum, &name, &src, &len, "vmm.driver.conceal1394",
	    "vmm.driver.conceal1394");
	ss (uintnum, &name, &src, &len, "vmm.driver.concealPRO1000",
	    "vmm.driver.concealPRO1000");
	ss (uintnum, &name, &src, &len, "vmm.driver.vpn.PRO100",
	    "vmm.driver.vpn.PRO100");
	ss (uintnum, &name, &src, &len, "vmm.driver.vpn.PRO1000",
	    "vmm.driver.vpn.PRO1000");
	ss (uintnum, &name, &src, &len, "vmm.driver.vpn.RTL8169",
	    "vmm.driver.vpn.RTL8169");
	ss (uintnum, &name, &src, &len, "vmm.driver.vpn.ve",
	    "vmm.driver.vpn.ve");
	ss (uintnum, &name, &src, &len, "vmm.iccard.enable",
	    "vmm.iccard.enable");
	ss (uintnum, &name, &src, &len, "vmm.iccard.status",
	    "vmm.iccard.status");
	/* idman */
	CONF (idman.crl01);
	CONF (idman.crl02);
	CONF (idman.crl03);
	CONF (idman.pkc01);
	CONF (idman.pkc02);
	CONF (idman.pkc03);
	CONF (idman.randomSeedSize);
	CONF (idman.maxPinLen);
	CONF (idman.minPinLen);
	CONF (idman.authenticationMethod);
	/* VPN */
	CONF (vpn.mode);
	CONF (vpn.virtualGatewayMacAddress);
	CONF (vpn.bindV4);
	CONF (vpn.guestIpAddressV4);
	CONF (vpn.guestIpSubnetV4);
	CONF (vpn.guestMtuV4);
	CONF (vpn.guestVirtualGatewayIpAddressV4);
	CONF (vpn.dhcpV4);
	CONF (vpn.dhcpLeaseExpiresV4);
	CONF (vpn.dhcpDnsV4);
	CONF (vpn.dhcpDomainV4);
	CONF (vpn.adjustTcpMssV4);
	CONF (vpn.hostIpAddressV4);
	CONF (vpn.hostIpSubnetV4);
	CONF (vpn.hostMtuV4);
	CONF (vpn.hostIpDefaultGatewayV4);
	CONF (vpn.optionV4ArpExpires);
	CONF (vpn.optionV4ArpDontUpdateExpires);
	CONF (vpn.vpnGatewayAddressV4);
	CONF (vpn.vpnAuthMethodV4);
	CONF (vpn.vpnPasswordV4);
	CONF (vpn.vpnIdStringV4);
	CONF (vpn.vpnCertV4);
	CONF (vpn.vpnCaCertV4);
	CONF (vpn.vpnRsaKeyV4);
	CONF (vpn.vpnSpecifyIssuerV4);
	CONF (vpn.vpnPhase1CryptoV4);
	CONF (vpn.vpnPhase1HashV4);
	CONF (vpn.vpnPhase1LifeSecondsV4);
	CONF (vpn.vpnPhase1LifeKilobytesV4);
	CONF (vpn.vpnWaitPhase2BlankSpanV4);
	CONF (vpn.vpnPhase2CryptoV4);
	CONF (vpn.vpnPhase2HashV4);
	CONF (vpn.vpnPhase2LifeSecondsV4);
	CONF (vpn.vpnPhase2LifeKilobytesV4);
	CONF (vpn.vpnConnectTimeoutV4);
	CONF (vpn.vpnIdleTimeoutV4);
	CONF (vpn.vpnPingTargetV4);
	CONF (vpn.vpnPingIntervalV4);
	CONF (vpn.vpnPingMsgSizeV4);
	CONF (vpn.bindV6);
	CONF (vpn.guestIpAddressPrefixV6);
	CONF (vpn.guestIpAddressSubnetV6);
	CONF (vpn.guestMtuV6);
	CONF (vpn.guestVirtualGatewayIpAddressV6);
	CONF (vpn.raV6);
	CONF (vpn.raLifetimeV6);
	CONF (vpn.raDnsV6);
	CONF (vpn.hostIpAddressV6);
	CONF (vpn.hostIpAddressSubnetV6);
	CONF (vpn.hostMtuV6);
	CONF (vpn.hostIpDefaultGatewayV6);
	CONF (vpn.optionV6NeighborExpires);
	CONF (vpn.vpnGatewayAddressV6);
	CONF (vpn.vpnAuthMethodV6);
	CONF (vpn.vpnPasswordV6);
	CONF (vpn.vpnIdStringV6);
	CONF (vpn.vpnCertV6);
	CONF (vpn.vpnCaCertV6);
	CONF (vpn.vpnRsaKeyV6);
	CONF (vpn.vpnSpecifyIssuerV6);
	CONF (vpn.vpnPhase1CryptoV6);
	CONF (vpn.vpnPhase1HashV6);
	CONF (vpn.vpnPhase1LifeSecondsV6);
	CONF (vpn.vpnPhase1LifeKilobytesV6);
	CONF (vpn.vpnWaitPhase2BlankSpanV6);
	CONF (vpn.vpnPhase2CryptoV6);
	CONF (vpn.vpnPhase2HashV6);
	CONF (vpn.vpnPhase2LifeSecondsV6);
	CONF (vpn.vpnPhase2LifeKilobytesV6);
	CONF (vpn.vpnPhase2StrictIdV6);
	CONF (vpn.vpnConnectTimeoutV6);
	CONF (vpn.vpnIdleTimeoutV6);
	CONF (vpn.vpnPingTargetV6);
	CONF (vpn.vpnPingIntervalV6);
	CONF (vpn.vpnPingMsgSizeV6);
	/* storage */
	for (i = 0; i < NUM_OF_STORAGE_KEYS; i++)
		CONF1 ("storage.keys[%d]", i, cfg->storage.keys[i]);
	for (i = 0; i < NUM_OF_STORAGE_KEYS_CONF; i++) {
		CONF1 ("storage.keys_conf[%d].guid", i,
		       cfg->storage.keys_conf[i].guid);
		CONF1 ("storage.keys_conf[%d].type", i,
		       cfg->storage.keys_conf[i].type);
		CONF1 ("storage.keys_conf[%d].host_id", i,
		       cfg->storage.keys_conf[i].host_id);
		CONF1 ("storage.keys_conf[%d].device_id", i,
		       cfg->storage.keys_conf[i].device_id);
		CONF1 ("storage.keys_conf[%d].lba_low", i,
		       cfg->storage.keys_conf[i].lba_low);
		CONF1 ("storage.keys_conf[%d].lba_high", i,
		       cfg->storage.keys_conf[i].lba_high);
		CONF1 ("storage.keys_conf[%d].crypto_name", i,
		       cfg->storage.keys_conf[i].crypto_name);
		CONF1 ("storage.keys_conf[%d].keyindex", i,
		       cfg->storage.keys_conf[i].keyindex);
		CONF1 ("storage.keys_conf[%d].keybits", i,
		       cfg->storage.keys_conf[i].keybits);
		CONF1 ("storage.keys_conf[%d].extend", i,
		       cfg->storage.keys_conf[i].extend);
	}
	/* vmm */
	CONF (vmm.f11panic);
	CONF (vmm.f12msg);
	CONF (vmm.auto_reboot);
	CONF (vmm.shell);
	CONF (vmm.dbgsh);
	CONF (vmm.status);
	CONF (vmm.boot_active);
	CONF (vmm.tty_pro1000);
	CONF (vmm.tty_pro1000_mac_address);
	CONF (vmm.tty_rtl8169);
	CONF (vmm.tty_rtl8169_mac_address);
	CONF (vmm.driver.ata);
	CONF (vmm.driver.usb.uhci);
	CONF (vmm.driver.usb.ehci);
	CONF (vmm.driver.concealEHCI);
	CONF (vmm.driver.conceal1394);
	CONF (vmm.driver.concealPRO1000);
	CONF (vmm.driver.vpn.PRO100);
	CONF (vmm.driver.vpn.PRO1000);
	CONF (vmm.driver.vpn.RTL8169);
	CONF (vmm.driver.vpn.ve);
	CONF (vmm.driver.pci_conceal);
	CONF (vmm.iccard.enable);
	CONF (vmm.iccard.status);
	if (!dst) {
		fprintf (stderr, "unknown config \"%s\"\n", name);
		exit (EXIT_FAILURE);
	}
	if (len > dstlen) {
		fprintf (stderr, "config \"%s\" is too long\n", name);
		exit (EXIT_FAILURE);
	}
	memset (dst, 0, dstlen);
	memcpy (dst, src, len);
	free (name);
	free (src);
}
Exemplo n.º 2
0
void conf1(INTEGER k)
{
    CONF1(0, EB[k], Time_CONF1, S[k]);
}