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 |
| 3 | * (C) 2010 by Harald Welte + Holger Hans Peter Freyther */ |
| 4 | module L1CTL_Types { |
| 5 | |
| 6 | import from General_Types all; |
| 7 | import from GSM_Types all; |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 8 | import from GSM_RR_Types all; |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 9 | import from Osmocom_Types all; |
| 10 | |
Harald Welte | 7024baa | 2018-03-02 23:37:51 +0100 | [diff] [blame] | 11 | type uint32_t uint32_le with { variant "BYTEORDER(first)" }; |
| 12 | |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 13 | type enumerated L1ctlMsgType { |
| 14 | L1CTL_NONE, |
| 15 | L1CTL_FBSB_REQ, |
| 16 | L1CTL_FBSB_CONF, |
| 17 | L1CTL_DATA_IND, |
| 18 | L1CTL_RACH_REQ, |
| 19 | L1CTL_DM_EST_REQ, |
| 20 | L1CTL_DATA_REQ, |
| 21 | L1CTL_RESET_IND, |
| 22 | L1CTL_PM_REQ, /* power measurement */ |
| 23 | L1CTL_PM_CONF, /* power measurement */ |
| 24 | L1CTL_ECHO_REQ, |
| 25 | L1CTL_ECHO_CONF, |
| 26 | L1CTL_RACH_CONF, |
| 27 | L1CTL_RESET_REQ, |
| 28 | L1CTL_RESET_CONF, |
| 29 | L1CTL_DATA_CONF, |
| 30 | L1CTL_CCCH_MODE_REQ, |
| 31 | L1CTL_CCCH_MODE_CONF, |
| 32 | L1CTL_DM_REL_REQ, |
| 33 | L1CTL_PARAM_REQ, |
| 34 | L1CTL_DM_FREQ_REQ, |
| 35 | L1CTL_CRYPTO_REQ, |
| 36 | L1CTL_SIM_REQ, |
| 37 | L1CTL_SIM_CONF, |
| 38 | L1CTL_TCH_MODE_REQ, |
| 39 | L1CTL_TCH_MODE_CONF, |
| 40 | L1CTL_NEIGH_PM_REQ, |
| 41 | L1CTL_NEIGH_PM_IND, |
| 42 | L1CTL_TRAFFIC_REQ, |
| 43 | L1CTL_TRAFFIC_CONF, |
Harald Welte | 00d4dac | 2017-07-30 00:50:32 +0200 | [diff] [blame] | 44 | L1CTL_TRAFFIC_IND, |
| 45 | L1CTL_TBF_CFG_REQ, |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 46 | L1CTL_TBF_CFG_CONF, |
| 47 | L1CTL_DATA_TBF_REQ, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 48 | L1CTL_DATA_TBF_CONF, |
| 49 | L1CTL_DATA_ABS_REQ |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 50 | } with { variant "FIELDLENGTH(8)" }; |
| 51 | |
| 52 | type enumerated L1ctlCcchMode { |
| 53 | CCCH_MODE_NONE (0), |
| 54 | CCCH_MODE_NON_COMBINED, |
| 55 | CCCH_MODE_COMBINED |
| 56 | } with { variant "FIELDLENGTH(8)" }; |
| 57 | |
| 58 | type enumerated L1ctlNeighMode { |
| 59 | NEIGH_MODE_NONE (0), |
| 60 | NEIGH_MODE_PM, |
| 61 | NEIGH_MODE_SB |
| 62 | } with { variant "FIELDLENGTH(8)" }; |
| 63 | |
Harald Welte | 1dcc371 | 2017-08-01 00:05:52 +0200 | [diff] [blame] | 64 | type enumerated L1ctlGprsCs { |
| 65 | L1CTL_CS1 (1), |
| 66 | L1CTL_CS2, |
| 67 | L1CTL_CS3, |
| 68 | L1CTL_CS4, |
| 69 | L1CTL_MCS1, |
| 70 | L1CTL_MCS2, |
| 71 | L1CTL_MCS3, |
| 72 | L1CTL_MCS4, |
| 73 | L1CTL_MCS5, |
| 74 | L1CTL_MCS6, |
| 75 | L1CTL_MCS7, |
| 76 | L1CTL_MCS8, |
| 77 | L1CTL_MCS9 |
| 78 | } with { variant "FIELDLENGTH(8)" }; |
| 79 | |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 80 | type enumerated L1ctlResetType { |
| 81 | L1CTL_RES_T_BOOT (0), |
| 82 | L1CTL_RES_T_FULL, |
| 83 | L1CTL_RES_T_SCHED |
| 84 | } with { variant "FIELDLENGTH(8)" }; |
| 85 | |
| 86 | const integer TRAFFIC_DATA_LEN := 40; |
| 87 | |
| 88 | type record L1ctlHdrFlags { |
| 89 | BIT7 padding, |
| 90 | boolean f_done |
| 91 | } with { variant "" }; |
| 92 | |
| 93 | type record L1ctlHeader { |
| 94 | L1ctlMsgType msg_type, |
| 95 | L1ctlHdrFlags flags, |
| 96 | OCT2 padding |
| 97 | } with { variant "" }; |
| 98 | |
Harald Welte | 52c713c | 2017-07-16 15:44:44 +0200 | [diff] [blame] | 99 | template L1ctlHeader t_L1ctlHeader(template L1ctlMsgType msg_type) := { |
| 100 | msg_type := msg_type, |
| 101 | flags := { padding := '0000000'B, f_done := false }, |
| 102 | padding := '0000'O |
| 103 | }; |
| 104 | |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 105 | type record L1ctlDlInfo { |
Harald Welte | 8e4db2c | 2017-07-16 18:54:55 +0200 | [diff] [blame] | 106 | RslChannelNr chan_nr, |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 107 | RslLinkId link_id, |
| 108 | Arfcn arfcn, |
Harald Welte | 5f0d5c8 | 2017-07-16 18:56:01 +0200 | [diff] [blame] | 109 | uint32_t frame_nr, |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 110 | GsmRxLev rx_level, |
| 111 | uint8_t snr, |
| 112 | uint8_t num_biterr, |
| 113 | uint8_t fire_crc |
| 114 | } with { variant "" }; |
| 115 | |
| 116 | type record L1ctlFbsbConf { |
| 117 | int16_t initial_freq_err, |
| 118 | uint8_t result, |
| 119 | uint8_t bsic |
| 120 | } with { variant "" }; |
| 121 | |
| 122 | type record L1ctlCcchModeConf { |
| 123 | L1ctlCcchMode ccch_mode, |
| 124 | OCT3 padding |
| 125 | } with { variant "" }; |
| 126 | |
| 127 | /* gsm48_chan_mode */ |
| 128 | type uint8_t L1ctlTchMode; |
| 129 | |
| 130 | type record L1ctlAudioMode { |
| 131 | BIT4 padding, |
| 132 | boolean tx_microphone, |
| 133 | boolean tx_traffic_req, |
| 134 | boolean rx_speaker, |
| 135 | boolean rx_traffic_ind |
| 136 | } with { variant "" }; |
| 137 | |
Harald Welte | 66110f0 | 2017-07-16 21:05:18 +0200 | [diff] [blame] | 138 | template L1ctlAudioMode t_L1CTL_AudioModeNone := { '0000'B, false, false, false, false }; |
| 139 | |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 140 | type record L1ctlTchModeConf { |
| 141 | L1ctlTchMode tch_mode, |
| 142 | L1ctlAudioMode audio_mode, |
| 143 | OCT2 padding |
| 144 | } with { variant "" }; |
| 145 | |
| 146 | type record L1ctlDataInd { |
| 147 | octetstring payload length(23) |
Harald Welte | 7024baa | 2018-03-02 23:37:51 +0100 | [diff] [blame] | 148 | } with { |
| 149 | variant (payload) "BYTEORDER(first)" |
| 150 | }; |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 151 | |
| 152 | type union L1ctlDlPayload { |
| 153 | L1ctlFbsbConf fbsb_conf, |
| 154 | L1ctlCcchModeConf ccch_mode_conf, |
| 155 | L1ctlTchModeConf tch_mode_conf, |
| 156 | L1ctlDataInd data_ind, |
| 157 | L1ctlTrafficReq traffic_ind, |
Harald Welte | 00d4dac | 2017-07-30 00:50:32 +0200 | [diff] [blame] | 158 | L1ctlTbfCfgReq tbf_cfg_conf, |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 159 | octetstring other |
Harald Welte | 7024baa | 2018-03-02 23:37:51 +0100 | [diff] [blame] | 160 | } with { |
| 161 | variant (other) "BYTEORDER(first)" |
| 162 | }; |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 163 | |
| 164 | type record L1ctlDlMessage { |
| 165 | L1ctlHeader header, |
| 166 | L1ctlDlInfo dl_info optional, |
| 167 | L1ctlDlPayload payload |
| 168 | } with { variant (dl_info) "PRESENCE(header.msg_type = L1CTL_FBSB_CONF, |
| 169 | header.msg_type = L1CTL_RACH_CONF, |
| 170 | header.msg_type = L1CTL_DATA_IND, |
| 171 | header.msg_type = L1CTL_DATA_CONF, |
| 172 | header.msg_type = L1CTL_TRAFFIC_IND)" |
| 173 | variant (payload) "CROSSTAG(fbsb_conf, header.msg_type = L1CTL_FBSB_CONF; |
| 174 | ccch_mode_conf, header.msg_type = L1CTL_CCCH_MODE_CONF; |
| 175 | tch_mode_conf, header.msg_type = L1CTL_TCH_MODE_CONF; |
| 176 | data_ind, header.msg_type = L1CTL_DATA_IND; |
| 177 | traffic_ind, header.msg_type = L1CTL_TRAFFIC_IND; |
Harald Welte | 00d4dac | 2017-07-30 00:50:32 +0200 | [diff] [blame] | 178 | tbf_cfg_conf, header.msg_type = L1CTL_TBF_CFG_CONF; |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 179 | other, OTHERWISE; |
| 180 | )" }; |
| 181 | |
| 182 | external function enc_L1ctlDlMessage(in L1ctlDlMessage msg) return octetstring |
| 183 | with { extension "prototype(convert) encode(RAW)" }; |
| 184 | external function dec_L1ctlDlMessage(in octetstring stream) return L1ctlDlMessage |
| 185 | with { extension "prototype(convert) decode(RAW)" }; |
| 186 | |
| 187 | |
| 188 | type record L1ctlUlInfo { |
Harald Welte | 8e4db2c | 2017-07-16 18:54:55 +0200 | [diff] [blame] | 189 | RslChannelNr chan_nr, |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 190 | RslLinkId link_id, |
| 191 | OCT2 padding |
| 192 | } with { variant "" }; |
| 193 | |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 194 | type record L1ctlUlTbfInfo { |
| 195 | uint8_t tbf_nr, |
Harald Welte | 1dcc371 | 2017-08-01 00:05:52 +0200 | [diff] [blame] | 196 | L1ctlGprsCs cs, |
| 197 | OCT2 padding |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 198 | } with { variant "" }; |
| 199 | |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 200 | type record L1ctlUlAbsInfo { |
| 201 | uint8_t tbf_nr, |
| 202 | L1ctlGprsCs cs, |
| 203 | uint8_t ts_nr, |
| 204 | OCT1 padding, |
Harald Welte | 7024baa | 2018-03-02 23:37:51 +0100 | [diff] [blame] | 205 | uint32_le fn, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 206 | Arfcn arfcn, |
| 207 | OCT2 padding2 |
| 208 | } with { variant "" }; |
| 209 | |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 210 | type record L1ctlFbsbFlags { |
| 211 | BIT5 padding, |
| 212 | boolean sb, |
| 213 | boolean fb1, |
| 214 | boolean fb0 |
| 215 | } with { variant "" }; |
| 216 | |
Harald Welte | 66110f0 | 2017-07-16 21:05:18 +0200 | [diff] [blame] | 217 | template L1ctlFbsbFlags t_L1CTL_FBSB_F_ALL := { |
| 218 | padding := '00000'B, |
| 219 | sb := true, |
| 220 | fb1 := true, |
| 221 | fb0 := true |
| 222 | }; |
| 223 | |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 224 | type record L1ctlFbsbReq { |
| 225 | Arfcn arfcn, |
| 226 | uint16_t timeout_tdma_frames, |
| 227 | uint16_t freq_err_thresh1, |
| 228 | uint16_t freq_err_thresh2, |
| 229 | uint8_t num_freqerr_avg, |
| 230 | L1ctlFbsbFlags flags, |
| 231 | uint8_t sync_info_idx, |
| 232 | L1ctlCcchMode ccch_mode, |
| 233 | GsmRxLev rxlev_exp |
| 234 | } with { variant "" }; |
| 235 | |
| 236 | type record L1ctlCcchModeReq { |
| 237 | L1ctlTchMode tch_mode, |
| 238 | L1ctlAudioMode audio_mode, |
| 239 | OCT2 padding |
| 240 | } with { variant "" }; |
| 241 | |
| 242 | type record L1ctlTchModeReq { |
| 243 | L1ctlTchMode tch_mode, |
| 244 | L1ctlAudioMode audio_mode, |
| 245 | OCT2 padding |
| 246 | } with { variant "" }; |
| 247 | |
| 248 | type record L1ctlRachReq { |
| 249 | uint8_t ra, |
| 250 | uint8_t combined, |
| 251 | uint16_t offset |
| 252 | } with { variant "" }; |
| 253 | |
| 254 | type record L1ctlParReq { |
| 255 | int8_t ta, |
| 256 | uint8_t tx_power, |
| 257 | OCT2 padding |
| 258 | } with { variant "" }; |
| 259 | |
| 260 | type record L1ctlH1 { |
| 261 | uint8_t hsn, |
| 262 | uint8_t maio, |
| 263 | uint8_t n, |
| 264 | OCT1 padding, |
| 265 | bitstring ma length(64) |
| 266 | } with { variant "" }; |
| 267 | |
| 268 | type record L1ctlDmEstReq { |
| 269 | GsmTsc tsc, |
| 270 | uint8_t h, |
| 271 | Arfcn arfcn optional, |
| 272 | L1ctlH1 hopping optional, |
| 273 | L1ctlTchMode tch_mode, |
| 274 | L1ctlAudioMode audio_mode |
| 275 | } with { variant (arfcn) "PRESENCE(h = 0)" |
| 276 | variant (hopping) "PRESENCE(h = 1)" }; |
| 277 | |
| 278 | type record L1ctlReset { |
| 279 | L1ctlResetType reset_type, |
| 280 | OCT3 padding |
| 281 | } with { variant "" }; |
| 282 | |
| 283 | |
| 284 | type record L1ctlTrafficReq { |
| 285 | octetstring data length(TRAFFIC_DATA_LEN) |
Harald Welte | 7024baa | 2018-03-02 23:37:51 +0100 | [diff] [blame] | 286 | } with { |
| 287 | variant (data) "BYTEORDER(first)" |
| 288 | } |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 289 | |
Harald Welte | 00d4dac | 2017-07-30 00:50:32 +0200 | [diff] [blame] | 290 | type record length(8) of uint8_t TfiUsfArr; |
| 291 | |
| 292 | type record L1ctlTbfCfgReq { |
| 293 | uint8_t tbf_nr, |
| 294 | boolean is_uplink, |
| 295 | OCT2 padding, |
| 296 | TfiUsfArr tfi_usf |
| 297 | } with { variant (is_uplink) "FIELDLENGTH(8)" }; |
| 298 | |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 299 | type union L1ctlUlPayload { |
| 300 | L1ctlFbsbReq fbsb_req, |
| 301 | L1ctlCcchModeReq ccch_mode_req, |
| 302 | L1ctlTchModeReq tch_mode_req, |
| 303 | L1ctlRachReq rach_req, |
| 304 | L1ctlParReq par_req, |
| 305 | L1ctlDmEstReq dm_est_req, |
| 306 | L1ctlReset reset_req, |
| 307 | //L1ctlNeighPmReq neigh_pm_req, |
| 308 | L1ctlTrafficReq traffic_req, |
Harald Welte | 00d4dac | 2017-07-30 00:50:32 +0200 | [diff] [blame] | 309 | L1ctlTbfCfgReq tbf_cfg_req, |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 310 | octetstring other |
Harald Welte | 7024baa | 2018-03-02 23:37:51 +0100 | [diff] [blame] | 311 | } with { |
| 312 | variant (other) "BYTEORDER(first)" |
| 313 | }; |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 314 | |
| 315 | type record L1ctlUlMessage { |
| 316 | L1ctlHeader header, |
| 317 | L1ctlUlInfo ul_info optional, |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 318 | L1ctlUlTbfInfo ul_info_tbf optional, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 319 | L1ctlUlAbsInfo ul_info_abs optional, |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 320 | L1ctlUlPayload payload |
| 321 | } with { variant (ul_info) "PRESENCE(header.msg_type = L1CTL_RACH_REQ, |
| 322 | header.msg_type = L1CTL_PARAM_REQ, |
| 323 | header.msg_type = L1CTL_CRYPTO_REQ, |
| 324 | header.msg_type = L1CTL_DATA_REQ, |
| 325 | header.msg_type = L1CTL_DM_EST_REQ, |
| 326 | header.msg_type = L1CTL_DM_FREQ_REQ, |
| 327 | header.msg_type = L1CTL_DM_REL_REQ, |
| 328 | header.msg_type = L1CTL_TRAFFIC_REQ)" |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 329 | variant (ul_info_tbf) "PRESENCE(header.msg_type = L1CTL_DATA_TBF_REQ)" |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 330 | variant (ul_info_abs) "PRESENCE(header.msg_type = L1CTL_DATA_ABS_REQ)" |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 331 | variant (payload) "CROSSTAG(fbsb_req, header.msg_type = L1CTL_FBSB_REQ; |
| 332 | ccch_mode_req, header.msg_type = L1CTL_CCCH_MODE_REQ; |
| 333 | tch_mode_req, header.msg_type = L1CTL_TCH_MODE_REQ; |
| 334 | rach_req, header.msg_type = L1CTL_RACH_REQ; |
| 335 | par_req, header.msg_type = L1CTL_PARAM_REQ; |
| 336 | dm_est_req, header.msg_type = L1CTL_DM_EST_REQ; |
| 337 | reset_req, header.msg_type = L1CTL_RESET_REQ; |
| 338 | traffic_req, header.msg_type = L1CTL_TRAFFIC_REQ; |
Harald Welte | 00d4dac | 2017-07-30 00:50:32 +0200 | [diff] [blame] | 339 | tbf_cfg_req, header.msg_type = L1CTL_TBF_CFG_REQ; |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 340 | other, OTHERWISE; |
| 341 | )" }; |
| 342 | |
| 343 | external function enc_L1ctlUlMessage(in L1ctlUlMessage msg) return octetstring |
| 344 | with { extension "prototype(convert) encode(RAW)" }; |
| 345 | external function dec_L1ctlUlMessage(in octetstring stream) return L1ctlUlMessage |
| 346 | with { extension "prototype(convert) decode(RAW)" }; |
| 347 | |
Harald Welte | 52c713c | 2017-07-16 15:44:44 +0200 | [diff] [blame] | 348 | type record L1ctlUlMessageLV { |
| 349 | uint16_t len, |
| 350 | L1ctlUlMessage msg |
| 351 | } with { variant (len) "LENGTHTO(msg)" }; |
| 352 | |
| 353 | external function enc_L1ctlUlMessageLV(in L1ctlUlMessageLV msg) return octetstring |
| 354 | with { extension "prototype(convert) encode(RAW)" }; |
| 355 | external function dec_L1ctlUlMessageLV(in octetstring stream) return L1ctlUlMessageLV |
| 356 | with { extension "prototype(convert) decode(RAW)" }; |
| 357 | |
| 358 | type record L1ctlDlMessageLV { |
| 359 | uint16_t len, |
| 360 | L1ctlDlMessage msg |
| 361 | } with { variant (len) "LENGTHTO(msg)" }; |
| 362 | |
| 363 | external function enc_L1ctlDlMessageLV(in L1ctlDlMessageLV msg) return octetstring |
| 364 | with { extension "prototype(convert) encode(RAW)" }; |
| 365 | external function dec_L1ctlDlMessageLV(in octetstring stream) return L1ctlDlMessageLV |
| 366 | with { extension "prototype(convert) decode(RAW)" }; |
| 367 | |
| 368 | |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 369 | |
| 370 | |
| 371 | /* for generating RESET_REQ */ |
| 372 | template L1ctlUlMessage t_L1ctlResetReq(template L1ctlResetType rst_type) := { |
| 373 | header := t_L1ctlHeader(L1CTL_RESET_REQ), |
| 374 | ul_info := omit, |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 375 | ul_info_tbf := omit, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 376 | ul_info_abs := omit, |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 377 | payload := { |
| 378 | reset_req := { |
| 379 | reset_type := rst_type, |
| 380 | padding := '000000'O |
| 381 | } |
| 382 | } |
| 383 | }; |
| 384 | |
| 385 | /* for generating FBSB_REQ */ |
| 386 | template L1ctlUlMessage t_L1CTL_FBSB_REQ(template Arfcn arfcn, template L1ctlFbsbFlags flags, uint8_t sync_info_idx, L1ctlCcchMode ccch_mode, GsmRxLev rxlev_exp) := { |
| 387 | header := t_L1ctlHeader(L1CTL_FBSB_REQ), |
| 388 | ul_info := omit, |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 389 | ul_info_tbf := omit, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 390 | ul_info_abs := omit, |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 391 | payload := { |
| 392 | fbsb_req := { |
| 393 | arfcn := arfcn, |
Harald Welte | a82f7e6 | 2018-02-22 18:51:33 +0100 | [diff] [blame] | 394 | timeout_tdma_frames := 250, /* about 1s */ |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 395 | freq_err_thresh1 := 10000, |
| 396 | freq_err_thresh2 := 800, |
| 397 | num_freqerr_avg := 3, |
| 398 | flags := flags, |
| 399 | sync_info_idx := sync_info_idx, |
| 400 | ccch_mode := ccch_mode, |
| 401 | rxlev_exp := rxlev_exp |
| 402 | } |
| 403 | } |
| 404 | }; |
| 405 | |
| 406 | /* for matching against incoming FBSB_CONF */ |
| 407 | template L1ctlDlMessage t_L1CTL_FBSB_CONF(template uint8_t result) := { |
| 408 | header := t_L1ctlHeader(L1CTL_FBSB_CONF), |
| 409 | dl_info := ?, |
| 410 | payload := { |
| 411 | fbsb_conf := { |
| 412 | initial_freq_err := ?, |
| 413 | result := result, |
| 414 | bsic := ? |
| 415 | } |
| 416 | } |
| 417 | }; |
| 418 | |
| 419 | template L1ctlUlMessage t_L1CTL_RACH_REQ(uint8_t ra, uint8_t combined, uint16_t offset) := { |
| 420 | header := t_L1ctlHeader(L1CTL_RACH_REQ), |
| 421 | ul_info := { |
| 422 | chan_nr := t_RslChanNr_RACH(0), |
| 423 | link_id := ts_RslLinkID_DCCH(0), |
| 424 | padding := '0000'O |
| 425 | }, |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 426 | ul_info_tbf := omit, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 427 | ul_info_abs := omit, |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 428 | payload := { |
| 429 | rach_req := { |
| 430 | ra := ra, |
| 431 | combined := combined, |
| 432 | offset := offset |
| 433 | } |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | template L1ctlUlMessage t_L1CTL_DM_EST_REQ(Arfcn arfcn, RslChannelNr chan_nr, GsmTsc tsc) := { |
| 438 | header := t_L1ctlHeader(L1CTL_DM_EST_REQ), |
| 439 | ul_info := { |
| 440 | chan_nr := chan_nr, |
| 441 | link_id := ts_RslLinkID_DCCH(0), |
| 442 | padding := '0000'O |
| 443 | }, |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 444 | ul_info_tbf := omit, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 445 | ul_info_abs := omit, |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 446 | payload := { |
| 447 | dm_est_req := { |
| 448 | tsc := tsc, |
| 449 | h := 0, |
| 450 | arfcn := arfcn, |
| 451 | hopping := omit, |
| 452 | tch_mode := 0, |
| 453 | audio_mode := t_L1CTL_AudioModeNone |
| 454 | } |
| 455 | } |
| 456 | } |
| 457 | |
| 458 | template L1ctlUlMessage t_L1CTL_DM_REL_REQ(RslChannelNr chan_nr) := { |
Harald Welte | 143edbd | 2017-07-17 20:55:42 +0200 | [diff] [blame] | 459 | header := t_L1ctlHeader(L1CTL_DM_REL_REQ), |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 460 | ul_info := { |
| 461 | chan_nr := chan_nr, |
| 462 | link_id := ts_RslLinkID_DCCH(0), |
| 463 | padding := '0000'O |
| 464 | }, |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 465 | ul_info_tbf := omit, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 466 | ul_info_abs := omit, |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 467 | payload := { |
| 468 | other := ''O |
| 469 | } |
| 470 | } |
| 471 | |
| 472 | template L1ctlUlMessage t_L1CTL_DATA_REQ(template RslChannelNr chan_nr, template RslLinkId link_id, octetstring l2_data) := { |
| 473 | header := t_L1ctlHeader(L1CTL_DATA_REQ), |
| 474 | ul_info := { |
| 475 | chan_nr := chan_nr, |
| 476 | link_id := link_id, |
| 477 | padding := '0000'O |
| 478 | }, |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 479 | ul_info_tbf := omit, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 480 | ul_info_abs := omit, |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 481 | payload := { |
| 482 | other := l2_data |
| 483 | } |
| 484 | } |
| 485 | |
Harald Welte | 00d4dac | 2017-07-30 00:50:32 +0200 | [diff] [blame] | 486 | template L1ctlUlMessage t_L1CTL_TBF_CFG_REQ(boolean is_uplink, TfiUsfArr tfi_usf) := { |
| 487 | header := t_L1ctlHeader(L1CTL_TBF_CFG_REQ), |
| 488 | ul_info := omit, |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 489 | ul_info_tbf := omit, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 490 | ul_info_abs := omit, |
Harald Welte | 00d4dac | 2017-07-30 00:50:32 +0200 | [diff] [blame] | 491 | payload := { |
| 492 | tbf_cfg_req := { |
| 493 | tbf_nr := 0, |
| 494 | is_uplink := is_uplink, |
| 495 | padding := '0000'O, |
| 496 | tfi_usf := tfi_usf |
| 497 | } |
| 498 | } |
| 499 | }; |
| 500 | |
| 501 | template L1ctlDlMessage t_L1CTL_TBF_CFG_CONF(template boolean is_uplink) := { |
| 502 | header := t_L1ctlHeader(L1CTL_TBF_CFG_CONF), |
| 503 | dl_info := omit, |
| 504 | payload := { |
| 505 | tbf_cfg_conf := { |
| 506 | tbf_nr := 0, |
| 507 | is_uplink := is_uplink, |
| 508 | padding := ?, |
| 509 | tfi_usf := ? |
| 510 | } |
| 511 | } |
| 512 | }; |
| 513 | |
Harald Welte | 1dcc371 | 2017-08-01 00:05:52 +0200 | [diff] [blame] | 514 | template L1ctlUlMessage t_L1CTL_DATA_TBF_REQ(octetstring l2_data, L1ctlGprsCs cs := L1CTL_CS1, uint8_t tbf_nr := 0) := { |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 515 | header := t_L1ctlHeader(L1CTL_DATA_TBF_REQ), |
| 516 | ul_info := omit, |
| 517 | ul_info_tbf := { |
| 518 | tbf_nr := tbf_nr, |
Harald Welte | 1dcc371 | 2017-08-01 00:05:52 +0200 | [diff] [blame] | 519 | cs := cs, |
| 520 | padding := '0000'O |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 521 | }, |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 522 | ul_info_abs := omit, |
Harald Welte | b3c226e | 2017-07-30 17:18:01 +0200 | [diff] [blame] | 523 | payload := { |
| 524 | other := l2_data |
| 525 | } |
| 526 | } |
| 527 | |
Harald Welte | 3a40ec7 | 2018-03-02 20:45:04 +0100 | [diff] [blame] | 528 | template L1ctlUlMessage t_L1CTL_DATA_ABS_REQ(octetstring l2_data, Arfcn arfcn, |
| 529 | uint8_t ts, GsmFrameNumber fn, |
| 530 | L1ctlGprsCs cs := L1CTL_CS1, |
| 531 | uint8_t tbf_nr := 0) := { |
| 532 | header := t_L1ctlHeader(L1CTL_DATA_ABS_REQ), |
| 533 | ul_info := omit, |
| 534 | ul_info_tbf := omit, |
| 535 | ul_info_abs := { |
| 536 | tbf_nr := tbf_nr, |
| 537 | cs := cs, |
| 538 | ts_nr := ts, |
| 539 | padding := '00'O, |
| 540 | fn := fn, |
| 541 | arfcn := arfcn, |
| 542 | padding2 := '0000'O |
| 543 | }, |
| 544 | payload := { |
| 545 | other := l2_data |
| 546 | } |
| 547 | } |
| 548 | |
| 549 | |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 550 | /* for matching against incoming RACH_CONF */ |
| 551 | template L1ctlDlMessage t_L1CTL_RACH_CONF := { |
| 552 | header := t_L1ctlHeader(L1CTL_RACH_CONF), |
| 553 | dl_info := ?, |
| 554 | payload := ? |
| 555 | }; |
| 556 | |
Harald Welte | ce6dc44 | 2018-02-21 22:00:21 +0100 | [diff] [blame] | 557 | /* for matching against incoming DATA_IND */ |
| 558 | template L1ctlDlMessage t_L1CTL_DATA_IND(template RslChannelNr chan_nr, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 559 | template RslLinkId link_id := ?, |
| 560 | template octetstring l2_data := ?) := { |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 561 | header := t_L1ctlHeader(L1CTL_DATA_IND), |
| 562 | dl_info := { |
| 563 | chan_nr := chan_nr, |
Harald Welte | ce6dc44 | 2018-02-21 22:00:21 +0100 | [diff] [blame] | 564 | link_id := link_id, |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 565 | arfcn := ?, |
| 566 | frame_nr := ?, |
| 567 | rx_level := ?, |
| 568 | snr := ?, |
| 569 | num_biterr := ?, |
| 570 | fire_crc := ? |
| 571 | }, |
| 572 | payload := { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 573 | data_ind := { |
| 574 | payload := l2_data |
| 575 | } |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 576 | } |
| 577 | }; |
| 578 | |
Harald Welte | 88849c6 | 2017-07-30 17:19:41 +0200 | [diff] [blame] | 579 | template ImmediateAssignment t_IMM_ASS(uint8_t ra, GsmFrameNumber fn) := { |
| 580 | ded_or_tbf := ?, |
| 581 | page_mode := ?, |
| 582 | chan_desc := *, |
| 583 | pkt_chan_desc := *, |
| 584 | req_ref := f_compute_ReqRef(ra, fn), |
| 585 | timing_advance := ?, |
| 586 | mobile_allocation := ?, |
| 587 | rest_octets:= ? |
| 588 | }; |
| 589 | |
| 590 | template GsmRrMessage t_RR_IMM_ASS(uint8_t ra, GsmFrameNumber fn) := { |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 591 | header := t_RrHeader(IMMEDIATE_ASSIGNMENT, ?), |
| 592 | payload := { |
Harald Welte | 88849c6 | 2017-07-30 17:19:41 +0200 | [diff] [blame] | 593 | imm_ass := t_IMM_ASS(ra, fn) |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 594 | } |
| 595 | }; |
| 596 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 597 | const octetstring c_DummyUI := '0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O; |
| 598 | |
Harald Welte | 7024baa | 2018-03-02 23:37:51 +0100 | [diff] [blame] | 599 | /* We use "BYTEORDER(last)" so we get little-endian integers. Unfortuantely, this also |
| 600 | 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] | 601 | } with { encode "RAW" }; |