trafgen: use bool for flags
[netsniff-ng.git] / src / patricia.h
blob0e3bc5f7322192ad54f0f79b46f075d428c30160
1 /*
2 * netsniff-ng - the packet sniffing beast
3 * By Daniel Borkmann <daniel@netsniff-ng.org>
4 * Copyright 2011 Daniel Borkmann, rewritten
5 * Copyright 1991-2007 Kawahara Lab., Kyoto University
6 * Copyright 2000-2005 Shikano Lab., Nara Institute of Science and Technology
7 * Copyright 2005-2007 Julius project team, Nagoya Institute of Technology
8 * All rights reserved
9 * Subject to the GPL, version 2.
12 #ifndef PATRICIA_H
13 #define PATRICIA_H
15 #include <netinet/in.h>
17 #include "built_in.h"
19 struct patricia_node {
20 void *key;
21 size_t klen;
22 struct sockaddr_storage *addr;
23 size_t alen;
24 union {
25 int data;
26 int thres_bit;
27 } value;
28 struct patricia_node *l, *r;
29 } __cacheline_aligned;
31 extern int ptree_search_data_nearest(void *str, size_t sstr,
32 struct sockaddr_storage *addr, size_t *alen,
33 struct patricia_node *root);
34 extern int ptree_search_data_exact(void *str, size_t sstr,
35 struct sockaddr_storage *addr, size_t *alen,
36 struct patricia_node *root);
37 extern int ptree_add_entry(void *str, size_t sstr, int data,
38 struct sockaddr_storage *addr, size_t alen,
39 struct patricia_node **root);
40 extern void ptree_del_entry(void *str, size_t sstr,
41 struct patricia_node **root);
42 extern void ptree_get_key(int data, struct patricia_node *node,
43 struct patricia_node **wanted);
44 extern void ptree_get_key_addr(struct sockaddr_storage *addr, size_t alen,
45 struct patricia_node *node,
46 struct patricia_node **wanted);
47 extern void ptree_display(struct patricia_node *node, int level);
48 extern void ptree_free(struct patricia_node *root);
50 #define ptree_maybe_add_entry ptree_add_entry
52 #endif /* PATRICIA_H */