forked from RakshaBangera/dpi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rtp.c
40 lines (28 loc) · 753 Bytes
/
rtp.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<stdio.h>
#include<sys/types.h>
#include<netinet/in.h>
#include"types.h"
int check_rtp(unsigned char *p_current, unsigned int payload_len)
{
int version1 = (*p_current) & 0x80;
int version2 = (*p_current) & 0x40;
int payload_type = 0;
int rtp = 0;
if (debug_verbose) {
printf("Matching signature for RTP...\n");
}
if (payload_len < 12) {
return 0;
}
payload_type = *(p_current + 1) & 0x7F;
if ( version1 && !version2 && payload_type >=0 && payload_type < 128) {
rtp = 1;
}
if (debug_verbose && rtp) {
printf("Signature match succeeded\n\n");
}
if (debug_verbose && !rtp) {
printf("Signature match failed\n\n");
}
return rtp;
}