|
|
|
@ -120,7 +120,7 @@ static void SCRadixAppendToSCRadixUserDataList(SCRadixUserData *new,
|
|
|
|
|
* \param key_stream Data that has to be wrapped in a SCRadixPrefix instance to
|
|
|
|
|
* be processed for insertion/lookup/removal of a node by the
|
|
|
|
|
* radix tree
|
|
|
|
|
* \param key_bitlen The bitlen of the the above stream. For example if the
|
|
|
|
|
* \param key_bitlen The bitlen of the above stream. For example if the
|
|
|
|
|
* stream holds the ipv4 address(4 bytes), bitlen would be 32
|
|
|
|
|
* \param user Pointer to the user data that has to be associated with
|
|
|
|
|
* this key
|
|
|
|
@ -417,7 +417,7 @@ static void SCRadixReleaseNode(SCRadixNode *node, SCRadixTree *tree)
|
|
|
|
|
* \brief Creates a new Radix tree
|
|
|
|
|
*
|
|
|
|
|
* \param Free Function pointer supplied by the user to be used by the Radix
|
|
|
|
|
* cleanup API to free the user suppplied data
|
|
|
|
|
* cleanup API to free the user supplied data
|
|
|
|
|
*
|
|
|
|
|
* \retval tree The newly created radix tree on success
|
|
|
|
|
*
|
|
|
|
@ -476,7 +476,7 @@ void SCRadixReleaseRadixTree(SCRadixTree *tree)
|
|
|
|
|
* \brief Adds a key to the Radix tree. Used internally by the API.
|
|
|
|
|
*
|
|
|
|
|
* \param key_stream Data that has to added to the Radix tree
|
|
|
|
|
* \param key_bitlen The bitlen of the the above stream. For example if the
|
|
|
|
|
* \param key_bitlen The bitlen of the above stream. For example if the
|
|
|
|
|
* stream is the string "abcd", the bitlen would be 32. If
|
|
|
|
|
* the stream is an IPV6 address bitlen would be 128
|
|
|
|
|
* \param tree Pointer to the Radix tree
|
|
|
|
@ -736,7 +736,7 @@ static SCRadixNode *SCRadixAddKey(
|
|
|
|
|
node->parent = new_node;
|
|
|
|
|
/* stick our new_node into the tree. Create a node that holds the
|
|
|
|
|
* differing bit position and break the branch. Also handle the
|
|
|
|
|
* tranfer of netmasks between node and inter_node(explained in more
|
|
|
|
|
* transfer of netmasks between node and inter_node(explained in more
|
|
|
|
|
* detail below) */
|
|
|
|
|
} else {
|
|
|
|
|
inter_node = SCRadixCreateNode();
|
|
|
|
@ -1175,7 +1175,7 @@ static void SCRadixRemoveNetblockEntry(SCRadixNode *node, uint8_t netmask)
|
|
|
|
|
* \brief Removes a key from the Radix tree
|
|
|
|
|
*
|
|
|
|
|
* \param key_stream Data that has to be removed from the Radix tree
|
|
|
|
|
* \param key_bitlen The bitlen of the the above stream. For example if the
|
|
|
|
|
* \param key_bitlen The bitlen of the above stream. For example if the
|
|
|
|
|
* stream holds an IPV4 address(4 bytes), bitlen would be 32
|
|
|
|
|
* \param tree Pointer to the Radix tree from which the key has to be
|
|
|
|
|
* removed
|
|
|
|
@ -1312,7 +1312,7 @@ static void SCRadixRemoveKey(uint8_t *key_stream, uint16_t key_bitlen,
|
|
|
|
|
* \brief Removes a key from the Radix tree
|
|
|
|
|
*
|
|
|
|
|
* \param key_stream Data that has to be removed from the Radix tree
|
|
|
|
|
* \param key_bitlen The bitlen of the the above stream.
|
|
|
|
|
* \param key_bitlen The bitlen of the above stream.
|
|
|
|
|
* \param tree Pointer to the Radix tree from which the key has to be
|
|
|
|
|
* removed
|
|
|
|
|
*/
|
|
|
|
@ -1735,13 +1735,13 @@ static int SCRadixTestIPV4Insertion03(void)
|
|
|
|
|
/* add a key that already exists in the tree */
|
|
|
|
|
SCRadixAddKeyIPV4((uint8_t *)&servaddr.sin_addr, tree, NULL);
|
|
|
|
|
|
|
|
|
|
/* test for the existance of a key */
|
|
|
|
|
/* test for the existence of a key */
|
|
|
|
|
memset(&servaddr, 0, sizeof(servaddr));
|
|
|
|
|
if (inet_pton(AF_INET, "192.168.1.6", &servaddr.sin_addr) <= 0)
|
|
|
|
|
return 0;
|
|
|
|
|
result &= (SCRadixFindKeyIPV4ExactMatch((uint8_t *)&servaddr.sin_addr, tree, NULL) == NULL);
|
|
|
|
|
|
|
|
|
|
/* test for the existance of a key */
|
|
|
|
|
/* test for the existence of a key */
|
|
|
|
|
memset(&servaddr, 0, sizeof(servaddr));
|
|
|
|
|
if (inet_pton(AF_INET, "192.167.1.4", &servaddr.sin_addr) <= 0)
|
|
|
|
|
return 0;
|
|
|
|
@ -2125,7 +2125,7 @@ static int SCRadixTestIPV6Removal08(void)
|
|
|
|
|
return 0;
|
|
|
|
|
SCRadixAddKeyIPV6((uint8_t *)&servaddr.sin6_addr, tree, NULL);
|
|
|
|
|
|
|
|
|
|
/* test for existance */
|
|
|
|
|
/* test for existence */
|
|
|
|
|
memset(&servaddr, 0, sizeof(servaddr));
|
|
|
|
|
if (inet_pton(AF_INET6, "1111:A21B:6221:BDEA:BBBA::DBAA:9861",
|
|
|
|
|
&servaddr.sin6_addr) <= 0)
|
|
|
|
@ -2175,7 +2175,7 @@ static int SCRadixTestIPV6Removal08(void)
|
|
|
|
|
return 0;
|
|
|
|
|
SCRadixRemoveKeyIPV6((uint8_t *)&servaddr.sin6_addr, tree);
|
|
|
|
|
|
|
|
|
|
/* test for existance */
|
|
|
|
|
/* test for existence */
|
|
|
|
|
memset(&servaddr, 0, sizeof(servaddr));
|
|
|
|
|
if (inet_pton(AF_INET6, "2003:0BF1:5346:BDEA:7422:8713:9124:2315",
|
|
|
|
|
&servaddr.sin6_addr) <= 0)
|
|
|
|
@ -2237,7 +2237,7 @@ static int SCRadixTestIPV6Removal08(void)
|
|
|
|
|
return 0;
|
|
|
|
|
SCRadixRemoveKeyIPV6((uint8_t *)&servaddr.sin6_addr, tree);
|
|
|
|
|
|
|
|
|
|
/* test for existance */
|
|
|
|
|
/* test for existence */
|
|
|
|
|
memset(&servaddr, 0, sizeof(servaddr));
|
|
|
|
|
if (inet_pton(AF_INET6, "2003:0BF1:5346:BDEA:7422:8713:9124:2315",
|
|
|
|
|
&servaddr.sin6_addr) <= 0)
|
|
|
|
@ -2533,7 +2533,7 @@ static int SCRadixTestIPV4NetblockInsertion09(void)
|
|
|
|
|
return 0;
|
|
|
|
|
SCRadixAddKeyIPV4Netblock((uint8_t *)&servaddr.sin_addr, tree, NULL, 16);
|
|
|
|
|
|
|
|
|
|
/* test for the existance of a key */
|
|
|
|
|
/* test for the existence of a key */
|
|
|
|
|
memset(&servaddr, 0, sizeof(servaddr));
|
|
|
|
|
if (inet_pton(AF_INET, "192.168.1.6", &servaddr.sin_addr) <= 0)
|
|
|
|
|
return 0;
|
|
|
|
@ -2644,7 +2644,7 @@ static int SCRadixTestIPV4NetblockInsertion10(void)
|
|
|
|
|
|
|
|
|
|
SCRadixPrintTree(tree);
|
|
|
|
|
|
|
|
|
|
/* test for the existance of a key */
|
|
|
|
|
/* test for the existence of a key */
|
|
|
|
|
memset(&servaddr, 0, sizeof(servaddr));
|
|
|
|
|
if (inet_pton(AF_INET, "192.171.128.53", &servaddr.sin_addr) <= 0)
|
|
|
|
|
return 0;
|
|
|
|
@ -2761,7 +2761,7 @@ static int SCRadixTestIPV4NetblockInsertion11(void)
|
|
|
|
|
return 0;
|
|
|
|
|
node = SCRadixAddKeyIPV4Netblock((uint8_t *)&servaddr.sin_addr, tree, NULL, 0);
|
|
|
|
|
|
|
|
|
|
/* test for the existance of a key */
|
|
|
|
|
/* test for the existence of a key */
|
|
|
|
|
memset(&servaddr, 0, sizeof(servaddr));
|
|
|
|
|
if (inet_pton(AF_INET, "192.171.128.53", &servaddr.sin_addr) <= 0)
|
|
|
|
|
return 0;
|
|
|
|
@ -2925,7 +2925,7 @@ static int SCRadixTestIPV4NetblockInsertion12(void)
|
|
|
|
|
return 0;
|
|
|
|
|
SCRadixAddKeyIPV4Netblock((uint8_t *)&servaddr.sin_addr, tree, NULL, 32);
|
|
|
|
|
|
|
|
|
|
/* test for the existance of a key */
|
|
|
|
|
/* test for the existence of a key */
|
|
|
|
|
memset(&servaddr, 0, sizeof(servaddr));
|
|
|
|
|
if (inet_pton(AF_INET, "192.171.128.53", &servaddr.sin_addr) <= 0)
|
|
|
|
|
return 0;
|
|
|
|
@ -3673,10 +3673,9 @@ static int SCRadixTestIPV6NetBlocksAndBestSearch24(void)
|
|
|
|
|
PASS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \test SCRadixTestIPV4NetblockInsertion15 insert a node searching on it.
|
|
|
|
|
* Should always return true but the purposse of the test is to monitor
|
|
|
|
|
* Should always return true but the purpose of the test is to monitor
|
|
|
|
|
* the memory usage to detect memleaks (there was one on searching)
|
|
|
|
|
*/
|
|
|
|
|
static int SCRadixTestIPV4NetblockInsertion25(void)
|
|
|
|
@ -3692,7 +3691,7 @@ static int SCRadixTestIPV4NetblockInsertion25(void)
|
|
|
|
|
return 0;
|
|
|
|
|
SCRadixAddKeyIPV4Netblock((uint8_t *)&servaddr.sin_addr, tree, NULL, 16);
|
|
|
|
|
|
|
|
|
|
/* test for the existance of a key */
|
|
|
|
|
/* test for the existence of a key */
|
|
|
|
|
memset(&servaddr, 0, sizeof(servaddr));
|
|
|
|
|
if (inet_pton(AF_INET, "192.168.128.53", &servaddr.sin_addr) <= 0)
|
|
|
|
|
return 0;
|
|
|
|
@ -3706,7 +3705,7 @@ static int SCRadixTestIPV4NetblockInsertion25(void)
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \test SCRadixTestIPV4NetblockInsertion26 insert a node searching on it.
|
|
|
|
|
* Should always return true but the purposse of the test is to monitor
|
|
|
|
|
* Should always return true but the purpose of the test is to monitor
|
|
|
|
|
* the memory usage to detect memleaks (there was one on searching)
|
|
|
|
|
*/
|
|
|
|
|
static int SCRadixTestIPV4NetblockInsertion26(void)
|
|
|
|
@ -3742,8 +3741,8 @@ static int SCRadixTestIPV4NetblockInsertion26(void)
|
|
|
|
|
node = SCRadixAddKeyIPV4Netblock((uint8_t *)&servaddr.sin_addr, tree, str, 7);
|
|
|
|
|
FAIL_IF_NULL(node);
|
|
|
|
|
|
|
|
|
|
/* test for the existance of a key */
|
|
|
|
|
//result &= (SCRadixFindKeyIPV4BestMatch((uint8_t *)&servaddr.sin_addr, tree) != NULL);
|
|
|
|
|
/* test for the existence of a key */
|
|
|
|
|
// result &= (SCRadixFindKeyIPV4BestMatch((uint8_t *)&servaddr.sin_addr, tree) != NULL);
|
|
|
|
|
|
|
|
|
|
SCRadixReleaseRadixTree(tree);
|
|
|
|
|
|
|
|
|
|