[PATCH 4/5] Add basic UARFCN support

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

msuraev at sysmocom.de msuraev at sysmocom.de
Wed Apr 20 13:57:13 UTC 2016


From: Max <msuraev at sysmocom.de>

* add data structures, generation functions
* vty interface for neightbor UARFCNs specific to SI2quater
* vty test
* unit test

Fixes: OS#1666
---
 openbsc/include/openbsc/gsm_data_shared.h    |   3 +
 openbsc/include/openbsc/rest_octets.h        |   8 +-
 openbsc/include/openbsc/system_information.h |   9 +-
 openbsc/src/libbsc/bsc_vty.c                 |  53 ++++++++++
 openbsc/src/libbsc/rest_octets.c             |  91 ++++++++++++++----
 openbsc/src/libbsc/system_information.c      | 139 ++++++++++++++++++++++++++-
 openbsc/tests/gsm0408/gsm0408_test.c         |  75 +++++++++++----
 openbsc/tests/gsm0408/gsm0408_test.ok        |  14 ++-
 openbsc/tests/vty_test_runner.py             |  23 +++++
 9 files changed, 369 insertions(+), 46 deletions(-)

diff --git a/openbsc/include/openbsc/gsm_data_shared.h b/openbsc/include/openbsc/gsm_data_shared.h
index 52e4805..8658fe7 100644
--- a/openbsc/include/openbsc/gsm_data_shared.h
+++ b/openbsc/include/openbsc/gsm_data_shared.h
@@ -717,6 +717,7 @@ struct gsm_bts {
 		struct bitvec cell_alloc;
 		struct bitvec si5_neigh_list;
 		struct osmo_earfcn_si2q si2quater_neigh_list;
+		size_t uarfcn_length; /* index for uarfcn and scramble lists */
 		struct {
 			/* bitmask large enough for all possible ARFCN's */
 			uint8_t neigh_list[1024/8];
@@ -725,6 +726,8 @@ struct gsm_bts {
 			uint8_t si5_neigh_list[1024/8];
 			uint8_t meas_bw_list[MAX_EARFCN_LIST];
 			uint16_t earfcn_list[MAX_EARFCN_LIST];
+			uint16_t uarfcn_list[MAX_EARFCN_LIST];
+			uint16_t scramble_list[MAX_EARFCN_LIST];
 		} data;
 	} si_common;
 
diff --git a/openbsc/include/openbsc/rest_octets.h b/openbsc/include/openbsc/rest_octets.h
index fd5ec6a..32b9963 100644
--- a/openbsc/include/openbsc/rest_octets.h
+++ b/openbsc/include/openbsc/rest_octets.h
@@ -5,11 +5,13 @@
 #include <openbsc/gsm_04_08.h>
 #include <osmocom/gsm/sysinfo.h>
 
+#define SI2Q_MAX_LEN 160
+#define SI2Q_MIN_LEN 18
+
 /* generate SI1 rest octets */
 int rest_octets_si1(uint8_t *data, uint8_t *nch_pos, int is1800_net);
-int rest_octets_si2quater(uint8_t *data,
-			  const struct osmo_earfcn_si2q *e, bool uarfcn,
-			  bool earfcn);
+int rest_octets_si2quater(uint8_t *data, const struct osmo_earfcn_si2q *e,
+			  const uint16_t *u, const uint16_t *sc, size_t u_len);
 
 struct gsm48_si_selection_params {
 	uint16_t penalty_time:5,
diff --git a/openbsc/include/openbsc/system_information.h b/openbsc/include/openbsc/system_information.h
index 6a56848..ecc6964 100644
--- a/openbsc/include/openbsc/system_information.h
+++ b/openbsc/include/openbsc/system_information.h
@@ -6,5 +6,12 @@
 struct gsm_bts;
 
 int gsm_generate_si(struct gsm_bts *bts, enum osmo_sysinfo_type type);
-
+uint16_t encode_fdd(uint16_t scramble, bool diversity);
+unsigned uarfcn_size(const uint16_t *u, const uint16_t *sc, size_t u_len);
+unsigned earfcn_size(const struct osmo_earfcn_si2q *e);
+unsigned range1024_p(unsigned n);
+unsigned range512_q(unsigned m);
+int bts_uarfcn_del(struct gsm_bts *bts, uint16_t arfcn, uint16_t scramble);
+int bts_uarfcn_add(struct gsm_bts *bts, uint16_t arfcn, uint16_t scramble,
+		   bool diversity);
 #endif
diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c
index 85b8394..cc46865 100644
--- a/openbsc/src/libbsc/bsc_vty.c
+++ b/openbsc/src/libbsc/bsc_vty.c
@@ -707,6 +707,14 @@ static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts)
 		}
 	}
 
