]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
unused reputation: radix update
authorVictor Julien <victor@inliniac.net>
Fri, 20 Dec 2013 13:36:14 +0000 (14:36 +0100)
committerVictor Julien <victor@inliniac.net>
Fri, 7 Feb 2014 16:16:15 +0000 (17:16 +0100)
Update the unused reputation code to compile after radix update.

src/reputation.c

index 04945aa2e239883f7ffa4553cb62bf12cf207f99..c9c0d1d563abc804f33cb121b372899fe3c6b238 100644 (file)
@@ -842,18 +842,19 @@ Reputation *SCReputationAddIPV4Data(uint8_t *ipv4addr, int netmask_value, Reputa
  */
 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);
@@ -876,13 +877,14 @@ Reputation *SCReputationLookupIPV4BestMatch(uint8_t *ipv4_addr)
     /* 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);
@@ -905,13 +907,14 @@ Reputation *SCReputationLookupIPV6BestMatch(uint8_t *ipv6_addr)
     /* 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);
@@ -934,13 +937,14 @@ Reputation *SCReputationLookupIPV6ExactMatch(uint8_t *ipv6_addr)
     /* 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);
@@ -959,11 +963,12 @@ Reputation *SCReputationLookupIPV6ExactMatch(uint8_t *ipv6_addr)
  */
 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;
     }
 }
 
@@ -978,11 +983,12 @@ Reputation *SCReputationLookupIPV4ExactMatchReal(uint8_t *ipv4_addr)
  */
 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;
     }
 }
 
@@ -997,11 +1003,12 @@ Reputation *SCReputationLookupIPV4BestMatchReal(uint8_t *ipv4_addr)
  */
 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;
     }
 }
 
@@ -1016,11 +1023,12 @@ Reputation *SCReputationLookupIPV6BestMatchReal(uint8_t *ipv6_addr)
  */
 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;
     }
 }