Prevet a crash when dissecting linked TI.
[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  */
2796 static const range_string gmm_cause_vals[] = {
2797         { 0x00, 0x01, "Protocol error, unspecified(Not def in v8.6.0)"},
2798         { 0x02, 0x02, "IMSI unknown in HLR"},
2799         { 0x03, 0x03, "Illegal MS"},
2800         { 0x04, 0x04, "IMSI unknown in VLR"}, /* Annex G.1 */
2801         { 0x05, 0x05, "IMEI not accepted"}, /* Annex G.1 */
2802         { 0x06, 0x06, "Illegal ME"},
2803         { 0x07, 0x07, "GPRS services not allowed"},
2804         { 0x08, 0x08, "GPRS services and non-GPRS services not allowed"},
2805         { 0x09, 0x09, "MS identity cannot be derived by the network"},
2806         { 0x0a, 0x0a, "Implicitly detached"},
2807         { 0x0b, 0x0b, "PLMN not allowed"},
2808         { 0x0c, 0x0c, "Location Area not allowed"},
2809         { 0x0d, 0x0d, "Roaming not allowed in this location area"},
2810         { 0x0e, 0x0e, "GPRS services not allowed in this PLMN"},
2811         { 0x0f, 0x0f, "No Suitable Cells In Location Area"},
2812         { 0x10, 0x10, "MSC temporarily not reachable"},
2813         { 0x11, 0x11, "Network failure"},
2814         { 0x12, 0x13, "Protocol error, unspecified(Not def in v8.6.0)"},
2815         { 0x14, 0x14, "MAC failure"},
2816         { 0x15, 0x15, "Synch failure"},
2817         { 0x16, 0x16, "Congestion"},
2818         { 0x17, 0x17, "GSM authentication unacceptable"},
2819         { 0x18, 0x18, "Protocol error, unspecified(Not def in v8.6.0)"},
2820         { 0x19, 0x19, "Not authorized for this CSG"},
2821         { 0x20, 0x20, "Service option not supported"},                                          /* Annex G.4 */
2822         { 0x21, 0x21, "Requested service option not subscribed"},                       /* Annex G.4 */
2823         { 0x22, 0x22, "Service option temporarily out of order"},                       /* Annex G.4 */
2824
2825         { 0x23, 0x25, "Protocol error, unspecified(Not def in v8.6.0)"},
2826
2827         { 0x26, 0x26, "Call cannot be identified(non-GPRS services only)"},     /* Annex G.4 */
2828         { 0x27, 0x27, "Protocol error, unspecified(Not def in v8.6.0)"},
2829         { 0x28, 0x28, "No PDP context activated"},
2830         { 0x29, 0x2f, "Protocol error, unspecified(Not def in v8.6.0)"},
2831         { 0x30, 0x3f, "Retry upon entry into a new cell"},
2832
2833         { 0x40, 0x5e, "Protocol error, unspecified(Not def in v8.6.0)"},
2834
2835         { 0x5f, 0x5f, "Semantically incorrect message"},
2836         { 0x60, 0x60, "Invalid mandatory information"},
2837         { 0x61, 0x61, "Message type non-existent or not implemented"},
2838         { 0x62, 0x62, "Message type not compatible with the protocol state"},
2839         { 0x63, 0x63, "Information element non-existent or notimplemented"},
2840         { 0x64, 0x64, "Conditional IE error"},
2841         { 0x65, 0x65, "Message not compatible with the protocol state"},
2842
2843         { 0x66, 0x6e, "Protocol error, unspecified(Not def in v8.6.0)"},
2844
2845         { 0x6f, 0x6f, "Protocol error, unspecified"},
2846         { 0x70, 0xff, "Protocol error, unspecified(Not def in v8.6.0)"},
2847         { 0, 0, NULL }
2848 };
2849 /* NOTE 1 TS 124 008 V8.6.0 (2009-07)
2850         "Any other value received by the mobile station shall be treated as 0110 1111, "Protocol
2851         error, unspecified". Any other value received by the network shall be treated as
2852         0110 1111, "Protocol error, unspecified".
2853  */
2854
2855 /* NOTE: The listed reject cause values are defined in annex G. */
2856
2857 static guint16
2858 de_gmm_cause(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2859 {
2860         guint32       curr_offset;
2861
2862         curr_offset = offset;
2863
2864         proto_tree_add_item(tree, hf_gsm_a_gm_cause, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2865
2866         curr_offset++;
2867
2868         /* no length check possible */
2869
2870         return(curr_offset - offset);
2871 }
2872
2873 /*
2874  * [7] 10.5.5.15 Routing area identification
2875  */
2876 guint16
2877 de_gmm_rai(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2878 {
2879         proto_tree   *subtree;
2880         proto_item   *item;
2881         guint32       mcc;
2882         guint32       mnc;
2883         guint32       lac;
2884         guint32       rac;
2885         guint32       curr_offset;
2886
2887         curr_offset = offset;
2888
2889         mcc = (tvb_get_guint8(tvb, curr_offset) & 0x0f) <<8;
2890         mcc |= (tvb_get_guint8(tvb, curr_offset) & 0xf0);
2891         mcc |= (tvb_get_guint8(tvb, curr_offset+1) & 0x0f);
2892         mnc = (tvb_get_guint8(tvb, curr_offset+2) & 0x0f) <<8;
2893         mnc |= (tvb_get_guint8(tvb, curr_offset+2) & 0xf0);
2894         mnc |= (tvb_get_guint8(tvb, curr_offset+1) & 0xf0) >>4;
2895         if ((mnc&0x000f) == 0x000f)
2896                  mnc = mnc>>4;
2897
2898         lac = tvb_get_ntohs(tvb, curr_offset+3);
2899         rac = tvb_get_guint8(tvb, curr_offset+5);
2900
2901         item = proto_tree_add_text(tree,
2902                 tvb, curr_offset, 6,
2903                 "Routing area identification: %x-%x-%u-%u",
2904                 mcc,mnc,lac,rac);
2905
2906         subtree = proto_item_add_subtree(item, ett_gmm_rai);
2907         dissect_e212_mcc_mnc(tvb, pinfo, subtree, offset, TRUE);
2908
2909         proto_tree_add_item(subtree, hf_gsm_a_lac, tvb, curr_offset+3, 2, ENC_BIG_ENDIAN);
2910         proto_tree_add_item(subtree, hf_gsm_a_gm_rac, tvb, curr_offset+5, 1, ENC_BIG_ENDIAN);
2911
2912         curr_offset+=6;
2913     if (add_string)
2914     {
2915         if (add_string[0] == '\0')
2916         {
2917             g_snprintf(add_string, string_len, " - RAI: %x-%x-%u-%u", mcc,mnc,lac,rac);
2918         }
2919     }
2920
2921
2922         /* no length check possible */
2923
2924         return(curr_offset - offset);
2925 }
2926
2927 /*
2928  * [7] 10.5.5.15a Routing area identification 2
2929  */
2930 static guint16
2931 de_gmm_rai2(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2932 {
2933         /* The routing area identification 2 value is coded as octet 2 to 7 of the Routing area identification information element. */
2934         return de_gmm_rai(tvb, tree, pinfo, offset, len, add_string, string_len);
2935 }
2936
2937 /*
2938  * [7] 10.5.5.17
2939  */
2940 static guint16
2941 de_gmm_update_res(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2942 {
2943         guint8        oct;
2944         guint32       curr_offset;
2945         const gchar  *str;
2946
2947         curr_offset = offset;
2948
2949         oct = tvb_get_guint8(tvb, curr_offset);
2950
2951         /* IMPORTANT - IT'S ASSUMED THAT THE INFORMATION IS IN THE HIGHER NIBBLE */
2952         oct >>= 4;
2953
2954         switch(oct&7)
2955         {
2956                 case 0:  str="RA updated";              break;
2957                 case 1:  str="combined RA/LA updated";  break;
2958                 default: str="reserved";
2959         }
2960
2961         proto_tree_add_text(tree,
2962                 tvb, curr_offset, 1,
2963                 "Update Result: %s (%u)",
2964                 str,
2965                 oct&7);
2966
2967         curr_offset++;
2968
2969         /* no length check possible */
2970
2971         return(curr_offset - offset);
2972 }
2973
2974 /*
2975  * [9] 10.5.5.18 Update Type
2976  */
2977 static const value_string gsm_a_gm_update_type_vals[] = {
2978         { 0x00, "RA updating" },
2979         { 0x01, "combined RA/LA updating" },
2980         { 0x02, "combined RA/LA updating with IMSI attach" },
2981         { 0x03, "Periodic updating" },
2982         { 0, NULL }
2983 };
2984
2985 static guint16
2986 de_gmm_update_type(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2987 {
2988         proto_item   *tf = NULL;
2989         proto_tree   *tf_tree = NULL;
2990
2991         proto_tree_add_bits_item(tree, hf_gsm_a_gm_ciph_key_seq_num, tvb, offset << 3, 4, ENC_BIG_ENDIAN);
2992
2993         tf = proto_tree_add_text(tree,
2994                 tvb, offset, 1,
2995                 "Update Type");
2996
2997         tf_tree = proto_item_add_subtree(tf, ett_gmm_update_type );
2998
2999         proto_tree_add_item(tf_tree, hf_gsm_a_gm_for, tvb, offset, 1, ENC_BIG_ENDIAN);
3000         proto_tree_add_item(tf_tree, hf_gsm_a_gm_update_type, tvb, offset, 1, ENC_BIG_ENDIAN);
3001
3002         /* no length check possible */
3003         return(1);
3004 }
3005
3006 /*
3007  * [9] 10.5.5.19 A&C reference number (lower nibble)
3008  */
3009 static guint16
3010 de_gmm_ac_ref_nr(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3011 {
3012         /* IMPORTANT - IT'S ASSUMED THAT THE INFORMATION IS IN THE LOWER NIBBLE */
3013         proto_tree_add_bits_item(tree, hf_gsm_a_gm_ac_ref_nr, tvb, (offset << 3) + 4, 4, ENC_BIG_ENDIAN);
3014
3015         /* no length check possible */
3016         return(1);
3017 }
3018
3019 /*
3020  * [9] 10.5.5.19 A&C reference number (higher nibble)
3021  */
3022 static guint16
3023 de_gmm_ac_ref_nr_h(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3024 {
3025         /* IMPORTANT - IT'S ASSUMED THAT THE INFORMATION IS IN THE HIGHER NIBBLE */
3026         proto_tree_add_bits_item(tree, hf_gsm_a_gm_ac_ref_nr, tvb, offset << 3, 4, ENC_BIG_ENDIAN);
3027
3028         /* no length check possible */
3029         return(1);
3030 }
3031
3032 /*
3033  * [9] 10.5.5.20 Service type
3034  */
3035 static const value_string gsm_a_gm_serv_type_vals[] = {
3036         { 0x00, "Signalling" },
3037         { 0x01, "Data" },
3038         { 0x02, "Paging response" },
3039         { 0x03, "MBMS Multicast Service Reception" },
3040         { 0x04, "MBMS Broadcast Service Reception" },
3041         { 0, NULL }
3042 };
3043
3044 static guint16
3045 de_gmm_service_type(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3046 {
3047         guint32 bit_offset;
3048
3049         bit_offset = offset << 3;
3050         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
3051         bit_offset += 1;
3052         proto_tree_add_bits_item(tree, hf_gsm_a_gm_serv_type, tvb, bit_offset, 3, ENC_BIG_ENDIAN);
3053         bit_offset += 3;
3054         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
3055         bit_offset += 1;
3056         proto_tree_add_bits_item(tree, hf_gsm_a_gm_ciph_key_seq_num, tvb, bit_offset, 3, ENC_BIG_ENDIAN);
3057
3058         /* no length check possible */
3059         return(1);
3060 }
3061
3062 /*
3063  * [9] 10.5.5.21 Cell Notification
3064  * No data
3065  */
3066
3067 /*
3068  * [9] 10.5.5.22 PS LCS Capability
3069  */
3070 static const true_false_string gsm_a_gm_apc_vals = {
3071         "Additional Positioning Capabilities which can be retrieved by RRLP are supported",
3072         "Additional Positioning Capabilities which can be retrieved by RRLP are not supported"
3073 };
3074
3075 static const true_false_string gsm_a_gm_otd_a_vals = {
3076         "MS assisted E-OTD supported",
3077         "MS assisted E-OTD not supported"
3078 };
3079
3080 static const true_false_string gsm_a_gm_otd_b_vals = {
3081         "MS based E-OTD supported",
3082         "MS based E-OTD not supported"
3083 };
3084
3085 static const true_false_string gsm_a_gm_gps_a_vals = {
3086         "MS assisted GPS supported",
3087         "MS assisted GPS not supported"
3088 };
3089
3090 static const true_false_string gsm_a_gm_gps_b_vals = {
3091         "MS based GPS supported",
3092         "MS based GPS not supported"
3093 };
3094
3095 static const true_false_string gsm_a_gm_gps_c_vals = {
3096         "Conventional GPS supported",
3097         "Conventional GPS not supported"
3098 };
3099
3100 static guint16
3101 de_gmm_ps_lcs_cap(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3102 {
3103         guint32 curr_offset;
3104
3105         curr_offset = offset;
3106         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, curr_offset << 3, 2, ENC_BIG_ENDIAN);
3107         proto_tree_add_item(tree, hf_gsm_a_gm_apc, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3108         proto_tree_add_item(tree, hf_gsm_a_gm_otd_a, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3109         proto_tree_add_item(tree, hf_gsm_a_gm_otd_b, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3110         proto_tree_add_item(tree, hf_gsm_a_gm_gps_a, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3111         proto_tree_add_item(tree, hf_gsm_a_gm_gps_b, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3112         proto_tree_add_item(tree, hf_gsm_a_gm_gps_c, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3113
3114         curr_offset++;
3115
3116         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
3117
3118         return(curr_offset - offset);
3119 }
3120
3121 /*
3122  * [7] 10.5.5.23
3123  */
3124 static guint16
3125 de_gmm_net_feat_supp(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3126 {
3127         guint8  oct;
3128         guint32 curr_offset;
3129         const gchar     *str;
3130
3131         curr_offset = offset;
3132
3133         oct = tvb_get_guint8(tvb, curr_offset);
3134
3135         switch(oct&8)
3136         {
3137                 case 8: str="LCS-MOLR via PS domain not supported"; break;
3138                 default: str="LCS-MOLR via PS domain supported";
3139         }
3140
3141         proto_tree_add_text(tree,
3142                 tvb, curr_offset, 1,
3143                 "Network Feature Support: %s (%u)",
3144                 str,
3145                 (oct>>3)&1);
3146
3147         curr_offset++;
3148
3149         /* no length check possible */
3150
3151         return(curr_offset - offset);
3152 }
3153
3154 /* [7] 10.5.5.24 Inter RAT information container */
3155 static guint16
3156 de_gmm_rat_info_container(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
3157 {
3158         guint32 curr_offset;
3159         tvbuff_t *rrc_irat_ho_info_tvb;
3160
3161         curr_offset = offset;
3162
3163 /* The value part of the Inter RAT information container information element is the INTER RAT HANDOVER INFO as
3164 defined in 3GPP TS 25.331 [23c]. If this field includes padding bits, they are defined in 3GPP TS 25.331 [23c].*/
3165         rrc_irat_ho_info_tvb = tvb_new_subset(tvb, curr_offset, len, len);
3166         if (rrc_irat_ho_info_handle)
3167                 call_dissector(rrc_irat_ho_info_handle, rrc_irat_ho_info_tvb,pinfo , tree);
3168         else
3169                 proto_tree_add_text(tree, tvb, curr_offset, len,"INTER RAT HANDOVER INFO - Not decoded");
3170
3171         return len;
3172
3173 }
3174
3175 /* [7] 10.5.5.25 Requested MS information */
3176 static const true_false_string gsm_a_gm_req_ms_info_irat_vals = {
3177         "Inter RAT information container IE requested",
3178         "Inter RAT information container IE not requested"
3179 };
3180 static const true_false_string gsm_a_gm_req_ms_info_irat2_vals = {
3181         "E-UTRAN inter RAT information container IE requested",
3182         "E-UTRAN inter RAT information container IE not requested"
3183 };
3184
3185 static guint16
3186 de_gmm_req_ms_info(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
3187 {
3188         guint32 curr_offset;
3189         guint32 bit_offset;
3190
3191         curr_offset = offset;
3192         bit_offset = (curr_offset<<3)+4;
3193
3194         proto_tree_add_bits_item(tree, hf_gsm_a_gm_req_ms_info_irat, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
3195         bit_offset++;
3196         proto_tree_add_bits_item(tree, hf_gsm_a_gm_req_ms_info_irat2, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
3197         bit_offset++;
3198         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, bit_offset, 2, ENC_BIG_ENDIAN);
3199         bit_offset+=2;
3200         curr_offset++;
3201
3202         return len;
3203 }
3204
3205 /* [7] 10.5.5.26 UE network capability
3206  * See subclause 9.9.3.x in 3GPP TS 24.301 [120].
3207  */
3208
3209 /* [7] 10.5.5.27 E-UTRAN inter RAT information container */
3210 static guint16
3211 de_gmm_eutran_irat_info_container(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
3212 {
3213         guint32 curr_offset;
3214         tvbuff_t *lte_rrc_ue_eutra_cap_tvb;
3215
3216         curr_offset = offset;
3217
3218 /* The value part of the E-UTRAN inter RAT information container information element
3219    is formatted and coded according to the UE-EUTRA-Capability IE defined in 3GPP TS 36.331 [129]*/
3220         lte_rrc_ue_eutra_cap_tvb = tvb_new_subset(tvb, curr_offset, len, len);
3221         if (lte_rrc_ue_eutra_cap_handle)
3222                 call_dissector(lte_rrc_ue_eutra_cap_handle, lte_rrc_ue_eutra_cap_tvb, pinfo, tree);
3223         else
3224                 proto_tree_add_text(tree, tvb, curr_offset, len,"E-UTRAN Inter RAT information container - Not decoded");
3225
3226         return len;
3227 }
3228
3229 /* [7] 10.5.5.28 Voice domain preference and UE's usage setting */
3230 static const true_false_string gsm_a_gm_ue_usage_setting_vals = {
3231         "Data centric",
3232         "Voice centric"
3233 };
3234 static const value_string gsm_a_gm_voice_domain_pref_for_eutran_vals[] = {
3235         {0x0,   "CS Voice only"},
3236         {0x1,   "IMS PS Voice only"},
3237         {0x2,   "CS voice preferred, IMS PS Voice as secondary"},
3238         {0x3,   "IMS PS voice preferred, CS Voice as secondary"},
3239         {  0,   NULL }
3240 };
3241
3242 static guint16
3243 de_gmm_voice_domain_pref(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
3244 {
3245         guint32 curr_offset;
3246         guint32 bit_offset;
3247
3248         curr_offset = offset;
3249         bit_offset = curr_offset<<3;
3250
3251         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, bit_offset, 5, ENC_BIG_ENDIAN);
3252         bit_offset+=5;
3253         proto_tree_add_bits_item(tree, hf_gsm_a_gm_ue_usage_setting, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
3254         bit_offset++;
3255         proto_tree_add_bits_item(tree, hf_gsm_a_gm_voice_domain_pref_for_eutran, tvb, bit_offset, 2, ENC_BIG_ENDIAN);
3256         bit_offset+=2;
3257         curr_offset++;
3258
3259         return len;
3260 }
3261
3262 /*
3263  * [7] 10.5.7.1
3264  */
3265 static guint16
3266 de_gc_context_stat(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3267 {
3268         guint8  oct;
3269         guint16 pdp_nr;
3270         guint32 curr_offset;
3271         proto_item  *tf = NULL;
3272         proto_tree  *tf_tree = NULL;
3273
3274         curr_offset = offset;
3275
3276         oct = tvb_get_guint8(tvb, curr_offset);
3277
3278         tf = proto_tree_add_text(tree,
3279                 tvb, curr_offset, 1,
3280                 "PDP Context Status");
3281
3282         tf_tree = proto_item_add_subtree(tf, ett_gmm_context_stat );
3283
3284         oct = tvb_get_guint8(tvb, curr_offset);
3285
3286         for ( pdp_nr=0;pdp_nr<16; pdp_nr++ )
3287         {
3288                 if ( pdp_nr == 8 )
3289                 {
3290                         curr_offset++;
3291                         oct = tvb_get_guint8(tvb, curr_offset);
3292                 }
3293                 proto_tree_add_text(tf_tree,
3294                         tvb, curr_offset, 1,
3295                         "NSAPI %d: %s (%u)",pdp_nr,
3296                         pdp_str[oct&1],
3297                         oct&1);
3298                 oct>>=1;
3299         }
3300
3301         curr_offset++;
3302
3303         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
3304
3305         return(curr_offset - offset);
3306 }
3307
3308 /*
3309  * [7] 10.5.7.2
3310  */
3311 static guint16
3312 de_gc_radio_prio(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3313 {
3314         guint8  oct;
3315         guint32 curr_offset;
3316         const gchar     *str;
3317
3318         curr_offset = offset;
3319
3320         oct = tvb_get_guint8(tvb, curr_offset);
3321
3322         switch ( oct&7 )
3323         {
3324                 case 1: str="priority level 1 (highest)"; break;
3325                 case 2: str="priority level 2"; break;
3326                 case 3: str="priority level 3"; break;
3327                 case 4: str="priority level 4 (lowest)"; break;
3328                 default: str="priority level 4 (lowest)";
3329         }
3330
3331         proto_tree_add_text(tree,
3332                 tvb, curr_offset, 1,
3333                 "Radio Priority (PDP or SMS): %s (%u)",
3334                 str,
3335                 oct&7);
3336
3337         curr_offset++;
3338
3339         return(curr_offset - offset);
3340 }
3341
3342 /*
3343  * [9] 10.5.7.3 GPRS Timer
3344  */
3345 static const value_string gsm_a_gm_gprs_timer_unit_vals[] = {
3346         { 0x00, "value is incremented in multiples of 2 seconds" },
3347         { 0x01, "value is incremented in multiples of 1 minute" },
3348         { 0x02, "value is incremented in multiples of decihours" },
3349         { 0x07, "value indicates that the timer is deactivated" },
3350         { 0, NULL }
3351 };
3352
3353 static guint16
3354 de_gc_timer(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3355 {
3356         guint8  oct;
3357         guint16 val;
3358         const gchar     *str;
3359         proto_tree      *subtree;
3360         proto_item      *item;
3361
3362         oct = tvb_get_guint8(tvb, offset);
3363         val = oct&0x1f;
3364
3365         switch(oct>>5)
3366         {
3367                 case 0: str="sec"; val*=2; break;
3368                 case 1: str="min"; break;
3369                 case 2: str="min"; val*=6; break;
3370                 case 7:
3371                         proto_tree_add_text(tree,
3372                                 tvb, offset, 1,
3373                                 "GPRS Timer: timer is deactivated");
3374
3375                 default: str="min";
3376         }
3377
3378         item = proto_tree_add_text(tree,
3379                 tvb, offset, 1,
3380                 "GPRS Timer: %u %s",
3381                 val,
3382                 str);
3383
3384         subtree = proto_item_add_subtree(item, ett_gmm_gprs_timer);
3385         proto_tree_add_item(subtree, hf_gsm_a_gm_gprs_timer_unit, tvb, offset, 1, ENC_BIG_ENDIAN);
3386         proto_tree_add_item(subtree, hf_gsm_a_gm_gprs_timer_value, tvb, offset, 1, ENC_BIG_ENDIAN);
3387
3388         /* no length check possible */
3389         return(1);
3390 }
3391
3392 /*
3393  * [7] 10.5.7.4
3394  */
3395 static guint16
3396 de_gc_timer2(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string, int string_len _U_)
3397 {
3398         guint8  oct;
3399         guint16 val;
3400         guint32 curr_offset;
3401         const gchar     *str;
3402
3403         curr_offset = offset;
3404
3405         oct = tvb_get_guint8(tvb, curr_offset);
3406
3407         val = oct&0x1f;
3408
3409         switch(oct>>5)
3410         {
3411                 case 0: str="sec"; val*=2; break;
3412                 case 1: str="min"; break;
3413                 case 2: str="min"; val*=6; break;
3414                 case 7:
3415                         proto_tree_add_text(tree,
3416                         tvb, curr_offset, 1,
3417                         "GPRS Timer: timer is deactivated");
3418
3419                 default: str="min";
3420         }
3421
3422         proto_tree_add_text(tree,
3423                 tvb, curr_offset, 1,
3424                 "GPRS Timer: %u %s %s (%u)",
3425                 val,
3426                 str, add_string ? add_string : "", oct);
3427
3428         curr_offset++;
3429
3430         return(curr_offset - offset);
3431 }
3432
3433 /*
3434  * [7] 10.5.7.5
3435  */
3436 static guint16
3437 de_gc_radio_prio2(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
3438 {
3439         guint8  oct;
3440         guint32 curr_offset;
3441         const gchar     *str;
3442
3443         curr_offset = offset;
3444
3445         oct = tvb_get_guint8(tvb, curr_offset);
3446
3447         /* IMPORTANT - IT'S ASSUMED THAT THE INFORMATION IS IN THE HIGHER NIBBLE */
3448         oct >>= 4;
3449
3450         switch ( oct&7 )
3451         {
3452                 case 1: str="priority level 1 (highest)"; break;
3453                 case 2: str="priority level 2"; break;
3454                 case 3: str="priority level 3"; break;
3455                 case 4: str="priority level 4 (lowest)"; break;
3456                 default: str="priority level 4 (lowest)";
3457         }
3458
3459         proto_tree_add_text(tree,
3460                 tvb, curr_offset, 1,
3461                 "Radio Priority (TOM8): %s (%u)",
3462                 str,
3463                 oct&7);
3464
3465         curr_offset++;
3466
3467         return(curr_offset - offset);
3468 }
3469
3470 /*
3471  * [8] 10.5.7.6 MBMS context status
3472  */
3473 static guint16
3474 de_gc_mbms_context_stat(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
3475 {
3476         guint32 curr_offset;
3477         guint   i;
3478         guint8  oct, j;
3479         proto_item  *tf = NULL;
3480         proto_tree  *tf_tree = NULL;
3481
3482         curr_offset = offset;
3483
3484         oct = tvb_get_guint8(tvb, curr_offset);
3485
3486         tf = proto_tree_add_text(tree,
3487                 tvb, curr_offset, 1,
3488                 "MBMS Context Status");
3489
3490         tf_tree = proto_item_add_subtree(tf, ett_gmm_context_stat );
3491
3492         for (i=0; i<len; i++)
3493         {
3494                 oct = tvb_get_guint8(tvb, curr_offset);
3495
3496                 for (j=0; j<8; j++)
3497                 {
3498                         proto_tree_add_text(tf_tree,
3499                                 tvb, curr_offset, 1,
3500                                 "NSAPI %d: %s (%u)",128+i*8+j,
3501                                 pdp_str[oct&1],
3502                                 oct&1);
3503                         oct>>=1;
3504                 }
3505                 curr_offset++;
3506         }
3507
3508         return(len);
3509 }
3510
3511 /*
3512  * [8] 10.5.7.7 Uplink data status
3513  */
3514 static const true_false_string gsm_a_gm_nsapi_ul_stat_vals = {
3515         "uplink data are pending for the preserved PDP context",
3516         "no uplink data are pending for the preserved PDP context or the PDP context is PDP-INACTIVE or is PDP-ACTIVE with a RAB already established"
3517 };
3518
3519 static guint16
3520 de_gc_uplink_data_stat(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
3521 {
3522         guint32 curr_offset;
3523         guint32 bit_offset;
3524
3525         curr_offset = offset;
3526         bit_offset = curr_offset<<3;
3527
3528         proto_tree_add_bits_item(tree, hf_gsm_a_gm_nsapi_7_ul_stat, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
3529         bit_offset++;
3530         proto_tree_add_bits_item(tree, hf_gsm_a_gm_nsapi_6_ul_stat, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
3531         bit_offset++;
3532         proto_tree_add_bits_item(tree, hf_gsm_a_gm_nsapi_5_ul_stat, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
3533         bit_offset++;
3534         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, bit_offset, 5, ENC_BIG_ENDIAN);
3535         bit_offset+=5;
3536         curr_offset++;
3537         proto_tree_add_bits_item(tree, hf_gsm_a_gm_nsapi_15_ul_stat, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
3538         bit_offset++;
3539         proto_tree_add_bits_item(tree, hf_gsm_a_gm_nsapi_14_ul_stat, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
3540         bit_offset++;
3541         proto_tree_add_bits_item(tree, hf_gsm_a_gm_nsapi_13_ul_stat, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
3542         bit_offset++;
3543         proto_tree_add_bits_item(tree, hf_gsm_a_gm_nsapi_12_ul_stat, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
3544         bit_offset++;
3545         proto_tree_add_bits_item(tree, hf_gsm_a_gm_nsapi_11_ul_stat, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
3546         bit_offset++;
3547         proto_tree_add_bits_item(tree, hf_gsm_a_gm_nsapi_10_ul_stat, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
3548         bit_offset++;
3549         proto_tree_add_bits_item(tree, hf_gsm_a_gm_nsapi_9_ul_stat, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
3550         bit_offset++;
3551         proto_tree_add_bits_item(tree, hf_gsm_a_gm_nsapi_8_ul_stat, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
3552         bit_offset++;
3553         curr_offset++;
3554
3555         return(len);
3556 }
3557
3558 /*
3559  * [7] 10.5.6.1
3560  */
3561 #define MAX_APN_LENGTH          50
3562
3563 guint16
3564 de_sm_apn(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string, int string_len _U_)
3565 {
3566         guint32 curr_offset;
3567         guint   curr_len;
3568         guint8    str[MAX_APN_LENGTH+1];
3569
3570         curr_offset = offset;
3571
3572         /* init buffer and copy it */
3573         memset ( str , 0 , MAX_APN_LENGTH );
3574         tvb_memcpy(tvb, str, offset, len<MAX_APN_LENGTH?len:MAX_APN_LENGTH);
3575
3576         curr_len = 0;
3577         while (( curr_len < len ) && ( curr_len < MAX_APN_LENGTH ))
3578         {
3579                 guint step = str[curr_len];
3580                 str[curr_len]='.';
3581                 curr_len += step+1;
3582         }
3583
3584         proto_tree_add_text(tree,
3585                 tvb, curr_offset, len,
3586                 "APN: %s %s", str+1 , add_string ? add_string : "");
3587
3588         curr_offset+= len;
3589
3590         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
3591
3592         return(curr_offset - offset);
3593 }
3594
3595 /*
3596  * [7] 10.5.6.2
3597  */
3598 static guint16
3599 de_sm_nsapi(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string, int string_len _U_)
3600 {
3601         guint8  oct;
3602         guint32 curr_offset;
3603
3604         curr_offset = offset;
3605
3606         oct = tvb_get_guint8(tvb, curr_offset);
3607
3608         proto_tree_add_text(tree,
3609                 tvb, curr_offset, 1,
3610                 "NSAPI: 0x%02x (%u) %s",
3611                 oct&0x0f, oct&0x0f,add_string ? add_string : "");
3612
3613         curr_offset++;
3614
3615         return(curr_offset - offset);
3616 }
3617
3618 /*
3619  * [7] 10.5.6.3 Protocol configuration options
3620  */
3621 static const value_string gsm_a_sm_pco_ms2net_prot_vals[] = {
3622         { 0x01, "P-CSCF IPv6 Address Request" },
3623         { 0x02, "IM CN Subsystem Signaling Flag" },
3624         { 0x03, "DNS Server IPv6 Address Request" },
3625         { 0x04, "Not Supported" },
3626         { 0x05, "MS Support of Network Requested Bearer Control indicator" },
3627         { 0x06, "Reserved" },
3628         { 0x07, "DSMIPv6 Home Agent Address Request" },
3629         { 0x08, "DSMIPv6 Home Network Prefix Request" },
3630         { 0x09, "DSMIPv6 IPv4 Home Agent Address Request" },
3631         { 0x0a, "IP address allocation via NAS signalling" },
3632         { 0x0b, "IPv4 address allocation via DHCPv4" },
3633         { 0x0c, "P-CSCF IPv4 Address Request" },
3634         { 0x0d, "DNS Server IPv4 Address Request" },
3635         { 0x0e, "MSISDN Request" },
3636         { 0, NULL }
3637 };
3638 static const value_string gsm_a_sm_pco_net2ms_prot_vals[] = {
3639         { 0x01, "P-CSCF IPv6 Address" },
3640         { 0x02, "IM CN Subsystem Signaling Flag" },
3641         { 0x03, "DNS Server IPv6 Address" },
3642         { 0x04, "Policy Control rejection code" },
3643         { 0x05, "Selected Bearer Control Mode" },
3644         { 0x06, "Reserved" },
3645         { 0x07, "DSMIPv6 Home Agent Address" },
3646         { 0x08, "DSMIPv6 Home Network Prefix" },
3647         { 0x09, "DSMIPv6 IPv4 Home Agent Address" },
3648         { 0x0a, "Reserved" },
3649         { 0x0b, "Reserved" },
3650         { 0x0c, "P-CSCF IPv4 Address" },
3651         { 0x0d, "DNS Server IPv4 Address" },
3652         { 0x0e, "MSISDN" },
3653         { 0, NULL }
3654 };
3655
3656 static const value_string gsm_a_gm_link_dir_vals[] = {
3657         { -1, "Unknown" },
3658         { 0x0, "MS to network" },
3659         { 0x1, "Network to MS" },
3660         { 0, NULL }
3661 };
3662
3663 guint16
3664 de_sm_pco(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
3665 {
3666         proto_item   *generated_item = NULL;
3667         guint32 curr_offset;
3668         guint   curr_len;
3669         guchar  oct;
3670         struct e_in6_addr ipv6_addr;
3671         int     link_dir;
3672
3673         curr_len = len;
3674         curr_offset = offset;
3675
3676         oct = tvb_get_guint8(tvb, curr_offset);
3677
3678         link_dir = pinfo->link_dir;
3679         generated_item =proto_tree_add_int(tree, hf_gsm_a_gm_link_dir, tvb, curr_offset, 0, link_dir);
3680         PROTO_ITEM_SET_GENERATED(generated_item);
3681
3682
3683         /* 1 ext 0 0 0 0 Spare  Configuration protocol */
3684         proto_tree_add_item(tree, hf_gsm_a_gm_sm_ext, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3685         /* Configuration protocol (octet 3)
3686          * Bits
3687          * 3 2 1
3688          * 0 0 0 PPP for use with IP PDP type or IP PDN type (see 3GPP TS 24.301 [120])
3689          *
3690          * All other values are interpreted as PPP in this version of the protocol.
3691          * (3GPP TS 24.008 version 9.4.0 Release 9)
3692          */
3693         proto_tree_add_text(tree,tvb, curr_offset, 1, "Configuration Protocol: PPP (%u)",oct&0x07);
3694         curr_len--;
3695         curr_offset++;
3696
3697         while ( curr_len > 0 )
3698         {
3699                 guchar e_len;
3700                 guint16 prot;
3701                 tvbuff_t *l3_tvb;
3702                 dissector_handle_t handle = NULL;
3703
3704                 /* Protocol ID 1                    octet 4
3705                  *                                  octet 5
3706                  * Length of protocol ID 1 contents octet 6
3707                  * Protocol ID 1 contents           octet 7
3708                  */
3709
3710                 prot = tvb_get_ntohs(tvb,curr_offset);
3711                 proto_tree_add_uint_format(tree, hf_gsm_a_gm_pco_pid, tvb, curr_offset, 2, (guint32)prot,
3712                                 "Protocol or Container ID: %s (%u)",
3713                                 link_dir ?
3714                                         val_to_str_const((guint32)prot, gsm_a_sm_pco_net2ms_prot_vals, val_to_str_ext_const(prot, &ppp_vals_ext, "Unknown")) :
3715                                         val_to_str_const((guint32)prot, gsm_a_sm_pco_ms2net_prot_vals, val_to_str_ext_const(prot, &ppp_vals_ext, "Unknown")),
3716                                 (guint32)prot);
3717
3718                 curr_len-=2;
3719                 curr_offset+=2;
3720                 e_len = tvb_get_guint8(tvb, curr_offset);
3721                 proto_tree_add_text(tree,tvb, curr_offset, 1, "Length: 0x%02x (%u)", e_len , e_len);
3722                 curr_len-=1;
3723                 curr_offset+=1;
3724
3725                 switch ( prot )
3726                 {
3727                         case 0x0001:
3728                         {
3729                                 if (e_len > 0) {
3730                                         tvb_get_ipv6(tvb, curr_offset, &ipv6_addr);
3731                                         proto_tree_add_text(tree,
3732                                         tvb, curr_offset, 16,
3733                                         "IPv6: %s", ip6_to_str(&ipv6_addr));
3734                                 }
3735                                 break;
3736                         }
3737                         case 0x0002:
3738                                 break;
3739                         case 0x0003:
3740                         {
3741                                 if (e_len > 0) {
3742                                         tvb_get_ipv6(tvb, curr_offset, &ipv6_addr);
3743                                         proto_tree_add_text(tree,
3744                                         tvb, curr_offset, 16,
3745                                         "IPv6: %s", ip6_to_str(&ipv6_addr));
3746                                 }
3747                                 break;
3748                         }
3749                         case 0x0004:
3750                                 oct = tvb_get_guint8(tvb, curr_offset);
3751                                 proto_tree_add_text(tree,tvb, curr_offset, 1, "Reject Code: 0x%02x (%u)", e_len , e_len);
3752                                 break;
3753                         default:
3754                         {
3755                                 handle = dissector_get_uint_handle ( gprs_sm_pco_subdissector_table , prot );
3756                                 if ( handle != NULL )
3757                                 {
3758                                         /*
3759                                          * dissect the embedded message
3760                                          */
3761                                         l3_tvb = tvb_new_subset(tvb, curr_offset, e_len, e_len);
3762                                         /* In this case we do not want the columns updated */
3763                                         col_set_writable(pinfo->cinfo, FALSE);
3764                                         call_dissector(handle, l3_tvb , pinfo  , tree );
3765                                         col_set_writable(pinfo->cinfo, TRUE);
3766                                 }
3767                                 else
3768                                 {
3769                                         /*
3770                                         * dissect the embedded DATA message
3771                                         */
3772                                         l3_tvb = tvb_new_subset(tvb, curr_offset, e_len, e_len);
3773                                         call_dissector(data_handle, l3_tvb, pinfo , tree);
3774                                 }
3775                         }
3776                 }
3777
3778                 curr_len-= e_len;
3779                 curr_offset+= e_len;
3780         }
3781         curr_offset+= curr_len;
3782
3783         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
3784
3785         return(curr_offset - offset);
3786 }
3787
3788 /*
3789  * [9] 10.5.6.4 Packet data protocol address
3790  */
3791 static const value_string gsm_a_sm_pdp_type_org_vals[] = {
3792         { 0x00, "ETSI allocated address" },
3793         { 0x01, "IETF allocated address" },
3794         { 0x0f, "Empty PDP type" },
3795         { 0, NULL }
3796 };
3797
3798 static guint16
3799 de_sm_pdp_addr(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
3800 {
3801         guint32 curr_offset;
3802         const gchar     *str;
3803         guchar    pdp_type_org, pdp_type_num;
3804
3805         curr_offset = offset;
3806
3807         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (curr_offset << 3), 4, ENC_BIG_ENDIAN);
3808         proto_tree_add_item(tree, hf_gsm_a_sm_pdp_type_org, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3809
3810         pdp_type_org = tvb_get_guint8(tvb, curr_offset) & 0x0f;
3811         curr_offset += 1;
3812         pdp_type_num = tvb_get_guint8(tvb, curr_offset);
3813
3814         if (pdp_type_org == 0 )
3815         {
3816                 /* ETSI allocated address */
3817                 switch (pdp_type_num)
3818                 {
3819                         case 0x00: str="Reserved, used in earlier version of this protocol"; break;
3820                         case 0x01: str="PDP-type PPP"; break;
3821                         default: str="reserved";
3822                 }
3823         }
3824         else if (pdp_type_org == 1)
3825         {
3826                 /* IETF allocated addres */
3827                 switch (pdp_type_num)
3828                 {
3829                         case 0x21: str="IPv4 address"; break;
3830                         case 0x57: str="IPv6 address"; break;
3831                         case 0x8d: str="IPv4v6 address"; break;
3832                         default: str="Unknown, interpreted as IPv4 address";
3833                 }
3834         }
3835         else if ((pdp_type_num == 0) && (pdp_type_org == 0x0f))
3836                 str="Empty";
3837         else
3838                 str="Not specified";
3839
3840         proto_tree_add_text(tree,
3841                 tvb, curr_offset, 1,
3842                 "PDP type number: %s (%u)",str,pdp_type_num);
3843
3844         if (( len == 2 ) && (( pdp_type_num == 0x21 ) || ( pdp_type_num == 0x57 ) || (pdp_type_num == 0x8d)))
3845         {
3846                 proto_tree_add_text(tree,
3847                         tvb, curr_offset, 1,
3848                         "Dynamic addressing");
3849                 curr_offset += 1;
3850                 return(curr_offset - offset);
3851         }
3852         else if ( len == 2 )
3853         {
3854                 proto_tree_add_text(tree,
3855                         tvb, curr_offset, 1,
3856                         "No PDP address is included");
3857                 curr_offset += 1;
3858                 return(curr_offset - offset);
3859         }
3860
3861         curr_offset += 1;
3862         if (pdp_type_org == 1)
3863         switch (pdp_type_num)
3864         {
3865                 case 0x57:
3866                         proto_tree_add_item(tree,hf_gsm_a_sm_ip6_address,tvb,curr_offset,16,ENC_NA);
3867                         curr_offset+=16;
3868                         break;
3869
3870                 case 0x8d:
3871                         proto_tree_add_item(tree,hf_gsm_a_sm_ip4_address,tvb,curr_offset,4,ENC_BIG_ENDIAN);
3872                         curr_offset+=4;
3873                         proto_tree_add_item(tree,hf_gsm_a_sm_ip6_address,tvb,curr_offset,16,ENC_NA);
3874                         curr_offset+=16;
3875                         break;
3876
3877                 default:
3878                         proto_tree_add_item(tree,hf_gsm_a_sm_ip4_address,tvb,curr_offset,4,ENC_BIG_ENDIAN);
3879                         curr_offset+=4;
3880         }
3881
3882         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
3883
3884         return(curr_offset - offset);
3885 }
3886
3887 /*
3888  * [9] 10.5.6.5 Quality of service
3889  */
3890 static const value_string gsm_a_qos_delay_cls_vals[] = {
3891         { 0x00, "Subscribed delay class (in MS to network direction)" },
3892         { 0x01, "Delay class 1" },
3893         { 0x02, "Delay class 2" },
3894         { 0x03, "Delay class 3" },
3895         { 0x04, "Delay class 4 (best effort)" },
3896         { 0x07, "Reserved" },
3897         { 0, NULL }
3898 };
3899
3900 static const value_string gsm_a_qos_reliability_vals[] = {
3901         { 0x00, "Subscribed reliability class (in MS to network direction)" },
3902         { 0x01, "Acknowledged GTP, LLC, and RLC; Protected data" },
3903         { 0x02, "Unacknowledged GTP, Ack LLC/RLC, Protected data" },
3904         { 0x03, "Unacknowledged GTP/LLC, Ack RLC, Protected data" },
3905         { 0x04, "Unacknowledged GTP/LLC/RLC, Protected data" },
3906         { 0x05, "Unacknowledged GTP/LLC/RLC, Unprotected data" },
3907         { 0x07, "Reserved" },
3908         { 0, NULL }
3909 };
3910  /* Delivery of erroneous SDUs, octet 6 (see 3GPP TS 23.107) Bits 3 2 1 */
3911 const value_string gsm_a_qos_del_of_err_sdu_vals[] = {
3912         { 0, "Subscribed delivery of erroneous SDUs/Reserved" },
3913         { 1, "No detect('-')" },
3914         { 2, "Erroneous SDUs are delivered('yes')" },
3915         { 3, "Erroneous SDUs are not delivered('No')" },
3916         { 7, "Reserved" },
3917         { 0, NULL }
3918 };
3919
3920  /* Delivery order, octet 6 (see 3GPP TS 23.107) Bits 5 4 3 */
3921 const value_string gsm_a_qos_del_order_vals[] = {
3922         { 0, "Subscribed delivery order/Reserved" },
3923         { 1, "With delivery order ('yes')" },
3924         { 2, "Without delivery order ('no')" },
3925         { 3, "Reserved" },
3926         { 0, NULL }
3927 };
3928 /* Traffic class, octet 6 (see 3GPP TS 23.107) Bits 8 7 6 */
3929 const value_string gsm_a_qos_traffic_cls_vals[] = {
3930         { 0, "Subscribed traffic class/Reserved" },
3931         { 1, "Conversational class" },
3932         { 2, "Streaming class" },
3933         { 3, "Interactive class" },
3934         { 4, "Background class" },
3935         { 7, "Reserved" },
3936         { 0, NULL }
3937 };
3938
3939 /* Residual Bit Error Rate (BER), octet 10 (see 3GPP TS 23.107) Bits 8 7 6 5 */
3940 const value_string gsm_a_qos_ber_vals[] = {
3941         { 0, "Subscribed residual BER/Reserved" },
3942         { 1, "5*10-2" },
3943         { 2, "1*10-2" },
3944         { 3, "5*10-3" },
3945         { 4, "4*10-3" },
3946         { 5, "1*10-3" },
3947         { 6, "1*10-4" },
3948         { 7, "1*10-5" },
3949         { 8, "1*10-6" },
3950         { 9, "6*10-8" },
3951         { 10, "Reserved" },
3952         { 0, NULL }
3953 };
3954
3955 /* SDU error ratio, octet 10 (see 3GPP TS 23.107) Bits 4 3 2 1 */
3956 const value_string gsm_a_qos_sdu_err_rat_vals[] = {
3957         { 0, "Subscribed SDU error ratio/Reserved" },
3958         { 1, "1*10-2" },
3959         { 2, "7*10-3" },
3960         { 3, "1*10-3" },
3961         { 4, "1*10-4" },
3962         { 5, "1*10-5" },
3963         { 6, "1*10-6" },
3964         { 7, "1*10-1" },
3965         { 15, "Reserved" },
3966         { 0, NULL }
3967 };
3968
3969 /* Traffic handling priority, octet 11 (see 3GPP TS 23.107) Bits 2 1 */
3970 const value_string gsm_a_qos_traff_hdl_pri_vals[] = {
3971         { 0, "Subscribed traffic handling priority/Reserved" },
3972         { 1, "Priority level 1" },
3973         { 2, "Priority level 2" },
3974         { 3, "Priority level 3" },
3975         { 0, NULL }
3976 };
3977
3978 const range_string gsm_a_qos_peak_thr_vals[] = {
3979         { 0x00, 0x00, "Subscribed peak throughput/reserved" },
3980         { 0x01, 0x01, "Up to 1 000 octet/s" },
3981         { 0x02, 0x02, "Up to 2 000 octet/s" },
3982         { 0x03, 0x03, "Up to 4 000 octet/s" },
3983         { 0x04, 0x04, "Up to 8 000 octet/s" },
3984         { 0x05, 0x05, "Up to 16 000 octet/s" },
3985         { 0x06, 0x06, "Up to 32 000 octet/s" },
3986         { 0x07, 0x07, "Up to 64 000 octet/s" },
3987         { 0x08, 0x08, "Up to 128 000 octet/s" },
3988         { 0x09, 0x09, "Up to 256 000 octet/s" },
3989         { 0x0a, 0x0e, "Interpreted as Up to 1 000 octet/s" },
3990         { 0x0f, 0x0f, "Reserved" },
3991         { 0, 0, NULL }
3992 };
3993
3994 const range_string gsm_a_qos_mean_thr_vals[] = {
3995         { 0x00, 0x00, "Subscribed peak throughput/reserved" },
3996         { 0x01, 0x01, "100 octet/h" },
3997         { 0x02, 0x02, "200 octet/h" },
3998         { 0x03, 0x03, "500 octet/h" },
3999         { 0x04, 0x04, "1 000 octet/h" },
4000         { 0x05, 0x05, "2 000 octet/h" },
4001         { 0x06, 0x06, "5 000 octet/h" },
4002         { 0x07, 0x07, "10 000 octet/h" },
4003         { 0x08, 0x08, "20 000 octet/h" },
4004         { 0x09, 0x09, "50 000 octet/h" },
4005         { 0x0a, 0x0a, "100 000 octet/h" },
4006         { 0x0b, 0x0b, "200 000 octet/h" },
4007         { 0x0c, 0x0c, "500 000 octet/h" },
4008         { 0x0d, 0x0d, "1 000 000 octet/h" },
4009         { 0x0e, 0x0e, "2 000 000 octet/h" },
4010         { 0x0f, 0x0f, "5 000 000 octet/h" },
4011         { 0x10, 0x10, "10 000 000 octet/h" },
4012         { 0x11, 0x11, "20 000 000 octet/h" },
4013         { 0x12, 0x12, "50 000 000 octet/h" },
4014         { 0x13, 0x1d, "Interpreted as Best effort" },
4015         { 0x1e, 0x1e, "Reserved" },
4016         { 0x1f, 0x1f, "Best effort" },
4017         { 0, 0, NULL }
4018 };
4019
4020 const range_string gsm_a_qos_prec_class_vals[] = {
4021         { 0x00, 0x00, "Subscribed precedence/reserved" },
4022         { 0x01, 0x01, "High priority" },
4023         { 0x02, 0x02, "Normal priority" },
4024         { 0x03, 0x03, "Low priority" },
4025         { 0x04, 0x06, "Interpreted as Normal priority" },
4026         { 0x07, 0x07, "Reserved" },
4027         { 0, 0, NULL }
4028 };
4029
4030 const true_false_string gsm_a_qos_signalling_ind_value = {
4031         "Optimised for signalling traffic",
4032         "Not optimised for signalling traffic"
4033 };
4034
4035 /* Helper function returning the main bitrates in kbps */
4036 static guint32
4037 qos_calc_bitrate(guint8 oct)
4038 {
4039         if (oct <= 0x3f)
4040                 return oct;
4041         if (oct <= 0x7f)
4042                 return 64 + (oct-0x40) * 8;
4043
4044         return 576 + (oct-0x80) * 64;
4045 }
4046
4047 /* Helper function returning the extended bitrates in kbps */
4048 static guint32
4049 qos_calc_ext_bitrate(guint8 oct)
4050 {
4051         if (oct <= 0x4a)
4052                 return 8600 + oct * 100;
4053         if (oct <= 0xba)
4054                 return 16000 + (oct-0x4a) * 1000;
4055
4056         return 128000 + (oct - 0xba) * 2000;
4057 }
4058
4059 guint16
4060 de_sm_qos(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4061 {
4062         guint32 curr_offset;
4063         guchar     oct, tmp_oct;
4064         const gchar     *str;
4065         guint32 temp32;
4066
4067         curr_offset = offset;
4068
4069         /* Octet 3 */
4070         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (curr_offset << 3), 2, ENC_BIG_ENDIAN);
4071         proto_tree_add_item(tree, hf_gsm_a_qos_delay_cls, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4072         proto_tree_add_item(tree, hf_gsm_a_qos_reliability_cls, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4073         curr_offset+= 1;
4074
4075         /* Octet 4 */
4076         oct = tvb_get_guint8(tvb, curr_offset);
4077         proto_tree_add_item(tree, hf_gsm_a_qos_peak_thr, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4078         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (curr_offset << 3) + 4, 1, ENC_BIG_ENDIAN);
4079         proto_tree_add_item(tree, hf_gsm_a_qos_prec_class, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4080         curr_offset+= 1;
4081
4082         /* Octet 5 */
4083         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (curr_offset << 3), 3, ENC_BIG_ENDIAN);
4084         proto_tree_add_item(tree, hf_gsm_a_qos_mean_thr, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4085         curr_offset+= 1;
4086
4087         NO_MORE_DATA_CHECK(len);
4088
4089         /* Octet 6 */
4090         proto_tree_add_item(tree, hf_gsm_a_qos_traffic_cls, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4091         proto_tree_add_item(tree, hf_gsm_a_qos_del_order, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4092         proto_tree_add_item(tree, hf_gsm_a_qos_del_of_err_sdu, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4093         curr_offset+= 1;
4094
4095         NO_MORE_DATA_CHECK(len);
4096
4097         /* Octet 7 */
4098         oct = tvb_get_guint8(tvb, curr_offset);
4099
4100         switch ( oct )
4101         {
4102                 case 0x00: str="Subscribed maximum SDU size/reserved"; break;
4103                 case 0x97: str="1502 octets"; break;
4104                 case 0x98: str="1510 octets"; break;
4105                 case 0x99: str="1520 octets"; break;
4106                 case 0xff: str="Reserved"; break;
4107                 default: str="Unspecified";
4108         }
4109
4110         if (( oct >= 1 ) && ( oct <= 0x96 ))
4111                 proto_tree_add_text(tree,
4112                         tvb, curr_offset, 1,
4113                         "Maximum SDU size: %u octets (%u)",oct*10, oct);
4114         else
4115                 proto_tree_add_text(tree,
4116                         tvb, curr_offset, 1,
4117                         "Maximum SDU size: %s (%u)",str, oct);
4118
4119         curr_offset+= 1;
4120
4121         NO_MORE_DATA_CHECK(len);
4122
4123         /* Octet 8 */
4124         oct = tvb_get_guint8(tvb, curr_offset);
4125
4126         switch (oct)
4127         {
4128                 case 0x00: str = "Subscribed maximum bit rate for uplink/reserved"; break;
4129                 case 0xff: str = "0 kbps"; break;
4130                 default: str = ep_strdup_printf("%u kbps", qos_calc_bitrate(oct));
4131         }
4132
4133         proto_tree_add_uint_format_value(tree, hf_gsm_a_qos_max_bitrate_upl, tvb,
4134                 curr_offset, 1, oct, "%s (%u)", str, oct);
4135         curr_offset+= 1;
4136
4137         NO_MORE_DATA_CHECK(len);
4138
4139         /* Octet 9 */
4140         oct = tvb_get_guint8(tvb, curr_offset);
4141
4142         switch ( oct )
4143         {
4144                 case 0x00: str="Subscribed maximum bit rate for downlink/reserved"; break;
4145                 case 0xff: str="0 kbps"; break;
4146                 default: str = ep_strdup_printf("%u kbps", qos_calc_bitrate(oct));
4147         }
4148
4149         proto_tree_add_uint_format_value(tree, hf_gsm_a_qos_max_bitrate_downl, tvb,
4150                 curr_offset, 1, oct, "%s (%u)", str, oct);
4151         curr_offset+= 1;
4152
4153         NO_MORE_DATA_CHECK(len);
4154
4155         /* Octet 10 */
4156         proto_tree_add_item(tree, hf_gsm_a_qos_ber, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4157         proto_tree_add_item(tree, hf_gsm_a_qos_sdu_err_rat, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4158
4159         curr_offset+= 1;
4160         NO_MORE_DATA_CHECK(len);
4161
4162         /* Octet 11 */
4163         oct = tvb_get_guint8(tvb, curr_offset);
4164
4165         tmp_oct = oct >> 2;
4166         switch (tmp_oct)
4167         {
4168                 case 0x00: str="Subscribed transfer delay/reserved"; break;
4169                 case 0x3f: str="Reserved"; break;
4170                 default:
4171                         if (tmp_oct <= 0x0f)
4172                                 temp32 = tmp_oct * 10;
4173                         else if (tmp_oct <= 0x1f)
4174                                 temp32 = (tmp_oct - 0x10) * 50 + 200;
4175                         else
4176                                 temp32 = (tmp_oct - 0x20) * 100 + 1000;
4177                         str = ep_strdup_printf("%u ms", temp32);
4178         }
4179
4180         proto_tree_add_uint_format_value(tree, hf_gsm_a_qos_trans_delay, tvb,
4181                 curr_offset, 1, oct, "%s (%u)", str, tmp_oct);
4182
4183         tmp_oct = oct & 0x03;
4184         if (tmp_oct == 0)
4185                 str = "Subscribed traffic handling priority/reserved";
4186         else
4187                 str = ep_strdup_printf("Priority level %u", tmp_oct);
4188
4189         proto_tree_add_uint_format_value(tree, hf_gsm_a_qos_traf_handl_prio, tvb,
4190                 curr_offset, 1, oct, "%s (%u)", str, tmp_oct);
4191
4192         curr_offset+= 1;
4193         NO_MORE_DATA_CHECK(len);
4194
4195         /* Octet 12 */
4196         oct = tvb_get_guint8(tvb, curr_offset);
4197
4198         switch ( oct )
4199         {
4200                 case 0x00: str="Subscribed guaranteed bit rate for uplink/reserved"; break;
4201                 case 0xff: str="0 kbps"; break;
4202                 default: str = ep_strdup_printf("%u kbps", qos_calc_bitrate(oct));
4203         }
4204
4205         proto_tree_add_uint_format_value(tree, hf_gsm_a_qos_guar_bitrate_upl, tvb,
4206                 curr_offset, 1, oct, "%s (%u)", str, oct);
4207
4208         curr_offset+= 1;
4209         NO_MORE_DATA_CHECK(len);
4210
4211         /* Octet 13 */
4212         oct = tvb_get_guint8(tvb, curr_offset);
4213
4214         switch ( oct )
4215         {
4216                 case 0x00: str="Subscribed guaranteed bit rate for downlink/reserved"; break;
4217                 case 0xff: str="0 kbps"; break;
4218                 default: str = ep_strdup_printf("%u kbps", qos_calc_bitrate(oct));
4219         }
4220
4221         proto_tree_add_uint_format_value(tree, hf_gsm_a_qos_guar_bitrate_downl, tvb,
4222                 curr_offset, 1, oct, "%s (%u)", str, oct);
4223
4224         curr_offset+= 1;
4225         NO_MORE_DATA_CHECK(len);
4226
4227         /* Ocet 14 */
4228         oct = tvb_get_guint8(tvb, curr_offset);
4229         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (curr_offset << 3), 3, ENC_BIG_ENDIAN);
4230         proto_tree_add_item(tree, hf_gsm_a_qos_signalling_ind, tvb , curr_offset, 1, ENC_BIG_ENDIAN);
4231
4232         tmp_oct = oct & 7;
4233         if (tmp_oct == 0x01)
4234                 str = "speech";
4235         else
4236                 str = "unknown";
4237
4238         proto_tree_add_uint_format_value(tree, hf_gsm_a_qos_source_stat_desc, tvb,
4239                 curr_offset, 1, oct, "%s (%u)", str, tmp_oct);
4240
4241         curr_offset+= 1;
4242         NO_MORE_DATA_CHECK(len);
4243
4244         /* Octet 15 */
4245         oct = tvb_get_guint8(tvb, curr_offset);
4246
4247         if (oct == 0x00)
4248                 str = "Use the value indicated by the Maximum bit rate for downlink";
4249         else
4250         {
4251                 temp32 = qos_calc_ext_bitrate(oct);
4252                 if (temp32 % 1000 == 0)
4253                         str = ep_strdup_printf("%u Mbps", temp32 / 1000);
4254                 else
4255                         str = ep_strdup_printf("%u kbps", temp32);
4256         }
4257         proto_tree_add_uint_format_value(tree, hf_gsm_a_qos_max_bitrate_downl_ext, tvb,
4258                 curr_offset, 1, oct, "%s (%u)", str, oct);
4259
4260         curr_offset+= 1;
4261         NO_MORE_DATA_CHECK(len);
4262
4263         /* Octet 16 */
4264         oct = tvb_get_guint8(tvb, curr_offset);
4265
4266         if (oct == 0x00)
4267                 str = "Use the value indicated by the Guaranteed bit rate for downlink";
4268         else
4269         {
4270                 temp32 = qos_calc_ext_bitrate(oct);
4271                 if (temp32 % 1000 == 0)
4272                         str = ep_strdup_printf("%u Mbps", temp32 / 1000);
4273                 else
4274                         str = ep_strdup_printf("%u kbps", temp32);
4275         }
4276         proto_tree_add_uint_format_value(tree, hf_gsm_a_qos_guar_bitrate_downl_ext, tvb,
4277                 curr_offset, 1, oct, "%s (%u)", str, oct);
4278
4279         curr_offset+= 1;
4280         NO_MORE_DATA_CHECK(len);
4281
4282         /* Maximum bit rate for uplink (extended) Octet 17 */
4283         oct = tvb_get_guint8(tvb, curr_offset);
4284
4285         if (oct == 0x00)
4286                 str = "Use the value indicated by the Maximum bit rate for uplink";
4287         else
4288         {
4289                 temp32 = qos_calc_ext_bitrate(oct);
4290                 if (temp32 % 1000 == 0)
4291                         str = ep_strdup_printf("%u Mbps", temp32 / 1000);
4292                 else
4293                         str = ep_strdup_printf("%u kbps", temp32);
4294         }
4295         proto_tree_add_uint_format_value(tree, hf_gsm_a_qos_max_bitrate_upl_ext, tvb,
4296                 curr_offset, 1, oct, "%s (%u)", str, oct);
4297
4298         curr_offset+= 1;
4299         NO_MORE_DATA_CHECK(len);
4300
4301         /* Guaranteed bit rate for uplink (extended) Octet 18 */
4302         oct = tvb_get_guint8(tvb, curr_offset);
4303
4304         if (oct == 0x00)
4305                 str = "Use the value indicated by the Guaranteed bit rate for uplink";
4306         else
4307         {
4308                 temp32 = qos_calc_ext_bitrate(oct);
4309                 if (temp32 % 1000 == 0)
4310                         str = ep_strdup_printf("%u Mbps", temp32 / 1000);
4311                 else
4312                         str = ep_strdup_printf("%u kbps", temp32);
4313         }
4314         proto_tree_add_uint_format_value(tree, hf_gsm_a_qos_guar_bitrate_upl_ext, tvb,
4315                 curr_offset, 1, oct, "%s (%u)", str, oct);
4316
4317         curr_offset+= 1;
4318
4319         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
4320
4321         return(curr_offset - offset);
4322 }
4323
4324 /*
4325  * [9] 10.5.6.6 SM cause
4326  */
4327 static const value_string gsm_a_sm_cause_vals[] = {
4328         { 0x08, "Operator Determined Barring" },
4329         { 0x18, "MBMS bearer capabilities insufficient for the service" },
4330         { 0x19, "LLC or SNDCP failure(GSM only)" },
4331         { 0x1a, "Insufficient resources" },
4332         { 0x1b, "Missing or unknown APN" },
4333         { 0x1c, "Unknown PDP address or PDP type" },
4334         { 0x1d, "User Authentication failed" },
4335         { 0x1e, "Activation rejected by GGSN" },
4336         { 0x1f, "Activation rejected, unspecified" },
4337         { 0x20, "Service option not supported" },
4338         { 0x21, "Requested service option not subscribed" },
4339         { 0x22, "Service option temporarily out of order" },
4340         { 0x23, "NSAPI already used (not sent)" },
4341         { 0x24, "Regular deactivation" },
4342         { 0x25, "QoS not accepted" },
4343         { 0x26, "Network failure" },
4344         { 0x27, "Reactivation required" },
4345         { 0x28, "Feature not supported" },
4346         { 0x29, "Semantic error in the TFT operation" },
4347         { 0x2a, "Syntactical error in the TFT operation" },
4348         { 0x2b, "Unknown PDP context" },
4349         { 0x2c, "Semantic errors in packet filter(s)" },
4350         { 0x2d, "Syntactical errors in packet filter(s)" },
4351         { 0x2e, "PDP context without TFT already activated" },
4352         { 0x2f, "Multicast group membership time-out" },
4353         { 0x2c, "Semantic errors in packet filter(s)" },
4354         { 0x2d, "Syntactical errors in packet filter(s)" },
4355         { 0x30, "Activation rejected, BCM violation" },
4356         { 0x32, "PDP type IPv4 only allowed" },
4357         { 0x33, "PDP type IPv6 only allowed" },
4358         { 0x34, "Single address bearers only allowed" },
4359         { 0x51, "Invalid transaction identifier value" },
4360         { 0x5f, "Semantically incorrect message" },
4361         { 0x60, "Invalid mandatory information" },
4362         { 0x61, "Message type non-existent or not implemented" },
4363         { 0x62, "Message type not compatible with the protocol state" },
4364         { 0x63, "Information element non-existent or not implemented" },
4365         { 0x64, "Conditional IE error" },
4366         { 0x65, "Message not compatible with the protocol state" },
4367         { 0x6f, "Protocol error, unspecified" },
4368         { 0x70, "APN restriction value incompatible with active PDP context" },
4369         { 0, NULL }
4370 };
4371
4372 static guint16
4373 de_sm_cause(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
4374 {
4375         guint8  oct;
4376         const gchar     *str;
4377
4378         oct = tvb_get_guint8(tvb, offset);
4379
4380         /* SM Cause can be sent in both directions */
4381         str = val_to_str_const(oct, gsm_a_sm_cause_vals,
4382                                "Protocol error, unspecified / Service option temporarily out of order");
4383
4384         proto_tree_add_uint_format_value(tree, hf_gsm_a_sm_cause, tvb,
4385                                 offset, 1, oct, "%s (%u)", str, oct);
4386
4387         /* no length check possible */
4388         return(1);
4389 }
4390
4391 /*
4392  * [9] 10.5.6.6a SM cause 2
4393  */
4394 static guint16
4395 de_sm_cause_2(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
4396 {
4397         guint8  oct;
4398         const gchar     *str;
4399
4400         oct = tvb_get_guint8(tvb, offset);
4401
4402         /* SM Cause 2 is sent only in the Network-to-MS direction */
4403         str = val_to_str_const(oct, gsm_a_sm_cause_vals,
4404                                "Service option temporarily out of order");
4405
4406         proto_tree_add_uint_format_value(tree, hf_gsm_a_sm_cause_2, tvb,
4407                                 offset, 1, oct, "%s (%u)", str, oct);
4408
4409         /* no length check possible */
4410         return(1);
4411 }
4412 /*
4413  * [7] 10.5.6.7
4414  */
4415
4416 static const true_false_string gsm_a_sm_ti_flag_vals = {
4417         "The message is sent to the side that originates the TI",
4418         "The message is sent from the side that originates the TI"
4419 };
4420
4421 static guint16
4422 de_sm_linked_ti(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4423 {
4424         guint32 curr_offset;
4425         guint   curr_len;
4426         gchar   oct;
4427         curr_len = len;
4428         curr_offset = offset;
4429
4430         oct = tvb_get_guint8(tvb, curr_offset);
4431
4432         proto_tree_add_item(tree, hf_gsm_a_sm_ti_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
4433
4434         /* The TI value and the TI flag occupy bits 5 - 7 and bit 8 of the first octet respectively.
4435          * The extended TI shall not be used unless TI values of 7 or greater are needed.
4436          * Where the extended TI is used, the TI IE includes a second octet. The TI value in the first octet is ignored, and the TI
4437          * value is encoded in bits 7-1 of the second octet.
4438          */
4439
4440         if ( curr_len > 1 )
4441         {
4442                 curr_offset++;
4443                 oct = tvb_get_guint8(tvb, curr_offset);
4444
4445                 proto_tree_add_text(tree,
4446                         tvb, curr_offset, 1,
4447                         "TI value: 0x%02x (%u)",oct&0x7f,oct&0x7f);
4448
4449                 proto_tree_add_item(tree, hf_gsm_a_sm_ext, tvb, offset, 1, ENC_BIG_ENDIAN);
4450
4451                 curr_offset++;
4452         }
4453         else
4454         {
4455                 proto_tree_add_text(tree,
4456                         tvb, curr_offset, 1,
4457                         "TI value: 0x%02x (%u)",(oct>>4)&7,(oct>>4)&7);
4458                 curr_offset++;
4459         }
4460
4461
4462         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
4463
4464         return(curr_offset - offset);
4465 }
4466
4467 /*
4468  * [9] 10.5.6.9 LLC service access point identifier
4469  */
4470 static const value_string gsm_a_sm_llc_sapi_vals[] = {
4471         { 0, "LLC SAPI not assigned" },
4472         { 3, "SAPI 3" },
4473         { 5, "SAPI 5" },
4474         { 9, "SAPI 9" },
4475         { 11, "SAPI 11" },
4476         { 0, NULL }
4477 };
4478
4479 static guint16
4480 de_sm_sapi(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
4481 {
4482         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, offset << 3, 4, ENC_BIG_ENDIAN);
4483         proto_tree_add_item(tree, hf_gsm_a_sm_llc_sapi, tvb, offset, 1, ENC_BIG_ENDIAN);
4484
4485         /* no length check possible */
4486         return(1);
4487 }
4488
4489 /*
4490  * [9] 10.5.6.10 Tear down indicator
4491  */
4492 const true_false_string gsm_a_sm_tdi_value = {
4493         "Tear down requested",
4494         "Tear down not requested"
4495 };
4496
4497 static guint16
4498 de_sm_tear_down(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
4499 {
4500         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (offset << 3) + 4, 3, ENC_BIG_ENDIAN);
4501         proto_tree_add_item(tree, hf_gsm_a_sm_tdi, tvb, offset, 1, ENC_BIG_ENDIAN);
4502
4503         /* no length check possible */
4504         return(1);
4505 }
4506
4507 /*
4508  * [9] 10.5.6.11 Packet Flow Identifier
4509  */
4510 static const range_string gsm_a_sm_packet_flow_id_vals[] = {
4511         { 0x00, 0x00, "Best Effort"},
4512         { 0x01, 0x01, "Signaling"},
4513         { 0x02, 0x02, "SMS"},
4514         { 0x03, 0x03, "TOM8"},
4515         { 0x04, 0x07, "Reserved"},
4516         { 0x08, 0x7f, "Dynamically assigned"},
4517         { 0x00, 0x00, NULL }
4518 };
4519
4520 guint16
4521 de_sm_pflow_id(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4522 {
4523         guint32 curr_offset;
4524         guint value;
4525
4526         curr_offset = offset;
4527         value = tvb_get_guint8(tvb,curr_offset);
4528         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, curr_offset << 3, 1, ENC_BIG_ENDIAN);
4529         proto_tree_add_item(tree, hf_gsm_a_sm_packet_flow_id, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4530         curr_offset++;
4531
4532     if (add_string)
4533         g_snprintf(add_string, string_len, " - %s", rval_to_str(value, gsm_a_sm_packet_flow_id_vals, "Unknown"));
4534
4535         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
4536
4537         return(curr_offset - offset);
4538 }
4539
4540 /*
4541  * [7] 10.5.6.12     TFT - Traffic Flow Template
4542  */
4543 /* TFT operation code (octet 3) */
4544 static const value_string gsm_a_tft_op_code_vals[] = {
4545         { 0,            "Spare"},
4546         { 1,            "Create new TFT"},
4547         { 2,            "Delete existing TFT"},
4548         { 3,            "Add packet filters to existing TFT"},
4549         { 4,            "Replace packet filters in existing TFT"},
4550         { 5,            "Delete packet filters from existing TFT"},
4551         { 6,            "No TFT operation"},
4552         { 7,            "Reserved"},
4553         { 0,    NULL }
4554 };
4555
4556 static const true_false_string gsm_a_tft_e_bit  = {
4557   "Parameters list is included",
4558   "Parameters list is not included"
4559 };
4560
4561 static const value_string gsm_a_tft_pkt_flt_dir_vals[] = {
4562         { 0,    "Pre Rel-7 TFT filter"},
4563         { 1,    "Downlink only"},
4564         { 2,    "Uplink only"},
4565         { 3,    "Bidirectional"},
4566         { 0,    NULL }
4567 };
4568
4569 static const value_string gsm_a_tft_param_id_vals[] = {
4570         { 1,    "Authorization Token"},
4571         { 2,    "Flow Identifier"},
4572         { 3,    "Packet Filter Identifier"},
4573         { 0,    NULL }
4574 };
4575
4576 guint16
4577 de_sm_tflow_temp(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4578 {
4579         guint32       curr_offset;
4580         guint         curr_len;
4581         proto_item   *tf = NULL;
4582         proto_tree   *tf_tree = NULL;
4583         proto_tree   *comp_tree = NULL;
4584         guchar        op_code;
4585         guchar        pkt_fil_count;
4586         guchar        e_bit;
4587         const gchar  *str;
4588         guchar        count;
4589         guchar        oct;
4590         gint          pf_length;
4591         gint          i;
4592         gint          pack_component_type;
4593         gint          param;
4594
4595         curr_len = len;
4596         curr_offset = offset;
4597
4598         /*
4599          * parse first octet. It contain TFT operation code, E bit and Number of packet filters
4600          */
4601         oct = tvb_get_guint8(tvb, curr_offset);
4602
4603         op_code = oct>>5;
4604         pkt_fil_count = oct&0x0f;
4605         e_bit = (oct>>4)&1;
4606
4607         proto_tree_add_item(tree,hf_gsm_a_tft_op_code,tvb,curr_offset,1,ENC_BIG_ENDIAN);
4608         proto_tree_add_item(tree,hf_gsm_a_tft_e_bit,tvb,curr_offset,1,ENC_BIG_ENDIAN);
4609         proto_tree_add_item(tree,hf_gsm_a_tft_pkt_flt,tvb,curr_offset,1,ENC_BIG_ENDIAN);
4610
4611         curr_offset++;
4612         curr_len--;
4613
4614         /* Packet filter list dissect */
4615
4616         count = 0;
4617         if ( op_code == 2 )                     /* delete TFT contains no packet filters. so we will jump over it */
4618                 count = pkt_fil_count;
4619         while ( count < pkt_fil_count )
4620         {
4621                 tf = proto_tree_add_text(tree,
4622                         tvb, curr_offset, 1,
4623                         "Packet filter %d",count);   /* 0-> 7 */
4624
4625                 tf_tree = proto_item_add_subtree(tf, ett_sm_tft );
4626
4627                 if ( op_code == 5 )  /* Delete packet filters from existing TFT - just a list of identifiers */
4628                 {
4629                         if ((curr_offset-offset)<1) {
4630                                 proto_tree_add_text(tf_tree,tvb, curr_offset, 1,"Not enough data");
4631                                 return(len);
4632                         }
4633                         proto_tree_add_bits_item(tf_tree, hf_gsm_a_spare_bits, tvb, (curr_offset<<3), 4, ENC_BIG_ENDIAN);
4634                         proto_tree_add_item(tf_tree, hf_gsm_a_tft_pkt_flt_id, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4635                         curr_offset++;
4636                         curr_len--;
4637                         count++;
4638                 }
4639                 else                            /* create new, Add packet filters or Replace packet filters */
4640                 {
4641
4642                         if ((curr_offset-offset)<1) {
4643                                 proto_tree_add_text(tf_tree,tvb, curr_offset, 1,"Not enough data");
4644                                 return(len);
4645                         }
4646                         proto_tree_add_bits_item(tf_tree, hf_gsm_a_spare_bits, tvb, (curr_offset<<3), 2, ENC_BIG_ENDIAN);
4647                         proto_tree_add_item(tf_tree, hf_gsm_a_tft_pkt_flt_dir, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4648                         proto_tree_add_item(tf_tree, hf_gsm_a_tft_pkt_flt_id, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4649                         curr_offset++;
4650                         curr_len--;
4651
4652                         if ((curr_offset-offset)<1) {
4653                                 proto_tree_add_text(tf_tree,tvb, curr_offset, 1,"Not enough data");
4654                                 return(len);
4655                         }
4656                         oct = tvb_get_guint8(tvb, curr_offset);
4657                         curr_offset++;
4658                         curr_len--;
4659
4660                         proto_tree_add_text(tf_tree,
4661                                 tvb, curr_offset-1, 1,
4662                                 "Packet evaluation precedence: 0x%02x (%u)",oct,oct );
4663
4664                         if ((curr_offset-offset)<1) { proto_tree_add_text(tf_tree,tvb, curr_offset, 1,"Not enough data"); return(len);}
4665                         pf_length = tvb_get_guint8(tvb, curr_offset);
4666                         curr_offset++;
4667                         curr_len--;
4668
4669                         proto_tree_add_text(tf_tree,
4670                                 tvb, curr_offset-1, 1,
4671                                 "Packet filter length: 0x%02x (%u)",pf_length,pf_length );
4672                         /* New tree for component */
4673
4674                         /* Dissect Packet filter Component */
4675                         /* while ( filter_len > 1 ) */
4676                         /* packet filter component type identifier: */
4677
4678                         while (pf_length > 0 ){
4679                                 if ((curr_offset-offset)<1) {
4680                                         proto_tree_add_text(tf_tree,tvb, curr_offset, 1,"Not enough data");
4681                                         return(len);
4682                                 }
4683                                 pack_component_type = tvb_get_guint8(tvb, curr_offset);
4684                                 curr_offset++;
4685                                 curr_len--;
4686                                 pf_length--;
4687
4688                                 tf=proto_tree_add_text(tf_tree,tvb, curr_offset-1, 1,"Packet filter component type identifier: ");
4689                                 comp_tree = proto_item_add_subtree(tf, ett_sm_tft );
4690
4691                                 switch ( pack_component_type ){
4692
4693                                 case 0x10:
4694                                         str="IPv4 remote address type";
4695                                         proto_tree_add_item(comp_tree,hf_gsm_a_sm_ip4_address,tvb,curr_offset,4,ENC_BIG_ENDIAN);
4696                                         curr_offset+=4;
4697                                         curr_len-=4;
4698                                         proto_tree_add_item(comp_tree,hf_gsm_a_sm_ip4_mask,tvb,curr_offset,4,ENC_BIG_ENDIAN);
4699                                         curr_offset+=4;
4700                                         curr_len-=4;
4701                                         pf_length-=8;
4702                                         break;
4703
4704                                 case 0x20:
4705                                         str="IPv6 remote address type";
4706                                         proto_tree_add_item(comp_tree,hf_gsm_a_sm_ip6_address,tvb,curr_offset,16,ENC_NA);
4707                                         curr_offset+=16;
4708                                         curr_len-=16;
4709                                         proto_tree_add_item(comp_tree,hf_gsm_a_sm_ip6_mask,tvb,curr_offset,16,ENC_NA);
4710                                         curr_offset+=16;
4711                                         curr_len-=16;
4712                                         pf_length-=32;
4713                                         break;
4714
4715                                 case 0x30:
4716                                         str="Protocol identifier/Next header type";
4717                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_protocol_header,tvb,curr_offset,1,ENC_BIG_ENDIAN);
4718                                         curr_offset+=1;
4719                                         curr_len-=1;
4720                                         pf_length-=1;
4721                                         break;
4722
4723                                 case 0x40:
4724                                         str="Single local port type";
4725                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_port,tvb,curr_offset,2,ENC_BIG_ENDIAN);
4726                                         curr_offset+=2;
4727                                         curr_len-=2;
4728                                         pf_length-=2;
4729                                         break;
4730
4731                                 case 0x41:
4732                                         str="Local port range type";
4733                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_port_low,tvb,curr_offset,2,ENC_BIG_ENDIAN);
4734                                         curr_offset+=2;
4735                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_port_high,tvb,curr_offset,2,ENC_BIG_ENDIAN);
4736                                         curr_offset+=2;
4737                                         curr_len-=4;
4738                                         pf_length-=4;
4739                                         break;
4740
4741                                 case 0x50:
4742                                         str="Single remote port type";
4743                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_port,tvb,curr_offset,2,ENC_BIG_ENDIAN);
4744                                         curr_offset+=2;
4745                                         curr_len-=2;
4746                                         pf_length-=2;
4747                                         break;
4748
4749                                 case 0x51:
4750                                         str="Remote port range type";
4751                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_port_low,tvb,curr_offset,2,ENC_BIG_ENDIAN);
4752                                         curr_offset+=2;
4753                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_port_high,tvb,curr_offset,2,ENC_BIG_ENDIAN);
4754                                         curr_offset+=2;
4755                                         curr_len-=4;
4756                                         pf_length-=4;
4757                                         break;
4758
4759                                 case 0x60:
4760                                         str="Security parameter index type";
4761                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_security,tvb,curr_offset,4,ENC_BIG_ENDIAN);
4762                                         curr_offset+=4;
4763                                         curr_len-=4;
4764                                         pf_length-=4;
4765                                         break;
4766
4767
4768                                 case 0x70:
4769                                         str="Type of service/Traffic class type";
4770                                         proto_tree_add_item(comp_tree,hf_gsm_a_qos_traffic_cls,tvb,curr_offset,1,ENC_BIG_ENDIAN);
4771                                         curr_offset++;
4772                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_traffic_mask,tvb,curr_offset,1,ENC_BIG_ENDIAN);
4773                                         curr_offset++;
4774                                         curr_len-=2;
4775                                         pf_length-=2;
4776                                         break;
4777
4778                                 case 0x80:
4779                                         str="Flow label type";
4780                                         proto_tree_add_bits_item(comp_tree, hf_gsm_a_spare_bits, tvb, (curr_offset<<3), 4, ENC_BIG_ENDIAN);
4781                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_flow_label_type,tvb,curr_offset,3,ENC_BIG_ENDIAN);
4782                                         curr_offset+=3;
4783                                         curr_len-=3;
4784                                         pf_length-=3;
4785                                         break;
4786
4787                                 default:
4788                                         str="not specified";
4789                                         curr_offset+=pf_length;
4790                                         curr_len-=pf_length;
4791                                         pf_length=0;
4792                                 }
4793                                 proto_item_append_text(tf, "%s (%u)", str, pack_component_type);
4794                         }
4795                         count++;
4796                 }
4797         }
4798
4799         /* The parameters list contains a variable number of parameters that might need to be
4800          * transferred in addition to the packet filters. If the parameters list is included, the E
4801          * bit is set to 1; otherwise, the E bit is set to 0.
4802          */
4803         if ((e_bit == 1) && curr_len) {
4804                 count = 0;
4805                 while (curr_len) {
4806                         pf_length = tvb_get_guint8(tvb, curr_offset+1);
4807                         tf = proto_tree_add_text(tree, tvb, curr_offset, pf_length+2, "Parameter %d" ,count);
4808                         tf_tree = proto_item_add_subtree(tf, ett_sm_tft );
4809                         param = tvb_get_guint8(tvb, curr_offset);
4810                         proto_tree_add_item(tf_tree, hf_gsm_a_tft_param_id, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4811                         curr_offset += 2;
4812                         curr_len -= 2;
4813                         switch (param) {
4814                         case 0x01:
4815                                 proto_tree_add_text(tf_tree, tvb, curr_offset, pf_length, "Authorization token value: 0x%s",
4816                                                 tvb_bytes_to_str(tvb, curr_offset, pf_length));
4817                                 break;
4818
4819                         case 0x02:
4820                                 proto_tree_add_text(tf_tree, tvb, curr_offset, 2, "Media Component number value: 0x%x",
4821                                                 tvb_get_bits16(tvb, curr_offset<<3, 16, ENC_BIG_ENDIAN));
4822                                 proto_tree_add_text(tf_tree, tvb, curr_offset+2, 2, "IP flow number: 0x%x",
4823                                                 tvb_get_bits16(tvb, (curr_offset+2)<<3, 16, ENC_BIG_ENDIAN));
4824                                 break;
4825
4826                         case 0x03:
4827                                 for (i = 0; i < pf_length; i++) {
4828                                         proto_tree_add_text(tf_tree, tvb, curr_offset+i, 1, "Packet filter identifier %d: %d",
4829                                                     i, tvb_get_guint8(tvb, curr_offset+i));
4830                                 }
4831                                 break;
4832
4833                         default:
4834                                 proto_tree_add_text(tf_tree, tvb, curr_offset, pf_length, "Parameter content: 0x%s",
4835                                                     tvb_bytes_to_str(tvb, curr_offset, pf_length));
4836                                 break;
4837                         }
4838                         curr_offset += pf_length;
4839                         curr_len -= pf_length;
4840                         count++;
4841                 }
4842         }
4843
4844         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
4845
4846         return(len);
4847 }
4848
4849 /*
4850  * [9] 10.5.6.13 Temporary Mobile Group Identity (TMGI)
4851  */
4852 static guint16
4853 de_sm_tmgi(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4854 {
4855         guint32 curr_offset;
4856
4857         curr_offset = offset;
4858
4859         proto_tree_add_item(tree, hf_gsm_a_sm_tmgi, tvb, curr_offset, 3, ENC_BIG_ENDIAN);
4860         curr_offset += 3;
4861
4862         NO_MORE_DATA_CHECK(len);
4863         curr_offset = dissect_e212_mcc_mnc(tvb, pinfo, tree, curr_offset, TRUE);
4864
4865         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
4866
4867         return(curr_offset - offset);
4868 }
4869
4870 /*
4871  * [9] 10.5.6.14 MBMS bearer capabilities
4872  */
4873 static guint16
4874 de_sm_mbms_bearer_cap(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4875 {
4876         guint32 curr_offset, temp32;
4877         guint8 oct;
4878         const gchar *str;
4879
4880         curr_offset = offset;
4881
4882         oct = tvb_get_guint8(tvb, curr_offset);
4883
4884         switch (oct)
4885         {
4886                 case 0x00: str="Subscribed maximum bit rate for downlink/reserved"; break;
4887                 case 0xff: str="0 kbps"; break;
4888                 default: str = ep_strdup_printf("%u kbps", qos_calc_bitrate(oct));
4889         }
4890
4891         proto_tree_add_uint_format_value(tree, hf_gsm_a_qos_max_bitrate_downl, tvb,
4892                 curr_offset, 1, oct, "%s (%u)", str, oct);
4893         curr_offset+= 1;
4894
4895         NO_MORE_DATA_CHECK(len);
4896
4897         oct = tvb_get_guint8(tvb, curr_offset);
4898
4899         if (oct == 0x00)
4900                 str = "Use the value indicated by the Maximum bit rate for downlink";
4901         else
4902         {
4903                 temp32 = qos_calc_ext_bitrate(oct);
4904                 if (temp32 % 1000 == 0)
4905                         str = ep_strdup_printf("%u Mbps", temp32 / 1000);
4906                 else
4907                         str = ep_strdup_printf("%u kbps", temp32);
4908         }
4909         proto_tree_add_uint_format_value(tree, hf_gsm_a_qos_max_bitrate_downl_ext, tvb,
4910                 curr_offset, 1, oct, "%s (%u)", str, oct);
4911
4912         curr_offset+= 1;
4913
4914         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
4915
4916         return(curr_offset - offset);
4917 }
4918
4919 /*
4920  * [9] 10.5.6.15 MBMS protocol configuration options
4921  */
4922 static guint16
4923 de_sm_mbms_prot_conf_opt(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4924 {
4925         guint32 curr_offset;
4926
4927         curr_offset = offset;
4928         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (curr_offset<<3), 8, ENC_BIG_ENDIAN);
4929         curr_offset++;
4930
4931         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
4932
4933         return(curr_offset - offset);
4934 }
4935
4936 /*
4937  * [9] 10.5.6.16 Enhanced network service access point identifier
4938  */
4939 static guint16
4940 de_sm_enh_nsapi(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
4941 {
4942         guint8  oct;
4943         const gchar *str;
4944
4945         oct = tvb_get_guint8(tvb, offset);
4946
4947         if(oct < 0x80)
4948                 str = "Reserved";
4949         else if (oct < 0xff)
4950                         str = ep_strdup_printf("NSAPI %u for Multimedia Broadcast/Multicast Service (MBMS) Multicast mode", oct);
4951                 else
4952                         str = "Reserved for use by lower layers in the p2p radio bearer allocation message for MBMS Broadcast mode";
4953
4954
4955         proto_tree_add_uint_format_value(tree, hf_gsm_a_sm_enh_nsapi, tvb,
4956                 offset, 1, oct, "%s (%u)", str, oct);
4957
4958         /* no length check possible */
4959         return(1);
4960 }
4961
4962 /*
4963  * [9] 10.5.6.17 Request type
4964  */
4965 static const value_string gsm_a_sm_req_type_vals[] = {
4966         { 0x01, "Initial request" },
4967         { 0x02, "Handover" },
4968         { 0x03, "Unused. If received, the network shall interpret this as \"Initial request\"." },
4969         { 0, NULL }
4970 };
4971
4972 static guint16
4973 de_sm_req_type(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
4974 {
4975         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (offset<<3) + 4, 1, ENC_BIG_ENDIAN);
4976         proto_tree_add_item(tree, hf_gsm_a_sm_req_type, tvb, offset, 1, ENC_BIG_ENDIAN);
4977
4978         /* no length check possible */
4979         return(1);
4980 }
4981
4982 /*
4983  * [9] 10.5.6.18 Notification indicator
4984  */
4985 static const value_string gsm_a_sm_notif_ind_vals[] = {
4986         { 0x0,  "Reserved"},
4987         { 0x1,  "SRVCC handover cancelled, IMS session re-establishment required"},
4988         { 0, NULL }
4989 };
4990
4991 static guint16
4992 de_sm_notif_ind(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
4993 {
4994         guint32 curr_offset;
4995
4996         curr_offset = offset;
4997
4998         proto_tree_add_item(tree, hf_gsm_a_sm_notif_ind, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4999
5000         return(len);
5001 }
5002
5003
5004 guint16 (*gm_elem_fcn[])(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string, int string_len) = {
5005         /* GPRS Mobility Management Information Elements 10.5.5 */
5006         de_gmm_attach_res,      /* Attach Result */
5007         de_gmm_attach_type,     /* Attach Type */
5008         de_gmm_ciph_alg,        /* Cipher Algorithm */
5009         de_gmm_tmsi_stat,       /* TMSI Status */
5010         de_gmm_detach_type,     /* Detach Type */
5011         de_gmm_drx_param,       /* DRX Parameter */
5012         de_gmm_ftostby,         /* Force to Standby */
5013         de_gmm_ftostby_h,       /* Force to Standby - Info is in the high nibble */
5014         de_gmm_ptmsi_sig,       /* P-TMSI Signature */
5015         de_gmm_ptmsi_sig2,      /* P-TMSI Signature 2 */
5016         de_gmm_ident_type2,     /* Identity Type 2 */
5017         de_gmm_imeisv_req,      /* IMEISV Request */
5018         de_gmm_rec_npdu_lst,    /* Receive N-PDU Numbers List */
5019         de_gmm_ms_net_cap,      /* MS Network Capability */
5020         de_gmm_ms_radio_acc_cap,/* MS Radio Access Capability */
5021         de_gmm_cause,           /* GMM Cause */
5022         de_gmm_rai,             /* Routing Area Identification */
5023         de_gmm_rai2,    /* Routing Area Identification 2 */
5024         de_gmm_update_res,      /* Update Result */
5025         de_gmm_update_type,     /* Update Type */
5026         de_gmm_ac_ref_nr,       /* A&C Reference Number */
5027         de_gmm_ac_ref_nr_h,     /* A&C Reference Numer - Info is in the high nibble */
5028         de_gmm_service_type,    /* Service Type */
5029         NULL /* no associated data */,  /* Cell Notification */
5030         de_gmm_ps_lcs_cap,      /* PS LCS Capability */
5031         de_gmm_net_feat_supp,   /* Network Feature Support */
5032         de_gmm_rat_info_container, /* Inter RAT information container */
5033         de_gmm_req_ms_info, /* Requested MS information */
5034     NULL, /* UE network capability */
5035     de_gmm_eutran_irat_info_container, /* E-UTRAN inter RAT information container */
5036     de_gmm_voice_domain_pref, /* Voice domain preference and UE's usage setting */
5037         /* Session Management Information Elements 10.5.6 */
5038         de_sm_apn,              /* Access Point Name */
5039         de_sm_nsapi,            /* Network Service Access Point Identifier */
5040         de_sm_pco,              /* Protocol Configuration Options */
5041         de_sm_pdp_addr,         /* Packet Data Protocol Address */
5042         de_sm_qos,              /* Quality Of Service */
5043         de_sm_cause,            /* SM Cause */
5044         de_sm_cause_2,          /* SM Cause 2 */
5045         de_sm_linked_ti,        /* Linked TI */
5046         de_sm_sapi,             /* LLC Service Access Point Identifier */
5047         de_sm_tear_down,        /* Tear Down Indicator */
5048         de_sm_pflow_id,         /* Packet Flow Identifier */
5049         de_sm_tflow_temp,       /* Traffic Flow Template */
5050         de_sm_tmgi,             /* Temporary Mobile Group Identity (TMGI) */
5051         de_sm_mbms_bearer_cap,  /* MBMS bearer capabilities */
5052         de_sm_mbms_prot_conf_opt,       /* MBMS protocol configuration options */
5053         de_sm_enh_nsapi,        /* Enhanced network service access point identifier */
5054         de_sm_req_type,         /* Request type */
5055         de_sm_notif_ind,        /* Notification indicator */
5056         /* GPRS Common Information Elements 10.5.7 */
5057         de_gc_context_stat,     /* PDP Context Status */
5058         de_gc_radio_prio,       /* Radio Priority */
5059         de_gc_timer,            /* GPRS Timer */
5060         de_gc_timer2,           /* GPRS Timer 2 */
5061         de_gc_radio_prio2,      /* Radio Priority 2 */
5062         de_gc_mbms_context_stat,/* 10.5.7.6 MBMS context status */
5063         de_gc_uplink_data_stat, /* 10.5.7.7 Uplink data status */
5064         NULL,   /* NONE */
5065 };
5066
5067 /* MESSAGE FUNCTIONS */
5068
5069 /*
5070  * [7] 9.4.1
5071  */
5072 static void
5073 dtap_gmm_attach_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5074 {
5075         guint32 curr_offset;
5076         guint32 consumed;
5077         guint   curr_len;
5078
5079         curr_offset = offset;
5080         curr_len = len;
5081
5082         pinfo->p2p_dir = P2P_DIR_RECV;
5083
5084         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_MS_NET_CAP, NULL);
5085
5086         /* Included in attach type
5087
5088         ELEM_MAND_V(GSM_A_PDU_TYPE_COMMON, DE_CIPH_KEY_SEQ_NUM, NULL);
5089         curr_offset--;
5090         curr_len++;
5091         */
5092
5093         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_ATTACH_TYPE, NULL);
5094
5095         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_DRX_PARAM, NULL);
5096
5097         ELEM_MAND_LV(GSM_A_PDU_TYPE_COMMON, DE_MID , NULL);
5098
5099         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_RAI, " - Old routing area identification");
5100
5101         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_MS_RAD_ACC_CAP , NULL);
5102
5103         ELEM_OPT_TV( 0x19 , GSM_A_PDU_TYPE_GM, DE_P_TMSI_SIG, " - Old P-TMSI Signature");
5104
5105         ELEM_OPT_TV( 0x17 , GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER , " - Ready Timer" );
5106
5107         ELEM_OPT_TV_SHORT( 0x90 , GSM_A_PDU_TYPE_GM, DE_TMSI_STAT , NULL);
5108
5109         ELEM_OPT_TLV( 0x33 , GSM_A_PDU_TYPE_GM, DE_PS_LCS_CAP , NULL);
5110
5111         ELEM_OPT_TLV(0x11, GSM_A_PDU_TYPE_COMMON, DE_MS_CM_2, NULL);
5112
5113         ELEM_OPT_TLV(0x20, GSM_A_PDU_TYPE_COMMON, DE_MS_CM_3, NULL);
5114
5115         ELEM_OPT_TLV(0x40, GSM_A_PDU_TYPE_DTAP, DE_SUP_CODEC_LIST, NULL);
5116
5117         ELEM_OPT_TLV(0x58, NAS_PDU_TYPE_EMM, DE_EMM_UE_NET_CAP, NULL);
5118
5119         ELEM_OPT_TLV(0x1A, GSM_A_PDU_TYPE_COMMON, DE_MID, " - Additional mobile identity");
5120
5121         ELEM_OPT_TLV(0x1B, GSM_A_PDU_TYPE_GM, DE_RAI_2, " - Additional old routing area identification");
5122
5123         ELEM_OPT_TLV(0x5D, GSM_A_PDU_TYPE_GM, DE_VOICE_DOMAIN_PREF, NULL);
5124
5125         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5126 }
5127
5128 /*
5129  * [7] 9.4.2
5130  */
5131 static void
5132 dtap_gmm_attach_acc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5133 {
5134         guint32 curr_offset;
5135         guint32 consumed;
5136         guint   curr_len;
5137
5138         curr_offset = offset;
5139         curr_len = len;
5140
5141         pinfo->p2p_dir = P2P_DIR_SENT;
5142
5143         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_FORCE_TO_STAND_H, NULL);
5144         curr_len++;
5145         curr_offset--;
5146
5147         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_ATTACH_RES, NULL);
5148
5149         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER, NULL);
5150
5151         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_RAD_PRIO_2, " - Radio priority for TOM8");
5152         curr_len++;
5153         curr_offset--;
5154
5155         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_RAD_PRIO, " - Radio priority for SMS");
5156
5157         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_RAI, NULL);
5158
5159         ELEM_OPT_TV( 0x19 , GSM_A_PDU_TYPE_GM, DE_P_TMSI_SIG, NULL);
5160
5161         ELEM_OPT_TV( 0x17 , GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER , " - Negotiated Ready Timer" );
5162
5163         ELEM_OPT_TLV( 0x18 , GSM_A_PDU_TYPE_COMMON, DE_MID , " - Allocated P-TMSI" );
5164
5165         ELEM_OPT_TLV( 0x23 , GSM_A_PDU_TYPE_COMMON, DE_MID , NULL);
5166
5167         ELEM_OPT_TV( 0x25 , GSM_A_PDU_TYPE_GM, DE_GMM_CAUSE , NULL);
5168
5169         ELEM_OPT_TLV( 0x2A , GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER_2 , " - T3302" );
5170
5171         ELEM_OPT_T( 0x8C , GSM_A_PDU_TYPE_GM, DE_CELL_NOT , NULL);
5172
5173         ELEM_OPT_TLV( 0x4A , GSM_A_PDU_TYPE_COMMON, DE_PLMN_LIST , NULL);
5174
5175         ELEM_OPT_TV_SHORT( 0xB0 , GSM_A_PDU_TYPE_GM, DE_NET_FEAT_SUP , NULL);
5176
5177         ELEM_OPT_TLV( 0x34 , GSM_A_PDU_TYPE_DTAP, DE_EMERGENCY_NUM_LIST , NULL);
5178
5179         ELEM_OPT_TV_SHORT( 0xA0 , GSM_A_PDU_TYPE_GM , DE_REQ_MS_INFO , NULL);
5180
5181         ELEM_OPT_TLV( 0x37 , GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER_2 , " - T3319" );
5182
5183         ELEM_OPT_TLV( 0x38 , GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER_2 , " - T3323" );
5184
5185         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5186 }
5187
5188 /*
5189  * [7] 9.4.3
5190  */
5191 static void
5192 dtap_gmm_attach_com(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5193 {
5194
5195         guint32 curr_offset;
5196         guint32 consumed;
5197         guint   curr_len;
5198
5199         curr_offset = offset;
5200         curr_len = len;
5201
5202         pinfo->p2p_dir = P2P_DIR_RECV;
5203
5204         ELEM_OPT_TLV(0x27, GSM_A_PDU_TYPE_GM, DE_RAT_INFO_CONTAINER, " - Inter RAT handover information");
5205
5206         ELEM_OPT_TLV(0x2B, GSM_A_PDU_TYPE_GM, DE_EUTRAN_IRAT_INFO_CONTAINER, " - E-UTRAN inter RAT handover information");
5207
5208         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5209 }
5210
5211 /*
5212  * [7] 9.4.4
5213  */
5214 static void
5215 dtap_gmm_attach_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5216 {
5217         guint32 curr_offset;
5218         guint32 consumed;
5219         guint   curr_len;
5220
5221         curr_offset = offset;
5222         curr_len = len;
5223
5224         pinfo->p2p_dir = P2P_DIR_SENT;
5225
5226         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_GMM_CAUSE, NULL);
5227
5228         ELEM_OPT_TLV( 0x2A , GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER_2 , " - T3302" );
5229
5230         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5231 }
5232
5233 /*
5234  * [7] 9.4.5
5235  */
5236 static void
5237 dtap_gmm_detach_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5238 {
5239         guint32 curr_offset;
5240         guint32 consumed;
5241         guint   curr_len;
5242
5243         curr_offset = offset;
5244         curr_len = len;
5245
5246         pinfo->p2p_dir = P2P_DIR_SENT;
5247
5248         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_FORCE_TO_STAND_H, NULL);
5249         /* Force to standy might be wrong - To decode it correct, we need the direction */
5250         curr_len++;
5251         curr_offset--;
5252
5253         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_DETACH_TYPE, NULL);
5254
5255         ELEM_OPT_TV( 0x25 , GSM_A_PDU_TYPE_GM, DE_GMM_CAUSE , NULL);
5256
5257         ELEM_OPT_TLV( 0x18 , GSM_A_PDU_TYPE_COMMON, DE_MID , " - P-TMSI" );
5258
5259         ELEM_OPT_TLV( 0x19 , GSM_A_PDU_TYPE_GM, DE_P_TMSI_SIG_2 , NULL);
5260
5261         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5262 }
5263
5264 /*
5265  * [7] 9.4.6
5266  */
5267 static void
5268 dtap_gmm_detach_acc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5269 {
5270         guint32 curr_offset;
5271         guint32 consumed;
5272         guint   curr_len;
5273
5274         curr_offset = offset;
5275         curr_len = len;
5276
5277         pinfo->p2p_dir = P2P_DIR_RECV;
5278
5279         if ( curr_len != 0 )
5280         {
5281                 ELEM_MAND_V(GSM_A_PDU_TYPE_COMMON, DE_SPARE_NIBBLE, NULL);
5282                 curr_len++;
5283                 curr_offset--;
5284
5285                 ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_FORCE_TO_STAND, NULL);
5286         }
5287
5288         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5289 }
5290
5291 /*
5292  * [7] 9.4.7
5293  */
5294 static void
5295 dtap_gmm_ptmsi_realloc_cmd(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5296 {
5297         guint32 curr_offset;
5298         guint32 consumed;
5299         guint   curr_len;
5300
5301         curr_offset = offset;
5302         curr_len = len;
5303
5304         pinfo->p2p_dir = P2P_DIR_SENT;
5305
5306         ELEM_MAND_LV(GSM_A_PDU_TYPE_COMMON, DE_MID , " - Allocated P-TMSI" );
5307
5308         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_RAI, NULL);
5309
5310         ELEM_MAND_V(GSM_A_PDU_TYPE_COMMON, DE_SPARE_NIBBLE, NULL);
5311         curr_len++;
5312         curr_offset--;
5313
5314         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_FORCE_TO_STAND, NULL);
5315
5316         ELEM_OPT_TV( 0x19 , GSM_A_PDU_TYPE_GM, DE_P_TMSI_SIG , " - P-TMSI Signature" );
5317
5318         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5319 }
5320
5321 /*
5322  * [7] 9.4.8
5323  */
5324 static void
5325 dtap_gmm_ptmsi_realloc_com(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5326 {
5327         guint32 curr_offset;
5328 /*    guint32   consumed; */
5329         guint   curr_len;
5330
5331         curr_offset = offset;
5332         curr_len = len;
5333
5334         pinfo->p2p_dir = P2P_DIR_RECV;
5335
5336         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5337 }
5338
5339 /*
5340  * [7] 9.4.9
5341  */
5342 static void
5343 dtap_gmm_auth_ciph_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5344 {
5345         guint32 curr_offset;
5346         guint32 consumed;
5347         guint   curr_len;
5348         guint8  oct;
5349
5350         curr_offset = offset;
5351         curr_len = len;
5352
5353         pinfo->p2p_dir = P2P_DIR_SENT;
5354
5355         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_IMEISV_REQ, NULL);
5356         curr_offset--;
5357         curr_len++;
5358
5359         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_CIPH_ALG, NULL);
5360
5361         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_AC_REF_NUM_H, NULL);
5362         curr_offset--;
5363         curr_len++;
5364
5365         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_FORCE_TO_STAND, NULL);
5366
5367         ELEM_OPT_TV( 0x21 , GSM_A_PDU_TYPE_DTAP, DE_AUTH_PARAM_RAND , NULL);
5368
5369 #if 0
5370         ELEM_OPT_TV_SHORT( 0x08 , GSM_A_PDU_TYPE_COMMON, DE_CIPH_KEY_SEQ_NUM , NULL);
5371 #else
5372         if ( curr_len > 0 )
5373         {
5374                 oct = tvb_get_guint8(tvb, curr_offset);
5375                 if (( oct & 0xf0 ) == 0x80 )
5376                 {
5377                         /* The ciphering key sequence number is added here */
5378                         proto_tree_add_text(tree,
5379                                 tvb, curr_offset, 1,
5380                                 "Ciphering key sequence number: 0x%02x (%u)",
5381                                 oct&7,
5382                                 oct&7);
5383                         curr_offset++;
5384                         curr_len--;
5385                 }
5386         }
5387 #endif
5388
5389         if ( curr_len == 0  )
5390         {
5391                 EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5392         return;
5393         }
5394
5395         ELEM_OPT_TLV( 0x28 , GSM_A_PDU_TYPE_DTAP, DE_AUTH_PARAM_AUTN , NULL);
5396
5397         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5398 }
5399
5400 /*
5401  * [7] 9.4.10
5402  */
5403 static void
5404 dtap_gmm_auth_ciph_resp(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5405 {
5406         guint32 curr_offset;
5407         guint32 consumed;
5408         guint   curr_len;
5409
5410         curr_offset = offset;
5411         curr_len = len;
5412
5413         pinfo->p2p_dir = P2P_DIR_RECV;
5414
5415         ELEM_MAND_V(GSM_A_PDU_TYPE_COMMON, DE_SPARE_NIBBLE, NULL);
5416         curr_offset--;
5417         curr_len++;
5418
5419         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_AC_REF_NUM, NULL);
5420
5421         ELEM_OPT_TV( 0x22 , GSM_A_PDU_TYPE_DTAP, DE_AUTH_RESP_PARAM , NULL);
5422
5423         ELEM_OPT_TLV( 0x23 , GSM_A_PDU_TYPE_COMMON, DE_MID , " - IMEISV" );
5424
5425         ELEM_OPT_TLV( 0x29 , GSM_A_PDU_TYPE_DTAP, DE_AUTH_RESP_PARAM_EXT , NULL);
5426
5427         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5428 }
5429
5430 /*
5431  * [7] 9.4.11
5432  */
5433 static void
5434 dtap_gmm_auth_ciph_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5435 {
5436         guint32 curr_offset;
5437         guint   curr_len;
5438
5439         curr_offset = offset;
5440         curr_len = len;
5441
5442         pinfo->p2p_dir = P2P_DIR_SENT;
5443
5444         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5445 }
5446
5447 /*
5448  * [7] 9.4.10a
5449  */
5450 static void
5451 dtap_gmm_auth_ciph_fail(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5452 {
5453         guint32 curr_offset;
5454         guint32 consumed;
5455         guint   curr_len;
5456
5457         curr_offset = offset;
5458         curr_len = len;
5459
5460         pinfo->p2p_dir = P2P_DIR_RECV;
5461
5462         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_GMM_CAUSE, NULL);
5463
5464         ELEM_OPT_TLV( 0x30 , GSM_A_PDU_TYPE_DTAP, DE_AUTH_FAIL_PARAM , NULL);
5465
5466         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5467 }
5468
5469 /*
5470  * [7] 9.4.12
5471  */
5472 static void
5473 dtap_gmm_ident_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5474 {
5475         guint32 curr_offset;
5476         guint   curr_len;
5477
5478         curr_offset = offset;
5479         curr_len = len;
5480
5481         pinfo->p2p_dir = P2P_DIR_SENT;
5482
5483 /*  If the half octect that are about to get decoded is the LAST in the octetstream, the macro will call return BEFORE we get a chance to fix the index. The end result will be that the first half-octet will be decoded but not the last. */
5484 #if 0
5485         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_ID_TYPE_2, NULL);
5486         curr_offset--;
5487         curr_len++;
5488         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_FORCE_TO_STAND_H, NULL);
5489 #endif
5490
5491         elem_v(tvb, tree, pinfo, GSM_A_PDU_TYPE_GM, DE_FORCE_TO_STAND_H, curr_offset, NULL);
5492         elem_v(tvb, tree, pinfo, GSM_A_PDU_TYPE_GM, DE_ID_TYPE_2, curr_offset, NULL);
5493
5494         curr_offset+=1;
5495         curr_len-=1;
5496
5497         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5498 }
5499
5500 /*
5501  * [7] 9.4.13
5502  */
5503 static void
5504 dtap_gmm_ident_res(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5505 {
5506         guint32 curr_offset;
5507         guint32 consumed;
5508         guint   curr_len;
5509
5510         curr_offset = offset;
5511         curr_len = len;
5512
5513         pinfo->p2p_dir = P2P_DIR_RECV;
5514
5515         ELEM_MAND_LV(GSM_A_PDU_TYPE_COMMON, DE_MID , NULL);
5516
5517         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5518 }
5519
5520 /*
5521  * [7] 9.4.14
5522  */
5523 static void
5524 dtap_gmm_rau_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5525 {
5526         guint32 curr_offset;
5527         guint32 consumed;
5528         guint   curr_len;
5529
5530         curr_offset = offset;
5531         curr_len = len;
5532
5533         pinfo->p2p_dir = P2P_DIR_RECV;
5534
5535         /* is included in update type
5536         ELEM_MAND_V(GSM_A_PDU_TYPE_COMMON, DE_CIPH_KEY_SEQ_NUM, NULL);
5537         curr_offset--;
5538         curr_len++;
5539         */
5540
5541         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_UPD_TYPE, NULL);
5542
5543         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_RAI, " - Old routing area identification");
5544
5545         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_MS_RAD_ACC_CAP , NULL);
5546
5547         ELEM_OPT_TV( 0x19 , GSM_A_PDU_TYPE_GM, DE_P_TMSI_SIG , " - Old P-TMSI Signature" );
5548
5549         ELEM_OPT_TV( 0x17 , GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER , " - Requested Ready Timer" );
5550
5551         ELEM_OPT_TV( 0x27 , GSM_A_PDU_TYPE_GM, DE_DRX_PARAM , NULL);
5552
5553         ELEM_OPT_TV_SHORT( 0x90 , GSM_A_PDU_TYPE_GM, DE_TMSI_STAT , NULL);
5554
5555         ELEM_OPT_TLV( 0x18 , GSM_A_PDU_TYPE_COMMON, DE_MID , " - P-TMSI" );
5556
5557         ELEM_OPT_TLV( 0x31 , GSM_A_PDU_TYPE_GM, DE_MS_NET_CAP , NULL);
5558
5559         ELEM_OPT_TLV( 0x32 , GSM_A_PDU_TYPE_GM, DE_PDP_CONTEXT_STAT , NULL);
5560
5561         ELEM_OPT_TLV( 0x33 , GSM_A_PDU_TYPE_GM, DE_PS_LCS_CAP , NULL);
5562
5563         ELEM_OPT_TLV(0x35, GSM_A_PDU_TYPE_GM, DE_MBMS_CTX_STATUS, NULL);
5564
5565         ELEM_OPT_TLV(0x58, NAS_PDU_TYPE_EMM, DE_EMM_UE_NET_CAP, NULL);
5566
5567         ELEM_OPT_TLV(0x1A, GSM_A_PDU_TYPE_COMMON, DE_MID, " - Additional mobile identity");
5568
5569         ELEM_OPT_TLV(0x1B, GSM_A_PDU_TYPE_GM, DE_RAI_2, " - Additional old routing area identification");
5570
5571         ELEM_OPT_TLV(0x11, GSM_A_PDU_TYPE_COMMON, DE_MS_CM_2, NULL);
5572
5573         ELEM_OPT_TLV(0x20, GSM_A_PDU_TYPE_COMMON, DE_MS_CM_3, NULL);
5574
5575         ELEM_OPT_TLV(0x40, GSM_A_PDU_TYPE_DTAP, DE_SUP_CODEC_LIST, NULL);
5576
5577         ELEM_OPT_TLV(0x5D, GSM_A_PDU_TYPE_GM, DE_VOICE_DOMAIN_PREF, NULL);
5578
5579         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5580 }
5581
5582 /*
5583  * [7] 9.4.15
5584  */
5585 static void
5586 dtap_gmm_rau_acc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5587 {
5588         guint32 curr_offset;
5589         guint32 consumed;
5590         guint   curr_len;
5591
5592         curr_offset = offset;
5593         curr_len = len;
5594
5595         pinfo->p2p_dir = P2P_DIR_SENT;
5596
5597         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_UPD_RES, NULL);
5598         curr_offset--;
5599         curr_len++;
5600
5601         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_FORCE_TO_STAND, NULL);
5602
5603         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER, " - Periodic RA update timer");
5604
5605         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_RAI, NULL);
5606
5607         ELEM_OPT_TV( 0x19 , GSM_A_PDU_TYPE_GM, DE_P_TMSI_SIG , NULL);
5608
5609         ELEM_OPT_TLV( 0x18 , GSM_A_PDU_TYPE_COMMON, DE_MID , " - Allocated P-TMSI");
5610
5611         ELEM_OPT_TLV( 0x23 , GSM_A_PDU_TYPE_COMMON, DE_MID , " - MS identity");
5612
5613         ELEM_OPT_TLV( 0x26 , GSM_A_PDU_TYPE_GM, DE_REC_N_PDU_NUM_LIST , NULL);
5614
5615         ELEM_OPT_TV( 0x17 , GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER , " - Negotiated Ready Timer" );
5616
5617         ELEM_OPT_TV( 0x25 , GSM_A_PDU_TYPE_GM, DE_GMM_CAUSE , NULL);
5618
5619         ELEM_OPT_TLV( 0x2A , GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER_2 , " - T3302" );
5620
5621         ELEM_OPT_T( 0x8C , GSM_A_PDU_TYPE_GM, DE_CELL_NOT , NULL);
5622
5623         ELEM_OPT_TLV( 0x4A , GSM_A_PDU_TYPE_COMMON, DE_PLMN_LIST , NULL);
5624
5625         ELEM_OPT_TLV( 0x32 , GSM_A_PDU_TYPE_GM, DE_PDP_CONTEXT_STAT , NULL);
5626
5627         ELEM_OPT_TV_SHORT ( 0xB0 , GSM_A_PDU_TYPE_GM, DE_NET_FEAT_SUP , NULL);
5628
5629         ELEM_OPT_TLV( 0x34 , GSM_A_PDU_TYPE_DTAP, DE_EMERGENCY_NUM_LIST , NULL);
5630
5631         ELEM_OPT_TLV(0x35 , GSM_A_PDU_TYPE_GM, DE_MBMS_CTX_STATUS , NULL);
5632
5633         ELEM_OPT_TV_SHORT(0xA0 , GSM_A_PDU_TYPE_GM , DE_REQ_MS_INFO , NULL);
5634
5635         ELEM_OPT_TLV(0x37 , GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER_2 , " - T3319");
5636
5637         ELEM_OPT_TLV(0x38 , GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER_2 , " - T3323");
5638
5639         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5640 }
5641
5642 /*
5643  * [7] 9.4.16
5644  */
5645 static void
5646 dtap_gmm_rau_com(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5647 {
5648         guint32 curr_offset;
5649         guint32 consumed;
5650         guint   curr_len;
5651
5652         curr_offset = offset;
5653         curr_len = len;
5654
5655         pinfo->p2p_dir = P2P_DIR_RECV;
5656         /* [7] 10.5.5.11 */
5657         ELEM_OPT_TLV( 0x26 , GSM_A_PDU_TYPE_GM, DE_REC_N_PDU_NUM_LIST , NULL);
5658         /* Inter RAT information container 10.5.5.24 TS 24.008 version 6.8.0 Release 6 */
5659         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_RAT_INFO_CONTAINER , " - Inter RAT handover information");
5660
5661         ELEM_OPT_TLV(0x2B, GSM_A_PDU_TYPE_GM, DE_EUTRAN_IRAT_INFO_CONTAINER, " - E-UTRAN inter RAT handover information");
5662
5663         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5664 }
5665
5666 /*
5667  * [7] 9.4.17
5668  */
5669 static void
5670 dtap_gmm_rau_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5671 {
5672         guint32 curr_offset;
5673         guint32 consumed;
5674         guint   curr_len;
5675
5676         curr_offset = offset;
5677         curr_len = len;
5678
5679         pinfo->p2p_dir = P2P_DIR_SENT;
5680
5681         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_GMM_CAUSE, NULL);
5682
5683         ELEM_MAND_V(GSM_A_PDU_TYPE_COMMON, DE_SPARE_NIBBLE, NULL);
5684         curr_offset--;
5685         curr_len++;
5686
5687         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_FORCE_TO_STAND, NULL);
5688
5689         ELEM_OPT_TLV( 0x26 , GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER_2 , " - T3302" );
5690
5691         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5692 }
5693
5694 /*
5695  * [7] 9.4.18
5696  */
5697 static void
5698 dtap_gmm_status(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5699 {
5700         guint32 curr_offset;
5701         guint32 consumed;
5702         guint   curr_len;
5703
5704         curr_offset = offset;
5705         curr_len = len;
5706
5707         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
5708
5709         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_GMM_CAUSE, NULL);
5710
5711         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5712 }
5713
5714 /*
5715  * [8] 9.4.19 GMM Information
5716  */
5717 static void
5718 dtap_gmm_information(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5719 {
5720         guint32 curr_offset;
5721         guint32 consumed;
5722         guint   curr_len;
5723
5724         curr_offset = offset;
5725         curr_len = len;
5726
5727         pinfo->p2p_dir = P2P_DIR_SENT;
5728
5729         ELEM_OPT_TLV( 0x43 , GSM_A_PDU_TYPE_DTAP, DE_NETWORK_NAME , " - Full Name" );
5730
5731         ELEM_OPT_TLV( 0x45 , GSM_A_PDU_TYPE_DTAP, DE_NETWORK_NAME , " - Short Name" );
5732
5733         ELEM_OPT_TV( 0x46 , GSM_A_PDU_TYPE_DTAP, DE_TIME_ZONE , NULL);
5734
5735         ELEM_OPT_TV( 0x47 , GSM_A_PDU_TYPE_DTAP, DE_TIME_ZONE_TIME , NULL);
5736
5737         ELEM_OPT_TLV( 0x48 , GSM_A_PDU_TYPE_DTAP, DE_LSA_ID , NULL);
5738
5739         ELEM_OPT_TLV( 0x49 , GSM_A_PDU_TYPE_DTAP, DE_DAY_SAVING_TIME , NULL);
5740
5741         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5742 }
5743
5744 /*
5745  * [7] 9.4.20
5746  */
5747 static void
5748 dtap_gmm_service_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5749 {
5750         guint32 curr_offset;
5751         guint32 consumed;
5752         guint   curr_len;
5753
5754         curr_offset = offset;
5755         curr_len = len;
5756
5757         pinfo->p2p_dir = P2P_DIR_RECV;
5758
5759         /* Is included in SRVC TYPE
5760         ELEM_MAND_V(GSM_A_PDU_TYPE_COMMON, DE_CIPH_KEY_SEQ_NUM, NULL);
5761         curr_offset--;
5762         curr_len++;
5763         */
5764
5765         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_SRVC_TYPE, NULL);
5766
5767         /* P-TMSI Mobile station identity 10.5.1.4 M LV 6 */
5768         ELEM_MAND_LV(GSM_A_PDU_TYPE_COMMON, DE_MID, NULL);
5769
5770         ELEM_OPT_TLV( 0x32 , GSM_A_PDU_TYPE_GM, DE_PDP_CONTEXT_STAT , NULL);
5771
5772         /* MBMS context status 10.5.7.6 TLV 2 - 18 */
5773         ELEM_OPT_TLV( 0x35 , GSM_A_PDU_TYPE_GM, DE_MBMS_CTX_STATUS , NULL);
5774
5775         ELEM_OPT_TLV(0x36, GSM_A_PDU_TYPE_GM, DE_UPLINK_DATA_STATUS, NULL);
5776
5777         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5778 }
5779
5780 /*
5781  * [7] 9.4.21
5782  */
5783 static void
5784 dtap_gmm_service_acc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5785 {
5786         guint32 curr_offset;
5787         guint32 consumed;
5788         guint   curr_len;
5789
5790         curr_offset = offset;
5791         curr_len = len;
5792
5793         pinfo->p2p_dir = P2P_DIR_SENT;
5794
5795         ELEM_OPT_TLV( 0x32 , GSM_A_PDU_TYPE_GM, DE_PDP_CONTEXT_STAT , NULL);
5796
5797         /* MBMS context status 10.5.7.6 TLV 2 - 18 */
5798         ELEM_OPT_TLV( 0x35 , GSM_A_PDU_TYPE_GM, DE_MBMS_CTX_STATUS , NULL);
5799
5800         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5801 }
5802
5803 /*
5804  * [7] 9.4.22
5805  */
5806 static void
5807 dtap_gmm_service_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5808 {
5809         guint32 curr_offset;
5810         guint32 consumed;
5811         guint   curr_len;
5812
5813         curr_offset = offset;
5814         curr_len = len;
5815
5816         pinfo->p2p_dir = P2P_DIR_SENT;
5817
5818         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_GMM_CAUSE, NULL);
5819
5820         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5821 }
5822
5823 /*
5824  * [8] 9.5.1 Activate PDP context request
5825  * Direction:                   MS to network
5826  */
5827 static void
5828 dtap_sm_act_pdp_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5829 {
5830         guint32 curr_offset;
5831         guint32 consumed;
5832         guint   curr_len;
5833
5834         curr_offset = offset;
5835         curr_len = len;
5836
5837         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
5838         /* MS to network */
5839         pinfo->link_dir = P2P_DIR_UL;
5840
5841         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_NET_SAPI, " - Requested NSAPI");
5842
5843         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_LLC_SAPI, " - Requested LLC SAPI");
5844
5845         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_QOS , " - Requested QoS" );
5846
5847         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_PD_PRO_ADDR , " - Requested PDP address" );
5848
5849         ELEM_OPT_TLV( 0x28 , GSM_A_PDU_TYPE_GM, DE_ACC_POINT_NAME , NULL);
5850
5851         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL);
5852
5853         ELEM_OPT_TV_SHORT(0xA0, GSM_A_PDU_TYPE_GM, DE_REQ_TYPE, NULL);
5854
5855         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5856 }
5857
5858 /*
5859  * [9] 9.5.2 Activate PDP context accept
5860  * Direction:                   network to MS
5861  */
5862 static void
5863 dtap_sm_act_pdp_acc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5864 {
5865         guint32 curr_offset;
5866         guint32 consumed;
5867         guint   curr_len;
5868
5869         curr_offset = offset;
5870         curr_len = len;
5871
5872         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
5873         /* Network to MS*/
5874         pinfo->link_dir = P2P_DIR_DL;
5875
5876         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_LLC_SAPI, " - Negotiated LLC SAPI");
5877
5878         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_QOS , " - Negotiated QoS" );
5879
5880 #if 0
5881         /* This is done automatically */
5882         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_SPARE, NULL);
5883         curr_offset--;
5884         curr_len++;
5885 #endif
5886
5887         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_RAD_PRIO, NULL);
5888
5889         ELEM_OPT_TLV( 0x2B , GSM_A_PDU_TYPE_GM, DE_PD_PRO_ADDR , " - PDP address");
5890
5891         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL);
5892
5893         ELEM_OPT_TLV( 0x34 , GSM_A_PDU_TYPE_GM, DE_PACKET_FLOW_ID , NULL);
5894
5895         ELEM_OPT_TLV( 0x39 , GSM_A_PDU_TYPE_GM, DE_SM_CAUSE_2, " - SM cause");
5896
5897         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5898 }
5899
5900 /*
5901  * [8] 9.5.3 Activate PDP context reject
5902  * Direction:                   network to MS
5903  */
5904 static void
5905 dtap_sm_act_pdp_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5906 {
5907         guint32 curr_offset;
5908         guint32 consumed;
5909         guint   curr_len;
5910
5911         curr_offset = offset;
5912         curr_len = len;
5913
5914         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
5915         /* Network to MS*/
5916         pinfo->link_dir = P2P_DIR_DL;
5917
5918         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_SM_CAUSE, NULL);
5919
5920         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL);
5921
5922         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5923 }
5924
5925 /*
5926  * [8] 9.5.4 Activate Secondary PDP Context Request
5927  * Direction:                   MS to network
5928  */
5929 static void
5930 dtap_sm_act_sec_pdp_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5931 {
5932         guint32 curr_offset;
5933         guint32 consumed;
5934         guint   curr_len;
5935
5936         curr_offset = offset;
5937         curr_len = len;
5938
5939         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
5940         /* MS to Network */
5941         pinfo->link_dir = P2P_DIR_UL;
5942
5943         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_NET_SAPI, " - Requested NSAPI");
5944
5945         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_LLC_SAPI, " - Requested LLC SAPI");
5946
5947         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_QOS , " - Requested QoS" );
5948
5949         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_LINKED_TI , NULL);
5950
5951         /* 3GPP TS 24.008 version 6.8.0 Release 6, 36 TFT Traffic Flow Template 10.5.6.12 O TLV 3-257 */
5952         ELEM_OPT_TLV( 0x36 , GSM_A_PDU_TYPE_GM, DE_TRAFFIC_FLOW_TEMPLATE , NULL);
5953
5954         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL);
5955
5956         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5957 }
5958
5959 /*
5960  * [7] 9.5.5    Activate Secondary PDP Context Accept
5961  * Direction:                   network to MS
5962  */
5963 static void
5964 dtap_sm_act_sec_pdp_acc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5965 {
5966         guint32 curr_offset;
5967         guint32 consumed;
5968         guint   curr_len;
5969
5970         curr_offset = offset;
5971         curr_len = len;
5972
5973         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
5974         /* Network to MS*/
5975         pinfo->link_dir = P2P_DIR_DL;
5976
5977         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_LLC_SAPI, " - Negotiated LLC SAPI");
5978
5979         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_QOS , " - Negotiated QoS" );
5980
5981         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_RAD_PRIO, NULL);
5982
5983 #if 0
5984         /* This is done automatically */
5985         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_SPARE, NULL);
5986         curr_offset--;
5987         curr_len++;
5988 #endif
5989
5990         ELEM_OPT_TLV( 0x34 , GSM_A_PDU_TYPE_GM, DE_PACKET_FLOW_ID , NULL);
5991
5992         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL);
5993
5994         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5995 }
5996
5997 /*
5998  * [8] 9.5.6 Activate Secondary PDP Context Reject
5999  * Direction:                   network to MS
6000  */
6001 static void
6002 dtap_sm_act_sec_pdp_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
6003 {
6004         guint32 curr_offset;
6005         guint32 consumed;
6006         guint   curr_len;
6007
6008         curr_offset = offset;
6009         curr_len = len;
6010
6011         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
6012         /* Network to MS*/
6013         pinfo->link_dir = P2P_DIR_DL;
6014
6015         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_SM_CAUSE, NULL);
6016
6017         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL);
6018
6019         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
6020 }
6021
6022 /*
6023  * [8] 9.5.7 Request PDP context activation
6024  * Direction:                   network to MS
6025  */
6026 static void
6027 dtap_sm_req_pdp_act(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
6028 {
6029         guint32 curr_offset;
6030         guint32 consumed;
6031         guint   curr_len;
6032
6033         curr_offset = offset;
6034         curr_len = len;
6035
6036         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
6037         /* Network to MS*/
6038         pinfo->link_dir = P2P_DIR_DL;
6039
6040         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_PD_PRO_ADDR , " - Offered PDP address" );
6041
6042         ELEM_OPT_TLV( 0x28 , GSM_A_PDU_TYPE_GM, DE_ACC_POINT_NAME , NULL);
6043
6044         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL);
6045
6046         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
6047 }
6048
6049 /*
6050  * [8] 9.5.8 Request PDP context activation reject
6051  * Direction:                   MS to network
6052  */
6053 static void
6054 dtap_sm_req_pdp_act_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
6055 {
6056         guint32 curr_offset;
6057         guint32 consumed;
6058         guint   curr_len;
6059
6060         curr_offset = offset;
6061         curr_len = len;
6062
6063         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
6064         /* MS to  Network */
6065         pinfo->link_dir = P2P_DIR_UL;
6066
6067         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_SM_CAUSE, NULL);
6068
6069         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL);
6070
6071         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
6072 }
6073
6074 /*
6075  * [8] 9.5.9 Modify PDP context request (Network to MS direction)
6076  * Direction:                   network to MS
6077  */
6078 static void
6079 dtap_sm_mod_pdp_req_net(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
6080 {
6081         guint32 curr_offset;
6082         guint32 consumed;
6083         guint   curr_len;
6084
6085         curr_offset = offset;
6086         curr_len = len;
6087
6088         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
6089         /* Network to MS */
6090         pinfo->link_dir = P2P_DIR_DL;
6091
6092         ELEM_MAND_V(GSM_A_PDU_TYPE_GM,DE_RAD_PRIO, NULL);
6093 #if 0
6094         /* This is done automatically */
6095         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_SPARE, NULL);
6096         curr_offset--;
6097         curr_len++;
6098 #endif
6099
6100         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_LLC_SAPI, " - Requested LLC SAPI");
6101
6102         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_QOS , " - New QoS" );
6103
6104         ELEM_OPT_TLV( 0x2B , GSM_A_PDU_TYPE_GM, DE_PD_PRO_ADDR , " - PDP address");
6105
6106         ELEM_OPT_TLV( 0x34 , GSM_A_PDU_TYPE_GM, DE_PACKET_FLOW_ID , NULL);
6107
6108         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL);
6109
6110         ELEM_OPT_TLV(0x36 , GSM_A_PDU_TYPE_GM, DE_TRAFFIC_FLOW_TEMPLATE , NULL);
6111
6112         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
6113 }
6114
6115 /*
6116  * [8] 9.5.10 Modify PDP context request (MS to network direction)
6117  * Direction:                   MS to network
6118  */
6119 static void
6120 dtap_sm_mod_pdp_req_ms(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
6121 {
6122         guint32 curr_offset;
6123         guint32 consumed;
6124         guint   curr_len;
6125
6126         curr_offset = offset;
6127         curr_len = len;
6128
6129         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
6130         /* MS to Network */
6131         pinfo->link_dir = P2P_DIR_UL;
6132
6133         ELEM_OPT_TV( 0x32 , GSM_A_PDU_TYPE_GM, DE_LLC_SAPI , " - Requested LLC SAPI" );
6134
6135         ELEM_OPT_TLV( 0x30 , GSM_A_PDU_TYPE_GM, DE_QOS , " - Requested new QoS" );
6136
6137         ELEM_OPT_TLV( 0x31 , GSM_A_PDU_TYPE_GM, DE_TRAFFIC_FLOW_TEMPLATE , " - New TFT" );
6138
6139         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL);
6140
6141         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
6142 }
6143
6144 /*
6145  * [8] 9.5.11 Modify PDP context accept (MS to network direction)
6146  * Direction:                   MS to network
6147  */
6148 static void
6149 dtap_sm_mod_pdp_acc_ms(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
6150 {
6151         guint32 curr_offset;
6152         guint32 consumed;
6153         guint   curr_len;
6154
6155         curr_offset = offset;
6156         curr_len = len;
6157
6158         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
6159         /* MS to Network */
6160         pinfo->link_dir = P2P_DIR_UL;
6161
6162         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL);
6163
6164         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
6165 }
6166
6167 /*
6168  * [8] 9.5.12 Modify PDP context accept (Network to MS direction)
6169  * Direction:                   Network to MS
6170  */
6171 static void
6172 dtap_sm_mod_pdp_acc_net(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
6173 {
6174         guint32 curr_offset;
6175         guint32 consumed;
6176         guint   curr_len;
6177
6178         curr_offset = offset;
6179         curr_len = len;
6180
6181         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
6182         /* Network to MS */
6183         pinfo->link_dir = P2P_DIR_DL;
6184
6185         ELEM_OPT_TLV( 0x30 , GSM_A_PDU_TYPE_GM, DE_QOS , " - Negotiated QoS" );
6186
6187         ELEM_OPT_TV( 0x32 , GSM_A_PDU_TYPE_GM, DE_LLC_SAPI , " - Negotiated LLC SAPI" );
6188
6189         ELEM_OPT_TV_SHORT ( 0x80 , GSM_A_PDU_TYPE_GM , DE_RAD_PRIO , " - New radio priority" );
6190
6191         ELEM_OPT_TLV( 0x34 , GSM_A_PDU_TYPE_GM, DE_PACKET_FLOW_ID , NULL);
6192
6193         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL);
6194
6195         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
6196 }
6197
6198 /*
6199  * [8] 9.5.13 Modify PDP Context Reject
6200  * Direction:                   both
6201  */
6202 static void
6203 dtap_sm_mod_pdp_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
6204 {
6205         guint32 curr_offset;
6206         guint32 consumed;
6207         guint   curr_len;
6208
6209         curr_offset = offset;
6210         curr_len = len;
6211
6212         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
6213         /* Network or the MS */
6214         pinfo->link_dir = LINK_DIR_UNKNOWN;
6215
6216
6217         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_SM_CAUSE, NULL);
6218
6219         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL);
6220
6221         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
6222 }
6223
6224 /*
6225  * [8] 9.5.14 Deactivate PDP context request
6226  * Direction:                   both
6227  */
6228 static void
6229 dtap_sm_deact_pdp_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
6230 {
6231         guint32 curr_offset;
6232         guint32 consumed;
6233         guint   curr_len;
6234
6235         curr_offset = offset;
6236         curr_len = len;
6237
6238         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
6239         pinfo->link_dir = LINK_DIR_UNKNOWN;
6240
6241         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_SM_CAUSE, NULL);
6242
6243         ELEM_OPT_TV_SHORT( 0x90 , GSM_A_PDU_TYPE_GM , DE_TEAR_DOWN_IND , NULL);
6244
6245         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL);
6246
6247         /* MBMS context status 10.5.7.6 TLV 2 - 18 */
6248         ELEM_OPT_TLV( 0x35 , GSM_A_PDU_TYPE_GM, DE_MBMS_CTX_STATUS , NULL);
6249
6250         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
6251 }
6252
6253 /*
6254  * [8] 9.5.15 Deactivate PDP context accept
6255  * Direction:                   both
6256  */
6257 static void
6258 dtap_sm_deact_pdp_acc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
6259 {
6260         guint32 curr_offset;
6261         guint32 consumed;
6262         guint   curr_len;
6263
6264         curr_offset = offset;
6265         curr_len = len;
6266
6267         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
6268         pinfo->link_dir = LINK_DIR_UNKNOWN;
6269
6270         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL);
6271
6272         /* MBMS context status 10.5.7.6 TLV 2 - 18 */
6273         ELEM_OPT_TLV( 0x35 , GSM_A_PDU_TYPE_GM, DE_MBMS_CTX_STATUS , NULL);
6274
6275         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
6276 }
6277
6278 /*
6279  * [8] 9.5.15a Request Secondary PDP Context Activation
6280  * Direction:                   network to MS
6281  */
6282 static void
6283 dtap_sm_req_sec_pdp_act(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
6284 {
6285         guint32 curr_offset;
6286         guint32 consumed;
6287         guint   curr_len;
6288
6289         curr_offset = offset;
6290         curr_len = len;
6291
6292         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
6293         pinfo->link_dir = P2P_DIR_DL;
6294
6295         /* Required QoS Quality of service 10.5.6.5 M LV 13-17 */
6296         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_QOS , " - Required QoS");
6297
6298         /* Linked TI Linked TI 10.5.6.7 M LV 2-3 */
6299         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_LINKED_TI , NULL);
6300
6301         /* 36 TFT Traffic Flow Template 10.5.6.12 O TLV 3-257 */
6302         ELEM_OPT_TLV(0x36, GSM_A_PDU_TYPE_GM, DE_TRAFFIC_FLOW_TEMPLATE, NULL);
6303
6304         /* 27 Protocol configuration options Protocol configuration options 10.5.6.3 O TLV 3 \96 253 */
6305         ELEM_OPT_TLV(0x27, GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT, NULL);
6306
6307         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
6308 }
6309
6310 /*
6311  * [8] 9.5.15b Request Secondary PDP Context Activation Reject
6312  * Direction:                   MS to network
6313  */
6314 static void
6315 dtap_sm_req_sec_pdp_act_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
6316 {
6317         guint32 curr_offset;
6318         guint32 consumed;
6319         guint   curr_len;
6320
6321         curr_offset = offset;
6322         curr_len = len;
6323
6324         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
6325         pinfo->link_dir = P2P_DIR_UL;
6326
6327         /* SM cause SM cause 10.5.6.6 M V 1 */
6328         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_SM_CAUSE, NULL);
6329
6330         /* 27 Protocol configuration options Protocol configuration options 10.5.6.3 O TLV 3 \96 253 */
6331         ELEM_OPT_TLV(0x27, GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT, NULL);
6332
6333         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
6334 }
6335
6336 /*
6337  * [8] 9.5.16a Notification
6338  * Direction:                   network to MS
6339  */
6340 static void
6341 dtap_sm_notif(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
6342 {
6343         guint32 curr_offset;
6344         guint32 consumed;
6345         guint   curr_len;
6346
6347         curr_offset = offset;
6348         curr_len = len;
6349
6350         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
6351         pinfo->link_dir = P2P_DIR_DL;
6352
6353         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_SM_NOTIF_IND, NULL);
6354
6355         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
6356 }
6357
6358 /*
6359  * [8] 9.5.21 SM Status
6360  * Direction:                   both
6361  */
6362 static void
6363 dtap_sm_status(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
6364 {
6365         guint32 curr_offset;
6366         guint32 consumed;
6367         guint   curr_len;
6368
6369         curr_offset = offset;
6370         curr_len = len;
6371
6372         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
6373         pinfo->link_dir = LINK_DIR_UNKNOWN;
6374
6375         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_SM_CAUSE, NULL);
6376
6377         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
6378 }
6379
6380 /*
6381  * [9] 9.5.22 Activate MBMS Context Request
6382  * Direction:                   MS to network
6383  */
6384 static void
6385 dtap_sm_act_mbms_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
6386 {
6387         guint32 curr_offset;
6388         guint32 consumed;
6389         guint   curr_len;
6390
6391         curr_offset = offset;
6392         curr_len = len;
6393
6394         pinfo->p2p_dir = P2P_DIR_RECV;
6395
6396         /* Requested MBMS NSAPI Enhanced Network service access point identifier 10.5.6.16 M V */
6397         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_ENH_NSAPI, " - Requested MBMS NSAPI");
6398
6399         /* Requested LLC SAPI LLC service access point identifier 10.5.6.9 M V 1 */
6400         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_LLC_SAPI, " - Requested LLC SAPI");
6401
6402         /* Supported MBMS bearer capabilities MBMS bearer capabilities 10.5.6.14 M LV 2 - 3 */
6403         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_MBMS_BEARER_CAP , NULL );
6404
6405         /* Requested multicast address Packet data protocol address 10.5.6.4 M LV 3 - 19 */
6406         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_PD_PRO_ADDR , " - Requested multicast address" );
6407
6408         /* Access point name Access point name 10.5.6.1 M LV 2 - 101 */
6409         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_ACC_POINT_NAME , NULL );
6410
6411         /* 35 MBMS protocol configuration options MBMS protocol configuration options 10.5.6.15 O TLV 3 - 253 */
6412         ELEM_OPT_TLV( 0x35 , GSM_A_PDU_TYPE_GM, DE_MBMS_PROT_CONF_OPT , NULL);
6413
6414         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
6415 }
6416
6417 /*
6418  * [9] 9.5.23 Activate MBMS Context Accept
6419  * Direction:                   network to MS
6420  */
6421 static void
6422 dtap_sm_act_mbms_acc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
6423 {
6424         guint32 curr_offset;
6425         guint32 consumed;
6426         guint   curr_len;
6427
6428         curr_offset = offset;
6429         curr_len = len;
6430
6431         pinfo->p2p_dir = P2P_DIR_SENT;
6432
6433         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_TMGI, NULL);
6434
6435         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_LLC_SAPI, " - Negotiated LLC SAPI");
6436
6437         ELEM_OPT_TLV( 0x35 , GSM_A_PDU_TYPE_GM, DE_MBMS_PROT_CONF_OPT , NULL);
6438
6439         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
6440 }
6441
6442 /*
6443  * [9] 9.5.24 Activate MBMS Context Reject
6444  * Direction:                   network to MS
6445  */
6446 static void
6447 dtap_sm_act_mbms_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
6448 {
6449         guint32 curr_offset;
6450         guint32 consumed;
6451         guint   curr_len;
6452
6453         curr_offset = offset;
6454         curr_len = len;
6455
6456         pinfo->p2p_dir = P2P_DIR_SENT;
6457
6458         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_SM_CAUSE, NULL);
6459
6460         ELEM_OPT_TLV( 0x35 , GSM_A_PDU_TYPE_GM, DE_MBMS_PROT_CONF_OPT , NULL);
6461
6462         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
6463 }
6464
6465 /*
6466  * [9] 9.5.25 Request MBMS Context Activation
6467  * Direction:                   network to MS
6468  */
6469 static void
6470 dtap_sm_req_mbms_act(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
6471 {
6472         guint32 curr_offset;
6473         guint32 consumed;
6474         guint   curr_len;
6475
6476         curr_offset = offset;
6477         curr_len = len;
6478
6479         pinfo->p2p_dir = P2P_DIR_SENT;
6480
6481         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_NET_SAPI, " - Linked NSAPI");
6482
6483         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_PD_PRO_ADDR , " - Offered multicast address" );
6484
6485         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_ACC_POINT_NAME , NULL );
6486
6487         ELEM_OPT_TLV( 0x35 , GSM_A_PDU_TYPE_GM, DE_MBMS_PROT_CONF_OPT , NULL);
6488
6489         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
6490 }
6491
6492 /*
6493  * [8] 9.5.26 Request MBMS Context Activation Reject
6494  * Direction:                   MS to network
6495  */
6496 static void
6497 dtap_sm_req_mbms_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
6498 {
6499         guint32 curr_offset;
6500         guint32 consumed;
6501         guint   curr_len;
6502
6503         curr_offset = offset;
6504         curr_len = len;
6505
6506         pinfo->p2p_dir = P2P_DIR_RECV;
6507
6508         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_SM_CAUSE, NULL);
6509
6510         ELEM_OPT_TLV( 0x35 , GSM_A_PDU_TYPE_GM, DE_MBMS_PROT_CONF_OPT , NULL);
6511
6512         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
6513 }
6514
6515 #define NUM_GSM_DTAP_MSG_GMM (sizeof(gsm_a_dtap_msg_gmm_strings)/sizeof(value_string))
6516 static gint ett_gsm_dtap_msg_gmm[NUM_GSM_DTAP_MSG_GMM];
6517 static void (*dtap_msg_gmm_fcn[])(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len) = {
6518         dtap_gmm_attach_req,            /* Attach Request */
6519         dtap_gmm_attach_acc,            /* Attach Accept */
6520         dtap_gmm_attach_com,            /* Attach Complete */
6521         dtap_gmm_attach_rej,            /* Attach Reject */
6522         dtap_gmm_detach_req,            /* Detach Request */
6523         dtap_gmm_detach_acc,            /* Detach Accept */
6524         dtap_gmm_rau_req,                       /* Routing Area Update Request */
6525         dtap_gmm_rau_acc,                       /* Routing Area Update Accept */
6526         dtap_gmm_rau_com,                       /* Routing Area Update Complete */
6527         dtap_gmm_rau_rej,                       /* Routing Area Update Reject */
6528         dtap_gmm_service_req,           /* Service Request */
6529         dtap_gmm_service_acc,           /* Service Accept */
6530         dtap_gmm_service_rej,           /* Service Reject */
6531         dtap_gmm_ptmsi_realloc_cmd,     /* P-TMSI Reallocation Command */
6532         dtap_gmm_ptmsi_realloc_com,     /* P-TMSI Reallocation Complete */
6533         dtap_gmm_auth_ciph_req,         /* Authentication and Ciphering Req */
6534         dtap_gmm_auth_ciph_resp,        /* Authentication and Ciphering Resp */
6535         dtap_gmm_auth_ciph_rej,         /* Authentication and Ciphering Rej */
6536         dtap_gmm_auth_ciph_fail,        /* Authentication and Ciphering Failure */
6537         dtap_gmm_ident_req,                     /* Identity Request */
6538         dtap_gmm_ident_res,                     /* Identity Response */
6539         dtap_gmm_status,                        /* GMM Status */
6540         dtap_gmm_information,           /* GMM Information */
6541         NULL,   /* NONE */
6542 };
6543
6544 #define NUM_GSM_DTAP_MSG_SM (sizeof(gsm_a_dtap_msg_sm_strings)/sizeof(value_string))
6545 static gint ett_gsm_dtap_msg_sm[NUM_GSM_DTAP_MSG_SM];
6546 static void (*dtap_msg_sm_fcn[])(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len) = {
6547         dtap_sm_act_pdp_req,            /* Activate PDP Context Request */
6548         dtap_sm_act_pdp_acc,            /* Activate PDP Context Accept */
6549         dtap_sm_act_pdp_rej,            /* Activate PDP Context Reject */
6550         dtap_sm_req_pdp_act,            /* Request PDP Context Activation */
6551         dtap_sm_req_pdp_act_rej,        /* Request PDP Context Activation rej. */
6552         dtap_sm_deact_pdp_req,          /* Deactivate PDP Context Request */
6553         dtap_sm_deact_pdp_acc,          /* Deactivate PDP Context Accept */
6554         dtap_sm_mod_pdp_req_net,        /* Modify PDP Context Request(Network to MS direction) */
6555         dtap_sm_mod_pdp_acc_ms,         /* Modify PDP Context Accept (MS to network direction) */
6556         dtap_sm_mod_pdp_req_ms,         /* Modify PDP Context Request(MS to network direction) */
6557         dtap_sm_mod_pdp_acc_net,        /* Modify PDP Context Accept (Network to MS direction) */
6558         dtap_sm_mod_pdp_rej,            /* Modify PDP Context Reject */
6559         dtap_sm_act_sec_pdp_req,        /* Activate Secondary PDP Context Request */
6560         dtap_sm_act_sec_pdp_acc,        /* Activate Secondary PDP Context Accept */
6561         dtap_sm_act_sec_pdp_rej,        /* Activate Secondary PDP Context Reject */
6562         NULL,                                           /* Reserved: was allocated in earlier phases of the protocol */
6563         NULL,                                           /* Reserved: was allocated in earlier phases of the protocol */
6564         NULL,                                           /* Reserved: was allocated in earlier phases of the protocol */
6565         NULL,                                           /* Reserved: was allocated in earlier phases of the protocol */
6566         NULL,                                           /* Reserved: was allocated in earlier phases of the protocol */
6567         dtap_sm_status,                         /* SM Status */
6568         dtap_sm_act_mbms_req,           /* Activate MBMS Context Request */
6569         dtap_sm_act_mbms_acc,           /* Activate MBMS Context Accept */
6570         dtap_sm_act_mbms_rej,           /* Activate MBMS Context Reject */
6571         dtap_sm_req_mbms_act,           /* Request MBMS Context Activation */
6572         dtap_sm_req_mbms_rej,           /* Request MBMS Context Activation Reject */
6573         dtap_sm_req_sec_pdp_act,        /* Request Secondary PDP Context Activation */
6574         dtap_sm_req_sec_pdp_act_rej,/* Request Secondary PDP Context Activation Reject */
6575         dtap_sm_notif,              /* Notification */
6576         NULL,   /* NONE */
6577 };
6578
6579 void get_gmm_msg_params(guint8 oct, const gchar **msg_str, int *ett_tree, int *hf_idx, msg_fcn *dtap_msg_fcn)
6580 {
6581         gint                    idx;
6582
6583         *msg_str = match_strval_idx((guint32) (oct & DTAP_GMM_IEI_MASK), gsm_a_dtap_msg_gmm_strings, &idx);
6584         *ett_tree = ett_gsm_dtap_msg_gmm[idx];
6585         *hf_idx = hf_gsm_a_dtap_msg_gmm_type;
6586         *dtap_msg_fcn = dtap_msg_gmm_fcn[idx];
6587
6588         return;
6589 }
6590
6591 void get_sm_msg_params(guint8 oct, const gchar **msg_str, int *ett_tree, int *hf_idx, msg_fcn *dtap_msg_fcn)
6592 {
6593         gint                    idx;
6594
6595         *msg_str = match_strval_idx((guint32) (oct & DTAP_SM_IEI_MASK), gsm_a_dtap_msg_sm_strings, &idx);
6596         *ett_tree = ett_gsm_dtap_msg_sm[idx];
6597         *hf_idx = hf_gsm_a_dtap_msg_sm_type;
6598         *dtap_msg_fcn = dtap_msg_sm_fcn[idx];
6599
6600         return;
6601 }
6602
6603 /* Register the protocol with Wireshark */
6604 void
6605 proto_register_gsm_a_gm(void)
6606 {
6607         guint           i;
6608         guint           last_offset;
6609
6610         /* Setup list of header fields */
6611
6612         static hf_register_info hf[] =
6613         {
6614         { &hf_gsm_a_dtap_msg_gmm_type,
6615                 { "DTAP GPRS Mobility Management Message Type", "gsm_a.dtap_msg_gmm_type",
6616                   FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_msg_gmm_strings), 0x0,
6617                   NULL, HFILL }
6618         },
6619         { &hf_gsm_a_dtap_msg_sm_type,
6620                 { "DTAP GPRS Session Management Message Type",  "gsm_a.dtap_msg_sm_type",
6621                   FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_msg_sm_strings), 0x0,
6622                   NULL, HFILL }
6623         },
6624         { &hf_gsm_a_gm_elem_id,
6625                 { "Element ID", "gsm_a_gm.elem_id",
6626                 FT_UINT8, BASE_DEC, NULL, 0,
6627                 NULL, HFILL }
6628         },
6629         { &hf_gsm_a_qos_delay_cls,
6630                 { "Quality of Service Delay class", "gsm_a.qos.delay_cls",
6631                   FT_UINT8, BASE_DEC, VALS(gsm_a_qos_delay_cls_vals), 0x38,
6632                   NULL, HFILL }
6633         },
6634         { &hf_gsm_a_qos_reliability_cls,
6635                 { "Reliability class", "gsm_a.qos.delay_cls",
6636                   FT_UINT8, BASE_DEC, VALS(gsm_a_qos_delay_cls_vals), 0x07,
6637                   NULL, HFILL }
6638         },
6639         { &hf_gsm_a_qos_traffic_cls,
6640                 { "Traffic class", "gsm_a.qos.traffic_cls",
6641                   FT_UINT8, BASE_DEC, VALS(gsm_a_qos_traffic_cls_vals), 0xe0,
6642                   NULL, HFILL }
6643         },
6644         { &hf_gsm_a_qos_del_order,
6645                 { "Delivery order", "gsm_a.qos.del_order",
6646                   FT_UINT8, BASE_DEC, VALS(gsm_a_qos_del_order_vals), 0x18,
6647                   NULL, HFILL }
6648         },
6649         { &hf_gsm_a_qos_del_of_err_sdu,
6650                 { "Delivery of erroneous SDUs", "gsm_a.qos.del_of_err_sdu",
6651                   FT_UINT8, BASE_DEC, VALS(gsm_a_qos_del_of_err_sdu_vals), 0x07,
6652                   NULL, HFILL }
6653         },
6654         { &hf_gsm_a_qos_ber,
6655                 { "Residual Bit Error Rate (BER)", "gsm_a.qos.ber",
6656                   FT_UINT8, BASE_DEC, VALS(gsm_a_qos_ber_vals), 0xf0,
6657                   NULL, HFILL }
6658         },
6659         { &hf_gsm_a_qos_sdu_err_rat,
6660                 { "SDU error ratio", "gsm_a.qos.sdu_err_rat",
6661                   FT_UINT8, BASE_DEC, VALS(gsm_a_qos_sdu_err_rat_vals), 0x0f,
6662                   NULL, HFILL }
6663         },
6664         { &hf_gsm_a_qos_traff_hdl_pri,
6665                 { "Traffic handling priority", "gsm_a.qos.traff_hdl_pri",
6666                   FT_UINT8, BASE_DEC, VALS(gsm_a_qos_traff_hdl_pri_vals), 0x03,
6667                   NULL, HFILL }
6668         },
6669         { &hf_gsm_a_gmm_split_on_ccch,
6670                 { "SPLIT on CCCH","gsm_a.gmm.split_on_ccch",
6671                   FT_BOOLEAN, 8, TFS(&gsm_a_gmm_split_on_ccch_value), 0x08,
6672                   NULL, HFILL }
6673         },
6674         { &hf_gsm_a_gmm_non_drx_timer,
6675                 { "Non-DRX timer","gsm_a.gmm.non_drx_timer",
6676                   FT_UINT8, BASE_DEC, VALS(gsm_a_gmm_non_drx_timer_strings), 0x07,
6677                   NULL, HFILL }
6678         },
6679         { &hf_gsm_a_gmm_cn_spec_drs_cycle_len_coef,
6680                 { "CN Specific DRX cycle length coefficient","gsm_a.gmm.cn_spec_drs_cycle_len_coef",
6681                   FT_UINT8, BASE_DEC|BASE_RANGE_STRING, RVALS(gsm_a_gmm_cn_spec_drs_cycle_len_coef_strings), 0xf0,
6682                   NULL, HFILL }
6683         },
6684         { &hf_gsm_a_tft_op_code,
6685                 { "TFT operation code", "gsm_a.tft.op_code",
6686                   FT_UINT8, BASE_DEC, VALS(gsm_a_tft_op_code_vals), 0xe0,
6687                   NULL, HFILL }
6688         },
6689         { &hf_gsm_a_tft_e_bit,
6690                 { "E bit","gsm_a.tft.e_bit",
6691                   FT_BOOLEAN, 8, TFS(&gsm_a_tft_e_bit), 0x10,
6692                   NULL, HFILL }
6693         },
6694         { &hf_gsm_a_tft_pkt_flt,
6695                 { "Number of packet filters", "gsm_a.tft.pkt_flt",
6696                   FT_UINT8, BASE_DEC, NULL, 0x0f,
6697                   NULL, HFILL }
6698         },
6699         { &hf_gsm_a_tft_pkt_flt_dir,
6700                 { "Packet filter direction", "gsm_a.tft.pkt_flt_dir",
6701                   FT_UINT8, BASE_DEC, VALS(gsm_a_tft_pkt_flt_dir_vals), 0x30,
6702                   NULL, HFILL }
6703         },
6704         { &hf_gsm_a_tft_pkt_flt_id,
6705                 { "Packet filter identifier", "gsm_a.tft.pkt_flt_id",
6706                   FT_UINT8, BASE_DEC, NULL, 0x0f,
6707                   NULL, HFILL }
6708         },
6709         { &hf_gsm_a_sm_ip4_address,
6710                 { "IPv4 address", "gsm_a.sm.ip4_address",
6711                   FT_IPv4, BASE_NONE, NULL, 0x0,
6712                 NULL, HFILL }
6713         },
6714         { &hf_gsm_a_sm_ip4_mask,
6715                 { "IPv4 address mask", "gsm_a.sm.ip4_mask",
6716                   FT_IPv4, BASE_NONE, NULL, 0x0,
6717                 NULL, HFILL }
6718         },
6719         { &hf_gsm_a_sm_ip6_address,
6720                 { "IPv6 address", "gsm_a.sm.ip6_address",
6721                   FT_IPv6, BASE_NONE, NULL, 0x0,
6722                 NULL, HFILL }
6723         },
6724         { &hf_gsm_a_sm_ip6_mask,
6725                 { "IPv6 address mask", "gsm_a.sm.ip6_mask",
6726                   FT_IPv6, BASE_NONE, NULL, 0x0,
6727                 NULL, HFILL }
6728         },
6729         { &hf_gsm_a_tft_protocol_header,
6730                 { "Protocol/header", "gsm_a.tft.protocol_header",
6731                   FT_UINT8, BASE_HEX, NULL, 0x0,
6732                 NULL, HFILL }
6733         },
6734         { &hf_gsm_a_tft_port,
6735                 { "Port", "gsm_a.tft.port",
6736                   FT_UINT16, BASE_DEC, NULL, 0x0,
6737                 NULL, HFILL }
6738         },
6739         { &hf_gsm_a_tft_port_low,
6740                 { "Low limit port", "gsm_a.tft.port_low",
6741                   FT_UINT16, BASE_DEC, NULL, 0x0,
6742                 NULL, HFILL }
6743         },
6744         { &hf_gsm_a_tft_port_high,
6745                 { "High limit port", "gsm_a.tft.port_high",
6746                   FT_UINT16, BASE_DEC, NULL, 0x0,
6747                 NULL, HFILL }
6748         },
6749         { &hf_gsm_a_tft_security,
6750                 { "IPSec security parameter index", "gsm_a.tft.security",
6751                   FT_UINT32, BASE_HEX, NULL, 0x0,
6752                 NULL, HFILL }
6753         },
6754         { &hf_gsm_a_tft_traffic_mask,
6755                 { "Mask field", "gsm_a.tft.traffic_mask",
6756                   FT_UINT8, BASE_HEX, NULL, 0x0,
6757                 NULL, HFILL }
6758         },
6759         { &hf_gsm_a_tft_flow_label_type,
6760                 { "Flow Label Type", "gsm_a.tft.flow_label_type",
6761                   FT_UINT24, BASE_HEX, NULL, 0x0FFFFF,
6762                 NULL, HFILL }
6763         },
6764         { &hf_gsm_a_tft_param_id,
6765                 { "Parameter identifier", "gsm_a.tft.param_id",
6766                   FT_UINT8, BASE_DEC, VALS(gsm_a_tft_param_id_vals), 0x0,
6767                   NULL, HFILL }
6768         },
6769         { &hf_gsm_a_ptmsi_sig,
6770                 { "P-TMSI Signature", "gsm_a.ptmsi_sig",
6771                   FT_UINT24, BASE_HEX, NULL, 0x0,
6772                 NULL, HFILL }
6773         },
6774         { &hf_gsm_a_ptmsi_sig2,
6775                 { "P-TMSI Signature 2", "gsm_a.ptmsi_sig2",
6776                   FT_UINT24, BASE_HEX, NULL, 0x0,
6777                 NULL, HFILL }
6778         },
6779         { &hf_gsm_a_gm_acc_tech_type,
6780                 { "Access Technology Type", "gsm_a.gm.acc_tech_type",
6781                   FT_UINT8, BASE_DEC, VALS(gsm_a_gm_acc_tech_type_vals), 0x0,
6782                 NULL, HFILL }
6783         },
6784         { &hf_gsm_a_gm_acc_cap_struct_len,
6785                 { "Length in bits", "gsm_a.gm.acc_cap_struct_len",
6786                   FT_UINT8, BASE_HEX_DEC,NULL, 0x0,
6787                 NULL, HFILL }
6788         },
6789         { &hf_gsm_a_gm_sms_value,
6790                 { "SMS_VALUE (Switch-Measure-Switch)", "gsm_a.gm.sms",
6791                   FT_UINT8, BASE_DEC, VALS(gsm_a_sms_vals), 0x0,
6792                 NULL, HFILL }
6793         },
6794         { &hf_gsm_a_gm_sm_value,
6795                 { "(SM_VALUE) Switch-Measure", "gsm_a.gm.sm",
6796                   FT_UINT8, BASE_DEC, VALS(gsm_a_sms_vals), 0x0,
6797                 NULL, HFILL }
6798         },
6799         { &hf_gsm_a_gm_sm_ext,
6800                 { "Ext", "gsm_a.gm.sm.ext",
6801                   FT_UINT8, BASE_HEX, NULL, 0x80,
6802                 NULL, HFILL }
6803         },
6804         { &hf_gsm_a_gm_link_dir,
6805                 { "Link direction", "gsm_a.gm.link_dir",
6806                   FT_INT32, BASE_DEC, VALS(gsm_a_gm_link_dir_vals), 0x0,
6807                 NULL, HFILL }
6808         },
6809         { &hf_gsm_a_gm_cause,
6810                 { "gmm Cause", "gsm_a.gm.cause",
6811                   FT_UINT8, BASE_DEC|BASE_RANGE_STRING, RVALS(gmm_cause_vals), 0x0,
6812                 NULL, HFILL }
6813         },
6814         { &hf_gsm_a_gm_fop,
6815                 { "Follow-on proceed", "gsm_a.gm.fop",
6816                 FT_BOOLEAN, 8, NULL, 0x08,
6817                 NULL, HFILL }
6818         },
6819         { &hf_gsm_a_gm_res_of_attach,
6820                 { "Result of attach", "gsm_a.gm.res_of_attach",
6821                 FT_UINT8, BASE_DEC, VALS(gsm_a_gm_res_of_attach_vals), 0x07,
6822                 NULL, HFILL }
6823         },
6824         { &hf_gsm_a_gm_type_of_ciph_alg,
6825                 { "Type of ciphering algorithm", "gsm_a.gm.type_of_ciph_alg",
6826                 FT_UINT8, BASE_DEC, VALS(gsm_a_gm_type_of_ciph_alg_vals), 0x07,
6827                 NULL, HFILL }
6828         },
6829         { &hf_gsm_a_gm_imeisv_req,
6830                 { "IMEISV request", "gsm_a.gm.imeisv_req",
6831                 FT_UINT8, BASE_DEC|BASE_RANGE_STRING, RVALS(gsm_a_gm_imeisv_req_vals), 0x00,
6832                 NULL, HFILL }
6833         },
6834         { &hf_gsm_a_gm_ac_ref_nr,
6835                 { "A&C reference number", "gsm_a.gm.ac_ref_nr",
6836                   FT_UINT8, BASE_DEC, NULL, 0x0,
6837                 NULL, HFILL }
6838         },
6839         { &hf_gsm_a_gm_force_to_standby,
6840                 { "Force to standby", "gsm_a.gm.force_to_standby",
6841                 FT_UINT8, BASE_DEC|BASE_RANGE_STRING, RVALS(gsm_a_gm_force_to_standby_vals), 0x00,
6842                 NULL, HFILL }
6843         },
6844         { &hf_gsm_a_gm_ciph_key_seq_num,
6845                 { "Ciphering key sequence number", "gsm_a.gm.ciph_key_seq_num",
6846                 FT_UINT8, BASE_DEC, NULL, 0x00,
6847                 NULL, HFILL }
6848         },
6849         { &hf_gsm_a_gm_serv_type,
6850                 { "Service type", "gsm_a.gm.serv_type",
6851                 FT_UINT8, BASE_DEC, VALS(gsm_a_gm_serv_type_vals), 0x00,
6852                 NULL, HFILL }
6853         },
6854         { &hf_gsm_a_gm_for,
6855                 { "Follow-on request pending", "gsm_a.gm.for",
6856                 FT_BOOLEAN, 8, NULL, 0x08,
6857                 NULL, HFILL }
6858         },
6859         { &hf_gsm_a_gm_type_of_attach,
6860                 { "Type of attach", "gsm_a.gm.type_of_attach",
6861                 FT_UINT8, BASE_DEC, VALS(gsm_a_gm_type_of_attach_vals), 0x07,
6862                 NULL, HFILL }
6863         },
6864         { &hf_gsm_a_gm_tmsi_flag,
6865                 { "TMSI flag", "gsm_a.gm.tmsi_flag",
6866                 FT_BOOLEAN, 8, TFS(&gsm_a_gm_tmsi_flag_value), 0x01,
6867                 NULL, HFILL }
6868         },
6869         { &hf_gsm_a_gm_update_type,
6870                 { "Update type", "gsm_a.gm.update_type",
6871                 FT_UINT8, BASE_DEC, VALS(gsm_a_gm_update_type_vals), 0x07,
6872                 NULL, HFILL }
6873         },
6874         { &hf_gsm_a_gm_gprs_timer_unit,
6875                 { "Unit", "gsm_a.gm.gprs_timer_unit",
6876                 FT_UINT8, BASE_DEC, VALS(gsm_a_gm_gprs_timer_unit_vals), 0xe0,
6877                 NULL, HFILL }
6878         },
6879         { &hf_gsm_a_gm_gprs_timer_value,
6880                 { "Timer value", "gsm_a.gm.gprs_timer_value",
6881                 FT_UINT8, BASE_DEC, NULL, 0x1f,
6882                 NULL, HFILL }
6883         },
6884         { &hf_gsm_a_gm_nsapi_5_ul_stat,
6885                 { "NSAPI(5) uplink status", "gsm_a.gm.nsapi_5_ul_stat",
6886                 FT_BOOLEAN, 8, TFS(&gsm_a_gm_nsapi_ul_stat_vals), 0x0,
6887                 NULL, HFILL }
6888         },
6889         { &hf_gsm_a_gm_nsapi_6_ul_stat,
6890                 { "NSAPI(6) uplink status", "gsm_a.gm.nsapi_6_ul_stat",
6891                 FT_BOOLEAN, 8, TFS(&gsm_a_gm_nsapi_ul_stat_vals), 0x0,
6892                 NULL, HFILL }
6893         },
6894         { &hf_gsm_a_gm_nsapi_7_ul_stat,
6895                 { "NSAPI(7) uplink status", "gsm_a.gm.nsapi_7_ul_stat",
6896                 FT_BOOLEAN, 8, TFS(&gsm_a_gm_nsapi_ul_stat_vals), 0x0,
6897                 NULL, HFILL }
6898         },
6899         { &hf_gsm_a_gm_nsapi_8_ul_stat,
6900                 { "NSAPI(8) uplink status", "gsm_a.gm.nsapi_8_ul_stat",
6901                 FT_BOOLEAN, 8, TFS(&gsm_a_gm_nsapi_ul_stat_vals), 0x0,
6902                 NULL, HFILL }
6903         },
6904         { &hf_gsm_a_gm_nsapi_9_ul_stat,
6905                 { "NSAPI(9) uplink status", "gsm_a.gm.nsapi_9_ul_stat",
6906                 FT_BOOLEAN, 8, TFS(&gsm_a_gm_nsapi_ul_stat_vals), 0x0,
6907                 NULL, HFILL }
6908         },
6909         { &hf_gsm_a_gm_nsapi_10_ul_stat,
6910                 { "NSAPI(10) uplink status", "gsm_a.gm.nsapi_10_ul_stat",
6911                 FT_BOOLEAN, 8, TFS(&gsm_a_gm_nsapi_ul_stat_vals), 0x0,
6912                 NULL, HFILL }
6913         },
6914         { &hf_gsm_a_gm_nsapi_11_ul_stat,
6915                 { "NSAPI(11) uplink status", "gsm_a.gm.nsapi_11_ul_stat",
6916                 FT_BOOLEAN, 8, TFS(&gsm_a_gm_nsapi_ul_stat_vals), 0x0,
6917                 NULL, HFILL }
6918         },
6919         { &hf_gsm_a_gm_nsapi_12_ul_stat,
6920                 { "NSAPI(12) uplink status", "gsm_a.gm.nsapi_12_ul_stat",
6921                 FT_BOOLEAN, 8, TFS(&gsm_a_gm_nsapi_ul_stat_vals), 0x0,
6922                 NULL, HFILL }
6923         },
6924         { &hf_gsm_a_gm_nsapi_13_ul_stat,
6925                 { "NSAPI(13) uplink status", "gsm_a.gm.nsapi_13_ul_stat",
6926                 FT_BOOLEAN, 8, TFS(&gsm_a_gm_nsapi_ul_stat_vals), 0x0,
6927                 NULL, HFILL }
6928         },
6929         { &hf_gsm_a_gm_nsapi_14_ul_stat,
6930                 { "NSAPI(14) uplink status", "gsm_a.gm.nsapi_14_ul_stat",
6931                 FT_BOOLEAN, 8, TFS(&gsm_a_gm_nsapi_ul_stat_vals), 0x0,
6932                 NULL, HFILL }
6933         },
6934         { &hf_gsm_a_gm_nsapi_15_ul_stat,
6935                 { "NSAPI(15) uplink status", "gsm_a.gm.nsapi_15_ul_stat",
6936                 FT_BOOLEAN, 8, TFS(&gsm_a_gm_nsapi_ul_stat_vals), 0x0,
6937                 NULL, HFILL }
6938         },
6939         { &hf_gsm_a_gm_pco_pid,
6940                 { "Protocol or Container ID", "gsm_a.gm.pco_pid",
6941                 FT_UINT16, BASE_DEC, NULL, 0x0,
6942                 NULL, HFILL }
6943         },
6944         { &hf_gsm_a_gm_type_of_identity,
6945                 { "Type of identity", "gsm_a.gm.type_of_identity",
6946                 FT_UINT8, BASE_DEC, VALS(gsm_a_gm_type_of_identity_vals), 0x07,
6947                 NULL, HFILL }
6948         },
6949         { &hf_gsm_a_gm_rac,
6950                 { "Routing Area Code (RAC)","gsm_a.gm.rac",
6951                 FT_UINT8, BASE_HEX_DEC, NULL, 0x00,
6952                 NULL, HFILL }
6953         },
6954         { &hf_gsm_a_gm_apc,
6955                 { "APC","gsm_a.gm.apc",
6956                 FT_BOOLEAN, 8, TFS(&gsm_a_gm_apc_vals), 0x20,
6957                 NULL, HFILL }
6958         },
6959         { &hf_gsm_a_gm_otd_a,
6960                 { "OTD-A","gsm_a.gm.otd_a",
6961                 FT_BOOLEAN, 8, TFS(&gsm_a_gm_otd_a_vals), 0x10,
6962                 NULL, HFILL }
6963         },
6964         { &hf_gsm_a_gm_otd_b,
6965                 { "OTD-B","gsm_a.gm.otd_b",
6966                 FT_BOOLEAN, 8, TFS(&gsm_a_gm_otd_b_vals), 0x08,
6967                 NULL, HFILL }
6968         },
6969         { &hf_gsm_a_gm_gps_a,
6970                 { "GPS-A","gsm_a.gm.gps_a",
6971                 FT_BOOLEAN, 8, TFS(&gsm_a_gm_gps_a_vals), 0x04,
6972                 NULL, HFILL }
6973         },
6974         { &hf_gsm_a_gm_gps_b,
6975                 { "GPS-B","gsm_a.gm.gps_b",
6976                 FT_BOOLEAN, 8, TFS(&gsm_a_gm_gps_b_vals), 0x02,
6977                 NULL, HFILL }
6978         },
6979         { &hf_gsm_a_gm_gps_c,
6980                 { "GPS-C","gsm_a.gm.gps_c",
6981                 FT_BOOLEAN, 8, TFS(&gsm_a_gm_gps_c_vals), 0x01,
6982                 NULL, HFILL }
6983         },
6984         { &hf_gsm_a_gm_req_ms_info_irat,
6985                 { "I-RAT","gsm_a.gm.req_ms_info_irat",
6986                 FT_BOOLEAN, 8, TFS(&gsm_a_gm_req_ms_info_irat_vals), 0x0,
6987                 NULL, HFILL }
6988         },
6989         { &hf_gsm_a_gm_req_ms_info_irat2,
6990                 { "I-RAT2","gsm_a.gm.req_ms_info_irat2",
6991                 FT_BOOLEAN, 8, TFS(&gsm_a_gm_req_ms_info_irat2_vals), 0x0,
6992                 NULL, HFILL }
6993         },
6994         { &hf_gsm_a_gm_ue_usage_setting,
6995                 { "UE's usage setting","gsm_a.gm.ue_usage_setting",
6996                 FT_BOOLEAN, 8, TFS(&gsm_a_gm_ue_usage_setting_vals), 0x0,
6997                 NULL, HFILL }
6998         },
6999         { &hf_gsm_a_gm_voice_domain_pref_for_eutran,
7000                 { "Voice domain preference for E-UTRAN","gsm_a.gm.voice_domain_pref_for_eutran",
7001                 FT_UINT8, BASE_DEC, VALS(gsm_a_gm_voice_domain_pref_for_eutran_vals), 0x0,
7002                 NULL, HFILL }
7003         },
7004         { &hf_gsm_a_sm_pdp_type_org,
7005                 { "PDP type organization", "gsm_a.sm.pdp_type_org",
7006                 FT_UINT8, BASE_DEC, VALS(gsm_a_sm_pdp_type_org_vals), 0x0f,
7007                 NULL, HFILL }
7008         },
7009         { &hf_gsm_a_qos_mean_thr,
7010                 { "Mean throughput", "gsm_a.qos.mean_throughput",
7011                 FT_UINT8, BASE_DEC|BASE_RANGE_STRING, RVALS(gsm_a_qos_mean_thr_vals), 0x1f,
7012                 NULL, HFILL }
7013         },
7014         { &hf_gsm_a_qos_peak_thr,
7015                 { "Peak throughput", "gsm_a.qos.peak_throughput",
7016                 FT_UINT8, BASE_DEC|BASE_RANGE_STRING, RVALS(gsm_a_qos_peak_thr_vals), 0xf0,
7017                 NULL, HFILL }
7018         },
7019         { &hf_gsm_a_qos_prec_class,
7020                 { "Precedence class", "gsm_a.qos.prec_class",
7021                 FT_UINT8, BASE_DEC|BASE_RANGE_STRING, RVALS(gsm_a_qos_prec_class_vals), 0x07,
7022                 NULL, HFILL }
7023         },
7024         { &hf_gsm_a_qos_traf_handl_prio,
7025                 { "Traffic handling priority", "gsm_a.qos.traf_handl_prio",
7026                 FT_UINT8, BASE_DEC, NULL, 0x03,
7027                 NULL, HFILL }
7028         },
7029         { &hf_gsm_a_qos_trans_delay,
7030                 { "Transfer delay", "gsm_a.qos.trans_delay",
7031                 FT_UINT8, BASE_DEC, NULL, 0xfc,
7032                 NULL, HFILL }
7033         },
7034         { &hf_gsm_a_qos_signalling_ind,
7035                 { "Signalling indication", "gsm_a.qos.signalling_ind",
7036                 FT_BOOLEAN, 8, TFS(&gsm_a_qos_signalling_ind_value), 0x10,
7037                 NULL, HFILL }
7038         },
7039         { &hf_gsm_a_qos_source_stat_desc,
7040                 { "Source statistics description", "gsm_a.qos.source_stat_desc",
7041                 FT_UINT8, BASE_DEC, NULL, 0x0f,
7042                 NULL, HFILL }
7043         },
7044         { &hf_gsm_a_qos_max_bitrate_upl,
7045                 { "Maximum bitrate for uplink", "gsm_a.qos.max_bitrate_upl",
7046                   FT_UINT8, BASE_DEC, NULL, 0x0,
7047                 NULL, HFILL }
7048         },
7049         { &hf_gsm_a_qos_max_bitrate_downl,
7050                 { "Maximum bitrate for downlink", "gsm_a.qos.max_bitrate_downl",
7051                   FT_UINT8, BASE_DEC, NULL, 0x0,
7052                 NULL, HFILL }
7053         },
7054         { &hf_gsm_a_qos_guar_bitrate_upl,
7055                 { "Guaranteed bitrate for uplink", "gsm_a.qos.guar_bitrate_upl",
7056                   FT_UINT8, BASE_DEC, NULL, 0x0,
7057                 NULL, HFILL }
7058         },
7059         { &hf_gsm_a_qos_guar_bitrate_downl,
7060                 { "Guaranteed bitrate for downlink", "gsm_a.qos.guar_bitrate_downl",
7061                   FT_UINT8, BASE_DEC, NULL, 0x0,
7062                 NULL, HFILL }
7063         },
7064         { &hf_gsm_a_qos_max_bitrate_upl_ext,
7065                 { "Maximum bitrate for uplink (extended)", "gsm_a.qos.max_bitrate_upl_ext",
7066                   FT_UINT8, BASE_DEC, NULL, 0x0,
7067                 NULL, HFILL }
7068         },
7069         { &hf_gsm_a_qos_max_bitrate_downl_ext,
7070                 { "Maximum bitrate for downlink (extended)", "gsm_a.qos.max_bitrate_downl_ext",
7071                   FT_UINT8, BASE_DEC, NULL, 0x0,
7072                 NULL, HFILL }
7073         },
7074         { &hf_gsm_a_qos_guar_bitrate_upl_ext,
7075                 { "Guaranteed bitrate for uplink (extended)", "gsm_a.qos.guar_bitrate_upl_ext",
7076                   FT_UINT8, BASE_DEC, NULL, 0x0,
7077                 NULL, HFILL }
7078         },
7079         { &hf_gsm_a_qos_guar_bitrate_downl_ext,
7080                 { "Guaranteed bitrate for downlink (extended)", "gsm_a.qos.guar_bitrate_downl_ext",
7081                   FT_UINT8, BASE_DEC, NULL, 0x0,
7082                 NULL, HFILL }
7083         },
7084         { &hf_gsm_a_sm_cause,
7085                 { "SM Cause", "gsm_a.sm.cause",
7086                   FT_UINT8, BASE_DEC, NULL, 0x0,
7087                 NULL, HFILL }
7088         },
7089         { &hf_gsm_a_sm_cause_2,
7090                 { "SM Cause 2", "gsm_a.sm.cause_2",
7091                   FT_UINT8, BASE_DEC, NULL, 0x0,
7092                 NULL, HFILL }
7093         },
7094         { &hf_gsm_a_sm_llc_sapi,
7095                 { "LLC SAPI", "gsm_a.sm.llc_sapi",
7096                 FT_UINT8, BASE_DEC, VALS(gsm_a_sm_llc_sapi_vals), 0x0f,
7097                 NULL, HFILL }
7098         },
7099         { &hf_gsm_a_sm_tdi,
7100                 { "Tear Down Indicator (TDI)", "gsm_a.sm.tdi",
7101                 FT_BOOLEAN, 8, TFS(&gsm_a_sm_tdi_value), 0x01,
7102                 NULL, HFILL }
7103         },
7104         { &hf_gsm_a_sm_packet_flow_id,
7105                 { "Packet Flow Identifier (PFI)", "gsm_a.sm.packet_flow_id",
7106                 FT_UINT8, BASE_DEC|BASE_RANGE_STRING, RVALS(gsm_a_sm_packet_flow_id_vals), 0x7f,
7107                 NULL, HFILL }
7108         },
7109         { &hf_gsm_a_gmm_net_cap_gea1,
7110                 { "GEA/1", "gsm_a.gmm.net_cap.gea1",
7111                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_gea_vals), 0x80,
7112                 NULL, HFILL }
7113         },
7114         { &hf_gsm_a_gmm_net_cap_smdch,
7115                 { "SM capabilities via dedicated channels", "gsm_a.gmm.net_cap.smdch",
7116                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_smdch_vals), 0x40,
7117                 NULL, HFILL }
7118         },
7119         { &hf_gsm_a_gmm_net_cap_smgprs,
7120                 { "SM capabilities via GPRS channels", "gsm_a.gmm.net_cap.smgprs",
7121                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_smgprs_vals), 0x20,
7122                 NULL, HFILL }
7123         },
7124         { &hf_gsm_a_gmm_net_cap_ucs2,
7125                 { "UCS2 support", "gsm_a.gmm.net_cap.ucs2",
7126                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_smgprs_vals), 0x10,
7127                 NULL, HFILL }
7128         },
7129         { &hf_gsm_a_gmm_net_cap_ss_scr_ind,
7130                 { "SS Screening Indicator", "gsm_a.gmm.net_cap.ss_scr_ind",
7131                 FT_UINT8, BASE_HEX, VALS(gsm_a_gmm_net_cap_ss_scr_ind_vals), 0x0c,
7132                 NULL, HFILL }
7133         },
7134         { &hf_gsm_a_gmm_net_cap_solsa,
7135                 { "SoLSA Capability", "gsm_a.gmm.net_cap.solsa",
7136                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_solsa_vals), 0x02,
7137                 NULL, HFILL }
7138         },
7139         { &hf_gsm_a_gmm_net_cap_rev,
7140                 { "Revision level indicator", "gsm_a.gmm.net_cap.rev",
7141                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_rev_vals), 0x01,
7142                 NULL, HFILL }
7143         },
7144         { &hf_gsm_a_gmm_net_cap_pfc,
7145                 { "PFC feature mode", "gsm_a.gmm.net_cap.pfc",
7146                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_pfc_vals), 0x80,
7147                 NULL, HFILL }
7148         },
7149         { &hf_gsm_a_gmm_net_cap_ext_gea_bits,
7150                 { "Extended GEA bits", "gsm_a.gmm.net_cap.ext_gea_bits",
7151                 FT_UINT8, BASE_HEX, NULL, 0x7e,
7152                 NULL, HFILL }
7153         },
7154         { &hf_gsm_a_gmm_net_cap_gea2,
7155                 { "GEA/2", "gsm_a.gmm.net_cap.gea2",
7156                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_gea_vals), 0x40,
7157                 NULL, HFILL }
7158         },
7159         { &hf_gsm_a_gmm_net_cap_gea3,
7160                 { "GEA/3", "gsm_a.gmm.net_cap.gea3",
7161                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_gea_vals), 0x20,
7162                 NULL, HFILL }
7163         },
7164         { &hf_gsm_a_gmm_net_cap_gea4,
7165                 { "GEA/4", "gsm_a.gmm.net_cap.gea4",
7166                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_gea_vals), 0x10,
7167                 NULL, HFILL }
7168         },
7169         { &hf_gsm_a_gmm_net_cap_gea5,
7170                 { "GEA/5", "gsm_a.gmm.net_cap.gea5",
7171                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_gea_vals), 0x08,
7172                 NULL, HFILL }
7173         },
7174         { &hf_gsm_a_gmm_net_cap_gea6,
7175                 { "GEA/6", "gsm_a.gmm.net_cap.gea6",
7176                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_gea_vals), 0x04,
7177                 NULL, HFILL }
7178         },
7179         { &hf_gsm_a_gmm_net_cap_gea7,
7180                 { "GEA/7", "gsm_a.gmm.net_cap.gea7",
7181                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_gea_vals), 0x02,
7182                 NULL, HFILL }
7183         },
7184         { &hf_gsm_a_gmm_net_cap_lcs,
7185                 { "LCS VA capability", "gsm_a.gmm.net_cap.lcs",
7186                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_lcs_vals), 0x01,
7187                 NULL, HFILL }
7188         },
7189         { &hf_gsm_a_gmm_net_cap_ps_irat_iu,
7190                 { "PS inter-RAT HO to UTRAN Iu mode capability", "gsm_a.gmm.net_cap.ps_irat_iu",
7191                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_ps_irat_iu_vals), 0x80,
7192                 NULL, HFILL }
7193         },
7194         { &hf_gsm_a_gmm_net_cap_ps_irat_s1,
7195                 { "PS inter-RAT HO to E-UTRAN S1 mode capability", "gsm_a.gmm.net_cap.ps_irat_s1",
7196                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_ps_irat_s1_vals), 0x40,
7197                 NULL, HFILL }
7198         },
7199         { &hf_gsm_a_gmm_net_cap_comb_proc,
7200                 { "EMM Combined procedures capability", "gsm_a.gmm.net_cap.comb_proc",
7201                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_comb_proc_vals), 0x20,
7202                 NULL, HFILL }
7203         },
7204         { &hf_gsm_a_gmm_net_cap_isr,
7205                 { "ISR support", "gsm_a.gmm.net_cap.isr",
7206                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_isr_vals), 0x10,
7207                 NULL, HFILL }
7208         },
7209         { &hf_gsm_a_gmm_net_cap_srvcc_to_geran,
7210                 { "SRVCC to GERAN/UTRAN capability", "gsm_a.gmm.net_cap.srvcc_to_geran",
7211                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_srvcc_to_geran_vals), 0x08,
7212                 NULL, HFILL }
7213         },
7214         { &hf_gsm_a_gmm_net_cap_epc,
7215                 { "EPC Capability", "gsm_a.gmm.net_cap.epc",
7216                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_epc_vals), 0x04,
7217                 NULL, HFILL }
7218         },
7219         { &hf_gsm_a_gmm_net_cap_nf,
7220                 { "NF Capability", "gsm_a.gmm.net_cap.nf",
7221                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_nf_vals), 0x02,
7222                 NULL, HFILL }
7223         },
7224         { &hf_gsm_a_sm_tmgi,
7225                 { "Temporary Mobile Group Identity (TMGI)", "gsm_a.sm.tmgi",
7226                   FT_UINT24, BASE_HEX, NULL, 0x0,
7227                 NULL, HFILL }
7228         },
7229         { &hf_gsm_a_sm_enh_nsapi,
7230                 { "Enhanced NSAPI", "gsm_a.sm.enh_nsapi",
7231                   FT_UINT8, BASE_DEC, NULL, 0x0,
7232                 NULL, HFILL }
7233         },
7234         { &hf_gsm_a_sm_req_type,
7235                 { "Request type", "gsm_a.sm.req_type",
7236                   FT_UINT8, BASE_DEC, VALS(gsm_a_sm_req_type_vals), 0x07,
7237                 NULL, HFILL }
7238         },
7239         { &hf_gsm_a_sm_notif_ind,
7240                 { "Notification indicator value", "gsm_a.sm.notif_ind",
7241                   FT_UINT8, BASE_DEC, VALS(gsm_a_sm_notif_ind_vals), 0x0,
7242                 NULL, HFILL }
7243         },
7244         { &hf_gsm_a_gm_rac_ctrled_early_cm_sending,
7245                 { "Controlled early Classmark Sending", "gsm_a.gm.rac.comp_int_meas_cap",
7246                    FT_BOOLEAN, 8, TFS(&tfs_implemented_not_implemented), 0x0,
7247                 NULL, HFILL }
7248         },
7249         { &hf_gsm_a_gm_rac_pseudo_sync,
7250                 { "Pseudo Synchronisation", "gsm_a.gm.rac.pseudo_sync",
7251                    FT_BOOLEAN, 8, TFS(&tfs_present_not_present), 0x0,
7252                 NULL, HFILL }
7253         },
7254         { &hf_gsm_a_gm_rac_vgcs,
7255                 { "Voice Group Call Service", "gsm_a.gm.rac.vgcs",
7256                    FT_BOOLEAN, 8, TFS(&gsm_a_gm_vgcs), 0x0,
7257                 NULL, HFILL }
7258         },
7259         { &hf_gsm_a_gm_rac_vbs,
7260                 { "Voice Broadcast Service", "gsm_a.gm.rac.vbs",
7261                    FT_BOOLEAN, 8, TFS(&gsm_a_gm_vbs), 0x0,
7262                 NULL, HFILL }
7263         },
7264         { &hf_gsm_a_gm_rac_multislot_capability,
7265                 { "Multislot capability struct", "gsm_a.gm.rac.multislot_capability",
7266                    FT_BOOLEAN, 8, TFS(&tfs_present_not_present), 0x0,
7267                 NULL, HFILL }
7268         },
7269         { &hf_gsm_a_gm_rac_hscsd_multi_slot_class,
7270                 { "HSCSD multislot class", "gsm_a.gm.rac.hscsd_multi_slot_class",
7271                    FT_UINT8, BASE_DEC, VALS(gsm_a_gm_multi_slot_vals), 0x0,
7272                 NULL, HFILL }
7273         },
7274         { &hf_gsm_a_gm_rac_gprs_multi_slot_class,
7275                 { "GPRS multislot class", "gsm_a.gm.rac.gprs_multi_slot_class",
7276                    FT_UINT8, BASE_DEC, VALS(gsm_a_gm_multi_slot_vals), 0x0,
7277                 NULL, HFILL }
7278         },
7279         { &hf_gsm_a_gm_rac_gprs_ext_dyn_alloc_cap,
7280                 { "GPRS Extended Dynamic Allocation Capability", "gsm_a.gm.rac.gprs_ext_dyn_alloc_cap",
7281                    FT_BOOLEAN, 8, TFS(&tfs_implemented_not_implemented), 0x0,
7282                 NULL, HFILL }
7283         },
7284         { &hf_gsm_a_gm_rac_ecsd_multi_slot_class,
7285                 { "ECSD multislot class", "gsm_a.gm.rac.ecsd_multi_slot_class",
7286                    FT_UINT8, BASE_DEC, VALS(gsm_a_gm_multi_slot_vals), 0x0,
7287                 NULL, HFILL }
7288         },
7289         { &hf_gsm_a_gm_rac_egprs_multi_slot_class,
7290                 { "EGPRS multislot class", "gsm_a.gm.rac.egprs_multi_slot_class",
7291                    FT_UINT8, BASE_DEC, VALS(gsm_a_gm_multi_slot_vals), 0x0,
7292                 NULL, HFILL }
7293         },
7294         { &hf_gsm_a_gm_rac_egprs_ext_dyn_alloc_cap,
7295                 { "EGPRS Extended Dynamic Allocation Capability", "gsm_a.gm.rac.egprs_ext_dyn_alloc_cap",
7296                    FT_BOOLEAN, 8, TFS(&tfs_implemented_not_implemented), 0x0,
7297                 NULL, HFILL }
7298         },
7299         { &hf_gsm_a_gm_rac_dtm_gprs_multi_slot_class,
7300                 { "DTM GPRS Multi Slot Class", "gsm_a.gm.rac.dtm_gprs_multi_slot_class",
7301                    FT_UINT8, BASE_DEC, VALS(gsm_a_gm_dtm_gprs_multi_slot_class_vals), 0x0,
7302                 NULL, HFILL }
7303         },
7304         { &hf_gsm_a_gm_rac_single_slt_dtm,
7305                 { "Single Slot DTM", "gsm_a.gm.rac.single_slt_dtm",
7306                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
7307                 NULL, HFILL }
7308         },
7309         { &hf_gsm_a_gm_rac_dtm_egprs_multi_slot_cls_pres,
7310                 { "DTM EGPRS Multi Slot Class", "gsm_a.gm.rac.dtm_egprs_multi_slot_cls_pres",
7311                    FT_BOOLEAN, 8, TFS(&tfs_present_not_present), 0x0,
7312                 NULL, HFILL }
7313         },
7314         { &hf_gsm_a_gm_rac_dtm_egprs_multi_slot_class,
7315                 { "DTM EGPRS Multi Slot Class", "gsm_a.gm.rac.dtm_egprs_multi_slot_class",
7316                    FT_UINT8, BASE_DEC, VALS(gsm_a_gm_dtm_gprs_multi_slot_class_vals), 0x0,
7317                 NULL, HFILL }
7318         },
7319         { &hf_gsm_a_gm_rac_8psk_pow_cap_pres,
7320                 { "8PSK Power Capability Bits", "gsm_a.gm.rac.8psk_pow_cap_pres",
7321                    FT_BOOLEAN, 8, TFS(&tfs_present_not_present), 0x0,
7322                 NULL, HFILL }
7323         },
7324         { &hf_gsm_a_gm_rac_comp_int_meas_cap,
7325                 { "COMPACT Interference Measurement Capability", "gsm_a.gm.rac.comp_int_meas_cap",
7326                    FT_BOOLEAN, 8, TFS(&tfs_implemented_not_implemented), 0x0,
7327                 NULL, HFILL }
7328         },
7329         { &hf_gsm_a_gm_rel_lev_ind,
7330                 { "Revision Level Indicator", "gsm_a.gm.rel_lev_ind",
7331                    FT_BOOLEAN, 8, TFS(&gsm_a_gm_revision_level_indicator), 0x0,
7332                 NULL, HFILL }
7333         },
7334         { &hf_gsm_a_gm_rac_umts_fdd_cap,
7335                 { "UMTS FDD Radio Access Technology Capability", "gsm_a.gm.rac.umts_fdd_cap",
7336                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
7337                 NULL, HFILL }
7338         },
7339         { &hf_gsm_a_gm_rac_umts_384_tdd_ra_cap,
7340                 { "UMTS 3.84 Mcps TDD Radio Access Technology Capability", "gsm_a.gm.rac.umts_384_tdd_ra_cap",
7341                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
7342                 NULL, HFILL }
7343         },
7344         { &hf_gsm_a_gm_rac_cdma2000_cap,
7345                 { "CDMA 2000 Radio Access Technology Capability", "gsm_a.gm.rac.cdma2000_cap",
7346                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
7347                 NULL, HFILL }
7348         },
7349         { &hf_gsm_a_gm_rac_umts_128_tdd_ra_cap,
7350                 { "UMTS 1.28 Mcps TDD Radio Access Technology Capability", "gsm_a.gm.rac.umts_128_tdd_ra_cap",
7351                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
7352                 NULL, HFILL }
7353         },
7354         { &hf_gsm_a_gm_rac_geran_feat_pkg,
7355                 { "GERAN Feature Package 1", "gsm_a.gm.rac.geran_feat_pkg",
7356                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
7357                 NULL, HFILL }
7358         },
7359         { &hf_gsm_a_gm_rac_mod_based_multi_slot_class_support,
7360                 { "Modulation based multislot class support", "gsm_a.gm.rac.mod_based_multi_slot_class_support",
7361                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
7362                 NULL, HFILL }
7363         },
7364         { &hf_gsm_a_gm_rac_geran_iu_mode_cap,
7365                 { "GERAN Iu mode", "gsm_a.gm.rac.geran_iu_mode_cap",
7366                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
7367                 NULL, HFILL }
7368         },
7369         { &hf_gsm_a_gm_rac_flo_iu_cap,
7370                 { "FLO Iu Capability", "gsm_a.gm.rac.flo_iu_cap",
7371                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
7372                 NULL, HFILL }
7373         },
7374         { &hf_gsm_a_gm_rac_mult_tbf_cap,
7375                 { "Multiple TBF Capability", "gsm_a.gm.rac.mult_tbf_cap",
7376                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
7377                 NULL, HFILL }
7378         },
7379         { &hf_gsm_a_gm_rac_down_adv_rec_perf,
7380                 { "Downlink Advanced Receiver Performance", "gsm_a.gm.rac.down_adv_rec_perf",
7381                    FT_UINT8, BASE_DEC, VALS(gsm_a_gm_down_adv_rec_perf_vals), 0x0,
7382                 NULL, HFILL }
7383         },
7384         { &hf_gsm_a_gm_rac_ext_rlc_mac_ctrl_msg_seg_cap,
7385                 { "Extended RLC/MAC Control Message Segmentation Capability", "gsm_a.gm.rac.ext_rlc_mac_ctrl_msg_seg_cap",
7386                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
7387                 NULL, HFILL }
7388         },
7389         { &hf_gsm_a_gm_rac_dtm_enh_cap,
7390                 { "DTM Enhancements Capability", "gsm_a.gm.rac.dtm_enh_cap",
7391                    FT_BOOLEAN, 8, TFS(&gsm_a_gm_dtm_enh_cap), 0x0,
7392                 NULL, HFILL }
7393         },
7394         { &hf_gsm_a_gm_rac_dtm_gprs_high_multi_slot_class,
7395                 { "DTM GPRS High Multi Slot Class", "gsm_a.gm.rac.dtm_gprs_high_multi_slot_class",
7396                    FT_UINT8, BASE_DEC, VALS(gsm_a_gm_dtm_gprs_high_multi_slot_class_vals), 0x0,
7397                 NULL, HFILL }
7398         },
7399         { &hf_gsm_a_gm_rac_dtm_egprs_high_multi_slot_class,
7400                 { "DTM EGPRS High Multi Slot Class", "gsm_a.gm.rac.dtm_egprs_high_multi_slot_class",
7401                    FT_UINT8, BASE_DEC, VALS(gsm_a_gm_dtm_gprs_high_multi_slot_class_vals), 0x0,
7402                 NULL, HFILL }
7403         },
7404         { &hf_gsm_a_gm_rac_ps_ho_cap,
7405                 { "PS Handover Capability", "gsm_a.gm.rac.ps_ho_cap",
7406                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
7407                 NULL, HFILL }
7408         },
7409         { &hf_gsm_a_gm_rac_dtm_ho_cap,
7410                 { "DTM Handover Capability", "gsm_a.gm.rac.dtm_ho_cap",
7411                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
7412                 NULL, HFILL }
7413         },
7414         { &hf_gsm_a_gm_rac_multi_slot_cap_red_down_dual_carrier,
7415                 { "Multislot Capability Reduction for Downlink Dual Carrier", "gsm_a.gm.rac.multi_slot_cap_red_down_dual_carrier",
7416                    FT_UINT8, BASE_DEC, VALS(gsm_a_gm_multi_slot_cap_red_down_dual_carrier_vals), 0x0,
7417                 NULL, HFILL }
7418         },
7419         { &hf_gsm_a_gm_rac_down_dual_carrier_dtm_cap,
7420                 { "Downlink Dual Carrier for DTM Capability", "gsm_a.gm.rac.down_dual_carrier_dtm_cap",
7421                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
7422                 NULL, HFILL }
7423         },
7424         { &hf_gsm_a_gm_rac_flex_ts_assign,
7425                 { "Flexible Timeslot Assignment", "gsm_a.gm.rac.flex_ts_assign",
7426                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
7427                 NULL, HFILL }
7428         },
7429         { &hf_gsm_a_gm_rac_gan_ps_ho_cap,
7430                 { "GAN PS Handover Capability", "gsm_a.gm.rac.gan_ps_ho_cap",
7431                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
7432                 NULL, HFILL }
7433         },
7434         { &hf_gsm_a_gm_rac_rlc_non_pers_mode,
7435                 { "RLC Non-persistent Mode", "gsm_a.gm.rac.rlc_non_pers_mode",
7436                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
7437                 NULL, HFILL }
7438         },
7439         { &hf_gsm_a_gm_rac_reduced_lat_cap,
7440                 { "Reduced Latency Capability", "gsm_a.gm.rac.reduced_lat_cap",
7441                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
7442                 NULL, HFILL }
7443         },
7444         { &hf_gsm_a_gm_rac_ul_egprs2,
7445                 { "Uplink EGPRS2", "gsm_a.gm.rac.ul_egprs2",
7446                    FT_UINT8, BASE_DEC, VALS(gsm_a_gm_ul_egprs2_vals), 0x0,
7447                 NULL, HFILL }
7448         },
7449         { &hf_gsm_a_gm_rac_dl_egprs2,
7450                 { "Downlink EGPRS2", "gsm_a.gm.rac.dl_egprs2",
7451                    FT_UINT8, BASE_DEC, VALS(gsm_a_gm_dl_egprs2_vals), 0x0,
7452                 NULL, HFILL }
7453         },
7454         { &hf_gsm_a_gm_rac_eutra_fdd_support,
7455                 { "E-UTRA FDD support", "gsm_a.gm.rac.eutra_fdd_support",
7456                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
7457                 NULL, HFILL }
7458         },
7459         { &hf_gsm_a_gm_rac_eutra_tdd_support,
7460                 { "E-UTRA TDD support", "gsm_a.gm.rac.eutra_tdd_support",
7461                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
7462                 NULL, HFILL }
7463         },
7464         { &hf_gsm_a_gm_rac_geran_to_eutra_support_in_geran_ptm,
7465                 { "GERAN to E-UTRA support in GERAN packet transfer mode", "gsm_a.gm.rac.geran_to_eutra_support_in_geran_ptm",
7466                    FT_UINT8, BASE_DEC, VALS(gsm_a_gm_geran_to_eutra_support_in_geran_ptm_vals), 0x0,
7467                 NULL, HFILL }
7468         },
7469         { &hf_gsm_a_gm_rac_prio_based_resel_support,
7470                 { "Priority-based reselection support", "gsm_a.gm.rac.prio_based_resel_support",
7471                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
7472                 NULL, HFILL }
7473         },
7474         { &hf_gsm_a_gm_rac_alt_efta_multi_slot_class,
7475                 { "Alternative EFTA Multislot Class", "gsm_a.gm.rac.alt_efta_multi_slot_class",
7476                    FT_UINT8, BASE_DEC, VALS(gsm_a_gm_alt_efta_multi_slot_class_vals), 0x0,
7477                 NULL, HFILL }
7478         },
7479         { &hf_gsm_a_gm_rac_efta_multi_slot_cap_red_down_dual_carrier,
7480                 { "EFTA Multislot Capability Reduction for Downlink Dual Carrier", "gsm_a.gm.rac.efta_multi_slot_cap_red_down_dual_carrier",
7481                    FT_UINT8, BASE_DEC, VALS(gsm_a_gm_multi_slot_cap_red_down_dual_carrier_vals), 0x0,
7482                 NULL, HFILL }
7483         },
7484         { &hf_gsm_a_gm_rac_ind_up_layer_pdu_start_cap_for_rlc_um,
7485                 { "Indication of Upper Layer PDU Start Capability for RLC UM", "gsm_a.gm.rac.ind_up_layer_pdu_start_cap_for_rlc_um",
7486                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
7487                 NULL, HFILL }
7488         },
7489         { &hf_gsm_a_gm_rac_emst_cap,
7490                 { "Enhanced Multiplexing for Single TBF Capability", "gsm_a.gm.rac.emst_cap",
7491                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
7492                 NULL, HFILL }
7493         },
7494         { &hf_gsm_a_gm_rac_mtti_cap,
7495                 { "Multiple TTI Capability", "gsm_a.gm.rac.mtti_cap",
7496                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
7497                 NULL, HFILL }
7498         },
7499         { &hf_gsm_a_gm_rac_utra_csg_cell_report,
7500                 { "UTRA CSG Cells Reporting", "gsm_a.gm.rac.utra_csg_cell_report",
7501                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
7502                 NULL, HFILL }
7503         },
7504         { &hf_gsm_a_gm_rac_eutra_csg_cell_report,
7505                 { "E-UTRA CSG Cells Reporting", "gsm_a.gm.rac.mtti_cap",
7506                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
7507                 NULL, HFILL }
7508         },
7509         { &hf_gsm_a_sm_ti_flag,
7510                 { "TI Flag", "gsm_a.sm.ti_flag",
7511                    FT_BOOLEAN, 8, TFS(&gsm_a_sm_ti_flag_vals), 0x80,
7512                 NULL, HFILL }
7513         },
7514         { &hf_gsm_a_sm_ext,
7515                 { "Extension", "gsm_a.sm.ext",
7516                    FT_BOOLEAN, 8, NULL, 0x80,
7517                 NULL, HFILL }
7518         },
7519 };              
7520
7521         /* Setup protocol subtree array */
7522 #define NUM_INDIVIDUAL_ELEMS    18
7523         gint *ett[NUM_INDIVIDUAL_ELEMS +
7524                   NUM_GSM_DTAP_MSG_GMM + NUM_GSM_DTAP_MSG_SM +
7525                   NUM_GSM_GM_ELEM];
7526
7527         ett[0]  = &ett_tc_component;
7528         ett[1]  = &ett_tc_invoke_id;
7529         ett[2]  = &ett_tc_linked_id;
7530         ett[3]  = &ett_tc_opr_code;
7531         ett[4]  = &ett_tc_err_code;
7532         ett[5]  = &ett_tc_prob_code;
7533         ett[6]  = &ett_tc_sequence;
7534         ett[7]  = &ett_gmm_drx;
7535         ett[8]  = &ett_gmm_detach_type;
7536         ett[9]  = &ett_gmm_attach_type;
7537         ett[10] = &ett_gmm_context_stat;
7538         ett[11] = &ett_gmm_update_type;
7539         ett[12] = &ett_gmm_radio_cap;
7540         ett[13] = &ett_gmm_rai;
7541         ett[14] = &ett_sm_tft;
7542         ett[15] = &ett_gmm_gprs_timer;
7543         ett[16] = &ett_gmm_network_cap;
7544         ett[17] = &ett_gsm_a_gm_msrac_multislot_capability;
7545
7546         last_offset = NUM_INDIVIDUAL_ELEMS;
7547
7548         for (i=0; i < NUM_GSM_DTAP_MSG_GMM; i++, last_offset++)
7549         {
7550                 ett_gsm_dtap_msg_gmm[i] = -1;
7551                 ett[last_offset] = &ett_gsm_dtap_msg_gmm[i];
7552         }
7553
7554         for (i=0; i < NUM_GSM_DTAP_MSG_SM; i++, last_offset++)
7555         {
7556                 ett_gsm_dtap_msg_sm[i] = -1;
7557                 ett[last_offset] = &ett_gsm_dtap_msg_sm[i];
7558         }
7559
7560         for (i=0; i < NUM_GSM_GM_ELEM; i++, last_offset++)
7561         {
7562                 ett_gsm_gm_elem[i] = -1;
7563                 ett[last_offset] = &ett_gsm_gm_elem[i];
7564         }
7565
7566         proto_a_gm =
7567                 proto_register_protocol("GSM A-I/F GPRS Mobility and Session Management", "GSM Management", "gsm_a_gm");
7568
7569         proto_register_field_array(proto_a_gm, hf, array_length(hf));
7570
7571         proto_register_subtree_array(ett, array_length(ett));
7572
7573         /* subdissector code */
7574         gprs_sm_pco_subdissector_table = register_dissector_table("sm_pco.protocol",
7575                 "GPRS SM PCO PPP protocol", FT_UINT16, BASE_HEX);
7576 }
7577
7578 void
7579 proto_reg_handoff_gsm_a_gm(void)
7580 {
7581         data_handle = find_dissector("data");
7582         rrc_irat_ho_info_handle = find_dissector("rrc.irat.irat_ho_info");
7583         lte_rrc_ue_eutra_cap_handle = find_dissector("lte-rrc.ue_eutra_cap");
7584 }