lynxis lazus has uploaded this change for review.

View Change

gprs/gsm23003: add osmo_gummei_cmp

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

git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/68/38668/1
diff --git a/include/osmocom/gsm/gsm23003.h b/include/osmocom/gsm/gsm23003.h
index 4070581..fb35d51 100644
--- a/include/osmocom/gsm/gsm23003.h
+++ b/include/osmocom/gsm/gsm23003.h
@@ -167,6 +167,7 @@
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_gummei_cmp(const struct osmo_gummei *a, const struct osmo_gummei *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);
diff --git a/src/gsm/gsm23003.c b/src/gsm/gsm23003.c
index 1eed41f..b7c6228 100644
--- a/src/gsm/gsm23003.c
+++ b/src/gsm/gsm23003.c
@@ -656,6 +656,30 @@
return 0;
}

+/* Compare two GUMMEI
+ * The order of comparison is MCC, MNC, MME GroupId, MME Code.
+ * \param a[in] "Left" side GUMMEI.
+ * \param b[in] "Right" side GUMMEI.
+ * \returns 0 if the GUMMEI are equal, -1 if a < b, 1 if a > b. */
+int osmo_gummei_cmp(const struct osmo_gummei *a, const struct osmo_gummei *b)
+{
+ int rc = osmo_plmn_cmp(&a->plmn, &b->plmn);
+ if (rc)
+ return rc;
+
+ if (a->mme.code < b->mme.code)
+ return -1;
+ if (a->mme.code > b->mme.code)
+ return 1;
+
+ if (a->mme.group_id < b->mme.group_id)
+ return -1;
+ if (a->mme.group_id > b->mme.group_id)
+ 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 3bc8309..6796c9a 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -502,6 +502,7 @@
osmo_gummei_name;
osmo_gummei_name_buf;
osmo_gummei_name_c;
+osmo_gummei_cmp;
osmo_mnc_from_str;
osmo_mnc_cmp;
osmo_plmn_cmp;

To view, visit change 38668. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I85aab7fcb18f69cca1ce51c86291d1b9e4793a28
Gerrit-Change-Number: 38668
Gerrit-PatchSet: 1
Gerrit-Owner: lynxis lazus <lynxis@fe80.eu>