#ifdef UNITTESTS
-static int UTHValidateDetectAddress(DetectAddress *ad, const char *one, const char *two)
+static bool UTHValidateDetectAddress(DetectAddress *ad, const char *one, const char *two)
{
char str1[46] = "", str2[46] = "";
if (ad == NULL)
- return FALSE;
+ return false;
switch(ad->ip.family) {
case AF_INET:
if (strcmp(str1, one) != 0) {
SCLogInfo("%s != %s", str1, one);
- return FALSE;
+ return false;
}
if (strcmp(str2, two) != 0) {
SCLogInfo("%s != %s", str2, two);
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
break;
case AF_INET6:
if (strcmp(str1, one) != 0) {
SCLogInfo("%s != %s", str1, one);
- return FALSE;
+ return false;
}
if (strcmp(str2, two) != 0) {
SCLogInfo("%s != %s", str2, two);
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
break;
}
- return FALSE;
+ return false;
}
typedef struct UTHValidateDetectAddressHeadRange_ {
int have = 0;
if (gh == NULL)
- return FALSE;
+ return false;
DetectAddress *ad = NULL;
ad = gh->ipv4_head;
while (have < expect) {
if (ad == NULL) {
printf("bad head: have %d ranges, expected %d: ", have, expect);
- return FALSE;
+ return false;
}
- if (UTHValidateDetectAddress(ad, expectations[have].one, expectations[have].two) == FALSE)
- return FALSE;
+ if (!UTHValidateDetectAddress(ad, expectations[have].one, expectations[have].two))
+ return false;
ad = ad->next;
have++;
}
- return TRUE;
+ return true;
}
static int AddressTestParse01(void)
if (gh != NULL) {
int r = DetectAddressParse(NULL, gh, "![192.168.0.0/16,!192.168.14.0/24]");
if (r == 1) {
- if (UTHValidateDetectAddressHead(gh, 3, expectations) == TRUE)
+ if (UTHValidateDetectAddressHead(gh, 3, expectations))
result = 1;
}
if (gh != NULL) {
int r = DetectAddressParse(NULL, gh, "[![192.168.0.0/16,!192.168.14.0/24]]");
if (r == 1) {
- if (UTHValidateDetectAddressHead(gh, 3, expectations) == TRUE)
+ if (UTHValidateDetectAddressHead(gh, 3, expectations))
result = 1;
}
if (gh != NULL) {
int r = DetectAddressParse(NULL, gh, "[![192.168.0.0/16,[!192.168.14.0/24]]]");
if (r == 1) {
- if (UTHValidateDetectAddressHead(gh, 3, expectations) == TRUE)
+ if (UTHValidateDetectAddressHead(gh, 3, expectations))
result = 1;
}
if (gh != NULL) {
int r = DetectAddressParse(NULL, gh, "[![192.168.0.0/16,![192.168.14.0/24]]]");
if (r == 1) {
- if (UTHValidateDetectAddressHead(gh, 3, expectations) == TRUE)
+ if (UTHValidateDetectAddressHead(gh, 3, expectations))
result = 1;
}
if (gh != NULL) {
int r = DetectAddressParse(NULL, gh, "[2001::/3]");
if (r == 0) {
- if (UTHValidateDetectAddressHead(gh, 1, expectations) == TRUE)
+ if (UTHValidateDetectAddressHead(gh, 1, expectations))
result = 1;
}
if (gh != NULL) {
int r = DetectAddressParse(NULL, gh, "[2001::/3,!3000::/5]");
if (r == 1) {
- if (UTHValidateDetectAddressHead(gh, 2, expectations) == TRUE)
+ if (UTHValidateDetectAddressHead(gh, 2, expectations))
result = 1;
}
if (gh != NULL) {
int r = DetectAddressParse(NULL, gh, "3ffe:ffff:7654:feda:1245:ba98:3210:4562/96");
if (r == 0) {
- if (UTHValidateDetectAddressHead(gh, 1, expectations) == TRUE)
+ if (UTHValidateDetectAddressHead(gh, 1, expectations))
result = 1;
}
if (gh != NULL) {
int r = DetectAddressParse(NULL, gh, "[![192.168.0.0/16,![192.168.1.0/24,192.168.3.0/24]]]");
if (r == 1) {
- if (UTHValidateDetectAddressHead(gh, 4, expectations) == TRUE)
+ if (UTHValidateDetectAddressHead(gh, 4, expectations))
result = 1;
}
if (gh != NULL) {
int r = DetectAddressParse(NULL, gh, "[![192.168.0.0/16,![192.168.1.0/24,192.168.3.0/24],!192.168.5.0/24]]");
if (r == 1) {
- if (UTHValidateDetectAddressHead(gh, 5, expectations) == TRUE)
+ if (UTHValidateDetectAddressHead(gh, 5, expectations))
result = 1;
}
if (gh != NULL) {
int r = DetectAddressParse(NULL, gh, "[192.168.0.0/16,![192.168.1.0/24,192.168.3.0/24],!192.168.5.0/24]");
if (r == 1) {
- if (UTHValidateDetectAddressHead(gh, 4, expectations) == TRUE)
+ if (UTHValidateDetectAddressHead(gh, 4, expectations))
result = 1;
}