diff options
author | Neels Hofmeyr <neels@hofmeyr.de> | 2018-05-25 16:56:35 +0200 |
---|---|---|
committer | Neels Hofmeyr <neels@hofmeyr.de> | 2018-05-27 21:54:12 +0200 |
commit | 38e58416b1ab32a7f156d01b166493411f4cffdb (patch) | |
tree | 961eac0362d11fc1ef6f39d39f1d53511f43fbf3 /src/gsm/gsm0808_utils.c | |
parent | b4186824c20cbb5a18963d737f47718aed791e33 (diff) |
add gsm0808_cell_id_to_list()
The idea is to be able to add a gsm0808_cell_id to a gsm0808_cell_id_list2:
first convert it to a list, then re-use gsm0808_cell_id_list_add(). It will be
used by osmo-bsc to manage neighbor-BSS cell identifiers from VTY.
Change-Id: Ibf746ac60b1b1e920baf494b396658a5ceabd788
Diffstat (limited to 'src/gsm/gsm0808_utils.c')
-rw-r--r-- | src/gsm/gsm0808_utils.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c index 2c659bba..080fc95b 100644 --- a/src/gsm/gsm0808_utils.c +++ b/src/gsm/gsm0808_utils.c @@ -988,6 +988,37 @@ int gsm0808_cell_id_list_add(struct gsm0808_cell_id_list2 *dst, const struct gsm return added; } +/*! Convert a single Cell Identifier to a Cell Identifier List with one entry. + * \param dst[out] Overwrite this list. + * \param src[in] Set \a dst to contain exactly this item. + */ +void gsm0808_cell_id_to_list(struct gsm0808_cell_id_list2 *dst, const struct gsm0808_cell_id *src) +{ + if (!dst) + return; + if (!src) { + *dst = (struct gsm0808_cell_id_list2){ + .id_discr = CELL_IDENT_NO_CELL, + }; + return; + } + + *dst = (struct gsm0808_cell_id_list2){ + .id_discr = src->id_discr, + .id_list = { src->id }, + .id_list_len = 1, + }; + + switch (src->id_discr) { + case CELL_IDENT_NO_CELL: + case CELL_IDENT_BSS: + dst->id_list_len = 0; + break; + default: + break; + } +} + /*! Encode Cell Identifier IE (3GPP TS 48.008 3.2.2.17). * \param[out] msg Message Buffer to which IE is to be appended * \param[in] ci Cell ID to be encoded |