aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Willmann <dwillmann@sysmocom.de>2017-03-01 18:56:38 +0100
committerDaniel Willmann <dwillmann@sysmocom.de>2017-03-15 14:14:06 +0100
commit96279f9cc81dcb41e6b3dd5ed0918588d122dab0 (patch)
tree90d580a67369346af2a7f26be262bbfa04a9d67a
parentfafecb5e50b3efd6fcd0f9060fee1c9af87ceee1 (diff)
tests: Test IMSI routing with multiple MSCs
Change-Id: Iab46d45aa8ba708282debcd7b9d704fc40e6ff1f Ticket: SYS#3208 Sponsored-by: On-Waves ehf.
-rw-r--r--openbsc/tests/bsc-nat/bsc_nat_test.c49
-rw-r--r--openbsc/tests/bsc-nat/bsc_nat_test.ok1
2 files changed, 50 insertions, 0 deletions
diff --git a/openbsc/tests/bsc-nat/bsc_nat_test.c b/openbsc/tests/bsc-nat/bsc_nat_test.c
index 6e1e64be6..ac7d89ae1 100644
--- a/openbsc/tests/bsc-nat/bsc_nat_test.c
+++ b/openbsc/tests/bsc-nat/bsc_nat_test.c
@@ -1549,6 +1549,54 @@ static void test_nat_extract_lac()
bsc_nat_free(nat);
}
+static void test_multiple_msc_fwd()
+{
+ int res;
+ struct bsc_nat *nat;
+ struct msc_config *msc;
+ struct bsc_msg_acc_lst *acc;
+ struct bsc_msg_acc_lst_entry *entry;
+ char *re1 = "^1[0-9]*$";
+ char *re2 = "^2[0-9]*$";
+
+ printf("Test routing IMSIs to different MSCs\n");
+
+ /* Initialize the test case */
+ nat = bsc_nat_alloc();
+
+ /* Create MSC configs */
+ msc = msc_config_alloc(nat);
+ msc->msc_con = 0x23;
+ msc->acc_lst_name = "msc1";
+
+ msc = msc_config_alloc(nat);
+ msc->msc_con = 0x42;
+ msc->acc_lst_name = "msc2";
+
+ /* Create the ACLs */
+ acc = bsc_msg_acc_lst_get(nat, &nat->access_lists, "msc1");
+ OSMO_ASSERT(acc);
+ entry = bsc_msg_acc_lst_entry_create(acc);
+ OSMO_ASSERT(entry);
+ res = gsm_parse_reg(acc, &entry->imsi_allow_re, &entry->imsi_allow, 1, &re1);
+ OSMO_ASSERT(!res);
+
+ acc = bsc_msg_acc_lst_get(nat, &nat->access_lists, "msc2");
+ OSMO_ASSERT(acc);
+ entry = bsc_msg_acc_lst_entry_create(acc);
+ OSMO_ASSERT(entry);
+ res = gsm_parse_reg(acc, &entry->imsi_allow_re, &entry->imsi_allow, 1, &re2);
+ OSMO_ASSERT(!res);
+
+ /* Check that IMSIs are routed to the correct MSCs */
+ OSMO_ASSERT(msc_conn_by_imsi(nat, "100") == 0x23);
+ OSMO_ASSERT(msc_conn_by_imsi(nat, "101") == 0x23);
+ OSMO_ASSERT(msc_conn_by_imsi(nat, "200") == 0x42);
+ OSMO_ASSERT(msc_conn_by_imsi(nat, "201") == 0x42);
+
+ bsc_nat_free(nat);
+}
+
int main(int argc, char **argv)
{
sccp_set_log_area(DSCCP);
@@ -1571,6 +1619,7 @@ int main(int argc, char **argv)
test_mgcp_allocations();
test_barr_list_parsing();
test_nat_extract_lac();
+ test_multiple_msc_fwd();
printf("Testing execution completed.\n");
return 0;
diff --git a/openbsc/tests/bsc-nat/bsc_nat_test.ok b/openbsc/tests/bsc-nat/bsc_nat_test.ok
index ab04f4273..986a24452 100644
--- a/openbsc/tests/bsc-nat/bsc_nat_test.ok
+++ b/openbsc/tests/bsc-nat/bsc_nat_test.ok
@@ -36,4 +36,5 @@ IMSI: 12123127 CM: 3 LU: 5
IMSI: 12123128 CM: 3 LU: 6
IMSI: 12123124 CM: 3 LU: 2
Testing LAC extraction from SCCP CR
+Test routing IMSIs to different MSCs
Testing execution completed.