diff options
author | Max <msuraev@sysmocom.de> | 2017-05-11 15:38:10 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2017-05-14 08:51:26 +0000 |
commit | 91dd219b99336f519ac9e9f5bb13df4627550e47 (patch) | |
tree | 1dc0c2d6de8f795802bf42913986b745f9ba74ec /src | |
parent | 6959e3c1101f59968825d144ade1d53116f538ba (diff) |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/gsm/libosmogsm.map | 1 | ||||
-rw-r--r-- | src/gsm/sysinfo.c | 27 |
2 files changed, 22 insertions, 6 deletions
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index 97fd2b45..8fb9878a 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -48,6 +48,7 @@ dbm2rxlev; 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 3ec54448..b5ebd57d 100644 --- a/src/gsm/sysinfo.c +++ b/src/gsm/sysinfo.c @@ -151,15 +151,30 @@ int osmo_earfcn_add(struct osmo_earfcn_si2q *e, uint16_t arfcn, uint8_t meas_bw) */ 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; |