Harald Welte | c676c68 | 2017-12-24 20:38:20 +0100 | [diff] [blame] | 1 | module IuUP_Types { |
| 2 | |
Harald Welte | 35bb716 | 2018-01-03 21:07:52 +0100 | [diff] [blame] | 3 | /* Definition of abstract types for the IuUP protocol as specified in |
| 4 | * 3GPP TS 25.415. Uses the TITAN "RAW" codec to auto-generate encoder/decoder |
| 5 | * functions. |
| 6 | * |
| 7 | * (C) 2017 by Harald Welte <laforge@gnumonks.org> |
| 8 | * All rights reserved. |
| 9 | * |
| 10 | * Released under the terms of GNU General Public License, Version 2 or |
| 11 | * (at your option) any later version. |
| 12 | */ |
| 13 | |
Harald Welte | c676c68 | 2017-12-24 20:38:20 +0100 | [diff] [blame] | 14 | import from Osmocom_Types all; |
| 15 | import from General_Types all; |
| 16 | |
| 17 | /* See TS 25.415 6.6.3.1 */ |
| 18 | type uint4_t IuUP_PDU_Type; |
| 19 | |
| 20 | /* See TS 25.415 6.6.3.2 */ |
| 21 | type enumerated IuUP_AckNack { |
| 22 | IuUP_ACKNACK_CTRL (0), |
| 23 | IuUP_ACKNACK_ACK (1), |
| 24 | IuUP_ACKNACK_NACK (2), |
| 25 | IuUP_ACKNACK_RESERVED (3) |
| 26 | } with { variant "FIELDLENGTH(2)" }; |
| 27 | |
| 28 | /* See TS 25.415 6.6.3.3 */ |
| 29 | type uint4_t IuUP_FrameNr; |
| 30 | |
| 31 | /* See TS 25.415 6.6.3.5 */ |
| 32 | type enumerated IuUP_FQC { |
| 33 | IuUP_FQC_GOOD (0), |
| 34 | IuUP_FQC_BAD (1), |
| 35 | IuUP_FQC_BAD_RADIO (2), |
| 36 | IuUP_FQC_SPARE (3) |
| 37 | } with { variant "FIELDLENGTH(2)" }; |
| 38 | |
| 39 | /* See TS 25.415 6.6.3.6 */ |
| 40 | type uint6_t IuUP_RFCI; |
| 41 | |
| 42 | /* See TS 25.415 6.6.3.7 */ |
| 43 | type enumerated IuUP_ProcedureIndicator { |
| 44 | IuUP_PRI_INITIALIZATION (0), |
| 45 | IuUP_PRI_RATE_CONTROL (1), |
| 46 | IuUP_PRI_TIME_ALIGNMENT (2), |
| 47 | IuUP_PRI_ERROR_EVENT (3) |
| 48 | /* reserved */ |
| 49 | } with { variant "FIELDLENGTH(4)" }; |
| 50 | |
| 51 | /* See TS 25.415 6.6.3.13 */ |
| 52 | type uint6_t IuUP_NumOfRfciInd; |
| 53 | |
| 54 | /* See TS 25.415 6.6.3.15 */ |
| 55 | type enumerated IuUP_ErrorDistance { |
| 56 | IuUP_ERR_DIST_LOCAL (0), |
| 57 | IuUP_ERR_DIST_FIRST_FW (1), |
| 58 | IuUP_ERR_DIST_SECOND_FW (2), |
| 59 | IuUP_ERR_DIST_RESERVED (3) |
| 60 | } with { variant "FIELDLENGTH(2)" }; |
| 61 | |
| 62 | /* See TS 25.415 6.6.3.16 */ |
| 63 | type enumerated IuUP_ErrorCause { |
| 64 | /* Syntactical protocol errors */ |
| 65 | IuUP_CAUSE_CRC_ERROR_HEADER (0), |
| 66 | IuUP_CAUSE_CRC_ERROR_PAYLOAD (1), |
| 67 | IuUP_CAUSE_UNEXP_FRAME_NR (2), |
| 68 | IuUP_CAUSE_FRAME_LOSS (3), |
| 69 | IuUP_CAUSE_PDU_TYPE_UNKNOWN (4), |
| 70 | IuUP_CAUSE_UNKNOWN_PROCEDURE (5), |
| 71 | IuUP_CAUSE_UNKNOWN_RES_VAL (6), |
| 72 | IuUP_CAUSE_UNKNOWN_FIELD (7), |
| 73 | IuUP_CAUSE_FRAME_TOO_SHORT (8), |
| 74 | IuUP_CAUSE_MISSING_FIELD (9), |
| 75 | /* Semantical protocol errors */ |
| 76 | IuUP_CAUSE_UNEXPECTED_PDU_TYPE (16), |
| 77 | IuUP_CAUSE_UNEXPECTED_PROCEDURE (18), |
| 78 | IuUP_CAUSE_UNEXPECTED_RFCI (19), |
| 79 | IuUP_CAUSE_UNEXPECTED_VALUE (20), |
| 80 | /* Other Errors */ |
| 81 | IuUP_CAUSE_INIT_FAIL (42), |
| 82 | IuUP_CAUSE_INIT_FAIL_NET_TMR_EXP (43), |
| 83 | IuUP_CAUSE_INIT_FAIL_FERR_REP_NACK (44), |
| 84 | IuUP_CAUSE_RATE_CONTROL_FAIL (45), |
| 85 | IuUP_CAUSE_ERROR_EVENT_FAIL (46), |
| 86 | IuUP_CAUSE_TIME_ALIGN_NOTSUPP (47), |
| 87 | IuUP_CAUSE_REQ_ALIGN_NOTPOSS (48), |
| 88 | IuUP_CAUSE_IU_UP_VERS_NOTSUPP (49) |
| 89 | } with { variant "FIELDLENGTH(6)" }; |
| 90 | |
| 91 | /* See TS 25.415 6.6.3.18 */ |
| 92 | type uint8_t IuUP_TimeAlignment; |
| 93 | |
| 94 | |
| 95 | /* See TS 25.415 6.6.2.1 */ |
| 96 | type record IuUP_PDU_Type_0 { |
| 97 | IuUP_PDU_Type pdu_type, /* 0 */ |
| 98 | IuUP_FrameNr frame_nr, |
| 99 | IuUP_FQC fqc, |
| 100 | IuUP_RFCI rfci, |
| 101 | uint6_t header_crc, |
| 102 | uint10_t payload_crc, |
| 103 | octetstring payload |
| 104 | }; |
| 105 | |
| 106 | /* See TS 25.415 6.6.2.2 */ |
| 107 | type record IuUP_PDU_Type_1 { |
| 108 | IuUP_PDU_Type pdu_type, /* 1 */ |
| 109 | IuUP_FrameNr frame_nr, |
| 110 | IuUP_FQC fqc, |
| 111 | IuUP_RFCI rfci, |
| 112 | uint6_t header_crc, |
| 113 | BIT2 spare, |
| 114 | octetstring payload |
| 115 | }; |
| 116 | |
| 117 | /* See TS 25.415 6.6.6.2.3 */ |
| 118 | type record IuUP_PDU_Type_14 { |
| 119 | IuUP_PDU_Type pdu_type, |
| 120 | IuUP_AckNack ack_nack, |
| 121 | uint2_t frame_nr, |
| 122 | uint4_t iuup_version, |
| 123 | IuUP_ProcedureIndicator procedure_ind, |
| 124 | uint6_t header_crc, |
| 125 | uint10_t payload_crc, |
| 126 | IuUP_PDU14_Union u |
| 127 | } with { variant (u) "CROSSTAG( proc_sending, ack_nack=IuUP_ACKNACK_CTRL; |
| 128 | ack, ack_nack=IuUP_ACKNACK_ACK; |
| 129 | nack, ack_nack=IuUP_ACKNACK_NACK)" |
| 130 | }; |
| 131 | |
| 132 | /* 6.6.2.3.1 Figure 21 */ |
| 133 | type record IuUP_PDU14_ProcSending { |
| 134 | octetstring payload |
| 135 | }; |
| 136 | |
| 137 | /* 6.6.2.3.2 Figure 22 */ |
| 138 | type record IuUP_PDU14_ACK { |
| 139 | octetstring spare_ext optional |
| 140 | }; |
| 141 | |
| 142 | /* 6.6.2.3.3 Figure 23 */ |
| 143 | type record IuUP_PDU14_NACK { |
| 144 | IuUP_ErrorCause err_cause, |
| 145 | BIT2 spare, |
| 146 | octetstring spare_ext optional |
| 147 | }; |
| 148 | |
| 149 | type union IuUP_PDU14_Union { |
| 150 | IuUP_PDU14_ProcSending proc_sending, |
| 151 | IuUP_PDU14_ACK ack, |
| 152 | IuUP_PDU14_NACK nack |
| 153 | }; |
| 154 | |
| 155 | type union IuUP_PDU14_ProcSendingUnion { |
| 156 | IuUP_PDU14_ProcSending_INIT init, |
| 157 | IuUP_PDU14_ProcSending_RATE_CTRL rate_ctrl, |
| 158 | IuUP_PDU14_ProcSending_RATE_CTRL rate_ctrl_ack, |
| 159 | IuUP_PDU14_ProcSending_TIME_ALIGNMENT time_alignment, |
| 160 | IuUP_PDU14_ProcSending_ERROR_EVENT error_event |
| 161 | }; |
| 162 | |
| 163 | /* 6.6.2.3.4.1 Initialisation */ |
| 164 | type record IuUP_PDU14_ProcSending_INIT { |
| 165 | BIT3 spare, |
| 166 | boolean ti, |
| 167 | uint3_t subflows_per_rfci, |
| 168 | boolean chain_ind, |
| 169 | |
| 170 | /* FIXME: Further decode */ |
| 171 | octetstring payload |
| 172 | }; |
| 173 | type record IuUP_InitRfci { |
| 174 | boolean lri, |
| 175 | boolean li, |
| 176 | IuUP_RFCI rfci, |
| 177 | RecOfU8 len8 optional, |
| 178 | RecOfU16 len16 optional |
| 179 | } with { variant (len8) "PRESENCE(li=false)"; |
| 180 | variant (len16) "PRESENCE(li=true)" |
| 181 | }; |
| 182 | type record of uint8_t RecOfU8; |
| 183 | type record of uint16_t RecOfU16; |
| 184 | |
| 185 | /* 6.6.2.3.4.2.1 Rate Control procedure */ |
| 186 | type record IuUP_PDU14_ProcSending_RATE_CTRL { |
| 187 | BIT2 spare, |
| 188 | uint6_t nr_of_rfci_ind, |
| 189 | bitstring rfci_ind |
| 190 | } with { variant (nr_of_rfci_ind) "LENGTHTO(rfci_ind)" |
| 191 | variant (nr_of_rfci_ind) "UNIT(bits)" |
| 192 | }; |
| 193 | |
| 194 | /* 6.6.2.3.4.3 Time Alignment */ |
| 195 | type record IuUP_PDU14_ProcSending_TIME_ALIGNMENT { |
| 196 | uint8_t time_alignment, |
| 197 | octetstring spare optional |
| 198 | }; |
| 199 | |
| 200 | /* 6.6.2.3.4.4 Error Event */ |
| 201 | type record IuUP_PDU14_ProcSending_ERROR_EVENT { |
| 202 | IuUP_ErrorDistance distance, |
| 203 | IuUP_ErrorCause cause |
| 204 | }; |
| 205 | |
| 206 | |
| 207 | type union IuUP_PDU { |
| 208 | IuUP_PDU_Type_0 type_0, |
| 209 | IuUP_PDU_Type_1 type_1, |
| 210 | IuUP_PDU_Type_14 type_14 |
| 211 | } with { variant "TAG( type_0, pdu_type = 0; |
| 212 | type_1, pdu_type = 1; |
| 213 | type_14, pdu_type = 14;)" }; |
| 214 | |
| 215 | /* hand-written C++ functions */ |
| 216 | external function f_enc_IuUP_PDU(in IuUP_PDU msg) return octetstring; |
| 217 | external function f_IuUP_compute_crc_header(in octetstring inp) return uint6_t; |
| 218 | external function f_IuUP_compute_crc_payload(in octetstring inp) return uint10_t; |
| 219 | |
| 220 | /* auto-generated */ |
| 221 | external function dec_IuUP_PDU(in octetstring stream) return IuUP_PDU |
| 222 | with { extension "prototype(convert) decode(RAW)" }; |
| 223 | |
| 224 | template IuUP_PDU ts_IuUP_INIT_ACK(uint2_t frame_nr, uint4_t version) := { |
| 225 | type_14 := { |
| 226 | pdu_type := 14, |
| 227 | ack_nack := IuUP_ACKNACK_ACK, |
| 228 | frame_nr := frame_nr, |
| 229 | iuup_version := version, |
| 230 | procedure_ind := IuUP_PRI_INITIALIZATION, |
| 231 | header_crc := 0, |
| 232 | payload_crc := 0, |
| 233 | u := { |
| 234 | ack := { |
| 235 | spare_ext := omit |
| 236 | } |
| 237 | } |
| 238 | } |
| 239 | }; |
| 240 | |
| 241 | template IuUP_PDU tr_IuUP_INIT_ACK(template uint2_t frame_nr := ?, template uint4_t version := ?) := { |
| 242 | type_14 := { |
| 243 | pdu_type := 14, |
| 244 | ack_nack := IuUP_ACKNACK_ACK, |
| 245 | frame_nr := frame_nr, |
| 246 | iuup_version := version, |
| 247 | procedure_ind := IuUP_PRI_INITIALIZATION, |
| 248 | header_crc := ?, |
| 249 | payload_crc := ?, |
| 250 | u := { |
| 251 | ack := { |
| 252 | spare_ext := omit |
| 253 | } |
| 254 | } |
| 255 | } |
| 256 | }; |
| 257 | |
| 258 | template IuUP_PDU ts_IuUP_INIT(octetstring payload, uint2_t frame_nr := 0, uint4_t version := 0) := { |
| 259 | type_14 := { |
| 260 | pdu_type := 14, |
| 261 | ack_nack := IuUP_ACKNACK_CTRL, |
| 262 | frame_nr := frame_nr, |
| 263 | iuup_version := version, |
| 264 | procedure_ind := IuUP_PRI_INITIALIZATION, |
| 265 | header_crc := 0, |
| 266 | payload_crc := 0, |
| 267 | u := { |
| 268 | proc_sending := { |
| 269 | payload := payload |
| 270 | } |
| 271 | } |
| 272 | } |
| 273 | }; |
| 274 | |
| 275 | template IuUP_PDU tr_IuUP_INIT(template octetstring payload := ?, template uint2_t frame_nr := ?, |
| 276 | template uint4_t version := ?) := { |
| 277 | type_14 := { |
| 278 | pdu_type := 14, |
| 279 | ack_nack := IuUP_ACKNACK_CTRL, |
| 280 | frame_nr := frame_nr, |
| 281 | iuup_version := version, |
| 282 | procedure_ind := IuUP_PRI_INITIALIZATION, |
| 283 | header_crc := ?, |
| 284 | payload_crc := ?, |
| 285 | u := { |
| 286 | proc_sending := { |
| 287 | payload := payload |
| 288 | } |
| 289 | } |
| 290 | } |
| 291 | }; |
| 292 | |
| 293 | |
| 294 | template IuUP_PDU ts_IuUP_Type0(IuUP_FrameNr frame_nr, IuUP_RFCI rfci, octetstring payload, |
| 295 | IuUP_FQC fqc := IuUP_FQC_GOOD) := { |
| 296 | type_0 := { |
| 297 | pdu_type := 0, |
| 298 | frame_nr := frame_nr, |
| 299 | fqc := fqc, |
| 300 | rfci := rfci, |
| 301 | header_crc := 0, |
| 302 | payload_crc := 0, |
| 303 | payload := payload |
| 304 | } |
| 305 | }; |
| 306 | |
| 307 | template IuUP_PDU tr_IuUP_Type0(template IuUP_FrameNr frame_nr := ?, template IuUP_RFCI rfci := ?, |
| 308 | template IuUP_FQC fqc := ?) := { |
| 309 | type_0 := { |
| 310 | pdu_type := 0, |
| 311 | frame_nr := frame_nr, |
| 312 | fqc := fqc, |
| 313 | rfci := rfci, |
| 314 | header_crc := ?, |
| 315 | payload_crc := ?, |
| 316 | payload := ? |
| 317 | } |
| 318 | }; |
| 319 | |
| 320 | template IuUP_PDU ts_IuUP_Type1(IuUP_FrameNr frame_nr, IuUP_RFCI rfci, octetstring payload, |
| 321 | IuUP_FQC fqc := IuUP_FQC_GOOD) := { |
| 322 | type_1 := { |
| 323 | pdu_type := 1, |
| 324 | frame_nr := frame_nr, |
| 325 | fqc := fqc, |
| 326 | rfci := rfci, |
| 327 | header_crc := 0, |
| 328 | spare := '00'B, |
| 329 | payload := payload |
| 330 | } |
| 331 | }; |
| 332 | |
| 333 | |
| 334 | template IuUP_PDU tr_IuUP_Type1(template IuUP_FrameNr frame_nr := ?, template IuUP_RFCI rfci := ?, |
| 335 | template IuUP_FQC fqc := ?) := { |
| 336 | type_1 := { |
| 337 | pdu_type := 1, |
| 338 | frame_nr := frame_nr, |
| 339 | fqc := fqc, |
| 340 | rfci := rfci, |
| 341 | header_crc := ?, |
| 342 | spare := ?, |
| 343 | payload := ? |
| 344 | } |
| 345 | }; |
| 346 | |
| 347 | |
| 348 | |
| 349 | } with { encode "RAW" ; variant "FIELDORDER(msb)" } |