blob: f6f8d6ebb92402d6575232460bf4a86fe56ff917 [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;
41
Holger Hans Peter Freyther6aa882b2010-08-03 14:35:50 +000042 uint32_t orig_ssrc;
43 uint32_t ssrc;
Holger Hans Peter Freyther31868922010-08-03 11:59:04 +000044 uint16_t seq_no;
45 int lost_no;
Holger Hans Peter Freyther6aa882b2010-08-03 14:35:50 +000046 int seq_offset;
47 uint32_t last_timestamp;
48 int32_t timestamp_offset;
Holger Hans Peter Freyther31868922010-08-03 11:59:04 +000049};
Holger Hans Peter Freyther98a38772010-08-03 02:27:21 +080050
Holger Hans Peter Freyther7bdc6372010-02-20 21:21:02 +010051struct mgcp_endpoint {
52 int ci;
53 char *callid;
54 char *local_options;
55 int conn_mode;
Holger Hans Peter Freytherc597a4e2010-08-03 02:57:02 +080056 int orig_mode;
Holger Hans Peter Freyther7bdc6372010-02-20 21:21:02 +010057
Holger Hans Peter Freytheref6bb252010-02-26 13:41:22 +010058 int bts_payload_type;
59 int net_payload_type;
60
Holger Hans Peter Freyther7bdc6372010-02-20 21:21:02 +010061 /* the local rtp port we are binding to */
62 int rtp_port;
63
64 /*
65 * RTP mangling:
66 * - we get RTP and RTCP to us and need to forward to the BTS
67 * - we get RTP and RTCP from the BTS and forward to the network
68 */
69 struct bsc_fd local_rtp;
70 struct bsc_fd local_rtcp;
71
72 struct in_addr remote;
73 struct in_addr bts;
74
75 /* in network byte order */
76 int net_rtp, net_rtcp;
77 int bts_rtp, bts_rtcp;
78
79 /* backpointer */
80 struct mgcp_config *cfg;
Holger Hans Peter Freytherb4b135e2010-04-07 09:37:17 +020081
82 /* statistics */
83 unsigned int in_bts;
84 unsigned int in_remote;
Holger Hans Peter Freyther380b8712010-07-29 02:38:39 +080085
86 /* sequence bits */
Holger Hans Peter Freyther31868922010-08-03 11:59:04 +000087 struct mgcp_rtp_state net_state;
88 struct mgcp_rtp_state bts_state;
Holger Hans Peter Freyther7bdc6372010-02-20 21:21:02 +010089};
90
91#define ENDPOINT_NUMBER(endp) abs(endp - endp->cfg->endpoints)
92
Holger Hans Peter Freytherf2f15912010-04-01 03:27:04 +020093struct mgcp_msg_ptr {
94 unsigned int start;
95 unsigned int length;
96};
97
98int mgcp_analyze_header(struct mgcp_config *cfg, struct msgb *msg,
99 struct mgcp_msg_ptr *ptr, int size,
100 const char **transaction_id, struct mgcp_endpoint **endp);
Holger Hans Peter Freytherb844b872010-04-21 21:25:13 +0800101int mgcp_send_dummy(struct mgcp_endpoint *endp);
Holger Hans Peter Freytherf2f15912010-04-01 03:27:04 +0200102
Holger Hans Peter Freyther7bdc6372010-02-20 21:21:02 +0100103#endif