diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2021-02-04 12:49:40 +0100 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2021-02-04 12:49:40 +0100 |
commit | 4be5ab37071d8102c133d65546b76117d1da18f1 (patch) | |
tree | 26aaea48b0a798c616c3b219d5a28aa0fb710884 | |
parent | c999c223aefd927ac77ba973e5bb2c748ca46e95 (diff) |
sndcp: Fix struct bit fields on big endian
Change-Id: I30014bf84e7a69fa3d85d542d03e41d56506beb7
-rw-r--r-- | src/sgsn/gprs_sndcp.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/sgsn/gprs_sndcp.c b/src/sgsn/gprs_sndcp.c index 19d87121e..b237bf9ad 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 @@ static void debug_ip_packet(uint8_t *data, int len, int dir, char *info) /* 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)); |