From 3c21004bfba30054bf0069c5b4bc27447453178d Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Fri, 16 Nov 2018 00:18:08 +0100 Subject: add/clean big-endian packed structs (struct_endianess.py) Change-Id: If408153af472a41dcea8d6f6aedd22adb16963d5 --- include/osmocom/netif/amr.h | 15 +++++---------- include/osmocom/netif/osmux.h | 19 ++++++++----------- include/osmocom/netif/rtp.h | 9 +++------ 3 files changed, 16 insertions(+), 27 deletions(-) diff --git a/include/osmocom/netif/amr.h b/include/osmocom/netif/amr.h index f32f044..cae82cb 100644 --- a/include/osmocom/netif/amr.h +++ b/include/osmocom/netif/amr.h @@ -43,16 +43,7 @@ */ struct amr_hdr { -#if OSMO_IS_BIG_ENDIAN - /* Payload Header */ - uint8_t cmr:4, /* Codec Mode Request */ - pad1:4; - /* Table of Contents */ - uint8_t f:1, /* followed by another speech frame? */ - ft:4, /* coding mode */ - q:1, /* OK (not damaged) at origin? */ - pad2:2; -#elif OSMO_IS_LITTLE_ENDIAN +#if OSMO_IS_LITTLE_ENDIAN /* Payload Header */ uint8_t pad1:4, cmr:4; @@ -61,6 +52,10 @@ struct amr_hdr { q:1, /* OK (not damaged) at origin? */ ft:4, /* coding mode */ f:1; /* followed by another speech frame? */ +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t cmr:4, pad1:4; + uint8_t f:1, ft:4, q:1, pad2:2; #endif } __attribute__((packed)); diff --git a/include/osmocom/netif/osmux.h b/include/osmocom/netif/osmux.h index dfed66a..86d425a 100644 --- a/include/osmocom/netif/osmux.h +++ b/include/osmocom/netif/osmux.h @@ -30,28 +30,25 @@ #define OSMUX_FT_DUMMY 2 struct osmux_hdr { -#if OSMO_IS_BIG_ENDIAN - uint8_t rtp_m:1, - ft:2, - ctr:3, - amr_f:1, - amr_q:1; -#elif OSMO_IS_LITTLE_ENDIAN +#if OSMO_IS_LITTLE_ENDIAN uint8_t amr_q:1, amr_f:1, ctr:3, ft:2, rtp_m:1; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t rtp_m:1, ft:2, ctr:3, amr_f:1, amr_q:1; #endif uint8_t seq; #define OSMUX_CID_MAX 255 /* determined by circuit_id */ uint8_t circuit_id; -#if OSMO_IS_BIG_ENDIAN - uint8_t amr_ft:4, - amr_cmr:4; -#elif OSMO_IS_LITTLE_ENDIAN +#if OSMO_IS_LITTLE_ENDIAN uint8_t amr_cmr:4, amr_ft:4; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t amr_ft:4, amr_cmr:4; #endif } __attribute__((packed)); diff --git a/include/osmocom/netif/rtp.h b/include/osmocom/netif/rtp.h index c01df41..4e40745 100644 --- a/include/osmocom/netif/rtp.h +++ b/include/osmocom/netif/rtp.h @@ -13,12 +13,9 @@ struct rtp_hdr { uint8_t payload_type:7, marker:1; #elif OSMO_IS_BIG_ENDIAN - uint8_t version:2, - padding:1, - extension:1, - csrc_count:4; - uint8_t marker:1, - payload_type:7; +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t version:2, padding:1, extension:1, csrc_count:4; + uint8_t marker:1, payload_type:7; #endif uint16_t sequence; uint32_t timestamp; -- cgit v1.2.3