diff options
Diffstat (limited to 'openbsc/tests')
-rw-r--r-- | openbsc/tests/bsc-nat/Makefile.am | 1 | ||||
-rw-r--r-- | openbsc/tests/bsc-nat/bsc_data.c | 7 | ||||
-rw-r--r-- | openbsc/tests/bsc-nat/bsc_nat_test.c | 38 |
3 files changed, 44 insertions, 2 deletions
diff --git a/openbsc/tests/bsc-nat/Makefile.am b/openbsc/tests/bsc-nat/Makefile.am index d26bbeb47..bcd9f1827 100644 --- a/openbsc/tests/bsc-nat/Makefile.am +++ b/openbsc/tests/bsc-nat/Makefile.am @@ -9,5 +9,6 @@ bsc_nat_test_SOURCES = bsc_nat_test.c \ $(top_srcdir)/src/nat/bsc_filter.c \ $(top_srcdir)/src/nat/bsc_sccp.c \ $(top_srcdir)/src/nat/bsc_nat_utils.c \ + $(top_srcdir)/src/nat/bsc_mgcp_utils.c \ $(top_srcdir)/src/bssap.c bsc_nat_test_LDADD = $(top_builddir)/src/libbsc.a $(top_builddir)/src/libsccp.a $(LIBOSMOCORE_LIBS) diff --git a/openbsc/tests/bsc-nat/bsc_data.c b/openbsc/tests/bsc-nat/bsc_data.c index b73aff118..ca170e2ac 100644 --- a/openbsc/tests/bsc-nat/bsc_data.c +++ b/openbsc/tests/bsc-nat/bsc_data.c @@ -80,3 +80,10 @@ static const u_int8_t paging_by_lac_cmd[] = { 0x10, 0x52, 0x08, 0x08, 0x29, 0x47, 0x10, 0x02, 0x01, 0x50, 0x02, 0x30, 0x1a, 0x03, 0x05, 0x20, 0x15 }; + +/* an assignment command */ +static const u_int8_t ass_cmd[] = { +0x00, 0x12, 0xfd, 0x06, +0x00, 0x00, 0x49, 0x00, 0x01, 0x0b, 0x00, 0x09, +0x01, 0x0b, 0x03, 0x01, 0x0a, 0x11, 0x01, 0x00, +0x15 }; diff --git a/openbsc/tests/bsc-nat/bsc_nat_test.c b/openbsc/tests/bsc-nat/bsc_nat_test.c index 3a1096001..70e98d721 100644 --- a/openbsc/tests/bsc-nat/bsc_nat_test.c +++ b/openbsc/tests/bsc-nat/bsc_nat_test.c @@ -335,6 +335,41 @@ static void test_paging(void) talloc_free(parsed); } +static void test_mgcp(void) +{ + struct sccp_connections con; + struct bsc_nat_parsed *parsed; + struct msgb *msg; + + fprintf(stderr, "Testing MGCP.\n"); + memset(&con, 0, sizeof(con)); + + msg = msgb_alloc(4096, "foo"); + copy_to_msg(msg, ass_cmd, sizeof(ass_cmd)); + parsed = bsc_nat_parse(msg); + if (bsc_mgcp_assign(&con, msg) != 0) { + fprintf(stderr, "Failed to handle assignment.\n"); + abort(); + } + + if (con.msc_timeslot != 21) { + fprintf(stderr, "Timeslot should be 21.\n"); + abort(); + } + + if (con.bsc_timeslot != 21) { + fprintf(stderr, "Assigned timeslot should have been 21.\n"); + abort(); + } + talloc_free(parsed); + + bsc_mgcp_clear(&con); + if (con.bsc_timeslot != -1 || con.msc_timeslot != -1) { + fprintf(stderr, "Clearing should remove the mapping.\n"); + abort(); + } +} + int main(int argc, char **argv) { struct debug_target *stderr_target; @@ -345,9 +380,8 @@ int main(int argc, char **argv) test_filter(); test_contrack(); - - debug_set_log_level(stderr_target, 1); test_paging(); + test_mgcp(); return 0; } |