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/.
dexter gerrit-no-reply at lists.osmocom.orgdexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/22438 )
Change subject: gprs_bssgp_rim: add functions to convert a RIM-RI to a string
......................................................................
gprs_bssgp_rim: add functions to convert a RIM-RI to a string
RIM routing formation structs can contain different variants of address
identifiers, so it is difficult for an API user to pick the _name()
function to generate a human readable string. Lets add
bssgp_rim_ri_name() and bssgp_rim_ri_name_buf() to make printing a
routing identifier easier.
Change-Id: Idca6bdccffe663aea71a0183ca3ea5bb5b59e702
Related: SYS#5103
---
M include/osmocom/gprs/gprs_bssgp_rim.h
M src/gb/gprs_bssgp_rim.c
M src/gb/libosmogb.map
3 files changed, 64 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/38/22438/1
diff --git a/include/osmocom/gprs/gprs_bssgp_rim.h b/include/osmocom/gprs/gprs_bssgp_rim.h
index 0810c8e..432805c 100644
--- a/include/osmocom/gprs/gprs_bssgp_rim.h
+++ b/include/osmocom/gprs/gprs_bssgp_rim.h
@@ -64,6 +64,8 @@
* address type (discr) of variable length. */
#define BSSGP_RIM_ROUTING_INFO_MAXLEN 14
+char *bssgp_rim_ri_name_buf(char *buf, size_t buf_len, const struct bssgp_rim_routing_info *ri);
+char *bssgp_rim_ri_name(const struct bssgp_rim_routing_info *ri);
int bssgp_parse_rim_ri(struct bssgp_rim_routing_info *ri, const uint8_t *buf, unsigned int len);
int bssgp_create_rim_ri(uint8_t *buf, const struct bssgp_rim_routing_info *ri);
diff --git a/src/gb/gprs_bssgp_rim.c b/src/gb/gprs_bssgp_rim.c
index 844268a..d89e526 100644
--- a/src/gb/gprs_bssgp_rim.c
+++ b/src/gb/gprs_bssgp_rim.c
@@ -146,6 +146,66 @@
return len;
}
+/*! Encode a RIM Routing information into a human readable string.
+ * \param[buf] user provided string buffer to store the resulting string.
+ * \param[buf_len] maximum length of string buffer.
+ * \param[in] ri user provided input data struct.
+ * \returns pointer to the beginning of the resulting string stored in string buffer. */
+char *bssgp_rim_ri_name_buf(char *buf, size_t buf_len, const struct bssgp_rim_routing_info *ri)
+{
+ static __thread char rai_buf[32];
+ static __thread char plmn_buf[16];
+ static __thread char en_bid_buf[16];
+ struct osmo_plmn_id plmn;
+ struct osmo_routing_area_id rai;
+
+ if (!ri)
+ return NULL;
+
+ switch (ri->discr) {
+ case BSSGP_RIM_ROUTING_INFO_GERAN:
+ rai.rac = ri->geran.raid.rac;
+ rai.lac.lac = ri->geran.raid.lac;
+ rai.lac.plmn.mcc = ri->geran.raid.mcc;
+ rai.lac.plmn.mnc_3_digits = ri->geran.raid.mnc_3_digits;
+ rai.lac.plmn.mnc = ri->geran.raid.mnc;
+ snprintf(buf, buf_len, "%s-%s-%u", bssgp_rim_routing_info_discr_str(ri->discr),
+ osmo_rai_name2_buf(rai_buf, sizeof(rai_buf), &rai), ri->geran.cid);
+ break;
+ case BSSGP_RIM_ROUTING_INFO_UTRAN:
+ rai.rac = ri->utran.raid.rac;
+ rai.lac.lac = ri->utran.raid.lac;
+ rai.lac.plmn.mcc = ri->utran.raid.mcc;
+ rai.lac.plmn.mnc_3_digits = ri->utran.raid.mnc_3_digits;
+ rai.lac.plmn.mnc = ri->utran.raid.mnc;
+ snprintf(buf, buf_len, "%s-%s-%u", bssgp_rim_routing_info_discr_str(ri->discr),
+ osmo_rai_name2_buf(rai_buf, sizeof(rai_buf), &rai), ri->utran.rncid);
+ break;
+ case BSSGP_RIM_ROUTING_INFO_EUTRAN:
+ plmn.mcc = ri->eutran.tai.mcc;
+ plmn.mnc = ri->eutran.tai.mnc;
+ plmn.mnc_3_digits = ri->eutran.tai.mnc_3_digits;
+ snprintf(buf, buf_len, "%s-%s-%u-%s", bssgp_rim_routing_info_discr_str(ri->discr),
+ osmo_plmn_name_buf(plmn_buf, sizeof(plmn_buf), &plmn), ri->eutran.tai.tac,
+ osmo_hexdump_buf(en_bid_buf, sizeof(en_bid_buf), ri->eutran.global_enb_id,
+ ri->eutran.global_enb_id_len, "", false));
+ break;
+ default:
+ snprintf(buf, buf_len, "invalid");
+ }
+
+ return buf;
+}
+
+/*! Encode a RIM Routing information into a human readable string.
+ * \param[in] ri user provided input data struct.
+ * \returns pointer to the resulting string. */
+char *bssgp_rim_ri_name(const struct bssgp_rim_routing_info *ri)
+{
+ static __thread char rim_ri_buf[64];
+ return bssgp_rim_ri_name_buf(rim_ri_buf, sizeof(rim_ri_buf), ri);
+}
+
/*! Decode a RAN Information Request Application Container for NACC (3GPP TS 48.018, section 11.3.63.1.1).
* \param[out] user provided memory for decoded data struct.
* \param[in] buf user provided memory with the encoded value data of the IE.
diff --git a/src/gb/libosmogb.map b/src/gb/libosmogb.map
index b4d7fdb..c6bbc78 100644
--- a/src/gb/libosmogb.map
+++ b/src/gb/libosmogb.map
@@ -35,6 +35,8 @@
bssgp_parse_rim_ri;
bssgp_ran_inf_app_id_strs;
bssgp_rim_routing_info_discr_strs;
+bssgp_rim_ri_name_buf;
+bssgp_rim_ri_name;
bssgp_set_bssgp_callback;
bssgp_tx_bvc_block;
bssgp_tx_bvc_reset;
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/22438
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Idca6bdccffe663aea71a0183ca3ea5bb5b59e702
Gerrit-Change-Number: 22438
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210125/7f3e9ff5/attachment.htm>