Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 1 | /* Data Types / Encoding / Decoding for OsmocomBB L1CTL interface */ |
| 2 | /* (C) 2017 by Harald Welte <laforge@gnumonks.org>, derived from l1ctl_proto.h |
Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 3 | * which is (C) 2010 by Harald Welte + Holger Hans Peter Freyther |
| 4 | * All rights reserved. |
| 5 | * |
| 6 | * Released under the terms of GNU General Public License, Version 2 or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 10 | */ |
| 11 | |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 12 | module L1CTL_Types { |
| 13 | |
| 14 | import from General_Types all; |
| 15 | import from GSM_Types all; |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 16 | import from GSM_RR_Types all; |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 17 | import from Osmocom_Types all; |
| 18 | |
Harald Welte | 7024baa | 2018-03-02 23:37:51 +0100 | [diff] [blame] | 19 | type uint32_t uint32_le with { variant "BYTEORDER(first)" }; |
| 20 | |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 21 | type enumerated L1ctlMsgType { |
| 22 | L1CTL_NONE, |
| 23 | L1CTL_FBSB_REQ, |
| 24 | L1CTL_FBSB_CONF, |
| 25 | L1CTL_DATA_IND, |
| 26 | L1CTL_RACH_REQ, |
| 27 | L1CTL_DM_EST_REQ, |
| 28 | L1CTL_DATA_REQ, |
| 29 | L1CTL_RESET_IND, |
| 30 | L1CTL_PM_REQ, /* power measurement */ |
| 31 | L1CTL_PM_CONF, /* power measurement */ |
| 32 | L1CTL_ECHO_REQ, |
| 33 | L1CTL_ECHO_CONF, |
| 34 | L1CTL_RACH_CONF, |
| 35 | L1CTL_RESET_REQ, |
| 36 | L1CTL_RESET_CONF, |
| 37 | L1CTL_DATA_CONF, |
| 38 | L1CTL_CCCH_MODE_REQ, |
| 39 | L1CTL_CCCH_MODE_CONF, |
| 40 | L1CTL_DM_REL_REQ, |
| 41 | L1CTL_PARAM_REQ, |
| 42 | L1CTL_DM_FREQ_REQ, |
| 43 | L1CTL_CRYPTO_REQ, |
| 44 | L1CTL_SIM_REQ, |
| 45 | L1CTL_SIM_CONF, |
| 46 | L1CTL_TCH_MODE_REQ, |
| 47 | L1CTL_TCH_MODE_CONF, |
| 48 | L1CTL_NEIGH_PM_REQ, |
| 49 | L1CTL_NEIGH_PM_IND, |
| 50 | L1CTL_TRAFFIC_REQ, |
| 51 | L1CTL_TRAFFIC_CONF, |
Harald Welte | 00d4dac | 2017-07-30 00:50:32 +0200 | [diff] [blame] | 52 | L1CTL_TRAFFIC_IND, |
Vadim Yanitskiy | 4e79ff5 | 2019-04-22 06:38:21 +0700 | [diff] [blame] | 53 | L1CTL_BURST_IND, |
Harald Welte | 00d4dac | 2017-07-30 00:50:32 +0200 | [diff] [blame] | 54 | L1CTL_TBF_CFG_REQ, |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 55 | L1CTL_TBF_CFG_CONF, |
| 56 | L1CTL_DATA_TBF_REQ, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 57 | L1CTL_DATA_TBF_CONF, |
Vadim Yanitskiy | 5c83679 | 2019-04-22 05:45:03 +0700 | [diff] [blame] | 58 | L1CTL_EXT_RACH_REQ, |
| 59 | L1CTL_DATA_ABS_REQ /*!< FIXME: no such message in OsmocomBB */ |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 60 | } with { variant "FIELDLENGTH(8)" }; |
| 61 | |
| 62 | type enumerated L1ctlCcchMode { |
| 63 | CCCH_MODE_NONE (0), |
| 64 | CCCH_MODE_NON_COMBINED, |
Harald Welte | 990a361 | 2019-05-27 14:02:13 +0200 | [diff] [blame] | 65 | CCCH_MODE_COMBINED, |
| 66 | CCCH_MODE_COMBINED_CBCH |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 67 | } with { variant "FIELDLENGTH(8)" }; |
| 68 | |
| 69 | type enumerated L1ctlNeighMode { |
| 70 | NEIGH_MODE_NONE (0), |
| 71 | NEIGH_MODE_PM, |
| 72 | NEIGH_MODE_SB |
| 73 | } with { variant "FIELDLENGTH(8)" }; |
| 74 | |
Harald Welte | 1dcc371 | 2017-08-01 00:05:52 +0200 | [diff] [blame] | 75 | type enumerated L1ctlGprsCs { |
| 76 | L1CTL_CS1 (1), |
| 77 | L1CTL_CS2, |
| 78 | L1CTL_CS3, |
| 79 | L1CTL_CS4, |
| 80 | L1CTL_MCS1, |
| 81 | L1CTL_MCS2, |
| 82 | L1CTL_MCS3, |
| 83 | L1CTL_MCS4, |
| 84 | L1CTL_MCS5, |
| 85 | L1CTL_MCS6, |
| 86 | L1CTL_MCS7, |
| 87 | L1CTL_MCS8, |
| 88 | L1CTL_MCS9 |
| 89 | } with { variant "FIELDLENGTH(8)" }; |
| 90 | |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 91 | type enumerated L1ctlResetType { |
| 92 | L1CTL_RES_T_BOOT (0), |
| 93 | L1CTL_RES_T_FULL, |
| 94 | L1CTL_RES_T_SCHED |
| 95 | } with { variant "FIELDLENGTH(8)" }; |
| 96 | |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 97 | type record L1ctlHdrFlags { |
| 98 | BIT7 padding, |
| 99 | boolean f_done |
| 100 | } with { variant "" }; |
| 101 | |
| 102 | type record L1ctlHeader { |
| 103 | L1ctlMsgType msg_type, |
| 104 | L1ctlHdrFlags flags, |
| 105 | OCT2 padding |
| 106 | } with { variant "" }; |
| 107 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 108 | template L1ctlHeader tr_L1ctlHeader(template L1ctlMsgType msg_type) := { |
| 109 | msg_type := msg_type, |
| 110 | flags := ?, |
| 111 | padding := ? |
| 112 | }; |
| 113 | |
| 114 | template (value) L1ctlHeader ts_L1ctlHeader(L1ctlMsgType msg_type) := { |
Harald Welte | 52c713c | 2017-07-16 15:44:44 +0200 | [diff] [blame] | 115 | msg_type := msg_type, |
| 116 | flags := { padding := '0000000'B, f_done := false }, |
| 117 | padding := '0000'O |
| 118 | }; |
| 119 | |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 120 | type record L1ctlDlInfo { |
Harald Welte | 8e4db2c | 2017-07-16 18:54:55 +0200 | [diff] [blame] | 121 | RslChannelNr chan_nr, |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 122 | RslLinkId link_id, |
| 123 | Arfcn arfcn, |
Harald Welte | 5f0d5c8 | 2017-07-16 18:56:01 +0200 | [diff] [blame] | 124 | uint32_t frame_nr, |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 125 | GsmRxLev rx_level, |
| 126 | uint8_t snr, |
| 127 | uint8_t num_biterr, |
| 128 | uint8_t fire_crc |
| 129 | } with { variant "" }; |
| 130 | |
| 131 | type record L1ctlFbsbConf { |
| 132 | int16_t initial_freq_err, |
| 133 | uint8_t result, |
| 134 | uint8_t bsic |
| 135 | } with { variant "" }; |
| 136 | |
| 137 | type record L1ctlCcchModeConf { |
| 138 | L1ctlCcchMode ccch_mode, |
| 139 | OCT3 padding |
| 140 | } with { variant "" }; |
| 141 | |
| 142 | /* gsm48_chan_mode */ |
| 143 | type uint8_t L1ctlTchMode; |
| 144 | |
| 145 | type record L1ctlAudioMode { |
| 146 | BIT4 padding, |
| 147 | boolean tx_microphone, |
| 148 | boolean tx_traffic_req, |
| 149 | boolean rx_speaker, |
| 150 | boolean rx_traffic_ind |
| 151 | } with { variant "" }; |
| 152 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 153 | template (value) L1ctlAudioMode t_L1CTL_AudioModeNone := { '0000'B, false, false, false, false }; |
Harald Welte | 66110f0 | 2017-07-16 21:05:18 +0200 | [diff] [blame] | 154 | |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 155 | type record L1ctlTchModeConf { |
| 156 | L1ctlTchMode tch_mode, |
| 157 | L1ctlAudioMode audio_mode, |
| 158 | OCT2 padding |
| 159 | } with { variant "" }; |
| 160 | |
| 161 | type record L1ctlDataInd { |
Vadim Yanitskiy | 2a92e2a | 2019-05-28 21:13:35 +0700 | [diff] [blame] | 162 | octetstring payload |
Harald Welte | 7024baa | 2018-03-02 23:37:51 +0100 | [diff] [blame] | 163 | } with { |
| 164 | variant (payload) "BYTEORDER(first)" |
| 165 | }; |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 166 | |
| 167 | type union L1ctlDlPayload { |
| 168 | L1ctlFbsbConf fbsb_conf, |
| 169 | L1ctlCcchModeConf ccch_mode_conf, |
| 170 | L1ctlTchModeConf tch_mode_conf, |
| 171 | L1ctlDataInd data_ind, |
| 172 | L1ctlTrafficReq traffic_ind, |
Harald Welte | 00d4dac | 2017-07-30 00:50:32 +0200 | [diff] [blame] | 173 | L1ctlTbfCfgReq tbf_cfg_conf, |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 174 | octetstring other |
Harald Welte | 7024baa | 2018-03-02 23:37:51 +0100 | [diff] [blame] | 175 | } with { |
| 176 | variant (other) "BYTEORDER(first)" |
| 177 | }; |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 178 | |
| 179 | type record L1ctlDlMessage { |
| 180 | L1ctlHeader header, |
| 181 | L1ctlDlInfo dl_info optional, |
Harald Welte | f56cc49 | 2018-04-15 10:58:43 +0200 | [diff] [blame] | 182 | L1ctlDlPayload payload optional |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 183 | } with { variant (dl_info) "PRESENCE(header.msg_type = L1CTL_FBSB_CONF, |
| 184 | header.msg_type = L1CTL_RACH_CONF, |
| 185 | header.msg_type = L1CTL_DATA_IND, |
| 186 | header.msg_type = L1CTL_DATA_CONF, |
Harald Welte | 3c4cbf6 | 2018-03-30 10:31:39 +0200 | [diff] [blame] | 187 | header.msg_type = L1CTL_TRAFFIC_IND, |
| 188 | header.msg_type = L1CTL_TRAFFIC_CONF)" |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 189 | variant (payload) "CROSSTAG(fbsb_conf, header.msg_type = L1CTL_FBSB_CONF; |
| 190 | ccch_mode_conf, header.msg_type = L1CTL_CCCH_MODE_CONF; |
| 191 | tch_mode_conf, header.msg_type = L1CTL_TCH_MODE_CONF; |
| 192 | data_ind, header.msg_type = L1CTL_DATA_IND; |
| 193 | traffic_ind, header.msg_type = L1CTL_TRAFFIC_IND; |
Harald Welte | 00d4dac | 2017-07-30 00:50:32 +0200 | [diff] [blame] | 194 | tbf_cfg_conf, header.msg_type = L1CTL_TBF_CFG_CONF; |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 195 | other, OTHERWISE; |
| 196 | )" }; |
| 197 | |
| 198 | external function enc_L1ctlDlMessage(in L1ctlDlMessage msg) return octetstring |
| 199 | with { extension "prototype(convert) encode(RAW)" }; |
| 200 | external function dec_L1ctlDlMessage(in octetstring stream) return L1ctlDlMessage |
| 201 | with { extension "prototype(convert) decode(RAW)" }; |
| 202 | |
| 203 | |
| 204 | type record L1ctlUlInfo { |
Harald Welte | 8e4db2c | 2017-07-16 18:54:55 +0200 | [diff] [blame] | 205 | RslChannelNr chan_nr, |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 206 | RslLinkId link_id, |
| 207 | OCT2 padding |
| 208 | } with { variant "" }; |
| 209 | |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 210 | type record L1ctlUlTbfInfo { |
| 211 | uint8_t tbf_nr, |
Harald Welte | 1dcc371 | 2017-08-01 00:05:52 +0200 | [diff] [blame] | 212 | L1ctlGprsCs cs, |
| 213 | OCT2 padding |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 214 | } with { variant "" }; |
| 215 | |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 216 | type record L1ctlUlAbsInfo { |
| 217 | uint8_t tbf_nr, |
| 218 | L1ctlGprsCs cs, |
| 219 | uint8_t ts_nr, |
| 220 | OCT1 padding, |
Harald Welte | 7024baa | 2018-03-02 23:37:51 +0100 | [diff] [blame] | 221 | uint32_le fn, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 222 | Arfcn arfcn, |
| 223 | OCT2 padding2 |
| 224 | } with { variant "" }; |
| 225 | |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 226 | type record L1ctlFbsbFlags { |
| 227 | BIT5 padding, |
| 228 | boolean sb, |
| 229 | boolean fb1, |
| 230 | boolean fb0 |
Harald Welte | 344c0cf | 2018-03-09 16:17:45 +0100 | [diff] [blame] | 231 | } with { variant "FIELDORDER(msb)" }; |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 232 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 233 | template (value) L1ctlFbsbFlags t_L1CTL_FBSB_F_ALL := { |
Harald Welte | 66110f0 | 2017-07-16 21:05:18 +0200 | [diff] [blame] | 234 | padding := '00000'B, |
| 235 | sb := true, |
| 236 | fb1 := true, |
| 237 | fb0 := true |
| 238 | }; |
| 239 | |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 240 | type record L1ctlFbsbReq { |
| 241 | Arfcn arfcn, |
| 242 | uint16_t timeout_tdma_frames, |
| 243 | uint16_t freq_err_thresh1, |
| 244 | uint16_t freq_err_thresh2, |
| 245 | uint8_t num_freqerr_avg, |
| 246 | L1ctlFbsbFlags flags, |
| 247 | uint8_t sync_info_idx, |
| 248 | L1ctlCcchMode ccch_mode, |
| 249 | GsmRxLev rxlev_exp |
| 250 | } with { variant "" }; |
| 251 | |
| 252 | type record L1ctlCcchModeReq { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 253 | L1ctlCcchMode ccch_mode, |
| 254 | OCT3 padding |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 255 | } with { variant "" }; |
| 256 | |
| 257 | type record L1ctlTchModeReq { |
| 258 | L1ctlTchMode tch_mode, |
| 259 | L1ctlAudioMode audio_mode, |
| 260 | OCT2 padding |
| 261 | } with { variant "" }; |
| 262 | |
| 263 | type record L1ctlRachReq { |
| 264 | uint8_t ra, |
| 265 | uint8_t combined, |
| 266 | uint16_t offset |
| 267 | } with { variant "" }; |
| 268 | |
Vadim Yanitskiy | 5c83679 | 2019-04-22 05:45:03 +0700 | [diff] [blame] | 269 | type enumerated L1ctlRachSynchSeq { |
| 270 | RACH_SYNCH_SEQ_TS0 (0), |
| 271 | RACH_SYNCH_SEQ_TS1, |
| 272 | RACH_SYNCH_SEQ_TS2 |
| 273 | } with { variant "FIELDLENGTH(8)" }; |
| 274 | |
| 275 | type record L1ctlExtRachReq { |
| 276 | uint16_t ra11, |
| 277 | L1ctlRachSynchSeq synch_seq, |
| 278 | uint8_t combined, |
| 279 | uint16_t offset |
| 280 | } with { variant "" }; |
| 281 | |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 282 | type record L1ctlParReq { |
| 283 | int8_t ta, |
| 284 | uint8_t tx_power, |
| 285 | OCT2 padding |
| 286 | } with { variant "" }; |
| 287 | |
Pau Espin Pedrol | 0aad596 | 2018-09-28 16:03:55 +0200 | [diff] [blame] | 288 | type record L1ctlDataReq { |
| 289 | SacchL1Header l1header optional, |
| 290 | octetstring l2_payload |
| 291 | } with { variant "" }; |
| 292 | |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 293 | type record L1ctlH1 { |
| 294 | uint8_t hsn, |
| 295 | uint8_t maio, |
| 296 | uint8_t n, |
| 297 | OCT1 padding, |
| 298 | bitstring ma length(64) |
| 299 | } with { variant "" }; |
| 300 | |
| 301 | type record L1ctlDmEstReq { |
| 302 | GsmTsc tsc, |
| 303 | uint8_t h, |
| 304 | Arfcn arfcn optional, |
| 305 | L1ctlH1 hopping optional, |
| 306 | L1ctlTchMode tch_mode, |
| 307 | L1ctlAudioMode audio_mode |
| 308 | } with { variant (arfcn) "PRESENCE(h = 0)" |
| 309 | variant (hopping) "PRESENCE(h = 1)" }; |
| 310 | |
| 311 | type record L1ctlReset { |
| 312 | L1ctlResetType reset_type, |
| 313 | OCT3 padding |
| 314 | } with { variant "" }; |
| 315 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 316 | type record L1CtlCryptoReq { |
| 317 | uint8_t algo, |
| 318 | uint8_t key_len, |
| 319 | octetstring key |
| 320 | } with { variant (key_len) "LENGTHTO(key)" }; |
| 321 | |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 322 | |
| 323 | type record L1ctlTrafficReq { |
Vadim Yanitskiy | e01691d | 2018-10-29 00:18:04 +0700 | [diff] [blame] | 324 | octetstring data |
Harald Welte | 7024baa | 2018-03-02 23:37:51 +0100 | [diff] [blame] | 325 | } with { |
| 326 | variant (data) "BYTEORDER(first)" |
| 327 | } |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 328 | |
Harald Welte | 00d4dac | 2017-07-30 00:50:32 +0200 | [diff] [blame] | 329 | type record length(8) of uint8_t TfiUsfArr; |
| 330 | |
| 331 | type record L1ctlTbfCfgReq { |
| 332 | uint8_t tbf_nr, |
| 333 | boolean is_uplink, |
| 334 | OCT2 padding, |
| 335 | TfiUsfArr tfi_usf |
| 336 | } with { variant (is_uplink) "FIELDLENGTH(8)" }; |
| 337 | |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 338 | type union L1ctlUlPayload { |
| 339 | L1ctlFbsbReq fbsb_req, |
| 340 | L1ctlCcchModeReq ccch_mode_req, |
| 341 | L1ctlTchModeReq tch_mode_req, |
| 342 | L1ctlRachReq rach_req, |
Vadim Yanitskiy | 5c83679 | 2019-04-22 05:45:03 +0700 | [diff] [blame] | 343 | L1ctlExtRachReq ext_rach_req, |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 344 | L1ctlParReq par_req, |
| 345 | L1ctlDmEstReq dm_est_req, |
| 346 | L1ctlReset reset_req, |
| 347 | //L1ctlNeighPmReq neigh_pm_req, |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 348 | L1CtlCryptoReq crypto_req, |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 349 | L1ctlTrafficReq traffic_req, |
Harald Welte | 00d4dac | 2017-07-30 00:50:32 +0200 | [diff] [blame] | 350 | L1ctlTbfCfgReq tbf_cfg_req, |
Pau Espin Pedrol | 0aad596 | 2018-09-28 16:03:55 +0200 | [diff] [blame] | 351 | L1ctlDataReq data_req, |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 352 | octetstring other |
Harald Welte | 7024baa | 2018-03-02 23:37:51 +0100 | [diff] [blame] | 353 | } with { |
| 354 | variant (other) "BYTEORDER(first)" |
| 355 | }; |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 356 | |
| 357 | type record L1ctlUlMessage { |
| 358 | L1ctlHeader header, |
| 359 | L1ctlUlInfo ul_info optional, |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 360 | L1ctlUlTbfInfo ul_info_tbf optional, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 361 | L1ctlUlAbsInfo ul_info_abs optional, |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 362 | L1ctlUlPayload payload |
| 363 | } with { variant (ul_info) "PRESENCE(header.msg_type = L1CTL_RACH_REQ, |
Vadim Yanitskiy | 5c83679 | 2019-04-22 05:45:03 +0700 | [diff] [blame] | 364 | header.msg_type = L1CTL_EXT_RACH_REQ, |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 365 | header.msg_type = L1CTL_PARAM_REQ, |
| 366 | header.msg_type = L1CTL_CRYPTO_REQ, |
| 367 | header.msg_type = L1CTL_DATA_REQ, |
| 368 | header.msg_type = L1CTL_DM_EST_REQ, |
| 369 | header.msg_type = L1CTL_DM_FREQ_REQ, |
| 370 | header.msg_type = L1CTL_DM_REL_REQ, |
| 371 | header.msg_type = L1CTL_TRAFFIC_REQ)" |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 372 | variant (ul_info_tbf) "PRESENCE(header.msg_type = L1CTL_DATA_TBF_REQ)" |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 373 | variant (ul_info_abs) "PRESENCE(header.msg_type = L1CTL_DATA_ABS_REQ)" |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 374 | variant (payload) "CROSSTAG(fbsb_req, header.msg_type = L1CTL_FBSB_REQ; |
| 375 | ccch_mode_req, header.msg_type = L1CTL_CCCH_MODE_REQ; |
| 376 | tch_mode_req, header.msg_type = L1CTL_TCH_MODE_REQ; |
| 377 | rach_req, header.msg_type = L1CTL_RACH_REQ; |
Vadim Yanitskiy | 5c83679 | 2019-04-22 05:45:03 +0700 | [diff] [blame] | 378 | ext_rach_req, header.msg_type = L1CTL_EXT_RACH_REQ; |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 379 | par_req, header.msg_type = L1CTL_PARAM_REQ; |
| 380 | dm_est_req, header.msg_type = L1CTL_DM_EST_REQ; |
| 381 | reset_req, header.msg_type = L1CTL_RESET_REQ; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 382 | crypto_req, header.msg_type = L1CTL_CRYPTO_REQ; |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 383 | traffic_req, header.msg_type = L1CTL_TRAFFIC_REQ; |
Harald Welte | 00d4dac | 2017-07-30 00:50:32 +0200 | [diff] [blame] | 384 | tbf_cfg_req, header.msg_type = L1CTL_TBF_CFG_REQ; |
Pau Espin Pedrol | 0aad596 | 2018-09-28 16:03:55 +0200 | [diff] [blame] | 385 | data_req, header.msg_type = L1CTL_DATA_REQ; |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 386 | other, OTHERWISE; |
| 387 | )" }; |
| 388 | |
| 389 | external function enc_L1ctlUlMessage(in L1ctlUlMessage msg) return octetstring |
| 390 | with { extension "prototype(convert) encode(RAW)" }; |
| 391 | external function dec_L1ctlUlMessage(in octetstring stream) return L1ctlUlMessage |
| 392 | with { extension "prototype(convert) decode(RAW)" }; |
| 393 | |
Harald Welte | 52c713c | 2017-07-16 15:44:44 +0200 | [diff] [blame] | 394 | type record L1ctlUlMessageLV { |
| 395 | uint16_t len, |
| 396 | L1ctlUlMessage msg |
| 397 | } with { variant (len) "LENGTHTO(msg)" }; |
| 398 | |
| 399 | external function enc_L1ctlUlMessageLV(in L1ctlUlMessageLV msg) return octetstring |
| 400 | with { extension "prototype(convert) encode(RAW)" }; |
| 401 | external function dec_L1ctlUlMessageLV(in octetstring stream) return L1ctlUlMessageLV |
| 402 | with { extension "prototype(convert) decode(RAW)" }; |
| 403 | |
| 404 | type record L1ctlDlMessageLV { |
| 405 | uint16_t len, |
| 406 | L1ctlDlMessage msg |
| 407 | } with { variant (len) "LENGTHTO(msg)" }; |
| 408 | |
| 409 | external function enc_L1ctlDlMessageLV(in L1ctlDlMessageLV msg) return octetstring |
| 410 | with { extension "prototype(convert) encode(RAW)" }; |
| 411 | external function dec_L1ctlDlMessageLV(in octetstring stream) return L1ctlDlMessageLV |
| 412 | with { extension "prototype(convert) decode(RAW)" }; |
| 413 | |
| 414 | |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 415 | |
| 416 | |
| 417 | /* for generating RESET_REQ */ |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 418 | template (value) L1ctlUlMessage t_L1ctlResetReq(L1ctlResetType rst_type) := { |
| 419 | header := ts_L1ctlHeader(L1CTL_RESET_REQ), |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 420 | ul_info := omit, |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 421 | ul_info_tbf := omit, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 422 | ul_info_abs := omit, |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 423 | payload := { |
| 424 | reset_req := { |
| 425 | reset_type := rst_type, |
| 426 | padding := '000000'O |
| 427 | } |
| 428 | } |
| 429 | }; |
| 430 | |
| 431 | /* for generating FBSB_REQ */ |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 432 | template (value) L1ctlUlMessage ts_L1CTL_FBSB_REQ(Arfcn arfcn, L1ctlFbsbFlags flags, |
| 433 | uint8_t sync_info_idx, |
| 434 | L1ctlCcchMode ccch_mode, |
| 435 | GsmRxLev rxlev_exp) := { |
| 436 | header := ts_L1ctlHeader(L1CTL_FBSB_REQ), |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 437 | ul_info := omit, |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 438 | ul_info_tbf := omit, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 439 | ul_info_abs := omit, |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 440 | payload := { |
| 441 | fbsb_req := { |
| 442 | arfcn := arfcn, |
Harald Welte | a82f7e6 | 2018-02-22 18:51:33 +0100 | [diff] [blame] | 443 | timeout_tdma_frames := 250, /* about 1s */ |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 444 | freq_err_thresh1 := 10000, |
| 445 | freq_err_thresh2 := 800, |
| 446 | num_freqerr_avg := 3, |
| 447 | flags := flags, |
| 448 | sync_info_idx := sync_info_idx, |
| 449 | ccch_mode := ccch_mode, |
| 450 | rxlev_exp := rxlev_exp |
| 451 | } |
| 452 | } |
| 453 | }; |
| 454 | |
| 455 | /* for matching against incoming FBSB_CONF */ |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 456 | template L1ctlDlMessage tr_L1CTL_FBSB_CONF(template uint8_t result) := { |
| 457 | header := tr_L1ctlHeader(L1CTL_FBSB_CONF), |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 458 | dl_info := ?, |
| 459 | payload := { |
| 460 | fbsb_conf := { |
| 461 | initial_freq_err := ?, |
| 462 | result := result, |
| 463 | bsic := ? |
| 464 | } |
| 465 | } |
| 466 | }; |
| 467 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 468 | template (value) L1ctlUlMessage ts_L1CTL_CCCH_MODE_REQ(L1ctlCcchMode ccch_mode) := { |
| 469 | header := ts_L1ctlHeader(L1CTL_CCCH_MODE_REQ), |
| 470 | ul_info := omit, |
| 471 | ul_info_tbf := omit, |
| 472 | ul_info_abs := omit, |
| 473 | payload := { |
| 474 | ccch_mode_req := { |
| 475 | ccch_mode := ccch_mode, |
| 476 | padding := '000000'O |
| 477 | } |
| 478 | } |
| 479 | }; |
| 480 | |
Harald Welte | 3757e60 | 2018-03-10 17:12:02 +0100 | [diff] [blame] | 481 | |
| 482 | template L1ctlDlMessage tr_L1CTL_MsgType(template L1ctlMsgType msg_type) := { |
| 483 | header := tr_L1ctlHeader(msg_type), |
| 484 | dl_info := *, |
Harald Welte | f56cc49 | 2018-04-15 10:58:43 +0200 | [diff] [blame] | 485 | payload := * |
Harald Welte | 3757e60 | 2018-03-10 17:12:02 +0100 | [diff] [blame] | 486 | } |
| 487 | |
| 488 | template L1ctlDlMessage tr_L1CTL_CCCH_MODE_CONF := tr_L1CTL_MsgType(L1CTL_CCCH_MODE_CONF); |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 489 | |
| 490 | template L1ctlUlMessage ts_L1CTL_RACH_REQ(uint8_t ra, uint8_t combined, uint16_t offset) := { |
| 491 | header := ts_L1ctlHeader(L1CTL_RACH_REQ), |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 492 | ul_info := { |
Vadim Yanitskiy | 5c83679 | 2019-04-22 05:45:03 +0700 | [diff] [blame] | 493 | /* FIXME: both RSL chan_nr and link_id should be configurable */ |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 494 | chan_nr := t_RslChanNr_RACH(0), |
| 495 | link_id := ts_RslLinkID_DCCH(0), |
| 496 | padding := '0000'O |
| 497 | }, |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 498 | ul_info_tbf := omit, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 499 | ul_info_abs := omit, |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 500 | payload := { |
| 501 | rach_req := { |
| 502 | ra := ra, |
| 503 | combined := combined, |
| 504 | offset := offset |
| 505 | } |
| 506 | } |
| 507 | } |
| 508 | |
Vadim Yanitskiy | 5c83679 | 2019-04-22 05:45:03 +0700 | [diff] [blame] | 509 | template L1ctlUlMessage ts_L1CTL_EXT_RACH_REQ( |
| 510 | uint16_t ra11, L1ctlRachSynchSeq seq, |
| 511 | uint8_t combined, uint16_t offset |
| 512 | ) := { |
| 513 | header := ts_L1ctlHeader(L1CTL_EXT_RACH_REQ), |
| 514 | ul_info := { |
| 515 | /* FIXME: both RSL chan_nr and link_id should be configurable */ |
| 516 | chan_nr := t_RslChanNr_RACH(0), |
| 517 | link_id := ts_RslLinkID_DCCH(0), |
| 518 | padding := '0000'O |
| 519 | }, |
| 520 | ul_info_tbf := omit, |
| 521 | ul_info_abs := omit, |
| 522 | payload := { |
| 523 | ext_rach_req := { |
| 524 | ra11 := ra11, |
| 525 | synch_seq := seq, |
| 526 | combined := combined, |
| 527 | offset := offset |
| 528 | } |
| 529 | } |
| 530 | } |
| 531 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 532 | template L1ctlUlMessage ts_L1CTL_PAR_REQ(uint8_t ta, uint8_t tx_power) := { |
| 533 | header := ts_L1ctlHeader(L1CTL_PARAM_REQ), |
Harald Welte | 3705273 | 2018-03-09 19:38:46 +0100 | [diff] [blame] | 534 | ul_info := { |
| 535 | chan_nr := t_RslChanNr_RACH(0), |
| 536 | link_id := ts_RslLinkID_DCCH(0), |
| 537 | padding := '0000'O |
| 538 | }, |
| 539 | ul_info_tbf := omit, |
| 540 | ul_info_abs := omit, |
| 541 | payload := { |
| 542 | par_req := { |
| 543 | ta := ta, |
| 544 | tx_power := tx_power, |
| 545 | padding := '0000'O |
| 546 | } |
| 547 | } |
| 548 | } |
| 549 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 550 | template L1ctlUlMessage ts_L1CTL_DM_EST_REQ(Arfcn arfcn, RslChannelNr chan_nr, GsmTsc tsc) := { |
| 551 | header := ts_L1ctlHeader(L1CTL_DM_EST_REQ), |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 552 | ul_info := { |
| 553 | chan_nr := chan_nr, |
| 554 | link_id := ts_RslLinkID_DCCH(0), |
| 555 | padding := '0000'O |
| 556 | }, |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 557 | ul_info_tbf := omit, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 558 | ul_info_abs := omit, |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 559 | payload := { |
| 560 | dm_est_req := { |
| 561 | tsc := tsc, |
| 562 | h := 0, |
| 563 | arfcn := arfcn, |
| 564 | hopping := omit, |
| 565 | tch_mode := 0, |
| 566 | audio_mode := t_L1CTL_AudioModeNone |
| 567 | } |
| 568 | } |
| 569 | } |
| 570 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 571 | template L1ctlUlMessage ts_L1CTL_DM_REL_REQ(RslChannelNr chan_nr) := { |
| 572 | header := ts_L1ctlHeader(L1CTL_DM_REL_REQ), |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 573 | ul_info := { |
| 574 | chan_nr := chan_nr, |
| 575 | link_id := ts_RslLinkID_DCCH(0), |
| 576 | padding := '0000'O |
| 577 | }, |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 578 | ul_info_tbf := omit, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 579 | ul_info_abs := omit, |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 580 | payload := { |
| 581 | other := ''O |
| 582 | } |
| 583 | } |
| 584 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 585 | template (value) L1ctlUlMessage ts_L1CTL_DATA_REQ(template (value) RslChannelNr chan_nr, |
| 586 | template (value) RslLinkId link_id, |
| 587 | octetstring l2_data) := { |
| 588 | header := ts_L1ctlHeader(L1CTL_DATA_REQ), |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 589 | ul_info := { |
| 590 | chan_nr := chan_nr, |
| 591 | link_id := link_id, |
| 592 | padding := '0000'O |
| 593 | }, |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 594 | ul_info_tbf := omit, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 595 | ul_info_abs := omit, |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 596 | payload := { |
| 597 | other := l2_data |
| 598 | } |
| 599 | } |
| 600 | |
Pau Espin Pedrol | 0aad596 | 2018-09-28 16:03:55 +0200 | [diff] [blame] | 601 | template (value) L1ctlUlMessage ts_L1CTL_DATA_REQ_SACCH(template (value) RslChannelNr chan_nr, |
| 602 | template (value) RslLinkId link_id, |
| 603 | L1ctlDataReq data_req) := { |
| 604 | header := ts_L1ctlHeader(L1CTL_DATA_REQ), |
| 605 | ul_info := { |
| 606 | chan_nr := chan_nr, |
| 607 | link_id := link_id, |
| 608 | padding := '0000'O |
| 609 | }, |
| 610 | ul_info_tbf := omit, |
| 611 | ul_info_abs := omit, |
| 612 | payload := { |
| 613 | data_req := data_req |
| 614 | } |
| 615 | } |
| 616 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 617 | template (value) L1ctlUlMessage ts_L1CTL_TBF_CFG_REQ(boolean is_uplink, TfiUsfArr tfi_usf) := { |
| 618 | header := ts_L1ctlHeader(L1CTL_TBF_CFG_REQ), |
Harald Welte | 00d4dac | 2017-07-30 00:50:32 +0200 | [diff] [blame] | 619 | ul_info := omit, |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 620 | ul_info_tbf := omit, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 621 | ul_info_abs := omit, |
Harald Welte | 00d4dac | 2017-07-30 00:50:32 +0200 | [diff] [blame] | 622 | payload := { |
| 623 | tbf_cfg_req := { |
| 624 | tbf_nr := 0, |
| 625 | is_uplink := is_uplink, |
| 626 | padding := '0000'O, |
| 627 | tfi_usf := tfi_usf |
| 628 | } |
| 629 | } |
| 630 | }; |
| 631 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 632 | template L1ctlDlMessage tr_L1CTL_TBF_CFG_CONF(template boolean is_uplink) := { |
| 633 | header := tr_L1ctlHeader(L1CTL_TBF_CFG_CONF), |
Harald Welte | 00d4dac | 2017-07-30 00:50:32 +0200 | [diff] [blame] | 634 | dl_info := omit, |
| 635 | payload := { |
| 636 | tbf_cfg_conf := { |
| 637 | tbf_nr := 0, |
| 638 | is_uplink := is_uplink, |
| 639 | padding := ?, |
| 640 | tfi_usf := ? |
| 641 | } |
| 642 | } |
| 643 | }; |
| 644 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 645 | template (value) L1ctlUlMessage ts_L1CTL_DATA_TBF_REQ(octetstring l2_data, |
| 646 | L1ctlGprsCs cs := L1CTL_CS1, |
| 647 | uint8_t tbf_nr := 0) := { |
| 648 | header := ts_L1ctlHeader(L1CTL_DATA_TBF_REQ), |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 649 | ul_info := omit, |
| 650 | ul_info_tbf := { |
| 651 | tbf_nr := tbf_nr, |
Harald Welte | 1dcc371 | 2017-08-01 00:05:52 +0200 | [diff] [blame] | 652 | cs := cs, |
| 653 | padding := '0000'O |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 654 | }, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 655 | ul_info_abs := omit, |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 656 | payload := { |
| 657 | other := l2_data |
| 658 | } |
| 659 | } |
| 660 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 661 | template (value) L1ctlUlMessage ts_L1CTL_DATA_ABS_REQ(octetstring l2_data, Arfcn arfcn, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 662 | uint8_t ts, GsmFrameNumber fn, |
| 663 | L1ctlGprsCs cs := L1CTL_CS1, |
| 664 | uint8_t tbf_nr := 0) := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 665 | header := ts_L1ctlHeader(L1CTL_DATA_ABS_REQ), |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 666 | ul_info := omit, |
| 667 | ul_info_tbf := omit, |
| 668 | ul_info_abs := { |
| 669 | tbf_nr := tbf_nr, |
| 670 | cs := cs, |
| 671 | ts_nr := ts, |
| 672 | padding := '00'O, |
| 673 | fn := fn, |
| 674 | arfcn := arfcn, |
| 675 | padding2 := '0000'O |
| 676 | }, |
| 677 | payload := { |
| 678 | other := l2_data |
| 679 | } |
| 680 | } |
| 681 | |
| 682 | |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 683 | /* for matching against incoming RACH_CONF */ |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 684 | template L1ctlDlMessage tr_L1CTL_RACH_CONF := { |
| 685 | header := tr_L1ctlHeader(L1CTL_RACH_CONF), |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 686 | dl_info := ?, |
Harald Welte | f56cc49 | 2018-04-15 10:58:43 +0200 | [diff] [blame] | 687 | payload := * |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 688 | }; |
| 689 | |
Harald Welte | ce6dc44 | 2018-02-21 22:00:21 +0100 | [diff] [blame] | 690 | /* for matching against incoming DATA_IND */ |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 691 | template L1ctlDlMessage tr_L1CTL_DATA_IND(template RslChannelNr chan_nr, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 692 | template RslLinkId link_id := ?, |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 693 | template octetstring l2_data := ?, |
| 694 | template uint8_t num_biterr := 0, |
| 695 | template uint8_t fire_crc := 0) := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 696 | header := tr_L1ctlHeader(L1CTL_DATA_IND), |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 697 | dl_info := { |
| 698 | chan_nr := chan_nr, |
Harald Welte | ce6dc44 | 2018-02-21 22:00:21 +0100 | [diff] [blame] | 699 | link_id := link_id, |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 700 | arfcn := ?, |
| 701 | frame_nr := ?, |
| 702 | rx_level := ?, |
| 703 | snr := ?, |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 704 | num_biterr := num_biterr, |
| 705 | fire_crc := fire_crc |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 706 | }, |
| 707 | payload := { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 708 | data_ind := { |
| 709 | payload := l2_data |
| 710 | } |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 711 | } |
| 712 | }; |
| 713 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 714 | template (value) L1ctlUlMessage ts_L1CTL_CRYPTO_REQ(RslChannelNr chan_nr, uint8_t algo, |
| 715 | octetstring key) := { |
| 716 | header := ts_L1ctlHeader(L1CTL_CRYPTO_REQ), |
| 717 | ul_info := { |
| 718 | chan_nr := chan_nr, |
| 719 | link_id := ts_RslLinkID_DCCH(0), |
| 720 | padding := '0000'O |
| 721 | }, |
| 722 | ul_info_tbf := omit, |
| 723 | ul_info_abs := omit, |
| 724 | payload := { |
| 725 | crypto_req := { |
| 726 | algo := algo, |
| 727 | key_len := 0, /* overwritten */ |
| 728 | key := key |
| 729 | } |
| 730 | } |
| 731 | }; |
| 732 | |
Harald Welte | 88849c6 | 2017-07-30 17:19:41 +0200 | [diff] [blame] | 733 | template ImmediateAssignment t_IMM_ASS(uint8_t ra, GsmFrameNumber fn) := { |
| 734 | ded_or_tbf := ?, |
| 735 | page_mode := ?, |
| 736 | chan_desc := *, |
| 737 | pkt_chan_desc := *, |
| 738 | req_ref := f_compute_ReqRef(ra, fn), |
| 739 | timing_advance := ?, |
| 740 | mobile_allocation := ?, |
| 741 | rest_octets:= ? |
| 742 | }; |
| 743 | |
| 744 | template GsmRrMessage t_RR_IMM_ASS(uint8_t ra, GsmFrameNumber fn) := { |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 745 | header := t_RrHeader(IMMEDIATE_ASSIGNMENT, ?), |
| 746 | payload := { |
Harald Welte | 88849c6 | 2017-07-30 17:19:41 +0200 | [diff] [blame] | 747 | imm_ass := t_IMM_ASS(ra, fn) |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 748 | } |
| 749 | }; |
| 750 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 751 | const octetstring c_DummyUI := '0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O; |
| 752 | |
Harald Welte | 7024baa | 2018-03-02 23:37:51 +0100 | [diff] [blame] | 753 | /* We use "BYTEORDER(last)" so we get little-endian integers. Unfortuantely, this also |
| 754 | switches the byte ordering in octet strings, so we need to explicitly annotate them :/ */ |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 755 | } with { encode "RAW" }; |