RTRlib
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
trie.h
1 /*
2  * This file is part of RTRlib.
3  *
4  * This file is subject to the terms and conditions of the MIT license.
5  * See the file LICENSE in the top level directory for more details.
6  *
7  * Website: http://rtrlib.realmv6.org/
8  */
9 
10 #ifndef RTR_trie
11 #define RTR_trie
12 #include <inttypes.h>
13 #include "rtrlib/lib/ip.h"
14 
24 struct trie_node {
25  struct lrtr_ip_addr prefix;
26  struct trie_node *rchild;
27  struct trie_node *lchild;
28  struct trie_node *parent;
29  void *data;
30  uint8_t len;
31 };
32 
39 void trie_insert(struct trie_node *root, struct trie_node *new_node,
40  const unsigned int level);
41 
56 struct trie_node *trie_lookup(const struct trie_node *root_node,
57  const struct lrtr_ip_addr *prefix,
58  const uint8_t mask_len, unsigned int *level);
59 
74 struct trie_node *trie_lookup_exact(struct trie_node *root_node,
75  const struct lrtr_ip_addr *prefix,
76  const uint8_t mask_len,
77  unsigned int *level, bool *found);
78 
88 struct trie_node *trie_remove(struct trie_node *root_node,
89  const struct lrtr_ip_addr *prefix,
90  const uint8_t mask_len,
91  const unsigned int level);
92 
99 bool trie_is_leaf(const struct trie_node *node);
100 
101 int trie_get_children(const struct trie_node *root_node,
102  struct trie_node ***array, unsigned int *len);
103 #endif
trie_node
Definition: trie.h:24
The lrtr_ip_addr struct stores a IPv4 or IPv6 address in host byte order.
Definition: ip.h:32