blob: e27f84a5d56291c626429dddd9d320e692c3d96d [file] [log] [blame]
Harald Welted284cd92010-03-01 21:58:31 +01001/* GSM Radio Signalling Link messages on the A-bis interface
2 * 3GPP TS 08.58 version 8.6.0 Release 1999 / ETSI TS 100 596 V8.6.0 */
3
Harald Welteeb8bf392010-03-04 10:32:09 +01004/* (C) 2008-2010 by Harald Welte <laforge@gnumonks.org>
Harald Welted284cd92010-03-01 21:58:31 +01005 *
6 * All Rights Reserved
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 */
23
Harald Welteecf9dd02010-03-04 14:27:48 +010024#include <stdint.h>
Harald Welte40481e82010-07-30 11:40:32 +020025#include <stdio.h>
Harald Welteecf9dd02010-03-04 14:27:48 +010026#include <errno.h>
27
Pablo Neira Ayuso83419342011-03-22 16:36:13 +010028#include <osmocom/gsm/tlv.h>
29#include <osmocom/gsm/rsl.h>
Harald Welted284cd92010-03-01 21:58:31 +010030
Harald Welte8f2c7e52011-08-17 18:52:03 +020031/*! \addtogroup rsl
32 * @{
33 */
34
35/*! \file rsl.c */
36
37/*! \brief Size for RSL \ref msgb_alloc */
Harald Welteeb8bf392010-03-04 10:32:09 +010038#define RSL_ALLOC_SIZE 200
Harald Welte8f2c7e52011-08-17 18:52:03 +020039/*! \brief Headroom size for RSL \ref msgb_alloc */
Harald Welteeb8bf392010-03-04 10:32:09 +010040#define RSL_ALLOC_HEADROOM 56
41
Harald Welte8f2c7e52011-08-17 18:52:03 +020042/*! \brief Initialize a RSL RLL header */
Harald Welted284cd92010-03-01 21:58:31 +010043void rsl_init_rll_hdr(struct abis_rsl_rll_hdr *dh, uint8_t msg_type)
44{
45 dh->c.msg_discr = ABIS_RSL_MDISC_RLL;
46 dh->c.msg_type = msg_type;
47 dh->ie_chan = RSL_IE_CHAN_NR;
48 dh->ie_link_id = RSL_IE_LINK_IDENT;
49}
50
Harald Welte8f2c7e52011-08-17 18:52:03 +020051/*! \brief Initialize a RSL Common Channel header */
Harald Welte6eb7d6c2010-07-13 13:48:13 +020052void rsl_init_cchan_hdr(struct abis_rsl_cchan_hdr *ch, uint8_t msg_type)
53{
54 ch->c.msg_discr = ABIS_RSL_MDISC_COM_CHAN;
55 ch->c.msg_type = msg_type;
56 ch->ie_chan = RSL_IE_CHAN_NR;
57}
58
Harald Welte8f2c7e52011-08-17 18:52:03 +020059/* \brief TLV parser definition for RSL */
Harald Welted284cd92010-03-01 21:58:31 +010060const struct tlv_definition rsl_att_tlvdef = {
61 .def = {
62 [RSL_IE_CHAN_NR] = { TLV_TYPE_TV },
63 [RSL_IE_LINK_IDENT] = { TLV_TYPE_TV },
64 [RSL_IE_ACT_TYPE] = { TLV_TYPE_TV },
65 [RSL_IE_BS_POWER] = { TLV_TYPE_TV },
66 [RSL_IE_CHAN_IDENT] = { TLV_TYPE_TLV },
67 [RSL_IE_CHAN_MODE] = { TLV_TYPE_TLV },
68 [RSL_IE_ENCR_INFO] = { TLV_TYPE_TLV },
69 [RSL_IE_FRAME_NUMBER] = { TLV_TYPE_FIXED, 2 },
70 [RSL_IE_HANDO_REF] = { TLV_TYPE_TV },
71 [RSL_IE_L1_INFO] = { TLV_TYPE_FIXED, 2 },
72 [RSL_IE_L3_INFO] = { TLV_TYPE_TL16V },
73 [RSL_IE_MS_IDENTITY] = { TLV_TYPE_TLV },
74 [RSL_IE_MS_POWER] = { TLV_TYPE_TV },
75 [RSL_IE_PAGING_GROUP] = { TLV_TYPE_TV },
76 [RSL_IE_PAGING_LOAD] = { TLV_TYPE_FIXED, 2 },
77 [RSL_IE_PYHS_CONTEXT] = { TLV_TYPE_TLV },
78 [RSL_IE_ACCESS_DELAY] = { TLV_TYPE_TV },
79 [RSL_IE_RACH_LOAD] = { TLV_TYPE_TLV },
80 [RSL_IE_REQ_REFERENCE] = { TLV_TYPE_FIXED, 3 },
81 [RSL_IE_RELEASE_MODE] = { TLV_TYPE_TV },
82 [RSL_IE_RESOURCE_INFO] = { TLV_TYPE_TLV },
83 [RSL_IE_RLM_CAUSE] = { TLV_TYPE_TLV },
84 [RSL_IE_STARTNG_TIME] = { TLV_TYPE_FIXED, 2 },
85 [RSL_IE_TIMING_ADVANCE] = { TLV_TYPE_TV },
86 [RSL_IE_UPLINK_MEAS] = { TLV_TYPE_TLV },
87 [RSL_IE_CAUSE] = { TLV_TYPE_TLV },
88 [RSL_IE_MEAS_RES_NR] = { TLV_TYPE_TV },
89 [RSL_IE_MSG_ID] = { TLV_TYPE_TV },
90 [RSL_IE_SYSINFO_TYPE] = { TLV_TYPE_TV },
91 [RSL_IE_MS_POWER_PARAM] = { TLV_TYPE_TLV },
92 [RSL_IE_BS_POWER_PARAM] = { TLV_TYPE_TLV },
93 [RSL_IE_PREPROC_PARAM] = { TLV_TYPE_TLV },
94 [RSL_IE_PREPROC_MEAS] = { TLV_TYPE_TLV },
95 [RSL_IE_IMM_ASS_INFO] = { TLV_TYPE_TLV },
96 [RSL_IE_SMSCB_INFO] = { TLV_TYPE_FIXED, 23 },
97 [RSL_IE_MS_TIMING_OFFSET] = { TLV_TYPE_TV },
98 [RSL_IE_ERR_MSG] = { TLV_TYPE_TLV },
99 [RSL_IE_FULL_BCCH_INFO] = { TLV_TYPE_TLV },
100 [RSL_IE_CHAN_NEEDED] = { TLV_TYPE_TV },
101 [RSL_IE_CB_CMD_TYPE] = { TLV_TYPE_TV },
102 [RSL_IE_SMSCB_MSG] = { TLV_TYPE_TLV },
103 [RSL_IE_FULL_IMM_ASS_INFO] = { TLV_TYPE_TLV },
104 [RSL_IE_SACCH_INFO] = { TLV_TYPE_TLV },
105 [RSL_IE_CBCH_LOAD_INFO] = { TLV_TYPE_TV },
106 [RSL_IE_SMSCB_CHAN_INDICATOR] = { TLV_TYPE_TV },
107 [RSL_IE_GROUP_CALL_REF] = { TLV_TYPE_TLV },
108 [RSL_IE_CHAN_DESC] = { TLV_TYPE_TLV },
109 [RSL_IE_NCH_DRX_INFO] = { TLV_TYPE_TLV },
110 [RSL_IE_CMD_INDICATOR] = { TLV_TYPE_TLV },
111 [RSL_IE_EMLPP_PRIO] = { TLV_TYPE_TV },
112 [RSL_IE_UIC] = { TLV_TYPE_TLV },
113 [RSL_IE_MAIN_CHAN_REF] = { TLV_TYPE_TV },
114 [RSL_IE_MR_CONFIG] = { TLV_TYPE_TLV },
115 [RSL_IE_MR_CONTROL] = { TLV_TYPE_TV },
116 [RSL_IE_SUP_CODEC_TYPES] = { TLV_TYPE_TLV },
117 [RSL_IE_CODEC_CONFIG] = { TLV_TYPE_TLV },
118 [RSL_IE_RTD] = { TLV_TYPE_TV },
119 [RSL_IE_TFO_STATUS] = { TLV_TYPE_TV },
120 [RSL_IE_LLP_APDU] = { TLV_TYPE_TLV },
121 [RSL_IE_SIEMENS_MRPCI] = { TLV_TYPE_TV },
122 [RSL_IE_IPAC_PROXY_UDP] = { TLV_TYPE_FIXED, 2 },
123 [RSL_IE_IPAC_BSCMPL_TOUT] = { TLV_TYPE_TV },
124 [RSL_IE_IPAC_REMOTE_IP] = { TLV_TYPE_FIXED, 4 },
125 [RSL_IE_IPAC_REMOTE_PORT] = { TLV_TYPE_FIXED, 2 },
126 [RSL_IE_IPAC_RTP_PAYLOAD] = { TLV_TYPE_TV },
127 [RSL_IE_IPAC_LOCAL_PORT] = { TLV_TYPE_FIXED, 2 },
128 [RSL_IE_IPAC_SPEECH_MODE] = { TLV_TYPE_TV },
129 [RSL_IE_IPAC_LOCAL_IP] = { TLV_TYPE_FIXED, 4 },
130 [RSL_IE_IPAC_CONN_ID] = { TLV_TYPE_FIXED, 2 },
131 [RSL_IE_IPAC_RTP_CSD_FMT] = { TLV_TYPE_TV },
132 [RSL_IE_IPAC_RTP_JIT_BUF] = { TLV_TYPE_FIXED, 2 },
133 [RSL_IE_IPAC_RTP_COMPR] = { TLV_TYPE_TV },
134 [RSL_IE_IPAC_RTP_PAYLOAD2] = { TLV_TYPE_TV },
135 [RSL_IE_IPAC_RTP_MPLEX] = { TLV_TYPE_FIXED, 8 },
136 [RSL_IE_IPAC_RTP_MPLEX_ID] = { TLV_TYPE_TV },
137 },
138};
139
Harald Welte8f2c7e52011-08-17 18:52:03 +0200140/*! \brief Encode channel number as per Section 9.3.1 */
Harald Welted284cd92010-03-01 21:58:31 +0100141uint8_t rsl_enc_chan_nr(uint8_t type, uint8_t subch, uint8_t timeslot)
142{
143 uint8_t ret;
144
145 ret = (timeslot & 0x07) | type;
146
147 switch (type) {
148 case RSL_CHAN_Lm_ACCHs:
149 subch &= 0x01;
150 break;
151 case RSL_CHAN_SDCCH4_ACCH:
Harald Welte098cd4b2010-03-04 10:12:50 +0100152 subch &= 0x03;
Harald Welted284cd92010-03-01 21:58:31 +0100153 break;
154 case RSL_CHAN_SDCCH8_ACCH:
155 subch &= 0x07;
156 break;
157 default:
158 /* no subchannels allowed */
159 subch = 0x00;
160 break;
161 }
162 ret |= (subch << 3);
163
164 return ret;
165}
166
Harald Welte8f2c7e52011-08-17 18:52:03 +0200167/*! \brief Decode RSL channel number
168 * \param[in] chan_nr Channel Number
169 * \param[out] type Channel Type
170 * \param[out] subch Sub-channel Number
171 * \param[out] timeslot Timeslot
172 */
Harald Welteecf9dd02010-03-04 14:27:48 +0100173int rsl_dec_chan_nr(uint8_t chan_nr, uint8_t *type, uint8_t *subch, uint8_t *timeslot)
174{
175 *timeslot = chan_nr & 0x7;
176
177 if ((chan_nr & 0xf8) == RSL_CHAN_Bm_ACCHs) {
178 *type = RSL_CHAN_Bm_ACCHs;
179 *subch = 0;
180 } else if ((chan_nr & 0xf0) == RSL_CHAN_Lm_ACCHs) {
181 *type = RSL_CHAN_Lm_ACCHs;
182 *subch = (chan_nr >> 3) & 0x1;
183 } else if ((chan_nr & 0xe0) == RSL_CHAN_SDCCH4_ACCH) {
184 *type = RSL_CHAN_SDCCH4_ACCH;
185 *subch = (chan_nr >> 3) & 0x3;
186 } else if ((chan_nr & 0xc0) == RSL_CHAN_SDCCH8_ACCH) {
187 *type = RSL_CHAN_SDCCH8_ACCH;
188 *subch = (chan_nr >> 3) & 0x7;
Harald Welte6fec5142010-03-04 14:30:15 +0100189 } else if ((chan_nr & 0xf8) == RSL_CHAN_BCCH) {
Harald Welteecf9dd02010-03-04 14:27:48 +0100190 *type = RSL_CHAN_BCCH;
191 *subch = 0;
Harald Welte6fec5142010-03-04 14:30:15 +0100192 } else if ((chan_nr & 0xf8) == RSL_CHAN_RACH) {
Harald Welteecf9dd02010-03-04 14:27:48 +0100193 *type = RSL_CHAN_RACH;
194 *subch = 0;
Harald Welte6fec5142010-03-04 14:30:15 +0100195 } else if ((chan_nr & 0xf8) == RSL_CHAN_PCH_AGCH) {
Harald Welteecf9dd02010-03-04 14:27:48 +0100196 *type = RSL_CHAN_PCH_AGCH;
197 *subch = 0;
198 } else
199 return -EINVAL;
200
201 return 0;
202}
203
Harald Welte8f2c7e52011-08-17 18:52:03 +0200204/*! \brief Get human-readable string for RSL channel number */
Sylvain Munaut27af0752010-07-25 12:25:17 +0200205const char *rsl_chan_nr_str(uint8_t chan_nr)
206{
207 static char str[20];
208 int ts = chan_nr & 7;
209 uint8_t cbits = chan_nr >> 3;
210
211 if (cbits == 0x01)
212 sprintf(str, "TCH/F on TS%d", ts);
213 else if ((cbits & 0x1e) == 0x02)
214 sprintf(str, "TCH/H(%u) on TS%d", cbits & 0x01, ts);
215 else if ((cbits & 0x1c) == 0x04)
216 sprintf(str, "SDCCH/4(%u) on TS%d", cbits & 0x03, ts);
217 else if ((cbits & 0x18) == 0x08)
218 sprintf(str, "SDCCH/8(%u) on TS%d", cbits & 0x07, ts);
219 else if (cbits == 0x10)
220 sprintf(str, "BCCH on TS%d", ts);
221 else if (cbits == 0x11)
222 sprintf(str, "RACH on TS%d", ts);
223 else if (cbits == 0x12)
224 sprintf(str, "PCH/AGCH on TS%d", ts);
225 else
226 sprintf(str, "UNKNOWN on TS%d", ts);
227
228 return str;
229}
230
Harald Weltee9e190a2010-03-25 11:44:57 +0800231static const struct value_string rsl_err_vals[] = {
232 { RSL_ERR_RADIO_IF_FAIL, "Radio Interface Failure" },
233 { RSL_ERR_RADIO_LINK_FAIL, "Radio Link Failure" },
234 { RSL_ERR_HANDOVER_ACC_FAIL, "Handover Access Failure" },
235 { RSL_ERR_TALKER_ACC_FAIL, "Talker Access Failure" },
236 { RSL_ERR_OM_INTERVENTION, "O&M Intervention" },
237 { RSL_ERR_NORMAL_UNSPEC, "Normal event, unspecified" },
238 { RSL_ERR_T_MSRFPCI_EXP, "Siemens: T_MSRFPCI Expired" },
239 { RSL_ERR_EQUIPMENT_FAIL, "Equipment Failure" },
240 { RSL_ERR_RR_UNAVAIL, "Radio Resource not available" },
241 { RSL_ERR_TERR_CH_FAIL, "Terrestrial Channel Failure" },
242 { RSL_ERR_CCCH_OVERLOAD, "CCCH Overload" },
243 { RSL_ERR_ACCH_OVERLOAD, "ACCH Overload" },
244 { RSL_ERR_PROCESSOR_OVERLOAD, "Processor Overload" },
245 { RSL_ERR_RES_UNAVAIL, "Resource not available, unspecified" },
246 { RSL_ERR_TRANSC_UNAVAIL, "Transcoding not available" },
247 { RSL_ERR_SERV_OPT_UNAVAIL, "Service or Option not available" },
248 { RSL_ERR_ENCR_UNIMPL, "Encryption algorithm not implemented" },
249 { RSL_ERR_SERV_OPT_UNIMPL, "Service or Option not implemented" },
250 { RSL_ERR_RCH_ALR_ACTV_ALLOC, "Radio channel already activated" },
251 { RSL_ERR_INVALID_MESSAGE, "Invalid Message, unspecified" },
252 { RSL_ERR_MSG_DISCR, "Message Discriminator Error" },
253 { RSL_ERR_MSG_TYPE, "Message Type Error" },
254 { RSL_ERR_MSG_SEQ, "Message Sequence Error" },
255 { RSL_ERR_IE_ERROR, "General IE error" },
256 { RSL_ERR_MAND_IE_ERROR, "Mandatory IE error" },
257 { RSL_ERR_OPT_IE_ERROR, "Optional IE error" },
258 { RSL_ERR_IE_NONEXIST, "IE non-existent" },
259 { RSL_ERR_IE_LENGTH, "IE length error" },
260 { RSL_ERR_IE_CONTENT, "IE content error" },
261 { RSL_ERR_PROTO, "Protocol error, unspecified" },
262 { RSL_ERR_INTERWORKING, "Interworking error, unspecified" },
263 { 0, NULL }
Harald Welted284cd92010-03-01 21:58:31 +0100264};
265
Harald Welte8f2c7e52011-08-17 18:52:03 +0200266/*! \brief Get human-readable name for RSL Error */
Harald Welte52b4abd2010-03-25 12:11:38 +0800267const char *rsl_err_name(uint8_t err)
268{
269 return get_value_string(rsl_err_vals, err);
270}
271
Harald Weltecf7e5da2011-06-23 20:43:13 +0200272/* Names for Radio Link Layer Management */
273static const struct value_string rsl_msgt_names[] = {
274 { RSL_MT_DATA_REQ, "DATA_REQ" },
275 { RSL_MT_DATA_IND, "DATA_IND" },
276 { RSL_MT_ERROR_IND, "ERROR_IND" },
277 { RSL_MT_EST_REQ, "EST_REQ" },
278 { RSL_MT_EST_CONF, "EST_CONF" },
279 { RSL_MT_EST_IND, "EST_IND" },
280 { RSL_MT_REL_REQ, "REL_REQ" },
281 { RSL_MT_REL_CONF, "REL_CONF" },
282 { RSL_MT_REL_IND, "REL_IND" },
283 { RSL_MT_UNIT_DATA_REQ, "UNIT_DATA_REQ" },
284 { RSL_MT_UNIT_DATA_IND, "UNIT_DATA_IND" },
285 { RSL_MT_SUSP_REQ, "SUSP_REQ" },
286 { RSL_MT_SUSP_CONF, "SUSP_CONF" },
287 { RSL_MT_RES_REQ, "RES_REQ" },
288 { RSL_MT_RECON_REQ, "RECON_REQ" },
289
290 { RSL_MT_BCCH_INFO, "BCCH_INFO" },
291 { RSL_MT_CCCH_LOAD_IND, "CCCH_LOAD_IND" },
292 { RSL_MT_CHAN_RQD, "CHAN_RQD" },
293 { RSL_MT_DELETE_IND, "DELETE_IND" },
294 { RSL_MT_PAGING_CMD, "PAGING_CMD" },
295 { RSL_MT_IMMEDIATE_ASSIGN_CMD, "IMM_ASS_CMD" },
296 { RSL_MT_SMS_BC_REQ, "SMS_BC_REQ" },
297 { RSL_MT_CHAN_CONF, "CHAN_CONF" },
298
299 { RSL_MT_RF_RES_IND, "RF_RES_IND" },
300 { RSL_MT_SACCH_FILL, "SACCH_FILL" },
301 { RSL_MT_OVERLOAD, "OVERLOAD" },
302 { RSL_MT_ERROR_REPORT, "ERROR_REPORT" },
303 { RSL_MT_SMS_BC_CMD, "SMS_BC_CMD" },
304 { RSL_MT_CBCH_LOAD_IND, "CBCH_LOAD_IND" },
305 { RSL_MT_NOT_CMD, "NOTIFY_CMD" },
306
307 { RSL_MT_CHAN_ACTIV, "CHAN_ACTIV" },
308 { RSL_MT_CHAN_ACTIV_ACK, "CHAN_ACTIV_ACK" },
309 { RSL_MT_CHAN_ACTIV_NACK, "CHAN_ACTIV_NACK" },
310 { RSL_MT_CONN_FAIL, "CONN_FAIL" },
311 { RSL_MT_DEACTIVATE_SACCH, "DEACTIVATE_SACCH" },
312 { RSL_MT_ENCR_CMD, "ENCR_CMD" },
313 { RSL_MT_HANDO_DET, "HANDOVER_DETECT" },
314 { RSL_MT_MEAS_RES, "MEAS_RES" },
315 { RSL_MT_MODE_MODIFY_REQ, "MODE_MODIFY_REQ" },
316 { RSL_MT_MODE_MODIFY_ACK, "MODE_MODIFY_ACK" },
317 { RSL_MT_MODE_MODIFY_NACK, "MODE_MODIFY_NACK" },
318 { RSL_MT_PHY_CONTEXT_REQ, "PHY_CONTEXT_REQ" },
319 { RSL_MT_PHY_CONTEXT_CONF, "PHY_CONTEXT_CONF" },
320 { RSL_MT_RF_CHAN_REL, "RF_CHAN_REL" },
321 { RSL_MT_MS_POWER_CONTROL, "MS_POWER_CONTROL" },
322 { RSL_MT_BS_POWER_CONTROL, "BS_POWER_CONTROL" },
323 { RSL_MT_PREPROC_CONFIG, "PREPROC_CONFIG" },
324 { RSL_MT_PREPROC_MEAS_RES, "PREPROC_MEAS_RES" },
325 { RSL_MT_RF_CHAN_REL_ACK, "RF_CHAN_REL_ACK" },
326 { RSL_MT_SACCH_INFO_MODIFY, "SACCH_INFO_MODIFY" },
327 { RSL_MT_TALKER_DET, "TALKER_DETECT" },
328 { RSL_MT_LISTENER_DET, "LISTENER_DETECT" },
329 { RSL_MT_REMOTE_CODEC_CONF_REP, "REM_CODEC_CONF_REP" },
330 { RSL_MT_RTD_REP, "RTD_REQ" },
331 { RSL_MT_PRE_HANDO_NOTIF, "HANDO_NOTIF" },
332 { RSL_MT_MR_CODEC_MOD_REQ, "CODEC_MOD_REQ" },
333 { RSL_MT_MR_CODEC_MOD_ACK, "CODEC_MOD_ACK" },
334 { RSL_MT_MR_CODEC_MOD_NACK, "CODEC_MOD_NACK" },
335 { RSL_MT_MR_CODEC_MOD_PER, "CODEC_MODE_PER" },
336 { RSL_MT_TFO_REP, "TFO_REP" },
337 { RSL_MT_TFO_MOD_REQ, "TFO_MOD_REQ" },
338 { RSL_MT_LOCATION_INFO, "LOCATION_INFO" },
339 { 0, NULL }
340};
341
342
Harald Welte8f2c7e52011-08-17 18:52:03 +0200343/*! \brief Get human-readable string for RSL Message Type */
Harald Weltecf7e5da2011-06-23 20:43:13 +0200344const char *rsl_msg_name(uint8_t msg_type)
345{
346 return get_value_string(rsl_msgt_names, msg_type);
347}
348
Harald Weltea24026a2011-09-02 12:26:50 +0200349/*! \brief ip.access specific */
350static const struct value_string rsl_ipac_msgt_names[] = {
351 { RSL_MT_IPAC_PDCH_ACT, "IPAC_PDCH_ACT" },
352 { RSL_MT_IPAC_PDCH_ACT_ACK, "IPAC_PDCH_ACT_ACK" },
353 { RSL_MT_IPAC_PDCH_ACT_NACK, "IPAC_PDCH_ACT_NACK" },
354 { RSL_MT_IPAC_PDCH_DEACT, "IPAC_PDCH_DEACT" },
355 { RSL_MT_IPAC_PDCH_DEACT_ACK, "IPAC_PDCH_DEACT_ACK" },
356 { RSL_MT_IPAC_PDCH_DEACT_NACK, "IPAC_PDCH_DEACT_NACK" },
357 { RSL_MT_IPAC_CONNECT_MUX, "IPAC_CONNECT_MUX" },
358 { RSL_MT_IPAC_CONNECT_MUX_ACK, "IPAC_CONNECT_MUX_ACK" },
359 { RSL_MT_IPAC_CONNECT_MUX_NACK, "IPAC_CONNECT_MUX_NACK" },
360 { RSL_MT_IPAC_BIND_MUX, "IPAC_BIND_MUX" },
361 { RSL_MT_IPAC_BIND_MUX_ACK, "IPAC_BIND_MUX_ACK" },
362 { RSL_MT_IPAC_BIND_MUX_NACK, "IPAC_BIND_MUX_NACK" },
363 { RSL_MT_IPAC_DISC_MUX, "IPAC_DISC_MUX" },
364 { RSL_MT_IPAC_DISC_MUX_ACK, "IPAC_DISC_MUX_ACK" },
365 { RSL_MT_IPAC_DISC_MUX_NACK, "IPAC_DISC_MUX_NACK" },
366 { RSL_MT_IPAC_CRCX, "IPAC_CRCX" },
367 { RSL_MT_IPAC_CRCX_ACK, "IPAC_CRCX_ACK" },
368 { RSL_MT_IPAC_CRCX_NACK, "IPAC_CRCX_NACK" },
369 { RSL_MT_IPAC_MDCX, "IPAC_MDCX" },
370 { RSL_MT_IPAC_MDCX_ACK, "IPAC_MDCX_ACK" },
371 { RSL_MT_IPAC_MDCX_NACK, "IPAC_MDCX_NACK" },
372 { RSL_MT_IPAC_DLCX_IND, "IPAC_DLCX_IND" },
373 { RSL_MT_IPAC_DLCX, "IPAC_DLCX" },
374 { RSL_MT_IPAC_DLCX_ACK, "IPAC_DLCX_ACK" },
375 { RSL_MT_IPAC_DLCX_NACK, "IPAC_DLCX_NACK" },
376 { 0, NULL }
377};
378
379/*! \brief Get human-readable name of ip.access RSL msg type */
380const char *rsl_ipac_msg_name(uint8_t msg_type)
381{
382 return get_value_string(rsl_ipac_msgt_names, msg_type);
383}
384
Harald Welte52b4abd2010-03-25 12:11:38 +0800385static const struct value_string rsl_rlm_cause_strs[] = {
Harald Welted284cd92010-03-01 21:58:31 +0100386 { RLL_CAUSE_T200_EXPIRED, "Timer T200 expired (N200+1) times" },
387 { RLL_CAUSE_REEST_REQ, "Re-establishment request" },
388 { RLL_CAUSE_UNSOL_UA_RESP, "Unsolicited UA response" },
389 { RLL_CAUSE_UNSOL_DM_RESP, "Unsolicited DM response" },
390 { RLL_CAUSE_UNSOL_DM_RESP_MF, "Unsolicited DM response, multiple frame" },
391 { RLL_CAUSE_UNSOL_SPRV_RESP, "Unsolicited supervisory response" },
392 { RLL_CAUSE_SEQ_ERR, "Sequence Error" },
393 { RLL_CAUSE_UFRM_INC_PARAM, "U-Frame with incorrect parameters" },
394 { RLL_CAUSE_SFRM_INC_PARAM, "S-Frame with incorrect parameters" },
395 { RLL_CAUSE_IFRM_INC_MBITS, "I-Frame with incorrect use of M bit" },
396 { RLL_CAUSE_IFRM_INC_LEN, "I-Frame with incorrect length" },
Holger Hans Peter Freyther9ac45372013-06-11 17:54:56 +0200397 { RLL_CAUSE_FRM_UNIMPL, "Frame not implemented" },
Harald Welted284cd92010-03-01 21:58:31 +0100398 { RLL_CAUSE_SABM_MF, "SABM command, multiple frame established state" },
399 { RLL_CAUSE_SABM_INFO_NOTALL, "SABM frame with information not allowed in this state" },
400 { 0, NULL },
401};
402
Harald Welte8f2c7e52011-08-17 18:52:03 +0200403/*! \brief Get human-readable string for RLM cause */
Harald Welte52b4abd2010-03-25 12:11:38 +0800404const char *rsl_rlm_cause_name(uint8_t err)
Harald Welted284cd92010-03-01 21:58:31 +0100405{
Harald Welte52b4abd2010-03-25 12:11:38 +0800406 return get_value_string(rsl_rlm_cause_strs, err);
Harald Welted284cd92010-03-01 21:58:31 +0100407}
408
409/* Section 3.3.2.3 TS 05.02. I think this looks like a table */
410int rsl_ccch_conf_to_bs_cc_chans(int ccch_conf)
411{
412 switch (ccch_conf) {
413 case RSL_BCCH_CCCH_CONF_1_NC:
414 return 1;
415 case RSL_BCCH_CCCH_CONF_1_C:
416 return 1;
417 case RSL_BCCH_CCCH_CONF_2_NC:
418 return 2;
419 case RSL_BCCH_CCCH_CONF_3_NC:
420 return 3;
421 case RSL_BCCH_CCCH_CONF_4_NC:
422 return 4;
423 default:
424 return -1;
425 }
426}
427
428/* Section 3.3.2.3 TS 05.02 */
429int rsl_ccch_conf_to_bs_ccch_sdcch_comb(int ccch_conf)
430{
431 switch (ccch_conf) {
432 case RSL_BCCH_CCCH_CONF_1_NC:
433 return 0;
434 case RSL_BCCH_CCCH_CONF_1_C:
435 return 1;
436 case RSL_BCCH_CCCH_CONF_2_NC:
437 return 0;
438 case RSL_BCCH_CCCH_CONF_3_NC:
439 return 0;
440 case RSL_BCCH_CCCH_CONF_4_NC:
441 return 0;
442 default:
443 return -1;
444 }
445}
Harald Weltef08eabf2010-03-02 21:59:20 +0100446
Harald Welte8f2c7e52011-08-17 18:52:03 +0200447/*! \brief Push a RSL RLL header onto an existing msgb */
Harald Welte6eb7d6c2010-07-13 13:48:13 +0200448void rsl_rll_push_hdr(struct msgb *msg, uint8_t msg_type, uint8_t chan_nr,
449 uint8_t link_id, int transparent)
Harald Weltef08eabf2010-03-02 21:59:20 +0100450{
Harald Weltef08eabf2010-03-02 21:59:20 +0100451 struct abis_rsl_rll_hdr *rh;
452
Harald Weltef08eabf2010-03-02 21:59:20 +0100453 rh = (struct abis_rsl_rll_hdr *) msgb_push(msg, sizeof(*rh));
454 rsl_init_rll_hdr(rh, msg_type);
Harald Welteeb8bf392010-03-04 10:32:09 +0100455 if (transparent)
456 rh->c.msg_discr |= ABIS_RSL_MDISC_TRANSP;
Harald Weltef08eabf2010-03-02 21:59:20 +0100457 rh->chan_nr = chan_nr;
458 rh->link_id = link_id;
459
460 /* set the l2 header pointer */
461 msg->l2h = (uint8_t *)rh;
Harald Weltef08eabf2010-03-02 21:59:20 +0100462}
463
Harald Welte8f2c7e52011-08-17 18:52:03 +0200464/*! \brief Push a RSL RLL header with L3_INFO IE */
Harald Welte6eb7d6c2010-07-13 13:48:13 +0200465void rsl_rll_push_l3(struct msgb *msg, uint8_t msg_type, uint8_t chan_nr,
466 uint8_t link_id, int transparent)
467{
468 uint8_t l3_len = msg->tail - (uint8_t *)msgb_l3(msg);
469
470 /* construct a RSLms RLL message (DATA INDICATION, UNIT DATA
471 * INDICATION) and send it off via RSLms */
472
473 /* Push the L3 IE tag and lengh */
474 msgb_tv16_push(msg, RSL_IE_L3_INFO, l3_len);
475
476 /* Then push the RSL header */
477 rsl_rll_push_hdr(msg, msg_type, chan_nr, link_id, transparent);
478}
479
Harald Welte8f2c7e52011-08-17 18:52:03 +0200480/*! \brief Create msgb with RSL RLL header */
Harald Weltef08eabf2010-03-02 21:59:20 +0100481struct msgb *rsl_rll_simple(uint8_t msg_type, uint8_t chan_nr,
Harald Welteeb8bf392010-03-04 10:32:09 +0100482 uint8_t link_id, int transparent)
Harald Weltef08eabf2010-03-02 21:59:20 +0100483{
484 struct abis_rsl_rll_hdr *rh;
Harald Welteeb8bf392010-03-04 10:32:09 +0100485 struct msgb *msg;
486
487 msg = msgb_alloc_headroom(RSL_ALLOC_SIZE+RSL_ALLOC_HEADROOM,
488 RSL_ALLOC_HEADROOM, "rsl_rll_simple");
Harald Weltef08eabf2010-03-02 21:59:20 +0100489
490 if (!msg)
491 return NULL;
492
493 /* put the RSL header */
494 rh = (struct abis_rsl_rll_hdr *) msgb_put(msg, sizeof(*rh));
495 rsl_init_rll_hdr(rh, msg_type);
Harald Welteeb8bf392010-03-04 10:32:09 +0100496 if (transparent)
497 rh->c.msg_discr |= ABIS_RSL_MDISC_TRANSP;
Harald Weltef08eabf2010-03-02 21:59:20 +0100498 rh->chan_nr = chan_nr;
499 rh->link_id = link_id;
500
501 /* set the l2 header pointer */
502 msg->l2h = (uint8_t *)rh;
503
504 return msg;
505}
Harald Welte8f2c7e52011-08-17 18:52:03 +0200506
Sylvain Munautdca7d2c2012-04-18 21:53:23 +0200507/*! @} */