aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/tests
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-04-04 18:09:10 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-04-04 18:09:10 +0200
commitbbfff6ec39d6499404f1b603da2ee9091b3c899c (patch)
treecd23692a531b790a52f261eb1a1060cb135d7f5f /openbsc/tests
parentdc0914df098f754ec8f6af5fddccce5521f6332a (diff)
nat: Make rewrite work on string, read to a string first, copy to msgb
The MGCP protocol parsing is adding '\0' to make sure we do not parse beyond where we should parse. This does not mix with strtok or similiar routines. For now we will read the msg into a global array first, then copy it to the msgb for mgcp protocol handling and if we are required to forward it to the MGCP we have a untouched copy we will modify into our own msgb.
Diffstat (limited to 'openbsc/tests')
-rw-r--r--openbsc/tests/bsc-nat/bsc_nat_test.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/openbsc/tests/bsc-nat/bsc_nat_test.c b/openbsc/tests/bsc-nat/bsc_nat_test.c
index 10b876b37..def6bfec8 100644
--- a/openbsc/tests/bsc-nat/bsc_nat_test.c
+++ b/openbsc/tests/bsc-nat/bsc_nat_test.c
@@ -425,20 +425,18 @@ static void test_mgcp_find(void)
static void test_mgcp_rewrite(void)
{
int i;
- struct msgb *input, *output;
+ struct msgb *output;
fprintf(stderr, "Test rewriting MGCP messages.\n");
- input = msgb_alloc(4096, "input");
-
for (i = 0; i < ARRAY_SIZE(mgcp_messages); ++i) {
const char *orig = mgcp_messages[i].orig;
const char *patc = mgcp_messages[i].patch;
const char *ip = mgcp_messages[i].ip;
const int port = mgcp_messages[i].port;
- copy_to_msg(input, (const u_int8_t *) orig, strlen(orig) + 1);
+ char *input = strdup(orig);
- output = bsc_mgcp_rewrite(input, ip, port);
+ output = bsc_mgcp_rewrite(input, strlen(input), ip, port);
if (msgb_l2len(output) != strlen(patc)) {
fprintf(stderr, "Wrong sizes for test: %d %d != %d != %d\n", i, msgb_l2len(output), strlen(patc), strlen(orig));
fprintf(stderr, "String '%s' vs '%s'\n", (const char *) output->l2h, patc);
@@ -451,9 +449,8 @@ static void test_mgcp_rewrite(void)
}
msgb_free(output);
+ free(input);
}
-
- msgb_free(input);
}
static void test_mgcp_parse(void)