Neels Hofmeyr | 17518fe | 2017-06-20 04:35:06 +0200 | [diff] [blame] | 1 | /* |
Harald Welte | e08da97 | 2017-11-13 01:00:26 +0900 | [diff] [blame] | 2 | * (C) 2008-2017 by Harald Welte <laforge@gnumonks.org> |
| 3 | * (C) 2013 by Holger Freyther <holger@freyther.de> |
| 4 | * (C) 2014-2016 by sysmocom - s.f.m.c. GmbH |
Harald Welte | d284cd9 | 2010-03-01 21:58:31 +0100 | [diff] [blame] | 5 | * |
| 6 | * All Rights Reserved |
| 7 | * |
Harald Welte | e08da97 | 2017-11-13 01:00:26 +0900 | [diff] [blame] | 8 | * SPDX-License-Identifier: GPL-2.0+ |
| 9 | * |
Harald Welte | d284cd9 | 2010-03-01 21:58:31 +0100 | [diff] [blame] | 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation; either version 2 of the License, or |
| 13 | * (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
Harald Welte | d284cd9 | 2010-03-01 21:58:31 +0100 | [diff] [blame] | 20 | */ |
| 21 | |
Harald Welte | ecf9dd0 | 2010-03-04 14:27:48 +0100 | [diff] [blame] | 22 | #include <stdint.h> |
Harald Welte | 40481e8 | 2010-07-30 11:40:32 +0200 | [diff] [blame] | 23 | #include <stdio.h> |
Harald Welte | ecf9dd0 | 2010-03-04 14:27:48 +0100 | [diff] [blame] | 24 | #include <errno.h> |
| 25 | |
Pablo Neira Ayuso | 8341934 | 2011-03-22 16:36:13 +0100 | [diff] [blame] | 26 | #include <osmocom/gsm/tlv.h> |
| 27 | #include <osmocom/gsm/rsl.h> |
Harald Welte | d284cd9 | 2010-03-01 21:58:31 +0100 | [diff] [blame] | 28 | |
Harald Welte | 8f2c7e5 | 2011-08-17 18:52:03 +0200 | [diff] [blame] | 29 | /*! \addtogroup rsl |
| 30 | * @{ |
Neels Hofmeyr | 17518fe | 2017-06-20 04:35:06 +0200 | [diff] [blame] | 31 | * GSM Radio Signalling Link messages on the A-bis interface. |
| 32 | * 3GPP TS 08.58 version 8.6.0 Release 1999 / ETSI TS 100 596 V8.6.0. |
| 33 | * |
| 34 | * \file rsl.c */ |
Harald Welte | 8f2c7e5 | 2011-08-17 18:52:03 +0200 | [diff] [blame] | 35 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 36 | /*! Size for RSL \ref msgb_alloc */ |
Harald Welte | eb8bf39 | 2010-03-04 10:32:09 +0100 | [diff] [blame] | 37 | #define RSL_ALLOC_SIZE 200 |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 38 | /*! Headroom size for RSL \ref msgb_alloc */ |
Harald Welte | eb8bf39 | 2010-03-04 10:32:09 +0100 | [diff] [blame] | 39 | #define RSL_ALLOC_HEADROOM 56 |
| 40 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 41 | /*! Initialize a RSL RLL header |
Harald Welte | 96e2a00 | 2017-06-12 21:44:18 +0200 | [diff] [blame] | 42 | * \param[out] dh Caller-allocated RSL RLL header |
| 43 | * \param[in] msg_type Message Type */ |
Harald Welte | d284cd9 | 2010-03-01 21:58:31 +0100 | [diff] [blame] | 44 | void rsl_init_rll_hdr(struct abis_rsl_rll_hdr *dh, uint8_t msg_type) |
| 45 | { |
| 46 | dh->c.msg_discr = ABIS_RSL_MDISC_RLL; |
| 47 | dh->c.msg_type = msg_type; |
| 48 | dh->ie_chan = RSL_IE_CHAN_NR; |
| 49 | dh->ie_link_id = RSL_IE_LINK_IDENT; |
| 50 | } |
| 51 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 52 | /*! Initialize a RSL Common Channel header |
Harald Welte | 96e2a00 | 2017-06-12 21:44:18 +0200 | [diff] [blame] | 53 | * \param[out] ch Caller-allocated RSL Common Channel Header |
| 54 | * \param[in] msg_type Message Type */ |
Harald Welte | 6eb7d6c | 2010-07-13 13:48:13 +0200 | [diff] [blame] | 55 | void rsl_init_cchan_hdr(struct abis_rsl_cchan_hdr *ch, uint8_t msg_type) |
| 56 | { |
| 57 | ch->c.msg_discr = ABIS_RSL_MDISC_COM_CHAN; |
| 58 | ch->c.msg_type = msg_type; |
| 59 | ch->ie_chan = RSL_IE_CHAN_NR; |
| 60 | } |
| 61 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 62 | /* TLV parser definition for RSL */ |
Harald Welte | d284cd9 | 2010-03-01 21:58:31 +0100 | [diff] [blame] | 63 | const struct tlv_definition rsl_att_tlvdef = { |
| 64 | .def = { |
| 65 | [RSL_IE_CHAN_NR] = { TLV_TYPE_TV }, |
| 66 | [RSL_IE_LINK_IDENT] = { TLV_TYPE_TV }, |
| 67 | [RSL_IE_ACT_TYPE] = { TLV_TYPE_TV }, |
| 68 | [RSL_IE_BS_POWER] = { TLV_TYPE_TV }, |
| 69 | [RSL_IE_CHAN_IDENT] = { TLV_TYPE_TLV }, |
| 70 | [RSL_IE_CHAN_MODE] = { TLV_TYPE_TLV }, |
| 71 | [RSL_IE_ENCR_INFO] = { TLV_TYPE_TLV }, |
| 72 | [RSL_IE_FRAME_NUMBER] = { TLV_TYPE_FIXED, 2 }, |
| 73 | [RSL_IE_HANDO_REF] = { TLV_TYPE_TV }, |
| 74 | [RSL_IE_L1_INFO] = { TLV_TYPE_FIXED, 2 }, |
| 75 | [RSL_IE_L3_INFO] = { TLV_TYPE_TL16V }, |
| 76 | [RSL_IE_MS_IDENTITY] = { TLV_TYPE_TLV }, |
| 77 | [RSL_IE_MS_POWER] = { TLV_TYPE_TV }, |
| 78 | [RSL_IE_PAGING_GROUP] = { TLV_TYPE_TV }, |
| 79 | [RSL_IE_PAGING_LOAD] = { TLV_TYPE_FIXED, 2 }, |
| 80 | [RSL_IE_PYHS_CONTEXT] = { TLV_TYPE_TLV }, |
| 81 | [RSL_IE_ACCESS_DELAY] = { TLV_TYPE_TV }, |
| 82 | [RSL_IE_RACH_LOAD] = { TLV_TYPE_TLV }, |
| 83 | [RSL_IE_REQ_REFERENCE] = { TLV_TYPE_FIXED, 3 }, |
| 84 | [RSL_IE_RELEASE_MODE] = { TLV_TYPE_TV }, |
| 85 | [RSL_IE_RESOURCE_INFO] = { TLV_TYPE_TLV }, |
| 86 | [RSL_IE_RLM_CAUSE] = { TLV_TYPE_TLV }, |
| 87 | [RSL_IE_STARTNG_TIME] = { TLV_TYPE_FIXED, 2 }, |
| 88 | [RSL_IE_TIMING_ADVANCE] = { TLV_TYPE_TV }, |
| 89 | [RSL_IE_UPLINK_MEAS] = { TLV_TYPE_TLV }, |
| 90 | [RSL_IE_CAUSE] = { TLV_TYPE_TLV }, |
| 91 | [RSL_IE_MEAS_RES_NR] = { TLV_TYPE_TV }, |
| 92 | [RSL_IE_MSG_ID] = { TLV_TYPE_TV }, |
| 93 | [RSL_IE_SYSINFO_TYPE] = { TLV_TYPE_TV }, |
| 94 | [RSL_IE_MS_POWER_PARAM] = { TLV_TYPE_TLV }, |
| 95 | [RSL_IE_BS_POWER_PARAM] = { TLV_TYPE_TLV }, |
| 96 | [RSL_IE_PREPROC_PARAM] = { TLV_TYPE_TLV }, |
| 97 | [RSL_IE_PREPROC_MEAS] = { TLV_TYPE_TLV }, |
| 98 | [RSL_IE_IMM_ASS_INFO] = { TLV_TYPE_TLV }, |
| 99 | [RSL_IE_SMSCB_INFO] = { TLV_TYPE_FIXED, 23 }, |
| 100 | [RSL_IE_MS_TIMING_OFFSET] = { TLV_TYPE_TV }, |
| 101 | [RSL_IE_ERR_MSG] = { TLV_TYPE_TLV }, |
| 102 | [RSL_IE_FULL_BCCH_INFO] = { TLV_TYPE_TLV }, |
| 103 | [RSL_IE_CHAN_NEEDED] = { TLV_TYPE_TV }, |
| 104 | [RSL_IE_CB_CMD_TYPE] = { TLV_TYPE_TV }, |
| 105 | [RSL_IE_SMSCB_MSG] = { TLV_TYPE_TLV }, |
| 106 | [RSL_IE_FULL_IMM_ASS_INFO] = { TLV_TYPE_TLV }, |
| 107 | [RSL_IE_SACCH_INFO] = { TLV_TYPE_TLV }, |
| 108 | [RSL_IE_CBCH_LOAD_INFO] = { TLV_TYPE_TV }, |
| 109 | [RSL_IE_SMSCB_CHAN_INDICATOR] = { TLV_TYPE_TV }, |
| 110 | [RSL_IE_GROUP_CALL_REF] = { TLV_TYPE_TLV }, |
| 111 | [RSL_IE_CHAN_DESC] = { TLV_TYPE_TLV }, |
| 112 | [RSL_IE_NCH_DRX_INFO] = { TLV_TYPE_TLV }, |
| 113 | [RSL_IE_CMD_INDICATOR] = { TLV_TYPE_TLV }, |
| 114 | [RSL_IE_EMLPP_PRIO] = { TLV_TYPE_TV }, |
| 115 | [RSL_IE_UIC] = { TLV_TYPE_TLV }, |
| 116 | [RSL_IE_MAIN_CHAN_REF] = { TLV_TYPE_TV }, |
| 117 | [RSL_IE_MR_CONFIG] = { TLV_TYPE_TLV }, |
| 118 | [RSL_IE_MR_CONTROL] = { TLV_TYPE_TV }, |
| 119 | [RSL_IE_SUP_CODEC_TYPES] = { TLV_TYPE_TLV }, |
| 120 | [RSL_IE_CODEC_CONFIG] = { TLV_TYPE_TLV }, |
| 121 | [RSL_IE_RTD] = { TLV_TYPE_TV }, |
| 122 | [RSL_IE_TFO_STATUS] = { TLV_TYPE_TV }, |
| 123 | [RSL_IE_LLP_APDU] = { TLV_TYPE_TLV }, |
| 124 | [RSL_IE_SIEMENS_MRPCI] = { TLV_TYPE_TV }, |
Philipp Maier | a15967b | 2020-11-06 21:37:16 +0100 | [diff] [blame] | 125 | [RSL_IE_OSMO_REP_ACCH_CAP] = { TLV_TYPE_TLV }, |
Neels Hofmeyr | dd6f136 | 2021-04-20 23:02:59 +0200 | [diff] [blame] | 126 | [RSL_IE_OSMO_TRAINING_SEQUENCE] = { TLV_TYPE_TLV }, |
Philipp Maier | 0e44a72 | 2021-08-30 10:51:52 +0200 | [diff] [blame] | 127 | [RSL_IE_OSMO_TEMP_OVP_ACCH_CAP] = { TLV_TYPE_TLV }, |
Pau Espin Pedrol | 83287ba | 2022-08-08 17:07:18 +0200 | [diff] [blame] | 128 | [RSL_IE_OSMO_OSMUX_CID] = { TLV_TYPE_TLV }, |
Pau Espin Pedrol | b0c2f75 | 2022-04-04 19:37:19 +0200 | [diff] [blame] | 129 | [RSL_IE_IPAC_SRTP_CONFIG] = { TLV_TYPE_TLV }, |
Harald Welte | d284cd9 | 2010-03-01 21:58:31 +0100 | [diff] [blame] | 130 | [RSL_IE_IPAC_PROXY_UDP] = { TLV_TYPE_FIXED, 2 }, |
| 131 | [RSL_IE_IPAC_BSCMPL_TOUT] = { TLV_TYPE_TV }, |
| 132 | [RSL_IE_IPAC_REMOTE_IP] = { TLV_TYPE_FIXED, 4 }, |
| 133 | [RSL_IE_IPAC_REMOTE_PORT] = { TLV_TYPE_FIXED, 2 }, |
| 134 | [RSL_IE_IPAC_RTP_PAYLOAD] = { TLV_TYPE_TV }, |
| 135 | [RSL_IE_IPAC_LOCAL_PORT] = { TLV_TYPE_FIXED, 2 }, |
| 136 | [RSL_IE_IPAC_SPEECH_MODE] = { TLV_TYPE_TV }, |
| 137 | [RSL_IE_IPAC_LOCAL_IP] = { TLV_TYPE_FIXED, 4 }, |
Pau Espin Pedrol | 388a53a | 2022-04-04 19:26:05 +0200 | [diff] [blame] | 138 | [RSL_IE_IPAC_CONN_STAT] = { TLV_TYPE_TLV, 28 }, |
Pau Espin Pedrol | b0c2f75 | 2022-04-04 19:37:19 +0200 | [diff] [blame] | 139 | [RSL_IE_IPAC_HO_C_PARMS] = { TLV_TYPE_TLV }, |
Harald Welte | d284cd9 | 2010-03-01 21:58:31 +0100 | [diff] [blame] | 140 | [RSL_IE_IPAC_CONN_ID] = { TLV_TYPE_FIXED, 2 }, |
| 141 | [RSL_IE_IPAC_RTP_CSD_FMT] = { TLV_TYPE_TV }, |
| 142 | [RSL_IE_IPAC_RTP_JIT_BUF] = { TLV_TYPE_FIXED, 2 }, |
| 143 | [RSL_IE_IPAC_RTP_COMPR] = { TLV_TYPE_TV }, |
| 144 | [RSL_IE_IPAC_RTP_PAYLOAD2] = { TLV_TYPE_TV }, |
| 145 | [RSL_IE_IPAC_RTP_MPLEX] = { TLV_TYPE_FIXED, 8 }, |
| 146 | [RSL_IE_IPAC_RTP_MPLEX_ID] = { TLV_TYPE_TV }, |
| 147 | }, |
| 148 | }; |
| 149 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 150 | /*! Encode channel number as per Section 9.3.1 |
Harald Welte | 96e2a00 | 2017-06-12 21:44:18 +0200 | [diff] [blame] | 151 | * \param[in] Channel Type (RSL_CHAN_...) |
| 152 | * \param[in] subch Sub-Channel within Channel |
| 153 | * \param[in] timeslot Air interface timeslot |
| 154 | * \returns RSL Channel Number (TS 08.58 9.3.1) */ |
Harald Welte | d284cd9 | 2010-03-01 21:58:31 +0100 | [diff] [blame] | 155 | uint8_t rsl_enc_chan_nr(uint8_t type, uint8_t subch, uint8_t timeslot) |
| 156 | { |
| 157 | uint8_t ret; |
| 158 | |
| 159 | ret = (timeslot & 0x07) | type; |
| 160 | |
| 161 | switch (type) { |
| 162 | case RSL_CHAN_Lm_ACCHs: |
Vadim Yanitskiy | fc02ff4 | 2021-05-26 18:19:03 +0200 | [diff] [blame] | 163 | case RSL_CHAN_OSMO_VAMOS_Lm_ACCHs: |
Harald Welte | d284cd9 | 2010-03-01 21:58:31 +0100 | [diff] [blame] | 164 | subch &= 0x01; |
| 165 | break; |
| 166 | case RSL_CHAN_SDCCH4_ACCH: |
Harald Welte | 098cd4b | 2010-03-04 10:12:50 +0100 | [diff] [blame] | 167 | subch &= 0x03; |
Harald Welte | d284cd9 | 2010-03-01 21:58:31 +0100 | [diff] [blame] | 168 | break; |
| 169 | case RSL_CHAN_SDCCH8_ACCH: |
| 170 | subch &= 0x07; |
| 171 | break; |
| 172 | default: |
| 173 | /* no subchannels allowed */ |
| 174 | subch = 0x00; |
| 175 | break; |
| 176 | } |
| 177 | ret |= (subch << 3); |
| 178 | |
| 179 | return ret; |
| 180 | } |
| 181 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 182 | /*! Decode RSL channel number |
Harald Welte | 8f2c7e5 | 2011-08-17 18:52:03 +0200 | [diff] [blame] | 183 | * \param[in] chan_nr Channel Number |
| 184 | * \param[out] type Channel Type |
| 185 | * \param[out] subch Sub-channel Number |
| 186 | * \param[out] timeslot Timeslot |
| 187 | */ |
Harald Welte | ecf9dd0 | 2010-03-04 14:27:48 +0100 | [diff] [blame] | 188 | int rsl_dec_chan_nr(uint8_t chan_nr, uint8_t *type, uint8_t *subch, uint8_t *timeslot) |
| 189 | { |
| 190 | *timeslot = chan_nr & 0x7; |
| 191 | |
Vadim Yanitskiy | 57850ae | 2021-05-26 20:23:46 +0200 | [diff] [blame] | 192 | switch (chan_nr & RSL_CHAN_NR_MASK) { |
| 193 | case RSL_CHAN_Bm_ACCHs: |
| 194 | case RSL_CHAN_BCCH: |
| 195 | case RSL_CHAN_RACH: |
| 196 | case RSL_CHAN_PCH_AGCH: |
| 197 | case RSL_CHAN_OSMO_PDCH: |
| 198 | case RSL_CHAN_OSMO_CBCH4: |
| 199 | case RSL_CHAN_OSMO_CBCH8: |
Vadim Yanitskiy | fc02ff4 | 2021-05-26 18:19:03 +0200 | [diff] [blame] | 200 | case RSL_CHAN_OSMO_VAMOS_Bm_ACCHs: |
Vadim Yanitskiy | 57850ae | 2021-05-26 20:23:46 +0200 | [diff] [blame] | 201 | *type = chan_nr & RSL_CHAN_NR_MASK; |
Harald Welte | ecf9dd0 | 2010-03-04 14:27:48 +0100 | [diff] [blame] | 202 | *subch = 0; |
Vadim Yanitskiy | 57850ae | 2021-05-26 20:23:46 +0200 | [diff] [blame] | 203 | break; |
| 204 | default: |
| 205 | if ((chan_nr & 0xf0) == RSL_CHAN_Lm_ACCHs) { |
| 206 | *type = RSL_CHAN_Lm_ACCHs; |
| 207 | *subch = (chan_nr >> 3) & 0x1; |
| 208 | } else if ((chan_nr & 0xe0) == RSL_CHAN_SDCCH4_ACCH) { |
| 209 | *type = RSL_CHAN_SDCCH4_ACCH; |
| 210 | *subch = (chan_nr >> 3) & 0x3; |
| 211 | } else if ((chan_nr & 0xc0) == RSL_CHAN_SDCCH8_ACCH) { |
| 212 | *type = RSL_CHAN_SDCCH8_ACCH; |
| 213 | *subch = (chan_nr >> 3) & 0x7; |
Vadim Yanitskiy | fc02ff4 | 2021-05-26 18:19:03 +0200 | [diff] [blame] | 214 | } else if ((chan_nr & 0xf0) == RSL_CHAN_OSMO_VAMOS_Lm_ACCHs) { |
| 215 | *type = RSL_CHAN_OSMO_VAMOS_Lm_ACCHs; |
| 216 | *subch = (chan_nr >> 3) & 0x1; |
Vadim Yanitskiy | 57850ae | 2021-05-26 20:23:46 +0200 | [diff] [blame] | 217 | } else |
| 218 | return -EINVAL; |
| 219 | } |
Harald Welte | ecf9dd0 | 2010-03-04 14:27:48 +0100 | [diff] [blame] | 220 | |
| 221 | return 0; |
| 222 | } |
| 223 | |
Harald Welte | 4a62eda | 2019-03-18 18:27:00 +0100 | [diff] [blame] | 224 | /*! Get human-readable string for RSL channel number, in caller-provided buffer. |
| 225 | * \param[out] buf caller-provided output buffer |
| 226 | * \param[in] buf_len size of buf in bytes |
| 227 | * \param[in] chan_nr channel number to be stringified |
| 228 | * \returns buf with string |
| 229 | */ |
| 230 | char *rsl_chan_nr_str_buf(char *buf, size_t buf_len, uint8_t chan_nr) |
Sylvain Munaut | 27af075 | 2010-07-25 12:25:17 +0200 | [diff] [blame] | 231 | { |
Sylvain Munaut | 27af075 | 2010-07-25 12:25:17 +0200 | [diff] [blame] | 232 | int ts = chan_nr & 7; |
| 233 | uint8_t cbits = chan_nr >> 3; |
| 234 | |
Vadim Yanitskiy | fdaec8e | 2020-10-17 00:27:12 +0700 | [diff] [blame] | 235 | if (cbits == ABIS_RSL_CHAN_NR_CBITS_Bm_ACCHs) |
Harald Welte | 4a62eda | 2019-03-18 18:27:00 +0100 | [diff] [blame] | 236 | snprintf(buf, buf_len, "TCH/F on TS%d", ts); |
Vadim Yanitskiy | fdaec8e | 2020-10-17 00:27:12 +0700 | [diff] [blame] | 237 | else if ((cbits & 0x1e) == ABIS_RSL_CHAN_NR_CBITS_Lm_ACCHs(0)) |
Harald Welte | 4a62eda | 2019-03-18 18:27:00 +0100 | [diff] [blame] | 238 | snprintf(buf, buf_len, "TCH/H(%u) on TS%d", cbits & 0x01, ts); |
Vadim Yanitskiy | fdaec8e | 2020-10-17 00:27:12 +0700 | [diff] [blame] | 239 | else if ((cbits & 0x1c) == ABIS_RSL_CHAN_NR_CBITS_SDCCH4_ACCH(0)) |
Harald Welte | 4a62eda | 2019-03-18 18:27:00 +0100 | [diff] [blame] | 240 | snprintf(buf, buf_len, "SDCCH/4(%u) on TS%d", cbits & 0x03, ts); |
Vadim Yanitskiy | fdaec8e | 2020-10-17 00:27:12 +0700 | [diff] [blame] | 241 | else if ((cbits & 0x18) == ABIS_RSL_CHAN_NR_CBITS_SDCCH8_ACCH(0)) |
Harald Welte | 4a62eda | 2019-03-18 18:27:00 +0100 | [diff] [blame] | 242 | snprintf(buf, buf_len, "SDCCH/8(%u) on TS%d", cbits & 0x07, ts); |
Vadim Yanitskiy | fdaec8e | 2020-10-17 00:27:12 +0700 | [diff] [blame] | 243 | else if (cbits == ABIS_RSL_CHAN_NR_CBITS_BCCH) |
Harald Welte | 4a62eda | 2019-03-18 18:27:00 +0100 | [diff] [blame] | 244 | snprintf(buf, buf_len, "BCCH on TS%d", ts); |
Vadim Yanitskiy | fdaec8e | 2020-10-17 00:27:12 +0700 | [diff] [blame] | 245 | else if (cbits == ABIS_RSL_CHAN_NR_CBITS_RACH) |
Harald Welte | 4a62eda | 2019-03-18 18:27:00 +0100 | [diff] [blame] | 246 | snprintf(buf, buf_len, "RACH on TS%d", ts); |
Vadim Yanitskiy | fdaec8e | 2020-10-17 00:27:12 +0700 | [diff] [blame] | 247 | else if (cbits == ABIS_RSL_CHAN_NR_CBITS_PCH_AGCH) |
Harald Welte | 4a62eda | 2019-03-18 18:27:00 +0100 | [diff] [blame] | 248 | snprintf(buf, buf_len, "PCH/AGCH on TS%d", ts); |
Vadim Yanitskiy | fdaec8e | 2020-10-17 00:27:12 +0700 | [diff] [blame] | 249 | else if (cbits == ABIS_RSL_CHAN_NR_CBITS_OSMO_PDCH) |
Harald Welte | 4a62eda | 2019-03-18 18:27:00 +0100 | [diff] [blame] | 250 | snprintf(buf, buf_len, "PDCH on TS%d", ts); |
Vadim Yanitskiy | fdaec8e | 2020-10-17 00:27:12 +0700 | [diff] [blame] | 251 | else if (cbits == ABIS_RSL_CHAN_NR_CBITS_OSMO_CBCH4) |
Harald Welte | a8d7ebb | 2019-05-27 16:51:23 +0200 | [diff] [blame] | 252 | snprintf(buf, buf_len, "CBCH(SDCCH/4) on TS%d", ts); |
Vadim Yanitskiy | fdaec8e | 2020-10-17 00:27:12 +0700 | [diff] [blame] | 253 | else if (cbits == ABIS_RSL_CHAN_NR_CBITS_OSMO_CBCH8) |
Harald Welte | a8d7ebb | 2019-05-27 16:51:23 +0200 | [diff] [blame] | 254 | snprintf(buf, buf_len, "CBCH(SDCCH/8) on TS%d", ts); |
Vadim Yanitskiy | fc02ff4 | 2021-05-26 18:19:03 +0200 | [diff] [blame] | 255 | else if (cbits == ABIS_RSL_CHAN_NR_CBITS_OSMO_VAMOS_Bm_ACCHs) |
| 256 | snprintf(buf, buf_len, "VAMOS TCH/F on TS%d", ts); |
| 257 | else if ((cbits & 0x1e) == ABIS_RSL_CHAN_NR_CBITS_OSMO_VAMOS_Lm_ACCHs(0)) |
| 258 | snprintf(buf, buf_len, "VAMOS TCH/H(%u) on TS%d", cbits & 0x01, ts); |
Sylvain Munaut | 27af075 | 2010-07-25 12:25:17 +0200 | [diff] [blame] | 259 | else |
Harald Welte | 4a62eda | 2019-03-18 18:27:00 +0100 | [diff] [blame] | 260 | snprintf(buf, buf_len, "UNKNOWN on TS%d", ts); |
Sylvain Munaut | 27af075 | 2010-07-25 12:25:17 +0200 | [diff] [blame] | 261 | |
Harald Welte | 4a62eda | 2019-03-18 18:27:00 +0100 | [diff] [blame] | 262 | return buf; |
| 263 | } |
| 264 | |
| 265 | /*! Get human-readable string for RSL channel number, in static buffer. |
| 266 | * \param[in] chan_nr channel number to be stringified |
| 267 | * \returns buf with string |
| 268 | */ |
| 269 | const char *rsl_chan_nr_str(uint8_t chan_nr) |
| 270 | { |
Vadim Yanitskiy | 6b60d52 | 2021-09-30 22:54:07 +0600 | [diff] [blame] | 271 | static __thread char str[32]; |
Harald Welte | 4a62eda | 2019-03-18 18:27:00 +0100 | [diff] [blame] | 272 | return rsl_chan_nr_str_buf(str, sizeof(str), chan_nr); |
Sylvain Munaut | 27af075 | 2010-07-25 12:25:17 +0200 | [diff] [blame] | 273 | } |
| 274 | |
Harald Welte | 179f357 | 2019-03-18 18:38:47 +0100 | [diff] [blame] | 275 | /*! Get human-readable string for RSL channel number, in dynamically-allocated buffer. |
| 276 | * \param[in] ctx talloc context from which to allocate output buffer |
| 277 | * \param[in] chan_nr channel number to be stringified |
| 278 | * \returns dynamically-allocated buffer with string representation |
| 279 | */ |
| 280 | char *rsl_chan_nr_str_c(const void *ctx, uint8_t chan_nr) |
| 281 | { |
Vadim Yanitskiy | 6b60d52 | 2021-09-30 22:54:07 +0600 | [diff] [blame] | 282 | char *str = talloc_size(ctx, 32); |
Harald Welte | 179f357 | 2019-03-18 18:38:47 +0100 | [diff] [blame] | 283 | if (!str) |
| 284 | return NULL; |
Vadim Yanitskiy | 6b60d52 | 2021-09-30 22:54:07 +0600 | [diff] [blame] | 285 | return rsl_chan_nr_str_buf(str, 32, chan_nr); |
Harald Welte | 179f357 | 2019-03-18 18:38:47 +0100 | [diff] [blame] | 286 | } |
| 287 | |
Harald Welte | e9e190a | 2010-03-25 11:44:57 +0800 | [diff] [blame] | 288 | static const struct value_string rsl_err_vals[] = { |
| 289 | { RSL_ERR_RADIO_IF_FAIL, "Radio Interface Failure" }, |
| 290 | { RSL_ERR_RADIO_LINK_FAIL, "Radio Link Failure" }, |
| 291 | { RSL_ERR_HANDOVER_ACC_FAIL, "Handover Access Failure" }, |
| 292 | { RSL_ERR_TALKER_ACC_FAIL, "Talker Access Failure" }, |
| 293 | { RSL_ERR_OM_INTERVENTION, "O&M Intervention" }, |
| 294 | { RSL_ERR_NORMAL_UNSPEC, "Normal event, unspecified" }, |
| 295 | { RSL_ERR_T_MSRFPCI_EXP, "Siemens: T_MSRFPCI Expired" }, |
| 296 | { RSL_ERR_EQUIPMENT_FAIL, "Equipment Failure" }, |
| 297 | { RSL_ERR_RR_UNAVAIL, "Radio Resource not available" }, |
| 298 | { RSL_ERR_TERR_CH_FAIL, "Terrestrial Channel Failure" }, |
| 299 | { RSL_ERR_CCCH_OVERLOAD, "CCCH Overload" }, |
| 300 | { RSL_ERR_ACCH_OVERLOAD, "ACCH Overload" }, |
| 301 | { RSL_ERR_PROCESSOR_OVERLOAD, "Processor Overload" }, |
Philipp Maier | 6d21448 | 2020-07-28 16:53:27 +0200 | [diff] [blame] | 302 | { RSL_ERR_BTS_NOT_EQUIPPED, "BTS not equipped" }, |
| 303 | { RSL_ERR_REMOTE_TRANSC_FAIL, "Remote Transcoder Failure" }, |
| 304 | { RSL_ERR_NOTIFICATION_OVERFL, "Notification Overflow" }, |
Harald Welte | e9e190a | 2010-03-25 11:44:57 +0800 | [diff] [blame] | 305 | { RSL_ERR_RES_UNAVAIL, "Resource not available, unspecified" }, |
| 306 | { RSL_ERR_TRANSC_UNAVAIL, "Transcoding not available" }, |
| 307 | { RSL_ERR_SERV_OPT_UNAVAIL, "Service or Option not available" }, |
| 308 | { RSL_ERR_ENCR_UNIMPL, "Encryption algorithm not implemented" }, |
| 309 | { RSL_ERR_SERV_OPT_UNIMPL, "Service or Option not implemented" }, |
| 310 | { RSL_ERR_RCH_ALR_ACTV_ALLOC, "Radio channel already activated" }, |
| 311 | { RSL_ERR_INVALID_MESSAGE, "Invalid Message, unspecified" }, |
| 312 | { RSL_ERR_MSG_DISCR, "Message Discriminator Error" }, |
| 313 | { RSL_ERR_MSG_TYPE, "Message Type Error" }, |
| 314 | { RSL_ERR_MSG_SEQ, "Message Sequence Error" }, |
| 315 | { RSL_ERR_IE_ERROR, "General IE error" }, |
| 316 | { RSL_ERR_MAND_IE_ERROR, "Mandatory IE error" }, |
| 317 | { RSL_ERR_OPT_IE_ERROR, "Optional IE error" }, |
| 318 | { RSL_ERR_IE_NONEXIST, "IE non-existent" }, |
| 319 | { RSL_ERR_IE_LENGTH, "IE length error" }, |
| 320 | { RSL_ERR_IE_CONTENT, "IE content error" }, |
| 321 | { RSL_ERR_PROTO, "Protocol error, unspecified" }, |
| 322 | { RSL_ERR_INTERWORKING, "Interworking error, unspecified" }, |
| 323 | { 0, NULL } |
Harald Welte | d284cd9 | 2010-03-01 21:58:31 +0100 | [diff] [blame] | 324 | }; |
| 325 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 326 | /*! Get human-readable name for RSL Error */ |
Harald Welte | 52b4abd | 2010-03-25 12:11:38 +0800 | [diff] [blame] | 327 | const char *rsl_err_name(uint8_t err) |
| 328 | { |
| 329 | return get_value_string(rsl_err_vals, err); |
| 330 | } |
| 331 | |
Harald Welte | cf7e5da | 2011-06-23 20:43:13 +0200 | [diff] [blame] | 332 | /* Names for Radio Link Layer Management */ |
| 333 | static const struct value_string rsl_msgt_names[] = { |
| 334 | { RSL_MT_DATA_REQ, "DATA_REQ" }, |
| 335 | { RSL_MT_DATA_IND, "DATA_IND" }, |
| 336 | { RSL_MT_ERROR_IND, "ERROR_IND" }, |
| 337 | { RSL_MT_EST_REQ, "EST_REQ" }, |
| 338 | { RSL_MT_EST_CONF, "EST_CONF" }, |
| 339 | { RSL_MT_EST_IND, "EST_IND" }, |
| 340 | { RSL_MT_REL_REQ, "REL_REQ" }, |
| 341 | { RSL_MT_REL_CONF, "REL_CONF" }, |
| 342 | { RSL_MT_REL_IND, "REL_IND" }, |
| 343 | { RSL_MT_UNIT_DATA_REQ, "UNIT_DATA_REQ" }, |
| 344 | { RSL_MT_UNIT_DATA_IND, "UNIT_DATA_IND" }, |
| 345 | { RSL_MT_SUSP_REQ, "SUSP_REQ" }, |
| 346 | { RSL_MT_SUSP_CONF, "SUSP_CONF" }, |
| 347 | { RSL_MT_RES_REQ, "RES_REQ" }, |
| 348 | { RSL_MT_RECON_REQ, "RECON_REQ" }, |
| 349 | |
| 350 | { RSL_MT_BCCH_INFO, "BCCH_INFO" }, |
| 351 | { RSL_MT_CCCH_LOAD_IND, "CCCH_LOAD_IND" }, |
| 352 | { RSL_MT_CHAN_RQD, "CHAN_RQD" }, |
| 353 | { RSL_MT_DELETE_IND, "DELETE_IND" }, |
| 354 | { RSL_MT_PAGING_CMD, "PAGING_CMD" }, |
| 355 | { RSL_MT_IMMEDIATE_ASSIGN_CMD, "IMM_ASS_CMD" }, |
| 356 | { RSL_MT_SMS_BC_REQ, "SMS_BC_REQ" }, |
| 357 | { RSL_MT_CHAN_CONF, "CHAN_CONF" }, |
| 358 | |
| 359 | { RSL_MT_RF_RES_IND, "RF_RES_IND" }, |
| 360 | { RSL_MT_SACCH_FILL, "SACCH_FILL" }, |
| 361 | { RSL_MT_OVERLOAD, "OVERLOAD" }, |
| 362 | { RSL_MT_ERROR_REPORT, "ERROR_REPORT" }, |
| 363 | { RSL_MT_SMS_BC_CMD, "SMS_BC_CMD" }, |
| 364 | { RSL_MT_CBCH_LOAD_IND, "CBCH_LOAD_IND" }, |
| 365 | { RSL_MT_NOT_CMD, "NOTIFY_CMD" }, |
| 366 | |
| 367 | { RSL_MT_CHAN_ACTIV, "CHAN_ACTIV" }, |
| 368 | { RSL_MT_CHAN_ACTIV_ACK, "CHAN_ACTIV_ACK" }, |
| 369 | { RSL_MT_CHAN_ACTIV_NACK, "CHAN_ACTIV_NACK" }, |
| 370 | { RSL_MT_CONN_FAIL, "CONN_FAIL" }, |
| 371 | { RSL_MT_DEACTIVATE_SACCH, "DEACTIVATE_SACCH" }, |
| 372 | { RSL_MT_ENCR_CMD, "ENCR_CMD" }, |
| 373 | { RSL_MT_HANDO_DET, "HANDOVER_DETECT" }, |
| 374 | { RSL_MT_MEAS_RES, "MEAS_RES" }, |
| 375 | { RSL_MT_MODE_MODIFY_REQ, "MODE_MODIFY_REQ" }, |
| 376 | { RSL_MT_MODE_MODIFY_ACK, "MODE_MODIFY_ACK" }, |
| 377 | { RSL_MT_MODE_MODIFY_NACK, "MODE_MODIFY_NACK" }, |
| 378 | { RSL_MT_PHY_CONTEXT_REQ, "PHY_CONTEXT_REQ" }, |
| 379 | { RSL_MT_PHY_CONTEXT_CONF, "PHY_CONTEXT_CONF" }, |
| 380 | { RSL_MT_RF_CHAN_REL, "RF_CHAN_REL" }, |
| 381 | { RSL_MT_MS_POWER_CONTROL, "MS_POWER_CONTROL" }, |
| 382 | { RSL_MT_BS_POWER_CONTROL, "BS_POWER_CONTROL" }, |
| 383 | { RSL_MT_PREPROC_CONFIG, "PREPROC_CONFIG" }, |
| 384 | { RSL_MT_PREPROC_MEAS_RES, "PREPROC_MEAS_RES" }, |
| 385 | { RSL_MT_RF_CHAN_REL_ACK, "RF_CHAN_REL_ACK" }, |
| 386 | { RSL_MT_SACCH_INFO_MODIFY, "SACCH_INFO_MODIFY" }, |
| 387 | { RSL_MT_TALKER_DET, "TALKER_DETECT" }, |
| 388 | { RSL_MT_LISTENER_DET, "LISTENER_DETECT" }, |
| 389 | { RSL_MT_REMOTE_CODEC_CONF_REP, "REM_CODEC_CONF_REP" }, |
| 390 | { RSL_MT_RTD_REP, "RTD_REQ" }, |
| 391 | { RSL_MT_PRE_HANDO_NOTIF, "HANDO_NOTIF" }, |
| 392 | { RSL_MT_MR_CODEC_MOD_REQ, "CODEC_MOD_REQ" }, |
| 393 | { RSL_MT_MR_CODEC_MOD_ACK, "CODEC_MOD_ACK" }, |
| 394 | { RSL_MT_MR_CODEC_MOD_NACK, "CODEC_MOD_NACK" }, |
| 395 | { RSL_MT_MR_CODEC_MOD_PER, "CODEC_MODE_PER" }, |
| 396 | { RSL_MT_TFO_REP, "TFO_REP" }, |
| 397 | { RSL_MT_TFO_MOD_REQ, "TFO_MOD_REQ" }, |
| 398 | { RSL_MT_LOCATION_INFO, "LOCATION_INFO" }, |
Harald Welte | f945689 | 2019-09-03 13:56:00 +0200 | [diff] [blame] | 399 | { RSL_MT_OSMO_ETWS_CMD, "OSMO_ETWS_CMD" }, |
Harald Welte | cf7e5da | 2011-06-23 20:43:13 +0200 | [diff] [blame] | 400 | { 0, NULL } |
| 401 | }; |
| 402 | |
| 403 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 404 | /*! Get human-readable string for RSL Message Type */ |
Harald Welte | cf7e5da | 2011-06-23 20:43:13 +0200 | [diff] [blame] | 405 | const char *rsl_msg_name(uint8_t msg_type) |
| 406 | { |
| 407 | return get_value_string(rsl_msgt_names, msg_type); |
| 408 | } |
| 409 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 410 | /*! ip.access specific */ |
Harald Welte | a24026a | 2011-09-02 12:26:50 +0200 | [diff] [blame] | 411 | static const struct value_string rsl_ipac_msgt_names[] = { |
| 412 | { RSL_MT_IPAC_PDCH_ACT, "IPAC_PDCH_ACT" }, |
| 413 | { RSL_MT_IPAC_PDCH_ACT_ACK, "IPAC_PDCH_ACT_ACK" }, |
| 414 | { RSL_MT_IPAC_PDCH_ACT_NACK, "IPAC_PDCH_ACT_NACK" }, |
| 415 | { RSL_MT_IPAC_PDCH_DEACT, "IPAC_PDCH_DEACT" }, |
| 416 | { RSL_MT_IPAC_PDCH_DEACT_ACK, "IPAC_PDCH_DEACT_ACK" }, |
| 417 | { RSL_MT_IPAC_PDCH_DEACT_NACK, "IPAC_PDCH_DEACT_NACK" }, |
| 418 | { RSL_MT_IPAC_CONNECT_MUX, "IPAC_CONNECT_MUX" }, |
| 419 | { RSL_MT_IPAC_CONNECT_MUX_ACK, "IPAC_CONNECT_MUX_ACK" }, |
| 420 | { RSL_MT_IPAC_CONNECT_MUX_NACK, "IPAC_CONNECT_MUX_NACK" }, |
| 421 | { RSL_MT_IPAC_BIND_MUX, "IPAC_BIND_MUX" }, |
| 422 | { RSL_MT_IPAC_BIND_MUX_ACK, "IPAC_BIND_MUX_ACK" }, |
| 423 | { RSL_MT_IPAC_BIND_MUX_NACK, "IPAC_BIND_MUX_NACK" }, |
| 424 | { RSL_MT_IPAC_DISC_MUX, "IPAC_DISC_MUX" }, |
| 425 | { RSL_MT_IPAC_DISC_MUX_ACK, "IPAC_DISC_MUX_ACK" }, |
| 426 | { RSL_MT_IPAC_DISC_MUX_NACK, "IPAC_DISC_MUX_NACK" }, |
| 427 | { RSL_MT_IPAC_CRCX, "IPAC_CRCX" }, |
| 428 | { RSL_MT_IPAC_CRCX_ACK, "IPAC_CRCX_ACK" }, |
| 429 | { RSL_MT_IPAC_CRCX_NACK, "IPAC_CRCX_NACK" }, |
| 430 | { RSL_MT_IPAC_MDCX, "IPAC_MDCX" }, |
| 431 | { RSL_MT_IPAC_MDCX_ACK, "IPAC_MDCX_ACK" }, |
| 432 | { RSL_MT_IPAC_MDCX_NACK, "IPAC_MDCX_NACK" }, |
| 433 | { RSL_MT_IPAC_DLCX_IND, "IPAC_DLCX_IND" }, |
| 434 | { RSL_MT_IPAC_DLCX, "IPAC_DLCX" }, |
| 435 | { RSL_MT_IPAC_DLCX_ACK, "IPAC_DLCX_ACK" }, |
| 436 | { RSL_MT_IPAC_DLCX_NACK, "IPAC_DLCX_NACK" }, |
Minh-Quang Nguyen | 2ff597e | 2017-02-02 13:44:25 -0500 | [diff] [blame] | 437 | { RSL_MT_IPAC_DIR_RETR_ENQ, "IPAC_DIR_RETR_ENQ" }, |
Harald Welte | a24026a | 2011-09-02 12:26:50 +0200 | [diff] [blame] | 438 | { 0, NULL } |
| 439 | }; |
| 440 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 441 | /*! Get human-readable name of ip.access RSL msg type */ |
Harald Welte | a24026a | 2011-09-02 12:26:50 +0200 | [diff] [blame] | 442 | const char *rsl_ipac_msg_name(uint8_t msg_type) |
| 443 | { |
| 444 | return get_value_string(rsl_ipac_msgt_names, msg_type); |
| 445 | } |
| 446 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 447 | /*! Get human-readable name of standard or ip.access RSL msg type. |
Neels Hofmeyr | 0167e3f | 2016-06-06 18:10:38 +0200 | [diff] [blame] | 448 | * If msg_type is a standard RSL message type, return its human-readable name. |
| 449 | * Otherwise return rsl_ipac_msg_name(msg_type). */ |
| 450 | const char *rsl_or_ipac_msg_name(uint8_t msg_type) |
| 451 | { |
| 452 | const char *str = get_value_string_or_null(rsl_msgt_names, msg_type); |
| 453 | if (str) |
| 454 | return str; |
| 455 | return rsl_ipac_msg_name(msg_type); |
| 456 | } |
| 457 | |
Harald Welte | 52b4abd | 2010-03-25 12:11:38 +0800 | [diff] [blame] | 458 | static const struct value_string rsl_rlm_cause_strs[] = { |
Harald Welte | d284cd9 | 2010-03-01 21:58:31 +0100 | [diff] [blame] | 459 | { RLL_CAUSE_T200_EXPIRED, "Timer T200 expired (N200+1) times" }, |
| 460 | { RLL_CAUSE_REEST_REQ, "Re-establishment request" }, |
| 461 | { RLL_CAUSE_UNSOL_UA_RESP, "Unsolicited UA response" }, |
| 462 | { RLL_CAUSE_UNSOL_DM_RESP, "Unsolicited DM response" }, |
| 463 | { RLL_CAUSE_UNSOL_DM_RESP_MF, "Unsolicited DM response, multiple frame" }, |
| 464 | { RLL_CAUSE_UNSOL_SPRV_RESP, "Unsolicited supervisory response" }, |
| 465 | { RLL_CAUSE_SEQ_ERR, "Sequence Error" }, |
| 466 | { RLL_CAUSE_UFRM_INC_PARAM, "U-Frame with incorrect parameters" }, |
| 467 | { RLL_CAUSE_SFRM_INC_PARAM, "S-Frame with incorrect parameters" }, |
| 468 | { RLL_CAUSE_IFRM_INC_MBITS, "I-Frame with incorrect use of M bit" }, |
| 469 | { RLL_CAUSE_IFRM_INC_LEN, "I-Frame with incorrect length" }, |
Holger Hans Peter Freyther | 9ac4537 | 2013-06-11 17:54:56 +0200 | [diff] [blame] | 470 | { RLL_CAUSE_FRM_UNIMPL, "Frame not implemented" }, |
Harald Welte | d284cd9 | 2010-03-01 21:58:31 +0100 | [diff] [blame] | 471 | { RLL_CAUSE_SABM_MF, "SABM command, multiple frame established state" }, |
| 472 | { RLL_CAUSE_SABM_INFO_NOTALL, "SABM frame with information not allowed in this state" }, |
| 473 | { 0, NULL }, |
| 474 | }; |
| 475 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 476 | /*! Get human-readable string for RLM cause */ |
Harald Welte | 52b4abd | 2010-03-25 12:11:38 +0800 | [diff] [blame] | 477 | const char *rsl_rlm_cause_name(uint8_t err) |
Harald Welte | d284cd9 | 2010-03-01 21:58:31 +0100 | [diff] [blame] | 478 | { |
Harald Welte | 52b4abd | 2010-03-25 12:11:38 +0800 | [diff] [blame] | 479 | return get_value_string(rsl_rlm_cause_strs, err); |
Harald Welte | d284cd9 | 2010-03-01 21:58:31 +0100 | [diff] [blame] | 480 | } |
| 481 | |
| 482 | /* Section 3.3.2.3 TS 05.02. I think this looks like a table */ |
| 483 | int rsl_ccch_conf_to_bs_cc_chans(int ccch_conf) |
| 484 | { |
| 485 | switch (ccch_conf) { |
| 486 | case RSL_BCCH_CCCH_CONF_1_NC: |
| 487 | return 1; |
| 488 | case RSL_BCCH_CCCH_CONF_1_C: |
| 489 | return 1; |
| 490 | case RSL_BCCH_CCCH_CONF_2_NC: |
| 491 | return 2; |
| 492 | case RSL_BCCH_CCCH_CONF_3_NC: |
| 493 | return 3; |
| 494 | case RSL_BCCH_CCCH_CONF_4_NC: |
| 495 | return 4; |
| 496 | default: |
| 497 | return -1; |
| 498 | } |
| 499 | } |
| 500 | |
| 501 | /* Section 3.3.2.3 TS 05.02 */ |
| 502 | int rsl_ccch_conf_to_bs_ccch_sdcch_comb(int ccch_conf) |
| 503 | { |
| 504 | switch (ccch_conf) { |
| 505 | case RSL_BCCH_CCCH_CONF_1_NC: |
| 506 | return 0; |
| 507 | case RSL_BCCH_CCCH_CONF_1_C: |
| 508 | return 1; |
| 509 | case RSL_BCCH_CCCH_CONF_2_NC: |
| 510 | return 0; |
| 511 | case RSL_BCCH_CCCH_CONF_3_NC: |
| 512 | return 0; |
| 513 | case RSL_BCCH_CCCH_CONF_4_NC: |
| 514 | return 0; |
| 515 | default: |
| 516 | return -1; |
| 517 | } |
| 518 | } |
Harald Welte | f08eabf | 2010-03-02 21:59:20 +0100 | [diff] [blame] | 519 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 520 | /*! Push a RSL RLL header onto an existing msgb |
Harald Welte | 96e2a00 | 2017-06-12 21:44:18 +0200 | [diff] [blame] | 521 | * \param msg Message Buffer to which RLL header shall be pushed |
| 522 | * \param[in] msg_type RSL Message Type |
| 523 | * \param[in] chan_nr RSL Channel Number |
| 524 | * \param[in] link_id RSL Link Identifier |
| 525 | * \param[in] transparent Transparent to BTS (1) or not (0) */ |
Harald Welte | 6eb7d6c | 2010-07-13 13:48:13 +0200 | [diff] [blame] | 526 | void rsl_rll_push_hdr(struct msgb *msg, uint8_t msg_type, uint8_t chan_nr, |
| 527 | uint8_t link_id, int transparent) |
Harald Welte | f08eabf | 2010-03-02 21:59:20 +0100 | [diff] [blame] | 528 | { |
Harald Welte | f08eabf | 2010-03-02 21:59:20 +0100 | [diff] [blame] | 529 | struct abis_rsl_rll_hdr *rh; |
| 530 | |
Harald Welte | f08eabf | 2010-03-02 21:59:20 +0100 | [diff] [blame] | 531 | rh = (struct abis_rsl_rll_hdr *) msgb_push(msg, sizeof(*rh)); |
| 532 | rsl_init_rll_hdr(rh, msg_type); |
Harald Welte | eb8bf39 | 2010-03-04 10:32:09 +0100 | [diff] [blame] | 533 | if (transparent) |
| 534 | rh->c.msg_discr |= ABIS_RSL_MDISC_TRANSP; |
Harald Welte | f08eabf | 2010-03-02 21:59:20 +0100 | [diff] [blame] | 535 | rh->chan_nr = chan_nr; |
| 536 | rh->link_id = link_id; |
| 537 | |
| 538 | /* set the l2 header pointer */ |
| 539 | msg->l2h = (uint8_t *)rh; |
Harald Welte | f08eabf | 2010-03-02 21:59:20 +0100 | [diff] [blame] | 540 | } |
| 541 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 542 | /*! Wrap msgb in L3 Info IE and push a RSL RLL header |
Harald Welte | 96e2a00 | 2017-06-12 21:44:18 +0200 | [diff] [blame] | 543 | * \param[in] msg Message Buffer to which L3 Header shall be appended |
| 544 | * \param[in] msg_type RSL Message Type |
| 545 | * \param[in] chan_hr RSL Channel Number |
| 546 | * \param[in] link_id Link Identififer |
| 547 | * \param[in] transparent Transparent to BTS (1) or not (0) */ |
Harald Welte | 6eb7d6c | 2010-07-13 13:48:13 +0200 | [diff] [blame] | 548 | void rsl_rll_push_l3(struct msgb *msg, uint8_t msg_type, uint8_t chan_nr, |
| 549 | uint8_t link_id, int transparent) |
| 550 | { |
| 551 | uint8_t l3_len = msg->tail - (uint8_t *)msgb_l3(msg); |
| 552 | |
| 553 | /* construct a RSLms RLL message (DATA INDICATION, UNIT DATA |
| 554 | * INDICATION) and send it off via RSLms */ |
| 555 | |
| 556 | /* Push the L3 IE tag and lengh */ |
| 557 | msgb_tv16_push(msg, RSL_IE_L3_INFO, l3_len); |
| 558 | |
| 559 | /* Then push the RSL header */ |
| 560 | rsl_rll_push_hdr(msg, msg_type, chan_nr, link_id, transparent); |
| 561 | } |
| 562 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 563 | /*! Create msgb with RSL RLL header |
Harald Welte | 96e2a00 | 2017-06-12 21:44:18 +0200 | [diff] [blame] | 564 | * \param[in] msg_type RSL Message Type |
| 565 | * \param[in] chan_nr RSL Channel Number |
| 566 | * \param[in] link_id RSL Link Identifier |
| 567 | * \param[in] transparent Transparent to BTS (1) or not (0) |
| 568 | * \returns callee-allocated msgb; NULL on error */ |
Harald Welte | f08eabf | 2010-03-02 21:59:20 +0100 | [diff] [blame] | 569 | struct msgb *rsl_rll_simple(uint8_t msg_type, uint8_t chan_nr, |
Harald Welte | eb8bf39 | 2010-03-04 10:32:09 +0100 | [diff] [blame] | 570 | uint8_t link_id, int transparent) |
Harald Welte | f08eabf | 2010-03-02 21:59:20 +0100 | [diff] [blame] | 571 | { |
| 572 | struct abis_rsl_rll_hdr *rh; |
Harald Welte | eb8bf39 | 2010-03-04 10:32:09 +0100 | [diff] [blame] | 573 | struct msgb *msg; |
| 574 | |
| 575 | msg = msgb_alloc_headroom(RSL_ALLOC_SIZE+RSL_ALLOC_HEADROOM, |
| 576 | RSL_ALLOC_HEADROOM, "rsl_rll_simple"); |
Harald Welte | f08eabf | 2010-03-02 21:59:20 +0100 | [diff] [blame] | 577 | |
| 578 | if (!msg) |
| 579 | return NULL; |
| 580 | |
| 581 | /* put the RSL header */ |
| 582 | rh = (struct abis_rsl_rll_hdr *) msgb_put(msg, sizeof(*rh)); |
| 583 | rsl_init_rll_hdr(rh, msg_type); |
Harald Welte | eb8bf39 | 2010-03-04 10:32:09 +0100 | [diff] [blame] | 584 | if (transparent) |
| 585 | rh->c.msg_discr |= ABIS_RSL_MDISC_TRANSP; |
Harald Welte | f08eabf | 2010-03-02 21:59:20 +0100 | [diff] [blame] | 586 | rh->chan_nr = chan_nr; |
| 587 | rh->link_id = link_id; |
| 588 | |
| 589 | /* set the l2 header pointer */ |
| 590 | msg->l2h = (uint8_t *)rh; |
| 591 | |
| 592 | return msg; |
| 593 | } |
Harald Welte | 8f2c7e5 | 2011-08-17 18:52:03 +0200 | [diff] [blame] | 594 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 595 | /*! TLV parser definitions for IPA embedded IEs */ |
Harald Welte | fad5752 | 2015-12-13 11:56:36 +0100 | [diff] [blame] | 596 | const struct tlv_definition rsl_ipac_eie_tlvdef = { |
| 597 | .def = { |
| 598 | [RSL_IPAC_EIE_RXLEV] = { TLV_TYPE_TV }, |
| 599 | [RSL_IPAC_EIE_RXQUAL] = { TLV_TYPE_TV }, |
| 600 | [RSL_IPAC_EIE_FREQ_ERR] = { TLV_TYPE_FIXED, 2 }, |
| 601 | [RSL_IPAC_EIE_TIMING_ERR] = { TLV_TYPE_TV }, |
| 602 | [RSL_IPAC_EIE_MEAS_AVG_CFG] = { TLV_TYPE_TLV }, |
| 603 | [RSL_IPAC_EIE_BS_PWR_CTL] = { TLV_TYPE_FIXED, 3 }, |
| 604 | [RSL_IPAC_EIE_MS_PWR_CTL] = { TLV_TYPE_FIXED, 3 }, |
| 605 | [RSL_IPAC_EIE_HANDO_THRESH] = { TLV_TYPE_FIXED, 6 }, |
| 606 | [RSL_IPAC_EIE_NCELL_DEFAULTS] = { TLV_TYPE_FIXED, 3 }, |
| 607 | [RSL_IPAC_EIE_NCELL_LIST] = { TLV_TYPE_TLV }, |
| 608 | [RSL_IPAC_EIE_PC_THRESH_COMP] = { TLV_TYPE_FIXED, 10 }, |
| 609 | [RSL_IPAC_EIE_HO_THRESH_COMP] = { TLV_TYPE_FIXED, 10 }, |
| 610 | [RSL_IPAC_EIE_HO_CAUSE] = { TLV_TYPE_TLV }, |
| 611 | [RSL_IPAC_EIE_HO_CANDIDATES] = { TLV_TYPE_TLV }, |
| 612 | [RSL_IPAC_EIE_NCELL_BA_CHG_LIST]= { TLV_TYPE_TLV }, |
| 613 | [RSL_IPAC_EIE_NUM_OF_MS] = { TLV_TYPE_TV }, |
| 614 | [RSL_IPAC_EIE_HO_CAND_EXT] = { TLV_TYPE_TLV }, |
| 615 | [RSL_IPAC_EIE_NCELL_DEF_EXT] = { TLV_TYPE_TLV }, |
| 616 | [RSL_IPAC_EIE_NCELL_LIST_EXT] = { TLV_TYPE_TLV }, |
| 617 | [RSL_IPAC_EIE_MASTER_KEY] = { TLV_TYPE_TLV }, |
| 618 | [RSL_IPAC_EIE_MASTER_SALT] = { TLV_TYPE_TLV }, |
Minh-Quang Nguyen | 17a8748 | 2016-09-02 11:28:31 -0400 | [diff] [blame] | 619 | [RSL_IPAC_EIE_MEAS_TRANS_RES] = {TLV_TYPE_TV}, |
| 620 | [RSL_IPAC_EIE_3G_HO_PARAM] = { TLV_TYPE_TLV }, |
| 621 | [RSL_IPAC_EIE_3G_NCELL_LIST] = { TLV_TYPE_TLV }, |
| 622 | [RSL_IPAC_EIE_SDCCH_CTL_PARAM] = { TLV_TYPE_TV }, |
| 623 | [RSL_IPAC_EIE_AMR_CONV_THRESH] = { TLV_TYPE_FIXED, 9 }, |
Pau Espin Pedrol | 5193384 | 2021-08-30 13:50:56 +0200 | [diff] [blame] | 624 | /* Osmocom extensions: */ |
| 625 | [RSL_IPAC_EIE_OSMO_MEAS_AVG_CFG]= { TLV_TYPE_TLV }, |
| 626 | [RSL_IPAC_EIE_OSMO_MS_PWR_CTL] = { TLV_TYPE_TLV }, |
| 627 | [RSL_IPAC_EIE_OSMO_PC_THRESH_COMP]= { TLV_TYPE_TLV }, |
Harald Welte | fad5752 | 2015-12-13 11:56:36 +0100 | [diff] [blame] | 628 | }, |
| 629 | }; |
| 630 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 631 | /*! String names of RSL Channel Activation Types */ |
Neels Hofmeyr | 4739076 | 2016-07-18 23:54:01 +0200 | [diff] [blame] | 632 | const struct value_string rsl_act_type_names[] = { |
| 633 | { RSL_ACT_TYPE_INITIAL, "INITIAL" }, |
| 634 | { RSL_ACT_TYPE_REACT, "REACT" }, |
| 635 | { RSL_ACT_INTRA_IMM_ASS, "INTRA_IMM_ASS" }, |
| 636 | { RSL_ACT_INTRA_NORM_ASS, "INTRA_NORM_ASS" }, |
| 637 | { RSL_ACT_INTER_ASYNC, "INTER_ASYNC" }, |
| 638 | { RSL_ACT_INTER_SYNC, "INTER_SYNC" }, |
| 639 | { RSL_ACT_SECOND_ADD, "SECOND_ADD" }, |
| 640 | { RSL_ACT_SECOND_MULTI, "SECOND_MULTI" }, |
| 641 | { RSL_ACT_OSMO_PDCH, "OSMO_PDCH" }, |
| 642 | { 0, NULL } |
| 643 | }; |
| 644 | |
Sylvain Munaut | dca7d2c | 2012-04-18 21:53:23 +0200 | [diff] [blame] | 645 | /*! @} */ |