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 <math.h>
44 
45 #include <epan/packet.h>
46 #include <epan/conversation.h>
47 #include <epan/prefs.h>
48 #include <epan/expert.h>
49 #include <epan/sminmpec.h>
50 #include <epan/addr_resolv.h>
51 #include <epan/asn1.h>
52 #include <epan/tap.h>
53 #include <epan/srt_table.h>
54 #include <epan/to_str.h>
55 #include <epan/uat.h>
56 #include <epan/proto_data.h>
57 #include <epan/etypes.h>
58 
59 #include "packet-ppp.h"
60 #include "packet-radius.h"
61 #include "packet-gsm_a_common.h"
62 #include "packet-gsm_map.h"
63 #include "packet-gprscdr.h"
64 #include "packet-bssgp.h"
65 #include "packet-e212.h"
66 #include "packet-e164.h"
67 #include "packet-gtp.h"
68 #include "packet-ranap.h"
69 #include "packet-pdcp-nr.h"
70 #include "packet-pdcp-lte.h"
71 #include "packet-rohc.h"
72 
73 void proto_register_gtp(void);
74 void proto_reg_handoff_gtp(void);
75 
76 static dissector_table_t gtp_priv_ext_dissector_table;
77 static dissector_table_t gtp_cdr_fmt_dissector_table;
78 static dissector_table_t gtp_hdr_ext_dissector_table;
79 static dissector_handle_t gtp_handle, gtp_prime_handle;
80 static dissector_handle_t nrup_handle;
81 
82 #define GTPv0_PORT  3386
83 #define GTPv1C_PORT 2123    /* 3G Control PDU */
84 #define GTPv1U_PORT 2152    /* 3G T-PDU */
85 
86 #define GTPv0_HDR_LENGTH     20
87 #define GTPv1_HDR_LENGTH     12
88 #define GTP_PRIME_HDR_LENGTH  6
89 
90 /* to check compliance with ETSI  */
91 #define GTP_MANDATORY   1
92 #define GTP_OPTIONAL    2
93 #define GTP_CONDITIONAL 4
94 
95 #define GTP_TPDU_AS_NONE -1
96 #define GTP_TPDU_AS_TPDU_HEUR 0
97 #define GTP_TPDU_AS_PDCP_LTE 1
98 #define GTP_TPDU_AS_PDCP_NR 2
99 #define GTP_TPDU_AS_SYNC 3
100 #define GTP_TPDU_AS_ETHERNET 4
101 #define GTP_TPDU_AS_CUSTOM 5
102 
103 static gboolean g_gtp_over_tcp = TRUE;
104 gboolean g_gtp_session = FALSE;
105 
106 static guint pref_pair_matching_max_interval_ms = 0; /* Default: disable */
107 
108 static guint g_gtpv0_port  = GTPv0_PORT;
109 static guint g_gtpv1c_port = GTPv1C_PORT;
110 static guint g_gtpv1u_port = GTPv1U_PORT;
111 
112 static int proto_gtp = -1;
113 static int proto_gtpprime = -1;
114 
115 /*KTi*/
116 static int hf_gtp_ie_id = -1;
117 static int hf_gtp_response_in = -1;
118 static int hf_gtp_response_to = -1;
119 static int hf_gtp_time = -1;
120 static int hf_gtp_apn = -1;
121 static int hf_gtp_cause = -1;
122 static int hf_gtp_chrg_char = -1;
123 static int hf_gtp_chrg_char_s = -1;
124 static int hf_gtp_chrg_char_n = -1;
125 static int hf_gtp_chrg_char_p = -1;
126 static int hf_gtp_chrg_char_f = -1;
127 static int hf_gtp_chrg_char_h = -1;
128 static int hf_gtp_chrg_char_r = -1;
129 static int hf_gtp_chrg_id = -1;
130 static int hf_gtp_chrg_ipv4 = -1;
131 static int hf_gtp_chrg_ipv6 = -1;
132 static int hf_gtp_ext_flow_label = -1;
133 static int hf_gtp_ext_id = -1;
134 static int hf_gtp_ext_val = -1;
135 static int hf_gtp_ext_hdr = -1;
136 static int hf_gtp_ext_hdr_next = -1;
137 static int hf_gtp_ext_hdr_length = -1;
138 static int hf_gtp_ext_hdr_ran_cont = -1;
139 static int hf_gtp_ext_hdr_spare_bits = -1;
140 static int hf_gtp_ext_hdr_spare_bytes = -1;
141 static int hf_gtp_ext_hdr_long_pdcp_sn = -1;
142 static int hf_gtp_ext_hdr_xw_ran_cont = -1;
143 static int hf_gtp_ext_hdr_pdcpsn = -1;
144 static int hf_gtp_ext_hdr_udp_port = -1;
145 static int hf_gtp_flags = -1;
146 static int hf_gtp_flags_ver = -1;
147 static int hf_gtp_prime_flags_ver = -1;
148 static int hf_gtp_flags_pt = -1;
149 static int hf_gtp_flags_spare1 = -1;
150 static int hf_gtp_flags_hdr_length = -1;
151 static int hf_gtp_flags_snn = -1;
152 static int hf_gtp_flags_spare2 = -1;
153 static int hf_gtp_flags_e = -1;
154 static int hf_gtp_flags_s = -1;
155 static int hf_gtp_flags_pn = -1;
156 static int hf_gtp_flow_ii = -1;
157 static int hf_gtp_flow_label = -1;
158 static int hf_gtp_flow_sig = -1;
159 static int hf_gtp_gsn_addr_len = -1;
160 static int hf_gtp_gsn_addr_type = -1;
161 static int hf_gtp_gsn_ipv4 = -1;
162 static int hf_gtp_gsn_ipv6 = -1;
163 static int hf_gtp_length = -1;
164 static int hf_gtp_map_cause = -1;
165 static int hf_gtp_message_type = -1;
166 static int hf_gtp_ms_reason = -1;
167 static int hf_gtp_ms_valid = -1;
168 static int hf_gtp_npdu_number = -1;
169 static int hf_gtp_node_ipv4 = -1;
170 static int hf_gtp_node_ipv6 = -1;
171 static int hf_gtp_node_name = -1;
172 static int hf_gtp_node_realm = -1;
173 static int hf_gtp_nsapi = -1;
174 static int hf_gtp_ptmsi = -1;
175 static int hf_gtp_ptmsi_sig = -1;
176 static int hf_gtp_qos_version = -1;
177 static int hf_gtp_qos_spare1 = -1;
178 static int hf_gtp_qos_delay = -1;
179 static int hf_gtp_qos_mean = -1;
180 static int hf_gtp_qos_peak = -1;
181 static int hf_gtp_qos_spare2 = -1;
182 static int hf_gtp_qos_precedence = -1;
183 static int hf_gtp_qos_spare3 = -1;
184 static int hf_gtp_qos_reliability = -1;
185 static int hf_gtp_qos_al_ret_priority = -1;
186 static int hf_gtp_qos_traf_class = -1;
187 static int hf_gtp_qos_del_order = -1;
188 static int hf_gtp_qos_del_err_sdu = -1;
189 static int hf_gtp_qos_max_sdu_size = -1;
190 static int hf_gtp_qos_max_ul = -1;
191 static int hf_gtp_qos_max_dl = -1;
192 static int hf_gtp_qos_res_ber = -1;
193 static int hf_gtp_qos_sdu_err_ratio = -1;
194 static int hf_gtp_qos_trans_delay = -1;
195 static int hf_gtp_qos_traf_handl_prio = -1;
196 static int hf_gtp_qos_guar_ul = -1;
197 static int hf_gtp_qos_guar_dl = -1;
198 static int hf_gtp_qos_spare4 = -1;
199 static int hf_gtp_qos_sig_ind = -1;
200 static int hf_gtp_qos_src_stat_desc = -1;
201 static int hf_gtp_qos_arp = -1;
202 static int hf_gtp_qos_arp_pvi = -1;
203 static int hf_gtp_qos_arp_pl = -1;
204 static int hf_gtp_qos_arp_pci = -1;
205 static int hf_gtp_qos_qci = -1;
206 static int hf_gtp_qos_ul_mbr = -1;
207 static int hf_gtp_qos_dl_mbr = -1;
208 static int hf_gtp_qos_ul_gbr = -1;
209 static int hf_gtp_qos_dl_gbr = -1;
210 static int hf_gtp_qos_ul_apn_ambr = -1;
211 static int hf_gtp_qos_dl_apn_ambr = -1;
212 static int hf_gtp_pkt_flow_id = -1;
213 static int hf_gtp_rab_gtpu_dn = -1;
214 static int hf_gtp_rab_gtpu_up = -1;
215 static int hf_gtp_rab_pdu_dn = -1;
216 static int hf_gtp_rab_pdu_up = -1;
217 static int hf_gtp_uli_geo_loc_type = -1;
218 static int hf_gtp_cgi_ci = -1;
219 static int hf_gtp_sai_sac = -1;
220 static int hf_gtp_rai_rac = -1;
221 static int hf_gtp_lac = -1;
222 static int hf_gtp_tac = -1;
223 static int hf_gtp_ranap_cause = -1;
224 static int hf_gtp_recovery = -1;
225 static int hf_gtp_reorder = -1;
226 static int hf_gtp_rnc_ipv4 = -1;
227 static int hf_gtp_rnc_ipv6 = -1;
228 static int hf_gtp_rp = -1;
229 static int hf_gtp_rp_nsapi = -1;
230 static int hf_gtp_rp_sms = -1;
231 static int hf_gtp_rp_spare = -1;
232 static int hf_gtp_sel_mode = -1;
233 static int hf_gtp_seq_number = -1;
234 static int hf_gtp_session = -1;
235 static int hf_gtp_sndcp_number = -1;
236 static int hf_gtp_tear_ind = -1;
237 static int hf_gtp_teid = -1;
238 static int hf_gtp_teid_cp = -1;
239 static int hf_gtp_uplink_teid_cp = -1;
240 static int hf_gtp_teid_data = -1;
241 static int hf_gtp_uplink_teid_data = -1;
242 static int hf_gtp_teid_ii = -1;
243 static int hf_gtp_tid = -1;
244 static int hf_gtp_tlli = -1;
245 static int hf_gtp_tr_comm = -1;
246 static int hf_gtp_trace_ref = -1;
247 static int hf_gtp_trace_type = -1;
248 static int hf_gtp_user_addr_pdp_org = -1;
249 static int hf_gtp_user_addr_pdp_type = -1;
250 static int hf_gtp_user_ipv4 = -1;
251 static int hf_gtp_user_ipv6 = -1;
252 static int hf_gtp_security_mode = -1;
253 static int hf_gtp_no_of_vectors = -1;
254 static int hf_gtp_cipher_algorithm = -1;
255 static int hf_gtp_cksn_ksi = -1;
256 static int hf_gtp_cksn = -1;
257 static int hf_gtp_ksi = -1;
258 static int hf_gtp_ext_length = -1;
259 static int hf_gtp_utran_field = -1;
260 static int hf_gtp_ext_apn_res = -1;
261 static int hf_gtp_ext_rat_type = -1;
262 static int hf_gtp_ext_imeisv = -1;
263 static int hf_gtp_target_rnc_id = -1;
264 static int hf_gtp_target_ext_rnc_id = -1;
265 static int hf_gtp_bssgp_cause = -1;
266 static int hf_gtp_bssgp_ra_discriminator = -1;
267 static int hf_gtp_sapi = -1;
268 static int hf_gtp_xid_par_len = -1;
269 static int hf_gtp_rep_act_type = -1;
270 static int hf_gtp_correlation_id = -1;
271 static int hf_gtp_earp_pci = -1;
272 static int hf_gtp_earp_pl = -1;
273 static int hf_gtp_earp_pvi = -1;
274 static int hf_gtp_ext_comm_flags_uasi = -1;
275 static int hf_gtp_ext_comm_flags_II_pnsi = -1;
276 static int hf_gtp_ext_comm_flags_II_dtci = -1;
277 static int hf_gtp_ext_comm_flags_II_pmtsmi = -1;
278 static int hf_gtp_ext_comm_flags_II_spare = -1;
279 static int hf_gtp_cdr_app = -1;
280 static int hf_gtp_cdr_rel = -1;
281 static int hf_gtp_cdr_ver = -1;
282 static int hf_gtp_cdr_length = -1;
283 static int hf_gtp_cdr_context = -1;
284 static int hf_gtp_cmn_flg_ppc = -1;
285 static int hf_gtp_cmn_flg_mbs_srv_type = -1;
286 static int hf_gtp_cmn_flg_mbs_ran_pcd_rdy = -1;
287 static int hf_gtp_cmn_flg_mbs_cnt_inf = -1;
288 static int hf_gtp_cmn_flg_nrsn = -1;
289 static int hf_gtp_cmn_flg_no_qos_neg = -1;
290 static int hf_gtp_cmn_flg_upgrd_qos_sup = -1;
291 static int hf_gtp_cmn_flg_dual_addr_bearer_flg = -1;
292 static int hf_gtp_tmgi = -1;
293 static int hf_gtp_mbms_ses_dur_days = -1;
294 static int hf_gtp_mbms_ses_dur_s = -1;
295 static int hf_gtp_no_of_mbms_sa_codes = -1;
296 static int hf_gtp_mbms_sa_code = -1;
297 static int hf_gtp_mbs_2g_3g_ind = -1;
298 static int hf_gtp_time_2_dta_tr = -1;
299 static int hf_gtp_ext_ei = -1;
300 static int hf_gtp_ext_gcsi = -1;
301 static int hf_gtp_ext_dti = -1;
302 static int hf_gtp_ra_prio_lcs = -1;
303 static int hf_gtp_bcm = -1;
304 static int hf_gtp_fqdn = -1;
305 static int hf_gtp_rim_routing_addr = -1;
306 static int hf_gtp_mbms_flow_id = -1;
307 static int hf_gtp_mbms_dist_indic = -1;
308 static int hf_gtp_ext_apn_ambr_ul = -1;
309 static int hf_gtp_ext_apn_ambr_dl = -1;
310 static int hf_gtp_ext_sub_ue_ambr_ul = -1;
311 static int hf_gtp_ext_sub_ue_ambr_dl = -1;
312 static int hf_gtp_ext_auth_ue_ambr_ul = -1;
313 static int hf_gtp_ext_auth_ue_ambr_dl = -1;
314 static int hf_gtp_ext_auth_apn_ambr_ul = -1;
315 static int hf_gtp_ext_auth_apn_ambr_dl = -1;
316 static int hf_gtp_ext_ggsn_back_off_time_units = -1;
317 static int hf_gtp_ext_ggsn_back_off_timer = -1;
318 static int hf_gtp_higher_br_16mb_flg = -1;
319 static int hf_gtp_max_mbr_apn_ambr_ul = -1;
320 static int hf_gtp_max_mbr_apn_ambr_dl = -1;
321 static int hf_gtp_ext_enb_type = -1;
322 static int hf_gtp_macro_enodeb_id = -1;
323 static int hf_gtp_home_enodeb_id = -1;
324 static int hf_gtp_dummy_octets = -1;
325 
326 static int hf_pdcp_cont = -1;
327 
328 static int hf_gtp_ext_hdr_pdu_ses_cont_pdu_type = -1;
329 static int hf_gtp_ext_hdr_pdu_ses_cont_ppp = -1;
330 static int hf_gtp_ext_hdr_pdu_ses_cont_rqi = -1;
331 static int hf_gtp_ext_hdr_pdu_ses_cont_qos_flow_id = -1;
332 static int hf_gtp_ext_hdr_pdu_ses_cont_ppi = -1;
333 
334 static int hf_gtp_spare_b4b0 = -1;
335 static int hf_gtp_spare_b7b6 = -1;
336 static int hf_gtp_spare_h1 = -1;
337 static int hf_gtp_rnc_ip_addr_v4 = -1;
338 static int hf_gtp_rnc_ip_addr_v6 = -1;
339 static int hf_gtp_ms_cm_2_len = -1;
340 static int hf_gtp_ms_cm_3_len = -1;
341 static int hf_gtp_sup_codec_lst_len = -1;
342 static int hf_gtp_add_flg_for_srvcc_ics = -1;
343 static int hf_gtp_sel_mode_val = -1;
344 
345 /* Generated from convert_proto_tree_add_text.pl */
346 static int hf_gtp_rfsp_index = -1;
347 static int hf_gtp_quintuplet_ciphering_key = -1;
348 static int hf_gtp_kc = -1;
349 static int hf_gtp_rand = -1;
350 static int hf_gtp_pdp_context_identifier = -1;
351 static int hf_gtp_receive_n_pdu_number = -1;
352 static int hf_gtp_container_length = -1;
353 static int hf_gtp_quintuplets_length = -1;
354 static int hf_gtp_auth = -1;
355 static int hf_gtp_tft_length = -1;
356 static int hf_gtp_ggsn_address_for_control_plane_ipv4 = -1;
357 static int hf_gtp_ggsn_address_for_control_plane_ipv6 = -1;
358 static int hf_gtp_ggsn_address_for_user_traffic_ipv4 = -1;
359 static int hf_gtp_ggsn_address_for_user_traffic_ipv6 = -1;
360 static int hf_gtp_integrity_key_ik = -1;
361 static int hf_gtp_gsn_address_information_element_length = -1;
362 static int hf_gtp_reordering_required = -1;
363 static int hf_gtp_sres = -1;
364 static int hf_gtp_data_record_format = -1;
365 static int hf_gtp_timezone = -1;
366 static int hf_gtp_timezone_dst = -1;
367 static int hf_gtp_authentication_length = -1;
368 static int hf_gtp_send_n_pdu_number = -1;
369 static int hf_gtp_sequence_number_up = -1;
370 static int hf_gtp_pdp_address_length = -1;
371 static int hf_gtp_transaction_identifier = -1;
372 static int hf_gtp_xres_length = -1;
373 static int hf_gtp_ggsn_address_length = -1;
374 static int hf_gtp_apn_length = -1;
375 static int hf_gtp_sequence_number_down = -1;
376 static int hf_gtp_pdp_address_ipv4 = -1;
377 static int hf_gtp_activity_status_indicator = -1;
378 static int hf_gtp_pdp_type = -1;
379 static int hf_gtp_quintuplet_integrity_key = -1;
380 static int hf_gtp_pdp_address_ipv6 = -1;
381 static int hf_gtp_rab_setup_length = -1;
382 static int hf_gtp_number_of_data_records = -1;
383 static int hf_gtp_ciphering_key_kc = -1;
384 static int hf_gtp_pdp_cntxt_sapi = -1;
385 static int hf_gtp_xres = -1;
386 static int hf_gtp_pdp_organization = -1;
387 static int hf_gtp_node_address_length = -1;
388 static int hf_gtp_gsn_address_length = -1;
389 static int hf_gtp_vplmn_address_allowed = -1;
390 static int hf_gtp_uplink_flow_label_signalling = -1;
391 static int hf_gtp_extended_end_user_address = -1;
392 static int hf_gtp_ciphering_key_ck = -1;
393 static int hf_gtp_fqdn_length = -1;
394 static int hf_gtp_seq_num_released = -1;
395 static int hf_gtp_seq_num_canceled = -1;
396 static int hf_gtp_requests_responded = -1;
397 static int hf_gtp_hyphen_separator = -1;
398 static int hf_gtp_ms_network_cap_content_len = -1;
399 static int hf_gtp_iei = -1;
400 static int hf_gtp_iei_mobile_id_len = -1;
401 static int hf_gtp_qos_umts_length = -1;
402 static int hf_gtp_num_ext_hdr_types = -1;
403 static int hf_gtp_ext_hdr_type = -1;
404 static int hf_gtp_tpdu_data = -1;
405 
406 static int hf_gtp_sgsn_address_for_control_plane_ipv4 = -1;
407 static int hf_gtp_sgsn_address_for_control_plane_ipv6 = -1;
408 static int hf_gtp_sgsn_address_for_user_traffic_ipv4 = -1;
409 static int hf_gtp_sgsn_address_for_user_traffic_ipv6 = -1;
410 
411 /* Initialize the subtree pointers */
412 static gint ett_gtp = -1;
413 static gint ett_gtp_flags = -1;
414 static gint ett_gtp_ext = -1;
415 static gint ett_gtp_ext_hdr = -1;
416 static gint ett_gtp_qos = -1;
417 static gint ett_gtp_qos_arp = -1;
418 static gint ett_gtp_flow_ii = -1;
419 static gint ett_gtp_rp = -1;
420 static gint ett_gtp_pkt_flow_id = -1;
421 static gint ett_gtp_trip = -1;
422 static gint ett_gtp_quint = -1;
423 static gint ett_gtp_proto = -1;
424 static gint ett_gtp_gsn_addr = -1;
425 static gint ett_gtp_tft = -1;
426 static gint ett_gtp_rab_setup = -1;
427 static gint ett_gtp_hdr_list = -1;
428 static gint ett_gtp_node_addr = -1;
429 static gint ett_gtp_rel_pack = -1;
430 static gint ett_gtp_can_pack = -1;
431 static gint ett_gtp_data_resp = -1;
432 static gint ett_gtp_drx = -1;
433 static gint ett_gtp_net_cap = -1;
434 static gint ett_gtp_tmgi = -1;
435 static gint ett_gtp_cdr_ver = -1;
436 static gint ett_gtp_cdr_dr = -1;
437 static gint ett_gtp_mm_cntxt = -1;
438 static gint ett_gtp_utran_cont = -1;
439 static gint ett_gtp_nr_ran_cont = -1;
440 static gint ett_gtp_pdcp_no_conf = -1;
441 static gint ett_pdu_session_cont = -1;
442 
443 static expert_field ei_gtp_ext_hdr_pdcpsn = EI_INIT;
444 static expert_field ei_gtp_ext_length_mal = EI_INIT;
445 static expert_field ei_gtp_ext_length_warn = EI_INIT;
446 static expert_field ei_gtp_undecoded = EI_INIT;
447 static expert_field ei_gtp_message_not_found = EI_INIT;
448 static expert_field ei_gtp_field_not_present = EI_INIT;
449 static expert_field ei_gtp_wrong_next_field = EI_INIT;
450 static expert_field ei_gtp_field_not_support_in_version = EI_INIT;
451 static expert_field ei_gtp_guaranteed_bit_rate_value = EI_INIT;
452 static expert_field ei_gtp_max_bit_rate_value = EI_INIT;
453 static expert_field ei_gtp_ext_geo_loc_type = EI_INIT;
454 static expert_field ei_gtp_iei = EI_INIT;
455 static expert_field ei_gtp_unknown_extension_header = EI_INIT;
456 static expert_field ei_gtp_unknown_pdu_type = EI_INIT;
457 
458 static const range_string assistance_info_type[] = {
459     { 0,   0,   "UNKNOWN" },
460     { 1,   1,   "Average CQL" },
461     { 2,   2,   "Average HARQ Failure" },
462     { 3,   3,   "Average HARQ Retransmissions" },
463     { 4,   4,   "DL Radio Quality Index" },
464     { 5,   5,   "UL Radio Quality Index" },
465     { 6,   6,   "Power Headroom Report" },
466     { 7,   228, "reserved for future value extensions" },
467     { 229, 255, "reserved for test purposes" },
468     { 0,   0,   NULL}
469 };
470 
471 
472 /* NRUP - TS 38.425 */
473 /* NR-U RAN Container */
474 static int proto_nrup = -1;
475 static int hf_nrup_pdu_type = -1;
476 static int hf_nrup_spr_bit_extnd_flag = -1;
477 static int hf_nrup_dl_discrd_blks = -1;
478 static int hf_nrup_dl_flush = -1;
479 static int hf_nrup_rpt_poll = -1;
480 static int hf_nrup_retransmission_flag = -1;
481 static int hf_nrup_ass_inf_rep_poll_flag = -1;
482 static int hf_nrup_spare = -1;
483 static int hf_nrup_request_out_of_seq_report = -1;
484 static int hf_nrup_report_delivered = -1;
485 static int hf_nrup_user_data_existence_flag = -1;
486 static int hf_nrup_nr_u_seq_num = -1;
487 static int hf_nrup_dl_disc_nr_pdcp_pdu_sn = -1;
488 static int hf_nrup_dl_disc_num_blks = -1;
489 static int hf_nrup_dl_disc_nr_pdcp_pdu_sn_start = -1;
490 static int hf_nrup_dl_disc_blk_sz = -1;
491 static int hf_nrup_dl_report_nr_pdcp_pdu_sn = -1;
492 static int hf_nrup_high_tx_nr_pdcp_sn_ind = -1;
493 static int hf_nrup_high_delivered_nr_pdcp_sn_ind = -1;
494 static int hf_nrup_final_frame_ind = -1;
495 static int hf_nrup_lost_pkt_rpt = -1;
496 static int hf_nrup_high_retx_nr_pdcp_sn_ind = -1;
497 static int hf_nrup_high_delivered_retx_nr_pdcp_sn_ind = -1;
498 static int hf_nrup_cause_rpt = -1;
499 static int hf_nrup_delivered_nr_pdcp_sn_range_ind = -1;
500 static int hf_nrup_data_rate_ind = -1;
501 static int hf_nrup_desrd_buff_sz_data_radio_bearer = -1;
502 static int hf_nrup_desrd_data_rate = -1;
503 static int hf_nrup_num_lost_nru_seq_num = -1;
504 static int hf_nrup_start_lost_nru_seq_num = -1;
505 static int hf_nrup_end_lost_nru_seq_num = -1;
506 static int hf_nrup_high_success_delivered_nr_pdcp_sn = -1;
507 static int hf_nrup_high_tx_nr_pdcp_sn = -1;
508 static int hf_nrup_cause_val = -1;
509 static int hf_nrup_high_success_delivered_retx_nr_pdcp_sn = -1;
510 static int hf_nrup_high_retx_nr_pdcp_sn = -1;
511 static int hf_nrup_pdcp_duplication_ind = -1;
512 static int hf_nrup_assistance_information_ind = -1;
513 static int hf_nrup_ul_delay_ind = -1;
514 static int hf_nrup_dl_delay_ind = -1;
515 static int hf_nrup_spare_2 = -1;
516 static int hf_nrup_pdcp_duplication_activation_suggestion = -1;
517 static int hf_nrup_num_assistance_info_fields = -1;
518 static int hf_nrup_assistance_information_type = -1;
519 static int hf_nrup_num_octets_radio_qa_info = -1;
520 static int hf_nrup_radio_qa_info = -1;
521 static int hf_nrup_ul_delay_du_result = -1;
522 static int hf_nrup_dl_delay_du_result = -1;
523 
524 static gint ett_nrup = -1;
525 
526 
527 
528 /* --- PDCP DECODE ADDITIONS --- */
529 static gboolean
pdcp_uat_fld_ip_chk_cb(void * r _U_,const char * ipaddr,guint len _U_,const void * u1 _U_,const void * u2 _U_,char ** err)530 pdcp_uat_fld_ip_chk_cb(void* r _U_, const char* ipaddr, guint len _U_, const void* u1 _U_, const void* u2 _U_, char** err)
531 {
532     ws_in4_addr ip4_addr;
533     ws_in6_addr ip6_addr;
534 
535     /* Check for a valid IPv4 or IPv6 address */
536     if (ipaddr &&
537         (ws_inet_pton6(ipaddr, &ip6_addr) ||
538          ws_inet_pton4(ipaddr, &ip4_addr))) {
539         *err = NULL;
540         return TRUE;
541     }
542 
543     *err = g_strdup_printf("No valid IP address given");
544     return FALSE;
545 }
546 
547 #define PDCP_TEID_WILDCARD "*"
548 
549 static gboolean
pdcp_uat_fld_teid_chk_cb(void * r _U_,const char * teid,guint len _U_,const void * u1 _U_,const void * u2 _U_,char ** err)550 pdcp_uat_fld_teid_chk_cb(void* r _U_, const char* teid, guint len _U_, const void* u1 _U_, const void* u2 _U_, char** err)
551 {
552     if (teid) {
553         guint32 val;
554 
555         /* Check if it is a wildcard TEID */
556         if (!strcmp(teid, PDCP_TEID_WILDCARD)) {
557             *err = NULL;
558             return TRUE;
559         }
560         /* Check if it is a valid 32bits unsinged integer */
561         if (ws_basestrtou32(teid, NULL, &val, 0)) {
562             *err = NULL;
563             return TRUE;
564         }
565     }
566 
567     *err = g_strdup_printf("No valid TEID given");
568     return FALSE;
569 }
570 
571 typedef struct {
572     gchar *ip_addr_str;
573     address ip_address;
574     gchar *teid_str;
575     gboolean teid_wildcard;
576     guint32 teid;
577     guint header_present;
578     enum pdcp_plane plane;
579     guint lte_sn_length;
580     guint rohc_compression;
581     //guint rohc_mode;
582     guint rohc_profile;
583 } uat_pdcp_lte_keys_record_t;
584 
585 /* N.B. this is an array/table of the struct above, where IP address + TEID is the key */
586 static uat_pdcp_lte_keys_record_t *uat_pdcp_lte_keys_records = NULL;
587 
pdcp_lte_update_cb(void * r,char ** err)588 static gboolean pdcp_lte_update_cb(void *r, char **err)
589 {
590     uat_pdcp_lte_keys_record_t* rec = (uat_pdcp_lte_keys_record_t *)r;
591     ws_in4_addr ip4_addr;
592     ws_in6_addr ip6_addr;
593 
594     if (!strcmp(rec->teid_str, PDCP_TEID_WILDCARD)) {
595         rec->teid_wildcard = TRUE;
596         rec->teid = 0;
597     } else if (ws_basestrtou32(rec->teid_str, NULL, &rec->teid, 0)) {
598         rec->teid_wildcard = FALSE;
599     } else {
600         if (err)
601             *err = g_strdup_printf("No valid TEID given");
602         return FALSE;
603     }
604 
605     free_address_wmem(wmem_epan_scope(), &rec->ip_address);
606     if (ws_inet_pton6(rec->ip_addr_str, &ip6_addr)) {
607         alloc_address_wmem(wmem_epan_scope(), &rec->ip_address, AT_IPv6, sizeof(ws_in6_addr), &ip6_addr);
608     } else if (ws_inet_pton4(rec->ip_addr_str, &ip4_addr)) {
609         alloc_address_wmem(wmem_epan_scope(), &rec->ip_address, AT_IPv4, sizeof(ws_in4_addr), &ip4_addr);
610     } else {
611         if (err)
612             *err = g_strdup_printf("No valid IP address given");
613         return FALSE;
614     }
615 
616     return TRUE;
617 }
618 
pdcp_lte_copy_cb(void * n,const void * o,size_t len _U_)619 static void *pdcp_lte_copy_cb(void *n, const void *o, size_t len _U_)
620 {
621     uat_pdcp_lte_keys_record_t* new_rec = (uat_pdcp_lte_keys_record_t *)n;
622     const uat_pdcp_lte_keys_record_t* old_rec = (const uat_pdcp_lte_keys_record_t *)o;
623 
624     /* Copy UAT fields */
625     new_rec->ip_addr_str = g_strdup(old_rec->ip_addr_str);
626     clear_address(&new_rec->ip_address);
627     new_rec->teid_str = g_strdup(old_rec->teid_str);
628     new_rec->header_present = old_rec->header_present;
629     new_rec->plane = old_rec->plane;
630     new_rec->lte_sn_length = old_rec->lte_sn_length;
631     new_rec->rohc_compression = old_rec->rohc_compression;
632     //new_rec->rohc_mode = old_rec->rohc_mode;
633     new_rec->rohc_profile = old_rec->rohc_profile;
634 
635     pdcp_lte_update_cb(new_rec, NULL);
636 
637     return new_rec;
638 }
639 
pdcp_lte_free_cb(void * r)640 static void pdcp_lte_free_cb(void *r)
641 {
642     uat_pdcp_lte_keys_record_t* rec = (uat_pdcp_lte_keys_record_t *)r;
643 
644     g_free(rec->ip_addr_str);
645     g_free(rec->teid_str);
646     free_address_wmem(wmem_epan_scope(), &rec->ip_address);
647 }
648 
649 #define PDCP_SN_LENGTH_12_BITS_STR "12 bits"
650 static const value_string vs_pdcp_lte_sn_length[] = {
651     {PDCP_SN_LENGTH_5_BITS,  "5 bits"},
652     {PDCP_SN_LENGTH_7_BITS,  "7 bits"},
653     {PDCP_SN_LENGTH_12_BITS, PDCP_SN_LENGTH_12_BITS_STR},
654     {PDCP_SN_LENGTH_15_BITS, "15 bits"},
655     {PDCP_SN_LENGTH_18_BITS, "18 bits"},
656     {0, NULL}
657 };
658 
659 /* Struct for saving PDCP-NR information about specific TEID */
660 typedef struct {
661     gchar *ip_addr_str;
662     address ip_address;
663     gchar *teid_str;
664     gboolean teid_wildcard;
665     guint32 teid;
666     guint direction;
667     /* PDCP_NR_(U|D)L_sdap_hdr_PRESENT bitmask */
668     guint sdap_header_present;
669     guint mac_i_present;
670     enum pdcp_nr_plane plane;
671     guint pdcp_nr_sn_length;
672     guint rohc_compression;
673     //guint rohc_mode;
674     guint rohc_profile;
675 } uat_pdcp_nr_keys_record_t;
676 
677 /* N.B. this is an array/table of the struct above, where IP address + TEID is the key */
678 static uat_pdcp_nr_keys_record_t *uat_pdcp_nr_keys_records = NULL;
679 
pdcp_nr_update_cb(void * r,char ** err)680 static gboolean pdcp_nr_update_cb(void *r, char **err) {
681     uat_pdcp_nr_keys_record_t* rec = (uat_pdcp_nr_keys_record_t *)r;
682     ws_in4_addr ip4_addr;
683     ws_in6_addr ip6_addr;
684 
685     if (!strcmp(rec->teid_str, PDCP_TEID_WILDCARD)) {
686         rec->teid_wildcard = TRUE;
687         rec->teid = 0;
688     } else if (ws_basestrtou32(rec->teid_str, NULL, &rec->teid, 0)) {
689         rec->teid_wildcard = FALSE;
690     } else {
691         if (err)
692             *err = g_strdup_printf("No valid TEID given");
693         return FALSE;
694     }
695 
696     free_address_wmem(wmem_epan_scope(), &rec->ip_address);
697     if (ws_inet_pton6(rec->ip_addr_str, &ip6_addr)) {
698         alloc_address_wmem(wmem_epan_scope(), &rec->ip_address, AT_IPv6, sizeof(ws_in6_addr), &ip6_addr);
699     } else if (ws_inet_pton4(rec->ip_addr_str, &ip4_addr)) {
700         alloc_address_wmem(wmem_epan_scope(), &rec->ip_address, AT_IPv4, sizeof(ws_in4_addr), &ip4_addr);
701     } else {
702         if (err)
703             *err = g_strdup_printf("No valid IP address given");
704         return FALSE;
705     }
706 
707     return TRUE;
708 }
709 
pdcp_nr_copy_cb(void * n,const void * o,size_t len _U_)710 static void *pdcp_nr_copy_cb(void *n, const void *o, size_t len _U_) {
711     uat_pdcp_nr_keys_record_t* new_rec = (uat_pdcp_nr_keys_record_t *)n;
712     const uat_pdcp_nr_keys_record_t* old_rec = (const uat_pdcp_nr_keys_record_t *)o;
713 
714     /* Copy UAT fields */
715     new_rec->ip_addr_str = g_strdup(old_rec->ip_addr_str);
716     clear_address(&new_rec->ip_address);
717     new_rec->teid_str = g_strdup(old_rec->teid_str);
718     new_rec->direction = old_rec->direction;
719     new_rec->sdap_header_present = old_rec->sdap_header_present;
720     new_rec->mac_i_present = old_rec->mac_i_present;
721     new_rec->plane = old_rec->plane;
722     new_rec->pdcp_nr_sn_length = old_rec->pdcp_nr_sn_length;
723     new_rec->rohc_compression = old_rec->rohc_compression;
724     //new_rec->rohc_mode = old_rec->rohc_mode;
725     new_rec->rohc_profile = old_rec->rohc_profile;
726 
727     pdcp_nr_update_cb(new_rec, NULL);
728 
729     return new_rec;
730 }
731 
pdcp_nr_free_cb(void * r)732 static void pdcp_nr_free_cb(void *r)
733 {
734     uat_pdcp_nr_keys_record_t* rec = (uat_pdcp_nr_keys_record_t *)r;
735 
736     g_free(rec->ip_addr_str);
737     g_free(rec->teid_str);
738     free_address_wmem(wmem_epan_scope(), &rec->ip_address);
739 }
740 
741 #define PDCP_NR_DIRECTION_UPLINK_STR "UL"
742 static const value_string vs_direction[] = {
743     { PDCP_NR_DIRECTION_UPLINK, PDCP_NR_DIRECTION_UPLINK_STR },
744     { PDCP_NR_DIRECTION_DOWNLINK, "DL" },
745     { 0, NULL }
746 };
747 
748 /* Value sets for each drop-down list in the GUI */
749 #define PDCP_NR_SDAP_HEADER_NOT_PRESENT_STR "SDAP header NOT present"
750 #define PDCP_NR_SDAP_HEADER_NOT_PRESENT 0
751 #define PDCP_NR_SDAP_HEADER_PRESENT 1
752 static const value_string vs_sdap_header_present[] = {
753     { 0, PDCP_NR_SDAP_HEADER_NOT_PRESENT_STR },
754     { 1, "SDAP header present" },
755     { 0, NULL }
756 };
757 
758 #define PDCP_LTE_HEADER_PRESENT_STR "Header present"
759 #define PDCP_LTE_HEADER_NOT_PRESENT 0
760 #define PDCP_LTE_HEADER_PRESENT 1
761 
762 static const value_string vs_header_present[] = {
763     { 0, "Header NOT present" },
764     { 1, PDCP_LTE_HEADER_PRESENT_STR },
765     { 0, NULL }
766 };
767 
768 
769 #define MAC_I_PRESENT_FALSE_STR "MAC-I NOT present"
770 static const value_string vs_mac_i_present[] = {
771     { FALSE, MAC_I_PRESENT_FALSE_STR },
772     { TRUE, "MAC-I present" },
773     { 0, NULL }
774 };
775 
776 #define USER_PLANE_STR "User plane"
777 static const value_string vs_pdcp_plane[] = {
778     { NR_SIGNALING_PLANE, "Signaling plane" },
779     { NR_USER_PLANE, USER_PLANE_STR },
780     { 0, NULL }
781 };
782 
783 static const value_string vs_pdcp_nr_sn_length[] = {
784     { PDCP_NR_SN_LENGTH_12_BITS, PDCP_SN_LENGTH_12_BITS_STR },
785     { PDCP_NR_SN_LENGTH_18_BITS, "18 bits" },
786     { 0, NULL }
787 };
788 
789 #define ROHC_COMPRESSION_FALSE_STR "RoHC NOT compressed"
790 static const value_string vs_rohc_compression[] = {
791     { FALSE, ROHC_COMPRESSION_FALSE_STR },
792     { TRUE, "RoHC compressed" },
793     { 0, NULL }
794 };
795 
796 //#define ROHC_MODE_NOT_SET_STR "Mode not set"
797 //static const value_string vs_rohc_mode[] = {
798 //    { MODE_NOT_SET, ROHC_MODE_NOT_SET_STR },
799 //    { UNIDIRECTIONAL, "Unidirectional" },
800 //    { OPTIMISTIC_BIDIRECTIONAL, "Optimistic bidirectional" },
801 //    { RELIABLE_BIDIRECTIONAL, "Reliable bidirectional" },
802 //    { 0, NULL }
803 //};
804 
805 #define ROHC_PROFILE_RTP_STR "RTP (1)"
806 #define ROHC_PROFILE_UNCOMPRESSED_STR "Uncompressed (0)"
807 static const value_string vs_rohc_profile[] = {
808     { ROHC_PROFILE_UNCOMPRESSED, ROHC_PROFILE_UNCOMPRESSED_STR },
809     { ROHC_PROFILE_RTP, ROHC_PROFILE_RTP_STR },
810     { ROHC_PROFILE_UDP, "UDP (2)" },
811     { ROHC_PROFILE_IP, "IP (4)" },
812     { ROHC_PROFILE_UNKNOWN, "Unknown" },
813     { 0, NULL }
814 };
815 
816 /* Entries added by UAT */
817 static uat_t * pdcp_nr_keys_uat = NULL;
818 static guint num_pdcp_nr_keys_uat = 0;
819 
820 /* Default values for a TEID entry */
UAT_CSTRING_CB_DEF(pdcp_nr_users,ip_addr_str,uat_pdcp_nr_keys_record_t)821 UAT_CSTRING_CB_DEF(pdcp_nr_users, ip_addr_str, uat_pdcp_nr_keys_record_t)
822 UAT_CSTRING_CB_DEF(pdcp_nr_users, teid_str, uat_pdcp_nr_keys_record_t)
823 UAT_VS_DEF(pdcp_nr_users, direction, uat_pdcp_nr_keys_record_t, guint, PDCP_NR_DIRECTION_UPLINK, PDCP_NR_DIRECTION_UPLINK_STR)
824 UAT_VS_DEF(pdcp_nr_users, sdap_header_present, uat_pdcp_nr_keys_record_t, guint, PDCP_NR_SDAP_HEADER_NOT_PRESENT, PDCP_NR_SDAP_HEADER_NOT_PRESENT_STR)
825 UAT_VS_DEF(pdcp_nr_users, mac_i_present, uat_pdcp_nr_keys_record_t, guint, FALSE, MAC_I_PRESENT_FALSE_STR)
826 UAT_VS_DEF(pdcp_nr_users, plane, uat_pdcp_nr_keys_record_t, enum pdcp_nr_plane, NR_USER_PLANE, USER_PLANE_STR)
827 UAT_VS_DEF(pdcp_nr_users, pdcp_nr_sn_length, uat_pdcp_nr_keys_record_t, guint, PDCP_NR_SN_LENGTH_12_BITS, PDCP_SN_LENGTH_12_BITS_STR)
828 UAT_VS_DEF(pdcp_nr_users, rohc_compression, uat_pdcp_nr_keys_record_t, guint, FALSE, ROHC_COMPRESSION_FALSE_STR)
829 //UAT_VS_DEF(pdcp_nr_users, rohc_mode, uat_pdcp_nr_keys_record_t, guint, MODE_NOT_SET, ROHC_MODE_NOT_SET_STR)
830 UAT_VS_DEF(pdcp_nr_users, rohc_profile, uat_pdcp_nr_keys_record_t, guint, ROHC_PROFILE_UNCOMPRESSED, ROHC_PROFILE_UNCOMPRESSED_STR)
831 
832 static uat_pdcp_nr_keys_record_t* look_up_pdcp_nr_keys_record(packet_info *pinfo, guint32 teidn)
833 {
834     unsigned int record_id;
835 
836     /* Look up UAT entries. N.B. linear search... */
837     for (record_id = 0; record_id < num_pdcp_nr_keys_uat; record_id++) {
838         if (addresses_equal(&uat_pdcp_nr_keys_records[record_id].ip_address, &pinfo->dst) &&
839             (uat_pdcp_nr_keys_records[record_id].teid_wildcard ||
840              uat_pdcp_nr_keys_records[record_id].teid == teidn)) {
841             return &uat_pdcp_nr_keys_records[record_id];
842         }
843     }
844 
845     /* No match at all - return NULL */
846     return NULL;
847 }
848 
849 /* Entries added by UAT */
850 static uat_t * pdcp_lte_keys_uat = NULL;
851 static guint num_pdcp_lte_keys_uat = 0;
852 
853 /* Default values for a TEID entry */
UAT_CSTRING_CB_DEF(pdcp_lte_users,ip_addr_str,uat_pdcp_lte_keys_record_t)854 UAT_CSTRING_CB_DEF(pdcp_lte_users, ip_addr_str, uat_pdcp_lte_keys_record_t)
855 UAT_CSTRING_CB_DEF(pdcp_lte_users, teid_str, uat_pdcp_lte_keys_record_t)
856 UAT_VS_DEF(pdcp_lte_users, header_present, uat_pdcp_lte_keys_record_t, guint, PDCP_LTE_HEADER_PRESENT, PDCP_LTE_HEADER_PRESENT_STR)
857 UAT_VS_DEF(pdcp_lte_users, plane, uat_pdcp_lte_keys_record_t, enum pdcp_plane, USER_PLANE, USER_PLANE_STR)
858 UAT_VS_DEF(pdcp_lte_users, lte_sn_length, uat_pdcp_lte_keys_record_t, guint, PDCP_NR_SN_LENGTH_12_BITS, PDCP_SN_LENGTH_12_BITS_STR)
859 UAT_VS_DEF(pdcp_lte_users, rohc_compression, uat_pdcp_lte_keys_record_t, guint, FALSE, ROHC_COMPRESSION_FALSE_STR)
860 //UAT_VS_DEF(pdcp_lte_users, rohc_mode, uat_pdcp_lte_keys_record_t, guint, MODE_NOT_SET, ROHC_MODE_NOT_SET_STR)
861 UAT_VS_DEF(pdcp_lte_users, rohc_profile, uat_pdcp_lte_keys_record_t, guint, ROHC_PROFILE_UNCOMPRESSED, ROHC_PROFILE_UNCOMPRESSED_STR)
862 
863 static uat_pdcp_lte_keys_record_t* look_up_pdcp_lte_keys_record(packet_info *pinfo, guint32 teidn)
864 {
865     unsigned int record_id;
866 
867     /* Look up UAT entries. N.B. linear search... */
868     for (record_id = 0; record_id < num_pdcp_lte_keys_uat; record_id++) {
869         if (addresses_equal(&uat_pdcp_lte_keys_records[record_id].ip_address, &pinfo->dst) &&
870             (uat_pdcp_lte_keys_records[record_id].teid_wildcard ||
871              uat_pdcp_lte_keys_records[record_id].teid == teidn)) {
872             return &uat_pdcp_lte_keys_records[record_id];
873         }
874     }
875 
876     /* No match at all - return NULL */
877     return NULL;
878 }
879 
880 /* --- END PDCP NR DECODE ADDITIONS --- */
881 
882 static gboolean g_gtp_etsi_order = FALSE;
883 
884 static gint dissect_tpdu_as = GTP_TPDU_AS_TPDU_HEUR;
885 static const enum_val_t gtp_decode_tpdu_as[] = {
886     {"none", "None",   GTP_TPDU_AS_NONE},
887     {"tpdu heuristic", "TPDU Heuristic",   GTP_TPDU_AS_TPDU_HEUR},
888     {"pdcp-lte", "PDCP-LTE",   GTP_TPDU_AS_PDCP_LTE },
889     {"pdcp-nr", "PDCP-NR",   GTP_TPDU_AS_PDCP_NR },
890     {"sync", "SYNC",   GTP_TPDU_AS_SYNC},
891     {"eth", "ETHERNET",   GTP_TPDU_AS_ETHERNET},
892     {"custom", "Custom",   GTP_TPDU_AS_CUSTOM},
893     {NULL, NULL, 0}
894 };
895 
896 
897 static int gtp_tap = -1;
898 static int gtpv1_tap = -1;
899 
900 /* Definition of flags masks */
901 #define GTP_VER_MASK 0xE0
902 
903 static const true_false_string gtp_hdr_length_vals = {
904     "6-Octet Header",
905     "20-Octet Header"
906 };
907 
908 static const value_string ver_types[] = {
909     {0, "GTP release 97/98 version"},
910     {1, "GTP release 99 version"},
911     {2, "GTPv2-C"},
912     {3, "None"},
913     {4, "None"},
914     {5, "None"},
915     {6, "None"},
916     {7, "None"},
917     {0, NULL}
918 };
919 
920 static const value_string pt_types[] = {
921     {0, "GTP'"},
922     {1, "GTP"},
923     {0, NULL}
924 };
925 
926 #define GTP_PT_MASK         0x10
927 #define GTP_SPARE1_MASK     0x0E
928 #define GTP_SPARE2_MASK     0x08
929 #define GTP_E_MASK          0x04
930 #define GTP_S_MASK          0x02
931 #define GTP_SNN_MASK        0x01
932 #define GTP_PN_MASK         0x01
933 
934 #define GTP_EXT_HDR_NO_MORE_EXT_HDRS         0x00
935 #define GTP_EXT_HDR_MBMS_SUPPORT_IND         0x01
936 #define GTP_EXT_HDR_MS_INFO_CHG_REP_SUPP_IND 0x02
937 #define GTP_EXT_HDR_LONG_PDCP_PDU_NUMBER     0x03 /* TS 29.281 (GTPv1-U)*/
938 #define GTP_EXT_HDR_SERVICE_CLASS_INDICATOR  0x20 /* TS 29.281 (GTPv1-U)*/
939 #define GTP_EXT_HDR_UDP_PORT                 0x40
940 #define GTP_EXT_HDR_RAN_CONT                 0x81
941 #define GTP_EXT_HDR_LONG_PDCP_PDU            0x82
942 #define GTP_EXT_HDR_XW_RAN_CONT              0x83
943 #define GTP_EXT_HDR_NR_RAN_CONT              0x84
944 #define GTP_EXT_HDR_PDU_SESSION_CONT         0x85
945 #define GTP_EXT_HDR_PDCP_SN                  0xC0
946 #define GTP_EXT_HDR_SUSPEND_REQ              0xC1
947 #define GTP_EXT_HDR_SUSPEND_RESP             0xC2
948 
949 static const value_string next_extension_header_fieldvals[] = {
950     {GTP_EXT_HDR_NO_MORE_EXT_HDRS, "No more extension headers"},
951     {GTP_EXT_HDR_MBMS_SUPPORT_IND, "MBMS support indication"},
952     {GTP_EXT_HDR_MS_INFO_CHG_REP_SUPP_IND, "MS Info Change Reporting support indication"},
953     {GTP_EXT_HDR_LONG_PDCP_PDU_NUMBER, "Long PDCP PDU Number"},
954     {GTP_EXT_HDR_SERVICE_CLASS_INDICATOR, "Service Class Indicator"},
955     {GTP_EXT_HDR_UDP_PORT, "UDP Port number"},
956     {GTP_EXT_HDR_RAN_CONT,"RAN container"},
957     {GTP_EXT_HDR_LONG_PDCP_PDU,"Long PDCP PDU number"},
958     {GTP_EXT_HDR_XW_RAN_CONT,"Xw RAN container"},
959     {GTP_EXT_HDR_NR_RAN_CONT,"NR RAN container"},
960     {GTP_EXT_HDR_PDU_SESSION_CONT,"PDU Session container"},
961     {GTP_EXT_HDR_PDCP_SN, "PDCP PDU number"},
962     {GTP_EXT_HDR_SUSPEND_REQ, "Suspend Request"},
963     {GTP_EXT_HDR_SUSPEND_RESP, "Suspend Response"},
964     {0, NULL}
965 };
966 
967 /* Definition of 3G charging characteristics masks */
968 #define GTP_MASK_CHRG_CHAR_S    0xF000
969 #define GTP_MASK_CHRG_CHAR_N    0x0800
970 #define GTP_MASK_CHRG_CHAR_P    0x0400
971 #define GTP_MASK_CHRG_CHAR_F    0x0200
972 #define GTP_MASK_CHRG_CHAR_H    0x0100
973 #define GTP_MASK_CHRG_CHAR_R    0x00FF
974 
975 /* Definition of GSN Address masks */
976 #define GTP_EXT_GSN_ADDR_TYPE_MASK      0xC0
977 #define GTP_EXT_GSN_ADDR_LEN_MASK       0x3F
978 
979 /* Definition of QoS masks */
980 #define GTP_EXT_QOS_SPARE1_MASK                 0xC0
981 #define GTP_EXT_QOS_DELAY_MASK                  0x38
982 #define GTP_EXT_QOS_RELIABILITY_MASK            0x07
983 #define GTP_EXT_QOS_PEAK_MASK                   0xF0
984 #define GTP_EXT_QOS_SPARE2_MASK                 0x08
985 #define GTP_EXT_QOS_PRECEDENCE_MASK             0x07
986 #define GTP_EXT_QOS_SPARE3_MASK                 0xE0
987 #define GTP_EXT_QOS_MEAN_MASK                   0x1F
988 #define GTP_EXT_QOS_TRAF_CLASS_MASK             0xE0
989 #define GTP_EXT_QOS_DEL_ORDER_MASK              0x18
990 #define GTP_EXT_QOS_DEL_ERR_SDU_MASK            0x07
991 #define GTP_EXT_QOS_RES_BER_MASK                0xF0
992 #define GTP_EXT_QOS_SDU_ERR_RATIO_MASK          0x0F
993 #define GTP_EXT_QOS_TRANS_DELAY_MASK            0xFC
994 #define GTP_EXT_QOS_TRAF_HANDL_PRIORITY_MASK    0x03
995 #define GTP_EXT_QOS_SPARE4_MASK                 0xE0
996 #define GTP_EXT_QOS_SIG_IND_MASK                0x10
997 #define GTP_EXT_QOS_SRC_STAT_DESC_MASK          0x0F
998 
999 /* Definition of Radio Priority's masks */
1000 #define GTPv1_EXT_RP_NSAPI_MASK         0xF0
1001 #define GTPv1_EXT_RP_SPARE_MASK         0x08
1002 #define GTPv1_EXT_RP_MASK               0x07
1003 
1004 #define NR_UP_DL_USER_DATA                0
1005 #define NR_UP_DL_DATA_DELIVERY_STATUS     1
1006 #define NR_UP_ASSISTANCE_INFORMATION_DATA 2
1007 
1008 static const value_string nr_pdu_type_cnst[] = {
1009     {NR_UP_DL_USER_DATA,                "DL User Data"},
1010     {NR_UP_DL_DATA_DELIVERY_STATUS,     "DL Data Delivery Status"},
1011     {NR_UP_ASSISTANCE_INFORMATION_DATA, "Assistance Information Data"},
1012     {0, NULL}
1013 };
1014 
1015 static const range_string nr_up_cause_vals[] = {
1016     {0,   0,     "Unknown"},
1017     {1,   1,     "Radio Link Outage"},
1018     {2,   2,     "Radio Link Resume"},
1019     {3,   3,     "UL Radio Link Outage"},
1020     {4,   4,     "DL Radio Link Outage"},
1021     {5,   5,     "UL Radio Link Resume"},
1022     {6,   6,     "DL Radio Link Resume"},
1023     {7,   228,   "Reserved for future value extensions"},
1024     {228, 255,   "Reserved for test purposes"},
1025     {0,   0,     NULL}
1026 };
1027 
1028 
1029 static const true_false_string tfs_final_frame_indication = {
1030     "Frame is final",
1031     "Frame is not final"
1032 };
1033 
1034 
1035 static const value_string gtp_message_type[] = {
1036     {GTP_MSG_UNKNOWN,             "For future use"},
1037     {GTP_MSG_ECHO_REQ,            "Echo request"},
1038     {GTP_MSG_ECHO_RESP,           "Echo response"},
1039     {GTP_MSG_VER_NOT_SUPP,        "Version not supported"},
1040     {GTP_MSG_NODE_ALIVE_REQ,      "Node alive request"},
1041     {GTP_MSG_NODE_ALIVE_RESP,     "Node alive response"},
1042     {GTP_MSG_REDIR_REQ,           "Redirection request"},
1043     {GTP_MSG_REDIR_RESP,          "Redirection response"},
1044     /*
1045      * 8-15 For future use. Shall not be sent. If received,
1046      * shall be treated as an Unknown message.
1047      */
1048 #if 0
1049     {   8,                              "Unknown message(For future use)"},
1050     {   9,                              "Unknown message(For future use)"},
1051     {  10,                              "Unknown message(For future use)"},
1052     {  11,                              "Unknown message(For future use)"},
1053     {  12,                              "Unknown message(For future use)"},
1054     {  13,                              "Unknown message(For future use)"},
1055     {  14,                              "Unknown message(For future use)"},
1056     {  15,                              "Unknown message(For future use)"},
1057 #endif
1058     {GTP_MSG_CREATE_PDP_REQ,            "Create PDP context request"},
1059     {GTP_MSG_CREATE_PDP_RESP,           "Create PDP context response"},
1060     {GTP_MSG_UPDATE_PDP_REQ,            "Update PDP context request"},
1061     {GTP_MSG_UPDATE_PDP_RESP,           "Update PDP context response"},
1062     {GTP_MSG_DELETE_PDP_REQ,            "Delete PDP context request"},
1063     {GTP_MSG_DELETE_PDP_RESP,           "Delete PDP context response"},
1064     {GTP_MSG_INIT_PDP_CONTEXT_ACT_REQ,  "Initiate PDP Context Activation Request"},
1065     {GTP_MSG_INIT_PDP_CONTEXT_ACT_RESP, "Initiate PDP Context Activation Response"},
1066 /*
1067  * 24-25 For future use. Shall not be sent. If received,
1068  * shall be treated as an Unknown message.
1069  */
1070     {GTP_MSG_DELETE_AA_PDP_REQ,   "Delete AA PDP Context Request"},
1071     {GTP_MSG_DELETE_AA_PDP_RESP,  "Delete AA PDP Context Response"},
1072     {GTP_MSG_ERR_IND,             "Error indication"},
1073     {GTP_MSG_PDU_NOTIFY_REQ,      "PDU notification request"},
1074     {GTP_MSG_PDU_NOTIFY_RESP,     "PDU notification response"},
1075     {GTP_MSG_PDU_NOTIFY_REJ_REQ,  "PDU notification reject request"},
1076     {GTP_MSG_PDU_NOTIFY_REJ_RESP, "PDU notification reject response"},
1077     {GTP_MSG_SUPP_EXT_HDR,        "Supported extension header notification"},
1078     {GTP_MSG_SEND_ROUT_INFO_REQ,  "Send routing information for GPRS request"},
1079     {GTP_MSG_SEND_ROUT_INFO_RESP, "Send routing information for GPRS response"},
1080     {GTP_MSG_FAIL_REP_REQ,        "Failure report request"},
1081     {GTP_MSG_FAIL_REP_RESP,       "Failure report response"},
1082     {GTP_MSG_MS_PRESENT_REQ,      "Note MS GPRS present request"},
1083     {GTP_MSG_MS_PRESENT_RESP,     "Note MS GPRS present response"},
1084     /* 38-47 For future use. Shall not be sent. If received,
1085      * shall be treated as an Unknown message.
1086      */
1087 #if 0
1088     {  38,                        "Unknown message(For future use)"},
1089     {  39,                        "Unknown message(For future use)"},
1090     {  40,                        "Unknown message(For future use)"},
1091     {  41,                        "Unknown message(For future use)"},
1092     {  42,                        "Unknown message(For future use)"},
1093     {  43,                        "Unknown message(For future use)"},
1094     {  44,                        "Unknown message(For future use)"},
1095     {  45,                        "Unknown message(For future use)"},
1096     {  46,                        "Unknown message(For future use)"},
1097     {  47,                        "Unknown message(For future use)"},
1098 #endif
1099     {GTP_MSG_IDENT_REQ,           "Identification request"},
1100     {GTP_MSG_IDENT_RESP,          "Identification response"},
1101     {GTP_MSG_SGSN_CNTXT_REQ,      "SGSN context request"},
1102     {GTP_MSG_SGSN_CNTXT_RESP,     "SGSN context response"},
1103     {GTP_MSG_SGSN_CNTXT_ACK,      "SGSN context acknowledgement"},
1104     {GTP_MSG_FORW_RELOC_REQ,      "Forward relocation request"},
1105     {GTP_MSG_FORW_RELOC_RESP,     "Forward relocation response"},
1106     {GTP_MSG_FORW_RELOC_COMP,     "Forward relocation complete"},
1107     {GTP_MSG_RELOC_CANCEL_REQ,    "Relocation cancel request"},
1108     {GTP_MSG_RELOC_CANCEL_RESP,   "Relocation cancel response"},
1109     {GTP_MSG_FORW_SRNS_CNTXT,     "Forward SRNS context"},
1110     {GTP_MSG_FORW_RELOC_ACK,      "Forward relocation complete acknowledge"},
1111     {GTP_MSG_FORW_SRNS_CNTXT_ACK, "Forward SRNS context acknowledge"},
1112     /* 61-69 For future use. Shall not be sent. If received,
1113      * shall be treated as an Unknown message.
1114      */
1115 #if 0
1116     {  61,                        "Unknown message(For future use)"},
1117     {  62,                        "Unknown message(For future use)"},
1118     {  63,                        "Unknown message(For future use)"},
1119     {  64,                        "Unknown message(For future use)"},
1120     {  65,                        "Unknown message(For future use)"},
1121     {  66,                        "Unknown message(For future use)"},
1122     {  67,                        "Unknown message(For future use)"},
1123     {  68,                        "Unknown message(For future use)"},
1124     {  69,                        "Unknown message(For future use)"},
1125 #endif
1126     {GTP_MSG_RAN_INFO_RELAY,      "RAN Information Relay"},
1127     /* 71-95 For future use. Shall not be sent. If received,
1128      * shall be treated as an Unknown message.
1129      */
1130 #if 0
1131     {  71,                        "Unknown message(For future use)"},
1132     {  72,                        "Unknown message(For future use)"},
1133     {  73,                        "Unknown message(For future use)"},
1134     {  74,                        "Unknown message(For future use)"},
1135     {  75,                        "Unknown message(For future use)"},
1136     {  76,                        "Unknown message(For future use)"},
1137     {  77,                        "Unknown message(For future use)"},
1138     {  78,                        "Unknown message(For future use)"},
1139     {  79,                        "Unknown message(For future use)"},
1140     {  80,                        "Unknown message(For future use)"},
1141     {  81,                        "Unknown message(For future use)"},
1142     {  82,                        "Unknown message(For future use)"},
1143     {  83,                        "Unknown message(For future use)"},
1144     {  84,                        "Unknown message(For future use)"},
1145     {  85,                        "Unknown message(For future use)"},
1146     {  86,                        "Unknown message(For future use)"},
1147     {  87,                        "Unknown message(For future use)"},
1148     {  88,                        "Unknown message(For future use)"},
1149     {  89,                        "Unknown message(For future use)"},
1150     {  90,                        "Unknown message(For future use)"},
1151     {  91,                        "Unknown message(For future use)"},
1152     {  92,                        "Unknown message(For future use)"},
1153     {  93,                        "Unknown message(For future use)"},
1154     {  94,                        "Unknown message(For future use)"},
1155     {  95,                        "Unknown message(For future use)"},
1156 #endif
1157     {GTP_MBMS_NOTIFY_REQ,         "MBMS Notification Request"},
1158     {GTP_MBMS_NOTIFY_RES,         "MBMS Notification Response"},
1159     {GTP_MBMS_NOTIFY_REJ_REQ,     "MBMS Notification Reject Request"},
1160     {GTP_MBMS_NOTIFY_REJ_RES,     "MBMS Notification Reject Response"},
1161     {GTP_CREATE_MBMS_CNTXT_REQ,   "Create MBMS Context Request"},
1162     {GTP_CREATE_MBMS_CNTXT_RES,   "Create MBMS Context Response"},
1163     {GTP_UPD_MBMS_CNTXT_REQ,      "Update MBMS Context Request"},
1164     {GTP_UPD_MBMS_CNTXT_RES,      "Update MBMS Context Response"},
1165     {GTP_DEL_MBMS_CNTXT_REQ,      "Delete MBMS Context Request"},
1166     {GTP_DEL_MBMS_CNTXT_RES,      "Delete MBMS Context Response"},
1167     /* 106 - 111 For future use. Shall not be sent. If received,
1168      * shall be treated as an Unknown message.
1169      */
1170 #if 0
1171     {  106,                       "Unknown message(For future use)"},
1172     {  107,                       "Unknown message(For future use)"},
1173     {  108,                       "Unknown message(For future use)"},
1174     {  109,                       "Unknown message(For future use)"},
1175     {  110,                       "Unknown message(For future use)"},
1176     {  111,                       "Unknown message(For future use)"},
1177 #endif
1178     {GTP_MBMS_REG_REQ,            "MBMS Registration Request"},
1179     {GTP_MBMS_REG_RES,            "MBMS Registration Response"},
1180     {GTP_MBMS_DE_REG_REQ,         "MBMS De-Registration Request"},
1181     {GTP_MBMS_DE_REG_RES,         "MBMS De-Registration Response"},
1182     {GTP_MBMS_SES_START_REQ,      "MBMS Session Start Request"},
1183     {GTP_MBMS_SES_START_RES,      "MBMS Session Start Response"},
1184     {GTP_MBMS_SES_STOP_REQ,       "MBMS Session Stop Request"},
1185     {GTP_MBMS_SES_STOP_RES,       "MBMS Session Stop Response"},
1186     {GTP_MBMS_SES_UPD_REQ,        "MBMS Session Update Request"},
1187     {GTP_MBMS_SES_UPD_RES,        "MBMS Session Update Response"},
1188     /* 122-127 For future use. Shall not be sent.
1189      * If received, shall be treated as an Unknown message.
1190      */
1191 #if 0
1192     {  122,                       "Unknown message(For future use)"},
1193     {  123,                       "Unknown message(For future use)"},
1194     {  124,                       "Unknown message(For future use)"},
1195     {  125,                       "Unknown message(For future use)"},
1196     {  126,                       "Unknown message(For future use)"},
1197     {  127,                       "Unknown message(For future use)"},
1198 #endif
1199     {GTP_MS_INFO_CNG_NOT_REQ,     "MS Info Change Notification Request"},
1200     {GTP_MS_INFO_CNG_NOT_RES,     "MS Info Change Notification Response"},
1201     /* 130-239 For future use. Shall not be sent. If received,
1202      * shall be treated as an Unknown message.
1203      */
1204 #if 0
1205     {  130,                       "Unknown message(For future use)"},
1206     {  131,                       "Unknown message(For future use)"},
1207     {  132,                       "Unknown message(For future use)"},
1208     {  133,                       "Unknown message(For future use)"},
1209     {  134,                       "Unknown message(For future use)"},
1210     {  135,                       "Unknown message(For future use)"},
1211     {  136,                       "Unknown message(For future use)"},
1212     {  137,                       "Unknown message(For future use)"},
1213     {  138,                       "Unknown message(For future use)"},
1214     {  139,                       "Unknown message(For future use)"},
1215     {  140,                       "Unknown message(For future use)"},
1216     {  141,                       "Unknown message(For future use)"},
1217     {  142,                       "Unknown message(For future use)"},
1218     {  143,                       "Unknown message(For future use)"},
1219     {  144,                       "Unknown message(For future use)"},
1220     {  145,                       "Unknown message(For future use)"},
1221     {  146,                       "Unknown message(For future use)"},
1222     {  147,                       "Unknown message(For future use)"},
1223     {  148,                       "Unknown message(For future use)"},
1224     {  149,                       "Unknown message(For future use)"},
1225     {  150,                       "Unknown message(For future use)"},
1226     {  151,                       "Unknown message(For future use)"},
1227     {  152,                       "Unknown message(For future use)"},
1228     {  153,                       "Unknown message(For future use)"},
1229     {  154,                       "Unknown message(For future use)"},
1230     {  155,                       "Unknown message(For future use)"},
1231     {  156,                       "Unknown message(For future use)"},
1232     {  157,                       "Unknown message(For future use)"},
1233     {  158,                       "Unknown message(For future use)"},
1234     {  159,                       "Unknown message(For future use)"},
1235 #endif
1236     {GTP_MSG_DATA_TRANSF_REQ,     "Data record transfer request"},
1237     {GTP_MSG_DATA_TRANSF_RESP,    "Data record transfer response"},
1238     /* 242-253 For future use. Shall not be sent. If received,
1239      * shall be treated as an Unknown message.
1240      */
1241 #if 0
1242     {  242,                       "Unknown message(For future use)"},
1243     {  243,                       "Unknown message(For future use)"},
1244     {  244,                       "Unknown message(For future use)"},
1245     {  245,                       "Unknown message(For future use)"},
1246     {  246,                       "Unknown message(For future use)"},
1247     {  247,                       "Unknown message(For future use)"},
1248     {  248,                       "Unknown message(For future use)"},
1249     {  249,                       "Unknown message(For future use)"},
1250     {  250,                       "Unknown message(For future use)"},
1251     {  251,                       "Unknown message(For future use)"},
1252     {  252,                       "Unknown message(For future use)"},
1253     {  253,                       "Unknown message(For future use)"},
1254 #endif
1255     {GTP_MSG_END_MARKER,          "End Marker"},
1256     {GTP_MSG_TPDU,                "T-PDU"},
1257     {0, NULL}
1258 };
1259 static value_string_ext gtp_message_type_ext = VALUE_STRING_EXT_INIT(gtp_message_type);
1260 
1261 /* definitions of fields in extension header */
1262 #define GTP_EXT_CAUSE                 0x01
1263 #define GTP_EXT_IMSI                  0x02
1264 #define GTP_EXT_RAI                   0x03
1265 #define GTP_EXT_TLLI                  0x04
1266 #define GTP_EXT_PTMSI                 0x05
1267 #define GTP_EXT_QOS_GPRS              0x06
1268 #define GTP_EXT_REORDER               0x08
1269 #define GTP_EXT_AUTH_TRI              0x09
1270 #define GTP_EXT_MAP_CAUSE             0x0B
1271 #define GTP_EXT_PTMSI_SIG             0x0C
1272 #define GTP_EXT_MS_VALID              0x0D
1273 #define GTP_EXT_RECOVER               0x0E
1274 #define GTP_EXT_SEL_MODE              0x0F
1275 
1276 #define GTP_EXT_16                    0x10
1277 #define GTP_EXT_FLOW_LABEL            0x10
1278 #define GTP_EXT_TEID                  0x10    /* 0xFF10 3G */
1279 
1280 #define GTP_EXT_17                    0x11
1281 #define GTP_EXT_FLOW_SIG              0x11
1282 #define GTP_EXT_TEID_CP               0x11    /* 0xFF11 3G */
1283 
1284 #define GTP_EXT_18                    0x12
1285 #define GTP_EXT_FLOW_II               0x12
1286 #define GTP_EXT_TEID_II               0x12    /* 0xFF12 3G */
1287 
1288 #define GTP_EXT_19                    0x13    /* 19 TV Teardown Ind 7.7.16 */
1289 #define GTP_EXT_MS_REASON             0x13    /* same as 0x1D GTPv1_EXT_MS_REASON */
1290 #define GTP_EXT_TEAR_IND              0x13    /* 0xFF13 3G */
1291 
1292 #define GTP_EXT_NSAPI                 0x14    /* 3G */
1293 #define GTP_EXT_RANAP_CAUSE           0x15    /* 3G */
1294 #define GTP_EXT_RAB_CNTXT             0x16    /* 3G */
1295 #define GTP_EXT_RP_SMS                0x17    /* 3G */
1296 #define GTP_EXT_RP                    0x18    /* 3G */
1297 #define GTP_EXT_PKT_FLOW_ID           0x19    /* 3G */
1298 #define GTP_EXT_CHRG_CHAR             0x1A    /* 3G */
1299 #define GTP_EXT_TRACE_REF             0x1B    /* 3G */
1300 #define GTP_EXT_TRACE_TYPE            0x1C    /* 3G */
1301 #define GTPv1_EXT_MS_REASON           0x1D    /* 3G 29 TV MS Not Reachable Reason 7.7.25A */
1302 /* 117-126 Reserved for the GPRS charging protocol (see GTP' in 3GPP TS 32.295 [33]) */
1303 #define GTP_EXT_TR_COMM               0x7E    /* charging */
1304 #define GTP_EXT_CHRG_ID               0x7F    /* 127 TV Charging ID 7.7.26 */
1305 #define GTP_EXT_USER_ADDR             0x80
1306 #define GTP_EXT_MM_CNTXT              0x81
1307 #define GTP_EXT_PDP_CNTXT             0x82
1308 #define GTP_EXT_APN                   0x83
1309 #define GTP_EXT_PROTO_CONF            0x84
1310 #define GTP_EXT_GSN_ADDR              0x85
1311 #define GTP_EXT_MSISDN                0x86
1312 #define GTP_EXT_QOS_UMTS              0x87    /* 3G */
1313 #define GTP_EXT_AUTH_QUI              0x88    /* 3G */
1314 #define GTP_EXT_TFT                   0x89    /* 3G */
1315 #define GTP_EXT_TARGET_ID             0x8A    /* 3G */
1316 #define GTP_EXT_UTRAN_CONT            0x8B    /* 3G */
1317 #define GTP_EXT_RAB_SETUP             0x8C    /* 3G */
1318 #define GTP_EXT_HDR_LIST              0x8D    /* 3G */
1319 #define GTP_EXT_TRIGGER_ID            0x8E    /* 3G   142 7.7.41 */
1320 #define GTP_EXT_OMC_ID                0x8F    /* 3G   143 TLV OMC Identity 7.7.42 */
1321 #define GTP_EXT_RAN_TR_CONT           0x90    /* 3G   144 TLV RAN Transparent Container 7.7.43 */
1322 #define GTP_EXT_PDP_CONT_PRIO         0x91    /* 3G   145 TLV PDP Context Prioritization 7.7.45 */
1323 #define GTP_EXT_ADD_RAB_SETUP_INF     0x92    /* 3G   146 TLV Additional RAB Setup Information 7.7.45A */
1324 #define GTP_EXT_SGSN_NO               0x93    /* 3G   147 TLV SGSN Number 7.7.47 */
1325 #define GTP_EXT_COMMON_FLGS           0x94    /* 3G   148 TLV Common Flags 7.7.48 */
1326 #define GTP_EXT_APN_RES               0x95    /* 3G   149 */
1327 #define GTP_EXT_RA_PRIO_LCS           0x96    /* 3G   150 TLV Radio Priority LCS 7.7.25B */
1328 #define GTP_EXT_RAT_TYPE              0x97    /* 3G   151 TLV RAT Type 7.7.50 */
1329 #define GTP_EXT_USR_LOC_INF           0x98    /* 3G   152 TLV User Location Information 7.7.51 */
1330 #define GTP_EXT_MS_TIME_ZONE          0x99    /* 3G   153 TLV MS Time Zone 7.7.52 */
1331 #define GTP_EXT_IMEISV                0x9A    /* 3G   154 TLV IMEI(SV) 7.7.53 */
1332 #define GTP_EXT_CAMEL_CHG_INF_CON     0x9B    /* 3G   155 TLV CAMEL Charging Information Container 7.7.54 */
1333 #define GTP_EXT_MBMS_UE_CTX           0x9C    /* 3G   156 TLV MBMS UE Context 7.7.55 */
1334 #define GTP_EXT_TMGI                  0x9D    /* 3G   157 TLV Temporary Mobile Group Identity (TMGI) 7.7.56 */
1335 #define GTP_EXT_RIM_RA                0x9E    /* 3G   158 TLV RIM Routing Address 7.7.57 */
1336 #define GTP_EXT_MBMS_PROT_CONF_OPT    0x9F    /* 3G   159 TLV MBMS Protocol Configuration Options 7.7.58 */
1337 #define GTP_EXT_MBMS_SA               0xA0    /* 3G   160 TLV MBMS Service Area 7.7.60 */
1338 #define GTP_EXT_SRC_RNC_PDP_CTX_INF   0xA1    /* 3G   161 TLV Source RNC PDCP context info 7.7.61 */
1339 #define GTP_EXT_ADD_TRS_INF           0xA2    /* 3G   162 TLV Additional Trace Info 7.7.62 */
1340 #define GTP_EXT_HOP_COUNT             0xA3    /* 3G   163 TLV Hop Counter 7.7.63 */
1341 #define GTP_EXT_SEL_PLMN_ID           0xA4    /* 3G   164 TLV Selected PLMN ID 7.7.64 */
1342 #define GTP_EXT_MBMS_SES_ID           0xA5    /* 3G   165 TLV MBMS Session Identifier 7.7.65 */
1343 #define GTP_EXT_MBMS_2G_3G_IND        0xA6    /* 3G   166 TLV MBMS 2G/3G Indicator 7.7.66 */
1344 #define GTP_EXT_ENH_NSAPI             0xA7    /* 3G   167 TLV Enhanced NSAPI 7.7.67 */
1345 #define GTP_EXT_MBMS_SES_DUR          0xA8    /* 3G   168 TLV MBMS Session Duration 7.7.59 */
1346 #define GTP_EXT_ADD_MBMS_TRS_INF      0xA9    /* 3G   169 TLV Additional MBMS Trace Info 7.7.68 */
1347 #define GTP_EXT_MBMS_SES_ID_REP_NO    0xAA    /* 3G   170 TLV MBMS Session Identity Repetition Number 7.7.69 */
1348 #define GTP_EXT_MBMS_TIME_TO_DATA_TR  0xAB    /* 3G   171 TLV MBMS Time To Data Transfer 7.7.70 */
1349 #define GTP_EXT_PS_HO_REQ_CTX         0xAC    /* 3G   172 TLV PS Handover Request Context 7.7.71 */
1350 #define GTP_EXT_BSS_CONT              0xAD    /* 3G   173 TLV BSS Container 7.7.72 */
1351 #define GTP_EXT_CELL_ID               0xAE    /* 3G   174 TLV Cell Identification 7.7.73 */
1352 #define GTP_EXT_PDU_NO                0xAF    /* 3G   175 TLV PDU Numbers                               7.7.74 */
1353 #define GTP_EXT_BSSGP_CAUSE           0xB0    /* 3G   176 TLV BSSGP Cause                               7.7.75 */
1354 #define GTP_EXT_REQ_MBMS_BEARER_CAP   0xB1    /* 3G   177 TLV Required MBMS bearer capabilities         7.7.76 */
1355 #define GTP_EXT_RIM_ROUTING_ADDR_DISC 0xB2    /* 3G   178 TLV RIM Routing Address Discriminator         7.7.77 */
1356 #define GTP_EXT_LIST_OF_SETUP_PFCS    0xB3    /* 3G   179 TLV List of set-up PFCs                       7.7.78 */
1357 #define GTP_EXT_PS_HANDOVER_XIP_PAR   0xB4    /* 3G   180 TLV PS Handover XID Parameters                7.7.79 */
1358 #define GTP_EXT_MS_INF_CHG_REP_ACT    0xB5    /* 3G   181 TLV MS Info Change Reporting Action           7.7.80 */
1359 #define GTP_EXT_DIRECT_TUNNEL_FLGS    0xB6    /* 3G   182 TLV Direct Tunnel Flags                       7.7.81 */
1360 #define GTP_EXT_CORRELATION_ID        0xB7    /* 3G   183 TLV Correlation-ID                            7.7.82 */
1361 #define GTP_EXT_BEARER_CONTROL_MODE   0xB8    /* 3G   184 TLV Bearer Control Mode                       7.7.83 */
1362 #define GTP_EXT_MBMS_FLOW_ID          0xB9    /* 3G   185 TLV MBMS Flow Identifier                      7.7.84 */
1363 #define GTP_EXT_MBMS_IP_MCAST_DIST    0xBA    /* 3G   186 TLV MBMS IP Multicast Distribution            7.7.85 */
1364 #define GTP_EXT_MBMS_DIST_ACK         0xBB    /* 3G   187 TLV MBMS Distribution Acknowledgement         7.7.86 */
1365 #define GTP_EXT_RELIABLE_IRAT_HO_INF  0xBC    /* 3G   188 TLV Reliable INTER RAT HANDOVER INFO          7.7.87 */
1366 #define GTP_EXT_RFSP_INDEX            0xBD    /* 3G   189 TLV RFSP Index                                7.7.88 */
1367 #define GTP_EXT_FQDN                  0xBE    /* 3G   190 TLV Fully Qualified Domain Name (FQDN)        7.7.90 */
1368 #define GTP_EXT_EVO_ALLO_RETE_P1      0xBF    /* 3G   191 TLV Evolved Allocation/Retention Priority I   7.7.91 */
1369 #define GTP_EXT_EVO_ALLO_RETE_P2      0xC0    /* 3G   192 TLV Evolved Allocation/Retention Priority II  7.7.92 */
1370 #define GTP_EXT_EXTENDED_COMMON_FLGS  0xC1    /* 3G   193 TLV Extended Common Flags                     7.7.93 */
1371 #define GTP_EXT_UCI                   0xC2    /* 3G   194 TLV User CSG Information (UCI)                7.7.94 */
1372 #define GTP_EXT_CSG_INF_REP_ACT       0xC3    /* 3G   195 TLV CSG Information Reporting Action          7.7.95 */
1373 #define GTP_EXT_CSG_ID                0xC4    /* 3G   196 TLV CSG ID                                    7.7.96 */
1374 #define GTP_EXT_CMI                   0xC5    /* 3G   197 TLV CSG Membership Indication (CMI)           7.7.97 */
1375 #define GTP_EXT_AMBR                  0xC6    /* 3G   198 TLV Aggregate Maximum Bit Rate (AMBR)         7.7.98 */
1376 #define GTP_EXT_UE_NETWORK_CAP        0xC7    /* 3G   199 TLV UE Network Capability                     7.7.99 */
1377 #define GTP_EXT_UE_AMBR               0xC8    /* 3G   200 TLV UE-AMBR                                   7.7.100 */
1378 #define GTP_EXT_APN_AMBR_WITH_NSAPI   0xC9    /* 3G   201 TLV APN-AMBR with NSAPI                       7.7.101 */
1379 #define GTP_EXT_GGSN_BACK_OFF_TIME    0xCA    /* 3G   202 TLV GGSN Back-Off Time                        7.7.102 */
1380 #define GTP_EXT_SIG_PRI_IND           0xCB    /* 3G   203 TLV Signalling Priority Indication            7.7.103 */
1381 #define GTP_EXT_SIG_PRI_IND_W_NSAPI   0xCC    /* 3G   204 TLV Signalling Priority Indication with NSAPI 7.7.104 */
1382 #define GTP_EXT_HIGHER_BR_16MB_FLG    0xCD    /* 3G   205 TLV Higher bitrates than 16 Mbps flag         7.7.105 */
1383 #define GTP_EXT_MAX_MBR_APN_AMBR      0xCE    /* 3G   206 TLV Max MBR/APN-AMBR                          7.7.106 */
1384 #define GTP_EXT_ADD_MM_CTX_SRVCC      0xCF    /* 3G   207 TLV Additional MM context for SRVCC           7.7.107 */
1385 #define GTP_EXT_ADD_FLGS_SRVCC        0xD0    /* 3G   208 TLV Additional flags for SRVCC                7.7.108 */
1386 #define GTP_EXT_STN_SR                0xD1    /* 3G   209 TLV STN-SR                                    7.7.109 */
1387 #define GTP_EXT_C_MSISDN              0xD2    /* 3G   210 TLV C-MSISDN                                  7.7.110 */
1388 #define GTP_EXT_EXT_RANAP_CAUSE       0xD3    /* 3G   211 TLV Extended RANAP Cause                      7.7.111 */
1389 #define GTP_EXT_ENODEB_ID             0xD4    /* 3G   212 TLV eNodeB ID                                 7.7.112 */
1390 #define GTP_EXT_SEL_MODE_W_NSAPI      0xD5    /* 3G   213 TLV Selection Mode with NSAPI                 7.7.113 */
1391 #define GTP_EXT_ULI_TIMESTAMP         0xD6    /* 3G   214 TLV ULI Timestamp                             7.7.114 */
1392 #define GTP_EXT_LHN_ID_W_SAPI         0xD7    /* 3G   215 TLV Local Home Network ID (LHN-ID) with NSAPI 7.7.115 */
1393 #define GTP_EXT_CN_OP_SEL_ENTITY      0xD8    /* 3G   216 TLV CN Operator Selection Entity              7.7.116 */
1394 #define GTP_EXT_UE_USAGE_TYPE         0xD9    /* 3G   217 TLV UE Usage Type                             7.7.117 */
1395 #define GTP_EXT_EXT_COMMON_FLGS_II    0xDA    /* 3G   218 TLV Extended Common Flags II                  7.7.118 */
1396 #define GTP_EXT_NODE_IDENTIFIER       0xDB    /* 3G   219 TLV Node Identifier                           7.7.119 */
1397 #define GTP_EXT_CIOT_OPT_SUP_IND      0xDC    /* 3G   220 TLV CIoT Optimizations Support Indication     7.7.120 */
1398 #define GTP_EXT_SCEF_PDN_CONNECTION   0xDD    /* 3G   221 TLV SCEF PDN Connection                       7.7.121 */
1399 
1400 
1401 /*  222-238 TLV Spare. For future use.     */
1402 
1403 /* 239-250  Reserved for the GPRS charging protocol (see GTP' in 3GPP TS 32.295 [33])*/
1404 
1405 #define GTP_EXT_C1                    0xC1
1406 #define GTP_EXT_C2                    0xC2
1407 #define GTP_EXT_REL_PACK              0xF9    /* charging */
1408 #define GTP_EXT_CAN_PACK              0xFA    /* charging */
1409 #define GTP_EXT_CHRG_ADDR             0xFB    /* 3G   251     TLV     Charging Gateway Address        7.7.44 */
1410 /* 252-254  Reserved for the GPRS charging protocol (see GTP' in 3GPP TS 32.295 [33])*/
1411 #define GTP_EXT_DATA_REQ              0xFC    /* charging */
1412 #define GTP_EXT_DATA_RESP             0xFD    /* charging */
1413 #define GTP_EXT_NODE_ADDR             0xFE    /* charging */
1414 #define GTP_EXT_PRIV_EXT              0xFF
1415 
1416 static const value_string gtp_val[] = {
1417     {GTP_EXT_CAUSE,                 "Cause of operation"},
1418     {GTP_EXT_IMSI,                  "IMSI"},
1419     {GTP_EXT_RAI,                   "Routing Area Identity"},
1420     {GTP_EXT_TLLI,                  "Temporary Logical Link Identity"},
1421     {GTP_EXT_PTMSI,                 "Packet TMSI"},
1422 /*   6 */  {GTP_EXT_QOS_GPRS,       "Quality of Service"},
1423 /* 6-7 Spare */
1424 /*   8 */  {GTP_EXT_REORDER,        "Reorder required"},
1425 /*   9 */  {GTP_EXT_AUTH_TRI,       "Authentication triplets"},
1426 /* 10 Spare */
1427 /*  11 */  {GTP_EXT_MAP_CAUSE,      "MAP cause"},
1428 /*  12 */  {GTP_EXT_PTMSI_SIG,      "P-TMSI signature"},
1429 /*  13 */  {GTP_EXT_MS_VALID,       "MS validated"},
1430 /*  14 */  {GTP_EXT_RECOVER,        "Recovery"},
1431 /*  15 */  {GTP_EXT_SEL_MODE,       "Selection mode"},
1432 
1433 /*  16 */  {GTP_EXT_16,             "Flow label data I"},
1434 /*  16 */  /* ??? {GTP_EXT_FLOW_LABEL,     "Flow label data I"}, */
1435 /*  16 */  /* ??? {GTP_EXT_TEID,           "Tunnel Endpoint Identifier Data I"}, */   /* 3G */
1436 
1437     {GTP_EXT_17,                    "Flow label signalling"},
1438 /* ???    {GTP_EXT_FLOW_SIG,              "Flow label signalling"}, */
1439 /* ???    {GTP_EXT_TEID_CP,               "Tunnel Endpoint Identifier Data Control Plane"}, */ /* 3G */
1440 
1441     {GTP_EXT_18,                    "Flow label data II"},
1442 /* ???    {GTP_EXT_FLOW_II,               "Flow label data II"}, */
1443 /* ???    {GTP_EXT_TEID_II,               "Tunnel Endpoint Identifier Data II"}, */   /* 3G */
1444 
1445     {GTP_EXT_19,                    "MS not reachable reason"},
1446 /* ???    {GTP_EXT_MS_REASON,             "MS not reachable reason"}, */
1447 /* ???    {GTP_EXT_TEAR_IND,              "Teardown ID"}, */ /* 3G */
1448 
1449     {GTP_EXT_NSAPI,                 "NSAPI"},   /* 3G */
1450     {GTP_EXT_RANAP_CAUSE,           "RANAP cause"},   /* 3G */
1451     {GTP_EXT_RAB_CNTXT,             "RAB context"}, /* 3G */
1452     {GTP_EXT_RP_SMS,                "Radio Priority for MO SMS"},  /* 3G */
1453     {GTP_EXT_RP,                    "Radio Priority"}, /* 3G */
1454     {GTP_EXT_PKT_FLOW_ID,           "Packet Flow ID"},    /* 3G */
1455     {GTP_EXT_CHRG_CHAR,             "Charging characteristics"},    /* 3G */
1456     {GTP_EXT_TRACE_REF,             "Trace references"},    /* 3G */
1457     {GTP_EXT_TRACE_TYPE,            "Trace type"}, /* 3G */
1458 /*  29 */  {GTPv1_EXT_MS_REASON,    "MS not reachable reason"},   /* 3G */
1459 /* 117-126 Reserved for the GPRS charging protocol (see GTP' in 3GPP TS 32.295 [33]) */
1460 /* 126 */  {GTP_EXT_TR_COMM,        "Packet transfer command"},   /* charging */
1461 /* 127 */  {GTP_EXT_CHRG_ID,        "Charging ID"},
1462     {GTP_EXT_USER_ADDR,             "End user address"},
1463     {GTP_EXT_MM_CNTXT,              "MM context"},
1464     {GTP_EXT_PDP_CNTXT,             "PDP context"},
1465     {GTP_EXT_APN,                   "Access Point Name"},
1466     {GTP_EXT_PROTO_CONF,            "Protocol configuration options"},
1467     {GTP_EXT_GSN_ADDR,              "GSN address"},
1468     {GTP_EXT_MSISDN,                "MS international PSTN/ISDN number"},
1469     {GTP_EXT_QOS_UMTS,              "Quality of service (UMTS)"},    /* 3G */
1470     {GTP_EXT_AUTH_QUI,              "Authentication quintuplets"},   /* 3G */
1471     {GTP_EXT_TFT,                   "Traffic Flow Template (TFT)"},   /* 3G */
1472     {GTP_EXT_TARGET_ID,             "Target (RNC) identification"}, /* 3G */
1473     {GTP_EXT_UTRAN_CONT,            "UTRAN transparent field"},    /* 3G */
1474     {GTP_EXT_RAB_SETUP,             "RAB setup information"},   /* 3G */
1475     {GTP_EXT_HDR_LIST,              "Extension Header Types List"},  /* 3G */
1476     {GTP_EXT_TRIGGER_ID,            "Trigger Id"}, /* 3G */
1477     {GTP_EXT_OMC_ID,                "OMC Identity"},   /* 3G */
1478 
1479     {GTP_EXT_RAN_TR_CONT,           "RAN Transparent Container"}, /* 7.7.43 */
1480     {GTP_EXT_PDP_CONT_PRIO,         "PDP Context Prioritization"},  /* 7.7.45 */
1481     {GTP_EXT_ADD_RAB_SETUP_INF,     "Additional RAB Setup Information"},    /* 7.7.45A */
1482     {GTP_EXT_SGSN_NO,               "SGSN Number"},   /* 7.7.47 */
1483     {GTP_EXT_COMMON_FLGS,           "Common Flags"},  /* 7.7.48 */
1484     {GTP_EXT_APN_RES,               "APN Restriction"},   /* 3G */
1485     {GTP_EXT_RA_PRIO_LCS,           "Radio Priority LCS"},    /* 7.7.25B */
1486     {GTP_EXT_RAT_TYPE,              "RAT Type"}, /* 3G */
1487     {GTP_EXT_USR_LOC_INF,           "User Location Information"}, /* 7.7.51 */
1488     {GTP_EXT_MS_TIME_ZONE,          "MS Time Zone"}, /* 7.7.52 */
1489 
1490     {GTP_EXT_IMEISV,                "IMEI(SV)"},   /* 3G */
1491     {GTP_EXT_CAMEL_CHG_INF_CON,     "CAMEL Charging Information Container"},    /* 7.7.54 */
1492     {GTP_EXT_MBMS_UE_CTX,           "MBMS UE Context"},   /* 7.7.55 */
1493     {GTP_EXT_TMGI,                  "Temporary Mobile Group Identity (TMGI)"},   /* 7.7.56 */
1494     {GTP_EXT_RIM_RA,                "RIM Routing Address"},    /* 7.7.57 */
1495     {GTP_EXT_MBMS_PROT_CONF_OPT,    "MBMS Protocol Configuration Options"},    /* 7.7.58 */
1496     {GTP_EXT_MBMS_SA,               "MBMS Service Area"}, /* 7.7.60 */
1497     {GTP_EXT_SRC_RNC_PDP_CTX_INF,   "Source RNC PDCP context info"},  /* 7.7.61 */
1498     {GTP_EXT_ADD_TRS_INF,           "Additional Trace Info"}, /* 7.7.62 */
1499     {GTP_EXT_HOP_COUNT,             "Hop Counter"}, /* 7.7.63 */
1500     {GTP_EXT_SEL_PLMN_ID,           "Selected PLMN ID"},  /* 7.7.64 */
1501     {GTP_EXT_MBMS_SES_ID,           "MBMS Session Identifier"},   /* 7.7.65 */
1502     {GTP_EXT_MBMS_2G_3G_IND,        "MBMS 2G/3G Indicator"},   /* 7.7.66 */
1503     {GTP_EXT_ENH_NSAPI,             "Enhanced NSAPI"},  /* 7.7.67 */
1504     {GTP_EXT_MBMS_SES_DUR,          "MBMS Session Duration"},    /* 7.7.59 */
1505     {GTP_EXT_ADD_MBMS_TRS_INF,      "Additional MBMS Trace Info"},   /* 7.7.68 */
1506     {GTP_EXT_MBMS_SES_ID_REP_NO,    "MBMS Session Identity Repetition Number"},    /* 7.7.69 */
1507     {GTP_EXT_MBMS_TIME_TO_DATA_TR,  "MBMS Time To Data Transfer"},   /* 7.7.70 */
1508     {GTP_EXT_PS_HO_REQ_CTX,         "PS Handover Request Context"}, /* 7.7.71 */
1509     {GTP_EXT_BSS_CONT,              "BSS Container"},    /* 7.7.72 */
1510     {GTP_EXT_CELL_ID,               "Cell Identification"},   /* 7.7.73 */
1511     {GTP_EXT_PDU_NO,                "PDU Numbers"},    /* 7.7.74 */
1512     {GTP_EXT_BSSGP_CAUSE,           "BSSGP Cause"},   /* 7.7.75 */
1513     {GTP_EXT_REQ_MBMS_BEARER_CAP,   "Required MBMS bearer capabilities"}, /* 7.7.76 */
1514     {GTP_EXT_RIM_ROUTING_ADDR_DISC, "RIM Routing Address Discriminator"},   /* 7.7.77 */
1515     {GTP_EXT_LIST_OF_SETUP_PFCS,    "List of set-up PFCs"},    /* 7.7.78 */
1516 /* 180 */  {GTP_EXT_PS_HANDOVER_XIP_PAR, "  PS Handover XID Parameters"},                  /* 7.7.79 */
1517 /* 181 */  {GTP_EXT_MS_INF_CHG_REP_ACT,     "MS Info Change Reporting Action"},            /* 7.7.80 */
1518 /* 182 */  {GTP_EXT_DIRECT_TUNNEL_FLGS,     "Direct Tunnel Flags"},                        /* 7.7.81 */
1519 /* 183 */  {GTP_EXT_CORRELATION_ID,         "Correlation-ID"},                             /* 7.7.82 */
1520 /* 184 */  {GTP_EXT_BEARER_CONTROL_MODE,    "Bearer Control Mode"},                        /* 7.7.83 */
1521 /* 185 */  {GTP_EXT_MBMS_FLOW_ID,           "MBMS Flow Identifier"},                       /* 7.7.84 */
1522 /* 186 */  {GTP_EXT_MBMS_IP_MCAST_DIST,     "MBMS IP Multicast Distribution"},             /* 7.7.85 */
1523 /* 187 */  {GTP_EXT_MBMS_DIST_ACK,          "MBMS Distribution Acknowledgement"},          /* 7.7.86 */
1524 /* 188 */  {GTP_EXT_RELIABLE_IRAT_HO_INF,   "Reliable INTER RAT HANDOVER INFO"},           /* 7.7.87 */
1525 /* 189 */  {GTP_EXT_RFSP_INDEX,             "RFSP Index"},                                 /* 7.7.88 */
1526 /* 190 */  {GTP_EXT_FQDN,                   "Fully Qualified Domain Name (FQDN)"},         /* 7.7.90 */
1527 /* 191 */  {GTP_EXT_EVO_ALLO_RETE_P1,       "Evolved Allocation/Retention Priority I"},    /* 7.7.91 */
1528 /* 192 */  {GTP_EXT_EVO_ALLO_RETE_P2,       "Evolved Allocation/Retention Priority II"},   /* 7.7.92 */
1529 /* 193 */  {GTP_EXT_EXTENDED_COMMON_FLGS,   "Extended Common Flags"},                      /* 7.7.93 */
1530 /* 194 */  {GTP_EXT_UCI,                    "User CSG Information (UCI)"},                 /* 7.7.94 */
1531 /* 195 */  {GTP_EXT_CSG_INF_REP_ACT,        "CSG Information Reporting Action"},           /* 7.7.95 */
1532 /* 196 */  {GTP_EXT_CSG_ID,                 "CSG ID"},                                     /* 7.7.96 */
1533 /* 197 */  {GTP_EXT_CMI,                    "CSG Membership Indication (CMI)"},            /* 7.7.97 */
1534 /* 198 */  {GTP_EXT_AMBR,                   "Aggregate Maximum Bit Rate (AMBR)"},          /* 7.7.98 */
1535 /* 199 */  {GTP_EXT_UE_NETWORK_CAP,         "UE Network Capability"},                      /* 7.7.99 */
1536 /* 200 */  {GTP_EXT_UE_AMBR,                "UE-AMBR"},                                    /* 7.7.100 */
1537 /* 201 */  {GTP_EXT_APN_AMBR_WITH_NSAPI,    "APN-AMBR with NSAPI"},                        /* 7.7.101 */
1538 /* 202 */  {GTP_EXT_GGSN_BACK_OFF_TIME,     "GGSN Back-Off Time"},                         /* 7.7.102 */
1539 /* 203 */  {GTP_EXT_SIG_PRI_IND,            "Signalling Priority Indication"},             /* 7.7.103 */
1540 /* 204 */  {GTP_EXT_SIG_PRI_IND_W_NSAPI,    "Signalling Priority Indication with NSAPI"},  /* 7.7.104 */
1541 /* 205 */  {GTP_EXT_HIGHER_BR_16MB_FLG,     "Higher bitrates than 16 Mbps flag"},          /* 7.7.105 */
1542 /* 206 */  {GTP_EXT_MAX_MBR_APN_AMBR,       "Max MBR/APN-AMBR"},                           /* 7.7.106 */
1543 /* 207 */  {GTP_EXT_ADD_MM_CTX_SRVCC,       "Additional MM context for SRVCC"},            /* 7.7.107 */
1544 /* 208 */  {GTP_EXT_ADD_FLGS_SRVCC,         "Additional flags for SRVCC"},                 /* 7.7.108 */
1545 /* 209 */  {GTP_EXT_STN_SR,                 "STN-SR"},                                     /* 7.7.109 */
1546 /* 210 */  {GTP_EXT_C_MSISDN,               "C-MSISDN"},                                   /* 7.7.110 */
1547 /* 211 */  {GTP_EXT_EXT_RANAP_CAUSE,        "Extended RANAP Cause"},                       /* 7.7.111 */
1548 /* 212 */  {GTP_EXT_ENODEB_ID,              "eNodeB ID" },                                 /* 7.7.112 */
1549 /* 213 */  {GTP_EXT_SEL_MODE_W_NSAPI,       "Selection Mode with NSAPI" },                 /* 7.7.113 */
1550 /* 214 */  {GTP_EXT_ULI_TIMESTAMP,          "ULI Timestamp" },                             /* 7.7.114 */
1551 /* 215 */  {GTP_EXT_LHN_ID_W_SAPI,          "Local Home Network ID (LHN-ID) with NSAPI" }, /* 7.7.115 */
1552 /* 216 */  {GTP_EXT_CN_OP_SEL_ENTITY,       "Operator Selection Entity" },                 /* 7.7.116 */
1553 /* 217 */  {GTP_EXT_UE_USAGE_TYPE,          "UE Usage Type" },                             /* 7.7.117 */
1554 /* 218 */  {GTP_EXT_EXT_COMMON_FLGS_II,     "Extended Common Flags II"},                   /* 7.7.118 */
1555 /* 219 */  {GTP_EXT_NODE_IDENTIFIER,        "Node Identifier" },                           /* 7.7.119 */
1556 /* 220 */  {GTP_EXT_CIOT_OPT_SUP_IND,       "CIoT Optimizations Support Indication" },     /* 7.7.120 */
1557 /* 221 */  {GTP_EXT_SCEF_PDN_CONNECTION,    "SCEF PDN Connection" },                       /* 7.7.121 */
1558 
1559 
1560 /* 222-238 TLV Spare. For future use. */
1561 /* 239-250 Reserved for the GPRS charging protocol (see GTP' in 3GPP TS 32.295 [33]) */
1562 /* 249 */  {GTP_EXT_REL_PACK,  "Sequence numbers of released packets IE"},  /* charging */
1563 /* 250 */  {GTP_EXT_CAN_PACK,  "Sequence numbers of canceled packets IE"},  /* charging */
1564 /* 251 */  {GTP_EXT_CHRG_ADDR, "Charging Gateway address"},                 /* 7.7.44 */
1565 /* 252-254 Reserved for the GPRS charging protocol (see GTP' in 3GPP TS 32.295 [33]) */
1566 /* 252 */  {GTP_EXT_DATA_REQ,  "Data record packet"},                       /* charging */
1567 /* 253 */  {GTP_EXT_DATA_RESP, "Requests responded"},                       /* charging */
1568 /* 254 */  {GTP_EXT_NODE_ADDR, "Address of recommended node"},              /* charging */
1569 /* 255 */  {GTP_EXT_PRIV_EXT,  "Private Extension"},
1570     {0, NULL}
1571 };
1572 static value_string_ext gtp_val_ext = VALUE_STRING_EXT_INIT(gtp_val);
1573 
1574 /* It seems like some IE's are renamed in gtpv1 at least reading
1575  * 3GPP TS 29.060 version 6.11.0 Release 6
1576  */
1577 static const value_string gtpv1_val[] = {
1578 /*   1 */  {GTP_EXT_CAUSE,                 "Cause of operation"},
1579 /*   2 */  {GTP_EXT_IMSI,                  "IMSI"},
1580 /*   3 */  {GTP_EXT_RAI,                   "Routing Area Identity"},
1581 /*   4 */  {GTP_EXT_TLLI,                  "Temporary Logical Link Identity"},
1582 /*   5 */  {GTP_EXT_PTMSI,                 "Packet TMSI"},
1583 /*   6 */  {GTP_EXT_QOS_GPRS,              "Quality of Service"},
1584 /* 6-7 Spare */
1585 /*   7 */  {7,                             "Spare"},
1586 /*   8 */  {GTP_EXT_REORDER,               "Reorder required"},
1587 /*   9 */  {GTP_EXT_AUTH_TRI,              "Authentication triplets"},
1588 /* 10 Spare */
1589 /*  10 */  {10,                            "Spare"},
1590 /*  11 */  {GTP_EXT_MAP_CAUSE,             "MAP cause"},
1591 /*  12 */  {GTP_EXT_PTMSI_SIG,             "P-TMSI signature"},
1592 /*  13 */  {GTP_EXT_MS_VALID,              "MS validated"},
1593 /*  14 */  {GTP_EXT_RECOVER,               "Recovery"},
1594 /*  15 */  {GTP_EXT_SEL_MODE,              "Selection mode"},
1595 /*  16 */  {GTP_EXT_TEID,                  "Tunnel Endpoint Identifier Data I"},              /* 3G */
1596 /*  17 */  {GTP_EXT_TEID_CP,               "Tunnel Endpoint Identifier Data Control Plane"},  /* 3G */
1597 /*  18 */  {GTP_EXT_TEID_II,               "Tunnel Endpoint Identifier Data II"},             /* 3G */
1598 /*  19 */  {GTP_EXT_TEAR_IND,              "Teardown ID"},                                    /* 3G */
1599 
1600 /*  20 */  {GTP_EXT_NSAPI,                 "NSAPI"},                                          /* 3G */
1601 /*  21 */  {GTP_EXT_RANAP_CAUSE,           "RANAP cause"},                                    /* 3G */
1602 /*  22 */  {GTP_EXT_RAB_CNTXT,             "RAB context"},                                    /* 3G */
1603 /*  23 */  {GTP_EXT_RP_SMS,                "Radio Priority for MO SMS"},                      /* 3G */
1604 /*  24 */  {GTP_EXT_RP,                    "Radio Priority"},                                 /* 3G */
1605 /*  25 */  {GTP_EXT_PKT_FLOW_ID,           "Packet Flow ID"},                                 /* 3G */
1606 /*  26 */  {GTP_EXT_CHRG_CHAR,             "Charging characteristics"},                       /* 3G */
1607 /*  27 */  {GTP_EXT_TRACE_REF,             "Trace references"},                               /* 3G */
1608 /*  28 */  {GTP_EXT_TRACE_TYPE,            "Trace type"},                                     /* 3G */
1609 /*  29 */  {GTPv1_EXT_MS_REASON,           "MS not reachable reason"},                        /* 3G */
1610 /* 117-126 Reserved for the GPRS charging protocol (see GTP' in 3GPP TS 32.295 [33]) */
1611 /* 126 */  {GTP_EXT_TR_COMM,               "Packet transfer command"},                        /* charging */
1612 /* 127 */  {GTP_EXT_CHRG_ID,               "Charging ID"},
1613 
1614 /* 128 */  {GTP_EXT_USER_ADDR,             "End user address"},
1615 /* 129 */  {GTP_EXT_MM_CNTXT,              "MM context"},
1616 /* 130 */  {GTP_EXT_PDP_CNTXT,             "PDP context"},
1617 /* 131 */  {GTP_EXT_APN,                   "Access Point Name"},
1618 /* 132 */  {GTP_EXT_PROTO_CONF,            "Protocol configuration options"},
1619 /* 133 */  {GTP_EXT_GSN_ADDR,              "GSN address"},
1620 /* 134 */  {GTP_EXT_MSISDN,                "MS international PSTN/ISDN number"},
1621 /* 135 */  {GTP_EXT_QOS_UMTS,              "Quality of service (UMTS)"},                      /* 3G */
1622 /* 136 */  {GTP_EXT_AUTH_QUI,              "Authentication quintuplets"},                     /* 3G */
1623 /* 137 */  {GTP_EXT_TFT,                   "Traffic Flow Template (TFT)"},                    /* 3G */
1624 /* 138 */  {GTP_EXT_TARGET_ID,             "Target (RNC) identification"},                    /* 3G */
1625 /* 139 */  {GTP_EXT_UTRAN_CONT,            "UTRAN transparent field"},                        /* 3G */
1626 /* 140 */  {GTP_EXT_RAB_SETUP,             "RAB setup information"},                          /* 3G */
1627 /* 141 */  {GTP_EXT_HDR_LIST,              "Extension Header Types List"},                    /* 3G */
1628 /* 142 */  {GTP_EXT_TRIGGER_ID,            "Trigger Id"},                                     /* 3G */
1629 /* 143 */  {GTP_EXT_OMC_ID,                "OMC Identity"},                                   /* 3G */
1630 /* 144 */  {GTP_EXT_RAN_TR_CONT,           "RAN Transparent Container"},                      /* 7.7.43 */
1631 /* 145 */  {GTP_EXT_PDP_CONT_PRIO,         "PDP Context Prioritization"},                     /* 7.7.45 */
1632 /* 146 */  {GTP_EXT_ADD_RAB_SETUP_INF,     "Additional RAB Setup Information"},               /* 7.7.45A */
1633 /* 147 */  {GTP_EXT_SGSN_NO,               "SGSN Number"},                                    /* 7.7.47 */
1634 /* 148 */  {GTP_EXT_COMMON_FLGS,           "Common Flags"},                                   /* 7.7.48 */
1635 /* 149 */  {GTP_EXT_APN_RES,               "APN Restriction"},                                /* 3G */
1636 /* 150 */  {GTP_EXT_RA_PRIO_LCS,           "Radio Priority LCS"},                             /* 7.7.25B */
1637 /* 151 */  {GTP_EXT_RAT_TYPE,              "RAT Type"},                                       /* 3G */
1638 /* 152 */  {GTP_EXT_USR_LOC_INF,           "User Location Information"},                      /* 7.7.51 */
1639 /* 153 */  {GTP_EXT_MS_TIME_ZONE,          "MS Time Zone"},                                   /* 7.7.52 */
1640 
1641 /* 154 */  {GTP_EXT_IMEISV,                "IMEI(SV)"},                                       /* 3G */
1642 /* 155 */  {GTP_EXT_CAMEL_CHG_INF_CON,     "CAMEL Charging Information Container"},           /* 7.7.54 */
1643 /* 156 */  {GTP_EXT_MBMS_UE_CTX,           "MBMS UE Context"},                                /* 7.7.55 */
1644 /* 157 */  {GTP_EXT_TMGI,                  "Temporary Mobile Group Identity (TMGI)"},         /* 7.7.56 */
1645 /* 158 */  {GTP_EXT_RIM_RA,                "RIM Routing Address"},                            /* 7.7.57 */
1646 /* 159 */  {GTP_EXT_MBMS_PROT_CONF_OPT,    "MBMS Protocol Configuration Options"},            /* 7.7.58 */
1647 /* 160 */  {GTP_EXT_MBMS_SA,               "MBMS Service Area"},                              /* 7.7.60 */
1648 /* 161 */  {GTP_EXT_SRC_RNC_PDP_CTX_INF,   "Source RNC PDCP context info"},                   /* 7.7.61 */
1649 /* 162 */  {GTP_EXT_ADD_TRS_INF,           "Additional Trace Info"},                          /* 7.7.62 */
1650 /* 163 */  {GTP_EXT_HOP_COUNT,             "Hop Counter"},                                    /* 7.7.63 */
1651 /* 164 */  {GTP_EXT_SEL_PLMN_ID,           "Selected PLMN ID"},                               /* 7.7.64 */
1652 /* 165 */  {GTP_EXT_MBMS_SES_ID,           "MBMS Session Identifier"},                        /* 7.7.65 */
1653 /* 166 */  {GTP_EXT_MBMS_2G_3G_IND,        "MBMS 2G/3G Indicator"},                           /* 7.7.66 */
1654 /* 167 */  {GTP_EXT_ENH_NSAPI,             "Enhanced NSAPI"},                                 /* 7.7.67 */
1655 /* 168 */  {GTP_EXT_MBMS_SES_DUR,          "MBMS Session Duration"},                          /* 7.7.59 */
1656 /* 169 */  {GTP_EXT_ADD_MBMS_TRS_INF,      "Additional MBMS Trace Info"},                     /* 7.7.68 */
1657 /* 170 */  {GTP_EXT_MBMS_SES_ID_REP_NO,    "MBMS Session Identity Repetition Number"},        /* 7.7.69 */
1658 /* 171 */  {GTP_EXT_MBMS_TIME_TO_DATA_TR,  "MBMS Time To Data Transfer"},                     /* 7.7.70 */
1659 /* 172 */  {GTP_EXT_PS_HO_REQ_CTX,         "PS Handover Request Context"},                    /* 7.7.71 */
1660 /* 173 */  {GTP_EXT_BSS_CONT,              "BSS Container"},                                  /* 7.7.72 */
1661 /* 174 */  {GTP_EXT_CELL_ID,               "Cell Identification"},                            /* 7.7.73 */
1662 /* 175 */  {GTP_EXT_PDU_NO,                "PDU Numbers"},                                    /* 7.7.74 */
1663 /* 176 */  {GTP_EXT_BSSGP_CAUSE,           "BSSGP Cause"},                                    /* 7.7.75 */
1664 
1665 /* 177 */  {GTP_EXT_REQ_MBMS_BEARER_CAP,   "Required MBMS bearer capabilities"},              /* 7.7.76 */
1666 /* 178 */  {GTP_EXT_RIM_ROUTING_ADDR_DISC, "RIM Routing Address Discriminator"},              /* 7.7.77 */
1667 /* 179 */  {GTP_EXT_LIST_OF_SETUP_PFCS,    "List of set-up PFCs"},                            /* 7.7.78 */
1668 /* 180 */  {GTP_EXT_PS_HANDOVER_XIP_PAR,   "PS Handover XID Parameters"},                     /* 7.7.79 */
1669 /* 181 */  {GTP_EXT_MS_INF_CHG_REP_ACT,    "MS Info Change Reporting Action"},                /* 7.7.80 */
1670 /* 182 */  {GTP_EXT_DIRECT_TUNNEL_FLGS,    "Direct Tunnel Flags"},                            /* 7.7.81 */
1671 /* 183 */  {GTP_EXT_CORRELATION_ID,        "Correlation-ID"},                                 /* 7.7.82 */
1672 /* 184 */  {GTP_EXT_BEARER_CONTROL_MODE,   "Bearer Control Mode"},                            /* 7.7.83 */
1673 /* 185 */  {GTP_EXT_MBMS_FLOW_ID,          "MBMS Flow Identifier"},                           /* 7.7.84 */
1674 /* 186 */  {GTP_EXT_MBMS_IP_MCAST_DIST,    "MBMS IP Multicast Distribution"},                 /* 7.7.85 */
1675 /* 187 */  {GTP_EXT_MBMS_DIST_ACK,         "MBMS Distribution Acknowledgement"},              /* 7.7.86 */
1676 /* 188 */  {GTP_EXT_RELIABLE_IRAT_HO_INF,  "Reliable INTER RAT HANDOVER INFO"},               /* 7.7.87 */
1677 /* 190 */  {GTP_EXT_RFSP_INDEX,            "RFSP Index"},                                     /* 7.7.88 */
1678 /* 190 */  {GTP_EXT_FQDN,                  "Fully Qualified Domain Name (FQDN)"},             /* 7.7.90 */
1679 /* 191 */  {GTP_EXT_EVO_ALLO_RETE_P1,      "Evolved Allocation/Retention Priority I"},        /* 7.7.91 */
1680 /* 192 */  {GTP_EXT_EVO_ALLO_RETE_P2,      "Evolved Allocation/Retention Priority II"},       /* 7.7.92 */
1681 /* 193 */  {GTP_EXT_EXTENDED_COMMON_FLGS,  "Extended Common Flags"},                          /* 7.7.93 */
1682 /* 194 */  {GTP_EXT_UCI,                   "User CSG Information (UCI)"},                     /* 7.7.94 */
1683 /* 195 */  {GTP_EXT_CSG_INF_REP_ACT,       "CSG Information Reporting Action"},               /* 7.7.95 */
1684 /* 196 */  {GTP_EXT_CSG_ID,                "CSG ID"},                                         /* 7.7.96 */
1685 /* 197 */  {GTP_EXT_CMI,                   "CSG Membership Indication (CMI)"},                /* 7.7.97 */
1686 /* 198 */  {198,                           "Aggregate Maximum Bit Rate (AMBR)"},              /* 7.7.98 */
1687 /* 199 */  {199,                           "UE Network Capability"},                          /* 7.7.99 */
1688 /* 200 */  {200,                           "UE-AMBR"},                                        /* 7.7.100 */
1689 /* 201 */  {201,                           "APN-AMBR with NSAPI"},                            /* 7.7.101 */
1690 /* 202 */  {202,                           "GGSN Back-Off Time"},                             /* 7.7.102 */
1691 /* 203 */  {203,                           "Signalling Priority Indication"},                 /* 7.7.103 */
1692 /* 204 */  {204,                           "Signalling Priority Indication with NSAPI"},      /* 7.7.104 */
1693 /* 205 */  {205,                           "Higher bitrates than 16 Mbps flag"},              /* 7.7.105 */
1694 /* 206 */  {206,                           "Max MBR/APN-AMBR"},                               /* 7.7.106 */
1695 /* 207 */  {207,                           "Additional MM context for SRVCC"},                /* 7.7.107 */
1696 /* 208 */  {208,                           "Additional flags for SRVCC"},                     /* 7.7.108 */
1697 /* 209 */  {209,                           "STN-SR"},                                         /* 7.7.109 */
1698 /* 210 */  {210,                           "C-MSISDN"},                                       /* 7.7.110 */
1699 /* 211 */  {211,                           "Extended RANAP Cause"},                           /* 7.7.111 */
1700 /* 212 */  {GTP_EXT_ENODEB_ID,             "eNodeB ID" },                                     /* 7.7.112 */
1701 /* 213 */  {GTP_EXT_SEL_MODE_W_NSAPI,      "Selection Mode with NSAPI" },                     /* 7.7.113 */
1702 /* 214 */  {GTP_EXT_ULI_TIMESTAMP,         "ULI Timestamp" },                                 /* 7.7.114 */
1703 /* 215 */  {GTP_EXT_LHN_ID_W_SAPI,         "Local Home Network ID (LHN-ID) with NSAPI" },     /* 7.7.115 */
1704 /* 216 */  {GTP_EXT_CN_OP_SEL_ENTITY,      "Operator Selection Entity" },                     /* 7.7.116 */
1705 /* 217 */  {GTP_EXT_UE_USAGE_TYPE,         "UE Usage Type" },                                 /* 7.7.117 */
1706 /* 218 */  {GTP_EXT_EXT_COMMON_FLGS_II,    "Extended Common Flags II"},                       /* 7.7.118 */
1707 /* 219 */  {GTP_EXT_NODE_IDENTIFIER,       "Node Identifier" },                              /* 7.7.119 */
1708 /* 220 */  {GTP_EXT_CIOT_OPT_SUP_IND,      "CIoT Optimizations Support Indication" },        /* 7.7.120 */
1709 /* 221 */  {GTP_EXT_SCEF_PDN_CONNECTION,   "SCEF PDN Connection" },                          /* 7.7.121 */
1710 
1711 /* 219-238 TLV Spare. For future use. */
1712 /* 239-250 Reserved for the GPRS charging protocol (see GTP' in 3GPP TS 32.295 [33]) */
1713 /* 249 */  {GTP_EXT_REL_PACK,              "Sequence numbers of released packets IE"},        /* charging */
1714 /* 250 */  {GTP_EXT_CAN_PACK,              "Sequence numbers of canceled packets IE"},        /* charging */
1715 /* 251 */  {GTP_EXT_CHRG_ADDR,             "Charging Gateway address"},                       /* 7.7.44 */
1716 /* 252-254 Reserved for the GPRS charging protocol (see GTP' in 3GPP TS 32.295 [33]) */
1717 /* 252 */  {GTP_EXT_DATA_REQ,              "Data record packet"},                             /* charging */
1718 /* 253 */  {GTP_EXT_DATA_RESP,             "Requests responded"},                             /* charging */
1719 /* 254 */  {GTP_EXT_NODE_ADDR,             "Address of recommended node"},                    /* charging */
1720 /* 255 */  {GTP_EXT_PRIV_EXT,              "Private Extension"},
1721 
1722     {0, NULL}
1723 };
1724 static value_string_ext gtpv1_val_ext = VALUE_STRING_EXT_INIT(gtpv1_val);
1725 
1726 /* GPRS:    9.60 v7.6.0, page 37
1727  * UMTS:    29.060 v4.0, page 45
1728  * ETSI TS 129 060 V9.4.0 (2010-10) Ch 7.7.1
1729  */
1730 static const value_string cause_type[] = {
1731     {  0, "Request IMSI"},
1732     {  1, "Request IMEI"},
1733     {  2, "Request IMSI and IMEI"},
1734     {  3, "No identity needed"},
1735     {  4, "MS refuses"},
1736     {  5, "MS is not GPRS responding"},
1737     {  6, "Reactivation Requested"},
1738     {  7, "PDP address inactivity timer expires"},
1739     /* For future use 8-48 */
1740     /* Cause values reserved for GPRS charging
1741      * protocol use (see GTP' in 3GPP TS 32.295 [33])
1742      * 49-63
1743      */
1744     { 59, "System failure"}, /* charging */
1745     { 60, "The transmit buffers are becoming full"}, /* charging */
1746     { 61, "The receive buffers are becoming full"},  /* charging */
1747     { 62, "Another node is about to go down"},       /* charging */
1748     { 63, "This node is about to go down"},          /* charging */
1749     /* For future use 64-127 */
1750     {128, "Request accepted"},
1751     {129, "New PDP type due to network preference"},
1752     {130, "New PDP type due to single address bearer only"},
1753     /* For future use 131-176 */
1754     /* Cause values reserved for GPRS charging
1755      * protocol use (see GTP' in 3GPP TS 32.295 [33])
1756      * 177-191
1757      */
1758     {177, "CDR decoding error"},
1759 
1760     {192, "Non-existent"},
1761     {193, "Invalid message format"},
1762     {194, "IMSI not known"},
1763     {195, "MS is GPRS detached"},
1764     {196, "MS is not GPRS responding"},
1765     {197, "MS refuses"},
1766     {198, "Version not supported"},
1767     {199, "No resource available"},
1768     {200, "Service not supported"},
1769     {201, "Mandatory IE incorrect"},
1770     {202, "Mandatory IE missing"},
1771     {203, "Optional IE incorrect"},
1772     {204, "System failure"},
1773     {205, "Roaming restriction"},
1774     {206, "P-TMSI signature mismatch"},
1775     {207, "GPRS connection suspended"},
1776     {208, "Authentication failure"},
1777     {209, "User authentication failed"},
1778     {210, "Context not found"},
1779     {211, "All PDP dynamic addresses are occupied"},
1780     {212, "No memory is available"},
1781     {213, "Relocation failure"},
1782     {214, "Unknown mandatory extension header"},
1783     {215, "Semantic error in the TFT operation"},
1784     {216, "Syntactic error in the TFT operation"},
1785     {217, "Semantic errors in packet filter(s)"},
1786     {218, "Syntactic errors in packet filter(s)"},
1787     {219, "Missing or unknown APN"},
1788     {220, "Unknown PDP address or PDP type"},
1789     {221, "PDP context without TFT already activated"},
1790     {222, "APN access denied - no subscription"},
1791     {223, "APN Restriction type incompatibility with currently active PDP Contexts"},
1792     {224, "MS MBMS Capabilities Insufficient"},
1793     {225, "Invalid Correlation-ID"},
1794     {226, "MBMS Bearer Context Superseded"},
1795     {227, "Bearer Control Mode violation"},
1796     {228, "Collision with network initiated request"},
1797     {229, "APN Congestion"},
1798     {230, "Bearer handling not supported"},
1799     {231, "Target access restricted for the subscriber" },
1800     {232, "UE is temporarily not reachable due to power saving" },
1801     {233, "Relocation failure due to NAS message redirection"},
1802     /* For future use -240 */
1803     /* Cause values reserved for GPRS charging
1804      * protocol use (see GTP' in 3GPP TS 32.295 [33])
1805      * 241-255
1806      */
1807     {252, "Request related to possibly duplicated packets already fulfilled"},  /* charging */
1808     {253, "Request already fulfilled"}, /* charging */
1809     {254, "Sequence numbers of released/cancelled packets IE incorrect"},   /* charging */
1810     {255, "Request not fulfilled"}, /* charging */
1811     {0, NULL}
1812 };
1813 value_string_ext cause_type_ext = VALUE_STRING_EXT_INIT(cause_type);
1814 
1815 /* GPRS:    9.02 v7.7.0
1816  * UMTS:    29.002 v4.2.1, chapter 17.5, page 268
1817  * Imported gsm_old_GSMMAPLocalErrorcode_vals from gsm_map from gsm_map
1818  */
1819 
1820 static const value_string gsn_addr_type[] = {
1821     {0x00, "IPv4"},
1822     {0x01, "IPv6"},
1823     {0, NULL}
1824 };
1825 
1826 static const value_string pdp_type[] = {
1827     {0x00, "X.25"},
1828     {0x01, "PPP"},
1829     {0x02, "OSP:IHOSS"},
1830     {0x21, "IPv4"},
1831     {0x57, "IPv6"},
1832     {0x8d, "IPv4v6"},
1833     {0, NULL}
1834 };
1835 
1836 static const value_string pdp_org_type[] = {
1837     {0, "ETSI"},
1838     {1, "IETF"},
1839     {0, NULL}
1840 };
1841 
1842 static const value_string qos_delay_type[] = {
1843     {0x00, "Subscribed delay class (in MS to network direction)"},
1844     {0x01, "Delay class 1"},
1845     {0x02, "Delay class 2"},
1846     {0x03, "Delay class 3"},
1847     {0x04, "Delay class 4 (best effort)"},
1848     {0x07, "Reserved"},
1849     {0, NULL}
1850 };
1851 
1852 static const value_string qos_reliability_type[] = {
1853     {0x00, "Subscribed reliability class (in MS to network direction)"},
1854     {0x01, "Acknowledged GTP, LLC, and RLC; Protected data"},
1855     {0x02, "Unacknowledged GTP, Ack LLC/RLC, Protected data"},
1856     {0x03, "Unacknowledged GTP/LLC, Ack RLC, Protected data"},
1857     {0x04, "Unacknowledged GTP/LLC/RLC, Protected data"},
1858     {0x05, "Unacknowledged GTP/LLC/RLC, Unprotected data"},
1859     {0x07, "Reserved"},
1860     {0, NULL}
1861 };
1862 
1863 static const value_string qos_peak_type[] = {
1864     {0x00, "Subscribed peak throughput (in MS to network direction)"},
1865     {0x01, "Up to 1 000 oct/s"},
1866     {0x02, "Up to 2 000 oct/s"},
1867     {0x03, "Up to 4 000 oct/s"},
1868     {0x04, "Up to 8 000 oct/s"},
1869     {0x05, "Up to 16 000 oct/s"},
1870     {0x06, "Up to 32 000 oct/s"},
1871     {0x07, "Up to 64 000 oct/s"},
1872     {0x08, "Up to 128 000 oct/s"},
1873     {0x09, "Up to 256 000 oct/s"},
1874 /* QoS Peak throughput classes from 0x0A to 0x0F (from 10 to 15) are subscribed */
1875     {0x0A, "Reserved"},
1876     {0x0B, "Reserved"},
1877     {0x0C, "Reserved"},
1878     {0x0D, "Reserved"},
1879     {0x0E, "Reserved"},
1880     {0x0F, "Reserved"},
1881     {0, NULL}
1882 };
1883 
1884 static const value_string qos_precedence_type[] = {
1885     {0x00, "Subscribed precedence (in MS to network direction)"},
1886     {0x01, "High priority"},
1887     {0x02, "Normal priority"},
1888     {0x03, "Low priority"},
1889     {0x07, "Reserved"},
1890     {0, NULL}
1891 };
1892 
1893 static const value_string qos_mean_type[] = {
1894     {0x00, "Subscribed mean throughput (in MS to network direction)"},
1895     {0x01, "100 oct/h"},        /* Class 2 */
1896     {0x02, "200 oct/h"},        /* Class 3 */
1897     {0x03, "500 oct/h"},        /* Class 4 */
1898     {0x04, "1 000 oct/h"},      /* Class 5 */
1899     {0x05, "2 000 oct/h"},      /* Class 6 */
1900     {0x06, "5 000 oct/h"},      /* Class 7 */
1901     {0x07, "10 000 oct/h"},     /* Class 8 */
1902     {0x08, "20 000 oct/h"},     /* Class 9 */
1903     {0x09, "50 000 oct/h"},     /* Class 10 */
1904     {0x0A, "100 000 oct/h"},    /* Class 11 */
1905     {0x0B, "200 000 oct/h"},    /* Class 12 */
1906     {0x0C, "500 000 oct/h"},    /* Class 13 */
1907     {0x0D, "1 000 000 oct/h"},  /* Class 14 */
1908     {0x0E, "2 000 000 oct/h"},  /* Class 15 */
1909     {0x0F, "5 000 000 oct/h"},  /* Class 16 */
1910     {0x10, "10 000 000 oct/h"}, /* Class 17 */
1911     {0x11, "20 000 000 oct/h"}, /* Class 18 */
1912     {0x12, "50 000 000 oct/h"}, /* Class 19 */
1913 /* QoS Mean throughput classes from 0x13 to 0x1E (from 19 to 30) are subscribed */
1914     {0x13, "Reserved"},
1915     {0x14, "Reserved"},
1916     {0x15, "Reserved"},
1917     {0x16, "Reserved"},
1918     {0x17, "Reserved"},
1919     {0x18, "Reserved"},
1920     {0x19, "Reserved"},
1921     {0x1A, "Reserved"},
1922     {0x1B, "Reserved"},
1923     {0x1C, "Reserved"},
1924     {0x1D, "Reserved"},
1925     {0x1E, "Reserved"},
1926     {0x1F, "Best effort"},  /* Class 1 */
1927     {0, NULL}
1928 };
1929 static value_string_ext qos_mean_type_ext = VALUE_STRING_EXT_INIT(qos_mean_type);
1930 
1931 static const value_string qos_del_err_sdu[] = {
1932     {0x00, "Subscribed delivery of erroneous SDUs (in MS to network direction)"},
1933     {0x01, "No detect ('-')"},
1934     {0x02, "Erroneous SDUs are delivered ('yes')"},
1935     {0x03, "Erroneous SDUs are not delivered ('no')"},
1936     {0x07, "Reserved"},  /* All other values are reserved */
1937     {0, NULL}
1938 };
1939 
1940 static const value_string qos_del_order[] = {
1941     {0x00, "Subscribed delivery order (in MS to network direction)"},
1942     {0x01, "With delivery order ('yes')"},
1943     {0x02, "Without delivery order ('no')"},
1944     {0x03, "Reserved"},  /* All other values are reserved */
1945     {0, NULL}
1946 };
1947 
1948 static const value_string qos_traf_class[] = {
1949     {0x00, "Subscribed traffic class (in MS to network direction)"},
1950     {0x01, "Conversational class"},
1951     {0x02, "Streaming class"},
1952     {0x03, "Interactive class"},
1953     {0x04, "Background class"},
1954     {0x07, "Reserved"},  /* All other values are reserved */
1955     {0, NULL}
1956 };
1957 
1958 static const value_string qos_max_sdu_size[] = {
1959     {0x00, "Subscribed maximum SDU size (in MS to network direction"},
1960     /* For values from 0x01 to 0x96 (from 1 to 150), use a granularity of 10 octets */
1961     {0x97, "1502 octets"},
1962     {0x98, "1510 octets"},
1963     {0x99, "1520 octets"},
1964     {0, NULL}             /* All other values are reserved */
1965 };
1966 
1967 static const value_string qos_max_ul[] = {
1968     {0x00, "Subscribed maximum bit rate for uplink (in MS to network direction)"},
1969     /* For values from 0x01 to 0x3F (from 1 to 63), use a granularity of 1 kbps */
1970     /* For values from 0x40 to 0x7F, value = 64 kbps + (value - 0x40) * 8 kbps */
1971     /* For values from 0x80 to 0xFE, value = 576 kbps + (value - 0x80) * 64 kbps */
1972     {0xFF, "0 kbps"},
1973     {0, NULL}
1974 };
1975 
1976 static const value_string qos_max_dl[] = {
1977     {0x00, "Subscribed maximum bit rate for downlink (in MS to network direction)"},
1978     /* For values from 0x01 to 0x3F (from 1 to 63), use a granularity of 1 kbps */
1979     /* For values from 0x40 to 0x7F, value = 64 kbps + (value - 0x40) * 8 kbps */
1980     /* For values from 0x80 to 0xFE, value = 576 kbps + (value - 0x80) * 64 kbps */
1981     {0xFF, "0 kbps"},
1982     {0, NULL}
1983 };
1984 
1985 static const value_string qos_res_ber[] = {
1986     {0x00, "Subscribed residual BER (in MS to network direction)"},
1987     {0x01, "1/20 = 5x10^-2"},
1988     {0x02, "1/100 = 1x10^-2"},
1989     {0x03, "1/200 = 5x10^-3"},
1990     {0x04, "1/250 = 4x10^-3"},
1991     {0x05, "1/1 000 = 1x10^-3"},
1992     {0x06, "1/10 000 = 1x10^-4"},
1993     {0x07, "1/100 000 = 1x10^-5"},
1994     {0x08, "1/1 000 000 = 1x10^-6"},
1995     {0x09, "3/50 000 000 = 6x10^-8"},
1996     {0x0F, "Reserved"},    /* All other values are reserved */
1997     {0, NULL}
1998 };
1999 
2000 static const value_string qos_sdu_err_ratio[] = {
2001     {0x00, "Subscribed SDU error ratio (in MS to network direction)"},
2002     {0x01, "1/100 = 1x10^-2"},
2003     {0x02, "7/1000 = 7x10^-3"},
2004     {0x03, "1/1 000 = 1x10^-3"},
2005     {0x04, "1/10 000 = 1x10^-4"},
2006     {0x05, "1/100 000 = 1x10^-5"},
2007     {0x06, "1/1 000 000 = 1x10^-6"},
2008     {0x07, "1/10 = 1x10^-1"},
2009     {0x0F, "Reserved"},    /* All other values are reserved */
2010     {0, NULL}
2011 };
2012 
2013 static const value_string qos_traf_handl_prio[] = {
2014     {0x00, "Subscribed traffic handling priority (in MS to network direction)"},
2015     {0x01, "Priority level 1"},
2016     {0x02, "Priority level 2"},
2017     {0x03, "Priority level 3"},
2018     {0, NULL}
2019 };
2020 
2021 static const value_string qos_trans_delay[] = {
2022     {0x00, "Subscribed Transfer Delay (in MS to network direction)"},
2023     {0x01, "10 ms"},        /* Using a granularity of 10 ms */
2024     {0x02, "20 ms"},
2025     {0x03, "30 ms"},
2026     {0x04, "40 ms"},
2027     {0x05, "50 ms"},
2028     {0x06, "60 ms"},
2029     {0x07, "70 ms"},
2030     {0x08, "80 ms"},
2031     {0x09, "90 ms"},
2032     {0x0A, "100 ms"},
2033     {0x0B, "110 ms"},
2034     {0x0C, "120 ms"},
2035     {0x0D, "130 ms"},
2036     {0x0E, "140 ms"},
2037     {0x0F, "150 ms"},
2038     {0x10, "200 ms"},       /* (For values from 0x10 to 0x1F, value = 200 ms + (value - 0x10) * 50 ms */
2039     {0x11, "250 ms"},
2040     {0x12, "300 ms"},
2041     {0x13, "350 ms"},
2042     {0x14, "400 ms"},
2043     {0x15, "450 ms"},
2044     {0x16, "500 ms"},
2045     {0x17, "550 ms"},
2046     {0x18, "600 ms"},
2047     {0x19, "650 ms"},
2048     {0x1A, "700 ms"},
2049     {0x1B, "750 ms"},
2050     {0x1C, "800 ms"},
2051     {0x1D, "850 ms"},
2052     {0x1E, "900 ms"},
2053     {0x1F, "950 ms"},
2054     {0x20, "1000 ms"},      /* For values from 0x20 to 0x3E, value = 1000 ms + (value - 0x20) * 100 ms */
2055     {0x21, "1100 ms"},
2056     {0x22, "1200 ms"},
2057     {0x23, "1300 ms"},
2058     {0x24, "1400 ms"},
2059     {0x25, "1500 ms"},
2060     {0x26, "1600 ms"},
2061     {0x27, "1700 ms"},
2062     {0x28, "1800 ms"},
2063     {0x29, "1900 ms"},
2064     {0x2A, "2000 ms"},
2065     {0x2B, "2100 ms"},
2066     {0x2C, "2200 ms"},
2067     {0x2D, "2300 ms"},
2068     {0x2E, "2400 ms"},
2069     {0x2F, "2500 ms"},
2070     {0x30, "2600 ms"},
2071     {0x31, "2700 ms"},
2072     {0x32, "2800 ms"},
2073     {0x33, "2900 ms"},
2074     {0x34, "3000 ms"},
2075     {0x35, "3100 ms"},
2076     {0x36, "3200 ms"},
2077     {0x37, "3300 ms"},
2078     {0x38, "3400 ms"},
2079     {0x39, "3500 ms"},
2080     {0x3A, "3600 ms"},
2081     {0x3B, "3700 ms"},
2082     {0x3C, "3800 ms"},
2083     {0x3D, "3900 ms"},
2084     {0x3E, "4000 ms"},
2085     {0x3F, "Reserved"},
2086     {0, NULL}
2087 };
2088 static value_string_ext qos_trans_delay_ext = VALUE_STRING_EXT_INIT(qos_trans_delay);
2089 
2090 static const value_string qos_guar_ul[] = {
2091     {0x00, "Subscribed guaranteed bit rate for uplink (in MS to network direction)"},
2092     /* For values from 0x01 to 0x3F (from 1 to 63), use a granularity of 1 kbps */
2093     /* For values from 0x40 to 0x7F, value = 64 kbps + (value - 0x40) * 8 kbps */
2094     /* For values from 0x80 to 0xFE, value = 576 kbps + (value - 0x80) * 64 kbps */
2095     {0xFF, "0 kbps"},
2096     {0, NULL}
2097 };
2098 
2099 static const value_string src_stat_desc_vals[] = {
2100     {0x00, "unknown"},
2101     {0x01, "speech"},
2102     {0, NULL}
2103 };
2104 
2105 
2106 static const true_false_string gtp_sig_ind = {
2107     "Optimised for signalling traffic",
2108     "Not optimised for signalling traffic"
2109 };
2110 
2111 static const value_string qos_guar_dl[] = {
2112     {0x00, "Subscribed guaranteed bit rate for downlink (in MS to network direction)"},
2113     /* For values from 0x01 to 0x3F (from 1 to 63), use a granularity of 1 kbps */
2114     /* For values from 0x40 to 0x7F, value = 64 kbps + (value - 0x40) * 8 kbps */
2115     /* For values from 0x80 to 0xFE, value = 576 kbps + (value - 0x80) * 64 kbps */
2116     {0xFF, "0 kbps"},
2117     {0, NULL}
2118 };
2119 
2120 static const value_string sel_mode_type[] = {
2121     {0, "MS or network provided APN, subscribed verified"},
2122     {1, "MS provided APN, subscription not verified"},
2123     {2, "Network provided APN, subscription not verified"},
2124     {3, "For future use (Network provided APN, subscription not verified"}, /* Shall not be sent. If received, shall be sent as value 2 */
2125     {0, NULL}
2126 };
2127 
2128 static const value_string tr_comm_type[] = {
2129     {1, "Send data record packet"},
2130     {2, "Send possibly duplicated data record packet"},
2131     {3, "Cancel data record packet"},
2132     {4, "Release data record packet"},
2133     {0, NULL}
2134 };
2135 
2136 /*
2137  * UMTS:   23.040 v14.0.0, chapter 3.3.2
2138  */
2139 static const value_string ms_not_reachable_type[] = {
2140     { 0, "No paging response via the MSC"},
2141     { 1, "IMSI detached"},
2142     { 2, "Roaming restriction"},
2143     { 3, "Deregistered in the HLR for non GPRS"},
2144     { 4, "MS purge for non GPRS"},
2145     { 5, "No paging response via the SGSN"},
2146     { 6, "GPRS detached"},
2147     { 7, "Deregistered in the HLR for non GPRS"},
2148     { 8, "MS purged for GPRS"},
2149     { 9, "Unidentified subscriber via the MSC"},
2150     {10, "Unidentified subscriber via the SGSN"},
2151     {11, "Deregistered in the HSS/HLR for IMS"},
2152     {12, "No response via the IP-SM-GW"},
2153     {13, "The MS is temporarily unavailable"},
2154     {0, NULL}             /* All other values are reserved */
2155 };
2156 
2157 /* UMTS:   25.413 v3.4.0, chapter 9.2.1.4, page 80
2158  */
2159 static const value_string ranap_cause_type[] = {
2160 /* Radio Network Layer Cause (1-->64) */
2161     {   1, "RAB preempted"},
2162     {   2, "Trelocoverall Expiry"},
2163     {   3, "Trelocprep Expiry"},
2164     {   4, "Treloccomplete Expiry"},
2165     {   5, "Tqueuing Expiry"},
2166     {   6, "Relocation Triggered"},
2167     {   7, "TRELOCalloc Expiry"},
2168     {   8, "Unable to Establish During Relocation"},
2169     {   9, "Unknown Target RNC"},
2170     {  10, "Relocation Cancelled"},
2171     {  11, "Successful Relocation"},
2172     {  12, "Requested Ciphering and/or Integrity Protection Algorithms not Supported"},
2173     {  13, "Change of Ciphering and/or Integrity Protection is not supported"},
2174     {  14, "Failure in the Radio Interface Procedure"},
2175     {  15, "Release due to UTRAN Generated Reason"},
2176     {  16, "User Inactivity"},
2177     {  17, "Time Critical Relocation"},
2178     {  18, "Requested Traffic Class not Available"},
2179     {  19, "Invalid RAB Parameters Value"},
2180     {  20, "Requested Maximum Bit Rate not Available"},
2181     {  21, "Requested Guaranteed Bit Rate not Available"},
2182     {  22, "Requested Transfer Delay not Achievable"},
2183     {  23, "Invalid RAB Parameters Combination"},
2184     {  24, "Condition Violation for SDU Parameters"},
2185     {  25, "Condition Violation for Traffic Handling Priority"},
2186     {  26, "Condition Violation for Guaranteed Bit Rate"},
2187     {  27, "User Plane Versions not Supported"},
2188     {  28, "Iu UP Failure"},
2189     {  29, "Relocation Failure in Target CN/RNC or Target System"},
2190     {  30, "Invalid RAB ID"},
2191     {  31, "No Remaining RAB"},
2192     {  32, "Interaction with other procedure"},
2193     {  33, "Requested Maximum Bit Rate for DL not Available"},
2194     {  34, "Requested Maximum Bit Rate for UL not Available"},
2195     {  35, "Requested Guaranteed Bit Rate for DL not Available"},
2196     {  36, "Requested Guaranteed Bit Rate for UL not Available"},
2197     {  37, "Repeated Integrity Checking Failure"},
2198     {  38, "Requested Report Type not supported"},
2199     {  39, "Request superseded"},
2200     {  40, "Release due to UE generated signalling connection release"},
2201     {  41, "Resource Optimisation Relocation"},
2202     {  42, "Requested Information Not Available"},
2203     {  43, "Relocation desirable for radio reasons"},
2204     {  44, "Relocation not supported in Target RNC or Target System"},
2205     {  45, "Directed Retry"},
2206     {  46, "Radio Connection With UE Lost"},
2207     {  47, "rNC-unable-to-establish-all-RFCs"},
2208     {  48, "deciphering-keys-not-available"},
2209     {  49, "dedicated-assistance-data-not-available"},
2210     {  50, "relocation-target-not-allowed"},
2211     {  51, "location-reporting-congestion"},
2212     {  52, "reduce-load-in-serving-cell"},
2213     {  53, "no-radio-resources-available-in-target-cell"},
2214     {  54, "gERAN-Iumode-failure"},
2215     {  55, "access-restricted-due-to-shared-networks"},
2216     {  56, "incoming-relocation-not-supported-due-to-PUESBINE-feature"},
2217     {  57, "traffic-load-in-the-target-cell-higher-than-in-the-source-cell"},
2218     {  58, "mBMS-no-multicast-service-for-this-UE"},
2219     {  59, "mBMS-unknown-UE-ID"},
2220     {  60, "successful-MBMS-session-start-no-data-bearer-necessary"},
2221     {  61, "mBMS-superseded-due-to-NNSF"},
2222     {  62, "mBMS-UE-linking-already-done"},
2223     {  63, "mBMS-UE-de-linking-failure-no-existing-UE-linking"},
2224     {  64, "tMGI-unknown"},
2225 /* Transport Layer Cause (65-->80) */
2226     {  65, "Signalling Transport Resource Failure"},
2227     {  66, "Iu Transport Connection Failed to Establish"},
2228 /* NAS Cause (81-->96) */
2229     {  81, "User Restriction Start Indication"},
2230     {  82, "User Restriction End Indication"},
2231     {  83, "Normal Release"},
2232 /* Protocol Cause (97-->112) */
2233     {  97, "Transfer Syntax Error"},
2234     {  98, "Semantic Error"},
2235     {  99, "Message not compatible with receiver state"},
2236     { 100, "Abstract Syntax Error (Reject)"},
2237     { 101, "Abstract Syntax Error (Ignore and Notify)"},
2238     { 102, "Abstract Syntax Error (Falsely Constructed Message"},
2239 /* Miscellaneous Cause (113-->128) */
2240     { 113, "O & M Intervention"},
2241     { 114, "No Resource Available"},
2242     { 115, "Unspecified Failure"},
2243     { 116, "Network Optimisation"},
2244 /* Non-standard Cause (129-->255) */
2245 
2246 /* ranap_CauseRadioNetworkExtension ??
2247     { 257, "iP-multicast-address-and-APN-not-valid" },
2248     { 258, "mBMS-de-registration-rejected-due-to-implicit-registration" },
2249     { 259, "mBMS-request-superseded" },
2250     { 260, "mBMS-de-registration-during-session-not-allowed" },
2251     { 261, "mBMS-no-data-bearer-necessary" },
2252   */
2253 
2254     {0, NULL}
2255 };
2256 static value_string_ext ranap_cause_type_ext = VALUE_STRING_EXT_INIT(ranap_cause_type);
2257 
2258 static const value_string mm_sec_modep[] = {
2259     {0, "Used cipher value, UMTS keys and Quintuplets"},
2260     {1, "GSM key and triplets"},
2261     {2, "UMTS key and quintuplets"},
2262     {3, "GSM key and quintuplets"},
2263     {0, NULL}
2264 };
2265 
2266 static const value_string gtp_cipher_algorithm[] = {
2267     {0, "No ciphering"},
2268     {1, "GEA/1"},
2269     {2, "GEA/2"},
2270     {3, "GEA/3"},
2271     {4, "GEA/4"},
2272     {5, "GEA/5"},
2273     {6, "GEA/6"},
2274     {7, "GEA/7"},
2275     {0, NULL}
2276 };
2277 static const value_string gtp_ext_rat_type_vals[] = {
2278     {0, "Reserved"},
2279     {1, "UTRAN"},
2280     {2, "GERAN"},
2281     {3, "WLAN"},
2282     {4, "GAN"},
2283     {5, "HSPA Evolution"},
2284     {6, "EUTRAN (WB-E-UTRAN)"},
2285     {7, "Virtual"},
2286     {8, "EUTRAN-NB-IoT"},
2287     {0, NULL}
2288 };
2289 static const value_string chg_rep_act_type_vals[] = {
2290     {0, "Stop Reporting"},
2291     {1, "Start Reporting CGI/SAI"},
2292     {2, "Start Reporting RAI"},
2293     {0, NULL}
2294 };
2295 
2296 
2297 static const value_string geographic_location_type[] = {
2298     {0, "Cell Global Identification (CGI)"},
2299     {1, "Service Area Identity (SAI)"},
2300     {2, "Routing Area Identification (RAI)"},
2301 /* reserved for future used (3-->127) */
2302 /* values below used by Radius */
2303     {128, "TAI"},
2304     {129, "ECGI"},
2305     {130, "TAI & ECGI"},
2306     {131, "eNodeB ID"},
2307     {132, "TAI and eNodeB ID"},
2308     {133, "extended eNodeB ID"},
2309     {134, "TAI and extended eNodeB ID"},
2310     {135, "NCGI"},
2311     {136, "5GS TAI"},
2312     {137, "5GS TAI and NCGI"},
2313     {138, "NG-RAN Node ID"},
2314     {139, "5GS TAI and NG-RAN Node ID"},
2315 /* reserved for future used (140-->255) */
2316     {0, NULL}
2317 };
2318 
2319 static const value_string gtp_ext_hdr_pdu_ses_cont_pdu_type_vals[] = {
2320     {0,  "DL PDU SESSION INFORMATION"},
2321     {1,  "UL PDU SESSION INFORMATION"},
2322     {0, NULL}
2323 };
2324 
2325 
2326 #define MM_PROTO_GROUP_CALL_CONTROL     0x00
2327 #define MM_PROTO_BROADCAST_CALL_CONTROL 0x01
2328 #define MM_PROTO_PDSS1                  0x02
2329 #define MM_PROTO_CALL_CONTROL           0x03
2330 #define MM_PROTO_PDSS2                  0x04
2331 #define MM_PROTO_MM_NON_GPRS            0x05
2332 #define MM_PROTO_RR_MGMT                0x06
2333 #define MM_PROTO_MM_GPRS                0x08
2334 #define MM_PROTO_SMS                    0x09
2335 #define MM_PROTO_SESSION_MGMT           0x0A
2336 #define MM_PROTO_NON_CALL_RELATED       0x0B
2337 
2338 static void
gtpstat_init(struct register_srt * srt _U_,GArray * srt_array)2339 gtpstat_init(struct register_srt* srt _U_, GArray* srt_array)
2340 {
2341     srt_stat_table *gtp_srt_table;
2342 
2343     gtp_srt_table = init_srt_table("GTP Requests", NULL, srt_array, 4, NULL, NULL, NULL);
2344     init_srt_table_row(gtp_srt_table, 0, "Echo");
2345     init_srt_table_row(gtp_srt_table, 1, "Create PDP context");
2346     init_srt_table_row(gtp_srt_table, 2, "Update PDP context");
2347     init_srt_table_row(gtp_srt_table, 3, "Delete PDP context");
2348 }
2349 
2350 static tap_packet_status
gtpstat_packet(void * pss,packet_info * pinfo,epan_dissect_t * edt _U_,const void * prv)2351 gtpstat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prv)
2352 {
2353     guint i = 0;
2354     srt_stat_table *gtp_srt_table;
2355     srt_data_t *data = (srt_data_t *)pss;
2356     const gtp_msg_hash_t *gtp=(const gtp_msg_hash_t *)prv;
2357     int idx=0;
2358 
2359     /* we are only interested in reply packets */
2360     if(gtp->is_request){
2361         return TAP_PACKET_DONT_REDRAW;
2362     }
2363     /* if we have not seen the request, just ignore it */
2364     if(!gtp->req_frame){
2365         return TAP_PACKET_DONT_REDRAW;
2366     }
2367 
2368     /* Only use the commands we know how to handle, this is not a comprehensive list */
2369     /* Redoing the message indexing is bit reduntant,                    */
2370     /*  but using message type as such would yield a long gtp_srt_table. */
2371     /*  Only a fraction of the messages are matchable req/resp pairs,    */
2372     /*  it just doesn't feel feasible.                                   */
2373 
2374     switch(gtp->msgtype){
2375     case GTP_MSG_ECHO_REQ: idx=0;
2376         break;
2377     case GTP_MSG_CREATE_PDP_REQ: idx=1;
2378         break;
2379     case GTP_MSG_UPDATE_PDP_REQ: idx=2;
2380         break;
2381     case GTP_MSG_DELETE_PDP_REQ: idx=3;
2382         break;
2383     default:
2384         return TAP_PACKET_DONT_REDRAW;
2385     }
2386 
2387     gtp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i);
2388     add_srt_table_data(gtp_srt_table, idx, &gtp->req_time, pinfo);
2389 
2390     return TAP_PACKET_REDRAW;
2391 }
2392 
2393 
2394 static dissector_handle_t eth_handle;
2395 static dissector_handle_t ip_handle;
2396 static dissector_handle_t ipv6_handle;
2397 static dissector_handle_t ppp_handle;
2398 static dissector_handle_t sync_handle;
2399 static dissector_handle_t gtpcdr_handle;
2400 static dissector_handle_t sndcpxid_handle;
2401 static dissector_handle_t gtpv2_handle;
2402 static dissector_handle_t bssgp_handle;
2403 static dissector_handle_t pdcp_nr_handle;
2404 static dissector_handle_t pdcp_lte_handle;
2405 static dissector_handle_t gtp_tpdu_custom_handle;
2406 static dissector_table_t bssap_pdu_type_table;
2407 
2408 static int proto_pdcp_lte = -1;
2409 
2410 guint32 gtp_session_count;
2411 
2412 /* Relation between frame -> session */
2413 GHashTable* session_table;
2414 /* Relation between <teid,ip> -> frame */
2415 wmem_tree_t* frame_tree;
2416 
2417 typedef struct {
2418     guint32 teid;
2419     guint32 frame;
2420 } gtp_info_t;
2421 
2422 /* GTP Session funcs*/
2423 guint32
get_frame(address ip,guint32 teid,guint32 * frame)2424 get_frame(address ip, guint32 teid, guint32 *frame) {
2425     gboolean found = FALSE;
2426     wmem_list_frame_t *elem;
2427     gtp_info_t *info;
2428     wmem_list_t *info_list;
2429     gchar *ip_str;
2430 
2431     /* First we get the teid list*/
2432     ip_str = address_to_str(wmem_packet_scope(), &ip);
2433     info_list = (wmem_list_t*)wmem_tree_lookup_string(frame_tree, ip_str, 0);
2434     if (info_list != NULL) {
2435         elem = wmem_list_head(info_list);
2436         while (!found && elem) {
2437             info = (gtp_info_t*)wmem_list_frame_data(elem);
2438             if (teid == info->teid) {
2439                 *frame = info->frame;
2440                 return 1;
2441             }
2442             elem = wmem_list_frame_next(elem);
2443         }
2444     }
2445     return 0;
2446 }
2447 
2448 static gboolean
call_foreach_ip(const void * key _U_,void * value,void * data)2449 call_foreach_ip(const void *key _U_, void *value, void *data){
2450     wmem_list_frame_t * elem;
2451     wmem_list_t *info_list = (wmem_list_t *)value;
2452     gtp_info_t *info;
2453     guint32* frame = (guint32*)data;
2454 
2455     /* We loop over the <teid, frame> list */
2456     elem = wmem_list_head(info_list);
2457     while (elem) {
2458         info = (gtp_info_t*)wmem_list_frame_data(elem);
2459         if (info->frame == *frame) {
2460             wmem_list_frame_t * del = elem;
2461             /* proceed to next request */
2462             elem = wmem_list_frame_next(elem);
2463             /* If we find the frame we remove its information from the list */
2464             wmem_list_remove_frame(info_list, del);
2465             wmem_free(wmem_file_scope(), info);
2466         }
2467         else {
2468             elem = wmem_list_frame_next(elem);
2469         }
2470     }
2471 
2472     return FALSE;
2473 }
2474 
2475 void
remove_frame_info(guint32 * f)2476 remove_frame_info(guint32 *f) {
2477     /* For each ip node */
2478     wmem_tree_foreach(frame_tree, call_foreach_ip, (void *)f);
2479 }
2480 
2481 void
add_gtp_session(guint32 frame,guint32 session)2482 add_gtp_session(guint32 frame, guint32 session) {
2483     guint32 *f, *session_count;
2484 
2485     f = wmem_new0(wmem_file_scope(), guint32);
2486     session_count = wmem_new0(wmem_file_scope(), guint32);
2487     *f = frame;
2488     *session_count = session;
2489     g_hash_table_insert(session_table, f, session_count);
2490 }
2491 
2492 gboolean
teid_exists(guint32 teid,wmem_list_t * teid_list)2493 teid_exists(guint32 teid, wmem_list_t *teid_list) {
2494     wmem_list_frame_t *elem;
2495     guint32 *info;
2496     gboolean found;
2497     found = FALSE;
2498     elem = wmem_list_head(teid_list);
2499     while (!found && elem) {
2500         info = (guint32*)wmem_list_frame_data(elem);
2501         found = *info == teid;
2502         elem = wmem_list_frame_next(elem);
2503     }
2504     return found;
2505 }
2506 
2507 gboolean
ip_exists(address ip,wmem_list_t * ip_list)2508 ip_exists(address ip, wmem_list_t *ip_list) {
2509     wmem_list_frame_t *elem;
2510     address *info;
2511     gboolean found;
2512     found = FALSE;
2513     elem = wmem_list_head(ip_list);
2514     while (!found && elem) {
2515         info = (address*)wmem_list_frame_data(elem);
2516         found = addresses_equal(info, &ip);
2517         elem = wmem_list_frame_next(elem);
2518     }
2519     return found;
2520 }
2521 
2522 static gboolean
info_exists(gtp_info_t * wanted,wmem_list_t * info_list)2523 info_exists(gtp_info_t *wanted, wmem_list_t *info_list) {
2524     wmem_list_frame_t *elem;
2525     gtp_info_t *info;
2526     gboolean found;
2527     found = FALSE;
2528     elem = wmem_list_head(info_list);
2529     while (!found && elem) {
2530         info = (gtp_info_t*)wmem_list_frame_data(elem);
2531         found = wanted->teid == info->teid;
2532         elem = wmem_list_frame_next(elem);
2533     }
2534     return found;
2535 }
2536 
2537 void
fill_map(wmem_list_t * teid_list,wmem_list_t * ip_list,guint32 frame)2538 fill_map(wmem_list_t *teid_list, wmem_list_t *ip_list, guint32 frame) {
2539     wmem_list_frame_t *elem_ip, *elem_teid;
2540     gtp_info_t *gtp_info;
2541     wmem_list_t * info_list; /* List of <teids,frames>*/
2542     guint32 *f, *session, *fr, *session_count;
2543     GHashTableIter iter;
2544     guint32 teid;
2545     gchar *ip;
2546 
2547     elem_ip = wmem_list_head(ip_list);
2548     while (elem_ip) {
2549         ip = address_to_str(wmem_file_scope(), (address*)wmem_list_frame_data(elem_ip));
2550         /* We check if a teid list exists for this ip */
2551         info_list = (wmem_list_t*)wmem_tree_lookup_string(frame_tree, ip, 0);
2552         if (info_list == NULL) {
2553             info_list = wmem_list_new(wmem_file_scope());
2554         }
2555         /* We loop over the teid list */
2556         elem_teid = wmem_list_head(teid_list);
2557         while (elem_teid) {
2558             teid = *(guint32*)wmem_list_frame_data(elem_teid);
2559             f = wmem_new0(wmem_file_scope(), guint32);
2560             *f = frame;
2561             gtp_info = wmem_new0(wmem_file_scope(), gtp_info_t);
2562             gtp_info->teid = teid;
2563             gtp_info->frame = *f;
2564             if (info_exists(gtp_info, info_list)) {
2565                 /* If the teid and ip already existed, that means that we need to remove old info about that session */
2566                 /* We look for its session ID */
2567                 session = (guint32 *)g_hash_table_lookup(session_table, f);
2568                 if (session) {
2569                     g_hash_table_iter_init(&iter, session_table);
2570                     while (g_hash_table_iter_next(&iter, (gpointer*)&fr, (gpointer*)&session_count)) {
2571                         /* If the msg has the same session ID and it's not the upd req we have to remove its info */
2572                         if (*session_count == *session) {
2573                             /* If it's the session we are looking for, we remove all the frame information */
2574                             remove_frame_info(fr);
2575                         }
2576                     }
2577                 }
2578             }
2579             wmem_list_prepend(info_list, gtp_info);
2580             elem_teid = wmem_list_frame_next(elem_teid);
2581         }
2582         wmem_tree_insert_string(frame_tree, ip, info_list, 0);
2583         elem_ip = wmem_list_frame_next(elem_ip);
2584     }
2585 }
2586 
2587 gboolean
is_cause_accepted(guint8 cause,guint32 version)2588 is_cause_accepted(guint8 cause, guint32 version) {
2589     if (version == 1) {
2590         return cause == 128 || cause == 129 || cause == 130;
2591     }
2592     else if (version == 2) {
2593         return cause == 16 || cause == 17 || cause == 18 || cause == 19;
2594     }
2595     return FALSE;
2596 }
2597 
2598 static int decode_gtp_cause(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args);
2599 static int decode_gtp_imsi(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2600 static int decode_gtp_rai(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2601 static int decode_gtp_tlli(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2602 static int decode_gtp_ptmsi(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2603 static int decode_gtp_qos_gprs(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2604 static int decode_gtp_reorder(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2605 static int decode_gtp_auth_tri(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2606 static int decode_gtp_map_cause(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2607 static int decode_gtp_ptmsi_sig(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2608 static int decode_gtp_ms_valid(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2609 static int decode_gtp_recovery(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2610 static int decode_gtp_sel_mode(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2611 static int decode_gtp_16(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args);
2612 static int decode_gtp_17(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args);
2613 static int decode_gtp_18(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2614 static int decode_gtp_19(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2615 static int decode_gtp_nsapi(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2616 static int decode_gtp_ranap_cause(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2617 static int decode_gtp_rab_cntxt(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2618 static int decode_gtp_rp_sms(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2619 static int decode_gtp_rp(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2620 static int decode_gtp_pkt_flow_id(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2621 static int decode_gtp_chrg_char(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2622 static int decode_gtp_trace_ref(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2623 static int decode_gtp_trace_type(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2624 static int decode_gtp_ms_reason(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2625 static int decode_gtp_tr_comm(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2626 static int decode_gtp_chrg_id(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2627 static int decode_gtp_user_addr(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2628 static int decode_gtp_mm_cntxt(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2629 static int decode_gtp_pdp_cntxt(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2630 static int decode_gtp_apn(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2631 static int decode_gtp_gsn_addr_common(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args, const char * tree_name, int hf_ipv4, int hf_ipv6);
2632 static int decode_gtp_gsn_addr(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args);
2633 static int decode_gtp_sgsn_addr_for_control_plane(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args);
2634 static int decode_gtp_sgsn_addr_for_user_plane(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args);
2635 static int decode_gtp_ggsn_addr_for_control_plane(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args);
2636 static int decode_gtp_ggsn_addr_for_user_plane(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args);
2637 static int decode_gtp_proto_conf(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2638 static int decode_gtp_msisdn(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2639 static int decode_gtp_qos_umts(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2640 static int decode_gtp_auth_qui(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2641 static int decode_gtp_tft(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2642 static int decode_gtp_target_id(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2643 static int decode_gtp_utran_cont(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2644 static int decode_gtp_rab_setup(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2645 static int decode_gtp_hdr_list(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2646 static int decode_gtp_trigger_id(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2647 static int decode_gtp_omc_id(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2648 
2649 static int decode_gtp_ran_tr_cont(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2650 static int decode_gtp_pdp_cont_prio(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2651 static int decode_gtp_add_rab_setup_inf(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2652 static int decode_gtp_sgsn_no(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2653 static int decode_gtp_common_flgs(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2654 static int decode_gtp_apn_res(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2655 static int decode_gtp_ra_prio_lcs(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2656 static int decode_gtp_rat_type(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2657 static int decode_gtp_usr_loc_inf(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2658 static int decode_gtp_ms_time_zone(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2659 static int decode_gtp_imeisv(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2660 static int decode_gtp_camel_chg_inf_con(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2661 static int decode_gtp_mbms_ue_ctx(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2662 static int decode_gtp_tmgi(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2663 static int decode_gtp_rim_ra(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2664 static int decode_gtp_mbms_prot_conf_opt(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2665 static int decode_gtp_mbms_sa(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2666 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_);
2667 static int decode_gtp_add_trs_inf(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2668 static int decode_gtp_hop_count(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2669 static int decode_gtp_sel_plmn_id(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2670 static int decode_gtp_mbms_ses_id(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2671 static int decode_gtp_mbms_2g_3g_ind(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2672 static int decode_gtp_enh_nsapi(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2673 static int decode_gtp_mbms_ses_dur(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2674 static int decode_gtp_add_mbms_trs_inf(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2675 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_);
2676 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_);
2677 static int decode_gtp_ps_ho_req_ctx(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2678 static int decode_gtp_bss_cont(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2679 static int decode_gtp_cell_id(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2680 static int decode_gtp_pdu_no(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2681 static int decode_gtp_bssgp_cause(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2682 static int decode_gtp_mbms_bearer_cap(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2683 static int decode_gtp_rim_ra_disc(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2684 static int decode_gtp_lst_set_up_pfc(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2685 static int decode_gtp_ps_handover_xid(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2686 static int decode_gtp_direct_tnl_flg(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2687 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_);
2688 static int decode_gtp_corrl_id(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2689 static int decode_gtp_fqdn(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2690 static int decode_gtp_evolved_allc_rtn_p1(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2691 static int decode_gtp_evolved_allc_rtn_p2(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2692 static int decode_gtp_extended_common_flgs(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2693 static int decode_gtp_uci(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2694 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_);
2695 static int decode_gtp_csg_id(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2696 static int decode_gtp_cmi(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2697 static int decode_gtp_apn_ambr(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2698 static int decode_gtp_ue_network_cap(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2699 static int decode_gtp_ue_ambr(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2700 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_);
2701 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_);
2702 static int decode_gtp_sig_pri_ind(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2703 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_);
2704 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_);
2705 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_);
2706 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_);
2707 static int decode_gtp_add_flgs_srvcc(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2708 static int decode_gtp_stn_sr(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2709 static int decode_gtp_c_msisdn(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2710 static int decode_gtp_ext_ranap_cause(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2711 static int decode_gtp_ext_enodeb_id(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2712 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_);
2713 static int decode_gtp_ext_uli_timestamp(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2714 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_);
2715 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_);
2716 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_);
2717 static int decode_gtp_ext_node_id(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2718 
2719 static int decode_gtp_bearer_cntrl_mod(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2720 static int decode_gtp_mbms_flow_id(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2721 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_);
2722 static int decode_gtp_mbms_dist_ack(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2723 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_);
2724 static int decode_gtp_rfsp_index(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
2725 
2726 static int decode_gtp_chrg_addr(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2727 static int decode_gtp_rel_pack(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2728 static int decode_gtp_can_pack(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2729 static int decode_gtp_data_req(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2730 static int decode_gtp_data_resp(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2731 static int decode_gtp_node_addr(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2732 static int decode_gtp_priv_ext(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2733 static int decode_gtp_unknown(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
2734 
2735 typedef struct {
2736     int optcode;
2737     int (*decode) (tvbuff_t *, int, packet_info *, proto_tree *, session_args_t *);
2738 } gtp_opt_t;
2739 
2740 static const gtp_opt_t gtpopt[] = {
2741 /* 0x01 */  {GTP_EXT_CAUSE, decode_gtp_cause},
2742 /* 0x02 */  {GTP_EXT_IMSI, decode_gtp_imsi},
2743 /* 0x03 */  {GTP_EXT_RAI, decode_gtp_rai},
2744 /* 0x04 */  {GTP_EXT_TLLI, decode_gtp_tlli},
2745 /* 0x05 */  {GTP_EXT_PTMSI, decode_gtp_ptmsi},
2746 /* 0x06 */  {GTP_EXT_QOS_GPRS, decode_gtp_qos_gprs},
2747 /* 0x07 */
2748 /* 0x08 */  {GTP_EXT_REORDER, decode_gtp_reorder},
2749 /* 0x09 */  {GTP_EXT_AUTH_TRI, decode_gtp_auth_tri},
2750 /* 0x0a */
2751 /* 0x0b */  {GTP_EXT_MAP_CAUSE, decode_gtp_map_cause},
2752 /* 0x0c */  {GTP_EXT_PTMSI_SIG, decode_gtp_ptmsi_sig},
2753 /* 0x0d */  {GTP_EXT_MS_VALID, decode_gtp_ms_valid},
2754 /* 0x0e */  {GTP_EXT_RECOVER, decode_gtp_recovery},
2755 /* 0x0f */  {GTP_EXT_SEL_MODE, decode_gtp_sel_mode},
2756 /* 0x10 */  {GTP_EXT_16, decode_gtp_16},
2757 /* 0x11 */  {GTP_EXT_17, decode_gtp_17},
2758 /* 0x12 */  {GTP_EXT_18, decode_gtp_18},
2759 /* 0x13 */  {GTP_EXT_19, decode_gtp_19},
2760 /* 0x14 */  {GTP_EXT_NSAPI, decode_gtp_nsapi},
2761 /* 0x15 */  {GTP_EXT_RANAP_CAUSE, decode_gtp_ranap_cause},
2762 /* 0x16 */  {GTP_EXT_RAB_CNTXT, decode_gtp_rab_cntxt},
2763 /* 0x17 */  {GTP_EXT_RP_SMS, decode_gtp_rp_sms},
2764 /* 0x18 */  {GTP_EXT_RP, decode_gtp_rp},
2765 /* 0x19 */  {GTP_EXT_PKT_FLOW_ID, decode_gtp_pkt_flow_id},
2766 /* 0x1a */  {GTP_EXT_CHRG_CHAR, decode_gtp_chrg_char},
2767 /* 0x1b */  {GTP_EXT_TRACE_REF, decode_gtp_trace_ref},
2768 /* 0x1c */  {GTP_EXT_TRACE_TYPE, decode_gtp_trace_type},
2769 /* 0x1d */  {GTPv1_EXT_MS_REASON, decode_gtp_ms_reason},
2770 
2771 /* 0x7e */  {GTP_EXT_TR_COMM, decode_gtp_tr_comm},
2772 /* 0x7f */  {GTP_EXT_CHRG_ID, decode_gtp_chrg_id},
2773 /* 0x80 */  {GTP_EXT_USER_ADDR, decode_gtp_user_addr},
2774 /* 0x81 */  {GTP_EXT_MM_CNTXT, decode_gtp_mm_cntxt},
2775 /* 0x82 */  {GTP_EXT_PDP_CNTXT, decode_gtp_pdp_cntxt},
2776 /* 0x83 */  {GTP_EXT_APN, decode_gtp_apn},
2777 /* 0x84 */  {GTP_EXT_PROTO_CONF, decode_gtp_proto_conf},
2778 /* 0x85 */  {GTP_EXT_GSN_ADDR, decode_gtp_gsn_addr},
2779 /* 0x86 */  {GTP_EXT_MSISDN, decode_gtp_msisdn},
2780 /* 0x87 */  {GTP_EXT_QOS_UMTS, decode_gtp_qos_umts},                            /* 3G */
2781 /* 0x88 */  {GTP_EXT_AUTH_QUI, decode_gtp_auth_qui},                            /* 3G */
2782 /* 0x89 */  {GTP_EXT_TFT, decode_gtp_tft},                                      /* 3G */
2783 /* 0x8a */  {GTP_EXT_TARGET_ID, decode_gtp_target_id},                          /* 3G */
2784 /* 0x8b */  {GTP_EXT_UTRAN_CONT, decode_gtp_utran_cont},                        /* 3G */
2785 /* 0x8c */  {GTP_EXT_RAB_SETUP, decode_gtp_rab_setup},                          /* 3G */
2786 /* 0x8d */  {GTP_EXT_HDR_LIST, decode_gtp_hdr_list},                            /* 3G */
2787 /* 0x8e */  {GTP_EXT_TRIGGER_ID, decode_gtp_trigger_id},                        /* 3G */
2788 /* 0x8f */  {GTP_EXT_OMC_ID, decode_gtp_omc_id},                                /* 3G */
2789     /* TS 29 060 V6.11.0 */
2790 /* 0x90 */  {GTP_EXT_RAN_TR_CONT, decode_gtp_ran_tr_cont},                      /* 7.7.43 */
2791 /* 0x91 */  {GTP_EXT_PDP_CONT_PRIO, decode_gtp_pdp_cont_prio},                  /* 7.7.45 */
2792 /* 0x92 */  {GTP_EXT_ADD_RAB_SETUP_INF, decode_gtp_add_rab_setup_inf},          /* 7.7.45A */
2793 /* 0x93 */  {GTP_EXT_SGSN_NO, decode_gtp_sgsn_no},                              /* 7.7.47 */
2794 /* 0x94 */  {GTP_EXT_COMMON_FLGS, decode_gtp_common_flgs},                      /* 7.7.48 */
2795 /* 0x95 */  {GTP_EXT_APN_RES, decode_gtp_apn_res},                              /* 3G */
2796 /* 0x96 */  {GTP_EXT_RA_PRIO_LCS, decode_gtp_ra_prio_lcs},                      /* 7.7.25B */
2797 /* 0x97 */  {GTP_EXT_RAT_TYPE, decode_gtp_rat_type},                            /* 3G */
2798 /* 0x98 */  {GTP_EXT_USR_LOC_INF, decode_gtp_usr_loc_inf},                      /* 7.7.51 */
2799 /* 0x99 */  {GTP_EXT_MS_TIME_ZONE, decode_gtp_ms_time_zone},                    /* 7.7.52 */
2800 /* 0x9a */  {GTP_EXT_IMEISV, decode_gtp_imeisv},                                /* 3G 7.7.53 */
2801 /* 0x9b */  {GTP_EXT_CAMEL_CHG_INF_CON, decode_gtp_camel_chg_inf_con},          /* 7.7.54 */
2802 /* 0x9c */  {GTP_EXT_MBMS_UE_CTX, decode_gtp_mbms_ue_ctx},                      /* 7.7.55 */
2803 /* 0x9d */  {GTP_EXT_TMGI, decode_gtp_tmgi},                                    /* 7.7.56 */
2804 /* 0x9e */  {GTP_EXT_RIM_RA, decode_gtp_rim_ra},                                /* 7.7.57 */
2805 /* 0x9f */  {GTP_EXT_MBMS_PROT_CONF_OPT, decode_gtp_mbms_prot_conf_opt},        /* 7.7.58 */
2806 /* 0xa0 */  {GTP_EXT_MBMS_SA, decode_gtp_mbms_sa},                              /* 7.7.60 */
2807 /* 0xa1 */  {GTP_EXT_SRC_RNC_PDP_CTX_INF, decode_gtp_src_rnc_pdp_ctx_inf},      /* 7.7.61 */
2808 /* 0xa2 */  {GTP_EXT_ADD_TRS_INF, decode_gtp_add_trs_inf},                      /* 7.7.62 */
2809 /* 0xa3 */  {GTP_EXT_HOP_COUNT, decode_gtp_hop_count},                          /* 7.7.63 */
2810 /* 0xa4 */  {GTP_EXT_SEL_PLMN_ID, decode_gtp_sel_plmn_id},                      /* 7.7.64 */
2811 /* 0xa5 */  {GTP_EXT_MBMS_SES_ID, decode_gtp_mbms_ses_id},                      /* 7.7.65 */
2812 /* 0xa6 */  {GTP_EXT_MBMS_2G_3G_IND, decode_gtp_mbms_2g_3g_ind},                /* 7.7.66 */
2813 /* 0xa7 */  {GTP_EXT_ENH_NSAPI, decode_gtp_enh_nsapi},                          /* 7.7.67 */
2814 /* 0xa8 */  {GTP_EXT_MBMS_SES_DUR, decode_gtp_mbms_ses_dur},                    /* 7.7.59 */
2815 /* 0xa9 */  {GTP_EXT_ADD_MBMS_TRS_INF, decode_gtp_add_mbms_trs_inf},            /* 7.7.68 */
2816 /* 0xaa */  {GTP_EXT_MBMS_SES_ID_REP_NO, decode_gtp_mbms_ses_id_rep_no},        /* 7.7.69 */
2817 /* 0xab */  {GTP_EXT_MBMS_TIME_TO_DATA_TR, decode_gtp_mbms_time_to_data_tr},    /* 7.7.70 */
2818 /* 0xac */  {GTP_EXT_PS_HO_REQ_CTX, decode_gtp_ps_ho_req_ctx},                  /* 7.7.71 */
2819 /* 0xad */  {GTP_EXT_BSS_CONT, decode_gtp_bss_cont},                            /* 7.7.72 */
2820 /* 0xae */  {GTP_EXT_CELL_ID, decode_gtp_cell_id},                              /* 7.7.73 */
2821 /* 0xaf */  {GTP_EXT_PDU_NO, decode_gtp_pdu_no},                                /* 7.7.74 */
2822 /* 0xb0 */  {GTP_EXT_BSSGP_CAUSE, decode_gtp_bssgp_cause},                      /* 7.7.75 */
2823 /* 0xb1 */  {GTP_EXT_REQ_MBMS_BEARER_CAP, decode_gtp_mbms_bearer_cap},          /* 7.7.76 */
2824 /* 0xb2 */  {GTP_EXT_RIM_ROUTING_ADDR_DISC, decode_gtp_rim_ra_disc},            /* 7.7.77 */
2825 /* 0xb3 */  {GTP_EXT_LIST_OF_SETUP_PFCS, decode_gtp_lst_set_up_pfc},            /* 7.7.78 */
2826 /* 0xb4 */  {GTP_EXT_PS_HANDOVER_XIP_PAR, decode_gtp_ps_handover_xid},          /* 7.7.79 */
2827 /* 0xb5 */  {GTP_EXT_MS_INF_CHG_REP_ACT, decode_gtp_ms_inf_chg_rep_act},        /* 7.7.80 */
2828 /* 0xb6 */  {GTP_EXT_DIRECT_TUNNEL_FLGS, decode_gtp_direct_tnl_flg},            /* 7.7.81 */
2829 /* 0xb7 */  {GTP_EXT_CORRELATION_ID, decode_gtp_corrl_id},                      /* 7.7.82 */
2830 /* 0xb8 */  {GTP_EXT_BEARER_CONTROL_MODE, decode_gtp_bearer_cntrl_mod},         /* 7.7.83 */
2831 /* 0xb9 */  {GTP_EXT_MBMS_FLOW_ID, decode_gtp_mbms_flow_id},                    /* 7.7.84 */
2832 /* 0xba */  {GTP_EXT_MBMS_IP_MCAST_DIST, decode_gtp_mbms_ip_mcast_dist},        /* 7.7.85 */
2833 /* 0xba */  {GTP_EXT_MBMS_DIST_ACK, decode_gtp_mbms_dist_ack},                  /* 7.7.86 */
2834 /* 0xbc */  {GTP_EXT_RELIABLE_IRAT_HO_INF, decode_gtp_reliable_irat_ho_inf},    /* 7.7.87 */
2835 /* 0xbd */  {GTP_EXT_RFSP_INDEX, decode_gtp_rfsp_index},                        /* 7.7.87 */
2836 
2837 /* 0xbe */  {GTP_EXT_FQDN, decode_gtp_fqdn},                                    /* 7.7.90 */
2838 /* 0xbf */  {GTP_EXT_EVO_ALLO_RETE_P1, decode_gtp_evolved_allc_rtn_p1},         /* 7.7.91 */
2839 /* 0xc0 */  {GTP_EXT_EVO_ALLO_RETE_P2, decode_gtp_evolved_allc_rtn_p2},         /* 7.7.92 */
2840 /* 0xc1 */  {GTP_EXT_EXTENDED_COMMON_FLGS, decode_gtp_extended_common_flgs},    /* 7.7.93 */
2841 /* 0xc2 */  {GTP_EXT_UCI, decode_gtp_uci},                                      /* 7.7.94 */
2842 /* 0xc3 */  {GTP_EXT_CSG_INF_REP_ACT, decode_gtp_csg_inf_rep_act},              /* 7.7.95 */
2843 /* 0xc4 */  {GTP_EXT_CSG_ID, decode_gtp_csg_id},                                /* 7.7.96 */
2844 /* 0xc5 */  {GTP_EXT_CMI, decode_gtp_cmi},                                      /* 7.7.97 */
2845 /* 0xc6 */  {GTP_EXT_AMBR, decode_gtp_apn_ambr},                                /* 7.7.98 */
2846 /* 0xc7 */  {GTP_EXT_UE_NETWORK_CAP, decode_gtp_ue_network_cap},                /* 7.7.99 */
2847 /* 0xc8 */  {GTP_EXT_UE_AMBR, decode_gtp_ue_ambr},                              /* 7.7.100 */
2848 /* 0xc9 */  {GTP_EXT_APN_AMBR_WITH_NSAPI, decode_gtp_apn_ambr_with_nsapi},      /* 7.7.101 */
2849 /* 0xCA */  {GTP_EXT_GGSN_BACK_OFF_TIME, decode_gtp_ggsn_back_off_time},        /* 7.7.102 */
2850 /* 0xCB */  {GTP_EXT_SIG_PRI_IND, decode_gtp_sig_pri_ind},                      /* 7.7.103 */
2851 /* 0xCC */  {GTP_EXT_SIG_PRI_IND_W_NSAPI, decode_gtp_sig_pri_ind_w_nsapi},      /* 7.7.104 */
2852 /* 0xCD */  {GTP_EXT_HIGHER_BR_16MB_FLG, decode_gtp_higher_br_16mb_flg},        /* 7.7.105 */
2853 /* 0xCE */  {GTP_EXT_MAX_MBR_APN_AMBR, decode_gtp_max_mbr_apn_ambr},            /* 7.7.106 */
2854 /* 0xCF */  {GTP_EXT_ADD_MM_CTX_SRVCC, decode_gtp_add_mm_ctx_srvcc},            /* 7.7.107 */
2855 /* 0xD0 */  {GTP_EXT_ADD_FLGS_SRVCC, decode_gtp_add_flgs_srvcc},                /* 7.7.108 */
2856 /* 0xD1 */  {GTP_EXT_STN_SR, decode_gtp_stn_sr},                                /* 7.7.109 */
2857 /* 0xD2 */  {GTP_EXT_C_MSISDN, decode_gtp_c_msisdn},                            /* 7.7.110 */
2858 /* 0xD3 */  {GTP_EXT_EXT_RANAP_CAUSE, decode_gtp_ext_ranap_cause},              /* 7.7.111 */
2859 /* 0xD4 */  {GTP_EXT_ENODEB_ID, decode_gtp_ext_enodeb_id },                     /* 7.7.112 */
2860 /* 0xD5 */  {GTP_EXT_SEL_MODE_W_NSAPI, decode_gtp_ext_sel_mode_w_nsapi },       /* 7.7.113 */
2861 /* 0xD6 */  {GTP_EXT_ULI_TIMESTAMP, decode_gtp_ext_uli_timestamp },             /* 7.7.114 */
2862 /* 0xD7 */  {GTP_EXT_LHN_ID_W_SAPI, decode_gtp_ext_lhn_id_w_sapi },             /* 7.7.115 */
2863 /* 0xD8 */  {GTP_EXT_CN_OP_SEL_ENTITY, decode_gtp_ext_cn_op_sel_entity },       /* 7.7.116 */
2864 
2865 /* 0xDA */  {GTP_EXT_EXT_COMMON_FLGS_II, decode_gtp_extended_common_flgs_II },  /* 7.7.118 */
2866 /* 0xDB */  {GTP_EXT_NODE_IDENTIFIER, decode_gtp_ext_node_id },                 /* 7.7.119 */
2867 
2868 /* 0xf9 */  {GTP_EXT_REL_PACK, decode_gtp_rel_pack },                           /* charging */
2869 /* 0xfa */  {GTP_EXT_CAN_PACK, decode_gtp_can_pack},                            /* charging */
2870 /* 0xfb */  {GTP_EXT_CHRG_ADDR, decode_gtp_chrg_addr},
2871 
2872 /* 0xfc */  {GTP_EXT_DATA_REQ, decode_gtp_data_req},                           /* charging */
2873 /* 0xfd */  {GTP_EXT_DATA_RESP, decode_gtp_data_resp},                         /* charging */
2874 /* 0xfe */  {GTP_EXT_NODE_ADDR, decode_gtp_node_addr},
2875 /* 0xff */  {GTP_EXT_PRIV_EXT, decode_gtp_priv_ext},
2876     {0, decode_gtp_unknown}
2877 };
2878 
2879 #define NUM_GTP_IES 255
2880 static gint ett_gtp_ies[NUM_GTP_IES];
2881 
2882 static guint8 gtp_version = 0;
2883 
2884 #define BCD2CHAR(d)         ((d) | 0x30)
2885 
2886 static gchar *
id_to_str(tvbuff_t * tvb,gint offset)2887 id_to_str(tvbuff_t *tvb, gint offset)
2888 {
2889     static gchar str[17] = "                ";
2890     guint8 bits8to5, bits4to1;
2891     int i, j;
2892     guint8 ad;
2893 
2894     for (i = j = 0; i < 8; i++) {
2895         ad = tvb_get_guint8(tvb, offset + i);
2896         bits8to5 = hi_nibble(ad);
2897         bits4to1 = lo_nibble(ad);
2898         if (bits4to1 <= 9)
2899             str[j++] = BCD2CHAR(bits4to1);
2900         else
2901             str[j++] = ' ';
2902         if (bits8to5 <= 9)
2903             str[j++] = BCD2CHAR(bits8to5);
2904         else
2905             str[j++] = ' ';
2906     }
2907     str[j] = '\0';
2908     return str;
2909 }
2910 
2911 
2912 /* Next definitions and function check_field_presence_and_decoder checks if given field
2913  * in GTP packet is compliant with ETSI
2914  */
2915 typedef int (ie_decoder) (tvbuff_t *, int, packet_info *, proto_tree *, session_args_t *);
2916 
2917 typedef struct {
2918     guint8 code;
2919     guint8 presence;
2920     ie_decoder *alt_decoder;
2921 } ext_header;
2922 
2923 typedef struct {
2924     guint8 code;
2925     ext_header fields[32];
2926 } _gtp_mess_items;
2927 
2928 /* ---------------------
2929  * GPRS messages
2930  * ---------------------*/
2931 static _gtp_mess_items gprs_mess_items[] = {
2932 
2933     {
2934         GTP_MSG_ECHO_REQ, {
2935             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
2936             {0, 0, NULL}
2937         }
2938     },
2939     {
2940         GTP_MSG_ECHO_RESP, {
2941             {GTP_EXT_RECOVER, GTP_MANDATORY, NULL},
2942             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
2943             {0, 0, NULL}
2944         }
2945     },
2946     {
2947         GTP_MSG_VER_NOT_SUPP, {
2948             {0, 0, NULL}
2949         }
2950     },
2951     {
2952         GTP_MSG_NODE_ALIVE_REQ, {
2953             {GTP_EXT_NODE_ADDR, GTP_MANDATORY, NULL},
2954             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
2955             {0, 0, NULL}
2956         }
2957     },
2958     {
2959         GTP_MSG_NODE_ALIVE_RESP, {
2960             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
2961             {0, 0, NULL}
2962         }
2963     },
2964     {
2965         GTP_MSG_REDIR_REQ, {
2966             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
2967             {GTP_EXT_NODE_ADDR, GTP_OPTIONAL, NULL},
2968             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
2969             {0, 0, NULL}
2970         }
2971     },
2972     {
2973         GTP_MSG_REDIR_RESP, {
2974             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
2975             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
2976             {0, 0, NULL}
2977         }
2978     },
2979     {
2980         GTP_MSG_CREATE_PDP_REQ, {
2981             {GTP_EXT_QOS_GPRS, GTP_MANDATORY, NULL},
2982             {GTP_EXT_RECOVER, GTP_OPTIONAL, NULL},
2983             {GTP_EXT_SEL_MODE, GTP_MANDATORY, NULL},
2984             {GTP_EXT_FLOW_LABEL, GTP_MANDATORY, NULL},
2985             {GTP_EXT_FLOW_SIG, GTP_MANDATORY, NULL},
2986             {GTP_EXT_MSISDN, GTP_MANDATORY, NULL},
2987             {GTP_EXT_USER_ADDR, GTP_MANDATORY, NULL},
2988             {GTP_EXT_APN, GTP_MANDATORY, NULL},
2989             {GTP_EXT_PROTO_CONF, GTP_OPTIONAL, NULL},
2990             {GTP_EXT_GSN_ADDR, GTP_MANDATORY, NULL},
2991             {GTP_EXT_GSN_ADDR, GTP_MANDATORY, NULL},
2992             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
2993             {0, 0, NULL}
2994         }
2995     },
2996     {
2997         GTP_MSG_CREATE_PDP_RESP, {
2998             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
2999             {GTP_EXT_QOS_GPRS, GTP_CONDITIONAL, NULL},
3000             {GTP_EXT_REORDER, GTP_CONDITIONAL, NULL},
3001             {GTP_EXT_RECOVER, GTP_OPTIONAL, NULL},
3002             {GTP_EXT_FLOW_LABEL, GTP_CONDITIONAL, NULL},
3003             {GTP_EXT_FLOW_SIG, GTP_CONDITIONAL, NULL},
3004             {GTP_EXT_CHRG_ID, GTP_CONDITIONAL, NULL},
3005             {GTP_EXT_USER_ADDR, GTP_CONDITIONAL, NULL},
3006             {GTP_EXT_PROTO_CONF, GTP_OPTIONAL, NULL},
3007             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL, NULL},
3008             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL, NULL},
3009             {GTP_EXT_CHRG_ADDR, GTP_OPTIONAL, NULL},
3010             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3011             {0, 0, NULL}
3012         }
3013     },
3014     {
3015         GTP_MSG_UPDATE_PDP_REQ, {
3016             {GTP_EXT_QOS_GPRS, GTP_MANDATORY, NULL},
3017             {GTP_EXT_RECOVER, GTP_OPTIONAL, NULL},
3018             {GTP_EXT_FLOW_LABEL, GTP_MANDATORY, NULL},
3019             {GTP_EXT_FLOW_SIG, GTP_MANDATORY, NULL},
3020             {GTP_EXT_GSN_ADDR, GTP_MANDATORY, NULL},
3021             {GTP_EXT_GSN_ADDR, GTP_MANDATORY, NULL},
3022             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3023             {0, 0, NULL},
3024         }
3025     },
3026     {
3027         GTP_MSG_UPDATE_PDP_RESP, {
3028             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3029             {GTP_EXT_QOS_GPRS, GTP_CONDITIONAL, NULL},
3030             {GTP_EXT_RECOVER, GTP_OPTIONAL, NULL},
3031             {GTP_EXT_FLOW_LABEL, GTP_CONDITIONAL, NULL},
3032             {GTP_EXT_FLOW_SIG, GTP_CONDITIONAL, NULL},
3033             {GTP_EXT_CHRG_ID, GTP_CONDITIONAL, NULL},
3034             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL, NULL},
3035             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL, NULL},
3036             {GTP_EXT_CHRG_ADDR, GTP_OPTIONAL, NULL},
3037             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3038             {0, 0, NULL}
3039         }
3040     },
3041     {
3042         GTP_MSG_DELETE_PDP_REQ, {
3043             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3044             {0, 0, NULL}
3045         }
3046     },
3047     {
3048         GTP_MSG_DELETE_PDP_RESP, {
3049             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3050             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3051             {0, 0, NULL},
3052         }
3053     },
3054     {
3055         GTP_MSG_INIT_PDP_CONTEXT_ACT_REQ, {
3056             {GTP_EXT_QOS_GPRS, GTP_MANDATORY, NULL},
3057             {GTP_EXT_RECOVER, GTP_OPTIONAL, NULL},
3058             {GTP_EXT_SEL_MODE, GTP_MANDATORY, NULL},
3059             {GTP_EXT_FLOW_LABEL, GTP_MANDATORY, NULL},
3060             {GTP_EXT_FLOW_SIG, GTP_MANDATORY, NULL},
3061             {GTP_EXT_USER_ADDR, GTP_MANDATORY, NULL},
3062             {GTP_EXT_APN, GTP_MANDATORY, NULL},
3063             {GTP_EXT_PROTO_CONF, GTP_OPTIONAL, NULL},
3064             {GTP_EXT_GSN_ADDR, GTP_MANDATORY, NULL},
3065             {GTP_EXT_GSN_ADDR, GTP_MANDATORY, NULL},
3066             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3067             {0, 0, NULL}
3068         }
3069     },
3070     {
3071         GTP_MSG_INIT_PDP_CONTEXT_ACT_RESP, {
3072             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3073             {GTP_EXT_QOS_GPRS, GTP_CONDITIONAL, NULL},
3074             {GTP_EXT_REORDER, GTP_CONDITIONAL, NULL},
3075             {GTP_EXT_RECOVER, GTP_OPTIONAL, NULL},
3076             {GTP_EXT_FLOW_LABEL, GTP_CONDITIONAL, NULL},
3077             {GTP_EXT_FLOW_SIG, GTP_CONDITIONAL, NULL},
3078             {GTP_EXT_CHRG_ID, GTP_CONDITIONAL, NULL},
3079             {GTP_EXT_USER_ADDR, GTP_CONDITIONAL, NULL},
3080             {GTP_EXT_PROTO_CONF, GTP_OPTIONAL, NULL},
3081             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL, NULL},
3082             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL, NULL},
3083             {GTP_EXT_CHRG_ADDR, GTP_OPTIONAL, NULL},
3084             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3085             {0, 0, NULL}
3086         }
3087     },
3088     {
3089         GTP_MSG_DELETE_AA_PDP_REQ, {
3090             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3091             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3092             {0, 0, NULL}
3093         }
3094     },
3095     {
3096         GTP_MSG_DELETE_AA_PDP_RESP, {
3097             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3098             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3099             {0, 0, NULL}
3100         }
3101     },
3102     {
3103         GTP_MSG_ERR_IND, {
3104             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3105             {0, 0, NULL}
3106         }
3107     },
3108     {
3109         GTP_MSG_PDU_NOTIFY_REQ, {
3110             {GTP_EXT_USER_ADDR, GTP_MANDATORY, NULL},
3111             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3112             {0, 0, NULL}
3113         }
3114     },
3115     {
3116         GTP_MSG_PDU_NOTIFY_RESP, {
3117             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3118             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3119             {0, 0, NULL}
3120         }
3121     },
3122     {
3123         GTP_MSG_PDU_NOTIFY_REJ_REQ, {
3124             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3125             {GTP_EXT_USER_ADDR, GTP_MANDATORY, NULL},
3126             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3127             {0, 0, NULL}
3128         }
3129     },
3130     {
3131         GTP_MSG_PDU_NOTIFY_REJ_RESP, {
3132             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3133             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3134             {0, 0, NULL}
3135         }
3136     },
3137     {
3138         GTP_MSG_SEND_ROUT_INFO_REQ, {
3139             {GTP_EXT_IMSI, GTP_MANDATORY, NULL},
3140             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3141             {0, 0, NULL}
3142         }
3143     },
3144     {
3145         GTP_MSG_SEND_ROUT_INFO_RESP, {
3146             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3147             {GTP_EXT_IMSI, GTP_MANDATORY, NULL},
3148             {GTP_EXT_MAP_CAUSE, GTP_OPTIONAL, NULL},
3149             {GTP_EXT_MS_REASON, GTP_OPTIONAL, NULL},
3150             {GTP_EXT_GSN_ADDR, GTP_OPTIONAL, NULL},
3151             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3152             {0, 0, NULL}
3153         }
3154     },
3155     {
3156         GTP_MSG_FAIL_REP_REQ, {
3157             {GTP_EXT_IMSI, GTP_MANDATORY, NULL},
3158             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3159             {0, 0, NULL}
3160         }
3161     },
3162     {
3163         GTP_MSG_FAIL_REP_RESP, {
3164             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3165             {GTP_EXT_MAP_CAUSE, GTP_OPTIONAL, NULL},
3166             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3167             {0, 0, NULL}
3168         }
3169     },
3170     {
3171         GTP_MSG_MS_PRESENT_REQ, {
3172             {GTP_EXT_IMSI, GTP_MANDATORY, NULL},
3173             {GTP_EXT_GSN_ADDR, GTP_MANDATORY, NULL},
3174             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3175             {0, 0, NULL}
3176         }
3177     },
3178     {
3179         GTP_MSG_MS_PRESENT_RESP, {
3180             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3181             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3182             {0, 0, NULL}
3183         }
3184     },
3185     {
3186         GTP_MSG_IDENT_REQ, {
3187             {GTP_EXT_RAI, GTP_MANDATORY, NULL},
3188             {GTP_EXT_PTMSI, GTP_MANDATORY, NULL},
3189             {GTP_EXT_PTMSI_SIG, GTP_OPTIONAL, NULL},
3190             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3191             {0, 0, NULL}
3192         }
3193     },
3194     {
3195         GTP_MSG_IDENT_RESP, {
3196             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3197             {GTP_EXT_IMSI, GTP_CONDITIONAL, NULL},
3198             {GTP_EXT_AUTH_TRI, GTP_OPTIONAL, NULL},
3199             {GTP_EXT_AUTH_QUI, GTP_OPTIONAL, NULL},
3200             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3201             {0, 0, NULL}
3202         }
3203     },
3204     {
3205         GTP_MSG_SGSN_CNTXT_REQ, {
3206             {GTP_EXT_IMSI, GTP_CONDITIONAL, NULL},
3207             {GTP_EXT_RAI, GTP_MANDATORY, NULL},
3208             {GTP_EXT_TLLI, GTP_MANDATORY, NULL},
3209             {GTP_EXT_PTMSI_SIG, GTP_OPTIONAL, NULL},
3210             {GTP_EXT_MS_VALID, GTP_OPTIONAL, NULL},
3211             {GTP_EXT_FLOW_SIG, GTP_MANDATORY, NULL},
3212             {0, 0, NULL}
3213         }
3214     },
3215     {
3216         GTP_MSG_SGSN_CNTXT_RESP, {
3217             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3218             {GTP_EXT_IMSI, GTP_CONDITIONAL, NULL},
3219             {GTP_EXT_FLOW_SIG, GTP_CONDITIONAL, NULL},
3220             {GTP_EXT_MM_CNTXT, GTP_CONDITIONAL, NULL},
3221             {GTP_EXT_PDP_CNTXT, GTP_CONDITIONAL, NULL},
3222             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3223             {0, 0, NULL}
3224         }
3225     },
3226     {
3227         GTP_MSG_SGSN_CNTXT_ACK, {
3228             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3229             {GTP_EXT_FLOW_II, GTP_CONDITIONAL, NULL},
3230             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL, NULL},
3231             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3232             {0, 0, NULL}
3233         }
3234     },
3235     {
3236         GTP_MSG_DATA_TRANSF_REQ, {
3237             {GTP_EXT_TR_COMM, GTP_MANDATORY, NULL},
3238             {GTP_EXT_DATA_REQ, GTP_CONDITIONAL, NULL},
3239             {GTP_EXT_REL_PACK, GTP_CONDITIONAL, NULL},
3240             {GTP_EXT_CAN_PACK, GTP_CONDITIONAL, NULL},
3241             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3242             {0, 0, NULL}
3243         }
3244     },
3245     {
3246         GTP_MSG_DATA_TRANSF_RESP, {
3247             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3248             {GTP_EXT_DATA_RESP, GTP_MANDATORY, NULL},
3249             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3250             {0, 0, NULL}
3251         }
3252     },
3253     {
3254         0, {
3255             {0, 0, NULL}
3256         }
3257     }
3258 };
3259 
3260 /* -----------------------------
3261  * UMTS messages
3262  * -----------------------------*/
3263 static _gtp_mess_items umts_mess_items[] = {
3264     /* 7.2 Path Management Messages */
3265     {
3266         GTP_MSG_ECHO_REQ, {
3267             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3268             {0, 0, NULL}
3269         }
3270     },
3271     {
3272         GTP_MSG_ECHO_RESP, {
3273             {GTP_EXT_RECOVER, GTP_MANDATORY, NULL},
3274             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3275             {0, 0, NULL}
3276         }
3277     },
3278     {
3279         GTP_MSG_VER_NOT_SUPP, {
3280             {0, 0, NULL}
3281         }
3282     },
3283     {
3284         GTP_MSG_SUPP_EXT_HDR, {
3285             {GTP_EXT_HDR_LIST, GTP_MANDATORY, NULL},
3286             {0, 0, NULL}
3287         }
3288     },
3289     /* ??? */
3290     {
3291         GTP_MSG_NODE_ALIVE_REQ, {
3292             {GTP_EXT_NODE_ADDR, GTP_MANDATORY, NULL},
3293             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3294             {0, 0, NULL}
3295         }
3296     },
3297     {
3298         GTP_MSG_NODE_ALIVE_RESP, {
3299             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3300             {0, 0, NULL}
3301         }
3302     },
3303     {
3304         GTP_MSG_REDIR_REQ, {
3305             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3306             {GTP_EXT_NODE_ADDR, GTP_OPTIONAL, NULL},
3307             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3308             {0, 0, NULL}
3309         }
3310     },
3311     {
3312         GTP_MSG_REDIR_REQ, {
3313             {0, 0, NULL}
3314         }
3315     },
3316     /* 7.3 Tunnel Management Messages */
3317     {
3318         GTP_MSG_CREATE_PDP_REQ, {
3319             {GTP_EXT_IMSI, GTP_CONDITIONAL, NULL},
3320             /* RAI is in TS 29.060 V6.11.0 */
3321             {GTP_EXT_RAI, GTP_OPTIONAL, NULL},        /* Routeing Area Identity (RAI) Optional 7.7.3 */
3322             {GTP_EXT_RECOVER, GTP_OPTIONAL, NULL},
3323             {GTP_EXT_SEL_MODE, GTP_CONDITIONAL, NULL},
3324             {GTP_EXT_TEID, GTP_MANDATORY, NULL},
3325             {GTP_EXT_TEID_CP, GTP_CONDITIONAL, NULL},
3326             {GTP_EXT_NSAPI, GTP_MANDATORY, NULL},
3327             {GTP_EXT_NSAPI, GTP_CONDITIONAL, NULL},
3328             {GTP_EXT_CHRG_CHAR, GTP_OPTIONAL, NULL},
3329             {GTP_EXT_TRACE_REF, GTP_OPTIONAL, NULL},
3330             {GTP_EXT_TRACE_TYPE, GTP_OPTIONAL, NULL},
3331             {GTP_EXT_USER_ADDR, GTP_CONDITIONAL, NULL},
3332             {GTP_EXT_APN, GTP_CONDITIONAL, NULL},
3333             {GTP_EXT_PROTO_CONF, GTP_CONDITIONAL, NULL},
3334             {GTP_EXT_GSN_ADDR, GTP_MANDATORY, decode_gtp_sgsn_addr_for_control_plane},
3335             {GTP_EXT_GSN_ADDR, GTP_MANDATORY, decode_gtp_sgsn_addr_for_user_plane},
3336             {GTP_EXT_MSISDN, GTP_CONDITIONAL, NULL},
3337             {GTP_EXT_QOS_UMTS, GTP_MANDATORY, NULL},
3338             {GTP_EXT_TFT, GTP_CONDITIONAL, NULL},
3339             {GTP_EXT_TRIGGER_ID, GTP_OPTIONAL, NULL},
3340             {GTP_EXT_OMC_ID, GTP_OPTIONAL, NULL},
3341             /* TS 29.060 V6.11.0 */
3342             {GTP_EXT_APN_RES, GTP_OPTIONAL, NULL},
3343             {GTP_EXT_RAT_TYPE, GTP_OPTIONAL, NULL},
3344             {GTP_EXT_USR_LOC_INF, GTP_OPTIONAL, NULL},
3345             {GTP_EXT_MS_TIME_ZONE, GTP_OPTIONAL, NULL},
3346             {GTP_EXT_IMEISV, GTP_OPTIONAL, NULL},
3347             {GTP_EXT_CAMEL_CHG_INF_CON, GTP_OPTIONAL, NULL},
3348             {GTP_EXT_ADD_TRS_INF, GTP_OPTIONAL, NULL},
3349             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3350             {0, 0, NULL}
3351         }
3352     },
3353     {
3354         GTP_MSG_CREATE_PDP_RESP, {
3355             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3356             {GTP_EXT_REORDER, GTP_CONDITIONAL, NULL},
3357             {GTP_EXT_RECOVER, GTP_OPTIONAL, NULL},
3358             {GTP_EXT_TEID, GTP_CONDITIONAL, NULL},
3359             {GTP_EXT_TEID_CP, GTP_CONDITIONAL, NULL},
3360             {GTP_EXT_NSAPI, GTP_CONDITIONAL, NULL},
3361             {GTP_EXT_CHRG_ID, GTP_CONDITIONAL, NULL},
3362             {GTP_EXT_USER_ADDR, GTP_CONDITIONAL, NULL},
3363             {GTP_EXT_PROTO_CONF, GTP_OPTIONAL, NULL},
3364             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL, decode_gtp_ggsn_addr_for_control_plane},
3365             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL, decode_gtp_ggsn_addr_for_user_plane},
3366             {GTP_EXT_QOS_UMTS, GTP_CONDITIONAL, NULL},
3367             {GTP_EXT_CHRG_ADDR, GTP_OPTIONAL, NULL},
3368             /* TS 29.060 V6.11.0 */
3369             {GTP_EXT_CHRG_ADDR, GTP_OPTIONAL, NULL},   /* Alternative Charging Gateway Address Optional 7.7.44 */
3370             {GTP_EXT_COMMON_FLGS, GTP_OPTIONAL, NULL}, /* Common Flags Optional 7.7.48 */
3371             {GTP_EXT_APN_RES, GTP_OPTIONAL, NULL},     /* APN Restriction Optional 7.7.49 */
3372             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3373             {0, 0, NULL}
3374         }
3375     },
3376     {                           /* checked, SGSN -> GGSN */
3377         GTP_MSG_UPDATE_PDP_REQ, {
3378             {GTP_EXT_IMSI, GTP_CONDITIONAL, NULL},
3379             {GTP_EXT_RAI, GTP_OPTIONAL, NULL},         /* Routeing Area Identity (RAI) Optional 7.7.3 */
3380             {GTP_EXT_RECOVER, GTP_OPTIONAL, NULL},
3381             {GTP_EXT_TEID, GTP_MANDATORY, NULL},
3382             {GTP_EXT_TEID_CP, GTP_CONDITIONAL, NULL},
3383             {GTP_EXT_NSAPI, GTP_MANDATORY, NULL},
3384             {GTP_EXT_TRACE_REF, GTP_OPTIONAL, NULL},
3385             {GTP_EXT_TRACE_TYPE, GTP_OPTIONAL, NULL},
3386             {GTP_EXT_PROTO_CONF, GTP_OPTIONAL, NULL},  /* Protocol Configuration Options Optional 7.7.31 */
3387             {GTP_EXT_GSN_ADDR, GTP_MANDATORY, decode_gtp_sgsn_addr_for_control_plane},   /* SGSN Address for Control Plane Mandatory GSN Address 7.7.32 */
3388             {GTP_EXT_GSN_ADDR, GTP_MANDATORY, decode_gtp_sgsn_addr_for_user_plane},      /* SGSN Address for User Traffic Mandatory GSN Address 7.7.32 */
3389             {GTP_EXT_GSN_ADDR, GTP_OPTIONAL, NULL},    /* Alternative SGSN Address for Control Plane Conditional GSN Address 7.7.32 */
3390             {GTP_EXT_GSN_ADDR, GTP_OPTIONAL, NULL},    /* Alternative SGSN Address for User Traffic Conditional GSN Address 7.7.32 */
3391             {GTP_EXT_QOS_UMTS, GTP_MANDATORY, NULL},
3392             {GTP_EXT_TFT, GTP_OPTIONAL, NULL},
3393             {GTP_EXT_TRIGGER_ID, GTP_OPTIONAL, NULL},
3394             {GTP_EXT_OMC_ID, GTP_OPTIONAL, NULL},
3395             {GTP_EXT_COMMON_FLGS, GTP_OPTIONAL, NULL},        /* Common Flags Optional 7.7.48 */
3396             {GTP_EXT_RAT_TYPE, GTP_OPTIONAL, NULL},           /* RAT Type Optional 7.7.50 */
3397             {GTP_EXT_USR_LOC_INF, GTP_OPTIONAL, NULL},        /* User Location Information Optional 7.7.51 */
3398             {GTP_EXT_MS_TIME_ZONE, GTP_OPTIONAL, NULL},       /* MS Time Zone Optional 7.7.52 */
3399             {GTP_EXT_ADD_TRS_INF, GTP_OPTIONAL, NULL},        /* Additional Trace Info Optional 7.7.62 */
3400             {GTP_EXT_DIRECT_TUNNEL_FLGS, GTP_OPTIONAL, NULL}, /* Direct Tunnel Flags     7.7.81 */
3401             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3402             {0, 0, NULL}
3403         }
3404     },
3405     {                           /* checked, GGSN -> SGSN */
3406         GTP_MSG_UPDATE_PDP_RESP, {
3407             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3408             {GTP_EXT_RECOVER, GTP_OPTIONAL, NULL},
3409             {GTP_EXT_TEID, GTP_CONDITIONAL, NULL},
3410             {GTP_EXT_TEID_CP, GTP_CONDITIONAL, NULL},
3411             {GTP_EXT_CHRG_ID, GTP_CONDITIONAL, NULL},
3412             {GTP_EXT_PROTO_CONF, GTP_OPTIONAL, NULL},  /* Protocol Configuration Options Optional 7.7.31 */
3413             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL, NULL},
3414             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL, NULL},
3415             {GTP_EXT_GSN_ADDR, GTP_OPTIONAL, NULL},    /* Alternative SGSN Address for Control Plane Conditional GSN Address 7.7.32 */
3416             {GTP_EXT_GSN_ADDR, GTP_OPTIONAL, NULL},    /* Alternative SGSN Address for User Traffic Conditional GSN Address 7.7.32 */
3417             {GTP_EXT_QOS_UMTS, GTP_CONDITIONAL, NULL},
3418             {GTP_EXT_CHRG_ADDR, GTP_OPTIONAL, NULL},
3419             {GTP_EXT_CHRG_ADDR, GTP_OPTIONAL, NULL},   /* Alternative Charging Gateway Address Optional 7.7.44 */
3420             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3421             {GTP_EXT_COMMON_FLGS, GTP_OPTIONAL, NULL}, /* Common Flags Optional 7.7.48 */
3422             {GTP_EXT_APN_RES, GTP_OPTIONAL, NULL},     /* APN Restriction Optional 7.7.49 */
3423             {0, 0, NULL}
3424         }
3425     },
3426     {
3427         GTP_MSG_DELETE_PDP_REQ, {
3428             {GTP_EXT_TEAR_IND, GTP_CONDITIONAL, NULL},
3429             {GTP_EXT_NSAPI, GTP_MANDATORY, NULL},
3430             {GTP_EXT_PROTO_CONF, GTP_OPTIONAL, NULL}, /* Protocol Configuration Options Optional 7.7.31 */
3431             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3432             {0, 0, NULL}
3433         }
3434     },
3435     {
3436         GTP_MSG_DELETE_PDP_RESP, {
3437             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3438             {GTP_EXT_PROTO_CONF, GTP_OPTIONAL, NULL}, /* Protocol Configuration Options Optional 7.7.31 */
3439             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3440             {0, 0, NULL}
3441         }
3442     },
3443     {
3444         GTP_MSG_ERR_IND, {
3445             {GTP_EXT_TEID, GTP_MANDATORY, NULL},
3446             {GTP_EXT_GSN_ADDR, GTP_MANDATORY, decode_gtp_ggsn_addr_for_control_plane},  /* GSN Address Mandatory 7.7.32 */
3447             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3448             {0, 0, NULL}
3449         }
3450     },
3451     {
3452         GTP_MSG_PDU_NOTIFY_REQ, {
3453             {GTP_EXT_IMSI, GTP_MANDATORY, NULL},
3454             {GTP_EXT_TEID_CP, GTP_MANDATORY, NULL},
3455             {GTP_EXT_USER_ADDR, GTP_MANDATORY, NULL},
3456             {GTP_EXT_APN, GTP_MANDATORY, NULL},
3457             {GTP_EXT_PROTO_CONF, GTP_OPTIONAL, NULL}, /* Protocol Configuration Options Optional 7.7.31 */
3458             {GTP_EXT_GSN_ADDR, GTP_MANDATORY, decode_gtp_ggsn_addr_for_control_plane},
3459             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3460             {0, 0, NULL}
3461         }
3462     },
3463     {
3464         GTP_MSG_PDU_NOTIFY_RESP, {
3465             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3466             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3467             {0, 0, NULL}
3468         }
3469     },
3470     {
3471         GTP_MSG_PDU_NOTIFY_REJ_REQ, {
3472             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3473             {GTP_EXT_TEID_CP, GTP_MANDATORY, NULL},
3474             {GTP_EXT_USER_ADDR, GTP_MANDATORY, NULL},
3475             {GTP_EXT_APN, GTP_MANDATORY, NULL},
3476             {GTP_EXT_PROTO_CONF, GTP_OPTIONAL, NULL}, /* Protocol Configuration Options Optional 7.7.31 */
3477             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3478             {0, 0, NULL}
3479         }
3480     },
3481     {
3482         GTP_MSG_PDU_NOTIFY_REJ_RESP, {
3483             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3484             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3485             {0, 0, NULL}
3486         }
3487     },
3488     /* 7.4 Location Management Messages */
3489     {
3490         GTP_MSG_SEND_ROUT_INFO_REQ, {
3491             {GTP_EXT_IMSI, GTP_MANDATORY, NULL},
3492             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3493             {0, 0, NULL}
3494         }
3495     },
3496     {
3497         GTP_MSG_SEND_ROUT_INFO_RESP, {
3498             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3499             {GTP_EXT_IMSI, GTP_MANDATORY, NULL},
3500             {GTP_EXT_MAP_CAUSE, GTP_OPTIONAL, NULL},
3501             {GTPv1_EXT_MS_REASON, GTP_OPTIONAL, NULL},
3502             {GTP_EXT_GSN_ADDR, GTP_OPTIONAL, NULL},
3503             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3504             {0, 0, NULL}
3505         }
3506     },
3507     {
3508         GTP_MSG_FAIL_REP_REQ, {
3509             {GTP_EXT_IMSI, GTP_MANDATORY, NULL},
3510             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3511             {0, 0, NULL}
3512         }
3513     },
3514     {
3515         GTP_MSG_FAIL_REP_RESP, {
3516             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3517             {GTP_EXT_MAP_CAUSE, GTP_OPTIONAL, NULL},
3518             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3519             {0, 0, NULL}
3520         }
3521     },
3522     {
3523         GTP_MSG_MS_PRESENT_REQ, {
3524             {GTP_EXT_IMSI, GTP_MANDATORY, NULL},
3525             {GTP_EXT_GSN_ADDR, GTP_MANDATORY, NULL},
3526             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3527             {0, 0, NULL}
3528         }
3529     },
3530     {
3531         GTP_MSG_MS_PRESENT_RESP, {
3532             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3533             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3534             {0, 0, NULL}
3535         }
3536     },
3537     /* 7.5 Mobility Management Messages */
3538     {
3539         GTP_MSG_IDENT_REQ, {
3540             {GTP_EXT_RAI, GTP_MANDATORY, NULL},
3541             {GTP_EXT_PTMSI, GTP_MANDATORY, NULL},
3542             {GTP_EXT_PTMSI_SIG, GTP_CONDITIONAL, NULL},
3543             {GTP_EXT_GSN_ADDR, GTP_OPTIONAL, decode_gtp_sgsn_addr_for_control_plane},   /* SGSN Address for Control Plane Optional 7.7.32 */
3544             {GTP_EXT_HOP_COUNT, GTP_OPTIONAL, NULL},  /* Hop Counter Optional 7.7.63 */
3545             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3546             {0, 0, NULL}
3547         }
3548     },
3549     {
3550         GTP_MSG_IDENT_RESP, {
3551             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3552             {GTP_EXT_IMSI, GTP_CONDITIONAL, NULL},
3553             {GTP_EXT_AUTH_TRI, GTP_CONDITIONAL, NULL},
3554             {GTP_EXT_AUTH_QUI, GTP_CONDITIONAL, NULL},
3555             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3556             {0, 0, NULL}
3557         }
3558     },
3559     {
3560         GTP_MSG_SGSN_CNTXT_REQ, {
3561             {GTP_EXT_IMSI, GTP_CONDITIONAL, NULL},
3562             {GTP_EXT_RAI, GTP_MANDATORY, NULL},
3563             {GTP_EXT_TLLI, GTP_CONDITIONAL, NULL},
3564             {GTP_EXT_PTMSI, GTP_CONDITIONAL, NULL},
3565             {GTP_EXT_PTMSI_SIG, GTP_CONDITIONAL, NULL},
3566             {GTP_EXT_MS_VALID, GTP_OPTIONAL, NULL},
3567             {GTP_EXT_TEID_CP, GTP_MANDATORY, NULL},
3568             {GTP_EXT_GSN_ADDR, GTP_MANDATORY, decode_gtp_sgsn_addr_for_control_plane},
3569             {GTP_EXT_GSN_ADDR, GTP_OPTIONAL, decode_gtp_sgsn_addr_for_control_plane},   /* Alternative SGSN Address for Control Plane Optional 7.7.32 */
3570             {GTP_EXT_SGSN_NO, GTP_OPTIONAL, NULL},    /* SGSN Number Optional 7.7.47 */
3571             {GTP_EXT_HOP_COUNT, GTP_OPTIONAL, NULL},  /* Hop Counter Optional 7.7.63 */
3572             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3573             {0, 0, NULL}
3574         }
3575     },
3576     {
3577         GTP_MSG_SGSN_CNTXT_RESP, {
3578             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3579             {GTP_EXT_IMSI, GTP_CONDITIONAL, NULL},
3580             {GTP_EXT_TEID_CP, GTP_CONDITIONAL, NULL},
3581             {GTP_EXT_RAB_CNTXT, GTP_CONDITIONAL, NULL},  /* RAB Context Conditional 7.7.19 */
3582             {GTP_EXT_RP_SMS, GTP_OPTIONAL, NULL},
3583             {GTP_EXT_RP, GTP_OPTIONAL, NULL},
3584             {GTP_EXT_PKT_FLOW_ID, GTP_OPTIONAL, NULL},
3585             {GTP_EXT_CHRG_CHAR, GTP_OPTIONAL, NULL},     /* CharingCharacteristics Optional 7.7.23 */
3586             {GTP_EXT_RA_PRIO_LCS, GTP_OPTIONAL, NULL},   /* Radio Priority LCS Optional 7.7.25B */
3587             {GTP_EXT_MM_CNTXT, GTP_CONDITIONAL, NULL},
3588             {GTP_EXT_PDP_CNTXT, GTP_CONDITIONAL, NULL},
3589             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL, decode_gtp_sgsn_addr_for_control_plane},
3590             {GTP_EXT_PDP_CONT_PRIO, GTP_OPTIONAL, NULL}, /* PDP Context Prioritization Optional 7.7.45 */
3591             {GTP_EXT_MBMS_UE_CTX, GTP_OPTIONAL, NULL},   /* MBMS UE Context Optional 7.7.55 */
3592             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3593             {0, 0, NULL}
3594         }
3595     },
3596     {
3597         GTP_MSG_SGSN_CNTXT_ACK, {
3598             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3599             {GTP_EXT_TEID_II, GTP_CONDITIONAL, NULL},
3600             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL, decode_gtp_sgsn_addr_for_user_plane},
3601             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3602             {0, 0, NULL}
3603         }
3604     },
3605     {
3606         GTP_MSG_FORW_RELOC_REQ, {
3607             {GTP_EXT_IMSI, GTP_MANDATORY, NULL},
3608             {GTP_EXT_TEID_CP, GTP_MANDATORY, NULL},
3609             {GTP_EXT_RANAP_CAUSE, GTP_MANDATORY, NULL},
3610             {GTP_EXT_CHRG_CHAR, GTP_OPTIONAL, NULL},     /* CharingCharacteristics Optional 7.7.23 */
3611             {GTP_EXT_MM_CNTXT, GTP_MANDATORY, NULL},
3612             {GTP_EXT_PDP_CNTXT, GTP_CONDITIONAL, NULL},
3613             {GTP_EXT_GSN_ADDR, GTP_MANDATORY, decode_gtp_sgsn_addr_for_control_plane},
3614             {GTP_EXT_TARGET_ID, GTP_MANDATORY, NULL},
3615             {GTP_EXT_UTRAN_CONT, GTP_MANDATORY, NULL},
3616             {GTP_EXT_PDP_CONT_PRIO, GTP_OPTIONAL, NULL}, /* PDP Context Prioritization Optional 7.7.45 */
3617             {GTP_EXT_MBMS_UE_CTX, GTP_OPTIONAL, NULL},   /* MBMS UE Context Optional 7.7.55 */
3618             {GTP_EXT_SEL_PLMN_ID, GTP_OPTIONAL, NULL},   /* Selected PLMN ID Optional 7.7.64 */
3619             {GTP_EXT_PS_HO_REQ_CTX, GTP_OPTIONAL, NULL}, /* PS Handover Request Context Optional 7.7.71 */
3620             {GTP_EXT_BSS_CONT, GTP_OPTIONAL, NULL},      /* BSS Container Optional 7.7.72 */
3621             {GTP_EXT_CELL_ID, GTP_OPTIONAL, NULL},       /* Cell Identification Optional 7.7.73 */
3622             {GTP_EXT_BSSGP_CAUSE, GTP_OPTIONAL, NULL},   /* BSSGP Cause Optional 7.7.75 */
3623             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3624             {GTP_EXT_SGSN_NO, GTP_OPTIONAL, NULL},
3625             {0, 0, NULL}
3626         }
3627     },
3628     {
3629         GTP_MSG_FORW_RELOC_RESP, {
3630             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3631             {GTP_EXT_TEID_CP, GTP_CONDITIONAL, NULL},
3632             {GTP_EXT_TEID_II, GTP_CONDITIONAL, NULL},           /* Tunnel Endpoint Identifier Data II Optional 7.7.15 */
3633             {GTP_EXT_RANAP_CAUSE, GTP_CONDITIONAL, NULL},
3634             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL, NULL},
3635             {GTP_EXT_UTRAN_CONT, GTP_OPTIONAL, NULL},
3636             {GTP_EXT_RAB_SETUP, GTP_CONDITIONAL, NULL},
3637             {GTP_EXT_ADD_RAB_SETUP_INF, GTP_CONDITIONAL, NULL}, /* Additional RAB Setup Information Conditional 7.7.45A */
3638             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3639             {0, 0, NULL}
3640         }
3641     },
3642     {
3643         GTP_MSG_FORW_RELOC_COMP, {
3644             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3645             {0, 0, NULL}
3646         }
3647     },
3648     {
3649         GTP_MSG_RELOC_CANCEL_REQ, {
3650             {GTP_EXT_IMSI, GTP_MANDATORY, NULL},
3651             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3652             {0, 0, NULL}
3653         }
3654     },
3655     {
3656         GTP_MSG_RELOC_CANCEL_RESP, {
3657             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3658             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3659             {0, 0, NULL}
3660         }
3661     },
3662     {
3663         GTP_MSG_FORW_RELOC_ACK, {
3664             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3665             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3666             {0, 0, NULL}
3667         }
3668     },
3669     {
3670         GTP_MSG_FORW_SRNS_CNTXT_ACK, {
3671             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},
3672             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3673             {0, 0, NULL}
3674         }
3675     },
3676     {
3677         GTP_MSG_FORW_SRNS_CNTXT, {
3678             {GTP_EXT_RAB_CNTXT, GTP_MANDATORY, NULL},
3679             {GTP_EXT_SRC_RNC_PDP_CTX_INF, GTP_OPTIONAL, NULL}, /* Source RNC PDCP context info Optional 7.7.61 */
3680             {GTP_EXT_PDU_NO, GTP_OPTIONAL, NULL},              /* PDU Numbers Optional 7.7.74 */
3681             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3682             {0, 0, NULL}
3683         }
3684     },
3685 
3686 /*      7.5.14 RAN Information Management Messages */
3687     {
3688         GTP_MSG_RAN_INFO_RELAY, {
3689             {GTP_EXT_RAN_TR_CONT, GTP_MANDATORY, NULL},        /* RAN Transparent Container Mandatory 7.7.43 */
3690             {GTP_EXT_RIM_RA, GTP_OPTIONAL, NULL},              /* RIM Routing Address Optional 7.7.57 */
3691             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3692             {0, 0, NULL}
3693         }
3694     },
3695 /* 7.5A MBMS Messages
3696  * 7.5A.1 UE Specific MBMS Messages
3697  */
3698     {
3699         GTP_MBMS_NOTIFY_REQ, {
3700             {GTP_EXT_IMSI, GTP_MANDATORY, NULL},              /* IMSI Mandatory 7.7.2 */
3701             {GTP_EXT_TEID_CP, GTP_MANDATORY, NULL},           /* Tunnel Endpoint Identifier Control Plane Mandatory 7.7.14 */
3702             {GTP_EXT_NSAPI, GTP_MANDATORY, NULL},             /* NSAPI Mandatory 7.7.17 */
3703             {GTP_EXT_USER_ADDR, GTP_MANDATORY, NULL},         /* End User Address Mandatory 7.7.27 */
3704             {GTP_EXT_APN, GTP_MANDATORY, NULL},               /* Access Point Name Mandatory 7.7.30 */
3705             {GTP_EXT_GSN_ADDR, GTP_MANDATORY, decode_gtp_ggsn_addr_for_control_plane},          /* GGSN Address for Control Plane Mandatory 7.7.32 */
3706             {GTP_EXT_MBMS_PROT_CONF_OPT, GTP_OPTIONAL, NULL}, /* MBMS Protocol Configuration Options Optional 7.7.58 */
3707             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},           /* Private Extension Optional 7.7.46 */
3708             {0, 0, NULL}
3709         }
3710     },
3711     {
3712         GTP_MBMS_NOTIFY_RES, {
3713             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},     /* Cause Mandatory 7.7.1 */
3714             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3715             {0, 0, NULL}
3716         }
3717     },
3718     {
3719         GTP_MBMS_NOTIFY_REJ_REQ, {
3720             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},     /* Cause Mandatory 7.7.1 */
3721             {GTP_EXT_TEID_CP, GTP_MANDATORY, NULL},   /* Tunnel Endpoint Identifier Control Plane Mandatory 7.7.14 */
3722             {GTP_EXT_NSAPI, GTP_MANDATORY, NULL},     /* NSAPI Mandatory 7.7.17 */
3723             {GTP_EXT_USER_ADDR, GTP_MANDATORY, NULL}, /* End User Address Mandatory 7.7.27 */
3724             {GTP_EXT_APN, GTP_MANDATORY, NULL},       /* Access Point Name Mandatory 7.7.30 */
3725             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3726             {0, 0, NULL}
3727         }
3728     },
3729     {
3730         GTP_MBMS_NOTIFY_REJ_RES, {
3731             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},     /* Cause Mandatory 7.7.1 */
3732             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3733             {0, 0, NULL}
3734         }
3735     },
3736     {
3737         GTP_CREATE_MBMS_CNTXT_REQ, {
3738             {GTP_EXT_IMSI, GTP_CONDITIONAL, NULL},            /* IMSI Conditional 7.7.2 */
3739             {GTP_EXT_RAI, GTP_MANDATORY, NULL},               /* Routeing Area Identity (RAI) Mandatory 7.7.3 */
3740             {GTP_EXT_RECOVER, GTP_OPTIONAL, NULL},            /* Recovery Optional 7.7.11 */
3741             {GTP_EXT_SEL_MODE, GTP_CONDITIONAL, NULL},        /* Selection mode Conditional 7.7.12 */
3742             {GTP_EXT_TEID_CP, GTP_CONDITIONAL, NULL},         /* Tunnel Endpoint Identifier Control Plane Conditional 7.7.14 */
3743             {GTP_EXT_TRACE_REF, GTP_OPTIONAL, NULL},          /* Trace Reference Optional 7.7.24 */
3744             {GTP_EXT_TRACE_TYPE, GTP_OPTIONAL, NULL},         /* Trace Type Optional 7.7.25 */
3745             {GTP_EXT_USER_ADDR, GTP_MANDATORY, NULL},         /* End User Address Mandatory 7.7.27 */
3746             {GTP_EXT_APN, GTP_MANDATORY, NULL},               /* Access Point Name Mandatory 7.7.30 */
3747             {GTP_EXT_GSN_ADDR, GTP_MANDATORY, decode_gtp_sgsn_addr_for_control_plane},          /* SGSN Address for signalling Mandatory GSN Address 7.7.32 */
3748             {GTP_EXT_MSISDN, GTP_CONDITIONAL, NULL},          /* MSISDN Conditional 7.7.33 */
3749             {GTP_EXT_TRIGGER_ID, GTP_OPTIONAL, NULL},         /* Trigger Id Optional 7.7.41 */
3750             {GTP_EXT_OMC_ID, GTP_OPTIONAL, NULL},             /* OMC Identity Optional 7.7.42 */
3751             {GTP_EXT_RAT_TYPE, GTP_OPTIONAL, NULL},           /* RAT Type Optional 7.7.50 */
3752             {GTP_EXT_USR_LOC_INF, GTP_OPTIONAL, NULL},        /* User Location Information Optional 7.7.51 */
3753             {GTP_EXT_MS_TIME_ZONE, GTP_OPTIONAL, NULL},       /* MS Time Zone Optional 7.7.52 */
3754             {GTP_EXT_IMEISV, GTP_OPTIONAL, NULL},             /* IMEI(SV) Optional 7.7.53 */
3755             {GTP_EXT_MBMS_PROT_CONF_OPT, GTP_OPTIONAL, NULL}, /* MBMS Protocol Configuration Options Optional 7.7.58 */
3756             {GTP_EXT_ADD_TRS_INF, GTP_OPTIONAL, NULL},        /* Additional Trace Info Optional 7.7.62 */
3757             {GTP_EXT_ENH_NSAPI, GTP_MANDATORY, NULL},         /* Enhanced NSAPI Mandatory 7.7.67 */
3758             {GTP_EXT_ADD_MBMS_TRS_INF, GTP_OPTIONAL, NULL},   /* Additional MBMS Trace Info Optional 7.7.68 */
3759             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3760             {0, 0, NULL}
3761         }
3762     },
3763     {
3764         GTP_CREATE_MBMS_CNTXT_RES, {
3765             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},             /* Cause Mandatory 7.7.1 */
3766             {GTP_EXT_RECOVER, GTP_OPTIONAL, NULL},            /* Recovery Optional 7.7.11 */
3767             {GTP_EXT_TEID_CP, GTP_CONDITIONAL, NULL},         /* Tunnel Endpoint Identifier Control Plane Conditional 7.7.14 */
3768             {GTP_EXT_CHRG_ID, GTP_CONDITIONAL, NULL},         /* Charging ID Conditional 7.7.26 */
3769             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL, NULL},        /* GGSN Address for Control Plane Conditional GSN Address 7.7.32 */
3770             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL, NULL},        /* Alternative GGSN Address for Control Plane Conditional GSN Address 7.7.32 */
3771             {GTP_EXT_CHRG_ADDR, GTP_OPTIONAL, NULL},          /* Charging Gateway Address Optional 7.7.44 */
3772             {GTP_EXT_CHRG_ADDR, GTP_OPTIONAL, NULL},          /* Alternative Charging Gateway Address Optional 7.7.44 */
3773             {GTP_EXT_MBMS_PROT_CONF_OPT, GTP_OPTIONAL, NULL}, /* MBMS Protocol Configuration Options Optional 7.7.58 */
3774             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3775             {0, 0, NULL}
3776         }
3777     },
3778     {
3779         GTP_UPD_MBMS_CNTXT_REQ, {
3780             {GTP_EXT_IMSI, GTP_CONDITIONAL, NULL},          /* IMSI Conditional 7.7.2 */
3781             {GTP_EXT_RAI, GTP_MANDATORY, NULL},             /* Routeing Area Identity (RAI) Mandatory 7.7.3 */
3782             {GTP_EXT_RECOVER, GTP_OPTIONAL, NULL},          /* Recovery Optional 7.7.11 */
3783             {GTP_EXT_TEID_CP, GTP_CONDITIONAL, NULL},       /* Tunnel Endpoint Identifier Control Plane Conditional 7.7.14 */
3784             {GTP_EXT_TRACE_REF, GTP_OPTIONAL, NULL},        /* Trace Reference Optional 7.7.24 */
3785             {GTP_EXT_TRACE_TYPE, GTP_OPTIONAL, NULL},       /* Trace Type Optional 7.7.25 */
3786             {GTP_EXT_GSN_ADDR, GTP_MANDATORY, decode_gtp_sgsn_addr_for_control_plane},        /* SGSN Address for Control Plane Mandatory GSN Address 7.7.32 */
3787             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL, NULL},      /* Alternative SGSN Address for Control Plane Conditional GSN Address 7.7.32 */
3788             {GTP_EXT_TRIGGER_ID, GTP_OPTIONAL, NULL},       /* Trigger Id Optional 7.7.41 */
3789             {GTP_EXT_OMC_ID, GTP_OPTIONAL, NULL},           /* OMC Identity Optional 7.7.42 */
3790             {GTP_EXT_RAT_TYPE, GTP_OPTIONAL, NULL},         /* RAT Type Optional 7.7.50 */
3791             {GTP_EXT_USR_LOC_INF, GTP_OPTIONAL, NULL},      /* User Location Information Optional 7.7.51 */
3792             {GTP_EXT_MS_TIME_ZONE, GTP_OPTIONAL, NULL},     /* MS Time Zone Optional 7.7.52 */
3793             {GTP_EXT_ADD_TRS_INF, GTP_OPTIONAL, NULL},      /* Additional Trace Info Optional 7.7.62 */
3794             {GTP_EXT_ENH_NSAPI, GTP_MANDATORY, NULL},       /* Enhanced NSAPI Mandatory 7.7.67 */
3795             {GTP_EXT_ADD_MBMS_TRS_INF, GTP_OPTIONAL, NULL}, /* Additional MBMS Trace Info Optional 7.7.68 */
3796             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3797             {0, 0, NULL}
3798         }
3799     },
3800     {
3801         GTP_UPD_MBMS_CNTXT_RES, {
3802             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},      /* Cause Mandatory 7.7.1 */
3803             {GTP_EXT_RECOVER, GTP_OPTIONAL, NULL},     /* Recovery Optional 7.7.11 */
3804             {GTP_EXT_TEID_CP, GTP_MANDATORY, NULL},    /* Tunnel Endpoint Identifier Control Plane Conditional 7.7.14 */
3805             {GTP_EXT_CHRG_ID, GTP_CONDITIONAL, NULL},  /* Charging ID Conditional 7.7.26 */
3806             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL, NULL}, /* GGSN Address for Control Plane Conditional GSN Address 7.7.32 */
3807             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL, NULL}, /* Alternative GGSN Address for Control Plane Conditional GSN Address 7.7.32 */
3808             {GTP_EXT_CHRG_ADDR, GTP_OPTIONAL, NULL},   /* Charging Gateway Address Optional 7.7.44 */
3809             {GTP_EXT_CHRG_ADDR, GTP_OPTIONAL, NULL},   /* Alternative Charging Gateway Address Optional 7.7.44 */
3810             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},    /* Private Extension Optional 7.7.46 */
3811             {0, 0, NULL}
3812         }
3813     },
3814     {
3815         GTP_DEL_MBMS_CNTXT_REQ, {
3816             {GTP_EXT_IMSI, GTP_CONDITIONAL, NULL},            /* IMSI Conditional 7.7.2 */
3817             {GTP_EXT_TEID_CP, GTP_MANDATORY, NULL},           /* Tunnel Endpoint Identifier Control Plane Conditional 7.7.14 */
3818             {GTP_EXT_USER_ADDR, GTP_CONDITIONAL, NULL},       /* End User Address Conditional 7.7.27 */
3819             {GTP_EXT_APN, GTP_CONDITIONAL, NULL},             /* Access Point Name Conditional 7.7.30 */
3820             {GTP_EXT_MBMS_PROT_CONF_OPT, GTP_OPTIONAL, NULL}, /* MBMS Protocol Configuration Options Optional 7.7.58 */
3821             {GTP_EXT_ENH_NSAPI, GTP_MANDATORY, NULL},         /* Enhanced NSAPI Conditional 7.7.67 */
3822             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},           /* Private Extension Optional 7.7.46 */
3823             {0, 0, NULL}
3824         }
3825     },
3826     {
3827         GTP_DEL_MBMS_CNTXT_RES, {
3828             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},             /* Cause Mandatory 7.7.1 */
3829             {GTP_EXT_MBMS_PROT_CONF_OPT, GTP_OPTIONAL, NULL}, /* MBMS Protocol Configuration Options Optional 7.7.58 */
3830             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},
3831             {0, 0, NULL}
3832         }
3833     },
3834     {
3835         GTP_MBMS_REG_REQ, {
3836             {GTP_EXT_USER_ADDR, GTP_MANDATORY, NULL}, /* End User Address Mandatory 7.7.27 */
3837             {GTP_EXT_APN, GTP_MANDATORY, NULL},       /* Access Point Name Mandatory 7.7.30 */
3838             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},   /* Private Extension Optional 7.7.46 */
3839             {0, 0, NULL}
3840         }
3841     },
3842     {
3843         GTP_MBMS_REG_RES, {
3844             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},     /* Cause Mandatory 7.7.1 */
3845             {GTP_EXT_TMGI, GTP_MANDATORY, NULL},      /* Temporary Mobile Group Identity (TMGI) Conditional 7.7.56 */
3846             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},   /* Private Extension Optional 7.7.46 */
3847             {0, 0, NULL}
3848         }
3849     },
3850     {
3851         GTP_MBMS_DE_REG_REQ, {
3852             {GTP_EXT_USER_ADDR, GTP_MANDATORY, NULL}, /* End User Address Mandatory 7.7.27 */
3853             {GTP_EXT_APN, GTP_MANDATORY, NULL},       /* Access Point Name Mandatory 7.7.30 */
3854             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},   /* Private Extension Optional 7.7.46 */
3855             {0, 0, NULL}
3856         }
3857     },
3858     {
3859         GTP_MBMS_DE_REG_RES, {
3860             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},     /* Cause Mandatory 7.7.1 */
3861             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},   /* Private Extension Optional 7.7.46 */
3862             {0, 0, NULL}
3863         }
3864     },
3865     {
3866         GTP_MBMS_SES_START_REQ, {
3867             {GTP_EXT_RECOVER, GTP_OPTIONAL, NULL},               /* Recovery Optional 7.7.11 */
3868             {GTP_EXT_TEID_CP, GTP_CONDITIONAL, NULL},            /* Tunnel Endpoint Identifier Control Plane Conditional 7.7.14 */
3869             {GTP_EXT_USER_ADDR, GTP_MANDATORY, NULL},            /* End User Address Mandatory 7.7.27 */
3870             {GTP_EXT_APN, GTP_MANDATORY, NULL},                  /* Access Point Name Mandatory 7.7.30 */
3871             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL, NULL},           /* GGSN Address for Control Plane Conditional GSN Address 7.7.32 */
3872             {GTP_EXT_QOS_UMTS, GTP_MANDATORY, NULL},             /* Quality of Service Profile Mandatory 7.7.34 */
3873             {GTP_EXT_COMMON_FLGS, GTP_OPTIONAL, NULL},           /* Common Flags Mandatory 7.7.48 */
3874             {GTP_EXT_TMGI, GTP_MANDATORY, NULL},                 /* Temporary Mobile Group Identity (TMGI) Mandatory 7.7.56 */
3875             {GTP_EXT_MBMS_SES_DUR, GTP_MANDATORY, NULL},         /* MBMS Session Duration Mandatory 7.7.59 */
3876             {GTP_EXT_MBMS_SA, GTP_MANDATORY, NULL},              /* MBMS Service Area Mandatory 7.7.60 */
3877             {GTP_EXT_MBMS_SES_ID, GTP_OPTIONAL, NULL},           /* MBMS Session Identifier Optional 7.7.65 */
3878             {GTP_EXT_MBMS_2G_3G_IND, GTP_MANDATORY, NULL},       /* MBMS 2G/3G Indicator Mandatory 7.7.66 */
3879             {GTP_EXT_MBMS_SES_ID_REP_NO, GTP_OPTIONAL, NULL},    /* MBMS Session Identity Repetition Number Optional 7.7.69 */
3880             {GTP_EXT_MBMS_TIME_TO_DATA_TR, GTP_MANDATORY, NULL}, /* MBMS Time To Data Transfer Mandatory 7.7.70 */
3881             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},              /* Private Extension Optional 7.7.46 */
3882             {0, 0, NULL}
3883         }
3884     },
3885     {
3886         GTP_MBMS_SES_START_RES, {
3887             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},      /* Cause Mandatory 7.7.1 */
3888             {GTP_EXT_RECOVER, GTP_OPTIONAL, NULL},     /* Recovery Optional 7.7.11 */
3889             {GTP_EXT_TEID, GTP_CONDITIONAL, NULL},     /* Tunnel Endpoint Identifier Data I Conditional 7.7.13 */
3890             {GTP_EXT_TEID_CP, GTP_CONDITIONAL, NULL},  /* Tunnel Endpoint Identifier Control Plane Conditional 7.7.14 */
3891             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL, NULL}, /* SGSN Address for Control Plane Conditional GSN Address 7.7.32 */
3892             {GTP_EXT_GSN_ADDR, GTP_CONDITIONAL, NULL}, /* SGSN Address for user traffic Conditional GSN Address 7.7.32 */
3893             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},    /* Private Extension Optional 7.7.46 */
3894             {0, 0, NULL}
3895         }
3896     },
3897     {
3898         GTP_MBMS_SES_STOP_REQ, {
3899             {GTP_EXT_USER_ADDR, GTP_MANDATORY, NULL}, /* End User Address Mandatory 7.7.27 */
3900             {GTP_EXT_APN, GTP_MANDATORY, NULL},       /* Access Point Name Mandatory 7.7.30 */
3901             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},   /* Private Extension Optional 7.7.46 */
3902             {0, 0, NULL}
3903         }
3904     },
3905     {
3906         GTP_MBMS_SES_STOP_RES, {
3907             {GTP_EXT_CAUSE, GTP_MANDATORY, NULL},     /* Cause Mandatory 7.7.1 */
3908             {GTP_EXT_PRIV_EXT, GTP_OPTIONAL, NULL},   /* Private Extension Optional 7.7.46 */
3909             {0, 0, NULL}
3910         }
3911     },
3912     {
3913         0, {
3914             {0, 0, NULL}
3915         }
3916     }
3917 };
3918 
3919 /* Data structure attached to a  conversation,
3920         to keep track of request/response-pairs
3921  */
3922 typedef struct gtp_conv_info_t {
3923     struct gtp_conv_info_t *next;
3924     GHashTable             *unmatched;
3925     GHashTable             *matched;
3926 } gtp_conv_info_t;
3927 
3928 static gtp_conv_info_t *gtp_info_items = NULL;
3929 
3930 static guint
gtp_sn_hash(gconstpointer k)3931 gtp_sn_hash(gconstpointer k)
3932 {
3933     const gtp_msg_hash_t *key = (const gtp_msg_hash_t *)k;
3934 
3935     return key->seq_nr;
3936 }
3937 
3938 static gint
gtp_sn_equal_matched(gconstpointer k1,gconstpointer k2)3939 gtp_sn_equal_matched(gconstpointer k1, gconstpointer k2)
3940 {
3941     const gtp_msg_hash_t *key1 = (const gtp_msg_hash_t *)k1;
3942     const gtp_msg_hash_t *key2 = (const gtp_msg_hash_t *)k2;
3943     double diff;
3944     nstime_t delta;
3945 
3946     if ( key1->req_frame && key2->req_frame && (key1->req_frame != key2->req_frame) ) {
3947         return 0;
3948     }
3949 
3950     if ( key1->rep_frame && key2->rep_frame && (key1->rep_frame != key2->rep_frame) ) {
3951         return 0;
3952     }
3953 
3954     if (pref_pair_matching_max_interval_ms) {
3955         nstime_delta(&delta, &key1->req_time, &key2->req_time);
3956         diff = fabs(nstime_to_msec(&delta));
3957 
3958         return key1->seq_nr == key2->seq_nr && diff < pref_pair_matching_max_interval_ms;
3959     }
3960 
3961     return key1->seq_nr == key2->seq_nr;
3962 }
3963 
3964 static gint
gtp_sn_equal_unmatched(gconstpointer k1,gconstpointer k2)3965 gtp_sn_equal_unmatched(gconstpointer k1, gconstpointer k2)
3966 {
3967     const gtp_msg_hash_t *key1 = (const gtp_msg_hash_t *)k1;
3968     const gtp_msg_hash_t *key2 = (const gtp_msg_hash_t *)k2;
3969     double diff;
3970     nstime_t delta;
3971 
3972     if (pref_pair_matching_max_interval_ms) {
3973         nstime_delta(&delta, &key1->req_time, &key2->req_time);
3974         diff = fabs(nstime_to_msec(&delta));
3975 
3976         return key1->seq_nr == key2->seq_nr && diff < pref_pair_matching_max_interval_ms;
3977     }
3978 
3979     return key1->seq_nr == key2->seq_nr;
3980 }
3981 
3982 static gtp_msg_hash_t *
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)3983 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)
3984 {
3985     gtp_msg_hash_t   gcr, *gcrp = NULL;
3986     guint32 *session;
3987 
3988     gcr.seq_nr=seq_nr;
3989     gcr.req_time = pinfo->abs_ts;
3990 
3991     switch (msgtype) {
3992     case GTP_MSG_ECHO_REQ:
3993     case GTP_MSG_CREATE_PDP_REQ:
3994     case GTP_MSG_UPDATE_PDP_REQ:
3995     case GTP_MSG_DELETE_PDP_REQ:
3996     case GTP_MSG_FORW_RELOC_REQ:
3997     case GTP_MSG_DATA_TRANSF_REQ:
3998     case GTP_MSG_SGSN_CNTXT_REQ:
3999     case GTP_MS_INFO_CNG_NOT_REQ:
4000     case GTP_MSG_IDENT_REQ:
4001         gcr.is_request=TRUE;
4002         gcr.req_frame=pinfo->num;
4003         gcr.rep_frame=0;
4004         break;
4005     case GTP_MSG_ECHO_RESP:
4006     case GTP_MSG_CREATE_PDP_RESP:
4007     case GTP_MSG_UPDATE_PDP_RESP:
4008     case GTP_MSG_DELETE_PDP_RESP:
4009     case GTP_MSG_FORW_RELOC_RESP:
4010     case GTP_MSG_DATA_TRANSF_RESP:
4011     case GTP_MSG_SGSN_CNTXT_RESP:
4012     case GTP_MS_INFO_CNG_NOT_RES:
4013     case GTP_MSG_IDENT_RESP:
4014         gcr.is_request=FALSE;
4015         gcr.req_frame=0;
4016         gcr.rep_frame=pinfo->num;
4017         break;
4018     default:
4019         gcr.is_request=FALSE;
4020         gcr.req_frame=0;
4021         gcr.rep_frame=0;
4022         break;
4023     }
4024 
4025     gcrp = (gtp_msg_hash_t *)g_hash_table_lookup(gtp_info->matched, &gcr);
4026 
4027     if (gcrp) {
4028 
4029         gcrp->is_request=gcr.is_request;
4030 
4031     } else {
4032 
4033         /*no match, let's try to make one*/
4034         switch (msgtype) {
4035         case GTP_MSG_ECHO_REQ:
4036         case GTP_MSG_CREATE_PDP_REQ:
4037         case GTP_MSG_UPDATE_PDP_REQ:
4038         case GTP_MSG_DELETE_PDP_REQ:
4039         case GTP_MSG_FORW_RELOC_REQ:
4040         case GTP_MSG_DATA_TRANSF_REQ:
4041         case GTP_MSG_SGSN_CNTXT_REQ:
4042         case GTP_MS_INFO_CNG_NOT_REQ:
4043         case GTP_MSG_IDENT_REQ:
4044             gcr.seq_nr=seq_nr;
4045 
4046             gcrp=(gtp_msg_hash_t *)g_hash_table_lookup(gtp_info->unmatched, &gcr);
4047             if (gcrp) {
4048                 g_hash_table_remove(gtp_info->unmatched, gcrp);
4049             }
4050             /* if we can't reuse the old one, grab a new chunk */
4051             if (!gcrp) {
4052                 gcrp = wmem_new(wmem_file_scope(), gtp_msg_hash_t);
4053             }
4054             gcrp->seq_nr=seq_nr;
4055             gcrp->req_frame = pinfo->num;
4056             gcrp->req_time = pinfo->abs_ts;
4057             gcrp->rep_frame = 0;
4058             gcrp->msgtype = msgtype;
4059             gcrp->is_request = TRUE;
4060             g_hash_table_insert(gtp_info->unmatched, gcrp, gcrp);
4061             return NULL;
4062             break;
4063         case GTP_MSG_ECHO_RESP:
4064         case GTP_MSG_CREATE_PDP_RESP:
4065         case GTP_MSG_UPDATE_PDP_RESP:
4066         case GTP_MSG_DELETE_PDP_RESP:
4067         case GTP_MSG_FORW_RELOC_RESP:
4068         case GTP_MSG_DATA_TRANSF_RESP:
4069         case GTP_MSG_SGSN_CNTXT_RESP:
4070         case GTP_MS_INFO_CNG_NOT_RES:
4071         case GTP_MSG_IDENT_RESP:
4072             gcr.seq_nr=seq_nr;
4073             gcrp=(gtp_msg_hash_t *)g_hash_table_lookup(gtp_info->unmatched, &gcr);
4074 
4075             if (gcrp) {
4076                 if (!gcrp->rep_frame) {
4077                     g_hash_table_remove(gtp_info->unmatched, gcrp);
4078                     gcrp->rep_frame=pinfo->num;
4079                     gcrp->is_request=FALSE;
4080                     g_hash_table_insert(gtp_info->matched, gcrp, gcrp);
4081                 }
4082             }
4083             break;
4084         default:
4085             break;
4086         }
4087     }
4088 
4089     /* we have found a match */
4090     if (gcrp) {
4091         proto_item *it;
4092 
4093 
4094         if (gcrp->is_request) {
4095             it = proto_tree_add_uint(tree, hf_gtp_response_in, tvb, 0, 0, gcrp->rep_frame);
4096             proto_item_set_generated(it);
4097         } else {
4098             nstime_t ns;
4099 
4100             it = proto_tree_add_uint(tree, hf_gtp_response_to, tvb, 0, 0, gcrp->req_frame);
4101             proto_item_set_generated(it);
4102             nstime_delta(&ns, &pinfo->abs_ts, &gcrp->req_time);
4103             it = proto_tree_add_time(tree, hf_gtp_time, tvb, 0, 0, &ns);
4104             proto_item_set_generated(it);
4105             if (g_gtp_session) {
4106                 if (!PINFO_FD_VISITED(pinfo) && gtp_version == 1) {
4107                     /* GTP session */
4108                     /* If it does not have any session assigned yet */
4109                     session = (guint32 *)g_hash_table_lookup(session_table, &pinfo->num);
4110                     if (!session) {
4111                         session = (guint32 *)g_hash_table_lookup(session_table, &gcrp->req_frame);
4112                         if (session != NULL) {
4113                             add_gtp_session(pinfo->num, *session);
4114                         }
4115                     }
4116 
4117                     if (!is_cause_accepted(last_cause, gtp_version)){
4118                         /* If the cause is not accepted then we have to remove all the session information about its corresponding request */
4119                         remove_frame_info(&gcrp->req_frame);
4120                     }
4121                 }
4122             }
4123         }
4124     }
4125     return gcrp;
4126 }
4127 
4128 
4129 static int
check_field_presence_and_decoder(guint8 message,guint8 field,int * position,ie_decoder ** alt_decoder)4130 check_field_presence_and_decoder(guint8 message, guint8 field, int *position, ie_decoder **alt_decoder)
4131 {
4132 
4133     guint i = 0;
4134     _gtp_mess_items *mess_items;
4135 
4136     switch (gtp_version) {
4137     case 0:
4138         mess_items = gprs_mess_items;
4139         break;
4140     case 1:
4141         mess_items = umts_mess_items;
4142         break;
4143     default:
4144         return -2;
4145     }
4146 
4147     while (mess_items[i].code) {
4148         if (mess_items[i].code == message) {
4149 
4150             while (mess_items[i].fields[*position].code) {
4151                 if (mess_items[i].fields[*position].code == field) {
4152                     *alt_decoder = mess_items[i].fields[*position].alt_decoder;
4153                     (*position)++;
4154                     return 0;
4155                 } else {
4156                     if (mess_items[i].fields[*position].presence == GTP_MANDATORY) {
4157                         return mess_items[i].fields[(*position)++].code;
4158                     } else {
4159                         (*position)++;
4160                     }
4161                 }
4162             }
4163             return -1;
4164         }
4165         i++;
4166     }
4167 
4168     return -2;
4169 }
4170 
4171 /* Decoders of fields in extension headers, each function returns no of bytes from field */
4172 
4173 /* GPRS:        9.60 v7.6.0, chapter
4174  * UMTS:        29.060 v4.0, chapter
4175  * 7.7.1 Cause
4176  */
4177 static int
decode_gtp_cause(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args)4178 decode_gtp_cause(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args)
4179 {
4180 
4181     guint8 cause;
4182 
4183     cause = tvb_get_guint8(tvb, offset + 1);
4184     if (g_gtp_session) {
4185         args->last_cause = cause;
4186     }
4187     proto_tree_add_uint(tree, hf_gtp_cause, tvb, offset, 2, cause);
4188 
4189     return 2;
4190 }
4191 
4192 /* GPRS:        9.60 v7.6.0, chapter 7.9.2
4193  * UMTS:        29.060 v4.0, chapter 7.7.2
4194  */
4195 static int
decode_gtp_imsi(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args _U_)4196 decode_gtp_imsi(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
4197 {
4198     /* const gchar *imsi_str; */
4199 
4200     /* Octets 2 - 9 IMSI */
4201     /* imsi_str = */ dissect_e212_imsi(tvb, pinfo, tree,  offset+1, 8, FALSE);
4202 
4203     return 9;
4204 }
4205 
4206 /* GPRS:        9.60 v7.6.0, chapter 7.9.3
4207  * UMTS:        29.060 v4.0, chapter 7.7.3 Routeing Area Identity (RAI)
4208  */
4209 static int
decode_gtp_rai(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)4210 decode_gtp_rai(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4211 {
4212 
4213     proto_tree *ext_tree_rai;
4214 
4215     ext_tree_rai = proto_tree_add_subtree(tree, tvb, offset, 1, ett_gtp_ies[GTP_EXT_RAI], NULL,
4216                             val_to_str_ext_const(GTP_EXT_RAI, &gtp_val_ext, "Unknown message"));
4217 
4218     dissect_e212_mcc_mnc(tvb, pinfo, ext_tree_rai, offset+1, E212_RAI, TRUE);
4219     proto_tree_add_item(ext_tree_rai, hf_gtp_lac, tvb, offset + 4, 2, ENC_BIG_ENDIAN);
4220     proto_tree_add_item(ext_tree_rai, hf_gtp_rai_rac, tvb, offset + 6, 1, ENC_BIG_ENDIAN);
4221 
4222     return 7;
4223 }
4224 
4225 /* GPRS:        9.60 v7.6.0, chapter 7.9.4, page 39
4226  * UMTS:        29.060 v4.0, chapter 7.7.4 Temporary Logical Link Identity (TLLI)
4227  */
4228 static int
decode_gtp_tlli(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)4229 decode_gtp_tlli(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4230 {
4231 
4232     guint32 tlli;
4233 
4234     tlli = tvb_get_ntohl(tvb, offset + 1);
4235     proto_tree_add_uint(tree, hf_gtp_tlli, tvb, offset, 5, tlli);
4236 
4237     return 5;
4238 }
4239 
4240 /* GPRS:        9.60 v7.6.0, chapter 7.9.5, page 39
4241  * UMTS:        29.060 v4.0, chapter 7.7.5 Packet TMSI (P-TMSI)
4242  */
4243 static int
decode_gtp_ptmsi(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)4244 decode_gtp_ptmsi(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4245 {
4246     proto_item* ti;
4247 
4248     proto_tree_add_item(tree, hf_gtp_ptmsi, tvb, offset + 1, 4, ENC_BIG_ENDIAN);
4249     ti = proto_tree_add_item(tree, hf_3gpp_tmsi, tvb, offset+1, 4, ENC_BIG_ENDIAN);
4250     proto_item_set_hidden(ti);
4251 
4252     return 5;
4253 }
4254 
4255 /*
4256  * adjust - how many bytes before offset should be highlighted
4257  */
4258 static int
decode_qos_gprs(tvbuff_t * tvb,int offset,proto_tree * tree,const gchar * qos_str,guint8 adjust)4259 decode_qos_gprs(tvbuff_t * tvb, int offset, proto_tree * tree, const gchar * qos_str, guint8 adjust)
4260 {
4261 
4262     guint8      spare1, delay, reliability, peak, spare2, precedence, spare3, mean;
4263     proto_tree *ext_tree_qos;
4264 
4265     spare1      = tvb_get_guint8(tvb, offset)     & GTP_EXT_QOS_SPARE1_MASK;
4266     delay       = tvb_get_guint8(tvb, offset)     & GTP_EXT_QOS_DELAY_MASK;
4267     reliability = tvb_get_guint8(tvb, offset)     & GTP_EXT_QOS_RELIABILITY_MASK;
4268     peak        = tvb_get_guint8(tvb, offset + 1) & GTP_EXT_QOS_PEAK_MASK;
4269     spare2      = tvb_get_guint8(tvb, offset + 1) & GTP_EXT_QOS_SPARE2_MASK;
4270     precedence  = tvb_get_guint8(tvb, offset + 1) & GTP_EXT_QOS_PRECEDENCE_MASK;
4271     spare3      = tvb_get_guint8(tvb, offset + 2) & GTP_EXT_QOS_SPARE3_MASK;
4272     mean        = tvb_get_guint8(tvb, offset + 2) & GTP_EXT_QOS_MEAN_MASK;
4273 
4274     ext_tree_qos = proto_tree_add_subtree_format(tree, tvb, offset - adjust, 3 + adjust, ett_gtp_qos, NULL,
4275                              "%s: delay: %u, reliability: %u, peak: %u, precedence: %u, mean: %u",
4276                              qos_str, (delay >> 3) & 0x07, reliability, (peak >> 4) & 0x0F, precedence, mean);
4277 
4278     if (adjust != 0) {
4279         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_spare1,      tvb, offset,     1, spare1);
4280         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_delay,       tvb, offset,     1, delay);
4281         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_reliability, tvb, offset,     1, reliability);
4282         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_peak,        tvb, offset + 1, 1, peak);
4283         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_spare2,      tvb, offset + 1, 1, spare2);
4284         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_precedence,  tvb, offset + 1, 1, precedence);
4285         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_spare3,      tvb, offset + 2, 1, spare3);
4286         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_mean,        tvb, offset + 2, 1, mean);
4287     }
4288 
4289     return 3;
4290 }
4291 
4292 /* GPRS:        9.60 v7.6.0, chapter 7.9.6, page 39
4293  *              4.08
4294  *              3.60
4295  * UMTS:        not present
4296  * TODO:        check if length is included: ETSI 4.08 vs 9.60
4297  */
4298 static int
decode_gtp_qos_gprs(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)4299 decode_gtp_qos_gprs(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4300 {
4301 
4302     return (1 + decode_qos_gprs(tvb, offset + 1, tree, "Quality of Service", 1));
4303 
4304 }
4305 
4306 /* GPRS:        9.60 v7.6.0, chapter 7.9.7, page 39
4307  * UMTS:        29.060 v4.0, chapter 7.7.6 Reordering Required
4308  */
4309 static int
decode_gtp_reorder(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)4310 decode_gtp_reorder(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4311 {
4312 
4313     guint8 reorder;
4314 
4315     reorder = tvb_get_guint8(tvb, offset + 1) & 0x01;
4316     proto_tree_add_boolean(tree, hf_gtp_reorder, tvb, offset, 2, reorder);
4317 
4318     return 2;
4319 }
4320 
4321 /* GPRS:        9.60 v7.6.0, chapter 7.9.8, page 40
4322  *              4.08 v7.1.2, chapter 10.5.3.1+
4323  * UMTS:        29.060 v4.0, chapter 7.7.7
4324  * TODO: Add blurb support by registering items in the protocol registration
4325  */
4326 static int
decode_gtp_auth_tri(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)4327 decode_gtp_auth_tri(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4328 {
4329 
4330     proto_tree *ext_tree_auth_tri;
4331 
4332     ext_tree_auth_tri = proto_tree_add_subtree(tree, tvb, offset, 29, ett_gtp_ies[GTP_EXT_AUTH_TRI], NULL,
4333                             val_to_str_ext_const(GTP_EXT_AUTH_TRI, &gtp_val_ext, "Unknown message"));
4334 
4335     proto_tree_add_item(ext_tree_auth_tri, hf_gtp_rand, tvb, offset + 1, 16, ENC_NA);
4336     proto_tree_add_item(ext_tree_auth_tri, hf_gtp_sres, tvb, offset + 17, 4, ENC_NA);
4337     proto_tree_add_item(ext_tree_auth_tri, hf_gtp_kc, tvb, offset + 21, 8, ENC_NA);
4338 
4339     return 1 + 16 + 4 + 8;
4340 }
4341 
4342 /* GPRS:        9.60 v7.6.0, chapter 7.9.9, page 40
4343  *              9.02 v7.7.0, page 1090
4344  * UMTS:        29.060 v4.0, chapter 7.7.8, page 48
4345  *              29.002 v4.2.1, chapter 17.5, page 268
4346  */
4347 static int
decode_gtp_map_cause(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)4348 decode_gtp_map_cause(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4349 {
4350 
4351     guint8 map_cause;
4352 
4353     map_cause = tvb_get_guint8(tvb, offset + 1);
4354     proto_tree_add_uint(tree, hf_gtp_map_cause, tvb, offset, 2, map_cause);
4355 
4356     return 2;
4357 }
4358 
4359 /* GPRS:        9.60 v7.6.0, chapter 7.9.10, page 41
4360  * UMTS:        29.060 v4.0, chapter 7.7.9, page 48
4361  */
4362 static int
decode_gtp_ptmsi_sig(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)4363 decode_gtp_ptmsi_sig(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4364 {
4365 
4366     guint32 ptmsi_sig;
4367 
4368     ptmsi_sig = tvb_get_ntoh24(tvb, offset + 1);
4369     proto_tree_add_uint(tree, hf_gtp_ptmsi_sig, tvb, offset, 4, ptmsi_sig);
4370 
4371     return 4;
4372 }
4373 
4374 /* GPRS:        9.60 v7.6.0, chapter 7.9.11, page 41
4375  * UMTS:        29.060 v4.0, chapter 7.7.10, page 49
4376  */
4377 static int
decode_gtp_ms_valid(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)4378 decode_gtp_ms_valid(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4379 {
4380 
4381     guint8 ms_valid;
4382 
4383     ms_valid = tvb_get_guint8(tvb, offset + 1) & 0x01;
4384     proto_tree_add_boolean(tree, hf_gtp_ms_valid, tvb, offset, 2, ms_valid);
4385 
4386     return 2;
4387 }
4388 
4389 /* GPRS:        9.60 v7.6.0, chapter 7.9.12, page 41
4390  * UMTS:        29.060 v4.0, chapter 7.7.11 Recovery
4391  */
4392 static int
decode_gtp_recovery(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)4393 decode_gtp_recovery(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4394 {
4395 
4396     guint8 recovery;
4397 
4398     recovery = tvb_get_guint8(tvb, offset + 1);
4399     proto_tree_add_uint(tree, hf_gtp_recovery, tvb, offset, 2, recovery);
4400 
4401     return 2;
4402 }
4403 
4404 /* GPRS:        9.60 v7.6.0, chapter 7.9.13, page 42
4405  * UMTS:        29.060 v4.0, chapter 7.7.12 Selection Mode
4406  */
4407 
4408 
4409 static const gchar *
dissect_radius_selection_mode(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo _U_)4410 dissect_radius_selection_mode(proto_tree * tree, tvbuff_t * tvb, packet_info* pinfo _U_)
4411 {
4412     guint8 sel_mode;
4413 
4414     /* Value in ASCII(UTF-8) */
4415     sel_mode = tvb_get_guint8(tvb, 0) - 0x30;
4416     proto_tree_add_uint(tree, hf_gtp_sel_mode, tvb, 0, 1, sel_mode);
4417 
4418     return val_to_str_const(sel_mode, sel_mode_type, "Unknown");
4419 }
4420 
4421 static int
decode_gtp_sel_mode(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)4422 decode_gtp_sel_mode(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4423 {
4424     proto_tree *ext_tree;
4425     proto_item *te;
4426     guint8 sel_mode;
4427 
4428     sel_mode = tvb_get_guint8(tvb, offset + 1) & 0x03;
4429 
4430     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 2, ett_gtp_ies[GTP_EXT_SEL_MODE], &te,
4431                             val_to_str_ext_const(GTP_EXT_SEL_MODE, &gtp_val_ext, "Unknown message"));
4432     proto_item_append_text(te, ": %s", val_to_str_const(sel_mode, sel_mode_type, "Unknown"));
4433     proto_tree_add_item(ext_tree, hf_gtp_sel_mode, tvb, offset+1, 1, ENC_BIG_ENDIAN);
4434 
4435     return 2;
4436 }
4437 
4438 /* GPRS:        9.60 v7.6.0, chapter 7.9.14, page 42
4439  * UMTS:        29.060 v4.0, chapter 7.7.13, page 50
4440  */
4441 static int
decode_gtp_16(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args)4442 decode_gtp_16(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args)
4443 {
4444 
4445     guint16 ext_flow_label;
4446     guint32 teid_data, *teid;
4447 
4448     switch (gtp_version) {
4449     case 0:
4450         ext_flow_label = tvb_get_ntohs(tvb, offset + 1);
4451         proto_tree_add_uint(tree, hf_gtp_ext_flow_label, tvb, offset, 3, ext_flow_label);
4452 
4453         return 3;
4454     case 1:
4455         teid_data = tvb_get_ntohl(tvb, offset + 1);
4456         /* We save the teid_data so that we could assignate its corresponding session ID later */
4457         if (g_gtp_session && !PINFO_FD_VISITED(pinfo)) {
4458             args->last_teid = teid_data; /* We save it to track the error indication */
4459             if (!teid_exists(teid_data, args->teid_list)) {
4460                 teid = wmem_new(wmem_packet_scope(), guint32);
4461                 *teid = teid_data;
4462                 wmem_list_prepend(args->teid_list, teid);
4463             }
4464         }
4465         proto_tree_add_uint(tree, hf_gtp_teid_data, tvb, offset+1, 4, teid_data);
4466 
4467         return 5;
4468     default:
4469         proto_tree_add_expert_format(tree, pinfo, &ei_gtp_field_not_support_in_version,
4470                     tvb, offset, 1, "Flow label/TEID Data I : GTP version not supported");
4471 
4472         return 3;
4473     }
4474 }
4475 
4476 /* GPRS:        9.60 v7.6.0, chapter 7.9.15, page 42
4477  * UMTS:        29.060 v4.0, chapter 7.7.14, page 42
4478  */
4479 static int
decode_gtp_17(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args)4480 decode_gtp_17(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args)
4481 {
4482 
4483     guint32 teid_cp;
4484     guint32 *teid;
4485 
4486     switch (gtp_version) {
4487     case 0:
4488         proto_tree_add_item(tree, hf_gtp_flow_sig, tvb, offset+1, 2, ENC_BIG_ENDIAN);
4489         return 3;
4490     case 1:
4491         proto_tree_add_item_ret_uint(tree, hf_gtp_teid_cp, tvb, offset+1 , 4, ENC_BIG_ENDIAN, &teid_cp);
4492         /* We save the teid_cp so that we could assignate its corresponding session ID later */
4493         if (g_gtp_session && !PINFO_FD_VISITED(pinfo)) {
4494             if (!teid_exists(teid_cp, args->teid_list)) {
4495                 teid = wmem_new(wmem_packet_scope(), guint32);
4496                 *teid = teid_cp;
4497                 wmem_list_prepend(args->teid_list, teid);
4498             }
4499         }
4500         return 5;
4501     default:
4502         proto_tree_add_expert_format(tree, pinfo, &ei_gtp_field_not_support_in_version,
4503             tvb, offset, 1, "Flow label signalling/TEID control plane : GTP version not supported");
4504         return 3;
4505     }
4506 }
4507 
4508 /* GPRS:        9.60 v7.6.0, chapter 7.9.16, page 42
4509  * UMTS:        29.060 v4.0, chapter 7.7.15, page 51
4510  */
4511 static int
decode_gtp_18(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args _U_)4512 decode_gtp_18(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
4513 {
4514 
4515     guint16     flow_ii;
4516     guint32     teid_ii;
4517     proto_tree *ext_tree_flow_ii;
4518 
4519     switch (gtp_version) {
4520     case 0:
4521         ext_tree_flow_ii = proto_tree_add_subtree(tree, tvb, offset, 4, ett_gtp_ies[GTP_EXT_FLOW_II], NULL,
4522                         val_to_str_ext_const(GTP_EXT_FLOW_II, &gtp_val_ext, "Unknown message"));
4523 
4524         proto_tree_add_item(ext_tree_flow_ii, hf_gtp_nsapi, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
4525 
4526         flow_ii = tvb_get_ntohs(tvb, offset + 2);
4527         proto_tree_add_uint(ext_tree_flow_ii, hf_gtp_flow_ii, tvb, offset + 2, 2, flow_ii);
4528 
4529         return 4;
4530     case 1:
4531         ext_tree_flow_ii = proto_tree_add_subtree(tree, tvb, offset, 6, ett_gtp_flow_ii, NULL,
4532                 val_to_str_ext_const(GTP_EXT_TEID_II, &gtpv1_val_ext, "Unknown message"));
4533 
4534         proto_tree_add_item(ext_tree_flow_ii, hf_gtp_nsapi, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
4535 
4536         teid_ii = tvb_get_ntohl(tvb, offset + 2);
4537         proto_tree_add_uint(ext_tree_flow_ii, hf_gtp_teid_ii, tvb, offset + 2, 4, teid_ii);
4538 
4539         return 6;
4540     default:
4541         proto_tree_add_expert_format(tree, pinfo, &ei_gtp_field_not_support_in_version,
4542             tvb, offset, 1, "Flow data II/TEID Data II : GTP Version not supported");
4543 
4544         return 4;
4545     }
4546 }
4547 
4548 /* GPRS:        9.60 v7.6.0, chapter 7.9.16A, page 43
4549  * UMTS:        29.060 v4.0, chapter 7.7.16, page 51
4550  * Check if all ms_reason types are included
4551  */
4552 static int
decode_gtp_19(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args _U_)4553 decode_gtp_19(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
4554 {
4555 
4556     guint8 field19;
4557 
4558     field19 = tvb_get_guint8(tvb, offset + 1);
4559 
4560     switch (gtp_version) {
4561     case 0:
4562         proto_tree_add_uint(tree, hf_gtp_ms_reason, tvb, offset, 2, field19);
4563         break;
4564     case 1:
4565         proto_tree_add_boolean(tree, hf_gtp_tear_ind, tvb, offset, 2, field19 & 0x01);
4566         break;
4567     default:
4568         proto_tree_add_expert_format(tree, pinfo, &ei_gtp_field_not_support_in_version,
4569             tvb, offset, 1, "Information Element Type = 19 : GTP Version not supported");
4570         break;
4571     }
4572 
4573     return 2;
4574 }
4575 
4576 /* GPRS:        not present
4577  * UMTS:        29.060 v4.0, chapter 7.7.17, page 51
4578  */
4579 static int
decode_gtp_nsapi(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)4580 decode_gtp_nsapi(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4581 {
4582     guint8      nsapi;
4583     proto_tree *ext_tree;
4584     proto_item *te;
4585 
4586     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 2, ett_gtp_ies[GTP_EXT_NSAPI], &te,
4587                             val_to_str_ext_const(GTP_EXT_NSAPI, &gtp_val_ext, "Unknown message"));
4588 
4589     nsapi = tvb_get_guint8(tvb, offset + 1) & 0x0F;
4590     proto_tree_add_item(ext_tree, hf_gtp_nsapi, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
4591     proto_item_append_text(te, ": %u",nsapi);
4592 
4593     return 2;
4594 }
4595 
4596 /* GPRS:        not present
4597  * UMTS:        29.060 v4.0, chapter 7.7.18, page 52
4598  */
4599 static int
decode_gtp_ranap_cause(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)4600 decode_gtp_ranap_cause(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4601 {
4602 
4603     guint8 ranap;
4604 
4605     ranap = tvb_get_guint8(tvb, offset + 1);
4606 
4607     if ((ranap > 0) && (ranap <= 64))
4608         proto_tree_add_uint_format(tree, hf_gtp_ranap_cause, tvb, offset, 2,
4609                                    ranap, "%s (Radio Network Layer Cause) : %s (%u)",
4610                                    val_to_str_ext_const(GTP_EXT_RANAP_CAUSE, &gtp_val_ext, "Unknown"),
4611                                    val_to_str_ext_const(ranap, &ranap_cause_type_ext, "Unknown RANAP Cause"), ranap);
4612 
4613     if ((ranap > 64) && (ranap <= 80))
4614         proto_tree_add_uint_format(tree, hf_gtp_ranap_cause, tvb, offset, 2,
4615                                    ranap, "%s (Transport Layer Cause) : %s (%u)",
4616                                    val_to_str_ext_const(GTP_EXT_RANAP_CAUSE, &gtp_val_ext, "Unknown"),
4617                                    val_to_str_ext_const(ranap, &ranap_cause_type_ext, "Unknown RANAP Cause"), ranap);
4618 
4619     if ((ranap > 80) && (ranap <= 96))
4620         proto_tree_add_uint_format(tree, hf_gtp_ranap_cause, tvb, offset, 2,
4621                                    ranap, "%s (NAS Cause) : %s (%u)",
4622                                    val_to_str_ext_const(GTP_EXT_RANAP_CAUSE, &gtp_val_ext, "Unknown"),
4623                                    val_to_str_ext_const(ranap, &ranap_cause_type_ext, "Unknown RANAP Cause"), ranap);
4624 
4625     if ((ranap > 96) && (ranap <= 112))
4626         proto_tree_add_uint_format(tree, hf_gtp_ranap_cause, tvb, offset, 2, ranap,
4627                                    "%s (Protocol Cause) : %s (%u)",
4628                                    val_to_str_ext_const(GTP_EXT_RANAP_CAUSE, &gtp_val_ext, "Unknown"),
4629                                    val_to_str_ext_const(ranap, &ranap_cause_type_ext, "Unknown RANAP Cause"), ranap);
4630 
4631     if ((ranap > 112) && (ranap <= 128))
4632         proto_tree_add_uint_format(tree, hf_gtp_ranap_cause, tvb, offset, 2, ranap,
4633                                    "%s (Miscellaneous Cause) : %s (%u)",
4634                                    val_to_str_ext_const(GTP_EXT_RANAP_CAUSE, &gtp_val_ext, "Unknown"),
4635                                    val_to_str_ext_const(ranap, &ranap_cause_type_ext, "Unknown RANAP Cause"), ranap);
4636 
4637     if ((ranap > 128) /* && (ranap <= 255) */ )
4638         proto_tree_add_uint_format(tree, hf_gtp_ranap_cause, tvb, offset, 2, ranap,
4639                                    "%s (Non-standard Cause) : %s (%u)",
4640                                    val_to_str_ext_const(GTP_EXT_RANAP_CAUSE, &gtp_val_ext, "Unknown"),
4641                                    val_to_str_ext_const(ranap, &ranap_cause_type_ext, "Unknown RANAP Cause"), ranap);
4642 
4643     return 2;
4644 }
4645 
4646 /* GPRS:        not present
4647  * UMTS:        29.060 v4.0, chapter 7.7.19, page 52
4648  */
4649 static int
decode_gtp_rab_cntxt(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)4650 decode_gtp_rab_cntxt(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4651 {
4652     proto_tree *ext_tree_rab_cntxt;
4653 
4654     ext_tree_rab_cntxt = proto_tree_add_subtree(tree, tvb, offset, 10, ett_gtp_ies[GTP_EXT_RAB_CNTXT], NULL,
4655                         val_to_str_ext_const(GTP_EXT_RAB_CNTXT, &gtp_val_ext, "Unknown message"));
4656 
4657     proto_tree_add_item(ext_tree_rab_cntxt, hf_gtp_nsapi,       tvb, offset + 1, 1, ENC_BIG_ENDIAN);
4658     proto_tree_add_item(ext_tree_rab_cntxt, hf_gtp_rab_gtpu_dn, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
4659     proto_tree_add_item(ext_tree_rab_cntxt, hf_gtp_rab_gtpu_up, tvb, offset + 4, 2, ENC_BIG_ENDIAN);
4660     proto_tree_add_item(ext_tree_rab_cntxt, hf_gtp_rab_pdu_dn,  tvb, offset + 6, 2, ENC_BIG_ENDIAN);
4661     proto_tree_add_item(ext_tree_rab_cntxt, hf_gtp_rab_pdu_up,  tvb, offset + 8, 2, ENC_BIG_ENDIAN);
4662 
4663     return 10;
4664 }
4665 
4666 
4667 /* GPRS:        not present
4668  * UMTS:        29.060 v4.0, chapter 7.7.20, page 53
4669  */
4670 static int
decode_gtp_rp_sms(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)4671 decode_gtp_rp_sms(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4672 {
4673 
4674     guint8 rp_sms;
4675 
4676     rp_sms = tvb_get_guint8(tvb, offset + 1) & 0x07;
4677     proto_tree_add_uint(tree, hf_gtp_rp_sms, tvb, offset, 2, rp_sms);
4678 
4679     return 2;
4680 }
4681 
4682 /* GPRS:        not present
4683  * UMTS:        29.060 v4.0, chapter 7.7.21, page 53
4684  */
4685 static int
decode_gtp_rp(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)4686 decode_gtp_rp(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4687 {
4688 
4689     proto_tree *ext_tree_rp;
4690     proto_item *te;
4691     guint8      nsapi, rp, spare;
4692 
4693     nsapi = tvb_get_guint8(tvb, offset + 1) & 0xF0;
4694     spare = tvb_get_guint8(tvb, offset + 1) & 0x08;
4695     rp = tvb_get_guint8(tvb, offset + 1) & 0x07;
4696 
4697     te = proto_tree_add_uint_format(tree, hf_gtp_rp, tvb, offset, 2, rp, "Radio Priority for NSAPI(%u) : %u", nsapi, rp);
4698     ext_tree_rp = proto_item_add_subtree(te, ett_gtp_rp);
4699 
4700     proto_tree_add_uint(ext_tree_rp, hf_gtp_rp_nsapi, tvb, offset + 1, 1, nsapi);
4701     proto_tree_add_uint(ext_tree_rp, hf_gtp_rp_spare, tvb, offset + 1, 1, spare);
4702     proto_tree_add_uint(ext_tree_rp, hf_gtp_rp,       tvb, offset + 1, 1, rp);
4703 
4704     return 2;
4705 }
4706 
4707 /* GPRS:        not present
4708  * UMTS:        29.060 v4.0, chapter 7.7.22, page 53
4709  */
4710 static int
decode_gtp_pkt_flow_id(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)4711 decode_gtp_pkt_flow_id(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4712 {
4713 
4714     proto_tree *ext_tree_pkt_flow_id;
4715     proto_item *te;
4716     guint8      nsapi, pkt_flow_id;
4717 
4718     nsapi = tvb_get_guint8(tvb, offset + 1) & 0x0F;
4719     pkt_flow_id = tvb_get_guint8(tvb, offset + 2);
4720 
4721     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);
4722     ext_tree_pkt_flow_id = proto_item_add_subtree(te, ett_gtp_pkt_flow_id);
4723 
4724     proto_tree_add_item(ext_tree_pkt_flow_id, hf_gtp_nsapi, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
4725     proto_tree_add_uint_format(ext_tree_pkt_flow_id, hf_gtp_pkt_flow_id, tvb,
4726                                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);
4727 
4728     return 3;
4729 }
4730 
4731 /* GPRS:        not present
4732  * UMTS:        29.060 v4.0, chapter 7.7.23, page 53
4733  * TODO: Differenciate these uints?
4734  */
4735 static int
decode_gtp_chrg_char(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)4736 decode_gtp_chrg_char(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4737 {
4738 
4739     guint16     chrg_char;
4740     proto_item *te;
4741     proto_tree *ext_tree_chrg_char;
4742 
4743     chrg_char = tvb_get_ntohs(tvb, offset + 1);
4744 
4745     te = proto_tree_add_uint(tree, hf_gtp_chrg_char, tvb, offset, 3, chrg_char);
4746     /*"%s: %x", val_to_str_ext_const (GTP_EXT_CHRG_CHAR, &gtp_val_ext, "Unknown message"), chrg_char); */
4747     ext_tree_chrg_char = proto_item_add_subtree(te, ett_gtp_ies[GTP_EXT_CHRG_CHAR]);
4748 
4749     proto_tree_add_uint(ext_tree_chrg_char, hf_gtp_chrg_char_s, tvb, offset + 1, 2, chrg_char);
4750     proto_tree_add_uint(ext_tree_chrg_char, hf_gtp_chrg_char_n, tvb, offset + 1, 2, chrg_char);
4751     proto_tree_add_uint(ext_tree_chrg_char, hf_gtp_chrg_char_p, tvb, offset + 1, 2, chrg_char);
4752     proto_tree_add_uint(ext_tree_chrg_char, hf_gtp_chrg_char_f, tvb, offset + 1, 2, chrg_char);
4753     proto_tree_add_uint(ext_tree_chrg_char, hf_gtp_chrg_char_h, tvb, offset + 1, 2, chrg_char);
4754     proto_tree_add_uint(ext_tree_chrg_char, hf_gtp_chrg_char_r, tvb, offset + 1, 2, chrg_char);
4755 
4756     return 3;
4757 }
4758 
4759 /* GPRS:        not present
4760  * UMTS:        29.060 v4.0, chapter 7.7.24, page
4761  */
4762 static int
decode_gtp_trace_ref(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)4763 decode_gtp_trace_ref(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4764 {
4765 
4766     guint16 trace_ref;
4767 
4768     trace_ref = tvb_get_ntohs(tvb, offset + 1);
4769 
4770     proto_tree_add_uint(tree, hf_gtp_trace_ref, tvb, offset, 3, trace_ref);
4771 
4772     return 3;
4773 }
4774 
4775 /* GPRS:        not present
4776  * UMTS:        29.060 v4.0, chapter 7.7.25, page
4777  */
4778 static int
decode_gtp_trace_type(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)4779 decode_gtp_trace_type(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4780 {
4781 
4782     guint16 trace_type;
4783 
4784     trace_type = tvb_get_ntohs(tvb, offset + 1);
4785 
4786     proto_tree_add_uint(tree, hf_gtp_trace_type, tvb, offset, 3, trace_type);
4787 
4788     return 3;
4789 }
4790 
4791 /* GPRS:        9.60 v7.6.0, chapter 7.9.16A
4792  * UMTS:        29.060 v4.0, chapter 7.7.25A, page
4793  */
4794 static int
decode_gtp_ms_reason(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)4795 decode_gtp_ms_reason(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4796 {
4797 
4798     guint8 reason;
4799 
4800     reason = tvb_get_guint8(tvb, offset + 1);
4801 
4802     /* Reason for Absence is defined in 3GPP TS 23.040  */
4803     proto_tree_add_uint(tree, hf_gtp_ms_reason, tvb, offset, 2, reason);
4804 
4805     return 2;
4806 }
4807 
4808 /* GPRS:        ?
4809  * UMTS:        29.060 v6.11.0, chapter 7.7.25B
4810  * Radio Priority LCS
4811  */
4812 static int
decode_gtp_ra_prio_lcs(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)4813 decode_gtp_ra_prio_lcs(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4814 {
4815 
4816     guint16     length;
4817     proto_tree *ext_tree;
4818 
4819     length = tvb_get_ntohs(tvb, offset + 1);
4820     ext_tree = proto_tree_add_subtree_format(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_RA_PRIO_LCS], NULL,
4821                     "%s : ", val_to_str_ext_const(GTP_EXT_RA_PRIO_LCS, &gtp_val_ext, "Unknown"));
4822 
4823     offset++;
4824     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
4825     offset = offset + 2;
4826 
4827     proto_tree_add_item(ext_tree, hf_gtp_ra_prio_lcs, tvb, offset, 1, ENC_BIG_ENDIAN);
4828 
4829     return 3 + length;
4830 
4831 }
4832 
4833 /* GPRS:        12.15 v7.6.0, chapter 7.3.3, page 45
4834  * UMTS:        33.015
4835  */
4836 static int
decode_gtp_tr_comm(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)4837 decode_gtp_tr_comm(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4838 {
4839 
4840     guint8 tr_command;
4841 
4842     tr_command = tvb_get_guint8(tvb, offset + 1);
4843 
4844     proto_tree_add_uint(tree, hf_gtp_tr_comm, tvb, offset, 2, tr_command);
4845 
4846     return 2;
4847 }
4848 
4849 /* GPRS:        9.60 v7.6.0, chapter 7.9.17, page 43
4850  * UMTS:        29.060 v4.0, chapter 7.7.26, page 55
4851  */
4852 static int
decode_gtp_chrg_id(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)4853 decode_gtp_chrg_id(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4854 {
4855 
4856     guint32 chrg_id;
4857 
4858     chrg_id = tvb_get_ntohl(tvb, offset + 1);
4859     proto_tree_add_uint(tree, hf_gtp_chrg_id, tvb, offset, 5, chrg_id);
4860 
4861     return 5;
4862 }
4863 
4864 /* GPRS:        9.60 v7.6.0, chapter 7.9.18, page 43
4865  * UMTS:        29.060 v4.0, chapter 7.7.27, page 55
4866  */
4867 static int
decode_gtp_user_addr(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)4868 decode_gtp_user_addr(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
4869 {
4870 
4871     guint16            length;
4872     guint8             pdp_typ, pdp_org;
4873     proto_tree        *ext_tree_user;
4874     proto_item        *te;
4875 
4876 
4877     length = tvb_get_ntohs(tvb, offset + 1);
4878     pdp_org = tvb_get_guint8(tvb, offset + 3) & 0x0F;
4879     pdp_typ = tvb_get_guint8(tvb, offset + 4);
4880 
4881     ext_tree_user = proto_tree_add_subtree_format(tree, tvb, offset, 3 + length,
4882                              ett_gtp_ies[GTP_EXT_USER_ADDR], &te, "%s (%s/%s)",
4883                              val_to_str_ext_const(GTP_EXT_USER_ADDR, &gtp_val_ext, "Unknown message"),
4884                              val_to_str_const(pdp_org, pdp_org_type, "Unknown PDP Organization"),
4885                              val_to_str_const(pdp_typ, pdp_type, "Unknown PDP Type"));
4886 
4887     proto_tree_add_item(ext_tree_user, hf_gtp_length, tvb, offset + 1, 2, ENC_BIG_ENDIAN);
4888     proto_tree_add_uint(ext_tree_user, hf_gtp_user_addr_pdp_org,  tvb, offset + 3, 1, pdp_org);
4889     proto_tree_add_uint(ext_tree_user, hf_gtp_user_addr_pdp_type, tvb, offset + 4, 1, pdp_typ);
4890 
4891     if (length == 2) {
4892         if ((pdp_org == 0) && (pdp_typ == 1))
4893             proto_item_append_text(te, " (Point to Point Protocol)");
4894         else if (pdp_typ == 2)
4895             proto_item_append_text(te, " (Octet Stream Protocol)");
4896     } else if (length > 2) {
4897         switch (pdp_typ) {
4898         case 0x21:
4899             proto_tree_add_item(ext_tree_user, hf_gtp_user_ipv4, tvb, offset + 5, 4, ENC_BIG_ENDIAN);
4900             proto_item_append_text(te, " : %s", tvb_ip_to_str(pinfo->pool, tvb, offset + 5));
4901             break;
4902         case 0x57:
4903             proto_tree_add_item(ext_tree_user, hf_gtp_user_ipv6, tvb, offset + 5, 16, ENC_NA);
4904             proto_item_append_text(te, " : %s", tvb_ip6_to_str(pinfo->pool, tvb, offset + 5));
4905             break;
4906         case 0x8d:
4907             if (length == 6) {
4908                 ws_in6_addr ipv6;
4909                 memset(&ipv6, 0, sizeof(ws_in6_addr));
4910                 proto_tree_add_item(ext_tree_user, hf_gtp_user_ipv4, tvb, offset + 5, 4, ENC_BIG_ENDIAN);
4911                 proto_tree_add_ipv6_format_value(ext_tree_user, hf_gtp_user_ipv6, tvb, offset + 9, 0, &ipv6, "dynamic");
4912                 proto_item_append_text(te, " : %s / dynamic", tvb_ip_to_str(pinfo->pool, tvb, offset + 5));
4913             } else if (length == 18) {
4914                 proto_tree_add_ipv4_format_value(ext_tree_user, hf_gtp_user_ipv6, tvb, offset + 5, 0, 0, "dynamic");
4915                 proto_tree_add_item(ext_tree_user, hf_gtp_user_ipv6, tvb, offset + 5, 16, ENC_NA);
4916                 proto_item_append_text(te, " : dynamic / %s", tvb_ip6_to_str(pinfo->pool, tvb, offset + 5));
4917             } else if (length == 22) {
4918                 proto_tree_add_item(ext_tree_user, hf_gtp_user_ipv4, tvb, offset + 5, 4, ENC_BIG_ENDIAN);
4919                 proto_tree_add_item(ext_tree_user, hf_gtp_user_ipv6, tvb, offset + 9, 16, ENC_NA);
4920                 proto_item_append_text(te, " : %s / %s", tvb_ip_to_str(pinfo->pool, tvb, offset + 5),
4921                                        tvb_ip6_to_str(pinfo->pool, tvb, offset + 9));
4922             } else {
4923                 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);
4924             }
4925             break;
4926         }
4927     } else
4928         proto_item_append_text(te, " : empty PDP Address");
4929 
4930     return 3 + length;
4931 }
4932 
4933 static int
decode_triplet(tvbuff_t * tvb,int offset,proto_tree * tree,guint16 count)4934 decode_triplet(tvbuff_t * tvb, int offset, proto_tree * tree, guint16 count)
4935 {
4936 
4937     proto_tree *ext_tree_trip;
4938     guint16     i;
4939 
4940     for (i = 0; i < count; i++) {
4941         ext_tree_trip = proto_tree_add_subtree_format(tree, tvb, offset + i * 28, 28, ett_gtp_trip, NULL, "Triplet no%x", i);
4942 
4943         proto_tree_add_item(ext_tree_trip, hf_gtp_rand, tvb, offset + i * 28, 16, ENC_NA);
4944         proto_tree_add_item(ext_tree_trip, hf_gtp_sres, tvb, offset + i * 28 + 16, 4, ENC_NA);
4945         proto_tree_add_item(ext_tree_trip, hf_gtp_kc, tvb, offset + i * 28 + 20, 8, ENC_NA);
4946     }
4947 
4948     return count * 28;
4949 }
4950 
4951 /* adjust - how many bytes before quintuplet should be highlighted
4952  */
4953 static int
decode_quintuplet(tvbuff_t * tvb,int offset,proto_tree * tree,guint16 count)4954 decode_quintuplet(tvbuff_t * tvb, int offset, proto_tree * tree, guint16 count)
4955 {
4956 
4957     proto_tree *ext_tree_quint;
4958     proto_item *te_quint;
4959     guint16     q_offset, i;
4960     guint8      xres_len, auth_len;
4961 
4962     q_offset = 0;
4963 
4964     for (i = 0; i < count; i++) {
4965 
4966         ext_tree_quint = proto_tree_add_subtree_format(tree, tvb, offset, -1,
4967                                 ett_gtp_quint, &te_quint, "Quintuplet #%x", i + 1);
4968 
4969         proto_tree_add_item(ext_tree_quint, hf_gtp_rand, tvb, offset + q_offset, 16, ENC_NA);
4970         q_offset = q_offset + 16;
4971         xres_len = tvb_get_guint8(tvb, offset + q_offset);
4972         proto_tree_add_item(ext_tree_quint, hf_gtp_xres_length, tvb, offset + q_offset, 1, ENC_BIG_ENDIAN);
4973         q_offset++;
4974         proto_tree_add_item(ext_tree_quint, hf_gtp_xres, tvb, offset + q_offset, xres_len, ENC_NA);
4975         q_offset = q_offset + xres_len;
4976         proto_tree_add_item(ext_tree_quint, hf_gtp_quintuplet_ciphering_key, tvb, offset + q_offset, 16, ENC_NA);
4977         q_offset = q_offset + 16;
4978         proto_tree_add_item(ext_tree_quint, hf_gtp_quintuplet_integrity_key, tvb, offset + q_offset, 16, ENC_NA);
4979         q_offset = q_offset + 16;
4980         auth_len = tvb_get_guint8(tvb, offset + q_offset);
4981         proto_tree_add_item(ext_tree_quint, hf_gtp_authentication_length, tvb, offset + q_offset, 1, ENC_BIG_ENDIAN);
4982         q_offset++;
4983         proto_tree_add_item(ext_tree_quint, hf_gtp_auth, tvb, offset + q_offset, auth_len, ENC_NA);
4984 
4985         q_offset = q_offset + auth_len;
4986         proto_item_set_end(te_quint, tvb, offset + q_offset);
4987 
4988     }
4989 
4990     return q_offset;
4991 }
4992 
4993 /* GPRS:        9.60 v7.6.0, chapter 7.9.19 page
4994  * UMTS:        29.060 v4.0, chapter 7.7.28 page 57
4995  * TODO:        - check if for quintuplets first 2 bytes are length, according to AuthQuint
4996  *              - finish displaying last 3 parameters
4997  */
4998 static int
decode_gtp_mm_cntxt(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args _U_)4999 decode_gtp_mm_cntxt(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
5000 {
5001 
5002     guint16     length, con_len;
5003     guint8      count, sec_mode, len, iei;
5004     proto_tree *ext_tree_mm;
5005     proto_tree *tf_tree = NULL, *con_tree;
5006 
5007     ext_tree_mm = proto_tree_add_subtree(tree, tvb, offset, 1, ett_gtp_ies[GTP_EXT_MM_CNTXT], NULL,
5008                         val_to_str_ext_const(GTP_EXT_MM_CNTXT, &gtp_val_ext, "Unknown message"));
5009 
5010     /* Octet 2 - 3 */
5011     length = tvb_get_ntohs(tvb, offset + 1);
5012     if (length < 1)
5013         return 3;
5014 
5015     /* Octet 4 (cksn)*/
5016 
5017     /* Octet 5 */
5018     sec_mode = (tvb_get_guint8(tvb, offset + 4) >> 6) & 0x03;
5019     count = (tvb_get_guint8(tvb, offset + 4) >> 3) & 0x07;
5020 
5021     proto_tree_add_item(ext_tree_mm, hf_gtp_length, tvb, offset + 1, 2, ENC_BIG_ENDIAN);
5022     if (gtp_version == 0)
5023         sec_mode = 1;
5024 
5025 
5026     switch (sec_mode) {
5027     case 0:                     /* Used cipher value, UMTS keys and Quintuplets */
5028         proto_tree_add_item(ext_tree_mm, hf_gtp_cksn_ksi,         tvb, offset + 3, 1, ENC_BIG_ENDIAN);
5029         proto_tree_add_item(ext_tree_mm, hf_gtp_security_mode,    tvb, offset + 4, 1, ENC_BIG_ENDIAN);
5030         proto_tree_add_item(ext_tree_mm, hf_gtp_no_of_vectors,    tvb, offset + 4, 1, ENC_BIG_ENDIAN);
5031         proto_tree_add_item(ext_tree_mm, hf_gtp_cipher_algorithm, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
5032         proto_tree_add_item(ext_tree_mm, hf_gtp_ciphering_key_ck, tvb, offset + 5, 16, ENC_NA);
5033         proto_tree_add_item(ext_tree_mm, hf_gtp_integrity_key_ik, tvb, offset + 21, 16, ENC_NA);
5034         proto_tree_add_item(ext_tree_mm, hf_gtp_quintuplets_length, tvb, offset + 37, 2, ENC_BIG_ENDIAN);
5035 
5036         offset = offset + decode_quintuplet(tvb, offset + 39, ext_tree_mm, count) + 39;
5037 
5038 
5039         break;
5040     case 1:                     /* GSM key and triplets */
5041         proto_tree_add_item(ext_tree_mm, hf_gtp_cksn, tvb, offset + 3, 1, ENC_BIG_ENDIAN);
5042         if (gtp_version != 0)
5043             proto_tree_add_item(ext_tree_mm, hf_gtp_security_mode, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
5044 
5045         proto_tree_add_item(ext_tree_mm, hf_gtp_no_of_vectors,    tvb, offset + 4, 1, ENC_BIG_ENDIAN);
5046         proto_tree_add_item(ext_tree_mm, hf_gtp_cipher_algorithm, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
5047         proto_tree_add_item(ext_tree_mm, hf_gtp_ciphering_key_kc, tvb, offset + 5, 8, ENC_NA);
5048 
5049         offset = offset + decode_triplet(tvb, offset + 13, ext_tree_mm, count) + 13;
5050 
5051         break;
5052     case 2:                     /* UMTS key and quintuplets */
5053         proto_tree_add_item(ext_tree_mm, hf_gtp_ksi, tvb, offset + 3, 1, ENC_BIG_ENDIAN);
5054         proto_tree_add_item(ext_tree_mm, hf_gtp_security_mode, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
5055         proto_tree_add_item(ext_tree_mm, hf_gtp_no_of_vectors, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
5056         proto_tree_add_item(ext_tree_mm, hf_gtp_ciphering_key_ck, tvb, offset + 5, 16, ENC_NA);
5057         proto_tree_add_item(ext_tree_mm, hf_gtp_integrity_key_ik, tvb, offset + 21, 16, ENC_NA);
5058        proto_tree_add_item(ext_tree_mm, hf_gtp_quintuplets_length, tvb, offset + 37, 2, ENC_BIG_ENDIAN);
5059 
5060         offset = offset + decode_quintuplet(tvb, offset + 39, ext_tree_mm, count) + 39;
5061 
5062         break;
5063     case 3:                     /* GSM key and quintuplets */
5064         proto_tree_add_item(ext_tree_mm, hf_gtp_cksn,             tvb, offset + 3, 1, ENC_BIG_ENDIAN);
5065         proto_tree_add_item(ext_tree_mm, hf_gtp_security_mode,    tvb, offset + 4, 1, ENC_BIG_ENDIAN);
5066         proto_tree_add_item(ext_tree_mm, hf_gtp_no_of_vectors,    tvb, offset + 4, 1, ENC_BIG_ENDIAN);
5067         proto_tree_add_item(ext_tree_mm, hf_gtp_cipher_algorithm, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
5068         proto_tree_add_item(ext_tree_mm, hf_gtp_ciphering_key_kc, tvb, offset + 5, 8, ENC_NA);
5069         proto_tree_add_item(ext_tree_mm, hf_gtp_quintuplets_length, tvb, offset + 13, 2, ENC_BIG_ENDIAN);
5070 
5071         offset = offset + decode_quintuplet(tvb, offset + 15, ext_tree_mm, count) + 15;
5072 
5073         break;
5074     default:
5075         break;
5076     }
5077 
5078 /*
5079  * 3GPP TS 24.008 10.5.5.6 ( see packet-gsm_a.c )
5080  */
5081     tf_tree = proto_tree_add_subtree(ext_tree_mm, tvb, offset, 2, ett_gtp_drx, NULL, "DRX Parameter");
5082     de_gmm_drx_param(tvb, tf_tree, pinfo, offset, 2, NULL, 0);
5083     offset = offset + 2;
5084 
5085     len = tvb_get_guint8(tvb, offset);
5086     tf_tree = proto_tree_add_subtree(ext_tree_mm, tvb, offset, len + 1, ett_gtp_net_cap, NULL, "MS Network Capability");
5087 
5088     proto_tree_add_uint(tf_tree, hf_gtp_ms_network_cap_content_len, tvb, offset, 1, len);
5089 
5090     offset++;
5091 /*
5092  * GPP TS 24.008 10.5.5.12 ( see packet-gsm_a.c )
5093  */
5094     de_gmm_ms_net_cap(tvb, tf_tree, pinfo, offset, len, NULL, 0);
5095     offset = offset + len;
5096 
5097 /* 3GPP TS 29.060 version 9.4.0 Release 9
5098  *  The two octets Container Length holds the length of the Container, excluding the Container Length octets.
5099  * Container contains one or several optional information elements as described in the clause "Overview", from the clause
5100  * "General message format and information elements coding" in 3GPP TS 24.008 [5]. For the definition of the IEI see
5101  * table 47a, "IEIs for information elements used in the container". The IMEISV shall, if available, be included in the
5102  * Container. The IMEISV is included in the Mobile identity IE. If Container is not included, its Length field value shall
5103  * be set to 0. If the MS is emergency attached and the MS is UICCless or the IMSI is unauthenticated, the International
5104  * Mobile Equipment Identity (IMEI) shall be used as the MS identity.
5105  *
5106  * Table 47A: IEIs for information elements used in the container
5107  * IEI            Information element
5108  * 0x23           Mobile identity
5109  *
5110  * NOTE: In 3GPP TS 24.008 [5] the IEI definition is
5111  * message dependent. The table is added to
5112  * have a unique definition in the present
5113  * document for the used IEI in the MMcontext.
5114  */
5115 
5116     con_len = tvb_get_ntohs(tvb, offset);
5117     proto_tree_add_item(ext_tree_mm, hf_gtp_container_length, tvb, offset, 2, ENC_BIG_ENDIAN);
5118     offset = offset + 2;
5119 
5120     if (con_len > 0) {
5121         proto_item* ti;
5122 
5123         con_tree = proto_tree_add_subtree(ext_tree_mm, tvb, offset, con_len, ett_gtp_mm_cntxt, NULL, "Container");
5124 
5125         iei = tvb_get_guint8(tvb,offset);
5126         ti = proto_tree_add_uint(con_tree, hf_gtp_iei, tvb, offset, 1, iei);
5127         if (iei == 0x23) {
5128             proto_item_append_text(ti, " (Mobile identity)");
5129             offset++;
5130             len = tvb_get_guint8(tvb,offset);
5131             proto_tree_add_uint(con_tree, hf_gtp_iei_mobile_id_len, tvb, offset, 1, len);
5132             offset++;
5133             de_mid(tvb, con_tree, pinfo, offset, len, NULL, 0);
5134         } else {
5135             expert_add_info(pinfo, ti, &ei_gtp_iei);
5136         }
5137     }
5138 
5139     return 3 + length;
5140 }
5141 
5142 /* Function to extract the value of an hexadecimal octet. Only the lower
5143  * nybble will be non-zero in the output.
5144  * */
5145 static guint8
hex2dec(guint8 x)5146 hex2dec(guint8 x)
5147 {
5148     /* XXX, ws_xton() */
5149     if ((x >= 'a') && (x <= 'f'))
5150         x = x - 'a' + 10;
5151     else if ((x >= 'A') && (x <= 'F'))
5152         x = x - 'A' + 10;
5153     else if ((x >= '0') && (x <= '9'))
5154         x = x - '0';
5155     else
5156         x = 0;
5157     return x;
5158 }
5159 
5160 /* Wrapper function to add UTF-8 decoding for QoS attributes in
5161  * RADIUS messages.
5162  * */
5163 static guint8
wrapped_tvb_get_guint8(tvbuff_t * tvb,int offset,int type)5164 wrapped_tvb_get_guint8(tvbuff_t * tvb, int offset, int type)
5165 {
5166     if (type == 2)
5167         return (hex2dec(tvb_get_guint8(tvb, offset)) << 4 | hex2dec(tvb_get_guint8(tvb, offset + 1)));
5168     else
5169         return tvb_get_guint8(tvb, offset);
5170 }
5171 
5172  /* WARNING : actually length is coded on 2 octets for QoS profile but on 1 octet for PDP Context!
5173   * so type means length of length :-)
5174   *
5175   * WARNING :) type does not mean length of length any more... see below for
5176   * type = 3!
5177   */
5178 int
decode_qos_umts(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,const gchar * qos_str,guint8 type)5179 decode_qos_umts(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, const gchar * qos_str, guint8 type)
5180 {
5181 
5182     guint       length;
5183     guint8      al_ret_priority;
5184     guint8      delay, reliability, peak, precedence, mean, spare1, spare2, spare3;
5185     guint8      traf_class, del_order, del_err_sdu;
5186     guint8      max_sdu_size, max_ul, max_dl, max_ul_ext, max_dl_ext, max_ul_ext2 = 0, max_dl_ext2 = 0;
5187     guint8      res_ber, sdu_err_ratio;
5188     guint8      trans_delay, traf_handl_prio;
5189     guint8      guar_ul, guar_dl, guar_ul_ext, guar_dl_ext, guar_ul_ext2 = 0, guar_dl_ext2 = 0;
5190     guint8      src_stat_desc, sig_ind, spare4;
5191     proto_tree *ext_tree_qos;
5192     int         mss, mu, md, gu, gd;
5193     guint8      arp, qci;
5194     guint32     apn_ambr;
5195     guint64     br;
5196 
5197     /* Will keep if the input is UTF-8 encoded (as in RADIUS messages).
5198      * If 1, input is *not* UTF-8 encoded (i.e. each input octet corresponds
5199      * to one byte to be dissected).
5200      * If 2, input is UTF-8 encoded (i.e. each *couple* of input octets
5201      * corresponds to one byte to be dissected)
5202      * */
5203     guint8 utf8_type = 1;
5204 
5205     /* Will keep the release indicator as indicated in the RADIUS message */
5206     guint8 rel_ind = 0;
5207 
5208     /* In RADIUS messages the QoS has a version field of two octets prepended.
5209      * As of 29.061 v.3.a.0, there is an hyphen between "Release Indicator" and
5210      * <release specific QoS IE UTF-8 encoding>. Even if it sounds rather
5211      * inconsistent and unuseful, I will check hyphen presence here and
5212      * will signal its presence.
5213      * */
5214     guint8 hyphen;
5215 
5216     /* Will keep the value that will be returned
5217      * */
5218     int retval = 0;
5219 
5220     switch (type) {
5221     case 0:
5222         /* For QoS inside GPRS-CDR messages from GGSN/P-GW */
5223         length = tvb_reported_length(tvb);
5224         ext_tree_qos = proto_tree_add_subtree(tree, tvb, offset, length, ett_gtp_qos, NULL, qos_str);
5225         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_umts_length, tvb, offset, 1, length);
5226         /* QoS inside GPRS-CDR has no length octet, so no extra offset needed */
5227         retval = length;
5228         break;
5229     case 1:
5230         length = tvb_get_guint8(tvb, offset);
5231         ext_tree_qos = proto_tree_add_subtree(tree, tvb, offset, length + 1, ett_gtp_qos, NULL, qos_str);
5232         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_umts_length, tvb, offset, 1, length);
5233         offset++;
5234         retval = length + 1;
5235         break;
5236     case 2:
5237         length = tvb_get_ntohs(tvb, offset + 1);
5238         ext_tree_qos = proto_tree_add_subtree(tree, tvb, offset, length + 3, ett_gtp_qos, NULL, qos_str);
5239         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_umts_length, tvb, offset + 1, 2, length);
5240         offset += 3;            /* +1 because of first 0x86 byte for UMTS QoS */
5241         retval = length + 3;
5242         break;
5243     case 3:
5244         /* For QoS inside RADIUS Client messages from GGSN/P-GW */
5245         utf8_type = 2;
5246 
5247         /* The field in the RADIUS message is the length of the tvb we were given */
5248         length = tvb_reported_length(tvb);
5249         ext_tree_qos = proto_tree_add_subtree(tree, tvb, offset, length, ett_gtp_qos, NULL, qos_str);
5250 
5251         rel_ind = wrapped_tvb_get_guint8(tvb, offset, 2);
5252         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_version, tvb, offset, 2, rel_ind);
5253 
5254         /* Hyphen handling */
5255         hyphen = tvb_get_guint8(tvb, offset + 2);
5256         if (hyphen == ((guint8) '-')) {
5257             /* Hyphen is present, put in protocol tree */
5258             proto_tree_add_item(ext_tree_qos, hf_gtp_hyphen_separator, tvb, offset + 2, 1, ENC_NA);
5259             offset++;           /* "Get rid" of hyphen */
5260         }
5261 
5262         /* Now, we modify offset here and in order to use type later
5263          * effectively.*/
5264         offset++;
5265 
5266         length -= offset;
5267         length /= 2;
5268 
5269         /* Fake the length of the IE including the IE id and length octets
5270          * we are actually using it to determine precense of Octet n as counted in
5271          * TS 24.008
5272          */
5273         length = retval = length + 2;    /* Actually, will be ignored. */
5274         break;
5275     default:
5276         /* XXX - what should we do with the length here? */
5277         length = 0;
5278         retval = 0;
5279         ext_tree_qos = NULL;
5280         break;
5281     }
5282 
5283     if ((type == 3) && (rel_ind >= 8)) {
5284         /* Release 8 or higher P-GW QoS profile */
5285         static int * const arp_flags[] = {
5286             &hf_gtp_qos_arp_pci,
5287             &hf_gtp_qos_arp_pl,
5288             &hf_gtp_qos_arp_pvi,
5289             NULL
5290         };
5291 
5292         offset++;
5293         arp = wrapped_tvb_get_guint8(tvb, offset, 2);
5294         proto_tree_add_bitmask_value_with_flags(ext_tree_qos, tvb, offset, hf_gtp_qos_arp,
5295                     ett_gtp_qos_arp, arp_flags, arp, BMT_NO_APPEND);
5296         offset += 2;
5297 
5298         qci = wrapped_tvb_get_guint8(tvb, offset, 2);
5299         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_qci, tvb, offset, 2, qci);
5300         offset += 2;
5301         if (qci <= 4) {
5302             /* GBR QCI */
5303             br = ((guint64)wrapped_tvb_get_guint8(tvb, offset  , 2) << 32) |
5304                  ((guint64)wrapped_tvb_get_guint8(tvb, offset+2, 2) << 24) |
5305                  ((guint64)wrapped_tvb_get_guint8(tvb, offset+4, 2) << 16) |
5306                  ((guint64)wrapped_tvb_get_guint8(tvb, offset+6, 2) <<  8) |
5307                   (guint64)wrapped_tvb_get_guint8(tvb, offset+8, 2);
5308             proto_tree_add_uint64(ext_tree_qos, hf_gtp_qos_ul_mbr, tvb, offset, 10, br);
5309             offset += 10;
5310             br = ((guint64)wrapped_tvb_get_guint8(tvb, offset  , 2) << 32) |
5311                  ((guint64)wrapped_tvb_get_guint8(tvb, offset+2, 2) << 24) |
5312                  ((guint64)wrapped_tvb_get_guint8(tvb, offset+4, 2) << 16) |
5313                  ((guint64)wrapped_tvb_get_guint8(tvb, offset+6, 2) <<  8) |
5314                   (guint64)wrapped_tvb_get_guint8(tvb, offset+8, 2);
5315             proto_tree_add_uint64(ext_tree_qos, hf_gtp_qos_dl_mbr, tvb, offset, 10, br);
5316             offset += 10;
5317             br = ((guint64)wrapped_tvb_get_guint8(tvb, offset  , 2) << 32) |
5318                  ((guint64)wrapped_tvb_get_guint8(tvb, offset+2, 2) << 24) |
5319                  ((guint64)wrapped_tvb_get_guint8(tvb, offset+4, 2) << 16) |
5320                  ((guint64)wrapped_tvb_get_guint8(tvb, offset+6, 2) <<  8) |
5321                   (guint64)wrapped_tvb_get_guint8(tvb, offset+8, 2);
5322             proto_tree_add_uint64(ext_tree_qos, hf_gtp_qos_ul_gbr, tvb, offset, 10, br);
5323             offset += 10;
5324             br = ((guint64)wrapped_tvb_get_guint8(tvb, offset  , 2) << 32) |
5325                  ((guint64)wrapped_tvb_get_guint8(tvb, offset+2, 2) << 24) |
5326                  ((guint64)wrapped_tvb_get_guint8(tvb, offset+4, 2) << 16) |
5327                  ((guint64)wrapped_tvb_get_guint8(tvb, offset+6, 2) <<  8) |
5328                   (guint64)wrapped_tvb_get_guint8(tvb, offset+8, 2);
5329             proto_tree_add_uint64(ext_tree_qos, hf_gtp_qos_dl_gbr, tvb, offset, 10, br);
5330         } else {
5331             /* non GBR QCI */
5332             apn_ambr = (wrapped_tvb_get_guint8(tvb, offset  , 2) << 24) |
5333                        (wrapped_tvb_get_guint8(tvb, offset+2, 2) << 16) |
5334                        (wrapped_tvb_get_guint8(tvb, offset+4, 2) <<  8) |
5335                         wrapped_tvb_get_guint8(tvb, offset+6, 2);
5336             proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_ul_apn_ambr, tvb, offset, 8, apn_ambr);
5337             offset += 8;
5338             apn_ambr = (wrapped_tvb_get_guint8(tvb, offset  , 2) << 24) |
5339                        (wrapped_tvb_get_guint8(tvb, offset+2, 2) << 16) |
5340                        (wrapped_tvb_get_guint8(tvb, offset+4, 2) <<  8) |
5341                         wrapped_tvb_get_guint8(tvb, offset+6, 2);
5342             proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_dl_apn_ambr, tvb, offset, 8, apn_ambr);
5343         }
5344         return retval;
5345     }
5346 
5347     /* In RADIUS messages there is no allocation-retention priority
5348      * so I don't need to wrap the following call to tvb_get_guint8
5349      * */
5350     al_ret_priority = tvb_get_guint8(tvb, offset);
5351 
5352     /* All calls are wrapped to take into account the possibility that the
5353      * input is UTF-8 encoded. If utf8_type is equal to 1, the final value
5354      * of the offset will be the same as in the previous version of this
5355      * dissector, and the wrapped function will serve as a dumb wrapper;
5356      * otherwise, if utf_8_type is 2, the offset is correctly shifted by
5357      * two bytes for needed shift, and the wrapped function will unencode
5358      * two values from the input.
5359      * */
5360     spare1      = wrapped_tvb_get_guint8(tvb, offset + (1 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_SPARE1_MASK;
5361     delay       = wrapped_tvb_get_guint8(tvb, offset + (1 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_DELAY_MASK;
5362     reliability = wrapped_tvb_get_guint8(tvb, offset + (1 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_RELIABILITY_MASK;
5363     peak        = wrapped_tvb_get_guint8(tvb, offset + (2 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_PEAK_MASK;
5364     spare2      = wrapped_tvb_get_guint8(tvb, offset + (2 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_SPARE2_MASK;
5365     precedence  = wrapped_tvb_get_guint8(tvb, offset + (2 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_PRECEDENCE_MASK;
5366     spare3      = wrapped_tvb_get_guint8(tvb, offset + (3 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_SPARE3_MASK;
5367     mean        = wrapped_tvb_get_guint8(tvb, offset + (3 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_MEAN_MASK;
5368 
5369     /* In RADIUS messages there is no allocation-retention priority */
5370     if (type != 3)
5371         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_al_ret_priority, tvb, offset, 1, al_ret_priority);
5372 
5373     /* All additions must take care of the fact that QoS fields in RADIUS
5374      * messages are UTF-8 encoded, so we have to use the same trick as above.
5375      * */
5376     proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_spare1,      tvb, offset + (1 - 1) * utf8_type + 1, utf8_type, spare1);
5377     proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_delay,       tvb, offset + (1 - 1) * utf8_type + 1, utf8_type, delay);
5378     proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_reliability, tvb, offset + (1 - 1) * utf8_type + 1, utf8_type, reliability);
5379     proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_peak,        tvb, offset + (2 - 1) * utf8_type + 1, utf8_type, peak);
5380     proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_spare2,      tvb, offset + (2 - 1) * utf8_type + 1, utf8_type, spare2);
5381     proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_precedence,  tvb, offset + (2 - 1) * utf8_type + 1, utf8_type, precedence);
5382     proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_spare3,      tvb, offset + (3 - 1) * utf8_type + 1, utf8_type, spare3);
5383     proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_mean,        tvb, offset + (3 - 1) * utf8_type + 1, utf8_type, mean);
5384 
5385     /* TS 24.008 V 7.8.0 10.5.6.5 Quality of service
5386      * The quality of service is a type 4 information element with a minimum length of 14 octets and a maximum length of 18
5387      * octets. The QoS requested by the MS shall be encoded both in the QoS attributes specified in octets 3-5 and in the QoS
5388      * attributes specified in octets 6-14.
5389      * In the MS to network direction and in the network to MS direction the following applies:
5390      * - Octets 15-18 are optional. If octet 15 is included, then octet 16 shall also be included, and octets 17 and 18 may
5391      * be included.
5392      * - If octet 17 is included, then octet 18 shall also be included.
5393      * - A QoS IE received without octets 6-18, without octets 14-18, without octets 15-18, or without octets 17-18 shall
5394      * be accepted by the receiving entity.
5395      */
5396 
5397     if (length > 4) {
5398 
5399         /* See above for the need of wrapping
5400          *
5401          */
5402         /* Octet 6 */
5403         traf_class      = wrapped_tvb_get_guint8(tvb, offset + (4 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_TRAF_CLASS_MASK;
5404         del_order       = wrapped_tvb_get_guint8(tvb, offset + (4 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_DEL_ORDER_MASK;
5405         del_err_sdu     = wrapped_tvb_get_guint8(tvb, offset + (4 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_DEL_ERR_SDU_MASK;
5406         max_sdu_size    = wrapped_tvb_get_guint8(tvb, offset + (5 - 1) * utf8_type + 1, utf8_type);
5407         max_ul          = wrapped_tvb_get_guint8(tvb, offset + (6 - 1) * utf8_type + 1, utf8_type);
5408         max_dl          = wrapped_tvb_get_guint8(tvb, offset + (7 - 1) * utf8_type + 1, utf8_type);
5409         res_ber         = wrapped_tvb_get_guint8(tvb, offset + (8 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_RES_BER_MASK;
5410         sdu_err_ratio   = wrapped_tvb_get_guint8(tvb, offset + (8 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_SDU_ERR_RATIO_MASK;
5411         trans_delay     = wrapped_tvb_get_guint8(tvb, offset + (9 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_TRANS_DELAY_MASK;
5412         traf_handl_prio = wrapped_tvb_get_guint8(tvb, offset + (9 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_TRAF_HANDL_PRIORITY_MASK;
5413         guar_ul         = wrapped_tvb_get_guint8(tvb, offset + (10 - 1) * utf8_type + 1, utf8_type);
5414         /* Octet 13 */
5415         guar_dl         = wrapped_tvb_get_guint8(tvb, offset + (11 - 1) * utf8_type + 1, utf8_type);
5416 
5417         spare4        = 0;
5418         sig_ind       = 0;
5419         src_stat_desc = 0;
5420         max_dl_ext    = 0;
5421         guar_dl_ext   = 0;
5422         max_ul_ext    = 0;
5423         guar_ul_ext   = 0;
5424 
5425         if (length > 13 ||((type == 2) && (length == 13))) {
5426             spare4        = wrapped_tvb_get_guint8(tvb, offset + (12 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_SPARE4_MASK;
5427             sig_ind       = wrapped_tvb_get_guint8(tvb, offset + (12 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_SIG_IND_MASK;
5428             src_stat_desc = wrapped_tvb_get_guint8(tvb, offset + (12 - 1) * utf8_type + 1, utf8_type) & GTP_EXT_QOS_SRC_STAT_DESC_MASK;
5429         }
5430         if (length > 14) {
5431             max_dl_ext  = wrapped_tvb_get_guint8(tvb, offset + (13 - 1) * utf8_type + 1, utf8_type);
5432             guar_dl_ext = wrapped_tvb_get_guint8(tvb, offset + (14 - 1) * utf8_type + 1, utf8_type);
5433         }
5434         if (length > 16) {
5435             max_ul_ext = wrapped_tvb_get_guint8(tvb, offset + (15 - 1) * utf8_type + 1, utf8_type);
5436             guar_ul_ext = wrapped_tvb_get_guint8(tvb, offset + (16 - 1) * utf8_type + 1, utf8_type);
5437         }
5438         if (length > 18) {
5439             max_dl_ext2 = wrapped_tvb_get_guint8(tvb, offset + (17 - 1) * utf8_type + 1, utf8_type);
5440             guar_dl_ext2 = wrapped_tvb_get_guint8(tvb, offset + (18 - 1) * utf8_type + 1, utf8_type);
5441         }
5442         if (length > 20) {
5443             max_ul_ext2 = wrapped_tvb_get_guint8(tvb, offset + (19 - 1) * utf8_type + 1, utf8_type);
5444             guar_ul_ext2 = wrapped_tvb_get_guint8(tvb, offset + (20 - 1) * utf8_type + 1, utf8_type);
5445         }
5446 
5447         /*
5448          * See above comments for the changes
5449          */
5450         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_traf_class,  tvb, offset + (4 - 1) * utf8_type + 1, utf8_type, traf_class);
5451         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_del_order,   tvb, offset + (4 - 1) * utf8_type + 1, utf8_type, del_order);
5452         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);
5453         if (max_sdu_size == 0 || max_sdu_size > 150)
5454             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);
5455         if ((max_sdu_size > 0) && (max_sdu_size <= 150)) {
5456             mss = max_sdu_size * 10;
5457             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,
5458                                        "%u octets", mss);
5459         }
5460 
5461         if (max_ul == 0 || max_ul == 255)
5462             proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset + (6 - 1) * utf8_type + 1, utf8_type, max_ul);
5463         if ((max_ul > 0) && (max_ul <= 63))
5464             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,
5465                                        "%u kbps", max_ul);
5466         if ((max_ul > 63) && (max_ul <= 127)) {
5467             mu = 64 + (max_ul - 64) * 8;
5468             proto_tree_add_uint_format_value(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset + (6 - 1) * utf8_type + 1, utf8_type, mu,
5469                                        "%u kbps", mu);
5470         }
5471 
5472         if ((max_ul > 127) && (max_ul <= 254)) {
5473             mu = 576 + (max_ul - 128) * 64;
5474             proto_tree_add_uint_format_value(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset + (6 - 1) * utf8_type + 1, utf8_type, mu,
5475                                        "%u kbps", mu);
5476         }
5477 
5478         if (max_dl == 0 || max_dl == 255)
5479             proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_max_dl, tvb, offset + (7 - 1) * utf8_type + 1, utf8_type, max_dl);
5480         if ((max_dl > 0) && (max_dl <= 63))
5481             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,
5482                                        "%u kbps", max_dl);
5483         if ((max_dl > 63) && (max_dl <= 127)) {
5484             md = 64 + (max_dl - 64) * 8;
5485             proto_tree_add_uint_format_value(ext_tree_qos, hf_gtp_qos_max_dl, tvb, offset + (7 - 1) * utf8_type + 1, utf8_type, md,
5486                                        "%u kbps", md);
5487         }
5488         if ((max_dl > 127) && (max_dl <= 254)) {
5489             md = 576 + (max_dl - 128) * 64;
5490             proto_tree_add_uint_format_value(ext_tree_qos, hf_gtp_qos_max_dl, tvb, offset + (7 - 1) * utf8_type + 1, utf8_type, md,
5491                                        "%u kbps", md);
5492         }
5493 
5494         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_res_ber,         tvb, offset + (8 - 1) * utf8_type + 1, utf8_type, res_ber);
5495         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);
5496         proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_trans_delay,     tvb, offset + (9 - 1) * utf8_type + 1, utf8_type, trans_delay);
5497         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);
5498 
5499         if (guar_ul == 0 || guar_ul == 255)
5500             proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset + (10 - 1) * utf8_type + 1, utf8_type, guar_ul);
5501         if ((guar_ul > 0) && (guar_ul <= 63))
5502             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,
5503                                        "%u kbps", guar_ul);
5504         if ((guar_ul > 63) && (guar_ul <= 127)) {
5505             gu = 64 + (guar_ul - 64) * 8;
5506             proto_tree_add_uint_format_value(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset + (10 - 1) * utf8_type + 1, utf8_type, gu,
5507                                        "%u kbps", gu);
5508         }
5509         if ((guar_ul > 127) && (guar_ul <= 254)) {
5510             gu = 576 + (guar_ul - 128) * 64;
5511             proto_tree_add_uint_format_value(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset + (10 - 1) * utf8_type + 1, utf8_type, gu,
5512                                        "%u kbps", gu);
5513         }
5514 
5515         /* Octet 13 */
5516         if (guar_dl == 0 || guar_dl == 255)
5517             proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_guar_dl, tvb, offset + (11 - 1) * utf8_type + 1, utf8_type, guar_dl);
5518         if ((guar_dl > 0) && (guar_dl <= 63))
5519             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,
5520                                        "%u kbps", guar_dl);
5521         if ((guar_dl > 63) && (guar_dl <= 127)) {
5522             gd = 64 + (guar_dl - 64) * 8;
5523             proto_tree_add_uint_format_value(ext_tree_qos, hf_gtp_qos_guar_dl, tvb, offset + (11 - 1) * utf8_type + 1, utf8_type, gd,
5524                                        "%u kbps", gd);
5525         }
5526         if ((guar_dl > 127) && (guar_dl <= 254)) {
5527             gd = 576 + (guar_dl - 128) * 64;
5528             proto_tree_add_uint_format_value(ext_tree_qos, hf_gtp_qos_guar_dl, tvb, offset + (11 - 1) * utf8_type + 1, utf8_type, gd,
5529                                        "%u kbps", gd);
5530         }
5531 
5532         if(length > 13 ||((type == 2) && (length == 13))) {
5533             proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_spare4, tvb, offset + (12 - 1) * utf8_type + 1, utf8_type, spare4);
5534             proto_tree_add_boolean(ext_tree_qos, hf_gtp_qos_sig_ind, tvb, offset + (12 - 1) * utf8_type + 1, utf8_type, sig_ind);
5535             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);
5536         }
5537 
5538 
5539         if(length > 14) {
5540             /* Octet 15 */
5541             if ((max_dl_ext > 0) && (max_dl_ext <= 0x4a)) {
5542                 md = 8600 + max_dl_ext * 100;
5543                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_dl, tvb, offset + (13 - 1) * utf8_type + 1, utf8_type, md,
5544                                            "Ext Maximum bit rate for downlink: %u kbps", md);
5545             }
5546             if ((max_dl_ext > 0x4a) && (max_dl_ext <= 0xba)) {
5547                 md = 16 + (max_dl_ext-0x4a);
5548                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_dl, tvb, offset + (13 - 1) * utf8_type + 1, utf8_type, md,
5549                                            "Ext Maximum bit rate for downlink: %u Mbps", md);
5550             }
5551             if ((max_dl_ext > 0xba) && (max_dl_ext <= 0xfa)) {
5552                 md = 128 + (max_dl_ext-0xba)*2;
5553                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_dl, tvb, offset + (13 - 1) * utf8_type + 1, utf8_type, md,
5554                                            "Ext Maximum bit rate for downlink: %u Mbps", md);
5555             }
5556             /* Octet 16 */
5557             if(guar_dl_ext == 0)
5558                 proto_tree_add_expert_format(ext_tree_qos, pinfo, &ei_gtp_guaranteed_bit_rate_value, tvb, offset + (14 - 1) * utf8_type + 1, utf8_type,
5559                                            "Use the value indicated by the Guaranteed bit rate for downlink in octet 13");
5560             if ((guar_dl_ext > 0) && (guar_dl_ext <= 0x4a)) {
5561                 gd = 8600 + guar_dl_ext * 100;
5562                 proto_tree_add_uint_format_value(ext_tree_qos, hf_gtp_qos_guar_dl, tvb, offset + (14 - 1) * utf8_type + 1, utf8_type, gd,
5563                                            "%u kbps", gd);
5564             }
5565             if ((guar_dl_ext > 0x4a) && (max_dl_ext <= 0xba)) {
5566                 gd = 16 + (guar_dl_ext-0x4a);
5567                 proto_tree_add_uint_format_value(ext_tree_qos, hf_gtp_qos_guar_dl, tvb, offset + (14 - 1) * utf8_type + 1, utf8_type, gd,
5568                                            "%u Mbps", gd);
5569             }
5570             if ((guar_dl_ext > 0xba) && (max_dl_ext <= 0xfa)) {
5571                 gd = 128 + (guar_dl_ext-0xba)*2;
5572                 proto_tree_add_uint_format_value(ext_tree_qos, hf_gtp_qos_guar_dl, tvb, offset + (14 - 1) * utf8_type + 1, utf8_type, gd,
5573                                            "%u Mbps", gd);
5574             }
5575 
5576         }
5577         if(length > 16) {
5578             /* Octet 17
5579              * 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
5580              * rate for downlink (extended).
5581              */
5582             if ((max_ul_ext > 0) && (max_ul_ext <= 0x4a)) {
5583                 md = 8600 + max_ul_ext * 100;
5584                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset + (15 - 1) * utf8_type + 1, utf8_type, md,
5585                                            "Ext Maximum bit rate for uplink: %u kbps", md);
5586             }
5587             if ((max_ul_ext > 0x4a) && (max_ul_ext <= 0xba)) {
5588                 md = 16 + (max_ul_ext-0x4a);
5589                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset + (15 - 1) * utf8_type + 1, utf8_type, md,
5590                                            "Ext Maximum bit rate for uplink: %u Mbps", md);
5591             }
5592             if ((max_ul_ext > 0xba) && (max_ul_ext <= 0xfa)) {
5593                 md = 128 + (max_ul_ext-0xba)*2;
5594                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset + (15 - 1) * utf8_type + 1, utf8_type, md,
5595                                            "Ext Maximum bit rate for uplink: %u Mbps", md);
5596             }
5597             /* Octet 18 */
5598             if (guar_ul_ext == 0)
5599                 proto_tree_add_expert_format(ext_tree_qos, pinfo, &ei_gtp_guaranteed_bit_rate_value, tvb, offset + (16 - 1) * utf8_type + 1, utf8_type,
5600                                            "Use the value indicated by the Guaranteed bit rate for uplink in octet 12");
5601             if ((guar_ul_ext > 0) && (guar_ul_ext <= 0x4a)) {
5602                 gd = 8600 + guar_ul_ext * 100;
5603                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset + (16 - 1) * utf8_type + 1, utf8_type, gd,
5604                                            "Ext Guaranteed bit rate for uplink: %u kbps", gd);
5605             }
5606             if ((guar_ul_ext > 0x4a) && (guar_ul_ext <= 0xba)) {
5607                 gd = 16 + (guar_ul_ext-0x4a);
5608                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset + (16 - 1) * utf8_type + 1, utf8_type, gd,
5609                                            "Ext Guaranteed bit rate for uplink: %u Mbps", gd);
5610             }
5611             if ((guar_ul_ext > 0xba) && (guar_ul_ext <= 0xfa)) {
5612                 gd = 128 + (guar_ul_ext-0xba)*2;
5613                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset + (16 - 1) * utf8_type + 1, utf8_type, gd,
5614                                            "Ext Guaranteed bit rate for uplink: %u Mbps", gd);
5615             }
5616         }
5617 
5618         if(length > 18) {
5619             /* Octet 19 Maximum bit rate for downlink (extended-2)
5620              * 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
5621              * rate for downlink (extended).
5622              */
5623             if (guar_dl_ext2 == 0)
5624                 proto_tree_add_expert_format(ext_tree_qos, pinfo, &ei_gtp_max_bit_rate_value, tvb, offset + (17 - 1) * utf8_type + 1, utf8_type,
5625                                            "Use the value indicated by the Maximum bit rate for downlink in octet 9 and octet 15.");
5626 
5627             if ((max_dl_ext2 > 0) && (max_dl_ext2 <= 0x3d)) {
5628                 md = 256 + max_dl_ext2 * 4;
5629                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset + (15 - 1) * utf8_type + 1, utf8_type, md,
5630                                            "Ext Maximum bit rate for downlink: %u Mbps", md);
5631             }
5632             if ((max_dl_ext2 > 0x3d) && (max_dl_ext2 <= 0xa1)) {
5633                 md = 500 + (max_dl_ext2-0x3d) * 10;
5634                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset + (15 - 1) * utf8_type + 1, utf8_type, md,
5635                                            "Ext Maximum bit rate for downlink: %u Mbps", md);
5636             }
5637             if ((max_dl_ext2 > 0xa1) && (max_dl_ext2 <= 0xf6)) {
5638                 md = 1500 + (max_dl_ext2-0xa1)*10;
5639                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset + (15 - 1) * utf8_type + 1, utf8_type, md,
5640                                            "Ext Maximum bit rate for downlink: %u Mbps", md);
5641             }
5642             /* Octet 20 Guaranteed bit rate for downlink (extended-2) */
5643             if (max_dl_ext2 == 0)
5644                 proto_tree_add_expert_format(ext_tree_qos, pinfo, &ei_gtp_max_bit_rate_value, tvb, offset + (16 - 1) * utf8_type + 1, utf8_type,
5645                                            "Use the value indicated by the Maximum bit rate for downlink in octet 13 and octet 16.");
5646             if ((max_dl_ext2 > 0) && (max_dl_ext2 <= 0x3d)) {
5647                 gd = 256 + max_dl_ext2 * 4;
5648                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset + (16 - 1) * utf8_type + 1, utf8_type, gd,
5649                                            "Ext Guaranteed bit rate for downlink: %u Mbps", gd);
5650             }
5651             if ((max_dl_ext2 > 0x3d) && (max_dl_ext2 <= 0xa1)) {
5652                 gd = 500 + (max_dl_ext2-0x3d) * 10;
5653                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset + (16 - 1) * utf8_type + 1, utf8_type, gd,
5654                                            "Ext Guaranteed bit rate for downlink: %u Mbps", gd);
5655             }
5656             if ((max_dl_ext2 > 0xba) && (max_dl_ext2 <= 0xfa)) {
5657                 gd = 1500 + (max_dl_ext2-0xa1) * 10;
5658                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset + (16 - 1) * utf8_type + 1, utf8_type, gd,
5659                                            "Ext Guaranteed bit rate for uplink: %u Mbps", gd);
5660             }
5661         }
5662 
5663         if(length > 20) {
5664             /* Maximum bit rate for uplink (extended-2), octet 21
5665              * 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
5666              * rate for downlink (extended).
5667              */
5668             if (guar_ul_ext2 == 0)
5669                 proto_tree_add_expert_format(ext_tree_qos, pinfo, &ei_gtp_max_bit_rate_value, tvb, offset + (17 - 1) * utf8_type + 1, utf8_type,
5670                                            "Use the value indicated by the Maximum bit rate for uplink in octet 9 and octet 15.");
5671 
5672             if ((max_ul_ext2 > 0) && (max_ul_ext2 <= 0x3d)) {
5673                 md = 256 + max_ul_ext2 * 4;
5674                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset + (15 - 1) * utf8_type + 1, utf8_type, md,
5675                                            "Ext Maximum bit rate for uplink: %u Mbps", md);
5676             }
5677             if ((max_ul_ext2 > 0x3d) && (max_ul_ext2 <= 0xa1)) {
5678                 md = 500 + (max_ul_ext2-0x3d) * 10;
5679                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset + (15 - 1) * utf8_type + 1, utf8_type, md,
5680                                            "Ext Maximum bit rate for uplink: %u Mbps", md);
5681             }
5682             if ((max_ul_ext2 > 0xa1) && (max_ul_ext2 <= 0xf6)) {
5683                 md = 1500 + (max_ul_ext2-0xa1)*10;
5684                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset + (15 - 1) * utf8_type + 1, utf8_type, md,
5685                                            "Ext Maximum bit rate for uplink: %u Mbps", md);
5686             }
5687             /* Guaranteed bit rate for uplink (extended-2), octet 22 */
5688             if (max_ul_ext2 == 0)
5689                 proto_tree_add_expert_format(ext_tree_qos, pinfo, &ei_gtp_max_bit_rate_value, tvb, offset + (16 - 1) * utf8_type + 1, utf8_type,
5690                                            "Use the value indicated by the Maximum bit rate for uplink in octet 13 and octet 16.");
5691             if ((max_ul_ext2 > 0) && (max_ul_ext2 <= 0x3d)) {
5692                 gd = 256 + max_ul_ext2 * 4;
5693                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset + (16 - 1) * utf8_type + 1, utf8_type, gd,
5694                                            "Ext Guaranteed bit rate for uplink: %u Mbps", gd);
5695             }
5696             if ((max_ul_ext2 > 0x3d) && (max_ul_ext2 <= 0xa1)) {
5697                 gd = 500 + (max_ul_ext2-0x3d) * 10;
5698                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset + (16 - 1) * utf8_type + 1, utf8_type, gd,
5699                                            "Ext Guaranteed bit rate for uplink: %u Mbps", gd);
5700             }
5701             if ((max_ul_ext2 > 0xba) && (max_ul_ext2 <= 0xfa)) {
5702                 gd = 1500 + (max_ul_ext2-0xa1) * 10;
5703                 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset + (16 - 1) * utf8_type + 1, utf8_type, gd,
5704                                            "Ext Guaranteed bit rate for uplink: %u Mbps", gd);
5705             }
5706         }
5707     }
5708 
5709     return retval;
5710 }
5711 
5712 /* Diameter 3GPP AVP Code: 5 3GPP-GPRS Negotiated QoS profile */
5713 static int
dissect_diameter_3gpp_qosprofile(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,void * data _U_)5714 dissect_diameter_3gpp_qosprofile(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) {
5715 
5716     decode_qos_umts(tvb, 0, pinfo, tree, "UMTS GTP QoS Profile", 3);
5717     return tvb_reported_length(tvb);
5718 }
5719 
5720 static const gchar *
dissect_radius_qos_umts(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo)5721 dissect_radius_qos_umts(proto_tree * tree, tvbuff_t * tvb, packet_info* pinfo)
5722 {
5723     decode_qos_umts(tvb, 0, pinfo, tree, "UMTS GTP QoS Profile", 3);
5724     return tvb_get_string_enc(wmem_packet_scope(), tvb, 0, tvb_reported_length(tvb), ENC_UTF_8|ENC_NA);
5725 }
5726 
5727 #define MAX_APN_LENGTH          100
5728 
5729 static void
decode_apn(tvbuff_t * tvb,int offset,guint16 length,proto_tree * tree,proto_item * item)5730 decode_apn(tvbuff_t * tvb, int offset, guint16 length, proto_tree * tree, proto_item *item)
5731 {
5732     guint8   str[MAX_APN_LENGTH+1];
5733     guint    curr_len;
5734 
5735     /*
5736      * This is "a domain name represented as a sequence of labels, where
5737      * each label consists of a length octet followed by that number of
5738      * octets.", DNS-style.
5739      *
5740      * XXX - does it involve compression?
5741      */
5742 
5743     /* init buffer and copy it */
5744     memset(str, 0, MAX_APN_LENGTH+1);
5745     tvb_memcpy(tvb, str, offset, length<MAX_APN_LENGTH?length:MAX_APN_LENGTH);
5746 
5747     curr_len = 0;
5748     while ((curr_len < length) && (curr_len < MAX_APN_LENGTH))
5749     {
5750         guint step    = str[curr_len];
5751         str[curr_len] = '.';
5752         curr_len     += step+1;
5753     }
5754 
5755     /* Highlight bytes including the first length byte */
5756     proto_tree_add_string(tree, hf_gtp_apn, tvb, offset, length, str+1);
5757     if(item){
5758         proto_item_append_text(item, ": %s", str+1);
5759     }
5760 
5761 }
5762 
5763 static void
decode_fqdn(tvbuff_t * tvb,int offset,guint16 length,proto_tree * tree,session_args_t * args _U_)5764 decode_fqdn(tvbuff_t * tvb, int offset, guint16 length, proto_tree * tree, session_args_t * args _U_)
5765 {
5766     guint8 *fqdn = NULL;
5767     int     name_len, tmp;
5768 
5769     if (length > 0) {
5770         name_len = tvb_get_guint8(tvb, offset);
5771 
5772         if (name_len < 0x20) {
5773             fqdn = tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, length - 1, ENC_ASCII);
5774             for (;;) {
5775                 if (name_len >= length - 1)
5776                     break;
5777                 tmp = name_len;
5778                 name_len = name_len + fqdn[tmp] + 1;
5779                 fqdn[tmp] = '.';
5780             }
5781         } else
5782             fqdn = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_ASCII);
5783 
5784         proto_tree_add_string(tree, hf_gtp_fqdn, tvb, offset, length, fqdn);
5785     }
5786 }
5787 
5788 /*
5789  * GPRS:        9.60 v7.6.0, chapter 7.9.20
5790  * UMTS:        29.060 v4.0, chapter 7.7.29 PDP Context
5791  * TODO:        unify addr functions
5792  */
5793 static int
decode_gtp_pdp_cntxt(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)5794 decode_gtp_pdp_cntxt(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
5795 {
5796 
5797     guint8             ggsn_addr_len, apn_len, trans_id, ea;
5798     guint8             pdp_type_num, pdp_addr_len;
5799     guint16            length;
5800     proto_tree        *ext_tree_pdp;
5801 
5802     length = tvb_get_ntohs(tvb, offset + 1);
5803 
5804     ext_tree_pdp = proto_tree_add_subtree(tree, tvb, offset, length + 3, ett_gtp_ies[GTP_EXT_PDP_CNTXT], NULL,
5805                     val_to_str_ext_const(GTP_EXT_PDP_CNTXT, &gtp_val_ext, "Unknown message"));
5806 
5807     ea = (tvb_get_guint8(tvb, offset + 3) >> 7) & 0x01;
5808 
5809     proto_tree_add_item(ext_tree_pdp, hf_gtp_extended_end_user_address, tvb, offset + 3, 1, ENC_NA);
5810     proto_tree_add_item(ext_tree_pdp, hf_gtp_vplmn_address_allowed, tvb, offset + 3, 1, ENC_NA);
5811     proto_tree_add_item(ext_tree_pdp, hf_gtp_activity_status_indicator, tvb, offset + 3, 1, ENC_NA);
5812     proto_tree_add_item(ext_tree_pdp, hf_gtp_reordering_required, tvb, offset + 3, 1, ENC_NA);
5813     proto_tree_add_item(ext_tree_pdp, hf_gtp_nsapi, tvb, offset + 3, 1, ENC_BIG_ENDIAN);
5814     proto_tree_add_item(ext_tree_pdp, hf_gtp_pdp_cntxt_sapi, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
5815 
5816     switch (gtp_version) {
5817     case 0:
5818         decode_qos_gprs(tvb, offset + 5, ext_tree_pdp, "QoS subscribed", 0);
5819         decode_qos_gprs(tvb, offset + 8, ext_tree_pdp, "QoS requested", 0);
5820         decode_qos_gprs(tvb, offset + 11, ext_tree_pdp, "QoS negotiated", 0);
5821         offset = offset + 14;
5822         break;
5823     case 1:
5824         offset = offset + 5;
5825         offset = offset + decode_qos_umts(tvb, offset, pinfo, ext_tree_pdp, "QoS subscribed", 1);
5826         offset = offset + decode_qos_umts(tvb, offset, pinfo, ext_tree_pdp, "QoS requested", 1);
5827         offset = offset + decode_qos_umts(tvb, offset, pinfo, ext_tree_pdp, "QoS negotiated", 1);
5828         break;
5829     default:
5830         break;
5831     }
5832 
5833     proto_tree_add_item(ext_tree_pdp, hf_gtp_sequence_number_down, tvb, offset, 2, ENC_BIG_ENDIAN);
5834     proto_tree_add_item(ext_tree_pdp, hf_gtp_sequence_number_up, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
5835     proto_tree_add_item(ext_tree_pdp, hf_gtp_send_n_pdu_number, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
5836     proto_tree_add_item(ext_tree_pdp, hf_gtp_receive_n_pdu_number, tvb, offset + 5, 1, ENC_BIG_ENDIAN);
5837 
5838     switch (gtp_version) {
5839     case 0:
5840         proto_tree_add_item(ext_tree_pdp, hf_gtp_uplink_flow_label_signalling, tvb, offset + 6, 2, ENC_BIG_ENDIAN);
5841         offset = offset + 8;
5842         break;
5843     case 1:
5844         proto_tree_add_item(ext_tree_pdp, hf_gtp_uplink_teid_cp,   tvb, offset + 6, 4, ENC_BIG_ENDIAN);
5845         proto_tree_add_item(ext_tree_pdp, hf_gtp_uplink_teid_data, tvb, offset + 10, 4, ENC_BIG_ENDIAN);
5846         proto_tree_add_item(ext_tree_pdp, hf_gtp_pdp_context_identifier, tvb, offset + 14, 1, ENC_BIG_ENDIAN);
5847         offset = offset + 15;
5848         break;
5849     default:
5850         break;
5851     }
5852 
5853     pdp_type_num = tvb_get_guint8(tvb, offset + 1);
5854     pdp_addr_len = tvb_get_guint8(tvb, offset + 2);
5855 
5856     proto_tree_add_item(ext_tree_pdp, hf_gtp_pdp_organization, tvb, offset, 1, ENC_BIG_ENDIAN);
5857     proto_tree_add_item(ext_tree_pdp, hf_gtp_pdp_type, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
5858     proto_tree_add_item(ext_tree_pdp, hf_gtp_pdp_address_length, tvb, offset + 2, 1, ENC_BIG_ENDIAN);
5859 
5860     if (pdp_addr_len > 0) {
5861         switch (pdp_type_num) {
5862         case 0x21:
5863             proto_tree_add_item(ext_tree_pdp, hf_gtp_pdp_address_ipv4, tvb, offset + 3, 4, ENC_BIG_ENDIAN);
5864             break;
5865         case 0x57:
5866             proto_tree_add_item(ext_tree_pdp, hf_gtp_pdp_address_ipv6, tvb, offset + 3, 16, ENC_NA);
5867             break;
5868         default:
5869             break;
5870         }
5871     }
5872 
5873     offset = offset + 3 + pdp_addr_len;
5874 
5875     ggsn_addr_len = tvb_get_guint8(tvb, offset);
5876     proto_tree_add_item(ext_tree_pdp, hf_gtp_ggsn_address_length, tvb, offset, 1, ENC_BIG_ENDIAN);
5877 
5878     switch (ggsn_addr_len) {
5879     case 4:
5880         proto_tree_add_item(ext_tree_pdp, hf_gtp_ggsn_address_for_control_plane_ipv4, tvb, offset + 1, 4, ENC_BIG_ENDIAN);
5881         break;
5882     case 16:
5883         proto_tree_add_item(ext_tree_pdp, hf_gtp_ggsn_address_for_control_plane_ipv6, tvb, offset + 1, 16, ENC_NA);
5884         break;
5885     default:
5886         break;
5887     }
5888 
5889     offset = offset + 1 + ggsn_addr_len;
5890 
5891     if (gtp_version == 1) {
5892 
5893         ggsn_addr_len = tvb_get_guint8(tvb, offset);
5894         proto_tree_add_item(ext_tree_pdp, hf_gtp_ggsn_address_length, tvb, offset, 1, ENC_BIG_ENDIAN);
5895 
5896         switch (ggsn_addr_len) {
5897         case 4:
5898             proto_tree_add_item(ext_tree_pdp, hf_gtp_ggsn_address_for_user_traffic_ipv4, tvb, offset + 1, 4, ENC_BIG_ENDIAN);
5899             break;
5900         case 16:
5901             proto_tree_add_item(ext_tree_pdp, hf_gtp_ggsn_address_for_user_traffic_ipv6, tvb, offset + 1, 16, ENC_NA);
5902             break;
5903         default:
5904             break;
5905         }
5906         offset = offset + 1 + ggsn_addr_len;
5907 
5908     }
5909 
5910     apn_len = tvb_get_guint8(tvb, offset);
5911     proto_tree_add_item(ext_tree_pdp, hf_gtp_apn_length, tvb, offset, 1, ENC_BIG_ENDIAN);
5912     decode_apn(tvb, offset + 1, apn_len, ext_tree_pdp, NULL);
5913 
5914     offset = offset + 1 + apn_len;
5915     /*
5916      * The Transaction Identifier is the 4 or 12 bit Transaction Identifier used in the 3GPP TS 24.008 [5] Session Management
5917      * messages which control this PDP Context. If the length of the Transaction Identifier is 4 bit, the second octet shall be
5918      * set to all zeros. The encoding is defined in 3GPP TS 24.007 [3]. The latest Transaction Identifier sent from SGSN to
5919      * MS is stored in the PDP context IE.
5920      * 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
5921      * octet in this field.
5922      */
5923     trans_id = tvb_get_guint8(tvb, offset);
5924     proto_tree_add_uint(ext_tree_pdp, hf_gtp_transaction_identifier, tvb, offset, 2, trans_id);
5925     offset += 2;
5926 
5927     if (ea) {
5928         pdp_type_num = tvb_get_guint8(tvb, offset);
5929         pdp_addr_len = tvb_get_guint8(tvb, offset + 1);
5930 
5931         proto_tree_add_item(ext_tree_pdp, hf_gtp_pdp_type, tvb, offset, 1, ENC_BIG_ENDIAN);
5932         proto_tree_add_item(ext_tree_pdp, hf_gtp_pdp_address_length, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
5933 
5934         if (pdp_addr_len > 0) {
5935             switch (pdp_type_num) {
5936             case 0x21:
5937                 proto_tree_add_item(ext_tree_pdp, hf_gtp_pdp_address_ipv4, tvb, offset + 2, 4, ENC_NA);
5938                 break;
5939             case 0x57:
5940                 proto_tree_add_item(ext_tree_pdp, hf_gtp_pdp_address_ipv6, tvb, offset + 2, 16, ENC_NA);
5941                 break;
5942             default:
5943                 break;
5944             }
5945         }
5946     }
5947 
5948     return 3 + length;
5949 }
5950 
5951 /* GPRS:        9.60, v7.6.0, chapter 7.9.21
5952  * UMTS:        29.060, v4.0, chapter 7.7.30
5953  */
5954 static int
decode_gtp_apn(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)5955 decode_gtp_apn(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
5956 {
5957 
5958     guint16     length;
5959     proto_tree *ext_tree_apn;
5960     proto_item *te;
5961 
5962     length = tvb_get_ntohs(tvb, offset + 1);
5963 
5964     ext_tree_apn = proto_tree_add_subtree(tree, tvb, offset, length + 3, ett_gtp_ies[GTP_EXT_APN], &te,
5965                                 val_to_str_ext_const(GTP_EXT_APN, &gtp_val_ext, "Unknown field"));
5966 
5967     proto_tree_add_item(ext_tree_apn, hf_gtp_apn_length, tvb, offset + 1, 2, ENC_BIG_ENDIAN);
5968     decode_apn(tvb, offset + 3, length, ext_tree_apn, te);
5969 
5970     return 3 + length;
5971 }
5972 
5973 /* GPRS:        9.60 v7.6.0, chapter 7.9.22
5974  *              4.08 v. 7.1.2, chapter 10.5.6.3 (p.580)
5975  * UMTS:        29.060 v4.0, chapter 7.7.31 Protocol Configuration Options
5976  *              24.008, v4.2, chapter 10.5.6.3
5977  */
5978 int
decode_gtp_proto_conf(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args _U_)5979 decode_gtp_proto_conf(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
5980 {
5981 
5982     guint16     length;
5983     tvbuff_t   *next_tvb;
5984     proto_tree *ext_tree_proto;
5985 
5986     length = tvb_get_ntohs(tvb, offset + 1);
5987 
5988     ext_tree_proto = proto_tree_add_subtree(tree, tvb, offset, length + 3,
5989                 ett_gtp_proto, NULL, val_to_str_ext_const(GTP_EXT_PROTO_CONF, &gtp_val_ext, "Unknown message"));
5990 
5991     proto_tree_add_uint(ext_tree_proto, hf_gtp_length, tvb, offset + 1, 2, length);
5992 
5993     if (length < 1)
5994         return 3;
5995 
5996     /* The Protocol Configuration Options contains external network protocol options that may be necessary to transfer
5997      * between the GGSN and the MS. The content and the coding of the Protocol Configuration are defined in octet 3-z of the
5998      * Protocol Configuration Options in3GPP TS 24.008 [5].
5999      */
6000     next_tvb = tvb_new_subset_length(tvb, offset + 3, length);
6001     de_sm_pco(next_tvb, ext_tree_proto, pinfo, 0, length, NULL, 0);
6002 
6003     return 3 + length;
6004 }
6005 
6006 /* GPRS:        9.60 v7.6.0, chapter 7.9.23
6007  * UMTS:        29.060 v4.0, chapter 7.7.32
6008  */
6009 static int
decode_gtp_gsn_addr_common(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args,const char * tree_name,int hf_ipv4,int hf_ipv6)6010 decode_gtp_gsn_addr_common(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args, const char * tree_name, int hf_ipv4, int hf_ipv6)
6011 {
6012 
6013     guint8             addr_type, addr_len;
6014     guint16            length;
6015     proto_tree        *ext_tree_gsn_addr;
6016     proto_item        *te;
6017     address           *gsn_address;
6018 
6019     length = tvb_get_ntohs(tvb, offset + 1);
6020 
6021     ext_tree_gsn_addr = proto_tree_add_subtree_format(tree, tvb, offset, 3 + length, ett_gtp_gsn_addr, &te, "%s : ", tree_name);
6022     gsn_address = wmem_new0(wmem_packet_scope(), address);
6023     switch (length) {
6024     case 4:
6025         proto_tree_add_item(ext_tree_gsn_addr, hf_gtp_gsn_address_length, tvb, offset + 1, 2, ENC_BIG_ENDIAN);
6026         proto_tree_add_item(ext_tree_gsn_addr, hf_ipv4, tvb, offset + 3, 4, ENC_BIG_ENDIAN);
6027         if (hf_ipv4 != hf_gtp_gsn_ipv4)
6028             proto_item_set_hidden(proto_tree_add_item(ext_tree_gsn_addr, hf_gtp_gsn_ipv4, tvb, offset + 3, 4, ENC_BIG_ENDIAN));
6029         proto_item_append_text(te, "%s", tvb_ip_to_str(pinfo->pool, tvb, offset + 3));
6030         set_address_tvb(gsn_address, AT_IPv4, 4, tvb, offset + 3);
6031         break;
6032     case 5:
6033         proto_tree_add_item(ext_tree_gsn_addr, hf_gtp_gsn_address_information_element_length, tvb, offset + 1, 2, ENC_BIG_ENDIAN);
6034         addr_type = tvb_get_guint8(tvb, offset + 3) & 0xC0;
6035         proto_tree_add_uint(ext_tree_gsn_addr, hf_gtp_gsn_addr_type, tvb, offset + 3, 1, addr_type);
6036         addr_len = tvb_get_guint8(tvb, offset + 3) & 0x3F;
6037         proto_tree_add_uint(ext_tree_gsn_addr, hf_gtp_gsn_addr_len, tvb, offset + 3, 1, addr_len);
6038         proto_tree_add_item(ext_tree_gsn_addr, hf_ipv4, tvb, offset + 4, 4, ENC_BIG_ENDIAN);
6039         if (hf_ipv4 != hf_gtp_gsn_ipv4)
6040             proto_item_set_hidden(proto_tree_add_item(ext_tree_gsn_addr, hf_gtp_gsn_ipv4, tvb, offset + 4, 4, ENC_BIG_ENDIAN));
6041         proto_item_append_text(te, "%s", tvb_ip_to_str(pinfo->pool, tvb, offset + 4));
6042         set_address_tvb(gsn_address, AT_IPv6, 16, tvb, offset + 4);
6043         break;
6044     case 16:
6045         proto_tree_add_item(ext_tree_gsn_addr, hf_gtp_gsn_address_length, tvb, offset + 1, 2, ENC_BIG_ENDIAN);
6046         proto_tree_add_item(ext_tree_gsn_addr, hf_ipv6, tvb, offset + 3, 16, ENC_NA);
6047         if (hf_ipv6 != hf_gtp_gsn_ipv6)
6048             proto_item_set_hidden(proto_tree_add_item(ext_tree_gsn_addr, hf_gtp_gsn_ipv6, tvb, offset + 3, 16, ENC_NA));
6049         proto_item_append_text(te, "%s", tvb_ip6_to_str(pinfo->pool, tvb, offset + 3));
6050         set_address_tvb(gsn_address, AT_IPv4, 4, tvb, offset + 3);
6051         break;
6052     case 17:
6053         proto_tree_add_item(ext_tree_gsn_addr, hf_gtp_gsn_address_information_element_length, tvb, offset + 1, 2, ENC_BIG_ENDIAN);
6054         addr_type = tvb_get_guint8(tvb, offset + 3) & 0xC0;
6055         proto_tree_add_uint(ext_tree_gsn_addr, hf_gtp_gsn_addr_type, tvb, offset + 3, 1, addr_type);
6056         addr_len = tvb_get_guint8(tvb, offset + 3) & 0x3F;
6057         proto_tree_add_uint(ext_tree_gsn_addr, hf_gtp_gsn_addr_len, tvb, offset + 3, 1, addr_len);
6058         proto_item_append_text(te, "%s", tvb_ip6_to_str(pinfo->pool, tvb, offset + 4));
6059         proto_tree_add_item(ext_tree_gsn_addr, hf_ipv6, tvb, offset + 4, 16, ENC_NA);
6060         if (hf_ipv6 != hf_gtp_gsn_ipv6)
6061             proto_item_set_hidden(proto_tree_add_item(ext_tree_gsn_addr, hf_gtp_gsn_ipv6, tvb, offset + 4, 16, ENC_NA));
6062         set_address_tvb(gsn_address, AT_IPv6, 16, tvb, offset + 4);
6063         break;
6064     default:
6065         proto_item_append_text(te, "unknown type or wrong length");
6066         break;
6067     }
6068 
6069     if (g_gtp_session && gtp_version == 1 && !PINFO_FD_VISITED(pinfo)) {
6070         if (!ip_exists(*gsn_address, args->ip_list)) {
6071             copy_address_wmem(wmem_packet_scope(), &args->last_ip, gsn_address);
6072             wmem_list_prepend(args->ip_list, gsn_address);
6073         }
6074     }
6075     return 3 + length;
6076 }
6077 
6078 static int
decode_gtp_gsn_addr(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args)6079 decode_gtp_gsn_addr(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args) {
6080     return decode_gtp_gsn_addr_common(tvb, offset, pinfo, tree, args, "GSN address", hf_gtp_gsn_ipv4, hf_gtp_gsn_ipv6);
6081 }
6082 
6083 static int
decode_gtp_sgsn_addr_for_control_plane(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args)6084 decode_gtp_sgsn_addr_for_control_plane(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args)
6085 {
6086     return decode_gtp_gsn_addr_common(tvb, offset, pinfo, tree, args,
6087         "SGSN Address for control plane", hf_gtp_sgsn_address_for_control_plane_ipv4, hf_gtp_sgsn_address_for_control_plane_ipv6);
6088 }
6089 
6090 static int
decode_gtp_sgsn_addr_for_user_plane(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args)6091 decode_gtp_sgsn_addr_for_user_plane(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args)
6092 {
6093     return decode_gtp_gsn_addr_common(tvb, offset, pinfo, tree, args,
6094         "SGSN Address for user traffic", hf_gtp_sgsn_address_for_user_traffic_ipv4, hf_gtp_sgsn_address_for_user_traffic_ipv6);
6095 }
6096 
6097 static int
decode_gtp_ggsn_addr_for_control_plane(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args)6098 decode_gtp_ggsn_addr_for_control_plane(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args)
6099 {
6100     return decode_gtp_gsn_addr_common(tvb, offset, pinfo, tree, args,
6101         "GGSN Address for control plane", hf_gtp_sgsn_address_for_control_plane_ipv4, hf_gtp_sgsn_address_for_control_plane_ipv6);
6102 }
6103 
6104 static int
decode_gtp_ggsn_addr_for_user_plane(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args)6105 decode_gtp_ggsn_addr_for_user_plane(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args)
6106 {
6107     return decode_gtp_gsn_addr_common(tvb, offset, pinfo, tree, args,
6108         "GGSN Address for user traffic", hf_gtp_ggsn_address_for_user_traffic_ipv4, hf_gtp_ggsn_address_for_user_traffic_ipv6);
6109 }
6110 
6111 /* GPRS:        9.60 v7.6.0, chapter 7.9.24
6112  * UMTS:        29.060 v4.0, chapter 7.7.33
6113  */
6114 static int
decode_gtp_msisdn(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args _U_)6115 decode_gtp_msisdn(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
6116 {
6117     guint16     length;
6118     tvbuff_t   *next_tvb;
6119     proto_tree *ext_tree_proto;
6120 
6121     length = tvb_get_ntohs(tvb, offset + 1);
6122 
6123     ext_tree_proto = proto_tree_add_subtree(tree, tvb, offset, length + 3, ett_gtp_proto, NULL,
6124                             val_to_str_ext_const(GTP_EXT_MSISDN, &gtp_val_ext, "Unknown message"));
6125 
6126     proto_tree_add_uint(ext_tree_proto, hf_gtp_length, tvb, offset + 1, 2, length);
6127 
6128     length = tvb_get_ntohs(tvb, offset + 1);
6129 
6130     if (length < 1)
6131         return 3;
6132 
6133     next_tvb = tvb_new_subset_length(tvb, offset+3, length);
6134     dissect_gsm_map_msisdn(next_tvb, pinfo, ext_tree_proto);
6135 
6136     return 3 + length;
6137 }
6138 
6139 /* GPRS:        not present
6140  * UMTS:        29.060 v4.0, chapter 7.7.34
6141  *              24.008 v4.2, chapter 10.5.6.5
6142  */
6143 static int
decode_gtp_qos_umts(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args _U_)6144 decode_gtp_qos_umts(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
6145 {
6146 
6147     return decode_qos_umts(tvb, offset, pinfo, tree, "Quality of Service", 2);
6148 }
6149 
6150 /* GPRS:        not present
6151  * UMTS:        29.060 v4.0, chapter 7.7.35
6152  */
6153 static int
decode_gtp_auth_qui(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)6154 decode_gtp_auth_qui(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6155 {
6156 
6157     proto_tree *ext_tree;
6158     guint16     length;
6159     guint8      xres_len, auth_len;
6160 
6161 
6162     length = tvb_get_ntohs(tvb, offset + 1);
6163 
6164     ext_tree = proto_tree_add_subtree(tree, tvb, offset, length + 1, ett_gtp_quint, NULL, "Quintuplet");
6165     offset++;
6166 
6167     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6168     offset = offset + 2;
6169 
6170     proto_tree_add_item(ext_tree, hf_gtp_rand, tvb, offset, 16, ENC_NA);
6171     offset = offset + 16;
6172     xres_len = tvb_get_guint8(tvb, offset);
6173     proto_tree_add_item(ext_tree, hf_gtp_xres_length, tvb, offset, 1, ENC_BIG_ENDIAN);
6174     offset++;
6175     proto_tree_add_item(ext_tree, hf_gtp_xres, tvb, offset, xres_len, ENC_NA);
6176     offset = offset + xres_len;
6177     proto_tree_add_item(ext_tree, hf_gtp_quintuplet_ciphering_key, tvb, offset, 16, ENC_NA);
6178     offset = offset + 16;
6179     proto_tree_add_item(ext_tree, hf_gtp_quintuplet_integrity_key, tvb, offset, 16, ENC_NA);
6180     offset = offset + 16;
6181     auth_len = tvb_get_guint8(tvb, offset);
6182     proto_tree_add_item(ext_tree, hf_gtp_authentication_length, tvb, offset, 1, ENC_BIG_ENDIAN);
6183     offset++;
6184     proto_tree_add_item(ext_tree, hf_gtp_auth, tvb, offset, auth_len, ENC_NA);
6185 
6186     return (3 + length);
6187 
6188 }
6189 
6190 /* GPRS:        not present
6191  * UMTS:        29.060 v4.0, chapter 7.7.36
6192  *              24.008 v4.2, chapter 10.5.6.12
6193  */
6194 static int
decode_gtp_tft(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)6195 decode_gtp_tft(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6196 {
6197     proto_tree     *ext_tree_tft;
6198     guint          length;
6199 
6200     length = tvb_get_ntohs(tvb, offset + 1);
6201 
6202     ext_tree_tft = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_tft, NULL, "Traffic flow template");
6203     proto_tree_add_item(ext_tree_tft, hf_gtp_tft_length, tvb, offset + 1, 2, ENC_BIG_ENDIAN);
6204 
6205     /* The detailed coding of Traffic Flow Template
6206     * Description is specified in 3GPP TS 24.008 [5] ,
6207     * clause 10.5.6.12, beginning with octet 3..
6208     * Use the decoding in packet-gsm_a_gm.c
6209     */
6210     de_sm_tflow_temp(tvb, ext_tree_tft, pinfo, offset + 3, length, NULL, 0);
6211 
6212     return 3 + length;
6213 }
6214 
6215 /* GPRS:        not present
6216  * UMTS:        3GPP TS 29.060 version 10.4.0 Release 10, chapter 7.7.37
6217  * Type = 138 (Decimal)
6218  *              25.413(RANAP) TargetID
6219  * There are several CRs to to this IE make sure to check with a recent spec if dissection is questioned.
6220  */
6221 static int
decode_gtp_target_id(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args _U_)6222 decode_gtp_target_id(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
6223 {
6224 
6225     guint16         length;
6226     proto_tree      *ext_tree;
6227 
6228 
6229     length = tvb_get_ntohs(tvb, offset + 1);
6230 
6231     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_TARGET_ID], NULL, "Target Identification");
6232     offset = offset + 1;
6233     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6234     offset = offset + 2;
6235     if (length == 0){
6236         return 3 + length;
6237     }
6238 
6239     /* Quote from specification:
6240      * The Target Identification information element contains the identification of a target RNC. Octets 4-n shall contain a
6241      * non-transparent copy of the corresponding IEs (see subclause 7.7.2) and be encoded as specified in Figure 51 below.
6242      * The "Target RNC-ID" part of the "Target ID" parameter is specified in 3GPP TS 25.413 [7].
6243      * NOTE 1: The ASN.1 parameter "Target ID" is forwarded non-transparently in order to maintain backward compatibility.
6244      * NOTE 2: The preamble of the "Target RNC-ID" (numerical value of e.g. 0x20) however shall not be included in
6245      *         octets 4-n. Also the optional "iE-Extensions" parameter shall not be included into the GTP IE.
6246      */
6247     /* Octet 4-6 MCC + MNC */
6248     if (length == 9) {
6249         /* Patch for systems still not following NOTE 2 */
6250         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.");
6251         offset+=1;
6252         dissect_e212_mcc_mnc(tvb, pinfo, ext_tree, offset, E212_NONE, FALSE);
6253     } else {
6254         /* Following Standards */
6255         dissect_e212_mcc_mnc(tvb, pinfo, ext_tree, offset, E212_NONE, TRUE);
6256     }
6257     offset+=3;
6258 
6259     /* Octet 7-8 LAC */
6260     proto_tree_add_item(ext_tree, hf_gtp_lac, tvb, offset, 2, ENC_BIG_ENDIAN);
6261     offset+=2;
6262     /* Octet 9 RAC */
6263     proto_tree_add_item(ext_tree, hf_gtp_rai_rac, tvb, offset, 1, ENC_BIG_ENDIAN);
6264     offset++;
6265     /* Octet 10-11 RNC-ID*/
6266     proto_tree_add_item(ext_tree, hf_gtp_target_rnc_id, tvb, offset, 2, ENC_BIG_ENDIAN);
6267     offset+=2;
6268     /* If the optional Extended RNC-ID is not included, then the length variable 'n' = 8 and the overall length of the IE is 11
6269      * octets. Otherwise, 'n' = 10 and the overall length of the IE is 13 octets
6270      */
6271     if(length == 10){
6272         proto_tree_add_item(ext_tree, hf_gtp_target_ext_rnc_id, tvb, offset, 2, ENC_BIG_ENDIAN);
6273     }
6274 
6275     return 3 + length;
6276 }
6277 
6278 
6279 /* GPRS:        not present
6280  * UMTS:        29.060 v4.0, chapter 7.7.38
6281  */
6282 static int
decode_gtp_utran_cont(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)6283 decode_gtp_utran_cont(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6284 {
6285 
6286     guint16     length;
6287     proto_tree *ext_tree;
6288     tvbuff_t   *new_tvb;
6289     proto_tree *sub_tree;
6290 
6291     length = tvb_get_ntohs(tvb, offset + 1);
6292 
6293     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_UTRAN_CONT], NULL, "UTRAN transparent Container");
6294 
6295     offset = offset + 1;
6296     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6297     offset = offset + 2;
6298     proto_tree_add_item(ext_tree, hf_gtp_utran_field, tvb, offset, length, ENC_NA);
6299 
6300     switch (pinfo->link_dir) {
6301     case P2P_DIR_UL:
6302         sub_tree = proto_tree_add_subtree(ext_tree, tvb, offset, length, ett_gtp_utran_cont, NULL, "Source RNC to Target RNC Transparent Container");
6303         new_tvb = tvb_new_subset_remaining(tvb, offset);
6304         dissect_ranap_SourceRNC_ToTargetRNC_TransparentContainer_PDU(new_tvb, pinfo, sub_tree, NULL);
6305         break;
6306     case P2P_DIR_DL:
6307         sub_tree = proto_tree_add_subtree(ext_tree, tvb, offset, length, ett_gtp_utran_cont, NULL, "Target RNC to Source RNC Transparent Container");
6308         new_tvb = tvb_new_subset_remaining(tvb, offset);
6309         dissect_ranap_TargetRNC_ToSourceRNC_TransparentContainer_PDU(new_tvb, pinfo, sub_tree, NULL);
6310         break;
6311     default:
6312         break;
6313     }
6314 
6315     return 3 + length;
6316 
6317 }
6318 
6319 
6320 /* GPRS:        not present
6321  * UMTS:        29.060 v4.0, chapter 7.7.39
6322  */
6323 static int
decode_gtp_rab_setup(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)6324 decode_gtp_rab_setup(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6325 {
6326 
6327     guint32            teid;
6328     guint16            length;
6329     proto_tree        *ext_tree_rab_setup;
6330 
6331     length = tvb_get_ntohs(tvb, offset + 1);
6332 
6333     ext_tree_rab_setup = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_rab_setup, NULL, "Radio Access Bearer Setup Information");
6334 
6335     proto_tree_add_item(ext_tree_rab_setup, hf_gtp_rab_setup_length, tvb, offset + 1, 2, ENC_BIG_ENDIAN);
6336     proto_tree_add_item(ext_tree_rab_setup, hf_gtp_nsapi, tvb, offset + 3, 1, ENC_BIG_ENDIAN);
6337 
6338     if (length > 1) {
6339 
6340         teid = tvb_get_ntohl(tvb, offset + 4);
6341 
6342         proto_tree_add_uint(ext_tree_rab_setup, hf_gtp_teid_data, tvb, offset + 4, 4, teid);
6343 
6344         switch (length) {
6345         case 9:
6346             proto_tree_add_item(ext_tree_rab_setup, hf_gtp_rnc_ipv4, tvb, offset + 8, 4, ENC_BIG_ENDIAN);
6347             break;
6348         case 21:
6349             proto_tree_add_item(ext_tree_rab_setup, hf_gtp_rnc_ipv6, tvb, offset + 8, 16, ENC_NA);
6350             break;
6351         default:
6352             break;
6353         }
6354     }
6355 
6356     return 3 + length;
6357 }
6358 
6359 
6360 /* GPRS:        not present
6361  * UMTS:        29.060 v4.0, chapter 7.7.40
6362  */
6363 static int
decode_gtp_hdr_list(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)6364 decode_gtp_hdr_list(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6365 {
6366 
6367     int         i;
6368     guint8      length, hdr;
6369     proto_tree *ext_tree_hdr_list;
6370 
6371     length = tvb_get_guint8(tvb, offset + 1);
6372 
6373     ext_tree_hdr_list = proto_tree_add_subtree(tree, tvb, offset, 2 + length, ett_gtp_hdr_list, NULL,
6374                             val_to_str_ext_const(GTP_EXT_HDR_LIST, &gtp_val_ext, "Unknown"));
6375 
6376     proto_tree_add_item(ext_tree_hdr_list, hf_gtp_num_ext_hdr_types, tvb, offset + 1, 1, ENC_NA);
6377 
6378     for (i = 0; i < length; i++) {
6379         hdr = tvb_get_guint8(tvb, offset + 2 + i);
6380 
6381         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,
6382                             val_to_str_const(hdr, next_extension_header_fieldvals, "Unknown Extension Header Type"), hdr);
6383     }
6384 
6385     return 2 + length;
6386 }
6387 
6388 /* GPRS:        not present
6389  * UMTS:        29.060 v4.0, chapter 7.7.41
6390  * TODO:        find TriggerID description
6391  */
6392 static int
decode_gtp_trigger_id(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)6393 decode_gtp_trigger_id(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6394 {
6395     guint16 length;
6396     proto_item* ti;
6397 
6398     length = tvb_get_ntohs(tvb, offset + 1);
6399 
6400     ti = proto_tree_add_uint_format(tree, hf_gtp_ext_length, tvb, offset, 2, length, "%s length : %u",
6401                                   val_to_str_ext_const(GTP_EXT_TRIGGER_ID, &gtp_val_ext, "Unknown"), length);
6402     proto_item_set_len(ti, 3 + length);
6403 
6404     return 3 + length;
6405 
6406 }
6407 
6408 /* GPRS:        not present
6409  * UMTS:        29.060 v4.0, chapter 7.7.42
6410  * TODO:        find OMC-ID description
6411  */
6412 static int
decode_gtp_omc_id(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)6413 decode_gtp_omc_id(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6414 {
6415     guint16 length;
6416     proto_item* ti;
6417 
6418     length = tvb_get_ntohs(tvb, offset + 1);
6419 
6420     ti = proto_tree_add_uint_format(tree, hf_gtp_ext_length, tvb, offset, 2, length, "%s length : %u",
6421                                   val_to_str_ext_const(GTP_EXT_OMC_ID, &gtp_val_ext, "Unknown"), length);
6422     proto_item_set_len(ti, 3 + length);
6423 
6424     return 3 + length;
6425 
6426 }
6427 
6428 /* GPRS:        9.60 v7.6.0, chapter 7.9.25
6429  * UMTS:        29.060 v6.11.0, chapter 7.7.44 Charging Gateway Address
6430  */
6431 static int
decode_gtp_chrg_addr(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)6432 decode_gtp_chrg_addr(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6433 {
6434 
6435     guint16            length;
6436     proto_tree        *ext_tree_chrg_addr;
6437     proto_item        *te;
6438 
6439     length = tvb_get_ntohs(tvb, offset + 1);
6440 
6441     ext_tree_chrg_addr = proto_tree_add_subtree_format(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_CHRG_ADDR], &te,
6442                                     "%s : ", val_to_str_ext_const(GTP_EXT_CHRG_ADDR, &gtp_val_ext, "Unknown"));
6443 
6444     proto_tree_add_uint_format(ext_tree_chrg_addr, hf_gtp_ext_length, tvb, offset + 1, 2, length,
6445                                     "%s length : %u", val_to_str_ext_const(GTP_EXT_CHRG_ADDR, &gtp_val_ext, "Unknown"), length);
6446 
6447     switch (length) {
6448     case 4:
6449         proto_tree_add_item(ext_tree_chrg_addr, hf_gtp_chrg_ipv4, tvb, offset + 3, 4, ENC_BIG_ENDIAN);
6450         proto_item_append_text(te, "%s", tvb_ip_to_str(pinfo->pool, tvb, offset + 3));
6451         break;
6452     case 16:
6453         proto_tree_add_item(ext_tree_chrg_addr, hf_gtp_chrg_ipv6, tvb, offset + 3, 16, ENC_NA);
6454         proto_item_append_text(te, "%s", tvb_ip6_to_str(pinfo->pool, tvb, offset + 3));
6455         break;
6456     default:
6457         proto_item_append_text(te, "unknown type or wrong length");
6458         break;
6459     }
6460 
6461     return 3 + length;
6462 }
6463 
6464 /* GPRS:        ?
6465  * UMTS:        29.060 V9.4.0, chapter 7.7.43 RAN Transparent Container
6466  * The information in the value part of the RAN Transparent Container IE contains all information elements (starting with
6467  * and including the BSSGP "PDU Type") in either of the RAN INFORMATION, RAN INFORMATION REQUEST,
6468  * RAN INFORMATION ACK or RAN INFORMATION ERROR messages respectively as specified in 3GPP TS 48.018
6469  */
6470 static int
decode_gtp_ran_tr_cont(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args _U_)6471 decode_gtp_ran_tr_cont(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
6472 {
6473 
6474     guint16     length;
6475     proto_tree *ext_tree;
6476     tvbuff_t   *next_tvb;
6477 
6478     length = tvb_get_ntohs(tvb, offset + 1);
6479     ext_tree = proto_tree_add_subtree_format(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_RAN_TR_CONT], NULL,
6480                         "%s : ", val_to_str_ext_const(GTP_EXT_RAN_TR_CONT, &gtp_val_ext, "Unknown"));
6481 
6482     offset++;
6483     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6484     offset = offset + 2;
6485 
6486     next_tvb = tvb_new_subset_length(tvb, offset, length);
6487     if (bssgp_handle) {
6488 #if 0
6489         col_set_fence(pinfo->cinfo, COL_INFO);
6490 #endif
6491         call_dissector(bssgp_handle, next_tvb, pinfo, ext_tree);
6492     }
6493 
6494     return 3 + length;
6495 
6496 }
6497 
6498 /* GPRS:        ?
6499  * UMTS:        29.060 v6.11.0, chapter 7.7.45 PDP Context Prioritization
6500  */
6501 static int
decode_gtp_pdp_cont_prio(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args _U_)6502 decode_gtp_pdp_cont_prio(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
6503 {
6504 
6505     guint16     length;
6506     proto_tree *ext_tree;
6507 
6508     length = tvb_get_ntohs(tvb, offset + 1);
6509     ext_tree = proto_tree_add_subtree_format(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_PDP_CONT_PRIO], NULL,
6510                         "%s : ", val_to_str_ext_const(GTP_EXT_PDP_CONT_PRIO, &gtp_val_ext, "Unknown"));
6511 
6512     if (length == 0) {
6513         return 3;
6514     }
6515 
6516     offset++;
6517     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6518     offset = offset + 2;
6519     /* TODO add decoding of data */
6520     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
6521 
6522     return 3 + length;
6523 
6524 }
6525 
6526 /* GPRS:        ?
6527  * UMTS:        29.060 v6.11.0, chapter 7.7.45A Additional RAB Setup Information
6528  */
6529 static int
decode_gtp_add_rab_setup_inf(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)6530 decode_gtp_add_rab_setup_inf(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6531 {
6532 
6533     guint16     length;
6534     proto_tree *ext_tree;
6535 
6536     length = tvb_get_ntohs(tvb, offset + 1);
6537     ext_tree = proto_tree_add_subtree_format(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_ADD_RAB_SETUP_INF], NULL,
6538                     "%s : ", val_to_str_ext_const(GTP_EXT_ADD_RAB_SETUP_INF, &gtp_val_ext, "Unknown"));
6539 
6540     offset++;
6541     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6542     offset = offset + 2;
6543 
6544     proto_tree_add_item(ext_tree, hf_gtp_nsapi, tvb, offset, 1, ENC_BIG_ENDIAN);
6545     if (length == 1)
6546         return 3 + length;
6547 
6548     offset++;
6549     proto_tree_add_item(ext_tree, hf_gtp_teid, tvb, offset, 4, ENC_BIG_ENDIAN);
6550     offset += 4;
6551 
6552     if (length == 9) {
6553         /* RNC IP address IPv4*/
6554         proto_tree_add_item(ext_tree, hf_gtp_rnc_ip_addr_v4, tvb, offset, 4, ENC_BIG_ENDIAN);
6555     } else {
6556         /* RNC IP address IPv6*/
6557         proto_tree_add_item(ext_tree, hf_gtp_rnc_ip_addr_v6, tvb, offset, 16, ENC_NA);
6558     }
6559 
6560 
6561     return 3 + length;
6562 
6563 }
6564 
6565 
6566  /* GPRS:       ?
6567   * UMTS:       29.060 v6.11.0, chapter 7.7.47 SGSN Number
6568   */
6569 static int
decode_gtp_sgsn_no(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)6570 decode_gtp_sgsn_no(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6571 {
6572 
6573     guint16     length;
6574     proto_tree *ext_tree;
6575     tvbuff_t   *new_tvb;
6576 
6577     length = tvb_get_ntohs(tvb, offset + 1);
6578     ext_tree = proto_tree_add_subtree_format(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_SGSN_NO], NULL,
6579                     "%s", val_to_str_ext_const(GTP_EXT_SGSN_NO, &gtp_val_ext, "Unknown"));
6580     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
6581 
6582     offset++;
6583     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6584     offset = offset + 2;
6585 
6586     new_tvb = tvb_new_subset_length(tvb, offset, length);
6587     dissect_gsm_map_msisdn(new_tvb, pinfo, ext_tree);
6588 
6589     return 3 + length;
6590 
6591 }
6592 
6593 /* GPRS:        ?
6594  * UMTS:        3GPP TS 29.060 version 7.8.0 Release 7, chapter 7.7.48 Common Flags
6595  */
6596 static int
decode_gtp_common_flgs(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)6597 decode_gtp_common_flgs(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6598 {
6599 
6600     guint16     length;
6601     proto_tree *ext_tree;
6602 
6603     length = tvb_get_ntohs(tvb, offset + 1);
6604     ext_tree = proto_tree_add_subtree_format(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_COMMON_FLGS], NULL,
6605                 "%s : ", val_to_str_ext_const(GTP_EXT_COMMON_FLGS, &gtp_val_ext, "Unknown"));
6606 
6607     offset++;
6608     proto_tree_add_item(ext_tree, hf_gtp_ext_length,                   tvb, offset, 2, ENC_BIG_ENDIAN);
6609     offset = offset + 2;
6610     /* Dual Address Bearer Flag */
6611     proto_tree_add_item(ext_tree, hf_gtp_cmn_flg_dual_addr_bearer_flg, tvb, offset, 1, ENC_BIG_ENDIAN);
6612     /* Upgrade QoS Supported */
6613     proto_tree_add_item(ext_tree, hf_gtp_cmn_flg_upgrd_qos_sup,        tvb, offset, 1, ENC_BIG_ENDIAN);
6614     /* NRSN bit field */
6615     proto_tree_add_item(ext_tree, hf_gtp_cmn_flg_nrsn,                 tvb, offset, 1, ENC_BIG_ENDIAN);
6616     /* No QoS negotiation */
6617     proto_tree_add_item(ext_tree, hf_gtp_cmn_flg_no_qos_neg,           tvb, offset, 1, ENC_BIG_ENDIAN);
6618     /* MBMS Counting Information bi */
6619     proto_tree_add_item(ext_tree, hf_gtp_cmn_flg_mbs_cnt_inf,          tvb, offset, 1, ENC_BIG_ENDIAN);
6620     /* RAN Procedures Ready */
6621     proto_tree_add_item(ext_tree, hf_gtp_cmn_flg_mbs_ran_pcd_rdy,      tvb, offset, 1, ENC_BIG_ENDIAN);
6622     /* MBMS Service Type */
6623     proto_tree_add_item(ext_tree, hf_gtp_cmn_flg_mbs_srv_type,         tvb, offset, 1, ENC_BIG_ENDIAN);
6624     /* Prohibit Payload Compression */
6625     proto_tree_add_item(ext_tree, hf_gtp_cmn_flg_ppc,                  tvb, offset, 1, ENC_BIG_ENDIAN);
6626 
6627     return 3 + length;
6628 
6629 }
6630 
6631 /* GPRS:        ?
6632  * UMTS:        29.060 v6.11.0, chapter 7.7.49
6633  */
6634 static int
decode_gtp_apn_res(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args _U_)6635 decode_gtp_apn_res(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
6636 {
6637 
6638     guint16     length;
6639     proto_tree *ext_tree_apn_res;
6640 
6641     length = tvb_get_ntohs(tvb, offset + 1);
6642     ext_tree_apn_res = proto_tree_add_subtree_format(tree, tvb, offset, 3 + length,  ett_gtp_ies[GTP_EXT_APN_RES], NULL,
6643                 "%s : ", val_to_str_ext_const(GTP_EXT_APN_RES, &gtp_val_ext, "Unknown"));
6644 
6645     offset++;
6646     proto_tree_add_item(ext_tree_apn_res, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6647     offset = offset + 2;
6648 
6649     /* Restriction Type value */
6650     if (length != 1) {
6651         proto_tree_add_expert_format(tree, pinfo, &ei_gtp_ext_length_mal, tvb, 0, length, "Wrong length indicated. Expected 1, got %u", length);
6652         return 3 + length;
6653     }
6654 
6655     proto_tree_add_item(ext_tree_apn_res, hf_gtp_ext_apn_res, tvb, offset, length, ENC_BIG_ENDIAN);
6656     return 3 + length;
6657 }
6658 
6659 /* GPRS:        ?
6660  * UMTS:        29.060 v6.11.0, chapter 7.7.50 RAT Type
6661  * RAT Type
6662  * Type = 151 (Decimal)
6663  */
6664 
6665 static int
decode_gtp_rat_type(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args _U_)6666 decode_gtp_rat_type(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
6667 {
6668 
6669     guint16     length;
6670     proto_tree *ext_tree_rat_type;
6671     proto_item *te;
6672 
6673     length = tvb_get_ntohs(tvb, offset + 1);
6674     ext_tree_rat_type = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_RAT_TYPE], &te,
6675                         val_to_str_ext_const(GTP_EXT_RAT_TYPE, &gtp_val_ext, "Unknown"));
6676 
6677     offset++;
6678     proto_tree_add_item(ext_tree_rat_type, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6679     offset = offset + 2;
6680 
6681     /* RAT Type value */
6682     if (length != 1) {
6683         proto_tree_add_expert_format(tree, pinfo, &ei_gtp_ext_length_mal, tvb, 0, length, "Wrong length indicated. Expected 1, got %u", length);
6684         return 3 + length;
6685     }
6686 
6687    proto_tree_add_item(ext_tree_rat_type, hf_gtp_ext_rat_type, tvb, offset, length, ENC_BIG_ENDIAN);
6688    proto_item_append_text(te, ": %s", val_to_str_const(tvb_get_guint8(tvb,offset), gtp_ext_rat_type_vals, "Unknown"));
6689 
6690    return 3 + length;
6691 }
6692 
6693 /*
6694  * 7.7.51 User Location Information
6695  */
6696 
6697 void
dissect_gtp_uli(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args _U_)6698 dissect_gtp_uli(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
6699 {
6700     guint8      geo_loc_type;
6701     proto_item* ti;
6702 
6703     /* Geographic Location Type */
6704     geo_loc_type = tvb_get_guint8(tvb, offset);
6705     ti = proto_tree_add_uint(tree, hf_gtp_uli_geo_loc_type, tvb, offset, 1, geo_loc_type);
6706 
6707     offset++;
6708 
6709     switch(geo_loc_type) {
6710         case 0:
6711             /* Geographic Location field included and it holds the Cell Global
6712              * Identification (CGI) of where the user currently is registered.
6713              * CGI is defined in sub-clause 4.3.1 of 3GPP TS 23.003 [2].
6714              */
6715             dissect_e212_mcc_mnc(tvb, pinfo, tree, offset, E212_CGI, TRUE);
6716             offset+=3;
6717             proto_tree_add_item(tree, hf_gtp_lac, tvb, offset, 2, ENC_BIG_ENDIAN);
6718             offset+=2;
6719             /* The CI is of fixed length with 2 octets and it can be coded using a full hexadecimal representation */
6720             proto_tree_add_item(tree, hf_gtp_cgi_ci, tvb, offset, 2, ENC_BIG_ENDIAN);
6721             break;
6722         case 1:
6723             /* Geographic Location field included and it holds the Service
6724              * Area Identity (SAI) of where the user currently is registered.
6725              * SAI is defined in sub-clause 9.2.3.9 of 3GPP TS 25.413 [7].
6726              */
6727             dissect_e212_mcc_mnc(tvb, pinfo, tree, offset, E212_SAI, TRUE);
6728             offset+=3;
6729             proto_tree_add_item(tree, hf_gtp_lac, tvb, offset, 2, ENC_BIG_ENDIAN);
6730             offset+=2;
6731             proto_tree_add_item(tree, hf_gtp_sai_sac, tvb, offset, 2, ENC_BIG_ENDIAN);
6732             break;
6733         case 2:
6734             /* Geographic Location field included and it holds the Routing
6735              * Area Identification (RAI) of where the user currently is
6736              * registered. RAI is defined in sub-clause 4.2 of 3GPP TS 23.003
6737              * [2].
6738              */
6739             dissect_e212_mcc_mnc(tvb, pinfo, tree, offset, E212_RAI, TRUE);
6740             offset+=3;
6741             proto_tree_add_item(tree, hf_gtp_lac, tvb, offset, 2, ENC_BIG_ENDIAN);
6742             offset+=2;
6743             proto_tree_add_item(tree, hf_gtp_rai_rac, tvb, offset, 2, ENC_BIG_ENDIAN);
6744             break;
6745         default:
6746             expert_add_info(pinfo, ti, &ei_gtp_ext_geo_loc_type);
6747             break;
6748     }
6749 }
6750 
6751 static int
decode_gtp_usr_loc_inf(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args _U_)6752 decode_gtp_usr_loc_inf(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
6753 {
6754 
6755     guint16     length;
6756     proto_tree *ext_tree;
6757 
6758     length = tvb_get_ntohs(tvb, offset + 1);
6759     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_USR_LOC_INF], NULL,
6760                 val_to_str_ext_const(GTP_EXT_USR_LOC_INF, &gtp_val_ext, "Unknown"));
6761 
6762     offset++;
6763     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6764     offset = offset + 2;
6765 
6766     dissect_gtp_uli(tvb, offset, pinfo, ext_tree, args);
6767 
6768     return 3 + length;
6769 }
6770 
6771 static const value_string daylight_saving_time_vals[] = {
6772     {0, "No adjustment"},
6773     {1, "+1 hour adjustment for Daylight Saving Time"},
6774     {2, "+2 hours adjustment for Daylight Saving Time"},
6775     {3, "Reserved"},
6776     {0, NULL}
6777 };
6778 
6779 /* GPRS:        ?
6780  * UMTS:        29.060 v6.11.0, chapter 7.7.52
6781  * MS Time Zone
6782  * Type = 153 (Decimal)
6783  * The ' MS Time Zone' IE is used to indicate the offset between universal time and local time
6784  * in steps of 15 minutes of where the MS currently resides. The 'Time Zone' field uses the same
6785  * format as the 'Time Zone' IE in 3GPP TS 24.008 (10.5.3.8)
6786  * its value shall be set as defined in 3GPP TS 22.042
6787  */
6788 static int
decode_gtp_ms_time_zone(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)6789 decode_gtp_ms_time_zone(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6790 {
6791 
6792     guint16     length;
6793     proto_tree *ext_tree;
6794     proto_item *te;
6795     guint8      data;
6796     char        sign;
6797 
6798     length = tvb_get_ntohs(tvb, offset + 1);
6799     ext_tree = proto_tree_add_subtree_format(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_MS_TIME_ZONE], &te,
6800                     "%s: ", val_to_str_ext_const(GTP_EXT_MS_TIME_ZONE, &gtp_val_ext, "Unknown"));
6801 
6802     offset++;
6803     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6804     offset = offset + 2;
6805 
6806     /* 3GPP TS 23.040 version 6.6.0 Release 6
6807      * 9.2.3.11 TP-Service-Centre-Time-Stamp (TP-SCTS)
6808      * :
6809      * The Time Zone indicates the difference, expressed in quarters of an hour,
6810      * between the local time and GMT. In the first of the two semi-octets,
6811      * the first bit (bit 3 of the seventh octet of the TP-Service-Centre-Time-Stamp field)
6812      * represents the algebraic sign of this difference (0: positive, 1: negative).
6813      */
6814 
6815     data = tvb_get_guint8(tvb, offset);
6816     sign = (data & 0x08) ? '-' : '+';
6817     data = (data >> 4) + (data & 0x07) * 10;
6818 
6819     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);
6820     proto_item_append_text(te, "GMT %c %d hours %d minutes", sign, data / 4, data % 4 * 15);
6821     offset++;
6822 
6823     proto_tree_add_item(ext_tree, hf_gtp_timezone_dst, tvb, offset, 1, ENC_NA);
6824 
6825     return 3 + length;
6826 
6827 }
6828 
6829 /* GPRS:        ?
6830  * UMTS:        29.060 v6.11.0, chapter 7.7.53
6831  * International Mobile Equipment Identity (and Software Version) (IMEI(SV))
6832  * Type = 154 (Decimal)
6833  */
6834 static int
decode_gtp_imeisv(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)6835 decode_gtp_imeisv(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6836 {
6837 
6838     guint16     length;
6839     proto_tree *ext_imeisv;
6840     proto_item *te;
6841     tvbuff_t   *next_tvb;
6842     char       *digit_str;
6843 
6844     length = tvb_get_ntohs(tvb, offset + 1);
6845     ext_imeisv = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_IMEISV], &te,
6846                         val_to_str_ext_const(GTP_EXT_IMEISV, &gtp_val_ext, "Unknown"));
6847 
6848     offset++;
6849     proto_tree_add_item(ext_imeisv, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6850     offset = offset + 2;
6851 
6852     /* IMEI(SV)
6853      * The structure of the IMEI and IMEISV are defined in sub-clause 6.2 of 3GPP TS 23.003 [2].
6854      * The 'IMEI(SV)' field shall contain the IMEISV if it is available. If only the IMEI is available,
6855      * then the IMEI shall be placed in the IMEI(SV) field and the last semi-octet of octet 11 shall be
6856      * set to '1111'. Both IMEI and IMEISV are BCD encoded.
6857      */
6858     next_tvb = tvb_new_subset_length(tvb, offset, length);
6859     proto_tree_add_item_ret_display_string(ext_imeisv, hf_gtp_ext_imeisv, next_tvb, 0, -1, ENC_BCD_DIGITS_0_9, wmem_packet_scope(), &digit_str);
6860     proto_item_append_text(te, ": %s", digit_str);
6861 
6862     return 3 + length;
6863 }
6864 
6865 /* GPRS:        ?
6866  * UMTS:        29.060 v6.11.0, chapter 7.7.54
6867  * CAMEL Charging Information Container
6868  * Type = 155 (Decimal)
6869  */
6870 static int
decode_gtp_camel_chg_inf_con(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)6871 decode_gtp_camel_chg_inf_con(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6872 {
6873 
6874     guint16     length;
6875     proto_tree *ext_tree;
6876 
6877     length = tvb_get_ntohs(tvb, offset + 1);
6878     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_CAMEL_CHG_INF_CON], NULL,
6879                     val_to_str_ext_const(GTP_EXT_CAMEL_CHG_INF_CON, &gtp_val_ext, "Unknown"));
6880 
6881     offset++;
6882     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6883     offset = offset + 2;
6884     /* TODO add decoding of data */
6885     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
6886 
6887     return 3 + length;
6888 
6889 }
6890 
6891 /* GPRS:        ?
6892  * UMTS:        29.060 v6.11.0, chapter 7.7.55
6893  * MBMS UE Context
6894  */
6895 static int
decode_gtp_mbms_ue_ctx(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)6896 decode_gtp_mbms_ue_ctx(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6897 {
6898 
6899     guint16     length;
6900     proto_tree *ext_tree;
6901 
6902     length = tvb_get_ntohs(tvb, offset + 1);
6903     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_MBMS_UE_CTX], NULL,
6904                 val_to_str_ext_const(GTP_EXT_MBMS_UE_CTX, &gtp_val_ext, "Unknown"));
6905 
6906     offset++;
6907     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6908     offset = offset + 2;
6909     /* TODO add decoding of data */
6910     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
6911 
6912     return 3 + length;
6913 
6914 }
6915 
6916 /* GPRS:        ?
6917  * UMTS:        3GPP TS 29.060 version 7.8.0 Release 7, chapter 7.7.56
6918  * Temporary Mobile Group Identity (TMGI)
6919  * The Temporary Mobile Group Identity (TMGI) information element contains
6920  * a TMGI allocated by the BM-SC. It is coded as in the value part defined
6921  * in 3GPP T S 24.008 [5] (i.e. the IEI and octet length indicator are not included).
6922  */
6923 
6924 static int
decode_gtp_tmgi(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args _U_)6925 decode_gtp_tmgi(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
6926 {
6927 
6928     guint16     length;
6929     proto_tree *ext_tree, *tmgi_tree;
6930     proto_item *ti;
6931     tvbuff_t   *next_tvb;
6932 
6933     length = tvb_get_ntohs(tvb, offset + 1);
6934     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_TMGI], NULL,
6935                 val_to_str_ext_const(GTP_EXT_TMGI, &gtp_val_ext, "Unknown"));
6936 
6937     offset++;
6938     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6939     offset = offset + 2;
6940 
6941     ti = proto_tree_add_item(ext_tree, hf_gtp_tmgi, tvb, offset, length, ENC_NA);
6942 
6943     tmgi_tree = proto_item_add_subtree(ti, ett_gtp_tmgi);
6944     next_tvb = tvb_new_subset_length(tvb, offset, length);
6945     de_mid(next_tvb, tmgi_tree, pinfo, 0, length, NULL, 0);
6946     return 3 + length;
6947 
6948 }
6949 
6950 /* GPRS:        ?
6951  * UMTS:        29.060 v6.11.0, chapter 7.7.57
6952  * RIM Routing Address
6953  */
6954 static int
decode_gtp_rim_ra(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)6955 decode_gtp_rim_ra(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6956 {
6957 
6958     guint16     length;
6959     proto_tree *ext_tree;
6960 
6961     length = tvb_get_ntohs(tvb, offset + 1);
6962     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_RIM_RA], NULL,
6963                             val_to_str_ext_const(GTP_EXT_RIM_RA, &gtp_val_ext, "Unknown"));
6964 
6965     offset++;
6966     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6967     offset = offset + 2;
6968     /* To dissect the Address the Routing Address discriminator must be known */
6969     /*
6970      * Octets 4-n are coded according to 3GPP TS 48.018 [20] 11.3.77 RIM Routing Information IE octets 4-n.
6971      */
6972     proto_tree_add_item(ext_tree, hf_gtp_rim_routing_addr, tvb, offset, length, ENC_NA);
6973 
6974     return 3 + length;
6975 
6976 }
6977 
6978 /* GPRS:        ?
6979  * UMTS:        29.060 v6.11.0, chapter 7.7.58
6980  * MBMS Protocol Configuration Options
6981  */
6982 static int
decode_gtp_mbms_prot_conf_opt(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)6983 decode_gtp_mbms_prot_conf_opt(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
6984 {
6985 
6986     guint16     length;
6987     proto_tree *ext_tree;
6988 
6989     length = tvb_get_ntohs(tvb, offset + 1);
6990     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_MBMS_PROT_CONF_OPT], NULL,
6991                     val_to_str_ext_const(GTP_EXT_MBMS_PROT_CONF_OPT, &gtp_val_ext, "Unknown"));
6992 
6993     offset++;
6994     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
6995     offset = offset + 2;
6996     /* TODO add decoding of data */
6997     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
6998 
6999     return 3 + length;
7000 
7001 }
7002 
7003 /* GPRS:        ?
7004  * UMTS:        3GPP TS 29.060 version 7.8.0 Release 7, chapter 7.7.59
7005  * MBMS Session Duration
7006  */
7007 /* Used for Diameter */
7008 static int
dissect_gtp_mbms_ses_dur(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree,void * data _U_)7009 dissect_gtp_mbms_ses_dur(tvbuff_t * tvb, packet_info * pinfo _U_, proto_tree * tree, void *data _U_)
7010 {
7011 
7012     int offset = 0;
7013 
7014     proto_tree_add_item(tree, hf_gtp_mbms_ses_dur_days, tvb, offset, 3, ENC_BIG_ENDIAN);
7015     proto_tree_add_item(tree, hf_gtp_mbms_ses_dur_s,    tvb, offset, 3, ENC_BIG_ENDIAN);
7016 
7017     return 3;
7018 
7019 }
7020 
7021 static int
decode_gtp_mbms_ses_dur(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)7022 decode_gtp_mbms_ses_dur(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7023 {
7024 
7025     guint16     length;
7026     proto_tree *ext_tree;
7027 
7028     length = tvb_get_ntohs(tvb, offset + 1);
7029     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_MBMS_SES_DUR], NULL,
7030                 val_to_str_ext_const(GTP_EXT_MBMS_SES_DUR, &gtp_val_ext, "Unknown"));
7031 
7032     offset++;
7033     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7034     offset = offset + 2;
7035     /* The MBMS Session Duration is defined in 3GPP TS 23.246 [26].
7036      * The MBMS Session Duration information element indicates the estimated
7037      * session duration of the MBMS service data transmission if available.
7038      * The payload shall be encoded as per the MBMS-Session-Duration AVP defined
7039      * in 3GPP TS 29.061 [27], excluding the AVP Header fields
7040      * (as defined in IETF RFC 3588 [36], section 4.1).
7041      */
7042     /* The MBMS-Session-Duration AVP (AVP code 904) is of type OctetString
7043      * with a length of three octets and indicates the estimated session duration
7044      * (MBMS Service data transmission). Bits 0 to 16 (17 bits) express seconds, for which the
7045      * maximum allowed value is 86400 seconds. Bits 17 to 23 (7 bits) express days,
7046      * for which the maximum allowed value is 18 days. For the whole session duration the seconds
7047      * and days are added together and the maximum session duration is 19 days.
7048      */
7049     proto_tree_add_item(ext_tree, hf_gtp_mbms_ses_dur_days, tvb, offset, 3, ENC_BIG_ENDIAN);
7050     proto_tree_add_item(ext_tree, hf_gtp_mbms_ses_dur_s, tvb, offset, 3, ENC_BIG_ENDIAN);
7051 
7052     return 3 + length;
7053 
7054 }
7055 
7056 /* GPRS:        ?
7057  * UMTS:        3GPP TS 29.060 version 7.8.0 Release 7, chapter 7.7.60
7058  * MBMS Service Area
7059  */
7060 static int
dissect_gtp_3gpp_mbms_service_area(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree,void * data _U_)7061 dissect_gtp_3gpp_mbms_service_area(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_) {
7062 
7063     int    offset = 0;
7064     guint8 no_of_mbms_sa_codes;
7065     int    i;
7066 
7067     /* The MBMS Service Area is defined in 3GPP TS 23.246 [26].
7068      * The MBMS Service Area information element indicates the area over
7069      * which the Multimedia Broadcast/Multicast Service is to be distributed.
7070      * The payload shall be encoded as per the MBMS-Service-Area AVP defined
7071      * in 3GPP TS 29.061 [27], excluding the AVP Header fields (as defined in
7072      * IETF RFC 3588 [36], section 4.1).
7073      */
7074     /* Number N of MBMS service area codes coded as:
7075      * 1 binary value is '00000000'
7076      * ... ...
7077      * 256 binary value is '11111111'
7078      */
7079     no_of_mbms_sa_codes = tvb_get_guint8(tvb, offset) + 1;
7080     proto_tree_add_uint(tree, hf_gtp_no_of_mbms_sa_codes, tvb, offset, 1, no_of_mbms_sa_codes);
7081     offset++;
7082     /* A consecutive list of N MBMS service area codes
7083      * The MBMS Service Area Identity and its semantics are defined in 3GPP TS 23.003
7084      * The length of an MBMS service area code is 2 octets.
7085      */
7086     for (i = 0; i < no_of_mbms_sa_codes; i++) {
7087         proto_tree_add_item(tree, hf_gtp_mbms_sa_code, tvb, offset, 2, ENC_BIG_ENDIAN);
7088         offset = offset + 2;
7089     }
7090 
7091     return offset;
7092 }
7093 
7094 static int
decode_gtp_mbms_sa(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args _U_)7095 decode_gtp_mbms_sa(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
7096 {
7097 
7098     tvbuff_t   *next_tvb;
7099     guint16     length;
7100     proto_tree *ext_tree;
7101 
7102     length = tvb_get_ntohs(tvb, offset + 1);
7103     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_MBMS_SA], NULL,
7104                 val_to_str_ext_const(GTP_EXT_MBMS_SA, &gtp_val_ext, "Unknown"));
7105 
7106     offset++;
7107     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7108     offset = offset + 2;
7109     next_tvb = tvb_new_subset_length(tvb, offset, length-3);
7110     dissect_gtp_3gpp_mbms_service_area(next_tvb, pinfo, ext_tree, NULL);
7111 
7112     return 3 + length;
7113 
7114 }
7115 
7116 /* GPRS:        ?
7117  * UMTS:        29.060 v6.11.0, chapter 7.7.61
7118  * Source RNC PDCP context info
7119  */
7120 static int
decode_gtp_src_rnc_pdp_ctx_inf(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)7121 decode_gtp_src_rnc_pdp_ctx_inf(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7122 {
7123 
7124     guint16     length;
7125     proto_tree *ext_tree;
7126 
7127     length = tvb_get_ntohs(tvb, offset + 1);
7128     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_SRC_RNC_PDP_CTX_INF], NULL,
7129                     val_to_str_ext_const(GTP_EXT_SRC_RNC_PDP_CTX_INF, &gtp_val_ext, "Unknown"));
7130 
7131     offset++;
7132     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7133     offset = offset + 2;
7134     /* TODO add decoding of data */
7135     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
7136 
7137     return 3 + length;
7138 
7139 }
7140 
7141 /* GPRS:        ?
7142  * UMTS:        29.060 v6.11.0, chapter 7.7.62
7143  * Additional Trace Info
7144  */
7145 static int
decode_gtp_add_trs_inf(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)7146 decode_gtp_add_trs_inf(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_ADD_TRS_INF], NULL,
7154                     val_to_str_ext_const(GTP_EXT_ADD_TRS_INF, &gtp_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 = offset + 2;
7159     /* TODO add decoding of data */
7160     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
7161 
7162     return 3 + length;
7163 
7164 }
7165 
7166 /* GPRS:        ?
7167  * UMTS:        29.060 v6.11.0, chapter 7.7.63
7168  * Hop Counter
7169  */
7170 static int
decode_gtp_hop_count(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)7171 decode_gtp_hop_count(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7172 {
7173 
7174     guint16     length;
7175     proto_tree *ext_tree;
7176 
7177     length = tvb_get_ntohs(tvb, offset + 1);
7178     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_HOP_COUNT], NULL,
7179                 val_to_str_ext_const(GTP_EXT_HOP_COUNT, &gtp_val_ext, "Unknown"));
7180 
7181     offset++;
7182     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7183     offset = offset + 2;
7184     /* TODO add decoding of data */
7185     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
7186 
7187     return 3 + length;
7188 
7189 }
7190 
7191 /* GPRS:        ?
7192  * UMTS:        29.060 v6.11.0, chapter 7.7.64
7193  * Selected PLMN ID
7194  */
7195 static int
decode_gtp_sel_plmn_id(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args _U_)7196 decode_gtp_sel_plmn_id(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
7197 {
7198 
7199     guint16     length;
7200     proto_tree *ext_tree;
7201 
7202     length = tvb_get_ntohs(tvb, offset + 1);
7203     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_MBMS_SES_ID], NULL,
7204                                 val_to_str_ext_const(GTP_EXT_SEL_PLMN_ID, &gtp_val_ext, "Unknown"));
7205 
7206     offset++;
7207     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7208     offset = offset + 2;
7209 
7210     dissect_e212_mcc_mnc(tvb, pinfo, ext_tree, offset, E212_NONE, FALSE);
7211     return 3 + length;
7212 
7213 }
7214 
7215 /* GPRS:        ?
7216  * UMTS:        29.060 v6.11.0, chapter 7.7.65
7217  * MBMS Session Identifier
7218  */
7219 static int
decode_gtp_mbms_ses_id(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)7220 decode_gtp_mbms_ses_id(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7221 {
7222 
7223     guint16     length;
7224     proto_tree *ext_tree;
7225 
7226     length = tvb_get_ntohs(tvb, offset + 1);
7227     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"));
7228 
7229     offset++;
7230     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7231     offset = offset + 2;
7232     /* TODO add decoding of data */
7233     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
7234 
7235     return 3 + length;
7236 
7237 }
7238 
7239 /* GPRS:        ?
7240  * UMTS:        29.060 v6.11.0, chapter 7.7.66
7241  * MBMS 2G/3G Indicator
7242  */
7243 static const value_string gtp_mbs_2g_3g_ind_vals[] = {
7244     {0, "2G only"},
7245     {1, "3G only"},
7246     {2, "Both 2G and 3G"},
7247     {0, NULL}
7248 };
7249 
7250 static int
decode_gtp_mbms_2g_3g_ind(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)7251 decode_gtp_mbms_2g_3g_ind(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7252 {
7253 
7254     guint16     length;
7255     proto_tree *ext_tree;
7256 
7257     length = tvb_get_ntohs(tvb, offset + 1);
7258     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_MBMS_2G_3G_IND], NULL,
7259                 val_to_str_ext_const(GTP_EXT_MBMS_2G_3G_IND, &gtp_val_ext, "Unknown"));
7260 
7261     offset++;
7262     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7263     offset = offset + 2;
7264     /* MBMS 2G/3G Indicator */
7265     proto_tree_add_item(ext_tree, hf_gtp_mbs_2g_3g_ind, tvb, offset, 1, ENC_BIG_ENDIAN);
7266 
7267     return 3 + length;
7268 
7269 }
7270 
7271 /* GPRS:        ?
7272  * UMTS:        29.060 v6.11.0, chapter 7.7.67
7273  * Enhanced NSAPI
7274  */
7275 static int
decode_gtp_enh_nsapi(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)7276 decode_gtp_enh_nsapi(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7277 {
7278 
7279     guint16     length;
7280     proto_tree *ext_tree;
7281 
7282     length = tvb_get_ntohs(tvb, offset + 1);
7283     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"));
7284 
7285     offset++;
7286     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7287     offset = offset + 2;
7288     /* TODO add decoding of data */
7289     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
7290 
7291     return 3 + length;
7292 
7293 }
7294 
7295 /* GPRS:        ?
7296  * UMTS:        29.060 v6.11.0, chapter 7.7.68
7297  * Additional MBMS Trace Info
7298  */
7299 static int
decode_gtp_add_mbms_trs_inf(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)7300 decode_gtp_add_mbms_trs_inf(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7301 {
7302 
7303     guint16     length;
7304     proto_tree *ext_tree;
7305 
7306     length = tvb_get_ntohs(tvb, offset + 1);
7307     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_ADD_MBMS_TRS_INF], NULL,
7308                             val_to_str_ext_const(GTP_EXT_ADD_MBMS_TRS_INF, &gtpv1_val_ext, "Unknown"));
7309 
7310     offset++;
7311     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7312     offset = offset + 2;
7313     /* TODO add decoding of data */
7314     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
7315 
7316     return 3 + length;
7317 
7318 }
7319 
7320 /* GPRS:        ?
7321  * UMTS:        29.060 v6.11.0, chapter 7.7.69
7322  * MBMS Session Identity Repetition Number
7323  */
7324 static int
decode_gtp_mbms_ses_id_rep_no(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)7325 decode_gtp_mbms_ses_id_rep_no(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7326 {
7327 
7328     guint16     length;
7329     proto_tree *ext_tree;
7330 
7331     length = tvb_get_ntohs(tvb, offset + 1);
7332     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_MBMS_SES_ID_REP_NO], NULL,
7333                                         val_to_str_ext_const(GTP_EXT_MBMS_SES_ID_REP_NO, &gtpv1_val_ext, "Unknown"));
7334 
7335     offset++;
7336     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7337     offset = offset + 2;
7338     /* TODO add decoding of data */
7339     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
7340 
7341     return 3 + length;
7342 
7343 }
7344 
7345 /* GPRS:        ?
7346  * UMTS:        3GPP TS 29.060 version 7.8.0 Release 7
7347  * MBMS Time To Data Transfer
7348  */
7349 /* Used for Diameter */
7350 static int
dissect_gtp_mbms_time_to_data_tr(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree,void * data _U_)7351 dissect_gtp_mbms_time_to_data_tr(tvbuff_t * tvb, packet_info * pinfo _U_, proto_tree * tree, void *data _U_)
7352 {
7353 
7354     int    offset = 0;
7355     guint8 time_2_dta_tr;
7356 
7357     time_2_dta_tr = tvb_get_guint8(tvb, offset) + 1;
7358     proto_tree_add_uint(tree, hf_gtp_time_2_dta_tr, tvb, offset, 1, time_2_dta_tr);
7359 
7360     return 3;
7361 
7362 }
7363 
7364 static int
decode_gtp_mbms_time_to_data_tr(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)7365 decode_gtp_mbms_time_to_data_tr(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7366 {
7367 
7368     guint16     length;
7369     proto_tree *ext_tree;
7370     guint8      time_2_dta_tr;
7371 
7372     length = tvb_get_ntohs(tvb, offset + 1);
7373     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_MBMS_TIME_TO_DATA_TR], NULL,
7374                         val_to_str_ext_const(GTP_EXT_MBMS_TIME_TO_DATA_TR, &gtpv1_val_ext, "Unknown"));
7375 
7376     offset++;
7377     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7378     offset = offset + 2;
7379     /* TODO add decoding of data
7380      * The MBMS Time To Data Transfer is defined in 3GPP TS 23.246 [26].
7381      * The MBMS Time To Data Transfer information element contains a
7382      * MBMS Time To Data Transfer allocated by the BM-SC.
7383      * The payload shall be encoded as per the MBMS-Time-To-Data-Transfer AVP
7384      * defined in 3GPP TS 29.061 [27], excluding the AVP Header fields
7385      * (as defined in IETF RFC 3588 [36], section 4.1).
7386      */
7387     /* The coding is specified as per the Time to MBMS Data Transfer Value Part Coding
7388      * of the Time to MBMS Data Transfer IE in 3GPP TS 48.018
7389      * Bits
7390      * 8 7 6 5 4 3 2 1
7391      * 0 0 0 0 0 0 0 0 1s
7392      * 0 0 0 0 0 0 0 1 2s
7393      * 0 0 0 0 0 0 1 0 3s
7394      * :
7395      * 1 1 1 1 1 1 1 1 256s
7396      */
7397     time_2_dta_tr = tvb_get_guint8(tvb, offset) + 1;
7398     proto_tree_add_uint(ext_tree, hf_gtp_time_2_dta_tr, tvb, offset, 1, time_2_dta_tr);
7399 
7400     return 3 + length;
7401 
7402 }
7403 
7404 /* GPRS:        ?
7405  * UMTS:        29.060 v6.11.0, chapter 7.7.71
7406  * PS Handover Request Context
7407  */
7408 static int
decode_gtp_ps_ho_req_ctx(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)7409 decode_gtp_ps_ho_req_ctx(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7410 {
7411 
7412     guint16     length;
7413     proto_tree *ext_tree;
7414 
7415     length = tvb_get_ntohs(tvb, offset + 1);
7416     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_PS_HO_REQ_CTX], NULL,
7417                 val_to_str_ext_const(GTP_EXT_PS_HO_REQ_CTX, &gtpv1_val_ext, "Unknown"));
7418 
7419     offset++;
7420     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7421     offset = offset + 2;
7422     /* TODO add decoding of data */
7423     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
7424 
7425     return 3 + length;
7426 
7427 }
7428 
7429 /* GPRS:        ?
7430  * UMTS:        29.060 v6.11.0, chapter 7.7.72
7431  * BSS Container
7432  */
7433 static int
decode_gtp_bss_cont(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)7434 decode_gtp_bss_cont(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7435 {
7436 
7437     guint16     length;
7438     proto_tree *ext_tree;
7439 
7440     length = tvb_get_ntohs(tvb, offset + 1);
7441     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_BSS_CONT], NULL,
7442                     val_to_str_ext_const(GTP_EXT_BSS_CONT, &gtpv1_val_ext, "Unknown"));
7443 
7444     offset++;
7445     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7446     offset = offset + 2;
7447     /* TODO add decoding of data */
7448     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
7449     /*
7450      * The content of this container is defined in 3GPP TS 48.018
7451      */
7452 
7453     return 3 + length;
7454 
7455 }
7456 
7457 /* GPRS:        ?
7458  * UMTS:        29.060 v6.11.0, chapter 7.7.73
7459  * Cell Identification
7460  */
7461 static int
decode_gtp_cell_id(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)7462 decode_gtp_cell_id(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7463 {
7464 
7465     guint16     length;
7466     proto_tree *ext_tree;
7467 
7468     length = tvb_get_ntohs(tvb, offset + 1);
7469     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_CELL_ID], NULL,
7470                                 val_to_str_ext_const(GTP_EXT_CELL_ID, &gtpv1_val_ext, "Unknown"));
7471 
7472     offset++;
7473     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7474     offset = offset + 2;
7475     /* TODO add decoding of data */
7476     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
7477     /*
7478      * for PS handover from A/Gb mode, the identification of a target cell (Cell ID 1) and the identification of the
7479      * source cell (Cell ID 2) as defined in 3GPP TS 48.018 [20].
7480      *
7481      * for PS handover from Iu mode, the identification of a target cell (Cell ID 1)) and the identification of the
7482      * source RNC (RNC-ID) as defined in 3GPP TS 48.018
7483      */
7484 
7485     return 3 + length;
7486 
7487 }
7488 
7489 /* GPRS:        ?
7490  * UMTS:        29.060 v6.11.0, chapter 7.7.74
7491  * PDU Numbers
7492  */
7493 static int
decode_gtp_pdu_no(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)7494 decode_gtp_pdu_no(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7495 {
7496 
7497     guint16     length;
7498     proto_tree *ext_tree;
7499 
7500     length = tvb_get_ntohs(tvb, offset + 1);
7501     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_PDU_NO], NULL,
7502                                             val_to_str_ext_const(GTP_EXT_PDU_NO, &gtpv1_val_ext, "Unknown"));
7503 
7504     offset++;
7505     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7506     offset = offset + 2;
7507     /* TODO add decoding of data */
7508     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
7509 
7510     return 3 + length;
7511 
7512 }
7513 
7514 /* GPRS:        ?
7515  * UMTS:        29.060 v6.11.0, chapter 7.7.75
7516  * BSSGP Cause
7517  */
7518 static int
decode_gtp_bssgp_cause(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)7519 decode_gtp_bssgp_cause(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7520 {
7521 
7522     guint16     length;
7523     proto_tree *ext_tree;
7524 
7525     length = tvb_get_ntohs(tvb, offset + 1);
7526     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_BSSGP_CAUSE], NULL,
7527                                         val_to_str_ext_const(GTP_EXT_BSSGP_CAUSE, &gtpv1_val_ext, "Unknown"));
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     /*
7534      * The BSSGP Cause information element contains the cause as defined in 3GPP TS 48.018
7535      */
7536     proto_tree_add_item(ext_tree, hf_gtp_bssgp_cause, tvb, offset, 1, ENC_BIG_ENDIAN);
7537 
7538     return 3 + length;
7539 
7540 }
7541 
7542 /*
7543  * Required MBMS bearer capabilities    7.7.76
7544  */
7545 static int
decode_gtp_mbms_bearer_cap(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)7546 decode_gtp_mbms_bearer_cap(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7547 {
7548     guint16     length;
7549     proto_tree *ext_tree;
7550 
7551     length = tvb_get_ntohs(tvb, offset + 1);
7552     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_REQ_MBMS_BEARER_CAP], NULL,
7553                                     val_to_str_ext_const(GTP_EXT_REQ_MBMS_BEARER_CAP, &gtpv1_val_ext, "Unknown"));
7554 
7555     offset++;
7556     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7557 #if 0 /* Fix Dead Store Warning */
7558     offset = offset + 2;
7559 #endif
7560     /* The payload shall be encoded as per the
7561      * Required-MBMS-Bearer-Capabilities AVP defined in 3GPP TS 29.061 [27],
7562      * excluding the AVP Header fields (as defined in IETF RFC 3588 [36], section 4.1).
7563      */
7564     /* TODO Add decoding (call Diameter dissector???) */
7565         return 3 + length;
7566 }
7567 
7568 /*
7569  * RIM Routing Address Discriminator    7.7.77
7570  */
7571 
7572 static const value_string gtp_bssgp_ra_discriminator_vals[] = {
7573     { 0, "A Cell Identifier is used to identify a GERAN cell" },
7574     { 1, "A Global RNC-ID is used to identify a UTRAN RNC" },
7575     { 2, "An eNB identifier is used to identify an E-UTRAN eNodeB or HeNB" },
7576     { 0, NULL }
7577 };
7578 
7579 static int
decode_gtp_rim_ra_disc(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)7580 decode_gtp_rim_ra_disc(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7581 {
7582 
7583     guint16     length;
7584     proto_tree *ext_tree;
7585 
7586     length = tvb_get_ntohs(tvb, offset + 1);
7587     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_RIM_ROUTING_ADDR_DISC], NULL,
7588                                 val_to_str_ext_const(GTP_EXT_RIM_ROUTING_ADDR_DISC, &gtpv1_val_ext, "Unknown"));
7589 
7590     offset++;
7591     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7592     offset = offset + 2;
7593     /* Octet 4 bits 4 - 1 is coded according to 3GPP TS 48.018 [20]
7594      * RIM Routing Information IE octet 3 bits 4 - 1.
7595      * Bits 8 - 5 are coded "0000".
7596      */
7597     proto_tree_add_item(ext_tree, hf_gtp_bssgp_ra_discriminator, tvb, offset, 1, ENC_BIG_ENDIAN);
7598 
7599     return 3 + length;
7600 
7601 }
7602 /*
7603  * List of set-up PFCs  7.7.78
7604  */
7605 static int
decode_gtp_lst_set_up_pfc(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)7606 decode_gtp_lst_set_up_pfc(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7607 {
7608 
7609     guint16     length;
7610     proto_tree *ext_tree;
7611 
7612     length = tvb_get_ntohs(tvb, offset + 1);
7613     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_LIST_OF_SETUP_PFCS], NULL,
7614                                         val_to_str_ext_const(GTP_EXT_LIST_OF_SETUP_PFCS, &gtpv1_val_ext, "Unknown"));
7615 
7616     offset++;
7617     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7618     offset = offset + 2;
7619     /* TODO add decoding of data */
7620     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
7621 
7622     return 3 + length;
7623 
7624 }
7625 /*
7626  * PS Handover XID Parameters   7.7.79
7627  */
7628 static int
decode_gtp_ps_handover_xid(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args _U_)7629 decode_gtp_ps_handover_xid(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
7630 {
7631 
7632     guint16     length;
7633     proto_tree *ext_tree;
7634     tvbuff_t   *next_tvb;
7635     guint8      sapi;
7636     guint8      xid_par_len;
7637 
7638     length = tvb_get_ntohs(tvb, offset + 1);
7639     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_PS_HANDOVER_XIP_PAR], NULL,
7640                                         val_to_str_ext_const(GTP_EXT_PS_HANDOVER_XIP_PAR, &gtpv1_val_ext, "Unknown"));
7641 
7642     offset++;
7643     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7644     offset = offset + 2;
7645 
7646     sapi = tvb_get_guint8(tvb, offset) & 0x0F;
7647     proto_tree_add_uint(ext_tree, hf_gtp_sapi, tvb, offset, 1, sapi);
7648     offset++;
7649 
7650     xid_par_len = tvb_get_guint8(tvb, offset);
7651     proto_tree_add_uint(ext_tree, hf_gtp_xid_par_len, tvb, offset, 1, xid_par_len);
7652     offset++;
7653 
7654     next_tvb = tvb_new_subset_remaining(tvb, offset);
7655     if (sndcpxid_handle)
7656         call_dissector(sndcpxid_handle, next_tvb, pinfo, tree);
7657     else
7658         call_data_dissector(next_tvb, pinfo, tree);
7659 
7660     return 4 + length;
7661 
7662 }
7663 
7664 /*
7665  * MS Info Change Reporting Action      7.7.80
7666  */
7667 static int
decode_gtp_ms_inf_chg_rep_act(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)7668 decode_gtp_ms_inf_chg_rep_act(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7669 {
7670 
7671     guint16     length;
7672     proto_tree *ext_tree;
7673 
7674     length = tvb_get_ntohs(tvb, offset + 1);
7675     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_MS_INF_CHG_REP_ACT], NULL,
7676                                         val_to_str_ext_const(GTP_EXT_MS_INF_CHG_REP_ACT, &gtpv1_val_ext, "Unknown"));
7677 
7678     offset++;
7679     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7680     offset = offset + 2;
7681 
7682     proto_tree_add_item(ext_tree, hf_gtp_rep_act_type, tvb, offset, 1, ENC_BIG_ENDIAN);
7683 
7684     return 3 + length;
7685 
7686 }
7687 /*
7688  * Direct Tunnel Flags  7.7.81
7689  */
7690 static int
decode_gtp_direct_tnl_flg(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)7691 decode_gtp_direct_tnl_flg(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7692 {
7693 
7694     guint16     length;
7695     proto_tree *ext_tree;
7696 
7697     length = tvb_get_ntohs(tvb, offset + 1);
7698     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_DIRECT_TUNNEL_FLGS], NULL,
7699                                         val_to_str_ext_const(GTP_EXT_DIRECT_TUNNEL_FLGS, &gtpv1_val_ext, "Unknown"));
7700 
7701     offset++;
7702     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7703     offset += 2;
7704 
7705     proto_tree_add_item(ext_tree, hf_gtp_ext_ei,   tvb, offset, 1, ENC_BIG_ENDIAN);
7706     proto_tree_add_item(ext_tree, hf_gtp_ext_gcsi, tvb, offset, 1, ENC_BIG_ENDIAN);
7707     proto_tree_add_item(ext_tree, hf_gtp_ext_dti,  tvb, offset, 1, ENC_BIG_ENDIAN);
7708     offset++;
7709 
7710     if (length == 1) {
7711         return 3 + length;
7712     }
7713     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
7714 
7715     return 3 + length;
7716 
7717 }
7718 /*
7719  * Correlation-ID       7.7.82
7720  */
7721 static int
decode_gtp_corrl_id(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)7722 decode_gtp_corrl_id(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7723 {
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_CORRELATION_ID], NULL,
7730                     val_to_str_ext_const(GTP_EXT_CORRELATION_ID, &gtpv1_val_ext, "Unknown"));
7731 
7732     offset++;
7733     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7734     offset = offset + 2;
7735 
7736     proto_tree_add_item(ext_tree, hf_gtp_correlation_id,  tvb, offset, 1, ENC_BIG_ENDIAN);
7737 
7738     return 3 + length;
7739 
7740 }
7741 /*
7742  * Bearer Control Mode  7.7.83
7743  * version 10.0.0
7744  */
7745 static const value_string gtp_pdp_bcm_type_vals[] = {
7746     {0, "MS_only"},
7747     {1, "MS/NW"},
7748     {0, NULL}
7749 };
7750 
7751 static int
decode_gtp_bearer_cntrl_mod(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)7752 decode_gtp_bearer_cntrl_mod(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7753 {
7754 
7755     guint16     length;
7756     proto_tree *ext_tree;
7757 
7758     length = tvb_get_ntohs(tvb, offset + 1);
7759     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length,  ett_gtp_ies[GTP_EXT_BEARER_CONTROL_MODE], NULL,
7760                                         val_to_str_ext_const(GTP_EXT_BEARER_CONTROL_MODE, &gtpv1_val_ext, "Unknown"));
7761 
7762     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7763 
7764     offset++;
7765     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7766     offset = offset + 2;
7767 
7768     proto_tree_add_item(ext_tree, hf_gtp_bcm, tvb, offset, 1, ENC_BIG_ENDIAN);
7769 
7770     return 3 + length;
7771 
7772 }
7773 
7774 /*
7775  * 7.7.84 MBMS Flow Identifier
7776  */
7777 static int
decode_gtp_mbms_flow_id(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)7778 decode_gtp_mbms_flow_id(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7779 {
7780     guint16     length;
7781     proto_tree *ext_tree;
7782 
7783     length = tvb_get_ntohs(tvb, offset + 1);
7784     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_MBMS_FLOW_ID], NULL,
7785                                         val_to_str_ext_const(GTP_EXT_MBMS_FLOW_ID, &gtpv1_val_ext, "Unknown"));
7786     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7787 
7788     offset++;
7789     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7790     offset = offset + 2;
7791 
7792     /* 4-n MBMS Flow Identifier */
7793     proto_tree_add_item(ext_tree, hf_gtp_mbms_flow_id, tvb, offset, length, ENC_NA);
7794 
7795 
7796     return 3 + length;
7797 }
7798 
7799 /*
7800  * 7.7.85 MBMS IP Multicast Distribution
7801  */
7802 
7803 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_)7804 decode_gtp_mbms_ip_mcast_dist(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7805 {
7806     guint16     length;
7807     proto_tree *ext_tree;
7808 
7809     length = tvb_get_ntohs(tvb, offset + 1);
7810     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_MBMS_IP_MCAST_DIST], NULL,
7811                                     val_to_str_ext_const(GTP_EXT_MBMS_IP_MCAST_DIST, &gtpv1_val_ext, "Unknown"));
7812     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7813 
7814     offset++;
7815     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7816     offset = offset + 2;
7817 
7818     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
7819 
7820     return 3 + length;
7821 }
7822 
7823 /*
7824  * 7.7.86 MBMS Distribution Acknowledgement
7825  */
7826 /* Table 7.7.86.1: Distribution Indication values */
7827 static const value_string gtp_mbms_dist_indic_vals[] = {
7828     {0, "No RNCs have accepted IP multicast distribution"},
7829     {1, "All RNCs have accepted IP multicast distribution"},
7830     {2, "Some RNCs have accepted IP multicast distribution"},
7831     {3, "Spare. For future use."},
7832     {0, NULL}
7833 };
7834 static int
decode_gtp_mbms_dist_ack(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)7835 decode_gtp_mbms_dist_ack(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_MBMS_DIST_ACK], NULL,
7842                                     val_to_str_ext_const(GTP_EXT_MBMS_DIST_ACK, &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 = offset + 2;
7848 
7849     /* Distribution Indication values */
7850     proto_tree_add_item(ext_tree, hf_gtp_mbms_dist_indic, tvb, offset, 1, ENC_BIG_ENDIAN);
7851 
7852     return 3 + length;
7853 }
7854 
7855 /*
7856  * 7.7.87 Reliable INTER RAT HANDOVER INFO
7857  */
7858 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_)7859 decode_gtp_reliable_irat_ho_inf(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_RELIABLE_IRAT_HO_INF], NULL,
7866                                         val_to_str_ext_const(GTP_EXT_RELIABLE_IRAT_HO_INF, &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 = 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 /*
7879  * 7.7.88 RFSP Index
7880  */
7881 static int
decode_gtp_rfsp_index(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)7882 decode_gtp_rfsp_index(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7883 {
7884     guint16     length, rfsp;
7885     proto_tree *ext_tree;
7886 
7887     length = tvb_get_ntohs(tvb, offset + 1);
7888     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_RFSP_INDEX], NULL,
7889                                         val_to_str_ext_const(GTP_EXT_RFSP_INDEX, &gtpv1_val_ext, "Unknown"));
7890     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7891 
7892     offset++;
7893     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7894     offset = offset + 2;
7895 
7896     rfsp = tvb_get_ntohs(tvb, offset);
7897     proto_tree_add_uint(ext_tree, hf_gtp_rfsp_index, tvb, offset, length, rfsp+1);
7898 
7899     return 3 + length;
7900 }
7901 /*
7902  * 7.7.89 PDP Type
7903  */
7904 /*
7905  * 7.7.90 Fully Qualified Domain Name (FQDN)
7906  */
7907 static int
decode_gtp_fqdn(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)7908 decode_gtp_fqdn(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7909 {
7910 
7911     guint16     length;
7912     proto_tree *ext_tree;
7913 
7914     length = tvb_get_ntohs(tvb, offset + 1);
7915 
7916     ext_tree = proto_tree_add_subtree(tree, tvb, offset, length + 3, ett_gtp_ies[GTP_EXT_FQDN], NULL,
7917                                     val_to_str_ext_const(GTP_EXT_FQDN, &gtp_val_ext, "Unknown field"));
7918     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7919 
7920     proto_tree_add_item(ext_tree, hf_gtp_fqdn_length, tvb, offset + 1, 2, ENC_BIG_ENDIAN);
7921     decode_fqdn(tvb, offset + 3, length, ext_tree, NULL);
7922 
7923     return 3 + length;
7924 }
7925 
7926 /*
7927  * 7.7.91 Evolved Allocation/Retention Priority I
7928  */
7929 static int
decode_gtp_evolved_allc_rtn_p1(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)7930 decode_gtp_evolved_allc_rtn_p1(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7931 {
7932 
7933     guint16     length;
7934     proto_tree *ext_tree;
7935 
7936     length = tvb_get_ntohs(tvb, offset + 1);
7937     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_EVO_ALLO_RETE_P1], NULL,
7938                                         val_to_str_ext_const(GTP_EXT_EVO_ALLO_RETE_P1, &gtpv1_val_ext, "Unknown"));
7939     proto_tree_add_item(ext_tree, hf_gtp_ie_id,      tvb, offset, 1, ENC_BIG_ENDIAN);
7940 
7941     offset++;
7942     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7943     offset += 2;
7944 
7945     proto_tree_add_item(ext_tree, hf_gtp_earp_pci,   tvb, offset, 1, ENC_BIG_ENDIAN);
7946     proto_tree_add_item(ext_tree, hf_gtp_earp_pl,    tvb, offset, 1, ENC_BIG_ENDIAN);
7947     proto_tree_add_item(ext_tree, hf_gtp_earp_pvi,   tvb, offset, 1, ENC_BIG_ENDIAN);
7948 
7949     return 3 + length;
7950 
7951 
7952 }
7953 
7954 /*
7955  * 7.7.92 Evolved Allocation/Retention Priority II
7956  */
7957 static int
decode_gtp_evolved_allc_rtn_p2(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)7958 decode_gtp_evolved_allc_rtn_p2(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7959 {
7960 
7961     guint16     length;
7962     proto_tree *ext_tree;
7963 
7964     length = tvb_get_ntohs(tvb, offset + 1);
7965     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_EVO_ALLO_RETE_P2], NULL,
7966                                         val_to_str_ext_const(GTP_EXT_EVO_ALLO_RETE_P2, &gtpv1_val_ext, "Unknown"));
7967     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7968 
7969     offset++;
7970     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
7971     offset = offset + 2;
7972 
7973     proto_tree_add_item(ext_tree, hf_gtp_nsapi, tvb, offset, 1, ENC_BIG_ENDIAN);
7974     offset++;
7975 
7976     proto_tree_add_item(ext_tree, hf_gtp_earp_pci, tvb, offset, 1, ENC_BIG_ENDIAN);
7977     proto_tree_add_item(ext_tree, hf_gtp_earp_pl,  tvb, offset, 1, ENC_BIG_ENDIAN);
7978     proto_tree_add_item(ext_tree, hf_gtp_earp_pvi, tvb, offset, 1, ENC_BIG_ENDIAN);
7979 
7980     return 3 + length;
7981 
7982 
7983 }
7984 
7985 /*
7986  * 7.7.93 Extended Common Flags
7987  */
7988 static int
decode_gtp_extended_common_flgs(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)7989 decode_gtp_extended_common_flgs(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
7990 {
7991     guint16     length;
7992     proto_tree *ext_tree;
7993 
7994     length = tvb_get_ntohs(tvb, offset + 1);
7995     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_EXTENDED_COMMON_FLGS], NULL,
7996                                         val_to_str_ext_const(GTP_EXT_EXTENDED_COMMON_FLGS, &gtpv1_val_ext, "Unknown"));
7997     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
7998 
7999     offset++;
8000     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8001     offset = offset + 2;
8002 
8003     proto_tree_add_item(ext_tree, hf_gtp_ext_comm_flags_uasi, tvb, offset, 1, ENC_BIG_ENDIAN);
8004     offset++;
8005 
8006     if(length > 1){
8007         proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length-1);
8008     }
8009 
8010     return 3 + length;
8011 }
8012 
8013 /*
8014  * 7.7.94 User CSG Information (UCI)
8015  */
8016 static int
decode_gtp_uci(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)8017 decode_gtp_uci(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8018 {
8019     guint16     length;
8020     proto_tree *ext_tree;
8021 
8022     length = tvb_get_ntohs(tvb, offset + 1);
8023     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_UCI], NULL,
8024                                         val_to_str_ext_const(GTP_EXT_UCI, &gtpv1_val_ext, "Unknown"));
8025     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
8026 
8027     offset++;
8028     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8029     offset = offset + 2;
8030 
8031     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
8032 
8033     return 3 + length;
8034 }
8035 
8036 /*
8037  * 7.7.95 CSG Information Reporting Action
8038  */
8039 
8040 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_)8041 decode_gtp_csg_inf_rep_act(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8042 {
8043     guint16     length;
8044     proto_tree *ext_tree;
8045 
8046     length = tvb_get_ntohs(tvb, offset + 1);
8047     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_CSG_INF_REP_ACT], NULL,
8048                                             val_to_str_ext_const(GTP_EXT_CSG_INF_REP_ACT, &gtpv1_val_ext, "Unknown"));
8049     proto_tree_add_item(ext_tree, hf_gtp_ie_id,      tvb, offset, 1, ENC_BIG_ENDIAN);
8050 
8051     offset++;
8052     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8053     offset = offset + 2;
8054 
8055     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
8056 
8057     return 3 + length;
8058 }
8059 /*
8060  * 7.7.96 CSG ID
8061  */
8062 
8063 static int
decode_gtp_csg_id(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)8064 decode_gtp_csg_id(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8065 {
8066     guint16     length;
8067     proto_tree *ext_tree;
8068 
8069     length = tvb_get_ntohs(tvb, offset + 1);
8070     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_CSG_ID], NULL,
8071                                             val_to_str_ext_const(GTP_EXT_CSG_ID, &gtpv1_val_ext, "Unknown"));
8072     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
8073 
8074     offset++;
8075     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8076     offset = offset + 2;
8077 
8078     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
8079 
8080     return 3 + length;
8081 }
8082 /*
8083  * 7.7.97 CSG Membership Indication (CMI)
8084  */
8085 static int
decode_gtp_cmi(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)8086 decode_gtp_cmi(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8087 {
8088     guint16     length;
8089     proto_tree *ext_tree;
8090 
8091     length = tvb_get_ntohs(tvb, offset + 1);
8092     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_CMI], NULL,
8093                                         val_to_str_ext_const(GTP_EXT_CMI, &gtpv1_val_ext, "Unknown"));
8094     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
8095 
8096     offset++;
8097     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8098     offset = offset + 2;
8099 
8100     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
8101 
8102     return 3 + length;
8103 }
8104 /*
8105  * 7.7.98 APN Aggregate Maximum Bit Rate (APN-AMBR)
8106  */
8107 static int
decode_gtp_apn_ambr(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)8108 decode_gtp_apn_ambr(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8109 {
8110     guint16     length;
8111     proto_tree *ext_tree;
8112 
8113     length = tvb_get_ntohs(tvb, offset + 1);
8114     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_RELIABLE_IRAT_HO_INF], NULL,
8115                                         val_to_str_ext_const(GTP_EXT_AMBR, &gtpv1_val_ext, "Unknown"));
8116     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
8117 
8118     offset++;
8119     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8120     offset = offset + 2;
8121 
8122     /* APN Aggregate Maximum Bit Rate (APN-AMBR) is defined in clause 9.9.4.2 of 3GPP TS 24.301 [42], but shall be
8123      * formatted as shown in Figure 7.7.98-1 as Unsigned32 binary integer values in kbps (1000 bits per second).
8124      */
8125     /* 4 to 7 APN-AMBR for Uplink */
8126     proto_tree_add_item(ext_tree, hf_gtp_ext_apn_ambr_ul, tvb, offset, 4, ENC_BIG_ENDIAN);
8127     offset+=4;
8128     /* 8 to 11 APN-AMBR for Downlink */
8129     proto_tree_add_item(ext_tree, hf_gtp_ext_apn_ambr_dl, tvb, offset, 4, ENC_BIG_ENDIAN);
8130 
8131     return 3 + length;
8132 }
8133 /*
8134  * 7.7.99 UE Network Capability
8135  */
8136 static int
decode_gtp_ue_network_cap(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args _U_)8137 decode_gtp_ue_network_cap(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
8138 {
8139     guint16     length;
8140     proto_tree *ext_tree;
8141 
8142     length = tvb_get_ntohs(tvb, offset + 1);
8143     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_UE_NETWORK_CAP], NULL,
8144                                         val_to_str_ext_const(GTP_EXT_UE_NETWORK_CAP, &gtpv1_val_ext, "Unknown"));
8145 
8146     offset++;
8147     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8148     offset = offset + 2;
8149 
8150     de_emm_ue_net_cap(tvb, ext_tree, pinfo, offset, length, NULL, 0);
8151 
8152     return 3 + length;
8153 }
8154 /*
8155  * 7.7.100 UE-AMBR
8156  */
8157 
8158 static int
decode_gtp_ue_ambr(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)8159 decode_gtp_ue_ambr(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8160 {
8161     guint16     length;
8162     proto_tree *ext_tree;
8163 
8164     length = tvb_get_ntohs(tvb, offset + 1);
8165     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_APN_AMBR_WITH_NSAPI], NULL,
8166                                         val_to_str_ext_const(GTP_EXT_APN_AMBR_WITH_NSAPI, &gtpv1_val_ext, "Unknown"));
8167     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
8168 
8169     offset++;
8170     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8171     offset = offset + 2;
8172 
8173     /* 4 to 7 Subscribed UE-AMBR for Uplink */
8174     proto_tree_add_item(ext_tree, hf_gtp_ext_sub_ue_ambr_ul, tvb, offset, 4, ENC_BIG_ENDIAN);
8175     offset+=4;
8176     /* 8 to 11 Subscribed UE-AMBR for Downlink */
8177     proto_tree_add_item(ext_tree, hf_gtp_ext_sub_ue_ambr_dl, tvb, offset, 4, ENC_BIG_ENDIAN);
8178     offset+=4;
8179 
8180     /* Authorized UE-AMBR for Uplink and Downlink fields are present in the IE only if the sender has their valid values
8181      * available. Otherwise, the fields from m to (n+3) shall not be present.
8182      */
8183     if(offset >= length)
8184         return 3 + length;
8185 
8186     /* m to (m+3) Authorized UE-AMBR for Uplink */
8187     proto_tree_add_item(ext_tree, hf_gtp_ext_auth_ue_ambr_ul, tvb, offset, 4, ENC_BIG_ENDIAN);
8188     offset+=4;
8189 
8190     /* (m+4) to (n+3) Authorized UE-AMBR for Downlink */
8191     proto_tree_add_item(ext_tree, hf_gtp_ext_auth_ue_ambr_dl, tvb, offset, 4, ENC_BIG_ENDIAN);
8192 
8193     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
8194 
8195     return 3 + length;
8196 }
8197 
8198 /*
8199  * 7.7.101 APN-AMBR with NSAPI
8200  */
8201 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_)8202 decode_gtp_apn_ambr_with_nsapi(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8203 {
8204     guint16     length;
8205     proto_tree *ext_tree;
8206 
8207     length = tvb_get_ntohs(tvb, offset + 1);
8208     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_UE_AMBR], NULL,
8209                                         val_to_str_ext_const(GTP_EXT_UE_AMBR, &gtpv1_val_ext, "Unknown"));
8210     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
8211 
8212     offset++;
8213     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8214     offset = offset + 2;
8215 
8216     proto_tree_add_item(ext_tree, hf_gtp_nsapi, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
8217     offset++;
8218 
8219     /* 5 to 8 Authorized APN-AMBR for Uplink */
8220     proto_tree_add_item(ext_tree, hf_gtp_ext_auth_apn_ambr_ul, tvb, offset, 4, ENC_BIG_ENDIAN);
8221     offset+=4;
8222 
8223     /* 9 to12 Authorized APN-AMBR for Downlink */
8224     proto_tree_add_item(ext_tree, hf_gtp_ext_auth_apn_ambr_dl, tvb, offset, 4, ENC_BIG_ENDIAN);
8225 
8226     return 3 + length;
8227 }
8228 /*
8229  * 7.7.102 GGSN Back-Off Time
8230  */
8231 /* Table 7.7.102.1: GGSN Back-Off Time information element */
8232 static const value_string gtp_ggsn_back_off_time_units_vals[] = {
8233     {0, "value is incremented in multiples of 2 seconds"},
8234     {1, "value is incremented in multiples of 1 minute"},
8235     {2, "value is incremented in multiples of 10 minutes"},
8236     {3, "value is incremented in multiples of 1 hour"},
8237     {4, "value is incremented in multiples of 10 hours"},
8238     {5, "value indicates that the timer is infinite"},
8239     {0, NULL}
8240 };
8241 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_)8242 decode_gtp_ggsn_back_off_time(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8243 {
8244     guint16     length;
8245     proto_tree *ext_tree;
8246 
8247     length = tvb_get_ntohs(tvb, offset + 1);
8248     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_GGSN_BACK_OFF_TIME], NULL,
8249                                         val_to_str_ext_const(GTP_EXT_GGSN_BACK_OFF_TIME, &gtpv1_val_ext, "Unknown"));
8250     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
8251 
8252     offset++;
8253     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8254     offset += 2;
8255 
8256     /* 4 Timer unit Timer value */
8257     proto_tree_add_item(ext_tree, hf_gtp_ext_ggsn_back_off_time_units, tvb, offset, 1, ENC_BIG_ENDIAN);
8258     proto_tree_add_item(ext_tree, hf_gtp_ext_ggsn_back_off_timer, tvb, offset, 1, ENC_BIG_ENDIAN);
8259 
8260     return 3 + length;
8261 }
8262 
8263 /*
8264  * 7.7.103 Signalling Priority Indication
8265  */
8266 
8267 static int
decode_gtp_sig_pri_ind(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)8268 decode_gtp_sig_pri_ind(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8269 {
8270     guint16     length;
8271     proto_tree *ext_tree;
8272 
8273     length = tvb_get_ntohs(tvb, offset + 1);
8274     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_SIG_PRI_IND], NULL,
8275                                     val_to_str_ext_const(GTP_EXT_SIG_PRI_IND, &gtpv1_val_ext, "Unknown"));
8276     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
8277 
8278     offset++;
8279     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8280     offset += 2;
8281 
8282     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
8283 
8284     return 3 + length;
8285 }
8286 /*
8287  * 7.7.104 Signalling Priority Indication with NSAPI
8288  */
8289 
8290 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_)8291 decode_gtp_sig_pri_ind_w_nsapi(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8292 {
8293     guint16     length;
8294     proto_tree *ext_tree;
8295 
8296     length = tvb_get_ntohs(tvb, offset + 1);
8297     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_SIG_PRI_IND_W_NSAPI], NULL,
8298                                             val_to_str_ext_const(GTP_EXT_SIG_PRI_IND_W_NSAPI, &gtpv1_val_ext, "Unknown"));
8299     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
8300 
8301     offset++;
8302     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8303     offset += 2;
8304 
8305     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
8306 
8307     return 3 + length;
8308 }
8309 /*
8310  * 7.7.105 Higher bitrates than 16 Mbps flag
8311  */
8312 static const value_string gtp_higher_br_16mb_flg_vals[] = {
8313     {0, "Not allowed"},
8314     {1, "Allowed"},
8315     {0, NULL}
8316 };
8317 
8318 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_)8319 decode_gtp_higher_br_16mb_flg(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8320 {
8321     guint16     length;
8322     proto_tree *ext_tree;
8323 
8324     length = tvb_get_ntohs(tvb, offset + 1);
8325     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_HIGHER_BR_16MB_FLG], NULL,
8326                                           val_to_str_ext_const(GTP_EXT_HIGHER_BR_16MB_FLG, &gtpv1_val_ext, "Unknown"));
8327     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
8328 
8329     offset++;
8330     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8331     offset += 2;
8332 
8333     /* Higher bitrates than 16 Mbps flag */
8334     proto_tree_add_item(ext_tree, hf_gtp_higher_br_16mb_flg, tvb, offset, 1, ENC_BIG_ENDIAN);
8335 
8336     return 3 + length;
8337 }
8338 /*
8339  * 7.7.106 Max MBR/APN-AMBR
8340  */
8341 
8342 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_)8343 decode_gtp_max_mbr_apn_ambr(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8344 {
8345     guint16     length;
8346     proto_tree *ext_tree;
8347     guint32     max_ul;
8348     guint32     max_dl;
8349 
8350     length = tvb_get_ntohs(tvb, offset + 1);
8351     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_MAX_MBR_APN_AMBR], NULL,
8352                                     val_to_str_ext_const(GTP_EXT_MAX_MBR_APN_AMBR, &gtpv1_val_ext, "Unknown"));
8353     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
8354 
8355     offset++;
8356     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8357     offset = offset + 2;
8358 
8359         /* Max MBR/APN-AMBR for uplink */
8360     max_ul = tvb_get_ntohl(tvb, offset);
8361     proto_tree_add_uint_format_value(ext_tree, hf_gtp_max_mbr_apn_ambr_ul, tvb, offset, 4, max_ul, "%u %s",
8362                                (max_ul) > 1000 ? max_ul/1000 : max_ul,
8363                                (max_ul) > 1000 ? "Mbps" : "kbps");
8364 
8365     offset += 4;
8366 
8367     /* Max MBR/APN-AMBR for downlink */
8368     max_dl = tvb_get_ntohl(tvb, offset);
8369     proto_tree_add_uint_format_value(ext_tree, hf_gtp_max_mbr_apn_ambr_dl, tvb, offset, 4, max_dl, "%u %s",
8370                                 (max_dl) > 1000 ? max_dl/1000 : max_dl,
8371                                 (max_dl) > 1000 ? "Mbps" : "kbps");
8372 
8373     return 3 + length;
8374 }
8375 /*
8376  * 7.7.107 Additional MM context for SRVCC
8377  */
8378 
8379 static int
decode_gtp_add_mm_ctx_srvcc(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args _U_)8380 decode_gtp_add_mm_ctx_srvcc(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
8381 {
8382     guint16     length;
8383     proto_tree *ext_tree;
8384     guint32 inf_len;
8385 
8386     length = tvb_get_ntohs(tvb, offset + 1);
8387     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_ADD_MM_CTX_SRVCC], NULL,
8388                                         val_to_str_ext_const(GTP_EXT_ADD_MM_CTX_SRVCC, &gtpv1_val_ext, "Unknown"));
8389     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
8390 
8391     offset++;
8392     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8393     offset += 2;
8394 
8395     /* Length of the Mobile Station Classmark 2 */
8396     proto_tree_add_item_ret_uint(ext_tree, hf_gtp_ms_cm_2_len, tvb, offset, 1, ENC_BIG_ENDIAN, &inf_len);
8397     offset++;
8398     if (inf_len > 0) {
8399         offset += de_ms_cm_2(tvb, ext_tree, pinfo, offset, inf_len, NULL, 0);
8400     }
8401 
8402     /* Length of the Mobile Station Classmark 3 */
8403     proto_tree_add_item_ret_uint(ext_tree, hf_gtp_ms_cm_3_len, tvb, offset, 1, ENC_BIG_ENDIAN, &inf_len);
8404     offset++;
8405     if (inf_len > 0) {
8406         offset += de_ms_cm_3(tvb, ext_tree, pinfo, offset, inf_len, NULL, 0);
8407     }
8408 
8409     /* Length of the Supported Codec List */
8410     proto_tree_add_item_ret_uint(ext_tree, hf_gtp_sup_codec_lst_len, tvb, offset, 1, ENC_BIG_ENDIAN, &inf_len);
8411     offset++;
8412     if (inf_len > 0) {
8413         de_sup_codec_list(tvb, ext_tree, pinfo, offset, inf_len, NULL, 0);
8414     }
8415 
8416     return 3 + length;
8417 }
8418 
8419 /*
8420  * 7.7.108 Additional flags for SRVCC
8421  */
8422 
8423 static int
decode_gtp_add_flgs_srvcc(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)8424 decode_gtp_add_flgs_srvcc(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8425 {
8426     guint16     length;
8427     proto_tree *ext_tree;
8428 
8429     length = tvb_get_ntohs(tvb, offset + 1);
8430     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_ADD_FLGS_SRVCC], NULL,
8431                                         val_to_str_ext_const(GTP_EXT_ADD_FLGS_SRVCC, &gtpv1_val_ext, "Unknown"));
8432     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
8433 
8434     offset++;
8435     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8436     offset += 2;
8437 
8438     /* 4    Spare ICS */
8439     proto_tree_add_item(ext_tree, hf_gtp_add_flg_for_srvcc_ics, tvb, offset, 1, ENC_BIG_ENDIAN);
8440 
8441     return 3 + length;
8442 }
8443 /*
8444  * 7.7.109 STN-SR
8445  */
8446 static int
decode_gtp_stn_sr(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)8447 decode_gtp_stn_sr(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8448 {
8449     guint16     length;
8450     proto_tree *ext_tree;
8451 
8452     length = tvb_get_ntohs(tvb, offset + 1);
8453     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_STN_SR], NULL,
8454                                         val_to_str_ext_const(GTP_EXT_STN_SR, &gtpv1_val_ext, "Unknown"));
8455     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
8456 
8457     offset++;
8458     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8459     offset += 2;
8460 
8461     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
8462 
8463     return 3 + length;
8464 }
8465 
8466 /*
8467  * 7.7.110 C-MSISDN
8468  */
8469 
8470 static int
decode_gtp_c_msisdn(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)8471 decode_gtp_c_msisdn(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8472 {
8473     guint16     length;
8474     proto_tree *ext_tree;
8475 
8476     length = tvb_get_ntohs(tvb, offset + 1);
8477     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_C_MSISDN], NULL,
8478                                         val_to_str_ext_const(GTP_EXT_C_MSISDN, &gtpv1_val_ext, "Unknown"));
8479     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
8480 
8481     offset++;
8482     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8483     offset += 2;
8484 
8485     dissect_e164_msisdn(tvb, ext_tree, offset, length, E164_ENC_BCD);
8486 
8487     return 3 + length;
8488 }
8489 /*
8490  * 7.7.111 Extended RANAP Cause
8491  */
8492 static int
decode_gtp_ext_ranap_cause(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args _U_)8493 decode_gtp_ext_ranap_cause(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
8494 {
8495     guint16     length;
8496     proto_tree *ext_tree;
8497     tvbuff_t *new_tvb;
8498 
8499     length = tvb_get_ntohs(tvb, offset + 1);
8500     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_EXT_RANAP_CAUSE], NULL,
8501                                         val_to_str_ext_const(GTP_EXT_EXT_RANAP_CAUSE, &gtpv1_val_ext, "Unknown"));
8502     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
8503 
8504     offset++;
8505     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8506     offset += 2;
8507 
8508     new_tvb = tvb_new_subset_remaining(tvb, offset);
8509 
8510     dissect_ranap_Cause_PDU(new_tvb, pinfo, ext_tree, NULL);
8511 
8512     return 3 + length;
8513 }
8514 
8515 /*
8516  * 7.7.112 eNodeB ID
8517  */
8518 
8519 static const value_string gtp_enb_type_vals[] = {
8520     { 0, "Macro eNodeB ID" },
8521     { 1, "Home eNodeB ID" },
8522     { 0, NULL }
8523 };
8524 
8525 static int
decode_gtp_ext_enodeb_id(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)8526 decode_gtp_ext_enodeb_id(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8527 {
8528     guint16     length;
8529     proto_tree *ext_tree;
8530     guint32 enb_type;
8531 
8532     length = tvb_get_ntohs(tvb, offset + 1);
8533     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_ENODEB_ID], NULL,
8534         val_to_str_ext_const(GTP_EXT_ENODEB_ID, &gtpv1_val_ext, "Unknown"));
8535     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
8536 
8537     offset++;
8538     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8539     offset += 2;
8540 
8541     /* eNodeB Type */
8542     proto_tree_add_item_ret_uint(ext_tree, hf_gtp_ext_enb_type, tvb, offset, 1, ENC_BIG_ENDIAN, &enb_type);
8543     offset++;
8544 
8545     dissect_e212_mcc_mnc(tvb, pinfo, ext_tree, offset, E212_NONE, TRUE);
8546     offset += 3;
8547 
8548     switch (enb_type){
8549     case 0:
8550         /* Macro eNodeB ID */
8551         proto_tree_add_item(ext_tree, hf_gtp_macro_enodeb_id, tvb, offset, 3, ENC_BIG_ENDIAN);
8552         offset += 3;
8553         proto_tree_add_item(ext_tree, hf_gtp_tac, tvb, offset, 2, ENC_BIG_ENDIAN);
8554         break;
8555     case 1:
8556         /* Home eNodeB ID */
8557         proto_tree_add_item(ext_tree, hf_gtp_home_enodeb_id, tvb, offset, 4, ENC_BIG_ENDIAN);
8558         offset += 4;
8559         proto_tree_add_item(ext_tree, hf_gtp_tac, tvb, offset, 2, ENC_BIG_ENDIAN);
8560         break;
8561     default:
8562         proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length - 4);
8563         break;
8564     }
8565 
8566     return 3 + length;
8567 }
8568 
8569 /*
8570  * 7.7.113 Selection Mode with NSAPI
8571  */
8572 
8573 static const value_string gtp_sel_mode_vals[] = {
8574     { 0, "MS or network provided APN, subscription verified" },
8575     { 1, "MS provided APN, subscription not verified" },
8576     { 2, "Network provided APN, subscription not verified" },
8577     { 3, "For future use. Shall not be sent. If received, shall be interpreted as the value 2" },
8578     { 0, NULL }
8579 };
8580 
8581 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_)8582 decode_gtp_ext_sel_mode_w_nsapi(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8583 {
8584     guint16     length;
8585     proto_tree *ext_tree;
8586 
8587     length = tvb_get_ntohs(tvb, offset + 1);
8588     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_SEL_MODE_W_NSAPI], NULL,
8589         val_to_str_ext_const(GTP_EXT_SEL_MODE_W_NSAPI, &gtpv1_val_ext, "Unknown"));
8590     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
8591 
8592     offset++;
8593     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8594     offset += 2;
8595 
8596     proto_tree_add_item(ext_tree, hf_gtp_nsapi, tvb, offset, 1, ENC_BIG_ENDIAN);
8597     offset++;
8598 
8599     proto_tree_add_item(ext_tree, hf_gtp_sel_mode_val, tvb, offset, 1, ENC_BIG_ENDIAN);
8600 
8601 
8602     return 3 + length;
8603 }
8604 /*
8605  * 7.7.114 ULI Timestamp
8606  */
8607 static int
decode_gtp_ext_uli_timestamp(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)8608 decode_gtp_ext_uli_timestamp(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8609 {
8610     guint16     length;
8611     proto_tree *ext_tree;
8612 
8613     length = tvb_get_ntohs(tvb, offset + 1);
8614     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_ULI_TIMESTAMP], NULL,
8615         val_to_str_ext_const(GTP_EXT_ULI_TIMESTAMP, &gtpv1_val_ext, "Unknown"));
8616     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
8617 
8618     offset++;
8619     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8620     offset += 2;
8621 
8622     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
8623 
8624     return 3 + length;
8625 }
8626 
8627 /*
8628  * 7.7.115 Local Home Network ID (LHN-ID) with NSAPI
8629  */
8630 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_)8631 decode_gtp_ext_lhn_id_w_sapi(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8632 {
8633     guint16     length;
8634     proto_tree *ext_tree;
8635 
8636     length = tvb_get_ntohs(tvb, offset + 1);
8637     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_LHN_ID_W_SAPI], NULL,
8638         val_to_str_ext_const(GTP_EXT_LHN_ID_W_SAPI, &gtpv1_val_ext, "Unknown"));
8639     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
8640 
8641     offset++;
8642     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8643     offset += 2;
8644 
8645     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
8646 
8647     return 3 + length;
8648 }
8649 /*
8650  * 7.7.116 CN Operator Selection Entity
8651  */
8652 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_)8653 decode_gtp_ext_cn_op_sel_entity(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8654 {
8655     guint16     length;
8656     proto_tree *ext_tree;
8657 
8658     length = tvb_get_ntohs(tvb, offset + 1);
8659     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_CN_OP_SEL_ENTITY], NULL,
8660         val_to_str_ext_const(GTP_EXT_CN_OP_SEL_ENTITY, &gtpv1_val_ext, "Unknown"));
8661     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
8662 
8663     offset++;
8664     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8665     offset += 2;
8666 
8667     proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length);
8668 
8669     return 3 + length;
8670 }
8671 
8672 /*
8673  * 7.7.118 Extended Common Flags II
8674  */
8675 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_)8676 decode_gtp_extended_common_flgs_II(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8677 {
8678     guint16     length;
8679     proto_tree *ext_tree;
8680 
8681     length = tvb_get_ntohs(tvb, offset + 1);
8682     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_EXT_COMMON_FLGS_II], NULL,
8683                                         val_to_str_ext_const(GTP_EXT_EXT_COMMON_FLGS_II, &gtpv1_val_ext, "Unknown"));
8684     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
8685 
8686     offset++;
8687     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8688     offset = offset + 2;
8689 
8690     proto_tree_add_item(ext_tree, hf_gtp_ext_comm_flags_II_pnsi, tvb, offset, 1, ENC_BIG_ENDIAN);
8691     proto_tree_add_item(ext_tree, hf_gtp_ext_comm_flags_II_dtci, tvb, offset, 1, ENC_BIG_ENDIAN);
8692     proto_tree_add_item(ext_tree, hf_gtp_ext_comm_flags_II_pmtsmi, tvb, offset, 1, ENC_BIG_ENDIAN);
8693     proto_tree_add_item(ext_tree, hf_gtp_ext_comm_flags_II_spare, tvb, offset, 1, ENC_BIG_ENDIAN);
8694 
8695     offset++;
8696 
8697     if(length > 1){
8698         proto_tree_add_expert(ext_tree, pinfo, &ei_gtp_undecoded, tvb, offset, length-1);
8699     }
8700 
8701     return 3 + length;
8702 }
8703 
8704 /*
8705  * 7.7.119 Node Identifier
8706  */
8707 static int
decode_gtp_ext_node_id(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)8708 decode_gtp_ext_node_id(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8709 {
8710     guint16     length;
8711     guint32     item_len;
8712     proto_tree *ext_tree;
8713 
8714     length = tvb_get_ntohs(tvb, offset + 1);
8715     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_ies[GTP_EXT_NODE_IDENTIFIER], NULL,
8716         val_to_str_ext_const(GTP_EXT_NODE_IDENTIFIER, &gtpv1_val_ext, "Unknown"));
8717     proto_tree_add_item(ext_tree, hf_gtp_ie_id, tvb, offset, 1, ENC_BIG_ENDIAN);
8718 
8719     offset++;
8720     proto_tree_add_item(ext_tree, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8721     offset += 2;
8722 
8723     /* The Node Name and Node Realm are Diameter Identities, which are
8724      * specified by RFC 6733 to be in ASCII for compatibility with DNS.
8725      */
8726     proto_tree_add_item_ret_length(ext_tree, hf_gtp_node_name, tvb, offset, 1, ENC_ASCII | ENC_NA, &item_len);
8727     offset += item_len;
8728     proto_tree_add_item_ret_length(ext_tree, hf_gtp_node_realm, tvb, offset, 1, ENC_ASCII | ENC_NA, &item_len);
8729 
8730     return 3 + length;
8731 }
8732 
8733 
8734 static int
decode_gtp_rel_pack(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)8735 decode_gtp_rel_pack(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8736 {
8737 
8738     guint16     length, n, number;
8739     proto_tree *ext_tree_rel_pack;
8740 
8741     length = tvb_get_ntohs(tvb, offset + 1);
8742 
8743     ext_tree_rel_pack = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_rel_pack, NULL,
8744                                     "Sequence numbers of released packets IE");
8745 
8746     n = 0;
8747 
8748     while (n < length) {
8749 
8750         number = tvb_get_ntohs(tvb, offset + 3 + n);
8751         proto_tree_add_uint_format(ext_tree_rel_pack, hf_gtp_seq_num_released, tvb, offset + 3 + n, 2, number, "%u", number);
8752         n = n + 2;
8753 
8754     }
8755 
8756     return 3 + length;
8757 }
8758 
8759 /* GPRS:        12.15
8760  * UMTS:        33.015
8761  */
8762 static int
decode_gtp_can_pack(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)8763 decode_gtp_can_pack(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8764 {
8765 
8766     guint16     length, n, number;
8767     proto_tree *ext_tree_can_pack;
8768 
8769     length = tvb_get_ntohs(tvb, offset + 1);
8770 
8771     ext_tree_can_pack = proto_tree_add_subtree(tree, tvb, offset, 3 + length, ett_gtp_can_pack, NULL,
8772                                         "Sequence numbers of cancelled  packets IE");
8773 
8774     n = 0;
8775 
8776     while (n < length) {
8777 
8778         number = tvb_get_ntohs(tvb, offset + 3 + n);
8779         proto_tree_add_uint_format(ext_tree_can_pack, hf_gtp_seq_num_canceled, tvb, offset + 3 + n, 2, number, "%u", number);
8780         n += 2;
8781     }
8782 
8783     return 3 + length;
8784 }
8785 
8786 /* CDRs dissector
8787  * 3GPP TS 32.295 version 9.0.0 Release 9
8788  */
8789 
8790 
8791 static const value_string gtp_cdr_fmt_vals[] = {
8792     {1, "Basic Encoding Rules (BER)"},
8793     {2, "Unaligned basic Packed Encoding Rules (PER)"},
8794     {3, "Aligned basic Packed Encoding Rules (PER)"},
8795     {0, NULL}
8796 };
8797 static int
decode_gtp_data_req(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args _U_)8798 decode_gtp_data_req(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
8799 {
8800 
8801     guint16     length, cdr_length;
8802     guint8      no, format, app_id, rel_id, ver_id, i;
8803     proto_tree *ext_tree, *ver_tree, *cdr_dr_tree;
8804     proto_item *fmt_item;
8805     tvbuff_t   *next_tvb;
8806 
8807     ext_tree = proto_tree_add_subtree(tree, tvb, offset, 1, ett_gtp_ext, NULL,
8808                     val_to_str_ext_const(GTP_EXT_DATA_REQ, &gtp_val_ext, "Unknown message"));
8809     offset++;
8810 
8811     length = tvb_get_ntohs(tvb, offset);
8812     proto_tree_add_uint(ext_tree, hf_gtp_length, tvb, offset, 2, length);
8813     offset+=2;
8814 
8815     if (length == 0) {
8816         return 3;
8817     }
8818 
8819     /* Octet 4 Number of Data Records */
8820     no = tvb_get_guint8(tvb, offset);
8821     proto_tree_add_item(ext_tree, hf_gtp_number_of_data_records, tvb, offset, 1, ENC_BIG_ENDIAN);
8822     offset++;
8823 
8824     /* Octet 5 Data Record Format */
8825     format   = tvb_get_guint8(tvb, offset);
8826     fmt_item = proto_tree_add_item(ext_tree, hf_gtp_data_record_format, tvb, offset, 1, ENC_BIG_ENDIAN);
8827     offset++;
8828     /* The value range is 1-255 in decimal. The value '0' should not be used.
8829      * Only the values 1-10 and 51-255 can be used for standards purposes.
8830      * Values in the range of 11-50 are to be configured only by operators, and are not subject to standardization.
8831      */
8832     if(format < 4) {
8833         proto_item_append_text(fmt_item, " %s", val_to_str_const(format, gtp_cdr_fmt_vals, "Unknown"));
8834         /* Octet 6 -7  Data Record Format Version
8835          *    8 7 6 5             4 3 2 1
8836          * 6 Application Identifier Release Identifier
8837          * 7 Version Identifier
8838          */
8839         app_id = tvb_get_guint8(tvb,offset);
8840         rel_id = app_id & 0x0f;
8841         app_id = app_id >>4;
8842         ver_id =tvb_get_guint8(tvb,offset+1);
8843         /* The second octet (#7 in Data Record Packet IE) identifies the version of the TS used to encode the CDR,
8844          * i.e. its value corresponds to the second digit of the version number of the document [51]
8845          * (as shown on the cover sheet), plus '1'.
8846          * E.g. for version 3.4.0, the Version Identifier would be "5".
8847          * In circumstances where the second digit is an alphabetical character, (e.g. 3.b.0), the corresponding ASCII value shall
8848          * be taken, e.g. the Version Identifier would be "66" (ASCII(b)).
8849          */
8850         if(ver_id < 0x65)
8851             ver_id = ver_id -1;
8852         /* XXX We don't handle ASCCI version */
8853 
8854         ver_tree = proto_tree_add_subtree_format(ext_tree, tvb, offset, 2, ett_gtp_cdr_ver, NULL,
8855                                 "Data record format version: AppId %u Rel %u.%u.0", app_id,rel_id,ver_id);
8856         proto_tree_add_item(ver_tree, hf_gtp_cdr_app, tvb, offset, 1, ENC_BIG_ENDIAN);
8857         proto_tree_add_item(ver_tree, hf_gtp_cdr_rel, tvb, offset, 1, ENC_BIG_ENDIAN);
8858         offset++;
8859         proto_tree_add_item(ver_tree, hf_gtp_cdr_ver, tvb, offset, 1, ENC_BIG_ENDIAN);
8860         offset++;
8861         for(i = 0; i < no; ++i) {
8862             cdr_length = tvb_get_ntohs(tvb, offset);
8863             cdr_dr_tree = proto_tree_add_subtree_format(ext_tree, tvb, offset, cdr_length+2,
8864                                     ett_gtp_cdr_dr, NULL, "Data record %d", i + 1);
8865             proto_tree_add_uint(cdr_dr_tree, hf_gtp_cdr_length, tvb, offset, 2, cdr_length);
8866             offset+=2;
8867             proto_tree_add_item(cdr_dr_tree, hf_gtp_cdr_context, tvb, offset, cdr_length, ENC_NA);
8868             next_tvb = tvb_new_subset_remaining(tvb, offset);
8869 
8870             /* XXX this is for release 6, may not work for higher releases */
8871             if(format==1) {
8872                 if(rel_id <= 6){
8873                     dissect_gprscdr_GPRSCallEventRecord_PDU(next_tvb, pinfo, cdr_dr_tree, NULL);
8874                 }else{
8875                     dissect_gprscdr_GPRSRecord_PDU(next_tvb, pinfo, cdr_dr_tree, NULL);
8876                 }
8877             } else {
8878                 /* Do we have a dissector regestering for this data format? */
8879                 dissector_try_uint(gtp_cdr_fmt_dissector_table, format, next_tvb, pinfo, cdr_dr_tree);
8880             }
8881 
8882             offset = offset + cdr_length;
8883         }
8884 
8885     } else {
8886         /* Proprietary CDR format */
8887         proto_item_append_text(fmt_item, " Proprietary or un documented format");
8888     }
8889 
8890     if (gtpcdr_handle) {
8891         next_tvb = tvb_new_subset_remaining(tvb, offset);
8892         call_dissector(gtpcdr_handle, next_tvb, pinfo, tree);
8893     }
8894 
8895     return 3 + length;
8896 }
8897 
8898 /* GPRS:        12.15
8899  * UMTS:        33.015
8900  */
8901 static int
decode_gtp_data_resp(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)8902 decode_gtp_data_resp(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8903 {
8904 
8905     guint16     length, n, number;
8906     proto_tree *ext_tree_data_resp;
8907 
8908     length = tvb_get_ntohs(tvb, offset + 1);
8909 
8910     ext_tree_data_resp = proto_tree_add_subtree(tree, tvb, offset, 3 + length,
8911                                 ett_gtp_data_resp, NULL, "Requests responded");
8912 
8913     n = 0;
8914 
8915     while (n < length) {
8916 
8917         number = tvb_get_ntohs(tvb, offset + 3 + n);
8918         proto_tree_add_uint_format(ext_tree_data_resp, hf_gtp_requests_responded, tvb, offset + 3 + n, 2, number, "%u", number);
8919         n = n + 2;
8920 
8921     }
8922 
8923     return 3 + length;
8924 
8925 }
8926 
8927 /* GPRS:        12.15
8928  * UMTS:        33.015
8929  */
8930 static int
decode_gtp_node_addr(tvbuff_t * tvb,int offset,packet_info * pinfo _U_,proto_tree * tree,session_args_t * args _U_)8931 decode_gtp_node_addr(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_)
8932 {
8933 
8934     guint16            length;
8935     proto_tree        *ext_tree_node_addr;
8936     proto_item        *te;
8937 
8938     length = tvb_get_ntohs(tvb, offset + 1);
8939 
8940     ext_tree_node_addr = proto_tree_add_subtree(tree, tvb, offset, 3 + length,
8941                                 ett_gtp_node_addr, &te, "Node address: ");
8942 
8943     proto_tree_add_item(ext_tree_node_addr, hf_gtp_node_address_length, tvb, offset + 1, 2, ENC_BIG_ENDIAN);
8944 
8945     switch (length) {
8946     case 4:
8947         proto_tree_add_item(ext_tree_node_addr, hf_gtp_node_ipv4, tvb, offset + 3, 4, ENC_BIG_ENDIAN);
8948         proto_item_append_text(te, "%s", tvb_ip_to_str(pinfo->pool, tvb, offset + 3));
8949         break;
8950     case 16:
8951         proto_tree_add_item(ext_tree_node_addr, hf_gtp_node_ipv6, tvb, offset + 3, 16, ENC_NA);
8952         proto_item_append_text(te, "%s", tvb_ip6_to_str(pinfo->pool, tvb, offset + 3));
8953         break;
8954     default:
8955         proto_item_append_text(te, "unknown type or wrong length");
8956         break;
8957     }
8958 
8959     return 3 + length;
8960 
8961 }
8962 
8963 /* GPRS:        9.60 v7.6.0, chapter 7.9.26
8964  * UMTS:        29.060 v4.0, chapter 7.7.46 Private Extension
8965  *
8966  */
8967 
8968 static int
decode_gtp_priv_ext(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args _U_)8969 decode_gtp_priv_ext(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
8970 {
8971 
8972     guint16     length, ext_id;
8973     proto_tree *ext_tree_priv_ext;
8974     proto_item *te;
8975     tvbuff_t   *next_tvb;
8976 
8977     ext_tree_priv_ext = proto_tree_add_subtree_format(tree, tvb, offset, 1, ett_gtp_ext, &te,
8978                 "%s : ", val_to_str_ext_const(GTP_EXT_PRIV_EXT, &gtp_val_ext, "Unknown message"));
8979 
8980     offset++;
8981     length = tvb_get_ntohs(tvb, offset);
8982     proto_tree_add_item(ext_tree_priv_ext, hf_gtp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
8983     offset += 2;
8984     if (length >= 2) {
8985         ext_id = tvb_get_ntohs(tvb, offset);
8986         proto_tree_add_uint(ext_tree_priv_ext, hf_gtp_ext_id, tvb, offset, 2, ext_id);
8987         proto_item_append_text(te, "%s (%u)", enterprises_lookup(ext_id, "Unknown"), ext_id);
8988         offset = offset + 2;
8989 
8990        if (length > 2) {
8991             next_tvb = tvb_new_subset_length(tvb, offset, length-2);
8992             if(!dissector_try_uint(gtp_priv_ext_dissector_table, ext_id, next_tvb, pinfo, ext_tree_priv_ext)){
8993                     proto_tree_add_item(ext_tree_priv_ext, hf_gtp_ext_val, tvb, offset, length - 2, ENC_NA);
8994             }
8995        }
8996     }
8997 
8998     return 3 + length;
8999 }
9000 
9001 static int
decode_gtp_unknown(tvbuff_t * tvb,int offset,packet_info * pinfo,proto_tree * tree,session_args_t * args _U_)9002 decode_gtp_unknown(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_)
9003 {
9004 
9005     proto_tree_add_expert(tree, pinfo, &ei_gtp_unknown_extension_header, tvb, offset, 1);
9006 
9007     return tvb_reported_length_remaining(tvb, offset);
9008 }
9009 
9010 static void
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)9011 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)
9012 {
9013     guint32 *session, frame_teid_cp;
9014     proto_item *it;
9015 
9016     /* GTP session */
9017     if (tree) {
9018         session = (guint32*)g_hash_table_lookup(session_table, &pinfo->num);
9019         if (session) {
9020             it = proto_tree_add_uint(tree, hf_gtp_session, tvb, 0, 0, *session);
9021             proto_item_set_generated(it);
9022         }
9023     }
9024 
9025 
9026     if (!PINFO_FD_VISITED(pinfo) && gtp_version == 1) {
9027         /* If the message does not have any session ID */
9028         session = (guint32*)g_hash_table_lookup(session_table, &pinfo->num);
9029         if (!session) {
9030             /* If the message is not a CPDPCRES, CPDPCREQ, UPDPREQ, UPDPRES then we remove its information from teid and ip lists */
9031             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
9032                 && gtp_hdr->message != GTP_MSG_UPDATE_PDP_REQ)) {
9033                 /* If the lists are not empty*/
9034                 if (wmem_list_count(teid_list) && wmem_list_count(ip_list)) {
9035                     remove_frame_info(&pinfo->num);
9036                 }
9037             }
9038 
9039             if (gtp_hdr->message == GTP_MSG_CREATE_PDP_REQ) {
9040                 /* If CPDPCREQ and not already in the list then we create a new session*/
9041                 add_gtp_session(pinfo->num, gtp_session_count++);
9042             } else if (gtp_hdr->message != GTP_MSG_CREATE_PDP_RESP) {
9043                 /* 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 */
9044                 if (gtp_hdr->message == GTP_MSG_ERR_IND) {
9045                     if (get_frame(last_ip, last_teid, &frame_teid_cp) == 1) {
9046                         session = (guint32*)g_hash_table_lookup(session_table, &frame_teid_cp);
9047                         if (session != NULL) {
9048                             /* We add the corresponding session to the session list*/
9049                             add_gtp_session(pinfo->num, *session);
9050                         }
9051                     }
9052                 }
9053                 else {
9054                     /* 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
9055                     the corresponding session ID */
9056                     if ((get_frame(pinfo->dst, (guint32)gtp_hdr->teid, &frame_teid_cp) == 1)) {
9057                         /* Then we have to set its session ID */
9058                         session = (guint32*)g_hash_table_lookup(session_table, &frame_teid_cp);
9059                         if (session != NULL) {
9060                             /* We add the corresponding session to the list so that when a response came we can associate its session ID*/
9061                             add_gtp_session(pinfo->num, *session);
9062                         }
9063                     }
9064                 }
9065             }
9066         }
9067     }
9068 }
9069 
9070 static int
dissect_nrup(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree,void * private_data _U_)9071 dissect_nrup(tvbuff_t * tvb, packet_info * pinfo _U_, proto_tree * tree,
9072             void *private_data _U_)
9073 {
9074     guint32 pdu_type;
9075     gboolean dl_disc_blk;
9076     gboolean dl_flush;
9077     guint32 dl_disc_num_blks;
9078     gint offset = 0;
9079 
9080     /* NRUP */
9081     proto_item *nrup_ti;
9082     proto_tree *nrup_tree;
9083 
9084     /* Protocol subtree */
9085     nrup_ti = proto_tree_add_item(tree, proto_nrup, tvb, offset, -1, ENC_NA);
9086     nrup_tree = proto_item_add_subtree(nrup_ti, ett_nrup);
9087 
9088 
9089     proto_tree_add_item_ret_uint(nrup_ti, hf_nrup_pdu_type,tvb, offset, 1, ENC_BIG_ENDIAN, &pdu_type);
9090 
9091     switch (pdu_type) {
9092         case NR_UP_DL_USER_DATA:
9093         {
9094             /* 5.5.2.1 */
9095             gboolean report_delivered;
9096 
9097             /* PDU Type (=0) Spare DL Discard Blocks DL Flush Report polling Octet 1*/
9098             proto_tree_add_item(nrup_tree, hf_nrup_spr_bit_extnd_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
9099             proto_tree_add_item_ret_boolean(nrup_tree, hf_nrup_dl_discrd_blks, tvb, offset, 1, ENC_BIG_ENDIAN, &dl_disc_blk);
9100             proto_tree_add_item_ret_boolean(nrup_tree, hf_nrup_dl_flush, tvb, offset, 1, ENC_BIG_ENDIAN, &dl_flush);
9101             proto_tree_add_item(nrup_tree, hf_nrup_rpt_poll, tvb, offset, 1, ENC_BIG_ENDIAN);
9102             offset++;
9103 
9104             /* Spare    Assistance Info. Report Polling Flag    Retransmission flag*/
9105             proto_tree_add_item(nrup_tree, hf_nrup_spare, tvb, offset, 1, ENC_BIG_ENDIAN);
9106             proto_tree_add_item(nrup_tree, hf_nrup_request_out_of_seq_report, tvb, offset, 1, ENC_BIG_ENDIAN);
9107             proto_tree_add_item_ret_boolean(nrup_tree, hf_nrup_report_delivered, tvb, offset, 1, ENC_BIG_ENDIAN, &report_delivered);
9108             proto_tree_add_item(nrup_tree, hf_nrup_user_data_existence_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
9109             proto_tree_add_item(nrup_tree, hf_nrup_ass_inf_rep_poll_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
9110             proto_tree_add_item(nrup_tree, hf_nrup_retransmission_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
9111             offset++;
9112 
9113             /* NR-U Sequence NUmber */
9114             proto_tree_add_item(nrup_tree, hf_nrup_nr_u_seq_num, tvb, offset, 3, ENC_BIG_ENDIAN);
9115             offset += 3;
9116 
9117             if (dl_flush) {
9118                 /* DL discard NR PDCP PDU SN */
9119                 proto_tree_add_item(nrup_tree, hf_nrup_dl_disc_nr_pdcp_pdu_sn, tvb, offset, 3, ENC_BIG_ENDIAN);
9120                 offset += 3;
9121             }
9122             /* Discarded blocks */
9123             if (dl_disc_blk) {
9124                 /* DL discard Number of blocks */
9125                 proto_tree_add_item_ret_uint(nrup_tree, hf_nrup_dl_disc_num_blks, tvb, offset, 1, ENC_BIG_ENDIAN, &dl_disc_num_blks);
9126                 offset++;
9127                 while (dl_disc_num_blks) {
9128                     /* DL discard NR PDCP PDU SN start */
9129                     proto_tree_add_item(nrup_tree, hf_nrup_dl_disc_nr_pdcp_pdu_sn_start, tvb, offset, 3, ENC_BIG_ENDIAN);
9130                     offset += 3;
9131 
9132                     /* Discarded Block size */
9133                     proto_tree_add_item(nrup_tree, hf_nrup_dl_disc_blk_sz, tvb, offset, 1, ENC_BIG_ENDIAN);
9134                     offset++;
9135                     dl_disc_num_blks--;
9136                 }
9137             }
9138 
9139             if (report_delivered) {
9140                 /* DL report NR PDCP PDU SN */
9141                 proto_tree_add_item(nrup_tree, hf_nrup_dl_report_nr_pdcp_pdu_sn, tvb, offset, 3, ENC_BIG_ENDIAN);
9142                 offset += 3;
9143             }
9144             break;
9145         }
9146 
9147         case NR_UP_DL_DATA_DELIVERY_STATUS:
9148         {
9149             /* 5.5.2.2 */
9150             gboolean high_tx_nr_pdcp_sn_ind;
9151             gboolean high_del_nr_pdcp_sn_ind;
9152             gboolean lost_packet_report;
9153             gboolean high_retx_nr_pdcp_sn_ind;
9154             gboolean high_del_retx_nr_pdcp_sn_ind;
9155             gboolean cause_rpt;
9156             gboolean data_rate_ind;
9157             guint32 lost_NR_U_SN_range;
9158 
9159             proto_tree_add_item_ret_boolean(nrup_tree, hf_nrup_high_tx_nr_pdcp_sn_ind ,tvb, offset,1, ENC_BIG_ENDIAN, &high_tx_nr_pdcp_sn_ind );
9160             proto_tree_add_item_ret_boolean(nrup_tree, hf_nrup_high_delivered_nr_pdcp_sn_ind ,tvb, offset,1, ENC_BIG_ENDIAN, &high_del_nr_pdcp_sn_ind );
9161             proto_tree_add_item(nrup_tree, hf_nrup_final_frame_ind,tvb, offset, 1, ENC_BIG_ENDIAN);
9162             proto_tree_add_item_ret_boolean(nrup_tree, hf_nrup_lost_pkt_rpt,tvb, offset, 1, ENC_BIG_ENDIAN, &lost_packet_report);
9163             offset++;
9164 
9165             proto_tree_add_item(nrup_tree, hf_nrup_spare, tvb, offset, 1, ENC_BIG_ENDIAN);
9166             proto_tree_add_item(nrup_tree, hf_nrup_delivered_nr_pdcp_sn_range_ind ,tvb, offset,1, ENC_BIG_ENDIAN);
9167             proto_tree_add_item_ret_boolean(nrup_tree, hf_nrup_data_rate_ind,tvb, offset,1, ENC_BIG_ENDIAN, &data_rate_ind);
9168             proto_tree_add_item_ret_boolean(nrup_tree, hf_nrup_high_retx_nr_pdcp_sn_ind,tvb, offset,1, ENC_BIG_ENDIAN, &high_retx_nr_pdcp_sn_ind);
9169             proto_tree_add_item_ret_boolean(nrup_tree, hf_nrup_high_delivered_retx_nr_pdcp_sn_ind,tvb, offset,1, ENC_BIG_ENDIAN, &high_del_retx_nr_pdcp_sn_ind);
9170             proto_tree_add_item_ret_boolean(nrup_tree, hf_nrup_cause_rpt,tvb, offset,1, ENC_BIG_ENDIAN, &cause_rpt);
9171             offset++;
9172 
9173             proto_tree_add_item(nrup_tree, hf_nrup_desrd_buff_sz_data_radio_bearer,tvb, offset, 4, ENC_BIG_ENDIAN);
9174             offset += 4;
9175 
9176             if (data_rate_ind){
9177                 proto_tree_add_item(nrup_tree, hf_nrup_desrd_data_rate,tvb, offset, 4, ENC_BIG_ENDIAN);
9178                 offset += 4;
9179             }
9180 
9181             if (lost_packet_report) {
9182                 proto_tree_add_item_ret_uint(nrup_tree, hf_nrup_num_lost_nru_seq_num,tvb, offset, 1, ENC_BIG_ENDIAN, &lost_NR_U_SN_range);
9183                 offset+=1;
9184 
9185                 while (lost_NR_U_SN_range) {
9186                     proto_tree_add_item(nrup_tree, hf_nrup_start_lost_nru_seq_num,tvb, offset, 3, ENC_BIG_ENDIAN);
9187                     offset += 3;
9188 
9189                      proto_tree_add_item(nrup_tree, hf_nrup_end_lost_nru_seq_num,tvb, offset, 3, ENC_BIG_ENDIAN);
9190                      offset += 3;
9191                      lost_NR_U_SN_range--;
9192                 }
9193             }
9194 
9195             if (high_del_nr_pdcp_sn_ind) {
9196                 proto_tree_add_item(nrup_tree, hf_nrup_high_success_delivered_nr_pdcp_sn,tvb, offset, 3, ENC_BIG_ENDIAN);
9197                 offset += 3;
9198             }
9199 
9200             if (high_tx_nr_pdcp_sn_ind) {
9201                 proto_tree_add_item(nrup_tree, hf_nrup_high_tx_nr_pdcp_sn,tvb, offset, 3, ENC_BIG_ENDIAN);
9202                 offset += 3;
9203             }
9204 
9205             if (cause_rpt) {
9206                 proto_tree_add_item(nrup_tree, hf_nrup_cause_val,tvb, offset, 1, ENC_BIG_ENDIAN);
9207                 offset ++;
9208             }
9209 
9210             if (high_del_retx_nr_pdcp_sn_ind) {
9211                 proto_tree_add_item(nrup_tree, hf_nrup_high_success_delivered_retx_nr_pdcp_sn,tvb, offset, 3, ENC_BIG_ENDIAN);
9212                 offset += 3;
9213             }
9214 
9215             if (high_retx_nr_pdcp_sn_ind) {
9216                 proto_tree_add_item(nrup_tree, hf_nrup_high_retx_nr_pdcp_sn,tvb, offset, 3, ENC_BIG_ENDIAN);
9217             }
9218 
9219             break;
9220         }
9221 
9222         case NR_UP_ASSISTANCE_INFORMATION_DATA:
9223         {
9224             /* 5.5.2.3 */
9225             gboolean pdcp_duplication_indication;
9226             gboolean assistance_information_ind;
9227             gboolean ul_delay_ind;
9228             gboolean dl_delay_ind;
9229             gboolean pdcp_duplication_suggestion;
9230 
9231             /* Flags */
9232             proto_tree_add_item_ret_boolean(nrup_tree, hf_nrup_pdcp_duplication_ind, tvb, offset,1, ENC_BIG_ENDIAN, &pdcp_duplication_indication);
9233             proto_tree_add_item_ret_boolean(nrup_tree, hf_nrup_assistance_information_ind, tvb, offset,1, ENC_BIG_ENDIAN, &assistance_information_ind);
9234             proto_tree_add_item_ret_boolean(nrup_tree, hf_nrup_ul_delay_ind, tvb, offset,1, ENC_BIG_ENDIAN, &ul_delay_ind);
9235             proto_tree_add_item_ret_boolean(nrup_tree, hf_nrup_dl_delay_ind, tvb, offset,1, ENC_BIG_ENDIAN, &dl_delay_ind);
9236             offset++;
9237             proto_tree_add_item(nrup_tree, hf_nrup_spare_2, tvb, offset,1, ENC_BIG_ENDIAN);
9238             proto_tree_add_item_ret_boolean(nrup_tree, hf_nrup_pdcp_duplication_activation_suggestion,
9239                                             tvb, offset,1, ENC_BIG_ENDIAN, &pdcp_duplication_suggestion);
9240             offset++;
9241 
9242             /* Number of Assistance Information Fields */
9243             if (assistance_information_ind) {
9244                 guint32  number_of_assistance_information_fields = 0;
9245                 guint32 num_octets_radio_qa_info;
9246 
9247                 /* Number of assistance info fields */
9248                 proto_tree_add_item_ret_uint(nrup_tree, hf_nrup_num_assistance_info_fields,
9249                                              tvb, offset,1, ENC_BIG_ENDIAN, &number_of_assistance_information_fields);
9250                 offset++;
9251 
9252                 for (guint n=0; n < number_of_assistance_information_fields; n++) {
9253                     /* Assistance Information Type */
9254                     proto_tree_add_item(nrup_tree, hf_nrup_assistance_information_type,
9255                                         tvb, offset,1, ENC_BIG_ENDIAN);
9256                     offset++;
9257                     /* Num octets in assistance info */
9258                     proto_tree_add_item_ret_uint(nrup_tree, hf_nrup_num_octets_radio_qa_info,
9259                                                  tvb, offset, 1, ENC_BIG_ENDIAN, &num_octets_radio_qa_info);
9260                     offset++;
9261                     /* Radio Quality Assistance info */
9262                     proto_tree_add_item(nrup_tree, hf_nrup_radio_qa_info, tvb, offset,
9263                                         num_octets_radio_qa_info, ENC_NA);
9264                     offset += num_octets_radio_qa_info;
9265                 }
9266             }
9267 
9268             /* UL Delay DU Result */
9269             if (ul_delay_ind) {
9270                 proto_tree_add_item(nrup_tree, hf_nrup_ul_delay_du_result, tvb, offset, 4, ENC_BIG_ENDIAN);
9271                 offset += 4;
9272             }
9273             /* DL Delay DU Result */
9274             if (dl_delay_ind) {
9275                 proto_tree_add_item(nrup_tree, hf_nrup_dl_delay_du_result, tvb, offset, 4, ENC_BIG_ENDIAN);
9276                 offset += 4;
9277             }
9278             break;
9279         }
9280         default:
9281             /* TODO: expert info error for unexpected PDU type? */
9282             break;
9283     }
9284 
9285     return offset;
9286 }
9287 
9288 /* TS 38.425 */
9289 static void
addRANContParameter(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,gint offset,gint length)9290 addRANContParameter(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset, gint length)
9291 {
9292     tvbuff_t *next_tvb = tvb_new_subset_length(tvb, offset, length);
9293     call_dissector(nrup_handle, next_tvb, pinfo, tree);
9294 }
9295 
9296 
9297 static int
dissect_gtp_common(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree)9298 dissect_gtp_common(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
9299 {
9300     guint8           octet;
9301     gtp_hdr_t       *gtp_hdr = NULL;
9302     proto_tree      *gtp_tree = NULL, *ext_tree;
9303     proto_tree      *ran_cont_tree = NULL;
9304     proto_item      *ti = NULL, *tf, *ext_hdr_len_item, *message_item;
9305     int              i, offset = 0, checked_field, mandatory;
9306     gboolean         gtp_prime, has_SN;
9307     int              seq_no           = 0;
9308     int              flow_label       = 0;
9309     guint8           pdu_no, next_hdr = 0;
9310     guint8           ext_hdr_val;
9311     guint            ext_hdr_length;
9312     guint16          ext_hdr_pdcpsn;
9313     gchar           *tid_str;
9314     tvbuff_t        *next_tvb;
9315     guint8           sub_proto;
9316     guint8           acfield_len      = 0;
9317     gtp_msg_hash_t  *gcrp             = NULL;
9318     conversation_t  *conversation;
9319     gtp_conv_info_t *gtp_info;
9320     session_args_t  *args             = NULL;
9321     ie_decoder      *decoder          = NULL;
9322 
9323     /* Do we have enough bytes for the version and message type? */
9324     if (!tvb_bytes_exist(tvb, 0, 2)) {
9325         /* No - reject the packet. */
9326         return 0;
9327     }
9328     octet = tvb_get_guint8(tvb, 0);
9329     if (((octet >> 5) & 0x07) > 2) {
9330         /* Version > 2; reject the packet */
9331         return 0;
9332     }
9333     octet = tvb_get_guint8(tvb, 1);
9334     if (octet == GTP_MSG_UNKNOWN || try_val_to_str(octet, gtp_message_type) == NULL) {
9335         /* Unknown message type; reject the packet */
9336         return 0;
9337     }
9338 
9339     /* Setting everything to 0, so that the TEID is 0 for GTP version 0
9340      * The magic number should perhaps be replaced.
9341      */
9342     gtp_hdr = wmem_new0(wmem_packet_scope(), gtp_hdr_t);
9343 
9344     /* Setting the TEID to -1 to say that the TEID is not valid for this packet */
9345     gtp_hdr->teid = -1;
9346 
9347     col_set_str(pinfo->cinfo, COL_PROTOCOL, "GTP");
9348     col_clear(pinfo->cinfo, COL_INFO);
9349 
9350     if (g_gtp_session) {
9351         args = wmem_new0(wmem_packet_scope(), session_args_t);
9352         args->last_cause = 128;                                         /* It stores the last cause decoded. Cause accepted by default */
9353         /* We create the auxiliary lists */
9354         args->teid_list = wmem_list_new(wmem_packet_scope());
9355         args->ip_list = wmem_list_new(wmem_packet_scope());
9356     }
9357 
9358     /*
9359     * Do we have a conversation for this connection?
9360     */
9361     conversation = find_or_create_conversation(pinfo);
9362 
9363     /*
9364     * Do we already know this conversation?
9365     */
9366     gtp_info = (gtp_conv_info_t *)conversation_get_proto_data(conversation, proto_gtp);
9367     if (gtp_info == NULL) {
9368         /* No.  Attach that information to the conversation, and add
9369         * it to the list of information structures.
9370         */
9371         gtp_info = wmem_new(wmem_file_scope(), gtp_conv_info_t);
9372         /*Request/response matching tables*/
9373         gtp_info->matched = g_hash_table_new(gtp_sn_hash, gtp_sn_equal_matched);
9374         gtp_info->unmatched = g_hash_table_new(gtp_sn_hash, gtp_sn_equal_unmatched);
9375 
9376         conversation_add_proto_data(conversation, proto_gtp, gtp_info);
9377 
9378         gtp_info->next = gtp_info_items;
9379         gtp_info_items = gtp_info;
9380     }
9381 
9382     gtp_hdr->flags = tvb_get_guint8(tvb, offset);
9383 
9384     if (!(gtp_hdr->flags & 0x10)){
9385         gtp_prime = TRUE;
9386     }else{
9387         gtp_prime = FALSE;
9388     }
9389 
9390     switch ((gtp_hdr->flags >> 5) & 0x07) {
9391         case 0:
9392             gtp_version = 0;
9393             break;
9394         case 1:
9395             gtp_version = 1;
9396             break;
9397         default:
9398             gtp_version = 1;
9399             break;
9400     }
9401     if (tree) {
9402         if (gtp_prime) {
9403             static int * const gtp_prime_flags[] = {
9404                 &hf_gtp_prime_flags_ver,
9405                 &hf_gtp_flags_pt,
9406                 &hf_gtp_flags_spare1,
9407                 NULL
9408             };
9409             static int * const gtp_prime_v0_flags[] = {
9410                 &hf_gtp_prime_flags_ver,
9411                 &hf_gtp_flags_pt,
9412                 &hf_gtp_flags_spare1,
9413                 &hf_gtp_flags_hdr_length,
9414                 NULL
9415             };
9416 
9417             ti = proto_tree_add_item(tree, proto_gtpprime, tvb, 0, -1, ENC_NA);
9418             gtp_tree = proto_item_add_subtree(ti, ett_gtp);
9419 
9420             /* Octet  8    7    6    5    4    3    2    1
9421              * 1      Version   | PT| Spare '1 1 1 '| ' 0/1 '
9422              */
9423 
9424              /* Bit 1 of octet 1 is not used in GTP' (except in v0), and it is marked '0'
9425               * in the GTP' header. It is in use in GTP' v0 and distinguishes the used header-length.
9426               * In the case of GTP' v0, this bit being marked one (1) indicates the usage of the 6
9427               * octets header. If the bit is set to '0' (usually the case) the 20-octet header is used.
9428               * For all other versions of GTP', this bit is not used and is set to '0'. However,
9429               * this does not suggest the use of the 20-octet header, rather a shorter 6-octet header.
9430               */
9431             if (gtp_version == 0) {
9432                 proto_tree_add_bitmask_value_with_flags(gtp_tree, tvb, offset, hf_gtp_flags,
9433                     ett_gtp_flags, gtp_prime_v0_flags, gtp_hdr->flags, BMT_NO_APPEND);
9434             } else {
9435                 proto_tree_add_bitmask_value_with_flags(gtp_tree, tvb, offset, hf_gtp_flags,
9436                     ett_gtp_flags, gtp_prime_flags, gtp_hdr->flags, BMT_NO_APPEND);
9437             }
9438         } else {
9439             static int * const gtp_flags[] = {
9440                 &hf_gtp_flags_ver,
9441                 &hf_gtp_flags_pt,
9442                 &hf_gtp_flags_spare2,
9443                 &hf_gtp_flags_e,
9444                 &hf_gtp_flags_s,
9445                 &hf_gtp_flags_pn,
9446                 NULL
9447             };
9448             static int * const gtp_v0_flags[] = {
9449                 &hf_gtp_flags_ver,
9450                 &hf_gtp_flags_pt,
9451                 &hf_gtp_flags_spare1,
9452                 &hf_gtp_flags_snn,
9453                 NULL
9454             };
9455             ti = proto_tree_add_item(tree, proto_gtp, tvb, 0, -1, ENC_NA);
9456             gtp_tree = proto_item_add_subtree(ti, ett_gtp);
9457 
9458             if (gtp_version == 0) {
9459                 proto_tree_add_bitmask_value_with_flags(gtp_tree, tvb, offset, hf_gtp_flags,
9460                     ett_gtp_flags, gtp_v0_flags, gtp_hdr->flags, BMT_NO_APPEND);
9461             } else {
9462                 proto_tree_add_bitmask_value_with_flags(gtp_tree, tvb, offset, hf_gtp_flags,
9463                     ett_gtp_flags, gtp_flags, gtp_hdr->flags, BMT_NO_APPEND);
9464             }
9465         }
9466     }
9467     offset++;
9468 
9469     gtp_hdr->message = tvb_get_guint8(tvb, offset);
9470     /* Link direction is needed to properly dissect PCO */
9471     switch(gtp_hdr->message){
9472         case GTP_MSG_DELETE_PDP_REQ:
9473         case GTP_MSG_UPDATE_PDP_REQ:
9474         case GTP_MSG_CREATE_PDP_REQ:
9475         case GTP_MSG_INIT_PDP_CONTEXT_ACT_REQ:
9476         case GTP_MSG_PDU_NOTIFY_REQ:
9477         case GTP_MSG_PDU_NOTIFY_REJ_REQ:
9478         case GTP_MSG_FORW_RELOC_REQ: /* direction added for UTRAN Container decode */
9479             pinfo->link_dir = P2P_DIR_UL;
9480             break;
9481         case GTP_MSG_DELETE_PDP_RESP:
9482         case GTP_MSG_UPDATE_PDP_RESP:
9483         case GTP_MSG_CREATE_PDP_RESP:
9484         case GTP_MSG_INIT_PDP_CONTEXT_ACT_RESP:
9485         case GTP_MSG_FORW_RELOC_RESP: /* direction added for UTRAN Container decode */
9486             pinfo->link_dir = P2P_DIR_DL;
9487             break;
9488     default:
9489         break;
9490     }
9491     col_set_str(pinfo->cinfo, COL_INFO, val_to_str_ext_const(gtp_hdr->message, &gtp_message_type_ext, "Unknown"));
9492     message_item = proto_tree_add_uint(gtp_tree, hf_gtp_message_type, tvb, offset, 1, gtp_hdr->message);
9493     offset++;
9494 
9495     gtp_hdr->length = tvb_get_ntohs(tvb, offset);
9496     proto_tree_add_uint(gtp_tree, hf_gtp_length, tvb, 2, 2, gtp_hdr->length);
9497     offset += 2;
9498 
9499     /* We initialize the sequence number*/
9500     has_SN = FALSE;
9501     if (gtp_prime) {
9502         seq_no = tvb_get_ntohs(tvb, offset);
9503         has_SN = TRUE;
9504         proto_tree_add_uint(gtp_tree, hf_gtp_seq_number, tvb, offset, 2, seq_no);
9505         offset += 2;
9506         /* If GTP' version is 0 and bit 1 is 0 20 bytes header is used, dissect it */
9507         if( (gtp_version == 0) && ((gtp_hdr->flags & 0x01) == 0) ) {
9508             proto_tree_add_item(gtp_tree, hf_gtp_dummy_octets, tvb, offset, 14, ENC_NA);
9509             offset += 14;
9510         }
9511 
9512         set_actual_length(tvb, offset + gtp_hdr->length);
9513     } else {
9514         switch (gtp_version) {
9515         case 0:
9516             seq_no = tvb_get_ntohs(tvb, offset);
9517             has_SN = TRUE;
9518             proto_tree_add_uint(gtp_tree, hf_gtp_seq_number, tvb, offset, 2, seq_no);
9519             offset += 2;
9520 
9521             flow_label = tvb_get_ntohs(tvb, offset);
9522             proto_tree_add_uint(gtp_tree, hf_gtp_flow_label, tvb, offset, 2, flow_label);
9523             offset += 2;
9524 
9525             pdu_no = tvb_get_guint8(tvb, offset);
9526             proto_tree_add_uint(gtp_tree, hf_gtp_sndcp_number, tvb, offset, 1, pdu_no);
9527             offset += 4;
9528 
9529             tid_str = id_to_str(tvb, offset);
9530             proto_tree_add_string(gtp_tree, hf_gtp_tid, tvb, offset, 8, tid_str);
9531             offset += 8;
9532 
9533             set_actual_length(tvb, offset + gtp_hdr->length);
9534 
9535             break;
9536         case 1:
9537             gtp_hdr->teid = tvb_get_ntohl(tvb, offset);
9538             proto_tree_add_item(gtp_tree, hf_gtp_teid, tvb, offset, 4, ENC_BIG_ENDIAN);
9539             offset += 4;
9540 
9541             set_actual_length(tvb, offset + gtp_hdr->length);
9542 
9543             /* Are sequence number/N-PDU Number/extension header present?
9544                See NOTE 5 of Figure 2 of 3GPP TS 29.060 version 4.3.0
9545                Release 4 - the Sequence Number, N-PDU Number, and
9546                Next Extension Header fields are present if any of
9547                GTP_E_MASK, GTP_S_MASK, or GTP_PN_MASK are set. */
9548             if (gtp_hdr->flags & (GTP_E_MASK|GTP_S_MASK|GTP_PN_MASK)) {
9549                 /* Those fields are only *interpreted* if the
9550                    particular flag for the field is set. */
9551                 if (gtp_hdr->flags & GTP_S_MASK) {
9552                     seq_no = tvb_get_ntohs(tvb, offset);
9553                     has_SN = TRUE;
9554                     proto_tree_add_uint(gtp_tree, hf_gtp_seq_number, tvb, offset, 2, seq_no);
9555                 }
9556                 offset += 2;
9557 
9558                 if (gtp_hdr->flags & GTP_PN_MASK) {
9559                     pdu_no = tvb_get_guint8(tvb, offset);
9560                     proto_tree_add_uint(gtp_tree, hf_gtp_npdu_number, tvb, offset, 1, pdu_no);
9561                 }
9562                 offset++;
9563 
9564                 if (gtp_hdr->flags & GTP_E_MASK) {
9565                     proto_item* hdr_ext_item;
9566                     next_hdr = tvb_get_guint8(tvb, offset);
9567                     hdr_ext_item = proto_tree_add_uint(gtp_tree, hf_gtp_ext_hdr_next, tvb, offset, 1, next_hdr);
9568                     offset++;
9569                     /* Add each extension header found. */
9570                     while (next_hdr != 0) {
9571                         ext_hdr_length = tvb_get_guint8(tvb, offset);
9572                         tf = proto_tree_add_item(gtp_tree, hf_gtp_ext_hdr, tvb, offset, ext_hdr_length*4, ENC_NA);
9573                         ext_tree = proto_item_add_subtree(tf, ett_gtp_ext_hdr);
9574                         ext_hdr_len_item = proto_tree_add_item(ext_tree, hf_gtp_ext_hdr_length, tvb, offset,1, ENC_BIG_ENDIAN);
9575                         if (ext_hdr_length == 0) {
9576                             expert_add_info_format(pinfo, ext_hdr_len_item, &ei_gtp_ext_length_mal,
9577                                                    "Extension header length is zero");
9578                             return tvb_reported_length(tvb);
9579                         }
9580                         offset++;
9581                         proto_item_append_text(tf, " (%s)", val_to_str_const(next_hdr, next_extension_header_fieldvals, "Unknown"));
9582 
9583                         switch (next_hdr) {
9584 
9585                         case GTP_EXT_HDR_UDP_PORT:
9586                             /* UDP Port
9587                              * 3GPP 29.281 v9.0.0, 5.2.2.1 UDP Port
9588                              * "This extension header may be transmitted in
9589                              * Error Indication messages to provide the UDP
9590                              * Source Port of the G-PDU that triggered the
9591                              * Error Indication. It is 4 octets long, and
9592                              * therefore the Length field has value 1"
9593                              */
9594                             if (ext_hdr_length == 1) {
9595                                 /* UDP Port of source */
9596                                 proto_tree_add_item(ext_tree, hf_gtp_ext_hdr_udp_port, tvb, offset, 2, ENC_BIG_ENDIAN);
9597                             } else {
9598                                 /* Bad length */
9599                                 expert_add_info_format(pinfo, ext_tree, &ei_gtp_ext_length_warn, "The length field for the UDP Port Extension header should be 1.");
9600                             }
9601                             break;
9602 
9603                         case GTP_EXT_HDR_RAN_CONT:
9604                             /* RAN Container
9605                              * 3GPP 29.281 v15.2.0, 5.2.2.4 RAN Container
9606                              * This extension header may be transmitted in
9607                              * a G-PDU over the X2 user plane interface
9608                              * between the eNBs. The RAN Container has a
9609                              * variable length and its content is specified
9610                              * in 3GPP TS 36.425 [25]. A G-PDU message with
9611                              * this extension header may be sent without a T-PDU.
9612                              */
9613                             proto_tree_add_item(ext_tree, hf_gtp_ext_hdr_ran_cont, tvb, offset, (4*ext_hdr_length)-1, ENC_NA);
9614                             break;
9615 
9616                         case GTP_EXT_HDR_LONG_PDCP_PDU:
9617                             /* Long PDCP PDU Number
9618                              * 3GPP 29.281 v15.2.0, 5.2.2.2A Long PDCP PDU Number
9619                              * This extension header is used for direct X2 or
9620                              * indirect S1 DL data forwarding during a Handover
9621                              * procedure between two eNBs. The Long PDCP PDU number
9622                              * extension header is 8 octets long, and therefore
9623                              * the Length field has value 2.
9624                              * The PDCP PDU number field of the Long PDCP PDU number
9625                              * extension header has a maximum value which requires 18
9626                              * bits (see 3GPP TS 36.323 [24]). Bit 2 of octet 2 is
9627                              * the most significant bit and bit 1 of octet 4 is the
9628                              * least significant bit, see Figure 5.2.2.2A-1. Bits 8 to
9629                              * 3 of octet 2, and Bits 8 to 1 of octets 5 to 7 shall be
9630                              * set to 0.
9631                              * NOTE: A G-PDU which includes a PDCP PDU Number contains
9632                              * either the extension header PDCP PDU Number or Long PDCP
9633                              * PDU Number.
9634                              */
9635                             if (ext_hdr_length == 2) {
9636                                 proto_tree_add_bits_item(ext_tree, hf_gtp_ext_hdr_spare_bits, tvb, offset<<3, 6, ENC_BIG_ENDIAN);
9637                                 proto_tree_add_item(ext_tree, hf_gtp_ext_hdr_long_pdcp_sn, tvb, offset, 3, ENC_BIG_ENDIAN);
9638                                 proto_tree_add_item(ext_tree, hf_gtp_ext_hdr_spare_bytes, tvb, offset+3, 3, ENC_NA);
9639                             } else {
9640                                 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.");
9641                             }
9642                             break;
9643 
9644                         case GTP_EXT_HDR_XW_RAN_CONT:
9645                             /* Xw RAN Container
9646                              * 3GPP 29.281 v15.2.0, 5.2.2.5 Xw RAN Container
9647                              * This extension header may be transmitted in a
9648                              * G-PDU over the Xw user plane interface between
9649                              * the eNB and the WLAN Termination (WT). The Xw
9650                              * RAN Container has a variable length and its
9651                              * content is specified in 3GPP TS 36.464 [27].
9652                              * A G-PDU message with this extension header may
9653                              * be sent without a T-PDU.
9654                              */
9655                             proto_tree_add_item(ext_tree, hf_gtp_ext_hdr_xw_ran_cont, tvb, offset, (4*ext_hdr_length)-1, ENC_NA);
9656                             break;
9657 
9658                         case GTP_EXT_HDR_NR_RAN_CONT:
9659                             /* NR RAN Container
9660                              * 3GPP 29.281 v15.2.0, 5.2.2.6 NR RAN Container
9661                              * This extension header may be transmitted in a
9662                              * G-PDU over the X2-U, Xn-U and F1-U user plane
9663                              * interfaces, within NG-RAN and, for EN-DC, within
9664                              * E-UTRAN. The NR RAN Container has a variable
9665                              * length and its content is specified in 3GPP TS
9666                              * 38.425 [30]. A G-PDU message with this extension
9667                              * header may be sent without a T-PDU.
9668                              */
9669                             ran_cont_tree = proto_tree_add_subtree(ext_tree, tvb, offset, (ext_hdr_length * 4) - 1, ett_gtp_nr_ran_cont, NULL, "NR RAN Container");
9670                             addRANContParameter(tvb, pinfo, ran_cont_tree, offset, (ext_hdr_length * 4) - 1);
9671                             break;
9672 
9673                         case GTP_EXT_HDR_PDU_SESSION_CONT:
9674                         {
9675                             /* PDU Session Container
9676                              * 3GPP 29.281 v15.2.0, 5.2.2.7 PDU Session Container
9677                              * This extension header may be transmitted in a G-PDU
9678                              * over the N3 and N9 user plane interfaces, between
9679                              * NG-RAN and UPF, or between two UPFs. The PDU Session
9680                              * Container has a variable length and its content is
9681                              * specified in 3GPP TS 38.415 [31].
9682                              */
9683                             static int * const flags1[] = {
9684                                 &hf_gtp_ext_hdr_pdu_ses_cont_ppp,
9685                                 &hf_gtp_ext_hdr_pdu_ses_cont_rqi,
9686                                 &hf_gtp_ext_hdr_pdu_ses_cont_qos_flow_id,
9687                                 NULL
9688                             };
9689                             static int * const flags2[] = {
9690                                 &hf_gtp_ext_hdr_pdu_ses_cont_ppi,
9691                                 &hf_gtp_spare_b4b0,
9692                                 NULL
9693                             };
9694                             static int * const flags3[] = {
9695                                 &hf_gtp_spare_b7b6,
9696                                 &hf_gtp_ext_hdr_pdu_ses_cont_qos_flow_id,
9697                                 NULL
9698                             };
9699 
9700                             proto_tree *pdu_ses_cont_tree;
9701                             guint32 pdu_type;
9702                             guint8 value;
9703 
9704                             pdu_ses_cont_tree = proto_tree_add_subtree(ext_tree, tvb, offset, (ext_hdr_length * 4) - 1, ett_pdu_session_cont, NULL, "PDU Session Container");
9705                             /* PDU Type    Spare */
9706                             proto_tree_add_item_ret_uint(pdu_ses_cont_tree, hf_gtp_ext_hdr_pdu_ses_cont_pdu_type, tvb, offset, 1, ENC_BIG_ENDIAN, &pdu_type);
9707                             proto_tree_add_item(pdu_ses_cont_tree, hf_gtp_spare_h1, tvb, offset, 1, ENC_BIG_ENDIAN);
9708                             switch (pdu_type) {
9709                             case 0:
9710                                 /* PDU Type: DL PDU SESSION INFORMATION (0) */
9711                                 /* Octet 1: PPP    RQI    QoS Flow Identifier  */
9712                                 value = tvb_get_guint8(tvb, offset + 1);
9713                                 proto_tree_add_bitmask_list_value(pdu_ses_cont_tree, tvb, offset + 1, 1, flags1, value);
9714                                 if (value & 0x80)
9715                                 {
9716                                     /* Octet 2 PPI    Spare*/
9717                                     proto_tree_add_bitmask_list(pdu_ses_cont_tree, tvb, offset + 2, 1, flags2, ENC_BIG_ENDIAN);
9718                                 }
9719                                 break;
9720                             case 1:
9721                                 /* PDU Type: UL PDU SESSION INFORMATION (1)*/
9722                                 /* Spare    QoS Flow Identifier */
9723                                 proto_tree_add_bitmask_list(pdu_ses_cont_tree, tvb, offset + 1, 1, flags3, ENC_BIG_ENDIAN);
9724                                 break;
9725                             default:
9726                                 proto_tree_add_expert(pdu_ses_cont_tree, pinfo, &ei_gtp_unknown_pdu_type, tvb, offset, 1);
9727                                 break;
9728                             }
9729                         }
9730                             break;
9731 
9732                         case GTP_EXT_HDR_PDCP_SN:
9733                             /* PDCP PDU
9734                              * 3GPP 29.281 v9.0.0, 5.2.2.2 PDCP PDU Number
9735                              *
9736                              * "This extension header is transmitted, for
9737                              * example in UTRAN, at SRNS relocation time,
9738                              * to provide the PDCP sequence number of not
9739                              * yet acknowledged N-PDUs. It is 4 octets long,
9740                              * and therefore the Length field has value 1.
9741                              *
9742                              * When used during a handover procedure between
9743                              * two eNBs at the X2 interface (direct DL data
9744                              * forwarding) or via the S1 interface (indirect
9745                              * DL data forwarding) in E-UTRAN, bit 8 of octet
9746                              * 2 is spare and shall be set to zero.
9747                              *
9748                              * Wireshark Note: TS 29.060 does not define bit
9749                              * 5-6 as spare, so no check is possible unless
9750                              * a preference is used.
9751                              */
9752                             /* First byte is length (should be 1) */
9753                             if (ext_hdr_length == 1) {
9754                                 proto_item* ext_item;
9755 
9756                                 ext_hdr_pdcpsn = tvb_get_ntohs(tvb, offset);
9757                                 ext_item = proto_tree_add_item(ext_tree, hf_gtp_ext_hdr_pdcpsn, tvb, offset, 2, ENC_BIG_ENDIAN);
9758                                 if (ext_hdr_pdcpsn & 0x8000) {
9759                                     expert_add_info(pinfo, ext_item, &ei_gtp_ext_hdr_pdcpsn);
9760                                 }
9761                             } else {
9762                                 expert_add_info_format(pinfo, ext_tree, &ei_gtp_ext_length_warn, "The length field for the PDCP SN Extension header should be 1.");
9763                             }
9764                             break;
9765 
9766                         case GTP_EXT_HDR_SUSPEND_REQ:
9767                             /* Suspend Request */
9768                             break;
9769 
9770                         case GTP_EXT_HDR_SUSPEND_RESP:
9771                             /* Suspend Response */
9772                             break;
9773 
9774                         default:
9775                             {
9776                                 tvbuff_t * ext_hdr_tvb;
9777                                 gtp_hdr_ext_info_t gtp_hdr_ext_info;
9778 
9779                                 gtp_hdr_ext_info.hdr_ext_item = hdr_ext_item;
9780                                 /* NOTE Type and lenght included in the call*/
9781                                 ext_hdr_tvb = tvb_new_subset_remaining(tvb, offset - 2);
9782                                 dissector_try_uint_new(gtp_hdr_ext_dissector_table, next_hdr, ext_hdr_tvb, pinfo, ext_tree, FALSE, &gtp_hdr_ext_info);
9783                                 break;
9784                             }
9785                         }
9786                         offset += ext_hdr_length*4 - 2;
9787 
9788                         next_hdr = tvb_get_guint8(tvb, offset);
9789                         hdr_ext_item = proto_tree_add_uint(ext_tree, hf_gtp_ext_hdr_next, tvb, offset, 1, next_hdr);
9790                         offset++;
9791                     }
9792                 } else
9793                     offset++;
9794             }
9795             break;
9796         default:
9797             break;
9798         }
9799     }
9800 
9801     if (gtp_hdr->message != GTP_MSG_TPDU) {
9802         /* Dissect IEs */
9803         mandatory = 0;      /* check order of GTP fields against ETSI */
9804         while (tvb_reported_length_remaining(tvb, offset) > 0) {
9805             decoder = NULL;
9806             ext_hdr_val = tvb_get_guint8(tvb, offset);
9807             if (g_gtp_etsi_order) {
9808                 checked_field = check_field_presence_and_decoder(gtp_hdr->message, ext_hdr_val, &mandatory, &decoder);
9809                 switch (checked_field) {
9810                 case -2:
9811                     expert_add_info(pinfo, message_item, &ei_gtp_message_not_found);
9812                     break;
9813                 case -1:
9814                     expert_add_info(pinfo, message_item, &ei_gtp_field_not_present);
9815                     break;
9816                 case 0:
9817                     break;
9818                 default:
9819                     expert_add_info_format(pinfo, message_item, &ei_gtp_wrong_next_field, "[WARNING] wrong next field, should be: %s",
9820                                         val_to_str_ext_const(checked_field, &gtp_val_ext, "Unknown extension field"));
9821                     break;
9822                 }
9823             }
9824 
9825             if (decoder == NULL) {
9826                 i = -1;
9827                 while (gtpopt[++i].optcode)
9828                     if (gtpopt[i].optcode == ext_hdr_val)
9829                         break;
9830                 decoder = gtpopt[i].decode;
9831             }
9832 
9833             offset = offset + (*decoder) (tvb, offset, pinfo, gtp_tree, args);
9834         }
9835 
9836         if (args && !PINFO_FD_VISITED(pinfo)) {
9837             /* We insert the lists inside the table*/
9838             fill_map(args->teid_list, args->ip_list, pinfo->num);
9839         }
9840         /*Use sequence number to track Req/Resp pairs*/
9841         if (has_SN) {
9842             guint8 cause_aux = 128; /* Cause accepted by default. Only used when args is NULL */
9843             if (args) {
9844                 cause_aux = args->last_cause;
9845             }
9846             gcrp = gtp_match_response(tvb, pinfo, gtp_tree, seq_no, gtp_hdr->message, gtp_info, cause_aux);
9847             /*pass packet to tap for response time reporting*/
9848             if (gcrp) {
9849                 tap_queue_packet(gtp_tap,pinfo,gcrp);
9850             }
9851         }
9852     }
9853     if (args) {
9854         track_gtp_session(tvb, pinfo, gtp_tree, gtp_hdr, args->teid_list, args->ip_list, args->last_teid, args->last_ip);
9855     }
9856     proto_item_set_end(ti, tvb, offset);
9857 
9858     if ((gtp_hdr->message == GTP_MSG_TPDU) && (tvb_reported_length_remaining(tvb, offset) > 0)) {
9859         switch (dissect_tpdu_as) {
9860         case GTP_TPDU_AS_TPDU_HEUR:
9861             sub_proto = tvb_get_guint8(tvb, offset);
9862 
9863             if ((sub_proto >= 0x45) && (sub_proto <= 0x4e)) {
9864                 /* this is most likely an IPv4 packet
9865                 * we can exclude 0x40 - 0x44 because the minimum header size is 20 octets
9866                 * 0x4f is excluded because PPP protocol type "IPv6 header compression"
9867                 * with protocol field compression is more likely than a plain IPv4 packet with 60 octet header size */
9868 
9869                 next_tvb = tvb_new_subset_remaining(tvb, offset);
9870                 call_dissector(ip_handle, next_tvb, pinfo, tree);
9871 
9872             } else if ((sub_proto & 0xf0) == 0x60) {
9873                 /* this is most likely an IPv6 packet */
9874                 next_tvb = tvb_new_subset_remaining(tvb, offset);
9875                 call_dissector(ipv6_handle, next_tvb, pinfo, tree);
9876             } else {
9877                 if (tvb_reported_length_remaining(tvb, offset)>14) {
9878                     guint16 eth_type;
9879                     eth_type = tvb_get_ntohs(tvb, offset+12);
9880                     if (eth_type == ETHERTYPE_ARP || eth_type == ETHERTYPE_IPv6 || eth_type == ETHERTYPE_IP) {
9881                         /* guess this is an ethernet PDU based on the eth type field */
9882                         next_tvb = tvb_new_subset_remaining(tvb, offset);
9883                         call_dissector(eth_handle, next_tvb, pinfo, tree);
9884                     }
9885                 } else {
9886 #if 0
9887                     /* This turns out not to be true, remove the code and try to improve it if we get bug reports */
9888                     /* this seems to be a PPP packet */
9889 
9890                     if (sub_proto == 0xff) {
9891                         guint8           control_field;
9892                         /* this might be an address field, even it shouldn't be here */
9893                         control_field = tvb_get_guint8(tvb, offset + 1);
9894                         if (control_field == 0x03)
9895                             /* now we are pretty sure that address and control field are mistakenly inserted -> ignore it for PPP dissection */
9896                             acfield_len = 2;
9897                     }
9898 
9899                     next_tvb = tvb_new_subset_remaining(tvb, offset + acfield_len);
9900                     call_dissector(ppp_handle, next_tvb, pinfo, tree);
9901 #endif
9902                     proto_tree_add_item(tree, hf_gtp_tpdu_data, tvb, offset, -1, ENC_NA);
9903                 }
9904             }
9905             col_prepend_fstr(pinfo->cinfo, COL_PROTOCOL, "GTP <");
9906             col_append_str(pinfo->cinfo, COL_PROTOCOL, ">");
9907             break;
9908         case GTP_TPDU_AS_PDCP_LTE:
9909             if (tvb_reported_length_remaining(tvb, offset) > 0) {
9910                 /* Check if we have info to call the PDCP dissector */
9911                 struct pdcp_lte_info *p_pdcp_info;
9912                 uat_pdcp_lte_keys_record_t * found_record;
9913                 tvbuff_t *pdcp_lte_tvb;
9914 
9915                 if ((found_record = look_up_pdcp_lte_keys_record(pinfo, (guint32)gtp_hdr->teid))) {
9916                     /* Look for attached packet info! */
9917                     p_pdcp_info = (struct pdcp_lte_info *)p_get_proto_data(wmem_file_scope(), pinfo, proto_pdcp_lte, 0);
9918                     /* If we don't have the data, add it */
9919                     if (p_pdcp_info == NULL) {
9920                         p_pdcp_info = wmem_new0(wmem_file_scope(), pdcp_lte_info);
9921                         /* Channel info is needed for RRC parsing */
9922                         /*p_pdcp_info->direction;*/
9923                         /*p_pdcp_info->ueid;*/
9924                         /*p_pdcp_info->channelType;*/
9925                         /*p_pdcp_info->channelId;*/
9926                         /*p_pdcp_info->BCCHTransport;*/
9927 
9928                         /* Details of PDCP header */
9929                         if (found_record->header_present == PDCP_LTE_HEADER_PRESENT) {
9930                             p_pdcp_info->no_header_pdu = FALSE;
9931                         } else {
9932                             p_pdcp_info->no_header_pdu = TRUE;
9933                         }
9934                         p_pdcp_info->plane = found_record->plane;
9935                         p_pdcp_info->seqnum_length = found_record->lte_sn_length;
9936 
9937                         /* RoHC settings */
9938                         p_pdcp_info->rohc.rohc_compression = found_record->rohc_compression;
9939                         p_pdcp_info->rohc.rohc_ip_version = 4; /* For now set it explicitly */
9940                         p_pdcp_info->rohc.cid_inclusion_info = FALSE;
9941                         p_pdcp_info->rohc.large_cid_present = FALSE;
9942                         p_pdcp_info->rohc.mode = MODE_NOT_SET;
9943                         p_pdcp_info->rohc.rnd = FALSE;
9944                         p_pdcp_info->rohc.udp_checksum_present = FALSE;
9945                         p_pdcp_info->rohc.profile = found_record->rohc_profile;
9946 
9947                        /* p_pdcp_info->is_retx;*/
9948 
9949                         /* Used by heuristic dissector only */
9950                         /*p_pdcp_info->pdu_length;*/
9951                         p_add_proto_data(wmem_file_scope(), pinfo, proto_pdcp_lte, 0, p_pdcp_info);
9952                     }
9953                     pdcp_lte_tvb = tvb_new_subset_remaining(tvb, offset);
9954                     call_dissector(pdcp_lte_handle, pdcp_lte_tvb, pinfo, tree);
9955 
9956                 } else {
9957                     proto_tree_add_subtree(tree, tvb, offset, -1, ett_gtp_pdcp_no_conf, NULL, "[No PDCP-LTE Configuration data found]");
9958                     proto_tree_add_item(tree, hf_pdcp_cont, tvb, offset, -1, ENC_NA);
9959                 }
9960             }
9961 
9962             break;
9963         case GTP_TPDU_AS_PDCP_NR:
9964             if (tvb_reported_length_remaining(tvb, offset) > 0) {
9965                 /*NR-U DUD or DDDS PDU
9966                 * This is NR-U DUD/DDDS PDU. It contains PDCP
9967                 * payload as per 3GPP TS 38.323
9968                 */
9969                 /* Check if we have info to call the PDCP dissector */
9970                 uat_pdcp_nr_keys_record_t* found_record;
9971 
9972                 if ((found_record = look_up_pdcp_nr_keys_record(pinfo, (guint32)gtp_hdr->teid))) {
9973                     tvbuff_t *pdcp_tvb;
9974                     struct pdcp_nr_info temp_data;
9975 
9976                     pdcp_tvb = tvb_new_subset_remaining(tvb, offset);
9977                     /* Fill in pdcp_nr_info */
9978 
9979                     temp_data.direction = found_record->direction;
9980                     /*temp_data.ueid*/
9981                     /*temp_data.bearerType;*/
9982                     /*temp_data.bearerId;*/
9983 
9984                     /* Details of PDCP header */
9985                     temp_data.plane = found_record->plane;
9986                     temp_data.seqnum_length = found_record->pdcp_nr_sn_length;
9987                     /* PDCP_NR_(U|D)L_sdap_hdr_PRESENT bitmask */
9988                     if (found_record->sdap_header_present == PDCP_NR_SDAP_HEADER_PRESENT) {
9989                         if (temp_data.direction == PDCP_NR_DIRECTION_UPLINK) {
9990                             temp_data.sdap_header = PDCP_NR_UL_SDAP_HEADER_PRESENT;
9991                         } else {
9992                             temp_data.sdap_header = PDCP_NR_DL_SDAP_HEADER_PRESENT;
9993                         }
9994                     } else {
9995                         temp_data.sdap_header = 0;
9996                     }
9997                     temp_data.maci_present = found_record->mac_i_present;
9998 
9999                     /* RoHC settings */
10000                     temp_data.rohc.rohc_compression = found_record->rohc_compression;
10001                     temp_data.rohc.rohc_ip_version = 4; /* For now set it explicitly */
10002                     temp_data.rohc.cid_inclusion_info = FALSE;
10003                     temp_data.rohc.large_cid_present = FALSE;
10004                     temp_data.rohc.mode = MODE_NOT_SET;
10005                     temp_data.rohc.rnd = FALSE;
10006                     temp_data.rohc.udp_checksum_present = FALSE;
10007                     temp_data.rohc.profile = found_record->rohc_profile;
10008 
10009                     temp_data.is_retx = 0;
10010 
10011                     /* Used by heuristic dissector only */
10012                     temp_data.pdu_length = 0;
10013 
10014                     call_dissector_with_data(pdcp_nr_handle, pdcp_tvb, pinfo, tree, &temp_data);
10015                 } else {
10016                     proto_tree_add_subtree(tree, tvb, offset, -1, ett_gtp_pdcp_no_conf, NULL, "[No PDCP-NR Configuration data found]");
10017                     proto_tree_add_item(tree, hf_pdcp_cont, tvb, offset, -1, ENC_NA);
10018                 }
10019             }
10020 
10021             break;
10022         case GTP_TPDU_AS_SYNC:
10023             next_tvb = tvb_new_subset_remaining(tvb, offset + acfield_len);
10024             call_dissector(sync_handle, next_tvb, pinfo, tree);
10025             col_prepend_fstr(pinfo->cinfo, COL_PROTOCOL, "GTP <");
10026             col_append_str(pinfo->cinfo, COL_PROTOCOL, ">");
10027             break;
10028         case GTP_TPDU_AS_ETHERNET:
10029             next_tvb = tvb_new_subset_remaining(tvb, offset);
10030             call_dissector(eth_handle, next_tvb, pinfo, tree);
10031             col_prepend_fstr(pinfo->cinfo, COL_PROTOCOL, "GTP <");
10032             col_append_str(pinfo->cinfo, COL_PROTOCOL, ">");
10033             break;
10034         case GTP_TPDU_AS_CUSTOM:
10035             /* Call a custom dissector if available */
10036             if (gtp_tpdu_custom_handle ||
10037                  (gtp_tpdu_custom_handle = find_dissector("gtp_tpdu_custom"))) {
10038                 next_tvb = tvb_new_subset_remaining(tvb, offset);
10039                 call_dissector(gtp_tpdu_custom_handle, next_tvb, pinfo, tree);
10040                 col_prepend_fstr(pinfo->cinfo, COL_PROTOCOL, "GTP <");
10041                 col_append_str(pinfo->cinfo, COL_PROTOCOL, ">");
10042             } else {
10043                 proto_tree_add_item(tree, hf_gtp_tpdu_data, tvb, offset, -1, ENC_NA);
10044             }
10045             break;
10046         default:
10047             proto_tree_add_item(tree, hf_gtp_tpdu_data, tvb, offset, -1, ENC_NA);
10048             break;
10049         }
10050     }
10051 
10052     tap_queue_packet(gtpv1_tap,pinfo, gtp_hdr);
10053 
10054     return tvb_reported_length(tvb);
10055 }
10056 
10057 static int
dissect_gtpprime(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,void * private_data _U_)10058 dissect_gtpprime(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree,
10059                 void *private_data _U_)
10060 {
10061     return dissect_gtp_common(tvb, pinfo, tree);
10062 }
10063 
10064 static int
dissect_gtp(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,void * private_data _U_)10065 dissect_gtp(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree,
10066             void *private_data _U_)
10067 {
10068     guint8 version;
10069 
10070     /*
10071      * Do we have enough data to check the first byte?
10072      */
10073     if (!tvb_bytes_exist(tvb, 0, 1)) {
10074         /* No. */
10075         return 0;
10076     }
10077 
10078     /*
10079      * If this is GTPv2-C call the gtpv2 dissector if present
10080      * Should this be moved to after the conversation stuff to retain that functionality for GTPv2 ???
10081      */
10082     version = tvb_get_guint8(tvb,0)>>5;
10083     if (version > 2) {
10084         /* Unknown version - reject the packet */
10085         return 0;
10086     }
10087     if (version == 2) {
10088         /* GTPv2-C 3GPP TS 29.274 */
10089         if (gtpv2_handle) {
10090             call_dissector(gtpv2_handle, tvb, pinfo, tree);
10091             return tvb_reported_length(tvb);
10092         }
10093     }
10094 
10095     return dissect_gtp_common(tvb, pinfo, tree);
10096 }
10097 
10098 static void
gtp_init(void)10099 gtp_init(void)
10100 {
10101     gtp_session_count = 1;
10102     session_table = g_hash_table_new(g_int_hash, g_int_equal);
10103     frame_tree = wmem_tree_new(wmem_file_scope());
10104 }
10105 
10106 static void
gtp_cleanup(void)10107 gtp_cleanup(void)
10108 {
10109     gtp_conv_info_t *gtp_info;
10110 
10111     /* Free up state attached to the gtp_info structures */
10112     for (gtp_info = gtp_info_items; gtp_info != NULL; ) {
10113         gtp_conv_info_t *next;
10114 
10115         g_hash_table_destroy(gtp_info->matched);
10116         gtp_info->matched=NULL;
10117         g_hash_table_destroy(gtp_info->unmatched);
10118         gtp_info->unmatched=NULL;
10119 
10120         next = gtp_info->next;
10121         gtp_info = next;
10122     }
10123 
10124     /* Free up state attached to the gtp session structures */
10125     gtp_info_items = NULL;
10126 
10127     if (session_table != NULL) {
10128         g_hash_table_destroy(session_table);
10129     }
10130     session_table = NULL;
10131 }
10132 
10133 void
proto_register_gtp(void)10134 proto_register_gtp(void)
10135 {
10136     module_t *gtp_module;
10137     expert_module_t* expert_gtp;
10138     guint     i;
10139     guint     last_offset;
10140 
10141     static hf_register_info hf_gtp[] = {
10142 
10143         {&hf_gtp_ie_id,
10144          { "IE Id", "gtp.ie_id",
10145            FT_UINT8, BASE_DEC|BASE_EXT_STRING, &gtp_val_ext, 0x0,
10146            NULL, HFILL}
10147         },
10148         {&hf_gtp_response_in,
10149          { "Response In", "gtp.response_in",
10150            FT_FRAMENUM, BASE_NONE, NULL, 0x0,
10151            "The response to this GTP request is in this frame", HFILL}
10152         },
10153         {&hf_gtp_response_to,
10154          { "Response To", "gtp.response_to",
10155            FT_FRAMENUM, BASE_NONE, NULL, 0x0,
10156            "This is a response to the GTP request in this frame", HFILL}
10157         },
10158         {&hf_gtp_time,
10159          { "Time", "gtp.time",
10160            FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
10161            "The time between the Request and the Response", HFILL}
10162         },
10163         {&hf_gtp_apn,
10164          { "APN", "gtp.apn",
10165            FT_STRING, BASE_NONE, NULL, 0,
10166            "Access Point Name", HFILL}
10167         },
10168         {&hf_gtp_cause,
10169          { "Cause", "gtp.cause",
10170            FT_UINT8, BASE_DEC|BASE_EXT_STRING, &cause_type_ext, 0,
10171            "Cause of operation", HFILL}
10172         },
10173         {&hf_gtp_chrg_char,
10174          { "Charging characteristics", "gtp.chrg_char",
10175            FT_UINT16, BASE_DEC, NULL, 0,
10176            NULL, HFILL}
10177         },
10178         {&hf_gtp_chrg_char_s,
10179          { "Spare", "gtp.chrg_char_s",
10180            FT_UINT16, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_S,
10181            NULL, HFILL}
10182         },
10183         {&hf_gtp_chrg_char_n,
10184          { "Normal charging", "gtp.chrg_char_n",
10185            FT_UINT16, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_N,
10186            NULL, HFILL}
10187         },
10188         {&hf_gtp_chrg_char_p,
10189          { "Prepaid charging", "gtp.chrg_char_p",
10190            FT_UINT16, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_P,
10191            NULL, HFILL}
10192         },
10193         {&hf_gtp_chrg_char_f,
10194          { "Flat rate charging", "gtp.chrg_char_f",
10195            FT_UINT16, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_F,
10196            NULL, HFILL}
10197         },
10198         {&hf_gtp_chrg_char_h,
10199          { "Hot billing charging", "gtp.chrg_char_h",
10200            FT_UINT16, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_H,
10201            NULL, HFILL}
10202         },
10203         {&hf_gtp_chrg_char_r,
10204          { "Reserved", "gtp.chrg_char_r",
10205            FT_UINT16, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_R,
10206            NULL, HFILL}
10207         },
10208         {&hf_gtp_chrg_id,
10209          { "Charging ID", "gtp.chrg_id",
10210            FT_UINT32, BASE_HEX_DEC, NULL, 0,
10211            NULL, HFILL}
10212         },
10213         {&hf_gtp_chrg_ipv4,
10214          { "CG address IPv4", "gtp.chrg_ipv4",
10215            FT_IPv4, BASE_NONE, NULL, 0,
10216            "Charging Gateway address IPv4", HFILL}
10217         },
10218         {&hf_gtp_chrg_ipv6,
10219          { "CG address IPv6", "gtp.chrg_ipv6",
10220            FT_IPv6, BASE_NONE, NULL, 0,
10221            "Charging Gateway address IPv6", HFILL}
10222         },
10223         {&hf_gtp_ext_flow_label,
10224          { "Flow Label Data I", "gtp.ext_flow_label",
10225            FT_UINT16, BASE_HEX, NULL, 0,
10226            "Flow label data", HFILL}
10227         },
10228         {&hf_gtp_ext_id,
10229          { "Extension identifier", "gtp.ext_id",
10230            FT_UINT16, BASE_ENTERPRISES, STRINGS_ENTERPRISES, 0,
10231            "Private Enterprise number", HFILL}
10232         },
10233         {&hf_gtp_ext_val,
10234          { "Extension value", "gtp.ext_val",
10235            FT_BYTES, BASE_NONE, NULL, 0,
10236            NULL, HFILL}
10237         },
10238         {&hf_gtp_flags,
10239          { "Flags", "gtp.flags",
10240            FT_UINT8, BASE_HEX, NULL, 0,
10241            "Ver/PT/Spare...", HFILL}
10242         },
10243         {&hf_gtp_ext_hdr,
10244          { "Extension header", "gtp.ext_hdr",
10245            FT_NONE, BASE_NONE, NULL, 0,
10246            NULL, HFILL}
10247         },
10248         {&hf_gtp_ext_hdr_next,
10249          { "Next extension header type", "gtp.ext_hdr.next",
10250            FT_UINT8, BASE_HEX, VALS(next_extension_header_fieldvals), 0,
10251            NULL, HFILL}
10252         },
10253         {&hf_gtp_ext_hdr_ran_cont,
10254          { "RAN Container", "gtp.ext_hdr.ran_cont",
10255            FT_BYTES, BASE_NONE, NULL, 0,
10256            NULL, HFILL}
10257         },
10258         {&hf_gtp_ext_hdr_spare_bits,
10259          { "Spare", "gtp.ext_hdr.spare_bits",
10260            FT_UINT8, BASE_HEX, NULL, 0,
10261            NULL, HFILL}
10262         },
10263         {&hf_gtp_ext_hdr_spare_bytes,
10264          { "Spare", "gtp.ext_hdr.spare_bytes",
10265            FT_BYTES, BASE_NONE, NULL, 0,
10266            NULL, HFILL}
10267         },
10268         {&hf_gtp_ext_hdr_long_pdcp_sn,
10269          { "Long PDCP Sequence Number", "gtp.ext_hdr.long_pdcp_sn",
10270            FT_UINT24, BASE_DEC, NULL, 0,
10271            NULL, HFILL}
10272         },
10273         {&hf_gtp_ext_hdr_xw_ran_cont,
10274          { "Xw RAN Container", "gtp.ext_hdr.xw_ran_cont",
10275            FT_BYTES, BASE_NONE, NULL, 0,
10276            NULL, HFILL}
10277         },
10278 
10279         { &hf_gtp_ext_hdr_pdu_ses_cont_pdu_type,
10280          { "PDU Type", "gtp.ext_hdr.pdu_ses_con.pdu_type",
10281            FT_UINT8, BASE_DEC, VALS(gtp_ext_hdr_pdu_ses_cont_pdu_type_vals), 0xf0,
10282            NULL, HFILL}
10283         },
10284         { &hf_gtp_ext_hdr_pdu_ses_cont_ppp,
10285          { "Paging Policy Presence (PPP)", "gtp.ext_hdr.pdu_ses_cont.ppp",
10286            FT_BOOLEAN, 8, TFS(&tfs_present_not_present), 0x80,
10287            NULL, HFILL}
10288         },
10289         { &hf_gtp_ext_hdr_pdu_ses_cont_rqi,
10290          { "Reflective QoS Indicator (RQI)", "gtp.ext_hdr.pdu_ses_cont.rqi",
10291            FT_BOOLEAN, 8, TFS(&tfs_present_not_present), 0x40,
10292            NULL, HFILL}
10293         },
10294         { &hf_gtp_ext_hdr_pdu_ses_cont_qos_flow_id,
10295          { "QoS Flow Identifier (QFI)", "gtp.ext_hdr.pdu_ses_con.qos_flow_id",
10296            FT_UINT8, BASE_DEC, NULL, 0x3f,
10297            NULL, HFILL}
10298         },
10299         { &hf_gtp_ext_hdr_pdu_ses_cont_ppi,
10300          { "Paging Policy Indicator (PPI)", "gtp.ext_hdr.pdu_ses_cont.ppi",
10301            FT_UINT8, BASE_DEC, NULL, 0xe0,
10302            NULL, HFILL}
10303         },
10304 
10305         {&hf_pdcp_cont,
10306          { "PDCP Protocol", "gtp.pdcp",
10307            FT_BYTES, BASE_NONE, NULL, 0,
10308            NULL, HFILL}
10309         },
10310         {&hf_gtp_ext_hdr_pdcpsn,
10311          { "PDCP Sequence Number", "gtp.ext_hdr.pdcp_sn",
10312            FT_UINT16, BASE_DEC, NULL, 0,
10313            NULL, HFILL}
10314         },
10315         {&hf_gtp_ext_hdr_udp_port,
10316          { "UDP Port", "gtp.ext_hdr.udp_port",
10317            FT_UINT16, BASE_DEC, NULL, 0,
10318            NULL, HFILL}
10319         },
10320         {&hf_gtp_ext_hdr_length,
10321          { "Extension Header Length", "gtp.ext_hdr.length",
10322            FT_UINT8, BASE_DEC, NULL, 0,
10323            NULL, HFILL}
10324         },
10325         {&hf_gtp_flags_ver,
10326          { "Version", "gtp.flags.version",
10327            FT_UINT8, BASE_DEC, VALS(ver_types), GTP_VER_MASK,
10328            "GTP Version", HFILL}
10329         },
10330         {&hf_gtp_prime_flags_ver,
10331          { "Version", "gtp.prim.flags.version",
10332            FT_UINT8, BASE_DEC,NULL, GTP_VER_MASK,
10333            "GTP' Version", HFILL}
10334         },
10335         {&hf_gtp_flags_pt,
10336          { "Protocol type", "gtp.flags.payload",
10337            FT_UINT8, BASE_DEC, VALS(pt_types), GTP_PT_MASK,
10338            NULL, HFILL}
10339         },
10340         {&hf_gtp_flags_spare1,
10341          { "Reserved", "gtp.flags.reserved",
10342            FT_UINT8, BASE_DEC, NULL, GTP_SPARE1_MASK,
10343            "Reserved (shall be sent as '111' )", HFILL}
10344         },
10345         {&hf_gtp_flags_hdr_length,
10346          { "Header length", "gtp.flags.hdr_length",
10347            FT_BOOLEAN, 8,  TFS(&gtp_hdr_length_vals), 0x01,
10348            NULL, HFILL}
10349         },
10350         {&hf_gtp_flags_snn,
10351          { "Is SNDCP N-PDU included?", "gtp.flags.snn",
10352            FT_BOOLEAN, 8, TFS(&tfs_yes_no), GTP_SNN_MASK,
10353            "Is SNDCP N-PDU LLC Number included? (1 = yes, 0 = no)", HFILL}
10354         },
10355         {&hf_gtp_flags_spare2,
10356          { "Reserved", "gtp.flags.reserved",
10357            FT_UINT8, BASE_DEC, NULL, GTP_SPARE2_MASK,
10358            "Reserved (shall be sent as '1' )", HFILL}
10359         },
10360         {&hf_gtp_flags_e,
10361          { "Is Next Extension Header present?", "gtp.flags.e",
10362            FT_BOOLEAN, 8, TFS(&tfs_yes_no), GTP_E_MASK,
10363            "Is Next Extension Header present? (1 = yes, 0 = no)", HFILL}
10364         },
10365         {&hf_gtp_flags_s,
10366          { "Is Sequence Number present?", "gtp.flags.s",
10367            FT_BOOLEAN, 8, TFS(&tfs_yes_no), GTP_S_MASK,
10368            "Is Sequence Number present? (1 = yes, 0 = no)", HFILL}
10369         },
10370         {&hf_gtp_flags_pn,
10371          { "Is N-PDU number present?", "gtp.flags.pn",
10372            FT_BOOLEAN, 8, TFS(&tfs_yes_no), GTP_PN_MASK,
10373            "Is N-PDU number present? (1 = yes, 0 = no)", HFILL}
10374         },
10375         {&hf_gtp_flow_ii,
10376          { "Flow Label Data II", "gtp.flow_ii",
10377            FT_UINT16, BASE_DEC, NULL, 0,
10378            "Downlink flow label data", HFILL}
10379         },
10380         {&hf_gtp_flow_label,
10381          { "Flow label", "gtp.flow_label",
10382            FT_UINT16, BASE_HEX, NULL, 0,
10383            NULL, HFILL}
10384         },
10385         {&hf_gtp_flow_sig,
10386          { "Flow label Signalling", "gtp.flow_sig",
10387            FT_UINT16, BASE_HEX, NULL, 0,
10388            NULL, HFILL}
10389         },
10390         {&hf_gtp_gsn_addr_len,
10391          { "GSN Address Length", "gtp.gsn_addr_len",
10392            FT_UINT8, BASE_DEC, NULL, GTP_EXT_GSN_ADDR_LEN_MASK,
10393            NULL, HFILL}
10394         },
10395         {&hf_gtp_gsn_addr_type,
10396          { "GSN Address Type", "gtp.gsn_addr_type",
10397            FT_UINT8, BASE_DEC, VALS(gsn_addr_type), GTP_EXT_GSN_ADDR_TYPE_MASK,
10398            NULL, HFILL}
10399         },
10400         {&hf_gtp_gsn_ipv4,
10401          { "GSN address IPv4", "gtp.gsn_ipv4",
10402            FT_IPv4, BASE_NONE, NULL, 0,
10403            NULL, HFILL}
10404         },
10405         {&hf_gtp_gsn_ipv6,
10406          { "GSN address IPv6", "gtp.gsn_ipv6",
10407            FT_IPv6, BASE_NONE, NULL, 0,
10408            NULL, HFILL}
10409         },
10410         {&hf_gtp_length,
10411          { "Length", "gtp.length",
10412            FT_UINT16, BASE_DEC, NULL, 0,
10413            "Length (i.e. number of octets after TID or TEID)", HFILL}
10414         },
10415         {&hf_gtp_map_cause,
10416          { "MAP cause", "gtp.map_cause",
10417            FT_UINT8, BASE_DEC, VALS(gsm_old_GSMMAPLocalErrorcode_vals), 0,
10418            NULL, HFILL}
10419         },
10420         {&hf_gtp_message_type,
10421          { "Message Type", "gtp.message",
10422            FT_UINT8, BASE_HEX|BASE_EXT_STRING, &gtp_message_type_ext, 0x0,
10423            "GTP Message Type", HFILL}
10424         },
10425         {&hf_gtp_ms_reason,
10426          { "MS not reachable reason", "gtp.ms_reason",
10427            FT_UINT8, BASE_DEC, VALS(ms_not_reachable_type), 0,
10428            NULL, HFILL}
10429         },
10430         {&hf_gtp_ms_valid,
10431          { "MS validated", "gtp.ms_valid",
10432            FT_BOOLEAN, BASE_NONE, NULL, 0x0,
10433            NULL, HFILL}
10434         },
10435         {&hf_gtp_node_ipv4,
10436          { "Node address IPv4", "gtp.node_ipv4",
10437            FT_IPv4, BASE_NONE, NULL, 0,
10438            "Recommended node address IPv4", HFILL}
10439         },
10440         {&hf_gtp_node_ipv6,
10441          { "Node address IPv6", "gtp.node_ipv6",
10442            FT_IPv6, BASE_NONE, NULL, 0,
10443            "Recommended node address IPv6", HFILL}
10444         },
10445         {&hf_gtp_node_name,
10446          { "Node name", "gtp.node_name",
10447            FT_UINT_STRING, STR_ASCII, NULL, 0,
10448            "Diameter Identity of the node", HFILL}
10449         },
10450         {&hf_gtp_node_realm,
10451          { "Node realm", "gtp.node_realm",
10452            FT_UINT_STRING, STR_ASCII, NULL, 0,
10453            "Diameter Realm Identity of the node", HFILL}
10454         },
10455         {&hf_gtp_npdu_number,
10456          { "N-PDU Number", "gtp.npdu_number",
10457            FT_UINT8, BASE_HEX, NULL, 0,
10458            NULL, HFILL}
10459         },
10460         {&hf_gtp_nsapi,
10461          { "NSAPI", "gtp.nsapi",
10462            FT_UINT8, BASE_DEC, NULL, 0x0f,
10463            "Network layer Service Access Point Identifier", HFILL}
10464         },
10465         {&hf_gtp_qos_version,
10466          { "Version", "gtp.qos_version",
10467            FT_UINT8, BASE_HEX, NULL, 0,
10468            "Version of the QoS Profile", HFILL}
10469         },
10470         {&hf_gtp_qos_spare1,
10471          { "Spare", "gtp.qos_spare1",
10472            FT_UINT8, BASE_DEC, NULL, GTP_EXT_QOS_SPARE1_MASK,
10473            "Spare (shall be sent as '00' )", HFILL}
10474         },
10475         {&hf_gtp_qos_delay,
10476          { "QoS delay", "gtp.qos_delay",
10477            FT_UINT8, BASE_DEC, VALS(qos_delay_type), GTP_EXT_QOS_DELAY_MASK,
10478            "Quality of Service Delay Class", HFILL}
10479         },
10480         {&hf_gtp_qos_reliability,
10481          { "QoS reliability", "gtp.qos_reliability",
10482            FT_UINT8, BASE_DEC, VALS(qos_reliability_type), GTP_EXT_QOS_RELIABILITY_MASK,
10483            "Quality of Service Reliability Class", HFILL}
10484         },
10485         {&hf_gtp_qos_peak,
10486          { "QoS peak", "gtp.qos_peak",
10487            FT_UINT8, BASE_DEC, VALS(qos_peak_type), GTP_EXT_QOS_PEAK_MASK,
10488            "Quality of Service Peak Throughput", HFILL}
10489         },
10490         {&hf_gtp_qos_spare2,
10491          { "Spare", "gtp.qos_spare2",
10492            FT_UINT8, BASE_DEC, NULL, GTP_EXT_QOS_SPARE2_MASK,
10493            "Spare (shall be sent as 0)", HFILL}
10494         },
10495         {&hf_gtp_qos_precedence,
10496          { "QoS precedence", "gtp.qos_precedence",
10497            FT_UINT8, BASE_DEC, VALS(qos_precedence_type), GTP_EXT_QOS_PRECEDENCE_MASK,
10498            "Quality of Service Precedence Class", HFILL}
10499         },
10500         {&hf_gtp_qos_spare3,
10501          { "Spare", "gtp.qos_spare3",
10502            FT_UINT8, BASE_DEC, NULL, GTP_EXT_QOS_SPARE3_MASK,
10503            "Spare (shall be sent as '000' )", HFILL}
10504         },
10505         {&hf_gtp_qos_mean,
10506          { "QoS mean", "gtp.qos_mean",
10507            FT_UINT8, BASE_DEC|BASE_EXT_STRING, &qos_mean_type_ext, GTP_EXT_QOS_MEAN_MASK,
10508            "Quality of Service Mean Throughput", HFILL}
10509         },
10510         {&hf_gtp_qos_al_ret_priority,
10511          { "Allocation/Retention priority", "gtp.qos_al_ret_priority",
10512            FT_UINT8, BASE_DEC, NULL, 0,
10513            NULL, HFILL}
10514         },
10515         {&hf_gtp_qos_traf_class,
10516          { "Traffic class", "gtp.qos_traf_class",
10517            FT_UINT8, BASE_DEC, VALS(qos_traf_class), GTP_EXT_QOS_TRAF_CLASS_MASK,
10518            NULL, HFILL}
10519         },
10520         {&hf_gtp_qos_del_order,
10521          { "Delivery order", "gtp.qos_del_order",
10522            FT_UINT8, BASE_DEC, VALS(qos_del_order), GTP_EXT_QOS_DEL_ORDER_MASK,
10523            NULL, HFILL}
10524         },
10525         {&hf_gtp_qos_del_err_sdu,
10526          { "Delivery of erroneous SDU", "gtp.qos_del_err_sdu",
10527            FT_UINT8, BASE_DEC, VALS(qos_del_err_sdu), GTP_EXT_QOS_DEL_ERR_SDU_MASK,
10528            NULL, HFILL}
10529         },
10530         {&hf_gtp_qos_max_sdu_size,
10531          { "Maximum SDU size", "gtp.qos_max_sdu_size",
10532            FT_UINT8, BASE_DEC, VALS(qos_max_sdu_size), 0,
10533            NULL, HFILL}
10534         },
10535         {&hf_gtp_qos_max_ul,
10536          { "Maximum bit rate for uplink", "gtp.qos_max_ul",
10537            FT_UINT8, BASE_DEC, VALS(qos_max_ul), 0,
10538            NULL, HFILL}
10539         },
10540         {&hf_gtp_qos_max_dl,
10541          { "Maximum bit rate for downlink", "gtp.qos_max_dl",
10542            FT_UINT8, BASE_DEC, VALS(qos_max_dl), 0,
10543            NULL, HFILL}
10544         },
10545         {&hf_gtp_qos_res_ber,
10546          { "Residual BER", "gtp.qos_res_ber",
10547            FT_UINT8, BASE_DEC, VALS(qos_res_ber), GTP_EXT_QOS_RES_BER_MASK,
10548            "Residual Bit Error Rate", HFILL}
10549         },
10550         {&hf_gtp_qos_sdu_err_ratio,
10551          { "SDU Error ratio", "gtp.qos_sdu_err_ratio",
10552            FT_UINT8, BASE_DEC, VALS(qos_sdu_err_ratio), GTP_EXT_QOS_SDU_ERR_RATIO_MASK,
10553            NULL,
10554            HFILL}
10555         },
10556         {&hf_gtp_qos_trans_delay,
10557          { "Transfer delay", "gtp.qos_trans_delay",
10558            FT_UINT8, BASE_DEC|BASE_EXT_STRING, &qos_trans_delay_ext, GTP_EXT_QOS_TRANS_DELAY_MASK,
10559            NULL, HFILL}
10560         },
10561         {&hf_gtp_qos_traf_handl_prio,
10562          { "Traffic handling priority", "gtp.qos_traf_handl_prio",
10563            FT_UINT8, BASE_DEC, VALS(qos_traf_handl_prio), GTP_EXT_QOS_TRAF_HANDL_PRIORITY_MASK,
10564            NULL, HFILL}
10565         },
10566         {&hf_gtp_qos_guar_ul,
10567          { "Guaranteed bit rate for uplink", "gtp.qos_guar_ul",
10568            FT_UINT8, BASE_DEC, VALS(qos_guar_ul), 0,
10569            NULL, HFILL}
10570         },
10571         {&hf_gtp_qos_guar_dl,
10572          { "Guaranteed bit rate for downlink", "gtp.qos_guar_dl",
10573            FT_UINT8, BASE_DEC, VALS(qos_guar_dl), 0,
10574            NULL, HFILL}
10575         },
10576         {&hf_gtp_qos_spare4,
10577          { "Spare", "gtp.qos_spare4",
10578            FT_UINT8, BASE_DEC, NULL, GTP_EXT_QOS_SPARE4_MASK,
10579            "Spare (shall be sent as '000' )", HFILL}
10580         },
10581         {&hf_gtp_qos_sig_ind,
10582          { "Signalling Indication", "gtp.sig_ind",
10583            FT_BOOLEAN, 8, TFS(&gtp_sig_ind), GTP_EXT_QOS_SIG_IND_MASK,
10584            NULL, HFILL}
10585         },
10586         {&hf_gtp_qos_src_stat_desc,
10587          { "Source Statistics Descriptor", "gtp.src_stat_desc",
10588            FT_UINT8, BASE_DEC, VALS(src_stat_desc_vals), GTP_EXT_QOS_SRC_STAT_DESC_MASK,
10589            NULL, HFILL}
10590         },
10591         { &hf_gtp_qos_arp,
10592           {"Allocation/Retention Priority", "gtp.qos_arp",
10593           FT_UINT16, BASE_HEX, NULL, 0x0,
10594           NULL, HFILL}
10595         },
10596         { &hf_gtp_qos_arp_pci,
10597           {"Pre-emption Capability (PCI)", "gtp.qos_arp_pci",
10598           FT_BOOLEAN, 16, TFS(&tfs_disabled_enabled), 0x40,
10599           NULL, HFILL}
10600         },
10601         { &hf_gtp_qos_arp_pl,
10602           {"Priority Level", "gtp.qos_arp_pl",
10603           FT_UINT16, BASE_DEC, NULL, 0x3c,
10604           NULL, HFILL}
10605         },
10606         { &hf_gtp_qos_arp_pvi,
10607           {"Pre-emption Vulnerability (PVI)", "gtp.qos_arp_pvi",
10608           FT_BOOLEAN, 16, TFS(&tfs_disabled_enabled), 0x01,
10609           NULL, HFILL}
10610         },
10611         {&hf_gtp_qos_qci,
10612          {"QCI", "gtp.qos_qci",
10613           FT_UINT8, BASE_DEC, NULL, 0x0,
10614           NULL, HFILL}
10615         },
10616         {&hf_gtp_qos_ul_mbr,
10617          {"Uplink Maximum Bit Rate", "gtp.qos_ul_mbr",
10618           FT_UINT64, BASE_DEC, NULL, 0x0,
10619           NULL, HFILL}
10620         },
10621         {&hf_gtp_qos_dl_mbr,
10622          {"Downlink Maximum Bit Rate", "gtp.qos_dl_mbr",
10623           FT_UINT64, BASE_DEC, NULL, 0x0,
10624           NULL, HFILL}
10625         },
10626         {&hf_gtp_qos_ul_gbr,
10627          {"Uplink Guaranteed Bit Rate", "gtp.qos_ul_gbr",
10628           FT_UINT64, BASE_DEC, NULL, 0x0,
10629           NULL, HFILL}
10630         },
10631         {&hf_gtp_qos_dl_gbr,
10632          {"Downlink Guaranteed Bit Rate", "gtp.qos_dl_gbr",
10633           FT_UINT64, BASE_DEC, NULL, 0x0,
10634           NULL, HFILL}
10635         },
10636         {&hf_gtp_qos_ul_apn_ambr,
10637          {"Uplink APN Aggregate Maximum Bit Rate", "gtp.qos_ul_apn_ambr",
10638           FT_UINT32, BASE_DEC, NULL, 0x0,
10639           NULL, HFILL}
10640         },
10641         {&hf_gtp_qos_dl_apn_ambr,
10642          {"Downlink APN Aggregate Maximum Bit Rate", "gtp.qos_dl_apn_ambr",
10643           FT_UINT32, BASE_DEC, NULL, 0x0,
10644           NULL, HFILL}
10645         },
10646         {&hf_gtp_pkt_flow_id,
10647          { "Packet Flow ID", "gtp.pkt_flow_id",
10648            FT_UINT8, BASE_DEC, NULL, 0,
10649            NULL, HFILL}
10650         },
10651         {&hf_gtp_ptmsi,
10652          { "P-TMSI", "gtp.ptmsi",
10653            FT_UINT32, BASE_DEC_HEX, NULL, 0,
10654            "Packet-Temporary Mobile Subscriber Identity", HFILL}
10655         },
10656         {&hf_gtp_ptmsi_sig,
10657          { "P-TMSI Signature", "gtp.ptmsi_sig",
10658            FT_UINT24, BASE_HEX, NULL, 0,
10659            NULL, HFILL}
10660         },
10661         {&hf_gtp_rab_gtpu_dn,
10662          { "Downlink GTP-U seq number", "gtp.rab_gtp_dn",
10663            FT_UINT16, BASE_DEC, NULL, 0,
10664            "Downlink GTP-U sequence number", HFILL}
10665         },
10666         {&hf_gtp_rab_gtpu_up,
10667          { "Uplink GTP-U seq number", "gtp.rab_gtp_up",
10668            FT_UINT16, BASE_DEC, NULL, 0,
10669            "Uplink GTP-U sequence number", HFILL}
10670         },
10671         {&hf_gtp_rab_pdu_dn,
10672          { "Downlink next PDCP-PDU seq number", "gtp.rab_pdu_dn",
10673            FT_UINT16, BASE_DEC, NULL, 0,
10674            "Downlink next PDCP-PDU sequence number", HFILL}
10675         },
10676         {&hf_gtp_rab_pdu_up,
10677          { "Uplink next PDCP-PDU seq number", "gtp.rab_pdu_up",
10678            FT_UINT16, BASE_DEC, NULL, 0,
10679            "Uplink next PDCP-PDU sequence number", HFILL}
10680         },
10681         {&hf_gtp_uli_geo_loc_type,
10682          { "Geographic Location Type", "gtp.geo_loc_type",
10683            FT_UINT8, BASE_DEC, VALS(geographic_location_type),  0,
10684            NULL, HFILL}
10685         },
10686         {&hf_gtp_cgi_ci,
10687          { "Cell ID (CI)", "gtp.cgi_ci",
10688            FT_UINT16, BASE_DEC, NULL, 0,
10689            NULL, HFILL}
10690         },
10691         {&hf_gtp_sai_sac,
10692          { "Service Area Code (SAC)", "gtp.sai_sac",
10693            FT_UINT16, BASE_DEC, NULL, 0,
10694            NULL, HFILL}
10695         },
10696         {&hf_gtp_rai_rac,
10697          { "Routing Area Code (RAC)", "gtp.rai_rac",
10698            FT_UINT16, BASE_DEC, NULL, 0,
10699            NULL, HFILL}
10700         },
10701         {&hf_gtp_lac,
10702          { "Location Area Code (LAC)", "gtp.lac",
10703            FT_UINT16, BASE_DEC, NULL, 0,
10704            NULL, HFILL}
10705         },
10706         { &hf_gtp_tac,
10707           {"TAC", "gtp.tac",
10708            FT_UINT16, BASE_DEC, NULL, 0,
10709            NULL, HFILL}
10710         },
10711         {&hf_gtp_ranap_cause,
10712          { "RANAP cause", "gtp.ranap_cause",
10713            FT_UINT8, BASE_DEC|BASE_EXT_STRING, &ranap_cause_type_ext, 0,
10714            NULL, HFILL}
10715         },
10716         {&hf_gtp_recovery,
10717          { "Recovery", "gtp.recovery",
10718            FT_UINT8, BASE_DEC, NULL, 0,
10719            "Restart counter", HFILL}
10720         },
10721         {&hf_gtp_reorder,
10722          { "Reordering required", "gtp.reorder",
10723            FT_BOOLEAN, BASE_NONE, NULL, 0x0,
10724            NULL, HFILL}
10725         },
10726         {&hf_gtp_rnc_ipv4,
10727          { "RNC address IPv4", "gtp.rnc_ipv4",
10728            FT_IPv4, BASE_NONE, NULL, 0,
10729            "Radio Network Controller address IPv4", HFILL}
10730         },
10731         {&hf_gtp_rnc_ipv6,
10732          { "RNC address IPv6", "gtp.rnc_ipv6",
10733            FT_IPv6, BASE_NONE, NULL, 0,
10734            "Radio Network Controller address IPv6", HFILL}
10735         },
10736         {&hf_gtp_rp,
10737          { "Radio Priority", "gtp.rp",
10738            FT_UINT8, BASE_DEC, NULL, GTPv1_EXT_RP_MASK,
10739            "Radio Priority for uplink tx", HFILL}
10740         },
10741         {&hf_gtp_rp_nsapi,
10742          { "NSAPI in Radio Priority", "gtp.rp_nsapi",
10743            FT_UINT8, BASE_DEC, NULL, GTPv1_EXT_RP_NSAPI_MASK,
10744            "Network layer Service Access Point Identifier in Radio Priority", HFILL}
10745         },
10746         {&hf_gtp_rp_sms,
10747          { "Radio Priority SMS", "gtp.rp_sms",
10748            FT_UINT8, BASE_DEC, NULL, 0,
10749            "Radio Priority for MO SMS", HFILL}
10750         },
10751         {&hf_gtp_rp_spare,
10752          { "Reserved", "gtp.rp_spare",
10753            FT_UINT8, BASE_DEC, NULL, GTPv1_EXT_RP_SPARE_MASK,
10754            "Spare bit", HFILL}
10755         },
10756         {&hf_gtp_sel_mode,
10757          { "Selection mode", "gtp.sel_mode",
10758            FT_UINT8, BASE_DEC, VALS(sel_mode_type), 0x03,
10759            NULL, HFILL}
10760         },
10761         {&hf_gtp_seq_number,
10762          { "Sequence number", "gtp.seq_number",
10763            FT_UINT16, BASE_HEX_DEC, NULL, 0,
10764            NULL, HFILL}
10765         },
10766         { &hf_gtp_session,
10767         { "Session", "gtp.session",
10768         FT_UINT32, BASE_DEC, NULL, 0,
10769         NULL, HFILL }
10770         },
10771         {&hf_gtp_sndcp_number,
10772          { "SNDCP N-PDU LLC Number", "gtp.sndcp_number",
10773            FT_UINT8, BASE_HEX, NULL, 0,
10774            NULL, HFILL}
10775         },
10776         {&hf_gtp_tear_ind,
10777          { "Teardown Indicator", "gtp.tear_ind",
10778            FT_BOOLEAN, BASE_NONE, NULL, 0x0,
10779            NULL, HFILL}
10780         },
10781         {&hf_gtp_teid,
10782          { "TEID", "gtp.teid",
10783            FT_UINT32, BASE_HEX_DEC, NULL, 0,
10784            "Tunnel Endpoint Identifier", HFILL}
10785         },
10786         {&hf_gtp_teid_cp,
10787          { "TEID Control Plane", "gtp.teid_cp",
10788            FT_UINT32, BASE_HEX_DEC, NULL, 0,
10789            "Tunnel Endpoint Identifier Control Plane", HFILL}
10790         },
10791         {&hf_gtp_uplink_teid_cp,
10792          { "Uplink TEID Control Plane", "gtp.uplink_teid_cp",
10793            FT_UINT32, BASE_HEX_DEC, NULL, 0,
10794            "Uplink Tunnel Endpoint Identifier Control Plane", HFILL}
10795         },
10796         {&hf_gtp_teid_data,
10797          { "TEID Data I", "gtp.teid_data",
10798            FT_UINT32, BASE_HEX_DEC, NULL, 0,
10799            "Tunnel Endpoint Identifier Data I", HFILL}
10800         },
10801         {&hf_gtp_uplink_teid_data,
10802          { "Uplink TEID Data I", "gtp.uplink_teid_data",
10803            FT_UINT32, BASE_HEX_DEC, NULL, 0,
10804            "UplinkTunnel Endpoint Identifier Data I", HFILL}
10805         },
10806         {&hf_gtp_teid_ii,
10807          { "TEID Data II", "gtp.teid_ii",
10808            FT_UINT32, BASE_HEX_DEC, NULL, 0,
10809            "Tunnel Endpoint Identifier Data II", HFILL}
10810         },
10811         {&hf_gtp_tid,
10812          { "TID", "gtp.tid",
10813            FT_STRING, BASE_NONE, NULL, 0,
10814            "Tunnel Identifier", HFILL}
10815         },
10816         {&hf_gtp_tlli,
10817          { "TLLI", "gtp.tlli",
10818            FT_UINT32, BASE_HEX, NULL, 0,
10819            "Temporary Logical Link Identity", HFILL}
10820         },
10821         {&hf_gtp_tr_comm,
10822          { "Packet transfer command", "gtp.tr_comm",
10823            FT_UINT8, BASE_DEC, VALS(tr_comm_type), 0,
10824            NULL, HFILL}
10825         },
10826         {&hf_gtp_trace_ref,
10827          { "Trace reference", "gtp.trace_ref",
10828            FT_UINT16, BASE_HEX, NULL, 0,
10829            NULL, HFILL}
10830         },
10831         {&hf_gtp_trace_type,
10832          { "Trace type", "gtp.trace_type",
10833            FT_UINT16, BASE_HEX, NULL, 0,
10834            NULL, HFILL}
10835         },
10836         {&hf_gtp_user_addr_pdp_org,
10837          { "PDP type organization", "gtp.user_addr_pdp_org",
10838            FT_UINT8, BASE_DEC, VALS(pdp_org_type), 0,
10839            NULL, HFILL}
10840         },
10841         {&hf_gtp_user_addr_pdp_type,
10842          { "PDP type number", "gtp.user_addr_pdp_type",
10843            FT_UINT8, BASE_HEX, VALS(pdp_type), 0,
10844            NULL, HFILL}
10845         },
10846         {&hf_gtp_user_ipv4,
10847          { "End user address IPv4", "gtp.user_ipv4",
10848            FT_IPv4, BASE_NONE, NULL, 0,
10849            NULL, HFILL}
10850         },
10851         {&hf_gtp_user_ipv6,
10852          { "End user address IPv6", "gtp.user_ipv6",
10853            FT_IPv6, BASE_NONE, NULL, 0,
10854            NULL, HFILL}
10855         },
10856         {&hf_gtp_security_mode,
10857          { "Security Mode", "gtp.security_mode",
10858            FT_UINT8, BASE_DEC, VALS(mm_sec_modep), 0xc0,
10859            NULL, HFILL}
10860         },
10861         {&hf_gtp_no_of_vectors,
10862          { "No of Vectors", "gtp.no_of_vectors",
10863            FT_UINT8, BASE_DEC, NULL, 0x38,
10864            NULL, HFILL}
10865         },
10866         {&hf_gtp_cipher_algorithm,
10867          { "Cipher Algorithm", "gtp.cipher_algorithm",
10868            FT_UINT8, BASE_DEC, VALS(gtp_cipher_algorithm), 0x07,
10869            NULL, HFILL}
10870         },
10871         {&hf_gtp_cksn_ksi,
10872          { "Ciphering Key Sequence Number (CKSN)/Key Set Identifier (KSI)", "gtp.cksn_ksi",
10873            FT_UINT8, BASE_DEC, NULL, 0x07,
10874            "CKSN/KSI", HFILL}
10875         },
10876         {&hf_gtp_cksn,
10877          { "Ciphering Key Sequence Number (CKSN)", "gtp.cksn",
10878            FT_UINT8, BASE_DEC, NULL, 0x07,
10879            "CKSN", HFILL}
10880         },
10881         {&hf_gtp_ksi,
10882          { "Key Set Identifier (KSI)", "gtp.ksi",
10883            FT_UINT8, BASE_DEC, NULL, 0x07,
10884            "KSI", HFILL}
10885         },
10886         {&hf_gtp_ext_length,
10887          { "Length", "gtp.ext_length",
10888            FT_UINT16, BASE_DEC, NULL, 0x0,
10889            "IE Length", HFILL}
10890         },
10891         {&hf_gtp_utran_field,
10892          { "UTRAN Transparent Field", "gtp.utran_field",
10893            FT_BYTES, BASE_NONE, NULL, 0x0,
10894            NULL, HFILL}
10895         },
10896         {&hf_gtp_ext_apn_res,
10897          { "Restriction Type", "gtp.ext_apn_res",
10898            FT_UINT8, BASE_DEC, NULL, 0x0,
10899            NULL, HFILL}
10900         },
10901         {&hf_gtp_ext_rat_type,
10902          { "RAT Type", "gtp.ext_rat_type",
10903            FT_UINT8, BASE_DEC, VALS(gtp_ext_rat_type_vals), 0x0,
10904            NULL, HFILL}
10905         },
10906         {&hf_gtp_ext_imeisv,
10907          { "IMEI(SV)", "gtp.ext_imeisv",
10908            FT_STRING, BASE_NONE, NULL, 0x0,
10909            NULL, HFILL}
10910         },
10911         { &hf_gtp_target_rnc_id,
10912           { "targetRNC-ID", "gtp.targetRNC_ID",
10913             FT_UINT16, BASE_HEX, NULL, 0x0fff,
10914             NULL, HFILL }
10915         },
10916         { &hf_gtp_target_ext_rnc_id,
10917           { "Extended RNC-ID", "gtp.target_ext_RNC_ID",
10918             FT_UINT16, BASE_HEX, NULL, 0,
10919             NULL, HFILL }
10920         },
10921         {&hf_gtp_bssgp_cause,
10922          { "BSSGP Cause", "gtp.bssgp_cause",
10923            FT_UINT8, BASE_DEC|BASE_EXT_STRING, &bssgp_cause_vals_ext, 0,
10924            NULL, HFILL}
10925         },
10926         { &hf_gtp_bssgp_ra_discriminator,
10927           { "Routing Address Discriminator", "gtp.bssgp.rad",
10928             FT_UINT8, BASE_DEC, VALS(gtp_bssgp_ra_discriminator_vals), 0x0f,
10929             NULL, HFILL }
10930         },
10931         {&hf_gtp_sapi,
10932          { "PS Handover XID SAPI", "gtp.ps_handover_xid_sapi",
10933            FT_UINT8, BASE_DEC, NULL, 0x0F,
10934            "SAPI", HFILL}
10935         },
10936         {&hf_gtp_xid_par_len,
10937          { "PS Handover XID parameter length", "gtp.ps_handover_xid_par_len",
10938            FT_UINT8, BASE_DEC, NULL, 0xFF,
10939            "XID parameter length", HFILL}
10940         },
10941         {&hf_gtp_rep_act_type,
10942          { "Action", "gtp.ms_inf_chg_rep_act",
10943            FT_UINT8, BASE_DEC, VALS(chg_rep_act_type_vals), 0xFF,
10944            NULL, HFILL}
10945         },
10946         {&hf_gtp_correlation_id,
10947          { "Correlation-ID", "gtp.correlation_id",
10948            FT_UINT8, BASE_DEC, NULL, 0,
10949            NULL, HFILL}
10950         },
10951         {&hf_gtp_earp_pci,
10952          { "PCI Pre-emption Capability", "gtp.EARP_pre_emption_Capability",
10953            FT_BOOLEAN, 8, TFS(&tfs_disabled_enabled), 0x40,
10954            NULL, HFILL}
10955         },
10956         {&hf_gtp_earp_pl,
10957          { "PL Priority Level", "gtp.EARP_priority_level",
10958            FT_UINT8, BASE_DEC, NULL, 0x3C,
10959            NULL, HFILL}
10960         },
10961         {&hf_gtp_earp_pvi,
10962          { "PVI Pre-emption Vulnerability", "gtp.EARP_pre_emption_par_vulnerability",
10963            FT_BOOLEAN, 8, TFS(&tfs_disabled_enabled), 0x01,
10964            NULL, HFILL}
10965         },
10966         {&hf_gtp_ext_comm_flags_uasi,
10967          { "UASI", "gtp.ext_comm_flags_uasi",
10968            FT_BOOLEAN, 8, NULL, 0x80,
10969            NULL, HFILL}
10970         },
10971         {&hf_gtp_ext_comm_flags_II_pnsi,
10972          { "PNSI", "gtp.ext_comm_flags_II_pnsi",
10973            FT_UINT8, BASE_DEC, NULL, 0x01,
10974            NULL, HFILL}
10975         },
10976         {&hf_gtp_ext_comm_flags_II_dtci,
10977          { "DTCI", "gtp.ext_comm_flags_II_dtci",
10978            FT_BOOLEAN, 8, NULL, 0x02,
10979            NULL, HFILL}
10980         },
10981         {&hf_gtp_ext_comm_flags_II_pmtsmi,
10982          { "PMTSMI", "gtp.ext_comm_flags_II_pmtsmi",
10983            FT_UINT8, BASE_DEC, NULL, 0x04,
10984            NULL, HFILL}
10985         },
10986         {&hf_gtp_ext_comm_flags_II_spare,
10987          { "SPARE", "gtp.ext_comm_flags_II_spare",
10988            FT_UINT8, BASE_HEX, NULL, 0xF8,
10989            NULL, HFILL}
10990         },
10991         {&hf_gtp_cdr_app,
10992          { "Application Identifier", "gtp.cdr_app",
10993            FT_UINT8, BASE_DEC, NULL, 0xf0,
10994            NULL, HFILL}
10995         },
10996         { &hf_gtp_cdr_rel,
10997           { "Release Identifier", "gtp.cdr_rel",
10998             FT_UINT8, BASE_DEC, NULL, 0x0f,
10999             NULL, HFILL}
11000         },
11001         { &hf_gtp_cdr_ver,
11002           { "Version Identifier", "gtp.cdr_ver",
11003             FT_UINT8, BASE_DEC, NULL, 0x0,
11004             NULL, HFILL}
11005         },
11006         { &hf_gtp_cdr_length,
11007           { "Length", "gtp.cdr_length",
11008             FT_UINT16, BASE_DEC, NULL, 0x0,
11009             NULL, HFILL}
11010         },
11011         { &hf_gtp_cdr_context,
11012           { "Context", "gtp.cdr_context",
11013             FT_BYTES, BASE_NONE, NULL, 0x0,
11014             NULL, HFILL}
11015         },
11016         {&hf_gtp_cmn_flg_ppc,
11017          { "Prohibit Payload Compression", "gtp.cmn_flg.ppc",
11018            FT_BOOLEAN, 8, NULL, 0x01,
11019            NULL, HFILL}
11020         },
11021         {&hf_gtp_cmn_flg_mbs_srv_type,
11022          { "MBMS Service Type", "gtp.cmn_flg.mbs_srv_type",
11023            FT_BOOLEAN, 8, NULL, 0x02,
11024            NULL, HFILL}
11025         },
11026         {&hf_gtp_cmn_flg_mbs_ran_pcd_rdy,
11027          { "RAN Procedures Ready", "gtp.cmn_flg.mbs_ran_pcd_rdy",
11028            FT_BOOLEAN, 8, NULL, 0x04,
11029            NULL, HFILL}
11030         },
11031         {&hf_gtp_cmn_flg_mbs_cnt_inf,
11032          { "MBMS Counting Information", "gtp.cmn_flg.mbs_cnt_inf",
11033            FT_BOOLEAN, 8, NULL, 0x08,
11034            NULL, HFILL}
11035         },
11036         {&hf_gtp_cmn_flg_no_qos_neg,
11037          { "No QoS negotiation", "gtp.cmn_flg.no_qos_neg",
11038            FT_BOOLEAN, 8, NULL, 0x10,
11039            NULL, HFILL}
11040         },
11041         {&hf_gtp_cmn_flg_nrsn,
11042          { "NRSN bit field", "gtp.cmn_flg.nrsn",
11043            FT_BOOLEAN, 8, NULL, 0x20,
11044            NULL, HFILL}
11045         },
11046         {&hf_gtp_cmn_flg_upgrd_qos_sup,
11047          { "Upgrade QoS Supported", "gtp.cmn_flg.upgrd_qos_sup",
11048            FT_BOOLEAN, 8, NULL, 0x40,
11049            NULL, HFILL}
11050         },
11051         {&hf_gtp_cmn_flg_dual_addr_bearer_flg,
11052          { "Dual Address Bearer Flag", "gtp.cmn_flg.dual_addr_bearer_flg",
11053            FT_BOOLEAN, 8, NULL, 0x80,
11054            NULL, HFILL}
11055         },
11056         {&hf_gtp_tmgi,
11057          { "Temporary Mobile Group Identity (TMGI)", "gtp.tmgi",
11058            FT_BYTES, BASE_NONE, NULL, 0x0,
11059            NULL, HFILL}
11060         },
11061         {&hf_gtp_no_of_mbms_sa_codes,
11062          { "Number of MBMS service area codes", "gtp.no_of_mbms_sa_codes",
11063            FT_UINT8, BASE_DEC, NULL, 0x0,
11064            "Number N of MBMS service area codes", HFILL}
11065         },
11066 
11067         {&hf_gtp_mbms_ses_dur_days,
11068          { "Estimated session duration days", "gtp.mbms_ses_dur_days",
11069            FT_UINT24, BASE_DEC, NULL, 0x00007F,
11070            NULL, HFILL}
11071         },
11072         {&hf_gtp_mbms_ses_dur_s,
11073          { "Estimated session duration seconds", "gtp.mbms_ses_dur_s",
11074            FT_UINT24, BASE_DEC, NULL, 0xFFFF80,
11075            NULL, HFILL}
11076         },
11077         {&hf_gtp_mbms_sa_code,
11078          { "MBMS service area code", "gtp.mbms_sa_code",
11079            FT_UINT16, BASE_DEC, NULL, 0x0,
11080            NULL, HFILL}
11081         },
11082         {&hf_gtp_mbs_2g_3g_ind,
11083          { "MBMS 2G/3G Indicator", "gtp.mbs_2g_3g_ind",
11084            FT_UINT8, BASE_DEC, VALS(gtp_mbs_2g_3g_ind_vals), 0x0,
11085            NULL, HFILL}
11086         },
11087         {&hf_gtp_time_2_dta_tr,
11088          { "Time to MBMS Data Transfer", "gtp.time_2_dta_tr",
11089            FT_UINT8, BASE_DEC, NULL, 0x0,
11090            NULL, HFILL}
11091         },
11092         { &hf_gtp_ext_ei,
11093           { "Error Indication (EI)", "gtp.ei",
11094             FT_UINT8, BASE_DEC, NULL, 0x04,
11095             NULL, HFILL}
11096         },
11097         {&hf_gtp_ext_gcsi,
11098          { "GPRS-CSI (GCSI)", "gtp.gcsi",
11099            FT_UINT8, BASE_DEC, NULL, 0x02,
11100            NULL, HFILL}
11101         },
11102         { &hf_gtp_ext_dti,
11103           { "Direct Tunnel Indicator (DTI)", "gtp.dti",
11104             FT_UINT8, BASE_DEC, NULL, 0x01,
11105             NULL, HFILL}
11106         },
11107         { &hf_gtp_ra_prio_lcs,
11108           { "Radio Priority LCS", "gtp.raplcs",
11109             FT_UINT8, BASE_DEC, NULL, 0x07,
11110             NULL, HFILL}
11111         },
11112         { &hf_gtp_bcm,
11113           { "Bearer Control Mode", "gtp.bcm",
11114             FT_UINT8, BASE_DEC, VALS(gtp_pdp_bcm_type_vals), 0,
11115             NULL, HFILL}
11116         },
11117         { &hf_gtp_fqdn,
11118           { "FQDN", "gtp.fqdn",
11119             FT_STRING, BASE_NONE, NULL, 0,
11120             "Fully Qualified Domain Name", HFILL}
11121         },
11122         { &hf_gtp_rim_routing_addr,
11123           { "RIM Routing Address value", "gtp.rim_routing_addr_val",
11124             FT_BYTES, BASE_NONE, NULL, 0,
11125             NULL, HFILL}
11126         },
11127         { &hf_gtp_mbms_flow_id,
11128           { "MBMS Flow Identifier", "gtp.mbms_flow_id",
11129             FT_BYTES, BASE_NONE, NULL, 0,
11130             NULL, HFILL}
11131         },
11132         { &hf_gtp_mbms_dist_indic,
11133           { "Distribution Indication", "gtp.mbms_dist_indic",
11134             FT_UINT8, BASE_DEC, VALS(gtp_mbms_dist_indic_vals), 0x03,
11135             NULL, HFILL}
11136         },
11137         { &hf_gtp_ext_apn_ambr_ul,
11138           { "APN-AMBR for Uplink", "gtp.apn_ambr_ul",
11139             FT_INT32, BASE_DEC|BASE_UNIT_STRING, &units_kbps, 0x0,
11140             NULL, HFILL}
11141         },
11142         { &hf_gtp_ext_apn_ambr_dl,
11143           { "APN-AMBR for Downlink", "gtp.apn_ambr_dl",
11144             FT_INT32, BASE_DEC|BASE_UNIT_STRING, &units_kbps, 0x0,
11145             NULL, HFILL}
11146         },
11147         { &hf_gtp_ext_sub_ue_ambr_ul,
11148           { "Subscribed UE-AMBR for Uplink", "gtp.sub_ue_ambr_ul",
11149             FT_INT32, BASE_DEC|BASE_UNIT_STRING, &units_kbps, 0x0,
11150             NULL, HFILL}
11151         },
11152         { &hf_gtp_ext_sub_ue_ambr_dl,
11153           { "Subscribed UE-AMBR for Downlink", "gtp.sub_ue_ambr_dl",
11154             FT_INT32, BASE_DEC|BASE_UNIT_STRING, &units_kbps, 0x0,
11155             NULL, HFILL}
11156         },
11157         { &hf_gtp_ext_auth_ue_ambr_ul,
11158           { "Authorized UE-AMBR for Uplink", "gtp.auth_ue_ambr_ul",
11159             FT_INT32, BASE_DEC|BASE_UNIT_STRING, &units_kbps, 0x0,
11160             NULL, HFILL}
11161         },
11162         { &hf_gtp_ext_auth_ue_ambr_dl,
11163           { "Authorized UE-AMBR for Downlink", "gtp.auth_ue_ambr_dl",
11164             FT_INT32, BASE_DEC|BASE_UNIT_STRING, &units_kbps, 0x0,
11165             NULL, HFILL}
11166         },
11167         { &hf_gtp_ext_auth_apn_ambr_ul,
11168           { "Authorized APN-AMBR for Uplink", "gtp.auth_apn_ambr_ul",
11169             FT_INT32, BASE_DEC|BASE_UNIT_STRING, &units_kbps, 0x0,
11170             NULL, HFILL}
11171         },
11172         { &hf_gtp_ext_auth_apn_ambr_dl,
11173           { "Authorized APN-AMBR for Downlink", "gtp.auth_apn_ambr_dl",
11174             FT_INT32, BASE_DEC|BASE_UNIT_STRING, &units_kbps, 0x0,
11175             NULL, HFILL}
11176         },
11177         { &hf_gtp_ext_ggsn_back_off_time_units,
11178           { "Timer unit", "gtp.ggsn_back_off_time_units",
11179             FT_UINT8, BASE_DEC, VALS(gtp_ggsn_back_off_time_units_vals), 0xe0,
11180             NULL, HFILL}
11181         },
11182         { &hf_gtp_ext_ggsn_back_off_timer,
11183           { "Timer value", "gtp.ggsn_back_off_timer",
11184             FT_UINT8, BASE_DEC, NULL, 0x1f,
11185             NULL, HFILL}
11186         },
11187         { &hf_gtp_higher_br_16mb_flg,
11188           { "Higher bitrates than 16 Mbps flag", "gtp.higher_br_16mb_flg",
11189             FT_UINT8, BASE_DEC, VALS(gtp_higher_br_16mb_flg_vals), 0x0,
11190             NULL, HFILL}
11191         },
11192         { &hf_gtp_max_mbr_apn_ambr_ul,
11193           { "Max MBR/APN-AMBR for uplink", "gtp.max_mbr_apn_ambr_ul",
11194             FT_UINT32, BASE_DEC, NULL, 0x0,
11195             NULL, HFILL}
11196         },
11197         { &hf_gtp_max_mbr_apn_ambr_dl,
11198           { "Max MBR/APN-AMBR for downlink", "gtp.max_mbr_apn_ambr_dl",
11199             FT_UINT32, BASE_DEC, NULL, 0x0,
11200             NULL, HFILL}
11201         },
11202 
11203       { &hf_gtp_rand, { "RAND", "gtp.rand", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
11204       { &hf_gtp_sres, { "SRES", "gtp.sres", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
11205       { &hf_gtp_kc, { "Kc", "gtp.kc", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
11206       { &hf_gtp_xres_length, { "XRES length", "gtp.xres_length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
11207       { &hf_gtp_xres, { "XRES", "gtp.xres", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
11208       { &hf_gtp_quintuplet_ciphering_key, { "Quintuplet Ciphering Key", "gtp.quintuplet_ciphering_key", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
11209       { &hf_gtp_quintuplet_integrity_key, { "Quintuplet Integrity Key", "gtp.quintuplet_integrity_key", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
11210       { &hf_gtp_authentication_length, { "Authentication length", "gtp.authentication_length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
11211       { &hf_gtp_auth, { "AUTH", "gtp.auth", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
11212       { &hf_gtp_ciphering_key_ck, { "Ciphering key CK", "gtp.ciphering_key_ck", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
11213       { &hf_gtp_integrity_key_ik, { "Integrity key IK", "gtp.integrity_key_ik", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
11214       { &hf_gtp_quintuplets_length, { "Quintuplets length", "gtp.quintuplets_length", FT_UINT16, BASE_DEC_HEX, NULL, 0x0, NULL, HFILL }},
11215       { &hf_gtp_ciphering_key_kc, { "Ciphering key Kc", "gtp.ciphering_key_kc", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
11216       { &hf_gtp_container_length, { "Container length", "gtp.container_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
11217       { &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 }},
11218       { &hf_gtp_vplmn_address_allowed, { "VPLMN address allowed", "gtp.vplmn_address_allowed", FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x40, NULL, HFILL }},
11219       { &hf_gtp_activity_status_indicator, { "Activity Status Indicator", "gtp.activity_status_indicator", FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x20, NULL, HFILL }},
11220       { &hf_gtp_reordering_required, { "Reordering required", "gtp.reordering_required", FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x10, NULL, HFILL }},
11221       { &hf_gtp_pdp_cntxt_sapi, { "SAPI", "gtp.pdp_cntxt.sapi", FT_UINT8, BASE_DEC, NULL, 0x0F, NULL, HFILL }},
11222       { &hf_gtp_sequence_number_down, { "Sequence number down", "gtp.sequence_number_down", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
11223       { &hf_gtp_sequence_number_up, { "Sequence number up", "gtp.sequence_number_up", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
11224       { &hf_gtp_send_n_pdu_number, { "Send N-PDU number", "gtp.send_n_pdu_number", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
11225       { &hf_gtp_receive_n_pdu_number, { "Receive N-PDU number", "gtp.receive_n_pdu_number", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
11226       { &hf_gtp_uplink_flow_label_signalling, { "Uplink flow label signalling", "gtp.uplink_flow_label_signalling", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
11227       { &hf_gtp_pdp_context_identifier, { "PDP context identifier", "gtp.pdp_context_identifier", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
11228       { &hf_gtp_pdp_organization, { "PDP organization", "gtp.pdp_organization", FT_UINT8, BASE_DEC, VALS(pdp_type), 0x0F, NULL, HFILL }},
11229       { &hf_gtp_pdp_type, { "PDP type", "gtp.pdp_type", FT_UINT8, BASE_DEC, VALS(pdp_type), 0x0, NULL, HFILL }},
11230       { &hf_gtp_pdp_address_length, { "PDP address length", "gtp.pdp_address_length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
11231       { &hf_gtp_pdp_address_ipv4, { "PDP address", "gtp.pdp_address.ipv4", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
11232       { &hf_gtp_pdp_address_ipv6, { "PDP address", "gtp.pdp_address.ipv6", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
11233       { &hf_gtp_sgsn_address_for_control_plane_ipv4, { "SGSN Address for control plane", "gtp.sgsn_address_for_control_plane.ipv4", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
11234       { &hf_gtp_sgsn_address_for_control_plane_ipv6, { "SGSN Address for control plane", "gtp.sgsn_address_for_control_plane.ipv6", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
11235       { &hf_gtp_sgsn_address_for_user_traffic_ipv4, { "SGSN Address for User Traffic", "gtp.sgsn_address_for_user_traffic.ipv4", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
11236       { &hf_gtp_sgsn_address_for_user_traffic_ipv6, { "SGSN Address for User Traffic", "gtp.sgsn_address_for_user_traffic.ipv6", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
11237       { &hf_gtp_ggsn_address_length, { "GGSN address length", "gtp.ggsn_address_length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
11238       { &hf_gtp_ggsn_address_for_control_plane_ipv4, { "GGSN Address for control plane", "gtp.ggsn_address_for_control_plane.ipv4", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
11239       { &hf_gtp_ggsn_address_for_control_plane_ipv6, { "GGSN Address for control plane", "gtp.ggsn_address_for_control_plane.ipv6", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
11240       { &hf_gtp_ggsn_address_for_user_traffic_ipv4, { "GGSN Address for User Traffic", "gtp.ggsn_address_for_user_traffic.ipv4", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
11241       { &hf_gtp_ggsn_address_for_user_traffic_ipv6, { "GGSN Address for User Traffic", "gtp.ggsn_address_for_user_traffic.ipv6", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
11242       { &hf_gtp_apn_length, { "APN length", "gtp.apn_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
11243       { &hf_gtp_transaction_identifier, { "Transaction identifier", "gtp.transaction_identifier", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
11244       { &hf_gtp_gsn_address_length, { "GSN address length", "gtp.gsn_address_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
11245       { &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 }},
11246       { &hf_gtp_tft_length, { "TFT length", "gtp.tft_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
11247       { &hf_gtp_rab_setup_length, { "RAB setup length", "gtp.rab_setup_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
11248       { &hf_gtp_timezone, { "Timezone", "gtp.timezone", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
11249       { &hf_gtp_timezone_dst, { "DST", "gtp.timezone_dst", FT_UINT8, BASE_DEC, VALS(daylight_saving_time_vals), 0x03, NULL, HFILL }},
11250       { &hf_gtp_rfsp_index, { "RFSP Index", "gtp.rfsp_index", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
11251       { &hf_gtp_fqdn_length, { "FQDN length", "gtp.fqdn_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
11252       { &hf_gtp_number_of_data_records, { "Number of data records", "gtp.number_of_data_records", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
11253       { &hf_gtp_data_record_format, { "Data record format", "gtp.data_record_format", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
11254       { &hf_gtp_node_address_length, { "Node address length", "gtp.node_address_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
11255       { &hf_gtp_seq_num_released, { "Sequence number released", "gtp.seq_num_released", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
11256       { &hf_gtp_seq_num_canceled, { "Sequence number cancelled", "gtp.seq_num_canceled", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
11257       { &hf_gtp_requests_responded, { "Requests responded", "gtp.requests_responded", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
11258       { &hf_gtp_hyphen_separator, { "Hyphen separator: -", "gtp.hyphen_separator", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
11259       { &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 }},
11260       { &hf_gtp_iei, { "IEI", "gtp.iei", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
11261       { &hf_gtp_iei_mobile_id_len, { "Length", "gtp.iei.mobile_id_len", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
11262       { &hf_gtp_qos_umts_length, { "Length", "gtp.qos_umts_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
11263       { &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 }},
11264       { &hf_gtp_ext_hdr_type, { "Extension Header Type", "gtp.ext_hdr_type", FT_UINT8, BASE_DEC, VALS(next_extension_header_fieldvals), 0x0, NULL, HFILL }},
11265       { &hf_gtp_tpdu_data, { "T-PDU Data", "gtp.tpdu_data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
11266       { &hf_gtp_ext_enb_type, { "enb_type", "gtp.enb_type", FT_UINT8, BASE_DEC, VALS(gtp_enb_type_vals), 0x0, NULL, HFILL } },
11267       { &hf_gtp_macro_enodeb_id,
11268       { "Macro eNodeB ID", "gtp.macro_enodeb_id",
11269       FT_UINT24, BASE_HEX, NULL, 0x0fffff,
11270       NULL, HFILL }
11271       },
11272       { &hf_gtp_home_enodeb_id,
11273       { "Home eNodeB ID", "gtp.home_enodeb_id",
11274       FT_UINT32, BASE_HEX, NULL, 0x0fffffff,
11275       NULL, HFILL }
11276       },
11277       { &hf_gtp_dummy_octets,
11278       { "Dummy octets", "gtp.dummy_octets",
11279             FT_BYTES, BASE_NONE, NULL, 0x0,
11280             NULL, HFILL }
11281       },
11282       { &hf_gtp_spare_b4b0,
11283       { "Spare", "gtp.spare.b4b0",
11284       FT_UINT8, BASE_HEX, NULL, 0x1f,
11285       NULL, HFILL }
11286       },
11287       { &hf_gtp_spare_b7b6,
11288       { "Spare", "gtp.spare.b7b6",
11289       FT_UINT8, BASE_HEX, NULL, 0xc0,
11290       NULL, HFILL }
11291       },
11292       { &hf_gtp_spare_h1,
11293       { "Spare", "gtp.spare.h1",
11294       FT_UINT8, BASE_HEX, NULL, 0xf,
11295       NULL, HFILL }
11296       },
11297       { &hf_gtp_rnc_ip_addr_v4,
11298       { "RNC IP address", "gtp.rnc_ip_addr_v4",
11299       FT_IPv4, BASE_NONE, NULL, 0x0,
11300       NULL, HFILL }
11301       },
11302       { &hf_gtp_rnc_ip_addr_v6,
11303       { "RNC IP address", "gtp.rnc_ip_addr_v6",
11304       FT_IPv6, BASE_NONE, NULL, 0x0,
11305       NULL, HFILL }
11306       },
11307       { &hf_gtp_ms_cm_2_len,
11308       { "Length of the Mobile Station Classmark 2", "gtp.ms_cm_2_len",
11309       FT_UINT8, BASE_DEC, NULL, 0x0,
11310       NULL, HFILL }
11311       },
11312       { &hf_gtp_ms_cm_3_len,
11313       { "Length of the Mobile Station Classmark 3", "gtp.ms_cm_3_len",
11314       FT_UINT8, BASE_DEC, NULL, 0x0,
11315       NULL, HFILL }
11316       },
11317       { &hf_gtp_sup_codec_lst_len,
11318       { "Length of the Supported Codec List", "gtp.sup_codec_lst_len",
11319       FT_UINT8, BASE_DEC, NULL, 0x0,
11320       NULL, HFILL }
11321       },
11322       { &hf_gtp_add_flg_for_srvcc_ics,
11323       { "ICS (IMS Centralized Service)", "gtp.add_flg_for_srvcc_ics",
11324       FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x01,
11325       NULL, HFILL }
11326       },
11327       { &hf_gtp_sel_mode_val,
11328       { "Selection Mode Value", "gtp.sel_mode_val",
11329       FT_UINT8, BASE_DEC, VALS(gtp_sel_mode_vals), 0x03,
11330       NULL, HFILL }
11331       },
11332 };
11333 
11334 
11335    static hf_register_info hf_nrup[] =
11336    {
11337       {&hf_nrup_pdu_type,
11338         { "PDU Type", "nrup.pdu_type",
11339           FT_UINT8, BASE_DEC, VALS(nr_pdu_type_cnst), 0xf0,
11340           NULL, HFILL}
11341       },
11342       {&hf_nrup_spr_bit_extnd_flag,
11343         { "Spare", "nrup.spr_bit",
11344           FT_BOOLEAN, 8, NULL, 0x08,
11345           NULL, HFILL}
11346       },
11347       {&hf_nrup_dl_discrd_blks,
11348         { "DL Discard Blocks", "nrup.dl_disc_blks",
11349           FT_BOOLEAN, 8, TFS(&tfs_present_not_present), 0x04,
11350           "Presence of DL discard Number of blocks, discard NR PDCP PDU SN start and Discarded Block size", HFILL}
11351       },
11352       {&hf_nrup_dl_flush,
11353        { "DL Flush", "nrup.dl_flush",
11354          FT_BOOLEAN, 8, TFS(&tfs_present_not_present), 0x02,
11355          "Presence of DL discard NR PDCP PDU SN", HFILL}
11356       },
11357       {&hf_nrup_rpt_poll,
11358         { "Report Polling", "nrup.report_polling",
11359           FT_BOOLEAN, 8, TFS(&tfs_requested_not_requested), 0x01,
11360           "Indicates that the node hosting the NR PDCP entity requests providing the downlink delivery status report", HFILL}
11361       },
11362       {&hf_nrup_retransmission_flag,
11363         { "Retransmission Flag", "nrup.retransmission_flag",
11364            FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x01,
11365            "Indicates whether the NR PDCP PDU is a retransmission NR-U packet sent by the node hosting the NR PDCP entity to the corresponding node", HFILL}
11366       },
11367       { &hf_nrup_ass_inf_rep_poll_flag,
11368         { "Assistance Info. Report Polling Flag", "nrup.ass_inf_rep_poll_flag",
11369            FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x02,
11370            NULL, HFILL }
11371       },
11372       { &hf_nrup_spare,
11373         { "Spare", "nrup.spare",
11374            FT_UINT8, BASE_DEC, NULL, 0xe0,
11375            NULL, HFILL }
11376       },
11377       { &hf_nrup_request_out_of_seq_report,
11378         { "Request Out Of Seq Report", "nrup.request_out_of_seq_report",
11379            FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x10,
11380            NULL, HFILL}
11381       },
11382 
11383       {&hf_nrup_report_delivered,
11384          { "Report Delivered", "nrup.report_delivered",
11385            FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x08,
11386            "Presence of DL report NR PDCP PDU SN", HFILL}
11387       },
11388       {&hf_nrup_user_data_existence_flag,
11389          { "User Data Existence Flag", "nrup.user_data_existence_flag",
11390            FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x04,
11391            "Whether the node hosting the NR PDCP entity has some user data for the concerned data radio bearer", HFILL}
11392       },
11393       {&hf_nrup_nr_u_seq_num,
11394          { "NR-U Sequence Number", "nrup.seq_num",
11395            FT_UINT24, BASE_DEC, NULL, 0,
11396            "NR-U sequence number as assigned by the node hosting the NR PDCP entity", HFILL}
11397       },
11398       {&hf_nrup_dl_disc_nr_pdcp_pdu_sn,
11399          { "DL discard NR PDCP PDU SN", "nrup.dl_disc_nr_pdcp_pdu_sn",
11400            FT_UINT24, BASE_DEC, NULL, 0,
11401            NULL, HFILL}
11402       },
11403       {&hf_nrup_dl_disc_num_blks,
11404          { "DL discard Number of blocks", "nrup.dl_disc_num_blks",
11405            FT_UINT8, BASE_DEC, NULL, 0xff,
11406            NULL, HFILL}
11407       },
11408       {&hf_nrup_dl_disc_nr_pdcp_pdu_sn_start,
11409          { "DL discard NR PDCP PDU SN Start", "nrup.dl_disc_nr_pdcp_pdu_sn_start",
11410            FT_UINT24, BASE_DEC, NULL, 0,
11411            NULL, HFILL}
11412       },
11413       {&hf_nrup_dl_disc_blk_sz,
11414          { "Discarded block size", "nrup.disc_blk_sz",
11415            FT_UINT8, BASE_DEC, NULL, 0,
11416            "The number of NR PDCP PDUs counted from the starting SN to be discarded", HFILL}
11417       },
11418        {&hf_nrup_dl_report_nr_pdcp_pdu_sn,
11419           { "DL report NR PDCP PDU SN", "nrup.dl_report_nr_pdcp_pdu_sn",
11420             FT_UINT24, BASE_DEC, NULL, 0,
11421             "DL delivery status report wanted when this SN has been delivered", HFILL}
11422        },
11423 
11424       {&hf_nrup_high_tx_nr_pdcp_sn_ind,
11425          { "Highest Transmitted NR PDCP SN Ind", "nrup.high_tx_nr_pdcp_sn_ind",
11426            FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x08,
11427            NULL, HFILL}
11428       },
11429       {&hf_nrup_high_delivered_nr_pdcp_sn_ind,
11430          { "Highest Delivered NR PDCP SN Ind", "nrup.high_delivered_nr_pdcp_sn_ind",
11431            FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x04,
11432            NULL, HFILL}
11433       },
11434       {&hf_nrup_final_frame_ind,
11435          { "Final Frame Indication", "nrup.final_frame_ind",
11436            FT_BOOLEAN, 8, TFS(&tfs_final_frame_indication), 0x02,
11437            "Whether the frame is the last DL status report", HFILL}
11438       },
11439       {&hf_nrup_lost_pkt_rpt,
11440          { "Lost Packet Report", "nrup.lost_pkt_rpt",
11441            FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x01,
11442            "Indicates the presence of Number of lost NR-U Sequence Number ranges reported" , HFILL}
11443       },
11444       {&hf_nrup_high_retx_nr_pdcp_sn_ind,
11445          { "Highest Retransmitted NR PDCP SN Ind", "nrup.high_retx_nr_pdcp_sn_ind",
11446            FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x04,
11447            NULL, HFILL}
11448       },
11449       {&hf_nrup_cause_rpt,
11450          { "Cause Report", "nrup.cause_rpt",
11451            FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x01,
11452            "Presence of Cause Value", HFILL}
11453       },
11454       {&hf_nrup_delivered_nr_pdcp_sn_range_ind,
11455          { "Delivered NR PDCP SN Range Ind", "nrup.delivered_nr_pdcp_sn_range_ind",
11456            FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x10,
11457            NULL, HFILL}
11458       },
11459       {&hf_nrup_data_rate_ind,
11460          { "Data Rate Ind", "nrup.data_rate_ind",
11461            FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x08,
11462            NULL, HFILL}
11463       },
11464       {&hf_nrup_desrd_buff_sz_data_radio_bearer,
11465          { "Desired buffer size for the data radio bearer", "nrup.desrd_buff_sz_data_radio_bearer",
11466            FT_UINT32, BASE_DEC, NULL, 0,
11467            NULL, HFILL}
11468       },
11469       {&hf_nrup_high_delivered_retx_nr_pdcp_sn_ind,
11470          { "Highest Delivered Retransmitted NR PDCP SN Ind", "nrup.high_delivered_retx_nr_pdcp_sn_ind",
11471            FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x02,
11472            NULL, HFILL}
11473       },
11474       {&hf_nrup_desrd_data_rate,
11475          { "Desired data rate", "nrup.desrd_data_rate",
11476            FT_UINT32, BASE_DEC, NULL, 0,
11477            NULL, HFILL}
11478       },
11479       {&hf_nrup_num_lost_nru_seq_num,
11480          { "Number of lost NR-U Sequence Number ranges reported", "nrup.num_lost_nru_seq_num",
11481            FT_UINT8, BASE_DEC, NULL, 0,
11482            NULL, HFILL}
11483       },
11484       {&hf_nrup_start_lost_nru_seq_num,
11485          { "Start of lost NR-U Sequence Number range", "nrup.start_num_lost_nru_seq_num",
11486            FT_UINT24, BASE_DEC, NULL, 0,
11487            NULL, HFILL}
11488       },
11489       {&hf_nrup_end_lost_nru_seq_num,
11490          { "End of lost NR-U Sequence Number range", "nrup.end_num_lost_nru_seq_num",
11491            FT_UINT24, BASE_DEC, NULL, 0,
11492            NULL, HFILL}
11493       },
11494       {&hf_nrup_high_success_delivered_nr_pdcp_sn,
11495          { "Highest Successfully Delivered NR PDCP SN", "nrup.high_success_delivered_nr_pdcp_sn",
11496            FT_UINT24, BASE_DEC, NULL, 0,
11497            NULL, HFILL}
11498       },
11499       {&hf_nrup_high_tx_nr_pdcp_sn,
11500          { "Highest transmitted NR PDCP SN", "nrup.high_tx_nr_pdcp_sn",
11501            FT_UINT24, BASE_DEC, NULL, 0,
11502            NULL, HFILL}
11503       },
11504       {&hf_nrup_cause_val ,
11505          { "Cause Value", "nrup.cause_val",
11506            FT_UINT8, BASE_DEC|BASE_RANGE_STRING, RVALS(nr_up_cause_vals), 0,
11507            "Indicates specific events reported by the corresponding node", HFILL}
11508       },
11509       {&hf_nrup_high_success_delivered_retx_nr_pdcp_sn,
11510          { "Highest Successfully Delivered Retransmitted NR PDCP SN", "nrup.high_success_delivered_retx_nr_pdcp_sn",
11511            FT_UINT24, BASE_DEC, NULL, 0,
11512            NULL, HFILL}
11513       },
11514       {&hf_nrup_high_retx_nr_pdcp_sn,
11515          { "Highest Retransmitted NR PDCP SN Ind", "nrup.high_retx_nr_pdcp_sn",
11516            FT_UINT24, BASE_DEC, NULL, 0,
11517            NULL, HFILL}
11518       },
11519 
11520       {&hf_nrup_pdcp_duplication_ind,
11521          { "PDCP Duplication Indication", "nrup.pdcp_duplication_ind",
11522            FT_BOOLEAN, 8, TFS(&tfs_present_not_present), 0x08,
11523            NULL, HFILL}
11524       },
11525       {&hf_nrup_assistance_information_ind,
11526          { "Assistance Information Indication", "nrup.assistance_information_ind",
11527            FT_BOOLEAN, 8, TFS(&tfs_present_not_present), 0x04,
11528            NULL, HFILL}
11529       },
11530       {&hf_nrup_ul_delay_ind,
11531          { "UL Delay Indicator", "nrup.ul_delay_ind",
11532            FT_BOOLEAN, 8, TFS(&tfs_present_not_present), 0x02,
11533            NULL, HFILL}
11534       },
11535       {&hf_nrup_dl_delay_ind,
11536          { "DL Delay Indicator", "nrup.dl_delay_ind",
11537            FT_BOOLEAN, 8, TFS(&tfs_present_not_present), 0x01,
11538            NULL, HFILL}
11539       },
11540       {&hf_nrup_spare_2,
11541          { "Spare", "nrup.spare",
11542            FT_UINT8, BASE_HEX, NULL, 0xfe,
11543            NULL, HFILL}
11544       },
11545       {&hf_nrup_pdcp_duplication_activation_suggestion,
11546          { "PDCP Duplication Activation Suggestion", "nrup.pdcp_duplication_activation_suggestion",
11547            FT_BOOLEAN, 8, TFS(&tfs_present_not_present), 0x01,
11548            NULL, HFILL}
11549       },
11550       {&hf_nrup_num_assistance_info_fields,
11551          { "Number of Assistance Information Fields", "nrup.num_assistance_info_fields",
11552            FT_UINT8, BASE_DEC, NULL, 0x0,
11553            NULL, HFILL}
11554       },
11555       {&hf_nrup_assistance_information_type,
11556          { "Assistance Information Type", "nrup.assistance_info_type",
11557            FT_UINT8, BASE_DEC|BASE_RANGE_STRING, RVALS(assistance_info_type), 0x0,
11558            NULL, HFILL}
11559       },
11560       {&hf_nrup_num_octets_radio_qa_info,
11561          { "Number of octets for Radio Quality Assistance Information Fields", "nrup.num_octets_radio_qa_info",
11562            FT_UINT8, BASE_DEC, NULL, 0x0,
11563            NULL, HFILL}
11564       },
11565       {&hf_nrup_radio_qa_info,
11566          { "Radio Quality Assistance Information", "nrup.radio_qa_info",
11567            FT_BYTES, BASE_NONE, NULL, 0x0,
11568            NULL, HFILL}
11569       },
11570       {&hf_nrup_ul_delay_du_result,
11571          { "UL Delay DU Result", "nrup.ul_delay_du_result",
11572            FT_UINT32, BASE_DEC, NULL, 0x0,
11573            NULL, HFILL}
11574       },
11575       {&hf_nrup_dl_delay_du_result,
11576          { "DL Delay DU Result", "nrup.dl_delay_du_result",
11577            FT_UINT32, BASE_DEC, NULL, 0x0,
11578            NULL, HFILL}
11579       }
11580     };
11581 
11582 
11583     static ei_register_info ei[] = {
11584         { &ei_gtp_ext_length_mal, { "gtp.ext_length.invalid", PI_MALFORMED, PI_ERROR, "Malformed length", EXPFILL }},
11585         { &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 }},
11586         { &ei_gtp_ext_length_warn, { "gtp.ext_length.invalid", PI_PROTOCOL, PI_WARN, "Length warning", EXPFILL }},
11587         { &ei_gtp_undecoded, { "gtp.undecoded", PI_UNDECODED, PI_WARN, "Data not decoded yet", EXPFILL }},
11588         { &ei_gtp_message_not_found, { "gtp.message_not_found", PI_PROTOCOL, PI_WARN, "Message not found", EXPFILL }},
11589         { &ei_gtp_field_not_present, { "gtp.field_not_present", PI_PROTOCOL, PI_WARN, "Field not present", EXPFILL }},
11590         { &ei_gtp_wrong_next_field, { "gtp.wrong_next_field", PI_PROTOCOL, PI_WARN, "Wrong next field", EXPFILL }},
11591         { &ei_gtp_field_not_support_in_version, { "gtp.field_not_support_in_version", PI_PROTOCOL, PI_WARN, "GTP version not supported for field", EXPFILL }},
11592         { &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 }},
11593         { &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 }},
11594         { &ei_gtp_ext_geo_loc_type, { "gtp.ext_geo_loc_type.unknown", PI_PROTOCOL, PI_WARN, "Unknown Location type data", EXPFILL }},
11595         { &ei_gtp_iei, { "gtp.iei.unknown", PI_PROTOCOL, PI_WARN, "Unknown IEI - Later spec than TS 29.060 9.4.0 used?", EXPFILL }},
11596         { &ei_gtp_unknown_extension_header, { "gtp.unknown_extension_header", PI_PROTOCOL, PI_WARN, "Unknown extension header", EXPFILL }},
11597         { &ei_gtp_unknown_pdu_type, { "gtp.unknown_pdu_type", PI_PROTOCOL, PI_WARN, "Unknown PDU type", EXPFILL }},
11598     };
11599 
11600     /* Setup protocol subtree array */
11601 #define GTP_NUM_INDIVIDUAL_ELEMS    31
11602     static gint *ett_gtp_array[GTP_NUM_INDIVIDUAL_ELEMS + NUM_GTP_IES];
11603 
11604     ett_gtp_array[0] = &ett_gtp;
11605     ett_gtp_array[1] = &ett_gtp_flags;
11606     ett_gtp_array[2] = &ett_gtp_ext;
11607     ett_gtp_array[3] = &ett_gtp_cdr_dr;
11608     ett_gtp_array[4] = &ett_gtp_qos;
11609     ett_gtp_array[5] = &ett_gtp_qos_arp;
11610     ett_gtp_array[6] = &ett_gtp_flow_ii;
11611     ett_gtp_array[7] = &ett_gtp_ext_hdr;
11612     ett_gtp_array[8] = &ett_gtp_rp;
11613     ett_gtp_array[9] = &ett_gtp_pkt_flow_id;
11614     ett_gtp_array[10] = &ett_gtp_data_resp;
11615     ett_gtp_array[11] = &ett_gtp_cdr_ver;
11616     ett_gtp_array[12] = &ett_gtp_tmgi;
11617     ett_gtp_array[13] = &ett_gtp_trip;
11618     ett_gtp_array[14] = &ett_gtp_quint;
11619     ett_gtp_array[15] = &ett_gtp_drx;
11620     ett_gtp_array[16] = &ett_gtp_net_cap;
11621     ett_gtp_array[17] = &ett_gtp_can_pack;
11622     ett_gtp_array[18] = &ett_gtp_proto;
11623     ett_gtp_array[19] = &ett_gtp_gsn_addr;
11624     ett_gtp_array[20] = &ett_gtp_tft;
11625     ett_gtp_array[21] = &ett_gtp_rab_setup;
11626     ett_gtp_array[22] = &ett_gtp_hdr_list;
11627     ett_gtp_array[23] = &ett_gtp_rel_pack;
11628     ett_gtp_array[24] = &ett_gtp_node_addr;
11629     ett_gtp_array[25] = &ett_gtp_mm_cntxt;
11630     ett_gtp_array[26] = &ett_gtp_utran_cont;
11631     ett_gtp_array[27] = &ett_gtp_nr_ran_cont;
11632     ett_gtp_array[28] = &ett_gtp_pdcp_no_conf;
11633     ett_gtp_array[29] = &ett_pdu_session_cont;
11634     ett_gtp_array[30] = &ett_nrup;
11635 
11636     last_offset = GTP_NUM_INDIVIDUAL_ELEMS;
11637 
11638     for (i=0; i < NUM_GTP_IES; i++, last_offset++)
11639     {
11640         ett_gtp_ies[i] = -1;
11641         ett_gtp_array[last_offset] = &ett_gtp_ies[i];
11642     }
11643 
11644 
11645     proto_gtp = proto_register_protocol("GPRS Tunneling Protocol", "GTP", "gtp");
11646     proto_gtpprime = proto_register_protocol("GPRS Tunneling Protocol Prime", "GTP (Prime)", "gtpprime");
11647 
11648     proto_register_field_array(proto_gtp, hf_gtp, array_length(hf_gtp));
11649     proto_register_subtree_array(ett_gtp_array, array_length(ett_gtp_array));
11650     expert_gtp = expert_register_protocol(proto_gtp);
11651     expert_register_field_array(expert_gtp, ei, array_length(ei));
11652 
11653     proto_nrup = proto_register_protocol("NRUP", "NRUP", "nrup");
11654     proto_register_field_array(proto_nrup, hf_nrup, array_length(hf_nrup));
11655 
11656 
11657     gtp_module = prefs_register_protocol(proto_gtp, proto_reg_handoff_gtp);
11658     /* For reading older preference files with "gtpv0." or "gtpv1." preferences */
11659     prefs_register_module_alias("gtpv0", gtp_module);
11660     prefs_register_module_alias("gtpv1", gtp_module);
11661 
11662     prefs_register_uint_preference(gtp_module, "v0_port", "GTPv0 and GTP' port", "GTPv0 and GTP' port (default 3386)", 10, &g_gtpv0_port);
11663     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,
11664                                    &g_gtpv1c_port);
11665     prefs_register_uint_preference(gtp_module, "v1u_port", "GTPv1 user plane (GTP-U) port", "GTPv1 user plane port (default 2152)", 10,
11666                                    &g_gtpv1u_port);
11667     prefs_register_enum_preference(gtp_module, "dissect_tpdu_as",
11668                                                "Dissect T-PDU as",
11669                                                "Dissect T-PDU as",
11670                                                &dissect_tpdu_as,
11671                                                gtp_decode_tpdu_as,
11672                                                FALSE);
11673     prefs_register_uint_preference(gtp_module, "pair_max_interval", "Max interval allowed in pair matching", "Request/reply pair matches only if their timestamps are closer than that value, in ms (default 0, i.e. don't use timestamps)", 10, &pref_pair_matching_max_interval_ms);
11674 
11675     prefs_register_obsolete_preference(gtp_module, "v0_dissect_cdr_as");
11676     prefs_register_obsolete_preference(gtp_module, "v0_check_etsi");
11677     prefs_register_obsolete_preference(gtp_module, "v1_check_etsi");
11678     prefs_register_bool_preference(gtp_module, "check_etsi", "Compare GTP order with ETSI", "GTP ETSI order", &g_gtp_etsi_order);
11679     prefs_register_obsolete_preference(gtp_module, "ppp_reorder");
11680     prefs_register_obsolete_preference(gtp_module, "dissect_tpdu");
11681 
11682     /* This preference can be used to disable the dissection of GTP over TCP. Most of the Wireless operators uses GTP over UDP.
11683      * The preference is set to TRUE by default forbackward compatibility
11684      */
11685     prefs_register_bool_preference(gtp_module, "dissect_gtp_over_tcp", "Dissect GTP over TCP", "Dissect GTP over TCP", &g_gtp_over_tcp);
11686     prefs_register_bool_preference(gtp_module, "track_gtp_session", "Track GTP session", "Track GTP session", &g_gtp_session);
11687 
11688     /* --- PDCP DECODE ADDITIONS --- */
11689 
11690     static uat_field_t pdcp_lte_keys_uat_flds[] = {
11691         UAT_FLD_CSTRING_OTHER(pdcp_lte_users, ip_addr_str, "Dst IP address", pdcp_uat_fld_ip_chk_cb, "IPv4 or IPv6 address"),
11692         UAT_FLD_CSTRING_OTHER(pdcp_lte_users, teid_str, "TEID value  or \"" PDCP_TEID_WILDCARD "\"", pdcp_uat_fld_teid_chk_cb, "Tunnel Endpoint Identifier"),
11693         UAT_FLD_VS(pdcp_lte_users, header_present, "Header present", vs_header_present, "Header present flag"),
11694         UAT_FLD_VS(pdcp_lte_users, plane, "Plane", vs_pdcp_plane, "Signaling or user plane"),
11695         UAT_FLD_VS(pdcp_lte_users, lte_sn_length, "PDCP SN length", vs_pdcp_lte_sn_length, "Length of PDCP sequence number"),
11696         UAT_FLD_VS(pdcp_lte_users, rohc_compression, "ROHC compression", vs_rohc_compression, "Header compression"),
11697         //UAT_FLD_VS(pdcp_lte_users, rohc_mode, "ROHC mode", vs_rohc_mode, "ROHC mode"),
11698         UAT_FLD_VS(pdcp_lte_users, rohc_profile, "ROHC profile", vs_rohc_profile, "ROHC profile"),
11699         UAT_END_FIELDS
11700     };
11701 
11702     pdcp_lte_keys_uat = uat_new("PDCP-LTE Keys",
11703         sizeof(uat_pdcp_lte_keys_record_t), /* record size */
11704         "gtp_pdcp_lte_keys2",                /* filename */
11705         TRUE,                               /* from_profile */
11706         &uat_pdcp_lte_keys_records,         /* data_ptr */
11707         &num_pdcp_lte_keys_uat,             /* numitems_ptr */
11708         UAT_AFFECTS_DISSECTION,             /* affects dissection of packets, but not set of named fields */
11709         NULL,                               /* help */
11710         pdcp_lte_copy_cb,                   /* copy callback */
11711         pdcp_lte_update_cb,                 /* update callback */
11712         pdcp_lte_free_cb,                   /* free callback */
11713         NULL,                               /* post update callback */
11714         NULL,                               /* reset callback */
11715         pdcp_lte_keys_uat_flds);            /* UAT field definitions */
11716 
11717     prefs_register_uat_preference(gtp_module,
11718         "pdcp_lte_table",
11719         "GTP PDCP-LTE Keys",
11720         "Preconfigured PDCP-LTE Keys",
11721         pdcp_lte_keys_uat);
11722 
11723     static uat_field_t pdcp_nr_keys_uat_flds[] = {
11724         UAT_FLD_CSTRING_OTHER(pdcp_nr_users, ip_addr_str, "Dst IP address", pdcp_uat_fld_ip_chk_cb, "IPv4 or IPv6 address"),
11725         UAT_FLD_CSTRING_OTHER(pdcp_nr_users, teid_str, "TEID value or \"" PDCP_TEID_WILDCARD "\"", pdcp_uat_fld_teid_chk_cb, "Tunnel Endpoint Identifier"),
11726         UAT_FLD_VS(pdcp_nr_users, direction, "Direction", vs_direction, "Direction"),
11727         UAT_FLD_VS(pdcp_nr_users, sdap_header_present, "SDAP header present flag", vs_sdap_header_present, "SDAP header present flag"),
11728         UAT_FLD_VS(pdcp_nr_users, mac_i_present, "MAC-I present flag", vs_mac_i_present, "MAC-I present flag"),
11729         UAT_FLD_VS(pdcp_nr_users, plane, "Plane", vs_pdcp_plane, "Signaling or user plane"),
11730         UAT_FLD_VS(pdcp_nr_users, pdcp_nr_sn_length, "PDCP SN length", vs_pdcp_nr_sn_length, "Length of PDCP sequence number"),
11731         UAT_FLD_VS(pdcp_nr_users, rohc_compression, "ROHC compression", vs_rohc_compression, "Header compression"),
11732         //UAT_FLD_VS(pdcp_nr_users, rohc_mode, "ROHC mode", vs_rohc_mode, "ROHC mode"),
11733         UAT_FLD_VS(pdcp_nr_users, rohc_profile, "ROHC profile", vs_rohc_profile, "ROHC profile"),
11734         UAT_END_FIELDS
11735     };
11736 
11737     pdcp_nr_keys_uat = uat_new("PDCP-NR Keys",
11738         sizeof(uat_pdcp_nr_keys_record_t), /* record size */
11739         "gtp_pdcp_nr_keys2",                /* filename */
11740         TRUE,                              /* from_profile */
11741         &uat_pdcp_nr_keys_records,         /* data_ptr */
11742         &num_pdcp_nr_keys_uat,             /* numitems_ptr */
11743         UAT_AFFECTS_DISSECTION,            /* affects dissection of packets, but not set of named fields */
11744         NULL,                              /* help */
11745         pdcp_nr_copy_cb,                   /* copy callback */
11746         pdcp_nr_update_cb,                 /* update callback */
11747         pdcp_nr_free_cb,                   /* free callback */
11748         NULL,                              /* post update callback */
11749         NULL,                              /* reset callback */
11750         pdcp_nr_keys_uat_flds);            /* UAT field definitions */
11751 
11752     prefs_register_uat_preference(gtp_module,
11753         "pdcp_nr_table",
11754         "GTP PDCP-NR Keys",
11755         "Preconfigured PDCP-NR Keys",
11756         pdcp_nr_keys_uat);
11757 
11758     /* --- END PDCP NR DECODE ADDITIONS ---*/
11759 
11760     gtp_handle = register_dissector("gtp", dissect_gtp, proto_gtp);
11761     gtp_prime_handle = register_dissector("gtpprime", dissect_gtpprime, proto_gtpprime);
11762     nrup_handle = register_dissector("nrup", dissect_nrup, proto_nrup);
11763 
11764     gtp_priv_ext_dissector_table = register_dissector_table("gtp.priv_ext", "GTP Private Extension", proto_gtp, FT_UINT16, BASE_DEC);
11765     gtp_cdr_fmt_dissector_table = register_dissector_table("gtp.cdr_fmt", "GTP Data Record Type", proto_gtp, FT_UINT16, BASE_DEC);
11766     gtp_hdr_ext_dissector_table = register_dissector_table("gtp.hdr_ext", "GTP Header Extension", proto_gtp, FT_UINT16, BASE_DEC);
11767 
11768     register_init_routine(gtp_init);
11769     register_cleanup_routine(gtp_cleanup);
11770     gtp_tap = register_tap("gtp");
11771     gtpv1_tap = register_tap("gtpv1");
11772 
11773     register_srt_table(proto_gtp, NULL, 1, gtpstat_packet, gtpstat_init, NULL);
11774 }
11775 /* TS 132 295 V9.0.0 (2010-02)
11776  * 5.1.3 Port usage
11777  * - The UDP Destination Port may be the server port number 3386 which has been reserved for GTP'.
11778  * Alternatively another port can be used, which has been configured by O&M, except Port Number 2123
11779  * which is used by GTPv2-C.
11780  * :
11781  * The TCP Destination Port may be the server port number 3386, which has been reserved for G-PDUs. Alternatively,
11782  * another port may be used as configured by O&M. Extra implementation-specific destination ports are possible but
11783  * all CGFs shall support the server port number.
11784  */
11785 
11786 void
proto_reg_handoff_gtp(void)11787 proto_reg_handoff_gtp(void)
11788 {
11789     static gboolean           Initialized = FALSE;
11790     static gboolean           gtp_over_tcp;
11791     static guint              gtpv0_port;
11792     static guint              gtpv1c_port;
11793     static guint              gtpv1u_port;
11794 
11795     if (!Initialized) {
11796 
11797         radius_register_avp_dissector(VENDOR_THE3GPP, 5, dissect_radius_qos_umts);
11798         radius_register_avp_dissector(VENDOR_THE3GPP, 12, dissect_radius_selection_mode);
11799 
11800 
11801 
11802         eth_handle           = find_dissector_add_dependency("eth_withoutfcs", proto_gtp);
11803         ip_handle            = find_dissector_add_dependency("ip", proto_gtp);
11804         ipv6_handle          = find_dissector_add_dependency("ipv6", proto_gtp);
11805         ppp_handle           = find_dissector_add_dependency("ppp", proto_gtp);
11806         sync_handle          = find_dissector_add_dependency("sync", proto_gtp);
11807         gtpcdr_handle        = find_dissector_add_dependency("gtpcdr", proto_gtp);
11808         sndcpxid_handle      = find_dissector_add_dependency("sndcpxid", proto_gtp);
11809         gtpv2_handle         = find_dissector_add_dependency("gtpv2", proto_gtp);
11810         bssgp_handle         = find_dissector_add_dependency("bssgp", proto_gtp);
11811         pdcp_nr_handle       = find_dissector_add_dependency("pdcp-nr", proto_gtp);
11812         pdcp_lte_handle      = find_dissector_add_dependency("pdcp-lte", proto_gtp);
11813         proto_pdcp_lte       = dissector_handle_get_protocol_index(pdcp_lte_handle);
11814 
11815         bssap_pdu_type_table = find_dissector_table("bssap.pdu_type");
11816         /* AVP Code: 5 3GPP-GPRS Negotiated QoS profile */
11817         dissector_add_uint("diameter.3gpp", 5, create_dissector_handle(dissect_diameter_3gpp_qosprofile, proto_gtp));
11818         /* AVP Code: 903 MBMS-Service-Area */
11819         dissector_add_uint("diameter.3gpp", 903, create_dissector_handle(dissect_gtp_3gpp_mbms_service_area, proto_gtp));
11820         /* AVP Code: 904 MBMS-Session-Duration */
11821         dissector_add_uint("diameter.3gpp", 904, create_dissector_handle(dissect_gtp_mbms_ses_dur, proto_gtp));
11822         /* AVP Code: 911 MBMS-Time-To-Data-Transfer */
11823         dissector_add_uint("diameter.3gpp", 911, create_dissector_handle(dissect_gtp_mbms_time_to_data_tr, proto_gtp));
11824 
11825         Initialized = TRUE;
11826     } else {
11827         dissector_delete_uint("udp.port", gtpv0_port,  gtp_prime_handle);
11828         dissector_delete_uint("udp.port", gtpv1c_port, gtp_handle);
11829         dissector_delete_uint("udp.port", gtpv1u_port, gtp_handle);
11830 
11831         if (gtp_over_tcp) {
11832             dissector_delete_uint("tcp.port", gtpv0_port,  gtp_prime_handle);
11833             dissector_delete_uint("tcp.port", gtpv1c_port, gtp_handle);
11834             dissector_delete_uint("tcp.port", gtpv1u_port, gtp_handle);
11835         }
11836     }
11837 
11838     gtp_over_tcp = g_gtp_over_tcp;
11839     gtpv0_port   = g_gtpv0_port;
11840     gtpv1c_port  = g_gtpv1c_port;
11841     gtpv1u_port  = g_gtpv1u_port;
11842 
11843     /* This doesn't use the "auto preference" API because the port
11844         description is too specific */
11845     dissector_add_uint("udp.port", g_gtpv0_port, gtp_prime_handle);
11846     dissector_add_uint("udp.port", g_gtpv1c_port, gtp_handle);
11847     dissector_add_uint("udp.port", g_gtpv1u_port, gtp_handle);
11848 
11849     if (g_gtp_over_tcp) {
11850         /* This doesn't use the "auto preference" API because the port
11851            description is too specific */
11852         dissector_add_uint("tcp.port", g_gtpv0_port, gtp_prime_handle);
11853         dissector_add_uint("tcp.port", g_gtpv1c_port, gtp_handle);
11854         dissector_add_uint("tcp.port", g_gtpv1u_port, gtp_handle);
11855     }
11856 }
11857 
11858 /*
11859  * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
11860  *
11861  * Local variables:
11862  * c-basic-offset: 4
11863  * tab-width: 8
11864  * indent-tabs-mode: nil
11865  * End:
11866  *
11867  * vi: set shiftwidth=4 tabstop=8 expandtab:
11868  * :indentSize=4:tabSize=8:noTabs=true:
11869  */
11870