RTRlib
Loading...
Searching...
No Matches
trie_private.h
Go to the documentation of this file.
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_PRIVATE
11#define RTR_TRIE_PRIVATE
12
15
16#include <inttypes.h>
17
18#define PFX_DBG1(a) lrtr_dbg("PFX: " a)
19
29struct trie_node {
34 void *data;
35 uint8_t len;
36};
37
44void trie_insert(struct trie_node *root, struct trie_node *new_node, const unsigned int level);
45
60struct trie_node *trie_lookup(const struct trie_node *root_node, const struct lrtr_ip_addr *prefix,
61 const uint8_t mask_len, unsigned int *level);
62
77struct trie_node *trie_lookup_exact(struct trie_node *root_node, const struct lrtr_ip_addr *prefix,
78 const uint8_t mask_len, unsigned int *level, bool *found);
79
89struct trie_node *trie_remove(struct trie_node *root_node, const struct lrtr_ip_addr *prefix, const uint8_t mask_len,
90 const unsigned int level);
91
98bool trie_is_leaf(const struct trie_node *node);
99
100int trie_get_children(const struct trie_node *root_node, struct trie_node ***array, unsigned int *len);
101#endif
uint32_t len
Definition rtr_pdus.h:4
The lrtr_ip_addr struct stores a IPv4 or IPv6 address in host byte order.
Definition ip.h:38
trie_node
Definition trie_private.h:29
uint8_t len
Definition trie_private.h:35
void * data
Definition trie_private.h:34
struct trie_node * parent
Definition trie_private.h:33
struct trie_node * lchild
Definition trie_private.h:32
struct trie_node * rchild
Definition trie_private.h:31
struct lrtr_ip_addr prefix
Definition trie_private.h:30
void trie_insert(struct trie_node *root, struct trie_node *new_node, const unsigned int level)
Inserts new_node in the tree.
int trie_get_children(const struct trie_node *root_node, struct trie_node ***array, unsigned int *len)
struct trie_node * trie_lookup(const struct trie_node *root_node, const struct lrtr_ip_addr *prefix, const uint8_t mask_len, unsigned int *level)
Searches for a matching node matching the passed ip prefix and prefix length.
bool trie_is_leaf(const struct trie_node *node)
Detects if a node is a leaf in the tree.
struct trie_node * trie_lookup_exact(struct trie_node *root_node, const struct lrtr_ip_addr *prefix, const uint8_t mask_len, unsigned int *level, bool *found)
Search for a node with the same prefix and prefix length.
struct trie_node * trie_remove(struct trie_node *root_node, const struct lrtr_ip_addr *prefix, const uint8_t mask_len, const unsigned int level)
Removes the node with the passed IP prefix and mask_len from the tree.