Change in libosmocore[master]: gsm48: add compare function for struct gprs_ra_id

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

dexter gerrit-no-reply at lists.osmocom.org
Wed Feb 3 21:14:01 UTC 2021


dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/22669 )


Change subject: gsm48: add compare function for struct gprs_ra_id
......................................................................

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
---
M include/osmocom/gsm/gsm48.h
M src/gsm/gsm48.c
M src/gsm/libosmogsm.map
3 files changed, 21 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/69/22669/1

diff --git a/include/osmocom/gsm/gsm48.h b/include/osmocom/gsm/gsm48.h
index f772f4a..4f6c0dc 100644
--- a/include/osmocom/gsm/gsm48.h
+++ b/include/osmocom/gsm/gsm48.h
@@ -104,6 +104,7 @@
 void gsm48_parse_ra(struct gprs_ra_id *raid, const uint8_t *buf);
 void gsm48_encode_ra(struct gsm48_ra_id *out, const struct gprs_ra_id *raid);
 int gsm48_construct_ra(uint8_t *buf, const struct gprs_ra_id *raid) OSMO_DEPRECATED("Use gsm48_encode_ra() instead");
+int gsm48_compare_ra(const struct gprs_ra_id *raid1, const struct gprs_ra_id *raid2);
 
 int gsm48_number_of_paging_subchannels(struct gsm48_control_channel_descr *chan_desc);
 
diff --git a/src/gsm/gsm48.c b/src/gsm/gsm48.c
index c497c74..97f031a 100644
--- a/src/gsm/gsm48.c
+++ b/src/gsm/gsm48.c
@@ -1298,6 +1298,25 @@
 	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 0 if raid1 and raid2 match, -1 otherwise. */
+int gsm48_compare_ra(const struct gprs_ra_id *raid1, const struct gprs_ra_id *raid2)
+{
+	if (raid1->mcc != raid2->mcc)
+		return -1;
+	if (raid1->mnc != raid2->mnc)
+		return -1;
+	if (raid1->mnc_3_digits != raid2->mnc_3_digits)
+		return -1;
+	if (raid1->lac != raid2->lac)
+		return -1;
+	if (raid1->rac != raid2->rac)
+		return -1;
+	return 0;
+}
+
 /*! 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 584d761..426e281 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -326,6 +326,7 @@
 gsm48_rr_msg_name;
 gsm48_cc_state_name;
 gsm48_construct_ra;
+gsm48_compare_ra;
 gsm48_encode_ra;
 gsm48_hdr_gmm_cipherable;
 gsm48_decode_bcd_number;

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/22669
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I4d7558c04d9d01761516526086be5104bb2eeada
Gerrit-Change-Number: 22669
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210203/151ad6c5/attachment.htm>


More information about the gerrit-log mailing list