Change in libosmocore[master]: LCLS: add GCR comparison helper

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

Max gerrit-no-reply at lists.osmocom.org
Wed Jan 9 12:52:29 UTC 2019


Max has uploaded this change for review. ( https://gerrit.osmocom.org/12493


Change subject: LCLS: add GCR comparison helper
......................................................................

LCLS: add GCR comparison helper

Change-Id: I9e3b5560a058b976638d03cb819415d237ae9984
---
M include/osmocom/gsm/gsm29205.h
M src/gsm/gsm29205.c
M src/gsm/libosmogsm.map
M tests/gsm0808/gsm0808_test.c
4 files changed, 31 insertions(+), 11 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/93/12493/1

diff --git a/include/osmocom/gsm/gsm29205.h b/include/osmocom/gsm/gsm29205.h
index 3c47edf..e3ac1b8 100644
--- a/include/osmocom/gsm/gsm29205.h
+++ b/include/osmocom/gsm/gsm29205.h
@@ -39,4 +39,5 @@
 
 uint8_t osmo_enc_gcr(struct msgb *msg, const struct osmo_gcr_parsed *g);
 int osmo_dec_gcr(struct osmo_gcr_parsed *gcr, const uint8_t *elem, uint8_t len);
+bool osmo_gcr_eq(const struct osmo_gcr_parsed *gcr1, const struct osmo_gcr_parsed *gcr2);
 char *osmo_gcr_dump(const struct osmo_gcr_parsed *gcr);
diff --git a/src/gsm/gsm29205.c b/src/gsm/gsm29205.c
index 17308da..c31a944 100644
--- a/src/gsm/gsm29205.c
+++ b/src/gsm/gsm29205.c
@@ -95,6 +95,27 @@
 	return parsed + 5;
 }
 
+/*! Compare two GCR structs.
+ *  \param[in] gcr1 pointer to the GCR struct
+ *  \param[in] gcr2 pointer to the GCR struct
+ *  \returns true if GCRs are equal, false otherwise */
+bool osmo_gcr_eq(const struct osmo_gcr_parsed *gcr1, const struct osmo_gcr_parsed *gcr2)
+{
+	if (gcr1->net_len != gcr2->net_len)
+		return false;
+
+	if (gcr1->node != gcr2->node)
+		return false;
+
+	if (memcmp(gcr1->cr, gcr2->cr, 5) != 0)
+		return false;
+
+	if (memcmp(gcr1->net, gcr2->net, gcr2->net_len) != 0)
+		return false;
+
+	return true;
+}
+
 /*! Dump GCR struct into string for printing.
  *  \param[in] gcr pointer to the struct to print
  *  \returns string representation of GCR or NULL on error */
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index 7b5f2e9..3d3b74e 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -241,6 +241,7 @@
 
 osmo_enc_gcr;
 osmo_dec_gcr;
+osmo_gcr_eq;
 osmo_gcr_dump;
 osmo_lcls_dump;
 
diff --git a/tests/gsm0808/gsm0808_test.c b/tests/gsm0808/gsm0808_test.c
index 628bff9..425af64 100644
--- a/tests/gsm0808/gsm0808_test.c
+++ b/tests/gsm0808/gsm0808_test.c
@@ -722,23 +722,20 @@
 		abort();
 	}
 
-	if (lcls_out->gcr->net_len != g.net_len) {
-		printf("Network ID length parsed wrong: %u != %u\n", lcls_out->gcr->net_len, g.net_len);
+	if (lcls_out->config != lcls_in.config) {
+		printf("LCLS Config parsed wrong: %s != %s\n",
+		       gsm0808_lcls_config_name(lcls_out->config), gsm0808_lcls_config_name(lcls_in.config));
 		abort();
 	}
 
-	if (lcls_out->gcr->node != g.node) {
-		printf("Node ID parsed wrong: 0x%X != 0x%X\n", lcls_out->gcr->node, g.node);
+	if (lcls_out->control != lcls_in.control) {
+		printf("LCLS Control parsed wrong: %s != %s\n",
+		       gsm0808_lcls_control_name(lcls_out->control), gsm0808_lcls_control_name(lcls_in.control));
 		abort();
 	}
 
-	if (memcmp(lcls_out->gcr->net, g.net, g.net_len) != 0) {
-		printf("Network ID parsed wrong: %s\n", osmo_hexdump(lcls_out->gcr->net, lcls_out->gcr->net_len));
-		abort();
-	}
-
-	if (memcmp(lcls_out->gcr->cr, g.cr, 5) != 0) {
-		printf("Call ref. ID parsed wrong: %s\n", osmo_hexdump(lcls_out->gcr->cr, 5));
+	if (!osmo_gcr_eq(lcls_out->gcr, lcls_in.gcr)) {
+		printf("GCR parsed wrong:\n\t%s\n\t%s\n", osmo_gcr_dump(lcls_out->gcr), osmo_gcr_dump(lcls_in.gcr));
 		abort();
 	}
 

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9e3b5560a058b976638d03cb819415d237ae9984
Gerrit-Change-Number: 12493
Gerrit-PatchSet: 1
Gerrit-Owner: Max <msuraev at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190109/bdab8ebb/attachment.htm>


More information about the gerrit-log mailing list