mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git
synced 2025-10-23 08:12:01 +00:00
mgcp_protocol: Avoid code duplication between virtual + other trunks
There were two code paths that were supposed to do exactly the same, but then in Change-Id I3994af016fb96427263edbba05f560743f85fdd4 only one of the two was modified, resulting in OS#4034 Let's * dynamically allocate the virtual trunk * rename mgcp_config.trunk to mgcp_config.virt_trunk to clarify * as a result, abolish copy+pasted code for trunk initialization Change-Id: I54762af6d417b849a24b6e71b6c5c996a5cb3fa6 Related: OS#4034
This commit is contained in:
@@ -261,7 +261,10 @@ struct mgcp_config {
|
||||
uint32_t last_call_id;
|
||||
|
||||
/* trunk handling */
|
||||
struct mgcp_trunk_config trunk;
|
||||
|
||||
/* virtual trunk for RTP - RTP endpoints */
|
||||
struct mgcp_trunk_config *virt_trunk;
|
||||
/* physical trunks with underlying E1 endpoints */
|
||||
struct llist_head trunks;
|
||||
|
||||
enum mgcp_role role;
|
||||
|
@@ -282,7 +282,7 @@ 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_alloc(struct mgcp_config *cfg, enum mgcp_trunk_type ttype, int index);
|
||||
struct mgcp_trunk_config *mgcp_trunk_num(struct mgcp_config *cfg, int index);
|
||||
|
||||
char *get_lco_identifier(const char *options);
|
||||
|
@@ -235,6 +235,7 @@ static struct mgcp_endpoint *find_endpoint(struct mgcp_config *cfg,
|
||||
unsigned int gw = INT_MAX;
|
||||
const char *endpoint_number_str;
|
||||
struct mgcp_endpoint *endp;
|
||||
struct mgcp_trunk_config *virt_trunk = cfg->virt_trunk;
|
||||
|
||||
*cause = 0;
|
||||
|
||||
@@ -259,15 +260,15 @@ static struct mgcp_endpoint *find_endpoint(struct mgcp_config *cfg,
|
||||
endpoint_number_str =
|
||||
mgcp + strlen(MGCP_ENDPOINT_PREFIX_VIRTUAL_TRUNK);
|
||||
if (endpoint_number_str[0] == '*') {
|
||||
endp = find_free_endpoint(cfg->trunk.endpoints,
|
||||
cfg->trunk.number_endpoints);
|
||||
endp = find_free_endpoint(virt_trunk->endpoints,
|
||||
virt_trunk->number_endpoints);
|
||||
if (!endp)
|
||||
*cause = -403;
|
||||
return endp;
|
||||
}
|
||||
gw = strtoul(endpoint_number_str, &endptr, 16);
|
||||
if (gw < cfg->trunk.number_endpoints && endptr[0] == '@') {
|
||||
endp = &cfg->trunk.endpoints[gw];
|
||||
if (gw < virt_trunk->number_endpoints && endptr[0] == '@') {
|
||||
endp = &virt_trunk->endpoints[gw];
|
||||
endp->wildcarded_req = false;
|
||||
return endp;
|
||||
}
|
||||
@@ -278,8 +279,8 @@ static struct mgcp_endpoint *find_endpoint(struct mgcp_config *cfg,
|
||||
"Addressing virtual trunk without prefix (deprecated), please use %s: '%s'\n",
|
||||
MGCP_ENDPOINT_PREFIX_VIRTUAL_TRUNK, mgcp);
|
||||
gw = strtoul(mgcp, &endptr, 16);
|
||||
if (gw < cfg->trunk.number_endpoints && endptr[0] == '@') {
|
||||
endp = &cfg->trunk.endpoints[gw];
|
||||
if (gw < virt_trunk->number_endpoints && endptr[0] == '@') {
|
||||
endp = &virt_trunk->endpoints[gw];
|
||||
endp->wildcarded_req = false;
|
||||
return endp;
|
||||
}
|
||||
|
@@ -1440,7 +1440,7 @@ static int bind_rtp(struct mgcp_config *cfg, const char *source_addr,
|
||||
{
|
||||
/* NOTE: The port that is used for RTCP is the RTP port incremented by one
|
||||
* (e.g. RTP-Port = 16000 ==> RTCP-Port = 16001) */
|
||||
struct mgcp_endpoint *endp = &cfg->trunk.endpoints[endpno];
|
||||
struct mgcp_endpoint *endp = &cfg->virt_trunk->endpoints[endpno];
|
||||
|
||||
if (mgcp_create_bind(source_addr, &rtp_end->rtp,
|
||||
rtp_end->local_port) != 0) {
|
||||
|
@@ -202,9 +202,9 @@ osmux_conn_lookup(struct mgcp_config *cfg, uint8_t cid,
|
||||
struct mgcp_conn_rtp * conn_rtp;
|
||||
int i;
|
||||
|
||||
for (i=0; i<cfg->trunk.number_endpoints; i++) {
|
||||
for (i=0; i<cfg->virt_trunk->number_endpoints; i++) {
|
||||
|
||||
endp = &cfg->trunk.endpoints[i];
|
||||
endp = &cfg->virt_trunk->endpoints[i];
|
||||
|
||||
llist_for_each_entry(conn, &endp->conns, entry) {
|
||||
if (conn->type != MGCP_CONN_TYPE_RTP)
|
||||
|
@@ -379,7 +379,7 @@ 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 mgcp_trunk_config *tcfg = cfg->virt_trunk;
|
||||
struct rate_ctr_group *rate_ctrs = tcfg->mgcp_general_ctr_group;
|
||||
struct mgcp_parse_data pdata;
|
||||
int rc, i, code, handled = 0;
|
||||
@@ -1657,33 +1657,26 @@ struct mgcp_config *mgcp_config_alloc(void)
|
||||
|
||||
cfg->get_net_downlink_format_cb = &mgcp_get_net_downlink_format_default;
|
||||
|
||||
/* 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;
|
||||
cfg->trunk.audio_name = talloc_strdup(cfg, "AMR/8000");
|
||||
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) {
|
||||
INIT_LLIST_HEAD(&cfg->trunks);
|
||||
|
||||
/* default trunk handling */
|
||||
cfg->virt_trunk = mgcp_trunk_alloc(cfg, MGCP_TRUNK_VIRTUAL, 0);
|
||||
if (!cfg->virt_trunk) {
|
||||
talloc_free(cfg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
INIT_LLIST_HEAD(&cfg->trunks);
|
||||
/* virtual trunk is not part of the list! */
|
||||
llist_del(&cfg->virt_trunk->entry);
|
||||
|
||||
return cfg;
|
||||
}
|
||||
|
||||
/*! allocate configuration with default values.
|
||||
/*! allocate configuration with default values. Do not link it into global list yet!
|
||||
* (called once at startup by VTY)
|
||||
* \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, int nr)
|
||||
struct mgcp_trunk_config *mgcp_trunk_alloc(struct mgcp_config *cfg, enum mgcp_trunk_type ttype, int nr)
|
||||
{
|
||||
struct mgcp_trunk_config *trunk;
|
||||
|
||||
@@ -1694,16 +1687,19 @@ struct mgcp_trunk_config *mgcp_trunk_alloc(struct mgcp_config *cfg, int nr)
|
||||
}
|
||||
|
||||
trunk->cfg = cfg;
|
||||
trunk->trunk_type = MGCP_TRUNK_E1;
|
||||
trunk->trunk_type = ttype;
|
||||
trunk->trunk_nr = nr;
|
||||
trunk->audio_name = talloc_strdup(cfg, "AMR/8000");
|
||||
trunk->audio_name = talloc_strdup(trunk, "AMR/8000");
|
||||
trunk->audio_payload = 126;
|
||||
trunk->audio_send_ptime = 1;
|
||||
trunk->audio_send_name = 1;
|
||||
trunk->vty_number_endpoints = 33;
|
||||
trunk->omit_rtcp = 0;
|
||||
mgcp_trunk_set_keepalive(trunk, MGCP_KEEPALIVE_ONCE);
|
||||
alloc_mgcp_rate_counters(trunk, trunk);
|
||||
if (alloc_mgcp_rate_counters(trunk, trunk) < 0) {
|
||||
talloc_free(trunk);
|
||||
return NULL;
|
||||
}
|
||||
llist_add_tail(&trunk->entry, &cfg->trunks);
|
||||
|
||||
return trunk;
|
||||
|
@@ -47,7 +47,7 @@ static struct mgcp_trunk_config *find_trunk(struct mgcp_config *cfg, int nr)
|
||||
struct mgcp_trunk_config *trunk;
|
||||
|
||||
if (nr == 0)
|
||||
trunk = &cfg->trunk;
|
||||
trunk = cfg->virt_trunk;
|
||||
else
|
||||
trunk = mgcp_trunk_num(cfg, nr);
|
||||
|
||||
@@ -68,6 +68,8 @@ struct cmd_node trunk_node = {
|
||||
|
||||
static int config_write_mgcp(struct vty *vty)
|
||||
{
|
||||
struct mgcp_trunk_config *trunk = g_cfg->virt_trunk;
|
||||
|
||||
vty_out(vty, "mgcp%s", VTY_NEWLINE);
|
||||
vty_out(vty, " domain %s%s", g_cfg->domain, VTY_NEWLINE);
|
||||
if (g_cfg->local_ip)
|
||||
@@ -85,50 +87,50 @@ static int config_write_mgcp(struct vty *vty)
|
||||
else
|
||||
vty_out(vty, " no rtp ip-probing%s", VTY_NEWLINE);
|
||||
vty_out(vty, " rtp ip-dscp %d%s", g_cfg->endp_dscp, VTY_NEWLINE);
|
||||
if (g_cfg->trunk.keepalive_interval == MGCP_KEEPALIVE_ONCE)
|
||||
if (trunk->keepalive_interval == MGCP_KEEPALIVE_ONCE)
|
||||
vty_out(vty, " rtp keep-alive once%s", VTY_NEWLINE);
|
||||
else if (g_cfg->trunk.keepalive_interval)
|
||||
else if (trunk->keepalive_interval)
|
||||
vty_out(vty, " rtp keep-alive %d%s",
|
||||
g_cfg->trunk.keepalive_interval, VTY_NEWLINE);
|
||||
trunk->keepalive_interval, VTY_NEWLINE);
|
||||
else
|
||||
vty_out(vty, " no rtp keep-alive%s", VTY_NEWLINE);
|
||||
|
||||
if (g_cfg->trunk.omit_rtcp)
|
||||
if (trunk->omit_rtcp)
|
||||
vty_out(vty, " rtcp-omit%s", VTY_NEWLINE);
|
||||
else
|
||||
vty_out(vty, " no rtcp-omit%s", VTY_NEWLINE);
|
||||
if (g_cfg->trunk.force_constant_ssrc
|
||||
|| g_cfg->trunk.force_aligned_timing
|
||||
|| g_cfg->trunk.rfc5993_hr_convert) {
|
||||
if (trunk->force_constant_ssrc
|
||||
|| trunk->force_aligned_timing
|
||||
|| trunk->rfc5993_hr_convert) {
|
||||
vty_out(vty, " %srtp-patch ssrc%s",
|
||||
g_cfg->trunk.force_constant_ssrc ? "" : "no ",
|
||||
trunk->force_constant_ssrc ? "" : "no ",
|
||||
VTY_NEWLINE);
|
||||
vty_out(vty, " %srtp-patch timestamp%s",
|
||||
g_cfg->trunk.force_aligned_timing ? "" : "no ",
|
||||
trunk->force_aligned_timing ? "" : "no ",
|
||||
VTY_NEWLINE);
|
||||
vty_out(vty, " %srtp-patch rfc5993hr%s",
|
||||
g_cfg->trunk.rfc5993_hr_convert ? "" : "no ",
|
||||
trunk->rfc5993_hr_convert ? "" : "no ",
|
||||
VTY_NEWLINE);
|
||||
} else
|
||||
vty_out(vty, " no rtp-patch%s", VTY_NEWLINE);
|
||||
if (g_cfg->trunk.audio_payload != -1)
|
||||
if (trunk->audio_payload != -1)
|
||||
vty_out(vty, " sdp audio-payload number %d%s",
|
||||
g_cfg->trunk.audio_payload, VTY_NEWLINE);
|
||||
if (g_cfg->trunk.audio_name)
|
||||
trunk->audio_payload, VTY_NEWLINE);
|
||||
if (trunk->audio_name)
|
||||
vty_out(vty, " sdp audio-payload name %s%s",
|
||||
g_cfg->trunk.audio_name, VTY_NEWLINE);
|
||||
if (g_cfg->trunk.audio_fmtp_extra)
|
||||
trunk->audio_name, VTY_NEWLINE);
|
||||
if (trunk->audio_fmtp_extra)
|
||||
vty_out(vty, " sdp audio fmtp-extra %s%s",
|
||||
g_cfg->trunk.audio_fmtp_extra, VTY_NEWLINE);
|
||||
trunk->audio_fmtp_extra, VTY_NEWLINE);
|
||||
vty_out(vty, " %ssdp audio-payload send-ptime%s",
|
||||
g_cfg->trunk.audio_send_ptime ? "" : "no ", VTY_NEWLINE);
|
||||
trunk->audio_send_ptime ? "" : "no ", VTY_NEWLINE);
|
||||
vty_out(vty, " %ssdp audio-payload send-name%s",
|
||||
g_cfg->trunk.audio_send_name ? "" : "no ", VTY_NEWLINE);
|
||||
vty_out(vty, " loop %u%s", ! !g_cfg->trunk.audio_loop, VTY_NEWLINE);
|
||||
trunk->audio_send_name ? "" : "no ", VTY_NEWLINE);
|
||||
vty_out(vty, " loop %u%s", ! !trunk->audio_loop, VTY_NEWLINE);
|
||||
vty_out(vty, " number endpoints %u%s",
|
||||
g_cfg->trunk.vty_number_endpoints - 1, VTY_NEWLINE);
|
||||
trunk->vty_number_endpoints - 1, VTY_NEWLINE);
|
||||
vty_out(vty, " %sallow-transcoding%s",
|
||||
g_cfg->trunk.no_audio_transcoding ? "no " : "", VTY_NEWLINE);
|
||||
trunk->no_audio_transcoding ? "no " : "", VTY_NEWLINE);
|
||||
if (g_cfg->call_agent_addr)
|
||||
vty_out(vty, " call-agent ip %s%s", g_cfg->call_agent_addr,
|
||||
VTY_NEWLINE);
|
||||
@@ -299,7 +301,7 @@ DEFUN(show_mcgp, show_mgcp_cmd,
|
||||
struct mgcp_trunk_config *trunk;
|
||||
int show_stats = argc >= 1;
|
||||
|
||||
dump_trunk(vty, &g_cfg->trunk, show_stats);
|
||||
dump_trunk(vty, g_cfg->virt_trunk, show_stats);
|
||||
|
||||
llist_for_each_entry(trunk, &g_cfg->trunks, entry)
|
||||
dump_trunk(vty, trunk, show_stats);
|
||||
@@ -350,7 +352,7 @@ DEFUN(show_mcgp_endpoint, show_mgcp_endpoint_cmd,
|
||||
{
|
||||
struct mgcp_trunk_config *trunk;
|
||||
|
||||
dump_mgcp_endpoint(vty, &g_cfg->trunk, argv[0]);
|
||||
dump_mgcp_endpoint(vty, g_cfg->virt_trunk, argv[0]);
|
||||
llist_for_each_entry(trunk, &g_cfg->trunks, entry)
|
||||
dump_mgcp_endpoint(vty, trunk, argv[0]);
|
||||
|
||||
@@ -561,7 +563,7 @@ DEFUN(cfg_mgcp_sdp_fmtp_extra,
|
||||
if (!txt)
|
||||
return CMD_WARNING;
|
||||
|
||||
osmo_talloc_replace_string(g_cfg, &g_cfg->trunk.audio_fmtp_extra, txt);
|
||||
osmo_talloc_replace_string(g_cfg, &g_cfg->virt_trunk->audio_fmtp_extra, txt);
|
||||
talloc_free(txt);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
@@ -570,7 +572,7 @@ DEFUN(cfg_mgcp_allow_transcoding,
|
||||
cfg_mgcp_allow_transcoding_cmd,
|
||||
"allow-transcoding", "Allow transcoding\n")
|
||||
{
|
||||
g_cfg->trunk.no_audio_transcoding = 0;
|
||||
g_cfg->virt_trunk->no_audio_transcoding = 0;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -578,7 +580,7 @@ DEFUN(cfg_mgcp_no_allow_transcoding,
|
||||
cfg_mgcp_no_allow_transcoding_cmd,
|
||||
"no allow-transcoding", NO_STR "Allow transcoding\n")
|
||||
{
|
||||
g_cfg->trunk.no_audio_transcoding = 1;
|
||||
g_cfg->virt_trunk->no_audio_transcoding = 1;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -590,7 +592,7 @@ DEFUN(cfg_mgcp_sdp_payload_number,
|
||||
SDP_STR AUDIO_STR "Number\n" "Payload number\n")
|
||||
{
|
||||
unsigned int payload = atoi(argv[0]);
|
||||
g_cfg->trunk.audio_payload = payload;
|
||||
g_cfg->virt_trunk->audio_payload = payload;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -604,7 +606,7 @@ ALIAS_DEPRECATED(cfg_mgcp_sdp_payload_number,
|
||||
"sdp audio-payload name NAME",
|
||||
SDP_STR AUDIO_STR "Name\n" "Payload name\n")
|
||||
{
|
||||
osmo_talloc_replace_string(g_cfg, &g_cfg->trunk.audio_name, argv[0]);
|
||||
osmo_talloc_replace_string(g_cfg, &g_cfg->virt_trunk->audio_name, argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -617,7 +619,7 @@ ALIAS_DEPRECATED(cfg_mgcp_sdp_payload_name, cfg_mgcp_sdp_payload_name_cmd_old,
|
||||
"sdp audio-payload send-ptime",
|
||||
SDP_STR AUDIO_STR "Send SDP ptime (packet duration) attribute\n")
|
||||
{
|
||||
g_cfg->trunk.audio_send_ptime = 1;
|
||||
g_cfg->virt_trunk->audio_send_ptime = 1;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -626,7 +628,7 @@ DEFUN(cfg_mgcp_no_sdp_payload_send_ptime,
|
||||
"no sdp audio-payload send-ptime",
|
||||
NO_STR SDP_STR AUDIO_STR "Send SDP ptime (packet duration) attribute\n")
|
||||
{
|
||||
g_cfg->trunk.audio_send_ptime = 0;
|
||||
g_cfg->virt_trunk->audio_send_ptime = 0;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -635,7 +637,7 @@ DEFUN(cfg_mgcp_sdp_payload_send_name,
|
||||
"sdp audio-payload send-name",
|
||||
SDP_STR AUDIO_STR "Send SDP rtpmap with the audio name\n")
|
||||
{
|
||||
g_cfg->trunk.audio_send_name = 1;
|
||||
g_cfg->virt_trunk->audio_send_name = 1;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -644,7 +646,7 @@ DEFUN(cfg_mgcp_no_sdp_payload_send_name,
|
||||
"no sdp audio-payload send-name",
|
||||
NO_STR SDP_STR AUDIO_STR "Send SDP rtpmap with the audio name\n")
|
||||
{
|
||||
g_cfg->trunk.audio_send_name = 0;
|
||||
g_cfg->virt_trunk->audio_send_name = 0;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -657,7 +659,7 @@ DEFUN(cfg_mgcp_loop,
|
||||
vty_out(vty, "Cannot use `loop' with `osmux'.%s", VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
g_cfg->trunk.audio_loop = atoi(argv[0]);
|
||||
g_cfg->virt_trunk->audio_loop = atoi(argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -667,7 +669,7 @@ DEFUN(cfg_mgcp_force_realloc,
|
||||
"Force endpoint reallocation when the endpoint is still seized\n"
|
||||
"Don't force reallocation\n" "force reallocation\n")
|
||||
{
|
||||
g_cfg->trunk.force_realloc = atoi(argv[0]);
|
||||
g_cfg->virt_trunk->force_realloc = atoi(argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -677,7 +679,7 @@ DEFUN(cfg_mgcp_rtp_accept_all,
|
||||
"Accept all RTP packets, even when the originating IP/Port does not match\n"
|
||||
"enable filter\n" "disable filter\n")
|
||||
{
|
||||
g_cfg->trunk.rtp_accept_all = atoi(argv[0]);
|
||||
g_cfg->virt_trunk->rtp_accept_all = atoi(argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -687,20 +689,20 @@ DEFUN(cfg_mgcp_number_endp,
|
||||
"Number options\n" "Endpoints available\n" "Number endpoints\n")
|
||||
{
|
||||
/* + 1 as we start counting at one */
|
||||
g_cfg->trunk.vty_number_endpoints = atoi(argv[0]) + 1;
|
||||
g_cfg->virt_trunk->vty_number_endpoints = atoi(argv[0]) + 1;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_mgcp_omit_rtcp, cfg_mgcp_omit_rtcp_cmd, "rtcp-omit", RTCP_OMIT_STR)
|
||||
{
|
||||
g_cfg->trunk.omit_rtcp = 1;
|
||||
g_cfg->virt_trunk->omit_rtcp = 1;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_mgcp_no_omit_rtcp,
|
||||
cfg_mgcp_no_omit_rtcp_cmd, "no rtcp-omit", NO_STR RTCP_OMIT_STR)
|
||||
{
|
||||
g_cfg->trunk.omit_rtcp = 0;
|
||||
g_cfg->virt_trunk->omit_rtcp = 0;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -708,7 +710,7 @@ DEFUN(cfg_mgcp_patch_rtp_ssrc,
|
||||
cfg_mgcp_patch_rtp_ssrc_cmd,
|
||||
"rtp-patch ssrc", RTP_PATCH_STR "Force a fixed SSRC\n")
|
||||
{
|
||||
g_cfg->trunk.force_constant_ssrc = 1;
|
||||
g_cfg->virt_trunk->force_constant_ssrc = 1;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -716,7 +718,7 @@ DEFUN(cfg_mgcp_no_patch_rtp_ssrc,
|
||||
cfg_mgcp_no_patch_rtp_ssrc_cmd,
|
||||
"no rtp-patch ssrc", NO_STR RTP_PATCH_STR "Force a fixed SSRC\n")
|
||||
{
|
||||
g_cfg->trunk.force_constant_ssrc = 0;
|
||||
g_cfg->virt_trunk->force_constant_ssrc = 0;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -724,7 +726,7 @@ DEFUN(cfg_mgcp_patch_rtp_ts,
|
||||
cfg_mgcp_patch_rtp_ts_cmd,
|
||||
"rtp-patch timestamp", RTP_PATCH_STR "Adjust RTP timestamp\n")
|
||||
{
|
||||
g_cfg->trunk.force_aligned_timing = 1;
|
||||
g_cfg->virt_trunk->force_aligned_timing = 1;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -732,7 +734,7 @@ DEFUN(cfg_mgcp_no_patch_rtp_ts,
|
||||
cfg_mgcp_no_patch_rtp_ts_cmd,
|
||||
"no rtp-patch timestamp", NO_STR RTP_PATCH_STR "Adjust RTP timestamp\n")
|
||||
{
|
||||
g_cfg->trunk.force_aligned_timing = 0;
|
||||
g_cfg->virt_trunk->force_aligned_timing = 0;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -740,7 +742,7 @@ DEFUN(cfg_mgcp_patch_rtp_rfc5993hr,
|
||||
cfg_mgcp_patch_rtp_rfc5993hr_cmd,
|
||||
"rtp-patch rfc5993hr", RTP_PATCH_STR RTP_TS101318_RFC5993_CONV_STR)
|
||||
{
|
||||
g_cfg->trunk.rfc5993_hr_convert = true;
|
||||
g_cfg->virt_trunk->rfc5993_hr_convert = true;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -748,16 +750,16 @@ DEFUN(cfg_mgcp_no_patch_rtp_rfc5993hr,
|
||||
cfg_mgcp_no_patch_rtp_rfc5993hr_cmd,
|
||||
"no rtp-patch rfc5993hr", NO_STR RTP_PATCH_STR RTP_TS101318_RFC5993_CONV_STR)
|
||||
{
|
||||
g_cfg->trunk.rfc5993_hr_convert = false;
|
||||
g_cfg->virt_trunk->rfc5993_hr_convert = false;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_mgcp_no_patch_rtp,
|
||||
cfg_mgcp_no_patch_rtp_cmd, "no rtp-patch", NO_STR RTP_PATCH_STR)
|
||||
{
|
||||
g_cfg->trunk.force_constant_ssrc = 0;
|
||||
g_cfg->trunk.force_aligned_timing = 0;
|
||||
g_cfg->trunk.rfc5993_hr_convert = false;
|
||||
g_cfg->virt_trunk->force_constant_ssrc = 0;
|
||||
g_cfg->virt_trunk->force_aligned_timing = 0;
|
||||
g_cfg->virt_trunk->rfc5993_hr_convert = false;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -766,7 +768,7 @@ DEFUN(cfg_mgcp_rtp_keepalive,
|
||||
"rtp keep-alive <1-120>",
|
||||
RTP_STR RTP_KEEPALIVE_STR "Keep alive interval in secs\n")
|
||||
{
|
||||
mgcp_trunk_set_keepalive(&g_cfg->trunk, atoi(argv[0]));
|
||||
mgcp_trunk_set_keepalive(g_cfg->virt_trunk, atoi(argv[0]));
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -775,7 +777,7 @@ DEFUN(cfg_mgcp_rtp_keepalive_once,
|
||||
"rtp keep-alive once",
|
||||
RTP_STR RTP_KEEPALIVE_STR "Send dummy packet only once after CRCX/MDCX\n")
|
||||
{
|
||||
mgcp_trunk_set_keepalive(&g_cfg->trunk, MGCP_KEEPALIVE_ONCE);
|
||||
mgcp_trunk_set_keepalive(g_cfg->virt_trunk, MGCP_KEEPALIVE_ONCE);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -783,7 +785,7 @@ DEFUN(cfg_mgcp_no_rtp_keepalive,
|
||||
cfg_mgcp_no_rtp_keepalive_cmd,
|
||||
"no rtp keep-alive", NO_STR RTP_STR RTP_KEEPALIVE_STR)
|
||||
{
|
||||
mgcp_trunk_set_keepalive(&g_cfg->trunk, MGCP_KEEPALIVE_NEVER);
|
||||
mgcp_trunk_set_keepalive(g_cfg->virt_trunk, MGCP_KEEPALIVE_NEVER);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -809,8 +811,11 @@ ALIAS_DEPRECATED(cfg_mgcp_agent_addr, cfg_mgcp_agent_addr_cmd_old,
|
||||
int index = atoi(argv[0]);
|
||||
|
||||
trunk = mgcp_trunk_num(g_cfg, index);
|
||||
if (!trunk)
|
||||
trunk = mgcp_trunk_alloc(g_cfg, index);
|
||||
if (!trunk) {
|
||||
trunk = mgcp_trunk_alloc(g_cfg, MGCP_TRUNK_E1, index);
|
||||
if (!trunk)
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
if (!trunk) {
|
||||
vty_out(vty, "%%Unable to allocate trunk %u.%s",
|
||||
@@ -855,7 +860,7 @@ static int config_write_trunk(struct vty *vty)
|
||||
else
|
||||
vty_out(vty, " no rtcp-omit%s", VTY_NEWLINE);
|
||||
if (trunk->force_constant_ssrc || trunk->force_aligned_timing
|
||||
|| g_cfg->trunk.rfc5993_hr_convert) {
|
||||
|| g_cfg->virt_trunk->rfc5993_hr_convert) {
|
||||
vty_out(vty, " %srtp-patch ssrc%s",
|
||||
trunk->force_constant_ssrc ? "" : "no ",
|
||||
VTY_NEWLINE);
|
||||
@@ -1318,7 +1323,7 @@ DEFUN(cfg_mgcp_osmux,
|
||||
else if (strcmp(argv[0], "only") == 0)
|
||||
g_cfg->osmux = OSMUX_USAGE_ONLY;
|
||||
|
||||
if (g_cfg->trunk.audio_loop) {
|
||||
if (g_cfg->virt_trunk->audio_loop) {
|
||||
vty_out(vty, "Cannot use `loop' with `osmux'.%s", VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
@@ -1519,10 +1524,10 @@ int mgcp_parse_config(const char *config_file, struct mgcp_config *cfg,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mgcp_endpoints_allocate(&g_cfg->trunk) != 0) {
|
||||
if (mgcp_endpoints_allocate(g_cfg->virt_trunk) != 0) {
|
||||
LOGP(DLMGCP, LOGL_ERROR,
|
||||
"Failed to initialize the virtual trunk (%d endpoints)\n",
|
||||
g_cfg->trunk.number_endpoints);
|
||||
g_cfg->virt_trunk->number_endpoints);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@@ -757,13 +757,13 @@ static void test_messages(void)
|
||||
|
||||
cfg = mgcp_config_alloc();
|
||||
|
||||
cfg->trunk.vty_number_endpoints = 64;
|
||||
mgcp_endpoints_allocate(&cfg->trunk);
|
||||
cfg->virt_trunk->vty_number_endpoints = 64;
|
||||
mgcp_endpoints_allocate(cfg->virt_trunk);
|
||||
cfg->policy_cb = mgcp_test_policy_cb;
|
||||
|
||||
memset(last_conn_id, 0, sizeof(last_conn_id));
|
||||
|
||||
trunk2 = mgcp_trunk_alloc(cfg, 1);
|
||||
trunk2 = mgcp_trunk_alloc(cfg, MGCP_TRUNK_E1, 1);
|
||||
mgcp_endpoints_allocate(trunk2);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(tests); i++) {
|
||||
@@ -777,7 +777,7 @@ static void test_messages(void)
|
||||
last_endpoint = -1;
|
||||
dummy_packets = 0;
|
||||
|
||||
osmo_talloc_replace_string(cfg, &cfg->trunk.audio_fmtp_extra,
|
||||
osmo_talloc_replace_string(cfg, &cfg->virt_trunk->audio_fmtp_extra,
|
||||
t->extra_fmtp);
|
||||
|
||||
inp = create_msg(t->req, last_conn_id);
|
||||
@@ -810,7 +810,7 @@ static void test_messages(void)
|
||||
printf("Dummy packets: %d\n", dummy_packets);
|
||||
|
||||
if (last_endpoint != -1) {
|
||||
endp = &cfg->trunk.endpoints[last_endpoint];
|
||||
endp = &cfg->virt_trunk->endpoints[last_endpoint];
|
||||
|
||||
conn = mgcp_conn_get_rtp(endp, "1");
|
||||
if (conn) {
|
||||
@@ -866,7 +866,7 @@ static void test_messages(void)
|
||||
/* Check detected payload type */
|
||||
if (conn && t->ptype != PTYPE_IGNORE) {
|
||||
OSMO_ASSERT(last_endpoint != -1);
|
||||
endp = &cfg->trunk.endpoints[last_endpoint];
|
||||
endp = &cfg->virt_trunk->endpoints[last_endpoint];
|
||||
|
||||
fprintf(stderr, "endpoint 0x%x: "
|
||||
"payload type %d (expected %d)\n",
|
||||
@@ -883,7 +883,7 @@ static void test_messages(void)
|
||||
}
|
||||
|
||||
mgcp_endpoints_release(trunk2);
|
||||
mgcp_endpoints_release(&cfg->trunk);
|
||||
mgcp_endpoints_release(cfg->virt_trunk);
|
||||
talloc_free(cfg);
|
||||
}
|
||||
|
||||
@@ -897,12 +897,12 @@ static void test_retransmission(void)
|
||||
|
||||
cfg = mgcp_config_alloc();
|
||||
|
||||
cfg->trunk.vty_number_endpoints = 64;
|
||||
mgcp_endpoints_allocate(&cfg->trunk);
|
||||
cfg->virt_trunk->vty_number_endpoints = 64;
|
||||
mgcp_endpoints_allocate(cfg->virt_trunk);
|
||||
|
||||
memset(last_conn_id, 0, sizeof(last_conn_id));
|
||||
|
||||
trunk2 = mgcp_trunk_alloc(cfg, 1);
|
||||
trunk2 = mgcp_trunk_alloc(cfg, MGCP_TRUNK_E1, 1);
|
||||
mgcp_endpoints_allocate(trunk2);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(retransmit); i++) {
|
||||
@@ -944,7 +944,7 @@ static void test_retransmission(void)
|
||||
}
|
||||
|
||||
mgcp_endpoints_release(trunk2);
|
||||
mgcp_endpoints_release(&cfg->trunk);
|
||||
mgcp_endpoints_release(cfg->virt_trunk);
|
||||
talloc_free(cfg);
|
||||
}
|
||||
|
||||
@@ -965,10 +965,10 @@ static void test_rqnt_cb(void)
|
||||
cfg = mgcp_config_alloc();
|
||||
cfg->rqnt_cb = rqnt_cb;
|
||||
|
||||
cfg->trunk.vty_number_endpoints = 64;
|
||||
mgcp_endpoints_allocate(&cfg->trunk);
|
||||
cfg->virt_trunk->vty_number_endpoints = 64;
|
||||
mgcp_endpoints_allocate(cfg->virt_trunk);
|
||||
|
||||
trunk2 = mgcp_trunk_alloc(cfg, 1);
|
||||
trunk2 = mgcp_trunk_alloc(cfg, MGCP_TRUNK_E1, 1);
|
||||
mgcp_endpoints_allocate(trunk2);
|
||||
|
||||
inp = create_msg(CRCX, NULL);
|
||||
@@ -999,7 +999,7 @@ static void test_rqnt_cb(void)
|
||||
msgb_free(mgcp_handle_message(cfg, inp));
|
||||
msgb_free(inp);
|
||||
mgcp_endpoints_release(trunk2);
|
||||
mgcp_endpoints_release(&cfg->trunk);
|
||||
mgcp_endpoints_release(cfg->virt_trunk);
|
||||
talloc_free(cfg);
|
||||
}
|
||||
|
||||
@@ -1371,11 +1371,11 @@ static void test_multilple_codec(void)
|
||||
printf("Testing multiple payload types\n");
|
||||
|
||||
cfg = mgcp_config_alloc();
|
||||
cfg->trunk.vty_number_endpoints = 64;
|
||||
mgcp_endpoints_allocate(&cfg->trunk);
|
||||
cfg->virt_trunk->vty_number_endpoints = 64;
|
||||
mgcp_endpoints_allocate(cfg->virt_trunk);
|
||||
cfg->policy_cb = mgcp_test_policy_cb;
|
||||
|
||||
trunk2 = mgcp_trunk_alloc(cfg, 1);
|
||||
trunk2 = mgcp_trunk_alloc(cfg, MGCP_TRUNK_E1, 1);
|
||||
mgcp_endpoints_allocate(trunk2);
|
||||
|
||||
/* Allocate endpoint 1@mgw with two codecs */
|
||||
@@ -1388,7 +1388,7 @@ static void test_multilple_codec(void)
|
||||
msgb_free(resp);
|
||||
|
||||
OSMO_ASSERT(last_endpoint == 1);
|
||||
endp = &cfg->trunk.endpoints[last_endpoint];
|
||||
endp = &cfg->virt_trunk->endpoints[last_endpoint];
|
||||
conn = mgcp_conn_get_rtp(endp, conn_id);
|
||||
OSMO_ASSERT(conn);
|
||||
OSMO_ASSERT(conn->end.codec->payload_type == 18);
|
||||
@@ -1403,7 +1403,7 @@ static void test_multilple_codec(void)
|
||||
msgb_free(resp);
|
||||
|
||||
OSMO_ASSERT(last_endpoint == 2);
|
||||
endp = &cfg->trunk.endpoints[last_endpoint];
|
||||
endp = &cfg->virt_trunk->endpoints[last_endpoint];
|
||||
conn = mgcp_conn_get_rtp(endp, conn_id);
|
||||
OSMO_ASSERT(conn);
|
||||
OSMO_ASSERT(conn->end.codec->payload_type == 18);
|
||||
@@ -1423,7 +1423,7 @@ static void test_multilple_codec(void)
|
||||
msgb_free(resp);
|
||||
|
||||
OSMO_ASSERT(last_endpoint == 3);
|
||||
endp = &cfg->trunk.endpoints[last_endpoint];
|
||||
endp = &cfg->virt_trunk->endpoints[last_endpoint];
|
||||
conn = mgcp_conn_get_rtp(endp, conn_id);
|
||||
OSMO_ASSERT(conn);
|
||||
OSMO_ASSERT(conn->end.codec->payload_type == 0);
|
||||
@@ -1438,7 +1438,7 @@ static void test_multilple_codec(void)
|
||||
msgb_free(resp);
|
||||
|
||||
OSMO_ASSERT(last_endpoint == 4);
|
||||
endp = &cfg->trunk.endpoints[last_endpoint];
|
||||
endp = &cfg->virt_trunk->endpoints[last_endpoint];
|
||||
conn = mgcp_conn_get_rtp(endp, conn_id);
|
||||
OSMO_ASSERT(conn);
|
||||
OSMO_ASSERT(conn->end.codec->payload_type == 18);
|
||||
@@ -1446,9 +1446,9 @@ static void test_multilple_codec(void)
|
||||
/* Allocate 5@mgw at select GSM.. */
|
||||
last_endpoint = -1;
|
||||
inp = create_msg(CRCX_MULT_GSM_EXACT, NULL);
|
||||
talloc_free(cfg->trunk.audio_name);
|
||||
cfg->trunk.audio_name = "GSM/8000";
|
||||
cfg->trunk.no_audio_transcoding = 1;
|
||||
talloc_free(cfg->virt_trunk->audio_name);
|
||||
cfg->virt_trunk->audio_name = "GSM/8000";
|
||||
cfg->virt_trunk->no_audio_transcoding = 1;
|
||||
resp = mgcp_handle_message(cfg, inp);
|
||||
OSMO_ASSERT(get_conn_id_from_response(resp->data, conn_id,
|
||||
sizeof(conn_id)) == 0);
|
||||
@@ -1456,7 +1456,7 @@ static void test_multilple_codec(void)
|
||||
msgb_free(resp);
|
||||
|
||||
OSMO_ASSERT(last_endpoint == 5);
|
||||
endp = &cfg->trunk.endpoints[last_endpoint];
|
||||
endp = &cfg->virt_trunk->endpoints[last_endpoint];
|
||||
conn = mgcp_conn_get_rtp(endp, conn_id);
|
||||
OSMO_ASSERT(conn);
|
||||
OSMO_ASSERT(conn->end.codec->payload_type == 3);
|
||||
@@ -1467,7 +1467,7 @@ static void test_multilple_codec(void)
|
||||
msgb_free(inp);
|
||||
msgb_free(resp);
|
||||
OSMO_ASSERT(last_endpoint == 5);
|
||||
endp = &cfg->trunk.endpoints[last_endpoint];
|
||||
endp = &cfg->virt_trunk->endpoints[last_endpoint];
|
||||
conn = mgcp_conn_get_rtp(endp, conn_id);
|
||||
OSMO_ASSERT(conn);
|
||||
OSMO_ASSERT(conn->end.codec->payload_type == 3);
|
||||
@@ -1489,7 +1489,7 @@ static void test_multilple_codec(void)
|
||||
|
||||
last_endpoint = -1;
|
||||
inp = create_msg(CRCX_MULT_GSM_EXACT, NULL);
|
||||
cfg->trunk.no_audio_transcoding = 0;
|
||||
cfg->virt_trunk->no_audio_transcoding = 0;
|
||||
resp = mgcp_handle_message(cfg, inp);
|
||||
OSMO_ASSERT(get_conn_id_from_response(resp->data, conn_id,
|
||||
sizeof(conn_id)) == 0);
|
||||
@@ -1497,13 +1497,13 @@ static void test_multilple_codec(void)
|
||||
msgb_free(resp);
|
||||
|
||||
OSMO_ASSERT(last_endpoint == 5);
|
||||
endp = &cfg->trunk.endpoints[last_endpoint];
|
||||
endp = &cfg->virt_trunk->endpoints[last_endpoint];
|
||||
conn = mgcp_conn_get_rtp(endp, conn_id);
|
||||
OSMO_ASSERT(conn);
|
||||
OSMO_ASSERT(conn->end.codec->payload_type == 0);
|
||||
|
||||
mgcp_endpoints_release(trunk2);
|
||||
mgcp_endpoints_release(&cfg->trunk);
|
||||
mgcp_endpoints_release(cfg->virt_trunk);
|
||||
talloc_free(cfg);
|
||||
}
|
||||
|
||||
@@ -1517,10 +1517,10 @@ static void test_no_cycle(void)
|
||||
printf("Testing no sequence flow on initial packet\n");
|
||||
|
||||
cfg = mgcp_config_alloc();
|
||||
cfg->trunk.vty_number_endpoints = 64;
|
||||
mgcp_endpoints_allocate(&cfg->trunk);
|
||||
cfg->virt_trunk->vty_number_endpoints = 64;
|
||||
mgcp_endpoints_allocate(cfg->virt_trunk);
|
||||
|
||||
endp = &cfg->trunk.endpoints[1];
|
||||
endp = &cfg->virt_trunk->endpoints[1];
|
||||
|
||||
_conn = mgcp_conn_alloc(NULL, endp, MGCP_CONN_TYPE_RTP,
|
||||
"test-connection");
|
||||
@@ -1552,7 +1552,7 @@ static void test_no_cycle(void)
|
||||
OSMO_ASSERT(conn->state.stats.cycles == UINT16_MAX + 1);
|
||||
OSMO_ASSERT(conn->state.stats.max_seq == 0);
|
||||
|
||||
mgcp_endpoints_release(&cfg->trunk);
|
||||
mgcp_endpoints_release(cfg->virt_trunk);
|
||||
talloc_free(cfg);
|
||||
}
|
||||
|
||||
@@ -1565,13 +1565,13 @@ static void test_no_name(void)
|
||||
printf("Testing no rtpmap name\n");
|
||||
cfg = mgcp_config_alloc();
|
||||
|
||||
cfg->trunk.vty_number_endpoints = 64;
|
||||
cfg->trunk.audio_send_name = 0;
|
||||
mgcp_endpoints_allocate(&cfg->trunk);
|
||||
cfg->virt_trunk->vty_number_endpoints = 64;
|
||||
cfg->virt_trunk->audio_send_name = 0;
|
||||
mgcp_endpoints_allocate(cfg->virt_trunk);
|
||||
|
||||
cfg->policy_cb = mgcp_test_policy_cb;
|
||||
|
||||
trunk2 = mgcp_trunk_alloc(cfg, 1);
|
||||
trunk2 = mgcp_trunk_alloc(cfg, MGCP_TRUNK_E1, 1);
|
||||
mgcp_endpoints_allocate(trunk2);
|
||||
|
||||
inp = create_msg(CRCX, NULL);
|
||||
@@ -1586,7 +1586,7 @@ static void test_no_name(void)
|
||||
msgb_free(msg);
|
||||
|
||||
mgcp_endpoints_release(trunk2);
|
||||
mgcp_endpoints_release(&cfg->trunk);
|
||||
mgcp_endpoints_release(cfg->virt_trunk);
|
||||
talloc_free(cfg);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user