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