2010-02-20 20:21:02 +00:00
|
|
|
/* MGCP Private Data */
|
|
|
|
|
|
|
|
/*
|
2011-02-27 23:56:17 +00:00
|
|
|
* (C) 2009-2011 by Holger Hans Peter Freyther <zecke@selfish.org>
|
|
|
|
* (C) 2009-2011 by On-Waves
|
2010-02-20 20:21:02 +00:00
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2011-01-01 14:25:50 +00:00
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2010-02-20 20:21:02 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2011-01-01 14:25:50 +00:00
|
|
|
* GNU Affero General Public License for more details.
|
2010-02-20 20:21:02 +00:00
|
|
|
*
|
2011-01-01 14:25:50 +00:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-02-20 20:21:02 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef OPENBSC_MGCP_DATA_H
|
|
|
|
#define OPENBSC_MGCP_DATA_H
|
|
|
|
|
2011-03-22 15:47:59 +00:00
|
|
|
#include <osmocom/core/select.h>
|
2010-02-20 20:21:02 +00:00
|
|
|
|
|
|
|
#define CI_UNUSED 0
|
|
|
|
|
2010-08-02 18:27:21 +00:00
|
|
|
enum mgcp_connection_mode {
|
|
|
|
MGCP_CONN_NONE = 0,
|
|
|
|
MGCP_CONN_RECV_ONLY = 1,
|
|
|
|
MGCP_CONN_SEND_ONLY = 2,
|
|
|
|
MGCP_CONN_RECV_SEND = MGCP_CONN_RECV_ONLY | MGCP_CONN_SEND_ONLY,
|
|
|
|
MGCP_CONN_LOOPBACK = 4,
|
|
|
|
};
|
|
|
|
|
2011-02-27 23:56:17 +00:00
|
|
|
enum mgcp_trunk_type {
|
|
|
|
MGCP_TRUNK_VIRTUAL,
|
|
|
|
MGCP_TRUNK_E1,
|
|
|
|
};
|
|
|
|
|
2010-08-03 11:59:04 +00:00
|
|
|
struct mgcp_rtp_state {
|
|
|
|
int initialized;
|
2010-08-03 15:36:57 +00:00
|
|
|
int patch;
|
2010-08-03 11:59:04 +00:00
|
|
|
|
2010-08-03 14:35:50 +00:00
|
|
|
uint32_t orig_ssrc;
|
|
|
|
uint32_t ssrc;
|
2010-08-03 11:59:04 +00:00
|
|
|
uint16_t seq_no;
|
|
|
|
int lost_no;
|
2010-08-03 14:35:50 +00:00
|
|
|
int seq_offset;
|
|
|
|
uint32_t last_timestamp;
|
|
|
|
int32_t timestamp_offset;
|
2010-08-03 11:59:04 +00:00
|
|
|
};
|
2010-08-02 18:27:21 +00:00
|
|
|
|
2010-08-04 17:34:51 +00:00
|
|
|
struct mgcp_rtp_end {
|
|
|
|
/* statistics */
|
|
|
|
unsigned int packets;
|
|
|
|
struct in_addr addr;
|
|
|
|
|
|
|
|
/* in network byte order */
|
|
|
|
int rtp_port, rtcp_port;
|
|
|
|
|
|
|
|
int payload_type;
|
2010-08-04 19:08:35 +00:00
|
|
|
|
2010-08-04 19:37:22 +00:00
|
|
|
/*
|
|
|
|
* Each end has a socket...
|
|
|
|
*/
|
|
|
|
struct bsc_fd rtp;
|
|
|
|
struct bsc_fd rtcp;
|
|
|
|
|
2010-08-04 19:08:35 +00:00
|
|
|
int local_port;
|
2010-08-05 00:08:17 +00:00
|
|
|
int local_alloc;
|
2010-08-04 17:34:51 +00:00
|
|
|
};
|
|
|
|
|
2010-08-05 17:12:21 +00:00
|
|
|
enum {
|
|
|
|
MGCP_TAP_BTS_IN,
|
|
|
|
MGCP_TAP_BTS_OUT,
|
|
|
|
MGCP_TAP_NET_IN,
|
|
|
|
MGCP_TAP_NET_OUT,
|
|
|
|
|
|
|
|
/* last element */
|
|
|
|
MGCP_TAP_COUNT
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mgcp_rtp_tap {
|
|
|
|
int enabled;
|
|
|
|
struct sockaddr_in forward;
|
|
|
|
};
|
|
|
|
|
2010-02-20 20:21:02 +00:00
|
|
|
struct mgcp_endpoint {
|
2010-08-06 10:03:11 +00:00
|
|
|
int allocated;
|
2010-08-06 00:26:54 +00:00
|
|
|
uint32_t ci;
|
2010-02-20 20:21:02 +00:00
|
|
|
char *callid;
|
|
|
|
char *local_options;
|
|
|
|
int conn_mode;
|
2010-08-02 18:57:02 +00:00
|
|
|
int orig_mode;
|
2010-02-20 20:21:02 +00:00
|
|
|
|
|
|
|
/* backpointer */
|
|
|
|
struct mgcp_config *cfg;
|
2011-02-27 23:56:17 +00:00
|
|
|
struct mgcp_trunk_config *tcfg;
|
2010-04-07 07:37:17 +00:00
|
|
|
|
2010-08-04 17:34:51 +00:00
|
|
|
/* port status for bts/net */
|
|
|
|
struct mgcp_rtp_end bts_end;
|
|
|
|
struct mgcp_rtp_end net_end;
|
2010-11-01 19:53:31 +00:00
|
|
|
|
2010-11-01 20:04:54 +00:00
|
|
|
/*
|
|
|
|
* For transcoding we will send from the local_port
|
|
|
|
* of trans_bts and it will arrive at trans_net from
|
|
|
|
* where we will forward it to the network.
|
|
|
|
*/
|
|
|
|
struct mgcp_rtp_end trans_bts;
|
2010-11-01 19:53:31 +00:00
|
|
|
struct mgcp_rtp_end trans_net;
|
2010-11-01 18:57:50 +00:00
|
|
|
int is_transcoded;
|
2010-07-28 18:38:39 +00:00
|
|
|
|
|
|
|
/* sequence bits */
|
2010-08-03 11:59:04 +00:00
|
|
|
struct mgcp_rtp_state net_state;
|
|
|
|
struct mgcp_rtp_state bts_state;
|
2010-08-05 12:07:00 +00:00
|
|
|
|
|
|
|
/* SSRC/seq/ts patching for loop */
|
|
|
|
int allow_patch;
|
2010-08-05 17:12:21 +00:00
|
|
|
|
|
|
|
/* tap for the endpoint */
|
|
|
|
struct mgcp_rtp_tap taps[MGCP_TAP_COUNT];
|
2010-02-20 20:21:02 +00:00
|
|
|
};
|
|
|
|
|
2011-02-27 23:56:17 +00:00
|
|
|
#define ENDPOINT_NUMBER(endp) abs(endp - endp->tcfg->endpoints)
|
2010-02-20 20:21:02 +00:00
|
|
|
|
2010-04-01 01:27:04 +00:00
|
|
|
struct mgcp_msg_ptr {
|
|
|
|
unsigned int start;
|
|
|
|
unsigned int length;
|
|
|
|
};
|
|
|
|
|
|
|
|
int mgcp_analyze_header(struct mgcp_config *cfg, struct msgb *msg,
|
|
|
|
struct mgcp_msg_ptr *ptr, int size,
|
|
|
|
const char **transaction_id, struct mgcp_endpoint **endp);
|
2010-04-21 13:25:13 +00:00
|
|
|
int mgcp_send_dummy(struct mgcp_endpoint *endp);
|
2010-08-04 19:29:33 +00:00
|
|
|
int mgcp_bind_bts_rtp_port(struct mgcp_endpoint *endp, int rtp_port);
|
2010-08-04 20:10:21 +00:00
|
|
|
int mgcp_bind_net_rtp_port(struct mgcp_endpoint *endp, int rtp_port);
|
2010-11-01 20:04:54 +00:00
|
|
|
int mgcp_bind_trans_bts_rtp_port(struct mgcp_endpoint *enp, int rtp_port);
|
|
|
|
int mgcp_bind_trans_net_rtp_port(struct mgcp_endpoint *enp, int rtp_port);
|
2010-08-05 00:08:17 +00:00
|
|
|
int mgcp_free_rtp_port(struct mgcp_rtp_end *end);
|
2010-04-01 01:27:04 +00:00
|
|
|
|
2010-11-01 20:04:54 +00:00
|
|
|
/* For transcoding we need to manage an in and an output that are connected */
|
|
|
|
static inline int endp_back_channel(int endpoint)
|
|
|
|
{
|
|
|
|
return endpoint + 60;
|
|
|
|
}
|
|
|
|
|
2011-02-28 11:11:02 +00:00
|
|
|
struct mgcp_trunk_config *mgcp_trunk_alloc(struct mgcp_config *cfg, int index);
|
|
|
|
struct mgcp_trunk_config *mgcp_trunk_num(struct mgcp_config *cfg, int index);
|
|
|
|
|
2010-11-01 20:04:54 +00:00
|
|
|
|
2010-02-20 20:21:02 +00:00
|
|
|
#endif
|