summaryrefslogtreecommitdiffstats
path: root/openbsc/tests
diff options
context:
space:
mode:
Diffstat (limited to 'openbsc/tests')
-rw-r--r--openbsc/tests/bsc-nat/bsc_nat_test.c14
-rw-r--r--openbsc/tests/ctrl_test_runner.py27
-rw-r--r--openbsc/tests/db/db_test.c6
-rw-r--r--openbsc/tests/gbproxy/gbproxy_test.c3
-rw-r--r--openbsc/tests/gprs/Makefile.am4
-rw-r--r--openbsc/tests/gprs/gprs_test.c480
-rw-r--r--openbsc/tests/gprs/gprs_test.ok14
-rw-r--r--openbsc/tests/gsm0408/Makefile.am3
-rw-r--r--openbsc/tests/gsm0408/gsm0408_test.c128
-rw-r--r--openbsc/tests/gsm0408/gsm0408_test.ok21
-rw-r--r--openbsc/tests/gtphub/gtphub_test.c2
-rw-r--r--openbsc/tests/mm_auth/mm_auth_test.c6
-rw-r--r--openbsc/tests/oap/Makefile.am1
-rw-r--r--openbsc/tests/oap/oap_test.c9
-rw-r--r--openbsc/tests/sgsn/Makefile.am1
-rw-r--r--openbsc/tests/sgsn/sgsn_test.c25
-rw-r--r--openbsc/tests/vty_test_runner.py225
17 files changed, 420 insertions, 549 deletions
diff --git a/openbsc/tests/bsc-nat/bsc_nat_test.c b/openbsc/tests/bsc-nat/bsc_nat_test.c
index a4b313c91..a405763bc 100644
--- a/openbsc/tests/bsc-nat/bsc_nat_test.c
+++ b/openbsc/tests/bsc-nat/bsc_nat_test.c
@@ -316,7 +316,7 @@ static void test_contrack()
printf("Testing connection tracking.\n");
nat = bsc_nat_alloc();
con = bsc_connection_alloc(nat);
- con->cfg = bsc_config_alloc(nat, "foo");
+ con->cfg = bsc_config_alloc(nat, "foo", 0);
bsc_config_add_lac(con->cfg, 23);
bsc_config_add_lac(con->cfg, 49);
bsc_config_add_lac(con->cfg, 42);
@@ -434,7 +434,7 @@ static void test_paging(void)
nat = bsc_nat_alloc();
con = bsc_connection_alloc(nat);
- cfg = bsc_config_alloc(nat, "unknown");
+ cfg = bsc_config_alloc(nat, "unknown", 0);
con->cfg = cfg;
bsc_config_add_lac(cfg, 23);
con->authenticated = 1;
@@ -476,7 +476,7 @@ static void test_mgcp_allocations(void)
nat->mgcp_cfg->trunk.number_endpoints = 64;
bsc = bsc_connection_alloc(nat);
- bsc->cfg = bsc_config_alloc(nat, "foo");
+ bsc->cfg = bsc_config_alloc(nat, "foo", 0);
bsc->cfg->max_endpoints = 60;
bsc_config_add_lac(bsc->cfg, 2323);
bsc->last_endpoint = 0x22;
@@ -522,7 +522,7 @@ static void test_mgcp_ass_tracking(void)
mgcp_endpoints_allocate(&nat->mgcp_cfg->trunk);
bsc = bsc_connection_alloc(nat);
- bsc->cfg = bsc_config_alloc(nat, "foo");
+ bsc->cfg = bsc_config_alloc(nat, "foo", 0);
bsc_config_add_lac(bsc->cfg, 2323);
bsc->last_endpoint = 0x1e;
con.bsc = bsc;
@@ -874,7 +874,7 @@ static void test_cr_filter()
struct bsc_nat *nat = bsc_nat_alloc();
struct bsc_connection *bsc = bsc_connection_alloc(nat);
- bsc->cfg = bsc_config_alloc(nat, "foo");
+ bsc->cfg = bsc_config_alloc(nat, "foo", 0);
bsc_config_add_lac(bsc->cfg, 1234);
bsc->cfg->acc_lst_name = "bsc";
nat->acc_lst_name = "nat";
@@ -953,7 +953,7 @@ static void test_dt_filter()
struct bsc_connection *bsc = bsc_connection_alloc(nat);
struct nat_sccp_connection *con = talloc_zero(0, struct nat_sccp_connection);
- bsc->cfg = bsc_config_alloc(nat, "foo");
+ bsc->cfg = bsc_config_alloc(nat, "foo", 0);
bsc_config_add_lac(bsc->cfg, 23);
con->bsc = bsc;
@@ -1525,7 +1525,7 @@ static void test_nat_extract_lac()
/* initialize the testcase */
nat = bsc_nat_alloc();
bsc = bsc_connection_alloc(nat);
- bsc->cfg = bsc_config_alloc(nat, "foo");
+ bsc->cfg = bsc_config_alloc(nat, "foo", 0);
memset(&con, 0, sizeof(con));
con.bsc = bsc;
diff --git a/openbsc/tests/ctrl_test_runner.py b/openbsc/tests/ctrl_test_runner.py
index 21850e348..7a126437c 100644
--- a/openbsc/tests/ctrl_test_runner.py
+++ b/openbsc/tests/ctrl_test_runner.py
@@ -469,6 +469,33 @@ class TestCtrlNITB(TestCtrlBase):
self.assertEquals(r['var'], 'number-of-bts')
self.assertEquals(r['value'], '1')
+ def testSubscriberAddWithKi(self):
+ """Test that we can set the algorithm to none, xor, comp128v1"""
+
+ r = self.do_set('subscriber-modify-v1', '2620345,445566')
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['var'], 'subscriber-modify-v1')
+ self.assertEquals(r['value'], 'OK')
+
+ r = self.do_set('subscriber-modify-v1', '2620345,445566,none')
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['var'], 'subscriber-modify-v1')
+ self.assertEquals(r['value'], 'OK')
+
+ r = self.do_set('subscriber-modify-v1', '2620345,445566,xor')
+ self.assertEquals(r['mtype'], 'ERROR')
+ self.assertEquals(r['error'], 'Value failed verification.')
+
+ r = self.do_set('subscriber-modify-v1', '2620345,445566,comp128v1,00112233445566778899AABBCCDDEEFF')
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['var'], 'subscriber-modify-v1')
+ self.assertEquals(r['value'], 'OK')
+
+ r = self.do_set('subscriber-modify-v1', '2620345,445566,none')
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['var'], 'subscriber-modify-v1')
+ self.assertEquals(r['value'], 'OK')
+
def testSubscriberAddRemove(self):
r = self.do_set('subscriber-modify-v1', '2620345,445566')
self.assertEquals(r['mtype'], 'SET_REPLY')
diff --git a/openbsc/tests/db/db_test.c b/openbsc/tests/db/db_test.c
index a02d1f801..fb159a5b1 100644
--- a/openbsc/tests/db/db_test.c
+++ b/openbsc/tests/db/db_test.c
@@ -1,5 +1,5 @@
/* (C) 2008 by Jan Luebbe <jluebbe@debian.org>
- * (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
+ * (C) 2009-2016 by Holger Hans Peter Freyther <zecke@selfish.org>
* (C) 2014 by Alexander Chemeris <Alexander.Chemeris@fairwaves.co>
* All Rights Reserved
*
@@ -246,6 +246,10 @@ int main()
SUBSCR_PUT(alice_db);
SUBSCR_PUT(alice);
+ /* create it again and see it fails */
+ alice = db_create_subscriber(alice_imsi);
+ OSMO_ASSERT(!alice);
+
test_sms();
test_sms_migrate();
diff --git a/openbsc/tests/gbproxy/gbproxy_test.c b/openbsc/tests/gbproxy/gbproxy_test.c
index 0ba827f76..a2ff95b1d 100644
--- a/openbsc/tests/gbproxy/gbproxy_test.c
+++ b/openbsc/tests/gbproxy/gbproxy_test.c
@@ -26,6 +26,7 @@
#include <osmocom/core/rate_ctr.h>
#include <osmocom/gsm/tlv.h>
#include <osmocom/gsm/gsm_utils.h>
+#include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
#include <osmocom/gprs/gprs_msgb.h>
#include <osmocom/gprs/gprs_ns.h>
#include <osmocom/gprs/gprs_bssgp.h>
@@ -34,7 +35,6 @@
#include <openbsc/gprs_utils.h>
#include <openbsc/gprs_llc.h>
#include <openbsc/gprs_gb_parse.h>
-#include <openbsc/gsm_04_08_gprs.h>
#include <openbsc/debug.h>
#include <openssl/rand.h>
@@ -1293,6 +1293,7 @@ static int gprs_process_message(struct gprs_ns_inst *nsi, const char *text, stru
}
msg = gprs_ns_msgb_alloc();
+ OSMO_ASSERT(msg);
memmove(msg->data, data, data_len);
msg->l2h = msg->data;
msgb_put(msg, data_len);
diff --git a/openbsc/tests/gprs/Makefile.am b/openbsc/tests/gprs/Makefile.am
index b57977b94..902313f2a 100644
--- a/openbsc/tests/gprs/Makefile.am
+++ b/openbsc/tests/gprs/Makefile.am
@@ -5,8 +5,6 @@ EXTRA_DIST = gprs_test.ok
noinst_PROGRAMS = gprs_test
-gprs_test_SOURCES = gprs_test.c $(top_srcdir)/src/gprs/gprs_utils.c \
- $(top_srcdir)/src/gprs/gprs_gsup_messages.c \
- $(top_srcdir)/src/libcommon/utils.c
+gprs_test_SOURCES = gprs_test.c $(top_srcdir)/src/gprs/gprs_utils.c
gprs_test_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS)
diff --git a/openbsc/tests/gprs/gprs_test.c b/openbsc/tests/gprs/gprs_test.c
index c78b98ab5..ff7740494 100644
--- a/openbsc/tests/gprs/gprs_test.c
+++ b/openbsc/tests/gprs/gprs_test.c
@@ -5,17 +5,14 @@
#include <openbsc/gprs_llc.h>
#include <openbsc/gprs_utils.h>
-#include <openbsc/gprs_gsup_messages.h>
-
#include <openbsc/debug.h>
#include <osmocom/core/application.h>
+#include <osmocom/gsm/gsup.h>
#define ASSERT_FALSE(x) if (x) { printf("Should have returned false.\n"); abort(); }
#define ASSERT_TRUE(x) if (!x) { printf("Should have returned true.\n"); abort(); }
-#define VERBOSE_FPRINTF(...)
-
/**
* GSM 04.64 8.4.2 Receipt of unacknowledged information
*/
@@ -146,479 +143,6 @@ static void test_gsm_03_03_apn(void)
}
}
-/* TODO: Move tlv testing to libosmocore */
-static void check_tlv_parse(uint8_t **data, size_t *data_len,
- uint8_t exp_tag, size_t exp_len, const uint8_t *exp_val)
-{
- uint8_t *value;
- size_t value_len;
- uint8_t tag;
- int rc;
- uint8_t *saved_data = *data;
- size_t saved_data_len = *data_len;
-
- rc = gprs_match_tlv(data, data_len, exp_tag ^ 1, NULL, NULL);
- OSMO_ASSERT(rc == 0);
-
- rc = gprs_match_tlv(data, data_len, exp_tag, &value, &value_len);
- OSMO_ASSERT(rc == (int)value_len + 2);
- OSMO_ASSERT(value_len == exp_len);
- OSMO_ASSERT(memcmp(value, exp_val, exp_len) == 0);
-
- /* restore data/data_len */
- *data = saved_data;
- *data_len = saved_data_len;
-
- rc = gprs_shift_tlv(data, data_len, &tag, &value, &value_len);
- OSMO_ASSERT(rc == (int)value_len + 2);
- OSMO_ASSERT(tag == exp_tag);
- OSMO_ASSERT(value_len == exp_len);
- OSMO_ASSERT(memcmp(value, exp_val, exp_len) == 0);
-}
-
-static void check_tv_fixed_match(uint8_t **data, size_t *data_len,
- uint8_t tag, size_t len, const uint8_t *exp_val)
-{
- uint8_t *value;
- int rc;
-
- rc = gprs_match_tv_fixed(data, data_len, tag ^ 1, len, NULL);
- OSMO_ASSERT(rc == 0);
-
- rc = gprs_match_tv_fixed(data, data_len, tag, len, &value);
- OSMO_ASSERT(rc == (int)len + 1);
- OSMO_ASSERT(memcmp(value, exp_val, len) == 0);
-}
-
-static void check_v_fixed_shift(uint8_t **data, size_t *data_len,
- size_t len, const uint8_t *exp_val)
-{
- uint8_t *value;
- int rc;
-
- rc = gprs_shift_v_fixed(data, data_len, len, &value);
- OSMO_ASSERT(rc == (int)len);
- OSMO_ASSERT(memcmp(value, exp_val, len) == 0);
-}
-
-static void check_lv_shift(uint8_t **data, size_t *data_len,
- size_t exp_len, const uint8_t *exp_val)
-{
- uint8_t *value;
- size_t value_len;
- int rc;
-
- rc = gprs_shift_lv(data, data_len, &value, &value_len);
- OSMO_ASSERT(rc == (int)value_len + 1);
- OSMO_ASSERT(value_len == exp_len);
- OSMO_ASSERT(memcmp(value, exp_val, exp_len) == 0);
-}
-
-static void check_tlv_match_data_len(size_t data_len, uint8_t tag, size_t len,
- const uint8_t *test_data)
-{
- uint8_t buf[300] = {0};
-
- uint8_t *unchanged_ptr = buf - 1;
- size_t unchanged_len = 0xdead;
- size_t tmp_data_len = data_len;
- uint8_t *value = unchanged_ptr;
- size_t value_len = unchanged_len;
- uint8_t *data = buf;
-
- OSMO_ASSERT(data_len <= sizeof(buf));
-
- tlv_put(data, tag, len, test_data);
- if (data_len < len + 2) {
- OSMO_ASSERT(-1 == gprs_match_tlv(&data, &tmp_data_len,
- tag, &value, &value_len));
- OSMO_ASSERT(tmp_data_len == 0);
- OSMO_ASSERT(data == buf + data_len);
- OSMO_ASSERT(value == unchanged_ptr);
- OSMO_ASSERT(value_len == unchanged_len);
- } else {
- OSMO_ASSERT(0 <= gprs_match_tlv(&data, &tmp_data_len,
- tag, &value, &value_len));
- OSMO_ASSERT(value != unchanged_ptr);
- OSMO_ASSERT(value_len != unchanged_len);
- }
-}
-
-static void check_tv_fixed_match_data_len(size_t data_len,
- uint8_t tag, size_t len,
- const uint8_t *test_data)
-{
- uint8_t buf[300] = {0};
-
- uint8_t *unchanged_ptr = buf - 1;
- size_t tmp_data_len = data_len;
- uint8_t *value = unchanged_ptr;
- uint8_t *data = buf;
-
- OSMO_ASSERT(data_len <= sizeof(buf));
-
- tv_fixed_put(data, tag, len, test_data);
-
- if (data_len < len + 1) {
- OSMO_ASSERT(-1 == gprs_match_tv_fixed(&data, &tmp_data_len,
- tag, len, &value));
- OSMO_ASSERT(tmp_data_len == 0);
- OSMO_ASSERT(data == buf + data_len);
- OSMO_ASSERT(value == unchanged_ptr);
- } else {
- OSMO_ASSERT(0 <= gprs_match_tv_fixed(&data, &tmp_data_len,
- tag, len, &value));
- OSMO_ASSERT(value != unchanged_ptr);
- }
-}
-
-static void check_v_fixed_shift_data_len(size_t data_len,
- size_t len, const uint8_t *test_data)
-{
- uint8_t buf[300] = {0};
-
- uint8_t *unchanged_ptr = buf - 1;
- size_t tmp_data_len = data_len;
- uint8_t *value = unchanged_ptr;
- uint8_t *data = buf;
-
- OSMO_ASSERT(data_len <= sizeof(buf));
-
- memcpy(data, test_data, len);
-
- if (data_len < len) {
- OSMO_ASSERT(-1 == gprs_shift_v_fixed(&data, &tmp_data_len,
- len, &value));
- OSMO_ASSERT(tmp_data_len == 0);
- OSMO_ASSERT(data == buf + data_len);
- OSMO_ASSERT(value == unchanged_ptr);
- } else {
- OSMO_ASSERT(0 <= gprs_shift_v_fixed(&data, &tmp_data_len,
- len, &value));
- OSMO_ASSERT(value != unchanged_ptr);
- }
-}
-
-static void check_lv_shift_data_len(size_t data_len,
- size_t len, const uint8_t *test_data)
-{
- uint8_t buf[300] = {0};
-
- uint8_t *unchanged_ptr = buf - 1;
- size_t unchanged_len = 0xdead;
- size_t tmp_data_len = data_len;
- uint8_t *value = unchanged_ptr;
- size_t value_len = unchanged_len;
- uint8_t *data = buf;
-
- lv_put(data, len, test_data);
- if (data_len < len + 1) {
- OSMO_ASSERT(-1 == gprs_shift_lv(&data, &tmp_data_len,
- &value, &value_len));
- OSMO_ASSERT(tmp_data_len == 0);
- OSMO_ASSERT(data == buf + data_len);
- OSMO_ASSERT(value == unchanged_ptr);
- OSMO_ASSERT(value_len == unchanged_len);
- } else {
- OSMO_ASSERT(0 <= gprs_shift_lv(&data, &tmp_data_len,
- &value, &value_len));
- OSMO_ASSERT(value != unchanged_ptr);
- OSMO_ASSERT(value_len != unchanged_len);
- }
-}
-
-static void test_tlv_shift_functions()
-{
- uint8_t test_data[1024];
- uint8_t buf[1024];
- uint8_t *data_end;
- unsigned i, len;
- uint8_t *data;
- size_t data_len;
- const uint8_t tag = 0x1a;
-
- printf("Test shift functions\n");
-
- for (i = 0; i < ARRAY_SIZE(test_data); i++)
- test_data[i] = (uint8_t)i;
-
- for (len = 0; len < 256; len++) {
- const unsigned iterations = sizeof(buf) / (len + 2) / 4;
-
- memset(buf, 0xee, sizeof(buf));
- data_end = data = buf;
-
- for (i = 0; i < iterations; i++) {
- data_end = tlv_put(data_end, tag, len, test_data);
- data_end = tv_fixed_put(data_end, tag, len, test_data);
- /* v_fixed_put */
- memcpy(data_end, test_data, len);
- data_end += len;
- data_end = lv_put(data_end, len, test_data);
- }
-
- data_len = data_end - data;
- OSMO_ASSERT(data_len <= sizeof(buf));
-
- for (i = 0; i < iterations; i++) {
- check_tlv_parse(&data, &data_len, tag, len, test_data);
- check_tv_fixed_match(&data, &data_len, tag, len, test_data);
- check_v_fixed_shift(&data, &data_len, len, test_data);
- check_lv_shift(&data, &data_len, len, test_data);
- }
-
- OSMO_ASSERT(data == data_end);
-
- /* Test at end of data */
-
- OSMO_ASSERT(-1 == gprs_match_tlv(&data, &data_len, tag, NULL, NULL));
- OSMO_ASSERT(-1 == gprs_match_tv_fixed(&data, &data_len, tag, len, NULL));
- OSMO_ASSERT((len ? -1 : 0) == gprs_shift_v_fixed(&data, &data_len, len, NULL));
- OSMO_ASSERT(-1 == gprs_shift_lv(&data, &data_len, NULL, NULL));
-
- /* Test invalid data_len */
- for (data_len = 0; data_len <= len + 2 + 1; data_len += 1) {
- check_tlv_match_data_len(data_len, tag, len, test_data);
- check_tv_fixed_match_data_len(data_len, tag, len, test_data);
- check_v_fixed_shift_data_len(data_len, len, test_data);
- check_lv_shift_data_len(data_len, len, test_data);
- }
- }
-}
-
-/* Tests for gprs_gsup_messages.c */
-
-#define TEST_IMSI_IE 0x01, 0x08, 0x21, 0x43, 0x65, 0x87, 0x09, 0x21, 0x43, 0xf5
-#define TEST_IMSI_STR "123456789012345"
-
-static void test_gsup_messages_dec_enc(void)
-{
- int test_idx;
- int rc;
- uint8_t buf[1024];
-
- static const uint8_t send_auth_info_req[] = {
- 0x08,
- TEST_IMSI_IE
- };
-
- static const uint8_t send_auth_info_err[] = {
- 0x09,
- TEST_IMSI_IE,
- 0x02, 0x01, 0x07 /* GPRS no allowed */
- };
-
- static const uint8_t send_auth_info_res[] = {
- 0x0a,
- TEST_IMSI_IE,
- 0x03, 0x22, /* Auth tuple */
- 0x20, 0x10,
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
- 0x21, 0x04,
- 0x21, 0x22, 0x23, 0x24,
- 0x22, 0x08,
- 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
- 0x03, 0x22, /* Auth tuple */
- 0x20, 0x10,
- 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88,
- 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90,
- 0x21, 0x04,
- 0xa1, 0xa2, 0xa3, 0xa4,
- 0x22, 0x08,
- 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8,
- };
-
- static const uint8_t update_location_req[] = {
- 0x04,
- TEST_IMSI_IE,
- };
-
- static const uint8_t update_location_err[] = {
- 0x05,
- TEST_IMSI_IE,
- 0x02, 0x01, 0x07 /* GPRS no allowed */
- };
-
- static const uint8_t update_location_res[] = {
- 0x06,
- TEST_IMSI_IE,
- 0x08, 0x07, /* MSISDN of the subscriber */
- 0x91, 0x94, 0x61, 0x46, 0x32, 0x24, 0x43,
- 0x09, 0x07, /* HLR-Number of the subscriber */
- 0x91, 0x83, 0x52, 0x38, 0x48, 0x83, 0x93,
- 0x04, 0x00, /* PDP info complete */
- 0x05, 0x15,
- 0x10, 0x01, 0x01,
- 0x11, 0x02, 0xf1, 0x21, /* IPv4 */
- 0x12, 0x09, 0x04, 't', 'e', 's', 't', 0x03, 'a', 'p', 'n',
- 0x13, 0x01, 0x02,
- 0x05, 0x11,
- 0x10, 0x01, 0x02,
- 0x11, 0x02, 0xf1, 0x21, /* IPv4 */
- 0x12, 0x08, 0x03, 'f', 'o', 'o', 0x03, 'a', 'p', 'n',
- };
-
- static const uint8_t location_cancellation_req[] = {
- 0x1c,
- TEST_IMSI_IE,
- 0x06, 0x01, 0x00,
- };
-
- static const uint8_t location_cancellation_err[] = {
- 0x1d,
- TEST_IMSI_IE,
- 0x02, 0x01, 0x03 /* Illegal MS */
- };
-
- static const uint8_t location_cancellation_res[] = {
- 0x1e,
- TEST_IMSI_IE,
- };
-
- static const uint8_t purge_ms_req[] = {
- 0x0c,
- TEST_IMSI_IE,
- };
-
- static const uint8_t purge_ms_err[] = {
- 0x0d,
- TEST_IMSI_IE,
- 0x02, 0x01, 0x03, /* Illegal MS */
- };
-
- static const uint8_t purge_ms_res[] = {
- 0x0e,
- TEST_IMSI_IE,
- 0x07, 0x00,
- };
-
- static const struct test {
- char *name;
- const uint8_t *data;
- size_t data_len;
- } test_messages[] = {
- {"Send Authentication Info Request",
- send_auth_info_req, sizeof(send_auth_info_req)},
- {"Send Authentication Info Error",
- send_auth_info_err, sizeof(send_auth_info_err)},
- {"Send Authentication Info Result",
- send_auth_info_res, sizeof(send_auth_info_res)},
- {"Update Location Request",
- update_location_req, sizeof(update_location_req)},
- {"Update Location Error",
- update_location_err, sizeof(update_location_err)},
- {"Update Location Result",
- update_location_res, sizeof(update_location_res)},
- {"Location Cancellation Request",
- location_cancellation_req, sizeof(location_cancellation_req)},
- {"Location Cancellation Error",
- location_cancellation_err, sizeof(location_cancellation_err)},
- {"Location Cancellation Result",
- location_cancellation_res, sizeof(location_cancellation_res)},
- {"Purge MS Request",
- purge_ms_req, sizeof(purge_ms_req)},
- {"Purge MS Error",
- purge_ms_err, sizeof(purge_ms_err)},
- {"Purge MS Result",
- purge_ms_res, sizeof(purge_ms_res)},
- };
-
- printf("Test GSUP message decoding/encoding\n");
-
- for (test_idx = 0; test_idx < ARRAY_SIZE(test_messages); test_idx++) {
- const struct test *t = &test_messages[test_idx];
- struct gprs_gsup_message gm = {0};
- struct msgb *msg = msgb_alloc(4096, "gsup_test");
-
- printf(" Testing %s\n", t->name);
-
- rc = gprs_gsup_decode(t->data, t->data_len, &gm);
- OSMO_ASSERT(rc >= 0);
-
- gprs_gsup_encode(msg, &gm);
-
- fprintf(stderr, " generated message: %s\n", msgb_hexdump(msg));
- fprintf(stderr, " original message: %s\n", osmo_hexdump(t->data, t->data_len));
- fprintf(stderr, " IMSI: %s\n", gm.imsi);
- OSMO_ASSERT(strcmp(gm.imsi, TEST_IMSI_STR) == 0);
- OSMO_ASSERT(msgb_length(msg) == t->data_len);
- OSMO_ASSERT(memcmp(msgb_data(msg), t->data, t->data_len) == 0);
-
- msgb_free(msg);
- }
-
- /* simple truncation test */
- for (test_idx = 0; test_idx < ARRAY_SIZE(test_messages); test_idx++) {
- int j;
- const struct test *t = &test_messages[test_idx];
- int ie_end = t->data_len;
- struct gprs_gsup_message gm = {0};
- int counter = 0;
- int parse_err = 0;
-
- for (j = t->data_len - 1; j >= 0; --j) {
- rc = gprs_gsup_decode(t->data, j, &gm);
- counter += 1;
-
- VERBOSE_FPRINTF(stderr,
- " partial message decoding: "
- "orig_len = %d, trunc = %d, rc = %d, ie_end = %d\n",
- t->data_len, j, rc, ie_end);
- if (rc >= 0) {
- VERBOSE_FPRINTF(stderr,
- " remaing partial message: %s\n",
- osmo_hexdump(t->data + j, ie_end - j));
-
- OSMO_ASSERT(j <= ie_end - 2);
- OSMO_ASSERT(t->data[j+0] <= GPRS_GSUP_KC_IE);
- OSMO_ASSERT(t->data[j+1] <= ie_end - j - 2);
-
- ie_end = j;
- } else {
- parse_err += 1;
- }
- }
-
- fprintf(stderr,
- " message %d: tested %d truncations, %d parse failures\n",
- test_idx, counter, parse_err);
- }
-
- /* message modification test (relies on ASAN or valgrind being used) */
- for (test_idx = 0; test_idx < ARRAY_SIZE(test_messages); test_idx++) {
- int j;
- const struct test *t = &test_messages[test_idx];
- struct gprs_gsup_message gm = {0};
- uint8_t val;
- int counter = 0;
- int parse_err = 0;
-
- OSMO_ASSERT(sizeof(buf) >= t->data_len);
-
- for (j = t->data_len - 1; j >= 0; --j) {
- memcpy(buf, t->data, t->data_len);
- val = 0;
- do {
- VERBOSE_FPRINTF(stderr,
- "t = %d, len = %d, val = %d\n",
- test_idx, j, val);
- buf[j] = val;
- rc = gprs_gsup_decode(buf, t->data_len, &gm);
- counter += 1;
- if (rc < 0)
- parse_err += 1;
-
- val += 1;
- } while (val != (uint8_t)256);
- }
-
- fprintf(stderr,
- " message %d: tested %d modifications, %d parse failures\n",
- test_idx, counter, parse_err);
- }
-}
-
static void test_gprs_timer_enc_dec(void)
{
int i, u, secs, tmr;
@@ -705,8 +229,6 @@ int main(int argc, char **argv)
test_8_4_2();
test_gsm_03_03_apn();
- test_tlv_shift_functions();
- test_gsup_messages_dec_enc();
test_gprs_timer_enc_dec();
printf("Done.\n");
diff --git a/openbsc/tests/gprs/gprs_test.ok b/openbsc/tests/gprs/gprs_test.ok
index cf710769e..da7888c6a 100644
--- a/openbsc/tests/gprs/gprs_test.ok
+++ b/openbsc/tests/gprs/gprs_test.ok
@@ -13,19 +13,5 @@ N(U) = 511, V(UR) = 511 => new
N(U) = 510, V(UR) = 511 => retransmit
N(U) = 481, V(UR) = 511 => retransmit
N(U) = 479, V(UR) = 511 => new
-Test shift functions
-Test GSUP message decoding/encoding
- Testing Send Authentication Info Request
- Testing Send Authentication Info Error
- Testing Send Authentication Info Result
- Testing Update Location Request
- Testing Update Location Error
- Testing Update Location Result
- Testing Location Cancellation Request
- Testing Location Cancellation Error
- Testing Location Cancellation Result
- Testing Purge MS Request
- Testing Purge MS Error
- Testing Purge MS Result
Test GPRS timer decoding/encoding
Done.
diff --git a/openbsc/tests/gsm0408/Makefile.am b/openbsc/tests/gsm0408/Makefile.am
index 619618652..d87913671 100644
--- a/openbsc/tests/gsm0408/Makefile.am
+++ b/openbsc/tests/gsm0408/Makefile.am
@@ -7,5 +7,6 @@ EXTRA_DIST = gsm0408_test.ok
gsm0408_test_SOURCES = gsm0408_test.c
gsm0408_test_LDADD = $(top_builddir)/src/libbsc/libbsc.a \
$(top_builddir)/src/libxsc/libxsc.a \
+ $(top_builddir)/src/libtrau/libtrau.a \
$(top_builddir)/src/libcommon/libcommon.a \
- $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) -ldbi
+ $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOABIS_LIBS) -ldbi
diff --git a/openbsc/tests/gsm0408/gsm0408_test.c b/openbsc/tests/gsm0408/gsm0408_test.c
index 88da271f2..1379c42ce 100644
--- a/openbsc/tests/gsm0408/gsm0408_test.c
+++ b/openbsc/tests/gsm0408/gsm0408_test.c
@@ -29,7 +29,11 @@
#include <openbsc/gsm_subscriber.h>
#include <openbsc/debug.h>
#include <openbsc/arfcn_range_encode.h>
+#include <openbsc/system_information.h>
+#include <openbsc/abis_rsl.h>
+
#include <osmocom/core/application.h>
+#include <osmocom/gsm/sysinfo.h>
#define COMPARE(result, op, value) \
if (!((result) op (value))) {\
@@ -79,6 +83,104 @@ static void test_location_area_identifier(void)
COMPARE(lai48.lac, ==, htons(0x000f));
}
+static inline void add_arfcn_b(struct osmo_earfcn_si2q *e, uint16_t earfcn,
+ uint8_t bw)
+{
+ int r = osmo_earfcn_add(e, earfcn, bw);
+ if (r)
+ printf("failed to add EARFCN %u: %s\n", earfcn, strerror(r));
+ else
+ printf("added EARFCN %u - ", earfcn);
+}
+
+static inline void gen(struct gsm_bts *bts)
+{
+ int r = gsm_generate_si(bts, SYSINFO_TYPE_2quater);
+ if (r > 0)
+ printf("generated SI2quater: [%d] %s\n", r,
+ osmo_hexdump(bts->si_buf[SYSINFO_TYPE_2quater], r));
+ else
+ printf("failed to generate SI2quater: %s\n", strerror(-r));
+}
+
+static inline void _bts_uarfcn_add(struct gsm_bts *bts, uint16_t arfcn,
+ uint16_t scramble, bool diversity)
+{
+ int r = bts_uarfcn_add(bts, arfcn, scramble, diversity);
+ if (r < 0)
+ printf("failed to add UARFCN to SI2quater: %s\n", strerror(-r));
+ else
+ gen(bts);
+}
+
+static inline void test_si2q_u(void)
+{
+ struct gsm_bts *bts;
+ struct gsm_network *network = gsm_network_init(NULL, 1, 1, NULL);
+ printf("Testing SYSINFO_TYPE_2quater UARFCN generation:\n");
+
+ if (!network)
+ exit(1);
+ bts = gsm_bts_alloc(network);
+
+ _bts_uarfcn_add(bts, 1982, 13, 1);
+ _bts_uarfcn_add(bts, 1982, 44, 0);
+ _bts_uarfcn_add(bts, 1982, 61, 1);
+ _bts_uarfcn_add(bts, 1982, 89, 1);
+ _bts_uarfcn_add(bts, 1982, 113, 0);
+ _bts_uarfcn_add(bts, 1982, 123, 0);
+ _bts_uarfcn_add(bts, 1982, 56, 1);
+ _bts_uarfcn_add(bts, 1982, 72, 1);
+ _bts_uarfcn_add(bts, 1982, 223, 1);
+ _bts_uarfcn_add(bts, 1982, 14, 0);
+ _bts_uarfcn_add(bts, 1982, 88, 0);
+ gen(bts);
+}
+
+static inline void test_si2q_e(void)
+{
+ struct gsm_bts *bts;
+ struct gsm_network *network = gsm_network_init(NULL, 1, 1, NULL);
+ printf("Testing SYSINFO_TYPE_2quater EARFCN generation:\n");
+
+ if (!network)
+ exit(1);
+ bts = gsm_bts_alloc(network);
+
+ bts->si_common.si2quater_neigh_list.arfcn =
+ bts->si_common.data.earfcn_list;
+ bts->si_common.si2quater_neigh_list.meas_bw =
+ bts->si_common.data.meas_bw_list;
+ bts->si_common.si2quater_neigh_list.length = MAX_EARFCN_LIST;
+ bts->si_common.si2quater_neigh_list.thresh_hi = 5;
+
+ osmo_earfcn_init(&bts->si_common.si2quater_neigh_list);
+
+ add_arfcn_b(&bts->si_common.si2quater_neigh_list, 1917, 1);
+ gen(bts);
+
+ add_arfcn_b(&bts->si_common.si2quater_neigh_list, 1932,
+ OSMO_EARFCN_MEAS_INVALID);
+ gen(bts);
+
+ add_arfcn_b(&bts->si_common.si2quater_neigh_list, 1937, 2);
+ gen(bts);
+
+ add_arfcn_b(&bts->si_common.si2quater_neigh_list, 1945,
+ OSMO_EARFCN_MEAS_INVALID);
+ gen(bts);
+
+ add_arfcn_b(&bts->si_common.si2quater_neigh_list, 1965,
+ OSMO_EARFCN_MEAS_INVALID);
+ gen(bts);
+
+ add_arfcn_b(&bts->si_common.si2quater_neigh_list, 1967, 4);
+ gen(bts);
+
+ add_arfcn_b(&bts->si_common.si2quater_neigh_list, 1982, 3);
+ gen(bts);
+}
+
static void test_mi_functionality(void)
{
const char *imsi_odd = "987654321098763";
@@ -162,11 +264,7 @@ static int test_single_range_encoding(int range, const int *orig_arfcns,
f0, &f0_included);
memset(w, 0, sizeof(w));
- rc = range_enc_arfcns(range, arfcns, arfcns_used, w, 0);
- if (rc != 0) {
- printf("Cannot compute range W(k), rc = %d\n", rc);
- return 1;
- }
+ range_enc_arfcns(range, arfcns, arfcns_used, w, 0);
if (!silent)
fprintf(stderr, "range=%d, arfcns_used=%d, f0=%d, f0_included=%d\n",
@@ -175,24 +273,20 @@ static int test_single_range_encoding(int range, const int *orig_arfcns,
/* Select the range and the amount of bits needed */
switch (range) {
case ARFCN_RANGE_128:
- rc = range_enc_range128(chan_list, f0, w);
+ range_enc_range128(chan_list, f0, w);
break;
case ARFCN_RANGE_256:
- rc = range_enc_range256(chan_list, f0, w);
+ range_enc_range256(chan_list, f0, w);
break;
case ARFCN_RANGE_512:
- rc = range_enc_range512(chan_list, f0, w);
+ range_enc_range512(chan_list, f0, w);
break;
case ARFCN_RANGE_1024:
- rc = range_enc_range1024(chan_list, f0, f0_included, w);
+ range_enc_range1024(chan_list, f0, f0_included, w);
break;
default:
return 1;
};
- if (rc != 0) {
- printf("Cannot encode range, rc = %d\n", rc);
- return 1;
- }
if (!silent)
printf("chan_list = %s\n",
@@ -403,8 +497,7 @@ static void test_print_encoding()
break;
}
- rc = range_enc_range512(chan_list, (1 << 9) | 0x96, w);
- VERIFY(rc, ==, 0);
+ range_enc_range512(chan_list, (1 << 9) | 0x96, w);
printf("Range512: %s\n", osmo_hexdump(chan_list, ARRAY_SIZE(chan_list)));
}
@@ -428,8 +521,7 @@ static void test_si_range_helpers()
printf("Element is: %d => freqs[i] = %d\n", i, i >= 0 ? freqs3[i] : -1);
VERIFY(i, ==, 0);
- i = range_enc_arfcns(1023, freqs1, ARRAY_SIZE(freqs1), ws, 0);
- VERIFY(i, ==, 0);
+ range_enc_arfcns(1023, freqs1, ARRAY_SIZE(freqs1), ws, 0);
for (i = 0; i < sizeof(freqs1)/sizeof(freqs1[0]); ++i) {
printf("w[%d]=%d\n", i, ws[i]);
@@ -486,6 +578,8 @@ int main(int argc, char **argv)
test_range_encoding();
test_gsm411_rp_ref_wrap();
+ test_si2q_e();
+ test_si2q_u();
printf("Done.\n");
return EXIT_SUCCESS;
}
diff --git a/openbsc/tests/gsm0408/gsm0408_test.ok b/openbsc/tests/gsm0408/gsm0408_test.ok
index 058563aab..7b7a2cc76 100644
--- a/openbsc/tests/gsm0408/gsm0408_test.ok
+++ b/openbsc/tests/gsm0408/gsm0408_test.ok
@@ -62,4 +62,25 @@ testing RP-Reference wrap
Allocated reference: 255
Allocated reference: 0
Allocated reference: 1
+Testing SYSINFO_TYPE_2quater EARFCN generation:
+added EARFCN 1917 - generated SI2quater: [23] 59 06 07 c0 00 04 86 59 83 be c8 50 0b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
+added EARFCN 1932 - generated SI2quater: [23] 59 06 07 c0 00 04 86 59 83 be cc 1e 30 14 03 2b 2b 2b 2b 2b 2b 2b 2b
+added EARFCN 1937 - generated SI2quater: [23] 59 06 07 c0 00 04 86 59 83 be cc 1e 31 07 91 a0 a0 2b 2b 2b 2b 2b 2b
+added EARFCN 1945 - generated SI2quater: [23] 59 06 07 c0 00 04 86 59 83 be cc 1e 31 07 91 a8 3c c8 28 0b 2b 2b 2b
+added EARFCN 1965 - generated SI2quater: [23] 59 06 07 c0 00 04 86 59 83 be cc 1e 31 07 91 a8 3c ca 0f 5a 0a 03 2b
+added EARFCN 1967 - failed to generate SI2quater: Cannot allocate memory
+added EARFCN 1982 - failed to generate SI2quater: Cannot allocate memory
+Testing SYSINFO_TYPE_2quater UARFCN generation:
+generated SI2quater: [23] 59 06 07 c0 00 25 0f 7c 0c 1a 10 99 64 00 0b 2b 2b 2b 2b 2b 2b 2b 2b
+generated SI2quater: [23] 59 06 07 c0 00 25 0f 7c 14 1a 1f 00 44 b2 00 03 2b 2b 2b 2b 2b 2b 2b
+generated SI2quater: [23] 59 06 07 c0 00 25 0f 7c 18 58 12 f0 84 86 59 00 03 2b 2b 2b 2b 2b 2b
+generated SI2quater: [23] 59 06 07 c0 00 25 0f 7c 20 58 2e f0 f2 04 86 59 00 03 2b 2b 2b 2b 2b
+generated SI2quater: [23] 59 06 07 c0 00 25 0f 7c 28 58 2e 22 f2 4e 84 86 59 00 03 2b 2b 2b 2b
+generated SI2quater: [23] 59 06 07 c0 00 25 0f 7c 34 1a 64 26 5d f2 05 04 86 59 00 03 2b 2b 2b
+generated SI2quater: [23] 59 06 07 c0 00 25 0f 7c 38 58 12 22 fd ce 8e 05 04 86 59 00 03 2b 2b
+generated SI2quater: [23] 59 06 07 c0 00 25 0f 7c 40 58 1d 22 fa ce 88 85 7b 00 44 b2 00 03 2b
+generated SI2quater: [23] 59 06 07 c0 00 25 0f 7c 4c 7a 34 0e 64 77 85 43 55 c8 10 99 64 00 0b
+failed to add UARFCN to SI2quater: No space left on device
+failed to add UARFCN to SI2quater: No space left on device
+generated SI2quater: [23] 59 06 07 c0 00 25 0f 7c 4c 7a 34 0e 64 77 85 43 55 c8 10 99 64 00 0b
Done.
diff --git a/openbsc/tests/gtphub/gtphub_test.c b/openbsc/tests/gtphub/gtphub_test.c
index 8ce83c82e..e24967b85 100644
--- a/openbsc/tests/gtphub/gtphub_test.c
+++ b/openbsc/tests/gtphub/gtphub_test.c
@@ -388,7 +388,7 @@ static void test_expiry(void)
#undef MAP3
}
-char resolve_ggsn_got_imsi[GSM_IMSI_LENGTH];
+char resolve_ggsn_got_imsi[GSM23003_IMSI_MAX_DIGITS+1];
char resolve_ggsn_got_ni[GSM_APN_LENGTH];
struct osmo_sockaddr resolved_ggsn_addr;
diff --git a/openbsc/tests/mm_auth/mm_auth_test.c b/openbsc/tests/mm_auth/mm_auth_test.c
index 34d96f187..b8777a8c5 100644
--- a/openbsc/tests/mm_auth/mm_auth_test.c
+++ b/openbsc/tests/mm_auth/mm_auth_test.c
@@ -26,9 +26,9 @@ static char *auth_tuple_str(struct gsm_auth_tuple *atuple)
print2buf("gsm_auth_tuple {\n");
print2buf(" .use_count = %d\n", atuple->use_count);
print2buf(" .key_seq = %d\n", atuple->key_seq);
- print2buf(" .rand = %s\n", osmo_hexdump(atuple->rand, sizeof(atuple->rand)));
- print2buf(" .sres = %s\n", osmo_hexdump(atuple->sres, sizeof(atuple->sres)));
- print2buf(" .kc = %s\n", osmo_hexdump(atuple->kc, sizeof(atuple->kc)));
+ print2buf(" .rand = %s\n", osmo_hexdump(atuple->vec.rand, sizeof(atuple->vec.rand)));
+ print2buf(" .sres = %s\n", osmo_hexdump(atuple->vec.sres, sizeof(atuple->vec.sres)));
+ print2buf(" .kc = %s\n", osmo_hexdump(atuple->vec.kc, sizeof(atuple->vec.kc)));
print2buf("}\n");
#undef print2buf
diff --git a/openbsc/tests/oap/Makefile.am b/openbsc/tests/oap/Makefile.am
index 3a76b11ad..538e1787e 100644
--- a/openbsc/tests/oap/Makefile.am
+++ b/openbsc/tests/oap/Makefile.am
@@ -15,7 +15,6 @@ oap_test_LDADD = \
$(top_builddir)/src/gprs/oap.o \
$(top_builddir)/src/gprs/oap_messages.o \
$(top_builddir)/src/gprs/gprs_utils.o \
- $(top_builddir)/src/gprs/gsm_04_08_gprs.o \
$(top_builddir)/src/libcommon/libcommon.a \
$(LIBOSMOCORE_LIBS) \
$(LIBOSMOGSM_LIBS) \
diff --git a/openbsc/tests/oap/oap_test.c b/openbsc/tests/oap/oap_test.c
index 9a2063bdc..339d77430 100644
--- a/openbsc/tests/oap/oap_test.c
+++ b/openbsc/tests/oap/oap_test.c
@@ -26,6 +26,7 @@
#include <openbsc/oap_messages.h>
#include <stdio.h>
+#include <string.h>
static void test_oap_api(void)
{
@@ -94,8 +95,8 @@ static void test_oap_api(void)
printf(" - AUTN failures\n");
- struct oap_message oap_rx;
- struct oap_message oap_tx;
+ struct osmo_oap_message oap_rx;
+ struct osmo_oap_message oap_tx;
struct msgb *msg_rx;
struct msgb *msg_tx;
@@ -167,7 +168,7 @@ static void test_oap_api(void)
/* Expect the challenge response in msg_tx */
OSMO_ASSERT(msg_tx);
- OSMO_ASSERT(oap_decode(msg_tx->data, msg_tx->len, &oap_tx) == 0);
+ OSMO_ASSERT(osmo_oap_decode(&oap_tx, msg_tx->data, msg_tx->len) == 0);
OSMO_ASSERT(oap_tx.message_type == OAP_MSGT_CHALLENGE_RESULT);
OSMO_ASSERT(strcmp("e2d05b598c61d9ba",
osmo_hexdump_nospc(oap_tx.xres, sizeof(oap_tx.xres)))
@@ -190,7 +191,7 @@ static void test_oap_api(void)
OSMO_ASSERT(oap_handle(state, msg_rx, &msg_tx) == 0);
OSMO_ASSERT(state->registration_failures == 1);
OSMO_ASSERT(msg_tx);
- OSMO_ASSERT(oap_decode(msg_tx->data, msg_tx->len, &oap_tx) == 0);
+ OSMO_ASSERT(osmo_oap_decode(&oap_tx, msg_tx->data, msg_tx->len) == 0);
OSMO_ASSERT(oap_tx.message_type == OAP_MSGT_REGISTER_REQUEST);
OSMO_ASSERT(state->state == OAP_REQUESTED_CHALLENGE);
msgb_free(msg_tx);
diff --git a/openbsc/tests/sgsn/Makefile.am b/openbsc/tests/sgsn/Makefile.am
index 477658c01..6e2416de7 100644
--- a/openbsc/tests/sgsn/Makefile.am
+++ b/openbsc/tests/sgsn/Makefile.am
@@ -23,7 +23,6 @@ sgsn_test_LDADD = \
$(top_builddir)/src/gprs/sgsn_libgtp.o \
$(top_builddir)/src/gprs/sgsn_auth.o \
$(top_builddir)/src/gprs/sgsn_ares.o \
- $(top_builddir)/src/gprs/gprs_gsup_messages.o \
$(top_builddir)/src/gprs/gprs_gsup_client.o \
$(top_builddir)/src/gprs/gprs_utils.o \
$(top_builddir)/src/gprs/gprs_subscriber.o \
diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c
index 2c5e2b429..15c4c17d0 100644
--- a/openbsc/tests/sgsn/sgsn_test.c
+++ b/openbsc/tests/sgsn/sgsn_test.c
@@ -24,7 +24,7 @@
#include <openbsc/gprs_gmm.h>
#include <openbsc/debug.h>
#include <openbsc/gsm_subscriber.h>
-#include <openbsc/gprs_gsup_messages.h>
+#include <osmocom/gsm/gsup.h>
#include <openbsc/gprs_gsup_client.h>
#include <openbsc/gprs_utils.h>
#include <openbsc/gprs_gb_parse.h>
@@ -32,7 +32,6 @@
#include <osmocom/gprs/gprs_bssgp.h>
#include <osmocom/gsm/gsm_utils.h>
-#include <openbsc/gsm_04_08_gprs.h>
#include <osmocom/core/application.h>
#include <osmocom/core/msgb.h>
@@ -617,8 +616,8 @@ static void test_subscriber_gsup(void)
/* Inject InsertSubscrData GSUP message */
last_updated_subscr = NULL;
rc = rx_gsup_message(insert_data_req, sizeof(insert_data_req));
- OSMO_ASSERT(rc == -GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL);
- OSMO_ASSERT(last_updated_subscr == NULL);
+ OSMO_ASSERT(rc = -ENOTSUP); /* not connected */
+ OSMO_ASSERT(last_updated_subscr == s1);
/* Inject DeleteSubscrData GSUP message */
last_updated_subscr = NULL;
@@ -1138,7 +1137,7 @@ static void test_gmm_attach_subscr_fake_auth(void)
int my_subscr_request_auth_info_real_auth(struct sgsn_mm_ctx *mmctx)
{
struct gsm_auth_tuple at = {
- .sres = {0x51, 0xe5, 0x51, 0xe5},
+ .vec.sres = {0x51, 0xe5, 0x51, 0xe5},
.key_seq = 0
};
@@ -1273,13 +1272,13 @@ static void test_gmm_attach_subscr_gsup_auth(int retry)
int my_gprs_gsup_client_send(struct gprs_gsup_client *gsupc, struct msgb *msg)
{
- struct gprs_gsup_message to_peer = {0};
- struct gprs_gsup_message from_peer = {0};
+ struct osmo_gsup_message to_peer = {0};
+ struct osmo_gsup_message from_peer = {0};
struct msgb *reply_msg;
int rc;
/* Simulate the GSUP peer */
- rc = gprs_gsup_decode(msgb_data(msg), msgb_length(msg), &to_peer);
+ rc = osmo_gsup_decode(msgb_data(msg), msgb_length(msg), &to_peer);
OSMO_ASSERT(rc >= 0);
OSMO_ASSERT(to_peer.imsi[0] != 0);
strncpy(from_peer.imsi, to_peer.imsi, sizeof(from_peer.imsi));
@@ -1288,16 +1287,16 @@ int my_gprs_gsup_client_send(struct gprs_gsup_client *gsupc, struct msgb *msg)
msgb_free(msg);
switch (to_peer.message_type) {
- case GPRS_GSUP_MSGT_UPDATE_LOCATION_REQUEST:
+ case OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST:
/* Send UPDATE_LOCATION_RESULT */
return my_subscr_request_update_gsup_auth(NULL);
- case GPRS_GSUP_MSGT_SEND_AUTH_INFO_REQUEST:
+ case OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST:
/* Send SEND_AUTH_INFO_RESULT */
return my_subscr_request_auth_info_gsup_auth(NULL);
- case GPRS_GSUP_MSGT_PURGE_MS_REQUEST:
- from_peer.message_type = GPRS_GSUP_MSGT_PURGE_MS_RESULT;
+ case OSMO_GSUP_MSGT_PURGE_MS_REQUEST:
+ from_peer.message_type = OSMO_GSUP_MSGT_PURGE_MS_RESULT;
break;
default:
@@ -1315,7 +1314,7 @@ int my_gprs_gsup_client_send(struct gprs_gsup_client *gsupc, struct msgb *msg)
reply_msg = gprs_gsup_msgb_alloc();
reply_msg->l2h = reply_msg->data;
- gprs_gsup_encode(reply_msg, &from_peer);
+ osmo_gsup_encode(reply_msg, &from_peer);
gprs_subscr_rx_gsup_message(reply_msg);
msgb_free(reply_msg);
diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py
index 8db0825e3..c0888559e 100644
--- a/openbsc/tests/vty_test_runner.py
+++ b/openbsc/tests/vty_test_runner.py
@@ -231,6 +231,43 @@ class TestVTYNITB(TestVTYGenericBSC):
self.assertEquals(self.vty.node(), 'config-mncc-int')
+ def testSi2Q(self):
+ self.vty.enable()
+ self.vty.command("configure terminal")
+ self.vty.command("network")
+ self.vty.command("bts 0")
+ before = self.vty.command("show running-config")
+ self.vty.command("si2quater neighbor-list add earfcn 1911 threshold 11 2")
+ self.vty.command("si2quater neighbor-list add earfcn 1924 threshold 11 3")
+ self.vty.command("si2quater neighbor-list add earfcn 2111 threshold 11")
+ self.vty.command("si2quater neighbor-list del earfcn 1911")
+ self.vty.command("si2quater neighbor-list del earfcn 1924")
+ self.vty.command("si2quater neighbor-list del earfcn 2111")
+ self.assertEquals(before, self.vty.command("show running-config"))
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 13 1")
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 38 1")
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 44 1")
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 120 1")
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 140 1")
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 163 1")
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 166 1")
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 217 1")
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 224 1")
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 225 1")
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 226 1")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 13")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 38")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 44")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 120")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 140")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 163")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 166")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 217")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 224")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 225")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 226")
+ self.assertEquals(before, self.vty.command("show running-config"))
+
def testEnableDisablePeriodicLU(self):
self.vty.enable()
self.vty.command("configure terminal")
@@ -307,6 +344,42 @@ class TestVTYNITB(TestVTYGenericBSC):
if classNum != 10:
self.assertEquals(res.find("rach access-control-class " + str(classNum) + " barred"), -1)
+ def testSubscriberCreateDeleteTwice(self):
+ """
+ OS#1657 indicates that there might be an issue creating the
+ same subscriber twice. This test will use the VTY command to
+ create a subscriber and then issue a second create command
+ with the same IMSI. The test passes if the VTY continues to
+ respond to VTY commands.
+ """
+ self.vty.enable()
+
+ imsi = "204300854013739"
+
+ # Initially we don't have this subscriber
+ self.vty.verify('show subscriber imsi '+imsi, ['% No subscriber found for imsi '+imsi])
+
+ # Lets create one
+ res = self.vty.command('subscriber create imsi '+imsi)
+ self.assert_(res.find(" IMSI: "+imsi) > 0)
+ # And now create one again.
+ res2 = self.vty.command('subscriber create imsi '+imsi)
+ self.assert_(res2.find(" IMSI: "+imsi) > 0)
+ self.assertEqual(res, res2)
+
+ # Verify it has been created
+ res = self.vty.command('show subscriber imsi '+imsi)
+ self.assert_(res.find(" IMSI: "+imsi) > 0)
+
+ # Delete it
+ res = self.vty.command('subscriber delete imsi '+imsi)
+ self.assert_(res != "")
+
+ # Now it should not be there anymore
+ res = self.vty.command('show subscriber imsi '+imsi)
+ self.assert_(res != '% No subscriber found for imsi '+imsi)
+
+
def testSubscriberCreateDelete(self):
self.vty.enable()
@@ -584,12 +657,63 @@ class TestVTYBSC(TestVTYGenericBSC):
class TestVTYNAT(TestVTYGenericBSC):
def vty_command(self):
- return ["./src/osmo-bsc_nat/osmo-bsc_nat", "-c",
+ return ["./src/osmo-bsc_nat/osmo-bsc_nat", "-l", "127.0.0.1", "-c",
"doc/examples/osmo-bsc_nat/osmo-bsc_nat.cfg"]
def vty_app(self):
return (4244, "src/osmo-bsc_nat/osmo-bsc_nat", "OsmoBSCNAT", "nat")
+ def testBSCreload(self):
+ # Use different port for the mock msc to avoid clashing with
+ # the osmo-bsc_nat itself
+ ip = "127.0.0.1"
+ port = 5522
+ self.vty.enable()
+ bscs1 = self.vty.command("show bscs-config")
+ nat_bsc_reload(self)
+ bscs2 = self.vty.command("show bscs-config")
+ # check that multiple calls to bscs-config-file give the same result
+ self.assertEquals(bscs1, bscs2)
+
+ # add new bsc
+ self.vty.command("configure terminal")
+ self.vty.command("nat")
+ self.vty.command("bsc 5")
+ self.vty.command("token key")
+ self.vty.command("location_area_code 666")
+ self.vty.command("end")
+
+ # update bsc token
+ self.vty.command("configure terminal")
+ self.vty.command("nat")
+ self.vty.command("bsc 1")
+ self.vty.command("token xyu")
+ self.vty.command("end")
+
+ nat_msc_ip(self, ip, port)
+ msc = nat_msc_test(self, ip, port)
+ b0 = nat_bsc_sock_test(0, "lol")
+ b1 = nat_bsc_sock_test(1, "xyu")
+ b2 = nat_bsc_sock_test(5, "key")
+
+ self.assertEquals("3 BSCs configured", self.vty.command("show nat num-bscs-configured"))
+ self.assertTrue(3 == nat_bsc_num_con(self))
+ self.assertEquals("MSC is connected: 1", self.vty.command("show msc connection"))
+
+ nat_bsc_reload(self)
+ bscs2 = self.vty.command("show bscs-config")
+ # check that the reset to initial config succeeded
+ self.assertEquals(bscs1, bscs2)
+
+ self.assertEquals("2 BSCs configured", self.vty.command("show nat num-bscs-configured"))
+ self.assertTrue(1 == nat_bsc_num_con(self))
+ rem = self.vty.command("show bsc connections").split(' ')
+ # remaining connection is for BSC0
+ self.assertEquals('0', rem[2])
+ # remaining connection is authorized
+ self.assertEquals('1', rem[4])
+ self.assertEquals("MSC is connected: 1", self.vty.command("show msc connection"))
+
def testVtyTree(self):
self.vty.enable()
self.assertTrue(self.vty.verify('configure terminal', ['']))
@@ -700,13 +824,13 @@ class TestVTYNAT(TestVTYGenericBSC):
self.assertEqual(data, "\x00\x01\xfe\x04")
print "Going to send ID_RESP response"
- res = ussdSocket.send("\x00\x07\xfe\x05\x00\x04\x01\x6b\x65\x79")
+ res = ipa_send_resp(ussdSocket, "\x6b\x65\x79")
self.assertEqual(res, 10)
# initiating PING/PONG cycle to know, that the ID_RESP message has been processed
print "Going to send PING request"
- res = ussdSocket.send("\x00\x01\xfe\x00")
+ res = ipa_send_ping(ussdSocket)
self.assertEqual(res, 4)
print "Expecting PONG response"
@@ -971,6 +1095,101 @@ def add_nat_test(suite, workdir):
test = unittest.TestLoader().loadTestsFromTestCase(TestVTYNAT)
suite.addTest(test)
+def ipa_send_pong(x, verbose = False):
+ if (verbose):
+ print "\tBSC -> NAT: PONG!"
+ return x.send("\x00\x01\xfe\x01")
+
+def ipa_send_ping(x, verbose = False):
+ if (verbose):
+ print "\tBSC -> NAT: PING?"
+ return x.send("\x00\x01\xfe\x00")
+
+def ipa_send_ack(x, verbose = False):
+ if (verbose):
+ print "\tBSC -> NAT: IPA ID ACK"
+ return x.send("\x00\x01\xfe\x06")
+
+def ipa_send_reset(x, verbose = False):
+ if (verbose):
+ print "\tBSC -> NAT: RESET"
+ return x.send("\x00\x12\xfd\x09\x00\x03\x05\x07\x02\x42\xfe\x02\x42\xfe\x06\x00\x04\x30\x04\x01\x20")
+
+def ipa_send_resp(x, tk, verbose = False):
+ if (verbose):
+ print "\tBSC -> NAT: IPA ID RESP"
+ return x.send("\x00\x07\xfe\x05\x00\x04\x01" + tk)
+
+def nat_bsc_reload(x):
+ x.vty.command("configure terminal")
+ x.vty.command("nat")
+ x.vty.command("bscs-config-file bscs.config")
+ x.vty.command("end")
+
+def nat_msc_ip(x, ip, port):
+ x.vty.command("configure terminal")
+ x.vty.command("nat")
+ x.vty.command("msc ip " + ip)
+ x.vty.command("msc port " + str(port))
+ x.vty.command("end")
+
+def data2str(d):
+ return d.encode('hex').lower()
+
+def nat_msc_test(x, ip, port, verbose = False):
+ msc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ msc.settimeout(32)
+ msc.bind((ip, port))
+ msc.listen(5)
+ if (verbose):
+ print "MSC is ready at " + ip
+ while "MSC is connected: 0" == x.vty.command("show msc connection"):
+ conn, addr = msc.accept()
+ if (verbose):
+ print "MSC got connection from ", addr
+ return conn
+
+def ipa_handle_small(x, verbose = False):
+ s = data2str(x.recv(4))
+ if "0001fe00" == s:
+ if (verbose):
+ print "\tBSC <- NAT: PING?"
+ ipa_send_pong(x, verbose)
+ elif "0001fe06" == s:
+ if (verbose):
+ print "\tBSC <- NAT: IPA ID ACK"
+ ipa_send_ack(x, verbose)
+ elif "0001fe00" == s:
+ if (verbose):
+ print "\tBSC <- NAT: PONG!"
+ else:
+ if (verbose):
+ print "\tBSC <- NAT: ", s
+
+def ipa_handle_resp(x, tk, verbose = False):
+ s = data2str(x.recv(38))
+ if "0023fe040108010701020103010401050101010011" in s:
+ ipa_send_resp(x, tk, verbose)
+ else:
+ if (verbose):
+ print "\tBSC <- NAT: ", s
+
+def nat_bsc_num_con(x):
+ return len(x.vty.command("show bsc connections").split('\n'))
+
+def nat_bsc_sock_test(nr, tk, verbose = False):
+ bsc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ bsc.bind(('127.0.0.1', 0))
+ bsc.connect(('127.0.0.1', 5000))
+ if (verbose):
+ print "BSC%d " %nr
+ print "\tconnected to %s:%d" % bsc.getpeername()
+ ipa_handle_small(bsc, verbose)
+ ipa_handle_resp(bsc, tk, verbose)
+ bsc.recv(27) # MGCP msg
+ ipa_handle_small(bsc, verbose)
+ return bsc
+
def add_bsc_test(suite, workdir):
if not os.path.isfile(os.path.join(workdir, "src/osmo-bsc/osmo-bsc")):
print("Skipping the BSC test")