diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-04-21 17:48:28 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-04-21 17:48:28 +0100 |
commit | 875707dcc1f2dff45af8da88c93b6d5a658baf4f (patch) | |
tree | ba3bcc3d3ca565ddc321ff3e5a83f65aad6b8a5d /src/libutil | |
parent | 0645b75e9671ece4756ab5c3477acf00c9bca015 (diff) | |
download | rspamd-875707dcc1f2dff45af8da88c93b6d5a658baf4f.tar.gz rspamd-875707dcc1f2dff45af8da88c93b6d5a658baf4f.zip |
Add function `radix32_tree_find_addr`.
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/radix.c | 10 | ||||
-rw-r--r-- | src/libutil/radix.h | 9 | ||||
-rw-r--r-- | src/libutil/util.h | 1 |
3 files changed, 19 insertions, 1 deletions
diff --git a/src/libutil/radix.c b/src/libutil/radix.c index 1a05db178..7af665331 100644 --- a/src/libutil/radix.c +++ b/src/libutil/radix.c @@ -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 */ diff --git a/src/libutil/radix.h b/src/libutil/radix.h index 4cc2873c7..88f345e3d 100644 --- a/src/libutil/radix.h +++ b/src/libutil/radix.h @@ -3,6 +3,7 @@ #include "config.h" #include "mem_pool.h" +#include "util.h" #define RADIX_NO_VALUE (uintptr_t)-1 @@ -70,6 +71,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 */ void radix32tree_traverse (radix_tree_t *tree, radix_tree_traverse_func func, void *user_data); diff --git a/src/libutil/util.h b/src/libutil/util.h index 0605fe87d..4359d4288 100644 --- a/src/libutil/util.h +++ b/src/libutil/util.h @@ -3,7 +3,6 @@ #include "config.h" #include "mem_pool.h" -#include "radix.h" #include "statfile.h" #include "printf.h" #include "fstring.h" |