Fixed invalid network searchthat caused categories to be set randomly
This commit is contained in:
+12
-7
@@ -4417,16 +4417,21 @@ int ndpi_fill_ip_protocol_category(struct ndpi_detection_module_struct *ndpi_str
|
|||||||
prefix_t prefix;
|
prefix_t prefix;
|
||||||
patricia_node_t *node;
|
patricia_node_t *node;
|
||||||
|
|
||||||
/* Make sure all in network byte order otherwise compares wont work */
|
if(saddr == 0)
|
||||||
fill_prefix_v4(&prefix, (struct in_addr *)&saddr,
|
node = NULL;
|
||||||
32, ((patricia_tree_t*)ndpi_str->protocols_ptree)->maxbits);
|
else {
|
||||||
node = ndpi_patricia_search_best(ndpi_str->custom_categories.ipAddresses, &prefix);
|
/* Make sure all in network byte order otherwise compares wont work */
|
||||||
|
fill_prefix_v4(&prefix, (struct in_addr *)&saddr,
|
||||||
if(!node) {
|
|
||||||
fill_prefix_v4(&prefix, (struct in_addr *)&daddr,
|
|
||||||
32, ((patricia_tree_t*)ndpi_str->protocols_ptree)->maxbits);
|
32, ((patricia_tree_t*)ndpi_str->protocols_ptree)->maxbits);
|
||||||
node = ndpi_patricia_search_best(ndpi_str->custom_categories.ipAddresses, &prefix);
|
node = ndpi_patricia_search_best(ndpi_str->custom_categories.ipAddresses, &prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!node) {
|
||||||
|
if(daddr != 0)
|
||||||
|
fill_prefix_v4(&prefix, (struct in_addr *)&daddr,
|
||||||
|
32, ((patricia_tree_t*)ndpi_str->protocols_ptree)->maxbits);
|
||||||
|
node = ndpi_patricia_search_best(ndpi_str->custom_categories.ipAddresses, &prefix);
|
||||||
|
}
|
||||||
|
|
||||||
if(node) {
|
if(node) {
|
||||||
ret->category = (ndpi_protocol_category_t)node->value.user_value;
|
ret->category = (ndpi_protocol_category_t)node->value.user_value;
|
||||||
|
|||||||
Reference in New Issue
Block a user