gsm: Introduce osmo_{rai,cgi_ps}_cmp() APIs

Similar to what we already have for other data types, such as
osmo_lai_cmp or osmo_cgi_cmp.

Change-Id: I00e329bc5be8674b30267dec238e7656ddfc21db
This commit is contained in:
Pau Espin 2021-01-22 17:44:34 +01:00
parent cc885fb0b6
commit d426ba6730
4 changed files with 39 additions and 0 deletions

View File

@ -13,3 +13,4 @@ libosmogsm API change struct ipac_preproc_ave_cfg: new zero-sized flexible arra
libosmovty ABI change struct cmd_element: add a field for program specific attributes
libosmovty ABI change struct vty_app_info: optional program specific attributes description
libosmoctrl ABI change struct ctrl_handle changed size (new field "reply_cb" at the end)
libosmogsm new API osmo_rai_cmp(), osmo_cgi_ps_cmp()

View File

@ -157,7 +157,9 @@ static inline int osmo_mcc_from_str(const char *mcc_str, uint16_t *mcc)
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);
int osmo_lai_cmp(const struct osmo_location_area_id *a, const struct osmo_location_area_id *b);
int osmo_rai_cmp(const struct osmo_routing_area_id *a, const struct osmo_routing_area_id *b);
int osmo_cgi_cmp(const struct osmo_cell_global_id *a, const struct osmo_cell_global_id *b);
int osmo_cgi_ps_cmp(const struct osmo_cell_global_id_ps *a, const struct osmo_cell_global_id_ps *b);
int osmo_gen_home_network_domain(char *out, const struct osmo_plmn_id *plmn);
int osmo_parse_home_network_domain(struct osmo_plmn_id *out, const char *in);

View File

@ -565,6 +565,23 @@ int osmo_lai_cmp(const struct osmo_location_area_id *a, const struct osmo_locati
return 0;
}
/* Compare two RAI.
* The order of comparison is MCC, MNC, LAC, RAC. See also osmo_lai_cmp().
* \param a[in] "Left" side RAI.
* \param b[in] "Right" side RAI.
* \returns 0 if the RAI are equal, -1 if a < b, 1 if a > b. */
int osmo_rai_cmp(const struct osmo_routing_area_id *a, const struct osmo_routing_area_id *b)
{
int rc = osmo_lai_cmp(&a->lac, &b->lac);
if (rc)
return rc;
if (a->rac < b->rac)
return -1;
if (a->rac > b->rac)
return 1;
return 0;
}
/* Compare two CGI.
* The order of comparison is MCC, MNC, LAC, CI. See also osmo_lai_cmp().
* \param a[in] "Left" side CGI.
@ -582,6 +599,23 @@ int osmo_cgi_cmp(const struct osmo_cell_global_id *a, const struct osmo_cell_glo
return 0;
}
/* Compare two CGI-PS.
* The order of comparison is MCC, MNC, LAC, RAC, CI. See also osmo_rai_cmp().
* \param a[in] "Left" side CGI-PS.
* \param b[in] "Right" side CGI-PS.
* \returns 0 if the CGI are equal, -1 if a < b, 1 if a > b. */
int osmo_cgi_ps_cmp(const struct osmo_cell_global_id_ps *a, const struct osmo_cell_global_id_ps *b)
{
int rc = osmo_rai_cmp(&a->rai, &b->rai);
if (rc)
return rc;
if (a->cell_identity < b->cell_identity)
return -1;
if (a->cell_identity > b->cell_identity)
return 1;
return 0;
}
/*! Generate TS 23.003 Section 19.2 Home Network Realm/Domain (text form)
* \param out[out] caller-provided output buffer, at least 33 bytes long
* \param plmn[in] Osmocom representation of PLMN ID (MCC + MNC)

View File

@ -410,6 +410,7 @@ osmo_lai_cmp;
osmo_lai_name;
osmo_lai_name_buf;
osmo_lai_name_c;
osmo_rai_cmp;
osmo_rai_name;
osmo_rai_name_buf;
osmo_rai_name_c;
@ -421,6 +422,7 @@ osmo_cgi_name;
osmo_cgi_name_buf;
osmo_cgi_name_c;
osmo_cgi_name2;
osmo_cgi_ps_cmp;
osmo_cgi_ps_name;
osmo_cgi_ps_name_buf;
osmo_cgi_ps_name_c;