add/clean big-endian packed structs (struct_endianess.py)

This is 1:1 the result of doing

  cd libosmocore
  ./contrib/struct_endianess.py
  git commit -a

Running struct_endianess.py again should result in no changes.

That means we could include such a check in the gerrit verification job now.

Change-Id: Ia0b99d76932aeb03e93bd0c62d3bf025dec5f9d2
This commit is contained in:
Neels Hofmeyr 2018-11-16 00:20:39 +01:00 committed by Neels Hofmeyr
parent 036012b508
commit b26003963e
9 changed files with 647 additions and 45 deletions

View File

@ -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

View File

@ -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;

View File

@ -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 spare:5, key_seq:3;
uint8_t cm2_len;
struct gsm48_classmark2 cm2;
uint8_t data[0];
#endif
} __attribute__((packed));
/* Section 9.1.29 */

View File

@ -7,6 +7,7 @@
#include <stdbool.h>
#include <osmocom/gsm/protocol/gsm_04_08.h>
#include <osmocom/crypt/gprs_cipher.h>
#include <osmocom/core/endian.h>
/* Table 10.4 / 10.4a, GPRS Mobility Management (GMM) */
#define GSM48_MT_GMM_ATTACH_REQ 0x01
@ -120,11 +121,19 @@ enum gsm48_gprs_ie_sm {
/* Chapter 9.4.15 / Table 9.4.15 */
struct gsm48_ra_upd_ack {
#if OSMO_IS_LITTLE_ENDIAN
uint8_t force_stby:4, /* 10.5.5.7 */
upd_result:4; /* 10.5.5.17 */
uint8_t ra_upd_timer; /* 10.5.7.3 */
struct gsm48_ra_id ra_id; /* 10.5.5.15 */
uint8_t data[0];
#elif OSMO_IS_BIG_ENDIAN
/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
uint8_t upd_result:4, force_stby:4;
uint8_t ra_upd_timer;
struct gsm48_ra_id ra_id;
uint8_t data[0];
#endif
} __attribute__((packed));
/* Chapter 10.5.7.3 */
@ -140,28 +149,50 @@ enum gsm48_gprs_tmr_unit {
/* Chapter 9.4.2 / Table 9.4.2 */
struct gsm48_attach_ack {
#if OSMO_IS_LITTLE_ENDIAN
uint8_t att_result:4, /* 10.5.5.7 */
force_stby:4; /* 10.5.5.1 */
uint8_t ra_upd_timer; /* 10.5.7.3 */
uint8_t radio_prio; /* 10.5.7.2 */
struct gsm48_ra_id ra_id; /* 10.5.5.15 */
uint8_t data[0];
#elif OSMO_IS_BIG_ENDIAN
/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
uint8_t force_stby:4, att_result:4;
uint8_t ra_upd_timer;
uint8_t radio_prio;
struct gsm48_ra_id ra_id;
uint8_t data[0];
#endif
} __attribute__((packed));
/* Chapter 9.4.9 / Table 9.4.9 */
struct gsm48_auth_ciph_req {
#if OSMO_IS_LITTLE_ENDIAN
uint8_t ciph_alg:4, /* 10.5.5.3 */
imeisv_req:4; /* 10.5.5.10 */
uint8_t force_stby:4, /* 10.5.5.7 */
ac_ref_nr:4; /* 10.5.5.19 */
uint8_t data[0];
#elif OSMO_IS_BIG_ENDIAN
/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
uint8_t imeisv_req:4, ciph_alg:4;
uint8_t ac_ref_nr:4, force_stby:4;
uint8_t data[0];
#endif
} __attribute__((packed));
/* optional: TV RAND, TV CKSN */
struct gsm48_auth_ciph_resp {
#if OSMO_IS_LITTLE_ENDIAN
uint8_t ac_ref_nr:4,
spare:4;
uint8_t data[0];
#elif OSMO_IS_BIG_ENDIAN
/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
uint8_t spare:4, ac_ref_nr:4;
uint8_t data[0];
#endif
} __attribute__((packed));
/* Chapter 9.5.1 / Table 9.5.1 */

View File

@ -4,6 +4,7 @@
#pragma once
#include <stdint.h>
#include <osmocom/core/endian.h>
#define GSM412_MSG_LEN 88 /* TS 04.12 Section 3.1 */
#define GSM412_BLOCK_LEN 22 /* TS 04.12 Section 3.1 */
@ -16,17 +17,30 @@
#define GSM412_SEQ_NULL_MSG 0xf
struct gsm412_block_type {
#if OSMO_IS_LITTLE_ENDIAN
uint8_t seq_nr : 4,
lb : 1,
lpd : 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, lpd:2, lb:1, seq_nr:4;
#endif
} __attribute__((packed));
struct gsm412_sched_msg {
#if OSMO_IS_LITTLE_ENDIAN
uint8_t beg_slot_nr : 6,
type : 2;
uint8_t end_slot_nr : 6,
spare1 : 1, spare2: 1;
uint8_t cbsms_msg_map[6];
uint8_t data[0];
#elif OSMO_IS_BIG_ENDIAN
/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
uint8_t type:2, beg_slot_nr:6;
uint8_t spare2:1, spare1:1, end_slot_nr:6;
uint8_t cbsms_msg_map[6];
uint8_t data[0];
#endif
} __attribute__((packed));

View File

@ -25,29 +25,26 @@ enum gsm414_tch_loop_mode {
#define GSM414_MT_CLOSE_MSLOT_LOOP_CMD 0x20 /* 8.4 */
struct gsm414_close_mslot_loop_cmd {
#if OSMO_IS_LITTLE_ENDIAN == 1
#if OSMO_IS_LITTLE_ENDIAN
uint8_t chc:2,
loop_mech:3,
tn:3;
#else
uint8_t tn:3,
loop_mech:3,
chc:2;
#elif OSMO_IS_BIG_ENDIAN
/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
uint8_t tn:3, loop_mech:3, chc:2;
#endif
} __attribute__((packed));
#define GSM414_MT_CLOSE_MSLOT_LOOP_ACK 0x21 /* 8.5 */
struct gsm414_close_mslot_loop_ack {
#if OSMO_IS_LITTLE_ENDIAN == 1
#if OSMO_IS_LITTLE_ENDIAN
uint8_t err_ind:1,
loop_mech:3,
chc:2,
spare:2;
#else
uint8_t spare:2,
chc:2,
loop_mech:3,
err_ind:1;
#elif OSMO_IS_BIG_ENDIAN
/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
uint8_t spare:2, chc:2, loop_mech:3, err_ind:1;
#endif
} __attribute__((packed));
@ -65,34 +62,32 @@ struct gsm414_close_mslot_loop_ack {
#define GSM414_MT_GPRS_TEST_MODE_CMD 0x24 /* 8.13 */
struct gsm414_gprs_test_mode_cmd {
#if OSMO_IS_LITTLE_ENDIAN == 1
#if OSMO_IS_LITTLE_ENDIAN
uint16_t d:12,
spare:3,
l:1;
uint8_t m:1,
dl_tx_offset:3,
_spare:4;
#else
uint16_t l:1,
#elif OSMO_IS_BIG_ENDIAN
/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
uint16_t d:12,
spare:3,
d:12;
uint8_t _spare:4,
dl_tx_offset:3,
m:1;
l:1;
uint8_t _spare:4, dl_tx_offset:3, m:1;
#endif
} __attribute__((packed));
#define GSM414_MT_EGPRS_ST_RB_LOOP_CMD 0x25 /* 8.14 */
struct gsm414_egprs_st_sb_loop_cmd {
#if OSMO_IS_LITTLE_ENDIAN == 1
#if OSMO_IS_LITTLE_ENDIAN
uint8_t _spare:4,
dl_tx_offset:3,
m:1;
#else
uint8_t m:1,
dl_tx_offset:3,
_spare:4;
#elif OSMO_IS_BIG_ENDIAN
/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
uint8_t m:1, dl_tx_offset:3, _spare:4;
#endif
} __attribute__((packed));

View File

@ -594,10 +594,15 @@ struct rsl_ie_chan_ident {
/*! RSL Cell Broadcast Command (Chapter 9.3.45) */
struct rsl_ie_cb_cmd_type {
#if OSMO_IS_LITTLE_ENDIAN
uint8_t last_block:2;
uint8_t spare:1;
uint8_t def_bcast:1;
uint8_t command:4;
#elif OSMO_IS_BIG_ENDIAN
/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
uint8_t command:4, def_bcast:1, spare:1, last_block:2;
#endif
} __attribute__ ((packed));
/* ->command */
#define RSL_CB_CMD_TYPE_NORMAL 0x00
@ -732,14 +737,21 @@ enum rsl_ipac_embedded_ie {
};
struct ipac_preproc_ave_cfg {
#if OSMO_IS_LITTLE_ENDIAN
uint8_t h_reqave:5,
param_id:2,
reserved:1;
uint8_t h_reqt:5,
ave_method:3;
#elif OSMO_IS_BIG_ENDIAN
/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
uint8_t reserved:1, param_id:2, h_reqave:5;
uint8_t ave_method:3, h_reqt:5;
#endif
}__attribute__ ((packed));
struct ipac_preproc_ho_thresh {
#if OSMO_IS_LITTLE_ENDIAN
uint8_t l_rxlev_ul_h:6,
reserved_l_rxlev_ul:2;
uint8_t l_rxlev_dl_h:6,
@ -754,9 +766,19 @@ struct ipac_preproc_ho_thresh {
reserved_rxqual_dl:1;
uint8_t ms_range_max:6,
reserved_ms_range:2;
#elif OSMO_IS_BIG_ENDIAN
/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
uint8_t reserved_l_rxlev_ul:2, l_rxlev_ul_h:6;
uint8_t reserved_l_rxlev_dl:2, l_rxlev_dl_h:6;
uint8_t reserved_rxlev_ul:2, rxlev_ul_ih:6;
uint8_t reserved_rxlev_dl:2, rxlev_dl_ih:6;
uint8_t reserved_rxqual_dl:1, l_rxqual_dl_h:3, reserved_rxlqual_ul:1, l_rxqual_ul_h:3;
uint8_t reserved_ms_range:2, ms_range_max:6;
#endif
}__attribute__ ((packed));
struct ipac_preproc_ho_comp {
#if OSMO_IS_LITTLE_ENDIAN
uint8_t p5:5,
reserved_p5:3;
uint8_t n5:5,
@ -777,30 +799,61 @@ struct ipac_preproc_ho_comp {
reserved_ho:3;
uint8_t reserved;
#elif OSMO_IS_BIG_ENDIAN
/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
uint8_t reserved_p5:3, p5:5;
uint8_t reserved_n5:3, n5:5;
uint8_t reserved_p6:3, p6:5;
uint8_t reserved_n6:3, n6:5;
uint8_t reserved_p7:3, p7:5;
uint8_t reserved_n7:3, n7:5;
uint8_t reserved_p8:3, p8:5;
uint8_t reserved_n8:3, n8:5;
uint8_t reserved_ho:3, ho_interval:5;
uint8_t reserved;
#endif
}__attribute__ ((packed));
struct ipac_preproc_ho_candidates {
#if OSMO_IS_LITTLE_ENDIAN
uint8_t bsic:6,
reserved0:2;
uint8_t bcch_freq:5,
ba_used:1,
s:1,
reserved1:1;
#elif OSMO_IS_BIG_ENDIAN
/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
uint8_t reserved0:2, bsic:6;
uint8_t reserved1:1, s:1, ba_used:1, bcch_freq:5;
#endif
}__attribute__ ((packed));
struct ipac_preproc_ncell_dflts {
#if OSMO_IS_LITTLE_ENDIAN
uint8_t rxlev_min_def:6,
reserved_rxlev_min_def:2;
uint8_t ho_margin_def:5,
reserved_ho_margin_def:3;
uint8_t ms_txpwr_max_def:5,
reserved_ms_txpwr_max_def:3;
#elif OSMO_IS_BIG_ENDIAN
/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
uint8_t reserved_rxlev_min_def:2, rxlev_min_def:6;
uint8_t reserved_ho_margin_def:3, ho_margin_def:5;
uint8_t reserved_ms_txpwr_max_def:3, ms_txpwr_max_def:5;
#endif
}__attribute__ ((packed));
struct ipac_preproc_ho_ctl_param {
#if OSMO_IS_LITTLE_ENDIAN
uint8_t sdcch_ho_gsm:1,
sdcch_ho_umts:1,
reserved:6;
#elif OSMO_IS_BIG_ENDIAN
/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
uint8_t reserved:6, sdcch_ho_umts:1, sdcch_ho_gsm:1;
#endif
}__attribute__ ((packed));
struct ipac_preproc_cfg {

View File

@ -4,6 +4,7 @@
#pragma once
#include <stdint.h>
#include <osmocom/core/endian.h>
/* Table 11.1.1.2.1: Protocol Discriminator */
enum gan_pdisc {
@ -154,15 +155,24 @@ enum gan_iei {
/* 11.1.1 GA-RC and GA-CSR Message header IE */
struct gan_rc_csr_hdr {
#if OSMO_IS_LITTLE_ENDIAN
uint16_t len;
uint8_t pdisc:4,
skip_ind:4;
uint8_t msg_type;
uint8_t data[0];
#elif OSMO_IS_BIG_ENDIAN
/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
uint16_t len;
uint8_t skip_ind:4, pdisc:4;
uint8_t msg_type;
uint8_t data[0];
#endif
} __attribute__((packed));
/* 11.2.14.1: GAN Control Channel Description IE */
struct gan_cch_desc_ie {
#if OSMO_IS_LITTLE_ENDIAN
uint8_t spare:1,
ecmc:1,
nmo:2,
@ -179,4 +189,12 @@ struct gan_cch_desc_ie {
tgecs:2,
spare2:2;
uint8_t access_class[2];
#elif OSMO_IS_BIG_ENDIAN
/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
uint8_t mscr:1, att:1, dtm:1, gprs:1, nmo:2, ecmc:1, spare:1;
uint8_t t3212;
uint8_t rac;
uint8_t spare2:2, tgecs:2, pfcfm:1, re:1, ecmp:1, sgsnr:1;
uint8_t access_class[2];
#endif
} __attribute__((packed));

View File

@ -1,5 +1,6 @@
#include <osmocom/core/byteswap.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/endian.h>
int main(int argc, char **argv)
{