From 721aa6ded9c736e3cc5b20824dd58b1af4f4a907 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Tue, 20 Feb 2018 21:38:00 +0100 Subject: gsm: add osmo_mnc_from_str(), osmo_mnc_cmp(), osmo_plmn_cmp() for 3-digit MNC osmo_mnc_from_str() preserves leading zeros in the string and is useful for VTY config parsing (osmo-bsc, osmo-msc, osmo-sgsn, osmo-pcu). osmo_{plmn,mnc}_cmp() takes care of the slight intricacy of ignoring the 3-digit flag if the MNC is anyway >99. Will be used by osmo-sgsn.git and osmo-bsc.git. (All current users just care about identical MNC, but a proper cmp doesn't hurt.) Change-Id: Ib7176b1d65a03b76f41f94bc9d3293a8a07d24c6 --- include/osmocom/gsm/gsm23003.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/osmocom/gsm/gsm23003.h b/include/osmocom/gsm/gsm23003.h index 51e5ef83..660186e3 100644 --- a/include/osmocom/gsm/gsm23003.h +++ b/include/osmocom/gsm/gsm23003.h @@ -95,3 +95,8 @@ const char *osmo_lai_name(const struct osmo_location_area_id *lai); 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); + +int osmo_mnc_from_str(const char *mnc_str, uint16_t *mnc, bool *mnc_3_digits); + +int osmo_mnc_cmp(uint16_t a_mnc, bool a_mnc_3_digits, uint16_t b_mnc, bool b_mnc_3_digits); +int osmo_plmn_cmp(const struct osmo_plmn_id *a, const struct osmo_plmn_id *b); -- cgit v1.2.3