Merge pull request #58 from electronjoe/a1cf780cccc4819eb360cda1e0e94e17935cb8c7
[netsniff-ng-old.git] / patricia.h
blob81e0f6af3ec025616a30ad472aef2cafa3a2cfe5
1 /*
2 * netsniff-ng - the packet sniffing beast
3 * Copyright 2011 Daniel Borkmann, rewritten
4 * Copyright 1991-2007 Kawahara Lab., Kyoto University
5 * Copyright 2000-2005 Shikano Lab., Nara Institute of Science and Technology
6 * Copyright 2005-2007 Julius project team, Nagoya Institute of Technology
7 * All rights reserved
8 * Subject to the GPL, version 2.
9 */
11 #ifndef PATRICIA_H
12 #define PATRICIA_H
14 #include <netinet/in.h>
16 #include "built_in.h"
18 struct patricia_node {
19 void *key;
20 size_t klen;
21 struct sockaddr_storage *addr;
22 size_t alen;
23 union {
24 int data;
25 int thres_bit;
26 } value;
27 struct patricia_node *l, *r;
28 } __cacheline_aligned;
30 extern int ptree_search_data_nearest(void *str, size_t sstr,
31 struct sockaddr_storage *addr, size_t *alen,
32 struct patricia_node *root);
33 extern int ptree_search_data_exact(void *str, size_t sstr,
34 struct sockaddr_storage *addr, size_t *alen,
35 struct patricia_node *root);
36 extern int ptree_add_entry(void *str, size_t sstr, int data,
37 struct sockaddr_storage *addr, size_t alen,
38 struct patricia_node **root);
39 extern void ptree_del_entry(void *str, size_t sstr,
40 struct patricia_node **root);
41 extern void ptree_get_key(int data, struct patricia_node *node,
42 struct patricia_node **wanted);
43 extern void ptree_get_key_addr(struct sockaddr_storage *addr, size_t alen,
44 struct patricia_node *node,
45 struct patricia_node **wanted);
46 extern void ptree_display(struct patricia_node *node, int level);
47 extern void ptree_free(struct patricia_node *root);
49 #endif /* PATRICIA_H */