Fix for #218
This commit is contained in:
@@ -29,7 +29,6 @@
|
|||||||
|
|
||||||
#define MAX_NUM_STUN_PKTS 10
|
#define MAX_NUM_STUN_PKTS 10
|
||||||
|
|
||||||
|
|
||||||
struct stun_packet_header {
|
struct stun_packet_header {
|
||||||
u_int16_t msg_type, msg_len;
|
u_int16_t msg_type, msg_len;
|
||||||
u_int32_t cookie;
|
u_int32_t cookie;
|
||||||
@@ -54,6 +53,7 @@ static ndpi_int_stun_t ndpi_int_check_stun(struct ndpi_detection_module_struct *
|
|||||||
u_int8_t *is_lync) {
|
u_int8_t *is_lync) {
|
||||||
u_int16_t msg_type, msg_len;
|
u_int16_t msg_type, msg_len;
|
||||||
struct stun_packet_header *h = (struct stun_packet_header*)payload;
|
struct stun_packet_header *h = (struct stun_packet_header*)payload;
|
||||||
|
u_int8_t can_this_be_whatsapp_voice = 1;
|
||||||
|
|
||||||
if(payload_length < sizeof(struct stun_packet_header)) {
|
if(payload_length < sizeof(struct stun_packet_header)) {
|
||||||
if(flow->num_stun_udp_pkts > 0) {
|
if(flow->num_stun_udp_pkts > 0) {
|
||||||
@@ -91,6 +91,12 @@ static ndpi_int_stun_t ndpi_int_check_stun(struct ndpi_detection_module_struct *
|
|||||||
u_int16_t len = ntohs(*((u_int16_t*)&payload[offset+2]));
|
u_int16_t len = ntohs(*((u_int16_t*)&payload[offset+2]));
|
||||||
|
|
||||||
switch(attribute) {
|
switch(attribute) {
|
||||||
|
case 0x0008: /* Message Integrity */
|
||||||
|
case 0x0020: /* XOR-MAPPED-ADDRESSES */
|
||||||
|
case 0x4002:
|
||||||
|
/* These are the only messages apparently whatsapp voice can use */
|
||||||
|
break;
|
||||||
|
|
||||||
case 0x8054: /* Candidate Identifier */
|
case 0x8054: /* Candidate Identifier */
|
||||||
if((len == 4)
|
if((len == 4)
|
||||||
&& (payload[offset+4] == 0x31)
|
&& (payload[offset+4] == 0x31)
|
||||||
@@ -112,6 +118,11 @@ static ndpi_int_stun_t ndpi_int_check_stun(struct ndpi_detection_module_struct *
|
|||||||
return(NDPI_IS_STUN);
|
return(NDPI_IS_STUN);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
/* This means this STUN packet cannot be confused with whatsapp voice */
|
||||||
|
can_this_be_whatsapp_voice = 0;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
offset += len + 4;
|
offset += len + 4;
|
||||||
}
|
}
|
||||||
@@ -227,7 +238,8 @@ static ndpi_int_stun_t ndpi_int_check_stun(struct ndpi_detection_module_struct *
|
|||||||
return NDPI_IS_NOT_STUN;
|
return NDPI_IS_NOT_STUN;
|
||||||
|
|
||||||
udp_stun_found:
|
udp_stun_found:
|
||||||
flow->num_stun_udp_pkts++;
|
if(can_this_be_whatsapp_voice)
|
||||||
|
flow->num_stun_udp_pkts++;
|
||||||
|
|
||||||
return((flow->num_stun_udp_pkts < MAX_NUM_STUN_PKTS) ? NDPI_IS_NOT_STUN : NDPI_IS_STUN);
|
return((flow->num_stun_udp_pkts < MAX_NUM_STUN_PKTS) ? NDPI_IS_NOT_STUN : NDPI_IS_STUN);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user