FreeCalypso > hg > rtp-debug-utils
annotate rtp-gsmfr-dump.c @ 9:c00510e1ae8b
new program udp-test-sink
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 10 Mar 2024 02:27:37 +0000 |
parents | 7c85a7a913f7 |
children |
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) { |
5
7c85a7a913f7
rtp-gsmfr-dump: treat stream discontinuities as non-fatal
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
74 printf( |
0
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); |
5
7c85a7a913f7
rtp-gsmfr-dump: treat stream discontinuities as non-fatal
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
77 } else if (cur_seq != last_seq + 1 && |
7c85a7a913f7
rtp-gsmfr-dump: treat stream discontinuities as non-fatal
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
78 (cur_seq != 0 || last_seq != 0xFFFF)) { |
7c85a7a913f7
rtp-gsmfr-dump: treat stream discontinuities as non-fatal
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
79 printf( |
0
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 "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
|
81 pkt_idx, last_seq, cur_seq); |
5
7c85a7a913f7
rtp-gsmfr-dump: treat stream discontinuities as non-fatal
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
82 } else if (cur_tstamp != last_tstamp + 160) { |
7c85a7a913f7
rtp-gsmfr-dump: treat stream discontinuities as non-fatal
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
83 printf( |
0
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 "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
|
85 pkt_idx, last_tstamp, cur_tstamp); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 } |
5
7c85a7a913f7
rtp-gsmfr-dump: treat stream discontinuities as non-fatal
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
87 } else |
0
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 stream_init_flag = 1; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 last_seq = cur_seq; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 last_tstamp = cur_tstamp; |
5
7c85a7a913f7
rtp-gsmfr-dump: treat stream discontinuities as non-fatal
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
91 stream_ssrc = cur_ssrc; |
0
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 } |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 static void |
3
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
95 process_payload(payload, payload_len) |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
96 u_char *payload; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
97 unsigned payload_len; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
98 { |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
99 gsm_signal params[76]; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
100 int i, j, n; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
101 |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
102 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
|
103 switch (payload_len) { |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
104 case 0: |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
105 printf("zero-length payload\n"); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
106 return; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
107 case 1: |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
108 if ((payload[0] & 0xF6) != 0xE6) |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
109 break; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
110 printf("TEH 0x%02X\n", payload[0]); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
111 return; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
112 case 2: |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
113 if (payload[0] != 0xBF) |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
114 break; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
115 printf("old BFI TAF=%u\n", payload[1] & 1); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
116 return; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
117 case 31: |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
118 if ((payload[0] & 0xF0) != 0xC0) |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
119 break; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
120 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
|
121 EFR_frame2params(payload, params); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
122 print_efr: |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
123 n = 0; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
124 for (i = 0; i < 5; i++) |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
125 printf(" %d", params[n++]); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
126 putchar('\n'); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
127 for (i = 0; i < 4; i++) { |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
128 putchar(' '); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
129 for (j = 0; j < 13; j++) |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
130 printf(" %d", params[n++]); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
131 putchar('\n'); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
132 } |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
133 return; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
134 case 32: |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
135 if ((payload[0] & 0xF4) != 0xE0) |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
136 break; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
137 if ((payload[1] & 0xF0) != 0xC0) |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
138 break; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
139 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
|
140 EFR_sid_classify(payload+1)); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
141 EFR_frame2params(payload+1, params); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
142 goto print_efr; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
143 case 33: |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
144 if ((payload[0] & 0xF0) != 0xD0) |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
145 break; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
146 fputs("std FR", stdout); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
147 gsm_explode(dummy_state, payload, params); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
148 print_fr: |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
149 n = 0; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
150 for (i = 0; i < 8; i++) |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
151 printf(" %d", params[n++]); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
152 putchar('\n'); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
153 for (i = 0; i < 4; i++) { |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
154 putchar(' '); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
155 for (j = 0; j < 17; j++) |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
156 printf(" %d", params[n++]); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
157 putchar('\n'); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
158 } |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
159 return; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
160 case 34: |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
161 if ((payload[0] & 0xF4) != 0xE0) |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
162 break; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
163 if ((payload[1] & 0xF0) != 0xD0) |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
164 break; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
165 printf("TEH 0x%02X FR", payload[0]); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
166 gsm_explode(dummy_state, payload+1, params); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
167 goto print_fr; |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
168 } |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
169 printf("unknown payload format, length=%u\n", payload_len); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
170 } |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
171 |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
172 static void |
0
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 process_packet(pkt, caplen, pkt_idx) |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 u_char *pkt; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 unsigned caplen, pkt_idx; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 unsigned udplen, payload_len; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 if (caplen < link_hdr_len + 28) |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 return; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 if (link_hdr_len) { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 if (pkt[ethertype_offset] != 0x08) |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 return; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 if (pkt[ethertype_offset+1] != 0x00) |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 return; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 pkt += link_hdr_len; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 caplen -= link_hdr_len; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 } |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 /* check IP header */ |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 if (pkt[0] != 0x45) |
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 if (pkt[9] != 17) /* UDP */ |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 return; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 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
|
195 return; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 /* check UDP header */ |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 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
|
198 return; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 /* it is our target - now scrutinize it */ |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 udplen = (pkt[24] << 8) | pkt[25]; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 if (caplen < udplen + 20) { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 fprintf(stderr, |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 "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
|
204 pkt_idx); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 exit(1); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 } |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 if (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 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
|
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 (pkt[28] != 0x80) { |
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: unsupported RTP header structure\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 rtp_stream_logic(pkt + 28, pkt_idx); |
3
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
220 process_payload(pkt + 40, udplen - 20); |
0
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
221 } |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
222 |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 main(argc, argv) |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 char **argv; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 char errbuf[PCAP_ERRBUF_SIZE]; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 u_char *pkt; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 struct pcap_pkthdr pkthdr; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 unsigned pkt_idx; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
230 |
3
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
231 if (argc != 5) { |
0
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
232 fprintf(stderr, |
3
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
233 "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
|
234 argv[0]); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
235 exit(1); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
236 } |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
237 pcap = pcap_open_offline(argv[1], errbuf); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
238 if (!pcap) { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
239 fprintf(stderr, "%s: %s\n", argv[1], errbuf); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
240 exit(1); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
241 } |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
242 check_dl_type(); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
243 if (!strcmp(argv[2], "src")) { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
244 iphdr_addr_offset = 12; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
245 udphdr_port_offset = 0; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
246 } else if (!strcmp(argv[2], "dest")) { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
247 iphdr_addr_offset = 16; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
248 udphdr_port_offset = 2; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
249 } else { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
250 fprintf(stderr, |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
251 "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
|
252 exit(1); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
253 } |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
254 match_ip_addr = inet_addr(argv[3]); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
255 if (match_ip_addr == INADDR_NONE) { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
256 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
|
257 exit(1); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 } |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 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
|
260 dummy_state = gsm_create(); |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
261 if (!dummy_state) { |
50aa973a91ef
new program rtp-gsmfr-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
262 fprintf(stderr, "gsm_create() failed!\n"); |
0
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 for (pkt_idx = 0; ; pkt_idx++) { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
266 pkt = pcap_next(pcap, &pkthdr); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
267 if (!pkt) |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
268 break; |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
269 process_packet(pkt, (unsigned) pkthdr.caplen, pkt_idx); |
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 if (!stream_init_flag) { |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
272 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
|
273 exit(1); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
274 } |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
275 exit(0); |
05ff0f7ac977
initial commit: split from gsm-codec-lib
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
276 } |