From Pascal Quantin:
[obnox/wireshark/wip.git] / epan / dissectors / packet-gsm_a_gm.c
1 /* packet-gsm_a_gm.c
2  * Routines for GSM A Interface GPRS Mobilty Management and GPRS Session Management
3  *
4  * Copyright 2003, Michael Lum <mlum [AT] telostech.com>
5  * In association with Telos Technology Inc.
6  *
7  * Added the GPRS Mobility Managment Protocol and
8  * the GPRS Session Managment Protocol
9  *   Copyright 2004, Rene Pilz <rene.pilz [AT] ftw.com>
10  *   In association with Telecommunications Research Center
11  *   Vienna (ftw.)Betriebs-GmbH within the Project Metawin.
12  *
13  * Various updates, enhancements and fixes
14  * Copyright 2009, Gerasimos Dimitriadis <dimeg [AT] intracom.gr>
15  * In association with Intracom Telecom SA
16  *
17  * Title                3GPP                    Other
18  *
19  *   Reference [7]
20  *   Mobile radio interface Layer 3 specification;
21  *   Core network protocols;
22  *   Stage 3
23  *   (3GPP TS 24.008 version 5.9.0 Release 5)
24  *
25  *   Reference [8]
26  *   Mobile radio interface Layer 3 specification;
27  *   Core network protocols;
28  *   Stage 3
29  *   (3GPP TS 24.008 version 6.7.0 Release 6)
30  *       (3GPP TS 24.008 version 6.8.0 Release 6)
31  *
32  *   Reference [9]
33  *   Mobile radio interface Layer 3 specification;
34  *   Core network protocols;
35  *   Stage 3
36  *   (3GPP TS 24.008 version 9.6.0 Release 9)
37  *
38  * $Id$
39  *
40  * Wireshark - Network traffic analyzer
41  * By Gerald Combs <gerald@wireshark.org>
42  * Copyright 1998 Gerald Combs
43  *
44  * This program is free software; you can redistribute it and/or
45  * modify it under the terms of the GNU General Public License
46  * as published by the Free Software Foundation; either version 2
47  * of the License, or (at your option) any later version.
48  *
49  * This program is distributed in the hope that it will be useful,
50  * but WITHOUT ANY WARRANTY; without even the implied warranty of
51  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
52  * GNU General Public License for more details.
53  *
54  * You should have received a copy of the GNU General Public License
55  * along with this program; if not, write to the Free Software
56  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
57  */
58
59 #ifdef HAVE_CONFIG_H
60 # include "config.h"
61 #endif
62
63 #include <string.h>
64
65 #include <epan/packet.h>
66 #include <epan/expert.h>
67 #include <epan/prefs.h>
68 #include <epan/tap.h>
69 #include <epan/asn1.h>
70
71 #include "packet-bssap.h"
72 #include "packet-sccp.h"
73 #include "packet-ber.h"
74 #include "packet-q931.h"
75 #include "packet-gsm_a_common.h"
76 #include "packet-e212.h"
77 #include "packet-ppp.h"
78
79 /* PROTOTYPES/FORWARDS */
80
81 const value_string gsm_a_dtap_msg_gmm_strings[] = {
82         { 0x01, "Attach Request" },
83         { 0x02, "Attach Accept" },
84         { 0x03, "Attach Complete" },
85         { 0x04, "Attach Reject" },
86         { 0x05, "Detach Request" },
87         { 0x06, "Detach Accept" },
88         { 0x08, "Routing Area Update Request" },
89         { 0x09, "Routing Area Update Accept" },
90         { 0x0a, "Routing Area Update Complete" },
91         { 0x0b, "Routing Area Update Reject" },
92         { 0x0c, "Service Request" },
93         { 0x0d, "Service Accept" },
94         { 0x0e, "Service Reject" },
95         { 0x10, "P-TMSI Reallocation Command" },
96         { 0x11, "P-TMSI Reallocation Complete" },
97         { 0x12, "Authentication and Ciphering Req" },
98         { 0x13, "Authentication and Ciphering Resp" },
99         { 0x14, "Authentication and Ciphering Rej" },
100         { 0x1c, "Authentication and Ciphering Failure" },
101         { 0x15, "Identity Request" },
102         { 0x16, "Identity Response" },
103         { 0x20, "GMM Status" },
104         { 0x21, "GMM Information" },
105         { 0, NULL }
106 };
107
108 const value_string gsm_a_dtap_msg_sm_strings[] = {
109         { 0x41, "Activate PDP Context Request" },
110         { 0x42, "Activate PDP Context Accept" },
111         { 0x43, "Activate PDP Context Reject" },
112         { 0x44, "Request PDP Context Activation" },
113         { 0x45, "Request PDP Context Activation rej." },
114         { 0x46, "Deactivate PDP Context Request" },
115         { 0x47, "Deactivate PDP Context Accept" },
116         { 0x48, "Modify PDP Context Request(Network to MS direction)" },
117         { 0x49, "Modify PDP Context Accept (MS to network direction)" },
118         { 0x4a, "Modify PDP Context Request(MS to network direction)" },
119         { 0x4b, "Modify PDP Context Accept (Network to MS direction)" },
120         { 0x4c, "Modify PDP Context Reject" },
121         { 0x4d, "Activate Secondary PDP Context Request" },
122         { 0x4e, "Activate Secondary PDP Context Accept" },
123         { 0x4f, "Activate Secondary PDP Context Reject" },
124         { 0x50, "Reserved: was allocated in earlier phases of the protocol" },
125         { 0x51, "Reserved: was allocated in earlier phases of the protocol" },
126         { 0x52, "Reserved: was allocated in earlier phases of the protocol" },
127         { 0x53, "Reserved: was allocated in earlier phases of the protocol" },
128         { 0x54, "Reserved: was allocated in earlier phases of the protocol" },
129         { 0x55, "SM Status" },
130         { 0x56, "Activate MBMS Context Request" },
131         { 0x57, "Activate MBMS Context Accept" },
132         { 0x58, "Activate MBMS Context Reject" },
133         { 0x59, "Request MBMS Context Activation" },
134         { 0x5a, "Request MBMS Context Activation Reject" },
135         { 0x5b, "Request Secondary PDP Context Activation" },
136         { 0x5c, "Request Secondary PDP Context Activation Reject" },
137         { 0x5d, "Notification" },
138         { 0, NULL }
139 };
140
141 const value_string gsm_gm_elem_strings[] = {
142         /* GPRS Mobility Management Information Elements 10.5.5 */
143         { 0x00, "Attach Result" },
144         { 0x00, "Attach Type" },
145         { 0x00, "Cipher Algorithm" },
146         { 0x00, "TMSI Status" },
147         { 0x00, "Detach Type" },
148         { 0x00, "DRX Parameter" },
149         { 0x00, "Force to Standby" },
150         { 0x00, "Force to Standby" },
151         { 0x00, "P-TMSI Signature" },
152         { 0x00, "P-TMSI Signature 2" },
153         { 0x00, "Identity Type 2" },
154         { 0x00, "IMEISV Request" },
155         { 0x00, "Receive N-PDU Numbers List" },
156         { 0x00, "MS Network Capability" },
157         { 0x00, "MS Radio Access Capability" },
158         { 0x00, "GMM Cause" },
159         { 0x00, "Routing Area Identification" },
160         { 0x00, "Routing Area Identification 2" },
161         { 0x00, "Update Result" },
162         { 0x00, "Update Type" },
163         { 0x00, "A&C Reference Number" },
164         { 0x00, "A&C Reference Number" },
165         { 0x00, "Service Type" },
166         { 0x00, "Cell Notification" },
167         { 0x00, "PS LCS Capability" },
168         { 0x00, "Network Feature Support" },
169         { 0x00, "Inter RAT information container" },
170         { 0x00, "Requested MS information" },
171         { 0x00, "UE network capability" },
172         { 0x00, "E-UTRAN inter RAT information container" },
173         { 0x00, "Voice domain preference and UE's usage setting" },
174         /* Session Management Information Elements 10.5.6 */
175         { 0x00, "Access Point Name" },
176         { 0x00, "Network Service Access Point Identifier" },
177         { 0x00, "Protocol Configuration Options" },
178         { 0x00, "Packet Data Protocol Address" },
179         { 0x00, "Quality Of Service" },
180         { 0x00, "SM Cause" },
181         { 0x00, "SM Cause 2" },
182         { 0x00, "Linked TI" },
183         { 0x00, "LLC Service Access Point Identifier" },
184         { 0x00, "Tear Down Indicator" },
185         { 0x00, "Packet Flow Identifier" },
186         { 0x00, "Traffic Flow Template" },
187         { 0x00, "Temporary Mobile Group Identity (TMGI)" },
188         { 0x00, "MBMS bearer capabilities" },
189         { 0x00, "MBMS protocol configuration options" },
190         { 0x00, "Enhanced network service access point identifier" },
191         { 0x00, "Request type" },
192         { 0x00, "Notification indicator" },
193         /* GPRS Common Information Elements 10.5.7 */
194         { 0x00, "PDP Context Status" },
195         { 0x00, "Radio Priority" },
196         { 0x00, "GPRS Timer" },
197         { 0x00, "GPRS Timer 2" },
198         { 0x00, "Radio Priority 2"},
199         { 0x00, "MBMS context status"},
200         { 0x00, "Uplink data status"},
201         { 0x00, "Spare Nibble"},
202         { 0, NULL }
203 };
204
205 #define DTAP_GMM_IEI_MASK       0xff
206 #define DTAP_SM_IEI_MASK        0xff
207
208 /* Initialize the protocol and registered fields */
209 static int proto_a_gm = -1;
210
211 static int hf_gsm_a_dtap_msg_gmm_type = -1;
212 static int hf_gsm_a_dtap_msg_sm_type = -1;
213 int hf_gsm_a_gm_elem_id = -1;
214 static int hf_gsm_a_qos_delay_cls       = -1;
215 static int hf_gsm_a_qos_reliability_cls = -1;
216 static int hf_gsm_a_qos_traffic_cls = -1;
217 static int hf_gsm_a_qos_del_order = -1;
218 static int hf_gsm_a_qos_del_of_err_sdu = -1;
219 static int hf_gsm_a_qos_ber = -1;
220 static int hf_gsm_a_qos_sdu_err_rat = -1;
221 static int hf_gsm_a_qos_traff_hdl_pri = -1;
222
223 static int hf_gsm_a_gmm_split_on_ccch = -1;
224 static int hf_gsm_a_gmm_non_drx_timer = -1;
225 static int hf_gsm_a_gmm_cn_spec_drs_cycle_len_coef = -1;
226
227 static int hf_gsm_a_ptmsi_sig =-1;
228 static int hf_gsm_a_ptmsi_sig2 =-1;
229
230 static int hf_gsm_a_tft_op_code = -1;
231 static int hf_gsm_a_tft_e_bit = -1;
232 static int hf_gsm_a_tft_pkt_flt = -1;
233 static int hf_gsm_a_tft_pkt_flt_id = -1;
234 static int hf_gsm_a_tft_pkt_flt_dir = -1;
235 static int hf_gsm_a_sm_ip4_address = -1;
236 static int hf_gsm_a_sm_ip4_mask = -1;
237 static int hf_gsm_a_sm_ip6_address = -1;
238 static int hf_gsm_a_sm_ip6_mask = -1;
239 static int hf_gsm_a_tft_protocol_header = -1;
240 static int hf_gsm_a_tft_port = -1;
241 static int hf_gsm_a_tft_port_low = -1;
242 static int hf_gsm_a_tft_port_high = -1;
243 static int hf_gsm_a_tft_security = -1;
244 static int hf_gsm_a_tft_traffic_mask = -1;
245 static int hf_gsm_a_tft_flow_label_type = -1;
246 static int hf_gsm_a_tft_param_id = -1;
247 static int hf_gsm_a_gm_acc_tech_type = -1;
248 static int hf_gsm_a_gm_acc_cap_struct_len = -1;
249 static int hf_gsm_a_gm_sms_value = -1;
250 static int hf_gsm_a_gm_sm_value = -1;
251 static int hf_gsm_a_gm_sm_ext = -1;
252 static int hf_gsm_a_gm_link_dir = -1;
253 static int hf_gsm_a_gm_cause = -1;
254
255 static int hf_gsm_a_gm_fop = -1;
256 static int hf_gsm_a_gm_res_of_attach = -1;
257 static int hf_gsm_a_gm_type_of_ciph_alg = -1;
258 static int hf_gsm_a_gm_imeisv_req = -1;
259 static int hf_gsm_a_gm_ac_ref_nr = -1;
260 static int hf_gsm_a_gm_force_to_standby = -1;
261 static int hf_gsm_a_gm_serv_type = -1;
262 static int hf_gsm_a_gm_ciph_key_seq_num = -1;
263 static int hf_gsm_a_gm_for = -1;
264 static int hf_gsm_a_gm_type_of_attach = -1;
265 static int hf_gsm_a_gm_tmsi_flag = -1;
266 static int hf_gsm_a_gm_update_type = -1;
267 static int hf_gsm_a_gm_gprs_timer_unit = -1;
268 static int hf_gsm_a_gm_gprs_timer_value = -1;
269 static int hf_gsm_a_gm_nsapi_5_ul_stat = -1;
270 static int hf_gsm_a_gm_nsapi_6_ul_stat = -1;
271 static int hf_gsm_a_gm_nsapi_7_ul_stat = -1;
272 static int hf_gsm_a_gm_nsapi_8_ul_stat = -1;
273 static int hf_gsm_a_gm_nsapi_9_ul_stat = -1;
274 static int hf_gsm_a_gm_nsapi_10_ul_stat = -1;
275 static int hf_gsm_a_gm_nsapi_11_ul_stat = -1;
276 static int hf_gsm_a_gm_nsapi_12_ul_stat = -1;
277 static int hf_gsm_a_gm_nsapi_13_ul_stat = -1;
278 static int hf_gsm_a_gm_nsapi_14_ul_stat = -1;
279 static int hf_gsm_a_gm_nsapi_15_ul_stat = -1;
280 static int hf_gsm_a_gm_pco_pid = -1;
281 static int hf_gsm_a_gm_type_of_identity = -1;
282 static int hf_gsm_a_gm_rac = -1;
283 static int hf_gsm_a_gm_apc = -1;
284 static int hf_gsm_a_gm_otd_a = -1;
285 static int hf_gsm_a_gm_otd_b = -1;
286 static int hf_gsm_a_gm_gps_a = -1;
287 static int hf_gsm_a_gm_gps_b = -1;
288 static int hf_gsm_a_gm_gps_c = -1;
289 static int hf_gsm_a_gm_req_ms_info_irat = -1;
290 static int hf_gsm_a_gm_req_ms_info_irat2 = -1;
291 static int hf_gsm_a_gm_ue_usage_setting = -1;
292 static int hf_gsm_a_gm_voice_domain_pref_for_eutran = -1;
293 static int hf_gsm_a_sm_pdp_type_org = -1;
294 static int hf_gsm_a_qos_mean_thr = -1;
295 static int hf_gsm_a_qos_peak_thr = -1;
296 static int hf_gsm_a_qos_prec_class = -1;
297 static int hf_gsm_a_qos_traf_handl_prio = -1;
298 static int hf_gsm_a_qos_trans_delay = -1;
299 static int hf_gsm_a_qos_signalling_ind = -1;
300 static int hf_gsm_a_qos_source_stat_desc = -1;
301 static int hf_gsm_a_qos_max_bitrate_upl = -1;
302 static int hf_gsm_a_qos_max_bitrate_downl = -1;
303 static int hf_gsm_a_qos_guar_bitrate_upl = -1;
304 static int hf_gsm_a_qos_guar_bitrate_downl = -1;
305 static int hf_gsm_a_qos_max_bitrate_upl_ext = -1;
306 static int hf_gsm_a_qos_max_bitrate_downl_ext = -1;
307 static int hf_gsm_a_qos_guar_bitrate_upl_ext = -1;
308 static int hf_gsm_a_qos_guar_bitrate_downl_ext = -1;
309 static int hf_gsm_a_sm_cause = -1;
310 static int hf_gsm_a_sm_cause_2 = -1;
311 static int hf_gsm_a_sm_llc_sapi = -1;
312 static int hf_gsm_a_sm_tdi = -1;
313 static int hf_gsm_a_sm_packet_flow_id = -1;
314 static int hf_gsm_a_sm_tmgi = -1;
315 static int hf_gsm_a_sm_enh_nsapi = -1;
316 static int hf_gsm_a_sm_req_type = -1;
317 static int hf_gsm_a_sm_notif_ind = -1;
318 static int hf_gsm_a_gm_rac_ctrled_early_cm_sending = -1;
319 static int hf_gsm_a_gm_rac_pseudo_sync = -1;
320 static int hf_gsm_a_gm_rac_vgcs = -1;
321 static int hf_gsm_a_gm_rac_vbs = -1;
322 static int hf_gsm_a_gm_rac_multislot_capability = -1;
323 static int hf_gsm_a_gm_rac_hscsd_multi_slot_class = -1;
324 static int hf_gsm_a_gm_rac_gprs_multi_slot_class = -1;
325 static int hf_gsm_a_gm_rac_gprs_ext_dyn_alloc_cap = -1;
326 static int hf_gsm_a_gm_rac_ecsd_multi_slot_class = -1;
327 static int hf_gsm_a_gm_rac_egprs_multi_slot_class = -1;
328 static int hf_gsm_a_gm_rac_egprs_ext_dyn_alloc_cap = -1;
329 static int hf_gsm_a_gm_rac_dtm_gprs_multi_slot_class = -1;
330 static int hf_gsm_a_gm_rac_single_slt_dtm = -1;
331 static int hf_gsm_a_gm_rac_dtm_egprs_multi_slot_cls_pres = -1;
332 static int hf_gsm_a_gm_rac_dtm_egprs_multi_slot_class = -1;
333 static int hf_gsm_a_gm_rac_8psk_pow_cap_pres = -1;
334 static int hf_gsm_a_gm_rac_comp_int_meas_cap = -1;
335 static int hf_gsm_a_gm_rel_lev_ind = -1;
336 static int hf_gsm_a_gm_rac_geran_feat_pkg = -1;
337 static int hf_gsm_a_gm_rac_umts_fdd_cap = -1;
338 static int hf_gsm_a_gm_rac_umts_384_tdd_ra_cap = -1;
339 static int hf_gsm_a_gm_rac_cdma2000_cap = -1;
340 static int hf_gsm_a_gm_rac_umts_128_tdd_ra_cap = -1;
341 static int hf_gsm_a_gm_rac_mod_based_multi_slot_class_support = -1;
342 static int hf_gsm_a_gm_rac_geran_iu_mode_cap = -1;
343 static int hf_gsm_a_gm_rac_flo_iu_cap = -1;
344 static int hf_gsm_a_gm_rac_mult_tbf_cap = -1;
345 static int hf_gsm_a_gm_rac_down_adv_rec_perf = -1;
346 static int hf_gsm_a_gm_rac_ext_rlc_mac_ctrl_msg_seg_cap = -1;
347 static int hf_gsm_a_gm_rac_dtm_enh_cap = -1;
348 static int hf_gsm_a_gm_rac_dtm_gprs_high_multi_slot_class = -1;
349 static int hf_gsm_a_gm_rac_dtm_egprs_high_multi_slot_class = -1;
350 static int hf_gsm_a_gm_rac_ps_ho_cap = -1;
351 static int hf_gsm_a_gm_rac_dtm_ho_cap = -1;
352 static int hf_gsm_a_gm_rac_multi_slot_cap_red_down_dual_carrier = -1;
353 static int hf_gsm_a_gm_rac_down_dual_carrier_dtm_cap = -1;
354 static int hf_gsm_a_gm_rac_flex_ts_assign = -1;
355 static int hf_gsm_a_gm_rac_gan_ps_ho_cap = -1;
356 static int hf_gsm_a_gm_rac_rlc_non_pers_mode = -1;
357 static int hf_gsm_a_gm_rac_reduced_lat_cap = -1;
358 static int hf_gsm_a_gm_rac_ul_egprs2 = -1;
359 static int hf_gsm_a_gm_rac_dl_egprs2 = -1;
360 static int hf_gsm_a_gm_rac_eutra_fdd_support = -1;
361 static int hf_gsm_a_gm_rac_eutra_tdd_support = -1;
362 static int hf_gsm_a_gm_rac_geran_to_eutra_support_in_geran_ptm = -1;
363 static int hf_gsm_a_gm_rac_prio_based_resel_support = -1;
364 static int hf_gsm_a_gm_rac_alt_efta_multi_slot_class = -1;
365 static int hf_gsm_a_gm_rac_efta_multi_slot_cap_red_down_dual_carrier = -1;
366 static int hf_gsm_a_gm_rac_ind_up_layer_pdu_start_cap_for_rlc_um = -1;
367 static int hf_gsm_a_gm_rac_emst_cap = -1;
368 static int hf_gsm_a_gm_rac_mtti_cap = -1;
369 static int hf_gsm_a_gm_rac_utra_csg_cell_report = -1;
370 static int hf_gsm_a_gm_rac_eutra_csg_cell_report = -1;
371 static int hf_gsm_a_sm_ti_flag = -1;
372 static int hf_gsm_a_sm_ext = -1;
373
374 static int hf_gsm_a_gmm_net_cap_gea1 = -1;
375 static int hf_gsm_a_gmm_net_cap_smdch = -1;
376 static int hf_gsm_a_gmm_net_cap_smgprs = -1;
377 static int hf_gsm_a_gmm_net_cap_ucs2 = -1;
378 static int hf_gsm_a_gmm_net_cap_ss_scr_ind = -1;
379 static int hf_gsm_a_gmm_net_cap_solsa = -1;
380 static int hf_gsm_a_gmm_net_cap_rev = -1;
381 static int hf_gsm_a_gmm_net_cap_pfc = -1;
382 static int hf_gsm_a_gmm_net_cap_ext_gea_bits = -1;
383 static int hf_gsm_a_gmm_net_cap_gea2 = -1;
384 static int hf_gsm_a_gmm_net_cap_gea3 = -1;
385 static int hf_gsm_a_gmm_net_cap_gea4 = -1;
386 static int hf_gsm_a_gmm_net_cap_gea5 = -1;
387 static int hf_gsm_a_gmm_net_cap_gea6 = -1;
388 static int hf_gsm_a_gmm_net_cap_gea7 = -1;
389 static int hf_gsm_a_gmm_net_cap_lcs = -1;
390 static int hf_gsm_a_gmm_net_cap_ps_irat_iu = -1;
391 static int hf_gsm_a_gmm_net_cap_ps_irat_s1 = -1;
392 static int hf_gsm_a_gmm_net_cap_comb_proc = -1;
393 static int hf_gsm_a_gmm_net_cap_isr = -1;
394 static int hf_gsm_a_gmm_net_cap_srvcc_to_geran = -1;
395 static int hf_gsm_a_gmm_net_cap_epc = -1;
396 static int hf_gsm_a_gmm_net_cap_nf = -1;
397
398 /* Initialize the subtree pointers */
399 static gint ett_tc_component = -1;
400 static gint ett_tc_invoke_id = -1;
401 static gint ett_tc_linked_id = -1;
402 static gint ett_tc_opr_code = -1;
403 static gint ett_tc_err_code = -1;
404 static gint ett_tc_prob_code = -1;
405 static gint ett_tc_sequence = -1;
406
407 static gint ett_gmm_drx = -1;
408 static gint ett_gmm_detach_type = -1;
409 static gint ett_gmm_attach_type = -1;
410 static gint ett_gmm_context_stat = -1;
411 static gint ett_gmm_update_type = -1;
412 static gint ett_gmm_radio_cap = -1;
413 static gint ett_gmm_network_cap = -1;
414 static gint ett_gsm_a_gm_msrac_multislot_capability = -1;
415 static gint ett_gmm_rai = -1;
416 static gint ett_gmm_gprs_timer = -1;
417
418 static gint ett_sm_tft = -1;
419
420 static dissector_handle_t data_handle;
421 static dissector_handle_t rrc_irat_ho_info_handle;
422 static dissector_handle_t lte_rrc_ue_eutra_cap_handle;
423
424 static dissector_table_t gprs_sm_pco_subdissector_table; /* GPRS SM PCO PPP Protocols */
425
426 #define NUM_GSM_GM_ELEM (sizeof(gsm_gm_elem_strings)/sizeof(value_string))
427 gint ett_gsm_gm_elem[NUM_GSM_GM_ELEM];
428
429 static const gchar *pdp_str[2]={ "PDP-INACTIVE", "PDP-ACTIVE" };
430
431 /*
432  * [9] 10.5.5.1 Attach result
433  */
434 static const value_string gsm_a_gm_res_of_attach_vals[] = {
435         { 0x01, "GPRS only attached" },
436         { 0x03, "Combined GPRS/IMSI attached" },
437         { 0, NULL }
438 };
439
440 static guint16
441 de_gmm_attach_res(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
442 {
443         proto_tree_add_item(tree, hf_gsm_a_gm_fop, tvb, offset, 1, ENC_BIG_ENDIAN);
444         proto_tree_add_item(tree, hf_gsm_a_gm_res_of_attach, tvb, offset, 1, ENC_BIG_ENDIAN);
445
446         /* no length check possible */
447         return(1);
448 }
449
450 /*
451  * [9] 10.5.5.2 Attach type
452  */
453 static const value_string gsm_a_gm_type_of_attach_vals[] = {
454         { 0x01, "GPRS attach" },
455         { 0x02, "Not used (In earlier versions: GPRS attach while IMSI attached)" },
456         { 0x03, "Combined GPRS/IMSI attached" },
457         { 0, NULL }
458 };
459
460 static guint16
461 de_gmm_attach_type(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
462 {
463         proto_item   *tf = NULL;
464         proto_tree   *tf_tree = NULL;
465
466         proto_tree_add_bits_item(tree, hf_gsm_a_gm_ciph_key_seq_num, tvb, offset << 3, 4, ENC_BIG_ENDIAN);
467
468         tf = proto_tree_add_text(tree,
469                 tvb, offset, 1,
470                 "Attach Type");
471
472         tf_tree = proto_item_add_subtree(tf, ett_gmm_attach_type );
473
474         proto_tree_add_item(tf_tree, hf_gsm_a_gm_for, tvb, offset, 1, ENC_BIG_ENDIAN);
475         proto_tree_add_item(tf_tree, hf_gsm_a_gm_type_of_attach, tvb, offset, 1, ENC_BIG_ENDIAN);
476
477         /* no length check possible */
478         return(1);
479 }
480
481 /*
482  * [9] 10.5.5.3 Ciphering algorithm
483  */
484 const value_string gsm_a_gm_type_of_ciph_alg_vals[] = {
485         { 0x00, "ciphering not used" },
486         { 0x01, "GPRS Encryption Algorithm GEA/1" },
487         { 0x02, "GPRS Encryption Algorithm GEA/2" },
488         { 0x03, "GPRS Encryption Algorithm GEA/3" },
489         { 0x04, "GPRS Encryption Algorithm GEA/4" },
490         { 0x05, "GPRS Encryption Algorithm GEA/5" },
491         { 0x06, "GPRS Encryption Algorithm GEA/6" },
492         { 0x07, "GPRS Encryption Algorithm GEA/7" },
493         { 0, NULL }
494 };
495
496 static guint16
497 de_gmm_ciph_alg(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
498 {
499         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (offset << 3) + 4, 1, ENC_BIG_ENDIAN);
500         proto_tree_add_item(tree, hf_gsm_a_gm_type_of_ciph_alg, tvb, offset, 1, ENC_BIG_ENDIAN);
501
502         /* no length check possible */
503         return(1);
504 }
505
506 /*
507  * [9] 10.5.5.4 TMSI status
508  */
509 const true_false_string gsm_a_gm_tmsi_flag_value = {
510         "valid TMSI available",
511         "no valid TMSI available"
512 };
513
514 static guint16
515 de_gmm_tmsi_stat(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
516 {
517         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (offset << 3) + 4, 3, ENC_BIG_ENDIAN);
518         proto_tree_add_item(tree, hf_gsm_a_gm_tmsi_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
519
520         /* no length check possible */
521         return(1);
522 }
523
524 /*
525  * [7] 10.5.5.5
526  */
527 static guint16
528 de_gmm_detach_type(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
529 {
530         guint8        oct;
531         guint32       curr_offset;
532         const gchar  *str;
533         const gchar  *str_power;
534         proto_item   *tf = NULL;
535         proto_tree   *tf_tree = NULL;
536
537         curr_offset = offset;
538
539         oct = tvb_get_guint8(tvb, curr_offset);
540
541         switch(oct&7)
542         {
543                 case 1:  str="GPRS detach/re-attach required";                            break;
544                 case 2:  str="IMSI detach/re-attach not required";                        break;
545                 case 3:  str="Combined GPRS/IMSI detach/IMSI detach (after VLR failure)"; break;
546                 default: str="Combined GPRS/IMSI detach/re-attach not required";
547         }
548
549         switch(oct&8)
550         {
551                 case 8:  str_power="power switched off"; break;
552                 default: str_power="normal detach";      break;
553         }
554
555         tf = proto_tree_add_text(tree,
556                 tvb, curr_offset, 1,
557                 "Detach Type");
558
559         tf_tree = proto_item_add_subtree(tf, ett_gmm_detach_type );
560
561         proto_tree_add_text(tf_tree,
562                 tvb, curr_offset, 1,
563                 "Type: %s (%u)",
564                 str,
565                 oct&7);
566
567         proto_tree_add_text(tf_tree,
568                 tvb, curr_offset, 1,
569                 "Power: %s (%u)",
570                 str_power,
571                 (oct>>3)&1);
572
573         curr_offset++;
574
575         /* no length check possible */
576
577         return(curr_offset - offset);
578 }
579
580 /*
581  * [7] 10.5.5.6
582  *
583  * SPLIT on CCCH, octet 3 (bit 4)
584  * 0 Split pg cycle on CCCH is not supported by the mobile station
585  * 1 Split pg cycle on CCCH is supported by the mobile station
586  */
587 static const true_false_string gsm_a_gmm_split_on_ccch_value  = {
588         "Split pg cycle on CCCH is supported by the mobile station",
589         "Split pg cycle on CCCH is not supported by the mobile station"
590 };
591
592 /* non-DRX timer, octet 3
593  * bit
594  * 3 2 1
595  */
596 static const value_string gsm_a_gmm_non_drx_timer_strings[] = {
597         { 0x00, "no non-DRX mode after transfer state" },
598         { 0x01, "max. 1 sec non-DRX mode after transfer state" },
599         { 0x02, "max. 2 sec non-DRX mode after transfer state" },
600         { 0x03, "max. 4 sec non-DRX mode after transfer state" },
601         { 0x04, "max. 8 sec non-DRX mode after transfer state" },
602         { 0x05, "max. 16 sec non-DRX mode after transfer state" },
603         { 0x06, "max. 32 sec non-DRX mode after transfer state" },
604         { 0x07, "max. 64 sec non-DRX mode after transfer state" },
605         { 0, NULL },
606 };
607 /*
608  * CN Specific DRX cycle length coefficient, octet 3
609  * bit
610  * 8 7 6 5 Iu mode specific
611  * 0 0 0 0 CN Specific DRX cycle length coefficient not specified by the MS, ie. the
612  * system information value 'CN domain specific DRX cycle length' is used.
613  * (Ref 3GPP TS 25.331)
614  * 0 1 1 0 CN Specific DRX cycle length coefficient 6
615  * 0 1 1 1 CN Specific DRX cycle length coefficient 7
616  * 1 0 0 0 CN Specific DRX cycle length coefficient 8
617  * 1 0 0 1 CN Specific DRX cycle length coefficient 9
618  * All other values shall be interpreted as "CN Specific DRX cycle length coefficient not
619  * specified by the MS " by this version of the protocol.
620  * NOTE: In Iu mode this field (octet 3 bits 8 to 5) is used, but was spare in earlier
621  * versions of this protocol.
622  */
623 static const range_string gsm_a_gmm_cn_spec_drs_cycle_len_coef_strings[] = {
624         { 0x00, 0x05, "CN Specific DRX cycle length coefficient not specified by the MS" },
625         { 0x06, 0x06, "CN Specific DRX cycle length coefficient 6" },
626         { 0x07, 0x07, "CN Specific DRX cycle length coefficient 7" },
627         { 0x08, 0x08, "CN Specific DRX cycle length coefficient 8" },
628         { 0x09, 0x09, "CN Specific DRX cycle length coefficient 9" },
629         { 0x0a, 0x0f, "CN Specific DRX cycle length coefficient not specified by the MS" },
630         { 0, 0, NULL },
631 };
632 guint16
633 de_gmm_drx_param(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
634 {
635         guint8        oct;
636         guint32       curr_offset;
637         const gchar  *str;
638         proto_item   *tf = NULL;
639         proto_tree   *tf_tree = NULL;
640
641         curr_offset = offset;
642
643         tf = proto_tree_add_text(tree,
644                 tvb, curr_offset, 2,
645                 "DRX Parameter");
646
647         tf_tree = proto_item_add_subtree(tf, ett_gmm_drx );
648
649         oct = tvb_get_guint8(tvb, curr_offset);
650
651         switch(oct)
652         {
653                 case 0:  str="704"; break;
654                 case 65: str="71";  break;
655                 case 66: str="72";  break;
656                 case 67: str="74";  break;
657                 case 68: str="75";  break;
658                 case 69: str="77";  break;
659                 case 70: str="79";  break;
660                 case 71: str="80";  break;
661                 case 72: str="83";  break;
662                 case 73: str="86";  break;
663                 case 74: str="88";  break;
664                 case 75: str="90";  break;
665                 case 76: str="92";  break;
666                 case 77: str="96";  break;
667                 case 78: str="101"; break;
668                 case 79: str="103"; break;
669                 case 80: str="107"; break;
670                 case 81: str="112"; break;
671                 case 82: str="116"; break;
672                 case 83: str="118"; break;
673                 case 84: str="128"; break;
674                 case 85: str="141"; break;
675                 case 86: str="144"; break;
676                 case 87: str="150"; break;
677                 case 88: str="160"; break;
678                 case 89: str="171"; break;
679                 case 90: str="176"; break;
680                 case 91: str="192"; break;
681                 case 92: str="214"; break;
682                 case 93: str="224"; break;
683                 case 94: str="235"; break;
684                 case 95: str="256"; break;
685                 case 96: str="288"; break;
686                 case 97: str="320"; break;
687                 case 98: str="352"; break;
688                 default: str="Reserved, interpreted as 1";
689         }
690
691         proto_tree_add_text(tf_tree,
692                 tvb, curr_offset, 1,
693                 "Split PG Cycle Code: %s (%u)",
694                 str,
695                 oct);
696
697         curr_offset++;
698         proto_tree_add_item(tf_tree, hf_gsm_a_gmm_cn_spec_drs_cycle_len_coef, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
699         proto_tree_add_item(tf_tree, hf_gsm_a_gmm_split_on_ccch, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
700         proto_tree_add_item(tf_tree, hf_gsm_a_gmm_non_drx_timer, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
701
702         curr_offset++;
703
704         /* no length check possible */
705
706         return(curr_offset - offset);
707 }
708
709 /*
710  * [9] 10.5.5.7 Force to standby (lower nibble)
711  */
712 static const range_string gsm_a_gm_force_to_standby_vals[] = {
713         { 0x00, 0x00, "Force to standby not indicated" },
714         { 0x01, 0x01, "Force to standby indicated" },
715         { 0x02, 0x07, "Unknown, interpreted as Force to standby not indicated" },
716         { 0, 0, NULL }
717 };
718
719 static guint16
720 de_gmm_ftostby(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
721 {
722         guint32 bit_offset;
723
724         /* IMPORTANT - IT'S ASSUMED THAT THE INFORMATION IS IN THE LOWER NIBBLE */
725         bit_offset = (offset << 3) + 4;
726         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
727         proto_tree_add_bits_item(tree, hf_gsm_a_gm_force_to_standby, tvb, bit_offset + 1, 3, ENC_BIG_ENDIAN);
728
729         /* no length check possible */
730         return(1);
731 }
732
733 /*
734  * [9] 10.5.5.7 Force to standby (higher nibble)
735  */
736 static guint16
737 de_gmm_ftostby_h(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
738 {
739         guint32 bit_offset;
740
741         /* IMPORTANT - IT'S ASSUMED THAT THE INFORMATION IS IN THE HIGHER NIBBLE */
742         bit_offset = offset << 3;
743         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
744         proto_tree_add_bits_item(tree, hf_gsm_a_gm_force_to_standby, tvb, bit_offset + 1, 3, ENC_BIG_ENDIAN);
745
746         /* no length check possible */
747         return(1);
748 }
749
750 /*
751  * [7] 10.5.5.8
752  */
753 static guint16
754 de_gmm_ptmsi_sig(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
755 {
756         guint32       curr_offset;
757         proto_item   *curr_item;
758
759         curr_offset = offset;
760
761         curr_item= proto_tree_add_item(tree,hf_gsm_a_ptmsi_sig,tvb,curr_offset,3,ENC_BIG_ENDIAN);
762         proto_item_append_text(curr_item,"%s",add_string ? add_string : "");
763
764         curr_offset+=3;
765
766         /* no length check possible */
767
768         return(curr_offset - offset);
769 }
770
771 /*
772  * [7] 10.5.5.8a
773  */
774 static guint16
775 de_gmm_ptmsi_sig2(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string, int string_len _U_)
776 {
777         guint32       curr_offset;
778         proto_item   *curr_item;
779
780         curr_offset = offset;
781
782         curr_item= proto_tree_add_item(tree,hf_gsm_a_ptmsi_sig2,tvb,curr_offset,3,ENC_BIG_ENDIAN);
783         proto_item_append_text(curr_item,"%s",add_string ? add_string : "");
784         curr_offset+=3;
785
786         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
787
788         return(curr_offset - offset);
789 }
790
791 /*
792  * [9] 10.5.5.9 Identity type 2
793  */
794 static const value_string gsm_a_gm_type_of_identity_vals[] = {
795         { 0x01, "IMSI" },
796         { 0x02, "IMEI" },
797         { 0x03, "IMEISV" },
798         { 0x04, "TMSI" },
799         { 0, NULL }
800 };
801
802 static guint16
803 de_gmm_ident_type2(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
804 {
805         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (offset << 3) + 4, 1, ENC_BIG_ENDIAN);
806         proto_tree_add_item(tree, hf_gsm_a_gm_type_of_identity, tvb, offset, 1, ENC_BIG_ENDIAN);
807
808         /* no length check possible */
809         return(1);
810 }
811
812 /*
813  * [9] 10.5.5.10 IMEISV request
814  */
815 static const range_string gsm_a_gm_imeisv_req_vals[] = {
816         { 0x00, 0x00, "IMEISV not requested" },
817         { 0x01, 0x01, "IMEISV requested" },
818         { 0x02, 0x07, "Unknown, interpreted as IMEISV not requested" },
819         { 0, 0, NULL }
820 };
821
822 static guint16
823 de_gmm_imeisv_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
824 {
825         guint32 bit_offset;
826
827         /* IMPORTANT - IT'S ASSUMED THAT THE INFORMATION IS IN THE HIGHER NIBBLE */
828         bit_offset = offset << 3;
829         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
830         proto_tree_add_bits_item(tree, hf_gsm_a_gm_imeisv_req, tvb, bit_offset + 1, 3, ENC_BIG_ENDIAN);
831
832         /* no length check possible */
833         return(1);
834 }
835
836 /*
837  * [7] 10.5.5.11
838  */
839 static guint16
840 de_gmm_rec_npdu_lst(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
841 {
842         guint32 curr_offset;
843         guint   curr_len;
844
845         curr_len = len;
846         curr_offset = offset;
847
848         if ( len == 0 ) return 0;
849
850         do
851         {
852                 guint32 oct;
853                 oct = tvb_get_guint8(tvb, curr_offset);
854                 oct <<=8;
855                 oct |= tvb_get_guint8(tvb, curr_offset+1);
856                 curr_len -= 2;
857                 oct <<=8;
858
859                 proto_tree_add_text(tree,
860                         tvb, curr_offset, 2,
861                         "NSAPI %d: 0x%02x (%u)",
862                         oct>>20,
863                         (oct>>12)&0xff,
864                         (oct>>12)&0xff);
865                 curr_offset+= 2;
866
867                 if ( curr_len > 2 )
868                 {
869                         oct |= tvb_get_guint8(tvb, curr_offset+2);
870                         curr_len--;
871                         oct <<= 12;
872
873                         proto_tree_add_text(tree,
874                                 tvb, curr_offset-1, 2,
875                                 "NSAPI %d: 0x%02x (%u)",
876                                 oct>>20,
877                                 (oct>>12)&0xff,
878                                 (oct>>12)&0xff);
879                         curr_offset++;
880                 }
881
882         } while ( curr_len > 1 );
883
884         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
885
886         return(curr_offset - offset);
887 }
888
889 /*
890  * [9] 10.5.5.12 MS network capability
891  */
892 static const true_false_string gsm_a_gmm_net_cap_gea_vals = {
893         "Encryption algorithm available",
894         "Encryption algorithm not available"
895 };
896
897 static const true_false_string gsm_a_gmm_net_cap_smdch_vals = {
898         "Mobile station supports mobile terminated point to point SMS via dedicated signalling channels",
899         "Mobile station does not support mobile terminated point to point SMS via dedicated signalling channels"
900 };
901
902 static const true_false_string gsm_a_gmm_net_cap_smgprs_vals = {
903         "Mobile station supports mobile terminated point to point SMS via GPRS packet data channels",
904         "Mobile station does not support mobile terminated point to point SMS via GPRS packet data channels"
905 };
906
907 static const true_false_string gsm_a_gmm_net_cap_ucs2_vals = {
908         "The ME has no preference between the use of the default alphabet and the use of UCS2",
909         "The ME has a preference for the default alphabet (defined in 3GPP TS 23.038 [8b]) over UCS2"
910 };
911
912 static const value_string gsm_a_gmm_net_cap_ss_scr_ind_vals[]={
913         { 0x00, "Default value of phase 1" },
914         { 0x01, "capability of handling of ellipsis notation and phase 2 error handling" },
915         { 0x02, "For future use, interpreted as Capability of handling of ellipsis notation and phase 2 error handling" },
916         { 0x03, "For future use, interpreted as Capability of handling of ellipsis notation and phase 2 error handling" },
917         { 0x00, NULL }
918 };
919
920 static const true_false_string gsm_a_gmm_net_cap_solsa_vals = {
921         "The ME supports SoLSA",
922         "The ME does not support SoLSA"
923 };
924
925 static const true_false_string gsm_a_gmm_net_cap_rev_vals = {
926         "Used by a mobile station supporting R99 or later versions of the protocol",
927         "Used by a mobile station not supporting R99 or later versions of the protocol"
928 };
929
930 static const true_false_string gsm_a_gmm_net_cap_pfc_vals = {
931         "Mobile station does support BSS packet flow procedures",
932         "Mobile station does not support BSS packet flow procedures"
933 };
934
935 static const true_false_string gsm_a_gmm_net_cap_lcs_vals = {
936         "LCS value added location request notification capability supported",
937         "LCS value added location request notification capability not supported"
938 };
939
940 static const true_false_string gsm_a_gmm_net_cap_ps_irat_iu_vals = {
941         "PS inter-RAT HO to UTRAN Iu mode supported",
942         "PS inter-RAT HO to UTRAN Iu mode not supported"
943 };
944
945 static const true_false_string gsm_a_gmm_net_cap_ps_irat_s1_vals = {
946         "PS inter-RAT HO to E-UTRAN S1 mode supported",
947         "PS inter-RAT HO to E-UTRAN S1 mode not supported"
948 };
949
950 static const true_false_string gsm_a_gmm_net_cap_comb_proc_vals = {
951         "Mobile station supports EMM combined procedures",
952         "Mobile station does not support EMM combined procedures"
953 };
954
955 static const true_false_string gsm_a_gmm_net_cap_isr_vals = {
956         "The mobile station supports ISR",
957         "The mobile station does not support ISR"
958 };
959
960 static const true_false_string gsm_a_gmm_net_cap_srvcc_to_geran_vals = {
961         "SRVCC from UTRAN HSPA or E-UTRAN to GERAN/UTRAN supported",
962         "SRVCC from UTRAN HSPA or E-UTRAN to GERAN/UTRAN not supported"
963 };
964
965 static const true_false_string gsm_a_gmm_net_cap_epc_vals = {
966         "EPC supported",
967         "EPC not supported"
968 };
969
970 static const true_false_string gsm_a_gmm_net_cap_nf_vals = {
971         "Mobile station supports the notification procedure",
972         "Mobile station does not support the notification procedure"
973 };
974
975 guint16
976 de_gmm_ms_net_cap(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
977 {
978         guint32 curr_offset;
979         proto_tree      *subtree;
980         proto_item      *item;
981
982         curr_offset = offset;
983
984         /* bit 8: GEA1 */
985         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_gea1, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
986
987         /* bit 7: SM capabilities via dedicated channels */
988         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_smdch, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
989
990         /* bit 6: SM capabilities via GPRS channels */
991         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_smgprs, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
992
993         /* bit 5: UCS2 support */
994         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_ucs2, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
995
996         /* bits 4 3: SS Screening Indicator */
997         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_ss_scr_ind, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
998
999         /* bit 2: SoLSA Capability */
1000         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_solsa, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1001
1002         /* bit 1 */
1003         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_rev, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1004
1005         curr_offset++;
1006         NO_MORE_DATA_CHECK(len);
1007
1008         /* bit 8: PFC feature mode */
1009         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_pfc, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1010
1011         /* bits 7 6 5 4 3 2: Extended GEA bits */
1012         item = proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_ext_gea_bits, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1013         subtree = proto_item_add_subtree(item, ett_gmm_network_cap);
1014         proto_tree_add_item(subtree, hf_gsm_a_gmm_net_cap_gea2, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1015         proto_tree_add_item(subtree, hf_gsm_a_gmm_net_cap_gea3, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1016         proto_tree_add_item(subtree, hf_gsm_a_gmm_net_cap_gea4, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1017         proto_tree_add_item(subtree, hf_gsm_a_gmm_net_cap_gea5, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1018         proto_tree_add_item(subtree, hf_gsm_a_gmm_net_cap_gea6, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1019         proto_tree_add_item(subtree, hf_gsm_a_gmm_net_cap_gea7, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1020
1021         /* bit 1: LCS VA capability */
1022         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_lcs, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1023
1024         curr_offset++;
1025         NO_MORE_DATA_CHECK(len);
1026
1027         /* bit 8: PS inter-RAT HO to UTRAN Iu mode capability */
1028         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_ps_irat_iu, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1029
1030         /* bit 7: PS inter-RAT HO to E-UTRAN S1 mode capability */
1031         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_ps_irat_s1, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1032
1033         /* bit 6: EMM Combined procedures capability */
1034         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_comb_proc, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1035
1036         /* bit 5: ISR support */
1037         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_isr, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1038
1039         /* bit 4: SRVCC to GERAN/UTRAN capability */
1040         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_srvcc_to_geran, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1041
1042         /* bit 3: EPC capability */
1043         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_epc, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1044
1045         /* bit 3: NF capability */
1046         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_nf, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1047
1048         /* bits 1: Spare bit */
1049         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (curr_offset<<3)+7, 1, ENC_BIG_ENDIAN);
1050
1051         curr_offset++;
1052         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
1053
1054         return(curr_offset - offset);
1055 }
1056
1057 /*
1058  * [7] 10.5.5.12a
1059  */
1060 #define GET_DATA                                /* check if we have enough bits left */ \
1061         if ( curr_bits_length < bits_needed ) \
1062                 continue; \
1063         /* check if oct has enougth bits */ \
1064         if ( bits_in_oct < bits_needed ) \
1065         { \
1066                 guint32 tmp_oct; \
1067                 if ( curr_len == 0 ) \
1068                 { \
1069                         proto_tree_add_text(tf_tree, \
1070                                 tvb, curr_offset, 1, \
1071                                 "Not enough data available"); \
1072                 } \
1073                 tmp_oct = tvb_get_guint8(tvb, curr_offset); \
1074                 oct |= tmp_oct<<(32-8-bits_in_oct); \
1075                 curr_len--; \
1076                 curr_offset++; \
1077                 if ( bits_in_oct != 0 ) \
1078                         add_ocetets = 1; \
1079                 else \
1080                         add_ocetets = 0; \
1081                 bits_in_oct += 8; \
1082         } \
1083         else \
1084                 add_ocetets = 0;
1085
1086 /* Access Technology Type */
1087
1088 static const value_string gsm_a_gm_acc_tech_type_vals[] = {
1089         { 0x00, "GSM P" },
1090         { 0x01, "GSM E --note that GSM E covers GSM P" },
1091         { 0x02, "GSM R --note that GSM R covers GSM E and GSM P" },
1092         { 0x03, "GSM 1800" },
1093         { 0x04, "GSM 1900" },
1094         { 0x05, "GSM 450" },
1095         { 0x06, "GSM 480" },
1096         { 0x07, "GSM 850" },
1097         { 0x08, "GSM 750" },
1098         { 0x09, "GSM T 380" },
1099         { 0x0a, "GSM T 410" },
1100         { 0x0b, "GSM T 900" },
1101         { 0x0c, "GSM 710" },
1102         { 0x0d, "GSM T 810" },
1103         { 0x0f, "Indicates the presence of a list of Additional access technologies" },
1104         { 0, NULL }
1105 };
1106
1107 static const true_false_string gsm_a_gm_vgcs = {
1108         "VGCS capability and notifications wanted",
1109         "no VGCS capability or no notifications wanted"
1110 };
1111
1112 static const true_false_string gsm_a_gm_vbs = {
1113         "VBS capability and notifications wanted",
1114         "no VBS capability or no notifications wanted"
1115 };
1116
1117 static const value_string gsm_a_gm_multi_slot_vals[] = {
1118         { 0x00, "Not specified" },
1119         { 0x01, "Max Rx-Slot/TDMA:1 Max Tx-Slot/TDMA:1 Max-Sum-Slot/TDMA:2 Tta:3 Ttb:2 Tra:4 Trb:2 Type:1" },
1120         { 0x02, "Max Rx-Slot/TDMA:2 Max Tx-Slot/TDMA:1 Max-Sum-Slot/TDMA:3 Tta:3 Ttb:2 Tra:3 Trb:1 Type:1" },
1121         { 0x03, "Max Rx-Slot/TDMA:2 Max Tx-Slot/TDMA:2 Max-Sum-Slot/TDMA:3 Tta:3 Ttb:2 Tra:3 Trb:1 Type:1" },
1122         { 0x04, "Max Rx-Slot/TDMA:3 Max Tx-Slot/TDMA:1 Max-Sum-Slot/TDMA:4 Tta:3 Ttb:1 Tra:3 Trb:1 Type:1" },
1123         { 0x05, "Max Rx-Slot/TDMA:2 Max Tx-Slot/TDMA:2 Max-Sum-Slot/TDMA:4 Tta:3 Ttb:1 Tra:3 Trb:1 Type:1" },
1124         { 0x06, "Max Rx-Slot/TDMA:3 Max Tx-Slot/TDMA:2 Max-Sum-Slot/TDMA:4 Tta:3 Ttb:1 Tra:3 Trb:1 Type:1" },
1125         { 0x07, "Max Rx-Slot/TDMA:3 Max Tx-Slot/TDMA:3 Max-Sum-Slot/TDMA:4 Tta:3 Ttb:1 Tra:3 Trb:1 Type:1" },
1126         { 0x08, "Max Rx-Slot/TDMA:4 Max Tx-Slot/TDMA:1 Max-Sum-Slot/TDMA:5 Tta:3 Ttb:1 Tra:2 Trb:1 Type:1" },
1127         { 0x09, "Max Rx-Slot/TDMA:3 Max Tx-Slot/TDMA:2 Max-Sum-Slot/TDMA:5 Tta:3 Ttb:1 Tra:2 Trb:1 Type:1" },
1128         { 0x0a, "Max Rx-Slot/TDMA:4 Max Tx-Slot/TDMA:2 Max-Sum-Slot/TDMA:5 Tta:3 Ttb:1 Tra:2 Trb:1 Type:1" },
1129         { 0x0b, "Max Rx-Slot/TDMA:4 Max Tx-Slot/TDMA:3 Max-Sum-Slot/TDMA:5 Tta:3 Ttb:1 Tra:2 Trb:1 Type:1" },
1130         { 0x0c, "Max Rx-Slot/TDMA:4 Max Tx-Slot/TDMA:4 Max-Sum-Slot/TDMA:5 Tta:2 Ttb:1 Tra:2 Trb:1 Type:1" },
1131         { 0x0d, "Max Rx-Slot/TDMA:3 Max Tx-Slot/TDMA:3 Max-Sum-Slot/TDMA:NA Tta:NA Ttb:a) Tra:3 Trb:a) Type:2 (a: 1 with frequency hopping, 0 otherwise)" },
1132         { 0x0e, "Max Rx-Slot/TDMA:4 Max Tx-Slot/TDMA:4 Max-Sum-Slot/TDMA:NA Tta:NA Ttb:a) Tra:3 Trb:a) Type:2 (a: 1 with frequency hopping, 0 otherwise)" },
1133         { 0x0f, "Max Rx-Slot/TDMA:5 Max Tx-Slot/TDMA:5 Max-Sum-Slot/TDMA:NA Tta:NA Ttb:a) Tra:3 Trb:a) Type:2 (a: 1 with frequency hopping, 0 otherwise)" },
1134         { 0x10, "Max Rx-Slot/TDMA:6 Max Tx-Slot/TDMA:6 Max-Sum-Slot/TDMA:NA Tta:NA Ttb:a) Tra:2 Trb:a) Type:2 (a: 1 with frequency hopping, 0 otherwise)" },
1135         { 0x11, "Max Rx-Slot/TDMA:7 Max Tx-Slot/TDMA:7 Max-Sum-Slot/TDMA:NA Tta:NA Ttb:a) Tra:1 Trb:0 Type:2 (a: 1 with frequency hopping, 0 otherwise)" },
1136         { 0x12, "Max Rx-Slot/TDMA:8 Max Tx-Slot/TDMA:8 Max-Sum-Slot/TDMA:NA Tta:NA Ttb:0 Tra:0 Trb:0 Type:2" },
1137         { 0x13, "Max Rx-Slot/TDMA:6 Max Tx-Slot/TDMA:2 Max-Sum-Slot/TDMA:NA Tta:3 Ttb:b) Tra:2 Trb:c) Type:1 (b: 1 with frequency hopping or change from Rx to Tx, 0 otherwise; c: 1 with frequency hopping or change from Tx to Rx, 0 otherwise" },
1138         { 0x14, "Max Rx-Slot/TDMA:6 Max Tx-Slot/TDMA:3 Max-Sum-Slot/TDMA:NA Tta:3 Ttb:b) Tra:2 Trb:c) Type:1 (b: 1 with frequency hopping or change from Rx to Tx, 0 otherwise; c: 1 with frequency hopping or change from Tx to Rx, 0 otherwise" },
1139         { 0x15, "Max Rx-Slot/TDMA:6 Max Tx-Slot/TDMA:4 Max-Sum-Slot/TDMA:NA Tta:3 Ttb:b) Tra:2 Trb:c) Type:1 (b: 1 with frequency hopping or change from Rx to Tx, 0 otherwise; c: 1 with frequency hopping or change from Tx to Rx, 0 otherwise" },
1140         { 0x16, "Max Rx-Slot/TDMA:6 Max Tx-Slot/TDMA:4 Max-Sum-Slot/TDMA:NA Tta:3 Ttb:b) Tra:2 Trb:c) Type:1 (b: 1 with frequency hopping or change from Rx to Tx, 0 otherwise; c: 1 with frequency hopping or change from Tx to Rx, 0 otherwise" },
1141         { 0x17, "Max Rx-Slot/TDMA:6 Max Tx-Slot/TDMA:6 Max-Sum-Slot/TDMA:NA Tta:3 Ttb:b) Tra:2 Trb:c) Type:1 (b: 1 with frequency hopping or change from Rx to Tx, 0 otherwise; c: 1 with frequency hopping or change from Tx to Rx, 0 otherwise" },
1142         { 0x18, "Max Rx-Slot/TDMA:8 Max Tx-Slot/TDMA:2 Max-Sum-Slot/TDMA:NA Tta:3 Ttb:b) Tra:2 Trb:c) Type:1 (b: 1 with frequency hopping or change from Rx to Tx, 0 otherwise; c: 1 with frequency hopping or change from Tx to Rx, 0 otherwise" },
1143         { 0x19, "Max Rx-Slot/TDMA:8 Max Tx-Slot/TDMA:3 Max-Sum-Slot/TDMA:NA Tta:3 Ttb:b) Tra:2 Trb:c) Type:1 (b: 1 with frequency hopping or change from Rx to Tx, 0 otherwise; c: 1 with frequency hopping or change from Tx to Rx, 0 otherwise" },
1144         { 0x1a, "Max Rx-Slot/TDMA:8 Max Tx-Slot/TDMA:4 Max-Sum-Slot/TDMA:NA Tta:3 Ttb:b) Tra:2 Trb:c) Type:1 (b: 1 with frequency hopping or change from Rx to Tx, 0 otherwise; c: 1 with frequency hopping or change from Tx to Rx, 0 otherwise" },
1145         { 0x1b, "Max Rx-Slot/TDMA:8 Max Tx-Slot/TDMA:4 Max-Sum-Slot/TDMA:NA Tta:3 Ttb:b) Tra:2 Trb:c) Type:1 (b: 1 with frequency hopping or change from Rx to Tx, 0 otherwise; c: 1 with frequency hopping or change from Tx to Rx, 0 otherwise" },
1146         { 0x1c, "Max Rx-Slot/TDMA:8 Max Tx-Slot/TDMA:6 Max-Sum-Slot/TDMA:NA Tta:3 Ttb:b) Tra:2 Trb:c) Type:1 (b: 1 with frequency hopping or change from Rx to Tx, 0 otherwise; c: 1 with frequency hopping or change from Tx to Rx, 0 otherwise" },
1147         { 0x1d, "Max Rx-Slot/TDMA:8 Max Tx-Slot/TDMA:8 Max-Sum-Slot/TDMA:NA Tta:3 Ttb:b) Tra:2 Trb:c) Type:1 (b: 1 with frequency hopping or change from Rx to Tx, 0 otherwise; c: 1 with frequency hopping or change from Tx to Rx, 0 otherwise" },
1148         { 0x1e, "Max Rx-Slot/TDMA:5 Max Tx-Slot/TDMA:1 Max-Sum-Slot/TDMA:6 Tta:2 Ttb:1 Tra:1 Trb:1 Type:1" },
1149         { 0x1f, "Max Rx-Slot/TDMA:5 Max Tx-Slot/TDMA:2 Max-Sum-Slot/TDMA:6 Tta:2 Ttb:1 Tra:1 Trb:1 Type:1" },
1150         { 0x20, "Max Rx-Slot/TDMA:5 Max Tx-Slot/TDMA:3 Max-Sum-Slot/TDMA:6 Tta:2 Ttb:1 Tra:1 Trb:1 Type:1" },
1151         { 0x21, "Max Rx-Slot/TDMA:5 Max Tx-Slot/TDMA:4 Max-Sum-Slot/TDMA:6 Tta:2 Ttb:1 Tra:1 Trb:1 Type:1" },
1152         { 0x22, "Max Rx-Slot/TDMA:5 Max Tx-Slot/TDMA:5 Max-Sum-Slot/TDMA:6 Tta:2 Ttb:1 Tra:1 Trb:1 Type:1" },
1153         { 0x23, "Max Rx-Slot/TDMA:5 Max Tx-Slot/TDMA:1 Max-Sum-Slot/TDMA:6 Tta:2 Ttb:1 Tra:1+to Trb:1 Type:1 (to: to = 31 symbol periods (this can be provided by a TA offset, i.e. a minimum TA value))" },
1154         { 0x24, "Max Rx-Slot/TDMA:5 Max Tx-Slot/TDMA:2 Max-Sum-Slot/TDMA:6 Tta:2 Ttb:1 Tra:1+to Trb:1 Type:1 (to: to = 31 symbol periods (this can be provided by a TA offset, i.e. a minimum TA value))" },
1155         { 0x25, "Max Rx-Slot/TDMA:5 Max Tx-Slot/TDMA:3 Max-Sum-Slot/TDMA:6 Tta:2 Ttb:1 Tra:1+to Trb:1 Type:1 (to: to = 31 symbol periods (this can be provided by a TA offset, i.e. a minimum TA value))" },
1156         { 0x26, "Max Rx-Slot/TDMA:5 Max Tx-Slot/TDMA:4 Max-Sum-Slot/TDMA:6 Tta:2 Ttb:1 Tra:1+to Trb:1 Type:1 (to: to = 31 symbol periods (this can be provided by a TA offset, i.e. a minimum TA value))" },
1157         { 0x27, "Max Rx-Slot/TDMA:5 Max Tx-Slot/TDMA:5 Max-Sum-Slot/TDMA:6 Tta:2 Ttb:1 Tra:1+to Trb:1 Type:1 (to: to = 31 symbol periods (this can be provided by a TA offset, i.e. a minimum TA value))" },
1158         { 0x28, "Max Rx-Slot/TDMA:6 Max Tx-Slot/TDMA:1 Max-Sum-Slot/TDMA:7 Tta:1 Ttb:1 Tra:1 Trb:to Type:1 (to: to = 31 symbol periods (this can be provided by a TA offset, i.e. a minimum TA value))" },
1159         { 0x29, "Max Rx-Slot/TDMA:6 Max Tx-Slot/TDMA:2 Max-Sum-Slot/TDMA:7 Tta:1 Ttb:1 Tra:1 Trb:to Type:1 (to: to = 31 symbol periods (this can be provided by a TA offset, i.e. a minimum TA value))" },
1160         { 0x2a, "Max Rx-Slot/TDMA:6 Max Tx-Slot/TDMA:3 Max-Sum-Slot/TDMA:7 Tta:1 Ttb:1 Tra:1 Trb:to Type:1 (to: to = 31 symbol periods (this can be provided by a TA offset, i.e. a minimum TA value))" },
1161         { 0x2b, "Max Rx-Slot/TDMA:6 Max Tx-Slot/TDMA:4 Max-Sum-Slot/TDMA:7 Tta:1 Ttb:1 Tra:1 Trb:to Type:1 (to: to = 31 symbol periods (this can be provided by a TA offset, i.e. a minimum TA value))" },
1162         { 0x2c, "Max Rx-Slot/TDMA:6 Max Tx-Slot/TDMA:5 Max-Sum-Slot/TDMA:7 Tta:1 Ttb:1 Tra:1 Trb:to Type:1 (to: to = 31 symbol periods (this can be provided by a TA offset, i.e. a minimum TA value))" },
1163         { 0x2d, "Max Rx-Slot/TDMA:6 Max Tx-Slot/TDMA:6 Max-Sum-Slot/TDMA:7 Tta:1 Ttb:1 Tra:1 Trb:to Type:1 (to: to = 31 symbol periods (this can be provided by a TA offset, i.e. a minimum TA value))" },
1164         { 0, NULL }
1165 };
1166
1167 static const value_string gsm_a_gm_dtm_gprs_multi_slot_class_vals[] = {
1168         { 0x00, "Unused. If received, the network shall interpret this as Multislot class 5" },
1169         { 0x01, "Multislot class 5 supported" },
1170         { 0x02, "Multislot class 9 supported" },
1171         { 0x03, "Multislot class 11 supported" },
1172         { 0, NULL }
1173 };
1174
1175 static const true_false_string gsm_a_gm_revision_level_indicator = {
1176         "The ME is Release '99 onwards",
1177         "The ME is Release '98 or older"
1178 };
1179
1180 static const value_string gsm_a_gm_down_adv_rec_perf_vals[] = {
1181         { 0x00, "Downlink Advanced Receiver Performance not supported" },
1182         { 0x01, "Downlink Advanced Receiver Performance - phase I supported" },
1183         { 0x02, "Downlink Advanced Receiver Performance - phase II supported" },
1184         { 0, NULL }
1185 };
1186
1187 static const true_false_string gsm_a_gm_dtm_enh_cap = {
1188         "The mobile station supports enhanced DTM CS establishment and enhanced DTM CS release procedures",
1189         "The mobile station does not support enhanced DTM CS establishment and enhanced DTM CS release procedures"
1190 };
1191
1192 static const value_string gsm_a_gm_dtm_gprs_high_multi_slot_class_vals[] = {
1193         { 0x00, "Unused. If received, the network shall interpret this as 'Multislot class 31 or 36 supported'" },
1194         { 0x01, "Multislot class 31 or 36 supported" },
1195         { 0x02, "Multislot class 32 or 37 supported" },
1196         { 0x03, "Multislot class 33 or 38 supported" },
1197         { 0x04, "Multislot class 41 supported" },
1198         { 0x05, "Multislot class 42 supported" },
1199         { 0x06, "Multislot class 43 supported" },
1200         { 0x07, "Multislot class 44 supported" },
1201         { 0, NULL }
1202 };
1203
1204 static const value_string gsm_a_gm_multi_slot_cap_red_down_dual_carrier_vals[] = {
1205         { 0x00, "No reduction" },
1206         { 0x01, "The MS supports 1 timeslot fewer than the maximum number of receive timeslots" },
1207         { 0x02, "The MS supports 2 timeslots fewer than the maximum number of receive timeslots" },
1208         { 0x03, "The MS supports 3 timeslots fewer than the maximum number of receive timeslots" },
1209         { 0x04, "The MS supports 4 timeslots fewer than the maximum number of receive timeslots" },
1210         { 0x05, "The MS supports 5 timeslots fewer than the maximum number of receive timeslots" },
1211         { 0x06, "The MS supports 6 timeslots fewer than the maximum number of receive timeslots" },
1212         { 0x07, "Reserved for future use" },
1213         { 0, NULL }
1214 };
1215
1216 static const value_string gsm_a_gm_ul_egprs2_vals[] = {
1217         { 0x00, "The mobile station does not support either EGPRS2-A or EGPRS2-B in the uplink" },
1218         { 0x01, "The mobile station supports EGPRS2-A in the uplink" },
1219         { 0x02, "The mobile station supports both EGPRS2-A and EGPRS2-B in the uplink" },
1220         { 0x03, "This value is not used in this release/version of the specifications. If received it shall be interpreted as 'The mobile station supports both EGPRS2-A and EGPRS2-B in the uplink'" },
1221         { 0, NULL }
1222 };
1223
1224 static const value_string gsm_a_gm_dl_egprs2_vals[] = {
1225         { 0x00, "The mobile station does not support either EGPRS2-A or EGPRS2-B in the downlink" },
1226         { 0x01, "The mobile station supports EGPRS2-A in the downlink" },
1227         { 0x02, "The mobile station supports both EGPRS2-A and EGPRS2-B in the downlink" },
1228         { 0x03, "This value is not used in this release/version of the specifications. If received it shall be interpreted as 'The mobile station supports both EGPRS2-A and EGPRS2-B in the downlink'" },
1229         { 0, NULL }
1230 };
1231
1232 static const value_string gsm_a_gm_geran_to_eutra_support_in_geran_ptm_vals[] = {
1233         { 0x00, "None" },
1234         { 0x01, "E-UTRAN Neighbour Cell measurements and MS autonomous cell reselection to E-UTRAN supported" },
1235         { 0x02, "CCN towards E-UTRAN, E-UTRAN Neighbour Cell measurement reporting and Network controlled cell reselection to E-UTRAN supported in addition to capabilities indicated by '01'" },
1236         { 0x03, "PS Handover to E-UTRAN supported in addition to capabilities indicated by '01' and '10'" },
1237         { 0, NULL }
1238 };
1239
1240 static const value_string gsm_a_gm_alt_efta_multi_slot_class_vals[] = {
1241         { 0x00, "No Alternative EFTA multislot class is indicated. Use (DTM) EGPRS (high) multislot class only" },
1242         { 0x01, "Alternative EFTA multislot class is Multislot class 19" },
1243         { 0x02, "Alternative EFTA multislot class is Multislot class 20" },
1244         { 0x03, "Alternative EFTA multislot class is Multislot class 21" },
1245         { 0x04, "Alternative EFTA multislot class is Multislot class 22" },
1246         { 0x05, "Alternative EFTA multislot class is Multislot class 23" },
1247         { 0x06, "Alternative EFTA multislot class is Multislot class 24" },
1248         { 0x07, "Alternative EFTA multislot class is Multislot class 25" },
1249         { 0x08, "Alternative EFTA multislot class is Multislot class 26" },
1250         { 0x09, "Alternative EFTA multislot class is Multislot class 27" },
1251         { 0x0a, "Alternative EFTA multislot class is Multislot class 28" },
1252         { 0x0b, "Alternative EFTA multislot class is Multislot class 29" },
1253         { 0x0c, "Unused" },
1254         { 0x0d, "Unused" },
1255         { 0x0e, "Unused" },
1256         { 0x0f, "Unused" },
1257         { 0, NULL }
1258 };
1259
1260 guint16
1261 de_gmm_ms_radio_acc_cap(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
1262 {
1263         guint32      curr_offset;
1264         guint        curr_len;
1265         int          bit_offset;
1266         proto_item  *tf = NULL, *mc_item = NULL;
1267         proto_tree  *tf_tree = NULL, *mc_tree = NULL;
1268         guint32      oct;
1269         guchar       bits_in_oct;
1270         guchar       bits_needed;
1271         guint        bits_length;
1272         guint        add_ocetets;       /* octets which are covered by one element -1 */
1273         guint        curr_bits_length;
1274         guchar       acc_type;
1275         guint        value;
1276         const gchar *str;
1277         guint indx = 0;
1278         guchar dtm_gprs_mslot = 0;
1279         guchar dtm_egprs_mslot = 4;
1280         gboolean finished = TRUE;
1281
1282         curr_len = len;
1283         curr_offset = offset;
1284         bit_offset = offset<<3;
1285
1286         bits_in_oct = 0;
1287         oct = 0;
1288
1289
1290         do
1291         {
1292                 /* check for a new round */
1293                 if (( curr_len*8 + bits_in_oct ) < 11 )
1294                         break;
1295
1296                 /* now read the first 11 bits */
1297                 curr_bits_length = 11;
1298                 /*
1299                  *
1300                  */
1301                 if ( curr_len != len )
1302                 {
1303                         bits_needed = 1;
1304                         GET_DATA;
1305
1306                         if (( oct>>(32-bits_needed) ) == 1 )
1307                         {
1308                                 curr_bits_length -= bits_needed;
1309                                 oct <<= bits_needed;
1310                                 bits_in_oct -= bits_needed;
1311                                 bit_offset++;
1312
1313                                 if (( curr_len*8 + bits_in_oct ) < 11 )
1314                                         break;
1315                                 curr_bits_length = 11;
1316                         }
1317                         else
1318                         {
1319                                 curr_bits_length -= bits_needed;
1320                                 oct <<= bits_needed;
1321                                 bits_in_oct -= bits_needed;
1322                                 bit_offset++;
1323                                 break;
1324                         }
1325                 }
1326
1327                 indx++;
1328                 tf = proto_tree_add_text(tree,
1329                                 tvb, curr_offset, 1,
1330                                 "MS RA capability %d",indx);
1331
1332                 tf_tree = proto_item_add_subtree(tf, ett_gmm_radio_cap );
1333
1334                 /*
1335                  * Access Technology
1336                  */
1337                 bits_needed = 4;
1338                 GET_DATA;
1339
1340                 acc_type = oct>>(32-bits_needed);
1341
1342                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_acc_tech_type, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
1343                 bit_offset+=4;
1344
1345                 curr_bits_length -= bits_needed;
1346                 oct <<= bits_needed;
1347                 bits_in_oct -= bits_needed;
1348
1349                 /* < Access capabilities struct > ::= */
1350                 /*
1351                  * get bits_length
1352                  */
1353                 bits_needed = 7;
1354                 GET_DATA;
1355
1356                 bits_length = curr_bits_length = oct>>(32-bits_needed);
1357
1358                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_acc_cap_struct_len, tvb, bit_offset, 7, ENC_BIG_ENDIAN);
1359                 proto_item_set_len(tf, (bits_length>>3)+1);
1360                 /* This is already done - length doesn't contain this field
1361                  curr_bits_length -= bits_needed;
1362                 */
1363                 bit_offset+=7;
1364                 oct <<= bits_needed;
1365                 bits_in_oct -= bits_needed;
1366
1367                 if ( acc_type == 0x0f )
1368                 {
1369                         do
1370                         {
1371                                 /*
1372                                  * Additional access technologies:
1373                                  */
1374                                 finished = TRUE; /* Break out of the loop unless proven unfinished */
1375
1376                                 /*
1377                                  * Presence bit
1378                                  */
1379                                 bits_needed = 1;
1380                                 GET_DATA;
1381
1382                                 /* analyse bits */
1383                                 switch ( oct>>(32-bits_needed) )
1384                                 {
1385                                         case 0x00: str="Not Present"; finished = TRUE; break;
1386                                         case 0x01: str="Present"; finished = FALSE;    break;
1387                                         default:   str="This should not happen";
1388                                 }
1389
1390                                 proto_tree_add_text(tf_tree,
1391                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1392                                         "Presence: %s (%u)", str, oct>>(32-bits_needed));
1393                                 bit_offset++;
1394                                 curr_bits_length -= bits_needed;
1395                                 oct <<= bits_needed;
1396                                 bits_in_oct -= bits_needed;
1397
1398                                 if (finished)
1399                                 {
1400                                         /*
1401                                          * No more valid data, get spare bits if any
1402                                          */
1403                                         while ( curr_bits_length > 0 )
1404                                         {
1405                                                 if ( curr_bits_length > 8 )
1406                                                         bits_needed = 8;
1407                                                 else
1408                                                         bits_needed = curr_bits_length;
1409                                                 GET_DATA;
1410                                                 curr_bits_length -= bits_needed;
1411                                                 oct <<= bits_needed;
1412                                                 bits_in_oct -= bits_needed;
1413                                                 bit_offset+= bits_needed;
1414                                         }
1415                                         continue;
1416                                 }
1417
1418                                 /*
1419                                  * Access Technology
1420                                  */
1421                                 bits_needed = 4;
1422                                 GET_DATA;
1423
1424                                 acc_type = oct>>(32-bits_needed);
1425
1426                                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_acc_cap_struct_len, tvb, bit_offset, 7, ENC_BIG_ENDIAN);
1427                                 bit_offset+=4;
1428
1429                                 curr_bits_length -= bits_needed;
1430                                 oct <<= bits_needed;
1431                                 bits_in_oct -= bits_needed;
1432
1433                                 /*
1434                                  * RF Power
1435                                  */
1436                                 bits_needed = 3;
1437                                 GET_DATA;
1438
1439                                 value = tvb_get_bits8(tvb, bit_offset, 3);
1440                                 /* analyse bits */
1441                                 if ( acc_type == 0x04 ) /* GSM 1900 */
1442                                 {
1443                                         switch ( value )
1444                                         {
1445                                                 case 0x01: str="1 W (30 dBm)";    break;
1446                                                 case 0x02: str="0,25 W (24 dBm)"; break;
1447                                                 case 0x03: str="2 W (33 dBm)";    break;
1448                                                 default:   str="Not specified";
1449                                         }
1450                                 }
1451                                 else if ( acc_type == 0x03 )
1452                                 {
1453                                         /*
1454                                          * 3 GSM 1800
1455                                          */
1456                                         switch ( value )
1457                                         {
1458                                                 case 0x01: str="1 W (30 dBm)";    break;
1459                                                 case 0x02: str="0,25 W (24 dBm)"; break;
1460                                                 case 0x03: str="4 W (36 dBm)";    break;
1461                                                 default:   str="Not specified";
1462                                         }
1463                                 }
1464                                 else if ( acc_type <= 0x08 )
1465                                 {
1466                                         /* 0 GSM P
1467                                          * 1 GSM E
1468                                          * 2 GSM R
1469                                          * 5 GSM 450
1470                                          * 6 GSM 480
1471                                          * 7 GSM 850
1472                                          */
1473
1474                                         switch ( value )
1475                                         {
1476                                                 case 0x02: str="8 W (39 dBm)";   break;
1477                                                 case 0x03: str="5 W (37 dBm)";   break;
1478                                                 case 0x04: str="2 W (33 dBm)";   break;
1479                                                 case 0x05: str="0,8 W (29 dBm)"; break;
1480                                                 default:   str="Not specified";
1481                                         }
1482                                 }
1483                                 else
1484                                         str="Not specified??";
1485
1486                                 /* decode_bits_in_field(gint bit_offset, gint no_of_bits, guint64 value)*/
1487                                 proto_tree_add_text(tf_tree,
1488                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1489                                         "%s RF Power Capability, GMSK Power Class: %s (%u)", decode_bits_in_field(bit_offset, 3, value), str, value);
1490                                 bit_offset+=3;
1491                                 curr_bits_length -= bits_needed;
1492                                 oct <<= bits_needed;
1493                                 bits_in_oct -= bits_needed;
1494
1495                                 /*
1496                                  * 8PSK Power Class
1497                                  */
1498                                 bits_needed = 2;
1499                                 GET_DATA;
1500
1501                                 value = tvb_get_bits8(tvb, bit_offset, 2);
1502                                 /* analyse bits */
1503                                 switch ( value )
1504                                 {
1505                                         case 0x00: str="8PSK modulation not supported for uplink"; break;
1506                                         case 0x01: str="Power class E1"; break;
1507                                         case 0x02: str="Power class E2"; break;
1508                                         case 0x03: str="Power class E3"; break;
1509                                         default:   str="This should not happen";
1510                                 }
1511
1512                                 proto_tree_add_text(tf_tree,
1513                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1514                                         "8PSK Power Class: %s (%u)",str,value);
1515                                 bit_offset+=2;
1516                                 curr_bits_length -= bits_needed;
1517                                 oct <<= bits_needed;
1518                                 bits_in_oct -= bits_needed;
1519
1520                         } while (!finished);
1521
1522                         /* goto next one */
1523                         continue;
1524                 }
1525                 /*
1526                  * RF Power
1527                  */
1528                 bits_needed = 3;
1529                 GET_DATA;
1530
1531                 value = tvb_get_bits8(tvb, bit_offset, 3);
1532                 /* analyse bits */
1533                 if ( acc_type == 0x04 ) /* GSM 1900 */
1534                 {
1535                         switch ( value )
1536                         {
1537                                 case 0x01: str="1 W (30 dBm)";    break;
1538                                 case 0x02: str="0,25 W (24 dBm)"; break;
1539                                 case 0x03: str="2 W (33 dBm)";    break;
1540                                 default:   str="Not specified";
1541                         }
1542                 }
1543                 else if ( acc_type == 0x03 )
1544                 {
1545                         switch ( value )
1546                         {
1547                                 case 0x01: str="1 W (30 dBm)";    break;
1548                                 case 0x02: str="0,25 W (24 dBm)"; break;
1549                                 case 0x03: str="4 W (36 dBm)";    break;
1550                                 default:   str="Not specified";
1551                         }
1552                 }
1553                 else if ( acc_type <= 0x08 )
1554                 {
1555                         switch ( value )
1556                         {
1557                                 case 0x02: str="8 W (39 dBm)";   break;
1558                                 case 0x03: str="5 W (37 dBm)";   break;
1559                                 case 0x04: str="2 W (33 dBm)";   break;
1560                                 case 0x05: str="0,8 W (29 dBm)"; break;
1561                                 default:   str="Not specified";
1562                         }
1563                 }
1564                 else
1565                         str="Not specified??";
1566
1567                 proto_tree_add_text(tf_tree,
1568                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1569                         "%s RF Power Capability, GMSK Power Class: %s (%u)", decode_bits_in_field(bit_offset, 3, value),str,value);
1570
1571                 bit_offset+=3;
1572                 curr_bits_length -= bits_needed;
1573                 oct <<= bits_needed;
1574                 bits_in_oct -= bits_needed;
1575
1576                 /*
1577                  * A5 Bits?
1578                  */
1579                 bits_needed = 1;
1580                 GET_DATA;
1581
1582                 /* analyse bits */
1583                 if ((oct>>(32-bits_needed))==0)
1584                 {
1585                         proto_tree_add_text(tf_tree,
1586                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1587                                 "A5 Bits: Same values apply for parameters as in the immediately preceding Access capabilities field within this IE (%u)",oct>>(32-bits_needed));
1588                         bit_offset++;
1589                         curr_bits_length -= bits_needed;
1590                         oct <<= bits_needed;
1591                         bits_in_oct -= bits_needed;
1592                 }
1593                 else
1594                 {
1595                         int i;
1596
1597                         proto_tree_add_text(tf_tree,
1598                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1599                                 "A5 Bits: A5 bits follow (%u)",oct>>(32-bits_needed));
1600
1601                         bit_offset++;
1602                         curr_bits_length -= bits_needed;
1603                         oct <<= bits_needed;
1604                         bits_in_oct -= bits_needed;
1605
1606                         for (i=1; i<= 7 ; i++ )
1607                         {
1608                                 /*
1609                                  * A5 Bits decoding
1610                                  */
1611                                 bits_needed = 1;
1612                                 GET_DATA;
1613
1614                                 /* analyse bits */
1615                                 switch ( oct>>(32-bits_needed) )
1616                                 {
1617                                         case 0x00: str="encryption algorithm not available"; break;
1618                                         case 0x01: str="encryption algorithm available";     break;
1619                                         default:   str="This should not happen";
1620                                 }
1621
1622                                 proto_tree_add_text(tf_tree,
1623                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1624                                         "A5/%d: %s (%u)",i,str,oct>>(32-bits_needed));
1625                                 bit_offset++;
1626                                 curr_bits_length -= bits_needed;
1627                                 oct <<= bits_needed;
1628                                 bits_in_oct -= bits_needed;
1629                         }
1630                 }
1631
1632                 /*
1633                  * ES IND
1634                  */
1635                 bits_needed = 1;
1636                 GET_DATA;
1637
1638                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_ctrled_early_cm_sending, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1639                 bit_offset++;
1640                 curr_bits_length -= bits_needed;
1641                 oct <<= bits_needed;
1642                 bits_in_oct -= bits_needed;
1643
1644                 /*
1645                  * PS
1646                  */
1647                 bits_needed = 1;
1648                 GET_DATA;
1649
1650                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_pseudo_sync, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1651                 bit_offset++;
1652                 curr_bits_length -= bits_needed;
1653                 oct <<= bits_needed;
1654                 bits_in_oct -= bits_needed;
1655
1656                 /*
1657                  * VGCS
1658                  */
1659                 bits_needed = 1;
1660                 GET_DATA;
1661
1662                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_vgcs, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1663                 bit_offset++;
1664                 curr_bits_length -= bits_needed;
1665                 oct <<= bits_needed;
1666                 bits_in_oct -= bits_needed;
1667
1668                 /*
1669                  * VBS
1670                  */
1671                 bits_needed = 1;
1672                 GET_DATA;
1673
1674                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_vbs, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1675                 bit_offset++;
1676                 curr_bits_length -= bits_needed;
1677                 oct <<= bits_needed;
1678                 bits_in_oct -= bits_needed;
1679
1680                 /*
1681                  * Multislot capability?
1682                  */
1683                 bits_needed = 1;
1684                 GET_DATA;
1685
1686                 value = oct>>(32-bits_needed);
1687
1688                 mc_item = proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_multislot_capability, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1689                 bit_offset++;
1690
1691                 curr_bits_length -= bits_needed;
1692                 oct <<= bits_needed;
1693                 bits_in_oct -= bits_needed;
1694
1695                 /* analyse bits */
1696                 if (value==1)
1697                 {
1698                         mc_tree = proto_item_add_subtree(mc_item, ett_gsm_a_gm_msrac_multislot_capability);
1699                         /*
1700                          * HSCSD multislot class?
1701                          */
1702                         bits_needed = 1;
1703                         GET_DATA;
1704
1705                         /* analyse bits */
1706                         if ((oct>>(32-bits_needed))==0)
1707                         {
1708                                 proto_tree_add_text(mc_tree,
1709                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1710                                         "HSCSD multislot class: Bits are not available (%u)",oct>>(32-bits_needed));
1711                                 bit_offset++;
1712                                 curr_bits_length -= bits_needed;
1713                                 oct <<= bits_needed;
1714                                 bits_in_oct -= bits_needed;
1715                         }
1716                         else
1717                         {
1718                                 curr_bits_length -= bits_needed;
1719                                 oct <<= bits_needed;
1720                                 bits_in_oct -= bits_needed;
1721                                 bit_offset++;
1722
1723                                 /*
1724                                  * HSCSD multislot class
1725                                  */
1726                                 bits_needed = 5;
1727                                 GET_DATA;
1728
1729                                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_hscsd_multi_slot_class, tvb, bit_offset, 5, ENC_BIG_ENDIAN);
1730                                 bit_offset+=5;
1731                                 curr_bits_length -= bits_needed;
1732                                 oct <<= bits_needed;
1733                                 bits_in_oct -= bits_needed;
1734                         }
1735
1736                         /*
1737                          * GPRS multislot class?
1738                          */
1739                         bits_needed = 1;
1740                         GET_DATA;
1741
1742                         /* analyse bits */
1743                         if ((oct>>(32-bits_needed))==0)
1744                         {
1745                                 proto_tree_add_text(mc_tree,
1746                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1747                                         "GPRS multislot class: Bits are not available (%u)",oct>>(32-bits_needed));
1748                                 bit_offset++;
1749                                 curr_bits_length -= bits_needed;
1750                                 oct <<= bits_needed;
1751                                 bits_in_oct -= bits_needed;
1752                         }
1753                         else
1754                         {
1755                                 curr_bits_length -= bits_needed;
1756                                 oct <<= bits_needed;
1757                                 bits_in_oct -= bits_needed;
1758                                 bit_offset++;
1759
1760                                 /*
1761                                  * GPRS multislot class
1762                                  */
1763                                 bits_needed = 5;
1764                                 GET_DATA;
1765
1766                                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_gprs_multi_slot_class, tvb, bit_offset, 5, ENC_BIG_ENDIAN);
1767                                 bit_offset+=5;
1768                                 curr_bits_length -= bits_needed;
1769                                 oct <<= bits_needed;
1770                                 bits_in_oct -= bits_needed;
1771
1772                                 /*
1773                                  * GPRS Extended Dynamic Allocation Capability
1774                                  */
1775                                 bits_needed = 1;
1776                                 GET_DATA;
1777
1778                                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_gprs_ext_dyn_alloc_cap, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1779                                 bit_offset++;
1780                                 curr_bits_length -= bits_needed;
1781                                 oct <<= bits_needed;
1782                                 bits_in_oct -= bits_needed;
1783                         }
1784
1785                         /*
1786                          * SMS/SM values
1787                          */
1788                         bits_needed = 1;
1789                         GET_DATA;
1790
1791                         /* analyse bits */
1792                         if ((oct>>(32-bits_needed))==0)
1793                         {
1794                                 proto_tree_add_text(mc_tree,
1795                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1796                                         "SMS/SM values: Bits are not available (%u)",oct>>(32-bits_needed));
1797                                 bit_offset++;
1798                                 curr_bits_length -= bits_needed;
1799                                 oct <<= bits_needed;
1800                                 bits_in_oct -= bits_needed;
1801                         }
1802                         else
1803                         {
1804                                 curr_bits_length -= bits_needed;
1805                                 oct <<= bits_needed;
1806                                 bits_in_oct -= bits_needed;
1807                                 bit_offset++;
1808
1809                                 /*
1810                                  * Switch-Measure-Switch value
1811                                  */
1812                                 bits_needed = 4;
1813                                 GET_DATA;
1814
1815                                 /* analyse bits */
1816                                 proto_tree_add_bits_item(mc_tree, hf_gsm_a_gm_sms_value, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
1817                                 bit_offset+=4;
1818                                 curr_bits_length -= bits_needed;
1819                                 oct <<= bits_needed;
1820                                 bits_in_oct -= bits_needed;
1821
1822                                 /*
1823                                  * Switch-Measure value
1824                                  */
1825                                 bits_needed = 4;
1826                                 GET_DATA;
1827
1828                                 /* analyse bits */
1829                                 proto_tree_add_bits_item(mc_tree, hf_gsm_a_gm_sm_value, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
1830                                 bit_offset+=4;
1831                                 curr_bits_length -= bits_needed;
1832                                 oct <<= bits_needed;
1833                                 bits_in_oct -= bits_needed;
1834                         }
1835
1836                         /*
1837                          * ECSD multislot class?
1838                          */
1839                         bits_needed = 1;
1840                         GET_DATA;
1841
1842                         /* analyse bits */
1843                         if ((oct>>(32-bits_needed))==0)
1844                         {
1845                                 proto_tree_add_text(mc_tree,
1846                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1847                                         "ECSD multislot class: Bits are not available (%u)",oct>>(32-bits_needed));
1848                                 bit_offset++;
1849                                 curr_bits_length -= bits_needed;
1850                                 oct <<= bits_needed;
1851                                 bits_in_oct -= bits_needed;
1852                         }
1853                         else
1854                         {
1855                                 curr_bits_length -= bits_needed;
1856                                 oct <<= bits_needed;
1857                                 bits_in_oct -= bits_needed;
1858                                 bit_offset++;
1859
1860                                 /*
1861                                  * ECSD multislot class
1862                                  */
1863                                 bits_needed = 5;
1864                                 GET_DATA;
1865
1866                                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_ecsd_multi_slot_class, tvb, bit_offset, 5, ENC_BIG_ENDIAN);
1867                                 bit_offset+=5;
1868                                 curr_bits_length -= bits_needed;
1869                                 oct <<= bits_needed;
1870                                 bits_in_oct -= bits_needed;
1871                         }
1872
1873                         /*
1874                          * EGPRS multislot class?
1875                          */
1876                         bits_needed = 1;
1877                         GET_DATA;
1878
1879                         /* analyse bits */
1880                         if ((oct>>(32-bits_needed))==0)
1881                         {
1882                                 proto_tree_add_text(mc_tree,
1883                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1884                                         "EGPRS multislot class: Bits are not available (%u)",oct>>(32-bits_needed));
1885                                 curr_bits_length -= bits_needed;
1886                                 oct <<= bits_needed;
1887                                 bits_in_oct -= bits_needed;
1888                                 bit_offset++;
1889                         }
1890                         else
1891                         {
1892                                 curr_bits_length -= bits_needed;
1893                                 oct <<= bits_needed;
1894                                 bits_in_oct -= bits_needed;
1895                                 bit_offset++;
1896
1897                                 /*
1898                                  * EGPRS multislot class
1899                                  */
1900                                 bits_needed = 5;
1901                                 GET_DATA;
1902
1903                                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_egprs_multi_slot_class, tvb, bit_offset, 5, ENC_BIG_ENDIAN);
1904                                 bit_offset+=5;
1905                                 curr_bits_length -= bits_needed;
1906                                 oct <<= bits_needed;
1907                                 bits_in_oct -= bits_needed;
1908
1909                                 /*
1910                                  * EGPRS Extended Dynamic Allocation Capability
1911                                  */
1912                                 bits_needed = 1;
1913                                 GET_DATA;
1914
1915                                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_egprs_ext_dyn_alloc_cap, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1916                                 bit_offset++;
1917                                 curr_bits_length -= bits_needed;
1918                                 oct <<= bits_needed;
1919                                 bits_in_oct -= bits_needed;
1920                         }
1921
1922                         /*
1923                          * DTM GPRS Multi Slot Class ?
1924                         */
1925                         bits_needed = 1;
1926                         GET_DATA;
1927
1928                         /* analyse bits */
1929                         if ((oct>>(32-bits_needed))==0)
1930                         {
1931                                 proto_tree_add_text(mc_tree,
1932                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1933                                         "DTM GPRS Multi Slot Class: Bits are not available (%u)",oct>>(32-bits_needed));
1934                                 bit_offset++;
1935                                 curr_bits_length -= bits_needed;
1936                                 oct <<= bits_needed;
1937                                 bits_in_oct -= bits_needed;
1938                         }
1939                         else
1940                         {
1941                                 curr_bits_length -= bits_needed;
1942                                 oct <<= bits_needed;
1943                                 bits_in_oct -= bits_needed;
1944                                 bit_offset++;
1945
1946                                 /*
1947                                  * DTM GPRS Multi Slot Class
1948                                  */
1949                                 bits_needed = 2;
1950                                 GET_DATA;
1951
1952                                 /* analyse bits */
1953                                 dtm_gprs_mslot = oct>>(32-bits_needed);
1954
1955                                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_dtm_gprs_multi_slot_class, tvb, bit_offset, 2, ENC_BIG_ENDIAN);
1956                                 bit_offset+=2;
1957                                 curr_bits_length -= bits_needed;
1958                                 oct <<= bits_needed;
1959                                 bits_in_oct -= bits_needed;
1960
1961                                 /*
1962                                  * Single Slot DTM
1963                                  */
1964                                 bits_needed = 1;
1965                                 GET_DATA;
1966
1967                                 proto_tree_add_bits_item(mc_tree, hf_gsm_a_gm_rac_single_slt_dtm, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1968                                 bit_offset++;
1969                                 curr_bits_length -= bits_needed;
1970                                 oct <<= bits_needed;
1971                                 bits_in_oct -= bits_needed;
1972
1973                                 /*
1974                                  * DTM EGPRS Multi Slot Class ?
1975                                 */
1976                                 bits_needed = 1;
1977                                 GET_DATA;
1978
1979                                 /* analyse bits */
1980                                 dtm_egprs_mslot = oct>>(32-bits_needed);
1981                                 proto_tree_add_bits_item(mc_tree, hf_gsm_a_gm_rac_dtm_egprs_multi_slot_cls_pres, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1982                                 bit_offset++;
1983                                 curr_bits_length -= bits_needed;
1984                                 oct <<= bits_needed;
1985                                 bits_in_oct -= bits_needed;
1986
1987                                 if ((oct>>(32-bits_needed))==1)
1988                                 {
1989                                         /*
1990                                          * DTM EGPRS Multi Slot Class
1991                                          */
1992                                         bits_needed = 2;
1993                                         GET_DATA;
1994
1995                                         proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_dtm_egprs_multi_slot_class, tvb, bit_offset, 2, ENC_BIG_ENDIAN);
1996                                         bit_offset+=2;
1997                                         curr_bits_length -= bits_needed;
1998                                         oct <<= bits_needed;
1999                                         bits_in_oct -= bits_needed;
2000                                 }
2001                         }
2002                 }
2003
2004                 /*
2005                  * 8PSK Power Capability?
2006                  */
2007                 bits_needed = 1;
2008                 GET_DATA;
2009
2010                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_8psk_pow_cap_pres, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2011                 bit_offset++;
2012                 curr_bits_length -= bits_needed;
2013                 oct <<= bits_needed;
2014                 bits_in_oct -= bits_needed;
2015
2016                 /* analyse bits */
2017                 if ((oct>>(32-bits_needed))==1)
2018                 {
2019                         /*
2020                          * 8PSK Power Capability
2021                          */
2022                         bits_needed = 2;
2023                         GET_DATA;
2024
2025                         /* analyse bits */
2026                         switch ( oct>>(32-bits_needed) )
2027                         {
2028                                 case 0x00: str="Reserved";       break;
2029                                 case 0x01: str="Power class E1"; break;
2030                                 case 0x02: str="Power class E2"; break;
2031                                 case 0x03: str="Power class E3"; break;
2032                                 default:   str="This should not happen";
2033                         }
2034
2035                         proto_tree_add_text(tf_tree,
2036                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
2037                                 "8PSK Power Capability: %s (%u)",str,oct>>(32-bits_needed));
2038                         bit_offset+=2;
2039                         curr_bits_length -= bits_needed;
2040                         oct <<= bits_needed;
2041                         bits_in_oct -= bits_needed;
2042                 }
2043
2044                 /*
2045                  * COMPACT Interference Measurement Capability
2046                  */
2047                 bits_needed = 1;
2048                 GET_DATA;
2049
2050                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_comp_int_meas_cap, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2051                 bit_offset++;
2052                 curr_bits_length -= bits_needed;
2053                 oct <<= bits_needed;
2054                 bits_in_oct -= bits_needed;
2055
2056                 /*
2057                  * Revision Level Indicator
2058                  */
2059                 bits_needed = 1;
2060                 GET_DATA;
2061
2062                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rel_lev_ind, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2063                 bit_offset++;
2064                 curr_bits_length -= bits_needed;
2065                 oct <<= bits_needed;
2066                 bits_in_oct -= bits_needed;
2067
2068                 /*
2069                  * UMTS FDD Radio Access Technology Capability
2070                  */
2071                 bits_needed = 1;
2072                 GET_DATA;
2073
2074                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_umts_fdd_cap, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2075                 bit_offset++;
2076                 curr_bits_length -= bits_needed;
2077                 oct <<= bits_needed;
2078                 bits_in_oct -= bits_needed;
2079
2080                 /*
2081                  * UMTS 3.84 Mcps TDD Radio Access Technology Capability
2082                  */
2083                 bits_needed = 1;
2084                 GET_DATA;
2085
2086                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_umts_384_tdd_ra_cap, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2087                 bit_offset++;
2088                 curr_bits_length -= bits_needed;
2089                 oct <<= bits_needed;
2090                 bits_in_oct -= bits_needed;
2091
2092                 /*
2093                  * CDMA 2000 Radio Access Technology Capability
2094                  */
2095                 bits_needed = 1;
2096                 GET_DATA;
2097
2098                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_cdma2000_cap, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2099                 bit_offset++;
2100                 curr_bits_length -= bits_needed;
2101                 oct <<= bits_needed;
2102                 bits_in_oct -= bits_needed;
2103
2104                 /*
2105                  * UMTS 1.28 Mcps TDD Radio Access Technology Capability
2106                  */
2107                 bits_needed = 1;
2108                 GET_DATA;
2109
2110                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_umts_128_tdd_ra_cap, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2111                 bit_offset++;
2112                 curr_bits_length -= bits_needed;
2113                 oct <<= bits_needed;
2114                 bits_in_oct -= bits_needed;
2115
2116                 /*
2117                  * GERAN Feature Package 1
2118                  */
2119                 bits_needed = 1;
2120                 GET_DATA;
2121
2122                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_geran_feat_pkg, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2123                 bit_offset++;
2124                 curr_bits_length -= bits_needed;
2125                 oct <<= bits_needed;
2126                 bits_in_oct -= bits_needed;
2127
2128                 /*
2129                  * Extended DTM (E)GPRS Multi Slot Class
2130                  */
2131
2132                 bits_needed = 1;
2133                 GET_DATA;
2134
2135                 /* analyse bits */
2136                 if ((oct>>(32-bits_needed))==0)
2137                 {
2138                         proto_tree_add_text(tf_tree,
2139                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
2140                                 "Extended DTM (E)GPRS Multi Slot Class: Bits are not available (%u)",oct>>(32-bits_needed));
2141                         curr_bits_length -= bits_needed;
2142                         oct <<= bits_needed;
2143                         bits_in_oct -= bits_needed;
2144                         bit_offset++;
2145                 }
2146                 else
2147                 {
2148                         curr_bits_length -= bits_needed;
2149                         oct <<= bits_needed;
2150                         bits_in_oct -= bits_needed;
2151                         bit_offset++;
2152
2153                         /*
2154                          * Extended DTM GPRS Multi Slot Class
2155                          */
2156                         bits_needed = 2;
2157                         GET_DATA;
2158
2159                         /* analyse bits */
2160                         switch ( (oct>>(32-bits_needed))|(dtm_gprs_mslot<<4) )
2161                         {
2162                                 case 0x00: str="Unused. If received, it shall be interpreted as Multislot class 5 supported";  break;
2163                                 case 0x01: str="Unused. If received, it shall be interpreted as Multislot class 5 supported";  break;
2164                                 case 0x02: str="Unused. If received, it shall be interpreted as Multislot class 5 supported";  break;
2165                                 case 0x03: str="Unused. If received, it shall be interpreted as Multislot class 5 supported";  break;
2166                                 case 0x10: str="Multislot class 5 supported";  break;
2167                                 case 0x11: str="Multislot class 6 supported";  break;
2168                                 case 0x12: str="Unused. If received, it shall be interpreted as Multislot class 5 supported";  break;
2169                                 case 0x13: str="Unused. If received, it shall be interpreted as Multislot class 5 supported";  break;
2170                                 case 0x20: str="Multislot class 9 supported";  break;
2171                                 case 0x21: str="Multislot class 10 supported"; break;
2172                                 case 0x22: str="Unused. If received, it shall be interpreted as Multislot class 9 supported";  break;
2173                                 case 0x23: str="Unused. If received, it shall be interpreted as Multislot class 9 supported";  break;
2174                                 case 0x30: str="Multislot class 11 supported"; break;
2175                                 case 0x31: str="Unused. If received, it shall be interpreted as Multislot class 11 supported"; break;
2176                                 case 0x32: str="Unused. If received, it shall be interpreted as Multislot class 11 supported"; break;
2177                                 case 0x33: str="Unused. If received, it shall be interpreted as Multislot class 11 supported"; break;
2178                                 default:   str="This should not happen";
2179                         }
2180
2181                         proto_tree_add_text(tf_tree,
2182                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
2183                                 "Extended DTM GPRS Multi Slot Class: %s (%u)",str,oct>>(32-bits_needed));
2184                         bit_offset+=2;
2185                         curr_bits_length -= bits_needed;
2186                         oct <<= bits_needed;
2187                         bits_in_oct -= bits_needed;
2188
2189                         if ( dtm_egprs_mslot <= 3 )
2190                         {
2191                                 /*
2192                                  * Extended DTM EGPRS Multi Slot Class
2193                                  */
2194                                 bits_needed = 2;
2195                                 GET_DATA;
2196
2197                                 /* analyse bits */
2198                                 switch ( (oct>>(32-bits_needed))|(dtm_egprs_mslot<<4) )
2199                                 {
2200                                         case 0x00: str="Unused. If received, it shall be interpreted as Multislot class 5 supported";  break;
2201                                         case 0x01: str="Unused. If received, it shall be interpreted as Multislot class 5 supported";  break;
2202                                         case 0x02: str="Unused. If received, it shall be interpreted as Multislot class 5 supported";  break;
2203                                         case 0x03: str="Unused. If received, it shall be interpreted as Multislot class 5 supported";  break;
2204                                         case 0x10: str="Multislot class 5 supported";  break;
2205                                         case 0x11: str="Multislot class 6 supported";  break;
2206                                         case 0x12: str="Unused. If received, it shall be interpreted as Multislot class 5 supported";  break;
2207                                         case 0x13: str="Unused. If received, it shall be interpreted as Multislot class 5 supported";  break;
2208                                         case 0x20: str="Multislot class 9 supported";  break;
2209                                         case 0x21: str="Multislot class 10 supported"; break;
2210                                         case 0x22: str="Unused. If received, it shall be interpreted as Multislot class 9 supported";  break;
2211                                         case 0x23: str="Unused. If received, it shall be interpreted as Multislot class 9 supported";  break;
2212                                         case 0x30: str="Multislot class 11 supported"; break;
2213                                         case 0x31: str="Unused. If received, it shall be interpreted as Multislot class 11 supported"; break;
2214                                         case 0x32: str="Unused. If received, it shall be interpreted as Multislot class 11 supported"; break;
2215                                         case 0x33: str="Unused. If received, it shall be interpreted as Multislot class 11 supported"; break;
2216                                         default:   str="This should not happen";
2217                                 }
2218
2219                                 proto_tree_add_text(tf_tree,
2220                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
2221                                         "Extended DTM EGPRS Multi Slot Class: %s (%u)",str, oct>>(32-bits_needed));
2222                                 bit_offset+=2;
2223                                 curr_bits_length -= bits_needed;
2224                                 oct <<= bits_needed;
2225                                 bits_in_oct -= bits_needed;
2226                         }
2227                 }
2228
2229                 /*
2230                  * Modulation based multislot class support
2231                  */
2232                 bits_needed = 1;
2233                 GET_DATA;
2234
2235                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_mod_based_multi_slot_class_support, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2236                 bit_offset++;
2237                 curr_bits_length -= bits_needed;
2238                 oct <<= bits_needed;
2239                 bits_in_oct -= bits_needed;
2240
2241                 /*
2242                  * High Multislot Capability
2243                  */
2244                 bits_needed = 1;
2245                 GET_DATA;
2246
2247                 /* analyse bits */
2248                 if ((oct>>(32-bits_needed))==0)
2249                 {
2250                         proto_tree_add_text(tf_tree,
2251                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
2252                                 "High Multislot Capability: Bits are not available (%u)",oct>>(32-bits_needed));
2253                         bit_offset++;
2254                         curr_bits_length -= bits_needed;
2255                         oct <<= bits_needed;
2256                         bits_in_oct -= bits_needed;
2257                 }
2258                 else
2259                 {
2260                         curr_bits_length -= bits_needed;
2261                         oct <<= bits_needed;
2262                         bits_in_oct -= bits_needed;
2263                         bit_offset++;
2264
2265                         /*
2266                          * High Multislot Capability
2267                          */
2268                         bits_needed = 2;
2269                         GET_DATA;
2270
2271                         /* analyse bits */
2272                         proto_tree_add_text(tf_tree,
2273                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
2274                                             "High Multislot Capability: 0x%02x (%u)"
2275                                             " - This field effect all other multislot fields."
2276                                             " To understand the value please read TS 24.008 5.6.0"
2277                                             " Release 5 Chap 10.5.5.12 Page 406",
2278                                             oct>>(32-bits_needed),
2279                                             oct>>(32-bits_needed));
2280                         bit_offset+=2;
2281                         curr_bits_length -= bits_needed;
2282                         oct <<= bits_needed;
2283                         bits_in_oct -= bits_needed;
2284                 }
2285
2286                 /*
2287                  * GERAN Iu Mode Capability
2288                  */
2289                 bits_needed = 1;
2290                 GET_DATA;
2291
2292                 value = tvb_get_bits8(tvb, bit_offset, 1);
2293                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_geran_iu_mode_cap, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2294                 bit_offset+=bits_needed;
2295                 curr_bits_length -= bits_needed;
2296                 oct <<= bits_needed;
2297                 bits_in_oct -= bits_needed;
2298                 if (value)
2299                 {
2300                         /* GERAN Iu Mode Capabilities struct present */
2301                         bits_needed = 4;
2302                         GET_DATA;
2303                         value = tvb_get_bits8(tvb, bit_offset, 4);
2304                         bit_offset+=bits_needed;
2305                         curr_bits_length -= bits_needed;
2306                         oct <<= bits_needed;
2307                         bits_in_oct -= bits_needed;
2308                         if (value)
2309                         {
2310                                 /*
2311                                  * FLO Iu Capability
2312                                  */
2313                                 bits_needed = 1;
2314                                 GET_DATA;
2315                                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_flo_iu_cap, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2316                                 bit_offset+=bits_needed;
2317                                 curr_bits_length -= bits_needed;
2318                                 oct <<= bits_needed;
2319                                 bits_in_oct -= bits_needed;
2320                                 value--;
2321                                 
2322                                 /* skip spare bits */
2323                                 bit_offset+=value;
2324                                 curr_bits_length -= value;
2325                                 oct <<= value;
2326                                 bits_in_oct -= value;
2327                         }
2328                 }
2329
2330                 /*
2331                  * GMSK Multislot Power Profile
2332                  */
2333                 bits_needed = 2;
2334                 GET_DATA;
2335
2336                 /* analyse bits */
2337                 switch ( oct>>(32-bits_needed) )
2338                 {
2339                         case 0x00: str="GMSK_MULTISLOT_POWER_PROFILE 0"; break;
2340                         case 0x01: str="GMSK_MULTISLOT_POWER_PROFILE 1"; break;
2341                         case 0x02: str="GMSK_MULTISLOT_POWER_PROFILE 2"; break;
2342                         case 0x03: str="GMSK_MULTISLOT_POWER_PROFILE 3"; break;
2343                         default:   str="This should not happen";
2344                 }
2345
2346                 proto_tree_add_text(tf_tree,
2347                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
2348                         "GMSK Multislot Power Profile: %s (%u)",str,oct>>(32-bits_needed));
2349                 bit_offset+=2;
2350                 curr_bits_length -= bits_needed;
2351                 oct <<= bits_needed;
2352                 bits_in_oct -= bits_needed;
2353
2354                 /*
2355                  * 8-PSK Multislot Power Profile
2356                  */
2357                 bits_needed = 2;
2358                 GET_DATA;
2359
2360                 /* analyse bits */
2361                 switch ( oct>>(32-bits_needed) )
2362                 {
2363                         case 0x00: str="8-PSK_MULTISLOT_POWER_PROFILE 0"; break;
2364                         case 0x01: str="8-PSK_MULTISLOT_POWER_PROFILE 1"; break;
2365                         case 0x02: str="8-PSK_MULTISLOT_POWER_PROFILE 2"; break;
2366                         case 0x03: str="8-PSK_MULTISLOT_POWER_PROFILE 3"; break;
2367                         default:   str="This should not happen";
2368                 }
2369
2370                 proto_tree_add_text(tf_tree,
2371                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
2372                 "8-PSK Multislot Power Profile: %s (%u)",str,oct>>(32-bits_needed));
2373                 bit_offset+=2;
2374                 curr_bits_length -= bits_needed;
2375                 oct <<= bits_needed;
2376                 bits_in_oct -= bits_needed;
2377
2378                 /*
2379                  * Release 6
2380                  */
2381                  
2382                 /*
2383                  * Multiple TBF Capability
2384                  */
2385                 bits_needed = 1;
2386                 GET_DATA;
2387                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_mult_tbf_cap, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2388                 bit_offset+=bits_needed;
2389                 curr_bits_length -= bits_needed;
2390                 oct <<= bits_needed;
2391                 bits_in_oct -= bits_needed;
2392                 
2393                 /*
2394                  * Downlink Advanced Receiver Performance
2395                  */
2396                 bits_needed = 2;
2397                 GET_DATA;
2398                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_down_adv_rec_perf, tvb, bit_offset, 2, ENC_BIG_ENDIAN);
2399                 bit_offset+=bits_needed;
2400                 curr_bits_length -= bits_needed;
2401                 oct <<= bits_needed;
2402                 bits_in_oct -= bits_needed;
2403                 
2404                 /*
2405                  * Extended RLC/MAC Control Message Segmentation Capability
2406                  */
2407                 bits_needed = 1;
2408                 GET_DATA;
2409                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_ext_rlc_mac_ctrl_msg_seg_cap, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2410                 bit_offset+=bits_needed;
2411                 curr_bits_length -= bits_needed;
2412                 oct <<= bits_needed;
2413                 bits_in_oct -= bits_needed;
2414
2415                 /*
2416                  * DTM Enhancements Capability
2417                  */
2418                 bits_needed = 1;
2419                 GET_DATA;
2420                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_dtm_enh_cap, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2421                 bit_offset+=bits_needed;
2422                 curr_bits_length -= bits_needed;
2423                 oct <<= bits_needed;
2424                 bits_in_oct -= bits_needed;
2425
2426                 /*
2427                  * DTM GPRS High Multi Slot Class & DTM EGPRS High Multi Slot Class
2428                  */
2429                 bits_needed = 1;
2430                 GET_DATA;
2431                 if ((oct>>(32-bits_needed))==0)
2432                 {
2433                         bit_offset+=bits_needed;
2434                         curr_bits_length -= bits_needed;
2435                         oct <<= bits_needed;
2436                         bits_in_oct -= bits_needed;
2437                 }
2438                 else
2439                 {
2440                         bit_offset+=bits_needed;
2441                         curr_bits_length -= bits_needed;
2442                         oct <<= bits_needed;
2443                         bits_in_oct -= bits_needed;
2444
2445                         /*
2446                          * DTM GPRS High Multi Slot Class
2447                          */
2448                         bits_needed = 3;
2449                         GET_DATA;
2450                         proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_dtm_gprs_high_multi_slot_class, tvb, bit_offset, 3, ENC_BIG_ENDIAN);
2451                         bit_offset+=bits_needed;
2452                         curr_bits_length -= bits_needed;
2453                         oct <<= bits_needed;
2454                         bits_in_oct -= bits_needed;
2455
2456                         bits_needed = 1;
2457                         GET_DATA;
2458                         if ((oct>>(32-bits_needed))==0)
2459                         {
2460                                 bit_offset+=bits_needed;
2461                                 curr_bits_length -= bits_needed;
2462                                 oct <<= bits_needed;
2463                                 bits_in_oct -= bits_needed;
2464                         }
2465                         else
2466                         {
2467                                 bit_offset+=bits_needed;
2468                                 curr_bits_length -= bits_needed;
2469                                 oct <<= bits_needed;
2470                                 bits_in_oct -= bits_needed;
2471
2472                                 /*
2473                                  * DTM EGPRS High Multi Slot Class
2474                                  */
2475                                 bits_needed = 3;
2476                                 GET_DATA;
2477                                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_dtm_egprs_high_multi_slot_class, tvb, bit_offset, 3, ENC_BIG_ENDIAN);
2478                                 bit_offset+=bits_needed;
2479                                 curr_bits_length -= bits_needed;
2480                                 oct <<= bits_needed;
2481                                 bits_in_oct -= bits_needed;
2482                         }
2483                 }
2484                 
2485                 /*
2486                  * PS Handover Capability
2487                  */
2488                 bits_needed = 1;
2489                 GET_DATA;
2490                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_ps_ho_cap, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2491                 bit_offset+=bits_needed;
2492                 curr_bits_length -= bits_needed;
2493                 oct <<= bits_needed;
2494                 bits_in_oct -= bits_needed;
2495                         
2496                 /*
2497                  * Release 7
2498                  */
2499  
2500                 /*
2501                  * DTM Handover Capability
2502                  */
2503                 bits_needed = 1;
2504                 GET_DATA;
2505                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_dtm_ho_cap, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2506                 bit_offset+=bits_needed;
2507                 curr_bits_length -= bits_needed;
2508                 oct <<= bits_needed;
2509                 bits_in_oct -= bits_needed;
2510
2511                 /*
2512                  * Multislot Capability Reduction for Downlink Dual Carrier & Downlink Dual Carrier for DTM Capability
2513                  */
2514                 bits_needed = 1;
2515                 GET_DATA;
2516                 if ((oct>>(32-bits_needed))==0)
2517                 {
2518                         bit_offset+=bits_needed;
2519                         curr_bits_length -= bits_needed;
2520                         oct <<= bits_needed;
2521                         bits_in_oct -= bits_needed;
2522                 }
2523                 else
2524                 {
2525                         bit_offset+=bits_needed;
2526                         curr_bits_length -= bits_needed;
2527                         oct <<= bits_needed;
2528                         bits_in_oct -= bits_needed;
2529
2530                         /*
2531                          * Multislot Capability Reduction for Downlink Dual Carrier
2532                          */
2533                         bits_needed = 3;
2534                         GET_DATA;
2535                         proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_multi_slot_cap_red_down_dual_carrier, tvb, bit_offset, 3, ENC_BIG_ENDIAN);
2536                         bit_offset+=bits_needed;
2537                         curr_bits_length -= bits_needed;
2538                         oct <<= bits_needed;
2539                         bits_in_oct -= bits_needed;
2540
2541                         /*
2542                          * Downlink Dual Carrier for DTM Capability
2543                          */
2544                         bits_needed = 1;
2545                         GET_DATA;
2546                         proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_down_dual_carrier_dtm_cap, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2547                         bit_offset+=bits_needed;
2548                         curr_bits_length -= bits_needed;
2549                         oct <<= bits_needed;
2550                         bits_in_oct -= bits_needed;
2551                 }
2552
2553                 /*
2554                  * Flexible Timeslot Assignment
2555                  */
2556                 bits_needed = 1;
2557                 GET_DATA;
2558                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_flex_ts_assign, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2559                 bit_offset+=bits_needed;
2560                 curr_bits_length -= bits_needed;
2561                 oct <<= bits_needed;
2562                 bits_in_oct -= bits_needed;
2563  
2564                 /*
2565                  * GAN PS Handover Capability
2566                  */
2567                 bits_needed = 1;
2568                 GET_DATA;
2569                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_gan_ps_ho_cap, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2570                 bit_offset+=bits_needed;
2571                 curr_bits_length -= bits_needed;
2572                 oct <<= bits_needed;
2573                 bits_in_oct -= bits_needed;
2574  
2575                 /*
2576                  * RLC Non-persistent Mode
2577                  */
2578                 bits_needed = 1;
2579                 GET_DATA;
2580                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_rlc_non_pers_mode, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2581                 bit_offset+=bits_needed;
2582                 curr_bits_length -= bits_needed;
2583                 oct <<= bits_needed;
2584                 bits_in_oct -= bits_needed;
2585  
2586                 /*
2587                  * Reduced Latency Capability
2588                  */
2589                 bits_needed = 1;
2590                 GET_DATA;
2591                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_reduced_lat_cap, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2592                 bit_offset+=bits_needed;
2593                 curr_bits_length -= bits_needed;
2594                 oct <<= bits_needed;
2595                 bits_in_oct -= bits_needed;
2596  
2597                 /*
2598                  * Uplink EGPRS2
2599                  */
2600                 bits_needed = 2;
2601                 GET_DATA;
2602                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_ul_egprs2, tvb, bit_offset, 2, ENC_BIG_ENDIAN);
2603                 bit_offset+=bits_needed;
2604                 curr_bits_length -= bits_needed;
2605                 oct <<= bits_needed;
2606                 bits_in_oct -= bits_needed;
2607  
2608                 /*
2609                  * Downlink EGPRS2
2610                  */
2611                 bits_needed = 2;
2612                 GET_DATA;
2613                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_dl_egprs2, tvb, bit_offset, 2, ENC_BIG_ENDIAN);
2614                 bit_offset+=bits_needed;
2615                 curr_bits_length -= bits_needed;
2616                 oct <<= bits_needed;
2617                 bits_in_oct -= bits_needed;
2618  
2619                 /*
2620                  * Release 8
2621                  */
2622  
2623                 /*
2624                  * E-UTRA FDD support
2625                  */
2626                 bits_needed = 1;
2627                 GET_DATA;
2628                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_eutra_fdd_support, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2629                 bit_offset+=bits_needed;
2630                 curr_bits_length -= bits_needed;
2631                 oct <<= bits_needed;
2632                 bits_in_oct -= bits_needed;
2633  
2634                 /*
2635                  * E-UTRA TDD support
2636                  */
2637                 bits_needed = 1;
2638                 GET_DATA;
2639                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_eutra_tdd_support, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2640                 bit_offset+=bits_needed;
2641                 curr_bits_length -= bits_needed;
2642                 oct <<= bits_needed;
2643                 bits_in_oct -= bits_needed;
2644  
2645                 /*
2646                  * GERAN to E-UTRA support in GERAN packet transfer mode
2647                  */
2648                 bits_needed = 2;
2649                 GET_DATA;
2650                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_geran_to_eutra_support_in_geran_ptm, tvb, bit_offset, 2, ENC_BIG_ENDIAN);
2651                 bit_offset+=bits_needed;
2652                 curr_bits_length -= bits_needed;
2653                 oct <<= bits_needed;
2654                 bits_in_oct -= bits_needed;
2655  
2656                 /*
2657                  * Priority-based reselection support
2658                  */
2659                 bits_needed = 1;
2660                 GET_DATA;
2661                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_prio_based_resel_support, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2662                 bit_offset+=bits_needed;
2663                 curr_bits_length -= bits_needed;
2664                 oct <<= bits_needed;
2665                 bits_in_oct -= bits_needed;
2666  
2667                 /*
2668                  * Release 9
2669                  */
2670
2671                 /*
2672                  * Enhanced Flexible Timeslot Assignment
2673                  */
2674                 bits_needed = 1;
2675                 GET_DATA;
2676                 if ((oct>>(32-bits_needed))==0)
2677                 {
2678                         bit_offset+=bits_needed;
2679                         curr_bits_length -= bits_needed;
2680                         oct <<= bits_needed;
2681                         bits_in_oct -= bits_needed;
2682                 }
2683                 else
2684                 {
2685                         bit_offset+=bits_needed;
2686                         curr_bits_length -= bits_needed;
2687                         oct <<= bits_needed;
2688                         bits_in_oct -= bits_needed;
2689
2690                         /*
2691                          * Alternative EFTA Multislot Class
2692                          */
2693                         bits_needed = 4;
2694                         GET_DATA;
2695                         proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_alt_efta_multi_slot_class, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
2696                         bit_offset+=bits_needed;
2697                         curr_bits_length -= bits_needed;
2698                         oct <<= bits_needed;
2699                         bits_in_oct -= bits_needed;
2700  
2701                         /*
2702                          * EFTA Multislot Capability Reduction for Downlink Dual Carrier
2703                          */
2704                         bits_needed = 3;
2705                         GET_DATA;
2706                         proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_efta_multi_slot_cap_red_down_dual_carrier, tvb, bit_offset, 3, ENC_BIG_ENDIAN);
2707                         bit_offset+=bits_needed;
2708                         curr_bits_length -= bits_needed;
2709                         oct <<= bits_needed;
2710                         bits_in_oct -= bits_needed;
2711                 }
2712  
2713                 /*
2714                  * Indication of Upper Layer PDU Start Capability for RLC UM
2715                  */
2716                 bits_needed = 1;
2717                 GET_DATA;
2718                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_ind_up_layer_pdu_start_cap_for_rlc_um, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2719                 bit_offset+=bits_needed;
2720                 curr_bits_length -= bits_needed;
2721                 oct <<= bits_needed;
2722                 bits_in_oct -= bits_needed;
2723
2724                 /*
2725                  * EMST Capability
2726                  */
2727                 bits_needed = 1;
2728                 GET_DATA;
2729                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_emst_cap, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2730                 bit_offset+=bits_needed;
2731                 curr_bits_length -= bits_needed;
2732                 oct <<= bits_needed;
2733                 bits_in_oct -= bits_needed;
2734
2735                 /*
2736                  * MTTI Capability
2737                  */
2738                 bits_needed = 1;
2739                 GET_DATA;
2740                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_mtti_cap, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2741                 bit_offset+=bits_needed;
2742                 curr_bits_length -= bits_needed;
2743                 oct <<= bits_needed;
2744                 bits_in_oct -= bits_needed;
2745
2746                 /*
2747                  * UTRA CSG Cells Reporting
2748                  */
2749                 bits_needed = 1;
2750                 GET_DATA;
2751                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_utra_csg_cell_report, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2752                 bit_offset+=bits_needed;
2753                 curr_bits_length -= bits_needed;
2754                 oct <<= bits_needed;
2755                 bits_in_oct -= bits_needed;
2756
2757                 /*
2758                  * E-UTRA CSG Cells Reporting
2759                  */
2760                 bits_needed = 1;
2761                 GET_DATA;
2762                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_eutra_csg_cell_report, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2763                 bit_offset+=bits_needed;
2764                 curr_bits_length -= bits_needed;
2765                 oct <<= bits_needed;
2766                 bits_in_oct -= bits_needed;
2767
2768                 /*
2769                  * we are too long ... so jump over it
2770                  */
2771                 while ( curr_bits_length > 0 )
2772                 {
2773                         if ( curr_bits_length > 8 )
2774                                 bits_needed = 8;
2775                         else
2776                                 bits_needed = curr_bits_length;
2777                         GET_DATA;
2778                         curr_bits_length -= bits_needed;
2779                         oct <<= bits_needed;
2780                         bits_in_oct -= bits_needed;
2781                 }
2782
2783
2784         } while ( 1 );
2785
2786         curr_offset+= curr_len;
2787
2788         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
2789
2790         return(curr_offset - offset);
2791 }
2792
2793 /*
2794  * [9] 10.5.5.14
2795  */