Don't guard col_set_str (COL_PROTOCOL) with col_check
[metze/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 <stdio.h>
38 #include <stdlib.h>
39 #include <string.h>
40 #include <ctype.h>
41
42 #include <epan/packet.h>
43 #include <epan/proto.h>
44 #include <epan/lapd_sapi.h>
45
46 #include "packet-gsm_a_common.h"
47
48 /* Initialize the protocol and registered fields */
49 static int proto_rsl            = -1;
50
51 static int hf_rsl_msg_type                      = -1;
52 static int hf_rsl_T_bit                         = -1;
53 static int hf_rsl_msg_dsc                       = -1;
54 static int hf_rsl_ie_id                         = -1;
55 static int hf_rsl_ie_length                     = -1;
56 static int hf_rsl_ch_no_Cbits           = -1;
57 static int hf_rsl_ch_no_TN                      = -1;
58 static int hf_rsl_acc_delay                     = -1;
59 static int hf_rsl_rach_slot_cnt         = -1;
60 static int hf_rsl_rach_busy_cnt         = -1;
61 static int hf_rsl_rach_acc_cnt          = -1;
62 static int hf_rsl_req_ref_ra            = -1;
63 static int hf_rsl_req_ref_T1prim        = -1;
64 static int hf_rsl_req_ref_T3            = -1;
65 static int hf_rsl_req_ref_T2            = -1;
66 static int hf_rsl_timing_adv            = -1;
67 static int hf_rsl_ho_ref                        = -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_power_lev                     = -1;
72 static int hf_rsl_phy_ctx                       = -1;
73 static int hf_rsl_na                            = -1;
74 static int hf_rsl_ch_type                       = -1;
75 static int hf_rsl_prio                          = -1;
76 static int hf_rsl_sapi                          = -1;
77 static int hf_rsl_rbit                          = -1;
78 static int hf_rsl_a3a2                          = -1;
79 static int hf_rsl_a1_0                          = -1;
80 static int hf_rsl_a1_1                          = -1;
81 static int hf_rsl_a1_2                          = -1;
82 static int hf_rsl_epc_mode                      = -1;
83 static int hf_rsl_bs_fpc_epc_mode       = -1;
84 static int hf_rsl_bs_power                      = -1;
85 static int hf_rsl_cm_dtxd                       = -1;
86 static int hf_rsl_cm_dtxu                       = -1;
87 static int hf_rsl_speech_or_data        = -1;
88 static int hf_rsl_ch_rate_and_type      = -1;
89 static int hf_rsl_speech_coding_alg = -1;
90 static int hf_rsl_t_nt_bit                      = -1;
91 static int hf_rsl_ra_if_data_rte        = -1;
92 static int hf_rsl_data_rte                      = -1;
93 static int hf_rsl_alg_id                        = -1;
94 static int hf_rsl_key                           = -1;
95 static int hf_rsl_cause                         = -1;
96 static int hf_rsl_rel_mode                      = -1;
97 static int hf_rsl_interf_band           = -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 proto_tree *top_tree;
178 dissector_handle_t gsm_a_ccch_handle;
179 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's" },
496         {  0x03,        "Lm + ACCH's" },
497         {  0x03,        "Lm + ACCH's" },
498         {  0x04,        "SDCCH/4 + ACCH" },
499         {  0x05,        "SDCCH/4 + ACCH" },
500         {  0x06,        "SDCCH/4 + ACCH" },
501         {  0x07,        "SDCCH/4 + ACCH" },
502         {  0x08,        "SDCCH/8 + ACCH" },
503         {  0x09,        "SDCCH/8 + ACCH" },
504         {  0x0a,        "SDCCH/8 + ACCH" },
505         {  0x0b,        "SDCCH/8 + ACCH" },
506         {  0x0c,        "SDCCH/8 + ACCH" },
507         {  0x0d,        "SDCCH/8 + ACCH" },
508         {  0x0e,        "SDCCH/8 + ACCH" },
509         {  0x0f,        "SDCCH/8 + ACCH" },
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_ms_power_lev, tvb, offset, 1, FALSE);
1091         /* FPC */
1092         proto_tree_add_item(ie_tree, hf_rsl_ms_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,        "unsolicated 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                 offset++;
1544                 length = length - 2;
1545         }
1546         return ie_offset + length;
1547 }
1548
1549 /*
1550  * 9.3.22 RLM Cause                             9.3.22  M TLV 2-4
1551  */
1552 static int
1553 dissect_rsl_ie_rlm_cause(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1554 {
1555         proto_item *ti;
1556         proto_tree *ie_tree;
1557
1558         guint           length;
1559         guint8          octet;
1560         guint8 ie_id;
1561
1562         if(is_mandatory == FALSE){
1563                 ie_id = tvb_get_guint8(tvb,offset);
1564                 if (ie_id != RSL_IE_RLM_CAUSE)
1565                         return offset;
1566         }
1567
1568         ti = proto_tree_add_text(tree, tvb,offset,0,"RLM Cause IE ");
1569         ie_tree = proto_item_add_subtree(ti, ett_ie_rlm_cause);
1570
1571         /* Element identifier */
1572         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1573         offset++;
1574         /* Length */
1575         length = tvb_get_guint8(tvb,offset);
1576         proto_item_set_len(ti, length+2);
1577
1578         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
1579         offset++;
1580
1581         /* The Cause Value is a one octet field if the extension bit is set to 0.
1582          * If the extension bit is set to 1, the Cause Value is a two octet field.
1583          */
1584         octet = tvb_get_guint8(tvb,offset);
1585         proto_tree_add_item(tree, hf_rsl_extension_bit, tvb, offset, 1, FALSE);
1586         proto_tree_add_item(ie_tree, hf_rsl_cause, tvb, offset, 1, FALSE);
1587         offset++;
1588
1589         return offset;
1590 }
1591
1592 /*
1593  * 9.3.23 Starting Time
1594  */
1595 static int
1596 dissect_rsl_ie_staring_time(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1597 {
1598         proto_item *ti;
1599         proto_tree *ie_tree;
1600         guint8 ie_id;
1601
1602         if(is_mandatory == FALSE){
1603                 ie_id = tvb_get_guint8(tvb,offset);
1604                 if (ie_id != RSL_IE_STARTING_TIME)
1605                         return offset;
1606         }
1607
1608         ti = proto_tree_add_text(tree, tvb,offset,3,"Starting Time IE");
1609         ie_tree = proto_item_add_subtree(ti, ett_ie_staring_time);
1610
1611         /* Element identifier */
1612         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1613         offset++;
1614
1615         proto_tree_add_item(ie_tree, hf_rsl_req_ref_T1prim, tvb, offset, 1, FALSE);
1616         proto_tree_add_item(ie_tree, hf_rsl_req_ref_T3, tvb, offset, 2, FALSE);
1617         offset++;
1618         proto_tree_add_item(ie_tree, hf_rsl_req_ref_T2, tvb, offset, 1, FALSE);
1619         offset++;
1620
1621         return offset;
1622 }
1623
1624 /* 
1625  * 9.3.24 Timing Advance
1626  */
1627 static int
1628 dissect_rsl_ie_timing_adv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1629 {
1630         proto_item *ti;
1631         proto_tree *ie_tree;
1632         guint8 ie_id;
1633
1634         if(is_mandatory == FALSE){
1635                 ie_id = tvb_get_guint8(tvb,offset);
1636                 if (ie_id != RSL_IE_TIMING_ADV)
1637                         return offset;
1638         }
1639
1640         ti = proto_tree_add_text(tree, tvb,offset,2,"Timing Advance IE");
1641         ie_tree = proto_item_add_subtree(ti, ett_ie_timing_adv);
1642
1643         /* Element identifier */
1644         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1645         offset++;
1646
1647         proto_tree_add_item(ie_tree, hf_rsl_timing_adv, tvb, offset, 1, FALSE);
1648         offset++;
1649
1650         return offset;
1651 }
1652
1653 /*
1654  * 9.3.25 Uplink Measurements
1655  */
1656 static const true_false_string rsl_dtxd_vals = {
1657   "Employed",
1658   "Not employed"
1659 };
1660
1661 static int
1662 dissect_rsl_ie_uplik_meas(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1663 {
1664         proto_item *ti;
1665         proto_tree *ie_tree;
1666         guint           length;
1667         int                     ie_offset;
1668         guint8 ie_id;
1669
1670         if(is_mandatory == FALSE){
1671                 ie_id = tvb_get_guint8(tvb,offset);
1672                 if (ie_id != RSL_IE_UPLINK_MEAS)
1673                         return offset;
1674         }
1675
1676         ti = proto_tree_add_text(tree, tvb,offset,0,"Uplink Measurements IE");
1677         ie_tree = proto_item_add_subtree(ti, ett_ie_uplink_meas);
1678
1679         /* Element identifier */
1680         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1681         offset++;
1682
1683         /* Length */
1684         length = tvb_get_guint8(tvb,offset);
1685         proto_item_set_len(ti, length+2);
1686
1687         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
1688         offset++;
1689         ie_offset = offset;
1690
1691         /* Octet 3
1692          * 8    7        6      5       4       3       2       1
1693          * rfu  DTXd | RXLEV.FULL.up
1694          */
1695         proto_tree_add_item(ie_tree, hf_rsl_dtxd, tvb, offset, 1, FALSE);
1696         proto_tree_add_item(ie_tree, hf_rsl_rxlev_full_up, tvb, offset, 1, FALSE);
1697         offset++;
1698
1699         /* Octet4
1700          * 8    7       6       5       4       3       2       1
1701          * Reserved |  RXLEV.SUB.up 4
1702          */
1703         proto_tree_add_item(ie_tree, hf_rsl_rxlev_sub_up, tvb, offset, 1, FALSE);
1704         offset++;
1705         /* Octet 5 
1706          * 8    7        6      5       4                 3     2       1
1707          * Reserved | RXQUAL.FULL.up | RXQUAL.SUB.up
1708          */
1709         proto_tree_add_item(ie_tree, hf_rsl_rxqual_full_up, tvb, offset, 1, FALSE);
1710         proto_tree_add_item(ie_tree, hf_rsl_rxqual_sub_up, tvb, offset, 1, FALSE);
1711          offset++;
1712         /* Octet 6 - N
1713          * Supplementary Measurement Information
1714          */
1715         return ie_offset+length;
1716 }
1717
1718
1719 static const value_string rsl_class_vals[] = {
1720         {  0x00,        "Normal event" },
1721         {  0x01,        "Normal event" },
1722         {  0x02,        "Resource unavailable" },
1723         {  0x03,        "Service or option not available" },
1724         {  0x04,        "Service or option not implemented" },
1725         {  0x05,        "Invalid message (e.g. parameter out of range)" },
1726         {  0x06,        "Protocol error" },
1727         {  0x07,        "Interworking" },
1728         { 0,                    NULL }
1729 };
1730         
1731  /*
1732   * 9.3.26 Cause
1733   */
1734 static int
1735 dissect_rsl_ie_cause(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1736 {
1737         proto_item *ti;
1738         proto_tree *ie_tree;
1739         guint           length;
1740         guint8          octet;
1741         int                     ie_offset;
1742         guint8 ie_id;
1743
1744         if(is_mandatory == FALSE){
1745                 ie_id = tvb_get_guint8(tvb,offset);
1746                 if (ie_id != RSL_IE_CAUSE)
1747                         return offset;
1748         }
1749
1750         ti = proto_tree_add_text(tree, tvb,offset,0,"Cause IE");
1751         ie_tree = proto_item_add_subtree(ti, ett_ie_cause);
1752
1753         /* Element identifier */
1754         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1755         offset++;
1756         /* Length */
1757         length = tvb_get_guint8(tvb,offset);
1758         proto_item_set_len(ti, length+2);
1759         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
1760         offset++;
1761         ie_offset = offset;
1762         
1763         /* Cause Value */
1764         octet = tvb_get_guint8(tvb,offset);
1765         proto_tree_add_item(tree, hf_rsl_extension_bit, tvb, offset, 1, FALSE);
1766         proto_tree_add_item(tree, hf_rsl_class, tvb, offset, 1, FALSE);
1767         if ((octet & 0x80) == 80)
1768         /* Cause Extension*/
1769                 offset++;
1770         
1771         /* Diagnostic(s) if any */
1772         return ie_offset+length;
1773 }
1774 /*
1775  * 9.3.27 Measurement result number
1776  */
1777
1778 static int
1779 dissect_rsl_ie_meas_res_no(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1780 {
1781         proto_item *ti;
1782         proto_tree *ie_tree;
1783         guint8 ie_id;
1784
1785         if(is_mandatory == FALSE){
1786                 ie_id = tvb_get_guint8(tvb,offset);
1787                 if (ie_id != RSL_IE_MEAS_RES_NO)
1788                         return offset;
1789         }
1790
1791         ti = proto_tree_add_text(tree, tvb,offset,2,"Measurement result number IE");
1792         ie_tree = proto_item_add_subtree(ti, ett_ie_meas_res_no);
1793
1794         /* Element identifier */
1795         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1796         offset++;
1797
1798         /* Measurement result number */
1799         proto_tree_add_item(ie_tree, hf_rsl_meas_res_no, tvb, offset, 1, FALSE);
1800         offset++;
1801
1802         return offset;
1803 }
1804 /*
1805  * 9.3.28 Message Identifier
1806  */
1807 static int
1808 dissect_rsl_ie_message_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1809 {
1810         proto_item *ti;
1811         proto_tree *ie_tree;
1812         guint8 ie_id;
1813
1814         if(is_mandatory == FALSE){
1815                 ie_id = tvb_get_guint8(tvb,offset);
1816                 if (ie_id != RSL_IE_MESSAGE_ID)
1817                         return offset;
1818         }
1819
1820         ti = proto_tree_add_text(tree, tvb,offset,0,"Message Identifier IE");
1821         ie_tree = proto_item_add_subtree(ti, ett_ie_message_id);
1822
1823         /* Element identifier */
1824         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1825         offset++;
1826         /* Message Type */
1827         proto_tree_add_item(tree, hf_rsl_msg_type, tvb, offset, 1, FALSE);
1828         offset++;
1829         return offset;
1830 }
1831 /*
1832  * 9.3.30 System Info Type
1833  */
1834 static const value_string rsl_sys_info_type_vals[] = {
1835         {  0x00,        "SYSTEM INFORMATION 8" },
1836         {  0x01,        "SYSTEM INFORMATION 1" },
1837         {  0x02,        "SYSTEM INFORMATION 2" },
1838         {  0x03,        "SYSTEM INFORMATION 3" },
1839         {  0x04,        "SYSTEM INFORMATION 4" },
1840         {  0x05,        "SYSTEM INFORMATION 5" },
1841         {  0x06,        "SYSTEM INFORMATION 6" },
1842         {  0x07,        "SYSTEM INFORMATION 7" },
1843         {  0x08,        "SYSTEM INFORMATION 16" },
1844         {  0x09,        "SYSTEM INFORMATION 17" },
1845         {  0x0a,        "SYSTEM INFORMATION 2bis" },
1846         {  0x0b,        "SYSTEM INFORMATION 2ter" },
1847         {  0x0d,        "SYSTEM INFORMATION 5bis" },
1848         {  0x0e,        "SYSTEM INFORMATION 5ter" },
1849         {  0x0f,        "SYSTEM INFORMATION 10" },
1850         {  0x47,        "EXTENDED MEASUREMENT ORDER" },
1851         {  0x48,        "MEASUREMENT INFORMATION" },
1852         {  0x28,        "SYSTEM INFORMATION 13" },
1853         {  0x29,        "SYSTEM INFORMATION 2quater" },
1854         {  0x2a,        "SYSTEM INFORMATION 9" },
1855         {  0x2b,        "SYSTEM INFORMATION 18" },
1856         {  0x2c,        "SYSTEM INFORMATION 19" },
1857         {  0x2d,        "SYSTEM INFORMATION 20" },
1858         { 0,                    NULL }
1859 };
1860
1861
1862 static int
1863 dissect_rsl_ie_sys_info_type(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1864 {
1865         proto_item *ti;
1866         proto_tree *ie_tree;
1867         guint8 ie_id, sitype;
1868
1869         if(is_mandatory == FALSE){
1870                 ie_id = tvb_get_guint8(tvb,offset);
1871                 if (ie_id != RSL_IE_SYS_INFO_TYPE)
1872                         return offset;
1873         }
1874
1875         ti = proto_tree_add_text(tree, tvb,offset,2,"System Info Type IE");
1876         ie_tree = proto_item_add_subtree(ti, ett_ie_sys_info_type);
1877
1878         /* Element identifier */
1879         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1880         offset++;
1881         /* Message Type */
1882         proto_tree_add_item(tree, hf_rsl_sys_info_type, tvb, offset, 1, FALSE);
1883         sitype = tvb_get_guint8(tvb, offset);
1884         offset++;
1885
1886         /* Check if SI is 2q, if so set flag */
1887         if (sitype==0x29) {
1888                 is_si2q = TRUE; }
1889
1890         return offset;
1891 }
1892
1893 /*
1894  * 9.3.35 Full Immediate Assign Info TLV 25
1895  */
1896 static int
1897 dissect_rsl_ie_full_imm_ass_inf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, gboolean is_mandatory)
1898 {
1899         proto_item *ti;
1900         proto_tree *ie_tree;
1901
1902         guint           length;
1903         tvbuff_t        *next_tvb;
1904         guint8          ie_id;
1905
1906         if(is_mandatory == FALSE){
1907                 ie_id = tvb_get_guint8(tvb,offset);
1908                 if (ie_id != RSL_IE_FULL_IMM_ASS_INF)
1909                         return offset;
1910         }
1911
1912         ti = proto_tree_add_text(tree, tvb,offset,0,"Full Immediate Assign Info IE ");
1913         ie_tree = proto_item_add_subtree(ti, ett_ie_full_imm_ass_inf);
1914
1915         /* Element identifier */
1916         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1917         offset++;
1918         /* Length */
1919         length = tvb_get_guint8(tvb,offset);
1920         proto_item_set_len(ti, length+2);
1921
1922         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
1923         offset++;
1924         /*      The Full Immediate Assign Info field (octets 3-25)
1925          * contains a complete immediate assign message (IMMEDIATE ASSIGNMENT or
1926          * IMMEDIATE ASSIGNMENT EXTENDED or IMMEDIATE ASSIGNMENT REJECT)
1927          * as defined in 3GPP TS 44.018.
1928          */
1929         proto_tree_add_text(ie_tree, tvb,offset,length,"Full Immediate Assign Info field");
1930         next_tvb = tvb_new_subset(tvb, offset, length, length);
1931         call_dissector(gsm_a_ccch_handle, next_tvb, pinfo, top_tree);
1932
1933         offset = offset + length;
1934
1935         return offset;
1936 }
1937
1938 /*
1939  * 9.3.36 SMSCB Information
1940  *
1941  * This element is used to convey a complete frame to be broadcast on the CBCH
1942  * including the Layer 2 header for the radio path.
1943  */
1944 static int
1945 dissect_rsl_ie_smscb_inf(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1946 {
1947         proto_item *ti;
1948         proto_tree *ie_tree;
1949
1950         guint           length;
1951         guint8          ie_id;
1952
1953         if(is_mandatory == FALSE){
1954                 ie_id = tvb_get_guint8(tvb,offset);
1955                 if (ie_id != RSL_IE_SMSCB_INF)
1956                         return offset;
1957         }
1958
1959         ti = proto_tree_add_text(tree, tvb,offset,0,"SMSCB Information IE ");
1960         ie_tree = proto_item_add_subtree(ti, ett_ie_smscb_inf);
1961
1962         /* Element identifier */
1963         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
1964         offset++;
1965         /* Length */
1966         length = tvb_get_guint8(tvb,offset);
1967         proto_item_set_len(ti, length+2);
1968
1969         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
1970         offset++;
1971         /*      
1972          * SMSCB frame
1973          */
1974         proto_tree_add_text(ie_tree, tvb,offset,length,"SMSCB frame");
1975
1976         offset = offset + length;
1977
1978         return offset;
1979 }
1980
1981 /*
1982  * 9.3.37 MS Timing Offset
1983  */
1984
1985 static int
1986 dissect_rsl_ie_ms_timing_offset(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
1987 {
1988         proto_item *ti;
1989         proto_tree *ie_tree;
1990         guint8          ie_id;
1991
1992         if(is_mandatory == FALSE){
1993                 ie_id = tvb_get_guint8(tvb,offset);
1994                 if (ie_id != RSL_IE_FULL_MS_TIMING_OFFSET)
1995                         return offset;
1996         }
1997
1998         ti = proto_tree_add_text(tree, tvb,offset,0,"MS Timing Offset IE");
1999         ie_tree = proto_item_add_subtree(ti, ett_ie_ms_timing_offset);
2000
2001         /* Element identifier */
2002         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2003         offset++;
2004
2005         /* Timing Offset 
2006          * The meaning of the MS Timing Offset is as defined in 3GPP TS 45.010. 
2007          * The value of MS Timing Offset is the binary value of the 8-bit Timing Offset field (octet 2) - 63.
2008          * The range of MS Timing Offset is therefore -63 to 192.
2009          */
2010         proto_tree_add_item(ie_tree, hf_rsl_timing_offset, tvb, offset, 1, FALSE);
2011         offset++;
2012         
2013         return offset;
2014 }
2015
2016 /*
2017  * 9.3.38 Erroneous Message
2018  * This information element is used to carry a complete A-bis interface message
2019  * which was considered erroneous at reception.
2020  */
2021 static int
2022 dissect_rsl_ie_err_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, gboolean is_mandatory)
2023 {
2024         proto_item *ti;
2025         proto_tree *ie_tree;
2026
2027         guint           length;
2028         guint8          ie_id;
2029         if(is_mandatory == FALSE){
2030                 ie_id = tvb_get_guint8(tvb,offset);
2031                 if (ie_id != RSL_IE_ERR_MSG)
2032                         return offset;
2033         }
2034
2035         ti = proto_tree_add_text(tree, tvb,offset,0,"Erroneous Message IE ");
2036         ie_tree = proto_item_add_subtree(ti, ett_ie_err_msg);
2037
2038         /* Element identifier */
2039         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2040         offset++;
2041         /* Length */
2042         length = tvb_get_guint8(tvb,offset);
2043         proto_item_set_len(ti, length+2);
2044
2045         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
2046         offset++;
2047
2048         /* Received Message */
2049         offset = dissct_rsl_msg(tvb, pinfo, ie_tree, offset);
2050
2051         return offset;
2052 }
2053
2054 /*
2055  * 9.3.39 Full BCCH Information (message name)
2056  */
2057 static int
2058 dissect_rsl_ie_full_bcch_inf(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2059 {
2060         proto_item *ti;
2061         proto_tree *ie_tree;
2062         tvbuff_t        *next_tvb;
2063         guint16 length;
2064         guint8 ie_id;
2065
2066         if(is_mandatory == FALSE){
2067                 ie_id = tvb_get_guint8(tvb,offset);
2068                 if (ie_id != RSL_IE_FULL_BCCH_INF)
2069                         return offset;
2070         }
2071
2072         ti = proto_tree_add_text(tree, tvb,offset,0,"Full BCCH Information IE");
2073         ie_tree = proto_item_add_subtree(ti, ett_ie_full_bcch_inf);
2074
2075         /* Element identifier */
2076         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2077         offset++;
2078         /* Length */
2079         length = tvb_get_guint8(tvb, offset);
2080         proto_item_set_len(ti, length+2);
2081         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
2082         offset++;
2083
2084         /* 
2085          * Octets 3-25 contain the complete L3 message as defined in 3GPP TS 44.018.
2086          */
2087
2088         proto_tree_add_text(ie_tree, tvb,offset,length,"Layer 3 message");
2089         next_tvb = tvb_new_subset(tvb, offset, length, length);
2090         /* call_dissector(gsm_a_dtap_handle, next_tvb, pinfo, top_tree);*/
2091
2092         offset = offset + length;
2093
2094         return offset;
2095  }
2096
2097 /*
2098  * 9.3.40 Channel Needed
2099  */
2100 static const value_string rsl_ch_needed_vals[] = {
2101         {  0x00,        "Any Channel" },
2102         {  0x01,        "SDCCH" },
2103         {  0x02,        "TCH/F (Full rate)" },
2104         {  0x03,        "TCH/F or TCH/H (Dual rate)" },
2105         { 0,            NULL }
2106 };
2107
2108 static int
2109 dissect_rsl_ie_ch_needed(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2110 {
2111         proto_item *ti;
2112         proto_tree *ie_tree;
2113         guint8          ie_id;
2114
2115         if(is_mandatory == FALSE){
2116                 ie_id = tvb_get_guint8(tvb,offset);
2117                 if (ie_id != RSL_IE_CH_NEEDED)
2118                         return offset;
2119         }
2120
2121
2122         ti = proto_tree_add_text(tree, tvb,offset,0,"Channel Needed IE");
2123         ie_tree = proto_item_add_subtree(ti, ett_ie_ch_needed);
2124
2125         /* Element identifier */
2126         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2127         offset++;
2128
2129         /* Channel */
2130         proto_tree_add_item(ie_tree, hf_rsl_ch_needed, tvb, offset, 1, FALSE);
2131         offset++;
2132         
2133         return offset;
2134 }
2135 /* 
2136  * 9.3.41 CB Command type
2137  */
2138 static int
2139 dissect_rsl_ie_cb_cmd_type(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2140 {
2141         proto_item *ti;
2142         proto_tree *ie_tree;
2143         guint8          ie_id;
2144
2145         if(is_mandatory == FALSE){
2146                 ie_id = tvb_get_guint8(tvb,offset);
2147                 if (ie_id != RSL_IE_CB_CMD_TYPE)
2148                         return offset;
2149         }
2150
2151
2152         ti = proto_tree_add_text(tree, tvb,offset,0,"CB Command type IE");
2153         ie_tree = proto_item_add_subtree(ti, ett_ie_cb_cmd_type);
2154
2155         /* Element identifier */
2156         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2157         offset++;
2158
2159         /* Channel */
2160         proto_tree_add_item(ie_tree, hf_rsl_ch_needed, tvb, offset, 1, FALSE);
2161         offset++;
2162         
2163         return offset;
2164 }
2165
2166 /*
2167  * 9.3.42 SMSCB Message
2168  */
2169 static int
2170 dissect_rsl_ie_smscb_mess(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2171 {
2172         proto_item *ti;
2173         proto_tree *ie_tree;
2174         guint length;
2175         guint8 ie_id;
2176         int     ie_offset;
2177
2178         if(is_mandatory == FALSE){
2179                 ie_id = tvb_get_guint8(tvb,offset);
2180                 if (ie_id != RSL_IE_SMSCB_MESS)
2181                         return offset;
2182         }
2183         ti = proto_tree_add_text(tree, tvb,offset,0,"SMSCB Message IE");
2184         ie_tree = proto_item_add_subtree(ti, ett_ie_smscb_mess);
2185
2186         /* Element identifier */
2187         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2188         offset++;
2189         /* Length */
2190         length = tvb_get_guint8(tvb,offset);
2191         proto_item_set_len(ti, length+2);
2192         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
2193         offset++;
2194         ie_offset = offset;
2195
2196         /* 
2197          * SMSCB Message
2198          */
2199
2200         proto_tree_add_text(ie_tree, tvb,offset,length ,"SMSCB Message");
2201
2202         offset = ie_offset + length;
2203
2204         return offset;
2205 }
2206
2207 /*
2208  * 9.3.43 CBCH Load Information
2209  */
2210
2211 static const true_false_string rsl_cbch_load_type_vals = {
2212   "Overflow",
2213   "Underflow"
2214 };
2215
2216 static int
2217 dissect_rsl_ie_cbch_load_inf(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2218 {
2219         proto_item *ti, *item;
2220         proto_tree *ie_tree;
2221         guint8          ie_id;
2222         guint8          octet;
2223
2224         if(is_mandatory == FALSE){
2225                 ie_id = tvb_get_guint8(tvb,offset);
2226                 if (ie_id != RSL_IE_CBCH_LOAD_INF)
2227                         return offset;
2228         }
2229
2230
2231         ti = proto_tree_add_text(tree, tvb,offset,0,"CBCH Load Information IE");
2232         ie_tree = proto_item_add_subtree(ti, ett_ie_cbch_load_inf);
2233
2234         /* Element identifier */
2235         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2236         offset++;
2237
2238         octet = tvb_get_guint8(tvb,offset);
2239         /* CBCH Load Type */
2240         proto_tree_add_item(ie_tree, hf_rsl_cbch_load_type, tvb, offset, 1, FALSE);
2241
2242         /* Message Slot Count */
2243         item = proto_tree_add_item(ie_tree, hf_rsl_msg_slt_cnt, tvb, offset, 1, FALSE);
2244         if ((octet & 0x80) == 0x80){
2245                 proto_item_append_text(item,"The amount of SMSCB messages (1 to 15) that are needed immediately by BTS");
2246         }else{
2247                 proto_item_append_text(item,"The amount of delay in message slots (1 to 15) that is needed immediately by BTS");
2248         }
2249         offset++;
2250
2251         return offset;
2252 }
2253
2254 /*
2255  * 9.3.44 SMSCB Channel Indicator
2256  */
2257
2258 static const value_string rsl_ch_ind_vals[] = {
2259         {  0x00,        "Basic CBCH" },
2260         {  0x01,        "Extended CBCH (supporting the extended CBCH by the network or MSs is optional)" },
2261         { 0,            NULL }
2262 };
2263
2264 static int
2265 dissect_rsl_ie_smscb_ch_ind(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2266 {
2267         proto_item *ti;
2268         proto_tree *ie_tree;
2269         guint8          ie_id;
2270
2271         if(is_mandatory == FALSE){
2272                 ie_id = tvb_get_guint8(tvb,offset);
2273                 if (ie_id != RSL_IE_SMSCB_CH_IND)
2274                         return offset;
2275         }
2276
2277
2278         ti = proto_tree_add_text(tree, tvb,offset,0,"SMSCB Channel Indicator IE");
2279         ie_tree = proto_item_add_subtree(ti, ett_ie_smscb_ch_ind);
2280
2281         /* Element identifier */
2282         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2283         offset++;
2284
2285         /* Channel Ind */
2286         proto_tree_add_item(ie_tree, hf_rsl_ch_ind, tvb, offset, 1, FALSE);
2287         offset++;
2288         
2289         return offset;
2290 }
2291
2292 /*
2293  * 9.3.45 Group call reference
2294  */
2295 static int
2296 dissect_rsl_ie_grp_call_ref(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2297 {
2298         proto_item *ti;
2299         proto_tree *ie_tree;
2300         guint length;
2301         guint8 ie_id;
2302
2303         if(is_mandatory == FALSE){
2304                 ie_id = tvb_get_guint8(tvb,offset);
2305                 if (ie_id != RSL_IE_GRP_CALL_REF)
2306                         return offset;
2307         }
2308         ti = proto_tree_add_text(tree, tvb,offset,0,"Group call reference IE");
2309         ie_tree = proto_item_add_subtree(ti, ett_ie_grp_call_ref);
2310
2311         /* Element identifier */
2312         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2313         offset++;
2314         /* Length */
2315         length = tvb_get_guint8(tvb,offset);
2316         proto_item_set_len(ti, length+2);
2317         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
2318         offset++;
2319
2320         proto_tree_add_text(ie_tree, tvb,offset,length,"Descriptive group or broadcast call reference");
2321
2322         /* The octets 3 to 7 are coded in the same way as the octets 2 to 6 
2323          * in the Descriptive group or broadcast call reference
2324          * information element as defined in 3GPP TS 24.008.
2325          */
2326         de_d_gb_call_ref(tvb, ie_tree, offset, length, NULL, 0);
2327
2328         offset = offset + length;
2329
2330         return offset;
2331 }
2332 /*
2333  * 9.3.46 Channel description
2334  */
2335 static int
2336 dissect_rsl_ie_ch_desc(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2337 {
2338         proto_item *ti;
2339         proto_tree *ie_tree;
2340         guint length;
2341         guint8 ie_id;
2342
2343         if(is_mandatory == FALSE){
2344                 ie_id = tvb_get_guint8(tvb,offset);
2345                 if (ie_id != RSL_IE_CH_DESC)
2346                         return offset;
2347         }
2348         ti = proto_tree_add_text(tree, tvb,offset,0,"Channel description IE");
2349         ie_tree = proto_item_add_subtree(ti, ett_ie_ch_desc);
2350
2351         /* Element identifier */
2352         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2353         offset++;
2354         /* Length */
2355         length = tvb_get_guint8(tvb,offset);
2356         proto_item_set_len(ti, length+2);
2357         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
2358         offset++;
2359
2360         proto_tree_add_text(ie_tree, tvb,offset,length,"Group Channel Description");
2361
2362         /* Octet j (j = 3, 4, ..., n) is the unchanged octet j-2 of a radio interface Group Channel description
2363          * information element as defined in 3GPP TS 44.018, n-2 is equal to the length of the radio interface
2364          * Group channel description information element
2365          */
2366         
2367         offset = offset + length;
2368
2369         return offset;
2370 }
2371 /*
2372  * 9.3.47 NCH DRX information
2373  * This is a variable length element used to pass a radio interface information element
2374  * from BSC to BTS.
2375  */
2376 static int
2377 dissect_rsl_ie_nch_drx(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2378 {
2379         proto_item *ti;
2380         proto_tree *ie_tree;
2381         guint8          ie_id;
2382
2383         if(is_mandatory == FALSE){
2384                 ie_id = tvb_get_guint8(tvb,offset);
2385                 if (ie_id != RSL_IE_NCH_DRX_INF)
2386                         return offset;
2387         }
2388
2389         ti = proto_tree_add_text(tree, tvb,offset,2,"NCH DRX information IE");
2390         ie_tree = proto_item_add_subtree(ti, ett_ie_nch_drx);
2391
2392         /* Element identifier */
2393         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2394         offset++;
2395         /* NCH DRX information */
2396         /* Octet 3 bits 7 and 8 are spare and set to zero. */
2397         /* Octet 3 bit 6 is the NLN status parameter as defined in 3GPP TS 44.018.*/
2398         /* Octet 3 bits 3, 4 and 5 are bits 1, 2 and 3 of the radio interface
2399          * eMLPP priority as defined in 3GPP TS 44.018.
2400          */
2401         /* Octet 3 bits 1 and 2 are bits 1 and 2 of the radio interface NLN 
2402          * as defined in 3GPP TS 44.018.
2403          */
2404
2405         offset++;
2406
2407         return offset;
2408 }
2409 /*
2410  * 9.3.48 Command indicator
2411  */
2412
2413 static int
2414 dissect_rsl_ie_cmd_ind(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2415 {
2416         proto_item *ti;
2417         proto_tree *ie_tree;
2418         guint8          ie_id;
2419         guint8          octet;
2420
2421         if(is_mandatory == FALSE){
2422                 ie_id = tvb_get_guint8(tvb,offset);
2423                 if (ie_id != RSL_IE_CMD_IND)
2424                         return offset;
2425         }
2426
2427
2428         /* TODO Length wrong if extended */
2429         ti = proto_tree_add_text(tree, tvb,offset,2,"Command indicator IE");
2430         ie_tree = proto_item_add_subtree(ti, ett_ie_cmd_ind);
2431
2432         /* Element identifier */
2433         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2434         offset++;
2435
2436         /* Extension bit */
2437         proto_tree_add_item(ie_tree, hf_rsl_extension_bit, tvb, offset, 1, FALSE);
2438
2439
2440         /* TODO this should probably be add_uint instead!!! */
2441         octet = tvb_get_guint8(tvb,offset);
2442         if ((octet&0x80)==0x80){
2443                 /* extended */
2444                 /* Command Extension */
2445                 proto_tree_add_item(ie_tree, hf_rsl_command, tvb, offset, 2, FALSE);
2446                 offset = offset+2;
2447         }else{
2448                 /* Command Value */
2449                 proto_tree_add_item(ie_tree, hf_rsl_command, tvb, offset, 1, FALSE);
2450                 offset++;
2451         }
2452         
2453         return offset;
2454 }
2455 /*
2456  * 9.3.49 eMLPP Priority
2457  */
2458 static const value_string rsl_emlpp_prio_vals[] = {
2459         {  0x00,        "no priority applied" },
2460         {  0x01,        "call priority level 4" },
2461         {  0x02,        "call priority level 3" },
2462         {  0x03,        "call priority level 2" },
2463         {  0x04,        "call priority level 1" },
2464         {  0x05,        "call priority level 0" },
2465         {  0x06,        "call priority level B" },
2466         {  0x07,        "call priority level A" },
2467         { 0,                    NULL }
2468 };
2469
2470 static int
2471 dissect_rsl_ie_emlpp_prio(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2472 {
2473         proto_item *ti;
2474         proto_tree *ie_tree;
2475         guint8          ie_id;
2476
2477         if(is_mandatory == FALSE){
2478                 ie_id = tvb_get_guint8(tvb,offset);
2479                 if (ie_id != RSL_IE_EMLPP_PRIO)
2480                         return offset;
2481         }
2482
2483         ti = proto_tree_add_text(tree, tvb,offset,2,"eMLPP Priority IE");
2484         ie_tree = proto_item_add_subtree(ti, ett_ie_emlpp_prio);
2485
2486         /* Element identifier */
2487         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2488         offset++;
2489
2490         /* The call priority field (bit 3 to 1 of octet 2) is coded in the same way
2491          * as the call priority field (bit 3 to 1 of octet 5) in the 
2492          * Descriptive group or broadcast call reference information element
2493          * as defined in 3GPP TS 24.008. 
2494          */
2495         proto_tree_add_item(ie_tree, hf_rsl_emlpp_prio, tvb, offset, 1, FALSE);
2496         offset++;
2497
2498         return offset;
2499 }
2500
2501 /*
2502  * 9.3.50 UIC
2503  */
2504 static int
2505 dissect_rsl_ie_uic(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2506 {
2507         proto_item *ti;
2508         proto_tree *ie_tree;
2509         guint8          ie_id;
2510
2511         if(is_mandatory == FALSE){
2512                 ie_id = tvb_get_guint8(tvb,offset);
2513                 if (ie_id != RSL_IE_UIC)
2514                         return offset;
2515         }
2516
2517         ti = proto_tree_add_text(tree, tvb,offset,0,"UIC IE");
2518         ie_tree = proto_item_add_subtree(ti, ett_ie_uic);
2519
2520         /* Element identifier */
2521         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2522         offset++;
2523
2524         /* Octet 3 bits 1 to 6 contain the radio interface octet 2 bits 3 to 8 of the
2525          * UIC information element as defined in 3GPP TS 44.018. 
2526          */
2527         proto_tree_add_text(ie_tree, tvb,offset,1,"UIC");
2528         offset++;
2529
2530         return offset;
2531 }
2532
2533 /*
2534  * 9.3.51 Main channel reference
2535  */
2536
2537 static int
2538 dissect_rsl_ie_main_ch_ref(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2539 {
2540         proto_item *ti;
2541         proto_tree *ie_tree;
2542         guint8          ie_id;
2543
2544         if(is_mandatory == FALSE){
2545                 ie_id = tvb_get_guint8(tvb,offset);
2546                 if (ie_id != RSL_IE_MAIN_CH_REF)
2547                         return offset;
2548         }
2549
2550         ti = proto_tree_add_text(tree, tvb,offset,0,"Main channel reference IE");
2551         ie_tree = proto_item_add_subtree(ti, ett_ie_main_ch_ref);
2552
2553         /* Element identifier */
2554         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2555         offset++;
2556
2557         /* TN is time slot number, binary represented as in 3GPP TS 45.002.
2558          * 3 Bits
2559          */
2560         proto_tree_add_item(ie_tree, hf_rsl_ch_no_TN, tvb, offset, 1, FALSE);
2561         offset++;
2562         return offset;
2563 }
2564
2565 /*
2566  * 9.3.52 MultiRate configuration
2567  */
2568
2569 static int
2570 dissect_rsl_ie_multirate_conf(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2571 {
2572         proto_item *ti;
2573         proto_tree *ie_tree;
2574         guint length;
2575         guint8 ie_id;
2576
2577         if(is_mandatory == FALSE){
2578                 ie_id = tvb_get_guint8(tvb,offset);
2579                 if (ie_id != RSL_IE_MULTIRATE_CONF)
2580                         return offset;
2581         }
2582         ti = proto_tree_add_text(tree, tvb,offset,0,"MultiRate configuration IE");
2583         ie_tree = proto_item_add_subtree(ti, ett_ie_multirate_conf);
2584
2585         /* Element identifier */
2586         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2587         offset++;
2588         /* Length */
2589         length = tvb_get_guint8(tvb,offset);
2590         proto_item_set_len(ti, length+2);
2591         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
2592         offset++;
2593
2594         /* Rest of element coded as in 3GPP TS 44.018 not including
2595          * 3GPP TS 44.018 element identifier or 3GPP TS 44.018 octet length value
2596          */
2597
2598         de_rr_multirate_conf(tvb, ie_tree, offset, length, NULL, 0);
2599
2600         offset = offset + length;
2601
2602         return offset;
2603 }
2604
2605 /*
2606  * 9.3.53 MultiRate Control
2607  */
2608 static int
2609 dissect_rsl_ie_multirate_cntrl(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2610 {
2611         proto_item *ti;
2612         proto_tree *ie_tree;
2613         guint8 ie_id;
2614
2615         if(is_mandatory == FALSE){
2616                 ie_id = tvb_get_guint8(tvb,offset);
2617                 if (ie_id != RSL_IE_MULTIRATE_CNTRL)
2618                         return offset;
2619         }
2620         ti = proto_tree_add_text(tree, tvb,offset,2,"MultiRate Control IE");
2621         ie_tree = proto_item_add_subtree(ti, ett_ie_multirate_cntrl);
2622
2623         /* Element identifier */
2624         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2625         offset++;
2626
2627         /* Bit 8 -5 Spare */
2628         /* The OD field (bit 5 of octet 3) indicates if the BSC expects distant parameters or
2629          * TFO Decision algorithm result from the BTS
2630          */
2631         /* The PRE field (bit 4 of octet 3) indicates if an handover is to be expected soon or not. */
2632         /* The RAE field (bits 2-3, octet 3) defines whether the RATSCCH mechanism is enabled or not.*/
2633         offset++;
2634
2635         return offset;
2636 }
2637
2638 /*
2639  * 9.3.54 Supported Codec Types
2640  * This element indicates the codec types supported by the BSS or remote BSS.
2641  */
2642 static int
2643 dissect_rsl_ie_sup_codec_types(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2644 {
2645         proto_item *ti;
2646         proto_tree *ie_tree;
2647         guint length;
2648         guint8 ie_id;
2649
2650         if(is_mandatory == FALSE){
2651                 ie_id = tvb_get_guint8(tvb,offset);
2652                 if (ie_id != RSL_IE_SUP_CODEC_TYPES)
2653                         return offset;
2654         }
2655         ti = proto_tree_add_text(tree, tvb,offset,0,"Supported Codec Types IE");
2656         ie_tree = proto_item_add_subtree(ti, ett_ie_sup_codec_types);
2657
2658         /* Element identifier */
2659         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2660         offset++;
2661         /* Length */
2662         length = tvb_get_guint8(tvb,offset);
2663         proto_item_set_len(ti, length+2);
2664         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
2665         offset++;
2666
2667         proto_tree_add_text(tree, tvb,offset,length,"Codec List");
2668
2669         /* The Codec List field (octet 4) lists the codec types that are supported
2670          * by the BSS and Transcoder, and are therefore potential candidates for TFO
2671          * establishment.
2672          */
2673         /* The Codec List extension 1 field (octet 5) lists additional codec types
2674          * that are supported by the BSS and Transcoder, and are therefore potential
2675          * candidates for TFO establishment. When no codec from this list is supported,
2676          * then this field shall not be sent, and the extension bit of octet 4 shall
2677          * be set to 0.
2678          */
2679         /* If bit 4 of the Codec List field (octet 4) indicates that FR AMR is supported
2680          * or if bit 5 of the Codec List field (octet 4) indicates that HR AMR is supported
2681          * and bit 8 is set to 0, or if bit 6 of the Codec List field (octet 4) indicates
2682          * that UMTS AMR is supported, or if bit 7 of the Codec List field (octet 4)
2683          * indicates that UMTS AMR 2 is supported, or if bit 1, 3, 4 or 5 of the Codec List
2684          * extension 1 field (octet 5) indicates that AMR WB is supported, the following 
2685          * two octets (after the Codec List field and its extensions) is present
2686          */
2687
2688         return offset + length;
2689
2690 }
2691 /*
2692  * 9.3.55 Codec Configuration
2693  */
2694 /* The Active Codec Type field (bits 1-8, octet 3) indicates the type of codec in use. It is coded as follows: */
2695 /*
2696 0 0 0 0 . 0 0 0 0: Full Rate Codec in use
2697 0 0 0 0 . 0 0 0 1: Half Rate Codec in use
2698 0 0 0 0 . 0 0 1 0: Enhanced Full Rate Codec in use
2699 0 0 0 0 . 0 0 1 1: FR Adaptive Multi Rate Codec in use
2700 0 0 0 0 . 0 1 0 0: HR Adaptive Multi Rate Codec in use
2701 0 0 0 0 . 0 1 0 1: UMTS Adaptive Multi Rate Codec in use
2702 0 0 0 0 . 0 1 1 0: UMTS Adaptive Multi Rate 2 Codec in use
2703 0 0 0 0 . 1 0 0 1: Full Rate Adaptive Multi-Rate WideBand Codec in use
2704 0 0 0 0 1 0 1 0 UMTS Adaptive Multi-Rate WideBand Codec in use
2705 0 0 0 0 1 0 1 1 8PSK Half Rate Adaptive Multi-Rate Codec in use
2706 0 0 0 0 1 1 0 0 8PSK Full Rate Adaptive Multi-Rate WideBand Codec in use
2707 0 0 0 0 1 1 0 1 8PSK Half Rate Adaptive Multi-Rate WideBand Codec in use
2708 All other values are reserved for future use
2709 */
2710 static int
2711 dissect_rsl_ie_codec_conf(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2712 {
2713         proto_item *ti;
2714         proto_tree *ie_tree;
2715         guint length;
2716         guint8 ie_id;
2717
2718         if(is_mandatory == FALSE){
2719                 ie_id = tvb_get_guint8(tvb,offset);
2720                 if (ie_id != RSL_IE_CODEC_CONF)
2721                         return offset;
2722         }
2723         ti = proto_tree_add_text(tree, tvb,offset,0,"Codec Configuration IE");
2724         ie_tree = proto_item_add_subtree(ti, ett_ie_codec_conf);
2725
2726         /* Element identifier */
2727         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2728         offset++;
2729         /* Length */
2730         length = tvb_get_guint8(tvb,offset);
2731         proto_item_set_len(ti, length+2);
2732         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
2733         offset++;
2734
2735         /* Active Codec Type */
2736
2737         return offset + length;
2738 }
2739
2740 /*
2741  * 9.3.56 Round Trip Delay
2742  * This element indicates the value of the calculated round trip delay between the BTS
2743  * and the transcoder, or between the BTS and the remote BTS, if TFO is established.
2744  */
2745
2746 static const value_string rsl_delay_ind_vals[] = {
2747         {  0x00,        "The RTD field contains the BTS-Transcoder round trip delay" },
2748         {  0x01,        "The RTD field contains the BTS-Remote BTS round trip delay" },
2749         { 0,                    NULL }
2750 };
2751 static int
2752 dissect_rsl_ie_rtd(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2753 {
2754         proto_item *ti, *rtd_item;
2755         proto_tree *ie_tree;
2756         guint8          ie_id;
2757         guint8          rtd;
2758
2759         if(is_mandatory == FALSE){
2760                 ie_id = tvb_get_guint8(tvb,offset);
2761                 if (ie_id != RSL_IE_RTD)
2762                         return offset;
2763         }
2764
2765         ti = proto_tree_add_text(tree, tvb,offset,0,"Round Trip Delay IE");
2766         ie_tree = proto_item_add_subtree(ti, ett_ie_rtd);
2767
2768         /* Element identifier */
2769         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2770         offset++;
2771
2772         /* The RTD field is the binary representation of the value of the 
2773          * round trip delay in 20 ms increments.
2774          */
2775         rtd = (tvb_get_guint8(tvb,offset)>>1)*20;
2776         rtd_item = proto_tree_add_uint(tree, hf_rsl_rtd, tvb,offset,1,rtd);
2777         proto_item_append_text(rtd_item," ms");
2778
2779         /* The Delay IND field indicates if the delay corresponds to a BTS 
2780          * to transcoder delay or to a BTS to remote BTS delay.
2781          */
2782         proto_tree_add_item(ie_tree, hf_rsl_delay_ind, tvb, offset, 1, FALSE);
2783         offset++;
2784
2785         return offset;
2786 }
2787 /*
2788  * 9.3.57 TFO Status
2789  * This element indicates if TFO is established. It is coded in 2 octets
2790  */
2791
2792 static const true_false_string rsl_tfo_vals = {
2793   "TFO is established",
2794   "TFO is not established"
2795 };
2796
2797 static int
2798 dissect_rsl_ie_tfo_status(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2799 {
2800         proto_item *ti;
2801         proto_tree *ie_tree;
2802         guint8          ie_id;
2803
2804         if(is_mandatory == FALSE){
2805                 ie_id = tvb_get_guint8(tvb,offset);
2806                 if (ie_id != RSL_IE_TFO_STATUS)
2807                         return offset;
2808         }
2809
2810         ti = proto_tree_add_text(tree, tvb,offset,0,"TFO Status IE");
2811         ie_tree = proto_item_add_subtree(ti, ett_ie_tfo_status);
2812
2813         /* Element identifier */
2814         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2815         offset++;
2816
2817         proto_tree_add_item(ie_tree, hf_rsl_tfo, tvb, offset, 1, FALSE);
2818         offset++;
2819         return offset;
2820 }
2821 /*
2822  * 9.3.58 LLP APDU
2823  */
2824
2825 static int
2826 dissect_rsl_ie_llp_apdu(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2827 {
2828         proto_item *ti;
2829         proto_tree *ie_tree;
2830         guint8 length;
2831         int ie_offset;
2832         guint8 ie_id;
2833
2834         if(is_mandatory == FALSE){
2835                 ie_id = tvb_get_guint8(tvb,offset);
2836                 if (ie_id != RSL_IE_LLP_APDU)
2837                         return offset;
2838         }
2839
2840         ti = proto_tree_add_text(tree, tvb,offset,0,"LLP APDU IE");
2841         ie_tree = proto_item_add_subtree(ti, ett_ie_llp_apdu);
2842
2843         /* Element identifier */
2844         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2845         offset++;
2846         /* Length */
2847         length = tvb_get_guint8(tvb, offset);
2848         proto_item_set_len(ti, length+2);
2849         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
2850         offset++;
2851
2852         ie_offset = offset;
2853
2854         /* The rest of the information element contains the embedded message
2855          * that contains a Facility Information Element as defined in
2856          * 3GPP TS 44.071 excluding the Facility IEI and length of Facility IEI
2857          * octets defined in 3GPP TS 44.071.
2858          */
2859         /* TODO: Given traces with LLP data this IE could be further dissected */
2860         proto_tree_add_text(tree, tvb,offset,length,
2861                 "Facility Information Element as defined in 3GPP TS 44.071");
2862         return ie_offset + length;
2863 }
2864 /*
2865  * 9.3.59 TFO transparent container
2866  * This is a variable length element that conveys a message associated with TFO protocol,
2867  * as defined in 3GPP TS 28.062. This element can be sent from the BSC to the BTS or 
2868  * from the BTS to the BSC. The BTS shall retrieve the information it is able to understand,
2869  * and forward transparently the complete information to the BSC or to the TRAU.
2870  */
2871 static int
2872 dissect_rsl_ie_tfo_transp_cont(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean is_mandatory)
2873 {
2874         proto_item *ti;
2875         proto_tree *ie_tree;
2876         guint8 length;
2877         int ie_offset;
2878         guint8 ie_id;
2879
2880         if(is_mandatory == FALSE){
2881                 ie_id = tvb_get_guint8(tvb,offset);
2882                 if (ie_id != RSL_IE_TFO_TRANSP_CONT)
2883                         return offset;
2884         }
2885
2886         ti = proto_tree_add_text(tree, tvb,offset,0,"TFO transparent container IE");
2887         ie_tree = proto_item_add_subtree(ti, ett_ie_tfo_transp_cont);
2888
2889         /* Element identifier */
2890         proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
2891         offset++;
2892         /* Length */
2893         length = tvb_get_guint8(tvb, offset);
2894         proto_item_set_len(ti, length+2);
2895         proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
2896         offset++;
2897
2898         ie_offset = offset;
2899
2900         /* The rest of the information element contains the embedded message
2901          * that contains a Facility Information Element as defined in
2902          * 3GPP TS 44.071 excluding the Facility IEI and length of Facility IEI
2903          * octets defined in 3GPP TS 44.071.
2904          */
2905         proto_tree_add_text(tree, tvb,offset,length,
2906                 "Embedded message that contains the TFO configuration");
2907         return ie_offset + length;
2908 }
2909
2910 static int
2911 dissct_rsl_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
2912 {
2913         guint8  msg_type;
2914
2915         msg_type = tvb_get_guint8(tvb,offset)&0x7f;
2916         proto_tree_add_item(tree, hf_rsl_msg_type, tvb, offset, 1, FALSE);
2917         offset++;
2918
2919         switch (msg_type){
2920 /* Radio Link Layer Management messages */
2921         /* 8.3.1 DATA REQUEST */
2922         case RSL_MSG_TYPE_DATA_REQ:
2923                 /* Channel number                       9.3.1   M TV 2          */
2924                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
2925                 /* Link Identifier                      9.3.2   M TV 2          */
2926                 offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset, TRUE);
2927                 /* L3 Information                       9.3.11  M TLV >=3       */
2928                 offset = dissect_rsl_ie_L3_inf(tvb, pinfo, tree, offset, TRUE);
2929                 break;
2930         /* 8.3.2 DATA INDICATION */
2931         case RSL_MSG_TYPE_DATA_IND:
2932                 /* Channel number                       9.3.1   M TV 2          */
2933                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
2934                 /* Link Identifier                      9.3.2   M TV 2          */
2935                 offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset, TRUE);
2936                 /* L3 Information                       9.3.11  M TLV >=3       */
2937                 offset = dissect_rsl_ie_L3_inf(tvb, pinfo, tree, offset, TRUE);
2938                 break;
2939         /* 8.3.3 ERROR INDICATION */
2940         case RSL_MSG_TYPE_ERROR_IND:
2941                 /* Channel number                       9.3.1   M TV 2          */
2942                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
2943                 /* Link Identifier                      9.3.2   M TV 2          */
2944                 offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset, TRUE);
2945                 /* RLM Cause                            9.3.22  M TLV 2-4       */
2946                 offset = dissect_rsl_ie_rlm_cause(tvb, pinfo, tree, offset, TRUE);
2947                 break;
2948         /* 8.3.4 ESTABLISH REQUEST */
2949         case RSL_MSG_TYPE_EST_REQ:
2950                 /* Channel number                       9.3.1   M TV 2          */
2951                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
2952                 /* Link Identifier                      9.3.2   M TV 2          */
2953                 offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset, TRUE);
2954                 break;
2955         /* 8.3.5 ESTABLISH CONFIRM */
2956         case RSL_MSG_TYPE_EST_CONF:
2957                 /* Channel number                       9.3.1   M TV 2          */
2958                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
2959                 /* Link Identifier                      9.3.2   M TV 2          */
2960                 offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset, TRUE);
2961                 break;
2962         /* 8.3.6 */
2963         case RSL_MSG_EST_IND:
2964                 /*      Channel number                  9.3.1   M TV 2                           */
2965                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
2966                 /*      Link Identifier                 9.3.2   M TV 2                           */
2967                 offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset, TRUE);
2968                 /*      L3 Information                  9.3.11  O (note 1) TLV 3-23      */
2969                 if(tvb_length_remaining(tvb,offset) >1)
2970                         offset = dissect_rsl_ie_L3_inf(tvb, pinfo, tree, offset, FALSE);
2971                 break;
2972         /* 8.3.7 RELEASE REQUEST */
2973         case RSL_MSG_REL_REQ:
2974                 /*      Channel number                  9.3.1   M TV 2                           */
2975                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
2976                 /*      Link Identifier                 9.3.2   M TV 2                           */
2977                 offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset, TRUE);
2978                 /* Release Mode                         9.3.20  M TV 2                          */
2979                 offset = dissect_rsl_ie_rel_mode(tvb, pinfo, tree, offset, TRUE);
2980                 break;
2981         /* 8.3.8 RELEASE CONFIRM */
2982         case RSL_MSG_REL_CONF:
2983                 /*      Channel number                  9.3.1   M TV 2                           */
2984                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
2985                 /*      Link Identifier                 9.3.2   M TV 2                           */
2986                 offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset, TRUE);
2987                 break;
2988         /* 8.3.9 RELEASE INDICATION */
2989         case RSL_MSG_REL_IND:
2990                 /*      Channel number                  9.3.1   M TV 2                           */
2991                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
2992                 /*      Link Identifier                 9.3.2   M TV 2                           */
2993                 offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset, TRUE);
2994                 break;
2995         /* 8.3.10 UNIT DATA REQUEST 10 */
2996         case RSL_MSG_UNIT_DATA_REQ:
2997                 /*      Channel number                  9.3.1   M TV 2                           */
2998                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
2999                 /*      Link Identifier                 9.3.2   M TV 2                           */
3000                 offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset, TRUE);
3001                 /*      L3 Information                  9.3.11  O (note 1) TLV 3-23      */
3002                 if(tvb_length_remaining(tvb,offset) > 0)
3003                         offset = dissect_rsl_ie_L3_inf(tvb, pinfo, tree, offset, FALSE);
3004                 break;
3005 /* Common Channel Management/TRX Management messages */
3006         /* 8.5.1 BCCH INFORMATION 17*/
3007         case RSL_MSG_BCCH_INFO:
3008                 /*      Channel number                  9.3.1   M TV 2 */
3009                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3010                 /*      System Info Type                9.3.30  M TV 2 */
3011                 offset = dissect_rsl_ie_sys_info_type(tvb, pinfo, tree, offset, TRUE);
3012                 /*      Full BCCH Info (SYS INFO) 9.3.39 O 1) TLV 25 */
3013                 if(tvb_length_remaining(tvb,offset) > 0)
3014                         offset = dissect_rsl_ie_full_bcch_inf(tvb, pinfo, tree, offset, TRUE);
3015                 /*      Starting Time                   9.3.23  O 2) TV 3 */
3016                 if(tvb_length_remaining(tvb,offset) > 0)
3017                         offset = dissect_rsl_ie_staring_time(tvb, pinfo, tree, offset, FALSE);
3018                 break;
3019         /* 8.5.2 CCCH LOAD INDICATION 18*/      
3020         case RSL_MSG_CCCH_LOAD_IND:
3021                 /*      Channel number (note)   9.3.1   M TV 2 */
3022                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3023                 /* Either RACH Load or Paging Load present */
3024                 /*      RACH Load                               9.3.18  C 1) TLV >=8 */
3025                 offset = dissect_rsl_ie_rach_load(tvb, pinfo, tree, offset, FALSE);
3026                 /*      Paging Load                             9.3.15  C 2) TV 3 */
3027                 if(tvb_length_remaining(tvb,offset) > 0)
3028                         offset = dissect_rsl_ie_paging_load(tvb, pinfo, tree, offset, FALSE);
3029                 break;
3030         /* 8.5.3 */
3031         case RSL_MSG_CHANRQD: /* 19 */
3032                 /* Channel number                       9.3.1   M TV 2 */
3033                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3034                 /* Request Reference            9.3.19  M TV 4 */
3035                 offset = dissect_rsl_ie_req_ref(tvb, pinfo, tree, offset, TRUE);
3036                 /* Access Delay                         9.3.17  M TV 2 */
3037                 offset = dissect_rsl_ie_access_delay(tvb, pinfo, tree, offset, TRUE);
3038                 /* Physical Context                     9.3.16  O 1) TLV >=2 */
3039                 if(tvb_length_remaining(tvb,offset) > 0)
3040                         offset = dissect_rsl_ie_phy_ctx(tvb, pinfo, tree, offset, FALSE);
3041                 break;
3042         /* 8.5.4 DELETE INDICATION */
3043         case RSL_MSG_DELETE_IND: /* 20 */
3044                 /* Channel number                       9.3.1   M TV 2 */
3045                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3046                 /* Full Imm. Assign Info        9.3.35  M TLV 25 */
3047                 offset = dissect_rsl_ie_full_imm_ass_inf(tvb, pinfo, tree, offset, TRUE);
3048                 break;
3049         case RSL_MSG_PAGING_CMD:        /* 21 */
3050                 /* Channel number                       9.3.1   M TV 2 */
3051                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3052                 /* Paging Group                         9.3.14  M TV 2 2 */
3053                 offset = dissect_rsl_ie_paging_grp(tvb, pinfo, tree, offset, TRUE);
3054                 /* MS Identity                          9.3.12  M TLV 2-10 2 */
3055                 offset = dissect_rsl_ie_ms_id(tvb, pinfo, tree, offset, TRUE);
3056                 /* Channel Needed                       9.3.40  O 1) TV 2 2 */
3057                 if(tvb_length_remaining(tvb,offset) > 0)
3058                         offset = dissect_rsl_ie_ch_needed(tvb, pinfo, tree, offset, FALSE);
3059                 /* eMLPP Priority                       9.3.49  O 2) TV 2 2 */
3060                 if(tvb_length_remaining(tvb,offset) > 0)
3061                         offset = dissect_rsl_ie_emlpp_prio(tvb, pinfo, tree, offset, FALSE);
3062                 break;
3063         /* 8.5.6 IMMEDIATE ASSIGN COMMAND */
3064         case RSL_MSG_IMM_ASS_CMD:       /* 22 */
3065                 /* Channel number                       9.3.1   M TV 2 */
3066                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3067                 /* Full Imm. Assign Info        9.3.35  M TLV 25 */
3068                 offset = dissect_rsl_ie_full_imm_ass_inf(tvb, pinfo, tree, offset, TRUE);
3069                 break;
3070         /* 8.5.7 SMS BROADCAST REQUEST */
3071         case RSL_MSG_SMS_BC_REQ:        /*      23       8.5.7 */
3072                 /* Channel number                       9.3.1   M TV 2 */
3073                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3074                 /* SMSCB Information            9.3.36  M TV 24 */
3075                 offset = dissect_rsl_ie_smscb_inf(tvb, pinfo, tree, offset, TRUE);
3076                 /* SMSCB Channel Indicator      9.3.44  O 1) TV 2 */
3077                 if(tvb_length_remaining(tvb,offset) > 0)
3078                         offset = dissect_rsl_ie_smscb_ch_ind(tvb, pinfo, tree, offset, FALSE);
3079                 break;
3080 /* 8.6 TRX MANAGEMENT MESSAGES */
3081         /* 8.6.1 RF RESOURCE INDICATION */
3082         case RSL_MSG_RF_RES_IND:        /*      24       8.6.1 */
3083                 /* Resource Information         9.3.21  M TLV >=2 */
3084                 offset = dissect_rsl_ie_resource_inf(tvb, pinfo, tree, offset, TRUE);
3085                 break;
3086         /* 8.6.2 SACCH FILLING */
3087         case RSL_MSG_SACCH_FILL:        /*      25       8.6.2 */
3088                 /* System Info Type                     9.3.30  M TV 2 */
3089                 offset = dissect_rsl_ie_sys_info_type(tvb, pinfo, tree, offset, TRUE);
3090                 /* L3 Info (SYS INFO)           9.3.11 O 1) TLV 22 */
3091                 if(tvb_length_remaining(tvb,offset) > 0)
3092                         offset = dissect_rsl_ie_L3_inf(tvb, pinfo, tree, offset, FALSE);
3093                 /* Starting Time                        9.3.23 O 2) TV 3 */
3094                 if(tvb_length_remaining(tvb,offset) > 0)
3095                         offset = dissect_rsl_ie_staring_time(tvb, pinfo, tree, offset, FALSE);
3096                 break;
3097         case RSL_MSG_OVERLOAD:          /*      27       8.6.3 */
3098                 /* Cause                                        9.3.26  M TLV >=3 */
3099                 offset = dissect_rsl_ie_cause(tvb, pinfo, tree, offset, TRUE);
3100                 break;
3101         case RSL_MSG_ERROR_REPORT:      /*      28       8.6.4 */
3102                 /* Cause                                        9.3.26  M TLV >=3 */
3103                 offset = dissect_rsl_ie_cause(tvb, pinfo, tree, offset, TRUE);
3104                 /* Message Identifier           9.3.28  O 1) TV 2 */
3105                 if(tvb_length_remaining(tvb,offset) > 0)
3106                         offset = dissect_rsl_ie_message_id(tvb, pinfo, tree, offset, FALSE);
3107                 /* Channel Number                       9.3.1   O 2) TV 2 */
3108                 if(tvb_length_remaining(tvb,offset) > 0)
3109                         offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3110                 /* Link identifier                      9.3.2   O 3) TV 2 */
3111                 if(tvb_length_remaining(tvb,offset) > 0)
3112                         offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset, TRUE);
3113                 /* Erroneous Message            9.3.38  O 4) TLV >=3 */
3114                 if(tvb_length_remaining(tvb,offset) > 0)
3115                         offset = dissect_rsl_ie_err_msg(tvb, pinfo, tree, offset, TRUE);
3116                 break;
3117         /* 8.5.8 SMS BROADCAST COMMAND */
3118         case RSL_MSG_SMS_BC_CMD:        /*      29       8.5.8 */
3119                 /* Channel number                       9.3.1   M TV 2 */
3120                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3121                 /* CB Command type                      9.3.41  M TV 2 */
3122                 offset = dissect_rsl_ie_cb_cmd_type(tvb, pinfo, tree, offset, TRUE);
3123                 /* SMSCB message                        9.3.42  M TLV 2-90 */
3124                 offset = dissect_rsl_ie_smscb_mess(tvb, pinfo, tree, offset, TRUE);
3125                 /* SMSCB Channel Indicator      9.3.44  O 1) TV 2 */
3126                 if(tvb_length_remaining(tvb,offset) > 0)
3127                         offset = dissect_rsl_ie_smscb_ch_ind(tvb, pinfo, tree, offset, FALSE);
3128                 break;
3129         case RSL_MSG_CBCH_LOAD_IND:     /*      30       8.5.9 */
3130                 /* Channel number                       9.3.1   M TV 2 */
3131                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3132                 /* CBCH Load Information        9.3.43  M TV 2 */
3133                 offset = dissect_rsl_ie_cbch_load_inf(tvb, pinfo, tree, offset, TRUE);
3134                 /* SMSCB Channel Indicator      9.3.44 O 1) TV 2 */
3135                 if(tvb_length_remaining(tvb,offset) > 0)
3136                         offset = dissect_rsl_ie_smscb_ch_ind(tvb, pinfo, tree, offset, FALSE);
3137                 break;
3138         case RSL_MSG_NOT_CMD:           /*      31       8.5.10 */
3139                 /* Channel number                       9.3.1   M TV 2 */
3140                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3141                 /* Command indicator            9.3.48 M 1) TLV 3-4 */
3142                 offset = dissect_rsl_ie_cmd_ind(tvb, pinfo, tree, offset, TRUE);
3143                 /* Group call reference         9.3.45 O TLV 7 */
3144                 if(tvb_length_remaining(tvb,offset) > 0)
3145                         offset = dissect_rsl_ie_grp_call_ref(tvb, pinfo, tree, offset, FALSE);
3146                 /* Channel Description          9.3.46 O TLV 3-n */
3147                 if(tvb_length_remaining(tvb,offset) > 0)
3148                         offset = dissect_rsl_ie_ch_desc(tvb, pinfo, tree, offset, FALSE);
3149                 /* NCH DRX information          9.3.47 O TLV 3 */
3150                 if(tvb_length_remaining(tvb,offset) > 0)
3151                         offset = dissect_rsl_ie_nch_drx(tvb, pinfo, tree, offset, FALSE);
3152                 break;
3153
3154 /* Dedicated Channel Management messages: */
3155         /* 8.4.1 CHANNEL ACTIVATION 33*/
3156         case RSL_MSG_CHAN_ACTIV:
3157                 /* Channel number                       9.3.1   M TV 2                  */
3158                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3159                 /* Activation Type                      9.3.3   M TV 2                  */
3160                 offset = dissect_rsl_ie_act_type(tvb, pinfo, tree, offset, TRUE);
3161                 /* Channel Mode                         9.3.6   M TLV 8-9               */
3162                 offset = dissect_rsl_ie_ch_mode(tvb, pinfo, tree, offset, TRUE);
3163                 /* Channel Identification       9.3.5   O 7) TLV 8              */
3164                 if(tvb_length_remaining(tvb,offset) > 0)
3165                         offset = dissect_rsl_ie_ch_id(tvb, pinfo, tree, offset, FALSE);
3166                 /* Encryption information       9.3.7   O 1) TLV >=3    */
3167                 if(tvb_length_remaining(tvb,offset) > 0)
3168                         offset = dissect_rsl_ie_enc_inf(tvb, pinfo, tree, offset, FALSE);
3169                 /* Handover Reference           9.3.9   C 2) TV 2               */
3170                 if(tvb_length_remaining(tvb,offset) > 0)
3171                         offset = dissect_rsl_ie_ho_ref(tvb, pinfo, tree, offset, FALSE);
3172                 /* BS Power                                     9.3.4   O 3) TV 2               */
3173                 if(tvb_length_remaining(tvb,offset) > 0)
3174                         offset = dissect_rsl_ie_bs_power(tvb, pinfo, tree, offset, FALSE); 
3175                 /* MS Power                                     9.3.13  O 3) TV 2               */
3176                 if(tvb_length_remaining(tvb,offset) > 0)
3177                         offset = dissect_rsl_ie_ms_pow(tvb, pinfo, tree, offset, FALSE);
3178                 /* Timing Advance                       9.3.24  C 3) 4) TV 2    */
3179                 if(tvb_length_remaining(tvb,offset) > 0)
3180                         offset = dissect_rsl_ie_timing_adv(tvb, pinfo, tree, offset, FALSE);
3181                 /* BS Power Parameters          9.3.32  O 5) TLV >=2    */
3182                 /* MS Power Parameters          9.3.31  O 5) TLV >=2    */
3183                 /* Physical Context                     9.3.16  O 6) TLV >=2    */
3184                 if(tvb_length_remaining(tvb,offset) > 0)
3185                         offset = dissect_rsl_ie_phy_ctx(tvb, pinfo, tree, offset, FALSE);
3186                 /* SACCH Information            9.3.29  O 8) TLV >=3    */
3187                 /* UIC                                          9.3.50  O 9) TLV 3              */
3188                 if(tvb_length_remaining(tvb,offset) > 0)
3189                         offset = dissect_rsl_ie_uic(tvb, pinfo, tree, offset, FALSE);
3190                 /* Main channel reference       9.3.51  O 10) TV 2              */
3191                 if(tvb_length_remaining(tvb,offset) > 0)
3192                         offset = dissect_rsl_ie_main_ch_ref(tvb, pinfo, tree, offset, FALSE);
3193                 /* MultiRate configuration      9.3.52  O 11) TLV >=4   */
3194                 if(tvb_length_remaining(tvb,offset) > 0)
3195                         offset = dissect_rsl_ie_multirate_conf(tvb, pinfo, tree, offset, FALSE);
3196                 /* MultiRate Control            9.3.53  O 12) TV 2              */
3197                 if(tvb_length_remaining(tvb,offset) > 0)
3198                         offset = dissect_rsl_ie_multirate_cntrl(tvb, pinfo, tree, offset, FALSE);
3199                         /* Supported Codec Types        9.3.54  O 12) TLV >=5   */
3200                 if(tvb_length_remaining(tvb,offset) > 0)
3201                         offset = dissect_rsl_ie_sup_codec_types(tvb, pinfo, tree, offset, FALSE);
3202                 /* TFO transparent container 9.3.59 O 12) TLV >=3       */
3203                 if(tvb_length_remaining(tvb,offset) > 0)
3204                         offset = dissect_rsl_ie_tfo_transp_cont(tvb, pinfo, tree, offset, FALSE);
3205                 break;
3206
3207         /* 8.4.2 CHANNEL ACTIVATION ACKNOWLEDGE 34*/
3208         case RSL_MSG_CHAN_ACTIV_ACK:
3209                 /* Channel number                       9.3.1   M TV 2                  */
3210                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3211                 /* Frame number                         9.3.8   M TV 3                  */
3212                 offset = dissect_rsl_ie_frame_no(tvb, pinfo, tree, offset, TRUE);
3213                 break;
3214         case RSL_MSG_CHAN_ACTIV_N_ACK:
3215         /* 8.4.3 CHANNEL ACTIVATION NEGATIVE ACKNOWLEDGE */
3216                 /* Channel number                       9.3.1   M TV 2                  */
3217                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3218                 /* Cause                                        9.3.26  M TLV >=3               */
3219                 offset = dissect_rsl_ie_cause(tvb, pinfo, tree, offset, TRUE);
3220                 break;
3221         /* 8.4.4 CONNECTION FAILURE INDICATION */
3222         case RSL_MSG_CONN_FAIL:
3223                 /* Channel number                       9.3.1   M TV 2                  */
3224                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3225                 /* Cause                                        9.3.26  M TLV >=3               */
3226                 offset = dissect_rsl_ie_cause(tvb, pinfo, tree, offset, TRUE);
3227                 break;
3228         /* 8.4.5 DEACTIVATE SACCH */
3229         case RSL_MSG_DEACTIVATE_SACCH:
3230                 /* Channel number                       9.3.1   M TV 2                  */
3231                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3232                 break;
3233         /* 8.4.6 ENCRYPTION COMMAND */
3234         case RSL_MSG_ENCR_CMD:                  /*      38       8.4.6 */
3235                 /* Channel number                       9.3.1   M TV 2                  */
3236                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3237                 /* Encryption information       9.3.7   M TLV >=3               */
3238                 offset = dissect_rsl_ie_enc_inf(tvb, pinfo, tree, offset, TRUE);
3239                 /* Link Identifier                      9.3.2   M TV 2                  */
3240                 offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset, TRUE);
3241                 /* L3 Info (CIPH MOD CMD)       9.3.11  M TLV 6                 */
3242                 offset = dissect_rsl_ie_L3_inf(tvb, pinfo, tree, offset, TRUE); 
3243                 break;
3244         /* 8.4.7 HANDOVER DETECTION */
3245         case RSL_MSG_HANDODET:                  /*      39       8.4.7 */
3246                 /* Channel number                       9.3.1   M TV 2                  */
3247                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3248                 /* Access Delay                         9.3.17 O 1) TV 2                */
3249                 if(tvb_length_remaining(tvb,offset) > 0)
3250                         offset = dissect_rsl_ie_access_delay(tvb, pinfo, tree, offset, FALSE);
3251                 break;
3252         /* 8.4.8 MEASUREMENT RESULT 40 */
3253         case RSL_MSG_MEAS_RES:
3254                 /* Channel number                       9.3.1   M TV 2                  */
3255                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3256                 /* Measurement result number 9.3.27 M TV 2                      */
3257                 offset = dissect_rsl_ie_meas_res_no(tvb, pinfo, tree, offset, TRUE);
3258                 /* Uplink Measurements          9.3.25  M TLV >=5               */
3259                 offset = dissect_rsl_ie_uplik_meas(tvb, pinfo, tree, offset, TRUE);
3260                 /* BS Power                                     9.3.4   M TV 2                  */
3261                 offset = dissect_rsl_ie_bs_power(tvb, pinfo, tree, offset, TRUE);
3262                 /* L1 Information                       9.3.10 O 1) TV 3                */
3263                 if(tvb_length_remaining(tvb,offset) > 0)
3264                         offset = dissect_rsl_ie_l1_inf(tvb, pinfo, tree, offset, FALSE);
3265                 /* L3 Info (MEAS REP, EXT MEAS REP or ENH MEAS REP) 9.3.11 O 1) TLV 21 */
3266                 if(tvb_length_remaining(tvb,offset) > 0)
3267                         offset = dissect_rsl_ie_L3_inf(tvb, pinfo, tree, offset, FALSE); 
3268                 /* MS Timing Offset                     9.3.37 O 2) TV 2                */
3269                 if(tvb_length_remaining(tvb,offset) > 0)
3270                         offset = dissect_rsl_ie_ms_timing_offset(tvb, pinfo, tree, offset, FALSE); 
3271                 break;
3272         /* 8.4.9 MODE MODIFY */
3273         case RSL_MSG_MODE_MODIFY_REQ:   /*      41      8.4.9 */
3274                 /* Channel number                       9.3.1 M TV 2 */
3275                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3276                 /* Channel Mode                         9.3.6 M TLV 8-9 */
3277                 offset = dissect_rsl_ie_ch_mode(tvb, pinfo, tree, offset, TRUE);
3278                 /* Encryption information       9.3.7 O 1) TLV >=3 */
3279                 if(tvb_length_remaining(tvb,offset) > 0)
3280                         offset = dissect_rsl_ie_enc_inf(tvb, pinfo, tree, offset, FALSE); 
3281                 /* Main channel reference       9.3.45 O 2) TV 2 */
3282                 if(tvb_length_remaining(tvb,offset) > 0)
3283                         offset = dissect_rsl_ie_main_ch_ref(tvb, pinfo, tree, offset, FALSE);
3284                 /* MultiRate configuration      9.3.52 O 3) TLV >=3 */
3285                 if(tvb_length_remaining(tvb,offset) > 0)
3286                         offset = dissect_rsl_ie_multirate_conf(tvb, pinfo, tree, offset, FALSE);
3287                 /* Multirate Control            9.3.53 O 4) TV 2 */
3288                 if(tvb_length_remaining(tvb,offset) > 0)
3289                         offset = dissect_rsl_ie_multirate_cntrl(tvb, pinfo, tree, offset, FALSE);
3290                 /* Supported Codec Types        9.3.54 O 4) TLV >=5 */
3291                 if(tvb_length_remaining(tvb,offset) > 0)
3292                         offset = dissect_rsl_ie_sup_codec_types(tvb, pinfo, tree, offset, FALSE);
3293                 /* TFO transparent container 9.3.59 O 4) TLV */
3294                 if(tvb_length_remaining(tvb,offset) > 0)
3295                         offset = dissect_rsl_ie_tfo_transp_cont(tvb, pinfo, tree, offset, FALSE);
3296                 break;
3297         /* 8.4.10 MODE MODIFY ACKNOWLEDGE */
3298         case RSL_MSG_MODE_MODIFY_ACK:   /*      42      8.4.10 */
3299                 /* Channel number                       9.3.1   M TV 2                  */
3300                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3301                 break;
3302         /* 8.4.11 MODE MODIFY NEGATIVE ACKNOWLEDGE */
3303         case RSL_MSG_MODE_MODIFY_NACK:  /*      43      8.4.11 */
3304                 /* Channel number                       9.3.1   M TV 2                  */
3305                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3306                 /* Cause                                        9.3.26  M TLV >=3               */
3307                 offset = dissect_rsl_ie_cause(tvb, pinfo, tree, offset, TRUE);
3308                 break;
3309         /* 8.4.12 PHYSICAL CONTEXT REQUEST */
3310         case RSL_MSG_PHY_CONTEXT_REQ:   /*      44      8.4.12 */
3311                 /* Channel number                       9.3.1   M TV 2                  */
3312                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3313                 break;
3314         /* 8.4.13 PHYSICAL CONTEXT CONFIRM */
3315         case RSL_MSG_PHY_CONTEXT_CONF:  /*      45      8.4.13 */
3316                 /* Channel number                       9.3.1   M TV 2 */
3317                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3318                 /* BS Power                                     9.3.4   M TV 2 */
3319                 offset = dissect_rsl_ie_bs_power(tvb, pinfo, tree, offset, TRUE);
3320                 /* MS Power                                     9.3.13  M TV 2 */
3321                 offset = dissect_rsl_ie_ms_pow(tvb, pinfo, tree, offset, TRUE);
3322                 /* Timing Advance                       9.3.24  M TV 2 */
3323                 offset = dissect_rsl_ie_timing_adv(tvb, pinfo, tree, offset, TRUE);
3324                 /* Physical Context                     9.3.16  O 1) TLV */
3325                 if(tvb_length_remaining(tvb,offset) > 0)
3326                         offset = dissect_rsl_ie_phy_ctx(tvb, pinfo, tree, offset, FALSE);
3327                 break;
3328         /* 8.4.14 RF CHANNEL RELEASE */
3329         case RSL_MSG_RF_CHAN_REL:               /*      46      8.4.14 */
3330                 /* Channel number                       9.3.1   M TV 2                  */
3331                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3332                 break;
3333         /* 8.4.15 MS POWER CONTROL */
3334         case RSL_MSG_MS_POWER_CONTROL:  /*      47      8.4.15 */
3335                 /* Channel number                       9.3.1   M TV 2 */
3336                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3337                 /* MS Power                                     9.3.13  M TV 2 */
3338                 if(tvb_length_remaining(tvb,offset) > 0)
3339                         offset = dissect_rsl_ie_ms_pow(tvb, pinfo, tree, offset, FALSE);
3340                 /* MS Power Parameters          9.3.31  O 1) TLV >=2 */
3341                 break;
3342         /* 8.4.16 BS POWER CONTROL */
3343         case RSL_MSG_BS_POWER_CONTROL:  /*      48      8.4.16 */
3344                 /* Channel number                       9.3.1 M TV 2 */
3345                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3346                 /* BS Power                                     9.3.4 M TV 2 */
3347                 offset = dissect_rsl_ie_bs_power(tvb, pinfo, tree, offset, TRUE);
3348                 /* BS Power Parameters          9.3.32 O 1) TLV >=2 */
3349                 break;
3350         /* 8.4.17 PREPROCESS CONFIGURE */
3351         case RSL_MSG_PREPROC_CONFIG:            /*      49      8.4.17 */
3352                 /* Channel number                       9.3.1   M TV 2 */
3353                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3354                 /* Preproc. Parameters          9.3.33  M TLV >=3 */
3355                 break;
3356         /* 8.4.18 PREPROCESSED MEASUREMENT RESULT */
3357         case RSL_MSG_PREPROC_MEAS_RES:  /*      50      8.4.18 */
3358                 /* Channel number                       9.3.1   M TV 2 */
3359                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3360                 /* Preproc. Measurements        9.3.34  M TLV >=2 */
3361                 break;
3362         /* 8.4.19 RF CHANNEL RELEASE ACKNOWLEDGE */
3363         case RSL_MSG_RF_CHAN_REL_ACK:           /*      51      8.4.19 */
3364                 /* Channel number                       9.3.1   M TV 2                  */
3365                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3366                 break;
3367         /* 8.4.20 SACCH INFO MODIFY */
3368         case RSL_MSG_SACCH_INFO_MODIFY: /*      52      8.4.20 */
3369                 /* Channel number                       9.3.1   M TV 2 */
3370                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3371                 /* System Info Type                     9.3.30  M TV 2 */
3372                 offset = dissect_rsl_ie_sys_info_type(tvb, pinfo, tree, offset, TRUE);
3373                 /* L3 Info                                      9.3.11  O 1) TLV 22 */
3374                 if(tvb_length_remaining(tvb,offset) > 0)
3375                         offset = dissect_rsl_ie_L3_inf(tvb, pinfo, tree, offset, FALSE);
3376                 /* Starting Time                        9.3.23  O 2) TV 3 */
3377                 if(tvb_length_remaining(tvb,offset) > 0)
3378                         offset = dissect_rsl_ie_staring_time(tvb, pinfo, tree, offset, FALSE);
3379                 break;
3380         /* 8.4.21 TALKER DETECTION */
3381         case RSL_MSG_TALKER_DET:                        /*      53      8.4.21 */
3382                 /* Channel number                       9.3.1   M TV 2 */
3383                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3384                 /* Access Delay                         9.3.17  O 1) TV 2 */
3385                 if(tvb_length_remaining(tvb,offset) > 0)
3386                                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3387                 break;
3388         /* 8.4.22 LISTENER DETECTION */
3389         case RSL_MSG_LISTENER_DET:              /*      54      8.4.22 */
3390                 /* Channel number                       9.3.1   M TV 2 */
3391                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3392                 /* Access Delay                         9.3.17  O 1) TV 2 */
3393                 if(tvb_length_remaining(tvb,offset) > 0)
3394                                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3395                 break;
3396         /* 8.4.23 REMOTE CODEC CONFIGURATION REPORT */
3397         case RSL_MSG_REMOTE_CODEC_CONF_REP:/*   55      8.4.23 */
3398                 /* Channel number                       9.3.1   M TV 2 */
3399                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3400                 /* Codec Configuration          9.3.55  M TLV >=3 */
3401                 offset = dissect_rsl_ie_codec_conf(tvb, pinfo, tree, offset, TRUE);
3402                 /* Supported Codec Types        9.3.54  M TLV >=5 */
3403                 if(tvb_length_remaining(tvb,offset) > 0)
3404                         offset = dissect_rsl_ie_sup_codec_types(tvb, pinfo, tree, offset, FALSE);
3405                 /* TFO transparent container 9.3.59 O 4) TLV >=3 */
3406                 if(tvb_length_remaining(tvb,offset) > 0)
3407                         offset = dissect_rsl_ie_tfo_transp_cont(tvb, pinfo, tree, offset, FALSE);
3408                 break;
3409         /* 8.4.24 ROUND TRIP DELAY REPORT */
3410         case RSL_MSG_R_T_D_REP:                 /*      56      8.4.24 */
3411                 /* Channel number                       9.3.1   M TV 2 */
3412                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3413                 /* Round Trip Delay                     9.3.56  M TV 2 */
3414                 offset = dissect_rsl_ie_rtd(tvb, pinfo, tree, offset, TRUE);
3415                 break;
3416         /* 8.4.25 PRE-HANDOVER NOTIFICATION */
3417         case RSL_MSG_PRE_HANDO_NOTIF:           /*      57      8.4.25 */
3418                 /* Channel number                       9.3.1   M TV 2 */
3419                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3420                 /* MultiRateControl                     9.3.53  M TV 2 */
3421                 offset = dissect_rsl_ie_multirate_cntrl(tvb, pinfo, tree, offset, TRUE);
3422                 /* Codec Configuration          9.3.55  M TLV >=3 */
3423                 offset = dissect_rsl_ie_codec_conf(tvb, pinfo, tree, offset, TRUE);
3424                 /* TFO transparent container 9.3.59 O 4) TLV >=3 */
3425                 if(tvb_length_remaining(tvb,offset) > 0)
3426                         offset = dissect_rsl_ie_tfo_transp_cont(tvb, pinfo, tree, offset, FALSE);
3427                 break;
3428         /* 8.4.26 MULTIRATE CODEC MODIFICATION REQUEST */
3429         case RSL_MSG_MR_CODEC_MOD_REQ:  /*      58      8.4.26 */
3430                 /* Channel number                       9.3.1   M TV 2 */
3431                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3432                 /* MultiRate Configuration      9.3.52  O 1) TLV >=4 */
3433                 if(tvb_length_remaining(tvb,offset) > 0)
3434                         offset = dissect_rsl_ie_multirate_conf(tvb, pinfo, tree, offset, FALSE);
3435                 break;
3436         /*  8.4.27 MULTIRATE CODEC MODIFICATION ACKNOWLEDGE */
3437         case RSL_MSG_MR_CODEC_MOD_ACK:  /*      59      8.4.27 */
3438                 /* Channel number                       9.3.1   M TV 2 */
3439                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3440                 /* MultiRate Configuration      9.3.52  O 1) TLV >=4 */
3441                 if(tvb_length_remaining(tvb,offset) > 0)
3442                         offset = dissect_rsl_ie_multirate_conf(tvb, pinfo, tree, offset, FALSE);
3443                 break;
3444         /* 8.4.28 MULTIRATE CODEC MODIFICATION NEGATIVE ACKNOWLEDGE */
3445         case RSL_MSG_MR_CODEC_MOD_NACK: /*      60      8.4.28 */
3446                 /* Channel number                       9.3.1   M TV 2                  */
3447                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3448                 /* Cause                                        9.3.26  M TLV >=3               */
3449                 offset = dissect_rsl_ie_cause(tvb, pinfo, tree, offset, TRUE);
3450                 break;
3451         /* 8.4.29 MULTIRATE CODEC MODIFICATION PERFORMED */
3452         case RSL_MSG_MR_CODEC_MOD_PER:  /*      61      8.4.29 */
3453                 /* Channel number                       9.3.1   M TV 2 */
3454                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3455                 /* MultiRate Configuration      9.3.52  M TLV >=4 */
3456                 offset = dissect_rsl_ie_multirate_conf(tvb, pinfo, tree, offset, TRUE);
3457                 break;
3458         /* 8.4.30 TFO REPORT */
3459         case RSL_MSG_TFO_REP:                           /*      62      8.4.30 */
3460                 /* Channel number                       9.3.1   M TV 2 */
3461                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3462                 /* TFO Status                           9.3.57  M TV 1 */
3463                 offset = dissect_rsl_ie_tfo_status(tvb, pinfo, tree, offset, TRUE);
3464                 break;
3465         /* 8.4.31 TFO MODIFICATION REQUEST */
3466         case RSL_MSG_TFO_MOD_REQ:                       /*      63      8.4.31 */
3467                 /* Channel number                       9.3.1 M TV 2 */
3468                 offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset, TRUE);
3469                 /* MultiRateControl                     9.3.53 M TV 2 */
3470                 offset = dissect_rsl_ie_multirate_cntrl(tvb, pinfo, tree, offset, TRUE);
3471                 /* Supported Codec Type         9.3.54 O 1) TLV >=5 */
3472                 if(tvb_length_remaining(tvb,offset) > 0)
3473                         offset = dissect_rsl_ie_sup_codec_types(tvb, pinfo, tree, offset, FALSE);                       
3474                 /* TFO transparent container 9.3.59 O 4) TLV >=3 */
3475                 if(tvb_length_remaining(tvb,offset) > 0)
3476                         offset = dissect_rsl_ie_tfo_transp_cont(tvb, pinfo, tree, offset, FALSE);
3477                 break;
3478         /*      0 1 - - - - - - Location Services messages: */
3479         /* 8.7.1 LOCATION INFORMATION */
3480         case RSL_MSG_LOC_INF:                           /*      65      8.7.1 */
3481                 /* LLP APDU 9.3.58 M LV 2-N */
3482                 offset = dissect_rsl_ie_llp_apdu(tvb, pinfo, tree, offset, TRUE);
3483                 break;
3484         default:
3485                 break;
3486         }
3487
3488         return offset;
3489
3490 }
3491 static void
3492 dissect_rsl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3493 {
3494         proto_item *ti;
3495         proto_tree *rsl_tree;
3496         guint8  msg_type;
3497
3498
3499         int offset = 0;
3500
3501         col_set_str(pinfo->cinfo, COL_PROTOCOL, "RSL");
3502         if (check_col(pinfo->cinfo, COL_INFO))
3503                 col_clear(pinfo->cinfo, COL_INFO);
3504
3505         msg_type = tvb_get_guint8(tvb,offset+1)&0x7f;
3506
3507         if (check_col(pinfo->cinfo, COL_INFO)){
3508                 col_append_fstr(pinfo->cinfo, COL_INFO, "%s ",val_to_str(msg_type, rsl_msg_type_vals,"unknown %u"));
3509         }
3510
3511         top_tree = tree;
3512         if (tree) {
3513                 ti = proto_tree_add_item(tree, proto_rsl, tvb, 0, -1, FALSE);
3514                 rsl_tree = proto_item_add_subtree(ti, ett_rsl);
3515
3516                 /* 9.1 Message discriminator */
3517                 proto_tree_add_item(rsl_tree, hf_rsl_msg_dsc, tvb, offset, 1, FALSE);
3518                 proto_tree_add_item(rsl_tree, hf_rsl_T_bit, tvb, offset, 1, FALSE);
3519                 offset++;
3520
3521                 offset = dissct_rsl_msg(tvb, pinfo, rsl_tree, offset);
3522
3523         }
3524
3525 }
3526
3527 void
3528 proto_reg_handoff_rsl(void)
3529 {
3530         dissector_handle_t rsl_handle;
3531
3532         rsl_handle = create_dissector_handle(dissect_rsl, proto_rsl);
3533         dissector_add("lapd.gsm.sapi", LAPD_GSM_SAPI_RA_SIG_PROC, rsl_handle);
3534
3535         gsm_a_ccch_handle = find_dissector("gsm_a_ccch");
3536         gsm_a_dtap_handle = find_dissector("gsm_a_dtap");
3537 }
3538
3539 /* Register the protocol with Wireshark */
3540 void proto_register_rsl(void)
3541 {
3542
3543         /* Setup list of header fields */
3544         static hf_register_info hf[] = {
3545                 { &hf_rsl_msg_dsc,
3546                         { "Message discriminator",           "rsl.msg_dsc",
3547                         FT_UINT8, BASE_DEC, VALS(rsl_msg_disc_vals), 0xfe,
3548                         NULL, HFILL }
3549                 },
3550                 { &hf_rsl_T_bit,
3551                         { "T bit",           "rsl.T_bit",
3552                         FT_BOOLEAN, 8, TFS(&rsl_t_bit_vals), 0x01,
3553                         NULL, HFILL }
3554                 },
3555                 { &hf_rsl_msg_type,
3556                         { "Message type",           "rsl.msg_type",
3557                         FT_UINT8, BASE_HEX_DEC, VALS(rsl_msg_type_vals), 0x7f,
3558                         NULL, HFILL }
3559                 },
3560                 { &hf_rsl_ie_id,
3561                         { "Element identifier",           "rsl.ie_id",
3562                         FT_UINT8, BASE_HEX_DEC, VALS(rsl_ie_type_vals), 0x0,
3563                         NULL, HFILL }
3564                 },
3565                 { &hf_rsl_ie_length,
3566                         { "Length",           "rsl.ie_length",
3567                         FT_UINT16, BASE_DEC, NULL, 0x0,
3568                         NULL, HFILL }
3569                 },
3570                 { &hf_rsl_ch_no_Cbits,
3571                         { "C-bits",           "rsl.ch_no_Cbits",
3572                         FT_UINT8, BASE_DEC, VALS(rsl_ch_no_Cbits_vals), 0xf8,
3573                         NULL, HFILL }
3574                 },
3575                 { &hf_rsl_ch_no_TN,
3576                         { "Time slot number (TN)",  "rsl.ch_no_TN",
3577                         FT_UINT8, BASE_DEC, NULL, 0x07,
3578                         NULL, HFILL }
3579                 },
3580                 { &hf_rsl_rtd,
3581                         { "Round Trip Delay (RTD)",  "rsl.rtd",
3582                         FT_UINT8, BASE_DEC, NULL, 0xfe,
3583                         NULL, HFILL }
3584                 },
3585                 { &hf_rsl_delay_ind,
3586                         { "Delay IND",  "rsl.delay_ind",
3587                         FT_UINT8, BASE_DEC, rsl_delay_ind_vals, 0x01,
3588                         NULL, HFILL }
3589                 },
3590                 { &hf_rsl_tfo,
3591                         { "TFO",           "rsl.tfo",
3592                         FT_BOOLEAN, 8, TFS(&rsl_tfo_vals), 0x01,
3593                         NULL, HFILL }
3594                 },
3595                 { &hf_rsl_req_ref_ra,
3596                         { "Random Access Information (RA)", "rsl.req_ref_ra",
3597                         FT_UINT8, BASE_DEC, NULL, 0x0,
3598                         NULL, HFILL }
3599                 },
3600                 { &hf_rsl_req_ref_T1prim,
3601                         { "T1'",           "rsl.req_ref_T1prim",
3602                         FT_UINT8, BASE_DEC, NULL, 0xf8,
3603                         NULL, HFILL }
3604                 },
3605                 { &hf_rsl_req_ref_T3,
3606                         { "T3",           "rsl.req_ref_T3",
3607                         FT_UINT16, BASE_DEC, NULL, 0x07e0,
3608                         NULL, HFILL }
3609                 },
3610                 { &hf_rsl_req_ref_T2,
3611                         { "T2",           "rsl.req_ref_T2",
3612                         FT_UINT8, BASE_DEC, NULL, 0x1f,
3613                         NULL, HFILL }
3614                 },
3615                 { &hf_rsl_timing_adv,
3616                         { "Timing Advance",           "rsl.timing_adv",
3617                         FT_UINT8, BASE_DEC, NULL, 0x0,
3618                         NULL, HFILL }
3619                 },
3620                 { &hf_rsl_ho_ref,
3621                         { "Hand-over reference",           "rsl.ho_ref",
3622                         FT_UINT8, BASE_DEC, NULL, 0x0,
3623                         NULL, HFILL }
3624                 },
3625                 { &hf_rsl_ms_power_lev,
3626                         { "MS power level",           "rsl.ms_power_lev",
3627                         FT_UINT8, BASE_DEC, NULL, 0xf8,
3628                         NULL, HFILL }
3629                 },
3630                 { &hf_rsl_ms_fpc,
3631                         { "FPC/EPC",           "rsl.ms_fpc",
3632                         FT_BOOLEAN, 8, TFS(&rsl_ms_fpc_epc_mode_vals), 0x04,
3633                         NULL, HFILL }
3634                 },
3635                 { &hf_rsl_act_timing_adv,
3636                         { "Actual Timing Advance",           "rsl.act_timing_adv",
3637                         FT_UINT8, BASE_DEC, NULL, 0x0,
3638                         NULL, HFILL }
3639                 },
3640                 { &hf_rsl_power_lev,
3641                         { "Power level",           "rsl.power_lev",
3642                         FT_UINT8, BASE_DEC, NULL, 0x1f,
3643                         NULL, HFILL }
3644                 },
3645
3646                 { &hf_rsl_dtxd,
3647                         { "DTXd",           "rsl.dtxd",
3648                         FT_BOOLEAN, 8, TFS(&rsl_dtxd_vals), 0x40,
3649                         NULL, HFILL }
3650                 },
3651                 { &hf_rsl_rxlev_full_up,
3652                         { "RXLEV.FULL.up",           "rsl.rxlev_full_up",
3653                         FT_UINT8, BASE_DEC, NULL, 0x3f,
3654                         NULL, HFILL }
3655                 },
3656                 { &hf_rsl_rxlev_sub_up,
3657                         { "RXLEV.SUB.up",           "rsl.rxlev_sub_up",
3658                         FT_UINT8, BASE_DEC, NULL, 0x3f,
3659                         NULL, HFILL }
3660                 },
3661                 { &hf_rsl_rxqual_full_up,
3662                         { "RXQUAL.FULL.up",           "rsl.rxqual_full_up",
3663                         FT_UINT8, BASE_DEC, NULL, 0x38,
3664                         NULL, HFILL }
3665                 },
3666                 { &hf_rsl_rxqual_sub_up,
3667                         { "RXQUAL.SUB.up",           "rsl.rxqual_sub_up",
3668                         FT_UINT8, BASE_DEC, NULL, 0x07,
3669                         NULL, HFILL }
3670                 },
3671                 { &hf_rsl_acc_delay,
3672                         { "Access Delay",           "rsl.acc_del",
3673                         FT_UINT8, BASE_DEC, NULL, 0x0,
3674                         NULL, HFILL }
3675                 },
3676                 { &hf_rsl_rach_slot_cnt,
3677                         { "RACH Slot Count",           "rsl.rach_slot_cnt",
3678                         FT_UINT16, BASE_DEC, NULL, 0x0,
3679                         NULL, HFILL }
3680                 },
3681                 { &hf_rsl_rach_busy_cnt,
3682                         { "RACH Busy Count",           "rsl.rach_busy_cnt",
3683                         FT_UINT16, BASE_DEC, NULL, 0x0,
3684                         NULL, HFILL }
3685                 },
3686                 { &hf_rsl_rach_acc_cnt,
3687                         { "RACH Access Count",           "rsl.rach_acc_cnt",
3688                         FT_UINT16, BASE_DEC, NULL, 0x0,
3689                         NULL, HFILL }
3690                 },
3691                 { &hf_rsl_phy_ctx,
3692                         { "Physical Context",           "rsl.phy_ctx",
3693                         FT_BYTES, BASE_NONE, NULL, 0x0,
3694                         NULL, HFILL }
3695                 },
3696                 { &hf_rsl_na,
3697                         { "Not applicable (NA)",           "rsl.na",
3698                         FT_BOOLEAN, 8, TFS(&rsl_na_vals), 0x20,
3699                         NULL, HFILL }
3700                 },
3701                 { &hf_rsl_ch_type,
3702                         { "channel type",           "rsl.ch_type",
3703                         FT_UINT8, BASE_DEC, VALS(rsl_ch_type_vals), 0xc0,
3704                         NULL, HFILL }
3705                 },
3706                 { &hf_rsl_prio,
3707                         { "Priority",           "rsl.prio",
3708                         FT_UINT8, BASE_DEC, VALS(rsl_prio_vals), 0x18,
3709                         NULL, HFILL }
3710                 },
3711                 { &hf_rsl_sapi,
3712                         { "SAPI",           "rsl.sapi",
3713                         FT_UINT8, BASE_DEC, NULL, 0x07,
3714                         NULL, HFILL }
3715                 },
3716                 { &hf_rsl_rbit,
3717                         { "R",           "rsl.rbit",
3718                         FT_BOOLEAN, 8, TFS(&rsl_rbit_vals), 0x80,
3719                         NULL, HFILL }
3720                 },
3721                 { &hf_rsl_a3a2,
3722                         { "A3A2",           "rsl.a3a2",
3723                         FT_UINT8, BASE_DEC, VALS(rsl_a3a2_vals), 0x06,
3724                         NULL, HFILL }
3725                 },
3726                 { &hf_rsl_a1_0,
3727                         { "A1",           "rsl.a1_0",
3728                         FT_BOOLEAN, 8, TFS(&rsl_a1_0_vals), 0x01,
3729                         NULL, HFILL }
3730                 },
3731                 { &hf_rsl_a1_1,
3732                         { "A1",           "rsl.a1_1",
3733                         FT_BOOLEAN, 8, TFS(&rsl_a1_1_vals), 0x01,
3734                         NULL, HFILL }
3735                 },
3736                 { &hf_rsl_a1_2,
3737                         { "A1",           "rsl.a2_0",
3738                         FT_BOOLEAN, 8, TFS(&rsl_a1_2_vals), 0x01,
3739                         NULL, HFILL }
3740                 },
3741                 { &hf_rsl_epc_mode,
3742                         { "EPC mode", "rsl.epc_mode",
3743                         FT_BOOLEAN, 8, TFS(&rsl_epc_mode_vals), 0x20,
3744                         NULL, HFILL }
3745                 },
3746                 { &hf_rsl_bs_fpc_epc_mode,
3747                         { "FPC-EPC mode", "rsl.fpc_epc_mode",
3748                         FT_BOOLEAN, 8, TFS(&rsl_fpc_epc_mode_vals), 0x10,
3749                         NULL, HFILL }
3750                 },
3751                 { &hf_rsl_bs_power,
3752                         { "Power Level",           "rsl.bs_power",
3753                         FT_UINT8, BASE_DEC, VALS(rsl_rlm_bs_power_vals), 0x0f,
3754                         NULL, HFILL }
3755                 },
3756                 { &hf_rsl_cm_dtxd,
3757                         { "DTXd", "rsl.cm_dtxd",
3758                         FT_BOOLEAN, 8, TFS(&rsl_dtx_vals), 0x02,
3759                         NULL, HFILL }
3760                 },
3761                 { &hf_rsl_cm_dtxu,
3762                         { "DTXu", "rsl.cm_dtxu",
3763                         FT_BOOLEAN, 8, TFS(&rsl_dtx_vals), 0x01,
3764                         NULL, HFILL }
3765                 },
3766                 { &hf_rsl_speech_or_data,
3767                         { "Speech or data indicator",           "rsl.speech_or_data",
3768                         FT_UINT8, BASE_DEC, VALS(rsl_speech_or_data_vals), 0x0,
3769                         NULL, HFILL }
3770                 },
3771                 { &hf_rsl_ch_rate_and_type,
3772                         { "Channel rate and type",           "rsl.speech_or_data",
3773                         FT_UINT8, BASE_DEC, VALS(rsl_ch_rate_and_type_vals), 0x0,
3774                         NULL, HFILL }
3775                 },
3776                 { &hf_rsl_speech_coding_alg,
3777                         { "Speech coding algorithm",           "rsl.speech_coding_alg",
3778                         FT_UINT8, BASE_DEC, VALS(rsl_speech_coding_alg_vals), 0x0,
3779                         NULL, HFILL }
3780                 },
3781                 { &hf_rsl_t_nt_bit,
3782                         { "Transparent indication", "rsl.t_nt_bit",
3783                         FT_BOOLEAN, 8, TFS(&t_nt_bit_vals), 0x40,
3784                         NULL, HFILL }
3785                 },
3786                 { &hf_rsl_ra_if_data_rte,
3787                         { "Radio interface data rate",           "rsl.ra_if_data_rte",
3788                         FT_UINT8, BASE_DEC, VALS(rsl_ra_if_data_rte_vals), 0x3f,
3789                         NULL, HFILL }
3790                 },
3791                 { &hf_rsl_data_rte,
3792                         { "Data rate",           "rsl.data_rte",
3793                         FT_UINT8, BASE_DEC, VALS(rsl_ra_if_data_rte_vals), 0x3f,
3794                         NULL, HFILL }
3795                 },
3796                 { &hf_rsl_alg_id,
3797                         { "Algorithm Identifier",           "rsl.alg_id",
3798                         FT_UINT8, BASE_DEC, VALS(rsl_algorithm_id_vals), 0x0,
3799                         NULL, HFILL }
3800                 },
3801                 { &hf_rsl_key,
3802                         { "KEY",           "rsl.key",
3803                         FT_BYTES, BASE_NONE, NULL, 0x0,
3804                         NULL, HFILL }
3805                 },
3806                 { &hf_rsl_cause,
3807                         { "Cause",           "rsl.cause",
3808                         FT_UINT8, BASE_DEC, VALS(rsl_rlm_cause_vals), 0x7f,
3809                         NULL, HFILL }
3810                 },
3811                 { &hf_rsl_rel_mode,
3812                         { "Release Mode",           "rsl.rel_mode",
3813                         FT_UINT8, BASE_DEC, VALS(rel_mode_vals), 0x01,
3814                         NULL, HFILL }
3815                 },
3816                 { &hf_rsl_interf_band,
3817                         { "Interf Band",           "rsl.interf_band",
3818                         FT_UINT8, BASE_DEC, NULL, 0xe0,
3819                         NULL, HFILL }
3820                 },
3821                 { &hf_rsl_meas_res_no,
3822                         { "Measurement result number",           "rsl.meas_res_no",
3823                         FT_UINT8, BASE_DEC, NULL, 0x0,
3824                         NULL, HFILL }
3825                 },
3826                 { &hf_rsl_extension_bit,
3827                         { "Extension", "rsl.extension_bit",
3828                         FT_BOOLEAN, 8, TFS(&rsl_extension_bit_value), 0x80,
3829                         NULL, HFILL }},
3830                 { &hf_rsl_class,
3831                         { "Class",           "rsl.class",
3832                         FT_UINT8, BASE_DEC, VALS(rsl_class_vals), 0x70,
3833                         NULL, HFILL }
3834                 },
3835                 { &hf_rsl_paging_grp,
3836                         { "Paging Group",           "rsl.paging_grp",
3837                         FT_UINT8, BASE_DEC, NULL, 0x0,
3838                         NULL, HFILL }
3839                 },
3840                 { &hf_rsl_paging_load,
3841                         { "Paging Buffer Space",           "rsl.paging_load",
3842                         FT_UINT16, BASE_DEC, NULL, 0x0,
3843                         NULL, HFILL }
3844                 },
3845                 { &hf_rsl_sys_info_type,
3846                         { "System Info Type",           "rsl.sys_info_type",
3847                         FT_UINT8, BASE_DEC, VALS(rsl_sys_info_type_vals), 0x0,
3848                         NULL, HFILL }
3849                 },
3850                 { &hf_rsl_timing_offset,
3851                         { "Timing Offset",           "rsl.timing_offset",
3852                         FT_UINT8, BASE_DEC, NULL, 0x0,
3853                         NULL, HFILL }
3854                 },
3855                 { &hf_rsl_ch_needed,
3856                         { "Channel Needed",           "rsl.ch_needed",
3857                         FT_UINT8, BASE_DEC, VALS(rsl_ch_needed_vals), 0x03,
3858                         NULL, HFILL }
3859                 },
3860                 { &hf_rsl_cbch_load_type,
3861                         { "CBCH Load Type", "rsl.cbch_load_type",
3862                         FT_BOOLEAN, 8, TFS(&rsl_cbch_load_type_vals), 0x80,
3863                         NULL, HFILL }
3864                 },
3865                 { &hf_rsl_msg_slt_cnt,
3866                         { "Message Slot Count", "rsl.sg_slt_cnt",
3867                         FT_UINT8, BASE_DEC, NULL, 0x0f,
3868                         NULL, HFILL }
3869                 },
3870                 { &hf_rsl_ch_ind,
3871                         { "Channel Ind",           "rsl.ch_ind",
3872                         FT_UINT8, BASE_DEC, VALS(rsl_ch_ind_vals), 0x0f,
3873                         NULL, HFILL }
3874                 },
3875                 { &hf_rsl_command,
3876                         { "Command",           "rsl.cmd",
3877                         FT_UINT16, BASE_DEC, NULL, 0x0,
3878                         NULL, HFILL }
3879                 },
3880                 { &hf_rsl_emlpp_prio,
3881                         { "eMLPP Priority",           "rsl.emlpp_prio",
3882                         FT_UINT8, BASE_DEC, VALS(rsl_emlpp_prio_vals), 0x03,
3883                         NULL, HFILL }
3884                 },
3885         };
3886         static gint *ett[] = {
3887                 &ett_rsl,
3888                 &ett_ie_link_id,
3889                 &ett_ie_act_type,
3890                 &ett_ie_bs_power,
3891                 &ett_ie_ch_id,
3892                 &ett_ie_ch_mode,
3893                 &ett_ie_enc_inf,
3894                 &ett_ie_ch_no,
3895                 &ett_ie_frame_no,
3896                 &ett_ie_ho_ref,
3897                 &ett_ie_l1_inf,
3898                 &ett_ie_L3_inf,
3899                 &ett_ie_ms_id,
3900                 &ett_ie_ms_pow,
3901                 &ett_ie_phy_ctx,
3902                 &ett_ie_paging_grp,
3903                 &ett_ie_paging_load,
3904                 &ett_ie_access_delay,
3905                 &ett_ie_rach_load,
3906                 &ett_ie_req_ref,
3907                 &ett_ie_rel_mode,
3908                 &ett_ie_resource_inf,
3909                 &ett_ie_rlm_cause,
3910                 &ett_ie_staring_time,
3911                 &ett_ie_timing_adv,
3912                 &ett_ie_uplink_meas,
3913                 &ett_ie_full_imm_ass_inf,
3914                 &ett_ie_smscb_inf,
3915                 &ett_ie_ms_timing_offset,
3916                 &ett_ie_err_msg,
3917                 &ett_ie_full_bcch_inf,
3918                 &ett_ie_ch_needed,
3919                 &ett_ie_cb_cmd_type,
3920                 &ett_ie_smscb_mess,
3921                 &ett_ie_cbch_load_inf,
3922                 &ett_ie_smscb_ch_ind,
3923                 &ett_ie_grp_call_ref,
3924                 &ett_ie_ch_desc,
3925                 &ett_ie_nch_drx,
3926                 &ett_ie_cmd_ind,
3927                 &ett_ie_emlpp_prio,
3928                 &ett_ie_uic,
3929                 &ett_ie_main_ch_ref,
3930                 &ett_ie_multirate_conf,
3931                 &ett_ie_multirate_cntrl,
3932                 &ett_ie_sup_codec_types,
3933                 &ett_ie_codec_conf,
3934                 &ett_ie_rtd,
3935                 &ett_ie_tfo_status,
3936                 &ett_ie_llp_apdu,
3937                 &ett_ie_tfo_transp_cont,
3938                 &ett_ie_cause,
3939                 &ett_ie_meas_res_no,
3940                 &ett_ie_message_id,
3941                 &ett_ie_sys_info_type,
3942         };
3943
3944         /* Register the protocol name and description */
3945         proto_rsl = proto_register_protocol("Radio Signalling Link (RSL)",
3946                                             "RSL", "rsl");
3947
3948         proto_register_field_array(proto_rsl, hf, array_length(hf));
3949         proto_register_subtree_array(ett, array_length(ett));
3950
3951         register_dissector("gsm_abis_rsl", dissect_rsl, proto_rsl);
3952
3953 }
3954