summaryrefslogtreecommitdiffstats
path: root/openbsc/tests
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-04-23 20:25:17 -0400
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-04-23 20:27:30 -0400
commit7f100c9712de5c684462e809bf31a58c0c326337 (patch)
treea0679413f21ddea3c2656f0463595056f4769989 /openbsc/tests
parentd4b03187c68c6136192f7a41335982b5ceeeb036 (diff)
nat: Make mode-set patching optional
Diffstat (limited to 'openbsc/tests')
-rw-r--r--openbsc/tests/bsc-nat/bsc_data.c15
-rw-r--r--openbsc/tests/bsc-nat/bsc_nat_test.c3
-rw-r--r--openbsc/tests/vty_test_runner.py17
3 files changed, 34 insertions, 1 deletions
diff --git a/openbsc/tests/bsc-nat/bsc_data.c b/openbsc/tests/bsc-nat/bsc_data.c
index d1f8ebc..3f1f527 100644
--- a/openbsc/tests/bsc-nat/bsc_data.c
+++ b/openbsc/tests/bsc-nat/bsc_data.c
@@ -171,6 +171,7 @@ static const char mdcx_resp_patched[] = "200 23330829\r\n\r\nv=0\r\nc=IN IP4 10.
/* different line ending */
static const char mdcx_resp2[] = "200 33330829\n\nv=0\nc=IN IP4 172.16.18.2\nm=audio 4002 RTP/AVP 98\na=rtpmap:98 AMR/8000\n";
static const char mdcx_resp_patched2[] = "200 33330829\n\nv=0\nc=IN IP4 10.0.0.23\nm=audio 5555 RTP/AVP 98\na=rtpmap:98 AMR/8000\na=fmtp:98 mode-set=2\n";
+static const char mdcx_resp_patched2_noamr[] = "200 33330829\n\nv=0\nc=IN IP4 10.0.0.23\nm=audio 5555 RTP/AVP 98\na=rtpmap:98 AMR/8000\n";
struct mgcp_patch_test {
const char *orig;
@@ -178,6 +179,7 @@ struct mgcp_patch_test {
const char *ip;
const int port;
const int payload_type;
+ const int ensure_mode_set;
};
static const struct mgcp_patch_test mgcp_messages[] = {
@@ -186,6 +188,7 @@ static const struct mgcp_patch_test mgcp_messages[] = {
.patch = crcx_patched,
.ip = "0.0.0.0",
.port = 2323,
+ .ensure_mode_set = 1,
},
{
.orig = crcx_resp,
@@ -193,6 +196,7 @@ static const struct mgcp_patch_test mgcp_messages[] = {
.ip = "10.0.0.1",
.port = 999,
.payload_type = 98,
+ .ensure_mode_set = 1,
},
{
.orig = mdcx,
@@ -200,6 +204,7 @@ static const struct mgcp_patch_test mgcp_messages[] = {
.ip = "10.0.0.23",
.port = 6666,
.payload_type = 126,
+ .ensure_mode_set = 1,
},
{
.orig = mdcx_resp,
@@ -207,6 +212,7 @@ static const struct mgcp_patch_test mgcp_messages[] = {
.ip = "10.0.0.23",
.port = 5555,
.payload_type = 98,
+ .ensure_mode_set = 1,
},
{
.orig = mdcx_resp2,
@@ -214,6 +220,15 @@ static const struct mgcp_patch_test mgcp_messages[] = {
.ip = "10.0.0.23",
.port = 5555,
.payload_type = 98,
+ .ensure_mode_set = 1,
+ },
+ {
+ .orig = mdcx_resp2,
+ .patch = mdcx_resp_patched2_noamr,
+ .ip = "10.0.0.23",
+ .port = 5555,
+ .payload_type = 98,
+ .ensure_mode_set = 0,
},
};
diff --git a/openbsc/tests/bsc-nat/bsc_nat_test.c b/openbsc/tests/bsc-nat/bsc_nat_test.c
index 245b081..5b01cc3 100644
--- a/openbsc/tests/bsc-nat/bsc_nat_test.c
+++ b/openbsc/tests/bsc-nat/bsc_nat_test.c
@@ -625,12 +625,13 @@ static void test_mgcp_rewrite(void)
const char *ip = mgcp_messages[i].ip;
const int port = mgcp_messages[i].port;
const int expected_payload_type = mgcp_messages[i].payload_type;
+ const int ensure_mode_set = mgcp_messages[i].ensure_mode_set;
int payload_type = -1;
char *input = strdup(orig);
output = bsc_mgcp_rewrite(input, strlen(input), 0x1e,
- ip, port, -1, &payload_type);
+ ip, port, -1, &payload_type, ensure_mode_set);
if (payload_type != -1) {
fprintf(stderr, "Found media payload type %d in SDP data\n",
diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py
index fb4ca7d..3581b67 100644
--- a/openbsc/tests/vty_test_runner.py
+++ b/openbsc/tests/vty_test_runner.py
@@ -588,6 +588,23 @@ class TestVTYNAT(TestVTYGenericBSC):
res = self.vty.command("number-rewrite rewrite.cfg")
res = self.vty.command("no number-rewrite")
+ def testEnsureNoEnsureModeSet(self):
+ self.vty.enable()
+ res = self.vty.command("configure terminal")
+ res = self.vty.command("nat")
+
+ # Ensure the default
+ res = self.vty.command("show running-config")
+ self.assert_(res.find('\n sdp-ensure-amr-mode-set') > 0)
+
+ self.vty.command("sdp-ensure-amr-mode-set")
+ res = self.vty.command("show running-config")
+ self.assert_(res.find('\n sdp-ensure-amr-mode-set') > 0)
+
+ self.vty.command("no sdp-ensure-amr-mode-set")
+ res = self.vty.command("show running-config")
+ self.assert_(res.find('\n no sdp-ensure-amr-mode-set') > 0)
+
def testRewritePostNoRewrite(self):
self.vty.enable()
self.vty.command("configure terminal")