Harald Welte | 9fe1f9f | 2018-11-29 13:47:39 +0100 | [diff] [blame] | 1 | #pragma once |
| 2 | /* Iu User Plane (IuUP) Definitions as per 3GPP TS 25.415 */ |
| 3 | /* (C) 2017 by Harald Welte <laforge@gnumonks.org> |
| 4 | * All Rights Reserved. |
| 5 | * |
| 6 | * SPDX-License-Identifier: GPL-2.0+ |
| 7 | */ |
| 8 | |
| 9 | #include <stdint.h> |
| 10 | #include <osmocom/core/endian.h> |
| 11 | |
| 12 | /* 3GPP TS 25.415 Section 6.6.2.1 */ |
| 13 | struct iuup_pdutype0_hdr { |
| 14 | #if OSMO_IS_LITTLE_ENDIAN |
| 15 | /* control part */ |
| 16 | uint8_t frame_nr:4, |
| 17 | pdu_type:4; |
| 18 | uint8_t rfci:6, |
| 19 | fqc:2; |
| 20 | /* checksum part */ |
| 21 | uint8_t payload_crc_hi:2, header_crc:6; |
| 22 | uint8_t payload_crc_lo; |
| 23 | |
| 24 | /* payload part */ |
| 25 | uint8_t payload[0]; |
| 26 | #elif OSMO_IS_BIG_ENDIAN |
Oliver Smith | 0b5c09b | 2023-02-17 10:35:38 +0100 | [diff] [blame] | 27 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */ |
Harald Welte | 9fe1f9f | 2018-11-29 13:47:39 +0100 | [diff] [blame] | 28 | uint8_t pdu_type:4, frame_nr:4; |
| 29 | uint8_t fqc:2, rfci:6; |
| 30 | uint8_t header_crc:6, payload_crc_hi:2; |
| 31 | uint8_t payload_crc_lo; |
| 32 | uint8_t payload[0]; |
| 33 | #endif |
| 34 | } __attribute__((packed)); |
| 35 | |
| 36 | /* 3GPP TS 25.415 Section 6.6.2.2 */ |
| 37 | struct iuup_pdutype1_hdr { |
| 38 | #if OSMO_IS_LITTLE_ENDIAN |
| 39 | /* control part */ |
| 40 | uint8_t frame_nr:4, |
| 41 | pdu_type:4; |
| 42 | uint8_t rfci:6, |
| 43 | fqc:2; |
| 44 | /* checksum part */ |
| 45 | uint8_t spare:2, |
| 46 | header_crc:6; |
| 47 | /* payload part */ |
| 48 | uint8_t payload[0]; |
| 49 | #elif OSMO_IS_BIG_ENDIAN |
Oliver Smith | 0b5c09b | 2023-02-17 10:35:38 +0100 | [diff] [blame] | 50 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */ |
Harald Welte | 9fe1f9f | 2018-11-29 13:47:39 +0100 | [diff] [blame] | 51 | uint8_t pdu_type:4, frame_nr:4; |
| 52 | uint8_t fqc:2, rfci:6; |
| 53 | uint8_t header_crc:6, spare:2; |
| 54 | uint8_t payload[0]; |
| 55 | #endif |
| 56 | } __attribute__((packed)); |
| 57 | |
| 58 | /* 3GPP TS 25.415 Section 6.6.2.3 */ |
| 59 | struct iuup_pdutype14_hdr { |
| 60 | #if OSMO_IS_LITTLE_ENDIAN |
| 61 | /* control part */ |
| 62 | uint8_t frame_nr:2, |
| 63 | ack_nack:2, |
| 64 | pdu_type:4; |
| 65 | uint8_t proc_ind:4, |
| 66 | mode_version:4; |
| 67 | /* checksum part */ |
| 68 | uint8_t payload_crc_hi:2, header_crc:6; |
| 69 | uint8_t payload_crc_lo; |
| 70 | /* payload part */ |
| 71 | uint8_t payload[0]; |
| 72 | #elif OSMO_IS_BIG_ENDIAN |
Oliver Smith | 0b5c09b | 2023-02-17 10:35:38 +0100 | [diff] [blame] | 73 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */ |
Harald Welte | 9fe1f9f | 2018-11-29 13:47:39 +0100 | [diff] [blame] | 74 | uint8_t pdu_type:4, ack_nack:2, frame_nr:2; |
| 75 | uint8_t mode_version:4, proc_ind:4; |
| 76 | uint8_t header_crc:6, payload_crc_hi:2; |
| 77 | uint8_t payload_crc_lo; |
| 78 | uint8_t payload[0]; |
| 79 | #endif |
| 80 | } __attribute__((packed)); |
| 81 | |
| 82 | /* 3GPP TS 25.415 Section 6.6.2.3.4.1 */ |
| 83 | struct iuup_ctrl_init_rfci_hdr { |
| 84 | #if OSMO_IS_LITTLE_ENDIAN |
| 85 | uint8_t rfci:6, |
| 86 | li:1, |
| 87 | lri:1; |
| 88 | uint8_t subflow_length[0]; /* 1 or 2 bytes depending on li */ |
| 89 | #elif OSMO_IS_BIG_ENDIAN |
Oliver Smith | 0b5c09b | 2023-02-17 10:35:38 +0100 | [diff] [blame] | 90 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */ |
Harald Welte | 9fe1f9f | 2018-11-29 13:47:39 +0100 | [diff] [blame] | 91 | uint8_t lri:1, li:1, rfci:6; |
| 92 | uint8_t subflow_length[0]; |
| 93 | #endif |
| 94 | } __attribute__((packed)); |
| 95 | struct iuup_ctrl_init_hdr { |
| 96 | #if OSMO_IS_LITTLE_ENDIAN |
| 97 | uint8_t chain_ind:1, |
| 98 | num_subflows_per_rfci:3, |
| 99 | ti:1, |
| 100 | spare:3; |
| 101 | uint8_t rfci_data[0]; /* struct iuup_ctrl_init_rfci_hdr* */ |
| 102 | #elif OSMO_IS_BIG_ENDIAN |
Oliver Smith | 0b5c09b | 2023-02-17 10:35:38 +0100 | [diff] [blame] | 103 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */ |
Harald Welte | 9fe1f9f | 2018-11-29 13:47:39 +0100 | [diff] [blame] | 104 | uint8_t spare:3, ti:1, num_subflows_per_rfci:3, chain_ind:1; |
| 105 | uint8_t rfci_data[0]; /* struct iuup_ctrl_init_rfci_hdr* */ |
| 106 | ; |
| 107 | #endif |
| 108 | } __attribute__((packed)); |
| 109 | struct iuup_ctrl_init_tail { |
| 110 | #if OSMO_IS_LITTLE_ENDIAN |
| 111 | uint16_t versions_supported; |
| 112 | uint8_t spare:4, |
| 113 | data_pdu_type:4; |
| 114 | uint8_t spare_extension[0]; |
| 115 | #elif OSMO_IS_BIG_ENDIAN |
Oliver Smith | 0b5c09b | 2023-02-17 10:35:38 +0100 | [diff] [blame] | 116 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */ |
Harald Welte | 9fe1f9f | 2018-11-29 13:47:39 +0100 | [diff] [blame] | 117 | uint16_t versions_supported; |
| 118 | uint8_t data_pdu_type:4, spare:4; |
| 119 | uint8_t spare_extension[0]; |
| 120 | #endif |
| 121 | } __attribute__((packed)); |
| 122 | |
| 123 | /* 3GPP TS 25.415 Section 6.6.2.3.4.4 */ |
| 124 | struct iuup_ctrl_error_event { |
| 125 | #if OSMO_IS_LITTLE_ENDIAN |
| 126 | struct iuup_pdutype14_hdr hdr; |
| 127 | uint8_t error_cause:6, |
| 128 | error_distance:2; |
| 129 | uint8_t spare_extension[0]; |
| 130 | #elif OSMO_IS_BIG_ENDIAN |
Oliver Smith | 0b5c09b | 2023-02-17 10:35:38 +0100 | [diff] [blame] | 131 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */ |
Harald Welte | 9fe1f9f | 2018-11-29 13:47:39 +0100 | [diff] [blame] | 132 | struct iuup_pdutype14_hdr hdr; |
| 133 | uint8_t error_distance:2, error_cause:6; |
| 134 | uint8_t spare_extension[0]; |
| 135 | #endif |
| 136 | } __attribute__((packed)); |
| 137 | |
| 138 | /* 3GPP TS 25.415 Section 6.6.2.3.2 */ |
| 139 | struct iuup_ctrl_ack { |
| 140 | struct iuup_pdutype14_hdr hdr; |
| 141 | uint8_t spare_extension[0]; |
| 142 | } __attribute__((packed)); |
| 143 | |
| 144 | /* 3GPP TS 25.415 Section 6.6.2.3.3 */ |
| 145 | struct iuup_ctrl_nack { |
| 146 | #if OSMO_IS_LITTLE_ENDIAN |
| 147 | struct iuup_pdutype14_hdr hdr; |
| 148 | uint8_t spare:2, |
| 149 | error_cause:6; |
| 150 | uint8_t spare_extension[0]; |
| 151 | #elif OSMO_IS_BIG_ENDIAN |
Oliver Smith | 0b5c09b | 2023-02-17 10:35:38 +0100 | [diff] [blame] | 152 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */ |
Harald Welte | 9fe1f9f | 2018-11-29 13:47:39 +0100 | [diff] [blame] | 153 | struct iuup_pdutype14_hdr hdr; |
| 154 | uint8_t error_cause:6, spare:2; |
| 155 | uint8_t spare_extension[0]; |
| 156 | #endif |
| 157 | } __attribute__((packed)); |
| 158 | |
| 159 | /* 3GPP TS 25.415 Section 6.6.2 + 6.6.3.1 */ |
| 160 | enum iuup_pdu_type { |
| 161 | IUUP_PDU_T_DATA_CRC = 0, |
| 162 | IUUP_PDU_T_DATA_NOCRC = 1, |
| 163 | IUUP_PDU_T_CONTROL = 14, |
| 164 | }; |
| 165 | |
| 166 | /* 3GPP TS 25.415 Section 6.6.3.2 */ |
| 167 | enum iuup_ack_nack { |
| 168 | IUUP_AN_PROCEDURE = 0, |
| 169 | IUUP_AN_ACK = 1, |
| 170 | IUUP_AN_NACK = 2, |
| 171 | }; |
| 172 | |
| 173 | /* 3GPP TS 25.415 Section 6.6.3.5 */ |
| 174 | enum iuup_fqc { |
| 175 | IUUP_FQC_FRAME_GOOD = 0, |
| 176 | IUUP_FQC_FRAME_BAD = 1, |
| 177 | IUUP_FQC_FRAME_BAD_RADIO = 2, |
| 178 | }; |
| 179 | |
| 180 | /* 3GPP TS 25.415 Section 6.6.3.7 */ |
| 181 | enum iuup_procedure { |
| 182 | IUUP_PROC_INIT = 0, |
| 183 | IUUP_PROC_RATE_CTRL = 1, |
| 184 | IUUP_PROC_TIME_ALIGN = 2, |
| 185 | IUUP_PROC_ERR_EVENT = 3, |
| 186 | }; |
| 187 | |
| 188 | |
| 189 | /* 3GPP TS 25.415 Section 6.6.3.15 */ |
| 190 | enum iuup_error_distance { |
| 191 | IUUP_ERR_DIST_LOCAL = 0, |
| 192 | IUUP_ERR_DIST_FIRST_FWD = 1, |
| 193 | IUUP_ERR_DIST_SECOND_FWD = 2, |
| 194 | IUUP_ERR_DIST_RESERVED = 3, |
| 195 | }; |
| 196 | |
| 197 | |
| 198 | /* 3GPP TS 25.415 Section 6.6.3.16 */ |
| 199 | enum iuup_error_cause { |
| 200 | IUUP_ERR_CAUSE_CRC_ERR_HDR = 0, |
| 201 | IUUP_ERR_CAUSE_CRC_ERR_DATA = 1, |
| 202 | IUUP_ERR_CAUSE_UNEXPECTED_FN = 2, |
| 203 | IUUP_ERR_CAUSE_FRAME_LOSS = 3, |
| 204 | IUUP_ERR_CAUSE_UNKNOWN_PDUTYPE = 4, |
| 205 | IUUP_ERR_CAUSE_UNKNOWN_PROC = 5, |
| 206 | IUUP_ERR_CAUSE_UNKNNOWN_RES_VAL = 6, |
| 207 | IUUP_ERR_CAUSE_UNKNNOWN_FIELD = 7, |
| 208 | IUUP_ERR_CAUSE_FRAME_TOO_SHORT = 8, |
| 209 | IUUP_ERR_CAUSE_MISSING_FIELDS = 9, |
| 210 | IUUP_ERR_CAUSE_UNEXPECTED_PDU_T = 16, |
| 211 | IUUP_ERR_CAUSE_UNEXPECTED_PROC = 18, |
| 212 | IUUP_ERR_CAUSE_UNEXPECTED_RFCI = 19, |
| 213 | IUUP_ERR_CAUSE_UNEXPECTED_VALUE = 20, |
| 214 | IUUP_ERR_CAUSE_INIT_FAILURE = 42, |
| 215 | IUUP_ERR_CAUSE_INIT_FAILURE_NET_TMR = 43, |
| 216 | IUUP_ERR_CAUSE_INIT_FAILURE_REP_NACK = 44, |
| 217 | IUUP_ERR_CAUSE_RATE_CTRL_FAILURE = 45, |
| 218 | IUUP_ERR_CAUSE_ERR_EVENT_FAIL = 46, |
| 219 | IUUP_ERR_CAUSE_TIME_ALIGN_NOTSUPP = 47, |
| 220 | IUUP_ERR_CAUSE_REQ_TIME_ALIGN_NOTPOSS = 48, |
| 221 | IUUP_ERR_CAUSE_MODE_VERSION_NOT_SUPPORTED = 49, |
| 222 | }; |