diff options
author | Luca Deri <deri@ntop.org> | 2015-05-19 12:30:44 +0200 |
---|---|---|
committer | Luca Deri <deri@ntop.org> | 2015-05-19 12:30:44 +0200 |
commit | 993665726aa807ff64ca28776af6aee43b19b66d (patch) | |
tree | 948570b748786479da278afa2bb57b57a036044f /src/lib/ndpi_main.c | |
parent | ad28d5ff7b5d5793172032281a9527bac4e64a62 (diff) |
Fixed bug that prevented (due to endianess) to properly match hosts
Added tests for skype detection
Diffstat (limited to 'src/lib/ndpi_main.c')
-rw-r--r-- | src/lib/ndpi_main.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c index 7719f766e..8d39d8115 100644 --- a/src/lib/ndpi_main.c +++ b/src/lib/ndpi_main.c @@ -1677,6 +1677,7 @@ static int fill_prefix_v4(prefix_t *p, struct in_addr *a, int b, int mb) { if(b < 0 || b > mb) return(-1); + memset(p, 0, sizeof(prefix_t)); memcpy(&p->add.sin, a, (mb+7)/8); p->family = AF_INET; p->bitlen = b; @@ -1692,6 +1693,7 @@ u_int16_t ndpi_network_ptree_match(struct ndpi_detection_module_struct *ndpi_str prefix_t prefix; patricia_node_t *node; + pin->s_addr = ntohl(pin->s_addr); /* Make sure all in network byte order otherwise compares wont work */ fill_prefix_v4(&prefix, pin, 32, ((patricia_tree_t*)ndpi_struct->protocols_ptree)->maxbits); node = ndpi_patricia_search_best(ndpi_struct->protocols_ptree, &prefix); @@ -1755,7 +1757,7 @@ static void ndpi_init_ptree_ipv4(struct ndpi_detection_module_struct *ndpi_str, struct in_addr pin; patricia_node_t *node; - pin.s_addr = host_list[i].network; + pin.s_addr = ntohl(host_list[i].network); if((node = add_to_ptree(ptree, AF_INET, &pin, host_list[i].cidr /* bits */)) != NULL) node->value.user_value = host_list[i].value; } |