Fixed bug that prevented (due to endianess) to properly match hosts

Added tests for skype detection
This commit is contained in:
Luca Deri
2015-05-19 12:30:44 +02:00
parent ad28d5ff7b
commit 993665726a
4 changed files with 32 additions and 3 deletions
+5 -2
View File
@@ -72,12 +72,14 @@ static ndpi_network host_protocol_list[] = {
{ 0x6CA0A000 /* 108.160.160.0 */, 20, NDPI_PROTOCOL_DROPBOX },
/*
Skype
Skype (Microsoft CDN)
157.56.0.0/14, 157.60.0.0/16, 157.54.0.0/15
111.221.64.0 - 111.221.127.255
*/
{ 0x9D380000 /* 157.56.0.0 */, 14, NDPI_PROTOCOL_SKYPE },
{ 0x9D3C0000 /* 157.60.0.0 */, 16, NDPI_PROTOCOL_SKYPE },
{ 0x9D360000 /* 157.54.0.0/ */, 15, NDPI_PROTOCOL_SKYPE },
{ 0x9D360000 /* 157.54.0.0 */, 15, NDPI_PROTOCOL_SKYPE },
{ 0x6FDD4000 /* 111.221.64.0 */, 18, NDPI_PROTOCOL_SKYPE },
/*
Google
@@ -258,6 +260,7 @@ static ndpi_network host_protocol_list[] = {
{ 0xD820F200, 24, NDPI_PROTOCOL_SKYPE },
{ 0xD821F000, 22, NDPI_PROTOCOL_SKYPE },
{ 0xD4A10800, 24, NDPI_PROTOCOL_SKYPE },
{ 0x012A1231, 32, NDPI_PROTOCOL_TOR },
{ 0x01E69FA1, 32, NDPI_PROTOCOL_TOR },
{ 0x020DE985, 32, NDPI_PROTOCOL_TOR },
+3 -1
View File
@@ -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;
}
+13
View File
@@ -0,0 +1,13 @@
Unknown 409 49221 18
DNS 8 807 4
MDNS 8 1736 2
NTP 2 180 1
SSDP 101 38156 6
ICMP 8 656 1
IGMP 5 258 4
SSL 20 1516 1
DropBox 38 17948 5
Skype 2362 501011 246
Apple 15 2045 2
AppleiCloud 88 20520 2
Spotify 5 430 1
+11
View File
@@ -0,0 +1,11 @@
Unknown 241 60170 16
DNS 6 627 3
MDNS 3 400 2
NetBIOS 22 3106 7
SSDP 40 14100 3
ICMP 4 328 1
IGMP 4 226 4
SSL 22 1444 3
DropBox 16 7342 5
Skype 1637 379382 221
Apple 84 20699 2