Change the signature of elem_fcn():ns to include pinfo.
[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 8.6.0 Release 8)
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         { 0, NULL }
136 };
137
138 const value_string gsm_gm_elem_strings[] = {
139         /* GPRS Mobility Management Information Elements 10.5.5 */
140         { 0x00, "Attach Result" },
141         { 0x00, "Attach Type" },
142         { 0x00, "Cipher Algorithm" },
143         { 0x00, "TMSI Status" },
144         { 0x00, "Detach Type" },
145         { 0x00, "DRX Parameter" },
146         { 0x00, "Force to Standby" },
147         { 0x00, "Force to Standby" },
148         { 0x00, "P-TMSI Signature" },
149         { 0x00, "P-TMSI Signature 2" },
150         { 0x00, "Identity Type 2" },
151         { 0x00, "IMEISV Request" },
152         { 0x00, "Receive N-PDU Numbers List" },
153         { 0x00, "MS Network Capability" },
154         { 0x00, "MS Radio Access Capability" },
155         { 0x00, "GMM Cause" },
156         { 0x00, "Routing Area Identification" },
157         { 0x00, "Update Result" },
158         { 0x00, "Update Type" },
159         { 0x00, "A&C Reference Number" },
160         { 0x00, "A&C Reference Number" },
161         { 0x00, "Service Type" },
162         { 0x00, "Cell Notification" },
163         { 0x00, "PS LCS Capability" },
164         { 0x00, "Network Feature Support" },
165         { 0x00, "Inter RAT information container" },
166         /* Session Management Information Elements 10.5.6 */
167         { 0x00, "Access Point Name" },
168         { 0x00, "Network Service Access Point Identifier" },
169         { 0x00, "Protocol Configuration Options" },
170         { 0x00, "Packet Data Protocol Address" },
171         { 0x00, "Quality Of Service" },
172         { 0x00, "SM Cause" },
173         { 0x00, "SM Cause 2" },
174         { 0x00, "Linked TI" },
175         { 0x00, "LLC Service Access Point Identifier" },
176         { 0x00, "Tear Down Indicator" },
177         { 0x00, "Packet Flow Identifier" },
178         { 0x00, "Traffic Flow Template" },
179         { 0x00, "Temporary Mobile Group Identity (TMGI)" },
180         { 0x00, "MBMS bearer capabilities" },
181         { 0x00, "MBMS protocol configuration options" },
182         { 0x00, "Enhanced network service access point identifier" },
183         { 0x00, "Request type" },
184         /* GPRS Common Information Elements 10.5.7 */
185         { 0x00, "PDP Context Status" },
186         { 0x00, "Radio Priority" },
187         { 0x00, "GPRS Timer" },
188         { 0x00, "GPRS Timer 2" },
189         { 0x00, "Radio Priority 2"},
190         { 0x00, "MBMS context status"},
191         { 0x00, "Spare Nibble"},
192         { 0, NULL }
193 };
194
195 #define DTAP_GMM_IEI_MASK       0xff
196 #define DTAP_SM_IEI_MASK        0xff
197
198 /* Initialize the protocol and registered fields */
199 static int proto_a_gm = -1;
200
201 static int hf_gsm_a_dtap_msg_gmm_type = -1;
202 static int hf_gsm_a_dtap_msg_sm_type = -1;
203 int hf_gsm_a_gm_elem_id = -1;
204 static int hf_gsm_a_qos_delay_cls       = -1;
205 static int hf_gsm_a_qos_reliability_cls = -1;
206 static int hf_gsm_a_qos_traffic_cls = -1;
207 static int hf_gsm_a_qos_del_order = -1;
208 static int hf_gsm_a_qos_del_of_err_sdu = -1;
209 static int hf_gsm_a_qos_ber = -1;
210 static int hf_gsm_a_qos_sdu_err_rat = -1;
211 static int hf_gsm_a_qos_traff_hdl_pri = -1;
212
213 static int hf_gsm_a_gmm_split_on_ccch = -1;
214 static int hf_gsm_a_gmm_non_drx_timer = -1;
215 static int hf_gsm_a_gmm_cn_spec_drs_cycle_len_coef = -1;
216
217 static int hf_gsm_a_ptmsi_sig =-1;
218 static int hf_gsm_a_ptmsi_sig2 =-1;
219
220 static int hf_gsm_a_tft_op_code = -1;
221 static int hf_gsm_a_tft_e_bit = -1;
222 static int hf_gsm_a_tft_pkt_flt = -1;
223 static int hf_gsm_a_tft_pkt_flt_id = -1;
224 static int hf_gsm_a_tft_pkt_flt_dir = -1;
225 static int hf_gsm_a_sm_ip4_address = -1;
226 static int hf_gsm_a_sm_ip4_mask = -1;
227 static int hf_gsm_a_sm_ip6_address = -1;
228 static int hf_gsm_a_sm_ip6_mask = -1;
229 static int hf_gsm_a_tft_protocol_header = -1;
230 static int hf_gsm_a_tft_port = -1;
231 static int hf_gsm_a_tft_port_low = -1;
232 static int hf_gsm_a_tft_port_high = -1;
233 static int hf_gsm_a_tft_security = -1;
234 static int hf_gsm_a_tft_traffic_mask = -1;
235 static int hf_gsm_a_tft_flow_label_type = -1;
236 static int hf_gsm_a_tft_param_id = -1;
237 static int hf_gsm_a_gm_acc_tech_type = -1;
238 static int hf_gsm_a_gm_acc_cap_struct_len = -1;
239 static int hf_gsm_a_gm_sms_value = -1;
240 static int hf_gsm_a_gm_sm_value = -1;
241 static int hf_gsm_a_gm_sm_ext = -1;
242 static int hf_gsm_a_gm_link_dir = -1;
243 static int hf_gsm_a_gm_cause = -1;
244
245 static int hf_gsm_a_gm_fop = -1;
246 static int hf_gsm_a_gm_res_of_attach = -1;
247 static int hf_gsm_a_gm_type_of_ciph_alg = -1;
248 static int hf_gsm_a_gm_imeisv_req = -1;
249 static int hf_gsm_a_gm_ac_ref_nr = -1;
250 static int hf_gsm_a_gm_force_to_standby = -1;
251 static int hf_gsm_a_gm_serv_type = -1;
252 static int hf_gsm_a_gm_ciph_key_seq_num = -1;
253 static int hf_gsm_a_gm_for = -1;
254 static int hf_gsm_a_gm_type_of_attach = -1;
255 static int hf_gsm_a_gm_tmsi_flag = -1;
256 static int hf_gsm_a_gm_update_type = -1;
257 static int hf_gsm_a_gm_gprs_timer_unit = -1;
258 static int hf_gsm_a_gm_gprs_timer_value = -1;
259 static int hf_gsm_a_gm_pco_pid = -1;
260 static int hf_gsm_a_gm_type_of_identity = -1;
261 static int hf_gsm_a_gm_rac = -1;
262 static int hf_gsm_a_gm_apc = -1;
263 static int hf_gsm_a_gm_otd_a = -1;
264 static int hf_gsm_a_gm_otd_b = -1;
265 static int hf_gsm_a_gm_gps_a = -1;
266 static int hf_gsm_a_gm_gps_b = -1;
267 static int hf_gsm_a_gm_gps_c = -1;
268 static int hf_gsm_a_sm_pdp_type_org = -1;
269 static int hf_gsm_a_qos_mean_thr = -1;
270 static int hf_gsm_a_qos_peak_thr = -1;
271 static int hf_gsm_a_qos_prec_class = -1;
272 static int hf_gsm_a_qos_traf_handl_prio = -1;
273 static int hf_gsm_a_qos_trans_delay = -1;
274 static int hf_gsm_a_qos_signalling_ind = -1;
275 static int hf_gsm_a_qos_source_stat_desc = -1;
276 static int hf_gsm_a_qos_max_bitrate_upl = -1;
277 static int hf_gsm_a_qos_max_bitrate_downl = -1;
278 static int hf_gsm_a_qos_guar_bitrate_upl = -1;
279 static int hf_gsm_a_qos_guar_bitrate_downl = -1;
280 static int hf_gsm_a_qos_max_bitrate_upl_ext = -1;
281 static int hf_gsm_a_qos_max_bitrate_downl_ext = -1;
282 static int hf_gsm_a_qos_guar_bitrate_upl_ext = -1;
283 static int hf_gsm_a_qos_guar_bitrate_downl_ext = -1;
284 static int hf_gsm_a_sm_cause = -1;
285 static int hf_gsm_a_sm_cause_2 = -1;
286 static int hf_gsm_a_sm_llc_sapi = -1;
287 static int hf_gsm_a_sm_tdi = -1;
288 static int hf_gsm_a_sm_packet_flow_id = -1;
289 static int hf_gsm_a_sm_tmgi = -1;
290 static int hf_gsm_a_sm_enh_nsapi = -1;
291 static int hf_gsm_a_sm_req_type = -1;
292 static int hf_gsm_a_gm_rac_ctrled_early_cm_sending = -1;
293 static int hf_gsm_a_gm_rac_multislot_capability = -1;
294 static int hf_gsm_a_gm_rac_single_slt_dtm = -1;
295 static int hf_gsm_a_gm_rac_dtm_egprs_multi_slot_cls_pres = -1;
296 static int hf_gsm_a_gm_rac_8psk_pow_cap_pres = -1;
297 static int hf_gsm_a_gm_rac_comp_int_meas_cap = -1;
298 static int hf_gsm_a_gm_rel_lev_ind = -1;
299 static int hf_gsm_a_gm_rac_geran_feat_pkg = -1;
300 static int hf_gsm_a_gm_rac_umts_fdd_cap = -1;
301 static int hf_gsm_a_gm_rac_umts_384_tdd_ra_cap = -1;
302 static int hf_gsm_a_gm_rac_cdma2000_cap = -1;
303 static int hf_gsm_a_gm_rac_umts_128_tdd_ra_cap = -1;
304
305 static int hf_gsm_a_gmm_net_cap_gea1 = -1;
306 static int hf_gsm_a_gmm_net_cap_smdch = -1;
307 static int hf_gsm_a_gmm_net_cap_smgprs = -1;
308 static int hf_gsm_a_gmm_net_cap_ucs2 = -1;
309 static int hf_gsm_a_gmm_net_cap_ss_scr_ind = -1;
310 static int hf_gsm_a_gmm_net_cap_solsa = -1;
311 static int hf_gsm_a_gmm_net_cap_rev = -1;
312 static int hf_gsm_a_gmm_net_cap_pfc = -1;
313 static int hf_gsm_a_gmm_net_cap_ext_gea_bits = -1;
314 static int hf_gsm_a_gmm_net_cap_gea2 = -1;
315 static int hf_gsm_a_gmm_net_cap_gea3 = -1;
316 static int hf_gsm_a_gmm_net_cap_gea4 = -1;
317 static int hf_gsm_a_gmm_net_cap_gea5 = -1;
318 static int hf_gsm_a_gmm_net_cap_gea6 = -1;
319 static int hf_gsm_a_gmm_net_cap_gea7 = -1;
320 static int hf_gsm_a_gmm_net_cap_lcs = -1;
321 static int hf_gsm_a_gmm_net_cap_ps_irat_iu = -1;
322 static int hf_gsm_a_gmm_net_cap_ps_irat_s1 = -1;
323 static int hf_gsm_a_gmm_net_cap_csfb = -1;
324 static int hf_gsm_a_gmm_net_cap_isr = -1;
325 static int hf_gsm_a_gmm_net_cap_srvcc_to_geran = -1;
326 static int hf_gsm_a_gmm_net_cap_epc = -1;
327
328 /* Initialize the subtree pointers */
329 static gint ett_tc_component = -1;
330 static gint ett_tc_invoke_id = -1;
331 static gint ett_tc_linked_id = -1;
332 static gint ett_tc_opr_code = -1;
333 static gint ett_tc_err_code = -1;
334 static gint ett_tc_prob_code = -1;
335 static gint ett_tc_sequence = -1;
336
337 static gint ett_gmm_drx = -1;
338 static gint ett_gmm_detach_type = -1;
339 static gint ett_gmm_attach_type = -1;
340 static gint ett_gmm_context_stat = -1;
341 static gint ett_gmm_update_type = -1;
342 static gint ett_gmm_radio_cap = -1;
343 static gint ett_gmm_network_cap = -1;
344 static gint ett_gsm_a_gm_msrac_multislot_capability = -1;
345 static gint ett_gmm_rai = -1;
346 static gint ett_gmm_gprs_timer = -1;
347
348 static gint ett_sm_tft = -1;
349
350 static dissector_handle_t data_handle;
351 static dissector_handle_t rrc_irat_ho_info_handle;
352
353 static dissector_table_t gprs_sm_pco_subdissector_table; /* GPRS SM PCO PPP Protocols */
354
355 #define NUM_GSM_GM_ELEM (sizeof(gsm_gm_elem_strings)/sizeof(value_string))
356 gint ett_gsm_gm_elem[NUM_GSM_GM_ELEM];
357
358 static const gchar *pdp_str[2]={ "PDP-INACTIVE", "PDP-ACTIVE" };
359
360 /*
361  * [9] 10.5.5.1 Attach result
362  */
363 static const value_string gsm_a_gm_res_of_attach_vals[] = {
364         { 0x01, "GPRS only attached" },
365         { 0x03, "Combined GPRS/IMSI attached" },
366         { 0, NULL }
367 };
368
369 static guint16
370 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_)
371 {
372         proto_tree_add_item(tree, hf_gsm_a_gm_fop, tvb, offset, 1, FALSE);
373         proto_tree_add_item(tree, hf_gsm_a_gm_res_of_attach, tvb, offset, 1, FALSE);
374
375         /* no length check possible */
376         return(1);
377 }
378
379 /*
380  * [9] 10.5.5.2 Attach type
381  */
382 static const value_string gsm_a_gm_type_of_attach_vals[] = {
383         { 0x01, "GPRS attach" },
384         { 0x02, "Not used (In earlier versions: GPRS attach while IMSI attached)" },
385         { 0x03, "Combined GPRS/IMSI attached" },
386         { 0, NULL }
387 };
388
389 static guint16
390 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_)
391 {
392         proto_item   *tf = NULL;
393         proto_tree   *tf_tree = NULL;
394
395         proto_tree_add_bits_item(tree, hf_gsm_a_gm_ciph_key_seq_num, tvb, offset << 3, 4, FALSE);
396
397         tf = proto_tree_add_text(tree,
398                 tvb, offset, 1,
399                 "Attach Type");
400
401         tf_tree = proto_item_add_subtree(tf, ett_gmm_attach_type );
402
403         proto_tree_add_item(tf_tree, hf_gsm_a_gm_for, tvb, offset, 1, FALSE);
404         proto_tree_add_item(tf_tree, hf_gsm_a_gm_type_of_attach, tvb, offset, 1, FALSE);
405
406         /* no length check possible */
407         return(1);
408 }
409
410 /*
411  * [9] 10.5.5.3 Ciphering algorithm
412  */
413 const value_string gsm_a_gm_type_of_ciph_alg_vals[] = {
414         { 0x00, "ciphering not used" },
415         { 0x01, "GPRS Encryption Algorithm GEA/1" },
416         { 0x02, "GPRS Encryption Algorithm GEA/2" },
417         { 0x03, "GPRS Encryption Algorithm GEA/3" },
418         { 0x04, "GPRS Encryption Algorithm GEA/4" },
419         { 0x05, "GPRS Encryption Algorithm GEA/5" },
420         { 0x06, "GPRS Encryption Algorithm GEA/6" },
421         { 0x07, "GPRS Encryption Algorithm GEA/7" },
422         { 0, NULL }
423 };
424
425 static guint16
426 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_)
427 {
428         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (offset << 3) + 4, 1, FALSE);
429         proto_tree_add_item(tree, hf_gsm_a_gm_type_of_ciph_alg, tvb, offset, 1, FALSE);
430
431         /* no length check possible */
432         return(1);
433 }
434
435 /*
436  * [9] 10.5.5.4 TMSI status
437  */
438 const true_false_string gsm_a_gm_tmsi_flag_value = {
439         "valid TMSI available",
440         "no valid TMSI available"
441 };
442
443 static guint16
444 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_)
445 {
446         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (offset << 3) + 4, 3, FALSE);
447         proto_tree_add_item(tree, hf_gsm_a_gm_tmsi_flag, tvb, offset, 1, FALSE);
448
449         /* no length check possible */
450         return(1);
451 }
452
453 /*
454  * [7] 10.5.5.5
455  */
456 static guint16
457 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_)
458 {
459         guint8        oct;
460         guint32       curr_offset;
461         const gchar  *str;
462         const gchar  *str_power;
463         proto_item   *tf = NULL;
464         proto_tree   *tf_tree = NULL;
465
466         curr_offset = offset;
467
468         oct = tvb_get_guint8(tvb, curr_offset);
469
470         switch(oct&7)
471         {
472                 case 1:  str="GPRS detach/re-attach required";                            break;
473                 case 2:  str="IMSI detach/re-attach not required";                        break;
474                 case 3:  str="Combined GPRS/IMSI detach/IMSI detach (after VLR failure)"; break;
475                 default: str="Combined GPRS/IMSI detach/re-attach not required";
476         }
477
478         switch(oct&8)
479         {
480                 case 8:  str_power="power switched off"; break;
481                 default: str_power="normal detach";      break;
482         }
483
484         tf = proto_tree_add_text(tree,
485                 tvb, curr_offset, 1,
486                 "Detach Type");
487
488         tf_tree = proto_item_add_subtree(tf, ett_gmm_detach_type );
489
490         proto_tree_add_text(tf_tree,
491                 tvb, curr_offset, 1,
492                 "Type: %s (%u)",
493                 str,
494                 oct&7);
495
496         proto_tree_add_text(tf_tree,
497                 tvb, curr_offset, 1,
498                 "Power: %s (%u)",
499                 str_power,
500                 (oct>>3)&1);
501
502         curr_offset++;
503
504         /* no length check possible */
505
506         return(curr_offset - offset);
507 }
508
509 /*
510  * [7] 10.5.5.6
511  *
512  * SPLIT on CCCH, octet 3 (bit 4)
513  * 0 Split pg cycle on CCCH is not supported by the mobile station
514  * 1 Split pg cycle on CCCH is supported by the mobile station
515  */
516 static const true_false_string gsm_a_gmm_split_on_ccch_value  = {
517         "Split pg cycle on CCCH is supported by the mobile station",
518         "Split pg cycle on CCCH is not supported by the mobile station"
519 };
520
521 /* non-DRX timer, octet 3
522  * bit
523  * 3 2 1
524  */
525 static const value_string gsm_a_gmm_non_drx_timer_strings[] = {
526         { 0x00, "no non-DRX mode after transfer state" },
527         { 0x01, "max. 1 sec non-DRX mode after transfer state" },
528         { 0x02, "max. 2 sec non-DRX mode after transfer state" },
529         { 0x03, "max. 4 sec non-DRX mode after transfer state" },
530         { 0x04, "max. 8 sec non-DRX mode after transfer state" },
531         { 0x05, "max. 16 sec non-DRX mode after transfer state" },
532         { 0x06, "max. 32 sec non-DRX mode after transfer state" },
533         { 0x07, "max. 64 sec non-DRX mode after transfer state" },
534         { 0, NULL },
535 };
536 /*
537  * CN Specific DRX cycle length coefficient, octet 3
538  * bit
539  * 8 7 6 5 Iu mode specific
540  * 0 0 0 0 CN Specific DRX cycle length coefficient not specified by the MS, ie. the
541  * system information value 'CN domain specific DRX cycle length' is used.
542  * (Ref 3GPP TS 25.331)
543  * 0 1 1 0 CN Specific DRX cycle length coefficient 6
544  * 0 1 1 1 CN Specific DRX cycle length coefficient 7
545  * 1 0 0 0 CN Specific DRX cycle length coefficient 8
546  * 1 0 0 1 CN Specific DRX cycle length coefficient 9
547  * All other values shall be interpreted as "CN Specific DRX cycle length coefficient not
548  * specified by the MS " by this version of the protocol.
549  * NOTE: In Iu mode this field (octet 3 bits 8 to 5) is used, but was spare in earlier
550  * versions of this protocol.
551  */
552 static const range_string gsm_a_gmm_cn_spec_drs_cycle_len_coef_strings[] = {
553         { 0x00, 0x05, "CN Specific DRX cycle length coefficient not specified by the MS" },
554         { 0x06, 0x06, "CN Specific DRX cycle length coefficient 6" },
555         { 0x07, 0x07, "CN Specific DRX cycle length coefficient 7" },
556         { 0x08, 0x08, "CN Specific DRX cycle length coefficient 8" },
557         { 0x09, 0x09, "CN Specific DRX cycle length coefficient 9" },
558         { 0x0a, 0x0f, "CN Specific DRX cycle length coefficient not specified by the MS" },
559         { 0, 0, NULL },
560 };
561 guint16
562 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_)
563 {
564         guint8        oct;
565         guint32       curr_offset;
566         const gchar  *str;
567         proto_item   *tf = NULL;
568         proto_tree   *tf_tree = NULL;
569
570         curr_offset = offset;
571
572         tf = proto_tree_add_text(tree,
573                 tvb, curr_offset, 2,
574                 "DRX Parameter");
575
576         tf_tree = proto_item_add_subtree(tf, ett_gmm_drx );
577
578         oct = tvb_get_guint8(tvb, curr_offset);
579
580         switch(oct)
581         {
582                 case 0:  str="704"; break;
583                 case 65: str="71";  break;
584                 case 66: str="72";  break;
585                 case 67: str="74";  break;
586                 case 68: str="75";  break;
587                 case 69: str="77";  break;
588                 case 70: str="79";  break;
589                 case 71: str="80";  break;
590                 case 72: str="83";  break;
591                 case 73: str="86";  break;
592                 case 74: str="88";  break;
593                 case 75: str="90";  break;
594                 case 76: str="92";  break;
595                 case 77: str="96";  break;
596                 case 78: str="101"; break;
597                 case 79: str="103"; break;
598                 case 80: str="107"; break;
599                 case 81: str="112"; break;
600                 case 82: str="116"; break;
601                 case 83: str="118"; break;
602                 case 84: str="128"; break;
603                 case 85: str="141"; break;
604                 case 86: str="144"; break;
605                 case 87: str="150"; break;
606                 case 88: str="160"; break;
607                 case 89: str="171"; break;
608                 case 90: str="176"; break;
609                 case 91: str="192"; break;
610                 case 92: str="214"; break;
611                 case 93: str="224"; break;
612                 case 94: str="235"; break;
613                 case 95: str="256"; break;
614                 case 96: str="288"; break;
615                 case 97: str="320"; break;
616                 case 98: str="352"; break;
617                 default: str="Reserved, interpreted as 1";
618         }
619
620         proto_tree_add_text(tf_tree,
621                 tvb, curr_offset, 1,
622                 "Split PG Cycle Code: %s (%u)",
623                 str,
624                 oct);
625
626         curr_offset++;
627         proto_tree_add_item(tf_tree, hf_gsm_a_gmm_cn_spec_drs_cycle_len_coef, tvb, curr_offset, 1, FALSE);
628         proto_tree_add_item(tf_tree, hf_gsm_a_gmm_split_on_ccch, tvb, curr_offset, 1, FALSE);
629         proto_tree_add_item(tf_tree, hf_gsm_a_gmm_non_drx_timer, tvb, curr_offset, 1, FALSE);
630
631         curr_offset++;
632
633         /* no length check possible */
634
635         return(curr_offset - offset);
636 }
637
638 /*
639  * [9] 10.5.5.7 Force to standby (lower nibble)
640  */
641 static const range_string gsm_a_gm_force_to_standby_vals[] = {
642         { 0x00, 0x00, "Force to standby not indicated" },
643         { 0x01, 0x01, "Force to standby indicated" },
644         { 0x02, 0x07, "Unknown, interpreted as Force to standby not indicated" },
645         { 0, 0, NULL }
646 };
647
648 static guint16
649 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_)
650 {
651         guint32 bit_offset;
652
653         /* IMPORTANT - IT'S ASSUMED THAT THE INFORMATION IS IN THE LOWER NIBBLE */
654         bit_offset = (offset << 3) + 4;
655         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, bit_offset, 1, FALSE);
656         proto_tree_add_bits_item(tree, hf_gsm_a_gm_force_to_standby, tvb, bit_offset + 1, 3, FALSE);
657
658         /* no length check possible */
659         return(1);
660 }
661
662 /*
663  * [9] 10.5.5.7 Force to standby (higher nibble)
664  */
665 static guint16
666 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_)
667 {
668         guint32 bit_offset;
669
670         /* IMPORTANT - IT'S ASSUMED THAT THE INFORMATION IS IN THE HIGHER NIBBLE */
671         bit_offset = offset << 3;
672         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, bit_offset, 1, FALSE);
673         proto_tree_add_bits_item(tree, hf_gsm_a_gm_force_to_standby, tvb, bit_offset + 1, 3, FALSE);
674
675         /* no length check possible */
676         return(1);
677 }
678
679 /*
680  * [7] 10.5.5.8
681  */
682 static guint16
683 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_)
684 {
685         guint32       curr_offset;
686         proto_item   *curr_item;
687
688         curr_offset = offset;
689
690         curr_item= proto_tree_add_item(tree,hf_gsm_a_ptmsi_sig,tvb,curr_offset,3,FALSE);
691         proto_item_append_text(curr_item,"%s",add_string ? add_string : "");
692
693         curr_offset+=3;
694
695         /* no length check possible */
696
697         return(curr_offset - offset);
698 }
699
700 /*
701  * [7] 10.5.5.8a
702  */
703 static guint16
704 de_gmm_ptmsi_sig2(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string, int string_len _U_)
705 {
706         guint32       curr_offset;
707         proto_item   *curr_item;
708
709         curr_offset = offset;
710
711         curr_item= proto_tree_add_item(tree,hf_gsm_a_ptmsi_sig2,tvb,curr_offset,3,FALSE);
712         proto_item_append_text(curr_item,"%s",add_string ? add_string : "");
713         curr_offset+=3;
714
715         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
716
717         return(curr_offset - offset);
718 }
719
720 /*
721  * [9] 10.5.5.9 Identity type 2
722  */
723 static const value_string gsm_a_gm_type_of_identity_vals[] = {
724         { 0x01, "IMSI" },
725         { 0x02, "IMEI" },
726         { 0x03, "IMEISV" },
727         { 0x04, "TMSI" },
728         { 0, NULL }
729 };
730
731 static guint16
732 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_)
733 {
734         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (offset << 3) + 4, 1, FALSE);
735         proto_tree_add_item(tree, hf_gsm_a_gm_type_of_identity, tvb, offset, 1, FALSE);
736
737         /* no length check possible */
738         return(1);
739 }
740
741 /*
742  * [9] 10.5.5.10 IMEISV request
743  */
744 static const range_string gsm_a_gm_imeisv_req_vals[] = {
745         { 0x00, 0x00, "IMEISV not requested" },
746         { 0x01, 0x01, "IMEISV requested" },
747         { 0x02, 0x07, "Unknown, interpreted as IMEISV not requested" },
748         { 0, 0, NULL }
749 };
750
751 static guint16
752 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_)
753 {
754         guint32 bit_offset;
755
756         /* IMPORTANT - IT'S ASSUMED THAT THE INFORMATION IS IN THE HIGHER NIBBLE */
757         bit_offset = offset << 3;
758         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, bit_offset, 1, FALSE);
759         proto_tree_add_bits_item(tree, hf_gsm_a_gm_imeisv_req, tvb, bit_offset + 1, 3, FALSE);
760
761         /* no length check possible */
762         return(1);
763 }
764
765 /*
766  * [7] 10.5.5.11
767  */
768 static guint16
769 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_)
770 {
771         guint32 curr_offset;
772         guint   curr_len;
773
774         curr_len = len;
775         curr_offset = offset;
776
777         if ( len == 0 ) return 0;
778
779         do
780         {
781                 guint32 oct;
782                 oct = tvb_get_guint8(tvb, curr_offset);
783                 oct <<=8;
784                 oct |= tvb_get_guint8(tvb, curr_offset+1);
785                 curr_len -= 2;
786                 oct <<=8;
787
788                 proto_tree_add_text(tree,
789                         tvb, curr_offset, 2,
790                         "NSAPI %d: 0x%02x (%u)",
791                         oct>>20,
792                         (oct>>12)&0xff,
793                         (oct>>12)&0xff);
794                 curr_offset+= 2;
795
796                 if ( curr_len > 2 )
797                 {
798                         oct |= tvb_get_guint8(tvb, curr_offset+2);
799                         curr_len--;
800                         oct <<= 12;
801
802                         proto_tree_add_text(tree,
803                                 tvb, curr_offset-1, 2,
804                                 "NSAPI %d: 0x%02x (%u)",
805                                 oct>>20,
806                                 (oct>>12)&0xff,
807                                 (oct>>12)&0xff);
808                         curr_offset++;
809                 }
810
811         } while ( curr_len > 1 );
812
813         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
814
815         return(curr_offset - offset);
816 }
817
818 /*
819  * [9] 10.5.5.12 MS network capability
820  */
821 static const true_false_string gsm_a_gmm_net_cap_gea_vals = {
822         "Encryption algorithm available",
823         "Encryption algorithm not available"
824 };
825
826 static const true_false_string gsm_a_gmm_net_cap_smdch_vals = {
827         "Mobile station supports mobile terminated point to point SMS via dedicated signalling channels",
828         "Mobile station does not support mobile terminated point to point SMS via dedicated signalling channels"
829 };
830
831 static const true_false_string gsm_a_gmm_net_cap_smgprs_vals = {
832         "Mobile station supports mobile terminated point to point SMS via GPRS packet data channels",
833         "Mobile station does not support mobile terminated point to point SMS via GPRS packet data channels"
834 };
835
836 static const true_false_string gsm_a_gmm_net_cap_ucs2_vals = {
837         "The ME has no preference between the use of the default alphabet and the use of UCS2",
838         "The ME has a preference for the default alphabet (defined in 3GPP TS 23.038 [8b]) over UCS2"
839 };
840
841 static const value_string gsm_a_gmm_net_cap_ss_scr_ind_vals[]={
842         { 0x00, "Default value of phase 1" },
843         { 0x01, "capability of handling of ellipsis notation and phase 2 error handling" },
844         { 0x02, "For future use, interpreted as Capability of handling of ellipsis notation and phase 2 error handling" },
845         { 0x03, "For future use, interpreted as Capability of handling of ellipsis notation and phase 2 error handling" },
846         { 0x00, NULL }
847 };
848
849 static const true_false_string gsm_a_gmm_net_cap_solsa_vals = {
850         "The ME supports SoLSA",
851         "The ME does not support SoLSA"
852 };
853
854 static const true_false_string gsm_a_gmm_net_cap_rev_vals = {
855         "Used by a mobile station supporting R99 or later versions of the protocol",
856         "Used by a mobile station not supporting R99 or later versions of the protocol"
857 };
858
859 static const true_false_string gsm_a_gmm_net_cap_pfc_vals = {
860         "Mobile station does support BSS packet flow procedures",
861         "Mobile station does not support BSS packet flow procedures"
862 };
863
864 static const true_false_string gsm_a_gmm_net_cap_lcs_vals = {
865         "LCS value added location request notification capability supported",
866         "LCS value added location request notification capability not supported"
867 };
868
869 static const true_false_string gsm_a_gmm_net_cap_ps_irat_iu_vals = {
870         "PS inter-RAT HO to UTRAN Iu mode supported",
871         "PS inter-RAT HO to UTRAN Iu mode not supported"
872 };
873
874 static const true_false_string gsm_a_gmm_net_cap_ps_irat_s1_vals = {
875         "PS inter-RAT HO to E-UTRAN S1 mode supported",
876         "PS inter-RAT HO to E-UTRAN S1 mode not supported"
877 };
878
879 static const true_false_string gsm_a_gmm_net_cap_csfb_vals = {
880         "Mobile station supports CS fallback",
881         "Mobile station does not support CS fallback"
882 };
883
884 static const true_false_string gsm_a_gmm_net_cap_isr_vals = {
885         "The mobile station supports ISR",
886         "The mobile station does not support ISR"
887 };
888
889 static const true_false_string gsm_a_gmm_net_cap_srvcc_to_geran_vals = {
890         "SRVCC from UTRAN HSPA or E-UTRAN to GERAN/UTRAN supported",
891         "SRVCC from UTRAN HSPA or E-UTRAN to GERAN/UTRAN not supported"
892 };
893
894 static const true_false_string gsm_a_gmm_net_cap_epc_vals = {
895         "EPC supported",
896         "EPC not supported"
897 };
898
899 guint16
900 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_)
901 {
902         guint32 curr_offset;
903         proto_tree      *subtree;
904         proto_item      *item;
905
906         curr_offset = offset;
907
908         /* bit 8: GEA1 */
909         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_gea1, tvb, curr_offset, 1, FALSE);
910
911         /* bit 7: SM capabilities via dedicated channels */
912         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_smdch, tvb, curr_offset, 1, FALSE);
913
914         /* bit 6: SM capabilities via GPRS channels */
915         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_smgprs, tvb, curr_offset, 1, FALSE);
916
917         /* bit 5: UCS2 support */
918         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_ucs2, tvb, curr_offset, 1, FALSE);
919
920         /* bits 4 3: SS Screening Indicator */
921         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_ss_scr_ind, tvb, curr_offset, 1, FALSE);
922
923         /* bit 2: SoLSA Capability */
924         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_solsa, tvb, curr_offset, 1, FALSE);
925
926         /* bit 1 */
927         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_rev, tvb, curr_offset, 1, FALSE);
928
929         curr_offset++;
930         NO_MORE_DATA_CHECK(len);
931
932         /* bit 8: PFC feature mode */
933         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_pfc, tvb, curr_offset, 1, FALSE);
934
935         /* bits 7 6 5 4 3 2: Extended GEA bits */
936         item = proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_ext_gea_bits, tvb, curr_offset, 1, FALSE);
937         subtree = proto_item_add_subtree(item, ett_gmm_network_cap);
938         proto_tree_add_item(subtree, hf_gsm_a_gmm_net_cap_gea2, tvb, curr_offset, 1, FALSE);
939         proto_tree_add_item(subtree, hf_gsm_a_gmm_net_cap_gea3, tvb, curr_offset, 1, FALSE);
940         proto_tree_add_item(subtree, hf_gsm_a_gmm_net_cap_gea4, tvb, curr_offset, 1, FALSE);
941         proto_tree_add_item(subtree, hf_gsm_a_gmm_net_cap_gea5, tvb, curr_offset, 1, FALSE);
942         proto_tree_add_item(subtree, hf_gsm_a_gmm_net_cap_gea6, tvb, curr_offset, 1, FALSE);
943         proto_tree_add_item(subtree, hf_gsm_a_gmm_net_cap_gea7, tvb, curr_offset, 1, FALSE);
944
945         /* bit 1: LCS VA capability */
946         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_lcs, tvb, curr_offset, 1, FALSE);
947
948         curr_offset++;
949         NO_MORE_DATA_CHECK(len);
950
951         /* bit 8: PS inter-RAT HO to UTRAN Iu mode capability */
952         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_ps_irat_iu, tvb, curr_offset, 1, FALSE);
953
954         /* bit 7: PS inter-RAT HO to E-UTRAN S1 mode capability */
955         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_ps_irat_s1, tvb, curr_offset, 1, FALSE);
956
957         /* bit 6: CSFB Capability */
958         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_csfb, tvb, curr_offset, 1, FALSE);
959
960         /* bit 5: ISR support */
961         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_isr, tvb, curr_offset, 1, FALSE);
962
963         /* bit 4: SRVCC to GERAN/UTRAN capability */
964         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_srvcc_to_geran, tvb, curr_offset, 1, FALSE);
965
966         /* bit 3: EPC capability */
967         proto_tree_add_item(tree, hf_gsm_a_gmm_net_cap_epc, tvb, curr_offset, 1, FALSE);
968
969         /* bits 2 1: Spare bits */
970         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (curr_offset<<3)+6, 2, FALSE);
971
972         curr_offset++;
973         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
974
975         return(curr_offset - offset);
976 }
977
978 /*
979  * [7] 10.5.5.12a
980  */
981 #define GET_DATA                                /* check if we have enough bits left */ \
982         if ( curr_bits_length < bits_needed ) \
983                 continue; \
984         /* check if oct has enougth bits */ \
985         if ( bits_in_oct < bits_needed ) \
986         { \
987                 guint32 tmp_oct; \
988                 if ( curr_len == 0 ) \
989                 { \
990                         proto_tree_add_text(tf_tree, \
991                                 tvb, curr_offset, 1, \
992                                 "Not enough data available"); \
993                 } \
994                 tmp_oct = tvb_get_guint8(tvb, curr_offset); \
995                 oct |= tmp_oct<<(32-8-bits_in_oct); \
996                 curr_len--; \
997                 curr_offset++; \
998                 if ( bits_in_oct != 0 ) \
999                         add_ocetets = 1; \
1000                 else \
1001                         add_ocetets = 0; \
1002                 bits_in_oct += 8; \
1003         } \
1004         else \
1005                 add_ocetets = 0;
1006
1007 /* Access Technology Type */
1008
1009 static const value_string gsm_a_gm_acc_tech_type_vals[] = {
1010         { 0x00, "GSM P" },
1011         { 0x01, "GSM E --note that GSM E covers GSM P" },
1012         { 0x02, "GSM R --note that GSM R covers GSM E and GSM P" },
1013         { 0x03, "GSM 1800" },
1014         { 0x04, "GSM 1900" },
1015         { 0x05, "GSM 450" },
1016         { 0x06, "GSM 480" },
1017         { 0x07, "GSM 850" },
1018         { 0x08, "GSM 750" },
1019         { 0x09, "GSM T 380" },
1020         { 0x0a, "GSM T 410" },
1021         { 0x0b, "GSM T 900" },
1022         { 0x0c, "GSM 710" },
1023         { 0x0d, "GSM T 810" },
1024         { 0x0f, "Indicates the presence of a list of Additional access technologies" },
1025         { 0, NULL }
1026 };
1027
1028 static const value_string gsm_a_gm_revision_level_indicator_vals[] = {
1029         { 0x00, "The ME is Release '98 or older" },
1030         { 0x01, "The ME is Release '99 onwards" },
1031
1032         { 0, NULL }
1033 };
1034 guint16
1035 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_)
1036 {
1037         guint32      curr_offset;
1038         guint        curr_len;
1039         int          bit_offset;
1040         proto_item  *tf = NULL, *mc_item = NULL;
1041         proto_tree  *tf_tree = NULL, *mc_tree = NULL;
1042         guint32      oct;
1043         guchar       bits_in_oct;
1044         guchar       bits_needed;
1045         guint        bits_length;
1046         guint        add_ocetets;       /* octets which are covered by one element -1 */
1047         guint        curr_bits_length;
1048         guchar       acc_type;
1049         guint        value;
1050         const gchar *str;
1051         /** XXX: AFAIT only the first 32 entries of the following are actually used. Is this a bug someplace ?? */
1052         static const gchar *multi_slot_str[64] = {
1053                 "Not specified", /* 00 */
1054                 "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", /* 01 */
1055                 "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", /* 02 */
1056                 "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", /* 03 */
1057                 "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", /* 04 */
1058                 "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", /* 05 */
1059                 "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", /* 06 */
1060                 "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", /* 07 */
1061                 "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", /* 08 */
1062                 "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", /* 09 */
1063                 "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", /* 10 */
1064                 "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", /* 11 */
1065                 "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", /* 12 */
1066                 "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)", /* 13 */
1067                 "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)", /* 14 */
1068                 "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)", /* 15 */
1069                 "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)", /* 16 */
1070                 "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)", /* 17 */
1071                 "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", /* 18 */
1072                 "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", /* 19 */
1073                 "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", /* 20 */
1074                 "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", /* 21 */
1075                 "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", /* 22 */
1076                 "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", /* 23 */
1077                 "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", /* 24 */
1078                 "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", /* 25 */
1079                 "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", /* 26 */
1080                 "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", /* 27 */
1081                 "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", /* 28 */
1082                 "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", /* 29 */
1083                 "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", /* 30 */
1084                 "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", /* 31 */
1085                 "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", /* 32 */
1086                 "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", /* 33 */
1087                 "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", /* 34 */
1088                 "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))", /* 35 */
1089                 "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))", /* 36 */
1090                 "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))", /* 37 */
1091                 "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))", /* 38 */
1092                 "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))", /* 39 */
1093                 "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))", /* 40 */
1094                 "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))", /* 41 */
1095                 "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))", /* 42 */
1096                 "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))", /* 43 */
1097                 "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))", /* 44 */
1098                 "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))", /* 45 */
1099                 "Not specified", /* 46 */
1100                 "Not specified", /* 47 */
1101                 "Not specified", /* 48 */
1102                 "Not specified", /* 49 */
1103                 "Not specified", /* 50 */
1104                 "Not specified", /* 51 */
1105                 "Not specified", /* 52 */
1106                 "Not specified", /* 53 */
1107                 "Not specified", /* 54 */
1108                 "Not specified", /* 55 */
1109                 "Not specified", /* 56 */
1110                 "Not specified", /* 57 */
1111                 "Not specified", /* 58 */
1112                 "Not specified", /* 59 */
1113                 "Not specified", /* 60 */
1114                 "Not specified", /* 61 */
1115                 "Not specified", /* 62 */
1116                 "Not specified", /* 63 */
1117         };
1118         guint indx = 0;
1119         guchar dtm_gprs_mslot = 0;
1120         guchar dtm_egprs_mslot = 4;
1121         gboolean finished = TRUE;
1122
1123         curr_len = len;
1124         curr_offset = offset;
1125         bit_offset = offset<<3;
1126
1127         bits_in_oct = 0;
1128         oct = 0;
1129
1130
1131         do
1132         {
1133                 /* check for a new round */
1134                 if (( curr_len*8 + bits_in_oct ) < 11 )
1135                         break;
1136
1137                 /* now read the first 11 bits */
1138                 curr_bits_length = 11;
1139                 /*
1140                  *
1141                  */
1142                 if ( curr_len != len )
1143                 {
1144                         bits_needed = 1;
1145                         GET_DATA;
1146
1147                         if (( oct>>(32-bits_needed) ) == 1 )
1148                         {
1149                                 curr_bits_length -= bits_needed;
1150                                 oct <<= bits_needed;
1151                                 bits_in_oct -= bits_needed;
1152                                 bit_offset++;
1153
1154                                 if (( curr_len*8 + bits_in_oct ) < 11 )
1155                                         break;
1156                                 curr_bits_length = 11;
1157                         }
1158                         else
1159                         {
1160                                 curr_bits_length -= bits_needed;
1161                                 oct <<= bits_needed;
1162                                 bits_in_oct -= bits_needed;
1163                                 bit_offset++;
1164                                 break;
1165                         }
1166                 }
1167
1168                 indx++;
1169                 tf = proto_tree_add_text(tree,
1170                                 tvb, curr_offset, 1,
1171                                 "MS RA capability %d",indx);
1172
1173                 tf_tree = proto_item_add_subtree(tf, ett_gmm_radio_cap );
1174
1175                 /*
1176                  * Access Technology
1177                  */
1178                 bits_needed = 4;
1179                 GET_DATA;
1180
1181                 acc_type = oct>>(32-bits_needed);
1182
1183                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_acc_tech_type, tvb, bit_offset, 4, FALSE);
1184                 bit_offset+=4;
1185
1186                 curr_bits_length -= bits_needed;
1187                 oct <<= bits_needed;
1188                 bits_in_oct -= bits_needed;
1189
1190                 /* < Access capabilities struct > ::= */
1191                 /*
1192                  * get bits_length
1193                  */
1194                 bits_needed = 7;
1195                 GET_DATA;
1196
1197                 bits_length = curr_bits_length = oct>>(32-bits_needed);
1198                 
1199                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_acc_cap_struct_len, tvb, bit_offset, 7, FALSE);
1200                 proto_item_set_len(tf, (bits_length>>3)+1);
1201                 /* This is already done - length doesn't contain this field
1202                  curr_bits_length -= bits_needed;
1203                 */
1204                 bit_offset+=7;
1205                 oct <<= bits_needed;
1206                 bits_in_oct -= bits_needed;
1207
1208                 if ( acc_type == 0x0f )
1209                 {
1210                         do
1211                         {
1212                                 /*
1213                                  * Additional access technologies:
1214                                  */
1215                                 finished = TRUE; /* Break out of the loop unless proven unfinished */
1216
1217                                 /*
1218                                  * Presence bit
1219                                  */
1220                                 bits_needed = 1;
1221                                 GET_DATA;
1222
1223                                 /* analyse bits */
1224                                 switch ( oct>>(32-bits_needed) )
1225                                 {
1226                                         case 0x00: str="Not Present"; finished = TRUE; break;
1227                                         case 0x01: str="Present"; finished = FALSE;    break;
1228                                         default:   str="This should not happen";
1229                                 }
1230
1231                                 proto_tree_add_text(tf_tree,
1232                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1233                                         "Presence: %s (%u)", str, oct>>(32-bits_needed));
1234                                 bit_offset++;
1235                                 curr_bits_length -= bits_needed;
1236                                 oct <<= bits_needed;
1237                                 bits_in_oct -= bits_needed;
1238
1239                                 if (finished)
1240                                 {
1241                                         /*
1242                                          * No more valid data, get spare bits if any
1243                                          */
1244                                         while ( curr_bits_length > 0 )
1245                                         {
1246                                                 if ( curr_bits_length > 8 )
1247                                                         bits_needed = 8;
1248                                                 else
1249                                                         bits_needed = curr_bits_length;
1250                                                 GET_DATA;
1251                                                 curr_bits_length -= bits_needed;
1252                                                 oct <<= bits_needed;
1253                                                 bits_in_oct -= bits_needed;
1254                                                 bit_offset+= bits_needed;
1255                                         }
1256                                         continue;
1257                                 }
1258
1259                                 /*
1260                                  * Access Technology
1261                                  */
1262                                 bits_needed = 4;
1263                                 GET_DATA;
1264
1265                                 acc_type = oct>>(32-bits_needed);
1266
1267                                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_acc_cap_struct_len, tvb, bit_offset, 7, FALSE);
1268                                 bit_offset+=4;
1269
1270                                 curr_bits_length -= bits_needed;
1271                                 oct <<= bits_needed;
1272                                 bits_in_oct -= bits_needed;
1273
1274                                 /*
1275                                  * RF Power
1276                                  */
1277                                 bits_needed = 3;
1278                                 GET_DATA;
1279
1280                                 value = tvb_get_bits8(tvb, bit_offset, 3);
1281                                 /* analyse bits */
1282                                 if ( acc_type == 0x04 ) /* GSM 1900 */
1283                                 {
1284                                         switch ( value )
1285                                         {
1286                                                 case 0x01: str="1 W (30 dBm)";    break;
1287                                                 case 0x02: str="0,25 W (24 dBm)"; break;
1288                                                 case 0x03: str="2 W (33 dBm)";    break;
1289                                                 default:   str="Not specified";
1290                                         }
1291                                 }
1292                                 else if ( acc_type == 0x03 )
1293                                 {
1294                                         /*
1295                                          * 3 GSM 1800
1296                                          */
1297                                         switch ( value )
1298                                         {
1299                                                 case 0x01: str="1 W (30 dBm)";    break;
1300                                                 case 0x02: str="0,25 W (24 dBm)"; break;
1301                                                 case 0x03: str="4 W (36 dBm)";    break;
1302                                                 default:   str="Not specified";
1303                                         }
1304                                 }
1305                                 else if ( acc_type <= 0x08 )
1306                                 {
1307                                         /* 0 GSM P
1308                                          * 1 GSM E
1309                                          * 2 GSM R
1310                                          * 5 GSM 450
1311                                          * 6 GSM 480
1312                                          * 7 GSM 850
1313                                          */
1314
1315                                         switch ( value )
1316                                         {
1317                                                 case 0x02: str="8 W (39 dBm)";   break;
1318                                                 case 0x03: str="5 W (37 dBm)";   break;
1319                                                 case 0x04: str="2 W (33 dBm)";   break;
1320                                                 case 0x05: str="0,8 W (29 dBm)"; break;
1321                                                 default:   str="Not specified";
1322                                         }
1323                                 }
1324                                 else
1325                                         str="Not specified??";
1326
1327                                 /* decode_bits_in_field(gint bit_offset, gint no_of_bits, guint64 value)*/
1328                                 proto_tree_add_text(tf_tree,
1329                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1330                                         "%s RF Power Capability, GMSK Power Class: %s (%u)", decode_bits_in_field(bit_offset, 3, value), str, value);
1331                                 bit_offset+=3;
1332                                 curr_bits_length -= bits_needed;
1333                                 oct <<= bits_needed;
1334                                 bits_in_oct -= bits_needed;
1335
1336                                 /*
1337                                  * 8PSK Power Class
1338                                  */
1339                                 bits_needed = 2;
1340                                 GET_DATA;
1341
1342                                 value = tvb_get_bits8(tvb, bit_offset, 2);
1343                                 /* analyse bits */
1344                                 switch ( value )
1345                                 {
1346                                         case 0x00: str="8PSK modulation not supported for uplink"; break;
1347                                         case 0x01: str="Power class E1"; break;
1348                                         case 0x02: str="Power class E2"; break;
1349                                         case 0x03: str="Power class E3"; break;
1350                                         default:   str="This should not happen";
1351                                 }
1352
1353                                 proto_tree_add_text(tf_tree,
1354                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1355                                         "8PSK Power Class: %s (%u)",str,value);
1356                                 bit_offset+=2;
1357                                 curr_bits_length -= bits_needed;
1358                                 oct <<= bits_needed;
1359                                 bits_in_oct -= bits_needed;
1360
1361                         } while (!finished);
1362
1363                         /* goto next one */
1364                         continue;
1365                 }
1366                 /*
1367                  * RF Power
1368                  */
1369                 bits_needed = 3;
1370                 GET_DATA;
1371
1372                 value = tvb_get_bits8(tvb, bit_offset, 3);
1373                 /* analyse bits */
1374                 if ( acc_type == 0x04 ) /* GSM 1900 */
1375                 {
1376                         switch ( value )
1377                         {
1378                                 case 0x01: str="1 W (30 dBm)";    break;
1379                                 case 0x02: str="0,25 W (24 dBm)"; break;
1380                                 case 0x03: str="2 W (33 dBm)";    break;
1381                                 default:   str="Not specified";
1382                         }
1383                 }
1384                 else if ( acc_type == 0x03 )
1385                 {
1386                         switch ( value )
1387                         {
1388                                 case 0x01: str="1 W (30 dBm)";    break;
1389                                 case 0x02: str="0,25 W (24 dBm)"; break;
1390                                 case 0x03: str="4 W (36 dBm)";    break;
1391                                 default:   str="Not specified";
1392                         }
1393                 }
1394                 else if ( acc_type <= 0x08 )
1395                 {
1396                         switch ( value )
1397                         {
1398                                 case 0x02: str="8 W (39 dBm)";   break;
1399                                 case 0x03: str="5 W (37 dBm)";   break;
1400                                 case 0x04: str="2 W (33 dBm)";   break;
1401                                 case 0x05: str="0,8 W (29 dBm)"; break;
1402                                 default:   str="Not specified";
1403                         }
1404                 }
1405                 else
1406                         str="Not specified??";
1407
1408                 proto_tree_add_text(tf_tree,
1409                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1410                         "%s RF Power Capability, GMSK Power Class: %s (%u)", decode_bits_in_field(bit_offset, 3, value),str,value);
1411
1412                 bit_offset+=3;
1413                 curr_bits_length -= bits_needed;
1414                 oct <<= bits_needed;
1415                 bits_in_oct -= bits_needed;
1416
1417                 /*
1418                  * A5 Bits?
1419                  */
1420                 bits_needed = 1;
1421                 GET_DATA;
1422
1423                 /* analyse bits */
1424                 if ((oct>>(32-bits_needed))==0)
1425                 {
1426                         proto_tree_add_text(tf_tree,
1427                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1428                                 "A5 Bits: Same values apply for parameters as in the immediately preceding Access capabilities field within this IE (%u)",oct>>(32-bits_needed));
1429                         bit_offset++;
1430                         curr_bits_length -= bits_needed;
1431                         oct <<= bits_needed;
1432                         bits_in_oct -= bits_needed;
1433                 }
1434                 else
1435                 {
1436                         int i;
1437
1438                         proto_tree_add_text(tf_tree,
1439                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1440                                 "A5 Bits: A5 bits follow (%u)",oct>>(32-bits_needed));
1441
1442                         bit_offset++;
1443                         curr_bits_length -= bits_needed;
1444                         oct <<= bits_needed;
1445                         bits_in_oct -= bits_needed;
1446
1447                         for (i=1; i<= 7 ; i++ )
1448                         {
1449                                 /*
1450                                  * A5 Bits decoding
1451                                  */
1452                                 bits_needed = 1;
1453                                 GET_DATA;
1454
1455                                 /* analyse bits */
1456                                 switch ( oct>>(32-bits_needed) )
1457                                 {
1458                                         case 0x00: str="encryption algorithm not available"; break;
1459                                         case 0x01: str="encryption algorithm available";     break;
1460                                         default:   str="This should not happen";
1461                                 }
1462
1463                                 proto_tree_add_text(tf_tree,
1464                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1465                                         "A5/%d: %s (%u)",i,str,oct>>(32-bits_needed));
1466                                 bit_offset++;
1467                                 curr_bits_length -= bits_needed;
1468                                 oct <<= bits_needed;
1469                                 bits_in_oct -= bits_needed;
1470                         }
1471                 }
1472
1473                 /*
1474                  * ES IND
1475                  */
1476                 bits_needed = 1;
1477                 GET_DATA;
1478
1479                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_ctrled_early_cm_sending, tvb, bit_offset, 1, FALSE);
1480                 bit_offset++;
1481                 curr_bits_length -= bits_needed;
1482                 oct <<= bits_needed;
1483                 bits_in_oct -= bits_needed;
1484
1485                 /*
1486                  * PS
1487                  */
1488                 bits_needed = 1;
1489                 GET_DATA;
1490
1491                 /* analyse bits */
1492                 switch ( oct>>(32-bits_needed) )
1493                 {
1494                         case 0x00: str="PS capability not present"; break;
1495                         case 0x01: str="PS capability present";     break;
1496                         default:   str="This should not happen";
1497                 }
1498
1499                 proto_tree_add_text(tf_tree,
1500                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1501                         "Pseudo Synchronisation: %s (%u)",str,oct>>(32-bits_needed));
1502                 bit_offset++;
1503                 curr_bits_length -= bits_needed;
1504                 oct <<= bits_needed;
1505                 bits_in_oct -= bits_needed;
1506
1507                 /*
1508                  * VGCS
1509                  */
1510                 bits_needed = 1;
1511                 GET_DATA;
1512
1513                 /* analyse bits */
1514                 switch ( oct>>(32-bits_needed) )
1515                 {
1516                         case 0x00: str="no VGCS capability or no notifications wanted"; break;
1517                         case 0x01: str="VGCS capability and notifications wanted";      break;
1518                         default:   str="This should not happen";
1519                 }
1520
1521                 proto_tree_add_text(tf_tree,
1522                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1523                         "Voice Group Call Service: %s (%u)",str,oct>>(32-bits_needed));
1524                 bit_offset++;
1525                 curr_bits_length -= bits_needed;
1526                 oct <<= bits_needed;
1527                 bits_in_oct -= bits_needed;
1528
1529                 /*
1530                  * VBS
1531                  */
1532                 bits_needed = 1;
1533                 GET_DATA;
1534
1535                 /* analyse bits */
1536                 switch ( oct>>(32-bits_needed) )
1537                 {
1538                         case 0x00: str="no VBS capability or no notifications wanted"; break;
1539                         case 0x01: str="VBS capability and notifications wanted";      break;
1540                         default:   str="This should not happen";
1541                 }
1542
1543                 proto_tree_add_text(tf_tree,
1544                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1545                         "Voice Broadcast Service: %s (%u)",str,oct>>(32-bits_needed));
1546                 bit_offset++;
1547                 curr_bits_length -= bits_needed;
1548                 oct <<= bits_needed;
1549                 bits_in_oct -= bits_needed;
1550
1551                 /*
1552                  * Multislot capability?
1553                  */
1554                 bits_needed = 1;
1555                 GET_DATA;
1556
1557                 value = oct>>(32-bits_needed);
1558
1559                 mc_item = proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_multislot_capability, tvb, bit_offset, 1, FALSE);
1560                 bit_offset++;
1561
1562                 curr_bits_length -= bits_needed;
1563                 oct <<= bits_needed;
1564                 bits_in_oct -= bits_needed;
1565
1566                 /* analyse bits */
1567                 if (value==1)
1568                 {
1569                         mc_tree = proto_item_add_subtree(mc_item, ett_gsm_a_gm_msrac_multislot_capability);
1570                         /*
1571                          * HSCSD multislot class?
1572                          */
1573                         bits_needed = 1;
1574                         GET_DATA;
1575
1576                         /* analyse bits */
1577                         if ((oct>>(32-bits_needed))==0)
1578                         {
1579                                 proto_tree_add_text(mc_tree,
1580                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1581                                         "HSCSD multislot class: Bits are not available (%u)",oct>>(32-bits_needed));
1582                                 bit_offset++;
1583                                 curr_bits_length -= bits_needed;
1584                                 oct <<= bits_needed;
1585                                 bits_in_oct -= bits_needed;
1586                         }
1587                         else
1588                         {
1589                                 curr_bits_length -= bits_needed;
1590                                 oct <<= bits_needed;
1591                                 bits_in_oct -= bits_needed;
1592                                 bit_offset++;
1593
1594                                 /*
1595                                  * HSCSD multislot class
1596                                  */
1597                                 bits_needed = 5;
1598                                 GET_DATA;
1599
1600                                 /* analyse bits */
1601                                 proto_tree_add_text(mc_tree,
1602                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1603                                         "HSCSD multislot class: %s (%u)",multi_slot_str[oct>>(32-bits_needed)],oct>>(32-bits_needed));
1604                                 bit_offset+=5;
1605                                 curr_bits_length -= bits_needed;
1606                                 oct <<= bits_needed;
1607                                 bits_in_oct -= bits_needed;
1608                         }
1609
1610                         /*
1611                          * GPRS multislot class?
1612                          */
1613                         bits_needed = 1;
1614                         GET_DATA;
1615
1616                         /* analyse bits */
1617                         if ((oct>>(32-bits_needed))==0)
1618                         {
1619                                 proto_tree_add_text(mc_tree,
1620                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1621                                         "GPRS multislot class: Bits are not available (%u)",oct>>(32-bits_needed));
1622                                 bit_offset++;
1623                                 curr_bits_length -= bits_needed;
1624                                 oct <<= bits_needed;
1625                                 bits_in_oct -= bits_needed;
1626                         }
1627                         else
1628                         {
1629                                 curr_bits_length -= bits_needed;
1630                                 oct <<= bits_needed;
1631                                 bits_in_oct -= bits_needed;
1632                                 bit_offset++;
1633
1634                                 /*
1635                                  * GPRS multislot class
1636                                  */
1637                                 bits_needed = 5;
1638                                 GET_DATA;
1639
1640                                 /* analyse bits */
1641                                 proto_tree_add_text(mc_tree,
1642                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1643                                         "GPRS multislot class: %s (%u)",multi_slot_str[oct>>(32-bits_needed)],oct>>(32-bits_needed));
1644                                 bit_offset+=5;
1645                                 curr_bits_length -= bits_needed;
1646                                 oct <<= bits_needed;
1647                                 bits_in_oct -= bits_needed;
1648
1649                                 /*
1650                                  * GPRS Extended Dynamic Allocation Capability
1651                                  */
1652                                 bits_needed = 1;
1653                                 GET_DATA;
1654
1655                                 /* analyse bits */
1656                                 switch ( oct>>(32-bits_needed) )
1657                                 {
1658                                         case 0x00: str="Extended Dynamic Allocation Capability for GPRS is not implemented"; break;
1659                                         case 0x01: str="Extended Dynamic Allocation Capability for GPRS is implemented";     break;
1660                                         default:   str="This should not happen";
1661                                 }
1662                                 proto_tree_add_text(mc_tree,
1663                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1664                                         "GPRS Extended Dynamic Allocation Capability: %s (%u)",str,oct>>(32-bits_needed));
1665                                 bit_offset++;
1666                                 curr_bits_length -= bits_needed;
1667                                 oct <<= bits_needed;
1668                                 bits_in_oct -= bits_needed;
1669                         }
1670
1671                         /*
1672                          * SMS/SM values
1673                          */
1674                         bits_needed = 1;
1675                         GET_DATA;
1676
1677                         /* analyse bits */
1678                         if ((oct>>(32-bits_needed))==0)
1679                         {
1680                                 proto_tree_add_text(mc_tree,
1681                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1682                                         "SMS/SM values: Bits are not available (%u)",oct>>(32-bits_needed));
1683                                 bit_offset++;
1684                                 curr_bits_length -= bits_needed;
1685                                 oct <<= bits_needed;
1686                                 bits_in_oct -= bits_needed;
1687                         }
1688                         else
1689                         {
1690                                 curr_bits_length -= bits_needed;
1691                                 oct <<= bits_needed;
1692                                 bits_in_oct -= bits_needed;
1693                                 bit_offset++;
1694
1695                                 /*
1696                                  * Switch-Measure-Switch value
1697                                  */
1698                                 bits_needed = 4;
1699                                 GET_DATA;
1700
1701                                 /* analyse bits */
1702                                 proto_tree_add_bits_item(mc_tree, hf_gsm_a_gm_sms_value, tvb, bit_offset, 4, FALSE);
1703                                 bit_offset+=4;
1704                                 curr_bits_length -= bits_needed;
1705                                 oct <<= bits_needed;
1706                                 bits_in_oct -= bits_needed;
1707
1708                                 /*
1709                                  * Switch-Measure value
1710                                  */
1711                                 bits_needed = 4;
1712                                 GET_DATA;
1713
1714                                 /* analyse bits */
1715                                 proto_tree_add_bits_item(mc_tree, hf_gsm_a_gm_sm_value, tvb, bit_offset, 4, FALSE);
1716                                 bit_offset+=4;
1717                                 curr_bits_length -= bits_needed;
1718                                 oct <<= bits_needed;
1719                                 bits_in_oct -= bits_needed;
1720                         }
1721
1722                         /*
1723                          * ECSD multislot class?
1724                          */
1725                         bits_needed = 1;
1726                         GET_DATA;
1727
1728                         /* analyse bits */
1729                         if ((oct>>(32-bits_needed))==0)
1730                         {
1731                                 proto_tree_add_text(mc_tree,
1732                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1733                                         "ECSD multislot class: Bits are not available (%u)",oct>>(32-bits_needed));
1734                                 bit_offset++;
1735                                 curr_bits_length -= bits_needed;
1736                                 oct <<= bits_needed;
1737                                 bits_in_oct -= bits_needed;
1738                         }
1739                         else
1740                         {
1741                                 curr_bits_length -= bits_needed;
1742                                 oct <<= bits_needed;
1743                                 bits_in_oct -= bits_needed;
1744                                 bit_offset++;
1745
1746                                 /*
1747                                  * ECSD multislot class
1748                                  */
1749                                 bits_needed = 5;
1750                                 GET_DATA;
1751
1752                                 /* analyse bits */
1753                                 proto_tree_add_text(mc_tree,
1754                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1755                                         "ECSD multislot class: %s (%u)",multi_slot_str[oct>>(32-bits_needed)],oct>>(32-bits_needed));
1756                                 bit_offset+=5;
1757                                 curr_bits_length -= bits_needed;
1758                                 oct <<= bits_needed;
1759                                 bits_in_oct -= bits_needed;
1760                         }
1761
1762                         /*
1763                          * EGPRS multislot class?
1764                          */
1765                         bits_needed = 1;
1766                         GET_DATA;
1767
1768                         /* analyse bits */
1769                         if ((oct>>(32-bits_needed))==0)
1770                         {
1771                                 proto_tree_add_text(mc_tree,
1772                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1773                                         "EGPRS multislot class: Bits are not available (%u)",oct>>(32-bits_needed));
1774                                 curr_bits_length -= bits_needed;
1775                                 oct <<= bits_needed;
1776                                 bits_in_oct -= bits_needed;
1777                                 bit_offset++;
1778                         }
1779                         else
1780                         {
1781                                 curr_bits_length -= bits_needed;
1782                                 oct <<= bits_needed;
1783                                 bits_in_oct -= bits_needed;
1784                                 bit_offset++;
1785
1786                                 /*
1787                                  * EGPRS multislot class
1788                                  */
1789                                 bits_needed = 5;
1790                                 GET_DATA;
1791
1792                                 /* analyse bits */
1793                                 proto_tree_add_text(mc_tree,
1794                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1795                                 "EGPRS multislot class: %s (%u)",multi_slot_str[oct>>(32-bits_needed)],oct>>(32-bits_needed));
1796                                 bit_offset+=5;
1797                                 curr_bits_length -= bits_needed;
1798                                 oct <<= bits_needed;
1799                                 bits_in_oct -= bits_needed;
1800
1801                                 /*
1802                                  * EGPRS Extended Dynamic Allocation Capability
1803                                  */
1804                                 bits_needed = 1;
1805                                 GET_DATA;
1806
1807                                 /* analyse bits */
1808                                 switch ( oct>>(32-bits_needed) )
1809                                 {
1810                                         case 0x00: str="Extended Dynamic Allocation Capability for EGPRS is not implemented"; break;
1811                                         case 0x01: str="Extended Dynamic Allocation Capability for EGPRS is implemented";     break;
1812                                         default:   str="This should not happen";
1813                                 }
1814                                 proto_tree_add_text(mc_tree,
1815                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1816                                         "EGPRS Extended Dynamic Allocation Capability: %s (%u)",str, oct>>(32-bits_needed));
1817                                 bit_offset++;
1818                                 curr_bits_length -= bits_needed;
1819                                 oct <<= bits_needed;
1820                                 bits_in_oct -= bits_needed;
1821                         }
1822
1823                         /*
1824                          * DTM GPRS Multi Slot Class ?
1825                         */
1826                         bits_needed = 1;
1827                         GET_DATA;
1828
1829                         /* analyse bits */
1830                         if ((oct>>(32-bits_needed))==0)
1831                         {
1832                                 proto_tree_add_text(mc_tree,
1833                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1834                                         "DTM GPRS Multi Slot Class: Bits are not available (%u)",oct>>(32-bits_needed));
1835                                 bit_offset++;
1836                                 curr_bits_length -= bits_needed;
1837                                 oct <<= bits_needed;
1838                                 bits_in_oct -= bits_needed;
1839                         }
1840                         else
1841                         {
1842                                 curr_bits_length -= bits_needed;
1843                                 oct <<= bits_needed;
1844                                 bits_in_oct -= bits_needed;
1845                                 bit_offset++;
1846
1847                                 /*
1848                                  * DTM GPRS Multi Slot Class
1849                                  */
1850                                 bits_needed = 2;
1851                                 GET_DATA;
1852
1853                                 /* analyse bits */
1854                                 dtm_gprs_mslot = oct>>(32-bits_needed);
1855
1856                                 switch ( oct>>(32-bits_needed) )
1857                                 {
1858                                         case 0:  str="Unused. If received, the network shall interpret this as Multislot class 5"; break;
1859                                         case 1:  str="Multislot class 5 supported";  break;
1860                                         case 2:  str="Multislot class 9 supported";  break;
1861                                         case 3:  str="Multislot class 11 supported"; break;
1862                                         default: str="This should not happen";
1863                                 }
1864
1865                                 proto_tree_add_text(mc_tree,
1866                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1867                                         "DTM GPRS Multi Slot Class: %s (%u)",str,oct>>(32-bits_needed));
1868                                 bit_offset+=2;
1869                                 curr_bits_length -= bits_needed;
1870                                 oct <<= bits_needed;
1871                                 bits_in_oct -= bits_needed;
1872
1873                                 /*
1874                                  * Single Slot DTM
1875                                  */
1876                                 bits_needed = 1;
1877                                 GET_DATA;
1878
1879                                 proto_tree_add_bits_item(mc_tree, hf_gsm_a_gm_rac_single_slt_dtm, tvb, bit_offset, 1, FALSE);
1880                                 bit_offset++;
1881                                 curr_bits_length -= bits_needed;
1882                                 oct <<= bits_needed;
1883                                 bits_in_oct -= bits_needed;
1884
1885                                 /*
1886                                  * DTM EGPRS Multi Slot Class ?
1887                                 */
1888                                 bits_needed = 1;
1889                                 GET_DATA;
1890
1891                                 /* analyse bits */
1892                                 dtm_egprs_mslot = oct>>(32-bits_needed);
1893                                 proto_tree_add_bits_item(mc_tree, hf_gsm_a_gm_rac_dtm_egprs_multi_slot_cls_pres, tvb, bit_offset, 1, FALSE);
1894                                 bit_offset++;
1895                                 curr_bits_length -= bits_needed;
1896                                 oct <<= bits_needed;
1897                                 bits_in_oct -= bits_needed;
1898
1899                                 if ((oct>>(32-bits_needed))==1)
1900                                 {
1901                                         /*
1902                                          * DTM EGPRS Multi Slot Class
1903                                          */
1904                                         bits_needed = 2;
1905                                         GET_DATA;
1906
1907                                         /* analyse bits */
1908                                         switch ( oct>>(32-bits_needed) )
1909                                         {
1910                                                 case 0: str="Unused. If received, the network shall interpret this as Multislot class 5"; break;
1911                                                 case 1:  str="Multislot class 5 supported";  break;
1912                                                 case 2:  str="Multislot class 9 supported";  break;
1913                                                 case 3:  str="Multislot class 11 supported"; break;
1914                                                 default: str="This should not happen";
1915                                         }
1916
1917                                         proto_tree_add_text(mc_tree,
1918                                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1919                                                 "DTM EGPRS Multi Slot Class: %s (%u)",str,oct>>(32-bits_needed));
1920                                         bit_offset+=2;
1921                                         curr_bits_length -= bits_needed;
1922                                         oct <<= bits_needed;
1923                                         bits_in_oct -= bits_needed;
1924                                 }
1925                         }
1926                 }
1927
1928                 /*
1929                  * 8PSK Power Capability?
1930                  */
1931                 bits_needed = 1;
1932                 GET_DATA;
1933
1934                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_8psk_pow_cap_pres, tvb, bit_offset, 1, FALSE);
1935                 bit_offset++;
1936                 curr_bits_length -= bits_needed;
1937                 oct <<= bits_needed;
1938                 bits_in_oct -= bits_needed;
1939
1940                 /* analyse bits */
1941                 if ((oct>>(32-bits_needed))==1)
1942                 {
1943                         /*
1944                          * 8PSK Power Capability
1945                          */
1946                         bits_needed = 2;
1947                         GET_DATA;
1948
1949                         /* analyse bits */
1950                         switch ( oct>>(32-bits_needed) )
1951                         {
1952                                 case 0x00: str="Reserved";       break;
1953                                 case 0x01: str="Power class E1"; break;
1954                                 case 0x02: str="Power class E2"; break;
1955                                 case 0x03: str="Power class E3"; break;
1956                                 default:   str="This should not happen";
1957                         }
1958
1959                         proto_tree_add_text(tf_tree,
1960                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
1961                                 "8PSK Power Capability: %s (%u)",str,oct>>(32-bits_needed));
1962                         bit_offset+=2;
1963                         curr_bits_length -= bits_needed;
1964                         oct <<= bits_needed;
1965                         bits_in_oct -= bits_needed;
1966                 }
1967
1968                 /*
1969                  * COMPACT Interference Measurement Capability
1970                  */
1971                 bits_needed = 1;
1972                 GET_DATA;
1973
1974                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_comp_int_meas_cap, tvb, bit_offset, 1, FALSE);
1975                 bit_offset++;
1976                 curr_bits_length -= bits_needed;
1977                 oct <<= bits_needed;
1978                 bits_in_oct -= bits_needed;
1979
1980                 /*
1981                  * Revision Level Indicator
1982                  */
1983                 bits_needed = 1;
1984                 GET_DATA;
1985
1986                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rel_lev_ind, tvb, bit_offset, 1, FALSE);
1987                 bit_offset++;
1988                 curr_bits_length -= bits_needed;
1989                 oct <<= bits_needed;
1990                 bits_in_oct -= bits_needed;
1991
1992                 /*
1993                  * UMTS FDD Radio Access Technology Capability
1994                  */
1995                 bits_needed = 1;
1996                 GET_DATA;
1997
1998                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_umts_fdd_cap, tvb, bit_offset, 1, FALSE);
1999                 bit_offset++;
2000                 curr_bits_length -= bits_needed;
2001                 oct <<= bits_needed;
2002                 bits_in_oct -= bits_needed;
2003
2004                 /*
2005                  * UMTS 3.84 Mcps TDD Radio Access Technology Capability
2006                  */
2007                 bits_needed = 1;
2008                 GET_DATA;
2009
2010                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_umts_384_tdd_ra_cap, tvb, bit_offset, 1, FALSE);
2011                 bit_offset++;
2012                 curr_bits_length -= bits_needed;
2013                 oct <<= bits_needed;
2014                 bits_in_oct -= bits_needed;
2015
2016                 /*
2017                  * CDMA 2000 Radio Access Technology Capability
2018                  */
2019                 bits_needed = 1;
2020                 GET_DATA;
2021
2022                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_cdma2000_cap, tvb, bit_offset, 1, FALSE);
2023                 bit_offset++;
2024                 curr_bits_length -= bits_needed;
2025                 oct <<= bits_needed;
2026                 bits_in_oct -= bits_needed;
2027
2028                 /*
2029                  * UMTS 1.28 Mcps TDD Radio Access Technology Capability
2030                  */
2031                 bits_needed = 1;
2032                 GET_DATA;
2033
2034                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_umts_128_tdd_ra_cap, tvb, bit_offset, 1, FALSE);
2035                 bit_offset++;
2036                 curr_bits_length -= bits_needed;
2037                 oct <<= bits_needed;
2038                 bits_in_oct -= bits_needed;
2039
2040                 /*
2041                  * GERAN Feature Package 1
2042                  */
2043                 bits_needed = 1;
2044                 GET_DATA;
2045
2046                 proto_tree_add_bits_item(tf_tree, hf_gsm_a_gm_rac_geran_feat_pkg, tvb, bit_offset, 1, FALSE);
2047                 bit_offset++;
2048                 curr_bits_length -= bits_needed;
2049                 oct <<= bits_needed;
2050                 bits_in_oct -= bits_needed;
2051
2052                 /*
2053                  * Extended DTM (E)GPRS Multi Slot Class
2054                  */
2055
2056                 bits_needed = 1;
2057                 GET_DATA;
2058
2059                 /* analyse bits */
2060                 if ((oct>>(32-bits_needed))==0)
2061                 {
2062                         proto_tree_add_text(tf_tree,
2063                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
2064                                 "Extended DTM (E)GPRS Multi Slot Class: Bits are not available (%u)",oct>>(32-bits_needed));
2065                         curr_bits_length -= bits_needed;
2066                         oct <<= bits_needed;
2067                         bits_in_oct -= bits_needed;
2068                         bit_offset++;
2069                 }
2070                 else
2071                 {
2072                         curr_bits_length -= bits_needed;
2073                         oct <<= bits_needed;
2074                         bits_in_oct -= bits_needed;
2075
2076                         /*
2077                          * Extended DTM GPRS Multi Slot Class
2078                          */
2079                         bits_needed = 2;
2080                         GET_DATA;
2081
2082                         /* analyse bits */
2083                         switch ( (oct>>(32-bits_needed))|(dtm_gprs_mslot<<4) )
2084                         {
2085                                 case 0x00: str="Unused. If received, it shall be interpreted as Multislot class 5 supported";  break;
2086                                 case 0x01: str="Unused. If received, it shall be interpreted as Multislot class 5 supported";  break;
2087                                 case 0x02: str="Unused. If received, it shall be interpreted as Multislot class 5 supported";  break;
2088                                 case 0x03: str="Unused. If received, it shall be interpreted as Multislot class 5 supported";  break;
2089                                 case 0x10: str="Multislot class 5 supported";  break;
2090                                 case 0x11: str="Multislot class 6 supported";  break;
2091                                 case 0x12: str="Unused. If received, it shall be interpreted as Multislot class 5 supported";  break;
2092                                 case 0x13: str="Unused. If received, it shall be interpreted as Multislot class 5 supported";  break;
2093                                 case 0x20: str="Multislot class 9 supported";  break;
2094                                 case 0x21: str="Multislot class 10 supported"; break;
2095                                 case 0x22: str="Unused. If received, it shall be interpreted as Multislot class 9 supported";  break;
2096                                 case 0x23: str="Unused. If received, it shall be interpreted as Multislot class 9 supported";  break;
2097                                 case 0x30: str="Multislot class 11 supported"; break;
2098                                 case 0x31: str="Unused. If received, it shall be interpreted as Multislot class 11 supported"; break;
2099                                 case 0x32: str="Unused. If received, it shall be interpreted as Multislot class 11 supported"; break;
2100                                 case 0x33: str="Unused. If received, it shall be interpreted as Multislot class 11 supported"; break;
2101                                 default:   str="This should not happen";
2102                         }
2103
2104                         proto_tree_add_text(tf_tree,
2105                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
2106                                 "Extended DTM GPRS Multi Slot Class: %s (%u)",str,oct>>(32-bits_needed));
2107                         bit_offset+=2;
2108                         curr_bits_length -= bits_needed;
2109                         oct <<= bits_needed;
2110                         bits_in_oct -= bits_needed;
2111
2112                         if ( dtm_egprs_mslot <= 3 )
2113                         {
2114                                 /*
2115                                  * Extended DTM EGPRS Multi Slot Class
2116                                  */
2117                                 bits_needed = 2;
2118                                 GET_DATA;
2119
2120                                 /* analyse bits */
2121                                 switch ( (oct>>(32-bits_needed))|(dtm_egprs_mslot<<4) )
2122                                 {
2123                                         case 0x00: str="Unused. If received, it shall be interpreted as Multislot class 5 supported";  break;
2124                                         case 0x01: str="Unused. If received, it shall be interpreted as Multislot class 5 supported";  break;
2125                                         case 0x02: str="Unused. If received, it shall be interpreted as Multislot class 5 supported";  break;
2126                                         case 0x03: str="Unused. If received, it shall be interpreted as Multislot class 5 supported";  break;
2127                                         case 0x10: str="Multislot class 5 supported";  break;
2128                                         case 0x11: str="Multislot class 6 supported";  break;
2129                                         case 0x12: str="Unused. If received, it shall be interpreted as Multislot class 5 supported";  break;
2130                                         case 0x13: str="Unused. If received, it shall be interpreted as Multislot class 5 supported";  break;
2131                                         case 0x20: str="Multislot class 9 supported";  break;
2132                                         case 0x21: str="Multislot class 10 supported"; break;
2133                                         case 0x22: str="Unused. If received, it shall be interpreted as Multislot class 9 supported";  break;
2134                                         case 0x23: str="Unused. If received, it shall be interpreted as Multislot class 9 supported";  break;
2135                                         case 0x30: str="Multislot class 11 supported"; break;
2136                                         case 0x31: str="Unused. If received, it shall be interpreted as Multislot class 11 supported"; break;
2137                                         case 0x32: str="Unused. If received, it shall be interpreted as Multislot class 11 supported"; break;
2138                                         case 0x33: str="Unused. If received, it shall be interpreted as Multislot class 11 supported"; break;
2139                                         default:   str="This should not happen";
2140                                 }
2141
2142                                 proto_tree_add_text(tf_tree,
2143                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
2144                                         "Extended DTM EGPRS Multi Slot Class: %s (%u)",str, oct>>(32-bits_needed));
2145                                 bit_offset+=2;
2146                                 curr_bits_length -= bits_needed;
2147                                 oct <<= bits_needed;
2148                                 bits_in_oct -= bits_needed;
2149                         }
2150                 }
2151
2152                 /*
2153                  * Modulation based multislot class support
2154                  */
2155                 bits_needed = 1;
2156                 GET_DATA;
2157
2158                 /* analyse bits */
2159                 switch ( oct>>(32-bits_needed) )
2160                 {
2161                         case 0x00: str="Modulation based multislot class not supported"; break;
2162                         case 0x01: str="Modulation based multislot class supported";     break;
2163                         default:   str="This should not happen";
2164                 }
2165
2166                 proto_tree_add_text(tf_tree,
2167                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
2168                         "Modulation based multislot class support: %s (%u)",str,oct>>(32-bits_needed));
2169                 bit_offset++;
2170                 curr_bits_length -= bits_needed;
2171                 oct <<= bits_needed;
2172                 bits_in_oct -= bits_needed;
2173
2174                 /*
2175                  * High Multislot Capability
2176                  */
2177                 bits_needed = 1;
2178                 GET_DATA;
2179
2180                 /* analyse bits */
2181                 if ((oct>>(32-bits_needed))==0)
2182                 {
2183                         proto_tree_add_text(tf_tree,
2184                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
2185                                 "High Multislot Capability: Bits are not available (%u)",oct>>(32-bits_needed));
2186                         bit_offset++;
2187                         curr_bits_length -= bits_needed;
2188                         oct <<= bits_needed;
2189                         bits_in_oct -= bits_needed;
2190                 }
2191                 else
2192                 {
2193                         curr_bits_length -= bits_needed;
2194                         oct <<= bits_needed;
2195                         bits_in_oct -= bits_needed;
2196                         bit_offset++;
2197
2198                         /*
2199                          * High Multislot Capability
2200                          */
2201                         bits_needed = 2;
2202                         GET_DATA;
2203
2204                         /* analyse bits */
2205                         proto_tree_add_text(tf_tree,
2206                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
2207                                             "High Multislot Capability: 0x%02x (%u)"
2208                                             " - This field effect all other multislot fields."
2209                                             " To understand the value please read TS 24.008 5.6.0"
2210                                             " Release 5 Chap 10.5.5.12 Page 406",
2211                                             oct>>(32-bits_needed),
2212                                             oct>>(32-bits_needed));
2213                         bit_offset+=2;
2214                         curr_bits_length -= bits_needed;
2215                         oct <<= bits_needed;
2216                         bits_in_oct -= bits_needed;
2217                 }
2218
2219                 /*
2220                  * GERAN Iu Mode Capability
2221                  */
2222                 bits_needed = 1;
2223                 GET_DATA;
2224
2225                 /* analyse bits */
2226                 switch ( oct>>(32-bits_needed) )
2227                 {
2228                         case 0x00: str="GERAN Iu mode not supported"; break;
2229                         case 0x01: str="GERAN Iu mode supported";     break;
2230                         default:   str="This should not happen";
2231                 }
2232
2233                 proto_tree_add_text(tf_tree,
2234                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
2235                         "GERAN Iu Mode Capability: %s (%u)",str,oct>>(32-bits_needed));
2236                 bit_offset++;
2237                 curr_bits_length -= bits_needed;
2238                 oct <<= bits_needed;
2239                 bits_in_oct -= bits_needed;
2240
2241                 /*
2242                  * GMSK/8-PSK Multislot Power Profile
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                                 "GMSK/8-PSK Multislot Power Profile: 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                          * GMSK Multislot Power Profile
2267                          */
2268                         bits_needed = 2;
2269                         GET_DATA;
2270
2271                         /* analyse bits */
2272                         switch ( oct>>(32-bits_needed) )
2273                         {
2274                                 case 0x00: str="GMSK_MULTISLOT_POWER_PROFILE 0"; break;
2275                                 case 0x01: str="GMSK_MULTISLOT_POWER_PROFILE 1"; break;
2276                                 case 0x02: str="GMSK_MULTISLOT_POWER_PROFILE 2"; break;
2277                                 case 0x03: str="GMSK_MULTISLOT_POWER_PROFILE 3"; break;
2278                                 default:   str="This should not happen";
2279                         }
2280
2281                         proto_tree_add_text(tf_tree,
2282                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
2283                                 "GMSK Multislot Power Profile: %s (%u)",str,oct>>(32-bits_needed));
2284                         bit_offset+=2;
2285                         curr_bits_length -= bits_needed;
2286                         oct <<= bits_needed;
2287                         bits_in_oct -= bits_needed;
2288
2289                         /*
2290                          * 8-PSK Multislot Power Profile
2291                          */
2292                         bits_needed = 2;
2293                         GET_DATA;
2294
2295                         /* analyse bits */
2296                         switch ( oct>>(32-bits_needed) )
2297                         {
2298                                 case 0x00: str="8-PSK_MULTISLOT_POWER_PROFILE 0"; break;
2299                                 case 0x01: str="8-PSK_MULTISLOT_POWER_PROFILE 1"; break;
2300                                 case 0x02: str="8-PSK_MULTISLOT_POWER_PROFILE 2"; break;
2301                                 case 0x03: str="8-PSK_MULTISLOT_POWER_PROFILE 3"; break;
2302                                 default:   str="This should not happen";
2303                         }
2304
2305                         proto_tree_add_text(tf_tree,
2306                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
2307                         "8-PSK Multislot Power Profile: %s (%u)",str,oct>>(32-bits_needed));
2308                         bit_offset+=2;
2309                         curr_bits_length -= bits_needed;
2310                         oct <<= bits_needed;
2311                         bits_in_oct -= bits_needed;
2312
2313                 }
2314
2315                 /*
2316                  * we are too long ... so jump over it
2317                  */
2318                 while ( curr_bits_length > 0 )
2319                 {
2320                         if ( curr_bits_length > 8 )
2321                                 bits_needed = 8;
2322                         else
2323                                 bits_needed = curr_bits_length;
2324                         GET_DATA;
2325                         curr_bits_length -= bits_needed;
2326                         oct <<= bits_needed;
2327                         bits_in_oct -= bits_needed;
2328                 }
2329
2330
2331         } while ( 1 );
2332
2333         curr_offset+= curr_len;
2334
2335         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
2336
2337         return(curr_offset - offset);
2338 }
2339
2340 /*
2341  * [9] 10.5.5.14
2342  */
2343 static const range_string gmm_cause_vals[] = {
2344         { 0x00, 0x01, "Protocol error, unspecified(Not def in v8.6.0)"},
2345         { 0x02, 0x02, "IMSI unknown in HLR"},
2346         { 0x03, 0x03, "Illegal MS"},
2347         { 0x04, 0x04, "IMSI unknown in VLR"}, /* Annex G.1 */
2348         { 0x05, 0x05, "IMEI not accepted"}, /* Annex G.1 */
2349         { 0x06, 0x06, "Illegal ME"},
2350         { 0x07, 0x07, "GPRS services not allowed"},
2351         { 0x08, 0x08, "GPRS services and non-GPRS services not allowed"},
2352         { 0x09, 0x09, "MS identity cannot be derived by the network"},
2353         { 0x0a, 0x0a, "Implicitly detached"},
2354         { 0x0b, 0x0b, "PLMN not allowed"},
2355         { 0x0c, 0x0c, "Location Area not allowed"},
2356         { 0x0d, 0x0d, "Roaming not allowed in this location area"},
2357         { 0x0e, 0x0e, "GPRS services not allowed in this PLMN"},
2358         { 0x0f, 0x0f, "No Suitable Cells In Location Area"},
2359         { 0x10, 0x10, "MSC temporarily not reachable"},
2360         { 0x11, 0x11, "Network failure"},
2361         { 0x12, 0x13, "Protocol error, unspecified(Not def in v8.6.0)"},
2362         { 0x14, 0x14, "MAC failure"},
2363         { 0x15, 0x15, "Synch failure"},
2364         { 0x16, 0x16, "Congestion"},
2365         { 0x17, 0x17, "GSM authentication unacceptable"},
2366         { 0x18, 0x18, "Protocol error, unspecified(Not def in v8.6.0)"},
2367         { 0x19, 0x19, "Not authorized for this CSG"},
2368         { 0x20, 0x20, "Service option not supported"},                                          /* Annex G.4 */
2369         { 0x21, 0x21, "Requested service option not subscribed"},                       /* Annex G.4 */
2370         { 0x22, 0x22, "Service option temporarily out of order"},                       /* Annex G.4 */
2371
2372         { 0x23, 0x25, "Protocol error, unspecified(Not def in v8.6.0)"},
2373
2374         { 0x26, 0x26, "Call cannot be identified(non-GPRS services only)"},     /* Annex G.4 */
2375         { 0x27, 0x27, "Protocol error, unspecified(Not def in v8.6.0)"},
2376         { 0x28, 0x28, "No PDP context activated"},
2377         { 0x29, 0x2f, "Protocol error, unspecified(Not def in v8.6.0)"},
2378         { 0x30, 0x3f, "Retry upon entry into a new cell"},
2379
2380         { 0x40, 0x5e, "Protocol error, unspecified(Not def in v8.6.0)"},
2381
2382         { 0x5f, 0x5f, "Semantically incorrect message"},
2383         { 0x60, 0x60, "Invalid mandatory information"},
2384         { 0x61, 0x61, "Message type non-existent or not implemented"},
2385         { 0x62, 0x62, "Message type not compatible with the protocol state"},
2386         { 0x63, 0x63, "Information element non-existent or notimplemented"},
2387         { 0x64, 0x64, "Conditional IE error"},
2388         { 0x65, 0x65, "Message not compatible with the protocol state"},
2389
2390         { 0x66, 0x6e, "Protocol error, unspecified(Not def in v8.6.0)"},
2391
2392         { 0x6f, 0x6f, "Protocol error, unspecified"},
2393         { 0x70, 0xff, "Protocol error, unspecified(Not def in v8.6.0)"},
2394         { 0, 0, NULL }
2395 };
2396 /* NOTE 1 TS 124 008 V8.6.0 (2009-07)
2397         "Any other value received by the mobile station shall be treated as 0110 1111, "Protocol
2398         error, unspecified". Any other value received by the network shall be treated as
2399         0110 1111, "Protocol error, unspecified".
2400  */
2401
2402 /* NOTE: The listed reject cause values are defined in annex G. */
2403
2404 static guint16
2405 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_)
2406 {
2407         guint32       curr_offset;
2408
2409         curr_offset = offset;
2410
2411         proto_tree_add_item(tree, hf_gsm_a_gm_cause, tvb, curr_offset, 1, FALSE);
2412
2413         curr_offset++;
2414
2415         /* no length check possible */
2416
2417         return(curr_offset - offset);
2418 }
2419
2420 /*
2421  * [7] 10.5.5.15 Routing area identification
2422  */
2423 guint16
2424 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_)
2425 {
2426         proto_tree   *subtree;
2427         proto_item   *item;
2428         guint32       mcc;
2429         guint32       mnc;
2430         guint32       lac;
2431         guint32       rac;
2432         guint32       curr_offset;
2433
2434         curr_offset = offset;
2435
2436         mcc = (tvb_get_guint8(tvb, curr_offset) & 0x0f) <<8;
2437         mcc |= (tvb_get_guint8(tvb, curr_offset) & 0xf0);
2438         mcc |= (tvb_get_guint8(tvb, curr_offset+1) & 0x0f);
2439         mnc = (tvb_get_guint8(tvb, curr_offset+2) & 0x0f) <<8;
2440         mnc |= (tvb_get_guint8(tvb, curr_offset+2) & 0xf0);
2441         mnc |= (tvb_get_guint8(tvb, curr_offset+1) & 0xf0) >>4;
2442         if ((mnc&0x000f) == 0x000f)
2443                  mnc = mnc>>4;
2444
2445         lac = tvb_get_ntohs(tvb, curr_offset+3);
2446         rac = tvb_get_guint8(tvb, curr_offset+5);
2447
2448         item = proto_tree_add_text(tree,
2449                 tvb, curr_offset, 6,
2450                 "Routing area identification: %x-%x-%u-%u",
2451                 mcc,mnc,lac,rac);
2452
2453         subtree = proto_item_add_subtree(item, ett_gmm_rai);
2454         dissect_e212_mcc_mnc(tvb, pinfo, subtree, offset, TRUE);
2455
2456         proto_tree_add_item(subtree, hf_gsm_a_lac, tvb, curr_offset+3, 2, FALSE);
2457         proto_tree_add_item(subtree, hf_gsm_a_gm_rac, tvb, curr_offset+5, 1, FALSE);
2458
2459         curr_offset+=6;
2460     if (add_string)
2461     {
2462         if (add_string[0] == '\0')
2463         {
2464             g_snprintf(add_string, string_len, " - RAI: %x-%x-%u-%u", mcc,mnc,lac,rac);
2465         }
2466     }
2467
2468
2469         /* no length check possible */
2470
2471         return(curr_offset - offset);
2472 }
2473
2474 /*
2475  * [7] 10.5.5.17
2476  */
2477 static guint16
2478 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_)
2479 {
2480         guint8        oct;
2481         guint32       curr_offset;
2482         const gchar  *str;
2483
2484         curr_offset = offset;
2485
2486         oct = tvb_get_guint8(tvb, curr_offset);
2487
2488         /* IMPORTANT - IT'S ASSUMED THAT THE INFORMATION IS IN THE HIGHER NIBBLE */
2489         oct >>= 4;
2490
2491         switch(oct&7)
2492         {
2493                 case 0:  str="RA updated";              break;
2494                 case 1:  str="combined RA/LA updated";  break;
2495                 default: str="reserved";
2496         }
2497
2498         proto_tree_add_text(tree,
2499                 tvb, curr_offset, 1,
2500                 "Update Result: %s (%u)",
2501                 str,
2502                 oct&7);
2503
2504         curr_offset++;
2505
2506         /* no length check possible */
2507
2508         return(curr_offset - offset);
2509 }
2510
2511 /*
2512  * [9] 10.5.5.18 Update Type
2513  */
2514 static const value_string gsm_a_gm_update_type_vals[] = {
2515         { 0x00, "RA updating" },
2516         { 0x01, "combined RA/LA updating" },
2517         { 0x02, "combined RA/LA updating with IMSI attach" },
2518         { 0x03, "Periodic updating" },
2519         { 0, NULL }
2520 };
2521
2522 static guint16
2523 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_)
2524 {
2525         proto_item   *tf = NULL;
2526         proto_tree   *tf_tree = NULL;
2527
2528         proto_tree_add_bits_item(tree, hf_gsm_a_gm_ciph_key_seq_num, tvb, offset << 3, 4, FALSE);
2529
2530         tf = proto_tree_add_text(tree,
2531                 tvb, offset, 1,
2532                 "Update Type");
2533
2534         tf_tree = proto_item_add_subtree(tf, ett_gmm_update_type );
2535
2536         proto_tree_add_item(tf_tree, hf_gsm_a_gm_for, tvb, offset, 1, FALSE);
2537         proto_tree_add_item(tf_tree, hf_gsm_a_gm_update_type, tvb, offset, 1, FALSE);
2538
2539         /* no length check possible */
2540         return(1);
2541 }
2542
2543 /*
2544  * [9] 10.5.5.19 A&C reference number (lower nibble)
2545  */
2546 static guint16
2547 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_)
2548 {
2549         /* IMPORTANT - IT'S ASSUMED THAT THE INFORMATION IS IN THE LOWER NIBBLE */
2550         proto_tree_add_bits_item(tree, hf_gsm_a_gm_ac_ref_nr, tvb, (offset << 3) + 4, 4, FALSE);
2551
2552         /* no length check possible */
2553         return(1);
2554 }
2555
2556 /*
2557  * [9] 10.5.5.19 A&C reference number (higher nibble)
2558  */
2559 static guint16
2560 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_)
2561 {
2562         /* IMPORTANT - IT'S ASSUMED THAT THE INFORMATION IS IN THE HIGHER NIBBLE */
2563         proto_tree_add_bits_item(tree, hf_gsm_a_gm_ac_ref_nr, tvb, offset << 3, 4, FALSE);
2564
2565         /* no length check possible */
2566         return(1);
2567 }
2568
2569 /*
2570  * [9] 10.5.5.20 Service type
2571  */
2572 static const value_string gsm_a_gm_serv_type_vals[] = {
2573         { 0x00, "Signalling" },
2574         { 0x01, "Data" },
2575         { 0x02, "Paging response" },
2576         { 0x03, "MBMS Multicast Service Reception" },
2577         { 0x04, "MBMS Broadcast Service Reception" },
2578         { 0, NULL }
2579 };
2580
2581 static guint16
2582 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_)
2583 {
2584         guint32 bit_offset;
2585
2586         bit_offset = offset << 3;
2587         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, bit_offset, 1, FALSE);
2588         bit_offset += 1;
2589         proto_tree_add_bits_item(tree, hf_gsm_a_gm_serv_type, tvb, bit_offset, 3, FALSE);
2590         bit_offset += 3;
2591         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, bit_offset, 1, FALSE);
2592         bit_offset += 1;
2593         proto_tree_add_bits_item(tree, hf_gsm_a_gm_ciph_key_seq_num, tvb, bit_offset, 3, FALSE);
2594
2595         /* no length check possible */
2596         return(1);
2597 }
2598
2599 /*
2600  * [9] 10.5.5.21 Cell Notification
2601  * No data
2602  */
2603
2604 /*
2605  * [9] 10.5.5.22 PS LCS Capability
2606  */
2607 static const true_false_string gsm_a_gm_apc_vals = {
2608         "Additional Positioning Capabilities which can be retrieved by RRLP are supported",
2609         "Additional Positioning Capabilities which can be retrieved by RRLP are not supported"
2610 };
2611
2612 static const true_false_string gsm_a_gm_otd_a_vals = {
2613         "MS assisted E-OTD supported",
2614         "MS assisted E-OTD not supported"
2615 };
2616
2617 static const true_false_string gsm_a_gm_otd_b_vals = {
2618         "MS based E-OTD supported",
2619         "MS based E-OTD not supported"
2620 };
2621
2622 static const true_false_string gsm_a_gm_gps_a_vals = {
2623         "MS assisted GPS supported",
2624         "MS assisted GPS not supported"
2625 };
2626
2627 static const true_false_string gsm_a_gm_gps_b_vals = {
2628         "MS based GPS supported",
2629         "MS based GPS not supported"
2630 };
2631
2632 static const true_false_string gsm_a_gm_gps_c_vals = {
2633         "Conventional GPS supported",
2634         "Conventional GPS not supported"
2635 };
2636
2637 static guint16
2638 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_)
2639 {
2640         guint32 curr_offset;
2641
2642         curr_offset = offset;
2643         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, curr_offset << 3, 2, FALSE);
2644         proto_tree_add_item(tree, hf_gsm_a_gm_apc, tvb, curr_offset, 1, FALSE);
2645         proto_tree_add_item(tree, hf_gsm_a_gm_otd_a, tvb, curr_offset, 1, FALSE);
2646         proto_tree_add_item(tree, hf_gsm_a_gm_otd_b, tvb, curr_offset, 1, FALSE);
2647         proto_tree_add_item(tree, hf_gsm_a_gm_gps_a, tvb, curr_offset, 1, FALSE);
2648         proto_tree_add_item(tree, hf_gsm_a_gm_gps_b, tvb, curr_offset, 1, FALSE);
2649         proto_tree_add_item(tree, hf_gsm_a_gm_gps_c, tvb, curr_offset, 1, FALSE);
2650
2651         curr_offset++;
2652
2653         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
2654
2655         return(curr_offset - offset);
2656 }
2657
2658 /*
2659  * [7] 10.5.5.23
2660  */
2661 static guint16
2662 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_)
2663 {
2664         guint8  oct;
2665         guint32 curr_offset;
2666         const gchar     *str;
2667
2668         curr_offset = offset;
2669
2670         oct = tvb_get_guint8(tvb, curr_offset);
2671
2672         switch(oct&8)
2673         {
2674                 case 8: str="LCS-MOLR via PS domain not supported"; break;
2675                 default: str="LCS-MOLR via PS domain supported";
2676         }
2677
2678         proto_tree_add_text(tree,
2679                 tvb, curr_offset, 1,
2680                 "Network Feature Support: %s (%u)",
2681                 str,
2682                 (oct>>3)&1);
2683
2684         curr_offset++;
2685
2686         /* no length check possible */
2687
2688         return(curr_offset - offset);
2689 }
2690
2691 /* [7] 10.5.5.24 Inter RAT information container */
2692 static guint16
2693 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_)
2694 {
2695         guint32 curr_offset;
2696         tvbuff_t *rrc_irat_ho_info_tvb;
2697
2698         curr_offset = offset;
2699
2700 /* The value part of the Inter RAT information container information element is the INTER RAT HANDOVER INFO as
2701 defined in 3GPP TS 25.331 [23c]. If this field includes padding bits, they are defined in 3GPP TS 25.331 [23c].*/
2702         rrc_irat_ho_info_tvb = tvb_new_subset(tvb, curr_offset, len, len);
2703         if (rrc_irat_ho_info_handle)
2704                 call_dissector(rrc_irat_ho_info_handle, rrc_irat_ho_info_tvb,pinfo , tree);
2705         else
2706                 proto_tree_add_text(tree, tvb, curr_offset, len,"INTER RAT HANDOVER INFO - Not decoded");
2707
2708         return len;
2709
2710 }
2711
2712 /*
2713  * [7] 10.5.7.1
2714  */
2715 static guint16
2716 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_)
2717 {
2718         guint8  oct;
2719         guint16 pdp_nr;
2720         guint32 curr_offset;
2721         proto_item  *tf = NULL;
2722         proto_tree  *tf_tree = NULL;
2723
2724         curr_offset = offset;
2725
2726         oct = tvb_get_guint8(tvb, curr_offset);
2727
2728         tf = proto_tree_add_text(tree,
2729                 tvb, curr_offset, 1,
2730                 "PDP Context Status");
2731
2732         tf_tree = proto_item_add_subtree(tf, ett_gmm_context_stat );
2733
2734         oct = tvb_get_guint8(tvb, curr_offset);
2735
2736         for ( pdp_nr=0;pdp_nr<16; pdp_nr++ )
2737         {
2738                 if ( pdp_nr == 8 )
2739                 {
2740                         curr_offset++;
2741                         oct = tvb_get_guint8(tvb, curr_offset);
2742                 }
2743                 proto_tree_add_text(tf_tree,
2744                         tvb, curr_offset, 1,
2745                         "NSAPI %d: %s (%u)",pdp_nr,
2746                         pdp_str[oct&1],
2747                         oct&1);
2748                 oct>>=1;
2749         }
2750
2751         curr_offset++;
2752
2753         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
2754
2755         return(curr_offset - offset);
2756 }
2757
2758 /*
2759  * [7] 10.5.7.2
2760  */
2761 static guint16
2762 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_)
2763 {
2764         guint8  oct;
2765         guint32 curr_offset;
2766         const gchar     *str;
2767
2768         curr_offset = offset;
2769
2770         oct = tvb_get_guint8(tvb, curr_offset);
2771
2772         switch ( oct&7 )
2773         {
2774                 case 1: str="priority level 1 (highest)"; break;
2775                 case 2: str="priority level 2"; break;
2776                 case 3: str="priority level 3"; break;
2777                 case 4: str="priority level 4 (lowest)"; break;
2778                 default: str="priority level 4 (lowest)";
2779         }
2780
2781         proto_tree_add_text(tree,
2782                 tvb, curr_offset, 1,
2783                 "Radio Priority (PDP or SMS): %s (%u)",
2784                 str,
2785                 oct&7);
2786
2787         curr_offset++;
2788
2789         return(curr_offset - offset);
2790 }
2791
2792 /*
2793  * [9] 10.5.7.3 GPRS Timer
2794  */
2795 static const value_string gsm_a_gm_gprs_timer_unit_vals[] = {
2796         { 0x00, "value is incremented in multiples of 2 seconds" },
2797         { 0x01, "value is incremented in multiples of 1 minute" },
2798         { 0x02, "value is incremented in multiples of decihours" },
2799         { 0x07, "value indicates that the timer is deactivated" },
2800         { 0, NULL }
2801 };
2802
2803 static guint16
2804 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_)
2805 {
2806         guint8  oct;
2807         guint16 val;
2808         const gchar     *str;
2809         proto_tree      *subtree;
2810         proto_item      *item;
2811
2812         oct = tvb_get_guint8(tvb, offset);
2813         val = oct&0x1f;
2814
2815         switch(oct>>5)
2816         {
2817                 case 0: str="sec"; val*=2; break;
2818                 case 1: str="min"; break;
2819                 case 2: str="min"; val*=6; break;
2820                 case 7:
2821                         proto_tree_add_text(tree,
2822                                 tvb, offset, 1,
2823                                 "GPRS Timer: timer is deactivated");
2824
2825                 default: str="min";
2826         }
2827
2828         item = proto_tree_add_text(tree,
2829                 tvb, offset, 1,
2830                 "GPRS Timer: %u %s",
2831                 val,
2832                 str);
2833
2834         subtree = proto_item_add_subtree(item, ett_gmm_gprs_timer);
2835         proto_tree_add_item(subtree, hf_gsm_a_gm_gprs_timer_unit, tvb, offset, 1, FALSE);
2836         proto_tree_add_item(subtree, hf_gsm_a_gm_gprs_timer_value, tvb, offset, 1, FALSE);
2837
2838         /* no length check possible */
2839         return(1);
2840 }
2841
2842 /*
2843  * [7] 10.5.7.4
2844  */
2845 static guint16
2846 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_)
2847 {
2848         guint8  oct;
2849         guint16 val;
2850         guint32 curr_offset;
2851         const gchar     *str;
2852
2853         curr_offset = offset;
2854
2855         oct = tvb_get_guint8(tvb, curr_offset);
2856
2857         val = oct&0x1f;
2858
2859         switch(oct>>5)
2860         {
2861                 case 0: str="sec"; val*=2; break;
2862                 case 1: str="min"; break;
2863                 case 2: str="min"; val*=6; break;
2864                 case 7:
2865                         proto_tree_add_text(tree,
2866                         tvb, curr_offset, 1,
2867                         "GPRS Timer: timer is deactivated");
2868
2869                 default: str="min";
2870         }
2871
2872         proto_tree_add_text(tree,
2873                 tvb, curr_offset, 1,
2874                 "GPRS Timer: %u %s %s (%u)",
2875                 val,
2876                 str, add_string ? add_string : "", oct);
2877
2878         curr_offset++;
2879
2880         return(curr_offset - offset);
2881 }
2882
2883 /*
2884  * [7] 10.5.7.5
2885  */
2886 static guint16
2887 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_)
2888 {
2889         guint8  oct;
2890         guint32 curr_offset;
2891         const gchar     *str;
2892
2893         curr_offset = offset;
2894
2895         oct = tvb_get_guint8(tvb, curr_offset);
2896
2897         /* IMPORTANT - IT'S ASSUMED THAT THE INFORMATION IS IN THE HIGHER NIBBLE */
2898         oct >>= 4;
2899
2900         switch ( oct&7 )
2901         {
2902                 case 1: str="priority level 1 (highest)"; break;
2903                 case 2: str="priority level 2"; break;
2904                 case 3: str="priority level 3"; break;
2905                 case 4: str="priority level 4 (lowest)"; break;
2906                 default: str="priority level 4 (lowest)";
2907         }
2908
2909         proto_tree_add_text(tree,
2910                 tvb, curr_offset, 1,
2911                 "Radio Priority (TOM8): %s (%u)",
2912                 str,
2913                 oct&7);
2914
2915         curr_offset++;
2916
2917         return(curr_offset - offset);
2918 }
2919
2920 /*
2921  * [8] 10.5.7.6 MBMS context status
2922  */
2923 static guint16
2924 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_)
2925 {
2926         guint32 curr_offset;
2927         guint   i;
2928         guint8  oct, j;
2929         proto_item  *tf = NULL;
2930         proto_tree  *tf_tree = NULL;
2931
2932         curr_offset = offset;
2933
2934         oct = tvb_get_guint8(tvb, curr_offset);
2935
2936         tf = proto_tree_add_text(tree,
2937                 tvb, curr_offset, 1,
2938                 "MBMS Context Status");
2939
2940         tf_tree = proto_item_add_subtree(tf, ett_gmm_context_stat );
2941
2942         for (i=0; i<len; i++)
2943         {
2944                 oct = tvb_get_guint8(tvb, curr_offset);
2945
2946                 for (j=0; j<8; j++)
2947                 {
2948                         proto_tree_add_text(tf_tree,
2949                                 tvb, curr_offset, 1,
2950                                 "NSAPI %d: %s (%u)",128+i*8+j,
2951                                 pdp_str[oct&1],
2952                                 oct&1);
2953                         oct>>=1;
2954                 }
2955                 curr_offset++;
2956         }
2957
2958         return(len);
2959 }
2960 /*
2961  * [7] 10.5.6.1
2962  */
2963 #define MAX_APN_LENGTH          50
2964
2965 guint16
2966 de_sm_apn(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string, int string_len _U_)
2967 {
2968         guint32 curr_offset;
2969         guint   curr_len;
2970         guint8    str[MAX_APN_LENGTH+1];
2971
2972         curr_offset = offset;
2973
2974         /* init buffer and copy it */
2975         memset ( str , 0 , MAX_APN_LENGTH );
2976         tvb_memcpy(tvb, str, offset, len<MAX_APN_LENGTH?len:MAX_APN_LENGTH);
2977
2978         curr_len = 0;
2979         while (( curr_len < len ) && ( curr_len < MAX_APN_LENGTH ))
2980         {
2981                 guint step = str[curr_len];
2982                 str[curr_len]='.';
2983                 curr_len += step+1;
2984         }
2985
2986         proto_tree_add_text(tree,
2987                 tvb, curr_offset, len,
2988                 "APN: %s %s", str+1 , add_string ? add_string : "");
2989
2990         curr_offset+= len;
2991
2992         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
2993
2994         return(curr_offset - offset);
2995 }
2996
2997 /*
2998  * [7] 10.5.6.2
2999  */
3000 static guint16
3001 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_)
3002 {
3003         guint8  oct;
3004         guint32 curr_offset;
3005
3006         curr_offset = offset;
3007
3008         oct = tvb_get_guint8(tvb, curr_offset);
3009
3010         proto_tree_add_text(tree,
3011                 tvb, curr_offset, 1,
3012                 "NSAPI: 0x%02x (%u) %s",
3013                 oct&0x0f, oct&0x0f,add_string ? add_string : "");
3014
3015         curr_offset++;
3016
3017         return(curr_offset - offset);
3018 }
3019
3020 /*
3021  * [7] 10.5.6.3 Protocol configuration options
3022  */
3023 static const value_string gsm_a_sm_pco_ms2net_prot_vals[] = {
3024         { 0x01, "P-CSCF IPv6 Address Request" },
3025         { 0x02, "IM CN Subsystem Signaling Flag" },
3026         { 0x03, "DNS Server IPv6 Address Request" },
3027         { 0x04, "Not Supported" },
3028         { 0x05, "MS Support of Network Requested Bearer Control indicator" },
3029         { 0x06, "Reserved" },
3030         { 0x07, "DSMIPv6 Home Agent Address Request" },
3031         { 0x08, "DSMIPv6 Home Network Prefix Request" },
3032         { 0x09, "DSMIPv6 IPv4 Home Agent Address Request" },
3033         { 0x0a, "IP address allocation via NAS signalling" },
3034         { 0x0b, "IPv4 address allocation via DHCPv4" },
3035         { 0x0c, "P-CSCF IPv4 Address Request" },
3036         { 0x0d, "DNS Server IPv4 Address Request" },
3037         { 0x0e, "MSISDN Request" },
3038         { 0, NULL }
3039 };
3040 static const value_string gsm_a_sm_pco_net2ms_prot_vals[] = {
3041         { 0x01, "P-CSCF IPv6 Address" },
3042         { 0x02, "IM CN Subsystem Signaling Flag" },
3043         { 0x03, "DNS Server IPv6 Address" },
3044         { 0x04, "Policy Control rejection code" },
3045         { 0x05, "Selected Bearer Control Mode" },
3046         { 0x06, "Reserved" },
3047         { 0x07, "DSMIPv6 Home Agent Address" },
3048         { 0x08, "DSMIPv6 Home Network Prefix" },
3049         { 0x09, "DSMIPv6 IPv4 Home Agent Address" },
3050         { 0x0a, "Reserved" },
3051         { 0x0b, "Reserved" },
3052         { 0x0c, "P-CSCF IPv4 Address" },
3053         { 0x0d, "DNS Server IPv4 Address" },
3054         { 0x0e, "MSISDN" },
3055         { 0, NULL }
3056 };
3057
3058 static const value_string gsm_a_gm_link_dir_vals[] = {
3059         { -1, "Unknown" },
3060         { 0x0, "MS to network" },
3061         { 0x1, "Network to MS" },
3062         { 0, NULL }
3063 };
3064
3065 guint16
3066 de_sm_pco(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
3067 {
3068         proto_item   *generated_item = NULL;
3069         guint32 curr_offset;
3070         guint   curr_len;
3071         guchar  oct;
3072         struct e_in6_addr ipv6_addr;
3073         int     link_dir;
3074
3075         curr_len = len;
3076         curr_offset = offset;
3077
3078         oct = tvb_get_guint8(tvb, curr_offset);
3079
3080         link_dir = pinfo->link_dir;
3081         generated_item =proto_tree_add_int(tree, hf_gsm_a_gm_link_dir, tvb, curr_offset, 0, link_dir);
3082         PROTO_ITEM_SET_GENERATED(generated_item);
3083
3084
3085         /* 1 ext 0 0 0 0 Spare  Configuration protocol */
3086         proto_tree_add_item(tree, hf_gsm_a_gm_sm_ext, tvb, curr_offset, 1, FALSE);
3087         /* Configuration protocol (octet 3)
3088          * Bits
3089          * 3 2 1
3090          * 0 0 0 PPP for use with IP PDP type or IP PDN type (see 3GPP TS 24.301 [120])
3091          *
3092          * All other values are interpreted as PPP in this version of the protocol.
3093          * (3GPP TS 24.008 version 9.4.0 Release 9)
3094          */
3095         proto_tree_add_text(tree,tvb, curr_offset, 1, "Configuration Protocol: PPP (%u)",oct&0x07);
3096         curr_len--;
3097         curr_offset++;
3098
3099         while ( curr_len > 0 )
3100         {
3101                 guchar e_len;
3102                 guint16 prot;
3103                 tvbuff_t *l3_tvb;
3104                 dissector_handle_t handle = NULL;
3105
3106                 /* Protocol ID 1                    octet 4
3107                  *                                  octet 5
3108                  * Length of protocol ID 1 contents octet 6
3109                  * Protocol ID 1 contents           octet 7
3110                  */
3111
3112                 prot = tvb_get_ntohs(tvb,curr_offset);
3113                 proto_tree_add_uint_format(tree, hf_gsm_a_gm_pco_pid, tvb, curr_offset, 2, (guint32)prot,
3114                                 "Protocol or Container ID: %s (%u)",
3115                                 link_dir ?
3116                                         val_to_str_const((guint32)prot, gsm_a_sm_pco_net2ms_prot_vals, val_to_str_ext_const(prot, &ppp_vals_ext, "Unknown")) :
3117                                         val_to_str_const((guint32)prot, gsm_a_sm_pco_ms2net_prot_vals, val_to_str_ext_const(prot, &ppp_vals_ext, "Unknown")),
3118                                 (guint32)prot);
3119
3120                 curr_len-=2;
3121                 curr_offset+=2;
3122                 e_len = tvb_get_guint8(tvb, curr_offset);
3123                 proto_tree_add_text(tree,tvb, curr_offset, 1, "Length: 0x%02x (%u)", e_len , e_len);
3124                 curr_len-=1;
3125                 curr_offset+=1;
3126
3127                 switch ( prot )
3128                 {
3129                         case 0x0001:
3130                         {
3131                                 if (e_len > 0) {
3132                                         tvb_get_ipv6(tvb, curr_offset, &ipv6_addr);
3133                                         proto_tree_add_text(tree,
3134                                         tvb, curr_offset, 16,
3135                                         "IPv6: %s", ip6_to_str(&ipv6_addr));
3136                                 }
3137                                 break;
3138                         }
3139                         case 0x0002:
3140                                 break;
3141                         case 0x0003:
3142                         {
3143                                 if (e_len > 0) {
3144                                         tvb_get_ipv6(tvb, curr_offset, &ipv6_addr);
3145                                         proto_tree_add_text(tree,
3146                                         tvb, curr_offset, 16,
3147                                         "IPv6: %s", ip6_to_str(&ipv6_addr));
3148                                 }
3149                                 break;
3150                         }
3151                         case 0x0004:
3152                                 oct = tvb_get_guint8(tvb, curr_offset);
3153                                 proto_tree_add_text(tree,tvb, curr_offset, 1, "Reject Code: 0x%02x (%u)", e_len , e_len);
3154                                 break;
3155                         default:
3156                         {
3157                                 handle = dissector_get_uint_handle ( gprs_sm_pco_subdissector_table , prot );
3158                                 if ( handle != NULL )
3159                                 {
3160                                         /*
3161                                          * dissect the embedded message
3162                                          */
3163                                         l3_tvb = tvb_new_subset(tvb, curr_offset, e_len, e_len);
3164                                         call_dissector(handle, l3_tvb , pinfo  , tree );
3165                                 }
3166                                 else
3167                                 {
3168                                         /*
3169                                         * dissect the embedded DATA message
3170                                         */
3171                                         l3_tvb = tvb_new_subset(tvb, curr_offset, e_len, e_len);
3172                                         call_dissector(data_handle, l3_tvb, pinfo , tree);
3173                                 }
3174                         }
3175                 }
3176
3177                 curr_len-= e_len;
3178                 curr_offset+= e_len;
3179         }
3180         curr_offset+= curr_len;
3181
3182         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
3183
3184         return(curr_offset - offset);
3185 }
3186
3187 /*
3188  * [9] 10.5.6.4 Packet data protocol address
3189  */
3190 static const value_string gsm_a_sm_pdp_type_org_vals[] = {
3191         { 0x00, "ETSI allocated address" },
3192         { 0x01, "IETF allocated address" },
3193         { 0x0f, "Empty PDP type" },
3194         { 0, NULL }
3195 };
3196
3197 static guint16
3198 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_)
3199 {
3200         guint32 curr_offset;
3201         guint   curr_len;
3202         const gchar     *str;
3203         guchar    pdp_type_org, pdp_type_num;
3204
3205         curr_len = len;
3206         curr_offset = offset;
3207
3208         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (curr_offset << 3), 4, FALSE);
3209         proto_tree_add_item(tree, hf_gsm_a_sm_pdp_type_org, tvb, curr_offset, 1, FALSE);
3210
3211         pdp_type_org = tvb_get_guint8(tvb, curr_offset) & 0x0f;
3212         curr_offset += 1;
3213         pdp_type_num = tvb_get_guint8(tvb, curr_offset);
3214
3215         if (pdp_type_org == 0 )
3216         {
3217                 /* ETSI allocated address */
3218                 switch (pdp_type_num)
3219                 {
3220                         case 0x00: str="Reserved, used in earlier version of this protocol"; break;
3221                         case 0x01: str="PDP-type PPP"; break;
3222                         default: str="reserved";
3223                 }
3224         }
3225         else if (pdp_type_org == 1)
3226         {
3227                 /* IETF allocated addres */
3228                 switch (pdp_type_num)
3229                 {
3230                         case 0x21: str="IPv4 address"; break;
3231                         case 0x57: str="IPv6 address"; break;
3232                         case 0x8d: str="IPv4v6 address"; break;
3233                         default: str="Unknown, interpreted as IPv4 address";
3234                 }
3235         }
3236         else if ((pdp_type_num == 0) && (pdp_type_org == 0x0f))
3237                 str="Empty";
3238         else
3239                 str="Not specified";
3240
3241         proto_tree_add_text(tree,
3242                 tvb, curr_offset, 1,
3243                 "PDP type number: %s (%u)",str,pdp_type_num);
3244
3245         if (( len == 2 ) && (( pdp_type_num == 0x21 ) || ( pdp_type_num == 0x57 ) || (pdp_type_num == 0x8d)))
3246         {
3247                 proto_tree_add_text(tree,
3248                         tvb, curr_offset, 1,
3249                         "Dynamic addressing");
3250                 curr_offset += 1;
3251                 return(curr_offset - offset);
3252         }
3253         else if ( len == 2 )
3254         {
3255                 proto_tree_add_text(tree,
3256                         tvb, curr_offset, 1,
3257                         "No PDP address is included");
3258                 curr_offset += 1;
3259                 return(curr_offset - offset);
3260         }
3261
3262         curr_offset += 1;
3263         if (pdp_type_org == 1)
3264         switch (pdp_type_num)
3265         {
3266                 case 0x57:
3267                         proto_tree_add_item(tree,hf_gsm_a_sm_ip6_address,tvb,curr_offset,16,FALSE);
3268                         curr_offset+=16;
3269                         break;
3270
3271                 case 0x8d:
3272                         proto_tree_add_item(tree,hf_gsm_a_sm_ip4_address,tvb,curr_offset,4,FALSE);
3273                         curr_offset+=4;
3274                         proto_tree_add_item(tree,hf_gsm_a_sm_ip6_address,tvb,curr_offset,16,FALSE);
3275                         curr_offset+=16;
3276                         break;
3277
3278                 default:
3279                         proto_tree_add_item(tree,hf_gsm_a_sm_ip4_address,tvb,curr_offset,4,FALSE);
3280                         curr_offset+=4;
3281         }
3282
3283         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
3284
3285         return(curr_offset - offset);
3286 }
3287
3288 /*
3289  * [9] 10.5.6.5 Quality of service
3290  */
3291 static const value_string gsm_a_qos_delay_cls_vals[] = {
3292         { 0x00, "Subscribed delay class (in MS to network direction)" },
3293         { 0x01, "Delay class 1" },
3294         { 0x02, "Delay class 2" },
3295         { 0x03, "Delay class 3" },
3296         { 0x04, "Delay class 4 (best effort)" },
3297         { 0x07, "Reserved" },
3298         { 0, NULL }
3299 };
3300
3301 static const value_string gsm_a_qos_reliability_vals[] = {
3302         { 0x00, "Subscribed reliability class (in MS to network direction)" },
3303         { 0x01, "Acknowledged GTP, LLC, and RLC; Protected data" },
3304         { 0x02, "Unacknowledged GTP, Ack LLC/RLC, Protected data" },
3305         { 0x03, "Unacknowledged GTP/LLC, Ack RLC, Protected data" },
3306         { 0x04, "Unacknowledged GTP/LLC/RLC, Protected data" },
3307         { 0x05, "Unacknowledged GTP/LLC/RLC, Unprotected data" },
3308         { 0x07, "Reserved" },
3309         { 0, NULL }
3310 };
3311  /* Delivery of erroneous SDUs, octet 6 (see 3GPP TS 23.107) Bits 3 2 1 */
3312 const value_string gsm_a_qos_del_of_err_sdu_vals[] = {
3313         { 0, "Subscribed delivery of erroneous SDUs/Reserved" },
3314         { 1, "No detect('-')" },
3315         { 2, "Erroneous SDUs are delivered('yes')" },
3316         { 3, "Erroneous SDUs are not delivered('No')" },
3317         { 7, "Reserved" },
3318         { 0, NULL }
3319 };
3320
3321  /* Delivery order, octet 6 (see 3GPP TS 23.107) Bits 5 4 3 */
3322 const value_string gsm_a_qos_del_order_vals[] = {
3323         { 0, "Subscribed delivery order/Reserved" },
3324         { 1, "With delivery order ('yes')" },
3325         { 2, "Without delivery order ('no')" },
3326         { 3, "Reserved" },
3327         { 0, NULL }
3328 };
3329 /* Traffic class, octet 6 (see 3GPP TS 23.107) Bits 8 7 6 */
3330 const value_string gsm_a_qos_traffic_cls_vals[] = {
3331         { 0, "Subscribed traffic class/Reserved" },
3332         { 1, "Conversational class" },
3333         { 2, "Streaming class" },
3334         { 3, "Interactive class" },
3335         { 4, "Background class" },
3336         { 7, "Reserved" },
3337         { 0, NULL }
3338 };
3339
3340 /* Residual Bit Error Rate (BER), octet 10 (see 3GPP TS 23.107) Bits 8 7 6 5 */
3341 const value_string gsm_a_qos_ber_vals[] = {
3342         { 0, "Subscribed residual BER/Reserved" },
3343         { 1, "5*10-2" },
3344         { 2, "1*10-2" },
3345         { 3, "5*10-3" },
3346         { 4, "4*10-3" },
3347         { 5, "1*10-3" },
3348         { 6, "1*10-4" },
3349         { 7, "1*10-5" },
3350         { 8, "1*10-6" },
3351         { 9, "6*10-8" },
3352         { 10, "Reserved" },
3353         { 0, NULL }
3354 };
3355
3356 /* SDU error ratio, octet 10 (see 3GPP TS 23.107) Bits 4 3 2 1 */
3357 const value_string gsm_a_qos_sdu_err_rat_vals[] = {
3358         { 0, "Subscribed SDU error ratio/Reserved" },
3359         { 1, "1*10-2" },
3360         { 2, "7*10-3" },
3361         { 3, "1*10-3" },
3362         { 4, "1*10-4" },
3363         { 5, "1*10-5" },
3364         { 6, "1*10-6" },
3365         { 7, "1*10-1" },
3366         { 15, "Reserved" },
3367         { 0, NULL }
3368 };
3369
3370 /* Traffic handling priority, octet 11 (see 3GPP TS 23.107) Bits 2 1 */
3371 const value_string gsm_a_qos_traff_hdl_pri_vals[] = {
3372         { 0, "Subscribed traffic handling priority/Reserved" },
3373         { 1, "Priority level 1" },
3374         { 2, "Priority level 2" },
3375         { 3, "Priority level 3" },
3376         { 0, NULL }
3377 };
3378
3379 const range_string gsm_a_qos_peak_thr_vals[] = {
3380         { 0x00, 0x00, "Subscribed peak throughput/reserved" },
3381         { 0x01, 0x01, "Up to 1 000 octet/s" },
3382         { 0x02, 0x02, "Up to 2 000 octet/s" },
3383         { 0x03, 0x03, "Up to 4 000 octet/s" },
3384         { 0x04, 0x04, "Up to 8 000 octet/s" },
3385         { 0x05, 0x05, "Up to 16 000 octet/s" },
3386         { 0x06, 0x06, "Up to 32 000 octet/s" },
3387         { 0x07, 0x07, "Up to 64 000 octet/s" },
3388         { 0x08, 0x08, "Up to 128 000 octet/s" },
3389         { 0x09, 0x09, "Up to 256 000 octet/s" },
3390         { 0x0a, 0x0e, "Interpreted as Up to 1 000 octet/s" },
3391         { 0x0f, 0x0f, "Reserved" },
3392         { 0, 0, NULL }
3393 };
3394
3395 const range_string gsm_a_qos_mean_thr_vals[] = {
3396         { 0x00, 0x00, "Subscribed peak throughput/reserved" },
3397         { 0x01, 0x01, "100 octet/h" },
3398         { 0x02, 0x02, "200 octet/h" },
3399         { 0x03, 0x03, "500 octet/h" },
3400         { 0x04, 0x04, "1 000 octet/h" },
3401         { 0x05, 0x05, "2 000 octet/h" },
3402         { 0x06, 0x06, "5 000 octet/h" },
3403         { 0x07, 0x07, "10 000 octet/h" },
3404         { 0x08, 0x08, "20 000 octet/h" },
3405         { 0x09, 0x09, "50 000 octet/h" },
3406         { 0x0a, 0x0a, "100 000 octet/h" },
3407         { 0x0b, 0x0b, "200 000 octet/h" },
3408         { 0x0c, 0x0c, "500 000 octet/h" },
3409         { 0x0d, 0x0d, "1 000 000 octet/h" },
3410         { 0x0e, 0x0e, "2 000 000 octet/h" },
3411         { 0x0f, 0x0f, "5 000 000 octet/h" },
3412         { 0x10, 0x10, "10 000 000 octet/h" },
3413         { 0x11, 0x11, "20 000 000 octet/h" },
3414         { 0x12, 0x12, "50 000 000 octet/h" },
3415         { 0x13, 0x1d, "Interpreted as Best effort" },
3416         { 0x1e, 0x1e, "Reserved" },
3417         { 0x1f, 0x1f, "Best effort" },
3418         { 0, 0, NULL }
3419 };
3420
3421 const range_string gsm_a_qos_prec_class_vals[] = {
3422         { 0x00, 0x00, "Subscribed precedence/reserved" },
3423         { 0x01, 0x01, "High priority" },
3424         { 0x02, 0x02, "Normal priority" },
3425         { 0x03, 0x03, "Low priority" },
3426         { 0x04, 0x06, "Interpreted as Normal priority" },
3427         { 0x07, 0x07, "Reserved" },
3428         { 0, 0, NULL }
3429 };
3430
3431 const true_false_string gsm_a_qos_signalling_ind_value = {
3432         "Optimised for signalling traffic",
3433         "Not optimised for signalling traffic"
3434 };
3435
3436 /* Helper function returning the main bitrates in kbps */
3437 static guint32
3438 qos_calc_bitrate(guint8 oct)
3439 {
3440         if (oct <= 0x3f)
3441                 return oct;
3442         if (oct <= 0x7f)
3443                 return 64 + (oct-0x40) * 8;
3444
3445         return 576 + (oct-0x80) * 64;
3446 }
3447
3448 /* Helper function returning the extended bitrates in kbps */
3449 static guint32
3450 qos_calc_ext_bitrate(guint8 oct)
3451 {
3452         if (oct <= 0x4a)
3453                 return 8600 + oct * 100;
3454         if (oct <= 0xba)
3455                 return 16000 + (oct-0x4a) * 1000;
3456
3457         return 128000 + (oct - 0xba) * 2000;
3458 }
3459
3460 guint16
3461 de_sm_qos(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
3462 {
3463         guint32 curr_offset;
3464         guchar     oct, tmp_oct;
3465         const gchar     *str;
3466         guint32 temp32;
3467
3468         curr_offset = offset;
3469
3470         /* Octet 3 */
3471         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (curr_offset << 3), 2, FALSE);
3472         proto_tree_add_item(tree, hf_gsm_a_qos_delay_cls, tvb, curr_offset, 1, FALSE);
3473         proto_tree_add_item(tree, hf_gsm_a_qos_reliability_cls, tvb, curr_offset, 1, FALSE);
3474         curr_offset+= 1;
3475
3476         /* Octet 4 */
3477         oct = tvb_get_guint8(tvb, curr_offset);
3478         proto_tree_add_item(tree, hf_gsm_a_qos_peak_thr, tvb, curr_offset, 1, FALSE);
3479         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (curr_offset << 3) + 4, 1, FALSE);
3480         proto_tree_add_item(tree, hf_gsm_a_qos_prec_class, tvb, curr_offset, 1, FALSE);
3481         curr_offset+= 1;
3482
3483         /* Octet 5 */
3484         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (curr_offset << 3), 3, FALSE);
3485         proto_tree_add_item(tree, hf_gsm_a_qos_mean_thr, tvb, curr_offset, 1, FALSE);
3486         curr_offset+= 1;
3487
3488         NO_MORE_DATA_CHECK(len);
3489
3490         /* Octet 6 */
3491         proto_tree_add_item(tree, hf_gsm_a_qos_traffic_cls, tvb, curr_offset, 1, FALSE);
3492         proto_tree_add_item(tree, hf_gsm_a_qos_del_order, tvb, curr_offset, 1, FALSE);
3493         proto_tree_add_item(tree, hf_gsm_a_qos_del_of_err_sdu, tvb, curr_offset, 1, FALSE);
3494         curr_offset+= 1;
3495
3496         NO_MORE_DATA_CHECK(len);
3497
3498         /* Octet 7 */
3499         oct = tvb_get_guint8(tvb, curr_offset);
3500
3501         switch ( oct )
3502         {
3503                 case 0x00: str="Subscribed maximum SDU size/reserved"; break;
3504                 case 0x97: str="1502 octets"; break;
3505                 case 0x98: str="1510 octets"; break;
3506                 case 0x99: str="1520 octets"; break;
3507                 case 0xff: str="Reserved"; break;
3508                 default: str="Unspecified";
3509         }
3510
3511         if (( oct >= 1 ) && ( oct <= 0x96 ))
3512                 proto_tree_add_text(tree,
3513                         tvb, curr_offset, 1,
3514                         "Maximum SDU size: %u octets (%u)",oct*10, oct);
3515         else
3516                 proto_tree_add_text(tree,
3517                         tvb, curr_offset, 1,
3518                         "Maximum SDU size: %s (%u)",str, oct);
3519
3520         curr_offset+= 1;
3521
3522         NO_MORE_DATA_CHECK(len);
3523
3524         /* Octet 8 */
3525         oct = tvb_get_guint8(tvb, curr_offset);
3526
3527         switch (oct)
3528         {
3529                 case 0x00: str = "Subscribed maximum bit rate for uplink/reserved"; break;
3530                 case 0xff: str = "0 kbps"; break;
3531                 default: str = ep_strdup_printf("%u kbps", qos_calc_bitrate(oct));
3532         }
3533
3534         proto_tree_add_uint_format_value(tree, hf_gsm_a_qos_max_bitrate_upl, tvb,
3535                 curr_offset, 1, oct, "%s (%u)", str, oct);
3536         curr_offset+= 1;
3537
3538         NO_MORE_DATA_CHECK(len);
3539
3540         /* Octet 9 */
3541         oct = tvb_get_guint8(tvb, curr_offset);
3542
3543         switch ( oct )
3544         {
3545                 case 0x00: str="Subscribed maximum bit rate for downlink/reserved"; break;
3546                 case 0xff: str="0 kbps"; break;
3547                 default: str = ep_strdup_printf("%u kbps", qos_calc_bitrate(oct));
3548         }
3549
3550         proto_tree_add_uint_format_value(tree, hf_gsm_a_qos_max_bitrate_downl, tvb,
3551                 curr_offset, 1, oct, "%s (%u)", str, oct);
3552         curr_offset+= 1;
3553
3554         NO_MORE_DATA_CHECK(len);
3555
3556         /* Octet 10 */
3557         proto_tree_add_item(tree, hf_gsm_a_qos_ber, tvb, curr_offset, 1, FALSE);
3558         proto_tree_add_item(tree, hf_gsm_a_qos_sdu_err_rat, tvb, curr_offset, 1, FALSE);
3559
3560         curr_offset+= 1;
3561         NO_MORE_DATA_CHECK(len);
3562
3563         /* Octet 11 */
3564         oct = tvb_get_guint8(tvb, curr_offset);
3565
3566         tmp_oct = oct >> 2;
3567         switch (tmp_oct)
3568         {
3569                 case 0x00: str="Subscribed transfer delay/reserved"; break;
3570                 case 0x3f: str="Reserved"; break;
3571                 default:
3572                         if (tmp_oct <= 0x0f)
3573                                 temp32 = tmp_oct * 10;
3574                         else if (tmp_oct <= 0x1f)
3575                                 temp32 = (tmp_oct - 0x10) * 50 + 200;
3576                         else
3577                                 temp32 = (tmp_oct - 0x20) * 100 + 1000;
3578                         str = ep_strdup_printf("%u ms", temp32);
3579         }
3580
3581         proto_tree_add_uint_format_value(tree, hf_gsm_a_qos_trans_delay, tvb,
3582                 curr_offset, 1, oct, "%s (%u)", str, tmp_oct);
3583
3584         tmp_oct = oct & 0x03;
3585         if (tmp_oct == 0)
3586                 str = "Subscribed traffic handling priority/reserved";
3587         else
3588                 str = ep_strdup_printf("Priority level %u", tmp_oct);
3589
3590         proto_tree_add_uint_format_value(tree, hf_gsm_a_qos_traf_handl_prio, tvb,
3591                 curr_offset, 1, oct, "%s (%u)", str, tmp_oct);
3592
3593         curr_offset+= 1;
3594         NO_MORE_DATA_CHECK(len);
3595
3596         /* Octet 12 */
3597         oct = tvb_get_guint8(tvb, curr_offset);
3598
3599         switch ( oct )
3600         {
3601                 case 0x00: str="Subscribed guaranteed bit rate for uplink/reserved"; break;
3602                 case 0xff: str="0 kbps"; break;
3603                 default: str = ep_strdup_printf("%u kbps", qos_calc_bitrate(oct));
3604         }
3605
3606         proto_tree_add_uint_format_value(tree, hf_gsm_a_qos_guar_bitrate_upl, tvb,
3607                 curr_offset, 1, oct, "%s (%u)", str, oct);
3608
3609         curr_offset+= 1;
3610         NO_MORE_DATA_CHECK(len);
3611
3612         /* Octet 13 */
3613         oct = tvb_get_guint8(tvb, curr_offset);
3614
3615         switch ( oct )
3616         {
3617                 case 0x00: str="Subscribed guaranteed bit rate for downlink/reserved"; break;
3618                 case 0xff: str="0 kbps"; break;
3619                 default: str = ep_strdup_printf("%u kbps", qos_calc_bitrate(oct));
3620         }
3621
3622         proto_tree_add_uint_format_value(tree, hf_gsm_a_qos_guar_bitrate_downl, tvb,
3623                 curr_offset, 1, oct, "%s (%u)", str, oct);
3624
3625         curr_offset+= 1;
3626         NO_MORE_DATA_CHECK(len);
3627
3628         /* Ocet 14 */
3629         oct = tvb_get_guint8(tvb, curr_offset);
3630         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (curr_offset << 3), 3, FALSE);
3631         proto_tree_add_item(tree, hf_gsm_a_qos_signalling_ind, tvb , curr_offset, 1, FALSE);
3632
3633         tmp_oct = oct & 7;
3634         if (tmp_oct == 0x01)
3635                 str = "speech";
3636         else
3637                 str = "unknown";
3638
3639         proto_tree_add_uint_format_value(tree, hf_gsm_a_qos_source_stat_desc, tvb,
3640                 curr_offset, 1, oct, "%s (%u)", str, tmp_oct);
3641
3642         curr_offset+= 1;
3643         NO_MORE_DATA_CHECK(len);
3644
3645         /* Octet 15 */
3646         oct = tvb_get_guint8(tvb, curr_offset);
3647
3648         if (oct == 0x00)
3649                 str = "Use the value indicated by the Maximum bit rate for downlink";
3650         else
3651         {
3652                 temp32 = qos_calc_ext_bitrate(oct);
3653                 if (temp32 % 1000 == 0)
3654                         str = ep_strdup_printf("%u Mbps", temp32 / 1000);
3655                 else
3656                         str = ep_strdup_printf("%u kbps", temp32);
3657         }
3658         proto_tree_add_uint_format_value(tree, hf_gsm_a_qos_max_bitrate_downl_ext, tvb,
3659                 curr_offset, 1, oct, "%s (%u)", str, oct);
3660
3661         curr_offset+= 1;
3662         NO_MORE_DATA_CHECK(len);
3663
3664         /* Octet 16 */
3665         oct = tvb_get_guint8(tvb, curr_offset);
3666
3667         if (oct == 0x00)
3668                 str = "Use the value indicated by the Guaranteed bit rate for downlink";
3669         else
3670         {
3671                 temp32 = qos_calc_ext_bitrate(oct);
3672                 if (temp32 % 1000 == 0)
3673                         str = ep_strdup_printf("%u Mbps", temp32 / 1000);
3674                 else
3675                         str = ep_strdup_printf("%u kbps", temp32);
3676         }
3677         proto_tree_add_uint_format_value(tree, hf_gsm_a_qos_guar_bitrate_downl_ext, tvb,
3678                 curr_offset, 1, oct, "%s (%u)", str, oct);
3679
3680         curr_offset+= 1;
3681         NO_MORE_DATA_CHECK(len);
3682
3683         /* Maximum bit rate for uplink (extended) Octet 17 */
3684         oct = tvb_get_guint8(tvb, curr_offset);
3685
3686         if (oct == 0x00)
3687                 str = "Use the value indicated by the Maximum bit rate for uplink";
3688         else
3689         {
3690                 temp32 = qos_calc_ext_bitrate(oct);
3691                 if (temp32 % 1000 == 0)
3692                         str = ep_strdup_printf("%u Mbps", temp32 / 1000);
3693                 else
3694                         str = ep_strdup_printf("%u kbps", temp32);
3695         }
3696         proto_tree_add_uint_format_value(tree, hf_gsm_a_qos_max_bitrate_upl_ext, tvb,
3697                 curr_offset, 1, oct, "%s (%u)", str, oct);
3698
3699         curr_offset+= 1;
3700         NO_MORE_DATA_CHECK(len);
3701
3702         /* Guaranteed bit rate for uplink (extended) Octet 18 */
3703         oct = tvb_get_guint8(tvb, curr_offset);
3704
3705         if (oct == 0x00)
3706                 str = "Use the value indicated by the Guaranteed bit rate for uplink";
3707         else
3708         {
3709                 temp32 = qos_calc_ext_bitrate(oct);
3710                 if (temp32 % 1000 == 0)
3711                         str = ep_strdup_printf("%u Mbps", temp32 / 1000);
3712                 else
3713                         str = ep_strdup_printf("%u kbps", temp32);
3714         }
3715         proto_tree_add_uint_format_value(tree, hf_gsm_a_qos_guar_bitrate_upl_ext, tvb,
3716                 curr_offset, 1, oct, "%s (%u)", str, oct);
3717
3718         curr_offset+= 1;
3719
3720         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
3721
3722         return(curr_offset - offset);
3723 }
3724
3725 /*
3726  * [9] 10.5.6.6 SM cause
3727  */
3728 static const value_string gsm_a_sm_cause_vals[] = {
3729         { 0x08, "Operator Determined Barring" },
3730         { 0x18, "MBMS bearer capabilities insufficient for the service" },
3731         { 0x19, "LLC or SNDCP failure(GSM only)" },
3732         { 0x1a, "Insufficient resources" },
3733         { 0x1b, "Missing or unknown APN" },
3734         { 0x1c, "Unknown PDP address or PDP type" },
3735         { 0x1d, "User Authentication failed" },
3736         { 0x1e, "Activation rejected by GGSN" },
3737         { 0x1f, "Activation rejected, unspecified" },
3738         { 0x20, "Service option not supported" },
3739         { 0x21, "Requested service option not subscribed" },
3740         { 0x22, "Service option temporarily out of order" },
3741         { 0x23, "NSAPI already used (not sent)" },
3742         { 0x24, "Regular deactivation" },
3743         { 0x25, "QoS not accepted" },
3744         { 0x26, "Network failure" },
3745         { 0x27, "Reactivation required" },
3746         { 0x28, "Feature not supported" },
3747         { 0x29, "Semantic error in the TFT operation" },
3748         { 0x2a, "Syntactical error in the TFT operation" },
3749         { 0x2b, "Unknown PDP context" },
3750         { 0x2c, "Semantic errors in packet filter(s)" },
3751         { 0x2d, "Syntactical errors in packet filter(s)" },
3752         { 0x2e, "PDP context without TFT already activated" },
3753         { 0x2f, "Multicast group membership time-out" },
3754         { 0x2c, "Semantic errors in packet filter(s)" },
3755         { 0x2d, "Syntactical errors in packet filter(s)" },
3756         { 0x30, "Activation rejected, BCM violation" },
3757         { 0x32, "PDP type IPv4 only allowed" },
3758         { 0x33, "PDP type IPv6 only allowed" },
3759         { 0x34, "Single address bearers only allowed" },
3760         { 0x51, "Invalid transaction identifier value" },
3761         { 0x5f, "Semantically incorrect message" },
3762         { 0x60, "Invalid mandatory information" },
3763         { 0x61, "Message type non-existent or not implemented" },
3764         { 0x62, "Message type not compatible with the protocol state" },
3765         { 0x63, "Information element non-existent or not implemented" },
3766         { 0x64, "Conditional IE error" },
3767         { 0x65, "Message not compatible with the protocol state" },
3768         { 0x6f, "Protocol error, unspecified" },
3769         { 0x70, "APN restriction value incompatible with active PDP context" },
3770         { 0, NULL }
3771 };
3772
3773 static guint16
3774 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_)
3775 {
3776         guint8  oct;
3777         const gchar     *str;
3778
3779         oct = tvb_get_guint8(tvb, offset);
3780         str = match_strval(oct, gsm_a_sm_cause_vals);
3781
3782         /* SM Cause can be sent in both directions */
3783         if (!str)
3784                 str = "Protocol error, unspecified / Service option temporarily out of order";
3785
3786         proto_tree_add_uint_format_value(tree, hf_gsm_a_sm_cause, tvb,
3787                                 offset, 1, oct, "%s (%u)", str, oct);
3788
3789         /* no length check possible */
3790         return(1);
3791 }
3792
3793 /*
3794  * [9] 10.5.6.6a SM cause 2
3795  */
3796 static guint16
3797 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_)
3798 {
3799         guint8  oct;
3800         const gchar     *str;
3801
3802         oct = tvb_get_guint8(tvb, offset);
3803         str = match_strval(oct, gsm_a_sm_cause_vals);
3804
3805         /* SM Cause 2 is sent only in the Network-to-MS direction */
3806         if (!str)
3807                 str = "Service option temporarily out of order";
3808
3809         proto_tree_add_uint_format_value(tree, hf_gsm_a_sm_cause_2, tvb,
3810                                 offset, 1, oct, "%s (%u)", str, oct);
3811
3812         /* no length check possible */
3813         return(1);
3814 }
3815 /*
3816  * [7] 10.5.6.7
3817  */
3818 static guint16
3819 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_)
3820 {
3821         guint32 curr_offset;
3822         guint   curr_len;
3823         gchar   oct;
3824
3825         static const gchar *ti_flag[2]={
3826                 "The message is sent from the side that originates the TI" ,
3827                 "The message is sent to the side that originates the TI" };
3828
3829         curr_len = len;
3830         curr_offset = offset;
3831
3832         oct = tvb_get_guint8(tvb, curr_offset);
3833
3834         proto_tree_add_text(tree,
3835                 tvb, curr_offset, 1,
3836                 "TI flag: %s (%u)",ti_flag[oct>>7],oct>>7);
3837
3838         if ( curr_len > 1 )
3839         {
3840                 oct = tvb_get_guint8(tvb, curr_offset);
3841
3842                 proto_tree_add_text(tree,
3843                         tvb, curr_offset, 1,
3844                         "TI value: 0x%02x (%u)",oct&0x7f,oct&0x7f);
3845
3846                 proto_tree_add_text(tree,
3847                         tvb, curr_offset, 1,
3848                         "ext: 0x%02x (%u)",oct>>7,oct>>7);
3849
3850         }
3851         else
3852         {
3853                 proto_tree_add_text(tree,
3854                         tvb, curr_offset, 1,
3855                         "TI value: 0x%02x (%u)",(oct>>4)&7,(oct>>4)&7);
3856         }
3857
3858         curr_offset+= curr_len;
3859
3860         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
3861
3862         return(curr_offset - offset);
3863 }
3864
3865 /*
3866  * [9] 10.5.6.9 LLC service access point identifier
3867  */
3868 static const value_string gsm_a_sm_llc_sapi_vals[] = {
3869         { 0, "LLC SAPI not assigned" },
3870         { 3, "SAPI 3" },
3871         { 5, "SAPI 5" },
3872         { 9, "SAPI 9" },
3873         { 11, "SAPI 11" },
3874         { 0, NULL }
3875 };
3876
3877 static guint16
3878 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_)
3879 {
3880         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, offset << 3, 4, FALSE);
3881         proto_tree_add_item(tree, hf_gsm_a_sm_llc_sapi, tvb, offset, 1, FALSE);
3882
3883         /* no length check possible */
3884         return(1);
3885 }
3886
3887 /*
3888  * [9] 10.5.6.10 Tear down indicator
3889  */
3890 const true_false_string gsm_a_sm_tdi_value = {
3891         "Tear down requested",
3892         "Tear down not requested"
3893 };
3894
3895 static guint16
3896 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_)
3897 {
3898         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (offset << 3) + 4, 3, FALSE);
3899         proto_tree_add_item(tree, hf_gsm_a_sm_tdi, tvb, offset, 1, FALSE);
3900
3901         /* no length check possible */
3902         return(1);
3903 }
3904
3905 /*
3906  * [9] 10.5.6.11 Packet Flow Identifier
3907  */
3908 static const range_string gsm_a_sm_packet_flow_id_vals[] = {
3909         { 0x00, 0x00, "Best Effort"},
3910         { 0x01, 0x01, "Signaling"},
3911         { 0x02, 0x02, "SMS"},
3912         { 0x03, 0x03, "TOM8"},
3913         { 0x04, 0x07, "Reserved"},
3914         { 0x08, 0x7f, "Dynamically assigned"},
3915         { 0x00, 0x00, NULL }
3916 };
3917
3918 guint16
3919 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_)
3920 {
3921         guint32 curr_offset;
3922         guint value;
3923
3924         curr_offset = offset;
3925         value = tvb_get_guint8(tvb,curr_offset);
3926         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, curr_offset << 3, 1, FALSE);
3927         proto_tree_add_item(tree, hf_gsm_a_sm_packet_flow_id, tvb, curr_offset, 1, FALSE);
3928         curr_offset++;
3929
3930     if (add_string)
3931         g_snprintf(add_string, string_len, " - %s", rval_to_str(value, gsm_a_sm_packet_flow_id_vals, "Unknown"));
3932
3933         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
3934
3935         return(curr_offset - offset);
3936 }
3937
3938 /*
3939  * [7] 10.5.6.12     TFT - Traffic Flow Template
3940  */
3941 /* TFT operation code (octet 3) */
3942 static const value_string gsm_a_tft_op_code_vals[] = {
3943         { 0,            "Spare"},
3944         { 1,            "Create new TFT"},
3945         { 2,            "Delete existing TFT"},
3946         { 3,            "Add packet filters to existing TFT"},
3947         { 4,            "Replace packet filters in existing TFT"},
3948         { 5,            "Delete packet filters from existing TFT"},
3949         { 6,            "No TFT operation"},
3950         { 7,            "Reserved"},
3951         { 0,    NULL }
3952 };
3953
3954 static const true_false_string gsm_a_tft_e_bit  = {
3955   "Parameters list is included",
3956   "Parameters list is not included"
3957 };
3958
3959 static const value_string gsm_a_tft_pkt_flt_dir_vals[] = {
3960         { 0,    "Pre Rel-7 TFT filter"},
3961         { 1,    "Downlink only"},
3962         { 2,    "Uplink only"},
3963         { 3,    "Bidirectional"},
3964         { 0,    NULL }
3965 };
3966
3967 static const value_string gsm_a_tft_param_id_vals[] = {
3968         { 1,    "Authorization Token"},
3969         { 2,    "Flow Identifier"},
3970         { 3,    "Packet Filter Identifier"},
3971         { 0,    NULL }
3972 };
3973
3974 guint16
3975 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_)
3976 {
3977         guint32       curr_offset;
3978         guint         curr_len;
3979         proto_item   *tf = NULL;
3980         proto_tree   *tf_tree = NULL;
3981         proto_tree   *comp_tree = NULL;
3982         guchar        op_code;
3983         guchar        pkt_fil_count;
3984         guchar        e_bit;
3985         const gchar  *str;
3986         guchar        count;
3987         guchar        oct;
3988         gint          pf_length;
3989         gint          i;
3990         gint          pack_component_type;
3991         gint          param;
3992
3993         curr_len = len;
3994         curr_offset = offset;
3995
3996         /*
3997          * parse first octet. It contain TFT operation code, E bit and Number of packet filters
3998          */
3999         oct = tvb_get_guint8(tvb, curr_offset);
4000
4001         op_code = oct>>5;
4002         pkt_fil_count = oct&0x0f;
4003         e_bit = (oct>>4)&1;
4004
4005         proto_tree_add_item(tree,hf_gsm_a_tft_op_code,tvb,curr_offset,1,FALSE);
4006         proto_tree_add_item(tree,hf_gsm_a_tft_e_bit,tvb,curr_offset,1,FALSE);
4007         proto_tree_add_item(tree,hf_gsm_a_tft_pkt_flt,tvb,curr_offset,1,FALSE);
4008
4009         curr_offset++;
4010         curr_len--;
4011
4012         /* Packet filter list dissect */
4013
4014         count = 0;
4015         if ( op_code == 2 )                     /* delete TFT contains no packet filters. so we will jump over it */
4016                 count = pkt_fil_count;
4017         while ( count < pkt_fil_count )
4018         {
4019                 tf = proto_tree_add_text(tree,
4020                         tvb, curr_offset, 1,
4021                         "Packet filter %d",count);   /* 0-> 7 */
4022
4023                 tf_tree = proto_item_add_subtree(tf, ett_sm_tft );
4024
4025                 if ( op_code == 5 )  /* Delete packet filters from existing TFT - just a list of identifiers */
4026                 {
4027                         if ((curr_offset-offset)<1) {
4028                                 proto_tree_add_text(tf_tree,tvb, curr_offset, 1,"Not enough data");
4029                                 return(len);
4030                         }
4031                         proto_tree_add_bits_item(tf_tree, hf_gsm_a_spare_bits, tvb, (curr_offset<<3), 4, FALSE);
4032                         proto_tree_add_item(tf_tree, hf_gsm_a_tft_pkt_flt_id, tvb, curr_offset, 1, FALSE);
4033                         curr_offset++;
4034                         curr_len--;
4035                         count++;
4036                 }
4037                 else                            /* create new, Add packet filters or Replace packet filters */
4038                 {
4039
4040                         if ((curr_offset-offset)<1) {
4041                                 proto_tree_add_text(tf_tree,tvb, curr_offset, 1,"Not enough data");
4042                                 return(len);
4043                         }
4044                         proto_tree_add_bits_item(tf_tree, hf_gsm_a_spare_bits, tvb, (curr_offset<<3), 2, FALSE);
4045                         proto_tree_add_item(tf_tree, hf_gsm_a_tft_pkt_flt_dir, tvb, curr_offset, 1, FALSE);
4046                         proto_tree_add_item(tf_tree, hf_gsm_a_tft_pkt_flt_id, tvb, curr_offset, 1, FALSE);
4047                         curr_offset++;
4048                         curr_len--;
4049
4050                         if ((curr_offset-offset)<1) {
4051                                 proto_tree_add_text(tf_tree,tvb, curr_offset, 1,"Not enough data");
4052                                 return(len);
4053                         }
4054                         oct = tvb_get_guint8(tvb, curr_offset);
4055                         curr_offset++;
4056                         curr_len--;
4057
4058                         proto_tree_add_text(tf_tree,
4059                                 tvb, curr_offset-1, 1,
4060                                 "Packet evaluation precedence: 0x%02x (%u)",oct,oct );
4061
4062                         if ((curr_offset-offset)<1) { proto_tree_add_text(tf_tree,tvb, curr_offset, 1,"Not enough data"); return(len);}
4063                         pf_length = tvb_get_guint8(tvb, curr_offset);
4064                         curr_offset++;
4065                         curr_len--;
4066
4067                         proto_tree_add_text(tf_tree,
4068                                 tvb, curr_offset-1, 1,
4069                                 "Packet filter length: 0x%02x (%u)",pf_length,pf_length );
4070                         /* New tree for component */
4071
4072                         /* Dissect Packet filter Component */
4073                         /* while ( filter_len > 1 ) */
4074                         /* packet filter component type identifier: */
4075
4076                         while (pf_length > 0 ){
4077                                 if ((curr_offset-offset)<1) {
4078                                         proto_tree_add_text(tf_tree,tvb, curr_offset, 1,"Not enough data");
4079                                         return(len);
4080                                 }
4081                                 pack_component_type = tvb_get_guint8(tvb, curr_offset);
4082                                 curr_offset++;
4083                                 curr_len--;
4084                                 pf_length--;
4085
4086                                 tf=proto_tree_add_text(tf_tree,tvb, curr_offset-1, 1,"Packet filter component type identifier: ");
4087                                 comp_tree = proto_item_add_subtree(tf, ett_sm_tft );
4088
4089                                 switch ( pack_component_type ){
4090
4091                                 case 0x10:
4092                                         str="IPv4 remote address type";
4093                                         proto_tree_add_item(comp_tree,hf_gsm_a_sm_ip4_address,tvb,curr_offset,4,FALSE);
4094                                         curr_offset+=4;
4095                                         curr_len-=4;
4096                                         proto_tree_add_item(comp_tree,hf_gsm_a_sm_ip4_mask,tvb,curr_offset,4,FALSE);
4097                                         curr_offset+=4;
4098                                         curr_len-=4;
4099                                         pf_length-=8;
4100                                         break;
4101
4102                                 case 0x20:
4103                                         str="IPv6 remote address type";
4104                                         proto_tree_add_item(comp_tree,hf_gsm_a_sm_ip6_address,tvb,curr_offset,16,FALSE);
4105                                         curr_offset+=16;
4106                                         curr_len-=16;
4107                                         proto_tree_add_item(comp_tree,hf_gsm_a_sm_ip6_mask,tvb,curr_offset,16,FALSE);
4108                                         curr_offset+=16;
4109                                         curr_len-=16;
4110                                         pf_length-=32;
4111                                         break;
4112
4113                                 case 0x30:
4114                                         str="Protocol identifier/Next header type";
4115                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_protocol_header,tvb,curr_offset,1,FALSE);
4116                                         curr_offset+=1;
4117                                         curr_len-=1;
4118                                         pf_length-=1;
4119                                         break;
4120
4121                                 case 0x40:
4122                                         str="Single local port type";
4123                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_port,tvb,curr_offset,2,FALSE);
4124                                         curr_offset+=2;
4125                                         curr_len-=2;
4126                                         pf_length-=2;
4127                                         break;
4128
4129                                 case 0x41:
4130                                         str="Local port range type";
4131                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_port_low,tvb,curr_offset,2,FALSE);
4132                                         curr_offset+=2;
4133                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_port_high,tvb,curr_offset,2,FALSE);
4134                                         curr_offset+=2;
4135                                         curr_len-=4;
4136                                         pf_length-=4;
4137                                         break;
4138
4139                                 case 0x50:
4140                                         str="Single remote port type";
4141                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_port,tvb,curr_offset,2,FALSE);
4142                                         curr_offset+=2;
4143                                         curr_len-=2;
4144                                         pf_length-=2;
4145                                         break;
4146
4147                                 case 0x51:
4148                                         str="Remote port range type";
4149                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_port_low,tvb,curr_offset,2,FALSE);
4150                                         curr_offset+=2;
4151                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_port_high,tvb,curr_offset,2,FALSE);
4152                                         curr_offset+=2;
4153                                         curr_len-=4;
4154                                         pf_length-=4;
4155                                         break;
4156
4157                                 case 0x60:
4158                                         str="Security parameter index type";
4159                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_security,tvb,curr_offset,4,FALSE);
4160                                         curr_offset+=4;
4161                                         curr_len-=4;
4162                                         pf_length-=4;
4163                                         break;
4164
4165
4166                                 case 0x70:
4167                                         str="Type of service/Traffic class type";
4168                                         proto_tree_add_item(comp_tree,hf_gsm_a_qos_traffic_cls,tvb,curr_offset,1,FALSE);
4169                                         curr_offset++;
4170                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_traffic_mask,tvb,curr_offset,1,FALSE);
4171                                         curr_offset++;
4172                                         curr_len-=2;
4173                                         pf_length-=2;
4174                                         break;
4175
4176                                 case 0x80:
4177                                         str="Flow label type";
4178                                         proto_tree_add_bits_item(comp_tree, hf_gsm_a_spare_bits, tvb, (curr_offset<<3), 4, FALSE);
4179                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_flow_label_type,tvb,curr_offset,3,FALSE);
4180                                         curr_offset+=3;
4181                                         curr_len-=3;
4182                                         pf_length-=3;
4183                                         break;
4184
4185                                 default:
4186                                         str="not specified";
4187                                         curr_offset+=pf_length;
4188                                         curr_len-=pf_length;
4189                                         pf_length=0;
4190                                 }
4191                                 proto_item_append_text(tf, "%s (%u)", str, pack_component_type);
4192                         }
4193                         count++;
4194                 }
4195         }
4196
4197         /* The parameters list contains a variable number of parameters that might need to be
4198          * transferred in addition to the packet filters. If the parameters list is included, the E
4199          * bit is set to 1; otherwise, the E bit is set to 0.
4200          */
4201         if ((e_bit == 1) && curr_len) {
4202                 count = 0;
4203                 while (curr_len) {
4204                         pf_length = tvb_get_guint8(tvb, curr_offset+1);
4205                         tf = proto_tree_add_text(tree, tvb, curr_offset, pf_length+2, "Parameter %d" ,count);
4206                         tf_tree = proto_item_add_subtree(tf, ett_sm_tft );
4207                         param = tvb_get_guint8(tvb, curr_offset);
4208                         proto_tree_add_item(tf_tree, hf_gsm_a_tft_param_id, tvb, curr_offset, 1, FALSE);
4209                         curr_offset += 2;
4210                         curr_len -= 2;
4211                         switch (param) {
4212                         case 0x01:
4213                                 proto_tree_add_text(tf_tree, tvb, curr_offset, pf_length, "Authorization token value: 0x%s",
4214                                                 tvb_bytes_to_str(tvb, curr_offset, pf_length));
4215                                 break;
4216
4217                         case 0x02:
4218                                 proto_tree_add_text(tf_tree, tvb, curr_offset, 2, "Media Component number value: 0x%x",
4219                                                 tvb_get_bits16(tvb, curr_offset<<3, 16, FALSE));
4220                                 proto_tree_add_text(tf_tree, tvb, curr_offset+2, 2, "IP flow number: 0x%x",
4221                                                 tvb_get_bits16(tvb, (curr_offset+2)<<3, 16, FALSE));
4222                                 break;
4223
4224                         case 0x03:
4225                                 for (i = 0; i < pf_length; i++) {
4226                                         proto_tree_add_text(tf_tree, tvb, curr_offset+i, 1, "Packet filter identifier %d: %d",
4227                                                     i, tvb_get_guint8(tvb, curr_offset+i));
4228                                 }
4229                                 break;
4230
4231                         default:
4232                                 proto_tree_add_text(tf_tree, tvb, curr_offset, pf_length, "Parameter content: 0x%s",
4233                                                     tvb_bytes_to_str(tvb, curr_offset, pf_length));
4234                                 break;
4235                         }
4236                         curr_offset += pf_length;
4237                         curr_len -= pf_length;
4238                         count++;
4239                 }
4240         }
4241
4242         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
4243
4244         return(len);
4245 }
4246
4247 /*
4248  * [9] 10.5.6.13 Temporary Mobile Group Identity (TMGI)
4249  */
4250 static guint16
4251 de_sm_tmgi(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4252 {
4253         guint32 curr_offset;
4254
4255         curr_offset = offset;
4256
4257         proto_tree_add_item(tree, hf_gsm_a_sm_tmgi, tvb, curr_offset, 3, FALSE);
4258         curr_offset += 3;
4259
4260         NO_MORE_DATA_CHECK(len);
4261         curr_offset = dissect_e212_mcc_mnc(tvb, gsm_a_dtap_pinfo, tree, curr_offset, TRUE);
4262
4263         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
4264
4265         return(curr_offset - offset);
4266 }
4267
4268 /*
4269  * [9] 10.5.6.14 MBMS bearer capabilities
4270  */
4271 static guint16
4272 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_)
4273 {
4274         guint32 curr_offset, temp32;
4275         guint8 oct;
4276         const gchar *str;
4277
4278         curr_offset = offset;
4279
4280         oct = tvb_get_guint8(tvb, curr_offset);
4281
4282         switch (oct)
4283         {
4284                 case 0x00: str="Subscribed maximum bit rate for downlink/reserved"; break;
4285                 case 0xff: str="0 kbps"; break;
4286                 default: str = ep_strdup_printf("%u kbps", qos_calc_bitrate(oct));
4287         }
4288
4289         proto_tree_add_uint_format_value(tree, hf_gsm_a_qos_max_bitrate_downl, tvb,
4290                 curr_offset, 1, oct, "%s (%u)", str, oct);
4291         curr_offset+= 1;
4292
4293         NO_MORE_DATA_CHECK(len);
4294
4295         oct = tvb_get_guint8(tvb, curr_offset);
4296
4297         if (oct == 0x00)
4298                 str = "Use the value indicated by the Maximum bit rate for downlink";
4299         else
4300         {
4301                 temp32 = qos_calc_ext_bitrate(oct);
4302                 if (temp32 % 1000 == 0)
4303                         str = ep_strdup_printf("%u Mbps", temp32 / 1000);
4304                 else
4305                         str = ep_strdup_printf("%u kbps", temp32);
4306         }
4307         proto_tree_add_uint_format_value(tree, hf_gsm_a_qos_max_bitrate_downl_ext, tvb,
4308                 curr_offset, 1, oct, "%s (%u)", str, oct);
4309
4310         curr_offset+= 1;
4311
4312         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
4313
4314         return(curr_offset - offset);
4315 }
4316
4317 /*
4318  * [9] 10.5.6.15 MBMS protocol configuration options
4319  */
4320 static guint16
4321 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_)
4322 {
4323         guint32 curr_offset;
4324
4325         curr_offset = offset;
4326         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (curr_offset<<3), 8, FALSE);
4327         curr_offset++;
4328
4329         EXTRANEOUS_DATA_CHECK_EXPERT(len, curr_offset - offset, pinfo);
4330
4331         return(curr_offset - offset);
4332 }
4333
4334 /*
4335  * [9] 10.5.6.16 Enhanced network service access point identifier
4336  */
4337 static guint16
4338 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_)
4339 {
4340         guint8  oct;
4341         const gchar *str;
4342
4343         oct = tvb_get_guint8(tvb, offset);
4344
4345         if(oct < 0x80)
4346                 str = "Reserved";
4347         else if (oct < 0xff)
4348                         str = ep_strdup_printf("NSAPI %u for Multimedia Broadcast/Multicast Service (MBMS) Multicast mode", oct);
4349                 else
4350                         str = "Reserved for use by lower layers in the p2p radio bearer allocation message for MBMS Broadcast mode";
4351
4352
4353         proto_tree_add_uint_format_value(tree, hf_gsm_a_sm_enh_nsapi, tvb,
4354                 offset, 1, oct, "%s (%u)", str, oct);
4355
4356         /* no length check possible */
4357         return(1);
4358 }
4359
4360 /*
4361  * [9] 10.5.6.17 Request type
4362  */
4363 static const value_string gsm_a_sm_req_type_vals[] = {
4364         { 0x01, "Initial request" },
4365         { 0x02, "Handover" },
4366         { 0x03, "Unused. If received, the network shall interpret this as \"Initial request\"." },
4367         { 0, NULL }
4368 };
4369
4370 static guint16
4371 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_)
4372 {
4373         proto_tree_add_bits_item(tree, hf_gsm_a_spare_bits, tvb, (offset<<3) + 4, 1, FALSE);
4374         proto_tree_add_item(tree, hf_gsm_a_sm_req_type, tvb, offset, 1, FALSE);
4375
4376         /* no length check possible */
4377         return(1);
4378 }
4379
4380 guint16 (*gm_elem_fcn[])(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string, int string_len) = {
4381         /* GPRS Mobility Management Information Elements 10.5.5 */
4382         de_gmm_attach_res,      /* Attach Result */
4383         de_gmm_attach_type,     /* Attach Type */
4384         de_gmm_ciph_alg,        /* Cipher Algorithm */
4385         de_gmm_tmsi_stat,       /* TMSI Status */
4386         de_gmm_detach_type,     /* Detach Type */
4387         de_gmm_drx_param,       /* DRX Parameter */
4388         de_gmm_ftostby,         /* Force to Standby */
4389         de_gmm_ftostby_h,       /* Force to Standby - Info is in the high nibble */
4390         de_gmm_ptmsi_sig,       /* P-TMSI Signature */
4391         de_gmm_ptmsi_sig2,      /* P-TMSI Signature 2 */
4392         de_gmm_ident_type2,     /* Identity Type 2 */
4393         de_gmm_imeisv_req,      /* IMEISV Request */
4394         de_gmm_rec_npdu_lst,    /* Receive N-PDU Numbers List */
4395         de_gmm_ms_net_cap,      /* MS Network Capability */
4396         de_gmm_ms_radio_acc_cap,/* MS Radio Access Capability */
4397         de_gmm_cause,           /* GMM Cause */
4398         de_gmm_rai,             /* Routing Area Identification */
4399         de_gmm_update_res,      /* Update Result */
4400         de_gmm_update_type,     /* Update Type */
4401         de_gmm_ac_ref_nr,       /* A&C Reference Number */
4402         de_gmm_ac_ref_nr_h,     /* A&C Reference Numer - Info is in the high nibble */
4403         de_gmm_service_type,    /* Service Type */
4404         NULL /* no associated data */,  /* Cell Notification */
4405         de_gmm_ps_lcs_cap,      /* PS LCS Capability */
4406         de_gmm_net_feat_supp,   /* Network Feature Support */
4407         de_gmm_rat_info_container, /* Inter RAT information container */
4408         /* Session Management Information Elements 10.5.6 */
4409         de_sm_apn,              /* Access Point Name */
4410         de_sm_nsapi,            /* Network Service Access Point Identifier */
4411         de_sm_pco,              /* Protocol Configuration Options */
4412         de_sm_pdp_addr,         /* Packet Data Protocol Address */
4413         de_sm_qos,              /* Quality Of Service */
4414         de_sm_cause,            /* SM Cause */
4415         de_sm_cause_2,          /* SM Cause 2 */
4416         de_sm_linked_ti,        /* Linked TI */
4417         de_sm_sapi,             /* LLC Service Access Point Identifier */
4418         de_sm_tear_down,        /* Tear Down Indicator */
4419         de_sm_pflow_id,         /* Packet Flow Identifier */
4420         de_sm_tflow_temp,       /* Traffic Flow Template */
4421         de_sm_tmgi,             /* Temporary Mobile Group Identity (TMGI) */
4422         de_sm_mbms_bearer_cap,  /* MBMS bearer capabilities */
4423         de_sm_mbms_prot_conf_opt,       /* MBMS protocol configuration options */
4424         de_sm_enh_nsapi,        /* Enhanced network service access point identifier */
4425         de_sm_req_type,         /* Request type */
4426         /* GPRS Common Information Elements 10.5.7 */
4427         de_gc_context_stat,     /* PDP Context Status */
4428         de_gc_radio_prio,       /* Radio Priority */
4429         de_gc_timer,            /* GPRS Timer */
4430         de_gc_timer2,           /* GPRS Timer 2 */
4431         de_gc_radio_prio2,      /* Radio Priority 2 */
4432         de_gc_mbms_context_stat,/* 10.5.7.6 MBMS context status */
4433         NULL,   /* NONE */
4434 };
4435
4436 /* MESSAGE FUNCTIONS */
4437
4438 /*
4439  * [7] 9.4.1
4440  */
4441 static void
4442 dtap_gmm_attach_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
4443 {
4444         guint32 curr_offset;
4445         guint32 consumed;
4446         guint   curr_len;
4447
4448         curr_offset = offset;
4449         curr_len = len;
4450
4451         pinfo->p2p_dir = P2P_DIR_RECV;
4452
4453         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_MS_NET_CAP, NULL);
4454
4455         /* Included in attach type
4456
4457         ELEM_MAND_V(GSM_A_PDU_TYPE_COMMON, DE_CIPH_KEY_SEQ_NUM, NULL);
4458         curr_offset--;
4459         curr_len++;
4460         */
4461
4462         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_ATTACH_TYPE, NULL);
4463
4464         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_DRX_PARAM, NULL);
4465
4466         ELEM_MAND_LV(GSM_A_PDU_TYPE_COMMON, DE_MID , NULL);
4467
4468         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_RAI, " - Old routing area identification");
4469
4470         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_MS_RAD_ACC_CAP , NULL);
4471
4472         ELEM_OPT_TV( 0x19 , GSM_A_PDU_TYPE_GM, DE_P_TMSI_SIG, " - Old P-TMSI Signature");
4473
4474         ELEM_OPT_TV( 0x17 , GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER , " - Ready Timer" );
4475
4476         ELEM_OPT_TV_SHORT( 0x90 , GSM_A_PDU_TYPE_GM, DE_TMSI_STAT , NULL);
4477
4478         ELEM_OPT_TLV( 0x33 , GSM_A_PDU_TYPE_GM, DE_PS_LCS_CAP , NULL);
4479
4480         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
4481 }
4482
4483 /*
4484  * [7] 9.4.2
4485  */
4486 static void
4487 dtap_gmm_attach_acc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
4488 {
4489         guint32 curr_offset;
4490         guint32 consumed;
4491         guint   curr_len;
4492
4493         curr_offset = offset;
4494         curr_len = len;
4495
4496         pinfo->p2p_dir = P2P_DIR_SENT;
4497
4498         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_FORCE_TO_STAND_H, NULL);
4499         curr_len++;
4500         curr_offset--;
4501
4502         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_ATTACH_RES, NULL);
4503
4504         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER, NULL);
4505
4506         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_RAD_PRIO_2, " - Radio priority for TOM8");
4507         curr_len++;
4508         curr_offset--;
4509
4510         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_RAD_PRIO, " - Radio priority for SMS");
4511
4512         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_RAI, NULL);
4513
4514         ELEM_OPT_TV( 0x19 , GSM_A_PDU_TYPE_GM, DE_P_TMSI_SIG, NULL);
4515
4516         ELEM_OPT_TV( 0x17 , GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER , " - Negotiated Ready Timer" );
4517
4518         ELEM_OPT_TLV( 0x18 , GSM_A_PDU_TYPE_COMMON, DE_MID , " - Allocated P-TMSI" );
4519
4520         ELEM_OPT_TLV( 0x23 , GSM_A_PDU_TYPE_COMMON, DE_MID , NULL);
4521
4522         ELEM_OPT_TV( 0x25 , GSM_A_PDU_TYPE_GM, DE_GMM_CAUSE , NULL);
4523
4524         ELEM_OPT_TLV( 0x2A , GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER_2 , " - T3302" );
4525
4526         ELEM_OPT_T( 0x8C , GSM_A_PDU_TYPE_GM, DE_CELL_NOT , NULL);
4527
4528         ELEM_OPT_TLV( 0x4A , GSM_A_PDU_TYPE_COMMON, DE_PLMN_LIST , NULL);
4529
4530         ELEM_OPT_TV_SHORT( 0xB0 , GSM_A_PDU_TYPE_GM, DE_NET_FEAT_SUP , NULL);
4531
4532         ELEM_OPT_TLV( 0x34 , GSM_A_PDU_TYPE_DTAP, DE_EMERGENCY_NUM_LIST , NULL);
4533
4534         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
4535 }
4536
4537 /*
4538  * [7] 9.4.3
4539  */
4540 static void
4541 dtap_gmm_attach_com(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
4542 {
4543
4544         guint32 curr_offset;
4545 /*    guint32   consumed; */
4546         guint   curr_len;
4547
4548         curr_offset = offset;
4549         curr_len = len;
4550
4551         pinfo->p2p_dir = P2P_DIR_RECV;
4552
4553         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
4554 }
4555
4556 /*
4557  * [7] 9.4.4
4558  */
4559 static void
4560 dtap_gmm_attach_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
4561 {
4562         guint32 curr_offset;
4563         guint32 consumed;
4564         guint   curr_len;
4565
4566         curr_offset = offset;
4567         curr_len = len;
4568
4569         pinfo->p2p_dir = P2P_DIR_SENT;
4570
4571         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_GMM_CAUSE, NULL);
4572
4573         ELEM_OPT_TLV( 0x2A , GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER_2 , " - T3302" );
4574
4575         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
4576 }
4577
4578 /*
4579  * [7] 9.4.5
4580  */
4581 static void
4582 dtap_gmm_detach_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
4583 {
4584         guint32 curr_offset;
4585         guint32 consumed;
4586         guint   curr_len;
4587
4588         curr_offset = offset;
4589         curr_len = len;
4590
4591         pinfo->p2p_dir = P2P_DIR_SENT;
4592
4593         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_FORCE_TO_STAND_H, NULL);
4594         /* Force to standy might be wrong - To decode it correct, we need the direction */
4595         curr_len++;
4596         curr_offset--;
4597
4598         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_DETACH_TYPE, NULL);
4599
4600         ELEM_OPT_TV( 0x25 , GSM_A_PDU_TYPE_GM, DE_GMM_CAUSE , NULL);
4601
4602         ELEM_OPT_TLV( 0x18 , GSM_A_PDU_TYPE_COMMON, DE_MID , " - P-TMSI" );
4603
4604         ELEM_OPT_TLV( 0x19 , GSM_A_PDU_TYPE_GM, DE_P_TMSI_SIG , NULL);
4605
4606         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
4607 }
4608
4609 /*
4610  * [7] 9.4.6
4611  */
4612 static void
4613 dtap_gmm_detach_acc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
4614 {
4615         guint32 curr_offset;
4616         guint32 consumed;
4617         guint   curr_len;
4618
4619         curr_offset = offset;
4620         curr_len = len;
4621
4622         pinfo->p2p_dir = P2P_DIR_RECV;
4623
4624         if ( curr_len != 0 )
4625         {
4626                 ELEM_MAND_V(GSM_A_PDU_TYPE_COMMON, DE_SPARE_NIBBLE, NULL);
4627                 curr_len++;
4628                 curr_offset--;
4629
4630                 ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_FORCE_TO_STAND, NULL);
4631         }
4632
4633         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
4634 }
4635
4636 /*
4637  * [7] 9.4.7
4638  */
4639 static void
4640 dtap_gmm_ptmsi_realloc_cmd(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
4641 {
4642         guint32 curr_offset;
4643         guint32 consumed;
4644         guint   curr_len;
4645
4646         curr_offset = offset;
4647         curr_len = len;
4648
4649         pinfo->p2p_dir = P2P_DIR_SENT;
4650
4651         ELEM_MAND_LV(GSM_A_PDU_TYPE_COMMON, DE_MID , " - Allocated P-TMSI" );
4652
4653         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_RAI, NULL);
4654
4655         ELEM_MAND_V(GSM_A_PDU_TYPE_COMMON, DE_SPARE_NIBBLE, NULL);
4656         curr_len++;
4657         curr_offset--;
4658
4659         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_FORCE_TO_STAND, NULL);
4660
4661         ELEM_OPT_TV( 0x19 , GSM_A_PDU_TYPE_COMMON, DE_MID , " - P-TMSI Signature" );
4662
4663         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
4664 }
4665
4666 /*
4667  * [7] 9.4.8
4668  */
4669 static void
4670 dtap_gmm_ptmsi_realloc_com(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
4671 {
4672         guint32 curr_offset;
4673 /*    guint32   consumed; */
4674         guint   curr_len;
4675
4676         curr_offset = offset;
4677         curr_len = len;
4678
4679         pinfo->p2p_dir = P2P_DIR_RECV;
4680
4681         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
4682 }
4683
4684 /*
4685  * [7] 9.4.9
4686  */
4687 static void
4688 dtap_gmm_auth_ciph_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
4689 {
4690         guint32 curr_offset;
4691         guint32 consumed;
4692         guint   curr_len;
4693         guint8  oct;
4694
4695         curr_offset = offset;
4696         curr_len = len;
4697
4698         pinfo->p2p_dir = P2P_DIR_SENT;
4699
4700         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_IMEISV_REQ, NULL);
4701         curr_offset--;
4702         curr_len++;
4703
4704         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_CIPH_ALG, NULL);
4705
4706         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_AC_REF_NUM_H, NULL);
4707         curr_offset--;
4708         curr_len++;
4709
4710         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_FORCE_TO_STAND, NULL);
4711
4712         ELEM_OPT_TV( 0x21 , GSM_A_PDU_TYPE_DTAP, DE_AUTH_PARAM_RAND , NULL);
4713
4714 #if 0
4715         ELEM_OPT_TV_SHORT( 0x08 , GSM_A_PDU_TYPE_COMMON, DE_CIPH_KEY_SEQ_NUM , NULL);
4716 #else
4717         if ( curr_len > 0 )
4718         {
4719                 oct = tvb_get_guint8(tvb, curr_offset);
4720                 if (( oct & 0xf0 ) == 0x80 )
4721                 {
4722                         /* The ciphering key sequence number is added here */
4723                         proto_tree_add_text(tree,
4724                                 tvb, curr_offset, 1,
4725                                 "Ciphering key sequence number: 0x%02x (%u)",
4726                                 oct&7,
4727                                 oct&7);
4728                         curr_offset++;
4729                         curr_len--;
4730                 }
4731         }
4732 #endif
4733
4734         if ( curr_len == 0  )
4735         {
4736                 EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
4737         return;
4738         }
4739
4740         ELEM_OPT_TLV( 0x28 , GSM_A_PDU_TYPE_DTAP, DE_AUTH_PARAM_AUTN , NULL);
4741
4742         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
4743 }
4744
4745 /*
4746  * [7] 9.4.10
4747  */
4748 static void
4749 dtap_gmm_auth_ciph_resp(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
4750 {
4751         guint32 curr_offset;
4752         guint32 consumed;
4753         guint   curr_len;
4754
4755         curr_offset = offset;
4756         curr_len = len;
4757
4758         pinfo->p2p_dir = P2P_DIR_RECV;
4759
4760         ELEM_MAND_V(GSM_A_PDU_TYPE_COMMON, DE_SPARE_NIBBLE, NULL);
4761         curr_offset--;
4762         curr_len++;
4763
4764         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_AC_REF_NUM, NULL);
4765
4766         ELEM_OPT_TV( 0x22 , GSM_A_PDU_TYPE_DTAP, DE_AUTH_RESP_PARAM , NULL);
4767
4768         ELEM_OPT_TLV( 0x23 , GSM_A_PDU_TYPE_COMMON, DE_MID , " - IMEISV" );
4769
4770         ELEM_OPT_TLV( 0x29 , GSM_A_PDU_TYPE_DTAP, DE_AUTH_RESP_PARAM_EXT , NULL);
4771
4772         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
4773 }
4774
4775 /*
4776  * [7] 9.4.11
4777  */
4778 static void
4779 dtap_gmm_auth_ciph_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
4780 {
4781         guint32 curr_offset;
4782         guint   curr_len;
4783
4784         curr_offset = offset;
4785         curr_len = len;
4786
4787         pinfo->p2p_dir = P2P_DIR_SENT;
4788
4789         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
4790 }
4791
4792 /*
4793  * [7] 9.4.10a
4794  */
4795 static void
4796 dtap_gmm_auth_ciph_fail(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
4797 {
4798         guint32 curr_offset;
4799         guint32 consumed;
4800         guint   curr_len;
4801
4802         curr_offset = offset;
4803         curr_len = len;
4804
4805         pinfo->p2p_dir = P2P_DIR_RECV;
4806
4807         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_GMM_CAUSE, NULL);
4808
4809         ELEM_OPT_TLV( 0x30 , GSM_A_PDU_TYPE_DTAP, DE_AUTH_FAIL_PARAM , NULL);
4810
4811         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
4812 }
4813
4814 /*
4815  * [7] 9.4.12
4816  */
4817 static void
4818 dtap_gmm_ident_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
4819 {
4820         guint32 curr_offset;
4821         guint   curr_len;
4822
4823         curr_offset = offset;
4824         curr_len = len;
4825
4826         pinfo->p2p_dir = P2P_DIR_SENT;
4827
4828 /*  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. */
4829 #if 0
4830         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_ID_TYPE_2, NULL);
4831         curr_offset--;
4832         curr_len++;
4833         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_FORCE_TO_STAND_H, NULL);
4834 #endif
4835
4836         elem_v(tvb, tree, pinfo, GSM_A_PDU_TYPE_GM, DE_FORCE_TO_STAND_H, curr_offset, NULL);
4837         elem_v(tvb, tree, pinfo, GSM_A_PDU_TYPE_GM, DE_ID_TYPE_2, curr_offset, NULL);
4838
4839         curr_offset+=1;
4840         curr_len-=1;
4841
4842         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
4843 }
4844
4845 /*
4846  * [7] 9.4.13
4847  */
4848 static void
4849 dtap_gmm_ident_res(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
4850 {
4851         guint32 curr_offset;
4852         guint32 consumed;
4853         guint   curr_len;
4854
4855         curr_offset = offset;
4856         curr_len = len;
4857
4858         pinfo->p2p_dir = P2P_DIR_RECV;
4859
4860         ELEM_MAND_LV(GSM_A_PDU_TYPE_COMMON, DE_MID , NULL);
4861
4862         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
4863 }
4864
4865 /*
4866  * [7] 9.4.14
4867  */
4868 static void
4869 dtap_gmm_rau_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
4870 {
4871         guint32 curr_offset;
4872         guint32 consumed;
4873         guint   curr_len;
4874
4875         curr_offset = offset;
4876         curr_len = len;
4877
4878         pinfo->p2p_dir = P2P_DIR_RECV;
4879
4880         /* is included in update type
4881         ELEM_MAND_V(GSM_A_PDU_TYPE_COMMON, DE_CIPH_KEY_SEQ_NUM, NULL);
4882         curr_offset--;
4883         curr_len++;
4884         */
4885
4886         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_UPD_TYPE, NULL);
4887
4888         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_RAI, " - Old routing area identification");
4889
4890         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_MS_RAD_ACC_CAP , NULL);
4891
4892         ELEM_OPT_TV( 0x19 , GSM_A_PDU_TYPE_GM, DE_P_TMSI_SIG , " - Old P-TMSI Signature" );
4893
4894         ELEM_OPT_TV( 0x17 , GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER , " - Requested Ready Timer" );
4895
4896         ELEM_OPT_TV( 0x27 , GSM_A_PDU_TYPE_GM, DE_DRX_PARAM , NULL);
4897
4898         ELEM_OPT_TV_SHORT( 0x90 , GSM_A_PDU_TYPE_GM, DE_TMSI_STAT , NULL);
4899
4900         ELEM_OPT_TLV( 0x18 , GSM_A_PDU_TYPE_COMMON, DE_MID , " - P-TMSI" );
4901
4902         ELEM_OPT_TLV( 0x31 , GSM_A_PDU_TYPE_GM, DE_MS_NET_CAP , NULL);
4903
4904         ELEM_OPT_TLV( 0x32 , GSM_A_PDU_TYPE_GM, DE_PDP_CONTEXT_STAT , NULL);
4905
4906         ELEM_OPT_TLV( 0x33 , GSM_A_PDU_TYPE_GM, DE_PS_LCS_CAP , NULL);
4907
4908         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
4909 }
4910
4911 /*
4912  * [7] 9.4.15
4913  */
4914 static void
4915 dtap_gmm_rau_acc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
4916 {
4917         guint32 curr_offset;
4918         guint32 consumed;
4919         guint   curr_len;
4920
4921         curr_offset = offset;
4922         curr_len = len;
4923
4924         pinfo->p2p_dir = P2P_DIR_SENT;
4925
4926         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_UPD_RES, NULL);
4927         curr_offset--;
4928         curr_len++;
4929
4930         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_FORCE_TO_STAND, NULL);
4931
4932         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER, " - Periodic RA update timer");
4933
4934         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_RAI, NULL);
4935
4936         ELEM_OPT_TV( 0x19 , GSM_A_PDU_TYPE_GM, DE_P_TMSI_SIG , NULL);
4937
4938         ELEM_OPT_TLV( 0x18 , GSM_A_PDU_TYPE_COMMON, DE_MID , " - Allocated P-TMSI");
4939
4940         ELEM_OPT_TLV( 0x23 , GSM_A_PDU_TYPE_COMMON, DE_MID , NULL);
4941
4942         ELEM_OPT_TLV( 0x26 , GSM_A_PDU_TYPE_GM, DE_REC_N_PDU_NUM_LIST , NULL);
4943
4944         ELEM_OPT_TV( 0x17 , GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER , " - Negotiated Ready Timer" );
4945
4946         ELEM_OPT_TV( 0x25 , GSM_A_PDU_TYPE_GM, DE_GMM_CAUSE , NULL);
4947
4948         ELEM_OPT_TLV( 0x2A , GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER_2 , " - T3302" );
4949
4950         ELEM_OPT_T( 0x8C , GSM_A_PDU_TYPE_GM, DE_CELL_NOT , NULL);
4951
4952         ELEM_OPT_TLV( 0x4A , GSM_A_PDU_TYPE_COMMON, DE_PLMN_LIST , NULL);
4953
4954         ELEM_OPT_TLV( 0x32 , GSM_A_PDU_TYPE_GM, DE_PDP_CONTEXT_STAT , NULL);
4955
4956         ELEM_OPT_TV_SHORT ( 0xB0 , GSM_A_PDU_TYPE_GM, DE_NET_FEAT_SUP , NULL);
4957
4958         ELEM_OPT_TLV( 0x34 , GSM_A_PDU_TYPE_DTAP, DE_EMERGENCY_NUM_LIST , NULL);
4959
4960         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
4961 }
4962
4963 /*
4964  * [7] 9.4.16
4965  */
4966 static void
4967 dtap_gmm_rau_com(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
4968 {
4969         guint32 curr_offset;
4970         guint32 consumed;
4971         guint   curr_len;
4972
4973         curr_offset = offset;
4974         curr_len = len;
4975
4976         pinfo->p2p_dir = P2P_DIR_RECV;
4977         /* [7] 10.5.5.11 */
4978         ELEM_OPT_TLV( 0x26 , GSM_A_PDU_TYPE_GM, DE_REC_N_PDU_NUM_LIST , NULL);
4979         /* Inter RAT information container 10.5.5.24 TS 24.008 version 6.8.0 Release 6 */
4980         /*TO DO: Implement */
4981         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_RAT_INFO_CONTAINER , NULL);
4982
4983         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
4984 }
4985
4986 /*
4987  * [7] 9.4.17
4988  */
4989 static void
4990 dtap_gmm_rau_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
4991 {
4992         guint32 curr_offset;
4993         guint32 consumed;
4994         guint   curr_len;
4995
4996         curr_offset = offset;
4997         curr_len = len;
4998
4999         pinfo->p2p_dir = P2P_DIR_SENT;
5000
5001         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_GMM_CAUSE, NULL);
5002
5003         ELEM_MAND_V(GSM_A_PDU_TYPE_COMMON, DE_SPARE_NIBBLE, NULL);
5004         curr_offset--;
5005         curr_len++;
5006
5007         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_FORCE_TO_STAND, NULL);
5008
5009         ELEM_OPT_TLV( 0x26 , GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER_2 , " - T3302" );
5010
5011         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5012 }
5013
5014 /*
5015  * [7] 9.4.18
5016  */
5017 static void
5018 dtap_gmm_status(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5019 {
5020         guint32 curr_offset;
5021         guint32 consumed;
5022         guint   curr_len;
5023
5024         curr_offset = offset;
5025         curr_len = len;
5026
5027         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
5028
5029         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_GMM_CAUSE, NULL);
5030
5031         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5032 }
5033
5034 /*
5035  * [8] 9.4.19 GMM Information
5036  */
5037 static void
5038 dtap_gmm_information(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5039 {
5040         guint32 curr_offset;
5041         guint32 consumed;
5042         guint   curr_len;
5043
5044         curr_offset = offset;
5045         curr_len = len;
5046
5047         pinfo->p2p_dir = P2P_DIR_SENT;
5048
5049         ELEM_OPT_TLV( 0x43 , GSM_A_PDU_TYPE_DTAP, DE_NETWORK_NAME , " - Full Name" );
5050
5051         ELEM_OPT_TLV( 0x45 , GSM_A_PDU_TYPE_DTAP, DE_NETWORK_NAME , " - Short Name" );
5052
5053         ELEM_OPT_TV( 0x46 , GSM_A_PDU_TYPE_DTAP, DE_TIME_ZONE , NULL);
5054
5055         ELEM_OPT_TV( 0x47 , GSM_A_PDU_TYPE_DTAP, DE_TIME_ZONE_TIME , NULL);
5056
5057         ELEM_OPT_TLV( 0x48 , GSM_A_PDU_TYPE_DTAP, DE_LSA_ID , NULL);
5058
5059         ELEM_OPT_TLV( 0x49 , GSM_A_PDU_TYPE_DTAP, DE_DAY_SAVING_TIME , NULL);
5060
5061         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5062 }
5063
5064 /*
5065  * [7] 9.4.20
5066  */
5067 static void
5068 dtap_gmm_service_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5069 {
5070         guint32 curr_offset;
5071         guint32 consumed;
5072         guint   curr_len;
5073
5074         curr_offset = offset;
5075         curr_len = len;
5076
5077         pinfo->p2p_dir = P2P_DIR_RECV;
5078
5079         /* Is included in SRVC TYPE
5080         ELEM_MAND_V(GSM_A_PDU_TYPE_COMMON, DE_CIPH_KEY_SEQ_NUM, NULL);
5081         curr_offset--;
5082         curr_len++;
5083         */
5084
5085         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_SRVC_TYPE, NULL);
5086
5087         /* P-TMSI Mobile station identity 10.5.1.4 M LV 6 */
5088         ELEM_MAND_LV(GSM_A_PDU_TYPE_COMMON, DE_MID, NULL);
5089
5090         ELEM_OPT_TLV( 0x32 , GSM_A_PDU_TYPE_GM, DE_PDP_CONTEXT_STAT , NULL);
5091
5092         /* MBMS context status 10.5.7.6 TLV 2 - 18 */
5093         ELEM_OPT_TLV( 0x35 , GSM_A_PDU_TYPE_GM, DE_MBMS_CTX_STATUS , NULL);
5094
5095         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5096 }
5097
5098 /*
5099  * [7] 9.4.21
5100  */
5101 static void
5102 dtap_gmm_service_acc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5103 {
5104         guint32 curr_offset;
5105         guint32 consumed;
5106         guint   curr_len;
5107
5108         curr_offset = offset;
5109         curr_len = len;
5110
5111         pinfo->p2p_dir = P2P_DIR_SENT;
5112
5113         ELEM_OPT_TLV( 0x32 , GSM_A_PDU_TYPE_GM, DE_PDP_CONTEXT_STAT , NULL);
5114
5115         /* MBMS context status 10.5.7.6 TLV 2 - 18 */
5116         ELEM_OPT_TLV( 0x35 , GSM_A_PDU_TYPE_GM, DE_MBMS_CTX_STATUS , NULL);
5117
5118         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5119 }
5120
5121 /*
5122  * [7] 9.4.22
5123  */
5124 static void
5125 dtap_gmm_service_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5126 {
5127         guint32 curr_offset;
5128         guint32 consumed;
5129         guint   curr_len;
5130
5131         curr_offset = offset;
5132         curr_len = len;
5133
5134         pinfo->p2p_dir = P2P_DIR_SENT;
5135
5136         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_GMM_CAUSE, NULL);
5137
5138         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5139 }
5140
5141 /*
5142  * [8] 9.5.1 Activate PDP context request
5143  * Direction:                   MS to network
5144  */
5145 static void
5146 dtap_sm_act_pdp_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5147 {
5148         guint32 curr_offset;
5149         guint32 consumed;
5150         guint   curr_len;
5151
5152         curr_offset = offset;
5153         curr_len = len;
5154
5155         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
5156         /* MS to network */
5157         pinfo->link_dir = P2P_DIR_UL;
5158
5159         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_NET_SAPI, " - Requested NSAPI");
5160
5161         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_LLC_SAPI, " - Requested LLC SAPI");
5162
5163         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_QOS , " - Requested QoS" );
5164
5165         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_PD_PRO_ADDR , " - Requested PDP address" );
5166
5167         ELEM_OPT_TLV( 0x28 , GSM_A_PDU_TYPE_GM, DE_ACC_POINT_NAME , NULL);
5168
5169         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL);
5170
5171         ELEM_OPT_TV_SHORT(0xA0, GSM_A_PDU_TYPE_GM, DE_REQ_TYPE, NULL);
5172
5173         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5174 }
5175
5176 /*
5177  * [9] 9.5.2 Activate PDP context accept
5178  * Direction:                   network to MS
5179  */
5180 static void
5181 dtap_sm_act_pdp_acc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5182 {
5183         guint32 curr_offset;
5184         guint32 consumed;
5185         guint   curr_len;
5186
5187         curr_offset = offset;
5188         curr_len = len;
5189
5190         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
5191         /* Network to MS*/
5192         pinfo->link_dir = P2P_DIR_DL;
5193
5194         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_LLC_SAPI, " - Negotiated LLC SAPI");
5195
5196         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_QOS , " - Negotiated QoS" );
5197
5198 #if 0
5199         /* This is done automatically */
5200         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_SPARE, NULL);
5201         curr_offset--;
5202         curr_len++;
5203 #endif
5204
5205         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_RAD_PRIO, NULL);
5206
5207         ELEM_OPT_TLV( 0x2B , GSM_A_PDU_TYPE_GM, DE_PD_PRO_ADDR , NULL);
5208
5209         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL);
5210
5211         ELEM_OPT_TLV( 0x34 , GSM_A_PDU_TYPE_GM, DE_PACKET_FLOW_ID , NULL);
5212
5213         ELEM_OPT_TLV( 0x39 , GSM_A_PDU_TYPE_GM, DE_SM_CAUSE_2, NULL );
5214
5215         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5216 }
5217
5218 /*
5219  * [8] 9.5.3 Activate PDP context reject
5220  * Direction:                   network to MS
5221  */
5222 static void
5223 dtap_sm_act_pdp_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5224 {
5225         guint32 curr_offset;
5226         guint32 consumed;
5227         guint   curr_len;
5228
5229         curr_offset = offset;
5230         curr_len = len;
5231
5232         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
5233         /* Network to MS*/
5234         pinfo->link_dir = P2P_DIR_DL;
5235
5236         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_SM_CAUSE, NULL);
5237
5238         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL);
5239
5240         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5241 }
5242
5243 /*
5244  * [8] 9.5.4 Activate Secondary PDP Context Request
5245  * Direction:                   MS to network
5246  */
5247 static void
5248 dtap_sm_act_sec_pdp_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5249 {
5250         guint32 curr_offset;
5251         guint32 consumed;
5252         guint   curr_len;
5253
5254         curr_offset = offset;
5255         curr_len = len;
5256
5257         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
5258         /* MS to Network */
5259         pinfo->link_dir = P2P_DIR_UL;
5260
5261         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_NET_SAPI, " - Requested NSAPI");
5262
5263         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_LLC_SAPI, " - Requested LLC SAPI");
5264
5265         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_QOS , " - Requested QoS" );
5266
5267         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_LINKED_TI , NULL);
5268
5269         /* 3GPP TS 24.008 version 6.8.0 Release 6, 36 TFT Traffic Flow Template 10.5.6.12 O TLV 3-257 */
5270         ELEM_OPT_TLV( 0x36 , GSM_A_PDU_TYPE_GM, DE_TRAFFIC_FLOW_TEMPLATE , NULL);
5271
5272         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL);
5273
5274         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5275 }
5276
5277 /*
5278  * [7] 9.5.5    Activate Secondary PDP Context Accept
5279  * Direction:                   network to MS
5280  */
5281 static void
5282 dtap_sm_act_sec_pdp_acc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5283 {
5284         guint32 curr_offset;
5285         guint32 consumed;
5286         guint   curr_len;
5287
5288         curr_offset = offset;
5289         curr_len = len;
5290
5291         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
5292         /* Network to MS*/
5293         pinfo->link_dir = P2P_DIR_DL;
5294
5295         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_LLC_SAPI, " - Negotiated LLC SAPI");
5296
5297         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_QOS , " - Negotiated QoS" );
5298
5299         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_RAD_PRIO, NULL);
5300
5301 #if 0
5302         /* This is done automatically */
5303         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_SPARE, NULL);
5304         curr_offset--;
5305         curr_len++;
5306 #endif
5307
5308         ELEM_OPT_TLV( 0x34 , GSM_A_PDU_TYPE_GM, DE_PACKET_FLOW_ID , NULL);
5309
5310         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL);
5311
5312         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5313 }
5314
5315 /*
5316  * [8] 9.5.6 Activate Secondary PDP Context Reject
5317  * Direction:                   network to MS
5318  */
5319 static void
5320 dtap_sm_act_sec_pdp_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5321 {
5322         guint32 curr_offset;
5323         guint32 consumed;
5324         guint   curr_len;
5325
5326         curr_offset = offset;
5327         curr_len = len;
5328
5329         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
5330         /* Network to MS*/
5331         pinfo->link_dir = P2P_DIR_DL;
5332
5333         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_SM_CAUSE, NULL);
5334
5335         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL);
5336
5337         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5338 }
5339
5340 /*
5341  * [8] 9.5.7 Request PDP context activation
5342  * Direction:                   network to MS
5343  */
5344 static void
5345 dtap_sm_req_pdp_act(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5346 {
5347         guint32 curr_offset;
5348         guint32 consumed;
5349         guint   curr_len;
5350
5351         curr_offset = offset;
5352         curr_len = len;
5353
5354         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
5355         /* Network to MS*/
5356         pinfo->link_dir = P2P_DIR_DL;
5357
5358         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_PD_PRO_ADDR , " - Offered PDP address" );
5359
5360         ELEM_OPT_TLV( 0x28 , GSM_A_PDU_TYPE_GM, DE_ACC_POINT_NAME , NULL);
5361
5362         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL);
5363
5364         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5365 }
5366
5367 /*
5368  * [8] 9.5.8 Request PDP context activation reject
5369  * Direction:                   MS to network
5370  */
5371 static void
5372 dtap_sm_req_pdp_act_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5373 {
5374         guint32 curr_offset;
5375         guint32 consumed;
5376         guint   curr_len;
5377
5378         curr_offset = offset;
5379         curr_len = len;
5380
5381         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
5382         /* MS to  Network */
5383         pinfo->link_dir = P2P_DIR_UL;
5384
5385         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_SM_CAUSE, NULL);
5386
5387         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL);
5388
5389         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5390 }
5391
5392 /*
5393  * [8] 9.5.9 Modify PDP context request (Network to MS direction)
5394  * Direction:                   network to MS
5395  */
5396 static void
5397 dtap_sm_mod_pdp_req_net(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5398 {
5399         guint32 curr_offset;
5400         guint32 consumed;
5401         guint   curr_len;
5402
5403         curr_offset = offset;
5404         curr_len = len;
5405
5406         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
5407         /* Network to MS */
5408         pinfo->link_dir = P2P_DIR_DL;
5409
5410         ELEM_MAND_V(GSM_A_PDU_TYPE_GM,DE_RAD_PRIO, NULL);
5411 #if 0
5412         /* This is done automatically */
5413         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_SPARE, NULL);
5414         curr_offset--;
5415         curr_len++;
5416 #endif
5417
5418         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_LLC_SAPI, " - Requested LLC SAPI");
5419
5420         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_QOS , " - New QoS" );
5421
5422         ELEM_OPT_TLV( 0x2B , GSM_A_PDU_TYPE_GM, DE_PD_PRO_ADDR , NULL);
5423
5424         ELEM_OPT_TLV( 0x34 , GSM_A_PDU_TYPE_GM, DE_PACKET_FLOW_ID , NULL);
5425
5426         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL);
5427
5428         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5429 }
5430
5431 /*
5432  * [8] 9.5.10 Modify PDP context request (MS to network direction)
5433  * Direction:                   MS to network
5434  */
5435 static void
5436 dtap_sm_mod_pdp_req_ms(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5437 {
5438         guint32 curr_offset;
5439         guint32 consumed;
5440         guint   curr_len;
5441
5442         curr_offset = offset;
5443         curr_len = len;
5444
5445         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
5446         /* MS to Network */
5447         pinfo->link_dir = P2P_DIR_UL;
5448
5449         ELEM_OPT_TV( 0x32 , GSM_A_PDU_TYPE_GM, DE_LLC_SAPI , " - Requested LLC SAPI" );
5450
5451         ELEM_OPT_TLV( 0x30 , GSM_A_PDU_TYPE_GM, DE_QOS , " - Requested new QoS" );
5452
5453         ELEM_OPT_TLV( 0x31 , GSM_A_PDU_TYPE_GM, DE_TRAFFIC_FLOW_TEMPLATE , " - New TFT" );
5454
5455         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL);
5456
5457         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5458 }
5459
5460 /*
5461  * [8] 9.5.11 Modify PDP context accept (MS to network direction)
5462  * Direction:                   MS to network
5463  */
5464 static void
5465 dtap_sm_mod_pdp_acc_ms(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5466 {
5467         guint32 curr_offset;
5468         guint32 consumed;
5469         guint   curr_len;
5470
5471         curr_offset = offset;
5472         curr_len = len;
5473
5474         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
5475         /* MS to Network */
5476         pinfo->link_dir = P2P_DIR_UL;
5477
5478         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL);
5479
5480         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5481 }
5482
5483 /*
5484  * [8] 9.5.12 Modify PDP context accept (Network to MS direction)
5485  * Direction:                   Network to MS
5486  */
5487 static void
5488 dtap_sm_mod_pdp_acc_net(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5489 {
5490         guint32 curr_offset;
5491         guint32 consumed;
5492         guint   curr_len;
5493
5494         curr_offset = offset;
5495         curr_len = len;
5496
5497         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
5498         /* Network to MS */
5499         pinfo->link_dir = P2P_DIR_DL;
5500
5501         ELEM_OPT_TLV( 0x30 , GSM_A_PDU_TYPE_GM, DE_QOS , " - Negotiated QoS" );
5502
5503         ELEM_OPT_TV( 0x32 , GSM_A_PDU_TYPE_GM, DE_LLC_SAPI , " - Negotiated LLC SAPI" );
5504
5505         ELEM_OPT_TV_SHORT ( 0x80 , GSM_A_PDU_TYPE_GM , DE_RAD_PRIO , " - New radio priority" );
5506
5507         ELEM_OPT_TLV( 0x34 , GSM_A_PDU_TYPE_GM, DE_PACKET_FLOW_ID , NULL);
5508
5509         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL);
5510
5511         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5512 }
5513
5514 /*
5515  * [8] 9.5.13 Modify PDP Context Reject
5516  * Direction:                   both
5517  */
5518 static void
5519 dtap_sm_mod_pdp_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5520 {
5521         guint32 curr_offset;
5522         guint32 consumed;
5523         guint   curr_len;
5524
5525         curr_offset = offset;
5526         curr_len = len;
5527
5528         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
5529         /* Network or the MS */
5530         pinfo->link_dir = LINK_DIR_UNKNOWN;
5531
5532
5533         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_SM_CAUSE, NULL);
5534
5535         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL);
5536
5537         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5538 }
5539
5540 /*
5541  * [8] 9.5.14 Deactivate PDP context request
5542  * Direction:                   both
5543  */
5544 static void
5545 dtap_sm_deact_pdp_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5546 {
5547         guint32 curr_offset;
5548         guint32 consumed;
5549         guint   curr_len;
5550
5551         curr_offset = offset;
5552         curr_len = len;
5553
5554         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
5555         pinfo->link_dir = LINK_DIR_UNKNOWN;
5556
5557         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_SM_CAUSE, NULL);
5558
5559         ELEM_OPT_TV_SHORT( 0x90 , GSM_A_PDU_TYPE_GM , DE_TEAR_DOWN_IND , NULL);
5560
5561         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL);
5562
5563         /* MBMS context status 10.5.7.6 TLV 2 - 18 */
5564         ELEM_OPT_TLV( 0x35 , GSM_A_PDU_TYPE_GM, DE_MBMS_CTX_STATUS , NULL);
5565
5566         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5567 }
5568
5569 /*
5570  * [8] 9.5.15 Deactivate PDP context accept
5571  * Direction:                   both
5572  */
5573 static void
5574 dtap_sm_deact_pdp_acc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5575 {
5576         guint32 curr_offset;
5577         guint32 consumed;
5578         guint   curr_len;
5579
5580         curr_offset = offset;
5581         curr_len = len;
5582
5583         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
5584         pinfo->link_dir = LINK_DIR_UNKNOWN;
5585
5586         ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL);
5587
5588         /* MBMS context status 10.5.7.6 TLV 2 - 18 */
5589         ELEM_OPT_TLV( 0x35 , GSM_A_PDU_TYPE_GM, DE_MBMS_CTX_STATUS , NULL);
5590
5591         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5592 }
5593
5594 /*
5595  * [8] 9.5.21 SM Status
5596  * Direction:                   both
5597  */
5598 static void
5599 dtap_sm_status(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5600 {
5601         guint32 curr_offset;
5602         guint32 consumed;
5603         guint   curr_len;
5604
5605         curr_offset = offset;
5606         curr_len = len;
5607
5608         pinfo->p2p_dir = P2P_DIR_UNKNOWN;
5609         pinfo->link_dir = LINK_DIR_UNKNOWN;
5610
5611         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_SM_CAUSE, NULL);
5612
5613         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5614 }
5615
5616 /*
5617  * [9] 9.5.22 Activate MBMS Context Request
5618  * Direction:                   MS to network
5619  */
5620 static void
5621 dtap_sm_act_mbms_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5622 {
5623         guint32 curr_offset;
5624         guint32 consumed;
5625         guint   curr_len;
5626
5627         curr_offset = offset;
5628         curr_len = len;
5629
5630         pinfo->p2p_dir = P2P_DIR_RECV;
5631
5632         /* Requested MBMS NSAPI Enhanced Network service access point identifier 10.5.6.16 M V */
5633         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_ENH_NSAPI, " - Requested MBMS NSAPI");
5634
5635         /* Requested LLC SAPI LLC service access point identifier 10.5.6.9 M V 1 */
5636         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_LLC_SAPI, " - Requested LLC SAPI");
5637
5638         /* Supported MBMS bearer capabilities MBMS bearer capabilities 10.5.6.14 M LV 2 - 3 */
5639         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_MBMS_BEARER_CAP , NULL );
5640
5641         /* Requested multicast address Packet data protocol address 10.5.6.4 M LV 3 - 19 */
5642         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_PD_PRO_ADDR , " - Requested multicast address" );
5643
5644         /* Access point name Access point name 10.5.6.1 M LV 2 - 101 */
5645         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_ACC_POINT_NAME , NULL );
5646
5647         /* 35 MBMS protocol configuration options MBMS protocol configuration options 10.5.6.15 O TLV 3 - 253 */
5648         ELEM_OPT_TLV( 0x35 , GSM_A_PDU_TYPE_GM, DE_MBMS_PROT_CONF_OPT , NULL);
5649
5650         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5651 }
5652
5653 /*
5654  * [9] 9.5.23 Activate MBMS Context Accept
5655  * Direction:                   network to MS
5656  */
5657 static void
5658 dtap_sm_act_mbms_acc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5659 {
5660         guint32 curr_offset;
5661         guint32 consumed;
5662         guint   curr_len;
5663
5664         curr_offset = offset;
5665         curr_len = len;
5666
5667         pinfo->p2p_dir = P2P_DIR_SENT;
5668
5669         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_TMGI, NULL);
5670
5671         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_LLC_SAPI, " - Negotiated LLC SAPI");
5672
5673         ELEM_OPT_TLV( 0x35 , GSM_A_PDU_TYPE_GM, DE_MBMS_PROT_CONF_OPT , NULL);
5674
5675         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5676 }
5677
5678 /*
5679  * [9] 9.5.24 Activate MBMS Context Reject
5680  * Direction:                   network to MS
5681  */
5682 static void
5683 dtap_sm_act_mbms_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5684 {
5685         guint32 curr_offset;
5686         guint32 consumed;
5687         guint   curr_len;
5688
5689         curr_offset = offset;
5690         curr_len = len;
5691
5692         pinfo->p2p_dir = P2P_DIR_SENT;
5693
5694         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_SM_CAUSE, NULL);
5695
5696         ELEM_OPT_TLV( 0x35 , GSM_A_PDU_TYPE_GM, DE_MBMS_PROT_CONF_OPT , NULL);
5697
5698         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5699 }
5700
5701 /*
5702  * [9] 9.5.25 Request MBMS Context Activation
5703  * Direction:                   network to MS
5704  */
5705 static void
5706 dtap_sm_req_mbms_act(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5707 {
5708         guint32 curr_offset;
5709         guint32 consumed;
5710         guint   curr_len;
5711
5712         curr_offset = offset;
5713         curr_len = len;
5714
5715         pinfo->p2p_dir = P2P_DIR_SENT;
5716
5717         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_NET_SAPI, " - Linked NSAPI");
5718
5719         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_PD_PRO_ADDR , " - Offered multicast address" );
5720
5721         ELEM_MAND_LV(GSM_A_PDU_TYPE_GM, DE_ACC_POINT_NAME , NULL );
5722
5723         ELEM_OPT_TLV( 0x35 , GSM_A_PDU_TYPE_GM, DE_MBMS_PROT_CONF_OPT , NULL);
5724
5725         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5726 }
5727
5728 /*
5729  * [8] 9.5.26 Request MBMS Context Activation Reject
5730  * Direction:                   MS to network
5731  */
5732 static void
5733 dtap_sm_req_mbms_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
5734 {
5735         guint32 curr_offset;
5736         guint32 consumed;
5737         guint   curr_len;
5738
5739         curr_offset = offset;
5740         curr_len = len;
5741
5742         pinfo->p2p_dir = P2P_DIR_RECV;
5743
5744         ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_SM_CAUSE, NULL);
5745
5746         ELEM_OPT_TLV( 0x35 , GSM_A_PDU_TYPE_GM, DE_MBMS_PROT_CONF_OPT , NULL);
5747
5748         EXTRANEOUS_DATA_CHECK_EXPERT(curr_len, 0, pinfo);
5749 }
5750
5751 #define NUM_GSM_DTAP_MSG_GMM (sizeof(gsm_a_dtap_msg_gmm_strings)/sizeof(value_string))
5752 static gint ett_gsm_dtap_msg_gmm[NUM_GSM_DTAP_MSG_GMM];
5753 static void (*dtap_msg_gmm_fcn[])(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len) = {
5754         dtap_gmm_attach_req,            /* Attach Request */
5755         dtap_gmm_attach_acc,            /* Attach Accept */
5756         dtap_gmm_attach_com,            /* Attach Complete */
5757         dtap_gmm_attach_rej,            /* Attach Reject */
5758         dtap_gmm_detach_req,            /* Detach Request */
5759         dtap_gmm_detach_acc,            /* Detach Accept */
5760         dtap_gmm_rau_req,                       /* Routing Area Update Request */
5761         dtap_gmm_rau_acc,                       /* Routing Area Update Accept */
5762         dtap_gmm_rau_com,                       /* Routing Area Update Complete */
5763         dtap_gmm_rau_rej,                       /* Routing Area Update Reject */
5764         dtap_gmm_service_req,           /* Service Request */
5765         dtap_gmm_service_acc,           /* Service Accept */
5766         dtap_gmm_service_rej,           /* Service Reject */
5767         dtap_gmm_ptmsi_realloc_cmd,     /* P-TMSI Reallocation Command */
5768         dtap_gmm_ptmsi_realloc_com,     /* P-TMSI Reallocation Complete */
5769         dtap_gmm_auth_ciph_req,         /* Authentication and Ciphering Req */
5770         dtap_gmm_auth_ciph_resp,        /* Authentication and Ciphering Resp */
5771         dtap_gmm_auth_ciph_rej,         /* Authentication and Ciphering Rej */
5772         dtap_gmm_auth_ciph_fail,        /* Authentication and Ciphering Failure */
5773         dtap_gmm_ident_req,                     /* Identity Request */
5774         dtap_gmm_ident_res,                     /* Identity Response */
5775         dtap_gmm_status,                        /* GMM Status */
5776         dtap_gmm_information,           /* GMM Information */
5777         NULL,   /* NONE */
5778 };
5779
5780 #define NUM_GSM_DTAP_MSG_SM (sizeof(gsm_a_dtap_msg_sm_strings)/sizeof(value_string))
5781 static gint ett_gsm_dtap_msg_sm[NUM_GSM_DTAP_MSG_SM];
5782 static void (*dtap_msg_sm_fcn[])(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len) = {
5783         dtap_sm_act_pdp_req,            /* Activate PDP Context Request */
5784         dtap_sm_act_pdp_acc,            /* Activate PDP Context Accept */
5785         dtap_sm_act_pdp_rej,            /* Activate PDP Context Reject */
5786         dtap_sm_req_pdp_act,            /* Request PDP Context Activation */
5787         dtap_sm_req_pdp_act_rej,        /* Request PDP Context Activation rej. */
5788         dtap_sm_deact_pdp_req,          /* Deactivate PDP Context Request */
5789         dtap_sm_deact_pdp_acc,          /* Deactivate PDP Context Accept */
5790         dtap_sm_mod_pdp_req_net,        /* Modify PDP Context Request(Network to MS direction) */
5791         dtap_sm_mod_pdp_acc_ms,         /* Modify PDP Context Accept (MS to network direction) */
5792         dtap_sm_mod_pdp_req_ms,         /* Modify PDP Context Request(MS to network direction) */
5793         dtap_sm_mod_pdp_acc_net,        /* Modify PDP Context Accept (Network to MS direction) */
5794         dtap_sm_mod_pdp_rej,            /* Modify PDP Context Reject */
5795         dtap_sm_act_sec_pdp_req,        /* Activate Secondary PDP Context Request */
5796         dtap_sm_act_sec_pdp_acc,        /* Activate Secondary PDP Context Accept */
5797         dtap_sm_act_sec_pdp_rej,        /* Activate Secondary PDP Context Reject */
5798         NULL,                                           /* Reserved: was allocated in earlier phases of the protocol */
5799         NULL,                                           /* Reserved: was allocated in earlier phases of the protocol */
5800         NULL,                                           /* Reserved: was allocated in earlier phases of the protocol */
5801         NULL,                                           /* Reserved: was allocated in earlier phases of the protocol */
5802         NULL,                                           /* Reserved: was allocated in earlier phases of the protocol */
5803         dtap_sm_status,                         /* SM Status */
5804         dtap_sm_act_mbms_req,           /* Activate MBMS Context Request */
5805         dtap_sm_act_mbms_acc,           /* Activate MBMS Context Accept */
5806         dtap_sm_act_mbms_rej,           /* Activate MBMS Context Reject */
5807         dtap_sm_req_mbms_act,           /* Request MBMS Context Activation */
5808         dtap_sm_req_mbms_rej,           /* Request MBMS Context Activation Reject */
5809         NULL,   /* NONE */
5810 };
5811
5812 void get_gmm_msg_params(guint8 oct, const gchar **msg_str, int *ett_tree, int *hf_idx, msg_fcn *dtap_msg_fcn)
5813 {
5814         gint                    idx;
5815
5816         *msg_str = match_strval_idx((guint32) (oct & DTAP_GMM_IEI_MASK), gsm_a_dtap_msg_gmm_strings, &idx);
5817         *ett_tree = ett_gsm_dtap_msg_gmm[idx];
5818         *hf_idx = hf_gsm_a_dtap_msg_gmm_type;
5819         *dtap_msg_fcn = dtap_msg_gmm_fcn[idx];
5820
5821         return;
5822 }
5823
5824 void get_sm_msg_params(guint8 oct, const gchar **msg_str, int *ett_tree, int *hf_idx, msg_fcn *dtap_msg_fcn)
5825 {
5826         gint                    idx;
5827
5828         *msg_str = match_strval_idx((guint32) (oct & DTAP_SM_IEI_MASK), gsm_a_dtap_msg_sm_strings, &idx);
5829         *ett_tree = ett_gsm_dtap_msg_sm[idx];
5830         *hf_idx = hf_gsm_a_dtap_msg_sm_type;
5831         *dtap_msg_fcn = dtap_msg_sm_fcn[idx];
5832
5833         return;
5834 }
5835
5836 /* Register the protocol with Wireshark */
5837 void
5838 proto_register_gsm_a_gm(void)
5839 {
5840         guint           i;
5841         guint           last_offset;
5842
5843         /* Setup list of header fields */
5844
5845         static hf_register_info hf[] =
5846         {
5847         { &hf_gsm_a_dtap_msg_gmm_type,
5848                 { "DTAP GPRS Mobility Management Message Type", "gsm_a.dtap_msg_gmm_type",
5849                   FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_msg_gmm_strings), 0x0,
5850                   NULL, HFILL }
5851         },
5852         { &hf_gsm_a_dtap_msg_sm_type,
5853                 { "DTAP GPRS Session Management Message Type",  "gsm_a.dtap_msg_sm_type",
5854                   FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_msg_sm_strings), 0x0,
5855                   NULL, HFILL }
5856         },
5857         { &hf_gsm_a_gm_elem_id,
5858                 { "Element ID", "gsm_a_gm.elem_id",
5859                 FT_UINT8, BASE_DEC, NULL, 0,
5860                 NULL, HFILL }
5861         },
5862         { &hf_gsm_a_qos_delay_cls,
5863                 { "Quality of Service Delay class", "gsm_a.qos.delay_cls",
5864                   FT_UINT8, BASE_DEC, VALS(gsm_a_qos_delay_cls_vals), 0x38,
5865                   NULL, HFILL }
5866         },
5867         { &hf_gsm_a_qos_reliability_cls,
5868                 { "Reliability class", "gsm_a.qos.delay_cls",
5869                   FT_UINT8, BASE_DEC, VALS(gsm_a_qos_delay_cls_vals), 0x07,
5870                   NULL, HFILL }
5871         },
5872         { &hf_gsm_a_qos_traffic_cls,
5873                 { "Traffic class", "gsm_a.qos.traffic_cls",
5874                   FT_UINT8, BASE_DEC, VALS(gsm_a_qos_traffic_cls_vals), 0xe0,
5875                   NULL, HFILL }
5876         },
5877         { &hf_gsm_a_qos_del_order,
5878                 { "Delivery order", "gsm_a.qos.del_order",
5879                   FT_UINT8, BASE_DEC, VALS(gsm_a_qos_traffic_cls_vals), 0x18,
5880                   NULL, HFILL }
5881         },
5882         { &hf_gsm_a_qos_del_of_err_sdu,
5883                 { "Delivery of erroneous SDUs", "gsm_a.qos.del_of_err_sdu",
5884                   FT_UINT8, BASE_DEC, VALS(gsm_a_qos_del_of_err_sdu_vals), 0x03,
5885                   NULL, HFILL }
5886         },
5887         { &hf_gsm_a_qos_ber,
5888                 { "Residual Bit Error Rate (BER)", "gsm_a.qos.ber",
5889                   FT_UINT8, BASE_DEC, VALS(gsm_a_qos_ber_vals), 0xf0,
5890                   NULL, HFILL }
5891         },
5892         { &hf_gsm_a_qos_sdu_err_rat,
5893                 { "SDU error ratio", "gsm_a.qos.sdu_err_rat",
5894                   FT_UINT8, BASE_DEC, VALS(gsm_a_qos_sdu_err_rat_vals), 0x0f,
5895                   NULL, HFILL }
5896         },
5897         { &hf_gsm_a_qos_traff_hdl_pri,
5898                 { "Traffic handling priority", "gsm_a.qos.traff_hdl_pri",
5899                   FT_UINT8, BASE_DEC, VALS(gsm_a_qos_traff_hdl_pri_vals), 0x03,
5900                   NULL, HFILL }
5901         },
5902         { &hf_gsm_a_gmm_split_on_ccch,
5903                 { "SPLIT on CCCH","gsm_a.gmm.split_on_ccch",
5904                   FT_BOOLEAN, 8, TFS(&gsm_a_gmm_split_on_ccch_value), 0x08,
5905                   NULL, HFILL }
5906         },
5907         { &hf_gsm_a_gmm_non_drx_timer,
5908                 { "Non-DRX timer","gsm_a.gmm.non_drx_timer",
5909                   FT_UINT8, BASE_DEC, VALS(gsm_a_gmm_non_drx_timer_strings), 0x07,
5910                   NULL, HFILL }
5911         },
5912         { &hf_gsm_a_gmm_cn_spec_drs_cycle_len_coef,
5913                 { "CN Specific DRX cycle length coefficient","gsm_a.gmm.cn_spec_drs_cycle_len_coef",
5914                   FT_UINT8, BASE_DEC|BASE_RANGE_STRING, RVALS(gsm_a_gmm_cn_spec_drs_cycle_len_coef_strings), 0xf0,
5915                   NULL, HFILL }
5916         },
5917         { &hf_gsm_a_tft_op_code,
5918                 { "TFT operation code", "gsm_a.tft.op_code",
5919                   FT_UINT8, BASE_DEC, VALS(gsm_a_tft_op_code_vals), 0xe0,
5920                   NULL, HFILL }
5921         },
5922         { &hf_gsm_a_tft_e_bit,
5923                 { "E bit","gsm_a.tft.e_bit",
5924                   FT_BOOLEAN, 8, TFS(&gsm_a_tft_e_bit), 0x10,
5925                   NULL, HFILL }
5926         },
5927         { &hf_gsm_a_tft_pkt_flt,
5928                 { "Number of packet filters", "gsm_a.tft.pkt_flt",
5929                   FT_UINT8, BASE_DEC, NULL, 0x0f,
5930                   NULL, HFILL }
5931         },
5932         { &hf_gsm_a_tft_pkt_flt_dir,
5933                 { "Packet filter direction", "gsm_a.tft.pkt_flt_dir",
5934                   FT_UINT8, BASE_DEC, VALS(gsm_a_tft_pkt_flt_dir_vals), 0x30,
5935                   NULL, HFILL }
5936         },
5937         { &hf_gsm_a_tft_pkt_flt_id,
5938                 { "Packet filter identifier", "gsm_a.tft.pkt_flt_id",
5939                   FT_UINT8, BASE_DEC, NULL, 0x0f,
5940                   NULL, HFILL }
5941         },
5942         { &hf_gsm_a_sm_ip4_address,
5943                 { "IPv4 address", "gsm_a.sm.ip4_address",
5944                   FT_IPv4, BASE_NONE, NULL, 0x0,
5945                 NULL, HFILL }
5946         },
5947         { &hf_gsm_a_sm_ip4_mask,
5948                 { "IPv4 address mask", "gsm_a.sm.ip4_mask",
5949                   FT_IPv4, BASE_NONE, NULL, 0x0,
5950                 NULL, HFILL }
5951         },
5952         { &hf_gsm_a_sm_ip6_address,
5953                 { "IPv6 address", "gsm_a.sm.ip6_address",
5954                   FT_IPv6, BASE_NONE, NULL, 0x0,
5955                 NULL, HFILL }
5956         },
5957         { &hf_gsm_a_sm_ip6_mask,
5958                 { "IPv6 address mask", "gsm_a.sm.ip6_mask",
5959                   FT_IPv6, BASE_NONE, NULL, 0x0,
5960                 NULL, HFILL }
5961         },
5962         { &hf_gsm_a_tft_protocol_header,
5963                 { "Protocol/header", "gsm_a.tft.protocol_header",
5964                   FT_UINT8, BASE_HEX, NULL, 0x0,
5965                 NULL, HFILL }
5966         },
5967         { &hf_gsm_a_tft_port,
5968                 { "Port", "gsm_a.tft.port",
5969                   FT_UINT16, BASE_DEC, NULL, 0x0,
5970                 NULL, HFILL }
5971         },
5972         { &hf_gsm_a_tft_port_low,
5973                 { "Low limit port", "gsm_a.tft.port_low",
5974                   FT_UINT16, BASE_DEC, NULL, 0x0,
5975                 NULL, HFILL }
5976         },
5977         { &hf_gsm_a_tft_port_high,
5978                 { "High limit port", "gsm_a.tft.port_high",
5979                   FT_UINT16, BASE_DEC, NULL, 0x0,
5980                 NULL, HFILL }
5981         },
5982         { &hf_gsm_a_tft_security,
5983                 { "IPSec security parameter index", "gsm_a.tft.security",
5984                   FT_UINT32, BASE_HEX, NULL, 0x0,
5985                 NULL, HFILL }
5986         },
5987         { &hf_gsm_a_tft_traffic_mask,
5988                 { "Mask field", "gsm_a.tft.traffic_mask",
5989                   FT_UINT8, BASE_HEX, NULL, 0x0,
5990                 NULL, HFILL }
5991         },
5992         { &hf_gsm_a_tft_flow_label_type,
5993                 { "Flow Label Type", "gsm_a.tft.flow_label_type",
5994                   FT_UINT24, BASE_HEX, NULL, 0x0FFFFF,
5995                 NULL, HFILL }
5996         },
5997         { &hf_gsm_a_tft_param_id,
5998                 { "Parameter identifier", "gsm_a.tft.param_id",
5999                   FT_UINT8, BASE_DEC, VALS(gsm_a_tft_param_id_vals), 0x0,
6000                   NULL, HFILL }
6001         },
6002         { &hf_gsm_a_ptmsi_sig,
6003                 { "P-TMSI Signature", "gsm_a.ptmsi_sig",
6004                   FT_UINT24, BASE_HEX, NULL, 0x0,
6005                 NULL, HFILL }
6006         },
6007         { &hf_gsm_a_ptmsi_sig2,
6008                 { "P-TMSI Signature 2", "gsm_a.ptmsi_sig2",
6009                   FT_UINT24, BASE_HEX, NULL, 0x0,
6010                 NULL, HFILL }
6011         },
6012         { &hf_gsm_a_gm_acc_tech_type,
6013                 { "Access Technology Type", "gsm_a.gm.acc_tech_type",
6014                   FT_UINT8, BASE_DEC, VALS(gsm_a_gm_acc_tech_type_vals), 0x0,
6015                 NULL, HFILL }
6016         },
6017         { &hf_gsm_a_gm_acc_cap_struct_len,
6018                 { "Length in bits", "gsm_a.gm.acc_cap_struct_len",
6019                   FT_UINT8, BASE_HEX_DEC,NULL, 0x0,
6020                 NULL, HFILL }
6021         },
6022         { &hf_gsm_a_gm_sms_value,
6023                 { "SMS_VALUE (Switch-Measure-Switch)", "gsm_a.gm.sms",
6024                   FT_UINT8, BASE_DEC, VALS(gsm_a_sms_vals), 0x0,
6025                 NULL, HFILL }
6026         },
6027         { &hf_gsm_a_gm_sm_value,
6028                 { "(SM_VALUE) Switch-Measure", "gsm_a.gm.sm",
6029                   FT_UINT8, BASE_DEC, VALS(gsm_a_sms_vals), 0x0,
6030                 NULL, HFILL }
6031         },
6032         { &hf_gsm_a_gm_sm_ext,
6033                 { "Ext", "gsm_a.gm.sm.ext",
6034                   FT_UINT8, BASE_HEX, NULL, 0x80,
6035                 NULL, HFILL }
6036         },
6037         { &hf_gsm_a_gm_link_dir,
6038                 { "Link direction", "gsm_a.gm.link_dir",
6039                   FT_INT32, BASE_DEC, VALS(gsm_a_gm_link_dir_vals), 0x0,
6040                 NULL, HFILL }
6041         },
6042         { &hf_gsm_a_gm_cause,
6043                 { "gmm Cause", "gsm_a.gm.cause",
6044                   FT_UINT8, BASE_DEC|BASE_RANGE_STRING, RVALS(gmm_cause_vals), 0x0,
6045                 NULL, HFILL }
6046         },
6047         { &hf_gsm_a_gm_fop,
6048                 { "Follow-on proceed", "gsm_a.gm.fop",
6049                 FT_BOOLEAN, 8, NULL, 0x08,
6050                 NULL, HFILL }
6051         },
6052         { &hf_gsm_a_gm_res_of_attach,
6053                 { "Result of attach", "gsm_a.gm.res_of_attach",
6054                 FT_UINT8, BASE_DEC, VALS(gsm_a_gm_res_of_attach_vals), 0x07,
6055                 NULL, HFILL }
6056         },
6057         { &hf_gsm_a_gm_type_of_ciph_alg,
6058                 { "Type of ciphering algorithm", "gsm_a.gm.type_of_ciph_alg",
6059                 FT_UINT8, BASE_DEC, VALS(gsm_a_gm_type_of_ciph_alg_vals), 0x07,
6060                 NULL, HFILL }
6061         },
6062         { &hf_gsm_a_gm_imeisv_req,
6063                 { "IMEISV request", "gsm_a.gm.imeisv_req",
6064                 FT_UINT8, BASE_DEC|BASE_RANGE_STRING, RVALS(gsm_a_gm_imeisv_req_vals), 0x00,
6065                 NULL, HFILL }
6066         },
6067         { &hf_gsm_a_gm_ac_ref_nr,
6068                 { "A&C reference number", "gsm_a.gm.ac_ref_nr",
6069                   FT_UINT8, BASE_DEC, NULL, 0x0,
6070                 NULL, HFILL }
6071         },
6072         { &hf_gsm_a_gm_force_to_standby,
6073                 { "Force to standby", "gsm_a.gm.force_to_standby",
6074                 FT_UINT8, BASE_DEC|BASE_RANGE_STRING, RVALS(gsm_a_gm_force_to_standby_vals), 0x00,
6075                 NULL, HFILL }
6076         },
6077         { &hf_gsm_a_gm_ciph_key_seq_num,
6078                 { "Ciphering key sequence number", "gsm_a.gm.ciph_key_seq_num",
6079                 FT_UINT8, BASE_DEC, NULL, 0x00,
6080                 NULL, HFILL }
6081         },
6082         { &hf_gsm_a_gm_serv_type,
6083                 { "Service type", "gsm_a.gm.serv_type",
6084                 FT_UINT8, BASE_DEC, VALS(gsm_a_gm_serv_type_vals), 0x00,
6085                 NULL, HFILL }
6086         },
6087         { &hf_gsm_a_gm_for,
6088                 { "Follow-on request pending", "gsm_a.gm.for",
6089                 FT_BOOLEAN, 8, NULL, 0x08,
6090                 NULL, HFILL }
6091         },
6092         { &hf_gsm_a_gm_type_of_attach,
6093                 { "Type of attach", "gsm_a.gm.type_of_attach",
6094                 FT_UINT8, BASE_DEC, VALS(gsm_a_gm_type_of_attach_vals), 0x07,
6095                 NULL, HFILL }
6096         },
6097         { &hf_gsm_a_gm_tmsi_flag,
6098                 { "TMSI flag", "gsm_a.gm.tmsi_flag",
6099                 FT_BOOLEAN, 8, TFS(&gsm_a_gm_tmsi_flag_value), 0x01,
6100                 NULL, HFILL }
6101         },
6102         { &hf_gsm_a_gm_update_type,
6103                 { "Update type", "gsm_a.gm.update_type",
6104                 FT_UINT8, BASE_DEC, VALS(gsm_a_gm_update_type_vals), 0x07,
6105                 NULL, HFILL }
6106         },
6107         { &hf_gsm_a_gm_gprs_timer_unit,
6108                 { "Unit", "gsm_a.gm.gprs_timer_unit",
6109                 FT_UINT8, BASE_DEC, VALS(gsm_a_gm_gprs_timer_unit_vals), 0xe0,
6110                 NULL, HFILL }
6111         },
6112         { &hf_gsm_a_gm_gprs_timer_value,
6113                 { "Timer value", "gsm_a.gm.gprs_timer_value",
6114                 FT_UINT8, BASE_DEC, NULL, 0x1f,
6115                 NULL, HFILL }
6116         },
6117         { &hf_gsm_a_gm_pco_pid,
6118                 { "Protocol or Container ID", "gsm_a.gm.pco_pid",
6119                 FT_UINT16, BASE_DEC, NULL, 0x0,
6120                 NULL, HFILL }
6121         },
6122         { &hf_gsm_a_gm_type_of_identity,
6123                 { "Type of identity", "gsm_a.gm.type_of_identity",
6124                 FT_UINT8, BASE_DEC, VALS(gsm_a_gm_type_of_identity_vals), 0x07,
6125                 NULL, HFILL }
6126         },
6127         { &hf_gsm_a_gm_rac,
6128                 { "Routing Area Code (RAC)","gsm_a.gm.rac",
6129                 FT_UINT8, BASE_HEX_DEC, NULL, 0x00,
6130                 NULL, HFILL }
6131         },
6132         { &hf_gsm_a_gm_apc,
6133                 { "APC","gsm_a.gm.apc",
6134                 FT_BOOLEAN, 8, TFS(&gsm_a_gm_apc_vals), 0x20,
6135                 NULL, HFILL }
6136         },
6137         { &hf_gsm_a_gm_otd_a,
6138                 { "OTD-A","gsm_a.gm.otd_a",
6139                 FT_BOOLEAN, 8, TFS(&gsm_a_gm_otd_a_vals), 0x10,
6140                 NULL, HFILL }
6141         },
6142         { &hf_gsm_a_gm_otd_b,
6143                 { "OTD-B","gsm_a.gm.otd_b",
6144                 FT_BOOLEAN, 8, TFS(&gsm_a_gm_otd_b_vals), 0x08,
6145                 NULL, HFILL }
6146         },
6147         { &hf_gsm_a_gm_gps_a,
6148                 { "GPS-A","gsm_a.gm.gps_a",
6149                 FT_BOOLEAN, 8, TFS(&gsm_a_gm_gps_a_vals), 0x04,
6150                 NULL, HFILL }
6151         },
6152         { &hf_gsm_a_gm_gps_b,
6153                 { "GPS-B","gsm_a.gm.gps_b",
6154                 FT_BOOLEAN, 8, TFS(&gsm_a_gm_gps_b_vals), 0x02,
6155                 NULL, HFILL }
6156         },
6157         { &hf_gsm_a_gm_gps_c,
6158                 { "GPS-C","gsm_a.gm.gps_c",
6159                 FT_BOOLEAN, 8, TFS(&gsm_a_gm_gps_c_vals), 0x01,
6160                 NULL, HFILL }
6161         },
6162         { &hf_gsm_a_sm_pdp_type_org,
6163                 { "PDP type organization", "gsm_a.sm.pdp_type_org",
6164                 FT_UINT8, BASE_DEC, VALS(gsm_a_sm_pdp_type_org_vals), 0x0f,
6165                 NULL, HFILL }
6166         },
6167         { &hf_gsm_a_qos_mean_thr,
6168                 { "Mean throughput", "gsm_a.qos.mean_throughput",
6169                 FT_UINT8, BASE_DEC|BASE_RANGE_STRING, RVALS(gsm_a_qos_mean_thr_vals), 0x1f,
6170                 NULL, HFILL }
6171         },
6172         { &hf_gsm_a_qos_peak_thr,
6173                 { "Peak throughput", "gsm_a.qos.peak_throughput",
6174                 FT_UINT8, BASE_DEC|BASE_RANGE_STRING, RVALS(gsm_a_qos_peak_thr_vals), 0xf0,
6175                 NULL, HFILL }
6176         },
6177         { &hf_gsm_a_qos_prec_class,
6178                 { "Precedence class", "gsm_a.qos.prec_class",
6179                 FT_UINT8, BASE_DEC|BASE_RANGE_STRING, RVALS(gsm_a_qos_prec_class_vals), 0x07,
6180                 NULL, HFILL }
6181         },
6182         { &hf_gsm_a_qos_traf_handl_prio,
6183                 { "Traffic handling priority", "gsm_a.qos.traf_handl_prio",
6184                 FT_UINT8, BASE_DEC, NULL, 0x03,
6185                 NULL, HFILL }
6186         },
6187         { &hf_gsm_a_qos_trans_delay,
6188                 { "Transfer delay", "gsm_a.qos.trans_delay",
6189                 FT_UINT8, BASE_DEC, NULL, 0xfc,
6190                 NULL, HFILL }
6191         },
6192         { &hf_gsm_a_qos_signalling_ind,
6193                 { "Signalling indication", "gsm_a.qos.signalling_ind",
6194                 FT_BOOLEAN, 8, TFS(&gsm_a_qos_signalling_ind_value), 0x10,
6195                 NULL, HFILL }
6196         },
6197         { &hf_gsm_a_qos_source_stat_desc,
6198                 { "Source statistics description", "gsm_a.qos.source_stat_desc",
6199                 FT_UINT8, BASE_DEC, NULL, 0x0f,
6200                 NULL, HFILL }
6201         },
6202         { &hf_gsm_a_qos_max_bitrate_upl,
6203                 { "Maximum bitrate for uplink", "gsm_a.qos.max_bitrate_upl",
6204                   FT_UINT8, BASE_DEC, NULL, 0x0,
6205                 NULL, HFILL }
6206         },
6207         { &hf_gsm_a_qos_max_bitrate_downl,
6208                 { "Maximum bitrate for downlink", "gsm_a.qos.max_bitrate_downl",
6209                   FT_UINT8, BASE_DEC, NULL, 0x0,
6210                 NULL, HFILL }
6211         },
6212         { &hf_gsm_a_qos_guar_bitrate_upl,
6213                 { "Guaranteed bitrate for uplink", "gsm_a.qos.guar_bitrate_upl",
6214                   FT_UINT8, BASE_DEC, NULL, 0x0,
6215                 NULL, HFILL }
6216         },
6217         { &hf_gsm_a_qos_guar_bitrate_downl,
6218                 { "Guaranteed bitrate for downlink", "gsm_a.qos.guar_bitrate_downl",
6219                   FT_UINT8, BASE_DEC, NULL, 0x0,
6220                 NULL, HFILL }
6221         },
6222         { &hf_gsm_a_qos_max_bitrate_upl_ext,
6223                 { "Maximum bitrate for uplink (extended)", "gsm_a.qos.max_bitrate_upl_ext",
6224                   FT_UINT8, BASE_DEC, NULL, 0x0,
6225                 NULL, HFILL }
6226         },
6227         { &hf_gsm_a_qos_max_bitrate_downl_ext,
6228                 { "Maximum bitrate for downlink (extended)", "gsm_a.qos.max_bitrate_downl_ext",
6229                   FT_UINT8, BASE_DEC, NULL, 0x0,
6230                 NULL, HFILL }
6231         },
6232         { &hf_gsm_a_qos_guar_bitrate_upl_ext,
6233                 { "Guaranteed bitrate for uplink (extended)", "gsm_a.qos.guar_bitrate_upl_ext",
6234                   FT_UINT8, BASE_DEC, NULL, 0x0,
6235                 NULL, HFILL }
6236         },
6237         { &hf_gsm_a_qos_guar_bitrate_downl_ext,
6238                 { "Guaranteed bitrate for downlink (extended)", "gsm_a.qos.guar_bitrate_downl_ext",
6239                   FT_UINT8, BASE_DEC, NULL, 0x0,
6240                 NULL, HFILL }
6241         },
6242         { &hf_gsm_a_sm_cause,
6243                 { "SM Cause", "gsm_a.sm.cause",
6244                   FT_UINT8, BASE_DEC, NULL, 0x0,
6245                 NULL, HFILL }
6246         },
6247         { &hf_gsm_a_sm_cause_2,
6248                 { "SM Cause 2", "gsm_a.sm.cause_2",
6249                   FT_UINT8, BASE_DEC, NULL, 0x0,
6250                 NULL, HFILL }
6251         },
6252         { &hf_gsm_a_sm_llc_sapi,
6253                 { "LLC SAPI", "gsm_a.sm.llc_sapi",
6254                 FT_UINT8, BASE_DEC, VALS(gsm_a_sm_llc_sapi_vals), 0x0f,
6255                 NULL, HFILL }
6256         },
6257         { &hf_gsm_a_sm_tdi,
6258                 { "Tear Down Indicator (TDI)", "gsm_a.sm.tdi",
6259                 FT_BOOLEAN, 8, TFS(&gsm_a_sm_tdi_value), 0x01,
6260                 NULL, HFILL }
6261         },
6262         { &hf_gsm_a_sm_packet_flow_id,
6263                 { "Packet Flow Identifier (PFI)", "gsm_a.sm.packet_flow_id",
6264                 FT_UINT8, BASE_DEC|BASE_RANGE_STRING, RVALS(gsm_a_sm_packet_flow_id_vals), 0x7f,
6265                 NULL, HFILL }
6266         },
6267         { &hf_gsm_a_gmm_net_cap_gea1,
6268                 { "GEA/1", "gsm_a.gmm.net_cap.gea1",
6269                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_gea_vals), 0x80,
6270                 NULL, HFILL }
6271         },
6272         { &hf_gsm_a_gmm_net_cap_smdch,
6273                 { "SM capabilities via dedicated channels", "gsm_a.gmm.net_cap.smdch",
6274                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_smdch_vals), 0x40,
6275                 NULL, HFILL }
6276         },
6277         { &hf_gsm_a_gmm_net_cap_smgprs,
6278                 { "SM capabilities via GPRS channels", "gsm_a.gmm.net_cap.smgprs",
6279                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_smgprs_vals), 0x20,
6280                 NULL, HFILL }
6281         },
6282         { &hf_gsm_a_gmm_net_cap_ucs2,
6283                 { "UCS2 support", "gsm_a.gmm.net_cap.ucs2",
6284                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_smgprs_vals), 0x10,
6285                 NULL, HFILL }
6286         },
6287         { &hf_gsm_a_gmm_net_cap_ss_scr_ind,
6288                 { "SS Screening Indicator", "gsm_a.gmm.net_cap.ss_scr_ind",
6289                 FT_UINT8, BASE_HEX, VALS(gsm_a_gmm_net_cap_ss_scr_ind_vals), 0x0c,
6290                 NULL, HFILL }
6291         },
6292         { &hf_gsm_a_gmm_net_cap_solsa,
6293                 { "SoLSA Capability", "gsm_a.gmm.net_cap.solsa",
6294                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_solsa_vals), 0x02,
6295                 NULL, HFILL }
6296         },
6297         { &hf_gsm_a_gmm_net_cap_rev,
6298                 { "Revision level indicator", "gsm_a.gmm.net_cap.rev",
6299                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_rev_vals), 0x01,
6300                 NULL, HFILL }
6301         },
6302         { &hf_gsm_a_gmm_net_cap_pfc,
6303                 { "PFC feature mode", "gsm_a.gmm.net_cap.pfc",
6304                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_pfc_vals), 0x80,
6305                 NULL, HFILL }
6306         },
6307         { &hf_gsm_a_gmm_net_cap_ext_gea_bits,
6308                 { "Extended GEA bits", "gsm_a.gmm.net_cap.ext_gea_bits",
6309                 FT_UINT8, BASE_HEX, NULL, 0x7e,
6310                 NULL, HFILL }
6311         },
6312         { &hf_gsm_a_gmm_net_cap_gea2,
6313                 { "GEA/2", "gsm_a.gmm.net_cap.gea2",
6314                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_gea_vals), 0x40,
6315                 NULL, HFILL }
6316         },
6317         { &hf_gsm_a_gmm_net_cap_gea3,
6318                 { "GEA/3", "gsm_a.gmm.net_cap.gea3",
6319                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_gea_vals), 0x20,
6320                 NULL, HFILL }
6321         },
6322         { &hf_gsm_a_gmm_net_cap_gea4,
6323                 { "GEA/4", "gsm_a.gmm.net_cap.gea4",
6324                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_gea_vals), 0x10,
6325                 NULL, HFILL }
6326         },
6327         { &hf_gsm_a_gmm_net_cap_gea5,
6328                 { "GEA/5", "gsm_a.gmm.net_cap.gea5",
6329                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_gea_vals), 0x08,
6330                 NULL, HFILL }
6331         },
6332         { &hf_gsm_a_gmm_net_cap_gea6,
6333                 { "GEA/6", "gsm_a.gmm.net_cap.gea6",
6334                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_gea_vals), 0x04,
6335                 NULL, HFILL }
6336         },
6337         { &hf_gsm_a_gmm_net_cap_gea7,
6338                 { "GEA/7", "gsm_a.gmm.net_cap.gea7",
6339                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_gea_vals), 0x02,
6340                 NULL, HFILL }
6341         },
6342         { &hf_gsm_a_gmm_net_cap_lcs,
6343                 { "LCS VA capability", "gsm_a.gmm.net_cap.lcs",
6344                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_lcs_vals), 0x01,
6345                 NULL, HFILL }
6346         },
6347         { &hf_gsm_a_gmm_net_cap_ps_irat_iu,
6348                 { "PS inter-RAT HO to UTRAN Iu mode capability", "gsm_a.gmm.net_cap.ps_irat_iu",
6349                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_ps_irat_iu_vals), 0x80,
6350                 NULL, HFILL }
6351         },
6352         { &hf_gsm_a_gmm_net_cap_ps_irat_s1,
6353                 { "PS inter-RAT HO to E-UTRAN S1 mode capability", "gsm_a.gmm.net_cap.ps_irat_s1",
6354                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_ps_irat_s1_vals), 0x40,
6355                 NULL, HFILL }
6356         },
6357         { &hf_gsm_a_gmm_net_cap_csfb,
6358                 { "CSFB Capability", "gsm_a.gmm.net_cap.csfb",
6359                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_csfb_vals), 0x20,
6360                 NULL, HFILL }
6361         },
6362         { &hf_gsm_a_gmm_net_cap_isr,
6363                 { "ISR support", "gsm_a.gmm.net_cap.isr",
6364                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_isr_vals), 0x10,
6365                 NULL, HFILL }
6366         },
6367         { &hf_gsm_a_gmm_net_cap_srvcc_to_geran,
6368                 { "SRVCC to GERAN/UTRAN capability", "gsm_a.gmm.net_cap.srvcc_to_geran",
6369                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_srvcc_to_geran_vals), 0x08,
6370                 NULL, HFILL }
6371         },
6372         { &hf_gsm_a_gmm_net_cap_epc,
6373                 { "EPC Capability", "gsm_a.gmm.net_cap.epc",
6374                 FT_BOOLEAN, 8, TFS(&gsm_a_gmm_net_cap_epc_vals), 0x04,
6375                 NULL, HFILL }
6376         },
6377         { &hf_gsm_a_sm_tmgi,
6378                 { "Temporary Mobile Group Identity (TMGI)", "gsm_a.sm.tmgi",
6379                   FT_UINT24, BASE_HEX, NULL, 0x0,
6380                 NULL, HFILL }
6381         },
6382         { &hf_gsm_a_sm_enh_nsapi,
6383                 { "Enhanced NSAPI", "gsm_a.sm.enh_nsapi",
6384                   FT_UINT8, BASE_DEC, NULL, 0x0,
6385                 NULL, HFILL }
6386         },
6387         { &hf_gsm_a_sm_req_type,
6388                 { "Request type", "gsm_a.sm.req_type",
6389                   FT_UINT8, BASE_DEC, VALS(gsm_a_sm_req_type_vals), 0x07,
6390                 NULL, HFILL }
6391         },
6392         { &hf_gsm_a_gm_rac_ctrled_early_cm_sending,
6393                 { "Controlled early Classmark Sending", "gsm_a.gm.rac.comp_int_meas_cap",
6394                    FT_BOOLEAN, 8, TFS(&tfs_implemented_not_implemented), 0x0,
6395                 NULL, HFILL }
6396         },
6397         { &hf_gsm_a_gm_rac_multislot_capability,
6398                 { "Multislot capability struct", "gsm_a.gm.rac.multislot_capability",
6399                    FT_BOOLEAN, 8, TFS(&tfs_present_not_present), 0x0,
6400                 NULL, HFILL }
6401         },
6402
6403         { &hf_gsm_a_gm_rac_single_slt_dtm,
6404                 { "Single Slot DTM", "gsm_a.gm.rac.single_slt_dtm",
6405                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
6406                 NULL, HFILL }
6407         },
6408         { &hf_gsm_a_gm_rac_dtm_egprs_multi_slot_cls_pres,
6409                 { "DTM EGPRS Multi Slot Class", "gsm_a.gm.rac.dtm_egprs_multi_slot_cls_pres",
6410                    FT_BOOLEAN, 8, TFS(&tfs_present_not_present), 0x0,
6411                 NULL, HFILL }
6412         },
6413         { &hf_gsm_a_gm_rac_8psk_pow_cap_pres,
6414                 { "8PSK Power Capability Bits", "gsm_a.gm.rac.8psk_pow_cap_pres",
6415                    FT_BOOLEAN, 8, TFS(&tfs_present_not_present), 0x0,
6416                 NULL, HFILL }
6417         },
6418         { &hf_gsm_a_gm_rac_comp_int_meas_cap,
6419                 { "COMPACT Interference Measurement Capability", "gsm_a.gm.rac.comp_int_meas_cap",
6420                    FT_BOOLEAN, 8, TFS(&tfs_implemented_not_implemented), 0x0,
6421                 NULL, HFILL }
6422         },
6423         { &hf_gsm_a_gm_rel_lev_ind,
6424                 { "Revision Level Indicator", "gsm_a.gm.rel_lev_ind",
6425                    FT_UINT8, BASE_HEX, VALS(gsm_a_gm_revision_level_indicator_vals), 0x0,
6426                 NULL, HFILL }
6427         },
6428         { &hf_gsm_a_gm_rac_umts_fdd_cap,
6429                 { "UMTS FDD Radio Access Technology Capability", "gsm_a.gm.rac.umts_fdd_cap",
6430                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
6431                 NULL, HFILL }
6432         },
6433         { &hf_gsm_a_gm_rac_umts_384_tdd_ra_cap,
6434                 { "UMTS 3.84 Mcps TDD Radio Access Technology Capability", "gsm_a.gm.rac.umts_384_tdd_ra_cap",
6435                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
6436                 NULL, HFILL }
6437         },
6438         { &hf_gsm_a_gm_rac_cdma2000_cap,
6439                 { "CDMA 2000 Radio Access Technology Capability", "gsm_a.gm.rac.cdma2000_cap",
6440                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
6441                 NULL, HFILL }
6442         },
6443         { &hf_gsm_a_gm_rac_umts_128_tdd_ra_cap,
6444                 { "UMTS 1.28 Mcps TDD Radio Access Technology Capability", "gsm_a.gm.rac.umts_128_tdd_ra_cap",
6445                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
6446                 NULL, HFILL }
6447         },
6448         { &hf_gsm_a_gm_rac_geran_feat_pkg,
6449                 { "GERAN Feature Package 1", "gsm_a.gm.rac.geran_feat_pkg",
6450                    FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x0,
6451                 NULL, HFILL }
6452         },
6453         };
6454
6455         /* Setup protocol subtree array */
6456 #define NUM_INDIVIDUAL_ELEMS    18
6457         gint *ett[NUM_INDIVIDUAL_ELEMS +
6458                   NUM_GSM_DTAP_MSG_GMM + NUM_GSM_DTAP_MSG_SM +
6459                   NUM_GSM_GM_ELEM];
6460
6461         ett[0]  = &ett_tc_component;
6462         ett[1]  = &ett_tc_invoke_id;
6463         ett[2]  = &ett_tc_linked_id;
6464         ett[3]  = &ett_tc_opr_code;
6465         ett[4]  = &ett_tc_err_code;
6466         ett[5]  = &ett_tc_prob_code;
6467         ett[6]  = &ett_tc_sequence;
6468         ett[7]  = &ett_gmm_drx;
6469         ett[8]  = &ett_gmm_detach_type;
6470         ett[9]  = &ett_gmm_attach_type;
6471         ett[10] = &ett_gmm_context_stat;
6472         ett[11] = &ett_gmm_update_type;
6473         ett[12] = &ett_gmm_radio_cap;
6474         ett[13] = &ett_gmm_rai;
6475         ett[14] = &ett_sm_tft;
6476         ett[15] = &ett_gmm_gprs_timer;
6477         ett[16] = &ett_gmm_network_cap;
6478         ett[17] = &ett_gsm_a_gm_msrac_multislot_capability;
6479
6480         last_offset = NUM_INDIVIDUAL_ELEMS;
6481
6482         for (i=0; i < NUM_GSM_DTAP_MSG_GMM; i++, last_offset++)
6483         {
6484                 ett_gsm_dtap_msg_gmm[i] = -1;
6485                 ett[last_offset] = &ett_gsm_dtap_msg_gmm[i];
6486         }
6487
6488         for (i=0; i < NUM_GSM_DTAP_MSG_SM; i++, last_offset++)
6489         {
6490                 ett_gsm_dtap_msg_sm[i] = -1;
6491                 ett[last_offset] = &ett_gsm_dtap_msg_sm[i];
6492         }
6493
6494         for (i=0; i < NUM_GSM_GM_ELEM; i++, last_offset++)
6495         {
6496                 ett_gsm_gm_elem[i] = -1;
6497                 ett[last_offset] = &ett_gsm_gm_elem[i];
6498         }
6499
6500         proto_a_gm =
6501                 proto_register_protocol("GSM A-I/F GPRS Mobility and Session Management", "GSM Management", "gsm_a_gm");
6502
6503         proto_register_field_array(proto_a_gm, hf, array_length(hf));
6504
6505         proto_register_subtree_array(ett, array_length(ett));
6506
6507         /* subdissector code */
6508         gprs_sm_pco_subdissector_table = register_dissector_table("sm_pco.protocol",
6509                 "GPRS SM PCO PPP protocol", FT_UINT16, BASE_HEX);
6510 }
6511
6512 void
6513 proto_reg_handoff_gsm_a_gm(void)
6514 {
6515         data_handle = find_dissector("data");
6516         rrc_irat_ho_info_handle = find_dissector("rrc.irat.irat_ho_info");
6517 }