aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-04-13 03:30:14 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2018-04-13 05:38:47 +0200
commit250e7f7d30c5d90e39293f67bf7553d2d3d094f6 (patch)
treefe82a5c3a070ac54f22324e036e791d7870c38e6 /include
parenta78b22ba203d9674bb797623b9c1dd985b523663 (diff)
add gsm0808_{enc,dec}_cell_id
Clarify semantics and micro-optimise for the case of single Cell Identifer IEs. Test in gsm0808_test.c So far we have gsm0808_enc_cell_id_list2(), but there also exist instances of single Cell Identifiers (3GPP TS 48.008 3.2.2.17). It is possible to decode the same using the cell identifier list API, but this forces the caller to also keep a full struct gsm0808_cell_id_list2 with all its 127 entries around. E.g. for handover, there are two Cell Identifiers (Serving and Target); I'd need two full cell id lists for each, and these would be dynamically allocated for each handover operation, whether it uses them or not. Related: OS#2283 (inter-BSC HO, BSC side) Change-Id: I9f9c528965775698ab62ac386af0516192c4b0cc
Diffstat (limited to 'include')
-rw-r--r--include/osmocom/gsm/gsm0808_utils.h33
1 files changed, 21 insertions, 12 deletions
diff --git a/include/osmocom/gsm/gsm0808_utils.h b/include/osmocom/gsm/gsm0808_utils.h
index 34eae438..8e71b43c 100644
--- a/include/osmocom/gsm/gsm0808_utils.h
+++ b/include/osmocom/gsm/gsm0808_utils.h
@@ -31,20 +31,27 @@ struct sockaddr_storage;
/*! (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. */
+/*! Instead of this, use either struct gsm0808_cell_id or gsm0808_cell_id_list2.
+ * All elements contain parsed representations of the data in the corresponding IE, in host-byte order.
+ */
+union gsm0808_cell_id_u {
+ 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;
+};
+
+/*! Parsed representation of Cell Identifier IE (3GPP TS 48.008 3.2.2.17) */
+struct gsm0808_cell_id {
+ enum CELL_IDENT id_discr;
+ union gsm0808_cell_id_u id;
+};
+
+/*! Parsed representation of a Cell Identifier List IE (3GPP TS 48.008 3.2.2.27). */
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];
+ union gsm0808_cell_id_u id_list[GSM0808_CELL_ID_LIST2_MAXLEN];
unsigned int id_list_len;
};
@@ -78,6 +85,8 @@ int gsm0808_dec_cell_id_list(struct gsm0808_cell_id_list *cil,
const uint8_t *elem, uint8_t len)
OSMO_DEPRECATED("use gsm0808_dec_cell_id_list2 instead");
int gsm0808_cell_id_list_add(struct gsm0808_cell_id_list2 *dst, const struct gsm0808_cell_id_list2 *src);
+uint8_t gsm0808_enc_cell_id(struct msgb *msg, const struct gsm0808_cell_id *ci);
+int gsm0808_dec_cell_id(struct gsm0808_cell_id *ci, const uint8_t *elem, uint8_t len);
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);