Rename the routines that handle dissector tables with unsigned integer
[obnox/wireshark/wip.git] / epan / dissectors / packet-rsl.c
1 /* packet-rsl.c
2  * Routines for Radio Signalling Link (RSL) dissection.
3  *
4  * Copyright 2007, Anders Broman <anders.broman@ericsson.com>
5  *
6  * $Id$
7  *
8  * Wireshark - Network traffic analyzer
9  * By Gerald Combs <gerald@wireshark.org>
10  * Copyright 1998 Gerald Combs
11  *
12  * Copied from packet-cops.c
13  *
14  * This program is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU General Public License
16  * as published by the Free Software Foundation; either version 2
17  * of the License, or (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software
26  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
27  *
28  * REF: 3GPP TS 48.058 version 6.1.0 Release 6
29  * http://www.3gpp.org/ftp/Specs/html-info/48058.htm
30  *
31  */
32
33 #ifdef HAVE_CONFIG_H
34 # include "config.h"
35 #endif
36
37 #include <stdlib.h>
38 #include <ctype.h>
39
40 #include <epan/packet.h>
41 #include <epan/proto.h>
42 #include <epan/lapd_sapi.h>
43
44 #include "packet-gsm_a_common.h"
45
46 /* Initialize the protocol and registered fields */
47 static int proto_rsl            = -1;
48
49 static int hf_rsl_msg_type                      = -1;
50 static int hf_rsl_T_bit                         = -1;
51 static int hf_rsl_msg_dsc                       = -1;
52 static int hf_rsl_ie_id                         = -1;
53 static int hf_rsl_ie_length                     = -1;
54 static int hf_rsl_ch_no_Cbits           = -1;
55 static int hf_rsl_ch_no_TN                      = -1;
56 static int hf_rsl_acc_delay                     = -1;
57 static int hf_rsl_rach_slot_cnt         = -1;
58 static int hf_rsl_rach_busy_cnt         = -1;
59 static int hf_rsl_rach_acc_cnt          = -1;
60 static int hf_rsl_req_ref_ra            = -1;
61 static int hf_rsl_req_ref_T1prim        = -1;
62 static int hf_rsl_req_ref_T3            = -1;
63 static int hf_rsl_req_ref_T2            = -1;
64 static int hf_rsl_timing_adv            = -1;
65 static int hf_rsl_ho_ref                        = -1;
66 static int hf_rsl_l1inf_power_lev               = -1;
67 static int hf_rsl_l1inf_fpc                     = -1;
68 static int hf_rsl_ms_power_lev          = -1;
69 static int hf_rsl_ms_fpc                        = -1;
70 static int hf_rsl_act_timing_adv        = -1;
71 static int hf_rsl_phy_ctx                       = -1;
72 static int hf_rsl_na                            = -1;
73 static int hf_rsl_ch_type                       = -1;
74 static int hf_rsl_prio                          = -1;
75 static int hf_rsl_sapi                          = -1;
76 static int hf_rsl_rbit                          = -1;
77 static int hf_rsl_a3a2                          = -1;
78 static int hf_rsl_a1_0                          = -1;
79 static int hf_rsl_a1_1                          = -1;
80 static int hf_rsl_a1_2                          = -1;
81 static int hf_rsl_epc_mode                      = -1;
82 static int hf_rsl_bs_fpc_epc_mode       = -1;
83 static int hf_rsl_bs_power                      = -1;
84 static int hf_rsl_cm_dtxd                       = -1;
85 static int hf_rsl_cm_dtxu                       = -1;
86 static int hf_rsl_speech_or_data        = -1;
87 static int hf_rsl_ch_rate_and_type      = -1;
88 static int hf_rsl_speech_coding_alg = -1;
89 static int hf_rsl_t_nt_bit                      = -1;
90 static int hf_rsl_ra_if_data_rte        = -1;
91 static int hf_rsl_data_rte                      = -1;
92 static int hf_rsl_alg_id                        = -1;
93 static int hf_rsl_key                           = -1;
94 static int hf_rsl_cause                         = -1;
95 static int hf_rsl_rel_mode                      = -1;
96 static int hf_rsl_interf_band           = -1;
97 static int hf_rsl_interf_band_reserved = -1;
98 static int hf_rsl_meas_res_no           = -1;
99 static int hf_rsl_extension_bit         = -1;
100 static int hf_rsl_dtxd                          = -1;
101 static int hf_rsl_rxlev_full_up         = -1;
102 static int hf_rsl_rxlev_sub_up          = -1;
103 static int hf_rsl_rxqual_full_up        = -1;
104 static int hf_rsl_rxqual_sub_up         = -1;
105 static int hf_rsl_class                         = -1;
106 static int hf_rsl_paging_grp            = -1;
107 static int hf_rsl_paging_load           = -1;
108 static int hf_rsl_sys_info_type         = -1;
109 static int hf_rsl_timing_offset         = -1;
110 static int hf_rsl_ch_needed                     = -1;
111 static int hf_rsl_cbch_load_type        = -1;
112 static int hf_rsl_msg_slt_cnt           = -1;
113 static int hf_rsl_ch_ind                        = -1;
114 static int hf_rsl_command                       = -1;
115 static int hf_rsl_emlpp_prio            = -1;
116 static int hf_rsl_rtd                           = -1;
117 static int hf_rsl_delay_ind                     = -1;
118 static int hf_rsl_tfo                           = -1;
119
120 /* Initialize the subtree pointers */
121 static int ett_rsl = -1;
122 static int ett_ie_link_id = -1;
123 static int ett_ie_act_type = -1;
124 static int ett_ie_bs_power = -1;
125 static int ett_ie_ch_id = -1;
126 static int ett_ie_ch_mode = -1;
127 static int ett_ie_enc_inf = -1;
128 static int ett_ie_ch_no = -1;
129 static int ett_ie_frame_no = -1;
130 static int ett_ie_ho_ref = -1;
131 static int ett_ie_l1_inf = -1;
132 static int ett_ie_L3_inf = -1;
133 static int ett_ie_ms_id = -1;
134 static int ett_ie_ms_pow = -1;
135 static int ett_ie_phy_ctx = -1;
136 static int ett_ie_paging_grp = -1;
137 static int ett_ie_paging_load = -1;
138 static int ett_ie_access_delay = -1;
139 static int ett_ie_rach_load = -1;
140 static int ett_ie_req_ref = -1;
141 static int ett_ie_rel_mode = -1;
142 static int ett_ie_resource_inf = -1;
143 static int ett_ie_rlm_cause     =-1;
144 static int ett_ie_staring_time = -1;
145 static int ett_ie_timing_adv = -1;
146 static int ett_ie_uplink_meas = -1;
147 static int ett_ie_full_imm_ass_inf = -1;
148 static int ett_ie_smscb_inf = -1;
149 static int ett_ie_ms_timing_offset = -1;
150 static int ett_ie_err_msg = -1;
151 static int ett_ie_full_bcch_inf = -1;
152 static int ett_ie_ch_needed = -1;
153 static int ett_ie_cb_cmd_type = -1;
154 static int ett_ie_smscb_mess = -1;
155 static int ett_ie_cbch_load_inf = -1;
156 static int ett_ie_smscb_ch_ind = -1;
157 static int ett_ie_grp_call_ref = -1;
158 static int ett_ie_ch_desc = -1;
159 static int ett_ie_nch_drx = -1;
160 static int ett_ie_cmd_ind = -1;
161 static int ett_ie_emlpp_prio = -1;
162 static int ett_ie_uic = -1;
163 static int ett_ie_main_ch_ref = -1;
164 static int ett_ie_multirate_conf = -1;
165 static int ett_ie_multirate_cntrl = -1;
166 static int ett_ie_sup_codec_types = -1;
167 static int ett_ie_codec_conf = -1;
168 static int ett_ie_rtd = -1;
169 static int ett_ie_tfo_status = -1;
170 static int ett_ie_llp_apdu = -1;
171 static int ett_ie_tfo_transp_cont = -1;
172 static int ett_ie_cause = -1;
173 static int ett_ie_meas_res_no = -1;
174 static int ett_ie_message_id = -1;
175 static int ett_ie_sys_info_type = -1;
176
177 static proto_tree *top_tree;
178 static dissector_handle_t gsm_a_ccch_handle;
179 static dissector_handle_t gsm_a_dtap_handle;
180
181 static gboolean is_si2q = FALSE;
182
183 /* Forward declarations */
184 static int dissct_rsl_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset);
185
186 static const true_false_string rsl_t_bit_vals = {
187   "Considered transparent by BTS",
188   "Not considered transparent by BTS"
189 };
190
191 static const true_false_string rsl_na_vals = {
192   "Not Applicable",
193   "Applicable"
194 };
195
196 static const true_false_string rsl_extension_bit_value = {
197   "Extension",
198   "No Extension"
199 };
200
201 /*
202  * 9.1 Message discriminator
203  */
204 static const value_string rsl_msg_disc_vals[] = {
205         {  0x00,                "Reserved" },
206         {  0x01,                "Radio Link Layer Management messages" },
207         {  0x04,                "Dedicated Channel Management messages" },
208         {  0x06,                "Common Channel Management messages" },
209         {  0x08,                "TRX Management messages" },
210         {  0x16,                "Location Services messages" },
211         { 0,                    NULL }
212 };
213 /*
214  * 9.2 MESSAGE TYPE
215  */
216 #define RSL_MSG_TYPE_DATA_REQ           1
217 #define RSL_MSG_TYPE_DATA_IND           2
218 #define RSL_MSG_TYPE_ERROR_IND          3
219 #define RSL_MSG_TYPE_EST_REQ            4
220 #define RSL_MSG_TYPE_EST_CONF           5
221 #define RSL_MSG_EST_IND                         6
222 #define RSL_MSG_REL_REQ                         7
223 #define RSL_MSG_REL_CONF                        8
224 #define RSL_MSG_REL_IND                         9
225 #define RSL_MSG_UNIT_DATA_REQ           10
226 /* Common Channel Management/TRX Management messages */
227 #define RSL_MSG_BCCH_INFO                       17
228 #define RSL_MSG_CCCH_LOAD_IND           18
229 #define RSL_MSG_CHANRQD                         19
230 #define RSL_MSG_DELETE_IND                      20
231 #define RSL_MSG_PAGING_CMD                      21
232 #define RSL_MSG_IMM_ASS_CMD                     22
233 #define RSL_MSG_SMS_BC_REQ                      23      /* 8.5.7 */
234 #define RSL_MSG_RF_RES_IND                      25      /* 8.6.1 */
235 #define RSL_MSG_SACCH_FILL                      26      /* 8.6.2 */
236
237 #define RSL_MSG_OVERLOAD                        27      /* 8.6.3 */
238 #define RSL_MSG_ERROR_REPORT            28      /* 8.6.4 */
239 #define RSL_MSG_SMS_BC_CMD                      29      /* 8.5.8 */
240 #define RSL_MSG_CBCH_LOAD_IND           30      /* 8.5.9 */
241 #define RSL_MSG_NOT_CMD                         31      /* 8.5.10 */
242
243 /* 0 0 1 - - - - - Dedicated Channel Management messages: */
244 #define RSL_MSG_CHAN_ACTIV                      33
245 #define RSL_MSG_CHAN_ACTIV_ACK          34
246 #define RSL_MSG_CHAN_ACTIV_N_ACK        35
247 #define RSL_MSG_CONN_FAIL                       36
248 #define RSL_MSG_DEACTIVATE_SACCH        37
249
250 #define RSL_MSG_ENCR_CMD                                38      /* 8.4.6 */
251 #define RSL_MSG_HANDODET                                39      /* 8.4.7 */
252 #define RSL_MSG_MEAS_RES                                40      /* 8.4.8 */
253 #define RSL_MSG_MODE_MODIFY_REQ                 41      /* 8.4.9 */
254 #define RSL_MSG_MODE_MODIFY_ACK                 42      /* 8.4.10 */
255 #define RSL_MSG_MODE_MODIFY_NACK                43      /* 8.4.11 */
256 #define RSL_MSG_PHY_CONTEXT_REQ                 44      /* 8.4.12 */
257 #define RSL_MSG_PHY_CONTEXT_CONF                45      /* 8.4.13 */
258 #define RSL_MSG_RF_CHAN_REL                             46      /* 8.4.14 */
259 #define RSL_MSG_MS_POWER_CONTROL                47      /* 8.4.15 */
260 #define RSL_MSG_BS_POWER_CONTROL                48      /* 8.4.16 */
261 #define RSL_MSG_PREPROC_CONFIG                  49      /* 8.4.17 */
262 #define RSL_MSG_PREPROC_MEAS_RES                50      /* 8.4.18 */
263 #define RSL_MSG_RF_CHAN_REL_ACK                 51      /* 8.4.19 */
264 #define RSL_MSG_SACCH_INFO_MODIFY               52      /* 8.4.20 */
265 #define RSL_MSG_TALKER_DET                              53      /* 8.4.21 */
266 #define RSL_MSG_LISTENER_DET                    54      /* 8.4.22 */
267 #define RSL_MSG_REMOTE_CODEC_CONF_REP   55      /* 8.4.23 */
268 #define RSL_MSG_R_T_D_REP                               56      /* 8.4.24 */
269 #define RSL_MSG_PRE_HANDO_NOTIF                 57      /* 8.4.25 */
270 #define RSL_MSG_MR_CODEC_MOD_REQ                58      /* 8.4.26 */
271 #define RSL_MSG_MR_CODEC_MOD_ACK                59      /* 8.4.27 */
272 #define RSL_MSG_MR_CODEC_MOD_NACK               60      /* 8.4.28 */
273 #define RSL_MSG_MR_CODEC_MOD_PER                61      /* 8.4.29 */
274 #define RSL_MSG_TFO_REP                                 62      /* 8.4.30 */
275 #define RSL_MSG_TFO_MOD_REQ                             63      /* 8.4.31 */
276         /*      0 1 - - - - - - Location Services messages: */
277 #define RSL_MSG_LOC_INF                                 65      /* 8.7.1 */
278
279
280 static const value_string rsl_msg_type_vals[] = {
281           /*    0 0 0 0 - - - - Radio Link Layer Management messages: */
282         {  0x01,        "DATA REQuest" },                                                               /* 8.3.1 */
283         {  0x02,        "DATA INDication" },                                                    /* 8.3.2 */
284         {  0x03,        "ERROR INDication" },                                                   /* 8.3.3 */
285         {  0x04,        "ESTablish REQuest" },                                                  /* 8.3.4 */
286         {  0x05,        "ESTablish CONFirm" },                                                  /* 8.3.5 */
287         {  0x06,        "ESTablish INDication" },                                               /* 8.3.6 */
288         {  0x07,        "RELease REQuest" },                                                    /* 8.3.7 */
289         {  0x08,        "RELease CONFirm" },                                                    /* 8.3.8 */
290         {  0x09,        "RELease INDication" },                                                 /* 8.3.9 */
291         {  0x0a,        "UNIT DATA REQuest" },                                                  /* 8.3.10 */
292         /* 0 0 0 1 - - - - Common Channel Management/TRX Management messages: */
293         {  0x11,        "BCCH INFOrmation" },                                                   /* 8.5.1 */
294         {  0x12,        "CCCH LOAD INDication" },                                               /* 8.5.2 */
295         {  0x13,        "CHANnel ReQuireD" },                                                   /* 8.5.3 */
296         {  0x14,        "DELETE INDication" },                                                  /* 8.5.4 */
297         {  0x15,        "PAGING CoMmanD" },                                                             /* 8.5.5 */
298         {  0x16,        "IMMEDIATE ASSIGN COMMAND" },                                   /* 8.5.6 */
299         {  0x17,        "SMS BroadCast REQuest" },                                              /* 8.5.7 */
300         {  0x19,        "RF RESource INDication" },                                             /* 8.6.1 */
301         {  0x1a,        "SACCH FILLing" },                                                              /* 8.6.2 */
302         {  0x1b,        "OVERLOAD" },                                                                   /* 8.6.3 */
303         {  0x1c,        "ERROR REPORT" },                                                               /* 8.6.4 */
304         {  0x1d,        "SMS BroadCast CoMmanD" },                                              /* 8.5.8 */
305         {  0x1e,        "CBCH LOAD INDication" },                                               /* 8.5.9 */
306         {  0x1f,        "NOTification CoMmanD" },                                               /* 8.5.10 */
307         /* 0 0 1 - - - - - Dedicated Channel Management messages: */
308         {  0x21,        "CHANnel ACTIVation" },                                                 /* 8.4.1 */
309         {  0x22,        "CHANnel ACTIVation ACKnowledge" },                             /* 8.4.2 */
310         {  0x23,        "CHANnel ACTIVation Negative ACK" },                    /* 8.4.3 */
311         {  0x24,        "CONNection FAILure" },                                                 /* 8.4.4 */
312         {  0x25,        "DEACTIVATE SACCH" },                                                   /* 8.4.5 */
313         {  0x26,        "ENCRyption CoMmanD" },                                                 /* 8.4.6 */
314         {  0x27,        "HANDOver DETection" },                                                 /* 8.4.7 */
315         {  0x28,        "MEASurement RESult" },                                                 /* 8.4.8 */
316         {  0x29,        "MODE MODIFY REQuest" },                                                /* 8.4.9 */
317         {  0x2a,        "MODE MODIFY ACKnowledge" },                                    /* 8.4.10 */
318         {  0x2b,        "MODE MODIFY Negative ACKnowledge" },                   /* 8.4.11 */
319         {  0x2c,        "PHYsical CONTEXT REQuest" },                                   /* 8.4.12 */
320         {  0x2d,        "PHYsical CONTEXT CONFirm" },                                   /* 8.4.13 */
321         {  0x2e,        "RF CHANnel RELease" },                                                 /* 8.4.14 */
322         {  0x2f,        "MS POWER CONTROL" },                                                   /* 8.4.15 */
323         {  0x30,        "BS POWER CONTROL" },                                                   /* 8.4.16 */
324         {  0x31,        "PREPROCess CONFIGure" },                                               /* 8.4.17 */
325         {  0x32,        "PREPROCessed MEASurement RESult" },                    /* 8.4.18 */
326         {  0x33,        "RF CHANnel RELease ACKnowledge" },                             /* 8.4.19 */
327         {  0x34,        "SACCH INFO MODIFY" },                                                  /* 8.4.20 */
328         {  0x35,        "TALKER DETection" },                                                   /* 8.4.21 */
329         {  0x36,        "LISTENER DETection" },                                                 /* 8.4.22 */
330         {  0x37,        "REMOTE CODEC CONFiguration REPort" },                  /* 8.4.23 */
331         {  0x38,        "Round Trip Delay REPort" },                                    /* 8.4.24 */
332         {  0x39,        "PRE-HANDOver NOTIFication" },                                  /* 8.4.25 */
333         {  0x3a,        "MultiRate CODEC MODification REQest" },                /* 8.4.26 */
334         {  0x3b,        "MultiRate CODEC MOD ACKnowledge" },                    /* 8.4.27 */
335         {  0x3c,        "MultiRate CODEC MOD Negative ACKnowledge" },   /* 8.4.28 */
336         {  0x3d,        "MultiRate CODEC MOD PERformed" },                              /* 8.4.29 */
337         {  0x3e,        "TFO REPort" },                                                                 /* 8.4.30 */
338         {  0x3f,        "TFO MODification REQuest" },                                   /* 8.4.31 */
339         /*      0 1 - - - - - - Location Services messages: */
340         {  0x41,        "Location Information" },                                               /* 8.7.1 */
341         { 0,            NULL }
342 };
343
344 #define RSL_IE_CH_NO                    1
345 #define RSL_IE_LINK_ID                  2
346 #define RSL_IE_ACT_TYPE                 3
347 #define RSL_IE_BS_POW                   4
348 #define RSL_IE_CH_ID                    5
349 #define RSL_IE_CH_MODE                  6
350 #define RSL_IE_ENC_INF                  7
351 #define RSL_IE_FRAME_NO                 8
352 #define RSL_IE_HO_REF                   9
353 #define RSL_IE_L1_INF                   10
354 #define RSL_IE_L3_INF                   11
355 #define RSL_IE_MS_ID                    12
356 #define RSL_IE_MS_POW                   13
357 #define RSL_IE_PAGING_GRP               14
358 #define RSL_IE_PAGING_LOAD              15
359 #define RSL_IE_PHY_CTX                  16
360 #define RSL_IE_ACCESS_DELAY             17
361 #define RSL_IE_RACH_LOAD                18
362 #define RSL_IE_REQ_REF                  19
363 #define RSL_IE_REL_MODE                 20
364 #define RSL_IE_RESOURCE_INF             21
365 #define RSL_IE_RLM_CAUSE                22
366 #define RSL_IE_STARTING_TIME    23
367 #define RSL_IE_TIMING_ADV               24
368 #define RSL_IE_UPLINK_MEAS              25
369 #define RSL_IE_CAUSE                    26
370 #define RSL_IE_MEAS_RES_NO              27
371 #define RSL_IE_MESSAGE_ID               28
372
373 #define RSL_IE_SYS_INFO_TYPE    30
374
375
376
377
378 #define RSL_IE_FULL_IMM_ASS_INF                 35
379 #define RSL_IE_SMSCB_INF                                36
380 #define RSL_IE_FULL_MS_TIMING_OFFSET    37
381 #define RSL_IE_ERR_MSG                                  38
382 #define RSL_IE_FULL_BCCH_INF                    39
383 #define RSL_IE_CH_NEEDED                                40
384 #define RSL_IE_CB_CMD_TYPE                              41
385 #define RSL_IE_SMSCB_MESS                               42
386 #define RSL_IE_CBCH_LOAD_INF                    43
387
388
389 #define RSL_IE_SMSCB_CH_IND                             46
390 #define RSL_IE_GRP_CALL_REF                             47
391 #define RSL_IE_CH_DESC                                  48
392 #define RSL_IE_NCH_DRX_INF                              49
393 #define RSL_IE_CMD_IND                                  50
394 #define RSL_IE_EMLPP_PRIO                               51
395 #define RSL_IE_UIC                                              52
396 #define RSL_IE_MAIN_CH_REF                              53
397 #define RSL_IE_MULTIRATE_CONF                   54
398 #define RSL_IE_MULTIRATE_CNTRL                  55
399 #define RSL_IE_SUP_CODEC_TYPES                  56
400 #define RSL_IE_CODEC_CONF                               57
401 #define RSL_IE_RTD                                              58
402 #define RSL_IE_TFO_STATUS                               59
403 #define RSL_IE_LLP_APDU                                 60
404 #define RSL_IE_TFO_TRANSP_CONT                  61
405
406 static const value_string rsl_ie_type_vals[] = {
407         {  0x01,        "Channel Number" },                             /*  9.3.1 */
408         {  0x02,        "Link Identifier" },                    /*  9.3.2 */
409         {  0x03,        "Activation Type" },                    /*  9.3.3 */
410         {  0x04,        "BS Power" },                                   /*  9.3.4 */
411         {  0x05,        "Channel Identification" },             /*  9.3.5 */
412         {  0x06,        "Channel Mode" },                               /*  9.3.6 */
413         {  0x07,        "Encryption Information" },             /*  9.3.7 */
414         {  0x08,        "Frame Number" },                               /*  9.3.8 */
415         {  0x09,        "Handover Reference" },                 /*  9.3.9 */
416         {  0x0a,        "L1 Information" },                             /*  9.3.10 */
417         {  0x0b,        "L3 Information" },                             /*  9.3.11 */
418         {  0x0c,        "MS Identity" },                                /*  9.3.12 */
419         {  0x0d,        "MS Power" },                                   /*  9.3.13 */
420         {  0x0e,        "Paging Group" },                               /*  9.3.14 */
421         {  0x0f,        "Paging Load" },                                /*  9.3.15 */
422         {  0x10,        "Physical Context" },                   /*  9.3.16 */
423         {  0x11,        "Access Delay" },                               /*  9.3.17 */
424         {  0x12,        "RACH Load" },                                  /*  9.3.18 */
425         {  0x13,        "Request Reference" },                  /*  9.3.19 */
426         {  0x14,        "Release Mode" },                               /*  9.3.20 */
427         {  0x15,        "Resource Information" },               /*  9.3.21 */
428         {  0x16,        "RLM Cause" },                                  /*  9.3.22 */
429         {  0x17,        "Starting Time" },                              /*  9.3.23 */
430         {  0x18,        "Timing Advance" },                             /*  9.3.24 */
431         {  0x19,        "Uplink Measurements" },                /*  9.3.25 */
432         {  0x1a,        "Cause" },                                              /*  9.3.26 */
433         {  0x1b,        "Measurement Result Number" },  /*  9.3.27 */
434         {  0x1c,        "Message Identifier" },                 /*  9.3.28 */
435         {  0x1d,        "reserved" },                                   /*  */
436         {  0x1e,        "System Info Type" },                   /*  9.3.30 */
437         {  0x1f,        "MS Power Parameters" },                /*  9.3.31 */
438         {  0x20,        "BS Power Parameters" },                /*  9.3.32 */
439         {  0x21,        "Pre-processing Parameters" },  /*  9.3.33 */
440         {  0x22,        "Pre-processed Measurements" }, /*  9.3.34 */
441         {  0x23,        "reserved" },                                   /*  */
442         {  0x24,        "SMSCB Information" },                  /*  9.3.36 */
443         {  0x25,        "MS Timing Offset" },                   /*  9.3.37 */
444         {  0x26,        "Erroneous Message" },                  /*  9.3.38 */
445         {  0x27,        "Full BCCH Information" },              /*  9.3.39 */
446         {  0x28,        "Channel Needed" },                             /*  9.3.40 */
447         {  0x29,        "CB Command type" },                    /*  9.3.41 */
448         {  0x2a,        "SMSCB Message" },                              /*  9.3.42 */
449         {  0x2b,        "Full Immediate Assign Info" }, /*  9.3.35 */
450         {  0x2c,        "SACCH Information" },                  /*  9.3.29 */
451         {  0x2d,        "CBCH Load Information" },              /*  9.3.43 */
452         {  0x2e,        "SMSCB Channel Indicator" },    /*  9.3.44 */
453         {  0x2f,        "Group Call Reference" },               /*  9.3.45 */
454         {  0x30,        "Channel Description" },                /*  9.3.46 */
455         {  0x31,        "NCH DRX Information" },                /*  9.3.47 */
456         {  0x32,        "Command Indicator" },                  /*  9.3.48 */
457         {  0x33,        "eMLPP Priority" },                             /*  9.3.49 */
458         {  0x34,        "UIC" },                                                /*  9.3.50 */
459         {  0x35,        "Main Channel Reference" },             /*  9.3.51 */
460         {  0x36,        "MultiRate Configuration" },    /*  9.3.52 */
461         {  0x37,        "MultiRate Control" },                  /*  9.3.53 */
462         {  0x38,        "Supported Codec Types" },              /*  9.3.54 */
463         {  0x39,        "Codec Configuration" },                /*  9.3.55 */
464         {  0x3a,        "Round Trip Delay" },                   /*  9.3.56 */
465         {  0x3b,        "TFO Status" },                                 /*  9.3.57 */
466         {  0x3c,        "LLP APDU" },                                   /*  9.3.58 */
467         {  0x3d,        "TFO Transparent Container" },  /*  9.3.59 */
468         /*
469                         0 0 1 1 1 1 1 0
470                         to
471                         1 1 1 0 1 1 1 1
472                         Reserved for future use
473
474                         1 1 1 1 0 0 0 0
475                         to
476                         1 1 1 1 1 1 1 1
477                         Not used
478
479         */
480         { 0,                    NULL }
481 };
482
483
484 /*
485 C5      C4      C3      C2      C1
486 0       0       0       0       1       Bm + ACCH's
487 0       0       0       1       T       Lm + ACCH's
488 0       0       1       T       T       SDCCH/4 + ACCH
489 0       1       T       T       T       SDCCH/8 + ACCH
490 1       0       0       0       0       BCCH
491 1       0       0       0       1       Uplink CCCH (RACH)
492 1       0       0       1       0       Downlink CCCH (PCH + AGCH)
493 */
494 static const value_string rsl_ch_no_Cbits_vals[] = {
495         {  0x01,        "Bm + ACCH" },
496         {  0x02,        "Lm + ACCH (sub-chan 0)" },
497         {  0x03,        "Lm + ACCH (sub-chan 1)" },
498         {  0x04,        "SDCCH/4 + ACCH (sub-chan 0)" },
499         {  0x05,        "SDCCH/4 + ACCH (sub-chan 1)" },
500         {  0x06,        "SDCCH/4 + ACCH (sub-chan 2)" },
501         {  0x07,        "SDCCH/4 + ACCH (sub-chan 3)" },
502         {  0x08,        "SDCCH/8 + ACCH (sub-chan 0)" },
503         {  0x09,        "SDCCH/8 + ACCH (sub-chan 1)" },
504         {  0x0a,        "SDCCH/8 + ACCH (sub-chan 2)" },
505         {  0x0b,        "SDCCH/8 + ACCH (sub-chan 3)" },
506         {  0x0c,        "SDCCH/8 + ACCH (sub-chan 4)" },
507         {  0x0d,        "SDCCH/8 + ACCH (sub-chan 5)" },
508         {  0x0e,        "SDCCH/8 + ACCH (sub-chan 6)" },
509         {  0x0f,        "SDCCH/8 + ACCH (sub-chan 7)" },
510         {  0x10,        "BCCH" },
511         {  0x11,        "Uplink CCCH (RACH)" },
512         {  0x12,        "Downlink CCCH (PCH + AGCH)" },
513         { 0,                    NULL }
514 };
515
516 /* 9.3.1 Channel number                 9.3.1   M TV 2 */
517 static int
518 dissect_rsl_ie_ch_no(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
519 {
520         proto_item *ti;
521         proto_tree *ie_tree;
522         guint8 ie_id;
523
524         if(is_mandatory == FALSE){
525                 ie_id = tvb_get_guint8(tvb,offset);
526                 if (ie_id != RSL_IE_CH_NO)
527                         return offset;
528         }
529
530         ti = proto_tree_add_text(tree, tvb,offset,2,"Channel number IE ");
531         ie_tree = proto_item_add_subtree(ti, ett_ie_ch_no);
532
533
534         /* Element identifier */
535         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
536         offset++;
537         /* C-bits */
538         proto_tree_add_item(ie_tree, hf_rsl_ch_no_Cbits, tvb, offset, 1, FALSE);
539         /* TN is time slot number, binary represented as in 3GPP TS 45.002.
540          * 3 Bits
541          */
542         proto_tree_add_item(ie_tree, hf_rsl_ch_no_TN, tvb, offset, 1, FALSE);
543         offset++;
544         return offset;
545 }
546
547 static const value_string rsl_ch_type_vals[] = {
548         {  0x00,        "Main signalling channel (FACCH or SDCCH)" },
549         {  0x01,        "SACCH" },
550         { 0,                    NULL }
551 };
552
553 static const value_string rsl_prio_vals[] = {
554         {  0x00,        "Normal Priority" },
555         {  0x01,        "High Priority" },
556         {  0x02,        "Low Priority" },
557         { 0,                    NULL }
558 };
559
560 /*
561  * 9.3.2 Link Identifier M TV 2
562  */
563 static int
564 dissect_rsl_ie_link_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
565 {
566         proto_item *ti;
567         proto_tree *ie_tree;
568         guint8 octet;
569         guint8 ie_id;
570
571         if(is_mandatory == FALSE){
572                 ie_id = tvb_get_guint8(tvb,offset);
573                 if (ie_id != RSL_IE_LINK_ID)
574                         return offset;
575         }
576
577         ti = proto_tree_add_text(tree, tvb,offset,2, "Link Identifier IE ");
578         ie_tree = proto_item_add_subtree(ti, ett_ie_link_id);
579
580         /* Element identifier */
581         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
582         offset++;
583
584         octet = tvb_get_guint8(tvb,offset);
585
586         if((octet&0x20) == 0x20){
587                 /* Not applicable */
588                 proto_tree_add_item(ie_tree, hf_rsl_na, tvb, offset, 1, FALSE);
589                 return offset++;
590         }
591         /* channel type */
592         proto_tree_add_item(ie_tree, hf_rsl_ch_type, tvb, offset, 1, FALSE);
593         /* NA - Not applicable */
594         proto_tree_add_item(ie_tree, hf_rsl_na, tvb, offset, 1, FALSE);
595         /* Priority */
596         proto_tree_add_item(ie_tree, hf_rsl_prio, tvb, offset, 1, FALSE);
597         /* SAPI
598          * The SAPI field contains the SAPI value as defined in 3GPP TS 44.005.
599          */
600         proto_tree_add_item(ie_tree, hf_rsl_sapi, tvb, offset, 1, FALSE);
601         offset++;
602
603         return offset;
604 }
605
606 /*
607  * 9.3.3 Activation Type
608  */
609 static const true_false_string rsl_rbit_vals = {
610   "Reactivation",
611   "Initial activation"
612 };
613
614 static const value_string rsl_a3a2_vals[] = {
615         {  0x00,        "Activation related to intra-cell channel change" },
616         {  0x01,        "Activation related to inter-cell channel change (handover)" },
617         {  0x02,        "Activation related to secondary channels" },
618         { 0,                    NULL }
619 };
620
621 static const true_false_string rsl_a1_0_vals = {
622   "related to normal assignment procedure",
623   "related to immediate assignment procedure"
624 };
625
626 static const true_false_string rsl_a1_1_vals = {
627   "related to synchronous handover procedure",
628   "related to asynchronous handover procedure"
629 };
630
631 static const true_false_string rsl_a1_2_vals = {
632   "related to multislot configuration",
633   "related to additional assignment procedure"
634 };
635
636 static int
637 dissect_rsl_ie_act_type(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
638 {
639         proto_item *ti;
640         proto_tree *ie_tree;
641         guint8 ie_id;
642         guint   octet;
643
644         if(is_mandatory == FALSE){
645                 ie_id = tvb_get_guint8(tvb,offset);
646                 if (ie_id != RSL_IE_ACT_TYPE)
647                         return offset;
648         }
649
650         ti = proto_tree_add_text(tree, tvb,offset,2,"Activation Type IE ");
651         ie_tree = proto_item_add_subtree(ti, ett_ie_act_type);
652
653
654         /* Element identifier */
655         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
656         offset++;
657
658         /* The R bit indicates if the procedure is an initial activation or a reactivation. */
659         proto_tree_add_item(ie_tree, hf_rsl_rbit, tvb, offset, 1, FALSE);
660
661         /* The A-bits indicate the type of activation, which defines the access procedure
662          * and the operation of the data link layer
663          */
664         octet = (tvb_get_guint8(tvb,offset) & 0x06)>>1;
665         proto_tree_add_item(ie_tree, hf_rsl_a3a2, tvb, offset, 1, FALSE);
666         switch(octet){
667         case 0:
668                 /* Activation related to intra-cell channel change */
669                 proto_tree_add_item(ie_tree, hf_rsl_a1_0, tvb, offset, 1, FALSE);
670                 break;
671         case 1:
672                 /* Activation related to inter-cell channel change (handover) */
673                 proto_tree_add_item(ie_tree, hf_rsl_a1_1, tvb, offset, 1, FALSE);
674                 break;
675         case 2:
676                 /* Activation related to secondary channels */
677                 proto_tree_add_item(ie_tree, hf_rsl_a1_2, tvb, offset, 1, FALSE);
678                 break;
679         default:
680                 break;
681         }
682         offset++;
683
684         return offset;
685 }
686 /*
687  * 9.3.4 BS Power
688  */
689
690 static const true_false_string rsl_epc_mode_vals = {
691   "Channel in EPC mode",
692   "Channel not in EPC mode"
693 };
694
695 static const true_false_string rsl_fpc_epc_mode_vals = {
696   "Fast Power Control in use",
697   "Fast Power Control not in use"
698 };
699
700 static const value_string rsl_rlm_bs_power_vals[] = {
701         {  0x00,        "Pn" },
702         {  0x01,        "Pn - 2 dB" },
703         {  0x02,        "Pn - 4 dB" },
704         {  0x03,        "Pn - 6 dB" },
705         {  0x04,        "Pn - 8 dB" },
706         {  0x05,        "Pn - 10 dB" },
707         {  0x06,        "Pn - 12 dB" },
708         {  0x07,        "Pn - 14 dB" },
709         {  0x08,        "Pn - 16 dB" },
710         {  0x09,        "Pn - 18 dB" },
711         {  0x0a,        "Pn - 20 dB" },
712         {  0x0b,        "Pn - 22 dB" },
713         {  0x0c,        "Pn - 24 dB" },
714         {  0x0d,        "Pn - 26 dB" },
715         {  0x0e,        "Pn - 28 dB" },
716         {  0x0f,        "Pn - 30 dB" },
717         { 0,                    NULL }
718 };
719
720 static int
721 dissect_rsl_ie_bs_power(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
722 {
723         proto_item *ti;
724         proto_tree *ie_tree;
725         guint8 ie_id;
726
727         if(is_mandatory == FALSE){
728                 ie_id = tvb_get_guint8(tvb,offset);
729                 if (ie_id != RSL_IE_BS_POW)
730                         return offset;
731         }
732
733         ti = proto_tree_add_text(tree, tvb,offset,2,"BS Power IE");
734         ie_tree = proto_item_add_subtree(ti, ett_ie_bs_power);
735
736         /* Element identifier */
737         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
738         offset++;
739
740         /* EPC mode */
741         proto_tree_add_item(ie_tree, hf_rsl_epc_mode, tvb, offset, 1, FALSE);
742         /* FPC_EPC mode */
743         proto_tree_add_item(ie_tree, hf_rsl_bs_fpc_epc_mode, tvb, offset, 1, FALSE);
744
745         /* The Power Level field (octet 2) indicates the number of 2 dB steps by
746          * which the power shall be reduced from its nominal value, Pn,
747          * set by the network operator to adjust the coverage.
748          * Thus the Power Level values correspond to the following powers (relative to Pn):
749          */
750         proto_tree_add_item(ie_tree, hf_rsl_bs_power, tvb, offset, 1, FALSE);
751         offset++;
752
753         return offset;
754 }
755 /*
756  * 9.3.5 Channel Identification
757  */
758 static int
759 dissect_rsl_ie_ch_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
760 {
761         proto_item *ti;
762         proto_tree *ie_tree;
763         guint8 length;
764         int ie_offset;
765         guint8 ie_id;
766
767         if(is_mandatory == FALSE){
768                 ie_id = tvb_get_guint8(tvb,offset);
769                 if (ie_id != RSL_IE_CH_ID)
770                         return offset;
771         }
772
773         ti = proto_tree_add_text(tree, tvb,offset,0,"Channel Identification IE");
774         ie_tree = proto_item_add_subtree(ti, ett_ie_ch_id);
775
776         /* Element identifier */
777         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
778         offset++;
779         /* Length */
780         length = tvb_get_guint8(tvb, offset);
781         proto_item_set_len(ti, length+2);
782         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
783         offset++;
784
785         ie_offset = offset;
786
787         /* 3GPP TS 44.018 "Channel Description" */
788         de_rr_ch_dsc(tvb, ie_tree, offset, length, NULL, 0);
789         /*
790          * The 3GPP TS 24.008 "Mobile Allocation" shall for compatibility reasons be
791          * included but empty, i.e. the length shall be zero.
792          */
793         return ie_offset + length;
794 }
795 /*
796  * 9.3.6 Channel Mode
797  */
798
799 static const true_false_string rsl_dtx_vals = {
800   "DTX is applied",
801   "DTX is not applied"
802 };
803 static const value_string rsl_speech_or_data_vals[] = {
804         {  0x01,        "Speech" },
805         {  0x02,        "Data" },
806         {  0x03,        "Signalling" },
807         { 0,                    NULL }
808 };
809 static const value_string rsl_ch_rate_and_type_vals[] = {
810         {  0x01,        "SDCCH" },
811         {  0x08,        "Full rate TCH channel Bm" },
812         {  0x09,        "Half rate TCH channel Lm" },
813         {  0x0a,        "Full rate TCH channel bi-directional Bm, Multislot configuration" },
814         {  0x1a,        "Full rate TCH channel uni-directional downlink Bm, Multislot configuration" },
815         {  0x18,        "Full rate TCH channel Bm Group call channel" },
816         {  0x19,        "Half rate TCH channel Lm Group call channel" },
817         {  0x28,        "Full rate TCH channel Bm Broadcast call channel" },
818         {  0x29,        "PHalf rate TCH channel Lm Broadcast call channel" },
819         { 0,                    NULL }
820 };
821
822 static const value_string rsl_speech_coding_alg_vals[] = {
823         {  0x01,        "GSM speech coding algorithm version 1: GSM FR or GSM HR" },
824         {  0x11,        "GSM speech coding algorithm version 2: GSM EFR (half rate not defined in this version of the protocol)" },
825         {  0x21,        "GSM speech coding algorithm version 3: FR AMR or HR AMR" },
826         {  0x31,        "GSM speech coding algorithm version 4: OFR AMR-WB or OHR AMR-WB" },
827         {  0x09,        "GSM speech coding algorithm version 5: FR AMR-WB" },
828         {  0x0d,        "GSM speech coding algorithm version 6: OHR AMR" },
829         { 0,                    NULL }
830 };
831
832 static const true_false_string t_nt_bit_vals = {
833   "Non-transparent service",
834   "Transparent service"
835 };
836
837 static const value_string rsl_ra_if_data_rte_vals[] = {
838         {  0x21,        "asymmetric 43.5 kbit/s (downlink) + 14.5 kbit/s (uplink)" },
839         {  0x22,        "asymmetric 29.0 kbit/s (downlink) + 14.5 kbit/s (uplink)" },
840         {  0x23,        "asymmetric 43.5 kbit/s (downlink) + 29.0 kbit/s (uplink)" },
841         {  0x29,        "asymmetric 14.5 kbit/s (downlink) + 43.5 kbit/s (uplink)" },
842         {  0x2a,        "asymmetric 14.5 kbit/s (downlink) + 29.0 kbit/s (uplink)" },
843         {  0x2b,        "asymmetric 29.0 kbit/s (downlink) + 43.5 kbit/s (uplink)" },
844         {  0x34,        "43.5 kbit/s" },
845         {  0x31,        "28.8 kbit/s" },
846         {  0x18,        "14.5 kbit/s" },
847         {  0x10,        "12 kbit/s" },
848         {  0x11,        "6 kbit/s" },
849         { 0,                    NULL }
850 };
851
852 static const value_string rsl_data_rte_vals[] = {
853         {  0x38,        "32 kbit/s" },
854         {  0x22,        "39 kbit/s" },
855         {  0x18,        "14.4 kbit/s" },
856         {  0x10,        "9.6 kbit/s" },
857         {  0x11,        "4.8 kbit/s" },
858         {  0x12,        "2.4 kbit/s" },
859         {  0x13,        "1.2 kbit/s" },
860         {  0x14,        "600 bit/s" },
861         {  0x15,        "1 200/75 bit/s (1 200 network-to-MS, 75 MS-to-network)" },
862         { 0,                    NULL }
863 };
864
865 static int
866 dissect_rsl_ie_ch_mode(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
867 {
868         proto_item *ti;
869         proto_tree *ie_tree;
870         guint8 length;
871         int ie_offset;
872         guint8 ie_id;
873         guint8 octet;
874
875         if(is_mandatory == FALSE){
876                 ie_id = tvb_get_guint8(tvb,offset);
877                 if (ie_id != RSL_IE_CH_MODE)
878                         return offset;
879         }
880
881         ti = proto_tree_add_text(tree, tvb,offset,0,"Channel Mode IE");
882         ie_tree = proto_item_add_subtree(ti, ett_ie_ch_mode);
883
884         /* Element identifier */
885         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
886         offset++;
887         /* Length */
888         length = tvb_get_guint8(tvb, offset);
889         proto_item_set_len(ti, length+2);
890         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
891         offset++;
892         ie_offset = offset;
893
894         /* The DTX bits of octet 3 indicate whether DTX is applied
895          * DTXd indicates use of DTX in the downlink direction (BTS to MS) and
896          * DTXu indicates use of DTX in the uplink direction (MS to BTS).
897          */
898         proto_tree_add_item(ie_tree, hf_rsl_cm_dtxd, tvb, offset, 1, FALSE);
899         proto_tree_add_item(ie_tree, hf_rsl_cm_dtxu, tvb, offset, 1, FALSE);
900         offset++;
901         /* The "Speech or data indicator" field (octet 4) */
902         proto_tree_add_item(ie_tree, hf_rsl_speech_or_data, tvb, offset, 1, FALSE);
903         octet = tvb_get_guint8(tvb,offset);
904         offset++;
905         /* Channel rate and type */
906         proto_tree_add_item(ie_tree, hf_rsl_ch_rate_and_type, tvb, offset, 1, FALSE);
907         offset++;
908         /* Speech coding algor./data rate + transp ind */
909         switch(octet){
910         case 1:
911                 /* Speech */
912                 proto_tree_add_item(ie_tree, hf_rsl_speech_coding_alg, tvb, offset, 1, FALSE);
913                 break;
914         case 2:
915                 /* Data */
916                 proto_tree_add_item(ie_tree, hf_rsl_extension_bit, tvb, offset, 1, FALSE);
917                 proto_tree_add_item(ie_tree, hf_rsl_t_nt_bit, tvb, offset, 1, FALSE);
918                 octet = tvb_get_guint8(tvb,offset);
919                 if ((octet&0x40)==0x40){
920                         /* Non-transparent service */
921                         /* For the non-transparent service, bits 6 to 1 indicate the radio interface data rate:*/
922                         proto_tree_add_item(ie_tree, hf_rsl_ra_if_data_rte, tvb, offset, 1, FALSE);
923                 }else{
924                         /* For the transparent service, bits 6-1 indicate the data rate: */
925                         proto_tree_add_item(ie_tree, hf_rsl_data_rte, tvb, offset, 1, FALSE);
926                 }
927                 break;
928         case 3:
929                 /* Signalling
930                  * If octet 4 indicates signalling then octet 6 is coded as follows:
931                  * 0000 0000 No resources required
932                  */
933                 proto_tree_add_text(tree, tvb,offset,1,"0 No resources required(All other values are reserved)");
934                 break;
935         default:
936                 /* Should not happen */
937                 proto_tree_add_text(ie_tree, tvb,offset,1,"Speech or data indicator != 1,2 or 3");
938                 break;
939         }
940
941         offset++;
942
943         return ie_offset + length;
944 }
945
946 /*
947  * 9.3.7 Encryption information
948  */
949
950 /* The Algorithm Identifier field (octet 3) indicates the relevant ciphering algorithm. It is coded as: */
951 static const value_string rsl_algorithm_id_vals[] = {
952         {  0x00,        "Pn" },
953         {  0x00,        "Reserved" },
954         {  0x01,        "No encryption shall be used" },
955         {  0x02,        "GSM encryption algorithm version 1 (A5/1)" },
956         {  0x03,        "GSM A5/2" },
957         {  0x04,        "GSM A5/3" },
958         {  0x05,        "GSM A5/4" },
959         {  0x06,        "GSM A5/5" },
960         {  0x07,        "GSM A5/6" },
961         {  0x08,        "GSM A5/7" },
962         { 0,                    NULL }
963 };
964
965 static int
966 dissect_rsl_ie_enc_inf(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
967 {
968         proto_item *ti;
969         proto_tree *ie_tree;
970         guint8 length;
971         guint8 ie_id;
972
973         if(is_mandatory == FALSE){
974                 ie_id = tvb_get_guint8(tvb,offset);
975                 if (ie_id != RSL_IE_ENC_INF)
976                         return offset;
977         }
978
979         ti = proto_tree_add_text(tree, tvb,offset,0,"Encryption information IE");
980         ie_tree = proto_item_add_subtree(ti, ett_ie_enc_inf);
981
982         /* Element identifier */
983         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
984         offset++;
985         /* Length */
986         length = tvb_get_guint8(tvb, offset);
987         proto_item_set_len(ti, length+2);
988         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
989         offset++;
990
991         /* Algorithm Identifier field (octet 3) */
992         proto_tree_add_item(ie_tree, hf_rsl_alg_id, tvb, offset, 1, FALSE);
993
994         /* key */
995         proto_tree_add_item(ie_tree, hf_rsl_key, tvb, offset+1, length -1, FALSE);
996
997         return offset + length;
998
999 }
1000 /*
1001  * 9.3.8 Frame Number
1002  */
1003 static int
1004 dissect_rsl_ie_frame_no(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1005 {
1006         proto_item *ti;
1007         proto_tree *ie_tree;
1008         guint8 ie_id;
1009
1010         if(is_mandatory == FALSE){
1011                 ie_id = tvb_get_guint8(tvb,offset);
1012                 if (ie_id != RSL_IE_FRAME_NO)
1013                         return offset;
1014         }
1015
1016         ti = proto_tree_add_text(tree, tvb,offset,3,"Frame Number IE");
1017         ie_tree = proto_item_add_subtree(ti, ett_ie_frame_no);
1018
1019         /* Element identifier */
1020         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1021         offset++;
1022
1023         proto_tree_add_item(ie_tree, hf_rsl_req_ref_T1prim, tvb, offset, 1, FALSE);
1024         proto_tree_add_item(ie_tree, hf_rsl_req_ref_T3, tvb, offset, 2, FALSE);
1025         offset++;
1026         proto_tree_add_item(ie_tree, hf_rsl_req_ref_T2, tvb, offset, 1, FALSE);
1027         offset++;
1028
1029         return offset;
1030 }
1031
1032 /*
1033  * 9.3.9 Handover reference
1034  */
1035 static int
1036 dissect_rsl_ie_ho_ref(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1037 {
1038         proto_item *ti;
1039         proto_tree *ie_tree;
1040         guint8 ie_id;
1041
1042         if(is_mandatory == FALSE){
1043                 ie_id = tvb_get_guint8(tvb,offset);
1044                 if (ie_id != RSL_IE_HO_REF)
1045                         return offset;
1046         }
1047
1048         ti = proto_tree_add_text(tree, tvb,offset,2,"Handover reference IE");
1049         ie_tree = proto_item_add_subtree(ti, ett_ie_ho_ref);
1050
1051         /* Element identifier */
1052         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1053         offset++;
1054
1055         /* Hand-over reference */
1056         proto_tree_add_item(ie_tree, hf_rsl_ho_ref, tvb, offset, 1, FALSE);
1057         offset++;
1058
1059         return offset;
1060 }
1061
1062 /*
1063  * 9.3.10 L1 Information
1064  */
1065
1066 static int
1067 dissect_rsl_ie_l1_inf(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1068 {
1069         proto_item *ti;
1070         proto_tree *ie_tree;
1071         guint8 ie_id;
1072
1073         if(is_mandatory == FALSE){
1074                 ie_id = tvb_get_guint8(tvb,offset);
1075                 if (ie_id != RSL_IE_L1_INF)
1076                         return offset;
1077         }
1078
1079         ti = proto_tree_add_text(tree, tvb,offset, 3,"L1 Information IE");
1080         ie_tree = proto_item_add_subtree(ti, ett_ie_l1_inf);
1081
1082         /* Element identifier */
1083         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1084         offset++;
1085
1086         /* Octets 2-3 contain the L1 header information of SACCH blocks.
1087          * The information fields and codings are as defined in 3GPP TS 44.004.
1088          */
1089         /* Power level */
1090         proto_tree_add_item(ie_tree, hf_rsl_l1inf_power_lev, tvb, offset, 1, FALSE);
1091         /* FPC */
1092         proto_tree_add_item(ie_tree, hf_rsl_l1inf_fpc, tvb, offset, 1, FALSE);
1093         offset++;
1094         /* Actual Timing Advance */
1095         proto_tree_add_item(ie_tree, hf_rsl_act_timing_adv, tvb, offset, 1, FALSE);
1096         offset++;
1097
1098         return offset;
1099 }
1100
1101 /*
1102  * 9.3.11 L3 Information                        9.3.11  M TLV >=3
1103  *
1104  * This element contains a link layer service data unit (L3 message).
1105  * It is used to forward a complete L3 message as specified in
1106  * 3GPP TS 24.008 or 3GPP TS 44.018 between BTS and BSC.
1107  */
1108 static int
1109 dissect_rsl_ie_L3_inf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, gboolean is_mandatory)
1110 {
1111         proto_item *ti;
1112         proto_tree *ie_tree;
1113         tvbuff_t        *next_tvb;
1114         guint16 length;
1115         guint8 ie_id;
1116
1117         if(is_mandatory == FALSE){
1118                 ie_id = tvb_get_guint8(tvb,offset);
1119                 if (ie_id != RSL_IE_L3_INF)
1120                         return offset;
1121         }
1122
1123         ti = proto_tree_add_text(tree, tvb,offset,0,"L3 Information IE");
1124         ie_tree = proto_item_add_subtree(ti, ett_ie_L3_inf);
1125
1126         /* Element identifier */
1127         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1128         offset++;
1129         /* Length */
1130         length = tvb_get_ntohs(tvb, offset);
1131         proto_item_set_len(ti, length+3);
1132         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 2, FALSE);
1133         offset= offset+2;
1134
1135         /* Link Layer Service Data Unit (i.e. a layer 3 message
1136          * as defined in 3GPP TS 24.008 or 3GPP TS 44.018)
1137          */
1138         proto_tree_add_text(ie_tree, tvb,offset,length,"Link Layer Service Data Unit ( L3 Message)");
1139         next_tvb = tvb_new_subset(tvb, offset, length, length);
1140         call_dissector(gsm_a_dtap_handle, next_tvb, pinfo, top_tree);
1141
1142         offset = offset + length;
1143
1144         return offset;
1145  }
1146
1147 /*
1148  * 9.3.12 MS Identity
1149  */
1150 static int
1151 dissect_rsl_ie_ms_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1152 {
1153         proto_item *ti;
1154         proto_tree *ie_tree;
1155         guint length;
1156         guint8 ie_id;
1157
1158         if(is_mandatory == FALSE){
1159                 ie_id = tvb_get_guint8(tvb,offset);
1160                 if (ie_id != RSL_IE_MS_ID)
1161                         return offset;
1162         }
1163         ti = proto_tree_add_text(tree, tvb,offset,0,"MS Identity IE");
1164         ie_tree = proto_item_add_subtree(ti, ett_ie_ms_id);
1165
1166         /* Element identifier */
1167         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1168         offset++;
1169         /* Length */
1170         length = tvb_get_guint8(tvb,offset);
1171         proto_item_set_len(ti, length+2);
1172         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
1173         offset++;
1174
1175         de_mid(tvb, ie_tree, offset, length, NULL, 0);
1176
1177         offset = offset + length;
1178
1179         return offset;
1180 }
1181
1182 static const true_false_string rsl_ms_fpc_epc_mode_vals = {
1183   "In use",
1184   "Not in use"
1185 };
1186 /*
1187  * 9.3.13 MS Power
1188  */
1189 static int
1190 dissect_rsl_ie_ms_pow(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1191 {
1192         proto_item *ti;
1193         proto_tree *ie_tree;
1194         guint8 ie_id;
1195
1196         if(is_mandatory == FALSE){
1197                 ie_id = tvb_get_guint8(tvb,offset);
1198                 if (ie_id != RSL_IE_MS_POW)
1199                         return offset;
1200         }
1201
1202         ti = proto_tree_add_text(tree, tvb,offset, 2,"MS Power IE");
1203         ie_tree = proto_item_add_subtree(ti, ett_ie_ms_pow);
1204
1205         /* Element identifier */
1206         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1207         offset++;
1208
1209         /* MS power level */
1210         proto_tree_add_item(ie_tree, hf_rsl_ms_power_lev, tvb, offset, 1, FALSE);
1211         /* FPC */
1212         proto_tree_add_item(ie_tree, hf_rsl_ms_fpc, tvb, offset, 1, FALSE);
1213         /* Reserved */
1214         offset++;
1215
1216         return offset;
1217 }
1218
1219 /*
1220  * 9.3.14 Paging Group M TV 2 2
1221  */
1222 static int
1223 dissect_rsl_ie_paging_grp(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1224 {
1225         proto_item *ti;
1226         proto_tree *ie_tree;
1227         guint8 ie_id;
1228
1229         if(is_mandatory == FALSE){
1230                 ie_id = tvb_get_guint8(tvb,offset);
1231                 if (ie_id != RSL_IE_PAGING_GRP)
1232                         return offset;
1233         }
1234         ti = proto_tree_add_text(tree, tvb,offset,2,"Paging Group IE");
1235         ie_tree = proto_item_add_subtree(ti, ett_ie_paging_grp);
1236
1237         /* Element identifier */
1238         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1239         offset++;
1240
1241         /* The Paging Group field (octet 2) contains the binary representation of the paging
1242          * group as defined in 3GPP TS 45.002.
1243          */
1244         proto_tree_add_item(ie_tree, hf_rsl_paging_grp, tvb, offset, 1, FALSE);
1245         offset++;
1246
1247         return offset;
1248
1249 }
1250
1251 /*
1252  * 9.3.15 Paging Load
1253  */
1254 static int
1255 dissect_rsl_ie_paging_load(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1256 {
1257         proto_item *ti;
1258         proto_tree *ie_tree;
1259         guint8 ie_id;
1260
1261         if(is_mandatory == FALSE){
1262                 ie_id = tvb_get_guint8(tvb,offset);
1263                 if (ie_id != RSL_IE_PAGING_LOAD)
1264                         return offset;
1265         }
1266         ti = proto_tree_add_text(tree, tvb,offset,3,"Paging Load IE");
1267         ie_tree = proto_item_add_subtree(ti, ett_ie_paging_load);
1268
1269         /* Element identifier */
1270         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1271         offset++;
1272
1273         /*
1274          * Paging Buffer Space.
1275          */
1276         proto_tree_add_item(ie_tree, hf_rsl_paging_load, tvb, offset, 2, FALSE);
1277         offset = offset + 2;
1278
1279         return offset;
1280
1281 }
1282 /*
1283  * 9.3.16 Physical Context TLV
1284  */
1285 static int
1286 dissect_rsl_ie_phy_ctx(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1287 {
1288         proto_item *ti;
1289         proto_tree *ie_tree;
1290         guint length;
1291         guint8 ie_id;
1292
1293         if(is_mandatory == FALSE){
1294                 ie_id = tvb_get_guint8(tvb,offset);
1295                 if (ie_id != RSL_IE_PHY_CTX)
1296                         return offset;
1297         }
1298
1299         ti = proto_tree_add_text(tree, tvb,offset,0,"Physical Context IE ");
1300         ie_tree = proto_item_add_subtree(ti, ett_ie_phy_ctx);
1301
1302         /* Element identifier */
1303         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1304         offset++;
1305         /* Length */
1306         length = tvb_get_guint8(tvb,offset);
1307         proto_item_set_len(ti, length+2);
1308         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
1309         offset++;
1310
1311         /*
1312          * Physical Context Information:
1313          *      The Physical Context Information field is not specified.
1314          *      This information should not be analysed by BSC, but merely
1315          *      forwarded from one TRX/channel to another.
1316          */
1317         proto_tree_add_item(ie_tree, hf_rsl_phy_ctx, tvb, offset, length, FALSE);
1318         offset = offset + length;
1319
1320         return offset;
1321 }
1322 /*
1323  * 9.3.17 Access Delay M TV 2
1324  */
1325 static int
1326 dissect_rsl_ie_access_delay(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1327 {
1328         proto_item *ti;
1329         proto_tree *ie_tree;
1330         guint8 ie_id;
1331
1332         if(is_mandatory == FALSE){
1333                 ie_id = tvb_get_guint8(tvb,offset);
1334                 if (ie_id != RSL_IE_ACCESS_DELAY)
1335                         return offset;
1336         }
1337
1338         ti = proto_tree_add_text(tree, tvb,offset,2,"Access Delay IE ");
1339         ie_tree = proto_item_add_subtree(ti, ett_ie_access_delay);
1340
1341         /* Element identifier */
1342         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1343         offset++;
1344         proto_tree_add_item(ie_tree, hf_rsl_acc_delay, tvb, offset, 1, FALSE);
1345         offset++;
1346         return offset;
1347 }
1348
1349 /*
1350  * 9.3.18 RACH Load
1351  */
1352
1353 static int
1354 dissect_rsl_ie_rach_load(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1355 {
1356         proto_item *ti;
1357         proto_tree *ie_tree;
1358         guint length;
1359         guint8 ie_id;
1360         int ie_offset;
1361
1362         if(is_mandatory == FALSE){
1363                 ie_id = tvb_get_guint8(tvb,offset);
1364                 if (ie_id != RSL_IE_RACH_LOAD)
1365                         return offset;
1366         }
1367
1368         ti = proto_tree_add_text(tree, tvb,offset,0,"RACH Load IE ");
1369         ie_tree = proto_item_add_subtree(ti, ett_ie_rach_load);
1370
1371         /* Element identifier */
1372         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1373         offset++;
1374         /* Length */
1375         length = tvb_get_guint8(tvb,offset);
1376         proto_item_set_len(ti, length+2);
1377         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
1378         offset++;
1379         ie_offset = offset;
1380
1381         /*
1382          * This element is used to carry information on the load of the RACH (Random Access Channel)
1383          * associated with this CCCH timeslot. It is of variable length.
1384          */
1385         /*      RACH Slot Count */
1386         proto_tree_add_item(ie_tree, hf_rsl_rach_slot_cnt, tvb, offset, 2, FALSE);
1387         offset = offset +2;
1388         length = length -2;
1389         /* RACH Busy Count */
1390         proto_tree_add_item(ie_tree, hf_rsl_rach_busy_cnt, tvb, offset, 2, FALSE);
1391         offset = offset +2;
1392         length = length -2;
1393
1394         /* RACH Access Count */
1395         proto_tree_add_item(ie_tree, hf_rsl_rach_acc_cnt, tvb, offset, 2, FALSE);
1396         offset = offset +2;
1397         length = length -2;
1398
1399         /* Supplementary Information */
1400         if( length > 0){
1401                 proto_tree_add_text(ie_tree, tvb, offset,length ,"Supplementary Information");
1402         }
1403         offset = ie_offset + length;
1404
1405         return offset;
1406 }
1407
1408 /*
1409  * 9.3.19 Request Reference M TV 4
1410  */
1411 static int
1412 dissect_rsl_ie_req_ref(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1413 {
1414         proto_item *ti;
1415         proto_tree *ie_tree;
1416         guint8 ie_id;
1417
1418         if(is_mandatory == FALSE){
1419                 ie_id = tvb_get_guint8(tvb,offset);
1420                 if (ie_id != RSL_IE_REQ_REF)
1421                         return offset;
1422         }
1423
1424         ti = proto_tree_add_text(tree, tvb,offset,4,"Request Reference IE ");
1425         ie_tree = proto_item_add_subtree(ti, ett_ie_req_ref);
1426
1427         /* Element identifier */
1428         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1429         offset++;
1430         proto_tree_add_item(ie_tree, hf_rsl_req_ref_ra, tvb, offset, 1, FALSE);
1431         offset++;
1432         proto_tree_add_item(ie_tree, hf_rsl_req_ref_T1prim, tvb, offset, 1, FALSE);
1433         proto_tree_add_item(ie_tree, hf_rsl_req_ref_T3, tvb, offset, 2, FALSE);
1434         offset++;
1435         proto_tree_add_item(ie_tree, hf_rsl_req_ref_T2, tvb, offset, 1, FALSE);
1436         offset++;
1437         return offset;
1438 }
1439
1440 static const value_string rel_mode_vals[] = {
1441         {  0x00,        "Normal Release" },
1442         {  0x01,        "Local End Release" },
1443         { 0,                    NULL }
1444 };
1445
1446 /*
1447  * 9.3.20 Release Mode                          9.3.20  M TV 2
1448  */
1449 static int
1450 dissect_rsl_ie_rel_mode(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1451 {
1452         proto_item *ti;
1453         proto_tree *ie_tree;
1454         guint8 ie_id;
1455
1456         if(is_mandatory == FALSE){
1457                 ie_id = tvb_get_guint8(tvb,offset);
1458                 if (ie_id != RSL_IE_REL_MODE)
1459                         return offset;
1460         }
1461
1462         ti = proto_tree_add_text(tree, tvb,offset,4,"Release Mode IE ");
1463         ie_tree = proto_item_add_subtree(ti, ett_ie_rel_mode);
1464
1465         /* Element identifier */
1466         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1467         offset++;
1468
1469         /*      The M bit is coded as follows:
1470          * 0 normal release
1471          * 1 local end release
1472          */
1473         proto_tree_add_item(ie_tree, hf_rsl_rel_mode, tvb, offset, 1, FALSE);
1474
1475         offset++;
1476         return offset;
1477 }
1478
1479 static const value_string rsl_rlm_cause_vals[] = {
1480         {  0x00,        "reserved" },
1481         {  0x01,        "timer T200 expired (N200+1) times" },
1482         {  0x02,        "re-establishment request" },
1483         {  0x03,        "unsolicited UA response" },
1484         {  0x04,        "unsolicited DM response" },
1485         {  0x05,        "unsolicited DM response, multiple frame established state" },
1486         {  0x06,        "unsolicited supervisory response" },
1487         {  0x07,        "sequence error" },
1488         {  0x08,        "U-frame with incorrect parameters" },
1489         {  0x09,        "S-frame with incorrect parameters" },
1490         {  0x0a,        "I-frame with incorrect use of M bit" },
1491         {  0x0b,        "I-frame with incorrect length" },
1492         {  0x0c,        "frame not implemented" },
1493         {  0x0d,        "SABM command, multiple frame established state" },
1494         {  0x0e,        "SABM frame with information not allowed in this state" },
1495         { 0,                    NULL }
1496 };
1497
1498 /*
1499  * 9.3.21 Resource Information
1500  */
1501 static int
1502 dissect_rsl_ie_resource_inf(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1503 {
1504         proto_item *ti;
1505         proto_tree *ie_tree;
1506         guint8 ie_id;
1507         guint           length;
1508         int ie_offset;
1509
1510         if(is_mandatory == FALSE){
1511                 ie_id = tvb_get_guint8(tvb,offset);
1512                 if (ie_id != RSL_IE_RESOURCE_INF)
1513                         return offset;
1514         }
1515
1516         ti = proto_tree_add_text(tree, tvb,offset,0,"Resource Information IE");
1517         ie_tree = proto_item_add_subtree(ti, ett_ie_resource_inf);
1518
1519         /* Element identifier */
1520         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1521         offset++;
1522
1523         /* Length */
1524         length = tvb_get_guint8(tvb,offset);
1525         proto_item_set_len(ti, length+2);
1526
1527         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
1528         offset++;
1529
1530         ie_offset = offset;
1531
1532         while (length > 0){
1533                 proto_tree_add_item(ie_tree, hf_rsl_ch_no_Cbits, tvb, offset, 1, FALSE);
1534                 /* TN is time slot number, binary represented as in 3GPP TS 45.002.
1535                  * 3 Bits
1536                  */
1537                 proto_tree_add_item(ie_tree, hf_rsl_ch_no_TN, tvb, offset, 1, FALSE);
1538                 offset++;
1539
1540                 /* Interference level (1) */
1541                 /* Interf Band */
1542                 proto_tree_add_item(ie_tree, hf_rsl_interf_band, tvb, offset, 1, FALSE);
1543                 /* Interf Band reserved bits */
1544                 proto_tree_add_item(ie_tree, hf_rsl_interf_band_reserved, tvb, offset, 1, FALSE);
1545                 offset++;
1546                 length = length - 2;
1547         }
1548         return ie_offset + length;
1549 }
1550
1551 /*
1552  * 9.3.22 RLM Cause                             9.3.22  M TLV 2-4
1553  */
1554 static int
1555 dissect_rsl_ie_rlm_cause(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1556 {
1557         proto_item *ti;
1558         proto_tree *ie_tree;
1559
1560         guint           length;
1561         guint8          octet;
1562         guint8 ie_id;
1563
1564         if(is_mandatory == FALSE){
1565                 ie_id = tvb_get_guint8(tvb,offset);
1566                 if (ie_id != RSL_IE_RLM_CAUSE)
1567                         return offset;
1568         }
1569
1570         ti = proto_tree_add_text(tree, tvb,offset,0,"RLM Cause IE ");
1571         ie_tree = proto_item_add_subtree(ti, ett_ie_rlm_cause);
1572
1573         /* Element identifier */
1574         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1575         offset++;
1576         /* Length */
1577         length = tvb_get_guint8(tvb,offset);
1578         proto_item_set_len(ti, length+2);
1579
1580         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
1581         offset++;
1582
1583         /* The Cause Value is a one octet field if the extension bit is set to 0.
1584          * If the extension bit is set to 1, the Cause Value is a two octet field.
1585          */
1586         octet = tvb_get_guint8(tvb,offset);
1587         proto_tree_add_item(tree, hf_rsl_extension_bit, tvb, offset, 1, FALSE);
1588         proto_tree_add_item(ie_tree, hf_rsl_cause, tvb, offset, 1, FALSE);
1589         offset++;
1590
1591         return offset;
1592 }
1593
1594 /*
1595  * 9.3.23 Starting Time
1596  */
1597 static int
1598 dissect_rsl_ie_staring_time(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1599 {
1600         proto_item *ti;
1601         proto_tree *ie_tree;
1602         guint8 ie_id;
1603
1604         if(is_mandatory == FALSE){
1605                 ie_id = tvb_get_guint8(tvb,offset);
1606                 if (ie_id != RSL_IE_STARTING_TIME)
1607                         return offset;
1608         }
1609
1610         ti = proto_tree_add_text(tree, tvb,offset,3,"Starting Time IE");
1611         ie_tree = proto_item_add_subtree(ti, ett_ie_staring_time);
1612
1613         /* Element identifier */
1614         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1615         offset++;
1616
1617         proto_tree_add_item(ie_tree, hf_rsl_req_ref_T1prim, tvb, offset, 1, FALSE);
1618         proto_tree_add_item(ie_tree, hf_rsl_req_ref_T3, tvb, offset, 2, FALSE);
1619         offset++;
1620         proto_tree_add_item(ie_tree, hf_rsl_req_ref_T2, tvb, offset, 1, FALSE);
1621         offset++;
1622
1623         return offset;
1624 }
1625
1626 /*
1627  * 9.3.24 Timing Advance
1628  */
1629 static int
1630 dissect_rsl_ie_timing_adv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1631 {
1632         proto_item *ti;
1633         proto_tree *ie_tree;
1634         guint8 ie_id;
1635
1636         if(is_mandatory == FALSE){
1637                 ie_id = tvb_get_guint8(tvb,offset);
1638                 if (ie_id != RSL_IE_TIMING_ADV)
1639                         return offset;
1640         }
1641
1642         ti = proto_tree_add_text(tree, tvb,offset,2,"Timing Advance IE");
1643         ie_tree = proto_item_add_subtree(ti, ett_ie_timing_adv);
1644
1645         /* Element identifier */
1646         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1647         offset++;
1648
1649         proto_tree_add_item(ie_tree, hf_rsl_timing_adv, tvb, offset, 1, FALSE);
1650         offset++;
1651
1652         return offset;
1653 }
1654
1655 /*
1656  * 9.3.25 Uplink Measurements
1657  */
1658 static const true_false_string rsl_dtxd_vals = {
1659   "Employed",
1660   "Not employed"
1661 };
1662
1663 static int
1664 dissect_rsl_ie_uplik_meas(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1665 {
1666         proto_item *ti;
1667         proto_tree *ie_tree;
1668         guint           length;
1669         int                     ie_offset;
1670         guint8 ie_id;
1671
1672         if(is_mandatory == FALSE){
1673                 ie_id = tvb_get_guint8(tvb,offset);
1674                 if (ie_id != RSL_IE_UPLINK_MEAS)
1675                         return offset;
1676         }
1677
1678         ti = proto_tree_add_text(tree, tvb,offset,0,"Uplink Measurements IE");
1679         ie_tree = proto_item_add_subtree(ti, ett_ie_uplink_meas);
1680
1681         /* Element identifier */
1682         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1683         offset++;
1684
1685         /* Length */
1686         length = tvb_get_guint8(tvb,offset);
1687         proto_item_set_len(ti, length+2);
1688
1689         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
1690         offset++;
1691         ie_offset = offset;
1692
1693         /* Octet 3
1694          * 8    7        6      5       4       3       2       1
1695          * rfu  DTXd | RXLEV.FULL.up
1696          */
1697         proto_tree_add_item(ie_tree, hf_rsl_dtxd, tvb, offset, 1, FALSE);
1698         proto_tree_add_item(ie_tree, hf_rsl_rxlev_full_up, tvb, offset, 1, FALSE);
1699         offset++;
1700
1701         /* Octet4
1702          * 8    7       6       5       4       3       2       1
1703          * Reserved |  RXLEV.SUB.up 4
1704          */
1705         proto_tree_add_item(ie_tree, hf_rsl_rxlev_sub_up, tvb, offset, 1, FALSE);
1706         offset++;
1707         /* Octet 5
1708          * 8    7        6      5       4                 3     2       1
1709          * Reserved | RXQUAL.FULL.up | RXQUAL.SUB.up
1710          */
1711         proto_tree_add_item(ie_tree, hf_rsl_rxqual_full_up, tvb, offset, 1, FALSE);
1712         proto_tree_add_item(ie_tree, hf_rsl_rxqual_sub_up, tvb, offset, 1, FALSE);
1713          offset++;
1714         /* Octet 6 - N
1715          * Supplementary Measurement Information
1716          */
1717         return ie_offset+length;
1718 }
1719
1720
1721 static const value_string rsl_class_vals[] = {
1722         {  0x00,        "Normal event" },
1723         {  0x01,        "Normal event" },
1724         {  0x02,        "Resource unavailable" },
1725         {  0x03,        "Service or option not available" },
1726         {  0x04,        "Service or option not implemented" },
1727         {  0x05,        "Invalid message (e.g. parameter out of range)" },
1728         {  0x06,        "Protocol error" },
1729         {  0x07,        "Interworking" },
1730         { 0,                    NULL }
1731 };
1732
1733  /*
1734   * 9.3.26 Cause
1735   */
1736 static int
1737 dissect_rsl_ie_cause(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1738 {
1739         proto_item *ti;
1740         proto_tree *ie_tree;
1741         guint           length;
1742         guint8          octet;
1743         int                     ie_offset;
1744         guint8 ie_id;
1745
1746         if(is_mandatory == FALSE){
1747                 ie_id = tvb_get_guint8(tvb,offset);
1748                 if (ie_id != RSL_IE_CAUSE)
1749                         return offset;
1750         }
1751
1752         ti = proto_tree_add_text(tree, tvb,offset,0,"Cause IE");
1753         ie_tree = proto_item_add_subtree(ti, ett_ie_cause);
1754
1755         /* Element identifier */
1756         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1757         offset++;
1758         /* Length */
1759         length = tvb_get_guint8(tvb,offset);
1760         proto_item_set_len(ti, length+2);
1761         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
1762         offset++;
1763         ie_offset = offset;
1764
1765         /* Cause Value */
1766         octet = tvb_get_guint8(tvb,offset);
1767         proto_tree_add_item(tree, hf_rsl_extension_bit, tvb, offset, 1, FALSE);
1768         proto_tree_add_item(tree, hf_rsl_class, tvb, offset, 1, FALSE);
1769         if ((octet & 0x80) == 80)
1770         /* Cause Extension*/
1771                 offset++;
1772
1773         /* Diagnostic(s) if any */
1774         return ie_offset+length;
1775 }
1776 /*
1777  * 9.3.27 Measurement result number
1778  */
1779
1780 static int
1781 dissect_rsl_ie_meas_res_no(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1782 {
1783         proto_item *ti;
1784         proto_tree *ie_tree;
1785         guint8 ie_id;
1786
1787         if(is_mandatory == FALSE){
1788                 ie_id = tvb_get_guint8(tvb,offset);
1789                 if (ie_id != RSL_IE_MEAS_RES_NO)
1790                         return offset;
1791         }
1792
1793         ti = proto_tree_add_text(tree, tvb,offset,2,"Measurement result number IE");
1794         ie_tree = proto_item_add_subtree(ti, ett_ie_meas_res_no);
1795
1796         /* Element identifier */
1797         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1798         offset++;
1799
1800         /* Measurement result number */
1801         proto_tree_add_item(ie_tree, hf_rsl_meas_res_no, tvb, offset, 1, FALSE);
1802         offset++;
1803
1804         return offset;
1805 }
1806 /*
1807  * 9.3.28 Message Identifier
1808  */
1809 static int
1810 dissect_rsl_ie_message_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1811 {
1812         proto_item *ti;
1813         proto_tree *ie_tree;
1814         guint8 ie_id;
1815
1816         if(is_mandatory == FALSE){
1817                 ie_id = tvb_get_guint8(tvb,offset);
1818                 if (ie_id != RSL_IE_MESSAGE_ID)
1819                         return offset;
1820         }
1821
1822         ti = proto_tree_add_text(tree, tvb,offset,0,"Message Identifier IE");
1823         ie_tree = proto_item_add_subtree(ti, ett_ie_message_id);
1824
1825         /* Element identifier */
1826         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1827         offset++;
1828         /* Message Type */
1829         proto_tree_add_item(tree, hf_rsl_msg_type, tvb, offset, 1, FALSE);
1830         offset++;
1831         return offset;
1832 }
1833 /*
1834  * 9.3.30 System Info Type
1835  */
1836 static const value_string rsl_sys_info_type_vals[] = {
1837         {  0x00,        "SYSTEM INFORMATION 8" },
1838         {  0x01,        "SYSTEM INFORMATION 1" },
1839         {  0x02,        "SYSTEM INFORMATION 2" },
1840         {  0x03,        "SYSTEM INFORMATION 3" },
1841         {  0x04,        "SYSTEM INFORMATION 4" },
1842         {  0x05,        "SYSTEM INFORMATION 5" },
1843         {  0x06,        "SYSTEM INFORMATION 6" },
1844         {  0x07,        "SYSTEM INFORMATION 7" },
1845         {  0x08,        "SYSTEM INFORMATION 16" },
1846         {  0x09,        "SYSTEM INFORMATION 17" },
1847         {  0x0a,        "SYSTEM INFORMATION 2bis" },
1848         {  0x0b,        "SYSTEM INFORMATION 2ter" },
1849         {  0x0d,        "SYSTEM INFORMATION 5bis" },
1850         {  0x0e,        "SYSTEM INFORMATION 5ter" },
1851         {  0x0f,        "SYSTEM INFORMATION 10" },
1852         {  0x47,        "EXTENDED MEASUREMENT ORDER" },
1853         {  0x48,        "MEASUREMENT INFORMATION" },
1854         {  0x28,        "SYSTEM INFORMATION 13" },
1855         {  0x29,        "SYSTEM INFORMATION 2quater" },
1856         {  0x2a,        "SYSTEM INFORMATION 9" },
1857         {  0x2b,        "SYSTEM INFORMATION 18" },
1858         {  0x2c,        "SYSTEM INFORMATION 19" },
1859         {  0x2d,        "SYSTEM INFORMATION 20" },
1860         { 0,                    NULL }
1861 };
1862
1863
1864 static int
1865 dissect_rsl_ie_sys_info_type(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1866 {
1867         proto_item *ti;
1868         proto_tree *ie_tree;
1869         guint8 ie_id, sitype;
1870
1871         if(is_mandatory == FALSE){
1872                 ie_id = tvb_get_guint8(tvb,offset);
1873                 if (ie_id != RSL_IE_SYS_INFO_TYPE)
1874                         return offset;
1875         }
1876
1877         ti = proto_tree_add_text(tree, tvb,offset,2,"System Info Type IE");
1878         ie_tree = proto_item_add_subtree(ti, ett_ie_sys_info_type);
1879
1880         /* Element identifier */
1881         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1882         offset++;
1883         /* Message Type */
1884         proto_tree_add_item(tree, hf_rsl_sys_info_type, tvb, offset, 1, FALSE);
1885         sitype = tvb_get_guint8(tvb, offset);
1886         offset++;
1887
1888         /* Check if SI is 2q, if so set flag */
1889         if (sitype==0x29) {
1890                 is_si2q = TRUE; }
1891
1892         return offset;
1893 }
1894
1895 /*
1896  * 9.3.35 Full Immediate Assign Info TLV 25
1897  */
1898 static int
1899 dissect_rsl_ie_full_imm_ass_inf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, gboolean is_mandatory)
1900 {
1901         proto_item *ti;
1902         proto_tree *ie_tree;
1903
1904         guint           length;
1905         tvbuff_t        *next_tvb;
1906         guint8          ie_id;
1907
1908         if(is_mandatory == FALSE){
1909                 ie_id = tvb_get_guint8(tvb,offset);
1910                 if (ie_id != RSL_IE_FULL_IMM_ASS_INF)
1911                         return offset;
1912         }
1913
1914         ti = proto_tree_add_text(tree, tvb,offset,0,"Full Immediate Assign Info IE ");
1915         ie_tree = proto_item_add_subtree(ti, ett_ie_full_imm_ass_inf);
1916
1917         /* Element identifier */
1918         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1919         offset++;
1920         /* Length */
1921         length = tvb_get_guint8(tvb,offset);
1922         proto_item_set_len(ti, length+2);
1923
1924         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
1925         offset++;
1926         /*      The Full Immediate Assign Info field (octets 3-25)
1927          * contains a complete immediate assign message (IMMEDIATE ASSIGNMENT or
1928          * IMMEDIATE ASSIGNMENT EXTENDED or IMMEDIATE ASSIGNMENT REJECT)
1929          * as defined in 3GPP TS 44.018.
1930          */
1931         proto_tree_add_text(ie_tree, tvb,offset,length,"Full Immediate Assign Info field");
1932         next_tvb = tvb_new_subset(tvb, offset, length, length);
1933         call_dissector(gsm_a_ccch_handle, next_tvb, pinfo, top_tree);
1934
1935         offset = offset + length;
1936
1937         return offset;
1938 }
1939
1940 /*
1941  * 9.3.36 SMSCB Information
1942  *
1943  * This element is used to convey a complete frame to be broadcast on the CBCH
1944  * including the Layer 2 header for the radio path.
1945  */
1946 static int
1947 dissect_rsl_ie_smscb_inf(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1948 {
1949         proto_item *ti;
1950         proto_tree *ie_tree;
1951
1952         guint           length;
1953         guint8          ie_id;
1954
1955         if(is_mandatory == FALSE){
1956                 ie_id = tvb_get_guint8(tvb,offset);
1957                 if (ie_id != RSL_IE_SMSCB_INF)
1958                         return offset;
1959         }
1960
1961         ti = proto_tree_add_text(tree, tvb,offset,0,"SMSCB Information IE ");
1962         ie_tree = proto_item_add_subtree(ti, ett_ie_smscb_inf);
1963
1964         /* Element identifier */
1965         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1966         offset++;
1967         /* Length */
1968         length = tvb_get_guint8(tvb,offset);
1969         proto_item_set_len(ti, length+2);
1970
1971         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
1972         offset++;
1973         /*
1974          * SMSCB frame
1975          */
1976         proto_tree_add_text(ie_tree, tvb,offset,length,"SMSCB frame");
1977
1978         offset = offset + length;
1979
1980         return offset;
1981 }
1982
1983 /*
1984  * 9.3.37 MS Timing Offset
1985  */
1986
1987 static int
1988 dissect_rsl_ie_ms_timing_offset(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1989 {
1990         proto_item *ti;
1991         proto_tree *ie_tree;
1992         guint8          ie_id;
1993
1994         if(is_mandatory == FALSE){
1995                 ie_id = tvb_get_guint8(tvb,offset);
1996                 if (ie_id != RSL_IE_FULL_MS_TIMING_OFFSET)
1997                         return offset;
1998         }
1999
2000         ti = proto_tree_add_text(tree, tvb,offset,0,"MS Timing Offset IE");
2001         ie_tree = proto_item_add_subtree(ti, ett_ie_ms_timing_offset);
2002
2003         /* Element identifier */
2004         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2005         offset++;
2006
2007         /* Timing Offset
2008          * The meaning of the MS Timing Offset is as defined in 3GPP TS 45.010.
2009          * The value of MS Timing Offset is the binary value of the 8-bit Timing Offset field (octet 2) - 63.
2010          * The range of MS Timing Offset is therefore -63 to 192.
2011          */
2012         proto_tree_add_item(ie_tree, hf_rsl_timing_offset, tvb, offset, 1, FALSE);
2013         offset++;
2014
2015         return offset;
2016 }
2017
2018 /*
2019  * 9.3.38 Erroneous Message
2020  * This information element is used to carry a complete A-bis interface message
2021  * which was considered erroneous at reception.
2022  */
2023 static int
2024 dissect_rsl_ie_err_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, gboolean is_mandatory)
2025 {
2026         proto_item *ti;
2027         proto_tree *ie_tree;
2028
2029         guint           length;
2030         guint8          ie_id;
2031         if(is_mandatory == FALSE){
2032                 ie_id = tvb_get_guint8(tvb,offset);
2033                 if (ie_id != RSL_IE_ERR_MSG)
2034                         return offset;
2035         }
2036
2037         ti = proto_tree_add_text(tree, tvb,offset,0,"Erroneous Message IE ");
2038         ie_tree = proto_item_add_subtree(ti, ett_ie_err_msg);
2039
2040         /* Element identifier */
2041         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2042         offset++;
2043         /* Length */
2044         length = tvb_get_guint8(tvb,offset);
2045         proto_item_set_len(ti, length+2);
2046
2047         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
2048         offset++;
2049
2050         /* Received Message */
2051         offset = dissct_rsl_msg(tvb, pinfo, ie_tree, offset);
2052
2053         return offset;
2054 }
2055
2056 /*
2057  * 9.3.39 Full BCCH Information (message name)
2058  */
2059 static int
2060 dissect_rsl_ie_full_bcch_inf(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2061 {
2062         proto_item *ti;
2063         proto_tree *ie_tree;
2064         tvbuff_t        *next_tvb;
2065         guint16 length;
2066         guint8 ie_id;
2067
2068         if(is_mandatory == FALSE){
2069                 ie_id = tvb_get_guint8(tvb,offset);
2070                 if (ie_id != RSL_IE_FULL_BCCH_INF)
2071                         return offset;
2072         }
2073
2074         ti = proto_tree_add_text(tree, tvb,offset,0,"Full BCCH Information IE");
2075         ie_tree = proto_item_add_subtree(ti, ett_ie_full_bcch_inf);
2076
2077         /* Element identifier */
2078         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2079         offset++;
2080         /* Length */
2081         length = tvb_get_guint8(tvb, offset);
2082         proto_item_set_len(ti, length+2);
2083         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
2084         offset++;
2085
2086         /*
2087          * Octets 3-25 contain the complete L3 message as defined in 3GPP TS 44.018.
2088          */
2089
2090         proto_tree_add_text(ie_tree, tvb,offset,length,"Layer 3 message");
2091         next_tvb = tvb_new_subset(tvb, offset, length, length);
2092         call_dissector(gsm_a_ccch_handle, next_tvb, pinfo, top_tree);
2093
2094         offset = offset + length;
2095
2096         return offset;
2097  }
2098
2099 /*
2100  * 9.3.40 Channel Needed
2101  */
2102 static const value_string rsl_ch_needed_vals[] = {
2103         {  0x00,        "Any Channel" },
2104         {  0x01,        "SDCCH" },
2105         {  0x02,        "TCH/F (Full rate)" },
2106         {  0x03,        "TCH/F or TCH/H (Dual rate)" },
2107         { 0,            NULL }
2108 };
2109
2110 static int
2111 dissect_rsl_ie_ch_needed(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2112 {
2113         proto_item *ti;
2114         proto_tree *ie_tree;
2115         guint8          ie_id;
2116
2117         if(is_mandatory == FALSE){
2118                 ie_id = tvb_get_guint8(tvb,offset);
2119                 if (ie_id != RSL_IE_CH_NEEDED)
2120                         return offset;
2121         }
2122
2123
2124         ti = proto_tree_add_text(tree, tvb,offset,0,"Channel Needed IE");
2125         ie_tree = proto_item_add_subtree(ti, ett_ie_ch_needed);
2126
2127         /* Element identifier */
2128         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2129         offset++;
2130
2131         /* Channel */
2132         proto_tree_add_item(ie_tree, hf_rsl_ch_needed, tvb, offset, 1, FALSE);
2133         offset++;
2134
2135         return offset;
2136 }
2137 /*
2138  * 9.3.41 CB Command type
2139  */
2140 static int
2141 dissect_rsl_ie_cb_cmd_type(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2142 {
2143         proto_item *ti;
2144         proto_tree *ie_tree;
2145         guint8          ie_id;
2146
2147         if(is_mandatory == FALSE){
2148                 ie_id = tvb_get_guint8(tvb,offset);
2149                 if (ie_id != RSL_IE_CB_CMD_TYPE)
2150                         return offset;
2151         }
2152
2153
2154         ti = proto_tree_add_text(tree, tvb,offset,0,"CB Command type IE");
2155         ie_tree = proto_item_add_subtree(ti, ett_ie_cb_cmd_type);
2156
2157         /* Element identifier */
2158         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2159         offset++;
2160
2161         /* Channel */
2162         proto_tree_add_item(ie_tree, hf_rsl_ch_needed, tvb, offset, 1, FALSE);
2163         offset++;
2164
2165         return offset;
2166 }
2167
2168 /*
2169  * 9.3.42 SMSCB Message
2170  */
2171 static int
2172 dissect_rsl_ie_smscb_mess(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2173 {
2174         proto_item *ti;
2175         proto_tree *ie_tree;
2176         guint length;
2177         guint8 ie_id;
2178         int     ie_offset;
2179
2180         if(is_mandatory == FALSE){
2181                 ie_id = tvb_get_guint8(tvb,offset);
2182                 if (ie_id != RSL_IE_SMSCB_MESS)
2183                         return offset;
2184         }
2185         ti = proto_tree_add_text(tree, tvb,offset,0,"SMSCB Message IE");
2186         ie_tree = proto_item_add_subtree(ti, ett_ie_smscb_mess);
2187
2188         /* Element identifier */
2189         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2190         offset++;
2191         /* Length */
2192         length = tvb_get_guint8(tvb,offset);
2193         proto_item_set_len(ti, length+2);
2194         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
2195         offset++;
2196         ie_offset = offset;
2197
2198         /*
2199          * SMSCB Message
2200          */
2201
2202         proto_tree_add_text(ie_tree, tvb,offset,length ,"SMSCB Message");
2203
2204         offset = ie_offset + length;
2205
2206         return offset;
2207 }
2208
2209 /*
2210  * 9.3.43 CBCH Load Information
2211  */
2212
2213 static const true_false_string rsl_cbch_load_type_vals = {
2214   "Overflow",
2215   "Underflow"
2216 };
2217
2218 static int
2219 dissect_rsl_ie_cbch_load_inf(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2220 {
2221         proto_item *ti, *item;
2222         proto_tree *ie_tree;
2223         guint8          ie_id;
2224         guint8          octet;
2225
2226         if(is_mandatory == FALSE){
2227                 ie_id = tvb_get_guint8(tvb,offset);
2228                 if (ie_id != RSL_IE_CBCH_LOAD_INF)
2229                         return offset;
2230         }
2231
2232
2233         ti = proto_tree_add_text(tree, tvb,offset,0,"CBCH Load Information IE");
2234         ie_tree = proto_item_add_subtree(ti, ett_ie_cbch_load_inf);
2235
2236         /* Element identifier */
2237         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2238         offset++;
2239
2240         octet = tvb_get_guint8(tvb,offset);
2241         /* CBCH Load Type */
2242         proto_tree_add_item(ie_tree, hf_rsl_cbch_load_type, tvb, offset, 1, FALSE);
2243
2244         /* Message Slot Count */
2245         item = proto_tree_add_item(ie_tree, hf_rsl_msg_slt_cnt, tvb, offset, 1, FALSE);
2246         if ((octet & 0x80) == 0x80){
2247                 proto_item_append_text(item,"The amount of SMSCB messages (1 to 15) that are needed immediately by BTS");
2248         }else{
2249                 proto_item_append_text(item,"The amount of delay in message slots (1 to 15) that is needed immediately by BTS");
2250         }
2251         offset++;
2252
2253         return offset;
2254 }
2255
2256 /*
2257  * 9.3.44 SMSCB Channel Indicator
2258  */
2259
2260 static const value_string rsl_ch_ind_vals[] = {
2261         {  0x00,        "Basic CBCH" },
2262         {  0x01,        "Extended CBCH (supporting the extended CBCH by the network or MSs is optional)" },
2263         { 0,            NULL }
2264 };
2265
2266 static int
2267 dissect_rsl_ie_smscb_ch_ind(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2268 {
2269         proto_item *ti;
2270         proto_tree *ie_tree;
2271         guint8          ie_id;
2272
2273         if(is_mandatory == FALSE){
2274                 ie_id = tvb_get_guint8(tvb,offset);
2275                 if (ie_id != RSL_IE_SMSCB_CH_IND)
2276                         return offset;
2277         }
2278
2279
2280         ti = proto_tree_add_text(tree, tvb,offset,0,"SMSCB Channel Indicator IE");
2281         ie_tree = proto_item_add_subtree(ti, ett_ie_smscb_ch_ind);
2282
2283         /* Element identifier */
2284         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2285         offset++;
2286
2287         /* Channel Ind */
2288         proto_tree_add_item(ie_tree, hf_rsl_ch_ind, tvb, offset, 1, FALSE);
2289         offset++;
2290
2291         return offset;
2292 }
2293
2294 /*
2295  * 9.3.45 Group call reference
2296  */
2297 static int
2298 dissect_rsl_ie_grp_call_ref(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2299 {
2300         proto_item *ti;
2301         proto_tree *ie_tree;
2302         guint length;
2303         guint8 ie_id;
2304
2305         if(is_mandatory == FALSE){
2306                 ie_id = tvb_get_guint8(tvb,offset);
2307                 if (ie_id != RSL_IE_GRP_CALL_REF)
2308                         return offset;
2309         }
2310         ti = proto_tree_add_text(tree, tvb,offset,0,"Group call reference IE");
2311         ie_tree = proto_item_add_subtree(ti, ett_ie_grp_call_ref);
2312
2313         /* Element identifier */
2314         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2315         offset++;
2316         /* Length */
2317         length = tvb_get_guint8(tvb,offset);
2318         proto_item_set_len(ti, length+2);
2319         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
2320         offset++;
2321
2322         proto_tree_add_text(ie_tree, tvb,offset,length,"Descriptive group or broadcast call reference");
2323
2324         /* The octets 3 to 7 are coded in the same way as the octets 2 to 6
2325          * in the Descriptive group or broadcast call reference
2326          * information element as defined in 3GPP TS 24.008.
2327          */
2328         de_d_gb_call_ref(tvb, ie_tree, offset, length, NULL, 0);
2329
2330         offset = offset + length;
2331
2332         return offset;
2333 }
2334 /*
2335  * 9.3.46 Channel description
2336  */
2337 static int
2338 dissect_rsl_ie_ch_desc(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2339 {
2340         proto_item *ti;
2341         proto_tree *ie_tree;
2342         guint length;
2343         guint8 ie_id;
2344
2345         if(is_mandatory == FALSE){
2346                 ie_id = tvb_get_guint8(tvb,offset);
2347                 if (ie_id != RSL_IE_CH_DESC)
2348                         return offset;
2349         }
2350         ti = proto_tree_add_text(tree, tvb,offset,0,"Channel description IE");
2351         ie_tree = proto_item_add_subtree(ti, ett_ie_ch_desc);
2352
2353         /* Element identifier */
2354         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2355         offset++;
2356         /* Length */
2357         length = tvb_get_guint8(tvb,offset);
2358         proto_item_set_len(ti, length+2);
2359         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
2360         offset++;
2361
2362         proto_tree_add_text(ie_tree, tvb,offset,length,"Group Channel Description");
2363
2364         /* Octet j (j = 3, 4, ..., n) is the unchanged octet j-2 of a radio interface Group Channel description
2365          * information element as defined in 3GPP TS 44.018, n-2 is equal to the length of the radio interface
2366          * Group channel description information element
2367          */
2368
2369         offset = offset + length;
2370
2371         return offset;
2372 }
2373 /*
2374  * 9.3.47 NCH DRX information
2375  * This is a variable length element used to pass a radio interface information element
2376  * from BSC to BTS.
2377  */
2378 static int
2379 dissect_rsl_ie_nch_drx(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2380 {
2381         proto_item *ti;
2382         proto_tree *ie_tree;
2383         guint8          ie_id;
2384
2385         if(is_mandatory == FALSE){
2386                 ie_id = tvb_get_guint8(tvb,offset);
2387                 if (ie_id != RSL_IE_NCH_DRX_INF)
2388                         return offset;
2389         }
2390
2391         ti = proto_tree_add_text(tree, tvb,offset,2,"NCH DRX information IE");
2392         ie_tree = proto_item_add_subtree(ti, ett_ie_nch_drx);
2393
2394         /* Element identifier */
2395         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2396         offset++;
2397         /* NCH DRX information */
2398         /* Octet 3 bits 7 and 8 are spare and set to zero. */
2399         /* Octet 3 bit 6 is the NLN status parameter as defined in 3GPP TS 44.018.*/
2400         /* Octet 3 bits 3, 4 and 5 are bits 1, 2 and 3 of the radio interface
2401          * eMLPP priority as defined in 3GPP TS 44.018.
2402          */
2403         /* Octet 3 bits 1 and 2 are bits 1 and 2 of the radio interface NLN
2404          * as defined in 3GPP TS 44.018.
2405          */
2406
2407         offset++;
2408
2409         return offset;
2410 }
2411 /*
2412  * 9.3.48 Command indicator
2413  */
2414
2415 static int
2416 dissect_rsl_ie_cmd_ind(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2417 {
2418         proto_item *ti;
2419         proto_tree *ie_tree;
2420         guint8          ie_id;
2421         guint8          octet;
2422
2423         if(is_mandatory == FALSE){
2424                 ie_id = tvb_get_guint8(tvb,offset);
2425                 if (ie_id != RSL_IE_CMD_IND)
2426                         return offset;
2427         }
2428
2429
2430         /* TODO Length wrong if extended */
2431         ti = proto_tree_add_text(tree, tvb,offset,2,"Command indicator IE");
2432         ie_tree = proto_item_add_subtree(ti, ett_ie_cmd_ind);
2433
2434         /* Element identifier */
2435         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2436         offset++;
2437
2438         /* Extension bit */
2439         proto_tree_add_item(ie_tree, hf_rsl_extension_bit, tvb, offset, 1, FALSE);
2440
2441
2442         /* TODO this should probably be add_uint instead!!! */
2443         octet = tvb_get_guint8(tvb,offset);
2444         if ((octet&0x80)==0x80){
2445                 /* extended */
2446                 /* Command Extension */
2447                 proto_tree_add_item(ie_tree, hf_rsl_command, tvb, offset, 2, FALSE);
2448                 offset = offset+2;
2449         }else{
2450                 /* Command Value */
2451                 proto_tree_add_item(ie_tree, hf_rsl_command, tvb, offset, 1, FALSE);
2452                 offset++;
2453         }
2454
2455         return offset;
2456 }
2457 /*
2458  * 9.3.49 eMLPP Priority
2459  */
2460 static const value_string rsl_emlpp_prio_vals[] = {
2461         {  0x00,        "no priority applied" },
2462         {  0x01,        "call priority level 4" },
2463         {  0x02,        "call priority level 3" },
2464         {  0x03,        "call priority level 2" },
2465         {  0x04,        "call priority level 1" },
2466         {  0x05,        "call priority level 0" },
2467         {  0x06,        "call priority level B" },
2468         {  0x07,        "call priority level A" },
2469         { 0,                    NULL }
2470 };
2471
2472 static int
2473 dissect_rsl_ie_emlpp_prio(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2474 {
2475         proto_item *ti;
2476         proto_tree *ie_tree;
2477         guint8          ie_id;
2478
2479         if(is_mandatory == FALSE){
2480                 ie_id = tvb_get_guint8(tvb,offset);
2481                 if (ie_id != RSL_IE_EMLPP_PRIO)
2482                         return offset;
2483         }
2484
2485         ti = proto_tree_add_text(tree, tvb,offset,2,"eMLPP Priority IE");
2486         ie_tree = proto_item_add_subtree(ti, ett_ie_emlpp_prio);
2487
2488         /* Element identifier */
2489         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2490         offset++;
2491
2492         /* The call priority field (bit 3 to 1 of octet 2) is coded in the same way
2493          * as the call priority field (bit 3 to 1 of octet 5) in the
2494          * Descriptive group or broadcast call reference information element
2495          * as defined in 3GPP TS 24.008.
2496          */
2497         proto_tree_add_item(ie_tree, hf_rsl_emlpp_prio, tvb, offset, 1, FALSE);
2498         offset++;
2499
2500         return offset;
2501 }
2502
2503 /*
2504  * 9.3.50 UIC
2505  */
2506 static int
2507 dissect_rsl_ie_uic(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2508 {
2509         proto_item *ti;
2510         proto_tree *ie_tree;
2511         guint8          ie_id;
2512
2513         if(is_mandatory == FALSE){
2514                 ie_id = tvb_get_guint8(tvb,offset);
2515                 if (ie_id != RSL_IE_UIC)
2516                         return offset;
2517         }
2518
2519         ti = proto_tree_add_text(tree, tvb,offset,0,"UIC IE");
2520         ie_tree = proto_item_add_subtree(ti, ett_ie_uic);
2521
2522         /* Element identifier */
2523         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2524         offset++;
2525
2526         /* Octet 3 bits 1 to 6 contain the radio interface octet 2 bits 3 to 8 of the
2527          * UIC information element as defined in 3GPP TS 44.018.
2528          */
2529         proto_tree_add_text(ie_tree, tvb,offset,1,"UIC");
2530         offset++;
2531
2532         return offset;
2533 }
2534
2535 /*
2536  * 9.3.51 Main channel reference
2537  */
2538
2539 static int
2540 dissect_rsl_ie_main_ch_ref(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2541 {
2542         proto_item *ti;
2543         proto_tree *ie_tree;
2544         guint8          ie_id;
2545
2546         if(is_mandatory == FALSE){
2547                 ie_id = tvb_get_guint8(tvb,offset);
2548                 if (ie_id != RSL_IE_MAIN_CH_REF)
2549                         return offset;
2550         }
2551
2552         ti = proto_tree_add_text(tree, tvb,offset,0,"Main channel reference IE");
2553         ie_tree = proto_item_add_subtree(ti, ett_ie_main_ch_ref);
2554
2555         /* Element identifier */
2556         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2557         offset++;
2558
2559         /* TN is time slot number, binary represented as in 3GPP TS 45.002.
2560          * 3 Bits
2561          */
2562         proto_tree_add_item(ie_tree, hf_rsl_ch_no_TN, tvb, offset, 1, FALSE);
2563         offset++;
2564         return offset;
2565 }
2566
2567 /*
2568  * 9.3.52 MultiRate configuration
2569  */
2570
2571 static int
2572 dissect_rsl_ie_multirate_conf(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2573 {
2574         proto_item *ti;
2575         proto_tree *ie_tree;
2576         guint length;
2577         guint8 ie_id;
2578
2579         if(is_mandatory == FALSE){
2580                 ie_id = tvb_get_guint8(tvb,offset);
2581                 if (ie_id != RSL_IE_MULTIRATE_CONF)
2582                         return offset;
2583         }
2584         ti = proto_tree_add_text(tree, tvb,offset,0,"MultiRate configuration IE");
2585         ie_tree = proto_item_add_subtree(ti, ett_ie_multirate_conf);
2586
2587         /* Element identifier */
2588         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2589         offset++;
2590         /* Length */
2591         length = tvb_get_guint8(tvb,offset);
2592         proto_item_set_len(ti, length+2);
2593         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
2594         offset++;
2595
2596         /* Rest of element coded as in 3GPP TS 44.018 not including
2597          * 3GPP TS 44.018 element identifier or 3GPP TS 44.018 octet length value
2598          */
2599
2600         de_rr_multirate_conf(tvb, ie_tree, offset, length, NULL, 0);
2601
2602         offset = offset + length;
2603
2604         return offset;
2605 }
2606
2607 /*
2608  * 9.3.53 MultiRate Control
2609  */
2610 static int
2611 dissect_rsl_ie_multirate_cntrl(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2612 {
2613         proto_item *ti;
2614         proto_tree *ie_tree;
2615         guint8 ie_id;
2616
2617         if(is_mandatory == FALSE){
2618                 ie_id = tvb_get_guint8(tvb,offset);
2619                 if (ie_id != RSL_IE_MULTIRATE_CNTRL)
2620                         return offset;
2621         }
2622         ti = proto_tree_add_text(tree, tvb,offset,2,"MultiRate Control IE");
2623         ie_tree = proto_item_add_subtree(ti, ett_ie_multirate_cntrl);
2624
2625         /* Element identifier */
2626         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2627         offset++;
2628
2629         /* Bit 8 -5 Spare */
2630         /* The OD field (bit 5 of octet 3) indicates if the BSC expects distant parameters or
2631          * TFO Decision algorithm result from the BTS
2632          */
2633         /* The PRE field (bit 4 of octet 3) indicates if an handover is to be expected soon or not. */
2634         /* The RAE field (bits 2-3, octet 3) defines whether the RATSCCH mechanism is enabled or not.*/
2635         offset++;
2636
2637         return offset;
2638 }
2639
2640 /*
2641  * 9.3.54 Supported Codec Types
2642  * This element indicates the codec types supported by the BSS or remote BSS.
2643  */
2644 static int
2645 dissect_rsl_ie_sup_codec_types(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2646 {
2647         proto_item *ti;
2648         proto_tree *ie_tree;
2649         guint length;
2650         guint8 ie_id;
2651
2652         if(is_mandatory == FALSE){
2653                 ie_id = tvb_get_guint8(tvb,offset);
2654                 if (ie_id != RSL_IE_SUP_CODEC_TYPES)
2655                         return offset;
2656         }
2657         ti = proto_tree_add_text(tree, tvb,offset,0,"Supported Codec Types IE");
2658         ie_tree = proto_item_add_subtree(ti, ett_ie_sup_codec_types);
2659
2660         /* Element identifier */
2661         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2662         offset++;
2663         /* Length */
2664         length = tvb_get_guint8(tvb,offset);
2665         proto_item_set_len(ti, length+2);
2666         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
2667         offset++;
2668
2669         proto_tree_add_text(tree, tvb,offset,length,"Codec List");
2670
2671         /* The Codec List field (octet 4) lists the codec types that are supported
2672          * by the BSS and Transcoder, and are therefore potential candidates for TFO
2673          * establishment.
2674          */
2675         /* The Codec List extension 1 field (octet 5) lists additional codec types
2676          * that are supported by the BSS and Transcoder, and are therefore potential
2677          * candidates for TFO establishment. When no codec from this list is supported,
2678          * then this field shall not be sent, and the extension bit of octet 4 shall
2679          * be set to 0.
2680          */
2681         /* If bit 4 of the Codec List field (octet 4) indicates that FR AMR is supported
2682          * or if bit 5 of the Codec List field (octet 4) indicates that HR AMR is supported
2683          * and bit 8 is set to 0, or if bit 6 of the Codec List field (octet 4) indicates
2684          * that UMTS AMR is supported, or if bit 7 of the Codec List field (octet 4)
2685          * indicates that UMTS AMR 2 is supported, or if bit 1, 3, 4 or 5 of the Codec List
2686          * extension 1 field (octet 5) indicates that AMR WB is supported, the following
2687          * two octets (after the Codec List field and its extensions) is present
2688          */
2689
2690         return offset + length;
2691
2692 }
2693 /*
2694  * 9.3.55 Codec Configuration
2695  */
2696 /* The Active Codec Type field (bits 1-8, octet 3) indicates the type of codec in use. It is coded as follows: */
2697 /*
2698 0 0 0 0 . 0 0 0 0: Full Rate Codec in use
2699 0 0 0 0 . 0 0 0 1: Half Rate Codec in use
2700 0 0 0 0 . 0 0 1 0: Enhanced Full Rate Codec in use
2701 0 0 0 0 . 0 0 1 1: FR Adaptive Multi Rate Codec in use
2702 0 0 0 0 . 0 1 0 0: HR Adaptive Multi Rate Codec in use
2703 0 0 0 0 . 0 1 0 1: UMTS Adaptive Multi Rate Codec in use
2704 0 0 0 0 . 0 1 1 0: UMTS Adaptive Multi Rate 2 Codec in use
2705 0 0 0 0 . 1 0 0 1: Full Rate Adaptive Multi-Rate WideBand Codec in use
2706 0 0 0 0 1 0 1 0 UMTS Adaptive Multi-Rate WideBand Codec in use
2707 0 0 0 0 1 0 1 1 8PSK Half Rate Adaptive Multi-Rate Codec in use
2708 0 0 0 0 1 1 0 0 8PSK Full Rate Adaptive Multi-Rate WideBand Codec in use
2709 0 0 0 0 1 1 0 1 8PSK Half Rate Adaptive Multi-Rate WideBand Codec in use
2710 All other values are reserved for future use
2711 */
2712 static int
2713 dissect_rsl_ie_codec_conf(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2714 {
2715         proto_item *ti;
2716         proto_tree *ie_tree;
2717         guint length;
2718         guint8 ie_id;
2719
2720         if(is_mandatory == FALSE){
2721                 ie_id = tvb_get_guint8(tvb,offset);
2722                 if (ie_id != RSL_IE_CODEC_CONF)
2723                         return offset;
2724         }
2725         ti = proto_tree_add_text(tree, tvb,offset,0,"Codec Configuration IE");
2726         ie_tree = proto_item_add_subtree(ti, ett_ie_codec_conf);
2727
2728         /* Element identifier */
2729         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2730         offset++;
2731         /* Length */
2732         length = tvb_get_guint8(tvb,offset);
2733         proto_item_set_len(ti, length+2);
2734         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
2735         offset++;
2736
2737         /* Active Codec Type */
2738
2739         return offset + length;
2740 }
2741
2742 /*
2743  * 9.3.56 Round Trip Delay
2744  * This element indicates the value of the calculated round trip delay between the BTS
2745  * and the transcoder, or between the BTS and the remote BTS, if TFO is established.
2746  */
2747
2748 static const value_string rsl_delay_ind_vals[] = {
2749         {  0x00,        "The RTD field contains the BTS-Transcoder round trip delay" },
2750         {  0x01,        "The RTD field contains the BTS-Remote BTS round trip delay" },
2751         { 0,                    NULL }
2752 };
2753 static int
2754 dissect_rsl_ie_rtd(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2755 {
2756         proto_item *ti, *rtd_item;
2757         proto_tree *ie_tree;
2758         guint8          ie_id;
2759         guint8          rtd;
2760
2761         if(is_mandatory == FALSE){
2762                 ie_id = tvb_get_guint8(tvb,offset);
2763                 if (ie_id != RSL_IE_RTD)
2764                         return offset;
2765         }
2766
2767         ti = proto_tree_add_text(tree, tvb,offset,0,"Round Trip Delay IE");
2768         ie_tree = proto_item_add_subtree(ti, ett_ie_rtd);
2769
2770         /* Element identifier */
2771         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2772         offset++;
2773
2774         /* The RTD field is the binary representation of the value of the
2775          * round trip delay in 20 ms increments.
2776          */
2777         rtd = (tvb_get_guint8(tvb,offset)>>1)*20;
2778         rtd_item = proto_tree_add_uint(tree, hf_rsl_rtd, tvb,offset,1,rtd);
2779         proto_item_append_text(rtd_item," ms");
2780
2781         /* The Delay IND field indicates if the delay corresponds to a BTS
2782          * to transcoder delay or to a BTS to remote BTS delay.
2783          */
2784         proto_tree_add_item(ie_tree, hf_rsl_delay_ind, tvb, offset, 1, FALSE);
2785         offset++;
2786
2787         return offset;
2788 }
2789 /*
2790  * 9.3.57 TFO Status
2791  * This element indicates if TFO is established. It is coded in 2 octets
2792  */
2793
2794 static const true_false_string rsl_tfo_vals = {
2795   "TFO is established",
2796   "TFO is not established"
2797 };
2798
2799 static int
2800 dissect_rsl_ie_tfo_status(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2801 {
2802         proto_item *ti;
2803         proto_tree *ie_tree;
2804         guint8          ie_id;
2805
2806         if(is_mandatory == FALSE){
2807                 ie_id = tvb_get_guint8(tvb,offset);
2808                 if (ie_id != RSL_IE_TFO_STATUS)
2809                         return offset;
2810         }
2811
2812         ti = proto_tree_add_text(tree, tvb,offset,0,"TFO Status IE");
2813         ie_tree = proto_item_add_subtree(ti, ett_ie_tfo_status);
2814
2815         /* Element identifier */
2816         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2817         offset++;
2818
2819         proto_tree_add_item(ie_tree, hf_rsl_tfo, tvb, offset, 1, FALSE);
2820         offset++;
2821         return offset;
2822 }
2823 /*
2824  * 9.3.58 LLP APDU
2825  */
2826
2827 static int
2828 dissect_rsl_ie_llp_apdu(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2829 {
2830         proto_item *ti;
2831         proto_tree *ie_tree;
2832         guint8 length;
2833         int ie_offset;
2834         guint8 ie_id;
2835
2836         if(is_mandatory == FALSE){
2837                 ie_id = tvb_get_guint8(tvb,offset);
2838                 if (ie_id != RSL_IE_LLP_APDU)
2839                         return offset;
2840         }
2841
2842         ti = proto_tree_add_text(tree, tvb,offset,0,"LLP APDU IE");
2843         ie_tree = proto_item_add_subtree(ti, ett_ie_llp_apdu);
2844
2845         /* Element identifier */
2846         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2847         offset++;
2848         /* Length */
2849         length = tvb_get_guint8(tvb, offset);
2850         proto_item_set_len(ti, length+2);
2851         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
2852         offset++;
2853
2854         ie_offset = offset;
2855
2856         /* The rest of the information element contains the embedded message
2857          * that contains a Facility Information Element as defined in
2858          * 3GPP TS 44.071 excluding the Facility IEI and length of Facility IEI
2859          * octets defined in 3GPP TS 44.071.
2860          */
2861         /* TODO: Given traces with LLP data this IE could be further dissected */
2862         proto_tree_add_text(tree, tvb,offset,length,
2863                 "Facility Information Element as defined in 3GPP TS 44.071");
2864         return ie_offset + length;
2865 }
2866 /*
2867  * 9.3.59 TFO transparent container
2868  * This is a variable length element that conveys a message associated with TFO protocol,
2869  * as defined in 3GPP TS 28.062. This element can be sent from the BSC to the BTS or
2870  * from the BTS to the BSC. The BTS shall retrieve the information it is able to understand,
2871  * and forward transparently the complete information to the BSC or to the TRAU.
2872  */
2873 static int
2874 dissect_rsl_ie_tfo_transp_cont(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2875 {
2876         proto_item *ti;
2877         proto_tree *ie_tree;
2878         guint8 length;
2879         int ie_offset;
2880         guint8 ie_id;
2881
2882         if(is_mandatory == FALSE){
2883                 ie_id = tvb_get_guint8(tvb,offset);
2884                 if (ie_id != RSL_IE_TFO_TRANSP_CONT)
2885                         return offset;
2886         }
2887
2888         ti = proto_tree_add_text(tree, tvb,offset,0,"TFO transparent container IE");
2889         ie_tree = proto_item_add_subtree(ti, ett_ie_tfo_transp_cont);
2890
2891         /* Element identifier */
2892         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2893         offset++;
2894         /* Length */
2895         length = tvb_get_guint8(tvb, offset);
2896         proto_item_set_len(ti, length+2);
2897         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
2898         offset++;
2899
2900         ie_offset = offset;
2901
2902         /* The rest of the information element contains the embedded message
2903          * that contains a Facility Information Element as defined in
2904          * 3GPP TS 44.071 excluding the Facility IEI and length of Facility IEI
2905          * octets defined in 3GPP TS 44.071.
2906          */
2907         proto_tree_add_text(tree, tvb,offset,length,
2908                 "Embedded message that contains the TFO configuration");
2909         return ie_offset + length;
2910 }
2911
2912 static int
2913 dissct_rsl_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
2914 {
2915         guint8  msg_type;
2916
2917         msg_type = tvb_get_guint8(tvb,offset)&0x7f;
2918         proto_tree_add_item(tree, hf_rsl_msg_type, tvb, offset, 1, FALSE);
2919         offset++;
2920
2921         switch (msg_type){
2922 /* Radio Link Layer Management messages */
2923         /* 8.3.1 DATA REQUEST */
2924         case RSL_MSG_TYPE_DATA_REQ:
2925                 /* Channel number                       9.3.1   M TV 2          */
2926                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
2927                 /* Link Identifier                      9.3.2   M TV 2          */
2928                 offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset, TRUE);
2929                 /* L3 Information                       9.3.11  M TLV >=3       */
2930                 offset = dissect_rsl_ie_L3_inf(tvb, pinfo, tree, offset, TRUE);
2931                 break;
2932         /* 8.3.2 DATA INDICATION */
2933         case RSL_MSG_TYPE_DATA_IND:
2934                 /* Channel number                       9.3.1   M TV 2          */
2935                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
2936                 /* Link Identifier                      9.3.2   M TV 2          */
2937                 offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset, TRUE);
2938                 /* L3 Information                       9.3.11  M TLV >=3       */
2939                 offset = dissect_rsl_ie_L3_inf(tvb, pinfo, tree, offset, TRUE);
2940                 break;
2941         /* 8.3.3 ERROR INDICATION */
2942         case RSL_MSG_TYPE_ERROR_IND:
2943                 /* Channel number                       9.3.1   M TV 2          */
2944                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
2945                 /* Link Identifier                      9.3.2   M TV 2          */
2946                 offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset, TRUE);
2947                 /* RLM Cause                            9.3.22  M TLV 2-4       */
2948                 offset = dissect_rsl_ie_rlm_cause(tvb, pinfo, tree, offset, TRUE);
2949                 break;
2950         /* 8.3.4 ESTABLISH REQUEST */
2951         case RSL_MSG_TYPE_EST_REQ:
2952                 /* Channel number                       9.3.1   M TV 2          */
2953                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
2954                 /* Link Identifier                      9.3.2   M TV 2          */
2955                 offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset, TRUE);
2956                 break;
2957         /* 8.3.5 ESTABLISH CONFIRM */
2958         case RSL_MSG_TYPE_EST_CONF:
2959                 /* Channel number                       9.3.1   M TV 2          */
2960                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
2961                 /* Link Identifier                      9.3.2   M TV 2          */
2962                 offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset, TRUE);
2963                 break;
2964         /* 8.3.6 */
2965         case RSL_MSG_EST_IND:
2966                 /*      Channel number                  9.3.1   M TV 2                           */
2967                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
2968                 /*      Link Identifier                 9.3.2   M TV 2                           */
2969                 offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset, TRUE);
2970                 /*      L3 Information                  9.3.11  O (note 1) TLV 3-23      */
2971                 if(tvb_length_remaining(tvb,offset) >1)
2972                         offset = dissect_rsl_ie_L3_inf(tvb, pinfo, tree, offset, FALSE);
2973                 break;
2974         /* 8.3.7 RELEASE REQUEST */
2975         case RSL_MSG_REL_REQ:
2976                 /*      Channel number                  9.3.1   M TV 2                           */
2977                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
2978                 /*      Link Identifier                 9.3.2   M TV 2                           */
2979                 offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset, TRUE);
2980                 /* Release Mode                         9.3.20  M TV 2                          */
2981                 offset = dissect_rsl_ie_rel_mode(tvb, pinfo, tree, offset, TRUE);
2982                 break;
2983         /* 8.3.8 RELEASE CONFIRM */
2984         case RSL_MSG_REL_CONF:
2985                 /*      Channel number                  9.3.1   M TV 2                           */
2986                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
2987                 /*      Link Identifier                 9.3.2   M TV 2                           */
2988                 offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset, TRUE);
2989                 break;
2990         /* 8.3.9 RELEASE INDICATION */
2991         case RSL_MSG_REL_IND:
2992                 /*      Channel number                  9.3.1   M TV 2                           */
2993                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
2994                 /*      Link Identifier                 9.3.2   M TV 2                           */
2995                 offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset, TRUE);
2996                 break;
2997         /* 8.3.10 UNIT DATA REQUEST 10 */
2998         case RSL_MSG_UNIT_DATA_REQ:
2999                 /*      Channel number                  9.3.1   M TV 2                           */
3000                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3001                 /*      Link Identifier                 9.3.2   M TV 2                           */
3002                 offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset, TRUE);
3003                 /*      L3 Information                  9.3.11  O (note 1) TLV 3-23      */
3004                 if(tvb_length_remaining(tvb,offset) > 0)
3005                         offset = dissect_rsl_ie_L3_inf(tvb, pinfo, tree, offset, FALSE);
3006                 break;
3007 /* Common Channel Management/TRX Management messages */
3008         /* 8.5.1 BCCH INFORMATION 17*/
3009         case RSL_MSG_BCCH_INFO:
3010                 /*      Channel number                  9.3.1   M TV 2 */
3011                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3012                 /*      System Info Type                9.3.30  M TV 2 */
3013                 offset = dissect_rsl_ie_sys_info_type(tvb, pinfo, tree, offset, TRUE);
3014                 /*      Full BCCH Info (SYS INFO) 9.3.39 O 1) TLV 25 */
3015                 if(tvb_length_remaining(tvb,offset) > 0)
3016                         offset = dissect_rsl_ie_full_bcch_inf(tvb, pinfo, tree, offset, TRUE);
3017                 /*      Starting Time                   9.3.23  O 2) TV 3 */
3018                 if(tvb_length_remaining(tvb,offset) > 0)
3019                         offset = dissect_rsl_ie_staring_time(tvb, pinfo, tree, offset, FALSE);
3020                 break;
3021         /* 8.5.2 CCCH LOAD INDICATION 18*/
3022         case RSL_MSG_CCCH_LOAD_IND:
3023                 /*      Channel number (note)   9.3.1   M TV 2 */
3024                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3025                 /* Either RACH Load or Paging Load present */
3026                 /*      RACH Load                               9.3.18  C 1) TLV >=8 */
3027                 offset = dissect_rsl_ie_rach_load(tvb, pinfo, tree, offset, FALSE);
3028                 /*      Paging Load                             9.3.15  C 2) TV 3 */
3029                 if(tvb_length_remaining(tvb,offset) > 0)
3030                         offset = dissect_rsl_ie_paging_load(tvb, pinfo, tree, offset, FALSE);
3031                 break;
3032         /* 8.5.3 */
3033         case RSL_MSG_CHANRQD: /* 19 */
3034                 /* Channel number                       9.3.1   M TV 2 */
3035                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3036                 /* Request Reference            9.3.19  M TV 4 */
3037                 offset = dissect_rsl_ie_req_ref(tvb, pinfo, tree, offset, TRUE);
3038                 /* Access Delay                         9.3.17  M TV 2 */
3039                 offset = dissect_rsl_ie_access_delay(tvb, pinfo, tree, offset, TRUE);
3040                 /* Physical Context                     9.3.16  O 1) TLV >=2 */
3041                 if(tvb_length_remaining(tvb,offset) > 0)
3042                         offset = dissect_rsl_ie_phy_ctx(tvb, pinfo, tree, offset, FALSE);
3043                 break;
3044         /* 8.5.4 DELETE INDICATION */
3045         case RSL_MSG_DELETE_IND: /* 20 */
3046                 /* Channel number                       9.3.1   M TV 2 */
3047                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3048                 /* Full Imm. Assign Info        9.3.35  M TLV 25 */
3049                 offset = dissect_rsl_ie_full_imm_ass_inf(tvb, pinfo, tree, offset, TRUE);
3050                 break;
3051         case RSL_MSG_PAGING_CMD:        /* 21 */
3052                 /* Channel number                       9.3.1   M TV 2 */
3053                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3054                 /* Paging Group                         9.3.14  M TV 2 2 */
3055                 offset = dissect_rsl_ie_paging_grp(tvb, pinfo, tree, offset, TRUE);
3056                 /* MS Identity                          9.3.12  M TLV 2-10 2 */
3057                 offset = dissect_rsl_ie_ms_id(tvb, pinfo, tree, offset, TRUE);
3058                 /* Channel Needed                       9.3.40  O 1) TV 2 2 */
3059                 if(tvb_length_remaining(tvb,offset) > 0)
3060                         offset = dissect_rsl_ie_ch_needed(tvb, pinfo, tree, offset, FALSE);
3061                 /* eMLPP Priority                       9.3.49  O 2) TV 2 2 */
3062                 if(tvb_length_remaining(tvb,offset) > 0)
3063                         offset = dissect_rsl_ie_emlpp_prio(tvb, pinfo, tree, offset, FALSE);
3064                 break;
3065         /* 8.5.6 IMMEDIATE ASSIGN COMMAND */
3066         case RSL_MSG_IMM_ASS_CMD:       /* 22 */
3067                 /* Channel number                       9.3.1   M TV 2 */
3068                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3069                 /* Full Imm. Assign Info        9.3.35  M TLV 25 */
3070                 offset = dissect_rsl_ie_full_imm_ass_inf(tvb, pinfo, tree, offset, TRUE);
3071                 break;
3072         /* 8.5.7 SMS BROADCAST REQUEST */
3073         case RSL_MSG_SMS_BC_REQ:        /*      23       8.5.7 */
3074                 /* Channel number                       9.3.1   M TV 2 */
3075                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3076                 /* SMSCB Information            9.3.36  M TV 24 */
3077                 offset = dissect_rsl_ie_smscb_inf(tvb, pinfo, tree, offset, TRUE);
3078                 /* SMSCB Channel Indicator      9.3.44  O 1) TV 2 */
3079                 if(tvb_length_remaining(tvb,offset) > 0)
3080                         offset = dissect_rsl_ie_smscb_ch_ind(tvb, pinfo, tree, offset, FALSE);
3081                 break;
3082 /* 8.6 TRX MANAGEMENT MESSAGES */
3083         /* 8.6.1 RF RESOURCE INDICATION */
3084         case RSL_MSG_RF_RES_IND:        /*      24       8.6.1 */
3085                 /* Resource Information         9.3.21  M TLV >=2 */
3086                 offset = dissect_rsl_ie_resource_inf(tvb, pinfo, tree, offset, TRUE);
3087                 break;
3088         /* 8.6.2 SACCH FILLING */
3089         case RSL_MSG_SACCH_FILL:        /*      25       8.6.2 */
3090                 /* System Info Type                     9.3.30  M TV 2 */
3091                 offset = dissect_rsl_ie_sys_info_type(tvb, pinfo, tree, offset, TRUE);
3092                 /* L3 Info (SYS INFO)           9.3.11 O 1) TLV 22 */
3093                 if(tvb_length_remaining(tvb,offset) > 0)
3094                         offset = dissect_rsl_ie_L3_inf(tvb, pinfo, tree, offset, FALSE);
3095                 /* Starting Time                        9.3.23 O 2) TV 3 */
3096                 if(tvb_length_remaining(tvb,offset) > 0)
3097                         offset = dissect_rsl_ie_staring_time(tvb, pinfo, tree, offset, FALSE);
3098                 break;
3099         case RSL_MSG_OVERLOAD:          /*      27       8.6.3 */
3100                 /* Cause                                        9.3.26  M TLV >=3 */
3101                 offset = dissect_rsl_ie_cause(tvb, pinfo, tree, offset, TRUE);
3102                 break;
3103         case RSL_MSG_ERROR_REPORT:      /*      28       8.6.4 */
3104                 /* Cause                                        9.3.26  M TLV >=3 */
3105                 offset = dissect_rsl_ie_cause(tvb, pinfo, tree, offset, TRUE);
3106                 /* Message Identifier           9.3.28  O 1) TV 2 */
3107                 if(tvb_length_remaining(tvb,offset) > 0)
3108                         offset = dissect_rsl_ie_message_id(tvb, pinfo, tree, offset, FALSE);
3109                 /* Channel Number                       9.3.1   O 2) TV 2 */
3110                 if(tvb_length_remaining(tvb,offset) > 0)
3111                         offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3112                 /* Link identifier                      9.3.2   O 3) TV 2 */
3113                 if(tvb_length_remaining(tvb,offset) > 0)
3114                         offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset, TRUE);
3115                 /* Erroneous Message            9.3.38  O 4) TLV >=3 */
3116                 if(tvb_length_remaining(tvb,offset) > 0)
3117                         offset = dissect_rsl_ie_err_msg(tvb, pinfo, tree, offset, TRUE);
3118                 break;
3119         /* 8.5.8 SMS BROADCAST COMMAND */
3120         case RSL_MSG_SMS_BC_CMD:        /*      29       8.5.8 */
3121                 /* Channel number                       9.3.1   M TV 2 */
3122                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3123                 /* CB Command type                      9.3.41  M TV 2 */
3124                 offset = dissect_rsl_ie_cb_cmd_type(tvb, pinfo, tree, offset, TRUE);
3125                 /* SMSCB message                        9.3.42  M TLV 2-90 */
3126                 offset = dissect_rsl_ie_smscb_mess(tvb, pinfo, tree, offset, TRUE);
3127                 /* SMSCB Channel Indicator      9.3.44  O 1) TV 2 */
3128                 if(tvb_length_remaining(tvb,offset) > 0)
3129                         offset = dissect_rsl_ie_smscb_ch_ind(tvb, pinfo, tree, offset, FALSE);
3130                 break;
3131         case RSL_MSG_CBCH_LOAD_IND:     /*      30       8.5.9 */
3132                 /* Channel number                       9.3.1   M TV 2 */
3133                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3134                 /* CBCH Load Information        9.3.43  M TV 2 */
3135                 offset = dissect_rsl_ie_cbch_load_inf(tvb, pinfo, tree, offset, TRUE);
3136                 /* SMSCB Channel Indicator      9.3.44 O 1) TV 2 */
3137                 if(tvb_length_remaining(tvb,offset) > 0)
3138                         offset = dissect_rsl_ie_smscb_ch_ind(tvb, pinfo, tree, offset, FALSE);
3139                 break;
3140         case RSL_MSG_NOT_CMD:           /*      31       8.5.10 */
3141                 /* Channel number                       9.3.1   M TV 2 */
3142                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3143                 /* Command indicator            9.3.48 M 1) TLV 3-4 */
3144                 offset = dissect_rsl_ie_cmd_ind(tvb, pinfo, tree, offset, TRUE);
3145                 /* Group call reference         9.3.45 O TLV 7 */
3146                 if(tvb_length_remaining(tvb,offset) > 0)
3147                         offset = dissect_rsl_ie_grp_call_ref(tvb, pinfo, tree, offset, FALSE);
3148                 /* Channel Description          9.3.46 O TLV 3-n */
3149                 if(tvb_length_remaining(tvb,offset) > 0)
3150                         offset = dissect_rsl_ie_ch_desc(tvb, pinfo, tree, offset, FALSE);
3151                 /* NCH DRX information          9.3.47 O TLV 3 */
3152                 if(tvb_length_remaining(tvb,offset) > 0)
3153                         offset = dissect_rsl_ie_nch_drx(tvb, pinfo, tree, offset, FALSE);
3154                 break;
3155
3156 /* Dedicated Channel Management messages: */
3157         /* 8.4.1 CHANNEL ACTIVATION 33*/
3158         case RSL_MSG_CHAN_ACTIV:
3159                 /* Channel number                       9.3.1   M TV 2                  */
3160                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3161                 /* Activation Type                      9.3.3   M TV 2                  */
3162                 offset = dissect_rsl_ie_act_type(tvb, pinfo, tree, offset, TRUE);
3163                 /* Channel Mode                         9.3.6   M TLV 8-9               */
3164                 offset = dissect_rsl_ie_ch_mode(tvb, pinfo, tree, offset, TRUE);
3165                 /* Channel Identification       9.3.5   O 7) TLV 8              */
3166                 if(tvb_length_remaining(tvb,offset) > 0)
3167                         offset = dissect_rsl_ie_ch_id(tvb, pinfo, tree, offset, FALSE);
3168                 /* Encryption information       9.3.7   O 1) TLV >=3    */
3169                 if(tvb_length_remaining(tvb,offset) > 0)
3170                         offset = dissect_rsl_ie_enc_inf(tvb, pinfo, tree, offset, FALSE);
3171                 /* Handover Reference           9.3.9   C 2) TV 2               */
3172                 if(tvb_length_remaining(tvb,offset) > 0)
3173                         offset = dissect_rsl_ie_ho_ref(tvb, pinfo, tree, offset, FALSE);
3174                 /* BS Power                                     9.3.4   O 3) TV 2               */
3175                 if(tvb_length_remaining(tvb,offset) > 0)
3176                         offset = dissect_rsl_ie_bs_power(tvb, pinfo, tree, offset, FALSE);
3177                 /* MS Power                                     9.3.13  O 3) TV 2               */
3178                 if(tvb_length_remaining(tvb,offset) > 0)
3179                         offset = dissect_rsl_ie_ms_pow(tvb, pinfo, tree, offset, FALSE);
3180                 /* Timing Advance                       9.3.24  C 3) 4) TV 2    */
3181                 if(tvb_length_remaining(tvb,offset) > 0)
3182                         offset = dissect_rsl_ie_timing_adv(tvb, pinfo, tree, offset, FALSE);
3183                 /* BS Power Parameters          9.3.32  O 5) TLV >=2    */
3184                 /* MS Power Parameters          9.3.31  O 5) TLV >=2    */
3185                 /* Physical Context                     9.3.16  O 6) TLV >=2    */
3186                 if(tvb_length_remaining(tvb,offset) > 0)
3187                         offset = dissect_rsl_ie_phy_ctx(tvb, pinfo, tree, offset, FALSE);
3188                 /* SACCH Information            9.3.29  O 8) TLV >=3    */
3189                 /* UIC                                          9.3.50  O 9) TLV 3              */
3190                 if(tvb_length_remaining(tvb,offset) > 0)
3191                         offset = dissect_rsl_ie_uic(tvb, pinfo, tree, offset, FALSE);
3192                 /* Main channel reference       9.3.51  O 10) TV 2              */
3193                 if(tvb_length_remaining(tvb,offset) > 0)
3194                         offset = dissect_rsl_ie_main_ch_ref(tvb, pinfo, tree, offset, FALSE);
3195                 /* MultiRate configuration      9.3.52  O 11) TLV >=4   */
3196                 if(tvb_length_remaining(tvb,offset) > 0)
3197                         offset = dissect_rsl_ie_multirate_conf(tvb, pinfo, tree, offset, FALSE);
3198                 /* MultiRate Control            9.3.53  O 12) TV 2              */
3199                 if(tvb_length_remaining(tvb,offset) > 0)
3200                         offset = dissect_rsl_ie_multirate_cntrl(tvb, pinfo, tree, offset, FALSE);
3201                         /* Supported Codec Types        9.3.54  O 12) TLV >=5   */
3202                 if(tvb_length_remaining(tvb,offset) > 0)
3203                         offset = dissect_rsl_ie_sup_codec_types(tvb, pinfo, tree, offset, FALSE);
3204                 /* TFO transparent container 9.3.59 O 12) TLV >=3       */
3205                 if(tvb_length_remaining(tvb,offset) > 0)
3206                         offset = dissect_rsl_ie_tfo_transp_cont(tvb, pinfo, tree, offset, FALSE);
3207                 break;
3208
3209         /* 8.4.2 CHANNEL ACTIVATION ACKNOWLEDGE 34*/
3210         case RSL_MSG_CHAN_ACTIV_ACK:
3211                 /* Channel number                       9.3.1   M TV 2                  */
3212                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3213                 /* Frame number                         9.3.8   M TV 3                  */
3214                 offset = dissect_rsl_ie_frame_no(tvb, pinfo, tree, offset, TRUE);
3215                 break;
3216         case RSL_MSG_CHAN_ACTIV_N_ACK:
3217         /* 8.4.3 CHANNEL ACTIVATION NEGATIVE ACKNOWLEDGE */
3218                 /* Channel number                       9.3.1   M TV 2                  */
3219                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3220                 /* Cause                                        9.3.26  M TLV >=3               */
3221                 offset = dissect_rsl_ie_cause(tvb, pinfo, tree, offset, TRUE);
3222                 break;
3223         /* 8.4.4 CONNECTION FAILURE INDICATION */
3224         case RSL_MSG_CONN_FAIL:
3225                 /* Channel number                       9.3.1   M TV 2                  */
3226                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3227                 /* Cause                                        9.3.26  M TLV >=3               */
3228                 offset = dissect_rsl_ie_cause(tvb, pinfo, tree, offset, TRUE);
3229                 break;
3230         /* 8.4.5 DEACTIVATE SACCH */
3231         case RSL_MSG_DEACTIVATE_SACCH:
3232                 /* Channel number                       9.3.1   M TV 2                  */
3233                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3234                 break;
3235         /* 8.4.6 ENCRYPTION COMMAND */
3236         case RSL_MSG_ENCR_CMD:                  /*      38       8.4.6 */
3237                 /* Channel number                       9.3.1   M TV 2                  */
3238                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3239                 /* Encryption information       9.3.7   M TLV >=3               */
3240                 offset = dissect_rsl_ie_enc_inf(tvb, pinfo, tree, offset, TRUE);
3241                 /* Link Identifier                      9.3.2   M TV 2                  */
3242                 offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset, TRUE);
3243                 /* L3 Info (CIPH MOD CMD)       9.3.11  M TLV 6                 */
3244                 offset = dissect_rsl_ie_L3_inf(tvb, pinfo, tree, offset, TRUE);
3245                 break;
3246         /* 8.4.7 HANDOVER DETECTION */
3247         case RSL_MSG_HANDODET:                  /*      39       8.4.7 */
3248                 /* Channel number                       9.3.1   M TV 2                  */
3249                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3250                 /* Access Delay                         9.3.17 O 1) TV 2                */
3251                 if(tvb_length_remaining(tvb,offset) > 0)
3252                         offset = dissect_rsl_ie_access_delay(tvb, pinfo, tree, offset, FALSE);
3253                 break;
3254         /* 8.4.8 MEASUREMENT RESULT 40 */
3255         case RSL_MSG_MEAS_RES:
3256                 /* Channel number                       9.3.1   M TV 2                  */
3257                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3258                 /* Measurement result number 9.3.27 M TV 2                      */
3259                 offset = dissect_rsl_ie_meas_res_no(tvb, pinfo, tree, offset, TRUE);
3260                 /* Uplink Measurements          9.3.25  M TLV >=5               */
3261                 offset = dissect_rsl_ie_uplik_meas(tvb, pinfo, tree, offset, TRUE);
3262                 /* BS Power                                     9.3.4   M TV 2                  */
3263                 offset = dissect_rsl_ie_bs_power(tvb, pinfo, tree, offset, TRUE);
3264                 /* L1 Information                       9.3.10 O 1) TV 3                */
3265                 if(tvb_length_remaining(tvb,offset) > 0)
3266                         offset = dissect_rsl_ie_l1_inf(tvb, pinfo, tree, offset, FALSE);
3267                 /* L3 Info (MEAS REP, EXT MEAS REP or ENH MEAS REP) 9.3.11 O 1) TLV 21 */
3268                 if(tvb_length_remaining(tvb,offset) > 0)
3269                         offset = dissect_rsl_ie_L3_inf(tvb, pinfo, tree, offset, FALSE);
3270                 /* MS Timing Offset                     9.3.37 O 2) TV 2                */
3271                 if(tvb_length_remaining(tvb,offset) > 0)
3272                         offset = dissect_rsl_ie_ms_timing_offset(tvb, pinfo, tree, offset, FALSE);
3273                 break;
3274         /* 8.4.9 MODE MODIFY */
3275         case RSL_MSG_MODE_MODIFY_REQ:   /*      41      8.4.9 */
3276                 /* Channel number                       9.3.1 M TV 2 */
3277                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3278                 /* Channel Mode                         9.3.6 M TLV 8-9 */
3279                 offset = dissect_rsl_ie_ch_mode(tvb, pinfo, tree, offset, TRUE);
3280                 /* Encryption information       9.3.7 O 1) TLV >=3 */
3281                 if(tvb_length_remaining(tvb,offset) > 0)
3282                         offset = dissect_rsl_ie_enc_inf(tvb, pinfo, tree, offset, FALSE);
3283                 /* Main channel reference       9.3.45 O 2) TV 2 */
3284                 if(tvb_length_remaining(tvb,offset) > 0)
3285                         offset = dissect_rsl_ie_main_ch_ref(tvb, pinfo, tree, offset, FALSE);
3286                 /* MultiRate configuration      9.3.52 O 3) TLV >=3 */
3287                 if(tvb_length_remaining(tvb,offset) > 0)
3288                         offset = dissect_rsl_ie_multirate_conf(tvb, pinfo, tree, offset, FALSE);
3289                 /* Multirate Control            9.3.53 O 4) TV 2 */
3290                 if(tvb_length_remaining(tvb,offset) > 0)
3291                         offset = dissect_rsl_ie_multirate_cntrl(tvb, pinfo, tree, offset, FALSE);
3292                 /* Supported Codec Types        9.3.54 O 4) TLV >=5 */
3293                 if(tvb_length_remaining(tvb,offset) > 0)
3294                         offset = dissect_rsl_ie_sup_codec_types(tvb, pinfo, tree, offset, FALSE);
3295                 /* TFO transparent container 9.3.59 O 4) TLV */
3296                 if(tvb_length_remaining(tvb,offset) > 0)
3297                         offset = dissect_rsl_ie_tfo_transp_cont(tvb, pinfo, tree, offset, FALSE);
3298                 break;
3299         /* 8.4.10 MODE MODIFY ACKNOWLEDGE */
3300         case RSL_MSG_MODE_MODIFY_ACK:   /*      42      8.4.10 */
3301                 /* Channel number                       9.3.1   M TV 2                  */
3302                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3303                 break;
3304         /* 8.4.11 MODE MODIFY NEGATIVE ACKNOWLEDGE */
3305         case RSL_MSG_MODE_MODIFY_NACK:  /*      43      8.4.11 */
3306                 /* Channel number                       9.3.1   M TV 2                  */
3307                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3308                 /* Cause                                        9.3.26  M TLV >=3               */
3309                 offset = dissect_rsl_ie_cause(tvb, pinfo, tree, offset, TRUE);
3310                 break;
3311         /* 8.4.12 PHYSICAL CONTEXT REQUEST */
3312         case RSL_MSG_PHY_CONTEXT_REQ:   /*      44      8.4.12 */
3313                 /* Channel number                       9.3.1   M TV 2                  */
3314                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3315                 break;
3316         /* 8.4.13 PHYSICAL CONTEXT CONFIRM */
3317         case RSL_MSG_PHY_CONTEXT_CONF:  /*      45      8.4.13 */
3318                 /* Channel number                       9.3.1   M TV 2 */
3319                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3320                 /* BS Power                                     9.3.4   M TV 2 */
3321                 offset = dissect_rsl_ie_bs_power(tvb, pinfo, tree, offset, TRUE);
3322                 /* MS Power                                     9.3.13  M TV 2 */
3323                 offset = dissect_rsl_ie_ms_pow(tvb, pinfo, tree, offset, TRUE);
3324                 /* Timing Advance                       9.3.24  M TV 2 */
3325                 offset = dissect_rsl_ie_timing_adv(tvb, pinfo, tree, offset, TRUE);
3326                 /* Physical Context                     9.3.16  O 1) TLV */
3327                 if(tvb_length_remaining(tvb,offset) > 0)
3328                         offset = dissect_rsl_ie_phy_ctx(tvb, pinfo, tree, offset, FALSE);
3329                 break;
3330         /* 8.4.14 RF CHANNEL RELEASE */
3331         case RSL_MSG_RF_CHAN_REL:               /*      46      8.4.14 */
3332                 /* Channel number                       9.3.1   M TV 2                  */
3333                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3334                 break;
3335         /* 8.4.15 MS POWER CONTROL */
3336         case RSL_MSG_MS_POWER_CONTROL:  /*      47      8.4.15 */
3337                 /* Channel number                       9.3.1   M TV 2 */
3338                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3339                 /* MS Power                                     9.3.13  M TV 2 */
3340                 if(tvb_length_remaining(tvb,offset) > 0)
3341                         offset = dissect_rsl_ie_ms_pow(tvb, pinfo, tree, offset, FALSE);
3342                 /* MS Power Parameters          9.3.31  O 1) TLV >=2 */
3343                 break;
3344         /* 8.4.16 BS POWER CONTROL */
3345         case RSL_MSG_BS_POWER_CONTROL:  /*      48      8.4.16 */
3346                 /* Channel number                       9.3.1 M TV 2 */
3347                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3348                 /* BS Power                                     9.3.4 M TV 2 */
3349                 offset = dissect_rsl_ie_bs_power(tvb, pinfo, tree, offset, TRUE);
3350                 /* BS Power Parameters          9.3.32 O 1) TLV >=2 */
3351                 break;
3352         /* 8.4.17 PREPROCESS CONFIGURE */
3353         case RSL_MSG_PREPROC_CONFIG:            /*      49      8.4.17 */
3354                 /* Channel number                       9.3.1   M TV 2 */
3355                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3356                 /* Preproc. Parameters          9.3.33  M TLV >=3 */
3357                 break;
3358         /* 8.4.18 PREPROCESSED MEASUREMENT RESULT */
3359         case RSL_MSG_PREPROC_MEAS_RES:  /*      50      8.4.18 */
3360                 /* Channel number                       9.3.1   M TV 2 */
3361                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3362                 /* Preproc. Measurements        9.3.34  M TLV >=2 */
3363                 break;
3364         /* 8.4.19 RF CHANNEL RELEASE ACKNOWLEDGE */
3365         case RSL_MSG_RF_CHAN_REL_ACK:           /*      51      8.4.19 */
3366                 /* Channel number                       9.3.1   M TV 2                  */
3367                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3368                 break;
3369         /* 8.4.20 SACCH INFO MODIFY */
3370         case RSL_MSG_SACCH_INFO_MODIFY: /*      52      8.4.20 */
3371                 /* Channel number                       9.3.1   M TV 2 */
3372                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3373                 /* System Info Type                     9.3.30  M TV 2 */
3374                 offset = dissect_rsl_ie_sys_info_type(tvb, pinfo, tree, offset, TRUE);
3375                 /* L3 Info                                      9.3.11  O 1) TLV 22 */
3376                 if(tvb_length_remaining(tvb,offset) > 0)
3377                         offset = dissect_rsl_ie_L3_inf(tvb, pinfo, tree, offset, FALSE);
3378                 /* Starting Time                        9.3.23  O 2) TV 3 */
3379                 if(tvb_length_remaining(tvb,offset) > 0)
3380                         offset = dissect_rsl_ie_staring_time(tvb, pinfo, tree, offset, FALSE);
3381                 break;
3382         /* 8.4.21 TALKER DETECTION */
3383         case RSL_MSG_TALKER_DET:                        /*      53      8.4.21 */
3384                 /* Channel number                       9.3.1   M TV 2 */
3385                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3386                 /* Access Delay                         9.3.17  O 1) TV 2 */
3387                 if(tvb_length_remaining(tvb,offset) > 0)
3388                                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3389                 break;
3390         /* 8.4.22 LISTENER DETECTION */
3391         case RSL_MSG_LISTENER_DET:              /*      54      8.4.22 */
3392                 /* Channel number                       9.3.1   M TV 2 */
3393                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3394                 /* Access Delay                         9.3.17  O 1) TV 2 */
3395                 if(tvb_length_remaining(tvb,offset) > 0)
3396                                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3397                 break;
3398         /* 8.4.23 REMOTE CODEC CONFIGURATION REPORT */
3399         case RSL_MSG_REMOTE_CODEC_CONF_REP:/*   55      8.4.23 */
3400                 /* Channel number                       9.3.1   M TV 2 */
3401                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3402                 /* Codec Configuration          9.3.55  M TLV >=3 */
3403                 offset = dissect_rsl_ie_codec_conf(tvb, pinfo, tree, offset, TRUE);
3404                 /* Supported Codec Types        9.3.54  M TLV >=5 */
3405                 if(tvb_length_remaining(tvb,offset) > 0)
3406                         offset = dissect_rsl_ie_sup_codec_types(tvb, pinfo, tree, offset, FALSE);
3407                 /* TFO transparent container 9.3.59 O 4) TLV >=3 */
3408                 if(tvb_length_remaining(tvb,offset) > 0)
3409                         offset = dissect_rsl_ie_tfo_transp_cont(tvb, pinfo, tree, offset, FALSE);
3410                 break;
3411         /* 8.4.24 ROUND TRIP DELAY REPORT */
3412         case RSL_MSG_R_T_D_REP:                 /*      56      8.4.24 */
3413                 /* Channel number                       9.3.1   M TV 2 */
3414                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3415                 /* Round Trip Delay                     9.3.56  M TV 2 */
3416                 offset = dissect_rsl_ie_rtd(tvb, pinfo, tree, offset, TRUE);
3417                 break;
3418         /* 8.4.25 PRE-HANDOVER NOTIFICATION */
3419         case RSL_MSG_PRE_HANDO_NOTIF:           /*      57      8.4.25 */
3420                 /* Channel number                       9.3.1   M TV 2 */
3421                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3422                 /* MultiRateControl                     9.3.53  M TV 2 */
3423                 offset = dissect_rsl_ie_multirate_cntrl(tvb, pinfo, tree, offset, TRUE);
3424                 /* Codec Configuration          9.3.55  M TLV >=3 */
3425                 offset = dissect_rsl_ie_codec_conf(tvb, pinfo, tree, offset, TRUE);
3426                 /* TFO transparent container 9.3.59 O 4) TLV >=3 */
3427                 if(tvb_length_remaining(tvb,offset) > 0)
3428                         offset = dissect_rsl_ie_tfo_transp_cont(tvb, pinfo, tree, offset, FALSE);
3429                 break;
3430         /* 8.4.26 MULTIRATE CODEC MODIFICATION REQUEST */
3431         case RSL_MSG_MR_CODEC_MOD_REQ:  /*      58      8.4.26 */
3432                 /* Channel number                       9.3.1   M TV 2 */
3433                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3434                 /* MultiRate Configuration      9.3.52  O 1) TLV >=4 */
3435                 if(tvb_length_remaining(tvb,offset) > 0)
3436                         offset = dissect_rsl_ie_multirate_conf(tvb, pinfo, tree, offset, FALSE);
3437                 break;
3438         /*  8.4.27 MULTIRATE CODEC MODIFICATION ACKNOWLEDGE */
3439         case RSL_MSG_MR_CODEC_MOD_ACK:  /*      59      8.4.27 */
3440                 /* Channel number                       9.3.1   M TV 2 */
3441                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3442                 /* MultiRate Configuration      9.3.52  O 1) TLV >=4 */
3443                 if(tvb_length_remaining(tvb,offset) > 0)
3444                         offset = dissect_rsl_ie_multirate_conf(tvb, pinfo, tree, offset, FALSE);
3445                 break;
3446         /* 8.4.28 MULTIRATE CODEC MODIFICATION NEGATIVE ACKNOWLEDGE */
3447         case RSL_MSG_MR_CODEC_MOD_NACK: /*      60      8.4.28 */
3448                 /* Channel number                       9.3.1   M TV 2                  */
3449                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3450                 /* Cause                                        9.3.26  M TLV >=3               */
3451                 offset = dissect_rsl_ie_cause(tvb, pinfo, tree, offset, TRUE);
3452                 break;
3453         /* 8.4.29 MULTIRATE CODEC MODIFICATION PERFORMED */
3454         case RSL_MSG_MR_CODEC_MOD_PER:  /*      61      8.4.29 */
3455                 /* Channel number                       9.3.1   M TV 2 */
3456                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3457                 /* MultiRate Configuration      9.3.52  M TLV >=4 */
3458                 offset = dissect_rsl_ie_multirate_conf(tvb, pinfo, tree, offset, TRUE);
3459                 break;
3460         /* 8.4.30 TFO REPORT */
3461         case RSL_MSG_TFO_REP:                           /*      62      8.4.30 */
3462                 /* Channel number                       9.3.1   M TV 2 */
3463                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3464                 /* TFO Status                           9.3.57  M TV 1 */
3465                 offset = dissect_rsl_ie_tfo_status(tvb, pinfo, tree, offset, TRUE);
3466                 break;
3467         /* 8.4.31 TFO MODIFICATION REQUEST */
3468         case RSL_MSG_TFO_MOD_REQ:                       /*      63      8.4.31 */
3469                 /* Channel number                       9.3.1 M TV 2 */
3470                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3471                 /* MultiRateControl                     9.3.53 M TV 2 */
3472                 offset = dissect_rsl_ie_multirate_cntrl(tvb, pinfo, tree, offset, TRUE);
3473                 /* Supported Codec Type         9.3.54 O 1) TLV >=5 */
3474                 if(tvb_length_remaining(tvb,offset) > 0)
3475                         offset = dissect_rsl_ie_sup_codec_types(tvb, pinfo, tree, offset, FALSE);
3476                 /* TFO transparent container 9.3.59 O 4) TLV >=3 */
3477                 if(tvb_length_remaining(tvb,offset) > 0)
3478                         offset = dissect_rsl_ie_tfo_transp_cont(tvb, pinfo, tree, offset, FALSE);
3479                 break;
3480         /*      0 1 - - - - - - Location Services messages: */
3481         /* 8.7.1 LOCATION INFORMATION */
3482         case RSL_MSG_LOC_INF:                           /*      65      8.7.1 */
3483                 /* LLP APDU 9.3.58 M LV 2-N */
3484                 offset = dissect_rsl_ie_llp_apdu(tvb, pinfo, tree, offset, TRUE);
3485                 break;
3486         default:
3487                 break;
3488         }
3489
3490         return offset;
3491
3492 }
3493 static void
3494 dissect_rsl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3495 {
3496         proto_item *ti;
3497         proto_tree *rsl_tree;
3498         guint8  msg_type;
3499
3500
3501         int offset = 0;
3502
3503         col_set_str(pinfo->cinfo, COL_PROTOCOL, "RSL");
3504         col_clear(pinfo->cinfo, COL_INFO);
3505
3506         msg_type = tvb_get_guint8(tvb,offset+1)&0x7f;
3507
3508         if (check_col(pinfo->cinfo, COL_INFO)){
3509                 col_append_fstr(pinfo->cinfo, COL_INFO, "%s ",val_to_str(msg_type, rsl_msg_type_vals,"unknown %u"));
3510         }
3511
3512         top_tree = tree;
3513         if (tree) {
3514                 ti = proto_tree_add_item(tree, proto_rsl, tvb, 0, -1, FALSE);
3515                 rsl_tree = proto_item_add_subtree(ti, ett_rsl);
3516
3517                 /* 9.1 Message discriminator */
3518                 proto_tree_add_item(rsl_tree, hf_rsl_msg_dsc, tvb, offset, 1, FALSE);
3519                 proto_tree_add_item(rsl_tree, hf_rsl_T_bit, tvb, offset, 1, FALSE);
3520                 offset++;
3521
3522                 offset = dissct_rsl_msg(tvb, pinfo, rsl_tree, offset);
3523
3524         }
3525
3526 }
3527
3528 void
3529 proto_reg_handoff_rsl(void)
3530 {
3531         dissector_handle_t rsl_handle;
3532
3533         rsl_handle = create_dissector_handle(dissect_rsl, proto_rsl);
3534         dissector_add_uint("lapd.gsm.sapi", LAPD_GSM_SAPI_RA_SIG_PROC, rsl_handle);
3535
3536         gsm_a_ccch_handle = find_dissector("gsm_a_ccch");
3537         gsm_a_dtap_handle = find_dissector("gsm_a_dtap");
3538 }
3539
3540 /* Register the protocol with Wireshark */
3541 void proto_register_rsl(void)
3542 {
3543
3544         /* Setup list of header fields */
3545         static hf_register_info hf[] = {
3546                 { &hf_rsl_msg_dsc,
3547                         { "Message discriminator",           "rsl.msg_dsc",
3548                         FT_UINT8, BASE_DEC, VALS(rsl_msg_disc_vals), 0xfe,
3549                         NULL, HFILL }
3550                 },
3551                 { &hf_rsl_T_bit,
3552                         { "T bit",           "rsl.T_bit",
3553                         FT_BOOLEAN, 8, TFS(&rsl_t_bit_vals), 0x01,
3554                         NULL, HFILL }
3555                 },
3556                 { &hf_rsl_msg_type,
3557                         { "Message type",           "rsl.msg_type",
3558                         FT_UINT8, BASE_HEX_DEC, VALS(rsl_msg_type_vals), 0x7f,
3559                         NULL, HFILL }
3560                 },
3561                 { &hf_rsl_ie_id,
3562                         { "Element identifier",           "rsl.ie_id",
3563                         FT_UINT8, BASE_HEX_DEC, VALS(rsl_ie_type_vals), 0x0,
3564                         NULL, HFILL }
3565                 },
3566                 { &hf_rsl_ie_length,
3567                         { "Length",           "rsl.ie_length",
3568                         FT_UINT16, BASE_DEC, NULL, 0x0,
3569                         NULL, HFILL }
3570                 },
3571                 { &hf_rsl_ch_no_Cbits,
3572                         { "C-bits",           "rsl.ch_no_Cbits",
3573                         FT_UINT8, BASE_DEC, VALS(rsl_ch_no_Cbits_vals), 0xf8,
3574                         NULL, HFILL }
3575                 },
3576                 { &hf_rsl_ch_no_TN,
3577                         { "Time slot number (TN)",  "rsl.ch_no_TN",
3578                         FT_UINT8, BASE_DEC, NULL, 0x07,
3579                         NULL, HFILL }
3580                 },
3581                 { &hf_rsl_rtd,
3582                         { "Round Trip Delay (RTD)",  "rsl.rtd",
3583                         FT_UINT8, BASE_DEC, NULL, 0xfe,
3584                         NULL, HFILL }
3585                 },
3586                 { &hf_rsl_delay_ind,
3587                         { "Delay IND",  "rsl.delay_ind",
3588                         FT_UINT8, BASE_DEC, rsl_delay_ind_vals, 0x01,
3589                         NULL, HFILL }
3590                 },
3591                 { &hf_rsl_tfo,
3592                         { "TFO",           "rsl.tfo",
3593                         FT_BOOLEAN, 8, TFS(&rsl_tfo_vals), 0x01,
3594                         NULL, HFILL }
3595                 },
3596                 { &hf_rsl_req_ref_ra,
3597                         { "Random Access Information (RA)", "rsl.req_ref_ra",
3598                         FT_UINT8, BASE_DEC, NULL, 0x0,
3599                         NULL, HFILL }
3600                 },
3601                 { &hf_rsl_req_ref_T1prim,
3602                         { "T1'",           "rsl.req_ref_T1prim",
3603                         FT_UINT8, BASE_DEC, NULL, 0xf8,
3604                         NULL, HFILL }
3605                 },
3606                 { &hf_rsl_req_ref_T3,
3607                         { "T3",           "rsl.req_ref_T3",
3608                         FT_UINT16, BASE_DEC, NULL, 0x07e0,
3609                         NULL, HFILL }
3610                 },
3611                 { &hf_rsl_req_ref_T2,
3612                         { "T2",           "rsl.req_ref_T2",
3613                         FT_UINT8, BASE_DEC, NULL, 0x1f,
3614                         NULL, HFILL }
3615                 },
3616                 { &hf_rsl_timing_adv,
3617                         { "Timing Advance",           "rsl.timing_adv",
3618                         FT_UINT8, BASE_DEC, NULL, 0x0,
3619                         NULL, HFILL }
3620                 },
3621                 { &hf_rsl_ho_ref,
3622                         { "Hand-over reference",           "rsl.ho_ref",
3623                         FT_UINT8, BASE_DEC, NULL, 0x0,
3624                         NULL, HFILL }
3625                 },
3626                 { &hf_rsl_l1inf_power_lev,
3627                         { "MS power level",           "rsl.ms_power_lev",
3628                         FT_UINT8, BASE_DEC, NULL, 0xf8,
3629                         NULL, HFILL }
3630                 },
3631                 { &hf_rsl_l1inf_fpc,
3632                         { "FPC/EPC",           "rsl.ms_fpc",
3633                         FT_BOOLEAN, 8, TFS(&rsl_ms_fpc_epc_mode_vals), 0x04,
3634                         NULL, HFILL }
3635                 },
3636                 { &hf_rsl_ms_power_lev,
3637                         { "MS power level",           "rsl.ms_power_lev",
3638                         FT_UINT8, BASE_DEC, NULL, 0x1f,
3639                         NULL, HFILL }
3640                 },
3641                 { &hf_rsl_ms_fpc,
3642                         { "FPC/EPC",           "rsl.ms_fpc",
3643                         FT_BOOLEAN, 8, TFS(&rsl_ms_fpc_epc_mode_vals), 0x20,
3644                         NULL, HFILL }
3645                 },
3646                 { &hf_rsl_act_timing_adv,
3647                         { "Actual Timing Advance",           "rsl.act_timing_adv",
3648                         FT_UINT8, BASE_DEC, NULL, 0x0,
3649                         NULL, HFILL }
3650                 },
3651                 { &hf_rsl_dtxd,
3652                         { "DTXd",           "rsl.dtxd",
3653                         FT_BOOLEAN, 8, TFS(&rsl_dtxd_vals), 0x40,
3654                         NULL, HFILL }
3655                 },
3656                 { &hf_rsl_rxlev_full_up,
3657                         { "RXLEV.FULL.up",           "rsl.rxlev_full_up",
3658                         FT_UINT8, BASE_DEC, NULL, 0x3f,
3659                         NULL, HFILL }
3660                 },
3661                 { &hf_rsl_rxlev_sub_up,
3662                         { "RXLEV.SUB.up",           "rsl.rxlev_sub_up",
3663                         FT_UINT8, BASE_DEC, NULL, 0x3f,
3664                         NULL, HFILL }
3665                 },
3666                 { &hf_rsl_rxqual_full_up,
3667                         { "RXQUAL.FULL.up",           "rsl.rxqual_full_up",
3668                         FT_UINT8, BASE_DEC, NULL, 0x38,
3669                         NULL, HFILL }
3670                 },
3671                 { &hf_rsl_rxqual_sub_up,
3672                         { "RXQUAL.SUB.up",           "rsl.rxqual_sub_up",
3673                         FT_UINT8, BASE_DEC, NULL, 0x07,
3674                         NULL, HFILL }
3675                 },
3676                 { &hf_rsl_acc_delay,
3677                         { "Access Delay",           "rsl.acc_del",
3678                         FT_UINT8, BASE_DEC, NULL, 0x0,
3679                         NULL, HFILL }
3680                 },
3681                 { &hf_rsl_rach_slot_cnt,
3682                         { "RACH Slot Count",           "rsl.rach_slot_cnt",
3683                         FT_UINT16, BASE_DEC, NULL, 0x0,
3684                         NULL, HFILL }
3685                 },
3686                 { &hf_rsl_rach_busy_cnt,
3687                         { "RACH Busy Count",           "rsl.rach_busy_cnt",
3688                         FT_UINT16, BASE_DEC, NULL, 0x0,
3689                         NULL, HFILL }
3690                 },
3691                 { &hf_rsl_rach_acc_cnt,
3692                         { "RACH Access Count",           "rsl.rach_acc_cnt",
3693                         FT_UINT16, BASE_DEC, NULL, 0x0,
3694                         NULL, HFILL }
3695                 },
3696                 { &hf_rsl_phy_ctx,
3697                         { "Physical Context",           "rsl.phy_ctx",
3698                         FT_BYTES, BASE_NONE, NULL, 0x0,
3699                         NULL, HFILL }
3700                 },
3701                 { &hf_rsl_na,
3702                         { "Not applicable (NA)",           "rsl.na",
3703                         FT_BOOLEAN, 8, TFS(&rsl_na_vals), 0x20,
3704                         NULL, HFILL }
3705                 },
3706                 { &hf_rsl_ch_type,
3707                         { "channel type",           "rsl.ch_type",
3708                         FT_UINT8, BASE_DEC, VALS(rsl_ch_type_vals), 0xc0,
3709                         NULL, HFILL }
3710                 },
3711                 { &hf_rsl_prio,
3712                         { "Priority",           "rsl.prio",
3713                         FT_UINT8, BASE_DEC, VALS(rsl_prio_vals), 0x18,
3714                         NULL, HFILL }
3715                 },
3716                 { &hf_rsl_sapi,
3717                         { "SAPI",           "rsl.sapi",
3718                         FT_UINT8, BASE_DEC, NULL, 0x07,
3719                         NULL, HFILL }
3720                 },
3721                 { &hf_rsl_rbit,
3722                         { "R",           "rsl.rbit",
3723                         FT_BOOLEAN, 8, TFS(&rsl_rbit_vals), 0x80,
3724                         NULL, HFILL }
3725                 },
3726                 { &hf_rsl_a3a2,
3727                         { "A3A2",           "rsl.a3a2",
3728                         FT_UINT8, BASE_DEC, VALS(rsl_a3a2_vals), 0x06,
3729                         NULL, HFILL }
3730                 },
3731                 { &hf_rsl_a1_0,
3732                         { "A1",           "rsl.a1_0",
3733                         FT_BOOLEAN, 8, TFS(&rsl_a1_0_vals), 0x01,
3734                         NULL, HFILL }
3735                 },
3736                 { &hf_rsl_a1_1,
3737                         { "A1",           "rsl.a1_1",
3738                         FT_BOOLEAN, 8, TFS(&rsl_a1_1_vals), 0x01,
3739                         NULL, HFILL }
3740                 },
3741                 { &hf_rsl_a1_2,
3742                         { "A1",           "rsl.a2_0",
3743                         FT_BOOLEAN, 8, TFS(&rsl_a1_2_vals), 0x01,
3744                         NULL, HFILL }
3745                 },
3746                 { &hf_rsl_epc_mode,
3747                         { "EPC mode", "rsl.epc_mode",
3748                         FT_BOOLEAN, 8, TFS(&rsl_epc_mode_vals), 0x20,
3749                         NULL, HFILL }
3750                 },
3751                 { &hf_rsl_bs_fpc_epc_mode,
3752                         { "FPC-EPC mode", "rsl.fpc_epc_mode",
3753                         FT_BOOLEAN, 8, TFS(&rsl_fpc_epc_mode_vals), 0x10,
3754                         NULL, HFILL }
3755                 },
3756                 { &hf_rsl_bs_power,
3757                         { "Power Level",           "rsl.bs_power",
3758                         FT_UINT8, BASE_DEC, VALS(rsl_rlm_bs_power_vals), 0x0f,
3759                         NULL, HFILL }
3760                 },
3761                 { &hf_rsl_cm_dtxd,
3762                         { "DTXd", "rsl.cm_dtxd",
3763                         FT_BOOLEAN, 8, TFS(&rsl_dtx_vals), 0x02,
3764                         NULL, HFILL }
3765                 },
3766                 { &hf_rsl_cm_dtxu,
3767                         { "DTXu", "rsl.cm_dtxu",
3768                         FT_BOOLEAN, 8, TFS(&rsl_dtx_vals), 0x01,
3769                         NULL, HFILL }
3770                 },
3771                 { &hf_rsl_speech_or_data,
3772                         { "Speech or data indicator",           "rsl.speech_or_data",
3773                         FT_UINT8, BASE_DEC, VALS(rsl_speech_or_data_vals), 0x0,
3774                         NULL, HFILL }
3775                 },
3776                 { &hf_rsl_ch_rate_and_type,
3777                         { "Channel rate and type",           "rsl.speech_or_data",
3778                         FT_UINT8, BASE_DEC, VALS(rsl_ch_rate_and_type_vals), 0x0,
3779                         NULL, HFILL }
3780                 },
3781                 { &hf_rsl_speech_coding_alg,
3782                         { "Speech coding algorithm",           "rsl.speech_coding_alg",
3783                         FT_UINT8, BASE_DEC, VALS(rsl_speech_coding_alg_vals), 0x0,
3784                         NULL, HFILL }
3785                 },
3786                 { &hf_rsl_t_nt_bit,
3787                         { "Transparent indication", "rsl.t_nt_bit",
3788                         FT_BOOLEAN, 8, TFS(&t_nt_bit_vals), 0x40,
3789                         NULL, HFILL }
3790                 },
3791                 { &hf_rsl_ra_if_data_rte,
3792                         { "Radio interface data rate",           "rsl.ra_if_data_rte",
3793                         FT_UINT8, BASE_DEC, VALS(rsl_ra_if_data_rte_vals), 0x3f,
3794                         NULL, HFILL }
3795                 },
3796                 { &hf_rsl_data_rte,
3797                         { "Data rate",           "rsl.data_rte",
3798                         FT_UINT8, BASE_DEC, VALS(rsl_ra_if_data_rte_vals), 0x3f,
3799                         NULL, HFILL }
3800                 },
3801                 { &hf_rsl_alg_id,
3802                         { "Algorithm Identifier",           "rsl.alg_id",
3803                         FT_UINT8, BASE_DEC, VALS(rsl_algorithm_id_vals), 0x0,
3804                         NULL, HFILL }
3805                 },
3806                 { &hf_rsl_key,
3807                         { "KEY",           "rsl.key",
3808                         FT_BYTES, BASE_NONE, NULL, 0x0,
3809                         NULL, HFILL }
3810                 },
3811                 { &hf_rsl_cause,
3812                         { "Cause",           "rsl.cause",
3813                         FT_UINT8, BASE_DEC, VALS(rsl_rlm_cause_vals), 0x7f,
3814                         NULL, HFILL }
3815                 },
3816                 { &hf_rsl_rel_mode,
3817                         { "Release Mode",           "rsl.rel_mode",
3818                         FT_UINT8, BASE_DEC, VALS(rel_mode_vals), 0x01,
3819                         NULL, HFILL }
3820                 },
3821                 { &hf_rsl_interf_band,
3822                         { "Interf Band",           "rsl.interf_band",
3823                         FT_UINT8, BASE_DEC, NULL, 0xe0,
3824                         NULL, HFILL }
3825                 },
3826                 { &hf_rsl_interf_band_reserved,
3827                         { "Interf Band reserved bits",           "rsl.interf_band_reserved",
3828                         FT_UINT8, BASE_DEC, NULL, 0x1f,
3829                         NULL, HFILL }
3830                 },
3831                 { &hf_rsl_meas_res_no,
3832                         { "Measurement result number",           "rsl.meas_res_no",
3833                         FT_UINT8, BASE_DEC, NULL, 0x0,
3834                         NULL, HFILL }
3835                 },
3836                 { &hf_rsl_extension_bit,
3837                         { "Extension", "rsl.extension_bit",
3838                         FT_BOOLEAN, 8, TFS(&rsl_extension_bit_value), 0x80,
3839                         NULL, HFILL }},
3840                 { &hf_rsl_class,
3841                         { "Class",           "rsl.class",
3842                         FT_UINT8, BASE_DEC, VALS(rsl_class_vals), 0x70,
3843                         NULL, HFILL }
3844                 },
3845                 { &hf_rsl_paging_grp,
3846                         { "Paging Group",           "rsl.paging_grp",
3847                         FT_UINT8, BASE_DEC, NULL, 0x0,
3848                         NULL, HFILL }
3849                 },
3850                 { &hf_rsl_paging_load,
3851                         { "Paging Buffer Space",           "rsl.paging_load",
3852                         FT_UINT16, BASE_DEC, NULL, 0x0,
3853                         NULL, HFILL }
3854                 },
3855                 { &hf_rsl_sys_info_type,
3856                         { "System Info Type",           "rsl.sys_info_type",
3857                         FT_UINT8, BASE_DEC, VALS(rsl_sys_info_type_vals), 0x0,
3858                         NULL, HFILL }
3859                 },
3860                 { &hf_rsl_timing_offset,
3861                         { "Timing Offset",           "rsl.timing_offset",
3862                         FT_UINT8, BASE_DEC, NULL, 0x0,
3863                         NULL, HFILL }
3864                 },
3865                 { &hf_rsl_ch_needed,
3866                         { "Channel Needed",           "rsl.ch_needed",
3867                         FT_UINT8, BASE_DEC, VALS(rsl_ch_needed_vals), 0x03,
3868                         NULL, HFILL }
3869                 },
3870                 { &hf_rsl_cbch_load_type,
3871                         { "CBCH Load Type", "rsl.cbch_load_type",
3872                         FT_BOOLEAN, 8, TFS(&rsl_cbch_load_type_vals), 0x80,
3873                         NULL, HFILL }
3874                 },
3875                 { &hf_rsl_msg_slt_cnt,
3876                         { "Message Slot Count", "rsl.sg_slt_cnt",
3877                         FT_UINT8, BASE_DEC, NULL, 0x0f,
3878                         NULL, HFILL }
3879                 },
3880                 { &hf_rsl_ch_ind,
3881                         { "Channel Ind",           "rsl.ch_ind",
3882                         FT_UINT8, BASE_DEC, VALS(rsl_ch_ind_vals), 0x0f,
3883                         NULL, HFILL }
3884                 },
3885                 { &hf_rsl_command,
3886                         { "Command",           "rsl.cmd",
3887                         FT_UINT16, BASE_DEC, NULL, 0x0,
3888                         NULL, HFILL }
3889                 },
3890                 { &hf_rsl_emlpp_prio,
3891                         { "eMLPP Priority",           "rsl.emlpp_prio",
3892                         FT_UINT8, BASE_DEC, VALS(rsl_emlpp_prio_vals), 0x03,
3893                         NULL, HFILL }
3894                 },
3895         };
3896         static gint *ett[] = {
3897                 &ett_rsl,
3898                 &ett_ie_link_id,
3899                 &ett_ie_act_type,
3900                 &ett_ie_bs_power,
3901                 &ett_ie_ch_id,
3902                 &ett_ie_ch_mode,
3903                 &ett_ie_enc_inf,
3904                 &ett_ie_ch_no,
3905                 &ett_ie_frame_no,
3906                 &ett_ie_ho_ref,
3907                 &ett_ie_l1_inf,
3908                 &ett_ie_L3_inf,
3909                 &ett_ie_ms_id,
3910                 &ett_ie_ms_pow,
3911                 &ett_ie_phy_ctx,
3912                 &ett_ie_paging_grp,
3913                 &ett_ie_paging_load,
3914                 &ett_ie_access_delay,
3915                 &ett_ie_rach_load,
3916                 &ett_ie_req_ref,
3917                 &ett_ie_rel_mode,
3918                 &ett_ie_resource_inf,
3919                 &ett_ie_rlm_cause,
3920                 &ett_ie_staring_time,
3921                 &ett_ie_timing_adv,
3922                 &ett_ie_uplink_meas,
3923                 &ett_ie_full_imm_ass_inf,
3924                 &ett_ie_smscb_inf,
3925                 &ett_ie_ms_timing_offset,
3926                 &ett_ie_err_msg,
3927                 &ett_ie_full_bcch_inf,
3928                 &ett_ie_ch_needed,
3929                 &ett_ie_cb_cmd_type,
3930                 &ett_ie_smscb_mess,
3931                 &ett_ie_cbch_load_inf,
3932                 &ett_ie_smscb_ch_ind,
3933                 &ett_ie_grp_call_ref,
3934                 &ett_ie_ch_desc,
3935                 &ett_ie_nch_drx,
3936                 &ett_ie_cmd_ind,
3937                 &ett_ie_emlpp_prio,
3938                 &ett_ie_uic,
3939                 &ett_ie_main_ch_ref,
3940                 &ett_ie_multirate_conf,
3941                 &ett_ie_multirate_cntrl,
3942                 &ett_ie_sup_codec_types,
3943                 &ett_ie_codec_conf,
3944                 &ett_ie_rtd,
3945                 &ett_ie_tfo_status,
3946                 &ett_ie_llp_apdu,
3947                 &ett_ie_tfo_transp_cont,
3948                 &ett_ie_cause,
3949                 &ett_ie_meas_res_no,
3950                 &ett_ie_message_id,
3951                 &ett_ie_sys_info_type,
3952         };
3953
3954         /* Register the protocol name and description */
3955         proto_rsl = proto_register_protocol("Radio Signalling Link (RSL)",
3956                                             "RSL", "rsl");
3957
3958         proto_register_field_array(proto_rsl, hf, array_length(hf));
3959         proto_register_subtree_array(ett, array_length(ett));
3960
3961         register_dissector("gsm_abis_rsl", dissect_rsl, proto_rsl);
3962
3963 }
3964