aboutsummaryrefslogtreecommitdiff
path: root/src/lib/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/protocols')
-rw-r--r--src/lib/protocols/line.c2
-rw-r--r--src/lib/protocols/rtp.c15
-rw-r--r--src/lib/protocols/stun.c2
3 files changed, 7 insertions, 12 deletions
diff --git a/src/lib/protocols/line.c b/src/lib/protocols/line.c
index da28e613b..933693ed9 100644
--- a/src/lib/protocols/line.c
+++ b/src/lib/protocols/line.c
@@ -83,7 +83,7 @@ static void ndpi_search_line(struct ndpi_detection_module_struct *ndpi_struct,
/* It might be a RTP/RTCP packet. Ignore it and keep looking for the
LINE packet numbers */
/* Basic RTP detection */
- rc = is_rtp_or_rtcp(ndpi_struct, NULL);
+ rc = is_rtp_or_rtcp(ndpi_struct, packet->payload, packet->payload_packet_len, NULL);
if(rc == IS_RTCP || rc == IS_RTP) {
if(flow->packet_counter < 10) {
NDPI_LOG_DBG(ndpi_struct, "Probably RTP; keep looking for LINE\n");
diff --git a/src/lib/protocols/rtp.c b/src/lib/protocols/rtp.c
index b543e8b99..d8c09be3a 100644
--- a/src/lib/protocols/rtp.c
+++ b/src/lib/protocols/rtp.c
@@ -83,23 +83,16 @@ static int is_valid_rtcp_payload_type(uint8_t type) {
return (type >= 192 && type <= 213);
}
-int is_rtp_or_rtcp(struct ndpi_detection_module_struct *ndpi_struct, u_int16_t *seq)
+int is_rtp_or_rtcp(struct ndpi_detection_module_struct *ndpi_struct,
+ const u_int8_t *payload, u_int16_t payload_len, u_int16_t *seq)
{
- struct ndpi_packet_struct *packet = &ndpi_struct->packet;
u_int8_t csrc_count, ext_header;
u_int16_t ext_len;
u_int32_t min_len;
- const u_int8_t *payload = packet->payload;
- u_int16_t payload_len = packet->payload_packet_len;
if(payload_len < 2)
return NO_RTP_RTCP;
- if(packet->tcp != NULL) {
- payload_len -= 2;
- payload += 2; /* Skip the length field */
- }
-
if((payload[0] & 0xC0) != 0x80) { /* Version 2 */
NDPI_LOG_DBG(ndpi_struct, "Not version 2\n");
return NO_RTP_RTCP;
@@ -149,10 +142,12 @@ static void ndpi_rtp_search(struct ndpi_detection_module_struct *ndpi_struct,
u_int8_t is_rtp;
struct ndpi_packet_struct *packet = &ndpi_struct->packet;
const u_int8_t *payload = packet->payload;
+ u_int16_t payload_len = packet->payload_packet_len;
u_int16_t seq;
if(packet->tcp != NULL) {
payload += 2; /* Skip the length field */
+ payload_len -= 2;
}
NDPI_LOG_DBG(ndpi_struct, "search RTP (stage %d/%d)\n", flow->rtp_stage, flow->rtcp_stage);
@@ -169,7 +164,7 @@ static void ndpi_rtp_search(struct ndpi_detection_module_struct *ndpi_struct,
return;
}
- is_rtp = is_rtp_or_rtcp(ndpi_struct, &seq);
+ is_rtp = is_rtp_or_rtcp(ndpi_struct, payload, payload_len, &seq);
if(is_rtp == IS_RTP) {
if(flow->rtp_stage == 2) {
diff --git a/src/lib/protocols/stun.c b/src/lib/protocols/stun.c
index aca6540fc..877379abc 100644
--- a/src/lib/protocols/stun.c
+++ b/src/lib/protocols/stun.c
@@ -796,7 +796,7 @@ static int stun_search_again(struct ndpi_detection_module_struct *ndpi_struct,
NDPI_LOG_DBG(ndpi_struct, "QUIC range. Unexpected\n");
} else if(first_byte <= 191) {
- rtp_rtcp = is_rtp_or_rtcp(ndpi_struct, NULL);
+ rtp_rtcp = is_rtp_or_rtcp(ndpi_struct, packet->payload, packet->payload_packet_len, NULL);
if(rtp_rtcp == IS_RTP) {
NDPI_LOG_DBG(ndpi_struct, "RTP (dir %d)\n", packet->packet_direction);
NDPI_LOG_INFO(ndpi_struct, "Found RTP over STUN\n");