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