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/.

daniel gerrit-no-reply at lists.osmocom.org
Thu Feb 4 16:07:54 UTC 2021


daniel has submitted this change. ( 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(-)

Approvals:
  Jenkins Builder: Verified
  daniel: Looks good to me, but someone else must approve
  pespin: Looks good to me, approved



diff --git a/include/osmocom/gsm/gsm48.h b/include/osmocom/gsm/gsm48.h
index f772f4a..fdaa572 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");
+bool gsm48_ra_equal(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..e12fda5 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 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 584d761..efa23e6 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_ra_equal;
 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: 3
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210204/113c2e5b/attachment.htm>


More information about the gerrit-log mailing list