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