]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Add function `radix32_tree_find_addr`.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 21 Apr 2014 16:48:28 +0000 (17:48 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 21 Apr 2014 16:48:28 +0000 (17:48 +0100)
src/libutil/radix.c
src/libutil/radix.h
src/libutil/util.h

index 1a05db1789fe4ebde472055bf72d104ea31a582f..7af6653314732bba1e72ef06f69d66944d5014ff 100644 (file)
@@ -306,6 +306,16 @@ radix_tree_free (radix_tree_t * tree)
        g_free (tree);
 }
 
+uintptr_t
+radix32_tree_find_addr (radix_tree_t *tree, rspamd_inet_addr_t *addr)
+{
+       if (addr == NULL || addr->af != AF_INET) {
+               return RADIX_NO_VALUE;
+       }
+
+       return radix32tree_find (tree, ntohl (addr->addr.s4.sin_addr.s_addr));
+}
+
 /* 
  * vi:ts=4 
  */
index 4cc2873c7c31ef9ff4da4f10cd5f30c6f3481b89..88f345e3d0b3a1764c1ecb887491667c25a4f7cb 100644 (file)
@@ -3,6 +3,7 @@
 
 #include "config.h"
 #include "mem_pool.h"
+#include "util.h"
 
 #define RADIX_NO_VALUE   (uintptr_t)-1
 
@@ -69,6 +70,14 @@ gint radix32tree_delete (radix_tree_t *tree, guint32 key, guint32 mask);
  */
 uintptr_t radix32tree_find (radix_tree_t *tree, guint32 key);
 
+/**
+ * Find specified address in tree (works only for ipv4 addresses)
+ * @param tree
+ * @param addr
+ * @return
+ */
+uintptr_t radix32_tree_find_addr (radix_tree_t *tree, rspamd_inet_addr_t *addr);
+
 /**
  * Traverse via the whole tree calling specified callback
  */
index 0605fe87d8c48a76998c70847a69c274af2fe511..4359d4288b267787e5d494ed813c2e036b2570e5 100644 (file)
@@ -3,7 +3,6 @@
 
 #include "config.h"
 #include "mem_pool.h"
-#include "radix.h"
 #include "statfile.h"
 #include "printf.h"
 #include "fstring.h"