aboutsummaryrefslogtreecommitdiffstats
path: root/src/gsm
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2021-01-22 17:44:34 +0100
committerPau Espin Pedrol <pespin@sysmocom.de>2021-01-22 20:32:45 +0100
commitd426ba6730b65e4ac6ca809c00e91556ba907806 (patch)
treec4db04f85483ac69ba854ff8135507b4a5462b7d /src/gsm
parentcc885fb0b6051e5a4ee65d84ebfe3035bfc7e942 (diff)
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
Diffstat (limited to 'src/gsm')
-rw-r--r--src/gsm/gsm23003.c34
-rw-r--r--src/gsm/libosmogsm.map2
2 files changed, 36 insertions, 0 deletions
diff --git a/src/gsm/gsm23003.c b/src/gsm/gsm23003.c
index ae498fa8..c2b3de86 100644
--- a/src/gsm/gsm23003.c
+++ b/src/gsm/gsm23003.c
@@ -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)
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index de9a595c..c314c207 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -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;