From 59a1bf3dae0d0a9e914d3c615c6aa7fc8955d7b5 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 15 Apr 2016 16:04:46 +0200 Subject: Add basic SI2quater support * support for sending arbitrary static SI2quater. * vty interface for neightbor EARFCNs specific to SI2quater. * dynamic generation of SI2quater messages. * unit test for SI2quater messages. Fixes: OS#1630 --- openbsc/tests/gsm0408/gsm0408_test.c | 69 ++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'openbsc/tests/gsm0408/gsm0408_test.c') diff --git a/openbsc/tests/gsm0408/gsm0408_test.c b/openbsc/tests/gsm0408/gsm0408_test.c index 781ef6147..d6abce61c 100644 --- a/openbsc/tests/gsm0408/gsm0408_test.c +++ b/openbsc/tests/gsm0408/gsm0408_test.c @@ -29,7 +29,11 @@ #include #include #include +#include +#include + #include +#include #define COMPARE(result, op, value) \ if (!((result) op (value))) {\ @@ -79,6 +83,70 @@ 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 test_si2q(void) +{ + struct gsm_bts *bts; + struct gsm_network *network = gsm_network_init(1, 1, NULL); + printf("Testing SYSINFO_TYPE_2quater 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"; @@ -486,6 +554,7 @@ int main(int argc, char **argv) test_range_encoding(); test_gsm411_rp_ref_wrap(); + test_si2q(); printf("Done.\n"); return EXIT_SUCCESS; } -- cgit v1.2.3 From 26679e0475593aca645c7029e1aad899da73217a Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 20 Apr 2016 15:57:13 +0200 Subject: Add basic UARFCN support * add data structures, generation functions * vty interface for neightbor UARFCNs specific to SI2quater * vty test * unit test Fixes: OS#1666 --- openbsc/tests/gsm0408/gsm0408_test.c | 75 ++++++++++++++++++++++++++---------- 1 file changed, 55 insertions(+), 20 deletions(-) (limited to 'openbsc/tests/gsm0408/gsm0408_test.c') diff --git a/openbsc/tests/gsm0408/gsm0408_test.c b/openbsc/tests/gsm0408/gsm0408_test.c index d6abce61c..2d91b68f0 100644 --- a/openbsc/tests/gsm0408/gsm0408_test.c +++ b/openbsc/tests/gsm0408/gsm0408_test.c @@ -103,11 +103,55 @@ static inline void gen(struct gsm_bts *bts) printf("failed to generate SI2quater: %s\n", strerror(-r)); } -static inline void test_si2q(void) +static inline void test_si2q_u(void) { struct gsm_bts *bts; struct gsm_network *network = gsm_network_init(1, 1, NULL); - printf("Testing SYSINFO_TYPE_2quater generation:\n"); + printf("Testing SYSINFO_TYPE_2quater UARFCN generation:\n"); + + if (!network) + exit(1); + bts = gsm_bts_alloc(network); + + bts_uarfcn_add(bts, 1982, 13, 1); + gen(bts); + + bts_uarfcn_add(bts, 1982, 44, 0); + gen(bts); + + bts_uarfcn_add(bts, 1982, 61, 1); + gen(bts); + + bts_uarfcn_add(bts, 1982, 89, 1); + gen(bts); + + bts_uarfcn_add(bts, 1982, 113, 0); + gen(bts); + + bts_uarfcn_add(bts, 1982, 123, 0); + gen(bts); + + bts_uarfcn_add(bts, 1982, 56, 1); + gen(bts); + + bts_uarfcn_add(bts, 1982, 72, 1); + gen(bts); + + bts_uarfcn_add(bts, 1982, 223, 1); + gen(bts); + + bts_uarfcn_add(bts, 1982, 14, 0); + gen(bts); + + 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(1, 1, NULL); + printf("Testing SYSINFO_TYPE_2quater EARFCN generation:\n"); if (!network) exit(1); @@ -230,11 +274,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", @@ -243,24 +283,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", @@ -471,8 +507,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))); } @@ -496,8 +531,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]); @@ -554,7 +588,8 @@ int main(int argc, char **argv) test_range_encoding(); test_gsm411_rp_ref_wrap(); - test_si2q(); + test_si2q_e(); + test_si2q_u(); printf("Done.\n"); return EXIT_SUCCESS; } -- cgit v1.2.3 From aafff96c4060e9bf6ceb9dee9652a91d293a6e1e Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 20 Apr 2016 15:57:14 +0200 Subject: Add vty check for max si2quater size Explicitly check if added (U|E)ARFCN will fit into available si2quater message. --- openbsc/tests/gsm0408/gsm0408_test.c | 52 +++++++++++++++--------------------- 1 file changed, 21 insertions(+), 31 deletions(-) (limited to 'openbsc/tests/gsm0408/gsm0408_test.c') diff --git a/openbsc/tests/gsm0408/gsm0408_test.c b/openbsc/tests/gsm0408/gsm0408_test.c index 2d91b68f0..92626670c 100644 --- a/openbsc/tests/gsm0408/gsm0408_test.c +++ b/openbsc/tests/gsm0408/gsm0408_test.c @@ -103,6 +103,16 @@ static inline void gen(struct gsm_bts *bts) 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; @@ -113,37 +123,17 @@ static inline void test_si2q_u(void) exit(1); bts = gsm_bts_alloc(network); - bts_uarfcn_add(bts, 1982, 13, 1); - gen(bts); - - bts_uarfcn_add(bts, 1982, 44, 0); - gen(bts); - - bts_uarfcn_add(bts, 1982, 61, 1); - gen(bts); - - bts_uarfcn_add(bts, 1982, 89, 1); - gen(bts); - - bts_uarfcn_add(bts, 1982, 113, 0); - gen(bts); - - bts_uarfcn_add(bts, 1982, 123, 0); - gen(bts); - - bts_uarfcn_add(bts, 1982, 56, 1); - gen(bts); - - bts_uarfcn_add(bts, 1982, 72, 1); - gen(bts); - - bts_uarfcn_add(bts, 1982, 223, 1); - gen(bts); - - bts_uarfcn_add(bts, 1982, 14, 0); - gen(bts); - - bts_uarfcn_add(bts, 1982, 88, 0); + _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); } -- cgit v1.2.3