aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/tests/bsc-nat
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2013-11-29 13:43:45 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-12-05 10:27:32 +0100
commita52ac66e5227a31a4f8ecec6aa38b124cf6cb82b (patch)
tree031a9a54a7788be695a398601a736b0ec5e2b668 /openbsc/tests/bsc-nat
parent2bee7f96ff46f2f7e563d7aca5c4703214b6cd0e (diff)
mgcp: Add tests for payload types in MGCP messages
These tests mainly check whether the SDP parsing works properly by looking at the payload type detected. Sponsored-by: On-Waves ehf
Diffstat (limited to 'openbsc/tests/bsc-nat')
-rw-r--r--openbsc/tests/bsc-nat/bsc_data.c5
-rw-r--r--openbsc/tests/bsc-nat/bsc_nat_test.c16
2 files changed, 20 insertions, 1 deletions
diff --git a/openbsc/tests/bsc-nat/bsc_data.c b/openbsc/tests/bsc-nat/bsc_data.c
index 5a76689e9..d1f8ebc0d 100644
--- a/openbsc/tests/bsc-nat/bsc_data.c
+++ b/openbsc/tests/bsc-nat/bsc_data.c
@@ -177,6 +177,7 @@ struct mgcp_patch_test {
const char *patch;
const char *ip;
const int port;
+ const int payload_type;
};
static const struct mgcp_patch_test mgcp_messages[] = {
@@ -191,24 +192,28 @@ static const struct mgcp_patch_test mgcp_messages[] = {
.patch = crcx_resp_patched,
.ip = "10.0.0.1",
.port = 999,
+ .payload_type = 98,
},
{
.orig = mdcx,
.patch = mdcx_patched,
.ip = "10.0.0.23",
.port = 6666,
+ .payload_type = 126,
},
{
.orig = mdcx_resp,
.patch = mdcx_resp_patched,
.ip = "10.0.0.23",
.port = 5555,
+ .payload_type = 98,
},
{
.orig = mdcx_resp2,
.patch = mdcx_resp_patched2,
.ip = "10.0.0.23",
.port = 5555,
+ .payload_type = 98,
},
};
diff --git a/openbsc/tests/bsc-nat/bsc_nat_test.c b/openbsc/tests/bsc-nat/bsc_nat_test.c
index 5158f46cf..3320e0694 100644
--- a/openbsc/tests/bsc-nat/bsc_nat_test.c
+++ b/openbsc/tests/bsc-nat/bsc_nat_test.c
@@ -624,10 +624,24 @@ static void test_mgcp_rewrite(void)
const char *patc = mgcp_messages[i].patch;
const char *ip = mgcp_messages[i].ip;
const int port = mgcp_messages[i].port;
+ const int expected_payload_type = mgcp_messages[i].payload_type;
+ int payload_type = -1;
char *input = strdup(orig);
- output = bsc_mgcp_rewrite(input, strlen(input), 0x1e, ip, port);
+ output = bsc_mgcp_rewrite(input, strlen(input), 0x1e,
+ ip, port);
+
+ if (payload_type != -1) {
+ fprintf(stderr, "Found media payload type %d in SDP data\n",
+ payload_type);
+ if (payload_type != expected_payload_type) {
+ printf("Wrong payload type %d (expected %d)\n",
+ payload_type, expected_payload_type);
+ abort();
+ }
+ }
+
if (msgb_l2len(output) != strlen(patc)) {
printf("Wrong sizes for test: %d %d != %d != %d\n", i, msgb_l2len(output), strlen(patc), strlen(orig));
printf("String '%s' vs '%s'\n", (const char *) output->l2h, patc);