FreeCalypso > hg > rtp-debug-utils
annotate rtp-gsmfr-dump.c @ 3:50aa973a91ef
new program rtp-gsmfr-dump
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 16 Apr 2023 06:43:18 +0000 |
parents | rtp-gsmfr-extr.c@210dfa39f573 |
children | 7c85a7a913f7 |
rev | line source |
---|---|
0
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
3
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
2 * This program is a combination of rtp-gsmfr-extr and gsmrec-dump into |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
3 * one step: it reads a pcap file, extracts packets belonging to a |
0
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * particular RTP stream as identified by a source or destination |
3
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
5 * IP:port, verifies that an unbroken RTP stream is present, which is |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
6 * expected to be in GSM FR or EFR codec, but instead of writing this |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
7 * FR/EFR frame stream to a gsmx file, decodes it like gsmrec-dump. |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
8 * |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
9 * The advantage of this program over running rtp-gsmfr-extr followed |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
10 * by gsmrec-dump is that TRAUlike Extension Headers (if present) are |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
11 * dumped for analysis, rather than discarded. |
0
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 */ |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include <sys/types.h> |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include <sys/socket.h> |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #include <netinet/in.h> |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 #include <arpa/inet.h> |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 #include <stdio.h> |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 #include <stdlib.h> |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 #include <string.h> |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 #include <strings.h> |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 #include <pcap/pcap.h> |
3
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
23 #include <gsm.h> |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
24 #include <gsm_efr.h> |
0
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 static pcap_t *pcap; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 static in_addr_t match_ip_addr; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 static u_short match_udp_port; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 static unsigned iphdr_addr_offset, udphdr_port_offset; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 static unsigned link_hdr_len, ethertype_offset; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 static int stream_init_flag; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 static unsigned last_seq, last_tstamp, stream_ssrc; |
3
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
33 static gsm dummy_state; |
0
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 static void |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 check_dl_type() |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 int dltype; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 dltype = pcap_datalink(pcap); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 switch (dltype) { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 case DLT_EN10MB: |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 link_hdr_len = 14; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 ethertype_offset = 12; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 break; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 case DLT_RAW: |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 link_hdr_len = 0; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 break; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 case DLT_LINUX_SLL: |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 link_hdr_len = 16; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 ethertype_offset = 14; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 break; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 default: |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 fprintf(stderr, "error: unsupported data link type %d\n", |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 dltype); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 exit(1); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 } |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 } |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 static void |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 rtp_stream_logic(rtp_hdr, pkt_idx) |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 u_char *rtp_hdr; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 unsigned pkt_idx; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 unsigned cur_seq, cur_tstamp, cur_ssrc; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 cur_seq = (rtp_hdr[2] << 8) | rtp_hdr[3]; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 cur_tstamp = (rtp_hdr[4] << 24) | (rtp_hdr[5] << 16) | |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 (rtp_hdr[6] << 8) | rtp_hdr[7]; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 cur_ssrc = (rtp_hdr[8] << 24) | (rtp_hdr[9] << 16) | |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 (rtp_hdr[10] << 8) | rtp_hdr[11]; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 if (stream_init_flag) { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 if (cur_ssrc != stream_ssrc) { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 fprintf(stderr, |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 "error in packet #%u: SSRC change from 0x%08X to 0x%08X\n", |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 pkt_idx, stream_ssrc, cur_ssrc); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 exit(1); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 } |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 if (cur_seq != last_seq + 1 && |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 (cur_seq != 0 || last_seq != 0xFFFF)) { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 fprintf(stderr, |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 "error in packet #%u: seq break from 0x%04X to 0x%04X\n", |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 pkt_idx, last_seq, cur_seq); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 exit(1); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 } |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 if (cur_tstamp != last_tstamp + 160) { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 fprintf(stderr, |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 "error in packet #%u: timestamp break from 0x%08X to 0x%08X\n", |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 pkt_idx, last_tstamp, cur_tstamp); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 exit(1); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 } |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 } else { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 stream_init_flag = 1; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 stream_ssrc = cur_ssrc; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 } |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 last_seq = cur_seq; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 last_tstamp = cur_tstamp; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 } |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 static void |
3
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
101 process_payload(payload, payload_len) |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
102 u_char *payload; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
103 unsigned payload_len; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
104 { |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
105 gsm_signal params[76]; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
106 int i, j, n; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
107 |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
108 printf("seq 0x%04X ts 0x%08X: ", last_seq, last_tstamp); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
109 switch (payload_len) { |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
110 case 0: |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
111 printf("zero-length payload\n"); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
112 return; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
113 case 1: |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
114 if ((payload[0] & 0xF6) != 0xE6) |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
115 break; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
116 printf("TEH 0x%02X\n", payload[0]); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
117 return; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
118 case 2: |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
119 if (payload[0] != 0xBF) |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
120 break; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
121 printf("old BFI TAF=%u\n", payload[1] & 1); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
122 return; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
123 case 31: |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
124 if ((payload[0] & 0xF0) != 0xC0) |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
125 break; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
126 printf("std EFR SID=%d LPC", EFR_sid_classify(payload)); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
127 EFR_frame2params(payload, params); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
128 print_efr: |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
129 n = 0; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
130 for (i = 0; i < 5; i++) |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
131 printf(" %d", params[n++]); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
132 putchar('\n'); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
133 for (i = 0; i < 4; i++) { |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
134 putchar(' '); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
135 for (j = 0; j < 13; j++) |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
136 printf(" %d", params[n++]); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
137 putchar('\n'); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
138 } |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
139 return; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
140 case 32: |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
141 if ((payload[0] & 0xF4) != 0xE0) |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
142 break; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
143 if ((payload[1] & 0xF0) != 0xC0) |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
144 break; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
145 printf("TEH 0x%02X EFR SID=%d LPC", payload[0], |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
146 EFR_sid_classify(payload+1)); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
147 EFR_frame2params(payload+1, params); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
148 goto print_efr; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
149 case 33: |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
150 if ((payload[0] & 0xF0) != 0xD0) |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
151 break; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
152 fputs("std FR", stdout); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
153 gsm_explode(dummy_state, payload, params); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
154 print_fr: |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
155 n = 0; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
156 for (i = 0; i < 8; i++) |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
157 printf(" %d", params[n++]); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
158 putchar('\n'); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
159 for (i = 0; i < 4; i++) { |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
160 putchar(' '); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
161 for (j = 0; j < 17; j++) |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
162 printf(" %d", params[n++]); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
163 putchar('\n'); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
164 } |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
165 return; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
166 case 34: |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
167 if ((payload[0] & 0xF4) != 0xE0) |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
168 break; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
169 if ((payload[1] & 0xF0) != 0xD0) |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
170 break; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
171 printf("TEH 0x%02X FR", payload[0]); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
172 gsm_explode(dummy_state, payload+1, params); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
173 goto print_fr; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
174 } |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
175 printf("unknown payload format, length=%u\n", payload_len); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
176 } |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
177 |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
178 static void |
0
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 process_packet(pkt, caplen, pkt_idx) |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 u_char *pkt; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 unsigned caplen, pkt_idx; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 unsigned udplen, payload_len; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 if (caplen < link_hdr_len + 28) |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 return; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 if (link_hdr_len) { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 if (pkt[ethertype_offset] != 0x08) |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 return; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 if (pkt[ethertype_offset+1] != 0x00) |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 return; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 pkt += link_hdr_len; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 caplen -= link_hdr_len; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 } |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 /* check IP header */ |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 if (pkt[0] != 0x45) |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 return; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 if (pkt[9] != 17) /* UDP */ |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 return; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 if (bcmp(pkt + iphdr_addr_offset, &match_ip_addr, 4)) |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 return; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 /* check UDP header */ |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 if (bcmp(pkt + 20 + udphdr_port_offset, &match_udp_port, 2)) |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 return; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 /* it is our target - now scrutinize it */ |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 udplen = (pkt[24] << 8) | pkt[25]; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 if (caplen < udplen + 20) { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 fprintf(stderr, |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 "error: packet #%u is truncated in the capture\n", |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 pkt_idx); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 exit(1); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 } |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 if (udplen < 20) { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 fprintf(stderr, |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 "error in packet #%u: UDP length is too short for RTP header\n", |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 pkt_idx); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 exit(1); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 } |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
219 if (pkt[28] != 0x80) { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
220 fprintf(stderr, |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
221 "error in packet #%u: unsupported RTP header structure\n", |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
222 pkt_idx); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 exit(1); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 } |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 rtp_stream_logic(pkt + 28, pkt_idx); |
3
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
226 process_payload(pkt + 40, udplen - 20); |
0
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 } |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 main(argc, argv) |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
230 char **argv; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
231 { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
232 char errbuf[PCAP_ERRBUF_SIZE]; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
233 u_char *pkt; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
234 struct pcap_pkthdr pkthdr; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
235 unsigned pkt_idx; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
236 |
3
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
237 if (argc != 5) { |
0
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
238 fprintf(stderr, |
3
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
239 "usage: %s pcap-file src|dest ip-addr udp-port\n", |
0
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
240 argv[0]); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
241 exit(1); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
242 } |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
243 pcap = pcap_open_offline(argv[1], errbuf); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
244 if (!pcap) { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
245 fprintf(stderr, "%s: %s\n", argv[1], errbuf); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
246 exit(1); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
247 } |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
248 check_dl_type(); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
249 if (!strcmp(argv[2], "src")) { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
250 iphdr_addr_offset = 12; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
251 udphdr_port_offset = 0; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
252 } else if (!strcmp(argv[2], "dest")) { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
253 iphdr_addr_offset = 16; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
254 udphdr_port_offset = 2; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
255 } else { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
256 fprintf(stderr, |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 "error: direction argument must be \"src\" or \"dest\"\n"); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 exit(1); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 } |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
260 match_ip_addr = inet_addr(argv[3]); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
261 if (match_ip_addr == INADDR_NONE) { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
262 fprintf(stderr, "error: IP address argument is invalid\n"); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
263 exit(1); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
264 } |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
265 match_udp_port = htons(strtoul(argv[4], 0, 0)); |
3
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
266 dummy_state = gsm_create(); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
267 if (!dummy_state) { |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
268 fprintf(stderr, "gsm_create() failed!\n"); |
0
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
269 exit(1); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
270 } |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
271 for (pkt_idx = 0; ; pkt_idx++) { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
272 pkt = pcap_next(pcap, &pkthdr); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
273 if (!pkt) |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
274 break; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
275 process_packet(pkt, (unsigned) pkthdr.caplen, pkt_idx); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
276 } |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
277 if (!stream_init_flag) { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
278 fprintf(stderr, "error: specified RTP stream not found\n"); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
279 exit(1); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
280 } |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
281 exit(0); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
282 } |