Browse Source

Add function `radix32_tree_find_addr`.

tags/0.7.0
Vsevolod Stakhov 10 years ago
parent
commit
875707dcc1
3 changed files with 19 additions and 1 deletions
  1. 10
    0
      src/libutil/radix.c
  2. 9
    0
      src/libutil/radix.h
  3. 0
    1
      src/libutil/util.h

+ 10
- 0
src/libutil/radix.c View 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
*/

+ 9
- 0
src/libutil/radix.h View 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
*/

+ 0
- 1
src/libutil/util.h View File

@@ -3,7 +3,6 @@

#include "config.h"
#include "mem_pool.h"
#include "radix.h"
#include "statfile.h"
#include "printf.h"
#include "fstring.h"

Loading…
Cancel
Save