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 | |
Vadim Yanitskiy | be33f6b | 2020-11-14 04:05:34 +0700 | [diff] [blame] | 108 | template L1ctlHeader |
| 109 | tr_L1ctlHeader(template (present) L1ctlMsgType msg_type) := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 110 | msg_type := msg_type, |
| 111 | flags := ?, |
| 112 | padding := ? |
| 113 | }; |
| 114 | |
Vadim Yanitskiy | be33f6b | 2020-11-14 04:05:34 +0700 | [diff] [blame] | 115 | template (value) L1ctlHeader |
| 116 | ts_L1ctlHeader(template (value) L1ctlMsgType msg_type) := { |
Harald Welte | 52c713c | 2017-07-16 15:44:44 +0200 | [diff] [blame] | 117 | msg_type := msg_type, |
| 118 | flags := { padding := '0000000'B, f_done := false }, |
| 119 | padding := '0000'O |
| 120 | }; |
| 121 | |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 122 | type record L1ctlDlInfo { |
Harald Welte | 8e4db2c | 2017-07-16 18:54:55 +0200 | [diff] [blame] | 123 | RslChannelNr chan_nr, |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 124 | RslLinkId link_id, |
Vadim Yanitskiy | 1acc7bb | 2020-11-14 04:24:57 +0700 | [diff] [blame] | 125 | GsmBandArfcn arfcn, |
Harald Welte | 5f0d5c8 | 2017-07-16 18:56:01 +0200 | [diff] [blame] | 126 | uint32_t frame_nr, |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 127 | GsmRxLev rx_level, |
| 128 | uint8_t snr, |
| 129 | uint8_t num_biterr, |
| 130 | uint8_t fire_crc |
| 131 | } with { variant "" }; |
| 132 | |
| 133 | type record L1ctlFbsbConf { |
| 134 | int16_t initial_freq_err, |
| 135 | uint8_t result, |
| 136 | uint8_t bsic |
| 137 | } with { variant "" }; |
| 138 | |
| 139 | type record L1ctlCcchModeConf { |
| 140 | L1ctlCcchMode ccch_mode, |
| 141 | OCT3 padding |
| 142 | } with { variant "" }; |
| 143 | |
| 144 | /* gsm48_chan_mode */ |
Vadim Yanitskiy | fe05296 | 2020-10-19 13:27:09 +0700 | [diff] [blame] | 145 | type enumerated L1ctlTchMode { |
| 146 | L1CTL_CHAN_MODE_SIGN ('00000000'B), /* Signalling */ |
| 147 | L1CTL_CHAN_MODE_SPEECH_V1 ('00000001'B), /* FR or HR codec */ |
| 148 | L1CTL_CHAN_MODE_SPEECH_V2 ('00100001'B), /* EFR codec */ |
| 149 | L1CTL_CHAN_MODE_SPEECH_V3 ('01000001'B) /* AMR codec */ |
| 150 | /* Other modes are not supported for now */ |
| 151 | } with { variant "FIELDLENGTH(8)" }; |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 152 | |
Vadim Yanitskiy | 7ce605f | 2020-10-19 16:04:38 +0700 | [diff] [blame] | 153 | type enumerated L1ctlLoopMode { |
| 154 | L1CTL_LOOP_MODE_OPEN ('00000000'B), |
| 155 | L1CTL_LOOP_MODE_A ('00000001'B), |
| 156 | L1CTL_LOOP_MODE_B ('00000010'B), |
| 157 | L1CTL_LOOP_MODE_C ('00000011'B), |
| 158 | L1CTL_LOOP_MODE_D ('00000100'B), |
| 159 | L1CTL_LOOP_MODE_E ('00000101'B), |
| 160 | L1CTL_LOOP_MODE_F ('00000110'B), |
| 161 | L1CTL_LOOP_MODE_I ('00000111'B) |
| 162 | } with { variant "FIELDLENGTH(8)" }; |
| 163 | |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 164 | type record L1ctlAudioMode { |
| 165 | BIT4 padding, |
| 166 | boolean tx_microphone, |
| 167 | boolean tx_traffic_req, |
| 168 | boolean rx_speaker, |
| 169 | boolean rx_traffic_ind |
| 170 | } with { variant "" }; |
| 171 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 172 | template (value) L1ctlAudioMode t_L1CTL_AudioModeNone := { '0000'B, false, false, false, false }; |
Harald Welte | 66110f0 | 2017-07-16 21:05:18 +0200 | [diff] [blame] | 173 | |
Vadim Yanitskiy | 1618583 | 2020-10-19 21:20:43 +0700 | [diff] [blame] | 174 | /* Traffic forwarding mode (see TRAFFIC.{req,cnf,ind} messages) */ |
| 175 | template (value) L1ctlAudioMode t_L1CTL_AudioModeFwd |
| 176 | modifies t_L1CTL_AudioModeNone := { |
| 177 | tx_traffic_req := true, |
| 178 | rx_traffic_ind := true |
| 179 | }; |
| 180 | |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 181 | type record L1ctlTchModeConf { |
| 182 | L1ctlTchMode tch_mode, |
| 183 | L1ctlAudioMode audio_mode, |
Pau Espin Pedrol | 440e1dc | 2022-09-02 16:35:49 +0200 | [diff] [blame] | 184 | record { |
| 185 | uint8_t start_codec, |
| 186 | BIT8 codecs_bitmask |
| 187 | } amr |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 188 | } with { variant "" }; |
| 189 | |
| 190 | type record L1ctlDataInd { |
Vadim Yanitskiy | 2a92e2a | 2019-05-28 21:13:35 +0700 | [diff] [blame] | 191 | octetstring payload |
Harald Welte | 7024baa | 2018-03-02 23:37:51 +0100 | [diff] [blame] | 192 | } with { |
| 193 | variant (payload) "BYTEORDER(first)" |
| 194 | }; |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 195 | |
| 196 | type union L1ctlDlPayload { |
| 197 | L1ctlFbsbConf fbsb_conf, |
| 198 | L1ctlCcchModeConf ccch_mode_conf, |
| 199 | L1ctlTchModeConf tch_mode_conf, |
| 200 | L1ctlDataInd data_ind, |
| 201 | L1ctlTrafficReq traffic_ind, |
Harald Welte | 00d4dac | 2017-07-30 00:50:32 +0200 | [diff] [blame] | 202 | L1ctlTbfCfgReq tbf_cfg_conf, |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 203 | octetstring other |
Harald Welte | 7024baa | 2018-03-02 23:37:51 +0100 | [diff] [blame] | 204 | } with { |
| 205 | variant (other) "BYTEORDER(first)" |
| 206 | }; |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 207 | |
| 208 | type record L1ctlDlMessage { |
| 209 | L1ctlHeader header, |
| 210 | L1ctlDlInfo dl_info optional, |
Harald Welte | f56cc49 | 2018-04-15 10:58:43 +0200 | [diff] [blame] | 211 | L1ctlDlPayload payload optional |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 212 | } with { variant (dl_info) "PRESENCE(header.msg_type = L1CTL_FBSB_CONF, |
| 213 | header.msg_type = L1CTL_RACH_CONF, |
| 214 | header.msg_type = L1CTL_DATA_IND, |
| 215 | header.msg_type = L1CTL_DATA_CONF, |
Harald Welte | 3c4cbf6 | 2018-03-30 10:31:39 +0200 | [diff] [blame] | 216 | header.msg_type = L1CTL_TRAFFIC_IND, |
| 217 | header.msg_type = L1CTL_TRAFFIC_CONF)" |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 218 | variant (payload) "CROSSTAG(fbsb_conf, header.msg_type = L1CTL_FBSB_CONF; |
| 219 | ccch_mode_conf, header.msg_type = L1CTL_CCCH_MODE_CONF; |
| 220 | tch_mode_conf, header.msg_type = L1CTL_TCH_MODE_CONF; |
| 221 | data_ind, header.msg_type = L1CTL_DATA_IND; |
| 222 | traffic_ind, header.msg_type = L1CTL_TRAFFIC_IND; |
Harald Welte | 00d4dac | 2017-07-30 00:50:32 +0200 | [diff] [blame] | 223 | tbf_cfg_conf, header.msg_type = L1CTL_TBF_CFG_CONF; |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 224 | other, OTHERWISE; |
| 225 | )" }; |
| 226 | |
| 227 | external function enc_L1ctlDlMessage(in L1ctlDlMessage msg) return octetstring |
| 228 | with { extension "prototype(convert) encode(RAW)" }; |
| 229 | external function dec_L1ctlDlMessage(in octetstring stream) return L1ctlDlMessage |
| 230 | with { extension "prototype(convert) decode(RAW)" }; |
| 231 | |
| 232 | |
| 233 | type record L1ctlUlInfo { |
Harald Welte | 8e4db2c | 2017-07-16 18:54:55 +0200 | [diff] [blame] | 234 | RslChannelNr chan_nr, |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 235 | RslLinkId link_id, |
| 236 | OCT2 padding |
| 237 | } with { variant "" }; |
| 238 | |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 239 | type record L1ctlUlTbfInfo { |
| 240 | uint8_t tbf_nr, |
Harald Welte | 1dcc371 | 2017-08-01 00:05:52 +0200 | [diff] [blame] | 241 | L1ctlGprsCs cs, |
| 242 | OCT2 padding |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 243 | } with { variant "" }; |
| 244 | |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 245 | type record L1ctlUlAbsInfo { |
| 246 | uint8_t tbf_nr, |
| 247 | L1ctlGprsCs cs, |
| 248 | uint8_t ts_nr, |
| 249 | OCT1 padding, |
Harald Welte | 7024baa | 2018-03-02 23:37:51 +0100 | [diff] [blame] | 250 | uint32_le fn, |
Vadim Yanitskiy | 1acc7bb | 2020-11-14 04:24:57 +0700 | [diff] [blame] | 251 | GsmBandArfcn arfcn, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 252 | OCT2 padding2 |
| 253 | } with { variant "" }; |
| 254 | |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 255 | type record L1ctlFbsbFlags { |
| 256 | BIT5 padding, |
| 257 | boolean sb, |
| 258 | boolean fb1, |
| 259 | boolean fb0 |
Harald Welte | 344c0cf | 2018-03-09 16:17:45 +0100 | [diff] [blame] | 260 | } with { variant "FIELDORDER(msb)" }; |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 261 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 262 | template (value) L1ctlFbsbFlags t_L1CTL_FBSB_F_ALL := { |
Harald Welte | 66110f0 | 2017-07-16 21:05:18 +0200 | [diff] [blame] | 263 | padding := '00000'B, |
| 264 | sb := true, |
| 265 | fb1 := true, |
| 266 | fb0 := true |
| 267 | }; |
| 268 | |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 269 | type record L1ctlFbsbReq { |
Vadim Yanitskiy | 1acc7bb | 2020-11-14 04:24:57 +0700 | [diff] [blame] | 270 | GsmBandArfcn arfcn, |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 271 | uint16_t timeout_tdma_frames, |
| 272 | uint16_t freq_err_thresh1, |
| 273 | uint16_t freq_err_thresh2, |
| 274 | uint8_t num_freqerr_avg, |
| 275 | L1ctlFbsbFlags flags, |
| 276 | uint8_t sync_info_idx, |
| 277 | L1ctlCcchMode ccch_mode, |
| 278 | GsmRxLev rxlev_exp |
| 279 | } with { variant "" }; |
| 280 | |
| 281 | type record L1ctlCcchModeReq { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 282 | L1ctlCcchMode ccch_mode, |
| 283 | OCT3 padding |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 284 | } with { variant "" }; |
| 285 | |
| 286 | type record L1ctlTchModeReq { |
| 287 | L1ctlTchMode tch_mode, |
| 288 | L1ctlAudioMode audio_mode, |
Vadim Yanitskiy | 7ce605f | 2020-10-19 16:04:38 +0700 | [diff] [blame] | 289 | L1ctlLoopMode loop_mode, |
Pau Espin Pedrol | 440e1dc | 2022-09-02 16:35:49 +0200 | [diff] [blame] | 290 | record { |
| 291 | uint8_t start_codec, |
| 292 | BIT8 codecs_bitmask |
| 293 | } amr |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 294 | } with { variant "" }; |
| 295 | |
| 296 | type record L1ctlRachReq { |
| 297 | uint8_t ra, |
| 298 | uint8_t combined, |
| 299 | uint16_t offset |
| 300 | } with { variant "" }; |
| 301 | |
Vadim Yanitskiy | 5c83679 | 2019-04-22 05:45:03 +0700 | [diff] [blame] | 302 | type enumerated L1ctlRachSynchSeq { |
| 303 | RACH_SYNCH_SEQ_TS0 (0), |
| 304 | RACH_SYNCH_SEQ_TS1, |
| 305 | RACH_SYNCH_SEQ_TS2 |
| 306 | } with { variant "FIELDLENGTH(8)" }; |
| 307 | |
| 308 | type record L1ctlExtRachReq { |
| 309 | uint16_t ra11, |
| 310 | L1ctlRachSynchSeq synch_seq, |
| 311 | uint8_t combined, |
| 312 | uint16_t offset |
| 313 | } with { variant "" }; |
| 314 | |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 315 | type record L1ctlParReq { |
| 316 | int8_t ta, |
| 317 | uint8_t tx_power, |
| 318 | OCT2 padding |
| 319 | } with { variant "" }; |
| 320 | |
Pau Espin Pedrol | 0aad596 | 2018-09-28 16:03:55 +0200 | [diff] [blame] | 321 | type record L1ctlDataReq { |
| 322 | SacchL1Header l1header optional, |
| 323 | octetstring l2_payload |
| 324 | } with { variant "" }; |
| 325 | |
Vadim Yanitskiy | 2cdb97f | 2020-10-19 14:17:38 +0700 | [diff] [blame] | 326 | type record L1ctlH0 { |
| 327 | uint8_t h, |
Vadim Yanitskiy | 1acc7bb | 2020-11-14 04:24:57 +0700 | [diff] [blame] | 328 | GsmBandArfcn arfcn, |
Vadim Yanitskiy | 2cdb97f | 2020-10-19 14:17:38 +0700 | [diff] [blame] | 329 | octetstring padding length(130) |
| 330 | } with { variant "" }; |
| 331 | |
Vadim Yanitskiy | 1acc7bb | 2020-11-14 04:24:57 +0700 | [diff] [blame] | 332 | type record length(0..64) of GsmBandArfcn L1ctlMA; |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 333 | type record L1ctlH1 { |
Vadim Yanitskiy | 2cdb97f | 2020-10-19 14:17:38 +0700 | [diff] [blame] | 334 | uint8_t h, |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 335 | uint8_t hsn, |
| 336 | uint8_t maio, |
| 337 | uint8_t n, |
Vadim Yanitskiy | e8ea3ee | 2020-05-27 13:29:48 +0700 | [diff] [blame] | 338 | OCT1 spare, |
| 339 | L1ctlMA ma, |
| 340 | octetstring padding |
| 341 | } with { |
| 342 | variant (n) "LENGTHTO(ma)" |
| 343 | variant (n) "UNIT(elements)" |
| 344 | /* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=562849. |
| 345 | * TL;DR The reference point of the PADDING attribute is the beginning |
| 346 | * of the message, not the beginning of the type/field it's applied on. |
| 347 | * Therefore we cannot use it here, and have to add padding manually. |
| 348 | * variant (ma) "PADDING(128)" */ |
| 349 | }; |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 350 | |
Vadim Yanitskiy | 2cdb97f | 2020-10-19 14:17:38 +0700 | [diff] [blame] | 351 | type union L1ctlH0H1 { |
| 352 | L1ctlH0 h0, |
| 353 | L1ctlH1 h1 |
| 354 | } with { variant "TAG(h0, h = 0; h1, h = 1)" }; |
| 355 | |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 356 | type record L1ctlDmEstReq { |
| 357 | GsmTsc tsc, |
Vadim Yanitskiy | 2cdb97f | 2020-10-19 14:17:38 +0700 | [diff] [blame] | 358 | L1ctlH0H1 h0h1, |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 359 | L1ctlTchMode tch_mode, |
| 360 | L1ctlAudioMode audio_mode |
Vadim Yanitskiy | 2cdb97f | 2020-10-19 14:17:38 +0700 | [diff] [blame] | 361 | } with { variant "" }; |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 362 | |
| 363 | type record L1ctlReset { |
| 364 | L1ctlResetType reset_type, |
| 365 | OCT3 padding |
| 366 | } with { variant "" }; |
| 367 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 368 | type record L1CtlCryptoReq { |
| 369 | uint8_t algo, |
| 370 | uint8_t key_len, |
| 371 | octetstring key |
| 372 | } with { variant (key_len) "LENGTHTO(key)" }; |
| 373 | |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 374 | |
| 375 | type record L1ctlTrafficReq { |
Vadim Yanitskiy | e01691d | 2018-10-29 00:18:04 +0700 | [diff] [blame] | 376 | octetstring data |
Harald Welte | 7024baa | 2018-03-02 23:37:51 +0100 | [diff] [blame] | 377 | } with { |
| 378 | variant (data) "BYTEORDER(first)" |
| 379 | } |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 380 | |
Harald Welte | 00d4dac | 2017-07-30 00:50:32 +0200 | [diff] [blame] | 381 | type record length(8) of uint8_t TfiUsfArr; |
| 382 | |
| 383 | type record L1ctlTbfCfgReq { |
| 384 | uint8_t tbf_nr, |
| 385 | boolean is_uplink, |
| 386 | OCT2 padding, |
| 387 | TfiUsfArr tfi_usf |
| 388 | } with { variant (is_uplink) "FIELDLENGTH(8)" }; |
| 389 | |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 390 | type union L1ctlUlPayload { |
| 391 | L1ctlFbsbReq fbsb_req, |
| 392 | L1ctlCcchModeReq ccch_mode_req, |
| 393 | L1ctlTchModeReq tch_mode_req, |
| 394 | L1ctlRachReq rach_req, |
Vadim Yanitskiy | 5c83679 | 2019-04-22 05:45:03 +0700 | [diff] [blame] | 395 | L1ctlExtRachReq ext_rach_req, |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 396 | L1ctlParReq par_req, |
| 397 | L1ctlDmEstReq dm_est_req, |
| 398 | L1ctlReset reset_req, |
| 399 | //L1ctlNeighPmReq neigh_pm_req, |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 400 | L1CtlCryptoReq crypto_req, |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 401 | L1ctlTrafficReq traffic_req, |
Harald Welte | 00d4dac | 2017-07-30 00:50:32 +0200 | [diff] [blame] | 402 | L1ctlTbfCfgReq tbf_cfg_req, |
Pau Espin Pedrol | 0aad596 | 2018-09-28 16:03:55 +0200 | [diff] [blame] | 403 | L1ctlDataReq data_req, |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 404 | octetstring other |
Harald Welte | 7024baa | 2018-03-02 23:37:51 +0100 | [diff] [blame] | 405 | } with { |
| 406 | variant (other) "BYTEORDER(first)" |
| 407 | }; |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 408 | |
| 409 | type record L1ctlUlMessage { |
| 410 | L1ctlHeader header, |
| 411 | L1ctlUlInfo ul_info optional, |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 412 | L1ctlUlTbfInfo ul_info_tbf optional, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 413 | L1ctlUlAbsInfo ul_info_abs optional, |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 414 | L1ctlUlPayload payload |
| 415 | } with { variant (ul_info) "PRESENCE(header.msg_type = L1CTL_RACH_REQ, |
Vadim Yanitskiy | 5c83679 | 2019-04-22 05:45:03 +0700 | [diff] [blame] | 416 | header.msg_type = L1CTL_EXT_RACH_REQ, |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 417 | header.msg_type = L1CTL_PARAM_REQ, |
| 418 | header.msg_type = L1CTL_CRYPTO_REQ, |
| 419 | header.msg_type = L1CTL_DATA_REQ, |
| 420 | header.msg_type = L1CTL_DM_EST_REQ, |
| 421 | header.msg_type = L1CTL_DM_FREQ_REQ, |
| 422 | header.msg_type = L1CTL_DM_REL_REQ, |
| 423 | header.msg_type = L1CTL_TRAFFIC_REQ)" |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 424 | variant (ul_info_tbf) "PRESENCE(header.msg_type = L1CTL_DATA_TBF_REQ)" |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 425 | variant (ul_info_abs) "PRESENCE(header.msg_type = L1CTL_DATA_ABS_REQ)" |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 426 | variant (payload) "CROSSTAG(fbsb_req, header.msg_type = L1CTL_FBSB_REQ; |
| 427 | ccch_mode_req, header.msg_type = L1CTL_CCCH_MODE_REQ; |
| 428 | tch_mode_req, header.msg_type = L1CTL_TCH_MODE_REQ; |
| 429 | rach_req, header.msg_type = L1CTL_RACH_REQ; |
Vadim Yanitskiy | 5c83679 | 2019-04-22 05:45:03 +0700 | [diff] [blame] | 430 | ext_rach_req, header.msg_type = L1CTL_EXT_RACH_REQ; |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 431 | par_req, header.msg_type = L1CTL_PARAM_REQ; |
| 432 | dm_est_req, header.msg_type = L1CTL_DM_EST_REQ; |
| 433 | reset_req, header.msg_type = L1CTL_RESET_REQ; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 434 | crypto_req, header.msg_type = L1CTL_CRYPTO_REQ; |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 435 | traffic_req, header.msg_type = L1CTL_TRAFFIC_REQ; |
Harald Welte | 00d4dac | 2017-07-30 00:50:32 +0200 | [diff] [blame] | 436 | tbf_cfg_req, header.msg_type = L1CTL_TBF_CFG_REQ; |
Pau Espin Pedrol | 0aad596 | 2018-09-28 16:03:55 +0200 | [diff] [blame] | 437 | data_req, header.msg_type = L1CTL_DATA_REQ; |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 438 | other, OTHERWISE; |
| 439 | )" }; |
| 440 | |
| 441 | external function enc_L1ctlUlMessage(in L1ctlUlMessage msg) return octetstring |
| 442 | with { extension "prototype(convert) encode(RAW)" }; |
| 443 | external function dec_L1ctlUlMessage(in octetstring stream) return L1ctlUlMessage |
| 444 | with { extension "prototype(convert) decode(RAW)" }; |
| 445 | |
Harald Welte | 52c713c | 2017-07-16 15:44:44 +0200 | [diff] [blame] | 446 | type record L1ctlUlMessageLV { |
| 447 | uint16_t len, |
| 448 | L1ctlUlMessage msg |
| 449 | } with { variant (len) "LENGTHTO(msg)" }; |
| 450 | |
| 451 | external function enc_L1ctlUlMessageLV(in L1ctlUlMessageLV msg) return octetstring |
| 452 | with { extension "prototype(convert) encode(RAW)" }; |
| 453 | external function dec_L1ctlUlMessageLV(in octetstring stream) return L1ctlUlMessageLV |
| 454 | with { extension "prototype(convert) decode(RAW)" }; |
| 455 | |
| 456 | type record L1ctlDlMessageLV { |
| 457 | uint16_t len, |
| 458 | L1ctlDlMessage msg |
| 459 | } with { variant (len) "LENGTHTO(msg)" }; |
| 460 | |
| 461 | external function enc_L1ctlDlMessageLV(in L1ctlDlMessageLV msg) return octetstring |
| 462 | with { extension "prototype(convert) encode(RAW)" }; |
| 463 | external function dec_L1ctlDlMessageLV(in octetstring stream) return L1ctlDlMessageLV |
| 464 | with { extension "prototype(convert) decode(RAW)" }; |
| 465 | |
| 466 | |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 467 | |
| 468 | |
| 469 | /* for generating RESET_REQ */ |
Vadim Yanitskiy | be33f6b | 2020-11-14 04:05:34 +0700 | [diff] [blame] | 470 | template (value) L1ctlUlMessage |
| 471 | t_L1ctlResetReq(template (value) L1ctlResetType rst_type) := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 472 | header := ts_L1ctlHeader(L1CTL_RESET_REQ), |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 473 | ul_info := omit, |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 474 | ul_info_tbf := omit, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 475 | ul_info_abs := omit, |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 476 | payload := { |
| 477 | reset_req := { |
| 478 | reset_type := rst_type, |
| 479 | padding := '000000'O |
| 480 | } |
| 481 | } |
| 482 | }; |
| 483 | |
| 484 | /* for generating FBSB_REQ */ |
Vadim Yanitskiy | be33f6b | 2020-11-14 04:05:34 +0700 | [diff] [blame] | 485 | template (value) L1ctlUlMessage |
Vadim Yanitskiy | 1acc7bb | 2020-11-14 04:24:57 +0700 | [diff] [blame] | 486 | ts_L1CTL_FBSB_REQ(template (value) GsmBandArfcn arfcn, |
Vadim Yanitskiy | be33f6b | 2020-11-14 04:05:34 +0700 | [diff] [blame] | 487 | template (value) L1ctlFbsbFlags flags, |
| 488 | template (value) uint8_t sync_info_idx, |
| 489 | template (value) L1ctlCcchMode ccch_mode, |
| 490 | template (value) GsmRxLev rxlev_exp) := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 491 | header := ts_L1ctlHeader(L1CTL_FBSB_REQ), |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 492 | ul_info := omit, |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 493 | ul_info_tbf := omit, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 494 | ul_info_abs := omit, |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 495 | payload := { |
| 496 | fbsb_req := { |
| 497 | arfcn := arfcn, |
Harald Welte | a82f7e6 | 2018-02-22 18:51:33 +0100 | [diff] [blame] | 498 | timeout_tdma_frames := 250, /* about 1s */ |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 499 | freq_err_thresh1 := 10000, |
| 500 | freq_err_thresh2 := 800, |
| 501 | num_freqerr_avg := 3, |
| 502 | flags := flags, |
| 503 | sync_info_idx := sync_info_idx, |
| 504 | ccch_mode := ccch_mode, |
| 505 | rxlev_exp := rxlev_exp |
| 506 | } |
| 507 | } |
| 508 | }; |
| 509 | |
| 510 | /* for matching against incoming FBSB_CONF */ |
Vadim Yanitskiy | be33f6b | 2020-11-14 04:05:34 +0700 | [diff] [blame] | 511 | template L1ctlDlMessage |
| 512 | tr_L1CTL_FBSB_CONF(template (present) uint8_t result) := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 513 | header := tr_L1ctlHeader(L1CTL_FBSB_CONF), |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 514 | dl_info := ?, |
| 515 | payload := { |
| 516 | fbsb_conf := { |
| 517 | initial_freq_err := ?, |
| 518 | result := result, |
| 519 | bsic := ? |
| 520 | } |
| 521 | } |
| 522 | }; |
| 523 | |
Vadim Yanitskiy | be33f6b | 2020-11-14 04:05:34 +0700 | [diff] [blame] | 524 | template (value) L1ctlUlMessage |
| 525 | ts_L1CTL_CCCH_MODE_REQ(template (value) L1ctlCcchMode ccch_mode) := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 526 | header := ts_L1ctlHeader(L1CTL_CCCH_MODE_REQ), |
| 527 | ul_info := omit, |
| 528 | ul_info_tbf := omit, |
| 529 | ul_info_abs := omit, |
| 530 | payload := { |
| 531 | ccch_mode_req := { |
| 532 | ccch_mode := ccch_mode, |
| 533 | padding := '000000'O |
| 534 | } |
| 535 | } |
| 536 | }; |
| 537 | |
Vadim Yanitskiy | 3b1fae4 | 2020-10-19 16:16:41 +0700 | [diff] [blame] | 538 | template (value) L1ctlUlMessage |
| 539 | ts_L1CTL_TCH_MODE_REQ(template (value) L1ctlTchMode tch_mode := L1CTL_CHAN_MODE_SIGN, |
Vadim Yanitskiy | 1618583 | 2020-10-19 21:20:43 +0700 | [diff] [blame] | 540 | template (value) L1ctlAudioMode audio_mode := t_L1CTL_AudioModeFwd, |
Pau Espin Pedrol | 440e1dc | 2022-09-02 16:35:49 +0200 | [diff] [blame] | 541 | template (value) L1ctlLoopMode loop_mode := L1CTL_LOOP_MODE_OPEN, |
| 542 | template (value) uint8_t amr_start_codec := 0, |
| 543 | template (value) BIT8 amr_codecs_bitmask := '00000000'B) := { |
Vadim Yanitskiy | 3b1fae4 | 2020-10-19 16:16:41 +0700 | [diff] [blame] | 544 | header := ts_L1ctlHeader(L1CTL_TCH_MODE_REQ), |
| 545 | ul_info := omit, |
| 546 | ul_info_tbf := omit, |
| 547 | ul_info_abs := omit, |
| 548 | payload := { |
| 549 | tch_mode_req := { |
| 550 | tch_mode := tch_mode, |
| 551 | audio_mode := audio_mode, |
| 552 | loop_mode := loop_mode, |
Pau Espin Pedrol | 440e1dc | 2022-09-02 16:35:49 +0200 | [diff] [blame] | 553 | amr := { |
| 554 | start_codec := amr_start_codec, |
| 555 | codecs_bitmask := amr_codecs_bitmask |
| 556 | } |
Vadim Yanitskiy | 3b1fae4 | 2020-10-19 16:16:41 +0700 | [diff] [blame] | 557 | } |
| 558 | } |
| 559 | }; |
| 560 | |
Harald Welte | 3757e60 | 2018-03-10 17:12:02 +0100 | [diff] [blame] | 561 | |
Vadim Yanitskiy | be33f6b | 2020-11-14 04:05:34 +0700 | [diff] [blame] | 562 | template L1ctlDlMessage |
| 563 | tr_L1CTL_MsgType(template (present) L1ctlMsgType msg_type) := { |
Harald Welte | 3757e60 | 2018-03-10 17:12:02 +0100 | [diff] [blame] | 564 | header := tr_L1ctlHeader(msg_type), |
| 565 | dl_info := *, |
Harald Welte | f56cc49 | 2018-04-15 10:58:43 +0200 | [diff] [blame] | 566 | payload := * |
Harald Welte | 3757e60 | 2018-03-10 17:12:02 +0100 | [diff] [blame] | 567 | } |
| 568 | |
| 569 | 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] | 570 | |
Vadim Yanitskiy | be33f6b | 2020-11-14 04:05:34 +0700 | [diff] [blame] | 571 | template (value) L1ctlUlMessage |
| 572 | ts_L1CTL_RACH_REQ(template (value) uint8_t ra, |
| 573 | template (value) uint8_t combined, |
| 574 | template (value) uint16_t offset, |
| 575 | template (value) RslChannelNr chan_nr := ts_RslChanNr_RACH(0), |
| 576 | template (value) RslLinkId link_id := ts_RslLinkID_DCCH(0)) := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 577 | header := ts_L1ctlHeader(L1CTL_RACH_REQ), |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 578 | ul_info := { |
Vadim Yanitskiy | e432ba9 | 2019-05-31 18:44:13 +0700 | [diff] [blame] | 579 | chan_nr := chan_nr, |
| 580 | link_id := link_id, |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 581 | padding := '0000'O |
| 582 | }, |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 583 | ul_info_tbf := omit, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 584 | ul_info_abs := omit, |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 585 | payload := { |
| 586 | rach_req := { |
| 587 | ra := ra, |
| 588 | combined := combined, |
| 589 | offset := offset |
| 590 | } |
| 591 | } |
| 592 | } |
| 593 | |
Vadim Yanitskiy | be33f6b | 2020-11-14 04:05:34 +0700 | [diff] [blame] | 594 | template (value) L1ctlUlMessage |
| 595 | ts_L1CTL_EXT_RACH_REQ(template (value) uint16_t ra11, |
| 596 | template (value) L1ctlRachSynchSeq seq, |
| 597 | template (value) uint8_t combined, |
| 598 | template (value) uint16_t offset) := { |
Vadim Yanitskiy | 5c83679 | 2019-04-22 05:45:03 +0700 | [diff] [blame] | 599 | header := ts_L1ctlHeader(L1CTL_EXT_RACH_REQ), |
| 600 | ul_info := { |
| 601 | /* FIXME: both RSL chan_nr and link_id should be configurable */ |
Vadim Yanitskiy | 443891b | 2022-03-12 17:46:57 +0300 | [diff] [blame] | 602 | chan_nr := ts_RslChanNr_RACH(0), |
Vadim Yanitskiy | 5c83679 | 2019-04-22 05:45:03 +0700 | [diff] [blame] | 603 | link_id := ts_RslLinkID_DCCH(0), |
| 604 | padding := '0000'O |
| 605 | }, |
| 606 | ul_info_tbf := omit, |
| 607 | ul_info_abs := omit, |
| 608 | payload := { |
| 609 | ext_rach_req := { |
| 610 | ra11 := ra11, |
| 611 | synch_seq := seq, |
| 612 | combined := combined, |
| 613 | offset := offset |
| 614 | } |
| 615 | } |
| 616 | } |
| 617 | |
Vadim Yanitskiy | be33f6b | 2020-11-14 04:05:34 +0700 | [diff] [blame] | 618 | template (value) L1ctlUlMessage |
| 619 | ts_L1CTL_PAR_REQ(template (value) uint8_t ta, |
| 620 | template (value) uint8_t tx_power) := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 621 | header := ts_L1ctlHeader(L1CTL_PARAM_REQ), |
Harald Welte | 3705273 | 2018-03-09 19:38:46 +0100 | [diff] [blame] | 622 | ul_info := { |
Vadim Yanitskiy | 443891b | 2022-03-12 17:46:57 +0300 | [diff] [blame] | 623 | chan_nr := ts_RslChanNr_RACH(0), |
Harald Welte | 3705273 | 2018-03-09 19:38:46 +0100 | [diff] [blame] | 624 | link_id := ts_RslLinkID_DCCH(0), |
| 625 | padding := '0000'O |
| 626 | }, |
| 627 | ul_info_tbf := omit, |
| 628 | ul_info_abs := omit, |
| 629 | payload := { |
| 630 | par_req := { |
| 631 | ta := ta, |
| 632 | tx_power := tx_power, |
| 633 | padding := '0000'O |
| 634 | } |
| 635 | } |
| 636 | } |
| 637 | |
Vadim Yanitskiy | 5afe885 | 2020-05-27 14:40:51 +0700 | [diff] [blame] | 638 | /* Base template to be inherited by ts_L1CTL_DM_EST_REQ_H0 and ts_L1CTL_DM_EST_REQ_H1 */ |
Vadim Yanitskiy | be33f6b | 2020-11-14 04:05:34 +0700 | [diff] [blame] | 639 | private template (value) L1ctlUlMessage |
| 640 | ts_L1CTL_DM_EST_REQ(template (value) RslChannelNr chan_nr, |
| 641 | template (value) GsmTsc tsc) := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 642 | header := ts_L1ctlHeader(L1CTL_DM_EST_REQ), |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 643 | ul_info := { |
| 644 | chan_nr := chan_nr, |
| 645 | link_id := ts_RslLinkID_DCCH(0), |
| 646 | padding := '0000'O |
| 647 | }, |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 648 | ul_info_tbf := omit, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 649 | ul_info_abs := omit, |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 650 | payload := { |
| 651 | dm_est_req := { |
| 652 | tsc := tsc, |
Vadim Yanitskiy | 0a3e31c | 2022-12-18 08:09:38 +0700 | [diff] [blame] | 653 | h0h1 := -, |
Vadim Yanitskiy | fe05296 | 2020-10-19 13:27:09 +0700 | [diff] [blame] | 654 | tch_mode := L1CTL_CHAN_MODE_SIGN, |
Vadim Yanitskiy | 1618583 | 2020-10-19 21:20:43 +0700 | [diff] [blame] | 655 | audio_mode := t_L1CTL_AudioModeFwd |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 656 | } |
| 657 | } |
| 658 | } |
| 659 | |
Vadim Yanitskiy | be33f6b | 2020-11-14 04:05:34 +0700 | [diff] [blame] | 660 | template (value) L1ctlUlMessage |
| 661 | ts_L1CTL_DM_EST_REQ_H0(template (value) RslChannelNr chan_nr, |
| 662 | template (value) GsmTsc tsc, |
| 663 | template (value) GsmArfcn arfcn) |
Vadim Yanitskiy | 5afe885 | 2020-05-27 14:40:51 +0700 | [diff] [blame] | 664 | modifies ts_L1CTL_DM_EST_REQ := { |
| 665 | payload := { |
| 666 | dm_est_req := { |
Vadim Yanitskiy | 2cdb97f | 2020-10-19 14:17:38 +0700 | [diff] [blame] | 667 | h0h1 := { |
| 668 | h0 := { |
| 669 | h := 0, |
Vadim Yanitskiy | 1acc7bb | 2020-11-14 04:24:57 +0700 | [diff] [blame] | 670 | arfcn := ts_GsmBandArfcn(arfcn), |
Vadim Yanitskiy | 2cdb97f | 2020-10-19 14:17:38 +0700 | [diff] [blame] | 671 | padding := f_pad_oct(''O, 130, '00'O) |
| 672 | } |
| 673 | } |
Vadim Yanitskiy | 5afe885 | 2020-05-27 14:40:51 +0700 | [diff] [blame] | 674 | } |
| 675 | } |
| 676 | } |
| 677 | |
Vadim Yanitskiy | be33f6b | 2020-11-14 04:05:34 +0700 | [diff] [blame] | 678 | template (value) L1ctlUlMessage |
| 679 | ts_L1CTL_DM_EST_REQ_H1(template (value) RslChannelNr chan_nr, |
| 680 | template (value) GsmTsc tsc, |
| 681 | template (value) uint6_t hsn, |
| 682 | template (value) uint6_t maio, |
| 683 | template (value) L1ctlMA ma) |
Vadim Yanitskiy | eda9081 | 2020-05-27 14:51:18 +0700 | [diff] [blame] | 684 | modifies ts_L1CTL_DM_EST_REQ := { |
| 685 | payload := { |
| 686 | dm_est_req := { |
Vadim Yanitskiy | 2cdb97f | 2020-10-19 14:17:38 +0700 | [diff] [blame] | 687 | h0h1 := { |
| 688 | h1 := { |
| 689 | h := 1, |
| 690 | hsn := hsn, |
| 691 | maio := maio, |
| 692 | n := sizeof(ma), |
| 693 | spare := '00'O, |
| 694 | ma := ma, |
| 695 | /* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=562849 */ |
| 696 | padding := f_pad_oct(''O, (64 - sizeof(ma)) * 2, '00'O) |
| 697 | } |
Vadim Yanitskiy | eda9081 | 2020-05-27 14:51:18 +0700 | [diff] [blame] | 698 | } |
| 699 | } |
| 700 | } |
| 701 | } |
| 702 | |
Vadim Yanitskiy | be33f6b | 2020-11-14 04:05:34 +0700 | [diff] [blame] | 703 | template (value) L1ctlUlMessage |
| 704 | ts_L1CTL_DM_REL_REQ(template (value) RslChannelNr chan_nr) := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 705 | header := ts_L1ctlHeader(L1CTL_DM_REL_REQ), |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 706 | ul_info := { |
| 707 | chan_nr := chan_nr, |
| 708 | link_id := ts_RslLinkID_DCCH(0), |
| 709 | padding := '0000'O |
| 710 | }, |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 711 | ul_info_tbf := omit, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 712 | ul_info_abs := omit, |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 713 | payload := { |
| 714 | other := ''O |
| 715 | } |
| 716 | } |
| 717 | |
Vadim Yanitskiy | be33f6b | 2020-11-14 04:05:34 +0700 | [diff] [blame] | 718 | template (value) L1ctlUlMessage |
| 719 | ts_L1CTL_DATA_REQ(template (value) RslChannelNr chan_nr, |
| 720 | template (value) RslLinkId link_id, |
| 721 | octetstring l2_data) := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 722 | header := ts_L1ctlHeader(L1CTL_DATA_REQ), |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 723 | ul_info := { |
| 724 | chan_nr := chan_nr, |
| 725 | link_id := link_id, |
| 726 | padding := '0000'O |
| 727 | }, |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 728 | ul_info_tbf := omit, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 729 | ul_info_abs := omit, |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 730 | payload := { |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 731 | data_req := { |
| 732 | l1header := omit, |
| 733 | l2_payload := l2_data |
| 734 | } |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 735 | } |
| 736 | } |
| 737 | |
Vadim Yanitskiy | be33f6b | 2020-11-14 04:05:34 +0700 | [diff] [blame] | 738 | template (value) L1ctlUlMessage |
| 739 | ts_L1CTL_DATA_REQ_SACCH(template (value) RslChannelNr chan_nr, |
| 740 | template (value) RslLinkId link_id, |
| 741 | template (value) SacchL1Header l1h, |
| 742 | octetstring l2_data) := { |
Pau Espin Pedrol | 0aad596 | 2018-09-28 16:03:55 +0200 | [diff] [blame] | 743 | header := ts_L1ctlHeader(L1CTL_DATA_REQ), |
| 744 | ul_info := { |
| 745 | chan_nr := chan_nr, |
| 746 | link_id := link_id, |
| 747 | padding := '0000'O |
| 748 | }, |
| 749 | ul_info_tbf := omit, |
| 750 | ul_info_abs := omit, |
| 751 | payload := { |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 752 | data_req := { |
| 753 | l1header := l1h, |
| 754 | l2_payload := l2_data |
| 755 | } |
Pau Espin Pedrol | 0aad596 | 2018-09-28 16:03:55 +0200 | [diff] [blame] | 756 | } |
| 757 | } |
| 758 | |
Vadim Yanitskiy | be33f6b | 2020-11-14 04:05:34 +0700 | [diff] [blame] | 759 | template (value) L1ctlUlMessage |
| 760 | ts_L1CTL_TRAFFIC_REQ(template (value) RslChannelNr chan_nr, |
| 761 | template (value) RslLinkId link_id, |
| 762 | octetstring frame) := { |
Vadim Yanitskiy | f3cc649 | 2019-06-30 16:34:30 +0700 | [diff] [blame] | 763 | header := ts_L1ctlHeader(L1CTL_TRAFFIC_REQ), |
| 764 | ul_info := { |
| 765 | chan_nr := chan_nr, |
| 766 | link_id := link_id, |
| 767 | padding := '0000'O |
| 768 | }, |
| 769 | ul_info_tbf := omit, |
| 770 | ul_info_abs := omit, |
| 771 | payload := { |
| 772 | traffic_req := { |
| 773 | data := frame |
| 774 | } |
| 775 | } |
| 776 | }; |
| 777 | |
Vadim Yanitskiy | be33f6b | 2020-11-14 04:05:34 +0700 | [diff] [blame] | 778 | template (value) L1ctlUlMessage |
| 779 | ts_L1CTL_TBF_CFG_REQ(template (value) boolean is_uplink, |
| 780 | template (value) TfiUsfArr tfi_usf) := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 781 | header := ts_L1ctlHeader(L1CTL_TBF_CFG_REQ), |
Harald Welte | 00d4dac | 2017-07-30 00:50:32 +0200 | [diff] [blame] | 782 | ul_info := omit, |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 783 | ul_info_tbf := omit, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 784 | ul_info_abs := omit, |
Harald Welte | 00d4dac | 2017-07-30 00:50:32 +0200 | [diff] [blame] | 785 | payload := { |
| 786 | tbf_cfg_req := { |
| 787 | tbf_nr := 0, |
| 788 | is_uplink := is_uplink, |
| 789 | padding := '0000'O, |
| 790 | tfi_usf := tfi_usf |
| 791 | } |
| 792 | } |
| 793 | }; |
| 794 | |
Vadim Yanitskiy | be33f6b | 2020-11-14 04:05:34 +0700 | [diff] [blame] | 795 | template L1ctlDlMessage |
| 796 | tr_L1CTL_TBF_CFG_CONF(template (present) boolean is_uplink) := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 797 | header := tr_L1ctlHeader(L1CTL_TBF_CFG_CONF), |
Harald Welte | 00d4dac | 2017-07-30 00:50:32 +0200 | [diff] [blame] | 798 | dl_info := omit, |
| 799 | payload := { |
| 800 | tbf_cfg_conf := { |
| 801 | tbf_nr := 0, |
| 802 | is_uplink := is_uplink, |
| 803 | padding := ?, |
| 804 | tfi_usf := ? |
| 805 | } |
| 806 | } |
| 807 | }; |
| 808 | |
Vadim Yanitskiy | be33f6b | 2020-11-14 04:05:34 +0700 | [diff] [blame] | 809 | template (value) L1ctlUlMessage |
| 810 | ts_L1CTL_DATA_TBF_REQ(octetstring l2_data, |
| 811 | template (value) L1ctlGprsCs cs := L1CTL_CS1, |
| 812 | template (value) uint8_t tbf_nr := 0) := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 813 | header := ts_L1ctlHeader(L1CTL_DATA_TBF_REQ), |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 814 | ul_info := omit, |
| 815 | ul_info_tbf := { |
| 816 | tbf_nr := tbf_nr, |
Harald Welte | 1dcc371 | 2017-08-01 00:05:52 +0200 | [diff] [blame] | 817 | cs := cs, |
| 818 | padding := '0000'O |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 819 | }, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 820 | ul_info_abs := omit, |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 821 | payload := { |
| 822 | other := l2_data |
| 823 | } |
| 824 | } |
| 825 | |
Vadim Yanitskiy | be33f6b | 2020-11-14 04:05:34 +0700 | [diff] [blame] | 826 | template (value) L1ctlUlMessage |
| 827 | ts_L1CTL_DATA_ABS_REQ(octetstring l2_data, |
Vadim Yanitskiy | 1acc7bb | 2020-11-14 04:24:57 +0700 | [diff] [blame] | 828 | template (value) GsmBandArfcn arfcn, |
Vadim Yanitskiy | be33f6b | 2020-11-14 04:05:34 +0700 | [diff] [blame] | 829 | template (value) uint8_t ts, |
| 830 | template (value) GsmFrameNumber fn, |
| 831 | template (value) L1ctlGprsCs cs := L1CTL_CS1, |
| 832 | template (value) uint8_t tbf_nr := 0) := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 833 | header := ts_L1ctlHeader(L1CTL_DATA_ABS_REQ), |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 834 | ul_info := omit, |
| 835 | ul_info_tbf := omit, |
| 836 | ul_info_abs := { |
| 837 | tbf_nr := tbf_nr, |
| 838 | cs := cs, |
| 839 | ts_nr := ts, |
| 840 | padding := '00'O, |
| 841 | fn := fn, |
| 842 | arfcn := arfcn, |
| 843 | padding2 := '0000'O |
| 844 | }, |
| 845 | payload := { |
| 846 | other := l2_data |
| 847 | } |
| 848 | } |
| 849 | |
| 850 | |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 851 | /* for matching against incoming RACH_CONF */ |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 852 | template L1ctlDlMessage tr_L1CTL_RACH_CONF := { |
| 853 | header := tr_L1ctlHeader(L1CTL_RACH_CONF), |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 854 | dl_info := ?, |
Harald Welte | f56cc49 | 2018-04-15 10:58:43 +0200 | [diff] [blame] | 855 | payload := * |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 856 | }; |
| 857 | |
Vadim Yanitskiy | 60b6188 | 2022-12-18 06:02:22 +0700 | [diff] [blame] | 858 | /* for sending and matching L1CTL_DATA_IND */ |
| 859 | template (value) L1ctlDlMessage |
| 860 | ts_L1CTL_DATA_IND(template (value) RslChannelNr chan_nr, |
| 861 | template (value) RslLinkId link_id, |
| 862 | template (value) octetstring l2_data, |
| 863 | template (value) GsmBandArfcn arfcn, |
| 864 | template (value) uint32_t fn := 1337, |
| 865 | template (value) GsmRxLev rx_level := 63, |
| 866 | template (value) uint8_t num_biterr := 0, |
| 867 | template (value) uint8_t fire_crc := 0) := { |
| 868 | header := ts_L1ctlHeader(L1CTL_DATA_IND), |
| 869 | dl_info := { |
| 870 | chan_nr := chan_nr, |
| 871 | link_id := link_id, |
| 872 | arfcn := arfcn, |
| 873 | frame_nr := fn, |
| 874 | rx_level := rx_level, |
| 875 | snr := 0, |
| 876 | num_biterr := num_biterr, |
| 877 | fire_crc := fire_crc |
| 878 | }, |
| 879 | payload := { |
| 880 | data_ind := { |
| 881 | payload := l2_data |
| 882 | } |
| 883 | } |
| 884 | }; |
Vadim Yanitskiy | be33f6b | 2020-11-14 04:05:34 +0700 | [diff] [blame] | 885 | template L1ctlDlMessage |
| 886 | tr_L1CTL_DATA_IND(template (present) RslChannelNr chan_nr, |
| 887 | template (present) RslLinkId link_id := ?, |
| 888 | template (present) octetstring l2_data := ?, |
| 889 | template (present) uint8_t num_biterr := 0, |
| 890 | template (present) uint8_t fire_crc := 0) := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 891 | header := tr_L1ctlHeader(L1CTL_DATA_IND), |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 892 | dl_info := { |
| 893 | chan_nr := chan_nr, |
Harald Welte | ce6dc44 | 2018-02-21 22:00:21 +0100 | [diff] [blame] | 894 | link_id := link_id, |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 895 | arfcn := ?, |
| 896 | frame_nr := ?, |
| 897 | rx_level := ?, |
| 898 | snr := ?, |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 899 | num_biterr := num_biterr, |
Pau Espin Pedrol | 17da323 | 2022-09-02 16:35:32 +0200 | [diff] [blame] | 900 | fire_crc := fire_crc |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 901 | }, |
| 902 | payload := { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 903 | data_ind := { |
| 904 | payload := l2_data |
| 905 | } |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 906 | } |
| 907 | }; |
| 908 | |
Vadim Yanitskiy | f3cc649 | 2019-06-30 16:34:30 +0700 | [diff] [blame] | 909 | /* for matching against incoming TRAFFIC_IND */ |
Vadim Yanitskiy | be33f6b | 2020-11-14 04:05:34 +0700 | [diff] [blame] | 910 | template L1ctlDlMessage |
| 911 | tr_L1CTL_TRAFFIC_IND(template (present) RslChannelNr chan_nr, |
| 912 | template (present) RslLinkId link_id := ?, |
| 913 | template (present) octetstring frame := ?, |
| 914 | template (present) uint8_t num_biterr := ?, |
| 915 | template (present) uint8_t fire_crc := ?) := { |
Vadim Yanitskiy | f3cc649 | 2019-06-30 16:34:30 +0700 | [diff] [blame] | 916 | header := tr_L1ctlHeader(L1CTL_TRAFFIC_IND), |
| 917 | dl_info := { |
| 918 | chan_nr := chan_nr, |
| 919 | link_id := link_id, |
| 920 | arfcn := ?, |
| 921 | frame_nr := ?, |
| 922 | rx_level := ?, |
| 923 | snr := ?, |
| 924 | num_biterr := num_biterr, |
| 925 | fire_crc := fire_crc |
| 926 | }, |
| 927 | payload := { |
| 928 | traffic_ind := { |
| 929 | data := frame |
| 930 | } |
| 931 | } |
| 932 | }; |
| 933 | |
Vadim Yanitskiy | be33f6b | 2020-11-14 04:05:34 +0700 | [diff] [blame] | 934 | template (value) L1ctlUlMessage |
| 935 | ts_L1CTL_CRYPTO_REQ(template (value) RslChannelNr chan_nr, |
| 936 | template (value) uint8_t algo, |
| 937 | template (value) octetstring key) := { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 938 | header := ts_L1ctlHeader(L1CTL_CRYPTO_REQ), |
| 939 | ul_info := { |
| 940 | chan_nr := chan_nr, |
| 941 | link_id := ts_RslLinkID_DCCH(0), |
| 942 | padding := '0000'O |
| 943 | }, |
| 944 | ul_info_tbf := omit, |
| 945 | ul_info_abs := omit, |
| 946 | payload := { |
| 947 | crypto_req := { |
| 948 | algo := algo, |
| 949 | key_len := 0, /* overwritten */ |
| 950 | key := key |
| 951 | } |
| 952 | } |
| 953 | }; |
| 954 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 955 | const octetstring c_DummyUI := '0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O; |
| 956 | |
Harald Welte | 7024baa | 2018-03-02 23:37:51 +0100 | [diff] [blame] | 957 | /* We use "BYTEORDER(last)" so we get little-endian integers. Unfortuantely, this also |
| 958 | 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] | 959 | } with { encode "RAW" }; |