diff options
author | Neels Hofmeyr <neels@hofmeyr.de> | 2018-11-16 00:33:48 +0100 |
---|---|---|
committer | Neels Hofmeyr <neels@hofmeyr.de> | 2018-11-26 17:36:58 +0100 |
commit | e93fe1ba65dceaa662da29654a119011d46c71d5 (patch) | |
tree | a85161f1bc3ae2cda4c4844772bcbae7f2e8717f /src | |
parent | 926d54dc7e7e84abfe994fd7f625c943f250f9da (diff) |
add/clean big-endian packed structs (struct_endianess.py)neels/big_endian
Change-Id: I97ce5e758b47ec5cfc53c22362b71070be15aff3
Diffstat (limited to 'src')
-rw-r--r-- | src/gprs/gprs_sndcp.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/gprs/gprs_sndcp.c b/src/gprs/gprs_sndcp.c index f0239cb66..1eeafe2b1 100644 --- a/src/gprs/gprs_sndcp.c +++ b/src/gprs/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> @@ -163,27 +164,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)); |