aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--openbsc/include/openbsc/mgcp.h1
-rw-r--r--openbsc/src/libmgcp/mgcp_protocol.c4
-rw-r--r--openbsc/src/libmgcp/mgcp_vty.c50
-rw-r--r--openbsc/tests/mgcp/mgcp_test.c51
-rw-r--r--openbsc/tests/mgcp/mgcp_test.ok1
-rw-r--r--openbsc/tests/vty_test_runner.py15
6 files changed, 121 insertions, 1 deletions
diff --git a/openbsc/include/openbsc/mgcp.h b/openbsc/include/openbsc/mgcp.h
index 9015f6989..cc1fb1773 100644
--- a/openbsc/include/openbsc/mgcp.h
+++ b/openbsc/include/openbsc/mgcp.h
@@ -137,6 +137,7 @@ struct mgcp_trunk_config {
char *audio_name;
int audio_payload;
int audio_send_ptime;
+ int audio_send_name;
int audio_loop;
int omit_rtcp;
diff --git a/openbsc/src/libmgcp/mgcp_protocol.c b/openbsc/src/libmgcp/mgcp_protocol.c
index 79422fea4..98452ce04 100644
--- a/openbsc/src/libmgcp/mgcp_protocol.c
+++ b/openbsc/src/libmgcp/mgcp_protocol.c
@@ -274,7 +274,7 @@ static int write_response_sdp(struct mgcp_endpoint *endp,
len += nchars;
- if (audio_name) {
+ if (audio_name && endp->tcfg->audio_send_name) {
nchars = snprintf(sdp_record + len, size - len,
"a=rtpmap:%d %s\r\n",
payload_type, audio_name);
@@ -1417,6 +1417,7 @@ struct mgcp_config *mgcp_config_alloc(void)
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.omit_rtcp = 0;
mgcp_trunk_set_keepalive(&cfg->trunk, MGCP_KEEPALIVE_ONCE);
@@ -1441,6 +1442,7 @@ struct mgcp_trunk_config *mgcp_trunk_alloc(struct mgcp_config *cfg, int nr)
trunk->audio_name = talloc_strdup(cfg, "AMR/8000");
trunk->audio_payload = 126;
trunk->audio_send_ptime = 1;
+ trunk->audio_send_name = 1;
trunk->number_endpoints = 33;
trunk->omit_rtcp = 0;
mgcp_trunk_set_keepalive(trunk, MGCP_KEEPALIVE_ONCE);
diff --git a/openbsc/src/libmgcp/mgcp_vty.c b/openbsc/src/libmgcp/mgcp_vty.c
index b29eb6b4d..5124ca670 100644
--- a/openbsc/src/libmgcp/mgcp_vty.c
+++ b/openbsc/src/libmgcp/mgcp_vty.c
@@ -116,6 +116,8 @@ static int config_write_mgcp(struct vty *vty)
g_cfg->trunk.audio_fmtp_extra, VTY_NEWLINE);
vty_out(vty, " %ssdp audio-payload send-ptime%s",
g_cfg->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);
vty_out(vty, " number endpoints %u%s", g_cfg->trunk.number_endpoints - 1, VTY_NEWLINE);
if (g_cfg->call_agent_addr)
@@ -475,6 +477,26 @@ DEFUN(cfg_mgcp_no_sdp_payload_send_ptime,
return CMD_SUCCESS;
}
+DEFUN(cfg_mgcp_sdp_payload_send_name,
+ cfg_mgcp_sdp_payload_send_name_cmd,
+ "sdp audio-payload send-name",
+ SDP_STR AUDIO_STR
+ "Send SDP rtpmap with the audio name\n")
+{
+ g_cfg->trunk.audio_send_name = 1;
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_mgcp_no_sdp_payload_send_name,
+ cfg_mgcp_no_sdp_payload_send_name_cmd,
+ "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;
+ return CMD_SUCCESS;
+}
+
DEFUN(cfg_mgcp_loop,
cfg_mgcp_loop_cmd,
"loop (0|1)",
@@ -691,6 +713,8 @@ static int config_write_trunk(struct vty *vty)
trunk->audio_name, VTY_NEWLINE);
vty_out(vty, " %ssdp audio-payload send-ptime%s",
trunk->audio_send_ptime ? "" : "no ", VTY_NEWLINE);
+ vty_out(vty, " %ssdp audio-payload send-name%s",
+ trunk->audio_send_name ? "" : "no ", VTY_NEWLINE);
if (trunk->keepalive_interval == MGCP_KEEPALIVE_ONCE)
vty_out(vty, " rtp keep-alive once%s", VTY_NEWLINE);
@@ -807,6 +831,28 @@ DEFUN(cfg_trunk_no_sdp_payload_send_ptime,
return CMD_SUCCESS;
}
+DEFUN(cfg_trunk_sdp_payload_send_name,
+ cfg_trunk_sdp_payload_send_name_cmd,
+ "sdp audio-payload send-name",
+ SDP_STR AUDIO_STR
+ "Send SDP rtpmap with the audio name\n")
+{
+ struct mgcp_trunk_config *trunk = vty->index;
+ trunk->audio_send_name = 1;
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_trunk_no_sdp_payload_send_name,
+ cfg_trunk_no_sdp_payload_send_name_cmd,
+ "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;
+ trunk->audio_send_name = 0;
+ return CMD_SUCCESS;
+}
+
DEFUN(cfg_trunk_omit_rtcp,
cfg_trunk_omit_rtcp_cmd,
"rtcp-omit",
@@ -1210,6 +1256,8 @@ int mgcp_vty_init(void)
install_element(MGCP_NODE, &cfg_mgcp_sdp_fmtp_extra_cmd);
install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_send_ptime_cmd);
install_element(MGCP_NODE, &cfg_mgcp_no_sdp_payload_send_ptime_cmd);
+ install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_send_name_cmd);
+ install_element(MGCP_NODE, &cfg_mgcp_no_sdp_payload_send_name_cmd);
install_element(MGCP_NODE, &cfg_mgcp_osmux_cmd);
install_element(MGCP_NODE, &cfg_mgcp_osmux_batch_factor_cmd);
install_element(MGCP_NODE, &cfg_mgcp_osmux_batch_size_cmd);
@@ -1236,6 +1284,8 @@ int mgcp_vty_init(void)
install_element(TRUNK_NODE, &cfg_trunk_sdp_fmtp_extra_cmd);
install_element(TRUNK_NODE, &cfg_trunk_sdp_payload_send_ptime_cmd);
install_element(TRUNK_NODE, &cfg_trunk_no_sdp_payload_send_ptime_cmd);
+ install_element(TRUNK_NODE, &cfg_trunk_sdp_payload_send_name_cmd);
+ install_element(TRUNK_NODE, &cfg_trunk_no_sdp_payload_send_name_cmd);
return 0;
}
diff --git a/openbsc/tests/mgcp/mgcp_test.c b/openbsc/tests/mgcp/mgcp_test.c
index db2f4b35f..0a3c47a9f 100644
--- a/openbsc/tests/mgcp/mgcp_test.c
+++ b/openbsc/tests/mgcp/mgcp_test.c
@@ -215,6 +215,16 @@ static void test_strline(void)
"a=rtpmap:126 AMR/8000\r\n" \
"a=ptime:20\r\n"
+#define CRCX_RET_NO_RTPMAP "200 2 OK\r\n" \
+ "I: 1\n" \
+ "\n" \
+ "v=0\r\n" \
+ "o=- 1 23 IN IP4 0.0.0.0\r\n" \
+ "c=IN IP4 0.0.0.0\r\n" \
+ "t=0 0\r\n" \
+ "m=audio 0 RTP/AVP 126\r\n" \
+ "a=ptime:20\r\n"
+
#define CRCX_FMTP_RET "200 2 OK\r\n" \
"I: 3\n" \
"\n" \
@@ -1037,6 +1047,46 @@ static void test_no_cycle(void)
talloc_free(cfg);
}
+static void test_no_name(void)
+{
+ struct mgcp_config *cfg;
+ struct mgcp_endpoint *endp;
+ struct msgb *inp, *msg;
+ int i;
+
+ printf("Testing no rtpmap name\n");
+ cfg = mgcp_config_alloc();
+
+ cfg->trunk.number_endpoints = 64;
+ cfg->trunk.audio_send_name = 0;
+ mgcp_endpoints_allocate(&cfg->trunk);
+
+ cfg->policy_cb = mgcp_test_policy_cb;
+
+ mgcp_endpoints_allocate(mgcp_trunk_alloc(cfg, 1));
+
+ /* reset endpoints */
+ for (i = 0; i < cfg->trunk.number_endpoints; i++) {
+ endp = &cfg->trunk.endpoints[i];
+ endp->net_end.codec.payload_type = PTYPE_NONE;
+ endp->net_end.packet_duration_ms = -1;
+
+ OSMO_ASSERT(endp->conn_mode == MGCP_CONN_NONE);
+ endp->conn_mode |= CONN_UNMODIFIED;
+ }
+
+ inp = create_msg(CRCX);
+ msg = mgcp_handle_message(cfg, inp);
+ if (strcmp((char *) msg->data, CRCX_RET_NO_RTPMAP) != 0)
+ printf("FAILED: there should not be a RTPMAP: %s\n",
+ (char *) msg->data);
+ msgb_free(inp);
+ msgb_free(msg);
+
+ mgcp_release_endp(&cfg->trunk.endpoints[1]);
+ talloc_free(cfg);
+}
+
int main(int argc, char **argv)
{
osmo_init_logging(&log_info);
@@ -1054,6 +1104,7 @@ int main(int argc, char **argv)
test_packet_error_detection(1, 1);
test_multilple_codec();
test_no_cycle();
+ test_no_name();
printf("Done\n");
return EXIT_SUCCESS;
diff --git a/openbsc/tests/mgcp/mgcp_test.ok b/openbsc/tests/mgcp/mgcp_test.ok
index bb803d4e0..4e27282ee 100644
--- a/openbsc/tests/mgcp/mgcp_test.ok
+++ b/openbsc/tests/mgcp/mgcp_test.ok
@@ -476,4 +476,5 @@ Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
Stats: Jitter = 0, Transit = -144000
Testing multiple payload types
Testing no sequence flow on initial packet
+Testing no rtpmap name
Done
diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py
index 468d415e8..40053e30d 100644
--- a/openbsc/tests/vty_test_runner.py
+++ b/openbsc/tests/vty_test_runner.py
@@ -77,6 +77,21 @@ class TestVTYMGCP(TestVTYBase):
self.assertEquals(res.find(' rtp force-ptime 20\r'), -1)
self.assertEquals(res.find(' no rtp force-ptime\r'), -1)
+ def testOmitAudio(self):
+ self.vty.enable()
+ res = self.vty.command("show running-config")
+ self.assert_(res.find(' sdp audio-payload send-name\r') > 0)
+ self.assertEquals(res.find(' no sdp audio-payload send-name\r'), -1)
+
+ self.vty.command("configure terminal")
+ self.vty.command("mgcp")
+ self.vty.command("no sdp audio-payload send-name")
+ res = self.vty.command("show running-config")
+ self.assertEquals(res.find(' rtp sdp audio-payload send-name\r'), -1)
+ self.assert_(res.find(' no sdp audio-payload send-name\r') > 0)
+
+ # TODO: test it for the trunk!
+
class TestVTYGenericBSC(TestVTYBase):