// 仮想ホストオプションの読み込み (拡張) void NiLoadVhOptionEx(VH_OPTION *o, FOLDER *root) { FOLDER *host, *nat, *dhcp; char mac_address[MAX_SIZE]; // 引数チェック if (o == NULL || root == NULL) { return; } host = CfgGetFolder(root, "VirtualHost"); nat = CfgGetFolder(root, "VirtualRouter"); dhcp = CfgGetFolder(root, "VirtualDhcpServer"); Zero(o, sizeof(VH_OPTION)); GenMacAddress(o->MacAddress); if (CfgGetStr(host, "VirtualHostMacAddress", mac_address, sizeof(mac_address))) { BUF *b = StrToBin(mac_address); if (b != NULL) { if (b->Size == 6) { Copy(o->MacAddress, b->Buf, 6); } } FreeBuf(b); } CfgGetIp(host, "VirtualHostIp", &o->Ip); CfgGetIp(host, "VirtualHostIpSubnetMask", &o->Mask); o->UseNat = CfgGetBool(nat, "NatEnabled"); o->Mtu = CfgGetInt(nat, "NatMtu"); o->NatTcpTimeout = CfgGetInt(nat, "NatTcpTimeout"); o->NatUdpTimeout = CfgGetInt(nat, "NatUdpTimeout"); o->UseDhcp = CfgGetBool(dhcp, "DhcpEnabled"); CfgGetIp(dhcp, "DhcpLeaseIPStart", &o->DhcpLeaseIPStart); CfgGetIp(dhcp, "DhcpLeaseIPEnd", &o->DhcpLeaseIPEnd); CfgGetIp(dhcp, "DhcpSubnetMask", &o->DhcpSubnetMask); o->DhcpExpireTimeSpan = CfgGetInt(dhcp, "DhcpExpireTimeSpan"); CfgGetIp(dhcp, "DhcpGatewayAddress", &o->DhcpGatewayAddress); CfgGetIp(dhcp, "DhcpDnsServerAddress", &o->DhcpDnsServerAddress); CfgGetStr(dhcp, "DhcpDomainName", o->DhcpDomainName, sizeof(o->DhcpDomainName)); Trim(o->DhcpDomainName); if (StrLen(o->DhcpDomainName) == 0) { //GetDomainName(o->DhcpDomainName, sizeof(o->DhcpDomainName)); } o->SaveLog = CfgGetBool(root, "SaveLog"); }
// Read the configuration file bool NiLoadConfig(NAT *n, FOLDER *root) { FOLDER *host; BUF *b; // Validate arguments if (n == NULL || root == NULL) { return false; } host = CfgGetFolder(root, "VirtualHost"); if (host == NULL) { return false; } CfgGetByte(root, "HashedPassword", n->HashedPassword, sizeof(n->HashedPassword)); n->AdminPort = CfgGetInt(root, "AdminPort"); n->Online = CfgGetBool(root, "Online"); b = CfgGetBuf(root, "AdminCert"); if (b != NULL) { n->AdminX = BufToX(b, false); FreeBuf(b); } b = CfgGetBuf(root, "AdminKey"); if (b != NULL) { n->AdminK = BufToK(b, true, false, NULL); FreeBuf(b); } NiLoadVhOption(n, root); NiLoadClientData(n, root); return true; }
// Read the configuration from the folder void ElLoadConfigFromFolder(EL *e, FOLDER *root) { UINT i; TOKEN_LIST *t; FOLDER *devices; // Validate arguments if (e == NULL || root == NULL) { return; } i = CfgGetInt(root, "AdminPort"); if (i >= 1 && i <= 65535) { e->Port = i; } e->AutoDeleteCheckDiskFreeSpaceMin = CfgGetInt64(root, "AutoDeleteCheckDiskFreeSpaceMin"); if (CfgIsItem(root, "AutoDeleteCheckDiskFreeSpaceMin") == false && e->AutoDeleteCheckDiskFreeSpaceMin == 0) { e->AutoDeleteCheckDiskFreeSpaceMin = DISK_FREE_SPACE_DEFAULT; } if (e->AutoDeleteCheckDiskFreeSpaceMin != 0) { if (e->AutoDeleteCheckDiskFreeSpaceMin < DISK_FREE_SPACE_MIN) { e->AutoDeleteCheckDiskFreeSpaceMin = DISK_FREE_SPACE_MIN; } } if (CfgGetByte(root, "AdminPassword", e->HashedPassword, sizeof(e->HashedPassword)) != sizeof(e->HashedPassword)) { Hash(e->HashedPassword, "", 0, true); } if (ELOG_IS_BETA == false) { EiLoadLicenseManager(e, CfgGetFolder(root, "LicenseManager")); } devices = CfgGetFolder(root, "Devices"); if(devices != NULL) { LockList(e->DeviceList); { t = CfgEnumFolderToTokenList(devices); for (i = 0;i < t->NumTokens;i++) { char *name = t->Token[i]; FOLDER *f = CfgGetFolder(devices, name); if (f != NULL) { HUB_LOG g; Zero(&g, sizeof(g)); SiLoadHubLogCfg(&g, f); ElAddCaptureDevice(e, name, &g, CfgGetBool(f, "NoPromiscusMode")); } } FreeToken(t); } UnlockList(e->DeviceList); } }
// Read the virtual host option (extended) void NiLoadVhOptionEx(VH_OPTION *o, FOLDER *root) { FOLDER *host, *nat, *dhcp; char mac_address[MAX_SIZE]; // Validate arguments if (o == NULL || root == NULL) { return; } host = CfgGetFolder(root, "VirtualHost"); nat = CfgGetFolder(root, "VirtualRouter"); dhcp = CfgGetFolder(root, "VirtualDhcpServer"); Zero(o, sizeof(VH_OPTION)); GenMacAddress(o->MacAddress); if (CfgGetStr(host, "VirtualHostMacAddress", mac_address, sizeof(mac_address))) { BUF *b = StrToBin(mac_address); if (b != NULL) { if (b->Size == 6) { Copy(o->MacAddress, b->Buf, 6); } } FreeBuf(b); } CfgGetIp(host, "VirtualHostIp", &o->Ip); CfgGetIp(host, "VirtualHostIpSubnetMask", &o->Mask); o->UseNat = CfgGetBool(nat, "NatEnabled"); o->Mtu = CfgGetInt(nat, "NatMtu"); o->NatTcpTimeout = CfgGetInt(nat, "NatTcpTimeout"); o->NatUdpTimeout = CfgGetInt(nat, "NatUdpTimeout"); o->UseDhcp = CfgGetBool(dhcp, "DhcpEnabled"); CfgGetIp(dhcp, "DhcpLeaseIPStart", &o->DhcpLeaseIPStart); CfgGetIp(dhcp, "DhcpLeaseIPEnd", &o->DhcpLeaseIPEnd); CfgGetIp(dhcp, "DhcpSubnetMask", &o->DhcpSubnetMask); o->DhcpExpireTimeSpan = CfgGetInt(dhcp, "DhcpExpireTimeSpan"); CfgGetIp(dhcp, "DhcpGatewayAddress", &o->DhcpGatewayAddress); CfgGetIp(dhcp, "DhcpDnsServerAddress", &o->DhcpDnsServerAddress); CfgGetIp(dhcp, "DhcpDnsServerAddress2", &o->DhcpDnsServerAddress2); CfgGetStr(dhcp, "DhcpDomainName", o->DhcpDomainName, sizeof(o->DhcpDomainName)); CfgGetStr(dhcp, "DhcpPushRoutes", o->DhcpPushRoutes, sizeof(o->DhcpPushRoutes)); // Test code // StrCpy(o->DhcpPushRoutes, sizeof(o->DhcpPushRoutes), // "130.158.6.0/24/192.168.9.2 130.158.80.244/255.255.255.255/192.168.9.2"); NormalizeClasslessRouteTableStr(o->DhcpPushRoutes, sizeof(o->DhcpPushRoutes), o->DhcpPushRoutes); o->ApplyDhcpPushRoutes = true; Trim(o->DhcpDomainName); if (StrLen(o->DhcpDomainName) == 0) { //GetDomainName(o->DhcpDomainName, sizeof(o->DhcpDomainName)); } o->SaveLog = CfgGetBool(root, "SaveLog"); }