diff options
author | Max <msuraev@sysmocom.de> | 2016-03-17 11:51:09 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2016-03-17 14:07:19 +0100 |
commit | 03309b57e8ba0163032a1d3db6b44fc8a7e6147c (patch) | |
tree | 5da47f69684d70ef0d6cf7d585dd44e558118b95 /src/gsm | |
parent | d4793212b5026fed01d132fa7397cc0ff2f543fe (diff) |
Add basic EARFCN support
Add structure representing group of EARFCNs with common priority,
threshold etc.
Add functions to populate this structure.
Diffstat (limited to 'src/gsm')
-rw-r--r-- | src/gsm/libosmogsm.map | 4 | ||||
-rw-r--r-- | src/gsm/sysinfo.c | 50 |
2 files changed, 54 insertions, 0 deletions
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index 0aeefbb7..a6908a2c 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -29,6 +29,10 @@ osmo_sitype_strs; comp128; dbm2rxlev; +osmo_earfcn_add; +osmo_earfcn_del; +osmo_earfcn_init; + gprs_cipher_gen_input_i; gprs_cipher_gen_input_ui; gprs_cipher_load; diff --git a/src/gsm/sysinfo.c b/src/gsm/sysinfo.c index 1408f6bf..e4d0ddf7 100644 --- a/src/gsm/sysinfo.c +++ b/src/gsm/sysinfo.c @@ -125,6 +125,56 @@ const struct value_string osmo_sitype_strs[_MAX_SYSINFO_TYPE] = { { 0, NULL } }; +/*! \brief Add pair of arfcn and measurement bandwith value to earfcn struct + * \param[in,out] e earfcn struct + * \param[in] arfcn EARFCN value, 16 bits + * \param[in] meas_bw measurement bandwith value + * \returns 0 on success, error otherwise + */ +int osmo_earfcn_add(struct earfcn *e, uint16_t arfcn, uint8_t meas_bw) +{ + size_t i; + for (i = 0; i < e->length; i++) { + if (OSMO_EARFCN_INVALID == e->arfcn[i]) { + e->arfcn[i] = arfcn; + e->meas_bw[i] = meas_bw; + return 0; + } + } + return -ENOMEM; +} + +/*! \brief Delete arfcn (and corresponding measurement bandwith) from earfcn + * struct + * \param[in,out] e earfcn struct + * \param[in] arfcn EARFCN value, 16 bits + * \returns 0 on success, error otherwise + */ +int osmo_earfcn_del(struct earfcn *e, uint16_t arfcn) +{ + size_t i; + for (i = 0; i < e->length; i++) { + if (arfcn == e->arfcn[i]) { + e->arfcn[i] = OSMO_EARFCN_INVALID; + e->meas_bw[i] = OSMO_EARFCN_MEAS_INVALID; + return 0; + } + } + return -ENOENT; +} + +/*! \brief Initialize earfcn struct + * \param[in,out] e earfcn struct + */ +void osmo_earfcn_init(struct earfcn *e) +{ + size_t i; + for (i = 0; i < e->length; i++) { + e->arfcn[i] = OSMO_EARFCN_INVALID; + e->meas_bw[i] = OSMO_EARFCN_MEAS_INVALID; + } +} + uint8_t osmo_sitype2rsl(enum osmo_sysinfo_type si_type) { return sitype2rsl[si_type]; |