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