diff options
author | Luca Deri <deri@ntop.org> | 2023-03-13 20:52:08 +0100 |
---|---|---|
committer | Luca Deri <deri@ntop.org> | 2023-03-13 20:52:08 +0100 |
commit | ebfc1fe827bdc1058d70ca727bea580d1d1bd73a (patch) | |
tree | cd4304e71d041884f0d1acebc77812f5ff6d993f /src/lib/ndpi_main.c | |
parent | d398f232beca613b16cb6cb26214c8fc917a7d17 (diff) |
Minor cleanup
Diffstat (limited to 'src/lib/ndpi_main.c')
-rw-r--r-- | src/lib/ndpi_main.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c index f678416a8..ffb38b1cc 100644 --- a/src/lib/ndpi_main.c +++ b/src/lib/ndpi_main.c @@ -2173,12 +2173,15 @@ int ndpi_get_patricia_stats(struct ndpi_detection_module_struct *ndpi_struct, case NDPI_PTREE_RISK_MASK: ndpi_patricia_get_stats((ndpi_patricia_tree_t *)ndpi_struct->ip_risk_mask_ptree, stats); return 0; + case NDPI_PTREE_RISK: ndpi_patricia_get_stats((ndpi_patricia_tree_t *)ndpi_struct->ip_risk_ptree, stats); return 0; + case NDPI_PTREE_PROTOCOLS: ndpi_patricia_get_stats((ndpi_patricia_tree_t *)ndpi_struct->protocols_ptree, stats); return 0; + default: return -1; } @@ -2334,7 +2337,7 @@ u_int16_t ndpi_network_port_ptree_match(struct ndpi_detection_module_struct *ndp if(node) { int i; - for(i=0; i<2; i++) { + for(i=0; i<UV16_MAX_USER_VALUES; i++) { if((node->value.u.uv16[i].additional_user_value == 0) || (node->value.u.uv16[i].additional_user_value == port)) return(node->value.u.uv16[i].user_value); @@ -2423,7 +2426,7 @@ int ndpi_load_ipv4_ptree(struct ndpi_detection_module_struct *ndpi_str, if((node = add_to_ptree(ndpi_str->protocols_ptree, AF_INET, &pin, cidr ? atoi(cidr) : 32 /* bits */)) != NULL) { u_int i, found = 0; - for(i=0; i<2; i++) { + for(i=0; i<UV16_MAX_USER_VALUES; i++) { if(node->value.u.uv16[i].user_value == 0) { node->value.u.uv16[i].user_value = protocol_id, node->value.u.uv16[i].additional_user_value = 0 /* port */; found = 1; @@ -2453,9 +2456,10 @@ static void ndpi_init_ptree_ipv4(struct ndpi_detection_module_struct *ndpi_str, pin.s_addr = htonl(host_list[i].network); if((node = add_to_ptree(ptree, AF_INET, &pin, host_list[i].cidr /* bits */)) != NULL) { - /* Two main cases: - 1) ip -> protocol: uv16[0].user_value = protocol; uv16[0].additional_user_value = 0; - 2) ip -> risk: uv16[0].user_value = risk; uv16[0].additional_user_value = 0; + /* + Two main cases: + 1) ip -> protocol: uv16[0].user_value = protocol; uv16[0].additional_user_value = 0; + 2) ip -> risk: uv16[0].user_value = risk; uv16[0].additional_user_value = 0; */ node->value.u.uv16[0].user_value = host_list[i].value, node->value.u.uv16[0].additional_user_value = 0; } @@ -2502,7 +2506,7 @@ static int ndpi_add_host_ip_subprotocol(struct ndpi_detection_module_struct *ndp if((node = add_to_ptree(ndpi_str->protocols_ptree, AF_INET, &pin, bits)) != NULL) { int i; - for(i=0; i<2; i++) { + for(i=0; i<UV16_MAX_USER_VALUES; i++) { if(node->value.u.uv16[i].user_value == 0) { node->value.u.uv16[i].user_value = protocol_id, node->value.u.uv16[i].additional_user_value = htons(port); return(0); |