mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git
synced 2025-10-25 00:53:42 +00:00
Compare commits
15 Commits
osmith/fix
...
fairwaves/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
55b85a5da4 | ||
|
|
ebb9bf3f12 | ||
|
|
61cf9bb5f1 | ||
|
|
a7152e055a | ||
|
|
63866009e2 | ||
|
|
dab89af070 | ||
|
|
eebbf2b1fc | ||
|
|
e885bc5c24 | ||
|
|
173dc129fc | ||
|
|
3abced8d64 | ||
|
|
a48ff4a738 | ||
|
|
6c92f9d83e | ||
|
|
9852e22101 | ||
|
|
b141cccbfb | ||
|
|
ec45068972 |
15
configure.ac
15
configure.ac
@@ -22,6 +22,11 @@ AC_PROG_CC
|
||||
AC_PROG_INSTALL
|
||||
LT_INIT
|
||||
|
||||
dnl patching ${archive_cmds} to affect generation of file "libtool" to fix linking with clang
|
||||
AS_CASE(["$LD"],[*clang*],
|
||||
[AS_CASE(["${host_os}"],
|
||||
[*linux*],[archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'])])
|
||||
|
||||
dnl check for pkg-config (explained in detail in libosmocore/configure.ac)
|
||||
AC_PATH_PROG(PKG_CONFIG_INSTALLED, pkg-config, no)
|
||||
if test "x$PKG_CONFIG_INSTALLED" = "xno"; then
|
||||
@@ -38,10 +43,14 @@ dnl checks for libraries
|
||||
AC_SEARCH_LIBS([dlopen], [dl dld], [LIBRARY_DL="$LIBS";LIBS=""])
|
||||
AC_SUBST(LIBRARY_DL)
|
||||
|
||||
AC_SEARCH_LIBS([dlsym], [dl dld], [LIBRARY_DLSYM="$LIBS";LIBS=""])
|
||||
AC_SUBST(LIBRARY_DLSYM)
|
||||
|
||||
PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.0.0)
|
||||
PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.0.0)
|
||||
PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 1.0.0)
|
||||
|
||||
PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.1.0)
|
||||
PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.1.0)
|
||||
PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl >= 1.1.0)
|
||||
PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 1.1.0)
|
||||
PKG_CHECK_MODULES(LIBOSMONETIF, libosmo-netif >= 0.6.0)
|
||||
|
||||
AC_ARG_ENABLE(sanitize,
|
||||
|
||||
48
debian/changelog
vendored
48
debian/changelog
vendored
@@ -1,3 +1,51 @@
|
||||
osmo-mgw (1.7.0-fw.5) unstable; urgency=medium
|
||||
|
||||
* master:ebb9bf3f12
|
||||
|
||||
-- Kirill Zakharenko <kirill.zakharenko@fairwaves.co> Tue, 12 May 2020 23:26:34 +0000
|
||||
|
||||
osmo-mgw (1.7.0) unstable; urgency=medium
|
||||
|
||||
[ Neels Hofmeyr ]
|
||||
* rename codecs_cmp() to codecs_same()
|
||||
* mgcp_codec: constify 'param' arg
|
||||
* fix crashes: don't assert on incoming RTP packet size
|
||||
* mgcp_send(): stop looping on conversion error
|
||||
* mgcp_codec: split codec_free() off of codec_init()
|
||||
* fix memleak: actually free strings in mgcp_codec_reset_all()
|
||||
* mgcp_test: extend / rewrite test_mgcp_codec_pt_translate()
|
||||
* test_mgcp_codec_pt_translate(): more tests
|
||||
* differentiate AMR octet-aligned=0 vs =1
|
||||
* ptmap: implicitly match '/8000' and '/8000/1'
|
||||
* mgcp_codec: codec_set(): log about all possible errors
|
||||
* mgcp_codec_add: fix audio_name size check
|
||||
* explicitly free codecs in mgcp_rtp_conn_cleanup()
|
||||
* tweak mgcp_parse_audio_ptime_rtpmap()
|
||||
* SDP: store all ptmap entries
|
||||
* mgcp_client_fsm cleanup: Do not assert on DLCX failure
|
||||
* clear pending requests on MGCP failure
|
||||
* client: endp fsm: add notify struct, prep for cancel-notify
|
||||
* client: endp fsm: clear ci[] before dispatching DLCX success
|
||||
* client: endp fsm: allow cancelling a notify event
|
||||
* client: endp fsm: add osmo_mgcpc_ep_ci_ep()
|
||||
* accept MGCP without SDP
|
||||
* fix use-after-free: require new fsm deferred dealloc, check for term
|
||||
|
||||
[ Pau Espin Pedrol ]
|
||||
* mgcp_test: Correctly release all endpoints allocated
|
||||
* mgw: Allocate mgcp_conn instance under tcfg->endpoints
|
||||
|
||||
[ Harald Welte ]
|
||||
* manual: Fix copy+paste error
|
||||
* mgcp_client: Check for osmo_fsm_register() error return value
|
||||
* Move fsm_mgcp_client regstration to __attribute__((contructor))
|
||||
* exit(2) on unsupported positional arguments on command line
|
||||
|
||||
[ Oliver Smith ]
|
||||
* osmoappdesc.py: switch to python 3
|
||||
|
||||
-- Pau Espin Pedrol <pespin@sysmocom.de> Fri, 03 Jan 2020 13:35:09 +0100
|
||||
|
||||
osmo-mgw (1.6.0) unstable; urgency=medium
|
||||
|
||||
[ Oliver Smith ]
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
mgcp
|
||||
bind ip 127.0.0.1
|
||||
rtp port-range 4002 16000
|
||||
rtp bind-ip 10.9.1.122
|
||||
rtp bind-ip 127.0.0.1
|
||||
rtp ip-probing
|
||||
rtp ip-tos 184
|
||||
bind port 2427
|
||||
|
||||
@@ -6,5 +6,6 @@ noinst_HEADERS = \
|
||||
mgcp_endp.h \
|
||||
mgcp_sdp.h \
|
||||
mgcp_codec.h \
|
||||
mgcp_ctrl.h \
|
||||
debug.h \
|
||||
$(NULL)
|
||||
|
||||
@@ -119,6 +119,16 @@ struct mgcp_port_range {
|
||||
#define MGCP_KEEPALIVE_ONCE (-1)
|
||||
#define MGCP_KEEPALIVE_NEVER 0
|
||||
|
||||
/* Global MCGP general rate counters */
|
||||
enum {
|
||||
MGCP_GENERAL_RX_MSGS_TOTAL,
|
||||
MGCP_GENERAL_RX_MSGS_RETRANSMITTED,
|
||||
MGCP_GENERAL_RX_MSGS_HANDLED,
|
||||
MGCP_GENERAL_RX_MSGS_UNHANDLED,
|
||||
MGCP_GENERAL_RX_FAIL_MSG_PARSE,
|
||||
MGCP_GENERAL_RX_FAIL_NO_ENDPOINT,
|
||||
};
|
||||
|
||||
/* Global MCGP CRCX related rate counters */
|
||||
enum {
|
||||
MGCP_CRCX_SUCCESS,
|
||||
@@ -207,6 +217,8 @@ struct mgcp_trunk_config {
|
||||
int vty_number_endpoints;
|
||||
struct mgcp_endpoint *endpoints;
|
||||
|
||||
/* Rate counter group which contains stats for generic MGCP events. */
|
||||
struct rate_ctr_group *mgcp_general_ctr_group;
|
||||
/* Rate counter group which contains stats for processed CRCX commands. */
|
||||
struct rate_ctr_group *mgcp_crcx_ctr_group;
|
||||
/* Rate counter group which contains stats for processed MDCX commands. */
|
||||
@@ -279,6 +291,9 @@ struct mgcp_config {
|
||||
|
||||
/* time after which inactive connections (CIs) get closed */
|
||||
int conn_timeout;
|
||||
|
||||
/* osmocom CTRL interface */
|
||||
struct ctrl_handle *ctrl;
|
||||
};
|
||||
|
||||
/* config management */
|
||||
|
||||
24
include/osmocom/mgcp/mgcp_ctrl.h
Normal file
24
include/osmocom/mgcp/mgcp_ctrl.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* (C) 2020 by Harald Welte <laforge@gnumonks.org>
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
struct ctrl_handle *mgw_ctrl_interface_setup(struct mgcp_config *cfg,
|
||||
const char *bind_addr, uint16_t port);
|
||||
|
||||
@@ -20,7 +20,7 @@ AM_LDFLAGS = \
|
||||
|
||||
# This is not at all related to the release version, but a range of supported
|
||||
# API versions. Read TODO_RELEASE in the source tree's root!
|
||||
MGCP_CLIENT_LIBVERSION=6:0:0
|
||||
MGCP_CLIENT_LIBVERSION=7:0:1
|
||||
|
||||
lib_LTLIBRARIES = \
|
||||
libosmo-mgcp-client.la \
|
||||
|
||||
@@ -828,8 +828,8 @@ int mgcp_client_connect(struct mgcp_client *mgcp)
|
||||
inet_aton(mgcp->actual.remote_addr, &addr.sin_addr);
|
||||
mgcp->remote_addr = htonl(addr.sin_addr.s_addr);
|
||||
|
||||
osmo_wqueue_init(wq, 10);
|
||||
wq->bfd.when = BSC_FD_READ;
|
||||
osmo_wqueue_init(wq, 1024);
|
||||
wq->bfd.when = OSMO_FD_READ;
|
||||
wq->bfd.data = mgcp;
|
||||
wq->read_cb = mgcp_do_read;
|
||||
wq->write_cb = mgcp_do_write;
|
||||
|
||||
@@ -40,4 +40,5 @@ libosmo_mgcp_a_SOURCES = \
|
||||
mgcp_conn.c \
|
||||
mgcp_stat.c \
|
||||
mgcp_endp.c \
|
||||
mgcp_ctrl.c \
|
||||
$(NULL)
|
||||
|
||||
@@ -259,7 +259,6 @@ aggregate_rtp_conn_stats(struct mgcp_trunk_config *trunk, struct mgcp_conn_rtp *
|
||||
{
|
||||
struct rate_ctr_group *all_stats = trunk->all_rtp_conn_stats;
|
||||
struct rate_ctr_group *conn_stats = conn_rtp->rate_ctr_group;
|
||||
int i;
|
||||
|
||||
if (all_stats == NULL || conn_stats == NULL)
|
||||
return;
|
||||
@@ -269,8 +268,11 @@ aggregate_rtp_conn_stats(struct mgcp_trunk_config *trunk, struct mgcp_conn_rtp *
|
||||
* All other counters in both counter groups correspond to each other. */
|
||||
OSMO_ASSERT(conn_stats->desc->num_ctr + 1 == all_stats->desc->num_ctr);
|
||||
|
||||
for (i = 0; i < conn_stats->desc->num_ctr; i++)
|
||||
rate_ctr_add(&all_stats->ctr[i], conn_stats->ctr[i].current);
|
||||
/* all other counters are [now] updated in real-time */
|
||||
rate_ctr_add(&all_stats->ctr[IN_STREAM_ERR_TSTMP_CTR],
|
||||
conn_stats->ctr[IN_STREAM_ERR_TSTMP_CTR].current);
|
||||
rate_ctr_add(&all_stats->ctr[OUT_STREAM_ERR_TSTMP_CTR],
|
||||
conn_stats->ctr[OUT_STREAM_ERR_TSTMP_CTR].current);
|
||||
|
||||
rate_ctr_inc(&all_stats->ctr[RTP_NUM_CONNECTIONS]);
|
||||
}
|
||||
|
||||
36
src/libosmo-mgcp/mgcp_ctrl.c
Normal file
36
src/libosmo-mgcp/mgcp_ctrl.c
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* (C) 2020 by Harald Welte <laforge@gnumonks.org>
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <osmocom/ctrl/control_if.h>
|
||||
#include <osmocom/mgcp/mgcp.h>
|
||||
|
||||
|
||||
static int mgw_ctrl_node_lookup(void *data, vector vline, int *node_type,
|
||||
void **node_data, int *i)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
struct ctrl_handle *mgw_ctrl_interface_setup(struct mgcp_config *cfg,
|
||||
const char *bind_addr, uint16_t port)
|
||||
{
|
||||
return ctrl_interface_setup_dynip2(cfg, bind_addr, port, mgw_ctrl_node_lookup,
|
||||
_LAST_CTRL_NODE);
|
||||
}
|
||||
@@ -57,6 +57,22 @@ enum {
|
||||
MGCP_PROTO_RTCP,
|
||||
};
|
||||
|
||||
static void rtpconn_rate_ctr_add(struct mgcp_conn_rtp *conn_rtp, struct mgcp_endpoint *endp,
|
||||
int id, int inc)
|
||||
{
|
||||
struct rate_ctr_group *conn_stats = conn_rtp->rate_ctr_group;
|
||||
struct rate_ctr_group *trunk_stats = endp->tcfg->all_rtp_conn_stats;
|
||||
|
||||
/* add to both the per-connection and the per-trunk global stats */
|
||||
rate_ctr_add(&conn_stats->ctr[id], inc);
|
||||
rate_ctr_add(&trunk_stats->ctr[id], inc);
|
||||
}
|
||||
|
||||
static void rtpconn_rate_ctr_inc(struct mgcp_conn_rtp *conn_rtp, struct mgcp_endpoint *endp, int id)
|
||||
{
|
||||
rtpconn_rate_ctr_add(conn_rtp, endp, id, 1);
|
||||
}
|
||||
|
||||
/*! Determine the local rtp bind IP-address.
|
||||
* \param[out] addr caller provided memory to store the resulting IP-Address
|
||||
* \param[in] endp mgcp endpoint, that holds a copy of the VTY parameters
|
||||
@@ -845,7 +861,7 @@ int mgcp_send(struct mgcp_endpoint *endp, int is_rtp, struct sockaddr_in *addr,
|
||||
dest_name = conn_dst->conn->name;
|
||||
|
||||
if (!rtp_end->output_enabled) {
|
||||
rate_ctr_inc(&conn_dst->rate_ctr_group->ctr[RTP_DROPPED_PACKETS_CTR]);
|
||||
rtpconn_rate_ctr_inc(conn_dst, endp, RTP_DROPPED_PACKETS_CTR);
|
||||
LOGPENDP(endp, DRTP, LOGL_DEBUG,
|
||||
"output disabled, drop to %s %s "
|
||||
"rtp_port:%u rtcp_port:%u\n",
|
||||
@@ -924,8 +940,8 @@ int mgcp_send(struct mgcp_endpoint *endp, int is_rtp, struct sockaddr_in *addr,
|
||||
if (len <= 0)
|
||||
return len;
|
||||
|
||||
rate_ctr_inc(&conn_dst->rate_ctr_group->ctr[RTP_PACKETS_TX_CTR]);
|
||||
rate_ctr_add(&conn_dst->rate_ctr_group->ctr[RTP_OCTETS_TX_CTR], len);
|
||||
rtpconn_rate_ctr_inc(conn_dst, endp, RTP_PACKETS_TX_CTR);
|
||||
rtpconn_rate_ctr_add(conn_dst, endp, RTP_OCTETS_TX_CTR, len);
|
||||
|
||||
nbytes += len;
|
||||
buflen = cont;
|
||||
@@ -942,8 +958,8 @@ int mgcp_send(struct mgcp_endpoint *endp, int is_rtp, struct sockaddr_in *addr,
|
||||
&rtp_end->addr,
|
||||
rtp_end->rtcp_port, buf, len);
|
||||
|
||||
rate_ctr_inc(&conn_dst->rate_ctr_group->ctr[RTP_PACKETS_TX_CTR]);
|
||||
rate_ctr_add(&conn_dst->rate_ctr_group->ctr[RTP_OCTETS_TX_CTR], len);
|
||||
rtpconn_rate_ctr_inc(conn_dst, endp, RTP_PACKETS_TX_CTR);
|
||||
rtpconn_rate_ctr_add(conn_dst, endp, RTP_OCTETS_TX_CTR, len);
|
||||
|
||||
return len;
|
||||
}
|
||||
@@ -1189,8 +1205,8 @@ static int mgcp_recv(int *proto, struct sockaddr_in *addr, char *buf,
|
||||
}
|
||||
|
||||
/* Increment RX statistics */
|
||||
rate_ctr_inc(&conn->rate_ctr_group->ctr[RTP_PACKETS_RX_CTR]);
|
||||
rate_ctr_add(&conn->rate_ctr_group->ctr[RTP_OCTETS_RX_CTR], rc);
|
||||
rtpconn_rate_ctr_inc(conn, endp, RTP_PACKETS_RX_CTR);
|
||||
rtpconn_rate_ctr_add(conn, endp, RTP_OCTETS_RX_CTR, rc);
|
||||
|
||||
/* Forward a copy of the RTP data to a debug ip/port */
|
||||
forward_data(fd->fd, &conn->tap_in, buf, rc);
|
||||
@@ -1255,7 +1271,7 @@ int mgcp_dispatch_rtp_bridge_cb(int proto, struct sockaddr_in *addr, char *buf,
|
||||
struct mgcp_conn *conn_dst;
|
||||
|
||||
/*! NOTE: This callback function implements the endpoint specific
|
||||
* dispatch bahviour of an rtp bridge/proxy endpoint. It is assumed
|
||||
* dispatch behaviour of an rtp bridge/proxy endpoint. It is assumed
|
||||
* that the endpoint will hold only two connections. This premise
|
||||
* is used to determine the opposite connection (it is always the
|
||||
* connection that is not the originating connection). Once the
|
||||
@@ -1294,8 +1310,8 @@ int mgcp_dispatch_rtp_bridge_cb(int proto, struct sockaddr_in *addr, char *buf,
|
||||
|
||||
/* There is no destination conn, stop here */
|
||||
if (!conn_dst) {
|
||||
LOGPCONN(conn, DRTP, LOGL_ERROR,
|
||||
"unable to find destination conn\n");
|
||||
LOGPCONN(conn, DRTP, LOGL_DEBUG,
|
||||
"no connection to forward an incoming RTP packet to\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1446,7 +1462,7 @@ static int bind_rtp(struct mgcp_config *cfg, const char *source_addr,
|
||||
mgcp_set_ip_tos(rtp_end->rtp.fd, cfg->endp_dscp);
|
||||
mgcp_set_ip_tos(rtp_end->rtcp.fd, cfg->endp_dscp);
|
||||
|
||||
rtp_end->rtp.when = BSC_FD_READ;
|
||||
rtp_end->rtp.when = OSMO_FD_READ;
|
||||
if (osmo_fd_register(&rtp_end->rtp) != 0) {
|
||||
LOGPENDP(endp, DRTP, LOGL_ERROR,
|
||||
"failed to register RTP port %d\n",
|
||||
@@ -1454,7 +1470,7 @@ static int bind_rtp(struct mgcp_config *cfg, const char *source_addr,
|
||||
goto cleanup2;
|
||||
}
|
||||
|
||||
rtp_end->rtcp.when = BSC_FD_READ;
|
||||
rtp_end->rtcp.when = OSMO_FD_READ;
|
||||
if (osmo_fd_register(&rtp_end->rtcp) != 0) {
|
||||
LOGPENDP(endp, DRTP, LOGL_ERROR,
|
||||
"failed to register RTCP port %d\n",
|
||||
|
||||
@@ -406,7 +406,7 @@ int osmux_init(int role, struct mgcp_config *cfg)
|
||||
return ret;
|
||||
}
|
||||
mgcp_set_ip_tos(osmux_fd.fd, cfg->endp_dscp);
|
||||
osmux_fd.when |= BSC_FD_READ;
|
||||
osmux_fd.when |= OSMO_FD_READ;
|
||||
|
||||
ret = osmo_fd_register(&osmux_fd);
|
||||
if (ret < 0) {
|
||||
|
||||
@@ -53,6 +53,24 @@ struct mgcp_request {
|
||||
#define MGCP_REQUEST(NAME, REQ, DEBUG_NAME) \
|
||||
{ .name = NAME, .handle_request = REQ, .debug_name = DEBUG_NAME },
|
||||
|
||||
static const struct rate_ctr_desc mgcp_general_ctr_desc[] = {
|
||||
/* rx_msgs = rx_msgs_retransmitted + rx_msgs_handled + rx_msgs_unhandled + err_rx_msg_parse + err_rx_no_endpoint */
|
||||
[MGCP_GENERAL_RX_MSGS_TOTAL] = {"mgcp:rx_msgs", "total number of MGCP messages received."},
|
||||
[MGCP_GENERAL_RX_MSGS_RETRANSMITTED] = {"mgcp:rx_msgs_retransmitted", "number of received retransmissions."},
|
||||
[MGCP_GENERAL_RX_MSGS_HANDLED] = {"mgcp:rx_msgs_handled", "number of handled MGCP messages."},
|
||||
[MGCP_GENERAL_RX_MSGS_UNHANDLED] = {"mgcp:rx_msgs_unhandled", "number of unhandled MGCP messages."},
|
||||
[MGCP_GENERAL_RX_FAIL_MSG_PARSE] = {"mgcp:err_rx_msg_parse", "error parsing MGCP message."},
|
||||
[MGCP_GENERAL_RX_FAIL_NO_ENDPOINT] = {"mgcp:err_rx_no_endpoint", "can't find MGCP endpoint, probably we've used all allocated endpoints."},
|
||||
};
|
||||
|
||||
const static struct rate_ctr_group_desc mgcp_general_ctr_group_desc = {
|
||||
.group_name_prefix = "mgcp",
|
||||
.group_description = "mgcp general statistics",
|
||||
.class_id = OSMO_STATS_CLASS_GLOBAL,
|
||||
.num_ctr = ARRAY_SIZE(mgcp_general_ctr_desc),
|
||||
.ctr_desc = mgcp_general_ctr_desc
|
||||
};
|
||||
|
||||
static const struct rate_ctr_desc mgcp_crcx_ctr_desc[] = {
|
||||
[MGCP_CRCX_SUCCESS] = {"crcx:success", "CRCX command processed successfully."},
|
||||
[MGCP_CRCX_FAIL_BAD_ACTION] = {"crcx:bad_action", "bad action in CRCX command."},
|
||||
@@ -361,24 +379,33 @@ static void send_dummy(struct mgcp_endpoint *endp, struct mgcp_conn_rtp *conn)
|
||||
* - or a response (three numbers, space, transaction id) */
|
||||
struct msgb *mgcp_handle_message(struct mgcp_config *cfg, struct msgb *msg)
|
||||
{
|
||||
struct mgcp_trunk_config *tcfg = &cfg->trunk;
|
||||
struct rate_ctr_group *rate_ctrs = tcfg->mgcp_general_ctr_group;
|
||||
struct mgcp_parse_data pdata;
|
||||
int rc, i, code, handled = 0;
|
||||
struct msgb *resp = NULL;
|
||||
char *data;
|
||||
|
||||
/* Count all messages, even incorect ones */
|
||||
rate_ctr_inc(&rate_ctrs->ctr[MGCP_GENERAL_RX_MSGS_TOTAL]);
|
||||
|
||||
if (msgb_l2len(msg) < 4) {
|
||||
LOGP(DLMGCP, LOGL_ERROR, "msg too short: %d\n", msg->len);
|
||||
rate_ctr_inc(&rate_ctrs->ctr[MGCP_GENERAL_RX_FAIL_MSG_PARSE]);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (mgcp_msg_terminate_nul(msg))
|
||||
if (mgcp_msg_terminate_nul(msg)) {
|
||||
rate_ctr_inc(&rate_ctrs->ctr[MGCP_GENERAL_RX_FAIL_MSG_PARSE]);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mgcp_disp_msg(msg->l2h, msgb_l2len(msg), "Received message");
|
||||
|
||||
/* attempt to treat it as a response */
|
||||
if (sscanf((const char *)&msg->l2h[0], "%3d %*s", &code) == 1) {
|
||||
LOGP(DLMGCP, LOGL_DEBUG, "Response: Code: %d\n", code);
|
||||
rate_ctr_inc(&rate_ctrs->ctr[MGCP_GENERAL_RX_FAIL_MSG_PARSE]);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -394,12 +421,14 @@ struct msgb *mgcp_handle_message(struct mgcp_config *cfg, struct msgb *msg)
|
||||
if (pdata.endp && pdata.trans
|
||||
&& pdata.endp->last_trans
|
||||
&& strcmp(pdata.endp->last_trans, pdata.trans) == 0) {
|
||||
rate_ctr_inc(&rate_ctrs->ctr[MGCP_GENERAL_RX_MSGS_RETRANSMITTED]);
|
||||
return do_retransmission(pdata.endp);
|
||||
}
|
||||
|
||||
/* check for general parser failure */
|
||||
if (rc < 0) {
|
||||
LOGP(DLMGCP, LOGL_NOTICE, "%s: failed to find the endpoint\n", msg->l2h);
|
||||
rate_ctr_inc(&rate_ctrs->ctr[MGCP_GENERAL_RX_FAIL_NO_ENDPOINT]);
|
||||
return create_err_response(NULL, -rc, (const char *) msg->l2h, pdata.trans);
|
||||
}
|
||||
|
||||
@@ -413,9 +442,13 @@ struct msgb *mgcp_handle_message(struct mgcp_config *cfg, struct msgb *msg)
|
||||
}
|
||||
}
|
||||
|
||||
if (!handled)
|
||||
if (handled) {
|
||||
rate_ctr_inc(&rate_ctrs->ctr[MGCP_GENERAL_RX_MSGS_HANDLED]);
|
||||
} else {
|
||||
rate_ctr_inc(&rate_ctrs->ctr[MGCP_GENERAL_RX_MSGS_UNHANDLED]);
|
||||
LOGP(DLMGCP, LOGL_NOTICE, "MSG with type: '%.4s' not handled\n",
|
||||
&msg->l2h[0]);
|
||||
}
|
||||
|
||||
return resp;
|
||||
}
|
||||
@@ -1556,11 +1589,19 @@ static int alloc_mgcp_rate_counters(struct mgcp_trunk_config *trunk, void *ctx)
|
||||
/* FIXME: Each new rate counter group requires a unique index. At the
|
||||
* moment we generate an index using a counter, but perhaps there is
|
||||
* a better way of assigning indices? */
|
||||
static unsigned int general_rate_ctr_index = 0;
|
||||
static unsigned int crcx_rate_ctr_index = 0;
|
||||
static unsigned int mdcx_rate_ctr_index = 0;
|
||||
static unsigned int dlcx_rate_ctr_index = 0;
|
||||
static unsigned int all_rtp_conn_rate_ctr_index = 0;
|
||||
|
||||
if (trunk->mgcp_general_ctr_group == NULL) {
|
||||
trunk->mgcp_general_ctr_group = rate_ctr_group_alloc(ctx, &mgcp_general_ctr_group_desc, general_rate_ctr_index);
|
||||
if (!trunk->mgcp_general_ctr_group)
|
||||
return -1;
|
||||
talloc_set_destructor(trunk->mgcp_general_ctr_group, free_rate_counter_group);
|
||||
general_rate_ctr_index++;
|
||||
}
|
||||
if (trunk->mgcp_crcx_ctr_group == NULL) {
|
||||
trunk->mgcp_crcx_ctr_group = rate_ctr_group_alloc(ctx, &mgcp_crcx_ctr_group_desc, crcx_rate_ctr_index);
|
||||
if (!trunk->mgcp_crcx_ctr_group)
|
||||
@@ -1620,7 +1661,7 @@ struct mgcp_config *mgcp_config_alloc(void)
|
||||
|
||||
cfg->get_net_downlink_format_cb = &mgcp_get_net_downlink_format_default;
|
||||
|
||||
/* default trunk handling */
|
||||
/* default trunk handling; TODO: avoid duplication with mgcp_trunk_alloc() below */
|
||||
cfg->trunk.cfg = cfg;
|
||||
cfg->trunk.trunk_nr = 0;
|
||||
cfg->trunk.trunk_type = MGCP_TRUNK_VIRTUAL;
|
||||
@@ -1628,6 +1669,7 @@ struct mgcp_config *mgcp_config_alloc(void)
|
||||
cfg->trunk.audio_payload = 126;
|
||||
cfg->trunk.audio_send_ptime = 1;
|
||||
cfg->trunk.audio_send_name = 1;
|
||||
cfg->trunk.vty_number_endpoints = 33;
|
||||
cfg->trunk.omit_rtcp = 0;
|
||||
mgcp_trunk_set_keepalive(&cfg->trunk, MGCP_KEEPALIVE_ONCE);
|
||||
if (alloc_mgcp_rate_counters(&cfg->trunk, cfg) < 0) {
|
||||
|
||||
@@ -255,13 +255,21 @@ static void dump_trunk(struct vty *vty, struct mgcp_trunk_config *cfg, int show_
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 1; i < cfg->number_endpoints; ++i) {
|
||||
for (i = 0; i < cfg->number_endpoints; ++i) {
|
||||
struct mgcp_endpoint *endp = &cfg->endpoints[i];
|
||||
dump_endpoint(vty, endp, i, cfg->trunk_nr, cfg->trunk_type, show_stats);
|
||||
if (i < cfg->number_endpoints - 1)
|
||||
vty_out(vty, "%s", VTY_NEWLINE);
|
||||
}
|
||||
|
||||
if (show_stats) {
|
||||
vty_out(vty, "%s", VTY_NEWLINE);
|
||||
vty_out(vty, "Rate counters:%s", VTY_NEWLINE);
|
||||
}
|
||||
if (show_stats && cfg->mgcp_general_ctr_group) {
|
||||
vty_out(vty, " %s:%s", cfg->mgcp_general_ctr_group->desc->group_description, VTY_NEWLINE);
|
||||
vty_out_rate_ctr_group_fmt(vty, " %25n: %10c (%S/s %M/m %H/h %D/d) %d", cfg->mgcp_general_ctr_group);
|
||||
}
|
||||
if (show_stats && cfg->mgcp_crcx_ctr_group) {
|
||||
vty_out(vty, " %s:%s", cfg->mgcp_crcx_ctr_group->desc->group_description, VTY_NEWLINE);
|
||||
vty_out_rate_ctr_group_fmt(vty, " %25n: %10c (%S/s %M/m %H/h %D/d) %d", cfg->mgcp_crcx_ctr_group);
|
||||
|
||||
@@ -9,6 +9,7 @@ AM_CFLAGS = \
|
||||
$(LIBOSMOCORE_CFLAGS) \
|
||||
$(LIBOSMOVTY_CFLAGS) \
|
||||
$(LIBOSMOGSM_CFLAGS) \
|
||||
$(LIBOSMOCTRL_CFLAGS) \
|
||||
$(LIBOSMONETIF_CFLAGS) \
|
||||
$(COVERAGE_CFLAGS) \
|
||||
$(NULL)
|
||||
@@ -26,5 +27,6 @@ osmo_mgw_LDADD = \
|
||||
$(LIBOSMOCORE_LIBS) \
|
||||
$(LIBOSMOVTY_LIBS) \
|
||||
$(LIBOSMOGSM_LIBS) \
|
||||
$(LIBOSMOCTRL_LIBS) \
|
||||
$(LIBOSMONETIF_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <osmocom/mgcp/vty.h>
|
||||
#include <osmocom/mgcp/debug.h>
|
||||
#include <osmocom/mgcp/mgcp_endp.h>
|
||||
#include <osmocom/mgcp/mgcp_ctrl.h>
|
||||
|
||||
#include <osmocom/core/application.h>
|
||||
#include <osmocom/core/msgb.h>
|
||||
@@ -48,6 +49,8 @@
|
||||
#include <osmocom/core/logging.h>
|
||||
#include <osmocom/core/socket.h>
|
||||
|
||||
#include <osmocom/ctrl/control_vty.h>
|
||||
|
||||
#include <osmocom/vty/telnet_interface.h>
|
||||
#include <osmocom/vty/logging.h>
|
||||
#include <osmocom/vty/ports.h>
|
||||
@@ -60,6 +63,11 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <getopt.h>
|
||||
|
||||
/* can be changed once libosmocore 1.4.0 is released */
|
||||
#ifndef OSMO_CTRL_PORT_MGW
|
||||
#define OSMO_CTRL_PORT_MGW 4267
|
||||
#endif
|
||||
|
||||
/* FIXME: Make use of the rtp proxy code */
|
||||
|
||||
static struct mgcp_config *cfg;
|
||||
@@ -278,6 +286,7 @@ int main(int argc, char **argv)
|
||||
osmo_talloc_vty_add_cmds();
|
||||
osmo_stats_vty_add_cmds();
|
||||
mgcp_vty_init();
|
||||
ctrl_vty_init(cfg);
|
||||
|
||||
handle_options(argc, argv);
|
||||
|
||||
@@ -294,6 +303,12 @@ int main(int argc, char **argv)
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
cfg->ctrl = mgw_ctrl_interface_setup(cfg, ctrl_vty_get_bind_addr(), OSMO_CTRL_PORT_MGW);
|
||||
if (!cfg->ctrl) {
|
||||
fprintf(stderr, "Failed to init the control interface on %s:%u. Exiting\n",
|
||||
ctrl_vty_get_bind_addr(), OSMO_CTRL_PORT_MGW);
|
||||
}
|
||||
|
||||
/* Set the reset callback function. This functions is called when the
|
||||
* mgcp-command "RSIP" (Reset in Progress) is received */
|
||||
cfg->reset_cb = mgcp_rsip_cb;
|
||||
|
||||
@@ -36,6 +36,7 @@ mgcp_test_LDADD = \
|
||||
$(LIBOSMOVTY_LIBS) \
|
||||
$(LIBOSMOGSM_LIBS) \
|
||||
$(LIBRARY_DL) \
|
||||
$(LIBRARY_DLSYM) \
|
||||
$(LIBOSMONETIF_LIBS) \
|
||||
-lm \
|
||||
$(NULL)
|
||||
|
||||
@@ -35,6 +35,7 @@ mgcp_client_test_LDADD = \
|
||||
$(LIBOSMOCORE_LIBS) \
|
||||
$(LIBOSMOVTY_LIBS) \
|
||||
$(LIBRARY_DL) \
|
||||
$(LIBRARY_DLSYM) \
|
||||
$(LIBOSMONETIF_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user