*/
Reputation *SCReputationLookupIPV4ExactMatch(uint8_t *ipv4_addr)
{
- Reputation *rep_data;
+ Reputation *rep_data = NULL;
/* Be careful with this (locking)*/
SCMutexLock(&rep_ctx->reputationIPV4_lock);
- SCRadixNode *node = SCRadixFindKeyIPV4ExactMatch(ipv4_addr, rep_ctx->reputationIPV4_tree);
- if (node == NULL || node->prefix == NULL || node->prefix->user_data_result == NULL) {
+ void *user_data = NULL;
+ (void)SCRadixFindKeyIPV4ExactMatch(ipv4_addr, rep_ctx->reputationIPV4_tree, &user_data);
+ if (user_data == NULL) {
rep_data = NULL;
} else {
/* Yes, we clone it because the pointer can be outdated
* while another thread remove this reputation */
- rep_data = SCReputationClone((Reputation *)node->prefix->user_data_result);
+ rep_data = SCReputationClone((Reputation *)user_data);
}
SCMutexUnlock(&rep_ctx->reputationIPV4_lock);
/* Be careful with this (locking)*/
SCMutexLock(&rep_ctx->reputationIPV4_lock);
- SCRadixNode *node = SCRadixFindKeyIPV4BestMatch(ipv4_addr, rep_ctx->reputationIPV4_tree);
- if (node == NULL || node->prefix == NULL || node->prefix->user_data_result == NULL) {
+ void *user_data = NULL;
+ (void)SCRadixFindKeyIPV4BestMatch(ipv4_addr, rep_ctx->reputationIPV4_tree, &user_data);
+ if (user_data == NULL) {
rep_data = NULL;
} else {
/* Yes, we clone it because the pointer can be outdated
* while another thread remove this reputation */
- rep_data = SCReputationClone((Reputation *)node->prefix->user_data_result);
+ rep_data = SCReputationClone((Reputation *)user_data);
}
SCMutexUnlock(&rep_ctx->reputationIPV4_lock);
/* Be careful with this (locking)*/
SCMutexLock(&rep_ctx->reputationIPV6_lock);
- SCRadixNode *node = SCRadixFindKeyIPV6BestMatch(ipv6_addr, rep_ctx->reputationIPV6_tree);
- if (node == NULL || node->prefix == NULL || node->prefix->user_data_result == NULL) {
+ void *user_data = NULL;
+ (void)SCRadixFindKeyIPV6BestMatch(ipv6_addr, rep_ctx->reputationIPV6_tree, &user_data);
+ if (user_data == NULL) {
rep_data = NULL;
} else {
/* Yes, we clone it because the pointer can be outdated
* while another thread remove this reputation */
- rep_data = SCReputationClone((Reputation *)node->prefix->user_data_result);
+ rep_data = SCReputationClone((Reputation *)user_data);
}
SCMutexUnlock(&rep_ctx->reputationIPV6_lock);
/* Be careful with this (locking)*/
SCMutexLock(&rep_ctx->reputationIPV6_lock);
- SCRadixNode *node = SCRadixFindKeyIPV6ExactMatch(ipv6_addr, rep_ctx->reputationIPV6_tree);
- if (node == NULL || node->prefix == NULL || node->prefix->user_data_result == NULL) {
+ void *user_data = NULL;
+ (void)SCRadixFindKeyIPV6ExactMatch(ipv6_addr, rep_ctx->reputationIPV6_tree, &user_data);
+ if (user_data == NULL) {
rep_data = NULL;
} else {
/* Yes, we clone it because the pointer can be outdated
* while another thread remove this reputation */
- rep_data = SCReputationClone((Reputation *)node->prefix->user_data_result);
+ rep_data = SCReputationClone((Reputation *)user_data);
}
SCMutexUnlock(&rep_ctx->reputationIPV6_lock);
*/
Reputation *SCReputationLookupIPV4ExactMatchReal(uint8_t *ipv4_addr)
{
- SCRadixNode *node = SCRadixFindKeyIPV4ExactMatch(ipv4_addr, rep_ctx->reputationIPV4_tree);
- if (node == NULL || node->prefix == NULL || node->prefix->user_data_result == NULL) {
+ void *user_data = NULL;
+ (void)SCRadixFindKeyIPV4ExactMatch(ipv4_addr, rep_ctx->reputationIPV4_tree, &user_data);
+ if (user_data == NULL) {
return NULL;
} else {
- return (Reputation *)node->prefix->user_data_result;
+ return (Reputation *)user_data;
}
}
*/
Reputation *SCReputationLookupIPV4BestMatchReal(uint8_t *ipv4_addr)
{
- SCRadixNode *node = SCRadixFindKeyIPV4BestMatch(ipv4_addr, rep_ctx->reputationIPV4_tree);
- if (node == NULL || node->prefix == NULL || node->prefix->user_data_result == NULL) {
+ void *user_data = NULL;
+ (void)SCRadixFindKeyIPV4BestMatch(ipv4_addr, rep_ctx->reputationIPV4_tree, &user_data);
+ if (user_data == NULL) {
return NULL;
} else {
- return (Reputation *)node->prefix->user_data_result;
+ return (Reputation *)user_data;
}
}
*/
Reputation *SCReputationLookupIPV6BestMatchReal(uint8_t *ipv6_addr)
{
- SCRadixNode *node = SCRadixFindKeyIPV6BestMatch(ipv6_addr, rep_ctx->reputationIPV6_tree);
- if (node == NULL || node->prefix == NULL || node->prefix->user_data_result == NULL) {
+ void *user_data = NULL;
+ (void)SCRadixFindKeyIPV6BestMatch(ipv6_addr, rep_ctx->reputationIPV6_tree, &user_data);
+ if (user_data == NULL) {
return NULL;
} else {
- return (Reputation *)node->prefix->user_data_result;
+ return (Reputation *)user_data;
}
}
*/
Reputation *SCReputationLookupIPV6ExactMatchReal(uint8_t *ipv6_addr)
{
- SCRadixNode *node = SCRadixFindKeyIPV6ExactMatch(ipv6_addr, rep_ctx->reputationIPV6_tree);
- if (node == NULL || node->prefix == NULL || node->prefix->user_data_result == NULL) {
+ void *user_data = NULL;
+ (void)SCRadixFindKeyIPV6ExactMatch(ipv6_addr, rep_ctx->reputationIPV6_tree, &user_data);
+ if (user_data == NULL) {
return NULL;
} else {
- return (Reputation *)node->prefix->user_data_result;
+ return (Reputation *)user_data;
}
}