From Pascal Quantin:
[obnox/wireshark/wip.git] / epan / dissectors / packet-gsm_a_rr.c
1 /* packet-gsm_a_rr.c
2  * Routines for GSM A Interface (actually A-bis really) RR dissection - A.K.A. GSM layer 3 Radio Resource Protocol
3  *
4  * Copyright 2003, Michael Lum <mlum [AT] telostech.com>
5  * In association with Telos Technology Inc.
6  *
7  * Added Dissection of Radio Resource Management Information Elements
8  * and othere enhancements and fixes.
9  * Copyright 2005 - 2006, Anders Broman [AT] ericsson.com
10  *
11  * Title                3GPP                    Other
12  *
13  *   Reference [3]
14  *   Mobile radio interface Layer 3 specification;
15  *   Core network protocols;
16  *   Stage 3
17  *   (3GPP TS 24.008 version 4.7.0 Release 4)
18  *   (ETSI TS 124 008 V6.8.0 (2005-03))
19  *
20  *   Reference [4]
21  *   Mobile radio interface layer 3 specification;
22  *   Radio Resource Control Protocol
23  *   (GSM 04.18 version 8.4.1 Release 1999)
24  *   (3GPP TS 04.18 version 8.26.0 Release 1999)
25  *
26  * $Id$
27  *
28  * Wireshark - Network traffic analyzer
29  * By Gerald Combs <gerald@wireshark.org>
30  * Copyright 1998 Gerald Combs
31  *
32  * This program is free software; you can redistribute it and/or
33  * modify it under the terms of the GNU General Public License
34  * as published by the Free Software Foundation; either version 2
35  * of the License, or (at your option) any later version.
36  *
37  * This program is distributed in the hope that it will be useful,
38  * but WITHOUT ANY WARRANTY; without even the implied warranty of
39  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
40  * GNU General Public License for more details.
41  *
42  * You should have received a copy of the GNU General Public License
43  * along with this program; if not, write to the Free Software
44  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
45  */
46
47 #ifdef HAVE_CONFIG_H
48 # include "config.h"
49 #endif
50
51 #include <stdio.h>
52 #include <stdlib.h>
53
54 #include <string.h>
55
56 #include <epan/packet.h>
57 #include <epan/prefs.h>
58 #include <epan/tap.h>
59 #include <epan/asn1.h>
60
61 #include "packet-bssap.h"
62 #include "packet-sccp.h"
63 #include "packet-ber.h"
64 #include "packet-q931.h"
65 #include "packet-gsm_a_common.h"
66 #include "packet-ipv6.h"
67 #include "packet-e212.h"
68 #include "packet-ppp.h"
69
70 static dissector_handle_t rrc_irat_ho_info_handle;
71 static dissector_handle_t rrc_irat_ho_to_utran_cmd_handle;
72
73 #define PADDING_BYTE 0x2B
74
75 gboolean gsm_a_rr_is_bit_high(tvbuff_t *tvb, gint bit_offset)
76 {
77    guint8 bit_mask = 0x80 >> (bit_offset & 0x07);
78    if ((tvb_get_guint8(tvb,bit_offset >> 3) & bit_mask) != (PADDING_BYTE & bit_mask))
79       return TRUE;
80    return FALSE;
81 }
82
83 /* PROTOTYPES/FORWARDS */
84
85 const value_string gsm_a_dtap_msg_rr_strings[] = {
86         { 0x3c, "Reserved" },
87         { 0x3b, "Additional Assignment" },
88         { 0x3f, "Immediate Assignment" },
89         { 0x39, "Immediate Assignment Extended" },
90         { 0x3a, "Immediate Assignment Reject" },
91
92         { 0x48, "DTM Assignment Failure" },
93         { 0x49, "DTM Reject" },
94         { 0x4a, "DTM Request" },
95         { 0x4b, "Main DCCH Assignment Command" },
96         { 0x4c, "Packet Assignment Command" },
97
98         { 0x35, "Ciphering Mode Command" },
99         { 0x32, "Ciphering Mode Complete" },
100
101         { 0x30, "Configuration Change Command" },
102         { 0x31, "Configuration Change Ack." },
103         { 0x33, "Configuration Change Reject" },
104
105         { 0x2e, "Assignment Command" },
106         { 0x29, "Assignment Complete" },
107         { 0x2f, "Assignment Failure" },
108         { 0x2b, "Handover Command" },
109         { 0x2c, "Handover Complete" },
110         { 0x28, "Handover Failure" },
111         { 0x2d, "Physical Information" },
112         { 0x4d, "DTM Assignment Command" },
113
114         { 0x08, "RR-cell Change Order" },
115         { 0x23, "PDCH Assignment Command" },
116
117         { 0x0d, "Channel Release" },
118         { 0x0a, "Partial Release" },
119         { 0x0f, "Partial Release Complete" },
120
121         { 0x21, "Paging Request Type 1" },
122         { 0x22, "Paging Request Type 2" },
123         { 0x24, "Paging Request Type 3" },
124         { 0x27, "Paging Response" },
125         { 0x20, "Notification/NCH" },
126         { 0x25, "Reserved" },
127         { 0x26, "Notification/Response" },
128
129         { 0x0b, "Reserved" },
130
131 /*      ETSI TS 101 503 V8.5.0 Seems to give Other def for this Messages???
132         { 0xc0, "Utran Classmark Change" }, CONFLICTS WITH Handover To UTRAN Command
133         { 0xc1, "UE RAB Preconfiguration" },
134         { 0xc2, "cdma2000 Classmark Change" },*/
135
136         /* ETSI TS 101 503 V8.5.0 */
137         { 0x60, "Utran Classmark Change" },
138         { 0x62, "cdma2000 Classmark Change" },
139         { 0x63, "Inter System to UTRAN Handover Command" },
140         { 0x64, "Inter System to cdma2000 Handover Command" },
141         { 0x18, "System Information Type 8" },
142         { 0x19, "System Information Type 1" },
143         { 0x1a, "System Information Type 2" },
144         { 0x1b, "System Information Type 3" },
145         { 0x1c, "System Information Type 4" },
146         { 0x1d, "System Information Type 5" },
147         { 0x1e, "System Information Type 6" },
148         { 0x1f, "System Information Type 7" },
149
150         { 0x02, "System Information Type 2bis" },
151         { 0x03, "System Information Type 2ter" },
152         { 0x07, "System Information Type 2quater" },
153         { 0x05, "System Information Type 5bis" },
154         { 0x06, "System Information Type 5ter" },
155         { 0x04, "System Information Type 9" },
156         { 0x00, "System Information Type 13" },
157
158         { 0x3d, "System Information Type 16" },
159         { 0x3e, "System Information Type 17" },
160
161         { 0x40, "System Information Type 18" },
162         { 0x41, "System Information Type 19" },
163         { 0x42, "System Information Type 20" },
164
165         { 0x10, "Channel Mode Modify" },
166         { 0x12, "RR Status" },
167         { 0x17, "Channel Mode Modify Acknowledge" },
168         { 0x14, "Frequency Redefinition" },
169         { 0x15, "Measurement Report" },
170         { 0x16, "Classmark Change" },
171         { 0x13, "Classmark Enquiry" },
172         { 0x36, "Extended Measurement Report" },
173         { 0x37, "Extended Measurement Order" },
174         { 0x34, "GPRS Suspension Request" },
175
176         { 0x09, "VGCS Uplink Grant" },
177         { 0x0e, "Uplink Release" },
178         { 0x0c, "Reserved" },
179         { 0x2a, "Uplink Busy" },
180         { 0x11, "Talker Indication" },
181
182         { 0xc0, "UTRAN Classmark Change/Handover To UTRAN Command" },   /* spec conflict */
183
184         { 0x38, "Application Information" },
185
186         { 0, NULL }
187 };
188
189 const value_string gsm_rr_elem_strings[] = {
190         /* Radio Resource Management Information Elements 10.5.2, most are from 10.5.1 */
191         { 0x00, "BA Range" },                                           /* [3]  10.5.2.1a       BA Range */
192         { 0x00, "Cell Channel Description" },           /* [3]  10.5.2.1b       */
193         { 0x00, "BA List Pref" },                                       /* [3]  10.5.2.1c       BA List Pref */
194         { 0x00, "UTRAN Frequency List" },                       /* [3]  10.5.2.1d       UTRAN Frequency List */
195         { 0x00, "Cell Selection Indicator after Release of all TCH and SDCCH" },                /* [3]  10.5.2.1e       Cell selection indicator after release of all TCH and SDCCH IE */
196         { 0x00, "Cell Description" },                           /* 10.5.2.2  */
197         { 0x00, "Cell Options (BCCH)" },                        /* [3]  10.5.2.3        Cell Options (BCCH)                     */
198         { 0x00, "Cell Options (SACCH)" },                       /* [3]  10.5.2.3a       Cell Options (SACCH)            */
199         { 0x00, "Cell Selection Parameters" },          /* [3]  10.5.2.4        Cell Selection Parameters       */
200 /* [3]  10.5.2.4a       (void) */
201         { 0x00, "Channel Description" },                        /* 10.5.2.5      */
202         { 0x00, "Channel Description 2" },                      /* 10.5.2.5a */
203         { 0x00, "Channel Description 3" },                      /* 10.5.2.5c */
204         { 0x00, "Channel Mode" },                                       /* [3]  10.5.2.6 */
205         { 0x00, "Channel Mode 2" },                                     /* [3]  10.5.2.7 */
206         { 0x00, "UTRAN Classmark" },                            /* [3]  10.5.2.7a       */
207 /* [3]  10.5.2.7b       (void) */
208         { 0x00, "Classmark Enquiry Mask" },                     /* [3]  10.5.2.7c */
209 /* [3]  10.5.2.7d       GERAN Iu Mode Classmark information element */
210         { 0x00, "Channel Needed"},                                      /* [3]  10.5.2.8        */
211  /* [3]  10.5.2.8a      (void) */
212  /* [3]  10.5.2.8b      Channel Request Description 2 */
213                 /* Pos 20 */
214         { 0x00, "Cipher Mode Setting" },                        /* [3]  10.5.2.9        */
215         { 0x00, "Cipher Mode Response" },                         /* [3]  10.5.2.10     */
216         { 0x00, "Control Channel Description" },        /* [3]  10.5.2.11       Control Channel Description             */
217 /* [3]  10.5.2.11a      DTM Information Details */
218         { 0x00, "Dynamic ARFCN Mapping" },                      /* [3]  10.5.2.11b      */
219         { 0x00, "Frequency Channel Sequence" },         /* [3]  10.5.2.12       */
220         { 0x00, "Frequency List" },                                     /* 10.5.2.13            */
221         { 0x00, "Frequency Short List" },                       /* 10.5.2.14            */
222         { 0x00, "Frequency Short List2" },                      /* 10.5.2.14a           */
223 /* [3]  10.5.2.14b      Group Channel Description */
224         { 0x00, "GPRS Resumption" },                            /* [3]  10.5.2.14c      GPRS Resumption */
225         { 0x00, "GPRS Broadcast Information" },         /* [3]  10.5.2.14d      GPRS broadcast information */
226 /* [3]  10.5.2.14e      Enhanced DTM CS Release Indication */
227         { 0x00, "Handover Reference" },                         /* 10.5.2.15            */
228         { 0x00, "IA Rest Octets" },                                     /* [3] 10.5.2.16        */
229         { 0x00, "IAR Rest Octets" },                            /* [3] 10.5.2.17 IAR Rest Octets */
230         { 0x00, "IAX Rest Octets" },                            /* [3] 10.5.2.18 IAX Rest Octets */
231         { 0x00, "L2 Pseudo Length" },                           /* [3] 10.5.2.19        */
232         { 0x00, "Measurement Results" },                        /* [3] 10.5.2.20 Measurement Results */
233 /*
234  * [3] 10.5.2.20a GPRS Measurement Results
235  */
236         { 0x00, "Mobile Allocation" },                          /* [3] 10.5.2.21        */
237         { 0x00, "Mobile Time Difference" },                     /* [3] 10.5.2.21a       */
238         { 0x00, "MultiRate configuration" },            /* [3] 10.5.2.21aa      */
239         /* Pos 30 */
240         { 0x00, "Multislot Allocation" },                       /* [3] 10.5.2.21b       */
241  /*
242  * [3] 10.5.2.21c NC mode
243  */
244         { 0x00, "Neighbour Cell Description" },         /* [3] 10.5.2.22 Neighbour Cell Description */
245         { 0x00, "Neighbour Cell Description 2" },       /* [3] 10.5.2.22a Neighbour Cell Description 2 */
246 /*
247  * [3] 10.5.2.22b (void)
248  * [3] 10.5.2.22c NT/N Rest Octets */
249         { 0x00, "P1 Rest Octets" },                                             /* [3] 10.5.2.23 P1 Rest Octets */
250         { 0x00, "P2 Rest Octets" },                                             /* [3] 10.5.2.24 P2 Rest Octets */
251         { 0x00, "P3 Rest Octets" },                                             /* [3] 10.5.2.25 P3 Rest Octets */
252         { 0x00, "Packet Channel Description" },         /* [3] 10.5.2.25a       */
253         { 0x00, "Dedicated mode or TBF" },                      /* [3] 10.5.2.25b */
254  /* [3] 10.5.2.25c RR Packet Uplink Assignment
255  * [3] 10.5.2.25d RR Packet Downlink Assignment */
256         { 0x00, "Page Mode" },                                          /* [3] 10.5.2.26  */
257 /*
258  * [3] 10.5.2.26a (void)
259  * [3] 10.5.2.26b (void)
260  * [3] 10.5.2.26c (void)
261  * [3] 10.5.2.26d (void)
262  */
263         { 0x00, "NCC Permitted" },                                      /* [3] 10.5.2.27 NCC Permitted */
264         { 0x00, "Power Command" },                                      /* 10.5.2.28 */
265         { 0x00, "Power Command and access type" },      /* 10.5.2.28a */
266         { 0x00, "RACH Control Parameters" },            /* [3] 10.5.2.29 RACH Control Parameters */
267         { 0x00, "Request Reference" },                          /* [3] 10.5.2.30 Request Reference                              */
268         { 0x00, "RR Cause" },                                           /* 10.5.2.31 */
269         { 0x00, "Synchronization Indication" },         /* 10.5.2.39 */
270         { 0x00, "SI 1 Rest Octets" },                           /* [3] 10.5.2.32 */
271 /* [3] 10.5.2.33 SI 2bis Rest Octets */
272         { 0x00, "SI 2ter Rest Octets" },                /* [3] 10.5.2.33a */
273         { 0x00, "SI 2quater Rest Octets" },             /* [3] 10.5.2.33b */
274         { 0x00, "SI 3 Rest Octets" },                   /* [3] 10.5.2.34 */
275         { 0x00, "SI 4 Rest Octets" },                   /* [3] 10.5.2.35 */
276         { 0x00, "SI 6 Rest Octets" },                   /* [3] 10.5.2.35a */
277 /* [3] 10.5.2.36 SI 7 Rest Octets
278  * [3] 10.5.2.37 SI 8 Rest Octets
279  * [3] 10.5.2.37a SI 9 Rest Octets
280  */
281         { 0x00, "SI 13 Rest Octets" },                  /* [3] 10.5.2.37b */
282 /* [3] 10.5.2.37c (void)
283  * [3] 10.5.2.37d (void)
284  * [3] 10.5.2.37e SI 16 Rest Octets
285  * [3] 10.5.2.37f SI 17 Rest Octets
286  * [3] 10.5.2.37g SI 19 Rest Octets
287  * [3] 10.5.2.37h SI 18 Rest Octets
288  * [3] 10.5.2.37i SI 20 Rest Octets */
289         { 0x00, "Starting Time" },                                      /* [3] 10.5.2.38 Starting Time  */
290         { 0x00, "Timing Advance" },                                     /* [3] 10.5.2.40 Timing Advance */
291         { 0x00, "Time Difference" },                            /* [3] 10.5.2.41 Time Difference                                */
292         { 0x00, "TLLI" },                                                       /* [3] 10.5.2.41a TLLI                                                  */
293         { 0x00, "TMSI/P-TMSI" },                                        /* [3] 10.5.2.42 TMSI/P-TMSI */
294         { 0x00, "VGCS target mode Indication" },        /* [3] 10.5.2.42a                                                               */
295         /* Pos 40 */
296         { 0x00, "VGCS Ciphering Parameters" },          /* [3] 10.5.2.42b                                                               */
297         { 0x00, "Wait Indication" },                            /* [3] 10.5.2.43 Wait Indication */
298 /* [3] 10.5.2.44 SI10 rest octets $(ASCI)$ */
299         { 0x00, "Extended Measurement Results" },                       /* [3] 10.5.2.45 Extended Measurement Results */
300         { 0x00, "Extended Measurement Frequency List" },        /* [3] 10.5.2.46 Extended Measurement Frequency List */
301         { 0x00, "Suspension Cause" },                           /* [3] 10.5.2.47                                                                */
302 /* [3] 10.5.2.48 APDU ID
303  * [3] 10.5.2.49 APDU Flags
304  * [3] 10.5.2.50 APDU Data */
305         { 0x00, "Handover to UTRAN Command" },          /* [3] 10.5.2.51 Handover To UTRAN Command */
306 /* [3] 10.5.2.52 Handover To cdma2000 Command
307  * [3] 10.5.2.53 (void)
308  * [3] 10.5.2.54 (void)
309  * [3] 10.5.2.55 (void)
310  * [3] 10.5.2.56 3G Target Cell */
311  { 0x00,        "Service Support" },                                    /* [3] 10.5.2.57        */
312  /* 10.5.2.58 MBMS p-t-m Channel Description */
313         { 0x00, "Dedicated Service Information" },              /* [3] 10.5.2.59        */
314 /*
315  * 10.5.2.60 MPRACH Description
316  * 10.5.2.61 Restriction Timer
317  * 10.5.2.62 MBMS Session Identity
318  * 10.5.2.63 Reduced group or broadcast call reference
319  * 10.5.2.64 Talker Priority status
320  * 10.5.2.65 Talker Identity
321  * 10.5.2.66 Token
322  * 10.5.2.67 PS Cause
323  * 10.5.2.68 VGCS AMR Configuration
324  */
325         { 0x00, "Carrier Indication" },         /* 10.5.2.69 Carrier Indication */
326         { 0, NULL }
327 };
328
329 const value_string gsm_rr_rest_octets_elem_strings[] = {
330    /* RR Rest Octets information elements */
331    { 0, "UTRAN FDD Description" },
332    { 0, "UTRAN TDD Description" }, 
333    { 0, "3G Measurement Parameters Description" },
334    { 0, "3G Additional Measurement Parameters Description" },
335    { 0, "Measurement Parameters Description" },
336    { 0, "GPRS Real Time Difference Description" },
337    { 0, "GPRS BSIC Description" },
338    { 0, "GPRS Report Priority Description" },
339    { 0, "GPRS Measurement Parameters Description" },
340    { 0, "NC Measurement Parameters" },
341    { 0, "SI2q Extension Information" },
342    { 0, "CCN Support Description" },
343    { 0, "3G Neighbour Cell Description" },
344    { 0, "FDD Cell Information Field" },
345    { 0, "TDD Cell Information Field" },
346    { 0, "GPRS 3G Measurement Parameters Description" },
347    { 0, "3G Additional Measurement Parameters Description 2" },
348    { 0, "Optional Selection Parameters" },
349    { 0, "GPRS Indicator" },
350    { 0, "SI4 Rest Octets_O" },
351    { 0, "SI4 Rest Octets_S" },
352    { 0, "LSA Parameters" },
353    { 0, "LSA ID Information" },
354    { 0, "PCH and NCH Info" },
355    { 0, "VBS/VGCS Options" },
356    { 0, "GPRS Mobile Allocation" },
357    { 0, "GPRS Cell Options" },
358    { 0, "GPRS Cell Options Extension Information" },
359    { 0, "GPRS Power Control Parameters" },
360    { 0, "PBCCH Description" },
361    { 0, "GSM Description" },
362    { 0, "Real Time Difference Description" },
363    { 0, "BSIC Description" },
364    { 0, "Report Priority Description" },
365    { 0, "CDMA2000 Description" },
366    { 0, "Serving cell data" },
367    { 0, "Repeated Invalid BSIC Information" },
368    { 0, "Bitmap Type Reporting" },
369    { 0, NULL }
370 };
371
372
373 /* RR cause value (octet 2) TS 44.018 6.11.0*/
374 static const value_string gsm_a_rr_RR_cause_vals[] = {
375         { 0,    "Normal event"},
376         { 1,    "Abnormal release, unspecified"},
377         { 2,    "Abnormal release, channel unacceptable"},
378         { 3,    "Abnormal release, timer expired"},
379         { 4,    "Abnormal release, no activity on the radio path"},
380         { 5,    "Preemptive release"},
381         { 6,    "UTRAN configuration unknown"},
382         { 8,    "Handover impossible, timing advance out of range"},
383         { 9,    "Channel mode unacceptable"},
384         { 10,   "Frequency not implemented"},
385         { 13,   "Originator or talker leaving group call area"},
386         { 12,   "Lower layer failure"},
387         { 0x41, "Call already cleared"},
388         { 0x5f, "Semantically incorrect message"},
389         { 0x60, "Invalid mandatory information"},
390         { 0x61, "Message type non-existent or not implemented"},
391         { 0x62, "Message type not compatible with protocol state"},
392         { 0x64, "Conditional IE error"},
393         { 0x65, "No cell allocation available"},
394         { 0x6f, "Protocol error unspecified"},
395         { 0,    NULL }
396 };
397
398 static const value_string gsm_a_algorithm_identifier_vals[] = {
399         { 0,    "Cipher with algorithm A5/1"},
400         { 1,    "Cipher with algorithm A5/2"},
401         { 2,    "Cipher with algorithm A5/3"},
402         { 3,    "Cipher with algorithm A5/4"},
403         { 4,    "Cipher with algorithm A5/5"},
404         { 5,    "Cipher with algorithm A5/6"},
405         { 6,    "Cipher with algorithm A5/7"},
406         { 7,    "Reserved"},
407         { 0,    NULL }
408 };
409
410
411 #define DTAP_PD_MASK            0x0f
412 #define DTAP_SKIP_MASK          0xf0
413 #define DTAP_TI_MASK            DTAP_SKIP_MASK
414 #define DTAP_TIE_PRES_MASK      0x07                    /* after TI shifted to right */
415 #define DTAP_TIE_MASK           0x7f
416
417 #define DTAP_RR_IEI_MASK        0xff
418
419 /* Initialize the protocol and registered fields */
420 static int proto_a_ccch = -1;
421 static int proto_a_sacch = -1;
422
423 static int hf_gsm_a_dtap_msg_rr_type = -1;
424 int hf_gsm_a_rr_elem_id = -1;
425
426 static int hf_gsm_a_sacch_msg_rr_type = -1;
427
428 static int hf_gsm_a_bcc                         = -1;
429 static int hf_gsm_a_ncc                         = -1;
430 static int hf_gsm_a_bcch_arfcn          = -1;
431 static int hf_gsm_a_rr_range_nb = -1;
432 static int hf_gsm_a_rr_range_lower = -1;
433 static int hf_gsm_a_rr_range_higher = -1;
434 static int hf_gsm_a_rr_ba_list_pref_length = -1;
435 static int hf_gsm_a_rr_ba_freq = -1;
436 static int hf_gsm_a_rr_utran_freq_list_length = -1;
437 static int hf_gsm_a_rr_ho_ref_val       = -1;
438 static int hf_gsm_a_rr_L2_pseudo_len = -1;
439 static int hf_gsm_a_rr_ba_used = -1;
440 static int hf_gsm_a_rr_dtx_used = -1;
441 static int hf_gsm_a_rr_3g_ba_used = -1;
442 static int hf_gsm_a_rr_meas_valid = -1;
443 static int hf_gsm_a_rr_rxlev_full_serv_cell = -1;
444 static int hf_gsm_a_rr_rxlev_sub_serv_cell = -1;
445 static int hf_gsm_a_rr_rxqual_full_serv_cell = -1;
446 static int hf_gsm_a_rr_rxqual_sub_serv_cell = -1;
447 static int hf_gsm_a_rr_no_ncell_m = -1;
448 static int hf_gsm_a_rr_rxlev_ncell = -1;
449 static int hf_gsm_a_rr_bcch_freq_ncell = -1;
450 static int hf_gsm_a_rr_bsic_ncell = -1;
451 static int hf_gsm_a_rr_mobile_time_difference = -1;
452 static int hf_gsm_a_rr_pow_cmd_atc = -1;
453 static int hf_gsm_a_rr_pow_cmd_epc = -1;
454 static int hf_gsm_a_rr_page_mode = -1;
455 static int hf_gsm_a_rr_dedicated_mode_or_tbf = -1;
456 static int hf_gsm_a_rr_pow_cmd_fpcepc = -1;
457 static int hf_gsm_a_rr_pow_cmd_powlev = -1;
458 static int hf_gsm_a_rr_sync_ind_nci = -1;
459 static int hf_gsm_a_rr_sync_ind_rot = -1;
460 static int hf_gsm_a_rr_sync_ind_si = -1;
461 static int hf_gsm_a_rr_format_id = -1;
462 static int hf_gsm_a_rr_channel_mode = -1;
463 static int hf_gsm_a_rr_channel_mode2 = -1;
464 static int hf_gsm_a_rr_sc = -1;
465 static int hf_gsm_a_algorithm_id = -1;
466 static int hf_gsm_a_rr_cr = -1;
467 static int hf_gsm_a_rr_multirate_speech_ver = -1;
468 static int hf_gsm_a_rr_NCSB                             = -1;
469 static int hf_gsm_a_rr_ICMI                             = -1;
470 static int hf_gsm_a_rr_start_mode               = -1;
471 static int hf_gsm_a_rr_timing_adv = -1;
472 static int hf_gsm_a_rr_time_diff = -1;
473 static int hf_gsm_a_rr_tlli = -1;
474 static int hf_gsm_a_rr_tmsi_ptmsi = -1;
475 static int hf_gsm_a_rr_target_mode = -1;
476 static int hf_gsm_a_rr_wait_indication = -1;
477 static int hf_gsm_a_rr_seq_code = -1;
478 static int hf_gsm_a_rr_group_cipher_key_number = -1;
479 static int hf_gsm_a_rr_MBMS_multicast = -1;
480 static int hf_gsm_a_rr_MBMS_broadcast = -1;
481 static int hf_gsm_a_rr_last_segment = -1;
482 static int hf_gsm_a_rr_carrier_ind = -1;
483 static int hf_gsm_a_rr_ra               = -1;
484 static int hf_gsm_a_rr_T1prim   = -1;
485 static int hf_gsm_a_rr_T3               = -1;
486 static int hf_gsm_a_rr_T2               = -1;
487 static int hf_gsm_a_rr_rfn      = -1;
488 static int hf_gsm_a_rr_RR_cause = -1;
489 static int hf_gsm_a_rr_cm_cng_msg_req = -1;
490 static int hf_gsm_a_rr_utran_cm_cng_msg_req = -1;
491 static int hf_gsm_a_rr_cdma200_cm_cng_msg_req = -1;
492 static int hf_gsm_a_rr_geran_iu_cm_cng_msg_req = -1;
493 int hf_gsm_a_rr_chnl_needed_ch1 = -1;
494 static int hf_gsm_a_rr_chnl_needed_ch2 = -1;
495 static int hf_gsm_a_rr_chnl_needed_ch3 = -1;
496 static int hf_gsm_a_rr_chnl_needed_ch4 = -1;
497 static int hf_gsm_a_rr_suspension_cause = -1;
498 static int hf_gsm_a_rr_set_of_amr_codec_modes_v1_b8 = -1;
499 static int hf_gsm_a_rr_set_of_amr_codec_modes_v1_b7 = -1;
500 static int hf_gsm_a_rr_set_of_amr_codec_modes_v1_b6 = -1;
501 static int hf_gsm_a_rr_set_of_amr_codec_modes_v1_b5 = -1;
502 static int hf_gsm_a_rr_set_of_amr_codec_modes_v1_b4 = -1;
503 static int hf_gsm_a_rr_set_of_amr_codec_modes_v1_b3 = -1;
504 static int hf_gsm_a_rr_set_of_amr_codec_modes_v1_b2 = -1;
505 static int hf_gsm_a_rr_set_of_amr_codec_modes_v1_b1 = -1;
506 static int hf_gsm_a_rr_set_of_amr_codec_modes_v2_b5 = -1;
507 static int hf_gsm_a_rr_set_of_amr_codec_modes_v2_b4 = -1;
508 static int hf_gsm_a_rr_set_of_amr_codec_modes_v2_b3 = -1;
509 static int hf_gsm_a_rr_set_of_amr_codec_modes_v2_b2 = -1;
510 static int hf_gsm_a_rr_set_of_amr_codec_modes_v2_b1 = -1;
511 static int hf_gsm_a_rr_amr_threshold = -1;
512 static int hf_gsm_a_rr_amr_hysteresis = -1;
513 static int hf_gsm_a_rr_pwrc = -1;
514 static int hf_gsm_a_rr_dtx_bcch = -1;
515 static int hf_gsm_a_rr_dtx_sacch = -1;
516 static int hf_gsm_a_rr_radio_link_timeout = -1;
517 static int hf_gsm_a_rr_cell_reselect_hyst = -1;
518 static int hf_gsm_a_rr_ms_txpwr_max_cch = -1;
519 static int hf_gsm_a_rr_acs = -1;
520 static int hf_gsm_a_rr_neci = -1;
521 static int hf_gsm_a_rr_rxlev_access_min = -1;
522 static int hf_gsm_a_rr_mscr = -1;
523 static int hf_gsm_a_rr_att = -1;
524 static int hf_gsm_a_rr_ccch_conf = -1;
525 static int hf_gsm_a_rr_cbq3 = -1;
526 static int hf_gsm_a_rr_bs_pa_mfrms = -1;
527 static int hf_gsm_a_rr_bs_ag_blks_res = -1;
528 static int hf_gsm_a_rr_t3212 = -1;
529 static int hf_gsm_a_rr_dyn_arfcn_length = -1;
530 static int hf_gsm_a_rr_gsm_band = -1;
531 static int hf_gsm_a_rr_arfcn_first = -1;
532 static int hf_gsm_a_rr_band_offset = -1;
533 static int hf_gsm_a_rr_arfcn_range = -1;
534 static int hf_gsm_a_rr_lowest_arfcn = -1;
535 static int hf_gsm_a_rr_inc_skip_arfcn = -1;
536 static int hf_gsm_a_rr_gprs_resumption_ack = -1;
537 static int hf_gsm_a_rr_ext_ind = -1;
538 static int hf_gsm_a_rr_ba_ind = -1;
539 static int hf_gsm_a_rr_multiband_reporting = -1;
540 static int hf_gsm_a_rr_ncc_permitted = -1;
541 static int hf_gsm_a_rr_max_retrans = -1;
542 static int hf_gsm_a_rr_tx_integer = -1;
543 static int hf_gsm_a_rr_cell_barr_access = -1;
544 static int hf_gsm_a_rr_re = -1;
545 static int hf_gsm_a_rr_acc = -1;
546 static int hf_gsm_a_rr_nch_position = -1;
547 static int hf_gsm_a_rr_si2ter_mp_change_mark = -1;
548 static int hf_gsm_a_rr_si2ter_3g_change_mark = -1;
549 static int hf_gsm_a_rr_si2ter_index = -1;
550 static int hf_gsm_a_rr_si2ter_count = -1;
551 static int hf_gsm_a_rr_fdd_uarfcn = -1;
552 static int hf_gsm_a_rr_bandwidth_fdd = -1;
553 static int hf_gsm_a_rr_tdd_uarfcn = -1;
554 static int hf_gsm_a_rr_bandwidth_tdd = -1;
555 static int hf_gsm_a_rr_arfcn = -1;
556 static int hf_gsm_a_rr_bsic = -1;
557 static int hf_gsm_a_rr_qsearch_i = -1;
558 static int hf_gsm_a_rr_fdd_qoffset = -1;
559 static int hf_gsm_a_rr_fdd_qmin = -1;
560 static int hf_gsm_a_rr_tdd_qoffset = -1;
561 static int hf_gsm_a_rr_fdd_qmin_offset = -1;
562 static int hf_gsm_a_rr_fdd_rscpmin = -1;
563 static int hf_gsm_a_rr_3g_ba_ind = -1;
564 static int hf_gsm_a_rr_mp_change_mark = -1;
565 static int hf_gsm_a_rr_si2quater_index = -1;
566 static int hf_gsm_a_rr_si2quater_count = -1;
567 static int hf_gsm_a_rr_gsm_report_type = -1;
568 static int hf_gsm_a_rr_serving_band_reporting = -1;
569 static int hf_gsm_a_rr_frequency_scrolling = -1;
570 static int hf_gsm_a_rr_rep_priority = -1;
571 static int hf_gsm_a_rr_report_type = -1;
572 static int hf_gsm_a_rr_reporting_rate = -1;
573 static int hf_gsm_a_rr_invalid_bsic_reporting = -1;
574 static int hf_gsm_a_rr_scale_ord = -1;
575 static int hf_gsm_a_rr_900_reporting_offset = -1;
576 static int hf_gsm_a_rr_900_reporting_threshold = -1;
577 static int hf_gsm_a_rr_1800_reporting_offset = -1;
578 static int hf_gsm_a_rr_1800_reporting_threshold = -1;
579 static int hf_gsm_a_rr_400_reporting_offset = -1;
580 static int hf_gsm_a_rr_400_reporting_threshold = -1;
581 static int hf_gsm_a_rr_1900_reporting_offset = -1;
582 static int hf_gsm_a_rr_1900_reporting_threshold = -1;
583 static int hf_gsm_a_rr_850_reporting_offset = -1;
584 static int hf_gsm_a_rr_850_reporting_threshold = -1;
585 static int hf_gsm_a_rr_network_control_order = -1;
586 static int hf_gsm_a_rr_nc_non_drx_period = -1;
587 static int hf_gsm_a_rr_nc_reporting_period_i = -1;
588 static int hf_gsm_a_rr_nc_reporting_period_t = -1;
589 static int hf_gsm_a_rr_index_start_3g = -1;
590 static int hf_gsm_a_rr_absolute_index_start_emr = -1;
591 static int hf_gsm_a_rr_qsearch_c_initial = -1;
592 static int hf_gsm_a_rr_fdd_rep_quant = -1;
593 static int hf_gsm_a_rr_fdd_multirat_reporting = -1;
594 static int hf_gsm_a_rr_tdd_multirat_reporting = -1;
595 static int hf_gsm_a_rr_qsearch_p = -1;
596 static int hf_gsm_a_rr_3g_search_prio = -1;
597 static int hf_gsm_a_rr_fdd_reporting_offset = -1;
598 static int hf_gsm_a_rr_fdd_reporting_threshold = -1;
599 static int hf_gsm_a_rr_tdd_reporting_offset = -1;
600 static int hf_gsm_a_rr_tdd_reporting_threshold = -1;
601 static int hf_gsm_a_rr_fdd_reporting_threshold_2 = -1;
602 static int hf_gsm_a_rr_3g_ccn_active = -1;
603 static int hf_gsm_a_rr_700_reporting_offset = -1;
604 static int hf_gsm_a_rr_700_reporting_threshold = -1;
605 static int hf_gsm_a_rr_810_reporting_offset = -1;
606 static int hf_gsm_a_rr_810_reporting_threshold = -1;
607 static int hf_gsm_a_rr_cbq = -1;
608 static int hf_gsm_a_rr_cell_reselect_offset = -1;
609 static int hf_gsm_a_rr_temporary_offset = -1;
610 static int hf_gsm_a_rr_penalty_time = -1;
611 static int hf_gsm_a_rr_si13_position = -1;
612 static int hf_gsm_a_rr_power_offset = -1;
613 static int hf_gsm_a_rr_si2quater_position = -1;
614 static int hf_gsm_a_rr_si13alt_position = -1;
615 static int hf_gsm_a_rr_prio_thr = -1;
616 static int hf_gsm_a_rr_lsa_offset = -1;
617 static int hf_gsm_a_rr_paging_channel_restructuring = -1;
618 static int hf_gsm_a_rr_nln_sacch = -1;
619 static int hf_gsm_a_rr_nln_status_sacch = -1;
620 static int hf_gsm_a_rr_nln_pch = -1;
621 static int hf_gsm_a_rr_nln_status_pch = -1;
622 static int hf_gsm_a_rr_vbs_vgcs_inband_notifications = -1;
623 static int hf_gsm_a_rr_vbs_vgcs_inband_pagings = -1;
624 static int hf_gsm_a_rr_rac = -1;
625 static int hf_gsm_a_rr_max_lapdm = -1;
626 static int hf_gsm_a_rr_gprs_ms_txpwr_max_ccch = -1;
627 static int hf_gsm_a_rr_dedicated_mode_mbms_notification_support = -1;
628 static int hf_gsm_a_rr_mnci_support = -1;
629 static int hf_gsm_a_rr_amr_config = -1;
630 static int hf_gsm_a_rr_bcch_change_mark = -1;
631 static int hf_gsm_a_rr_si_change_field = -1;
632 static int hf_gsm_a_rr_si13_change_mark = -1;
633 static int hf_gsm_a_rr_hsn = -1;
634 static int hf_gsm_a_rr_rfl_number = -1;
635 static int hf_gsm_a_rr_arfcn_index = -1;
636 static int hf_gsm_a_rr_ma_length = -1;
637 static int hf_gsm_a_rr_psi1_repeat_period = -1;
638 static int hf_gsm_a_rr_pbcch_pb = -1;
639 static int hf_gsm_a_rr_pbcch_tsc = -1;
640 static int hf_gsm_a_rr_pbcch_tn = -1;
641 static int hf_gsm_a_rr_spgc_ccch_sup = -1;
642 static int hf_gsm_a_rr_priority_access_thr = -1;
643 static int hf_gsm_a_rr_nmo = -1;
644 static int hf_gsm_a_rr_t3168 = -1;
645 static int hf_gsm_a_rr_t3192 = -1;
646 static int hf_gsm_a_rr_drx_timer_max = -1;
647 static int hf_gsm_a_rr_access_burst_type = -1;
648 static int hf_gsm_a_rr_control_ack_type = -1;
649 static int hf_gsm_a_rr_bs_cv_max = -1;
650 static int hf_gsm_a_rr_pan_dec = -1;
651 static int hf_gsm_a_rr_pan_inc = -1;
652 static int hf_gsm_a_rr_pan_max = -1;
653 static int hf_gsm_a_rr_egprs_packet_channel_request = -1;
654 static int hf_gsm_a_rr_bep_period = -1;
655 static int hf_gsm_a_rr_pfc_feature_mode = -1;
656 static int hf_gsm_a_rr_dtm_support = -1;
657 static int hf_gsm_a_rr_bss_paging_coordination = -1;
658 static int hf_gsm_a_rr_ccn_active = -1;
659 static int hf_gsm_a_rr_nw_ext_utbf = -1;
660 static int hf_gsm_a_rr_multiple_tbf_capability = -1;
661 static int hf_gsm_a_rr_ext_utbf_no_data = -1;
662 static int hf_gsm_a_rr_dtm_enhancements_capability = -1;
663 static int hf_gsm_a_rr_reduced_latency_access = -1;
664 static int hf_gsm_a_rr_alpha = -1;
665 static int hf_gsm_a_rr_t_avg_w = -1;
666 static int hf_gsm_a_rr_t_avg_t = -1;
667 static int hf_gsm_a_rr_pc_meas_chan = -1;
668 static int hf_gsm_a_rr_n_avg_i = -1;
669 static int hf_gsm_a_rr_sgsnr = -1;
670 static int hf_gsm_a_rr_si_status_ind = -1;
671 static int hf_gsm_a_rr_lb_ms_txpwr_max_cch = -1;
672 static int hf_gsm_a_rr_si2n_support = -1;
673 static int hf_gsm_a_rr_mi_index = -1;
674 static int hf_gsm_a_rr_mi_count = -1;
675 static int hf_gsm_a_rr_3g_wait = -1;
676 static int hf_gsm_a_rr_qsearch_c = -1;
677 static int hf_gsm_a_rr_bsic_seen = -1;
678 static int hf_gsm_a_rr_scale = -1;
679 static int hf_gsm_a_rr_mean_bep_gmsk = -1;
680 static int hf_gsm_a_rr_mean_cv_bep = -1;
681 static int hf_gsm_a_rr_nbr_rcvd_blocks = -1;
682 static int hf_gsm_a_rr_reporting_quantity = -1;
683
684 /* Initialize the subtree pointers */
685 static gint ett_ccch_msg = -1;
686 static gint ett_ccch_oct_1 = -1;
687 static gint ett_sacch_msg = -1;
688
689 static char a_bigbuf[1024];
690
691 static dissector_handle_t data_handle;
692
693
694
695 #define NUM_GSM_RR_ELEM (sizeof(gsm_rr_elem_strings)/sizeof(value_string))
696 gint ett_gsm_rr_elem[NUM_GSM_RR_ELEM];
697
698 typedef enum
699 {
700    /* RR Rest Octets information elements */
701    DE_RR_REST_OCTETS_UTRAN_FDD_DESC,
702    DE_RR_REST_OCTETS_UTRAN_TDD_DESC,
703    DE_RR_REST_OCTETS_3G_MEAS_PARAM_DESC,
704    DE_RR_REST_OCTETS_3G_ADD_MEAS_PARAM_DESC,
705    DE_RR_REST_OCTETS_MEAS_PARAM_DESC,
706    DE_RR_REST_OCTETS_GPRS_RTD_DESC,
707    DE_RR_REST_OCTETS_GPRS_BSIC_DESC,
708    DE_RR_REST_OCTETS_GPRS_REPORT_PRIO_DESC,
709    DE_RR_REST_OCTETS_GPRS_MEAS_PARAM_DESC,
710    DE_RR_REST_OCTETS_NC_MEAS_PARAM,
711    DE_RR_REST_OCTETS_SI2Q_EXT_INFO,
712    DE_RR_REST_OCTETS_CCN_SUPPORT_DESC,
713    DE_RR_REST_OCTETS_3G_NEIGH_CELL_DESC,
714    DE_RR_REST_OCTETS_FDD_CELL_INFORMATION_FIELD,
715    DE_RR_REST_OCTETS_TDD_CELL_INFORMATION_FIELD,
716    DE_RR_REST_OCTETS_GPRS_3G_MEAS_PARAM_DESC,
717    DE_RR_REST_OCTETS_3G_ADD_MEAS_PARAM_DESC2,
718    DE_RR_REST_OCTETS_OPTIONAL_SEL_PARAM,
719    DE_RR_REST_OCTETS_GPRS_INDICATOR,
720    DE_RR_REST_OCTETS_SI4_REST_OCTETS_O,
721    DE_RR_REST_OCTETS_SI4_REST_OCTETS_S,
722    DE_RR_REST_OCTETS_LSA_PARAMETERS,
723    DE_RR_REST_OCTETS_LSA_ID_INFO,
724    DE_RR_REST_OCTETS_PCH_AND_NCH_INFO,
725    DE_RR_REST_OCTETS_VBS_VGCS_OPTIONS,
726    DE_RR_REST_OCTETS_GPRS_MOBILE_ALLOC,
727    DE_RR_REST_OCTETS_GPRS_CELL_OPTIONS,
728    DE_RR_REST_OCTETS_GPRS_CELL_OPTIONS_EXT_INFO,
729    DE_RR_REST_OCTETS_GPRS_POWER_CONTROL_PARAMS,
730    DE_RR_REST_OCTETS_PBCCH_DESC,
731    DE_RR_REST_OCTETS_GSM_DESC,
732    DE_RR_REST_OCTETS_RTD_DESC,
733    DE_RR_REST_OCTETS_BSIC_DESC,
734    DE_RR_REST_OCTETS_REPORT_PRIO_DESC,
735    DE_RR_REST_OCTETS_CDMA2000_DESC,
736    DE_RR_REST_OCTETS_SERVING_CELL_DATA,
737    DE_RR_REST_OCTETS_REPEAT_INV_BSIC_INFO,
738    DE_RR_REST_OCTETS_BITMAP_TYPE_REPORTING,
739    DE_RR_REST_OCTETS_NONE
740 }
741 rr_rest_octets_elem_idx_t;
742
743 #define NUM_GSM_RR_REST_OCTETS_ELEM (sizeof(gsm_rr_rest_octets_elem_strings)/sizeof(value_string))
744 gint ett_gsm_rr_rest_octets_elem[NUM_GSM_RR_REST_OCTETS_ELEM];
745
746 /*
747 10.5.2 Radio Resource management information elements
748  * [3] 10.5.2.1a BA Range
749  */
750 guint8
751 de_rr_ba_range(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
752 {
753    guint32 curr_offset;
754    gint bit_offset;
755    guint8 value;
756
757    curr_offset = offset;
758    proto_tree_add_item(tree, hf_gsm_a_rr_range_nb, tvb, curr_offset, 1, FALSE);
759    value = tvb_get_guint8(tvb, curr_offset);
760    curr_offset += 1;
761    bit_offset = curr_offset << 3;
762    while (value)
763    {
764       proto_tree_add_bits_item(tree, hf_gsm_a_rr_range_lower, tvb, bit_offset, 10, FALSE);
765       bit_offset += 10;
766       proto_tree_add_bits_item(tree, hf_gsm_a_rr_range_higher, tvb, bit_offset, 10, FALSE);
767       bit_offset += 10;
768       value -= 1;
769    }
770
771    curr_offset += len - 1;
772    return (curr_offset - offset);
773 }
774
775 /*
776  * [3] 10.5.2.1b Cell Channel Description
777  */
778
779 #define ARFCN_MAX 1024 /* total number of ARFCNs defined */
780
781 static void display_channel_list(guint8 *list, tvbuff_t *tvb, proto_tree *tree, guint32 offset)
782 {
783         int arfcn;
784         proto_item *ti=NULL;
785
786         ti = proto_tree_add_text(tree, tvb, 0, offset, "List of ARFCNs =");
787         for (arfcn=0; arfcn<ARFCN_MAX; arfcn++) {
788                 if (list[arfcn])
789                         proto_item_append_text(ti, " %d", arfcn);
790         }
791
792         return;
793 }
794
795 static gint greatest_power_of_2_lesser_or_equal_to(gint index)
796 {
797    gint j = 1;
798    do {
799       j<<=1;
800    } while (j<=index);
801    j >>= 1;
802    return j;
803 }
804
805 static gint f_k(gint k, gint *w, gint range)
806 {
807    gint index, n, j;
808
809    index = k;
810    range -= 1;
811    range = range/greatest_power_of_2_lesser_or_equal_to(index);
812    n = w[index]-1;
813
814    while (index>1) {
815       j = greatest_power_of_2_lesser_or_equal_to(index);
816       range = 2*range+1;
817       if ((2*index) < 3*j){ /* left child */
818          index -= j/2;
819          n = (n+w[index]-1+((range-1)/2)+1)%range;
820       }
821       else { /* right child */
822          index -= j;
823          n = (n+w[index]-1+1)%range;
824       }
825    }
826
827    return (n+1)%1024;
828 }
829
830 static void dissect_channel_list_n_range(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gint range)
831 {
832         gint curr_offset=offset, f0, arfcn_orig, bits, w[64], wsize, i, wi;
833         gint octet, nwi=1, jwi=0, wbits, imax, iused, arfcn;
834         guint8 list[1024];
835
836         memset((void*)list,0,sizeof(list));
837
838         octet = tvb_get_guint8(tvb, curr_offset++);
839         if (range==1024) {
840                 f0 = (octet>>2)&1;
841                 if (f0)
842                         list[0] = 1;
843                 bits = 2;
844                 arfcn_orig = 0;
845                 wsize = 10;
846                 imax = 16;
847         }
848         else {
849                 arfcn_orig = (octet&1);
850                 arfcn_orig = (arfcn_orig << 8) + tvb_get_guint8(tvb, curr_offset++);
851                 octet = tvb_get_guint8(tvb, curr_offset++);
852                 arfcn_orig = (arfcn_orig << 1) + (octet>>7);
853                 list[arfcn_orig] = 1;
854                 bits = 7;
855                 switch (range) {
856                 case 512:
857                         wsize=9;
858                         imax = 17;
859                         break;
860                 case 256:
861                         wsize=8;
862                         imax = 21;
863                         break;
864                 case 128:
865                         wsize=7;
866                         imax = 28;
867                         break;
868                 default:
869                         wsize=0;
870                         imax = 0;
871                         DISSECTOR_ASSERT_NOT_REACHED();
872                 }
873         }
874         iused = imax;   /* in case the list is actually full */
875
876         /* extract the variable size w[] elements */
877         for (i=1; i<=imax; i++) {
878                 wi = octet & ~(0xff<<bits);      /* mask "bits" low bits to start wi from existing octet */
879                 wbits = bits;
880                 if (wsize>wbits) {                        /* need to extract more bits from the next octet */
881                         octet = tvb_get_guint8(tvb, curr_offset++);
882                         wi = (wi << 8) + octet;
883                         bits = 8;
884                         wbits += 8;
885                 }
886
887                 if (wbits>wsize)        {                  /* now we have too many bits - save some */
888                         bits = wbits - wsize;
889                         wi >>= bits;
890                 }
891                 else                                                    /* just right number of bits */
892                         bits = 0;
893
894                 w[i] = wi;
895                 if ((w[i]==0) || ((curr_offset-offset)>len)) {
896                         iused = i - 1;
897                         break;    /* all remaining elements must also be zero */
898                 }
899
900                 if (++jwi==nwi) {          /* check if the number of wi at this wsize has been extracted */
901                         jwi = 0;                        /* reset the count of wi at this size */
902                         nwi <<= 1;                /* get twice as many of the next size */
903                         wsize--;                        /* make the next size 1 bit smaller */
904                 }
905         }
906
907         for (i=1; i<=iused; i++) {
908                 arfcn = (f_k(i, w, range) + arfcn_orig)%1024;
909                 list[arfcn] = 1;
910         }
911
912         display_channel_list(list, tvb, tree, offset);
913
914         return;
915 }
916
917 static guint8
918 dissect_arfcn_list(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
919 {
920         guint32 curr_offset;
921         guint8  oct,bit,byte;
922         guint16 arfcn;
923         proto_item      *item;
924
925         curr_offset = offset;
926
927         oct = tvb_get_guint8(tvb, curr_offset);
928
929         /* FORMAT-ID, Format Identifier (part of octet 3)*/
930         proto_tree_add_item(tree, hf_gsm_a_rr_format_id, tvb, curr_offset, 1, FALSE);
931
932         if ((oct & 0xc0) == 0x00)
933         {
934                 /* bit map 0 */
935                 item = proto_tree_add_text(tree,tvb, curr_offset, len, "List of ARFCNs =");
936                 bit = 4;
937                 arfcn = 125;
938                 for (byte = 0;byte <= len-1;byte++)
939                 {
940                         oct = tvb_get_guint8(tvb, curr_offset);
941                         while (bit-- != 0)
942                         {
943                                 arfcn--;
944                                 if (((oct >> bit) & 1) == 1)
945                                 {
946                                         proto_item_append_text(item," %d",arfcn);
947                                 }
948                         }
949                         bit = 8;
950                         curr_offset++;
951                 }
952         }
953         else if ((oct & 0xc8) == 0x80)
954         {
955                 /* 1024 range */
956                 dissect_channel_list_n_range(tvb, tree, curr_offset, len, 1024);
957                 curr_offset = curr_offset + len;
958         }
959         else if ((oct & 0xce) == 0x88)
960         {
961                 /* 512 range */
962                 dissect_channel_list_n_range(tvb, tree, curr_offset, len, 512);
963                 curr_offset = curr_offset + len;
964         }
965         else if ((oct & 0xce) == 0x8a)
966         {
967                 /* 256 range */
968                 dissect_channel_list_n_range(tvb, tree, curr_offset, len, 256);
969                 curr_offset = curr_offset + len;
970         }
971         else if ((oct & 0xce) == 0x8c)
972         {
973                 /* 128 range */
974                 dissect_channel_list_n_range(tvb, tree, curr_offset, len, 128);
975                 curr_offset = curr_offset + len;
976         }
977         else if ((oct & 0xce) == 0x8e)
978         {
979                 /* variable bit map */
980                 arfcn = ((oct & 0x01) << 9) | (tvb_get_guint8(tvb, curr_offset+1) << 1) | ((tvb_get_guint8(tvb, curr_offset + 2) & 0x80) >> 7);
981                 item = proto_tree_add_text(tree,tvb,curr_offset,len,"List of ARFCNs = %d",arfcn);
982                 curr_offset = curr_offset + 2;
983                 bit = 7;
984                 for (byte = 0;byte <= len-3;byte++)
985                 {
986                         oct = tvb_get_guint8(tvb, curr_offset);
987                         while (bit-- != 0)
988                         {
989                                 arfcn++;
990                                 if (((oct >> bit) & 1) == 1)
991                                 {
992                                         proto_item_append_text(item," %d",arfcn);
993                                 }
994                         }
995                         bit = 8;
996                         curr_offset++;
997                 }
998         }
999
1000         return(curr_offset - offset);
1001 }
1002
1003 guint8
1004 de_rr_cell_ch_dsc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1005 {
1006         return dissect_arfcn_list(tvb, tree, offset, 16, add_string, string_len);
1007 }
1008 /*
1009  * [3] 10.5.2.1c BA List Pref
1010  */
1011 guint8
1012 de_rr_ba_list_pref(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
1013 {
1014    guint32 curr_offset;
1015    gint bit_offset;
1016    guint8 value;
1017
1018    curr_offset = offset;
1019    proto_tree_add_item(tree, hf_gsm_a_rr_ba_list_pref_length, tvb, curr_offset, 1, FALSE);
1020    curr_offset += 1;
1021    bit_offset = curr_offset << 3;
1022    value = tvb_get_bits8(tvb,bit_offset,1);
1023    bit_offset += 1;
1024    while (value)
1025    {
1026       proto_tree_add_bits_item(tree, hf_gsm_a_rr_range_lower, tvb, bit_offset, 10, FALSE);
1027       bit_offset += 10;
1028       proto_tree_add_bits_item(tree, hf_gsm_a_rr_range_higher, tvb, bit_offset, 10, FALSE);
1029       bit_offset += 10;
1030       value = tvb_get_bits8(tvb,bit_offset,1);
1031       bit_offset += 1;
1032    }
1033    value = tvb_get_bits8(tvb,bit_offset,1);
1034    bit_offset += 1;
1035    while (value)
1036    {
1037       proto_tree_add_bits_item(tree, hf_gsm_a_rr_ba_freq, tvb, bit_offset, 10, FALSE);
1038       bit_offset += 10;
1039       value = tvb_get_bits8(tvb,bit_offset,1);
1040       bit_offset += 1;
1041    }
1042
1043    curr_offset += len - 1;
1044    return (curr_offset - offset);
1045 }
1046
1047 /*
1048  * [3] 10.5.2.1d UTRAN Frequency List
1049  */
1050 guint8
1051 de_rr_utran_freq_list(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
1052 {
1053    guint32 curr_offset;
1054    gint bit_offset;
1055    guint8 value;
1056
1057    curr_offset = offset;
1058    proto_tree_add_item(tree, hf_gsm_a_rr_utran_freq_list_length, tvb, curr_offset, 1, FALSE);
1059    curr_offset += 1;
1060    bit_offset = curr_offset << 3;
1061    value = tvb_get_bits8(tvb,bit_offset,1);
1062    bit_offset += 1;
1063    while (value)
1064    {
1065       proto_tree_add_bits_item(tree, hf_gsm_a_rr_fdd_uarfcn, tvb, bit_offset, 14, FALSE);
1066       bit_offset += 14;
1067       value = tvb_get_bits8(tvb,bit_offset,1);
1068       bit_offset += 1;
1069    }
1070    value = tvb_get_bits8(tvb,bit_offset,1);
1071    bit_offset += 1;
1072    while (value)
1073    {
1074       proto_tree_add_bits_item(tree, hf_gsm_a_rr_tdd_uarfcn, tvb, bit_offset, 14, FALSE);
1075       bit_offset += 14;
1076       value = tvb_get_bits8(tvb,bit_offset,1);
1077       bit_offset += 1;
1078    }
1079
1080    curr_offset += len - 1;
1081    return (curr_offset - offset);
1082 }
1083
1084 /*
1085  * [3] 10.5.2.1e Cell selection indicator after release of all TCH and SDCCH
1086  */
1087 static const guint8
1088 convert_n_to_p[32] = {   0, 10, 19, 28, 26, 44, 52, 60, 67, 74, 81, 88, 95, 102, 109, 116,
1089                        122,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,   0,   0,   0};
1090
1091 static const guint8
1092 convert_n_to_q[32] = {   0,   9,  17,  25,  32, 39, 46, 53, 59, 65, 71, 77, 83, 89, 95, 101,
1093                        106, 111, 116, 121, 126,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,   0};
1094
1095 guint8
1096 de_rr_cell_select_indic(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1097 {
1098    proto_tree *subtree, *subtree2;
1099         proto_item *item, *item2;
1100    guint32 curr_offset;
1101    gint bit_offset, bit_offset_sav, idx, xdd_cell_info, wsize, nwi, jwi, w[64], i, iused, xdd_indic0;
1102    guint8 value, length;
1103
1104    curr_offset = offset;
1105    length = tvb_get_guint8(tvb, curr_offset);
1106    curr_offset += 1;
1107    bit_offset = curr_offset << 3;
1108    value = tvb_get_bits8(tvb,bit_offset,3);
1109    bit_offset += 3;
1110    switch (value)
1111    {
1112       case 0: /* GSM Description */
1113          bit_offset_sav = bit_offset;
1114          item = proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_GSM_DESC].strptr);
1115          subtree = proto_item_add_subtree(item, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_GSM_DESC]);
1116          value = tvb_get_bits8(tvb,bit_offset,1);
1117          bit_offset += 1;
1118          while (value)
1119          {
1120             proto_tree_add_text(subtree,tvb, bit_offset>>3, 1, "Band Indicator: %s",tvb_get_bits8(tvb,bit_offset,1) ? "1900" : "1800");
1121             bit_offset += 1;
1122             proto_tree_add_bits_item(subtree, hf_gsm_a_rr_arfcn, tvb, bit_offset, 10, FALSE);
1123             bit_offset += 10;
1124             proto_tree_add_bits_item(subtree, hf_gsm_a_rr_bsic, tvb, bit_offset, 6, FALSE);
1125             bit_offset += 6;
1126             value = tvb_get_bits8(tvb,bit_offset,1);
1127             bit_offset += 1;
1128          }
1129          proto_item_set_len(item,((bit_offset-bit_offset_sav)>>3)+1);
1130          break;
1131       case 1: /* UTRAN FDD Description */
1132          bit_offset_sav = bit_offset;
1133          item = proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_UTRAN_FDD_DESC].strptr);
1134          subtree = proto_item_add_subtree(item, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_UTRAN_FDD_DESC]);
1135          value = tvb_get_bits8(tvb,bit_offset,1);
1136          bit_offset += 1;
1137          while (value)
1138          {
1139             if (tvb_get_bits8(tvb,bit_offset,1))
1140             {
1141                bit_offset += 1;
1142                proto_tree_add_bits_item(subtree, hf_gsm_a_rr_bandwidth_fdd, tvb, bit_offset, 3, FALSE);
1143                bit_offset += 3;
1144             }
1145             else
1146                bit_offset += 1;
1147             proto_tree_add_bits_item(subtree, hf_gsm_a_rr_fdd_uarfcn, tvb, bit_offset, 14, FALSE);
1148             bit_offset += 14;
1149             if (tvb_get_bits8(tvb,bit_offset,1))
1150             {
1151                bit_offset += 1;
1152                xdd_indic0 = tvb_get_bits8(tvb,bit_offset,1);
1153                proto_tree_add_text(subtree,tvb, bit_offset>>3, 1, "FDD Indic0: %d", xdd_indic0);
1154                bit_offset += 1;
1155                idx = tvb_get_bits8(tvb,bit_offset,5);
1156                proto_tree_add_text(subtree,tvb, bit_offset>>3, 1, "Nr of FDD Cells : %d", idx);
1157                bit_offset += 5;
1158                idx = convert_n_to_p[idx];
1159                item2 = proto_tree_add_text(subtree,tvb, bit_offset>>3, (idx>>3)+1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_UTRAN_FDD_DESC].strptr);
1160                subtree2 = proto_item_add_subtree(item2, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_FDD_CELL_INFORMATION_FIELD]);
1161                proto_tree_add_text(subtree2,tvb, bit_offset>>3, (idx>>3)+1, "Field is %d bits long", idx);
1162                if (xdd_indic0)
1163                {
1164                   proto_tree_add_text(subtree2,tvb, bit_offset>>3, 0, "Scrambling Code: %d", 0);
1165                   proto_tree_add_text(subtree2,tvb, bit_offset>>3, 0, "Diversity: %d", 0);
1166                }
1167                if (idx)
1168                {
1169                   wsize = 10;
1170                   nwi = 1;
1171                   jwi = 0;
1172                   i = 1;
1173    
1174                   while (idx > 0)
1175                   {
1176                      w[i] = tvb_get_bits16(tvb, bit_offset, wsize, FALSE);
1177                      bit_offset += wsize;
1178                      idx -= wsize;
1179                      if (w[i] == 0)
1180                      {
1181                         idx = 0;
1182                         break;
1183                      }
1184                      if (++jwi==nwi)
1185                      {
1186                         jwi = 0;
1187                         nwi <<= 1;
1188                         wsize--;
1189                      }
1190                      i++;
1191                   }
1192                   if (idx < 0)
1193                   {
1194                      bit_offset += idx;
1195                   }
1196                   iused = i-1;
1197    
1198                   for (i=1; i <= iused; i++)
1199                   {
1200                      xdd_cell_info = f_k(i, w, 1024);
1201                      proto_tree_add_text(subtree2,tvb, bit_offset>>3, 0, "Scrambling Code: %d", xdd_cell_info & 0x01FF);
1202                      proto_tree_add_text(subtree2,tvb, bit_offset>>3, 0, "Diversity: %d", (xdd_cell_info >> 9) & 0x01);
1203                   }
1204                }
1205             }
1206             else
1207                bit_offset += 1;
1208             value = tvb_get_bits8(tvb,bit_offset,1);
1209             bit_offset += 1;
1210          }
1211          proto_item_set_len(item,((bit_offset-bit_offset_sav)>>3)+1);
1212          break;
1213       case 2: /* UTRAN TDD Description */
1214          bit_offset_sav = bit_offset;
1215          item = proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_UTRAN_TDD_DESC].strptr);
1216          subtree = proto_item_add_subtree(item, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_UTRAN_TDD_DESC]);
1217          value = tvb_get_bits8(tvb,bit_offset,1);
1218          bit_offset += 1;
1219          while (value)
1220          {
1221             if (tvb_get_bits8(tvb,bit_offset,1))
1222             {
1223                bit_offset += 1;
1224                proto_tree_add_bits_item(subtree, hf_gsm_a_rr_bandwidth_tdd, tvb, bit_offset, 3, FALSE);
1225                bit_offset += 3;
1226             }
1227             else
1228                bit_offset += 1;
1229             proto_tree_add_bits_item(subtree, hf_gsm_a_rr_tdd_uarfcn, tvb, bit_offset, 14, FALSE);
1230             bit_offset += 14;
1231             if (tvb_get_bits8(tvb,bit_offset,1))
1232             {
1233                bit_offset += 1;
1234                xdd_indic0 = tvb_get_bits8(tvb,bit_offset,1);
1235                proto_tree_add_text(subtree,tvb, bit_offset>>3, 1, "TDD Indic0: %d", xdd_indic0);
1236                bit_offset += 1;
1237                idx = tvb_get_bits8(tvb,bit_offset,5);
1238                proto_tree_add_text(subtree,tvb, bit_offset>>3, 1, "Nr of TDD Cells : %d", idx);
1239                bit_offset += 5;
1240                idx = convert_n_to_q[idx];
1241                item2 = proto_tree_add_text(subtree,tvb, bit_offset>>3, (idx>>3)+1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_UTRAN_TDD_DESC].strptr);
1242                subtree2 = proto_item_add_subtree(item2, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_TDD_CELL_INFORMATION_FIELD]);
1243                proto_tree_add_text(subtree2,tvb, bit_offset>>3, (idx>>3)+1, "Field is %d bits long", idx);
1244                if (xdd_indic0)
1245                {
1246                   proto_tree_add_text(subtree2,tvb, bit_offset>>3, 0, "Cell Parameter: %d", 0);
1247                   proto_tree_add_text(subtree2,tvb, bit_offset>>3, 0, "Sync Case TSTD: %d", 0);
1248                   proto_tree_add_text(subtree2,tvb, bit_offset>>3, 0, "Diversity TDD: %d", 0);
1249                }
1250                if (idx)
1251                {
1252                   wsize = 9;
1253                   nwi = 1;
1254                   jwi = 0;
1255                   i = 1;
1256    
1257                   while (idx > 0)
1258                   {
1259                      w[i] = tvb_get_bits16(tvb, bit_offset, wsize, FALSE);
1260                      bit_offset += wsize;
1261                      idx -= wsize;
1262                      if (w[i] == 0)
1263                      {
1264                         idx = 0;
1265                         break;
1266                      }
1267                      if (++jwi==nwi)
1268                      {
1269                         jwi = 0;
1270                         nwi <<= 1;
1271                         wsize--;
1272                      }
1273                      i++;
1274                   }
1275                   if (idx < 0)
1276                   {
1277                      bit_offset += idx;
1278                   }
1279                   iused = i-1;
1280    
1281                   for (i=1; i <= iused; i++)
1282                   {
1283                      xdd_cell_info = f_k(i, w, 512);
1284                      proto_tree_add_text(subtree2,tvb, bit_offset>>3, 0, "Cell Parameter: %d", xdd_cell_info & 0x07F);
1285                      proto_tree_add_text(subtree2,tvb, bit_offset>>3, 0, "Sync Case TSTD: %d", (xdd_cell_info >> 7) & 0x01);
1286                      proto_tree_add_text(subtree2,tvb, bit_offset>>3, 0, "Diversity TDD: %d", (xdd_cell_info >> 8) & 0x01);
1287                   }
1288                }
1289             }
1290             else
1291                bit_offset += 1;
1292             value = tvb_get_bits8(tvb,bit_offset,1);
1293             bit_offset += 1;
1294          }
1295          proto_item_set_len(item,((bit_offset-bit_offset_sav)>>3)+1);
1296          break;
1297       default:
1298          break;
1299    }
1300
1301    curr_offset += length;
1302    return (curr_offset - offset);
1303 }
1304
1305 /*
1306  * [3] 10.5.2.2 Cell Description
1307  */
1308 guint8
1309 de_rr_cell_dsc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1310 {
1311         proto_tree      *subtree;
1312         proto_item      *item;
1313         guint8  oct;
1314         guint32 curr_offset;
1315         guint16 bcch_arfcn;
1316
1317         curr_offset = offset;
1318
1319         oct = tvb_get_guint8(tvb, curr_offset);
1320         item =
1321                 proto_tree_add_text(tree,
1322                         tvb, curr_offset, 2, "%s",
1323                         gsm_rr_elem_strings[DE_RR_CELL_DSC].strptr);
1324
1325         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_CELL_DSC]);
1326
1327         proto_tree_add_item(subtree, hf_gsm_a_ncc, tvb, curr_offset, 1, FALSE);
1328         proto_tree_add_item(subtree, hf_gsm_a_bcc, tvb, curr_offset, 1, FALSE);
1329         bcch_arfcn = (tvb_get_guint8(tvb,curr_offset) & 0xc0) << 2;
1330         bcch_arfcn = bcch_arfcn | tvb_get_guint8(tvb,curr_offset+1);
1331         proto_tree_add_uint(subtree, hf_gsm_a_bcch_arfcn , tvb, curr_offset, 2, bcch_arfcn );
1332
1333         curr_offset = curr_offset + 2;
1334
1335         return(curr_offset - offset);
1336 }
1337
1338 /*
1339  * [3] 10.5.2.3 Cell Options (BCCH)
1340  */
1341 static const value_string gsm_a_rr_dtx_bcch_vals[] = {
1342         { 0x00, "The MSs may use uplink discontinuous transmission" },
1343         { 0x01, "The MSs shall use uplink discontinuous transmission" },
1344         { 0x02, "The MSs shall not use uplink discontinuous transmission" },
1345         { 0x03, "Reserved" },
1346         { 0,    NULL } };
1347
1348 static const value_string gsm_a_rr_radio_link_timeout_vals[] = {
1349         { 0x00, "4" },
1350         { 0x01, "8" },
1351         { 0x02, "12" },
1352         { 0x03, "16" },
1353         { 0x04, "20" },
1354         { 0x05, "24" },
1355         { 0x06, "28" },
1356         { 0x07, "32" },
1357         { 0x08, "36" },
1358         { 0x09, "40" },
1359         { 0x0A, "44" },
1360         { 0x0B, "48" },
1361         { 0x0C, "52" },
1362         { 0x0D, "56" },
1363         { 0x0E, "60" },
1364         { 0x0F, "64" },
1365         { 0,    NULL } };
1366
1367 static guint8
1368 de_rr_cell_opt_bcch(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1369 {
1370         proto_tree      *subtree;
1371         proto_item      *item;
1372         guint32 curr_offset;
1373
1374         curr_offset = offset;
1375
1376         item = proto_tree_add_text(tree, tvb, curr_offset, 1, "%s",
1377                 gsm_rr_elem_strings[DE_RR_CELL_OPT_BCCH].strptr);
1378
1379         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_CELL_OPT_BCCH]);
1380
1381         proto_tree_add_bits_item(subtree, hf_gsm_a_rr_pwrc, tvb, (curr_offset<<3)+1, 1, FALSE);
1382         proto_tree_add_item(subtree, hf_gsm_a_rr_dtx_bcch, tvb, curr_offset, 1, FALSE);
1383         proto_tree_add_item(subtree, hf_gsm_a_rr_radio_link_timeout, tvb, curr_offset, 1, FALSE);
1384
1385         curr_offset = curr_offset + 1;
1386
1387         return(curr_offset - offset);
1388 }
1389
1390 /*
1391  * [3] 10.5.2.3a Cell Options (SACCH)
1392  */
1393 static const value_string gsm_a_rr_dtx_sacch_vals[] = {
1394         { 0x00, "The MS may use uplink discontinuous transmission on a TCH-F. The MS shall not use uplink discontinuous transmission on TCH-H" },
1395         { 0x01, "The MS shall use uplink discontinuous transmission on a TCH-F. The MS shall not use uplink discontinuous transmission on TCH-H" },
1396         { 0x02, "The MS shall not use uplink discontinuous transmission on a TCH-F. The MS shall not use uplink discontinuous transmission on TCH-H" },
1397         { 0x03, "The MS shall use uplink discontinuous transmission on a TCH-F. The MS may use uplink discontinuous transmission on TCH-H" },
1398         { 0x04, "The MS may use uplink discontinuous transmission on a TCH-F. The MS may use uplink discontinuous transmission on TCH-H" },
1399         { 0x05, "The MS shall use uplink discontinuous transmission on a TCH-F. The MS shall use uplink discontinuous transmission on TCH-H" },
1400         { 0x06, "The MS shall not use uplink discontinuous transmission on a TCH-F. The MS shall use uplink discontinuous transmission on TCH-H" },
1401         { 0x07, "The MS may use uplink discontinuous transmission on a TCH-F. The MS shall use uplink discontinuous transmission on TCH-H" },
1402         { 0,    NULL } };
1403
1404 static guint8
1405 de_rr_cell_opt_sacch(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1406 {
1407         proto_tree      *subtree;
1408         proto_item      *item;
1409         guint8  oct;
1410         guint8  dtx;
1411         guint32 curr_offset;
1412
1413         curr_offset = offset;
1414
1415         oct = tvb_get_guint8(tvb, curr_offset);
1416         dtx = ((oct&0x80)>>5)|((oct&0x30)>>4); /* DTX is a split filed in bits 8, 6 and 5 */
1417         item = proto_tree_add_text(tree, tvb, curr_offset, 1, "%s",
1418                 gsm_rr_elem_strings[DE_RR_CELL_OPT_SACCH].strptr);
1419
1420         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_CELL_OPT_SACCH]);
1421
1422         proto_tree_add_bits_item(subtree, hf_gsm_a_rr_pwrc, tvb, (curr_offset<<3)+1, 1, FALSE);
1423         proto_tree_add_uint(subtree, hf_gsm_a_rr_dtx_sacch, tvb, curr_offset, 1, dtx);
1424         proto_tree_add_item(subtree, hf_gsm_a_rr_radio_link_timeout, tvb, curr_offset, 1, FALSE);
1425
1426         curr_offset = curr_offset + 1;
1427
1428         return(curr_offset - offset);
1429 }
1430
1431 /*
1432  * [3] 10.5.2.4 Cell Selection Parameters
1433  */
1434 static guint8
1435 de_rr_cell_sel_param(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1436 {
1437         proto_tree      *subtree;
1438         proto_item      *item;
1439         guint8  oct;
1440         guint32 curr_offset;
1441
1442         curr_offset = offset;
1443
1444         oct = tvb_get_guint8(tvb, curr_offset);
1445         item = proto_tree_add_text(tree, tvb, curr_offset, 2, "%s",
1446                 gsm_rr_elem_strings[DE_RR_CELL_SEL_PARAM].strptr);
1447
1448         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_CELL_SEL_PARAM]);
1449
1450         proto_tree_add_item(subtree, hf_gsm_a_rr_cell_reselect_hyst, tvb, curr_offset, 1, FALSE);
1451         proto_tree_add_item(subtree, hf_gsm_a_rr_ms_txpwr_max_cch, tvb, curr_offset, 1, FALSE);
1452
1453         curr_offset = curr_offset + 1;
1454
1455         proto_tree_add_item(subtree, hf_gsm_a_rr_acs, tvb, curr_offset, 1, FALSE);
1456         proto_tree_add_item(subtree, hf_gsm_a_rr_neci, tvb, curr_offset, 1, FALSE);
1457         proto_tree_add_item(subtree, hf_gsm_a_rr_rxlev_access_min, tvb, curr_offset, 1, FALSE);
1458
1459         curr_offset = curr_offset + 1;
1460
1461         return(curr_offset - offset);
1462 }
1463
1464 /*
1465  * [3] 10.5.2.4a MAC Mode and Channel Coding Requested
1466  * [3] 10.5.2.5 Channel Description
1467  */
1468 guint8
1469 de_rr_ch_dsc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1470 {
1471         guint32 curr_offset;
1472         guint8  oct8,subchannel;
1473         guint16 arfcn, hsn, maio;
1474         proto_tree      *subtree;
1475         proto_item      *item;
1476         const gchar *str;
1477
1478         curr_offset = offset;
1479
1480         item = proto_tree_add_text(tree,tvb, curr_offset, 3, "%s", gsm_rr_elem_strings[DE_RR_CH_DSC].strptr);
1481
1482         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_CH_DSC]);
1483
1484         /* Octet 2 */
1485         oct8 = tvb_get_guint8(tvb, curr_offset);
1486
1487         if ((oct8 & 0xf8) == 0x08)
1488         {
1489                 str = "TCH/F + ACCHs";
1490                 other_decode_bitfield_value(a_bigbuf, oct8, 0xf8, 8);
1491                 proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = %s",a_bigbuf,str);
1492         }
1493         else
1494         {
1495                 if ((oct8 & 0xf0) == 0x10)
1496                 {
1497                         str = "TCH/H + ACCHs, Subchannel";
1498                         subchannel = ((oct8 & 0x08)>>3);
1499                 }
1500                 else if ((oct8 & 0xe0) == 0x20)
1501                 {
1502                         str = "SDCCH/4 + SACCH/C4 or CBCH (SDCCH/4), Subchannel";
1503                         subchannel = ((oct8 & 0x18)>>3);
1504                 }
1505                 else if ((oct8 & 0xc0) == 0x40)
1506                 {
1507                         str = "SDCCH/8 + SACCH/C8 or CBCH (SDCCH/8), Subchannel";
1508                         subchannel = ((oct8 % 0x38)>>3);
1509                 } else {
1510                         str = "";
1511                         subchannel = 0;
1512                         DISSECTOR_ASSERT_NOT_REACHED();
1513                 }
1514         
1515                 other_decode_bitfield_value(a_bigbuf, oct8, 0xf8, 8);
1516                 proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = %s %d",a_bigbuf,str,subchannel);
1517         }
1518
1519         other_decode_bitfield_value(a_bigbuf, oct8, 0x07, 8);
1520         proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Timeslot: %d",a_bigbuf,(oct8 & 0x07));
1521
1522         curr_offset +=1;
1523         
1524         /* Octet 3 */
1525         oct8 = tvb_get_guint8(tvb, curr_offset);
1526         other_decode_bitfield_value(a_bigbuf, oct8, 0xe0, 8);
1527         proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Training Sequence: %d",a_bigbuf,((oct8 & 0xe0)>>5));
1528         
1529
1530         if ((oct8 & 0x10) == 0x10)
1531         {
1532                 /* Hopping sequence */
1533                 maio = ((oct8 & 0x0f)<<2) | ((tvb_get_guint8(tvb,curr_offset+1) & 0xc0) >> 6);
1534                 hsn = (tvb_get_guint8(tvb,curr_offset+1) & 0x3f);
1535                 str = "Yes";
1536
1537                 other_decode_bitfield_value(a_bigbuf, oct8, 0x10, 8);
1538                 proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Hopping channel: %s",a_bigbuf,str);
1539                 proto_tree_add_text(subtree,tvb, curr_offset, 2,"Hopping channel: MAIO %d",maio);
1540                 proto_tree_add_text(subtree,tvb, curr_offset, 2,"Hopping channel: HSN %d",hsn);
1541         }
1542         else
1543         {
1544                 /* single ARFCN */
1545                 arfcn = ((oct8 & 0x03) << 8) | tvb_get_guint8(tvb,curr_offset+1);
1546                 str = "No";
1547
1548                 other_decode_bitfield_value(a_bigbuf, oct8, 0x10, 8);
1549                 proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Hopping channel: %s",a_bigbuf,str);
1550                 other_decode_bitfield_value(a_bigbuf, oct8, 0x0c, 8);
1551                 proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Spare",a_bigbuf);
1552                 proto_tree_add_text(subtree,tvb, curr_offset, 2,"Single channel : ARFCN %d",arfcn);
1553         }
1554         
1555         curr_offset = curr_offset + 2;
1556
1557         return(curr_offset - offset);
1558 }
1559 /*
1560  * [3] 10.5.2.5a Channel Description 2
1561  */
1562 static guint8
1563 de_rr_ch_dsc2(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1564 {
1565         guint32 curr_offset;
1566         guint8  oct8,subchannel;
1567         guint16 arfcn, hsn, maio;
1568         proto_tree      *subtree;
1569         proto_item      *item;
1570         const gchar *str;
1571
1572         curr_offset = offset;
1573
1574         item = proto_tree_add_text(tree,tvb, curr_offset, 3, "%s", gsm_rr_elem_strings[DE_RR_CH_DSC2].strptr);
1575
1576         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_CH_DSC2]);
1577
1578         /* Octet 2 */
1579         oct8 = tvb_get_guint8(tvb, curr_offset);
1580
1581         if ((oct8 & 0xf8) == 0x0)
1582         {
1583                 str = "TCH/F + FACCH/F and SACCH/M";
1584                 other_decode_bitfield_value(a_bigbuf, oct8, 0xf8, 8);
1585                 proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = %s",a_bigbuf,str);
1586         }
1587         else if ((oct8 & 0xf8) == 0x08)
1588         {
1589                 str = "TCH/F + FACCH/F and SACCH/F";
1590                 other_decode_bitfield_value(a_bigbuf, oct8, 0xf8, 8);
1591                 proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = %s",a_bigbuf,str);
1592         }
1593         else if ((oct8 & 0xf8) == 0xf0)
1594         {
1595                 str = "TCH/F + FACCH/F and SACCH/M + bi- and unidirectional channels";
1596                 other_decode_bitfield_value(a_bigbuf, oct8, 0xf8, 8);
1597                 proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = %s",a_bigbuf,str);
1598         }
1599         else
1600         {
1601                 if ((oct8 & 0xf0) == 0x10)
1602                 {
1603                         str = "TCH/H + ACCHs, Subchannel";
1604                         subchannel = ((oct8 & 0x08)>>3);
1605                 }
1606                 else if ((oct8 & 0xe0) == 0x20)
1607                 {
1608                         str = "SDCCH/4 + SACCH/C4 or CBCH (SDCCH/4), Subchannel";
1609                         subchannel = ((oct8 & 0x18)>>3);
1610                 }
1611                 else if ((oct8 & 0xc0) == 0x40)
1612                 {
1613                         str = "SDCCH/8 + SACCH/C8 or CBCH (SDCCH/8), Subchannel";
1614                         subchannel = ((oct8 % 0x38)>>3);
1615                 }
1616                 else if ((oct8 & 0xc0) == 0x80)
1617                 {
1618                         str = "TCH/F + FACCH/F and SACCH/M + bidirectional channels at timeslot";
1619                         subchannel = ((oct8 % 0x38)>>3);
1620                 }
1621                 else if ((oct8 & 0xe0) == 0xc0)
1622                 {
1623                         str = "TCH/F + FACCH/F and SACCH/M + unidirectional channels at timeslot";
1624                         subchannel = ((oct8 % 0x38)>>3);
1625                 } else {
1626                         str = "";
1627                         subchannel = 0;
1628                         DISSECTOR_ASSERT_NOT_REACHED();
1629                 }
1630                 other_decode_bitfield_value(a_bigbuf, oct8, 0xf8, 8);
1631                 proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = %s %d",a_bigbuf,str,subchannel);
1632         }
1633
1634         other_decode_bitfield_value(a_bigbuf, oct8, 0x07, 8);
1635         proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Timeslot: %d",a_bigbuf,(oct8 & 0x07));
1636
1637         curr_offset +=1;
1638         
1639         /* Octet 3 */
1640         oct8 = tvb_get_guint8(tvb, curr_offset);
1641         other_decode_bitfield_value(a_bigbuf, oct8, 0xe0, 8);
1642         proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Training Sequence: %d",a_bigbuf,((oct8 & 0xe0)>>5));
1643
1644         if ((oct8 & 0x10) == 0x10)
1645         {
1646                 /* Hopping sequence */
1647                 maio = ((oct8 & 0x0f)<<2) | ((tvb_get_guint8(tvb,curr_offset+1) & 0xc0) >> 6);
1648                 hsn = (tvb_get_guint8(tvb,curr_offset+1) & 0x3f);
1649                 str = "Yes";
1650
1651                 other_decode_bitfield_value(a_bigbuf, oct8, 0x10, 8);
1652                 proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Hopping channel: %s",a_bigbuf,str);
1653                 proto_tree_add_text(subtree,tvb, curr_offset, 2,"Hopping channel: MAIO %d",maio);
1654                 proto_tree_add_text(subtree,tvb, curr_offset, 2,"Hopping channel: HSN %d",hsn);
1655         }
1656         else
1657         {
1658                 /* single ARFCN */
1659                 arfcn = ((oct8 & 0x03) << 8) | tvb_get_guint8(tvb,curr_offset+1);
1660                 str = "No";
1661
1662                 other_decode_bitfield_value(a_bigbuf, oct8, 0x10, 8);
1663                 proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Hopping channel: %s",a_bigbuf,str);
1664                 other_decode_bitfield_value(a_bigbuf, oct8, 0x0c, 8);
1665                 proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Spare",a_bigbuf);
1666                 proto_tree_add_text(subtree,tvb, curr_offset, 2,"Single channel : ARFCN %d",arfcn);
1667         }
1668         
1669         curr_offset = curr_offset + 2;
1670
1671         return(curr_offset - offset);
1672 }
1673
1674 /*
1675  * [3] 10.5.2.5c Channel Description 3
1676  */
1677 static guint8
1678 de_rr_ch_dsc3(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1679 {
1680         guint32 curr_offset;
1681         guint8  oct8;
1682         guint16 arfcn, hsn, maio;
1683         proto_tree      *subtree;
1684         proto_item      *item;
1685         const gchar *str;
1686
1687         curr_offset = offset;
1688
1689         item = proto_tree_add_text(tree,tvb, curr_offset, 3, "%s", gsm_rr_elem_strings[DE_RR_CH_DSC3].strptr);
1690
1691         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_CH_DSC3]);
1692
1693         /* Octet 2 */
1694         oct8 = tvb_get_guint8(tvb, curr_offset);
1695         other_decode_bitfield_value(a_bigbuf, oct8, 0xe0, 8);
1696         proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Training Sequence: %d",a_bigbuf,((oct8 & 0xe0)>>5));
1697
1698         if ((oct8 & 0x10) == 0x10)
1699         {
1700                 /* Hopping sequence */
1701                 maio = ((oct8 & 0x0f)<<2) | ((tvb_get_guint8(tvb,curr_offset+1) & 0xc0) >> 6);
1702                 hsn = (tvb_get_guint8(tvb,curr_offset+1) & 0x3f);
1703                 str = "Yes";
1704
1705                 other_decode_bitfield_value(a_bigbuf, oct8, 0x10, 8);
1706                 proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Hopping channel: %s",a_bigbuf,str);
1707                 proto_tree_add_text(subtree,tvb, curr_offset, 2,"Hopping channel: MAIO %d",maio);
1708                 proto_tree_add_text(subtree,tvb, curr_offset, 2,"Hopping channel: HSN %d",hsn);
1709         }
1710         else
1711         {
1712                 /* single ARFCN */
1713                 arfcn = ((oct8 & 0x03) << 8) | tvb_get_guint8(tvb,curr_offset+1);
1714                 str = "No";
1715
1716                 other_decode_bitfield_value(a_bigbuf, oct8, 0x10, 8);
1717                 proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Hopping channel: %s",a_bigbuf,str);
1718                 other_decode_bitfield_value(a_bigbuf, oct8, 0x0c, 8);
1719                 proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Spare",a_bigbuf);
1720                 proto_tree_add_text(subtree,tvb, curr_offset, 2,"Single channel : ARFCN %d",arfcn);
1721         }
1722         
1723         curr_offset = curr_offset + 2;
1724
1725         return(curr_offset - offset);
1726 }
1727
1728 /*
1729  * [3] 10.5.2.6 Channel Mode
1730  */
1731 /* Channel Mode  */
1732 static const value_string gsm_a_rr_channel_mode_vals[] = {
1733         { 0x00, "signalling only"},
1734         { 0x01, "speech full rate or half rate version 1(GSM FR or GSM HR)"},
1735         { 0x21, "speech full rate or half rate version 2(GSM EFR)"},
1736         { 0x41, "speech full rate or half rate version 3(FR AMR or HR AMR)"},
1737         { 0x81, "speech full rate or half rate version 4(OFR AMR-WB or OHR AMR-WB)"},
1738         { 0x82, "speech full rate or half rate version 5(FR AMR-WB )"},
1739         { 0x83, "speech full rate or half rate version 6(OHR AMR )"},
1740         { 0x61, "data, 43.5 kbit/s (downlink)+14.5 kbps (uplink)"},
1741         { 0x62, "data, 29.0 kbit/s (downlink)+14.5 kbps (uplink)"},
1742         { 0x64, "data, 43.5 kbit/s (downlink)+29.0 kbps (uplink)"},
1743         { 0x67, "data, 14.5 kbit/s (downlink)+43.5 kbps (uplink)"},
1744         { 0x65, "data, 14.5 kbit/s (downlink)+29.0 kbps (uplink)"},
1745         { 0x66, "data, 29.0 kbit/s (downlink)+43.5 kbps (uplink)"},
1746         { 0x27, "data, 43.5 kbit/s radio interface rate"},
1747         { 0x63, "data, 32.0 kbit/s radio interface rate"},
1748         { 0x43, "data, 29.0 kbit/s radio interface rate"},
1749         { 0x0f, "data, 14.5 kbit/s radio interface rate"},
1750         { 0x03, "data, 12.0 kbit/s radio interface rate"},
1751         { 0x0b, "data, 6.0 kbit/s radio interface rate"},
1752         { 0x13, "data, 3.6 kbit/s radio interface rate"},
1753         { 0,    NULL }
1754 };
1755
1756 guint8
1757 de_rr_ch_mode(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1758 {
1759         guint32 curr_offset;
1760
1761         curr_offset = offset;
1762
1763         proto_tree_add_item(tree, hf_gsm_a_rr_channel_mode, tvb, curr_offset, 1, FALSE);
1764
1765         curr_offset = curr_offset + 1;
1766
1767         return(curr_offset - offset);
1768 }
1769 /*
1770  * [3] 10.5.2.7 Channel Mode 2
1771  */
1772
1773 static const value_string gsm_a_rr_channel_mode2_vals[] = {
1774         { 0x00, "signalling only"},
1775         { 0x05, "speech half rate version 1(GSM HR)"},
1776         { 0x25, "speech half rate version 2(GSM EFR)"},
1777         { 0x45, "speech half rate version 3(HR AMR)"},
1778         { 0x85, "speech half rate version 4(OHR AMR-WB)"},
1779         { 0x06, "speech half rate version 6(OHR AMR )"},
1780         { 0x0f, "data, 6.0 kbit/s radio interface rate"},
1781         { 0x17, "data, 3.6 kbit/s radio interface rate"},
1782         { 0,    NULL }
1783 };
1784
1785 static guint8
1786 de_rr_ch_mode2(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1787 {
1788         guint32 curr_offset;
1789
1790         curr_offset = offset;
1791
1792         proto_tree_add_item(tree, hf_gsm_a_rr_channel_mode2, tvb, curr_offset, 1, FALSE);
1793
1794         curr_offset = curr_offset + 1;
1795
1796         return(curr_offset - offset);
1797 }
1798 /*
1799  * [3] 10.5.2.7a UTRAN Classmark information element
1800  */
1801 static guint8
1802 de_rr_utran_cm(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
1803 {
1804    guint32 curr_offset;
1805    tvbuff_t *rrc_irat_ho_info_tvb;
1806    static packet_info p_info;
1807
1808    curr_offset = offset;
1809    if (len)
1810    {
1811       rrc_irat_ho_info_tvb = tvb_new_subset(tvb, curr_offset, len, len);
1812       if (rrc_irat_ho_info_handle)
1813          call_dissector(rrc_irat_ho_info_handle, rrc_irat_ho_info_tvb, &p_info, tree);
1814    }
1815
1816    curr_offset += len;
1817    return(curr_offset - offset);
1818 }
1819
1820 /*
1821  * [3] 10.5.2.7b (void)
1822  */
1823
1824 /*
1825  * [3] 10.5.2.7c Classmark Enquiry Mask
1826  * Bit 8:
1827  * 0    CLASSMARK CHANGE message is requested
1828  * 1    CLASSMARK CHANGE message is not requested
1829  * Bits 7-5 . 5
1830  * 000  UTRAN CLASSMARK CHANGE message including status on predefined configurations (i.e. Sequence Description) is requested
1831  * 111  UTRAN CLASSMARK CHANGE message including status on predefined configurations (i.e. Sequence Description) is not requested.
1832  * All other values shall not be sent. If received, they shall be interpreted as '000'.
1833  * Bit 4:
1834  * 0    CDMA2000 CLASSMARK CHANGE message requested
1835  * 1    CDMA2000 CLASSMARK CHANGE message not requested.
1836  * Bit 3:
1837  * 0    GERAN IU MODE CLASSMARK CHANGE message requested
1838  * 1    GERAN IU MODE CLASSMARK CHANGE message not requested.
1839  * Bits 2 - 1: spare(0).
1840  */
1841 static const true_false_string gsm_a_msg_req_value  = {
1842         "message is not requested",
1843         "message is requested"
1844 };
1845
1846 static const value_string gsm_a_rr_utran_cm_cng_msg_req_vals[] = {
1847         { 0x0,  "message including status on predefined configurations (i.e. Sequence Description) is requested"},
1848         { 0x1,  "message including status on predefined configurations (i.e. Sequence Description) is requested"},
1849         { 0x2,  "message including status on predefined configurations (i.e. Sequence Description) is requested"},
1850         { 0x3,  "message including status on predefined configurations (i.e. Sequence Description) is requested"},
1851         { 0x4,  "message including status on predefined configurations (i.e. Sequence Description) is requested"},
1852         { 0x5,  "message including status on predefined configurations (i.e. Sequence Description) is requested"},
1853         { 0x6,  "message including status on predefined configurations (i.e. Sequence Description) is requested"},
1854         { 0x7,  "message including status on predefined configurations (i.e. Sequence Description) is not requested."},
1855         { 0,    NULL }
1856 };
1857 guint8
1858 de_rr_cm_enq_mask(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1859 {
1860         guint32 curr_offset;
1861
1862         curr_offset = offset;
1863
1864         proto_tree_add_item(tree, hf_gsm_a_rr_cm_cng_msg_req, tvb, curr_offset, 1, FALSE);
1865         proto_tree_add_item(tree, hf_gsm_a_rr_utran_cm_cng_msg_req, tvb, curr_offset, 1, FALSE);
1866         proto_tree_add_item(tree, hf_gsm_a_rr_cdma200_cm_cng_msg_req, tvb, curr_offset, 1, FALSE);
1867         proto_tree_add_item(tree, hf_gsm_a_rr_geran_iu_cm_cng_msg_req, tvb, curr_offset, 1, FALSE);
1868
1869         curr_offset = curr_offset + 1;
1870
1871         return(curr_offset - offset);
1872 }
1873 /*
1874  * [3] 10.5.2.8 Channel Needed
1875  */
1876 static const value_string gsm_a_rr_channel_needed_vals[] = {
1877         { 0x00, "Any channel"},
1878         { 0x01, "SDCCH"},
1879         { 0x02, "TCH/F (Full rate)"},
1880         { 0x03, "TCH/H or TCH/F (Dual rate)"},
1881         { 0,    NULL }
1882 };
1883 guint8
1884 de_rr_chnl_needed(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1885 {
1886         proto_tree      *subtree;
1887         proto_item      *item;
1888         guint32 curr_offset;
1889         gint bit_offset;
1890
1891         curr_offset = offset;
1892         if (UPPER_NIBBLE==len)
1893                 bit_offset = 4;
1894         else
1895                 bit_offset = 0;
1896
1897         item = proto_tree_add_text(tree, tvb, curr_offset, 3, "%s",
1898                 gsm_rr_elem_strings[DE_RR_CHNL_NEEDED].strptr);
1899
1900         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_CHNL_NEEDED]);
1901
1902         proto_tree_add_bits_item(subtree, hf_gsm_a_rr_chnl_needed_ch1, tvb, (curr_offset<<3)+bit_offset+2, 2, FALSE);
1903    proto_tree_add_bits_item(subtree, hf_gsm_a_rr_chnl_needed_ch2, tvb, (curr_offset<<3)+bit_offset, 2, FALSE);
1904
1905         curr_offset = curr_offset + 1;
1906
1907         return(curr_offset - offset);
1908 }
1909 /*
1910  * [3] 10.5.2.8a Channel Request Description
1911  * [3] 10.5.2.8b Channel Request Description 2
1912  */
1913 /*
1914  * [3] 10.5.2.9 Cipher Mode Setting
1915  */
1916 /* SC (octet 1) */
1917 static const value_string gsm_a_rr_sc_vals[] = {
1918         { 0,    "No ciphering"},
1919         { 1,    "Start ciphering"},
1920         { 0,    NULL }
1921 };
1922 /* algorithm identifier
1923  * If SC=1 then:
1924  * bits
1925  * 4 3 2
1926  */
1927 guint8
1928 de_rr_cip_mode_set(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
1929 {
1930         guint32 curr_offset;
1931         gint bit_offset;
1932         guint64 value;
1933
1934         curr_offset = offset;
1935
1936         /* Cipher Mode Setting
1937          * Note: The coding of fields SC and algorithm identifier is defined in [44.018]
1938          * as part of the Cipher Mode Setting IE.
1939          */
1940         if (UPPER_NIBBLE==len)
1941                 bit_offset = 4;
1942         else
1943                 bit_offset = 0;
1944
1945         proto_tree_add_bits_ret_val(tree, hf_gsm_a_rr_sc, tvb, (curr_offset<<3)+bit_offset+3, 1, &value, FALSE);
1946         if (value == 1){ /* Start ciphering */
1947                 /* algorithm identifier */
1948                 proto_tree_add_bits_item(tree, hf_gsm_a_algorithm_id, tvb, (curr_offset<<3)+bit_offset, 3, FALSE);
1949         }
1950         curr_offset = curr_offset + 1;
1951
1952         return(curr_offset - offset);
1953 }
1954 /*
1955  * [3] 10.5.2.10 Cipher Response
1956  */
1957 /* CR (octet 1) */
1958 static const value_string gsm_a_rr_cr_vals[] = {
1959         { 0,            "IMEISV shall not be included"},
1960         { 1,            "IMEISV shall be included"},
1961         { 0,    NULL }
1962 };
1963
1964 static guint8
1965 de_rr_cip_mode_resp(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
1966 {
1967         guint32 curr_offset;
1968         gint bit_offset;
1969
1970         curr_offset = offset;
1971         if (UPPER_NIBBLE==len)
1972                 bit_offset = 4;
1973         else
1974                 bit_offset = 0;
1975
1976         /* Cipher Mode Response
1977                  * Note: The coding of field CR is defined in [44.018]
1978                  * as part of the Cipher Mode Response IE.
1979                  */
1980         proto_tree_add_bits_item(tree, hf_gsm_a_rr_cr, tvb, (curr_offset<<3)+bit_offset+3, 1, FALSE);
1981         curr_offset = curr_offset + 1;
1982
1983         return(curr_offset - offset);
1984 }
1985 /* [3] 10.5.2.11 Control Channel Description */
1986
1987 static const value_string gsm_a_rr_mscr_vals[] = {
1988         { 0,    "MSC is Release '98 or older"},
1989         { 1,    "MSC is Release '99 onwards"},
1990         { 0,    NULL }
1991 };
1992
1993 static const value_string gsm_a_rr_att_vals[] = {
1994         { 0,    "MSs in the cell are not allowed to apply IMSI attach and detach procedure"},
1995         { 1,    "MSs in the cell shall apply IMSI attach and detach procedure"},
1996         { 0,    NULL }
1997 };
1998
1999 static const value_string gsm_a_rr_ccch_conf_vals[] = {
2000         { 0,    "1 basic physical channel used for CCCH, not combined with SDCCHs"},
2001         { 1,    "1 basic physical channel used for CCCH, combined with SDCCHs"},
2002         { 2,    "2 basic physical channels used for CCCH, not combined with SDCCHs"},
2003         { 3,    "Reserved"},
2004         { 4,    "3 basic physical channels used for CCCH, not combined with SDCCHs"},
2005         { 5,    "Reserved"},
2006         { 6,    "4 basic physical channels used for CCCH, not combined with SDCCHs"},
2007         { 7,    "Reserved"},
2008         { 0,    NULL }
2009 };
2010
2011 static const value_string gsm_a_rr_cbq3_vals[] = {
2012         { 0,    "Iu mode not supported"},
2013         { 1,    "Iu mode capable MSs barred"},
2014         { 2,    "Iu mode supported, cell not barred"},
2015         { 3,    "Iu mode supported, cell not barred"},
2016         { 0,    NULL }
2017 };
2018
2019 static guint8
2020 de_rr_ctrl_ch_desc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2021 {
2022         proto_tree      *subtree;
2023         proto_item      *item;
2024         guint8  oct;
2025         guint32 curr_offset;
2026
2027         curr_offset = offset;
2028
2029         item = proto_tree_add_text(tree, tvb, curr_offset, 3, "%s",
2030                 gsm_rr_elem_strings[DE_RR_CTRL_CH_DESC].strptr);
2031
2032         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_CTRL_CH_DESC]);
2033
2034         proto_tree_add_item(subtree, hf_gsm_a_rr_mscr, tvb, curr_offset, 1, FALSE);
2035         proto_tree_add_item(subtree, hf_gsm_a_rr_att, tvb, curr_offset, 1, FALSE);
2036         proto_tree_add_item(subtree, hf_gsm_a_rr_bs_ag_blks_res, tvb, curr_offset, 1, FALSE);
2037         proto_tree_add_item(subtree, hf_gsm_a_rr_ccch_conf, tvb, curr_offset, 1, FALSE);
2038
2039         curr_offset = curr_offset + 1;
2040         oct = tvb_get_guint8(tvb, curr_offset);
2041
2042    proto_tree_add_bits_item(subtree, hf_gsm_a_rr_cbq3, tvb, (curr_offset<<3)+1, 2, FALSE);
2043         proto_tree_add_uint(subtree, hf_gsm_a_rr_bs_pa_mfrms, tvb, curr_offset, 1, (oct&0x07)+2);
2044
2045         curr_offset = curr_offset + 1;
2046
2047         proto_tree_add_item(subtree, hf_gsm_a_rr_t3212, tvb, curr_offset, 1, FALSE);
2048
2049         curr_offset = curr_offset + 1;
2050
2051         return(curr_offset - offset);
2052 }
2053
2054 /* [3] 10.5.2.11a DTM Information Details
2055  */
2056 /*
2057  * [3]  10.5.2.11b      Dynamic ARFCN Mapping   
2058  */
2059 static const value_string gsm_a_rr_gsm_band_vals[] = {
2060         { 0,    "GSM 750"},
2061         { 1,    "DCS 1800"},
2062         { 2,    "PCS 1900"},
2063         { 3,    "GSM T 380"},
2064         { 4,    "GSM T 410"},
2065         { 5,    "GSM T 900"},
2066         { 6,    "GSM 710"},
2067         { 7,    "GSM T 810"},
2068         { 8,    "Reserved"},
2069         { 9,    "Reserved"},
2070         { 10,   "Reserved"},
2071         { 11,   "Reserved"},
2072         { 12,   "Reserved"},
2073         { 13,   "Reserved"},
2074         { 14,   "Reserved"},
2075         { 15,   "Reserved"},
2076         { 0,    NULL }
2077 };
2078
2079
2080 static guint8
2081 de_rr_dyn_arfcn_map(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2082 {
2083         guint32 curr_offset;
2084    gint bit_offset;
2085    guint64 length;
2086    guint value;
2087
2088         curr_offset = offset;
2089    bit_offset = curr_offset << 3;
2090
2091    proto_tree_add_bits_ret_val(tree, hf_gsm_a_rr_dyn_arfcn_length, tvb, bit_offset, 8, &length, FALSE);
2092    value = tvb_get_bits8(tvb,bit_offset,1);
2093    bit_offset += 1;
2094    while (value && length)
2095    {
2096       proto_tree_add_bits_item(tree, hf_gsm_a_rr_gsm_band, tvb, bit_offset, 4, FALSE);
2097       bit_offset += 4;
2098       proto_tree_add_bits_item(tree, hf_gsm_a_rr_arfcn_first, tvb, bit_offset, 10, FALSE);
2099       bit_offset += 10;
2100       proto_tree_add_bits_item(tree, hf_gsm_a_rr_band_offset, tvb, bit_offset, 10, FALSE);
2101       bit_offset += 10;
2102       proto_tree_add_bits_item(tree, hf_gsm_a_rr_arfcn_range, tvb, bit_offset, 7, FALSE);
2103       bit_offset += 7;
2104       value = tvb_get_bits8(tvb,bit_offset,1);
2105       bit_offset += 1;
2106       length -= 4;
2107    }
2108
2109         curr_offset = curr_offset + len;
2110
2111         return(curr_offset - offset);
2112 }
2113 /*
2114  * [3] 10.5.2.12 Frequency Channel Sequence
2115  */
2116 static guint8
2117 de_rr_freq_ch_seq(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2118 {
2119         guint32 curr_offset;
2120    gint bit_offset, i;
2121
2122         curr_offset = offset;
2123
2124    proto_tree_add_item(tree, hf_gsm_a_rr_lowest_arfcn, tvb, curr_offset, 1, FALSE);
2125    curr_offset += 1;
2126    bit_offset = curr_offset << 3;
2127    for (i=0; i<16; i++)
2128    {
2129       proto_tree_add_bits_item(tree, hf_gsm_a_rr_inc_skip_arfcn, tvb, bit_offset, 4, FALSE);
2130       bit_offset += 4;
2131    }
2132
2133         curr_offset = curr_offset + 8;
2134
2135         return(curr_offset - offset);
2136 }
2137
2138 /*
2139  * [3] 10.5.2.13 Frequency List
2140  */
2141 /*
2142  * [3] 10.5.2.13 Frequency List
2143  * 
2144  * Bit Bit Bit Bit Bit format notation
2145  * 8 7  4 3 2
2146  * 0 0  X X X bit map 0
2147  * 1 0  0 X X 1024 range
2148  * 1 0  1 0 0 512 range
2149  * 1 0  1 0 1 256 range
2150  * 1 0  1 1 0 128 range
2151  * 1 0  1 1 1 variable bit map
2152  */
2153 /* The mask 0xce (1100 1110) will produce the result 0110 0111*/ 
2154 static const value_string gsm_a_rr_freq_list_format_id_vals[] = {
2155         { 0x00, "bit map 0"},
2156         { 0x02, "bit map 0"},
2157         { 0x04, "bit map 0"},
2158         { 0x06, "bit map 0"},
2159         { 0x08, "bit map 0"},
2160         { 0x0a, "bit map 0"},
2161         { 0x0c, "bit map 0"},
2162         { 0x0e, "bit map 0"},
2163         { 0x40, "1024 range"},
2164         { 0x41, "1024 range"},
2165         { 0x42, "1024 range"},
2166         { 0x43, "1024 range"},
2167         { 0x44, "512 range"},
2168         { 0x45, "256 range"},
2169         { 0x46, "128 range"},
2170         { 0x47, "variable bit map"},
2171         { 0x00, NULL }
2172 };
2173 static guint8
2174 de_rr_freq_list(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2175 {
2176         return dissect_arfcn_list(tvb, tree, offset, len, add_string, string_len);
2177 }
2178 /*
2179  * [3] 10.5.2.14 Frequency Short List
2180  *
2181  *The Frequency Short List information element is a type 3 information element of 10 octet length.
2182  *
2183  * This element is encoded exactly as the Frequency List information element,
2184  * except that it has a fixed length instead of a variable length and does
2185  * not contain a length indicator and that it shall not be encoded in bitmap 0 format.
2186  */
2187
2188  static guint8
2189 de_rr_freq_short_list(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2190 {
2191         return dissect_arfcn_list(tvb, tree, offset, 9, add_string, string_len);
2192 }
2193
2194 /*
2195  * [3] 10.5.2.14a Frequency Short List 2
2196  *
2197  * The Frequency Short List information element is a type 3 information element of 8 octet length.
2198  *
2199  * This element is encoded exactly as the Frequency List information element,
2200  * except that it has a fixed length instead of a variable length and does
2201  * not contain a length indicator and that it shall not be encoded in bitmap 0 format.
2202  */
2203 static guint8
2204 de_rr_freq_short_list2(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2205 {
2206         return dissect_arfcn_list(tvb, tree, offset, 8, add_string, string_len);
2207 }
2208 /*
2209  * [3] 10.5.2.14b Group Channel Description
2210  */
2211
2212 /*
2213  * [3] 10.5.2.14c GPRS Resumption
2214  */
2215 static const true_false_string gsm_a_rr_gprs_resumption_ack_value  = {
2216         "Resumption of GPRS services successfully acknowledged",
2217         "Resumption of GPRS services not successfully acknowledged"
2218 };
2219
2220 static guint8
2221 de_rr_gprs_resumption(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2222 {
2223    guint32 curr_offset;
2224
2225    curr_offset = offset;
2226
2227    proto_tree_add_item(tree, hf_gsm_a_rr_gprs_resumption_ack, tvb, curr_offset, 1, FALSE);
2228    curr_offset += 1;
2229
2230    return (curr_offset - offset);
2231 }
2232
2233 /*
2234  * [3] 10.5.2.14d GPRS broadcast information
2235  */
2236
2237 static gint
2238 de_rr_rest_oct_gprs_cell_options(tvbuff_t *tvb, proto_tree *tree, gint bit_offset)
2239 {
2240    proto_tree *subtree, *subtree2;
2241    proto_item *item, *item2;
2242    gint curr_bit_offset, curr_bit_offset_sav;
2243    guint8 value;
2244
2245    curr_bit_offset = bit_offset;
2246
2247    item = proto_tree_add_text(tree, tvb, curr_bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_GPRS_CELL_OPTIONS].strptr);
2248         subtree = proto_item_add_subtree(item, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_GPRS_CELL_OPTIONS]);
2249    proto_tree_add_bits_item(subtree, hf_gsm_a_rr_nmo, tvb, curr_bit_offset, 2, FALSE);
2250    curr_bit_offset += 2;
2251    proto_tree_add_bits_item(subtree, hf_gsm_a_rr_t3168, tvb, curr_bit_offset, 3, FALSE);
2252    curr_bit_offset += 3;
2253    proto_tree_add_bits_item(subtree, hf_gsm_a_rr_t3192, tvb, curr_bit_offset, 3, FALSE);
2254    curr_bit_offset += 3;
2255    proto_tree_add_bits_item(subtree, hf_gsm_a_rr_drx_timer_max, tvb, curr_bit_offset, 3, FALSE);
2256    curr_bit_offset += 3;
2257    proto_tree_add_bits_item(subtree, hf_gsm_a_rr_access_burst_type, tvb, curr_bit_offset, 1, FALSE);
2258    curr_bit_offset += 1;
2259    proto_tree_add_bits_item(subtree, hf_gsm_a_rr_control_ack_type, tvb, curr_bit_offset, 1, FALSE);
2260    curr_bit_offset += 1;
2261    proto_tree_add_bits_item(subtree, hf_gsm_a_rr_bs_cv_max, tvb, curr_bit_offset, 4, FALSE);
2262    curr_bit_offset += 4;
2263    if (tvb_get_bits8(tvb,curr_bit_offset,1))
2264    {
2265       curr_bit_offset += 1;
2266       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_pan_dec, tvb, curr_bit_offset, 3, FALSE);
2267       curr_bit_offset += 3;
2268       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_pan_inc, tvb, curr_bit_offset, 3, FALSE);
2269       curr_bit_offset += 3;
2270       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_pan_max, tvb, curr_bit_offset, 3, FALSE);
2271       curr_bit_offset += 3;
2272    }
2273    else
2274       curr_bit_offset += 1;
2275    if (tvb_get_bits8(tvb,curr_bit_offset,1))
2276    { /* Optional extension information */
2277       curr_bit_offset += 1;
2278       curr_bit_offset_sav = curr_bit_offset;
2279       item2 = proto_tree_add_text(subtree, tvb, curr_bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_GPRS_CELL_OPTIONS_EXT_INFO].strptr);
2280            subtree2 = proto_item_add_subtree(item2, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_GPRS_CELL_OPTIONS_EXT_INFO]);
2281       value = tvb_get_bits8(tvb,curr_bit_offset,6);
2282       proto_tree_add_text(subtree2,tvb, curr_bit_offset>>3, 1, "Extension Length: %d", value);
2283       curr_bit_offset += 6;
2284       value += 1;
2285       proto_item_set_len(item2,((curr_bit_offset+value-curr_bit_offset_sav)>>3)+1);
2286       if (tvb_get_bits8(tvb,curr_bit_offset,1))
2287       {
2288          curr_bit_offset += 1;
2289          proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_egprs_packet_channel_request, tvb, curr_bit_offset, 1, FALSE);
2290          curr_bit_offset += 1;
2291          proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_bep_period, tvb, curr_bit_offset, 4, FALSE);
2292          curr_bit_offset += 4;
2293          value -= 5;
2294       }
2295       else
2296          curr_bit_offset += 1;
2297       value -= 1;
2298       proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_pfc_feature_mode, tvb, curr_bit_offset, 1, FALSE);
2299       curr_bit_offset += 1;
2300       proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_dtm_support, tvb, curr_bit_offset, 1, FALSE);
2301       curr_bit_offset += 1;
2302       proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_bss_paging_coordination, tvb, curr_bit_offset, 1, FALSE);
2303       curr_bit_offset += 1;
2304       value -= 3;
2305       if (value > 0)
2306       { /* Rel 4 extension */
2307          proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_ccn_active, tvb, curr_bit_offset, 1, FALSE);
2308          curr_bit_offset += 1;
2309          proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_nw_ext_utbf, tvb, curr_bit_offset, 1, FALSE);
2310          curr_bit_offset += 1;
2311          value -= 2;
2312          if (value > 0)
2313          { /* Rel 6 extension */
2314             proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_multiple_tbf_capability, tvb, curr_bit_offset, 1, FALSE);
2315             curr_bit_offset += 1;
2316             proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_ext_utbf_no_data, tvb, curr_bit_offset, 1, FALSE);
2317             curr_bit_offset += 1;
2318             proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_dtm_enhancements_capability, tvb, curr_bit_offset, 1, FALSE);
2319             curr_bit_offset += 1;
2320             value -= 3;
2321             if (tvb_get_bits8(tvb,curr_bit_offset,1))
2322             {
2323                proto_tree_add_bits_item(subtree, hf_gsm_a_rr_dedicated_mode_mbms_notification_support, tvb, bit_offset, 1, FALSE);
2324                bit_offset += 1;
2325                proto_tree_add_bits_item(subtree, hf_gsm_a_rr_mnci_support, tvb, bit_offset, 1, FALSE);
2326                bit_offset += 1;
2327                value -= 2;
2328             }
2329             else
2330                bit_offset += 1;
2331             value -= 1;
2332             if (value > 0)
2333             { /* Rel 7 extension */
2334                proto_tree_add_bits_item(subtree, hf_gsm_a_rr_reduced_latency_access, tvb, bit_offset, 1, FALSE);
2335                bit_offset += 1;
2336                value -= 1;
2337             }
2338          }
2339       }
2340       curr_bit_offset += value;
2341    }
2342    else
2343       curr_bit_offset += 1;
2344    proto_item_set_len(item,((curr_bit_offset-bit_offset)>>3)+1);
2345
2346    return (curr_bit_offset - bit_offset);
2347 }
2348
2349 static gint
2350 de_rr_rest_oct_gprs_power_control_parameters(tvbuff_t *tvb, proto_tree *tree, gint bit_offset)
2351 {
2352    proto_tree *subtree;
2353    proto_item *item;
2354    gint curr_bit_offset;
2355
2356    curr_bit_offset = bit_offset;
2357
2358    item = proto_tree_add_text(tree, tvb, curr_bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_GPRS_POWER_CONTROL_PARAMS].strptr);
2359         subtree = proto_item_add_subtree(item, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_GPRS_POWER_CONTROL_PARAMS]);
2360    proto_tree_add_bits_item(subtree, hf_gsm_a_rr_alpha, tvb, curr_bit_offset, 4, FALSE);
2361    curr_bit_offset += 4;
2362    proto_tree_add_bits_item(subtree, hf_gsm_a_rr_t_avg_w, tvb, curr_bit_offset, 5, FALSE);
2363    curr_bit_offset += 5;
2364    proto_tree_add_bits_item(subtree, hf_gsm_a_rr_t_avg_t, tvb, curr_bit_offset, 5, FALSE);
2365    curr_bit_offset += 5;
2366    proto_tree_add_bits_item(subtree, hf_gsm_a_rr_pc_meas_chan, tvb, curr_bit_offset, 1, FALSE);
2367    curr_bit_offset += 1;
2368    proto_tree_add_bits_item(subtree, hf_gsm_a_rr_n_avg_i, tvb, curr_bit_offset, 4, FALSE);
2369    curr_bit_offset += 4;
2370    proto_item_set_len(item,((curr_bit_offset-bit_offset)>>3)+1);
2371
2372    return (curr_bit_offset - bit_offset);
2373 }
2374
2375 static guint8
2376 de_rr_gprs_broadcast_info(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len , gchar *add_string _U_, int string_len _U_)
2377 {
2378    guint32 curr_offset;
2379    gint bit_offset;
2380
2381    curr_offset = offset;
2382    bit_offset = curr_offset << 3;
2383
2384    bit_offset += de_rr_rest_oct_gprs_cell_options(tvb, tree, bit_offset);
2385    bit_offset += de_rr_rest_oct_gprs_power_control_parameters(tvb, tree, bit_offset);  
2386    curr_offset += len;
2387
2388    return (curr_offset - offset);
2389 }
2390
2391 /*
2392  * [3] 10.5.2.15 Handover Reference
2393  */
2394 static guint8
2395 de_rr_ho_ref(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2396 {
2397         proto_tree      *subtree;
2398         proto_item      *item;
2399         guint32 curr_offset;
2400
2401         curr_offset = offset;
2402
2403         item =
2404                 proto_tree_add_text(tree,
2405                         tvb, curr_offset, 1, "%s",
2406                         gsm_rr_elem_strings[DE_RR_HO_REF].strptr);
2407
2408         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_HO_REF]);
2409
2410         /* Handover reference value */
2411         proto_tree_add_item(subtree, hf_gsm_a_rr_ho_ref_val, tvb, curr_offset, 1, FALSE);
2412
2413         curr_offset = curr_offset + 1;
2414
2415         return(curr_offset - offset);
2416 }
2417 /*
2418  * [3] 10.5.2.16 IA Rest Octets
2419  */
2420
2421 static guint8
2422 de_rr_ia_rest_oct(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2423 {
2424         proto_tree      *subtree;
2425         proto_item      *item;
2426         guint32 curr_offset;
2427
2428         len = tvb_length_remaining(tvb,offset);
2429         if (len==0)
2430                 return 0;
2431
2432         curr_offset = offset;
2433
2434         item =
2435                 proto_tree_add_text(tree,
2436                         tvb, curr_offset, len, "%s",
2437                         gsm_rr_elem_strings[DE_RR_IA_REST_OCT].strptr);
2438
2439         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_IA_REST_OCT]);
2440
2441         proto_tree_add_text(subtree,tvb, curr_offset, len ,"Data(Not decoded)");
2442
2443         curr_offset = curr_offset + len;
2444
2445         return curr_offset-offset;
2446 }
2447
2448 /*
2449  * [3] 10.5.2.17 IAR Rest Octets
2450  */
2451
2452 static guint8
2453 de_rr_iar_rest_oct(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2454 {
2455         proto_tree      *subtree;
2456         proto_item      *item;
2457         guint32 curr_offset;
2458
2459         len = 3;
2460         curr_offset = offset;
2461
2462         item =
2463         proto_tree_add_text(tree,
2464                 tvb, curr_offset, 3, "%s",
2465                 gsm_rr_elem_strings[DE_RR_IAR_REST_OCT].strptr);
2466
2467         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_IAR_REST_OCT]);
2468
2469         proto_tree_add_text(subtree,tvb, curr_offset, len ,"Data(Not decoded)");
2470
2471         curr_offset = curr_offset + len;
2472
2473         return curr_offset-offset;
2474 }
2475
2476 /*
2477  * [3] 10.5.2.18 IAX Rest Octets
2478  */
2479 static guint8
2480 de_rr_iax_rest_oct(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2481 {
2482         proto_tree      *subtree;
2483         proto_item      *item;
2484         guint32 curr_offset;
2485
2486         len = tvb_length_remaining(tvb,offset);
2487         if (len==0)
2488                 return 0;
2489
2490         curr_offset = offset;
2491
2492         item =
2493         proto_tree_add_text(tree,
2494                 tvb, curr_offset, len, "%s",
2495                 gsm_rr_elem_strings[DE_RR_IAX_REST_OCT].strptr);
2496
2497         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_IAX_REST_OCT]);
2498
2499         proto_tree_add_text(subtree,tvb, curr_offset, len ,"Data(Not decoded)");
2500
2501         curr_offset = curr_offset + len;
2502
2503         return curr_offset-offset;
2504 }
2505
2506 /*
2507  * [3] 10.5.2.19 L2 Pseudo Length
2508  */
2509 static guint8
2510 de_rr_l2_pseudo_len(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2511 {
2512         proto_tree      *subtree;
2513         proto_item      *item;
2514         guint32 curr_offset;
2515
2516         curr_offset = offset;
2517
2518         item = proto_tree_add_text(tree,tvb, curr_offset, 1, "%s", gsm_rr_elem_strings[DE_RR_L2_PSEUDO_LEN].strptr);
2519
2520         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_L2_PSEUDO_LEN]);
2521
2522         /* L2 Pseudo Length value */
2523         proto_tree_add_item(subtree, hf_gsm_a_rr_L2_pseudo_len, tvb, curr_offset, 1, FALSE);
2524
2525         curr_offset = curr_offset + 1;
2526
2527         return(curr_offset - offset);
2528 }
2529
2530 /*
2531  * [3] 10.5.2.20 Measurement Results
2532  */
2533 static const true_false_string gsm_a_rr_dtx_vals  = {
2534         "DTX was used",
2535         "DTX was not used"
2536 };
2537
2538 static const value_string gsm_a_rr_rxlev_vals [] = {
2539         {0, "< -110 dBm"},
2540         {1, "-110 <= x < -109 dBm"},
2541         {2, "-109 <= x < -108 dBm"},
2542         {3, "-108 <= x < -107 dBm"},
2543         {4, "-107 <= x < -106 dBm"},
2544         {5, "-106 <= x < -105 dBm"},
2545         {6, "-105 <= x < -104 dBm"},
2546         {7, "-104 <= x < -103 dBm"},
2547         {8, "-103 <= x < -102 dBm"},
2548         {9, "-102 <= x < -101 dBm"},
2549         {10, "-101 <= x < -100 dBm"},
2550         {11, "-100 <= x < -99 dBm"},
2551         {12, "-99 <= x < -98 dBm"},
2552         {13, "-98 <= x < -97 dBm"},
2553         {14, "-97 <= x < -96 dBm"},
2554         {15, "-96 <= x < -95 dBm"},
2555         {16, "-95 <= x < -94 dBm"},
2556         {17, "-94 <= x < -93 dBm"},
2557         {18, "-93 <= x < -92 dBm"},
2558         {19, "-92 <= x < -91 dBm"},
2559         {20, "-91 <= x < -90 dBm"},
2560         {21, "-90 <= x < -89 dBm"},
2561         {22, "-89 <= x < -88 dBm"},
2562         {23, "-88 <= x < -87 dBm"},
2563         {24, "-87 <= x < -86 dBm"},
2564         {25, "-86 <= x < -85 dBm"},
2565         {26, "-85 <= x < -84 dBm"},
2566         {27, "-84 <= x < -83 dBm"},
2567         {28, "-83 <= x < -82 dBm"},
2568         {29, "-82 <= x < -81 dBm"},
2569         {30, "-81 <= x < -80 dBm"},
2570         {31, "-80 <= x < -79 dBm"},
2571         {32, "-79 <= x < -78 dBm"},
2572         {33, "-78 <= x < -77 dBm"},
2573         {34, "-77 <= x < -76 dBm"},
2574         {35, "-76 <= x < -75 dBm"},
2575         {36, "-75 <= x < -74 dBm"},
2576         {37, "-74 <= x < -73 dBm"},
2577         {38, "-73 <= x < -72 dBm"},
2578         {39, "-72 <= x < -71 dBm"},
2579         {40, "-71 <= x < -70 dBm"},
2580         {41, "-70 <= x < -69 dBm"},
2581         {42, "-69 <= x < -68 dBm"},
2582         {43, "-68 <= x < -67 dBm"},
2583         {44, "-67 <= x < -66 dBm"},
2584         {45, "-66 <= x < -65 dBm"},
2585         {46, "-65 <= x < -64 dBm"},
2586         {47, "-64 <= x < -63 dBm"},
2587         {48, "-63 <= x < -62 dBm"},
2588         {49, "-62 <= x < -61 dBm"},
2589         {50, "-61 <= x < -60 dBm"},
2590         {51, "-60 <= x < -59 dBm"},
2591         {52, "-59 <= x < -58 dBm"},
2592         {53, "-58 <= x < -57 dBm"},
2593         {54, "-57 <= x < -56 dBm"},
2594         {55, "-56 <= x < -55 dBm"},
2595         {56, "-55 <= x < -54 dBm"},
2596         {57, "-54 <= x < -53 dBm"},
2597         {58, "-53 <= x < -52 dBm"},
2598         {59, "-52 <= x < -51 dBm"},
2599         {60, "-51 <= x < -50 dBm"},
2600         {61, "-50 <= x < -49 dBm"},
2601         {62, "-49 <= x < -48 dBm"},
2602         {63, ">= -48 dBm"},
2603         { 0, NULL}
2604 };
2605
2606 static const true_false_string gsm_a_rr_mv_vals  = {
2607         "The measurement results are valid",
2608         "The measurement results are not valid"
2609 };
2610
2611 static const value_string gsm_a_rr_rxqual_vals [] = {
2612         {0, "BER < 0.2%, Mean value 0.14%"},
2613         {1, "0.2% <= BER < 0.4%, Mean value 0.28%"},
2614         {2, "0.4% <= BER < 0.8%, Mean value 0.57%"},
2615         {3, "0.8% <= BER < 1.6%, Mean value 1.13%"},
2616         {4, "1.6% <= BER < 3.2%, Mean value 2.26%"},
2617         {5, "3.2% <= BER < 6.4%, Mean value 4.53%"},
2618         {6, "6.4% <= BER < 12.8%, Mean value 9.05%"},
2619         {7, "BER > 12.8%, Mean value 18.10%"},
2620         {0, NULL}
2621 };
2622 static const value_string gsm_a_rr_ncell_vals [] = {
2623         {0, "No neighbour cell measurement result"},
2624         {1, "1 neighbour cell measurement result"},
2625         {2, "2 neighbour cell measurement result"},
2626         {3, "3 neighbour cell measurement result"},
2627         {4, "4 neighbour cell measurement result"},
2628         {5, "5 neighbour cell measurement result"},
2629         {6, "6 neighbour cell measurement result"},
2630         {7, "Neighbour cell information not available for serving cell"},
2631         {0, NULL}
2632 };
2633 guint8
2634 de_rr_meas_res(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2635 {
2636         proto_tree      *subtree;
2637         proto_item      *item;
2638         guint32 curr_offset;
2639         gint bit_offset;
2640         guint64 no_ncell_m;
2641
2642         curr_offset = offset;
2643
2644         item =
2645                 proto_tree_add_text(tree,
2646                         tvb, curr_offset, 16, "%s",
2647                         gsm_rr_elem_strings[DE_RR_MEAS_RES].strptr);
2648         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_MEAS_RES]);
2649
2650         /* 2nd octet */
2651         /* BA-USED */
2652         proto_tree_add_bits_item(subtree, hf_gsm_a_rr_ba_used, tvb, curr_offset<<3, 1, FALSE);
2653         /* DTX USED */
2654         proto_tree_add_bits_item(subtree, hf_gsm_a_rr_dtx_used, tvb, (curr_offset<<3)+1, 1, FALSE);
2655         /* RXLEV-FULL-SERVING-CELL */
2656         proto_tree_add_bits_item(subtree, hf_gsm_a_rr_rxlev_full_serv_cell, tvb, (curr_offset<<3)+2, 6, FALSE);
2657         curr_offset++;
2658
2659         /* 3rd octet */
2660         /* 3G-BA-USED */ 
2661         proto_tree_add_bits_item(subtree, hf_gsm_a_rr_3g_ba_used, tvb, curr_offset<<3, 1, FALSE);
2662         /* MEAS-VALID */
2663         proto_tree_add_item(subtree, hf_gsm_a_rr_meas_valid, tvb, curr_offset, 1, FALSE);       
2664         /* RXLEV-SUB-SERVING-CELL */
2665         proto_tree_add_item(subtree, hf_gsm_a_rr_rxlev_sub_serv_cell, tvb, curr_offset, 1, FALSE);
2666
2667         curr_offset++;
2668
2669         /* 4th octet */
2670         /* RXQUAL-FULL-SERVING-CELL */
2671         proto_tree_add_bits_item(subtree, hf_gsm_a_rr_rxqual_full_serv_cell, tvb, (curr_offset<<3)+1, 3, FALSE);
2672
2673         /* RXQUAL-SUB-SERVING-CELL */
2674         proto_tree_add_item(subtree, hf_gsm_a_rr_rxqual_sub_serv_cell, tvb, curr_offset, 1, FALSE);
2675         /* NO-NCELL-M */
2676         bit_offset = (curr_offset << 3) + 7;
2677         proto_tree_add_bits_ret_val(subtree, hf_gsm_a_rr_no_ncell_m, tvb, bit_offset, 3, &no_ncell_m, FALSE);
2678         bit_offset += 3;
2679         if (no_ncell_m == 7) /* No neighbour cell information available) */
2680                 no_ncell_m = 0;
2681         while (no_ncell_m)
2682         {
2683                 proto_tree_add_bits_item(subtree, hf_gsm_a_rr_rxlev_ncell, tvb, bit_offset, 6, FALSE);
2684                 bit_offset += 6;
2685                 proto_tree_add_bits_item(subtree, hf_gsm_a_rr_bcch_freq_ncell, tvb, bit_offset, 5, FALSE);
2686                 bit_offset += 5;
2687                 proto_tree_add_bits_item(subtree, hf_gsm_a_rr_bsic_ncell, tvb, bit_offset, 6, FALSE);
2688                 bit_offset += 6;
2689                 no_ncell_m -= 1;
2690         }
2691
2692         return(len);
2693 }
2694
2695 /*
2696  * [3] 10.5.2.20a GPRS Measurement Results
2697  */
2698 /*
2699  * [3] 10.5.2.21 Mobile Allocation
2700  */
2701 static guint8
2702 de_rr_mob_all(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2703 {
2704         guint32 curr_offset;
2705    proto_item *item;
2706    gint i, j;
2707    guint8 value;
2708
2709         curr_offset = offset;
2710
2711    item = proto_tree_add_text(tree, tvb, curr_offset, len, "Bitmap of increasing ARFCNs included in the Mobile Allocation: ");
2712    for(i=len; i>0; i--)
2713    {
2714       value = tvb_get_guint8(tvb,curr_offset+i-1);
2715       for (j=0; j<8; j++)
2716       {
2717          proto_item_append_text(item,"%d",(value>>j)&0x01);
2718       }
2719    }
2720
2721         curr_offset = curr_offset + len;
2722         return(curr_offset - offset);
2723 }
2724
2725 /*
2726  * [3] 10.5.2.21a Mobile Time Difference
2727  */
2728 static guint8
2729 de_rr_mob_time_diff(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2730 {
2731         guint32 curr_offset;
2732
2733         curr_offset = offset;
2734
2735         proto_tree_add_item(tree, hf_gsm_a_rr_mobile_time_difference, tvb, curr_offset, len, FALSE);
2736
2737         curr_offset = curr_offset + len;
2738         return(curr_offset - offset);
2739
2740 }
2741 /*
2742  * [3] 10.5.2.21aa MultiRate configuration
2743  */
2744 /*      Multirate speech version Octet 3 Bits 8 7 6 */
2745 static const value_string multirate_speech_ver_vals[] = {
2746         { 1,    "Adaptive Multirate speech version 1"},
2747         { 2,    "Adaptive Multirate speech version 2"},
2748         { 0,    NULL }
2749 };
2750 /* Bit  5       NSCB: Noise Suppression Control Bit */
2751 static const value_string NSCB_vals[] = {
2752         { 0,    "Noise Suppression can be used (default)"},
2753         { 1,    "Noise Suppression shall be turned off"},
2754         { 0,    NULL }
2755 };
2756 /* Bit  4       ICMI: Initial Codec Mode Indicator */
2757 static const value_string ICMI_vals[] = {
2758         { 0,    "The initial codec mode is defined by the implicit rule provided in 3GPP TS 05.09"},
2759         { 1,    "The initial codec mode is defined by the Start Mode field"},
2760         { 0,    NULL }
2761 };
2762 /*
2763 Table 10.5.2.21aa.2: Set of adaptive multirate codec modes field (octet 4)
2764 for the Multirate speech version 1
2765 */
2766 static const true_false_string gsm_a_rr_set_of_amr_codec_modes  = {
2767         "is part of the subset",
2768         "is not part of the subset"
2769 };
2770
2771 static const value_string gsm_a_rr_amr_threshold_vals[] = {
2772         { 0,    "0.0 dB"},
2773         { 1,    "0.5 dB"},
2774         { 2,    "1.0 dB"},
2775         { 3,    "1.5 dB"},
2776         { 4,    "2.0 dB"},
2777         { 5,    "2.5 dB"},
2778         { 6,    "3.0 dB"},
2779         { 7,    "3.5 dB"},
2780         { 8,    "4.0 dB"},
2781         { 9,    "4.5 dB"},
2782         { 10,   "5.0 dB"},
2783         { 11,   "5.5 dB"},
2784         { 12,   "6.0 dB"},
2785         { 13,   "6.5 dB"},
2786         { 14,   "7.0 dB"},
2787         { 15,   "7.5 dB"},
2788         { 16,   "8.0 dB"},
2789         { 17,   "8.5 dB"},
2790         { 18,   "9.0 dB"},
2791         { 19,   "9.5 dB"},
2792         { 20,   "10.0 dB"},
2793         { 21,   "10.5 dB"},
2794         { 22,   "11.0 dB"},
2795         { 23,   "11.5 dB"},
2796         { 24,   "12.0 dB"},
2797         { 25,   "12.5 dB"},
2798         { 26,   "13.0 dB"},
2799         { 27,   "13.5 dB"},
2800         { 28,   "14.0 dB"},
2801         { 29,   "14.5 dB"},
2802         { 30,   "15.0 dB"},
2803         { 31,   "15.5 dB"},
2804         { 32,   "16.0 dB"},
2805         { 33,   "16.5 dB"},
2806         { 34,   "17.0 dB"},
2807         { 35,   "17.5 dB"},
2808         { 36,   "18.0 dB"},
2809         { 37,   "18.5 dB"},
2810         { 38,   "19.0 dB"},
2811         { 39,   "19.5 dB"},
2812         { 40,   "20.0 dB"},
2813         { 41,   "20.5 dB"},
2814         { 42,   "21.0 dB"},
2815         { 43,   "21.5 dB"},
2816         { 44,   "22.0 dB"},
2817         { 45,   "22.5 dB"},
2818         { 46,   "23.0 dB"},
2819         { 47,   "23.5 dB"},
2820         { 48,   "24.0 dB"},
2821         { 49,   "24.5 dB"},
2822         { 50,   "25.0 dB"},
2823         { 51,   "25.5 dB"},
2824         { 52,   "26.0 dB"},
2825         { 53,   "26.5 dB"},
2826         { 54,   "27.0 dB"},
2827         { 55,   "27.5 dB"},
2828         { 56,   "28.0 dB"},
2829         { 57,   "28.5 dB"},
2830         { 58,   "29.0 dB"},
2831         { 59,   "29.5 dB"},
2832         { 60,   "30.0 dB"},
2833         { 61,   "30.5 dB"},
2834         { 62,   "31.0 dB"},
2835         { 63,   "31.5 dB"},
2836         { 0,    NULL }
2837 };
2838
2839 static const value_string gsm_a_rr_amr_hysteresis_vals[] = {
2840         { 0,    "0.0 dB"},
2841         { 1,    "0.5 dB"},
2842         { 2,    "1.0 dB"},
2843         { 3,    "1.5 dB"},
2844         { 4,    "2.0 dB"},
2845         { 5,    "2.5 dB"},
2846         { 6,    "3.0 dB"},
2847         { 7,    "3.5 dB"},
2848         { 8,    "4.0 dB"},
2849         { 9,    "4.5 dB"},
2850         { 10,   "5.0 dB"},
2851         { 11,   "5.5 dB"},
2852         { 12,   "6.0 dB"},
2853         { 13,   "6.5 dB"},
2854         { 14,   "7.0 dB"},
2855         { 15,   "7.5 dB"},
2856         { 0,    NULL }
2857 };
2858
2859 guint8
2860 de_rr_multirate_conf(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2861 {
2862         guint32 curr_offset;
2863         guint8 oct;
2864    gint bit_offset, remaining_length, nb_of_params;
2865
2866         curr_offset = offset;
2867
2868         proto_tree_add_item(tree, hf_gsm_a_rr_multirate_speech_ver, tvb, curr_offset, 1, FALSE);
2869         proto_tree_add_item(tree, hf_gsm_a_rr_NCSB, tvb, curr_offset, 1, FALSE);
2870         proto_tree_add_item(tree, hf_gsm_a_rr_ICMI, tvb, curr_offset, 1, FALSE);
2871         /* The initial codec mode is coded as in 3GPP TS 45.009 */
2872         proto_tree_add_item(tree, hf_gsm_a_rr_start_mode, tvb, curr_offset, 1, FALSE);
2873         oct = ( tvb_get_guint8(tvb,curr_offset) &0xe0 ) >> 5;
2874         curr_offset++;
2875         switch ( oct){
2876         case 1:
2877                 /* Adaptive Multirate speech version 1 */
2878                 /* Set of AMR codec modes */
2879                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v1_b8, tvb, curr_offset, 1, FALSE);
2880                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v1_b7, tvb, curr_offset, 1, FALSE);
2881                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v1_b6, tvb, curr_offset, 1, FALSE);
2882                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v1_b5, tvb, curr_offset, 1, FALSE);
2883                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v1_b4, tvb, curr_offset, 1, FALSE);
2884                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v1_b3, tvb, curr_offset, 1, FALSE);
2885                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v1_b2, tvb, curr_offset, 1, FALSE);
2886                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v1_b1, tvb, curr_offset, 1, FALSE);
2887                 curr_offset++;
2888
2889                 remaining_length = len-2;
2890                 break;
2891         case 2:
2892                 /* Adaptive Multirate speech version 2 */
2893                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v2_b5, tvb, curr_offset, 1, FALSE);
2894                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v2_b4, tvb, curr_offset, 1, FALSE);
2895                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v2_b3, tvb, curr_offset, 1, FALSE);
2896                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v2_b2, tvb, curr_offset, 1, FALSE);
2897                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v2_b1, tvb, curr_offset, 1, FALSE);
2898                 curr_offset++;
2899
2900                 remaining_length = len-2;
2901                 break;
2902         default:
2903                 proto_tree_add_text(tree,tvb,offset,1,"Unknown version");
2904                 proto_tree_add_text(tree,tvb, curr_offset, len-1 ,"Data(Not decoded)");
2905                 remaining_length = 0;
2906                 break;
2907         }
2908
2909    if (remaining_length)
2910    {
2911            bit_offset = (curr_offset<<3) + 2;
2912       nb_of_params = remaining_length - 1;
2913       while (nb_of_params)
2914       {
2915          proto_tree_add_bits_item(tree, hf_gsm_a_rr_amr_threshold, tvb, bit_offset, 6, FALSE);
2916          bit_offset += 6;
2917          proto_tree_add_bits_item(tree, hf_gsm_a_rr_amr_hysteresis, tvb, bit_offset, 4, FALSE);
2918          bit_offset += 4;
2919          nb_of_params -= 1;
2920       }
2921    }
2922
2923         curr_offset = offset + len;
2924         return(curr_offset - offset);
2925
2926 }
2927 /*
2928  * [3] 10.5.2.21b Multislot Allocation
2929  */
2930 static guint8
2931 de_rr_mult_all(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2932 {
2933         guint32 curr_offset;
2934
2935         curr_offset = offset;
2936
2937         proto_tree_add_text(tree,tvb, curr_offset, len ,"Data(Not decoded)");
2938
2939         curr_offset = curr_offset + len;
2940         return(curr_offset - offset);
2941
2942 }
2943 /*
2944  * [3] 10.5.2.21c NC mode
2945  */
2946
2947  /*
2948  * [3] 10.5.2.22 Neighbour Cell Description
2949  */
2950 static const value_string gsm_a_rr_ext_ind_vals[] = {
2951         { 0,    "The information element carries the complete BA"},
2952         { 1,    "The information element carries only a part of the BA"},
2953         { 0,    NULL }
2954 };
2955 static guint8
2956 de_rr_neigh_cell_desc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2957 {
2958         guint32 curr_offset;
2959
2960         curr_offset = offset;
2961
2962         proto_tree_add_item(tree, hf_gsm_a_rr_ext_ind, tvb, curr_offset, 1, FALSE);
2963         proto_tree_add_bits_item(tree, hf_gsm_a_rr_ba_ind, tvb, (curr_offset<<3)+3, 1, FALSE);
2964
2965         return dissect_arfcn_list(tvb, tree, offset, 16, add_string, string_len);
2966 }
2967
2968  /*
2969  * [3] 10.5.2.22a Neighbour Cell Description 2
2970  */
2971 static guint8
2972 de_rr_neigh_cell_desc2(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2973 {
2974         guint32 curr_offset;
2975
2976         curr_offset = offset;
2977
2978    proto_tree_add_bits_item(tree, hf_gsm_a_rr_multiband_reporting, tvb, (curr_offset<<3)+1, 2, FALSE);
2979         proto_tree_add_bits_item(tree, hf_gsm_a_rr_ba_ind, tvb, (curr_offset<<3)+3, 1, FALSE);
2980
2981         return dissect_arfcn_list(tvb, tree, offset, 16, add_string, string_len);
2982 }
2983
2984 /*
2985  * [3] 10.5.2.22b (void)
2986  * [3] 10.5.2.22c NT/N Rest Octets
2987  */
2988
2989 /*
2990  * [3] 10.5.2.23 P1 Rest Octets
2991  */
2992 static guint8
2993 de_rr_p1_rest_oct(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2994 {
2995    proto_tree *subtree;
2996    proto_item *item, *item2;
2997    guint32 curr_offset, value;
2998    gint bit_offset, bit_offset_sav, i;
2999
3000    curr_offset = offset;
3001    bit_offset = curr_offset << 3;
3002    len = tvb_length_remaining(tvb,offset);
3003
3004    item = proto_tree_add_text(tree, tvb, curr_offset, len, "%s",
3005     gsm_rr_elem_strings[DE_RR_P1_REST_OCT].strptr);
3006
3007    subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_P1_REST_OCT]);
3008
3009    if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
3010    {
3011       bit_offset += 1;
3012       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_nln_pch, tvb, bit_offset, 2, FALSE);
3013       bit_offset += 2;
3014       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_nln_status_pch, tvb, bit_offset, 1, FALSE);
3015       bit_offset += 1;
3016    }
3017    else
3018       bit_offset += 1;
3019    for (i=1; i<=2; i++)
3020    {
3021       if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
3022       {
3023          bit_offset += 1;
3024          item2 = proto_tree_add_bits_item(subtree, hf_gsm_a_call_prio, tvb, bit_offset, 3, FALSE);
3025          bit_offset += 3;
3026          proto_item_append_text(item2, " for Mobile Identity %d", i);
3027       }
3028       else
3029          bit_offset += 1;
3030    }
3031    if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
3032    { /* Group Call Information */
3033       bit_offset += 1;
3034       bit_offset_sav = bit_offset;
3035       bit_offset += 36;
3036       if (tvb_get_bits8(tvb,bit_offset,1))
3037       { /* Group Channel Description */
3038          bit_offset += 24+1;
3039          if (tvb_get_bits8(tvb,bit_offset,1))
3040          { /* Hopping case */
3041             bit_offset += 1;
3042             if (tvb_get_bits8(tvb,bit_offset,1))
3043             {
3044                bit_offset += 64+1;
3045             }
3046             else
3047             {
3048                bit_offset += 1;
3049                value = tvb_get_bits8(tvb,bit_offset,8);
3050                bit_offset += 8 + (value<<3);
3051             }
3052          }
3053          else
3054             bit_offset += 1;
3055       }
3056       else
3057          bit_offset += 1;
3058       proto_tree_add_text(subtree,tvb, bit_offset_sav>>3, (bit_offset-bit_offset_sav)>>3,"Group Call Information: Data(Not decoded)");
3059    }
3060    else
3061       bit_offset += 1;
3062    for (i=1; i<=2; i++)
3063    {
3064       item2 = proto_tree_add_text(subtree,tvb, bit_offset>>3, 1, "Packet Page Indication %d: ", i);
3065       if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
3066          proto_item_append_text(item2, "Packet paging procedure");
3067       else
3068          proto_item_append_text(item2, "Paging procedure for RR connection establishment");
3069       bit_offset += 1;
3070    }
3071    if (((curr_offset + len)<<3) - bit_offset > 0)
3072    {
3073       /* There is still room left in the Rest Octets IE */
3074       if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
3075       { /* Additions in release 6 */
3076          bit_offset += 1;
3077          proto_tree_add_text(subtree, tvb, bit_offset>>3, -1,"Additions in Release 6: Data(Not decoded)");
3078       }
3079       else
3080          bit_offset += 1;
3081    }
3082
3083    curr_offset = curr_offset + len;
3084
3085    return (curr_offset - offset);
3086 }
3087
3088 /*
3089  * [3] 10.5.2.24 P2 Rest Octets
3090  */
3091 static guint8
3092 de_rr_p2_rest_oct(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3093
3094 {
3095    proto_tree *subtree;
3096    proto_item *item, *item2;
3097    guint32 curr_offset;
3098    gint bit_offset, i;
3099
3100    curr_offset = offset;
3101    bit_offset = curr_offset << 3;
3102    len = tvb_length_remaining(tvb,offset);
3103
3104    item = proto_tree_add_text(tree, tvb, curr_offset, len, "%s",
3105     gsm_rr_elem_strings[DE_RR_P2_REST_OCT].strptr);
3106
3107    subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_P2_REST_OCT]);
3108
3109    if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
3110    {
3111       bit_offset += 1;
3112       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_chnl_needed_ch3, tvb, bit_offset, 2, FALSE);
3113       bit_offset += 2;
3114    }
3115    else
3116       bit_offset += 1;
3117    if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
3118    {
3119       bit_offset += 1;
3120       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_nln_pch, tvb, bit_offset, 2, FALSE);
3121       bit_offset += 2;
3122       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_nln_status_pch, tvb, bit_offset, 1, FALSE);
3123       bit_offset += 1;
3124    }
3125    else
3126       bit_offset += 1;
3127    for (i=1; i<=3; i++)
3128    {
3129       if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
3130       {
3131          bit_offset += 1;
3132          item2 = proto_tree_add_bits_item(subtree, hf_gsm_a_call_prio, tvb, bit_offset, 3, FALSE);
3133          bit_offset += 3;
3134          proto_item_append_text(item2, " for Mobile Identity %d", i);
3135       }
3136       else
3137          bit_offset += 1;
3138    }
3139    item2 = proto_tree_add_text(subtree,tvb, bit_offset>>3, 1, "Packet Page Indication 3: ");
3140    if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
3141       proto_item_append_text(item2, "Packet paging procedure");
3142    else
3143       proto_item_append_text(item2, "Paging procedure for RR connection establishment");
3144    bit_offset += 1;
3145    if (((curr_offset + len)<<3) - bit_offset > 0)
3146    {
3147       /* There is still room left in the Rest Octets IE */
3148       if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
3149       { /* Additions in release 6 */
3150          bit_offset += 1;
3151          proto_tree_add_text(subtree, tvb, bit_offset>>3, -1,"Additions in Release 6: Data(Not decoded)");
3152       }
3153       else
3154          bit_offset += 1;
3155    }
3156
3157    curr_offset = curr_offset + len;
3158
3159    return (curr_offset - offset);
3160 }
3161
3162 /*
3163  * [3] 10.5.2.25 P3 Rest Octets
3164  */
3165 static guint8
3166 de_rr_p3_rest_oct(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3167 {
3168    proto_tree *subtree;
3169    proto_item *item, *item2;
3170    guint32 curr_offset;
3171    gint bit_offset, i;
3172
3173    curr_offset = offset;
3174    bit_offset = curr_offset << 3;
3175    len = 3;
3176
3177    item = proto_tree_add_text(tree, tvb, curr_offset, len, "%s",
3178     gsm_rr_elem_strings[DE_RR_P3_REST_OCT].strptr);
3179
3180    subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_P3_REST_OCT]);
3181
3182    if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
3183    {
3184       bit_offset += 1;
3185       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_chnl_needed_ch3, tvb, bit_offset, 2, FALSE);
3186       bit_offset += 2;
3187       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_chnl_needed_ch4, tvb, bit_offset, 2, FALSE);
3188       bit_offset += 2;
3189    }
3190    else
3191       bit_offset += 1;
3192    if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
3193    {
3194       bit_offset += 1;
3195       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_nln_pch, tvb, bit_offset, 2, FALSE);
3196       bit_offset += 2;
3197       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_nln_status_pch, tvb, bit_offset, 1, FALSE);
3198       bit_offset += 1;
3199    }
3200    else
3201       bit_offset += 1;
3202    for (i=1; i<=4; i++)
3203    {
3204       if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
3205       {
3206          bit_offset += 1;
3207          item2 = proto_tree_add_bits_item(subtree, hf_gsm_a_call_prio, tvb, bit_offset, 3, FALSE);
3208          bit_offset += 3;
3209          proto_item_append_text(item2, " for Mobile Identity %d", i);
3210       }
3211       else
3212          bit_offset += 1;
3213    }
3214
3215    curr_offset = curr_offset + len;
3216
3217    return (curr_offset - offset);
3218 }
3219
3220 /*
3221  * [3] 10.5.2.25a Packet Channel Description C V 3
3222  */
3223 static guint8
3224 de_rr_packet_ch_desc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3225 {
3226         guint32 curr_offset;
3227         guint8  oct8;
3228         guint16 arfcn, hsn, maio;
3229         proto_tree      *subtree;
3230         proto_item      *item;
3231         const gchar *str;
3232
3233         curr_offset = offset;
3234
3235         item = proto_tree_add_text(tree,tvb,curr_offset,3, "%s", gsm_rr_elem_strings[DE_RR_PACKET_CH_DESC].strptr);
3236         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_PACKET_CH_DESC]);
3237
3238         /* Octet 2 */
3239         oct8 = tvb_get_guint8(tvb, curr_offset);
3240         /* Channel Type */
3241         str = "Spare bits (ignored by receiver)";
3242         other_decode_bitfield_value(a_bigbuf, oct8, 0xf8, 8);
3243         proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = %s",a_bigbuf,str);
3244         /* TN */
3245         other_decode_bitfield_value(a_bigbuf, oct8, 0x07, 8);
3246         proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Timeslot: %d",a_bigbuf,(oct8 & 0x07));
3247
3248         curr_offset +=1;
3249         
3250         /* Octet 3 */
3251         oct8 = tvb_get_guint8(tvb, curr_offset);
3252         other_decode_bitfield_value(a_bigbuf, oct8, 0xe0, 8);
3253         proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Training Sequence: %d",a_bigbuf,((oct8 & 0xe0)>>5));
3254         
3255         if ((oct8 & 0x10) == 0x10)
3256         {
3257                 /* Hopping sequence */
3258                 maio = ((oct8 & 0x0f)<<2) | ((tvb_get_guint8(tvb,curr_offset+1) & 0xc0) >> 6);
3259                 hsn = (tvb_get_guint8(tvb,curr_offset+1) & 0x3f);
3260                 str = "Yes";
3261
3262                 other_decode_bitfield_value(a_bigbuf, oct8, 0x10, 8);
3263                 proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Hopping channel: %s",a_bigbuf,str);
3264                 proto_tree_add_text(subtree,tvb, curr_offset, 2,"Hopping channel: MAIO %d",maio);
3265                 proto_tree_add_text(subtree,tvb, curr_offset, 2,"Hopping channel: HSN %d",hsn);
3266         }
3267         else
3268         {
3269                 /* single ARFCN */
3270                 arfcn = ((oct8 & 0x03) << 8) | tvb_get_guint8(tvb,curr_offset+1);
3271                 str = "No";
3272                 other_decode_bitfield_value(a_bigbuf, oct8, 0x10, 8);
3273                 proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Hopping channel: %s",a_bigbuf,str);
3274                 other_decode_bitfield_value(a_bigbuf, oct8, 0x0c, 8);
3275                 proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Spare",a_bigbuf);
3276                 proto_tree_add_text(subtree,tvb, curr_offset, 2,"Single channel : ARFCN %d",arfcn);
3277         }
3278
3279         curr_offset = curr_offset + 2;
3280         return(curr_offset - offset);
3281
3282 }
3283 /*
3284  * [3] 10.5.2.25b Dedicated mode or TBF
3285  */
3286
3287 static const value_string gsm_a_rr_dedicated_mode_or_tbf_vals[] = {
3288         { 0,    "This message assigns a dedicated mode resource"},
3289         { 1,    "This message assigns an uplink TBF or is the second message of two in a two-message assignment of an uplink or downlink TBF"},
3290         { 2,    "Not used"},
3291         { 3,    "This message assigns a downlink TBF to the mobile station identified in the IA Rest Octets IE"},
3292         { 4,    "Not used"},
3293         { 5,    "This message is the first message of two in a two-message assignment of an uplink TBF"},
3294         { 6,    "Not used"},
3295         { 7,    "This message is the first message of two in a two-message assignment of a downlink TBF to the mobile station identified in the IA Rest Octets IE"},
3296         { 0,    NULL }
3297 };
3298 static guint8
3299 de_rr_ded_mod_or_tbf(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3300 {
3301         proto_tree      *subtree;
3302         proto_item      *item;
3303         guint32 curr_offset;
3304
3305         curr_offset = offset;
3306
3307         item =
3308                 proto_tree_add_text(tree,
3309                         tvb, curr_offset, 1, "%s",
3310                         gsm_rr_elem_strings[DE_RR_DED_MOD_OR_TBF].strptr);
3311
3312         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_DED_MOD_OR_TBF]);
3313
3314         proto_tree_add_item(subtree, hf_gsm_a_rr_dedicated_mode_or_tbf, tvb, curr_offset, 1, FALSE);
3315
3316         curr_offset += 1;
3317
3318         return(curr_offset - offset);
3319 }
3320 /*
3321  * [3] 10.5.2.25c RR Packet Uplink Assignment
3322  * [3] 10.5.2.25d RR Packet Downlink Assignment
3323  */
3324 /*
3325  * [3] 10.5.2.26 Page Mode
3326  */
3327
3328 static const value_string gsm_a_rr_page_mode_vals[] = {
3329         { 0,    "Normal paging"},
3330         { 1,    "Extended paging"},
3331         { 2,    "Paging reorganization"},
3332         { 3,    "Same as before"},
3333         { 0,    NULL }
3334 };
3335 static guint8
3336 de_rr_page_mode(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3337 {
3338         proto_tree      *subtree;
3339         proto_item      *item;
3340         guint32 curr_offset;
3341
3342         curr_offset = offset;
3343
3344         item =
3345                 proto_tree_add_text(tree,
3346                         tvb, curr_offset, 1, "%s",
3347                         gsm_rr_elem_strings[DE_RR_PAGE_MODE].strptr);
3348
3349         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_PAGE_MODE]);
3350
3351         proto_tree_add_item(subtree, hf_gsm_a_rr_page_mode, tvb, curr_offset, 1, FALSE);
3352
3353         curr_offset += 1;
3354
3355         return(curr_offset - offset);
3356 }
3357 /*
3358  * [3] 10.5.2.26a (void)
3359  * [3] 10.5.2.26b (void)
3360  * [3] 10.5.2.26c (void)
3361  * [3] 10.5.2.26d (void)
3362  */
3363 /*
3364  * [3] 10.5.2.27 NCC Permitted
3365  */
3366 static guint8
3367 de_rr_ncc_perm(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3368 {
3369         proto_tree      *subtree;
3370         proto_item      *item;
3371         guint32 curr_offset;
3372
3373         curr_offset = offset;
3374
3375         item = proto_tree_add_text(tree, tvb, curr_offset, 1, "%s",
3376                 gsm_rr_elem_strings[DE_RR_NCC_PERM].strptr);
3377
3378         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_NCC_PERM]);
3379
3380         proto_tree_add_item(subtree, hf_gsm_a_rr_ncc_permitted, tvb, curr_offset, 1, FALSE);
3381
3382         curr_offset = curr_offset + 1;
3383
3384         return(curr_offset - offset);
3385 }
3386 /*
3387  * [3] 10.5.2.28 Power Command
3388  *
3389  *
3390  * ATC (Access Type Control) (octet 2)Bit 8
3391  * 0    Sending of Handover access is mandatory
3392  * 1    Sending of Handover access is optional
3393  */
3394 static const true_false_string gsm_a_rr_pow_cmd_atc_value  = {
3395         "Sending of Handover access is optional",
3396         "Sending of Handover access is mandatory"
3397 };
3398 /*
3399  *  The EPC mode field (octet 2) indicates whether the assigned channel(s)
3400  *  shall be in enhanced power control (EPC) mode. It is only valid for channels
3401  *  on which EPC may be used. It is coded as follows:
3402 */
3403 static const true_false_string gsm_a_rr_pow_cmd_epc_value  = {
3404         "Channel(s) in EPC mode",
3405         "Channel(s) not in EPC mode"
3406 };
3407 /*
3408  * FPC_EPC (octet 2)
3409  * The FPC_EPC field (octet 2) has different interpretation depending
3410  *              on the channel mode     of the assigned channel (s) and the value
3411  *              of the EPC mode field.
3412  * If the channel mode is such that fast power control (FPC) may be
3413  *              used, the FPC_EPC field indicates whether Fast Measurement
3414  *              Reporting and Power Control mechanism is used.
3415  *              It is coded as follows:
3416  * Value 0      FPC not in use
3417  *         1    FPC in use
3418  * If the channel mode is such that EPC may be used and the EPC mode
3419  *              field indicates that the channel is in EPC mode, the FPC_EPC
3420  *              field indicates whether EPC shall be used for uplink power control.
3421  * It is coded as follows:
3422  * Value 0      EPC not in use for uplink power control
3423  *               1      EPC in use for uplink power control
3424  *
3425  */
3426 static const true_false_string gsm_a_rr_pow_cmd_fpcepc_value  = {
3427         "FPC in use/EPC in use for uplink power control",
3428         "FPC not in use/C not in use for uplink power control"
3429 };
3430
3431 /*
3432  * Power level (octet 2)The power level field is coded as the binaryRepresentation
3433  * of the "power control level", see 3GPP TS 3GPP TS 45.005. This value shall be used
3434  * by the mobile station According to 3GPP TS 45.008.Range: 0 to 31.
3435  */
3436
3437 static guint8
3438 de_rr_pow_cmd(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3439 {
3440         proto_tree      *subtree;
3441         proto_item      *item;
3442         guint32 curr_offset;
3443
3444         curr_offset = offset;
3445
3446         item =
3447                 proto_tree_add_text(tree,
3448                         tvb, curr_offset, 1, "%s",
3449                         gsm_rr_elem_strings[DE_RR_POW_CMD].strptr);
3450
3451         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_POW_CMD]);
3452
3453         proto_tree_add_item(subtree, hf_gsm_a_b8spare, tvb, curr_offset, 1, FALSE);
3454         /*EPC mode */
3455         proto_tree_add_item(subtree, hf_gsm_a_rr_pow_cmd_epc, tvb, curr_offset, 1, FALSE);
3456         /*FPC_EPC*/
3457         proto_tree_add_item(subtree, hf_gsm_a_rr_pow_cmd_fpcepc, tvb, curr_offset, 1, FALSE);
3458         /*POWER LEVEL*/
3459         proto_tree_add_item(subtree, hf_gsm_a_rr_pow_cmd_powlev, tvb, curr_offset, 1, FALSE);
3460
3461         curr_offset = curr_offset + 1;
3462
3463         return(curr_offset - offset);
3464 }
3465
3466 /*
3467  * [3] 10.5.2.28a Power Command and access type
3468  */
3469 static guint8
3470 de_rr_pow_cmd_and_acc_type(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3471 {
3472         proto_tree      *subtree;
3473         proto_item      *item;
3474         guint32 curr_offset;
3475
3476         curr_offset = offset;
3477
3478         item =
3479                 proto_tree_add_text(tree,
3480                         tvb, curr_offset, 1, "%s",
3481                         gsm_rr_elem_strings[DE_RR_POW_CMD_AND_ACC_TYPE].strptr);
3482
3483         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_POW_CMD_AND_ACC_TYPE]);
3484
3485         /*ATC */
3486         proto_tree_add_item(subtree, hf_gsm_a_rr_pow_cmd_atc, tvb, curr_offset, 1, FALSE);
3487         /*EPC mode */
3488         proto_tree_add_item(subtree, hf_gsm_a_rr_pow_cmd_epc, tvb, curr_offset, 1, FALSE);
3489         /*FPC_EPC*/
3490         proto_tree_add_item(subtree, hf_gsm_a_rr_pow_cmd_fpcepc, tvb, curr_offset, 1, FALSE);
3491         /*POWER LEVEL*/
3492         proto_tree_add_item(subtree, hf_gsm_a_rr_pow_cmd_powlev, tvb, curr_offset, 1, FALSE);
3493
3494         curr_offset = curr_offset + 1;
3495
3496         return(curr_offset - offset);
3497 }
3498 /*
3499  * [3] 10.5.2.29 RACH Control Parameters
3500  */
3501
3502 static const value_string gsm_a_rr_max_retrans_vals[] = {
3503         { 0,    "Maximum 1 retransmission"},
3504         { 1,    "Maximum 2 retransmissions"},
3505         { 2,    "Maximum 4 retransmissions"},
3506         { 3,    "Maximum 7 retransmissions"},
3507         { 0,    NULL }
3508 };
3509
3510 static const value_string gsm_a_rr_tx_integer_vals[] = {
3511         { 0,    "3 slots used to spread transmission"},
3512         { 1,    "4 slots used to spread transmission"},
3513         { 2,    "5 slots used to spread transmission"},
3514         { 3,    "6 slots used to spread transmission"},
3515         { 4,    "7 slots used to spread transmission"},
3516         { 5,    "8 slots used to spread transmission"},
3517         { 6,    "9 slots used to spread transmission"},
3518         { 7,    "10 slots used to spread transmission"},
3519         { 8,    "11 slots used to spread transmission"},
3520         { 9,    "12 slots used to spread transmission"},
3521         { 10,   "14 slots used to spread transmission"},
3522         { 11,   "16 slots used to spread transmission"},
3523         { 12,   "20 slots used to spread transmission"},
3524         { 13,   "25 slots used to spread transmission"},
3525         { 14,   "32 slots used to spread transmission"},
3526         { 15,   "50 slots used to spread transmission"},
3527         { 0,    NULL }
3528 };
3529 static const value_string gsm_a_rr_cell_barr_access_vals[] = {
3530         { 0,    "The cell is not barred"},
3531         { 1,    "The cell is barred"},
3532         { 0,    NULL }
3533 };
3534 static const value_string gsm_a_rr_re_vals[] = {
3535         { 0,    "Call Reestablishment allowed in the cell"},
3536         { 1,    "Call Reestablishment not allowed in the cell"},
3537         { 0,    NULL }
3538 };
3539
3540 static guint8
3541 de_rr_rach_ctrl_param(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3542 {
3543         proto_tree      *subtree;
3544         proto_item      *item;
3545         guint32 curr_offset;
3546
3547         curr_offset = offset;
3548
3549         item = proto_tree_add_text(tree, tvb, curr_offset, 3, "%s",
3550                 gsm_rr_elem_strings[DE_RR_RACH_CTRL_PARAM].strptr);
3551
3552         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_RACH_CTRL_PARAM]);
3553
3554         proto_tree_add_item(subtree, hf_gsm_a_rr_max_retrans, tvb, curr_offset, 1, FALSE);
3555         proto_tree_add_item(subtree, hf_gsm_a_rr_tx_integer, tvb, curr_offset, 1, FALSE);
3556         proto_tree_add_item(subtree, hf_gsm_a_rr_cell_barr_access, tvb, curr_offset, 1, FALSE);
3557         proto_tree_add_item(subtree, hf_gsm_a_rr_re, tvb, curr_offset, 1, FALSE);
3558         curr_offset = curr_offset + 1;
3559
3560         proto_tree_add_item(subtree, hf_gsm_a_rr_acc, tvb, curr_offset, 2, FALSE);
3561
3562         curr_offset = curr_offset + 2;
3563
3564         return(curr_offset - offset);
3565 }
3566 /*
3567  * [3] 10.5.2.30 Request Reference M V 3
3568  */
3569 static guint16 reduced_frame_number(guint16 fn)
3570 {
3571         /* great care needed with signed/unsigned - -1 in unsigned is 0xffff, which mod(26) is not what you think !!! */
3572         gint16  t2, t3, t;
3573         guint16 frame, t1;
3574
3575         t1 = (fn >> 11) & 0x1f;
3576         t2 = (fn >> 0) & 0x1f;
3577         t3 = (fn >> 5) & 0x3f;
3578
3579         t = (t3-t2)%26;
3580         if (t<0)
3581                 t += 26;
3582
3583         frame = 51*(unsigned)t+(unsigned)t3+51*26*t1;
3584
3585         return frame;
3586 }
3587
3588 static guint8
3589 de_rr_req_ref(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3590 {
3591         proto_tree      *subtree;
3592         proto_item      *item;
3593         guint32 curr_offset;
3594         guint16 rfn;
3595         guint16 fn;
3596
3597         curr_offset = offset;
3598
3599         item =
3600                 proto_tree_add_text(tree,
3601                         tvb, curr_offset, 3, "%s",
3602                         gsm_rr_elem_strings[DE_RR_REQ_REF].strptr);
3603
3604         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_REQ_REF]);
3605
3606         proto_tree_add_item(subtree, hf_gsm_a_rr_ra, tvb, curr_offset, 1, FALSE);
3607         curr_offset++;
3608         fn = tvb_get_ntohs(tvb,curr_offset);
3609         rfn = reduced_frame_number(fn);
3610         proto_tree_add_item(subtree, hf_gsm_a_rr_T1prim, tvb, curr_offset, 1, FALSE);
3611         proto_tree_add_item(subtree, hf_gsm_a_rr_T3, tvb, curr_offset, 2, FALSE);
3612         curr_offset++;
3613         proto_tree_add_item(subtree, hf_gsm_a_rr_T2, tvb, curr_offset, 1, FALSE);
3614         curr_offset++;
3615         item = proto_tree_add_uint(subtree, hf_gsm_a_rr_rfn, tvb, curr_offset-2, 2, rfn);
3616         PROTO_ITEM_SET_GENERATED(item);
3617
3618         return(curr_offset - offset);
3619 }
3620 /*
3621  * [3] 10.5.2.31
3622  */
3623 guint8
3624 de_rr_cause(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3625 {
3626         guint32 curr_offset;
3627
3628         curr_offset = offset;
3629
3630         proto_tree_add_item(tree, hf_gsm_a_rr_RR_cause, tvb, curr_offset, 1, FALSE);
3631
3632         curr_offset++;
3633
3634         return(curr_offset - offset);
3635 }
3636
3637 /*
3638  * [3] 10.5.2.32 SI 1 Rest Octets
3639  */
3640 static const value_string gsm_a_rr_nch_position_vals[] = {
3641         { 0,    "No of blocks = 1 and Number of first block = 0"},
3642         { 1,    "No of blocks = 1 and Number of first block = 1"},
3643         { 2,    "No of blocks = 1 and Number of first block = 2"},
3644         { 3,    "No of blocks = 1 and Number of first block = 3"},
3645         { 4,    "No of blocks = 1 and Number of first block = 4"},
3646         { 5,    "No of blocks = 1 and Number of first block = 5"},
3647         { 6,    "No of blocks = 1 and Number of first block = 6"},
3648         { 7,    "No of blocks = 1 and Number of first block = 0"},
3649         { 8,    "No of blocks = 2 and Number of first block = 1"},
3650         { 9,    "No of blocks = 2 and Number of first block = 2"},
3651         {10,    "No of blocks = 2 and Number of first block = 3"},
3652         {11,    "No of blocks = 2 and Number of first block = 4"},
3653         {12,    "No of blocks = 2 and Number of first block = 5"},
3654         {13,    "No of blocks = 3 and Number of first block = 0"},
3655         {14,    "No of blocks = 3 and Number of first block = 1"},
3656         {15,    "No of blocks = 3 and Number of first block = 2"},
3657         {16,    "No of blocks = 3 and Number of first block = 3"},
3658         {17,    "No of blocks = 3 and Number of first block = 4"},
3659         {18,    "No of blocks = 4 and Number of first block = 0"},
3660         {19,    "No of blocks = 4 and Number of first block = 1"},
3661         {20,    "No of blocks = 4 and Number of first block = 2"},
3662         {21,    "No of blocks = 4 and Number of first block = 3"},
3663         {22,    "No of blocks = 5 and Number of first block = 0"},
3664         {23,    "No of blocks = 5 and Number of first block = 1"},
3665         {24,    "No of blocks = 5 and Number of first block = 2"},
3666         {25,    "No of blocks = 6 and Number of first block = 0"},
3667         {26,    "No of blocks = 6 and Number of first block = 1"},
3668         {27,    "No of blocks = 7 and Number of first block = 0"},
3669         {28,    "Reserved"},
3670         {29,    "Reserved"},
3671         {30,    "Reserved"},
3672         {31,    "Reserved"},
3673         { 0,    NULL }
3674 };
3675
3676 static guint8
3677 de_rr_si1_rest_oct(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
3678 {
3679         proto_tree      *subtree;
3680         proto_item      *item;
3681         guint32 curr_offset;
3682    gint bit_offset;
3683
3684         len = 1;
3685         curr_offset = offset;
3686    bit_offset = curr_offset << 3;
3687
3688         item = proto_tree_add_text(tree, tvb, curr_offset, len, "%s",
3689                 gsm_rr_elem_strings[DE_RR_SI1_REST_OCT].strptr);
3690
3691         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_SI1_REST_OCT]);
3692
3693    if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
3694    {
3695       bit_offset += 1;
3696       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_nch_position, tvb, bit_offset, 5, FALSE);
3697       bit_offset += 5;
3698    }
3699    else
3700    {
3701       proto_tree_add_text(subtree,tvb, bit_offset>>3, 1, "NCH position: not present");
3702       bit_offset += 1;
3703    }
3704    if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
3705       proto_tree_add_text(subtree,tvb, bit_offset>>3, 1, "Band Indicator: 1900");
3706    else
3707       proto_tree_add_text(subtree,tvb, bit_offset>>3, 1, "Band Indicator: 1800");
3708    bit_offset += 1;
3709
3710         curr_offset = curr_offset + len;
3711
3712         return curr_offset-offset;
3713 }
3714
3715 /*
3716  * [3] 10.5.2.33 SI 2bis Rest Octets
3717  */
3718
3719 /*
3720  * [3] 10.5.2.33a SI 2ter Rest Octets
3721  */
3722 static const value_string gsm_a_rr_qsearch_x_vals[] = {
3723         { 0,    "-98 dBm"},
3724         { 1,    "-94 dBm"},
3725         { 2,    "-90 dBm"},
3726         { 3,    "-86 dBm"},
3727         { 4,    "-82 dBm"},
3728         { 5,    "-78 dBm"},
3729         { 6,    "-74 dBm"},
3730         { 7,    "Always"},
3731         { 8,    "-78 dBm"},
3732         { 9,    "-74 dBm"},
3733         {10,    "-70 dBm"},
3734         {11,    "-66 dBm"},
3735         {12,    "-62 dBm"},
3736         {13,    "-58 dBm"},
3737         {14,    "-54 dBm"},
3738         {15,    "Never"},
3739         { 0,    NULL }
3740 };
3741
3742 static const value_string gsm_a_rr_xdd_qoffset_vals[] = {
3743         { 0,    "always select a cell if acceptable"},
3744         { 1,    "-28 dB"},
3745         { 2,    "-24 dB"},
3746         { 3,    "-20 dB"},
3747         { 4,    "-16 dB"},
3748         { 5,    "-12 dB"},
3749         { 6,    "-8 dB"},
3750         { 7,    "-4 dB"},
3751         { 8,    "0 dB"},
3752         { 9,    "4 dB"},
3753         {10,    "8 dB"},
3754         {11,    "12 dB"},
3755         {12,    "16 dB"},
3756         {13,    "20 dB"},
3757         {14,    "24 dB"},
3758         {15,    "28 dB"},
3759         { 0,    NULL }
3760 };
3761
3762 static const value_string gsm_a_rr_fdd_qmin_vals[] = {
3763         { 0,    "-20 dB"},
3764         { 1,    "-6 dB"},
3765         { 2,    "-18 dB"},
3766         { 3,    "-8 dB"},
3767         { 4,    "-16 dB"},
3768         { 5,    "-10 dB"},
3769         { 6,    "-14 dB"},
3770         { 7,    "-12 dB"},
3771         { 0,    NULL }
3772 };
3773
3774 static const value_string gsm_a_rr_fdd_qmin_offset_vals[] = {
3775         { 0,    "0 dB"},
3776         { 1,    "2 dB"},
3777         { 2,    "4 dB"},
3778         { 3,    "6 dB"},
3779         { 4,    "8 dB"},
3780         { 5,    "10 dB"},
3781         { 6,    "12 dB"},
3782         { 7,    "14 dB"},
3783         { 0,    NULL }
3784 };
3785
3786 static const value_string gsm_a_rr_fdd_rscpmin_vals[] = {
3787         { 0,    "-114 dBm"},
3788         { 1,    "-112 dBm"},
3789         { 2,    "-110 dBm"},
3790         { 3,    "-108 dBm"},
3791         { 4,    "-106 dBm"},
3792         { 5,    "-104 dBm"},
3793         { 6,    "-102 dBm"},
3794         { 7,    "-100 dBm"},
3795         { 8,    "-98 dBm"},
3796         { 9,    "-96 dBm"},
3797         {10,    "-94 dBm"},
3798         {11,    "-92 dBm"},
3799         {12,    "-90 dBm"},
3800         {13,    "-88 dBm"},
3801         {14,    "-86 dBm"},
3802         {15,    "-84 dBm"},
3803         { 0,    NULL }
3804 };
3805
3806 static guint8
3807 de_rr_si2ter_rest_oct(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
3808 {
3809         proto_tree      *subtree, *subtree2;
3810         proto_item      *item, *item2;
3811         guint32 curr_offset;
3812    gint bit_offset, bit_offset_sav;
3813    guint8 value;
3814
3815         len = 4;
3816         curr_offset = offset;
3817    bit_offset = curr_offset<<3;
3818
3819         item = proto_tree_add_text(tree, tvb, curr_offset, len, "%s",
3820                 gsm_rr_elem_strings[DE_RR_SI2TER_REST_OCT].strptr);
3821
3822         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_SI2TER_REST_OCT]);
3823
3824    if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
3825    {
3826       bit_offset += 1;
3827       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_si2ter_mp_change_mark, tvb, bit_offset, 1, FALSE);
3828       bit_offset += 1;
3829       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_si2ter_3g_change_mark, tvb, bit_offset, 1, FALSE);
3830       bit_offset += 1;
3831       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_si2ter_index, tvb, bit_offset, 3, FALSE);
3832       bit_offset += 3;
3833       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_si2ter_count, tvb, bit_offset, 3, FALSE);
3834       bit_offset += 3;
3835       value = tvb_get_bits8(tvb,bit_offset,1);
3836       bit_offset += 1;
3837       if (value)
3838       { /* UTRAN FDD Description */
3839          bit_offset_sav = bit_offset;
3840          item2 = proto_tree_add_text(subtree, tvb, bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_UTRAN_FDD_DESC].strptr);
3841          subtree2 = proto_item_add_subtree(item2, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_UTRAN_FDD_DESC]);
3842          bit_offset += 2; /* skip '01' bits */
3843          proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_fdd_uarfcn, tvb, bit_offset, 14, FALSE);
3844          bit_offset += 14;
3845          value = tvb_get_bits8(tvb,bit_offset,1);
3846          bit_offset += 1;
3847          if (value)
3848          {
3849             proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_bandwidth_fdd, tvb, bit_offset, 3, FALSE);
3850             bit_offset += 3;
3851          }
3852          proto_item_set_len(item2,((bit_offset-bit_offset_sav)>>3)+1);
3853       }
3854       value = tvb_get_bits8(tvb,bit_offset,1);
3855       bit_offset += 1;
3856       if (value)
3857       { /* UTRAN TDD Description */
3858          bit_offset_sav = bit_offset;
3859          item2 = proto_tree_add_text(subtree, tvb, bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_UTRAN_TDD_DESC].strptr);
3860          subtree2 = proto_item_add_subtree(item2, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_UTRAN_TDD_DESC]);
3861          bit_offset += 2; /* skip '01' bits */
3862          proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_tdd_uarfcn, tvb, bit_offset, 14, FALSE);
3863          bit_offset += 14;
3864          value = tvb_get_bits8(tvb,bit_offset,1);
3865          bit_offset += 1;
3866          if (value)
3867          {
3868             proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_bandwidth_tdd, tvb, bit_offset, 3, FALSE);
3869             bit_offset += 3;
3870          }
3871          proto_item_set_len(item2,((bit_offset-bit_offset_sav)>>3)+1);
3872       }
3873       value = tvb_get_bits8(tvb,bit_offset,1);
3874       bit_offset += 1;
3875       if (value)
3876       { /* 3G Measurement Parameters Description */
3877          bit_offset_sav = bit_offset;
3878          item2 = proto_tree_add_text(subtree, tvb, bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_3G_MEAS_PARAM_DESC].strptr);
3879          subtree2 = proto_item_add_subtree(item2, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_3G_MEAS_PARAM_DESC]);
3880          proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_qsearch_i, tvb, bit_offset, 4, FALSE);
3881          bit_offset += 4;
3882          value = tvb_get_bits8(tvb,bit_offset,1);
3883          bit_offset += 1;
3884          if (value)
3885          {
3886             proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_fdd_qoffset, tvb, bit_offset, 4, FALSE);
3887             bit_offset += 4;
3888             proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_fdd_qmin, tvb, bit_offset, 3, FALSE);
3889             bit_offset += 3;
3890          }
3891          value = tvb_get_bits8(tvb,bit_offset,1);
3892          bit_offset += 1;
3893          if (value)
3894          {
3895             proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_tdd_qoffset, tvb, bit_offset, 4, FALSE);
3896             bit_offset += 4;
3897          }
3898          proto_item_set_len(item2,((bit_offset-bit_offset_sav)>>3)+1);
3899       }
3900       if (((curr_offset + len)<<3) - bit_offset > 0)
3901       {
3902          /* There is still room left in the Rest Octets IE */
3903          if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
3904          { /* Additions in release R5 */
3905             bit_offset += 1;
3906             value = tvb_get_bits8(tvb,bit_offset,1);
3907             bit_offset += 1;
3908             if (value)
3909             { /* 3G Additional Measurement Parameters Description */
3910                bit_offset_sav = bit_offset;
3911                item2 = proto_tree_add_text(subtree, tvb, bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_3G_ADD_MEAS_PARAM_DESC].strptr);
3912                subtree2 = proto_item_add_subtree(item2, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_3G_ADD_MEAS_PARAM_DESC]);
3913                proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_fdd_qmin_offset, tvb, bit_offset, 3, FALSE);
3914                bit_offset += 3;
3915                proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_fdd_rscpmin, tvb, bit_offset, 4, FALSE);
3916                bit_offset += 4;
3917                proto_item_set_len(item2,((bit_offset-bit_offset_sav)>>3)+1);
3918             }
3919          }
3920          else
3921             bit_offset += 1;
3922       }
3923    }
3924    else
3925    {
3926       bit_offset += 1;
3927       proto_tree_add_text(subtree,tvb, curr_offset, len ,"Empty");
3928    }
3929
3930         curr_offset = curr_offset + len;
3931
3932         return curr_offset-offset;
3933 }
3934
3935 /*
3936  * [3] 10.5.2.33b SI 2quater Rest Octets
3937  */
3938 static const true_false_string gsm_a_rr_gsm_report_type_value = {
3939         "The MS shall use the Measurement Report message for reporting",
3940         "The MS shall use the Enhanced Measurement Report message for reporting if at least one BSIC is allocated to each BA (list) frequency. Otherwise, the Measurement Report message shall be used"
3941 };
3942
3943 static const true_false_string gsm_a_rr_frequency_scrolling_value = {
3944         "Next BSIC in the structure relates to the subsequent frequency in the BA(list)",
3945         "Next BSIC in the structure relates to the same frequency in the BA(list)"
3946 };
3947
3948 static const true_false_string gsm_a_rr_rep_priority_value = {
3949         "High reporting priority",
3950         "Normal reporting priority"
3951 };
3952
3953 static const true_false_string gsm_a_rr_report_type_value = {
3954         "The MS shall use the PACKET MEASUREMENT REPORT message for reporting",
3955         "The MS shall use the PACKET ENHANCED MEASUREMENT REPORT message for reporting"
3956 };
3957
3958 static const true_false_string gsm_a_rr_reporting_rate_value = {
3959         "Reduced reporting rate allowed",
3960         "Normal reporting rate"
3961 };
3962
3963 static const true_false_string gsm_a_rr_invalid_bsic_reporting_value = {
3964         "Report on cells with invalid BSIC and allowed NCC part of BSIC is allowed",
3965         "Report on cells with invalid BSIC and allowed NCC part of BSIC is not allowed"
3966 };
3967
3968 static const value_string gsm_a_rr_scale_ord_vals[] = {
3969         { 0, "An offset of 0 dB shall be used for the reported RXLEV values"},
3970         { 1, "An offset of 10 dB shall be used for the reported RXLEV values"},
3971         { 2, "An automatic offset shall be used for the reported RXLEV values"},
3972         { 0, NULL }
3973 };
3974
3975 static const value_string gsm_a_rr_xxx_reporting_offset_vals[] = {
3976         { 0, "Apply an offset of 0 dB to the reported value when prioritising the cells for reporting"},
3977         { 1, "Apply an offset of 6 dB to the reported value when prioritising the cells for reporting"},
3978         { 2, "Apply an offset of 12 dB to the reported value when prioritising the cells for reporting"},
3979         { 3, "Apply an offset of 18 dB to the reported value when prioritising the cells for reporting"},
3980         { 4, "Apply an offset of 24 dB to the reported value when prioritising the cells for reporting"},
3981         { 5, "Apply an offset of 30 dB to the reported value when prioritising the cells for reporting"},
3982         { 6, "Apply an offset of 36 dB to the reported value when prioritising the cells for reporting"},
3983         { 7, "Apply an offset of 42 dB to the reported value when prioritising the cells for reporting"},
3984         { 0, NULL }
3985 };
3986
3987 static const value_string gsm_a_rr_xxx_reporting_threshold_vals[] = {
3988         { 0, "Apply priority reporting if the reported value is above 0 dB"},
3989         { 1, "Apply priority reporting if the reported value is above 6 dB"},
3990         { 2, "Apply priority reporting if the reported value is above 12 dB"},
3991         { 3, "Apply priority reporting if the reported value is above 18 dB"},
3992         { 4, "Apply priority reporting if the reported value is above 24 dB"},
3993         { 5, "Apply priority reporting if the reported value is above 30 dB"},
3994         { 6, "Apply priority reporting if the reported value is above 36 dB"},
3995         { 7, "Never apply priority reporting"},
3996         { 0, NULL }
3997 };
3998
3999 static const value_string gsm_a_rr_network_control_order_vals[] = {
4000    { 0, "NC0"},
4001    { 1, "NC1"},
4002    { 2, "NC2"},
4003    { 3, "NC0"},
4004    { 0, NULL }
4005 };
4006
4007 static const value_string gsm_a_rr_nc_non_drx_period_vals[] = {
4008    { 0, "No non-DRX mode after a measurement report has been sent"},
4009    { 1, "0,24 s"},
4010    { 2, "0,48 s"},
4011    { 3, "0.72 s"},
4012    { 4, "0.96 s"},
4013    { 5, "1.20 s"},
4014    { 6, "1.44 s"},
4015    { 7, "1.92 s"},
4016    { 0, NULL }
4017 };
4018
4019 static const value_string gsm_a_rr_nc_reporting_period_x_vals[] = {
4020    { 0, "0.48 s"},
4021    { 1, "0.96 s"},
4022    { 2, "1.92 s"},
4023    { 3, "3.84 s"},
4024    { 4, "7.68 s"},
4025    { 5, "15.36 s"},
4026    { 6, "30.72 s"},
4027    { 7, "61.44 s"},
4028    { 0, NULL }
4029 };
4030
4031 static const true_false_string gsm_a_rr_qsearch_c_initial_value = {
4032         "Always",
4033         "use Qsearch I"
4034 };
4035
4036 static const true_false_string gsm_a_rr_fdd_rep_quant_value = {
4037         "Ec/No",
4038         "RSCP"
4039 };
4040
4041 static const true_false_string gsm_a_rr_3g_search_prio_value = {
4042         "3G cells may be searched when BSIC decoding is required",
4043         "3G cells may not be searched when BSIC decoding is required"
4044 };
4045
4046 static const true_false_string gsm_a_rr_3g_ccn_active_value = {
4047         "CCN towards 3G cells is enabled in the cell",
4048         "CCN towards 3G cells is disabled in the cell"
4049 };
4050
4051 static gint
4052 de_rr_si2quater_meas_info_utran_fdd_desc(tvbuff_t *tvb, proto_tree *tree, gint bit_offset)
4053 {
4054    proto_tree *subtree, *subtree2;
4055    proto_item *item, *item2;
4056    gint curr_bit_offset, idx;
4057    gint xdd_cell_info, wsize, nwi, jwi, w[64], i, iused, xdd_indic0;
4058    guint8 value;
4059
4060    curr_bit_offset = bit_offset; 
4061
4062    item = proto_tree_add_text(tree, tvb, curr_bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_UTRAN_FDD_DESC].strptr);
4063    subtree = proto_item_add_subtree(item, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_UTRAN_FDD_DESC]);
4064    value = tvb_get_bits8(tvb,curr_bit_offset,1);
4065    curr_bit_offset += 1;
4066    if (value)
4067    {
4068       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_bandwidth_fdd, tvb, curr_bit_offset, 3, FALSE);
4069       curr_bit_offset += 3;
4070    }
4071    value = tvb_get_bits8(tvb,curr_bit_offset,1);
4072    curr_bit_offset += 1;
4073    while (value)
4074    {
4075       curr_bit_offset += 1; /* skip a 0 bit */
4076       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_fdd_uarfcn, tvb, curr_bit_offset, 14, FALSE);
4077       curr_bit_offset += 14;
4078       xdd_indic0 = tvb_get_bits8(tvb,curr_bit_offset,1);
4079       proto_tree_add_text(subtree,tvb, curr_bit_offset>>3, 1, "FDD Indic0: %d", xdd_indic0);
4080       curr_bit_offset += 1;
4081       idx = tvb_get_bits8(tvb,curr_bit_offset,5);
4082       proto_tree_add_text(subtree,tvb, curr_bit_offset>>3, 1, "Nr of FDD Cells : %d", idx);
4083       curr_bit_offset += 5;
4084       idx = convert_n_to_p[idx];
4085       item2 = proto_tree_add_text(subtree,tvb, curr_bit_offset>>3, (idx>>3)+1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_UTRAN_FDD_DESC].strptr);
4086       subtree2 = proto_item_add_subtree(item2, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_FDD_CELL_INFORMATION_FIELD]);
4087       proto_tree_add_text(subtree2,tvb, curr_bit_offset>>3, (idx>>3)+1, "Field is %d bits long", idx);
4088       if (xdd_indic0)
4089       {
4090          proto_tree_add_text(subtree2,tvb, curr_bit_offset>>3, 0, "Scrambling Code: %d", 0);
4091          proto_tree_add_text(subtree2,tvb, curr_bit_offset>>3, 0, "Diversity: %d", 0);
4092       }
4093       if (idx)
4094       {
4095          wsize = 10;
4096          nwi = 1;
4097          jwi = 0;
4098          i = 1;
4099
4100          while (idx > 0)
4101          {
4102             w[i] = tvb_get_bits16(tvb, curr_bit_offset, wsize, FALSE);
4103             curr_bit_offset += wsize;
4104             idx -= wsize;
4105             if (w[i] == 0)
4106             {
4107                idx = 0;
4108                break;
4109             }
4110             if (++jwi==nwi)
4111             {
4112                jwi = 0;
4113                nwi <<= 1;
4114                wsize--;
4115             }
4116             i++;
4117          }
4118          if (idx < 0)
4119          {
4120             curr_bit_offset += idx;
4121          }
4122          iused = i-1;
4123
4124          for (i=1; i <= iused; i++)
4125          {
4126             xdd_cell_info = f_k(i, w, 1024);
4127             proto_tree_add_text(subtree2,tvb, curr_bit_offset>>3, 0, "Scrambling Code: %d", xdd_cell_info & 0x01FF);
4128             proto_tree_add_text(subtree2,tvb, curr_bit_offset>>3, 0, "Diversity: %d", (xdd_cell_info >> 9) & 0x01);
4129          }
4130       }
4131       value = tvb_get_bits8(tvb,curr_bit_offset,1);
4132       curr_bit_offset += 1;
4133    }
4134    proto_item_set_len(item,((curr_bit_offset-bit_offset)>>3)+1);
4135
4136    return (curr_bit_offset - bit_offset);
4137 }
4138
4139 static gint
4140 de_rr_si2quater_meas_info_utran_tdd_desc(tvbuff_t *tvb, proto_tree *tree, gint bit_offset)
4141 {
4142    proto_tree *subtree, *subtree2;
4143    proto_item *item, *item2;
4144    gint curr_bit_offset, idx;
4145    gint xdd_cell_info, wsize, nwi, jwi, w[64], i, iused, xdd_indic0;
4146    guint8 value;
4147
4148    curr_bit_offset = bit_offset; 
4149
4150    item = proto_tree_add_text(tree, tvb, curr_bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_UTRAN_TDD_DESC].strptr);
4151    subtree = proto_item_add_subtree(item, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_UTRAN_TDD_DESC]);
4152    value = tvb_get_bits8(tvb,curr_bit_offset,1);
4153    curr_bit_offset += 1;
4154    if (value)
4155    {
4156       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_bandwidth_tdd, tvb, curr_bit_offset, 3, FALSE);
4157       curr_bit_offset += 3;
4158    }
4159    value = tvb_get_bits8(tvb,curr_bit_offset,1);
4160    curr_bit_offset += 1;
4161    while (value)
4162    {
4163       curr_bit_offset += 1; /* skip a 0 bit */
4164       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_tdd_uarfcn, tvb, curr_bit_offset, 14, FALSE);
4165       curr_bit_offset += 14;
4166       xdd_indic0 = tvb_get_bits8(tvb,curr_bit_offset,1);
4167       proto_tree_add_text(subtree,tvb, curr_bit_offset>>3, 1, "TDD Indic0: %d", xdd_indic0);
4168       curr_bit_offset += 1;
4169       idx = tvb_get_bits8(tvb,curr_bit_offset,5);
4170       proto_tree_add_text(subtree,tvb, curr_bit_offset>>3, 1, "Nr of TDD Cells : %d", idx);
4171       curr_bit_offset += 5;
4172       idx = convert_n_to_q[idx];
4173       item2 = proto_tree_add_text(subtree,tvb, curr_bit_offset>>3, (idx>>3)+1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_UTRAN_TDD_DESC].strptr);
4174       subtree2 = proto_item_add_subtree(item2, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_TDD_CELL_INFORMATION_FIELD]);
4175       proto_tree_add_text(subtree2,tvb, curr_bit_offset>>3, (idx>>3)+1, "Field is %d bits long", idx);
4176       if (xdd_indic0)
4177       {
4178          proto_tree_add_text(subtree2,tvb, curr_bit_offset>>3, 0, "Cell Parameter: %d", 0);
4179          proto_tree_add_text(subtree2,tvb, curr_bit_offset>>3, 0, "Sync Case TSTD: %d", 0);
4180          proto_tree_add_text(subtree2,tvb, curr_bit_offset>>3, 0, "Diversity TDD: %d", 0);
4181       }
4182       if (idx)
4183       {
4184          wsize = 9;
4185          nwi = 1;
4186          jwi = 0;
4187          i = 1;
4188
4189          while (idx > 0)
4190          {
4191             w[i] = tvb_get_bits16(tvb, curr_bit_offset, wsize, FALSE);
4192             curr_bit_offset += wsize;
4193             idx -= wsize;
4194             if (w[i] == 0)
4195             {
4196                idx = 0;
4197                break;
4198             }
4199             if (++jwi==nwi)
4200             {
4201                jwi = 0;
4202                nwi <<= 1;
4203                wsize--;
4204             }
4205             i++;
4206          }
4207          if (idx < 0)
4208          {
4209             curr_bit_offset += idx;
4210          }
4211          iused = i-1;
4212
4213          for (i=1; i <= iused; i++)
4214          {
4215             xdd_cell_info = f_k(i, w, 512);
4216             proto_tree_add_text(subtree2,tvb, curr_bit_offset>>3, 0, "Cell Parameter: %d", xdd_cell_info & 0x07F);
4217             proto_tree_add_text(subtree2,tvb, curr_bit_offset>>3, 0, "Sync Case TSTD: %d", (xdd_cell_info >> 7) & 0x01);
4218             proto_tree_add_text(subtree2,tvb, curr_bit_offset>>3, 0, "Diversity TDD: %d", (xdd_cell_info >> 8) & 0x01);
4219          }
4220       }
4221       value = tvb_get_bits8(tvb,curr_bit_offset,1);
4222       curr_bit_offset += 1;
4223    }
4224    proto_item_set_len(item,((curr_bit_offset-bit_offset)>>3)+1);
4225
4226    return (curr_bit_offset - bit_offset);
4227 }
4228
4229 static gint
4230 de_rr_rtd_desc(tvbuff_t *tvb, proto_tree *tree, gint bit_offset, rr_rest_octets_elem_idx_t id)
4231 {
4232    proto_tree *subtree;
4233    proto_item *item;
4234    gint curr_bit_offset, idx;
4235    guint8 value;
4236
4237    curr_bit_offset = bit_offset;
4238
4239    item = proto_tree_add_text(tree, tvb, curr_bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[id].strptr);
4240    subtree = proto_item_add_subtree(item, ett_gsm_rr_rest_octets_elem[id]);
4241    value = tvb_get_bits8(tvb,curr_bit_offset,1);
4242    curr_bit_offset += 1;
4243    if (value)
4244    {
4245       value = tvb_get_bits8(tvb,curr_bit_offset,1);
4246       curr_bit_offset += 1;
4247       if (value)
4248       {
4249          idx = tvb_get_bits8(tvb,curr_bit_offset,5);
4250          proto_tree_add_text(subtree,tvb, curr_bit_offset>>3, 1, "BA Index Start RTD: %d", idx);
4251          curr_bit_offset += 5;
4252       }
4253       else
4254          idx = 0;
4255       value = tvb_get_bits8(tvb,curr_bit_offset,1);
4256       curr_bit_offset += 1;
4257       while (value == 0)
4258       {
4259          proto_tree_add_text(subtree,tvb, curr_bit_offset>>3, 1, "RTD index %d: %d TDMA frame(s) modulo 51 TDMA frames", idx, tvb_get_bits8(tvb,curr_bit_offset,6));
4260          curr_bit_offset += 6;
4261          value = tvb_get_bits8(tvb,curr_bit_offset,1);
4262          curr_bit_offset += 1;
4263       }
4264       value = tvb_get_bits8(tvb,curr_bit_offset,1);
4265       curr_bit_offset += 1;
4266       while (value == 0)
4267       {
4268          idx += 1;
4269          value = tvb_get_bits8(tvb,curr_bit_offset,1);
4270          curr_bit_offset += 1;
4271          while (value == 0)
4272          {
4273             proto_tree_add_text(subtree,tvb, curr_bit_offset>>3, 1, "RTD index %d: %d TDMA frame(s) modulo 51 TDMA frames", idx, tvb_get_bits8(tvb,curr_bit_offset,6));
4274             curr_bit_offset += 6;
4275             value = tvb_get_bits8(tvb,curr_bit_offset,1);
4276             curr_bit_offset += 1;
4277          }
4278       }
4279    }
4280    value = tvb_get_bits8(tvb,curr_bit_offset,1);
4281    curr_bit_offset += 1;
4282    if (value)
4283    {
4284       value = tvb_get_bits8(tvb,curr_bit_offset,1);
4285       curr_bit_offset += 1;
4286       if (value)
4287       {
4288          idx = tvb_get_bits8(tvb,curr_bit_offset,5);
4289          proto_tree_add_text(subtree,tvb, curr_bit_offset>>3, 1, "BA Index Start RTD: %d", idx);
4290          curr_bit_offset += 5;
4291       }
4292       else
4293          idx = 0;
4294       value = tvb_get_bits8(tvb,curr_bit_offset,1);
4295       curr_bit_offset += 1;
4296       while (value == 0)
4297       {
4298          proto_tree_add_text(subtree,tvb, curr_bit_offset>>3, 2, "RTD index %d: %d/64 TDMA frame(s) modulo 51 TDMA frames", idx, tvb_get_bits16(tvb,curr_bit_offset,12,FALSE));
4299          curr_bit_offset += 12;
4300          value = tvb_get_bits8(tvb,curr_bit_offset,1);
4301          curr_bit_offset += 1;
4302       }
4303       value = tvb_get_bits8(tvb,curr_bit_offset,1);
4304       curr_bit_offset += 1;
4305       while (value == 0)
4306       {
4307          idx += 1;
4308          value = tvb_get_bits8(tvb,curr_bit_offset,1);
4309          curr_bit_offset += 1;
4310          while (value == 0)
4311          {
4312             proto_tree_add_text(subtree,tvb, curr_bit_offset>>3, 2, "RTD index %d: %d/64 TDMA frame(s) modulo 51 TDMA frames", idx, tvb_get_bits16(tvb,curr_bit_offset,12,FALSE));
4313             curr_bit_offset += 12;
4314             value = tvb_get_bits8(tvb,curr_bit_offset,1);
4315             curr_bit_offset += 1;
4316          }
4317       }
4318    }
4319    proto_item_set_len(item,((curr_bit_offset-bit_offset)>>3)+1);
4320
4321    return (curr_bit_offset - bit_offset);
4322 }
4323
4324 static gint
4325 de_rr_bsic_desc(tvbuff_t *tvb, proto_tree *tree, gint bit_offset, rr_rest_octets_elem_idx_t id)
4326 {
4327    proto_tree *subtree;
4328    proto_item *item;
4329    gint curr_bit_offset, idx;
4330    guint8 value;
4331
4332    curr_bit_offset = bit_offset;
4333    item = proto_tree_add_text(tree, tvb, curr_bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[id].strptr);
4334    subtree = proto_item_add_subtree(item, ett_gsm_rr_rest_octets_elem[id]);
4335    value = tvb_get_bits8(tvb,curr_bit_offset,1);
4336    curr_bit_offset += 1;
4337    if (value)
4338    {
4339       proto_tree_add_text(subtree,tvb, curr_bit_offset>>3, 1, "BA Index Start BSIC: %d", tvb_get_bits8(tvb,curr_bit_offset,5));
4340       curr_bit_offset += 5;
4341    }
4342    proto_tree_add_bits_item(subtree, hf_gsm_a_rr_bsic, tvb, bit_offset, 6, FALSE);
4343    curr_bit_offset += 6;
4344    idx = tvb_get_bits8(tvb,curr_bit_offset,7);
4345    proto_tree_add_text(subtree,tvb, curr_bit_offset>>3, 1, "Number Remaining BSIC: %d", idx);
4346    curr_bit_offset += 7;
4347    while (idx)
4348    {
4349       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_frequency_scrolling, tvb, curr_bit_offset, 1, FALSE);
4350       curr_bit_offset += 1;
4351       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_bsic, tvb, bit_offset, 6, FALSE);
4352       curr_bit_offset += 6;
4353       idx -= 1;
4354    }
4355    proto_item_set_len(item,((curr_bit_offset-bit_offset)>>3)+1);
4356
4357    return(curr_bit_offset - bit_offset);
4358 }
4359
4360 static gint
4361 de_rr_report_priority_desc(tvbuff_t *tvb, proto_tree *tree, gint bit_offset, rr_rest_octets_elem_idx_t id)
4362 {
4363    proto_tree *subtree;
4364    proto_item *item;
4365    gint curr_bit_offset, idx;
4366
4367    curr_bit_offset = bit_offset;
4368
4369    item = proto_tree_add_text(tree, tvb, curr_bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[id].strptr);
4370    subtree = proto_item_add_subtree(item, ett_gsm_rr_rest_octets_elem[id]);
4371    idx = tvb_get_bits8(tvb,curr_bit_offset,7);
4372    proto_tree_add_text(subtree,tvb, curr_bit_offset>>3, 1, "Number Cells: %d", idx);
4373    curr_bit_offset += 7;
4374    while (idx)
4375    {
4376       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_rep_priority, tvb, curr_bit_offset, 1, FALSE);
4377       curr_bit_offset += 1;
4378       idx -= 1;
4379    }
4380    proto_item_set_len(item,((curr_bit_offset-bit_offset)>>3)+1);
4381
4382    return(curr_bit_offset - bit_offset);
4383 }
4384
4385 static gint
4386 de_rr_meas_param_desc(tvbuff_t *tvb, proto_tree *tree, gint bit_offset, rr_rest_octets_elem_idx_t id)
4387 {
4388    proto_tree *subtree;
4389    proto_item *item;
4390    gint curr_bit_offset;
4391    guint8 value;
4392
4393    curr_bit_offset = bit_offset;
4394    item = proto_tree_add_text(tree, tvb, curr_bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[id].strptr);
4395    subtree = proto_item_add_subtree(item, ett_gsm_rr_rest_octets_elem[id]);
4396    if (id == DE_RR_REST_OCTETS_GPRS_MEAS_PARAM_DESC)
4397    {
4398       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_report_type, tvb, curr_bit_offset, 1, FALSE);
4399       curr_bit_offset += 1;
4400       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_reporting_rate, tvb, curr_bit_offset, 1, FALSE);
4401       curr_bit_offset +=1;
4402       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_invalid_bsic_reporting, tvb, curr_bit_offset, 1, FALSE);
4403       curr_bit_offset +=1;
4404    }
4405    value = tvb_get_bits8(tvb,curr_bit_offset,1);
4406    curr_bit_offset += 1;
4407    if (value)
4408    {
4409       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_multiband_reporting, tvb, curr_bit_offset, 2, FALSE);
4410       curr_bit_offset += 2;
4411    }
4412    value = tvb_get_bits8(tvb,curr_bit_offset,1);
4413    curr_bit_offset += 1;
4414    if (value)
4415    {
4416       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_serving_band_reporting, tvb, curr_bit_offset, 2, FALSE);
4417       curr_bit_offset += 2;
4418    }
4419    proto_tree_add_bits_item(subtree, hf_gsm_a_rr_scale_ord, tvb, curr_bit_offset, 2, FALSE);
4420    curr_bit_offset += 2;
4421    value = tvb_get_bits8(tvb,curr_bit_offset,1);
4422    curr_bit_offset += 1;
4423    if (value)
4424    {
4425       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_900_reporting_offset, tvb, curr_bit_offset, 3, FALSE);
4426       curr_bit_offset += 3;
4427       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_900_reporting_threshold, tvb, curr_bit_offset, 3, FALSE);
4428       curr_bit_offset += 3;
4429    }
4430    value = tvb_get_bits8(tvb,curr_bit_offset,1);
4431    curr_bit_offset += 1;
4432    if (value)
4433    {
4434       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_1800_reporting_offset, tvb, curr_bit_offset, 3, FALSE);
4435       curr_bit_offset += 3;
4436       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_1800_reporting_threshold, tvb, curr_bit_offset, 3, FALSE);
4437       curr_bit_offset += 3;
4438    }
4439    value = tvb_get_bits8(tvb,curr_bit_offset,1);
4440    curr_bit_offset += 1;
4441    if (value)
4442    {
4443       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_400_reporting_offset, tvb, curr_bit_offset, 3, FALSE);
4444       curr_bit_offset += 3;
4445       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_400_reporting_threshold, tvb, curr_bit_offset, 3, FALSE);
4446       curr_bit_offset += 3;
4447    }
4448    value = tvb_get_bits8(tvb,curr_bit_offset,1);
4449    curr_bit_offset += 1;
4450    if (value)
4451    {
4452       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_1900_reporting_offset, tvb, curr_bit_offset, 3, FALSE);
4453       curr_bit_offset += 3;
4454       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_1900_reporting_threshold, tvb, curr_bit_offset, 3, FALSE);
4455       curr_bit_offset += 3;
4456    }
4457    value = tvb_get_bits8(tvb,curr_bit_offset,1);
4458    curr_bit_offset += 1;
4459    if (value)
4460    {
4461       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_850_reporting_offset, tvb, curr_bit_offset, 3, FALSE);
4462       curr_bit_offset += 3;
4463       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_850_reporting_threshold, tvb, curr_bit_offset, 3, FALSE);
4464       curr_bit_offset += 3;
4465    }
4466    proto_item_set_len(item,((curr_bit_offset-bit_offset)>>3)+1);
4467
4468    return(curr_bit_offset - bit_offset);
4469 }
4470
4471 static gint
4472 de_rr_3g_add_meas_param_desc2(tvbuff_t *tvb, proto_tree *tree, gint bit_offset)
4473 {
4474    proto_tree *subtree;
4475    proto_item *item;
4476    gint curr_bit_offset;
4477    guint8 value;
4478
4479    curr_bit_offset = bit_offset;
4480    item = proto_tree_add_text(tree, tvb, curr_bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_3G_ADD_MEAS_PARAM_DESC2].strptr);
4481    subtree = proto_item_add_subtree(item, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_3G_ADD_MEAS_PARAM_DESC2]);
4482    value = tvb_get_bits8(tvb,curr_bit_offset,1);
4483    curr_bit_offset += 1;
4484    if (value)
4485    {
4486       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_fdd_reporting_threshold_2, tvb, curr_bit_offset, 6, FALSE);
4487       curr_bit_offset += 6;
4488    }
4489    proto_item_set_len(item,((curr_bit_offset-bit_offset)>>3)+1);
4490
4491    return(curr_bit_offset - bit_offset);
4492 }
4493
4494 static guint8
4495 de_rr_si2quater_rest_oct(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4496 {
4497         proto_tree      *subtree, *subtree2, *subtree3;
4498         proto_item      *item, *item2, *item3;
4499         guint32 curr_offset;
4500    gint bit_offset, bit_offset_sav, idx;
4501    guint8 value;
4502
4503         len = 20;
4504         curr_offset = offset;
4505    bit_offset = curr_offset<<3;
4506
4507         item = proto_tree_add_text(tree, tvb, curr_offset, len, "%s",
4508                 gsm_rr_elem_strings[DE_RR_SI2QUATER_REST_OCT].strptr);
4509
4510         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_SI2QUATER_REST_OCT]);
4511
4512    proto_tree_add_bits_item(subtree, hf_gsm_a_rr_ba_ind, tvb, bit_offset, 1, FALSE);
4513    bit_offset += 1;
4514    proto_tree_add_bits_item(subtree, hf_gsm_a_rr_3g_ba_ind, tvb, bit_offset, 1, FALSE);
4515    bit_offset += 1;
4516    proto_tree_add_bits_item(subtree, hf_gsm_a_rr_mp_change_mark, tvb, bit_offset, 1, FALSE);
4517    bit_offset += 1;
4518    proto_tree_add_bits_item(subtree, hf_gsm_a_rr_si2quater_index, tvb, bit_offset, 4, FALSE);
4519    bit_offset += 4;
4520    proto_tree_add_bits_item(subtree, hf_gsm_a_rr_si2quater_count, tvb, bit_offset, 4, FALSE);
4521    bit_offset += 4;
4522    value = tvb_get_bits8(tvb,bit_offset,1);
4523    bit_offset += 1;
4524    if (value)
4525    { /* Measurement Parameters Description */
4526       bit_offset_sav = bit_offset;
4527       item2 = proto_tree_add_text(subtree, tvb, bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_MEAS_PARAM_DESC].strptr);
4528       subtree2 = proto_item_add_subtree(item2, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_MEAS_PARAM_DESC]);
4529       proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_gsm_report_type, tvb, bit_offset, 1, FALSE);
4530       bit_offset += 1;
4531       proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_serving_band_reporting, tvb, bit_offset, 2, FALSE);
4532       bit_offset += 2;
4533       proto_item_set_len(item2,((bit_offset-bit_offset_sav)>>3)+1);
4534    }
4535    value  = tvb_get_bits8(tvb,bit_offset,1);
4536    bit_offset += 1;
4537    if (value)
4538    { /* GPRS Real Time Difference Description */
4539       bit_offset += de_rr_rtd_desc(tvb, subtree, bit_offset, DE_RR_REST_OCTETS_GPRS_RTD_DESC);
4540
4541    }
4542    value  = tvb_get_bits8(tvb,bit_offset,1);
4543    bit_offset += 1;
4544    if (value)
4545    { /* GPRS BSIC Description */
4546       bit_offset += de_rr_bsic_desc(tvb, subtree, bit_offset, DE_RR_REST_OCTETS_GPRS_BSIC_DESC);
4547    }
4548    value  = tvb_get_bits8(tvb,bit_offset,1);
4549    bit_offset += 1;
4550    if (value)
4551    { /* GPRS Report Priority Description */
4552       bit_offset += de_rr_report_priority_desc(tvb, subtree, bit_offset, DE_RR_REST_OCTETS_GPRS_REPORT_PRIO_DESC);
4553    }
4554    value  = tvb_get_bits8(tvb,bit_offset,1);
4555    bit_offset += 1;
4556    if (value)
4557    { /* GPRS Measurement Parameters Description */
4558       bit_offset += de_rr_meas_param_desc(tvb, subtree, bit_offset, DE_RR_REST_OCTETS_GPRS_MEAS_PARAM_DESC);
4559    }
4560    value = tvb_get_bits8(tvb,bit_offset,1);
4561    bit_offset += 1;
4562    if (value)
4563    { /* NC Measurement Parameters */
4564       bit_offset_sav = bit_offset;
4565       item2 = proto_tree_add_text(subtree, tvb, bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_NC_MEAS_PARAM].strptr);
4566       subtree2 = proto_item_add_subtree(item2, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_NC_MEAS_PARAM]);
4567       proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_network_control_order, tvb, bit_offset, 2, FALSE);
4568       bit_offset += 2;
4569       value = tvb_get_bits8(tvb,bit_offset,1);
4570       bit_offset += 1;
4571       if (value)
4572       {
4573          proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_nc_non_drx_period, tvb, bit_offset, 3, FALSE);
4574          bit_offset += 3;
4575          proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_nc_reporting_period_i, tvb, bit_offset, 3, FALSE);
4576          bit_offset += 3;
4577          proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_nc_reporting_period_t, tvb, bit_offset, 3, FALSE);
4578          bit_offset += 3;
4579       }
4580       proto_item_set_len(item2,((bit_offset-bit_offset_sav)>>3)+1);
4581    }
4582    value = tvb_get_bits8(tvb,bit_offset,1);
4583    bit_offset += 1;
4584    if (value)
4585    { /* SI 2quater Extension Information */
4586       bit_offset_sav = bit_offset;
4587       item2 = proto_tree_add_text(subtree, tvb, bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_SI2Q_EXT_INFO].strptr);
4588       subtree2 = proto_item_add_subtree(item2, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_SI2Q_EXT_INFO]);
4589       idx = tvb_get_bits8(tvb,bit_offset,8);
4590       proto_tree_add_text(subtree2,tvb, bit_offset>>3, 1, "Extension Length: %d", idx);
4591       bit_offset += 8;
4592       proto_item_set_len(item2,((bit_offset+idx+1-bit_offset_sav)>>3)+1);
4593       value = tvb_get_bits8(tvb,bit_offset,1);
4594       bit_offset += 1;
4595       if (value)
4596       { /* CCN Support Description */
4597          bit_offset_sav = bit_offset;
4598          item3 = proto_tree_add_text(subtree2, tvb, bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_CCN_SUPPORT_DESC].strptr);
4599          subtree3 = proto_item_add_subtree(item3, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_CCN_SUPPORT_DESC]);
4600          value = tvb_get_bits8(tvb,bit_offset,7);
4601          proto_tree_add_text(subtree3,tvb, bit_offset>>3, 1, "Number Cells: %d", value);
4602          bit_offset += 7;
4603          idx -= 7;
4604          item2 = proto_tree_add_text(subtree3,tvb, bit_offset>>3, (value>>3)+1, "CCN Supported: ");
4605          while (value)
4606          {
4607             proto_item_append_text(item2,"%d",tvb_get_bits8(tvb,bit_offset,1));
4608             bit_offset += 1;
4609             value -= 1;
4610             idx -= 1;
4611          }
4612          proto_item_set_len(item3,((bit_offset+-bit_offset_sav)>>3)+1);
4613       }
4614       bit_offset += idx;
4615    }
4616    value = tvb_get_bits8(tvb,bit_offset,1);
4617    bit_offset += 1;
4618    if (value)
4619    { /* 3G Neighbour Cell Description */
4620       bit_offset_sav = bit_offset;
4621       item2 = proto_tree_add_text(subtree, tvb, bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_3G_NEIGH_CELL_DESC].strptr);
4622       subtree2 = proto_item_add_subtree(item2, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_3G_NEIGH_CELL_DESC]);
4623       value = tvb_get_bits8(tvb,bit_offset,1);
4624       bit_offset += 1;
4625       if (value)
4626       {
4627          proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_index_start_3g, tvb, bit_offset, 7, FALSE);
4628          bit_offset += 7;
4629       }
4630       value = tvb_get_bits8(tvb,bit_offset,1);
4631       bit_offset += 1;
4632       if (value)
4633       {
4634          proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_absolute_index_start_emr, tvb, bit_offset, 7, FALSE);
4635          bit_offset += 7;
4636       }
4637       value = tvb_get_bits8(tvb,bit_offset,1);
4638       bit_offset += 1;
4639       if (value)
4640       { /* UTRAN FDD Description */
4641          bit_offset += de_rr_si2quater_meas_info_utran_fdd_desc(tvb, subtree2, bit_offset);
4642       }
4643       value = tvb_get_bits8(tvb,bit_offset,1);
4644       bit_offset += 1;
4645       if (value)
4646       { /* UTRAN TDD Description */
4647          bit_offset += de_rr_si2quater_meas_info_utran_tdd_desc(tvb, subtree2, bit_offset);
4648       }
4649       proto_item_set_len(item2,((bit_offset-bit_offset_sav)>>3)+1);
4650    }
4651    value = tvb_get_bits8(tvb,bit_offset,1);
4652    bit_offset += 1;
4653    if (value)
4654    { /* 3G Measurement Parameters Description */
4655       bit_offset_sav = bit_offset;
4656       item2 = proto_tree_add_text(subtree, tvb, bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_3G_MEAS_PARAM_DESC].strptr);
4657       subtree2 = proto_item_add_subtree(item2, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_3G_MEAS_PARAM_DESC]);
4658       proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_qsearch_i, tvb, bit_offset, 4, FALSE);
4659       bit_offset += 4;
4660       proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_qsearch_c_initial, tvb, bit_offset, 1, FALSE);
4661       bit_offset += 1;
4662       value = tvb_get_bits8(tvb,bit_offset,1);
4663       bit_offset += 1;
4664       if (value)
4665       {
4666          proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_fdd_qoffset, tvb, bit_offset, 4, FALSE);
4667          bit_offset += 4;
4668          proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_fdd_rep_quant, tvb, bit_offset, 1, FALSE);
4669          bit_offset += 1;
4670          proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_fdd_multirat_reporting, tvb, bit_offset, 2, FALSE);
4671          bit_offset += 2;
4672          proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_fdd_qmin, tvb, bit_offset, 3, FALSE);
4673          bit_offset += 3;
4674       }
4675       value = tvb_get_bits8(tvb,bit_offset,1);
4676       bit_offset += 1;
4677       if (value)
4678       {
4679          proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_tdd_qoffset, tvb, bit_offset, 4, FALSE);
4680          bit_offset += 4;
4681          proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_tdd_multirat_reporting, tvb, bit_offset, 2, FALSE);
4682          bit_offset += 2;
4683       }
4684       proto_item_set_len(item2,((bit_offset-bit_offset_sav)>>3)+1);
4685    }
4686    value = tvb_get_bits8(tvb,bit_offset,1);
4687    bit_offset += 1;
4688    if (value)
4689    { /* GPRS 3G Measurement Parameters Description */
4690       bit_offset_sav = bit_offset;
4691       item2 = proto_tree_add_text(subtree, tvb, bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_GPRS_3G_MEAS_PARAM_DESC].strptr);
4692       subtree2 = proto_item_add_subtree(item2, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_GPRS_3G_MEAS_PARAM_DESC]);
4693       proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_qsearch_p, tvb, bit_offset, 4, FALSE);
4694       bit_offset += 4;
4695       proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_3g_search_prio, tvb, bit_offset, 1, FALSE);
4696       bit_offset += 1;
4697       value = tvb_get_bits8(tvb,bit_offset,1);
4698       bit_offset += 1;
4699       if (value)
4700       {
4701          proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_fdd_rep_quant, tvb, bit_offset, 1, FALSE);
4702          bit_offset += 1;
4703          proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_fdd_multirat_reporting, tvb, bit_offset, 2, FALSE);
4704          bit_offset += 2;
4705       }
4706       value = tvb_get_bits8(tvb,bit_offset,1);
4707       bit_offset += 1;
4708       if (value)
4709       {
4710          proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_fdd_reporting_offset, tvb, bit_offset, 3, FALSE);
4711          bit_offset += 3;
4712          proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_fdd_reporting_threshold, tvb, bit_offset, 3, FALSE);
4713          bit_offset += 3;
4714       }
4715       value = tvb_get_bits8(tvb,bit_offset,1);
4716       bit_offset += 1;
4717       if (value)
4718       {
4719          proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_tdd_multirat_reporting, tvb, bit_offset, 2, FALSE);
4720          bit_offset += 2;
4721       }
4722       value = tvb_get_bits8(tvb,bit_offset,1);
4723       bit_offset += 1;
4724       if (value)
4725       {
4726          proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_tdd_reporting_offset, tvb, bit_offset, 3, FALSE);
4727          bit_offset += 3;
4728          proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_tdd_reporting_threshold, tvb, bit_offset, 3, FALSE);
4729          bit_offset += 3;
4730       }
4731       proto_item_set_len(item2,((bit_offset-bit_offset_sav)>>3)+1);
4732    }
4733    if (((curr_offset + len)<<3) - bit_offset > 0)
4734    {
4735       /* There is still room left in the Rest Octets IE */
4736       if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
4737       { /* Additions in Rel-5 */
4738          bit_offset += 1;
4739          value = tvb_get_bits8(tvb,bit_offset,1);
4740          bit_offset += 1;
4741          if (value)
4742          { /* 3G Additional Measurement Parameters Description */
4743             bit_offset_sav = bit_offset;
4744             item2 = proto_tree_add_text(subtree, tvb, bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_3G_ADD_MEAS_PARAM_DESC].strptr);
4745             subtree2 = proto_item_add_subtree(item2, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_3G_ADD_MEAS_PARAM_DESC]);
4746             proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_fdd_qmin_offset, tvb, bit_offset, 3, FALSE);
4747             bit_offset += 3;
4748             proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_fdd_rscpmin, tvb, bit_offset, 4, FALSE);
4749             bit_offset += 4;
4750             proto_item_set_len(item2,((bit_offset-bit_offset_sav)>>3)+1);
4751          }
4752          value = tvb_get_bits8(tvb,bit_offset,1);
4753          bit_offset += 1;
4754          if (value)
4755          { /* 3G Additional Measurement Parameters Description 2 */
4756             bit_offset += de_rr_3g_add_meas_param_desc2(tvb, subtree, bit_offset);
4757          }
4758          if (((curr_offset + len)<<3) - bit_offset > 0)
4759          {
4760             /* There is still room left in the Rest Octets IE */
4761             if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
4762             { /* Additions in Rel-6 */
4763                bit_offset += 1;
4764                proto_tree_add_bits_item(subtree, hf_gsm_a_rr_3g_ccn_active, tvb, bit_offset, 1, FALSE);
4765                bit_offset += 1;
4766                if (((curr_offset + len)<<3) - bit_offset > 0)
4767                {
4768                   /* There is still room left in the Rest Octets IE */
4769                   if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
4770                   { /* Additions in Rel-7 */
4771                      bit_offset += 1;
4772                      value = tvb_get_bits8(tvb,bit_offset,1);
4773                      bit_offset += 1;
4774                      if (value)
4775                      {
4776                         proto_tree_add_bits_item(subtree, hf_gsm_a_rr_700_reporting_offset, tvb, bit_offset, 3, FALSE);
4777                         bit_offset += 3;
4778                         proto_tree_add_bits_item(subtree, hf_gsm_a_rr_700_reporting_threshold, tvb, bit_offset, 3, FALSE);
4779                         bit_offset += 3;
4780                      }
4781                      value = tvb_get_bits8(tvb,bit_offset,1);
4782                      bit_offset += 1;
4783                      if (value)
4784                      {
4785                         proto_tree_add_bits_item(subtree, hf_gsm_a_rr_810_reporting_offset, tvb, bit_offset, 3, FALSE);
4786                         bit_offset += 3;
4787                         proto_tree_add_bits_item(subtree, hf_gsm_a_rr_810_reporting_threshold, tvb, bit_offset, 3, FALSE);
4788                         bit_offset += 3;
4789                      }
4790                   }
4791                   else
4792                      bit_offset += 1;
4793                }
4794             }
4795             else
4796                bit_offset += 1;
4797          }
4798       }
4799       else bit_offset += 1;
4800    }
4801
4802         curr_offset = curr_offset + len;
4803
4804         return curr_offset-offset;
4805 }
4806
4807 /*
4808  * [3] 10.5.2.34 SI 3 Rest Octets
4809  */
4810 static const value_string gsm_a_rr_temporary_offset_vals[] = {
4811    { 0, "0 dB"},
4812    { 1, "10 dB"},
4813    { 2, "20 dB"},
4814    { 3, "30 dB"},
4815    { 4, "40 dB"},
4816    { 5, "50 dB"},
4817    { 6, "60 dB"},
4818    { 7, "infinity"},
4819    { 0, NULL }
4820 };
4821
4822 static const value_string gsm_a_rr_cell_reselect_offset_vals[] = {
4823    { 0, "0 dB"},
4824    { 1, "2 dB"},
4825    { 2, "4 dB"},
4826    { 3, "6 dB"},
4827    { 4, "8 dB"},
4828    { 5, "10 dB"},
4829    { 6, "12 dB"},
4830    { 7, "14 dB"},
4831    { 8, "16 dB"},
4832    { 9, "18 dB"},
4833    {10, "20 dB"},
4834    {11, "22 dB"},
4835    {12, "24 dB"},
4836    {13, "26 dB"},
4837    {14, "28 dB"},
4838    {15, "30 dB"},
4839    {16, "32 dB"},
4840    {17, "34 dB"},
4841    {18, "36 dB"},
4842    {19, "38 dB"},
4843    {20, "40 dB"},
4844    {21, "42 dB"},
4845    {22, "44 dB"},
4846    {23, "46 dB"},
4847    {24, "48 dB"},
4848    {25, "50 dB"},
4849    {26, "52 dB"},
4850    {27, "54 dB"},
4851    {28, "56 dB"},
4852    {29, "58 dB"},
4853    {30, "60 dB"},
4854    {31, "62 dB"},
4855    {32, "64 dB"},
4856    {33, "66 dB"},
4857    {34, "68 dB"},
4858    {35, "70 dB"},
4859    {36, "72 dB"},
4860    {37, "74 dB"},
4861    {38, "76 dB"},
4862    {39, "78 dB"},
4863    {40, "80 dB"},
4864    {41, "82 dB"},
4865    {42, "84 dB"},
4866    {43, "86 dB"},
4867    {44, "88 dB"},
4868    {45, "90 dB"},
4869    {46, "92 dB"},
4870    {47, "94 dB"},
4871    {48, "96 dB"},
4872    {49, "98 dB"},
4873    {50, "100 dB"},
4874    {51, "102 dB"},
4875    {52, "104 dB"},
4876    {53, "106 dB"},
4877    {54, "108 dB"},
4878    {55, "110 dB"},
4879    {56, "112 dB"},
4880    {57, "114 dB"},
4881    {58, "116 dB"},
4882    {59, "118 dB"},
4883    {60, "120 dB"},
4884    {61, "122 dB"},
4885    {62, "124 dB"},
4886    {63, "126 dB"},
4887    { 0, NULL }
4888 };
4889
4890 static const value_string gsm_a_rr_penalty_time_vals[] = {
4891    { 0, "20 s"},
4892    { 1, "40 s"},
4893    { 2, "60 s"},
4894    { 3, "80 s"},
4895    { 4, "100 s"},
4896    { 5, "120 s"},
4897    { 6, "140 s"},
4898    { 7, "160 s"},
4899    { 8, "180 s"},
4900    { 9, "200 s"},
4901    {10, "220 s"},
4902    {11, "240 s"},
4903    {12, "260 s"},
4904    {13, "280 s"},
4905    {14, "300 s"},
4906    {15, "320 s"},
4907    {16, "340 s"},
4908    {17, "360 s"},
4909    {18, "380 s"},
4910    {19, "400 s"},
4911    {20, "420 s"},
4912    {21, "440 s"},
4913    {22, "460 s"},
4914    {23, "480 s"},
4915    {24, "500 s"},
4916    {25, "520 s"},
4917    {26, "540 s"},
4918    {27, "560 s"},
4919    {28, "580 s"},
4920    {29, "600 s"},
4921    {30, "620 s"},
4922    {31, "Cell Reselect Offset is subtracted from C2 and Temporary Offset is ignored"},
4923    { 0, NULL }
4924 };
4925
4926 static gint
4927 de_rr_rest_oct_opt_sel_param(tvbuff_t *tvb, proto_tree *tree, gint bit_offset)
4928 {
4929    proto_tree *subtree;
4930    proto_item *item;
4931    gint curr_bit_offset;
4932
4933    curr_bit_offset = bit_offset;
4934
4935    if (gsm_a_rr_is_bit_high(tvb,curr_bit_offset) == TRUE)
4936    { /* Selection Parameters */
4937       curr_bit_offset += 1;
4938       item = proto_tree_add_text(tree, tvb, curr_bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_OPTIONAL_SEL_PARAM].strptr);
4939       subtree = proto_item_add_subtree(item, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_OPTIONAL_SEL_PARAM]);
4940       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_cbq, tvb, curr_bit_offset, 1, FALSE);
4941       curr_bit_offset += 1;
4942       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_cell_reselect_offset, tvb, curr_bit_offset, 6, FALSE);
4943       curr_bit_offset += 6;
4944       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_temporary_offset, tvb, curr_bit_offset, 3, FALSE);
4945       curr_bit_offset += 3;
4946       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_penalty_time, tvb, curr_bit_offset, 5, FALSE);
4947       curr_bit_offset += 5;
4948       proto_item_set_len(item,((curr_bit_offset-bit_offset)>>3)+1);
4949    }
4950    else
4951       curr_bit_offset += 1;
4952
4953    return (curr_bit_offset - bit_offset);
4954 }
4955
4956 static const value_string gsm_a_rr_si13_position_vals[] = {
4957    { 0, "SYSTEM INFORMATION TYPE 13 message is sent on BCCH Norm"},
4958    { 1, "SYSTEM INFORMATION TYPE 13 message is sent on BCCH Ext"},
4959    { 0, NULL }
4960 };
4961
4962 static gint
4963 de_rr_rest_oct_gprs_indicator(tvbuff_t *tvb, proto_tree *tree, gint bit_offset)
4964 {
4965    proto_tree *subtree;
4966    proto_item *item;
4967    gint curr_bit_offset;
4968
4969    curr_bit_offset = bit_offset;
4970
4971    item = proto_tree_add_text(tree, tvb, curr_bit_offset>>3, 1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_GPRS_INDICATOR].strptr);
4972    subtree = proto_item_add_subtree(item, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_GPRS_INDICATOR]);
4973    proto_tree_add_text(subtree, tvb, curr_bit_offset>>3, 1, "RA Colour: %d",tvb_get_bits8(tvb,curr_bit_offset,3));
4974    curr_bit_offset += 3;
4975    proto_tree_add_bits_item(subtree, hf_gsm_a_rr_si13_position, tvb, curr_bit_offset, 1, FALSE);
4976    curr_bit_offset += 1;
4977
4978    return (curr_bit_offset - bit_offset);
4979 }
4980
4981 static const value_string gsm_a_rr_power_offset_vals[] = {
4982         { 0, "0 dB"},
4983         { 1, "2 dB"},
4984         { 2, "4 dB"},
4985    { 3, "8 dB"},
4986         { 0, NULL }
4987 };
4988
4989 static const true_false_string gsm_a_rr_si2quater_position_value = {
4990    "SYSTEM INFORMATION TYPE 2 quater message is sent on BCCH Ext",
4991    "SYSTEM INFORMATION TYPE 2 quater message is sent on BCCH Norm"
4992 };
4993
4994 static const true_false_string gsm_a_rr_si13alt_position_value = {
4995    "If Iu mode is supported in the cell, SYSTEM INFORMATION TYPE 13alt message is sent on BCCH Ext",
4996    "If Iu mode is supported in the cell, SYSTEM INFORMATION TYPE 13alt message is sent on BCCH Norm"
4997 };
4998
4999 static guint8
5000 de_rr_si3_rest_oct(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5001 {
5002         proto_tree      *subtree;
5003         proto_item      *item;
5004         guint32 curr_offset;
5005    gint bit_offset;
5006    gboolean gprs_indicator;
5007
5008         len = 4;
5009         curr_offset = offset;
5010    bit_offset = curr_offset << 3;
5011
5012         item = proto_tree_add_text(tree, tvb, curr_offset, len, "%s",
5013                 gsm_rr_elem_strings[DE_RR_SI3_REST_OCT].strptr);
5014
5015         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_SI3_REST_OCT]);
5016
5017    bit_offset += de_rr_rest_oct_opt_sel_param(tvb, subtree, bit_offset);
5018
5019    if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
5020    { /* Optional Power Offset */
5021       bit_offset += 1;
5022       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_power_offset, tvb, bit_offset, 2, FALSE);
5023       bit_offset += 2;
5024    }
5025    else
5026       bit_offset += 1;
5027    if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
5028       proto_tree_add_text(subtree, tvb, bit_offset>>3, 1, "SYSTEM INFORMATION TYPE 2ter message is available");
5029    else
5030       proto_tree_add_text(subtree, tvb, bit_offset>>3, 1, "SYSTEM INFORMATION TYPE 2ter message is not available");
5031    bit_offset += 1;
5032    if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
5033       proto_tree_add_text(subtree, tvb, bit_offset>>3, 1, "Early Classmark Sending is allowed");
5034    else
5035       proto_tree_add_text(subtree, tvb, bit_offset>>3, 1, "Early Classmark Sending is forbidden");
5036    bit_offset += 1;
5037    if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
5038    { /* Scheduling if and where */
5039       bit_offset += 1;
5040       proto_tree_add_text(subtree, tvb, bit_offset>>3, 1, "Where: %d",tvb_get_bits8(tvb,bit_offset,3));
5041       bit_offset += 3;
5042    }
5043    else
5044       bit_offset += 1;
5045    gprs_indicator = gsm_a_rr_is_bit_high(tvb,bit_offset);
5046    if (gprs_indicator == TRUE)
5047    { /* GPRS indicator */
5048       bit_offset += 1;
5049       bit_offset += de_rr_rest_oct_gprs_indicator(tvb, subtree, bit_offset);
5050    }
5051    else
5052       bit_offset += 1;
5053    if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
5054       proto_tree_add_text(subtree, tvb, bit_offset>>3, 1, "3G Early Classmark Sending Restriction: The sending of UTRAN,CDMA2000 and GERAN IU MODE CLASSMARK CHANGE messages are controlled by the Early Classmark Sending Control parameter");
5055    else
5056       proto_tree_add_text(subtree, tvb, bit_offset>>3, 1, "3G Early Classmark Sending Restriction: Neither UTRAN, CDMA2000 nor GERAN IU MODE CLASSMARK CHANGE message shall be sent with the Early classmark sending");
5057    bit_offset += 1;
5058    if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
5059    { /* SI2quater Indicator */
5060       bit_offset += 1;
5061       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_si2quater_position, tvb, bit_offset, 1, FALSE);
5062       bit_offset += 1;
5063    }
5064    else
5065       bit_offset += 1;
5066    if (gprs_indicator == FALSE)
5067    {
5068       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_si13alt_position, tvb, bit_offset, 1, FALSE);
5069       bit_offset += 1;
5070    }
5071    
5072         curr_offset = curr_offset + len;
5073
5074         return curr_offset-offset;
5075 }
5076
5077 /*
5078  * [3] 10.5.2.32 SI 4 Rest Octets
5079  */
5080 static const value_string gsm_a_rr_prio_thr_vals[] = {
5081    { 0, "0 dB"},
5082    { 1, "6 dB"},
5083    { 2, "12 dB"},
5084    { 3, "18 dB"},
5085    { 4, "24 dB"},
5086    { 5, "30 dB"},
5087    { 6, "36 dB"},
5088    { 7, "Infinite"},
5089    { 0, NULL }
5090 };
5091
5092 static const value_string gsm_a_rr_lsa_offset_vals[] = {
5093    { 0, "0 dB"},
5094    { 1, "4 dB"},
5095    { 2, "8 dB"},
5096    { 3, "16 dB"},
5097    { 4, "24 dB"},
5098    { 5, "32 dB"},
5099    { 6, "48 dB"},
5100    { 7, "64 dB"},
5101    { 0, NULL }
5102 };
5103
5104 static guint8
5105 de_rr_si4_rest_oct(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5106 {
5107         proto_tree      *subtree, *subtree2, *subtree3;
5108         proto_item      *item, *item2, *item3;
5109         guint32 curr_offset;
5110    gint bit_offset, bit_offset_sav, bit_offset_sav2;
5111    guint value;
5112
5113         len = tvb_length_remaining(tvb,offset);
5114         if (len==0)
5115                 return 0;
5116
5117         curr_offset = offset;
5118    bit_offset = curr_offset << 3;
5119
5120         item = proto_tree_add_text(tree, tvb, curr_offset, len, "%s",
5121                 gsm_rr_elem_strings[DE_RR_SI4_REST_OCT].strptr);
5122
5123         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_SI4_REST_OCT]);
5124
5125    item2 = proto_tree_add_text(subtree, tvb, bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_SI4_REST_OCTETS_O].strptr);
5126
5127         subtree2 = proto_item_add_subtree(item2, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_SI4_REST_OCTETS_O]);
5128
5129    bit_offset += de_rr_rest_oct_opt_sel_param(tvb, subtree2, bit_offset);
5130
5131    if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
5132    { /* Optional Power Offset */
5133       bit_offset += 1;
5134       proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_power_offset, tvb, bit_offset, 2, FALSE);
5135       bit_offset += 2;
5136    }
5137    else
5138       bit_offset += 1;
5139    if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
5140    {
5141       bit_offset += 1;
5142       bit_offset += de_rr_rest_oct_gprs_indicator(tvb, subtree2, bit_offset);
5143    }
5144    else
5145       bit_offset += 1;
5146    proto_item_set_len(item2,(bit_offset>>3)+1-curr_offset);
5147    if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
5148    { /* SI4 Rest Octets_S */
5149       bit_offset += 1;
5150       bit_offset_sav = bit_offset;
5151       item2 = proto_tree_add_text(subtree, tvb, bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_SI4_REST_OCTETS_S].strptr);
5152       subtree2 = proto_item_add_subtree(item2, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_SI4_REST_OCTETS_S]);
5153       if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
5154       { /* LSA Parameters */
5155          bit_offset += 1;
5156          bit_offset_sav2 = bit_offset;
5157          item3 = proto_tree_add_text(subtree2, tvb, bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_LSA_PARAMETERS].strptr);
5158          subtree3 = proto_item_add_subtree(item3, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_LSA_PARAMETERS]);
5159          proto_tree_add_bits_item(subtree3, hf_gsm_a_rr_prio_thr, tvb, bit_offset, 3, FALSE);
5160          bit_offset += 3;
5161          proto_tree_add_bits_item(subtree3, hf_gsm_a_rr_lsa_offset, tvb, bit_offset, 3, FALSE);
5162          bit_offset += 3;
5163          value = tvb_get_bits8(tvb,bit_offset,1);
5164          bit_offset += 1;
5165          if (value)
5166          {
5167             proto_tree_add_text(subtree3, tvb, bit_offset>>3, 2, "MCC: %d", tvb_get_bits16(tvb,bit_offset,12,FALSE));
5168             bit_offset += 12;
5169             proto_tree_add_text(subtree3, tvb, bit_offset>>3, 2, "MNC: %d", tvb_get_bits16(tvb,bit_offset,12,FALSE));
5170             bit_offset += 12;
5171          }
5172          proto_item_set_len(item2,((bit_offset-bit_offset_sav2)>>3)+1);
5173       }
5174       else
5175          bit_offset += 1;
5176       if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
5177       { /* Cell Identity */
5178          bit_offset += 1;
5179          value = tvb_get_bits16(tvb, bit_offset, 16, FALSE);
5180                    proto_tree_add_uint(subtree2, hf_gsm_a_bssmap_cell_ci, tvb, bit_offset>>3, 2, value);
5181          bit_offset += 16;
5182       }
5183       else
5184          bit_offset += 1;
5185       if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
5186       { /* LSA ID information */
5187          bit_offset += 1;
5188          bit_offset_sav2 = bit_offset;
5189          item3 = proto_tree_add_text(subtree2, tvb, bit_offset>>3, len, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_LSA_ID_INFO].strptr);
5190          subtree3 = proto_item_add_subtree(item3, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_LSA_ID_INFO]);
5191          do
5192          {
5193             value = tvb_get_bits8(tvb,bit_offset,1);
5194             bit_offset += 1;
5195             if (value)
5196             {
5197                proto_tree_add_text(subtree3, tvb, bit_offset>>3, 3, "Short LSA ID: %d",tvb_get_bits16(tvb,bit_offset,10,FALSE));
5198                bit_offset += 10;
5199             }
5200             else
5201             {
5202                proto_tree_add_text(subtree3, tvb, bit_offset>>3, 3, "LSA ID: %d",tvb_get_bits32(tvb,bit_offset,24,FALSE));
5203                bit_offset += 24;
5204             }
5205             value = tvb_get_bits8(tvb,bit_offset,1);
5206             bit_offset += 1;
5207          } while (value);
5208       }
5209       else
5210          bit_offset += 1;
5211       if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
5212       {
5213          bit_offset += 1;
5214          proto_tree_add_bits_item(subtree, hf_gsm_a_rr_cbq3, tvb, (curr_offset<<3)+1, 2, FALSE);
5215          bit_offset += 3;
5216       }
5217       else
5218          bit_offset += 1;
5219       value = tvb_get_bits8(tvb,bit_offset,1);
5220       bit_offset += 1;
5221       if (value)
5222       {
5223          proto_tree_add_bits_item(subtree, hf_gsm_a_rr_si13alt_position, tvb, bit_offset, 1, FALSE);
5224          bit_offset += 1;
5225       }
5226       proto_item_set_len(item2,((bit_offset-bit_offset_sav)>>3)+1);
5227    }
5228    else
5229    { /* Break indicator */
5230       bit_offset += 1;
5231       if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
5232          proto_tree_add_text(subtree, tvb, bit_offset>>3, 1, "Break Indicator: Additional parameters \"SI4 Rest Octets_S\" are sent in SYSTEM INFORMATION TYPE 7 and 8");
5233       else
5234          proto_tree_add_text(subtree, tvb, bit_offset>>3, 1, "Break Indicator: Additional parameters \"SI4 Rest Octets_S\" are not sent in SYSTEM INFORMATION TYPE 7 and 8");
5235       bit_offset += 1;
5236    }
5237
5238         curr_offset = curr_offset + len;
5239
5240         return curr_offset-offset;
5241 }
5242
5243 /*
5244  * [3] 10.5.2.35a SI 6 Rest Octets
5245  */
5246 static const true_false_string gsm_a_rr_paging_channel_restructuring_value = {
5247    "Paging channel is restructured",
5248    "Paging channel is not restructured"
5249 };
5250
5251 static const true_false_string gsm_a_rr_vbs_vgcs_inband_notifications_value = {
5252    "The mobile shall be notified on incoming high priority VBS/VGCS calls through NOTIFICATION/FACCH, the mobile need not to inspect the NCH",
5253    "The network does not provide notification on FACCH so that the mobile should inspect the NCH for notifications"
5254 };
5255
5256 static const true_false_string gsm_a_rr_vbs_vgcs_inband_pagings_value = {
5257    "The mobile shall be notified on incoming high priority point-to-point calls through NOTIFICATION/FACCH, the mobile need not to inspect the PCH",
5258    "The network does not provide paging information on FACCH so that the mobile should inspect the PCH for pagings"
5259 };
5260
5261 static const value_string gsm_a_rr_max_lapdm_vals[] = {
5262    { 0, "Any message segmented in up to 5 LAPDm frames"},
5263    { 1, "Any message segmented in up to 6 LAPDm frames"},
5264    { 2, "Any message segmented in up to 7 LAPDm frames"},
5265    { 3, "Any message segmented in up to 8 LAPDm frames"},
5266    { 4, "Any message segmented in up to 9 LAPDm frames"},
5267    { 5, "Any message segmented in up to 10 LAPDm frames"},
5268    { 6, "Any message segmented in up to 11 LAPDm frames"},
5269    { 7, "Any message segmented in up to 12 LAPDm frames"},
5270    { 0, NULL }
5271 };
5272
5273 static const true_false_string gsm_a_rr_dedicated_mode_mbms_notification_support_value = {
5274    "The cell supports the Dedicated Mode MBMS Notification procedures",
5275    "The cell does not support the Dedicated Mode MBMS Notification procedures"
5276 };
5277
5278 static const true_false_string gsm_a_rr_mnci_support_value = {
5279    "The cell supports the distribution of MBMS NEIGHBOURING CELL INFORMATION messages",
5280    "The cell does not support the distribution of MBMS NEIGHBOURING CELL INFORMATION messages"
5281 };
5282
5283 static guint8
5284 de_rr_si6_rest_oct(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5285 {
5286         proto_tree      *subtree, *subtree2;
5287         proto_item      *item, *item2;
5288         guint32 curr_offset;
5289    gint bit_offset, bit_offset_sav;
5290    guint8 value;
5291
5292         len = 7;
5293         curr_offset = offset;
5294    bit_offset = curr_offset << 3;
5295
5296         item = proto_tree_add_text(tree, tvb, curr_offset, len, "%s",
5297                 gsm_rr_elem_strings[DE_RR_SI6_REST_OCT].strptr);
5298
5299         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_SI6_REST_OCT]);
5300
5301    if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
5302    { /* PCH and NCH Info */
5303       bit_offset += 1;
5304       bit_offset_sav = bit_offset;
5305       item2 = proto_tree_add_text(subtree, tvb, bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_PCH_AND_NCH_INFO].strptr);
5306            subtree2 = proto_item_add_subtree(item2, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_PCH_AND_NCH_INFO]);
5307       proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_paging_channel_restructuring, tvb, bit_offset, 1, FALSE);
5308       bit_offset += 1;
5309       proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_nln_sacch, tvb, bit_offset, 2, FALSE);
5310       bit_offset += 2;
5311       value = tvb_get_bits8(tvb,bit_offset,1);
5312       bit_offset += 1;
5313       if (value)
5314       {
5315          proto_tree_add_bits_item(subtree2, hf_gsm_a_call_prio, tvb, bit_offset, 3, FALSE);
5316          bit_offset += 3;
5317       }
5318       proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_nln_status_sacch, tvb, bit_offset, 1, FALSE);
5319       bit_offset += 1;
5320       proto_item_set_len(item2,((bit_offset-bit_offset_sav)>>3)+1);
5321    }
5322    else
5323       bit_offset += 1;
5324    if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
5325    { /* VBS/VGCS options */
5326       bit_offset += 1;
5327       bit_offset_sav = bit_offset;
5328       item2 = proto_tree_add_text(subtree, tvb,bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_VBS_VGCS_OPTIONS].strptr);
5329            subtree2 = proto_item_add_subtree(item2, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_VBS_VGCS_OPTIONS]);
5330       proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_vbs_vgcs_inband_notifications, tvb, bit_offset, 1, FALSE);
5331       bit_offset += 1;
5332       proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_vbs_vgcs_inband_pagings, tvb, bit_offset, 1, FALSE);
5333       bit_offset += 1;
5334       proto_item_set_len(item2,((bit_offset-bit_offset_sav)>>3)+1);
5335    }
5336    else
5337       bit_offset += 1;
5338    value = gsm_a_rr_is_bit_high(tvb,bit_offset);
5339    if (value == TRUE)
5340    {
5341       proto_tree_add_text(subtree, tvb, bit_offset>>3, 1, "DTM is supported in the serving cell");
5342       bit_offset += 1;
5343       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_rac, tvb, bit_offset, 8, FALSE);
5344       bit_offset += 8;
5345       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_max_lapdm, tvb, bit_offset, 3, FALSE);
5346       bit_offset += 3;
5347    }
5348    else
5349    {
5350       proto_tree_add_text(subtree, tvb, bit_offset>>3, 1, "DTM is not supported in the serving cell");
5351       bit_offset += 1;
5352    }
5353    if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
5354       proto_tree_add_text(subtree, tvb, bit_offset>>3, 1, "Band Indicator: 1900");
5355    else
5356       proto_tree_add_text(subtree, tvb, bit_offset>>3, 1, "Band Indicator: 1800");
5357    bit_offset += 1;
5358    if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
5359    {
5360       bit_offset += 1;
5361       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_gprs_ms_txpwr_max_ccch, tvb, bit_offset, 5, FALSE);
5362       bit_offset += 5;
5363    }
5364    else
5365       bit_offset += 1;
5366    if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
5367    { /* MBMS Procedures */
5368       bit_offset += 1;
5369       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_dedicated_mode_mbms_notification_support, tvb, bit_offset, 1, FALSE);
5370       bit_offset += 1;
5371       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_mnci_support, tvb, bit_offset, 1, FALSE);
5372       bit_offset += 1;
5373    }
5374    else
5375       bit_offset += 1;
5376    if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
5377    { /* Additions in Release 7 */
5378       bit_offset += 1;
5379       value = tvb_get_bits8(tvb,bit_offset,1);
5380       bit_offset += 1;
5381       if (value)
5382       {
5383          proto_tree_add_bits_item(subtree, hf_gsm_a_rr_amr_config, tvb, bit_offset, 4, FALSE);
5384          bit_offset += 4;
5385       }
5386    }
5387    else
5388       bit_offset += 1;
5389
5390         curr_offset = curr_offset + len;
5391
5392         return curr_offset-offset;
5393 }
5394
5395 /* [3] 10.5.2.36 SI 7 Rest Octets
5396  * [3] 10.5.2.37 SI 8 Rest Octets
5397  * [3] 10.5.2.37a SI 9 Rest Octets
5398  */
5399
5400 /*
5401  * [3] 10.5.2.37b SI 13 Rest Octets
5402  */
5403 static const value_string gsm_a_rr_si_change_field_vals[] = {
5404    { 0, "Update of unspecified SI message or SI messages"},
5405    { 1, "Update of SI1 message"},
5406    { 2, "Update of SI2, SI2 bis or SI2 ter message or any instance of SI2quater messages"},
5407    { 3, "Update of SI3, SI4, SI7, SI8, SI16 or SI17 message"},
5408    { 4, "Update of SI9 message"},
5409    { 5, "Update of SI18 or SI20 message"},
5410    { 6, "Update of SI19 message"},
5411    { 7, "Update of SI15 message"},
5412    { 8, "Update of SI2n message"},
5413    { 9, "Update of unknown SI message type"},
5414    { 10, "Update of unknown SI message type"},
5415    { 11, "Update of unknown SI message type"},
5416    { 12, "Update of unknown SI message type"},
5417    { 13, "Update of unknown SI message type"},
5418    { 14, "Update of unknown SI message type"},
5419    { 15, "Update of unknown SI message type"},
5420    { 0, NULL }
5421 };
5422
5423 static const value_string gsm_a_rr_psi1_repeat_period_vals[] = {
5424    { 0, "1 multiframe"},
5425    { 1, "2 multiframes"},
5426    { 2, "3 multiframes"},
5427    { 3, "4 multiframes"},
5428    { 4, "5 multiframes"},
5429    { 5, "6 multiframes"},
5430    { 6, "7 multiframes"},
5431    { 7, "8 multiframes"},
5432    { 8, "9 multiframes"},
5433    { 9, "10 multiframes"},
5434    { 10, "11 multiframes"},
5435    { 11, "12 multiframes"},
5436    { 12, "13 multiframes"},
5437    { 13, "14 multiframes"},
5438    { 14, "15 multiframes"},
5439    { 15, "16 multiframes"},
5440    { 0, NULL }
5441 };
5442
5443 static const value_string gsm_a_rr_pbcch_pb_vals[] = {
5444    { 0, "0 dB"},
5445    { 1, "-2 dB"},
5446    { 2, "-4 dB"},
5447    { 3, "-6 dB"},
5448    { 4, "-8 dB"},
5449    { 5, "-10 dB"},
5450    { 6, "-12 dB"},
5451    { 7, "-14 dB"},
5452    { 8, "-16 dB"},
5453    { 9, "-18 dB"},
5454    { 10, "-20 dB"},
5455    { 11, "-22 dB"},
5456    { 12, "-24 dB"},
5457    { 13, "-26 dB"},
5458    { 14, "-28 dB"},
5459    { 15, "-30 dB"},
5460    { 0, NULL }
5461 };
5462
5463 static const true_false_string gsm_a_rr_spgc_ccch_sup_value = {
5464    "SPLIT_PG_CYCLE is supported on CCCH in this cell",
5465    "SPLIT_PG_CYCLE is not supported on CCCH in this cell"
5466 };
5467
5468 static const value_string gsm_a_rr_priority_access_thr_vals[] = {
5469    { 0, "Packet access is not allowed in the cell"},
5470    { 1, "Packet access is not allowed in the cell"},
5471    { 2, "Packet access is not allowed in the cell"},
5472    { 3, "Packet access is allowed for priority level 1"},
5473    { 4, "Packet access is allowed for priority level 1 to 2"},
5474    { 5, "Packet access is allowed for priority level 1 to 3"},
5475    { 6, "Packet access is allowed for priority level 1 to 4"},
5476    { 7, "Packet access is allowed for priority level 1 to 4"},
5477    { 0, NULL }
5478 };
5479
5480 static gint
5481 de_rr_rest_oct_gprs_mobile_allocation(tvbuff_t *tvb, proto_tree *tree, gint bit_offset)
5482 {
5483    proto_tree *subtree;
5484    proto_item *item;
5485    gint curr_bit_offset;
5486    guint8 value;
5487    guint64 ma_length;
5488
5489    curr_bit_offset = bit_offset;
5490
5491    item = proto_tree_add_text(tree, tvb, curr_bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_GPRS_MOBILE_ALLOC].strptr);
5492         subtree = proto_item_add_subtree(item, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_GPRS_MOBILE_ALLOC]);
5493    proto_tree_add_bits_item(subtree, hf_gsm_a_rr_hsn, tvb, curr_bit_offset, 6, FALSE);
5494    curr_bit_offset += 6;
5495    while (tvb_get_bits8(tvb,curr_bit_offset,1))
5496    {
5497       curr_bit_offset += 1;
5498       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_rfl_number, tvb, curr_bit_offset, 4, FALSE);
5499       curr_bit_offset += 4;
5500    }
5501    curr_bit_offset += 1;
5502    if (tvb_get_bits8(tvb,curr_bit_offset,1))
5503    {
5504       curr_bit_offset += 1;
5505       while (tvb_get_bits8(tvb,curr_bit_offset,1))
5506       {
5507          curr_bit_offset += 1;
5508          proto_tree_add_bits_item(subtree, hf_gsm_a_rr_arfcn_index, tvb, curr_bit_offset, 6, FALSE);
5509          curr_bit_offset += 6;
5510       }
5511       curr_bit_offset += 1;
5512    }
5513    else
5514    {
5515       curr_bit_offset += 1;
5516       proto_tree_add_bits_ret_val(subtree, hf_gsm_a_rr_ma_length, tvb, curr_bit_offset, 6, &ma_length, FALSE);
5517       curr_bit_offset += 6;
5518       value = (gint)ma_length + 1;
5519       item = proto_tree_add_text(subtree,tvb, curr_bit_offset>>3, (value>>3)+1, "MA Bitmap: ");
5520       while (value)
5521       {
5522          proto_item_append_text(item,"%d",tvb_get_bits8(tvb,curr_bit_offset,1));
5523          curr_bit_offset += 1;
5524          value -= 1;
5525       }
5526    }
5527    proto_item_set_len(item,((curr_bit_offset-bit_offset)>>3)+1);
5528
5529    return (curr_bit_offset - bit_offset);
5530 }
5531
5532 static const value_string gsm_a_rr_nmo_vals[] = {
5533    { 0, "Network Mode of Operation I"},
5534    { 1, "Network Mode of Operation II"},
5535    { 2, "Network Mode of Operation III"},
5536    { 3, "Reserved"},
5537    { 0, NULL }
5538 };
5539
5540 static const value_string gsm_a_rr_t3168_vals[] = {
5541    { 0, "500 ms"},
5542    { 1, "1000 ms"},
5543    { 2, "1500 ms"},
5544    { 3, "2000 ms"},
5545    { 4, "2500 ms"},
5546    { 5, "3000 ms"},
5547    { 6, "3500 ms"},
5548    { 7, "4000 ms"},
5549    { 0, NULL }
5550 };
5551
5552 static const value_string gsm_a_rr_t3192_vals[] = {
5553    { 0, "500 ms"},
5554    { 1, "1000 ms"},
5555    { 2, "1500 ms"},
5556    { 3, "0 ms"},
5557    { 4, "80 ms"},
5558    { 5, "120 ms"},
5559    { 6, "160 ms"},
5560    { 7, "200 ms"},
5561    { 0, NULL }
5562 };
5563
5564 static const value_string gsm_a_rr_drx_timer_max_vals[] = {
5565    { 0, "0 s"},
5566    { 1, "1 s"},
5567    { 2, "2 s"},
5568    { 3, "4 s"},
5569    { 4, "8 s"},
5570    { 5, "16 s"},
5571    { 6, "32 s"},
5572    { 7, "64 s"},
5573    { 0, NULL }
5574 };
5575
5576 static const true_false_string gsm_a_rr_access_burst_type_value = {
5577    "11-bit format shall be used",
5578    "8-bit format shall be used"
5579 };
5580
5581 static const true_false_string gsm_a_rr_control_ack_type_value = {
5582    "Default format is RLC/MAC control block",
5583    "Default format is four access bursts"
5584 };
5585
5586 static const value_string gsm_a_rr_pan_max_vals[] = {
5587    { 0, "maximum value allowed for counter N3102 is 4"},
5588    { 1, "maximum value allowed for counter N3102 is 8"},
5589    { 2, "maximum value allowed for counter N3102 is 12"},
5590    { 3, "maximum value allowed for counter N3102 is 16"},
5591    { 4, "maximum value allowed for counter N3102 is 20"},
5592    { 5, "maximum value allowed for counter N3102 is 24"},
5593    { 6, "maximum value allowed for counter N3102 is 28"},
5594    { 7, "maximum value allowed for counter N3102 is 32"},
5595    { 0, NULL }
5596 };
5597
5598 static const true_false_string gsm_a_rr_egprs_packet_channel_request_value = {
5599    "Use two phase packet access with PACKET CHANNEL REQUEST message for uplink TBF establishment on the PRACH",
5600    "Use EGPRS PACKET CHANNEL REQUEST message for uplink TBF     establishment on the PRACH"
5601 };
5602
5603 static const value_string gsm_a_rr_bep_period_vals[] = {
5604    { 0, "1"},
5605    { 1, "2"},
5606    { 2, "3"},
5607    { 3, "4"},
5608    { 4, "5"},
5609    { 5, "7"},
5610    { 6, "10"},
5611    { 7, "12"},
5612    { 8, "15"},
5613    { 9, "20"},
5614    { 10, "25"},
5615    { 11, "Reserved"},
5616    { 12, "Reserved"},
5617    { 13, "Reserved"},
5618    { 14, "Reserved"},
5619    { 15, "Reserved"},
5620    { 0, NULL }
5621 };
5622
5623 static const true_false_string gsm_a_rr_pfc_feature_mode_value = {
5624    "The network supports packet flow context procedures",
5625    "The network does not support packet flow context procedures"
5626 };
5627
5628 static const true_false_string gsm_a_rr_dtm_support_value = {
5629    "The cell supports DTM procedures",
5630    "The cell does not support DTM procedures"
5631 };
5632
5633 static const true_false_string gsm_a_rr_bss_paging_coordination_value = {
5634    "The cell supports Circuit-Switched paging coordination",
5635    "The cell does not support Circuit-Switched paging coordination"
5636 };
5637
5638 static const true_false_string gsm_a_rr_ccn_active_value = {
5639    "CCN is enabled in the cell",
5640    "CCN is disabled in the cell"
5641 };
5642
5643 static const true_false_string gsm_a_rr_nw_ext_utbf_value = {
5644    "The extended uplink TBF mode is supported by the network",
5645    "The extended uplink TBF mode is not supported by the network"
5646 };
5647
5648 static const true_false_string gsm_a_rr_multiple_tbf_capability_value = {
5649    "The cell supports multiple TBF procedures",
5650    "The cell does not support multiple TBF procedures"
5651 };
5652
5653 static const true_false_string gsm_a_rr_ext_utbf_no_data_value = {
5654    "The mobile station may refrain from sending a PACKET UPLINK DUMMY CONTROL BLOCK message when there is no other RLC/MAC block ready to send in an uplink radio block allocated by the network",
5655    "The mobile station shall send a PACKET UPLINK DUMMY CONTROL BLOCK message when there is no other RLC/MAC block ready to send in an uplink radio block allocated by the network"
5656 };
5657
5658 static const true_false_string gsm_a_rr_dtm_enhancements_capability_value = {
5659    "The cell supports enhanced DTM CS establishment and enhanced DTM CS release procedures",
5660    "The cell does not support enhanced DTM CS establishment and enhanced DTM CS release procedures"
5661 };
5662
5663 static const true_false_string gsm_a_rr_reduced_latency_access_value = {
5664    "The cell supports \"One Phase Access Request by Reduced Latency MS\"",
5665    "The cell does not support \"One Phase Access Request by Reduced Latency MS\""
5666 };
5667
5668 static const value_string gsm_a_rr_alpha_vals[] = {
5669    { 0, "0.0"},
5670    { 1, "0.1"},
5671    { 2, "0.2"},
5672    { 3, "0.3"},
5673    { 4, "0.4"},
5674    { 5, "0.5"},
5675    { 6, "0.6"},
5676    { 7, "0.7"},
5677    { 8, "0.8"},
5678    { 9, "0.9"},
5679    { 10, "1.0"},
5680    { 11, "1.0"},
5681    { 12, "1.0"},
5682    { 13, "1.0"},
5683    { 14, "1.0"},
5684    { 15, "1.0"},
5685    { 0, NULL }
5686 };
5687
5688 static const value_string gsm_a_rr_t_avg_x_vals[] = {
5689    { 0, "2^(0/2) / 6 multiframes"},
5690    { 1, "2^(1/2) / 6 multiframes"},
5691    { 2, "2^(2/2) / 6 multiframes"},
5692    { 3, "2^(3/2) / 6 multiframes"},
5693    { 4, "2^(4/2) / 6 multiframes"},
5694    { 5, "2^(5/2) / 6 multiframes"},
5695    { 6, "2^(6/2) / 6 multiframes"},
5696    { 7, "2^(7/2) / 6 multiframes"},
5697    { 8, "2^(8/2) / 6 multiframes"},
5698    { 9, "2^(9/2) / 6 multiframes"},
5699    { 10, "2^(10/2) / 6 multiframes"},
5700    { 11, "2^(11/2) / 6 multiframes"},
5701    { 12, "2^(12/2) / 6 multiframes"},
5702    { 13, "2^(13/2) / 6 multiframes"},
5703    { 14, "2^(14/2) / 6 multiframes"},
5704    { 15, "2^(15/2) / 6 multiframes"},
5705    { 16, "2^(16/2) / 6 multiframes"},
5706    { 17, "2^(17/2) / 6 multiframes"},
5707    { 18, "2^(18/2) / 6 multiframes"},
5708    { 19, "2^(19/2) / 6 multiframes"},
5709    { 20, "2^(20/2) / 6 multiframes"},
5710    { 21, "2^(21/2) / 6 multiframes"},
5711    { 22, "2^(22/2) / 6 multiframes"},
5712    { 23, "2^(23/2) / 6 multiframes"},
5713    { 24, "2^(24/2) / 6 multiframes"},
5714    { 25, "2^(25/2) / 6 multiframes"},
5715    { 26, "2^(25/2) / 6 multiframes"},
5716    { 27, "2^(25/2) / 6 multiframes"},
5717    { 28, "2^(25/2) / 6 multiframes"},
5718    { 29, "2^(25/2) / 6 multiframes"},
5719    { 30, "2^(25/2) / 6 multiframes"},
5720    { 31, "2^(25/2) / 6 multiframes"},
5721    { 0, NULL }
5722 };
5723
5724 static const true_false_string gsm_a_rr_pc_meas_chan_value = {
5725    "Downlink measurements for power control shall be made on PDCH",
5726    "Downlink measurements for power control shall be made on BCCH"
5727 };
5728
5729 static const value_string gsm_a_rr_n_avg_i_vals[] = {
5730    { 0, "2^(0/2)"},
5731    { 1, "2^(1/2)"},
5732    { 2, "2^(2/2)"},
5733    { 3, "2^(3/2)"},
5734    { 4, "2^(4/2)"},
5735    { 5, "2^(5/2)"},
5736    { 6, "2^(6/2)"},
5737    { 7, "2^(7/2)"},
5738    { 8, "2^(8/2)"},
5739    { 9, "2^(9/2)"},
5740    { 10, "2^(10/2)"},
5741    { 11, "2^(11/2)"},
5742    { 12, "2^(12/2)"},
5743    { 13, "2^(13/2)"},
5744    { 14, "2^(14/2)"},
5745    { 15, "2^(15/2)"},
5746    { 0, NULL }
5747 };
5748
5749 static const true_false_string gsm_a_rr_sgsnr_value = {
5750    "SGSN is Release '99 onwards",
5751    "SGSN is Release '98 or older"
5752 };
5753
5754 static const true_false_string gsm_a_rr_si_status_ind_value = {
5755    "The network supports the PACKET SI STATUS message",
5756    "The network does not support the PACKET SI STATUS message"
5757 };
5758
5759 static const value_string gsm_a_rr_lb_ms_txpwr_max_cch_vals[] = {
5760    { 0, "43 dBm"},
5761    { 1, "41 dBm"},
5762    { 2, "39 dBm"},
5763    { 3, "37 dBm"},
5764    { 4, "35 dBm"},
5765    { 5, "33 dBm"},
5766    { 6, "31 dBm"},
5767    { 7, "29 dBm"},
5768    { 8, "27 dBm"},
5769    { 9, "25 dBm"},
5770    { 10, "23 dBm"},
5771    { 11, "21 dBm"},
5772    { 12, "19 dBm"},
5773    { 13, "17 dBm"},
5774    { 14, "15 dBm"},
5775    { 15, "13 dBm"},
5776    { 16, "11 dBm"},
5777    { 17, "9 dBm"},
5778    { 18, "7 dBm"},
5779    { 19, "5 dBm"},
5780    { 20, "5 dBm"},
5781    { 21, "5 dBm"},
5782    { 22, "5 dBm"},
5783    { 23, "5 dBm"},
5784    { 24, "5 dBm"},
5785    { 25, "5 dBm"},
5786    { 26, "5 dBm"},
5787    { 27, "5 dBm"},
5788    { 28, "5 dBm"},
5789    { 29, "5 dBm"},
5790    { 30, "5 dBm"},
5791    { 31, "5 dBm"},
5792    { 0, NULL }
5793 };
5794
5795 static const value_string gsm_a_rr_si2n_support_vals[] = {
5796    { 0, "SI2n is not supported"},
5797    { 1, "SI2n is supported on PACCH"},
5798    { 2, "SI2n is supported on PACCH and broadcast on BCCH"},
5799    { 3, "SI2n is supported on PACCH and broadcast on BCCH Ext"},
5800    { 0, NULL }
5801 };
5802
5803 static guint8
5804 de_rr_si13_rest_oct(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5805 {
5806         proto_tree      *subtree, *subtree2;
5807         proto_item      *item, *item2;
5808         guint32 curr_offset;
5809    gint bit_offset, bit_offset_sav;
5810    guint8 value;
5811
5812         len = 20;
5813         curr_offset = offset;
5814    bit_offset = curr_offset << 3;
5815
5816         item = proto_tree_add_text(tree, tvb, curr_offset, len, "%s",
5817                 gsm_rr_elem_strings[DE_RR_SI13_REST_OCT].strptr);
5818
5819         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_SI13_REST_OCT]);
5820
5821    if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
5822    {
5823       bit_offset += 1;
5824       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_bcch_change_mark, tvb, bit_offset, 3, FALSE);
5825       bit_offset += 3;
5826       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_si_change_field, tvb, bit_offset, 4, FALSE);
5827       bit_offset += 4;
5828       value = tvb_get_bits8(tvb,bit_offset,1);
5829       bit_offset += 1;
5830       if (value)
5831       {
5832          proto_tree_add_bits_item(subtree, hf_gsm_a_rr_si13_change_mark, tvb, bit_offset, 2, FALSE);
5833          bit_offset += 2;
5834          bit_offset += de_rr_rest_oct_gprs_mobile_allocation(tvb, subtree, bit_offset);
5835       }
5836       value = tvb_get_bits8(tvb,bit_offset,1);
5837       bit_offset += 1;
5838       if (value)
5839       { /* PBCCH present in the cell */
5840          proto_tree_add_bits_item(subtree, hf_gsm_a_rr_psi1_repeat_period, tvb, bit_offset, 4, FALSE);
5841          bit_offset += 4;
5842          bit_offset_sav = bit_offset;
5843          item2 = proto_tree_add_text(subtree, tvb, bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_PBCCH_DESC].strptr);
5844               subtree2 = proto_item_add_subtree(item2, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_PBCCH_DESC]);
5845          proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_pbcch_pb, tvb, bit_offset, 4, FALSE);
5846          bit_offset += 4;
5847          proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_pbcch_tsc, tvb, bit_offset, 3, FALSE);
5848          bit_offset += 3;
5849          proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_pbcch_tn, tvb, bit_offset, 3, FALSE);
5850          bit_offset += 3;
5851          value = tvb_get_bits8(tvb,bit_offset,1);
5852          bit_offset += 1;
5853          if (value)
5854          {
5855             proto_tree_add_text(subtree2, tvb, bit_offset>>3, 1, "MAIO: %d", tvb_get_bits8(tvb,bit_offset,6));
5856             bit_offset += 6;
5857          }
5858          else
5859          {
5860             value = tvb_get_bits8(tvb,bit_offset,1);
5861             bit_offset += 1;
5862             if (value)
5863             {
5864                proto_tree_add_bits_item(subtree2, hf_gsm_a_rr_arfcn, tvb, bit_offset, 10, FALSE);
5865                bit_offset += 10;
5866             }
5867             else
5868                proto_tree_add_text(subtree2, tvb, bit_offset>>3, 1, "PBCCH shall use the BCCH carrier");
5869          }
5870          proto_item_set_len(item2,((bit_offset-bit_offset_sav)>>3)+1);
5871       }
5872       else
5873       { /* PBCCH not present in the cell */
5874          proto_tree_add_bits_item(subtree, hf_gsm_a_rr_rac, tvb, bit_offset, 8, FALSE);
5875          bit_offset += 8;
5876          proto_tree_add_bits_item(subtree, hf_gsm_a_rr_spgc_ccch_sup, tvb, bit_offset, 1, FALSE);
5877          bit_offset += 1;
5878          proto_tree_add_bits_item(subtree, hf_gsm_a_rr_priority_access_thr, tvb, bit_offset, 3, FALSE);
5879          bit_offset += 3;
5880          proto_tree_add_bits_item(subtree, hf_gsm_a_rr_network_control_order, tvb, bit_offset, 2, FALSE);
5881          bit_offset += 2;
5882          bit_offset += de_rr_rest_oct_gprs_cell_options(tvb, subtree, bit_offset);
5883          bit_offset += de_rr_rest_oct_gprs_power_control_parameters(tvb, subtree, bit_offset);  
5884       }
5885       if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
5886       { /* Additions in release 99 */
5887          bit_offset += 1;
5888          proto_tree_add_bits_item(subtree, hf_gsm_a_rr_sgsnr, tvb, bit_offset, 1, FALSE);
5889          bit_offset += 1;
5890          if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
5891          { /* Additions in release Rel-4 */
5892             bit_offset += 1;
5893             proto_tree_add_bits_item(subtree, hf_gsm_a_rr_si_status_ind, tvb, bit_offset, 1, FALSE);
5894             bit_offset += 1;
5895             if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
5896             { /* Additions in release Rel-6 */
5897                bit_offset += 1;
5898                value = tvb_get_bits8(tvb,bit_offset,1);
5899                bit_offset += 1;
5900                if (value)
5901                {
5902                   proto_tree_add_bits_item(subtree, hf_gsm_a_rr_lb_ms_txpwr_max_cch, tvb, bit_offset, 5, FALSE);
5903                   bit_offset += 5;
5904                }
5905                proto_tree_add_bits_item(subtree, hf_gsm_a_rr_si2n_support, tvb, bit_offset, 2, FALSE);
5906                bit_offset += 2;
5907             }
5908             else
5909                bit_offset += 1;
5910          }
5911          else
5912             bit_offset += 1;
5913       }
5914       else
5915          bit_offset += 1;
5916    }
5917    else
5918    {
5919       bit_offset += 1;
5920       proto_tree_add_text(subtree,tvb, curr_offset, len ,"Empty");
5921    }
5922
5923         curr_offset = curr_offset + len;
5924
5925         return curr_offset-offset;
5926 }
5927
5928 /* [3] 10.5.2.37c (void)
5929  * [3] 10.5.2.37d (void)
5930  * [3] 10.5.2.37e SI 16 Rest Octets
5931  * [3] 10.5.2.37f SI 17 Rest Octets
5932  * [3] 10.5.2.37g SI 19 Rest Octets
5933  * [3] 10.5.2.37h SI 18 Rest Octets
5934  * [3] 10.5.2.37i SI 20 Rest Octets
5935  */
5936 /*
5937  * [3] 10.5.2.38 Starting Time
5938  */
5939 static guint8
5940 de_rr_starting_time(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
5941 {
5942         proto_item *item;
5943         guint32 curr_offset;
5944         guint16 rfn, fn;
5945
5946         curr_offset = offset;
5947
5948         fn = tvb_get_ntohs(tvb,curr_offset);
5949         rfn = reduced_frame_number(fn);
5950         proto_tree_add_item(tree, hf_gsm_a_rr_T1prim, tvb, curr_offset, 1, FALSE);
5951         proto_tree_add_item(tree, hf_gsm_a_rr_T3, tvb, curr_offset, 2, FALSE);
5952         curr_offset++;
5953         proto_tree_add_item(tree, hf_gsm_a_rr_T2, tvb, curr_offset, 1, FALSE);
5954         curr_offset++;
5955         item = proto_tree_add_uint(tree, hf_gsm_a_rr_rfn, tvb, curr_offset-2, 2, rfn);
5956         PROTO_ITEM_SET_GENERATED(item);
5957         return(curr_offset - offset);
5958 }
5959 /*
5960  * [3] 10.5.2.39 Synchronization Indication
5961  */
5962 /*
5963  * ROT: Report Observed Time Difference (Octet1 bit 3) */
5964
5965 static const true_false_string sm_a_rr_sync_ind_rot_value  = {
5966         "Mobile Time Difference IE shall be included in the HANDOVER COMPLETE message",
5967         "Mobile Time Difference IE shall not be included in the HANDOVER COMPLETE message"
5968 };
5969
5970 /* SI: Synchronization indication (octet 1)Bit2 1 */
5971
5972 static const value_string gsm_a_rr_sync_ind_si_vals[] = {
5973         { 0,    "Non-synchronized"},
5974         { 1,    "Synchronized"},
5975         { 2,    "Pre-synchronised"},
5976         { 3,    "Pseudo-synchronised"},
5977         { 0,    NULL }
5978 };
5979 /* NCI: Normal cell indication (octet 1, bit 4) */
5980
5981 static const true_false_string gsm_a_rr_sync_ind_nci_value  = {
5982         "Out of range timing advance shall trigger a handover failure procedure",
5983         "Out of range timing advance is ignored"
5984 };
5985 static guint8
5986 de_rr_sync_ind(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
5987 {
5988         guint32 curr_offset;
5989
5990         curr_offset = offset;
5991
5992         /*NCI */
5993         proto_tree_add_item(tree, hf_gsm_a_rr_sync_ind_nci, tvb, curr_offset, 1, FALSE);
5994         /*ROT */
5995         proto_tree_add_item(tree, hf_gsm_a_rr_sync_ind_rot, tvb, curr_offset, 1, FALSE);
5996         /*SI*/
5997         proto_tree_add_item(tree, hf_gsm_a_rr_sync_ind_si, tvb, curr_offset, 1, FALSE);
5998
5999         curr_offset = curr_offset + 1;
6000
6001         return(curr_offset - offset);
6002 }
6003
6004 /*
6005  * [3] 10.5.2.40 Timing Advance
6006  */
6007 static guint8
6008 de_rr_timing_adv(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
6009 {
6010         guint32 curr_offset;
6011
6012         curr_offset = offset;
6013
6014         proto_tree_add_item(tree, hf_gsm_a_rr_timing_adv, tvb, curr_offset, 1, FALSE);
6015         curr_offset = curr_offset + 1;
6016
6017         return(curr_offset - offset);
6018 }
6019
6020 /*
6021  * [3] 10.5.2.41 Time Difference
6022  */
6023 static guint8
6024 de_rr_time_diff(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
6025 {
6026         guint32 curr_offset;
6027
6028         curr_offset = offset;
6029
6030         proto_tree_add_item(tree, hf_gsm_a_rr_time_diff, tvb, curr_offset, 1, FALSE);
6031         curr_offset = curr_offset + 1;
6032
6033         return(curr_offset - offset);
6034 }
6035 /*
6036  * [3] 10.5.2.41a TLLI
6037  * The TLLI is encoded as a binary number with a length of 4 octets. TLLI is defined in 3GPP TS 23.003
6038  */
6039 guint8
6040 de_rr_tlli(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
6041 {
6042         guint32 curr_offset;
6043
6044         curr_offset = offset;
6045
6046         proto_tree_add_item(tree, hf_gsm_a_rr_tlli, tvb, curr_offset, 4, FALSE);
6047         curr_offset = curr_offset + 4;
6048
6049         return(curr_offset - offset);
6050 }
6051
6052 /*
6053  * [3] 10.5.2.42 TMSI/P-TMSI
6054  */
6055 guint8
6056 de_rr_tmsi_ptmsi(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
6057 {
6058         proto_tree      *subtree;
6059         proto_item      *item;
6060         guint32 curr_offset;
6061
6062         curr_offset = offset;
6063
6064         item = proto_tree_add_text(tree, tvb, curr_offset, 3, "%s",
6065                 gsm_rr_elem_strings[DE_RR_TMSI_PTMSI].strptr);
6066
6067         subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_TMSI_PTMSI]);
6068
6069         proto_tree_add_item(subtree, hf_gsm_a_rr_tmsi_ptmsi, tvb, curr_offset, 4, FALSE);
6070         curr_offset = curr_offset + 4;
6071
6072         return(curr_offset - offset);
6073 }
6074
6075 /*
6076  * [3] 10.5.2.42a VGCS target mode Indication
6077  */
6078 /*
6079 Target mode (octet 3)
6080 Bit     8 7
6081         0 0     dedicated mode
6082         0 1     group transmit mode
6083         Other values are reserved for future use.
6084 */
6085 static const value_string gsm_a_rr_target_mode_vals[] _U_ = {
6086         { 0,    "Dedicated mode"},
6087         { 1,    "Group transmit mode"},
6088         { 0,    NULL }
6089 };
6090 static guint8
6091 de_rr_vgcs_tar_mode_ind(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
6092 {
6093         guint32 curr_offset;
6094
6095         curr_offset = offset;
6096
6097         proto_tree_add_item(tree, hf_gsm_a_rr_target_mode, tvb, curr_offset, 1, FALSE);
6098         proto_tree_add_item(tree, hf_gsm_a_rr_group_cipher_key_number, tvb, curr_offset, 1, FALSE);
6099         curr_offset = curr_offset + 1;
6100
6101         return(curr_offset - offset);
6102 }
6103
6104 /*
6105  * [3] 10.5.2.42b       VGCS Ciphering Parameters
6106  */
6107 static guint8
6108 de_rr_vgcs_cip_par(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
6109 {
6110         guint32 curr_offset;
6111
6112         curr_offset = offset;
6113
6114         proto_tree_add_text(tree,tvb, curr_offset, len ,"Data(Not decoded)");
6115
6116         curr_offset = curr_offset + 2;
6117
6118         return(curr_offset - offset);
6119 }
6120 /*
6121  * [3] 10.5.2.43 Wait Indication
6122  */
6123 static guint8
6124 de_rr_wait_ind(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
6125 {
6126         guint32 curr_offset;
6127
6128         curr_offset = offset;
6129
6130         proto_tree_add_item(tree, hf_gsm_a_rr_wait_indication, tvb, curr_offset, 1, FALSE);
6131
6132         curr_offset = curr_offset + 1;
6133
6134         return(curr_offset - offset);
6135 }
6136
6137 /*
6138  * [3] 10.5.2.44 SI10 rest octets $(ASCI)$
6139  */
6140
6141 /*
6142  * [3] 10.5.2.45 Extended Measurement Results
6143  */
6144 static guint8
6145 de_rr_ext_meas_result(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
6146 {
6147    guint32 curr_offset;
6148    gint bit_offset, i;
6149    guint8 value;
6150
6151    curr_offset = offset;
6152    len = 16;
6153    bit_offset = curr_offset << 3;
6154
6155    proto_tree_add_bits_item(tree, hf_gsm_a_rr_seq_code, tvb,bit_offset, 1, FALSE);
6156    bit_offset += 1;
6157    proto_tree_add_bits_item(tree, hf_gsm_a_rr_dtx_used, tvb, bit_offset, 1, FALSE);
6158    bit_offset += 1;
6159    for (i=0; i<21; i++)
6160    {
6161       value = tvb_get_bits8(tvb,bit_offset,6);
6162       proto_tree_add_text(tree, tvb, bit_offset>>3, 1, "RXLEV carrier %d: %s (%d)",i,gsm_a_rr_rxlev_vals[value].strptr,value);
6163       bit_offset += 6;
6164    }
6165
6166    curr_offset = offset + len;
6167
6168    return(curr_offset - offset);
6169 }
6170
6171 /*
6172  * [3] 10.5.2.46 Extended Measurement Frequency List
6173  */
6174 static guint8
6175 de_rr_ext_meas_freq_list(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
6176 {
6177    guint32 curr_offset;
6178
6179    curr_offset = offset;
6180
6181    proto_tree_add_bits_item(tree, hf_gsm_a_rr_seq_code, tvb,(curr_offset<<3)+3, 1, FALSE);
6182    
6183    return dissect_arfcn_list(tvb, tree, offset, 16, add_string, string_len);
6184 }
6185
6186 /*
6187  * [3] 10.5.2.47 Suspension Cause
6188  */
6189 /*Suspension cause value (octet 2)*/
6190 static const value_string gsm_a_rr_suspension_cause_vals[] = {
6191         { 0,    "Emergency call, mobile originating call or call re-establishment"},
6192         { 1,    "Location Area Update"},
6193         { 2,    "MO Short message service"},
6194         { 3,    "Other procedure which can be completed with an SDCCH"},
6195         { 4,    "MO Voice broadcast or group call"},
6196         { 5,    "Mobile terminating CS connection"},
6197         { 6,    "DTM not supported in the cell"},
6198         { 0,    NULL }
6199 };
6200 guint8
6201 de_rr_sus_cau(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
6202 {
6203         guint32 curr_offset;
6204
6205         curr_offset = offset;
6206
6207         proto_tree_add_item(tree, hf_gsm_a_rr_suspension_cause, tvb, curr_offset, 1, FALSE);
6208
6209         curr_offset = curr_offset + 1;
6210
6211         return(curr_offset - offset);
6212 }
6213 /*
6214  * [3] 10.5.2.48 APDU ID
6215  * [3] 10.5.2.49 APDU Flags
6216  * [3] 10.5.2.50 APDU Data
6217  */
6218
6219 /*
6220  * [3] 10.5.2.51 Handover To UTRAN Command
6221  */
6222 static guint8
6223 de_rr_ho_to_utran_cmd(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
6224 {
6225    guint32 curr_offset;
6226    tvbuff_t *rrc_irat_ho_to_utran_cmd_tvb;
6227    static packet_info p_info;
6228
6229    curr_offset = offset;
6230    if (len)
6231    {
6232       rrc_irat_ho_to_utran_cmd_tvb = tvb_new_subset(tvb, curr_offset, len, len);
6233       if (rrc_irat_ho_to_utran_cmd_handle)
6234          call_dissector(rrc_irat_ho_to_utran_cmd_handle, rrc_irat_ho_to_utran_cmd_tvb, &p_info, tree);
6235    }
6236
6237    curr_offset += len;
6238    return(curr_offset - offset);
6239 }
6240
6241
6242 /*
6243  * [3] 10.5.2.52 Handover To cdma2000 Command
6244  * [3] 10.5.2.53 (void)
6245  * [3] 10.5.2.54 (void)
6246  * [3] 10.5.2.55 (void)
6247  * [3] 10.5.2.56 3G Target Cell
6248  */
6249 /*
6250  * 10.5.2.57 Service Support
6251  */
6252 static const true_false_string gsm_a_rr_MBMS_multicast_value  = {
6253         "mobile station requires notification of multicast MBMS services",
6254         "mobile station does not require notification of multicast MBMS services"
6255 };
6256 static const true_false_string gsm_a_rr_MBMS_broadcast_value  = {
6257         "mobile station requires notification of broadcast MBMS services",
6258         "mobile station does not require notification of broadcast MBMS services"
6259 };
6260 static guint8
6261 de_rr_serv_sup(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
6262 {
6263         guint32 curr_offset;
6264
6265         curr_offset = offset;
6266         /* bit 1
6267          * 0 mobile station does not require notification of broadcast MBMS services
6268          * 1 mobile station requires notification of broadcast MBMS services
6269          * bit 2
6270          * 0 mobile station does not require notification of multicast MBMS services
6271          * 1 mobile station requires notification of multicast MBMS services
6272          */
6273         /* MBMS Multicast */
6274         proto_tree_add_item(tree, hf_gsm_a_rr_MBMS_multicast, tvb, curr_offset, 1, FALSE);
6275
6276         /* MBMS Broadcast */
6277         proto_tree_add_item(tree, hf_gsm_a_rr_MBMS_broadcast, tvb, curr_offset, 1, FALSE);
6278         curr_offset++;
6279
6280         return(curr_offset - offset);
6281 }
6282
6283 /*
6284  * [3] 10.5.2.59        Dedicated Service Information
6285  */
6286 /*
6287 Last Segment (octet 2)
6288 bit 1
6289 0       mobile station shall not perform Service Information Sending procedure on new cell.
6290 1       mobile station shall perform Service Information Sending procedure on new cell.
6291 */
6292 static const true_false_string gsm_a_rr_last_segment_value  = {
6293         "Mobile station shall perform Service Information Sending procedure on new cell.",
6294         "mobile station shall not perform Service Information Sending procedure on new cell."
6295 };
6296 static guint8
6297 de_rr_ded_serv_inf(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
6298 {
6299         guint32 curr_offset;
6300
6301         curr_offset = offset;
6302
6303         proto_tree_add_item(tree, hf_gsm_a_rr_last_segment, tvb, curr_offset, 1, FALSE);
6304
6305         curr_offset = curr_offset + 3;
6306
6307         return(curr_offset - offset);
6308 }
6309
6310 /*
6311  * [3] 10.5.2.69        Carrier Indication
6312  */
6313 static const true_false_string gsm_a_rr_carrier_ind_value  = {
6314         "Carrier 2",
6315         "Carrier 1"
6316 };
6317
6318 static guint8
6319 de_rr_carrier_ind(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
6320 {
6321    proto_tree *subtree;
6322    proto_item *item;
6323    guint32 curr_offset;
6324
6325    curr_offset = offset;
6326
6327    item = proto_tree_add_text(tree, tvb, curr_offset, 3, "%s",
6328       gsm_rr_elem_strings[DE_RR_CARRIER_IND].strptr);
6329
6330    subtree = proto_item_add_subtree(item, ett_gsm_rr_elem[DE_RR_CARRIER_IND]);
6331
6332    proto_tree_add_item(tree, hf_gsm_a_rr_carrier_ind, tvb, curr_offset, 1, FALSE);
6333
6334    curr_offset += 1;
6335
6336    return(curr_offset - offset);
6337 }
6338
6339 guint8 (*rr_elem_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len) = {
6340         /* Radio Resource Management  Information Elements 10.5.2, most are from 10.5.1 */
6341
6342         de_rr_ba_range,                       /* [3]  10.5.2.1a BA Range */
6343         de_rr_cell_ch_dsc,                              /* [3]  10.5.2.1b       Cell Channel Description        */
6344         de_rr_ba_list_pref,                             /* [3]  10.5.2.1c       BA List Pref */
6345         de_rr_utran_freq_list,                  /* [3]  10.5.2.1d       UTRAN Frequency List */
6346         de_rr_cell_select_indic,                /* [3]  10.5.2.1e       Cell selection indicator after release of all TCH and SDCCH IE */
6347         de_rr_cell_dsc,                                 /* 10.5.2.2   RR Cell Description                               */
6348         de_rr_cell_opt_bcch,                            /* [3]  10.5.2.3        Cell Options (BCCH)     */
6349         de_rr_cell_opt_sacch,                   /* [3]  10.5.2.3a       Cell Options (SACCH)    */
6350         de_rr_cell_sel_param,                   /* [3]  10.5.2.4        Cell Selection Parameters               */
6351 /*
6352  * [3]  10.5.2.4a       (void)
6353  */
6354         de_rr_ch_dsc,                                   /* [3]  10.5.2.5        Channel Description                     */
6355         de_rr_ch_dsc2,                                  /* [3]  10.5.2.5a   RR Channel Description 2    */
6356         de_rr_ch_dsc3,                                  /* [3]  10.5.2.5c   RR Channel Description 3    */
6357         de_rr_ch_mode,                                  /* [3]  10.5.2.6        Channel Mode                            */
6358         de_rr_ch_mode2,                                 /* [3]  10.5.2.7        Channel Mode 2                          */
6359         de_rr_utran_cm,                                 /* [3]  10.5.2.7a       UTRAN Classmark */
6360 /* [3]  10.5.2.7b       (void) */
6361
6362         de_rr_cm_enq_mask,                              /* [3]  10.5.2.7c       Classmark Enquiry Mask          */
6363 /* [3]  10.5.2.7d       GERAN Iu Mode Classmark information element                                             */
6364         de_rr_chnl_needed,                              /* [3]  10.5.2.8        Channel Needed
6365  * [3]  10.5.2.8a       (void)
6366  * [3]  10.5.2.8b       Channel Request Description 2 */
6367         /* Pos 20 */
6368         de_rr_cip_mode_set,                                     /* [3]  10.5.2.9        Cipher Mode Setting             */
6369         de_rr_cip_mode_resp,                            /* [3]  10.5.2.10       Cipher Response */
6370         de_rr_ctrl_ch_desc,                     /* [3]  10.5.2.11       Control Channel Description     */
6371 /* [3]  10.5.2.11a      DTM Information Details */
6372         de_rr_dyn_arfcn_map,                            /* [3]  10.5.2.11b      Dynamic ARFCN Mapping           */
6373         de_rr_freq_ch_seq,                                      /* [3]  10.5.2.12       Frequency Channel Sequence      */
6374         de_rr_freq_list,                                        /* [3]  10.5.2.13       Frequency List                          */
6375         de_rr_freq_short_list,                          /* [3]  10.5.2.14       Frequency Short List            */
6376         de_rr_freq_short_list2,                         /* [3]  10.5.2.14a      Frequency Short List 2          */
6377 /* [3]  10.5.2.14b      Group Channel Description */
6378         de_rr_gprs_resumption,                          /* [3]  10.5.2.14c      GPRS Resumption */
6379         de_rr_gprs_broadcast_info,                      /* [3]  10.5.2.14d      GPRS broadcast information */
6380 /* [3]  10.5.2.14e      Enhanced DTM CS Release Indication */
6381         de_rr_ho_ref,                                           /* 10.5.2.15  Handover Reference                        */
6382         de_rr_ia_rest_oct,                                      /* [3] 10.5.2.16 IA Rest Octets                         */
6383         de_rr_iar_rest_oct,                                     /* [3] 10.5.2.17 IAR Rest Octets                        */
6384         de_rr_iax_rest_oct,                                     /* [3] 10.5.2.18 IAX Rest Octets                        */
6385         de_rr_l2_pseudo_len,                            /*[3] 10.5.2.19 L2 Pseudo Length                        */
6386         de_rr_meas_res,                                         /* [3] 10.5.2.20 Measurement Results            */
6387 /*
6388  * [3] (void)
6389  */
6390         de_rr_mob_all,                                  /* [3] 10.5.2.21 Mobile Allocation                              */
6391         de_rr_mob_time_diff,                    /* [3] 10.5.2.21a Mobile Time Difference                */
6392         de_rr_multirate_conf,                   /* [3] 10.5.2.21aa MultiRate configuration              */
6393         /* Pos 30 */
6394         de_rr_mult_all,                                 /* [3] 10.5.2.21b Multislot Allocation                  */
6395 /*
6396  * [3] 10.5.2.21c (void)
6397  */
6398         de_rr_neigh_cell_desc,                          /* [3] 10.5.2.22 Neighbour Cell Description     */
6399         de_rr_neigh_cell_desc2,                         /* [3] 10.5.2.22a Neighbour Cell Description 2  */
6400 /*
6401  * [3] 10.5.2.22b (void)
6402  * [3] 10.5.2.22c NT/N Rest Octets */
6403         de_rr_p1_rest_oct,                                      /* [3] 10.5.2.23 P1 Rest Octets */
6404         de_rr_p2_rest_oct,                                      /* [3] 10.5.2.24 P2 Rest Octets */
6405         de_rr_p3_rest_oct,                                      /* [3] 10.5.2.25 P3 Rest Octets */
6406         de_rr_packet_ch_desc,                   /* [3] 10.5.2.25a Packet Channel Description    */
6407         de_rr_ded_mod_or_tbf,                   /* [3] 10.5.2.25b Dedicated mode or TBF                 */
6408 /* [3] 10.5.2.25c RR Packet Uplink Assignment
6409  * [3] 10.5.2.25d RR Packet Downlink Assignment
6410  */
6411         de_rr_page_mode,                                /* [3] 10.5.2.26 Page Mode                                              */
6412 /*
6413  * [3] 10.5.2.26a (void)
6414  * [3] 10.5.2.26b (void)
6415  * [3] 10.5.2.26c (void)
6416  * [3] 10.5.2.26d (void)
6417  */
6418         de_rr_ncc_perm,                                 /* [3] 10.5.2.27 NCC Permitted                                  */
6419         de_rr_pow_cmd,                                  /* 10.5.2.28  Power Command                                             */
6420         de_rr_pow_cmd_and_acc_type,             /* 10.5.2.28a Power Command and access type             */
6421         de_rr_rach_ctrl_param,                  /* [3] 10.5.2.29 RACH Control Parameters                */
6422         de_rr_req_ref,                                  /* [3] 10.5.2.30 Request Reference                              */
6423         de_rr_cause,                                    /* 10.5.2.31  RR Cause                                                  */
6424         de_rr_sync_ind,                                 /* 10.5.2.39  Synchronization Indication                */
6425         de_rr_si1_rest_oct,                                     /* [3] 10.5.2.32 SI1 Rest Octets        */
6426 /* [3] 10.5.2.33 SI 2bis Rest Octets */
6427         de_rr_si2ter_rest_oct,                          /* [3] 10.5.2.33a SI 2ter Rest Octets */
6428         de_rr_si2quater_rest_oct,                       /* [3] 10.5.2.33b SI 2quater Rest Octets */
6429         de_rr_si3_rest_oct,                                     /* [3] 10.5.2.34 SI3 Rest Octets        */
6430         de_rr_si4_rest_oct,                                     /* [3] 10.5.2.35 SI4 Rest Octets        */
6431         de_rr_si6_rest_oct,                                     /* [3] 10.5.2.35b SI6 Rest Octets       */
6432 /* [3] 10.5.2.36 SI 7 Rest Octets
6433  * [3] 10.5.2.37 SI 8 Rest Octets
6434  * [3] 10.5.2.37a SI 9 Rest Octets
6435  */
6436         de_rr_si13_rest_oct,                                    /* [3] 10.5.2.37a SI13 Rest Octets      */
6437 /* [3] 10.5.2.37c (void)
6438  * [3] 10.5.2.37d (void)
6439  * [3] 10.5.2.37e SI 16 Rest Octets
6440  * [3] 10.5.2.37f SI 17 Rest Octets
6441  * [3] 10.5.2.37g SI 19 Rest Octets
6442  * [3] 10.5.2.37h SI 18 Rest Octets
6443  * [3] 10.5.2.37i SI 20 Rest Octets */
6444         de_rr_starting_time,                            /* [3] 10.5.2.38 Starting Time                                  */
6445         de_rr_timing_adv,                                       /* [3] 10.5.2.40 Timing Advance                                 */
6446         de_rr_time_diff,                                        /* [3] 10.5.2.41 Time Difference                                */
6447         de_rr_tlli,                                                     /* [3] 10.5.2.41a TLLI                                                  */
6448         de_rr_tmsi_ptmsi,                                       /* [3] 10.5.2.42 TMSI/P-TMSI */
6449         de_rr_vgcs_tar_mode_ind,                        /* [3] 10.5.2.42a VGCS target mode Indication   */
6450         /* Pos 40 */
6451         de_rr_vgcs_cip_par,                                     /* [3] 10.5.2.42b       VGCS Ciphering Parameters       */
6452         de_rr_wait_ind,                                 /* [3] 10.5.2.43 Wait Indication */
6453 /* [3] 10.5.2.44 SI10 rest octets $(ASCI)$ */
6454         de_rr_ext_meas_result,                  /* [3] 10.5.2.45 Extended Measurement Results */
6455         de_rr_ext_meas_freq_list,               /* [3] 10.5.2.46 Extended Measurement Frequency List */
6456         de_rr_sus_cau,                                          /* [3] 10.5.2.47 Suspension Cause                               */
6457 /* [3] 10.5.2.48 APDU ID
6458  * [3] 10.5.2.49 APDU Flags
6459  * [3] 10.5.2.50 APDU Data */
6460         de_rr_ho_to_utran_cmd,                  /* [3] 10.5.2.51 Handover To UTRAN Command */
6461 /* [3] 10.5.2.52 Handover To cdma2000 Command
6462  * [3] 10.5.2.53 (void)
6463  * [3] 10.5.2.54 (void)
6464  * [3] 10.5.2.55 (void)
6465  * [3] 10.5.2.56 3G Target Cell
6466  * 10.5.2.57 Service Support */
6467         de_rr_serv_sup,                                         /* 10.5.2.57            Service Support                         */
6468 /*
6469  * 10.5.2.58 MBMS p-t-m Channel Description
6470  */
6471         de_rr_ded_serv_inf,                                     /* [3] 10.5.2.59        Dedicated Service Information */
6472 /*
6473  * 10.5.2.60 MPRACH Description
6474  * 10.5.2.61 Restriction Timer
6475  * 10.5.2.62 MBMS Session Identity
6476  * 10.5.2.63 Reduced group or broadcast call reference
6477  * 10.5.2.64 Talker Priority status
6478  * 10.5.2.65 Talker Identity
6479  * 10.5.2.66 Token
6480  * 10.5.2.67 PS Cause
6481  * 10.5.2.68 VGCS AMR Configuration
6482  */
6483         de_rr_carrier_ind,                                      /* 10.5.2.69 Carrier Indication */
6484         NULL,   /* NONE */
6485 };
6486
6487 /* MESSAGE FUNCTIONS */
6488
6489 /*
6490  * 9.1.1 Additional Assignment
6491  */
6492 static void
6493 dtap_rr_add_ass(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
6494 {
6495    guint32 curr_offset;
6496    guint32 consumed;
6497    guint curr_len;
6498
6499    curr_offset = offset;
6500    curr_len = len;
6501
6502    /* Channel Description  10.5.2.5  M V 3 */
6503    ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_CH_DSC);
6504
6505    /* Mobile Allocation  10.5.2.21  C TLV 3-10 */
6506    ELEM_OPT_TLV(0x72, GSM_A_PDU_TYPE_RR, DE_RR_MOB_ALL, "");
6507
6508    /* Starting Time  10.5.2.38  O TV 3 */
6509    ELEM_OPT_TV(0x7c, GSM_A_PDU_TYPE_RR, DE_RR_STARTING_TIME, "");
6510
6511    EXTRANEOUS_DATA_CHECK(curr_len, 0);
6512 }
6513
6514 /*
6515  * 9.1.2 Assignment command
6516  */
6517 static void
6518 dtap_rr_ass_cmd(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
6519 {
6520         guint32 curr_offset;
6521         guint32 consumed;
6522         guint   curr_len;
6523
6524         curr_offset = offset;
6525         curr_len = len;
6526
6527         /* Channel Description 2        10.5.2.5a       M V 3 */
6528         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_CH_DSC2);
6529
6530         /* Power Command                        10.5.2.28       M V 1 */
6531         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_POW_CMD);
6532
6533         /* 05 Frequency List            10.5.2.13       C TLV 4-132 */
6534         ELEM_OPT_TLV(0x05, GSM_A_PDU_TYPE_RR, DE_RR_FREQ_LIST, " - Frequency List, after time");
6535
6536         /* 62 Cell Channel Description  10.5.2.1b       O TV 17 */
6537         ELEM_OPT_TV(0x62, GSM_A_PDU_TYPE_RR, DE_RR_CELL_CH_DSC, "");
6538
6539         /* 10 Multislot Allocation              10.5.2.21b      C TLV 3-12 */
6540         ELEM_OPT_TLV(0x10,GSM_A_PDU_TYPE_RR, DE_RR_MULT_ALL, " - Description of the multislot configuration");
6541
6542         /* 63 Channel Mode                              10.5.2.6        O TV 2 */
6543         ELEM_OPT_TV(0x63,GSM_A_PDU_TYPE_RR, DE_RR_CH_MODE, " - Mode of the First Channel(Channel Set 1)");
6544
6545         /* 11 Channel Mode                              10.5.2.6        O TV 2 */
6546         ELEM_OPT_TV(0x11,GSM_A_PDU_TYPE_RR, DE_RR_CH_MODE, " - Mode of Channel Set 2");
6547
6548         /* 13 Channel Mode                              10.5.2.6        O TV 2 */
6549         ELEM_OPT_TV(0x13,GSM_A_PDU_TYPE_RR, DE_RR_CH_MODE, " - Mode of Channel Set 3");
6550
6551         /* 14 Channel Mode                              10.5.2.6        O TV 2 */
6552         ELEM_OPT_TV(0x14,GSM_A_PDU_TYPE_RR, DE_RR_CH_MODE, " - Mode of Channel Set 4");
6553
6554         /* 15 Channel Mode                              10.5.2.6        O TV 2 */
6555         ELEM_OPT_TV(0x15,GSM_A_PDU_TYPE_RR, DE_RR_CH_MODE, " - Mode of Channel Set 5");
6556
6557         /* 16 Channel Mode                              10.5.2.6        O TV 2 */
6558         ELEM_OPT_TV(0x16,GSM_A_PDU_TYPE_RR, DE_RR_CH_MODE, " - Mode of Channel Set 6");
6559
6560         /* 17 Channel Mode                              10.5.2.6        O TV 2 */
6561         ELEM_OPT_TV(0x17,GSM_A_PDU_TYPE_RR, DE_RR_CH_MODE, " - Mode of Channel Set 7");
6562
6563         /* 18 Channel Mode                              10.5.2.6        O TV 2 */
6564         ELEM_OPT_TV(0x18,GSM_A_PDU_TYPE_RR, DE_RR_CH_MODE, " - Mode of Channel Set 8");
6565
6566         /* 64 Channel Description               10.5.2.5        O TV 4 */
6567         ELEM_OPT_TV(0x64,GSM_A_PDU_TYPE_RR, DE_RR_CH_DSC, "Description of the Second Channel, after time");
6568
6569         /* 66  Channel Mode 2                   10.5.2.7        O TV 2 */
6570         ELEM_OPT_TV(0x66,GSM_A_PDU_TYPE_RR, DE_RR_CH_MODE2, " - Mode of the Second Channel");
6571
6572         /* 72 Mobile Allocation                 10.5.2.21       C TLV 3-10 */
6573         ELEM_OPT_TLV(0x72,GSM_A_PDU_TYPE_RR, DE_RR_MOB_ALL, " - Mobile Allocation, after time");
6574
6575         /* 7C Starting Time                             10.5.2.38       O TV 3 */
6576         ELEM_OPT_TV(0x7C,GSM_A_PDU_TYPE_RR, DE_RR_STARTING_TIME, "");
6577
6578         /* 19 Frequency List                    10.5.2.13       C TLV 4-132 */
6579         ELEM_OPT_TLV(0x19, GSM_A_PDU_TYPE_RR, DE_RR_FREQ_LIST, " - Frequency List, before time");
6580
6581         /* 1C Channel Description 2             10.5.2.5a       O TV 4 */
6582         ELEM_OPT_TV(0x1c,GSM_A_PDU_TYPE_RR, DE_RR_CH_DSC2, " - Description of the First Channel, before time");
6583
6584         /* 1D Channel Description               10.5.2.5        O TV 4 */
6585         ELEM_OPT_TV(0x1d,GSM_A_PDU_TYPE_RR, DE_RR_CH_DSC, " - Description of the Second Channel, before time");
6586
6587         /* 1E Frequency channel sequence 10.5.2.12      C TV 10 */
6588         ELEM_OPT_TV(0x1e,GSM_A_PDU_TYPE_RR, DE_RR_FREQ_CH_SEQ, " - Frequency channel sequence before time");
6589
6590         /* 21 Mobile Allocation                 10.5.2.21       C TLV 3-10 */
6591         ELEM_OPT_TLV(0x21,GSM_A_PDU_TYPE_RR, DE_RR_MOB_ALL, " - Mobile Allocation, before time");
6592
6593         /* 9- Cipher Mode Setting               10.5.2.9        O TV 1 */
6594         ELEM_OPT_TV_SHORT(0x90,GSM_A_PDU_TYPE_RR, DE_RR_CIP_MODE_SET, "");
6595         /* 01 VGCS target mode Indication VGCS target mode Indication 10.5.2.42a O TLV 3 */
6596         ELEM_OPT_TLV(0x01,GSM_A_PDU_TYPE_RR, DE_RR_VGCS_TAR_MODE_IND, "");
6597
6598         /* 03 Multi-Rate configuration, MultiRate configuration 10.5.2.21aa     O TLV 4-8 */
6599         ELEM_OPT_TLV(0x03,GSM_A_PDU_TYPE_RR, DE_RR_MULTIRATE_CONF, "");
6600
6601         /* 04 VGCS Ciphering Parameters VGCS Ciphering Parameters 10.5.2.42b O TLV 3-15 */
6602         ELEM_OPT_TLV(0x04,GSM_A_PDU_TYPE_RR, DE_RR_VGCS_CIP_PAR, "");
6603
6604         EXTRANEOUS_DATA_CHECK(curr_len, 0);
6605
6606 }
6607
6608 /*
6609  * 9.1.3 Assignment complete
6610  */
6611 static void
6612 dtap_rr_ass_comp(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
6613 {
6614         guint32 curr_offset;
6615         guint32 consumed;
6616         guint   curr_len;
6617
6618         curr_offset = offset;
6619         curr_len = len;
6620
6621         /* RR Cause RR Cause 10.5.2.31 M V 1 */
6622         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_CAUSE);
6623
6624         EXTRANEOUS_DATA_CHECK(curr_len, 0);
6625
6626 }
6627
6628 /*
6629  * 9.1.4 Assignment failure
6630  */
6631 static void
6632 dtap_rr_ass_fail(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
6633 {
6634         guint32 curr_offset;
6635         guint32 consumed;
6636         guint   curr_len;
6637
6638         curr_offset = offset;
6639         curr_len = len;
6640
6641         /* RR Cause RR Cause 10.5.2.31 M V 1 */
6642         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_CAUSE);
6643
6644         EXTRANEOUS_DATA_CHECK(curr_len, 0);
6645
6646 }
6647
6648 /*
6649  * 9.1.5 Channel Mode Modify
6650  */
6651 static void
6652 dtap_rr_ch_mode_mod(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
6653 {
6654         guint32 curr_offset;
6655         guint32 consumed;
6656         guint   curr_len;
6657
6658         curr_offset = offset;
6659         curr_len = len;
6660
6661         /* Channel Description 2        10.5.2.5a       M V 3 */
6662         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_CH_DSC2);
6663
6664         /* Channel Mode                         10.5.2.6        M V 1 */
6665         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_CH_MODE);
6666
6667         /* 01 VGCS target mode Indication VGCS target mode Indication 10.5.2.42a O TLV 3 */
6668         ELEM_OPT_TLV(0x01,GSM_A_PDU_TYPE_RR, DE_RR_VGCS_TAR_MODE_IND, "");
6669
6670         /* 03 Multi-Rate configuration, MultiRate configuration 10.5.2.21aa     O TLV 4-8 */
6671         ELEM_OPT_TLV(0x03,GSM_A_PDU_TYPE_RR, DE_RR_MULTIRATE_CONF, "");
6672
6673         EXTRANEOUS_DATA_CHECK(curr_len, 0);
6674
6675 }
6676
6677 /*
6678  * 9.1.6 Channel Mode Modify Acknowledge
6679  */
6680 static void
6681 dtap_rr_ch_mode_mod_ack(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
6682 {
6683         guint32 curr_offset;
6684         guint32 consumed;
6685         guint   curr_len;
6686
6687         curr_offset = offset;
6688         curr_len = len;
6689
6690         /* Channel Description 2        10.5.2.5a       M V 3 */
6691         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_CH_DSC2);
6692
6693         /* Channel Mode                         10.5.2.6        M V 1 */
6694         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_CH_MODE);
6695
6696         EXTRANEOUS_DATA_CHECK(curr_len, 0);
6697
6698 }
6699
6700 /*
6701  * 9.1.7 Channel Release
6702  */
6703 static void
6704 dtap_rr_ch_rel(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
6705 {
6706         guint32 curr_offset;
6707         guint32 consumed;
6708         guint   curr_len;
6709
6710         curr_offset = offset;
6711         curr_len = len;
6712
6713         /* RR Cause RR Cause 10.5.2.31 M V 1 */
6714         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_CAUSE);
6715
6716         /* 73 BA Range BA Range 10.5.2.1a O TLV 6-7 */
6717         ELEM_OPT_TLV(0x73, GSM_A_PDU_TYPE_RR, DE_RR_BA_RANGE, "");
6718
6719         /* 74 Group Channel Description Group Channel Description 10.5.2.14b O TLV 5-13 */
6720         /* ELEM_OPT_TLV(0x74, GSM_A_PDU_TYPE_RR, DE_GRP_CH_DESC, ""); */
6721
6722         /* 8x Group Cipher Key Number Group Cipher Key Number 10.5.1.10 C TV 1 */
6723         /* ELEM_OPT_TV_SHORT(0x80, GSM_A_PDU_TYPE_RR, DE_GRP_CIP_KEY_NUM, ""); */
6724
6725         /* Cx GPRS Resumption GPRS Resumption 10.5.2.14c O TV 1 */
6726         ELEM_OPT_TV_SHORT(0xC0, GSM_A_PDU_TYPE_RR, DE_RR_GPRS_RESUMPTION, "");
6727
6728         /* 75 BA List Pref BA List Pref 10.5.2.1c O TLV 3-? */
6729         ELEM_OPT_TLV(0x75, GSM_A_PDU_TYPE_RR, DE_RR_BA_LIST_PREF, "");
6730
6731         /* 76 UTRAN Freq List 10.5.2.1d O TLV 3-? */
6732         ELEM_OPT_TLV(0x76, GSM_A_PDU_TYPE_RR, DE_RR_UTRAN_FREQ_LIST, "");
6733
6734         /* 62 Cell Channel Description Cell Channel Description 10.5.2.1b O TV 17 */
6735         ELEM_OPT_TV(0x62, GSM_A_PDU_TYPE_RR, DE_RR_CELL_CH_DSC, "");
6736
6737         /* 62 Cell selection indicator after release of all TCH and SDCCH 10.5.2.1e O TLV 4-? */
6738         ELEM_OPT_TLV(0x77, GSM_A_PDU_TYPE_RR, DE_RR_CELL_SELECT_INDIC, "");
6739
6740         EXTRANEOUS_DATA_CHECK(curr_len, 0);
6741
6742 }
6743
6744 /*
6745  * 9.1.8 Channel Request
6746  */
6747 /* This message is NOT follow the basic format, and is only found on RACH - ignored here */
6748
6749 /*
6750  * 9.1.9 Ciphering Mode Command
6751  */
6752 static void
6753 dtap_rr_cip_mode_cmd(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
6754 {
6755         guint32 curr_offset;
6756         guint32 consumed;
6757         guint   curr_len;
6758
6759         curr_offset = offset;
6760         curr_len = len;
6761         lower_nibble = FALSE;
6762
6763         /* Ciphering Mode Setting               10.5.2.9        M V 0.5 */
6764         ELEM_MAND_V_SHORT(GSM_A_PDU_TYPE_RR, DE_RR_CIP_MODE_SET);
6765         /* Cipher Response      10.5.2.10       M V 0.5 */
6766         ELEM_MAND_V_SHORT(GSM_A_PDU_TYPE_RR, DE_RR_CIP_MODE_RESP);
6767
6768         EXTRANEOUS_DATA_CHECK(curr_len, 0);
6769
6770 }
6771 /*
6772  * 9.1.10 Ciphering Mode Complete
6773  */
6774 static void
6775 dtap_rr_cip_mode_cpte(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
6776 {
6777         guint32 curr_offset;
6778         guint32 consumed;
6779         guint   curr_len;
6780
6781         curr_offset = offset;
6782         curr_len = len;
6783         lower_nibble = FALSE;
6784
6785         /* Mobile Equipment Identity            10.5.1.4        O TLV */
6786         ELEM_OPT_TLV(0x17, GSM_A_PDU_TYPE_COMMON, DE_MID, "Mobile Equipment Identity");
6787
6788         EXTRANEOUS_DATA_CHECK(curr_len, 0);
6789
6790 }
6791
6792 /*
6793  * 9.1.11 Classmark change
6794  */
6795 static void
6796 dtap_rr_mm_cm_change(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
6797 {
6798         guint32 curr_offset;
6799         guint32 consumed;
6800         guint   curr_len;
6801
6802         curr_offset = offset;
6803         curr_len = len;
6804
6805         /* Mobile Station Classmark 2           10.5.1.6        M LV 4 */
6806         ELEM_MAND_LV(GSM_A_PDU_TYPE_COMMON, DE_MS_CM_2, "");
6807         /* 20 Mobile Station Classmark 3        10.5.1.7        C TLV 3-34 */
6808         ELEM_OPT_TLV(0x20, GSM_A_PDU_TYPE_COMMON, DE_MS_CM_3, "");
6809
6810         EXTRANEOUS_DATA_CHECK(curr_len, 0);
6811
6812 }
6813
6814 /*
6815  * 9.1.11 UTRAN Classmark Change
6816  */
6817 static void
6818 dtap_rr_utran_classmark_change(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
6819 {
6820         guint32 curr_offset;
6821         guint32 consumed;
6822         guint   curr_len;
6823
6824         curr_offset = offset;
6825         curr_len = len;
6826
6827         /* UTRAN Classmark              10.5.2.7a       M LV 2-? */
6828         ELEM_MAND_LV(GSM_A_PDU_TYPE_RR, DE_RR_UTRAN_CM, "");
6829
6830         EXTRANEOUS_DATA_CHECK(curr_len, 0);
6831 }
6832
6833 /*
6834  * 9.1.12 Classmark enquiry
6835  */
6836 static void
6837 dtap_rr_cm_enq(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
6838 {
6839         guint32 curr_offset;
6840         guint32 consumed;
6841         guint   curr_len;
6842
6843         curr_offset = offset;
6844         curr_len = len;
6845
6846         /* 10 Classmark Enquiry Mask    10.5.2.7c       O TLV 3 */
6847         ELEM_OPT_TLV(0x10, GSM_A_PDU_TYPE_RR, DE_RR_CM_ENQ_MASK, "");
6848
6849         EXTRANEOUS_DATA_CHECK(curr_len, 0);
6850
6851 }
6852
6853 /*
6854  * 9.1.12b Configuration change command
6855  */
6856 static void
6857 dtap_rr_conf_change_cmd(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
6858 {
6859    guint32 curr_offset;
6860    guint32 consumed;
6861    guint curr_len;
6862
6863    curr_offset = offset;
6864    curr_len = len;
6865
6866    /* Multislot Allocation  10.5.2.21b  M LV 2-11 */
6867    ELEM_MAND_LV(GSM_A_PDU_TYPE_RR, DE_RR_MULT_ALL, "");
6868
6869    /* Channel Mode  10.5.2.6  O TV 2 */
6870    ELEM_OPT_TV(0x63,GSM_A_PDU_TYPE_RR, DE_RR_CH_MODE, " - Mode of Channel Set 1");
6871
6872    /* Channel Mode  10.5.2.6  O TV 2 */
6873    ELEM_OPT_TV(0x11,GSM_A_PDU_TYPE_RR, DE_RR_CH_MODE, " - Mode of Channel Set 2");
6874
6875    /* Channel Mode  10.5.2.6  O TV 2 */
6876    ELEM_OPT_TV(0x13,GSM_A_PDU_TYPE_RR, DE_RR_CH_MODE, " - Mode of Channel Set 3");
6877
6878    /* Channel Mode  10.5.2.6  O TV 2 */
6879    ELEM_OPT_TV(0x14,GSM_A_PDU_TYPE_RR, DE_RR_CH_MODE, " - Mode of Channel Set 4");
6880
6881    /* Channel Mode  10.5.2.6  O TV 2 */
6882    ELEM_OPT_TV(0x15,GSM_A_PDU_TYPE_RR, DE_RR_CH_MODE, " - Mode of Channel Set 5");
6883
6884    /* Channel Mode  10.5.2.6  O TV 2 */
6885    ELEM_OPT_TV(0x16,GSM_A_PDU_TYPE_RR, DE_RR_CH_MODE, " - Mode of Channel Set 6");
6886
6887    /* Channel Mode  10.5.2.6  O TV 2 */
6888    ELEM_OPT_TV(0x17,GSM_A_PDU_TYPE_RR, DE_RR_CH_MODE, " - Mode of Channel Set 7");
6889
6890    /* Channel Mode  10.5.2.6  O TV 2 */
6891    ELEM_OPT_TV(0x18,GSM_A_PDU_TYPE_RR, DE_RR_CH_MODE, " - Mode of Channel Set 8");
6892
6893    EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
6894 }
6895
6896 /*
6897  * 9.1.12c      Configuration change acknowledge
6898  */
6899 /* empty message */
6900
6901 /*
6902  * 9.1.12d      Configuration change reject
6903  */
6904 static void
6905 dtap_rr_conf_change_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
6906 {
6907    guint32 curr_offset;
6908    guint32 consumed;
6909    guint curr_len;
6910
6911    curr_offset = offset;
6912    curr_len = len;
6913
6914    /* RR Cause  10.5.2.31  M V 1 */
6915    ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_CAUSE);
6916
6917    EXTRANEOUS_DATA_CHECK(curr_len, 0);
6918 }
6919
6920
6921 /*
6922  * 9.1.13 Frequency Redefinition
6923  */
6924 static void
6925 dtap_rr_freq_redef(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
6926 {
6927    guint32 curr_offset;
6928    guint32 consumed;
6929    guint curr_len;
6930
6931    curr_offset = offset;
6932    curr_len = len;
6933
6934    /* Channel Description  10.5.2.5  M V 3 */
6935    ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_CH_DSC);
6936
6937    /* Mobile Allocation  10.5.2.21  M LV 1-9 */
6938    ELEM_MAND_LV(GSM_A_PDU_TYPE_RR, DE_RR_MOB_ALL, "");
6939
6940    /* Starting Time  10.5.2.38  M V 2 */
6941    ELEM_MAND_LV(GSM_A_PDU_TYPE_RR, DE_RR_STARTING_TIME, "");
6942
6943    /* Cell Channel Description  10.5.2.1b  O TV 17 */
6944    ELEM_OPT_TV(0x62,GSM_A_PDU_TYPE_RR, DE_RR_CELL_CH_DSC, "");
6945
6946    /* Carrier Indication  10.5.2.69  O TV 1 */
6947    ELEM_OPT_TV_SHORT(0x90,GSM_A_PDU_TYPE_RR, DE_RR_CARRIER_IND,"");
6948
6949    /* Mobile Allocation  10.5.2.21  O TLV 1-9 */
6950    ELEM_OPT_TLV(0x11, GSM_A_PDU_TYPE_RR, DE_RR_MOB_ALL, " - Mobile Allocation C2");
6951
6952    /* Channel Description 3  10.5.2.5c  O TV 3 */
6953    ELEM_OPT_TV(0x12,GSM_A_PDU_TYPE_RR, DE_RR_CH_DSC3, " - Channel Description C2");
6954
6955    EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
6956 }
6957
6958 /*
6959  * 9.1.13b GPRS suspension request
6960  */
6961 static void
6962 dtap_rr_gprs_sus_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
6963 {
6964         guint32 curr_offset;
6965         guint32 consumed;
6966         guint   curr_len;
6967         curr_offset = offset;
6968         curr_len = len;
6969
6970         /* TLLI                                                         10.5.2.41a      M V 4 */
6971         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_TLLI);
6972
6973         /* Routeing Area Identification         10.5.5.15       M V 6 */
6974         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_RAI);
6975         /* Suspension cause                                     10.5.2.47       M V 1 */
6976         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_SUS_CAU);
6977
6978         /* 01 Service Support                                   10.5.2.57       O TV 2 */
6979         ELEM_OPT_TV_SHORT(0x01,GSM_A_PDU_TYPE_RR, DE_RR_SERV_SUP,"");
6980
6981         EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
6982
6983 }
6984
6985 /*
6986  * 9.1.14 Handover Access
6987  */
6988 /* This message is NOT follow the basic format, and is only found on DCH during initial handover access */
6989
6990 /* 3GPP TS 24.008 version 4.7.0 Release 4
6991  * [3] 9.1.15
6992  */
6993 void
6994 dtap_rr_ho_cmd(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
6995 {
6996         guint32 curr_offset;
6997         guint32 consumed;
6998         guint   curr_len;
6999         curr_offset = offset;
7000         curr_len = len;
7001
7002         /* Mandatory Elemets
7003          * Cell description 10.5.2.2
7004          */
7005         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_CELL_DSC);
7006
7007         /* Description of the first channel,after time
7008          * Channel Description 2 10.5.2.5a
7009          */
7010         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_CH_DSC2);
7011
7012         /* Handover Reference 10.5.2.15 */
7013         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_HO_REF);
7014
7015         /* Power Command and Access type 10.5.2.28a */
7016         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_POW_CMD_AND_ACC_TYPE);
7017
7018         /* optional elements */
7019
7020         /* Synchronization Indication 10.5.2.39 */
7021         ELEM_OPT_TV_SHORT(0xD0,GSM_A_PDU_TYPE_RR, DE_RR_SYNC_IND,"");
7022
7023         /* Frequency Short List 10.5.2.14 */
7024         ELEM_OPT_TV(0x02,GSM_A_PDU_TYPE_RR, DE_RR_FREQ_SHORT_LIST," - Frequency Short List, after time");
7025
7026         /* Frequency List 10.5.2.13 */
7027         ELEM_OPT_TLV(0x05, GSM_A_PDU_TYPE_RR, DE_RR_FREQ_LIST, " - Frequency List, after time");
7028
7029         /* Cell Channel Description 10.5.2.1b */
7030         ELEM_OPT_TV(0x62,GSM_A_PDU_TYPE_RR, DE_RR_CELL_CH_DSC, "");
7031
7032         /* Multislot Allocation 10.5.2.21b */
7033         ELEM_OPT_TLV(0x10,GSM_A_PDU_TYPE_RR, DE_RR_MULT_ALL, "");
7034
7035         /* Mode of the First Channel(Channel Set 1)) Channel Mode 10.5.2.6*/
7036         ELEM_OPT_TV(0x63,GSM_A_PDU_TYPE_RR, DE_RR_CH_MODE, " - Mode of the First Channel(Channel Set 1))");
7037
7038         /* Mode of Channel Set 2 Channel Mode 10.5.2.6*/
7039         ELEM_OPT_TV(0x11,GSM_A_PDU_TYPE_RR, DE_RR_CH_MODE, " - Mode of Channel Set 2");
7040
7041         /* Mode of Channel Set 3 Channel Mode 10.5.2.6*/
7042         ELEM_OPT_TV(0x13,GSM_A_PDU_TYPE_RR, DE_RR_CH_MODE, " - Mode of Channel Set 3");
7043
7044         /* Mode of Channel Set 4 Channel Mode 10.5.2.6*/
7045         ELEM_OPT_TV(0x14,GSM_A_PDU_TYPE_RR, DE_RR_CH_MODE, " - Mode of Channel Set 4");
7046
7047         /* Mode of Channel Set 5 Channel Mode 10.5.2.6*/
7048         ELEM_OPT_TV(0x15,GSM_A_PDU_TYPE_RR, DE_RR_CH_MODE, " - Mode of Channel Set 5");
7049
7050         /* Mode of Channel Set 6 Channel Mode 10.5.2.6*/
7051         ELEM_OPT_TV(0x16,GSM_A_PDU_TYPE_RR, DE_RR_CH_MODE, " - Mode of Channel Set 6");
7052
7053         /* Mode of Channel Set 7 Channel Mode 10.5.2.6*/
7054         ELEM_OPT_TV(0x17,GSM_A_PDU_TYPE_RR, DE_RR_CH_MODE, " - Mode of Channel Set 7");
7055
7056         /* Mode of Channel Set 8 Channel Mode 10.5.2.6*/
7057         ELEM_OPT_TV(0x18,GSM_A_PDU_TYPE_RR, DE_RR_CH_MODE, " - Mode of Channel Set 8");
7058
7059         /* Description of the Second Channel, after time, Channel Description 10.5.2.5 */
7060         ELEM_OPT_TV(0x64,GSM_A_PDU_TYPE_RR, DE_RR_CH_DSC, " - Description of the Second Channel, after time");
7061
7062         /* Mode of the Second Channel, Channel Mode 2 10.5.2.7 */
7063         ELEM_OPT_TV(0x66,GSM_A_PDU_TYPE_RR, DE_RR_CH_MODE2, " - Mode of the Second Channel");
7064
7065         /* Frequency Channel Sequence, after time, Frequency Channel Sequence 10.5.2.12 */
7066         ELEM_OPT_TV(0x69,GSM_A_PDU_TYPE_RR, DE_RR_FREQ_CH_SEQ, " - Frequency Channel Sequence, after time");
7067
7068         /* Mobile Allocation, after time, Mobile Allocation 10.5.2.21 */
7069         ELEM_OPT_TLV(0x72,GSM_A_PDU_TYPE_RR, DE_RR_MOB_ALL, " - Mobile Allocation, after time");
7070
7071         /* Starting Time 10.5.2.38 */
7072         ELEM_OPT_TV(0x7C,GSM_A_PDU_TYPE_RR, DE_RR_STARTING_TIME, "");
7073
7074         /* Real Time Difference, Time Difference 10.5.2.41 */
7075         ELEM_OPT_TV(0x7B,GSM_A_PDU_TYPE_RR, DE_RR_TIME_DIFF, " - Real Time Difference");
7076
7077         /* Timing Advance, Timing Advance 10.5.2.40 */
7078         ELEM_OPT_TV(0x7D,GSM_A_PDU_TYPE_RR, DE_RR_TIMING_ADV, "");
7079
7080         /* Frequency Short List, before time, Frequency Short List 10.5.2.14 */
7081         ELEM_OPT_TV(0x12,GSM_A_PDU_TYPE_RR, DE_RR_FREQ_SHORT_LIST, " - Frequency Short List, before time");
7082
7083         /* Frequency List, before time, Frequency List 10.5.2.13 */
7084         ELEM_OPT_TLV(0x19,GSM_A_PDU_TYPE_RR, DE_RR_FREQ_LIST, " - Frequency List, before time");
7085
7086         /* Description of the First Channel, before time,       Channel Description 2 10.5.2.5a*/
7087         ELEM_OPT_TV(0x1c,GSM_A_PDU_TYPE_RR, DE_RR_CH_DSC2, " - Description of the First Channel, before time");
7088
7089         /* Description of the Second Channel, before time,      Channel Description 10.5.2.5*/
7090         ELEM_OPT_TV(0x1d,GSM_A_PDU_TYPE_RR, DE_RR_CH_DSC, " - Description of the Second Channel, before time");
7091
7092         /* Frequency channel sequence before time,      Frequency channel sequence 10.5.2.12*/
7093         ELEM_OPT_TV(0x1e,GSM_A_PDU_TYPE_RR, DE_RR_FREQ_CH_SEQ, " - Frequency channel sequence before time");
7094
7095         /* Mobile Allocation, before time,      Mobile Allocation 10.5.2.21 */
7096         ELEM_OPT_TLV(0x21,GSM_A_PDU_TYPE_RR, DE_RR_MOB_ALL, " - Mobile Allocation, before time");
7097
7098         /* Cipher Mode Setting, Cipher Mode Setting 10.5.2.9 */
7099         ELEM_OPT_TV_SHORT(0x90,GSM_A_PDU_TYPE_RR, DE_RR_CIP_MODE_SET, "");
7100
7101         /* VGCS target mode Indication, VGCS target mode Indication 10.5.2.42a */
7102         ELEM_OPT_TLV(0x01,GSM_A_PDU_TYPE_RR, DE_RR_VGCS_TAR_MODE_IND, "");
7103
7104         /* Multi-Rate configuration,    MultiRate configuration 10.5.2.21a */
7105         ELEM_OPT_TLV(0x03,GSM_A_PDU_TYPE_RR, DE_RR_MULTIRATE_CONF, "");
7106
7107         /* Dynamic ARFCN Mapping,       Dynamic ARFCN Mapping 10.5.2.11b */
7108         ELEM_OPT_TLV(0x76,GSM_A_PDU_TYPE_RR, DE_RR_DYN_ARFCN_MAP, "");
7109
7110         /* VGCS Ciphering Parameters,   VGCS Ciphering Parameters 10.5.2.42b */
7111         ELEM_OPT_TLV(0x04,GSM_A_PDU_TYPE_RR, DE_RR_VGCS_CIP_PAR, "");
7112
7113         /* Dedicated Service Information,       Dedicated Service Information 10.5.2.59 */
7114         ELEM_OPT_TV(0x51,GSM_A_PDU_TYPE_RR, DE_RR_DED_SERV_INF, "");
7115
7116         EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
7117
7118 }
7119
7120 /*
7121  * 9.1.15a Inter System To UTRAN Handover Command
7122  */
7123 static void
7124 dtap_rr_inter_syst_to_utran_ho_cmd(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
7125 {
7126         guint32 curr_offset;
7127         guint32 consumed;
7128         guint   curr_len;
7129
7130         curr_offset = offset;
7131         curr_len = len;
7132
7133         /* UTRAN Classmark              10.5.2.51       M LV 2-? */
7134         ELEM_MAND_LV(GSM_A_PDU_TYPE_RR, DE_RR_HO_TO_UTRAN_CMD, "");
7135
7136         EXTRANEOUS_DATA_CHECK(curr_len, 0);
7137 }
7138
7139 /* 3GPP TS 24.008 version 4.7.0 Release 4
7140  * [3] 9.1.16
7141  */
7142 static void
7143 dtap_rr_ho_cpte(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
7144 {
7145         guint32 curr_offset;
7146         guint32 consumed;
7147         guint   curr_len;
7148         curr_offset = offset;
7149         curr_len = len;
7150
7151         /* RR Cause RR Cause 10.5.2.31 M V 1 */
7152         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_CAUSE);
7153
7154         /* 77 Mobile Observed Time Difference   Mobile Time Difference 10.5.2.21a */
7155         ELEM_OPT_TLV(0x77,GSM_A_PDU_TYPE_RR, DE_RR_MOB_TIME_DIFF, " - Mobile Observed Time Difference");
7156
7157         EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
7158
7159 }
7160
7161 /*
7162  * 9.1.17 Handover failure
7163  */
7164 static void
7165 dtap_rr_ho_fail(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
7166 {
7167         guint32 curr_offset;
7168         guint32 consumed;
7169         guint   curr_len;
7170
7171         curr_offset = offset;
7172         curr_len = len;
7173
7174         /* RR Cause RR Cause 10.5.2.31 M V 1 */
7175         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_CAUSE);
7176
7177         EXTRANEOUS_DATA_CHECK(curr_len, 0);
7178
7179 }
7180
7181 /*
7182  * 9.1.18 Immediate assignment
7183  */
7184 static void
7185 dtap_rr_imm_ass(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
7186 {
7187         guint32 curr_offset;
7188         guint32 consumed;
7189         guint   curr_len;
7190         guint8 oct;
7191         curr_offset = offset;
7192         curr_len = len;
7193
7194         oct = tvb_get_guint8(tvb, curr_offset);
7195
7196         /* NOTE: The order of the mandatory information elements should be chosen so that
7197          * information elements with 1/2 octet of content (type 1) go together in succession.
7198          * The first type 1 information element occupies bits 1 to 4 of octet N,
7199          * the second bits 5 to 8 of octet N, the third bits 1 to 4 of octet N+1 etc.
7200          * If the number of type 1 information elements is odd then bits 5 to 8 of the last octet
7201          *  occupied by these information elements should be treated as spare bits,
7202          * i.e. coded with a "0" in each.
7203          */
7204
7205         /* Page Mode                                    10.5.2.26       M V 1/2 */
7206         ELEM_MAND_V_SHORT(GSM_A_PDU_TYPE_RR, DE_RR_PAGE_MODE);
7207
7208         /* Dedicated mode or TBF                10.5.2.25b      M V 1/2 */
7209         ELEM_MAND_V_SHORT(GSM_A_PDU_TYPE_RR, DE_RR_DED_MOD_OR_TBF);
7210
7211         if((oct&0x10) == 0){
7212         /* Channel Description                  10.5.2.5        C V 3m */
7213                 ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_CH_DSC);
7214         }else{
7215         /* Packet Channel Description   10.5.2.25a      C V 3
7216          * If the Dedicated mode or TBF IE indicates that the message assigns a Temporary Block Flow (TBF),
7217          * the mobile station shall consider this information element present in the message.
7218          * If the Dedicated mode or TBF IE indicates that this message is the first of two in a two-message
7219          * assignment of an uplink or downlink TBF, the mobile station shall ignore the contents
7220          * of this information element and regard it as an unnecessary IE.
7221          */
7222                 if((oct&0x04) == 0){
7223                         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_PACKET_CH_DESC);
7224                 }
7225         }
7226         /* Request Reference                    10.5.2.30       M V 3   */
7227         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_REQ_REF);
7228
7229         /* Timing Advance                               10.5.2.40       M V 1   */
7230         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_TIMING_ADV);
7231         /* Mobile Allocation                    10.5.2.21       M LV 1-9 */
7232         ELEM_MAND_LV(GSM_A_PDU_TYPE_RR, DE_RR_MOB_ALL, "");
7233         /* 7C Starting Time                             10.5.2.38       O TV 3  */
7234         ELEM_OPT_TV(0x7C,GSM_A_PDU_TYPE_RR, DE_RR_STARTING_TIME, "");
7235         /* IA Rest Octets                               10.5.2.16       M V 0-11 */
7236         if(tvb_length_remaining(tvb,curr_offset) > 0)
7237                 ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_IA_REST_OCT);
7238
7239 }
7240
7241 /*
7242  * 9.1.19 Immediate assignment extended
7243  */
7244 static void
7245 dtap_rr_imm_ass_ext(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
7246 {
7247         guint32 curr_offset;
7248         guint32 consumed;
7249         guint   curr_len;
7250         guint8 oct;
7251         curr_offset = offset;
7252         curr_len = len;
7253
7254         oct = tvb_get_guint8(tvb, curr_offset);
7255
7256         /* Page Mode                                    10.5.2.26       M V 1/2 */
7257         ELEM_MAND_V_SHORT(GSM_A_PDU_TYPE_RR, DE_RR_PAGE_MODE);
7258         /* Spare Half Octet             10.5.1.8        M V 1/2 */
7259         ELEM_MAND_V_SHORT(GSM_A_PDU_TYPE_COMMON, DE_SPARE_NIBBLE);
7260         /* Channel Description 1        Channel Description             10.5.2.5        M V 3 */
7261         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_CH_DSC);
7262         /* Request Reference 1  Request Reference               10.5.2.30       M V 3   */
7263         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_REQ_REF);
7264         /* Timing Advance 1     Timing Advance                  10.5.2.40       M V 1   */
7265         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_TIMING_ADV);
7266         /* Channel Description 2        Channel Description             10.5.2.5        M V 3 */
7267         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_CH_DSC);
7268         /* Request Reference 2  Request Reference               10.5.2.30       M V 3   */
7269         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_REQ_REF);
7270         /* Timing Advance 2     Timing Advance                  10.5.2.40       M V 1   */
7271         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_TIMING_ADV);
7272         /* Mobile Allocation                    10.5.2.21       M LV 1-9 */
7273         ELEM_MAND_LV(GSM_A_PDU_TYPE_RR, DE_RR_MOB_ALL, "");
7274         /* 7C Starting Time                             10.5.2.38       O TV 3  */
7275         ELEM_OPT_TV(0x7C,GSM_A_PDU_TYPE_RR, DE_RR_STARTING_TIME, "");
7276         /* IAX Rest Octets                              10.5.2.18       M V 0-4 */
7277         if(tvb_length_remaining(tvb,curr_offset) > 0)
7278                 ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_IAX_REST_OCT);
7279
7280 }
7281
7282 /*
7283  * 9.1.20 Immediate assignment reject
7284  */
7285 static void
7286 dtap_rr_imm_ass_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
7287 {
7288         guint32 curr_offset;
7289         guint32 consumed;
7290         guint   curr_len;
7291         guint8 oct;
7292         curr_offset = offset;
7293         curr_len = len;
7294
7295         oct = tvb_get_guint8(tvb, curr_offset);
7296
7297         /* Page Mode                                    10.5.2.26       M V 1/2 */
7298         ELEM_MAND_V_SHORT(GSM_A_PDU_TYPE_RR, DE_RR_PAGE_MODE);
7299         /* Spare Half Octet             10.5.1.8        M V 1/2 */
7300         ELEM_MAND_V_SHORT(GSM_A_PDU_TYPE_COMMON, DE_SPARE_NIBBLE);
7301         /* Request Reference 1  Request Reference               10.5.2.30       M V 3   */
7302         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_REQ_REF);
7303         /* Wait Indication 1    Wait Indication                 10.5.2.43       M V 1   */
7304         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_WAIT_IND);
7305         /* Request Reference 2  Request Reference               10.5.2.30       M V 3   */
7306         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_REQ_REF);
7307         /* Wait Indication 2    Wait Indication                 10.5.2.43       M V 1   */
7308         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_WAIT_IND);
7309         /* Request Reference 3  Request Reference               10.5.2.30       M V 3   */
7310         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_REQ_REF);
7311         /* Wait Indication 3    Wait Indication                 10.5.2.43       M V 1   */
7312         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_WAIT_IND);
7313         /* Request Reference 4  Request Reference               10.5.2.30       M V 3   */
7314         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_REQ_REF);
7315         /* Wait Indication 4    Wait Indication                 10.5.2.43       M V 1   */
7316         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_WAIT_IND);
7317         /* IAR Rest Octets                              10.5.2.19       M V 3 */
7318         if(tvb_length_remaining(tvb,curr_offset) > 0)
7319                 ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_IAR_REST_OCT);
7320
7321 }
7322
7323 /*
7324  * 9.1.21 Measurement report
7325  */
7326 static void
7327 dtap_rr_meas_rep(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
7328 {
7329         guint32 curr_offset;
7330         guint32 consumed;
7331         guint   curr_len;
7332
7333         curr_offset = offset;
7334         curr_len = len;
7335
7336         /* Measurement Results 10.5.2.20 M V 16 */
7337         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_MEAS_RES);
7338 }
7339
7340 /*
7341  * 9.1.7 Paging Request Type 1
7342  */
7343 static void
7344 dtap_rr_paging_req_type_1(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
7345 {
7346         guint32 curr_offset;
7347         guint32 consumed;
7348         guint   curr_len;
7349
7350         curr_offset = offset;
7351         curr_len = len;
7352         lower_nibble = FALSE;
7353
7354         /* RR Page Mode 10.5.2.26 M V 1/2 */
7355         ELEM_MAND_V_SHORT(GSM_A_PDU_TYPE_RR, DE_RR_PAGE_MODE);
7356
7357         /* RR Channel Needed 10.5.2.8 M V 1/2 */
7358         ELEM_MAND_V_SHORT(GSM_A_PDU_TYPE_RR, DE_RR_CHNL_NEEDED);
7359
7360         /* RR Mobile Identity 10.5.1.4 M LV 2-9 */
7361         ELEM_MAND_LV(GSM_A_PDU_TYPE_COMMON, DE_MID, " - Mobile Identity 1");
7362
7363         /* RR Mobile Identity 10.5.1.4 O TLV 3-10 */
7364         ELEM_OPT_TLV(0x17, GSM_A_PDU_TYPE_COMMON, DE_MID, " - Mobile Identity 2");
7365
7366         /* RR P1 Rest Octets 10.5.2.23 M V 0-17 */
7367         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_P1_REST_OCT);
7368
7369 }
7370
7371 /*
7372  * 9.1.8 Paging Request Type 2
7373  */
7374 static void
7375 dtap_rr_paging_req_type_2(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
7376 {
7377         guint32 curr_offset;
7378         guint32 consumed;
7379         guint   curr_len;
7380
7381         curr_offset = offset;
7382         curr_len = len;
7383         lower_nibble = FALSE;
7384
7385         /* RR Page Mode 10.5.2.26 M V 1/2 */
7386         ELEM_MAND_V_SHORT(GSM_A_PDU_TYPE_RR, DE_RR_PAGE_MODE);
7387
7388         /* RR Channel Needed 10.5.2.8 M V 1/2 */
7389         ELEM_MAND_V_SHORT(GSM_A_PDU_TYPE_RR, DE_RR_CHNL_NEEDED);
7390
7391         /* RR TMSI/P-TMSI 10.5.2.42 M V 4 */
7392         proto_tree_add_text(tree, tvb, curr_offset, 4, "Mobile Identity 1");
7393         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_TMSI_PTMSI);
7394
7395         /* RR TMSI/P-TMSI 10.5.2.42 M V 4 */
7396         proto_tree_add_text(tree, tvb, curr_offset, 4, "Mobile Identity 2");
7397         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_TMSI_PTMSI);
7398
7399         /* RR Mobile Identity 10.5.1.4 O TLV 3-10 */
7400         ELEM_OPT_TLV(0x17, GSM_A_PDU_TYPE_COMMON, DE_MID, " - Mobile Identity 3");
7401
7402         /* RR P2 Rest Octets 10.5.2.24 M V 1-11 */
7403         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_P2_REST_OCT);
7404
7405 }
7406
7407 /*
7408  * 9.1.9 Paging Request Type 3
7409  */
7410 static void
7411 dtap_rr_paging_req_type_3(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
7412 {
7413         guint32 curr_offset;
7414         guint32 consumed;
7415         guint   curr_len;
7416
7417         curr_offset = offset;
7418         curr_len = len;
7419         lower_nibble = FALSE;
7420
7421         /* RR Page Mode 10.5.2.26 M V 1/2 */
7422         ELEM_MAND_V_SHORT(GSM_A_PDU_TYPE_RR, DE_RR_PAGE_MODE);
7423
7424         /* RR Channel Needed 10.5.2.8 M V 1/2 */
7425         ELEM_MAND_V_SHORT(GSM_A_PDU_TYPE_RR, DE_RR_CHNL_NEEDED);
7426
7427         /* RR TMSI/P-TMSI 10.5.2.42 M V 4 */
7428         proto_tree_add_text(tree, tvb, curr_offset, 4, "Mobile Identity 1");
7429         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_TMSI_PTMSI);
7430
7431         /* RR TMSI/P-TMSI 10.5.2.42 M V 4 */
7432         proto_tree_add_text(tree, tvb, curr_offset, 4, "Mobile Identity 2");
7433         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_TMSI_PTMSI);
7434
7435         /* RR TMSI/P-TMSI 10.5.2.42 M V 4 */
7436         proto_tree_add_text(tree, tvb, curr_offset, 4, "Mobile Identity 3");
7437         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_TMSI_PTMSI);
7438
7439         /* RR TMSI/P-TMSI 10.5.2.42 M V 4 */
7440         proto_tree_add_text(tree, tvb, curr_offset, 4, "Mobile Identity 4");
7441         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_TMSI_PTMSI);
7442
7443         /* RR P3 Rest Octets 10.5.2.25 M V 3 */
7444         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_P3_REST_OCT);
7445
7446 }
7447
7448 /*
7449  * [4] 9.1.25 Paging response
7450  */
7451 static void
7452 dtap_rr_paging_resp(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
7453 {
7454         guint32 curr_offset;
7455         guint32 consumed;
7456         guint   curr_len;
7457         guint8  oct;
7458         proto_tree      *subtree;
7459         proto_item      *item;
7460
7461         curr_offset = offset;
7462         curr_len = len;
7463
7464         /*
7465          * special dissection for Cipher Key Sequence Number
7466          */
7467         oct = tvb_get_guint8(tvb, curr_offset);
7468
7469         other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
7470         proto_tree_add_text(tree,
7471         tvb, curr_offset, 1,
7472         "%s :  Spare",
7473         a_bigbuf);
7474
7475         item =
7476         proto_tree_add_text(tree,
7477                 tvb, curr_offset, 1, "%s",
7478                 gsm_common_elem_strings[DE_CIPH_KEY_SEQ_NUM].strptr);
7479
7480         subtree = proto_item_add_subtree(item, ett_gsm_common_elem[DE_CIPH_KEY_SEQ_NUM]);
7481
7482         other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
7483         proto_tree_add_text(subtree,
7484                 tvb, curr_offset, 1,
7485                 "%s :  Spare",
7486                 a_bigbuf);
7487
7488         other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
7489
7490         switch (oct & 0x07)
7491         {
7492         case 0x07:
7493                 proto_tree_add_text(subtree,
7494                         tvb, curr_offset, 1,
7495                         "%s :  Ciphering Key Sequence Number: No key is available",
7496                         a_bigbuf);
7497                 break;
7498
7499         default:
7500                 proto_tree_add_text(subtree,
7501                         tvb, curr_offset, 1,
7502                         "%s :  Ciphering Key Sequence Number: %u",
7503                         a_bigbuf,
7504                         oct & 0x07);
7505                 break;
7506         }
7507
7508         curr_offset++;
7509         curr_len--;
7510
7511         if (curr_len <= 0) return;
7512
7513         ELEM_MAND_LV(GSM_A_PDU_TYPE_COMMON, DE_MS_CM_2, "");
7514
7515         ELEM_MAND_LV(GSM_A_PDU_TYPE_COMMON, DE_MID, "");
7516
7517         EXTRANEOUS_DATA_CHECK(curr_len, 0);
7518 }
7519
7520 /*
7521  * [4] 9.1.26 Partial Release
7522  */
7523 static void
7524 dtap_rr_partial_rel(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
7525 {
7526    guint32 curr_offset;
7527    guint32 consumed;
7528    guint curr_len;
7529
7530    curr_offset = offset;
7531    curr_len = len;
7532
7533    /* Channel Description  10.5.2.5  M V 3 */
7534    ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_CH_DSC);
7535
7536    EXTRANEOUS_DATA_CHECK(curr_len, 0);
7537 }
7538
7539 /*
7540  * [4] 9.1.27 Partial Release Complete
7541  */
7542 /* empty message */
7543
7544 /*
7545  * [4] 9.1.29 Physical Information
7546  */
7547 static void
7548 dtap_rr_phy_info(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
7549 {
7550         guint32 curr_offset;
7551         guint32 consumed;
7552         guint   curr_len;
7553
7554         curr_offset = offset;
7555         curr_len = len;
7556
7557         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_TIMING_ADV);
7558
7559         EXTRANEOUS_DATA_CHECK(curr_len, 0);
7560 }
7561
7562 /*
7563  * [4] 9.1.29
7564  */
7565 static void
7566 dtap_rr_rr_status(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
7567 {
7568         guint32 curr_offset;
7569         guint32 consumed;
7570         guint   curr_len;
7571
7572         curr_offset = offset;
7573         curr_len = len;
7574
7575         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_CAUSE);
7576
7577         EXTRANEOUS_DATA_CHECK(curr_len, 0);
7578 }
7579
7580 /*
7581  * [4] 9.1.31
7582  */
7583 static void
7584 dtap_rr_sys_info_1(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
7585 {
7586         guint32 curr_offset;
7587         guint32 consumed;
7588         guint   curr_len;
7589
7590         curr_offset = offset;
7591         curr_len = len;
7592
7593         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_CELL_CH_DSC);
7594
7595         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_RACH_CTRL_PARAM);
7596
7597         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_SI1_REST_OCT);
7598 }
7599
7600 /*
7601  * [4] 9.1.32
7602  */
7603 static void
7604 dtap_rr_sys_info_2(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
7605 {
7606         guint32 curr_offset;
7607         guint32 consumed;
7608         guint   curr_len;
7609
7610         curr_offset = offset;
7611         curr_len = len;
7612
7613    proto_tree_add_text(tree, tvb, curr_offset, 16, "BCCH Frequency List");
7614         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_NEIGH_CELL_DESC);
7615
7616         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_NCC_PERM);
7617
7618         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_RACH_CTRL_PARAM);
7619 }
7620
7621 /*
7622  * [4] 9.1.33
7623  */
7624 static void
7625 dtap_rr_sys_info_2bis(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
7626 {
7627         guint32 curr_offset;
7628         guint32 consumed;
7629         guint   curr_len;
7630
7631         curr_offset = offset;
7632         curr_len = len;
7633
7634    proto_tree_add_text(tree, tvb, curr_offset, 16, "Extended BCCH Frequency List");
7635         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_NEIGH_CELL_DESC);
7636
7637         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_RACH_CTRL_PARAM);
7638 }
7639
7640 /*
7641  * [4] 9.1.34
7642  */
7643 static void
7644 dtap_rr_sys_info_2ter(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
7645 {
7646         guint32 curr_offset;
7647         guint32 consumed;
7648         guint   curr_len;
7649
7650         curr_offset = offset;
7651         curr_len = len;
7652
7653    proto_tree_add_text(tree, tvb, curr_offset, 16, "Extended BCCH Frequency List");
7654         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_NEIGH_CELL_DESC2);
7655
7656         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_SI2TER_REST_OCT);
7657 }
7658
7659 /*
7660  * [4] 9.1.34a
7661  */
7662 static void
7663 dtap_rr_sys_info_2quater(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
7664 {
7665         guint32 curr_offset;
7666         guint32 consumed;
7667         guint   curr_len;
7668
7669         curr_offset = offset;
7670         curr_len = len;
7671
7672         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_SI2QUATER_REST_OCT);
7673 }
7674
7675 /*
7676  * [4] 9.1.35
7677  */
7678 static void
7679 dtap_rr_sys_info_3(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
7680 {
7681         guint32 curr_offset;
7682         guint32 consumed;
7683         guint   curr_len;
7684
7685         curr_offset = offset;
7686         curr_len = len;
7687
7688         ELEM_MAND_V(GSM_A_PDU_TYPE_COMMON, DE_CELL_ID);
7689
7690         ELEM_MAND_V(GSM_A_PDU_TYPE_COMMON, DE_LAI);
7691
7692         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_CTRL_CH_DESC);
7693
7694         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_CELL_OPT_BCCH);
7695
7696         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_CELL_SEL_PARAM);
7697
7698         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_RACH_CTRL_PARAM);
7699
7700         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_SI3_REST_OCT);
7701 }
7702
7703 /*
7704  * [4] 9.1.36
7705  */
7706 static void
7707 dtap_rr_sys_info_4(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
7708 {
7709         guint32 curr_offset;
7710         guint32 consumed;
7711         guint   curr_len;
7712
7713         curr_offset = offset;
7714         curr_len = len;
7715
7716         ELEM_MAND_V(GSM_A_PDU_TYPE_COMMON, DE_LAI);
7717
7718         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_CELL_SEL_PARAM);
7719
7720         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_RACH_CTRL_PARAM);
7721
7722         ELEM_OPT_TV(0x64, GSM_A_PDU_TYPE_RR, DE_RR_CH_DSC, "CBCH Channel Description");
7723
7724         ELEM_OPT_TV(0x72, GSM_A_PDU_TYPE_RR, DE_RR_MOB_ALL, "CBCH Mobile Allocation");
7725
7726         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_SI4_REST_OCT);
7727 }
7728
7729 /*
7730  * [4] 9.1.37
7731  */
7732 static void
7733 dtap_rr_sys_info_5(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
7734 {
7735         guint32 curr_offset;
7736         guint32 consumed;
7737         guint   curr_len;
7738
7739         curr_offset = offset;
7740         curr_len = len;
7741
7742    proto_tree_add_text(tree, tvb, curr_offset, 16, "BCCH Frequency List");
7743         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_NEIGH_CELL_DESC);
7744 }
7745
7746 /*
7747  * [4] 9.1.38
7748  */
7749 static void
7750 dtap_rr_sys_info_5bis(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
7751 {
7752         guint32 curr_offset;
7753         guint32 consumed;
7754         guint   curr_len;
7755
7756         curr_offset = offset;
7757         curr_len = len;
7758
7759    proto_tree_add_text(tree, tvb, curr_offset, 16, "Extended BCCH Frequency List");
7760         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_NEIGH_CELL_DESC);
7761 }
7762
7763 /*
7764  * [4] 9.1.39
7765  */
7766 static void
7767 dtap_rr_sys_info_5ter(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
7768 {
7769         guint32 curr_offset;
7770         guint32 consumed;
7771         guint   curr_len;
7772
7773         curr_offset = offset;
7774         curr_len = len;
7775
7776    proto_tree_add_text(tree, tvb, curr_offset, 16, "Extended BCCH Frequency List");
7777         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_NEIGH_CELL_DESC2);
7778 }
7779
7780 /*
7781  * [4] 9.1.40
7782  */
7783 static void
7784 dtap_rr_sys_info_6(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
7785 {
7786         guint32 curr_offset;
7787         guint32 consumed;
7788         guint   curr_len;
7789
7790         curr_offset = offset;
7791         curr_len = len;
7792
7793         ELEM_MAND_V(GSM_A_PDU_TYPE_COMMON, DE_CELL_ID);
7794
7795         ELEM_MAND_V(GSM_A_PDU_TYPE_COMMON, DE_LAI);
7796
7797         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_CELL_OPT_SACCH);
7798
7799         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_NCC_PERM);
7800
7801         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_SI6_REST_OCT);
7802 }
7803
7804 /*
7805  * [4] 9.1.43a
7806  */
7807 static void
7808 dtap_rr_sys_info_13(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
7809 {
7810         guint32 curr_offset;
7811         guint32 consumed;
7812         guint   curr_len;
7813
7814         curr_offset = offset;
7815         curr_len = len;
7816
7817         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_SI13_REST_OCT);
7818 }
7819
7820 /*
7821  * [4] 9.1.51 Extended Measurement Order
7822  */
7823 static void
7824 dtap_rr_ext_meas_order(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
7825 {
7826    guint32 curr_offset;
7827    guint32 consumed;
7828    guint curr_len;
7829
7830    curr_offset = offset;
7831    curr_len = len;
7832
7833    /* Extended Measurement Frequency List  10.5.2.46  M V 16 */
7834    ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_EXT_MEAS_FREQ_LIST);
7835 }
7836
7837 /*
7838  * [4] 9.1.52 Extended Measurement Report
7839  */
7840 static void
7841 dtap_rr_ext_meas_report(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
7842 {
7843    guint32 curr_offset;
7844    guint32 consumed;
7845    guint curr_len;
7846
7847    curr_offset = offset;
7848    curr_len = len;
7849
7850    /* Extended Measurement Result  10.5.2.45  M V 16 */
7851    ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_EXT_MEAS_RESULT);
7852 }
7853
7854 /*
7855  * [4] 9.1.54 Measurement Information
7856  */
7857 static const value_string gsm_a_rr_3g_wait_vals[] = {
7858    { 0, "1 instance that contain 3G Neighbour Cell Description shall be received"},
7859    { 1, "2 instances that contain 3G Neighbour Cell Description shall be received"},
7860    { 2, "3 instances that contain 3G Neighbour Cell Description shall be received"},
7861    { 3, "4 instances that contain 3G Neighbour Cell Description shall be received"},
7862    { 4, "5 instances that contain 3G Neighbour Cell Description shall be received"},
7863    { 5, "6 instances that contain 3G Neighbour Cell Description shall be received"},
7864    { 6, "7 instances that contain 3G Neighbour Cell Description shall be received"},
7865    { 7, "8 instances that contain 3G Neighbour Cell Description shall be received"},
7866    { 0, NULL }
7867 };
7868
7869
7870 static void
7871 sacch_rr_meas_info(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_)
7872 {
7873    proto_tree *subtree, *subtree2;
7874    proto_item *item, *item2;
7875    guint32 curr_offset;
7876    gint bit_offset, bit_offset_sav, bit_offset_sav2;
7877    guint8 value, idx;
7878
7879    curr_offset = offset;
7880    bit_offset = curr_offset << 3;
7881
7882    proto_tree_add_bits_item(tree, hf_gsm_a_rr_ba_ind, tvb, bit_offset, 1, FALSE);
7883    bit_offset += 1;
7884    proto_tree_add_bits_item(tree, hf_gsm_a_rr_3g_ba_ind, tvb, bit_offset, 1, FALSE);
7885    bit_offset += 1;
7886    proto_tree_add_bits_item(tree, hf_gsm_a_rr_mp_change_mark, tvb, bit_offset, 1, FALSE);
7887    bit_offset += 1;
7888    proto_tree_add_bits_item(tree, hf_gsm_a_rr_mi_index, tvb, bit_offset, 4, FALSE);
7889    bit_offset += 4;
7890    proto_tree_add_bits_item(tree, hf_gsm_a_rr_mi_count, tvb, bit_offset, 4, FALSE);
7891    bit_offset += 4;
7892    proto_tree_add_bits_item(tree, hf_gsm_a_rr_pwrc, tvb, bit_offset, 1, FALSE);
7893    bit_offset += 1;
7894    proto_tree_add_bits_item(tree, hf_gsm_a_rr_gsm_report_type, tvb, bit_offset, 1, FALSE);
7895    bit_offset += 1;
7896    proto_tree_add_bits_item(tree, hf_gsm_a_rr_reporting_rate, tvb, bit_offset, 1, FALSE);
7897    bit_offset +=1;
7898    proto_tree_add_bits_item(tree, hf_gsm_a_rr_invalid_bsic_reporting, tvb, bit_offset, 1, FALSE);
7899    bit_offset +=1;
7900    value = tvb_get_bits8(tvb,bit_offset,1);
7901    bit_offset += 1;
7902    if (value)
7903    { /* Real Time Difference Description */
7904       bit_offset += de_rr_rtd_desc(tvb, tree, bit_offset, DE_RR_REST_OCTETS_RTD_DESC);
7905    }
7906    value = tvb_get_bits8(tvb,bit_offset,1);
7907    bit_offset += 1;
7908    if (value)
7909    { /* BSIC Description */
7910       bit_offset += de_rr_bsic_desc(tvb, tree, bit_offset, DE_RR_REST_OCTETS_BSIC_DESC);
7911    }
7912    value = tvb_get_bits8(tvb,bit_offset,1);
7913    bit_offset += 1;
7914    if (value)
7915    { /* Report Priority Description */
7916       bit_offset += de_rr_report_priority_desc(tvb, tree, bit_offset, DE_RR_REST_OCTETS_REPORT_PRIO_DESC);
7917    }
7918    value = tvb_get_bits8(tvb,bit_offset,1);
7919    bit_offset += 1;
7920    if (value)
7921    { /* Measurement Parameters Description */
7922       bit_offset += de_rr_meas_param_desc(tvb, tree, bit_offset, DE_RR_REST_OCTETS_MEAS_PARAM_DESC);
7923    }
7924    value = tvb_get_bits8(tvb,bit_offset,1);
7925    bit_offset += 1;
7926    if (value)
7927    {  /* used for future extensions of the 2G parameters */
7928       value = tvb_get_bits8(tvb,bit_offset,8);
7929       bit_offset += 8 + value + 1;
7930    }
7931    value = tvb_get_bits8(tvb,bit_offset,1);
7932    bit_offset += 1;
7933    if (value)
7934    { /* 3G Neighbour Cell Description */
7935       bit_offset_sav = bit_offset;
7936       item = proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_3G_NEIGH_CELL_DESC].strptr);
7937       subtree = proto_item_add_subtree(item, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_3G_NEIGH_CELL_DESC]);
7938       value = tvb_get_bits8(tvb,bit_offset,1);
7939       bit_offset += 1;
7940       if (value)
7941       {
7942          proto_tree_add_bits_item(subtree, hf_gsm_a_rr_3g_wait, tvb, bit_offset, 3, FALSE);
7943          bit_offset += 3;
7944       }
7945       value = tvb_get_bits8(tvb,bit_offset,1);
7946       bit_offset += 1;
7947       if (value)
7948       {
7949          proto_tree_add_bits_item(subtree, hf_gsm_a_rr_index_start_3g, tvb, bit_offset, 7, FALSE);
7950          bit_offset += 7;
7951       }
7952       value = tvb_get_bits8(tvb,bit_offset,1);
7953       bit_offset += 1;
7954       if (value)
7955       {
7956          proto_tree_add_bits_item(subtree, hf_gsm_a_rr_absolute_index_start_emr, tvb, bit_offset, 7, FALSE);
7957          bit_offset += 7;
7958       }
7959       value = tvb_get_bits8(tvb,bit_offset,1);
7960       bit_offset += 1;
7961       if (value)
7962       { /* UTRAN FDD Description */
7963          bit_offset += de_rr_si2quater_meas_info_utran_fdd_desc(tvb, subtree, bit_offset);
7964       }
7965       value = tvb_get_bits8(tvb,bit_offset,1);
7966       bit_offset += 1;
7967       if (value)
7968       { /* UTRAN TDD Description */
7969          bit_offset += de_rr_si2quater_meas_info_utran_tdd_desc(tvb, subtree, bit_offset);
7970       }
7971       value = tvb_get_bits8(tvb,bit_offset,1);
7972       bit_offset += 1;
7973       if (value)
7974       { /* CDMA2000 Description */
7975          bit_offset_sav2 = bit_offset;
7976          item2 = proto_tree_add_text(subtree, tvb, bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_CDMA2000_DESC].strptr);
7977          subtree2 = proto_item_add_subtree(item2, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_CDMA2000_DESC]);
7978          bit_offset += 16; /* cdma2000 frequency band + cdma2000 frequency */
7979          idx = tvb_get_bits8(tvb,bit_offset,5); /* number_cdma2000_cells */
7980          bit_offset += 5;
7981          while (idx)
7982          {
7983             bit_offset += 9; /* Pilot PN offset */
7984             if (tvb_get_bits8(tvb,bit_offset,1))
7985             {
7986                bit_offset += 1;
7987                value = tvb_get_bits8(tvb,bit_offset,3);
7988                switch (value)
7989                {
7990                   case 0:
7991                      bit_offset += 5; /* TD_MODE + TD_POWER_LEVEL */
7992                      break;
7993                   case 1:
7994                      bit_offset += 2; /* QOF */
7995                      bit_offset += tvb_get_bits8(tvb,bit_offset,3) + 3 + 6; /* WALSH_LEN_A + bit(val(WALSH_LEN_A)+6) */
7996                      break;
7997                   case 2:
7998                      bit_offset += 2; /* QOF */
7999                      bit_offset += tvb_get_bits8(tvb,bit_offset,3) + 3 + 6; /* WALSH_LEN_B + bit(val(WALSH_LEN_B)+6) */
8000                      bit_offset += 4; /* AUX_TD_POWER_LEVEL + TD_MODE */
8001                      break;
8002                   case 3:
8003                      bit_offset += 8; /* SR3_PRIM_PILOT + SR3_PILOT_POWER1 + SR3_PILOT_POWER2 */
8004                      break;
8005                   case 6:
8006                      bit_offset += 10; /* SR3_PRIM_PILOT + SR3_PILOT_POWER1 + SR3_PILOT_POWER2 + QOF */
8007                      bit_offset += tvb_get_bits8(tvb,bit_offset,3) + 3 + 6; /* WALSH_LEN_C + bit(val(WALSH_LEN_C)+6) */
8008                      if (tvb_get_bits8(tvb,bit_offset,1))
8009                      {
8010                         bit_offset += 3; /* 1 + QOF1 */
8011                         bit_offset += tvb_get_bits8(tvb,bit_offset,3) + 3 + 6; /* WALSH_LENGTH1 + bit(val(WALSH_LENGTH1)+6) */
8012                      }
8013                      else
8014                         bit_offset += 1;
8015                      if (tvb_get_bits8(tvb,bit_offset,1))
8016                      {
8017                         bit_offset += 3; /* 1 + QOF2 */
8018                         bit_offset += tvb_get_bits8(tvb,bit_offset,3) + 3 + 6; /* WALSH_LENGTH2 + bit(val(WALSH_LENGTH2)+6) */
8019                      }
8020                      else
8021                         bit_offset += 1;
8022                      break;
8023                   default:
8024                      /* decoding sequence is unknown ! */
8025                      return;
8026                }
8027             }
8028             else
8029                bit_offset += 1;
8030             idx -= 1;
8031          }
8032          proto_tree_add_text(subtree2,tvb, bit_offset_sav2>>3, ((bit_offset-bit_offset_sav2)>>3)+1,"Data(Not decoded)");
8033          proto_item_set_len(item2,((bit_offset-bit_offset_sav2)>>3)+1);
8034       }
8035       proto_item_set_len(item,((bit_offset-bit_offset_sav)>>3)+1);
8036    }
8037    value = tvb_get_bits8(tvb,bit_offset,1);
8038    bit_offset += 1;
8039    if (value)
8040    { /* 3G Measurement Parameters Description */
8041       bit_offset_sav = bit_offset;
8042       item = proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_3G_MEAS_PARAM_DESC].strptr);
8043       subtree = proto_item_add_subtree(item, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_3G_MEAS_PARAM_DESC]);
8044       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_qsearch_c, tvb, bit_offset, 4, FALSE);
8045       bit_offset += 4;
8046       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_3g_search_prio, tvb, bit_offset, 1, FALSE);
8047       bit_offset += 1;
8048       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_fdd_rep_quant, tvb, bit_offset, 1, FALSE);
8049       bit_offset += 1;
8050       value = tvb_get_bits8(tvb,bit_offset,1);
8051       bit_offset += 1;
8052       if (value)
8053       {
8054          proto_tree_add_bits_item(subtree, hf_gsm_a_rr_fdd_multirat_reporting, tvb, bit_offset, 2, FALSE);
8055          bit_offset += 2;
8056       }
8057       value = tvb_get_bits8(tvb,bit_offset,1);
8058       bit_offset += 1;
8059       if (value)
8060       {
8061          proto_tree_add_bits_item(subtree, hf_gsm_a_rr_fdd_reporting_offset, tvb, bit_offset, 3, FALSE);
8062          bit_offset += 3;
8063          proto_tree_add_bits_item(subtree, hf_gsm_a_rr_fdd_reporting_threshold, tvb, bit_offset, 3, FALSE);
8064          bit_offset += 3;
8065       }
8066       value = tvb_get_bits8(tvb,bit_offset,1);
8067       bit_offset += 1;
8068       if (value)
8069       {
8070          proto_tree_add_bits_item(subtree, hf_gsm_a_rr_tdd_multirat_reporting, tvb, bit_offset, 2, FALSE);
8071          bit_offset += 2;
8072       }
8073       value = tvb_get_bits8(tvb,bit_offset,1);
8074       bit_offset += 1;
8075       if (value)
8076       {
8077          proto_tree_add_bits_item(subtree, hf_gsm_a_rr_tdd_reporting_offset, tvb, bit_offset, 3, FALSE);
8078          bit_offset += 3;
8079          proto_tree_add_bits_item(subtree, hf_gsm_a_rr_tdd_reporting_threshold, tvb, bit_offset, 3, FALSE);
8080          bit_offset += 3;
8081       }
8082       value = tvb_get_bits8(tvb,bit_offset,1);
8083       bit_offset += 1;
8084       if (value)
8085          bit_offset += 2; /* CDMA2000 Multirat Reporting */
8086       value = tvb_get_bits8(tvb,bit_offset,1);
8087       bit_offset += 1;
8088       if (value)
8089          bit_offset += 6; /* CDMA2000 Reporting Offset + CDMA2000 Reporting Threshold */
8090       proto_item_set_len(item,((bit_offset-bit_offset_sav)>>3)+1);
8091    }
8092    if (((curr_offset + len)<<3) - bit_offset > 0)
8093    {
8094       /* There is still room left in the Rest Octets IE */
8095       if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
8096       { /* Additions in Rel-5 */
8097          bit_offset += 1;
8098          value = tvb_get_bits8(tvb,bit_offset,1);
8099          bit_offset += 1;
8100          if (value)
8101          { /* 3G Additional Measurement Parameters Description 2 */
8102             bit_offset += de_rr_3g_add_meas_param_desc2(tvb, tree, bit_offset);
8103          }
8104          if (((curr_offset + len)<<3) - bit_offset > 0)
8105          {
8106             /* There is still room left in the Rest Octets IE */
8107             if (gsm_a_rr_is_bit_high(tvb,bit_offset) == TRUE)
8108             { /* Additions in Rel-7 */
8109                bit_offset += 1;
8110                value = tvb_get_bits8(tvb,bit_offset,1);
8111                bit_offset += 1;
8112                if (value)
8113                {
8114                   proto_tree_add_bits_item(tree, hf_gsm_a_rr_700_reporting_offset, tvb, bit_offset, 3, FALSE);
8115                   bit_offset += 3;
8116                   proto_tree_add_bits_item(tree, hf_gsm_a_rr_700_reporting_threshold, tvb, bit_offset, 3, FALSE);
8117                   bit_offset += 3;
8118                }
8119                value = tvb_get_bits8(tvb,bit_offset,1);
8120                bit_offset += 1;
8121                if (value)
8122                {
8123                   proto_tree_add_bits_item(tree, hf_gsm_a_rr_810_reporting_offset, tvb, bit_offset, 3, FALSE);
8124                   bit_offset += 3;
8125                   proto_tree_add_bits_item(tree, hf_gsm_a_rr_810_reporting_threshold, tvb, bit_offset, 3, FALSE);
8126                   bit_offset += 3;
8127                }
8128             }
8129             else
8130                bit_offset += 1;
8131          }
8132       }
8133       else
8134          bit_offset += 1;
8135    }
8136 }
8137
8138 /*
8139  * [4] 9.1.55 Enhanced Measurement Information
8140  */
8141 static const true_false_string gsm_a_rr_bsic_seen_value = {
8142    "One Cell or more with invalid BSIC and allowed NCC part of BSIC is seen",
8143    "No cell with invalid BSIC and allowed NCC part of BSIC is seen"
8144 };
8145
8146 static const true_false_string gsm_a_rr_scale_value = {
8147    "+10 dB",
8148    "0 dB"
8149 };
8150
8151 static const value_string gsm_a_rr_mean_bep_gmsk_vals[] = {
8152         { 0,    "log10(BEP) > -0.60"},
8153         { 1,    "-0.70 < log10(BEP) < -0.60"},
8154         { 2,    "-0.80 < log10(BEP) < -0.70"},
8155         { 3,    "-0.90 < log10(BEP) < -0.80"},
8156         { 4,    "-1.00 < log10(BEP) < -0.90"},
8157         { 5,    "-1.10 < log10(BEP) < -1.00"},
8158         { 6,    "-1.20 < log10(BEP) < -1.10"},
8159         { 7,    "-1.30 < log10(BEP) < -1.20"},
8160         { 8,    "-1.40 < log10(BEP) < -1.30"},
8161         { 9,    "-1.50 < log10(BEP) < -1.40"},
8162         { 10,   "-1.60 < log10(BEP) < -1.50"},
8163         { 11,   "-1.70 < log10(BEP) < -1.60"},
8164         { 12,   "-1.80 < log10(BEP) < -1.70"},
8165         { 13,   "-1.90 < log10(BEP) < -1.80"},
8166         { 14,   "-2.00 < log10(BEP) < -1.90"},
8167         { 15,   "-2.10 < log10(BEP) < -2.00"},
8168         { 16,   "-2.20 < log10(BEP) < -2.10"},
8169         { 17,   "-2.30 < log10(BEP) < -2.20"},
8170         { 18,   "-2.40 < log10(BEP) < -2.30"},
8171         { 19,   "-2.50 < log10(BEP) < -2.40"},
8172         { 20,   "-2.60 < log10(BEP) < -2.50"},
8173         { 21,   "-2.70 < log10(BEP) < -2.60"},
8174         { 22,   "-2.80 < log10(BEP) < -2.70"},
8175         { 23,   "-2.90 < log10(BEP) < -2.80"},
8176         { 24,   "-3.00 < log10(BEP) < -2.90"},
8177         { 25,   "-3.10 < log10(BEP) < -3.00"},
8178         { 26,   "-3.20 < log10(BEP) < -3.10"},
8179         { 27,   "-3.30 < log10(BEP) < -3.20"},
8180         { 28,   "-3.40 < log10(BEP) < -3.30"},
8181         { 29,   "-3.50 < log10(BEP) < -3.40"},
8182         { 30,   "-3.60 < log10(BEP) < -3.50"},
8183         { 31,   "log10(BEP) < -3.60"},
8184         { 0,    NULL }
8185 };
8186
8187 static const value_string gsm_a_rr_cv_bep_vals[] = {
8188         { 0,    "1.75 < CV BEP < 2.00"},
8189         { 1,    "1.50 < CV BEP < 1.75"},
8190         { 2,    "1.25 < CV BEP < 1.50"},
8191         { 3,    "1.00 < CV BEP < 1.25"},
8192         { 4,    "0.75 < CV BEP < 1.00"},
8193         { 5,    "0.50 < CV BEP < 0.75"},
8194         { 6,    "0.25 < CV BEP < 0.50"},
8195         { 7,    "0.00 < CV BEP < 0.25"},
8196         { 0,    NULL }
8197 };
8198
8199
8200 static void
8201 sacch_rr_enh_meas_report(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
8202 {
8203    proto_tree *subtree;
8204    proto_item *item;
8205    guint32 curr_offset;
8206    gint bit_offset, bit_offset_sav;
8207    guint8 value, idx;
8208
8209    curr_offset = offset;
8210    bit_offset = curr_offset << 3;
8211
8212    proto_tree_add_bits_item(tree, hf_gsm_a_rr_ba_used, tvb, bit_offset, 1, FALSE);
8213    bit_offset += 1;
8214    proto_tree_add_bits_item(tree, hf_gsm_a_rr_3g_ba_used, tvb, bit_offset, 1, FALSE);
8215    bit_offset += 1;
8216    proto_tree_add_bits_item(tree, hf_gsm_a_rr_bsic_seen, tvb, bit_offset, 1, FALSE);
8217    bit_offset += 1;
8218    proto_tree_add_bits_item(tree, hf_gsm_a_rr_scale, tvb, bit_offset, 1, FALSE);
8219    bit_offset += 1;
8220    value = tvb_get_bits8(tvb,bit_offset,1);
8221    bit_offset += 1;
8222    if (value)
8223    { /* Serving cell data */
8224       bit_offset_sav = bit_offset;
8225       item = proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_SERVING_CELL_DATA].strptr);
8226       subtree = proto_item_add_subtree(item, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_SERVING_CELL_DATA]);
8227       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_dtx_used, tvb, bit_offset, 1, FALSE);
8228       bit_offset += 1;
8229       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_rxlev_full_serv_cell, tvb, bit_offset, 6, FALSE);
8230       bit_offset += 6;
8231       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_rxqual_full_serv_cell, tvb, bit_offset, 3, FALSE);
8232       bit_offset += 3;
8233       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_mean_bep_gmsk, tvb, bit_offset, 5, FALSE);
8234       bit_offset += 5;
8235       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_mean_cv_bep, tvb, bit_offset, 3, FALSE);
8236       bit_offset += 3;
8237       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_nbr_rcvd_blocks, tvb, bit_offset, 5, FALSE);
8238       bit_offset += 5;
8239       proto_item_set_len(item,((bit_offset-bit_offset_sav)>>3)+1);
8240    }
8241    value = tvb_get_bits8(tvb,bit_offset,1);
8242    bit_offset += 1;
8243    while (value)
8244    { /* Repeated Invalid BSIC Information */
8245       bit_offset_sav = bit_offset;
8246       item = proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_REPEAT_INV_BSIC_INFO].strptr);
8247       subtree = proto_item_add_subtree(item, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_REPEAT_INV_BSIC_INFO]);
8248       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_bcch_freq_ncell, tvb, bit_offset, 5, FALSE);
8249       bit_offset += 5;
8250       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_bsic_ncell, tvb, bit_offset, 6, FALSE);
8251       bit_offset += 6;
8252       proto_tree_add_bits_item(subtree, hf_gsm_a_rr_rxlev_ncell, tvb, bit_offset, 6, FALSE);
8253       bit_offset += 6;
8254       proto_item_set_len(item,((bit_offset-bit_offset_sav)>>3)+1);
8255       value = tvb_get_bits8(tvb,bit_offset,1);
8256       bit_offset += 1;
8257    }
8258    value = tvb_get_bits8(tvb,bit_offset,1);
8259    bit_offset += 1;
8260    if (value)
8261    { /* Bitmap Type Reporting */
8262       bit_offset_sav = bit_offset;
8263       item = proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "%s", gsm_rr_rest_octets_elem_strings[DE_RR_REST_OCTETS_BITMAP_TYPE_REPORTING].strptr);
8264       subtree = proto_item_add_subtree(item, ett_gsm_rr_rest_octets_elem[DE_RR_REST_OCTETS_BITMAP_TYPE_REPORTING]);
8265       idx = 0;
8266       while (((guint)(bit_offset>>3) <= (offset + len)) && (idx < 96))
8267       {
8268          value  = tvb_get_bits8(tvb,bit_offset,1);
8269          bit_offset += 1;
8270          if (value)
8271          {
8272             proto_tree_add_text(subtree, tvb, bit_offset>>3, 1, "Neighbour Cell List index: %u", idx);
8273             proto_tree_add_bits_item(subtree, hf_gsm_a_rr_reporting_quantity, tvb, bit_offset, 6, FALSE);
8274             bit_offset += 6;
8275          }
8276          idx += 1;
8277       }
8278    }
8279 }
8280
8281 #define NUM_GSM_DTAP_MSG_RR (sizeof(gsm_a_dtap_msg_rr_strings)/sizeof(value_string))
8282 static gint ett_gsm_dtap_msg_rr[NUM_GSM_DTAP_MSG_RR];
8283 static void (*dtap_msg_rr_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len) = {
8284         NULL,   /* Reserved */
8285         dtap_rr_add_ass,        /* Additional Assignment */
8286         dtap_rr_imm_ass,        /* 9.1.18 Immediate assignment  */
8287         dtap_rr_imm_ass_ext,    /* Immediate Assignment Extended */
8288         dtap_rr_imm_ass_rej,    /* Immediate Assignment Reject */
8289
8290         NULL,   /* DTM Assignment Failure */
8291         NULL,   /* DTM Reject */
8292         NULL,   /* DTM Request */
8293         NULL,   /* Main DCCH Assignment Command */
8294         NULL,   /* Packet Assignment Command */
8295
8296         dtap_rr_cip_mode_cmd,   /* Ciphering Mode Command */
8297         dtap_rr_cip_mode_cpte,  /* Ciphering Mode Complete */
8298
8299         dtap_rr_conf_change_cmd,        /* Configuration Change Command */
8300         NULL,   /* Configuration Change Ack. */
8301         dtap_rr_conf_change_rej,        /* Configuration Change Reject */
8302
8303         dtap_rr_ass_cmd,        /* 9.1.2 Assignment Command */
8304         dtap_rr_ass_comp,       /* Assignment Complete */
8305         dtap_rr_ass_fail,       /* Assignment Failure */
8306         dtap_rr_ho_cmd, /* Handover Command */
8307         dtap_rr_ho_cpte,        /* Handover Complete */
8308         dtap_rr_ho_fail,        /* Handover Failure */
8309         dtap_rr_phy_info,       /* Physical Information */
8310         NULL,   /* DTM Assignment Command */
8311
8312         NULL,   /* RR-cell Change Order */
8313         NULL,   /* PDCH Assignment Command */
8314
8315         dtap_rr_ch_rel, /* Channel Release */
8316         dtap_rr_partial_rel,    /* Partial Release */
8317         NULL,   /* Partial Release Complete */
8318
8319         dtap_rr_paging_req_type_1,      /* Paging Request Type 1 */
8320         dtap_rr_paging_req_type_2,      /* Paging Request Type 2 */
8321         dtap_rr_paging_req_type_3,      /* Paging Request Type 3 */
8322         dtap_rr_paging_resp,    /* Paging Response */
8323         NULL,   /* Notification/NCH */
8324         NULL,   /* Reserved */
8325         NULL,   /* Notification/Response */
8326
8327         NULL,   /* Reserved */
8328
8329         dtap_rr_utran_classmark_change, /* Utran Classmark Change  */
8330         NULL,   /* cdma2000 Classmark Change */
8331         dtap_rr_inter_syst_to_utran_ho_cmd,     /* Inter System to UTRAN Handover Command */
8332         NULL,   /* Inter System to cdma2000 Handover Command */
8333
8334         NULL,   /* System Information Type 8 */
8335         dtap_rr_sys_info_1,     /* System Information Type 1 */
8336         dtap_rr_sys_info_2,     /* System Information Type 2 */
8337         dtap_rr_sys_info_3,     /* System Information Type 3 */
8338         dtap_rr_sys_info_4,     /* System Information Type 4 */
8339         dtap_rr_sys_info_5,     /* System Information Type 5 */
8340         dtap_rr_sys_info_6,     /* System Information Type 6 */
8341         NULL,   /* System Information Type 7 */
8342
8343         dtap_rr_sys_info_2bis,  /* System Information Type 2bis */
8344         dtap_rr_sys_info_2ter,  /* System Information Type 2ter */
8345         dtap_rr_sys_info_2quater,       /* System Information Type 2quater */
8346         dtap_rr_sys_info_5bis,  /* System Information Type 5bis */
8347         dtap_rr_sys_info_5ter,  /* System Information Type 5ter */
8348         NULL,   /* System Information Type 9 */
8349         dtap_rr_sys_info_13,    /* System Information Type 13 */
8350
8351         NULL,   /* System Information Type 16 */
8352         NULL,   /* System Information Type 17 */
8353
8354         NULL,   /* System Information Type 18 */
8355         NULL,   /* System Information Type 19 */
8356         NULL,   /* System Information Type 20 */
8357
8358         dtap_rr_ch_mode_mod,    /* Channel Mode Modify */
8359         dtap_rr_rr_status,      /* RR Status */
8360         dtap_rr_ch_mode_mod_ack,        /* Channel Mode Modify Acknowledge */
8361         dtap_rr_freq_redef,     /* Frequency Redefinition */
8362         dtap_rr_meas_rep,               /* 9.1.21 Measurement report */
8363         dtap_rr_mm_cm_change,   /* 9.1.11 Classmark Change */
8364         dtap_rr_cm_enq, /* Classmark Enquiry */
8365         dtap_rr_ext_meas_report,        /* Extended Measurement Report */
8366         dtap_rr_ext_meas_order,         /* Extended Measurement Order */
8367         dtap_rr_gprs_sus_req,   /* 9.1.13b GPRS Suspension Request */
8368
8369         NULL,   /* VGCS Uplink Grant */
8370         NULL,   /* Uplink Release */
8371         NULL,   /* Reserved */
8372         NULL,   /* Uplink Busy */
8373         NULL,   /* Talker Indication */
8374
8375         NULL,   /* UTRAN Classmark Change/Handover To UTRAN Command */  /* spec conflict */
8376
8377         NULL,   /* Application Information */
8378
8379         NULL,   /* NONE */
8380 };
8381
8382 void get_rr_msg_params(guint8 oct, const gchar **msg_str, int *ett_tree, int *hf_idx, msg_fcn *msg_fcn)
8383 {
8384         gint                    idx;
8385
8386         *msg_str = match_strval_idx((guint32) (oct & DTAP_RR_IEI_MASK), gsm_a_dtap_msg_rr_strings, &idx);
8387         *ett_tree = ett_gsm_dtap_msg_rr[idx];
8388         *hf_idx = hf_gsm_a_dtap_msg_rr_type;
8389         *msg_fcn = dtap_msg_rr_fcn[idx];
8390
8391         return;
8392 }
8393 /* This is more or less a copy of the dissect_dtap() code just adding
8394  * L2 Pseudo Length decoding first
8395  * The code should probably be cleaned up.
8396  * The name CCCH might not be correct!
8397  */
8398 static void
8399 dissect_ccch(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
8400 {
8401
8402         static gsm_a_tap_rec_t  tap_rec[4];
8403         static gsm_a_tap_rec_t  *tap_p;
8404         static guint                    tap_current=0;
8405
8406         void                    (*msg_fcn)(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len);
8407         guint8                  oct;
8408         guint8                  pd;
8409         guint32                 offset, saved_offset;
8410         guint32                 len;
8411         guint32                 oct_1, oct_2;
8412         proto_item              *ccch_item = NULL;
8413         proto_tree              *ccch_tree = NULL;
8414         proto_item              *oct_1_item = NULL;
8415         proto_tree              *pd_tree = NULL;
8416         proto_tree              *saved_tree = NULL;
8417         const gchar             *msg_str;
8418         gint                    ett_tree;
8419         gint                    ti;
8420         int                             hf_idx;
8421         gboolean                nsd;
8422         guint8                  pseudo_len;
8423         guint32                 curr_offset;
8424         guint32                 consumed;
8425         guint                   curr_len;
8426
8427         len = tvb_length(tvb);
8428
8429         if (len < 2){
8430                 /*
8431                  * too short to be CCCH
8432                  */
8433                 call_dissector(data_handle, tvb, pinfo, tree);
8434                 return;
8435         }
8436
8437         if (check_col(pinfo->cinfo, COL_INFO)){
8438                 col_append_str(pinfo->cinfo, COL_INFO, "(CCCH) ");
8439         }
8440         /*
8441          * set tap record pointer
8442          */
8443         tap_current++;
8444         if (tap_current >= 4)
8445         {
8446                 tap_current = 0;
8447         }
8448         tap_p = &tap_rec[tap_current];
8449
8450         offset = 0;
8451         oct_2 = 0;
8452
8453         /* Skip pseeudo hdr here */
8454         offset = 1;
8455
8456         /*
8457          * get protocol discriminator
8458          */
8459         oct_1 = tvb_get_guint8(tvb, offset++);
8460
8461         if ((((oct_1 & DTAP_TI_MASK) >> 4) & DTAP_TIE_PRES_MASK) == DTAP_TIE_PRES_MASK){
8462                 /*
8463                  * eventhough we don't know if a TI should be in the message yet
8464                  * we rely on the TI/SKIP indicator to be 0 to avoid taking this
8465                  * octet
8466                  */
8467                 oct_2 = tvb_get_guint8(tvb, offset++);
8468         }
8469
8470         oct = tvb_get_guint8(tvb, offset);
8471
8472         pd = oct_1 & DTAP_PD_MASK;
8473         ti = -1;
8474         msg_str = NULL;
8475         ett_tree = -1;
8476         hf_idx = -1;
8477         msg_fcn = NULL;
8478         nsd = FALSE;
8479         if (check_col(pinfo->cinfo, COL_INFO)){
8480                 col_append_fstr(pinfo->cinfo, COL_INFO, "(%s) ",val_to_str(pd,gsm_a_pd_short_str_vals,"Unknown (%u)"));
8481         }
8482
8483         /*
8484          * octet 1
8485          */
8486         switch (pd){
8487         case 6:
8488                 get_rr_msg_params(oct, &msg_str, &ett_tree, &hf_idx, &msg_fcn);
8489                 break;
8490
8491         default:
8492                 /* XXX - hf_idx is still -1! this is a bug in the implementation, and I don't know how to fix it so simple return here */
8493                 return;
8494         }
8495
8496         /*
8497          * create the protocol tree
8498          */
8499         if (msg_str == NULL){
8500                 ccch_item = proto_tree_add_protocol_format(tree, proto_a_ccch, tvb, 0, len,
8501                         "GSM CCCH - Message Type (0x%02x)",
8502                         oct);
8503
8504                 ccch_tree = proto_item_add_subtree(ccch_item, ett_ccch_msg);
8505         }else{
8506                 ccch_item = proto_tree_add_protocol_format(tree, proto_a_ccch, tvb, 0, -1,
8507                         "GSM CCCH - %s", msg_str);
8508
8509                 ccch_tree = proto_item_add_subtree(ccch_item, ett_tree);
8510         }
8511
8512         if (check_col(pinfo->cinfo, COL_INFO)){
8513                 col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", msg_str);
8514         }
8515
8516         /* back to the begining */
8517         saved_offset = offset;
8518         offset = 0;
8519
8520         curr_offset = offset;
8521         curr_len = len;
8522         len = 1;
8523
8524         /*      L2 Pseudo Length 10.5.2.19 */
8525         pseudo_len = tvb_get_guint8(tvb,offset)>>2;
8526
8527         saved_tree = tree;
8528         tree = ccch_tree;
8529         ELEM_MAND_V(GSM_A_PDU_TYPE_RR, DE_RR_L2_PSEUDO_LEN);
8530         tree = saved_tree;
8531         offset = saved_offset;
8532
8533         oct_1_item =
8534         proto_tree_add_text(ccch_tree,
8535                 tvb, 1, 1,
8536                 "Protocol Discriminator: %s",
8537                 val_to_str(pd, protocol_discriminator_vals, "Unknown (%u)"));
8538
8539         pd_tree = proto_item_add_subtree(oct_1_item, ett_ccch_oct_1);
8540
8541         if (ti == -1){
8542                 proto_tree_add_item(pd_tree, hf_gsm_a_skip_ind, tvb, 1, 1, FALSE);
8543         }else{
8544                 other_decode_bitfield_value(a_bigbuf, oct_1, 0x80, 8);
8545                 proto_tree_add_text(pd_tree,tvb, 1, 1,
8546                         "%s :  TI flag: %s",
8547                         a_bigbuf,
8548                         ((oct_1 & 0x80) ?  "allocated by receiver" : "allocated by sender"));
8549
8550                 if ((ti & DTAP_TIE_PRES_MASK) == DTAP_TIE_PRES_MASK){
8551                         /* ti is extended to next octet */
8552                         other_decode_bitfield_value(a_bigbuf, oct_1, 0x70, 8);
8553                         proto_tree_add_text(pd_tree, tvb, 1, 1,
8554                                 "%s :  TIO: The TI value is given by the TIE in octet 2",
8555                                 a_bigbuf);
8556                 }else{
8557                         other_decode_bitfield_value(a_bigbuf, oct_1, 0x70, 8);
8558                         proto_tree_add_text(pd_tree,tvb, 1, 1,
8559                                 "%s :  TIO: %u",a_bigbuf,ti & DTAP_TIE_PRES_MASK);
8560                 }
8561         }
8562
8563         proto_tree_add_item(pd_tree, hf_gsm_a_L3_protocol_discriminator, tvb, 1, 1, FALSE);
8564
8565         if ((ti != -1) && (ti & DTAP_TIE_PRES_MASK) == DTAP_TIE_PRES_MASK){
8566                 proto_tree_add_item(tree, hf_gsm_a_extension, tvb, 2, 1, FALSE);
8567                 other_decode_bitfield_value(a_bigbuf, oct_2, DTAP_TIE_MASK, 8);
8568                 proto_tree_add_text(pd_tree, tvb, 2, 1,
8569                         "%s :  TIE: %u", a_bigbuf, oct_2 & DTAP_TIE_MASK);
8570         }
8571
8572         /*
8573          * N(SD)
8574          */
8575         if ((pinfo->p2p_dir == P2P_DIR_RECV) &&
8576                 nsd)
8577         {
8578                 /* XXX */
8579         }
8580
8581         /*
8582          * add DTAP message name
8583          */
8584         proto_tree_add_uint_format(ccch_tree, hf_idx, tvb, offset, 1, oct,
8585                 "Message Type: %s",msg_str ? msg_str : "(Unknown)");
8586
8587         offset++;
8588
8589         tap_p->pdu_type = GSM_A_PDU_TYPE_DTAP;
8590         tap_p->message_type = (nsd ? (oct & 0x3f) : oct);
8591         tap_p->protocol_disc = pd;
8592
8593         tap_queue_packet(gsm_a_tap, pinfo, tap_p);
8594
8595         if (msg_str == NULL)
8596                 return;
8597
8598         if ((len - offset) <= 0)
8599                 return;
8600
8601         /*
8602          * decode elements
8603          */
8604         if (msg_fcn == NULL){
8605                 proto_tree_add_text(ccch_tree, tvb, offset, len - offset,
8606                         "Message Elements");
8607         }else{
8608                 (*msg_fcn)(tvb, ccch_tree, offset, len - offset);
8609         }
8610 }
8611
8612 const value_string gsm_a_sacch_msg_rr_strings[] = {
8613    { 0x00, "System Information Type 10" },
8614    { 0x01, "Notification/FACCH" },
8615    { 0x02, "Uplink Free" },
8616    { 0x04, "Enhanced Measurement Report" },
8617    { 0x05, "Measurement Information" },
8618    { 0x06, "VBS/VGCS Reconfigure" },
8619    { 0x07, "VBS/VGCS Reconfigure2" },
8620    { 0x08, "VGCS Additional Information" },
8621    { 0x09, "VGCS SMS Information" },
8622    { 0, NULL }
8623 };
8624
8625 #define NUM_GSM_SACCH_MSG_RR (sizeof(gsm_a_sacch_msg_rr_strings)/sizeof(value_string))
8626 static gint ett_gsm_sacch_msg_rr[NUM_GSM_SACCH_MSG_RR];
8627 static void (*sacch_msg_rr_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len) = {
8628    NULL,        /* System Information Type 10 */
8629    NULL,        /* Notification/FACCH */
8630    NULL, /* Uplink Free  */
8631    sacch_rr_enh_meas_report, /* Enhanced Measurement Report */
8632    sacch_rr_meas_info, /* Measurement Information */
8633    NULL, /* VBS/VGCS Reconfigure */
8634    NULL, /* VBS/VGCS Reconfigure2 */
8635    NULL, /* VGCS Additional Information */
8636    NULL, /* VGCS SMS Information */
8637    NULL, /* NONE */
8638 };
8639
8640 void get_rr_short_pd_msg_params(guint8 mess_type, const gchar **msg_str, int *ett_tree, int *hf_idx, msg_fcn *msg_fcn)
8641 {
8642         gint                    idx;
8643
8644         *msg_str = match_strval_idx((guint32) mess_type, gsm_a_sacch_msg_rr_strings, &idx);
8645         *ett_tree = ett_gsm_sacch_msg_rr[idx];
8646         *hf_idx = hf_gsm_a_sacch_msg_rr_type;
8647         *msg_fcn = sacch_msg_rr_fcn[idx];
8648 }
8649
8650 const value_string short_protocol_discriminator_vals[] = {
8651         {0x0,   "Radio Resources Management messages"},
8652         { 0,    NULL }
8653 };
8654
8655 static void
8656 dissect_sacch(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
8657 {
8658    static gsm_a_tap_rec_t       tap_rec[4];
8659    static gsm_a_tap_rec_t       *tap_p;
8660    static guint                 tap_current=0;
8661
8662    void                 (*msg_fcn)(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len);
8663    guint8                       oct, short_pd, mess_type;
8664    guint32                      offset;
8665    guint32                      len;
8666    proto_item           *sacch_item = NULL;
8667    proto_tree           *sacch_tree = NULL;
8668    const gchar          *msg_str;
8669    gint                 ett_tree;
8670    int                          hf_idx;
8671
8672         len = tvb_length(tvb);
8673
8674         if (check_col(pinfo->cinfo, COL_INFO))
8675                 col_append_str(pinfo->cinfo, COL_INFO, "(SACCH) ");
8676
8677         /*
8678          * set tap record pointer
8679          */
8680         tap_current++;
8681         if (tap_current >= 4)
8682         {
8683                 tap_current = 0;
8684         }
8685         tap_p = &tap_rec[tap_current];
8686
8687         offset = 0;
8688
8689         oct = tvb_get_guint8(tvb, offset);
8690
8691         msg_str = NULL;
8692         ett_tree = -1;
8693         hf_idx = -1;
8694         msg_fcn = NULL;
8695
8696    short_pd = (oct & 0x80) >> 7;
8697    mess_type = (oct & 0x7c) >> 2;
8698
8699    if (short_pd == 0)
8700    {
8701            if (check_col(pinfo->cinfo, COL_INFO))
8702                    col_append_fstr(pinfo->cinfo, COL_INFO, "(RR) ");
8703       get_rr_short_pd_msg_params(mess_type, &msg_str, &ett_tree, &hf_idx, &msg_fcn);
8704         }
8705    else
8706    {
8707            if (check_col(pinfo->cinfo, COL_INFO))
8708                    col_append_fstr(pinfo->cinfo, COL_INFO, "(Unknown) ");
8709         }
8710
8711         /*
8712          * create the protocol tree
8713          */
8714         if (msg_str == NULL){
8715                 sacch_item = proto_tree_add_protocol_format(tree, proto_a_sacch, tvb, 0, len,
8716                         "GSM SACCH - Message Type (0x%02x)", mess_type);
8717
8718                 sacch_tree = proto_item_add_subtree(sacch_item, ett_sacch_msg);
8719         }else{
8720                 sacch_item = proto_tree_add_protocol_format(tree, proto_a_sacch, tvb, 0, -1,
8721                         "GSM SACCH - %s", msg_str);
8722
8723                 sacch_tree = proto_item_add_subtree(sacch_item, ett_tree);
8724
8725         if (check_col(pinfo->cinfo, COL_INFO)){
8726                 col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", msg_str);
8727            }
8728         }
8729
8730    if (short_pd == 0)
8731         proto_tree_add_text(sacch_tree,
8732                 tvb, offset, 1,
8733                 "Short Protocol Discriminator: %s",
8734                 val_to_str(short_pd, short_protocol_discriminator_vals, "Unknown (%u)"));
8735
8736    if (hf_idx == -1)
8737       return;
8738
8739         /*
8740          * add SACCH message name
8741          */
8742         proto_tree_add_uint_format(sacch_tree, hf_idx, tvb, offset, 1, oct,
8743                 "Message Type: %s",msg_str ? msg_str : "(Unknown)");
8744
8745    proto_tree_add_text(sacch_tree, tvb, offset, 1,
8746                 "Short Layer 2 header: %u", oct & 0x03);
8747
8748         offset++;
8749
8750         tap_p->pdu_type = GSM_A_PDU_TYPE_SACCH;
8751         tap_p->message_type = mess_type;
8752         tap_p->protocol_disc = short_pd;
8753
8754         tap_queue_packet(gsm_a_tap, pinfo, tap_p);
8755
8756         if (msg_str == NULL)
8757                 return;
8758
8759         /*
8760          * decode elements
8761          */
8762         if (msg_fcn == NULL){
8763                 proto_tree_add_text(sacch_tree, tvb, offset, len - offset,
8764                         "Message Elements");
8765         }else{
8766                 (*msg_fcn)(tvb, sacch_tree, offset, len - offset);
8767         }
8768 }
8769
8770 /* Register the protocol with Wireshark */
8771 void
8772 proto_register_gsm_a_rr(void)
8773 {
8774         guint           i;
8775         guint           last_offset;
8776
8777         /* Setup list of header fields */
8778
8779         static hf_register_info hf[] =
8780         {
8781         { &hf_gsm_a_dtap_msg_rr_type,
8782                 { "DTAP Radio Resources Management Message Type",       "gsm_a.dtap_msg_rr_type",
8783                 FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_msg_rr_strings), 0x0,
8784                 "", HFILL }
8785         },
8786         { &hf_gsm_a_rr_elem_id,
8787                 { "Element ID", "gsm_a_rr.elem_id",
8788                 FT_UINT8, BASE_DEC, NULL, 0,
8789                 "", HFILL }
8790         },
8791         { &hf_gsm_a_bcc,
8792                 { "BCC","gsm_a.bcc",
8793                 FT_UINT8,BASE_DEC,  NULL, 0x07,
8794                 "BCC", HFILL }
8795         },
8796         { &hf_gsm_a_ncc,
8797                 { "NCC","gsm_a.ncc",
8798                 FT_UINT8,BASE_DEC,  NULL, 0x38,
8799                 "NCC", HFILL }
8800         },
8801         { &hf_gsm_a_bcch_arfcn,
8802                 { "BCCH ARFCN(RF channel number)","gsm_a.bcch_arfcn",
8803                 FT_UINT16,BASE_DEC,  NULL, 0x0,
8804                 "BCCH ARFCN", HFILL }
8805         },
8806         { &hf_gsm_a_rr_range_nb,
8807                 { "Number of Ranges","gsm_a.rr.range_nb",
8808                 FT_UINT8, BASE_DEC,  NULL, 0xff,
8809                 "Number of Ranges", HFILL }
8810         },
8811         { &hf_gsm_a_rr_range_lower,
8812                 { "Range Lower","gsm_a.rr.range_lower",
8813                 FT_UINT16, BASE_DEC,  NULL, 0x0000,
8814                 "ARFCN used as the lower limit of a range of frequencies to be used by the mobile station in cell selection (Range Lower)", HFILL }
8815         },
8816         { &hf_gsm_a_rr_range_higher,
8817                 { "Range Higher","gsm_a.rr.range_higher",
8818                 FT_UINT16, BASE_DEC,  NULL, 0x0000,
8819                 "ARFCN used as the higher limit of a range of frequencies to be used by the mobile station in cell selection (Range Higher)", HFILL }
8820         },
8821         { &hf_gsm_a_rr_ba_list_pref_length,
8822                 { "Length of BA List Pref","gsm_a.rr.ba_list_pref_length",
8823                 FT_UINT8, BASE_DEC,  NULL, 0xff,
8824                 "Length of BA List Pref", HFILL }
8825         },
8826         { &hf_gsm_a_rr_ba_freq,
8827                 { "BA Freq","gsm_a.rr.ba_freq",
8828                 FT_UINT16, BASE_DEC,  NULL, 0x0000,
8829                 "ARFCN indicating a single frequency to be used by the mobile station in cell selection and reselection (BA Freq)", HFILL }
8830         },
8831         { &hf_gsm_a_rr_utran_freq_list_length,
8832                 { "Length of BA List Pref","gsm_a.rr.ba_list_pref_length",
8833                 FT_UINT8, BASE_DEC,  NULL, 0xff,
8834                 "Length of BA List Pref", HFILL }
8835         },
8836         { &hf_gsm_a_rr_ho_ref_val,
8837                 { "Handover reference value","gsm_a.rr.ho_ref_val",
8838                 FT_UINT8,BASE_DEC,  NULL, 0x0,
8839                 "Handover reference value", HFILL }
8840         },
8841         { &hf_gsm_a_rr_L2_pseudo_len,
8842                 { "L2 Pseudo Length value","gsm_a.rr.rr_2_pseudo_len",
8843                 FT_UINT8, BASE_DEC, NULL, 0xfc,
8844                 "L2 Pseudo Length value", HFILL }
8845         },
8846         { &hf_gsm_a_rr_ba_used,
8847                 { "BA-USED","gsm_a.rr.ba_used",
8848                 FT_UINT8, BASE_DEC,  NULL, 0x00,
8849                 "BA-USED", HFILL }
8850         },
8851         { &hf_gsm_a_rr_dtx_used,
8852                 { "DTX-USED","gsm_a.rr.dtx_used",
8853                 FT_BOOLEAN, 8,  TFS(&gsm_a_rr_dtx_vals), 0x00,
8854                 "DTX-USED", HFILL }
8855         },
8856         { &hf_gsm_a_rr_3g_ba_used,
8857         { "3G-BA-USED","gsm_a.rr.3g_ba_used",
8858                 FT_UINT8, BASE_DEC, NULL, 0x00,
8859                 "3G-BA-USED", HFILL }
8860         },
8861         { &hf_gsm_a_rr_meas_valid,
8862                 { "MEAS-VALID","gsm_a.rr.meas_valid",
8863                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_mv_vals), 0x40,
8864                 "MEAS-VALID", HFILL }
8865         },
8866         { &hf_gsm_a_rr_rxlev_full_serv_cell,
8867                 { "RXLEV-FULL-SERVING-CELL","gsm_a.rr.rxlev_full_serv_cell",
8868                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_rxlev_vals), 0x00,
8869                 "RXLEV-FULL-SERVING-CELL", HFILL }
8870         },
8871         { &hf_gsm_a_rr_rxlev_sub_serv_cell,
8872                 { "RXLEV-SUB-SERVING-CELL","gsm_a.rr.rxlev_sub_serv_cell",
8873                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_rxlev_vals), 0x3f,
8874                 "RXLEV-SUB-SERVING-CELL", HFILL }
8875         },
8876         { &hf_gsm_a_rr_rxqual_full_serv_cell,
8877                 { "RXQUAL-FULL-SERVING-CELL","gsm_a.rr.rxqual_full_serv_cell",
8878                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_rxqual_vals), 0x00,
8879                 "RXQUAL-FULL-SERVING-CELL", HFILL }
8880         },
8881         { &hf_gsm_a_rr_rxqual_sub_serv_cell,
8882                 { "RXQUAL-SUB-SERVING-CELL","gsm_a.rr.rxqual_sub_serv_cell",
8883                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_rxqual_vals), 0x0e,
8884                 "RXQUAL-SUB-SERVING-CELL", HFILL }
8885         },
8886         { &hf_gsm_a_rr_no_ncell_m,
8887                 { "NO-NCELL-M","gsm_a.rr.no_ncell_m",
8888                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_ncell_vals), 0x00,
8889                 "NO-NCELL-M", HFILL }
8890         },
8891         { &hf_gsm_a_rr_rxlev_ncell,
8892                 { "RXLEV-NCELL","gsm_a.rr.rxlev_ncell",
8893                 FT_UINT8,BASE_DEC, NULL, 0x00,
8894                 "RXLEV-NCELL", HFILL }
8895         },
8896         { &hf_gsm_a_rr_bcch_freq_ncell,
8897                 { "BCCH-FREQ-NCELL","gsm_a.rr.bcch_freq_ncell",
8898                 FT_UINT8,BASE_DEC, NULL, 0x00,
8899                 "BCCH-FREQ-NCELL", HFILL }
8900         },
8901         { &hf_gsm_a_rr_bsic_ncell,
8902                 { "BSIC-NCELL","gsm_a.rr.bsic_ncell",
8903                 FT_UINT8,BASE_DEC, NULL, 0x00,
8904                 "BSIC-NCELL", HFILL }
8905         },
8906         { &hf_gsm_a_rr_mobile_time_difference,
8907                 { "Mobile Timing Difference value (in half bit periods)","gsm_a.rr.mobile_time_difference",
8908                 FT_UINT32,BASE_DEC, NULL, 0xFFFFF8,
8909                 "Mobile Timing Difference value (in half bit periods)", HFILL }
8910         },
8911         { &hf_gsm_a_rr_pow_cmd_atc,
8912                 { "ATC","gsm_a.rr.pow_cmd_atc",
8913                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_pow_cmd_atc_value), 0x80,
8914                 "ATC", HFILL }
8915         },
8916         { &hf_gsm_a_rr_page_mode,
8917                 { "Page Mode","gsm_a.rr.page_mode",
8918                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_page_mode_vals), 0x03,
8919                 "Page Mode", HFILL }
8920         },
8921         { &hf_gsm_a_rr_dedicated_mode_or_tbf,
8922                 { "Dedicated mode or TBF","gsm_a.rr.dedicated_mode_or_tbf",
8923                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_dedicated_mode_or_tbf_vals), 0x70,
8924                 "Dedicated mode or TBF", HFILL }
8925         },
8926         { &hf_gsm_a_rr_pow_cmd_epc,
8927                 { "EPC_mode","gsm_a.rr.pow_cmd_epc",
8928                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_pow_cmd_epc_value), 0x40,
8929                 "EPC_mode", HFILL }
8930         },
8931         { &hf_gsm_a_rr_pow_cmd_fpcepc,
8932                 { "FPC_EPC","gsm_a.rr.pow_cmd_fpcepc",
8933                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_pow_cmd_fpcepc_value), 0x20,
8934                 "FPC_EPC", HFILL }
8935         },
8936         { &hf_gsm_a_rr_pow_cmd_powlev,
8937                 { "POWER LEVEL","gsm_a.rr.pow_cmd_pow",
8938                 FT_UINT8,BASE_DEC,  NULL, 0x1f,
8939                 "POWER LEVEL", HFILL }
8940         },
8941         { &hf_gsm_a_rr_sync_ind_nci,
8942                 { "Normal cell indication(NCI)","gsm_a.rr.sync_ind_nci",
8943                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_sync_ind_nci_value), 0x08,
8944                 "Normal cell indication(NCI)", HFILL }
8945         },
8946         { &hf_gsm_a_rr_sync_ind_rot,
8947                 { "Report Observed Time Difference(ROT)","gsm_a.rr.sync_ind_rot",
8948                 FT_BOOLEAN,8,  TFS(&sm_a_rr_sync_ind_rot_value), 0x04,
8949                 "Report Observed Time Difference(ROT)", HFILL }
8950         },
8951         { &hf_gsm_a_rr_sync_ind_si,
8952                 { "Synchronization indication(SI)","gsm_a.rr_sync_ind_si",
8953                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_sync_ind_si_vals), 0x03,
8954                 "Synchronization indication(SI)", HFILL }
8955         },
8956         { &hf_gsm_a_rr_format_id,
8957                 { "Format Identifier","gsm_a.rr_format_id",
8958                 FT_UINT8,BASE_HEX,  VALS(gsm_a_rr_freq_list_format_id_vals), 0xce,
8959                 "Format Identifier", HFILL }
8960         },
8961         { &hf_gsm_a_rr_channel_mode,
8962                 { "Channel Mode","gsm_a.rr.channel_mode",
8963                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_channel_mode_vals), 0x0,
8964                 "Channel Mode", HFILL }
8965         },
8966         { &hf_gsm_a_rr_channel_mode2,
8967                 { "Channel Mode 2","gsm_a.rr.channel_mode2",
8968                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_channel_mode2_vals), 0x0,
8969                 "Channel Mode 2", HFILL }
8970         },
8971         { &hf_gsm_a_rr_sc,
8972                 { "SC","gsm_a.rr.SC",
8973                 FT_UINT8, BASE_DEC,  VALS(gsm_a_rr_sc_vals), 0x00,
8974                 "SC", HFILL }
8975         },
8976         { &hf_gsm_a_algorithm_id,
8977                 { "Algorithm identifier","gsm_a.algorithm_identifier",
8978                 FT_UINT8,BASE_DEC,  VALS(gsm_a_algorithm_identifier_vals), 0x00,
8979                 "Algorithm_identifier", HFILL }
8980         },
8981         { &hf_gsm_a_rr_cr,
8982                 { "CR","gsm_a.rr.CR",
8983                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_cr_vals), 0x00,
8984                 "CR", HFILL }
8985         },
8986         { &hf_gsm_a_rr_multirate_speech_ver,
8987                 { "Multirate speech version","gsm_a.rr.multirate_speech_ver",
8988                 FT_UINT8,BASE_DEC,  VALS(multirate_speech_ver_vals), 0xe0,
8989                 "Multirate speech version", HFILL }
8990         },
8991         { &hf_gsm_a_rr_NCSB,
8992                 { "NSCB: Noise Suppression Control Bit","gsm_a.rr.NCSB",
8993                 FT_UINT8,BASE_DEC,  VALS(NSCB_vals), 0x10,
8994                 "NSCB: Noise Suppression Control Bit", HFILL }
8995         },
8996         { &hf_gsm_a_rr_ICMI,
8997                 { "ICMI: Initial Codec Mode Indicator","gsm_a.rr.ICMI",
8998                 FT_UINT8,BASE_DEC,  VALS(ICMI_vals), 0x8,
8999                 "ICMI: Initial Codec Mode Indicator", HFILL }
9000         },
9001         { &hf_gsm_a_rr_start_mode,
9002                 { "Start Mode","gsm_a.rr.start_mode",
9003                 FT_UINT8,BASE_DEC,  NULL, 0x3,
9004                 "Start Mode", HFILL }
9005         },
9006         { &hf_gsm_a_rr_timing_adv,
9007                 { "Timing advance value","gsm_a.rr.timing_adv",
9008                 FT_UINT8,BASE_DEC,  NULL, 0x0,
9009                 "Timing advance value", HFILL }
9010         },
9011         { &hf_gsm_a_rr_time_diff,
9012                 { "Time difference value","gsm_a.rr.time_diff",
9013                 FT_UINT8,BASE_DEC,  NULL, 0x0,
9014                 "Time difference value", HFILL }
9015         },
9016         { &hf_gsm_a_rr_tlli,
9017                 { "TLLI","gsm_a.rr.tlli",
9018                 FT_UINT32,BASE_HEX,  NULL, 0x0,
9019                 "TLLI", HFILL }
9020         },
9021         { &hf_gsm_a_rr_tmsi_ptmsi,
9022                 { "TMSI/P-TMSI Value","gsm_a.rr.tmsi_ptmsi",
9023                 FT_UINT32,BASE_HEX,  NULL, 0x0,
9024                 "TMSI/P-TMSI Value", HFILL }
9025         },
9026         { &hf_gsm_a_rr_target_mode,
9027                 { "Target mode","gsm_a.rr.target_mode",
9028                 FT_UINT8,BASE_DEC,  NULL, 0xc0,
9029                 "Target mode", HFILL }
9030         },
9031         { &hf_gsm_a_rr_wait_indication,
9032                 { "Wait Indication","gsm_a.rr.wait_indication",
9033                 FT_UINT8,BASE_DEC,  NULL, 0x00,
9034                 "Wait Indication (T3122/T3142)", HFILL }
9035         },
9036         { &hf_gsm_a_rr_seq_code,
9037                 { "Sequence Code","gsm_a.rr.seq_code",
9038                 FT_UINT8, BASE_DEC, NULL, 0x00,
9039                 "Sequence Code", HFILL }
9040         },
9041
9042         { &hf_gsm_a_rr_group_cipher_key_number,
9043                 { "Group cipher key number","gsm_a.rr.Group_cipher_key_number",
9044                 FT_UINT8,BASE_DEC,  NULL, 0x3c,
9045                 "Group cipher key number", HFILL }
9046         },
9047         { &hf_gsm_a_rr_MBMS_broadcast,
9048                 { "MBMS Broadcast","gsm_a.rr.MBMS_broadcast",
9049                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_MBMS_broadcast_value), 0x01,
9050                 "MBMS Broadcast", HFILL }
9051         },
9052         { &hf_gsm_a_rr_MBMS_multicast,
9053                 { "MBMS Multicast","gsm_a.rr.MBMS_multicast",
9054                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_MBMS_multicast_value), 0x02,
9055                 "MBMS Multicast", HFILL }
9056         },
9057         { &hf_gsm_a_rr_last_segment,
9058                 { "Last Segment","gsm_a.rr.last_segment",
9059                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_last_segment_value), 0x01,
9060                 "Last Segment", HFILL }
9061         },
9062         { &hf_gsm_a_rr_carrier_ind,
9063                 { "Carrier Indication","gsm_a.rr.carrier_ind",
9064                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_carrier_ind_value), 0x01,
9065                 "Carrier Indication", HFILL }
9066         },
9067         { &hf_gsm_a_rr_ra,
9068                 { "Random Access Information (RA)", "gsm_a_rr_ra",
9069                 FT_UINT8, BASE_DEC, NULL, 0x0,
9070                 "Random Access Information (RA)", HFILL }
9071         },
9072         { &hf_gsm_a_rr_T1prim,
9073                 { "T1'",                   "gsm_a.rr.T1prim",
9074                 FT_UINT8, BASE_DEC, NULL, 0xf8,
9075                 "T1'", HFILL }
9076         },
9077         { &hf_gsm_a_rr_T3,
9078                 { "T3",            "gsm_a.rr.T3",
9079                 FT_UINT16, BASE_DEC, NULL, 0x07e0,
9080                 "T3", HFILL }
9081         },
9082         { &hf_gsm_a_rr_T2,
9083                 { "T2",            "gsm_a.rr.T2",
9084                 FT_UINT8, BASE_DEC, NULL, 0x1f,
9085                 "T2", HFILL }
9086         },
9087         { &hf_gsm_a_rr_rfn,
9088                 { "RFN",                   "gsm_a.rr.rfn",
9089                 FT_UINT16, BASE_DEC, NULL, 0x0,
9090                 "Reduced Frame Number", HFILL }
9091         },
9092         { &hf_gsm_a_rr_RR_cause,
9093                 { "RR cause value","gsm_a.rr.RRcause",
9094                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_RR_cause_vals), 0x0,
9095                 "RR cause value", HFILL }
9096                 },
9097         { &hf_gsm_a_rr_cm_cng_msg_req,
9098                 { "CLASSMARK CHANGE","gsm_a.rr_cm_cng_msg_req",
9099                 FT_BOOLEAN,8,  TFS(&gsm_a_msg_req_value), 0x80,
9100                 "CLASSMARK CHANGE ", HFILL }
9101         },
9102         { &hf_gsm_a_rr_utran_cm_cng_msg_req,
9103                 { "UTRAN CLASSMARK CHANGE","gsm_a.rr_utran_cm_cng_msg_req",
9104                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_utran_cm_cng_msg_req_vals), 0x70,
9105                 "UTRAN CLASSMARK CHANGE", HFILL }
9106         },
9107         { &hf_gsm_a_rr_cdma200_cm_cng_msg_req,
9108                 { "CDMA2000 CLASSMARK CHANGE ","gsm_a.rr_cdma200_cm_cng_msg_req",
9109                 FT_BOOLEAN,8,  TFS(&gsm_a_msg_req_value), 0x08,
9110                 "CDMA2000 CLASSMARK CHANGE ", HFILL }
9111         },
9112         { &hf_gsm_a_rr_geran_iu_cm_cng_msg_req,
9113                 { "GERAN IU MODE CLASSMARK CHANGE","gsm_a.rr_geran_iu_cm_cng_msg_req",
9114                 FT_BOOLEAN,8,  TFS(&gsm_a_msg_req_value), 0x04,
9115                 "GERAN IU MODE CLASSMARK CHANGE", HFILL }
9116         },
9117         { &hf_gsm_a_rr_chnl_needed_ch1,
9118                 { "Channel 1","gsm_a.rr_chnl_needed_ch1",
9119                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_channel_needed_vals), 0x00,
9120                 "Channel 1", HFILL }
9121         },
9122         { &hf_gsm_a_rr_chnl_needed_ch2,
9123                 { "Channel 2","gsm_a.rr_chnl_needed_ch2",
9124                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_channel_needed_vals), 0x00,
9125                 "Channel 2", HFILL }
9126         },
9127         { &hf_gsm_a_rr_chnl_needed_ch3,
9128                 { "Channel 3","gsm_a.rr_chnl_needed_ch3",
9129                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_channel_needed_vals), 0x00,
9130                 "Channel 3", HFILL }
9131         },
9132         { &hf_gsm_a_rr_chnl_needed_ch4,
9133                 { "Channel 4","gsm_a.rr_chnl_needed_ch4",
9134                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_channel_needed_vals), 0x00,
9135                 "Channel 4", HFILL }
9136         },
9137         { &hf_gsm_a_rr_suspension_cause,
9138                 { "Suspension cause value","gsm_a.rr.suspension_cause",
9139                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_suspension_cause_vals), 0x0,
9140                 "Suspension cause value", HFILL }
9141         },
9142         { &hf_gsm_a_rr_set_of_amr_codec_modes_v1_b8,
9143           { "12,2 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v1b8",
9144                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x80,
9145                 "12,2 kbit/s codec rate", HFILL }
9146         },
9147         { &hf_gsm_a_rr_set_of_amr_codec_modes_v1_b7,
9148           { "10,2 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v1b7",
9149                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x40,
9150                 "10,2 kbit/s codec rate", HFILL }
9151         },
9152         { &hf_gsm_a_rr_set_of_amr_codec_modes_v1_b6,
9153           { "7,95 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v1b6",
9154                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x20,
9155                 "7,95 kbit/s codec rate", HFILL }
9156         },
9157         { &hf_gsm_a_rr_set_of_amr_codec_modes_v1_b5,
9158           { "7,40 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v1b5",
9159                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x10,
9160                 "7,40 kbit/s codec rate", HFILL }
9161         },
9162         { &hf_gsm_a_rr_set_of_amr_codec_modes_v1_b4,
9163           { "6,70 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v1b4",
9164                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x08,
9165                 "6,70 kbit/s codec rate", HFILL }
9166         },
9167         { &hf_gsm_a_rr_set_of_amr_codec_modes_v1_b3,
9168           { "5,90 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v1b3",
9169                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x04,
9170                 "5,90 kbit/s codec rate", HFILL }
9171         },
9172         { &hf_gsm_a_rr_set_of_amr_codec_modes_v1_b2,
9173           { "5,15 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v1b2",
9174                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x02,
9175                 "5,15 kbit/s codec rate", HFILL }
9176         },
9177         { &hf_gsm_a_rr_set_of_amr_codec_modes_v1_b1,
9178           { "4,75 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v1b1",
9179                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x01,
9180                 "4,75 kbit/s codec rate", HFILL }
9181         },
9182         { &hf_gsm_a_rr_set_of_amr_codec_modes_v2_b5,
9183           { "23,85 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v2b5",
9184                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x10,
9185                 "23,85 kbit/s codec rate", HFILL }
9186         },
9187         { &hf_gsm_a_rr_set_of_amr_codec_modes_v2_b4,
9188           { "15,85 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v2b4",
9189                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x08,
9190                 "15,85 kbit/s codec rate", HFILL }
9191         },
9192         { &hf_gsm_a_rr_set_of_amr_codec_modes_v2_b3,
9193           { "12,65 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v2b3",
9194                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x04,
9195                 "12,65 kbit/s codec rate", HFILL }
9196         },
9197         { &hf_gsm_a_rr_set_of_amr_codec_modes_v2_b2,
9198           { "8,85 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v2b2",
9199                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x02,
9200                 "8,85 kbit/s codec rate", HFILL }
9201         },
9202         { &hf_gsm_a_rr_set_of_amr_codec_modes_v2_b1,
9203           { "6,60 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v2b1",
9204                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x01,
9205                 "6,60 kbit/s codec rate", HFILL }
9206         },
9207         { &hf_gsm_a_rr_amr_threshold,
9208           { "AMR Threshold", "gsm_a.rr.amr_threshold",
9209                 FT_UINT8, BASE_DEC,  VALS(gsm_a_rr_amr_threshold_vals), 0x00,
9210                 "AMR Threshold", HFILL }
9211         },
9212         { &hf_gsm_a_rr_amr_hysteresis,
9213           { "AMR Hysteresis", "gsm_a.rr.amr_hysteresis",
9214                 FT_UINT8, BASE_DEC,  VALS(gsm_a_rr_amr_hysteresis_vals), 0x00,
9215                 "AMR Hysteresis", HFILL }
9216         },
9217         { &hf_gsm_a_rr_pwrc,
9218           { "PWRC", "gsm_a.rr.pwrc",
9219                 FT_BOOLEAN, BASE_DEC,  NULL, 0x00,
9220                 "Power Control Indicator (PWRC)", HFILL }
9221         },
9222         { &hf_gsm_a_rr_dtx_bcch,
9223           { "DTX (BCCH)", "gsm_a.rr.dtx_bcch",
9224                 FT_UINT8, BASE_DEC,  VALS(gsm_a_rr_dtx_bcch_vals), 0x30,
9225                 "Discontinuous Tranmission (DTX-BCCH)", HFILL }
9226         },
9227         { &hf_gsm_a_rr_dtx_sacch,
9228           { "DTX (SACCH)", "gsm_a.rr.dtx_sacch",
9229                 FT_UINT8, BASE_DEC,  VALS(gsm_a_rr_dtx_sacch_vals), 0xb0,
9230                 "Discontinuous Tranmission (DTX-SACCH)", HFILL }
9231         },
9232         { &hf_gsm_a_rr_radio_link_timeout,
9233           { "Radio Link Timeout", "gsm_a.rr.radio_link_timeout",
9234                 FT_UINT8, BASE_DEC,  VALS(gsm_a_rr_radio_link_timeout_vals), 0x0f,
9235                 "Radio Link Timeout (s)", HFILL }
9236         },
9237         { &hf_gsm_a_rr_cell_reselect_hyst,
9238           { "Cell Reselection Hysteresis", "gsm_a.rr.cell_reselect_hyst",
9239                 FT_UINT8, BASE_DEC,  NULL, 0xe0,
9240                 "Cell Reslection Hysteresis (dB)", HFILL }
9241         },
9242         { &hf_gsm_a_rr_ms_txpwr_max_cch,
9243           { "MS TXPWR MAX CCH", "gsm_a.rr.ms_txpwr_max_cch",
9244                 FT_UINT8, BASE_DEC,  NULL, 0x1f,
9245                 "MS TXPWR MAX CCH", HFILL }
9246         },
9247         { &hf_gsm_a_rr_acs,
9248           { "ACS", "gsm_a.rr.acs",
9249                 FT_BOOLEAN, 8,  NULL, 0x80,
9250                 "Additional Reselect Param Indicator (ACS)", HFILL }
9251         },
9252         { &hf_gsm_a_rr_neci,
9253           { "NECI", "gsm_a.rr.neci",
9254                 FT_UINT8, BASE_DEC,  NULL, 0x40,
9255                 "New Establishment Cause Indicator (NECI)", HFILL }
9256         },
9257         { &hf_gsm_a_rr_rxlev_access_min,
9258           { "RXLEV-ACCESS-MIN", "gsm_a.rr.rxlev_access_min",
9259                 FT_UINT8, BASE_DEC,  VALS(gsm_a_rr_rxlev_vals), 0x3f,
9260                 "RXLEV-ACCESS-MIN", HFILL }
9261         },
9262         { &hf_gsm_a_rr_mscr,
9263           { "MSCR", "gsm_a.rr.mscr",
9264                 FT_UINT8, BASE_DEC,  VALS(gsm_a_rr_mscr_vals), 0x80,
9265                 "MSC Release Indicator (MSCR)", HFILL }
9266         },
9267         { &hf_gsm_a_rr_att,
9268           { "ATT", "gsm_a.rr.att",
9269                 FT_UINT8, BASE_DEC,  VALS(gsm_a_rr_att_vals), 0x40,
9270                 "Attach Indicator (ATT)", HFILL }
9271         },
9272         { &hf_gsm_a_rr_bs_ag_blks_res,
9273           { "BS_AG_BLKS_RES", "gsm_a.rr.bs_ag_blks_res",
9274                 FT_UINT8, BASE_DEC,  NULL, 0x38,
9275                 "Access Grant Reserved Blocks (BS_AG_BLKS_RES)", HFILL }
9276         },
9277         { &hf_gsm_a_rr_ccch_conf,
9278           { "CCCH-CONF", "gsm_a.rr.ccch_conf",
9279                 FT_UINT8, BASE_DEC,  VALS(gsm_a_rr_ccch_conf_vals), 0x07,
9280                 "CCCH-CONF", HFILL }
9281         },
9282         { &hf_gsm_a_rr_cbq3,
9283           { "CBQ3", "gsm_a.rr.cbq3",
9284                 FT_UINT8, BASE_DEC,  VALS(gsm_a_rr_cbq3_vals), 0x00,
9285                 "Cell Bar Qualify 3", HFILL }
9286         },
9287         { &hf_gsm_a_rr_bs_pa_mfrms,
9288           { "BS-PA-MFRMS", "gsm_a.rr.bs_pa_mfrms",
9289                 FT_UINT8, BASE_DEC,  NULL, 0x07,
9290                 "BS-PA-MFRMS", HFILL }
9291         },
9292         { &hf_gsm_a_rr_t3212,
9293           { "T3212", "gsm_a.rr.t3212",
9294                 FT_UINT8, BASE_DEC,  NULL, 0x00,
9295                 "Periodic Update period (T3212) (deci-hours)", HFILL }
9296         },
9297         { &hf_gsm_a_rr_dyn_arfcn_length,
9298           { "Length of Dynamic Mapping", "gsm_a.rr.dyn_arfcn_length",
9299                 FT_UINT8, BASE_DEC,  NULL, 0x00,
9300                 "Length of Dynamic Mapping", HFILL }
9301         },
9302         { &hf_gsm_a_rr_gsm_band,
9303           { "GSM Band", "gsm_a.rr.gsm_band",
9304                 FT_UINT8, BASE_DEC,  VALS(gsm_a_rr_gsm_band_vals), 0x00,
9305                 "GSM Band", HFILL }
9306         },
9307         { &hf_gsm_a_rr_arfcn_first,
9308           { "ARFCN First", "gsm_a.rr.arfcn_first",
9309                 FT_UINT16, BASE_DEC,  NULL, 0x00,
9310                 "ARFCN First", HFILL }
9311         },
9312         { &hf_gsm_a_rr_band_offset,
9313           { "Band Offset", "gsm_a.rr.band_offset",
9314                 FT_UINT16, BASE_DEC,  NULL, 0x00,
9315                 "Band Offset", HFILL }
9316         },
9317         { &hf_gsm_a_rr_arfcn_range,
9318           { "ARFCN Range", "gsm_a.rr.arfcn_range",
9319                 FT_UINT8, BASE_DEC,  NULL, 0x00,
9320                 "ARFCN Range", HFILL }
9321         },
9322         { &hf_gsm_a_rr_lowest_arfcn,
9323           { "Lowest ARFCN", "gsm_a.rr.lowest_arfcn",
9324                 FT_UINT8, BASE_DEC,  NULL, 0x7f,
9325                 "Lowest ARFCN", HFILL }
9326         },
9327         { &hf_gsm_a_rr_inc_skip_arfcn,
9328           { "Increment skip ARFCN", "gsm_a.rr.inc_skip_arfcn",
9329                 FT_UINT8, BASE_DEC,  NULL, 0x00,
9330                 "Increment skip ARFCN", HFILL }
9331         },
9332         { &hf_gsm_a_rr_gprs_resumption_ack,
9333           { "Ack", "gsm_a.rr.gprs_resumption_ack",
9334                 FT_BOOLEAN, BASE_DEC,  TFS(&gsm_a_rr_gprs_resumption_ack_value), 0x01,
9335                 "GPRS Resumption Ack bit", HFILL }
9336         },
9337         { &hf_gsm_a_rr_ext_ind,
9338           { "EXT-IND", "gsm_a.rr.ext_ind",
9339                 FT_UINT8, BASE_DEC,  VALS(gsm_a_rr_ext_ind_vals), 0x20,
9340                 "Extension Indication (EXT-IND)", HFILL }
9341         },
9342         { &hf_gsm_a_rr_ba_ind,
9343           { "BA-IND", "gsm_a.rr.ba_ind",
9344                 FT_UINT8, BASE_DEC,  NULL, 0x00,
9345                 "BCCH Allocation Indication (BA-IND)", HFILL }
9346         },
9347         { &hf_gsm_a_rr_multiband_reporting,
9348           { "Multiband Reporting", "gsm_a.rr.multiband_reporting",
9349                 FT_UINT8, BASE_DEC,  NULL, 0x00,
9350                 "Number of cells to be reported in each band if Multiband Reporting", HFILL }
9351         },
9352         { &hf_gsm_a_rr_ncc_permitted,
9353           { "NCC Permitted", "gsm_a.rr.ncc_permitted",
9354                 FT_UINT8, BASE_HEX,  NULL, 0xff,
9355                 "NCC Permitted", HFILL }
9356         },
9357         { &hf_gsm_a_rr_max_retrans,
9358           { "Max retrans", "gsm_a.rr.max_retrans",
9359                 FT_UINT8, BASE_DEC,  VALS(gsm_a_rr_max_retrans_vals), 0xc0,
9360                 "Maximum number of retransmissions", HFILL }
9361         },
9362         { &hf_gsm_a_rr_tx_integer,
9363           { "Tx-integer", "gsm_a.rr.tx_integer",
9364                 FT_UINT8, BASE_DEC,  VALS(gsm_a_rr_tx_integer_vals), 0x3c,
9365                 "Number of Slots to spread Transmission (Tx-integer)", HFILL }
9366         },
9367         { &hf_gsm_a_rr_cell_barr_access,
9368           { "CELL_BARR_ACCESS", "gsm_a.rr.cell_barr_access",
9369                 FT_UINT8, BASE_DEC,  VALS(gsm_a_rr_cell_barr_access_vals), 0x02,
9370                 "Cell Barred for Access (CELL_BARR_ACCESS)", HFILL }
9371         },
9372         { &hf_gsm_a_rr_re,
9373           { "RE", "gsm_a.rr.re",
9374                 FT_BOOLEAN, 8,  NULL, 0x01,
9375                 "Call re-establishment allowed (RE)", HFILL }
9376         },
9377         { &hf_gsm_a_rr_acc,
9378           { "ACC", "gsm_a.rr.acc",
9379                 FT_UINT16, BASE_HEX,  NULL, 0xffff,
9380                 "Access Control Class N barred (ACC)", HFILL }
9381         },
9382         { &hf_gsm_a_rr_nch_position,
9383           { "NCH Position", "gsm_a.rr.nch_position",
9384                 FT_UINT8, BASE_DEC,  VALS(gsm_a_rr_nch_position_vals), 0x00,
9385                 "NCH Position", HFILL }
9386         },
9387         { &hf_gsm_a_rr_si2ter_mp_change_mark,
9388           { "SI2ter Measurement Parameter Change Mark", "gsm_a.rr.si2ter_mp_change_mark",
9389                 FT_UINT8, BASE_DEC,  NULL, 0x00,
9390                 "SI2ter Measurement Parameter Change Mark", HFILL }
9391         },
9392         { &hf_gsm_a_rr_si2ter_3g_change_mark,
9393           { "SI2ter 3G Change Mark", "gsm_a.rr.si2ter_3g_change_mark",
9394                 FT_UINT8, BASE_DEC,  NULL, 0x00,
9395                 "SI2ter 3G Change Mark", HFILL }
9396         },
9397         { &hf_gsm_a_rr_si2ter_index,
9398           { "SI2ter Index", "gsm_a.rr.si2ter_index",
9399                 FT_UINT8, BASE_DEC,  NULL, 0x00,
9400                 "SI2ter Index", HFILL }
9401         },
9402         { &hf_gsm_a_rr_si2ter_count,
9403           { "SI2ter Count", "gsm_a.rr.si2ter_count",
9404                 FT_UINT8, BASE_DEC,  NULL, 0x00,
9405                 "SI2ter Count", HFILL }
9406         },
9407         { &hf_gsm_a_rr_fdd_uarfcn,
9408           { "FDD UARFCN", "gsm_a.rr.fdd_uarfcn",
9409                 FT_UINT16, BASE_DEC,  NULL, 0x0000,
9410                 "FDD UARFCN", HFILL }
9411         },
9412         { &hf_gsm_a_rr_bandwidth_fdd,
9413           { "Bandwidth FDD", "gsm_a.rr.bandwidth_fdd",
9414                 FT_UINT8, BASE_DEC,  NULL, 0x00,
9415                 "Bandwidth FDD", HFILL }
9416         },
9417         { &hf_gsm_a_rr_tdd_uarfcn,
9418           { "TDD UARFCN", "gsm_a.rr.tdd_uarfcn",
9419                 FT_UINT16, BASE_DEC,  NULL, 0x0000,
9420                 "TDD UARFCN", HFILL }
9421         },
9422         { &hf_gsm_a_rr_bandwidth_tdd,
9423           { "Bandwidth TDD", "gsm_a.rr.bandwidth_tdd",
9424                 FT_UINT8, BASE_DEC,  NULL, 0x00,
9425                 "Bandwidth TDD", HFILL }
9426         },
9427         { &hf_gsm_a_rr_arfcn,
9428           { "ARFCN", "gsm_a.rr.arfcn",
9429                 FT_UINT16, BASE_DEC,  NULL, 0x0000,
9430                 "Absolute Radio Frequency Channel Number (ARFCN)", HFILL }
9431         },
9432         { &hf_gsm_a_rr_bsic,
9433           { "BSIC", "gsm_a.rr.bsic",
9434                 FT_UINT8, BASE_DEC,  NULL, 0x00,
9435                 "Base Station Identify Code (BSIC)", HFILL }
9436         },
9437         { &hf_gsm_a_rr_qsearch_i,
9438           { "Qsearch I", "gsm_a.rr.qsearch_i",
9439                 FT_UINT8, BASE_DEC,  VALS(gsm_a_rr_qsearch_x_vals), 0x00,
9440                 "Search for 3G cells if signal level is below (0 7) or above (8 15) threshold (Qsearch I)", HFILL }
9441         },
9442         { &hf_gsm_a_rr_fdd_qoffset,
9443           { "FDD Qoffset", "gsm_a.rr.fdd_qoffset",
9444                 FT_UINT8, BASE_DEC,  VALS(gsm_a_rr_xdd_qoffset_vals), 0x00,
9445                 "Offset to RLA_C for cell re selection to FDD access technology (FDD Qoffset)", HFILL }
9446         },
9447         { &hf_gsm_a_rr_fdd_qmin,
9448           { "FDD Qmin", "gsm_a.rr.fdd_qmin",
9449                 FT_UINT8, BASE_DEC,  VALS(gsm_a_rr_fdd_qmin_vals), 0x00,
9450                 "Minimum threshold for Ec/No for UTRAN FDD cell re-selection (FDD Qmin)", HFILL }
9451         },
9452         { &hf_gsm_a_rr_tdd_qoffset,
9453           { "TDD Qoffset", "gsm_a.rr.tdd_qoffset",
9454                 FT_UINT8, BASE_DEC,  VALS(gsm_a_rr_xdd_qoffset_vals), 0x00,
9455                 "Offset to RLA_C for cell re selection to TDD access technology (TDD Qoffset)", HFILL }
9456         },
9457         { &hf_gsm_a_rr_fdd_qmin_offset,
9458           { "FDD Qmin Offset", "gsm_a.rr.fdd_qmin_offset",
9459                 FT_UINT8, BASE_DEC,  VALS(gsm_a_rr_fdd_qmin_offset_vals), 0x00,
9460                 "Offset to FDD Qmin value (FDD Qmin Offset)", HFILL }
9461         },
9462         { &hf_gsm_a_rr_fdd_rscpmin,
9463           { "FDD RSCPmin", "gsm_a.rr.fdd_rscpmin",
9464                 FT_UINT8, BASE_DEC,  VALS(gsm_a_rr_fdd_rscpmin_vals), 0x00,
9465                 "Minimum threshold of RSCP for UTRAN FDD cell re-selection (FDD RSCPmin)", HFILL }
9466         },
9467         { &hf_gsm_a_rr_3g_ba_ind,
9468           { "3G BA-IND", "gsm_a.rr.3g_ba_ind",
9469                 FT_UINT8, BASE_DEC,  NULL, 0x00,
9470                 "3G BCCH Allocation Indication (3G BA-IND)", HFILL }
9471         },
9472         { &hf_gsm_a_rr_mp_change_mark,
9473           { "Measurement Parameter Change Mark", "gsm_a.rr.mp_change_mark",
9474                 FT_UINT8, BASE_DEC,  NULL, 0x00,
9475                 "Measurement Parameter Change Mark", HFILL }
9476         },
9477         { &hf_gsm_a_rr_si2quater_index,
9478           { "SI2quater Index", "gsm_a.rr.si2quater_index",
9479                 FT_UINT8, BASE_DEC,  NULL, 0x00,
9480                 "SI2quater Index", HFILL }
9481         },
9482         { &hf_gsm_a_rr_si2quater_count,
9483           { "SI2quater Count", "gsm_a.rr.si2quater_count",
9484                 FT_UINT8, BASE_DEC,  NULL, 0x00,
9485                 "SI2quater Count", HFILL }
9486         },
9487         { &hf_gsm_a_rr_gsm_report_type,
9488           { "Report Type", "gsm_a.rr.gsm_report_type",
9489                 FT_BOOLEAN, BASE_DEC,  TFS(&gsm_a_rr_gsm_report_type_value), 0x00,
9490                 "Report type the MS shall use (Report Type)", HFILL }
9491         },
9492         { &hf_gsm_a_rr_serving_band_reporting,
9493           { "Serving Band Reporting", "gsm_a.rr.serving_band_reporting",
9494                 FT_UINT8, BASE_DEC, NULL, 0x00,
9495                 "Number of cells reported from the GSM serving frequency band (Serving Band Reporting)", HFILL }
9496         },
9497         { &hf_gsm_a_rr_frequency_scrolling,
9498           { "Frequency Scrolling", "gsm_a.rr.frequency_scrolling",
9499                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_frequency_scrolling_value), 0x00,
9500                 "Frequency Scrolling", HFILL }
9501         },
9502         { &hf_gsm_a_rr_rep_priority,
9503           { "Rep Priority", "gsm_a.rr.rep_priority",
9504                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_rep_priority_value), 0x00,
9505                 "Reporting Priority", HFILL }
9506         },
9507         { &hf_gsm_a_rr_report_type,
9508           { "Report Type", "gsm_a.rr.report_type",
9509                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_report_type_value), 0x00,
9510                 "Report Type", HFILL }
9511         },
9512         { &hf_gsm_a_rr_reporting_rate,
9513           { "Reporting Rate", "gsm_a.rr.reporting_rate",
9514                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_reporting_rate_value), 0x00,
9515                 "Reporting Rate", HFILL }
9516         },
9517         { &hf_gsm_a_rr_invalid_bsic_reporting,
9518           { "Invalid BSIC Reporting", "gsm_a.rr.invalid_bsic_reporting",
9519                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_invalid_bsic_reporting_value), 0x00,
9520                 "Invalid BSIC Reporting", HFILL }
9521         },
9522         { &hf_gsm_a_rr_scale_ord,
9523           { "Scale Ord", "gsm_a.rr.scale_ord",
9524                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_scale_ord_vals), 0x00,
9525                 "Offset used for the reported RXLEV values (Scale Ord)", HFILL }
9526         },
9527         { &hf_gsm_a_rr_900_reporting_offset,
9528           { "900 Reporting Offset", "gsm_a.rr.900_reporting_offset",
9529                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_xxx_reporting_offset_vals), 0x00,
9530                 "Offset to the reported value when prioritising the cells for reporting for GSM frequency band 900 (900 Reporting Offset)", HFILL }
9531         },
9532         { &hf_gsm_a_rr_900_reporting_threshold,
9533           { "900 Reporting Threshold", "gsm_a.rr.900_reporting_threshold",
9534                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_xxx_reporting_threshold_vals), 0x00,
9535                 "Apply priority reporting if the reported value is above threshold for GSM frequency band 900 (900 Reporting Threshold)", HFILL }
9536         },
9537         { &hf_gsm_a_rr_1800_reporting_offset,
9538           { "1800 Reporting Offset", "gsm_a.rr.1800_reporting_offset",
9539                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_xxx_reporting_offset_vals), 0x00,
9540                 "Offset to the reported value when prioritising the cells for reporting for GSM frequency band 1800 (1800 Reporting Offset)", HFILL }
9541         },
9542         { &hf_gsm_a_rr_1800_reporting_threshold,
9543           { "1800 Reporting Threshold", "gsm_a.rr.1800_reporting_threshold",
9544                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_xxx_reporting_threshold_vals), 0x00,
9545                 "Apply priority reporting if the reported value is above threshold for GSM frequency band 1800 (1800 Reporting Threshold)", HFILL }
9546         },
9547         { &hf_gsm_a_rr_400_reporting_offset,
9548           { "400 Reporting Offset", "gsm_a.rr.400_reporting_offset",
9549                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_xxx_reporting_offset_vals), 0x00,
9550                 "Offset to the reported value when prioritising the cells for reporting for GSM frequency band 400 (400 Reporting Offset)", HFILL }
9551         },
9552         { &hf_gsm_a_rr_400_reporting_threshold,
9553           { "400 Reporting Threshold", "gsm_a.rr.400_reporting_threshold",
9554                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_xxx_reporting_threshold_vals), 0x00,
9555                 "Apply priority reporting if the reported value is above threshold for GSM frequency band 400 (400 Reporting Threshold)", HFILL }
9556         },
9557         { &hf_gsm_a_rr_1900_reporting_offset,
9558           { "1900 Reporting Offset", "gsm_a.rr.1900_reporting_offset",
9559                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_xxx_reporting_offset_vals), 0x00,
9560                 "Offset to the reported value when prioritising the cells for reporting for GSM frequency band 1900 (1900 Reporting Offset)", HFILL }
9561         },
9562         { &hf_gsm_a_rr_1900_reporting_threshold,
9563           { "1900 Reporting Threshold", "gsm_a.rr.1900_reporting_threshold",
9564                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_xxx_reporting_threshold_vals), 0x00,
9565                 "Apply priority reporting if the reported value is above threshold for GSM frequency band 1900 (1900 Reporting Threshold)", HFILL }
9566         },
9567         { &hf_gsm_a_rr_850_reporting_offset,
9568           { "850 Reporting Offset", "gsm_a.rr.850_reporting_offset",
9569                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_xxx_reporting_offset_vals), 0x00,
9570                 "Offset to the reported value when prioritising the cells for reporting for GSM frequency band 850 (850 Reporting Offset)", HFILL }
9571         },
9572         { &hf_gsm_a_rr_850_reporting_threshold,
9573           { "850 Reporting Threshold", "gsm_a.rr.900_reporting_threshold",
9574                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_xxx_reporting_threshold_vals), 0x00,
9575                 "Apply priority reporting if the reported value is above threshold for GSM frequency band 850 (850 Reporting Threshold)", HFILL }
9576         },
9577         { &hf_gsm_a_rr_network_control_order,
9578           { "Network Control Order", "gsm_a.rr.network_control_order",
9579                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_network_control_order_vals), 0x00,
9580                 "Network Control Order", HFILL }
9581         },
9582         { &hf_gsm_a_rr_nc_non_drx_period,
9583           { "NC Non DRX Period", "gsm_a.rr.nc_non_drx_period",
9584                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_nc_non_drx_period_vals), 0x00,
9585                 "NC Non DRX Period", HFILL }
9586         },
9587         { &hf_gsm_a_rr_nc_reporting_period_i,
9588           { "NC Reporting Period I", "gsm_a.rr.nc_reporting_period_i",
9589                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_nc_reporting_period_x_vals), 0x00,
9590                 "NC Reporting Period in Packet Idle mode (NC Reporting Period I)", HFILL }
9591         },
9592         { &hf_gsm_a_rr_nc_reporting_period_t,
9593           { "NC Reporting Period T", "gsm_a.rr.nc_reporting_period_t",
9594                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_nc_reporting_period_x_vals), 0x00,
9595                 "NC Reporting Period in Packet Transfer mode (NC Reporting Period T)", HFILL }
9596         },
9597         { &hf_gsm_a_rr_index_start_3g,
9598           { "Index Start 3G", "gsm_a.rr.index_start_3g",
9599                 FT_UINT8, BASE_DEC, NULL, 0x00,
9600                 "Index Start 3G", HFILL }
9601         },
9602         { &hf_gsm_a_rr_absolute_index_start_emr,
9603           { "Absolute Index Start EMR", "gsm_a.rr.absolute_index_start_emr",
9604                 FT_UINT8, BASE_DEC, NULL, 0x00,
9605                 "Absolute Index Start EMR", HFILL }
9606         },
9607         { &hf_gsm_a_rr_qsearch_c_initial,
9608           { "QSearch C Initial", "gsm_a.rr.qsearch_c_initial",
9609                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_qsearch_c_initial_value), 0x00,
9610                 "Qsearch value to be used in connected mode before Qsearch C is received (QSearch C Initial)", HFILL }
9611         },
9612         { &hf_gsm_a_rr_fdd_rep_quant,
9613           { "FDD Rep Quant", "gsm_a.rr.fdd_rep_quant",
9614                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_fdd_rep_quant_value), 0x00,
9615                 "FDD Reporting Quantity (FDD Rep Quant)", HFILL }
9616         },
9617         { &hf_gsm_a_rr_fdd_multirat_reporting,
9618           { "FDD Multirat Reporting", "gsm_a.rr.fdd_multirat_reporting",
9619                 FT_UINT8, BASE_DEC, NULL, 0x00,
9620                 "Number of cells from the FDD access technology that shall be included in the list of strongest cells or in the measurement report (FDD Multirat Reporting)", HFILL }
9621         },
9622         { &hf_gsm_a_rr_tdd_multirat_reporting,
9623           { "TDD Multirat Reporting", "gsm_a.rr.tdd_multirat_reporting",
9624                 FT_UINT8, BASE_DEC, NULL, 0x00,
9625                 "Number of cells from the TDD access technology that shall be included in the list of strongest cells or in the measurement report (TDD Multirat Reporting)", HFILL }
9626         },
9627         { &hf_gsm_a_rr_qsearch_p,
9628           { "Qsearch P", "gsm_a.rr.qsearch_p",
9629                 FT_UINT8, BASE_DEC,  VALS(gsm_a_rr_qsearch_x_vals), 0x00,
9630                 "Search for 3G cells if signal level below threshold (Qsearch P)", HFILL }
9631         },
9632         { &hf_gsm_a_rr_3g_search_prio,
9633           { "3G Search Prio", "gsm_a.rr.3g_search_prio",
9634                 FT_BOOLEAN, BASE_DEC,  TFS(&gsm_a_rr_3g_search_prio_value), 0x00,
9635                 "3G Search Priority", HFILL }
9636         },
9637         { &hf_gsm_a_rr_fdd_reporting_offset,
9638           { "FDD Reporting Offset", "gsm_a.rr.fdd_reporting_offset",
9639                 FT_UINT8, BASE_DEC,  VALS(gsm_a_rr_xxx_reporting_offset_vals), 0x00,
9640                 "Offset to the reported value when prioritising the cells for reporting for FDD access technology (FDD Reporting Offset)", HFILL }
9641         },
9642         { &hf_gsm_a_rr_fdd_reporting_threshold,
9643           { "FDD Reporting Threshold", "gsm_a.rr.fdd_reporting_threshold",
9644                 FT_UINT8, BASE_DEC,  VALS(gsm_a_rr_xxx_reporting_threshold_vals), 0x00,
9645                 "Apply priority reporting if the reported value is above threshold for FDD access technology (FDD Reporting Threshold)", HFILL }
9646         },
9647         { &hf_gsm_a_rr_tdd_reporting_offset,
9648           { "TDD Reporting Offset", "gsm_a.rr.tdd_reporting_offset",
9649                 FT_UINT8, BASE_DEC,  VALS(gsm_a_rr_xxx_reporting_offset_vals), 0x00,
9650                 "Offset to the reported value when prioritising the cells for reporting for TDD access technology (TDD Reporting Offset)", HFILL }
9651         },
9652         { &hf_gsm_a_rr_tdd_reporting_threshold,
9653           { "TDD Reporting Threshold", "gsm_a.rr.tdd_reporting_threshold",
9654                 FT_UINT8, BASE_DEC,  VALS(gsm_a_rr_xxx_reporting_threshold_vals), 0x00,
9655                 "Apply priority reporting if the reported value is above threshold for TDD access technology (TDD Reporting Threshold)", HFILL }
9656         },
9657         { &hf_gsm_a_rr_fdd_reporting_threshold_2,
9658           { "FDD Reporting Threshold 2", "gsm_a.rr.fdd_reporting_threshold_2",
9659                 FT_UINT8, BASE_DEC,  NULL, 0x00,
9660                 "Reporting threshold for the CPICH parameter (Ec/No or RSCP) that is not reported according to FDD_REP_QUANT (FDD Reporting Threshold 2)", HFILL }
9661         },
9662         { &hf_gsm_a_rr_3g_ccn_active,
9663           { "3G CCN Active", "gsm_a.rr.3g_ccn_active",
9664                 FT_BOOLEAN, BASE_DEC,  TFS(&gsm_a_rr_3g_ccn_active_value), 0x00,
9665                 "3G CCN Active", HFILL }
9666         },
9667         { &hf_gsm_a_rr_700_reporting_offset,
9668           { "700 Reporting Offset", "gsm_a.rr.700_reporting_offset",
9669                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_xxx_reporting_offset_vals), 0x00,
9670                 "Offset to the reported value when prioritising the cells for reporting for GSM frequency band 700 (700 Reporting Offset)", HFILL }
9671         },
9672         { &hf_gsm_a_rr_700_reporting_threshold,
9673           { "700 Reporting Threshold", "gsm_a.rr.700_reporting_threshold",
9674                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_xxx_reporting_threshold_vals), 0x00,
9675                 "Apply priority reporting if the reported value is above threshold for GSM frequency band 700 (700 Reporting Threshold)", HFILL }
9676         },
9677         { &hf_gsm_a_rr_810_reporting_offset,
9678           { "810 Reporting Offset", "gsm_a.rr.810_reporting_offset",
9679                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_xxx_reporting_offset_vals), 0x00,
9680                 "Offset to the reported value when prioritising the cells for reporting for GSM frequency band 810 (810 Reporting Offset)", HFILL }
9681         },
9682         { &hf_gsm_a_rr_810_reporting_threshold,
9683           { "810 Reporting Threshold", "gsm_a.rr.810_reporting_threshold",
9684                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_xxx_reporting_threshold_vals), 0x00,
9685                 "Apply priority reporting if the reported value is above threshold for GSM frequency band 810 (810 Reporting Threshold)", HFILL }
9686         },
9687         { &hf_gsm_a_rr_cbq,
9688           { "CBQ", "gsm_a.rr.cbq",
9689                 FT_UINT8, BASE_DEC,  NULL, 0x00,
9690                 "Cell Bar Qualify", HFILL }
9691         },
9692         { &hf_gsm_a_rr_cell_reselect_offset,
9693           { "Cell Reselect Offset", "gsm_a.rr.cell_reselect_offset",
9694                 FT_UINT8, BASE_DEC,  VALS(gsm_a_rr_cell_reselect_offset_vals), 0x00,
9695                 "Offset to the C2 reselection criterion (Cell Reselect Offset)", HFILL }
9696         },
9697         { &hf_gsm_a_rr_temporary_offset,
9698                 { "Temporary Offset", "gsm_a.rr.temporary_offset",
9699                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_temporary_offset_vals), 0x0,
9700                 "Negative offset to C2 for the duration of Penalty Time (Temporary Offset)", HFILL }
9701         },
9702         { &hf_gsm_a_rr_penalty_time,
9703                 { "Penalty Time", "gsm_a.rr.penalty_time",
9704                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_penalty_time_vals), 0x0,
9705                 "Duration for which the temporary offset is applied (Penalty Time)", HFILL }
9706         },
9707         { &hf_gsm_a_rr_si13_position,
9708                 { "SI13 Position", "gsm_a.rr.si13_position",
9709                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_si13_position_vals), 0x0,
9710                 "SI13 Position", HFILL }
9711         },
9712         { &hf_gsm_a_rr_power_offset,
9713                 { "Power Offset", "gsm_a.rr.power_offset",
9714                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_power_offset_vals), 0x0,
9715                 "Power offset used in conjunction with the MS TXPWR MAX CCH parameter by the class 3 DCS 1800 MS (Power Offset)", HFILL }
9716         },
9717         { &hf_gsm_a_rr_si2quater_position,
9718                 { "SI2quater Position", "gsm_a.rr.si2quater_position",
9719                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_si2quater_position_value), 0x0,
9720                 "SI2quater Position", HFILL }
9721         },
9722         { &hf_gsm_a_rr_si13alt_position,
9723                 { "SI13alt Position", "gsm_a.rr.si13alt_position",
9724                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_si13alt_position_value), 0x0,
9725                 "SI13alt Position", HFILL }
9726         },
9727         { &hf_gsm_a_rr_prio_thr,
9728                 { "Prio Thr", "gsm_a.rr.prio_thr",
9729                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_prio_thr_vals), 0x0,
9730                 "Prio signal strength threshold is related to RXLEV ACCESS_MIN (Prio Thr)", HFILL }
9731         },
9732         { &hf_gsm_a_rr_lsa_offset,
9733                 { "LSA Offset", "gsm_a.rr.lsa_offset",
9734                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_lsa_offset_vals), 0x0,
9735                 "Offset to be used for LSA cell re selection between cells with the same LSA priorities (LSA Offset)", HFILL }
9736         },
9737         { &hf_gsm_a_rr_paging_channel_restructuring,
9738                 { "Paging Channel Restructuring", "gsm_a.rr.paging_channel_restructuring",
9739                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_paging_channel_restructuring_value), 0x0,
9740                 "Paging Channel Restructuring", HFILL }
9741         },
9742         { &hf_gsm_a_rr_nln_sacch,
9743                 { "NLN (SACCH)", "gsm_a.rr.nln_sacch",
9744                 FT_UINT8, BASE_DEC, NULL, 0x0,
9745                 "NLN (SACCH)", HFILL }
9746         },
9747         { &hf_gsm_a_rr_nln_status_sacch,
9748                 { "NLN Status (SACCH)", "gsm_a.rr.nln_status_sacch",
9749                 FT_UINT8, BASE_DEC, NULL, 0x0,
9750                 "NLN Status (SACCH)", HFILL }
9751         },
9752         { &hf_gsm_a_rr_nln_pch,
9753                 { "NLN (PCH)", "gsm_a.rr.nln_pch",
9754                 FT_UINT8, BASE_DEC, NULL, 0x0,
9755                 "NLN (PCH)", HFILL }
9756         },
9757         { &hf_gsm_a_rr_nln_status_pch,
9758                 { "NLN Status (PCH)", "gsm_a.rr.nln_status_pch",
9759                 FT_UINT8, BASE_DEC, NULL, 0x0,
9760                 "NLN Status (PCH)", HFILL }
9761         },
9762         { &hf_gsm_a_rr_vbs_vgcs_inband_notifications,
9763                 { "Inband Notifications", "gsm_a.rr.vbs_vgcs_inband_notifications",
9764                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_vbs_vgcs_inband_notifications_value), 0x0,
9765                 "Inband Notifications", HFILL }
9766         },
9767         { &hf_gsm_a_rr_vbs_vgcs_inband_pagings,
9768                 { "Inband Pagings", "gsm_a.rr.vbs_vgcs_inband_pagings",
9769                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_vbs_vgcs_inband_pagings_value), 0x0,
9770                 "Inband Pagings", HFILL }
9771         },
9772         { &hf_gsm_a_rr_rac,
9773                 { "RAC", "gsm_a.rr.rac",
9774                 FT_UINT8, BASE_DEC, NULL, 0x0,
9775                 "Routeing Area Code", HFILL }
9776         },
9777         { &hf_gsm_a_rr_max_lapdm,
9778                 { "Max LAPDm", "gsm_a.rr.max_lapdm",
9779                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_max_lapdm_vals), 0x0,
9780                 "Maximum number of LAPDm frames on which a layer 3 can be segmented into and be sent on the main DCCH (Max LAPDm)", HFILL }
9781         },
9782         { &hf_gsm_a_rr_gprs_ms_txpwr_max_ccch,
9783           { "GPRS MS TxPwr Max CCH", "gsm_a.rr.gprs_ms_txpwr_max_cch",
9784                 FT_UINT8, BASE_DEC,  NULL, 0x00,
9785                 "GPRS MS TxPwr Max CCH", HFILL }
9786         },
9787         { &hf_gsm_a_rr_dedicated_mode_mbms_notification_support,
9788                 { "Dedicated Mode MBMS Notification Support", "gsm_a.rr.dedicated_mode_mbms_notification_support",
9789                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_dedicated_mode_mbms_notification_support_value), 0x0,
9790                 "Dedicated Mode MBMS Notification Support", HFILL }
9791         },
9792         { &hf_gsm_a_rr_mnci_support,
9793                 { "MNCI Support", "gsm_a.rr.mnci_support",
9794                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_mnci_support_value), 0x0,
9795                 "MBMS Neighbouring Cell Information Support (MNCI Support)", HFILL }
9796         },
9797         { &hf_gsm_a_rr_amr_config,
9798                 { "AMR Configuration", "gsm_a.rr.amr_config",
9799                 FT_UINT8, BASE_DEC, NULL, 0x0,
9800                 "AMR Configuration", HFILL }
9801         },
9802         { &hf_gsm_a_rr_bcch_change_mark,
9803                 { "BCCH Change Mark", "gsm_a.rr.bcch_change_mark",
9804                 FT_UINT8, BASE_DEC, NULL, 0x0,
9805                 "BCCH Change Mark", HFILL }
9806         },
9807         { &hf_gsm_a_rr_si_change_field,
9808                 { "SI Change Field", "gsm_a.rr.si_change_field",
9809                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_si_change_field_vals), 0x0,
9810                 "SI Change Field", HFILL }
9811         },
9812         { &hf_gsm_a_rr_si13_change_mark,
9813                 { "SI13 Change Mark", "gsm_a.rr.si13_change_mark",
9814                 FT_UINT8, BASE_DEC, NULL, 0x0,
9815                 "SI13 Change Mark", HFILL }
9816         },
9817         { &hf_gsm_a_rr_hsn,
9818                 { "HSN", "gsm_a.rr.hsn",
9819                 FT_UINT8, BASE_DEC, NULL, 0x0,
9820                 "Hopping Sequence Number (HSN)", HFILL }
9821         },
9822         { &hf_gsm_a_rr_rfl_number,
9823                 { "RFL Number", "gsm_a.rr.rfl_number",
9824                 FT_UINT8, BASE_DEC, NULL, 0x0,
9825                 "Radio Frequency List Number (RFL Number)", HFILL }
9826         },
9827         { &hf_gsm_a_rr_arfcn_index,
9828                 { "ARFCN Index", "gsm_a.rr.arfcn_index",
9829                 FT_UINT8, BASE_DEC, NULL, 0x0,
9830                 "ARFCN Index", HFILL }
9831         },
9832         { &hf_gsm_a_rr_ma_length,
9833                 { "MA Length", "gsm_a.rr.ma_length",
9834                 FT_UINT8, BASE_DEC, NULL, 0x0,
9835                 "Mobile Allocation Length (MA Length)", HFILL }
9836         },
9837         { &hf_gsm_a_rr_psi1_repeat_period,
9838                 { "PSI1 Repeat Period", "gsm_a.rr.psi1_repeat_period",
9839                 FT_UINT8, BASE_DEC, VALS(&gsm_a_rr_psi1_repeat_period_vals), 0x0,
9840                 "PSI1 Repeat Period", HFILL }
9841         },
9842         { &hf_gsm_a_rr_pbcch_pb,
9843                 { "Pb", "gsm_a.rr.pbcch_pb",
9844                 FT_UINT8, BASE_DEC, VALS(&gsm_a_rr_pbcch_pb_vals), 0x0,
9845                 "Power reduction on PBCCH/PCCCH (Pb)", HFILL }
9846         },
9847         { &hf_gsm_a_rr_pbcch_tsc,
9848                 { "TSC", "gsm_a.rr.pbcch_tsc",
9849                 FT_UINT8, BASE_DEC, NULL, 0x0,
9850                 "Training Sequence Code for PBCCH (TSC)", HFILL }
9851         },
9852         { &hf_gsm_a_rr_pbcch_tn,
9853                 { "TN", "gsm_a.rr.pbcch_tn",
9854                 FT_UINT8, BASE_DEC, NULL, 0x0,
9855                 "Timeslot Number for PCCH (TN)", HFILL }
9856         },
9857         { &hf_gsm_a_rr_spgc_ccch_sup,
9858                 { "SPGC CCCH Sup", "gsm_a.rr.spgc_ccch_sup",
9859                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_spgc_ccch_sup_value), 0x0,
9860                 "Split PG Cycle Code on CCCH Support (SPGC CCCH Sup)", HFILL }
9861         },
9862         { &hf_gsm_a_rr_priority_access_thr,
9863                 { "Priority Access Thr", "gsm_a.rr.priority_access_thr",
9864                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_priority_access_thr_vals), 0x0,
9865                 "Priority Access Threshold for packet access (Priority Access Thr)", HFILL }
9866         },
9867         { &hf_gsm_a_rr_nmo,
9868                 { "NMO", "gsm_a.rr.nmo",
9869                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_nmo_vals), 0x0,
9870                 "Network mode of Operation (NMO)", HFILL }
9871         },
9872         { &hf_gsm_a_rr_t3168,
9873                 { "T3168", "gsm_a.rr.t3168",
9874                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_t3168_vals), 0x0,
9875                 "T3168", HFILL }
9876         },
9877         { &hf_gsm_a_rr_t3192,
9878                 { "T3192", "gsm_a.rr.t3192",
9879                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_t3192_vals), 0x0,
9880                 "T3192", HFILL }
9881         },
9882         { &hf_gsm_a_rr_drx_timer_max,
9883                 { "DRX Timer Max", "gsm_a.rr.drx_timer_max",
9884                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_drx_timer_max_vals), 0x0,
9885                 "Discontinous Reception Timer Max (DRX Timer Max)", HFILL }
9886         },
9887         { &hf_gsm_a_rr_access_burst_type,
9888                 { "Access Burst Type", "gsm_a.rr.access_burst_type",
9889                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_access_burst_type_value), 0x0,
9890                 "Format used in the PACKET CHANNEL REQUEST message, the PS HANDOVER ACCESS message, the PTCCH uplink block and in the PACKET CONTROL ACKNOWLEDGMENT message (Access Burst Type)", HFILL }
9891         },
9892         { &hf_gsm_a_rr_control_ack_type,
9893                 { "Control Ack Type", "gsm_a.rr.control_ack_type",
9894                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_control_ack_type_value), 0x0,
9895                 "Default format of the PACKET CONTROL ACKNOWLEDGMENT message (Control Ack Type)", HFILL }
9896         },
9897         { &hf_gsm_a_rr_bs_cv_max,
9898                 { "BS CV Max", "gsm_a.rr.bs_cv_max",
9899                 FT_UINT8, BASE_DEC, NULL, 0x0,
9900                 "Base Station Countdown Value Maximum (BS CV Max)", HFILL }
9901         },
9902         { &hf_gsm_a_rr_pan_dec,
9903                 { "PAN Dec", "gsm_a.rr.pan_dec",
9904                 FT_UINT8, BASE_DEC, NULL, 0x0,
9905                 "PAN Dec", HFILL }
9906         },
9907         { &hf_gsm_a_rr_pan_inc,
9908                 { "PAN Inc", "gsm_a.rr.pan_inc",
9909                 FT_UINT8, BASE_DEC, NULL, 0x0,
9910                 "PAN Inc", HFILL }
9911         },
9912         { &hf_gsm_a_rr_pan_max,
9913                 { "PAN Max", "gsm_a.rr.pan_max",
9914                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_pan_max_vals), 0x0,
9915                 "PAN Max", HFILL }
9916         },
9917         { &hf_gsm_a_rr_egprs_packet_channel_request,
9918                 { "EGPRS Packet Channel Request", "gsm_a.rr.egprs_packet_channel_request",
9919                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_egprs_packet_channel_request_value), 0x0,
9920                 "EGPRS Packet Channel Request", HFILL }
9921         },
9922         { &hf_gsm_a_rr_bep_period,
9923                 { "BEP Period", "gsm_a.rr.bep_period",
9924                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_bep_period_vals), 0x0,
9925                 "BEP Period", HFILL }
9926         },
9927         { &hf_gsm_a_rr_pfc_feature_mode,
9928                 { "PFC Feature Mode", "gsm_a.rr.pfc_feature_mode",
9929                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_pfc_feature_mode_value), 0x0,
9930                 "Packet Flow Context Feature Mode (PFC Feature Mode)", HFILL }
9931         },
9932         { &hf_gsm_a_rr_dtm_support,
9933                 { "DTM Support", "gsm_a.rr.dtm_support",
9934                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_dtm_support_value), 0x0,
9935                 "Dual Transfer Mode Support (DTM Support)", HFILL }
9936         },
9937         { &hf_gsm_a_rr_bss_paging_coordination,
9938                 { "BSS Paging Coordination", "gsm_a.rr.bss_paging_coordination",
9939                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_bss_paging_coordination_value), 0x0,
9940                 "BSS Paging Coordination", HFILL }
9941         },
9942         { &hf_gsm_a_rr_ccn_active,
9943                 { "CCN Active", "gsm_a.rr.ccn_active",
9944                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_ccn_active_value), 0x0,
9945                 "CCN Active", HFILL }
9946         },
9947         { &hf_gsm_a_rr_nw_ext_utbf,
9948                 { "NW Ext UTBF", "gsm_a.rr.nw_ext_utbf",
9949                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_nw_ext_utbf_value), 0x0,
9950                 "Network Extended Uplink TBF (NW Ext UTBF)", HFILL }
9951         },
9952         { &hf_gsm_a_rr_multiple_tbf_capability,
9953                 { "Multiple TBF Capability", "gsm_a.rr.multiple_tbf_capability",
9954                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_multiple_tbf_capability_value), 0x0,
9955                 "Multiple TBF Capability", HFILL }
9956         },
9957         { &hf_gsm_a_rr_ext_utbf_no_data,
9958                 { "Ext UTBF No Data", "gsm_a.rr.ext_utbf_no_data",
9959                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_ext_utbf_no_data_value), 0x0,
9960                 "Ext UTBF No Data", HFILL }
9961         },
9962         { &hf_gsm_a_rr_dtm_enhancements_capability,
9963                 { "DTM Enhancements Capability", "gsm_a.rr.dtm_enhancements_capability",
9964                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_dtm_enhancements_capability_value), 0x0,
9965                 "DTM Enhancements Capability", HFILL }
9966         },
9967         { &hf_gsm_a_rr_reduced_latency_access,
9968                 { "Reduced Latency Access", "gsm_a.rr.reduced_latency_access",
9969                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_reduced_latency_access_value), 0x0,
9970                 "Reduced Latency Access", HFILL }
9971         },
9972         { &hf_gsm_a_rr_alpha,
9973                 { "Alpha", "gsm_a.rr.alpha",
9974                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_alpha_vals), 0x0,
9975                 "Alpha parameter for GPR MS output power control (Alpha)", HFILL }
9976         },
9977         { &hf_gsm_a_rr_t_avg_w,
9978                 { "T Avg W", "gsm_a.rr.t_avg_w",
9979                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_t_avg_x_vals), 0x0,
9980                 "Signal strength filter period for power control in packet idle mode ", HFILL }
9981         },
9982         { &hf_gsm_a_rr_t_avg_t,
9983                 { "T Avg T", "gsm_a.rr.t_avg_t",
9984                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_t_avg_x_vals), 0x0,
9985                 "Signal strength filter period for power control in packet transfer mode ", HFILL }
9986         },
9987         { &hf_gsm_a_rr_pc_meas_chan,
9988                 { "PC Meas Chan", "gsm_a.rr.pc_meas_chan",
9989                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_pc_meas_chan_value), 0x0,
9990                 "Channel used to measure the received power level on the downlink for the purpose of the uplink power control (PC Meas Chan)", HFILL }
9991         },
9992         { &hf_gsm_a_rr_n_avg_i,
9993                 { "N Avg I", "gsm_a.rr.n_avg_i",
9994                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_n_avg_i_vals), 0x0,
9995                 "Interfering signal strength filter constant for power control (N Avg I)", HFILL }
9996         },
9997         { &hf_gsm_a_rr_sgsnr,
9998                 { "SGSNR", "gsm_a.rr.sgsnr",
9999                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_sgsnr_value), 0x0,
10000                 "SGSN Release (SGSNR)", HFILL }
10001         },
10002         { &hf_gsm_a_rr_si_status_ind,
10003                 { "SI Status Ind", "gsm_a.rr.si_status_ind",
10004                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_si_status_ind_value), 0x0,
10005                 "SI Status Ind", HFILL }
10006         },
10007         { &hf_gsm_a_rr_lb_ms_txpwr_max_cch,
10008                 { "LB MS TxPwr Max CCCH", "gsm_a.rr.n_avg_i",
10009                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_n_avg_i_vals), 0x0,
10010                 "Maximum TX power level an MS is allowed to use on all other than DCS 1800 and PCS 1900 frequency bands when accessing the system until otherwise commanded (LB MS TxPwr Max CCCH)", HFILL }
10011         },
10012         { &hf_gsm_a_rr_si2n_support,
10013                 { "SI2n Support", "gsm_a.rr.si2n_support",
10014                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_si2n_support_vals), 0x0,
10015                 "SI2n Support", HFILL }
10016         },
10017         { &hf_gsm_a_rr_mi_index,
10018                 { "Measurement Information Index", "gsm_a.rr.mi_index",
10019                 FT_UINT8, BASE_DEC, NULL, 0x0,
10020                 "Measurement Information Index", HFILL }
10021         },
10022         { &hf_gsm_a_rr_mi_count,
10023                 { "Measurement Information Count", "gsm_a.rr.mi_count",
10024                 FT_UINT8, BASE_DEC, NULL, 0x0,
10025                 "Measurement Information Count", HFILL }
10026         },
10027         { &hf_gsm_a_rr_3g_wait,
10028                 { "3G Wait", "gsm_a.rr.3g_wait",
10029                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_3g_wait_vals), 0x0,
10030                 "3G Wait", HFILL }
10031         },
10032         { &hf_gsm_a_rr_qsearch_c,
10033           { "Qsearch C", "gsm_a.rr.qsearch_c",
10034                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_qsearch_x_vals), 0x00,
10035                 "Search for 3G cells if signal level is below (0 7) or above (8 15) threshold (Qsearch C)", HFILL }
10036         },
10037         { &hf_gsm_a_rr_bsic_seen,
10038           { "BSIC Seen", "gsm_a.rr.bsic_seen",
10039                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_bsic_seen_value), 0x00,
10040                 "BSIC Seen", HFILL }
10041         },
10042         { &hf_gsm_a_rr_scale,
10043           { "Scale", "gsm_a.rr.scale",
10044                 FT_BOOLEAN, BASE_DEC, TFS(&gsm_a_rr_scale_value), 0x00,
10045                 "Offset applied for the reported RXLEV values (Scale)", HFILL }
10046         },
10047         { &hf_gsm_a_rr_mean_bep_gmsk,
10048           { "Mean BEP GMSK", "gsm_a.rr.mean_bep_gmsk",
10049                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_mean_bep_gmsk_vals), 0x00,
10050                 "Mean Bit Error Probability in GMSK (Mean BEP GMSK)", HFILL }
10051         },
10052         { &hf_gsm_a_rr_mean_cv_bep,
10053           { "CV BEP", "gsm_a.rr.cv_bep",
10054                 FT_UINT8, BASE_DEC, VALS(gsm_a_rr_cv_bep_vals), 0x00,
10055                 "Coefficient of Variation of the Bit Error Probability (CV BEP)", HFILL }
10056         },
10057         { &hf_gsm_a_rr_nbr_rcvd_blocks,
10058           { "Nb Rcvd Blocks", "gsm_a.rr.nbr_rcvd_blocks",
10059                 FT_UINT8, BASE_DEC, NULL, 0x00,
10060                 "Number of correctly decoded blocks that were completed during the measurement report period (Nb Rcvd Blocks)", HFILL }
10061         },
10062         { &hf_gsm_a_rr_reporting_quantity,
10063           { "Reporting Quantity", "gsm_a.rr.reporting_quantity",
10064                 FT_UINT8, BASE_DEC, NULL, 0x00,
10065                 "Reporting Quantity", HFILL }
10066         }
10067         };
10068
10069         static hf_register_info hf_sacch[] =
10070         {
10071         { &hf_gsm_a_sacch_msg_rr_type,
10072                 { "SACCH Radio Resources Management Message Type",      "gsm_a.sacch_msg_rr_type",
10073                 FT_UINT8, BASE_HEX, VALS(gsm_a_sacch_msg_rr_strings), 0x0,
10074                 "", HFILL }
10075         }
10076         };
10077
10078         /* Setup protocol subtree array */
10079 #define NUM_INDIVIDUAL_ELEMS    3
10080         static gint *ett[NUM_INDIVIDUAL_ELEMS +
10081                         NUM_GSM_DTAP_MSG_RR +
10082                         NUM_GSM_RR_ELEM +
10083                         NUM_GSM_RR_REST_OCTETS_ELEM +
10084          NUM_GSM_SACCH_MSG_RR];
10085
10086         ett[0] = &ett_ccch_msg;
10087         ett[1] = &ett_ccch_oct_1;
10088    ett[2] = &ett_sacch_msg;
10089
10090         last_offset = NUM_INDIVIDUAL_ELEMS;
10091
10092         for (i=0; i < NUM_GSM_DTAP_MSG_RR; i++, last_offset++)
10093         {
10094                 ett_gsm_dtap_msg_rr[i] = -1;
10095                 ett[last_offset] = &ett_gsm_dtap_msg_rr[i];
10096         }
10097
10098         for (i=0; i < NUM_GSM_RR_ELEM; i++, last_offset++)
10099         {
10100                 ett_gsm_rr_elem[i] = -1;
10101                 ett[last_offset] = &ett_gsm_rr_elem[i];
10102         }
10103
10104         for (i=0; i < NUM_GSM_RR_REST_OCTETS_ELEM; i++, last_offset++)
10105         {
10106                 ett_gsm_rr_rest_octets_elem[i] = -1;
10107                 ett[last_offset] = &ett_gsm_rr_rest_octets_elem[i];
10108         }
10109
10110         for (i=0; i < NUM_GSM_SACCH_MSG_RR; i++, last_offset++)
10111         {
10112                 ett_gsm_sacch_msg_rr[i] = -1;
10113                 ett[last_offset] = &ett_gsm_sacch_msg_rr[i];
10114         }
10115
10116         /* Register the protocol name and description */
10117         proto_a_ccch =
10118                 proto_register_protocol("GSM CCCH", "GSM CCCH", "gsm_a_ccch");
10119
10120         proto_register_field_array(proto_a_ccch, hf, array_length(hf));
10121
10122         proto_register_subtree_array(ett, array_length(ett));
10123
10124         /* subdissector code */
10125         register_dissector("gsm_a_ccch", dissect_ccch, proto_a_ccch);
10126
10127         /* Register the protocol name and description */
10128         proto_a_sacch =
10129                 proto_register_protocol("GSM SACCH", "GSM SACCH", "gsm_a_sacch");
10130
10131         proto_register_field_array(proto_a_sacch, hf_sacch, array_length(hf_sacch));
10132
10133         proto_register_subtree_array(ett, array_length(ett));
10134
10135         /* subdissector code */
10136         register_dissector("gsm_a_sacch", dissect_sacch, proto_a_sacch);
10137 }
10138
10139 void
10140 proto_reg_handoff_gsm_a_rr(void)
10141 {
10142    rrc_irat_ho_info_handle = find_dissector("rrc.irat.irat_ho_info");
10143    rrc_irat_ho_to_utran_cmd_handle = find_dissector("rrc.irat.ho_to_utran_cmd");
10144 }