osmo-mgw: rename struct mgcp_trunk_config and symbol tcfg
rename struct mgcp_trunk_config to struct mgcp_trunk and the related
symbol name "tcfg" to "trunk" in order to better match the reality.
Change-Id: I02889dbf8149e139b1bd0326e13ce4c1aec867d1
Related: OS#2659
diff --git a/src/libosmo-mgcp/mgcp_codec.c b/src/libosmo-mgcp/mgcp_codec.c
index 9e55ab0..3cea495 100644
--- a/src/libosmo-mgcp/mgcp_codec.c
+++ b/src/libosmo-mgcp/mgcp_codec.c
@@ -292,7 +292,7 @@
* We do not compare to the full audio_name because we expect that
* "GSM", "GSM/8000" and "GSM/8000/1" are all compatible when the
* audio name of the codec is set to "GSM" */
- if (sscanf(endp->tcfg->audio_name, "%63[^/]/%*d/%*d", codec_name) < 1)
+ if (sscanf(endp->trunk->audio_name, "%63[^/]/%*d/%*d", codec_name) < 1)
return false;
/* Finally we check if the subtype_name we have generated from the
@@ -302,9 +302,9 @@
return true;
/* FIXME: It is questinable that the method to pick a compatible
- * codec can work properly. Since this useses tcfg->audio_name, as
+ * codec can work properly. Since this useses trunk->audio_name, as
* a reference, which is set to "AMR/8000" permanently.
- * tcfg->audio_name must be updated by the first connection that
+ * trunk->audio_name must be updated by the first connection that
* has been made on an endpoint, so that the second connection
* can make a meaningful decision here */
@@ -335,7 +335,7 @@
for (i = 0; i < rtp->codecs_assigned; i++) {
/* When no transcoding is available, avoid codecs that would
* require transcoding. */
- if (endp->tcfg->no_audio_transcoding && !is_codec_compatible(endp, &rtp->codecs[i])) {
+ if (endp->trunk->no_audio_transcoding && !is_codec_compatible(endp, &rtp->codecs[i])) {
LOGP(DLMGCP, LOGL_NOTICE, "transcoding not available, skipping codec: %d/%s\n",
rtp->codecs[i].payload_type, rtp->codecs[i].subtype_name);
continue;
diff --git a/src/libosmo-mgcp/mgcp_conn.c b/src/libosmo-mgcp/mgcp_conn.c
index 7a86274..0b499b4 100644
--- a/src/libosmo-mgcp/mgcp_conn.c
+++ b/src/libosmo-mgcp/mgcp_conn.c
@@ -255,7 +255,7 @@
}
static void
-aggregate_rtp_conn_stats(struct mgcp_trunk_config *trunk, struct mgcp_conn_rtp *conn_rtp)
+aggregate_rtp_conn_stats(struct mgcp_trunk *trunk, struct mgcp_conn_rtp *conn_rtp)
{
struct rate_ctr_group *all_stats = trunk->all_rtp_conn_stats;
struct rate_ctr_group *conn_stats = conn_rtp->rate_ctr_group;
@@ -296,7 +296,7 @@
switch (conn->type) {
case MGCP_CONN_TYPE_RTP:
- aggregate_rtp_conn_stats(endp->tcfg, &conn->u.rtp);
+ aggregate_rtp_conn_stats(endp->trunk, &conn->u.rtp);
mgcp_rtp_conn_cleanup(&conn->u.rtp);
break;
default:
diff --git a/src/libosmo-mgcp/mgcp_msg.c b/src/libosmo-mgcp/mgcp_msg.c
index b0d1a9f..7124a39 100644
--- a/src/libosmo-mgcp/mgcp_msg.c
+++ b/src/libosmo-mgcp/mgcp_msg.c
@@ -136,12 +136,12 @@
const char *mgcp)
{
char *rest = NULL;
- struct mgcp_trunk_config *tcfg;
- int trunk, endp;
+ struct mgcp_trunk *trunk;
+ int trunk_index, endp;
struct mgcp_endpoint *endp_ptr;
- trunk = strtoul(mgcp + 6, &rest, 10);
- if (rest == NULL || rest[0] != '/' || trunk < 1) {
+ trunk_index = strtoul(mgcp + 6, &rest, 10);
+ if (rest == NULL || rest[0] != '/' || trunk_index < 1) {
LOGP(DLMGCP, LOGL_ERROR, "Wrong trunk name '%s'\n", mgcp);
return NULL;
}
@@ -156,26 +156,26 @@
if (endp == 1)
return NULL;
- tcfg = mgcp_trunk_num(cfg, trunk);
- if (!tcfg) {
+ trunk = mgcp_trunk_num(cfg, trunk_index);
+ if (!trunk) {
LOGP(DLMGCP, LOGL_ERROR, "The trunk %d is not declared.\n",
- trunk);
+ trunk_index);
return NULL;
}
- if (!tcfg->endpoints) {
+ if (!trunk->endpoints) {
LOGP(DLMGCP, LOGL_ERROR,
- "Endpoints of trunk %d not allocated.\n", trunk);
+ "Endpoints of trunk %d not allocated.\n", trunk_index);
return NULL;
}
- if (endp < 1 || endp >= tcfg->number_endpoints) {
+ if (endp < 1 || endp >= trunk->number_endpoints) {
LOGP(DLMGCP, LOGL_ERROR, "Failed to find endpoint '%s'\n",
mgcp);
return NULL;
}
- endp_ptr = &tcfg->endpoints[endp];
+ endp_ptr = &trunk->endpoints[endp];
endp_ptr->wildcarded_req = false;
return endp_ptr;
}
@@ -235,7 +235,7 @@
unsigned int gw = INT_MAX;
const char *endpoint_number_str;
struct mgcp_endpoint *endp;
- struct mgcp_trunk_config *virt_trunk = cfg->virt_trunk;
+ struct mgcp_trunk *virt_trunk = cfg->virt_trunk;
*cause = 0;
diff --git a/src/libosmo-mgcp/mgcp_network.c b/src/libosmo-mgcp/mgcp_network.c
index 3b8e736..2d3fdc3 100644
--- a/src/libosmo-mgcp/mgcp_network.c
+++ b/src/libosmo-mgcp/mgcp_network.c
@@ -61,7 +61,7 @@
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;
+ struct rate_ctr_group *trunk_stats = endp->trunk->all_rtp_conn_stats;
/* add to both the per-connection and the per-trunk global stats */
rate_ctr_add(&conn_stats->ctr[id], inc);
@@ -187,7 +187,7 @@
if (rc == -1)
goto failed;
- if (endp->tcfg->omit_rtcp)
+ if (endp->trunk->omit_rtcp)
return rc;
was_rtcp = 1;
@@ -819,7 +819,7 @@
* connection in loopback mode exists), then the source connection
* shall be specified as destination connection */
- struct mgcp_trunk_config *tcfg = endp->tcfg;
+ struct mgcp_trunk *trunk = endp->trunk;
struct mgcp_rtp_end *rtp_end;
struct mgcp_rtp_state *rtp_state;
char *dest_name;
@@ -835,7 +835,7 @@
}
LOGPENDP(endp, DRTP, LOGL_DEBUG, "loop:%d, mode:%d%s\n",
- tcfg->audio_loop, conn_src->conn->mode,
+ trunk->audio_loop, conn_src->conn->mode,
conn_src->conn->mode == MGCP_CONN_LOOPBACK ? " (loopback)" : "");
/* FIXME: It is legal that the payload type on the egress connection is
@@ -947,7 +947,7 @@
buflen = cont;
} while (buflen > 0);
return nbytes;
- } else if (!tcfg->omit_rtcp) {
+ } else if (!trunk->omit_rtcp) {
LOGPENDP(endp, DRTP, LOGL_DEBUG,
"send to %s %s rtp_port:%u rtcp_port:%u\n",
dest_name, inet_ntoa(rtp_end->addr),
@@ -1150,12 +1150,12 @@
{
struct mgcp_endpoint *endp;
struct mgcp_conn_rtp *conn;
- struct mgcp_trunk_config *tcfg;
+ struct mgcp_trunk *trunk;
int rc;
conn = (struct mgcp_conn_rtp*) fd->data;
endp = conn->conn->endp;
- tcfg = endp->tcfg;
+ trunk = endp->trunk;
LOGPCONN(conn->conn, DRTP, LOGL_DEBUG, "receiving RTP/RTCP packet...\n");
@@ -1190,7 +1190,7 @@
LOGPENDP(endp, DRTP, LOGL_DEBUG, "conn:%s\n", mgcp_conn_dump(conn->conn));
/* Check if the origin of the RTP packet seems plausible */
- if (tcfg->rtp_accept_all == 0) {
+ if (trunk->rtp_accept_all == 0) {
if (check_rtp_origin(conn, addr) != 0)
return -1;
}
diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index caed0b7..4d77a4c 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -254,11 +254,11 @@
* Remember the last transmission per endpoint.
*/
if (endp) {
- struct mgcp_trunk_config *tcfg = endp->tcfg;
+ struct mgcp_trunk *trunk = endp->trunk;
talloc_free(endp->last_response);
talloc_free(endp->last_trans);
- endp->last_trans = talloc_strdup(tcfg->endpoints, trans);
- endp->last_response = talloc_strndup(tcfg->endpoints,
+ endp->last_trans = talloc_strdup(trunk->endpoints, trans);
+ endp->last_response = talloc_strndup(trunk->endpoints,
(const char *)res->l2h,
msgb_l2len(res));
}
@@ -296,7 +296,7 @@
/* NOTE: Only in the virtual trunk we allow dynamic endpoint names */
if (endp->wildcarded_req
- && endp->tcfg->trunk_type == MGCP_TRUNK_VIRTUAL) {
+ && endp->trunk->trunk_type == MGCP_TRUNK_VIRTUAL) {
rc = msgb_printf(msg, "Z: %s%x@%s\r\n",
MGCP_ENDPOINT_PREFIX_VIRTUAL_TRUNK,
ENDPOINT_NUMBER(endp), endp->cfg->domain);
@@ -379,8 +379,8 @@
* - 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->virt_trunk;
- struct rate_ctr_group *rate_ctrs = tcfg->mgcp_general_ctr_group;
+ struct mgcp_trunk *trunk = cfg->virt_trunk;
+ struct rate_ctr_group *rate_ctrs = trunk->mgcp_general_ctr_group;
struct mgcp_parse_data pdata;
int rc, i, code, handled = 0;
struct msgb *resp = NULL;
@@ -692,13 +692,13 @@
void mgcp_rtp_end_config(struct mgcp_endpoint *endp, int expect_ssrc_change,
struct mgcp_rtp_end *rtp)
{
- struct mgcp_trunk_config *tcfg = endp->tcfg;
+ struct mgcp_trunk *trunk = endp->trunk;
- int patch_ssrc = expect_ssrc_change && tcfg->force_constant_ssrc;
+ int patch_ssrc = expect_ssrc_change && trunk->force_constant_ssrc;
- rtp->force_aligned_timing = tcfg->force_aligned_timing;
+ rtp->force_aligned_timing = trunk->force_aligned_timing;
rtp->force_constant_ssrc = patch_ssrc ? 1 : 0;
- rtp->rfc5993_hr_convert = tcfg->rfc5993_hr_convert;
+ rtp->rfc5993_hr_convert = trunk->rfc5993_hr_convert;
LOGPENDP(endp, DLMGCP, LOGL_DEBUG,
"Configuring RTP endpoint: local port %d%s%s\n",
@@ -830,9 +830,9 @@
/* CRCX command handler, processes the received command */
static struct msgb *handle_create_con(struct mgcp_parse_data *p)
{
- struct mgcp_trunk_config *tcfg = p->endp->tcfg;
+ struct mgcp_trunk *trunk = p->endp->trunk;
struct mgcp_endpoint *endp = p->endp;
- struct rate_ctr_group *rate_ctrs = tcfg->mgcp_crcx_ctr_group;
+ struct rate_ctr_group *rate_ctrs = trunk->mgcp_crcx_ctr_group;
int error_code = 400;
const char *local_options = NULL;
const char *callid = NULL;
@@ -915,7 +915,7 @@
LOGPENDP(endp, DLMGCP, LOGL_ERROR,
"CRCX: endpoint full, max. %i connections allowed!\n",
endp->type->max_conns);
- if (tcfg->force_realloc) {
+ if (trunk->force_realloc) {
/* There is no more room for a connection, make some
* room by blindly tossing the oldest of the two two
* connections */
@@ -934,7 +934,7 @@
LOGPENDP(endp, DLMGCP, LOGL_ERROR,
"CRCX: already seized by other call (%s)\n",
endp->callid);
- if (tcfg->force_realloc)
+ if (trunk->force_realloc)
/* This is not our call, toss everything by releasing
* the entire endpoint. (rude!) */
mgcp_endp_release(endp);
@@ -949,10 +949,10 @@
/* Set the callid, creation of another connection will only be possible
* when the callid matches up. (Connections are distinguished by their
* connection ids) */
- endp->callid = talloc_strdup(tcfg->endpoints, callid);
+ endp->callid = talloc_strdup(trunk->endpoints, callid);
snprintf(conn_name, sizeof(conn_name), "%s", callid);
- _conn = mgcp_conn_alloc(tcfg->endpoints, endp, MGCP_CONN_TYPE_RTP, conn_name);
+ _conn = mgcp_conn_alloc(trunk->endpoints, endp, MGCP_CONN_TYPE_RTP, conn_name);
if (!_conn) {
LOGPENDP(endp, DLMGCP, LOGL_ERROR,
"CRCX: unable to allocate RTP connection\n");
@@ -987,7 +987,7 @@
/* Set local connection options, if present */
if (local_options) {
- rc = set_local_cx_options(endp->tcfg->endpoints,
+ rc = set_local_cx_options(endp->trunk->endpoints,
&endp->local_options, local_options);
if (rc != 0) {
LOGPCONN(_conn, DLMGCP, LOGL_ERROR,
@@ -1007,8 +1007,8 @@
goto error2;
}
- conn->end.fmtp_extra = talloc_strdup(tcfg->endpoints,
- tcfg->audio_fmtp_extra);
+ conn->end.fmtp_extra = talloc_strdup(trunk->endpoints,
+ trunk->audio_fmtp_extra);
if (p->cfg->force_ptime) {
conn->end.packet_duration_ms = p->cfg->force_ptime;
@@ -1043,7 +1043,7 @@
/* policy CB */
if (p->cfg->policy_cb) {
int rc;
- rc = p->cfg->policy_cb(tcfg, ENDPOINT_NUMBER(endp),
+ rc = p->cfg->policy_cb(trunk, ENDPOINT_NUMBER(endp),
MGCP_ENDP_CRCX, p->trans);
switch (rc) {
case MGCP_POLICY_REJECT:
@@ -1066,12 +1066,12 @@
LOGPCONN(conn->conn, DLMGCP, LOGL_DEBUG,
"CRCX: Creating connection: port: %u\n", conn->end.local_port);
if (p->cfg->change_cb)
- p->cfg->change_cb(tcfg, ENDPOINT_NUMBER(endp), MGCP_ENDP_CRCX);
+ p->cfg->change_cb(trunk, ENDPOINT_NUMBER(endp), MGCP_ENDP_CRCX);
/* Send dummy packet, see also comments in mgcp_keepalive_timer_cb() */
- OSMO_ASSERT(tcfg->keepalive_interval >= MGCP_KEEPALIVE_ONCE);
+ OSMO_ASSERT(trunk->keepalive_interval >= MGCP_KEEPALIVE_ONCE);
if (conn->conn->mode & MGCP_CONN_RECV_ONLY
- && tcfg->keepalive_interval != MGCP_KEEPALIVE_NEVER)
+ && trunk->keepalive_interval != MGCP_KEEPALIVE_NEVER)
send_dummy(endp, conn);
LOGPCONN(_conn, DLMGCP, LOGL_NOTICE,
@@ -1088,9 +1088,9 @@
/* MDCX command handler, processes the received command */
static struct msgb *handle_modify_con(struct mgcp_parse_data *p)
{
- struct mgcp_trunk_config *tcfg = p->endp->tcfg;
+ struct mgcp_trunk *trunk = p->endp->trunk;
struct mgcp_endpoint *endp = p->endp;
- struct rate_ctr_group *rate_ctrs = tcfg->mgcp_mdcx_ctr_group;
+ struct rate_ctr_group *rate_ctrs = trunk->mgcp_mdcx_ctr_group;
int error_code = 500;
int silent = 0;
int have_sdp = 0;
@@ -1198,7 +1198,7 @@
/* Set local connection options, if present */
if (local_options) {
- rc = set_local_cx_options(endp->tcfg->endpoints,
+ rc = set_local_cx_options(endp->trunk->endpoints,
&endp->local_options, local_options);
if (rc != 0) {
LOGPCONN(conn->conn, DLMGCP, LOGL_ERROR,
@@ -1257,7 +1257,7 @@
/* policy CB */
if (p->cfg->policy_cb) {
int rc;
- rc = p->cfg->policy_cb(endp->tcfg, ENDPOINT_NUMBER(endp),
+ rc = p->cfg->policy_cb(endp->trunk, ENDPOINT_NUMBER(endp),
MGCP_ENDP_MDCX, p->trans);
switch (rc) {
case MGCP_POLICY_REJECT:
@@ -1287,13 +1287,13 @@
LOGPCONN(conn->conn, DLMGCP, LOGL_DEBUG,
"MDCX: modified conn:%s\n", mgcp_conn_dump(conn->conn));
if (p->cfg->change_cb)
- p->cfg->change_cb(endp->tcfg, ENDPOINT_NUMBER(endp),
+ p->cfg->change_cb(endp->trunk, ENDPOINT_NUMBER(endp),
MGCP_ENDP_MDCX);
/* Send dummy packet, see also comments in mgcp_keepalive_timer_cb() */
- OSMO_ASSERT(endp->tcfg->keepalive_interval >= MGCP_KEEPALIVE_ONCE);
+ OSMO_ASSERT(endp->trunk->keepalive_interval >= MGCP_KEEPALIVE_ONCE);
if (conn->conn->mode & MGCP_CONN_RECV_ONLY
- && endp->tcfg->keepalive_interval != MGCP_KEEPALIVE_NEVER)
+ && endp->trunk->keepalive_interval != MGCP_KEEPALIVE_NEVER)
send_dummy(endp, conn);
rate_ctr_inc(&rate_ctrs->ctr[MGCP_MDCX_SUCCESS]);
@@ -1314,9 +1314,9 @@
/* DLCX command handler, processes the received command */
static struct msgb *handle_delete_con(struct mgcp_parse_data *p)
{
- struct mgcp_trunk_config *tcfg = p->endp->tcfg;
+ struct mgcp_trunk *trunk = p->endp->trunk;
struct mgcp_endpoint *endp = p->endp;
- struct rate_ctr_group *rate_ctrs = tcfg->mgcp_dlcx_ctr_group;
+ struct rate_ctr_group *rate_ctrs = trunk->mgcp_dlcx_ctr_group;
int error_code = 400;
int silent = 0;
char *line;
@@ -1377,7 +1377,7 @@
/* policy CB */
if (p->cfg->policy_cb) {
int rc;
- rc = p->cfg->policy_cb(endp->tcfg, ENDPOINT_NUMBER(endp),
+ rc = p->cfg->policy_cb(endp->trunk, ENDPOINT_NUMBER(endp),
MGCP_ENDP_DLCX, p->trans);
switch (rc) {
case MGCP_POLICY_REJECT:
@@ -1442,7 +1442,7 @@
}
if (p->cfg->change_cb)
- p->cfg->change_cb(endp->tcfg, ENDPOINT_NUMBER(endp),
+ p->cfg->change_cb(endp->trunk, ENDPOINT_NUMBER(endp),
MGCP_ENDP_DLCX);
rate_ctr_inc(&rate_ctrs->ctr[MGCP_DLCX_SUCCESS]);
@@ -1472,7 +1472,7 @@
LOGP(DLMGCP, LOGL_NOTICE, "RSIP: resetting all endpoints ...\n");
if (p->cfg->reset_cb)
- p->cfg->reset_cb(p->endp->tcfg);
+ p->cfg->reset_cb(p->endp->trunk);
return NULL;
}
@@ -1518,37 +1518,37 @@
/* Connection keepalive timer, will take care that dummy packets are send
* regularly, so that NAT connections stay open */
-static void mgcp_keepalive_timer_cb(void *_tcfg)
+static void mgcp_keepalive_timer_cb(void *_trunk)
{
- struct mgcp_trunk_config *tcfg = _tcfg;
+ struct mgcp_trunk *trunk = _trunk;
struct mgcp_conn *conn;
int i;
LOGP(DLMGCP, LOGL_DEBUG, "triggered trunk %d keepalive timer\n",
- tcfg->trunk_nr);
+ trunk->trunk_nr);
/* Do not accept invalid configuration values
* valid is MGCP_KEEPALIVE_NEVER, MGCP_KEEPALIVE_ONCE and
* values greater 0 */
- OSMO_ASSERT(tcfg->keepalive_interval >= MGCP_KEEPALIVE_ONCE);
+ OSMO_ASSERT(trunk->keepalive_interval >= MGCP_KEEPALIVE_ONCE);
/* The dummy packet functionality has been disabled, we will exit
* immediately, no further timer is scheduled, which means we will no
* longer send dummy packets even when we did before */
- if (tcfg->keepalive_interval == MGCP_KEEPALIVE_NEVER)
+ if (trunk->keepalive_interval == MGCP_KEEPALIVE_NEVER)
return;
/* In cases where only one dummy packet is sent, we do not need
* the timer since the functions that handle the CRCX and MDCX are
* triggering the sending of the dummy packet. So we behave like in
* the MGCP_KEEPALIVE_NEVER case */
- if (tcfg->keepalive_interval == MGCP_KEEPALIVE_ONCE)
+ if (trunk->keepalive_interval == MGCP_KEEPALIVE_ONCE)
return;
/* Send walk over all endpoints and send out dummy packets through
* every connection present on each endpoint */
- for (i = 1; i < tcfg->number_endpoints; ++i) {
- struct mgcp_endpoint *endp = &tcfg->endpoints[i];
+ for (i = 1; i < trunk->number_endpoints; ++i) {
+ struct mgcp_endpoint *endp = &trunk->endpoints[i];
llist_for_each_entry(conn, &endp->conns, entry) {
if (conn->mode == MGCP_CONN_RECV_ONLY)
send_dummy(endp, &conn->u.rtp);
@@ -1557,21 +1557,21 @@
/* Schedule the keepalive timer for the next round */
LOGP(DLMGCP, LOGL_DEBUG, "rescheduling trunk %d keepalive timer\n",
- tcfg->trunk_nr);
- osmo_timer_schedule(&tcfg->keepalive_timer, tcfg->keepalive_interval,
+ trunk->trunk_nr);
+ osmo_timer_schedule(&trunk->keepalive_timer, trunk->keepalive_interval,
0);
}
-void mgcp_trunk_set_keepalive(struct mgcp_trunk_config *tcfg, int interval)
+void mgcp_trunk_set_keepalive(struct mgcp_trunk *trunk, int interval)
{
- tcfg->keepalive_interval = interval;
- osmo_timer_setup(&tcfg->keepalive_timer, mgcp_keepalive_timer_cb, tcfg);
+ trunk->keepalive_interval = interval;
+ osmo_timer_setup(&trunk->keepalive_timer, mgcp_keepalive_timer_cb, trunk);
if (interval <= 0)
- osmo_timer_del(&tcfg->keepalive_timer);
+ osmo_timer_del(&trunk->keepalive_timer);
else
- osmo_timer_schedule(&tcfg->keepalive_timer,
- tcfg->keepalive_interval, 0);
+ osmo_timer_schedule(&trunk->keepalive_timer,
+ trunk->keepalive_interval, 0);
}
static int free_rate_counter_group(struct rate_ctr_group *rate_ctr_group)
@@ -1580,7 +1580,7 @@
return 0;
}
-static int alloc_mgcp_rate_counters(struct mgcp_trunk_config *trunk, void *ctx)
+static int alloc_mgcp_rate_counters(struct mgcp_trunk *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
@@ -1676,11 +1676,11 @@
* \param[in] cfg mgcp configuration
* \param[in] nr trunk number
* \returns pointer to allocated trunk configuration */
-struct mgcp_trunk_config *mgcp_trunk_alloc(struct mgcp_config *cfg, enum mgcp_trunk_type ttype, int nr)
+struct mgcp_trunk *mgcp_trunk_alloc(struct mgcp_config *cfg, enum mgcp_trunk_type ttype, int nr)
{
- struct mgcp_trunk_config *trunk;
+ struct mgcp_trunk *trunk;
- trunk = talloc_zero(cfg, struct mgcp_trunk_config);
+ trunk = talloc_zero(cfg, struct mgcp_trunk);
if (!trunk) {
LOGP(DLMGCP, LOGL_ERROR, "Failed to allocate.\n");
return NULL;
@@ -1709,9 +1709,9 @@
* \param[in] cfg mgcp configuration
* \param[in] index trunk number
* \returns pointer to trunk configuration, NULL on error */
-struct mgcp_trunk_config *mgcp_trunk_num(struct mgcp_config *cfg, int index)
+struct mgcp_trunk *mgcp_trunk_num(struct mgcp_config *cfg, int index)
{
- struct mgcp_trunk_config *trunk;
+ struct mgcp_trunk *trunk;
llist_for_each_entry(trunk, &cfg->trunks, entry)
if (trunk->trunk_nr == index)
@@ -1722,27 +1722,27 @@
/*! allocate endpoints and set default values.
* (called once at startup by VTY)
- * \param[in] tcfg trunk configuration
+ * \param[in] trunk trunk configuration
* \returns 0 on success, -1 on failure */
-int mgcp_endpoints_allocate(struct mgcp_trunk_config *tcfg)
+int mgcp_endpoints_allocate(struct mgcp_trunk *trunk)
{
int i;
- tcfg->endpoints = _talloc_zero_array(tcfg->cfg,
+ trunk->endpoints = _talloc_zero_array(trunk->cfg,
sizeof(struct mgcp_endpoint),
- tcfg->vty_number_endpoints,
+ trunk->vty_number_endpoints,
"endpoints");
- if (!tcfg->endpoints)
+ if (!trunk->endpoints)
return -1;
- for (i = 0; i < tcfg->vty_number_endpoints; ++i) {
- INIT_LLIST_HEAD(&tcfg->endpoints[i].conns);
- tcfg->endpoints[i].cfg = tcfg->cfg;
- tcfg->endpoints[i].tcfg = tcfg;
+ for (i = 0; i < trunk->vty_number_endpoints; ++i) {
+ INIT_LLIST_HEAD(&trunk->endpoints[i].conns);
+ trunk->endpoints[i].cfg = trunk->cfg;
+ trunk->endpoints[i].trunk = trunk;
- switch (tcfg->trunk_type) {
+ switch (trunk->trunk_type) {
case MGCP_TRUNK_VIRTUAL:
- tcfg->endpoints[i].type = &ep_typeset.rtp;
+ trunk->endpoints[i].type = &ep_typeset.rtp;
break;
case MGCP_TRUNK_E1:
/* FIXME: Implement E1 allocation */
@@ -1750,12 +1750,12 @@
break;
default:
osmo_panic("Cannot allocate unimplemented trunk type %d! %s:%d\n",
- tcfg->trunk_type, __FILE__, __LINE__);
+ trunk->trunk_type, __FILE__, __LINE__);
}
}
- tcfg->number_endpoints = tcfg->vty_number_endpoints;
- alloc_mgcp_rate_counters(tcfg, tcfg->cfg);
+ trunk->number_endpoints = trunk->vty_number_endpoints;
+ alloc_mgcp_rate_counters(trunk, trunk->cfg);
return 0;
}
diff --git a/src/libosmo-mgcp/mgcp_sdp.c b/src/libosmo-mgcp/mgcp_sdp.c
index 01e7968..428bde6 100644
--- a/src/libosmo-mgcp/mgcp_sdp.c
+++ b/src/libosmo-mgcp/mgcp_sdp.c
@@ -557,7 +557,7 @@
if (rc < 0)
goto buffer_too_small;
- if (endp->tcfg->audio_send_name) {
+ if (endp->trunk->audio_send_name) {
rc = add_rtpmap(sdp, payload_type, audio_name);
if (rc < 0)
goto buffer_too_small;
@@ -573,7 +573,7 @@
if (rc < 0)
goto buffer_too_small;
}
- if (conn->end.packet_duration_ms > 0 && endp->tcfg->audio_send_ptime) {
+ if (conn->end.packet_duration_ms > 0 && endp->trunk->audio_send_ptime) {
rc = msgb_printf(sdp, "a=ptime:%u\r\n",
conn->end.packet_duration_ms);
if (rc < 0)
diff --git a/src/libosmo-mgcp/mgcp_vty.c b/src/libosmo-mgcp/mgcp_vty.c
index 856c971..137d5de 100644
--- a/src/libosmo-mgcp/mgcp_vty.c
+++ b/src/libosmo-mgcp/mgcp_vty.c
@@ -42,9 +42,9 @@
static struct mgcp_config *g_cfg = NULL;
-static struct mgcp_trunk_config *find_trunk(struct mgcp_config *cfg, int nr)
+static struct mgcp_trunk *find_trunk(struct mgcp_config *cfg, int nr)
{
- struct mgcp_trunk_config *trunk;
+ struct mgcp_trunk *trunk;
if (nr == 0)
trunk = cfg->virt_trunk;
@@ -68,7 +68,7 @@
static int config_write_mgcp(struct vty *vty)
{
- struct mgcp_trunk_config *trunk = g_cfg->virt_trunk;
+ struct mgcp_trunk *trunk = g_cfg->virt_trunk;
vty_out(vty, "mgcp%s", VTY_NEWLINE);
vty_out(vty, " domain %s%s", g_cfg->domain, VTY_NEWLINE);
@@ -244,7 +244,7 @@
}
}
-static void dump_trunk(struct vty *vty, struct mgcp_trunk_config *cfg, int show_stats)
+static void dump_trunk(struct vty *vty, struct mgcp_trunk *cfg, int show_stats)
{
int i;
@@ -298,7 +298,7 @@
SHOW_MGCP_STR
"Include Statistics\n")
{
- struct mgcp_trunk_config *trunk;
+ struct mgcp_trunk *trunk;
int show_stats = argc >= 1;
dump_trunk(vty, g_cfg->virt_trunk, show_stats);
@@ -314,7 +314,7 @@
}
static void
-dump_mgcp_endpoint(struct vty *vty, struct mgcp_trunk_config *trunk, const char *epname)
+dump_mgcp_endpoint(struct vty *vty, struct mgcp_trunk *trunk, const char *epname)
{
const size_t virt_prefix_len = sizeof(MGCP_ENDPOINT_PREFIX_VIRTUAL_TRUNK) - 1;
unsigned long epidx;
@@ -350,7 +350,7 @@
SHOW_MGCP_STR
"Display information about an endpoint\n" "The name of the endpoint\n")
{
- struct mgcp_trunk_config *trunk;
+ struct mgcp_trunk *trunk;
dump_mgcp_endpoint(vty, g_cfg->virt_trunk, argv[0]);
llist_for_each_entry(trunk, &g_cfg->trunks, entry)
@@ -366,7 +366,7 @@
"Display information about a trunk\n" "Trunk number\n"
"Display information about an endpoint\n" "The name of the endpoint\n")
{
- struct mgcp_trunk_config *trunk;
+ struct mgcp_trunk *trunk;
int trunkidx = atoi(argv[0]);
trunk = find_trunk(g_cfg, trunkidx);
@@ -807,7 +807,7 @@
DEFUN(cfg_mgcp_trunk, cfg_mgcp_trunk_cmd,
"trunk <1-64>", "Configure a SS7 trunk\n" "Trunk Nr\n")
{
- struct mgcp_trunk_config *trunk;
+ struct mgcp_trunk *trunk;
int index = atoi(argv[0]);
trunk = mgcp_trunk_num(g_cfg, index);
@@ -827,7 +827,7 @@
static int config_write_trunk(struct vty *vty)
{
- struct mgcp_trunk_config *trunk;
+ struct mgcp_trunk *trunk;
llist_for_each_entry(trunk, &g_cfg->trunks, entry) {
vty_out(vty, " trunk %d%s", trunk->trunk_nr, VTY_NEWLINE);
@@ -885,7 +885,7 @@
"Add extra fmtp for the SDP file\n" "Audio\n" "Fmtp-extra\n"
"Extra Information\n")
{
- struct mgcp_trunk_config *trunk = vty->index;
+ struct mgcp_trunk *trunk = vty->index;
char *txt = argv_concat(argv, argc, 0);
if (!txt)
return CMD_WARNING;
@@ -900,7 +900,7 @@
"sdp audio-payload number <0-255>",
SDP_STR AUDIO_STR "Number\n" "Payload Number\n")
{
- struct mgcp_trunk_config *trunk = vty->index;
+ struct mgcp_trunk *trunk = vty->index;
unsigned int payload = atoi(argv[0]);
trunk->audio_payload = payload;
@@ -916,7 +916,7 @@
"sdp audio-payload name NAME",
SDP_STR AUDIO_STR "Payload\n" "Payload Name\n")
{
- struct mgcp_trunk_config *trunk = vty->index;
+ struct mgcp_trunk *trunk = vty->index;
osmo_talloc_replace_string(g_cfg, &trunk->audio_name, argv[0]);
return CMD_SUCCESS;
@@ -931,7 +931,7 @@
"loop (0|1)",
"Loop audio for all endpoints on this trunk\n" "Don't Loop\n" "Loop\n")
{
- struct mgcp_trunk_config *trunk = vty->index;
+ struct mgcp_trunk *trunk = vty->index;
if (g_cfg->osmux) {
vty_out(vty, "Cannot use `loop' with `osmux'.%s", VTY_NEWLINE);
@@ -946,7 +946,7 @@
"sdp audio-payload send-ptime",
SDP_STR AUDIO_STR "Send SDP ptime (packet duration) attribute\n")
{
- struct mgcp_trunk_config *trunk = vty->index;
+ struct mgcp_trunk *trunk = vty->index;
trunk->audio_send_ptime = 1;
return CMD_SUCCESS;
}
@@ -956,7 +956,7 @@
"no sdp audio-payload send-ptime",
NO_STR SDP_STR AUDIO_STR "Send SDP ptime (packet duration) attribute\n")
{
- struct mgcp_trunk_config *trunk = vty->index;
+ struct mgcp_trunk *trunk = vty->index;
trunk->audio_send_ptime = 0;
return CMD_SUCCESS;
}
@@ -966,7 +966,7 @@
"sdp audio-payload send-name",
SDP_STR AUDIO_STR "Send SDP rtpmap with the audio name\n")
{
- struct mgcp_trunk_config *trunk = vty->index;
+ struct mgcp_trunk *trunk = vty->index;
trunk->audio_send_name = 1;
return CMD_SUCCESS;
}
@@ -976,14 +976,14 @@
"no sdp audio-payload send-name",
NO_STR SDP_STR AUDIO_STR "Send SDP rtpmap with the audio name\n")
{
- struct mgcp_trunk_config *trunk = vty->index;
+ struct mgcp_trunk *trunk = vty->index;
trunk->audio_send_name = 0;
return CMD_SUCCESS;
}
DEFUN(cfg_trunk_omit_rtcp, cfg_trunk_omit_rtcp_cmd, "rtcp-omit", RTCP_OMIT_STR)
{
- struct mgcp_trunk_config *trunk = vty->index;
+ struct mgcp_trunk *trunk = vty->index;
trunk->omit_rtcp = 1;
return CMD_SUCCESS;
}
@@ -991,7 +991,7 @@
DEFUN(cfg_trunk_no_omit_rtcp,
cfg_trunk_no_omit_rtcp_cmd, "no rtcp-omit", NO_STR RTCP_OMIT_STR)
{
- struct mgcp_trunk_config *trunk = vty->index;
+ struct mgcp_trunk *trunk = vty->index;
trunk->omit_rtcp = 0;
return CMD_SUCCESS;
}
@@ -1000,7 +1000,7 @@
cfg_trunk_patch_rtp_ssrc_cmd,
"rtp-patch ssrc", RTP_PATCH_STR "Force a fixed SSRC\n")
{
- struct mgcp_trunk_config *trunk = vty->index;
+ struct mgcp_trunk *trunk = vty->index;
trunk->force_constant_ssrc = 1;
return CMD_SUCCESS;
}
@@ -1009,7 +1009,7 @@
cfg_trunk_no_patch_rtp_ssrc_cmd,
"no rtp-patch ssrc", NO_STR RTP_PATCH_STR "Force a fixed SSRC\n")
{
- struct mgcp_trunk_config *trunk = vty->index;
+ struct mgcp_trunk *trunk = vty->index;
trunk->force_constant_ssrc = 0;
return CMD_SUCCESS;
}
@@ -1018,7 +1018,7 @@
cfg_trunk_patch_rtp_ts_cmd,
"rtp-patch timestamp", RTP_PATCH_STR "Adjust RTP timestamp\n")
{
- struct mgcp_trunk_config *trunk = vty->index;
+ struct mgcp_trunk *trunk = vty->index;
trunk->force_aligned_timing = 1;
return CMD_SUCCESS;
}
@@ -1027,7 +1027,7 @@
cfg_trunk_no_patch_rtp_ts_cmd,
"no rtp-patch timestamp", NO_STR RTP_PATCH_STR "Adjust RTP timestamp\n")
{
- struct mgcp_trunk_config *trunk = vty->index;
+ struct mgcp_trunk *trunk = vty->index;
trunk->force_aligned_timing = 0;
return CMD_SUCCESS;
}
@@ -1036,7 +1036,7 @@
cfg_trunk_patch_rtp_rfc5993hr_cmd,
"rtp-patch rfc5993hr", RTP_PATCH_STR RTP_TS101318_RFC5993_CONV_STR)
{
- struct mgcp_trunk_config *trunk = vty->index;
+ struct mgcp_trunk *trunk = vty->index;
trunk->rfc5993_hr_convert = true;
return CMD_SUCCESS;
}
@@ -1045,7 +1045,7 @@
cfg_trunk_no_patch_rtp_rfc5993hr_cmd,
"no rtp-patch rfc5993hr", NO_STR RTP_PATCH_STR RTP_TS101318_RFC5993_CONV_STR)
{
- struct mgcp_trunk_config *trunk = vty->index;
+ struct mgcp_trunk *trunk = vty->index;
trunk->rfc5993_hr_convert = false;
return CMD_SUCCESS;
}
@@ -1053,7 +1053,7 @@
DEFUN(cfg_trunk_no_patch_rtp,
cfg_trunk_no_patch_rtp_cmd, "no rtp-patch", NO_STR RTP_PATCH_STR)
{
- struct mgcp_trunk_config *trunk = vty->index;
+ struct mgcp_trunk *trunk = vty->index;
trunk->force_constant_ssrc = 0;
trunk->force_aligned_timing = 0;
trunk->rfc5993_hr_convert = false;
@@ -1065,7 +1065,7 @@
"rtp keep-alive <1-120>",
RTP_STR RTP_KEEPALIVE_STR "Keep-alive interval in secs\n")
{
- struct mgcp_trunk_config *trunk = vty->index;
+ struct mgcp_trunk *trunk = vty->index;
mgcp_trunk_set_keepalive(trunk, atoi(argv[0]));
return CMD_SUCCESS;
}
@@ -1075,7 +1075,7 @@
"rtp keep-alive once",
RTP_STR RTP_KEEPALIVE_STR "Send dummy packet only once after CRCX/MDCX\n")
{
- struct mgcp_trunk_config *trunk = vty->index;
+ struct mgcp_trunk *trunk = vty->index;
mgcp_trunk_set_keepalive(trunk, MGCP_KEEPALIVE_ONCE);
return CMD_SUCCESS;
}
@@ -1084,7 +1084,7 @@
cfg_trunk_no_rtp_keepalive_cmd,
"no rtp keep-alive", NO_STR RTP_STR RTP_KEEPALIVE_STR)
{
- struct mgcp_trunk_config *trunk = vty->index;
+ struct mgcp_trunk *trunk = vty->index;
mgcp_trunk_set_keepalive(trunk, 0);
return CMD_SUCCESS;
}
@@ -1093,7 +1093,7 @@
cfg_trunk_allow_transcoding_cmd,
"allow-transcoding", "Allow transcoding\n")
{
- struct mgcp_trunk_config *trunk = vty->index;
+ struct mgcp_trunk *trunk = vty->index;
trunk->no_audio_transcoding = 0;
return CMD_SUCCESS;
}
@@ -1102,7 +1102,7 @@
cfg_trunk_no_allow_transcoding_cmd,
"no allow-transcoding", NO_STR "Allow transcoding\n")
{
- struct mgcp_trunk_config *trunk = vty->index;
+ struct mgcp_trunk *trunk = vty->index;
trunk->no_audio_transcoding = 1;
return CMD_SUCCESS;
}
@@ -1114,7 +1114,7 @@
"The name in hex of the endpoint\n" "Disable the loop\n"
"Enable the loop\n")
{
- struct mgcp_trunk_config *trunk;
+ struct mgcp_trunk *trunk;
struct mgcp_endpoint *endp;
struct mgcp_conn *conn;
@@ -1172,7 +1172,7 @@
"destination IP of the data\n" "destination port\n")
{
struct mgcp_rtp_tap *tap;
- struct mgcp_trunk_config *trunk;
+ struct mgcp_trunk *trunk;
struct mgcp_endpoint *endp;
struct mgcp_conn_rtp *conn;
const char *conn_id = NULL;
@@ -1227,7 +1227,7 @@
"free-endpoint <0-64> NUMBER",
"Free the given endpoint\n" "Trunk number\n" "Endpoint number in hex.\n")
{
- struct mgcp_trunk_config *trunk;
+ struct mgcp_trunk *trunk;
struct mgcp_endpoint *endp;
trunk = find_trunk(g_cfg, atoi(argv[0]));
@@ -1259,7 +1259,7 @@
"reset-endpoint <0-64> NUMBER",
"Reset the given endpoint\n" "Trunk number\n" "Endpoint number in hex.\n")
{
- struct mgcp_trunk_config *trunk;
+ struct mgcp_trunk *trunk;
struct mgcp_endpoint *endp;
int endp_no, rc;
@@ -1502,7 +1502,7 @@
enum mgcp_role role)
{
int rc;
- struct mgcp_trunk_config *trunk;
+ struct mgcp_trunk *trunk;
cfg->osmux_port = OSMUX_PORT;
cfg->osmux_batch = 4;