aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Willmann <dwillmann@sysmocom.de>2017-03-01 18:56:38 +0100
committerDaniel Willmann <dwillmann@sysmocom.de>2018-01-30 18:58:27 +0100
commite47099fbbf9efa3b59f2bdc53ed5e396b7b21bd7 (patch)
treef8e3f0817b7ff70411b441897bbcd6a61bbbc77a
parent0f4da6771cf3e5c3d5c1ed63d5b2cbf5c9be5e74 (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 2914a01b5..fb4d06f12 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)
{
msgb_talloc_ctx_init(NULL, 0);
@@ -1572,6 +1620,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.