aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/osmocom/gsm/gsm0808_utils.h1
-rw-r--r--src/gsm/gsm0808_utils.c83
-rw-r--r--src/gsm/libosmogsm.map1
3 files changed, 44 insertions, 41 deletions
diff --git a/include/osmocom/gsm/gsm0808_utils.h b/include/osmocom/gsm/gsm0808_utils.h
index 47c4e95c..3a7beb70 100644
--- a/include/osmocom/gsm/gsm0808_utils.h
+++ b/include/osmocom/gsm/gsm0808_utils.h
@@ -93,6 +93,7 @@ int gsm0808_cell_id_matches_list(const struct gsm0808_cell_id *id, const struct
void gsm0808_cell_id_from_cgi(struct gsm0808_cell_id *cid, enum CELL_IDENT id_discr,
const struct osmo_cell_global_id *cgi);
int gsm0808_cell_id_to_cgi(struct osmo_cell_global_id *cgi, const struct gsm0808_cell_id *cid);
+void gsm0808_msgb_put_cell_id_u(struct msgb *msg, enum CELL_IDENT id_discr, const union gsm0808_cell_id_u *u);
uint8_t gsm0808_enc_cause(struct msgb *msg, uint16_t cause);
uint8_t gsm0808_enc_aoip_trasp_addr(struct msgb *msg,
diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c
index 99cf1881..e8259300 100644
--- a/src/gsm/gsm0808_utils.c
+++ b/src/gsm/gsm0808_utils.c
@@ -737,6 +737,46 @@ int gsm0808_dec_encrypt_info(struct gsm0808_encrypt_info *ei,
return (int)(elem - old_elem);
}
+void gsm0808_msgb_put_cell_id_u(struct msgb *msg, enum CELL_IDENT id_discr, const union gsm0808_cell_id_u *u)
+{
+ switch (id_discr) {
+ case CELL_IDENT_WHOLE_GLOBAL: {
+ const struct osmo_cell_global_id *id = &u->global;
+ struct gsm48_loc_area_id lai;
+ gsm48_generate_lai2(&lai, &id->lai);
+ memcpy(msgb_put(msg, sizeof(lai)), &lai, sizeof(lai));
+ msgb_put_u16(msg, id->cell_identity);
+ break;
+ }
+ case CELL_IDENT_LAC_AND_CI: {
+ const struct osmo_lac_and_ci_id *id = &u->lac_and_ci;
+ msgb_put_u16(msg, id->lac);
+ msgb_put_u16(msg, id->ci);
+ break;
+ }
+ case CELL_IDENT_CI:
+ msgb_put_u16(msg, u->ci);
+ break;
+ case CELL_IDENT_LAI_AND_LAC: {
+ const struct osmo_location_area_id *id = &u->lai_and_lac;
+ struct gsm48_loc_area_id lai;
+ gsm48_generate_lai2(&lai, id);
+ memcpy(msgb_put(msg, sizeof(lai)), &lai, sizeof(lai));
+ break;
+ }
+ case CELL_IDENT_LAC:
+ msgb_put_u16(msg, u->lac);
+ break;
+ case CELL_IDENT_BSS:
+ case CELL_IDENT_NO_CELL:
+ /* Does not have any list items */
+ break;
+ default:
+ /* Support for other identifier list types is not implemented. */
+ OSMO_ASSERT(false);
+ }
+}
+
/*! Encode TS 08.08 Cell Identifier List IE
* \param[out] msg Message Buffer to which IE is to be appended
* \param[in] cil Cell ID List to be encoded
@@ -758,47 +798,8 @@ uint8_t gsm0808_enc_cell_id_list2(struct msgb *msg,
msgb_put_u8(msg, cil->id_discr & 0x0f);
OSMO_ASSERT(cil->id_list_len <= GSM0808_CELL_ID_LIST2_MAXLEN)
- switch (cil->id_discr) {
- case CELL_IDENT_WHOLE_GLOBAL:
- for (i = 0; i < cil->id_list_len; i++) {
- const struct osmo_cell_global_id *id = &cil->id_list[i].global;
- struct gsm48_loc_area_id lai;
- gsm48_generate_lai2(&lai, &id->lai);
- memcpy(msgb_put(msg, sizeof(lai)), &lai, sizeof(lai));
- msgb_put_u16(msg, id->cell_identity);
- }
- break;
- case CELL_IDENT_LAC_AND_CI:
- for (i = 0; i < cil->id_list_len; i++) {
- const struct osmo_lac_and_ci_id *id = &cil->id_list[i].lac_and_ci;
- msgb_put_u16(msg, id->lac);
- msgb_put_u16(msg, id->ci);
- }
- break;
- case CELL_IDENT_CI:
- for (i = 0; i < cil->id_list_len; i++)
- msgb_put_u16(msg, cil->id_list[i].ci);
- break;
- case CELL_IDENT_LAI_AND_LAC:
- for (i = 0; i < cil->id_list_len; i++) {
- const struct osmo_location_area_id *id = &cil->id_list[i].lai_and_lac;
- struct gsm48_loc_area_id lai;
- gsm48_generate_lai2(&lai, id);
- memcpy(msgb_put(msg, sizeof(lai)), &lai, sizeof(lai));
- }
- break;
- case CELL_IDENT_LAC:
- for (i = 0; i < cil->id_list_len; i++)
- msgb_put_u16(msg, cil->id_list[i].lac);
- break;
- case CELL_IDENT_BSS:
- case CELL_IDENT_NO_CELL:
- /* Does not have any list items */
- break;
- default:
- /* Support for other identifier list types is not implemented. */
- OSMO_ASSERT(false);
- }
+ for (i = 0; i < cil->id_list_len; i++)
+ gsm0808_msgb_put_cell_id_u(msg, cil->id_discr, &cil->id_list[i]);
*tlv_len = (uint8_t) (msg->tail - old_tail);
return *tlv_len + 2;
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index adfa096f..840bac9c 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -242,6 +242,7 @@ gsm0808_lcls_control_names;
gsm0808_lcls_status_names;
gsm0808_enc_lcls;
gsm0808_dec_lcls;
+gsm0808_msgb_put_cell_id_u;
gsm29118_msgb_alloc;
gsm29118_create_alert_req;