48 static SCRadixUserData *SCRadixAllocSCRadixUserData(uint8_t netmask,
void *user)
57 user_data->
user = user;
88 if (
new == NULL || list == NULL) {
95 while (temp != NULL) {
96 if (new->netmask > temp->
netmask)
124 static SCRadixPrefix *SCRadixCreatePrefix(uint8_t *key_stream,
125 uint16_t key_bitlen,
void *user,
130 if (key_bitlen == 0 || (key_bitlen % 8 != 0)) {
131 SCLogError(
"Invalid argument bitlen - %d", key_bitlen);
135 if (key_stream == NULL) {
146 memcpy(prefix->
stream, key_stream, key_bitlen / 8);
147 prefix->
bitlen = key_bitlen;
149 prefix->
user_data = SCRadixAllocSCRadixUserData(netmask, user);
157 if (prefix != NULL) {
158 if (prefix->
stream != NULL) {
176 static void SCRadixAddNetmaskUserDataToPrefix(
SCRadixPrefix *prefix,
180 if (prefix == NULL || user == NULL) {
184 SCRadixAppendToSCRadixUserDataList(
185 SCRadixAllocSCRadixUserData(netmask, user), &prefix->
user_data);
196 static void SCRadixRemoveNetmaskUserDataFromPrefix(
SCRadixPrefix *prefix,
201 if (prefix == NULL) {
206 while (temp != NULL) {
207 if (temp->
netmask == netmask) {
213 SCRadixDeAllocSCRadixUserData(temp);
231 static int SCRadixPrefixContainNetmask(
SCRadixPrefix *prefix, uint8_t netmask)
235 if (prefix == NULL) {
241 while (user_data != NULL) {
242 if (user_data->
netmask == netmask)
244 user_data = user_data->
next;
263 if (prefix == NULL) {
269 while (user_data != NULL) {
271 user_data = user_data->
next;
290 static int SCRadixPrefixContainNetmaskAndSetUserData(
291 SCRadixPrefix *prefix, uint16_t netmask,
bool exact_match,
void **user_data_result)
295 if (prefix == NULL) {
304 if (user_data->
netmask == netmask) {
305 if (user_data_result)
306 *user_data_result = user_data->
user;
314 while (user_data != NULL) {
315 if (user_data->
netmask == netmask) {
316 if (user_data_result)
317 *user_data_result = user_data->
user;
320 user_data = user_data->
next;
324 if (user_data_result != NULL)
325 *user_data_result = NULL;
340 if (prefix != NULL) {
341 if (prefix->
stream != NULL)
345 if (tree->
Free != NULL) {
346 while (user_data_temp1 != NULL) {
347 user_data_temp2 = user_data_temp1;
348 user_data_temp1 = user_data_temp1->
next;
350 SCRadixDeAllocSCRadixUserData(user_data_temp2);
352 }
else if (user_data_temp1 != NULL) {
370 SCLogError(
"Fatal error encountered in SCRadixCreateNode. Mem not allocated...");
386 SCRadixReleasePrefix(node->
prefix, tree);
410 FatalError(
"Fatal error encountered in SCRadixCreateRadixTree. Exiting...");
429 SCRadixReleaseRadixSubtree(node->
left, tree);
430 SCRadixReleaseRadixSubtree(node->
right, tree);
431 SCRadixReleaseNode(node, tree);
445 SCRadixReleaseRadixSubtree(tree->
head, tree);
466 static SCRadixNode *SCRadixAddKeyInternal(uint8_t *key_stream, uint8_t key_bitlen,
467 SCRadixTree *tree,
void *user, uint8_t netmask,
bool exclusive)
476 uint8_t *stream = NULL;
479 uint16_t check_bit = 0;
480 uint16_t differ_bit = 0;
495 if (tree->
head == NULL) {
497 if ( (prefix = SCRadixCreatePrefix(key_stream, key_bitlen, user,
503 node = SCRadixCreateNode();
505 SCRadixReleasePrefix(prefix, tree);
512 if (netmask == 255 || (netmask == 32 && key_bitlen == 32) ||
513 (netmask == 128 && key_bitlen == 128)) {
528 sizeof(uint8_t)))) == NULL) {
531 SCLogError(
"Fatal error encountered in SCRadixAddKey. Mem not allocated");
548 while (node->
bit < bitlen || node->
prefix == NULL) {
553 if (bitlen <= node->bit) {
554 if (node->
right == NULL)
559 (0x80 >> (node->
bit % 8))) ) {
560 if (node->
right == NULL)
564 if (node->
left == NULL)
579 check_bit = (node->
bit < bitlen)? node->
bit: bitlen;
580 for (i = 0; (i * 8) < check_bit; i++) {
582 if ((temp = (stream[i] ^ bottom_node->
prefix->
stream[i])) == 0) {
583 differ_bit = (i + 1) * 8;
593 else if (temp >= 128)
608 differ_bit = i * 8 + j;
611 if (check_bit < differ_bit)
612 differ_bit = check_bit;
616 while (parent && differ_bit <= parent->bit) {
622 if (differ_bit == bitlen && node->
bit == bitlen) {
623 if (node->
prefix != NULL) {
625 if (SCRadixPrefixContainNetmask(node->
prefix, netmask)) {
629 SCLogDebug(
"not inserting since it already exists");
633 SCLogDebug(
"Duplicate entry for this ip address/netblock");
639 SCRadixAddNetmaskUserDataToPrefix(node->
prefix, netmask, user);
645 if (netmask == 255 || (netmask == 32 && bitlen == 32) || (netmask == 128 && bitlen == 128))
652 while (parent != NULL && netmask < (parent->
bit + 1)) {
661 sizeof(uint8_t)))) == NULL) {
664 SCLogError(
"Fatal error encountered in SCRadixAddKey. Mem not allocated...");
678 if (netmask < node->netmasks[i - 1]) {
688 node->
prefix = SCRadixCreatePrefix(key_stream, key_bitlen,
696 if ( (prefix = SCRadixCreatePrefix(key_stream, key_bitlen, user,
702 new_node = SCRadixCreateNode();
704 if (new_node == NULL) {
705 SCRadixReleasePrefix(prefix, tree);
710 new_node->
prefix = prefix;
717 if (differ_bit == bitlen) {
719 (0x80 >> (differ_bit % 8))) ) {
720 new_node->
right = node;
722 new_node->
left = node;
727 tree->
head = new_node;
739 inter_node = SCRadixCreateNode();
741 if (inter_node == NULL) {
742 SCRadixReleaseNode(new_node, tree);
747 inter_node->
prefix = NULL;
748 inter_node->
bit = differ_bit;
753 if (node->
netmasks[i] < differ_bit + 1)
757 if (i < node->netmask_cnt) {
759 sizeof(uint8_t))) == NULL) {
760 SCLogError(
"Fatal error encountered in SCRadixAddKey. Mem not allocated...");
761 SCRadixReleaseNode(inter_node, tree);
762 SCRadixReleaseNode(new_node, tree);
776 (0x80 >> (differ_bit % 8))) ) {
777 inter_node->
left = node;
778 inter_node->
right = new_node;
780 inter_node->
left = new_node;
781 inter_node->
right = node;
783 new_node->
parent = inter_node;
786 tree->
head = inter_node;
792 node->
parent = inter_node;
796 if (netmask != 255 && (netmask != 32 || (netmask == 32 && bitlen != 32)) && netmask != 128) {
798 parent = new_node->
parent;
799 while (parent != NULL && netmask < (parent->
bit + 1)) {
806 sizeof(uint8_t)))) == NULL) {
809 FatalError(
"Fatal error encountered in SCRadixAddKey. Exiting...");
821 if (netmask < node->netmasks[i - 1]) {
835 uint8_t *key_stream, uint8_t key_bitlen,
SCRadixTree *tree,
void *user, uint8_t netmask)
837 return SCRadixAddKeyInternal(key_stream, key_bitlen, tree, user, netmask,
true);
841 uint8_t *key_stream, uint8_t key_bitlen,
SCRadixTree *tree,
void *user, uint8_t netmask)
843 return SCRadixAddKeyInternal(key_stream, key_bitlen, tree, user, netmask,
false);
860 SCRadixNode *node = SCRadixAddKey(key_stream, 32, tree, user, 32);
879 SCRadixNode *node = SCRadixAddKey(key_stream, 128, tree, user, 128);
884 #if defined(DEBUG_VALIDATION) || defined(UNITTESTS)
885 static void SCRadixValidateIPv4Key(uint8_t *key,
const uint8_t netmask)
889 uint32_t mask =
CIDRGet(netmask);
891 uint32_t masked =
address & mask;
892 char ostr[16], nstr[16];
894 PrintInet(AF_INET, (
void *)&masked, nstr,
sizeof(nstr));
895 SCLogNotice(
"input %s/%u != expected %s/%u", ostr, netmask, nstr, netmask);
900 static void SCRadixValidateIPv6Key(uint8_t *key,
const uint8_t netmask)
906 memset(&mask, 0,
sizeof(mask));
907 struct in6_addr mask6;
909 memcpy(&mask, &mask6.s6_addr,
sizeof(mask));
912 masked[0] =
address[0] & mask[0];
913 masked[1] =
address[1] & mask[1];
914 masked[2] =
address[2] & mask[2];
915 masked[3] =
address[3] & mask[3];
917 if (memcmp(masked,
address,
sizeof(masked)) != 0) {
918 char ostr[64], nstr[64];
920 PrintInet(AF_INET6, (
void *)&masked, nstr,
sizeof(nstr));
921 SCLogNotice(
"input %s/%u != expected %s/%u", ostr, netmask, nstr, netmask);
940 void *user, uint8_t netmask)
942 #if defined(DEBUG_VALIDATION) || defined(UNITTESTS)
943 SCRadixValidateIPv4Key(key_stream, netmask);
945 SCRadixNode *node = SCRadixAddKey(key_stream, 32, tree, user, netmask);
963 void *user, uint8_t netmask)
965 #if defined(DEBUG_VALIDATION) || defined(UNITTESTS)
966 SCRadixValidateIPv6Key(key_stream, netmask);
968 SCRadixNode *node = SCRadixAddKey(key_stream, 128, tree, user, netmask);
991 uint8_t netmask = 32;
993 char *mask_str = NULL;
998 *(ip_str + (
sizeof(ip_str) - 1)) =
'\0';
1001 if (NULL != (mask_str = strchr(ip_str,
'/'))) {
1003 *(mask_str++) =
'\0';
1006 if (strchr(mask_str,
'.') != NULL) {
1017 netmask = (uint8_t)cidr;
1021 if (inet_pton(AF_INET, ip_str, &addr) <= 0) {
1026 if (netmask != 32) {
1027 uint32_t mask =
CIDRGet(netmask);
1028 uint32_t masked = ip & mask;
1031 PrintInet(AF_INET, (
void *)&masked, nstr,
sizeof(nstr));
1035 #if defined(DEBUG_VALIDATION) || defined(UNITTESTS)
1036 SCRadixValidateIPv4Key((uint8_t *)&ip, netmask);
1040 SCLogDebug(
"trying to add %s, but only if it doesn't exist", ip_str);
1042 if (SCRadixAddKeyExclusive((uint8_t *)&ip, 32, tree, user, netmask) == NULL) {
1065 uint8_t netmask = 128;
1067 char *mask_str = NULL;
1068 struct in6_addr addr;
1072 *(ip_str +
sizeof(ip_str) - 1) =
'\0';
1075 if (NULL != (mask_str = strchr(ip_str,
'/'))) {
1077 *(mask_str++) =
'\0';
1080 if (strchr(mask_str,
'.') != NULL) {
1091 netmask = (uint8_t)cidr;
1095 if (inet_pton(AF_INET6, ip_str, &addr) <= 0) {
1100 if (netmask != 128) {
1101 struct in6_addr mask6, check;
1103 memcpy(&check, &addr,
sizeof(check));
1105 for (
int i = 0; i < 16; i++) {
1106 addr.s6_addr[i] &= mask6.s6_addr[i];
1107 diff |= (addr.s6_addr[i] != check.s6_addr[i]);
1111 PrintInet(AF_INET6, (
void *)&addr.s6_addr, nstr,
sizeof(nstr));
1114 #if defined(DEBUG_VALIDATION) || defined(UNITTESTS)
1115 SCRadixValidateIPv6Key((uint8_t *)&addr.s6_addr, netmask);
1119 SCLogDebug(
"trying to add %s, but only if it doesn't exist",
str);
1121 if (SCRadixAddKeyExclusive(addr.s6_addr, 128, tree, user, netmask) == NULL) {
1134 if (
src == NULL || dest == NULL) {
1140 if (
src->netmasks == NULL)
1145 sizeof(uint8_t))) == NULL) {
1152 for (i = dest->
netmask_cnt, j = 0; j < src->netmask_cnt; i++, j++)
1165 static void SCRadixRemoveNetblockEntry(
SCRadixNode *node, uint8_t netmask)
1172 SCLogError(
"Invalid argument. Node is NULL");
1176 SCRadixRemoveNetmaskUserDataFromPrefix(node->
prefix, netmask);
1178 if (netmask == 32 || netmask == 128)
1182 while (parent != NULL && netmask < (parent->
bit + 1)) {
1192 SCLogDebug(
"Something's wrong with the tree. We are unable to find the "
1225 static void SCRadixRemoveKey(uint8_t *key_stream, uint16_t key_bitlen,
1240 if ( (prefix = SCRadixCreatePrefix(key_stream, key_bitlen, NULL, 255)) == NULL)
1245 (0x80 >> (node->
bit % 8))) ) {
1252 SCRadixReleasePrefix(prefix, tree);
1258 SCRadixReleasePrefix(prefix, tree);
1264 mask = UINT_MAX << (8 - prefix->
bitlen % 8);
1266 if (prefix->
bitlen % 8 == 0 ||
1268 if (!SCRadixPrefixContainNetmask(node->
prefix, netmask)) {
1269 SCLogDebug(
"The ip key exists in the Radix Tree, but this(%d) "
1270 "netblock entry doesn't exist", netmask);
1271 SCRadixReleasePrefix(prefix, tree);
1275 SCLogDebug(
"You are trying to remove a key that doesn't exist in "
1277 SCRadixReleasePrefix(prefix, tree);
1281 SCLogDebug(
"You are trying to remove a key that doesn't exist in the "
1283 SCRadixReleasePrefix(prefix, tree);
1291 if (SCRadixPrefixNetmaskCount(node->
prefix) > 1) {
1292 SCRadixRemoveNetblockEntry(node, netmask);
1293 SCRadixReleasePrefix(prefix, tree);
1299 if (tree->
head == node) {
1300 SCRadixReleaseNode(node, tree);
1302 SCRadixReleasePrefix(prefix, tree);
1308 if (parent->
parent != NULL) {
1311 temp_dest = parent->
right;
1315 temp_dest = parent->
left;
1321 temp_dest = parent->
right;
1325 temp_dest = parent->
left;
1332 if (parent->
left == node) {
1344 SCRadixTransferNetmasksBWNodes(temp_dest, parent);
1346 SCRadixReleaseNode(parent, tree);
1347 SCRadixReleaseNode(node, tree);
1348 SCRadixReleasePrefix(prefix, tree);
1362 #if defined(DEBUG_VALIDATION) || defined(UNITTESTS)
1363 SCRadixValidateIPv4Key(key_stream, netmask);
1365 SCRadixRemoveKey(key_stream, 32, tree, netmask);
1380 SCRadixRemoveKey(key_stream, 32, tree, 32);
1394 #if defined(DEBUG_VALIDATION) || defined(UNITTESTS)
1395 SCRadixValidateIPv6Key(key_stream, netmask);
1397 SCRadixRemoveKey(key_stream, 128, tree, netmask);
1412 SCRadixRemoveKey(key_stream, 128, tree, 128);
1422 static inline SCRadixNode *SCRadixFindKeyIPNetblock(
1423 uint8_t *key_stream, uint8_t key_bitlen,
SCRadixNode *node,
void **user_data_result)
1431 while (node != NULL && node->
netmasks == NULL)
1438 netmask_node = node;
1441 bytes = key_bitlen / 8;
1442 for (i = 0; i < bytes; i++) {
1444 if ( ((i + 1) * 8) > netmask_node->
netmasks[j]) {
1445 if ( ((i + 1) * 8 - netmask_node->
netmasks[j]) < 8)
1446 mask = UINT_MAX << ((i + 1) * 8 - netmask_node->
netmasks[j]);
1450 key_stream[i] &= mask;
1453 while (node->
bit < key_bitlen) {
1455 (0x80 >> (node->
bit % 8))) ) {
1465 if (node->
bit != key_bitlen || node->
prefix == NULL)
1469 mask = UINT_MAX << (8 - key_bitlen % 8);
1471 if (key_bitlen % 8 == 0 ||
1472 (node->
prefix->
stream[bytes] & mask) == (key_stream[bytes] & mask)) {
1473 if (SCRadixPrefixContainNetmaskAndSetUserData(
1474 node->
prefix, netmask_node->
netmasks[j],
false, user_data_result))
1480 return SCRadixFindKeyIPNetblock(key_stream, key_bitlen, netmask_node->
parent, user_data_result);
1493 static SCRadixNode *SCRadixFindKey(uint8_t *key_stream, uint8_t key_bitlen, uint8_t netmask,
1494 SCRadixTree *tree,
bool exact_match,
void **user_data_result)
1496 if (tree == NULL || tree->
head == NULL)
1502 uint8_t tmp_stream[255];
1504 memset(tmp_stream, 0, 255);
1505 memcpy(tmp_stream, key_stream, key_bitlen / 8);
1507 while (node->
bit < key_bitlen) {
1509 (0x80 >> (node->
bit % 8))) ) {
1520 if (node->
bit != key_bitlen || node->
prefix == NULL) {
1524 bytes = key_bitlen / 8;
1526 mask = UINT_MAX << (8 - key_bitlen % 8);
1528 if (key_bitlen % 8 == 0 ||
1529 (node->
prefix->
stream[bytes] & mask) == (tmp_stream[bytes] & mask)) {
1530 if (SCRadixPrefixContainNetmaskAndSetUserData(
1531 node->
prefix, netmask,
true, user_data_result)) {
1542 SCRadixNode *ret = SCRadixFindKeyIPNetblock(tmp_stream, key_bitlen, node, user_data_result);
1555 return SCRadixFindKey(key_stream, 32, 32, tree,
true, user_data_result);
1567 return SCRadixFindKey(key_stream, 32, 32, tree,
false, user_data_result);
1578 uint8_t netmask,
void **user_data_result)
1580 #if defined(DEBUG_VALIDATION) || defined(UNITTESTS)
1581 SCRadixValidateIPv4Key(key_stream, netmask);
1583 SCRadixNode *node = SCRadixFindKey(key_stream, 32, netmask, tree,
true, user_data_result);
1595 uint8_t netmask,
void **user_data_result)
1597 #if defined(DEBUG_VALIDATION) || defined(UNITTESTS)
1598 SCRadixValidateIPv6Key(key_stream, netmask);
1600 SCRadixNode *node = SCRadixFindKey(key_stream, 128, netmask, tree,
true, user_data_result);
1613 return SCRadixFindKey(key_stream, 128, 128, tree,
true, user_data_result);
1625 return SCRadixFindKey(key_stream, 128, 128, tree,
false, user_data_result);
1641 for (i = 0; i < level; i++)
1644 printf(
"%d [", node->
bit);
1650 printf(
"%s%d", (0 == i ?
"" :
", "), node->
netmasks[i]);
1654 if (node->
prefix != NULL) {
1656 printf(
"%s%d", (0 == i ?
"" :
"."), node->
prefix->
stream[i]);
1661 for (
int x = 0; x <= level; x++)
1664 if (PrintData != NULL) {
1665 PrintData(ud->
user);
1671 }
while (ud != NULL);
1673 printf(
"inter_node)\n");
1684 static void SCRadixPrintRadixSubtree(
SCRadixNode *node,
int level,
void (*PrintData)(
void*))
1688 SCRadixPrintRadixSubtree(node->
left, level + 1, PrintData);
1689 SCRadixPrintRadixSubtree(node->
right, level + 1, PrintData);
1713 printf(
"Printing the Radix Tree: \n");
1722 static int SCRadixTestIPV4Insertion03(
void)
1725 struct sockaddr_in servaddr;
1731 memset(&servaddr, 0,
sizeof(servaddr));
1732 if (inet_pton(AF_INET,
"192.168.1.1", &servaddr.sin_addr) <= 0)
1736 memset(&servaddr, 0,
sizeof(servaddr));
1737 if (inet_pton(AF_INET,
"192.168.1.2", &servaddr.sin_addr) <= 0)
1741 memset(&servaddr, 0,
sizeof(servaddr));
1742 if (inet_pton(AF_INET,
"192.167.1.3", &servaddr.sin_addr) <= 0)
1746 memset(&servaddr, 0,
sizeof(servaddr));
1747 if (inet_pton(AF_INET,
"192.167.1.4", &servaddr.sin_addr) <= 0)
1755 memset(&servaddr, 0,
sizeof(servaddr));
1756 if (inet_pton(AF_INET,
"192.168.1.6", &servaddr.sin_addr) <= 0)
1761 memset(&servaddr, 0,
sizeof(servaddr));
1762 if (inet_pton(AF_INET,
"192.167.1.4", &servaddr.sin_addr) <= 0)
1767 memset(&servaddr, 0,
sizeof(servaddr));
1768 if (inet_pton(AF_INET,
"220.168.1.2", &servaddr.sin_addr) <= 0)
1772 memset(&servaddr, 0,
sizeof(servaddr));
1773 if (inet_pton(AF_INET,
"192.168.1.5", &servaddr.sin_addr) <= 0)
1777 memset(&servaddr, 0,
sizeof(servaddr));
1778 if (inet_pton(AF_INET,
"192.168.1.18", &servaddr.sin_addr) <= 0)
1783 memset(&servaddr, 0,
sizeof(servaddr));
1784 if (inet_pton(AF_INET,
"192.168.1.3", &servaddr.sin_addr) <= 0)
1788 memset(&servaddr, 0,
sizeof(servaddr));
1789 if (inet_pton(AF_INET,
"127.234.2.62", &servaddr.sin_addr) <= 0)
1793 memset(&servaddr, 0,
sizeof(servaddr));
1794 if (inet_pton(AF_INET,
"192.168.1.1", &servaddr.sin_addr) <= 0)
1798 memset(&servaddr, 0,
sizeof(servaddr));
1799 if (inet_pton(AF_INET,
"192.168.1.5", &servaddr.sin_addr) <= 0)
1803 memset(&servaddr, 0,
sizeof(servaddr));
1804 if (inet_pton(AF_INET,
"192.168.1.2", &servaddr.sin_addr) <= 0)
1808 memset(&servaddr, 0,
sizeof(servaddr));
1809 if (inet_pton(AF_INET,
"192.167.1.3", &servaddr.sin_addr) <= 0)
1813 memset(&servaddr, 0,
sizeof(servaddr));
1814 if (inet_pton(AF_INET,
"192.167.1.4", &servaddr.sin_addr) <= 0)
1818 memset(&servaddr, 0,
sizeof(servaddr));
1819 if (inet_pton(AF_INET,
"220.168.1.2", &servaddr.sin_addr) <= 0)
1823 memset(&servaddr, 0,
sizeof(servaddr));
1824 if (inet_pton(AF_INET,
"192.168.1.18", &servaddr.sin_addr) <= 0)
1833 static int SCRadixTestIPV4Removal04(
void)
1836 struct sockaddr_in servaddr;
1842 memset(&servaddr, 0,
sizeof(servaddr));
1843 if (inet_pton(AF_INET,
"192.168.1.1", &servaddr.sin_addr) <= 0)
1847 memset(&servaddr, 0,
sizeof(servaddr));
1848 if (inet_pton(AF_INET,
"192.168.1.2", &servaddr.sin_addr) <= 0)
1852 memset(&servaddr, 0,
sizeof(servaddr));
1853 if (inet_pton(AF_INET,
"192.167.1.3", &servaddr.sin_addr) <= 0)
1857 memset(&servaddr, 0,
sizeof(servaddr));
1858 if (inet_pton(AF_INET,
"192.167.1.4", &servaddr.sin_addr) <= 0)
1862 memset(&servaddr, 0,
sizeof(servaddr));
1863 if (inet_pton(AF_INET,
"220.168.1.2", &servaddr.sin_addr) <= 0)
1867 memset(&servaddr, 0,
sizeof(servaddr));
1868 if (inet_pton(AF_INET,
"192.168.1.5", &servaddr.sin_addr) <= 0)
1872 memset(&servaddr, 0,
sizeof(servaddr));
1873 if (inet_pton(AF_INET,
"192.168.1.18", &servaddr.sin_addr) <= 0)
1878 memset(&servaddr, 0,
sizeof(servaddr));
1879 if (inet_pton(AF_INET,
"192.168.1.1", &servaddr.sin_addr) <= 0)
1883 memset(&servaddr, 0,
sizeof(servaddr));
1884 if (inet_pton(AF_INET,
"192.167.1.3", &servaddr.sin_addr) <= 0)
1888 memset(&servaddr, 0,
sizeof(servaddr));
1889 if (inet_pton(AF_INET,
"192.167.1.4", &servaddr.sin_addr) <= 0)
1893 memset(&servaddr, 0,
sizeof(servaddr));
1894 if (inet_pton(AF_INET,
"192.168.1.18", &servaddr.sin_addr) <= 0)
1898 memset(&servaddr, 0,
sizeof(servaddr));
1899 if (inet_pton(AF_INET,
"192.167.1.1", &servaddr.sin_addr) <= 0)
1903 memset(&servaddr, 0,
sizeof(servaddr));
1904 if (inet_pton(AF_INET,
"192.168.1.2", &servaddr.sin_addr) <= 0)
1908 memset(&servaddr, 0,
sizeof(servaddr));
1909 if (inet_pton(AF_INET,
"192.167.1.3", &servaddr.sin_addr) <= 0)
1913 memset(&servaddr, 0,
sizeof(servaddr));
1914 if (inet_pton(AF_INET,
"220.168.1.2", &servaddr.sin_addr) <= 0)
1918 memset(&servaddr, 0,
sizeof(servaddr));
1919 if (inet_pton(AF_INET,
"192.168.1.5", &servaddr.sin_addr) <= 0)
1923 memset(&servaddr, 0,
sizeof(servaddr));
1924 if (inet_pton(AF_INET,
"192.168.1.2", &servaddr.sin_addr) <= 0)
1928 memset(&servaddr, 0,
sizeof(servaddr));
1929 if (inet_pton(AF_INET,
"192.168.1.2", &servaddr.sin_addr) <= 0)
1933 memset(&servaddr, 0,
sizeof(servaddr));
1934 if (inet_pton(AF_INET,
"192.168.1.5", &servaddr.sin_addr) <= 0)
1938 result &= (tree->
head == NULL);
1945 static int SCRadixTestIPV6Insertion07(
void)
1948 struct sockaddr_in6 servaddr;
1954 memset(&servaddr, 0,
sizeof(servaddr));
1955 if (inet_pton(AF_INET6,
"2003:0BF1:5346:BDEA:7422:8713:9124:2315",
1956 &servaddr.sin6_addr) <= 0)
1960 memset(&servaddr, 0,
sizeof(servaddr));
1961 if (inet_pton(AF_INET6,
"BD15:9791:5346:6223:AADB:8713:9882:2432",
1962 &servaddr.sin6_addr) <= 0)
1966 memset(&servaddr, 0,
sizeof(servaddr));
1967 if (inet_pton(AF_INET6,
"1111:A21B:6221:BDEA:BBBA::DBAA:9861",
1968 &servaddr.sin6_addr) <= 0)
1972 memset(&servaddr, 0,
sizeof(servaddr));
1973 if (inet_pton(AF_INET6,
"4444:0BF7:5346:BDEA:7422:8713:9124:2315",
1974 &servaddr.sin6_addr) <= 0)
1981 memset(&servaddr, 0,
sizeof(servaddr));
1982 if (inet_pton(AF_INET6,
"5555:0BF1:ABCD:ADEA:7922:ABCD:9124:2375",
1983 &servaddr.sin6_addr) <= 0)
1987 memset(&servaddr, 0,
sizeof(servaddr));
1988 if (inet_pton(AF_INET6,
"DBCA:ABCD:ABCD:DBCA:1245:2342:1111:2212",
1989 &servaddr.sin6_addr) <= 0)
1993 memset(&servaddr, 0,
sizeof(servaddr));
1994 if (inet_pton(AF_INET6,
"2003:0BF1:5346:1251:7422:1112:9124:2315",
1995 &servaddr.sin6_addr) <= 0)
2000 memset(&servaddr, 0,
sizeof(servaddr));
2001 if (inet_pton(AF_INET6,
"2003:0BF1:5346:BDEA:7422:8713:9124:2315",
2002 &servaddr.sin6_addr) <= 0)
2006 memset(&servaddr, 0,
sizeof(servaddr));
2007 if (inet_pton(AF_INET6,
"BD15:9791:5346:6223:AADB:8713:9882:2432",
2008 &servaddr.sin6_addr) <= 0)
2012 memset(&servaddr, 0,
sizeof(servaddr));
2013 if (inet_pton(AF_INET6,
"1111:A21B:6221:BDEA:BBBA::DBAA:9861",
2014 &servaddr.sin6_addr) <= 0)
2018 memset(&servaddr, 0,
sizeof(servaddr));
2019 if (inet_pton(AF_INET6,
"4444:0BF7:5346:BDEA:7422:8713:9124:2315",
2020 &servaddr.sin6_addr) <= 0)
2024 memset(&servaddr, 0,
sizeof(servaddr));
2025 if (inet_pton(AF_INET6,
"DBCA:ABC2:ABCD:DBCA:1245:2342:1111:2212",
2026 &servaddr.sin6_addr) <= 0)
2030 memset(&servaddr, 0,
sizeof(servaddr));
2031 if (inet_pton(AF_INET6,
"2003:0BF5:5346:1251:7422:1112:9124:2315",
2032 &servaddr.sin6_addr) <= 0)
2036 memset(&servaddr, 0,
sizeof(servaddr));
2037 if (inet_pton(AF_INET6,
"5555:0BF1:ABCD:ADEA:7922:ABCD:9124:2375",
2038 &servaddr.sin6_addr) <= 0)
2042 memset(&servaddr, 0,
sizeof(servaddr));
2043 if (inet_pton(AF_INET6,
"DBCA:ABCD:ABCD:DBCA:1245:2342:1111:2212",
2044 &servaddr.sin6_addr) <= 0)
2048 memset(&servaddr, 0,
sizeof(servaddr));
2049 if (inet_pton(AF_INET6,
"2003:0BF1:5346:1251:7422:1112:9124:2315",
2050 &servaddr.sin6_addr) <= 0)
2059 static int SCRadixTestIPV6Removal08(
void)
2062 struct sockaddr_in6 servaddr;
2068 memset(&servaddr, 0,
sizeof(servaddr));
2069 if (inet_pton(AF_INET6,
"2003:0BF1:5346:BDEA:7422:8713:9124:2315",
2070 &servaddr.sin6_addr) <= 0)
2074 memset(&servaddr, 0,
sizeof(servaddr));
2075 if (inet_pton(AF_INET6,
"BD15:9791:5346:6223:AADB:8713:9882:2432",
2076 &servaddr.sin6_addr) <= 0)
2080 memset(&servaddr, 0,
sizeof(servaddr));
2081 if (inet_pton(AF_INET6,
"1111:A21B:6221:BDEA:BBBA::DBAA:9861",
2082 &servaddr.sin6_addr) <= 0)
2086 memset(&servaddr, 0,
sizeof(servaddr));
2087 if (inet_pton(AF_INET6,
"4444:0BF7:5346:BDEA:7422:8713:9124:2315",
2088 &servaddr.sin6_addr) <= 0)
2095 memset(&servaddr, 0,
sizeof(servaddr));
2096 if (inet_pton(AF_INET6,
"5555:0BF1:ABCD:ADEA:7922:ABCD:9124:2375",
2097 &servaddr.sin6_addr) <= 0)
2101 memset(&servaddr, 0,
sizeof(servaddr));
2102 if (inet_pton(AF_INET6,
"DBCA:ABCD:ABCD:DBCA:1245:2342:1111:2212",
2103 &servaddr.sin6_addr) <= 0)
2107 memset(&servaddr, 0,
sizeof(servaddr));
2108 if (inet_pton(AF_INET6,
"2003:0BF1:5346:1251:7422:1112:9124:2315",
2109 &servaddr.sin6_addr) <= 0)
2114 memset(&servaddr, 0,
sizeof(servaddr));
2115 if (inet_pton(AF_INET6,
"2003:0BF1:5346:BDEA:7422:8713:9124:2315",
2116 &servaddr.sin6_addr) <= 0)
2120 memset(&servaddr, 0,
sizeof(servaddr));
2121 if (inet_pton(AF_INET6,
"8888:0BF1:5346:BDEA:6422:8713:9124:2315",
2122 &servaddr.sin6_addr) <= 0)
2126 memset(&servaddr, 0,
sizeof(servaddr));
2127 if (inet_pton(AF_INET6,
"2006:0BF1:5346:BDEA:7422:8713:9124:2315",
2128 &servaddr.sin6_addr) <= 0)
2132 memset(&servaddr, 0,
sizeof(servaddr));
2133 if (inet_pton(AF_INET6,
"2003:0BF1:5346:BDEA:7422:8713:9124:2315",
2134 &servaddr.sin6_addr) <= 0)
2138 memset(&servaddr, 0,
sizeof(servaddr));
2139 if (inet_pton(AF_INET6,
"BD15:9791:5346:6223:AADB:8713:9882:2432",
2140 &servaddr.sin6_addr) <= 0)
2145 memset(&servaddr, 0,
sizeof(servaddr));
2146 if (inet_pton(AF_INET6,
"1111:A21B:6221:BDEA:BBBA::DBAA:9861",
2147 &servaddr.sin6_addr) <= 0)
2151 memset(&servaddr, 0,
sizeof(servaddr));
2152 if (inet_pton(AF_INET6,
"4444:0BF7:5346:BDEA:7422:8713:9124:2315",
2153 &servaddr.sin6_addr) <= 0)
2157 memset(&servaddr, 0,
sizeof(servaddr));
2158 if (inet_pton(AF_INET6,
"5555:0BF1:ABCD:ADEA:7922:ABCD:9124:2375",
2159 &servaddr.sin6_addr) <= 0)
2163 memset(&servaddr, 0,
sizeof(servaddr));
2164 if (inet_pton(AF_INET6,
"DBCA:ABCD:ABCD:DBCA:1245:2342:1111:2212",
2165 &servaddr.sin6_addr) <= 0)
2169 memset(&servaddr, 0,
sizeof(servaddr));
2170 if (inet_pton(AF_INET6,
"2003:0BF1:5346:1251:7422:1112:9124:2315",
2171 &servaddr.sin6_addr) <= 0)
2175 memset(&servaddr, 0,
sizeof(servaddr));
2176 if (inet_pton(AF_INET6,
"2003:0BF1:5346:BDEA:7422:8713:DDDD:2315",
2177 &servaddr.sin6_addr) <= 0)
2182 memset(&servaddr, 0,
sizeof(servaddr));
2183 if (inet_pton(AF_INET6,
"2003:0BF1:5346:BDEA:7422:8713:9124:2315",
2184 &servaddr.sin6_addr) <= 0)
2188 memset(&servaddr, 0,
sizeof(servaddr));
2189 if (inet_pton(AF_INET6,
"BD15:9791:5346:6223:AADB:8713:9882:2432",
2190 &servaddr.sin6_addr) <= 0)
2195 memset(&servaddr, 0,
sizeof(servaddr));
2196 if (inet_pton(AF_INET6,
"2003:0BF1:5346:BDEA:7422:8713:9124:2315",
2197 &servaddr.sin6_addr) <= 0)
2201 memset(&servaddr, 0,
sizeof(servaddr));
2202 if (inet_pton(AF_INET6,
"BD15:9791:5346:6223:AADB:8713:9882:2432",
2203 &servaddr.sin6_addr) <= 0)
2207 memset(&servaddr, 0,
sizeof(servaddr));
2208 if (inet_pton(AF_INET6,
"1111:A21B:6221:BDEA:BBBA::DBAA:9861",
2209 &servaddr.sin6_addr) <= 0)
2213 memset(&servaddr, 0,
sizeof(servaddr));
2214 if (inet_pton(AF_INET6,
"4444:0BF7:5346:BDEA:7422:8713:9124:2315",
2215 &servaddr.sin6_addr) <= 0)
2219 memset(&servaddr, 0,
sizeof(servaddr));
2220 if (inet_pton(AF_INET6,
"5555:0BF1:ABCD:ADEA:7922:ABCD:9124:2375",
2221 &servaddr.sin6_addr) <= 0)
2225 memset(&servaddr, 0,
sizeof(servaddr));
2226 if (inet_pton(AF_INET6,
"DBCA:ABCD:ABCD:DBCA:1245:2342:1111:2212",
2227 &servaddr.sin6_addr) <= 0)
2232 memset(&servaddr, 0,
sizeof(servaddr));
2233 if (inet_pton(AF_INET6,
"1111:A21B:6221:BDEA:BBBA::DBAA:9861",
2234 &servaddr.sin6_addr) <= 0)
2238 memset(&servaddr, 0,
sizeof(servaddr));
2239 if (inet_pton(AF_INET6,
"4444:0BF7:5346:BDEA:7422:8713:9124:2315",
2240 &servaddr.sin6_addr) <= 0)
2244 memset(&servaddr, 0,
sizeof(servaddr));
2245 if (inet_pton(AF_INET6,
"5555:0BF1:ABCD:ADEA:7922:ABCD:9124:2375",
2246 &servaddr.sin6_addr) <= 0)
2250 memset(&servaddr, 0,
sizeof(servaddr));
2251 if (inet_pton(AF_INET6,
"DBCA:ABCD:ABCD:DBCA:1245:2342:1111:2212",
2252 &servaddr.sin6_addr) <= 0)
2257 memset(&servaddr, 0,
sizeof(servaddr));
2258 if (inet_pton(AF_INET6,
"2003:0BF1:5346:BDEA:7422:8713:9124:2315",
2259 &servaddr.sin6_addr) <= 0)
2263 memset(&servaddr, 0,
sizeof(servaddr));
2264 if (inet_pton(AF_INET6,
"BD15:9791:5346:6223:AADB:8713:9882:2432",
2265 &servaddr.sin6_addr) <= 0)
2269 memset(&servaddr, 0,
sizeof(servaddr));
2270 if (inet_pton(AF_INET6,
"1111:A21B:6221:BDEA:BBBA::DBAA:9861",
2271 &servaddr.sin6_addr) <= 0)
2275 memset(&servaddr, 0,
sizeof(servaddr));
2276 if (inet_pton(AF_INET6,
"4444:0BF7:5346:BDEA:7422:8713:9124:2315",
2277 &servaddr.sin6_addr) <= 0)
2281 memset(&servaddr, 0,
sizeof(servaddr));
2282 if (inet_pton(AF_INET6,
"5555:0BF1:ABCD:ADEA:7922:ABCD:9124:2375",
2283 &servaddr.sin6_addr) <= 0)
2287 memset(&servaddr, 0,
sizeof(servaddr));
2288 if (inet_pton(AF_INET6,
"DBCA:ABCD:ABCD:DBCA:1245:2342:1111:2212",
2289 &servaddr.sin6_addr) <= 0)
2308 static int SCRadixTestIPV4Bug5066(
void)
2310 struct sockaddr_in servaddr;
2316 memset(&servaddr, 0,
sizeof(servaddr));
2317 FAIL_IF(inet_pton(AF_INET,
"100.117.241.0", &servaddr.sin_addr) <= 0);
2328 FAIL_IF(inet_pton(AF_INET,
"100.117.241.0", &servaddr.sin_addr) <= 0);
2336 SCLogDebug(
"find 100.117.241.64/26 (should fail)");
2337 FAIL_IF(inet_pton(AF_INET,
"100.117.241.64", &servaddr.sin_addr) <= 0);
2344 SCLogDebug(
"find 100.117.241.64/26 (should succeed)");
2355 static void SCRadixTestIPV4Bug5066v2PrintData(
void *d)
2361 static int SCRadixTestIPV4Bug5066v2(
void)
2363 struct sockaddr_in servaddr;
2369 memset(&servaddr, 0,
sizeof(servaddr));
2370 FAIL_IF(inet_pton(AF_INET,
"1.2.3.0", &servaddr.sin_addr) <= 0);
2380 memset(&servaddr, 0,
sizeof(servaddr));
2381 FAIL_IF(inet_pton(AF_INET,
"1.2.3.0", &servaddr.sin_addr) <= 0);
2391 memset(&servaddr, 0,
sizeof(servaddr));
2392 FAIL_IF(inet_pton(AF_INET,
"1.2.3.0", &servaddr.sin_addr) <= 0);
2402 memset(&servaddr, 0,
sizeof(servaddr));
2403 FAIL_IF(inet_pton(AF_INET,
"1.2.3.64", &servaddr.sin_addr) <= 0);
2413 memset(&servaddr, 0,
sizeof(servaddr));
2414 FAIL_IF(inet_pton(AF_INET,
"1.2.3.64", &servaddr.sin_addr) <= 0);
2424 memset(&servaddr, 0,
sizeof(servaddr));
2425 FAIL_IF(inet_pton(AF_INET,
"1.2.3.96", &servaddr.sin_addr) <= 0);
2442 static int SCRadixTestIPV6Bug5066(
void)
2444 struct sockaddr_in6 servaddr;
2450 memset(&servaddr, 0,
sizeof(servaddr));
2451 FAIL_IF(inet_pton(AF_INET6,
"2000::1:0", &servaddr.sin6_addr) <= 0);
2462 FAIL_IF(inet_pton(AF_INET6,
"2000::1:0", &servaddr.sin6_addr) <= 0);
2470 SCLogDebug(
"find 2000::1:40/122 (should fail)");
2471 FAIL_IF(inet_pton(AF_INET6,
"2000::1:40", &servaddr.sin6_addr) <= 0);
2478 SCLogDebug(
"find 2000::1:40/122 (should succeed)");
2489 static int SCRadixTestIPV4NetblockInsertion09(
void)
2492 struct sockaddr_in servaddr;
2498 memset(&servaddr, 0,
sizeof(servaddr));
2499 if (inet_pton(AF_INET,
"192.168.1.1", &servaddr.sin_addr) <= 0)
2503 memset(&servaddr, 0,
sizeof(servaddr));
2504 if (inet_pton(AF_INET,
"192.168.1.2", &servaddr.sin_addr) <= 0)
2508 memset(&servaddr, 0,
sizeof(servaddr));
2509 if (inet_pton(AF_INET,
"192.167.1.3", &servaddr.sin_addr) <= 0)
2513 memset(&servaddr, 0,
sizeof(servaddr));
2514 if (inet_pton(AF_INET,
"192.167.1.4", &servaddr.sin_addr) <= 0)
2518 memset(&servaddr, 0,
sizeof(servaddr));
2519 if (inet_pton(AF_INET,
"220.168.1.2", &servaddr.sin_addr) <= 0)
2523 memset(&servaddr, 0,
sizeof(servaddr));
2524 if (inet_pton(AF_INET,
"192.168.1.5", &servaddr.sin_addr) <= 0)
2528 memset(&servaddr, 0,
sizeof(servaddr));
2529 if (inet_pton(AF_INET,
"192.168.1.18", &servaddr.sin_addr) <= 0)
2533 memset(&servaddr, 0,
sizeof(servaddr));
2534 if (inet_pton(AF_INET,
"192.168.0.0", &servaddr.sin_addr) <= 0)
2538 memset(&servaddr, 0,
sizeof(servaddr));
2539 if (inet_pton(AF_INET,
"192.171.128.0", &servaddr.sin_addr) <= 0)
2543 memset(&servaddr, 0,
sizeof(servaddr));
2544 if (inet_pton(AF_INET,
"192.171.192.0", &servaddr.sin_addr) <= 0)
2548 if (inet_pton(AF_INET,
"192.175.0.0", &servaddr.sin_addr) <= 0)
2553 memset(&servaddr, 0,
sizeof(servaddr));
2554 if (inet_pton(AF_INET,
"192.168.1.6", &servaddr.sin_addr) <= 0)
2558 memset(&servaddr, 0,
sizeof(servaddr));
2559 if (inet_pton(AF_INET,
"192.170.1.6", &servaddr.sin_addr) <= 0)
2563 memset(&servaddr, 0,
sizeof(servaddr));
2564 if (inet_pton(AF_INET,
"192.171.128.145", &servaddr.sin_addr) <= 0)
2568 memset(&servaddr, 0,
sizeof(servaddr));
2569 if (inet_pton(AF_INET,
"192.171.64.6", &servaddr.sin_addr) <= 0)
2573 memset(&servaddr, 0,
sizeof(servaddr));
2574 if (inet_pton(AF_INET,
"192.171.191.6", &servaddr.sin_addr) <= 0)
2578 memset(&servaddr, 0,
sizeof(servaddr));
2579 if (inet_pton(AF_INET,
"192.171.224.6", &servaddr.sin_addr) <= 0)
2583 memset(&servaddr, 0,
sizeof(servaddr));
2584 if (inet_pton(AF_INET,
"192.174.224.6", &servaddr.sin_addr) <= 0)
2588 memset(&servaddr, 0,
sizeof(servaddr));
2589 if (inet_pton(AF_INET,
"192.175.224.6", &servaddr.sin_addr) <= 0)
2598 static int SCRadixTestIPV4NetblockInsertion10(
void)
2602 struct sockaddr_in servaddr;
2607 memset(&servaddr, 0,
sizeof(servaddr));
2608 if (inet_pton(AF_INET,
"253.192.0.0", &servaddr.sin_addr) <= 0)
2612 memset(&servaddr, 0,
sizeof(servaddr));
2613 if (inet_pton(AF_INET,
"253.192.235.0", &servaddr.sin_addr) <= 0)
2617 memset(&servaddr, 0,
sizeof(servaddr));
2618 if (inet_pton(AF_INET,
"192.167.0.0", &servaddr.sin_addr) <= 0)
2622 memset(&servaddr, 0,
sizeof(servaddr));
2623 if (inet_pton(AF_INET,
"192.167.1.4", &servaddr.sin_addr) <= 0)
2627 memset(&servaddr, 0,
sizeof(servaddr));
2628 if (inet_pton(AF_INET,
"220.168.0.0", &servaddr.sin_addr) <= 0)
2632 memset(&servaddr, 0,
sizeof(servaddr));
2633 if (inet_pton(AF_INET,
"253.224.1.5", &servaddr.sin_addr) <= 0)
2637 memset(&servaddr, 0,
sizeof(servaddr));
2638 if (inet_pton(AF_INET,
"192.168.0.0", &servaddr.sin_addr) <= 0)
2642 memset(&servaddr, 0,
sizeof(servaddr));
2643 if (inet_pton(AF_INET,
"192.171.128.0", &servaddr.sin_addr) <= 0)
2647 memset(&servaddr, 0,
sizeof(servaddr));
2648 if (inet_pton(AF_INET,
"192.171.128.45", &servaddr.sin_addr) <= 0)
2652 memset(&servaddr, 0,
sizeof(servaddr));
2653 if (inet_pton(AF_INET,
"192.171.0.0", &servaddr.sin_addr) <= 0)
2657 if (inet_pton(AF_INET,
"192.175.0.0", &servaddr.sin_addr) <= 0)
2664 memset(&servaddr, 0,
sizeof(servaddr));
2665 if (inet_pton(AF_INET,
"192.171.128.53", &servaddr.sin_addr) <= 0)
2670 SCLogDebug(
"search \"exact\" match for 192.171.128.45");
2671 memset(&servaddr, 0,
sizeof(servaddr));
2672 if (inet_pton(AF_INET,
"192.171.128.45", &servaddr.sin_addr) <= 0)
2677 SCLogDebug(
"search \"best\" match for 192.171.128.45");
2678 memset(&servaddr, 0,
sizeof(servaddr));
2679 if (inet_pton(AF_INET,
"192.171.128.45", &servaddr.sin_addr) <= 0)
2684 memset(&servaddr, 0,
sizeof(servaddr));
2685 if (inet_pton(AF_INET,
"192.171.128.78", &servaddr.sin_addr) <= 0)
2691 memset(&servaddr, 0,
sizeof(servaddr));
2692 if (inet_pton(AF_INET,
"192.171.128.0", &servaddr.sin_addr) <= 0)
2696 memset(&servaddr, 0,
sizeof(servaddr));
2697 if (inet_pton(AF_INET,
"192.171.128.78", &servaddr.sin_addr) <= 0)
2702 memset(&servaddr, 0,
sizeof(servaddr));
2703 if (inet_pton(AF_INET,
"192.171.127.78", &servaddr.sin_addr) <= 0)
2712 static int SCRadixTestIPV4NetblockInsertion11(
void)
2716 struct sockaddr_in servaddr;
2722 memset(&servaddr, 0,
sizeof(servaddr));
2723 if (inet_pton(AF_INET,
"253.192.0.0", &servaddr.sin_addr) <= 0)
2727 memset(&servaddr, 0,
sizeof(servaddr));
2728 if (inet_pton(AF_INET,
"253.192.235.0", &servaddr.sin_addr) <= 0)
2732 memset(&servaddr, 0,
sizeof(servaddr));
2733 if (inet_pton(AF_INET,
"192.167.0.0", &servaddr.sin_addr) <= 0)
2737 memset(&servaddr, 0,
sizeof(servaddr));
2738 if (inet_pton(AF_INET,
"192.167.1.4", &servaddr.sin_addr) <= 0)
2742 memset(&servaddr, 0,
sizeof(servaddr));
2743 if (inet_pton(AF_INET,
"220.168.0.0", &servaddr.sin_addr) <= 0)
2747 memset(&servaddr, 0,
sizeof(servaddr));
2748 if (inet_pton(AF_INET,
"253.224.1.5", &servaddr.sin_addr) <= 0)
2752 memset(&servaddr, 0,
sizeof(servaddr));
2753 if (inet_pton(AF_INET,
"192.168.0.0", &servaddr.sin_addr) <= 0)
2757 memset(&servaddr, 0,
sizeof(servaddr));
2758 if (inet_pton(AF_INET,
"192.171.128.0", &servaddr.sin_addr) <= 0)
2762 memset(&servaddr, 0,
sizeof(servaddr));
2763 if (inet_pton(AF_INET,
"192.171.128.45", &servaddr.sin_addr) <= 0)
2767 memset(&servaddr, 0,
sizeof(servaddr));
2768 if (inet_pton(AF_INET,
"192.171.0.0", &servaddr.sin_addr) <= 0)
2772 if (inet_pton(AF_INET,
"192.175.0.0", &servaddr.sin_addr) <= 0)
2776 if (inet_pton(AF_INET,
"0.0.0.0", &servaddr.sin_addr) <= 0)
2781 memset(&servaddr, 0,
sizeof(servaddr));
2782 if (inet_pton(AF_INET,
"192.171.128.53", &servaddr.sin_addr) <= 0)
2786 memset(&servaddr, 0,
sizeof(servaddr));
2787 if (inet_pton(AF_INET,
"192.171.128.45", &servaddr.sin_addr) <= 0)
2791 memset(&servaddr, 0,
sizeof(servaddr));
2792 if (inet_pton(AF_INET,
"192.171.128.78", &servaddr.sin_addr) <= 0)
2796 memset(&servaddr, 0,
sizeof(servaddr));
2797 if (inet_pton(AF_INET,
"192.171.127.78", &servaddr.sin_addr) <= 0)
2801 memset(&servaddr, 0,
sizeof(servaddr));
2802 if (inet_pton(AF_INET,
"1.1.1.1", &servaddr.sin_addr) <= 0)
2806 memset(&servaddr, 0,
sizeof(servaddr));
2807 if (inet_pton(AF_INET,
"192.255.254.25", &servaddr.sin_addr) <= 0)
2811 memset(&servaddr, 0,
sizeof(servaddr));
2812 if (inet_pton(AF_INET,
"169.255.254.25", &servaddr.sin_addr) <= 0)
2816 memset(&servaddr, 0,
sizeof(servaddr));
2817 if (inet_pton(AF_INET,
"0.0.0.0", &servaddr.sin_addr) <= 0)
2821 memset(&servaddr, 0,
sizeof(servaddr));
2822 if (inet_pton(AF_INET,
"253.224.1.5", &servaddr.sin_addr) <= 0)
2827 memset(&servaddr, 0,
sizeof(servaddr));
2828 if (inet_pton(AF_INET,
"245.63.62.121", &servaddr.sin_addr) <= 0)
2833 memset(&servaddr, 0,
sizeof(servaddr));
2834 if (inet_pton(AF_INET,
"253.224.1.6", &servaddr.sin_addr) <= 0)
2840 memset(&servaddr, 0,
sizeof(servaddr));
2841 if (inet_pton(AF_INET,
"0.0.0.0", &servaddr.sin_addr) <= 0)
2845 memset(&servaddr, 0,
sizeof(servaddr));
2846 if (inet_pton(AF_INET,
"253.224.1.6", &servaddr.sin_addr) <= 0)
2850 memset(&servaddr, 0,
sizeof(servaddr));
2851 if (inet_pton(AF_INET,
"192.171.127.78", &servaddr.sin_addr) <= 0)
2855 memset(&servaddr, 0,
sizeof(servaddr));
2856 if (inet_pton(AF_INET,
"1.1.1.1", &servaddr.sin_addr) <= 0)
2860 memset(&servaddr, 0,
sizeof(servaddr));
2861 if (inet_pton(AF_INET,
"192.255.254.25", &servaddr.sin_addr) <= 0)
2865 memset(&servaddr, 0,
sizeof(servaddr));
2866 if (inet_pton(AF_INET,
"169.255.254.25", &servaddr.sin_addr) <= 0)
2870 memset(&servaddr, 0,
sizeof(servaddr));
2871 if (inet_pton(AF_INET,
"0.0.0.0", &servaddr.sin_addr) <= 0)
2880 static int SCRadixTestIPV4NetblockInsertion12(
void)
2884 struct sockaddr_in servaddr;
2890 memset(&servaddr, 0,
sizeof(servaddr));
2891 if (inet_pton(AF_INET,
"253.192.0.0", &servaddr.sin_addr) <= 0)
2895 memset(&servaddr, 0,
sizeof(servaddr));
2896 if (inet_pton(AF_INET,
"253.192.235.0", &servaddr.sin_addr) <= 0)
2900 memset(&servaddr, 0,
sizeof(servaddr));
2901 if (inet_pton(AF_INET,
"192.167.0.0", &servaddr.sin_addr) <= 0)
2905 memset(&servaddr, 0,
sizeof(servaddr));
2906 if (inet_pton(AF_INET,
"192.167.1.4", &servaddr.sin_addr) <= 0)
2910 memset(&servaddr, 0,
sizeof(servaddr));
2911 if (inet_pton(AF_INET,
"220.168.0.0", &servaddr.sin_addr) <= 0)
2915 memset(&servaddr, 0,
sizeof(servaddr));
2916 if (inet_pton(AF_INET,
"253.224.1.5", &servaddr.sin_addr) <= 0)
2920 memset(&servaddr, 0,
sizeof(servaddr));
2921 if (inet_pton(AF_INET,
"192.168.0.0", &servaddr.sin_addr) <= 0)
2925 memset(&servaddr, 0,
sizeof(servaddr));
2926 if (inet_pton(AF_INET,
"192.171.128.0", &servaddr.sin_addr) <= 0)
2930 memset(&servaddr, 0,
sizeof(servaddr));
2931 if (inet_pton(AF_INET,
"192.171.128.45", &servaddr.sin_addr) <= 0)
2935 memset(&servaddr, 0,
sizeof(servaddr));
2936 if (inet_pton(AF_INET,
"192.171.0.0", &servaddr.sin_addr) <= 0)
2940 if (inet_pton(AF_INET,
"225.175.21.228", &servaddr.sin_addr) <= 0)
2945 memset(&servaddr, 0,
sizeof(servaddr));
2946 if (inet_pton(AF_INET,
"192.171.128.53", &servaddr.sin_addr) <= 0)
2950 memset(&servaddr, 0,
sizeof(servaddr));
2951 if (inet_pton(AF_INET,
"192.171.128.53", &servaddr.sin_addr) <= 0)
2955 memset(&servaddr, 0,
sizeof(servaddr));
2956 if (inet_pton(AF_INET,
"192.171.128.45", &servaddr.sin_addr) <= 0)
2960 memset(&servaddr, 0,
sizeof(servaddr));
2961 if (inet_pton(AF_INET,
"192.171.128.45", &servaddr.sin_addr) <= 0)
2965 memset(&servaddr, 0,
sizeof(servaddr));
2966 if (inet_pton(AF_INET,
"192.171.128.45", &servaddr.sin_addr) <= 0)
2970 memset(&servaddr, 0,
sizeof(servaddr));
2971 if (inet_pton(AF_INET,
"192.171.128.78", &servaddr.sin_addr) <= 0)
2975 memset(&servaddr, 0,
sizeof(servaddr));
2976 if (inet_pton(AF_INET,
"192.171.127.78", &servaddr.sin_addr) <= 0)
2980 memset(&servaddr, 0,
sizeof(servaddr));
2981 if (inet_pton(AF_INET,
"225.175.21.228", &servaddr.sin_addr) <= 0)
2985 memset(&servaddr, 0,
sizeof(servaddr));
2986 if (inet_pton(AF_INET,
"225.175.21.224", &servaddr.sin_addr) <= 0)
2990 memset(&servaddr, 0,
sizeof(servaddr));
2991 if (inet_pton(AF_INET,
"225.175.21.229", &servaddr.sin_addr) <= 0)
2995 memset(&servaddr, 0,
sizeof(servaddr));
2996 if (inet_pton(AF_INET,
"225.175.21.230", &servaddr.sin_addr) <= 0)
3005 static int SCRadixTestIPV6NetblockInsertion13(
void)
3008 struct sockaddr_in6 servaddr;
3014 memset(&servaddr, 0,
sizeof(servaddr));
3015 if (inet_pton(AF_INET6,
"2003:0BF1:5346:BDEA:7422:8713:9124:2315",
3016 &servaddr.sin6_addr) <= 0)
3020 memset(&servaddr, 0,
sizeof(servaddr));
3021 if (inet_pton(AF_INET6,
"BD15:9791:5346:6223:AADB:8713:9882:2432",
3022 &servaddr.sin6_addr) <= 0)
3026 memset(&servaddr, 0,
sizeof(servaddr));
3027 if (inet_pton(AF_INET6,
"1111:A21B:6221:BDEA:BBBA::DBAA:9861",
3028 &servaddr.sin6_addr) <= 0)
3032 memset(&servaddr, 0,
sizeof(servaddr));
3033 if (inet_pton(AF_INET6,
"4444:0BF7:5346:BDEA:7422:8713:9124:2315",
3034 &servaddr.sin6_addr) <= 0)
3038 memset(&servaddr, 0,
sizeof(servaddr));
3039 if (inet_pton(AF_INET6,
"5555:0BF1:ABCD:ADEA:7922:ABCD:9124:2375",
3040 &servaddr.sin6_addr) <= 0)
3044 memset(&servaddr, 0,
sizeof(servaddr));
3045 if (inet_pton(AF_INET6,
"DBCA:ABCD:ABCD:DB00:0000:0000:0000:0000",
3046 &servaddr.sin6_addr) <= 0)
3050 memset(&servaddr, 0,
sizeof(servaddr));
3051 if (inet_pton(AF_INET6,
"DBCA:ABCD:ABCD:DBAA:1245:2342:1145:6241",
3052 &servaddr.sin6_addr) <= 0)
3057 memset(&servaddr, 0,
sizeof(servaddr));
3058 if (inet_pton(AF_INET6,
"2003:0BF1:5346:BDEA:7422:8713:9124:2315",
3059 &servaddr.sin6_addr) <= 0)
3063 memset(&servaddr, 0,
sizeof(servaddr));
3064 if (inet_pton(AF_INET6,
"BD15:9791:5346:6223:AADB:8713:9882:2432",
3065 &servaddr.sin6_addr) <= 0)
3069 memset(&servaddr, 0,
sizeof(servaddr));
3070 if (inet_pton(AF_INET6,
"1111:A21B:6221:BDEA:BBBA::DBAA:9861",
3071 &servaddr.sin6_addr) <= 0)
3075 memset(&servaddr, 0,
sizeof(servaddr));
3076 if (inet_pton(AF_INET6,
"1111:A21B:6221:BDEA:BBBA::DBAA:9861",
3077 &servaddr.sin6_addr) <= 0)
3081 memset(&servaddr, 0,
sizeof(servaddr));
3082 if (inet_pton(AF_INET6,
"4444:0BF7:5346:BDEA:7422:8713:9124:2315",
3083 &servaddr.sin6_addr) <= 0)
3087 memset(&servaddr, 0,
sizeof(servaddr));
3088 if (inet_pton(AF_INET6,
"DBCA:ABC2:ABCD:DBCA:1245:2342:1111:2212",
3089 &servaddr.sin6_addr) <= 0)
3093 memset(&servaddr, 0,
sizeof(servaddr));
3094 if (inet_pton(AF_INET6,
"2003:0BF5:5346:1251:7422:1112:9124:2315",
3095 &servaddr.sin6_addr) <= 0)
3099 memset(&servaddr, 0,
sizeof(servaddr));
3100 if (inet_pton(AF_INET6,
"5555:0BF1:ABCD:ADEA:7922:ABCD:9124:2375",
3101 &servaddr.sin6_addr) <= 0)
3105 memset(&servaddr, 0,
sizeof(servaddr));
3106 if (inet_pton(AF_INET6,
"DBCA:ABCD:ABCD:DBCA:1245:2342:1111:2212",
3107 &servaddr.sin6_addr) <= 0)
3111 memset(&servaddr, 0,
sizeof(servaddr));
3112 if (inet_pton(AF_INET6,
"DBCA:ABCD:ABCD:DBAA:1245:2342:1146:6241",
3113 &servaddr.sin6_addr) <= 0)
3117 memset(&servaddr, 0,
sizeof(servaddr));
3118 if (inet_pton(AF_INET6,
"DBCA:ABCD:ABCD:DBAA:1245:2342:1356:1241",
3119 &servaddr.sin6_addr) <= 0)
3123 memset(&servaddr, 0,
sizeof(servaddr));
3124 if (inet_pton(AF_INET6,
"DBCA:ABCD:ABCD:DAAA:1245:2342:1146:6241",
3125 &servaddr.sin6_addr) <= 0)
3135 static int SCRadixTestIPV6NetblockInsertion14(
void)
3139 struct sockaddr_in6 servaddr;
3145 memset(&servaddr, 0,
sizeof(servaddr));
3146 if (inet_pton(AF_INET6,
"2003:0BF1:5346:BDEA:7422:8713:9124:2315",
3147 &servaddr.sin6_addr) <= 0)
3151 memset(&servaddr, 0,
sizeof(servaddr));
3152 if (inet_pton(AF_INET6,
"BD15:9791:5346:6223:AADB:8713:9882:2432",
3153 &servaddr.sin6_addr) <= 0)
3157 memset(&servaddr, 0,
sizeof(servaddr));
3158 if (inet_pton(AF_INET6,
"1111:A21B:6221:BDEA:BBBA::DBAA:9861",
3159 &servaddr.sin6_addr) <= 0)
3163 memset(&servaddr, 0,
sizeof(servaddr));
3164 if (inet_pton(AF_INET6,
"4444:0BF7:5346:BDEA:7422:8713:9124:2315",
3165 &servaddr.sin6_addr) <= 0)
3169 memset(&servaddr, 0,
sizeof(servaddr));
3170 if (inet_pton(AF_INET6,
"5555:0BF1:ABCD:ADEA:7922:ABCD:9124:2375",
3171 &servaddr.sin6_addr) <= 0)
3175 memset(&servaddr, 0,
sizeof(servaddr));
3176 if (inet_pton(AF_INET6,
"DBCA:ABCD:ABCD:DB00:0000:0000:0000:0000",
3177 &servaddr.sin6_addr) <= 0)
3181 memset(&servaddr, 0,
sizeof(servaddr));
3182 if (inet_pton(AF_INET6,
"DBCA:ABCD:ABCD:DBAA:1245:2342:1145:6241",
3183 &servaddr.sin6_addr) <= 0)
3187 memset(&servaddr, 0,
sizeof(servaddr));
3188 if (inet_pton(AF_INET6,
"::", &servaddr.sin6_addr) <= 0)
3194 memset(&servaddr, 0,
sizeof(servaddr));
3195 if (inet_pton(AF_INET6,
"2004:0BF1:5346:BDEA:7422:8713:9124:2315",
3196 &servaddr.sin6_addr) <= 0)
3200 memset(&servaddr, 0,
sizeof(servaddr));
3201 if (inet_pton(AF_INET6,
"2004:0BF1:5346:BDEA:7422:8713:9124:2315",
3202 &servaddr.sin6_addr) <= 0)
3206 memset(&servaddr, 0,
sizeof(servaddr));
3207 if (inet_pton(AF_INET6,
"2004:0BF1:5346:B116:2362:8713:9124:2315",
3208 &servaddr.sin6_addr) <= 0)
3212 memset(&servaddr, 0,
sizeof(servaddr));
3213 if (inet_pton(AF_INET6,
"2004:0B23:3252:BDEA:7422:8713:9124:2341",
3214 &servaddr.sin6_addr) <= 0)
3218 memset(&servaddr, 0,
sizeof(servaddr));
3219 if (inet_pton(AF_INET6,
"DBCA:ABCD:ABCD:DBAA:1245:2342:1145:6241",
3220 &servaddr.sin6_addr) <= 0)
3225 memset(&servaddr, 0,
sizeof(servaddr));
3226 if (inet_pton(AF_INET6,
"DBCA:ABCD:ABCD:DBAA:1245:2342:1145:6241",
3227 &servaddr.sin6_addr) <= 0)
3241 static int SCRadixTestIPV4NetBlocksAndBestSearch15(
void)
3247 struct sockaddr_in servaddr;
3248 memset(&servaddr, 0,
sizeof(servaddr));
3249 FAIL_IF(inet_pton(AF_INET,
"192.168.0.1", &servaddr.sin_addr) <= 0);
3251 for (uint32_t i = 0; i <= 32; i++) {
3252 uint32_t *user =
SCMalloc(
sizeof(uint32_t));
3257 snprintf(
str,
sizeof(
str),
"192.168.0.1/%u", i);
3260 void *user_data = NULL;
3264 FAIL_IF(*((uint32_t *)user_data) != i);
3275 static int SCRadixTestIPV4NetBlocksAndBestSearch16(
void)
3281 struct sockaddr_in servaddr;
3282 memset(&servaddr, 0,
sizeof(servaddr));
3283 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &servaddr.sin_addr) <= 0);
3285 for (uint32_t i = 0; i <= 32; i++) {
3286 uint32_t *user =
SCMalloc(
sizeof(uint32_t));
3291 snprintf(
str,
sizeof(
str),
"192.168.1.1/%u", i);
3294 void *user_data = NULL;
3298 FAIL_IF(*((uint32_t *)user_data) != i);
3309 static int SCRadixTestIPV4NetBlocksAndBestSearch17(
void)
3314 struct sockaddr_in servaddr;
3315 memset(&servaddr, 0,
sizeof(servaddr));
3316 FAIL_IF(inet_pton(AF_INET,
"10.0.0.1", &servaddr.sin_addr) <= 0);
3318 for (uint32_t i = 0; i <= 32; i++) {
3319 uint32_t *user =
SCMalloc(
sizeof(uint32_t));
3324 snprintf(
str,
sizeof(
str),
"10.0.0.1/%u", i);
3327 void *user_data = NULL;
3331 FAIL_IF(*((uint32_t *)user_data) != i);
3342 static int SCRadixTestIPV4NetBlocksAndBestSearch18(
void)
3347 struct sockaddr_in servaddr;
3348 memset(&servaddr, 0,
sizeof(servaddr));
3349 FAIL_IF(inet_pton(AF_INET,
"172.26.0.1", &servaddr.sin_addr) <= 0);
3351 for (uint32_t i = 0; i <= 32; i++) {
3352 uint32_t *user =
SCMalloc(
sizeof(uint32_t));
3357 snprintf(
str,
sizeof(
str),
"172.26.0.1/%u", i);
3360 void *user_data = NULL;
3364 FAIL_IF(*((uint32_t *)user_data) != i);
3375 static int SCRadixTestIPV4NetBlocksAndBestSearch19(
void)
3380 struct sockaddr_in servaddr;
3381 memset(&servaddr, 0,
sizeof(servaddr));
3382 FAIL_IF(inet_pton(AF_INET,
"0.0.0.0", &servaddr.sin_addr) <= 0);
3384 uint32_t *user =
SCMalloc(
sizeof(uint32_t));
3390 memset(&servaddr, 0,
sizeof(servaddr));
3391 FAIL_IF(inet_pton(AF_INET,
"192.168.1.15", &servaddr.sin_addr) <= 0);
3392 void *user_data = NULL;
3396 FAIL_IF(*((uint32_t *)user_data) != 100);
3399 memset(&servaddr, 0,
sizeof(servaddr));
3400 FAIL_IF(inet_pton(AF_INET,
"177.0.0.0", &servaddr.sin_addr) <= 0);
3407 memset(&servaddr, 0,
sizeof(servaddr));
3408 FAIL_IF(inet_pton(AF_INET,
"177.168.1.15", &servaddr.sin_addr) <= 0);
3413 FAIL_IF(*((uint32_t *)user_data) != 200);
3416 memset(&servaddr, 0,
sizeof(servaddr));
3417 FAIL_IF(inet_pton(AF_INET,
"178.168.1.15", &servaddr.sin_addr) <= 0);
3422 FAIL_IF(*((uint32_t *)user_data) != 100);
3425 memset(&servaddr, 0,
sizeof(servaddr));
3426 FAIL_IF(inet_pton(AF_INET,
"177.160.0.0", &servaddr.sin_addr) <= 0);
3433 memset(&servaddr, 0,
sizeof(servaddr));
3434 FAIL_IF(inet_pton(AF_INET,
"177.168.1.15", &servaddr.sin_addr) <= 0);
3439 FAIL_IF(*((uint32_t *)user_data) != 300);
3442 memset(&servaddr, 0,
sizeof(servaddr));
3443 FAIL_IF(inet_pton(AF_INET,
"177.167.1.15", &servaddr.sin_addr) <= 0);
3448 FAIL_IF(*((uint32_t *)user_data) != 300);
3451 memset(&servaddr, 0,
sizeof(servaddr));
3452 FAIL_IF(inet_pton(AF_INET,
"177.178.1.15", &servaddr.sin_addr) <= 0);
3457 FAIL_IF(*((uint32_t *)user_data) != 200);
3460 memset(&servaddr, 0,
sizeof(servaddr));
3461 FAIL_IF(inet_pton(AF_INET,
"197.178.1.15", &servaddr.sin_addr) <= 0);
3466 FAIL_IF(*((uint32_t *)user_data) != 100);
3476 static int SCRadixTestIPV6NetBlocksAndBestSearch20(
void)
3481 struct sockaddr_in6 servaddr;
3482 memset(&servaddr, 0,
sizeof(servaddr));
3483 FAIL_IF(inet_pton(AF_INET6,
"ABAB:CDCD:ABAB:CDCD:1234:4321:1234:4321", &servaddr.sin6_addr) <=
3486 for (uint32_t i = 0; i <= 128; i++) {
3487 uint32_t *user =
SCMalloc(
sizeof(uint32_t));
3492 snprintf(
str,
sizeof(
str),
"ABAB:CDCD:ABAB:CDCD:1234:4321:1234:4321/%u", i);
3495 void *user_data = NULL;
3499 FAIL_IF(*((uint32_t *)user_data) != i);
3510 static int SCRadixTestIPV6NetBlocksAndBestSearch21(
void)
3515 struct sockaddr_in6 servaddr;
3516 memset(&servaddr, 0,
sizeof(servaddr));
3517 FAIL_IF(inet_pton(AF_INET6,
"ff00::1", &servaddr.sin6_addr) <= 0);
3519 for (uint32_t i = 0; i <= 128; i++) {
3520 uint32_t *user =
SCMalloc(
sizeof(uint32_t));
3525 snprintf(
str,
sizeof(
str),
"ff00::1/%u", i);
3528 void *user_data = NULL;
3532 FAIL_IF(*((uint32_t *)user_data) != i);
3543 static int SCRadixTestIPV6NetBlocksAndBestSearch22(
void)
3548 struct sockaddr_in6 servaddr;
3549 memset(&servaddr, 0,
sizeof(servaddr));
3550 FAIL_IF(inet_pton(AF_INET6,
"ff00::192:168:1:1", &servaddr.sin6_addr) <= 0);
3552 for (uint32_t i = 0; i <= 128; i++) {
3553 uint32_t *user =
SCMalloc(
sizeof(uint32_t));
3558 snprintf(
str,
sizeof(
str),
"ff00::192:168:1:1/%u", i);
3561 void *user_data = NULL;
3565 FAIL_IF(*((uint32_t *)user_data) != i);
3576 static int SCRadixTestIPV6NetBlocksAndBestSearch23(
void)
3581 struct sockaddr_in6 servaddr;
3582 memset(&servaddr, 0,
sizeof(servaddr));
3583 FAIL_IF(inet_pton(AF_INET6,
"FF00:ABCD:BCDA::ABCD", &servaddr.sin6_addr) <= 0);
3585 for (uint32_t i = 0; i <= 128; i++) {
3586 uint32_t *user =
SCMalloc(
sizeof(uint32_t));
3591 snprintf(
str,
sizeof(
str),
"FF00:ABCD:BCDA::ABCD/%u", i);
3594 void *user_data = NULL;
3598 FAIL_IF(*((uint32_t *)user_data) != i);
3609 static int SCRadixTestIPV6NetBlocksAndBestSearch24(
void)
3611 struct sockaddr_in6 servaddr;
3612 void *user_data = NULL;
3617 uint32_t *user =
SCMalloc(
sizeof(uint32_t));
3622 memset(&servaddr, 0,
sizeof(servaddr));
3623 FAIL_IF(inet_pton(AF_INET6,
"ABCD::1", &servaddr.sin6_addr) <= 0);
3627 FAIL_IF(*((uint32_t *)user_data) != 100);
3635 memset(&servaddr, 0,
sizeof(servaddr));
3636 FAIL_IF(inet_pton(AF_INET6,
"ABCD::1", &servaddr.sin6_addr) <= 0);
3640 FAIL_IF(*((uint32_t *)user_data) != 200);
3643 memset(&servaddr, 0,
sizeof(servaddr));
3644 FAIL_IF(inet_pton(AF_INET6,
"DCBA::1", &servaddr.sin6_addr) <= 0);
3649 FAIL_IF(*((uint32_t *)user_data) != 100);
3657 memset(&servaddr, 0,
sizeof(servaddr));
3658 FAIL_IF(inet_pton(AF_INET6,
"ABCD:ABCD::1", &servaddr.sin6_addr) <= 0);
3662 FAIL_IF(*((uint32_t *)user_data) != 300);
3665 memset(&servaddr, 0,
sizeof(servaddr));
3666 FAIL_IF(inet_pton(AF_INET6,
"ABCD:AAAA::1", &servaddr.sin6_addr) <= 0);
3670 FAIL_IF(*((uint32_t *)user_data) != 300);
3673 memset(&servaddr, 0,
sizeof(servaddr));
3674 FAIL_IF(inet_pton(AF_INET6,
"ABAB::1", &servaddr.sin6_addr) <= 0);
3678 FAIL_IF(*((uint32_t *)user_data) != 200);
3681 memset(&servaddr, 0,
sizeof(servaddr));
3682 FAIL_IF(inet_pton(AF_INET6,
"CABD::1", &servaddr.sin6_addr) <= 0);
3686 FAIL_IF(*((uint32_t *)user_data) != 100);
3697 static int SCRadixTestIPV4NetblockInsertion25(
void)
3700 struct sockaddr_in servaddr;
3705 memset(&servaddr, 0,
sizeof(servaddr));
3706 if (inet_pton(AF_INET,
"192.168.0.0", &servaddr.sin_addr) <= 0)
3711 memset(&servaddr, 0,
sizeof(servaddr));
3712 if (inet_pton(AF_INET,
"192.168.128.53", &servaddr.sin_addr) <= 0)
3727 static int SCRadixTestIPV4NetblockInsertion26(
void)
3729 struct sockaddr_in servaddr;
3734 memset(&servaddr, 0,
sizeof(servaddr));
3735 FAIL_IF(inet_pton(AF_INET,
"0.0.0.0", &servaddr.sin_addr) <= 0);
3745 memset(&servaddr, 0,
sizeof(servaddr));
3746 FAIL_IF(inet_pton(AF_INET,
"176.0.0.0", &servaddr.sin_addr) <= 0);
3754 memset(&servaddr, 0,
sizeof(servaddr));
3755 FAIL_IF(inet_pton(AF_INET,
"0.0.0.0", &servaddr.sin_addr) <= 0);
3774 UtRegisterTest(
"SCRadixTestIPV4Insertion03", SCRadixTestIPV4Insertion03);
3775 UtRegisterTest(
"SCRadixTestIPV4Removal04", SCRadixTestIPV4Removal04);
3776 UtRegisterTest(
"SCRadixTestIPV6Insertion07", SCRadixTestIPV6Insertion07);
3777 UtRegisterTest(
"SCRadixTestIPV6Removal08", SCRadixTestIPV6Removal08);
3779 SCRadixTestIPV4NetblockInsertion09);
3780 UtRegisterTest(
"SCRadixTestIPV4Bug5066", SCRadixTestIPV4Bug5066);
3781 UtRegisterTest(
"SCRadixTestIPV4Bug5066v2", SCRadixTestIPV4Bug5066v2);
3782 UtRegisterTest(
"SCRadixTestIPV6Bug5066", SCRadixTestIPV6Bug5066);
3784 SCRadixTestIPV4NetblockInsertion10);
3786 SCRadixTestIPV4NetblockInsertion11);
3788 SCRadixTestIPV4NetblockInsertion12);
3790 SCRadixTestIPV6NetblockInsertion13);
3792 SCRadixTestIPV6NetblockInsertion14);
3794 SCRadixTestIPV4NetBlocksAndBestSearch15);
3796 SCRadixTestIPV4NetBlocksAndBestSearch16);
3798 SCRadixTestIPV4NetBlocksAndBestSearch17);
3800 SCRadixTestIPV4NetBlocksAndBestSearch18);
3802 SCRadixTestIPV4NetBlocksAndBestSearch19);
3804 SCRadixTestIPV6NetBlocksAndBestSearch20);
3806 SCRadixTestIPV6NetBlocksAndBestSearch21);
3808 SCRadixTestIPV6NetBlocksAndBestSearch22);
3810 SCRadixTestIPV6NetBlocksAndBestSearch23);
3812 SCRadixTestIPV6NetBlocksAndBestSearch24);
3814 SCRadixTestIPV4NetblockInsertion25);
3816 SCRadixTestIPV4NetblockInsertion26);