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