This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Neels Hofmeyr gerrit-no-reply at lists.osmocom.orgNeels Hofmeyr has uploaded this change for review. ( https://gerrit.osmocom.org/13122 Change subject: add gsm0808_cell_id_from_cgi(), gsm0808_cell_id_to_cgi() ...................................................................... add gsm0808_cell_id_from_cgi(), gsm0808_cell_id_to_cgi() For example, for Paging, osmo-msc has a CGI for a subscriber and needs to send out a Cell Identifier IE. Makes sense to add this conversion here. While at it, also provide the reverse conversion. Change-Id: Ib9af67b100c4583342a2103669732dab2e577b04 --- M include/osmocom/gsm/gsm0808_utils.h M src/gsm/gsm0808_utils.c M src/gsm/libosmogsm.map 3 files changed, 91 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/22/13122/1 diff --git a/include/osmocom/gsm/gsm0808_utils.h b/include/osmocom/gsm/gsm0808_utils.h index 2b48be7..53f145c 100644 --- a/include/osmocom/gsm/gsm0808_utils.h +++ b/include/osmocom/gsm/gsm0808_utils.h @@ -84,6 +84,9 @@ bool gsm0808_cell_ids_match(const struct gsm0808_cell_id *id1, const struct gsm0808_cell_id *id2, bool exact_match); int gsm0808_cell_id_matches_list(const struct gsm0808_cell_id *id, const struct gsm0808_cell_id_list2 *list, unsigned int match_nr, bool exact_match); +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); 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 5477598..0426f78 100644 --- a/src/gsm/gsm0808_utils.c +++ b/src/gsm/gsm0808_utils.c @@ -1577,6 +1577,92 @@ return -1; } +/*! Copy information from a CGI to form a Cell Identifier of the specified kind. + * \param [out] cid Compose new Cell Identifier here. + * \param [in] id_discr Which kind of Cell Identifier to compose. + * \param [in] cgi Cell Global Identifier to form the Cell Identifier from. + */ +void gsm0808_cell_id_from_cgi(struct gsm0808_cell_id *cid, enum CELL_IDENT id_discr, + const struct osmo_cell_global_id *cgi) +{ + *cid = (struct gsm0808_cell_id){ + .id_discr = id_discr, + }; + + switch (id_discr) { + case CELL_IDENT_WHOLE_GLOBAL: + cid->id.global = *cgi; + return; + + case CELL_IDENT_LAC_AND_CI: + cid->id.lac_and_ci = (struct osmo_lac_and_ci_id){ + .lac = cgi->lai.lac, + .ci = cgi->cell_identity, + }; + return; + + case CELL_IDENT_CI: + cid->id.ci = cgi->cell_identity; + return; + + case CELL_IDENT_LAI: + cid->id.lai_and_lac = cgi->lai; + return; + + case CELL_IDENT_LAC: + cid->id.lac = cgi->lai.lac; + return; + + case CELL_IDENT_NO_CELL: + case CELL_IDENT_BSS: + case CELL_IDENT_UTRAN_PLMN_LAC_RNC: + case CELL_IDENT_UTRAN_RNC: + case CELL_IDENT_UTRAN_LAC_RNC: + default: + return; + }; +} + +/*! Overwrite parts of cgi with values from a Cell Identifier. + * Place only those items given in cid into cgi, leaving other values unchanged. + * \param[out] cgi Cell Global Identity to write to. + * \param[in] cid Cell Identity to read from. + * \return a bitmask of items that were set: 0x1 == PLMN, 0x2 == LAC, 0x4 == CI; 0 if nothing was written to cgi. + */ +int gsm0808_cell_id_to_cgi(struct osmo_cell_global_id *cgi, const struct gsm0808_cell_id *cid) +{ + switch (cid->id_discr) { + case CELL_IDENT_WHOLE_GLOBAL: + *cgi = cid->id.global; + return 0x1 | 0x2 | 0x4; + + case CELL_IDENT_LAC_AND_CI: + cgi->lai.lac = cid->id.lac_and_ci.lac; + cgi->cell_identity = cid->id.lac_and_ci.ci; + return 0x2 | 0x4; + + case CELL_IDENT_CI: + cgi->cell_identity = cid->id.ci; + return 0x4; + + case CELL_IDENT_LAI: + cgi->lai = cid->id.lai_and_lac; + return 0x1 | 0x2; + + case CELL_IDENT_LAC: + cgi->lai.lac = cid->id.lac; + return 0x2; + + case CELL_IDENT_NO_CELL: + case CELL_IDENT_BSS: + case CELL_IDENT_UTRAN_PLMN_LAC_RNC: + case CELL_IDENT_UTRAN_RNC: + case CELL_IDENT_UTRAN_LAC_RNC: + default: + return 0; + }; +} + /*! value_string[] for enum CELL_IDENT. */ const struct value_string gsm0808_cell_id_discr_names[] = { { CELL_IDENT_WHOLE_GLOBAL, "CGI" }, diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index 2d47d7a..3fadc5a 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -205,6 +205,8 @@ gsm0808_dec_cell_id_list2; gsm0808_cell_id_list_add; gsm0808_cell_id_to_list; +gsm0808_cell_id_to_cgi; +gsm0808_cell_id_from_cgi; gsm0808_enc_cell_id; gsm0808_dec_cell_id; gsm0808_cell_id_name; -- To view, visit https://gerrit.osmocom.org/13122 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-MessageType: newchange Gerrit-Change-Id: Ib9af67b100c4583342a2103669732dab2e577b04 Gerrit-Change-Number: 13122 Gerrit-PatchSet: 1 Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190304/6cf7b638/attachment.htm>