summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2016-04-15 16:04:04 +0200
committerHarald Welte <laforge@gnumonks.org>2016-04-16 13:41:56 +0200
commitfbb8bfa514284f9744809afba51dec716590090c (patch)
treed66c5065eb4f5502e3a3511e378cb1d8a898a069 /src
parentda1b20cd4f7b13121434d32817886d7803fd6052 (diff)
Add function to get osmo_earfcn bit size
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).
Diffstat (limited to 'src')
-rw-r--r--src/gsm/libosmogsm.map1
-rw-r--r--src/gsm/sysinfo.c24
2 files changed, 25 insertions, 0 deletions
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index a3e4e146..6886a6c0 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 42e717fe..3ec54448 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