From 49c7fb52f00816522a17abab9a5e7e277b1717f2 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Tue, 15 Jun 2010 18:48:55 +0800 Subject: nat: Return the SCCP connection, change order of patching and updating * Return the SCCP connection. This will be needed to store the assigned timeslot in there. * Update code to work with this change * This uncovered a bug in the CC handling, at the time the BSC was passed it was still a null pointer and the code would have failed. --- openbsc/tests/bsc-nat/bsc_nat_test.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'openbsc/tests') diff --git a/openbsc/tests/bsc-nat/bsc_nat_test.c b/openbsc/tests/bsc-nat/bsc_nat_test.c index 196f187d8..3a1096001 100644 --- a/openbsc/tests/bsc-nat/bsc_nat_test.c +++ b/openbsc/tests/bsc-nat/bsc_nat_test.c @@ -189,7 +189,7 @@ static void copy_to_msg(struct msgb *msg, const u_int8_t *data, unsigned int len } #define VERIFY(con_found, con, msg, ver, str) \ - if (con_found != con) { \ + if (!con_found || con_found->bsc != con) { \ fprintf(stderr, "Failed to find the con: %p\n", con_found); \ abort(); \ } \ @@ -203,7 +203,8 @@ static void test_contrack() { int rc; struct bsc_nat *nat; - struct bsc_connection *con, *con_found; + struct bsc_connection *con; + struct sccp_connections *con_found; struct bsc_nat_parsed *parsed; struct msgb *msg; @@ -226,7 +227,7 @@ static void test_contrack() abort(); } con_found = patch_sccp_src_ref_to_msc(msg, parsed, nat); - if (con_found != con) { + if (!con_found || con_found->bsc != con) { fprintf(stderr, "Failed to find the con: %p\n", con_found); abort(); } @@ -239,12 +240,12 @@ static void test_contrack() /* 2.) get the cc */ copy_to_msg(msg, msc_cc, sizeof(msc_cc)); parsed = bsc_nat_parse(msg); - if (update_sccp_src_ref(con, msg, parsed) != 0) { + con_found = patch_sccp_src_ref_to_bsc(msg, parsed, nat); + VERIFY(con_found, con, msg, msc_cc_patched, "MSC CC"); + if (update_sccp_src_ref(con_found, parsed) != 0) { fprintf(stderr, "Failed to update the SCCP con.\n"); abort(); } - con_found = patch_sccp_src_ref_to_bsc(msg, parsed, nat); - VERIFY(con_found, con, msg, msc_cc_patched, "MSC CC"); /* 3.) send some data */ copy_to_msg(msg, bsc_dtap, sizeof(bsc_dtap)); @@ -268,7 +269,7 @@ static void test_contrack() copy_to_msg(msg, bsc_rlc, sizeof(bsc_rlc)); parsed = bsc_nat_parse(msg); con_found = patch_sccp_src_ref_to_msc(msg, parsed, nat); - if (con_found != con) { + if (!con_found || con_found->bsc != con) { fprintf(stderr, "Failed to find the con: %p\n", con_found); abort(); } -- cgit v1.2.3