+	for (i = 0; i < bts->si_common.uarfcn_length; i++) {
+		vty_out(vty, "  si2quater neighbor-list add uarfcn %u %u %u%s",
+			bts->si_common.data.uarfcn_list[i],
+			bts->si_common.data.scramble_list[i] & ~(1 << 9),
+			(bts->si_common.data.scramble_list[i] >> 9) & 1,
+			VTY_NEWLINE);
+	}
+
 	vty_out(vty, "  codec-support fr");
 	if (bts->codec.hr)
 		vty_out(vty, " hr");
@@ -2813,6 +2821,49 @@ DEFUN(cfg_bts_si2quater_neigh_del, cfg_bts_si2quater_neigh_del_cmd,
 	return CMD_SUCCESS;
 }
 
+DEFUN(cfg_bts_si2quater_uarfcn_add, cfg_bts_si2quater_uarfcn_add_cmd,
+      "si2quater neighbor-list add uarfcn <1900-2200> <0-511> <0-1>",
+      "SI2quater Neighbor List\n"
+      "SI2quater Neighbor List\n" "Add to manual SI2quater neighbor list\n"
+      "UARFCN of neighbor\n" "UARFCN of neighbor\n" "scrambling code\n"
+      "diversity bit\n")
+{
+	struct gsm_bts *bts = vty->index;
+	uint16_t arfcn = atoi(argv[0]), scramble = atoi(argv[1]);
+
+	switch(bts_uarfcn_add(bts, arfcn, scramble, atoi(argv[2]))) {
+	case -ENOMEM:
+		vty_out(vty, "Unable to add arfcn: max number of UARFCNs (%u) "
+			"reached%s", MAX_EARFCN_LIST, VTY_NEWLINE);
+	case -EADDRINUSE:
+		vty_out(vty, "Unable to add arfcn: (%u, %u) is already added%s",
+			arfcn, scramble, VTY_NEWLINE);
+		return CMD_WARNING;
+	}
+
+	return CMD_SUCCESS;
+}
+
+DEFUN(cfg_bts_si2quater_uarfcn_del, cfg_bts_si2quater_uarfcn_del_cmd,
+      "si2quater neighbor-list del uarfcn <1900-2200> <0-511>",
+      "SI2quater Neighbor List\n"
+      "SI2quater Neighbor List\n"
+      "Delete from SI2quater manual neighbor list\n"
+      "UARFCN of neighbor\n"
+      "UARFCN\n"
+      "scrambling code\n")
+{
+	struct gsm_bts *bts = vty->index;
+
+	if (bts_uarfcn_del(bts, atoi(argv[0]), atoi(argv[1])) < 0) {
+		vty_out(vty, "Unable to delete uarfcn: pair not found%s",
+			VTY_NEWLINE);
+		return CMD_WARNING;
+	}
+
+	return CMD_SUCCESS;
+}
+
 DEFUN(cfg_bts_si5_neigh, cfg_bts_si5_neigh_cmd,
 	"si5 neighbor-list (add|del) arfcn <0-1023>",
 	"SI5 Neighbor List\n"
@@ -3945,6 +3996,8 @@ int bsc_vty_init(const struct log_info *cat)
 	install_element(BTS_NODE, &cfg_bts_si5_neigh_cmd);
 	install_element(BTS_NODE, &cfg_bts_si2quater_neigh_add_cmd);
 	install_element(BTS_NODE, &cfg_bts_si2quater_neigh_del_cmd);
+	install_element(BTS_NODE, &cfg_bts_si2quater_uarfcn_add_cmd);
+	install_element(BTS_NODE, &cfg_bts_si2quater_uarfcn_del_cmd);
 	install_element(BTS_NODE, &cfg_bts_excl_rf_lock_cmd);
 	install_element(BTS_NODE, &cfg_bts_no_excl_rf_lock_cmd);
 	install_element(BTS_NODE, &cfg_bts_force_comb_si_cmd);
diff --git a/openbsc/src/libbsc/rest_octets.c b/openbsc/src/libbsc/rest_octets.c
index 113af5c..b59430b 100644
--- a/openbsc/src/libbsc/rest_octets.c
+++ b/openbsc/src/libbsc/rest_octets.c
@@ -31,8 +31,7 @@
 #include <osmocom/core/bitvec.h>
 #include <openbsc/rest_octets.h>
 #include <openbsc/arfcn_range_encode.h>
-
-#define SI2Q_MAX_LEN 160
+#include <openbsc/system_information.h>
 
 /* generate SI1 rest octets */
 int rest_octets_si1(uint8_t *data, uint8_t *nch_pos, int is1800_net)
@@ -108,14 +107,6 @@ static inline void append_eutran_neib_cell(struct bitvec *bv,
 		bitvec_set_bit(bv, 0);
 }
 
-static inline int append_earfcn_size(const struct osmo_earfcn_si2q *e)
-{
-	if (!e)
-		return -EFAULT;
-	/* account for all the constant bits */
-	return 25 + osmo_earfcn_bit_size(e);
-}
-
 static inline void append_earfcn(struct bitvec *bv,
 				const struct osmo_earfcn_si2q *e)
 {
@@ -188,11 +179,62 @@ static inline void append_earfcn(struct bitvec *bv,
 	bitvec_set_bit(bv, L);
 }
 
+static inline void append_uarfcn(struct bitvec *bv, const uint16_t *u,
+				 const uint16_t *sc, size_t length)
+{
+	int f0_inc, i, arfcns_used, w[RANGE_ENC_MAX_ARFCNS], a[length];
+	uint8_t chan_list[16] = {0};
+
+	/* 3G Neighbour Cell Description */
+	bitvec_set_bit(bv, 1);
+	/* No Index_Start_3G */
+	bitvec_set_bit(bv, 0);
+	/* No Absolute_Index_Start_EMR */
+	bitvec_set_bit(bv, 0);
+
+	/* UTRAN FDD Description */
+	bitvec_set_bit(bv, 1);
+	/* No Bandwidth_FDD */
+	bitvec_set_bit(bv, 0);
+
+	memset(w, 0, sizeof(w));
+	for (i = 0; i < length; i++)
+		a[i] = sc[i];
+
+	/* Note: we do not support repeating Neighbour Cells ATM */
+	/* Repeated UTRAN FDD Neighbour Cells */
+	bitvec_set_bit(bv, 1);
+
+	/* FDD-ARFCN */
+	bitvec_set_bit(bv, 0);
+	/* Note: we do not support multiple UARFCN values ATM: */
+	bitvec_set_uint(bv, u[0], 14);
+
+	arfcns_used = range_enc_filter_arfcns(a, length, 0, &f0_inc);
+	range_enc_arfcns(ARFCN_RANGE_1024, a, arfcns_used, w, 0);
+	range_enc_range1024(chan_list, 0, f0_inc, w);
+
+	/* FDD_Indic0: parameter value '0000000000' is not a member of the set */
+	bitvec_set_bit(bv, f0_inc);
+	/* NR_OF_FDD_CELLS */
+	bitvec_set_uint(bv, length, 5);
+
+	i = bv->cur_bit;
+	bitvec_add_range1024(bv, (struct gsm48_range_1024 *)chan_list);
+	bv->cur_bit = i + range1024_p(length);
+
+	/* stop bit - end of Repeated UTRAN FDD Neighbour Cells */
+	bitvec_set_bit(bv, 0);
+
+	/* UTRAN TDD Description */
+	bitvec_set_bit(bv, 0);
+}
+
 /* generate SI2quater rest octets: 3GPP TS 44.018 § 10.5.2.33b */
 int rest_octets_si2quater(uint8_t *data, const struct osmo_earfcn_si2q *e,
-			  bool uarfcn, bool earfcn)
+			  const uint16_t *u, const uint16_t *sc, size_t u_len)
 {
-	int rc;
+	unsigned sz;
 	struct bitvec bv;
 	bv.data = data;
 	bv.data_len = 20;
@@ -226,8 +268,17 @@ int rest_octets_si2quater(uint8_t *data, const struct osmo_earfcn_si2q *e,
 	/* No extension (length) */
 	bitvec_set_bit(&bv, 0);
 
-	if (uarfcn) {
-
+	if (u_len) {
+		sz = uarfcn_size(u, sc, u_len);
+		/* Even if we do not append EARFCN we still need to set 3 bits */
+		if (sz + bv.cur_bit + 3 > SI2Q_MAX_LEN) {
+			LOGP(DRR, LOGL_ERROR, "SI2quater: not enough memory to "
+			     "add UARFCNs bits, current %u + required %u + "
+			     "reminder %u > max %u\n", bv.cur_bit, sz, 3,
+			     SI2Q_MAX_LEN);
+			return -ENOMEM;
+		}
+		append_uarfcn(&bv, u, sc, u_len);
 	} else { /* No 3G Neighbour Cell Description */
 		bitvec_set_bit(&bv, 0);
 	}
@@ -237,12 +288,14 @@ int rest_octets_si2quater(uint8_t *data, const struct osmo_earfcn_si2q *e,
 	/* No GPRS_3G_MEASUREMENT Parameters Descr. */
 	bitvec_set_bit(&bv, 0);
 
-	if (earfcn) {
-		rc = append_earfcn_size(e);
-		if (rc < 0)
-			return rc;
-		if (rc  + bv.cur_bit > SI2Q_MAX_LEN)
+	if (e) {
+		sz = earfcn_size(e);
+		if (sz + bv.cur_bit > SI2Q_MAX_LEN) {
+			LOGP(DRR, LOGL_ERROR, "SI2quater: not enough memory to "
+			     "add EARFCNs bits, current %u + required %u > max "
+			     "%u\n", bv.cur_bit, sz, SI2Q_MAX_LEN);
 			return -ENOMEM;
+		}
 		append_earfcn(&bv, e);
 	} else {
 		/* No Additions in Rel-5: */
diff --git a/openbsc/src/libbsc/system_information.c b/openbsc/src/libbsc/system_information.c
index 43a492a..8952534 100644
--- a/openbsc/src/libbsc/system_information.c
+++ b/openbsc/src/libbsc/system_information.c
@@ -68,6 +68,139 @@ static int is_dcs_net(const struct gsm_bts *bts)
 	return 1;
 }
 
+/* Return q(m) for given NR_OF_TDD_CELLS - see Table 9.1.54.1a, 3GPP TS 44.018 */
+unsigned range1024_p(unsigned n)
+{
+	switch (n) {
+	case 0: return 0;
+	case 1: return 10;
+	case 2: return 19;
+	case 3: return 28;
+	case 4: return 36;
+	case 5: return 44;
+	case 6: return 52;
+	case 7: return 60;
+	case 8: return 67;
+	case 9: return 74;
+	case 10: return 81;
+	case 11: return 88;
+	case 12: return 95;
+	case 13: return 102;
+	case 14: return 109;
+	case 15: return 116;
+	case 16: return 122;
+	default: return 0;
+	}
+}
+
+/* Return q(m) for given NR_OF_TDD_CELLS - see Table 9.1.54.1b, 3GPP TS 44.018 */
+unsigned range512_q(unsigned m)
+{
+	switch (m) {
+	case 0: return 0;
+	case 1: return 9;
+	case 2: return 17;
+	case 3: return 25;
+	case 4: return 32;
+	case 5: return 39;
+	case 6: return 46;
+	case 7: return 53;
+	case 8: return 59;
+	case 9: return 65;
+	case 10: return 71;
+	case 11: return 77;
+	case 12: return 83;
+	case 13: return 89;
+	case 14: return 95;
+	case 15: return 101;
+	case 16: return 106;
+	case 17: return 111;
+	case 18: return 116;
+	case 19: return 121;
+	case 20: return 126;
+	default: return 0;
+	}
+}
+
+unsigned earfcn_size(const struct osmo_earfcn_si2q *e)
+{
+	/* account for all the constant bits in append_earfcn() */
+	return 25 + osmo_earfcn_bit_size(e);
+}
+
+unsigned uarfcn_size(const uint16_t *u, const uint16_t *sc, size_t u_len)
+{
+	/*account for all the constant bits in append_uarfcn() */
+	return 29 + range1024_p(u_len);
+}
+
+/* 3GPP TS 44.018, Table 9.1.54.1 - prepend diversity bit to scrambling code */
+uint16_t encode_fdd(uint16_t scramble, bool diversity)
+{
+	if (diversity)
+		return scramble | (1 << 9);
+	return scramble;
+}
+
+int bts_uarfcn_del(struct gsm_bts *bts, uint16_t arfcn, uint16_t scramble)
+{
+	uint16_t sc0 = encode_fdd(scramble, false), sc1 = encode_fdd(scramble, true),
+		*ual = bts->si_common.data.uarfcn_list,
+		*scl = bts->si_common.data.scramble_list;
+	size_t len = bts->si_common.uarfcn_length, i;
+	for (i = 0; i < len; i++) {
+		if (arfcn == ual[i] && (sc0 == scl[i] || sc1 == scl[i])) {
+			/* we rely on the assumption that (uarfcn, scramble)
+			   tuple is unique in the lists */
+			if (i != len - 1) { /* move the tail if necessary */
+				memmove(ual + i, ual + i + 1, 2 * (len - i + 1));
+				memmove(scl + i, scl + i + 1, 2 * (len - i + 1));
+			}
+			break;
+		}
+	}
+
+	if (i == len)
+		return -EINVAL;
+
+	bts->si_common.uarfcn_length--;
+	return 0;
+}
+
+int bts_uarfcn_add(struct gsm_bts *bts, uint16_t arfcn, uint16_t scramble,
+		   bool diversity)
+{
+	size_t len = bts->si_common.uarfcn_length, i, k;
+	uint16_t scr, chk,
+		*ual = bts->si_common.data.uarfcn_list,
+		*scl = bts->si_common.data.scramble_list,
+		scramble1 = encode_fdd(scramble, true),
+		scramble0 = encode_fdd(scramble, false);
+
+	scr = diversity ? scramble1 : scramble0;
+	chk = diversity ? scramble0 : scramble1;
+
+	if (len == MAX_EARFCN_LIST)
+		return -ENOMEM;
+
+	for (i = 0, k = 0; i < len; i++) {
+		if (arfcn == ual[i] && (scr == scl[i] || chk == scl[i]))
+			return -EADDRINUSE;
+		if (scr > scl[i])
+			k = i + 1;
+	}
+	/* we keep lists sorted by scramble code:
+	   insert into appropriate position and move the tail */
+	if (len - k) {
+		memmove(ual + k + 1, ual + k, (len - k) * 2);
+		memmove(scl + k + 1, scl + k, (len - k) * 2);
+	}
+	ual[k] = arfcn;
+	scl[k] = scr;
+	bts->si_common.uarfcn_length++;
+	return 0;
+}
+
 static inline int use_arfcn(const struct gsm_bts *bts, const bool bis, const bool ter,
 			const bool pgsm, const int arfcn)
 {
@@ -508,8 +641,10 @@ static int generate_si2quater(uint8_t *output, struct gsm_bts *bts)
 	si2q->header.system_information = GSM48_MT_RR_SYSINFO_2quater;
 
 	rc = rest_octets_si2quater(si2q->rest_octets,
-				   &bts->si_common.si2quater_neigh_list, false,
-				   true);
+				   &bts->si_common.si2quater_neigh_list,
+				   bts->si_common.data.uarfcn_list,
+				   bts->si_common.data.scramble_list,
+				   bts->si_common.uarfcn_length);
 	if (rc < 0)
 		return rc;
 
diff --git a/openbsc/tests/gsm0408/gsm0408_test.c b/openbsc/tests/gsm0408/gsm0408_test.c
index d6abce6..2d91b68 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;
 }
diff --git a/openbsc/tests/gsm0408/gsm0408_test.ok b/openbsc/tests/gsm0408/gsm0408_test.ok
index 59319bf..565eac6 100644
--- a/openbsc/tests/gsm0408/gsm0408_test.ok
+++ b/openbsc/tests/gsm0408/gsm0408_test.ok
@@ -62,7 +62,7 @@ testing RP-Reference wrap
 Allocated reference: 255
 Allocated reference: 0
 Allocated reference: 1
-Testing SYSINFO_TYPE_2quater generation:
+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 
@@ -70,4 +70,16 @@ added EARFCN 1945 - generated SI2quater: [23] 59 06 07 c0 00 04 86 59 83 be cc 1
 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 generate SI2quater: Cannot allocate memory
+failed to generate SI2quater: Cannot allocate memory
 Done.
diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py
index 7f64a80..c088855 100644
--- a/openbsc/tests/vty_test_runner.py
+++ b/openbsc/tests/vty_test_runner.py
@@ -244,6 +244,29 @@ class TestVTYNITB(TestVTYGenericBSC):
         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()
-- 
2.8.1




More information about the OpenBSC mailing list