diff options
author | Neels Hofmeyr <neels@hofmeyr.de> | 2018-03-22 14:04:30 +0100 |
---|---|---|
committer | Neels Hofmeyr <neels@hofmeyr.de> | 2018-04-13 05:27:02 +0200 |
commit | 43496206c18b783a0c82faacd964819f8ee2e837 (patch) | |
tree | 1de80c9ea275e109e567678c8bc3532db7eacfe9 /src | |
parent | c62fc2d20f433117a123ec43862263c02013b460 (diff) |
add osmo_cgi_name()
This will be used by cell idenitifier list code, like upcoming neighbor_ident
VTY in osmo-bsc and regression tests.
Change-Id: Iebc5cdf61b697b1603900993fc265af3eca0cedf
Diffstat (limited to 'src')
-rw-r--r-- | src/gsm/gsm23003.c | 27 | ||||
-rw-r--r-- | src/gsm/libosmogsm.map | 2 |
2 files changed, 29 insertions, 0 deletions
diff --git a/src/gsm/gsm23003.c b/src/gsm/gsm23003.c index 574400de..2c3b21e6 100644 --- a/src/gsm/gsm23003.c +++ b/src/gsm/gsm23003.c @@ -133,6 +133,33 @@ const char *osmo_lai_name(const struct osmo_location_area_id *lai) 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; +} + +/*! Return MCC-MNC-LAC-CI as string, in a static buffer. + * \param[in] cgi CGI to encode. + * \returns Static string buffer. + */ +const char *osmo_cgi_name(const struct osmo_cell_global_id *cgi) +{ + static char buf[32]; + return _cgi_name(cgi, buf, sizeof(buf)); +} + +/*! Same as osmo_cgi_name(), but uses a different static buffer. + * Useful for printing two distinct CGIs in the same printf format. + * \param[in] cgi CGI to encode. + * \returns Static string buffer. + */ +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 31717d55..a6ea47dd 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -277,6 +277,8 @@ osmo_plmn_name; 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; |