blob: 5d5fca9a1a3e5ec29dcb02e49f85053004c4d2e9 [file] [log] [blame]
Neels Hofmeyr17518fe2017-06-20 04:35:06 +02001/*! \file gsm_04_60.h
2 * General Packet Radio Service (GPRS).
Tom Tsou9394dbd2016-07-07 17:06:12 -07003 * Radio Link Control / Medium Access Control (RLC/MAC) protocol
4 * 3GPP TS 04.60 version 8.27.0 Release 1999
5 */
6
Neels Hofmeyr17518fe2017-06-20 04:35:06 +02007#pragma once
8
Tom Tsou9394dbd2016-07-07 17:06:12 -07009#include <stdint.h>
Neels Hofmeyrb2600392018-11-16 00:20:39 +010010#include <osmocom/core/endian.h>
Tom Tsou9394dbd2016-07-07 17:06:12 -070011
12#if OSMO_IS_LITTLE_ENDIAN == 1
13/* TS 04.60 10.3a.4.1.1 */
14struct gprs_rlc_ul_header_egprs_1 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +010015#if OSMO_IS_LITTLE_ENDIAN
Tom Tsou9394dbd2016-07-07 17:06:12 -070016 uint8_t r:1,
17 si:1,
18 cv:4,
19 tfi_hi:2;
20 uint8_t tfi_lo:3,
21 bsn1_hi:5;
22 uint8_t bsn1_lo:6,
23 bsn2_hi:2;
24 uint8_t bsn2_lo:8;
25 uint8_t cps:5,
26 rsb:1,
27 pi:1,
28 spare_hi:1;
29 uint8_t spare_lo:6,
30 dummy:2;
Neels Hofmeyrb2600392018-11-16 00:20:39 +010031#elif OSMO_IS_BIG_ENDIAN
32/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
33 uint8_t tfi_hi:2, cv:4, si:1, r:1;
34 uint8_t bsn1_hi:5, tfi_lo:3;
35 uint8_t bsn2_hi:2, bsn1_lo:6;
36 uint8_t bsn2_lo:8;
37 uint8_t spare_hi:1, pi:1, rsb:1, cps:5;
38 uint8_t dummy:2, spare_lo:6;
39#endif
Tom Tsou9394dbd2016-07-07 17:06:12 -070040} __attribute__ ((packed));
41
42/* TS 04.60 10.3a.4.2.1 */
43struct gprs_rlc_ul_header_egprs_2 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +010044#if OSMO_IS_LITTLE_ENDIAN
Tom Tsou9394dbd2016-07-07 17:06:12 -070045 uint8_t r:1,
46 si:1,
47 cv:4,
48 tfi_hi:2;
49 uint8_t tfi_lo:3,
50 bsn1_hi:5;
51 uint8_t bsn1_lo:6,
52 cps_hi:2;
53 uint8_t cps_lo:1,
54 rsb:1,
55 pi:1,
56 spare_hi:5;
57 uint8_t spare_lo:5,
58 dummy:3;
Neels Hofmeyrb2600392018-11-16 00:20:39 +010059#elif OSMO_IS_BIG_ENDIAN
60/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
61 uint8_t tfi_hi:2, cv:4, si:1, r:1;
62 uint8_t bsn1_hi:5, tfi_lo:3;
63 uint8_t cps_hi:2, bsn1_lo:6;
64 uint8_t spare_hi:5, pi:1, rsb:1, cps_lo:1;
65 uint8_t dummy:3, spare_lo:5;
66#endif
Tom Tsou9394dbd2016-07-07 17:06:12 -070067} __attribute__ ((packed));
68
69/* TS 04.60 10.3a.4.3.1 */
70struct gprs_rlc_ul_header_egprs_3 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +010071#if OSMO_IS_LITTLE_ENDIAN
Tom Tsou9394dbd2016-07-07 17:06:12 -070072 uint8_t r:1,
73 si:1,
74 cv:4,
75 tfi_hi:2;
76 uint8_t tfi_lo:3,
77 bsn1_hi:5;
78 uint8_t bsn1_lo:6,
79 cps_hi:2;
80 uint8_t cps_lo:2,
81 spb:2,
82 rsb:1,
83 pi:1,
84 spare:1,
85 dummy:1;
Neels Hofmeyrb2600392018-11-16 00:20:39 +010086#elif OSMO_IS_BIG_ENDIAN
87/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
88 uint8_t tfi_hi:2, cv:4, si:1, r:1;
89 uint8_t bsn1_hi:5, tfi_lo:3;
90 uint8_t cps_hi:2, bsn1_lo:6;
91 uint8_t dummy:1, spare:1, pi:1, rsb:1, spb:2, cps_lo:2;
92#endif
Tom Tsou9394dbd2016-07-07 17:06:12 -070093} __attribute__ ((packed));
94
95struct gprs_rlc_dl_header_egprs_1 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +010096#if OSMO_IS_LITTLE_ENDIAN
Tom Tsou9394dbd2016-07-07 17:06:12 -070097 uint8_t usf:3,
98 es_p:2,
99 rrbp:2,
100 tfi_hi:1;
101 uint8_t tfi_lo:4,
102 pr:2,
103 bsn1_hi:2;
104 uint8_t bsn1_mid:8;
105 uint8_t bsn1_lo:1,
106 bsn2_hi:7;
107 uint8_t bsn2_lo:3,
108 cps:5;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100109#elif OSMO_IS_BIG_ENDIAN
110/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
111 uint8_t tfi_hi:1, rrbp:2, es_p:2, usf:3;
112 uint8_t bsn1_hi:2, pr:2, tfi_lo:4;
113 uint8_t bsn1_mid:8;
114 uint8_t bsn2_hi:7, bsn1_lo:1;
115 uint8_t cps:5, bsn2_lo:3;
116#endif
Tom Tsou9394dbd2016-07-07 17:06:12 -0700117} __attribute__ ((packed));
118
119struct gprs_rlc_dl_header_egprs_2 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100120#if OSMO_IS_LITTLE_ENDIAN
Tom Tsou9394dbd2016-07-07 17:06:12 -0700121 uint8_t usf:3,
122 es_p:2,
123 rrbp:2,
124 tfi_hi:1;
125 uint8_t tfi_lo:4,
126 pr:2,
127 bsn1_hi:2;
128 uint8_t bsn1_mid:8;
129 uint8_t bsn1_lo:1,
130 cps:3,
131 dummy:4;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100132#elif OSMO_IS_BIG_ENDIAN
133/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
134 uint8_t tfi_hi:1, rrbp:2, es_p:2, usf:3;
135 uint8_t bsn1_hi:2, pr:2, tfi_lo:4;
136 uint8_t bsn1_mid:8;
137 uint8_t dummy:4, cps:3, bsn1_lo:1;
138#endif
Tom Tsou9394dbd2016-07-07 17:06:12 -0700139} __attribute__ ((packed));
140
141struct gprs_rlc_dl_header_egprs_3 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100142#if OSMO_IS_LITTLE_ENDIAN
Tom Tsou9394dbd2016-07-07 17:06:12 -0700143 uint8_t usf:3,
144 es_p:2,
145 rrbp:2,
146 tfi_hi:1;
147 uint8_t tfi_lo:4,
148 pr:2,
149 bsn1_hi:2;
150 uint8_t bsn1_mid:8;
151 uint8_t bsn1_lo:1,
152 cps:4,
153 spb:2,
154 dummy:1;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100155#elif OSMO_IS_BIG_ENDIAN
156/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
157 uint8_t tfi_hi:1, rrbp:2, es_p:2, usf:3;
158 uint8_t bsn1_hi:2, pr:2, tfi_lo:4;
159 uint8_t bsn1_mid:8;
160 uint8_t dummy:1, spb:2, cps:4, bsn1_lo:1;
161#endif
Tom Tsou9394dbd2016-07-07 17:06:12 -0700162} __attribute__ ((packed));
163#else
164/* TS 04.60 10.3a.4.1.1 */
165struct gprs_rlc_ul_header_egprs_1 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100166#if OSMO_IS_LITTLE_ENDIAN
Tom Tsou9394dbd2016-07-07 17:06:12 -0700167 uint8_t tfi_hi:2,
168 cv:4,
169 si:1,
170 r:1;
171 uint8_t bsn1_hi:5,
172 tfi_lo:3;
173 uint8_t bsn2_hi:2,
174 bsn1_lo:6;
175 uint8_t bsn2_lo:8;
176 uint8_t spare_hi:1,
177 pi:1,
178 rsb:1,
179 cps:5;
180 uint8_t dummy:2,
181 spare_lo:6;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100182#elif OSMO_IS_BIG_ENDIAN
183/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
184 uint8_t r:1, si:1, cv:4, tfi_hi:2;
185 uint8_t tfi_lo:3, bsn1_hi:5;
186 uint8_t bsn1_lo:6, bsn2_hi:2;
187 uint8_t bsn2_lo:8;
188 uint8_t cps:5, rsb:1, pi:1, spare_hi:1;
189 uint8_t spare_lo:6, dummy:2;
190#endif
Tom Tsou9394dbd2016-07-07 17:06:12 -0700191} __attribute__ ((packed));
192
193/* TS 04.60 10.3a.4.2.1 */
194struct gprs_rlc_ul_header_egprs_2 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100195#if OSMO_IS_LITTLE_ENDIAN
Tom Tsou9394dbd2016-07-07 17:06:12 -0700196 uint8_t tfi_hi:2,
197 cv:4,
198 si:1,
199 r:1;
200 uint8_t bsn1_hi:5,
201 tfi_lo:3;
202 uint8_t cps_hi:2,
203 bsn1_lo:6;
204 uint8_t spare_hi:5,
205 pi:1,
206 rsb:1,
207 cps_lo:1;
208 uint8_t dummy:3,
209 spare_lo:5;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100210#elif OSMO_IS_BIG_ENDIAN
211/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
212 uint8_t r:1, si:1, cv:4, tfi_hi:2;
213 uint8_t tfi_lo:3, bsn1_hi:5;
214 uint8_t bsn1_lo:6, cps_hi:2;
215 uint8_t cps_lo:1, rsb:1, pi:1, spare_hi:5;
216 uint8_t spare_lo:5, dummy:3;
217#endif
Tom Tsou9394dbd2016-07-07 17:06:12 -0700218} __attribute__ ((packed));
219
220/* TS 04.60 10.3a.4.3.1 */
221struct gprs_rlc_ul_header_egprs_3 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100222#if OSMO_IS_LITTLE_ENDIAN
Tom Tsou9394dbd2016-07-07 17:06:12 -0700223 uint8_t tfi_hi:2,
224 cv:4,
225 si:1,
226 r:1;
227 uint8_t bsn1_hi:5,
228 tfi_lo:3;
229 uint8_t cps_hi:2,
230 bsn1_lo:6;
231 uint8_t dummy:1,
232 spare:1,
233 pi:1,
234 rsb:1,
235 spb:2,
236 cps_lo:2;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100237#elif OSMO_IS_BIG_ENDIAN
238/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
239 uint8_t r:1, si:1, cv:4, tfi_hi:2;
240 uint8_t tfi_lo:3, bsn1_hi:5;
241 uint8_t bsn1_lo:6, cps_hi:2;
242 uint8_t cps_lo:2, spb:2, rsb:1, pi:1, spare:1, dummy:1;
243#endif
Tom Tsou9394dbd2016-07-07 17:06:12 -0700244} __attribute__ ((packed));
245
246struct gprs_rlc_dl_header_egprs_1 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100247#if OSMO_IS_LITTLE_ENDIAN
Tom Tsou9394dbd2016-07-07 17:06:12 -0700248 uint8_t tfi_hi:1,
249 rrbp:2,
250 es_p:2,
251 usf:3;
252 uint8_t bsn1_hi:2,
253 pr:2,
254 tfi_lo:4;
255 uint8_t bsn1_mid:8;
256 uint8_t bsn2_hi:7,
257 bsn1_lo:1;
258 uint8_t cps:5,
259 bsn2_lo:3;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100260#elif OSMO_IS_BIG_ENDIAN
261/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
262 uint8_t usf:3, es_p:2, rrbp:2, tfi_hi:1;
263 uint8_t tfi_lo:4, pr:2, bsn1_hi:2;
264 uint8_t bsn1_mid:8;
265 uint8_t bsn1_lo:1, bsn2_hi:7;
266 uint8_t bsn2_lo:3, cps:5;
267#endif
Tom Tsou9394dbd2016-07-07 17:06:12 -0700268} __attribute__ ((packed));
269
270struct gprs_rlc_dl_header_egprs_2 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100271#if OSMO_IS_LITTLE_ENDIAN
Tom Tsou9394dbd2016-07-07 17:06:12 -0700272 uint8_t tfi_hi:1,
273 rrbp:2,
274 es_p:2,
275 usf:3;
276 uint8_t bsn1_hi:2,
277 pr:2,
278 tfi_lo:4;
279 uint8_t bsn1_mid:8;
280 uint8_t dummy:4,
281 cps:3,
282 bsn1_lo:1;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100283#elif OSMO_IS_BIG_ENDIAN
284/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
285 uint8_t usf:3, es_p:2, rrbp:2, tfi_hi:1;
286 uint8_t tfi_lo:4, pr:2, bsn1_hi:2;
287 uint8_t bsn1_mid:8;
288 uint8_t bsn1_lo:1, cps:3, dummy:4;
289#endif
Tom Tsou9394dbd2016-07-07 17:06:12 -0700290} __attribute__ ((packed));
291
292struct gprs_rlc_dl_header_egprs_3 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100293#if OSMO_IS_LITTLE_ENDIAN
Tom Tsou9394dbd2016-07-07 17:06:12 -0700294 uint8_t tfi_hi:1,
295 rrbp:2,
296 es_p:2,
297 usf:3;
298 uint8_t bsn1_hi:2,
299 pr:2,
300 tfi_lo:4;
301 uint8_t bsn1_mid:8;
302 uint8_t dummy:1,
303 spb:2,
304 cps:4,
305 bsn1_lo:1;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100306#elif OSMO_IS_BIG_ENDIAN
307/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
308 uint8_t usf:3, es_p:2, rrbp:2, tfi_hi:1;
309 uint8_t tfi_lo:4, pr:2, bsn1_hi:2;
310 uint8_t bsn1_mid:8;
311 uint8_t bsn1_lo:1, cps:4, spb:2, dummy:1;
312#endif
Tom Tsou9394dbd2016-07-07 17:06:12 -0700313} __attribute__ ((packed));
314#endif