From 34a313f2e2c60ba061a1515f3a77f9f6f61a413a Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Wed, 19 Jul 2017 16:48:42 +0200 Subject: move to osmo-mgw.git: osmo-bsc_mgcp and libmgcp as libosmo-legacy-mgcp Rewire build and includes to libosmo-legacy-mgcp. Drop osmo-bsc_mgcp and related python tests, now found in osmo-mgw.git. libosmo-legacy-mgcp is installed from osmo-mgw, hence add the dependency to jenkins.sh (so far using the pre_release branch). Change-Id: Ic99d681759edce11564da62500c2aac5cf5fffe2 --- include/openbsc/Makefile.am | 4 - include/openbsc/bsc_nat.h | 4 +- include/openbsc/gsm_data.h | 2 +- include/openbsc/mgcp.h | 300 ---------------------------------- include/openbsc/mgcp_internal.h | 337 --------------------------------------- include/openbsc/mgcp_transcode.h | 90 ----------- include/openbsc/mgcpgw_client.h | 111 ------------- 7 files changed, 3 insertions(+), 845 deletions(-) delete mode 100644 include/openbsc/mgcp.h delete mode 100644 include/openbsc/mgcp_internal.h delete mode 100644 include/openbsc/mgcp_transcode.h delete mode 100644 include/openbsc/mgcpgw_client.h (limited to 'include/openbsc') diff --git a/include/openbsc/Makefile.am b/include/openbsc/Makefile.am index 89e0338f5..c1cb6a3fb 100644 --- a/include/openbsc/Makefile.am +++ b/include/openbsc/Makefile.am @@ -54,10 +54,6 @@ noinst_HEADERS = \ iu_dummy.h \ meas_feed.h \ meas_rep.h \ - mgcp.h \ - mgcp_internal.h \ - mgcp_transcode.h \ - mgcpgw_client.h \ misdn.h \ mncc.h \ mncc_int.h \ diff --git a/include/openbsc/bsc_nat.h b/include/openbsc/bsc_nat.h index 94ab0e5ff..452daf2ab 100644 --- a/include/openbsc/bsc_nat.h +++ b/include/openbsc/bsc_nat.h @@ -21,9 +21,9 @@ #ifndef BSC_NAT_H #define BSC_NAT_H -#include "mgcp.h" -#include "bsc_msg_filter.h" +#include +#include "bsc_msg_filter.h" #include #include diff --git a/include/openbsc/gsm_data.h b/include/openbsc/gsm_data.h index 6079900a1..88a4f1067 100644 --- a/include/openbsc/gsm_data.h +++ b/include/openbsc/gsm_data.h @@ -17,7 +17,7 @@ #include #include #include -#include +#include /** annotations for msgb ownership */ diff --git a/include/openbsc/mgcp.h b/include/openbsc/mgcp.h deleted file mode 100644 index 7cf83b27c..000000000 --- a/include/openbsc/mgcp.h +++ /dev/null @@ -1,300 +0,0 @@ -/* A Media Gateway Control Protocol Media Gateway: RFC 3435 */ - -/* - * (C) 2009-2012 by Holger Hans Peter Freyther - * (C) 2009-2012 by On-Waves - * All Rights Reserved - * - * This program is free software; you can redistribute it and/or modify - * 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 - * (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 - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - -#ifndef OPENBSC_MGCP_H -#define OPENBSC_MGCP_H - -#include -#include -#include - -#include "debug.h" - -#include -#include -#include -#include - -#define RTP_PORT_DEFAULT 4000 -#define RTP_PORT_NET_DEFAULT 16000 - -/** - * Calculate the RTP audio port for the given multiplex - * and the direction. This allows a semi static endpoint - * to port calculation removing the need for the BSC - * and the MediaGateway to communicate. - * - * Port usage explained: - * base + (multiplex * 2) + 0 == local port to wait for network packets - * base + (multiplex * 2) + 1 == local port for rtcp - * - * The above port will receive packets from the BTS that need - * to be patched and forwarded to the network. - * The above port will receive packets from the network that - * need to be patched and forwarded to the BTS. - * - * We assume to have a static BTS IP address so we can differentiate - * network and BTS. - * - */ -static inline int rtp_calculate_port(int multiplex, int base) -{ - return base + (multiplex * 2); -} - - -/* - * Handling of MGCP Endpoints and the MGCP Config - */ -struct mgcp_endpoint; -struct mgcp_config; -struct mgcp_trunk_config; -struct mgcp_rtp_end; - -#define MGCP_ENDP_CRCX 1 -#define MGCP_ENDP_DLCX 2 -#define MGCP_ENDP_MDCX 3 - -/* - * what to do with the msg? - * - continue as usual? - * - reject and send a failure code? - * - defer? do not send anything - */ -#define MGCP_POLICY_CONT 4 -#define MGCP_POLICY_REJECT 5 -#define MGCP_POLICY_DEFER 6 - -typedef int (*mgcp_realloc)(struct mgcp_trunk_config *cfg, int endpoint); -typedef int (*mgcp_change)(struct mgcp_trunk_config *cfg, int endpoint, int state); -typedef int (*mgcp_policy)(struct mgcp_trunk_config *cfg, int endpoint, int state, const char *transactio_id); -typedef int (*mgcp_reset)(struct mgcp_trunk_config *cfg); -typedef int (*mgcp_rqnt)(struct mgcp_endpoint *endp, char tone); - -/** - * Return: - * < 0 in case no audio was processed - * >= 0 in case audio was processed. The remaining payload - * length will be returned. - */ -typedef int (*mgcp_processing)(struct mgcp_endpoint *endp, - struct mgcp_rtp_end *dst_end, - char *data, int *len, int buf_size); -typedef int (*mgcp_processing_setup)(struct mgcp_endpoint *endp, - struct mgcp_rtp_end *dst_end, - struct mgcp_rtp_end *src_end); - -typedef void (*mgcp_get_format)(struct mgcp_endpoint *endp, - int *payload_type, - const char**subtype_name, - const char**fmtp_extra); - -#define PORT_ALLOC_STATIC 0 -#define PORT_ALLOC_DYNAMIC 1 - -/** - * This holds information on how to allocate ports - */ -struct mgcp_port_range { - int mode; - - /* addr or NULL to fall-back to default */ - char *bind_addr; - - /* pre-allocated from a base? */ - int base_port; - - /* dynamically allocated */ - int range_start; - int range_end; - int last_port; -}; - -#define MGCP_KEEPALIVE_ONCE (-1) - -struct mgcp_trunk_config { - struct llist_head entry; - - struct mgcp_config *cfg; - - int trunk_nr; - int trunk_type; - - char *audio_fmtp_extra; - char *audio_name; - int audio_payload; - int audio_send_ptime; - int audio_send_name; - int audio_loop; - - int no_audio_transcoding; - - int omit_rtcp; - int keepalive_interval; - - /* RTP patching */ - int force_constant_ssrc; /* 0: don't, 1: once */ - int force_aligned_timing; - - /* spec handling */ - int force_realloc; - - /* timer */ - struct osmo_timer_list keepalive_timer; - - unsigned int number_endpoints; - struct mgcp_endpoint *endpoints; -}; - -enum mgcp_role { - MGCP_BSC = 0, - MGCP_BSC_NAT, -}; - -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 | MGCP_CONN_RECV_SEND, -}; - -extern const struct value_string mgcp_connection_mode_strs[]; - -static inline const char *mgcp_cmode_name(enum mgcp_connection_mode mode) -{ - return get_value_string(mgcp_connection_mode_strs, mode); -} - -struct mgcp_config { - int source_port; - char *local_ip; - char *source_addr; - char *bts_ip; - char *call_agent_addr; - - struct in_addr bts_in; - - /* transcoder handling */ - char *transcoder_ip; - struct in_addr transcoder_in; - int transcoder_remote_base; - - /* RTP processing */ - mgcp_processing rtp_processing_cb; - mgcp_processing_setup setup_rtp_processing_cb; - - mgcp_get_format get_net_downlink_format_cb; - - struct osmo_wqueue gw_fd; - - struct mgcp_port_range bts_ports; - struct mgcp_port_range net_ports; - struct mgcp_port_range transcoder_ports; - int endp_dscp; - - int bts_force_ptime; - - mgcp_change change_cb; - mgcp_policy policy_cb; - mgcp_reset reset_cb; - mgcp_realloc realloc_cb; - mgcp_rqnt rqnt_cb; - void *data; - - uint32_t last_call_id; - - /* trunk handling */ - struct mgcp_trunk_config trunk; - struct llist_head trunks; - - /* only used for start with a static configuration */ - int last_net_port; - int last_bts_port; - - enum mgcp_role role; - - /* osmux translator: 0 means disabled, 1 means enabled */ - int osmux; - /* addr to bind the server to */ - char *osmux_addr; - /* The BSC-NAT may ask for enabling osmux on demand. This tells us if - * the osmux socket is already initialized. - */ - int osmux_init; - /* osmux batch factor: from 1 to 4 maximum */ - int osmux_batch; - /* osmux batch size (in bytes) */ - int osmux_batch_size; - /* osmux port */ - uint16_t osmux_port; - /* Pad circuit with dummy messages until we see the first voice - * message. - */ - uint16_t osmux_dummy; -}; - -/* config management */ -struct mgcp_config *mgcp_config_alloc(void); -int mgcp_parse_config(const char *config_file, struct mgcp_config *cfg, - enum mgcp_role role); -int mgcp_vty_init(void); -int mgcp_endpoints_allocate(struct mgcp_trunk_config *cfg); -void mgcp_release_endp(struct mgcp_endpoint *endp); -void mgcp_initialize_endp(struct mgcp_endpoint *endp); -int mgcp_reset_transcoder(struct mgcp_config *cfg); -void mgcp_format_stats(struct mgcp_endpoint *endp, char *stats, size_t size); -int mgcp_parse_stats(struct msgb *msg, uint32_t *ps, uint32_t *os, uint32_t *pr, uint32_t *_or, int *loss, uint32_t *jitter); - -void mgcp_trunk_set_keepalive(struct mgcp_trunk_config *tcfg, int interval); - -/* - * format helper functions - */ -struct msgb *mgcp_handle_message(struct mgcp_config *cfg, struct msgb *msg); - -/* adc helper */ -static inline int mgcp_timeslot_to_endpoint(int multiplex, int timeslot) -{ - if (timeslot == 0) { - LOGP(DMGCP, LOGL_ERROR, "Timeslot should not be 0\n"); - timeslot = 255; - } - - return timeslot + (32 * multiplex); -} - -static inline void mgcp_endpoint_to_timeslot(int endpoint, int *multiplex, int *timeslot) -{ - *multiplex = endpoint / 32; - *timeslot = endpoint % 32; -} - -int mgcp_send_reset_ep(struct mgcp_endpoint *endp, int endpoint); -int mgcp_send_reset_all(struct mgcp_config *cfg); - - -int mgcp_create_bind(const char *source_addr, struct osmo_fd *fd, int port); -int mgcp_send(struct mgcp_endpoint *endp, int dest, int is_rtp, struct sockaddr_in *addr, char *buf, int rc); -int mgcp_udp_send(int fd, struct in_addr *addr, int port, char *buf, int len); - -#endif diff --git a/include/openbsc/mgcp_internal.h b/include/openbsc/mgcp_internal.h deleted file mode 100644 index b2c24089d..000000000 --- a/include/openbsc/mgcp_internal.h +++ /dev/null @@ -1,337 +0,0 @@ -/* MGCP Private Data */ - -/* - * (C) 2009-2012 by Holger Hans Peter Freyther - * (C) 2009-2012 by On-Waves - * All Rights Reserved - * - * This program is free software; you can redistribute it and/or modify - * 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 - * (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 - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - -#pragma once - -#include - -#include - -#define CI_UNUSED 0 - -enum mgcp_trunk_type { - MGCP_TRUNK_VIRTUAL, - MGCP_TRUNK_E1, -}; - -struct mgcp_rtp_stream_state { - uint32_t ssrc; - uint16_t last_seq; - uint32_t last_timestamp; - uint32_t err_ts_counter; - int32_t last_tsdelta; - uint32_t last_arrival_time; -}; - -struct mgcp_rtp_state { - int initialized; - int patch_ssrc; - - uint32_t orig_ssrc; - - int seq_offset; - - int32_t timestamp_offset; - uint32_t packet_duration; - - struct mgcp_rtp_stream_state in_stream; - struct mgcp_rtp_stream_state out_stream; - - /* jitter and packet loss calculation */ - int stats_initialized; - uint16_t stats_base_seq; - uint16_t stats_max_seq; - uint32_t stats_ssrc; - uint32_t stats_jitter; - int32_t stats_transit; - int stats_cycles; - bool patched_first_rtp_payload; /* FIXME: drop this, see OS#2459 */ -}; - -struct mgcp_rtp_codec { - uint32_t rate; - int channels; - uint32_t frame_duration_num; - uint32_t frame_duration_den; - - int payload_type; - char *audio_name; - char *subtype_name; -}; - -struct mgcp_rtp_end { - /* statistics */ - unsigned int packets; - unsigned int octets; - unsigned int dropped_packets; - struct in_addr addr; - - /* in network byte order */ - int rtp_port, rtcp_port; - - /* audio codec information */ - struct mgcp_rtp_codec codec; - struct mgcp_rtp_codec alt_codec; /* TODO/XXX: make it generic */ - - /* per endpoint data */ - int frames_per_packet; - uint32_t packet_duration_ms; - char *fmtp_extra; - int output_enabled; - int force_output_ptime; - - /* RTP patching */ - int force_constant_ssrc; /* -1: always, 0: don't, 1: once */ - int force_aligned_timing; - void *rtp_process_data; - - /* - * Each end has a socket... - */ - struct osmo_fd rtp; - struct osmo_fd rtcp; - - int local_port; - int local_alloc; -}; - -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; -}; - -struct mgcp_lco { - char *string; - char *codec; - int pkt_period_min; /* time in ms */ - int pkt_period_max; /* time in ms */ -}; - -enum mgcp_type { - MGCP_RTP_DEFAULT = 0, - MGCP_RTP_TRANSCODED, - MGCP_OSMUX_BSC, - MGCP_OSMUX_BSC_NAT, -}; - -#include - -struct mgcp_endpoint { - int allocated; - uint32_t ci; - char *callid; - struct mgcp_lco local_options; - int conn_mode; - int orig_mode; - - /* backpointer */ - struct mgcp_config *cfg; - struct mgcp_trunk_config *tcfg; - - /* port status for bts/net */ - struct mgcp_rtp_end bts_end; - struct mgcp_rtp_end net_end; - - /* - * 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; - struct mgcp_rtp_end trans_net; - enum mgcp_type type; - - /* sequence bits */ - struct mgcp_rtp_state net_state; - struct mgcp_rtp_state bts_state; - - /* fields for re-transmission */ - char *last_trans; - char *last_response; - - /* tap for the endpoint */ - struct mgcp_rtp_tap taps[MGCP_TAP_COUNT]; - - struct { - /* Osmux state: disabled, activating, active */ - enum osmux_state state; - /* Allocated Osmux circuit ID for this endpoint */ - int allocated_cid; - /* Used Osmux circuit ID for this endpoint */ - uint8_t cid; - /* handle to batch messages */ - struct osmux_in_handle *in; - /* handle to unbatch messages */ - struct osmux_out_handle out; - /* statistics */ - struct { - uint32_t chunks; - uint32_t octets; - } stats; - } osmux; -}; - -#define for_each_line(line, save) \ - for (line = strline_r(NULL, &save); line;\ - line = strline_r(NULL, &save)) - -static inline char *strline_r(char *str, char **saveptr) -{ - char *result; - - if (str) - *saveptr = str; - - result = *saveptr; - - if (*saveptr != NULL) { - *saveptr = strpbrk(*saveptr, "\r\n"); - - if (*saveptr != NULL) { - char *eos = *saveptr; - - if ((*saveptr)[0] == '\r' && (*saveptr)[1] == '\n') - (*saveptr)++; - (*saveptr)++; - if ((*saveptr)[0] == '\0') - *saveptr = NULL; - - *eos = '\0'; - } - } - - return result; -} - - - -#define ENDPOINT_NUMBER(endp) abs((int)(endp - endp->tcfg->endpoints)) - -/** - * Internal structure while parsing a request - */ -struct mgcp_parse_data { - struct mgcp_config *cfg; - struct mgcp_endpoint *endp; - char *trans; - char *save; - int found; -}; - -int mgcp_send_dummy(struct mgcp_endpoint *endp); -int mgcp_bind_bts_rtp_port(struct mgcp_endpoint *endp, int rtp_port); -int mgcp_bind_net_rtp_port(struct mgcp_endpoint *endp, int rtp_port); -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); -int mgcp_free_rtp_port(struct mgcp_rtp_end *end); - -/* 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; -} - -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); - -void mgcp_rtp_end_config(struct mgcp_endpoint *endp, int expect_ssrc_change, - struct mgcp_rtp_end *rtp); -uint32_t mgcp_rtp_packet_duration(struct mgcp_endpoint *endp, - struct mgcp_rtp_end *rtp); - -void mgcp_state_calc_loss(struct mgcp_rtp_state *s, struct mgcp_rtp_end *, - uint32_t *expected, int *loss); -uint32_t mgcp_state_calc_jitter(struct mgcp_rtp_state *); - -/* payload processing default functions */ -int mgcp_rtp_processing_default(struct mgcp_endpoint *endp, struct mgcp_rtp_end *dst_end, - char *data, int *len, int buf_size); - -int mgcp_setup_rtp_processing_default(struct mgcp_endpoint *endp, - struct mgcp_rtp_end *dst_end, - struct mgcp_rtp_end *src_end); - -void mgcp_get_net_downlink_format_default(struct mgcp_endpoint *endp, - int *payload_type, - const char**subtype_name, - const char**fmtp_extra); - -/* internal RTP Annex A counting */ -void mgcp_rtp_annex_count(struct mgcp_endpoint *endp, struct mgcp_rtp_state *state, - const uint16_t seq, const int32_t transit, - const uint32_t ssrc); - -int mgcp_set_ip_tos(int fd, int tos); - -enum { - MGCP_DEST_NET = 0, - MGCP_DEST_BTS, -}; - - -#define MGCP_DUMMY_LOAD 0x23 - - -/** - * SDP related information - */ -/* Assume audio frame length of 20ms */ -#define DEFAULT_RTP_AUDIO_FRAME_DUR_NUM 20 -#define DEFAULT_RTP_AUDIO_FRAME_DUR_DEN 1000 -#define DEFAULT_RTP_AUDIO_PACKET_DURATION_MS 20 -#define DEFAULT_RTP_AUDIO_DEFAULT_RATE 8000 -#define DEFAULT_RTP_AUDIO_DEFAULT_CHANNELS 1 - -#define PTYPE_UNDEFINED (-1) -int mgcp_parse_sdp_data(struct mgcp_endpoint *endp, struct mgcp_rtp_end *rtp, struct mgcp_parse_data *p); -int mgcp_set_audio_info(void *ctx, struct mgcp_rtp_codec *codec, - int payload_type, const char *audio_name); - - -/** - * Internal network related - */ -static inline const char *mgcp_net_src_addr(struct mgcp_endpoint *endp) -{ - if (endp->cfg->net_ports.bind_addr) - return endp->cfg->net_ports.bind_addr; - return endp->cfg->source_addr; -} - -static inline const char *mgcp_bts_src_addr(struct mgcp_endpoint *endp) -{ - if (endp->cfg->bts_ports.bind_addr) - return endp->cfg->bts_ports.bind_addr; - return endp->cfg->source_addr; -} - -int mgcp_msg_terminate_nul(struct msgb *msg); diff --git a/include/openbsc/mgcp_transcode.h b/include/openbsc/mgcp_transcode.h deleted file mode 100644 index 147e48bba..000000000 --- a/include/openbsc/mgcp_transcode.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * (C) 2014 by On-Waves - * All Rights Reserved - * - * This program is free software; you can redistribute it and/or modify - * 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 - * (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 - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ -#ifndef OPENBSC_MGCP_TRANSCODE_H -#define OPENBSC_MGCP_TRANSCODE_H - -#include "bscconfig.h" - -#include -#ifdef HAVE_BCG729 -#include -#include -#endif - -enum audio_format { - AF_INVALID, - AF_S16, - AF_L16, - AF_GSM, - AF_G729, - AF_PCMA, - AF_PCMU -}; - - -struct mgcp_process_rtp_state { - /* decoding */ - enum audio_format src_fmt; - union { - gsm gsm_handle; -#ifdef HAVE_BCG729 - bcg729DecoderChannelContextStruct *g729_dec; -#endif - } src; - size_t src_frame_size; - size_t src_samples_per_frame; - - /* processing */ - - /* encoding */ - enum audio_format dst_fmt; - union { - gsm gsm_handle; -#ifdef HAVE_BCG729 - bcg729EncoderChannelContextStruct *g729_enc; -#endif - } dst; - size_t dst_frame_size; - size_t dst_samples_per_frame; - int dst_packet_duration; - - int is_running; - uint16_t next_seq; - uint32_t next_time; - int16_t samples[10*160]; - size_t sample_cnt; - size_t sample_offs; -}; - - -int mgcp_transcoding_setup(struct mgcp_endpoint *endp, - struct mgcp_rtp_end *dst_end, - struct mgcp_rtp_end *src_end); - -void mgcp_transcoding_net_downlink_format(struct mgcp_endpoint *endp, - int *payload_type, - const char**audio_name, - const char**fmtp_extra); - -int mgcp_transcoding_process_rtp(struct mgcp_endpoint *endp, - struct mgcp_rtp_end *dst_end, - char *data, int *len, int buf_size); - -int mgcp_transcoding_get_frame_size(void *state_, int nsamples, int dst); -#endif /* OPENBSC_MGCP_TRANSCODE_H */ diff --git a/include/openbsc/mgcpgw_client.h b/include/openbsc/mgcpgw_client.h deleted file mode 100644 index b1b5fd42b..000000000 --- a/include/openbsc/mgcpgw_client.h +++ /dev/null @@ -1,111 +0,0 @@ -#pragma once - -#include - -#include -#include - -enum mgcp_connection_mode; - -struct msgb; -struct vty; - -#define MGCPGW_CLIENT_LOCAL_ADDR_DEFAULT "0.0.0.0" -#define MGCPGW_CLIENT_LOCAL_PORT_DEFAULT 0 -#define MGCPGW_CLIENT_REMOTE_ADDR_DEFAULT "127.0.0.1" -#define MGCPGW_CLIENT_REMOTE_PORT_DEFAULT 2427 - -#define MSGB_CB_MGCP_TRANS_ID 0 - -typedef unsigned int mgcp_trans_id_t; - -struct mgcpgw_client_conf { - const char *local_addr; - int local_port; - const char *remote_addr; - int remote_port; - uint16_t first_endpoint; - uint16_t last_endpoint; - uint16_t bts_base; -}; - -struct mgcp_response_head { - int response_code; - mgcp_trans_id_t trans_id; - const char *comment; -}; - -struct mgcp_response { - char *body; - struct mgcp_response_head head; - uint16_t audio_port; -}; - -struct mgcpgw_client { - struct mgcpgw_client_conf actual; - uint32_t remote_addr; - struct osmo_wqueue wq; - mgcp_trans_id_t next_trans_id; - struct llist_head responses_pending; - struct llist_head inuse_endpoints; -}; - -struct mgcp_inuse_endpoint { - struct llist_head entry; - uint16_t id; -}; - -/* Invoked when an MGCP response is received or sending failed. When the - * response is passed as NULL, this indicates failure during transmission. */ -typedef void (* mgcp_response_cb_t )(struct mgcp_response *response, void *priv); - -struct mgcp_response_pending { - struct llist_head entry; - - mgcp_trans_id_t trans_id; - mgcp_response_cb_t response_cb; - void *priv; -}; - - -void mgcpgw_client_conf_init(struct mgcpgw_client_conf *conf); - -struct mgcpgw_client *mgcpgw_client_init(void *ctx, - struct mgcpgw_client_conf *conf); -int mgcpgw_client_connect(struct mgcpgw_client *mgcp); - -const char *mgcpgw_client_remote_addr_str(struct mgcpgw_client *mgcp); -uint16_t mgcpgw_client_remote_port(struct mgcpgw_client *mgcp); -uint32_t mgcpgw_client_remote_addr_n(struct mgcpgw_client *mgcp); - -/* Find and seize an unsused endpoint id */ -int mgcpgw_client_next_endpoint(struct mgcpgw_client *client); - -/* Release a seized endpoint id to make it available again for other calls */ -void mgcpgw_client_release_endpoint(uint16_t id, struct mgcpgw_client *client); - -int mgcp_response_parse_params(struct mgcp_response *r); - -int mgcpgw_client_tx(struct mgcpgw_client *mgcp, struct msgb *msg, - mgcp_response_cb_t response_cb, void *priv); - -struct msgb *mgcp_msg_crcx(struct mgcpgw_client *mgcp, - uint16_t rtp_endpoint, unsigned int call_id, - enum mgcp_connection_mode mode); - -struct msgb *mgcp_msg_mdcx(struct mgcpgw_client *mgcp, - uint16_t rtp_endpoint, const char *rtp_conn_addr, - uint16_t rtp_port, enum mgcp_connection_mode mode); - -struct msgb *mgcp_msg_dlcx(struct mgcpgw_client *mgcp, uint16_t rtp_endpoint, - unsigned int call_id); - -void mgcpgw_client_vty_init(int node, struct mgcpgw_client_conf *conf); -int mgcpgw_client_config_write(struct vty *vty, const char *indent); - -struct mgcp_response_pending * mgcpgw_client_pending_add( - struct mgcpgw_client *mgcp, - mgcp_trans_id_t trans_id, - mgcp_response_cb_t response_cb, - void *priv); -int mgcpgw_client_rx(struct mgcpgw_client *mgcp, struct msgb *msg); -- cgit v1.2.3