Change in osmo-sgsn[master]: sndcp: Fix struct bit fields on big endian

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

laforge gerrit-no-reply at lists.osmocom.org
Thu Feb 4 14:04:41 UTC 2021


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-sgsn/+/22685 )

Change subject: sndcp: Fix struct bit fields on big endian
......................................................................

sndcp: Fix struct bit fields on big endian

Change-Id: I30014bf84e7a69fa3d85d542d03e41d56506beb7
---
M src/sgsn/gprs_sndcp.c
1 file changed, 17 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/src/sgsn/gprs_sndcp.c b/src/sgsn/gprs_sndcp.c
index 19d8712..b237bf9 100644
--- a/src/sgsn/gprs_sndcp.c
+++ b/src/sgsn/gprs_sndcp.c
@@ -28,6 +28,7 @@
 #include <osmocom/core/linuxlist.h>
 #include <osmocom/core/timer.h>
 #include <osmocom/core/talloc.h>
+#include <osmocom/core/endian.h>
 #include <osmocom/gprs/gprs_bssgp.h>
 
 #include <osmocom/sgsn/debug.h>
@@ -164,27 +165,43 @@
 
 /* Chapter 7.2: SN-PDU Formats */
 struct sndcp_common_hdr {
+#if OSMO_IS_LITTLE_ENDIAN
 	/* octet 1 */
 	uint8_t nsapi:4;
 	uint8_t more:1;
 	uint8_t type:1;
 	uint8_t first:1;
 	uint8_t spare:1;
+#elif OSMO_IS_BIG_ENDIAN
+/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
+	uint8_t spare:1, first:1, type:1, more:1, nsapi:4;
+#endif
 } __attribute__((packed));
 
 /* PCOMP / DCOMP only exist in first fragment */
 struct sndcp_comp_hdr {
+#if OSMO_IS_LITTLE_ENDIAN
 	/* octet 2 */
 	uint8_t pcomp:4;
 	uint8_t dcomp:4;
+#elif OSMO_IS_BIG_ENDIAN
+/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
+	uint8_t dcomp:4, pcomp:4;
+#endif
 } __attribute__((packed));
 
 struct sndcp_udata_hdr {
+#if OSMO_IS_LITTLE_ENDIAN
 	/* octet 3 */
 	uint8_t npdu_high:4;
 	uint8_t seg_nr:4;
 	/* octet 4 */
 	uint8_t npdu_low;
+#elif OSMO_IS_BIG_ENDIAN
+/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
+	uint8_t seg_nr:4, npdu_high:4;
+	uint8_t npdu_low;
+#endif
 } __attribute__((packed));
 
 

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

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-Change-Id: I30014bf84e7a69fa3d85d542d03e41d56506beb7
Gerrit-Change-Number: 22685
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210204/b02d5d58/attachment.htm>


More information about the gerrit-log mailing list