Review at  https://gerrit.osmocom.org/7786

add osmo_cgi_name()

Change-Id: Iebc5cdf61b697b1603900993fc265af3eca0cedf
---
M include/osmocom/gsm/gsm23003.h
M src/gsm/gsm23003.c
M src/gsm/libosmogsm.map
3 files changed, 22 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/86/7786/1

diff --git a/include/osmocom/gsm/gsm23003.h b/include/osmocom/gsm/gsm23003.h
index 02e7971..fd4f369 100644
--- a/include/osmocom/gsm/gsm23003.h
+++ b/include/osmocom/gsm/gsm23003.h
@@ -99,6 +99,8 @@
 const char *osmo_plmn_name(const struct osmo_plmn_id *plmn);
 const char *osmo_plmn_name2(const struct osmo_plmn_id *plmn);
 const char *osmo_lai_name(const struct osmo_location_area_id *lai);
+const char *osmo_cgi_name(const struct osmo_cell_global_id *cgi);
+const char *osmo_cgi_name2(const struct osmo_cell_global_id *cgi);
 
 void osmo_plmn_to_bcd(uint8_t *bcd_dst, const struct osmo_plmn_id *plmn);
 void osmo_plmn_from_bcd(const uint8_t *bcd_src, struct osmo_plmn_id *plmn);
diff --git a/src/gsm/gsm23003.c b/src/gsm/gsm23003.c
index 574400d..878ebc0 100644
--- a/src/gsm/gsm23003.c
+++ b/src/gsm/gsm23003.c
@@ -133,6 +133,24 @@
        return buf;
 }
 
+static const char *_cgi_name(const struct osmo_cell_global_id *cgi, char *buf, 
size_t buflen)
+{
+       snprintf(buf, buflen, "%s-%u", osmo_lai_name(&cgi->lai), 
cgi->cell_identity);
+       return buf;
+}
+
+const char *osmo_cgi_name(const struct osmo_cell_global_id *cgi)
+{
+       static char buf[32];
+       return _cgi_name(cgi, buf, sizeof(buf));
+}
+
+const char *osmo_cgi_name2(const struct osmo_cell_global_id *cgi)
+{
+       static char buf[32];
+       return _cgi_name(cgi, buf, sizeof(buf));
+}
+
 static void to_bcd(uint8_t *bcd, uint16_t val)
 {
        bcd[2] = val % 10;
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index 31717d5..a6ea47d 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -277,6 +277,8 @@
 osmo_plmn_name2;
 osmo_lai_name;
 osmo_rai_name;
+osmo_cgi_name;
+osmo_cgi_name2;
 osmo_mnc_from_str;
 osmo_mnc_cmp;
 osmo_plmn_cmp;

-- 
To view, visit https://gerrit.osmocom.org/7786
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iebc5cdf61b697b1603900993fc265af3eca0cedf
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofm...@sysmocom.de>

Reply via email to