[PATCH] libosmocore[master]: Make EARFCN size calculation more robust

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/gerrit-log@lists.osmocom.org/.

Max gerrit-no-reply at lists.osmocom.org
Fri May 12 18:27:27 UTC 2017


Review at  https://gerrit.osmocom.org/2587

Make EARFCN size calculation more robust

* add osmo_earfcn_bit_size_ext() function which allows to specify how many
  EARFCNs we should skip when estimating required bit size for SI2quater
* make old osmo_earfcn_bit_size() into wrapper over newly added function
  and mark it as deprecated

This is necessary to properly estimate necessary space for EARFCNs when
they are spread over several SI2q messages with different index.

Change-Id: I92e12e91605bdab9916a3f665705287572434f74
Related: RT#8792
---
M include/osmocom/gsm/sysinfo.h
M src/gsm/libosmogsm.map
M src/gsm/sysinfo.c
3 files changed, 26 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/87/2587/1

diff --git a/include/osmocom/gsm/sysinfo.h b/include/osmocom/gsm/sysinfo.h
index c7972f4..f3e0f22 100644
--- a/include/osmocom/gsm/sysinfo.h
+++ b/include/osmocom/gsm/sysinfo.h
@@ -1,6 +1,8 @@
 #pragma once
 
 #include <stdbool.h>
+
+#include <osmocom/core/defs.h>
 #include <osmocom/core/utils.h>
 #include <osmocom/gsm/protocol/gsm_04_08.h>
 
@@ -66,7 +68,8 @@
 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);
+size_t osmo_earfcn_bit_size(const struct osmo_earfcn_si2q *e) OSMO_DEPRECATED("Use osmo_earfcn_bit_size_ext()instead.");
+size_t osmo_earfcn_bit_size_ext(const struct osmo_earfcn_si2q *e, size_t offset);
 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 97fd2b4..8fb9878 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -48,6 +48,7 @@
 osmo_earfcn_add;
 osmo_earfcn_del;
 osmo_earfcn_bit_size;
+osmo_earfcn_bit_size_ext;
 osmo_earfcn_init;
 
 gprs_cipher_gen_input_i;
diff --git a/src/gsm/sysinfo.c b/src/gsm/sysinfo.c
index 3ec5444..b5ebd57 100644
--- a/src/gsm/sysinfo.c
+++ b/src/gsm/sysinfo.c
@@ -151,15 +151,30 @@
  */
 size_t osmo_earfcn_bit_size(const struct osmo_earfcn_si2q *e)
 {
+	return osmo_earfcn_bit_size_ext(e, 0);
+}
+
+/*! \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
+ *  \param[in] offset into earfcn struct: how many EARFCNs to skip while estimating size
+ *  \returns number of bits
+ */
+size_t osmo_earfcn_bit_size_ext(const struct osmo_earfcn_si2q *e, size_t offset)
+{
 	/* 1 stop bit + 5 bits for THRESH_E-UTRAN_high */
-	size_t i, bits = 6;
+	size_t i, bits = 6, skip = 0;
 	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;
+			if (skip < offset)
+				skip++;
+			else {
+				bits += 17;
+				if (OSMO_EARFCN_MEAS_INVALID == e->meas_bw[i])
+					bits++;
+				else
+					bits += 4;
+			}
 		}
 	}
 	bits += (e->prio_valid) ? 4 : 1;

-- 
To view, visit https://gerrit.osmocom.org/2587
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I92e12e91605bdab9916a3f665705287572434f74
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list