Project

General

Profile

Bug #499 ยป 0001-bug-499-update-host-os-info-enum-map-to-use-instead-.patch

Anoop Saldanha, 07/11/2012 04:58 AM

View differences:

src/util-host-os-info.c
SCEnumCharMap sc_hinfo_os_policy_map[ ] = {
{ "none", OS_POLICY_NONE },
{ "bsd", OS_POLICY_BSD },
{ "bsd_right", OS_POLICY_BSD_RIGHT },
{ "old_linux", OS_POLICY_OLD_LINUX },
{ "bsd-right", OS_POLICY_BSD_RIGHT },
{ "old-linux", OS_POLICY_OLD_LINUX },
{ "linux", OS_POLICY_LINUX },
{ "old_solaris", OS_POLICY_OLD_SOLARIS },
{ "old-solaris", OS_POLICY_OLD_SOLARIS },
{ "solaris", OS_POLICY_SOLARIS },
{ "hpux10", OS_POLICY_HPUX10 },
{ "hpux11", OS_POLICY_HPUX11 },
......
/** Radix tree that holds the host OS information */
static SCRadixTree *sc_hinfo_tree = NULL;
static SCRadixTree *sc_hinfo_tree_backup = NULL;
static void SCHInfoCreateContextBackup(void)
{
sc_hinfo_tree_backup = sc_hinfo_tree;
sc_hinfo_tree = NULL;
return;
}
static void SCHInfoRestoreContextBackup(void)
{
sc_hinfo_tree = sc_hinfo_tree_backup;
sc_hinfo_tree_backup = NULL;
return;
}
/**
* \brief Validates an IPV4 address and returns the network endian arranged
......
*/
int SCHInfoTestInvalidOSFlavour01(void)
{
int result = 1;
SCHInfoCreateContextBackup();
int result = 0;
result &= (SCHInfoAddHostOSInfo("bamboo", "192.168.1.1", SC_HINFO_IS_IPV4) ==
-1);
result &= (SCHInfoAddHostOSInfo("linux", "192.168.1.1", SC_HINFO_IS_IPV4) ==
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map));
result &= (SCHInfoAddHostOSInfo("windows", "192.168.1.1", SC_HINFO_IS_IPV4) ==
SCMapEnumNameToValue("windows", sc_hinfo_os_policy_map));
result &= (SCHInfoAddHostOSInfo("solaris", "192.168.1.1", SC_HINFO_IS_IPV4) ==
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map));
result &= (SCHInfoAddHostOSInfo("hpux10", "192.168.1.1", SC_HINFO_IS_IPV4) ==
SCMapEnumNameToValue("hpux10", sc_hinfo_os_policy_map));
result &= (SCHInfoAddHostOSInfo("hpux11", "192.168.1.1", SC_HINFO_IS_IPV4) ==
SCMapEnumNameToValue("hpux11", sc_hinfo_os_policy_map));
result &= (SCHInfoAddHostOSInfo("irix", "192.168.1.1", SC_HINFO_IS_IPV4) ==
SCMapEnumNameToValue("irix", sc_hinfo_os_policy_map));
result &= (SCHInfoAddHostOSInfo("bsd", "192.168.1.1", SC_HINFO_IS_IPV4) ==
SCMapEnumNameToValue("bsd", sc_hinfo_os_policy_map));
result &= (SCHInfoAddHostOSInfo("old_linux", "192.168.1.1", SC_HINFO_IS_IPV4) ==
SCMapEnumNameToValue("old_linux", sc_hinfo_os_policy_map));
result &= (SCHInfoAddHostOSInfo("macos", "192.168.1.1", SC_HINFO_IS_IPV4) ==
SCMapEnumNameToValue("macos", sc_hinfo_os_policy_map));
result &= (SCHInfoAddHostOSInfo("vista", "192.168.1.1", SC_HINFO_IS_IPV4) ==
SCMapEnumNameToValue("vista", sc_hinfo_os_policy_map));
result &= (SCHInfoAddHostOSInfo("windows2k3", "192.168.1.1", SC_HINFO_IS_IPV4) ==
SCMapEnumNameToValue("windows2k3", sc_hinfo_os_policy_map));
if (SCHInfoAddHostOSInfo("bamboo", "192.168.1.1", SC_HINFO_IS_IPV4) != -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("linux", "192.168.1.1", SC_HINFO_IS_IPV4) !=
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoAddHostOSInfo("windows", "192.168.1.1", SC_HINFO_IS_IPV4) !=
SCMapEnumNameToValue("windows", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoAddHostOSInfo("solaris", "192.168.1.1", SC_HINFO_IS_IPV4) !=
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoAddHostOSInfo("hpux10", "192.168.1.1", SC_HINFO_IS_IPV4) !=
SCMapEnumNameToValue("hpux10", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoAddHostOSInfo("hpux11", "192.168.1.1", SC_HINFO_IS_IPV4) !=
SCMapEnumNameToValue("hpux11", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoAddHostOSInfo("irix", "192.168.1.1", SC_HINFO_IS_IPV4) !=
SCMapEnumNameToValue("irix", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoAddHostOSInfo("bsd", "192.168.1.1", SC_HINFO_IS_IPV4) !=
SCMapEnumNameToValue("bsd", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoAddHostOSInfo("old_linux", "192.168.1.1", SC_HINFO_IS_IPV4) !=
SCMapEnumNameToValue("old_linux", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoAddHostOSInfo("macos", "192.168.1.1", SC_HINFO_IS_IPV4) !=
SCMapEnumNameToValue("macos", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoAddHostOSInfo("vista", "192.168.1.1", SC_HINFO_IS_IPV4) !=
SCMapEnumNameToValue("vista", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoAddHostOSInfo("windows2k3", "192.168.1.1", SC_HINFO_IS_IPV4) !=
SCMapEnumNameToValue("windows2k3", sc_hinfo_os_policy_map)) {
goto end;
}
result = 1;
end:
SCHInfoCleanResources();
SCHInfoRestoreContextBackup();
return result;
}
......
*/
int SCHInfoTestInvalidIPV4Address02(void)
{
SCHInfoCreateContextBackup();
int result = 1;
result &= (SCHInfoAddHostOSInfo("linux", "192.168.1.566", SC_HINFO_IS_IPV4) ==
-1);
result &= (SCHInfoAddHostOSInfo("linux", "192.168.1", SC_HINFO_IS_IPV4) ==
-1);
result &= (SCHInfoAddHostOSInfo("linux", "192.", SC_HINFO_IS_IPV4) == -1);
result &= (SCHInfoAddHostOSInfo("linux", "192.168", SC_HINFO_IS_IPV4) ==
-1);
result &= (SCHInfoAddHostOSInfo("linux", "", SC_HINFO_IS_IPV4) == -1);
result &= (SCHInfoAddHostOSInfo("linux", "192.168.1.1/33", SC_HINFO_IS_IPV4) ==
-1);
if (SCHInfoAddHostOSInfo("linux", "192.168.1.566", SC_HINFO_IS_IPV4) != -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("linux", "192.168.1", SC_HINFO_IS_IPV4 != -1)) {
goto end;
}
if (SCHInfoAddHostOSInfo("linux", "192.", SC_HINFO_IS_IPV4) != -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("linux", "192.168", SC_HINFO_IS_IPV4) != -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("linux", "", SC_HINFO_IS_IPV4) != -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("linux", "192.168.1.1/33", SC_HINFO_IS_IPV4) != -1) {
goto end;
}
result = 1;
end:
SCHInfoCleanResources();
SCHInfoRestoreContextBackup();
return result;
}
......
*/
int SCHInfoTestInvalidIPV6Address03(void)
{
SCHInfoCreateContextBackup();
int result = 1;
result &= (SCHInfoAddHostOSInfo("linux", "2362:7322", SC_HINFO_IS_IPV6) ==
-1);
result &= (SCHInfoAddHostOSInfo("linux", "19YW:", SC_HINFO_IS_IPV6) == -1);
result &= (SCHInfoAddHostOSInfo("linux", "1235", SC_HINFO_IS_IPV6) == -1);
result &= (SCHInfoAddHostOSInfo("linux", "1922:236115:", SC_HINFO_IS_IPV6) ==
-1);
result &= (SCHInfoAddHostOSInfo("linux", "", SC_HINFO_IS_IPV6) == -1);
result &= (SCHInfoAddHostOSInfo("linux",
"1921.6311:6241:6422:7352:ABBB:DDDD:EEEE/129",
SC_HINFO_IS_IPV6) == -1);
if (SCHInfoAddHostOSInfo("linux", "2362:7322", SC_HINFO_IS_IPV6) != -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("linux", "19YW:", SC_HINFO_IS_IPV6) != -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("linux", "1235", SC_HINFO_IS_IPV6) != -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("linux", "1922:236115:", SC_HINFO_IS_IPV6) != -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("linux", "", SC_HINFO_IS_IPV6) != -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("linux",
"1921.6311:6241:6422:7352:ABBB:DDDD:EEEE/129",
SC_HINFO_IS_IPV6) != -1) {
goto end;
}
result = 1;
end:
SCHInfoCleanResources();
SCHInfoRestoreContextBackup();
return result;
}
......
*/
int SCHInfoTestValidIPV4Address04(void)
{
SCHInfoCreateContextBackup();
int result = 1;
result &= (SCHInfoAddHostOSInfo("linux", "192.168.1.1", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoAddHostOSInfo("windows", "192.192.1.2", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoAddHostOSInfo("solaris", "192.168.1.100", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoAddHostOSInfo("hpux10", "192.168.2.4", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoAddHostOSInfo("linux", "192.192.1.5", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoAddHostOSInfo("vista", "192.168.10.20", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoAddHostOSInfo("solaris", "111.163.151.62", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoAddHostOSInfo("solaris", "11.1.120.210", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoAddHostOSInfo("linux", "19.18.110.210", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoAddHostOSInfo("windows", "19.18.120.110", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoAddHostOSInfo("hpux11", "191.168.11.128", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoAddHostOSInfo("vista", "191.168.11.192", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoGetHostOSFlavour("192.168.1.1") ==
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("192.168.1.2") == -1);
result &= (SCHInfoGetHostOSFlavour("192.168.1.100") ==
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("192.192.2.4") == -1);
result &= (SCHInfoGetHostOSFlavour("192.168.2.4") ==
SCMapEnumNameToValue("hpux10", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("192.192.1.5") ==
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("192.168.10.20") ==
SCMapEnumNameToValue("vista", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("111.163.151.62") ==
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("11.1.120.210") ==
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("19.18.110.210") ==
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("19.18.120.110") ==
SCMapEnumNameToValue("windows", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("191.168.11.128") ==
SCMapEnumNameToValue("hpux11", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("191.168.11.192") ==
SCMapEnumNameToValue("vista", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("191.168.11.224") == -1);
if (SCHInfoAddHostOSInfo("linux", "192.168.1.1", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("windows", "192.192.1.2", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("solaris", "192.168.1.100", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("hpux10", "192.168.2.4", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("linux", "192.192.1.5", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("vista", "192.168.10.20", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("solaris", "111.163.151.62", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("solaris", "11.1.120.210", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("linux", "19.18.110.210", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("windows", "19.18.120.110", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("hpux11", "191.168.11.128", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("vista", "191.168.11.192", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoGetHostOSFlavour("192.168.1.1") !=
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("192.168.1.2") != -1) {
goto end;
}
if (SCHInfoGetHostOSFlavour("192.168.1.100") !=
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("192.192.2.4") != -1) {
goto end;
}
if (SCHInfoGetHostOSFlavour("192.168.2.4") !=
SCMapEnumNameToValue("hpux10", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("192.192.1.5") !=
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("192.168.10.20") !=
SCMapEnumNameToValue("vista", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("111.163.151.62") !=
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("11.1.120.210") !=
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("19.18.110.210") !=
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("19.18.120.110") !=
SCMapEnumNameToValue("windows", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("191.168.11.128") !=
SCMapEnumNameToValue("hpux11", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("191.168.11.192") !=
SCMapEnumNameToValue("vista", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("191.168.11.224") != -1) {
goto end;
}
result = 1;
end:
SCHInfoCleanResources();
SCHInfoRestoreContextBackup();
return result;
}
......
*/
int SCHInfoTestValidIPV4Address05(void)
{
SCHInfoCreateContextBackup();
struct in_addr in;
int result = 1;
result &= (SCHInfoAddHostOSInfo("linux", "192.168.1.1", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoAddHostOSInfo("windows", "192.192.1.2", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoAddHostOSInfo("solaris", "192.168.1.100", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoAddHostOSInfo("hpux10", "192.168.2.4", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoAddHostOSInfo("linux", "192.192.1.5", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoAddHostOSInfo("vista", "192.168.10.20", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoAddHostOSInfo("solaris", "111.163.151.62", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoAddHostOSInfo("hpux11", "111.162.208.124/20", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoAddHostOSInfo("windows", "111.162.240.1", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoAddHostOSInfo("solaris", "111.162.214.100", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoAddHostOSInfo("vista", "111.162.208.100", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoAddHostOSInfo("linux", "111.162.194.112", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoGetHostOSFlavour("192.168.1.1") ==
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("192.168.1.2") == -1);
result &= (SCHInfoGetHostOSFlavour("192.168.1.100") ==
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("192.192.2.4") == -1);
result &= (SCHInfoGetHostOSFlavour("192.168.2.4") ==
SCMapEnumNameToValue("hpux10", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("192.192.1.5") ==
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("192.168.10.20") ==
SCMapEnumNameToValue("vista", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("111.163.151.62") ==
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("111.162.208.0") ==
SCMapEnumNameToValue("hpux11", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("111.162.210.1") ==
SCMapEnumNameToValue("hpux11", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("111.162.214.1") ==
SCMapEnumNameToValue("hpux11", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("111.162.0.0") == -1);
result &= (SCHInfoGetHostOSFlavour("111.162.240.112") == -1);
result &= (SCHInfoGetHostOSFlavour("111.162.240.1") ==
SCMapEnumNameToValue("windows", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("111.162.214.100") ==
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map));
if (inet_pton(AF_INET, "111.162.208.100", &in) < 0)
result = 0;
result &= (SCHInfoGetIPv4HostOSFlavour((uint8_t *)&in) ==
SCMapEnumNameToValue("vista", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("111.162.194.112") ==
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("111.162.208.200") ==
SCMapEnumNameToValue("hpux11", sc_hinfo_os_policy_map));
if (inet_pton(AF_INET, "111.162.208.200", &in) < 0)
result = 0;
result &= (SCHInfoGetIPv4HostOSFlavour((uint8_t *)&in) ==
SCMapEnumNameToValue("hpux11", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("111.162.200.201") == -1);
if (SCHInfoAddHostOSInfo("linux", "192.168.1.1", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("windows", "192.192.1.2", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("solaris", "192.168.1.100", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("hpux10", "192.168.2.4", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("linux", "192.192.1.5", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("vista", "192.168.10.20", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("solaris", "111.163.151.62", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("hpux11", "111.162.208.124/20", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("windows", "111.162.240.1", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("solaris", "111.162.214.100", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("vista", "111.162.208.100", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("linux", "111.162.194.112", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoGetHostOSFlavour("192.168.1.1") !=
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("192.168.1.2") != -1) {
goto end;
}
if (SCHInfoGetHostOSFlavour("192.168.1.100") !=
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("192.192.2.4") != -1) {
goto end;
}
if (SCHInfoGetHostOSFlavour("192.168.2.4") !=
SCMapEnumNameToValue("hpux10", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("192.192.1.5") !=
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("192.168.10.20") !=
SCMapEnumNameToValue("vista", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("111.163.151.62") !=
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("111.162.208.0") !=
SCMapEnumNameToValue("hpux11", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("111.162.210.1") !=
SCMapEnumNameToValue("hpux11", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("111.162.214.1") !=
SCMapEnumNameToValue("hpux11", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("111.162.0.0") != -1) {
goto end;
}
if (SCHInfoGetHostOSFlavour("111.162.240.112") != -1) {
goto end;
}
if (SCHInfoGetHostOSFlavour("111.162.240.1") !=
SCMapEnumNameToValue("windows", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("111.162.214.100") !=
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map)) {
goto end;
}
if (inet_pton(AF_INET, "111.162.208.100", &in) < 0) {
goto end;
}
if (SCHInfoGetIPv4HostOSFlavour((uint8_t *)&in) !=
SCMapEnumNameToValue("vista", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("111.162.194.112") !=
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("111.162.208.200") !=
SCMapEnumNameToValue("hpux11", sc_hinfo_os_policy_map)) {
goto end;
}
if (inet_pton(AF_INET, "111.162.208.200", &in) < 0) {
goto end;
}
if (SCHInfoGetIPv4HostOSFlavour((uint8_t *)&in) !=
SCMapEnumNameToValue("hpux11", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("111.162.200.201") != -1) {
goto end;
}
result = 1;
end:
SCHInfoCleanResources();
SCHInfoRestoreContextBackup();
return result;
}
......
*/
int SCHInfoTestValidIPV6Address06(void)
{
SCHInfoCreateContextBackup();
int result = 1;
result &= (SCHInfoAddHostOSInfo("linux",
"2351:2512:6211:6246:235A:6242:2352:62AD",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("windows",
"6961:6121:2132:6241:423A:2135:2461:621D",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("solaris",
"DD13:613D:F312:62DD:6213:421A:6212:2652",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("hpux10",
"9891:2131:2151:6426:1342:674D:622F:2342",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("linux",
"3525:2351:4223:6211:2311:2667:6242:2154",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("vista",
"1511:6211:6726:7777:1212:2333:6222:7722",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("solaris",
"2666:6222:7222:2335:6223:7722:3425:2362",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("solaris",
"8762:2352:6241:7245:EE23:21AD:2312:622C",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("linux",
"6422:EE1A:2621:34AD:2462:432D:642E:E13A",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("windows",
"3521:7622:6241:6242:7277:1234:2352:6234",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("hpux11",
"2141:6232:6252:2223:7734:2345:6245:6222",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("vista",
"5222:6432:6432:2322:6662:3423:4322:3245",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoGetHostOSFlavour("2351:2512:6211:6246:235A:6242:2352:62AD") ==
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("2351:2512:6211:6246:235A:6242:2352:6FFFE") ==
-1);
result &= (SCHInfoGetHostOSFlavour("DD13:613D:F312:62DD:6213:421A:6212:2652") ==
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("DD13:613D:F312:62DD:6213:421A:6212:2222") ==
-1);
result &= (SCHInfoGetHostOSFlavour("9891:2131:2151:6426:1342:674D:622F:2342") ==
SCMapEnumNameToValue("hpux10", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("3525:2351:4223:6211:2311:2667:6242:2154") ==
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("1511:6211:6726:7777:1212:2333:6222:7722") ==
SCMapEnumNameToValue("vista", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("2666:6222:7222:2335:6223:7722:3425:2362") ==
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:21AD:2312:622C") ==
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("6422:EE1A:2621:34AD:2462:432D:642E:E13A") ==
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("3521:7622:6241:6242:7277:1234:2352:6234") ==
SCMapEnumNameToValue("windows", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("2141:6232:6252:2223:7734:2345:6245:6222") ==
SCMapEnumNameToValue("hpux11", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("5222:6432:6432:2322:6662:3423:4322:3245") ==
SCMapEnumNameToValue("vista", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("5222:6432:6432:2322:6662:3423:4322:DDDD") ==
-1);
if (SCHInfoAddHostOSInfo("linux",
"2351:2512:6211:6246:235A:6242:2352:62AD",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("windows",
"6961:6121:2132:6241:423A:2135:2461:621D",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("solaris",
"DD13:613D:F312:62DD:6213:421A:6212:2652",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("hpux10",
"9891:2131:2151:6426:1342:674D:622F:2342",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("linux",
"3525:2351:4223:6211:2311:2667:6242:2154",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("vista",
"1511:6211:6726:7777:1212:2333:6222:7722",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("solaris",
"2666:6222:7222:2335:6223:7722:3425:2362",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("solaris",
"8762:2352:6241:7245:EE23:21AD:2312:622C",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("linux",
"6422:EE1A:2621:34AD:2462:432D:642E:E13A",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("windows",
"3521:7622:6241:6242:7277:1234:2352:6234",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("hpux11",
"2141:6232:6252:2223:7734:2345:6245:6222",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("vista",
"5222:6432:6432:2322:6662:3423:4322:3245",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoGetHostOSFlavour("2351:2512:6211:6246:235A:6242:2352:62AD") !=
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("2351:2512:6211:6246:235A:6242:2352:6FFFE") != -1) {
goto end;
}
if (SCHInfoGetHostOSFlavour("DD13:613D:F312:62DD:6213:421A:6212:2652") !=
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("DD13:613D:F312:62DD:6213:421A:6212:2222") != -1) {
goto end;
}
if (SCHInfoGetHostOSFlavour("9891:2131:2151:6426:1342:674D:622F:2342") !=
SCMapEnumNameToValue("hpux10", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("3525:2351:4223:6211:2311:2667:6242:2154") !=
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("1511:6211:6726:7777:1212:2333:6222:7722") !=
SCMapEnumNameToValue("vista", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("2666:6222:7222:2335:6223:7722:3425:2362") !=
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:21AD:2312:622C") !=
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("6422:EE1A:2621:34AD:2462:432D:642E:E13A") !=
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("3521:7622:6241:6242:7277:1234:2352:6234") !=
SCMapEnumNameToValue("windows", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("2141:6232:6252:2223:7734:2345:6245:6222") !=
SCMapEnumNameToValue("hpux11", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("5222:6432:6432:2322:6662:3423:4322:3245") !=
SCMapEnumNameToValue("vista", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("5222:6432:6432:2322:6662:3423:4322:DDDD") != -1) {
goto end;
}
result = 1;
end:
SCHInfoCleanResources();
SCHInfoRestoreContextBackup();
return result;
}
......
*/
int SCHInfoTestValidIPV6Address07(void)
{
SCHInfoCreateContextBackup();
int result = 1;
result &= (SCHInfoAddHostOSInfo("linux",
"2351:2512:6211:6246:235A:6242:2352:62AD",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("windows",
"6961:6121:2132:6241:423A:2135:2461:621D",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("solaris",
"DD13:613D:F312:62DD:6213:421A:6212:2652",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("hpux10",
"9891:2131:2151:6426:1342:674D:622F:2342",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("linux",
"3525:2351:4223:6211:2311:2667:6242:2154",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("vista",
"1511:6211:6726:7777:1212:2333:6222:7722",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("solaris",
"2666:6222:7222:2335:6223:7722:3425:2362",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("solaris",
"8762:2352:6241:7245:EE23:21AD:2312:622C/68",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("linux",
"8762:2352:6241:7245:EE23:21AD:2412:622C",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("windows",
"8762:2352:6241:7245:EE23:21AD:FFFF:622C",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("hpux11",
"8762:2352:6241:7245:EE23:21AD:2312:62FF",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("vista",
"8762:2352:6241:7245:EE23:21AD:2121:1212",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoGetHostOSFlavour("2351:2512:6211:6246:235A:6242:2352:62AD") ==
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("2351:2512:6211:6246:235A:6242:2352:6FFFE") ==
-1);
result &= (SCHInfoGetHostOSFlavour("DD13:613D:F312:62DD:6213:421A:6212:2652") ==
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("DD13:613D:F312:62DD:6213:421A:6212:2222") ==
-1);
result &= (SCHInfoGetHostOSFlavour("9891:2131:2151:6426:1342:674D:622F:2342") ==
SCMapEnumNameToValue("hpux10", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("3525:2351:4223:6211:2311:2667:6242:2154") ==
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("1511:6211:6726:7777:1212:2333:6222:7722") ==
SCMapEnumNameToValue("vista", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("2666:6222:7222:2335:6223:7722:3425:2362") ==
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:21AD:2312:622C") ==
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:21AD:2412:622C") ==
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:21AD:FFFF:622C") ==
SCMapEnumNameToValue("windows", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:21AD:2312:62FF") ==
SCMapEnumNameToValue("hpux11", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:21AD:2121:1212") ==
SCMapEnumNameToValue("vista", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("5222:6432:6432:2322:6662:3423:4322:DDDD") ==
-1);
result &= (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:21AD:2121:1DDD") ==
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:FFFF:2121:1DDD") ==
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:21AD:2312:622C") ==
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE00:0000:0000:0000") ==
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:E000:0000:0000:0000") ==
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map));
if (SCHInfoAddHostOSInfo("linux",
"2351:2512:6211:6246:235A:6242:2352:62AD",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("windows",
"6961:6121:2132:6241:423A:2135:2461:621D",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("solaris",
"DD13:613D:F312:62DD:6213:421A:6212:2652",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("hpux10",
"9891:2131:2151:6426:1342:674D:622F:2342",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("linux",
"3525:2351:4223:6211:2311:2667:6242:2154",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("vista",
"1511:6211:6726:7777:1212:2333:6222:7722",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("solaris",
"2666:6222:7222:2335:6223:7722:3425:2362",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("solaris",
"8762:2352:6241:7245:EE23:21AD:2312:622C/68",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("linux",
"8762:2352:6241:7245:EE23:21AD:2412:622C",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("windows",
"8762:2352:6241:7245:EE23:21AD:FFFF:622C",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("hpux11",
"8762:2352:6241:7245:EE23:21AD:2312:62FF",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("vista",
"8762:2352:6241:7245:EE23:21AD:2121:1212",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoGetHostOSFlavour("2351:2512:6211:6246:235A:6242:2352:62AD") !=
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("2351:2512:6211:6246:235A:6242:2352:6FFFE") != -1) {
goto end;
}
if (SCHInfoGetHostOSFlavour("DD13:613D:F312:62DD:6213:421A:6212:2652") !=
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("DD13:613D:F312:62DD:6213:421A:6212:2222") != -1) {
goto end;
}
if (SCHInfoGetHostOSFlavour("9891:2131:2151:6426:1342:674D:622F:2342") !=
SCMapEnumNameToValue("hpux10", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("3525:2351:4223:6211:2311:2667:6242:2154") !=
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("1511:6211:6726:7777:1212:2333:6222:7722") !=
SCMapEnumNameToValue("vista", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("2666:6222:7222:2335:6223:7722:3425:2362") !=
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:21AD:2312:622C") !=
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:21AD:2412:622C") !=
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:21AD:FFFF:622C") !=
SCMapEnumNameToValue("windows", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:21AD:2312:62FF") !=
SCMapEnumNameToValue("hpux11", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:21AD:2121:1212") !=
SCMapEnumNameToValue("vista", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("5222:6432:6432:2322:6662:3423:4322:DDDD") != -1) {
goto end;
}
if (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:21AD:2121:1DDD") !=
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:FFFF:2121:1DDD") !=
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:21AD:2312:622C") !=
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE00:0000:0000:0000") !=
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:E000:0000:0000:0000") !=
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map)) {
goto end;
}
result = 1;
end:
SCHInfoCleanResources();
SCHInfoRestoreContextBackup();
return result;
}
......
*/
int SCHInfoTestValidIPV6Address08(void)
{
SCHInfoCreateContextBackup();
struct in6_addr in6;
int result = 1;
result &= (SCHInfoAddHostOSInfo("linux",
"2351:2512:6211:6246:235A:6242:2352:62AD",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("windows",
"6961:6121:2132:6241:423A:2135:2461:621D",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("solaris",
"DD13:613D:F312:62DD:6213:421A:6212:2652",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("hpux10",
"9891:2131:2151:6426:1342:674D:622F:2342",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("linux",
"3525:2351:4223:6211:2311:2667:6242:2154",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("vista",
"1511:6211:6726:7777:1212:2333:6222:7722",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("solaris",
"2666:6222:7222:2335:6223:7722:3425:2362",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("solaris",
"8762:2352:6241:7245:EE23:21AD:2312:622C/68",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("linux",
"8762:2352:6241:7245:EE23:21AD:2412:622C",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("windows",
"8762:2352:6241:7245:EE23:21AD:FFFF:622C",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("hpux11",
"8762:2352:6241:7245:EE23:21AD:2312:62FF",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("vista",
"8762:2352:6241:7245:EE23:21AD:2121:1212",
SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoAddHostOSInfo("irix", "default", SC_HINFO_IS_IPV6) != -1);
result &= (SCHInfoGetHostOSFlavour("2351:2512:6211:6246:235A:6242:2352:62AD") ==
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("2351:2512:6211:6246:235A:6242:2352:6FFF") ==
SCMapEnumNameToValue("irix", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("DD13:613D:F312:62DD:6213:421A:6212:2652") ==
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("DD13:613D:F312:62DD:6213:421A:6212:2222") ==
SCMapEnumNameToValue("irix", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("9891:2131:2151:6426:1342:674D:622F:2342") ==
SCMapEnumNameToValue("hpux10", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("3525:2351:4223:6211:2311:2667:6242:2154") ==
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("1511:6211:6726:7777:1212:2333:6222:7722") ==
SCMapEnumNameToValue("vista", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("2666:6222:7222:2335:6223:7722:3425:2362") ==
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:21AD:2312:622C") ==
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:21AD:2412:622C") ==
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:21AD:FFFF:622C") ==
SCMapEnumNameToValue("windows", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:21AD:2312:62FF") ==
SCMapEnumNameToValue("hpux11", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:21AD:2121:1212") ==
SCMapEnumNameToValue("vista", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("5222:6432:6432:2322:6662:3423:4322:DDDD") ==
SCMapEnumNameToValue("irix", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:21AD:2121:1DDD") ==
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:FFFF:2121:1DDD") ==
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:21AD:2312:622C") ==
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE00:0000:0000:0000") ==
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map));
if (inet_pton(AF_INET6, "8762:2352:6241:7245:E000:0000:0000:0000", &in6) < 0)
result = 0;
result &= (SCHInfoGetIPv6HostOSFlavour((uint8_t *)&in6) ==
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map));
if (inet_pton(AF_INET6, "AD23:2DDA:6D1D:A223:E235:0232:1241:1666", &in6) < 0)
result = 0;
result &= (SCHInfoGetIPv6HostOSFlavour((uint8_t *)&in6) ==
SCMapEnumNameToValue("irix", sc_hinfo_os_policy_map));
if (SCHInfoAddHostOSInfo("linux",
"2351:2512:6211:6246:235A:6242:2352:62AD",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("windows",
"6961:6121:2132:6241:423A:2135:2461:621D",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("solaris",
"DD13:613D:F312:62DD:6213:421A:6212:2652",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("hpux10",
"9891:2131:2151:6426:1342:674D:622F:2342",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("linux",
"3525:2351:4223:6211:2311:2667:6242:2154",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("vista",
"1511:6211:6726:7777:1212:2333:6222:7722",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("solaris",
"2666:6222:7222:2335:6223:7722:3425:2362",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("solaris",
"8762:2352:6241:7245:EE23:21AD:2312:622C/68",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("linux",
"8762:2352:6241:7245:EE23:21AD:2412:622C",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("windows",
"8762:2352:6241:7245:EE23:21AD:FFFF:622C",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("hpux11",
"8762:2352:6241:7245:EE23:21AD:2312:62FF",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("vista",
"8762:2352:6241:7245:EE23:21AD:2121:1212",
SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("irix", "default", SC_HINFO_IS_IPV6) == -1) {
goto end;
}
if (SCHInfoGetHostOSFlavour("2351:2512:6211:6246:235A:6242:2352:62AD") !=
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("2351:2512:6211:6246:235A:6242:2352:6FFF") !=
SCMapEnumNameToValue("irix", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("DD13:613D:F312:62DD:6213:421A:6212:2652") !=
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("DD13:613D:F312:62DD:6213:421A:6212:2222") !=
SCMapEnumNameToValue("irix", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("9891:2131:2151:6426:1342:674D:622F:2342") !=
SCMapEnumNameToValue("hpux10", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("3525:2351:4223:6211:2311:2667:6242:2154") !=
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("1511:6211:6726:7777:1212:2333:6222:7722") !=
SCMapEnumNameToValue("vista", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("2666:6222:7222:2335:6223:7722:3425:2362") !=
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:21AD:2312:622C") !=
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:21AD:2412:622C") !=
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:21AD:FFFF:622C") !=
SCMapEnumNameToValue("windows", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:21AD:2312:62FF") !=
SCMapEnumNameToValue("hpux11", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:21AD:2121:1212") !=
SCMapEnumNameToValue("vista", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("5222:6432:6432:2322:6662:3423:4322:DDDD") !=
SCMapEnumNameToValue("irix", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:21AD:2121:1DDD") !=
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:FFFF:2121:1DDD") !=
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE23:21AD:2312:622C") !=
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("8762:2352:6241:7245:EE00:0000:0000:0000") !=
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map)) {
goto end;
}
if (inet_pton(AF_INET6, "8762:2352:6241:7245:E000:0000:0000:0000", &in6) < 0) {
goto end;
}
if (SCHInfoGetIPv6HostOSFlavour((uint8_t *)&in6) !=
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map)) {
goto end;
}
if (inet_pton(AF_INET6, "AD23:2DDA:6D1D:A223:E235:0232:1241:1666", &in6) < 0) {
goto end;
}
if (SCHInfoGetIPv6HostOSFlavour((uint8_t *)&in6) !=
SCMapEnumNameToValue("irix", sc_hinfo_os_policy_map)) {
goto end;
}
result = 1;
end:
SCHInfoCleanResources();
SCHInfoRestoreContextBackup();
return result;
}
......
*/
int SCHInfoTestValidIPV4Address09(void)
{
SCHInfoCreateContextBackup();
int result = 1;
result &= (SCHInfoAddHostOSInfo("linux", "192.168.1.0", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoAddHostOSInfo("windows", "192.192.1.2", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoGetHostOSFlavour("192.168.1.0") ==
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map));
result &= (SCHInfoAddHostOSInfo("solaris", "192.168.1.0/16", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoAddHostOSInfo("macos", "192.168.1.0/20", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoGetHostOSFlavour("192.168.1.0") ==
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map));
result &= (SCHInfoAddHostOSInfo("vista", "192.168.50.128/25", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoGetHostOSFlavour("192.168.50.128") ==
SCMapEnumNameToValue("vista", sc_hinfo_os_policy_map));
result &= (SCHInfoAddHostOSInfo("irix", "192.168.50.128", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoGetHostOSFlavour("192.168.50.128") ==
SCMapEnumNameToValue("irix", sc_hinfo_os_policy_map));
result &= (SCHInfoGetHostOSFlavour("192.168.1.100") ==
SCMapEnumNameToValue("macos", sc_hinfo_os_policy_map));
if (SCHInfoAddHostOSInfo("linux", "192.168.1.0", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("windows", "192.192.1.2", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoGetHostOSFlavour("192.168.1.0") !=
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoAddHostOSInfo("solaris", "192.168.1.0/16", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("macos", "192.168.1.0/20", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoGetHostOSFlavour("192.168.1.0") !=
SCMapEnumNameToValue("linux", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoAddHostOSInfo("vista", "192.168.50.128/25", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoGetHostOSFlavour("192.168.50.128") !=
SCMapEnumNameToValue("vista", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoAddHostOSInfo("irix", "192.168.50.128", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoGetHostOSFlavour("192.168.50.128") !=
SCMapEnumNameToValue("irix", sc_hinfo_os_policy_map)) {
goto end;
}
if (SCHInfoGetHostOSFlavour("192.168.1.100") !=
SCMapEnumNameToValue("macos", sc_hinfo_os_policy_map)) {
goto end;
}
struct sockaddr_in servaddr;
bzero(&servaddr, sizeof(servaddr));
if (inet_pton(AF_INET, "192.168.0.0", &servaddr.sin_addr) <= 0)
return 0;
if (inet_pton(AF_INET, "192.168.0.0", &servaddr.sin_addr) <= 0) {
goto end;
}
SCRadixRemoveKeyIPV4Netblock((uint8_t *)&servaddr.sin_addr, sc_hinfo_tree, 16);
result &= (SCHInfoGetHostOSFlavour("192.168.1.100") ==
SCMapEnumNameToValue("macos", sc_hinfo_os_policy_map));
if (SCHInfoGetHostOSFlavour("192.168.1.100") !=
SCMapEnumNameToValue("macos", sc_hinfo_os_policy_map)) {
goto end;
}
bzero(&servaddr, sizeof(servaddr));
if (inet_pton(AF_INET, "192.168.0.0", &servaddr.sin_addr) <= 0)
return 0;
if (inet_pton(AF_INET, "192.168.0.0", &servaddr.sin_addr) <= 0) {
goto end;
}
SCRadixRemoveKeyIPV4Netblock((uint8_t *)&servaddr.sin_addr, sc_hinfo_tree, 20);
result &= (SCHInfoGetHostOSFlavour("192.168.1.100") == -1);
if (SCHInfoGetHostOSFlavour("192.168.1.100") != -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("solaris", "192.168.1.0/16", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
if (SCHInfoAddHostOSInfo("macos", "192.168.1.0/20", SC_HINFO_IS_IPV4) == -1) {
goto end;
}
result &= (SCHInfoAddHostOSInfo("solaris", "192.168.1.0/16", SC_HINFO_IS_IPV4) !=
-1);
result &= (SCHInfoAddHostOSInfo("macos", "192.168.1.0/20", SC_HINFO_IS_IPV4) !=
-1);
if (SCHInfoGetHostOSFlavour("192.168.1.100") ==
SCMapEnumNameToValue("macos", sc_hinfo_os_policy_map)) {
goto end;
}
result &= (SCHInfoGetHostOSFlavour("192.168.1.100") ==
SCMapEnumNameToValue("macos", sc_hinfo_os_policy_map));
bzero(&servaddr, sizeof(servaddr));
if (inet_pton(AF_INET, "192.168.0.0", &servaddr.sin_addr) <= 0)
return 0;
if (inet_pton(AF_INET, "192.168.0.0", &servaddr.sin_addr) <= 0) {
goto end;
}
SCRadixRemoveKeyIPV4Netblock((uint8_t *)&servaddr.sin_addr, sc_hinfo_tree, 20);
result &= (SCHInfoGetHostOSFlavour("192.168.1.100") ==
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map));
if (SCHInfoGetHostOSFlavour("192.168.1.100") ==
SCMapEnumNameToValue("solaris", sc_hinfo_os_policy_map)) {
goto end;
}
bzero(&servaddr, sizeof(servaddr));
if (inet_pton(AF_INET, "192.168.0.0", &servaddr.sin_addr) <= 0)
return 0;
if (inet_pton(AF_INET, "192.168.0.0", &servaddr.sin_addr) <= 0) {
goto end;
}
SCRadixRemoveKeyIPV4Netblock((uint8_t *)&servaddr.sin_addr, sc_hinfo_tree, 16);
result &= (SCHInfoGetHostOSFlavour("192.168.1.100") == -1);
if (SCHInfoGetHostOSFlavour("192.168.1.100") != -1) {
goto end;
}
result = 1;
end:
SCHInfoCleanResources();
SCHInfoRestoreContextBackup();
return result;
}
......
linux: [10.0.0.5/32]\n\
\n";
int result = 0;
SCHInfoCreateContextBackup();
ConfCreateContextBackup();
ConfInit();
ConfYamlLoadString(config, strlen(config));
SCHInfoLoadFromConfig();
if (SCHInfoGetHostOSFlavour("10.0.0.4") != OS_POLICY_WINDOWS)
return 0;
goto end;
if (SCHInfoGetHostOSFlavour("10.0.0.5") != OS_POLICY_LINUX)
return 0;
goto end;
if (SCHInfoGetHostOSFlavour("192.168.1.1") != OS_POLICY_WINDOWS)
return 0;
goto end;
if (SCHInfoGetHostOSFlavour("172.168.1.1") != OS_POLICY_BSD)
return 0;
goto end;
result = 1;
end:
ConfDeInit();
ConfRestoreContextBackup();
SCHInfoRestoreContextBackup();
return result;
}
/**
* \test Check the loading of host info from a configuration file.
*/
int SCHInfoTestLoadFromConfig02(void)
{
char config[] = "\
%YAML 1.1\n\
---\n\
host-os-policy:\n\
one-two: [0.0.0.0/0]\n\
one-two-three:\n\
four_five:\n\
six-seven_eight: [10.0.0.0/8, 192.168.1.0/24]\n\
nine_ten_eleven: [10.0.0.5/32]\n\
\n";
int result = 0;
SCHInfoCreateContextBackup();
ConfCreateContextBackup();
ConfInit();
ConfYamlLoadString(config, strlen(config));
ConfNode *root = ConfGetNode("host-os-policy");
if (root == NULL)
goto end;
int count = 0;
ConfNode *policy;
TAILQ_FOREACH(policy, &root->head, next) {
switch (count) {
case 0:
if (strcmp("one-two", policy->name) != 0)
goto end;
break;
case 1:
if (strcmp("one-two-three", policy->name) != 0)
goto end;
break;
case 2:
if (strcmp("four-five", policy->name) != 0)
goto end;
break;
case 3:
if (strcmp("six-seven-eight", policy->name) != 0)
... This diff was truncated because it exceeds the maximum size that can be displayed.
    (1-1/1)