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

g_free (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 * vi:ts=4
*/ */

+ 9
- 0
src/libutil/radix.h View File



#include "config.h" #include "config.h"
#include "mem_pool.h" #include "mem_pool.h"
#include "util.h"


#define RADIX_NO_VALUE (uintptr_t)-1 #define RADIX_NO_VALUE (uintptr_t)-1


*/ */
uintptr_t radix32tree_find (radix_tree_t *tree, guint32 key); 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 * Traverse via the whole tree calling specified callback
*/ */

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



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

Loading…
Cancel
Save