Change in simtrace2[master]: sniff: ensure the checksum error flag is also printed

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

Harald Welte gerrit-no-reply at lists.osmocom.org
Sat Jul 28 21:23:20 UTC 2018


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/10211 )

Change subject: sniff: ensure the checksum error flag is also printed
......................................................................

sniff: ensure the checksum error flag is also printed

the firmware now also use a generic value_string array (as does the
host application)

Change-Id: I861bd8b52e8f2f2a4786bbe1cc834917119dc394
---
M firmware/libcommon/source/sniffer.c
M host/simtrace2-sniff.c
2 files changed, 37 insertions(+), 18 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/firmware/libcommon/source/sniffer.c b/firmware/libcommon/source/sniffer.c
index e800216..5cf96fd 100644
--- a/firmware/libcommon/source/sniffer.c
+++ b/firmware/libcommon/source/sniffer.c
@@ -302,6 +302,38 @@
 	//TRACE_INFO("Changed to ISO 7816-3 state %u\n\r", iso_state); /* don't print since this is function is also called by ISRs */
 }
 
+const struct value_string data_flags[] = {
+	{
+		.value = SNIFF_DATA_FLAG_ERROR_INCOMPLETE,
+		.str = "incomplete",
+	},
+	{
+		.value = SNIFF_DATA_FLAG_ERROR_MALFORMED,
+		.str = "malformed",
+	},
+	{
+		.value = SNIFF_DATA_FLAG_ERROR_CHECKSUM,
+		.str = "checksum error",
+	},
+	{
+		.value = 0,
+		.str = NULL,
+	},
+};
+
+static void print_flags(const struct value_string* flag_meanings, uint32_t nb_flags, uint32_t flags) {
+	uint32_t i;
+	for (i = 0; i < nb_flags; i++) {
+		if (flags & flag_meanings[i].value) {
+			printf(flag_meanings[i].str);
+			flags &= ~flag_meanings[i].value;
+			if (flags) {
+				printf(", ");
+			}
+		}
+	}
+}
+
 static void usb_send_data(enum simtrace_msg_type_sniff type, const uint8_t* data, uint16_t length, uint32_t flags)
 {
 	/* Sanity check */
@@ -329,20 +361,7 @@
 	}
 	if (flags) {
 		printf(" (");
-		if (flags & SNIFF_DATA_FLAG_ERROR_INCOMPLETE) {
-			printf("incomplete");
-			flags &= ~SNIFF_DATA_FLAG_ERROR_INCOMPLETE;
-			if (flags) {
-				printf(", ");
-			}
-		}
-		if (flags & SNIFF_DATA_FLAG_ERROR_MALFORMED) {
-			printf("malformed");
-			flags &= ~SNIFF_DATA_FLAG_ERROR_MALFORMED;
-			if (flags) {
-				printf(", ");
-			}
-		}
+		print_flags(data_flags, ARRAY_SIZE(data_flags), flags);
 		putchar(')');
 	}
 	printf(": ");
diff --git a/host/simtrace2-sniff.c b/host/simtrace2-sniff.c
index aeacc6b..368ae60 100644
--- a/host/simtrace2-sniff.c
+++ b/host/simtrace2-sniff.c
@@ -132,13 +132,13 @@
 		.str = "malformed",
 	},
 	{
-		.value = 0,
-		.str = NULL,
-	},
-	{
 		.value = SNIFF_DATA_FLAG_ERROR_CHECKSUM,
 		.str = "checksum error",
 	},
+	{
+		.value = 0,
+		.str = NULL,
+	},
 };
 
 static void print_flags(const struct value_string* flag_meanings, uint32_t nb_flags, uint32_t flags) {

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I861bd8b52e8f2f2a4786bbe1cc834917119dc394
Gerrit-Change-Number: 10211
Gerrit-PatchSet: 2
Gerrit-Owner: Kévin Redon <kredon at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180728/862c26c6/attachment.htm>


More information about the gerrit-log mailing list