diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/include/ndpi_api.h | 2 | ||||
-rw-r--r-- | src/lib/ndpi_main.c | 18 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/include/ndpi_api.h b/src/include/ndpi_api.h index 09d7c87cc..8e7d90336 100644 --- a/src/include/ndpi_api.h +++ b/src/include/ndpi_api.h @@ -153,6 +153,8 @@ extern "C" { */ u_int16_t ndpi_network_ptree_match(struct ndpi_detection_module_struct *ndpi_struct, struct in_addr *pin); + u_int16_t ndpi_network_ptree6_match(struct ndpi_detection_module_struct *ndpi_str, + struct in6_addr *pin); /** * Returns the nDPI protocol id for IP+port-based protocol detection diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c index f3104a9a8..5b5506195 100644 --- a/src/lib/ndpi_main.c +++ b/src/lib/ndpi_main.c @@ -2725,6 +2725,24 @@ u_int16_t ndpi_network_ptree_match(struct ndpi_detection_module_struct *ndpi_str /* ******************************************* */ +u_int16_t ndpi_network_ptree6_match(struct ndpi_detection_module_struct *ndpi_str, + struct in6_addr *pin) { + ndpi_prefix_t prefix; + ndpi_patricia_node_t *node; + + if(!ndpi_str || !ndpi_str->protocols) + return(NDPI_PROTOCOL_UNKNOWN); + + /* Make sure all in network byte order otherwise compares wont work */ + ndpi_fill_prefix_v6(&prefix, pin, 128, + ((ndpi_patricia_tree_t *) ndpi_str->protocols->v4)->maxbits); + node = ndpi_patricia_search_best(ndpi_str->protocols->v4, &prefix); + + return(node ? node->value.u.uv16[0].user_value : NDPI_PROTOCOL_UNKNOWN); +} + +/* ******************************************* */ + u_int16_t ndpi_network_port_ptree_match(struct ndpi_detection_module_struct *ndpi_str, struct in_addr *pin /* network byte order */, u_int16_t port /* network byte order */) { |