Neels Hofmeyr | 17518fe | 2017-06-20 04:35:06 +0200 | [diff] [blame] | 1 | /*! \file gsm_04_08.h |
| 2 | * GSM TS 04.08 definitions. */ |
| 3 | |
Sylvain Munaut | 12ba778 | 2014-06-16 10:13:40 +0200 | [diff] [blame] | 4 | #pragma once |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 5 | |
| 6 | #include <stdint.h> |
Max | fe65fa7 | 2016-05-10 17:17:05 +0200 | [diff] [blame] | 7 | #include <stdbool.h> |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 8 | |
Max | fb348ee | 2016-03-30 21:14:53 +0200 | [diff] [blame] | 9 | #include <osmocom/core/utils.h> |
Ruben Undheim | 720ac4a | 2016-05-27 22:03:59 +0200 | [diff] [blame] | 10 | #include <osmocom/core/endian.h> |
| 11 | |
Pau Espin Pedrol | 2272a03 | 2019-11-04 11:03:37 +0100 | [diff] [blame] | 12 | #include <osmocom/gsm/gsm_utils.h> |
| 13 | |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 14 | struct gsm_lchan; |
| 15 | |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 16 | /* Chapter 10.5.1.5 */ |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 17 | struct gsm48_classmark1 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 18 | #if OSMO_IS_LITTLE_ENDIAN |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 19 | uint8_t pwr_lev:3, |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 20 | a5_1:1, |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 21 | es_ind:1, |
| 22 | rev_lev:2, |
| 23 | spare:1; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 24 | #elif OSMO_IS_BIG_ENDIAN |
| 25 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 26 | uint8_t spare:1, rev_lev:2, es_ind:1, a5_1:1, pwr_lev:3; |
| 27 | #endif |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 28 | } __attribute__ ((packed)); |
| 29 | |
| 30 | /* Chapter 10.5.1.6 */ |
| 31 | struct gsm48_classmark2 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 32 | #if OSMO_IS_LITTLE_ENDIAN |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 33 | uint8_t pwr_lev:3, |
| 34 | a5_1:1, |
| 35 | es_ind:1, |
| 36 | rev_lev:2, |
| 37 | spare:1; |
| 38 | uint8_t fc:1, |
| 39 | vgcs:1, |
| 40 | vbs:1, |
| 41 | sm_cap:1, |
| 42 | ss_scr:2, |
| 43 | ps_cap:1, |
| 44 | spare2:1; |
| 45 | uint8_t a5_2:1, |
| 46 | a5_3:1, |
| 47 | cmsp:1, |
| 48 | solsa:1, |
| 49 | spare3:1, |
| 50 | lcsva_cap:1, |
| 51 | spare4:1, |
| 52 | cm3:1; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 53 | #elif OSMO_IS_BIG_ENDIAN |
| 54 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 55 | uint8_t spare:1, rev_lev:2, es_ind:1, a5_1:1, pwr_lev:3; |
| 56 | uint8_t spare2:1, ps_cap:1, ss_scr:2, sm_cap:1, vbs:1, vgcs:1, fc:1; |
| 57 | uint8_t cm3:1, spare4:1, lcsva_cap:1, spare3:1, solsa:1, cmsp:1, a5_3:1, a5_2:1; |
| 58 | #endif |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 59 | } __attribute__ ((packed)); |
| 60 | |
Neels Hofmeyr | 7740d26 | 2019-01-16 16:53:26 +0100 | [diff] [blame] | 61 | struct osmo_gsm48_classmark { |
| 62 | bool classmark1_set; |
| 63 | struct gsm48_classmark1 classmark1; |
| 64 | uint8_t classmark2_len; |
| 65 | struct gsm48_classmark2 classmark2; |
| 66 | uint8_t classmark3_len; |
| 67 | uint8_t classmark3[14]; /* if cm3 gets extended by spec, it will be truncated */ |
| 68 | }; |
| 69 | |
| 70 | bool osmo_gsm48_classmark_is_r99(const struct osmo_gsm48_classmark *cm); |
| 71 | bool osmo_gsm48_classmark1_is_r99(const struct gsm48_classmark1 *cm1); |
| 72 | bool osmo_gsm48_classmark2_is_r99(const struct gsm48_classmark2 *cm2, uint8_t cm2_len); |
| 73 | int osmo_gsm48_classmark_supports_a5(const struct osmo_gsm48_classmark *cm, uint8_t a5); |
| 74 | const char *osmo_gsm48_classmark_a5_name(const struct osmo_gsm48_classmark *cm); |
Harald Welte | 4a62eda | 2019-03-18 18:27:00 +0100 | [diff] [blame] | 75 | char *osmo_gsm48_classmark_a5_name_buf(char *buf, size_t buf_len, const struct osmo_gsm48_classmark *cm); |
Harald Welte | 179f357 | 2019-03-18 18:38:47 +0100 | [diff] [blame] | 76 | char *osmo_gsm48_classmark_a5_name_c(const void *ctx, const struct osmo_gsm48_classmark *cm); |
Neels Hofmeyr | 7740d26 | 2019-01-16 16:53:26 +0100 | [diff] [blame] | 77 | void osmo_gsm48_classmark_update(struct osmo_gsm48_classmark *dst, const struct osmo_gsm48_classmark *src); |
Pau Espin Pedrol | b99f4ca | 2019-10-31 13:35:22 +0100 | [diff] [blame] | 78 | int8_t osmo_gsm48_rfpowercap2powerclass(enum gsm_band band, uint8_t rf_power_cap); |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 79 | /* Chapter 10.5.2.1b.3 */ |
Ruben Undheim | 720ac4a | 2016-05-27 22:03:59 +0200 | [diff] [blame] | 80 | #if OSMO_IS_LITTLE_ENDIAN == 1 |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 81 | struct gsm48_range_1024 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 82 | #if OSMO_IS_LITTLE_ENDIAN |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 83 | uint8_t w1_hi:2, |
| 84 | f0:1, |
| 85 | form_id:5; |
| 86 | uint8_t w1_lo; |
| 87 | uint8_t w2_hi; |
| 88 | uint8_t w3_hi:7, |
| 89 | w2_lo:1; |
| 90 | uint8_t w4_hi:6, |
| 91 | w3_lo:2; |
| 92 | uint8_t w5_hi:6, |
| 93 | w4_lo:2; |
| 94 | uint8_t w6_hi:6, |
| 95 | w5_lo:2; |
| 96 | uint8_t w7_hi:6, |
| 97 | w6_lo:2; |
| 98 | uint8_t w8_hi:6, |
| 99 | w7_lo:2; |
| 100 | uint8_t w9:7, |
| 101 | w8_lo:1; |
| 102 | uint8_t w11_hi:1, |
| 103 | w10:7; |
| 104 | uint8_t w12_hi:2, |
| 105 | w11_lo:6; |
| 106 | uint8_t w13_hi:3, |
| 107 | w12_lo:5; |
| 108 | uint8_t w14_hi:4, |
| 109 | w13_lo:4; |
| 110 | uint8_t w15_hi:5, |
| 111 | w14_lo:3; |
| 112 | uint8_t w16:6, |
| 113 | w15_lo:2; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 114 | #elif OSMO_IS_BIG_ENDIAN |
| 115 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 116 | uint8_t form_id:5, f0:1, w1_hi:2; |
| 117 | uint8_t w1_lo; |
| 118 | uint8_t w2_hi; |
| 119 | uint8_t w2_lo:1, w3_hi:7; |
| 120 | uint8_t w3_lo:2, w4_hi:6; |
| 121 | uint8_t w4_lo:2, w5_hi:6; |
| 122 | uint8_t w5_lo:2, w6_hi:6; |
| 123 | uint8_t w6_lo:2, w7_hi:6; |
| 124 | uint8_t w7_lo:2, w8_hi:6; |
| 125 | uint8_t w8_lo:1, w9:7; |
| 126 | uint8_t w10:7, w11_hi:1; |
| 127 | uint8_t w11_lo:6, w12_hi:2; |
| 128 | uint8_t w12_lo:5, w13_hi:3; |
| 129 | uint8_t w13_lo:4, w14_hi:4; |
| 130 | uint8_t w14_lo:3, w15_hi:5; |
| 131 | uint8_t w15_lo:2, w16:6; |
| 132 | #endif |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 133 | } __attribute__ ((packed)); |
Ruben Undheim | 720ac4a | 2016-05-27 22:03:59 +0200 | [diff] [blame] | 134 | #else |
| 135 | struct gsm48_range_1024 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 136 | #if OSMO_IS_LITTLE_ENDIAN |
Ruben Undheim | 720ac4a | 2016-05-27 22:03:59 +0200 | [diff] [blame] | 137 | uint8_t form_id:5, |
| 138 | f0:1, |
| 139 | w1_hi:2; |
| 140 | uint8_t w1_lo; |
| 141 | uint8_t w2_hi; |
| 142 | uint8_t w2_lo:1, |
| 143 | w3_hi:7; |
| 144 | uint8_t w3_lo:2, |
| 145 | w4_hi:6; |
| 146 | uint8_t w4_lo:2, |
| 147 | w5_hi:6; |
| 148 | uint8_t w5_lo:2, |
| 149 | w6_hi:6; |
| 150 | uint8_t w6_lo:2, |
| 151 | w7_hi:6; |
| 152 | uint8_t w7_lo:2, |
| 153 | w8_hi:6; |
| 154 | uint8_t w8_lo:1, |
| 155 | w9:7; |
| 156 | uint8_t w10:7, |
| 157 | w11_hi:1; |
| 158 | uint8_t w11_lo:6, |
| 159 | w12_hi:2; |
| 160 | uint8_t w12_lo:5, |
| 161 | w13_hi:3; |
| 162 | uint8_t w13_lo:4, |
| 163 | w14_hi:4; |
| 164 | uint8_t w14_lo:3, |
| 165 | w15_hi:5; |
| 166 | uint8_t w15_lo:2, |
| 167 | w16:6; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 168 | #elif OSMO_IS_BIG_ENDIAN |
| 169 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 170 | uint8_t w1_hi:2, f0:1, form_id:5; |
| 171 | uint8_t w1_lo; |
| 172 | uint8_t w2_hi; |
| 173 | uint8_t w3_hi:7, w2_lo:1; |
| 174 | uint8_t w4_hi:6, w3_lo:2; |
| 175 | uint8_t w5_hi:6, w4_lo:2; |
| 176 | uint8_t w6_hi:6, w5_lo:2; |
| 177 | uint8_t w7_hi:6, w6_lo:2; |
| 178 | uint8_t w8_hi:6, w7_lo:2; |
| 179 | uint8_t w9:7, w8_lo:1; |
| 180 | uint8_t w11_hi:1, w10:7; |
| 181 | uint8_t w12_hi:2, w11_lo:6; |
| 182 | uint8_t w13_hi:3, w12_lo:5; |
| 183 | uint8_t w14_hi:4, w13_lo:4; |
| 184 | uint8_t w15_hi:5, w14_lo:3; |
| 185 | uint8_t w16:6, w15_lo:2; |
| 186 | #endif |
Ruben Undheim | 720ac4a | 2016-05-27 22:03:59 +0200 | [diff] [blame] | 187 | } __attribute__ ((packed)); |
| 188 | #endif |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 189 | |
| 190 | /* Chapter 10.5.2.1b.4 */ |
Ruben Undheim | 720ac4a | 2016-05-27 22:03:59 +0200 | [diff] [blame] | 191 | #if OSMO_IS_LITTLE_ENDIAN == 1 |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 192 | struct gsm48_range_512 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 193 | #if OSMO_IS_LITTLE_ENDIAN |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 194 | uint8_t orig_arfcn_hi:1, |
| 195 | form_id:7; |
| 196 | uint8_t orig_arfcn_mid; |
| 197 | uint8_t w1_hi:7, |
| 198 | orig_arfcn_lo:1; |
| 199 | uint8_t w2_hi:6, |
| 200 | w1_lo:2; |
| 201 | uint8_t w3_hi:6, |
| 202 | w2_lo:2; |
| 203 | uint8_t w4_hi:6, |
| 204 | w3_lo:2; |
| 205 | uint8_t w5:7, |
| 206 | w4_lo:1; |
| 207 | uint8_t w7_hi:1, |
| 208 | w6:7; |
| 209 | uint8_t w8_hi:2, |
| 210 | w7_lo:6; |
| 211 | uint8_t w9_hi:4, |
| 212 | w8_lo:4; |
| 213 | uint8_t w10:6, |
| 214 | w9_lo:2; |
| 215 | uint8_t w12_hi:2, |
| 216 | w11:6; |
| 217 | uint8_t w13_hi:4, |
| 218 | w12_lo:4; |
| 219 | uint8_t w14:6, |
| 220 | w13_lo:2; |
| 221 | uint8_t w16_hi:2, |
| 222 | w15:6; |
| 223 | uint8_t w17:5, |
| 224 | w16_lo:3; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 225 | #elif OSMO_IS_BIG_ENDIAN |
| 226 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 227 | uint8_t form_id:7, orig_arfcn_hi:1; |
| 228 | uint8_t orig_arfcn_mid; |
| 229 | uint8_t orig_arfcn_lo:1, w1_hi:7; |
| 230 | uint8_t w1_lo:2, w2_hi:6; |
| 231 | uint8_t w2_lo:2, w3_hi:6; |
| 232 | uint8_t w3_lo:2, w4_hi:6; |
| 233 | uint8_t w4_lo:1, w5:7; |
| 234 | uint8_t w6:7, w7_hi:1; |
| 235 | uint8_t w7_lo:6, w8_hi:2; |
| 236 | uint8_t w8_lo:4, w9_hi:4; |
| 237 | uint8_t w9_lo:2, w10:6; |
| 238 | uint8_t w11:6, w12_hi:2; |
| 239 | uint8_t w12_lo:4, w13_hi:4; |
| 240 | uint8_t w13_lo:2, w14:6; |
| 241 | uint8_t w15:6, w16_hi:2; |
| 242 | uint8_t w16_lo:3, w17:5; |
| 243 | #endif |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 244 | } __attribute__ ((packed)); |
Ruben Undheim | 720ac4a | 2016-05-27 22:03:59 +0200 | [diff] [blame] | 245 | #else |
| 246 | struct gsm48_range_512 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 247 | #if OSMO_IS_LITTLE_ENDIAN |
Ruben Undheim | 720ac4a | 2016-05-27 22:03:59 +0200 | [diff] [blame] | 248 | uint8_t form_id:7, |
| 249 | orig_arfcn_hi:1; |
| 250 | uint8_t orig_arfcn_mid; |
| 251 | uint8_t orig_arfcn_lo:1, |
| 252 | w1_hi:7; |
| 253 | uint8_t w1_lo:2, |
| 254 | w2_hi:6; |
| 255 | uint8_t w2_lo:2, |
| 256 | w3_hi:6; |
| 257 | uint8_t w3_lo:2, |
| 258 | w4_hi:6; |
| 259 | uint8_t w4_lo:1, |
| 260 | w5:7; |
| 261 | uint8_t w6:7, |
| 262 | w7_hi:1; |
| 263 | uint8_t w7_lo:6, |
| 264 | w8_hi:2; |
| 265 | uint8_t w8_lo:4, |
| 266 | w9_hi:4; |
| 267 | uint8_t w9_lo:2, |
| 268 | w10:6; |
| 269 | uint8_t w11:6, |
| 270 | w12_hi:2; |
| 271 | uint8_t w12_lo:4, |
| 272 | w13_hi:4; |
| 273 | uint8_t w13_lo:2, |
| 274 | w14:6; |
| 275 | uint8_t w15:6, |
| 276 | w16_hi:2; |
| 277 | uint8_t w16_lo:3, |
| 278 | w17:5; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 279 | #elif OSMO_IS_BIG_ENDIAN |
| 280 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 281 | uint8_t orig_arfcn_hi:1, form_id:7; |
| 282 | uint8_t orig_arfcn_mid; |
| 283 | uint8_t w1_hi:7, orig_arfcn_lo:1; |
| 284 | uint8_t w2_hi:6, w1_lo:2; |
| 285 | uint8_t w3_hi:6, w2_lo:2; |
| 286 | uint8_t w4_hi:6, w3_lo:2; |
| 287 | uint8_t w5:7, w4_lo:1; |
| 288 | uint8_t w7_hi:1, w6:7; |
| 289 | uint8_t w8_hi:2, w7_lo:6; |
| 290 | uint8_t w9_hi:4, w8_lo:4; |
| 291 | uint8_t w10:6, w9_lo:2; |
| 292 | uint8_t w12_hi:2, w11:6; |
| 293 | uint8_t w13_hi:4, w12_lo:4; |
| 294 | uint8_t w14:6, w13_lo:2; |
| 295 | uint8_t w16_hi:2, w15:6; |
| 296 | uint8_t w17:5, w16_lo:3; |
| 297 | #endif |
Ruben Undheim | 720ac4a | 2016-05-27 22:03:59 +0200 | [diff] [blame] | 298 | } __attribute__ ((packed)); |
| 299 | #endif |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 300 | |
| 301 | /* Chapter 10.5.2.1b.5 */ |
Ruben Undheim | 720ac4a | 2016-05-27 22:03:59 +0200 | [diff] [blame] | 302 | #if OSMO_IS_LITTLE_ENDIAN == 1 |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 303 | struct gsm48_range_256 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 304 | #if OSMO_IS_LITTLE_ENDIAN |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 305 | uint8_t orig_arfcn_hi:1, |
| 306 | form_id:7; |
| 307 | uint8_t orig_arfcn_mid; |
| 308 | uint8_t w1_hi:7, |
| 309 | orig_arfcn_lo:1; |
| 310 | uint8_t w2:7, |
| 311 | w1_lo:1; |
| 312 | uint8_t w4_hi:1, |
| 313 | w3:7; |
| 314 | uint8_t w5_hi:3, |
| 315 | w4_lo:5; |
| 316 | uint8_t w6_hi:5, |
| 317 | w5_lo:3; |
| 318 | uint8_t w8_hi:1, |
| 319 | w7:6, |
| 320 | w6_lo:1; |
| 321 | uint8_t w9_hi:4, |
| 322 | w8_lo:4; |
| 323 | uint8_t w11_hi:2, |
| 324 | w10:5, |
| 325 | w9_lo:1; |
| 326 | uint8_t w12:5, |
| 327 | w11_lo:3; |
| 328 | uint8_t w14_hi:3, |
| 329 | w13:5; |
| 330 | uint8_t w16_hi:1, |
| 331 | w15:5, |
| 332 | w14_lo:2; |
| 333 | uint8_t w18_hi:1, |
| 334 | w17:4, |
| 335 | w16_lo:3; |
| 336 | uint8_t w20_hi:1, |
| 337 | w19:4, |
| 338 | w18_lo:3; |
| 339 | uint8_t spare:1, |
| 340 | w21:4, |
| 341 | w20_lo:3; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 342 | #elif OSMO_IS_BIG_ENDIAN |
| 343 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 344 | uint8_t form_id:7, orig_arfcn_hi:1; |
| 345 | uint8_t orig_arfcn_mid; |
| 346 | uint8_t orig_arfcn_lo:1, w1_hi:7; |
| 347 | uint8_t w1_lo:1, w2:7; |
| 348 | uint8_t w3:7, w4_hi:1; |
| 349 | uint8_t w4_lo:5, w5_hi:3; |
| 350 | uint8_t w5_lo:3, w6_hi:5; |
| 351 | uint8_t w6_lo:1, w7:6, w8_hi:1; |
| 352 | uint8_t w8_lo:4, w9_hi:4; |
| 353 | uint8_t w9_lo:1, w10:5, w11_hi:2; |
| 354 | uint8_t w11_lo:3, w12:5; |
| 355 | uint8_t w13:5, w14_hi:3; |
| 356 | uint8_t w14_lo:2, w15:5, w16_hi:1; |
| 357 | uint8_t w16_lo:3, w17:4, w18_hi:1; |
| 358 | uint8_t w18_lo:3, w19:4, w20_hi:1; |
| 359 | uint8_t w20_lo:3, w21:4, spare:1; |
| 360 | #endif |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 361 | } __attribute__ ((packed)); |
Ruben Undheim | 720ac4a | 2016-05-27 22:03:59 +0200 | [diff] [blame] | 362 | #else |
| 363 | struct gsm48_range_256 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 364 | #if OSMO_IS_LITTLE_ENDIAN |
Ruben Undheim | 720ac4a | 2016-05-27 22:03:59 +0200 | [diff] [blame] | 365 | uint8_t form_id:7, |
| 366 | orig_arfcn_hi:1; |
| 367 | uint8_t orig_arfcn_mid; |
| 368 | uint8_t orig_arfcn_lo:1, |
| 369 | w1_hi:7; |
| 370 | uint8_t w1_lo:1, |
| 371 | w2:7; |
| 372 | uint8_t w3:7, |
| 373 | w4_hi:1; |
| 374 | uint8_t w4_lo:5, |
| 375 | w5_hi:3; |
| 376 | uint8_t w5_lo:3, |
| 377 | w6_hi:5; |
| 378 | uint8_t w6_lo:1, |
| 379 | w7:6, |
| 380 | w8_hi:1; |
| 381 | uint8_t w8_lo:4, |
| 382 | w9_hi:4; |
| 383 | uint8_t w9_lo:1, |
| 384 | w10:5, |
| 385 | w11_hi:2; |
| 386 | uint8_t w11_lo:3, |
| 387 | w12:5; |
| 388 | uint8_t w13:5, |
| 389 | w14_hi:3; |
| 390 | uint8_t w14_lo:2, |
| 391 | w15:5, |
| 392 | w16_hi:1; |
| 393 | uint8_t w16_lo:3, |
| 394 | w17:4, |
| 395 | w18_hi:1; |
| 396 | uint8_t w18_lo:3, |
| 397 | w19:4, |
| 398 | w20_hi:1; |
| 399 | uint8_t w20_lo:3, |
| 400 | w21:4, |
| 401 | spare:1; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 402 | #elif OSMO_IS_BIG_ENDIAN |
| 403 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 404 | uint8_t orig_arfcn_hi:1, form_id:7; |
| 405 | uint8_t orig_arfcn_mid; |
| 406 | uint8_t w1_hi:7, orig_arfcn_lo:1; |
| 407 | uint8_t w2:7, w1_lo:1; |
| 408 | uint8_t w4_hi:1, w3:7; |
| 409 | uint8_t w5_hi:3, w4_lo:5; |
| 410 | uint8_t w6_hi:5, w5_lo:3; |
| 411 | uint8_t w8_hi:1, w7:6, w6_lo:1; |
| 412 | uint8_t w9_hi:4, w8_lo:4; |
| 413 | uint8_t w11_hi:2, w10:5, w9_lo:1; |
| 414 | uint8_t w12:5, w11_lo:3; |
| 415 | uint8_t w14_hi:3, w13:5; |
| 416 | uint8_t w16_hi:1, w15:5, w14_lo:2; |
| 417 | uint8_t w18_hi:1, w17:4, w16_lo:3; |
| 418 | uint8_t w20_hi:1, w19:4, w18_lo:3; |
| 419 | uint8_t spare:1, w21:4, w20_lo:3; |
| 420 | #endif |
Ruben Undheim | 720ac4a | 2016-05-27 22:03:59 +0200 | [diff] [blame] | 421 | } __attribute__ ((packed)); |
| 422 | #endif |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 423 | |
| 424 | /* Chapter 10.5.2.1b.6 */ |
Ruben Undheim | 720ac4a | 2016-05-27 22:03:59 +0200 | [diff] [blame] | 425 | #if OSMO_IS_LITTLE_ENDIAN == 1 |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 426 | struct gsm48_range_128 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 427 | #if OSMO_IS_LITTLE_ENDIAN |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 428 | uint8_t orig_arfcn_hi:1, |
| 429 | form_id:7; |
| 430 | uint8_t orig_arfcn_mid; |
| 431 | uint8_t w1:7, |
| 432 | orig_arfcn_lo:1; |
| 433 | uint8_t w3_hi:2, |
| 434 | w2:6; |
| 435 | uint8_t w4_hi:4, |
| 436 | w3_lo:4; |
| 437 | uint8_t w6_hi:2, |
| 438 | w5:5, |
| 439 | w4_lo:1; |
| 440 | uint8_t w7:5, |
| 441 | w6_lo:3; |
| 442 | uint8_t w9:4, |
| 443 | w8:4; |
| 444 | uint8_t w11:4, |
| 445 | w10:4; |
| 446 | uint8_t w13:4, |
| 447 | w12:4; |
| 448 | uint8_t w15:4, |
| 449 | w14:4; |
| 450 | uint8_t w18_hi:2, |
| 451 | w17:3, |
| 452 | w16:3; |
| 453 | uint8_t w21_hi:1, |
| 454 | w20:3, |
| 455 | w19:3, |
| 456 | w18_lo:1; |
| 457 | uint8_t w23:3, |
| 458 | w22:3, |
| 459 | w21_lo:2; |
| 460 | uint8_t w26_hi:2, |
| 461 | w25:3, |
| 462 | w24:3; |
| 463 | uint8_t spare:1, |
| 464 | w28:3, |
| 465 | w27:3, |
| 466 | w26_lo:1; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 467 | #elif OSMO_IS_BIG_ENDIAN |
| 468 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 469 | uint8_t form_id:7, orig_arfcn_hi:1; |
| 470 | uint8_t orig_arfcn_mid; |
| 471 | uint8_t orig_arfcn_lo:1, w1:7; |
| 472 | uint8_t w2:6, w3_hi:2; |
| 473 | uint8_t w3_lo:4, w4_hi:4; |
| 474 | uint8_t w4_lo:1, w5:5, w6_hi:2; |
| 475 | uint8_t w6_lo:3, w7:5; |
| 476 | uint8_t w8:4, w9:4; |
| 477 | uint8_t w10:4, w11:4; |
| 478 | uint8_t w12:4, w13:4; |
| 479 | uint8_t w14:4, w15:4; |
| 480 | uint8_t w16:3, w17:3, w18_hi:2; |
| 481 | uint8_t w18_lo:1, w19:3, w20:3, w21_hi:1; |
| 482 | uint8_t w21_lo:2, w22:3, w23:3; |
| 483 | uint8_t w24:3, w25:3, w26_hi:2; |
| 484 | uint8_t w26_lo:1, w27:3, w28:3, spare:1; |
| 485 | #endif |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 486 | } __attribute__ ((packed)); |
Ruben Undheim | 720ac4a | 2016-05-27 22:03:59 +0200 | [diff] [blame] | 487 | #else |
| 488 | struct gsm48_range_128 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 489 | #if OSMO_IS_LITTLE_ENDIAN |
Ruben Undheim | 720ac4a | 2016-05-27 22:03:59 +0200 | [diff] [blame] | 490 | uint8_t form_id:7, |
| 491 | orig_arfcn_hi:1; |
| 492 | uint8_t orig_arfcn_mid; |
| 493 | uint8_t orig_arfcn_lo:1, |
| 494 | w1:7; |
| 495 | uint8_t w2:6, |
| 496 | w3_hi:2; |
| 497 | uint8_t w3_lo:4, |
| 498 | w4_hi:4; |
| 499 | uint8_t w4_lo:1, |
| 500 | w5:5, |
| 501 | w6_hi:2; |
| 502 | uint8_t w6_lo:3, |
| 503 | w7:5; |
| 504 | uint8_t w8:4, |
| 505 | w9:4; |
| 506 | uint8_t w10:4, |
| 507 | w11:4; |
| 508 | uint8_t w12:4, |
| 509 | w13:4; |
| 510 | uint8_t w14:4, |
| 511 | w15:4; |
| 512 | uint8_t w16:3, |
| 513 | w17:3, |
| 514 | w18_hi:2; |
| 515 | uint8_t w18_lo:1, |
| 516 | w19:3, |
| 517 | w20:3, |
| 518 | w21_hi:1; |
| 519 | uint8_t w21_lo:2, |
| 520 | w22:3, |
| 521 | w23:3; |
| 522 | uint8_t w24:3, |
| 523 | w25:3, |
| 524 | w26_hi:2; |
| 525 | uint8_t w26_lo:1, |
| 526 | w27:3, |
| 527 | w28:3, |
| 528 | spare:1; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 529 | #elif OSMO_IS_BIG_ENDIAN |
| 530 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 531 | uint8_t orig_arfcn_hi:1, form_id:7; |
| 532 | uint8_t orig_arfcn_mid; |
| 533 | uint8_t w1:7, orig_arfcn_lo:1; |
| 534 | uint8_t w3_hi:2, w2:6; |
| 535 | uint8_t w4_hi:4, w3_lo:4; |
| 536 | uint8_t w6_hi:2, w5:5, w4_lo:1; |
| 537 | uint8_t w7:5, w6_lo:3; |
| 538 | uint8_t w9:4, w8:4; |
| 539 | uint8_t w11:4, w10:4; |
| 540 | uint8_t w13:4, w12:4; |
| 541 | uint8_t w15:4, w14:4; |
| 542 | uint8_t w18_hi:2, w17:3, w16:3; |
| 543 | uint8_t w21_hi:1, w20:3, w19:3, w18_lo:1; |
| 544 | uint8_t w23:3, w22:3, w21_lo:2; |
| 545 | uint8_t w26_hi:2, w25:3, w24:3; |
| 546 | uint8_t spare:1, w28:3, w27:3, w26_lo:1; |
| 547 | #endif |
Ruben Undheim | 720ac4a | 2016-05-27 22:03:59 +0200 | [diff] [blame] | 548 | } __attribute__ ((packed)); |
| 549 | #endif |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 550 | |
| 551 | /* Chapter 10.5.2.1b.7 */ |
| 552 | struct gsm48_var_bit { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 553 | #if OSMO_IS_LITTLE_ENDIAN |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 554 | uint8_t orig_arfcn_hi:1, |
| 555 | form_id:7; |
| 556 | uint8_t orig_arfcn_mid; |
| 557 | uint8_t rrfcn1_7:7, |
| 558 | orig_arfcn_lo:1; |
| 559 | uint8_t rrfcn8_111[13]; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 560 | #elif OSMO_IS_BIG_ENDIAN |
| 561 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 562 | uint8_t form_id:7, orig_arfcn_hi:1; |
| 563 | uint8_t orig_arfcn_mid; |
| 564 | uint8_t orig_arfcn_lo:1, rrfcn1_7:7; |
| 565 | uint8_t rrfcn8_111[13]; |
| 566 | #endif |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 567 | } __attribute__ ((packed)); |
| 568 | |
| 569 | /* Chapter 10.5.2.5 */ |
| 570 | struct gsm48_chan_desc { |
| 571 | uint8_t chan_nr; |
| 572 | union { |
| 573 | struct { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 574 | #if OSMO_IS_LITTLE_ENDIAN |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 575 | uint8_t maio_high:4, |
| 576 | h:1, |
| 577 | tsc:3; |
| 578 | uint8_t hsn:6, |
| 579 | maio_low:2; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 580 | #elif OSMO_IS_BIG_ENDIAN |
| 581 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 582 | uint8_t tsc:3, h:1, maio_high:4; |
| 583 | uint8_t maio_low:2, hsn:6; |
| 584 | #endif |
Andreas Eversberg | 4b332d7 | 2012-02-07 20:02:17 +0100 | [diff] [blame] | 585 | } __attribute__ ((packed)) h1; |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 586 | struct { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 587 | #if OSMO_IS_LITTLE_ENDIAN |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 588 | uint8_t arfcn_high:2, |
| 589 | spare:2, |
| 590 | h:1, |
| 591 | tsc:3; |
| 592 | uint8_t arfcn_low; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 593 | #elif OSMO_IS_BIG_ENDIAN |
| 594 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 595 | uint8_t tsc:3, h:1, spare:2, arfcn_high:2; |
| 596 | uint8_t arfcn_low; |
| 597 | #endif |
Andreas Eversberg | 4b332d7 | 2012-02-07 20:02:17 +0100 | [diff] [blame] | 598 | } __attribute__ ((packed)) h0; |
| 599 | } __attribute__ ((packed)); |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 600 | } __attribute__ ((packed)); |
| 601 | |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 602 | /* Chapter 10.5.2.20 */ |
| 603 | struct gsm48_meas_res { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 604 | #if OSMO_IS_LITTLE_ENDIAN |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 605 | uint8_t rxlev_full:6, |
| 606 | dtx_used:1, |
| 607 | ba_used:1; |
| 608 | uint8_t rxlev_sub:6, |
| 609 | meas_valid:1, |
| 610 | spare:1; |
| 611 | uint8_t no_nc_n_hi:1, |
| 612 | rxqual_sub:3, |
| 613 | rxqual_full:3, |
| 614 | spare2:1; |
| 615 | uint8_t rxlev_nc1:6, |
| 616 | no_nc_n_lo:2; |
| 617 | uint8_t bsic_nc1_hi:3, |
| 618 | bcch_f_nc1:5; |
| 619 | uint8_t rxlev_nc2_hi:5, |
| 620 | bsic_nc1_lo:3; |
| 621 | uint8_t bsic_nc2_hi:2, |
| 622 | bcch_f_nc2:5, |
| 623 | rxlev_nc2_lo:1; |
| 624 | uint8_t rxlev_nc3_hi:4, |
| 625 | bsic_nc2_lo:4; |
| 626 | uint8_t bsic_nc3_hi:1, |
| 627 | bcch_f_nc3:5, |
| 628 | rxlev_nc3_lo:2; |
| 629 | uint8_t rxlev_nc4_hi:3, |
| 630 | bsic_nc3_lo:5; |
| 631 | uint8_t bcch_f_nc4:5, |
| 632 | rxlev_nc4_lo:3; |
| 633 | uint8_t rxlev_nc5_hi:2, |
| 634 | bsic_nc4:6; |
| 635 | uint8_t bcch_f_nc5_hi:4, |
| 636 | rxlev_nc5_lo:4; |
| 637 | uint8_t rxlev_nc6_hi:1, |
| 638 | bsic_nc5:6, |
| 639 | bcch_f_nc5_lo:1; |
| 640 | uint8_t bcch_f_nc6_hi:3, |
| 641 | rxlev_nc6_lo:5; |
| 642 | uint8_t bsic_nc6:6, |
| 643 | bcch_f_nc6_lo:2; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 644 | #elif OSMO_IS_BIG_ENDIAN |
| 645 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 646 | uint8_t ba_used:1, dtx_used:1, rxlev_full:6; |
| 647 | uint8_t spare:1, meas_valid:1, rxlev_sub:6; |
| 648 | uint8_t spare2:1, rxqual_full:3, rxqual_sub:3, no_nc_n_hi:1; |
| 649 | uint8_t no_nc_n_lo:2, rxlev_nc1:6; |
| 650 | uint8_t bcch_f_nc1:5, bsic_nc1_hi:3; |
| 651 | uint8_t bsic_nc1_lo:3, rxlev_nc2_hi:5; |
| 652 | uint8_t rxlev_nc2_lo:1, bcch_f_nc2:5, bsic_nc2_hi:2; |
| 653 | uint8_t bsic_nc2_lo:4, rxlev_nc3_hi:4; |
| 654 | uint8_t rxlev_nc3_lo:2, bcch_f_nc3:5, bsic_nc3_hi:1; |
| 655 | uint8_t bsic_nc3_lo:5, rxlev_nc4_hi:3; |
| 656 | uint8_t rxlev_nc4_lo:3, bcch_f_nc4:5; |
| 657 | uint8_t bsic_nc4:6, rxlev_nc5_hi:2; |
| 658 | uint8_t rxlev_nc5_lo:4, bcch_f_nc5_hi:4; |
| 659 | uint8_t bcch_f_nc5_lo:1, bsic_nc5:6, rxlev_nc6_hi:1; |
| 660 | uint8_t rxlev_nc6_lo:5, bcch_f_nc6_hi:3; |
| 661 | uint8_t bcch_f_nc6_lo:2, bsic_nc6:6; |
| 662 | #endif |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 663 | } __attribute__ ((packed)); |
| 664 | |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 665 | /* Chapter 10.5.2.21aa */ |
| 666 | struct gsm48_multi_rate_conf { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 667 | #if OSMO_IS_LITTLE_ENDIAN |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 668 | uint8_t smod : 2, |
| 669 | spare: 1, |
| 670 | icmi : 1, |
| 671 | nscb : 1, |
| 672 | ver : 3; |
| 673 | uint8_t m4_75 : 1, |
| 674 | m5_15 : 1, |
| 675 | m5_90 : 1, |
| 676 | m6_70 : 1, |
| 677 | m7_40 : 1, |
| 678 | m7_95 : 1, |
| 679 | m10_2 : 1, |
| 680 | m12_2 : 1; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 681 | #elif OSMO_IS_BIG_ENDIAN |
| 682 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 683 | uint8_t ver:3, nscb:1, icmi:1, spare:1, smod:2; |
| 684 | 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; |
| 685 | #endif |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 686 | } __attribute__((packed)); |
| 687 | |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 688 | /* Chapter 10.5.2.28(a) */ |
| 689 | struct gsm48_power_cmd { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 690 | #if OSMO_IS_LITTLE_ENDIAN |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 691 | uint8_t power_level:5, |
| 692 | spare:2, |
| 693 | atc:1; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 694 | #elif OSMO_IS_BIG_ENDIAN |
| 695 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 696 | uint8_t atc:1, spare:2, power_level:5; |
| 697 | #endif |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 698 | } __attribute__((packed)); |
| 699 | |
| 700 | /* Chapter 10.5.2.29 */ |
| 701 | struct gsm48_rach_control { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 702 | #if OSMO_IS_LITTLE_ENDIAN |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 703 | uint8_t re :1, |
| 704 | cell_bar :1, |
| 705 | tx_integer :4, |
| 706 | max_trans :2; |
Stefan Sperling | 1859515 | 2018-02-06 13:20:23 +0100 | [diff] [blame] | 707 | uint8_t t2; /* ACC 8-15 barred flags */ |
| 708 | uint8_t t3; /* ACC 0-7 barred flags */ |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 709 | #elif OSMO_IS_BIG_ENDIAN |
| 710 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 711 | uint8_t max_trans:2, tx_integer:4, cell_bar:1, re:1; |
| 712 | uint8_t t2; |
| 713 | uint8_t t3; |
| 714 | #endif |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 715 | } __attribute__ ((packed)); |
| 716 | |
Stefan Sperling | 1859515 | 2018-02-06 13:20:23 +0100 | [diff] [blame] | 717 | /* |
| 718 | * Mark an Access Control Class as barred. |
| 719 | * \param[in] rach_control A Rach Control Information Element. |
| 720 | * \param[in] acc Access Control Class number (0 - 15) which shall be barred. |
| 721 | */ |
| 722 | static inline void gsm48_barr_acc(struct gsm48_rach_control *rach_control, unsigned int acc) |
| 723 | { |
Vadim Yanitskiy | b8734ba | 2019-06-12 15:50:57 +0700 | [diff] [blame] | 724 | OSMO_ASSERT(acc <= 15); |
Stefan Sperling | 1859515 | 2018-02-06 13:20:23 +0100 | [diff] [blame] | 725 | if (acc >= 8) |
| 726 | rach_control->t2 |= (1 << (acc - 8)); |
| 727 | else |
| 728 | rach_control->t3 |= (1 << (acc)); |
| 729 | } |
| 730 | |
| 731 | /* |
| 732 | * Mark an Access Control Class as allowed. |
| 733 | * \param[in] rach_control A Rach Control Information Element. |
| 734 | * \param[in] acc Access Control Class number (0 - 15) which shall be allowed. |
| 735 | */ |
| 736 | static inline void gsm48_allow_acc(struct gsm48_rach_control *rach_control, unsigned int acc) |
| 737 | { |
Vadim Yanitskiy | b8734ba | 2019-06-12 15:50:57 +0700 | [diff] [blame] | 738 | OSMO_ASSERT(acc <= 15); |
Stefan Sperling | 1859515 | 2018-02-06 13:20:23 +0100 | [diff] [blame] | 739 | if (acc >= 8) |
| 740 | rach_control->t2 &= ~(1 << (acc - 8)); |
| 741 | else |
| 742 | rach_control->t3 &= ~(1 << (acc)); |
| 743 | } |
| 744 | |
| 745 | /* |
| 746 | * Indicate whether an Access Control Class is barred. |
| 747 | * \param[in] rach_control A Rach Control Information Element. |
| 748 | * \param[in] acc Access Control Class number (0 - 15). |
| 749 | * \returns true if the Access Control class is barred, false otherwise |
| 750 | */ |
| 751 | static inline bool gsm48_acc_is_barred(struct gsm48_rach_control *rach_control, unsigned int acc) |
| 752 | { |
Vadim Yanitskiy | b8734ba | 2019-06-12 15:50:57 +0700 | [diff] [blame] | 753 | OSMO_ASSERT(acc <= 15); |
Stefan Sperling | 1859515 | 2018-02-06 13:20:23 +0100 | [diff] [blame] | 754 | if (acc >= 8) |
| 755 | return (rach_control->t2 & (1 << (acc - 8))) != 0; |
| 756 | return (rach_control->t3 & (1 << (acc))) != 0; |
| 757 | } |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 758 | |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 759 | /* Chapter 10.5.2.30 */ |
| 760 | struct gsm48_req_ref { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 761 | #if OSMO_IS_LITTLE_ENDIAN |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 762 | uint8_t ra; |
| 763 | uint8_t t3_high:3, |
Andreas Eversberg | 93364fc | 2010-06-25 02:50:06 +0200 | [diff] [blame] | 764 | t1:5; |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 765 | uint8_t t2:5, |
| 766 | t3_low:3; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 767 | #elif OSMO_IS_BIG_ENDIAN |
| 768 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 769 | uint8_t ra; |
| 770 | uint8_t t1:5, t3_high:3; |
| 771 | uint8_t t3_low:3, t2:5; |
| 772 | #endif |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 773 | } __attribute__ ((packed)); |
| 774 | |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 775 | /* Chapter 10.5.2.38 */ |
| 776 | struct gsm48_start_time { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 777 | #if OSMO_IS_LITTLE_ENDIAN |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 778 | uint8_t t3_high:3, |
| 779 | t1:5; |
| 780 | uint8_t t2:5, |
| 781 | t3_low:3; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 782 | #elif OSMO_IS_BIG_ENDIAN |
| 783 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 784 | uint8_t t1:5, t3_high:3; |
| 785 | uint8_t t3_low:3, t2:5; |
| 786 | #endif |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 787 | } __attribute__ ((packed)); |
| 788 | |
| 789 | /* Chapter 10.5.2.39 */ |
| 790 | struct gsm48_sync_ind { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 791 | #if OSMO_IS_LITTLE_ENDIAN |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 792 | uint8_t si:2, |
| 793 | rot:1, |
| 794 | nci:1, |
| 795 | sync_ie:4; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 796 | #elif OSMO_IS_BIG_ENDIAN |
| 797 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 798 | uint8_t sync_ie:4, nci:1, rot:1, si:2; |
| 799 | #endif |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 800 | } __attribute__((packed)); |
| 801 | |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 802 | /* |
| 803 | * Chapter 9.1.5/9.1.6 |
| 804 | * |
| 805 | * For 9.1.6 the chan_desc has the meaning of 10.5.2.5a |
| 806 | */ |
| 807 | struct gsm48_chan_mode_modify { |
| 808 | struct gsm48_chan_desc chan_desc; |
| 809 | uint8_t mode; |
| 810 | } __attribute__ ((packed)); |
| 811 | |
| 812 | enum gsm48_chan_mode { |
| 813 | GSM48_CMODE_SIGN = 0x00, |
| 814 | GSM48_CMODE_SPEECH_V1 = 0x01, |
| 815 | GSM48_CMODE_SPEECH_EFR = 0x21, |
| 816 | GSM48_CMODE_SPEECH_AMR = 0x41, |
| 817 | GSM48_CMODE_DATA_14k5 = 0x0f, |
| 818 | GSM48_CMODE_DATA_12k0 = 0x03, |
| 819 | GSM48_CMODE_DATA_6k0 = 0x0b, |
Bhaskar | 31e844b | 2013-05-16 17:06:35 +0530 | [diff] [blame] | 820 | GSM48_CMODE_DATA_3k6 = 0x13, |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 821 | }; |
| 822 | |
Max | fb348ee | 2016-03-30 21:14:53 +0200 | [diff] [blame] | 823 | extern const struct value_string gsm48_chan_mode_names[]; |
Philipp Maier | 5796a21 | 2018-07-12 17:48:26 +0200 | [diff] [blame] | 824 | static inline const char *gsm48_chan_mode_name(enum gsm48_chan_mode val) |
| 825 | { return get_value_string(gsm48_chan_mode_names, val); } |
Max | fb348ee | 2016-03-30 21:14:53 +0200 | [diff] [blame] | 826 | |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 827 | /* Chapter 9.1.2 */ |
| 828 | struct gsm48_ass_cmd { |
| 829 | /* Semantic is from 10.5.2.5a */ |
| 830 | struct gsm48_chan_desc chan_desc; |
| 831 | uint8_t power_command; |
| 832 | uint8_t data[0]; |
| 833 | } __attribute__((packed)); |
| 834 | |
Andreas Eversberg | fa83201 | 2010-09-01 23:37:07 +0200 | [diff] [blame] | 835 | /* Chapter 9.1.13 */ |
| 836 | struct gsm48_frq_redef { |
| 837 | /* Semantic is from 10.5.2.5a */ |
| 838 | struct gsm48_chan_desc chan_desc; |
| 839 | uint8_t mob_alloc_len; |
| 840 | uint8_t mob_alloc[0]; |
| 841 | } __attribute__((packed)); |
| 842 | |
Harald Welte | 548e371 | 2017-07-10 22:32:08 +0200 | [diff] [blame] | 843 | /* Chapter 9.1.13b GPRS suspension request */ |
| 844 | struct gsm48_gprs_susp_req { |
| 845 | uint32_t tlli; |
| 846 | uint8_t ra_id[6]; |
| 847 | uint8_t cause; |
| 848 | uint8_t options[0]; |
| 849 | } __attribute__ ((packed)); |
| 850 | |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 851 | /* Chapter 10.5.2.2 */ |
| 852 | struct gsm48_cell_desc { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 853 | #if OSMO_IS_LITTLE_ENDIAN |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 854 | uint8_t bcc:3, |
| 855 | ncc:3, |
| 856 | arfcn_hi:2; |
| 857 | uint8_t arfcn_lo; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 858 | #elif OSMO_IS_BIG_ENDIAN |
| 859 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 860 | uint8_t arfcn_hi:2, ncc:3, bcc:3; |
| 861 | uint8_t arfcn_lo; |
| 862 | #endif |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 863 | } __attribute__((packed)); |
| 864 | |
| 865 | /* Chapter 9.1.15 */ |
| 866 | struct gsm48_ho_cmd { |
| 867 | struct gsm48_cell_desc cell_desc; |
| 868 | struct gsm48_chan_desc chan_desc; |
| 869 | uint8_t ho_ref; |
| 870 | uint8_t power_command; |
| 871 | uint8_t data[0]; |
| 872 | } __attribute__((packed)); |
| 873 | |
| 874 | /* Chapter 9.1.18 */ |
| 875 | struct gsm48_imm_ass { |
| 876 | uint8_t l2_plen; |
| 877 | uint8_t proto_discr; |
| 878 | uint8_t msg_type; |
| 879 | uint8_t page_mode; |
| 880 | struct gsm48_chan_desc chan_desc; |
| 881 | struct gsm48_req_ref req_ref; |
| 882 | uint8_t timing_advance; |
| 883 | uint8_t mob_alloc_len; |
| 884 | uint8_t mob_alloc[0]; |
| 885 | } __attribute__ ((packed)); |
| 886 | |
Holger Hans Peter Freyther | 5dcef3c | 2010-05-15 22:35:25 +0800 | [diff] [blame] | 887 | /* Chapter 9.1.25 */ |
| 888 | struct gsm48_pag_resp { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 889 | #if OSMO_IS_LITTLE_ENDIAN |
Holger Hans Peter Freyther | 5dcef3c | 2010-05-15 22:35:25 +0800 | [diff] [blame] | 890 | uint8_t spare:4, |
| 891 | key_seq:4; |
Pau Espin Pedrol | ba5a9b9 | 2019-11-04 15:41:32 +0100 | [diff] [blame] | 892 | union { |
| 893 | uint32_t classmark2; /* Backward compatibility */ |
| 894 | struct { |
| 895 | uint8_t cm2_len; |
| 896 | struct gsm48_classmark2 cm2; |
| 897 | }; |
| 898 | }; |
Holger Hans Peter Freyther | 5dcef3c | 2010-05-15 22:35:25 +0800 | [diff] [blame] | 899 | uint8_t mi_len; |
| 900 | uint8_t mi[0]; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 901 | #elif OSMO_IS_BIG_ENDIAN |
| 902 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 903 | uint8_t key_seq:4, spare:4; |
Pau Espin Pedrol | ba5a9b9 | 2019-11-04 15:41:32 +0100 | [diff] [blame] | 904 | union { |
| 905 | uint32_t classmark2; /* Backward compatibility */ |
| 906 | struct { |
| 907 | uint8_t cm2_len; |
| 908 | struct gsm48_classmark2 cm2; |
| 909 | }; |
| 910 | }; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 911 | uint8_t mi_len; |
| 912 | uint8_t mi[0]; |
| 913 | #endif |
Holger Hans Peter Freyther | 5dcef3c | 2010-05-15 22:35:25 +0800 | [diff] [blame] | 914 | } __attribute__ ((packed)); |
| 915 | |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 916 | /* Chapter 10.5.1.3 */ |
| 917 | struct gsm48_loc_area_id { |
| 918 | uint8_t digits[3]; /* BCD! */ |
| 919 | uint16_t lac; |
| 920 | } __attribute__ ((packed)); |
| 921 | |
| 922 | /* Section 9.2.2 */ |
| 923 | struct gsm48_auth_req { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 924 | #if OSMO_IS_LITTLE_ENDIAN |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 925 | uint8_t key_seq:4, |
| 926 | spare:4; |
| 927 | uint8_t rand[16]; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 928 | #elif OSMO_IS_BIG_ENDIAN |
| 929 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 930 | uint8_t spare:4, key_seq:4; |
| 931 | uint8_t rand[16]; |
| 932 | #endif |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 933 | } __attribute__ ((packed)); |
| 934 | |
Sylvain Munaut | d005eab | 2010-06-10 13:30:50 +0200 | [diff] [blame] | 935 | /* Section 9.2.3 */ |
| 936 | struct gsm48_auth_resp { |
| 937 | uint8_t sres[4]; |
| 938 | } __attribute__ ((packed)); |
| 939 | |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 940 | /* Section 9.2.15 */ |
| 941 | struct gsm48_loc_upd_req { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 942 | #if OSMO_IS_LITTLE_ENDIAN |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 943 | uint8_t type:4, |
| 944 | key_seq:4; |
| 945 | struct gsm48_loc_area_id lai; |
| 946 | struct gsm48_classmark1 classmark1; |
| 947 | uint8_t mi_len; |
| 948 | uint8_t mi[0]; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 949 | #elif OSMO_IS_BIG_ENDIAN |
| 950 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 951 | uint8_t key_seq:4, type:4; |
| 952 | struct gsm48_loc_area_id lai; |
| 953 | struct gsm48_classmark1 classmark1; |
| 954 | uint8_t mi_len; |
| 955 | uint8_t mi[0]; |
| 956 | #endif |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 957 | } __attribute__ ((packed)); |
| 958 | |
| 959 | /* Section 10.1 */ |
| 960 | struct gsm48_hdr { |
| 961 | uint8_t proto_discr; |
| 962 | uint8_t msg_type; |
| 963 | uint8_t data[0]; |
| 964 | } __attribute__ ((packed)); |
| 965 | |
| 966 | /* Section 9.1.3x System information Type header */ |
| 967 | struct gsm48_system_information_type_header { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 968 | #if OSMO_IS_LITTLE_ENDIAN |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 969 | uint8_t l2_plen; |
| 970 | uint8_t rr_protocol_discriminator :4, |
Pau Espin Pedrol | ab6d6cf | 2019-10-31 13:34:57 +0100 | [diff] [blame] | 971 | skip_indicator:4; |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 972 | uint8_t system_information; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 973 | #elif OSMO_IS_BIG_ENDIAN |
| 974 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 975 | uint8_t l2_plen; |
| 976 | uint8_t skip_indicator:4, rr_protocol_discriminator:4; |
| 977 | uint8_t system_information; |
| 978 | #endif |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 979 | } __attribute__ ((packed)); |
| 980 | |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 981 | /* Section 10.5.2.4 Cell Selection Parameters */ |
| 982 | struct gsm48_cell_sel_par { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 983 | #if OSMO_IS_LITTLE_ENDIAN |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 984 | uint8_t ms_txpwr_max_ccch:5, /* GSM 05.08 MS-TXPWR-MAX-CCCH */ |
| 985 | cell_resel_hyst:3; /* GSM 05.08 CELL-RESELECT-HYSTERESIS */ |
| 986 | uint8_t rxlev_acc_min:6, /* GSM 05.08 RXLEV-ACCESS-MIN */ |
| 987 | neci:1, |
| 988 | acs:1; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 989 | #elif OSMO_IS_BIG_ENDIAN |
| 990 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 991 | uint8_t cell_resel_hyst:3, ms_txpwr_max_ccch:5; |
| 992 | uint8_t acs:1, neci:1, rxlev_acc_min:6; |
| 993 | #endif |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 994 | } __attribute__ ((packed)); |
| 995 | |
Neels Hofmeyr | d1c2fc6 | 2017-02-21 14:51:40 +0100 | [diff] [blame] | 996 | /* 3GPP TS 44.018 Section 10.5.2.11 Control Channel Description */ |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 997 | struct gsm48_control_channel_descr { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 998 | #if OSMO_IS_LITTLE_ENDIAN |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 999 | uint8_t ccch_conf :3, |
| 1000 | bs_ag_blks_res :3, |
| 1001 | att :1, |
Neels Hofmeyr | d1c2fc6 | 2017-02-21 14:51:40 +0100 | [diff] [blame] | 1002 | mscr :1; |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1003 | uint8_t bs_pa_mfrms : 3, |
Neels Hofmeyr | d1c2fc6 | 2017-02-21 14:51:40 +0100 | [diff] [blame] | 1004 | spare_1 :2, |
| 1005 | cbq3 :2, |
| 1006 | spare_2 :1; |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1007 | uint8_t t3212; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 1008 | #elif OSMO_IS_BIG_ENDIAN |
| 1009 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 1010 | uint8_t mscr:1, att:1, bs_ag_blks_res:3, ccch_conf:3; |
| 1011 | uint8_t spare_2:1, cbq3:2, spare_1:2, bs_pa_mfrms:3; |
| 1012 | uint8_t t3212; |
| 1013 | #endif |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1014 | } __attribute__ ((packed)); |
| 1015 | |
Max | fe65fa7 | 2016-05-10 17:17:05 +0200 | [diff] [blame] | 1016 | enum gsm48_dtx_mode { |
| 1017 | GSM48_DTX_MAY_BE_USED, |
| 1018 | GSM48_DTX_SHALL_BE_USED, |
| 1019 | GSM48_DTX_SHALL_NOT_BE_USED |
| 1020 | }; |
| 1021 | |
| 1022 | /* Cell Options for SI6, SACCH (10.5.2.3a.2) or SI3, BCCH (Table 10.5.2.3.1), |
| 1023 | 3GPP TS 44.018 */ |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1024 | struct gsm48_cell_options { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 1025 | #if OSMO_IS_LITTLE_ENDIAN |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1026 | uint8_t radio_link_timeout:4, |
| 1027 | dtx:2, |
| 1028 | pwrc:1, |
Max | fe65fa7 | 2016-05-10 17:17:05 +0200 | [diff] [blame] | 1029 | /* either DN-IND or top bit of DTX IND */ |
| 1030 | d:1; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 1031 | #elif OSMO_IS_BIG_ENDIAN |
| 1032 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 1033 | uint8_t d:1, pwrc:1, dtx:2, radio_link_timeout:4; |
| 1034 | #endif |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1035 | } __attribute__ ((packed)); |
| 1036 | |
| 1037 | /* Section 9.2.9 CM service request */ |
| 1038 | struct gsm48_service_request { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 1039 | #if OSMO_IS_LITTLE_ENDIAN |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1040 | uint8_t cm_service_type : 4, |
| 1041 | cipher_key_seq : 4; |
Pau Espin Pedrol | ba5a9b9 | 2019-11-04 15:41:32 +0100 | [diff] [blame] | 1042 | union { |
| 1043 | uint32_t classmark; /* Backward compatibility */ |
| 1044 | struct { |
| 1045 | uint8_t cm2_len; |
| 1046 | struct gsm48_classmark2 classmark2; |
| 1047 | }; |
| 1048 | }; |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1049 | uint8_t mi_len; |
| 1050 | uint8_t mi[0]; |
| 1051 | /* optional priority level */ |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 1052 | #elif OSMO_IS_BIG_ENDIAN |
| 1053 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 1054 | uint8_t cipher_key_seq:4, cm_service_type:4; |
Pau Espin Pedrol | ba5a9b9 | 2019-11-04 15:41:32 +0100 | [diff] [blame] | 1055 | union { |
| 1056 | uint32_t classmark; /* Backward compatibility */ |
| 1057 | struct { |
| 1058 | uint8_t cm2_len; |
| 1059 | struct gsm48_classmark2 classmark2; |
| 1060 | }; |
| 1061 | }; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 1062 | uint8_t mi_len; |
| 1063 | uint8_t mi[0]; |
| 1064 | #endif |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1065 | } __attribute__ ((packed)); |
| 1066 | |
| 1067 | /* Section 9.1.31 System information Type 1 */ |
| 1068 | struct gsm48_system_information_type_1 { |
| 1069 | struct gsm48_system_information_type_header header; |
| 1070 | uint8_t cell_channel_description[16]; |
| 1071 | struct gsm48_rach_control rach_control; |
| 1072 | uint8_t rest_octets[0]; /* NCH position on the CCCH */ |
| 1073 | } __attribute__ ((packed)); |
| 1074 | |
| 1075 | /* Section 9.1.32 System information Type 2 */ |
| 1076 | struct gsm48_system_information_type_2 { |
| 1077 | struct gsm48_system_information_type_header header; |
| 1078 | uint8_t bcch_frequency_list[16]; |
| 1079 | uint8_t ncc_permitted; |
| 1080 | struct gsm48_rach_control rach_control; |
| 1081 | } __attribute__ ((packed)); |
| 1082 | |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1083 | /* Section 9.1.33 System information Type 2bis */ |
| 1084 | struct gsm48_system_information_type_2bis { |
| 1085 | struct gsm48_system_information_type_header header; |
| 1086 | uint8_t bcch_frequency_list[16]; |
| 1087 | struct gsm48_rach_control rach_control; |
| 1088 | uint8_t rest_octets[0]; |
| 1089 | } __attribute__ ((packed)); |
| 1090 | |
| 1091 | /* Section 9.1.34 System information Type 2ter */ |
| 1092 | struct gsm48_system_information_type_2ter { |
| 1093 | struct gsm48_system_information_type_header header; |
| 1094 | uint8_t ext_bcch_frequency_list[16]; |
| 1095 | uint8_t rest_octets[0]; |
| 1096 | } __attribute__ ((packed)); |
| 1097 | |
Max | e859aec | 2016-03-11 12:24:04 +0100 | [diff] [blame] | 1098 | /* Section 9.1.34a System information Type 2quater */ |
| 1099 | struct gsm48_system_information_type_2quater { |
| 1100 | struct gsm48_system_information_type_header header; |
| 1101 | uint8_t rest_octets[0]; |
| 1102 | } __attribute__ ((packed)); |
| 1103 | |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1104 | /* Section 9.1.35 System information Type 3 */ |
| 1105 | struct gsm48_system_information_type_3 { |
| 1106 | struct gsm48_system_information_type_header header; |
| 1107 | uint16_t cell_identity; |
| 1108 | struct gsm48_loc_area_id lai; |
| 1109 | struct gsm48_control_channel_descr control_channel_desc; |
| 1110 | struct gsm48_cell_options cell_options; |
| 1111 | struct gsm48_cell_sel_par cell_sel_par; |
| 1112 | struct gsm48_rach_control rach_control; |
| 1113 | uint8_t rest_octets[0]; |
| 1114 | } __attribute__ ((packed)); |
| 1115 | |
| 1116 | /* Section 9.1.36 System information Type 4 */ |
| 1117 | struct gsm48_system_information_type_4 { |
| 1118 | struct gsm48_system_information_type_header header; |
| 1119 | struct gsm48_loc_area_id lai; |
| 1120 | struct gsm48_cell_sel_par cell_sel_par; |
| 1121 | struct gsm48_rach_control rach_control; |
| 1122 | /* optional CBCH conditional CBCH... followed by |
| 1123 | mandantory SI 4 Reset Octets |
| 1124 | */ |
| 1125 | uint8_t data[0]; |
| 1126 | } __attribute__ ((packed)); |
| 1127 | |
| 1128 | /* Section 9.1.37 System information Type 5 */ |
| 1129 | struct gsm48_system_information_type_5 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 1130 | #if OSMO_IS_LITTLE_ENDIAN |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1131 | uint8_t rr_protocol_discriminator :4, |
Pau Espin Pedrol | ab6d6cf | 2019-10-31 13:34:57 +0100 | [diff] [blame] | 1132 | skip_indicator:4; |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1133 | uint8_t system_information; |
| 1134 | uint8_t bcch_frequency_list[16]; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 1135 | #elif OSMO_IS_BIG_ENDIAN |
| 1136 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 1137 | uint8_t skip_indicator:4, rr_protocol_discriminator:4; |
| 1138 | uint8_t system_information; |
| 1139 | uint8_t bcch_frequency_list[16]; |
| 1140 | #endif |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1141 | } __attribute__ ((packed)); |
| 1142 | |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1143 | /* Section 9.1.38 System information Type 5bis */ |
| 1144 | struct gsm48_system_information_type_5bis { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 1145 | #if OSMO_IS_LITTLE_ENDIAN |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1146 | uint8_t rr_protocol_discriminator :4, |
| 1147 | skip_indicator:4; |
| 1148 | uint8_t system_information; |
| 1149 | uint8_t bcch_frequency_list[16]; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 1150 | #elif OSMO_IS_BIG_ENDIAN |
| 1151 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 1152 | uint8_t skip_indicator:4, rr_protocol_discriminator:4; |
| 1153 | uint8_t system_information; |
| 1154 | uint8_t bcch_frequency_list[16]; |
| 1155 | #endif |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1156 | } __attribute__ ((packed)); |
| 1157 | |
| 1158 | /* Section 9.1.39 System information Type 5ter */ |
| 1159 | struct gsm48_system_information_type_5ter { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 1160 | #if OSMO_IS_LITTLE_ENDIAN |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1161 | uint8_t rr_protocol_discriminator :4, |
| 1162 | skip_indicator:4; |
| 1163 | uint8_t system_information; |
| 1164 | uint8_t bcch_frequency_list[16]; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 1165 | #elif OSMO_IS_BIG_ENDIAN |
| 1166 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 1167 | uint8_t skip_indicator:4, rr_protocol_discriminator:4; |
| 1168 | uint8_t system_information; |
| 1169 | uint8_t bcch_frequency_list[16]; |
| 1170 | #endif |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1171 | } __attribute__ ((packed)); |
| 1172 | |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1173 | /* Section 9.1.40 System information Type 6 */ |
| 1174 | struct gsm48_system_information_type_6 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 1175 | #if OSMO_IS_LITTLE_ENDIAN |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1176 | uint8_t rr_protocol_discriminator :4, |
Pau Espin Pedrol | ab6d6cf | 2019-10-31 13:34:57 +0100 | [diff] [blame] | 1177 | skip_indicator:4; |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1178 | uint8_t system_information; |
| 1179 | uint16_t cell_identity; |
| 1180 | struct gsm48_loc_area_id lai; |
| 1181 | struct gsm48_cell_options cell_options; |
| 1182 | uint8_t ncc_permitted; |
| 1183 | uint8_t rest_octets[0]; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 1184 | #elif OSMO_IS_BIG_ENDIAN |
| 1185 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 1186 | uint8_t skip_indicator:4, rr_protocol_discriminator:4; |
| 1187 | uint8_t system_information; |
| 1188 | uint16_t cell_identity; |
| 1189 | struct gsm48_loc_area_id lai; |
| 1190 | struct gsm48_cell_options cell_options; |
| 1191 | uint8_t ncc_permitted; |
| 1192 | uint8_t rest_octets[0]; |
| 1193 | #endif |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1194 | } __attribute__ ((packed)); |
| 1195 | |
| 1196 | /* Section 9.1.43a System Information type 13 */ |
| 1197 | struct gsm48_system_information_type_13 { |
| 1198 | struct gsm48_system_information_type_header header; |
| 1199 | uint8_t rest_octets[0]; |
| 1200 | } __attribute__ ((packed)); |
| 1201 | |
| 1202 | /* Section 9.2.12 IMSI Detach Indication */ |
| 1203 | struct gsm48_imsi_detach_ind { |
| 1204 | struct gsm48_classmark1 classmark1; |
| 1205 | uint8_t mi_len; |
| 1206 | uint8_t mi[0]; |
| 1207 | } __attribute__ ((packed)); |
| 1208 | |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1209 | /* Section 9.1.1 */ |
| 1210 | struct gsm48_add_ass { |
| 1211 | /* Semantic is from 10.5.2.5 */ |
| 1212 | struct gsm48_chan_desc chan_desc; |
| 1213 | uint8_t data[0]; |
| 1214 | } __attribute__((packed)); |
| 1215 | |
| 1216 | /* Section 9.1.3 */ |
| 1217 | struct gsm48_ass_cpl { |
| 1218 | uint8_t rr_cause; |
| 1219 | } __attribute__((packed)); |
| 1220 | |
| 1221 | /* Section 9.1.4 */ |
| 1222 | struct gsm48_ass_fail { |
| 1223 | uint8_t rr_cause; |
| 1224 | } __attribute__((packed)); |
| 1225 | |
Andreas Eversberg | fa83201 | 2010-09-01 23:37:07 +0200 | [diff] [blame] | 1226 | /* Section 9.1.3 */ |
| 1227 | struct gsm48_ho_cpl { |
| 1228 | uint8_t rr_cause; |
| 1229 | uint8_t data[0]; |
| 1230 | } __attribute__((packed)); |
| 1231 | |
| 1232 | /* Section 9.1.4 */ |
| 1233 | struct gsm48_ho_fail { |
| 1234 | uint8_t rr_cause; |
| 1235 | } __attribute__((packed)); |
| 1236 | |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1237 | /* Section 9.1.7 */ |
| 1238 | struct gsm48_chan_rel { |
| 1239 | uint8_t rr_cause; |
| 1240 | uint8_t data[0]; |
| 1241 | } __attribute__((packed)); |
| 1242 | |
| 1243 | /* Section 9.1.9 */ |
| 1244 | struct gsm48_cip_mode_cmd { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 1245 | #if OSMO_IS_LITTLE_ENDIAN |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1246 | uint8_t sc:1, |
| 1247 | alg_id:3, |
Sylvain Munaut | 77b6f6c | 2010-09-17 13:55:45 +0200 | [diff] [blame] | 1248 | cr:1, |
| 1249 | spare:3; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 1250 | #elif OSMO_IS_BIG_ENDIAN |
| 1251 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 1252 | uint8_t spare:3, cr:1, alg_id:3, sc:1; |
| 1253 | #endif |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1254 | } __attribute__((packed)); |
| 1255 | |
| 1256 | /* Section 9.1.11 */ |
| 1257 | struct gsm48_cm_change { |
| 1258 | uint8_t cm2_len; |
| 1259 | struct gsm48_classmark2 cm2; |
| 1260 | uint8_t data[0]; |
| 1261 | } __attribute__((packed)); |
| 1262 | |
| 1263 | /* Section 9.1.19 */ |
| 1264 | struct gsm48_imm_ass_ext { |
| 1265 | uint8_t l2_plen; |
| 1266 | uint8_t proto_discr; |
| 1267 | uint8_t msg_type; |
| 1268 | uint8_t page_mode; |
| 1269 | struct gsm48_chan_desc chan_desc1; |
| 1270 | struct gsm48_req_ref req_ref1; |
| 1271 | uint8_t timing_advance1; |
| 1272 | struct gsm48_chan_desc chan_desc2; |
| 1273 | struct gsm48_req_ref req_ref2; |
| 1274 | uint8_t timing_advance2; |
| 1275 | uint8_t mob_alloc_len; |
| 1276 | uint8_t mob_alloc[0]; |
| 1277 | } __attribute__ ((packed)); |
| 1278 | |
| 1279 | /* Section 9.1.20 */ |
| 1280 | struct gsm48_imm_ass_rej { |
| 1281 | uint8_t l2_plen; |
| 1282 | uint8_t proto_discr; |
| 1283 | uint8_t msg_type; |
| 1284 | uint8_t page_mode; |
| 1285 | struct gsm48_req_ref req_ref1; |
| 1286 | uint8_t wait_ind1; |
| 1287 | struct gsm48_req_ref req_ref2; |
| 1288 | uint8_t wait_ind2; |
| 1289 | struct gsm48_req_ref req_ref3; |
| 1290 | uint8_t wait_ind3; |
| 1291 | struct gsm48_req_ref req_ref4; |
| 1292 | uint8_t wait_ind4; |
| 1293 | uint8_t rest[0]; |
| 1294 | } __attribute__ ((packed)); |
| 1295 | |
| 1296 | /* Section 9.1.22 */ |
| 1297 | struct gsm48_paging1 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 1298 | #if OSMO_IS_LITTLE_ENDIAN |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1299 | uint8_t l2_plen; |
| 1300 | uint8_t proto_discr; |
| 1301 | uint8_t msg_type; |
| 1302 | uint8_t pag_mode:2, |
| 1303 | spare:2, |
| 1304 | cneed1:2, |
| 1305 | cneed2:2; |
| 1306 | uint8_t data[0]; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 1307 | #elif OSMO_IS_BIG_ENDIAN |
| 1308 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 1309 | uint8_t l2_plen; |
| 1310 | uint8_t proto_discr; |
| 1311 | uint8_t msg_type; |
| 1312 | uint8_t cneed2:2, cneed1:2, spare:2, pag_mode:2; |
| 1313 | uint8_t data[0]; |
| 1314 | #endif |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1315 | } __attribute__((packed)); |
| 1316 | |
| 1317 | /* Section 9.1.23 */ |
| 1318 | struct gsm48_paging2 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 1319 | #if OSMO_IS_LITTLE_ENDIAN |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1320 | uint8_t l2_plen; |
| 1321 | uint8_t proto_discr; |
| 1322 | uint8_t msg_type; |
| 1323 | uint8_t pag_mode:2, |
| 1324 | spare:2, |
| 1325 | cneed1:2, |
| 1326 | cneed2:2; |
| 1327 | uint32_t tmsi1; |
| 1328 | uint32_t tmsi2; |
| 1329 | uint8_t data[0]; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 1330 | #elif OSMO_IS_BIG_ENDIAN |
| 1331 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 1332 | uint8_t l2_plen; |
| 1333 | uint8_t proto_discr; |
| 1334 | uint8_t msg_type; |
| 1335 | uint8_t cneed2:2, cneed1:2, spare:2, pag_mode:2; |
| 1336 | uint32_t tmsi1; |
| 1337 | uint32_t tmsi2; |
| 1338 | uint8_t data[0]; |
| 1339 | #endif |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1340 | } __attribute__((packed)); |
| 1341 | |
| 1342 | /* Section 9.1.24 */ |
| 1343 | struct gsm48_paging3 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 1344 | #if OSMO_IS_LITTLE_ENDIAN |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1345 | uint8_t l2_plen; |
| 1346 | uint8_t proto_discr; |
| 1347 | uint8_t msg_type; |
| 1348 | uint8_t pag_mode:2, |
| 1349 | spare:2, |
| 1350 | cneed1:2, |
| 1351 | cneed2:2; |
| 1352 | uint32_t tmsi1; |
| 1353 | uint32_t tmsi2; |
| 1354 | uint32_t tmsi3; |
| 1355 | uint32_t tmsi4; |
| 1356 | uint8_t cneed3:2, |
| 1357 | cneed4:2, |
| 1358 | spare2:4; |
| 1359 | uint8_t rest[0]; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 1360 | #elif OSMO_IS_BIG_ENDIAN |
| 1361 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 1362 | uint8_t l2_plen; |
| 1363 | uint8_t proto_discr; |
| 1364 | uint8_t msg_type; |
| 1365 | uint8_t cneed2:2, cneed1:2, spare:2, pag_mode:2; |
| 1366 | uint32_t tmsi1; |
| 1367 | uint32_t tmsi2; |
| 1368 | uint32_t tmsi3; |
| 1369 | uint32_t tmsi4; |
| 1370 | uint8_t spare2:4, cneed4:2, cneed3:2; |
| 1371 | uint8_t rest[0]; |
| 1372 | #endif |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1373 | } __attribute__((packed)); |
| 1374 | |
| 1375 | /* Section 9.1.25 */ |
| 1376 | struct gsm48_pag_rsp { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 1377 | #if OSMO_IS_LITTLE_ENDIAN |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1378 | uint8_t key_seq:3, |
| 1379 | spare:5; |
| 1380 | uint8_t cm2_len; |
| 1381 | struct gsm48_classmark2 cm2; |
| 1382 | uint8_t data[0]; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 1383 | #elif OSMO_IS_BIG_ENDIAN |
| 1384 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 1385 | uint8_t spare:5, key_seq:3; |
| 1386 | uint8_t cm2_len; |
| 1387 | struct gsm48_classmark2 cm2; |
| 1388 | uint8_t data[0]; |
| 1389 | #endif |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1390 | } __attribute__((packed)); |
| 1391 | |
| 1392 | /* Section 9.1.29 */ |
| 1393 | struct gsm48_rr_status { |
| 1394 | uint8_t rr_cause; |
| 1395 | } __attribute__((packed)); |
| 1396 | |
Harald Welte | 3f066dd | 2017-05-29 15:59:03 +0200 | [diff] [blame] | 1397 | /* Section 10.2 + GSM 04.07 12.2.3.1.1 + 3GPP TS 24.007 11.2.3.1.1 */ |
Harald Welte | 753ae49 | 2019-05-18 11:07:54 +0200 | [diff] [blame] | 1398 | #define GSM48_PDISC_GROUP_CC 0x00 |
| 1399 | #define GSM48_PDISC_BCAST_CC 0x01 |
| 1400 | #define GSM48_PDISC_PDSS1 0x02 /* 04.07 only */ |
| 1401 | #define GSM48_PDISC_CC 0x03 |
| 1402 | #define GSM48_PDISC_PDSS2 0x04 /* 04.07 only */ |
| 1403 | #define GSM48_PDISC_GTTP 0x04 /* 24.007 only */ |
| 1404 | #define GSM48_PDISC_MM 0x05 |
| 1405 | #define GSM48_PDISC_RR 0x06 |
| 1406 | #define GSM48_PDISC_MM_GPRS 0x08 |
| 1407 | #define GSM48_PDISC_SMS 0x09 |
| 1408 | #define GSM48_PDISC_SM_GPRS 0x0a |
| 1409 | #define GSM48_PDISC_NC_SS 0x0b |
| 1410 | #define GSM48_PDISC_LOC 0x0c |
| 1411 | #define GSM48_PDISC_EXTEND 0x0e |
| 1412 | #define GSM48_PDISC_TEST 0x0f /* as per 11.10, 04.14 */ |
| 1413 | #define GSM48_PDISC_MASK 0x0f |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1414 | |
Neels Hofmeyr | dbd994c | 2017-03-09 23:07:02 +0100 | [diff] [blame] | 1415 | extern const struct value_string gsm48_pdisc_names[]; |
Harald Welte | 753ae49 | 2019-05-18 11:07:54 +0200 | [diff] [blame] | 1416 | static inline const char *gsm48_pdisc_name(uint8_t val) |
Neels Hofmeyr | dbd994c | 2017-03-09 23:07:02 +0100 | [diff] [blame] | 1417 | { return get_value_string(gsm48_pdisc_names, val); } |
| 1418 | |
Max | fdca25d | 2016-07-05 16:06:28 +0200 | [diff] [blame] | 1419 | bool gsm48_hdr_gmm_cipherable(const struct gsm48_hdr *hdr); |
| 1420 | |
Harald Welte | 753ae49 | 2019-05-18 11:07:54 +0200 | [diff] [blame] | 1421 | static inline uint8_t gsm48_hdr_pdisc(const struct gsm48_hdr *hdr) |
Neels Hofmeyr | 282e908 | 2016-03-14 16:06:46 +0100 | [diff] [blame] | 1422 | { |
| 1423 | /* |
| 1424 | * 3GPP TS 24.007 version 12.0.0 Release 12, |
| 1425 | * 11.2.3.1.1 Protocol discriminator |
| 1426 | */ |
| 1427 | uint8_t pdisc = hdr->proto_discr & GSM48_PDISC_MASK; |
| 1428 | if (pdisc == GSM48_PDISC_EXTEND) |
| 1429 | return hdr->proto_discr; |
| 1430 | return pdisc; |
| 1431 | } |
| 1432 | |
Neels Hofmeyr | da7bf4d | 2016-03-14 16:06:48 +0100 | [diff] [blame] | 1433 | static inline uint8_t gsm48_hdr_trans_id(const struct gsm48_hdr *hdr) |
| 1434 | { |
| 1435 | /* |
| 1436 | * 3GPP TS 24.007 version 12.0.0 Release 12, |
| 1437 | * 11.2.3.1.3 Transaction identifier |
| 1438 | */ |
| 1439 | return (hdr->proto_discr & 0xf0) >> 4; |
| 1440 | } |
| 1441 | |
Max | da34bf0 | 2016-07-17 16:37:56 +0200 | [diff] [blame] | 1442 | #define GSM48_TA_INVALID 220 |
| 1443 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 1444 | /*! Check if TA is valid according to 3GPP TS 44.018 ยง 10.5.2.40 |
Max | edb57e7 | 2016-07-14 11:35:17 +0200 | [diff] [blame] | 1445 | * \param[in] ta Timing Advance value |
| 1446 | * \returns true if ta is valid, false otherwise |
| 1447 | * Note: Rules for GSM400 band are ignored as it's not implemented in practice. |
| 1448 | */ |
| 1449 | static inline bool gsm48_ta_is_valid(uint8_t ta) |
| 1450 | { |
| 1451 | return (ta < 64); |
| 1452 | } |
| 1453 | |
Neels Hofmeyr | da7bf4d | 2016-03-14 16:06:48 +0100 | [diff] [blame] | 1454 | static inline uint8_t gsm48_hdr_trans_id_flip_ti(const struct gsm48_hdr *hdr) |
| 1455 | { |
| 1456 | return gsm48_hdr_trans_id(hdr) ^ 0x08; |
| 1457 | } |
| 1458 | |
| 1459 | static inline uint8_t gsm48_hdr_trans_id_no_ti(const struct gsm48_hdr *hdr) |
| 1460 | { |
| 1461 | return gsm48_hdr_trans_id(hdr) & 0x07; |
| 1462 | } |
| 1463 | |
Neels Hofmeyr | 282e908 | 2016-03-14 16:06:46 +0100 | [diff] [blame] | 1464 | static inline uint8_t gsm48_hdr_msg_type_r98(const struct gsm48_hdr *hdr) |
| 1465 | { |
| 1466 | /* |
| 1467 | * 3GPP TS 24.007 version 12.0.0 Release 12, |
| 1468 | * 11.2.3.2.1 Message type octet (when accessing Release 98 and older |
| 1469 | * networks only) |
| 1470 | */ |
| 1471 | switch (gsm48_hdr_pdisc(hdr)) { |
| 1472 | case GSM48_PDISC_MM: |
| 1473 | case GSM48_PDISC_CC: |
| 1474 | case GSM48_PDISC_NC_SS: |
| 1475 | case GSM48_PDISC_GROUP_CC: |
| 1476 | case GSM48_PDISC_BCAST_CC: |
| 1477 | case GSM48_PDISC_LOC: |
Harald Welte | 143aed7 | 2018-02-03 21:14:47 +0100 | [diff] [blame] | 1478 | return hdr->msg_type & 0x3f; |
Neels Hofmeyr | 282e908 | 2016-03-14 16:06:46 +0100 | [diff] [blame] | 1479 | default: |
| 1480 | return hdr->msg_type; |
| 1481 | } |
| 1482 | } |
| 1483 | |
| 1484 | static inline uint8_t gsm48_hdr_msg_type_r99(const struct gsm48_hdr *hdr) |
| 1485 | { |
| 1486 | /* |
| 1487 | * 3GPP TS 24.007 version 12.0.0 Release 12, |
| 1488 | * 11.2.3.2.2 Message type octet (when accessing Release 99 and newer |
| 1489 | * networks) |
| 1490 | */ |
| 1491 | switch (gsm48_hdr_pdisc(hdr)) { |
| 1492 | case GSM48_PDISC_MM: |
| 1493 | case GSM48_PDISC_CC: |
Neels Hofmeyr | 282e908 | 2016-03-14 16:06:46 +0100 | [diff] [blame] | 1494 | case GSM48_PDISC_NC_SS: |
Harald Welte | f1076ed | 2018-02-03 21:16:45 +0100 | [diff] [blame] | 1495 | return hdr->msg_type & 0x3f; |
Neels Hofmeyr | 282e908 | 2016-03-14 16:06:46 +0100 | [diff] [blame] | 1496 | case GSM48_PDISC_GROUP_CC: |
| 1497 | case GSM48_PDISC_BCAST_CC: |
| 1498 | case GSM48_PDISC_LOC: |
Harald Welte | 143aed7 | 2018-02-03 21:14:47 +0100 | [diff] [blame] | 1499 | return hdr->msg_type & 0x3f; |
Neels Hofmeyr | 282e908 | 2016-03-14 16:06:46 +0100 | [diff] [blame] | 1500 | default: |
| 1501 | return hdr->msg_type; |
| 1502 | } |
| 1503 | } |
| 1504 | |
Max | fe65fa7 | 2016-05-10 17:17:05 +0200 | [diff] [blame] | 1505 | void gsm48_set_dtx(struct gsm48_cell_options *op, enum gsm48_dtx_mode full, |
| 1506 | enum gsm48_dtx_mode half, bool is_bcch); |
| 1507 | |
Neels Hofmeyr | c656fae | 2016-03-14 16:06:47 +0100 | [diff] [blame] | 1508 | #define gsm48_hdr_msg_type gsm48_hdr_msg_type_r99 |
Neels Hofmeyr | 282e908 | 2016-03-14 16:06:46 +0100 | [diff] [blame] | 1509 | |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1510 | /* Section 10.4 */ |
| 1511 | #define GSM48_MT_RR_INIT_REQ 0x3c |
| 1512 | #define GSM48_MT_RR_ADD_ASS 0x3b |
| 1513 | #define GSM48_MT_RR_IMM_ASS 0x3f |
| 1514 | #define GSM48_MT_RR_IMM_ASS_EXT 0x39 |
| 1515 | #define GSM48_MT_RR_IMM_ASS_REJ 0x3a |
Philipp | 72e43f0 | 2016-10-27 13:35:20 +0200 | [diff] [blame] | 1516 | #define GSM48_MT_RR_DTM_ASS_FAIL 0x48 |
| 1517 | #define GSM48_MT_RR_DTM_REJECT 0x49 |
| 1518 | #define GSM48_MT_RR_DTM_REQUEST 0x4A |
| 1519 | #define GSM48_MT_RR_PACKET_ASS 0x4B |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1520 | |
| 1521 | #define GSM48_MT_RR_CIPH_M_CMD 0x35 |
| 1522 | #define GSM48_MT_RR_CIPH_M_COMPL 0x32 |
| 1523 | |
| 1524 | #define GSM48_MT_RR_CFG_CHG_CMD 0x30 |
| 1525 | #define GSM48_MT_RR_CFG_CHG_ACK 0x31 |
| 1526 | #define GSM48_MT_RR_CFG_CHG_REJ 0x33 |
| 1527 | |
| 1528 | #define GSM48_MT_RR_ASS_CMD 0x2e |
| 1529 | #define GSM48_MT_RR_ASS_COMPL 0x29 |
| 1530 | #define GSM48_MT_RR_ASS_FAIL 0x2f |
| 1531 | #define GSM48_MT_RR_HANDO_CMD 0x2b |
| 1532 | #define GSM48_MT_RR_HANDO_COMPL 0x2c |
| 1533 | #define GSM48_MT_RR_HANDO_FAIL 0x28 |
| 1534 | #define GSM48_MT_RR_HANDO_INFO 0x2d |
Philipp | 72e43f0 | 2016-10-27 13:35:20 +0200 | [diff] [blame] | 1535 | #define GSM48_MT_RR_HANDO_INFO 0x2d |
| 1536 | #define GSM48_MT_RR_DTM_ASS_CMD 0x4c |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1537 | |
| 1538 | #define GSM48_MT_RR_CELL_CHG_ORDER 0x08 |
| 1539 | #define GSM48_MT_RR_PDCH_ASS_CMD 0x23 |
| 1540 | |
| 1541 | #define GSM48_MT_RR_CHAN_REL 0x0d |
| 1542 | #define GSM48_MT_RR_PART_REL 0x0a |
| 1543 | #define GSM48_MT_RR_PART_REL_COMP 0x0f |
| 1544 | |
| 1545 | #define GSM48_MT_RR_PAG_REQ_1 0x21 |
| 1546 | #define GSM48_MT_RR_PAG_REQ_2 0x22 |
| 1547 | #define GSM48_MT_RR_PAG_REQ_3 0x24 |
| 1548 | #define GSM48_MT_RR_PAG_RESP 0x27 |
| 1549 | #define GSM48_MT_RR_NOTIF_NCH 0x20 |
Philipp | 72e43f0 | 2016-10-27 13:35:20 +0200 | [diff] [blame] | 1550 | #define GSM48_MT_RR_NOTIF_FACCH 0x25 /* (Reserved) */ |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1551 | #define GSM48_MT_RR_NOTIF_RESP 0x26 |
Philipp | 72e43f0 | 2016-10-27 13:35:20 +0200 | [diff] [blame] | 1552 | #define GSM48_MT_RR_PACKET_NOTIF 0x4e |
Philipp | 349784c | 2016-10-10 15:03:23 +0200 | [diff] [blame] | 1553 | #define GSM48_MT_RR_UTRAN_CLSM_CHG 0x60 |
| 1554 | #define GSM48_MT_RR_CDMA2K_CLSM_CHG 0x62 |
| 1555 | #define GSM48_MT_RR_IS_TO_UTRAN_HANDO 0x63 |
| 1556 | #define GSM48_MT_RR_IS_TO_CDMA2K_HANDO 0x64 |
| 1557 | |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1558 | #define GSM48_MT_RR_SYSINFO_8 0x18 |
| 1559 | #define GSM48_MT_RR_SYSINFO_1 0x19 |
| 1560 | #define GSM48_MT_RR_SYSINFO_2 0x1a |
| 1561 | #define GSM48_MT_RR_SYSINFO_3 0x1b |
| 1562 | #define GSM48_MT_RR_SYSINFO_4 0x1c |
| 1563 | #define GSM48_MT_RR_SYSINFO_5 0x1d |
| 1564 | #define GSM48_MT_RR_SYSINFO_6 0x1e |
| 1565 | #define GSM48_MT_RR_SYSINFO_7 0x1f |
| 1566 | |
| 1567 | #define GSM48_MT_RR_SYSINFO_2bis 0x02 |
| 1568 | #define GSM48_MT_RR_SYSINFO_2ter 0x03 |
Max | e859aec | 2016-03-11 12:24:04 +0100 | [diff] [blame] | 1569 | #define GSM48_MT_RR_SYSINFO_2quater 0x07 |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1570 | #define GSM48_MT_RR_SYSINFO_5bis 0x05 |
| 1571 | #define GSM48_MT_RR_SYSINFO_5ter 0x06 |
| 1572 | #define GSM48_MT_RR_SYSINFO_9 0x04 |
| 1573 | #define GSM48_MT_RR_SYSINFO_13 0x00 |
| 1574 | |
| 1575 | #define GSM48_MT_RR_SYSINFO_16 0x3d |
| 1576 | #define GSM48_MT_RR_SYSINFO_17 0x3e |
| 1577 | |
Philipp | 72e43f0 | 2016-10-27 13:35:20 +0200 | [diff] [blame] | 1578 | #define GSM48_MT_RR_SYSINFO_18 0x40 |
| 1579 | #define GSM48_MT_RR_SYSINFO_19 0x41 |
| 1580 | #define GSM48_MT_RR_SYSINFO_20 0x42 |
| 1581 | |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1582 | #define GSM48_MT_RR_CHAN_MODE_MODIF 0x10 |
| 1583 | #define GSM48_MT_RR_STATUS 0x12 |
| 1584 | #define GSM48_MT_RR_CHAN_MODE_MODIF_ACK 0x17 |
| 1585 | #define GSM48_MT_RR_FREQ_REDEF 0x14 |
| 1586 | #define GSM48_MT_RR_MEAS_REP 0x15 |
| 1587 | #define GSM48_MT_RR_CLSM_CHG 0x16 |
| 1588 | #define GSM48_MT_RR_CLSM_ENQ 0x13 |
| 1589 | #define GSM48_MT_RR_EXT_MEAS_REP 0x36 |
| 1590 | #define GSM48_MT_RR_EXT_MEAS_REP_ORD 0x37 |
| 1591 | #define GSM48_MT_RR_GPRS_SUSP_REQ 0x34 |
Philipp | 72e43f0 | 2016-10-27 13:35:20 +0200 | [diff] [blame] | 1592 | #define GSM48_MT_RR_DTM_INFO 0x4d |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1593 | |
Bhaskar | e6b45d8 | 2013-05-16 17:11:51 +0530 | [diff] [blame] | 1594 | #define GSM48_MT_RR_VGCS_UPL_GRANT 0x09 |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1595 | #define GSM48_MT_RR_UPLINK_RELEASE 0x0e |
| 1596 | #define GSM48_MT_RR_UPLINK_FREE 0x0c |
| 1597 | #define GSM48_MT_RR_UPLINK_BUSY 0x2a |
| 1598 | #define GSM48_MT_RR_TALKER_IND 0x11 |
| 1599 | |
| 1600 | #define GSM48_MT_RR_APP_INFO 0x38 |
| 1601 | |
| 1602 | /* Table 10.2/3GPP TS 04.08 */ |
| 1603 | #define GSM48_MT_MM_IMSI_DETACH_IND 0x01 |
| 1604 | #define GSM48_MT_MM_LOC_UPD_ACCEPT 0x02 |
| 1605 | #define GSM48_MT_MM_LOC_UPD_REJECT 0x04 |
| 1606 | #define GSM48_MT_MM_LOC_UPD_REQUEST 0x08 |
| 1607 | |
| 1608 | #define GSM48_MT_MM_AUTH_REJ 0x11 |
| 1609 | #define GSM48_MT_MM_AUTH_REQ 0x12 |
| 1610 | #define GSM48_MT_MM_AUTH_RESP 0x14 |
Neels Hofmeyr | 55a43b8 | 2017-02-02 20:27:55 +0100 | [diff] [blame] | 1611 | #define GSM48_MT_MM_AUTH_FAIL 0x1c |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1612 | #define GSM48_MT_MM_ID_REQ 0x18 |
| 1613 | #define GSM48_MT_MM_ID_RESP 0x19 |
| 1614 | #define GSM48_MT_MM_TMSI_REALL_CMD 0x1a |
| 1615 | #define GSM48_MT_MM_TMSI_REALL_COMPL 0x1b |
| 1616 | |
| 1617 | #define GSM48_MT_MM_CM_SERV_ACC 0x21 |
| 1618 | #define GSM48_MT_MM_CM_SERV_REJ 0x22 |
| 1619 | #define GSM48_MT_MM_CM_SERV_ABORT 0x23 |
| 1620 | #define GSM48_MT_MM_CM_SERV_REQ 0x24 |
| 1621 | #define GSM48_MT_MM_CM_SERV_PROMPT 0x25 |
| 1622 | #define GSM48_MT_MM_CM_REEST_REQ 0x28 |
| 1623 | #define GSM48_MT_MM_ABORT 0x29 |
| 1624 | |
| 1625 | #define GSM48_MT_MM_NULL 0x30 |
| 1626 | #define GSM48_MT_MM_STATUS 0x31 |
| 1627 | #define GSM48_MT_MM_INFO 0x32 |
| 1628 | |
| 1629 | /* Table 10.3/3GPP TS 04.08 */ |
| 1630 | #define GSM48_MT_CC_ALERTING 0x01 |
| 1631 | #define GSM48_MT_CC_CALL_CONF 0x08 |
| 1632 | #define GSM48_MT_CC_CALL_PROC 0x02 |
| 1633 | #define GSM48_MT_CC_CONNECT 0x07 |
| 1634 | #define GSM48_MT_CC_CONNECT_ACK 0x0f |
| 1635 | #define GSM48_MT_CC_EMERG_SETUP 0x0e |
| 1636 | #define GSM48_MT_CC_PROGRESS 0x03 |
| 1637 | #define GSM48_MT_CC_ESTAB 0x04 |
| 1638 | #define GSM48_MT_CC_ESTAB_CONF 0x06 |
| 1639 | #define GSM48_MT_CC_RECALL 0x0b |
| 1640 | #define GSM48_MT_CC_START_CC 0x09 |
| 1641 | #define GSM48_MT_CC_SETUP 0x05 |
| 1642 | |
| 1643 | #define GSM48_MT_CC_MODIFY 0x17 |
| 1644 | #define GSM48_MT_CC_MODIFY_COMPL 0x1f |
| 1645 | #define GSM48_MT_CC_MODIFY_REJECT 0x13 |
| 1646 | #define GSM48_MT_CC_USER_INFO 0x10 |
| 1647 | #define GSM48_MT_CC_HOLD 0x18 |
| 1648 | #define GSM48_MT_CC_HOLD_ACK 0x19 |
| 1649 | #define GSM48_MT_CC_HOLD_REJ 0x1a |
| 1650 | #define GSM48_MT_CC_RETR 0x1c |
| 1651 | #define GSM48_MT_CC_RETR_ACK 0x1d |
| 1652 | #define GSM48_MT_CC_RETR_REJ 0x1e |
| 1653 | |
| 1654 | #define GSM48_MT_CC_DISCONNECT 0x25 |
| 1655 | #define GSM48_MT_CC_RELEASE 0x2d |
| 1656 | #define GSM48_MT_CC_RELEASE_COMPL 0x2a |
| 1657 | |
| 1658 | #define GSM48_MT_CC_CONG_CTRL 0x39 |
| 1659 | #define GSM48_MT_CC_NOTIFY 0x3e |
| 1660 | #define GSM48_MT_CC_STATUS 0x3d |
| 1661 | #define GSM48_MT_CC_STATUS_ENQ 0x34 |
| 1662 | #define GSM48_MT_CC_START_DTMF 0x35 |
| 1663 | #define GSM48_MT_CC_STOP_DTMF 0x31 |
| 1664 | #define GSM48_MT_CC_STOP_DTMF_ACK 0x32 |
| 1665 | #define GSM48_MT_CC_START_DTMF_ACK 0x36 |
| 1666 | #define GSM48_MT_CC_START_DTMF_REJ 0x37 |
| 1667 | #define GSM48_MT_CC_FACILITY 0x3a |
| 1668 | |
Neels Hofmeyr | 00ab9ed | 2017-03-09 23:27:56 +0100 | [diff] [blame] | 1669 | extern const struct value_string gsm48_rr_msgtype_names[]; |
| 1670 | extern const struct value_string gsm48_mm_msgtype_names[]; |
| 1671 | extern const struct value_string gsm48_cc_msgtype_names[]; |
| 1672 | const char *gsm48_pdisc_msgtype_name(uint8_t pdisc, uint8_t msg_type); |
Harald Welte | 4a62eda | 2019-03-18 18:27:00 +0100 | [diff] [blame] | 1673 | char *gsm48_pdisc_msgtype_name_buf(char *buf, size_t buf_len, uint8_t pdisc, uint8_t msg_type); |
Harald Welte | 179f357 | 2019-03-18 18:38:47 +0100 | [diff] [blame] | 1674 | char *gsm48_pdisc_msgtype_name_c(const void *ctx, uint8_t pdisc, uint8_t msg_type); |
Neels Hofmeyr | 00ab9ed | 2017-03-09 23:27:56 +0100 | [diff] [blame] | 1675 | |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1676 | /* FIXME: Table 10.4 / 10.4a (GPRS) */ |
| 1677 | |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1678 | /* Section 10.5.3.3 CM service type */ |
Neels Hofmeyr | f8963f9 | 2019-01-10 23:33:32 +0100 | [diff] [blame] | 1679 | enum osmo_cm_service_type { |
| 1680 | GSM48_CMSERV_MO_CALL_PACKET = 1, |
| 1681 | GSM48_CMSERV_EMERGENCY = 2, |
| 1682 | GSM48_CMSERV_SMS = 4, |
| 1683 | GSM48_CMSERV_SUP_SERV = 8, |
| 1684 | GSM48_CMSERV_VGCS = 9, |
| 1685 | GSM48_CMSERV_VBS = 10, |
| 1686 | GSM48_CMSERV_LOC_SERV = 11, |
| 1687 | GSM48_CMSERV_MAX_VAL = GSM48_CMSERV_LOC_SERV |
| 1688 | }; |
| 1689 | |
| 1690 | extern const struct value_string osmo_cm_service_type_names[]; |
| 1691 | static inline const char *osmo_cm_service_type_name(enum osmo_cm_service_type val) |
| 1692 | { return get_value_string(osmo_cm_service_type_names, val); } |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1693 | |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1694 | /* Section 10.5.2.26, Table 10.5.64 */ |
| 1695 | #define GSM48_PM_MASK 0x03 |
| 1696 | #define GSM48_PM_NORMAL 0x00 |
| 1697 | #define GSM48_PM_EXTENDED 0x01 |
| 1698 | #define GSM48_PM_REORG 0x02 |
| 1699 | #define GSM48_PM_SAME 0x03 |
| 1700 | |
| 1701 | /* Chapter 10.5.3.5 / Table 10.5.93 */ |
| 1702 | #define GSM48_LUPD_NORMAL 0x0 |
| 1703 | #define GSM48_LUPD_PERIODIC 0x1 |
| 1704 | #define GSM48_LUPD_IMSI_ATT 0x2 |
| 1705 | #define GSM48_LUPD_RESERVED 0x3 |
| 1706 | |
Neels Hofmeyr | 92f3f5e | 2019-01-05 00:39:13 +0100 | [diff] [blame] | 1707 | extern const struct value_string osmo_lu_type_names[]; |
| 1708 | static inline const char *osmo_lu_type_name(uint8_t lu_type) |
| 1709 | { return get_value_string(osmo_lu_type_names, lu_type); } |
| 1710 | |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1711 | /* Table 10.5.4 */ |
| 1712 | #define GSM_MI_TYPE_MASK 0x07 |
| 1713 | #define GSM_MI_TYPE_NONE 0x00 |
| 1714 | #define GSM_MI_TYPE_IMSI 0x01 |
| 1715 | #define GSM_MI_TYPE_IMEI 0x02 |
| 1716 | #define GSM_MI_TYPE_IMEISV 0x03 |
| 1717 | #define GSM_MI_TYPE_TMSI 0x04 |
| 1718 | #define GSM_MI_ODD 0x08 |
| 1719 | |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1720 | #define GSM48_IE_MOBILE_ID 0x17 /* 10.5.1.4 */ |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1721 | #define GSM48_IE_NAME_LONG 0x43 /* 10.5.3.5a */ |
| 1722 | #define GSM48_IE_NAME_SHORT 0x45 /* 10.5.3.5a */ |
| 1723 | #define GSM48_IE_UTC 0x46 /* 10.5.3.8 */ |
| 1724 | #define GSM48_IE_NET_TIME_TZ 0x47 /* 10.5.3.9 */ |
| 1725 | #define GSM48_IE_LSA_IDENT 0x48 /* 10.5.3.11 */ |
Jacob Erlbeck | 1c3f088 | 2013-09-16 10:29:57 +0200 | [diff] [blame] | 1726 | #define GSM48_IE_NET_DST 0x49 /* 10.5.3.12 [24.008] */ |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1727 | |
| 1728 | #define GSM48_IE_BEARER_CAP 0x04 /* 10.5.4.5 */ |
| 1729 | #define GSM48_IE_CAUSE 0x08 /* 10.5.4.11 */ |
| 1730 | #define GSM48_IE_CC_CAP 0x15 /* 10.5.4.5a */ |
| 1731 | #define GSM48_IE_ALERT 0x19 /* 10.5.4.26 */ |
| 1732 | #define GSM48_IE_FACILITY 0x1c /* 10.5.4.15 */ |
| 1733 | #define GSM48_IE_PROGR_IND 0x1e /* 10.5.4.21 */ |
| 1734 | #define GSM48_IE_AUX_STATUS 0x24 /* 10.5.4.4 */ |
| 1735 | #define GSM48_IE_NOTIFY 0x27 /* 10.5.4.20 */ |
| 1736 | #define GSM48_IE_KPD_FACILITY 0x2c /* 10.5.4.17 */ |
| 1737 | #define GSM48_IE_SIGNAL 0x34 /* 10.5.4.23 */ |
| 1738 | #define GSM48_IE_CONN_BCD 0x4c /* 10.5.4.13 */ |
| 1739 | #define GSM48_IE_CONN_SUB 0x4d /* 10.5.4.14 */ |
| 1740 | #define GSM48_IE_CALLING_BCD 0x5c /* 10.5.4.9 */ |
| 1741 | #define GSM48_IE_CALLING_SUB 0x5d /* 10.5.4.10 */ |
| 1742 | #define GSM48_IE_CALLED_BCD 0x5e /* 10.5.4.7 */ |
| 1743 | #define GSM48_IE_CALLED_SUB 0x6d /* 10.5.4.8 */ |
| 1744 | #define GSM48_IE_REDIR_BCD 0x74 /* 10.5.4.21a */ |
| 1745 | #define GSM48_IE_REDIR_SUB 0x75 /* 10.5.4.21b */ |
| 1746 | #define GSM48_IE_LOWL_COMPAT 0x7c /* 10.5.4.18 */ |
| 1747 | #define GSM48_IE_HIGHL_COMPAT 0x7d /* 10.5.4.16 */ |
| 1748 | #define GSM48_IE_USER_USER 0x7e /* 10.5.4.25 */ |
| 1749 | #define GSM48_IE_SS_VERS 0x7f /* 10.5.4.24 */ |
| 1750 | #define GSM48_IE_MORE_DATA 0xa0 /* 10.5.4.19 */ |
| 1751 | #define GSM48_IE_CLIR_SUPP 0xa1 /* 10.5.4.11a */ |
| 1752 | #define GSM48_IE_CLIR_INVOC 0xa2 /* 10.5.4.11b */ |
| 1753 | #define GSM48_IE_REV_C_SETUP 0xa3 /* 10.5.4.22a */ |
| 1754 | #define GSM48_IE_REPEAT_CIR 0xd1 /* 10.5.4.22 */ |
| 1755 | #define GSM48_IE_REPEAT_SEQ 0xd3 /* 10.5.4.22 */ |
| 1756 | |
| 1757 | /* Section 10.5.4.11 / Table 10.5.122 */ |
| 1758 | #define GSM48_CAUSE_CS_GSM 0x60 |
| 1759 | |
| 1760 | /* Section 9.1.2 / Table 9.3 */ |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1761 | /* RR elements */ |
| 1762 | #define GSM48_IE_VGCS_TARGET 0x01 |
| 1763 | //#define GSM48_IE_VGCS_T_MODE_I 0x01 |
| 1764 | #define GSM48_IE_FRQSHORT_AFTER 0x02 |
| 1765 | #define GSM48_IE_MUL_RATE_CFG 0x03 /* 10.5.2.21aa */ |
| 1766 | #define GSM48_IE_FREQ_L_AFTER 0x05 |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1767 | #define GSM48_IE_MSLOT_DESC 0x10 |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1768 | #define GSM48_IE_CHANMODE_2 0x11 |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1769 | #define GSM48_IE_FRQSHORT_BEFORE 0x12 |
| 1770 | //#define GSM48_IE_FRQSHORT_BEFOR 0x12 |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1771 | #define GSM48_IE_CHANMODE_3 0x13 |
| 1772 | #define GSM48_IE_CHANMODE_4 0x14 |
| 1773 | #define GSM48_IE_CHANMODE_5 0x15 |
| 1774 | #define GSM48_IE_CHANMODE_6 0x16 |
| 1775 | #define GSM48_IE_CHANMODE_7 0x17 |
| 1776 | #define GSM48_IE_CHANMODE_8 0x18 |
| 1777 | #define GSM48_IE_CHANDESC_2 0x64 |
Harald Welte | 639f74b | 2010-06-15 09:32:14 +0200 | [diff] [blame] | 1778 | #define GSM48_IE_MA_AFTER 0x72 |
| 1779 | #define GSM48_IE_START_TIME 0x7c |
| 1780 | #define GSM48_IE_FREQ_L_BEFORE 0x19 |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1781 | //#define GSM48_IE_FRQLIST_BEFORE 0x19 |
Harald Welte | 639f74b | 2010-06-15 09:32:14 +0200 | [diff] [blame] | 1782 | #define GSM48_IE_CH_DESC_1_BEFORE 0x1c |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1783 | //#define GSM48_IE_CHDES_1_BEFORE 0x1c |
Harald Welte | 639f74b | 2010-06-15 09:32:14 +0200 | [diff] [blame] | 1784 | #define GSM48_IE_CH_DESC_2_BEFORE 0x1d |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1785 | //#define GSM48_IE_CHDES_2_BEFORE 0x1d |
Harald Welte | 639f74b | 2010-06-15 09:32:14 +0200 | [diff] [blame] | 1786 | #define GSM48_IE_F_CH_SEQ_BEFORE 0x1e |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1787 | //#define GSM48_IE_FRQSEQ_BEFORE 0x1e |
| 1788 | #define GSM48_IE_CLASSMARK3 0x20 |
Harald Welte | 639f74b | 2010-06-15 09:32:14 +0200 | [diff] [blame] | 1789 | #define GSM48_IE_MA_BEFORE 0x21 |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1790 | #define GSM48_IE_RR_PACKET_UL 0x22 |
| 1791 | #define GSM48_IE_RR_PACKET_DL 0x23 |
| 1792 | #define GSM48_IE_CELL_CH_DESC 0x62 |
| 1793 | #define GSM48_IE_CHANMODE_1 0x63 |
| 1794 | #define GSM48_IE_CHDES_2_AFTER 0x64 |
| 1795 | #define GSM48_IE_MODE_SEC_CH 0x66 |
| 1796 | #define GSM48_IE_F_CH_SEQ_AFTER 0x69 |
| 1797 | #define GSM48_IE_MA_AFTER 0x72 |
| 1798 | #define GSM48_IE_BA_RANGE 0x73 |
| 1799 | #define GSM48_IE_GROUP_CHDES 0x74 |
| 1800 | #define GSM48_IE_BA_LIST_PREF 0x75 |
| 1801 | #define GSM48_IE_MOB_OVSERV_DIF 0x77 |
Harald Welte | cf2caeb | 2019-02-03 00:37:20 +0100 | [diff] [blame] | 1802 | #define GSM48_IE_CELL_SEL_IND_AFTER_REL 0x77 /* 44.018 Section 9.1.7 */ |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1803 | #define GSM48_IE_REALTIME_DIFF 0x7b |
| 1804 | #define GSM48_IE_START_TIME 0x7c |
Harald Welte | cf2caeb | 2019-02-03 00:37:20 +0100 | [diff] [blame] | 1805 | #define GSM48_IE_INDIVIDUAL_PRIORITIES 0x7c /* 44.018 Section 9.1.7 */ |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1806 | #define GSM48_IE_TIMING_ADVANCE 0x7d |
| 1807 | #define GSM48_IE_GROUP_CIP_SEQ 0x80 |
| 1808 | #define GSM48_IE_CIP_MODE_SET 0x90 |
| 1809 | #define GSM48_IE_GPRS_RESUMPT 0xc0 |
| 1810 | #define GSM48_IE_SYNC_IND 0xd0 |
| 1811 | /* System Information 4 (types are equal IEs above) */ |
| 1812 | #define GSM48_IE_CBCH_CHAN_DESC 0x64 |
| 1813 | #define GSM48_IE_CBCH_MOB_AL 0x72 |
Harald Welte | 639f74b | 2010-06-15 09:32:14 +0200 | [diff] [blame] | 1814 | |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1815 | /* Additional MM elements */ |
| 1816 | #define GSM48_IE_LOCATION_AREA 0x13 |
Harald Welte | 82f94ef | 2016-05-05 23:33:27 +0200 | [diff] [blame] | 1817 | #define GSM48_IE_AUTN 0x20 |
Neels Hofmeyr | 55a43b8 | 2017-02-02 20:27:55 +0100 | [diff] [blame] | 1818 | #define GSM48_IE_AUTH_RES_EXT 0x21 |
| 1819 | #define GSM48_IE_AUTS 0x22 |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 1820 | #define GSM48_IE_PRIORITY_LEV 0x80 |
| 1821 | #define GSM48_IE_FOLLOW_ON_PROC 0xa1 |
| 1822 | #define GSM48_IE_CTS_PERMISSION 0xa2 |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1823 | |
Keith | 05d3278 | 2018-05-28 14:08:10 +0200 | [diff] [blame] | 1824 | /* Section 10.5.4.21 / Table 10.5.127 */ |
| 1825 | |
| 1826 | enum gsm48_progress_desc { |
| 1827 | GSM48_PROGR_NOT_E2E = 0x00, |
| 1828 | GSM48_PROGR_DEST_NOT_PLMN = 0x02, |
| 1829 | GSM48_PROGR_ORIG_NOT_PLMN = 0x03, |
| 1830 | GSM48_PROGR_RETURNED = 0x04, |
| 1831 | GSM48_PROGR_IN_BAND_AVAIL = 0x08, |
| 1832 | GSM48_PROGR_CALL_E2E = 0x20, |
| 1833 | GSM48_PROGR_QUEUEING = 0x40, |
| 1834 | }; |
| 1835 | |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1836 | /* Section 10.5.4.23 / Table 10.5.130 */ |
| 1837 | enum gsm48_signal_val { |
| 1838 | GSM48_SIGNAL_DIALTONE = 0x00, |
| 1839 | GSM48_SIGNAL_RINGBACK = 0x01, |
| 1840 | GSM48_SIGNAL_INTERCEPT = 0x02, |
| 1841 | GSM48_SIGNAL_NET_CONG = 0x03, |
| 1842 | GSM48_SIGNAL_BUSY = 0x04, |
| 1843 | GSM48_SIGNAL_CONFIRM = 0x05, |
| 1844 | GSM48_SIGNAL_ANSWER = 0x06, |
| 1845 | GSM48_SIGNAL_CALL_WAIT = 0x07, |
| 1846 | GSM48_SIGNAL_OFF_HOOK = 0x08, |
| 1847 | GSM48_SIGNAL_OFF = 0x3f, |
| 1848 | GSM48_SIGNAL_ALERT_OFF = 0x4f, |
| 1849 | }; |
| 1850 | |
Keith | adfa199 | 2018-05-25 15:24:06 +0200 | [diff] [blame] | 1851 | /* Section 10.5.4.11 / Table 10.5.122 */ |
| 1852 | enum gsm48_cause_coding { |
| 1853 | GSM48_CAUSE_CODING_CCITT_Q931 = 0x00, |
| 1854 | GSM48_CAUSE_CODING_RESERVED = 0x01, |
| 1855 | GSM48_CAUSE_CODING_NATIONAL = 0x02, |
| 1856 | GSM48_CAUSE_CODING_GSM = 0x03, |
| 1857 | }; |
| 1858 | |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1859 | enum gsm48_cause_loc { |
| 1860 | GSM48_CAUSE_LOC_USER = 0x00, |
| 1861 | GSM48_CAUSE_LOC_PRN_S_LU = 0x01, |
| 1862 | GSM48_CAUSE_LOC_PUN_S_LU = 0x02, |
| 1863 | GSM48_CAUSE_LOC_TRANS_NET = 0x03, |
| 1864 | GSM48_CAUSE_LOC_PUN_S_RU = 0x04, |
| 1865 | GSM48_CAUSE_LOC_PRN_S_RU = 0x05, |
| 1866 | /* not defined */ |
| 1867 | GSM48_CAUSE_LOC_INN_NET = 0x07, |
| 1868 | GSM48_CAUSE_LOC_NET_BEYOND = 0x0a, |
| 1869 | }; |
| 1870 | |
Neels Hofmeyr | 6ad50aa | 2019-01-14 20:28:56 +0100 | [diff] [blame] | 1871 | /* 3GPP TS 44.018 10.5.2.31 RR Cause / Table 10.5.70 */ |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1872 | enum gsm48_rr_cause { |
| 1873 | GSM48_RR_CAUSE_NORMAL = 0x00, |
| 1874 | GSM48_RR_CAUSE_ABNORMAL_UNSPEC = 0x01, |
| 1875 | GSM48_RR_CAUSE_ABNORMAL_UNACCT = 0x02, |
| 1876 | GSM48_RR_CAUSE_ABNORMAL_TIMER = 0x03, |
| 1877 | GSM48_RR_CAUSE_ABNORMAL_NOACT = 0x04, |
| 1878 | GSM48_RR_CAUSE_PREMPTIVE_REL = 0x05, |
Andreas Eversberg | c8cac64 | 2013-06-19 20:58:59 +0200 | [diff] [blame] | 1879 | GSM48_RR_CAUSE_HNDOVER_IMP = 0x08, |
| 1880 | GSM48_RR_CAUSE_CHAN_MODE_UNACCT = 0x09, |
| 1881 | GSM48_RR_CAUSE_FREQ_NOT_IMPL = 0x0a, |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1882 | GSM48_RR_CAUSE_CALL_CLEARED = 0x41, |
| 1883 | GSM48_RR_CAUSE_SEMANT_INCORR = 0x5f, |
| 1884 | GSM48_RR_CAUSE_INVALID_MAND_INF = 0x60, |
| 1885 | GSM48_RR_CAUSE_MSG_TYPE_N = 0x61, |
| 1886 | GSM48_RR_CAUSE_MSG_TYPE_N_COMPAT= 0x62, |
| 1887 | GSM48_RR_CAUSE_COND_IE_ERROR = 0x64, |
| 1888 | GSM48_RR_CAUSE_NO_CELL_ALLOC_A = 0x65, |
| 1889 | GSM48_RR_CAUSE_PROT_ERROR_UNSPC = 0x6f, |
| 1890 | }; |
| 1891 | |
| 1892 | /* Section 10.5.4.11 CC Cause / Table 10.5.123 */ |
| 1893 | enum gsm48_cc_cause { |
| 1894 | GSM48_CC_CAUSE_UNASSIGNED_NR = 1, |
| 1895 | GSM48_CC_CAUSE_NO_ROUTE = 3, |
| 1896 | GSM48_CC_CAUSE_CHAN_UNACCEPT = 6, |
| 1897 | GSM48_CC_CAUSE_OP_DET_BARRING = 8, |
| 1898 | GSM48_CC_CAUSE_NORM_CALL_CLEAR = 16, |
| 1899 | GSM48_CC_CAUSE_USER_BUSY = 17, |
| 1900 | GSM48_CC_CAUSE_USER_NOTRESPOND = 18, |
| 1901 | GSM48_CC_CAUSE_USER_ALERTING_NA = 19, |
| 1902 | GSM48_CC_CAUSE_CALL_REJECTED = 21, |
| 1903 | GSM48_CC_CAUSE_NUMBER_CHANGED = 22, |
| 1904 | GSM48_CC_CAUSE_PRE_EMPTION = 25, |
| 1905 | GSM48_CC_CAUSE_NONSE_USER_CLR = 26, |
| 1906 | GSM48_CC_CAUSE_DEST_OOO = 27, |
| 1907 | GSM48_CC_CAUSE_INV_NR_FORMAT = 28, |
| 1908 | GSM48_CC_CAUSE_FACILITY_REJ = 29, |
| 1909 | GSM48_CC_CAUSE_RESP_STATUS_INQ = 30, |
| 1910 | GSM48_CC_CAUSE_NORMAL_UNSPEC = 31, |
| 1911 | GSM48_CC_CAUSE_NO_CIRCUIT_CHAN = 34, |
| 1912 | GSM48_CC_CAUSE_NETWORK_OOO = 38, |
| 1913 | GSM48_CC_CAUSE_TEMP_FAILURE = 41, |
| 1914 | GSM48_CC_CAUSE_SWITCH_CONG = 42, |
| 1915 | GSM48_CC_CAUSE_ACC_INF_DISCARD = 43, |
| 1916 | GSM48_CC_CAUSE_REQ_CHAN_UNAVAIL = 44, |
| 1917 | GSM48_CC_CAUSE_RESOURCE_UNAVAIL = 47, |
| 1918 | GSM48_CC_CAUSE_QOS_UNAVAIL = 49, |
| 1919 | GSM48_CC_CAUSE_REQ_FAC_NOT_SUBSC= 50, |
| 1920 | GSM48_CC_CAUSE_INC_BARRED_CUG = 55, |
| 1921 | GSM48_CC_CAUSE_BEARER_CAP_UNAUTH= 57, |
| 1922 | GSM48_CC_CAUSE_BEARER_CA_UNAVAIL= 58, |
| 1923 | GSM48_CC_CAUSE_SERV_OPT_UNAVAIL = 63, |
| 1924 | GSM48_CC_CAUSE_BEARERSERV_UNIMPL= 65, |
| 1925 | GSM48_CC_CAUSE_ACM_GE_ACM_MAX = 68, |
| 1926 | GSM48_CC_CAUSE_REQ_FAC_NOTIMPL = 69, |
| 1927 | GSM48_CC_CAUSE_RESTR_BCAP_AVAIL = 70, |
| 1928 | GSM48_CC_CAUSE_SERV_OPT_UNIMPL = 79, |
| 1929 | GSM48_CC_CAUSE_INVAL_TRANS_ID = 81, |
| 1930 | GSM48_CC_CAUSE_USER_NOT_IN_CUG = 87, |
| 1931 | GSM48_CC_CAUSE_INCOMPAT_DEST = 88, |
| 1932 | GSM48_CC_CAUSE_INVAL_TRANS_NET = 91, |
| 1933 | GSM48_CC_CAUSE_SEMANTIC_INCORR = 95, |
| 1934 | GSM48_CC_CAUSE_INVAL_MAND_INF = 96, |
| 1935 | GSM48_CC_CAUSE_MSGTYPE_NOTEXIST = 97, |
| 1936 | GSM48_CC_CAUSE_MSGTYPE_INCOMPAT = 98, |
| 1937 | GSM48_CC_CAUSE_IE_NOTEXIST = 99, |
| 1938 | GSM48_CC_CAUSE_COND_IE_ERR = 100, |
| 1939 | GSM48_CC_CAUSE_MSG_INCOMP_STATE = 101, |
| 1940 | GSM48_CC_CAUSE_RECOVERY_TIMER = 102, |
| 1941 | GSM48_CC_CAUSE_PROTO_ERR = 111, |
| 1942 | GSM48_CC_CAUSE_INTERWORKING = 127, |
| 1943 | }; |
| 1944 | |
Keith | 3cdaa8d | 2018-08-31 20:09:18 +0200 | [diff] [blame] | 1945 | extern const struct value_string gsm48_cc_cause_names[]; |
| 1946 | static inline const char *gsm48_cc_cause_name(enum gsm48_cc_cause val) |
| 1947 | { return get_value_string(gsm48_cc_cause_names, val); } |
| 1948 | |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1949 | /* Annex G, GSM specific cause values for mobility management */ |
| 1950 | enum gsm48_reject_value { |
| 1951 | GSM48_REJECT_IMSI_UNKNOWN_IN_HLR = 2, |
| 1952 | GSM48_REJECT_ILLEGAL_MS = 3, |
| 1953 | GSM48_REJECT_IMSI_UNKNOWN_IN_VLR = 4, |
| 1954 | GSM48_REJECT_IMEI_NOT_ACCEPTED = 5, |
| 1955 | GSM48_REJECT_ILLEGAL_ME = 6, |
| 1956 | GSM48_REJECT_PLMN_NOT_ALLOWED = 11, |
| 1957 | GSM48_REJECT_LOC_NOT_ALLOWED = 12, |
| 1958 | GSM48_REJECT_ROAMING_NOT_ALLOWED = 13, |
| 1959 | GSM48_REJECT_NETWORK_FAILURE = 17, |
Neels Hofmeyr | 55a43b8 | 2017-02-02 20:27:55 +0100 | [diff] [blame] | 1960 | GSM48_REJECT_SYNCH_FAILURE = 21, |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1961 | GSM48_REJECT_CONGESTION = 22, |
| 1962 | GSM48_REJECT_SRV_OPT_NOT_SUPPORTED = 32, |
| 1963 | GSM48_REJECT_RQD_SRV_OPT_NOT_SUPPORTED = 33, |
| 1964 | GSM48_REJECT_SRV_OPT_TMP_OUT_OF_ORDER = 34, |
| 1965 | GSM48_REJECT_CALL_CAN_NOT_BE_IDENTIFIED = 38, |
| 1966 | GSM48_REJECT_INCORRECT_MESSAGE = 95, |
| 1967 | GSM48_REJECT_INVALID_MANDANTORY_INF = 96, |
| 1968 | GSM48_REJECT_MSG_TYPE_NOT_IMPLEMENTED = 97, |
| 1969 | GSM48_REJECT_MSG_TYPE_NOT_COMPATIBLE = 98, |
| 1970 | GSM48_REJECT_INF_ELEME_NOT_IMPLEMENTED = 99, |
| 1971 | GSM48_REJECT_CONDTIONAL_IE_ERROR = 100, |
| 1972 | GSM48_REJECT_MSG_NOT_COMPATIBLE = 101, |
| 1973 | GSM48_REJECT_PROTOCOL_ERROR = 111, |
| 1974 | |
| 1975 | /* according to G.6 Additional cause codes for GMM */ |
| 1976 | GSM48_REJECT_GPRS_NOT_ALLOWED = 7, |
| 1977 | GSM48_REJECT_SERVICES_NOT_ALLOWED = 8, |
| 1978 | GSM48_REJECT_MS_IDENTITY_NOT_DERVIVABLE = 9, |
| 1979 | GSM48_REJECT_IMPLICITLY_DETACHED = 10, |
| 1980 | GSM48_REJECT_GPRS_NOT_ALLOWED_IN_PLMN = 14, |
| 1981 | GSM48_REJECT_MSC_TMP_NOT_REACHABLE = 16, |
| 1982 | }; |
| 1983 | |
Neels Hofmeyr | aead241 | 2018-04-06 04:31:00 +0200 | [diff] [blame] | 1984 | extern const struct value_string gsm48_reject_value_names[]; |
| 1985 | static inline const char *gsm48_reject_value_name(enum gsm48_reject_value val) |
| 1986 | { return get_value_string(gsm48_reject_value_names, val); } |
| 1987 | |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1988 | enum chreq_type { |
| 1989 | CHREQ_T_EMERG_CALL, |
| 1990 | CHREQ_T_CALL_REEST_TCH_F, |
| 1991 | CHREQ_T_CALL_REEST_TCH_H, |
| 1992 | CHREQ_T_CALL_REEST_TCH_H_DBL, |
| 1993 | CHREQ_T_SDCCH, |
| 1994 | CHREQ_T_TCH_F, |
| 1995 | CHREQ_T_VOICE_CALL_TCH_H, |
| 1996 | CHREQ_T_DATA_CALL_TCH_H, |
| 1997 | CHREQ_T_LOCATION_UPD, |
| 1998 | CHREQ_T_PAG_R_ANY_NECI0, |
| 1999 | CHREQ_T_PAG_R_ANY_NECI1, |
| 2000 | CHREQ_T_PAG_R_TCH_F, |
| 2001 | CHREQ_T_PAG_R_TCH_FH, |
| 2002 | CHREQ_T_LMU, |
| 2003 | CHREQ_T_RESERVED_SDCCH, |
| 2004 | CHREQ_T_RESERVED_IGNORE, |
Alexander Couzens | f48e8a8 | 2016-12-05 15:57:42 +0100 | [diff] [blame] | 2005 | CHREQ_T_PDCH_ONE_PHASE, |
| 2006 | CHREQ_T_PDCH_TWO_PHASE, |
Alexander Couzens | 953f929 | 2017-03-14 13:47:29 +0100 | [diff] [blame] | 2007 | _NUM_CHREQ_T, |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 2008 | }; |
| 2009 | |
| 2010 | /* Chapter 11.3 */ |
| 2011 | #define GSM48_T301 180, 0 |
| 2012 | #define GSM48_T303 30, 0 |
| 2013 | #define GSM48_T305 30, 0 |
| 2014 | #define GSM48_T306 30, 0 |
Harald Welte | e50b009 | 2018-01-27 09:40:34 +0100 | [diff] [blame] | 2015 | #define GSM48_T308 10, 0 /* no spec default */ |
Harald Welte | cd82710 | 2018-01-27 09:43:03 +0100 | [diff] [blame] | 2016 | #define GSM48_T310 30, 0 /* no spec default */ |
Harald Welte | e50b009 | 2018-01-27 09:40:34 +0100 | [diff] [blame] | 2017 | #define GSM48_T313 30, 0 /* no spec default */ |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 2018 | #define GSM48_T323 30, 0 |
Harald Welte | e50b009 | 2018-01-27 09:40:34 +0100 | [diff] [blame] | 2019 | #define GSM48_T331 30, 0 /* no spec default */ |
| 2020 | #define GSM48_T333 30, 0 /* no spec default */ |
| 2021 | #define GSM48_T334 25, 0 /* min 15s */ |
| 2022 | #define GSM48_T338 30, 0 /* no spec default */ |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 2023 | #define GSM48_T303_MS 30, 0 |
| 2024 | #define GSM48_T305_MS 30, 0 |
| 2025 | #define GSM48_T308_MS 30, 0 |
| 2026 | #define GSM48_T310_MS 30, 0 |
| 2027 | #define GSM48_T313_MS 30, 0 |
| 2028 | #define GSM48_T323_MS 30, 0 |
| 2029 | #define GSM48_T332_MS 30, 0 |
| 2030 | #define GSM48_T335_MS 30, 0 |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 2031 | |
| 2032 | /* Chapter 5.1.2.2 */ |
| 2033 | #define GSM_CSTATE_NULL 0 |
| 2034 | #define GSM_CSTATE_INITIATED 1 |
Andreas Eversberg | 1ef041f | 2010-04-09 07:52:12 +0200 | [diff] [blame] | 2035 | #define GSM_CSTATE_MM_CONNECTION_PEND 2 /* see 10.5.4.6 */ |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 2036 | #define GSM_CSTATE_MO_CALL_PROC 3 |
| 2037 | #define GSM_CSTATE_CALL_DELIVERED 4 |
| 2038 | #define GSM_CSTATE_CALL_PRESENT 6 |
| 2039 | #define GSM_CSTATE_CALL_RECEIVED 7 |
| 2040 | #define GSM_CSTATE_CONNECT_REQUEST 8 |
| 2041 | #define GSM_CSTATE_MO_TERM_CALL_CONF 9 |
| 2042 | #define GSM_CSTATE_ACTIVE 10 |
| 2043 | #define GSM_CSTATE_DISCONNECT_REQ 12 |
| 2044 | #define GSM_CSTATE_DISCONNECT_IND 12 |
| 2045 | #define GSM_CSTATE_RELEASE_REQ 19 |
| 2046 | #define GSM_CSTATE_MO_ORIG_MODIFY 26 |
| 2047 | #define GSM_CSTATE_MO_TERM_MODIFY 27 |
| 2048 | #define GSM_CSTATE_CONNECT_IND 28 |
| 2049 | |
| 2050 | #define SBIT(a) (1 << a) |
| 2051 | #define ALL_STATES 0xffffffff |
| 2052 | |
| 2053 | /* Table 10.5.3/3GPP TS 04.08: Location Area Identification information element */ |
| 2054 | #define GSM_LAC_RESERVED_DETACHED 0x0 |
| 2055 | #define GSM_LAC_RESERVED_ALL_BTS 0xfffe |
| 2056 | |
| 2057 | /* GSM 04.08 Bearer Capability: Information Transfer Capability */ |
| 2058 | enum gsm48_bcap_itcap { |
| 2059 | GSM48_BCAP_ITCAP_SPEECH = 0, |
| 2060 | GSM48_BCAP_ITCAP_UNR_DIG_INF = 1, |
| 2061 | GSM48_BCAP_ITCAP_3k1_AUDIO = 2, |
| 2062 | GSM48_BCAP_ITCAP_FAX_G3 = 3, |
| 2063 | GSM48_BCAP_ITCAP_OTHER = 5, |
| 2064 | GSM48_BCAP_ITCAP_RESERVED = 7, |
| 2065 | }; |
| 2066 | |
| 2067 | /* GSM 04.08 Bearer Capability: Transfer Mode */ |
| 2068 | enum gsm48_bcap_tmod { |
| 2069 | GSM48_BCAP_TMOD_CIRCUIT = 0, |
| 2070 | GSM48_BCAP_TMOD_PACKET = 1, |
| 2071 | }; |
| 2072 | |
| 2073 | /* GSM 04.08 Bearer Capability: Coding Standard */ |
| 2074 | enum gsm48_bcap_coding { |
| 2075 | GSM48_BCAP_CODING_GSM_STD = 0, |
| 2076 | }; |
| 2077 | |
| 2078 | /* GSM 04.08 Bearer Capability: Radio Channel Requirements */ |
| 2079 | enum gsm48_bcap_rrq { |
| 2080 | GSM48_BCAP_RRQ_FR_ONLY = 1, |
| 2081 | GSM48_BCAP_RRQ_DUAL_HR = 2, |
| 2082 | GSM48_BCAP_RRQ_DUAL_FR = 3, |
| 2083 | }; |
| 2084 | |
Harald Welte | c8a0b93 | 2012-08-24 21:27:26 +0200 | [diff] [blame] | 2085 | /* GSM 04.08 Bearer Capability: Rate Adaption */ |
| 2086 | enum gsm48_bcap_ra { |
| 2087 | GSM48_BCAP_RA_NONE = 0, |
| 2088 | GSM48_BCAP_RA_V110_X30 = 1, |
| 2089 | GSM48_BCAP_RA_X31 = 2, |
| 2090 | GSM48_BCAP_RA_OTHER = 3, |
| 2091 | }; |
| 2092 | |
| 2093 | /* GSM 04.08 Bearer Capability: Signalling access protocol */ |
| 2094 | enum gsm48_bcap_sig_access { |
| 2095 | GSM48_BCAP_SA_I440_I450 = 1, |
| 2096 | GSM48_BCAP_SA_X21 = 2, |
| 2097 | GSM48_BCAP_SA_X28_DP_IN = 3, |
| 2098 | GSM48_BCAP_SA_X28_DP_UN = 4, |
| 2099 | GSM48_BCAP_SA_X28_NDP = 5, |
| 2100 | GSM48_BCAP_SA_X32 = 6, |
| 2101 | }; |
| 2102 | |
| 2103 | /* GSM 04.08 Bearer Capability: User Rate */ |
| 2104 | enum gsm48_bcap_user_rate { |
| 2105 | GSM48_BCAP_UR_300 = 1, |
| 2106 | GSM48_BCAP_UR_1200 = 2, |
| 2107 | GSM48_BCAP_UR_2400 = 3, |
| 2108 | GSM48_BCAP_UR_4800 = 4, |
| 2109 | GSM48_BCAP_UR_9600 = 5, |
| 2110 | GSM48_BCAP_UR_12000 = 6, |
| 2111 | GSM48_BCAP_UR_1200_75 = 7, |
| 2112 | }; |
| 2113 | |
| 2114 | /* GSM 04.08 Bearer Capability: Parity */ |
| 2115 | enum gsm48_bcap_parity { |
| 2116 | GSM48_BCAP_PAR_ODD = 0, |
| 2117 | GSM48_BCAP_PAR_EVEN = 2, |
| 2118 | GSM48_BCAP_PAR_NONE = 3, |
| 2119 | GSM48_BCAP_PAR_ZERO = 4, |
| 2120 | GSM48_BCAP_PAR_ONE = 5, |
| 2121 | }; |
| 2122 | |
| 2123 | /* GSM 04.08 Bearer Capability: Intermediate Rate */ |
| 2124 | enum gsm48_bcap_interm_rate { |
| 2125 | GSM48_BCAP_IR_8k = 2, |
| 2126 | GSM48_BCAP_IR_16k = 3, |
| 2127 | }; |
| 2128 | |
| 2129 | /* GSM 04.08 Bearer Capability: Transparency */ |
| 2130 | enum gsm48_bcap_transp { |
| 2131 | GSM48_BCAP_TR_TRANSP = 0, |
| 2132 | GSM48_BCAP_TR_RLP = 1, |
| 2133 | GSM48_BCAP_TR_TR_PREF = 2, |
| 2134 | GSM48_BCAP_TR_RLP_PREF = 3, |
| 2135 | }; |
| 2136 | |
| 2137 | /* GSM 04.08 Bearer Capability: Modem Type */ |
| 2138 | enum gsm48_bcap_modem_type { |
| 2139 | GSM48_BCAP_MT_NONE = 0, |
| 2140 | GSM48_BCAP_MT_V21 = 1, |
| 2141 | GSM48_BCAP_MT_V22 = 2, |
| 2142 | GSM48_BCAP_MT_V22bis = 3, |
| 2143 | GSM48_BCAP_MT_V23 = 4, |
| 2144 | GSM48_BCAP_MT_V26ter = 5, |
| 2145 | GSM48_BCAP_MT_V32 = 6, |
| 2146 | GSM48_BCAP_MT_UNDEF = 7, |
| 2147 | GSM48_BCAP_MT_AUTO_1 = 8, |
| 2148 | }; |
| 2149 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 2150 | /*! GSM 04.08 Bearer Capability: Speech Version Indication |
Philipp Maier | 3d9191e | 2017-05-31 17:22:03 +0200 | [diff] [blame] | 2151 | * (See also 3GPP TS 24.008, Table 10.5.103) */ |
Harald Welte | 30a8ec4 | 2012-08-24 23:00:05 +0200 | [diff] [blame] | 2152 | enum gsm48_bcap_speech_ver { |
Philipp Maier | a9e193b | 2017-06-16 16:47:06 +0200 | [diff] [blame] | 2153 | GSM48_BCAP_SV_FR = 0, /*!< GSM FR V1 (GSM FR) */ |
| 2154 | GSM48_BCAP_SV_HR = 1, /*!< GSM HR V1 (GSM HR) */ |
| 2155 | GSM48_BCAP_SV_EFR = 2, /*!< GSM FR V2 (GSM EFR) */ |
| 2156 | GSM48_BCAP_SV_AMR_F = 4, /*!< GSM FR V3 (FR AMR) */ |
| 2157 | GSM48_BCAP_SV_AMR_H = 5, /*!< GSM HR V3 (HR_AMR) */ |
Philipp Maier | 3d9191e | 2017-05-31 17:22:03 +0200 | [diff] [blame] | 2158 | GSM48_BCAP_SV_AMR_OFW = 6, /*!< GSM FR V4 (OFR AMR-WB) */ |
| 2159 | GSM48_BCAP_SV_AMR_OHW = 7, /*!< GSM HR V4 (OHR AMR-WB) */ |
| 2160 | GSM48_BCAP_SV_AMR_FW = 8, /*!< GSM FR V5 (FR AMR-WB) */ |
| 2161 | GSM48_BCAP_SV_AMR_OH = 11, /*!< GSM HR V6 (OHR AMR) */ |
Harald Welte | 30a8ec4 | 2012-08-24 23:00:05 +0200 | [diff] [blame] | 2162 | }; |
| 2163 | |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 2164 | #define GSM48_TMSI_LEN 5 |
| 2165 | #define GSM48_MID_TMSI_LEN (GSM48_TMSI_LEN + 2) |
| 2166 | #define GSM48_MI_SIZE 32 |
| 2167 | |
Max | ff2eeda | 2018-01-04 18:43:44 +0100 | [diff] [blame] | 2168 | /* 3GPP TS 24.008 ยง 10.5.5.15 Routing area identification */ |
Harald Welte | a1c4f76 | 2010-05-01 11:59:42 +0200 | [diff] [blame] | 2169 | struct gsm48_ra_id { |
| 2170 | uint8_t digits[3]; /* MCC + MNC BCD digits */ |
| 2171 | uint16_t lac; /* Location Area Code */ |
| 2172 | uint8_t rac; /* Routing Area Code */ |
| 2173 | } __attribute__ ((packed)); |
| 2174 | |
Harald Welte | b550313 | 2011-05-24 15:01:53 +0200 | [diff] [blame] | 2175 | #define GSM48_CELL_CHAN_DESC_SIZE 16 |
Harald Welte | a1c4f76 | 2010-05-01 11:59:42 +0200 | [diff] [blame] | 2176 | |
Harald Welte | b550313 | 2011-05-24 15:01:53 +0200 | [diff] [blame] | 2177 | #define GSM_MACBLOCK_LEN 23 |
| 2178 | #define GSM_MACBLOCK_PADDING 0x2b |
Harald Welte | 5547808 | 2018-02-09 22:39:29 +0100 | [diff] [blame] | 2179 | |
| 2180 | /* Table 10.5.118 / 3GPP TS 24.008 Section 10.5.4.7 */ |
| 2181 | enum gsm48_type_of_number { |
| 2182 | GSM48_TON_UNKNOWN = 0, |
| 2183 | GSM48_TON_INTERNATIONAL = 1, |
| 2184 | GSM48_TON_NATIONAL = 2, |
| 2185 | GSM48_TON_NET_SPEC = 3, |
| 2186 | GSM48_TON_SHORT_CODE = 4, |
| 2187 | /* reserved */ |
| 2188 | }; |
| 2189 | |
| 2190 | /* Table 10.5.118 / 3GPP TS 24.008 Section 10.5.4.7 */ |
| 2191 | enum gsm48_numbering_plan { |
| 2192 | GSM48_NPI_UNKNOWN = 0, |
| 2193 | GSM48_NPI_ISDN_E164 = 1, |
| 2194 | GSM48_NPI_DATA_X121 = 3, |
| 2195 | GSM48_NPI_TELEX_F69 = 4, |
| 2196 | GSM48_NPI_NATIONAL = 8, |
| 2197 | GSM48_NPI_PRIVATE = 9, |
| 2198 | GSM48_NPI_CTS = 11, |
| 2199 | /* reserved */ |
| 2200 | }; |