Skip to content

Commit 71bd585

Browse files
committed
Added ndpi_network_ptree6_match() API call
1 parent dd4807f commit 71bd585

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/include/ndpi_api.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ extern "C" {
153153
*/
154154
u_int16_t ndpi_network_ptree_match(struct ndpi_detection_module_struct *ndpi_struct,
155155
struct in_addr *pin);
156+
u_int16_t ndpi_network_ptree6_match(struct ndpi_detection_module_struct *ndpi_str,
157+
struct in6_addr *pin);
156158

157159
/**
158160
* Returns the nDPI protocol id for IP+port-based protocol detection

src/lib/ndpi_main.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2725,6 +2725,24 @@ u_int16_t ndpi_network_ptree_match(struct ndpi_detection_module_struct *ndpi_str
27252725

27262726
/* ******************************************* */
27272727

2728+
u_int16_t ndpi_network_ptree6_match(struct ndpi_detection_module_struct *ndpi_str,
2729+
struct in6_addr *pin) {
2730+
ndpi_prefix_t prefix;
2731+
ndpi_patricia_node_t *node;
2732+
2733+
if(!ndpi_str || !ndpi_str->protocols)
2734+
return(NDPI_PROTOCOL_UNKNOWN);
2735+
2736+
/* Make sure all in network byte order otherwise compares wont work */
2737+
ndpi_fill_prefix_v6(&prefix, pin, 128,
2738+
((ndpi_patricia_tree_t *) ndpi_str->protocols->v4)->maxbits);
2739+
node = ndpi_patricia_search_best(ndpi_str->protocols->v4, &prefix);
2740+
2741+
return(node ? node->value.u.uv16[0].user_value : NDPI_PROTOCOL_UNKNOWN);
2742+
}
2743+
2744+
/* ******************************************* */
2745+
27282746
u_int16_t ndpi_network_port_ptree_match(struct ndpi_detection_module_struct *ndpi_str,
27292747
struct in_addr *pin /* network byte order */,
27302748
u_int16_t port /* network byte order */) {

0 commit comments

Comments
 (0)