diff options
-rw-r--r-- | include/osmocom/gprs/protocol/gsm_04_60.h | 105 | ||||
-rw-r--r-- | include/osmocom/gsm/protocol/gsm_03_41.h | 40 | ||||
-rw-r--r-- | include/osmocom/gsm/protocol/gsm_04_08.h | 389 | ||||
-rw-r--r-- | include/osmocom/gsm/protocol/gsm_04_08_gprs.h | 31 | ||||
-rw-r--r-- | include/osmocom/gsm/protocol/gsm_04_12.h | 14 | ||||
-rw-r--r-- | include/osmocom/gsm/protocol/gsm_04_14.h | 41 | ||||
-rw-r--r-- | include/osmocom/gsm/protocol/gsm_08_58.h | 53 | ||||
-rw-r--r-- | include/osmocom/gsm/protocol/gsm_44_318.h | 18 | ||||
-rw-r--r-- | tests/endian/endian_test.c | 1 |
9 files changed, 647 insertions, 45 deletions
diff --git a/include/osmocom/gprs/protocol/gsm_04_60.h b/include/osmocom/gprs/protocol/gsm_04_60.h index 96e9ab78..5d5fca9a 100644 --- a/include/osmocom/gprs/protocol/gsm_04_60.h +++ b/include/osmocom/gprs/protocol/gsm_04_60.h @@ -7,10 +7,12 @@ #pragma once #include <stdint.h> +#include <osmocom/core/endian.h> #if OSMO_IS_LITTLE_ENDIAN == 1 /* TS 04.60 10.3a.4.1.1 */ struct gprs_rlc_ul_header_egprs_1 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t r:1, si:1, cv:4, @@ -26,10 +28,20 @@ struct gprs_rlc_ul_header_egprs_1 { spare_hi:1; uint8_t spare_lo:6, dummy:2; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t tfi_hi:2, cv:4, si:1, r:1; + uint8_t bsn1_hi:5, tfi_lo:3; + uint8_t bsn2_hi:2, bsn1_lo:6; + uint8_t bsn2_lo:8; + uint8_t spare_hi:1, pi:1, rsb:1, cps:5; + uint8_t dummy:2, spare_lo:6; +#endif } __attribute__ ((packed)); /* TS 04.60 10.3a.4.2.1 */ struct gprs_rlc_ul_header_egprs_2 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t r:1, si:1, cv:4, @@ -44,10 +56,19 @@ struct gprs_rlc_ul_header_egprs_2 { spare_hi:5; uint8_t spare_lo:5, dummy:3; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t tfi_hi:2, cv:4, si:1, r:1; + uint8_t bsn1_hi:5, tfi_lo:3; + uint8_t cps_hi:2, bsn1_lo:6; + uint8_t spare_hi:5, pi:1, rsb:1, cps_lo:1; + uint8_t dummy:3, spare_lo:5; +#endif } __attribute__ ((packed)); /* TS 04.60 10.3a.4.3.1 */ struct gprs_rlc_ul_header_egprs_3 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t r:1, si:1, cv:4, @@ -62,9 +83,17 @@ struct gprs_rlc_ul_header_egprs_3 { pi:1, spare:1, dummy:1; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t tfi_hi:2, cv:4, si:1, r:1; + uint8_t bsn1_hi:5, tfi_lo:3; + uint8_t cps_hi:2, bsn1_lo:6; + uint8_t dummy:1, spare:1, pi:1, rsb:1, spb:2, cps_lo:2; +#endif } __attribute__ ((packed)); struct gprs_rlc_dl_header_egprs_1 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t usf:3, es_p:2, rrbp:2, @@ -77,9 +106,18 @@ struct gprs_rlc_dl_header_egprs_1 { bsn2_hi:7; uint8_t bsn2_lo:3, cps:5; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t tfi_hi:1, rrbp:2, es_p:2, usf:3; + uint8_t bsn1_hi:2, pr:2, tfi_lo:4; + uint8_t bsn1_mid:8; + uint8_t bsn2_hi:7, bsn1_lo:1; + uint8_t cps:5, bsn2_lo:3; +#endif } __attribute__ ((packed)); struct gprs_rlc_dl_header_egprs_2 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t usf:3, es_p:2, rrbp:2, @@ -91,9 +129,17 @@ struct gprs_rlc_dl_header_egprs_2 { uint8_t bsn1_lo:1, cps:3, dummy:4; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t tfi_hi:1, rrbp:2, es_p:2, usf:3; + uint8_t bsn1_hi:2, pr:2, tfi_lo:4; + uint8_t bsn1_mid:8; + uint8_t dummy:4, cps:3, bsn1_lo:1; +#endif } __attribute__ ((packed)); struct gprs_rlc_dl_header_egprs_3 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t usf:3, es_p:2, rrbp:2, @@ -106,10 +152,18 @@ struct gprs_rlc_dl_header_egprs_3 { cps:4, spb:2, dummy:1; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t tfi_hi:1, rrbp:2, es_p:2, usf:3; + uint8_t bsn1_hi:2, pr:2, tfi_lo:4; + uint8_t bsn1_mid:8; + uint8_t dummy:1, spb:2, cps:4, bsn1_lo:1; +#endif } __attribute__ ((packed)); #else /* TS 04.60 10.3a.4.1.1 */ struct gprs_rlc_ul_header_egprs_1 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t tfi_hi:2, cv:4, si:1, @@ -125,10 +179,20 @@ struct gprs_rlc_ul_header_egprs_1 { cps:5; uint8_t dummy:2, spare_lo:6; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t r:1, si:1, cv:4, tfi_hi:2; + uint8_t tfi_lo:3, bsn1_hi:5; + uint8_t bsn1_lo:6, bsn2_hi:2; + uint8_t bsn2_lo:8; + uint8_t cps:5, rsb:1, pi:1, spare_hi:1; + uint8_t spare_lo:6, dummy:2; +#endif } __attribute__ ((packed)); /* TS 04.60 10.3a.4.2.1 */ struct gprs_rlc_ul_header_egprs_2 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t tfi_hi:2, cv:4, si:1, @@ -143,10 +207,19 @@ struct gprs_rlc_ul_header_egprs_2 { cps_lo:1; uint8_t dummy:3, spare_lo:5; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t r:1, si:1, cv:4, tfi_hi:2; + uint8_t tfi_lo:3, bsn1_hi:5; + uint8_t bsn1_lo:6, cps_hi:2; + uint8_t cps_lo:1, rsb:1, pi:1, spare_hi:5; + uint8_t spare_lo:5, dummy:3; +#endif } __attribute__ ((packed)); /* TS 04.60 10.3a.4.3.1 */ struct gprs_rlc_ul_header_egprs_3 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t tfi_hi:2, cv:4, si:1, @@ -161,9 +234,17 @@ struct gprs_rlc_ul_header_egprs_3 { rsb:1, spb:2, cps_lo:2; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t r:1, si:1, cv:4, tfi_hi:2; + uint8_t tfi_lo:3, bsn1_hi:5; + uint8_t bsn1_lo:6, cps_hi:2; + uint8_t cps_lo:2, spb:2, rsb:1, pi:1, spare:1, dummy:1; +#endif } __attribute__ ((packed)); struct gprs_rlc_dl_header_egprs_1 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t tfi_hi:1, rrbp:2, es_p:2, @@ -176,9 +257,18 @@ struct gprs_rlc_dl_header_egprs_1 { bsn1_lo:1; uint8_t cps:5, bsn2_lo:3; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t usf:3, es_p:2, rrbp:2, tfi_hi:1; + uint8_t tfi_lo:4, pr:2, bsn1_hi:2; + uint8_t bsn1_mid:8; + uint8_t bsn1_lo:1, bsn2_hi:7; + uint8_t bsn2_lo:3, cps:5; +#endif } __attribute__ ((packed)); struct gprs_rlc_dl_header_egprs_2 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t tfi_hi:1, rrbp:2, es_p:2, @@ -190,9 +280,17 @@ struct gprs_rlc_dl_header_egprs_2 { uint8_t dummy:4, cps:3, bsn1_lo:1; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t usf:3, es_p:2, rrbp:2, tfi_hi:1; + uint8_t tfi_lo:4, pr:2, bsn1_hi:2; + uint8_t bsn1_mid:8; + uint8_t bsn1_lo:1, cps:3, dummy:4; +#endif } __attribute__ ((packed)); struct gprs_rlc_dl_header_egprs_3 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t tfi_hi:1, rrbp:2, es_p:2, @@ -205,5 +303,12 @@ struct gprs_rlc_dl_header_egprs_3 { spb:2, cps:4, bsn1_lo:1; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t usf:3, es_p:2, rrbp:2, tfi_hi:1; + uint8_t tfi_lo:4, pr:2, bsn1_hi:2; + uint8_t bsn1_mid:8; + uint8_t bsn1_lo:1, cps:4, spb:2, dummy:1; +#endif } __attribute__ ((packed)); #endif diff --git a/include/osmocom/gsm/protocol/gsm_03_41.h b/include/osmocom/gsm/protocol/gsm_03_41.h index 2e0ad69f..1b399aee 100644 --- a/include/osmocom/gsm/protocol/gsm_03_41.h +++ b/include/osmocom/gsm/protocol/gsm_03_41.h @@ -19,35 +19,34 @@ /* Chapter 9.3.2 */ struct gsm341_ms_message { struct { -#if OSMO_IS_LITTLE_ENDIAN == 1 +#if OSMO_IS_LITTLE_ENDIAN uint8_t code_hi:6; uint8_t gs:2; uint8_t update:4; uint8_t code_lo:4; -#else - uint8_t gs:2; - uint8_t code_hi:6; - uint8_t code_lo:4; - uint8_t update:4; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t gs:2, code_hi:6; + uint8_t code_lo:4, update:4; #endif } serial; uint16_t msg_id; struct { -#if OSMO_IS_LITTLE_ENDIAN == 1 +#if OSMO_IS_LITTLE_ENDIAN uint8_t language:4; uint8_t group:4; -#else - uint8_t group:4; - uint8_t language:4; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t group:4, language:4; #endif } dcs; struct { -#if OSMO_IS_LITTLE_ENDIAN == 1 +#if OSMO_IS_LITTLE_ENDIAN uint8_t total:4; uint8_t current:4; -#else - uint8_t current:4; - uint8_t total:4; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t current:4, total:4; #endif } page; uint8_t data[0]; @@ -56,20 +55,17 @@ struct gsm341_ms_message { /* Chapter 9.4.1.3 */ struct gsm341_etws_message { struct { -#if OSMO_IS_LITTLE_ENDIAN == 1 +#if OSMO_IS_LITTLE_ENDIAN uint8_t code_hi:4; uint8_t popup:1; uint8_t alert:1; uint8_t gs:2; uint8_t update:4; uint8_t code_lo:4; -#else - uint8_t gs:2; - uint8_t alert:1; - uint8_t popup:1; - uint8_t code_hi:4; - uint8_t code_lo:4; - uint8_t update:4; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t gs:2, alert:1, popup:1, code_hi:4; + uint8_t code_lo:4, update:4; #endif } serial; uint16_t msg_id; diff --git a/include/osmocom/gsm/protocol/gsm_04_08.h b/include/osmocom/gsm/protocol/gsm_04_08.h index e218295c..a97225c5 100644 --- a/include/osmocom/gsm/protocol/gsm_04_08.h +++ b/include/osmocom/gsm/protocol/gsm_04_08.h @@ -13,15 +13,21 @@ struct gsm_lchan; /* Chapter 10.5.1.5 */ struct gsm48_classmark1 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t pwr_lev:3, a5_1:1, es_ind:1, rev_lev:2, spare:1; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t spare:1, rev_lev:2, es_ind:1, a5_1:1, pwr_lev:3; +#endif } __attribute__ ((packed)); /* Chapter 10.5.1.6 */ struct gsm48_classmark2 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t pwr_lev:3, a5_1:1, es_ind:1, @@ -42,11 +48,18 @@ struct gsm48_classmark2 { lcsva_cap:1, spare4:1, cm3:1; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t spare:1, rev_lev:2, es_ind:1, a5_1:1, pwr_lev:3; + uint8_t spare2:1, ps_cap:1, ss_scr:2, sm_cap:1, vbs:1, vgcs:1, fc:1; + uint8_t cm3:1, spare4:1, lcsva_cap:1, spare3:1, solsa:1, cmsp:1, a5_3:1, a5_2:1; +#endif } __attribute__ ((packed)); /* Chapter 10.5.2.1b.3 */ #if OSMO_IS_LITTLE_ENDIAN == 1 struct gsm48_range_1024 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t w1_hi:2, f0:1, form_id:5; @@ -78,9 +91,29 @@ struct gsm48_range_1024 { w14_lo:3; uint8_t w16:6, w15_lo:2; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t form_id:5, f0:1, w1_hi:2; + uint8_t w1_lo; + uint8_t w2_hi; + uint8_t w2_lo:1, w3_hi:7; + uint8_t w3_lo:2, w4_hi:6; + uint8_t w4_lo:2, w5_hi:6; + uint8_t w5_lo:2, w6_hi:6; + uint8_t w6_lo:2, w7_hi:6; + uint8_t w7_lo:2, w8_hi:6; + uint8_t w8_lo:1, w9:7; + uint8_t w10:7, w11_hi:1; + uint8_t w11_lo:6, w12_hi:2; + uint8_t w12_lo:5, w13_hi:3; + uint8_t w13_lo:4, w14_hi:4; + uint8_t w14_lo:3, w15_hi:5; + uint8_t w15_lo:2, w16:6; +#endif } __attribute__ ((packed)); #else struct gsm48_range_1024 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t form_id:5, f0:1, w1_hi:2; @@ -112,12 +145,32 @@ struct gsm48_range_1024 { w15_hi:5; uint8_t w15_lo:2, w16:6; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t w1_hi:2, f0:1, form_id:5; + uint8_t w1_lo; + uint8_t w2_hi; + uint8_t w3_hi:7, w2_lo:1; + uint8_t w4_hi:6, w3_lo:2; + uint8_t w5_hi:6, w4_lo:2; + uint8_t w6_hi:6, w5_lo:2; + uint8_t w7_hi:6, w6_lo:2; + uint8_t w8_hi:6, w7_lo:2; + uint8_t w9:7, w8_lo:1; + uint8_t w11_hi:1, w10:7; + uint8_t w12_hi:2, w11_lo:6; + uint8_t w13_hi:3, w12_lo:5; + uint8_t w14_hi:4, w13_lo:4; + uint8_t w15_hi:5, w14_lo:3; + uint8_t w16:6, w15_lo:2; +#endif } __attribute__ ((packed)); #endif /* Chapter 10.5.2.1b.4 */ #if OSMO_IS_LITTLE_ENDIAN == 1 struct gsm48_range_512 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t orig_arfcn_hi:1, form_id:7; uint8_t orig_arfcn_mid; @@ -149,9 +202,29 @@ struct gsm48_range_512 { w15:6; uint8_t w17:5, w16_lo:3; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t form_id:7, orig_arfcn_hi:1; + uint8_t orig_arfcn_mid; + uint8_t orig_arfcn_lo:1, w1_hi:7; + uint8_t w1_lo:2, w2_hi:6; + uint8_t w2_lo:2, w3_hi:6; + uint8_t w3_lo:2, w4_hi:6; + uint8_t w4_lo:1, w5:7; + uint8_t w6:7, w7_hi:1; + uint8_t w7_lo:6, w8_hi:2; + uint8_t w8_lo:4, w9_hi:4; + uint8_t w9_lo:2, w10:6; + uint8_t w11:6, w12_hi:2; + uint8_t w12_lo:4, w13_hi:4; + uint8_t w13_lo:2, w14:6; + uint8_t w15:6, w16_hi:2; + uint8_t w16_lo:3, w17:5; +#endif } __attribute__ ((packed)); #else struct gsm48_range_512 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t form_id:7, orig_arfcn_hi:1; uint8_t orig_arfcn_mid; @@ -183,12 +256,32 @@ struct gsm48_range_512 { w16_hi:2; uint8_t w16_lo:3, w17:5; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t orig_arfcn_hi:1, form_id:7; + uint8_t orig_arfcn_mid; + uint8_t w1_hi:7, orig_arfcn_lo:1; + uint8_t w2_hi:6, w1_lo:2; + uint8_t w3_hi:6, w2_lo:2; + uint8_t w4_hi:6, w3_lo:2; + uint8_t w5:7, w4_lo:1; + uint8_t w7_hi:1, w6:7; + uint8_t w8_hi:2, w7_lo:6; + uint8_t w9_hi:4, w8_lo:4; + uint8_t w10:6, w9_lo:2; + uint8_t w12_hi:2, w11:6; + uint8_t w13_hi:4, w12_lo:4; + uint8_t w14:6, w13_lo:2; + uint8_t w16_hi:2, w15:6; + uint8_t w17:5, w16_lo:3; +#endif } __attribute__ ((packed)); #endif /* Chapter 10.5.2.1b.5 */ #if OSMO_IS_LITTLE_ENDIAN == 1 struct gsm48_range_256 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t orig_arfcn_hi:1, form_id:7; uint8_t orig_arfcn_mid; @@ -226,9 +319,29 @@ struct gsm48_range_256 { uint8_t spare:1, w21:4, w20_lo:3; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t form_id:7, orig_arfcn_hi:1; + uint8_t orig_arfcn_mid; + uint8_t orig_arfcn_lo:1, w1_hi:7; + uint8_t w1_lo:1, w2:7; + uint8_t w3:7, w4_hi:1; + uint8_t w4_lo:5, w5_hi:3; + uint8_t w5_lo:3, w6_hi:5; + uint8_t w6_lo:1, w7:6, w8_hi:1; + uint8_t w8_lo:4, w9_hi:4; + uint8_t w9_lo:1, w10:5, w11_hi:2; + uint8_t w11_lo:3, w12:5; + uint8_t w13:5, w14_hi:3; + uint8_t w14_lo:2, w15:5, w16_hi:1; + uint8_t w16_lo:3, w17:4, w18_hi:1; + uint8_t w18_lo:3, w19:4, w20_hi:1; + uint8_t w20_lo:3, w21:4, spare:1; +#endif } __attribute__ ((packed)); #else struct gsm48_range_256 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t form_id:7, orig_arfcn_hi:1; uint8_t orig_arfcn_mid; @@ -266,12 +379,32 @@ struct gsm48_range_256 { uint8_t w20_lo:3, w21:4, spare:1; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t orig_arfcn_hi:1, form_id:7; + uint8_t orig_arfcn_mid; + uint8_t w1_hi:7, orig_arfcn_lo:1; + uint8_t w2:7, w1_lo:1; + uint8_t w4_hi:1, w3:7; + uint8_t w5_hi:3, w4_lo:5; + uint8_t w6_hi:5, w5_lo:3; + uint8_t w8_hi:1, w7:6, w6_lo:1; + uint8_t w9_hi:4, w8_lo:4; + uint8_t w11_hi:2, w10:5, w9_lo:1; + uint8_t w12:5, w11_lo:3; + uint8_t w14_hi:3, w13:5; + uint8_t w16_hi:1, w15:5, w14_lo:2; + uint8_t w18_hi:1, w17:4, w16_lo:3; + uint8_t w20_hi:1, w19:4, w18_lo:3; + uint8_t spare:1, w21:4, w20_lo:3; +#endif } __attribute__ ((packed)); #endif /* Chapter 10.5.2.1b.6 */ #if OSMO_IS_LITTLE_ENDIAN == 1 struct gsm48_range_128 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t orig_arfcn_hi:1, form_id:7; uint8_t orig_arfcn_mid; @@ -311,9 +444,29 @@ struct gsm48_range_128 { w28:3, w27:3, w26_lo:1; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t form_id:7, orig_arfcn_hi:1; + uint8_t orig_arfcn_mid; + uint8_t orig_arfcn_lo:1, w1:7; + uint8_t w2:6, w3_hi:2; + uint8_t w3_lo:4, w4_hi:4; + uint8_t w4_lo:1, w5:5, w6_hi:2; + uint8_t w6_lo:3, w7:5; + uint8_t w8:4, w9:4; + uint8_t w10:4, w11:4; + uint8_t w12:4, w13:4; + uint8_t w14:4, w15:4; + uint8_t w16:3, w17:3, w18_hi:2; + uint8_t w18_lo:1, w19:3, w20:3, w21_hi:1; + uint8_t w21_lo:2, w22:3, w23:3; + uint8_t w24:3, w25:3, w26_hi:2; + uint8_t w26_lo:1, w27:3, w28:3, spare:1; +#endif } __attribute__ ((packed)); #else struct gsm48_range_128 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t form_id:7, orig_arfcn_hi:1; uint8_t orig_arfcn_mid; @@ -353,17 +506,44 @@ struct gsm48_range_128 { w27:3, w28:3, spare:1; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t orig_arfcn_hi:1, form_id:7; + uint8_t orig_arfcn_mid; + uint8_t w1:7, orig_arfcn_lo:1; + uint8_t w3_hi:2, w2:6; + uint8_t w4_hi:4, w3_lo:4; + uint8_t w6_hi:2, w5:5, w4_lo:1; + uint8_t w7:5, w6_lo:3; + uint8_t w9:4, w8:4; + uint8_t w11:4, w10:4; + uint8_t w13:4, w12:4; + uint8_t w15:4, w14:4; + uint8_t w18_hi:2, w17:3, w16:3; + uint8_t w21_hi:1, w20:3, w19:3, w18_lo:1; + uint8_t w23:3, w22:3, w21_lo:2; + uint8_t w26_hi:2, w25:3, w24:3; + uint8_t spare:1, w28:3, w27:3, w26_lo:1; +#endif } __attribute__ ((packed)); #endif /* Chapter 10.5.2.1b.7 */ struct gsm48_var_bit { +#if OSMO_IS_LITTLE_ENDIAN uint8_t orig_arfcn_hi:1, form_id:7; uint8_t orig_arfcn_mid; uint8_t rrfcn1_7:7, orig_arfcn_lo:1; uint8_t rrfcn8_111[13]; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t form_id:7, orig_arfcn_hi:1; + uint8_t orig_arfcn_mid; + uint8_t orig_arfcn_lo:1, rrfcn1_7:7; + uint8_t rrfcn8_111[13]; +#endif } __attribute__ ((packed)); /* Chapter 10.5.2.5 */ @@ -371,24 +551,37 @@ struct gsm48_chan_desc { uint8_t chan_nr; union { struct { +#if OSMO_IS_LITTLE_ENDIAN uint8_t maio_high:4, h:1, tsc:3; uint8_t hsn:6, maio_low:2; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t tsc:3, h:1, maio_high:4; + uint8_t maio_low:2, hsn:6; +#endif } __attribute__ ((packed)) h1; struct { +#if OSMO_IS_LITTLE_ENDIAN uint8_t arfcn_high:2, spare:2, h:1, tsc:3; uint8_t arfcn_low; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t tsc:3, h:1, spare:2, arfcn_high:2; + uint8_t arfcn_low; +#endif } __attribute__ ((packed)) h0; } __attribute__ ((packed)); } __attribute__ ((packed)); /* Chapter 10.5.2.20 */ struct gsm48_meas_res { +#if OSMO_IS_LITTLE_ENDIAN uint8_t rxlev_full:6, dtx_used:1, ba_used:1; @@ -428,10 +621,30 @@ struct gsm48_meas_res { rxlev_nc6_lo:5; uint8_t bsic_nc6:6, bcch_f_nc6_lo:2; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t ba_used:1, dtx_used:1, rxlev_full:6; + uint8_t spare:1, meas_valid:1, rxlev_sub:6; + uint8_t spare2:1, rxqual_full:3, rxqual_sub:3, no_nc_n_hi:1; + uint8_t no_nc_n_lo:2, rxlev_nc1:6; + uint8_t bcch_f_nc1:5, bsic_nc1_hi:3; + uint8_t bsic_nc1_lo:3, rxlev_nc2_hi:5; + uint8_t rxlev_nc2_lo:1, bcch_f_nc2:5, bsic_nc2_hi:2; + uint8_t bsic_nc2_lo:4, rxlev_nc3_hi:4; + uint8_t rxlev_nc3_lo:2, bcch_f_nc3:5, bsic_nc3_hi:1; + uint8_t bsic_nc3_lo:5, rxlev_nc4_hi:3; + uint8_t rxlev_nc4_lo:3, bcch_f_nc4:5; + uint8_t bsic_nc4:6, rxlev_nc5_hi:2; + uint8_t rxlev_nc5_lo:4, bcch_f_nc5_hi:4; + uint8_t bcch_f_nc5_lo:1, bsic_nc5:6, rxlev_nc6_hi:1; + uint8_t rxlev_nc6_lo:5, bcch_f_nc6_hi:3; + uint8_t bcch_f_nc6_lo:2, bsic_nc6:6; +#endif } __attribute__ ((packed)); /* Chapter 10.5.2.21aa */ struct gsm48_multi_rate_conf { +#if OSMO_IS_LITTLE_ENDIAN uint8_t smod : 2, spare: 1, icmi : 1, @@ -445,23 +658,40 @@ struct gsm48_multi_rate_conf { m7_95 : 1, m10_2 : 1, m12_2 : 1; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t ver:3, nscb:1, icmi:1, spare:1, smod:2; + uint8_t m12_2:1, m10_2:1, m7_95:1, m7_40:1, m6_70:1, m5_90:1, m5_15:1, m4_75:1; +#endif } __attribute__((packed)); /* Chapter 10.5.2.28(a) */ struct gsm48_power_cmd { +#if OSMO_IS_LITTLE_ENDIAN uint8_t power_level:5, spare:2, atc:1; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t atc:1, spare:2, power_level:5; +#endif } __attribute__((packed)); /* Chapter 10.5.2.29 */ struct gsm48_rach_control { +#if OSMO_IS_LITTLE_ENDIAN uint8_t re :1, cell_bar :1, tx_integer :4, max_trans :2; uint8_t t2; /* ACC 8-15 barred flags */ uint8_t t3; /* ACC 0-7 barred flags */ +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t max_trans:2, tx_integer:4, cell_bar:1, re:1; + uint8_t t2; + uint8_t t3; +#endif } __attribute__ ((packed)); /* @@ -508,27 +738,45 @@ static inline bool gsm48_acc_is_barred(struct gsm48_rach_control *rach_control, /* Chapter 10.5.2.30 */ struct gsm48_req_ref { +#if OSMO_IS_LITTLE_ENDIAN uint8_t ra; uint8_t t3_high:3, t1:5; uint8_t t2:5, t3_low:3; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t ra; + uint8_t t1:5, t3_high:3; + uint8_t t3_low:3, t2:5; +#endif } __attribute__ ((packed)); /* Chapter 10.5.2.38 */ struct gsm48_start_time { +#if OSMO_IS_LITTLE_ENDIAN uint8_t t3_high:3, t1:5; uint8_t t2:5, t3_low:3; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t t1:5, t3_high:3; + uint8_t t3_low:3, t2:5; +#endif } __attribute__ ((packed)); /* Chapter 10.5.2.39 */ struct gsm48_sync_ind { +#if OSMO_IS_LITTLE_ENDIAN uint8_t si:2, rot:1, nci:1, sync_ie:4; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t sync_ie:4, nci:1, rot:1, si:2; +#endif } __attribute__((packed)); /* @@ -582,10 +830,16 @@ struct gsm48_gprs_susp_req { /* Chapter 10.5.2.2 */ struct gsm48_cell_desc { +#if OSMO_IS_LITTLE_ENDIAN uint8_t bcc:3, ncc:3, arfcn_hi:2; uint8_t arfcn_lo; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t arfcn_hi:2, ncc:3, bcc:3; + uint8_t arfcn_lo; +#endif } __attribute__((packed)); /* Chapter 9.1.15 */ @@ -612,11 +866,19 @@ struct gsm48_imm_ass { /* Chapter 9.1.25 */ struct gsm48_pag_resp { +#if OSMO_IS_LITTLE_ENDIAN uint8_t spare:4, key_seq:4; uint32_t classmark2; uint8_t mi_len; uint8_t mi[0]; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t key_seq:4, spare:4; + uint32_t classmark2; + uint8_t mi_len; + uint8_t mi[0]; +#endif } __attribute__ ((packed)); /* Chapter 10.5.1.3 */ @@ -627,9 +889,15 @@ struct gsm48_loc_area_id { /* Section 9.2.2 */ struct gsm48_auth_req { +#if OSMO_IS_LITTLE_ENDIAN uint8_t key_seq:4, spare:4; uint8_t rand[16]; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t spare:4, key_seq:4; + uint8_t rand[16]; +#endif } __attribute__ ((packed)); /* Section 9.2.3 */ @@ -639,12 +907,21 @@ struct gsm48_auth_resp { /* Section 9.2.15 */ struct gsm48_loc_upd_req { +#if OSMO_IS_LITTLE_ENDIAN uint8_t type:4, key_seq:4; struct gsm48_loc_area_id lai; struct gsm48_classmark1 classmark1; uint8_t mi_len; uint8_t mi[0]; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t key_seq:4, type:4; + struct gsm48_loc_area_id lai; + struct gsm48_classmark1 classmark1; + uint8_t mi_len; + uint8_t mi[0]; +#endif } __attribute__ ((packed)); /* Section 10.1 */ @@ -656,23 +933,37 @@ struct gsm48_hdr { /* Section 9.1.3x System information Type header */ struct gsm48_system_information_type_header { +#if OSMO_IS_LITTLE_ENDIAN uint8_t l2_plen; uint8_t rr_protocol_discriminator :4, skip_indicator:4; uint8_t system_information; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t l2_plen; + uint8_t skip_indicator:4, rr_protocol_discriminator:4; + uint8_t system_information; +#endif } __attribute__ ((packed)); /* Section 10.5.2.4 Cell Selection Parameters */ struct gsm48_cell_sel_par { +#if OSMO_IS_LITTLE_ENDIAN uint8_t ms_txpwr_max_ccch:5, /* GSM 05.08 MS-TXPWR-MAX-CCCH */ cell_resel_hyst:3; /* GSM 05.08 CELL-RESELECT-HYSTERESIS */ uint8_t rxlev_acc_min:6, /* GSM 05.08 RXLEV-ACCESS-MIN */ neci:1, acs:1; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t cell_resel_hyst:3, ms_txpwr_max_ccch:5; + uint8_t acs:1, neci:1, rxlev_acc_min:6; +#endif } __attribute__ ((packed)); /* 3GPP TS 44.018 Section 10.5.2.11 Control Channel Description */ struct gsm48_control_channel_descr { +#if OSMO_IS_LITTLE_ENDIAN uint8_t ccch_conf :3, bs_ag_blks_res :3, att :1, @@ -682,6 +973,12 @@ struct gsm48_control_channel_descr { cbq3 :2, spare_2 :1; uint8_t t3212; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t mscr:1, att:1, bs_ag_blks_res:3, ccch_conf:3; + uint8_t spare_2:1, cbq3:2, spare_1:2, bs_pa_mfrms:3; + uint8_t t3212; +#endif } __attribute__ ((packed)); enum gsm48_dtx_mode { @@ -693,15 +990,21 @@ enum gsm48_dtx_mode { /* Cell Options for SI6, SACCH (10.5.2.3a.2) or SI3, BCCH (Table 10.5.2.3.1), 3GPP TS 44.018 */ struct gsm48_cell_options { +#if OSMO_IS_LITTLE_ENDIAN uint8_t radio_link_timeout:4, dtx:2, pwrc:1, /* either DN-IND or top bit of DTX IND */ d:1; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t d:1, pwrc:1, dtx:2, radio_link_timeout:4; +#endif } __attribute__ ((packed)); /* Section 9.2.9 CM service request */ struct gsm48_service_request { +#if OSMO_IS_LITTLE_ENDIAN uint8_t cm_service_type : 4, cipher_key_seq : 4; /* length + 3 bytes */ @@ -709,6 +1012,13 @@ struct gsm48_service_request { uint8_t mi_len; uint8_t mi[0]; /* optional priority level */ +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t cipher_key_seq:4, cm_service_type:4; + uint32_t classmark; + uint8_t mi_len; + uint8_t mi[0]; +#endif } __attribute__ ((packed)); /* Section 9.1.31 System information Type 1 */ @@ -774,30 +1084,52 @@ struct gsm48_system_information_type_4 { /* Section 9.1.37 System information Type 5 */ struct gsm48_system_information_type_5 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t rr_protocol_discriminator :4, skip_indicator:4; uint8_t system_information; uint8_t bcch_frequency_list[16]; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t skip_indicator:4, rr_protocol_discriminator:4; + uint8_t system_information; + uint8_t bcch_frequency_list[16]; +#endif } __attribute__ ((packed)); /* Section 9.1.38 System information Type 5bis */ struct gsm48_system_information_type_5bis { +#if OSMO_IS_LITTLE_ENDIAN uint8_t rr_protocol_discriminator :4, skip_indicator:4; uint8_t system_information; uint8_t bcch_frequency_list[16]; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t skip_indicator:4, rr_protocol_discriminator:4; + uint8_t system_information; + uint8_t bcch_frequency_list[16]; +#endif } __attribute__ ((packed)); /* Section 9.1.39 System information Type 5ter */ struct gsm48_system_information_type_5ter { +#if OSMO_IS_LITTLE_ENDIAN uint8_t rr_protocol_discriminator :4, skip_indicator:4; uint8_t system_information; uint8_t bcch_frequency_list[16]; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t skip_indicator:4, rr_protocol_discriminator:4; + uint8_t system_information; + uint8_t bcch_frequency_list[16]; +#endif } __attribute__ ((packed)); /* Section 9.1.40 System information Type 6 */ struct gsm48_system_information_type_6 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t rr_protocol_discriminator :4, skip_indicator:4; uint8_t system_information; @@ -806,6 +1138,16 @@ struct gsm48_system_information_type_6 { struct gsm48_cell_options cell_options; uint8_t ncc_permitted; uint8_t rest_octets[0]; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t skip_indicator:4, rr_protocol_discriminator:4; + uint8_t system_information; + uint16_t cell_identity; + struct gsm48_loc_area_id lai; + struct gsm48_cell_options cell_options; + uint8_t ncc_permitted; + uint8_t rest_octets[0]; +#endif } __attribute__ ((packed)); /* Section 9.1.43a System Information type 13 */ @@ -857,10 +1199,15 @@ struct gsm48_chan_rel { /* Section 9.1.9 */ struct gsm48_cip_mode_cmd { +#if OSMO_IS_LITTLE_ENDIAN uint8_t sc:1, alg_id:3, cr:1, spare:3; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t spare:3, cr:1, alg_id:3, sc:1; +#endif } __attribute__((packed)); /* Section 9.1.11 */ @@ -905,6 +1252,7 @@ struct gsm48_imm_ass_rej { /* Section 9.1.22 */ struct gsm48_paging1 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t l2_plen; uint8_t proto_discr; uint8_t msg_type; @@ -913,10 +1261,19 @@ struct gsm48_paging1 { cneed1:2, cneed2:2; uint8_t data[0]; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t l2_plen; + uint8_t proto_discr; + uint8_t msg_type; + uint8_t cneed2:2, cneed1:2, spare:2, pag_mode:2; + uint8_t data[0]; +#endif } __attribute__((packed)); /* Section 9.1.23 */ struct gsm48_paging2 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t l2_plen; uint8_t proto_discr; uint8_t msg_type; @@ -927,10 +1284,21 @@ struct gsm48_paging2 { uint32_t tmsi1; uint32_t tmsi2; uint8_t data[0]; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t l2_plen; + uint8_t proto_discr; + uint8_t msg_type; + uint8_t cneed2:2, cneed1:2, spare:2, pag_mode:2; + uint32_t tmsi1; + uint32_t tmsi2; + uint8_t data[0]; +#endif } __attribute__((packed)); /* Section 9.1.24 */ struct gsm48_paging3 { +#if OSMO_IS_LITTLE_ENDIAN uint8_t l2_plen; uint8_t proto_discr; uint8_t msg_type; @@ -946,15 +1314,36 @@ struct gsm48_paging3 { cneed4:2, spare2:4; uint8_t rest[0]; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t l2_plen; + uint8_t proto_discr; + uint8_t msg_type; + uint8_t cneed2:2, cneed1:2, spare:2, pag_mode:2; + uint32_t tmsi1; + uint32_t tmsi2; + uint32_t tmsi3; + uint32_t tmsi4; + uint8_t spare2:4, cneed4:2, cneed3:2; + uint8_t rest[0]; +#endif } __attribute__((packed)); /* Section 9.1.25 */ struct gsm48_pag_rsp { +#if OSMO_IS_LITTLE_ENDIAN uint8_t key_seq:3, spare:5; uint8_t cm2_len; struct gsm48_classmark2 cm2; uint8_t data[0]; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t spa |