lynxis lazus has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/38763?usp=email )
Change subject: gprs/gsm23003: add osmo_mme_id_cmp & osmo_gummei_cmp ......................................................................
gprs/gsm23003: add osmo_mme_id_cmp & osmo_gummei_cmp
In order to support mobility between GERAN and EUTRAN, the SGSN need to route a SGSN Context Request towards a MME identified by the GUMMEI.
Change-Id: I9a6769b1bff16450046181b31a8762ff49955ae4 --- M include/osmocom/gsm/gsm23003.h M src/gsm/gsm23003.c M src/gsm/libosmogsm.map 3 files changed, 38 insertions(+), 0 deletions(-)
Approvals: fixeria: Looks good to me, approved pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified
diff --git a/include/osmocom/gsm/gsm23003.h b/include/osmocom/gsm/gsm23003.h index 4070581..8b9bcfb 100644 --- a/include/osmocom/gsm/gsm23003.h +++ b/include/osmocom/gsm/gsm23003.h @@ -167,6 +167,8 @@ 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_mme_id_cmp(const struct osmo_mme_id *a, const struct osmo_mme_id *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..0f4c301 100644 --- a/src/gsm/gsm23003.c +++ b/src/gsm/gsm23003.c @@ -656,6 +656,40 @@ return 0; }
+/* Compare two MME Ids + * The order of comparison is MME GroupId, MME Code. + * \param a[in] "Left" side MME Id. + * \param b[in] "Right" side MME Id. + * \returns 0 if the MME Ids are equal, -1 if a < b, 1 if a > b. */ +int osmo_mme_id_cmp(const struct osmo_mme_id *a, const struct osmo_mme_id *b) +{ + if (a->group_id < b->group_id) + return -1; + if (a->group_id > b->group_id) + return 1; + + if (a->code < b->code) + return -1; + if (a->code > b->code) + return 1; + + 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; + + return osmo_mme_id_cmp(&a->mme, &b->mme); +} + /*! 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..8d17ce3 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -502,6 +502,8 @@ osmo_gummei_name; osmo_gummei_name_buf; osmo_gummei_name_c; +osmo_gummei_cmp; +osmo_mme_id_cmp; osmo_mnc_from_str; osmo_mnc_cmp; osmo_plmn_cmp;