blob: 7f999a35d70e06e6a6ec7b5295d76c0b6adfb558 [file] [log] [blame]
Holger Hans Peter Freyther7bdc6372010-02-20 21:21:02 +01001/* MGCP Private Data */
2
3/*
4 * (C) 2009-2010 by Holger Hans Peter Freyther <zecke@selfish.org>
5 * (C) 2009-2010 by On-Waves
6 * All Rights Reserved
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 */
23
24#ifndef OPENBSC_MGCP_DATA_H
25#define OPENBSC_MGCP_DATA_H
26
Holger Hans Peter Freyther1ebad742010-02-26 20:16:37 +010027#include <osmocore/select.h>
Holger Hans Peter Freyther7bdc6372010-02-20 21:21:02 +010028
29#define CI_UNUSED 0
30
Holger Hans Peter Freyther98a38772010-08-03 02:27:21 +080031enum mgcp_connection_mode {
32 MGCP_CONN_NONE = 0,
33 MGCP_CONN_RECV_ONLY = 1,
34 MGCP_CONN_SEND_ONLY = 2,
35 MGCP_CONN_RECV_SEND = MGCP_CONN_RECV_ONLY | MGCP_CONN_SEND_ONLY,
36 MGCP_CONN_LOOPBACK = 4,
37};
38
Holger Hans Peter Freyther31868922010-08-03 11:59:04 +000039struct mgcp_rtp_state {
40 int initialized;
Holger Hans Peter Freyther5c1e6cf2010-08-03 15:36:57 +000041 int patch;
Holger Hans Peter Freyther31868922010-08-03 11:59:04 +000042
Holger Hans Peter Freyther6aa882b2010-08-03 14:35:50 +000043 uint32_t orig_ssrc;
44 uint32_t ssrc;
Holger Hans Peter Freyther31868922010-08-03 11:59:04 +000045 uint16_t seq_no;
46 int lost_no;
Holger Hans Peter Freyther6aa882b2010-08-03 14:35:50 +000047 int seq_offset;
48 uint32_t last_timestamp;
49 int32_t timestamp_offset;
Holger Hans Peter Freyther31868922010-08-03 11:59:04 +000050};
Holger Hans Peter Freyther98a38772010-08-03 02:27:21 +080051
Holger Hans Peter Freythera17d7012010-08-05 01:34:51 +080052struct mgcp_rtp_end {
53 /* statistics */
54 unsigned int packets;
55 struct in_addr addr;
56
57 /* in network byte order */
58 int rtp_port, rtcp_port;
59
60 int payload_type;
Holger Hans Peter Freyther58ff2192010-08-05 03:08:35 +080061
62 int local_port;
Holger Hans Peter Freythera17d7012010-08-05 01:34:51 +080063};
64
Holger Hans Peter Freyther7bdc6372010-02-20 21:21:02 +010065struct mgcp_endpoint {
66 int ci;
67 char *callid;
68 char *local_options;
69 int conn_mode;
Holger Hans Peter Freytherc597a4e2010-08-03 02:57:02 +080070 int orig_mode;
Holger Hans Peter Freyther7bdc6372010-02-20 21:21:02 +010071
Holger Hans Peter Freyther7bdc6372010-02-20 21:21:02 +010072 /*
73 * RTP mangling:
74 * - we get RTP and RTCP to us and need to forward to the BTS
75 * - we get RTP and RTCP from the BTS and forward to the network
76 */
77 struct bsc_fd local_rtp;
78 struct bsc_fd local_rtcp;
79
Holger Hans Peter Freyther7bdc6372010-02-20 21:21:02 +010080 /* backpointer */
81 struct mgcp_config *cfg;
Holger Hans Peter Freytherb4b135e2010-04-07 09:37:17 +020082
Holger Hans Peter Freythera17d7012010-08-05 01:34:51 +080083 /* port status for bts/net */
84 struct mgcp_rtp_end bts_end;
85 struct mgcp_rtp_end net_end;
Holger Hans Peter Freyther380b8712010-07-29 02:38:39 +080086
87 /* sequence bits */
Holger Hans Peter Freyther31868922010-08-03 11:59:04 +000088 struct mgcp_rtp_state net_state;
89 struct mgcp_rtp_state bts_state;
Holger Hans Peter Freyther7bdc6372010-02-20 21:21:02 +010090};
91
92#define ENDPOINT_NUMBER(endp) abs(endp - endp->cfg->endpoints)
93
Holger Hans Peter Freytherf2f15912010-04-01 03:27:04 +020094struct mgcp_msg_ptr {
95 unsigned int start;
96 unsigned int length;
97};
98
99int mgcp_analyze_header(struct mgcp_config *cfg, struct msgb *msg,
100 struct mgcp_msg_ptr *ptr, int size,
101 const char **transaction_id, struct mgcp_endpoint **endp);
Holger Hans Peter Freytherb844b872010-04-21 21:25:13 +0800102int mgcp_send_dummy(struct mgcp_endpoint *endp);
Holger Hans Peter Freytherbb89aa12010-08-05 03:29:33 +0800103int mgcp_bind_bts_rtp_port(struct mgcp_endpoint *endp, int rtp_port);
Holger Hans Peter Freytherf2f15912010-04-01 03:27:04 +0200104
Holger Hans Peter Freyther7bdc6372010-02-20 21:21:02 +0100105#endif