[PATCH] Add function to get osmo_earfcn bit size

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
Fri Apr 15 14:04:04 UTC 2016


From: Max <msuraev at sysmocom.de>

This function returns the number of bits necessary to pack osmo_earfcn
into Repeated E-UTRAN Neighbour Cells IE (3GPP TS 44.018 Table
10.5.2.33b.1).
---
 include/osmocom/gsm/sysinfo.h |  1 +
 src/gsm/libosmogsm.map        |  1 +
 src/gsm/sysinfo.c             | 24 ++++++++++++++++++++++++
 3 files changed, 26 insertions(+)

diff --git a/include/osmocom/gsm/sysinfo.h b/include/osmocom/gsm/sysinfo.h
index cb7e10d..c7972f4 100644
--- a/include/osmocom/gsm/sysinfo.h
+++ b/include/osmocom/gsm/sysinfo.h
@@ -66,6 +66,7 @@ typedef uint8_t sysinfo_buf_t[GSM_MACBLOCK_LEN];
 extern const struct value_string osmo_sitype_strs[_MAX_SYSINFO_TYPE];
 int osmo_earfcn_add(struct osmo_earfcn_si2q *e, uint16_t arfcn, uint8_t meas_bw);
 int osmo_earfcn_del(struct osmo_earfcn_si2q *e, uint16_t arfcn);
+size_t osmo_earfcn_bit_size(const struct osmo_earfcn_si2q *e);
 void osmo_earfcn_init(struct osmo_earfcn_si2q *e);
 uint8_t osmo_sitype2rsl(enum osmo_sysinfo_type si_type);
 enum osmo_sysinfo_type osmo_rsl2sitype(uint8_t rsl_si);
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index a3e4e14..6886a6c 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -31,6 +31,7 @@ dbm2rxlev;
 
 osmo_earfcn_add;
 osmo_earfcn_del;
+osmo_earfcn_bit_size;
 osmo_earfcn_init;
 
 gprs_cipher_gen_input_i;
diff --git a/src/gsm/sysinfo.c b/src/gsm/sysinfo.c
index 42e717f..3ec5444 100644
--- a/src/gsm/sysinfo.c
+++ b/src/gsm/sysinfo.c
@@ -144,6 +144,30 @@ int osmo_earfcn_add(struct osmo_earfcn_si2q *e, uint16_t arfcn, uint8_t meas_bw)
 	return -ENOMEM;
 }
 
+/*! \brief Return number of bits necessary to represent earfcn struct as
+ *  Repeated E-UTRAN Neighbour Cells IE from 3GPP TS 44.018 Table 10.5.2.33b.1
+ *  \param[in,out] e earfcn struct
+ *  \returns number of bits
+ */
+size_t osmo_earfcn_bit_size(const struct osmo_earfcn_si2q *e)
+{
+	/* 1 stop bit + 5 bits for THRESH_E-UTRAN_high */
+	size_t i, bits = 6;
+	for (i = 0; i < e->length; i++) {
+		if (e->arfcn[i] != OSMO_EARFCN_INVALID) {
+			bits += 17;
+			if (OSMO_EARFCN_MEAS_INVALID == e->meas_bw[i])
+				bits++;
+			else
+				bits += 4;
+		}
+	}
+	bits += (e->prio_valid) ? 4 : 1;
+	bits += (e->thresh_lo_valid) ? 6 : 1;
+	bits += (e->qrxlm_valid) ? 6 : 1;
+	return bits;
+}
+
 /*! \brief Delete arfcn (and corresponding measurement bandwith) from earfcn
  *  struct
  *  \param[in,out] e earfcn struct
-- 
2.8.1




More information about the OpenBSC mailing list