blob: 12e3ad9b19493d6cf377c7c13918306fde13ea88 [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
Holger Hans Peter Freytherc4921272010-08-05 03:37:22 +080062 /*
63 * Each end has a socket...
64 */
65 struct bsc_fd rtp;
66 struct bsc_fd rtcp;
67
Holger Hans Peter Freyther58ff2192010-08-05 03:08:35 +080068 int local_port;
Holger Hans Peter Freytherf138f912010-08-05 08:08:17 +080069 int local_alloc;
Holger Hans Peter Freythera17d7012010-08-05 01:34:51 +080070};
71
Holger Hans Peter Freyther260d6ed2010-08-06 01:12:21 +080072enum {
73 MGCP_TAP_BTS_IN,
74 MGCP_TAP_BTS_OUT,
75 MGCP_TAP_NET_IN,
76 MGCP_TAP_NET_OUT,
77
78 /* last element */
79 MGCP_TAP_COUNT
80};
81
82struct mgcp_rtp_tap {
83 int enabled;
84 struct sockaddr_in forward;
85};
86
Holger Hans Peter Freyther7bdc6372010-02-20 21:21:02 +010087struct mgcp_endpoint {
Holger Hans Peter Freyther39a97e22010-08-06 18:03:11 +080088 int allocated;
Holger Hans Peter Freyther46340132010-08-06 08:26:54 +080089 uint32_t ci;
Holger Hans Peter Freyther7bdc6372010-02-20 21:21:02 +010090 char *callid;
91 char *local_options;
92 int conn_mode;
Holger Hans Peter Freytherc597a4e2010-08-03 02:57:02 +080093 int orig_mode;
Holger Hans Peter Freyther7bdc6372010-02-20 21:21:02 +010094
Holger Hans Peter Freyther7bdc6372010-02-20 21:21:02 +010095 /* backpointer */
96 struct mgcp_config *cfg;
Holger Hans Peter Freytherb4b135e2010-04-07 09:37:17 +020097
Holger Hans Peter Freythera17d7012010-08-05 01:34:51 +080098 /* port status for bts/net */
99 struct mgcp_rtp_end bts_end;
100 struct mgcp_rtp_end net_end;
Holger Hans Peter Freyther380b8712010-07-29 02:38:39 +0800101
102 /* sequence bits */
Holger Hans Peter Freyther31868922010-08-03 11:59:04 +0000103 struct mgcp_rtp_state net_state;
104 struct mgcp_rtp_state bts_state;
Holger Hans Peter Freyther6357a8e2010-08-05 12:07:00 +0000105
106 /* SSRC/seq/ts patching for loop */
107 int allow_patch;
Holger Hans Peter Freyther260d6ed2010-08-06 01:12:21 +0800108
109 /* tap for the endpoint */
110 struct mgcp_rtp_tap taps[MGCP_TAP_COUNT];
Holger Hans Peter Freyther7bdc6372010-02-20 21:21:02 +0100111};
112
113#define ENDPOINT_NUMBER(endp) abs(endp - endp->cfg->endpoints)
114
Holger Hans Peter Freytherf2f15912010-04-01 03:27:04 +0200115struct mgcp_msg_ptr {
116 unsigned int start;
117 unsigned int length;
118};
119
120int mgcp_analyze_header(struct mgcp_config *cfg, struct msgb *msg,
121 struct mgcp_msg_ptr *ptr, int size,
122 const char **transaction_id, struct mgcp_endpoint **endp);
Holger Hans Peter Freytherb844b872010-04-21 21:25:13 +0800123int mgcp_send_dummy(struct mgcp_endpoint *endp);
Holger Hans Peter Freytherbb89aa12010-08-05 03:29:33 +0800124int mgcp_bind_bts_rtp_port(struct mgcp_endpoint *endp, int rtp_port);
Holger Hans Peter Freyther314584a2010-08-05 04:10:21 +0800125int mgcp_bind_net_rtp_port(struct mgcp_endpoint *endp, int rtp_port);
Holger Hans Peter Freytherf138f912010-08-05 08:08:17 +0800126int mgcp_free_rtp_port(struct mgcp_rtp_end *end);
Holger Hans Peter Freytherf2f15912010-04-01 03:27:04 +0200127
Holger Hans Peter Freyther7bdc6372010-02-20 21:21:02 +0100128#endif