From 11a4d9dd91216fe353e94bfdbbab53bc4f891c0d Mon Sep 17 00:00:00 2001 From: Stefan Sperling Date: Thu, 15 Feb 2018 18:28:04 +0100 Subject: support for more cell ID list types in libosmocore Introduce gsm0808_dec_cell_id_list2() with supports additional types of cell identifier lists. The new parsing routines are based on similar routines used by the paging code in osmo-bsc's osmo_bsc_bssap.c. Likewise, introduce gsm0808_enc_cell_id_list2() with support for the same additional types of cell identifier lists. The old API using struct gsm0808_cell_id_list is deprecated. The previous definition was insufficient because it assumed that all decoded cell ID types could be represented with a single uint16_t. It was declared in a GSM protocol header (gsm/protocol/gsm_08_08.h) despite being a host-side representation of data in an IE. The only user I am aware of is in osmo-msc, where this struct is used for one local variable. osmo-msc releases >= 1.1.0 make use of this API. While here, fix a small bug in a test: test_gsm0808_enc_dec_cell_id_list_bss() set the cell ID type to 'LAC' but obviously wants to use type 'BSS'. Change-Id: Ib7e754f538df0c83298a3c958b4e15a32fcb8abb Related: OS#2847 --- include/osmocom/gsm/gsm0808_utils.h | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'include/osmocom/gsm/gsm0808_utils.h') diff --git a/include/osmocom/gsm/gsm0808_utils.h b/include/osmocom/gsm/gsm0808_utils.h index 7432164d..363fc390 100644 --- a/include/osmocom/gsm/gsm0808_utils.h +++ b/include/osmocom/gsm/gsm0808_utils.h @@ -26,6 +26,27 @@ struct sockaddr_storage; #include +#include + + /*! (225-1)/2 is the maximum number of elements in a cell identifier list. */ +#define GSM0808_CELL_ID_LIST2_MAXLEN 127 + +/*! Parsed representation of a cell identifier list IE. */ +struct gsm0808_cell_id_list2 { + enum CELL_IDENT id_discr; + union { + /*! + * All elements of these arrays contain parsed representations of the + * data in the corresponding IE, in host-byte order. + */ + struct osmo_cell_global_id global; + struct osmo_lac_and_ci_id lac_and_ci; + uint16_t ci; + struct osmo_location_area_id lai_and_lac; + uint16_t lac; + } id_list[GSM0808_CELL_ID_LIST2_MAXLEN]; + unsigned int id_list_len; +}; uint8_t gsm0808_enc_aoip_trasp_addr(struct msgb *msg, const struct sockaddr_storage *ss); @@ -48,10 +69,14 @@ uint8_t gsm0808_enc_encrypt_info(struct msgb *msg, const struct gsm0808_encrypt_info *ei); int gsm0808_dec_encrypt_info(struct gsm0808_encrypt_info *ei, const uint8_t *elem, uint8_t len); +uint8_t gsm0808_enc_cell_id_list2(struct msgb *msg, const struct gsm0808_cell_id_list2 *cil); uint8_t gsm0808_enc_cell_id_list(struct msgb *msg, - const struct gsm0808_cell_id_list *cil); + const struct gsm0808_cell_id_list *cil) + OSMO_DEPRECATED("use gsm0808_enc_cell_id_list2 instead"); +int gsm0808_dec_cell_id_list2(struct gsm0808_cell_id_list2 *cil, const uint8_t *elem, uint8_t len); int gsm0808_dec_cell_id_list(struct gsm0808_cell_id_list *cil, - const uint8_t *elem, uint8_t len); + const uint8_t *elem, uint8_t len) + OSMO_DEPRECATED("use gsm0808_dec_cell_id_list2 instead"); int gsm0808_chan_type_to_speech_codec(uint8_t perm_spch); int gsm0808_speech_codec_from_chan_type(struct gsm0808_speech_codec *sc, uint8_t perm_spch); -- cgit v1.2.3