aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2021-02-03 22:11:46 +0100
committerPhilipp Maier <pmaier@sysmocom.de>2021-02-04 15:17:41 +0100
commitd11a5d5b9a636ce5e16d688c5303eeac8be45e8c (patch)
treeddc18a63ea58bf854983f07ff6f9c22ca0081a1c /src
parent700822b305850686528b0e83cb652b5a52b8600a (diff)
gsm48: add compare function for struct gprs_ra_id
Comparing struct gprs_ra_id using memcmp can be error prone, so lets add a compare function to compare two struct gprs_ra_id values reliably. Change-Id: I4d7558c04d9d01761516526086be5104bb2eeada Related: SYS#5103
Diffstat (limited to 'src')
-rw-r--r--src/gsm/gsm48.c19
-rw-r--r--src/gsm/libosmogsm.map1
2 files changed, 20 insertions, 0 deletions
diff --git a/src/gsm/gsm48.c b/src/gsm/gsm48.c
index c497c745..e12fda56 100644
--- a/src/gsm/gsm48.c
+++ b/src/gsm/gsm48.c
@@ -1298,6 +1298,25 @@ int gsm48_construct_ra(uint8_t *buf, const struct gprs_ra_id *raid)
return 6;
}
+/*! Compare a TS 04.08 Routing Area Identifier
+ * \param[in] raid1 first Routing Area ID to compare.
+ * \param[in] raid2 second Routing Area ID to compare.
+ * \returns true if raid1 and raid2 match, false otherwise. */
+bool gsm48_ra_equal(const struct gprs_ra_id *raid1, const struct gprs_ra_id *raid2)
+{
+ if (raid1->mcc != raid2->mcc)
+ return false;
+ if (raid1->mnc != raid2->mnc)
+ return false;
+ if (raid1->mnc_3_digits != raid2->mnc_3_digits)
+ return false;
+ if (raid1->lac != raid2->lac)
+ return false;
+ if (raid1->rac != raid2->rac)
+ return false;
+ return true;
+}
+
/*! Determine number of paging sub-channels
* \param[in] chan_desc Control Channel Description
* \returns number of paging sub-channels
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index 584d761d..efa23e65 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -326,6 +326,7 @@ osmo_gsm48_rest_octets_si4_decode;
gsm48_rr_msg_name;
gsm48_cc_state_name;
gsm48_construct_ra;
+gsm48_ra_equal;
gsm48_encode_ra;
gsm48_hdr_gmm_cipherable;
gsm48_decode_bcd_number;