From 71bd58532ad6648b5b80669bd992d6918ad9b69c Mon Sep 17 00:00:00 2001 From: Luca Deri Date: Fri, 31 Jan 2025 19:02:13 +0100 Subject: Added ndpi_network_ptree6_match() API call --- src/lib/ndpi_main.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/lib/ndpi_main.c') 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 */) { -- cgit v1.2.3