diff options
-rw-r--r-- | src/include/ndpi_api.h.in | 6 | ||||
-rw-r--r-- | src/lib/ndpi_main.c | 30 | ||||
-rw-r--r-- | src/lib/third_party/src/ndpi_patricia.c | 7 |
3 files changed, 43 insertions, 0 deletions
diff --git a/src/include/ndpi_api.h.in b/src/include/ndpi_api.h.in index 8ccb868f8..4e63d1d22 100644 --- a/src/include/ndpi_api.h.in +++ b/src/include/ndpi_api.h.in @@ -975,11 +975,17 @@ extern "C" { ndpi_patricia_node_t *ndpi_patricia_search_exact(ndpi_patricia_tree_t *patricia, ndpi_prefix_t *prefix); ndpi_patricia_node_t *ndpi_patricia_search_best(ndpi_patricia_tree_t *patricia, ndpi_prefix_t *prefix); ndpi_patricia_node_t *ndpi_patricia_lookup(ndpi_patricia_tree_t *patricia, ndpi_prefix_t *prefix); + size_t ndpi_patricia_walk_tree_inorder(ndpi_patricia_tree_t *patricia, ndpi_void_fn3_t func, void *data); size_t ndpi_patricia_walk_inorder(ndpi_patricia_node_t *node, ndpi_void_fn3_t func, void *data); void ndpi_patricia_remove(ndpi_patricia_tree_t *patricia, ndpi_patricia_node_t *node); void ndpi_patricia_set_node_u64(ndpi_patricia_node_t *node, u_int64_t value); u_int64_t ndpi_patricia_get_node_u64(ndpi_patricia_node_t *node); + void ndpi_patricia_set_node_data(ndpi_patricia_node_t *node, void *data); + void *ndpi_patricia_get_node_data(ndpi_patricia_node_t *node); + ndpi_prefix_t *ndpi_patricia_get_node_prefix(ndpi_patricia_node_t *node); + u_int16_t ndpi_patricia_get_node_bits(ndpi_patricia_node_t *node); + u_int16_t ndpi_patricia_get_maxbits(ndpi_patricia_tree_t *tree); /* ptree (trie) API - a wrapper on top of Patricia that seamlessly handle IPv4 and IPv6 */ ndpi_ptree_t* ndpi_ptree_create(void); diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c index b866ed537..e0d64009e 100644 --- a/src/lib/ndpi_main.c +++ b/src/lib/ndpi_main.c @@ -1660,6 +1660,12 @@ static int ac_match_handler(AC_MATCH_t *m, AC_TEXT_t *txt, AC_REP_t *match) { /* ******************************************************************** */ +u_int16_t ndpi_patricia_get_maxbits(ndpi_patricia_tree_t *tree) { + return(tree->maxbits); +} + +/* ******************************************************************** */ + int ndpi_fill_prefix_v4(ndpi_prefix_t *p, const struct in_addr *a, int b, int mb) { if(b < 0 || b > mb) return(-1); @@ -1703,6 +1709,30 @@ int ndpi_fill_prefix_mac(ndpi_prefix_t *prefix, u_int8_t *mac, int bits, int max /* ******************************************* */ +ndpi_prefix_t *ndpi_patricia_get_node_prefix(ndpi_patricia_node_t *node) { + return(node->prefix); +} + +/* ******************************************* */ + +u_int16_t ndpi_patricia_get_node_bits(ndpi_patricia_node_t *node) { + return(node->bit); +} + +/* ******************************************* */ + +void ndpi_patricia_set_node_data(ndpi_patricia_node_t *node, void *data) { + node->data = data; +} + +/* ******************************************* */ + +void *ndpi_patricia_get_node_data(ndpi_patricia_node_t *node) { + return(node->data); +} + +/* ******************************************* */ + void ndpi_patricia_set_node_u64(ndpi_patricia_node_t *node, u_int64_t value) { node->value.u.uv64 = value; } diff --git a/src/lib/third_party/src/ndpi_patricia.c b/src/lib/third_party/src/ndpi_patricia.c index c4a574f62..7035bf797 100644 --- a/src/lib/third_party/src/ndpi_patricia.c +++ b/src/lib/third_party/src/ndpi_patricia.c @@ -449,6 +449,13 @@ ndpi_patricia_walk_inorder(ndpi_patricia_node_t *node, ndpi_void_fn3_t func, voi return n; } +size_t +ndpi_patricia_walk_tree_inorder(ndpi_patricia_tree_t *patricia, ndpi_void_fn3_t func, void *data) { + if (patricia->head == NULL) + return 0; + + return ndpi_patricia_walk_inorder(patricia->head, func, data); +} ndpi_patricia_node_t * ndpi_patricia_search_exact (ndpi_patricia_tree_t *patricia, ndpi_prefix_t *prefix) |