1436869f3f80e4fc6be8af367705dcaef1564ef8
[metze/wireshark/wip.git] / epan / dissectors / packet-gtp.c
1 /* packet-gtp.c
2  *
3  * Routines for GTP dissection
4  * Copyright 2001, Michal Melerowicz <michal.melerowicz@nokia.com>
5  *                 Nicolas Balkota <balkota@mac.com>
6  *
7  * Updates and corrections:
8  * Copyright 2006 - 2009, Anders Broman <anders.broman@ericsson.com>
9  *
10  * Added Bearer control mode dissection:
11  * Copyright 2011, Grzegorz Szczytowski <grzegorz.szczytowski@gmail.com>
12  *
13  * Updates and corrections:
14  * Copyright 2011-2013, Anders Broman <anders.broman@ericsson.com>
15  *
16  * PDCP PDU number extension header support added by Martin Isaksson <martin.isaksson@ericsson.com>
17  *
18  * Control Plane Request-Response tracking code Largely based on similar routines in
19  * packet-ldap.c by Ronnie Sahlberg
20  * Added by Kari Tiirikainen <kari.tiirikainen@nsn.com>
21  *
22  * Wireshark - Network traffic analyzer
23  * By Gerald Combs <gerald@wireshark.org>
24  * Copyright 1998 Gerald Combs
25  *
26  * SPDX-License-Identifier: GPL-2.0-or-later
27  *
28  * GTP v0: 3GPP TS 09.60
29  *
30  *    http://www.3gpp.org/ftp/Specs/html-info/0960.htm
31  *
32  * GTP v1: 3GPP TS 29.060
33  *
34  *    http://www.3gpp.org/ftp/Specs/html-info/29060.htm
35  *
36  * GTP': 3GPP TS 32.295
37  *
38  *    http://www.3gpp.org/ftp/Specs/html-info/32295.htm
39  */
40
41 #include "config.h"
42
43 #include <epan/packet.h>
44 #include <epan/conversation.h>
45 #include <epan/prefs.h>
46 #include <epan/expert.h>
47 #include <epan/sminmpec.h>
48 #include <epan/addr_resolv.h>
49 #include <epan/asn1.h>
50 #include <epan/tap.h>
51 #include <epan/srt_table.h>
52 #include <epan/to_str.h>
53 #include "packet-ppp.h"
54 #include "packet-radius.h"
55 #include "packet-gsm_a_common.h"
56 #include "packet-gsm_map.h"
57 #include "packet-gprscdr.h"
58 #include "packet-bssgp.h"
59 #include "packet-e212.h"
60 #include "packet-gtp.h"
61 #include "packet-ranap.h"
62
63 void proto_register_gtp(void);
64 void proto_reg_handoff_gtp(void);
65
66 static dissector_table_t ppp_subdissector_table;
67 static dissector_table_t gtp_priv_ext_dissector_table;
68 static dissector_table_t gtp_cdr_fmt_dissector_table;
69 static dissector_handle_t gtp_handle, gtp_prime_handle;
70
71 #define GTPv0_PORT  3386
72 #define GTPv1C_PORT 2123    /* 3G Control PDU */
73 #define GTPv1U_PORT 2152    /* 3G T-PDU */
74
75 #define GTPv0_HDR_LENGTH     20
76 #define GTPv1_HDR_LENGTH     12
77 #define GTP_PRIME_HDR_LENGTH  6
78
79 /* to check compliance with ETSI  */
80 #define GTP_MANDATORY   1
81 #define GTP_OPTIONAL    2
82 #define GTP_CONDITIONAL 4
83
84 #define GTP_TPDU_AS_NONE -1
85 #define GTP_TPDU_AS_TPDU 0
86 #define GTP_TPDU_AS_SYNC 2
87
88 static gboolean g_gtp_over_tcp = TRUE;
89 gboolean g_gtp_session = FALSE;
90
91 static guint g_gtpv0_port  = GTPv0_PORT;
92 static guint g_gtpv1c_port = GTPv1C_PORT;
93 static guint g_gtpv1u_port = GTPv1U_PORT;
94
95 static int proto_gtp = -1;
96 static int proto_gtpprime = -1;
97
98 /*KTi*/
99 static int hf_gtp_ie_id = -1;
100 static int hf_gtp_response_in = -1;
101 static int hf_gtp_response_to = -1;
102 static int hf_gtp_time = -1;
103 static int hf_gtp_apn = -1;
104 static int hf_gtp_cause = -1;
105 static int hf_gtp_chrg_char = -1;
106 static int hf_gtp_chrg_char_s = -1;
107 static int hf_gtp_chrg_char_n = -1;
108 static int hf_gtp_chrg_char_p = -1;
109 static int hf_gtp_chrg_char_f = -1;
110 static int hf_gtp_chrg_char_h = -1;
111 static int hf_gtp_chrg_char_r = -1;
112 static int hf_gtp_chrg_id = -1;
113 static int hf_gtp_chrg_ipv4 = -1;
114 static int hf_gtp_chrg_ipv6 = -1;
115 static int hf_gtp_ext_flow_label = -1;
116 static int hf_gtp_ext_id = -1;
117 static int hf_gtp_ext_val = -1;
118 static int hf_gtp_ext_hdr = -1;
119 static int hf_gtp_ext_hdr_next = -1;
120 static int hf_gtp_ext_hdr_length = -1;
121 static int hf_gtp_ext_hdr_ran_cont = -1;
122 static int hf_gtp_ext_hdr_spare_bits = -1;
123 static int hf_gtp_ext_hdr_spare_bytes = -1;
124 static int hf_gtp_ext_hdr_long_pdcp_sn = -1;
125 static int hf_gtp_ext_hdr_xw_ran_cont = -1;
126 static int hf_gtp_ext_hdr_nr_ran_cont = -1;
127 static int hf_gtp_ext_hdr_pdu_session_cont = -1;
128 static int hf_gtp_ext_hdr_pdcpsn = -1;
129 static int hf_gtp_ext_hdr_udp_port = -1;
130 static int hf_gtp_flags = -1;
131 static int hf_gtp_flags_ver = -1;
132 static int hf_gtp_prime_flags_ver = -1;
133 static int hf_gtp_flags_pt = -1;
134 static int hf_gtp_flags_spare1 = -1;
135 static int hf_gtp_flags_hdr_length = -1;
136 static int hf_gtp_flags_snn = -1;
137 static int hf_gtp_flags_spare2 = -1;
138 static int hf_gtp_flags_e = -1;
139 static int hf_gtp_flags_s = -1;
140 static int hf_gtp_flags_pn = -1;
141 static int hf_gtp_flow_ii = -1;
142 static int hf_gtp_flow_label = -1;
143 static int hf_gtp_flow_sig = -1;
144 static int hf_gtp_gsn_addr_len = -1;
145 static int hf_gtp_gsn_addr_type = -1;
146 static int hf_gtp_gsn_ipv4 = -1;
147 static int hf_gtp_gsn_ipv6 = -1;
148 static int hf_gtp_length = -1;
149 static int hf_gtp_map_cause = -1;
150 static int hf_gtp_message_type = -1;
151 static int hf_gtp_ms_reason = -1;
152 static int hf_gtp_ms_valid = -1;
153 static int hf_gtp_npdu_number = -1;
154 static int hf_gtp_node_ipv4 = -1;
155 static int hf_gtp_node_ipv6 = -1;
156 static int hf_gtp_nsapi = -1;
157 static int hf_gtp_ptmsi = -1;
158 static int hf_gtp_ptmsi_sig = -1;
159 static int hf_gtp_qos_version = -1;
160 static int hf_gtp_qos_spare1 = -1;
161 static int hf_gtp_qos_delay = -1;
162 static int hf_gtp_qos_mean = -1;
163 static int hf_gtp_qos_peak = -1;
164 static int hf_gtp_qos_spare2 = -1;
165 static int hf_gtp_qos_precedence = -1;
166 static int hf_gtp_qos_spare3 = -1;
167 static int hf_gtp_qos_reliability = -1;
168 static int hf_gtp_qos_al_ret_priority = -1;
169 static int hf_gtp_qos_traf_class = -1;
170 static int hf_gtp_qos_del_order = -1;
171 static int hf_gtp_qos_del_err_sdu = -1;
172 static int hf_gtp_qos_max_sdu_size = -1;
173 static int hf_gtp_qos_max_ul = -1;
174 static int hf_gtp_qos_max_dl = -1;
175 static int hf_gtp_qos_res_ber = -1;
176 static int hf_gtp_qos_sdu_err_ratio = -1;
177 static int hf_gtp_qos_trans_delay = -1;
178 static int hf_gtp_qos_traf_handl_prio = -1;
179 static int hf_gtp_qos_guar_ul = -1;
180 static int hf_gtp_qos_guar_dl = -1;
181 static int hf_gtp_qos_spare4 = -1;
182 static int hf_gtp_qos_sig_ind = -1;
183 static int hf_gtp_qos_src_stat_desc = -1;
184 static int hf_gtp_qos_arp = -1;
185 static int hf_gtp_qos_arp_pvi = -1;
186 static int hf_gtp_qos_arp_pl = -1;
187 static int hf_gtp_qos_arp_pci = -1;
188 static int hf_gtp_qos_qci = -1;
189 static int hf_gtp_qos_ul_mbr = -1;
190 static int hf_gtp_qos_dl_mbr = -1;
191 static int hf_gtp_qos_ul_gbr = -1;
192 static int hf_gtp_qos_dl_gbr = -1;
193 static int hf_gtp_qos_ul_apn_ambr = -1;
194 static int hf_gtp_qos_dl_apn_ambr = -1;
195 static int hf_gtp_pkt_flow_id = -1;
196 static int hf_gtp_rab_gtpu_dn = -1;
197 static int hf_gtp_rab_gtpu_up = -1;
198 static int hf_gtp_rab_pdu_dn = -1;
199 static int hf_gtp_rab_pdu_up = -1;
200 static int hf_gtp_uli_geo_loc_type = -1;
201 static int hf_gtp_cgi_ci = -1;
202 static int hf_gtp_sai_sac = -1;
203 static int hf_gtp_rai_rac = -1;
204 static int hf_gtp_lac = -1;
205 static int hf_gtp_tac = -1;
206 static int hf_gtp_eci = -1;
207 static int hf_gtp_ranap_cause = -1;
208 static int hf_gtp_recovery = -1;
209 static int hf_gtp_reorder = -1;
210 static int hf_gtp_rnc_ipv4 = -1;
211 static int hf_gtp_rnc_ipv6 = -1;
212 static int hf_gtp_rp = -1;
213 static int hf_gtp_rp_nsapi = -1;
214 static int hf_gtp_rp_sms = -1;
215 static int hf_gtp_rp_spare = -1;
216 static int hf_gtp_sel_mode = -1;
217 static int hf_gtp_seq_number = -1;
218 static int hf_gtp_session = -1;
219 static int hf_gtp_sndcp_number = -1;
220 static int hf_gtp_tear_ind = -1;
221 static int hf_gtp_teid = -1;
222 static int hf_gtp_teid_cp = -1;
223 static int hf_gtp_ulink_teid_cp = -1;
224 static int hf_gtp_teid_data = -1;
225 static int hf_gtp_ulink_teid_data = -1;
226 static int hf_gtp_teid_ii = -1;
227 static int hf_gtp_tid = -1;
228 static int hf_gtp_tlli = -1;
229 static int hf_gtp_tr_comm = -1;
230 static int hf_gtp_trace_ref = -1;
231 static int hf_gtp_trace_type = -1;
232 static int hf_gtp_user_addr_pdp_org = -1;
233 static int hf_gtp_user_addr_pdp_type = -1;
234 static int hf_gtp_user_ipv4 = -1;
235 static int hf_gtp_user_ipv6 = -1;
236 static int hf_gtp_security_mode = -1;
237 static int hf_gtp_no_of_vectors = -1;
238 static int hf_gtp_cipher_algorithm = -1;
239 static int hf_gtp_cksn_ksi = -1;
240 static int hf_gtp_cksn = -1;
241 static int hf_gtp_ksi = -1;
242 static int hf_gtp_ext_length = -1;
243 static int hf_gtp_utran_field = -1;
244 static int hf_gtp_ext_apn_res = -1;
245 static int hf_gtp_ext_rat_type = -1;
246 static int hf_gtp_ext_imeisv = -1;
247 static int hf_gtp_target_rnc_id = -1;
248 static int hf_gtp_target_ext_rnc_id = -1;
249 static int hf_gtp_bssgp_cause = -1;
250 static int hf_gtp_bssgp_ra_discriminator = -1;
251 static int hf_gtp_sapi = -1;
252 static int hf_gtp_xid_par_len = -1;
253 static int hf_gtp_rep_act_type = -1;
254 static int hf_gtp_correlation_id = -1;
255 static int hf_gtp_earp_pci = -1;
256 static int hf_gtp_earp_pl = -1;
257 static int hf_gtp_earp_pvi = -1;
258 static int hf_gtp_ext_comm_flags_uasi = -1;
259 static int hf_gtp_ext_comm_flags_II_pnsi = -1;
260 static int hf_gtp_ext_comm_flags_II_dtci = -1;
261 static int hf_gtp_ext_comm_flags_II_pmtsmi = -1;
262 static int hf_gtp_ext_comm_flags_II_spare = -1;
263 static int hf_gtp_cdr_app = -1;
264 static int hf_gtp_cdr_rel = -1;
265 static int hf_gtp_cdr_ver = -1;
266 static int hf_gtp_cdr_length = -1;
267 static int hf_gtp_cdr_context = -1;
268 static int hf_gtp_cmn_flg_ppc = -1;
269 static int hf_gtp_cmn_flg_mbs_srv_type = -1;
270 static int hf_gtp_cmn_flg_mbs_ran_pcd_rdy = -1;
271 static int hf_gtp_cmn_flg_mbs_cnt_inf = -1;
272 static int hf_gtp_cmn_flg_nrsn = -1;
273 static int hf_gtp_cmn_flg_no_qos_neg = -1;
274 static int hf_gtp_cmn_flg_upgrd_qos_sup = -1;
275 static int hf_gtp_cmn_flg_dual_addr_bearer_flg = -1;
276 static int hf_gtp_tmgi = -1;
277 static int hf_gtp_mbms_ses_dur_days = -1;
278 static int hf_gtp_mbms_ses_dur_s = -1;
279 static int hf_gtp_no_of_mbms_sa_codes = -1;
280 static int hf_gtp_mbms_sa_code = -1;
281 static int hf_gtp_mbs_2g_3g_ind = -1;
282 static int hf_gtp_time_2_dta_tr = -1;
283 static int hf_gtp_ext_ei = -1;
284 static int hf_gtp_ext_gcsi = -1;
285 static int hf_gtp_ext_dti = -1;
286 static int hf_gtp_ra_prio_lcs = -1;
287 static int hf_gtp_bcm = -1;
288 static int hf_gtp_fqdn = -1;
289 static int hf_gtp_rim_routing_addr = -1;
290 static int hf_gtp_mbms_flow_id = -1;
291 static int hf_gtp_mbms_dist_indic = -1;
292 static int hf_gtp_ext_apn_ambr_ul = -1;
293 static int hf_gtp_ext_apn_ambr_dl = -1;
294 static int hf_gtp_ext_sub_ue_ambr_ul = -1;
295 static int hf_gtp_ext_sub_ue_ambr_dl = -1;
296 static int hf_gtp_ext_auth_ue_ambr_ul = -1;
297 static int hf_gtp_ext_auth_ue_ambr_dl = -1;
298 static int hf_gtp_ext_auth_apn_ambr_ul = -1;
299 static int hf_gtp_ext_auth_apn_ambr_dl = -1;
300 static int hf_gtp_ext_ggsn_back_off_time_units = -1;
301 static int hf_gtp_ext_ggsn_back_off_timer = -1;
302 static int hf_gtp_higher_br_16mb_flg = -1;
303 static int hf_gtp_max_mbr_apn_ambr_ul = -1;
304 static int hf_gtp_max_mbr_apn_ambr_dl = -1;
305 static int hf_gtp_ext_enb_type = -1;
306 static int hf_gtp_macro_enodeb_id = -1;
307 static int hf_gtp_home_enodeb_id = -1;
308 static int hf_gtp_dummy_octets = -1;
309
310 /* Generated from convert_proto_tree_add_text.pl */
311 static int hf_gtp_ggsn_2_address_ipv4 = -1;
312 static int hf_gtp_rfsp_index = -1;
313 static int hf_gtp_quintuplet_ciphering_key = -1;
314 static int hf_gtp_kc = -1;
315 static int hf_gtp_rand = -1;
316 static int hf_gtp_pdp_context_identifier = -1;
317 static int hf_gtp_receive_n_pdu_number = -1;
318 static int hf_gtp_container_length = -1;
319 static int hf_gtp_quintuplets_length = -1;
320 static int hf_gtp_auth = -1;
321 static int hf_gtp_tft_length = -1;
322 static int hf_gtp_ggsn_address_for_control_plane = -1;
323 static int hf_gtp_integrity_key_ik = -1;
324 static int hf_gtp_gsn_address_information_element_length = -1;
325 static int hf_gtp_reordering_required = -1;
326 static int hf_gtp_sres = -1;
327 static int hf_gtp_data_record_format = -1;
328 static int hf_gtp_timezone = -1;
329 static int hf_gtp_timezone_dst = -1;
330 static int hf_gtp_authentication_length = -1;
331 static int hf_gtp_send_n_pdu_number = -1;
332 static int hf_gtp_sequence_number_up = -1;
333 static int hf_gtp_pdp_address_length = -1;
334 static int hf_gtp_transaction_identifier = -1;
335 static int hf_gtp_xres_length = -1;
336 static int hf_gtp_ggsn_address_length = -1;
337 static int hf_gtp_apn_length = -1;
338 static int hf_gtp_sequence_number_down = -1;
339 static int hf_gtp_ggsn_2_address_ipv6 = -1;
340 static int hf_gtp_pdp_address_ipv4 = -1;
341 static int hf_gtp_activity_status_indicator = -1;
342 static int hf_gtp_pdp_type = -1;
343 static int hf_gtp_ggsn_address_for_user_traffic = -1;
344 static int hf_gtp_quintuplet_integrity_key = -1;
345 static int hf_gtp_pdp_address_ipv6 = -1;
346 static int hf_gtp_rab_setup_length = -1;
347 static int hf_gtp_number_of_data_records = -1;
348 static int hf_gtp_ciphering_key_kc = -1;
349 static int hf_gtp_pdp_cntxt_sapi = -1;
350 static int hf_gtp_xres = -1;
351 static int hf_gtp_pdp_organization = -1;
352 static int hf_gtp_node_address_length = -1;
353 static int hf_gtp_ggsn_2_address_length = -1;
354 static int hf_gtp_gsn_address_length = -1;
355 static int hf_gtp_vplmn_address_allowed = -1;
356 static int hf_gtp_uplink_flow_label_signalling = -1;
357 static int hf_gtp_extended_end_user_address = -1;
358 static int hf_gtp_ciphering_key_ck = -1;
359 static int hf_gtp_fqdn_length = -1;
360 static int hf_gtp_seq_num_released = -1;
361 static int hf_gtp_seq_num_canceled = -1;
362 static int hf_gtp_requests_responded = -1;
363 static int hf_gtp_hyphen_separator = -1;
364 static int hf_gtp_ms_network_cap_content_len = -1;
365 static int hf_gtp_iei = -1;
366 static int hf_gtp_iei_mobile_id_len = -1;
367 static int hf_gtp_qos_umts_length = -1;
368 static int hf_gtp_num_ext_hdr_types = -1;
369 static int hf_gtp_ext_hdr_type = -1;
370 static int hf_gtp_tpdu_data = -1;
371
372 /* Initialize the subtree pointers */
373 static gint ett_gtp = -1;
374 static gint ett_gtp_flags = -1;
375 static gint ett_gtp_ext = -1;
376 static gint ett_gtp_ext_hdr = -1;
377 static gint ett_gtp_qos = -1;
378 static gint ett_gtp_qos_arp = -1;
379 static gint ett_gtp_flow_ii = -1;
380 static gint ett_gtp_rp = -1;
381 static gint ett_gtp_pkt_flow_id = -1;
382 static gint ett_gtp_trip = -1;
383 static gint ett_gtp_quint = -1;
384 static gint ett_gtp_proto = -1;
385 static gint ett_gtp_gsn_addr = -1;
386 static gint ett_gtp_tft = -1;
387 static gint ett_gtp_rab_setup = -1;
388 static gint ett_gtp_hdr_list = -1;
389 static gint ett_gtp_node_addr = -1;
390 static gint ett_gtp_rel_pack = -1;
391 static gint ett_gtp_can_pack = -1;
392 static gint ett_gtp_data_resp = -1;
393 static gint ett_gtp_drx = -1;
394 static gint ett_gtp_net_cap = -1;
395 static gint ett_gtp_tmgi = -1;
396 static gint ett_gtp_cdr_ver = -1;
397 static gint ett_gtp_cdr_dr = -1;
398 static gint ett_gtp_mm_cntxt = -1;
399 static gint ett_gtp_utran_cont = -1;
400
401 static expert_field ei_gtp_ext_hdr_pdcpsn = EI_INIT;
402 static expert_field ei_gtp_ext_length_mal = EI_INIT;
403 static expert_field ei_gtp_ext_length_warn = EI_INIT;
404 static expert_field ei_gtp_undecoded = EI_INIT;
405 static expert_field ei_gtp_message_not_found = EI_INIT;
406 static expert_field ei_gtp_field_not_present = EI_INIT;
407 static expert_field ei_gtp_wrong_next_field = EI_INIT;
408 static expert_field ei_gtp_field_not_support_in_version = EI_INIT;
409 static expert_field ei_gtp_guaranteed_bit_rate_value = EI_INIT;
410 static expert_field ei_gtp_max_bit_rate_value = EI_INIT;
411 static expert_field ei_gtp_ext_geo_loc_type = EI_INIT;
412 static expert_field ei_gtp_iei = EI_INIT;
413 static expert_field ei_gtp_unknown_extention_header = EI_INIT;
414
415 static gboolean g_gtp_etsi_order = FALSE;
416
417 static gint dissect_tpdu_as = GTP_TPDU_AS_TPDU;
418 static const enum_val_t gtp_decode_tpdu_as[] = {
419     {"none", "None",   GTP_TPDU_AS_NONE},
420     {"tpdu", "TPDU",   GTP_TPDU_AS_TPDU},
421     {"sync", "SYNC",   GTP_TPDU_AS_SYNC},
422     {NULL, NULL, 0}
423 };
424
425
426 static int gtp_tap = -1;
427 static int gtpv1_tap = -1;
428
429 /* Definition of flags masks */
430 #define GTP_VER_MASK 0xE0
431
432 static const true_false_string gtp_hdr_length_vals = {
433     "6-Octet Header",
434     "20-Octet Header"
435 };
436
437 static const value_string ver_types[] = {
438     {0, "GTP release 97/98 version"},
439     {1, "GTP release 99 version"},
440     {2, "GTPv2-C"},
441     {3, "None"},
442     {4, "None"},
443     {5, "None"},
444     {6, "None"},
445     {7, "None"},
446     {0, NULL}
447 };
448
449 static const value_string pt_types[] = {
450     {0, "GTP'"},
451     {1, "GTP"},
452     {0, NULL}
453 };
454
455 #define GTP_PT_MASK         0x10
456 #define GTP_SPARE1_MASK     0x0E
457 #define GTP_SPARE2_MASK     0x08
458 #define GTP_E_MASK          0x04
459 #define GTP_S_MASK          0x02
460 #define GTP_SNN_MASK        0x01
461 #define GTP_PN_MASK         0x01
462
463 #define GTP_EXT_HDR_NO_MORE_EXT_HDRS         0x00
464 #define GTP_EXT_HDR_MBMS_SUPPORT_IND         0x01
465 #define GTP_EXT_HDR_MS_INFO_CHG_REP_SUPP_IND 0x02
466 #define GTP_EXT_HDR_UDP_PORT                 0x40
467 #define GTP_EXT_HDR_RAN_CONT                 0x81
468 #define GTP_EXT_HDR_LONG_PDCP_PDU            0x82
469 #define GTP_EXT_HDR_XW_RAN_CONT              0x83
470 #define GTP_EXT_HDR_NR_RAN_CONT              0x84
471 #define GTP_EXT_HDR_PDU_SESSION_CONT         0x85
472 #define GTP_EXT_HDR_PDCP_SN                  0xC0
473 #define GTP_EXT_HDR_SUSPEND_REQ              0xC1
474 #define GTP_EXT_HDR_SUSPEND_RESP             0xC2
475
476 static const value_string next_extension_header_fieldvals[] = {
477     {GTP_EXT_HDR_NO_MORE_EXT_HDRS, "No more extension headers"},
478     {GTP_EXT_HDR_MBMS_SUPPORT_IND, "MBMS support indication"},
479     {GTP_EXT_HDR_MS_INFO_CHG_REP_SUPP_IND, "MS Info Change Reporting support indication"},
480     {GTP_EXT_HDR_UDP_PORT, "UDP Port number"},
481     {GTP_EXT_HDR_RAN_CONT,"RAN container"},
482     {GTP_EXT_HDR_LONG_PDCP_PDU,"Long PDCP PDU number"},
483     {GTP_EXT_HDR_XW_RAN_CONT,"Xw RAN container"},
484     {GTP_EXT_HDR_NR_RAN_CONT,"NR RAN container"},
485     {GTP_EXT_HDR_PDU_SESSION_CONT,"PDU Session container"},
486     {GTP_EXT_HDR_PDCP_SN, "PDCP PDU number"},
487     {GTP_EXT_HDR_SUSPEND_REQ, "Suspend Request"},
488     {GTP_EXT_HDR_SUSPEND_RESP, "Suspend Response"},
489     {0, NULL}
490 };
491
492 /* Definition of 3G charging characteristics masks */
493 #define GTP_MASK_CHRG_CHAR_S    0xF000
494 #define GTP_MASK_CHRG_CHAR_N    0x0800
495 #define GTP_MASK_CHRG_CHAR_P    0x0400
496 #define GTP_MASK_CHRG_CHAR_F    0x0200
497 #define GTP_MASK_CHRG_CHAR_H    0x0100
498 #define GTP_MASK_CHRG_CHAR_R    0x00FF
499
500 /* Definition of GSN Address masks */
501 #define GTP_EXT_GSN_ADDR_TYPE_MASK      0xC0
502 #define GTP_EXT_GSN_ADDR_LEN_MASK       0x3F
503
504 /* Definition of QoS masks */
505 #define GTP_EXT_QOS_SPARE1_MASK                 0xC0
506 #define GTP_EXT_QOS_DELAY_MASK                  0x38
507 #define GTP_EXT_QOS_RELIABILITY_MASK            0x07
508 #define GTP_EXT_QOS_PEAK_MASK                   0xF0
509 #define GTP_EXT_QOS_SPARE2_MASK                 0x08
510 #define GTP_EXT_QOS_PRECEDENCE_MASK             0x07
511 #define GTP_EXT_QOS_SPARE3_MASK                 0xE0
512 #define GTP_EXT_QOS_MEAN_MASK                   0x1F
513 #define GTP_EXT_QOS_TRAF_CLASS_MASK             0xE0
514 #define GTP_EXT_QOS_DEL_ORDER_MASK              0x18
515 #define GTP_EXT_QOS_DEL_ERR_SDU_MASK            0x07
516 #define GTP_EXT_QOS_RES_BER_MASK                0xF0
517 #define GTP_EXT_QOS_SDU_ERR_RATIO_MASK          0x0F
518 #define GTP_EXT_QOS_TRANS_DELAY_MASK            0xFC
519 #define GTP_EXT_QOS_TRAF_HANDL_PRIORITY_MASK    0x03
520 #define GTP_EXT_QOS_SPARE4_MASK                 0xE0
521 #define GTP_EXT_QOS_SIG_IND_MASK                0x10
522 #define GTP_EXT_QOS_SRC_STAT_DESC_MASK          0x0F
523
524 /* Definition of Radio Priority's masks */
525 #define GTPv1_EXT_RP_NSAPI_MASK         0xF0
526 #define GTPv1_EXT_RP_SPARE_MASK         0x08
527 #define GTPv1_EXT_RP_MASK               0x07
528
529 static const value_string gtp_message_type[] = {
530     {GTP_MSG_UNKNOWN,             "For future use"},
531     {GTP_MSG_ECHO_REQ,            "Echo request"},
532     {GTP_MSG_ECHO_RESP,           "Echo response"},
533     {GTP_MSG_VER_NOT_SUPP,        "Version not supported"},
534     {GTP_MSG_NODE_ALIVE_REQ,      "Node alive request"},
535     {GTP_MSG_NODE_ALIVE_RESP,     "Node alive response"},
536     {GTP_MSG_REDIR_REQ,           "Redirection request"},
537     {GTP_MSG_REDIR_RESP,          "Redirection response"},
538     /*
539      * 8-15 For future use. Shall not be sent. If received,
540      * shall be treated as an Unknown message.
541      */
542 #if 0
543     {   8,                              "Unknown message(For future use)"},
544     {   9,                              "Unknown message(For future use)"},
545     {  10,                              "Unknown message(For future use)"},
546     {  11,                              "Unknown message(For future use)"},
547     {  12,                              "Unknown message(For future use)"},
548     {  13,                              "Unknown message(For future use)"},
549     {  14,                              "Unknown message(For future use)"},
550     {  15,                              "Unknown message(For future use)"},
551 #endif
552     {GTP_MSG_CREATE_PDP_REQ,            "Create PDP context request"},
553     {GTP_MSG_CREATE_PDP_RESP,           "Create PDP context response"},
554     {GTP_MSG_UPDATE_PDP_REQ,            "Update PDP context request"},
555     {GTP_MSG_UPDATE_PDP_RESP,           "Update PDP context response"},
556     {GTP_MSG_DELETE_PDP_REQ,            "Delete PDP context request"},
557     {GTP_MSG_DELETE_PDP_RESP,           "Delete PDP context response"},
558     {GTP_MSG_INIT_PDP_CONTEXT_ACT_REQ,  "Initiate PDP Context Activation Request"},
559     {GTP_MSG_INIT_PDP_CONTEXT_ACT_RESP, "Initiate PDP Context Activation Response"},
560 /*
561  * 24-25 For future use. Shall not be sent. If received,
562  * shall be treated as an Unknown message.
563  */
564     {GTP_MSG_DELETE_AA_PDP_REQ,   "Delete AA PDP Context Request"},
565     {GTP_MSG_DELETE_AA_PDP_RESP,  "Delete AA PDP Context Response"},
566     {GTP_MSG_ERR_IND,             "Error indication"},
567     {GTP_MSG_PDU_NOTIFY_REQ,      "PDU notification request"},
568     {GTP_MSG_PDU_NOTIFY_RESP,     "PDU notification response"},
569     {GTP_MSG_PDU_NOTIFY_REJ_REQ,  "PDU notification reject request"},
570     {GTP_MSG_PDU_NOTIFY_REJ_RESP, "PDU notification reject response"},
571     {GTP_MSG_SUPP_EXT_HDR,        "Supported extension header notification"},
572     {GTP_MSG_SEND_ROUT_INFO_REQ,  "Send routing information for GPRS request"},
573     {GTP_MSG_SEND_ROUT_INFO_RESP, "Send routing information for GPRS response"},
574     {GTP_MSG_FAIL_REP_REQ,        "Failure report request"},
575     {GTP_MSG_FAIL_REP_RESP,       "Failure report response"},
576     {GTP_MSG_MS_PRESENT_REQ,      "Note MS GPRS present request"},
577     {GTP_MSG_MS_PRESENT_RESP,     "Note MS GPRS present response"},
578     /* 38-47 For future use. Shall not be sent. If received,
579      * shall be treated as an Unknown message.
580      */
581 #if 0
582     {  38,                        "Unknown message(For future use)"},
583     {  39,                        "Unknown message(For future use)"},
584     {  40,                        "Unknown message(For future use)"},
585     {  41,                        "Unknown message(For future use)"},
586     {  42,                        "Unknown message(For future use)"},
587     {  43,                        "Unknown message(For future use)"},
588     {  44,                        "Unknown message(For future use)"},
589     {  45,                        "Unknown message(For future use)"},
590     {  46,                        "Unknown message(For future use)"},
591     {  47,                        "Unknown message(For future use)"},
592 #endif
593     {GTP_MSG_IDENT_REQ,           "Identification request"},
594     {GTP_MSG_IDENT_RESP,          "Identification response"},
595     {GTP_MSG_SGSN_CNTXT_REQ,      "SGSN context request"},
596     {GTP_MSG_SGSN_CNTXT_RESP,     "SGSN context response"},
597     {GTP_MSG_SGSN_CNTXT_ACK,      "SGSN context acknowledgement"},
598     {GTP_MSG_FORW_RELOC_REQ,      "Forward relocation request"},
599     {GTP_MSG_FORW_RELOC_RESP,     "Forward relocation response"},
600     {GTP_MSG_FORW_RELOC_COMP,     "Forward relocation complete"},
601     {GTP_MSG_RELOC_CANCEL_REQ,    "Relocation cancel request"},
602     {GTP_MSG_RELOC_CANCEL_RESP,   "Relocation cancel response"},
603     {GTP_MSG_FORW_SRNS_CNTXT,     "Forward SRNS context"},
604     {GTP_MSG_FORW_RELOC_ACK,      "Forward relocation complete acknowledge"},
605     {GTP_MSG_FORW_SRNS_CNTXT_ACK, "Forward SRNS context acknowledge"},
606     /* 61-69 For future use. Shall not be sent. If received,
607      * shall be treated as an Unknown message.
608      */
609 #if 0
610     {  61,                        "Unknown message(For future use)"},
611     {  62,                        "Unknown message(For future use)"},
612     {  63,                        "Unknown message(For future use)"},
613     {  64,                        "Unknown message(For future use)"},
614     {  65,                        "Unknown message(For future use)"},
615     {  66,                        "Unknown message(For future use)"},
616     {  67,                        "Unknown message(For future use)"},
617     {  68,                        "Unknown message(For future use)"},
618     {  69,                        "Unknown message(For future use)"},
619 #endif
620     {GTP_MSG_RAN_INFO_RELAY,      "RAN Information Relay"},
621     /* 71-95 For future use. Shall not be sent. If received,
622      * shall be treated as an Unknown message.
623      */
624 #if 0
625     {  71,                        "Unknown message(For future use)"},
626     {  72,                        "Unknown message(For future use)"},
627     {  73,                        "Unknown message(For future use)"},
628     {  74,                        "Unknown message(For future use)"},
629     {  75,                        "Unknown message(For future use)"},
630     {  76,                        "Unknown message(For future use)"},
631     {  77,                        "Unknown message(For future use)"},
632     {  78,                        "Unknown message(For future use)"},
633     {  79,                        "Unknown message(For future use)"},
634     {  80,                        "Unknown message(For future use)"},
635     {  81,                        "Unknown message(For future use)"},
636     {  82,                        "Unknown message(For future use)"},
637     {  83,                        "Unknown message(For future use)"},
638     {  84,                        "Unknown message(For future use)"},
639     {  85,                        "Unknown message(For future use)"},
640     {  86,                        "Unknown message(For future use)"},
641     {  87,                        "Unknown message(For future use)"},
642     {  88,                        "Unknown message(For future use)"},
643     {  89,                        "Unknown message(For future use)"},
644     {  90,                        "Unknown message(For future use)"},
645     {  91,                        "Unknown message(For future use)"},
646     {  92,                        "Unknown message(For future use)"},
647     {  93,                        "Unknown message(For future use)"},
648     {  94,                        "Unknown message(For future use)"},
649     {  95,                        "Unknown message(For future use)"},
650 #endif
651     {GTP_MBMS_NOTIFY_REQ,         "MBMS Notification Request"},
652     {GTP_MBMS_NOTIFY_RES,         "MBMS Notification Response"},
653     {GTP_MBMS_NOTIFY_REJ_REQ,     "MBMS Notification Reject Request"},
654     {GTP_MBMS_NOTIFY_REJ_RES,     "MBMS Notification Reject Response"},
655     {GTP_CREATE_MBMS_CNTXT_REQ,   "Create MBMS Context Request"},
656     {GTP_CREATE_MBMS_CNTXT_RES,   "Create MBMS Context Response"},
657     {GTP_UPD_MBMS_CNTXT_REQ,      "Update MBMS Context Request"},
658     {GTP_UPD_MBMS_CNTXT_RES,      "Update MBMS Context Response"},
659     {GTP_DEL_MBMS_CNTXT_REQ,      "Delete MBMS Context Request"},
660     {GTP_DEL_MBMS_CNTXT_RES,      "Delete MBMS Context Response"},
661     /* 106 - 111 For future use. Shall not be sent. If received,
662      * shall be treated as an Unknown message.
663      */
664 #if 0
665     {  106,                       "Unknown message(For future use)"},
666     {  107,                       "Unknown message(For future use)"},
667     {  108,                       "Unknown message(For future use)"},
668     {  109,                       "Unknown message(For future use)"},
669     {  110,                       "Unknown message(For future use)"},
670     {  111,                       "Unknown message(For future use)"},
671 #endif
672     {GTP_MBMS_REG_REQ,            "MBMS Registration Request"},
673     {GTP_MBMS_REG_RES,            "MBMS Registration Response"},
674     {GTP_MBMS_DE_REG_REQ,         "MBMS De-Registration Request"},
675     {GTP_MBMS_DE_REG_RES,         "MBMS De-Registration Response"},
676     {GTP_MBMS_SES_START_REQ,      "MBMS Session Start Request"},
677     {GTP_MBMS_SES_START_RES,      "MBMS Session Start Response"},
678     {GTP_MBMS_SES_STOP_REQ,       "MBMS Session Stop Request"},
679     {GTP_MBMS_SES_STOP_RES,       "MBMS Session Stop Response"},
680     {GTP_MBMS_SES_UPD_REQ,        "MBMS Session Update Request"},
681     {GTP_MBMS_SES_UPD_RES,        "MBMS Session Update Response"},
682     /* 122-127 For future use. Shall not be sent.
683      * If received, shall be treated as an Unknown message.
684      */
685 #if 0
686     {  122,                       "Unknown message(For future use)"},
687     {  123,                       "Unknown message(For future use)"},
688     {  124,                       "Unknown message(For future use)"},
689     {  125,                       "Unknown message(For future use)"},
690     {  126,                       "Unknown message(For future use)"},
691     {  127,                       "Unknown message(For future use)"},
692 #endif
693     {GTP_MS_INFO_CNG_NOT_REQ,     "MS Info Change Notification Request"},
694     {GTP_MS_INFO_CNG_NOT_RES,     "MS Info Change Notification Response"},
695     /* 130-239 For future use. Shall not be sent. If received,
696      * shall be treated as an Unknown message.
697      */
698 #if 0
699     {  130,                       "Unknown message(For future use)"},
700     {  131,                       "Unknown message(For future use)"},
701     {  132,                       "Unknown message(For future use)"},
702     {  133,                       "Unknown message(For future use)"},
703     {  134,                       "Unknown message(For future use)"},
704     {  135,                       "Unknown message(For future use)"},
705     {  136,                       "Unknown message(For future use)"},
706     {  137,                       "Unknown message(For future use)"},
707     {  138,                       "Unknown message(For future use)"},
708     {  139,                       "Unknown message(For future use)"},
709     {  140,                       "Unknown message(For future use)"},
710     {  141,                       "Unknown message(For future use)"},
711     {  142,                       "Unknown message(For future use)"},
712     {  143,                       "Unknown message(For future use)"},
713     {  144,                       "Unknown message(For future use)"},
714     {  145,                       "Unknown message(For future use)"},
715     {  146,                       "Unknown message(For future use)"},
716     {  147,                       "Unknown message(For future use)"},
717     {  148,                       "Unknown message(For future use)"},
718     {  149,                       "Unknown message(For future use)"},
719     {  150,                       "Unknown message(For future use)"},
720     {  151,                       "Unknown message(For future use)"},
721     {  152,                       "Unknown message(For future use)"},
722     {  153,                       "Unknown message(For future use)"},
723     {  154,                       "Unknown message(For future use)"},
724     {  155,                       "Unknown message(For future use)"},
725     {  156,                       "Unknown message(For future use)"},
726     {  157,                       "Unknown message(For future use)"},
727     {  158,                       "Unknown message(For future use)"},
728     {  159,                       "Unknown message(For future use)"},
729 #endif
730     {GTP_MSG_DATA_TRANSF_REQ,     "Data record transfer request"},
731     {GTP_MSG_DATA_TRANSF_RESP,    "Data record transfer response"},
732     /* 242-253 For future use. Shall not be sent. If received,
733      * shall be treated as an Unknown message.
734      */
735 #if 0
736     {  242,                       "Unknown message(For future use)"},
737     {  243,                       "Unknown message(For future use)"},
738     {  244,                       "Unknown message(For future use)"},
739     {  245,                       "Unknown message(For future use)"},
740     {  246,                       "Unknown message(For future use)"},
741     {  247,                       "Unknown message(For future use)"},
742     {  248,                       "Unknown message(For future use)"},
743     {  249,                       "Unknown message(For future use)"},
744     {  250,                       "Unknown message(For future use)"},
745     {  251,                       "Unknown message(For future use)"},
746     {  252,                       "Unknown message(For future use)"},
747     {  253,                       "Unknown message(For future use)"},
748 #endif
749     {GTP_MSG_END_MARKER,          "End Marker"},
750     {GTP_MSG_TPDU,                "T-PDU"},
751     {0, NULL}
752 };
753 static value_string_ext gtp_message_type_ext = VALUE_STRING_EXT_INIT(gtp_message_type);
754
755 /* definitions of fields in extension header */
756 #define GTP_EXT_CAUSE                 0x01
757 #define GTP_EXT_IMSI                  0x02
758 #define GTP_EXT_RAI                   0x03
759 #define GTP_EXT_TLLI                  0x04
760 #define GTP_EXT_PTMSI                 0x05
761 #define GTP_EXT_QOS_GPRS              0x06
762 #define GTP_EXT_REORDER               0x08
763 #define GTP_EXT_AUTH_TRI              0x09
764 #define GTP_EXT_MAP_CAUSE             0x0B
765 #define GTP_EXT_PTMSI_SIG             0x0C
766 #define GTP_EXT_MS_VALID              0x0D
767 #define GTP_EXT_RECOVER               0x0E
768 #define GTP_EXT_SEL_MODE              0x0F
769
770 #define GTP_EXT_16                    0x10
771 #define GTP_EXT_FLOW_LABEL            0x10
772 #define GTP_EXT_TEID                  0x10    /* 0xFF10 3G */
773
774 #define GTP_EXT_17                    0x11
775 #define GTP_EXT_FLOW_SIG              0x11
776 #define GTP_EXT_TEID_CP               0x11    /* 0xFF11 3G */
777
778 #define GTP_EXT_18                    0x12
779 #define GTP_EXT_FLOW_II               0x12
780 #define GTP_EXT_TEID_II               0x12    /* 0xFF12 3G */
781
782 #define GTP_EXT_19                    0x13    /* 19 TV Teardown Ind 7.7.16 */
783 #define GTP_EXT_MS_REASON             0x13    /* same as 0x1D GTPv1_EXT_MS_REASON */
784 #define GTP_EXT_TEAR_IND              0x13    /* 0xFF13 3G */
785
786 #define GTP_EXT_NSAPI                 0x14    /* 3G */
787 #define GTP_EXT_RANAP_CAUSE           0x15    /* 3G */
788 #define GTP_EXT_RAB_CNTXT             0x16    /* 3G */
789 #define GTP_EXT_RP_SMS                0x17    /* 3G */
790 #define GTP_EXT_RP                    0x18    /* 3G */
791 #define GTP_EXT_PKT_FLOW_ID           0x19    /* 3G */
792 #define GTP_EXT_CHRG_CHAR             0x1A    /* 3G */
793 #define GTP_EXT_TRACE_REF             0x1B    /* 3G */
794 #define GTP_EXT_TRACE_TYPE            0x1C    /* 3G */
795 #define GTPv1_EXT_MS_REASON           0x1D    /* 3G 29 TV MS Not Reachable Reason 7.7.25A */
796 /* 117-126 Reserved for the GPRS charging protocol (see GTP' in 3GPP TS 32.295 [33]) */
797 #define GTP_EXT_TR_COMM               0x7E    /* charging */
798 #define GTP_EXT_CHRG_ID               0x7F    /* 127 TV Charging ID 7.7.26 */
799 #define GTP_EXT_USER_ADDR             0x80
800 #define GTP_EXT_MM_CNTXT              0x81
801 #define GTP_EXT_PDP_CNTXT             0x82
802 #define GTP_EXT_APN                   0x83
803 #define GTP_EXT_PROTO_CONF            0x84
804 #define GTP_EXT_GSN_ADDR              0x85
805 #define GTP_EXT_MSISDN                0x86
806 #define GTP_EXT_QOS_UMTS              0x87    /* 3G */
807 #define GTP_EXT_AUTH_QUI              0x88    /* 3G */
808 #define GTP_EXT_TFT                   0x89    /* 3G */
809 #define GTP_EXT_TARGET_ID             0x8A    /* 3G */
810 #define GTP_EXT_UTRAN_CONT            0x8B    /* 3G */
811 #define GTP_EXT_RAB_SETUP             0x8C    /* 3G */
812 #define GTP_EXT_HDR_LIST              0x8D    /* 3G */
813 #define GTP_EXT_TRIGGER_ID            0x8E    /* 3G   142 7.7.41 */
814 #define GTP_EXT_OMC_ID                0x8F    /* 3G   143 TLV OMC Identity 7.7.42 */
815 #define GTP_EXT_RAN_TR_CONT           0x90    /* 3G   144 TLV RAN Transparent Container 7.7.43 */
816 #define GTP_EXT_PDP_CONT_PRIO         0x91    /* 3G   145 TLV PDP Context Prioritization 7.7.45 */
817 #define GTP_EXT_ADD_RAB_SETUP_INF     0x92    /* 3G   146 TLV Additional RAB Setup Information 7.7.45A */
818 #define GTP_EXT_SSGN_NO               0x93    /* 3G   147 TLV SGSN Number 7.7.47 */
819 #define GTP_EXT_COMMON_FLGS           0x94    /* 3G   148 TLV Common Flags 7.7.48 */
820 #define GTP_EXT_APN_RES               0x95    /* 3G   149 */
821 #define GTP_EXT_RA_PRIO_LCS           0x96    /* 3G   150 TLV Radio Priority LCS 7.7.25B */
822 #define GTP_EXT_RAT_TYPE              0x97    /* 3G   151 TLV RAT Type 7.7.50 */
823 #define GTP_EXT_USR_LOC_INF           0x98    /* 3G   152 TLV User Location Information 7.7.51 */
824 #define GTP_EXT_MS_TIME_ZONE          0x99    /* 3G   153 TLV MS Time Zone 7.7.52 */
825 #define GTP_EXT_IMEISV                0x9A    /* 3G   154 TLV IMEI(SV) 7.7.53 */
826 #define GTP_EXT_CAMEL_CHG_INF_CON     0x9B    /* 3G   155 TLV CAMEL Charging Information Container 7.7.54 */
827 #define GTP_EXT_MBMS_UE_CTX           0x9C    /* 3G   156 TLV MBMS UE Context 7.7.55 */
828 #define GTP_EXT_TMGI                  0x9D    /* 3G   157 TLV Temporary Mobile Group Identity (TMGI) 7.7.56 */
829 #define GTP_EXT_RIM_RA                0x9E    /* 3G   158 TLV RIM Routing Address 7.7.57 */
830 #define GTP_EXT_MBMS_PROT_CONF_OPT    0x9F    /* 3G   159 TLV MBMS Protocol Configuration Options 7.7.58 */
831 #define GTP_EXT_MBMS_SA               0xA0    /* 3G   160 TLV MBMS Service Area 7.7.60 */
832 #define GTP_EXT_SRC_RNC_PDP_CTX_INF   0xA1    /* 3G   161 TLV Source RNC PDCP context info 7.7.61 */
833 #define GTP_EXT_ADD_TRS_INF           0xA2    /* 3G   162 TLV Additional Trace Info 7.7.62 */
834 #define GTP_EXT_HOP_COUNT             0xA3    /* 3G   163 TLV Hop Counter 7.7.63 */
835 #define GTP_EXT_SEL_PLMN_ID           0xA4    /* 3G   164 TLV Selected PLMN ID 7.7.64 */
836 #define GTP_EXT_MBMS_SES_ID           0xA5    /* 3G   165 TLV MBMS Session Identifier 7.7.65 */
837 #define GTP_EXT_MBMS_2G_3G_IND        0xA6    /* 3G   166 TLV MBMS 2G/3G Indicator 7.7.66 */
838 #define GTP_EXT_ENH_NSAPI             0xA7    /* 3G   167 TLV Enhanced NSAPI 7.7.67 */
839 #define GTP_EXT_MBMS_SES_DUR          0xA8    /* 3G   168 TLV MBMS Session Duration 7.7.59 */
840 #define GTP_EXT_ADD_MBMS_TRS_INF      0xA9    /* 3G   169 TLV Additional MBMS Trace Info 7.7.68 */
841 #define GTP_EXT_MBMS_SES_ID_REP_NO    0xAA    /* 3G   170 TLV MBMS Session Identity Repetition Number 7.7.69 */
842 #define GTP_EXT_MBMS_TIME_TO_DATA_TR  0xAB    /* 3G   171 TLV MBMS Time To Data Transfer 7.7.70 */
843 #define GTP_EXT_PS_HO_REQ_CTX         0xAC    /* 3G   172 TLV PS Handover Request Context 7.7.71 */
844 #define GTP_EXT_BSS_CONT              0xAD    /* 3G   173 TLV BSS Container 7.7.72 */
845 #define GTP_EXT_CELL_ID               0xAE    /* 3G   174 TLV Cell Identification 7.7.73 */
846 #define GTP_EXT_PDU_NO                0xAF    /* 3G   175 TLV PDU Numbers                               7.7.74 */
847 #define GTP_EXT_BSSGP_CAUSE           0xB0    /* 3G   176 TLV BSSGP Cause                               7.7.75 */
848 #define GTP_EXT_REQ_MBMS_BEARER_CAP   0xB1    /* 3G   177 TLV Required MBMS bearer capabilities         7.7.76 */
849 #define GTP_EXT_RIM_ROUTING_ADDR_DISC 0xB2    /* 3G   178 TLV RIM Routing Address Discriminator         7.7.77 */
850 #define GTP_EXT_LIST_OF_SETUP_PFCS    0xB3    /* 3G   179 TLV List of set-up PFCs                       7.7.78 */
851 #define GTP_EXT_PS_HANDOVER_XIP_PAR   0xB4    /* 3G   180 TLV PS Handover XID Parameters                7.7.79 */
852 #define GTP_EXT_MS_INF_CHG_REP_ACT    0xB5    /* 3G   181 TLV MS Info Change Reporting Action           7.7.80 */
853 #define GTP_EXT_DIRECT_TUNNEL_FLGS    0xB6    /* 3G   182 TLV Direct Tunnel Flags                       7.7.81 */
854 #define GTP_EXT_CORRELATION_ID        0xB7    /* 3G   183 TLV Correlation-ID                            7.7.82 */
855 #define GTP_EXT_BEARER_CONTROL_MODE   0xB8    /* 3G   184 TLV Bearer Control Mode                       7.7.83 */
856 #define GTP_EXT_MBMS_FLOW_ID          0xB9    /* 3G   185 TLV MBMS Flow Identifier                      7.7.84 */
857 #define GTP_EXT_MBMS_IP_MCAST_DIST    0xBA    /* 3G   186 TLV MBMS IP Multicast Distribution            7.7.85 */
858 #define GTP_EXT_MBMS_DIST_ACK         0xBB    /* 3G   187 TLV MBMS Distribution Acknowledgement         7.7.86 */
859 #define GTP_EXT_RELIABLE_IRAT_HO_INF  0xBC    /* 3G   188 TLV Reliable INTER RAT HANDOVER INFO          7.7.87 */
860 #define GTP_EXT_RFSP_INDEX            0xBD    /* 3G   189 TLV RFSP Index                                7.7.88 */
861 #define GTP_EXT_FQDN                  0xBE    /* 3G   190 TLV Fully Qualified Domain Name (FQDN)        7.7.90 */
862 #define GTP_EXT_EVO_ALLO_RETE_P1      0xBF    /* 3G   191 TLV Evolved Allocation/Retention Priority I   7.7.91 */
863 #define GTP_EXT_EVO_ALLO_RETE_P2      0xC0    /* 3G   192 TLV Evolved Allocation/Retention Priority II  7.7.92 */
864 #define GTP_EXT_EXTENDED_COMMON_FLGS  0xC1    /* 3G   193 TLV Extended Common Flags                     7.7.93 */
865 #define GTP_EXT_UCI                   0xC2    /* 3G   194 TLV User CSG Information (UCI)                7.7.94 */
866 #define GTP_EXT_CSG_INF_REP_ACT       0xC3    /* 3G   195 TLV CSG Information Reporting Action          7.7.95 */
867 #define GTP_EXT_CSG_ID                0xC4    /* 3G   196 TLV CSG ID                                    7.7.96 */
868 #define GTP_EXT_CMI                   0xC5    /* 3G   197 TLV CSG Membership Indication (CMI)           7.7.97 */
869 #define GTP_EXT_AMBR                  0xC6    /* 3G   198 TLV Aggregate Maximum Bit Rate (AMBR)         7.7.98 */
870 #define GTP_EXT_UE_NETWORK_CAP        0xC7    /* 3G   199 TLV UE Network Capability                     7.7.99 */
871 #define GTP_EXT_UE_AMBR               0xC8    /* 3G   200 TLV UE-AMBR                                   7.7.100 */
872 #define GTP_EXT_APN_AMBR_WITH_NSAPI   0xC9    /* 3G   201 TLV APN-AMBR with NSAPI                       7.7.101 */
873 #define GTP_EXT_GGSN_BACK_OFF_TIME    0xCA    /* 3G   202 TLV GGSN Back-Off Time                        7.7.102 */
874 #define GTP_EXT_SIG_PRI_IND           0xCB    /* 3G   203 TLV Signalling Priority Indication            7.7.103 */
875 #define GTP_EXT_SIG_PRI_IND_W_NSAPI   0xCC    /* 3G   204 TLV Signalling Priority Indication with NSAPI 7.7.104 */
876 #define GTP_EXT_HIGHER_BR_16MB_FLG    0xCD    /* 3G   205 TLV Higher bitrates than 16 Mbps flag         7.7.105 */
877 #define GTP_EXT_MAX_MBR_APN_AMBR      0xCE    /* 3G   206 TLV Max MBR/APN-AMBR                          7.7.106 */
878 #define GTP_EXT_ADD_MM_CTX_SRVCC      0xCF    /* 3G   207 TLV Additional MM context for SRVCC           7.7.107 */
879 #define GTP_EXT_ADD_FLGS_SRVCC        0xD0    /* 3G   208 TLV Additional flags for SRVCC                7.7.108 */
880 #define GTP_EXT_STN_SR                0xD1    /* 3G   209 TLV STN-SR                                    7.7.109 */
881 #define GTP_EXT_C_MSISDN              0xD2    /* 3G   210 TLV C-MSISDN                                  7.7.110 */
882 #define GTP_EXT_EXT_RANAP_CAUSE       0xD3    /* 3G   211 TLV Extended RANAP Cause                      7.7.111 */
883 #define GTP_EXT_ENODEB_ID             0xD4    /* 3G   212 TLV eNodeB ID                                 7.7.112 */
884 #define GTP_EXT_SEL_MODE_W_NSAPI      0xD5    /* 3G   213 TLV Selection Mode with NSAPI                 7.7.113 */
885 #define GTP_EXT_ULI_TIMESTAMP         0xD6    /* 3G   214 TLV ULI Timestamp                             7.7.114 */
886 #define GTP_EXT_LHN_ID_W_SAPI         0xD7    /* 3G   215 TLV Local Home Network ID (LHN-ID) with NSAPI 7.7.115 */
887 #define GTP_EXT_CN_OP_SEL_ENTITY      0xD8    /* 3G   216 TLV CN Operator Selection Entity              7.7.116 */
888 #define GTP_EXT_UE_USAGE_TYPE         0xD9    /* 3G   217 TLV UE Usage Type                             7.7.117 */
889 #define GTP_EXT_EXT_COMMON_FLGS_II    0xDA    /* 3G   218 TLV Extended Common Flags II                  7.7.118 */
890 #define GTP_EXT_NODE_IDENTIFIER       0xDB    /* 3G   219 TLV Node Identifier                           7.7.119 */
891 #define GTP_EXT_CIOT_OPT_SUP_IND      0xDC    /* 3G   220 TLV CIoT Optimizations Support Indication     7.7.120 */
892 #define GTP_EXT_SCEF_PDN_CONNECTION   0xDD    /* 3G   221 TLV SCEF PDN Connection                       7.7.121 */
893
894
895 /*  222-238 TLV Spare. For future use.     */
896
897 /* 239-250  Reserved for the GPRS charging protocol (see GTP' in 3GPP TS 32.295 [33])*/
898
899 #define GTP_EXT_C1                    0xC1
900 #define GTP_EXT_C2                    0xC2
901 #define GTP_EXT_REL_PACK              0xF9    /* charging */
902 #define GTP_EXT_CAN_PACK              0xFA    /* charging */
903 #define GTP_EXT_CHRG_ADDR             0xFB    /* 3G   251     TLV     Charging Gateway Address        7.7.44 */
904 /* 252-254  Reserved for the GPRS charging protocol (see GTP' in 3GPP TS 32.295 [33])*/
905 #define GTP_EXT_DATA_REQ              0xFC    /* charging */
906 #define GTP_EXT_DATA_RESP             0xFD    /* charging */
907 #define GTP_EXT_NODE_ADDR             0xFE    /* charging */
908 #define GTP_EXT_PRIV_EXT              0xFF
909
910 static const value_string gtp_val[] = {
911     {GTP_EXT_CAUSE,                 "Cause of operation"},
912     {GTP_EXT_IMSI,                  "IMSI"},
913     {GTP_EXT_RAI,                   "Routing Area Identity"},
914     {GTP_EXT_TLLI,                  "Temporary Logical Link Identity"},
915     {GTP_EXT_PTMSI,                 "Packet TMSI"},
916 /*   6 */  {GTP_EXT_QOS_GPRS,       "Quality of Service"},
917 /* 6-7 Spare */
918 /*   8 */  {GTP_EXT_REORDER,        "Reorder required"},
919 /*   9 */  {GTP_EXT_AUTH_TRI,       "Authentication triplets"},
920 /* 10 Spare */
921 /*  11 */  {GTP_EXT_MAP_CAUSE,      "MAP cause"},
922 /*  12 */  {GTP_EXT_PTMSI_SIG,      "P-TMSI signature"},
923 /*  13 */  {GTP_EXT_MS_VALID,       "MS validated"},
924 /*  14 */  {GTP_EXT_RECOVER,        "Recovery"},
925 /*  15 */  {GTP_EXT_SEL_MODE,       "Selection mode"},
926
927 /*  16 */  {GTP_EXT_16,             "Flow label data I"},
928 /*  16 */  /* ??? {GTP_EXT_FLOW_LABEL,     "Flow label data I"}, */
929 /*  16 */  /* ??? {GTP_EXT_TEID,           "Tunnel Endpoint Identifier Data I"}, */   /* 3G */
930
931     {GTP_EXT_17,                    "Flow label signalling"},
932 /* ???    {GTP_EXT_FLOW_SIG,              "Flow label signalling"}, */
933 /* ???    {GTP_EXT_TEID_CP,               "Tunnel Endpoint Identifier Data Control Plane"}, */ /* 3G */
934
935     {GTP_EXT_18,                    "Flow label data II"},
936 /* ???    {GTP_EXT_FLOW_II,               "Flow label data II"}, */
937 /* ???    {GTP_EXT_TEID_II,               "Tunnel Endpoint Identifier Data II"}, */   /* 3G */
938
939     {GTP_EXT_19,                    "MS not reachable reason"},
940 /* ???    {GTP_EXT_MS_REASON,             "MS not reachable reason"}, */
941 /* ???    {GTP_EXT_TEAR_IND,              "Teardown ID"}, */ /* 3G */
942
943     {GTP_EXT_NSAPI,                 "NSAPI"},   /* 3G */
944     {GTP_EXT_RANAP_CAUSE,           "RANAP cause"},   /* 3G */
945     {GTP_EXT_RAB_CNTXT,             "RAB context"}, /* 3G */
946     {GTP_EXT_RP_SMS,                "Radio Priority for MO SMS"},  /* 3G */
947     {GTP_EXT_RP,                    "Radio Priority"}, /* 3G */
948     {GTP_EXT_PKT_FLOW_ID,           "Packet Flow ID"},    /* 3G */
949     {GTP_EXT_CHRG_CHAR,             "Charging characteristics"},    /* 3G */
950     {GTP_EXT_TRACE_REF,             "Trace references"},    /* 3G */
951     {GTP_EXT_TRACE_TYPE,            "Trace type"}, /* 3G */
952 /*  29 */  {GTPv1_EXT_MS_REASON,    "MS not reachable reason"},   /* 3G */
953 /* 117-126 Reserved for the GPRS charging protocol (see GTP' in 3GPP TS 32.295 [33]) */
954 /* 126 */  {GTP_EXT_TR_COMM,        "Packet transfer command"},   /* charging */
955 /* 127 */  {GTP_EXT_CHRG_ID,        "Charging ID"},
956     {GTP_EXT_USER_ADDR,             "End user address"},
957     {GTP_EXT_MM_CNTXT,              "MM context"},
958     {GTP_EXT_PDP_CNTXT,             "PDP context"},
959     {GTP_EXT_APN,                   "Access Point Name"},
960     {GTP_EXT_PROTO_CONF,            "Protocol configuration options"},
961     {GTP_EXT_GSN_ADDR,              "GSN address"},
962     {GTP_EXT_MSISDN,                "MS international PSTN/ISDN number"},
963     {GTP_EXT_QOS_UMTS,              "Quality of service (UMTS)"},    /* 3G */
964     {GTP_EXT_AUTH_QUI,              "Authentication quintuplets"},   /* 3G */
965     {GTP_EXT_TFT,                   "Traffic Flow Template (TFT)"},   /* 3G */
966     {GTP_EXT_TARGET_ID,             "Target (RNC) identification"}, /* 3G */
967     {GTP_EXT_UTRAN_CONT,            "UTRAN transparent field"},    /* 3G */
968     {GTP_EXT_RAB_SETUP,             "RAB setup information"},   /* 3G */
969     {GTP_EXT_HDR_LIST,              "Extension Header Types List"},  /* 3G */
970     {GTP_EXT_TRIGGER_ID,            "Trigger Id"}, /* 3G */
971     {GTP_EXT_OMC_ID,                "OMC Identity"},   /* 3G */
972
973     {GTP_EXT_RAN_TR_CONT,           "RAN Transparent Container"}, /* 7.7.43 */
974     {GTP_EXT_PDP_CONT_PRIO,         "PDP Context Prioritization"},  /* 7.7.45 */
975     {GTP_EXT_ADD_RAB_SETUP_INF,     "Additional RAB Setup Information"},    /* 7.7.45A */
976     {GTP_EXT_SSGN_NO,               "SGSN Number"},   /* 7.7.47 */
977     {GTP_EXT_COMMON_FLGS,           "Common Flags"},  /* 7.7.48 */
978     {GTP_EXT_APN_RES,               "APN Restriction"},   /* 3G */
979     {GTP_EXT_RA_PRIO_LCS,           "Radio Priority LCS"},    /* 7.7.25B */
980     {GTP_EXT_RAT_TYPE,              "RAT Type"}, /* 3G */
981     {GTP_EXT_USR_LOC_INF,           "User Location Information"}, /* 7.7.51 */
982     {GTP_EXT_MS_TIME_ZONE,          "MS Time Zone"}, /* 7.7.52 */
983
984     {GTP_EXT_IMEISV,                "IMEI(SV)"},   /* 3G */
985     {GTP_EXT_CAMEL_CHG_INF_CON,     "CAMEL Charging Information Container"},    /* 7.7.54 */
986     {GTP_EXT_MBMS_UE_CTX,           "MBMS UE Context"},   /* 7.7.55 */
987     {GTP_EXT_TMGI,                  "Temporary Mobile Group Identity (TMGI)"},   /* 7.7.56 */
988     {GTP_EXT_RIM_RA,                "RIM Routing Address"},    /* 7.7.57 */
989     {GTP_EXT_MBMS_PROT_CONF_OPT,    "MBMS Protocol Configuration Options"},    /* 7.7.58 */
990     {GTP_EXT_MBMS_SA,               "MBMS Service Area"}, /* 7.7.60 */
991     {GTP_EXT_SRC_RNC_PDP_CTX_INF,   "Source RNC PDCP context info"},  /* 7.7.61 */
992     {GTP_EXT_ADD_TRS_INF,           "Additional Trace Info"}, /* 7.7.62 */
993     {GTP_EXT_HOP_COUNT,             "Hop Counter"}, /* 7.7.63 */
994     {GTP_EXT_SEL_PLMN_ID,           "Selected PLMN ID"},  /* 7.7.64 */
995     {GTP_EXT_MBMS_SES_ID,           "MBMS Session Identifier"},   /* 7.7.65 */
996     {GTP_EXT_MBMS_2G_3G_IND,        "MBMS 2G/3G Indicator"},   /* 7.7.66 */
997     {GTP_EXT_ENH_NSAPI,             "Enhanced NSAPI"},  /* 7.7.67 */
998     {GTP_EXT_MBMS_SES_DUR,          "MBMS Session Duration"},    /* 7.7.59 */
999     {GTP_EXT_ADD_MBMS_TRS_INF,      "Additional MBMS Trace Info"},   /* 7.7.68 */
1000     {GTP_EXT_MBMS_SES_ID_REP_NO,    "MBMS Session Identity Repetition Number"},    /* 7.7.69 */
1001     {GTP_EXT_MBMS_TIME_TO_DATA_TR,  "MBMS Time To Data Transfer"},   /* 7.7.70 */
1002     {GTP_EXT_PS_HO_REQ_CTX,         "PS Handover Request Context"}, /* 7.7.71 */
1003     {GTP_EXT_BSS_CONT,              "BSS Container"},    /* 7.7.72 */
1004     {GTP_EXT_CELL_ID,               "Cell Identification"},   /* 7.7.73 */
1005     {GTP_EXT_PDU_NO,                "PDU Numbers"},    /* 7.7.74 */
1006     {GTP_EXT_BSSGP_CAUSE,           "BSSGP Cause"},   /* 7.7.75 */
1007     {GTP_EXT_REQ_MBMS_BEARER_CAP,   "Required MBMS bearer capabilities"}, /* 7.7.76 */
1008     {GTP_EXT_RIM_ROUTING_ADDR_DISC, "RIM Routing Address Discriminator"},   /* 7.7.77 */
1009     {GTP_EXT_LIST_OF_SETUP_PFCS,    "List of set-up PFCs"},    /* 7.7.78 */
1010 /* 180 */  {GTP_EXT_PS_HANDOVER_XIP_PAR, "  PS Handover XID Parameters"},                  /* 7.7.79 */
1011 /* 181 */  {GTP_EXT_MS_INF_CHG_REP_ACT,     "MS Info Change Reporting Action"},            /* 7.7.80 */
1012 /* 182 */  {GTP_EXT_DIRECT_TUNNEL_FLGS,     "Direct Tunnel Flags"},                        /* 7.7.81 */
1013 /* 183 */  {GTP_EXT_CORRELATION_ID,         "Correlation-ID"},                             /* 7.7.82 */
1014 /* 184 */  {GTP_EXT_BEARER_CONTROL_MODE,    "Bearer Control Mode"},                        /* 7.7.83 */
1015 /* 185 */  {GTP_EXT_MBMS_FLOW_ID,           "MBMS Flow Identifier"},                       /* 7.7.84 */
1016 /* 186 */  {GTP_EXT_MBMS_IP_MCAST_DIST,     "MBMS IP Multicast Distribution"},             /* 7.7.85 */
1017 /* 187 */  {GTP_EXT_MBMS_DIST_ACK,          "MBMS Distribution Acknowledgement"},          /* 7.7.86 */
1018 /* 188 */  {GTP_EXT_RELIABLE_IRAT_HO_INF,   "Reliable INTER RAT HANDOVER INFO"},           /* 7.7.87 */
1019 /* 189 */  {GTP_EXT_RFSP_INDEX,             "RFSP Index"},                                 /* 7.7.88 */
1020 /* 190 */  {GTP_EXT_FQDN,                   "Fully Qualified Domain Name (FQDN)"},         /* 7.7.90 */
1021 /* 191 */  {GTP_EXT_EVO_ALLO_RETE_P1,       "Evolved Allocation/Retention Priority I"},    /* 7.7.91 */
1022 /* 192 */  {GTP_EXT_EVO_ALLO_RETE_P2,       "Evolved Allocation/Retention Priority II"},   /* 7.7.92 */
1023 /* 193 */  {GTP_EXT_EXTENDED_COMMON_FLGS,   "Extended Common Flags"},                      /* 7.7.93 */
1024 /* 194 */  {GTP_EXT_UCI,                    "User CSG Information (UCI)"},                 /* 7.7.94 */
1025 /* 195 */  {GTP_EXT_CSG_INF_REP_ACT,        "CSG Information Reporting Action"},           /* 7.7.95 */
1026 /* 196 */  {GTP_EXT_CSG_ID,                 "CSG ID"},                                     /* 7.7.96 */
1027 /* 197 */  {GTP_EXT_CMI,                    "CSG Membership Indication (CMI)"},            /* 7.7.97 */
1028 /* 198 */  {GTP_EXT_AMBR,                   "Aggregate Maximum Bit Rate (AMBR)"},          /* 7.7.98 */
1029 /* 199 */  {GTP_EXT_UE_NETWORK_CAP,         "UE Network Capability"},                      /* 7.7.99 */
1030 /* 200 */  {GTP_EXT_UE_AMBR,                "UE-AMBR"},                                    /* 7.7.100 */
1031 /* 201 */  {GTP_EXT_APN_AMBR_WITH_NSAPI,    "APN-AMBR with NSAPI"},                        /* 7.7.101 */
1032 /* 202 */  {GTP_EXT_GGSN_BACK_OFF_TIME,     "GGSN Back-Off Time"},                         /* 7.7.102 */
1033 /* 203 */  {GTP_EXT_SIG_PRI_IND,            "Signalling Priority Indication"},             /* 7.7.103 */
1034 /* 204 */  {GTP_EXT_SIG_PRI_IND_W_NSAPI,    "Signalling Priority Indication with NSAPI"},  /* 7.7.104 */
1035 /* 205 */  {GTP_EXT_HIGHER_BR_16MB_FLG,     "Higher bitrates than 16 Mbps flag"},          /* 7.7.105 */
1036 /* 206 */  {GTP_EXT_MAX_MBR_APN_AMBR,       "Max MBR/APN-AMBR"},                           /* 7.7.106 */
1037 /* 207 */  {GTP_EXT_ADD_MM_CTX_SRVCC,       "Additional MM context for SRVCC"},            /* 7.7.107 */
1038 /* 208 */  {GTP_EXT_ADD_FLGS_SRVCC,         "Additional flags for SRVCC"},                 /* 7.7.108 */
1039 /* 209 */  {GTP_EXT_STN_SR,                 "STN-SR"},                                     /* 7.7.109 */
1040 /* 210 */  {GTP_EXT_C_MSISDN,               "C-MSISDN"},                                   /* 7.7.110 */
1041 /* 211 */  {GTP_EXT_EXT_RANAP_CAUSE,        "Extended RANAP Cause"},                       /* 7.7.111 */
1042 /* 212 */  {GTP_EXT_ENODEB_ID,              "eNodeB ID" },                                 /* 7.7.112 */
1043 /* 213 */  {GTP_EXT_SEL_MODE_W_NSAPI,       "Selection Mode with NSAPI" },                 /* 7.7.113 */
1044 /* 214 */  {GTP_EXT_ULI_TIMESTAMP,          "ULI Timestamp" },                             /* 7.7.114 */
1045 /* 215 */  {GTP_EXT_LHN_ID_W_SAPI,          "Local Home Network ID (LHN-ID) with NSAPI" }, /* 7.7.115 */
1046 /* 216 */  {GTP_EXT_CN_OP_SEL_ENTITY,       "Operator Selection Entity" },                 /* 7.7.116 */
1047 /* 217 */  {GTP_EXT_UE_USAGE_TYPE,          "UE Usage Type" },                             /* 7.7.117 */
1048 /* 218 */  {GTP_EXT_EXT_COMMON_FLGS_II,     "Extended Common Flags II"},                   /* 7.7.118 */
1049 /* 219 */  {GTP_EXT_NODE_IDENTIFIER,        "Node Identifier" },                           /* 7.7.119 */
1050 /* 220 */  {GTP_EXT_CIOT_OPT_SUP_IND,       "CIoT Optimizations Support Indication" },     /* 7.7.120 */
1051 /* 221 */  {GTP_EXT_SCEF_PDN_CONNECTION,    "SCEF PDN Connection" },                       /* 7.7.121 */
1052
1053
1054 /* 222-238 TLV Spare. For future use. */
1055 /* 239-250 Reserved for the GPRS charging protocol (see GTP' in 3GPP TS 32.295 [33]) */
1056 /* 249 */  {GTP_EXT_REL_PACK,  "Sequence numbers of released packets IE"},  /* charging */
1057 /* 250 */  {GTP_EXT_CAN_PACK,  "Sequence numbers of canceled packets IE"},  /* charging */
1058 /* 251 */  {GTP_EXT_CHRG_ADDR, "Charging Gateway address"},                 /* 7.7.44 */
1059 /* 252-254 Reserved for the GPRS charging protocol (see GTP' in 3GPP TS 32.295 [33]) */
1060 /* 252 */  {GTP_EXT_DATA_REQ,  "Data record packet"},                       /* charging */
1061 /* 253 */  {GTP_EXT_DATA_RESP, "Requests responded"},                       /* charging */
1062 /* 254 */  {GTP_EXT_NODE_ADDR, "Address of recommended node"},              /* charging */
1063 /* 255 */  {GTP_EXT_PRIV_EXT,  "Private Extension"},
1064     {0, NULL}
1065 };
1066 static value_string_ext gtp_val_ext = VALUE_STRING_EXT_INIT(gtp_val);
1067
1068 /* It seems like some IE's are renamed in gtpv1 at least reading
1069  * 3GPP TS 29.060 version 6.11.0 Release 6
1070  */
1071 static const value_string gtpv1_val[] = {
1072 /*   1 */  {GTP_EXT_CAUSE,                 "Cause of operation"},
1073 /*   2 */  {GTP_EXT_IMSI,                  "IMSI"},
1074 /*   3 */  {GTP_EXT_RAI,                   "Routing Area Identity"},
1075 /*   4 */  {GTP_EXT_TLLI,                  "Temporary Logical Link Identity"},
1076 /*   5 */  {GTP_EXT_PTMSI,                 "Packet TMSI"},
1077 /*   6 */  {GTP_EXT_QOS_GPRS,              "Quality of Service"},
1078 /* 6-7 Spare */
1079 /*   7 */  {7,                             "Spare"},
1080 /*   8 */  {GTP_EXT_REORDER,               "Reorder required"},
1081 /*   9 */  {GTP_EXT_AUTH_TRI,              "Authentication triplets"},
1082 /* 10 Spare */
1083 /*  10 */  {10,                            "Spare"},
1084 /*  11 */  {GTP_EXT_MAP_CAUSE,             "MAP cause"},
1085 /*  12 */  {GTP_EXT_PTMSI_SIG,             "P-TMSI signature"},
1086 /*  13 */  {GTP_EXT_MS_VALID,              "MS validated"},
1087 /*  14 */  {GTP_EXT_RECOVER,               "Recovery"},
1088 /*  15 */  {GTP_EXT_SEL_MODE,              "Selection mode"},
1089 /*  16 */  {GTP_EXT_TEID,                  "Tunnel Endpoint Identifier Data I"},              /* 3G */
1090 /*  17 */  {GTP_EXT_TEID_CP,               "Tunnel Endpoint Identifier Data Control Plane"},  /* 3G */
1091 /*  18 */  {GTP_EXT_TEID_II,               "Tunnel Endpoint Identifier Data II"},             /* 3G */
1092 /*  19 */  {GTP_EXT_TEAR_IND,              "Teardown ID"},                                    /* 3G */
1093
1094 /*  20 */  {GTP_EXT_NSAPI,                 "NSAPI"},                                          /* 3G */
1095 /*  21 */  {GTP_EXT_RANAP_CAUSE,           "RANAP cause"},                                    /* 3G */
1096 /*  22 */  {GTP_EXT_RAB_CNTXT,             "RAB context"},                                    /* 3G */
1097 /*  23 */  {GTP_EXT_RP_SMS,                "Radio Priority for MO SMS"},                      /* 3G */
1098 /*  24 */  {GTP_EXT_RP,                    "Radio Priority"},                                 /* 3G */
1099 /*  25 */  {GTP_EXT_PKT_FLOW_ID,           "Packet Flow ID"},                                 /* 3G */
1100 /*  26 */  {GTP_EXT_CHRG_CHAR,             "Charging characteristics"},                       /* 3G */
1101 /*  27 */  {GTP_EXT_TRACE_REF,             "Trace references"},                               /* 3G */
1102 /*  28 */  {GTP_EXT_TRACE_TYPE,            "Trace type"},                                     /* 3G */
1103 /*  29 */  {GTPv1_EXT_MS_REASON,           "MS not reachable reason"},                        /* 3G */
1104 /* 117-126 Reserved for the GPRS charging protocol (see GTP' in 3GPP TS 32.295 [33]) */
1105 /* 126 */  {GTP_EXT_TR_COMM,               "Packet transfer command"},                        /* charging */
1106 /* 127 */  {GTP_EXT_CHRG_ID,               "Charging ID"},
1107
1108 /* 128 */  {GTP_EXT_USER_ADDR,             "End user address"},
1109 /* 129 */  {GTP_EXT_MM_CNTXT,              "MM context"},
1110 /* 130 */  {GTP_EXT_PDP_CNTXT,             "PDP context"},
1111 /* 131 */  {GTP_EXT_APN,                   "Access Point Name"},
1112 /* 132 */  {GTP_EXT_PROTO_CONF,            "Protocol configuration options"},
1113 /* 133 */  {GTP_EXT_GSN_ADDR,              "GSN address"},
1114 /* 134 */  {GTP_EXT_MSISDN,                "MS international PSTN/ISDN number"},
1115 /* 135 */  {GTP_EXT_QOS_UMTS,              "Quality of service (UMTS)"},                      /* 3G */
1116 /* 136 */  {GTP_EXT_AUTH_QUI,              "Authentication quintuplets"},                     /* 3G */
1117 /* 137 */  {GTP_EXT_TFT,                   "Traffic Flow Template (TFT)"},                    /* 3G */
1118 /* 138 */  {GTP_EXT_TARGET_ID,             "Target (RNC) identification"},                    /* 3G */
1119 /* 139 */  {GTP_EXT_UTRAN_CONT,            "UTRAN transparent field"},                        /* 3G */
1120 /* 140 */  {GTP_EXT_RAB_SETUP,             "RAB setup information"},                          /* 3G */
1121 /* 141 */  {GTP_EXT_HDR_LIST,              "Extension Header Types List"},                    /* 3G */
1122 /* 142 */  {GTP_EXT_TRIGGER_ID,            "Trigger Id"},                                     /* 3G */
1123 /* 143 */  {GTP_EXT_OMC_ID,                "OMC Identity"},                                   /* 3G */
1124 /* 144 */  {GTP_EXT_RAN_TR_CONT,           "RAN Transparent Container"},                      /* 7.7.43 */
1125 /* 145 */  {GTP_EXT_PDP_CONT_PRIO,         "PDP Context Prioritization"},                     /* 7.7.45 */
1126 /* 146 */  {GTP_EXT_ADD_RAB_SETUP_INF,     "Additional RAB Setup Information"},               /* 7.7.45A */
1127 /* 147 */  {GTP_EXT_SSGN_NO,               "SGSN Number"},                                    /* 7.7.47 */
1128 /* 148 */  {GTP_EXT_COMMON_FLGS,           "Common Flags"},                                   /* 7.7.48 */
1129 /* 149 */  {GTP_EXT_APN_RES,               "APN Restriction"},                                /* 3G */
1130 /* 150 */  {GTP_EXT_RA_PRIO_LCS,           "Radio Priority LCS"},                             /* 7.7.25B */
1131 /* 151 */  {GTP_EXT_RAT_TYPE,              "RAT Type"},                                       /* 3G */
1132 /* 152 */  {GTP_EXT_USR_LOC_INF,           "User Location Information"},                      /* 7.7.51 */
1133 /* 153 */  {GTP_EXT_MS_TIME_ZONE,          "MS Time Zone"},                                   /* 7.7.52 */
1134
1135 /* 154 */  {GTP_EXT_IMEISV,                "IMEI(SV)"},                                       /* 3G */
1136 /* 155 */  {GTP_EXT_CAMEL_CHG_INF_CON,     "CAMEL Charging Information Container"},           /* 7.7.54 */
1137 /* 156 */  {GTP_EXT_MBMS_UE_CTX,           "MBMS UE Context"},                                /* 7.7.55 */
1138 /* 157 */  {GTP_EXT_TMGI,                  "Temporary Mobile Group Identity (TMGI)"},         /* 7.7.56 */
1139 /* 158 */  {GTP_EXT_RIM_RA,                "RIM Routing Address"},                            /* 7.7.57 */
1140 /* 159 */  {GTP_EXT_MBMS_PROT_CONF_OPT,    "MBMS Protocol Configuration Options"},            /* 7.7.58 */
1141 /* 160 */  {GTP_EXT_MBMS_SA,               "MBMS Service Area"},                              /* 7.7.60 */
1142 /* 161 */  {GTP_EXT_SRC_RNC_PDP_CTX_INF,   "Source RNC PDCP context info"},                   /* 7.7.61 */
1143 /* 162 */  {GTP_EXT_ADD_TRS_INF,           "Additional Trace Info"},                          /* 7.7.62 */
1144 /* 163 */  {GTP_EXT_HOP_COUNT,             "Hop Counter"},                                    /* 7.7.63 */
1145 /* 164 */  {GTP_EXT_SEL_PLMN_ID,           "Selected PLMN ID"},                               /* 7.7.64 */
1146 /* 165 */  {GTP_EXT_MBMS_SES_ID,           "MBMS Session Identifier"},                        /* 7.7.65 */
1147 /* 166 */  {GTP_EXT_MBMS_2G_3G_IND,        "MBMS 2G/3G Indicator"},                           /* 7.7.66 */
1148 /* 167 */  {GTP_EXT_ENH_NSAPI,             "Enhanced NSAPI"},                                 /* 7.7.67 */
1149 /* 168 */  {GTP_EXT_MBMS_SES_DUR,          "MBMS Session Duration"},                          /* 7.7.59 */
1150 /* 169 */  {GTP_EXT_ADD_MBMS_TRS_INF,      "Additional MBMS Trace Info"},                     /* 7.7.68 */
1151 /* 170 */  {GTP_EXT_MBMS_SES_ID_REP_NO,    "MBMS Session Identity Repetition Number"},        /* 7.7.69 */
1152 /* 171 */  {GTP_EXT_MBMS_TIME_TO_DATA_TR,  "MBMS Time To Data Transfer"},                     /* 7.7.70 */
1153 /* 172 */  {GTP_EXT_PS_HO_REQ_CTX,         "PS Handover Request Context"},                    /* 7.7.71 */
1154 /* 173 */  {GTP_EXT_BSS_CONT,              "BSS Container"},                                  /* 7.7.72 */
1155 /* 174 */  {GTP_EXT_CELL_ID,               "Cell Identification"},                            /* 7.7.73 */
1156 /* 175 */  {GTP_EXT_PDU_NO,                "PDU Numbers"},                                    /* 7.7.74 */
1157 /* 176 */  {GTP_EXT_BSSGP_CAUSE,           "BSSGP Cause"},                                    /* 7.7.75 */
1158
1159 /* 177 */  {GTP_EXT_REQ_MBMS_BEARER_CAP,   "Required MBMS bearer capabilities"},              /* 7.7.76 */
1160 /* 178 */  {GTP_EXT_RIM_ROUTING_ADDR_DISC, "RIM Routing Address Discriminator"},              /* 7.7.77 */
1161 /* 179 */  {GTP_EXT_LIST_OF_SETUP_PFCS,    "List of set-up PFCs"},                            /* 7.7.78 */
1162 /* 180 */  {GTP_EXT_PS_HANDOVER_XIP_PAR,   "PS Handover XID Parameters"},                     /* 7.7.79 */
1163 /* 181 */  {GTP_EXT_MS_INF_CHG_REP_ACT,    "MS Info Change Reporting Action"},                /* 7.7.80 */
1164 /* 182 */  {GTP_EXT_DIRECT_TUNNEL_FLGS,    "Direct Tunnel Flags"},                            /* 7.7.81 */
1165 /* 183 */  {GTP_EXT_CORRELATION_ID,        "Correlation-ID"},                                 /* 7.7.82 */
1166 /* 184 */  {GTP_EXT_BEARER_CONTROL_MODE,   "Bearer Control Mode"},                            /* 7.7.83 */
1167 /* 185 */  {GTP_EXT_MBMS_FLOW_ID,          "MBMS Flow Identifier"},                           /* 7.7.84 */
1168 /* 186 */  {GTP_EXT_MBMS_IP_MCAST_DIST,    "MBMS IP Multicast Distribution"},                 /* 7.7.85 */
1169 /* 187 */  {GTP_EXT_MBMS_DIST_ACK,         "MBMS Distribution Acknowledgement"},              /* 7.7.86 */
1170 /* 188 */  {GTP_EXT_RELIABLE_IRAT_HO_INF,  "Reliable INTER RAT HANDOVER INFO"},               /* 7.7.87 */
1171 /* 190 */  {GTP_EXT_RFSP_INDEX,            "RFSP Index"},                                     /* 7.7.88 */
1172 /* 190 */  {GTP_EXT_FQDN,                  "Fully Qualified Domain Name (FQDN)"},             /* 7.7.90 */
1173 /* 191 */  {GTP_EXT_EVO_ALLO_RETE_P1,      "Evolved Allocation/Retention Priority I"},        /* 7.7.91 */
1174 /* 192 */  {GTP_EXT_EVO_ALLO_RETE_P2,      "Evolved Allocation/Retention Priority II"},       /* 7.7.92 */
1175 /* 193 */  {GTP_EXT_EXTENDED_COMMON_FLGS,  "Extended Common Flags"},                          /* 7.7.93 */
1176 /* 194 */  {GTP_EXT_UCI,                   "User CSG Information (UCI)"},                     /* 7.7.94 */
1177 /* 195 */  {GTP_EXT_CSG_INF_REP_ACT,       "CSG Information Reporting Action"},               /* 7.7.95 */
1178 /* 196 */  {GTP_EXT_CSG_ID,                "CSG ID"},                                         /* 7.7.96 */
1179 /* 197 */  {GTP_EXT_CMI,                   "CSG Membership Indication (CMI)"},                /* 7.7.97 */
1180 /* 198 */  {198,                           "Aggregate Maximum Bit Rate (AMBR)"},              /* 7.7.98 */
1181 /* 199 */  {199,                           "UE Network Capability"},                          /* 7.7.99 */
1182 /* 200 */  {200,                           "UE-AMBR"},                                        /* 7.7.100 */
1183 /* 201 */  {201,                           "APN-AMBR with NSAPI"},                            /* 7.7.101 */
1184 /* 202 */  {202,                           "GGSN Back-Off Time"},                             /* 7.7.102 */
1185 /* 203 */  {203,                           "Signalling Priority Indication"},                 /* 7.7.103 */
1186 /* 204 */  {204,                           "Signalling Priority Indication with NSAPI"},      /* 7.7.104 */
1187 /* 205 */  {205,                           "Higher bitrates than 16 Mbps flag"},              /* 7.7.105 */
1188 /* 206 */  {206,                           "Max MBR/APN-AMBR"},                               /* 7.7.106 */
1189 /* 207 */  {207,                           "Additional MM context for SRVCC"},                /* 7.7.107 */
1190 /* 208 */  {208,                           "Additional flags for SRVCC"},                     /* 7.7.108 */
1191 /* 209 */  {209,                           "STN-SR"},                                         /* 7.7.109 */
1192 /* 210 */  {210,                           "C-MSISDN"},                                       /* 7.7.110 */
1193 /* 211 */  {211,                           "Extended RANAP Cause"},                           /* 7.7.111 */
1194 /* 212 */  {GTP_EXT_ENODEB_ID,             "eNodeB ID" },                                     /* 7.7.112 */
1195 /* 213 */  {GTP_EXT_SEL_MODE_W_NSAPI,      "Selection Mode with NSAPI" },                     /* 7.7.113 */
1196 /* 214 */  {GTP_EXT_ULI_TIMESTAMP,         "ULI Timestamp" },                                 /* 7.7.114 */
1197 /* 215 */  {GTP_EXT_LHN_ID_W_SAPI,         "Local Home Network ID (LHN-ID) with NSAPI" },     /* 7.7.115 */
1198 /* 216 */  {GTP_EXT_CN_OP_SEL_ENTITY,      "Operator Selection Entity" },                     /* 7.7.116 */
1199 /* 217 */  {GTP_EXT_UE_USAGE_TYPE,         "UE Usage Type" },                                 /* 7.7.117 */
1200 /* 218 */  {GTP_EXT_EXT_COMMON_FLGS_II,    "Extended Common Flags II"},                       /* 7.7.118 */
1201 /* 219 */  {GTP_EXT_NODE_IDENTIFIER,       "Node Identifier" },                              /* 7.7.119 */
1202 /* 220 */  {GTP_EXT_CIOT_OPT_SUP_IND,      "CIoT Optimizations Support Indication" },        /* 7.7.120 */
1203 /* 221 */  {GTP_EXT_SCEF_PDN_CONNECTION,   "SCEF PDN Connection" },                          /* 7.7.121 */
1204
1205 /* 219-238 TLV Spare. For future use. */
1206 /* 239-250 Reserved for the GPRS charging protocol (see GTP' in 3GPP TS 32.295 [33]) */
1207 /* 249 */  {GTP_EXT_REL_PACK,              "Sequence numbers of released packets IE"},        /* charging */
1208 /* 250 */  {GTP_EXT_CAN_PACK,              "Sequence numbers of canceled packets IE"},        /* charging */
1209 /* 251 */  {GTP_EXT_CHRG_ADDR,             "Charging Gateway address"},                       /* 7.7.44 */
1210 /* 252-254 Reserved for the GPRS charging protocol (see GTP' in 3GPP TS 32.295 [33]) */
1211 /* 252 */  {GTP_EXT_DATA_REQ,              "Data record packet"},                             /* charging */
1212 /* 253 */  {GTP_EXT_DATA_RESP,             "Requests responded"},                             /* charging */
1213 /* 254 */  {GTP_EXT_NODE_ADDR,             "Address of recommended node"},                    /* charging */
1214 /* 255 */  {GTP_EXT_PRIV_EXT,              "Private Extension"},
1215
1216     {0, NULL}
1217 };
1218 static value_string_ext gtpv1_val_ext = VALUE_STRING_EXT_INIT(gtpv1_val);
1219
1220 /* GPRS:    9.60 v7.6.0, page 37
1221  * UMTS:    29.060 v4.0, page 45
1222  * ETSI TS 129 060 V9.4.0 (2010-10) Ch 7.7.1
1223  */
1224 static const value_string cause_type[] = {
1225     {  0, "Request IMSI"},
1226     {  1, "Request IMEI"},
1227     {  2, "Request IMSI and IMEI"},
1228     {  3, "No identity needed"},
1229     {  4, "MS refuses"},
1230     {  5, "MS is not GPRS responding"},
1231     {  6, "Reactivation Requested"},
1232     {  7, "PDP address inactivity timer expires"},
1233     /* For future use 8-48 */
1234     /* Cause values reserved for GPRS charging
1235      * protocol use (see GTP' in 3GPP TS 32.295 [33])
1236      * 49-63
1237      */
1238     { 59, "System failure"}, /* charging */
1239     { 60, "The transmit buffers are becoming full"}, /* charging */
1240     { 61, "The receive buffers are becoming full"},  /* charging */
1241     { 62, "Another node is about to go down"},       /* charging */
1242     { 63, "This node is about to go down"},          /* charging */
1243     /* For future use 64-127 */
1244     {128, "Request accepted"},
1245     {129, "New PDP type due to network preference"},
1246     {130, "New PDP type due to single address bearer only"},
1247     /* For future use 131-176 */
1248     /* Cause values reserved for GPRS charging
1249      * protocol use (see GTP' in 3GPP TS 32.295 [33])
1250      * 177-191
1251      */
1252     {177, "CDR decoding error"},
1253
1254     {192, "Non-existent"},
1255     {193, "Invalid message format"},
1256     {194, "IMSI not known"},
1257     {195, "MS is GPRS detached"},
1258     {196, "MS is not GPRS responding"},
1259     {197, "MS refuses"},
1260     {198, "Version not supported"},
1261     {199, "No resource available"},
1262     {200, "Service not supported"},
1263     {201, "Mandatory IE incorrect"},
1264     {202, "Mandatory IE missing"},
1265     {203, "Optional IE incorrect"},
1266     {204, "System failure"},
1267     {205, "Roaming restriction"},
1268     {206, "P-TMSI signature mismatch"},
1269     {207, "GPRS connection suspended"},
1270     {208, "Authentication failure"},
1271     {209, "User authentication failed"},
1272     {210, "Context not found"},
1273     {211, "All PDP dynamic addresses are occupied"},
1274     {212, "No memory is available"},
1275     {213, "Relocation failure"},
1276     {214, "Unknown mandatory extension header"},
1277     {215, "Semantic error in the TFT operation"},
1278     {216, "Syntactic error in the TFT operation"},
1279     {217, "Semantic errors in packet filter(s)"},
1280     {218, "Syntactic errors in packet filter(s)"},
1281     {219, "Missing or unknown APN"},
1282     {220, "Unknown PDP address or PDP type"},
1283     {221, "PDP context without TFT already activated"},
1284     {222, "APN access denied - no subscription"},
1285     {223, "APN Restriction type incompatibility with currently active PDP Contexts"},
1286     {224, "MS MBMS Capabilities Insufficient"},
1287     {225, "Invalid Correlation-ID"},
1288     {226, "MBMS Bearer Context Superseded"},
1289     {227, "Bearer Control Mode violation"},
1290     {228, "Collision with network initiated request"},
1291     {229, "APN Congestion"},
1292     {230, "Bearer handling not supported"},
1293     {231, "Target access restricted for the subscriber" },
1294     {232, "UE is temporarily not reachable due to power saving" },
1295     {233, "Relocation failure due to NAS message redirection"},
1296     /* For future use -240 */
1297     /* Cause values reserved for GPRS charging
1298      * protocol use (see GTP' in 3GPP TS 32.295 [33])
1299      * 241-255
1300      */
1301     {252, "Request related to possibly duplicated packets already fulfilled"},  /* charging */
1302     {253, "Request already fulfilled"}, /* charging */
1303     {254, "Sequence numbers of released/cancelled packets IE incorrect"},   /* charging */
1304     {255, "Request not fulfilled"}, /* charging */
1305     {0, NULL}
1306 };
1307 value_string_ext cause_type_ext = VALUE_STRING_EXT_INIT(cause_type);
1308
1309 /* GPRS:    9.02 v7.7.0
1310  * UMTS:    29.002 v4.2.1, chapter 17.5, page 268
1311  * Imported gsm_old_GSMMAPLocalErrorcode_vals from gsm_map from gsm_map
1312  */
1313
1314 static const value_string gsn_addr_type[] = {
1315     {0x00, "IPv4"},
1316     {0x01, "IPv6"},
1317     {0, NULL}
1318 };
1319
1320 static const value_string pdp_type[] = {
1321     {0x00, "X.25"},
1322     {0x01, "PPP"},
1323     {0x02, "OSP:IHOSS"},
1324     {0x21, "IPv4"},
1325     {0x57, "IPv6"},
1326     {0x8d, "IPv4v6"},
1327     {0, NULL}
1328 };
1329
1330 static const value_string pdp_org_type[] = {
1331     {0, "ETSI"},
1332     {1, "IETF"},
1333     {0, NULL}
1334 };
1335
1336 static const value_string qos_delay_type[] = {
1337     {0x00, "Subscribed delay class (in MS to network direction)"},
1338     {0x01, "Delay class 1"},
1339     {0x02, "Delay class 2"},
1340     {0x03, "Delay class 3"},
1341     {0x04, "Delay class 4 (best effort)"},
1342     {0x07, "Reserved"},
1343     {0, NULL}
1344 };
1345
1346 static const value_string qos_reliability_type[] = {
1347     {0x00, "Subscribed reliability class (in MS to network direction)"},
1348     {0x01, "Acknowledged GTP, LLC, and RLC; Protected data"},
1349     {0x02, "Unacknowledged GTP, Ack LLC/RLC, Protected data"},
1350     {0x03, "Unacknowledged GTP/LLC, Ack RLC, Protected data"},
1351     {0x04, "Unacknowledged GTP/LLC/RLC, Protected data"},
1352     {0x05, "Unacknowledged GTP/LLC/RLC, Unprotected data"},
1353     {0x07, "Reserved"},
1354     {0, NULL}
1355 };
1356
1357 static const value_string qos_peak_type[] = {
1358     {0x00, "Subscribed peak throughput (in MS to network direction)"},
1359     {0x01, "Up to 1 000 oct/s"},
1360     {0x02, "Up to 2 000 oct/s"},
1361     {0x03, "Up to 4 000 oct/s"},
1362     {0x04, "Up to 8 000 oct/s"},
1363     {0x05, "Up to 16 000 oct/s"},
1364     {0x06, "Up to 32 000 oct/s"},
1365     {0x07, "Up to 64 000 oct/s"},
1366     {0x08, "Up to 128 000 oct/s"},
1367     {0x09, "Up to 256 000 oct/s"},
1368 /* QoS Peak throughput classes from 0x0A to 0x0F (from 10 to 15) are subscribed */
1369     {0x0A, "Reserved"},
1370     {0x0B, "Reserved"},
1371     {0x0C, "Reserved"},
1372     {0x0D, "Reserved"},
1373     {0x0E, "Reserved"},
1374     {0x0F, "Reserved"},
1375     {0, NULL}
1376 };
1377
1378 static const value_string qos_precedence_type[] = {
1379     {0x00, "Subscribed precedence (in MS to network direction)"},
1380     {0x01, "High priority"},
1381     {0x02, "Normal priority"},
1382     {0x03, "Low priority"},
1383     {0x07, "Reserved"},
1384     {0, NULL}
1385 };
1386
1387 static const value_string qos_mean_type[] = {
1388     {0x00, "Subscribed mean throughput (in MS to network direction)"},
1389     {0x01, "100 oct/h"},        /* Class 2 */
1390     {0x02, "200 oct/h"},        /* Class 3 */
1391     {0x03, "500 oct/h"},        /* Class 4 */
1392     {0x04, "1 000 oct/h"},      /* Class 5 */
1393     {0x05, "2 000 oct/h"},      /* Class 6 */
1394     {0x06, "5 000 oct/h"},      /* Class 7 */
1395     {0x07, "10 000 oct/h"},     /* Class 8 */
1396     {0x08, "20 000 oct/h"},     /* Class 9 */
1397     {0x09, "50 000 oct/h"},     /* Class 10 */
1398     {0x0A, "100 000 oct/h"},    /* Class 11 */
1399     {0x0B, "200 000 oct/h"},    /* Class 12 */
1400     {0x0C, "500 000 oct/h"},    /* Class 13 */
1401     {0x0D, "1 000 000 oct/h"},  /* Class 14 */
1402     {0x0E, "2 000 000 oct/h"},  /* Class 15 */
1403     {0x0F, "5 000 000 oct/h"},  /* Class 16 */
1404     {0x10, "10 000 000 oct/h"}, /* Class 17 */
1405     {0x11, "20 000 000 oct/h"}, /* Class 18 */
1406     {0x12, "50 000 000 oct/h"}, /* Class 19 */
1407 /* QoS Mean throughput classes from 0x13 to 0x1E (from 19 to 30) are subscribed */
1408     {0x13, "Reserved"},
1409     {0x14, "Reserved"},
1410     {0x15, "Reserved"},
1411     {0x16, "Reserved"},
1412     {0x17, "Reserved"},
1413     {0x18, "Reserved"},
1414     {0x19, "Reserved"},
1415     {0x1A, "Reserved"},
1416     {0x1B, "Reserved"},
1417     {0x1C, "Reserved"},
1418     {0x1D, "Reserved"},
1419     {0x1E, "Reserved"},
1420     {0x1F, "Best effort"},  /* Class 1 */
1421     {0, NULL}
1422 };
1423 static value_string_ext qos_mean_type_ext = VALUE_STRING_EXT_INIT(qos_mean_type);
1424
1425 static const value_string qos_del_err_sdu[] = {
1426     {0x00, "Subscribed delivery of erroneous SDUs (in MS to network direction)"},
1427     {0x01, "No detect ('-')"},
1428     {0x02, "Erroneous SDUs are delivered ('yes')"},
1429     {0x03, "Erroneous SDUs are not delivered ('no')"},
1430     {0x07, "Reserved"},  /* All other values are reserved */
1431     {0, NULL}
1432 };
1433
1434 static const value_string qos_del_order[] = {
1435     {0x00, "Subscribed delivery order (in MS to network direction)"},
1436     {0x01, "With delivery order ('yes')"},
1437     {0x02, "Without delivery order ('no')"},
1438     {0x03, "Reserved"},  /* All other values are reserved */
1439     {0, NULL}
1440 };
1441
1442 static const value_string qos_traf_class[] = {
1443     {0x00, "Subscribed traffic class (in MS to network direction)"},
1444     {0x01, "Conversational class"},
1445     {0x02, "Streaming class"},
1446     {0x03, "Interactive class"},
1447     {0x04, "Background class"},
1448     {0x07, "Reserved"},  /* All other values are reserved */
1449     {0, NULL}
1450 };
1451
1452 static const value_string qos_max_sdu_size[] = {
1453     {0x00, "Subscribed maximum SDU size (in MS to network direction"},
1454     /* For values from 0x01 to 0x96 (from 1 to 150), use a granularity of 10 octets */
1455     {0x97, "1502 octets"},
1456     {0x98, "1510 octets"},
1457     {0x99, "1520 octets"},
1458     {0, NULL}             /* All other values are reserved */
1459 };
1460
1461 static const value_string qos_max_ul[] = {
1462     {0x00, "Subscribed maximum bit rate for uplink (in MS to network direction)"},
1463     /* For values from 0x01 to 0x3F (from 1 to 63), use a granularity of 1 kbps */
1464     /* For values from 0x40 to 0x7F, value = 64 kbps + (value - 0x40) * 8 kbps */
1465     /* For values from 0x80 to 0xFE, value = 576 kbps + (value - 0x80) * 64 kbps */
1466     {0xFF, "0 kbps"},
1467     {0, NULL}
1468 };
1469
1470 static const value_string qos_max_dl[] = {
1471     {0x00, "Subscribed maximum bit rate for downlink (in MS to network direction)"},
1472     /* For values from 0x01 to 0x3F (from 1 to 63), use a granularity of 1 kbps */
1473     /* For values from 0x40 to 0x7F, value = 64 kbps + (value - 0x40) * 8 kbps */
1474     /* For values from 0x80 to 0xFE, value = 576 kbps + (value - 0x80) * 64 kbps */
1475     {0xFF, "0 kbps"},
1476     {0, NULL}
1477 };
1478
1479 static const value_string qos_res_ber[] = {
1480     {0x00, "Subscribed residual BER (in MS to network direction)"},
1481     {0x01, "1/20 = 5x10^-2"},
1482     {0x02, "1/100 = 1x10^-2"},
1483     {0x03, "1/200 = 5x10^-3"},
1484     {0x04, "1/250 = 4x10^-3"},
1485     {0x05, "1/1 000 = 1x10^-3"},
1486     {0x06, "1/10 000 = 1x10^-4"},
1487     {0x07, "1/100 000 = 1x10^-5"},
1488     {0x08, "1/1 000 000 = 1x10^-6"},
1489     {0x09, "3/50 000 000 = 6x10^-8"},
1490     {0x0F, "Reserved"},    /* All other values are reserved */
1491     {0, NULL}
1492 };
1493
1494 static const value_string qos_sdu_err_ratio[] = {
1495     {0x00, "Subscribed SDU error ratio (in MS to network direction)"},
1496     {0x01, "1/100 = 1x10^-2"},
1497     {0x02, "7/1000 = 7x10^-3"},
1498     {0x03, "1/1 000 = 1x10^-3"},
1499     {0x04, "1/10 000 = 1x10^-4"},
1500     {0x05, "1/100 000 = 1x10^-5"},
1501     {0x06, "1/1 000 000 = 1x10^-6"},
1502     {0x07, "1/10 = 1x10^-1"},
1503     {0x0F, "Reserved"},    /* All other values are reserved */
1504     {0, NULL}
1505 };
1506
1507 static const value_string qos_traf_handl_prio[] = {
1508     {0x00, "Subscribed traffic handling priority (in MS to network direction)"},
1509     {0x01, "Priority level 1"},
1510     {0x02, "Priority level 2"},
1511     {0x03, "Priority level 3"},
1512     {0, NULL}
1513 };
1514
1515 static const value_string qos_trans_delay[] = {
1516     {0x00, "Subscribed Transfer Delay (in MS to network direction)"},
1517     {0x01, "10 ms"},        /* Using a granularity of 10 ms */
1518     {0x02, "20 ms"},
1519     {0x03, "30 ms"},
1520     {0x04, "40 ms"},
1521     {0x05, "50 ms"},
1522     {0x06, "60 ms"},
1523     {0x07, "70 ms"},
1524     {0x08, "80 ms"},
1525     {0x09, "90 ms"},
1526     {0x0A, "100 ms"},
1527     {0x0B, "110 ms"},
1528     {0x0C, "120 ms"},
1529     {0x0D, "130 ms"},
1530     {0x0E, "140 ms"},
1531     {0x0F, "150 ms"},
1532     {0x10, "200 ms"},       /* (For values from 0x10 to 0x1F, value = 200 ms + (value - 0x10) * 50 ms */
1533     {0x11, "250 ms"},
1534     {0x12, "300 ms"},
1535     {0x13, "350 ms"},
1536     {0x14, "400 ms"},
1537     {0x15, "450 ms"},
1538     {0x16, "500 ms"},
1539     {0x17, "550 ms"},
1540     {0x18, "600 ms"},
1541     {0x19, "650 ms"},
1542     {0x1A, "700 ms"},
1543     {0x1B, "750 ms"},
1544     {0x1C, "800 ms"},
1545     {0x1D, "850 ms"},
1546     {0x1E, "900 ms"},
1547     {0x1F, "950 ms"},
1548     {0x20, "1000 ms"},      /* For values from 0x20 to 0x3E, value = 1000 ms + (value - 0x20) * 100 ms */
1549     {0x21, "1100 ms"},
1550     {0x22, "1200 ms"},
1551     {0x23, "1300 ms"},
1552     {0x24, "1400 ms"},
1553     {0x25, "1500 ms"},
1554     {0x26, "1600 ms"},
1555     {0x27, "1700 ms"},
1556     {0x28, "1800 ms"},
1557     {0x29, "1900 ms"},
1558     {0x2A, "2000 ms"},
1559     {0x2B, "2100 ms"},
1560     {0x2C, "2200 ms"},
1561     {0x2D, "2300 ms"},
1562     {0x2E, "2400 ms"},
1563     {0x2F, "2500 ms"},
1564     {0x30, "2600 ms"},
1565     {0x31, "2700 ms"},
1566     {0x32, "2800 ms"},
1567     {0x33, "2900 ms"},
1568     {0x34, "3000 ms"},
1569     {0x35, "3100 ms"},
1570     {0x36, "3200 ms"},
1571     {0x37, "3300 ms"},
1572     {0x38, "3400 ms"},
1573     {0x39, "3500 ms"},
1574     {0x3A, "3600 ms"},
1575     {0x3B, "3700 ms"},
1576     {0x3C, "3800 ms"},
1577     {0x3D, "3900 ms"},
1578     {0x3E, "4000 ms"},
1579     {0x3F, "Reserved"},
1580     {0, NULL}
1581 };
1582 static value_string_ext qos_trans_delay_ext = VALUE_STRING_EXT_INIT(qos_trans_delay);
1583
1584 static const value_string qos_guar_ul[] = {
1585     {0x00, "Subscribed guaranteed bit rate for uplink (in MS to network direction)"},
1586     /* For values from 0x01 to 0x3F (from 1 to 63), use a granularity of 1 kbps */
1587     /* For values from 0x40 to 0x7F, value = 64 kbps + (value - 0x40) * 8 kbps */
1588     /* For values from 0x80 to 0xFE, value = 576 kbps + (value - 0x80) * 64 kbps */
1589     {0xFF, "0 kbps"},
1590     {0, NULL}
1591 };
1592
1593 static const value_string src_stat_desc_vals[] = {
1594     {0x00, "unknown"},
1595     {0x01, "speech"},
1596     {0, NULL}
1597 };
1598
1599
1600 static const true_false_string gtp_sig_ind = {
1601     "Optimised for signalling traffic",
1602     "Not optimised for signalling traffic"
1603 };
1604
1605 static const value_string qos_guar_dl[] = {
1606     {0x00, "Subscribed guaranteed bit rate for downlink (in MS to network direction)"},
1607     /* For values from 0x01 to 0x3F (from 1 to 63), use a granularity of 1 kbps */
1608     /* For values from 0x40 to 0x7F, value = 64 kbps + (value - 0x40) * 8 kbps */
1609     /* For values from 0x80 to 0xFE, value = 576 kbps + (value - 0x80) * 64 kbps */
1610     {0xFF, "0 kbps"},
1611     {0, NULL}
1612 };
1613
1614 static const value_string sel_mode_type[] = {
1615     {0, "MS or network provided APN, subscribed verified"},
1616     {1, "MS provided APN, subscription not verified"},
1617     {2, "Network provided APN, subscription not verified"},
1618     {3, "For future use (Network provided APN, subscription not verified"}, /* Shall not be sent. If received, shall be sent as value 2 */
1619     {0, NULL}
1620 };
1621
1622 static const value_string tr_comm_type[] = {
1623     {1, "Send data record packet"},
1624     {2, "Send possibly duplicated data record packet"},
1625     {3, "Cancel data record packet"},
1626     {4, "Release data record packet"},
1627     {0, NULL}
1628 };
1629
1630 /*
1631  * UMTS:   23.040 v14.0.0, chapter 3.3.2
1632  */
1633 static const value_string ms_not_reachable_type[] = {
1634     { 0, "No paging response via the MSC"},
1635     { 1, "IMSI detached"},
1636     { 2, "Roaming restriction"},
1637     { 3, "Deregistered in the HLR for non GPRS"},
1638     { 4, "MS purge for non GPRS"},
1639     { 5, "No paging response via the SGSN"},
1640     { 6, "GPRS detached"},
1641     { 7, "Deregistered in the HLR for non GPRS"},
1642     { 8, "MS purged for GPRS"},
1643     { 9, "Unidentified subscriber via the MSC"},
1644     {10, "Unidentified subscriber via the SGSN"},
1645     {11, "Deregistered in the HSS/HLR for IMS"},
1646     {12, "No response via the IP-SM-GW"},
1647     {13, "The MS is temporarily unavailable"},
1648     {0, NULL}             /* All other values are reserved */
1649 };
1650
1651 /* UMTS:   25.413 v3.4.0, chapter 9.2.1.4, page 80
1652  */
1653 static const value_string ranap_cause_type[] = {
1654 /* Radio Network Layer Cause (1-->64) */
1655     {   1, "RAB preempted"},
1656     {   2, "Trelocoverall Expiry"},
1657     {   3, "Trelocprep Expiry"},
1658     {   4, "Treloccomplete Expiry"},
1659     {   5, "Tqueuing Expiry"},
1660     {   6, "Relocation Triggered"},
1661     {   7, "TRELOCalloc Expiry"},
1662     {   8, "Unable to Establish During Relocation"},
1663     {   9, "Unknown Target RNC"},
1664     {  10, "Relocation Cancelled"},
1665     {  11, "Successful Relocation"},
1666     {  12, "Requested Ciphering and/or Integrity Protection Algorithms not Supported"},
1667     {  13, "Change of Ciphering and/or Integrity Protection is not supported"},
1668     {  14, "Failure in the Radio Interface Procedure"},
1669     {  15, "Release due to UTRAN Generated Reason"},
1670     {  16, "User Inactivity"},
1671     {  17, "Time Critical Relocation"},
1672     {  18, "Requested Traffic Class not Available"},
1673     {  19, "Invalid RAB Parameters Value"},
1674     {  20, "Requested Maximum Bit Rate not Available"},
1675     {  21, "Requested Guaranteed Bit Rate not Available"},
1676     {  22, "Requested Transfer Delay not Achievable"},
1677     {  23, "Invalid RAB Parameters Combination"},
1678     {  24, "Condition Violation for SDU Parameters"},
1679     {  25, "Condition Violation for Traffic Handling Priority"},
1680     {  26, "Condition Violation for Guaranteed Bit Rate"},
1681     {  27, "User Plane Versions not Supported"},
1682     {  28, "Iu UP Failure"},
1683     {  29, "Relocation Failure in Target CN/RNC or Target System"},
1684     {  30, "Invalid RAB ID"},
1685     {  31, "No Remaining RAB"},
1686     {  32, "Interaction with other procedure"},
1687     {  33, "Requested Maximum Bit Rate for DL not Available"},
1688     {  34, "Requested Maximum Bit Rate for UL not Available"},
1689     {  35, "Requested Guaranteed Bit Rate for DL not Available"},
1690     {  36, "Requested Guaranteed Bit Rate for UL not Available"},
1691     {  37, "Repeated Integrity Checking Failure"},
1692     {  38, "Requested Report Type not supported"},
1693     {  39, "Request superseded"},
1694     {  40, "Release due to UE generated signalling connection release"},
1695     {  41, "Resource Optimisation Relocation"},
1696     {  42, "Requested Information Not Available"},
1697     {  43, "Relocation desirable for radio reasons"},
1698     {  44, "Relocation not supported in Target RNC or Target System"},
1699     {  45, "Directed Retry"},
1700     {  46, "Radio Connection With UE Lost"},
1701     {  47, "rNC-unable-to-establish-all-RFCs"},
1702     {  48, "deciphering-keys-not-available"},
1703     {  49, "dedicated-assistance-data-not-available"},
1704     {  50, "relocation-target-not-allowed"},
1705     {  51, "location-reporting-congestion"},
1706     {  52, "reduce-load-in-serving-cell"},
1707     {  53, "no-radio-resources-available-in-target-cell"},
1708     {  54, "gERAN-Iumode-failure"},
1709     {  55, "access-restricted-due-to-shared-networks"},
1710     {  56, "incoming-relocation-not-supported-due-to-PUESBINE-feature"},
1711     {  57, "traffic-load-in-the-target-cell-higher-than-in-the-source-cell"},
1712     {  58, "mBMS-no-multicast-service-for-this-UE"},
1713     {  59, "mBMS-unknown-UE-ID"},
1714     {  60, "successful-MBMS-session-start-no-data-bearer-necessary"},
1715     {  61, "mBMS-superseded-due-to-NNSF"},
1716     {  62, "mBMS-UE-linking-already-done"},
1717     {  63, "mBMS-UE-de-linking-failure-no-existing-UE-linking"},
1718     {  64, "tMGI-unknown"},
1719 /* Transport Layer Cause (65-->80) */
1720     {  65, "Signalling Transport Resource Failure"},
1721     {  66, "Iu Transport Connection Failed to Establish"},
1722 /* NAS Cause (81-->96) */
1723     {  81, "User Restriction Start Indication"},
1724     {  82, "User Restriction End Indication"},
1725     {  83, "Normal Release"},
1726 /* Protocol Cause (97-->112) */
1727     {  97, "Transfer Syntax Error"},
1728     {  98, "Semantic Error"},
1729     {  99, "Message not compatible with receiver state"},
1730     { 100, "Abstract Syntax Error (Reject)"},
1731     { 101, "Abstract Syntax Error (Ignore and Notify)"},
1732     { 102, "Abstract Syntax Error (Falsely Constructed Message"},
1733 /* Miscellaneous Cause (113-->128) */
1734     { 113, "O & M Intervention"},
1735     { 114, "No Resource Available"},
1736     { 115, "Unspecified Failure"},
1737     { 116, "Network Optimisation"},
1738 /* Non-standard Cause (129-->255) */
1739
1740 /* ranap_CauseRadioNetworkExtension ??
1741     { 257, "iP-multicast-address-and-APN-not-valid" },
1742     { 258, "mBMS-de-registration-rejected-due-to-implicit-registration" },
1743     { 259, "mBMS-request-superseded" },
1744     { 260, "mBMS-de-registration-during-session-not-allowed" },
1745     { 261, "mBMS-no-data-bearer-necessary" },
1746   */
1747
1748     {0, NULL}
1749 };
1750 static value_string_ext ranap_cause_type_ext = VALUE_STRING_EXT_INIT(ranap_cause_type);
1751
1752 static const value_string mm_sec_modep[] = {
1753     {0, "Used cipher value, UMTS keys and Quintuplets"},
1754     {1, "GSM key and triplets"},
1755     {2, "UMTS key and quintuplets"},
1756     {3, "GSM key and quintuplets"},
1757     {0, NULL}
1758 };
1759
1760 static const value_string gtp_cipher_algorithm[] = {
1761     {0, "No ciphering"},
1762     {1, "GEA/1"},
1763     {2, "GEA/2"},
1764     {3, "GEA/3"},
1765     {4, "GEA/4"},
1766     {5, "GEA/5"},
1767     {6, "GEA/6"},
1768     {7, "GEA/7"},
1769     {0, NULL}
1770 };
1771 static const value_string gtp_ext_rat_type_vals[] = {
1772     {0, "Reserved"},
1773     {1, "UTRAN"},
1774     {2, "GERAN"},
1775     {3, "WLAN"},
1776     {4, "GAN"},
1777     {5, "HSPA Evolution"},
1778     {6, "EUTRAN (WB-E-UTRAN)"},
1779     {7, "Virtual"},
1780     {8, "EUTRAN-NB-IoT"},
1781     {0, NULL}
1782 };
1783 static const value_string chg_rep_act_type_vals[] = {
1784     {0, "Stop Reporting"},
1785     {1, "Start Reporting CGI/SAI"},
1786     {2, "Start Reporting RAI"},
1787     {0, NULL}
1788 };
1789
1790
1791 static const value_string geographic_location_type[] = {
1792     {0, "Cell Global Identification (CGI)"},
1793     {1, "Service Area Identity (SAI)"},
1794     {2, "Routing Area Identification (RAI)"},
1795 /* reserved for future used (3-->127) */
1796     {128, "Tracking Area identity (TAI)"},                                              /* Radius */
1797     {129, "E-UTRAN Cell Global Identification (ECGI)"},                                 /* Radius */
1798     {130, "Tracking Area identity & E-UTRAN Cell Global Identification (TAI & ECGI)"},  /* Radius */
1799 /* reserved for future used (131-->255) */
1800     {0, NULL}
1801 };
1802
1803 #define MM_PROTO_GROUP_CALL_CONTROL     0x00
1804 #define MM_PROTO_BROADCAST_CALL_CONTROL 0x01
1805 #define MM_PROTO_PDSS1                  0x02
1806 #define MM_PROTO_CALL_CONTROL           0x03
1807 #define MM_PROTO_PDSS2                  0x04
1808 #define MM_PROTO_MM_NON_GPRS            0x05
1809 #define MM_PROTO_RR_MGMT                0x06
1810 #define MM_PROTO_MM_GPRS                0x08
1811 #define MM_PROTO_SMS                    0x09
1812 #define MM_PROTO_SESSION_MGMT           0x0A
1813 #define MM_PROTO_NON_CALL_RELATED       0x0B
1814
1815 static void
1816 gtpstat_init(struct register_srt* srt _U_, GArray* srt_array)
1817 {
1818     srt_stat_table *gtp_srt_table;
1819
1820     gtp_srt_table = init_srt_table("GTP Requests", NULL, srt_array, 4, NULL, NULL, NULL);
1821     init_srt_table_row(gtp_srt_table, 0, "Echo");
1822     init_srt_table_row(gtp_srt_table, 1, "Create PDP context");
1823     init_srt_table_row(gtp_srt_table, 2, "Update PDP context");
1824     init_srt_table_row(gtp_srt_table, 3, "Delete PDP context");
1825 }
1826
1827 static int
1828 gtpstat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prv)
1829 {
1830     guint i = 0;
1831     srt_stat_table *gtp_srt_table;
1832     srt_data_t *data = (srt_data_t *)pss;
1833     const gtp_msg_hash_t *gtp=(const gtp_msg_hash_t *)prv;
1834     int idx=0;
1835
1836     /* we are only interested in reply packets */
1837     if(gtp->is_request){
1838         return 0;
1839     }
1840     /* if we have not seen the request, just ignore it */
1841     if(!gtp->req_frame){
1842         return 0;
1843     }
1844
1845     /* Only use the commands we know how to handle, this is not a comprehensive list */
1846     /* Redoing the message indexing is bit reduntant,                    */
1847     /*  but using message type as such would yield a long gtp_srt_table. */
1848     /*  Only a fraction of the messages are matchable req/resp pairs,    */
1849     /*  it just doesn't feel feasible.                                   */
1850
1851     switch(gtp->msgtype){
1852     case GTP_MSG_ECHO_REQ: idx=0;
1853         break;
1854     case GTP_MSG_CREATE_PDP_REQ: idx=1;
1855         break;
1856     case GTP_MSG_UPDATE_PDP_REQ: idx=2;
1857         break;
1858     case GTP_MSG_DELETE_PDP_REQ: idx=3;
1859         break;
1860     default:
1861         return 0;
1862     }
1863
1864     gtp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i);
1865     add_srt_table_data(gtp_srt_table, idx, &gtp->req_time, pinfo);
1866
1867     return 1;
1868 }
1869
1870
1871 static dissector_handle_t ip_handle;
1872 static dissector_handle_t ipv6_handle;
1873 static dissector_handle_t ppp_handle;
1874 static dissector_handle_t sync_handle;
1875 static dissector_handle_t gtpcdr_handle;
1876 static dissector_handle_t sndcpxid_handle;
1877 static dissector_handle_t gtpv2_handle;
1878 static dissector_handle_t bssgp_handle;
1879 static dissector_table_t bssap_pdu_type_table;
1880 guint32 gtp_session_count;
1881
1882 /* Relation between frame -> session */
1883 GHashTable* session_table;
1884 /* Relation between <teid,ip> -> frame */
1885 wmem_tree_t* frame_tree;
1886
1887 typedef struct gtp_info {
1888     guint32 teid;
1889     guint32 frame;
1890 } gtp_info_t;
1891
1892 /* GTP Session funcs*/
1893 guint32
1894 get_frame(address ip, guint32 teid, guint32 *frame) {
1895     gboolean found = FALSE;
1896     wmem_list_frame_t *elem;
1897     gtp_info_t *info;
1898     wmem_list_t *info_list;
1899     gchar *ip_str;
1900
1901     /* First we get the teid list*/
1902     ip_str = address_to_str(wmem_packet_scope(), &ip);
1903     info_list = (wmem_list_t*)wmem_tree_lookup_string(frame_tree, ip_str, 0);
1904     if (info_list != NULL) {
1905         elem = wmem_list_head(info_list);
1906         while (!found && elem) {
1907             info = (gtp_info_t*)wmem_list_frame_data(elem);
1908             if (teid == info->teid) {
1909                 *frame = info->frame;
1910                 return 1;
1911             }
1912             elem = wmem_list_frame_next(elem);
1913         }
1914     }
1915     return 0;
1916 }
1917
1918 static gboolean
1919 call_foreach_ip(const void *key _U_, void *value, void *data){
1920     wmem_list_frame_t * elem;
1921     wmem_list_t *info_list = (wmem_list_t *)value;
1922     gtp_info_t *info;
1923     guint32* frame = (guint32*)data;
1924
1925     /* We loop over the <teid, frame> list */
1926     elem = wmem_list_head(info_list);
1927     while (elem) {
1928         info = (gtp_info_t*)wmem_list_frame_data(elem);
1929         if (info->frame == *frame) {
1930             wmem_list_frame_t * del = elem;
1931             /* proceed to next request */
1932             elem = wmem_list_frame_next(elem);
1933             /* If we find the frame we remove its information from the list */
1934             wmem_list_remove_frame(info_list, del);
1935             wmem_free(wmem_file_scope(), info);
1936         }
1937         else {
1938             elem = wmem_list_frame_next(elem);
1939         }
1940     }
1941
1942     return FALSE;
1943 }
1944
1945 void
1946 remove_frame_info(guint32 *f) {
1947     /* For each ip node */
1948     wmem_tree_foreach(frame_tree, call_foreach_ip, (void *)f);
1949 }
1950
1951 void
1952 add_gtp_session(guint32 frame, guint32 session) {
1953     guint32 *f, *session_count;
1954
1955     f = wmem_new0(wmem_file_scope(), guint32);
1956     session_count = wmem_new0(wmem_file_scope(), guint32);
1957     *f = frame;
1958     *session_count = session;
1959     g_hash_table_insert(session_table, f, session_count);
1960 }
1961
1962 gboolean
1963 teid_exists(guint32 teid, wmem_list_t *teid_list) {
1964     wmem_list_frame_t *elem;
1965     guint32 *info;
1966     gboolean found;
1967     found = FALSE;
1968     elem = wmem_list_head(teid_list);
1969     while (!found && elem) {
1970         info = (guint32*)wmem_list_frame_data(elem);
1971         found = *info == teid;
1972         elem = wmem_list_frame_next(elem);
1973     }
1974     return found;
1975 }
1976
1977 gboolean
1978 ip_exists(address ip, wmem_list_t *ip_list) {
1979     wmem_list_frame_t *elem;
1980     address *info;
1981     gboolean found;
1982     found = FALSE;
1983     elem = wmem_list_head(ip_list);
1984     while (!found && elem) {
1985         info = (address*)wmem_list_frame_data(elem);
1986         found = addresses_equal(info, &ip);
1987         elem = wmem_list_frame_next(elem);
1988     }
1989     return found;
1990 }
1991
1992 static gboolean
1993 info_exists(gtp_info_t *wanted, wmem_list_t *info_list) {
1994     wmem_list_frame_t *elem;
1995     gtp_info_t *info;
1996     gboolean found;
1997     found = FALSE;
1998     elem = wmem_list_head(info_list);
1999     while (!found && elem) {
2000         info = (gtp_info_t*)wmem_list_frame_data(elem);
2001         found = wanted->teid == info->teid;
2002         elem = wmem_list_frame_next(elem);
2003     }
2004     return found;
2005 }
2006
2007 void
2008 fill_map(wmem_list_t *teid_list, wmem_list_t *ip_list, guint32 frame) {
2009     wmem_list_frame_t *elem_ip, *elem_teid;
2010     gtp_info_t *gtp_info;
2011     wmem_list_t * info_list; /* List of <teids,frames>*/
2012     guint32 *f, *session, *fr, *session_count;
2013     GHashTableIter iter;
2014     guint32 teid;
2015     gchar *ip;
2016
2017     elem_ip = wmem_list_head(ip_list);
2018     while (elem_ip) {
2019         ip = address_to_str(wmem_file_scope(), (address*)wmem_list_frame_data(elem_ip));
2020         /* We check if a teid list exists for this ip */
2021         info_list = (wmem_list_t*)wmem_tree_lookup_string(frame_tree, ip, 0);
2022         if (info_list == NULL) {
2023             info_list = wmem_list_new(wmem_file_scope());
2024         }
2025         /* We loop over the teid list */
2026         elem_teid = wmem_list_head(teid_list);
2027         while (elem_teid) {
2028             teid = *(guint32*)wmem_list_frame_data(elem_teid);
2029             f = wmem_new0(wmem_file_scope(), guint32);
2030             *f = frame;
2031             gtp_info = wmem_new0(wmem_file_scope(), gtp_info_t);
2032             gtp_info->teid = teid;
2033             gtp_info->frame = *f;
2034             if (info_exists(gtp_info, info_list)) {
2035                 /* If the teid and ip already existed, that means that we need to remove old info about that session */
2036                 /* We look for its session ID */
2037                 session = (guint32 *)g_hash_table_lookup(session_table, f);
2038                 if (session) {
2039                     g_hash_table_iter_init(&iter, session_table);
2040                     while (g_hash_table_iter_next(&iter, (gpointer*)&fr, (gpointer*)&session_count)) {
2041                         /* If the msg has the same session ID and it's not the upd req we have to remove its info */
2042                         if (*session_count == *session) {
2043                             /* If it's the session we are looking for, we remove all the frame information */
2044                             remove_frame_info(fr);
2045                         }
2046                     }
2047                 }
2048             }
2049             wmem_list_prepend(info_list, gtp_info);
2050             elem_teid = wmem_list_frame_next(elem_teid);
2051         }
2052         wmem_tree_insert_string(frame_tree, ip, info_list, 0);
2053         elem_ip = wmem_list_frame_next(elem_ip);
2054     }
2055 }
2056
2057 gboolean
2058 is_cause_accepted(guint8 cause, guint32 version) {
2059     if (version == 1) {
2060         return cause == 128 || cause == 129 || cause == 130;
2061     }
2062     else if (version == 2) {
2063         return cause == 16 || cause == 17 || cause == 18 || cause == 19;
2064     }
2065     return FALSE;
2066 }
2067
2068 static int decode_gtp_cause(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args);
2069 static int decode_gtp_imsi(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2070 static int decode_gtp_rai(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2071 static int decode_gtp_tlli(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2072 static int decode_gtp_ptmsi(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2073 static int decode_gtp_qos_gprs(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2074 static int decode_gtp_reorder(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2075 static int decode_gtp_auth_tri(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2076 static int decode_gtp_map_cause(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2077 static int decode_gtp_ptmsi_sig(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2078 static int decode_gtp_ms_valid(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2079 static int decode_gtp_recovery(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2080 static int decode_gtp_sel_mode(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2081 static int decode_gtp_16(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args);
2082 static int decode_gtp_17(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args);
2083 static int decode_gtp_18(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2084 static int decode_gtp_19(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2085 static int decode_gtp_nsapi(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2086 static int decode_gtp_ranap_cause(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2087 static int decode_gtp_rab_cntxt(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2088 static int decode_gtp_rp_sms(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2089 static int decode_gtp_rp(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2090 static int decode_gtp_pkt_flow_id(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2091 static int decode_gtp_chrg_char(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2092 static int decode_gtp_trace_ref(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2093 static int decode_gtp_trace_type(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2094 static int decode_gtp_ms_reason(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2095 static int decode_gtp_tr_comm(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2096 static int decode_gtp_chrg_id(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2097 static int decode_gtp_user_addr(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2098 static int decode_gtp_mm_cntxt(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2099 static int decode_gtp_pdp_cntxt(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2100 static int decode_gtp_apn(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2101 static int decode_gtp_gsn_addr(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args);
2102 static int decode_gtp_proto_conf(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2103 static int decode_gtp_msisdn(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2104 static int decode_gtp_qos_umts(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2105 static int decode_gtp_auth_qui(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2106 static int decode_gtp_tft(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2107 static int decode_gtp_target_id(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2108 static int decode_gtp_utran_cont(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2109 static int decode_gtp_rab_setup(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2110 static int decode_gtp_hdr_list(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2111 static int decode_gtp_trigger_id(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2112 static int decode_gtp_omc_id(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2113
2114 static int decode_gtp_ran_tr_cont(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2115 static int decode_gtp_pdp_cont_prio(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2116 static int decode_gtp_add_rab_setup_inf(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2117 static int decode_gtp_ssgn_no(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2118 static int decode_gtp_common_flgs(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2119 static int decode_gtp_apn_res(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2120 static int decode_gtp_ra_prio_lcs(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2121 static int decode_gtp_rat_type(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2122 static int decode_gtp_usr_loc_inf(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2123 static int decode_gtp_ms_time_zone(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2124 static int decode_gtp_imeisv(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2125 static int decode_gtp_camel_chg_inf_con(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2126 static int decode_gtp_mbms_ue_ctx(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2127 static int decode_gtp_tmgi(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2128 static int decode_gtp_rim_ra(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2129 static int decode_gtp_mbms_prot_conf_opt(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2130 static int decode_gtp_mbms_sa(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2131 static int decode_gtp_src_rnc_pdp_ctx_inf(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2132 static int decode_gtp_add_trs_inf(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2133 static int decode_gtp_hop_count(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2134 static int decode_gtp_sel_plmn_id(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2135 static int decode_gtp_mbms_ses_id(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2136 static int decode_gtp_mbms_2g_3g_ind(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2137 static int decode_gtp_enh_nsapi(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2138 static int decode_gtp_mbms_ses_dur(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2139 static int decode_gtp_add_mbms_trs_inf(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2140 static int decode_gtp_mbms_ses_id_rep_no(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2141 static int decode_gtp_mbms_time_to_data_tr(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2142 static int decode_gtp_ps_ho_req_ctx(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2143 static int decode_gtp_bss_cont(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2144 static int decode_gtp_cell_id(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2145 static int decode_gtp_pdu_no(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2146 static int decode_gtp_bssgp_cause(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2147 static int decode_gtp_mbms_bearer_cap(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2148 static int decode_gtp_rim_ra_disc(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2149 static int decode_gtp_lst_set_up_pfc(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2150 static int decode_gtp_ps_handover_xid(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2151 static int decode_gtp_direct_tnl_flg(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2152 static int decode_gtp_ms_inf_chg_rep_act(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2153 static int decode_gtp_corrl_id(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2154 static int decode_gtp_fqdn(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2155 static int decode_gtp_evolved_allc_rtn_p1(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2156 static int decode_gtp_evolved_allc_rtn_p2(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2157 static int decode_gtp_extended_common_flgs(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2158 static int decode_gtp_uci(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2159 static int decode_gtp_csg_inf_rep_act(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2160 static int decode_gtp_csg_id(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2161 static int decode_gtp_cmi(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2162 static int decode_gtp_apn_ambr(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2163 static int decode_gtp_ue_network_cap(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2164 static int decode_gtp_ue_ambr(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2165 static int decode_gtp_apn_ambr_with_nsapi(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2166 static int decode_gtp_ggsn_back_off_time(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2167 static int decode_gtp_sig_pri_ind(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2168 static int decode_gtp_sig_pri_ind_w_nsapi(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2169 static int decode_gtp_higher_br_16mb_flg(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2170 static int decode_gtp_max_mbr_apn_ambr(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2171 static int decode_gtp_add_mm_ctx_srvcc(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2172 static int decode_gtp_add_flgs_srvcc(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2173 static int decode_gtp_stn_sr(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2174 static int decode_gtp_c_msisdn(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2175 static int decode_gtp_ext_ranap_cause(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2176 static int decode_gtp_ext_enodeb_id(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2177 static int decode_gtp_ext_sel_mode_w_nsapi(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2178 static int decode_gtp_ext_uli_timestamp(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2179 static int decode_gtp_ext_lhn_id_w_sapi(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2180 static int decode_gtp_ext_cn_op_sel_entity(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2181 static int decode_gtp_extended_common_flgs_II(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2182
2183 static int decode_gtp_bearer_cntrl_mod(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2184 static int decode_gtp_mbms_flow_id(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2185 static int decode_gtp_mbms_ip_mcast_dist(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2186 static int decode_gtp_mbms_dist_ack(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2187 static int decode_gtp_reliable_irat_ho_inf(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2188 static int decode_gtp_rfsp_index(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2189
2190 static int decode_gtp_chrg_addr(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2191 static int decode_gtp_rel_pack(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2192 static int decode_gtp_can_pack(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2193 static int decode_gtp_data_req(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2194 static int decode_gtp_data_resp(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2195 static int decode_gtp_node_addr(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2196 static int decode_gtp_priv_ext(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2197 static int decode_gtp_unknown(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2198
2199 typedef struct _gtp_opt {
2200     int optcode;
2201     int (*decode) (tvbuff_t *, int, packet_info *, proto_tree *, session_args_t *);
2202 } gtp_opt_t;
2203
2204 static const gtp_opt_t gtpopt[] = {
2205 /* 0x01 */  {GTP_EXT_CAUSE, decode_gtp_cause},
2206 /* 0x02 */  {GTP_EXT_IMSI, decode_gtp_imsi},
2207 /* 0x03 */  {GTP_EXT_RAI, decode_gtp_rai},
2208 /* 0x04 */  {GTP_EXT_TLLI, decode_gtp_tlli},
2209 /* 0x05 */  {GTP_EXT_PTMSI, decode_gtp_ptmsi},
2210 /* 0x06 */  {GTP_EXT_QOS_GPRS, decode_gtp_qos_gprs},
2211 /* 0x07 */
2212 /* 0x08 */  {GTP_EXT_REORDER, decode_gtp_reorder},
2213 /* 0x09 */  {GTP_EXT_AUTH_TRI, decode_gtp_auth_tri},
2214 /* 0x0a */
2215 /* 0x0b */  {GTP_EXT_MAP_CAUSE, decode_gtp_map_cause},
2216 /* 0x0c */  {GTP_EXT_PTMSI_SIG, decode_gtp_ptmsi_sig},
2217 /* 0x0d */  {GTP_EXT_MS_VALID, decode_gtp_ms_valid},
2218 /* 0x0e */  {GTP_EXT_RECOVER, decode_gtp_recovery},
2219 /* 0x0f */  {GTP_EXT_SEL_MODE, decode_gtp_sel_mode},
2220 /* 0x10 */  {GTP_EXT_16, decode_gtp_16},
2221 /* 0x11 */  {GTP_EXT_17, decode_gtp_17},
2222 /* 0x12 */  {GTP_EXT_18, decode_gtp_18},
2223 /* 0x13 */  {GTP_EXT_19, decode_gtp_19},
2224 /* 0x14 */  {GTP_EXT_NSAPI, decode_gtp_nsapi},
2225 /* 0x15 */  {GTP_EXT_RANAP_CAUSE, decode_gtp_ranap_cause},
2226 /* 0x16 */  {GTP_EXT_RAB_CNTXT, decode_gtp_rab_cntxt},
2227 /* 0x17 */  {GTP_EXT_RP_SMS, decode_gtp_rp_sms},
2228 /* 0x18 */  {GTP_EXT_RP, decode_gtp_rp},
2229 /* 0x19 */  {GTP_EXT_PKT_FLOW_ID, decode_gtp_pkt_flow_id},
2230 /* 0x1a */  {GTP_EXT_CHRG_CHAR, decode_gtp_chrg_char},
2231 /* 0x1b */  {GTP_EXT_TRACE_REF, decode_gtp_trace_ref},
2232 /* 0x1c */  {GTP_EXT_TRACE_TYPE, decode_gtp_trace_type},
2233 /* 0x1d */  {GTPv1_EXT_MS_REASON, decode_gtp_ms_reason},
2234
2235 /* 0x7e */  {GTP_EXT_TR_COMM, decode_gtp_tr_comm},
2236 /* 0x7f */  {GTP_EXT_CHRG_ID, decode_gtp_chrg_id},
2237 /* 0x80 */  {GTP_EXT_USER_ADDR, decode_gtp_user_addr},
2238 /* 0x81 */  {GTP_EXT_MM_CNTXT, decode_gtp_mm_cntxt},
2239 /* 0x82 */  {GTP_EXT_PDP_CNTXT, decode_gtp_pdp_cntxt},
2240 /* 0x83 */  {GTP_EXT_APN, decode_gtp_apn},
2241 /* 0x84 */  {GTP_EXT_PROTO_CONF, decode_gtp_proto_conf},
2242 /* 0x85 */  {GTP_EXT_GSN_ADDR, decode_gtp_gsn_addr},
2243 /* 0x86 */  {GTP_EXT_MSISDN, decode_gtp_msisdn},
2244 /* 0x87 */  {GTP_EXT_QOS_UMTS, decode_gtp_qos_umts},                            /* 3G */
2245 /* 0x88 */  {GTP_EXT_AUTH_QUI, decode_gtp_auth_qui},                            /* 3G */
2246 /* 0x89 */  {GTP_EXT_TFT, decode_gtp_tft},                                      /* 3G */
2247 /* 0x8a */  {GTP_EXT_TARGET_ID, decode_gtp_target_id},                          /* 3G */
2248 /* 0x8b */  {GTP_EXT_UTRAN_CONT, decode_gtp_utran_cont},                        /* 3G */
2249 /* 0x8c */  {GTP_EXT_RAB_SETUP, decode_gtp_rab_setup},                          /* 3G */
2250 /* 0x8d */  {GTP_EXT_HDR_LIST, decode_gtp_hdr_list},                            /* 3G */
2251 /* 0x8e */  {GTP_EXT_TRIGGER_ID, decode_gtp_trigger_id},                        /* 3G */
2252 /* 0x8f */  {GTP_EXT_OMC_ID, decode_gtp_omc_id},                                /* 3G */
2253     /* TS 29 060 V6.11.0 */
2254 /* 0x90 */  {GTP_EXT_RAN_TR_CONT, decode_gtp_ran_tr_cont},                      /* 7.7.43 */
2255 /* 0x91 */  {GTP_EXT_PDP_CONT_PRIO, decode_gtp_pdp_cont_prio},                  /* 7.7.45 */
2256 /* 0x92 */  {GTP_EXT_ADD_RAB_SETUP_INF, decode_gtp_add_rab_setup_inf},          /* 7.7.45A */
2257 /* 0x93 */  {GTP_EXT_SSGN_NO, decode_gtp_ssgn_no},                              /* 7.7.47 */
2258 /* 0x94 */  {GTP_EXT_COMMON_FLGS, decode_gtp_common_flgs},                      /* 7.7.48 */
2259 /* 0x95 */  {GTP_EXT_APN_RES, decode_gtp_apn_res},                              /* 3G */
2260 /* 0x96 */  {GTP_EXT_RA_PRIO_LCS, decode_gtp_ra_prio_lcs},                      /* 7.7.25B */
2261 /* 0x97 */  {GTP_EXT_RAT_TYPE, decode_gtp_rat_type},                            /* 3G */
2262 /* 0x98 */  {GTP_EXT_USR_LOC_INF, decode_gtp_usr_loc_inf},                      /* 7.7.51 */
2263 /* 0x99 */  {GTP_EXT_MS_TIME_ZONE, decode_gtp_ms_time_zone},                    /* 7.7.52 */
2264 /* 0x9a */  {GTP_EXT_IMEISV, decode_gtp_imeisv},                                /* 3G 7.7.53 */
2265 /* 0x9b */  {GTP_EXT_CAMEL_CHG_INF_CON, decode_gtp_camel_chg_inf_con},          /* 7.7.54 */
2266 /* 0x9c */  {GTP_EXT_MBMS_UE_CTX, decode_gtp_mbms_ue_ctx},                      /* 7.7.55 */
2267 /* 0x9d */  {GTP_EXT_TMGI, decode_gtp_tmgi},                                    /* 7.7.56 */
2268 /* 0x9e */  {GTP_EXT_RIM_RA, decode_gtp_rim_ra},                                /* 7.7.57 */
2269 /* 0x9f */  {GTP_EXT_MBMS_PROT_CONF_OPT, decode_gtp_mbms_prot_conf_opt},        /* 7.7.58 */
2270 /* 0xa0 */  {GTP_EXT_MBMS_SA, decode_gtp_mbms_sa},                              /* 7.7.60 */
2271 /* 0xa1 */  {GTP_EXT_SRC_RNC_PDP_CTX_INF, decode_gtp_src_rnc_pdp_ctx_inf},      /* 7.7.61 */
2272 /* 0xa2 */  {GTP_EXT_ADD_TRS_INF, decode_gtp_add_trs_inf},                      /* 7.7.62 */
2273 /* 0xa3 */  {GTP_EXT_HOP_COUNT, decode_gtp_hop_count},                          /* 7.7.63 */
2274 /* 0xa4 */  {GTP_EXT_SEL_PLMN_ID, decode_gtp_sel_plmn_id},                      /* 7.7.64 */
2275 /* 0xa5 */  {GTP_EXT_MBMS_SES_ID, decode_gtp_mbms_ses_id},                      /* 7.7.65 */
2276 /* 0xa6 */  {GTP_EXT_MBMS_2G_3G_IND, decode_gtp_mbms_2g_3g_ind},                /* 7.7.66 */
2277 /* 0xa7 */  {GTP_EXT_ENH_NSAPI, decode_gtp_enh_nsapi},                          /* 7.7.67 */
2278 /* 0xa8 */  {GTP_EXT_MBMS_SES_DUR, decode_gtp_mbms_ses_dur},                    /* 7.7.59 */
2279 /* 0xa9 */  {GTP_EXT_ADD_MBMS_TRS_INF, decode_gtp_add_mbms_trs_inf},            /* 7.7.68 */
2280 /* 0xaa */  {GTP_EXT_MBMS_SES_ID_REP_NO, decode_gtp_mbms_ses_id_rep_no},        /* 7.7.69 */
2281 /* 0xab */  {GTP_EXT_MBMS_TIME_TO_DATA_TR, decode_gtp_mbms_time_to_data_tr},    /* 7.7.70 */
2282 /* 0xac */  {GTP_EXT_PS_HO_REQ_CTX, decode_gtp_ps_ho_req_ctx},                  /* 7.7.71 */
2283 /* 0xad */  {GTP_EXT_BSS_CONT, decode_gtp_bss_cont},                            /* 7.7.72 */
2284 /* 0xae */  {GTP_EXT_CELL_ID, decode_gtp_cell_id},                              /* 7.7.73 */
2285 /* 0xaf */  {GTP_EXT_PDU_NO, decode_gtp_pdu_no},                                /* 7.7.74 */
2286 /* 0xb0 */  {GTP_EXT_BSSGP_CAUSE, decode_gtp_bssgp_cause},                      /* 7.7.75 */
2287 /* 0xb1 */  {GTP_EXT_REQ_MBMS_BEARER_CAP, decode_gtp_mbms_bearer_cap},          /* 7.7.76 */
2288 /* 0xb2 */  {GTP_EXT_RIM_ROUTING_ADDR_DISC, decode_gtp_rim_ra_disc},            /* 7.7.77 */
2289 /* 0xb3 */  {GTP_EXT_LIST_OF_SETUP_PFCS, decode_gtp_lst_set_up_pfc},            /* 7.7.78 */
2290 /* 0xb4 */  {GTP_EXT_PS_HANDOVER_XIP_PAR, decode_gtp_ps_handover_xid},          /* 7.7.79 */
2291 /* 0xb5 */  {GTP_EXT_MS_INF_CHG_REP_ACT, decode_gtp_ms_inf_chg_rep_act},        /* 7.7.80 */
2292 /* 0xb6 */  {GTP_EXT_DIRECT_TUNNEL_FLGS, decode_gtp_direct_tnl_flg},            /* 7.7.81 */
2293 /* 0xb7 */  {GTP_EXT_CORRELATION_ID, decode_gtp_corrl_id},                      /* 7.7.82 */
2294 /* 0xb8 */  {GTP_EXT_BEARER_CONTROL_MODE, decode_gtp_bearer_cntrl_mod},         /* 7.7.83 */
2295 /* 0xb9 */  {GTP_EXT_MBMS_FLOW_ID, decode_gtp_mbms_flow_id},                    /* 7.7.84 */
2296 /* 0xba */  {GTP_EXT_MBMS_IP_MCAST_DIST, decode_gtp_mbms_ip_mcast_dist},        /* 7.7.85 */
2297 /* 0xba */  {GTP_EXT_MBMS_DIST_ACK, decode_gtp_mbms_dist_ack},                  /* 7.7.86 */
2298 /* 0xbc */  {GTP_EXT_RELIABLE_IRAT_HO_INF, decode_gtp_reliable_irat_ho_inf},    /* 7.7.87 */
2299 /* 0xbd */  {GTP_EXT_RFSP_INDEX, decode_gtp_rfsp_index},                        /* 7.7.87 */
2300
2301 /* 0xbe */  {GTP_EXT_FQDN, decode_gtp_fqdn},                                    /* 7.7.90 */
2302 /* 0xbf */  {GTP_EXT_EVO_ALLO_RETE_P1, decode_gtp_evolved_allc_rtn_p1},         /* 7.7.91 */
2303 /* 0xc0 */  {GTP_EXT_EVO_ALLO_RETE_P2, decode_gtp_evolved_allc_rtn_p2},         /* 7.7.92 */
2304 /* 0xc1 */  {GTP_EXT_EXTENDED_COMMON_FLGS, decode_gtp_extended_common_flgs},    /* 7.7.93 */
2305 /* 0xc2 */  {GTP_EXT_UCI, decode_gtp_uci},                                      /* 7.7.94 */
2306 /* 0xc3 */  {GTP_EXT_CSG_INF_REP_ACT, decode_gtp_csg_inf_rep_act},              /* 7.7.95 */
2307 /* 0xc4 */  {GTP_EXT_CSG_ID, decode_gtp_csg_id},                                /* 7.7.96 */
2308 /* 0xc5 */  {GTP_EXT_CMI, decode_gtp_cmi},                                      /* 7.7.97 */
2309 /* 0xc6 */  {GTP_EXT_AMBR, decode_gtp_apn_ambr},                                /* 7.7.98 */
2310 /* 0xc7 */  {GTP_EXT_UE_NETWORK_CAP, decode_gtp_ue_network_cap},                /* 7.7.99 */
2311 /* 0xc8 */  {GTP_EXT_UE_AMBR, decode_gtp_ue_ambr},                              /* 7.7.100 */
2312 /* 0xc9 */  {GTP_EXT_APN_AMBR_WITH_NSAPI, decode_gtp_apn_ambr_with_nsapi},      /* 7.7.101 */
2313 /* 0xCA */  {GTP_EXT_GGSN_BACK_OFF_TIME, decode_gtp_ggsn_back_off_time},        /* 7.7.102 */
2314 /* 0xCB */  {GTP_EXT_SIG_PRI_IND, decode_gtp_sig_pri_ind},                      /* 7.7.103 */
2315 /* 0xCC */  {GTP_EXT_SIG_PRI_IND_W_NSAPI, decode_gtp_sig_pri_ind_w_nsapi},      /* 7.7.104 */
2316 /* 0xCD */  {GTP_EXT_HIGHER_BR_16MB_FLG, decode_gtp_higher_br_16mb_flg},        /* 7.7.105 */
2317 /* 0xCE */  {GTP_EXT_MAX_MBR_APN_AMBR, decode_gtp_max_mbr_apn_ambr},            /* 7.7.106 */
2318 /* 0xCF */  {GTP_EXT_ADD_MM_CTX_SRVCC, decode_gtp_add_mm_ctx_srvcc},            /* 7.7.107 */
2319 /* 0xD0 */  {GTP_EXT_ADD_FLGS_SRVCC, decode_gtp_add_flgs_srvcc},                /* 7.7.108 */
2320 /* 0xD1 */  {GTP_EXT_STN_SR, decode_gtp_stn_sr},                                /* 7.7.109 */
2321 /* 0xD2 */  {GTP_EXT_C_MSISDN, decode_gtp_c_msisdn},                            /* 7.7.110 */
2322 /* 0xD3 */  {GTP_EXT_EXT_RANAP_CAUSE, decode_gtp_ext_ranap_cause},              /* 7.7.111 */
2323 /* 0xD4 */  {GTP_EXT_ENODEB_ID, decode_gtp_ext_enodeb_id },                     /* 7.7.112 */
2324 /* 0xD5 */  {GTP_EXT_SEL_MODE_W_NSAPI, decode_gtp_ext_sel_mode_w_nsapi },       /* 7.7.113 */
2325 /* 0xD6 */  {GTP_EXT_ULI_TIMESTAMP, decode_gtp_ext_uli_timestamp },             /* 7.7.114 */
2326 /* 0xD7 */  {GTP_EXT_LHN_ID_W_SAPI, decode_gtp_ext_lhn_id_w_sapi },             /* 7.7.115 */
2327 /* 0xD8 */  {GTP_EXT_CN_OP_SEL_ENTITY, decode_gtp_ext_cn_op_sel_entity },       /* 7.7.116 */
2328
2329 /* 0xDA */      {GTP_EXT_EXT_COMMON_FLGS_II, decode_gtp_extended_common_flgs_II},       /* 7.7.118 */
2330
2331 /* 0xf9 */  {GTP_EXT_REL_PACK, decode_gtp_rel_pack },                           /* charging */
2332 /* 0xfa */  {GTP_EXT_CAN_PACK, decode_gtp_can_pack},                            /* charging */
2333 /* 0xfb */  {GTP_EXT_CHRG_ADDR, decode_gtp_chrg_addr},
2334
2335 /* 0xfc */  {GTP_EXT_DATA_REQ, decode_gtp_data_req},                           /* charging */
2336 /* 0xfd */  {GTP_EXT_DATA_RESP, decode_gtp_data_resp},                         /* charging */
2337 /* 0xfe */  {GTP_EXT_NODE_ADDR, decode_gtp_node_addr},
2338 /* 0xff */  {GTP_EXT_PRIV_EXT, decode_gtp_priv_ext},
2339     {0, decode_gtp_unknown}
2340 };
2341
2342 #define NUM_GTP_IES 255
2343 static gint ett_gtp_ies[NUM_GTP_IES];
2344
2345 static guint8 gtp_version = 0;
2346
2347 #define BCD2CHAR(d)         ((d) | 0x30)
2348
2349 static gchar *
2350 id_to_str(tvbuff_t *tvb, gint offset)
2351 {
2352     static gchar str[17] = "                ";
2353     guint8 bits8to5, bits4to1;
2354     int i, j;
2355     guint8 ad;
2356
2357     for (i = j = 0; i < 8; i++) {
2358         ad = tvb_get_guint8(tvb, offset + i);
2359         bits8to5 = hi_nibble(ad);
2360         bits4to1 = lo_nibble(ad);
2361         if (bits4to1 <= 9)
2362             str[j++] = BCD2CHAR(bits4to1);
2363         else
2364             str[j++] = ' ';
2365         if (bits8to5 <= 9)
2366             str[j++] = BCD2CHAR(bits8to5);
2367         else
2368             str[j++] = ' ';
2369     }
2370     str[j] = '\0';
2371     return str;
2372 }
2373
2374
2375 /* Next definitions and function check_field_presence checks if given field
2376  * in GTP packet is compliant with ETSI
2377  */
2378 typedef struct _header {
2379     guint8 code;
2380     guint8 presence;
2381 } ext_header;
2382
2383 typedef struct _message {
2384     guint8 code;
2385     ext_header fields[32];
2386 } _gtp_mess_items;
2387
2388 /* ---------------------
2389  * GPRS messages
2390  * ---------------------*/
2391 static _gtp_mess_items gprs_mess_items[] = {
2392
2393     {
2394         GTP_MSG_ECHO_REQ, {
2395             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2396             {0, 0}
2397         }
2398     },
2399     {
2400         GTP_MSG_ECHO_RESP, {
2401             {GTP_EXT_RECOVER, GTP_MANDATORY},
2402             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2403             {0, 0}
2404         }
2405     },
2406     {
2407         GTP_MSG_VER_NOT_SUPP, {
2408             {0, 0}
2409         }
2410     },
2411     {
2412         GTP_MSG_NODE_ALIVE_REQ, {
2413             {GTP_EXT_NODE_ADDR, GTP_MANDATORY},
2414             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2415             {0, 0}
2416         }
2417     },
2418     {
2419         GTP_MSG_NODE_ALIVE_RESP, {
2420             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2421             {0, 0}
2422         }
2423     },
2424     {
2425         GTP_MSG_REDIR_REQ, {
2426             {GTP_EXT_CAUSE, GTP_MANDATORY},
2427             {GTP_EXT_NODE_ADDR, GTP_OPTIONAL},
2428             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2429             {0, 0}
2430         }
2431     },
2432     {
2433         GTP_MSG_REDIR_RESP, {
2434             {GTP_EXT_CAUSE, GTP_MANDATORY},
2435             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2436             {0, 0}
2437         }
2438     },
2439     {
2440         GTP_MSG_CREATE_PDP_REQ, {
2441             {GTP_EXT_QOS_GPRS, GTP_MANDATORY},
2442             {GTP_EXT_RECOVER, GTP_OPTIONAL},
2443             {GTP_EXT_SEL_MODE, GTP_MANDATORY},
2444             {GTP_EXT_FLOW_LABEL, GTP_MANDATORY},
2445             {GTP_EXT_FLOW_SIG, GTP_MANDATORY},
2446             {GTP_EXT_MSISDN, GTP_MANDATORY},
2447             {GTP_EXT_USER_ADDR, GTP_MANDATORY},
2448             {GTP_EXT_APN, GTP_MANDATORY},
2449             {GTP_EXT_PROTO_CONF, GTP_OPTIONAL},
2450             {GTP_EXT_GSN_ADDR, GTP_MANDATORY},
2451             {GTP_EXT_GSN_ADDR, GTP_MANDATORY},
2452             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2453             {0, 0}
2454         }
2455     },
2456     {
2457         GTP_MSG_CREATE_PDP_RESP, {
2458             {GTP_EXT_CAUSE, GTP_MANDATORY},
2459             {GTP_EXT_QOS_GPRS, GTP_CONDITIONAL},
2460             {GTP_EXT_REORDER, GTP_CONDITIONAL},
2461             {GTP_EXT_RECOVER, GTP_OPTIONAL},
2462             {GTP_EXT_FLOW_LABEL, GTP_CONDITIONAL},
2463             {GTP_EXT_FLOW_SIG, GTP_CONDITIONAL},
2464             {GTP_EXT_CHRG_ID, GTP_CONDITIONAL},
2465             {GTP_EXT_USER_ADDR, GTP_CONDITIONAL},
2466             {GTP_EXT_PROTO_CONF, GTP_OPTIONAL},
2467             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL},
2468             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL},
2469             {GTP_EXT_CHRG_ADDR, GTP_OPTIONAL},
2470             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2471             {0, 0}
2472         }
2473     },
2474     {
2475         GTP_MSG_UPDATE_PDP_REQ, {
2476             {GTP_EXT_QOS_GPRS, GTP_MANDATORY},
2477             {GTP_EXT_RECOVER, GTP_OPTIONAL},
2478             {GTP_EXT_FLOW_LABEL, GTP_MANDATORY},
2479             {GTP_EXT_FLOW_SIG, GTP_MANDATORY},
2480             {GTP_EXT_GSN_ADDR, GTP_MANDATORY},
2481             {GTP_EXT_GSN_ADDR, GTP_MANDATORY},
2482             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2483             {0, 0},
2484         }
2485     },
2486     {
2487         GTP_MSG_UPDATE_PDP_RESP, {
2488             {GTP_EXT_CAUSE, GTP_MANDATORY},
2489             {GTP_EXT_QOS_GPRS, GTP_CONDITIONAL},
2490             {GTP_EXT_RECOVER, GTP_OPTIONAL},
2491             {GTP_EXT_FLOW_LABEL, GTP_CONDITIONAL},
2492             {GTP_EXT_FLOW_SIG, GTP_CONDITIONAL},
2493             {GTP_EXT_CHRG_ID, GTP_CONDITIONAL},
2494             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL},
2495             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL},
2496             {GTP_EXT_CHRG_ADDR, GTP_OPTIONAL},
2497             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2498             {0, 0}
2499         }
2500     },
2501     {
2502         GTP_MSG_DELETE_PDP_REQ, {
2503             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2504             {0, 0}
2505         }
2506     },
2507     {
2508         GTP_MSG_DELETE_PDP_RESP, {
2509             {GTP_EXT_CAUSE, GTP_MANDATORY},
2510             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2511             {0, 0},
2512         }
2513     },
2514     {
2515         GTP_MSG_INIT_PDP_CONTEXT_ACT_REQ, {
2516             {GTP_EXT_QOS_GPRS, GTP_MANDATORY},
2517             {GTP_EXT_RECOVER, GTP_OPTIONAL},
2518             {GTP_EXT_SEL_MODE, GTP_MANDATORY},
2519             {GTP_EXT_FLOW_LABEL, GTP_MANDATORY},
2520             {GTP_EXT_FLOW_SIG, GTP_MANDATORY},
2521             {GTP_EXT_USER_ADDR, GTP_MANDATORY},
2522             {GTP_EXT_APN, GTP_MANDATORY},
2523             {GTP_EXT_PROTO_CONF, GTP_OPTIONAL},
2524             {GTP_EXT_GSN_ADDR, GTP_MANDATORY},
2525             {GTP_EXT_GSN_ADDR, GTP_MANDATORY},
2526             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2527             {0, 0}
2528         }
2529     },
2530     {
2531         GTP_MSG_INIT_PDP_CONTEXT_ACT_RESP, {
2532             {GTP_EXT_CAUSE, GTP_MANDATORY},
2533             {GTP_EXT_QOS_GPRS, GTP_CONDITIONAL},
2534             {GTP_EXT_REORDER, GTP_CONDITIONAL},
2535             {GTP_EXT_RECOVER, GTP_OPTIONAL},
2536             {GTP_EXT_FLOW_LABEL, GTP_CONDITIONAL},
2537             {GTP_EXT_FLOW_SIG, GTP_CONDITIONAL},
2538             {GTP_EXT_CHRG_ID, GTP_CONDITIONAL},
2539             {GTP_EXT_USER_ADDR, GTP_CONDITIONAL},
2540             {GTP_EXT_PROTO_CONF, GTP_OPTIONAL},
2541             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL},
2542             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL},
2543             {GTP_EXT_CHRG_ADDR, GTP_OPTIONAL},
2544             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2545             {0, 0}
2546         }
2547     },
2548     {
2549         GTP_MSG_DELETE_AA_PDP_REQ, {
2550             {GTP_EXT_CAUSE, GTP_MANDATORY},
2551             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2552             {0, 0}
2553         }
2554     },
2555     {
2556         GTP_MSG_DELETE_AA_PDP_RESP, {
2557             {GTP_EXT_CAUSE, GTP_MANDATORY},
2558             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2559             {0, 0}
2560         }
2561     },
2562     {
2563         GTP_MSG_ERR_IND, {
2564             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2565             {0, 0}
2566         }
2567     },
2568     {
2569         GTP_MSG_PDU_NOTIFY_REQ, {
2570             {GTP_EXT_USER_ADDR, GTP_MANDATORY},
2571             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2572             {0, 0}
2573         }
2574     },
2575     {
2576         GTP_MSG_PDU_NOTIFY_RESP, {
2577             {GTP_EXT_CAUSE, GTP_MANDATORY},
2578             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2579             {0, 0}
2580         }
2581     },
2582     {
2583         GTP_MSG_PDU_NOTIFY_REJ_REQ, {
2584             {GTP_EXT_CAUSE, GTP_MANDATORY},
2585             {GTP_EXT_USER_ADDR, GTP_MANDATORY},
2586             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2587             {0, 0}
2588         }
2589     },
2590     {
2591         GTP_MSG_PDU_NOTIFY_REJ_RESP, {
2592             {GTP_EXT_CAUSE, GTP_MANDATORY},
2593             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2594             {0, 0}
2595         }
2596     },
2597     {
2598         GTP_MSG_SEND_ROUT_INFO_REQ, {
2599             {GTP_EXT_IMSI, GTP_MANDATORY},
2600             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2601             {0, 0}
2602         }
2603     },
2604     {
2605         GTP_MSG_SEND_ROUT_INFO_RESP, {
2606             {GTP_EXT_CAUSE, GTP_MANDATORY},
2607             {GTP_EXT_IMSI, GTP_MANDATORY},
2608             {GTP_EXT_MAP_CAUSE, GTP_OPTIONAL},
2609             {GTP_EXT_MS_REASON, GTP_OPTIONAL},
2610             {GTP_EXT_GSN_ADDR, GTP_OPTIONAL},
2611             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2612             {0, 0}
2613         }
2614     },
2615     {
2616         GTP_MSG_FAIL_REP_REQ, {
2617             {GTP_EXT_IMSI, GTP_MANDATORY},
2618             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2619             {0, 0}
2620         }
2621     },
2622     {
2623         GTP_MSG_FAIL_REP_RESP, {
2624             {GTP_EXT_CAUSE, GTP_MANDATORY},
2625             {GTP_EXT_MAP_CAUSE, GTP_OPTIONAL},
2626             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2627             {0, 0}
2628         }
2629     },
2630     {
2631         GTP_MSG_MS_PRESENT_REQ, {
2632             {GTP_EXT_IMSI, GTP_MANDATORY},
2633             {GTP_EXT_GSN_ADDR, GTP_MANDATORY},
2634             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2635             {0, 0}
2636         }
2637     },
2638     {
2639         GTP_MSG_MS_PRESENT_RESP, {
2640             {GTP_EXT_CAUSE, GTP_MANDATORY},
2641             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2642             {0, 0}
2643         }
2644     },
2645     {
2646         GTP_MSG_IDENT_REQ, {
2647             {GTP_EXT_RAI, GTP_MANDATORY},
2648             {GTP_EXT_PTMSI, GTP_MANDATORY},
2649             {GTP_EXT_PTMSI_SIG, GTP_OPTIONAL},
2650             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2651             {0, 0}
2652         }
2653     },
2654     {
2655         GTP_MSG_IDENT_RESP, {
2656             {GTP_EXT_CAUSE, GTP_MANDATORY},
2657             {GTP_EXT_IMSI, GTP_CONDITIONAL},
2658             {GTP_EXT_AUTH_TRI, GTP_OPTIONAL},
2659             {GTP_EXT_AUTH_QUI, GTP_OPTIONAL},
2660             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2661             {0, 0}
2662         }
2663     },
2664     {
2665         GTP_MSG_SGSN_CNTXT_REQ, {
2666             {GTP_EXT_IMSI, GTP_CONDITIONAL},
2667             {GTP_EXT_RAI, GTP_MANDATORY},
2668             {GTP_EXT_TLLI, GTP_MANDATORY},
2669             {GTP_EXT_PTMSI_SIG, GTP_OPTIONAL},
2670             {GTP_EXT_MS_VALID, GTP_OPTIONAL},
2671             {GTP_EXT_FLOW_SIG, GTP_MANDATORY},
2672             {0, 0}
2673         }
2674     },
2675     {
2676         GTP_MSG_SGSN_CNTXT_RESP, {
2677             {GTP_EXT_CAUSE, GTP_MANDATORY},
2678             {GTP_EXT_IMSI, GTP_CONDITIONAL},
2679             {GTP_EXT_FLOW_SIG, GTP_CONDITIONAL},
2680             {GTP_EXT_MM_CNTXT, GTP_CONDITIONAL},
2681             {GTP_EXT_PDP_CNTXT, GTP_CONDITIONAL},
2682             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2683             {0, 0}
2684         }
2685     },
2686     {
2687         GTP_MSG_SGSN_CNTXT_ACK, {
2688             {GTP_EXT_CAUSE, GTP_MANDATORY},
2689             {GTP_EXT_FLOW_II, GTP_CONDITIONAL},
2690             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL},
2691             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2692             {0, 0}
2693         }
2694     },
2695     {
2696         GTP_MSG_DATA_TRANSF_REQ, {
2697             {GTP_EXT_TR_COMM, GTP_MANDATORY},
2698             {GTP_EXT_DATA_REQ, GTP_CONDITIONAL},
2699             {GTP_EXT_REL_PACK, GTP_CONDITIONAL},
2700             {GTP_EXT_CAN_PACK, GTP_CONDITIONAL},
2701             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2702             {0, 0}
2703         }
2704     },
2705     {
2706         GTP_MSG_DATA_TRANSF_RESP, {
2707             {GTP_EXT_CAUSE, GTP_MANDATORY},
2708             {GTP_EXT_DATA_RESP, GTP_MANDATORY},
2709             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2710             {0, 0}
2711         }
2712     },
2713     {
2714         0, {
2715             {0, 0}
2716         }
2717     }
2718 };
2719
2720 /* -----------------------------
2721  * UMTS messages
2722  * -----------------------------*/
2723 static _gtp_mess_items umts_mess_items[] = {
2724     /* 7.2 Path Management Messages */
2725     {
2726         GTP_MSG_ECHO_REQ, {
2727             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2728             {0, 0}
2729         }
2730     },
2731     {
2732         GTP_MSG_ECHO_RESP, {
2733             {GTP_EXT_RECOVER, GTP_MANDATORY},
2734             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2735             {0, 0}
2736         }
2737     },
2738     {
2739         GTP_MSG_VER_NOT_SUPP, {
2740             {0, 0}
2741         }
2742     },
2743     {
2744         GTP_MSG_SUPP_EXT_HDR, {
2745             {GTP_EXT_HDR_LIST, GTP_MANDATORY},
2746             {0, 0}
2747         }
2748     },
2749     /* ??? */
2750     {
2751         GTP_MSG_NODE_ALIVE_REQ, {
2752             {GTP_EXT_NODE_ADDR, GTP_MANDATORY},
2753             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2754             {0, 0}
2755         }
2756     },
2757     {
2758         GTP_MSG_NODE_ALIVE_RESP, {
2759             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2760             {0, 0}
2761         }
2762     },
2763     {
2764         GTP_MSG_REDIR_REQ, {
2765             {GTP_EXT_CAUSE, GTP_MANDATORY},
2766             {GTP_EXT_NODE_ADDR, GTP_OPTIONAL},
2767             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2768             {0, 0}
2769         }
2770     },
2771     {
2772         GTP_MSG_REDIR_REQ, {
2773             {0, 0}
2774         }
2775     },
2776     /* 7.3 Tunnel Management Messages */
2777     {
2778         GTP_MSG_CREATE_PDP_REQ, {
2779             {GTP_EXT_IMSI, GTP_CONDITIONAL},
2780             /* RAI is in TS 29.060 V6.11.0 */
2781             {GTP_EXT_RAI, GTP_OPTIONAL},        /* Routeing Area Identity (RAI) Optional 7.7.3 */
2782             {GTP_EXT_RECOVER, GTP_OPTIONAL},
2783             {GTP_EXT_SEL_MODE, GTP_CONDITIONAL},
2784             {GTP_EXT_TEID, GTP_MANDATORY},
2785             {GTP_EXT_TEID_CP, GTP_CONDITIONAL},
2786             {GTP_EXT_NSAPI, GTP_MANDATORY},
2787             {GTP_EXT_NSAPI, GTP_CONDITIONAL},
2788             {GTP_EXT_CHRG_CHAR, GTP_OPTIONAL},
2789             {GTP_EXT_TRACE_REF, GTP_OPTIONAL},
2790             {GTP_EXT_TRACE_TYPE, GTP_OPTIONAL},
2791             {GTP_EXT_USER_ADDR, GTP_CONDITIONAL},
2792             {GTP_EXT_APN, GTP_CONDITIONAL},
2793             {GTP_EXT_PROTO_CONF, GTP_CONDITIONAL},
2794             {GTP_EXT_GSN_ADDR, GTP_MANDATORY},
2795             {GTP_EXT_GSN_ADDR, GTP_MANDATORY},
2796             {GTP_EXT_MSISDN, GTP_CONDITIONAL},
2797             {GTP_EXT_QOS_UMTS, GTP_MANDATORY},
2798             {GTP_EXT_TFT, GTP_CONDITIONAL},
2799             {GTP_EXT_TRIGGER_ID, GTP_OPTIONAL},
2800             {GTP_EXT_OMC_ID, GTP_OPTIONAL},
2801             /* TS 29.060 V6.11.0 */
2802             {GTP_EXT_APN_RES, GTP_OPTIONAL},
2803             {GTP_EXT_RAT_TYPE, GTP_OPTIONAL},
2804             {GTP_EXT_USR_LOC_INF, GTP_OPTIONAL},
2805             {GTP_EXT_MS_TIME_ZONE, GTP_OPTIONAL},
2806             {GTP_EXT_IMEISV, GTP_OPTIONAL},
2807             {GTP_EXT_CAMEL_CHG_INF_CON, GTP_OPTIONAL},
2808             {GTP_EXT_ADD_TRS_INF, GTP_OPTIONAL},
2809             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2810             {0, 0}
2811         }
2812     },
2813     {
2814         GTP_MSG_CREATE_PDP_RESP, {
2815             {GTP_EXT_CAUSE, GTP_MANDATORY},
2816             {GTP_EXT_REORDER, GTP_CONDITIONAL},
2817             {GTP_EXT_RECOVER, GTP_OPTIONAL},
2818             {GTP_EXT_TEID, GTP_CONDITIONAL},
2819             {GTP_EXT_TEID_CP, GTP_CONDITIONAL},
2820             {GTP_EXT_NSAPI, GTP_CONDITIONAL},
2821             {GTP_EXT_CHRG_ID, GTP_CONDITIONAL},
2822             {GTP_EXT_USER_ADDR, GTP_CONDITIONAL},
2823             {GTP_EXT_PROTO_CONF, GTP_OPTIONAL},
2824             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL},
2825             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL},
2826             {GTP_EXT_QOS_UMTS, GTP_CONDITIONAL},
2827             {GTP_EXT_CHRG_ADDR, GTP_OPTIONAL},
2828             /* TS 29.060 V6.11.0 */
2829             {GTP_EXT_CHRG_ADDR, GTP_OPTIONAL},   /* Alternative Charging Gateway Address Optional 7.7.44 */
2830             {GTP_EXT_COMMON_FLGS, GTP_OPTIONAL}, /* Common Flags Optional 7.7.48 */
2831             {GTP_EXT_APN_RES, GTP_OPTIONAL},     /* APN Restriction Optional 7.7.49 */
2832             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2833             {0, 0}
2834         }
2835     },
2836     {                           /* checked, SGSN -> GGSN */
2837         GTP_MSG_UPDATE_PDP_REQ, {
2838             {GTP_EXT_IMSI, GTP_CONDITIONAL},
2839             {GTP_EXT_RAI, GTP_OPTIONAL},         /* Routeing Area Identity (RAI) Optional 7.7.3 */
2840             {GTP_EXT_RECOVER, GTP_OPTIONAL},
2841             {GTP_EXT_TEID, GTP_MANDATORY},
2842             {GTP_EXT_TEID_CP, GTP_CONDITIONAL},
2843             {GTP_EXT_NSAPI, GTP_MANDATORY},
2844             {GTP_EXT_TRACE_REF, GTP_OPTIONAL},
2845             {GTP_EXT_TRACE_TYPE, GTP_OPTIONAL},
2846             {GTP_EXT_PROTO_CONF, GTP_OPTIONAL},  /* Protocol Configuration Options Optional 7.7.31 */
2847             {GTP_EXT_GSN_ADDR, GTP_MANDATORY},   /* SGSN Address for Control Plane Mandatory GSN Address 7.7.32 */
2848             {GTP_EXT_GSN_ADDR, GTP_MANDATORY},   /* SGSN Address for User Traffic Mandatory GSN Address 7.7.32 */
2849             {GTP_EXT_GSN_ADDR, GTP_OPTIONAL},    /* Alternative SGSN Address for Control Plane Conditional GSN Address 7.7.32 */
2850             {GTP_EXT_GSN_ADDR, GTP_OPTIONAL},    /* Alternative SGSN Address for User Traffic Conditional GSN Address 7.7.32 */
2851             {GTP_EXT_QOS_UMTS, GTP_MANDATORY},
2852             {GTP_EXT_TFT, GTP_OPTIONAL},
2853             {GTP_EXT_TRIGGER_ID, GTP_OPTIONAL},
2854             {GTP_EXT_OMC_ID, GTP_OPTIONAL},
2855             {GTP_EXT_COMMON_FLGS, GTP_OPTIONAL},        /* Common Flags Optional 7.7.48 */
2856             {GTP_EXT_RAT_TYPE, GTP_OPTIONAL},           /* RAT Type Optional 7.7.50 */
2857             {GTP_EXT_USR_LOC_INF, GTP_OPTIONAL},        /* User Location Information Optional 7.7.51 */
2858             {GTP_EXT_MS_TIME_ZONE, GTP_OPTIONAL},       /* MS Time Zone Optional 7.7.52 */
2859             {GTP_EXT_ADD_TRS_INF, GTP_OPTIONAL},        /* Additonal Trace Info Optional 7.7.62 */
2860             {GTP_EXT_DIRECT_TUNNEL_FLGS, GTP_OPTIONAL}, /* Direct Tunnel Flags     7.7.81 */
2861             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2862             {0, 0}
2863         }
2864     },
2865     {                           /* checked, GGSN -> SGSN */
2866         GTP_MSG_UPDATE_PDP_RESP, {
2867             {GTP_EXT_CAUSE, GTP_MANDATORY},
2868             {GTP_EXT_RECOVER, GTP_OPTIONAL},
2869             {GTP_EXT_TEID, GTP_CONDITIONAL},
2870             {GTP_EXT_TEID_CP, GTP_CONDITIONAL},
2871             {GTP_EXT_CHRG_ID, GTP_CONDITIONAL},
2872             {GTP_EXT_PROTO_CONF, GTP_OPTIONAL},  /* Protocol Configuration Options Optional 7.7.31 */
2873             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL},
2874             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL},
2875             {GTP_EXT_GSN_ADDR, GTP_OPTIONAL},    /* Alternative SGSN Address for Control Plane Conditional GSN Address 7.7.32 */
2876             {GTP_EXT_GSN_ADDR, GTP_OPTIONAL},    /* Alternative SGSN Address for User Traffic Conditional GSN Address 7.7.32 */
2877             {GTP_EXT_QOS_UMTS, GTP_CONDITIONAL},
2878             {GTP_EXT_CHRG_ADDR, GTP_OPTIONAL},
2879             {GTP_EXT_CHRG_ADDR, GTP_OPTIONAL},   /* Alternative Charging Gateway Address Optional 7.7.44 */
2880             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2881             {GTP_EXT_COMMON_FLGS, GTP_OPTIONAL}, /* Common Flags Optional 7.7.48 */
2882             {GTP_EXT_APN_RES, GTP_OPTIONAL},     /* APN Restriction Optional 7.7.49 */
2883             {0, 0}
2884         }
2885     },
2886     {
2887         GTP_MSG_DELETE_PDP_REQ, {
2888             {GTP_EXT_TEAR_IND, GTP_CONDITIONAL},
2889             {GTP_EXT_NSAPI, GTP_MANDATORY},
2890             {GTP_EXT_PROTO_CONF, GTP_OPTIONAL}, /* Protocol Configuration Options Optional 7.7.31 */
2891             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2892             {0, 0}
2893         }
2894     },
2895     {
2896         GTP_MSG_DELETE_PDP_RESP, {
2897             {GTP_EXT_CAUSE, GTP_MANDATORY},
2898             {GTP_EXT_PROTO_CONF, GTP_OPTIONAL}, /* Protocol Configuration Options Optional 7.7.31 */
2899             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2900             {0, 0}
2901         }
2902     },
2903     {
2904         GTP_MSG_ERR_IND, {
2905             {GTP_EXT_TEID, GTP_MANDATORY},
2906             {GTP_EXT_GSN_ADDR, GTP_MANDATORY},  /* GSN Address Mandatory 7.7.32 */
2907             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2908             {0, 0}
2909         }
2910     },
2911     {
2912         GTP_MSG_PDU_NOTIFY_REQ, {
2913             {GTP_EXT_IMSI, GTP_MANDATORY},
2914             {GTP_EXT_TEID_CP, GTP_MANDATORY},
2915             {GTP_EXT_USER_ADDR, GTP_MANDATORY},
2916             {GTP_EXT_APN, GTP_MANDATORY},
2917             {GTP_EXT_PROTO_CONF, GTP_OPTIONAL}, /* Protocol Configuration Options Optional 7.7.31 */
2918             {GTP_EXT_GSN_ADDR, GTP_MANDATORY},
2919             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2920             {0, 0}
2921         }
2922     },
2923     {
2924         GTP_MSG_PDU_NOTIFY_RESP, {
2925             {GTP_EXT_CAUSE, GTP_MANDATORY},
2926             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2927             {0, 0}
2928         }
2929     },
2930     {
2931         GTP_MSG_PDU_NOTIFY_REJ_REQ, {
2932             {GTP_EXT_CAUSE, GTP_MANDATORY},
2933             {GTP_EXT_TEID_CP, GTP_MANDATORY},
2934             {GTP_EXT_USER_ADDR, GTP_MANDATORY},
2935             {GTP_EXT_APN, GTP_MANDATORY},
2936             {GTP_EXT_PROTO_CONF, GTP_OPTIONAL}, /* Protocol Configuration Options Optional 7.7.31 */
2937             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2938             {0, 0}
2939         }
2940     },
2941     {
2942         GTP_MSG_PDU_NOTIFY_REJ_RESP, {
2943             {GTP_EXT_CAUSE, GTP_MANDATORY},
2944             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2945             {0, 0}
2946         }
2947     },
2948     /* 7.4 Location Management Messages */
2949     {
2950         GTP_MSG_SEND_ROUT_INFO_REQ, {
2951             {GTP_EXT_IMSI, GTP_MANDATORY},
2952             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2953             {0, 0}
2954         }
2955     },
2956     {
2957         GTP_MSG_SEND_ROUT_INFO_RESP, {
2958             {GTP_EXT_CAUSE, GTP_MANDATORY},
2959             {GTP_EXT_IMSI, GTP_MANDATORY},
2960             {GTP_EXT_MAP_CAUSE, GTP_OPTIONAL},
2961             {GTPv1_EXT_MS_REASON, GTP_OPTIONAL},
2962             {GTP_EXT_GSN_ADDR, GTP_OPTIONAL},
2963             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2964             {0, 0}
2965         }
2966     },
2967     {
2968         GTP_MSG_FAIL_REP_REQ, {
2969             {GTP_EXT_IMSI, GTP_MANDATORY},
2970             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2971             {0, 0}
2972         }
2973     },
2974     {
2975         GTP_MSG_FAIL_REP_RESP, {
2976             {GTP_EXT_CAUSE, GTP_MANDATORY},
2977             {GTP_EXT_MAP_CAUSE, GTP_OPTIONAL},
2978             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2979             {0, 0}
2980         }
2981     },
2982     {
2983         GTP_MSG_MS_PRESENT_REQ, {
2984             {GTP_EXT_IMSI, GTP_MANDATORY},
2985             {GTP_EXT_GSN_ADDR, GTP_MANDATORY},
2986             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2987             {0, 0}
2988         }
2989     },
2990     {
2991         GTP_MSG_MS_PRESENT_RESP, {
2992             {GTP_EXT_CAUSE, GTP_MANDATORY},
2993             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
2994             {0, 0}
2995         }
2996     },
2997     /* 7.5 Mobility Management Messages */
2998     {
2999         GTP_MSG_IDENT_REQ, {
3000             {GTP_EXT_RAI, GTP_MANDATORY},
3001             {GTP_EXT_PTMSI, GTP_MANDATORY},
3002             {GTP_EXT_PTMSI_SIG, GTP_CONDITIONAL},
3003             {GTP_EXT_GSN_ADDR, GTP_OPTIONAL},   /* SGSN Address for Control Plane Optional 7.7.32 */
3004             {GTP_EXT_HOP_COUNT, GTP_OPTIONAL},  /* Hop Counter Optional 7.7.63 */
3005             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
3006             {0, 0}
3007         }
3008     },
3009     {
3010         GTP_MSG_IDENT_RESP, {
3011             {GTP_EXT_CAUSE, GTP_MANDATORY},
3012             {GTP_EXT_IMSI, GTP_CONDITIONAL},
3013             {GTP_EXT_AUTH_TRI, GTP_CONDITIONAL},
3014             {GTP_EXT_AUTH_QUI, GTP_CONDITIONAL},
3015             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
3016             {0, 0}
3017         }
3018     },
3019     {
3020         GTP_MSG_SGSN_CNTXT_REQ, {
3021             {GTP_EXT_IMSI, GTP_CONDITIONAL},
3022             {GTP_EXT_RAI, GTP_MANDATORY},
3023             {GTP_EXT_TLLI, GTP_CONDITIONAL},
3024             {GTP_EXT_PTMSI, GTP_CONDITIONAL},
3025             {GTP_EXT_PTMSI_SIG, GTP_CONDITIONAL},
3026             {GTP_EXT_MS_VALID, GTP_OPTIONAL},
3027             {GTP_EXT_TEID_CP, GTP_MANDATORY},
3028             {GTP_EXT_GSN_ADDR, GTP_MANDATORY},
3029             {GTP_EXT_GSN_ADDR, GTP_OPTIONAL},   /* Alternative SGSN Address for Control Plane Optional 7.7.32 */
3030             {GTP_EXT_SSGN_NO, GTP_OPTIONAL},    /* SGSN Number Optional 7.7.47 */
3031             {GTP_EXT_HOP_COUNT, GTP_OPTIONAL},  /* Hop Counter Optional 7.7.63 */
3032             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
3033             {0, 0}
3034         }
3035     },
3036     {
3037         GTP_MSG_SGSN_CNTXT_RESP, {
3038             {GTP_EXT_CAUSE, GTP_MANDATORY},
3039             {GTP_EXT_IMSI, GTP_CONDITIONAL},
3040             {GTP_EXT_TEID_CP, GTP_CONDITIONAL},
3041             {GTP_EXT_RAB_CNTXT, GTP_CONDITIONAL},  /* RAB Context Conditional 7.7.19 */
3042             {GTP_EXT_RP_SMS, GTP_OPTIONAL},
3043             {GTP_EXT_RP, GTP_OPTIONAL},
3044             {GTP_EXT_PKT_FLOW_ID, GTP_OPTIONAL},
3045             {GTP_EXT_CHRG_CHAR, GTP_OPTIONAL},     /* CharingCharacteristics Optional 7.7.23 */
3046             {GTP_EXT_RA_PRIO_LCS, GTP_OPTIONAL},   /* Radio Priority LCS Optional 7.7.25B */
3047             {GTP_EXT_MM_CNTXT, GTP_CONDITIONAL},
3048             {GTP_EXT_PDP_CNTXT, GTP_CONDITIONAL},
3049             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL},
3050             {GTP_EXT_PDP_CONT_PRIO, GTP_OPTIONAL}, /* PDP Context Prioritization Optional 7.7.45 */
3051             {GTP_EXT_MBMS_UE_CTX, GTP_OPTIONAL},   /* MBMS UE Context Optional 7.7.55 */
3052             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
3053             {0, 0}
3054         }
3055     },
3056     {
3057         GTP_MSG_SGSN_CNTXT_ACK, {
3058             {GTP_EXT_CAUSE, GTP_MANDATORY},
3059             {GTP_EXT_TEID_II, GTP_CONDITIONAL},
3060             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL},
3061             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
3062             {0, 0}
3063         }
3064     },
3065     {
3066         GTP_MSG_FORW_RELOC_REQ, {
3067             {GTP_EXT_IMSI, GTP_MANDATORY},
3068             {GTP_EXT_TEID_CP, GTP_MANDATORY},
3069             {GTP_EXT_RANAP_CAUSE, GTP_MANDATORY},
3070             {GTP_EXT_CHRG_CHAR, GTP_OPTIONAL},     /* CharingCharacteristics Optional 7.7.23 */
3071             {GTP_EXT_MM_CNTXT, GTP_MANDATORY},
3072             {GTP_EXT_PDP_CNTXT, GTP_CONDITIONAL},
3073             {GTP_EXT_GSN_ADDR, GTP_MANDATORY},
3074             {GTP_EXT_TARGET_ID, GTP_MANDATORY},
3075             {GTP_EXT_UTRAN_CONT, GTP_MANDATORY},
3076             {GTP_EXT_PDP_CONT_PRIO, GTP_OPTIONAL}, /* PDP Context Prioritization Optional 7.7.45 */
3077             {GTP_EXT_MBMS_UE_CTX, GTP_OPTIONAL},   /* MBMS UE Context Optional 7.7.55 */
3078             {GTP_EXT_SEL_PLMN_ID, GTP_OPTIONAL},   /* Selected PLMN ID Optional 7.7.64 */
3079             {GTP_EXT_PS_HO_REQ_CTX, GTP_OPTIONAL}, /* PS Handover Request Context Optional 7.7.71 */
3080             {GTP_EXT_BSS_CONT, GTP_OPTIONAL},      /* BSS Container Optional 7.7.72 */
3081             {GTP_EXT_CELL_ID, GTP_OPTIONAL},       /* Cell Identification Optional 7.7.73 */
3082             {GTP_EXT_BSSGP_CAUSE, GTP_OPTIONAL},   /* BSSGP Cause Optional 7.7.75 */
3083             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
3084             {GTP_EXT_SSGN_NO, GTP_OPTIONAL},
3085             {0, 0}
3086         }
3087     },
3088     {
3089         GTP_MSG_FORW_RELOC_RESP, {
3090             {GTP_EXT_CAUSE, GTP_MANDATORY},
3091             {GTP_EXT_TEID_CP, GTP_CONDITIONAL},
3092             {GTP_EXT_TEID_II, GTP_CONDITIONAL},           /* Tunnel Endpoint Identifier Data II Optional 7.7.15 */
3093             {GTP_EXT_RANAP_CAUSE, GTP_CONDITIONAL},
3094             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL},
3095             {GTP_EXT_UTRAN_CONT, GTP_OPTIONAL},
3096             {GTP_EXT_RAB_SETUP, GTP_CONDITIONAL},
3097             {GTP_EXT_ADD_RAB_SETUP_INF, GTP_CONDITIONAL}, /* Additional RAB Setup Information Conditional 7.7.45A */
3098             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
3099             {0, 0}
3100         }
3101     },
3102     {
3103         GTP_MSG_FORW_RELOC_COMP, {
3104             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
3105             {0, 0}
3106         }
3107     },
3108     {
3109         GTP_MSG_RELOC_CANCEL_REQ, {
3110             {GTP_EXT_IMSI, GTP_MANDATORY},
3111             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
3112             {0, 0}
3113         }
3114     },
3115     {
3116         GTP_MSG_RELOC_CANCEL_RESP, {
3117             {GTP_EXT_CAUSE, GTP_MANDATORY},
3118             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
3119             {0, 0}
3120         }
3121     },
3122     {
3123         GTP_MSG_FORW_RELOC_ACK, {
3124             {GTP_EXT_CAUSE, GTP_MANDATORY},
3125             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
3126             {0, 0}
3127         }
3128     },
3129     {
3130         GTP_MSG_FORW_SRNS_CNTXT_ACK, {
3131             {GTP_EXT_CAUSE, GTP_MANDATORY},
3132             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
3133             {0, 0}
3134         }
3135     },
3136     {
3137         GTP_MSG_FORW_SRNS_CNTXT, {
3138             {GTP_EXT_RAB_CNTXT, GTP_MANDATORY},
3139             {GTP_EXT_SRC_RNC_PDP_CTX_INF, GTP_OPTIONAL}, /* Source RNC PDCP context info Optional 7.7.61 */
3140             {GTP_EXT_PDU_NO, GTP_OPTIONAL},              /* PDU Numbers Optional 7.7.74 */
3141             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
3142             {0, 0}
3143         }
3144     },
3145
3146 /*      7.5.14 RAN Information Management Messages */
3147     {
3148         GTP_MSG_RAN_INFO_RELAY, {
3149             {GTP_EXT_RAN_TR_CONT, GTP_MANDATORY},        /* RAN Transparent Container Mandatory 7.7.43 */
3150             {GTP_EXT_RIM_RA, GTP_OPTIONAL},              /* RIM Routing Address Optional 7.7.57 */
3151             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
3152             {0, 0}
3153         }
3154     },
3155 /* 7.5A MBMS Messages
3156  * 7.5A.1 UE Specific MBMS Messages
3157  */
3158     {
3159         GTP_MBMS_NOTIFY_REQ, {
3160             {GTP_EXT_IMSI, GTP_MANDATORY},              /* IMSI Mandatory 7.7.2 */
3161             {GTP_EXT_TEID_CP, GTP_MANDATORY},           /* Tunnel Endpoint Identifier Control Plane Mandatory 7.7.14 */
3162             {GTP_EXT_NSAPI, GTP_MANDATORY},             /* NSAPI Mandatory 7.7.17 */
3163             {GTP_EXT_USER_ADDR, GTP_MANDATORY},         /* End User Address Mandatory 7.7.27 */
3164             {GTP_EXT_APN, GTP_MANDATORY},               /* Access Point Name Mandatory 7.7.30 */
3165             {GTP_EXT_GSN_ADDR, GTP_MANDATORY},          /* GGSN Address for Control Plane Mandatory 7.7.32 */
3166             {GTP_EXT_MBMS_PROT_CONF_OPT, GTP_OPTIONAL}, /* MBMS Protocol Configuration Options Optional 7.7.58 */
3167             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},           /* Private Extension Optional 7.7.46 */
3168             {0, 0}
3169         }
3170     },
3171     {
3172         GTP_MBMS_NOTIFY_RES, {
3173             {GTP_EXT_CAUSE, GTP_MANDATORY},     /* Cause Mandatory 7.7.1 */
3174             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
3175             {0, 0}
3176         }
3177     },
3178     {
3179         GTP_MBMS_NOTIFY_REJ_REQ, {
3180             {GTP_EXT_CAUSE, GTP_MANDATORY},     /* Cause Mandatory 7.7.1 */
3181             {GTP_EXT_TEID_CP, GTP_MANDATORY},   /* Tunnel Endpoint Identifier Control Plane Mandatory 7.7.14 */
3182             {GTP_EXT_NSAPI, GTP_MANDATORY},     /* NSAPI Mandatory 7.7.17 */
3183             {GTP_EXT_USER_ADDR, GTP_MANDATORY}, /* End User Address Mandatory 7.7.27 */
3184             {GTP_EXT_APN, GTP_MANDATORY},       /* Access Point Name Mandatory 7.7.30 */
3185             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
3186             {0, 0}
3187         }
3188     },
3189     {
3190         GTP_MBMS_NOTIFY_REJ_RES, {
3191             {GTP_EXT_CAUSE, GTP_MANDATORY},     /* Cause Mandatory 7.7.1 */
3192             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
3193             {0, 0}
3194         }
3195     },
3196     {
3197         GTP_CREATE_MBMS_CNTXT_REQ, {
3198             {GTP_EXT_IMSI, GTP_CONDITIONAL},            /* IMSI Conditional 7.7.2 */
3199             {GTP_EXT_RAI, GTP_MANDATORY},               /* Routeing Area Identity (RAI) Mandatory 7.7.3 */
3200             {GTP_EXT_RECOVER, GTP_OPTIONAL},            /* Recovery Optional 7.7.11 */
3201             {GTP_EXT_SEL_MODE, GTP_CONDITIONAL},        /* Selection mode Conditional 7.7.12 */
3202             {GTP_EXT_TEID_CP, GTP_CONDITIONAL},         /* Tunnel Endpoint Identifier Control Plane Conditional 7.7.14 */
3203             {GTP_EXT_TRACE_REF, GTP_OPTIONAL},          /* Trace Reference Optional 7.7.24 */
3204             {GTP_EXT_TRACE_TYPE, GTP_OPTIONAL},         /* Trace Type Optional 7.7.25 */
3205             {GTP_EXT_USER_ADDR, GTP_MANDATORY},         /* End User Address Mandatory 7.7.27 */
3206             {GTP_EXT_APN, GTP_MANDATORY},               /* Access Point Name Mandatory 7.7.30 */
3207             {GTP_EXT_GSN_ADDR, GTP_MANDATORY},          /* SGSN Address for signalling Mandatory GSN Address 7.7.32 */
3208             {GTP_EXT_MSISDN, GTP_CONDITIONAL},          /* MSISDN Conditional 7.7.33 */
3209             {GTP_EXT_TRIGGER_ID, GTP_OPTIONAL},         /* Trigger Id Optional 7.7.41 */
3210             {GTP_EXT_OMC_ID, GTP_OPTIONAL},             /* OMC Identity Optional 7.7.42 */
3211             {GTP_EXT_RAT_TYPE, GTP_OPTIONAL},           /* RAT Type Optional 7.7.50 */
3212             {GTP_EXT_USR_LOC_INF, GTP_OPTIONAL},        /* User Location Information Optional 7.7.51 */
3213             {GTP_EXT_MS_TIME_ZONE, GTP_OPTIONAL},       /* MS Time Zone Optional 7.7.52 */
3214             {GTP_EXT_IMEISV, GTP_OPTIONAL},             /* IMEI(SV) Optional 7.7.53 */
3215             {GTP_EXT_MBMS_PROT_CONF_OPT, GTP_OPTIONAL}, /* MBMS Protocol Configuration Options Optional 7.7.58 */
3216             {GTP_EXT_ADD_TRS_INF, GTP_OPTIONAL},        /* Additonal Trace Info Optional 7.7.62 */
3217             {GTP_EXT_ENH_NSAPI, GTP_MANDATORY},         /* Enhanced NSAPI Mandatory 7.7.67 */
3218             {GTP_EXT_ADD_MBMS_TRS_INF, GTP_OPTIONAL},   /* Additional MBMS Trace Info Optional 7.7.68 */
3219             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
3220             {0, 0}
3221         }
3222     },
3223     {
3224         GTP_CREATE_MBMS_CNTXT_RES, {
3225             {GTP_EXT_CAUSE, GTP_MANDATORY},             /* Cause Mandatory 7.7.1 */
3226             {GTP_EXT_RECOVER, GTP_OPTIONAL},            /* Recovery Optional 7.7.11 */
3227             {GTP_EXT_TEID_CP, GTP_CONDITIONAL},         /* Tunnel Endpoint Identifier Control Plane Conditional 7.7.14 */
3228             {GTP_EXT_CHRG_ID, GTP_CONDITIONAL},         /* Charging ID Conditional 7.7.26 */
3229             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL},        /* GGSN Address for Control Plane Conditional GSN Address 7.7.32 */
3230             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL},        /* Alternative GGSN Address for Control Plane Conditional GSN Address 7.7.32 */
3231             {GTP_EXT_CHRG_ADDR, GTP_OPTIONAL},          /* Charging Gateway Address Optional 7.7.44 */
3232             {GTP_EXT_CHRG_ADDR, GTP_OPTIONAL},          /* Alternative Charging Gateway Address Optional 7.7.44 */
3233             {GTP_EXT_MBMS_PROT_CONF_OPT, GTP_OPTIONAL}, /* MBMS Protocol Configuration Options Optional 7.7.58 */
3234             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
3235             {0, 0}
3236         }
3237     },
3238     {
3239         GTP_UPD_MBMS_CNTXT_REQ, {
3240             {GTP_EXT_IMSI, GTP_CONDITIONAL},          /* IMSI Conditional 7.7.2 */
3241             {GTP_EXT_RAI, GTP_MANDATORY},             /* Routeing Area Identity (RAI) Mandatory 7.7.3 */
3242             {GTP_EXT_RECOVER, GTP_OPTIONAL},          /* Recovery Optional 7.7.11 */
3243             {GTP_EXT_TEID_CP, GTP_CONDITIONAL},       /* Tunnel Endpoint Identifier Control Plane Conditional 7.7.14 */
3244             {GTP_EXT_TRACE_REF, GTP_OPTIONAL},        /* Trace Reference Optional 7.7.24 */
3245             {GTP_EXT_TRACE_TYPE, GTP_OPTIONAL},       /* Trace Type Optional 7.7.25 */
3246             {GTP_EXT_GSN_ADDR, GTP_MANDATORY},        /* SGSN Address for Control Plane Mandatory GSN Address 7.7.32 */
3247             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL},      /* Alternative SGSN Address for Control Plane Conditional GSN Address 7.7.32 */
3248             {GTP_EXT_TRIGGER_ID, GTP_OPTIONAL},       /* Trigger Id Optional 7.7.41 */
3249             {GTP_EXT_OMC_ID, GTP_OPTIONAL},           /* OMC Identity Optional 7.7.42 */
3250             {GTP_EXT_RAT_TYPE, GTP_OPTIONAL},         /* RAT Type Optional 7.7.50 */
3251             {GTP_EXT_USR_LOC_INF, GTP_OPTIONAL},      /* User Location Information Optional 7.7.51 */
3252             {GTP_EXT_MS_TIME_ZONE, GTP_OPTIONAL},     /* MS Time Zone Optional 7.7.52 */
3253             {GTP_EXT_ADD_TRS_INF, GTP_OPTIONAL},      /* Additional Trace Info Optional 7.7.62 */
3254             {GTP_EXT_ENH_NSAPI, GTP_MANDATORY},       /* Enhanced NSAPI Mandatory 7.7.67 */
3255             {GTP_EXT_ADD_MBMS_TRS_INF, GTP_OPTIONAL}, /* Additional MBMS Trace Info Optional 7.7.68 */
3256             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
3257             {0, 0}
3258         }
3259     },
3260     {
3261         GTP_UPD_MBMS_CNTXT_RES, {
3262             {GTP_EXT_CAUSE, GTP_MANDATORY},      /* Cause Mandatory 7.7.1 */
3263             {GTP_EXT_RECOVER, GTP_OPTIONAL},     /* Recovery Optional 7.7.11 */
3264             {GTP_EXT_TEID_CP, GTP_MANDATORY},    /* Tunnel Endpoint Identifier Control Plane Conditional 7.7.14 */
3265             {GTP_EXT_CHRG_ID, GTP_CONDITIONAL},  /* Charging ID Conditional 7.7.26 */
3266             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL}, /* GGSN Address for Control Plane Conditional GSN Address 7.7.32 */
3267             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL}, /* Alternative GGSN Address for Control Plane Conditional GSN Address 7.7.32 */
3268             {GTP_EXT_CHRG_ADDR, GTP_OPTIONAL},   /* Charging Gateway Address Optional 7.7.44 */
3269             {GTP_EXT_CHRG_ADDR, GTP_OPTIONAL},   /* Alternative Charging Gateway Address Optional 7.7.44 */
3270             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},    /* Private Extension Optional 7.7.46 */
3271             {0, 0}
3272         }
3273     },
3274     {
3275         GTP_DEL_MBMS_CNTXT_REQ, {
3276             {GTP_EXT_IMSI, GTP_CONDITIONAL},            /* IMSI Conditional 7.7.2 */
3277             {GTP_EXT_TEID_CP, GTP_MANDATORY},           /* Tunnel Endpoint Identifier Control Plane Conditional 7.7.14 */
3278             {GTP_EXT_USER_ADDR, GTP_CONDITIONAL},       /* End User Address Conditional 7.7.27 */
3279             {GTP_EXT_APN, GTP_CONDITIONAL},             /* Access Point Name Conditional 7.7.30 */
3280             {GTP_EXT_MBMS_PROT_CONF_OPT, GTP_OPTIONAL}, /* MBMS Protocol Configuration Options Optional 7.7.58 */
3281             {GTP_EXT_ENH_NSAPI, GTP_MANDATORY},         /* Enhanced NSAPI Conditional 7.7.67 */
3282             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},           /* Private Extension Optional 7.7.46 */
3283             {0, 0}
3284         }
3285     },
3286     {
3287         GTP_DEL_MBMS_CNTXT_RES, {
3288             {GTP_EXT_CAUSE, GTP_MANDATORY},             /* Cause Mandatory 7.7.1 */
3289             {GTP_EXT_MBMS_PROT_CONF_OPT, GTP_OPTIONAL}, /* MBMS Protocol Configuration Options Optional 7.7.58 */
3290             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},
3291             {0, 0}
3292         }
3293     },
3294     {
3295         GTP_MBMS_REG_REQ, {
3296             {GTP_EXT_USER_ADDR, GTP_MANDATORY}, /* End User Address Mandatory 7.7.27 */
3297             {GTP_EXT_APN, GTP_MANDATORY},       /* Access Point Name Mandatory 7.7.30 */
3298             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},   /* Private Extension Optional 7.7.46 */
3299             {0, 0}
3300         }
3301     },
3302     {
3303         GTP_MBMS_REG_RES, {
3304             {GTP_EXT_CAUSE, GTP_MANDATORY},     /* Cause Mandatory 7.7.1 */
3305             {GTP_EXT_TMGI, GTP_MANDATORY},      /* Temporary Mobile Group Identity (TMGI) Conditional 7.7.56 */
3306             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},   /* Private Extension Optional 7.7.46 */
3307             {0, 0}
3308         }
3309     },
3310     {
3311         GTP_MBMS_DE_REG_REQ, {
3312             {GTP_EXT_USER_ADDR, GTP_MANDATORY}, /* End User Address Mandatory 7.7.27 */
3313             {GTP_EXT_APN, GTP_MANDATORY},       /* Access Point Name Mandatory 7.7.30 */
3314             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},   /* Private Extension Optional 7.7.46 */
3315             {0, 0}
3316         }
3317     },
3318     {
3319         GTP_MBMS_DE_REG_RES, {
3320             {GTP_EXT_CAUSE, GTP_MANDATORY},     /* Cause Mandatory 7.7.1 */
3321             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},   /* Private Extension Optional 7.7.46 */
3322             {0, 0}
3323         }
3324     },
3325     {
3326         GTP_MBMS_SES_START_REQ, {
3327             {GTP_EXT_RECOVER, GTP_OPTIONAL},               /* Recovery Optional 7.7.11 */
3328             {GTP_EXT_TEID_CP, GTP_CONDITIONAL},            /* Tunnel Endpoint Identifier Control Plane Conditional 7.7.14 */
3329             {GTP_EXT_USER_ADDR, GTP_MANDATORY},            /* End User Address Mandatory 7.7.27 */
3330             {GTP_EXT_APN, GTP_MANDATORY},                  /* Access Point Name Mandatory 7.7.30 */
3331             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL},           /* GGSN Address for Control Plane Conditional GSN Address 7.7.32 */
3332             {GTP_EXT_QOS_UMTS, GTP_MANDATORY},             /* Quality of Service Profile Mandatory 7.7.34 */
3333             {GTP_EXT_COMMON_FLGS, GTP_OPTIONAL},           /* Common Flags Mandatory 7.7.48 */
3334             {GTP_EXT_TMGI, GTP_MANDATORY},                 /* Temporary Mobile Group Identity (TMGI) Mandatory 7.7.56 */
3335             {GTP_EXT_MBMS_SES_DUR, GTP_MANDATORY},         /* MBMS Session Duration Mandatory 7.7.59 */
3336             {GTP_EXT_MBMS_SA, GTP_MANDATORY},              /* MBMS Service Area Mandatory 7.7.60 */
3337             {GTP_EXT_MBMS_SES_ID, GTP_OPTIONAL},           /* MBMS Session Identifier Optional 7.7.65 */
3338             {GTP_EXT_MBMS_2G_3G_IND, GTP_MANDATORY},       /* MBMS 2G/3G Indicator Mandatory 7.7.66 */
3339             {GTP_EXT_MBMS_SES_ID_REP_NO, GTP_OPTIONAL},    /* MBMS Session Identity Repetition Number Optional 7.7.69 */
3340             {GTP_EXT_MBMS_TIME_TO_DATA_TR, GTP_MANDATORY}, /* MBMS Time To Data Transfer Mandatory 7.7.70 */
3341             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},              /* Private Extension Optional 7.7.46 */
3342             {0, 0}
3343         }
3344     },
3345     {
3346         GTP_MBMS_SES_START_RES, {
3347             {GTP_EXT_CAUSE, GTP_MANDATORY},      /* Cause Mandatory 7.7.1 */
3348             {GTP_EXT_RECOVER, GTP_OPTIONAL},     /* Recovery Optional 7.7.11 */
3349             {GTP_EXT_TEID, GTP_CONDITIONAL},     /* Tunnel Endpoint Identifier Data I Conditional 7.7.13 */
3350             {GTP_EXT_TEID_CP, GTP_CONDITIONAL},  /* Tunnel Endpoint Identifier Control Plane Conditional 7.7.14 */
3351             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL}, /* SGSN Address for Control Plane Conditional GSN Address 7.7.32 */
3352             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL}, /* SGSN Address for user traffic Conditional GSN Address 7.7.32 */
3353             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},    /* Private Extension Optional 7.7.46 */
3354             {0, 0}
3355         }
3356     },
3357     {
3358         GTP_MBMS_SES_STOP_REQ, {
3359             {GTP_EXT_USER_ADDR, GTP_MANDATORY}, /* End User Address Mandatory 7.7.27 */
3360             {GTP_EXT_APN, GTP_MANDATORY},       /* Access Point Name Mandatory 7.7.30 */
3361             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},   /* Private Extension Optional 7.7.46 */
3362             {0, 0}
3363         }
3364     },
3365     {
3366         GTP_MBMS_SES_STOP_RES, {
3367             {GTP_EXT_CAUSE, GTP_MANDATORY},     /* Cause Mandatory 7.7.1 */
3368             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL},   /* Private Extension Optional 7.7.46 */
3369             {0, 0}
3370         }
3371     },
3372     {
3373         0, {
3374             {0, 0}
3375         }
3376     }
3377 };
3378
3379 /* Data structure attached to a  conversation,
3380         to keep track of request/response-pairs
3381  */
3382 typedef struct gtp_conv_info_t {
3383     struct gtp_conv_info_t *next;
3384     GHashTable             *unmatched;
3385     GHashTable             *matched;
3386 } gtp_conv_info_t;
3387
3388 static gtp_conv_info_t *gtp_info_items = NULL;
3389
3390 static guint
3391 gtp_sn_hash(gconstpointer k)
3392 {
3393     const gtp_msg_hash_t *key = (const gtp_msg_hash_t *)k;
3394
3395     return key->seq_nr;
3396 }
3397
3398 static gint
3399 gtp_sn_equal_matched(gconstpointer k1, gconstpointer k2)
3400 {
3401     const gtp_msg_hash_t *key1 = (const gtp_msg_hash_t *)k1;
3402     const gtp_msg_hash_t *key2 = (const gtp_msg_hash_t *)k2;
3403
3404     if ( key1->req_frame && key2->req_frame && (key1->req_frame != key2->req_frame) ) {
3405         return 0;
3406     }
3407
3408     if ( key1->rep_frame && key2->rep_frame && (key1->rep_frame != key2->rep_frame) ) {
3409         return 0;
3410     }
3411
3412     return key1->seq_nr == key2->seq_nr;
3413 }
3414
3415 static gint
3416 gtp_sn_equal_unmatched(gconstpointer k1, gconstpointer k2)
3417 {
3418     const gtp_msg_hash_t *key1 = (const gtp_msg_hash_t *)k1;
3419     const gtp_msg_hash_t *key2 = (const gtp_msg_hash_t *)k2;
3420
3421     return key1->seq_nr == key2->seq_nr;
3422 }
3423
3424 static gtp_msg_hash_t *
3425 gtp_match_response(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, gint seq_nr, guint msgtype, gtp_conv_info_t *gtp_info, guint8 last_cause)
3426 {
3427     gtp_msg_hash_t   gcr, *gcrp = NULL;
3428     guint32 *session;
3429     gcr.seq_nr=seq_nr;
3430
3431     switch (msgtype) {
3432     case GTP_MSG_ECHO_REQ:
3433     case GTP_MSG_CREATE_PDP_REQ:
3434     case GTP_MSG_UPDATE_PDP_REQ:
3435     case GTP_MSG_DELETE_PDP_REQ:
3436     case GTP_MSG_FORW_RELOC_REQ:
3437         gcr.is_request=TRUE;
3438         gcr.req_frame=pinfo->num;
3439         gcr.rep_frame=0;
3440         break;
3441     case GTP_MSG_ECHO_RESP:
3442     case GTP_MSG_CREATE_PDP_RESP:
3443     case GTP_MSG_UPDATE_PDP_RESP:
3444     case GTP_MSG_DELETE_PDP_RESP:
3445     case GTP_MSG_FORW_RELOC_RESP:
3446         gcr.is_request=FALSE;
3447         gcr.req_frame=0;
3448         gcr.rep_frame=pinfo->num;
3449         break;
3450     default:
3451         gcr.is_request=FALSE;
3452         gcr.req_frame=0;
3453         gcr.rep_frame=0;
3454         break;
3455     }
3456
3457     gcrp = (gtp_msg_hash_t *)g_hash_table_lookup(gtp_info->matched, &gcr);
3458
3459     if (gcrp) {
3460
3461         gcrp->is_request=gcr.is_request;
3462
3463     } else {
3464
3465         /*no match, let's try to make one*/
3466         switch (msgtype) {
3467         case GTP_MSG_ECHO_REQ:
3468         case GTP_MSG_CREATE_PDP_REQ:
3469         case GTP_MSG_UPDATE_PDP_REQ:
3470         case GTP_MSG_DELETE_PDP_REQ:
3471         case GTP_MSG_FORW_RELOC_REQ:
3472             gcr.seq_nr=seq_nr;
3473
3474             gcrp=(gtp_msg_hash_t *)g_hash_table_lookup(gtp_info->unmatched, &gcr);
3475             if (gcrp) {
3476                 g_hash_table_remove(gtp_info->unmatched, gcrp);
3477             }
3478             /* if we can't reuse the old one, grab a new chunk */
3479             if (!gcrp) {
3480                 gcrp = wmem_new(wmem_file_scope(), gtp_msg_hash_t);
3481             }
3482             gcrp->seq_nr=seq_nr;
3483             gcrp->req_frame = pinfo->num;
3484             gcrp->req_time = pinfo->abs_ts;
3485             gcrp->rep_frame = 0;
3486             gcrp->msgtype = msgtype;
3487             gcrp->is_request = TRUE;
3488             g_hash_table_insert(gtp_info->unmatched, gcrp, gcrp);
3489             return NULL;
3490             break;
3491         case GTP_MSG_ECHO_RESP:
3492         case GTP_MSG_CREATE_PDP_RESP:
3493         case GTP_MSG_UPDATE_PDP_RESP:
3494         case GTP_MSG_DELETE_PDP_RESP:
3495         case GTP_MSG_FORW_RELOC_RESP:
3496             gcr.seq_nr=seq_nr;
3497             gcrp=(gtp_msg_hash_t *)g_hash_table_lookup(gtp_info->unmatched, &gcr);
3498
3499             if (gcrp) {
3500                 if (!gcrp->rep_frame) {
3501                     g_hash_table_remove(gtp_info->unmatched, gcrp);
3502                     gcrp->rep_frame=pinfo->num;
3503                     gcrp->is_request=FALSE;
3504                     g_hash_table_insert(gtp_info->matched, gcrp, gcrp);
3505                 }
3506             }
3507             break;
3508         default:
3509             break;
3510         }
3511     }
3512
3513     /* we have found a match */
3514     if (gcrp) {
3515         proto_item *it;
3516
3517
3518         if (gcrp->is_request) {
3519             it = proto_tree_add_uint(tree, hf_gtp_response_in, tvb, 0, 0, gcrp->rep_frame);
3520             PROTO_ITEM_SET_GENERATED(it);
3521         } else {
3522             nstime_t ns;
3523
3524             it = proto_tree_add_uint(tree, hf_gtp_response_to, tvb, 0, 0, gcrp->req_frame);
3525             PROTO_ITEM_SET_GENERATED(it);
3526             nstime_delta(&ns, &pinfo->abs_ts, &gcrp->req_time);
3527             it = proto_tree_add_time(tree, hf_gtp_time, tvb, 0, 0, &ns);
3528             PROTO_ITEM_SET_GENERATED(it);
3529             if (g_gtp_session) {
3530                 if (!PINFO_FD_VISITED(pinfo) && gtp_version == 1) {
3531                     /* GTP session */
3532                     /* If it does not have any session assigned yet */
3533                     session = (guint32 *)g_hash_table_lookup(session_table, &pinfo->num);
3534                     if (!session) {
3535                         session = (guint32 *)g_hash_table_lookup(session_table, &gcrp->req_frame);
3536                         if (session != NULL) {
3537                             add_gtp_session(pinfo->num, *session);
3538                         }
3539                     }
3540
3541                     if (!is_cause_accepted(last_cause, gtp_version)){
3542                         /* If the cause is not accepted then we have to remove all the session information about its corresponding request */
3543                         remove_frame_info(&gcrp->req_frame);
3544                     }
3545                 }
3546             }
3547         }
3548     }
3549     return gcrp;
3550 }
3551
3552
3553 static int
3554 check_field_presence(guint8 message, guint8 field, int *position)
3555 {
3556
3557     guint i = 0;
3558     _gtp_mess_items *mess_items;
3559
3560     switch (gtp_version) {
3561     case 0:
3562         mess_items = gprs_mess_items;
3563         break;
3564     case 1:
3565         mess_items = umts_mess_items;
3566         break;
3567     default:
3568         return -2;
3569     }
3570
3571     while (mess_items[i].code) {
3572         if (mess_items[i].code == message) {
3573
3574             while (mess_items[i].fields[*position].code) {
3575                 if (mess_items[i].fields[*position].code == field) {
3576                     (*position)++;
3577                     return 0;
3578                 } else {
3579                     if (mess_items[i].fields[*position].presence == GTP_MANDATORY) {
3580                         return mess_items[i].fields[(*position)++].code;
3581                     } else {
3582                         (*position)++;
3583                     }
3584                 }
3585             }
3586             return -1;
3587         }
3588         i++;
3589     }
3590
3591     return -2;
3592 }
3593
3594 /* Decoders of fields in extension headers, each function returns no of bytes from field */
3595
3596 /* GPRS:        9.60 v7.6.0, chapter
3597  * UMTS:        29.060 v4.0, chapter
3598  * 7.7.1 Cause
3599  */
3600 static int
3601 decode_gtp_cause(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args)
3602 {
3603
3604     guint8 cause;
3605
3606     cause = tvb_get_guint8(tvb, offset + 1);
3607     if (g_gtp_session) {
3608         args->last_cause = cause;
3609     }
3610     proto_tree_add_uint(tree, hf_gtp_cause, tvb, offset, 2, cause);
3611
3612     return 2;
3613 }
3614
3615 /* GPRS:        9.60 v7.6.0, chapter 7.9.2
3616  * UMTS:        29.060 v4.0, chapter 7.7.2
3617  */
3618 static int
3619 decode_gtp_imsi(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
3620 {
3621     /* const gchar *imsi_str; */
3622
3623     /* Octets 2 - 9 IMSI */
3624     /* imsi_str = */ dissect_e212_imsi(tvb, pinfo, tree,  offset+1, 8, FALSE);
3625
3626     return 9;
3627 }
3628
3629 /* GPRS:        9.60 v7.6.0, chapter 7.9.3
3630  * UMTS:        29.060 v4.0, chapter 7.7.3 Routeing Area Identity (RAI)
3631  */
3632 static int
3633 decode_gtp_rai(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
3634 {
3635
3636     proto_tree *ext_tree_rai;
3637
3638     ext_tree_rai = proto_tree_add_subtree(tree, tvb, offset, 1, ett_gtp_ies[GTP_EXT_RAI], NULL,
3639                             val_to_str_ext_const(GTP_EXT_RAI, &gtp_val_ext, "Unknown message"));
3640
3641     dissect_e212_mcc_mnc(tvb, pinfo, ext_tree_rai, offset+1, E212_RAI, TRUE);
3642     proto_tree_add_item(ext_tree_rai, hf_gtp_lac, tvb, offset + 4, 2, ENC_BIG_ENDIAN);
3643     proto_tree_add_item(ext_tree_rai, hf_gtp_rai_rac, tvb, offset + 6, 1, ENC_BIG_ENDIAN);
3644
3645     return 7;
3646 }
3647
3648 /* GPRS:        9.60 v7.6.0, chapter 7.9.4, page 39
3649  * UMTS:        29.060 v4.0, chapter 7.7.4 Temporary Logical Link Identity (TLLI)
3650  */
3651 static int
3652 decode_gtp_tlli(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
3653 {
3654
3655     guint32 tlli;
3656
3657     tlli = tvb_get_ntohl(tvb, offset + 1);
3658     proto_tree_add_uint(tree, hf_gtp_tlli, tvb, offset, 5, tlli);
3659
3660     return 5;
3661 }
3662
3663 /* GPRS:        9.60 v7.6.0, chapter 7.9.5, page 39
3664  * UMTS:        29.060 v4.0, chapter 7.7.5 Packet TMSI (P-TMSI)
3665  */
3666 static int
3667 decode_gtp_ptmsi(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
3668 {
3669
3670     guint32 ptmsi;
3671
3672     ptmsi = tvb_get_ntohl(tvb, offset + 1);
3673     proto_tree_add_uint(tree, hf_gtp_ptmsi, tvb, offset, 5, ptmsi);
3674
3675     return 5;
3676 }
3677
3678 /*
3679  * adjust - how many bytes before offset should be highlighted
3680  */
3681 static int
3682 decode_qos_gprs(tvbuff_t * tvb, int offset, proto_tree * tree, const gchar * qos_str, guint8 adjust)
3683 {
3684
3685     guint8      spare1, delay, reliability, peak, spare2, precedence, spare3, mean;
3686     proto_tree *ext_tree_qos;
3687
3688     spare1      = tvb_get_guint8(tvb, offset)     & GTP_EXT_QOS_SPARE1_MASK;
3689     delay       = tvb_get_guint8(tvb, offset)     & GTP_EXT_QOS_DELAY_MASK;
3690     reliability = tvb_get_guint8(tvb, offset)     & GTP_EXT_QOS_RELIABILITY_MASK;
3691     peak        = tvb_get_guint8(tvb, offset + 1) & GTP_EXT_QOS_PEAK_MASK;
3692     spare2      = tvb_get_guint8(tvb, offset + 1) & GTP_EXT_QOS_SPARE2_MASK;
3693     precedence  = tvb_get_guint8(tvb, offset + 1) & GTP_EXT_QOS_PRECEDENCE_MASK;
3694     spare3      = tvb_get_guint8(tvb, offset + 2) & GTP_EXT_QOS_SPARE3_MASK;
3695     mean        = tvb_get_guint8(tvb, offset + 2) & GTP_EXT_QOS_MEAN_MASK;
3696
3697     ext_tree_qos = proto_tree_add_subtree_format(tree, tvb, offset - adjust, 3 + adjust, ett_gtp_qos, NULL,
3698                              "%s: delay: %u, reliability: %u, peak: %u, precedence: %u, mean: %u",
3699                              qos_str, (delay >> 3) & 0x07, reliability, (peak >> 4) & 0x0F, precedence, mean);
3700
3701     if (adjust != 0) {
3702         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_spare1,      tvb, offset,     1, spare1);
3703         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_delay,       tvb, offset,     1, delay);
3704         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_reliability, tvb, offset,     1, reliability);
3705         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_peak,        tvb, offset + 1, 1, peak);
3706         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_spare2,      tvb, offset + 1, 1, spare2);
3707         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_precedence,  tvb, offset + 1, 1, precedence);
3708         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_spare3,      tvb, offset + 2, 1, spare3);
3709         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_mean,        tvb, offset + 2, 1, mean);
3710     }
3711
3712     return 3;
3713 }
3714
3715 /* GPRS:        9.60 v7.6.0, chapter 7.9.6, page 39
3716  *              4.08
3717  *              3.60
3718  * UMTS:        not present
3719  * TODO:        check if length is included: ETSI 4.08 vs 9.60
3720  */
3721 static int
3722 decode_gtp_qos_gprs(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
3723 {
3724
3725     return (1 + decode_qos_gprs(tvb, offset + 1, tree, "Quality of Service", 1));
3726
3727 }
3728
3729 /* GPRS:        9.60 v7.6.0, chapter 7.9.7, page 39
3730  * UMTS:        29.060 v4.0, chapter 7.7.6 Reordering Required
3731  */
3732 static int
3733 decode_gtp_reorder(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
3734 {
3735
3736     guint8 reorder;
3737
3738     reorder = tvb_get_guint8(tvb, offset + 1) & 0x01;
3739     proto_tree_add_boolean(tree, hf_gtp_reorder, tvb, offset, 2, reorder);
3740
3741     return 2;
3742 }
3743
3744 /* GPRS:        9.60 v7.6.0, chapter 7.9.8, page 40
3745  *              4.08 v7.1.2, chapter 10.5.3.1+
3746  * UMTS:        29.060 v4.0, chapter 7.7.7
3747  * TODO: Add blurb support by registering items in the protocol registration
3748  */
3749 static int
3750 decode_gtp_auth_tri(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
3751 {
3752
3753     proto_tree *ext_tree_auth_tri;
3754
3755     ext_tree_auth_tri = proto_tree_add_subtree(tree, tvb, offset, 29, ett_gtp_ies[GTP_EXT_AUTH_TRI], NULL,
3756                             val_to_str_ext_const(GTP_EXT_AUTH_TRI, &gtp_val_ext, "Unknown message"));
3757
3758     proto_tree_add_item(ext_tree_auth_tri, hf_gtp_rand, tvb, offset + 1, 16, ENC_NA);
3759     proto_tree_add_item(ext_tree_auth_tri, hf_gtp_sres, tvb, offset + 17, 4, ENC_NA);
3760     proto_tree_add_item(ext_tree_auth_tri, hf_gtp_kc, tvb, offset + 21, 8, ENC_NA);
3761
3762     return 1 + 16 + 4 + 8;
3763 }
3764
3765 /* GPRS:        9.60 v7.6.0, chapter 7.9.9, page 40
3766  *              9.02 v7.7.0, page 1090
3767  * UMTS:        29.060 v4.0, chapter 7.7.8, page 48
3768  *              29.002 v4.2.1, chapter 17.5, page 268
3769  */
3770 static int
3771 decode_gtp_map_cause(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
3772 {
3773
3774     guint8 map_cause;
3775
3776     map_cause = tvb_get_guint8(tvb, offset + 1);
3777     proto_tree_add_uint(tree, hf_gtp_map_cause, tvb, offset, 2, map_cause);
3778
3779     return 2;
3780 }
3781
3782 /* GPRS:        9.60 v7.6.0, chapter 7.9.10, page 41
3783  * UMTS:        29.060 v4.0, chapter 7.7.9, page 48
3784  */
3785 static int
3786 decode_gtp_ptmsi_sig(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
3787 {
3788
3789     guint32 ptmsi_sig;
3790
3791     ptmsi_sig = tvb_get_ntoh24(tvb, offset + 1);
3792     proto_tree_add_uint(tree, hf_gtp_ptmsi_sig, tvb, offset, 4, ptmsi_sig);
3793
3794     return 4;
3795 }
3796
3797 /* GPRS:        9.60 v7.6.0, chapter 7.9.11, page 41
3798  * UMTS:        29.060 v4.0, chapter 7.7.10, page 49
3799  */
3800 static int
3801 decode_gtp_ms_valid(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
3802 {
3803
3804     guint8 ms_valid;
3805
3806     ms_valid = tvb_get_guint8(tvb, offset + 1) & 0x01;
3807     proto_tree_add_boolean(tree, hf_gtp_ms_valid, tvb, offset, 2, ms_valid);
3808
3809     return 2;
3810 }
3811
3812 /* GPRS:        9.60 v7.6.0, chapter 7.9.12, page 41
3813  * UMTS:        29.060 v4.0, chapter 7.7.11 Recovery
3814  */
3815 static int
3816 decode_gtp_recovery(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
3817 {
3818
3819     guint8 recovery;
3820
3821     recovery = tvb_get_guint8(tvb, offset + 1);
3822     proto_tree_add_uint(tree, hf_gtp_recovery, tvb, offset, 2, recovery);
3823
3824     return 2;
3825 }
3826
3827 /* GPRS:        9.60 v7.6.0, chapter 7.9.13, page 42
3828  * UMTS:        29.060 v4.0, chapter 7.7.12 Selection Mode
3829  */
3830
3831
3832 static const gchar *
3833 dissect_radius_selection_mode(proto_tree * tree, tvbuff_t * tvb, packet_info* pinfo _U_)
3834 {
3835     guint8 sel_mode;
3836
3837     /* Value in ASCII(UTF-8) */
3838     sel_mode = tvb_get_guint8(tvb, 0) - 0x30;
3839     proto_tree_add_uint(tree, hf_gtp_sel_mode, tvb, 0, 1, sel_mode);
3840
3841     return val_to_str_const(sel_mode, sel_mode_type, "Unknown");
3842 }
3843
3844 static int
3845 decode_gtp_sel_mode(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
3846 {
3847     proto_tree *ext_tree;
3848     proto_item *te;
3849     guint8 sel_mode;
3850
3851     sel_mode = tvb_get_guint8(tvb, offset + 1) & 0x03;
3852
3853     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 2, ett_gtp_ies[GTP_EXT_SEL_MODE], &te,
3854                             val_to_str_ext_const(GTP_EXT_SEL_MODE, &gtp_val_ext, "Unknown message"));
3855     proto_item_append_text(te, ": %s", val_to_str_const(sel_mode, sel_mode_type, "Unknown"));
3856     proto_tree_add_item(ext_tree, hf_gtp_sel_mode, tvb, offset, 2, ENC_BIG_ENDIAN);
3857
3858     return 2;
3859 }
3860
3861 /* GPRS:        9.60 v7.6.0, chapter 7.9.14, page 42
3862  * UMTS:        29.060 v4.0, chapter 7.7.13, page 50
3863  */
3864 static int
3865 decode_gtp_16(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args)
3866 {
3867
3868     guint16 ext_flow_label;
3869     guint32 teid_data, *teid;
3870
3871     switch (gtp_version) {
3872     case 0:
3873         ext_flow_label = tvb_get_ntohs(tvb, offset + 1);
3874         proto_tree_add_uint(tree, hf_gtp_ext_flow_label, tvb, offset, 3, ext_flow_label);
3875
3876         return 3;
3877     case 1:
3878         teid_data = tvb_get_ntohl(tvb, offset + 1);
3879         /* We save the teid_data so that we could assignate its corresponding session ID later */
3880         if (g_gtp_session && !PINFO_FD_VISITED(pinfo)) {
3881             args->last_teid = teid_data; /* We save it to track the error indication */
3882             if (!teid_exists(teid_data, args->teid_list)) {
3883                 teid = wmem_new(wmem_packet_scope(), guint32);
3884                 *teid = teid_data;
3885                 wmem_list_prepend(args->teid_list, teid);
3886             }
3887         }
3888         proto_tree_add_uint(tree, hf_gtp_teid_data, tvb, offset+1, 4, teid_data);
3889
3890         return 5;
3891     default:
3892         proto_tree_add_expert_format(tree, pinfo, &ei_gtp_field_not_support_in_version,
3893                     tvb, offset, 1, "Flow label/TEID Data I : GTP version not supported");
3894
3895         return 3;
3896     }
3897 }
3898
3899 /* GPRS:        9.60 v7.6.0, chapter 7.9.15, page 42
3900  * UMTS:        29.060 v4.0, chapter 7.7.14, page 42
3901  */
3902 static int
3903 decode_gtp_17(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args)
3904 {
3905
3906     guint16 flow_sig;
3907     guint32 teid_cp;
3908     guint32 *teid;
3909
3910     switch (gtp_version) {
3911     case 0:
3912         flow_sig = tvb_get_ntohs(tvb, offset + 1);
3913         proto_tree_add_uint(tree, hf_gtp_flow_sig, tvb, offset, 3, flow_sig);
3914         return 3;
3915     case 1:
3916         teid_cp = tvb_get_ntohl(tvb, offset + 1);
3917         /* We save the teid_cp so that we could assignate its corresponding session ID later */
3918         if (g_gtp_session && !PINFO_FD_VISITED(pinfo)) {
3919             if (!teid_exists(teid_cp, args->teid_list)) {
3920                 teid = wmem_new(wmem_packet_scope(), guint32);
3921                 *teid = teid_cp;
3922                 wmem_list_prepend(args->teid_list, teid);
3923             }
3924         }
3925         proto_tree_add_uint(tree, hf_gtp_teid_cp, tvb, offset, 5, teid_cp);
3926         return 5;
3927     default:
3928         proto_tree_add_expert_format(tree, pinfo, &ei_gtp_field_not_support_in_version,
3929             tvb, offset, 1, "Flow label signalling/TEID control plane : GTP version not supported");
3930         return 3;
3931     }
3932 }
3933
3934 /* GPRS:        9.60 v7.6.0, chapter 7.9.16, page 42
3935  * UMTS:        29.060 v4.0, chapter 7.7.15, page 51
3936  */
3937 static int
3938 decode_gtp_18(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
3939 {
3940
3941     guint16     flow_ii;
3942     guint32     teid_ii;
3943     proto_tree *ext_tree_flow_ii;
3944
3945     switch (gtp_version) {
3946     case 0:
3947         ext_tree_flow_ii = proto_tree_add_subtree(tree, tvb, offset, 4, ett_gtp_ies[GTP_EXT_FLOW_II], NULL,
3948                         val_to_str_ext_const(GTP_EXT_FLOW_II, &gtp_val_ext, "Unknown message"));
3949
3950         proto_tree_add_item(ext_tree_flow_ii, hf_gtp_nsapi, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
3951
3952         flow_ii = tvb_get_ntohs(tvb, offset + 2);
3953         proto_tree_add_uint(ext_tree_flow_ii, hf_gtp_flow_ii, tvb, offset + 2, 2, flow_ii);
3954
3955         return 4;
3956     case 1:
3957         ext_tree_flow_ii = proto_tree_add_subtree(tree, tvb, offset, 6, ett_gtp_flow_ii, NULL,
3958                 val_to_str_ext_const(GTP_EXT_TEID_II, &gtpv1_val_ext, "Unknown message"));
3959
3960         proto_tree_add_item(ext_tree_flow_ii, hf_gtp_nsapi, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
3961
3962         teid_ii = tvb_get_ntohl(tvb, offset + 2);
3963         proto_tree_add_uint(ext_tree_flow_ii, hf_gtp_teid_ii, tvb, offset + 2, 4, teid_ii);
3964
3965         return 6;
3966     default:
3967         proto_tree_add_expert_format(tree, pinfo, &ei_gtp_field_not_support_in_version,
3968             tvb, offset, 1, "Flow data II/TEID Data II : GTP Version not supported");
3969
3970         return 4;
3971     }
3972 }
3973
3974 /* GPRS:        9.60 v7.6.0, chapter 7.9.16A, page 43
3975  * UMTS:        29.060 v4.0, chapter 7.7.16, page 51
3976  * Check if all ms_reason types are included
3977  */
3978 static int
3979 decode_gtp_19(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
3980 {
3981
3982     guint8 field19;
3983
3984     field19 = tvb_get_guint8(tvb, offset + 1);
3985
3986     switch (gtp_version) {
3987     case 0:
3988         proto_tree_add_uint(tree, hf_gtp_ms_reason, tvb, offset, 2, field19);
3989         break;
3990     case 1:
3991         proto_tree_add_boolean(tree, hf_gtp_tear_ind, tvb, offset, 2, field19 & 0x01);
3992         break;
3993     default:
3994         proto_tree_add_expert_format(tree, pinfo, &ei_gtp_field_not_support_in_version,
3995             tvb, offset, 1, "Information Element Type = 19 : GTP Version not supported");
3996         break;
3997     }
3998
3999     return 2;
4000 }
4001
4002 /* GPRS:        not present
4003  * UMTS:        29.060 v4.0, chapter 7.7.17, page 51
4004  */
4005 static int
4006 decode_gtp_nsapi(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4007 {
4008     guint8      nsapi;
4009     proto_tree *ext_tree;
4010     proto_item *te;
4011
4012     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 2, ett_gtp_ies[GTP_EXT_NSAPI], &te,
4013                             val_to_str_ext_const(GTP_EXT_NSAPI, &gtp_val_ext, "Unknown message"));
4014
4015     nsapi = tvb_get_guint8(tvb, offset + 1) & 0x0F;
4016     proto_tree_add_item(ext_tree, hf_gtp_nsapi, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
4017     proto_item_append_text(te, ": %u",nsapi);
4018
4019     return 2;
4020 }
4021
4022 /* GPRS:        not present
4023  * UMTS:        29.060 v4.0, chapter 7.7.18, page 52
4024  */
4025 static int
4026 decode_gtp_ranap_cause(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4027 {
4028
4029     guint8 ranap;
4030
4031     ranap = tvb_get_guint8(tvb, offset + 1);
4032
4033     if ((ranap > 0) && (ranap <= 64))
4034         proto_tree_add_uint_format(tree, hf_gtp_ranap_cause, tvb, offset, 2,
4035                                    ranap, "%s (Radio Network Layer Cause) : %s (%u)",
4036                                    val_to_str_ext_const(GTP_EXT_RANAP_CAUSE, &gtp_val_ext, "Unknown"),
4037                                    val_to_str_ext_const(ranap, &ranap_cause_type_ext, "Unknown RANAP Cause"), ranap);
4038
4039     if ((ranap > 64) && (ranap <= 80))
4040         proto_tree_add_uint_format(tree, hf_gtp_ranap_cause, tvb, offset, 2,
4041                                    ranap, "%s (Transport Layer Cause) : %s (%u)",
4042                                    val_to_str_ext_const(GTP_EXT_RANAP_CAUSE, &gtp_val_ext, "Unknown"),
4043                                    val_to_str_ext_const(ranap, &ranap_cause_type_ext, "Unknown RANAP Cause"), ranap);
4044
4045     if ((ranap > 80) && (ranap <= 96))
4046         proto_tree_add_uint_format(tree, hf_gtp_ranap_cause, tvb, offset, 2,
4047                                    ranap, "%s (NAS Cause) : %s (%u)",
4048                                    val_to_str_ext_const(GTP_EXT_RANAP_CAUSE, &gtp_val_ext, "Unknown"),
4049                                    val_to_str_ext_const(ranap, &ranap_cause_type_ext, "Unknown RANAP Cause"), ranap);
4050
4051     if ((ranap > 96) && (ranap <= 112))
4052         proto_tree_add_uint_format(tree, hf_gtp_ranap_cause, tvb, offset, 2, ranap,
4053                                    "%s (Protocol Cause) : %s (%u)",
4054                                    val_to_str_ext_const(GTP_EXT_RANAP_CAUSE, &gtp_val_ext, "Unknown"),
4055                                    val_to_str_ext_const(ranap, &ranap_cause_type_ext, "Unknown RANAP Cause"), ranap);
4056
4057     if ((ranap > 112) && (ranap <= 128))
4058         proto_tree_add_uint_format(tree, hf_gtp_ranap_cause, tvb, offset, 2, ranap,
4059                                    "%s (Miscellaneous Cause) : %s (%u)",
4060                                    val_to_str_ext_const(GTP_EXT_RANAP_CAUSE, &gtp_val_ext, "Unknown"),
4061                                    val_to_str_ext_const(ranap, &ranap_cause_type_ext, "Unknown RANAP Cause"), ranap);
4062
4063     if ((ranap > 128) /* && (ranap <= 255) */ )
4064         proto_tree_add_uint_format(tree, hf_gtp_ranap_cause, tvb, offset, 2, ranap,
4065                                    "%s (Non-standard Cause) : %s (%u)",
4066                                    val_to_str_ext_const(GTP_EXT_RANAP_CAUSE, &gtp_val_ext, "Unknown"),
4067                                    val_to_str_ext_const(ranap, &ranap_cause_type_ext, "Unknown RANAP Cause"), ranap);
4068
4069     return 2;
4070 }
4071
4072 /* GPRS:        not present
4073  * UMTS:        29.060 v4.0, chapter 7.7.19, page 52
4074  */
4075 static int
4076 decode_gtp_rab_cntxt(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4077 {
4078     proto_tree *ext_tree_rab_cntxt;
4079
4080     ext_tree_rab_cntxt = proto_tree_add_subtree(tree, tvb, offset, 10, ett_gtp_ies[GTP_EXT_RAB_CNTXT], NULL,
4081                         val_to_str_ext_const(GTP_EXT_RAB_CNTXT, &gtp_val_ext, "Unknown message"));
4082
4083     proto_tree_add_item(ext_tree_rab_cntxt, hf_gtp_nsapi,       tvb, offset + 1, 1, ENC_BIG_ENDIAN);
4084     proto_tree_add_item(ext_tree_rab_cntxt, hf_gtp_rab_gtpu_dn, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
4085     proto_tree_add_item(ext_tree_rab_cntxt, hf_gtp_rab_gtpu_up, tvb, offset + 4, 2, ENC_BIG_ENDIAN);
4086     proto_tree_add_item(ext_tree_rab_cntxt, hf_gtp_rab_pdu_dn,  tvb, offset + 6, 2, ENC_BIG_ENDIAN);
4087     proto_tree_add_item(ext_tree_rab_cntxt, hf_gtp_rab_pdu_up,  tvb, offset + 8, 2, ENC_BIG_ENDIAN);
4088
4089     return 10;
4090 }
4091
4092
4093 /* GPRS:        not present
4094  * UMTS:        29.060 v4.0, chapter 7.7.20, page 53
4095  */
4096 static int
4097 decode_gtp_rp_sms(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4098 {
4099
4100     guint8 rp_sms;
4101
4102     rp_sms = tvb_get_guint8(tvb, offset + 1) & 0x07;
4103     proto_tree_add_uint(tree, hf_gtp_rp_sms, tvb, offset, 2, rp_sms);
4104
4105     return 2;
4106 }
4107
4108 /* GPRS:        not present
4109  * UMTS:        29.060 v4.0, chapter 7.7.21, page 53
4110  */
4111 static int
4112 decode_gtp_rp(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4113 {
4114
4115     proto_tree *ext_tree_rp;
4116     proto_item *te;
4117     guint8      nsapi, rp, spare;
4118
4119     nsapi = tvb_get_guint8(tvb, offset + 1) & 0xF0;
4120     spare = tvb_get_guint8(tvb, offset + 1) & 0x08;
4121     rp = tvb_get_guint8(tvb, offset + 1) & 0x07;
4122
4123     te = proto_tree_add_uint_format(tree, hf_gtp_rp, tvb, offset, 2, rp, "Radio Priority for NSAPI(%u) : %u", nsapi, rp);
4124     ext_tree_rp = proto_item_add_subtree(te, ett_gtp_rp);
4125
4126     proto_tree_add_uint(ext_tree_rp, hf_gtp_rp_nsapi, tvb, offset + 1, 1, nsapi);
4127     proto_tree_add_uint(ext_tree_rp, hf_gtp_rp_spare, tvb, offset + 1, 1, spare);
4128     proto_tree_add_uint(ext_tree_rp, hf_gtp_rp,       tvb, offset + 1, 1, rp);
4129
4130     return 2;
4131 }
4132
4133 /* GPRS:        not present
4134  * UMTS:        29.060 v4.0, chapter 7.7.22, page 53
4135  */
4136 static int
4137 decode_gtp_pkt_flow_id(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4138 {
4139
4140     proto_tree *ext_tree_pkt_flow_id;
4141     proto_item *te;
4142     guint8      nsapi, pkt_flow_id;
4143
4144     nsapi = tvb_get_guint8(tvb, offset + 1) & 0x0F;
4145     pkt_flow_id = tvb_get_guint8(tvb, offset + 2);
4146
4147     te = proto_tree_add_uint_format(tree, hf_gtp_pkt_flow_id, tvb, offset, 3, pkt_flow_id, "Packet Flow ID for NSAPI(%u) : %u", nsapi, pkt_flow_id);
4148     ext_tree_pkt_flow_id = proto_item_add_subtree(te, ett_gtp_pkt_flow_id);
4149
4150     proto_tree_add_item(ext_tree_pkt_flow_id, hf_gtp_nsapi, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
4151     proto_tree_add_uint_format(ext_tree_pkt_flow_id, hf_gtp_pkt_flow_id, tvb,
4152                                offset + 2, 1, pkt_flow_id, "%s : %u", val_to_str_ext_const(GTP_EXT_PKT_FLOW_ID, &gtp_val_ext, "Unknown message"), pkt_flow_id);
4153
4154     return 3;
4155 }
4156
4157 /* GPRS:        not present
4158  * UMTS:        29.060 v4.0, chapter 7.7.23, page 53
4159  * TODO: Differenciate these uints?
4160  */
4161 static int
4162 decode_gtp_chrg_char(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4163 {
4164
4165     guint16     chrg_char;
4166     proto_item *te;
4167     proto_tree *ext_tree_chrg_char;
4168
4169     chrg_char = tvb_get_ntohs(tvb, offset + 1);
4170
4171     te = proto_tree_add_uint(tree, hf_gtp_chrg_char, tvb, offset, 3, chrg_char);
4172     /*"%s: %x", val_to_str_ext_const (GTP_EXT_CHRG_CHAR, &gtp_val_ext, "Unknown message"), chrg_char); */
4173     ext_tree_chrg_char = proto_item_add_subtree(te, ett_gtp_ies[GTP_EXT_CHRG_CHAR]);
4174
4175     proto_tree_add_uint(ext_tree_chrg_char, hf_gtp_chrg_char_s, tvb, offset + 1, 2, chrg_char);
4176     proto_tree_add_uint(ext_tree_chrg_char, hf_gtp_chrg_char_n, tvb, offset + 1, 2, chrg_char);
4177     proto_tree_add_uint(ext_tree_chrg_char, hf_gtp_chrg_char_p, tvb, offset + 1, 2, chrg_char);
4178     proto_tree_add_uint(ext_tree_chrg_char, hf_gtp_chrg_char_f, tvb, offset + 1, 2, chrg_char);
4179     proto_tree_add_uint(ext_tree_chrg_char, hf_gtp_chrg_char_h, tvb, offset + 1, 2, chrg_char);
4180     proto_tree_add_uint(ext_tree_chrg_char, hf_gtp_chrg_char_r, tvb, offset + 1, 2, chrg_char);
4181
4182     return 3;
4183 }
4184
4185 /* GPRS:        not present
4186  * UMTS:        29.060 v4.0, chapter 7.7.24, page
4187  */
4188 static int
4189 decode_gtp_trace_ref(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4190 {
4191
4192     guint16 trace_ref;
4193
4194     trace_ref = tvb_get_ntohs(tvb, offset + 1);
4195
4196     proto_tree_add_uint(tree, hf_gtp_trace_ref, tvb, offset, 3, trace_ref);
4197
4198     return 3;
4199 }
4200
4201 /* GPRS:        not present
4202  * UMTS:        29.060 v4.0, chapter 7.7.25, page
4203  */
4204 static int
4205 decode_gtp_trace_type(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4206 {
4207
4208     guint16 trace_type;
4209
4210     trace_type = tvb_get_ntohs(tvb, offset + 1);
4211
4212     proto_tree_add_uint(tree, hf_gtp_trace_type, tvb, offset, 3, trace_type);
4213
4214     return 3;
4215 }
4216
4217 /* GPRS:        9.60 v7.6.0, chapter 7.9.16A
4218  * UMTS:        29.060 v4.0, chapter 7.7.25A, page
4219  */
4220 static int
4221 decode_gtp_ms_reason(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4222 {
4223
4224     guint8 reason;
4225
4226     reason = tvb_get_guint8(tvb, offset + 1);
4227
4228     /* Reason for Absence is defined in 3GPP TS 23.040  */
4229     proto_tree_add_uint(tree, hf_gtp_ms_reason, tvb, offset, 2, reason);
4230
4231     return 2;
4232 }
4233
4234 /* GPRS:        ?
4235  * UMTS:        29.060 v6.11.0, chapter 7.7.25B
4236  * Radio Priority LCS
4237  */
4238 static int
4239 decode_gtp_ra_prio_lcs(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4240 {
4241
4242     guint16     length;
4243     proto_tree *ext_tree;
4244
4245     length = tvb_get_ntohs(tvb, offset + 1);
4246     ext_tree = proto_tree_add_subtree_format(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_RA_PRIO_LCS], NULL,
4247                     "%s : ", val_to_str_ext_const(GTP_EXT_RA_PRIO_LCS, &gtp_val_ext, "Unknown"));
4248
4249     offset++;
4250     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
4251     offset = offset + 2;
4252
4253     proto_tree_add_item(ext_tree, hf_gtp_ra_prio_lcs, tvb, offset, 1, ENC_BIG_ENDIAN);
4254
4255     return 3 + length;
4256
4257 }
4258
4259 /* GPRS:        12.15 v7.6.0, chapter 7.3.3, page 45
4260  * UMTS:        33.015
4261  */
4262 static int
4263 decode_gtp_tr_comm(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4264 {
4265
4266     guint8 tr_command;
4267
4268     tr_command = tvb_get_guint8(tvb, offset + 1);
4269
4270     proto_tree_add_uint(tree, hf_gtp_tr_comm, tvb, offset, 2, tr_command);
4271
4272     return 2;
4273 }
4274
4275 /* GPRS:        9.60 v7.6.0, chapter 7.9.17, page 43
4276  * UMTS:        29.060 v4.0, chapter 7.7.26, page 55
4277  */
4278 static int
4279 decode_gtp_chrg_id(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4280 {
4281
4282     guint32 chrg_id;
4283
4284     chrg_id = tvb_get_ntohl(tvb, offset + 1);
4285     proto_tree_add_uint(tree, hf_gtp_chrg_id, tvb, offset, 5, chrg_id);
4286
4287     return 5;
4288 }
4289
4290 /* GPRS:        9.60 v7.6.0, chapter 7.9.18, page 43
4291  * UMTS:        29.060 v4.0, chapter 7.7.27, page 55
4292  */
4293 static int
4294 decode_gtp_user_addr(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4295 {
4296
4297     guint16            length;
4298     guint8             pdp_typ, pdp_org;
4299     proto_tree        *ext_tree_user;
4300     proto_item        *te;
4301
4302
4303     length = tvb_get_ntohs(tvb, offset + 1);
4304     pdp_org = tvb_get_guint8(tvb, offset + 3) & 0x0F;
4305     pdp_typ = tvb_get_guint8(tvb, offset + 4);
4306
4307     ext_tree_user = proto_tree_add_subtree_format(tree, tvb, offset, 3 + length,
4308                              ett_gtp_ies[GTP_EXT_USER_ADDR], &te, "%s (%s/%s)",
4309                              val_to_str_ext_const(GTP_EXT_USER_ADDR, &gtp_val_ext, "Unknown message"),
4310                              val_to_str_const(pdp_org, pdp_org_type, "Unknown PDP Organization"),
4311                              val_to_str_const(pdp_typ, pdp_type, "Unknown PDP Type"));
4312
4313     proto_tree_add_item(ext_tree_user, hf_gtp_length, tvb, offset + 1, 2, ENC_BIG_ENDIAN);
4314     proto_tree_add_uint(ext_tree_user, hf_gtp_user_addr_pdp_org,  tvb, offset + 3, 1, pdp_org);
4315     proto_tree_add_uint(ext_tree_user, hf_gtp_user_addr_pdp_type, tvb, offset + 4, 1, pdp_typ);
4316
4317     if (length == 2) {
4318         if ((pdp_org == 0) && (pdp_typ == 1))
4319             proto_item_append_text(te, " (Point to Point Protocol)");
4320         else if (pdp_typ == 2)
4321             proto_item_append_text(te, " (Octet Stream Protocol)");
4322     } else if (length > 2) {
4323         switch (pdp_typ) {
4324         case 0x21:
4325             proto_tree_add_item(ext_tree_user, hf_gtp_user_ipv4, tvb, offset + 5, 4, ENC_BIG_ENDIAN);
4326             proto_item_append_text(te, " : %s", tvb_ip_to_str(tvb, offset + 5));
4327             break;
4328         case 0x57:
4329             proto_tree_add_item(ext_tree_user, hf_gtp_user_ipv6, tvb, offset + 5, 16, ENC_NA);
4330             proto_item_append_text(te, " : %s", tvb_ip6_to_str(tvb, offset + 5));
4331             break;
4332         case 0x8d:
4333             if (length == 6) {
4334                 ws_in6_addr ipv6;
4335                 memset(&ipv6, 0, sizeof(ws_in6_addr));
4336                 proto_tree_add_item(ext_tree_user, hf_gtp_user_ipv4, tvb, offset + 5, 4, ENC_BIG_ENDIAN);
4337                 proto_tree_add_ipv6_format_value(ext_tree_user, hf_gtp_user_ipv6, tvb, offset + 9, 0, &ipv6, "dynamic");
4338                 proto_item_append_text(te, " : %s / dynamic", tvb_ip_to_str(tvb, offset + 5));
4339             } else if (length == 18) {
4340                 proto_tree_add_ipv4_format_value(ext_tree_user, hf_gtp_user_ipv6, tvb, offset + 5, 0, 0, "dynamic");
4341                 proto_tree_add_item(ext_tree_user, hf_gtp_user_ipv6, tvb, offset + 5, 16, ENC_NA);
4342                 proto_item_append_text(te, " : dynamic / %s", tvb_ip6_to_str(tvb, offset + 5));
4343             } else if (length == 22) {
4344                 proto_tree_add_item(ext_tree_user, hf_gtp_user_ipv4, tvb, offset + 5, 4, ENC_BIG_ENDIAN);
4345                 proto_tree_add_item(ext_tree_user, hf_gtp_user_ipv6, tvb, offset + 9, 16, ENC_NA);
4346                 proto_item_append_text(te, " : %s / %s", tvb_ip_to_str(tvb, offset + 5),
4347                                        tvb_ip6_to_str(tvb, offset + 9));
4348             } else {
4349                 proto_tree_add_expert_format(ext_tree_user, pinfo, &ei_gtp_ext_length_mal, tvb, offset + 3, length, "Wrong length indicated. Expected 6, 18 or 22, got %u", length);
4350             }
4351             break;
4352         }
4353     } else
4354         proto_item_append_text(te, " : empty PDP Address");
4355
4356     return 3 + length;
4357 }
4358
4359 static int
4360 decode_triplet(tvbuff_t * tvb, int offset, proto_tree * tree, guint16 count)
4361 {
4362
4363     proto_tree *ext_tree_trip;
4364     guint16     i;
4365
4366     for (i = 0; i < count; i++) {
4367         ext_tree_trip = proto_tree_add_subtree_format(tree, tvb, offset + i * 28, 28, ett_gtp_trip, NULL, "Triplet no%x", i);
4368
4369         proto_tree_add_item(ext_tree_trip, hf_gtp_rand, tvb, offset + i * 28, 16, ENC_NA);
4370         proto_tree_add_item(ext_tree_trip, hf_gtp_sres, tvb, offset + i * 28 + 16, 4, ENC_NA);
4371         proto_tree_add_item(ext_tree_trip, hf_gtp_kc, tvb, offset + i * 28 + 20, 8, ENC_NA);
4372     }
4373
4374     return count * 28;
4375 }
4376
4377 /* adjust - how many bytes before quintuplet should be highlighted
4378  */
4379 static int
4380 decode_quintuplet(tvbuff_t * tvb, int offset, proto_tree * tree, guint16 count)
4381 {
4382
4383     proto_tree *ext_tree_quint;
4384     proto_item *te_quint;
4385     guint16     q_offset, i;
4386     guint8      xres_len, auth_len;
4387
4388     q_offset = 0;
4389
4390     for (i = 0; i < count; i++) {
4391
4392         ext_tree_quint = proto_tree_add_subtree_format(tree, tvb, offset, -1,
4393                                 ett_gtp_quint, &te_quint, "Quintuplet #%x", i + 1);
4394
4395         proto_tree_add_item(ext_tree_quint, hf_gtp_rand, tvb, offset + q_offset, 16, ENC_NA);
4396         q_offset = q_offset + 16;
4397         xres_len = tvb_get_guint8(tvb, offset + q_offset);
4398         proto_tree_add_item(ext_tree_quint, hf_gtp_xres_length, tvb, offset + q_offset, 1, ENC_BIG_ENDIAN);
4399         q_offset++;
4400         proto_tree_add_item(ext_tree_quint, hf_gtp_xres, tvb, offset + q_offset, xres_len, ENC_NA);
4401         q_offset = q_offset + xres_len;
4402         proto_tree_add_item(ext_tree_quint, hf_gtp_quintuplet_ciphering_key, tvb, offset + q_offset, 16, ENC_NA);
4403         q_offset = q_offset + 16;
4404         proto_tree_add_item(ext_tree_quint, hf_gtp_quintuplet_integrity_key, tvb, offset + q_offset, 16, ENC_NA);
4405         q_offset = q_offset + 16;
4406         auth_len = tvb_get_guint8(tvb, offset + q_offset);
4407         proto_tree_add_item(ext_tree_quint, hf_gtp_authentication_length, tvb, offset + q_offset, 1, ENC_BIG_ENDIAN);
4408         q_offset++;
4409         proto_tree_add_item(ext_tree_quint, hf_gtp_auth, tvb, offset + q_offset, auth_len, ENC_NA);
4410
4411         q_offset = q_offset + auth_len;
4412         proto_item_set_end(te_quint, tvb, offset + q_offset);
4413
4414     }
4415
4416     return q_offset;
4417 }
4418
4419 /* GPRS:        9.60 v7.6.0, chapter 7.9.19 page
4420  * UMTS:        29.060 v4.0, chapter 7.7.28 page 57
4421  * TODO:        - check if for quintuplets first 2 bytes are length, according to AuthQuint
4422  *              - finish displaying last 3 parameters
4423  */
4424 static int
4425 decode_gtp_mm_cntxt(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
4426 {
4427
4428     guint16     length, con_len;
4429     guint8      count, sec_mode, len, iei;
4430     proto_tree *ext_tree_mm;
4431     proto_tree *tf_tree = NULL, *con_tree;
4432
4433     ext_tree_mm = proto_tree_add_subtree(tree, tvb, offset, 1, ett_gtp_ies[GTP_EXT_MM_CNTXT], NULL,
4434                         val_to_str_ext_const(GTP_EXT_MM_CNTXT, &gtp_val_ext, "Unknown message"));
4435
4436     /* Octet 2 - 3 */
4437     length = tvb_get_ntohs(tvb, offset + 1);
4438     if (length < 1)
4439         return 3;
4440
4441     /* Octet 4 (cksn)*/
4442
4443     /* Octet 5 */
4444     sec_mode = (tvb_get_guint8(tvb, offset + 4) >> 6) & 0x03;
4445     count = (tvb_get_guint8(tvb, offset + 4) >> 3) & 0x07;
4446
4447     proto_tree_add_item(ext_tree_mm, hf_gtp_length, tvb, offset + 1, 2, ENC_BIG_ENDIAN);
4448     if (gtp_version == 0)
4449         sec_mode = 1;
4450
4451
4452     switch (sec_mode) {
4453     case 0:                     /* Used cipher value, UMTS keys and Quintuplets */
4454         proto_tree_add_item(ext_tree_mm, hf_gtp_cksn_ksi,         tvb, offset + 3, 1, ENC_BIG_ENDIAN);
4455         proto_tree_add_item(ext_tree_mm, hf_gtp_security_mode,    tvb, offset + 4, 1, ENC_BIG_ENDIAN);
4456         proto_tree_add_item(ext_tree_mm, hf_gtp_no_of_vectors,    tvb, offset + 4, 1, ENC_BIG_ENDIAN);
4457         proto_tree_add_item(ext_tree_mm, hf_gtp_cipher_algorithm, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
4458         proto_tree_add_item(ext_tree_mm, hf_gtp_ciphering_key_ck, tvb, offset + 5, 16, ENC_NA);
4459         proto_tree_add_item(ext_tree_mm, hf_gtp_integrity_key_ik, tvb, offset + 21, 16, ENC_NA);
4460         proto_tree_add_item(ext_tree_mm, hf_gtp_quintuplets_length, tvb, offset + 37, 2, ENC_BIG_ENDIAN);
4461
4462         offset = offset + decode_quintuplet(tvb, offset + 39, ext_tree_mm, count) + 39;
4463
4464
4465         break;
4466     case 1:                     /* GSM key and triplets */
4467         proto_tree_add_item(ext_tree_mm, hf_gtp_cksn, tvb, offset + 3, 1, ENC_BIG_ENDIAN);
4468         if (gtp_version != 0)
4469             proto_tree_add_item(ext_tree_mm, hf_gtp_security_mode, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
4470
4471         proto_tree_add_item(ext_tree_mm, hf_gtp_no_of_vectors,    tvb, offset + 4, 1, ENC_BIG_ENDIAN);
4472         proto_tree_add_item(ext_tree_mm, hf_gtp_cipher_algorithm, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
4473         proto_tree_add_item(ext_tree_mm, hf_gtp_ciphering_key_kc, tvb, offset + 5, 8, ENC_NA);
4474
4475         offset = offset + decode_triplet(tvb, offset + 13, ext_tree_mm, count) + 13;
4476
4477         break;
4478     case 2:                     /* UMTS key and quintuplets */
4479         proto_tree_add_item(ext_tree_mm, hf_gtp_ksi, tvb, offset + 3, 1, ENC_BIG_ENDIAN);
4480         proto_tree_add_item(ext_tree_mm, hf_gtp_security_mode, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
4481         proto_tree_add_item(ext_tree_mm, hf_gtp_no_of_vectors, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
4482         proto_tree_add_item(ext_tree_mm, hf_gtp_ciphering_key_ck, tvb, offset + 5, 16, ENC_NA);
4483         proto_tree_add_item(ext_tree_mm, hf_gtp_integrity_key_ik, tvb, offset + 21, 16, ENC_NA);
4484        proto_tree_add_item(ext_tree_mm, hf_gtp_quintuplets_length, tvb, offset + 37, 2, ENC_BIG_ENDIAN);
4485
4486         offset = offset + decode_quintuplet(tvb, offset + 39, ext_tree_mm, count) + 39;
4487
4488         break;
4489     case 3:                     /* GSM key and quintuplets */
4490         proto_tree_add_item(ext_tree_mm, hf_gtp_cksn,             tvb, offset + 3, 1, ENC_BIG_ENDIAN);
4491         proto_tree_add_item(ext_tree_mm, hf_gtp_security_mode,    tvb, offset + 4, 1, ENC_BIG_ENDIAN);
4492         proto_tree_add_item(ext_tree_mm, hf_gtp_no_of_vectors,    tvb, offset + 4, 1, ENC_BIG_ENDIAN);
4493         proto_tree_add_item(ext_tree_mm, hf_gtp_cipher_algorithm, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
4494         proto_tree_add_item(ext_tree_mm, hf_gtp_ciphering_key_kc, tvb, offset + 5, 8, ENC_NA);
4495         proto_tree_add_item(ext_tree_mm, hf_gtp_quintuplets_length, tvb, offset + 13, 2, ENC_BIG_ENDIAN);
4496
4497         offset = offset + decode_quintuplet(tvb, offset + 15, ext_tree_mm, count) + 15;
4498
4499         break;
4500     default:
4501         break;
4502     }
4503
4504 /*
4505  * 3GPP TS 24.008 10.5.5.6 ( see packet-gsm_a.c )
4506  */
4507     tf_tree = proto_tree_add_subtree(ext_tree_mm, tvb, offset, 2, ett_gtp_drx, NULL, "DRX Parameter");
4508     de_gmm_drx_param(tvb, tf_tree, pinfo, offset, 2, NULL, 0);
4509     offset = offset + 2;
4510
4511     len = tvb_get_guint8(tvb, offset);
4512     tf_tree = proto_tree_add_subtree(ext_tree_mm, tvb, offset, len + 1, ett_gtp_net_cap, NULL, "MS Network Capability");
4513
4514     proto_tree_add_uint(tf_tree, hf_gtp_ms_network_cap_content_len, tvb, offset, 1, len);
4515
4516     offset++;
4517 /*
4518  * GPP TS 24.008 10.5.5.12 ( see packet-gsm_a.c )
4519  */
4520     de_gmm_ms_net_cap(tvb, tf_tree, pinfo, offset, len, NULL, 0);
4521     offset = offset + len;
4522
4523 /* 3GPP TS 29.060 version 9.4.0 Release 9
4524  *  The two octets Container Length holds the length of the Container, excluding the Container Length octets.
4525  * Container contains one or several optional information elements as described in the clause "Overview", from the clause
4526  * "General message format and information elements coding" in 3GPP TS 24.008 [5]. For the definition of the IEI see
4527  * table 47a, "IEIs for information elements used in the container". The IMEISV shall, if available, be included in the
4528  * Container. The IMEISV is included in the Mobile identity IE. If Container is not included, its Length field value shall
4529  * be set to 0. If the MS is emergency attached and the MS is UICCless or the IMSI is unauthenticated, the International
4530  * Mobile Equipment Identity (IMEI) shall be used as the MS identity.
4531  *
4532  * Table 47A: IEIs for information elements used in the container
4533  * IEI            Information element
4534  * 0x23           Mobile identity
4535  *
4536  * NOTE: In 3GPP TS 24.008 [5] the IEI definition is
4537  * message dependent. The table is added to
4538  * have a unique definition in the present
4539  * document for the used IEI in the MMcontext.
4540  */
4541
4542     con_len = tvb_get_ntohs(tvb, offset);
4543     proto_tree_add_item(ext_tree_mm, hf_gtp_container_length, tvb, offset, 2, ENC_BIG_ENDIAN);
4544     offset = offset + 2;
4545
4546     if (con_len > 0) {
4547         proto_item* ti;
4548
4549         con_tree = proto_tree_add_subtree(ext_tree_mm, tvb, offset, con_len, ett_gtp_mm_cntxt, NULL, "Container");
4550
4551         iei = tvb_get_guint8(tvb,offset);
4552         ti = proto_tree_add_uint(con_tree, hf_gtp_iei, tvb, offset, 1, iei);
4553         if (iei == 0x23) {
4554             proto_item_append_text(ti, " (Mobile identity)");
4555             offset++;
4556             len = tvb_get_guint8(tvb,offset);
4557             proto_tree_add_uint(con_tree, hf_gtp_iei_mobile_id_len, tvb, offset, 1, len);
4558             offset++;
4559             de_mid(tvb, con_tree, pinfo, offset, len, NULL, 0);
4560         } else {
4561             expert_add_info(pinfo, ti, &ei_gtp_iei);
4562         }
4563     }
4564
4565     return 3 + length;
4566 }
4567
4568 /* Function to extract the value of an hexadecimal octet. Only the lower
4569  * nybble will be non-zero in the output.
4570  * */
4571 static guint8
4572 hex2dec(guint8 x)
4573 {
4574     /* XXX, ws_xton() */
4575     if ((x >= 'a') && (x <= 'f'))
4576         x = x - 'a' + 10;
4577     else if ((x >= 'A') && (x <= 'F'))
4578         x = x - 'A' + 10;
4579     else if ((x >= '0') && (x <= '9'))
4580         x = x - '0';
4581     else
4582         x = 0;
4583     return x;
4584 }
4585
4586 /* Wrapper function to add UTF-8 decoding for QoS attributes in
4587  * RADIUS messages.
4588  * */
4589 static guint8
4590 wrapped_tvb_get_guint8(tvbuff_t * tvb, int offset, int type)
4591 {
4592     if (type == 2)
4593         return (hex2dec(tvb_get_guint8(tvb, offset)) << 4 | hex2dec(tvb_get_guint8(tvb, offset + 1)));
4594     else
4595         return tvb_get_guint8(tvb, offset);
4596 }
4597
4598  /* WARNING : actually length is coded on 2 octets for QoS profile but on 1 octet for PDP Context!
4599   * so type means length of length :-)
4600   *
4601   * WARNING :) type does not mean length of length any more... see below for
4602   * type = 3!
4603   */
4604 int
4605 decode_qos_umts(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, const gchar * qos_str, guint8 type)
4606 {
4607
4608     guint       length;
4609     guint8      al_ret_priority;
4610     guint8      delay, reliability, peak, precedence, mean, spare1, spare2, spare3;
4611     guint8      traf_class, del_order, del_err_sdu;
4612     guint8      max_sdu_size, max_ul, max_dl, max_ul_ext, max_dl_ext, max_ul_ext2 = 0, max_dl_ext2 = 0;
4613     guint8      res_ber, sdu_err_ratio;
4614     guint8      trans_delay, traf_handl_prio;
4615     guint8      guar_ul, guar_dl, guar_ul_ext, guar_dl_ext, guar_ul_ext2 = 0, guar_dl_ext2 = 0;
4616     guint8      src_stat_desc, sig_ind, spare4;
4617     proto_tree *ext_tree_qos;
4618     int         mss, mu, md, gu, gd;
4619     guint8      arp, qci;
4620     guint32     apn_ambr;
4621     guint64     br;
4622
4623     /* Will keep if the input is UTF-8 encoded (as in RADIUS messages).
4624      * If 1, input is *not* UTF-8 encoded (i.e. each input octet corresponds
4625      * to one byte to be dissected).
4626      * If 2, input is UTF-8 encoded (i.e. each *couple* of input octets
4627      * corresponds to one byte to be dissected)
4628      * */
4629     guint8 utf8_type = 1;
4630
4631     /* Will keep the release indicator as indicated in the RADIUS message */
4632     guint8 rel_ind = 0;
4633
4634     /* In RADIUS messages the QoS has a version field of two octets prepended.
4635      * As of 29.061 v.3.a.0, there is an hyphen between "Release Indicator" and
4636      * <release specific QoS IE UTF-8 encoding>. Even if it sounds rather
4637      * inconsistent and unuseful, I will check hyphen presence here and
4638      * will signal its presence.
4639      * */
4640     guint8 hyphen;
4641
4642     /* Will keep the value that will be returned
4643      * */
4644     int retval = 0;
4645
4646     switch (type) {
4647     case 0:
4648         /* For QoS inside GPRS-CDR messages from GGSN/P-GW */
4649         length = tvb_reported_length(tvb);
4650         ext_tree_qos = proto_tree_add_subtree(tree, tvb, offset, length, ett_gtp_qos, NULL, qos_str);
4651         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_umts_length, tvb, offset, 1, length);
4652         /* QoS inside GPRS-CDR has no length octet, so no extra offset needed */
4653         retval = length;
4654         break;
4655     case 1:
4656         length = tvb_get_guint8(tvb, offset);
4657         ext_tree_qos = proto_tree_add_subtree(tree, tvb, offset, length + 1, ett_gtp_qos, NULL, qos_str);
4658         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_umts_length, tvb, offset, 1, length);
4659         offset++;
4660         retval = length + 1;
4661         break;
4662     case 2:
4663         length = tvb_get_ntohs(tvb, offset + 1);
4664         ext_tree_qos = proto_tree_add_subtree(tree, tvb, offset, length + 3, ett_gtp_qos, NULL, qos_str);
4665         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_umts_length, tvb, offset + 1, 2, length);
4666         offset += 3;            /* +1 because of first 0x86 byte for UMTS QoS */
4667         retval = length + 3;
4668         break;
4669     case 3:
4670         /* For QoS inside RADIUS Client messages from GGSN/P-GW */
4671         utf8_type = 2;
4672
4673         /* The field in the RADIUS message is the length of the tvb we were given */
4674         length = tvb_reported_length(tvb);
4675         ext_tree_qos = proto_tree_add_subtree(tree, tvb, offset, length, ett_gtp_qos, NULL, qos_str);
4676
4677         rel_ind = wrapped_tvb_get_guint8(tvb, offset, 2);
4678         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_version, tvb, offset, 2, rel_ind);
4679
4680         /* Hyphen handling */
4681         hyphen = tvb_get_guint8(tvb, offset + 2);
4682         if (hyphen == ((guint8) '-')) {
4683             /* Hyphen is present, put in protocol tree */
4684             proto_tree_add_item(ext_tree_qos, hf_gtp_hyphen_separator, tvb, offset + 2, 1, ENC_NA);
4685             offset++;           /* "Get rid" of hyphen */
4686         }
4687
4688         /* Now, we modify offset here and in order to use type later
4689          * effectively.*/
4690         offset++;
4691
4692         length -= offset;
4693         length /= 2;
4694
4695         /* Fake the length of the IE including the IE id and length octets
4696          * we are actually using it to determine precense of Octet n as counted in
4697          * TS 24.008
4698          */
4699         length = retval = length + 2;    /* Actually, will be ignored. */
4700         break;
4701     default:
4702         /* XXX - what should we do with the length here? */
4703         length = 0;
4704         retval = 0;
4705         ext_tree_qos = NULL;
4706         break;
4707     }
4708
4709     if ((type == 3) && (rel_ind == 8)) {
4710         /* Release 8 or higher P-GW QoS profile */
4711         static const int * arp_flags[] = {
4712             &hf_gtp_qos_arp_pci,
4713             &hf_gtp_qos_arp_pl,
4714             &hf_gtp_qos_arp_pvi,
4715             NULL
4716         };
4717
4718         offset++;
4719         arp = wrapped_tvb_get_guint8(tvb, offset, 2);
4720         proto_tree_add_bitmask_value_with_flags(ext_tree_qos, tvb, offset, hf_gtp_qos_arp,
4721                     ett_gtp_qos_arp, arp_flags, arp, BMT_NO_APPEND);
4722         offset += 2;
4723
4724         qci = wrapped_tvb_get_guint8(tvb, offset, 2);
4725         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_qci, tvb, offset, 2, qci);
4726         offset += 2;
4727         if (qci <= 4) {
4728             /* GBR QCI */
4729             br = ((guint64)wrapped_tvb_get_guint8(tvb, offset  , 2) << 32) |
4730                  ((guint64)wrapped_tvb_get_guint8(tvb, offset+2, 2) << 24) |
4731                  ((guint64)wrapped_tvb_get_guint8(tvb, offset+4, 2) << 16) |
4732                  ((guint64)wrapped_tvb_get_guint8(tvb, offset+6, 2) <<  8) |
4733                   (guint64)wrapped_tvb_get_guint8(tvb, offset+8, 2);
4734             proto_tree_add_uint64(ext_tree_qos, hf_gtp_qos_ul_mbr, tvb, offset, 10, br);
4735             offset += 10;
4736             br = ((guint64)wrapped_tvb_get_guint8(tvb, offset  , 2) << 32) |
4737                  ((guint64)wrapped_tvb_get_guint8(tvb, offset+2, 2) << 24) |
4738                  ((guint64)wrapped_tvb_get_guint8(tvb, offset+4, 2) << 16) |
4739                  ((guint64)wrapped_tvb_get_guint8(tvb, offset+6, 2) <<  8) |
4740                   (guint64)wrapped_tvb_get_guint8(tvb, offset+8, 2);
4741             proto_tree_add_uint64(ext_tree_qos, hf_gtp_qos_dl_mbr, tvb, offset, 10, br);
4742             offset += 10;
4743             br = ((guint64)wrapped_tvb_get_guint8(tvb, offset  , 2) << 32) |
4744                  ((guint64)wrapped_tvb_get_guint8(tvb, offset+2, 2) << 24) |
4745                  ((guint64)wrapped_tvb_get_guint8(tvb, offset+4, 2) << 16) |
4746                  ((guint64)wrapped_tvb_get_guint8(tvb, offset+6, 2) <<  8) |
4747                   (guint64)wrapped_tvb_get_guint8(tvb, offset+8, 2);
4748             proto_tree_add_uint64(ext_tree_qos, hf_gtp_qos_ul_gbr, tvb, offset, 10, br);
4749             offset += 10;
4750             br = ((guint64)wrapped_tvb_get_guint8(tvb, offset  , 2) << 32) |
4751                  ((guint64)wrapped_tvb_get_guint8(tvb, offset+2, 2) << 24) |
4752                  ((guint64)wrapped_tvb_get_guint8(tvb, offset+4, 2) << 16) |
4753                  ((guint64)wrapped_tvb_get_guint8(tvb, offset+6, 2) <<  8) |
4754                   (guint64)wrapped_tvb_get_guint8(tvb, offset+8, 2);
4755             proto_tree_add_uint64(ext_tree_qos, hf_gtp_qos_dl_gbr, tvb, offset, 10, br);
4756         } else {
4757             /* non GBR QCI */
4758             apn_ambr = (wrapped_tvb_get_guint8(tvb, offset  , 2) << 24) |
4759                        (wrapped_tvb_get_guint8(tvb, offset+2, 2) << 16) |
4760                        (wrapped_tvb_get_guint8(tvb, offset+4, 2) <<  8) |
4761                         wrapped_tvb_get_guint8(tvb, offset+6, 2);
4762             proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_ul_apn_ambr, tvb, offset, 8, apn_ambr);
4763             offset += 8;
4764             apn_ambr = (wrapped_tvb_get_guint8(tvb, offset  , 2) << 24) |
4765                        (wrapped_tvb_get_guint8(tvb, offset+2, 2) << 16) |
4766                        (wrapped_tvb_get_guint8(tvb, offset+4, 2) <<  8) |
4767                         wrapped_tvb_get_guint8(tvb, offset+6, 2);
4768             proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_dl_apn_ambr, tvb, offset, 8, apn_ambr);
4769         }
4770         return retval;
4771     }
4772
4773     /* In RADIUS messages there is no allocation-retention priority
4774      * so I don't need to wrap the following call to tvb_get_guint8
4775      * */
4776     al_ret_priority = tvb_get_guint8(tvb, offset);
4777
4778     /* All calls are wrapped to take into account the possibility that the
4779      * input is UTF-8 encoded. If utf8_type is equal to 1, the final value
4780      * of the offset will be the same as in the previous version of this
4781      * dissector, and the wrapped function will serve as a dumb wrapper;
4782      * otherwise, if utf_8_type is 2, the offset is correctly shifted by
4783      * two bytes for needed shift, and the wrapped function will unencode
4784      * two values from the input.
4785      * */
4786     spare1      = wrapped_tvb_get_guint8(tvb, offset + (1 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_SPARE1_MASK;
4787     delay       = wrapped_tvb_get_guint8(tvb, offset + (1 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_DELAY_MASK;
4788     reliability = wrapped_tvb_get_guint8(tvb, offset + (1 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_RELIABILITY_MASK;
4789     peak        = wrapped_tvb_get_guint8(tvb, offset + (2 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_PEAK_MASK;
4790     spare2      = wrapped_tvb_get_guint8(tvb, offset + (2 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_SPARE2_MASK;
4791     precedence  = wrapped_tvb_get_guint8(tvb, offset + (2 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_PRECEDENCE_MASK;
4792     spare3      = wrapped_tvb_get_guint8(tvb, offset + (3 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_SPARE3_MASK;
4793     mean        = wrapped_tvb_get_guint8(tvb, offset + (3 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_MEAN_MASK;
4794
4795     /* In RADIUS messages there is no allocation-retention priority */
4796     if (type != 3)
4797         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_al_ret_priority, tvb, offset, 1, al_ret_priority);
4798
4799     /* All additions must take care of the fact that QoS fields in RADIUS
4800      * messages are UTF-8 encoded, so we have to use the same trick as above.
4801      * */
4802     proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_spare1,      tvb, offset + (1 - 1) * utf8_type + 1, utf8_type, spare1);
4803     proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_delay,       tvb, offset + (1 - 1) * utf8_type + 1, utf8_type, delay);
4804     proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_reliability, tvb, offset + (1 - 1) * utf8_type + 1, utf8_type, reliability);
4805     proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_peak,        tvb, offset + (2 - 1) * utf8_type + 1, utf8_type, peak);
4806     proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_spare2,      tvb, offset + (2 - 1) * utf8_type + 1, utf8_type, spare2);
4807     proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_precedence,  tvb, offset + (2 - 1) * utf8_type + 1, utf8_type, precedence);
4808     proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_spare3,      tvb, offset + (3 - 1) * utf8_type + 1, utf8_type, spare3);
4809     proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_mean,        tvb, offset + (3 - 1) * utf8_type + 1, utf8_type, mean);
4810
4811     /* TS 24.008 V 7.8.0 10.5.6.5 Quality of service
4812      * The quality of service is a type 4 information element with a minimum length of 14 octets and a maximum length of 18
4813      * octets. The QoS requested by the MS shall be encoded both in the QoS attributes specified in octets 3-5 and in the QoS
4814      * attributes specified in octets 6-14.
4815      * In the MS to network direction and in the network to MS direction the following applies:
4816      * - Octets 15-18 are optional. If octet 15 is included, then octet 16 shall also be included, and octets 17 and 18 may
4817      * be included.
4818      * - If octet 17 is included, then octet 18 shall also be included.
4819      * - A QoS IE received without octets 6-18, without octets 14-18, without octets 15-18, or without octets 17-18 shall
4820      * be accepted by the receiving entity.
4821      */
4822
4823     if (length > 4) {
4824
4825         /* See above for the need of wrapping
4826          *
4827          */
4828         /* Octet 6 */
4829         traf_class      = wrapped_tvb_get_guint8(tvb, offset + (4 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_TRAF_CLASS_MASK;
4830         del_order       = wrapped_tvb_get_guint8(tvb, offset + (4 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_DEL_ORDER_MASK;
4831         del_err_sdu     = wrapped_tvb_get_guint8(tvb, offset + (4 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_DEL_ERR_SDU_MASK;
4832         max_sdu_size    = wrapped_tvb_get_guint8(tvb, offset + (5 - 1) * utf8_type + 1, utf8_type);
4833         max_ul          = wrapped_tvb_get_guint8(tvb, offset + (6 - 1) * utf8_type + 1, utf8_type);
4834         max_dl          = wrapped_tvb_get_guint8(tvb, offset + (7 - 1) * utf8_type + 1, utf8_type);
4835         res_ber         = wrapped_tvb_get_guint8(tvb, offset + (8 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_RES_BER_MASK;
4836         sdu_err_ratio   = wrapped_tvb_get_guint8(tvb, offset + (8 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_SDU_ERR_RATIO_MASK;
4837         trans_delay     = wrapped_tvb_get_guint8(tvb, offset + (9 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_TRANS_DELAY_MASK;
4838         traf_handl_prio = wrapped_tvb_get_guint8(tvb, offset + (9 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_TRAF_HANDL_PRIORITY_MASK;
4839         guar_ul         = wrapped_tvb_get_guint8(tvb, offset + (10 - 1) * utf8_type + 1, utf8_type);
4840         /* Octet 13 */
4841         guar_dl         = wrapped_tvb_get_guint8(tvb, offset + (11 - 1) * utf8_type + 1, utf8_type);
4842
4843         spare4        = 0;
4844         sig_ind       = 0;
4845         src_stat_desc = 0;
4846         max_dl_ext    = 0;
4847         guar_dl_ext   = 0;
4848         max_ul_ext    = 0;
4849         guar_ul_ext   = 0;
4850
4851         if (length > 13 ||((type == 2) && (length == 13))) {
4852             spare4        = wrapped_tvb_get_guint8(tvb, offset + (12 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_SPARE4_MASK;
4853             sig_ind       = wrapped_tvb_get_guint8(tvb, offset + (12 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_SIG_IND_MASK;
4854             src_stat_desc = wrapped_tvb_get_guint8(tvb, offset + (12 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_SRC_STAT_DESC_MASK;
4855         }
4856         if (length > 14) {
4857             max_dl_ext  = wrapped_tvb_get_guint8(tvb, offset + (13 - 1) * utf8_type + 1, utf8_type);
4858             guar_dl_ext = wrapped_tvb_get_guint8(tvb, offset + (14 - 1) * utf8_type + 1, utf8_type);
4859         }
4860         if (length > 16) {
4861             max_ul_ext = wrapped_tvb_get_guint8(tvb, offset + (15 - 1) * utf8_type + 1, utf8_type);
4862             guar_ul_ext = wrapped_tvb_get_guint8(tvb, offset + (16 - 1) * utf8_type + 1, utf8_type);
4863         }
4864         if (length > 18) {
4865             max_dl_ext2 = wrapped_tvb_get_guint8(tvb, offset + (17 - 1) * utf8_type + 1, utf8_type);
4866             guar_dl_ext2 = wrapped_tvb_get_guint8(tvb, offset + (18 - 1) * utf8_type + 1, utf8_type);
4867         }
4868         if (length > 20) {
4869             max_ul_ext2 = wrapped_tvb_get_guint8(tvb, offset + (19 - 1) * utf8_type + 1, utf8_type);
4870             guar_ul_ext2 = wrapped_tvb_get_guint8(tvb, offset + (20 - 1) * utf8_type + 1, utf8_type);
4871         }
4872
4873         /*
4874          * See above comments for the changes
4875          */
4876         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_traf_class,  tvb, offset + (4 - 1) * utf8_type + 1, utf8_type, traf_class);
4877         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_del_order,   tvb, offset + (4 - 1) * utf8_type + 1, utf8_type, del_order);
4878         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_del_err_sdu, tvb, offset + (4 - 1) * utf8_type + 1, utf8_type, del_err_sdu);
4879         if (max_sdu_size == 0 || max_sdu_size > 150)
4880             proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_max_sdu_size, tvb, offset + (5 - 1) * utf8_type + 1, utf8_type, max_sdu_size);
4881         if ((max_sdu_size > 0) && (max_sdu_size <= 150)) {
4882             mss = max_sdu_size * 10;
4883             proto_tree_add_uint_format_value(ext_tree_qos, hf_gtp_qos_max_sdu_size, tvb, offset + (5 - 1) * utf8_type + 1, utf8_type, mss,
4884                                        "%u octets", mss);
4885         }
4886
4887         if (max_ul == 0 || max_ul == 255)
4888             proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset + (6 - 1) * utf8_type + 1, utf8_type, max_ul);
4889         if ((max_ul > 0) && (max_ul <= 63))
4890             proto_tree_add_uint_format_value(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset + (6 - 1) * utf8_type + 1, utf8_type, max_ul,
4891                                        "%u kbps", max_ul);
4892         if ((max_ul > 63) && (max_ul <= 127)) {
4893             mu = 64 + (max_ul - 64) * 8;
4894             proto_tree_add_uint_format_value(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset + (6 - 1) * utf8_type + 1, utf8_type, mu,
4895                                        "%u kbps", mu);
4896         }
4897
4898         if ((max_ul > 127) && (max_ul <= 254)) {
4899             mu = 576 + (max_ul - 128) * 64;
4900             proto_tree_add_uint_format_value(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset + (6 - 1) * utf8_type + 1, utf8_type, mu,
4901                                        "%u kbps", mu);
4902         }
4903
4904         if (max_dl == 0 || max_dl == 255)
4905             proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_max_dl, tvb, offset + (7 - 1) * utf8_type + 1, utf8_type, max_dl);
4906         if ((max_dl > 0) && (max_dl <= 63))
4907             proto_tree_add_uint_format_value(ext_tree_qos, hf_gtp_qos_max_dl, tvb, offset + (7 - 1) * utf8_type + 1, utf8_type, max_dl,
4908                                        "%u kbps", max_dl);
4909         if ((max_dl > 63) && (max_dl <= 127)) {
4910             md = 64 + (max_dl - 64) * 8;
4911             proto_tree_add_uint_format_value(ext_tree_qos, hf_gtp_qos_max_dl, tvb, offset + (7 - 1) * utf8_type + 1, utf8_type, md,
4912                                        "%u kbps", md);
4913         }
4914         if ((max_dl > 127) && (max_dl <= 254)) {
4915             md = 576 + (max_dl - 128) * 64;
4916             proto_tree_add_uint_format_value(ext_tree_qos, hf_gtp_qos_max_dl, tvb, offset + (7 - 1) * utf8_type + 1, utf8_type, md,
4917                                        "%u kbps", md);
4918         }
4919
4920         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_res_ber,         tvb, offset + (8 - 1) * utf8_type + 1, utf8_type, res_ber);
4921         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_sdu_err_ratio,   tvb, offset + (8 - 1) * utf8_type + 1, utf8_type, sdu_err_ratio);
4922         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_trans_delay,     tvb, offset + (9 - 1) * utf8_type + 1, utf8_type, trans_delay);
4923         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_traf_handl_prio, tvb, offset + (9 - 1) * utf8_type + 1, utf8_type, traf_handl_prio);
4924
4925         if (guar_ul == 0 || guar_ul == 255)
4926             proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset + (10 - 1) * utf8_type + 1, utf8_type, guar_ul);
4927         if ((guar_ul > 0) && (guar_ul <= 63))
4928             proto_tree_add_uint_format_value(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset + (10 - 1) * utf8_type + 1, utf8_type, guar_ul,
4929                                        "%u kbps", guar_ul);
4930         if ((guar_ul > 63) && (guar_ul <= 127)) {
4931             gu = 64 + (guar_ul - 64) * 8;
4932             proto_tree_add_uint_format_value(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset + (10 - 1) * utf8_type + 1, utf8_type, gu,
4933                                        "%u kbps", gu);
4934         }
4935         if ((guar_ul > 127) && (guar_ul <= 254)) {
4936             gu = 576 + (guar_ul - 128) * 64;
4937             proto_tree_add_uint_format_value(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset + (10 - 1) * utf8_type + 1, utf8_type, gu,
4938                                        "%u kbps", gu);
4939         }
4940
4941         /* Octet 13 */
4942         if (guar_dl == 0 || guar_dl == 255)
4943             proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_guar_dl, tvb, offset + (11 - 1) * utf8_type + 1, utf8_type, guar_dl);
4944         if ((guar_dl > 0) && (guar_dl <= 63))
4945             proto_tree_add_uint_format_value(ext_tree_qos, hf_gtp_qos_guar_dl, tvb, offset + (11 - 1) * utf8_type + 1, utf8_type, guar_dl,
4946                                        "%u kbps", guar_dl);
4947         if ((guar_dl > 63) && (guar_dl <= 127)) {
4948             gd = 64 + (guar_dl - 64) * 8;
4949             proto_tree_add_uint_format_value(ext_tree_qos, hf_gtp_qos_guar_dl, tvb, offset + (11 - 1) * utf8_type + 1, utf8_type, gd,
4950                                        "%u kbps", gd);
4951         }
4952         if ((guar_dl > 127) && (guar_dl <= 254)) {
4953             gd = 576 + (guar_dl - 128) * 64;
4954             proto_tree_add_uint_format_value(ext_tree_qos, hf_gtp_qos_guar_dl, tvb, offset + (11 - 1) * utf8_type + 1, utf8_type, gd,
4955                                        "%u kbps", gd);
4956         }
4957
4958         if(length > 13 ||((type == 2) && (length == 13))) {
4959             proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_spare4, tvb, offset + (12 - 1) * utf8_type + 1, utf8_type, spare4);
4960             proto_tree_add_boolean(ext_tree_qos, hf_gtp_qos_sig_ind, tvb, offset + (12 - 1) * utf8_type + 1, utf8_type, sig_ind);
4961             proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_src_stat_desc, tvb, offset + (12 - 1) * utf8_type + 1, utf8_type, src_stat_desc);
4962         }
4963
4964
4965         if(length > 14) {
4966             /* Octet 15 */
4967             if ((max_dl_ext > 0) && (max_dl_ext <= 0x4a)) {
4968                 md = 8600 + max_dl_ext * 100;
4969                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_dl, tvb, offset + (13 - 1) * utf8_type + 1, utf8_type, md,
4970                                            "Ext Maximum bit rate for downlink: %u kbps", md);
4971             }
4972             if ((max_dl_ext > 0x4a) && (max_dl_ext <= 0xba)) {
4973                 md = 16 + (max_dl_ext-0x4a);
4974                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_dl, tvb, offset + (13 - 1) * utf8_type + 1, utf8_type, md,
4975                                            "Ext Maximum bit rate for downlink: %u Mbps", md);
4976             }
4977             if ((max_dl_ext > 0xba) && (max_dl_ext <= 0xfa)) {
4978                 md = 128 + (max_dl_ext-0xba)*2;
4979                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_dl, tvb, offset + (13 - 1) * utf8_type + 1, utf8_type, md,
4980                                            "Ext Maximum bit rate for downlink: %u Mbps", md);
4981             }
4982             /* Octet 16 */
4983             if(guar_dl_ext == 0)
4984                 proto_tree_add_expert_format(ext_tree_qos, pinfo, &ei_gtp_guaranteed_bit_rate_value, tvb, offset + (14 - 1) * utf8_type + 1, utf8_type,
4985                                            "Use the value indicated by the Guaranteed bit rate for downlink in octet 13");
4986             if ((guar_dl_ext > 0) && (guar_dl_ext <= 0x4a)) {
4987                 gd = 8600 + guar_dl_ext * 100;
4988                 proto_tree_add_uint_format_value(ext_tree_qos, hf_gtp_qos_guar_dl, tvb, offset + (14 - 1) * utf8_type + 1, utf8_type, gd,
4989                                            "%u kbps", gd);
4990             }
4991             if ((guar_dl_ext > 0x4a) && (max_dl_ext <= 0xba)) {
4992                 gd = 16 + (guar_dl_ext-0x4a);
4993                 proto_tree_add_uint_format_value(ext_tree_qos, hf_gtp_qos_guar_dl, tvb, offset + (14 - 1) * utf8_type + 1, utf8_type, gd,
4994                                            "%u Mbps", gd);
4995             }
4996             if ((guar_dl_ext > 0xba) && (max_dl_ext <= 0xfa)) {
4997                 gd = 128 + (guar_dl_ext-0xba)*2;
4998                 proto_tree_add_uint_format_value(ext_tree_qos, hf_gtp_qos_guar_dl, tvb, offset + (14 - 1) * utf8_type + 1, utf8_type, gd,
4999                                            "%u Mbps", gd);
5000             }
5001
5002         }
5003         if(length > 16) {
5004             /* Octet 17
5005              * This field is an extension of the Maximum bit rate for uplink in octet 8. The coding is identical to that of the Maximum bit
5006              * rate for downlink (extended).
5007              */
5008             if ((max_ul_ext > 0) && (max_ul_ext <= 0x4a)) {
5009                 md = 8600 + max_ul_ext * 100;
5010                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset + (15 - 1) * utf8_type + 1, utf8_type, md,
5011                                            "Ext Maximum bit rate for uplink: %u kbps", md);
5012             }
5013             if ((max_ul_ext > 0x4a) && (max_ul_ext <= 0xba)) {
5014                 md = 16 + (max_ul_ext-0x4a);
5015                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset + (15 - 1) * utf8_type + 1, utf8_type, md,
5016                                            "Ext Maximum bit rate for uplink: %u Mbps", md);
5017             }
5018             if ((max_ul_ext > 0xba) && (max_ul_ext <= 0xfa)) {
5019                 md = 128 + (max_ul_ext-0xba)*2;
5020                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset + (15 - 1) * utf8_type + 1, utf8_type, md,
5021                                            "Ext Maximum bit rate for uplink: %u Mbps", md);
5022             }
5023             /* Octet 18 */
5024             if (guar_ul_ext == 0)
5025                 proto_tree_add_expert_format(ext_tree_qos, pinfo, &ei_gtp_guaranteed_bit_rate_value, tvb, offset + (16 - 1) * utf8_type + 1, utf8_type,
5026                                            "Use the value indicated by the Guaranteed bit rate for uplink in octet 12");
5027             if ((guar_ul_ext > 0) && (guar_ul_ext <= 0x4a)) {
5028                 gd = 8600 + guar_ul_ext * 100;
5029                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset + (16 - 1) * utf8_type + 1, utf8_type, gd,
5030                                            "Ext Guaranteed bit rate for uplink: %u kbps", gd);
5031             }
5032             if ((guar_ul_ext > 0x4a) && (guar_ul_ext <= 0xba)) {
5033                 gd = 16 + (guar_ul_ext-0x4a);
5034                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset + (16 - 1) * utf8_type + 1, utf8_type, gd,
5035                                            "Ext Guaranteed bit rate for uplink: %u Mbps", gd);
5036             }
5037             if ((guar_ul_ext > 0xba) && (guar_ul_ext <= 0xfa)) {
5038                 gd = 128 + (guar_ul_ext-0xba)*2;
5039                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset + (16 - 1) * utf8_type + 1, utf8_type, gd,
5040                                            "Ext Guaranteed bit rate for uplink: %u Mbps", gd);
5041             }
5042         }
5043
5044         if(length > 18) {
5045             /* Octet 19 Maximum bit rate for downlink (extended-2)
5046              * This field is an extension of the Maximum bit rate for uplink in octet 8. The coding is identical to that of the Maximum bit
5047              * rate for downlink (extended).
5048              */
5049             if (guar_dl_ext2 == 0)
5050                 proto_tree_add_expert_format(ext_tree_qos, pinfo, &ei_gtp_max_bit_rate_value, tvb, offset + (17 - 1) * utf8_type + 1, utf8_type,
5051                                            "Use the value indicated by the Maximum bit rate for downlink in octet 9 and octet 15.");
5052
5053             if ((max_dl_ext2 > 0) && (max_dl_ext2 <= 0x3d)) {
5054                 md = 256 + max_dl_ext2 * 4;
5055                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset + (15 - 1) * utf8_type + 1, utf8_type, md,
5056                                            "Ext Maximum bit rate for downlink: %u Mbps", md);
5057             }
5058             if ((max_dl_ext2 > 0x3d) && (max_dl_ext2 <= 0xa1)) {
5059                 md = 500 + (max_dl_ext2-0x3d) * 10;
5060                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset + (15 - 1) * utf8_type + 1, utf8_type, md,
5061                                            "Ext Maximum bit rate for downlink: %u Mbps", md);
5062             }
5063             if ((max_dl_ext2 > 0xa1) && (max_dl_ext2 <= 0xf6)) {
5064                 md = 1500 + (max_dl_ext2-0xa1)*10;
5065                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset + (15 - 1) * utf8_type + 1, utf8_type, md,
5066                                            "Ext Maximum bit rate for downlink: %u Mbps", md);
5067             }
5068             /* Octet 20 Guaranteed bit rate for downlink (extended-2) */
5069             if (max_dl_ext2 == 0)
5070                 proto_tree_add_expert_format(ext_tree_qos, pinfo, &ei_gtp_max_bit_rate_value, tvb, offset + (16 - 1) * utf8_type + 1, utf8_type,
5071                                            "Use the value indicated by the Maximum bit rate for downlink in octet 13 and octet 16.");
5072             if ((max_dl_ext2 > 0) && (max_dl_ext2 <= 0x3d)) {
5073                 gd = 256 + max_dl_ext2 * 4;
5074                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset + (16 - 1) * utf8_type + 1, utf8_type, gd,
5075                                            "Ext Guaranteed bit rate for downlink: %u Mbps", gd);
5076             }
5077             if ((max_dl_ext2 > 0x3d) && (max_dl_ext2 <= 0xa1)) {
5078                 gd = 500 + (max_dl_ext2-0x3d) * 10;
5079                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset + (16 - 1) * utf8_type + 1, utf8_type, gd,
5080                                            "Ext Guaranteed bit rate for downlink: %u Mbps", gd);
5081             }
5082             if ((max_dl_ext2 > 0xba) && (max_dl_ext2 <= 0xfa)) {
5083                 gd = 1500 + (max_dl_ext2-0xa1) * 10;
5084                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset + (16 - 1) * utf8_type + 1, utf8_type, gd,
5085                                            "Ext Guaranteed bit rate for uplink: %u Mbps", gd);
5086             }
5087         }
5088
5089         if(length > 20) {
5090             /* Maximum bit rate for uplink (extended-2), octet 21
5091              * This field is an extension of the Maximum bit rate for uplink in octet 8. The coding is identical to that of the Maximum bit
5092              * rate for downlink (extended).
5093              */
5094             if (guar_ul_ext2 == 0)
5095                 proto_tree_add_expert_format(ext_tree_qos, pinfo, &ei_gtp_max_bit_rate_value, tvb, offset + (17 - 1) * utf8_type + 1, utf8_type,
5096                                            "Use the value indicated by the Maximum bit rate for uplink in octet 9 and octet 15.");
5097
5098             if ((max_ul_ext2 > 0) && (max_ul_ext2 <= 0x3d)) {
5099                 md = 256 + max_ul_ext2 * 4;
5100                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset + (15 - 1) * utf8_type + 1, utf8_type, md,
5101                                            "Ext Maximum bit rate for uplink: %u Mbps", md);
5102             }
5103             if ((max_ul_ext2 > 0x3d) && (max_ul_ext2 <= 0xa1)) {
5104                 md = 500 + (max_ul_ext2-0x3d) * 10;
5105                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset + (15 - 1) * utf8_type + 1, utf8_type, md,
5106                                            "Ext Maximum bit rate for uplink: %u Mbps", md);
5107             }
5108             if ((max_ul_ext2 > 0xa1) && (max_ul_ext2 <= 0xf6)) {
5109                 md = 1500 + (max_ul_ext2-0xa1)*10;
5110                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset + (15 - 1) * utf8_type + 1, utf8_type, md,
5111                                            "Ext Maximum bit rate for uplink: %u Mbps", md);
5112             }
5113             /* Guaranteed bit rate for uplink (extended-2), octet 22 */
5114             if (max_ul_ext2 == 0)
5115                 proto_tree_add_expert_format(ext_tree_qos, pinfo, &ei_gtp_max_bit_rate_value, tvb, offset + (16 - 1) * utf8_type + 1, utf8_type,
5116                                            "Use the value indicated by the Maximum bit rate for uplink in octet 13 and octet 16.");
5117             if ((max_ul_ext2 > 0) && (max_ul_ext2 <= 0x3d)) {
5118                 gd = 256 + max_ul_ext2 * 4;
5119                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset + (16 - 1) * utf8_type + 1, utf8_type, gd,
5120                                            "Ext Guaranteed bit rate for uplink: %u Mbps", gd);
5121             }
5122             if ((max_ul_ext2 > 0x3d) && (max_ul_ext2 <= 0xa1)) {
5123                 gd = 500 + (max_ul_ext2-0x3d) * 10;
5124                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset + (16 - 1) * utf8_type + 1, utf8_type, gd,
5125                                            "Ext Guaranteed bit rate for uplink: %u Mbps", gd);
5126             }
5127             if ((max_ul_ext2 > 0xba) && (max_ul_ext2 <= 0xfa)) {
5128                 gd = 1500 + (max_ul_ext2-0xa1) * 10;
5129                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset + (16 - 1) * utf8_type + 1, utf8_type, gd,
5130                                            "Ext Guaranteed bit rate for uplink: %u Mbps", gd);
5131             }
5132         }
5133     }
5134
5135     return retval;
5136 }
5137
5138 /* Diameter 3GPP AVP Code: 5 3GPP-GPRS Negotiated QoS profile */
5139 static int
5140 dissect_diameter_3gpp_qosprofile(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) {
5141
5142     decode_qos_umts(tvb, 0, pinfo, tree, "UMTS GTP QoS Profile", 3);
5143     return tvb_reported_length(tvb);
5144 }
5145
5146 static const gchar *
5147 dissect_radius_qos_umts(proto_tree * tree, tvbuff_t * tvb, packet_info* pinfo)
5148 {
5149     decode_qos_umts(tvb, 0, pinfo, tree, "UMTS GTP QoS Profile", 3);
5150     return tvb_get_string_enc(wmem_packet_scope(), tvb, 0, tvb_reported_length(tvb), ENC_UTF_8|ENC_NA);
5151 }
5152
5153 #define MAX_APN_LENGTH          100
5154
5155 static void
5156 decode_apn(tvbuff_t * tvb, int offset, guint16 length, proto_tree * tree, proto_item *item)
5157 {
5158     guint8   str[MAX_APN_LENGTH+1];
5159     guint    curr_len;
5160
5161     /* init buffer and copy it */
5162     memset(str, 0, MAX_APN_LENGTH+1);
5163     tvb_memcpy(tvb, str, offset, length<MAX_APN_LENGTH?length:MAX_APN_LENGTH);
5164
5165     curr_len = 0;
5166     while ((curr_len < length) && (curr_len < MAX_APN_LENGTH))
5167     {
5168         guint step    = str[curr_len];
5169         str[curr_len] = '.';
5170         curr_len     += step+1;
5171     }
5172
5173     /* Highlight bytes including the first length byte */
5174     proto_tree_add_string(tree, hf_gtp_apn, tvb, offset, length, str+1);
5175     if(item){
5176         proto_item_append_text(item, ": %s", str+1);
5177     }
5178
5179 }
5180
5181 static void
5182 decode_fqdn(tvbuff_t * tvb, int offset, guint16 length, proto_tree * tree, session_args_t * args _U_)
5183 {
5184     guint8 *fqdn = NULL;
5185     int     name_len, tmp;
5186
5187     if (length > 0) {
5188         name_len = tvb_get_guint8(tvb, offset);
5189
5190         if (name_len < 0x20) {
5191             fqdn = tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, length - 1, ENC_ASCII);
5192             for (;;) {
5193                 if (name_len >= length - 1)
5194                     break;
5195                 tmp = name_len;
5196                 name_len = name_len + fqdn[tmp] + 1;
5197                 fqdn[tmp] = '.';
5198             }
5199         } else
5200             fqdn = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_ASCII);
5201
5202         proto_tree_add_string(tree, hf_gtp_fqdn, tvb, offset, length, fqdn);
5203     }
5204 }
5205
5206 /*
5207  * GPRS:        9.60 v7.6.0, chapter 7.9.20
5208  * UMTS:        29.060 v4.0, chapter 7.7.29 PDP Context
5209  * TODO:        unify addr functions
5210  */
5211 static int
5212 decode_gtp_pdp_cntxt(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
5213 {
5214
5215     guint8             ggsn_addr_len, apn_len, trans_id, ea;
5216     guint8             pdp_type_num, pdp_addr_len;
5217     guint16            length;
5218     proto_tree        *ext_tree_pdp;
5219
5220     length = tvb_get_ntohs(tvb, offset + 1);
5221
5222     ext_tree_pdp = proto_tree_add_subtree(tree, tvb, offset, length + 3, ett_gtp_ies[GTP_EXT_PDP_CNTXT], NULL,
5223                     val_to_str_ext_const(GTP_EXT_PDP_CNTXT, &gtp_val_ext, "Unknown message"));
5224
5225     ea = (tvb_get_guint8(tvb, offset + 3) >> 7) & 0x01;
5226
5227     proto_tree_add_item(ext_tree_pdp, hf_gtp_extended_end_user_address, tvb, offset + 3, 1, ENC_NA);
5228     proto_tree_add_item(ext_tree_pdp, hf_gtp_vplmn_address_allowed, tvb, offset + 3, 1, ENC_NA);
5229     proto_tree_add_item(ext_tree_pdp, hf_gtp_activity_status_indicator, tvb, offset + 3, 1, ENC_NA);
5230     proto_tree_add_item(ext_tree_pdp, hf_gtp_reordering_required, tvb, offset + 3, 1, ENC_NA);
5231     proto_tree_add_item(ext_tree_pdp, hf_gtp_nsapi, tvb, offset + 3, 1, ENC_BIG_ENDIAN);
5232     proto_tree_add_item(ext_tree_pdp, hf_gtp_pdp_cntxt_sapi, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
5233
5234     switch (gtp_version) {
5235     case 0:
5236         decode_qos_gprs(tvb, offset + 5, ext_tree_pdp, "QoS subscribed", 0);
5237         decode_qos_gprs(tvb, offset + 8, ext_tree_pdp, "QoS requested", 0);
5238         decode_qos_gprs(tvb, offset + 11, ext_tree_pdp, "QoS negotiated", 0);
5239         offset = offset + 14;
5240         break;
5241     case 1:
5242         offset = offset + 5;
5243         offset = offset + decode_qos_umts(tvb, offset, pinfo, ext_tree_pdp, "QoS subscribed", 1);
5244         offset = offset + decode_qos_umts(tvb, offset, pinfo, ext_tree_pdp, "QoS requested", 1);
5245         offset = offset + decode_qos_umts(tvb, offset, pinfo, ext_tree_pdp, "QoS negotiated", 1);
5246         break;
5247     default:
5248         break;
5249     }
5250
5251     proto_tree_add_item(ext_tree_pdp, hf_gtp_sequence_number_down, tvb, offset, 2, ENC_BIG_ENDIAN);
5252     proto_tree_add_item(ext_tree_pdp, hf_gtp_sequence_number_up, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
5253     proto_tree_add_item(ext_tree_pdp, hf_gtp_send_n_pdu_number, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
5254     proto_tree_add_item(ext_tree_pdp, hf_gtp_receive_n_pdu_number, tvb, offset + 5, 1, ENC_BIG_ENDIAN);
5255
5256     switch (gtp_version) {
5257     case 0:
5258         proto_tree_add_item(ext_tree_pdp, hf_gtp_uplink_flow_label_signalling, tvb, offset + 6, 2, ENC_BIG_ENDIAN);
5259         offset = offset + 8;
5260         break;
5261     case 1:
5262         proto_tree_add_item(ext_tree_pdp, hf_gtp_ulink_teid_cp,   tvb, offset + 6, 4, ENC_BIG_ENDIAN);
5263         proto_tree_add_item(ext_tree_pdp, hf_gtp_ulink_teid_data, tvb, offset + 10, 4, ENC_BIG_ENDIAN);
5264         proto_tree_add_item(ext_tree_pdp, hf_gtp_pdp_context_identifier, tvb, offset + 14, 1, ENC_BIG_ENDIAN);
5265         offset = offset + 15;
5266         break;
5267     default:
5268         break;
5269     }
5270
5271     pdp_type_num = tvb_get_guint8(tvb, offset + 1);
5272     pdp_addr_len = tvb_get_guint8(tvb, offset + 2);
5273
5274     proto_tree_add_item(ext_tree_pdp, hf_gtp_pdp_organization, tvb, offset, 1, ENC_BIG_ENDIAN);
5275     proto_tree_add_item(ext_tree_pdp, hf_gtp_pdp_type, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
5276     proto_tree_add_item(ext_tree_pdp, hf_gtp_pdp_address_length, tvb, offset + 2, 1, ENC_BIG_ENDIAN);
5277
5278     if (pdp_addr_len > 0) {
5279         switch (pdp_type_num) {
5280         case 0x21:
5281             proto_tree_add_item(ext_tree_pdp, hf_gtp_pdp_address_ipv4, tvb, offset + 3, 4, ENC_BIG_ENDIAN);
5282             break;
5283         case 0x57:
5284             proto_tree_add_item(ext_tree_pdp, hf_gtp_pdp_address_ipv6, tvb, offset + 3, 16, ENC_NA);
5285             break;
5286         default:
5287             break;
5288         }
5289     }
5290
5291     offset = offset + 3 + pdp_addr_len;
5292
5293     ggsn_addr_len = tvb_get_guint8(tvb, offset);
5294     proto_tree_add_item(ext_tree_pdp, hf_gtp_ggsn_address_length, tvb, offset, 1, ENC_BIG_ENDIAN);
5295
5296     switch (ggsn_addr_len) {
5297     case 4:
5298         proto_tree_add_item(ext_tree_pdp, hf_gtp_ggsn_address_for_control_plane, tvb, offset + 1, 4, ENC_BIG_ENDIAN);
5299         break;
5300     case 16:
5301         proto_tree_add_item(ext_tree_pdp, hf_gtp_ggsn_address_for_user_traffic, tvb, offset + 1, 16, ENC_BIG_ENDIAN);
5302         break;
5303     default:
5304         break;
5305     }
5306
5307     offset = offset + 1 + ggsn_addr_len;
5308
5309     if (gtp_version == 1) {
5310
5311         ggsn_addr_len = tvb_get_guint8(tvb, offset);
5312         proto_tree_add_item(ext_tree_pdp, hf_gtp_ggsn_2_address_length, tvb, offset, 1, ENC_BIG_ENDIAN);
5313
5314         switch (ggsn_addr_len) {
5315         case 4:
5316             proto_tree_add_item(ext_tree_pdp, hf_gtp_ggsn_2_address_ipv4, tvb, offset + 1, 4, ENC_BIG_ENDIAN);
5317             break;
5318         case 16:
5319             proto_tree_add_item(ext_tree_pdp, hf_gtp_ggsn_2_address_ipv6, tvb, offset + 1, 16, ENC_NA);
5320             break;
5321         default:
5322             break;
5323         }
5324         offset = offset + 1 + ggsn_addr_len;
5325
5326     }
5327
5328     apn_len = tvb_get_guint8(tvb, offset);
5329     proto_tree_add_item(ext_tree_pdp, hf_gtp_apn_length, tvb, offset, 1, ENC_BIG_ENDIAN);
5330     decode_apn(tvb, offset + 1, apn_len, ext_tree_pdp, NULL);
5331
5332     offset = offset + 1 + apn_len;
5333     /*
5334      * The Transaction Identifier is the 4 or 12 bit Transaction Identifier used in the 3GPP TS 24.008 [5] Session Management
5335      * messages which control this PDP Context. If the length of the Transaction Identifier is 4 bit, the second octet shall be
5336      * set to all zeros. The encoding is defined in 3GPP TS 24.007 [3]. The latest Transaction Identifier sent from SGSN to
5337      * MS is stored in the PDP context IE.
5338      * NOTE: Bit 5-8 of the first octet in the encoding defined in 3GPP TS 24.007 [3] is mapped into bit 1-4 of the first
5339      * octet in this field.
5340      */
5341     trans_id = tvb_get_guint8(tvb, offset);
5342     proto_tree_add_uint(ext_tree_pdp, hf_gtp_transaction_identifier, tvb, offset, 2, trans_id);
5343     offset += 2;
5344
5345     if (ea) {
5346         pdp_type_num = tvb_get_guint8(tvb, offset);
5347         pdp_addr_len = tvb_get_guint8(tvb, offset + 1);
5348
5349         proto_tree_add_item(ext_tree_pdp, hf_gtp_pdp_type, tvb, offset, 1, ENC_BIG_ENDIAN);
5350         proto_tree_add_item(ext_tree_pdp, hf_gtp_pdp_address_length, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
5351
5352         if (pdp_addr_len > 0) {
5353             switch (pdp_type_num) {
5354             case 0x21:
5355                 proto_tree_add_item(ext_tree_pdp, hf_gtp_pdp_address_ipv4, tvb, offset + 2, 4, ENC_NA);
5356                 break;
5357             case 0x57:
5358                 proto_tree_add_item(ext_tree_pdp, hf_gtp_pdp_address_ipv6, tvb, offset + 2, 16, ENC_NA);
5359                 break;
5360             default:
5361                 break;
5362             }
5363         }
5364     }
5365
5366     return 3 + length;
5367 }
5368
5369 /* GPRS:        9.60, v7.6.0, chapter 7.9.21
5370  * UMTS:        29.060, v4.0, chapter 7.7.30
5371  */
5372 static int
5373 decode_gtp_apn(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
5374 {
5375
5376     guint16     length;
5377     proto_tree *ext_tree_apn;
5378     proto_item *te;
5379
5380     length = tvb_get_ntohs(tvb, offset + 1);
5381
5382     ext_tree_apn = proto_tree_add_subtree(tree, tvb, offset, length + 3, ett_gtp_ies[GTP_EXT_APN], &te,
5383                                 val_to_str_ext_const(GTP_EXT_APN, &gtp_val_ext, "Unknown field"));
5384
5385     proto_tree_add_item(ext_tree_apn, hf_gtp_apn_length, tvb, offset + 1, 2, ENC_BIG_ENDIAN);
5386     decode_apn(tvb, offset + 3, length, ext_tree_apn, te);
5387
5388     return 3 + length;
5389 }
5390
5391 /* GPRS:        9.60 v7.6.0, chapter 7.9.22
5392  *              4.08 v. 7.1.2, chapter 10.5.6.3 (p.580)
5393  * UMTS:        29.060 v4.0, chapter 7.7.31 Protocol Configuration Options
5394  *              24.008, v4.2, chapter 10.5.6.3
5395  */
5396 int
5397 decode_gtp_proto_conf(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
5398 {
5399
5400     guint16     length;
5401     tvbuff_t   *next_tvb;
5402     proto_tree *ext_tree_proto;
5403
5404     length = tvb_get_ntohs(tvb, offset + 1);
5405
5406     ext_tree_proto = proto_tree_add_subtree(tree, tvb, offset, length + 3,
5407                 ett_gtp_proto, NULL, val_to_str_ext_const(GTP_EXT_PROTO_CONF, &gtp_val_ext, "Unknown message"));
5408
5409     proto_tree_add_uint(ext_tree_proto, hf_gtp_length, tvb, offset + 1, 2, length);
5410
5411     if (length < 1)
5412         return 3;
5413
5414     /* The Protocol Configuration Options contains external network protocol options that may be necessary to transfer
5415      * between the GGSN and the MS. The content and the coding of the Protocol Configuration are defined in octet 3-z of the
5416      * Protocol Configuration Options in3GPP TS 24.008 [5].
5417      */
5418     next_tvb = tvb_new_subset_length(tvb, offset + 3, length);
5419     de_sm_pco(next_tvb, ext_tree_proto, pinfo, 0, length, NULL, 0);
5420
5421     return 3 + length;
5422 }
5423
5424 /* GPRS:        9.60 v7.6.0, chapter 7.9.23
5425  * UMTS:        29.060 v4.0, chapter 7.7.32
5426  */
5427 static int
5428 decode_gtp_gsn_addr(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args)
5429 {
5430
5431     guint8             addr_type, addr_len;
5432     guint16            length;
5433     proto_tree        *ext_tree_gsn_addr;
5434     proto_item        *te;
5435     address           *gsn_address;
5436
5437     length = tvb_get_ntohs(tvb, offset + 1);
5438
5439     ext_tree_gsn_addr = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_gsn_addr, &te, "GSN address : ");
5440     gsn_address = wmem_new0(wmem_packet_scope(), address);
5441     switch (length) {
5442     case 4:
5443         proto_tree_add_item(ext_tree_gsn_addr, hf_gtp_gsn_address_length, tvb, offset + 1, 2, ENC_BIG_ENDIAN);
5444         proto_tree_add_item(ext_tree_gsn_addr, hf_gtp_gsn_ipv4, tvb, offset + 3, 4, ENC_BIG_ENDIAN);
5445         proto_item_append_text(te, "%s", tvb_ip_to_str(tvb, offset + 3));
5446         set_address_tvb(gsn_address, AT_IPv4, 4, tvb, offset + 3);
5447         break;
5448     case 5:
5449         proto_tree_add_item(ext_tree_gsn_addr, hf_gtp_gsn_address_information_element_length, tvb, offset + 1, 2, ENC_BIG_ENDIAN);
5450         addr_type = tvb_get_guint8(tvb, offset + 3) & 0xC0;
5451         proto_tree_add_uint(ext_tree_gsn_addr, hf_gtp_gsn_addr_type, tvb, offset + 3, 1, addr_type);
5452         addr_len = tvb_get_guint8(tvb, offset + 3) & 0x3F;
5453         proto_tree_add_uint(ext_tree_gsn_addr, hf_gtp_gsn_addr_len, tvb, offset + 3, 1, addr_len);
5454         proto_tree_add_item(ext_tree_gsn_addr, hf_gtp_gsn_ipv4, tvb, offset + 4, 4, ENC_BIG_ENDIAN);
5455         proto_item_append_text(te, "%s", tvb_ip_to_str(tvb, offset + 4));
5456         set_address_tvb(gsn_address, AT_IPv6, 16, tvb, offset + 4);
5457         break;
5458     case 16:
5459         proto_tree_add_item(ext_tree_gsn_addr, hf_gtp_gsn_address_length, tvb, offset + 1, 2, ENC_BIG_ENDIAN);
5460         proto_tree_add_item(ext_tree_gsn_addr, hf_gtp_gsn_ipv6, tvb, offset + 3, 16, ENC_NA);
5461         proto_item_append_text(te, "%s", tvb_ip6_to_str(tvb, offset + 3));
5462         set_address_tvb(gsn_address, AT_IPv4, 4, tvb, offset + 3);
5463         break;
5464     case 17:
5465         proto_tree_add_item(ext_tree_gsn_addr, hf_gtp_gsn_address_information_element_length, tvb, offset + 1, 2, ENC_BIG_ENDIAN);
5466         addr_type = tvb_get_guint8(tvb, offset + 3) & 0xC0;
5467         proto_tree_add_uint(ext_tree_gsn_addr, hf_gtp_gsn_addr_type, tvb, offset + 3, 1, addr_type);
5468         addr_len = tvb_get_guint8(tvb, offset + 3) & 0x3F;
5469         proto_tree_add_uint(ext_tree_gsn_addr, hf_gtp_gsn_addr_len, tvb, offset + 3, 1, addr_len);
5470         proto_item_append_text(te, "%s", tvb_ip6_to_str(tvb, offset + 4));
5471         proto_tree_add_item(ext_tree_gsn_addr, hf_gtp_gsn_ipv6, tvb, offset + 4, 16, ENC_NA);
5472         set_address_tvb(gsn_address, AT_IPv6, 16, tvb, offset + 4);
5473         break;
5474     default:
5475         proto_item_append_text(te, "unknown type or wrong length");
5476         break;
5477     }
5478
5479     if (g_gtp_session && gtp_version == 1 && !PINFO_FD_VISITED(pinfo)) {
5480         if (!ip_exists(*gsn_address, args->ip_list)) {
5481             copy_address_wmem(wmem_packet_scope(), &args->last_ip, gsn_address);
5482             wmem_list_prepend(args->ip_list, gsn_address);
5483         }
5484     }
5485     return 3 + length;
5486 }
5487
5488 /* GPRS:        9.60 v7.6.0, chapter 7.9.24
5489  * UMTS:        29.060 v4.0, chapter 7.7.33
5490  */
5491 static int
5492 decode_gtp_msisdn(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
5493 {
5494     guint16     length;
5495     tvbuff_t   *next_tvb;
5496     proto_tree *ext_tree_proto;
5497
5498     length = tvb_get_ntohs(tvb, offset + 1);
5499
5500     ext_tree_proto = proto_tree_add_subtree(tree, tvb, offset, length + 3, ett_gtp_proto, NULL,
5501                             val_to_str_ext_const(GTP_EXT_MSISDN, &gtp_val_ext, "Unknown message"));
5502
5503     proto_tree_add_uint(ext_tree_proto, hf_gtp_length, tvb, offset + 1, 2, length);
5504
5505     length = tvb_get_ntohs(tvb, offset + 1);
5506
5507     if (length < 1)
5508         return 3;
5509
5510     next_tvb = tvb_new_subset_length(tvb, offset+3, length);
5511     dissect_gsm_map_msisdn(next_tvb, pinfo, ext_tree_proto);
5512
5513     return 3 + length;
5514 }
5515
5516 /* GPRS:        not present
5517  * UMTS:        29.060 v4.0, chapter 7.7.34
5518  *              24.008 v4.2, chapter 10.5.6.5
5519  */
5520 static int
5521 decode_gtp_qos_umts(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
5522 {
5523
5524     return decode_qos_umts(tvb, offset, pinfo, tree, "Quality of Service", 2);
5525 }
5526
5527 /* GPRS:        not present
5528  * UMTS:        29.060 v4.0, chapter 7.7.35
5529  */
5530 static int
5531 decode_gtp_auth_qui(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
5532 {
5533
5534     proto_tree *ext_tree;
5535     guint16     length;
5536     guint8      xres_len, auth_len;
5537
5538
5539     length = tvb_get_ntohs(tvb, offset + 1);
5540
5541     ext_tree = proto_tree_add_subtree(tree, tvb, offset, length + 1, ett_gtp_quint, NULL, "Quintuplet");
5542     offset++;
5543
5544     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
5545     offset = offset + 2;
5546
5547     proto_tree_add_item(ext_tree, hf_gtp_rand, tvb, offset, 16, ENC_NA);
5548     offset = offset + 16;
5549     xres_len = tvb_get_guint8(tvb, offset);
5550     proto_tree_add_item(ext_tree, hf_gtp_xres_length, tvb, offset, 1, ENC_BIG_ENDIAN);
5551     offset++;
5552     proto_tree_add_item(ext_tree, hf_gtp_xres, tvb, offset, xres_len, ENC_NA);
5553     offset = offset + xres_len;
5554     proto_tree_add_item(ext_tree, hf_gtp_quintuplet_ciphering_key, tvb, offset, 16, ENC_NA);
5555     offset = offset + 16;
5556     proto_tree_add_item(ext_tree, hf_gtp_quintuplet_integrity_key, tvb, offset, 16, ENC_NA);
5557     offset = offset + 16;
5558     auth_len = tvb_get_guint8(tvb, offset);
5559     proto_tree_add_item(ext_tree, hf_gtp_authentication_length, tvb, offset, 1, ENC_BIG_ENDIAN);
5560     offset++;
5561     proto_tree_add_item(ext_tree, hf_gtp_auth, tvb, offset, auth_len, ENC_NA);
5562
5563     return (3 + length);
5564
5565 }
5566
5567 /* GPRS:        not present
5568  * UMTS:        29.060 v4.0, chapter 7.7.36
5569  *              24.008 v4.2, chapter 10.5.6.12
5570  */
5571 static int
5572 decode_gtp_tft(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
5573 {
5574     proto_tree     *ext_tree_tft;
5575     guint          length;
5576
5577     length = tvb_get_ntohs(tvb, offset + 1);
5578
5579     ext_tree_tft = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_tft, NULL, "Traffic flow template");
5580     proto_tree_add_item(ext_tree_tft, hf_gtp_tft_length, tvb, offset + 1, 2, ENC_BIG_ENDIAN);
5581
5582     /* The detailed coding of Traffic Flow Template
5583     * Description is specified in 3GPP TS 24.008 [5] ,
5584     * clause 10.5.6.12, beginning with octet 3..
5585     * Use the decoding in packet-gsm_a_gm.c
5586     */
5587     de_sm_tflow_temp(tvb, ext_tree_tft, pinfo, offset + 3, length, NULL, 0);
5588
5589     return 3 + length;
5590 }
5591
5592 /* GPRS:        not present
5593  * UMTS:        3GPP TS 29.060 version 10.4.0 Release 10, chapter 7.7.37
5594  * Type = 138 (Decimal)
5595  *              25.413(RANAP) TargetID
5596  * There are several CRs to to this IE make sure to check with a recent spec if dissection is questioned.
5597  */
5598 static int
5599 decode_gtp_target_id(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
5600 {
5601
5602     guint16         length;
5603     proto_tree      *ext_tree;
5604
5605
5606     length = tvb_get_ntohs(tvb, offset + 1);
5607
5608     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_TARGET_ID], NULL, "Target Identification");
5609     offset = offset + 1;
5610     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
5611     offset = offset + 2;
5612     if (length == 0){
5613         return 3 + length;
5614     }
5615
5616     /* Quote from specification:
5617      * The Target Identification information element contains the identification of a target RNC. Octets 4-n shall contain a
5618      * non-transparent copy of the corresponding IEs (see subclause 7.7.2) and be encoded as specified in Figure 51 below.
5619      * The "Target RNC-ID" part of the "Target ID" parameter is specified in 3GPP TS 25.413 [7].
5620      * NOTE 1: The ASN.1 parameter "Target ID" is forwarded non-transparently in order to maintain backward compatibility.
5621      * NOTE 2: The preamble of the "Target RNC-ID" (numerical value of e.g. 0x20) however shall not be included in
5622      *         octets 4-n. Also the optional "iE-Extensions" parameter shall not be included into the GTP IE.
5623      */
5624     /* Octet 4-6 MCC + MNC */
5625     if (length == 9) {
5626         /* Patch for systems still not following NOTE 2 */
5627         proto_tree_add_expert_format(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, 1, "Not Compliant with 3GPP TS 29.060 7.7.37: The preamble of the \"Target RNC-ID\" (numerical value of e.g. 0x20) however shall not be included in octets 4-n.");
5628         offset+=1;
5629         dissect_e212_mcc_mnc(tvb, pinfo, ext_tree, offset, E212_NONE, FALSE);
5630     } else {
5631         /* Following Standards */
5632         dissect_e212_mcc_mnc(tvb, pinfo, ext_tree, offset, E212_NONE, TRUE);
5633     }
5634     offset+=3;
5635
5636     /* Octet 7-8 LAC */
5637     proto_tree_add_item(ext_tree, hf_gtp_lac, tvb, offset, 2, ENC_BIG_ENDIAN);
5638     offset+=2;
5639     /* Octet 9 RAC */
5640     proto_tree_add_item(ext_tree, hf_gtp_rai_rac, tvb, offset, 1, ENC_BIG_ENDIAN);
5641     offset++;
5642     /* Octet 10-11 RNC-ID*/
5643     proto_tree_add_item(ext_tree, hf_gtp_target_rnc_id, tvb, offset, 2, ENC_BIG_ENDIAN);
5644     offset+=2;
5645     /* If the optional Extended RNC-ID is not included, then the length variable 'n' = 8 and the overall length of the IE is 11
5646      * octets. Otherwise, 'n' = 10 and the overall length of the IE is 13 octets
5647      */
5648     if(length == 10){
5649         proto_tree_add_item(ext_tree, hf_gtp_target_ext_rnc_id, tvb, offset, 2, ENC_BIG_ENDIAN);
5650     }
5651
5652     return 3 + length;
5653 }
5654
5655
5656 /* GPRS:        not present
5657  * UMTS:        29.060 v4.0, chapter 7.7.38
5658  */
5659 static int
5660 decode_gtp_utran_cont(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
5661 {
5662
5663     guint16     length;
5664     proto_tree *ext_tree;
5665     tvbuff_t   *new_tvb;
5666     proto_tree *sub_tree;
5667
5668     length = tvb_get_ntohs(tvb, offset + 1);
5669
5670     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_UTRAN_CONT], NULL, "UTRAN transparent Container");
5671
5672     offset = offset + 1;
5673     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
5674     offset = offset + 2;
5675     proto_tree_add_item(ext_tree, hf_gtp_utran_field, tvb, offset, length, ENC_NA);
5676
5677     switch (pinfo->link_dir) {
5678     case P2P_DIR_UL:
5679         sub_tree = proto_tree_add_subtree(ext_tree, tvb, offset, length, ett_gtp_utran_cont, NULL, "Source RNC to Target RNC Transparent Container");
5680         new_tvb = tvb_new_subset_remaining(tvb, offset);
5681         dissect_ranap_SourceRNC_ToTargetRNC_TransparentContainer_PDU(new_tvb, pinfo, sub_tree, NULL);
5682         break;
5683     case P2P_DIR_DL:
5684         sub_tree = proto_tree_add_subtree(ext_tree, tvb, offset, length, ett_gtp_utran_cont, NULL, "Target RNC to Source RNC Transparent Container");
5685         new_tvb = tvb_new_subset_remaining(tvb, offset);
5686         dissect_ranap_TargetRNC_ToSourceRNC_TransparentContainer_PDU(new_tvb, pinfo, sub_tree, NULL);
5687         break;
5688     default:
5689         break;
5690     }
5691
5692     return 3 + length;
5693
5694 }
5695
5696
5697 /* GPRS:        not present
5698  * UMTS:        29.060 v4.0, chapter 7.7.39
5699  */
5700 static int
5701 decode_gtp_rab_setup(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
5702 {
5703
5704     guint32            teid;
5705     guint16            length;
5706     proto_tree        *ext_tree_rab_setup;
5707
5708     length = tvb_get_ntohs(tvb, offset + 1);
5709
5710     ext_tree_rab_setup = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_rab_setup, NULL, "Radio Access Bearer Setup Information");
5711
5712     proto_tree_add_item(ext_tree_rab_setup, hf_gtp_rab_setup_length, tvb, offset + 1, 2, ENC_BIG_ENDIAN);
5713     proto_tree_add_item(ext_tree_rab_setup, hf_gtp_nsapi, tvb, offset + 3, 1, ENC_BIG_ENDIAN);
5714
5715     if (length > 1) {
5716
5717         teid = tvb_get_ntohl(tvb, offset + 4);
5718
5719         proto_tree_add_uint(ext_tree_rab_setup, hf_gtp_teid_data, tvb, offset + 4, 4, teid);
5720
5721         switch (length) {
5722         case 9:
5723             proto_tree_add_item(ext_tree_rab_setup, hf_gtp_rnc_ipv4, tvb, offset + 8, 4, ENC_BIG_ENDIAN);
5724             break;
5725         case 21:
5726             proto_tree_add_item(ext_tree_rab_setup, hf_gtp_rnc_ipv6, tvb, offset + 8, 16, ENC_NA);
5727             break;
5728         default:
5729             break;
5730         }
5731     }
5732
5733     return 3 + length;
5734 }
5735
5736
5737 /* GPRS:        not present
5738  * UMTS:        29.060 v4.0, chapter 7.7.40
5739  */
5740 static int
5741 decode_gtp_hdr_list(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
5742 {
5743
5744     int         i;
5745     guint8      length, hdr;
5746     proto_tree *ext_tree_hdr_list;
5747
5748     length = tvb_get_guint8(tvb, offset + 1);
5749
5750     ext_tree_hdr_list = proto_tree_add_subtree(tree, tvb, offset, 2 + length, ett_gtp_hdr_list, NULL,
5751                             val_to_str_ext_const(GTP_EXT_HDR_LIST, &gtp_val_ext, "Unknown"));
5752
5753     proto_tree_add_item(ext_tree_hdr_list, hf_gtp_num_ext_hdr_types, tvb, offset + 1, 1, ENC_NA);
5754
5755     for (i = 0; i < length; i++) {
5756         hdr = tvb_get_guint8(tvb, offset + 2 + i);
5757
5758         proto_tree_add_uint_format(ext_tree_hdr_list, hf_gtp_ext_hdr_type, tvb, offset + 2 + i, 1, hdr, "No. %u --> Extension Header Type value : %s (0x%02x)", i + 1,
5759                             val_to_str_const(hdr, next_extension_header_fieldvals, "Unknown Extension Header Type"), hdr);
5760     }
5761
5762     return 2 + length;
5763 }
5764
5765 /* GPRS:        not present
5766  * UMTS:        29.060 v4.0, chapter 7.7.41
5767  * TODO:        find TriggerID description
5768  */
5769 static int
5770 decode_gtp_trigger_id(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
5771 {
5772     guint16 length;
5773     proto_item* ti;
5774
5775     length = tvb_get_ntohs(tvb, offset + 1);
5776
5777     ti = proto_tree_add_uint_format(tree, hf_gtp_ext_length, tvb, offset, 2, length, "%s length : %u",
5778                                   val_to_str_ext_const(GTP_EXT_TRIGGER_ID, &gtp_val_ext, "Unknown"), length);
5779     proto_item_set_len(ti, 3 + length);
5780
5781     return 3 + length;
5782
5783 }
5784
5785 /* GPRS:        not present
5786  * UMTS:        29.060 v4.0, chapter 7.7.42
5787  * TODO:        find OMC-ID description
5788  */
5789 static int
5790 decode_gtp_omc_id(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
5791 {
5792     guint16 length;
5793     proto_item* ti;
5794
5795     length = tvb_get_ntohs(tvb, offset + 1);
5796
5797     ti = proto_tree_add_uint_format(tree, hf_gtp_ext_length, tvb, offset, 2, length, "%s length : %u",
5798                                   val_to_str_ext_const(GTP_EXT_OMC_ID, &gtp_val_ext, "Unknown"), length);
5799     proto_item_set_len(ti, 3 + length);
5800
5801     return 3 + length;
5802
5803 }
5804
5805 /* GPRS:        9.60 v7.6.0, chapter 7.9.25
5806  * UMTS:        29.060 v6.11.0, chapter 7.7.44 Charging Gateway Address
5807  */
5808 static int
5809 decode_gtp_chrg_addr(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
5810 {
5811
5812     guint16            length;
5813     proto_tree        *ext_tree_chrg_addr;
5814     proto_item        *te;
5815
5816     length = tvb_get_ntohs(tvb, offset + 1);
5817
5818     ext_tree_chrg_addr = proto_tree_add_subtree_format(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_CHRG_ADDR], &te,
5819                                     "%s : ", val_to_str_ext_const(GTP_EXT_CHRG_ADDR, &gtp_val_ext, "Unknown"));
5820
5821     proto_tree_add_uint_format(ext_tree_chrg_addr, hf_gtp_ext_length, tvb, offset + 1, 2, length,
5822                                     "%s length : %u", val_to_str_ext_const(GTP_EXT_CHRG_ADDR, &gtp_val_ext, "Unknown"), length);
5823
5824     switch (length) {
5825     case 4:
5826         proto_tree_add_item(ext_tree_chrg_addr, hf_gtp_chrg_ipv4, tvb, offset + 3, 4, ENC_BIG_ENDIAN);
5827         proto_item_append_text(te, "%s", tvb_ip_to_str(tvb, offset + 3));
5828         break;
5829     case 16:
5830         proto_tree_add_item(ext_tree_chrg_addr, hf_gtp_chrg_ipv6, tvb, offset + 3, 16, ENC_NA);
5831         proto_item_append_text(te, "%s", tvb_ip6_to_str(tvb, offset + 3));
5832         break;
5833     default:
5834         proto_item_append_text(te, "unknown type or wrong length");
5835         break;
5836     }
5837
5838     return 3 + length;
5839 }
5840
5841 /* GPRS:        ?
5842  * UMTS:        29.060 V9.4.0, chapter 7.7.43 RAN Transparent Container
5843  * The information in the value part of the RAN Transparent Container IE contains all information elements (starting with
5844  * and including the BSSGP "PDU Type") in either of the RAN INFORMATION, RAN INFORMATION REQUEST,
5845  * RAN INFORMATION ACK or RAN INFORMATION ERROR messages respectively as specified in 3GPP TS 48.018
5846  */
5847 static int
5848 decode_gtp_ran_tr_cont(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
5849 {
5850
5851     guint16     length;
5852     proto_tree *ext_tree;
5853     tvbuff_t   *next_tvb;
5854
5855     length = tvb_get_ntohs(tvb, offset + 1);
5856     ext_tree = proto_tree_add_subtree_format(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_RAN_TR_CONT], NULL,
5857                         "%s : ", val_to_str_ext_const(GTP_EXT_RAN_TR_CONT, &gtp_val_ext, "Unknown"));
5858
5859     offset++;
5860     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
5861     offset = offset + 2;
5862
5863     next_tvb = tvb_new_subset_length(tvb, offset, length);
5864     if (bssgp_handle) {
5865 #if 0
5866         col_set_fence(pinfo->cinfo, COL_INFO);
5867 #endif
5868         call_dissector(bssgp_handle, next_tvb, pinfo, ext_tree);
5869     }
5870
5871     return 3 + length;
5872
5873 }
5874
5875 /* GPRS:        ?
5876  * UMTS:        29.060 v6.11.0, chapter 7.7.45 PDP Context Prioritization
5877  */
5878 static int
5879 decode_gtp_pdp_cont_prio(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
5880 {
5881
5882     guint16     length;
5883     proto_tree *ext_tree;
5884
5885     length = tvb_get_ntohs(tvb, offset + 1);
5886     ext_tree = proto_tree_add_subtree_format(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_PDP_CONT_PRIO], NULL,
5887                         "%s : ", val_to_str_ext_const(GTP_EXT_PDP_CONT_PRIO, &gtp_val_ext, "Unknown"));
5888
5889     if (length == 0) {
5890         return 3;
5891     }
5892
5893     offset++;
5894     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
5895     offset = offset + 2;
5896     /* TODO add decoding of data */
5897     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
5898
5899     return 3 + length;
5900
5901 }
5902
5903 /* GPRS:        ?
5904  * UMTS:        29.060 v6.11.0, chapter 7.7.45A Additional RAB Setup Information
5905  */
5906 static int
5907 decode_gtp_add_rab_setup_inf(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
5908 {
5909
5910     guint16     length;
5911     proto_tree *ext_tree;
5912
5913     length = tvb_get_ntohs(tvb, offset + 1);
5914     ext_tree = proto_tree_add_subtree_format(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_ADD_RAB_SETUP_INF], NULL,
5915                     "%s : ", val_to_str_ext_const(GTP_EXT_ADD_RAB_SETUP_INF, &gtp_val_ext, "Unknown"));
5916
5917     offset++;
5918     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
5919     offset = offset + 2;
5920     /* TODO add decoding of data */
5921     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
5922
5923     return 3 + length;
5924
5925 }
5926
5927
5928  /* GPRS:       ?
5929   * UMTS:       29.060 v6.11.0, chapter 7.7.47 SGSN Number
5930   */
5931 static int
5932 decode_gtp_ssgn_no(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
5933 {
5934
5935     guint16     length;
5936     proto_tree *ext_tree;
5937
5938     length = tvb_get_ntohs(tvb, offset + 1);
5939     ext_tree = proto_tree_add_subtree_format(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_SSGN_NO], NULL,
5940                     "%s : ", val_to_str_ext_const(GTP_EXT_SSGN_NO, &gtp_val_ext, "Unknown"));
5941
5942     offset++;
5943     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
5944     offset = offset + 2;
5945     /* TODO add decoding of data */
5946     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
5947
5948     return 3 + length;
5949
5950 }
5951
5952 /* GPRS:        ?
5953  * UMTS:        3GPP TS 29.060 version 7.8.0 Release 7, chapter 7.7.48 Common Flags
5954  */
5955 static int
5956 decode_gtp_common_flgs(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
5957 {
5958
5959     guint16     length;
5960     proto_tree *ext_tree;
5961
5962     length = tvb_get_ntohs(tvb, offset + 1);
5963     ext_tree = proto_tree_add_subtree_format(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_COMMON_FLGS], NULL,
5964                 "%s : ", val_to_str_ext_const(GTP_EXT_COMMON_FLGS, &gtp_val_ext, "Unknown"));
5965
5966     offset++;
5967     proto_tree_add_item(ext_tree, hf_gtp_ext_length,                   tvb, offset, 2, ENC_BIG_ENDIAN);
5968     offset = offset + 2;
5969     /* Dual Address Bearer Flag */
5970     proto_tree_add_item(ext_tree, hf_gtp_cmn_flg_dual_addr_bearer_flg, tvb, offset, 1, ENC_BIG_ENDIAN);
5971     /* Upgrade QoS Supported */
5972     proto_tree_add_item(ext_tree, hf_gtp_cmn_flg_upgrd_qos_sup,        tvb, offset, 1, ENC_BIG_ENDIAN);
5973     /* NRSN bit field */
5974     proto_tree_add_item(ext_tree, hf_gtp_cmn_flg_nrsn,                 tvb, offset, 1, ENC_BIG_ENDIAN);
5975     /* No QoS negotiation */
5976     proto_tree_add_item(ext_tree, hf_gtp_cmn_flg_no_qos_neg,           tvb, offset, 1, ENC_BIG_ENDIAN);
5977     /* MBMS Counting Information bi */
5978     proto_tree_add_item(ext_tree, hf_gtp_cmn_flg_mbs_cnt_inf,          tvb, offset, 1, ENC_BIG_ENDIAN);
5979     /* RAN Procedures Ready */
5980     proto_tree_add_item(ext_tree, hf_gtp_cmn_flg_mbs_ran_pcd_rdy,      tvb, offset, 1, ENC_BIG_ENDIAN);
5981     /* MBMS Service Type */
5982     proto_tree_add_item(ext_tree, hf_gtp_cmn_flg_mbs_srv_type,         tvb, offset, 1, ENC_BIG_ENDIAN);
5983     /* Prohibit Payload Compression */
5984     proto_tree_add_item(ext_tree, hf_gtp_cmn_flg_ppc,                  tvb, offset, 1, ENC_BIG_ENDIAN);
5985
5986     return 3 + length;
5987
5988 }
5989
5990 /* GPRS:        ?
5991  * UMTS:        29.060 v6.11.0, chapter 7.7.49
5992  */
5993 static int
5994 decode_gtp_apn_res(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
5995 {
5996
5997     guint16     length;
5998     proto_tree *ext_tree_apn_res;
5999
6000     length = tvb_get_ntohs(tvb, offset + 1);
6001     ext_tree_apn_res = proto_tree_add_subtree_format(tree, tvb, offset, 3 + length,  ett_gtp_ies[GTP_EXT_APN_RES], NULL,
6002                 "%s : ", val_to_str_ext_const(GTP_EXT_APN_RES, &gtp_val_ext, "Unknown"));
6003
6004     offset++;
6005     proto_tree_add_item(ext_tree_apn_res, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6006     offset = offset + 2;
6007
6008     /* Restriction Type value */
6009     if (length != 1) {
6010         proto_tree_add_expert_format(tree, pinfo, &ei_gtp_ext_length_mal, tvb, 0, length, "Wrong length indicated. Expected 1, got %u", length);
6011         return 3 + length;
6012     }
6013
6014     proto_tree_add_item(ext_tree_apn_res, hf_gtp_ext_apn_res, tvb, offset, length, ENC_BIG_ENDIAN);
6015     return 3 + length;
6016 }
6017
6018 /* GPRS:        ?
6019  * UMTS:        29.060 v6.11.0, chapter 7.7.50 RAT Type
6020  * RAT Type
6021  * Type = 151 (Decimal)
6022  */
6023
6024 static int
6025 decode_gtp_rat_type(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
6026 {
6027
6028     guint16     length;
6029     proto_tree *ext_tree_rat_type;
6030     proto_item *te;
6031
6032     length = tvb_get_ntohs(tvb, offset + 1);
6033     ext_tree_rat_type = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_RAT_TYPE], &te,
6034                         val_to_str_ext_const(GTP_EXT_RAT_TYPE, &gtp_val_ext, "Unknown"));
6035
6036     offset++;
6037     proto_tree_add_item(ext_tree_rat_type, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6038     offset = offset + 2;
6039
6040     /* RAT Type value */
6041     if (length != 1) {
6042         proto_tree_add_expert_format(tree, pinfo, &ei_gtp_ext_length_mal, tvb, 0, length, "Wrong length indicated. Expected 1, got %u", length);
6043         return 3 + length;
6044     }
6045
6046    proto_tree_add_item(ext_tree_rat_type, hf_gtp_ext_rat_type, tvb, offset, length, ENC_BIG_ENDIAN);
6047    proto_item_append_text(te, ": %s", val_to_str_const(tvb_get_guint8(tvb,offset), gtp_ext_rat_type_vals, "Unknown"));
6048
6049    return 3 + length;
6050 }
6051
6052 /* GPRS:        ?
6053  * UMTS:        29.060 v6.11.0, chapter 7.7.51
6054  * User Location Information
6055  * Type = 152 (Decimal)
6056  */
6057
6058 static const
6059 gchar *dissect_radius_user_loc(proto_tree * tree, tvbuff_t * tvb, packet_info* pinfo)
6060 {
6061
6062     int     offset = 0;
6063     guint8  geo_loc_type;
6064     guint16 length = tvb_reported_length(tvb);
6065     proto_item* ti;
6066
6067     /* Geographic Location Type */
6068     geo_loc_type = tvb_get_guint8(tvb, offset);
6069     ti = proto_tree_add_uint(tree, hf_gtp_uli_geo_loc_type, tvb, offset, 1, geo_loc_type);
6070     offset++;
6071
6072     switch(geo_loc_type) {
6073         case 0:
6074             /* Geographic Location field included and it holds the Cell Global
6075              * Identification (CGI) of where the user currently is registered.
6076              * CGI is defined in sub-clause 4.3.1 of 3GPP TS 23.003 [2].
6077              */
6078             dissect_e212_mcc_mnc(tvb, pinfo, tree, offset, E212_CGI, TRUE);
6079             offset+=3;
6080             proto_tree_add_item(tree, hf_gtp_lac, tvb, offset, 2, ENC_BIG_ENDIAN);
6081             offset+=2;
6082             proto_tree_add_item(tree, hf_gtp_cgi_ci, tvb, offset, 2, ENC_BIG_ENDIAN);
6083             break;
6084         case 1:
6085             /* Geographic Location field included and it holds the Service
6086              * Area Identity (SAI) of where the user currently is registered.
6087              * SAI is defined in sub-clause 9.2.3.9 of 3GPP TS 25.413 [7].
6088              */
6089             dissect_e212_mcc_mnc(tvb, pinfo, tree, offset, E212_SAI, TRUE);
6090             offset+=3;
6091             proto_tree_add_item(tree, hf_gtp_lac, tvb, offset, 2, ENC_BIG_ENDIAN);
6092             offset+=2;
6093             proto_tree_add_item(tree, hf_gtp_sai_sac, tvb, offset, 2, ENC_BIG_ENDIAN);
6094             break;
6095         case 2:
6096             /* Geographic Location field included and it holds the Routing
6097              * Area Identification (RAI) of where the user currently is
6098              * registered. RAI is defined in sub-clause 4.2 of 3GPP TS 23.003
6099              * [2].
6100              */
6101             dissect_e212_mcc_mnc(tvb, pinfo, tree, offset, E212_RAI, TRUE);
6102             offset+=3;
6103             proto_tree_add_item(tree, hf_gtp_lac, tvb, offset, 2, ENC_BIG_ENDIAN);
6104             offset+=2;
6105             proto_tree_add_item(tree, hf_gtp_rai_rac, tvb, offset, 2, ENC_BIG_ENDIAN);
6106             break;
6107         case 128:
6108             /* Geographic Location field included and it holds the Tracking
6109              * Area Identity (TAI) of where the user currently is registered.
6110              * TAI is defined in sub-clause 8.21.4 of 3GPP TS 29.274.
6111              */
6112             dissect_e212_mcc_mnc(tvb, pinfo, tree, offset, E212_TAI, TRUE);
6113             offset+=3;
6114             proto_tree_add_item(tree, hf_gtp_tac, tvb, offset, 2, ENC_BIG_ENDIAN);
6115             break;
6116         case 129:
6117             /* Geographic Location field included and it holds the E-UTRAN Cell
6118              * Global Identifier (ECGI) of where the user currently is registered.
6119              * ECGI is defined in sub-clause 8.21.5 of 3GPP TS 29.274.
6120              */
6121             dissect_e212_mcc_mnc(tvb, pinfo, tree, offset, E212_ECGI, TRUE);
6122             offset+=3;
6123             proto_tree_add_item(tree, hf_gtp_eci, tvb, offset, 4, ENC_BIG_ENDIAN);
6124             break;
6125         case 130:
6126             /* Geographic Location field included and it holds the Tracking
6127              * Area Identity (TAI) and E-UTRAN CellGlobal Identifier (ECGI)
6128              * of where the user currently is registered.
6129              * TAI is defined in sub-clause 8.21.4 of 3GPP TS 29.274.
6130              * ECGI is defined in sub-clause 8.21.5 of 3GPP TS 29.274.
6131              */
6132             dissect_e212_mcc_mnc(tvb, pinfo, tree, offset, E212_TAI, TRUE);
6133             offset+=3;
6134             proto_tree_add_item(tree, hf_gtp_tac, tvb, offset, 2, ENC_BIG_ENDIAN);
6135             offset += 2;
6136             dissect_e212_mcc_mnc(tvb, pinfo, tree, offset, E212_ECGI, TRUE);
6137             offset+=3;
6138             proto_tree_add_item(tree, hf_gtp_eci, tvb, offset, 4, ENC_BIG_ENDIAN);
6139             break;
6140         default:
6141             expert_add_info(pinfo, ti, &ei_gtp_ext_geo_loc_type);
6142             break;
6143     }
6144
6145     return tvb_bytes_to_str(wmem_packet_scope(), tvb, 0, length);
6146 }
6147
6148 /*
6149  * 7.7.51 User Location Information
6150  */
6151
6152 void
6153 dissect_gtp_uli(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
6154 {
6155     guint8      geo_loc_type;
6156     proto_item* ti;
6157
6158     /* Geographic Location Type */
6159     geo_loc_type = tvb_get_guint8(tvb, offset);
6160     ti = proto_tree_add_uint(tree, hf_gtp_uli_geo_loc_type, tvb, offset, 1, geo_loc_type);
6161
6162     offset++;
6163
6164     switch(geo_loc_type) {
6165         case 0:
6166             /* Geographic Location field included and it holds the Cell Global
6167              * Identification (CGI) of where the user currently is registered.
6168              * CGI is defined in sub-clause 4.3.1 of 3GPP TS 23.003 [2].
6169              */
6170             dissect_e212_mcc_mnc(tvb, pinfo, tree, offset, E212_CGI, TRUE);
6171             offset+=3;
6172             proto_tree_add_item(tree, hf_gtp_lac, tvb, offset, 2, ENC_BIG_ENDIAN);
6173             offset+=2;
6174             proto_tree_add_item(tree, hf_gtp_cgi_ci, tvb, offset, 2, ENC_BIG_ENDIAN);
6175             break;
6176         case 1:
6177             /* Geographic Location field included and it holds the Service
6178              * Area Identity (SAI) of where the user currently is registered.
6179              * SAI is defined in sub-clause 9.2.3.9 of 3GPP TS 25.413 [7].
6180              */
6181             dissect_e212_mcc_mnc(tvb, pinfo, tree, offset, E212_SAI, TRUE);
6182             offset+=3;
6183             proto_tree_add_item(tree, hf_gtp_lac, tvb, offset, 2, ENC_BIG_ENDIAN);
6184             offset+=2;
6185             proto_tree_add_item(tree, hf_gtp_sai_sac, tvb, offset, 2, ENC_BIG_ENDIAN);
6186             break;
6187         case 2:
6188             /* Geographic Location field included and it holds the Routing
6189              * Area Identification (RAI) of where the user currently is
6190              * registered. RAI is defined in sub-clause 4.2 of 3GPP TS 23.003
6191              * [2].
6192              */
6193             dissect_e212_mcc_mnc(tvb, pinfo, tree, offset, E212_RAI, TRUE);
6194             offset+=3;
6195             proto_tree_add_item(tree, hf_gtp_lac, tvb, offset, 2, ENC_BIG_ENDIAN);
6196             offset+=2;
6197             proto_tree_add_item(tree, hf_gtp_rai_rac, tvb, offset, 2, ENC_BIG_ENDIAN);
6198             break;
6199         default:
6200             expert_add_info(pinfo, ti, &ei_gtp_ext_geo_loc_type);
6201             break;
6202     }
6203 }
6204
6205 static int
6206 decode_gtp_usr_loc_inf(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
6207 {
6208
6209     guint16     length;
6210     proto_tree *ext_tree;
6211
6212     length = tvb_get_ntohs(tvb, offset + 1);
6213     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_USR_LOC_INF], NULL,
6214                 val_to_str_ext_const(GTP_EXT_USR_LOC_INF, &gtp_val_ext, "Unknown"));
6215
6216     offset++;
6217     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6218     offset = offset + 2;
6219
6220     dissect_gtp_uli(tvb, offset, pinfo, ext_tree, args);
6221
6222     return 3 + length;
6223 }
6224
6225 static const value_string daylight_saving_time_vals[] = {
6226     {0, "No adjustment"},
6227     {1, "+1 hour adjustment for Daylight Saving Time"},
6228     {2, "+2 hours adjustment for Daylight Saving Time"},
6229     {3, "Reserved"},
6230     {0, NULL}
6231 };
6232
6233 /* GPRS:        ?
6234  * UMTS:        29.060 v6.11.0, chapter 7.7.52
6235  * MS Time Zone
6236  * Type = 153 (Decimal)
6237  * The ' MS Time Zone' IE is used to indicate the offset between universal time and local time
6238  * in steps of 15 minutes of where the MS currently resides. The 'Time Zone' field uses the same
6239  * format as the 'Time Zone' IE in 3GPP TS 24.008 (10.5.3.8)
6240  * its value shall be set as defined in 3GPP TS 22.042
6241  */
6242 static int
6243 decode_gtp_ms_time_zone(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6244 {
6245
6246     guint16     length;
6247     proto_tree *ext_tree;
6248     proto_item *te;
6249     guint8      data;
6250     char        sign;
6251
6252     length = tvb_get_ntohs(tvb, offset + 1);
6253     ext_tree = proto_tree_add_subtree_format(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_MS_TIME_ZONE], &te,
6254                     "%s: ", val_to_str_ext_const(GTP_EXT_MS_TIME_ZONE, &gtp_val_ext, "Unknown"));
6255
6256     offset++;
6257     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6258     offset = offset + 2;
6259
6260     /* 3GPP TS 23.040 version 6.6.0 Release 6
6261      * 9.2.3.11 TP-Service-Centre-Time-Stamp (TP-SCTS)
6262      * :
6263      * The Time Zone indicates the difference, expressed in quarters of an hour,
6264      * between the local time and GMT. In the first of the two semi-octets,
6265      * the first bit (bit 3 of the seventh octet of the TP-Service-Centre-Time-Stamp field)
6266      * represents the algebraic sign of this difference (0: positive, 1: negative).
6267      */
6268
6269     data = tvb_get_guint8(tvb, offset);
6270     sign = (data & 0x08) ? '-' : '+';
6271     data = (data >> 4) + (data & 0x07) * 10;
6272
6273     proto_tree_add_uint_format_value(ext_tree, hf_gtp_timezone, tvb, offset, 1, data, "GMT %c %d hours %d minutes", sign, data / 4, data % 4 * 15);
6274     proto_item_append_text(te, "GMT %c %d hours %d minutes", sign, data / 4, data % 4 * 15);
6275     offset++;
6276
6277     proto_tree_add_item(ext_tree, hf_gtp_timezone_dst, tvb, offset, 1, ENC_NA);
6278
6279     return 3 + length;
6280
6281 }
6282
6283 /* GPRS:        ?
6284  * UMTS:        29.060 v6.11.0, chapter 7.7.53
6285  * International Mobile Equipment Identity (and Software Version) (IMEI(SV))
6286  * Type = 154 (Decimal)
6287  */
6288 static int
6289 decode_gtp_imeisv(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6290 {
6291
6292     guint16     length;
6293     proto_tree *ext_imeisv;
6294     proto_item *te;
6295     tvbuff_t   *next_tvb;
6296     const char *digit_str;
6297
6298     length = tvb_get_ntohs(tvb, offset + 1);
6299     ext_imeisv = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_IMEISV], &te,
6300                         val_to_str_ext_const(GTP_EXT_IMEISV, &gtp_val_ext, "Unknown"));
6301
6302     offset++;
6303     proto_tree_add_item(ext_imeisv, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6304     offset = offset + 2;
6305
6306     /* IMEI(SV)
6307      * The structure of the IMEI and IMEISV are defined in sub-clause 6.2 of 3GPP TS 23.003 [2].
6308      * The 'IMEI(SV)' field shall contain the IMEISV if it is available. If only the IMEI is available,
6309      * then the IMEI shall be placed in the IMEI(SV) field and the last semi-octet of octet 11 shall be
6310      * set to '1111'. Both IMEI and IMEISV are BCD encoded.
6311      */
6312     next_tvb = tvb_new_subset_length(tvb, offset, length);
6313     digit_str = tvb_bcd_dig_to_wmem_packet_str(next_tvb, 0, -1, NULL, FALSE);
6314     proto_tree_add_string(ext_imeisv, hf_gtp_ext_imeisv, next_tvb, 0, -1, digit_str);
6315     proto_item_append_text(te, ": %s", digit_str);
6316
6317     return 3 + length;
6318 }
6319
6320 /* GPRS:        ?
6321  * UMTS:        29.060 v6.11.0, chapter 7.7.54
6322  * CAMEL Charging Information Container
6323  * Type = 155 (Decimal)
6324  */
6325 static int
6326 decode_gtp_camel_chg_inf_con(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6327 {
6328
6329     guint16     length;
6330     proto_tree *ext_tree;
6331
6332     length = tvb_get_ntohs(tvb, offset + 1);
6333     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_CAMEL_CHG_INF_CON], NULL,
6334                     val_to_str_ext_const(GTP_EXT_CAMEL_CHG_INF_CON, &gtp_val_ext, "Unknown"));
6335
6336     offset++;
6337     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6338     offset = offset + 2;
6339     /* TODO add decoding of data */
6340     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
6341
6342     return 3 + length;
6343
6344 }
6345
6346 /* GPRS:        ?
6347  * UMTS:        29.060 v6.11.0, chapter 7.7.55
6348  * MBMS UE Context
6349  */
6350 static int
6351 decode_gtp_mbms_ue_ctx(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6352 {
6353
6354     guint16     length;
6355     proto_tree *ext_tree;
6356
6357     length = tvb_get_ntohs(tvb, offset + 1);
6358     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_MBMS_UE_CTX], NULL,
6359                 val_to_str_ext_const(GTP_EXT_MBMS_UE_CTX, &gtp_val_ext, "Unknown"));
6360
6361     offset++;
6362     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6363     offset = offset + 2;
6364     /* TODO add decoding of data */
6365     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
6366
6367     return 3 + length;
6368
6369 }
6370
6371 /* GPRS:        ?
6372  * UMTS:        3GPP TS 29.060 version 7.8.0 Release 7, chapter 7.7.56
6373  * Temporary Mobile Group Identity (TMGI)
6374  * The Temporary Mobile Group Identity (TMGI) information element contains
6375  * a TMGI allocated by the BM-SC. It is coded as in the value part defined
6376  * in 3GPP T S 24.008 [5] (i.e. the IEI and octet length indicator are not included).
6377  */
6378
6379 static int
6380 decode_gtp_tmgi(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
6381 {
6382
6383     guint16     length;
6384     proto_tree *ext_tree, *tmgi_tree;
6385     proto_item *ti;
6386     tvbuff_t   *next_tvb;
6387
6388     length = tvb_get_ntohs(tvb, offset + 1);
6389     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_TMGI], NULL,
6390                 val_to_str_ext_const(GTP_EXT_TMGI, &gtp_val_ext, "Unknown"));
6391
6392     offset++;
6393     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6394     offset = offset + 2;
6395
6396     ti = proto_tree_add_item(ext_tree, hf_gtp_tmgi, tvb, offset, length, ENC_NA);
6397
6398     tmgi_tree = proto_item_add_subtree(ti, ett_gtp_tmgi);
6399     next_tvb = tvb_new_subset_length(tvb, offset, length);
6400     de_mid(next_tvb, tmgi_tree, pinfo, 0, length, NULL, 0);
6401     return 3 + length;
6402
6403 }
6404
6405 /* GPRS:        ?
6406  * UMTS:        29.060 v6.11.0, chapter 7.7.57
6407  * RIM Routing Address
6408  */
6409 static int
6410 decode_gtp_rim_ra(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6411 {
6412
6413     guint16     length;
6414     proto_tree *ext_tree;
6415
6416     length = tvb_get_ntohs(tvb, offset + 1);
6417     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_RIM_RA], NULL,
6418                             val_to_str_ext_const(GTP_EXT_RIM_RA, &gtp_val_ext, "Unknown"));
6419
6420     offset++;
6421     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6422     offset = offset + 2;
6423     /* To dissect the Address the Routing Address discriminator must be known */
6424     /*
6425      * Octets 4-n are coded according to 3GPP TS 48.018 [20] 11.3.77 RIM Routing Information IE octets 4-n.
6426      */
6427     proto_tree_add_item(ext_tree, hf_gtp_rim_routing_addr, tvb, offset, length, ENC_NA);
6428
6429     return 3 + length;
6430
6431 }
6432
6433 /* GPRS:        ?
6434  * UMTS:        29.060 v6.11.0, chapter 7.7.58
6435  * MBMS Protocol Configuration Options
6436  */
6437 static int
6438 decode_gtp_mbms_prot_conf_opt(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6439 {
6440
6441     guint16     length;
6442     proto_tree *ext_tree;
6443
6444     length = tvb_get_ntohs(tvb, offset + 1);
6445     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_MBMS_PROT_CONF_OPT], NULL,
6446                     val_to_str_ext_const(GTP_EXT_MBMS_PROT_CONF_OPT, &gtp_val_ext, "Unknown"));
6447
6448     offset++;
6449     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6450     offset = offset + 2;
6451     /* TODO add decoding of data */
6452     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
6453
6454     return 3 + length;
6455
6456 }
6457
6458 /* GPRS:        ?
6459  * UMTS:        3GPP TS 29.060 version 7.8.0 Release 7, chapter 7.7.59
6460  * MBMS Session Duration
6461  */
6462 /* Used for Diameter */
6463 static int
6464 dissect_gtp_mbms_ses_dur(tvbuff_t * tvb, packet_info * pinfo _U_, proto_tree * tree, void *data _U_)
6465 {
6466
6467     int offset = 0;
6468
6469     proto_tree_add_item(tree, hf_gtp_mbms_ses_dur_days, tvb, offset, 3, ENC_BIG_ENDIAN);
6470     proto_tree_add_item(tree, hf_gtp_mbms_ses_dur_s,    tvb, offset, 3, ENC_BIG_ENDIAN);
6471
6472     return 3;
6473
6474 }
6475
6476 static int
6477 decode_gtp_mbms_ses_dur(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6478 {
6479
6480     guint16     length;
6481     proto_tree *ext_tree;
6482
6483     length = tvb_get_ntohs(tvb, offset + 1);
6484     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_MBMS_SES_DUR], NULL,
6485                 val_to_str_ext_const(GTP_EXT_MBMS_SES_DUR, &gtp_val_ext, "Unknown"));
6486
6487     offset++;
6488     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6489     offset = offset + 2;
6490     /* The MBMS Session Duration is defined in 3GPP TS 23.246 [26].
6491      * The MBMS Session Duration information element indicates the estimated
6492      * session duration of the MBMS service data transmission if available.
6493      * The payload shall be encoded as per the MBMS-Session-Duration AVP defined
6494      * in 3GPP TS 29.061 [27], excluding the AVP Header fields
6495      * (as defined in IETF RFC 3588 [36], section 4.1).
6496      */
6497     /* The MBMS-Session-Duration AVP (AVP code 904) is of type OctetString
6498      * with a length of three octets and indicates the estimated session duration
6499      * (MBMS Service data transmission). Bits 0 to 16 (17 bits) express seconds, for which the
6500      * maximum allowed value is 86400 seconds. Bits 17 to 23 (7 bits) express days,
6501      * for which the maximum allowed value is 18 days. For the whole session duration the seconds
6502      * and days are added together and the maximum session duration is 19 days.
6503      */
6504     proto_tree_add_item(ext_tree, hf_gtp_mbms_ses_dur_days, tvb, offset, 3, ENC_BIG_ENDIAN);
6505     proto_tree_add_item(ext_tree, hf_gtp_mbms_ses_dur_s, tvb, offset, 3, ENC_BIG_ENDIAN);
6506
6507     return 3 + length;
6508
6509 }
6510
6511 /* GPRS:        ?
6512  * UMTS:        3GPP TS 29.060 version 7.8.0 Release 7, chapter 7.7.60
6513  * MBMS Service Area
6514  */
6515 static int
6516 dissect_gtp_3gpp_mbms_service_area(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_) {
6517
6518     int    offset = 0;
6519     guint8 no_of_mbms_sa_codes;
6520     int    i;
6521
6522     /* The MBMS Service Area is defined in 3GPP TS 23.246 [26].
6523      * The MBMS Service Area information element indicates the area over
6524      * which the Multimedia Broadcast/Multicast Service is to be distributed.
6525      * The payload shall be encoded as per the MBMS-Service-Area AVP defined
6526      * in 3GPP TS 29.061 [27], excluding the AVP Header fields (as defined in
6527      * IETF RFC 3588 [36], section 4.1).
6528      */
6529     /* Number N of MBMS service area codes coded as:
6530      * 1 binary value is '00000000'
6531      * ... ...
6532      * 256 binary value is '11111111'
6533      */
6534     no_of_mbms_sa_codes = tvb_get_guint8(tvb, offset) + 1;
6535     proto_tree_add_uint(tree, hf_gtp_no_of_mbms_sa_codes, tvb, offset, 1, no_of_mbms_sa_codes);
6536     offset++;
6537     /* A consecutive list of N MBMS service area codes
6538      * The MBMS Service Area Identity and its semantics are defined in 3GPP TS 23.003
6539      * The length of an MBMS service area code is 2 octets.
6540      */
6541     for (i = 0; i < no_of_mbms_sa_codes; i++) {
6542         proto_tree_add_item(tree, hf_gtp_mbms_sa_code, tvb, offset, 2, ENC_BIG_ENDIAN);
6543         offset = offset + 2;
6544     }
6545
6546     return offset;
6547 }
6548
6549 static int
6550 decode_gtp_mbms_sa(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
6551 {
6552
6553     tvbuff_t   *next_tvb;
6554     guint16     length;
6555     proto_tree *ext_tree;
6556
6557     length = tvb_get_ntohs(tvb, offset + 1);
6558     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_MBMS_SA], NULL,
6559                 val_to_str_ext_const(GTP_EXT_MBMS_SA, &gtp_val_ext, "Unknown"));
6560
6561     offset++;
6562     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6563     offset = offset + 2;
6564     next_tvb = tvb_new_subset_length(tvb, offset, length-3);
6565     dissect_gtp_3gpp_mbms_service_area(next_tvb, pinfo, ext_tree, NULL);
6566
6567     return 3 + length;
6568
6569 }
6570
6571 /* GPRS:        ?
6572  * UMTS:        29.060 v6.11.0, chapter 7.7.61
6573  * Source RNC PDCP context info
6574  */
6575 static int
6576 decode_gtp_src_rnc_pdp_ctx_inf(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6577 {
6578
6579     guint16     length;
6580     proto_tree *ext_tree;
6581
6582     length = tvb_get_ntohs(tvb, offset + 1);
6583     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_SRC_RNC_PDP_CTX_INF], NULL,
6584                     val_to_str_ext_const(GTP_EXT_SRC_RNC_PDP_CTX_INF, &gtp_val_ext, "Unknown"));
6585
6586     offset++;
6587     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6588     offset = offset + 2;
6589     /* TODO add decoding of data */
6590     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
6591
6592     return 3 + length;
6593
6594 }
6595
6596 /* GPRS:        ?
6597  * UMTS:        29.060 v6.11.0, chapter 7.7.62
6598  * Additional Trace Info
6599  */
6600 static int
6601 decode_gtp_add_trs_inf(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6602 {
6603
6604     guint16     length;
6605     proto_tree *ext_tree;
6606
6607     length = tvb_get_ntohs(tvb, offset + 1);
6608     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_ADD_TRS_INF], NULL,
6609                     val_to_str_ext_const(GTP_EXT_ADD_TRS_INF, &gtp_val_ext, "Unknown"));
6610
6611     offset++;
6612     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6613     offset = offset + 2;
6614     /* TODO add decoding of data */
6615     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
6616
6617     return 3 + length;
6618
6619 }
6620
6621 /* GPRS:        ?
6622  * UMTS:        29.060 v6.11.0, chapter 7.7.63
6623  * Hop Counter
6624  */
6625 static int
6626 decode_gtp_hop_count(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6627 {
6628
6629     guint16     length;
6630     proto_tree *ext_tree;
6631
6632     length = tvb_get_ntohs(tvb, offset + 1);
6633     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_HOP_COUNT], NULL,
6634                 val_to_str_ext_const(GTP_EXT_HOP_COUNT, &gtp_val_ext, "Unknown"));
6635
6636     offset++;
6637     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6638     offset = offset + 2;
6639     /* TODO add decoding of data */
6640     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
6641
6642     return 3 + length;
6643
6644 }
6645
6646 /* GPRS:        ?
6647  * UMTS:        29.060 v6.11.0, chapter 7.7.64
6648  * Selected PLMN ID
6649  */
6650 static int
6651 decode_gtp_sel_plmn_id(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
6652 {
6653
6654     guint16     length;
6655     proto_tree *ext_tree;
6656
6657     length = tvb_get_ntohs(tvb, offset + 1);
6658     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_MBMS_SES_ID], NULL,
6659                                 val_to_str_ext_const(GTP_EXT_SEL_PLMN_ID, &gtp_val_ext, "Unknown"));
6660
6661     offset++;
6662     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6663     offset = offset + 2;
6664
6665     dissect_e212_mcc_mnc(tvb, pinfo, ext_tree, offset, E212_NONE, FALSE);
6666     return 3 + length;
6667
6668 }
6669
6670 /* GPRS:        ?
6671  * UMTS:        29.060 v6.11.0, chapter 7.7.65
6672  * MBMS Session Identifier
6673  */
6674 static int
6675 decode_gtp_mbms_ses_id(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6676 {
6677
6678     guint16     length;
6679     proto_tree *ext_tree;
6680
6681     length = tvb_get_ntohs(tvb, offset + 1);
6682     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_MBMS_SES_ID], NULL, val_to_str_ext_const(GTP_EXT_MBMS_SES_ID, &gtp_val_ext, "Unknown"));
6683
6684     offset++;
6685     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6686     offset = offset + 2;
6687     /* TODO add decoding of data */
6688     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
6689
6690     return 3 + length;
6691
6692 }
6693
6694 /* GPRS:        ?
6695  * UMTS:        29.060 v6.11.0, chapter 7.7.66
6696  * MBMS 2G/3G Indicator
6697  */
6698 static const value_string gtp_mbs_2g_3g_ind_vals[] = {
6699     {0, "2G only"},
6700     {1, "3G only"},
6701     {2, "Both 2G and 3G"},
6702     {0, NULL}
6703 };
6704
6705 static int
6706 decode_gtp_mbms_2g_3g_ind(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6707 {
6708
6709     guint16     length;
6710     proto_tree *ext_tree;
6711
6712     length = tvb_get_ntohs(tvb, offset + 1);
6713     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_MBMS_2G_3G_IND], NULL,
6714                 val_to_str_ext_const(GTP_EXT_MBMS_2G_3G_IND, &gtp_val_ext, "Unknown"));
6715
6716     offset++;
6717     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6718     offset = offset + 2;
6719     /* MBMS 2G/3G Indicator */
6720     proto_tree_add_item(ext_tree, hf_gtp_mbs_2g_3g_ind, tvb, offset, 1, ENC_BIG_ENDIAN);
6721
6722     return 3 + length;
6723
6724 }
6725
6726 /* GPRS:        ?
6727  * UMTS:        29.060 v6.11.0, chapter 7.7.67
6728  * Enhanced NSAPI
6729  */
6730 static int
6731 decode_gtp_enh_nsapi(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6732 {
6733
6734     guint16     length;
6735     proto_tree *ext_tree;
6736
6737     length = tvb_get_ntohs(tvb, offset + 1);
6738     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_ENH_NSAPI], NULL, val_to_str_ext_const(GTP_EXT_ENH_NSAPI, &gtpv1_val_ext, "Unknown"));
6739
6740     offset++;
6741     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6742     offset = offset + 2;
6743     /* TODO add decoding of data */
6744     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
6745
6746     return 3 + length;
6747
6748 }
6749
6750 /* GPRS:        ?
6751  * UMTS:        29.060 v6.11.0, chapter 7.7.68
6752  * Additional MBMS Trace Info
6753  */
6754 static int
6755 decode_gtp_add_mbms_trs_inf(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6756 {
6757
6758     guint16     length;
6759     proto_tree *ext_tree;
6760
6761     length = tvb_get_ntohs(tvb, offset + 1);
6762     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_ADD_MBMS_TRS_INF], NULL,
6763                             val_to_str_ext_const(GTP_EXT_ADD_MBMS_TRS_INF, &gtpv1_val_ext, "Unknown"));
6764
6765     offset++;
6766     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6767     offset = offset + 2;
6768     /* TODO add decoding of data */
6769     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
6770
6771     return 3 + length;
6772
6773 }
6774
6775 /* GPRS:        ?
6776  * UMTS:        29.060 v6.11.0, chapter 7.7.69
6777  * MBMS Session Identity Repetition Number
6778  */
6779 static int
6780 decode_gtp_mbms_ses_id_rep_no(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6781 {
6782
6783     guint16     length;
6784     proto_tree *ext_tree;
6785
6786     length = tvb_get_ntohs(tvb, offset + 1);
6787     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_MBMS_SES_ID_REP_NO], NULL,
6788                                         val_to_str_ext_const(GTP_EXT_MBMS_SES_ID_REP_NO, &gtpv1_val_ext, "Unknown"));
6789
6790     offset++;
6791     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6792     offset = offset + 2;
6793     /* TODO add decoding of data */
6794     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
6795
6796     return 3 + length;
6797
6798 }
6799
6800 /* GPRS:        ?
6801  * UMTS:        3GPP TS 29.060 version 7.8.0 Release 7
6802  * MBMS Time To Data Transfer
6803  */
6804 /* Used for Diameter */
6805 static int
6806 dissect_gtp_mbms_time_to_data_tr(tvbuff_t * tvb, packet_info * pinfo _U_, proto_tree * tree, void *data _U_)
6807 {
6808
6809     int    offset = 0;
6810     guint8 time_2_dta_tr;
6811
6812     time_2_dta_tr = tvb_get_guint8(tvb, offset) + 1;
6813     proto_tree_add_uint(tree, hf_gtp_time_2_dta_tr, tvb, offset, 1, time_2_dta_tr);
6814
6815     return 3;
6816
6817 }
6818
6819 static int
6820 decode_gtp_mbms_time_to_data_tr(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6821 {
6822
6823     guint16     length;
6824     proto_tree *ext_tree;
6825     guint8      time_2_dta_tr;
6826
6827     length = tvb_get_ntohs(tvb, offset + 1);
6828     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_MBMS_TIME_TO_DATA_TR], NULL,
6829                         val_to_str_ext_const(GTP_EXT_MBMS_TIME_TO_DATA_TR, &gtpv1_val_ext, "Unknown"));
6830
6831     offset++;
6832     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6833     offset = offset + 2;
6834     /* TODO add decoding of data
6835      * The MBMS Time To Data Transfer is defined in 3GPP TS 23.246 [26].
6836      * The MBMS Time To Data Transfer information element contains a
6837      * MBMS Time To Data Transfer allocated by the BM-SC.
6838      * The payload shall be encoded as per the MBMS-Time-To-Data-Transfer AVP
6839      * defined in 3GPP TS 29.061 [27], excluding the AVP Header fields
6840      * (as defined in IETF RFC 3588 [36], section 4.1).
6841      */
6842     /* The coding is specified as per the Time to MBMS Data Transfer Value Part Coding
6843      * of the Time to MBMS Data Transfer IE in 3GPP TS 48.018
6844      * Bits
6845      * 8 7 6 5 4 3 2 1
6846      * 0 0 0 0 0 0 0 0 1s
6847      * 0 0 0 0 0 0 0 1 2s
6848      * 0 0 0 0 0 0 1 0 3s
6849      * :
6850      * 1 1 1 1 1 1 1 1 256s
6851      */
6852     time_2_dta_tr = tvb_get_guint8(tvb, offset) + 1;
6853     proto_tree_add_uint(ext_tree, hf_gtp_time_2_dta_tr, tvb, offset, 1, time_2_dta_tr);
6854
6855     return 3 + length;
6856
6857 }
6858
6859 /* GPRS:        ?
6860  * UMTS:        29.060 v6.11.0, chapter 7.7.71
6861  * PS Handover Request Context
6862  */
6863 static int
6864 decode_gtp_ps_ho_req_ctx(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6865 {
6866
6867     guint16     length;
6868     proto_tree *ext_tree;
6869
6870     length = tvb_get_ntohs(tvb, offset + 1);
6871     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_PS_HO_REQ_CTX], NULL,
6872                 val_to_str_ext_const(GTP_EXT_PS_HO_REQ_CTX, &gtpv1_val_ext, "Unknown"));
6873
6874     offset++;
6875     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6876     offset = offset + 2;
6877     /* TODO add decoding of data */
6878     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
6879
6880     return 3 + length;
6881
6882 }
6883
6884 /* GPRS:        ?
6885  * UMTS:        29.060 v6.11.0, chapter 7.7.72
6886  * BSS Container
6887  */
6888 static int
6889 decode_gtp_bss_cont(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6890 {
6891
6892     guint16     length;
6893     proto_tree *ext_tree;
6894
6895     length = tvb_get_ntohs(tvb, offset + 1);
6896     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_BSS_CONT], NULL,
6897                     val_to_str_ext_const(GTP_EXT_BSS_CONT, &gtpv1_val_ext, "Unknown"));
6898
6899     offset++;
6900     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6901     offset = offset + 2;
6902     /* TODO add decoding of data */
6903     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
6904     /*
6905      * The content of this container is defined in 3GPP TS 48.018
6906      */
6907
6908     return 3 + length;
6909
6910 }
6911
6912 /* GPRS:        ?
6913  * UMTS:        29.060 v6.11.0, chapter 7.7.73
6914  * Cell Identification
6915  */
6916 static int
6917 decode_gtp_cell_id(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6918 {
6919
6920     guint16     length;
6921     proto_tree *ext_tree;
6922
6923     length = tvb_get_ntohs(tvb, offset + 1);
6924     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_CELL_ID], NULL,
6925                                 val_to_str_ext_const(GTP_EXT_CELL_ID, &gtpv1_val_ext, "Unknown"));
6926
6927     offset++;
6928     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6929     offset = offset + 2;
6930     /* TODO add decoding of data */
6931     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
6932     /*
6933      * for PS handover from A/Gb mode, the identification of a target cell (Cell ID 1) and the identification of the
6934      * source cell (Cell ID 2) as defined in 3GPP TS 48.018 [20].
6935      *
6936      * for PS handover from Iu mode, the identification of a target cell (Cell ID 1)) and the identification of the
6937      * source RNC (RNC-ID) as defined in 3GPP TS 48.018
6938      */
6939
6940     return 3 + length;
6941
6942 }
6943
6944 /* GPRS:        ?
6945  * UMTS:        29.060 v6.11.0, chapter 7.7.74
6946  * PDU Numbers
6947  */
6948 static int
6949 decode_gtp_pdu_no(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6950 {
6951
6952     guint16     length;
6953     proto_tree *ext_tree;
6954
6955     length = tvb_get_ntohs(tvb, offset + 1);
6956     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_PDU_NO], NULL,
6957                                             val_to_str_ext_const(GTP_EXT_PDU_NO, &gtpv1_val_ext, "Unknown"));
6958
6959     offset++;
6960     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6961     offset = offset + 2;
6962     /* TODO add decoding of data */
6963     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
6964
6965     return 3 + length;
6966
6967 }
6968
6969 /* GPRS:        ?
6970  * UMTS:        29.060 v6.11.0, chapter 7.7.75
6971  * BSSGP Cause
6972  */
6973 static int
6974 decode_gtp_bssgp_cause(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6975 {
6976
6977     guint16     length;
6978     proto_tree *ext_tree;
6979
6980     length = tvb_get_ntohs(tvb, offset + 1);
6981     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_BSSGP_CAUSE], NULL,
6982                                         val_to_str_ext_const(GTP_EXT_BSSGP_CAUSE, &gtpv1_val_ext, "Unknown"));
6983
6984     offset++;
6985     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6986     offset = offset + 2;
6987
6988     /*
6989      * The BSSGP Cause information element contains the cause as defined in 3GPP TS 48.018
6990      */
6991     proto_tree_add_item(ext_tree, hf_gtp_bssgp_cause, tvb, offset, 2, ENC_BIG_ENDIAN);
6992
6993     return 3 + length;
6994
6995 }
6996
6997 /*
6998  * Required MBMS bearer capabilities    7.7.76
6999  */
7000 static int
7001 decode_gtp_mbms_bearer_cap(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7002 {
7003     guint16     length;
7004     proto_tree *ext_tree;
7005
7006     length = tvb_get_ntohs(tvb, offset + 1);
7007     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_REQ_MBMS_BEARER_CAP], NULL,
7008                                     val_to_str_ext_const(GTP_EXT_REQ_MBMS_BEARER_CAP, &gtpv1_val_ext, "Unknown"));
7009
7010     offset++;
7011     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7012 #if 0 /* Fix Dead Store Warning */
7013     offset = offset + 2;
7014 #endif
7015     /* The payload shall be encoded as per the
7016      * Required-MBMS-Bearer-Capabilities AVP defined in 3GPP TS 29.061 [27],
7017      * excluding the AVP Header fields (as defined in IETF RFC 3588 [36], section 4.1).
7018      */
7019     /* TODO Add decoding (call Diameter dissector???) */
7020         return 3 + length;
7021 }
7022
7023 /*
7024  * RIM Routing Address Discriminator    7.7.77
7025  */
7026
7027 static const value_string gtp_bssgp_ra_discriminator_vals[] = {
7028     { 0, "A Cell Identifier is used to identify a GERAN cell" },
7029     { 1, "A Global RNC-ID is used to identify a UTRAN RNC" },
7030     { 2, "An eNB identifier is used to identify an E-UTRAN eNodeB or HeNB" },
7031     { 0, NULL }
7032 };
7033
7034 static int
7035 decode_gtp_rim_ra_disc(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7036 {
7037
7038     guint16     length;
7039     proto_tree *ext_tree;
7040
7041     length = tvb_get_ntohs(tvb, offset + 1);
7042     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_RIM_ROUTING_ADDR_DISC], NULL,
7043                                 val_to_str_ext_const(GTP_EXT_RIM_ROUTING_ADDR_DISC, &gtpv1_val_ext, "Unknown"));
7044
7045     offset++;
7046     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7047     offset = offset + 2;
7048     /* Octet 4 bits 4 - 1 is coded according to 3GPP TS 48.018 [20]
7049      * RIM Routing Information IE octet 3 bits 4 - 1.
7050      * Bits 8 - 5 are coded "0000".
7051      */
7052     proto_tree_add_item(ext_tree, hf_gtp_bssgp_ra_discriminator, tvb, offset, 1, ENC_BIG_ENDIAN);
7053
7054     return 3 + length;
7055
7056 }
7057 /*
7058  * List of set-up PFCs  7.7.78
7059  */
7060 static int
7061 decode_gtp_lst_set_up_pfc(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7062 {
7063
7064     guint16     length;
7065     proto_tree *ext_tree;
7066
7067     length = tvb_get_ntohs(tvb, offset + 1);
7068     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_LIST_OF_SETUP_PFCS], NULL,
7069                                         val_to_str_ext_const(GTP_EXT_LIST_OF_SETUP_PFCS, &gtpv1_val_ext, "Unknown"));
7070
7071     offset++;
7072     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7073     offset = offset + 2;
7074     /* TODO add decoding of data */
7075     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
7076
7077     return 3 + length;
7078
7079 }
7080 /*
7081  * PS Handover XID Parameters   7.7.79
7082  */
7083 static int
7084 decode_gtp_ps_handover_xid(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
7085 {
7086
7087     guint16     length;
7088     proto_tree *ext_tree;
7089     tvbuff_t   *next_tvb;
7090     guint8      sapi;
7091     guint8      xid_par_len;
7092
7093     length = tvb_get_ntohs(tvb, offset + 1);
7094     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_PS_HANDOVER_XIP_PAR], NULL,
7095                                         val_to_str_ext_const(GTP_EXT_PS_HANDOVER_XIP_PAR, &gtpv1_val_ext, "Unknown"));
7096
7097     offset++;
7098     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7099     offset = offset + 2;
7100
7101     sapi = tvb_get_guint8(tvb, offset) & 0x0F;
7102     proto_tree_add_uint(ext_tree, hf_gtp_sapi, tvb, offset, 1, sapi);
7103     offset++;
7104
7105     xid_par_len = tvb_get_guint8(tvb, offset);
7106     proto_tree_add_uint(ext_tree, hf_gtp_xid_par_len, tvb, offset, 1, xid_par_len);
7107     offset++;
7108
7109     next_tvb = tvb_new_subset_remaining(tvb, offset);
7110     if (sndcpxid_handle)
7111         call_dissector(sndcpxid_handle, next_tvb, pinfo, tree);
7112     else
7113         call_data_dissector(next_tvb, pinfo, tree);
7114
7115     return 4 + length;
7116
7117 }
7118
7119 /*
7120  * MS Info Change Reporting Action      7.7.80
7121  */
7122 static int
7123 decode_gtp_ms_inf_chg_rep_act(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7124 {
7125
7126     guint16     length;
7127     proto_tree *ext_tree;
7128
7129     length = tvb_get_ntohs(tvb, offset + 1);
7130     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_MS_INF_CHG_REP_ACT], NULL,
7131                                         val_to_str_ext_const(GTP_EXT_MS_INF_CHG_REP_ACT, &gtpv1_val_ext, "Unknown"));
7132
7133     offset++;
7134     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7135     offset = offset + 2;
7136
7137     proto_tree_add_item(ext_tree, hf_gtp_rep_act_type, tvb, offset, 1, ENC_BIG_ENDIAN);
7138
7139     return 3 + length;
7140
7141 }
7142 /*
7143  * Direct Tunnel Flags  7.7.81
7144  */
7145 static int
7146 decode_gtp_direct_tnl_flg(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7147 {
7148
7149     guint16     length;
7150     proto_tree *ext_tree;
7151
7152     length = tvb_get_ntohs(tvb, offset + 1);
7153     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_DIRECT_TUNNEL_FLGS], NULL,
7154                                         val_to_str_ext_const(GTP_EXT_DIRECT_TUNNEL_FLGS, &gtpv1_val_ext, "Unknown"));
7155
7156     offset++;
7157     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7158     offset += 2;
7159
7160     proto_tree_add_item(ext_tree, hf_gtp_ext_ei,   tvb, offset, 1, ENC_BIG_ENDIAN);
7161     proto_tree_add_item(ext_tree, hf_gtp_ext_gcsi, tvb, offset, 1, ENC_BIG_ENDIAN);
7162     proto_tree_add_item(ext_tree, hf_gtp_ext_dti,  tvb, offset, 1, ENC_BIG_ENDIAN);
7163     offset++;
7164
7165     if (length == 1) {
7166         return 3 + length;
7167     }
7168     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
7169
7170     return 3 + length;
7171
7172 }
7173 /*
7174  * Correlation-ID       7.7.82
7175  */
7176 static int
7177 decode_gtp_corrl_id(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7178 {
7179
7180     guint16     length;
7181     proto_tree *ext_tree;
7182
7183     length = tvb_get_ntohs(tvb, offset + 1);
7184     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_CORRELATION_ID], NULL,
7185                     val_to_str_ext_const(GTP_EXT_CORRELATION_ID, &gtpv1_val_ext, "Unknown"));
7186
7187     offset++;
7188     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7189     offset = offset + 2;
7190
7191     proto_tree_add_item(ext_tree, hf_gtp_correlation_id,  tvb, offset, 1, ENC_BIG_ENDIAN);
7192
7193     return 3 + length;
7194
7195 }
7196 /*
7197  * Bearer Control Mode  7.7.83
7198  * version 10.0.0
7199  */
7200 static const value_string gtp_pdp_bcm_type_vals[] = {
7201     {0, "MS_only"},
7202     {1, "MS/NW"},
7203     {0, NULL}
7204 };
7205
7206 static int
7207 decode_gtp_bearer_cntrl_mod(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7208 {
7209
7210     guint16     length;
7211     proto_tree *ext_tree;
7212
7213     length = tvb_get_ntohs(tvb, offset + 1);
7214     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length,  ett_gtp_ies[GTP_EXT_BEARER_CONTROL_MODE], NULL,
7215                                         val_to_str_ext_const(GTP_EXT_BEARER_CONTROL_MODE, &gtpv1_val_ext, "Unknown"));
7216
7217     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7218
7219     offset++;
7220     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7221     offset = offset + 2;
7222
7223     proto_tree_add_item(ext_tree, hf_gtp_bcm, tvb, offset, 1, ENC_BIG_ENDIAN);
7224
7225     return 3 + length;
7226
7227 }
7228
7229 /*
7230  * 7.7.84 MBMS Flow Identifier
7231  */
7232 static int
7233 decode_gtp_mbms_flow_id(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7234 {
7235     guint16     length;
7236     proto_tree *ext_tree;
7237
7238     length = tvb_get_ntohs(tvb, offset + 1);
7239     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_MBMS_FLOW_ID], NULL,
7240                                         val_to_str_ext_const(GTP_EXT_MBMS_FLOW_ID, &gtpv1_val_ext, "Unknown"));
7241     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7242
7243     offset++;
7244     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7245     offset = offset + 2;
7246
7247     /* 4-n MBMS Flow Identifier */
7248     proto_tree_add_item(ext_tree, hf_gtp_mbms_flow_id, tvb, offset, length, ENC_NA);
7249
7250
7251     return 3 + length;
7252 }
7253
7254 /*
7255  * 7.7.85 MBMS IP Multicast Distribution
7256  */
7257
7258 static int
7259 decode_gtp_mbms_ip_mcast_dist(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7260 {
7261     guint16     length;
7262     proto_tree *ext_tree;
7263
7264     length = tvb_get_ntohs(tvb, offset + 1);
7265     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_MBMS_IP_MCAST_DIST], NULL,
7266                                     val_to_str_ext_const(GTP_EXT_MBMS_IP_MCAST_DIST, &gtpv1_val_ext, "Unknown"));
7267     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7268
7269     offset++;
7270     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7271     offset = offset + 2;
7272
7273     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
7274
7275     return 3 + length;
7276 }
7277
7278 /*
7279  * 7.7.86 MBMS Distribution Acknowledgement
7280  */
7281 /* Table 7.7.86.1: Distribution Indication values */
7282 static const value_string gtp_mbms_dist_indic_vals[] = {
7283     {0, "No RNCs have accepted IP multicast distribution"},
7284     {1, "All RNCs have accepted IP multicast distribution"},
7285     {2, "Some RNCs have accepted IP multicast distribution"},
7286     {3, "Spare. For future use."},
7287     {0, NULL}
7288 };
7289 static int
7290 decode_gtp_mbms_dist_ack(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7291 {
7292     guint16     length;
7293     proto_tree *ext_tree;
7294
7295     length = tvb_get_ntohs(tvb, offset + 1);
7296     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_MBMS_DIST_ACK], NULL,
7297                                     val_to_str_ext_const(GTP_EXT_MBMS_DIST_ACK, &gtpv1_val_ext, "Unknown"));
7298     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7299
7300     offset++;
7301     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7302     offset = offset + 2;
7303
7304     /* Distribution Indication values */
7305     proto_tree_add_item(ext_tree, hf_gtp_mbms_dist_indic, tvb, offset, 1, ENC_BIG_ENDIAN);
7306
7307     return 3 + length;
7308 }
7309
7310 /*
7311  * 7.7.87 Reliable INTER RAT HANDOVER INFO
7312  */
7313 static int
7314 decode_gtp_reliable_irat_ho_inf(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7315 {
7316     guint16     length;
7317     proto_tree *ext_tree;
7318
7319     length = tvb_get_ntohs(tvb, offset + 1);
7320     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_RELIABLE_IRAT_HO_INF], NULL,
7321                                         val_to_str_ext_const(GTP_EXT_RELIABLE_IRAT_HO_INF, &gtpv1_val_ext, "Unknown"));
7322     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7323
7324     offset++;
7325     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7326     offset = offset + 2;
7327
7328     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
7329
7330     return 3 + length;
7331 }
7332
7333 /*
7334  * 7.7.88 RFSP Index
7335  */
7336 static int
7337 decode_gtp_rfsp_index(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7338 {
7339     guint16     length, rfsp;
7340     proto_tree *ext_tree;
7341
7342     length = tvb_get_ntohs(tvb, offset + 1);
7343     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_RFSP_INDEX], NULL,
7344                                         val_to_str_ext_const(GTP_EXT_RFSP_INDEX, &gtpv1_val_ext, "Unknown"));
7345     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7346
7347     offset++;
7348     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7349     offset = offset + 2;
7350
7351     rfsp = tvb_get_ntohs(tvb, offset);
7352     proto_tree_add_uint(ext_tree, hf_gtp_rfsp_index, tvb, offset, length, rfsp+1);
7353
7354     return 3 + length;
7355 }
7356 /*
7357  * 7.7.89 PDP Type
7358  */
7359 /*
7360  * 7.7.90 Fully Qualified Domain Name (FQDN)
7361  */
7362 static int
7363 decode_gtp_fqdn(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7364 {
7365
7366     guint16     length;
7367     proto_tree *ext_tree;
7368
7369     length = tvb_get_ntohs(tvb, offset + 1);
7370
7371     ext_tree = proto_tree_add_subtree(tree, tvb, offset, length + 3, ett_gtp_ies[GTP_EXT_FQDN], NULL,
7372                                     val_to_str_ext_const(GTP_EXT_FQDN, &gtp_val_ext, "Unknown field"));
7373     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7374
7375     proto_tree_add_item(ext_tree, hf_gtp_fqdn_length, tvb, offset + 1, 2, ENC_BIG_ENDIAN);
7376     decode_fqdn(tvb, offset + 3, length, ext_tree, NULL);
7377
7378     return 3 + length;
7379 }
7380
7381 /*
7382  * 7.7.91 Evolved Allocation/Retention Priority I
7383  */
7384 static int
7385 decode_gtp_evolved_allc_rtn_p1(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7386 {
7387
7388     guint16     length;
7389     proto_tree *ext_tree;
7390
7391     length = tvb_get_ntohs(tvb, offset + 1);
7392     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_EVO_ALLO_RETE_P1], NULL,
7393                                         val_to_str_ext_const(GTP_EXT_EVO_ALLO_RETE_P1, &gtpv1_val_ext, "Unknown"));
7394     proto_tree_add_item(ext_tree, hf_gtp_ie_id,      tvb, offset, 1, ENC_BIG_ENDIAN);
7395
7396     offset++;
7397     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7398     offset += 2;
7399
7400     proto_tree_add_item(ext_tree, hf_gtp_earp_pci,   tvb, offset, 1, ENC_BIG_ENDIAN);
7401     proto_tree_add_item(ext_tree, hf_gtp_earp_pl,    tvb, offset, 1, ENC_BIG_ENDIAN);
7402     proto_tree_add_item(ext_tree, hf_gtp_earp_pvi,   tvb, offset, 1, ENC_BIG_ENDIAN);
7403
7404     return 3 + length;
7405
7406
7407 }
7408
7409 /*
7410  * 7.7.92 Evolved Allocation/Retention Priority II
7411  */
7412 static int
7413 decode_gtp_evolved_allc_rtn_p2(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7414 {
7415
7416     guint16     length;
7417     proto_tree *ext_tree;
7418
7419     length = tvb_get_ntohs(tvb, offset + 1);
7420     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_EVO_ALLO_RETE_P2], NULL,
7421                                         val_to_str_ext_const(GTP_EXT_EVO_ALLO_RETE_P2, &gtpv1_val_ext, "Unknown"));
7422     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7423
7424     offset++;
7425     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7426     offset = offset + 2;
7427
7428     proto_tree_add_item(ext_tree, hf_gtp_nsapi, tvb, offset, 1, ENC_BIG_ENDIAN);
7429     offset++;
7430
7431     proto_tree_add_item(ext_tree, hf_gtp_earp_pci, tvb, offset, 1, ENC_BIG_ENDIAN);
7432     proto_tree_add_item(ext_tree, hf_gtp_earp_pl,  tvb, offset, 1, ENC_BIG_ENDIAN);
7433     proto_tree_add_item(ext_tree, hf_gtp_earp_pvi, tvb, offset, 1, ENC_BIG_ENDIAN);
7434
7435     return 3 + length;
7436
7437
7438 }
7439
7440 /*
7441  * 7.7.93 Extended Common Flags
7442  */
7443 static int
7444 decode_gtp_extended_common_flgs(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7445 {
7446     guint16     length;
7447     proto_tree *ext_tree;
7448
7449     length = tvb_get_ntohs(tvb, offset + 1);
7450     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_EXTENDED_COMMON_FLGS], NULL,
7451                                         val_to_str_ext_const(GTP_EXT_EXTENDED_COMMON_FLGS, &gtpv1_val_ext, "Unknown"));
7452     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7453
7454     offset++;
7455     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7456     offset = offset + 2;
7457
7458     proto_tree_add_item(ext_tree, hf_gtp_ext_comm_flags_uasi, tvb, offset, 1, ENC_BIG_ENDIAN);
7459     offset++;
7460
7461     if(length > 1){
7462         proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length-1);
7463     }
7464
7465     return 3 + length;
7466 }
7467
7468 /*
7469  * 7.7.94 User CSG Information (UCI)
7470  */
7471 static int
7472 decode_gtp_uci(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7473 {
7474     guint16     length;
7475     proto_tree *ext_tree;
7476
7477     length = tvb_get_ntohs(tvb, offset + 1);
7478     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_UCI], NULL,
7479                                         val_to_str_ext_const(GTP_EXT_UCI, &gtpv1_val_ext, "Unknown"));
7480     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7481
7482     offset++;
7483     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7484     offset = offset + 2;
7485
7486     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
7487
7488     return 3 + length;
7489 }
7490
7491 /*
7492  * 7.7.95 CSG Information Reporting Action
7493  */
7494
7495 static int
7496 decode_gtp_csg_inf_rep_act(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7497 {
7498     guint16     length;
7499     proto_tree *ext_tree;
7500
7501     length = tvb_get_ntohs(tvb, offset + 1);
7502     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_CSG_INF_REP_ACT], NULL,
7503                                             val_to_str_ext_const(GTP_EXT_CSG_INF_REP_ACT, &gtpv1_val_ext, "Unknown"));
7504     proto_tree_add_item(ext_tree, hf_gtp_ie_id,      tvb, offset, 1, ENC_BIG_ENDIAN);
7505
7506     offset++;
7507     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7508     offset = offset + 2;
7509
7510     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
7511
7512     return 3 + length;
7513 }
7514 /*
7515  * 7.7.96 CSG ID
7516  */
7517
7518 static int
7519 decode_gtp_csg_id(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7520 {
7521     guint16     length;
7522     proto_tree *ext_tree;
7523
7524     length = tvb_get_ntohs(tvb, offset + 1);
7525     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_CSG_ID], NULL,
7526                                             val_to_str_ext_const(GTP_EXT_CSG_ID, &gtpv1_val_ext, "Unknown"));
7527     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7528
7529     offset++;
7530     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7531     offset = offset + 2;
7532
7533     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
7534
7535     return 3 + length;
7536 }
7537 /*
7538  * 7.7.97 CSG Membership Indication (CMI)
7539  */
7540 static int
7541 decode_gtp_cmi(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7542 {
7543     guint16     length;
7544     proto_tree *ext_tree;
7545
7546     length = tvb_get_ntohs(tvb, offset + 1);
7547     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_CMI], NULL,
7548                                         val_to_str_ext_const(GTP_EXT_CMI, &gtpv1_val_ext, "Unknown"));
7549     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7550
7551     offset++;
7552     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7553     offset = offset + 2;
7554
7555     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
7556
7557     return 3 + length;
7558 }
7559 /*
7560  * 7.7.98 APN Aggregate Maximum Bit Rate (APN-AMBR)
7561  */
7562 static int
7563 decode_gtp_apn_ambr(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7564 {
7565     guint16     length;
7566     proto_tree *ext_tree;
7567
7568     length = tvb_get_ntohs(tvb, offset + 1);
7569     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_RELIABLE_IRAT_HO_INF], NULL,
7570                                         val_to_str_ext_const(GTP_EXT_AMBR, &gtpv1_val_ext, "Unknown"));
7571     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7572
7573     offset++;
7574     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7575     offset = offset + 2;
7576
7577     /* APN Aggregate Maximum Bit Rate (APN-AMBR) is defined in clause 9.9.4.2 of 3GPP TS 24.301 [42], but shall be
7578      * formatted as shown in Figure 7.7.98-1 as Unsigned32 binary integer values in kbps (1000 bits per second).
7579      */
7580     /* 4 to 7 APN-AMBR for Uplink */
7581     proto_tree_add_item(ext_tree, hf_gtp_ext_apn_ambr_ul, tvb, offset, 4, ENC_BIG_ENDIAN);
7582     offset+=4;
7583     /* 8 to 11 APN-AMBR for Downlink */
7584     proto_tree_add_item(ext_tree, hf_gtp_ext_apn_ambr_dl, tvb, offset, 4, ENC_BIG_ENDIAN);
7585
7586     return 3 + length;
7587 }
7588 /*
7589  * 7.7.99 UE Network Capability
7590  */
7591 static int
7592 decode_gtp_ue_network_cap(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
7593 {
7594     guint16     length;
7595     proto_tree *ext_tree;
7596
7597     length = tvb_get_ntohs(tvb, offset + 1);
7598     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_UE_NETWORK_CAP], NULL,
7599                                         val_to_str_ext_const(GTP_EXT_UE_NETWORK_CAP, &gtpv1_val_ext, "Unknown"));
7600
7601     offset++;
7602     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7603     offset = offset + 2;
7604
7605     de_emm_ue_net_cap(tvb, ext_tree, pinfo, offset, length, NULL, 0);
7606
7607     return 3 + length;
7608 }
7609 /*
7610  * 7.7.100 UE-AMBR
7611  */
7612
7613 static int
7614 decode_gtp_ue_ambr(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7615 {
7616     guint16     length;
7617     proto_tree *ext_tree;
7618
7619     length = tvb_get_ntohs(tvb, offset + 1);
7620     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_APN_AMBR_WITH_NSAPI], NULL,
7621                                         val_to_str_ext_const(GTP_EXT_APN_AMBR_WITH_NSAPI, &gtpv1_val_ext, "Unknown"));
7622     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7623
7624     offset++;
7625     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7626     offset = offset + 2;
7627
7628     /* 4 to 7 Subscribed UE-AMBR for Uplink */
7629     proto_tree_add_item(ext_tree, hf_gtp_ext_sub_ue_ambr_ul, tvb, offset, 4, ENC_BIG_ENDIAN);
7630     offset+=4;
7631     /* 8 to 11 Subscribed UE-AMBR for Downlink */
7632     proto_tree_add_item(ext_tree, hf_gtp_ext_sub_ue_ambr_dl, tvb, offset, 4, ENC_BIG_ENDIAN);
7633     offset+=4;
7634
7635     /* Authorized UE-AMBR for Uplink and Downlink fields are present in the IE only if the sender has their valid values
7636      * available. Otherwise, the fields from m to (n+3) shall not be present.
7637      */
7638     if(offset >= length)
7639         return 3 + length;
7640
7641     /* m to (m+3) Authorized UE-AMBR for Uplink */
7642     proto_tree_add_item(ext_tree, hf_gtp_ext_auth_ue_ambr_ul, tvb, offset, 4, ENC_BIG_ENDIAN);
7643     offset+=4;
7644
7645     /* (m+4) to (n+3) Authorized UE-AMBR for Downlink */
7646     proto_tree_add_item(ext_tree, hf_gtp_ext_auth_ue_ambr_dl, tvb, offset, 4, ENC_BIG_ENDIAN);
7647
7648     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
7649
7650     return 3 + length;
7651 }
7652
7653 /*
7654  * 7.7.101 APN-AMBR with NSAPI
7655  */
7656 static int
7657 decode_gtp_apn_ambr_with_nsapi(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7658 {
7659     guint16     length;
7660     proto_tree *ext_tree;
7661
7662     length = tvb_get_ntohs(tvb, offset + 1);
7663     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_UE_AMBR], NULL,
7664                                         val_to_str_ext_const(GTP_EXT_UE_AMBR, &gtpv1_val_ext, "Unknown"));
7665     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7666
7667     offset++;
7668     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7669     offset = offset + 2;
7670
7671     proto_tree_add_item(ext_tree, hf_gtp_nsapi, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
7672     offset++;
7673
7674     /* 5 to 8 Authorized APN-AMBR for Uplink */
7675     proto_tree_add_item(ext_tree, hf_gtp_ext_auth_apn_ambr_ul, tvb, offset, 4, ENC_BIG_ENDIAN);
7676     offset+=4;
7677
7678     /* 9 to12 Authorized APN-AMBR for Downlink */
7679     proto_tree_add_item(ext_tree, hf_gtp_ext_auth_apn_ambr_dl, tvb, offset, 4, ENC_BIG_ENDIAN);
7680
7681     return 3 + length;
7682 }
7683 /*
7684  * 7.7.102 GGSN Back-Off Time
7685  */
7686 /* Table 7.7.102.1: GGSN Back-Off Time information element */
7687 static const value_string gtp_ggsn_back_off_time_units_vals[] = {
7688     {0, "value is incremented in multiples of 2 seconds"},
7689     {1, "value is incremented in multiples of 1 minute"},
7690     {2, "value is incremented in multiples of 10 minutes"},
7691     {3, "value is incremented in multiples of 1 hour"},
7692     {4, "value is incremented in multiples of 10 hours"},
7693     {5, "value indicates that the timer is infinite"},
7694     {0, NULL}
7695 };
7696 static int
7697 decode_gtp_ggsn_back_off_time(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7698 {
7699     guint16     length;
7700     proto_tree *ext_tree;
7701
7702     length = tvb_get_ntohs(tvb, offset + 1);
7703     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_GGSN_BACK_OFF_TIME], NULL,
7704                                         val_to_str_ext_const(GTP_EXT_GGSN_BACK_OFF_TIME, &gtpv1_val_ext, "Unknown"));
7705     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7706
7707     offset++;
7708     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7709     offset += 2;
7710
7711     /* 4 Timer unit Timer value */
7712     proto_tree_add_item(ext_tree, hf_gtp_ext_ggsn_back_off_time_units, tvb, offset, 1, ENC_BIG_ENDIAN);
7713     proto_tree_add_item(ext_tree, hf_gtp_ext_ggsn_back_off_timer, tvb, offset, 1, ENC_BIG_ENDIAN);
7714
7715     return 3 + length;
7716 }
7717
7718 /*
7719  * 7.7.103 Signalling Priority Indication
7720  */
7721
7722 static int
7723 decode_gtp_sig_pri_ind(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7724 {
7725     guint16     length;
7726     proto_tree *ext_tree;
7727
7728     length = tvb_get_ntohs(tvb, offset + 1);
7729     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_SIG_PRI_IND], NULL,
7730                                     val_to_str_ext_const(GTP_EXT_SIG_PRI_IND, &gtpv1_val_ext, "Unknown"));
7731     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7732
7733     offset++;
7734     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7735     offset += 2;
7736
7737     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
7738
7739     return 3 + length;
7740 }
7741 /*
7742  * 7.7.104 Signalling Priority Indication with NSAPI
7743  */
7744
7745 static int
7746 decode_gtp_sig_pri_ind_w_nsapi(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7747 {
7748     guint16     length;
7749     proto_tree *ext_tree;
7750
7751     length = tvb_get_ntohs(tvb, offset + 1);
7752     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_SIG_PRI_IND_W_NSAPI], NULL,
7753                                             val_to_str_ext_const(GTP_EXT_SIG_PRI_IND_W_NSAPI, &gtpv1_val_ext, "Unknown"));
7754     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7755
7756     offset++;
7757     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7758     offset += 2;
7759
7760     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
7761
7762     return 3 + length;
7763 }
7764 /*
7765  * 7.7.105 Higher bitrates than 16 Mbps flag
7766  */
7767 static const value_string gtp_higher_br_16mb_flg_vals[] = {
7768     {0, "Not allowed"},
7769     {1, "Allowed"},
7770     {0, NULL}
7771 };
7772
7773 static int
7774 decode_gtp_higher_br_16mb_flg(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7775 {
7776     guint16     length;
7777     proto_tree *ext_tree;
7778
7779     length = tvb_get_ntohs(tvb, offset + 1);
7780     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_HIGHER_BR_16MB_FLG], NULL,
7781                                           val_to_str_ext_const(GTP_EXT_HIGHER_BR_16MB_FLG, &gtpv1_val_ext, "Unknown"));
7782     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7783
7784     offset++;
7785     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7786     offset += 2;
7787
7788     /* Higher bitrates than 16 Mbps flag */
7789     proto_tree_add_item(ext_tree, hf_gtp_higher_br_16mb_flg, tvb, offset, 1, ENC_BIG_ENDIAN);
7790
7791     return 3 + length;
7792 }
7793 /*
7794  * 7.7.106 Max MBR/APN-AMBR
7795  */
7796
7797 static int
7798 decode_gtp_max_mbr_apn_ambr(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7799 {
7800     guint16     length;
7801     proto_tree *ext_tree;
7802     guint32     max_ul;
7803     guint32     max_dl;
7804
7805     length = tvb_get_ntohs(tvb, offset + 1);
7806     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_MAX_MBR_APN_AMBR], NULL,
7807                                     val_to_str_ext_const(GTP_EXT_MAX_MBR_APN_AMBR, &gtpv1_val_ext, "Unknown"));
7808     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7809
7810     offset++;
7811     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7812     offset = offset + 2;
7813
7814         /* Max MBR/APN-AMBR for uplink */
7815     max_ul = tvb_get_ntohl(tvb, offset);
7816     proto_tree_add_uint_format_value(ext_tree, hf_gtp_max_mbr_apn_ambr_ul, tvb, offset, 4, max_ul, "%u %s",
7817                                (max_ul) > 1000 ? max_ul/1000 : max_ul,
7818                                (max_ul) > 1000 ? "Mbps" : "kbps");
7819
7820     offset += 4;
7821
7822     /* Max MBR/APN-AMBR for downlink */
7823     max_dl = tvb_get_ntohl(tvb, offset);
7824     proto_tree_add_uint_format_value(ext_tree, hf_gtp_max_mbr_apn_ambr_dl, tvb, offset, 4, max_dl, "%u %s",
7825                                 (max_dl) > 1000 ? max_dl/1000 : max_dl,
7826                                 (max_dl) > 1000 ? "Mbps" : "kbps");
7827
7828     return 3 + length;
7829 }
7830 /*
7831  * 7.7.107 Additional MM context for SRVCC
7832  */
7833
7834 static int
7835 decode_gtp_add_mm_ctx_srvcc(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7836 {
7837     guint16     length;
7838     proto_tree *ext_tree;
7839
7840     length = tvb_get_ntohs(tvb, offset + 1);
7841     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_ADD_MM_CTX_SRVCC], NULL,
7842                                         val_to_str_ext_const(GTP_EXT_ADD_MM_CTX_SRVCC, &gtpv1_val_ext, "Unknown"));
7843     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7844
7845     offset++;
7846     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7847     offset += 2;
7848
7849     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
7850
7851     return 3 + length;
7852 }
7853
7854 /*
7855  * 7.7.108 Additional flags for SRVCC
7856  */
7857
7858 static int
7859 decode_gtp_add_flgs_srvcc(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7860 {
7861     guint16     length;
7862     proto_tree *ext_tree;
7863
7864     length = tvb_get_ntohs(tvb, offset + 1);
7865     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_ADD_FLGS_SRVCC], NULL,
7866                                         val_to_str_ext_const(GTP_EXT_ADD_FLGS_SRVCC, &gtpv1_val_ext, "Unknown"));
7867     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7868
7869     offset++;
7870     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7871     offset += 2;
7872
7873     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
7874
7875     return 3 + length;
7876 }
7877 /*
7878  * 7.7.109 STN-SR
7879  */
7880 static int
7881 decode_gtp_stn_sr(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7882 {
7883     guint16     length;
7884     proto_tree *ext_tree;
7885
7886     length = tvb_get_ntohs(tvb, offset + 1);
7887     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_STN_SR], NULL,
7888                                         val_to_str_ext_const(GTP_EXT_STN_SR, &gtpv1_val_ext, "Unknown"));
7889     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7890
7891     offset++;
7892     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7893     offset += 2;
7894
7895     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
7896
7897     return 3 + length;
7898 }
7899
7900 /*
7901  * 7.7.110 C-MSISDN
7902  */
7903
7904 static int
7905 decode_gtp_c_msisdn(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7906 {
7907     guint16     length;
7908     proto_tree *ext_tree;
7909
7910     length = tvb_get_ntohs(tvb, offset + 1);
7911     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_C_MSISDN], NULL,
7912                                         val_to_str_ext_const(GTP_EXT_C_MSISDN, &gtpv1_val_ext, "Unknown"));
7913     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7914
7915     offset++;
7916     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7917     offset += 2;
7918
7919     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
7920
7921     return 3 + length;
7922 }
7923 /*
7924  * 7.7.111 Extended RANAP Cause
7925  */
7926 static int
7927 decode_gtp_ext_ranap_cause(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7928 {
7929     guint16     length;
7930     proto_tree *ext_tree;
7931
7932     length = tvb_get_ntohs(tvb, offset + 1);
7933     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_EXT_RANAP_CAUSE], NULL,
7934                                         val_to_str_ext_const(GTP_EXT_EXT_RANAP_CAUSE, &gtpv1_val_ext, "Unknown"));
7935     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7936
7937     offset++;
7938     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7939     offset += 2;
7940
7941     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
7942
7943     return 3 + length;
7944 }
7945
7946 /*
7947  * 7.7.112 eNodeB ID
7948  */
7949
7950 static const value_string gtp_enb_type_vals[] = {
7951     { 0, "Macro eNodeB ID" },
7952     { 1, "Home eNodeB ID" },
7953     { 0, NULL }
7954 };
7955
7956 static int
7957 decode_gtp_ext_enodeb_id(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7958 {
7959     guint16     length;
7960     proto_tree *ext_tree;
7961     guint32 enb_type;
7962
7963     length = tvb_get_ntohs(tvb, offset + 1);
7964     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_ENODEB_ID], NULL,
7965         val_to_str_ext_const(GTP_EXT_ENODEB_ID, &gtpv1_val_ext, "Unknown"));
7966     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7967
7968     offset++;
7969     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7970     offset += 2;
7971
7972     /* eNodeB Type */
7973     proto_tree_add_item_ret_uint(ext_tree, hf_gtp_ext_enb_type, tvb, offset, 1, ENC_BIG_ENDIAN, &enb_type);
7974     offset++;
7975
7976     dissect_e212_mcc_mnc(tvb, pinfo, ext_tree, offset, E212_NONE, TRUE);
7977     offset += 3;
7978
7979     switch (enb_type){
7980     case 0:
7981         /* Macro eNodeB ID */
7982         proto_tree_add_item(ext_tree, hf_gtp_macro_enodeb_id, tvb, offset, 3, ENC_BIG_ENDIAN);
7983         offset += 3;
7984         proto_tree_add_item(ext_tree, hf_gtp_tac, tvb, offset, 2, ENC_BIG_ENDIAN);
7985         break;
7986     case 1:
7987         /* Home eNodeB ID */
7988         proto_tree_add_item(ext_tree, hf_gtp_home_enodeb_id, tvb, offset, 4, ENC_BIG_ENDIAN);
7989         offset += 4;
7990         proto_tree_add_item(ext_tree, hf_gtp_tac, tvb, offset, 2, ENC_BIG_ENDIAN);
7991         break;
7992     default:
7993         proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length - 4);
7994         break;
7995     }
7996
7997     return 3 + length;
7998 }
7999
8000 /*
8001  * 7.7.113 Selection Mode with NSAPI
8002  */
8003 static int
8004 decode_gtp_ext_sel_mode_w_nsapi(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8005 {
8006     guint16     length;
8007     proto_tree *ext_tree;
8008
8009     length = tvb_get_ntohs(tvb, offset + 1);
8010     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_SEL_MODE_W_NSAPI], NULL,
8011         val_to_str_ext_const(GTP_EXT_SEL_MODE_W_NSAPI, &gtpv1_val_ext, "Unknown"));
8012     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
8013
8014     offset++;
8015     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8016     offset += 2;
8017
8018     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
8019
8020     return 3 + length;
8021 }
8022 /*
8023  * 7.7.114 ULI Timestamp
8024  */
8025 static int
8026 decode_gtp_ext_uli_timestamp(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8027 {
8028     guint16     length;
8029     proto_tree *ext_tree;
8030
8031     length = tvb_get_ntohs(tvb, offset + 1);
8032     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_ULI_TIMESTAMP], NULL,
8033         val_to_str_ext_const(GTP_EXT_ULI_TIMESTAMP, &gtpv1_val_ext, "Unknown"));
8034     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
8035
8036     offset++;
8037     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8038     offset += 2;
8039
8040     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
8041
8042     return 3 + length;
8043 }
8044
8045 /*
8046  * 7.7.115 Local Home Network ID (LHN-ID) with NSAPI
8047  */
8048 static int
8049 decode_gtp_ext_lhn_id_w_sapi(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8050 {
8051     guint16     length;
8052     proto_tree *ext_tree;
8053
8054     length = tvb_get_ntohs(tvb, offset + 1);
8055     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_LHN_ID_W_SAPI], NULL,
8056         val_to_str_ext_const(GTP_EXT_LHN_ID_W_SAPI, &gtpv1_val_ext, "Unknown"));
8057     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
8058
8059     offset++;
8060     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8061     offset += 2;
8062
8063     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
8064
8065     return 3 + length;
8066 }
8067 /*
8068  * 7.7.116 CN Operator Selection Entity
8069  */
8070 static int
8071 decode_gtp_ext_cn_op_sel_entity(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8072 {
8073     guint16     length;
8074     proto_tree *ext_tree;
8075
8076     length = tvb_get_ntohs(tvb, offset + 1);
8077     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_CN_OP_SEL_ENTITY], NULL,
8078         val_to_str_ext_const(GTP_EXT_CN_OP_SEL_ENTITY, &gtpv1_val_ext, "Unknown"));
8079     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
8080
8081     offset++;
8082     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8083     offset += 2;
8084
8085     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
8086
8087     return 3 + length;
8088 }
8089
8090 /*
8091  * 7.7.118 Extended Common Flags II
8092  */
8093 static int
8094 decode_gtp_extended_common_flgs_II(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8095 {
8096     guint16     length;
8097     proto_tree *ext_tree;
8098
8099     length = tvb_get_ntohs(tvb, offset + 1);
8100     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_EXT_COMMON_FLGS_II], NULL,
8101                                         val_to_str_ext_const(GTP_EXT_EXT_COMMON_FLGS_II, &gtpv1_val_ext, "Unknown"));
8102     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
8103
8104     offset++;
8105     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8106     offset = offset + 2;
8107
8108     proto_tree_add_item(ext_tree, hf_gtp_ext_comm_flags_II_pnsi, tvb, offset, 1, ENC_BIG_ENDIAN);
8109     proto_tree_add_item(ext_tree, hf_gtp_ext_comm_flags_II_dtci, tvb, offset, 1, ENC_BIG_ENDIAN);
8110     proto_tree_add_item(ext_tree, hf_gtp_ext_comm_flags_II_pmtsmi, tvb, offset, 1, ENC_BIG_ENDIAN);
8111     proto_tree_add_item(ext_tree, hf_gtp_ext_comm_flags_II_spare, tvb, offset, 1, ENC_BIG_ENDIAN);
8112
8113     offset++;
8114
8115     if(length > 1){
8116         proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length-1);
8117     }
8118
8119     return 3 + length;
8120 }
8121
8122
8123 static int
8124 decode_gtp_rel_pack(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8125 {
8126
8127     guint16     length, n, number;
8128     proto_tree *ext_tree_rel_pack;
8129
8130     length = tvb_get_ntohs(tvb, offset + 1);
8131
8132     ext_tree_rel_pack = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_rel_pack, NULL,
8133                                     "Sequence numbers of released packets IE");
8134
8135     n = 0;
8136
8137     while (n < length) {
8138
8139         number = tvb_get_ntohs(tvb, offset + 3 + n);
8140         proto_tree_add_uint_format(ext_tree_rel_pack, hf_gtp_seq_num_released, tvb, offset + 3 + n, 2, number, "%u", number);
8141         n = n + 2;
8142
8143     }
8144
8145     return 3 + length;
8146 }
8147
8148 /* GPRS:        12.15
8149  * UMTS:        33.015
8150  */
8151 static int
8152 decode_gtp_can_pack(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8153 {
8154
8155     guint16     length, n, number;
8156     proto_tree *ext_tree_can_pack;
8157
8158     length = tvb_get_ntohs(tvb, offset + 1);
8159
8160     ext_tree_can_pack = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_can_pack, NULL,
8161                                         "Sequence numbers of cancelled  packets IE");
8162
8163     n = 0;
8164
8165     while (n < length) {
8166
8167         number = tvb_get_ntohs(tvb, offset + 3 + n);
8168         proto_tree_add_uint_format(ext_tree_can_pack, hf_gtp_seq_num_canceled, tvb, offset + 3 + n, 2, number, "%u", number);
8169         n += 2;
8170     }
8171
8172     return 3 + length;
8173 }
8174
8175 /* CDRs dissector
8176  * 3GPP TS 32.295 version 9.0.0 Release 9
8177  */
8178
8179
8180 static const value_string gtp_cdr_fmt_vals[] = {
8181     {1, "Basic Encoding Rules (BER)"},
8182     {2, "Unaligned basic Packed Encoding Rules (PER)"},
8183     {3, "Aligned basic Packed Encoding Rules (PER)"},
8184     {0, NULL}
8185 };
8186 static int
8187 decode_gtp_data_req(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
8188 {
8189
8190     guint16     length, cdr_length;
8191     guint8      no, format, app_id, rel_id, ver_id, i;
8192     proto_tree *ext_tree, *ver_tree, *cdr_dr_tree;
8193     proto_item *fmt_item;
8194     tvbuff_t   *next_tvb;
8195
8196     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 1, ett_gtp_ext, NULL,
8197                     val_to_str_ext_const(GTP_EXT_DATA_REQ, &gtp_val_ext, "Unknown message"));
8198     offset++;
8199
8200     length = tvb_get_ntohs(tvb, offset);
8201     proto_tree_add_uint(ext_tree, hf_gtp_length, tvb, offset, 2, length);
8202     offset+=2;
8203
8204     if (length == 0) {
8205         return 3;
8206     }
8207
8208     /* Octet 4 Number of Data Records */
8209     no = tvb_get_guint8(tvb, offset);
8210     proto_tree_add_item(ext_tree, hf_gtp_number_of_data_records, tvb, offset, 1, ENC_BIG_ENDIAN);
8211     offset++;
8212
8213     /* Octet 5 Data Record Format */
8214     format   = tvb_get_guint8(tvb, offset);
8215     fmt_item = proto_tree_add_item(ext_tree, hf_gtp_data_record_format, tvb, offset, 1, ENC_BIG_ENDIAN);
8216     offset++;
8217     /* The value range is 1-255 in decimal. The value '0' should not be used.
8218      * Only the values 1-10 and 51-255 can be used for standards purposes.
8219      * Values in the range of 11-50 are to be configured only by operators, and are not subject to standardization.
8220      */
8221     if(format < 4) {
8222         proto_item_append_text(fmt_item, " %s", val_to_str_const(format, gtp_cdr_fmt_vals, "Unknown"));
8223         /* Octet 6 -7  Data Record Format Version
8224          *    8 7 6 5             4 3 2 1
8225          * 6 Application Identifier Release Identifier
8226          * 7 Version Identifier
8227          */
8228         app_id = tvb_get_guint8(tvb,offset);
8229         rel_id = app_id & 0x0f;
8230         app_id = app_id >>4;
8231         ver_id =tvb_get_guint8(tvb,offset+1);
8232         /* The second octet (#7 in Data Record Packet IE) identifies the version of the TS used to encode the CDR,
8233          * i.e. its value corresponds to the second digit of the version number of the document [51]
8234          * (as shown on the cover sheet), plus '1'.
8235          * E.g. for version 3.4.0, the Version Identifier would be "5".
8236          * In circumstances where the second digit is an alphabetical character, (e.g. 3.b.0), the corresponding ASCII value shall
8237          * be taken, e.g. the Version Identifier would be "66" (ASCII(b)).
8238          */
8239         if(ver_id < 0x65)
8240             ver_id = ver_id -1;
8241         /* XXX We don't handle ASCCI version */
8242
8243         ver_tree = proto_tree_add_subtree_format(ext_tree, tvb, offset, 2, ett_gtp_cdr_ver, NULL,
8244                                 "Data record format version: AppId %u Rel %u.%u.0", app_id,rel_id,ver_id);
8245         proto_tree_add_item(ver_tree, hf_gtp_cdr_app, tvb, offset, 1, ENC_BIG_ENDIAN);
8246         proto_tree_add_item(ver_tree, hf_gtp_cdr_rel, tvb, offset, 1, ENC_BIG_ENDIAN);
8247         offset++;
8248         proto_tree_add_item(ver_tree, hf_gtp_cdr_ver, tvb, offset, 1, ENC_BIG_ENDIAN);
8249         offset++;
8250         for(i = 0; i < no; ++i) {
8251             cdr_length = tvb_get_ntohs(tvb, offset);
8252             cdr_dr_tree = proto_tree_add_subtree_format(ext_tree, tvb, offset, cdr_length+2,
8253                                     ett_gtp_cdr_dr, NULL, "Data record %d", i + 1);
8254             proto_tree_add_uint(cdr_dr_tree, hf_gtp_cdr_length, tvb, offset, 2, cdr_length);
8255             offset+=2;
8256             proto_tree_add_item(cdr_dr_tree, hf_gtp_cdr_context, tvb, offset, cdr_length, ENC_NA);
8257             next_tvb = tvb_new_subset_remaining(tvb, offset);
8258
8259             /* XXX this is for release 6, may not work for higher releases */
8260             if(format==1) {
8261                 if(rel_id <= 6){
8262                     dissect_gprscdr_GPRSCallEventRecord_PDU(next_tvb, pinfo, cdr_dr_tree, NULL);
8263                 }else if(rel_id >6){
8264                     dissect_gprscdr_GPRSRecord_PDU(next_tvb, pinfo, cdr_dr_tree, NULL);
8265                 }
8266             } else {
8267                 /* Do we have a dissector regestering for this data format? */
8268                 dissector_try_uint(gtp_cdr_fmt_dissector_table, format, next_tvb, pinfo, cdr_dr_tree);
8269             }
8270
8271             offset = offset + cdr_length;
8272         }
8273
8274     } else {
8275         /* Proprietary CDR format */
8276         proto_item_append_text(fmt_item, " Proprietary or un documented format");
8277     }
8278
8279     if (gtpcdr_handle) {
8280         next_tvb = tvb_new_subset_remaining(tvb, offset);
8281         call_dissector(gtpcdr_handle, next_tvb, pinfo, tree);
8282     }
8283
8284     return 3 + length;
8285 }
8286
8287 /* GPRS:        12.15
8288  * UMTS:        33.015
8289  */
8290 static int
8291 decode_gtp_data_resp(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8292 {
8293
8294     guint16     length, n, number;
8295     proto_tree *ext_tree_data_resp;
8296
8297     length = tvb_get_ntohs(tvb, offset + 1);
8298
8299     ext_tree_data_resp = proto_tree_add_subtree(tree, tvb, offset, 3 + length,
8300                                 ett_gtp_data_resp, NULL, "Requests responded");
8301
8302     n = 0;
8303
8304     while (n < length) {
8305
8306         number = tvb_get_ntohs(tvb, offset + 3 + n);
8307         proto_tree_add_uint_format(ext_tree_data_resp, hf_gtp_requests_responded, tvb, offset + 3 + n, 2, number, "%u", number);
8308         n = n + 2;
8309
8310     }
8311
8312     return 3 + length;
8313
8314 }
8315
8316 /* GPRS:        12.15
8317  * UMTS:        33.015
8318  */
8319 static int
8320 decode_gtp_node_addr(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8321 {
8322
8323     guint16            length;
8324     proto_tree        *ext_tree_node_addr;
8325     proto_item        *te;
8326
8327     length = tvb_get_ntohs(tvb, offset + 1);
8328
8329     ext_tree_node_addr = proto_tree_add_subtree(tree, tvb, offset, 3 + length,
8330                                 ett_gtp_node_addr, &te, "Node address: ");
8331
8332     proto_tree_add_item(ext_tree_node_addr, hf_gtp_node_address_length, tvb, offset + 1, 2, ENC_BIG_ENDIAN);
8333
8334     switch (length) {
8335     case 4:
8336         proto_tree_add_item(ext_tree_node_addr, hf_gtp_node_ipv4, tvb, offset + 3, 4, ENC_BIG_ENDIAN);
8337         proto_item_append_text(te, "%s", tvb_ip_to_str(tvb, offset + 3));
8338         break;
8339     case 16:
8340         proto_tree_add_item(ext_tree_node_addr, hf_gtp_node_ipv6, tvb, offset + 3, 16, ENC_NA);
8341         proto_item_append_text(te, "%s", tvb_ip6_to_str(tvb, offset + 3));
8342         break;
8343     default:
8344         proto_item_append_text(te, "unknown type or wrong length");
8345         break;
8346     }
8347
8348     return 3 + length;
8349
8350 }
8351
8352 /* GPRS:        9.60 v7.6.0, chapter 7.9.26
8353  * UMTS:        29.060 v4.0, chapter 7.7.46 Private Extension
8354  *
8355  */
8356
8357 static int
8358 decode_gtp_priv_ext(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
8359 {
8360
8361     guint16     length, ext_id;
8362     proto_tree *ext_tree_priv_ext;
8363     proto_item *te;
8364     tvbuff_t   *next_tvb;
8365
8366     ext_tree_priv_ext = proto_tree_add_subtree_format(tree, tvb, offset, 1, ett_gtp_ext, &te,
8367                 "%s : ", val_to_str_ext_const(GTP_EXT_PRIV_EXT, &gtp_val_ext, "Unknown message"));
8368
8369     offset++;
8370     length = tvb_get_ntohs(tvb, offset);
8371     proto_tree_add_item(ext_tree_priv_ext, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8372     offset += 2;
8373     if (length >= 2) {
8374         ext_id = tvb_get_ntohs(tvb, offset);
8375         proto_tree_add_uint(ext_tree_priv_ext, hf_gtp_ext_id, tvb, offset, 2, ext_id);
8376         proto_item_append_text(te, "%s (%u)", enterprises_lookup(ext_id, "Unknown"), ext_id);
8377         offset = offset + 2;
8378
8379        if (length > 2) {
8380             next_tvb = tvb_new_subset_length(tvb, offset, length-2);
8381             if(!dissector_try_uint(gtp_priv_ext_dissector_table, ext_id, next_tvb, pinfo, ext_tree_priv_ext)){
8382                     proto_tree_add_item(ext_tree_priv_ext, hf_gtp_ext_val, tvb, offset, length - 2, ENC_NA);
8383             }
8384        }
8385     }
8386
8387     return 3 + length;
8388 }
8389
8390 static int
8391 decode_gtp_unknown(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
8392 {
8393
8394     proto_tree_add_expert(tree, pinfo, &ei_gtp_unknown_extention_header, tvb, offset, 1);
8395
8396     return tvb_reported_length_remaining(tvb, offset);
8397 }
8398
8399 static void
8400 track_gtp_session(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, gtp_hdr_t * gtp_hdr, wmem_list_t *teid_list, wmem_list_t *ip_list, guint32 last_teid, address last_ip)
8401 {
8402     guint32 *session, frame_teid_cp;
8403     proto_item *it;
8404
8405     /* GTP session */
8406     if (tree) {
8407         session = (guint32*)g_hash_table_lookup(session_table, &pinfo->num);
8408         if (session) {
8409             it = proto_tree_add_uint(tree, hf_gtp_session, tvb, 0, 0, *session);
8410             PROTO_ITEM_SET_GENERATED(it);
8411         }
8412     }
8413
8414
8415     if (!PINFO_FD_VISITED(pinfo) && gtp_version == 1) {
8416         /* If the message does not have any session ID */
8417         session = (guint32*)g_hash_table_lookup(session_table, &pinfo->num);
8418         if (!session) {
8419             /* If the message is not a CPDPCRES, CPDPCREQ, UPDPREQ, UPDPRES then we remove its information from teid and ip lists */
8420             if ((gtp_hdr->message != GTP_MSG_CREATE_PDP_RESP && gtp_hdr->message != GTP_MSG_CREATE_PDP_REQ && gtp_hdr->message != GTP_MSG_UPDATE_PDP_RESP
8421                 && gtp_hdr->message != GTP_MSG_UPDATE_PDP_REQ)) {
8422                 /* If the lists are not empty*/
8423                 if (wmem_list_count(teid_list) && wmem_list_count(ip_list)) {
8424                     remove_frame_info(&pinfo->num);
8425                 }
8426             }
8427
8428             if (gtp_hdr->message == GTP_MSG_CREATE_PDP_REQ) {
8429                 /* If CPDPCREQ and not already in the list then we create a new session*/
8430                 add_gtp_session(pinfo->num, gtp_session_count++);
8431             } else if (gtp_hdr->message != GTP_MSG_CREATE_PDP_RESP) {
8432                 /* If this is an error indication then we have to check the session id that belongs to the message with the same data teid and ip */
8433                 if (gtp_hdr->message == GTP_MSG_ERR_IND) {
8434                     if (get_frame(last_ip, last_teid, &frame_teid_cp) == 1) {
8435                         session = (guint32*)g_hash_table_lookup(session_table, &frame_teid_cp);
8436                         if (session != NULL) {
8437                             /* We add the corresponding session to the session list*/
8438                             add_gtp_session(pinfo->num, *session);
8439                         }
8440                     }
8441                 }
8442                 else {
8443                     /* We have to check if its teid == teid_cp and ip.dst == gsn_ipv4 from the lists, if that is the case then we have to assign
8444                     the corresponding session ID */
8445                     if ((get_frame(pinfo->dst, (guint32)gtp_hdr->teid, &frame_teid_cp) == 1)) {
8446                         /* Then we have to set its session ID */
8447                         session = (guint32*)g_hash_table_lookup(session_table, &frame_teid_cp);
8448                         if (session != NULL) {
8449                             /* We add the corresponding session to the list so that when a response came we can associate its session ID*/
8450                             add_gtp_session(pinfo->num, *session);
8451                         }
8452                     }
8453                 }
8454             }
8455         }
8456     }
8457 }
8458
8459 static int
8460 dissect_gtp_common(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
8461 {
8462     guint8           octet;
8463     gtp_hdr_t       *gtp_hdr = NULL;
8464     proto_tree      *gtp_tree = NULL, *ext_tree;
8465     proto_item      *ti = NULL, *tf, *ext_hdr_len_item, *message_item;
8466     int              i, offset = 0, checked_field, mandatory;
8467     gboolean         gtp_prime, has_SN;
8468     int              seq_no           = 0;
8469     int              flow_label       = 0;
8470     guint8           pdu_no, next_hdr = 0;
8471     guint8           ext_hdr_val;
8472     guint            ext_hdr_length;
8473     guint16          ext_hdr_pdcpsn;
8474     gchar           *tid_str;
8475     tvbuff_t        *next_tvb;
8476     guint8           sub_proto;
8477     guint8           acfield_len      = 0;
8478     guint8           control_field;
8479     gtp_msg_hash_t  *gcrp             = NULL;
8480     conversation_t  *conversation;
8481     gtp_conv_info_t *gtp_info;
8482     session_args_t  *args             = NULL;
8483
8484     /* Do we have enough bytes for the version and message type? */
8485     if (!tvb_bytes_exist(tvb, 0, 2)) {
8486         /* No - reject the packet. */
8487         return 0;
8488     }
8489     octet = tvb_get_guint8(tvb, 0);
8490     if (((octet >> 5) & 0x07) > 2) {
8491         /* Version > 2; reject the packet */
8492         return 0;
8493     }
8494     octet = tvb_get_guint8(tvb, 1);
8495     if (octet == GTP_MSG_UNKNOWN || try_val_to_str(octet, gtp_message_type) == NULL) {
8496         /* Unknown message type; reject the packet */
8497         return 0;
8498     }
8499
8500     /* Setting everything to 0, so that the TEID is 0 for GTP version 0
8501      * The magic number should perhaps be replaced.
8502      */
8503     gtp_hdr = wmem_new0(wmem_packet_scope(), gtp_hdr_t);
8504
8505     /* Setting the TEID to -1 to say that the TEID is not valid for this packet */
8506     gtp_hdr->teid = -1;
8507
8508     col_set_str(pinfo->cinfo, COL_PROTOCOL, "GTP");
8509     col_clear(pinfo->cinfo, COL_INFO);
8510
8511     if (g_gtp_session) {
8512         args = wmem_new0(wmem_packet_scope(), session_args_t);
8513         args->last_cause = 128;                                         /* It stores the last cause decoded. Cause accepted by default */
8514         /* We create the auxiliary lists */
8515         args->teid_list = wmem_list_new(wmem_packet_scope());
8516         args->ip_list = wmem_list_new(wmem_packet_scope());
8517     }
8518
8519     /*
8520     * Do we have a conversation for this connection?
8521     */
8522     conversation = find_or_create_conversation(pinfo);
8523
8524     /*
8525     * Do we already know this conversation?
8526     */
8527     gtp_info = (gtp_conv_info_t *)conversation_get_proto_data(conversation, proto_gtp);
8528     if (gtp_info == NULL) {
8529         /* No.  Attach that information to the conversation, and add
8530         * it to the list of information structures.
8531         */
8532         gtp_info = (gtp_conv_info_t *)wmem_alloc(wmem_file_scope(), sizeof(gtp_conv_info_t));
8533         /*Request/response matching tables*/
8534         gtp_info->matched = g_hash_table_new(gtp_sn_hash, gtp_sn_equal_matched);
8535         gtp_info->unmatched = g_hash_table_new(gtp_sn_hash, gtp_sn_equal_unmatched);
8536
8537         conversation_add_proto_data(conversation, proto_gtp, gtp_info);
8538
8539         gtp_info->next = gtp_info_items;
8540         gtp_info_items = gtp_info;
8541     }
8542
8543     gtp_hdr->flags = tvb_get_guint8(tvb, offset);
8544
8545     if (!(gtp_hdr->flags & 0x10)){
8546         gtp_prime = TRUE;
8547     }else{
8548         gtp_prime = FALSE;
8549     }
8550
8551     switch ((gtp_hdr->flags >> 5) & 0x07) {
8552         case 0:
8553             gtp_version = 0;
8554             break;
8555         case 1:
8556             gtp_version = 1;
8557             break;
8558         default:
8559             gtp_version = 1;
8560             break;
8561     }
8562     if (tree) {
8563         if (gtp_prime) {
8564             const int * gtp_prime_flags[] = {
8565                 &hf_gtp_prime_flags_ver,
8566                 &hf_gtp_flags_pt,
8567                 &hf_gtp_flags_spare1,
8568                 NULL
8569             };
8570             const int * gtp_prime_v0_flags[] = {
8571                 &hf_gtp_prime_flags_ver,
8572                 &hf_gtp_flags_pt,
8573                 &hf_gtp_flags_spare1,
8574                 &hf_gtp_flags_hdr_length,
8575                 NULL
8576             };
8577
8578             ti = proto_tree_add_item(tree, proto_gtpprime, tvb, 0, -1, ENC_NA);
8579             gtp_tree = proto_item_add_subtree(ti, ett_gtp);
8580
8581             /* Octet  8    7    6    5    4    3    2    1
8582              * 1      Version   | PT| Spare '1 1 1 '| ' 0/1 '
8583              */
8584
8585              /* Bit 1 of octet 1 is not used in GTP' (except in v0), and it is marked '0'
8586               * in the GTP' header. It is in use in GTP' v0 and distinguishes the used header-length.
8587               * In the case of GTP' v0, this bit being marked one (1) indicates the usage of the 6
8588               * octets header. If the bit is set to '0' (usually the case) the 20-octet header is used.
8589               * For all other versions of GTP', this bit is not used and is set to '0'. However,
8590               * this does not suggest the use of the 20-octet header, rather a shorter 6-octet header.
8591               */
8592             if (gtp_version == 0) {
8593                 proto_tree_add_bitmask_value_with_flags(gtp_tree, tvb, offset, hf_gtp_flags,
8594                     ett_gtp_flags, gtp_prime_v0_flags, gtp_hdr->flags, BMT_NO_APPEND);
8595             } else {
8596                 proto_tree_add_bitmask_value_with_flags(gtp_tree, tvb, offset, hf_gtp_flags,
8597                     ett_gtp_flags, gtp_prime_flags, gtp_hdr->flags, BMT_NO_APPEND);
8598             }
8599         } else {
8600             const int * gtp_flags[] = {
8601                 &hf_gtp_flags_ver,
8602                 &hf_gtp_flags_pt,
8603                 &hf_gtp_flags_spare2,
8604                 &hf_gtp_flags_e,
8605                 &hf_gtp_flags_s,
8606                 &hf_gtp_flags_pn,
8607                 NULL
8608             };
8609             const int * gtp_v0_flags[] = {
8610                 &hf_gtp_flags_ver,
8611                 &hf_gtp_flags_pt,
8612                 &hf_gtp_flags_spare1,
8613                 &hf_gtp_flags_snn,
8614                 NULL
8615             };
8616             ti = proto_tree_add_item(tree, proto_gtp, tvb, 0, -1, ENC_NA);
8617             gtp_tree = proto_item_add_subtree(ti, ett_gtp);
8618
8619             if (gtp_version == 0) {
8620                 proto_tree_add_bitmask_value_with_flags(gtp_tree, tvb, offset, hf_gtp_flags,
8621                     ett_gtp_flags, gtp_v0_flags, gtp_hdr->flags, BMT_NO_APPEND);
8622             } else {
8623                 proto_tree_add_bitmask_value_with_flags(gtp_tree, tvb, offset, hf_gtp_flags,
8624                     ett_gtp_flags, gtp_flags, gtp_hdr->flags, BMT_NO_APPEND);
8625             }
8626         }
8627     }
8628     offset++;
8629
8630     gtp_hdr->message = tvb_get_guint8(tvb, offset);
8631     /* Link direction is needed to properly dissect PCO */
8632     switch(gtp_hdr->message){
8633         case GTP_MSG_DELETE_PDP_REQ:
8634         case GTP_MSG_UPDATE_PDP_REQ:
8635         case GTP_MSG_CREATE_PDP_REQ:
8636         case GTP_MSG_INIT_PDP_CONTEXT_ACT_REQ:
8637         case GTP_MSG_PDU_NOTIFY_REQ:
8638         case GTP_MSG_PDU_NOTIFY_REJ_REQ:
8639         case GTP_MSG_FORW_RELOC_REQ: /* direction added for UTRAN Container decode */
8640             pinfo->link_dir = P2P_DIR_UL;
8641             break;
8642         case GTP_MSG_DELETE_PDP_RESP:
8643         case GTP_MSG_UPDATE_PDP_RESP:
8644         case GTP_MSG_CREATE_PDP_RESP:
8645         case GTP_MSG_INIT_PDP_CONTEXT_ACT_RESP:
8646         case GTP_MSG_FORW_RELOC_RESP: /* direction added for UTRAN Container decode */
8647             pinfo->link_dir = P2P_DIR_DL;
8648             break;
8649     default:
8650         break;
8651     }
8652     col_set_str(pinfo->cinfo, COL_INFO, val_to_str_ext_const(gtp_hdr->message, &gtp_message_type_ext, "Unknown"));
8653     message_item = proto_tree_add_uint(gtp_tree, hf_gtp_message_type, tvb, offset, 1, gtp_hdr->message);
8654     offset++;
8655
8656     gtp_hdr->length = tvb_get_ntohs(tvb, offset);
8657     proto_tree_add_uint(gtp_tree, hf_gtp_length, tvb, 2, 2, gtp_hdr->length);
8658     offset += 2;
8659
8660     /* We initialize the sequence number*/
8661     has_SN = FALSE;
8662     if (gtp_prime) {
8663         seq_no = tvb_get_ntohs(tvb, offset);
8664         has_SN = TRUE;
8665         proto_tree_add_uint(gtp_tree, hf_gtp_seq_number, tvb, offset, 2, seq_no);
8666         offset += 2;
8667         /* If GTP' version is 0 and bit 1 is 0 20 bytes header is used, dissect it */
8668         if( (gtp_version == 0) && ((gtp_hdr->flags & 0x01) == 0) ) {
8669             proto_tree_add_item(gtp_tree, hf_gtp_dummy_octets, tvb, offset, 14, ENC_NA);
8670             offset += 14;
8671         }
8672
8673         set_actual_length(tvb, offset + gtp_hdr->length);
8674     } else {
8675         switch (gtp_version) {
8676         case 0:
8677             seq_no = tvb_get_ntohs(tvb, offset);
8678             has_SN = TRUE;
8679             proto_tree_add_uint(gtp_tree, hf_gtp_seq_number, tvb, offset, 2, seq_no);
8680             offset += 2;
8681
8682             flow_label = tvb_get_ntohs(tvb, offset);
8683             proto_tree_add_uint(gtp_tree, hf_gtp_flow_label, tvb, offset, 2, flow_label);
8684             offset += 2;
8685
8686             pdu_no = tvb_get_guint8(tvb, offset);
8687             proto_tree_add_uint(gtp_tree, hf_gtp_sndcp_number, tvb, offset, 1, pdu_no);
8688             offset += 4;
8689
8690             tid_str = id_to_str(tvb, offset);
8691             proto_tree_add_string(gtp_tree, hf_gtp_tid, tvb, offset, 8, tid_str);
8692             offset += 8;
8693
8694             set_actual_length(tvb, offset + gtp_hdr->length);
8695
8696             break;
8697         case 1:
8698             gtp_hdr->teid = tvb_get_ntohl(tvb, offset);
8699             proto_tree_add_item(gtp_tree, hf_gtp_teid, tvb, offset, 4, ENC_BIG_ENDIAN);
8700             offset += 4;
8701
8702             set_actual_length(tvb, offset + gtp_hdr->length);
8703
8704             /* Are sequence number/N-PDU Number/extension header present?
8705                See NOTE 5 of Figure 2 of 3GPP TS 29.060 version 4.3.0
8706                Release 4 - the Sequence Number, N-PDU Number, and
8707                Next Extension Header fields are present if any of
8708                GTP_E_MASK, GTP_S_MASK, or GTP_PN_MASK are set. */
8709             if (gtp_hdr->flags & (GTP_E_MASK|GTP_S_MASK|GTP_PN_MASK)) {
8710                 /* Those fields are only *interpreted* if the
8711                    particular flag for the field is set. */
8712                 if (gtp_hdr->flags & GTP_S_MASK) {
8713                     seq_no = tvb_get_ntohs(tvb, offset);
8714                     has_SN = TRUE;
8715                     proto_tree_add_uint(gtp_tree, hf_gtp_seq_number, tvb, offset, 2, seq_no);
8716                 }
8717                 offset += 2;
8718
8719                 if (gtp_hdr->flags & GTP_PN_MASK) {
8720                     pdu_no = tvb_get_guint8(tvb, offset);
8721                     proto_tree_add_uint(gtp_tree, hf_gtp_npdu_number, tvb, offset, 1, pdu_no);
8722                 }
8723                 offset++;
8724
8725                 if (gtp_hdr->flags & GTP_E_MASK) {
8726                     next_hdr = tvb_get_guint8(tvb, offset);
8727                     proto_tree_add_uint(gtp_tree, hf_gtp_ext_hdr_next, tvb, offset, 1, next_hdr);
8728                     offset++;
8729                     while (next_hdr != 0) {
8730                         ext_hdr_length = tvb_get_guint8(tvb, offset);
8731                         tf = proto_tree_add_item(gtp_tree, hf_gtp_ext_hdr, tvb, offset, ext_hdr_length*4, ENC_NA);
8732                         ext_tree = proto_item_add_subtree(tf, ett_gtp_ext_hdr);
8733                         ext_hdr_len_item = proto_tree_add_item(ext_tree, hf_gtp_ext_hdr_length, tvb, offset,1, ENC_BIG_ENDIAN);
8734                         if (ext_hdr_length == 0) {
8735                             expert_add_info_format(pinfo, ext_hdr_len_item, &ei_gtp_ext_length_mal,
8736                                                    "Extension header length is zero");
8737                             return tvb_reported_length(tvb);
8738                         }
8739                         offset++;
8740
8741                         switch (next_hdr) {
8742
8743                         case GTP_EXT_HDR_UDP_PORT:
8744                             /* UDP Port
8745                              * 3GPP 29.281 v9.0.0, 5.2.2.1 UDP Port
8746                              * "This extension header may be transmitted in
8747                              * Error Indication messages to provide the UDP
8748                              * Source Port of the G-PDU that triggered the
8749                              * Error Indication. It is 4 octets long, and
8750                              * therefore the Length field has value 1"
8751                              */
8752                             if (ext_hdr_length == 1) {
8753                                 /* UDP Port of source */
8754                                 proto_tree_add_item(ext_tree, hf_gtp_ext_hdr_udp_port, tvb, offset, 2, ENC_BIG_ENDIAN);
8755                             } else {
8756                                 /* Bad length */
8757                                 expert_add_info_format(pinfo, ext_tree, &ei_gtp_ext_length_warn, "The length field for the UDP Port Extension header should be 1.");
8758                             }
8759                             break;
8760
8761                         case GTP_EXT_HDR_RAN_CONT:
8762                             /* RAN Container
8763                              * 3GPP 29.281 v15.2.0, 5.2.2.4 RAN Container
8764                              * This extension header may be transmitted in
8765                              * a G-PDU over the X2 user plane interface
8766                              * between the eNBs. The RAN Container has a
8767                              * variable length and its content is specified
8768                              * in 3GPP TS 36.425 [25]. A G-PDU message with
8769                              * this extension header may be sent without a T-PDU.
8770                              */
8771                             proto_tree_add_item(ext_tree, hf_gtp_ext_hdr_ran_cont, tvb, offset, (4*ext_hdr_length)-1, ENC_NA);
8772                             break;
8773
8774                         case GTP_EXT_HDR_LONG_PDCP_PDU:
8775                             /* Long PDCP PDU Number
8776                              * 3GPP 29.281 v15.2.0, 5.2.2.2A Long PDCP PDU Number
8777                              * This extension header is used for direct X2 or
8778                              * indirect S1 DL data forwarding during a Handover
8779                              * procedure between two eNBs. The Long PDCP PDU number
8780                              * extension header is 8 octets long, and therefore
8781                              * the Length field has value 2.
8782                              * The PDCP PDU number field of the Long PDCP PDU number
8783                              * extension header has a maximum value which requires 18
8784                              * bits (see 3GPP TS 36.323 [24]). Bit 2 of octet 2 is
8785                              * the most significant bit and bit 1 of octet 4 is the
8786                              * least significant bit, see Figure 5.2.2.2A-1. Bits 8 to
8787                              * 3 of octet 2, and Bits 8 to 1 of octets 5 to 7 shall be
8788                              * set to 0.
8789                              * NOTE: A G-PDU which includes a PDCP PDU Number contains
8790                              * either the extension header PDCP PDU Number or Long PDCP
8791                              * PDU Number.
8792                              */
8793                             if (ext_hdr_length == 2) {
8794                                 proto_tree_add_bits_item(ext_tree, hf_gtp_ext_hdr_spare_bits, tvb, offset<<3, 6, ENC_BIG_ENDIAN);
8795                                 proto_tree_add_item(ext_tree, hf_gtp_ext_hdr_long_pdcp_sn, tvb, offset, 3, ENC_BIG_ENDIAN);
8796                                 proto_tree_add_item(ext_tree, hf_gtp_ext_hdr_spare_bytes, tvb, offset+3, 3, ENC_NA);
8797                             } else {
8798                                 expert_add_info_format(pinfo, ext_tree, &ei_gtp_ext_length_warn, "The length field for the Long PDCP SN Extension header should be 2.");
8799                             }
8800                             break;
8801
8802                         case GTP_EXT_HDR_XW_RAN_CONT:
8803                             /* Xw RAN Container
8804                              * 3GPP 29.281 v15.2.0, 5.2.2.5 Xw RAN Container
8805                              * This extension header may be transmitted in a
8806                              * G-PDU over the Xw user plane interface between
8807                              * the eNB and the WLAN Termination (WT). The Xw
8808                              * RAN Container has a variable length and its
8809                              * content is specified in 3GPP TS 36.464 [27].
8810                              * A G-PDU message with this extension header may
8811                              * be sent without a T-PDU.
8812                              */
8813                             proto_tree_add_item(ext_tree, hf_gtp_ext_hdr_xw_ran_cont, tvb, offset, (4*ext_hdr_length)-1, ENC_NA);
8814                             break;
8815
8816                         case GTP_EXT_HDR_NR_RAN_CONT:
8817                             /* NR RAN Container
8818                              * 3GPP 29.281 v15.2.0, 5.2.2.6 NR RAN Container
8819                              * This extension header may be transmitted in a
8820                              * G-PDU over the X2-U, Xn-U and F1-U user plane
8821                              * interfaces, within NG-RAN and, for EN-DC, within
8822                              * E-UTRAN. The NR RAN Container has a variable
8823                              * length and its content is specified in 3GPP TS
8824                              * 38.425 [30]. A G-PDU message with this extension
8825                              * header may be sent without a T-PDU.
8826                              */
8827                             proto_tree_add_item(ext_tree, hf_gtp_ext_hdr_nr_ran_cont, tvb, offset, (4*ext_hdr_length)-1, ENC_NA);
8828                             break;
8829
8830                         case GTP_EXT_HDR_PDU_SESSION_CONT:
8831                             /* PDU Session Container
8832                              * 3GPP 29.281 v15.2.0, 5.2.2.7 PDU Session Container
8833                              * This extension header may be transmitted in a G-PDU
8834                              * over the N3 and N9 user plane interfaces, between
8835                              * NG-RAN and UPF, or between two UPFs. The PDU Session
8836                              * Container has a variable length and its content is
8837                              * specified in 3GPP TS 38.415 [31].
8838                              */
8839                             proto_tree_add_item(ext_tree, hf_gtp_ext_hdr_pdu_session_cont, tvb, offset, (4*ext_hdr_length)-1, ENC_NA);
8840                             break;
8841
8842                         case GTP_EXT_HDR_PDCP_SN:
8843                             /* PDCP PDU
8844                              * 3GPP 29.281 v9.0.0, 5.2.2.2 PDCP PDU Number
8845                              *
8846                              * "This extension header is transmitted, for
8847                              * example in UTRAN, at SRNS relocation time,
8848                              * to provide the PDCP sequence number of not
8849                              * yet acknowledged N-PDUs. It is 4 octets long,
8850                              * and therefore the Length field has value 1.
8851                              *
8852                              * When used during a handover procedure between
8853                              * two eNBs at the X2 interface (direct DL data
8854                              * forwarding) or via the S1 interface (indirect
8855                              * DL data forwarding) in E-UTRAN, bit 8 of octet
8856                              * 2 is spare and shall be set to zero.
8857                              *
8858                              * Wireshark Note: TS 29.060 does not define bit
8859                              * 5-6 as spare, so no check is possible unless
8860                              * a preference is used.
8861                              */
8862                             /* First byte is length (should be 1) */
8863                             if (ext_hdr_length == 1) {
8864                                 proto_item* ext_item;
8865
8866                                 ext_hdr_pdcpsn = tvb_get_ntohs(tvb, offset);
8867                                 ext_item = proto_tree_add_item(ext_tree, hf_gtp_ext_hdr_pdcpsn, tvb, offset, 2, ENC_BIG_ENDIAN);
8868                                 if (ext_hdr_pdcpsn & 0x8000) {
8869                                     expert_add_info(pinfo, ext_item, &ei_gtp_ext_hdr_pdcpsn);
8870                                 }
8871                             } else {
8872                                 expert_add_info_format(pinfo, ext_tree, &ei_gtp_ext_length_warn, "The length field for the PDCP SN Extension header should be 1.");
8873                             }
8874                             break;
8875
8876                         case GTP_EXT_HDR_SUSPEND_REQ:
8877                             /* Suspend Request */
8878                             break;
8879
8880                         case GTP_EXT_HDR_SUSPEND_RESP:
8881                             /* Suspend Response */
8882                             break;
8883
8884                         default:
8885                             break;
8886                         }
8887                         offset += ext_hdr_length*4 - 2;
8888
8889                         next_hdr = tvb_get_guint8(tvb, offset);
8890                         proto_tree_add_uint(ext_tree, hf_gtp_ext_hdr_next, tvb, offset, 1, next_hdr);
8891                         offset++;
8892                     }
8893                 } else
8894                     offset++;
8895             }
8896             break;
8897         default:
8898             break;
8899         }
8900     }
8901
8902     if (gtp_hdr->message != GTP_MSG_TPDU) {
8903         /* Dissect IEs */
8904         mandatory = 0;      /* check order of GTP fields against ETSI */
8905         while (tvb_reported_length_remaining(tvb, offset) > 0) {
8906             ext_hdr_val = tvb_get_guint8(tvb, offset);
8907             if (g_gtp_etsi_order) {
8908                 checked_field = check_field_presence(gtp_hdr->message, ext_hdr_val, &mandatory);
8909                 switch (checked_field) {
8910                 case -2:
8911                     expert_add_info(pinfo, message_item, &ei_gtp_message_not_found);
8912                     break;
8913                 case -1:
8914                     expert_add_info(pinfo, message_item, &ei_gtp_field_not_present);
8915                     break;
8916                 case 0:
8917                     break;
8918                 default:
8919                     expert_add_info_format(pinfo, message_item, &ei_gtp_wrong_next_field, "[WARNING] wrong next field, should be: %s",
8920                                         val_to_str_ext_const(checked_field, &gtp_val_ext, "Unknown extension field"));
8921                     break;
8922                 }
8923             }
8924
8925             i = -1;
8926             while (gtpopt[++i].optcode)
8927                 if (gtpopt[i].optcode == ext_hdr_val)
8928                     break;
8929             offset = offset + (*gtpopt[i].decode) (tvb, offset, pinfo, gtp_tree, args);
8930         }
8931
8932         if (args && !PINFO_FD_VISITED(pinfo)) {
8933             /* We insert the lists inside the table*/
8934             fill_map(args->teid_list, args->ip_list, pinfo->num);
8935         }
8936         /*Use sequence number to track Req/Resp pairs*/
8937         if (has_SN) {
8938             guint8 cause_aux = 128; /* Cause accepted by default. Only used when args is NULL */
8939             if (args) {
8940                 cause_aux = args->last_cause;
8941             }
8942             gcrp = gtp_match_response(tvb, pinfo, gtp_tree, seq_no, gtp_hdr->message, gtp_info, cause_aux);
8943             /*pass packet to tap for response time reporting*/
8944             if (gcrp) {
8945                 tap_queue_packet(gtp_tap,pinfo,gcrp);
8946             }
8947         }
8948     }
8949     if (args) {
8950         track_gtp_session(tvb, pinfo, gtp_tree, gtp_hdr, args->teid_list, args->ip_list, args->last_teid, args->last_ip);
8951     }
8952     proto_item_set_end(ti, tvb, offset);
8953
8954     if ((gtp_hdr->message == GTP_MSG_TPDU) && dissect_tpdu_as == GTP_TPDU_AS_TPDU) {
8955         if(tvb_reported_length_remaining(tvb, offset) > 0){
8956             proto_tree_add_item(gtp_tree, hf_gtp_tpdu_data, tvb, offset, -1, ENC_NA);
8957
8958             sub_proto = tvb_get_guint8(tvb, offset);
8959
8960             if ((sub_proto >= 0x45) && (sub_proto <= 0x4e)) {
8961                 /* this is most likely an IPv4 packet
8962                 * we can exclude 0x40 - 0x44 because the minimum header size is 20 octets
8963                 * 0x4f is excluded because PPP protocol type "IPv6 header compression"
8964                 * with protocol field compression is more likely than a plain IPv4 packet with 60 octet header size */
8965
8966                 next_tvb = tvb_new_subset_remaining(tvb, offset);
8967                 call_dissector(ip_handle, next_tvb, pinfo, tree);
8968
8969             } else if ((sub_proto & 0xf0) == 0x60) {
8970                 /* this is most likely an IPv6 packet */
8971                 next_tvb = tvb_new_subset_remaining(tvb, offset);
8972                 call_dissector(ipv6_handle, next_tvb, pinfo, tree);
8973             } else {
8974                 /* this seems to be a PPP packet */
8975
8976                 if (sub_proto == 0xff) {
8977                     /* this might be an address field, even it shouldn't be here */
8978                     control_field = tvb_get_guint8(tvb, offset + 1);
8979                     if (control_field == 0x03)
8980                         /* now we are pretty sure that address and control field are mistakenly inserted -> ignore it for PPP dissection */
8981                         acfield_len = 2;
8982                 }
8983
8984                 next_tvb = tvb_new_subset_remaining(tvb, offset + acfield_len);
8985                 call_dissector(ppp_handle, next_tvb, pinfo, tree);
8986             }
8987         }
8988
8989         col_prepend_fstr(pinfo->cinfo, COL_PROTOCOL, "GTP <");
8990         col_append_str(pinfo->cinfo, COL_PROTOCOL, ">");
8991     }
8992     else if ((gtp_hdr->message == GTP_MSG_TPDU) && dissect_tpdu_as == GTP_TPDU_AS_SYNC) {
8993         next_tvb = tvb_new_subset_remaining(tvb, offset + acfield_len);
8994         call_dissector(sync_handle, next_tvb, pinfo, tree);
8995         col_prepend_fstr(pinfo->cinfo, COL_PROTOCOL, "GTP <");
8996         col_append_str(pinfo->cinfo, COL_PROTOCOL, ">");
8997     }
8998
8999     tap_queue_packet(gtpv1_tap,pinfo, gtp_hdr);
9000
9001     return tvb_reported_length(tvb);
9002 }
9003
9004 static int
9005 dissect_gtpprime(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree,
9006                 void *private_data _U_)
9007 {
9008     return dissect_gtp_common(tvb, pinfo, tree);
9009 }
9010
9011 static int
9012 dissect_gtp(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree,
9013             void *private_data _U_)
9014 {
9015     guint8 version;
9016
9017     /*
9018      * Do we have enough data to check the first byte?
9019      */
9020     if (!tvb_bytes_exist(tvb, 0, 1)) {
9021         /* No. */
9022         return 0;
9023     }
9024
9025     /*
9026      * If this is GTPv2-C call the gtpv2 dissector if present
9027      * Should this be moved to after the conversation stuff to retain that functionality for GTPv2 ???
9028      */
9029     version = tvb_get_guint8(tvb,0)>>5;
9030     if (version > 2) {
9031         /* Unknown version - reject the packet */
9032         return 0;
9033     }
9034     if (version == 2) {
9035         /* GTPv2-C 3GPP TS 29.274 */
9036         if (gtpv2_handle) {
9037             call_dissector(gtpv2_handle, tvb, pinfo, tree);
9038             return tvb_reported_length(tvb);
9039         }
9040     }
9041
9042     return dissect_gtp_common(tvb, pinfo, tree);
9043 }
9044
9045 static void
9046 gtp_init(void)
9047 {
9048     gtp_session_count = 1;
9049     session_table = g_hash_table_new(g_int_hash, g_int_equal);
9050     frame_tree = wmem_tree_new(wmem_file_scope());
9051 }
9052
9053 static void
9054 gtp_cleanup(void)
9055 {
9056     gtp_conv_info_t *gtp_info;
9057
9058     /* Free up state attached to the gtp_info structures */
9059     for (gtp_info = gtp_info_items; gtp_info != NULL; ) {
9060         gtp_conv_info_t *next;
9061
9062         g_hash_table_destroy(gtp_info->matched);
9063         gtp_info->matched=NULL;
9064         g_hash_table_destroy(gtp_info->unmatched);
9065         gtp_info->unmatched=NULL;
9066
9067         next = gtp_info->next;
9068         gtp_info = next;
9069     }
9070
9071     /* Free up state attached to the gtp session structures */
9072     gtp_info_items = NULL;
9073
9074     if (session_table != NULL) {
9075         g_hash_table_destroy(session_table);
9076     }
9077     session_table = NULL;
9078 }
9079
9080 void
9081 proto_register_gtp(void)
9082 {
9083     module_t *gtp_module;
9084     expert_module_t* expert_gtp;
9085     guint     i;
9086     guint     last_offset;
9087
9088     static hf_register_info hf_gtp[] = {
9089
9090         {&hf_gtp_ie_id,
9091          { "IE Id", "gtp.ie_id",
9092            FT_UINT8, BASE_DEC|BASE_EXT_STRING, &gtp_val_ext, 0x0,
9093            NULL, HFILL}
9094         },
9095         {&hf_gtp_response_in,
9096          { "Response In", "gtp.response_in",
9097            FT_FRAMENUM, BASE_NONE, NULL, 0x0,
9098            "The response to this GTP request is in this frame", HFILL}
9099         },
9100         {&hf_gtp_response_to,
9101          { "Response To", "gtp.response_to",
9102            FT_FRAMENUM, BASE_NONE, NULL, 0x0,
9103            "This is a response to the GTP request in this frame", HFILL}
9104         },
9105         {&hf_gtp_time,
9106          { "Time", "gtp.time",
9107            FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
9108            "The time between the Request and the Response", HFILL}
9109         },
9110         {&hf_gtp_apn,
9111          { "APN", "gtp.apn",
9112            FT_STRING, BASE_NONE, NULL, 0,
9113            "Access Point Name", HFILL}
9114         },
9115         {&hf_gtp_cause,
9116          { "Cause", "gtp.cause",
9117            FT_UINT8, BASE_DEC|BASE_EXT_STRING, &cause_type_ext, 0,
9118            "Cause of operation", HFILL}
9119         },
9120         {&hf_gtp_chrg_char,
9121          { "Charging characteristics", "gtp.chrg_char",
9122            FT_UINT16, BASE_DEC, NULL, 0,
9123            NULL, HFILL}
9124         },
9125         {&hf_gtp_chrg_char_s,
9126          { "Spare", "gtp.chrg_char_s",
9127            FT_UINT16, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_S,
9128            NULL, HFILL}
9129         },
9130         {&hf_gtp_chrg_char_n,
9131          { "Normal charging", "gtp.chrg_char_n",
9132            FT_UINT16, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_N,
9133            NULL, HFILL}
9134         },
9135         {&hf_gtp_chrg_char_p,
9136          { "Prepaid charging", "gtp.chrg_char_p",
9137            FT_UINT16, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_P,
9138            NULL, HFILL}
9139         },
9140         {&hf_gtp_chrg_char_f,
9141          { "Flat rate charging", "gtp.chrg_char_f",
9142            FT_UINT16, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_F,
9143            NULL, HFILL}
9144         },
9145         {&hf_gtp_chrg_char_h,
9146          { "Hot billing charging", "gtp.chrg_char_h",
9147            FT_UINT16, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_H,
9148            NULL, HFILL}
9149         },
9150         {&hf_gtp_chrg_char_r,
9151          { "Reserved", "gtp.chrg_char_r",
9152            FT_UINT16, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_R,
9153            NULL, HFILL}
9154         },
9155         {&hf_gtp_chrg_id,
9156          { "Charging ID", "gtp.chrg_id",
9157            FT_UINT32, BASE_HEX_DEC, NULL, 0,
9158            NULL, HFILL}
9159         },
9160         {&hf_gtp_chrg_ipv4,
9161          { "CG address IPv4", "gtp.chrg_ipv4",
9162            FT_IPv4, BASE_NONE, NULL, 0,
9163            "Charging Gateway address IPv4", HFILL}
9164         },
9165         {&hf_gtp_chrg_ipv6,
9166          { "CG address IPv6", "gtp.chrg_ipv6",
9167            FT_IPv6, BASE_NONE, NULL, 0,
9168            "Charging Gateway address IPv6", HFILL}
9169         },
9170         {&hf_gtp_ext_flow_label,
9171          { "Flow Label Data I", "gtp.ext_flow_label",
9172            FT_UINT16, BASE_HEX, NULL, 0,
9173            "Flow label data", HFILL}
9174         },
9175         {&hf_gtp_ext_id,
9176          { "Extension identifier", "gtp.ext_id",
9177            FT_UINT16, BASE_ENTERPRISES, STRINGS_ENTERPRISES, 0,
9178            "Private Enterprise number", HFILL}
9179         },
9180         {&hf_gtp_ext_val,
9181          { "Extension value", "gtp.ext_val",
9182            FT_BYTES, BASE_NONE, NULL, 0,
9183            NULL, HFILL}
9184         },
9185         {&hf_gtp_flags,
9186          { "Flags", "gtp.flags",
9187            FT_UINT8, BASE_HEX, NULL, 0,
9188            "Ver/PT/Spare...", HFILL}
9189         },
9190         {&hf_gtp_ext_hdr,
9191          { "Extension header", "gtp.ext_hdr",
9192            FT_NONE, BASE_NONE, NULL, 0,
9193            NULL, HFILL}
9194         },
9195         {&hf_gtp_ext_hdr_next,
9196          { "Next extension header type", "gtp.ext_hdr.next",
9197            FT_UINT8, BASE_HEX, VALS(next_extension_header_fieldvals), 0,
9198            NULL, HFILL}
9199         },
9200         {&hf_gtp_ext_hdr_ran_cont,
9201          { "RAN Container", "gtp.ext_hdr.ran_cont",
9202            FT_BYTES, BASE_NONE, NULL, 0,
9203            NULL, HFILL}
9204         },
9205         {&hf_gtp_ext_hdr_spare_bits,
9206          { "Spare", "gtp.ext_hdr.spare_bits",
9207            FT_UINT8, BASE_HEX, NULL, 0,
9208            NULL, HFILL}
9209         },
9210         {&hf_gtp_ext_hdr_spare_bytes,
9211          { "Spare", "gtp.ext_hdr.spare_bytes",
9212            FT_BYTES, BASE_NONE, NULL, 0,
9213            NULL, HFILL}
9214         },
9215         {&hf_gtp_ext_hdr_long_pdcp_sn,
9216          { "Long PDCP Sequence Number", "gtp.ext_hdr.long_pdcp_sn",
9217            FT_UINT24, BASE_DEC, NULL, 0,
9218            NULL, HFILL}
9219         },
9220         {&hf_gtp_ext_hdr_xw_ran_cont,
9221          { "Xw RAN Container", "gtp.ext_hdr.xw_ran_cont",
9222            FT_BYTES, BASE_NONE, NULL, 0,
9223            NULL, HFILL}
9224         },
9225         {&hf_gtp_ext_hdr_nr_ran_cont,
9226          { "NR RAN Container", "gtp.ext_hdr.nr_ran_cont",
9227            FT_BYTES, BASE_NONE, NULL, 0,
9228            NULL, HFILL}
9229         },
9230         {&hf_gtp_ext_hdr_pdu_session_cont,
9231          { "PDU Session Container", "gtp.ext_hdr.pdu_session_cont",
9232            FT_BYTES, BASE_NONE, NULL, 0,
9233            NULL, HFILL}
9234         },
9235         {&hf_gtp_ext_hdr_pdcpsn,
9236          { "PDCP Sequence Number", "gtp.ext_hdr.pdcp_sn",
9237            FT_UINT16, BASE_DEC, NULL, 0,
9238            NULL, HFILL}
9239         },
9240         {&hf_gtp_ext_hdr_udp_port,
9241          { "UDP Port", "gtp.ext_hdr.udp_port",
9242            FT_UINT16, BASE_DEC, NULL, 0,
9243            NULL, HFILL}
9244         },
9245         {&hf_gtp_ext_hdr_length,
9246          { "Extension Header Length", "gtp.ext_hdr.length",
9247            FT_UINT8, BASE_DEC, NULL, 0,
9248            NULL, HFILL}
9249         },
9250         {&hf_gtp_flags_ver,
9251          { "Version", "gtp.flags.version",
9252            FT_UINT8, BASE_DEC, VALS(ver_types), GTP_VER_MASK,
9253            "GTP Version", HFILL}
9254         },
9255         {&hf_gtp_prime_flags_ver,
9256          { "Version", "gtp.prim.flags.version",
9257            FT_UINT8, BASE_DEC,NULL, GTP_VER_MASK,
9258            "GTP' Version", HFILL}
9259         },
9260         {&hf_gtp_flags_pt,
9261          { "Protocol type", "gtp.flags.payload",
9262            FT_UINT8, BASE_DEC, VALS(pt_types), GTP_PT_MASK,
9263            NULL, HFILL}
9264         },
9265         {&hf_gtp_flags_spare1,
9266          { "Reserved", "gtp.flags.reserved",
9267            FT_UINT8, BASE_DEC, NULL, GTP_SPARE1_MASK,
9268            "Reserved (shall be sent as '111' )", HFILL}
9269         },
9270         {&hf_gtp_flags_hdr_length,
9271          { "Header length", "gtp.flags.hdr_length",
9272            FT_BOOLEAN, 8,  TFS(&gtp_hdr_length_vals), 0x01,
9273            NULL, HFILL}
9274         },
9275         {&hf_gtp_flags_snn,
9276          { "Is SNDCP N-PDU included?", "gtp.flags.snn",
9277            FT_BOOLEAN, 8, TFS(&tfs_yes_no), GTP_SNN_MASK,
9278            "Is SNDCP N-PDU LLC Number included? (1 = yes, 0 = no)", HFILL}
9279         },
9280         {&hf_gtp_flags_spare2,
9281          { "Reserved", "gtp.flags.reserved",
9282            FT_UINT8, BASE_DEC, NULL, GTP_SPARE2_MASK,
9283            "Reserved (shall be sent as '1' )", HFILL}
9284         },
9285         {&hf_gtp_flags_e,
9286          { "Is Next Extension Header present?", "gtp.flags.e",
9287            FT_BOOLEAN, 8, TFS(&tfs_yes_no), GTP_E_MASK,
9288            "Is Next Extension Header present? (1 = yes, 0 = no)", HFILL}
9289         },
9290         {&hf_gtp_flags_s,
9291          { "Is Sequence Number present?", "gtp.flags.s",
9292            FT_BOOLEAN, 8, TFS(&tfs_yes_no), GTP_S_MASK,
9293            "Is Sequence Number present? (1 = yes, 0 = no)", HFILL}
9294         },
9295         {&hf_gtp_flags_pn,
9296          { "Is N-PDU number present?", "gtp.flags.pn",
9297            FT_BOOLEAN, 8, TFS(&tfs_yes_no), GTP_PN_MASK,
9298            "Is N-PDU number present? (1 = yes, 0 = no)", HFILL}
9299         },
9300         {&hf_gtp_flow_ii,
9301          { "Flow Label Data II", "gtp.flow_ii",
9302            FT_UINT16, BASE_DEC, NULL, 0,
9303            "Downlink flow label data", HFILL}
9304         },
9305         {&hf_gtp_flow_label,
9306          { "Flow label", "gtp.flow_label",
9307            FT_UINT16, BASE_HEX, NULL, 0,
9308            NULL, HFILL}
9309         },
9310         {&hf_gtp_flow_sig,
9311          { "Flow label Signalling", "gtp.flow_sig",
9312            FT_UINT16, BASE_HEX, NULL, 0,
9313            NULL, HFILL}
9314         },
9315         {&hf_gtp_gsn_addr_len,
9316          { "GSN Address Length", "gtp.gsn_addr_len",
9317            FT_UINT8, BASE_DEC, NULL, GTP_EXT_GSN_ADDR_LEN_MASK,
9318            NULL, HFILL}
9319         },
9320         {&hf_gtp_gsn_addr_type,
9321          { "GSN Address Type", "gtp.gsn_addr_type",
9322            FT_UINT8, BASE_DEC, VALS(gsn_addr_type), GTP_EXT_GSN_ADDR_TYPE_MASK,
9323            NULL, HFILL}
9324         },
9325         {&hf_gtp_gsn_ipv4,
9326          { "GSN address IPv4", "gtp.gsn_ipv4",
9327            FT_IPv4, BASE_NONE, NULL, 0,
9328            NULL, HFILL}
9329         },
9330         {&hf_gtp_gsn_ipv6,
9331          { "GSN address IPv6", "gtp.gsn_ipv6",
9332            FT_IPv6, BASE_NONE, NULL, 0,
9333            NULL, HFILL}
9334         },
9335         {&hf_gtp_length,
9336          { "Length", "gtp.length",
9337            FT_UINT16, BASE_DEC, NULL, 0,
9338            "Length (i.e. number of octets after TID or TEID)", HFILL}
9339         },
9340         {&hf_gtp_map_cause,
9341          { "MAP cause", "gtp.map_cause",
9342            FT_UINT8, BASE_DEC, VALS(gsm_old_GSMMAPLocalErrorcode_vals), 0,
9343            NULL, HFILL}
9344         },
9345         {&hf_gtp_message_type,
9346          { "Message Type", "gtp.message",
9347            FT_UINT8, BASE_HEX|BASE_EXT_STRING, &gtp_message_type_ext, 0x0,
9348            "GTP Message Type", HFILL}
9349         },
9350         {&hf_gtp_ms_reason,
9351          { "MS not reachable reason", "gtp.ms_reason",
9352            FT_UINT8, BASE_DEC, VALS(ms_not_reachable_type), 0,
9353            NULL, HFILL}
9354         },
9355         {&hf_gtp_ms_valid,
9356          { "MS validated", "gtp.ms_valid",
9357            FT_BOOLEAN, BASE_NONE, NULL, 0x0,
9358            NULL, HFILL}
9359         },
9360         {&hf_gtp_node_ipv4,
9361          { "Node address IPv4", "gtp.node_ipv4",
9362            FT_IPv4, BASE_NONE, NULL, 0,
9363            "Recommended node address IPv4", HFILL}
9364         },
9365         {&hf_gtp_node_ipv6,
9366          { "Node address IPv6", "gtp.node_ipv6",
9367            FT_IPv6, BASE_NONE, NULL, 0,
9368            "Recommended node address IPv6", HFILL}
9369         },
9370         {&hf_gtp_npdu_number,
9371          { "N-PDU Number", "gtp.npdu_number",
9372            FT_UINT8, BASE_HEX, NULL, 0,
9373            NULL, HFILL}
9374         },
9375         {&hf_gtp_nsapi,
9376          { "NSAPI", "gtp.nsapi",
9377            FT_UINT8, BASE_DEC, NULL, 0x0f,
9378            "Network layer Service Access Point Identifier", HFILL}
9379         },
9380         {&hf_gtp_qos_version,
9381          { "Version", "gtp.qos_version",
9382            FT_UINT8, BASE_HEX, NULL, 0,
9383            "Version of the QoS Profile", HFILL}
9384         },
9385         {&hf_gtp_qos_spare1,
9386          { "Spare", "gtp.qos_spare1",
9387            FT_UINT8, BASE_DEC, NULL, GTP_EXT_QOS_SPARE1_MASK,
9388            "Spare (shall be sent as '00' )", HFILL}
9389         },
9390         {&hf_gtp_qos_delay,
9391          { "QoS delay", "gtp.qos_delay",
9392            FT_UINT8, BASE_DEC, VALS(qos_delay_type), GTP_EXT_QOS_DELAY_MASK,
9393            "Quality of Service Delay Class", HFILL}
9394         },
9395         {&hf_gtp_qos_reliability,
9396          { "QoS reliability", "gtp.qos_reliability",
9397            FT_UINT8, BASE_DEC, VALS(qos_reliability_type), GTP_EXT_QOS_RELIABILITY_MASK,
9398            "Quality of Service Reliability Class", HFILL}
9399         },
9400         {&hf_gtp_qos_peak,
9401          { "QoS peak", "gtp.qos_peak",
9402            FT_UINT8, BASE_DEC, VALS(qos_peak_type), GTP_EXT_QOS_PEAK_MASK,
9403            "Quality of Service Peak Throughput", HFILL}
9404         },
9405         {&hf_gtp_qos_spare2,
9406          { "Spare", "gtp.qos_spare2",
9407            FT_UINT8, BASE_DEC, NULL, GTP_EXT_QOS_SPARE2_MASK,
9408            "Spare (shall be sent as 0)", HFILL}
9409         },
9410         {&hf_gtp_qos_precedence,
9411          { "QoS precedence", "gtp.qos_precedence",
9412            FT_UINT8, BASE_DEC, VALS(qos_precedence_type), GTP_EXT_QOS_PRECEDENCE_MASK,
9413            "Quality of Service Precedence Class", HFILL}
9414         },
9415         {&hf_gtp_qos_spare3,
9416          { "Spare", "gtp.qos_spare3",
9417            FT_UINT8, BASE_DEC, NULL, GTP_EXT_QOS_SPARE3_MASK,
9418            "Spare (shall be sent as '000' )", HFILL}
9419         },
9420         {&hf_gtp_qos_mean,
9421          { "QoS mean", "gtp.qos_mean",
9422            FT_UINT8, BASE_DEC|BASE_EXT_STRING, &qos_mean_type_ext, GTP_EXT_QOS_MEAN_MASK,
9423            "Quality of Service Mean Throughput", HFILL}
9424         },
9425         {&hf_gtp_qos_al_ret_priority,
9426          { "Allocation/Retention priority", "gtp.qos_al_ret_priority",
9427            FT_UINT8, BASE_DEC, NULL, 0,
9428            NULL, HFILL}
9429         },
9430         {&hf_gtp_qos_traf_class,
9431          { "Traffic class", "gtp.qos_traf_class",
9432            FT_UINT8, BASE_DEC, VALS(qos_traf_class), GTP_EXT_QOS_TRAF_CLASS_MASK,
9433            NULL, HFILL}
9434         },
9435         {&hf_gtp_qos_del_order,
9436          { "Delivery order", "gtp.qos_del_order",
9437            FT_UINT8, BASE_DEC, VALS(qos_del_order), GTP_EXT_QOS_DEL_ORDER_MASK,
9438            NULL, HFILL}
9439         },
9440         {&hf_gtp_qos_del_err_sdu,
9441          { "Delivery of erroneous SDU", "gtp.qos_del_err_sdu",
9442            FT_UINT8, BASE_DEC, VALS(qos_del_err_sdu), GTP_EXT_QOS_DEL_ERR_SDU_MASK,
9443            NULL, HFILL}
9444         },
9445         {&hf_gtp_qos_max_sdu_size,
9446          { "Maximum SDU size", "gtp.qos_max_sdu_size",
9447            FT_UINT8, BASE_DEC, VALS(qos_max_sdu_size), 0,
9448            NULL, HFILL}
9449         },
9450         {&hf_gtp_qos_max_ul,
9451          { "Maximum bit rate for uplink", "gtp.qos_max_ul",
9452            FT_UINT8, BASE_DEC, VALS(qos_max_ul), 0,
9453            NULL, HFILL}
9454         },
9455         {&hf_gtp_qos_max_dl,
9456          { "Maximum bit rate for downlink", "gtp.qos_max_dl",
9457            FT_UINT8, BASE_DEC, VALS(qos_max_dl), 0,
9458            NULL, HFILL}
9459         },
9460         {&hf_gtp_qos_res_ber,
9461          { "Residual BER", "gtp.qos_res_ber",
9462            FT_UINT8, BASE_DEC, VALS(qos_res_ber), GTP_EXT_QOS_RES_BER_MASK,
9463            "Residual Bit Error Rate", HFILL}
9464         },
9465         {&hf_gtp_qos_sdu_err_ratio,
9466          { "SDU Error ratio", "gtp.qos_sdu_err_ratio",
9467            FT_UINT8, BASE_DEC, VALS(qos_sdu_err_ratio), GTP_EXT_QOS_SDU_ERR_RATIO_MASK,
9468            NULL,
9469            HFILL}
9470         },
9471         {&hf_gtp_qos_trans_delay,
9472          { "Transfer delay", "gtp.qos_trans_delay",
9473            FT_UINT8, BASE_DEC|BASE_EXT_STRING, &qos_trans_delay_ext, GTP_EXT_QOS_TRANS_DELAY_MASK,
9474            NULL, HFILL}
9475         },
9476         {&hf_gtp_qos_traf_handl_prio,
9477          { "Traffic handling priority", "gtp.qos_traf_handl_prio",
9478            FT_UINT8, BASE_DEC, VALS(qos_traf_handl_prio), GTP_EXT_QOS_TRAF_HANDL_PRIORITY_MASK,
9479            NULL, HFILL}
9480         },
9481         {&hf_gtp_qos_guar_ul,
9482          { "Guaranteed bit rate for uplink", "gtp.qos_guar_ul",
9483            FT_UINT8, BASE_DEC, VALS(qos_guar_ul), 0,
9484            NULL, HFILL}
9485         },
9486         {&hf_gtp_qos_guar_dl,
9487          { "Guaranteed bit rate for downlink", "gtp.qos_guar_dl",
9488            FT_UINT8, BASE_DEC, VALS(qos_guar_dl), 0,
9489            NULL, HFILL}
9490         },
9491         {&hf_gtp_qos_spare4,
9492          { "Spare", "gtp.qos_spare4",
9493            FT_UINT8, BASE_DEC, NULL, GTP_EXT_QOS_SPARE4_MASK,
9494            "Spare (shall be sent as '000' )", HFILL}
9495         },
9496         {&hf_gtp_qos_sig_ind,
9497          { "Signalling Indication", "gtp.sig_ind",
9498            FT_BOOLEAN, 8, TFS(&gtp_sig_ind), GTP_EXT_QOS_SIG_IND_MASK,
9499            NULL, HFILL}
9500         },
9501         {&hf_gtp_qos_src_stat_desc,
9502          { "Source Statistics Descriptor", "gtp.src_stat_desc",
9503            FT_UINT8, BASE_DEC, VALS(src_stat_desc_vals), GTP_EXT_QOS_SRC_STAT_DESC_MASK,
9504            NULL, HFILL}
9505         },
9506         { &hf_gtp_qos_arp,
9507           {"Allocation/Retention Priority", "gtp.qos_arp",
9508           FT_UINT16, BASE_HEX, NULL, 0x0,
9509           NULL, HFILL}
9510         },
9511         { &hf_gtp_qos_arp_pci,
9512           {"Pre-emption Capability (PCI)", "gtp.qos_arp_pci",
9513           FT_BOOLEAN, 16, TFS(&tfs_disabled_enabled), 0x40,
9514           NULL, HFILL}
9515         },
9516         { &hf_gtp_qos_arp_pl,
9517           {"Priority Level", "gtp.qos_arp_pl",
9518           FT_UINT16, BASE_DEC, NULL, 0x3c,
9519           NULL, HFILL}
9520         },
9521         { &hf_gtp_qos_arp_pvi,
9522           {"Pre-emption Vulnerability (PVI)", "gtp.qos_arp_pvi",
9523           FT_BOOLEAN, 16, TFS(&tfs_disabled_enabled), 0x01,
9524           NULL, HFILL}
9525         },
9526         {&hf_gtp_qos_qci,
9527          {"QCI", "gtp.qos_qci",
9528           FT_UINT8, BASE_DEC, NULL, 0x0,
9529           NULL, HFILL}
9530         },
9531         {&hf_gtp_qos_ul_mbr,
9532          {"Uplink Maximum Bit Rate", "gtp.qos_ul_mbr",
9533           FT_UINT64, BASE_DEC, NULL, 0x0,
9534           NULL, HFILL}
9535         },
9536         {&hf_gtp_qos_dl_mbr,
9537          {"Downlink Maximum Bit Rate", "gtp.qos_dl_mbr",
9538           FT_UINT64, BASE_DEC, NULL, 0x0,
9539           NULL, HFILL}
9540         },
9541         {&hf_gtp_qos_ul_gbr,
9542          {"Uplink Guaranteed Bit Rate", "gtp.qos_ul_gbr",
9543           FT_UINT64, BASE_DEC, NULL, 0x0,
9544           NULL, HFILL}
9545         },
9546         {&hf_gtp_qos_dl_gbr,
9547          {"Downlink Guaranteed Bit Rate", "gtp.qos_dl_gbr",
9548           FT_UINT64, BASE_DEC, NULL, 0x0,
9549           NULL, HFILL}
9550         },
9551         {&hf_gtp_qos_ul_apn_ambr,
9552          {"Uplink APN Aggregate Maximum Bit Rate", "gtp.qos_ul_apn_ambr",
9553           FT_UINT32, BASE_DEC, NULL, 0x0,
9554           NULL, HFILL}
9555         },
9556         {&hf_gtp_qos_dl_apn_ambr,
9557          {"Downlink APN Aggregate Maximum Bit Rate", "gtp.qos_dl_apn_ambr",
9558           FT_UINT32, BASE_DEC, NULL, 0x0,
9559           NULL, HFILL}
9560         },
9561         {&hf_gtp_pkt_flow_id,
9562          { "Packet Flow ID", "gtp.pkt_flow_id",
9563            FT_UINT8, BASE_DEC, NULL, 0,
9564            NULL, HFILL}
9565         },
9566         {&hf_gtp_ptmsi,
9567          { "P-TMSI", "gtp.ptmsi",
9568            FT_UINT32, BASE_HEX, NULL, 0,
9569            "Packet-Temporary Mobile Subscriber Identity", HFILL}
9570         },
9571         {&hf_gtp_ptmsi_sig,
9572          { "P-TMSI Signature", "gtp.ptmsi_sig",
9573            FT_UINT24, BASE_HEX, NULL, 0,
9574            NULL, HFILL}
9575         },
9576         {&hf_gtp_rab_gtpu_dn,
9577          { "Downlink GTP-U seq number", "gtp.rab_gtp_dn",
9578            FT_UINT16, BASE_DEC, NULL, 0,
9579            "Downlink GTP-U sequence number", HFILL}
9580         },
9581         {&hf_gtp_rab_gtpu_up,
9582          { "Uplink GTP-U seq number", "gtp.rab_gtp_up",
9583            FT_UINT16, BASE_DEC, NULL, 0,
9584            "Uplink GTP-U sequence number", HFILL}
9585         },
9586         {&hf_gtp_rab_pdu_dn,
9587          { "Downlink next PDCP-PDU seq number", "gtp.rab_pdu_dn",
9588            FT_UINT16, BASE_DEC, NULL, 0,
9589            "Downlink next PDCP-PDU sequence number", HFILL}
9590         },
9591         {&hf_gtp_rab_pdu_up,
9592          { "Uplink next PDCP-PDU seq number", "gtp.rab_pdu_up",
9593            FT_UINT16, BASE_DEC, NULL, 0,
9594            "Uplink next PDCP-PDU sequence number", HFILL}
9595         },
9596         {&hf_gtp_uli_geo_loc_type,
9597          { "Geographic Location Type", "gtp.geo_loc_type",
9598            FT_UINT8, BASE_DEC, VALS(geographic_location_type),  0,
9599            NULL, HFILL}
9600         },
9601         {&hf_gtp_cgi_ci,
9602          { "Cell ID (CI)", "gtp.cgi_ci",
9603            FT_UINT8, BASE_DEC, NULL, 0,
9604            NULL, HFILL}
9605         },
9606         {&hf_gtp_sai_sac,
9607          { "Service Area Code (SAC)", "gtp.sai_sac",
9608            FT_UINT8, BASE_DEC, NULL, 0,
9609            NULL, HFILL}
9610         },
9611         {&hf_gtp_rai_rac,
9612          { "Routing Area Code (RAC)", "gtp.rai_rac",
9613            FT_UINT8, BASE_DEC, NULL, 0,
9614            NULL, HFILL}
9615         },
9616         {&hf_gtp_lac,
9617          { "Location Area Code (LAC)", "gtp.lac",
9618            FT_UINT16, BASE_DEC, NULL, 0,
9619            NULL, HFILL}
9620         },
9621         { &hf_gtp_tac,
9622           {"TAC", "gtp.tac",
9623            FT_UINT16, BASE_DEC, NULL, 0,
9624            NULL, HFILL}
9625         },
9626         { &hf_gtp_eci,
9627           {"ECI", "gtp.eci",
9628            FT_UINT32, BASE_DEC, NULL, 0x0FFFFFFF,
9629            "E-UTRAN Cell Identifier", HFILL}
9630         },
9631         {&hf_gtp_ranap_cause,
9632          { "RANAP cause", "gtp.ranap_cause",
9633            FT_UINT8, BASE_DEC|BASE_EXT_STRING, &ranap_cause_type_ext, 0,
9634            NULL, HFILL}
9635         },
9636         {&hf_gtp_recovery,
9637          { "Recovery", "gtp.recovery",
9638            FT_UINT8, BASE_DEC, NULL, 0,
9639            "Restart counter", HFILL}
9640         },
9641         {&hf_gtp_reorder,
9642          { "Reordering required", "gtp.reorder",
9643            FT_BOOLEAN, BASE_NONE, NULL, 0x0,
9644            NULL, HFILL}
9645         },
9646         {&hf_gtp_rnc_ipv4,
9647          { "RNC address IPv4", "gtp.rnc_ipv4",
9648            FT_IPv4, BASE_NONE, NULL, 0,
9649            "Radio Network Controller address IPv4", HFILL}
9650         },
9651         {&hf_gtp_rnc_ipv6,
9652          { "RNC address IPv6", "gtp.rnc_ipv6",
9653            FT_IPv6, BASE_NONE, NULL, 0,
9654            "Radio Network Controller address IPv6", HFILL}
9655         },
9656         {&hf_gtp_rp,
9657          { "Radio Priority", "gtp.rp",
9658            FT_UINT8, BASE_DEC, NULL, GTPv1_EXT_RP_MASK,
9659            "Radio Priority for uplink tx", HFILL}
9660         },
9661         {&hf_gtp_rp_nsapi,
9662          { "NSAPI in Radio Priority", "gtp.rp_nsapi",
9663            FT_UINT8, BASE_DEC, NULL, GTPv1_EXT_RP_NSAPI_MASK,
9664            "Network layer Service Access Point Identifier in Radio Priority", HFILL}
9665         },
9666         {&hf_gtp_rp_sms,
9667          { "Radio Priority SMS", "gtp.rp_sms",
9668            FT_UINT8, BASE_DEC, NULL, 0,
9669            "Radio Priority for MO SMS", HFILL}
9670         },
9671         {&hf_gtp_rp_spare,
9672          { "Reserved", "gtp.rp_spare",
9673            FT_UINT8, BASE_DEC, NULL, GTPv1_EXT_RP_SPARE_MASK,
9674            "Spare bit", HFILL}
9675         },
9676         {&hf_gtp_sel_mode,
9677          { "Selection mode", "gtp.sel_mode",
9678            FT_UINT8, BASE_DEC, VALS(sel_mode_type), 0x03,
9679            NULL, HFILL}
9680         },
9681         {&hf_gtp_seq_number,
9682          { "Sequence number", "gtp.seq_number",
9683            FT_UINT16, BASE_HEX_DEC, NULL, 0,
9684            NULL, HFILL}
9685         },
9686         { &hf_gtp_session,
9687         { "Session", "gtp.session",
9688         FT_UINT32, BASE_DEC, NULL, 0,
9689         NULL, HFILL }
9690         },
9691         {&hf_gtp_sndcp_number,
9692          { "SNDCP N-PDU LLC Number", "gtp.sndcp_number",
9693            FT_UINT8, BASE_HEX, NULL, 0,
9694            NULL, HFILL}
9695         },
9696         {&hf_gtp_tear_ind,
9697          { "Teardown Indicator", "gtp.tear_ind",
9698            FT_BOOLEAN, BASE_NONE, NULL, 0x0,
9699            NULL, HFILL}
9700         },
9701         {&hf_gtp_teid,
9702          { "TEID", "gtp.teid",
9703            FT_UINT32, BASE_HEX_DEC, NULL, 0,
9704            "Tunnel Endpoint Identifier", HFILL}
9705         },
9706         {&hf_gtp_teid_cp,
9707          { "TEID Control Plane", "gtp.teid_cp",
9708            FT_UINT32, BASE_HEX_DEC, NULL, 0,
9709            "Tunnel Endpoint Identifier Control Plane", HFILL}
9710         },
9711         {&hf_gtp_ulink_teid_cp,
9712          { "Uplink TEID Control Plane", "gtp.ulink_teid_cp",
9713            FT_UINT32, BASE_HEX_DEC, NULL, 0,
9714            "Uplink Tunnel Endpoint Identifier Control Plane", HFILL}
9715         },
9716         {&hf_gtp_teid_data,
9717          { "TEID Data I", "gtp.teid_data",
9718            FT_UINT32, BASE_HEX_DEC, NULL, 0,
9719            "Tunnel Endpoint Identifier Data I", HFILL}
9720         },
9721         {&hf_gtp_ulink_teid_data,
9722          { "Uplink TEID Data I", "gtp.ulink_teid_data",
9723            FT_UINT32, BASE_HEX_DEC, NULL, 0,
9724            "UplinkTunnel Endpoint Identifier Data I", HFILL}
9725         },
9726         {&hf_gtp_teid_ii,
9727          { "TEID Data II", "gtp.teid_ii",
9728            FT_UINT32, BASE_HEX_DEC, NULL, 0,
9729            "Tunnel Endpoint Identifier Data II", HFILL}
9730         },
9731         {&hf_gtp_tid,
9732          { "TID", "gtp.tid",
9733            FT_STRING, BASE_NONE, NULL, 0,
9734            "Tunnel Identifier", HFILL}
9735         },
9736         {&hf_gtp_tlli,
9737          { "TLLI", "gtp.tlli",
9738            FT_UINT32, BASE_HEX, NULL, 0,
9739            "Temporary Logical Link Identity", HFILL}
9740         },
9741         {&hf_gtp_tr_comm,
9742          { "Packet transfer command", "gtp.tr_comm",
9743            FT_UINT8, BASE_DEC, VALS(tr_comm_type), 0,
9744            NULL, HFILL}
9745         },
9746         {&hf_gtp_trace_ref,
9747          { "Trace reference", "gtp.trace_ref",
9748            FT_UINT16, BASE_HEX, NULL, 0,
9749            NULL, HFILL}
9750         },
9751         {&hf_gtp_trace_type,
9752          { "Trace type", "gtp.trace_type",
9753            FT_UINT16, BASE_HEX, NULL, 0,
9754            NULL, HFILL}
9755         },
9756         {&hf_gtp_user_addr_pdp_org,
9757          { "PDP type organization", "gtp.user_addr_pdp_org",
9758            FT_UINT8, BASE_DEC, VALS(pdp_org_type), 0,
9759            NULL, HFILL}
9760         },
9761         {&hf_gtp_user_addr_pdp_type,
9762          { "PDP type number", "gtp.user_addr_pdp_type",
9763            FT_UINT8, BASE_HEX, VALS(pdp_type), 0,
9764            NULL, HFILL}
9765         },
9766         {&hf_gtp_user_ipv4,
9767          { "End user address IPv4", "gtp.user_ipv4",
9768            FT_IPv4, BASE_NONE, NULL, 0,
9769            NULL, HFILL}
9770         },
9771         {&hf_gtp_user_ipv6,
9772          { "End user address IPv6", "gtp.user_ipv6",
9773            FT_IPv6, BASE_NONE, NULL, 0,
9774            NULL, HFILL}
9775         },
9776         {&hf_gtp_security_mode,
9777          { "Security Mode", "gtp.security_mode",
9778            FT_UINT8, BASE_DEC, VALS(mm_sec_modep), 0xc0,
9779            NULL, HFILL}
9780         },
9781         {&hf_gtp_no_of_vectors,
9782          { "No of Vectors", "gtp.no_of_vectors",
9783            FT_UINT8, BASE_DEC, NULL, 0x38,
9784            NULL, HFILL}
9785         },
9786         {&hf_gtp_cipher_algorithm,
9787          { "Cipher Algorithm", "gtp.cipher_algorithm",
9788            FT_UINT8, BASE_DEC, VALS(gtp_cipher_algorithm), 0x07,
9789            NULL, HFILL}
9790         },
9791         {&hf_gtp_cksn_ksi,
9792          { "Ciphering Key Sequence Number (CKSN)/Key Set Identifier (KSI)", "gtp.cksn_ksi",
9793            FT_UINT8, BASE_DEC, NULL, 0x07,
9794            "CKSN/KSI", HFILL}
9795         },
9796         {&hf_gtp_cksn,
9797          { "Ciphering Key Sequence Number (CKSN)", "gtp.cksn",
9798            FT_UINT8, BASE_DEC, NULL, 0x07,
9799            "CKSN", HFILL}
9800         },
9801         {&hf_gtp_ksi,
9802          { "Key Set Identifier (KSI)", "gtp.ksi",
9803            FT_UINT8, BASE_DEC, NULL, 0x07,
9804            "KSI", HFILL}
9805         },
9806         {&hf_gtp_ext_length,
9807          { "Length", "gtp.ext_length",
9808            FT_UINT16, BASE_DEC, NULL, 0x0,
9809            "IE Length", HFILL}
9810         },
9811         {&hf_gtp_utran_field,
9812          { "UTRAN Transparent Field", "gtp.utran_field",
9813            FT_BYTES, BASE_NONE, NULL, 0x0,
9814            NULL, HFILL}
9815         },
9816         {&hf_gtp_ext_apn_res,
9817          { "Restriction Type", "gtp.ext_apn_res",
9818            FT_UINT8, BASE_DEC, NULL, 0x0,
9819            NULL, HFILL}
9820         },
9821         {&hf_gtp_ext_rat_type,
9822          { "RAT Type", "gtp.ext_rat_type",
9823            FT_UINT8, BASE_DEC, VALS(gtp_ext_rat_type_vals), 0x0,
9824            NULL, HFILL}
9825         },
9826         {&hf_gtp_ext_imeisv,
9827          { "IMEI(SV)", "gtp.ext_imeisv",
9828            FT_STRING, BASE_NONE, NULL, 0x0,
9829            NULL, HFILL}
9830         },
9831         { &hf_gtp_target_rnc_id,
9832           { "targetRNC-ID", "gtp.targetRNC_ID",
9833             FT_UINT16, BASE_HEX, NULL, 0x0fff,
9834             NULL, HFILL }
9835         },
9836         { &hf_gtp_target_ext_rnc_id,
9837           { "Extended RNC-ID", "gtp.target_ext_RNC_ID",
9838             FT_UINT16, BASE_HEX, NULL, 0,
9839             NULL, HFILL }
9840         },
9841         {&hf_gtp_bssgp_cause,
9842          { "BSSGP Cause", "gtp.bssgp_cause",
9843            FT_UINT8, BASE_DEC|BASE_EXT_STRING, &bssgp_cause_vals_ext, 0,
9844            NULL, HFILL}
9845         },
9846         { &hf_gtp_bssgp_ra_discriminator,
9847           { "Routing Address Discriminator", "gtp.bssgp.rad",
9848             FT_UINT8, BASE_DEC, VALS(gtp_bssgp_ra_discriminator_vals), 0x0f,
9849             NULL, HFILL }
9850         },
9851         {&hf_gtp_sapi,
9852          { "PS Handover XID SAPI", "gtp.ps_handover_xid_sapi",
9853            FT_UINT8, BASE_DEC, NULL, 0x0F,
9854            "SAPI", HFILL}
9855         },
9856         {&hf_gtp_xid_par_len,
9857          { "PS Handover XID parameter length", "gtp.ps_handover_xid_par_len",
9858            FT_UINT8, BASE_DEC, NULL, 0xFF,
9859            "XID parameter length", HFILL}
9860         },
9861         {&hf_gtp_rep_act_type,
9862          { "Action", "gtp.ms_inf_chg_rep_act",
9863            FT_UINT8, BASE_DEC, VALS(chg_rep_act_type_vals), 0xFF,
9864            NULL, HFILL}
9865         },
9866         {&hf_gtp_correlation_id,
9867          { "Correlation-ID", "gtp.correlation_id",
9868            FT_UINT8, BASE_DEC, NULL, 0,
9869            NULL, HFILL}
9870         },
9871         {&hf_gtp_earp_pci,
9872          { "PCI Pre-emption Capability", "gtp.EARP_pre_emption_Capability",
9873            FT_BOOLEAN, 8, TFS(&tfs_disabled_enabled), 0x40,
9874            NULL, HFILL}
9875         },
9876         {&hf_gtp_earp_pl,
9877          { "PL Priority Level", "gtp.EARP_priority_level",
9878            FT_UINT8, BASE_DEC, NULL, 0x3C,
9879            NULL, HFILL}
9880         },
9881         {&hf_gtp_earp_pvi,
9882          { "PVI Pre-emption Vulnerability", "gtp.EARP_pre_emption_par_vulnerability",
9883            FT_BOOLEAN, 8, TFS(&tfs_disabled_enabled), 0x01,
9884            NULL, HFILL}
9885         },
9886         {&hf_gtp_ext_comm_flags_uasi,
9887          { "UASI", "gtp.ext_comm_flags_uasi",
9888            FT_BOOLEAN, 8, NULL, 0x80,
9889            NULL, HFILL}
9890         },
9891         {&hf_gtp_ext_comm_flags_II_pnsi,
9892          { "PNSI", "gtp.ext_comm_flags_II_pnsi",
9893            FT_UINT8, BASE_DEC, NULL, 0x01,
9894            NULL, HFILL}
9895         },
9896         {&hf_gtp_ext_comm_flags_II_dtci,
9897          { "DTCI", "gtp.ext_comm_flags_II_dtci",
9898            FT_BOOLEAN, 8, NULL, 0x02,
9899            NULL, HFILL}
9900         },
9901         {&hf_gtp_ext_comm_flags_II_pmtsmi,
9902          { "PMTSMI", "gtp.ext_comm_flags_II_pmtsmi",
9903            FT_UINT8, BASE_DEC, NULL, 0x04,
9904            NULL, HFILL}
9905         },
9906         {&hf_gtp_ext_comm_flags_II_spare,
9907          { "SPARE", "gtp.ext_comm_flags_II_spare",
9908            FT_UINT8, BASE_HEX, NULL, 0xF8,
9909            NULL, HFILL}
9910         },
9911         {&hf_gtp_cdr_app,
9912          { "Application Identifier", "gtp.cdr_app",
9913            FT_UINT8, BASE_DEC, NULL, 0xf0,
9914            NULL, HFILL}
9915         },
9916         { &hf_gtp_cdr_rel,
9917           { "Release Identifier", "gtp.cdr_rel",
9918             FT_UINT8, BASE_DEC, NULL, 0x0f,
9919             NULL, HFILL}
9920         },
9921         { &hf_gtp_cdr_ver,
9922           { "Version Identifier", "gtp.cdr_ver",
9923             FT_UINT8, BASE_DEC, NULL, 0x0,
9924             NULL, HFILL}
9925         },
9926         { &hf_gtp_cdr_length,
9927           { "Length", "gtp.cdr_length",
9928             FT_UINT16, BASE_DEC, NULL, 0x0,
9929             NULL, HFILL}
9930         },
9931         { &hf_gtp_cdr_context,
9932           { "Context", "gtp.cdr_context",
9933             FT_BYTES, BASE_NONE, NULL, 0x0,
9934             NULL, HFILL}
9935         },
9936         {&hf_gtp_cmn_flg_ppc,
9937          { "Prohibit Payload Compression", "gtp.cmn_flg.ppc",
9938            FT_BOOLEAN, 8, NULL, 0x01,
9939            NULL, HFILL}
9940         },
9941         {&hf_gtp_cmn_flg_mbs_srv_type,
9942          { "MBMS Service Type", "gtp.cmn_flg.mbs_srv_type",
9943            FT_BOOLEAN, 8, NULL, 0x02,
9944            NULL, HFILL}
9945         },
9946         {&hf_gtp_cmn_flg_mbs_ran_pcd_rdy,
9947          { "RAN Procedures Ready", "gtp.cmn_flg.mbs_ran_pcd_rdy",
9948            FT_BOOLEAN, 8, NULL, 0x04,
9949            NULL, HFILL}
9950         },
9951         {&hf_gtp_cmn_flg_mbs_cnt_inf,
9952          { "MBMS Counting Information", "gtp.cmn_flg.mbs_cnt_inf",
9953            FT_BOOLEAN, 8, NULL, 0x08,
9954            NULL, HFILL}
9955         },
9956         {&hf_gtp_cmn_flg_no_qos_neg,
9957          { "No QoS negotiation", "gtp.cmn_flg.no_qos_neg",
9958            FT_BOOLEAN, 8, NULL, 0x10,
9959            NULL, HFILL}
9960         },
9961         {&hf_gtp_cmn_flg_nrsn,
9962          { "NRSN bit field", "gtp.cmn_flg.nrsn",
9963            FT_BOOLEAN, 8, NULL, 0x20,
9964            NULL, HFILL}
9965         },
9966         {&hf_gtp_cmn_flg_upgrd_qos_sup,
9967          { "Upgrade QoS Supported", "gtp.cmn_flg.upgrd_qos_sup",
9968            FT_BOOLEAN, 8, NULL, 0x40,
9969            NULL, HFILL}
9970         },
9971         {&hf_gtp_cmn_flg_dual_addr_bearer_flg,
9972          { "Dual Address Bearer Flag", "gtp.cmn_flg.dual_addr_bearer_flg",
9973            FT_BOOLEAN, 8, NULL, 0x80,
9974            NULL, HFILL}
9975         },
9976         {&hf_gtp_tmgi,
9977          { "Temporary Mobile Group Identity (TMGI)", "gtp.tmgi",
9978            FT_BYTES, BASE_NONE, NULL, 0x0,
9979            NULL, HFILL}
9980         },
9981         {&hf_gtp_no_of_mbms_sa_codes,
9982          { "Number of MBMS service area codes", "gtp.no_of_mbms_sa_codes",
9983            FT_UINT8, BASE_DEC, NULL, 0x0,
9984            "Number N of MBMS service area codes", HFILL}
9985         },
9986
9987         {&hf_gtp_mbms_ses_dur_days,
9988          { "Estimated session duration days", "gtp.mbms_ses_dur_days",
9989            FT_UINT24, BASE_DEC, NULL, 0x00007F,
9990            NULL, HFILL}
9991         },
9992         {&hf_gtp_mbms_ses_dur_s,
9993          { "Estimated session duration seconds", "gtp.mbms_ses_dur_s",
9994            FT_UINT24, BASE_DEC, NULL, 0xFFFF80,
9995            NULL, HFILL}
9996         },
9997         {&hf_gtp_mbms_sa_code,
9998          { "MBMS service area code", "gtp.mbms_sa_code",
9999            FT_UINT16, BASE_DEC, NULL, 0x0,
10000            NULL, HFILL}
10001         },
10002         {&hf_gtp_mbs_2g_3g_ind,
10003          { "MBMS 2G/3G Indicator", "gtp.mbs_2g_3g_ind",
10004            FT_UINT8, BASE_DEC, VALS(gtp_mbs_2g_3g_ind_vals), 0x0,
10005            NULL, HFILL}
10006         },
10007         {&hf_gtp_time_2_dta_tr,
10008          { "Time to MBMS Data Transfer", "gtp.time_2_dta_tr",
10009            FT_UINT8, BASE_DEC, NULL, 0x0,
10010            NULL, HFILL}
10011         },
10012         { &hf_gtp_ext_ei,
10013           { "Error Indication (EI)", "gtp.ei",
10014             FT_UINT8, BASE_DEC, NULL, 0x04,
10015             NULL, HFILL}
10016         },
10017         {&hf_gtp_ext_gcsi,
10018          { "GPRS-CSI (GCSI)", "gtp.gcsi",
10019            FT_UINT8, BASE_DEC, NULL, 0x02,
10020            NULL, HFILL}
10021         },
10022         { &hf_gtp_ext_dti,
10023           { "Direct Tunnel Indicator (DTI)", "gtp.dti",
10024             FT_UINT8, BASE_DEC, NULL, 0x01,
10025             NULL, HFILL}
10026         },
10027         { &hf_gtp_ra_prio_lcs,
10028           { "Radio Priority LCS", "gtp.raplcs",
10029             FT_UINT8, BASE_DEC, NULL, 0x07,
10030             NULL, HFILL}
10031         },
10032         { &hf_gtp_bcm,
10033           { "Bearer Control Mode", "gtp.bcm",
10034             FT_UINT8, BASE_DEC, VALS(gtp_pdp_bcm_type_vals), 0,
10035             NULL, HFILL}
10036         },
10037         { &hf_gtp_fqdn,
10038           { "FQDN", "gtp.fqdn",
10039             FT_STRING, BASE_NONE, NULL, 0,
10040             "Fully Qualified Domain Name", HFILL}
10041         },
10042         { &hf_gtp_rim_routing_addr,
10043           { "RIM Routing Address value", "gtp.rim_routing_addr_val",
10044             FT_BYTES, BASE_NONE, NULL, 0,
10045             NULL, HFILL}
10046         },
10047         { &hf_gtp_mbms_flow_id,
10048           { "MBMS Flow Identifier", "gtp.mbms_flow_id",
10049             FT_BYTES, BASE_NONE, NULL, 0,
10050             NULL, HFILL}
10051         },
10052         { &hf_gtp_mbms_dist_indic,
10053           { "Distribution Indication", "gtp.mbms_dist_indic",
10054             FT_UINT8, BASE_DEC, VALS(gtp_mbms_dist_indic_vals), 0x03,
10055             NULL, HFILL}
10056         },
10057         { &hf_gtp_ext_apn_ambr_ul,
10058           { "APN-AMBR for Uplink", "gtp.apn_ambr_ul",
10059             FT_INT32, BASE_DEC|BASE_UNIT_STRING, &units_kbps, 0x0,
10060             NULL, HFILL}
10061         },
10062         { &hf_gtp_ext_apn_ambr_dl,
10063           { "APN-AMBR for Downlink", "gtp.apn_ambr_dl",
10064             FT_INT32, BASE_DEC|BASE_UNIT_STRING, &units_kbps, 0x0,
10065             NULL, HFILL}
10066         },
10067         { &hf_gtp_ext_sub_ue_ambr_ul,
10068           { "Subscribed UE-AMBR for Uplink", "gtp.sub_ue_ambr_ul",
10069             FT_INT32, BASE_DEC|BASE_UNIT_STRING, &units_kbps, 0x0,
10070             NULL, HFILL}
10071         },
10072         { &hf_gtp_ext_sub_ue_ambr_dl,
10073           { "Subscribed UE-AMBR for Downlink", "gtp.sub_ue_ambr_dl",
10074             FT_INT32, BASE_DEC|BASE_UNIT_STRING, &units_kbps, 0x0,
10075             NULL, HFILL}
10076         },
10077         { &hf_gtp_ext_auth_ue_ambr_ul,
10078           { "Authorized UE-AMBR for Uplink", "gtp.auth_ue_ambr_ul",
10079             FT_INT32, BASE_DEC|BASE_UNIT_STRING, &units_kbps, 0x0,
10080             NULL, HFILL}
10081         },
10082         { &hf_gtp_ext_auth_ue_ambr_dl,
10083           { "Authorized UE-AMBR for Downlink", "gtp.auth_ue_ambr_dl",
10084             FT_INT32, BASE_DEC|BASE_UNIT_STRING, &units_kbps, 0x0,
10085             NULL, HFILL}
10086         },
10087         { &hf_gtp_ext_auth_apn_ambr_ul,
10088           { "Authorized APN-AMBR for Uplink", "gtp.auth_apn_ambr_ul",
10089             FT_INT32, BASE_DEC|BASE_UNIT_STRING, &units_kbps, 0x0,
10090             NULL, HFILL}
10091         },
10092         { &hf_gtp_ext_auth_apn_ambr_dl,
10093           { "Authorized APN-AMBR for Downlink", "gtp.auth_apn_ambr_dl",
10094             FT_INT32, BASE_DEC|BASE_UNIT_STRING, &units_kbps, 0x0,
10095             NULL, HFILL}
10096         },
10097         { &hf_gtp_ext_ggsn_back_off_time_units,
10098           { "Timer unit", "gtp.ggsn_back_off_time_units",
10099             FT_UINT8, BASE_DEC, VALS(gtp_ggsn_back_off_time_units_vals), 0xe0,
10100             NULL, HFILL}
10101         },
10102         { &hf_gtp_ext_ggsn_back_off_timer,
10103           { "Timer value", "gtp.ggsn_back_off_timer",
10104             FT_UINT8, BASE_DEC, NULL, 0x1f,
10105             NULL, HFILL}
10106         },
10107         { &hf_gtp_higher_br_16mb_flg,
10108           { "Higher bitrates than 16 Mbps flag", "gtp.higher_br_16mb_flg",
10109             FT_UINT8, BASE_DEC, VALS(gtp_higher_br_16mb_flg_vals), 0x0,
10110             NULL, HFILL}
10111         },
10112         { &hf_gtp_max_mbr_apn_ambr_ul,
10113           { "Max MBR/APN-AMBR for uplink", "gtp.max_mbr_apn_ambr_ul",
10114             FT_UINT32, BASE_DEC, NULL, 0x0,
10115             NULL, HFILL}
10116         },
10117         { &hf_gtp_max_mbr_apn_ambr_dl,
10118           { "Max MBR/APN-AMBR for downlink", "gtp.max_mbr_apn_ambr_dl",
10119             FT_UINT32, BASE_DEC, NULL, 0x0,
10120             NULL, HFILL}
10121         },
10122
10123       { &hf_gtp_rand, { "RAND", "gtp.rand", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
10124       { &hf_gtp_sres, { "SRES", "gtp.sres", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
10125       { &hf_gtp_kc, { "Kc", "gtp.kc", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
10126       { &hf_gtp_xres_length, { "XRES length", "gtp.xres_length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10127       { &hf_gtp_xres, { "XRES", "gtp.xres", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
10128       { &hf_gtp_quintuplet_ciphering_key, { "Quintuplet Ciphering Key", "gtp.quintuplet_ciphering_key", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
10129       { &hf_gtp_quintuplet_integrity_key, { "Quintuplet Integrity Key", "gtp.quintuplet_integrity_key", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
10130       { &hf_gtp_authentication_length, { "Authentication length", "gtp.authentication_length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10131       { &hf_gtp_auth, { "AUTH", "gtp.auth", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
10132       { &hf_gtp_ciphering_key_ck, { "Ciphering key CK", "gtp.ciphering_key_ck", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
10133       { &hf_gtp_integrity_key_ik, { "Integrity key IK", "gtp.integrity_key_ik", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
10134       { &hf_gtp_quintuplets_length, { "Quintuplets length", "gtp.quintuplets_length", FT_UINT16, BASE_DEC_HEX, NULL, 0x0, NULL, HFILL }},
10135       { &hf_gtp_ciphering_key_kc, { "Ciphering key Kc", "gtp.ciphering_key_kc", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
10136       { &hf_gtp_container_length, { "Container length", "gtp.container_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10137       { &hf_gtp_extended_end_user_address, { "Extended End User Address", "gtp.extended_end_user_address", FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x80, NULL, HFILL }},
10138       { &hf_gtp_vplmn_address_allowed, { "VPLMN address allowed", "gtp.vplmn_address_allowed", FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x40, NULL, HFILL }},
10139       { &hf_gtp_activity_status_indicator, { "Activity Status Indicator", "gtp.activity_status_indicator", FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x20, NULL, HFILL }},
10140       { &hf_gtp_reordering_required, { "Reordering required", "gtp.reordering_required", FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x10, NULL, HFILL }},
10141       { &hf_gtp_pdp_cntxt_sapi, { "SAPI", "gtp.pdp_cntxt.sapi", FT_UINT8, BASE_DEC, NULL, 0x0F, NULL, HFILL }},
10142       { &hf_gtp_sequence_number_down, { "Sequence number down", "gtp.sequence_number_down", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10143       { &hf_gtp_sequence_number_up, { "Sequence number up", "gtp.sequence_number_up", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10144       { &hf_gtp_send_n_pdu_number, { "Send N-PDU number", "gtp.send_n_pdu_number", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10145       { &hf_gtp_receive_n_pdu_number, { "Receive N-PDU number", "gtp.receive_n_pdu_number", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10146       { &hf_gtp_uplink_flow_label_signalling, { "Uplink flow label signalling", "gtp.uplink_flow_label_signalling", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10147       { &hf_gtp_pdp_context_identifier, { "PDP context identifier", "gtp.pdp_context_identifier", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10148       { &hf_gtp_pdp_organization, { "PDP organization", "gtp.pdp_organization", FT_UINT8, BASE_DEC, VALS(pdp_type), 0x0F, NULL, HFILL }},
10149       { &hf_gtp_pdp_type, { "PDP type", "gtp.pdp_type", FT_UINT8, BASE_DEC, VALS(pdp_type), 0x0, NULL, HFILL }},
10150       { &hf_gtp_pdp_address_length, { "PDP address length", "gtp.pdp_address_length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10151       { &hf_gtp_pdp_address_ipv4, { "PDP address", "gtp.pdp_address.ipv4", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
10152       { &hf_gtp_pdp_address_ipv6, { "PDP address", "gtp.pdp_address.ipv6", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
10153       { &hf_gtp_ggsn_address_length, { "GGSN address length", "gtp.ggsn_address_length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10154       { &hf_gtp_ggsn_address_for_control_plane, { "GGSN Address for control plane", "gtp.ggsn_address_for_control_plane", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
10155       { &hf_gtp_ggsn_address_for_user_traffic, { "GGSN Address for User Traffic", "gtp.ggsn_address_for_user_traffic", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
10156       { &hf_gtp_ggsn_2_address_length, { "GGSN 2 address length", "gtp.ggsn_2_address_length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10157       { &hf_gtp_ggsn_2_address_ipv4, { "GGSN 2 address", "gtp.ggsn_2_address.ipv4", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
10158       { &hf_gtp_ggsn_2_address_ipv6, { "GGSN 2 address", "gtp.ggsn_2_address.ipv6", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
10159       { &hf_gtp_apn_length, { "APN length", "gtp.apn_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10160       { &hf_gtp_transaction_identifier, { "Transaction identifier", "gtp.transaction_identifier", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10161       { &hf_gtp_gsn_address_length, { "GSN address length", "gtp.gsn_address_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10162       { &hf_gtp_gsn_address_information_element_length, { "GSN address Information Element length", "gtp.gsn_address_information_element_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10163       { &hf_gtp_tft_length, { "TFT length", "gtp.tft_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10164       { &hf_gtp_rab_setup_length, { "RAB setup length", "gtp.rab_setup_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10165       { &hf_gtp_timezone, { "Timezone", "gtp.timezone", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10166       { &hf_gtp_timezone_dst, { "DST", "gtp.timezone_dst", FT_UINT8, BASE_DEC, VALS(daylight_saving_time_vals), 0x03, NULL, HFILL }},
10167       { &hf_gtp_rfsp_index, { "RFSP Index", "gtp.rfsp_index", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10168       { &hf_gtp_fqdn_length, { "FQDN length", "gtp.fqdn_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10169       { &hf_gtp_number_of_data_records, { "Number of data records", "gtp.number_of_data_records", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10170       { &hf_gtp_data_record_format, { "Data record format", "gtp.data_record_format", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10171       { &hf_gtp_node_address_length, { "Node address length", "gtp.node_address_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10172       { &hf_gtp_seq_num_released, { "Sequence number released", "gtp.seq_num_released", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10173       { &hf_gtp_seq_num_canceled, { "Sequence number cancelled", "gtp.seq_num_canceled", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10174       { &hf_gtp_requests_responded, { "Requests responded", "gtp.requests_responded", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10175       { &hf_gtp_hyphen_separator, { "Hyphen separator: -", "gtp.hyphen_separator", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
10176       { &hf_gtp_ms_network_cap_content_len, { "Length of MS network capability contents", "gtp.ms_network_cap_content_len", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10177       { &hf_gtp_iei, { "IEI", "gtp.iei", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10178       { &hf_gtp_iei_mobile_id_len, { "Length", "gtp.iei.mobile_id_len", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10179       { &hf_gtp_qos_umts_length, { "Length", "gtp.qos_umts_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10180       { &hf_gtp_num_ext_hdr_types, { "Number of Extension Header Types in list (i.e., length)", "gtp.num_ext_hdr_types", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
10181       { &hf_gtp_ext_hdr_type, { "Extension Header Type", "gtp.ext_hdr_type", FT_UINT8, BASE_DEC, VALS(next_extension_header_fieldvals), 0x0, NULL, HFILL }},
10182       { &hf_gtp_tpdu_data, { "T-PDU Data", "gtp.tpdu_data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
10183       { &hf_gtp_ext_enb_type, { "enb_type", "gtp.enb_type", FT_UINT8, BASE_DEC, VALS(gtp_enb_type_vals), 0x0, NULL, HFILL } },
10184       { &hf_gtp_macro_enodeb_id,
10185       { "Macro eNodeB ID", "gtp.macro_enodeb_id",
10186       FT_UINT24, BASE_HEX, NULL, 0x0fffff,
10187       NULL, HFILL }
10188       },
10189       { &hf_gtp_home_enodeb_id,
10190       { "Home eNodeB ID", "gtp.home_enodeb_id",
10191       FT_UINT32, BASE_HEX, NULL, 0x0fffffff,
10192       NULL, HFILL }
10193       },
10194       { &hf_gtp_dummy_octets,
10195       { "Dummy octets", "gtp.dummy_octets",
10196             FT_BYTES, BASE_NONE, NULL, 0x0,
10197             NULL, HFILL }
10198       },
10199
10200 };
10201
10202     static ei_register_info ei[] = {
10203         { &ei_gtp_ext_length_mal, { "gtp.ext_length.invalid", PI_MALFORMED, PI_ERROR, "Malformed length", EXPFILL }},
10204         { &ei_gtp_ext_hdr_pdcpsn, { "gtp.ext_hdr.pdcp_sn.non_zero", PI_PROTOCOL, PI_NOTE, "3GPP TS 29.281 v9.0.0: When used between two eNBs at the X2 interface in E-UTRAN, bit 8 of octet 2 is spare. The meaning of the spare bits shall be set to zero.", EXPFILL }},
10205         { &ei_gtp_ext_length_warn, { "gtp.ext_length.invalid", PI_PROTOCOL, PI_WARN, "Length warning", EXPFILL }},
10206         { &ei_gtp_undecoded, { "gtp.undecoded", PI_UNDECODED, PI_WARN, "Data not decoded yet", EXPFILL }},
10207         { &ei_gtp_message_not_found, { "gtp.message_not_found", PI_PROTOCOL, PI_WARN, "Message not found", EXPFILL }},
10208         { &ei_gtp_field_not_present, { "gtp.field_not_present", PI_PROTOCOL, PI_WARN, "Field not present", EXPFILL }},
10209         { &ei_gtp_wrong_next_field, { "gtp.wrong_next_field", PI_PROTOCOL, PI_WARN, "Wrong next field", EXPFILL }},
10210         { &ei_gtp_field_not_support_in_version, { "gtp.field_not_support_in_version", PI_PROTOCOL, PI_WARN, "GTP version not supported for field", EXPFILL }},
10211         { &ei_gtp_guaranteed_bit_rate_value, { "gtp.guaranteed_bit_rate_value", PI_PROTOCOL, PI_NOTE, "Use the value indicated by the Guaranteed bit rate", EXPFILL }},
10212         { &ei_gtp_max_bit_rate_value, { "gtp.max_bit_rate_value", PI_PROTOCOL, PI_NOTE, "Use the value indicated by the Maximum bit rate", EXPFILL }},
10213         { &ei_gtp_ext_geo_loc_type, { "gtp.ext_geo_loc_type.unknown", PI_PROTOCOL, PI_WARN, "Unknown Location type data", EXPFILL }},
10214         { &ei_gtp_iei, { "gtp.iei.unknown", PI_PROTOCOL, PI_WARN, "Unknown IEI - Later spec than TS 29.060 9.4.0 used?", EXPFILL }},
10215         { &ei_gtp_unknown_extention_header, { "gtp.unknown_extention_header", PI_PROTOCOL, PI_WARN, "Unknown extension header", EXPFILL }},
10216     };
10217
10218     /* Setup protocol subtree array */
10219 #define GTP_NUM_INDIVIDUAL_ELEMS    27
10220     static gint *ett_gtp_array[GTP_NUM_INDIVIDUAL_ELEMS + NUM_GTP_IES];
10221
10222     ett_gtp_array[0] = &ett_gtp;
10223     ett_gtp_array[1] = &ett_gtp_flags;
10224     ett_gtp_array[2] = &ett_gtp_ext;
10225     ett_gtp_array[3] = &ett_gtp_cdr_dr;
10226     ett_gtp_array[4] = &ett_gtp_qos;
10227     ett_gtp_array[5] = &ett_gtp_qos_arp;
10228     ett_gtp_array[6] = &ett_gtp_flow_ii;
10229     ett_gtp_array[7] = &ett_gtp_ext_hdr;
10230     ett_gtp_array[8] = &ett_gtp_rp;
10231     ett_gtp_array[9] = &ett_gtp_pkt_flow_id;
10232     ett_gtp_array[10] = &ett_gtp_data_resp;
10233     ett_gtp_array[11] = &ett_gtp_cdr_ver;
10234     ett_gtp_array[12] = &ett_gtp_tmgi;
10235     ett_gtp_array[13] = &ett_gtp_trip;
10236     ett_gtp_array[14] = &ett_gtp_quint;
10237     ett_gtp_array[15] = &ett_gtp_drx;
10238     ett_gtp_array[16] = &ett_gtp_net_cap;
10239     ett_gtp_array[17] = &ett_gtp_can_pack;
10240     ett_gtp_array[18] = &ett_gtp_proto;
10241     ett_gtp_array[19] = &ett_gtp_gsn_addr;
10242     ett_gtp_array[20] = &ett_gtp_tft;
10243     ett_gtp_array[21] = &ett_gtp_rab_setup;
10244     ett_gtp_array[22] = &ett_gtp_hdr_list;
10245     ett_gtp_array[23] = &ett_gtp_rel_pack;
10246     ett_gtp_array[24] = &ett_gtp_node_addr;
10247     ett_gtp_array[25] = &ett_gtp_mm_cntxt;
10248     ett_gtp_array[26] = &ett_gtp_utran_cont;
10249
10250     last_offset = GTP_NUM_INDIVIDUAL_ELEMS;
10251
10252     for (i=0; i < NUM_GTP_IES; i++, last_offset++)
10253     {
10254         ett_gtp_ies[i] = -1;
10255         ett_gtp_array[last_offset] = &ett_gtp_ies[i];
10256     }
10257
10258
10259
10260     proto_gtp = proto_register_protocol("GPRS Tunneling Protocol", "GTP", "gtp");
10261     proto_gtpprime = proto_register_protocol("GPRS Tunneling Protocol Prime", "GTP (Prime)", "gtpprime");
10262
10263     proto_register_field_array(proto_gtp, hf_gtp, array_length(hf_gtp));
10264     proto_register_subtree_array(ett_gtp_array, array_length(ett_gtp_array));
10265     expert_gtp = expert_register_protocol(proto_gtp);
10266     expert_register_field_array(expert_gtp, ei, array_length(ei));
10267
10268     gtp_module = prefs_register_protocol(proto_gtp, proto_reg_handoff_gtp);
10269
10270     prefs_register_uint_preference(gtp_module, "v0_port", "GTPv0 and GTP' port", "GTPv0 and GTP' port (default 3386)", 10, &g_gtpv0_port);
10271     prefs_register_uint_preference(gtp_module, "v1c_port", "GTPv1 or GTPv2 control plane (GTP-C, GTPv2-C) port", "GTPv1 and GTPv2 control plane port (default 2123)", 10,
10272                                    &g_gtpv1c_port);
10273     prefs_register_uint_preference(gtp_module, "v1u_port", "GTPv1 user plane (GTP-U) port", "GTPv1 user plane port (default 2152)", 10,
10274                                    &g_gtpv1u_port);
10275     prefs_register_enum_preference(gtp_module, "dissect_tpdu_as",
10276                                                "Dissect T-PDU as",
10277                                                "Dissect T-PDU as",
10278                                                &dissect_tpdu_as,
10279                                                gtp_decode_tpdu_as,
10280                                                FALSE);
10281
10282     prefs_register_obsolete_preference(gtp_module, "v0_dissect_cdr_as");
10283     prefs_register_obsolete_preference(gtp_module, "v0_check_etsi");
10284     prefs_register_obsolete_preference(gtp_module, "v1_check_etsi");
10285     prefs_register_bool_preference(gtp_module, "check_etsi", "Compare GTP order with ETSI", "GTP ETSI order", &g_gtp_etsi_order);
10286     prefs_register_obsolete_preference(gtp_module, "ppp_reorder");
10287     prefs_register_obsolete_preference(gtp_module, "dissect_tpdu");
10288
10289     /* This preference can be used to disable the dissection of GTP over TCP. Most of the Wireless operators uses GTP over UDP.
10290      * The preference is set to TRUE by default forbackward compatibility
10291      */
10292     prefs_register_bool_preference(gtp_module, "dissect_gtp_over_tcp", "Dissect GTP over TCP", "Dissect GTP over TCP", &g_gtp_over_tcp);
10293     prefs_register_bool_preference(gtp_module, "track_gtp_session", "Track GTP session", "Track GTP session", &g_gtp_session);
10294
10295     gtp_handle = register_dissector("gtp", dissect_gtp, proto_gtp);
10296     gtp_prime_handle = register_dissector("gtpprime", dissect_gtpprime, proto_gtpprime);
10297
10298     gtp_priv_ext_dissector_table = register_dissector_table("gtp.priv_ext", "GTP Private Extension", proto_gtp, FT_UINT16, BASE_DEC);
10299     gtp_cdr_fmt_dissector_table = register_dissector_table("gtp.cdr_fmt", "GTP Data Record Type", proto_gtp, FT_UINT16, BASE_DEC);
10300
10301     register_init_routine(gtp_init);
10302     register_cleanup_routine(gtp_cleanup);
10303     gtp_tap = register_tap("gtp");
10304     gtpv1_tap = register_tap("gtpv1");
10305
10306     register_srt_table(proto_gtp, NULL, 1, gtpstat_packet, gtpstat_init, NULL);
10307 }
10308 /* TS 132 295 V9.0.0 (2010-02)
10309  * 5.1.3 Port usage
10310  * - The UDP Destination Port may be the server port number 3386 which has been reserved for GTP'.
10311  * Alternatively another port can be used, which has been configured by O&M, except Port Number 2123
10312  * which is used by GTPv2-C.
10313  * :
10314  * The TCP Destination Port may be the server port number 3386, which has been reserved for G-PDUs. Alternatively,
10315  * another port may be used as configured by O&M. Extra implementation-specific destination ports are possible but
10316  * all CGFs shall support the server port number.
10317  */
10318
10319 void
10320 proto_reg_handoff_gtp(void)
10321 {
10322     static gboolean           Initialized = FALSE;
10323     static gboolean           gtp_over_tcp;
10324     static guint              gtpv0_port;
10325     static guint              gtpv1c_port;
10326     static guint              gtpv1u_port;
10327
10328     if (!Initialized) {
10329         ppp_subdissector_table = find_dissector_table("ppp.protocol");
10330
10331         radius_register_avp_dissector(VENDOR_THE3GPP, 5, dissect_radius_qos_umts);
10332         radius_register_avp_dissector(VENDOR_THE3GPP, 12, dissect_radius_selection_mode);
10333         radius_register_avp_dissector(VENDOR_THE3GPP, 22, dissect_radius_user_loc);
10334
10335
10336
10337         ip_handle            = find_dissector_add_dependency("ip", proto_gtp);
10338         ipv6_handle          = find_dissector_add_dependency("ipv6", proto_gtp);
10339         ppp_handle           = find_dissector_add_dependency("ppp", proto_gtp);
10340         sync_handle          = find_dissector_add_dependency("sync", proto_gtp);
10341         gtpcdr_handle        = find_dissector_add_dependency("gtpcdr", proto_gtp);
10342         sndcpxid_handle      = find_dissector_add_dependency("sndcpxid", proto_gtp);
10343         gtpv2_handle         = find_dissector_add_dependency("gtpv2", proto_gtp);
10344         bssgp_handle         = find_dissector_add_dependency("bssgp", proto_gtp);
10345         bssap_pdu_type_table = find_dissector_table("bssap.pdu_type");
10346         /* AVP Code: 5 3GPP-GPRS Negotiated QoS profile */
10347         dissector_add_uint("diameter.3gpp", 5, create_dissector_handle(dissect_diameter_3gpp_qosprofile, proto_gtp));
10348         /* AVP Code: 903 MBMS-Service-Area */
10349         dissector_add_uint("diameter.3gpp", 903, create_dissector_handle(dissect_gtp_3gpp_mbms_service_area, proto_gtp));
10350         /* AVP Code: 904 MBMS-Session-Duration */
10351         dissector_add_uint("diameter.3gpp", 904, create_dissector_handle(dissect_gtp_mbms_ses_dur, proto_gtp));
10352         /* AVP Code: 911 MBMS-Time-To-Data-Transfer */
10353         dissector_add_uint("diameter.3gpp", 911, create_dissector_handle(dissect_gtp_mbms_time_to_data_tr, proto_gtp));
10354
10355         Initialized = TRUE;
10356     } else {
10357         dissector_delete_uint("udp.port", gtpv0_port,  gtp_prime_handle);
10358         dissector_delete_uint("udp.port", gtpv1c_port, gtp_handle);
10359         dissector_delete_uint("udp.port", gtpv1u_port, gtp_handle);
10360
10361         if (gtp_over_tcp) {
10362             dissector_delete_uint("tcp.port", gtpv0_port,  gtp_prime_handle);
10363             dissector_delete_uint("tcp.port", gtpv1c_port, gtp_handle);
10364             dissector_delete_uint("tcp.port", gtpv1u_port, gtp_handle);
10365         }
10366     }
10367
10368     gtp_over_tcp = g_gtp_over_tcp;
10369     gtpv0_port   = g_gtpv0_port;
10370     gtpv1c_port  = g_gtpv1c_port;
10371     gtpv1u_port  = g_gtpv1u_port;
10372
10373     /* This doesn't use the "auto preference" API because the port
10374         description is too specific */
10375     dissector_add_uint("udp.port", g_gtpv0_port, gtp_prime_handle);
10376     dissector_add_uint("udp.port", g_gtpv1c_port, gtp_handle);
10377     dissector_add_uint("udp.port", g_gtpv1u_port, gtp_handle);
10378
10379     if (g_gtp_over_tcp) {
10380         /* This doesn't use the "auto preference" API because the port
10381            description is too specific */
10382         dissector_add_uint("tcp.port", g_gtpv0_port, gtp_prime_handle);
10383         dissector_add_uint("tcp.port", g_gtpv1c_port, gtp_handle);
10384         dissector_add_uint("tcp.port", g_gtpv1u_port, gtp_handle);
10385     }
10386 }
10387
10388 /*
10389  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
10390  *
10391  * Local variables:
10392  * c-basic-offset: 4
10393  * tab-width: 8
10394  * indent-tabs-mode: nil
10395  * End:
10396  *
10397  * vi: set shiftwidth=4 tabstop=8 expandtab:
10398  * :indentSize=4:tabSize=8:noTabs=true:
10399  */