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; |
| 8 | import from Osmocom_Types all; |
| 9 | |
| 10 | type enumerated L1ctlMsgType { |
| 11 | L1CTL_NONE, |
| 12 | L1CTL_FBSB_REQ, |
| 13 | L1CTL_FBSB_CONF, |
| 14 | L1CTL_DATA_IND, |
| 15 | L1CTL_RACH_REQ, |
| 16 | L1CTL_DM_EST_REQ, |
| 17 | L1CTL_DATA_REQ, |
| 18 | L1CTL_RESET_IND, |
| 19 | L1CTL_PM_REQ, /* power measurement */ |
| 20 | L1CTL_PM_CONF, /* power measurement */ |
| 21 | L1CTL_ECHO_REQ, |
| 22 | L1CTL_ECHO_CONF, |
| 23 | L1CTL_RACH_CONF, |
| 24 | L1CTL_RESET_REQ, |
| 25 | L1CTL_RESET_CONF, |
| 26 | L1CTL_DATA_CONF, |
| 27 | L1CTL_CCCH_MODE_REQ, |
| 28 | L1CTL_CCCH_MODE_CONF, |
| 29 | L1CTL_DM_REL_REQ, |
| 30 | L1CTL_PARAM_REQ, |
| 31 | L1CTL_DM_FREQ_REQ, |
| 32 | L1CTL_CRYPTO_REQ, |
| 33 | L1CTL_SIM_REQ, |
| 34 | L1CTL_SIM_CONF, |
| 35 | L1CTL_TCH_MODE_REQ, |
| 36 | L1CTL_TCH_MODE_CONF, |
| 37 | L1CTL_NEIGH_PM_REQ, |
| 38 | L1CTL_NEIGH_PM_IND, |
| 39 | L1CTL_TRAFFIC_REQ, |
| 40 | L1CTL_TRAFFIC_CONF, |
| 41 | L1CTL_TRAFFIC_IND |
| 42 | } with { variant "FIELDLENGTH(8)" }; |
| 43 | |
| 44 | type enumerated L1ctlCcchMode { |
| 45 | CCCH_MODE_NONE (0), |
| 46 | CCCH_MODE_NON_COMBINED, |
| 47 | CCCH_MODE_COMBINED |
| 48 | } with { variant "FIELDLENGTH(8)" }; |
| 49 | |
| 50 | type enumerated L1ctlNeighMode { |
| 51 | NEIGH_MODE_NONE (0), |
| 52 | NEIGH_MODE_PM, |
| 53 | NEIGH_MODE_SB |
| 54 | } with { variant "FIELDLENGTH(8)" }; |
| 55 | |
| 56 | type enumerated L1ctlResetType { |
| 57 | L1CTL_RES_T_BOOT (0), |
| 58 | L1CTL_RES_T_FULL, |
| 59 | L1CTL_RES_T_SCHED |
| 60 | } with { variant "FIELDLENGTH(8)" }; |
| 61 | |
| 62 | const integer TRAFFIC_DATA_LEN := 40; |
| 63 | |
| 64 | type record L1ctlHdrFlags { |
| 65 | BIT7 padding, |
| 66 | boolean f_done |
| 67 | } with { variant "" }; |
| 68 | |
| 69 | type record L1ctlHeader { |
| 70 | L1ctlMsgType msg_type, |
| 71 | L1ctlHdrFlags flags, |
| 72 | OCT2 padding |
| 73 | } with { variant "" }; |
| 74 | |
| 75 | type uint8_t RslChanNr; |
| 76 | type uint8_t RslLinkId; |
| 77 | |
| 78 | type record L1ctlDlInfo { |
| 79 | RslChanNr chan_nr, |
| 80 | RslLinkId link_id, |
| 81 | Arfcn arfcn, |
| 82 | GsmFrameNumber frame_nr, |
| 83 | GsmRxLev rx_level, |
| 84 | uint8_t snr, |
| 85 | uint8_t num_biterr, |
| 86 | uint8_t fire_crc |
| 87 | } with { variant "" }; |
| 88 | |
| 89 | type record L1ctlFbsbConf { |
| 90 | int16_t initial_freq_err, |
| 91 | uint8_t result, |
| 92 | uint8_t bsic |
| 93 | } with { variant "" }; |
| 94 | |
| 95 | type record L1ctlCcchModeConf { |
| 96 | L1ctlCcchMode ccch_mode, |
| 97 | OCT3 padding |
| 98 | } with { variant "" }; |
| 99 | |
| 100 | /* gsm48_chan_mode */ |
| 101 | type uint8_t L1ctlTchMode; |
| 102 | |
| 103 | type record L1ctlAudioMode { |
| 104 | BIT4 padding, |
| 105 | boolean tx_microphone, |
| 106 | boolean tx_traffic_req, |
| 107 | boolean rx_speaker, |
| 108 | boolean rx_traffic_ind |
| 109 | } with { variant "" }; |
| 110 | |
| 111 | type record L1ctlTchModeConf { |
| 112 | L1ctlTchMode tch_mode, |
| 113 | L1ctlAudioMode audio_mode, |
| 114 | OCT2 padding |
| 115 | } with { variant "" }; |
| 116 | |
| 117 | type record L1ctlDataInd { |
| 118 | octetstring payload length(23) |
| 119 | } with { variant "" }; |
| 120 | |
| 121 | type union L1ctlDlPayload { |
| 122 | L1ctlFbsbConf fbsb_conf, |
| 123 | L1ctlCcchModeConf ccch_mode_conf, |
| 124 | L1ctlTchModeConf tch_mode_conf, |
| 125 | L1ctlDataInd data_ind, |
| 126 | L1ctlTrafficReq traffic_ind, |
| 127 | octetstring other |
| 128 | } with { variant "" }; |
| 129 | |
| 130 | type record L1ctlDlMessage { |
| 131 | L1ctlHeader header, |
| 132 | L1ctlDlInfo dl_info optional, |
| 133 | L1ctlDlPayload payload |
| 134 | } with { variant (dl_info) "PRESENCE(header.msg_type = L1CTL_FBSB_CONF, |
| 135 | header.msg_type = L1CTL_RACH_CONF, |
| 136 | header.msg_type = L1CTL_DATA_IND, |
| 137 | header.msg_type = L1CTL_DATA_CONF, |
| 138 | header.msg_type = L1CTL_TRAFFIC_IND)" |
| 139 | variant (payload) "CROSSTAG(fbsb_conf, header.msg_type = L1CTL_FBSB_CONF; |
| 140 | ccch_mode_conf, header.msg_type = L1CTL_CCCH_MODE_CONF; |
| 141 | tch_mode_conf, header.msg_type = L1CTL_TCH_MODE_CONF; |
| 142 | data_ind, header.msg_type = L1CTL_DATA_IND; |
| 143 | traffic_ind, header.msg_type = L1CTL_TRAFFIC_IND; |
| 144 | other, OTHERWISE; |
| 145 | )" }; |
| 146 | |
| 147 | external function enc_L1ctlDlMessage(in L1ctlDlMessage msg) return octetstring |
| 148 | with { extension "prototype(convert) encode(RAW)" }; |
| 149 | external function dec_L1ctlDlMessage(in octetstring stream) return L1ctlDlMessage |
| 150 | with { extension "prototype(convert) decode(RAW)" }; |
| 151 | |
| 152 | |
| 153 | type record L1ctlUlInfo { |
| 154 | RslChanNr chan_nr, |
| 155 | RslLinkId link_id, |
| 156 | OCT2 padding |
| 157 | } with { variant "" }; |
| 158 | |
| 159 | type record L1ctlFbsbFlags { |
| 160 | BIT5 padding, |
| 161 | boolean sb, |
| 162 | boolean fb1, |
| 163 | boolean fb0 |
| 164 | } with { variant "" }; |
| 165 | |
| 166 | type record L1ctlFbsbReq { |
| 167 | Arfcn arfcn, |
| 168 | uint16_t timeout_tdma_frames, |
| 169 | uint16_t freq_err_thresh1, |
| 170 | uint16_t freq_err_thresh2, |
| 171 | uint8_t num_freqerr_avg, |
| 172 | L1ctlFbsbFlags flags, |
| 173 | uint8_t sync_info_idx, |
| 174 | L1ctlCcchMode ccch_mode, |
| 175 | GsmRxLev rxlev_exp |
| 176 | } with { variant "" }; |
| 177 | |
| 178 | type record L1ctlCcchModeReq { |
| 179 | L1ctlTchMode tch_mode, |
| 180 | L1ctlAudioMode audio_mode, |
| 181 | OCT2 padding |
| 182 | } with { variant "" }; |
| 183 | |
| 184 | type record L1ctlTchModeReq { |
| 185 | L1ctlTchMode tch_mode, |
| 186 | L1ctlAudioMode audio_mode, |
| 187 | OCT2 padding |
| 188 | } with { variant "" }; |
| 189 | |
| 190 | type record L1ctlRachReq { |
| 191 | uint8_t ra, |
| 192 | uint8_t combined, |
| 193 | uint16_t offset |
| 194 | } with { variant "" }; |
| 195 | |
| 196 | type record L1ctlParReq { |
| 197 | int8_t ta, |
| 198 | uint8_t tx_power, |
| 199 | OCT2 padding |
| 200 | } with { variant "" }; |
| 201 | |
| 202 | type record L1ctlH1 { |
| 203 | uint8_t hsn, |
| 204 | uint8_t maio, |
| 205 | uint8_t n, |
| 206 | OCT1 padding, |
| 207 | bitstring ma length(64) |
| 208 | } with { variant "" }; |
| 209 | |
| 210 | type record L1ctlDmEstReq { |
| 211 | GsmTsc tsc, |
| 212 | uint8_t h, |
| 213 | Arfcn arfcn optional, |
| 214 | L1ctlH1 hopping optional, |
| 215 | L1ctlTchMode tch_mode, |
| 216 | L1ctlAudioMode audio_mode |
| 217 | } with { variant (arfcn) "PRESENCE(h = 0)" |
| 218 | variant (hopping) "PRESENCE(h = 1)" }; |
| 219 | |
| 220 | type record L1ctlReset { |
| 221 | L1ctlResetType reset_type, |
| 222 | OCT3 padding |
| 223 | } with { variant "" }; |
| 224 | |
| 225 | |
| 226 | type record L1ctlTrafficReq { |
| 227 | octetstring data length(TRAFFIC_DATA_LEN) |
| 228 | } with { variant "" }; |
| 229 | |
| 230 | type union L1ctlUlPayload { |
| 231 | L1ctlFbsbReq fbsb_req, |
| 232 | L1ctlCcchModeReq ccch_mode_req, |
| 233 | L1ctlTchModeReq tch_mode_req, |
| 234 | L1ctlRachReq rach_req, |
| 235 | L1ctlParReq par_req, |
| 236 | L1ctlDmEstReq dm_est_req, |
| 237 | L1ctlReset reset_req, |
| 238 | //L1ctlNeighPmReq neigh_pm_req, |
| 239 | L1ctlTrafficReq traffic_req, |
| 240 | octetstring other |
| 241 | } with { variant "" }; |
| 242 | |
| 243 | type record L1ctlUlMessage { |
| 244 | L1ctlHeader header, |
| 245 | L1ctlUlInfo ul_info optional, |
| 246 | L1ctlUlPayload payload |
| 247 | } with { variant (ul_info) "PRESENCE(header.msg_type = L1CTL_RACH_REQ, |
| 248 | header.msg_type = L1CTL_PARAM_REQ, |
| 249 | header.msg_type = L1CTL_CRYPTO_REQ, |
| 250 | header.msg_type = L1CTL_DATA_REQ, |
| 251 | header.msg_type = L1CTL_DM_EST_REQ, |
| 252 | header.msg_type = L1CTL_DM_FREQ_REQ, |
| 253 | header.msg_type = L1CTL_DM_REL_REQ, |
| 254 | header.msg_type = L1CTL_TRAFFIC_REQ)" |
| 255 | variant (payload) "CROSSTAG(fbsb_req, header.msg_type = L1CTL_FBSB_REQ; |
| 256 | ccch_mode_req, header.msg_type = L1CTL_CCCH_MODE_REQ; |
| 257 | tch_mode_req, header.msg_type = L1CTL_TCH_MODE_REQ; |
| 258 | rach_req, header.msg_type = L1CTL_RACH_REQ; |
| 259 | par_req, header.msg_type = L1CTL_PARAM_REQ; |
| 260 | dm_est_req, header.msg_type = L1CTL_DM_EST_REQ; |
| 261 | reset_req, header.msg_type = L1CTL_RESET_REQ; |
| 262 | traffic_req, header.msg_type = L1CTL_TRAFFIC_REQ; |
| 263 | other, OTHERWISE; |
| 264 | )" }; |
| 265 | |
| 266 | external function enc_L1ctlUlMessage(in L1ctlUlMessage msg) return octetstring |
| 267 | with { extension "prototype(convert) encode(RAW)" }; |
| 268 | external function dec_L1ctlUlMessage(in octetstring stream) return L1ctlUlMessage |
| 269 | with { extension "prototype(convert) decode(RAW)" }; |
| 270 | |
| 271 | } with { encode "RAW" }; |