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-06-15 20:24:10 +0800
commit8d20065c4b11520fe45b4001eaa44612686a5916 (patch)
tree1e40c0f5d85381b558789a498e03a4dc0e5e7f93 /openbsc/tests
parentbbb9d398e16b4a5c8d054c1589c04e301be324b1 (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)