Revert "Fixup: tvb_* -> tvb_captured"
[metze/wireshark/wip.git] / epan / dissectors / packet-gtpv2.c
1 /* packet-gtpv2.c
2  *
3  * Routines for GTPv2 dissection
4  * Copyright 2009 - 2012, Anders Broman <anders.broman [at] ericcsson.com>
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  * Ref: 3GPP TS 29.274 version 11.1.0 Release 11 ETSI TS 129 274 V8.1.1 (2009-04)
24  */
25
26 #include "config.h"
27
28 #include <glib.h>
29
30 #include <epan/packet.h>
31 #include <epan/to_str.h>
32 #include <epan/asn1.h>
33 #include <epan/expert.h>
34 #include <epan/sminmpec.h>
35
36 #include "packet-gsm_a_common.h"
37 #include "packet-gsm_map.h"
38 #include "packet-e164.h"
39 #include "packet-e212.h"
40 #include "packet-s1ap.h"
41 #include "packet-ranap.h"
42 #include "packet-bssgp.h"
43 #include "packet-ntp.h"
44 #include "packet-gtpv2.h"
45 #include "packet-diameter.h"
46
47 void proto_register_gtpv2(void);
48 void proto_reg_handoff_gtpv2(void);
49
50 static dissector_handle_t nas_eps_handle;
51 static dissector_table_t gtpv2_priv_ext_dissector_table;
52
53
54 /*GTPv2 Message->GTP Header(SB)*/
55 static int proto_gtpv2 = -1;
56
57 static int hf_gtpv2_reserved = -1;
58 static int hf_gtpv2_spare_half_octet = -1;
59 static int hf_gtpv2_spare_bits = -1;
60 static int hf_gtpv2_flags = -1;
61 static int hf_gtpv2_version = -1;
62 static int hf_gtpv2_p = -1;
63 static int hf_gtpv2_t = -1;
64 static int hf_gtpv2_message_type = -1;
65 static int hf_gtpv2_msg_length = -1;
66 static int hf_gtpv2_teid = -1;
67 static int hf_gtpv2_seq = -1;
68 static int hf_gtpv2_spare = -1;
69
70
71 static int hf_gtpv2_ie = -1;
72 static int hf_gtpv2_ie_len = -1;
73 static int hf_gtpv2_cr = -1;
74 static int hf_gtpv2_instance = -1;
75 static int hf_gtpv2_cause = -1;
76 static int hf_gtpv2_cause_cs = -1;
77 static int hf_gtpv2_cause_bce = -1;
78 static int hf_gtpv2_cause_pce = -1;
79 static int hf_gtpv2_cause_off_ie_t = -1;
80 static int hf_gtpv2_rec = -1;
81 /*Start SRVCC Messages*/
82 static int hf_gtpv2_stn_sr = -1;
83 static int hf_gtpv2_len_trans_con = -1;
84 static int hf_gtpv2_eksi = -1;
85 static int hf_gtpv2_ck = -1;
86 static int hf_gtpv2_ik = -1;
87 static int hf_gtpv2_len_ms_classmark2 = -1;
88 static int hf_gtpv2_len_ms_classmark3 = -1;
89 static int hf_gtpv2_len_supp_codec_list = -1;
90 static int hf_gtpv2_ksi = -1;
91 /*static int hf_gtpv2_kc = -1; */
92 static int hf_gtpv2_cksn = -1;
93 static int hf_gtpv2_srvcc_cause = -1;
94 static int hf_gtpv2_rac = -1;
95 static int hf_gtpv2_rnc_id = -1;
96 static int hf_gtpv2_ext_rnc_id = -1;
97 static int hf_gtpv2_lac = -1;
98 static int hf_gtpv2_sac = -1;
99 static int hf_gtpv2_tgt_g_cell_id = -1;
100 static int hf_gtpv2_teid_c = -1;
101 static int hf_gtpv2_sv_sti = -1;
102 static int hf_gtpv2_sv_ics = -1;
103 static int hf_gtpv2_sv_emind = -1;
104 /*End SRVCC Messages*/
105 static int hf_gtpv2_apn = -1;
106 static int hf_gtpv2_ebi = -1;
107 static int hf_gtpv2_daf = -1;
108 static int hf_gtpv2_dtf = -1;
109 static int hf_gtpv2_hi = -1;
110 static int hf_gtpv2_dfi = -1;
111 static int hf_gtpv2_oi = -1;
112 static int hf_gtpv2_isrsi = -1;
113 static int hf_gtpv2_israi = -1;
114 static int hf_gtpv2_sgwci = -1;
115 static int hf_gtpv2_sqci = -1;
116 static int hf_gtpv2_uimsi = -1;
117 static int hf_gtpv2_cfsi = -1;
118 static int hf_gtpv2_crsi = -1;
119 static int hf_gtpv2_pt = -1;
120 static int hf_gtpv2_ps = -1;
121 static int hf_gtpv2_si = -1;
122 static int hf_gtpv2_msv = -1;
123 static int hf_gtpv2_spare1 = -1;
124 static int hf_gtpv2_spare2 = -1;
125 static int hf_gtpv2_spare3 = -1;
126 static int hf_gtpv2_s6af = -1;
127 static int hf_gtpv2_s4af = -1;
128 static int hf_gtpv2_mbmdt = -1;
129 static int hf_gtpv2_israu = -1;
130 static int hf_gtpv2_ccrsi = -1;
131 static int hf_gtpv2_pdn_type = -1;
132 static int hf_gtpv2_pdn_ipv4 = -1;
133 static int hf_gtpv2_pdn_ipv6_len = -1;
134 static int hf_gtpv2_pdn_ipv6 = -1;
135 static int hf_gtpv2_pdn_numbers_nsapi = -1;
136 static int hf_gtpv2_p_tmsi = -1;
137 static int hf_gtpv2_p_tmsi_sig = -1;
138 static int hf_gtpv2_mmbr_ul = -1;
139 static int hf_gtpv2_mmbr_dl = -1;
140
141 static int hf_gtpv2_rat_type = -1;
142 static int hf_gtpv2_uli_ecgi_flg = -1;
143 static int hf_gtpv2_uli_lai_flg = -1;
144 static int hf_gtpv2_uli_tai_flg = -1;
145 static int hf_gtpv2_uli_rai_flg = -1;
146 static int hf_gtpv2_uli_sai_flg = -1;
147 static int hf_gtpv2_uli_cgi_flg = -1;
148 static int hf_gtpv2_glt = -1;
149 static int hf_gtpv2_cng_rep_act = -1;
150
151 static int hf_gtpv2_selec_mode = -1;
152 static int hf_gtpv2_source_type = -1;
153 static int hf_gtpv2_f_teid_v4 = -1;
154 static int hf_gtpv2_f_teid_v6 = -1;
155 static int hf_gtpv2_f_teid_interface_type= -1;
156 static int hf_gtpv2_f_teid_gre_key= -1;
157 static int hf_gtpv2_f_teid_ipv4= -1;
158 static int hf_gtpv2_f_teid_ipv6= -1;
159 static int hf_gtpv2_tmsi = -1;
160 static int hf_gtpv2_hsgw_addr_f_len = -1;
161 static int hf_gtpv2_hsgw_addr_ipv4 = -1;
162 static int hf_gtpv2_hsgw_addr_ipv6 = -1;
163 static int hf_gtpv2_gre_key = -1;
164 static int hf_gtpv2_sgw_addr_ipv4 = -1;
165 static int hf_gtpv2_sgw_addr_ipv6 = -1;
166 static int hf_gtpv2_sgw_s1u_teid = -1;
167 static int hf_gtpv2_imsi= -1;
168 static int hf_gtpv2_ipv4_addr = -1;
169
170
171 static int hf_gtpv2_ambr_up= -1;
172 static int hf_gtpv2_ambr_down= -1;
173 static int hf_gtpv2_ip_address_ipv4= -1;
174 static int hf_gtpv2_ip_address_ipv6= -1;
175 static int hf_gtpv2_mei= -1;
176
177 /* Trace Information */
178 /* static int hf_gtpv2_tra_info = -1; */
179 static int hf_gtpv2_tra_info_msc_momt_calls = -1;
180 static int hf_gtpv2_tra_info_msc_momt_sms = -1;
181 static int hf_gtpv2_tra_info_msc_lu_imsi_ad = -1;
182 static int hf_gtpv2_tra_info_msc_handovers = -1;
183 static int hf_gtpv2_tra_info_msc_ss = -1;
184 static int hf_gtpv2_tra_info_mgw_context = -1;
185 static int hf_gtpv2_tra_info_sgsn_pdp_context = -1;
186 static int hf_gtpv2_tra_info_sgsn_momt_sms = -1;
187 static int hf_gtpv2_tra_info_sgsn_rau_gprs_ad = -1;
188 static int hf_gtpv2_tra_info_sgsn_mbms = -1;
189 static int hf_gtpv2_tra_info_sgsn_reserved = -1;
190 static int hf_gtpv2_tra_info_ggsn_pdp = -1;
191 static int hf_gtpv2_tra_info_ggsn_mbms = -1;
192 static int hf_gtpv2_tra_info_bm_sc = -1;
193 static int hf_gtpv2_tra_info_mme_sgw_ss = -1;
194 static int hf_gtpv2_tra_info_mme_sgw_sr = -1;
195 static int hf_gtpv2_tra_info_mme_sgw_iataud = -1;
196 static int hf_gtpv2_tra_info_lne_msc_s = -1;
197 static int hf_gtpv2_tra_info_lne_mgw = -1;
198 static int hf_gtpv2_tra_info_lne_sgsn = -1;
199 static int hf_gtpv2_tra_info_lne_ggsn = -1;
200 static int hf_gtpv2_tra_info_lne_rnc = -1;
201 static int hf_gtpv2_tra_info_lne_bm_sc = -1;
202 static int hf_gtpv2_tra_info_lne_mme = -1;
203 static int hf_gtpv2_tra_info_lne_sgw = -1;
204 static int hf_gtpv2_tra_info_lne_pdn_gw = -1;
205 static int hf_gtpv2_tra_info_lne_enb = -1;
206 static int hf_gtpv2_tra_info_tdl = -1;
207 static int hf_gtpv2_tra_info_lmsc_a = -1;
208 static int hf_gtpv2_tra_info_lmsc_lu = -1;
209 static int hf_gtpv2_tra_info_lmsc_mc = -1;
210 static int hf_gtpv2_tra_info_lmsc_map_g = -1;
211 static int hf_gtpv2_tra_info_lmsc_map_b = -1;
212 static int hf_gtpv2_tra_info_lmsc_map_e = -1;
213 static int hf_gtpv2_tra_info_lmsc_map_f = -1;
214 static int hf_gtpv2_tra_info_lmsc_cap = -1;
215 static int hf_gtpv2_tra_info_lmsc_map_d = -1;
216 static int hf_gtpv2_tra_info_lmsc_map_c = -1;
217 static int hf_gtpv2_tra_info_lmgw_mc = -1;
218 static int hf_gtpv2_tra_info_lmgw_nb_up = -1;
219 static int hf_gtpv2_tra_info_lmgw_lu_up = -1;
220 static int hf_gtpv2_tra_info_lsgsn_gb = -1;
221 static int hf_gtpv2_tra_info_lsgsn_lu = -1;
222 static int hf_gtpv2_tra_info_lsgsn_gn = -1;
223 static int hf_gtpv2_tra_info_lsgsn_map_gr = -1;
224 static int hf_gtpv2_tra_info_lsgsn_map_gd = -1;
225 static int hf_gtpv2_tra_info_lsgsn_map_gf = -1;
226 static int hf_gtpv2_tra_info_lsgsn_gs = -1;
227 static int hf_gtpv2_tra_info_lsgsn_ge = -1;
228 static int hf_gtpv2_tra_info_lggsn_gn = -1;
229 static int hf_gtpv2_tra_info_lggsn_gi = -1;
230 static int hf_gtpv2_tra_info_lggsn_gmb = -1;
231 static int hf_gtpv2_tra_info_lrnc_lu = -1;
232 static int hf_gtpv2_tra_info_lrnc_lur = -1;
233 static int hf_gtpv2_tra_info_lrnc_lub = -1;
234 static int hf_gtpv2_tra_info_lrnc_uu = -1;
235 static int hf_gtpv2_tra_info_lbm_sc_gmb = -1;
236 static int hf_gtpv2_tra_info_lmme_s1_mme = -1;
237 static int hf_gtpv2_tra_info_lmme_s3 = -1;
238 static int hf_gtpv2_tra_info_lmme_s6a = -1;
239 static int hf_gtpv2_tra_info_lmme_s10 = -1;
240 static int hf_gtpv2_tra_info_lmme_s11 = -1;
241 static int hf_gtpv2_tra_info_lsgw_s4 = -1;
242 static int hf_gtpv2_tra_info_lsgw_s5 = -1;
243 static int hf_gtpv2_tra_info_lsgw_s8b = -1;
244 static int hf_gtpv2_tra_info_lsgw_s11 = -1;
245 static int hf_gtpv2_tra_info_lpdn_gw_s2a = -1;
246 static int hf_gtpv2_tra_info_lpdn_gw_s2b = -1;
247 static int hf_gtpv2_tra_info_lpdn_gw_s2c = -1;
248 static int hf_gtpv2_tra_info_lpdn_gw_s5 = -1;
249 static int hf_gtpv2_tra_info_lpdn_gw_s6c = -1;
250 static int hf_gtpv2_tra_info_lpdn_gw_gx = -1;
251 static int hf_gtpv2_tra_info_lpdn_gw_s8b = -1;
252 static int hf_gtpv2_tra_info_lpdn_gw_sgi = -1;
253 static int hf_gtpv2_tra_info_lenb_s1_mme = -1;
254 static int hf_gtpv2_tra_info_lenb_x2 = -1;
255 static int hf_gtpv2_tra_info_lenb_uu = -1;
256
257 static int hf_gtpv2_address_digits = -1;
258 static int hf_gtpv2_ti = -1;
259
260 static int hf_gtpv2_bearer_qos_pvi= -1;
261 static int hf_gtpv2_bearer_qos_pl= -1;
262 static int hf_gtpv2_bearer_qos_pci= -1;
263 static int hf_gtpv2_bearer_qos_label_qci = -1;
264 static int hf_gtpv2_bearer_qos_mbr_up = -1;
265 static int hf_gtpv2_bearer_qos_mbr_down = -1;
266 static int hf_gtpv2_bearer_qos_gbr_up = -1;
267 static int hf_gtpv2_bearer_qos_gbr_down = -1;
268 static int hf_gtpv2_flow_qos_label_qci = -1;
269 static int hf_gtpv2_flow_qos_mbr_up = -1;
270 static int hf_gtpv2_flow_qos_mbr_down = -1;
271 static int hf_gtpv2_flow_qos_gbr_up = -1;
272 static int hf_gtpv2_flow_qos_gbr_down = -1;
273
274 static int hf_gtpv2_delay_value = -1;
275 static int hf_gtpv2_charging_id = -1;
276 static int hf_gtpv2_charging_characteristic = -1;
277 static int hf_gtpv2_bearer_flag_ppc = -1;
278 static int hf_gtpv2_bearer_flag_vb = -1;
279 static int hf_gtpv2_ue_time_zone_dst = -1;
280 static int hf_gtpv2_fq_csid_type = -1;
281 static int hf_gtpv2_fq_csid_nr = -1;
282 static int hf_gtpv2_fq_csid_ipv4 = -1;
283 static int hf_gtpv2_fq_csid_ipv6 = -1;
284 static int hf_gtpv2_fq_csid_id = -1;
285 static int hf_gtpv2_complete_req_msg_type = -1;
286 static int hf_gtpv2_mme_grp_id = -1;
287 static int hf_gtpv2_mme_code = -1;
288 static int hf_gtpv2_m_tmsi = -1;
289 static int hf_gtpv2_container_type = -1;
290 static int hf_gtpv2_cause_type = -1;
291 static int hf_gtpv2_CauseRadioNetwork = -1;
292 static int hf_gtpv2_CauseTransport = -1;
293 static int hf_gtpv2_CauseNas = -1;
294 static int hf_gtpv2_CauseProtocol = -1;
295 static int hf_gtpv2_CauseMisc = -1;
296 static int hf_gtpv2_target_type = -1;
297 static int hf_gtpv2_macro_enodeb_id = -1;
298
299 static int hf_gtpv2_node_type= -1;
300 static int hf_gtpv2_fqdn = -1;
301 static int hf_gtpv2_enterprise_id = -1;
302 static int hf_gtpv2_apn_rest= -1;
303 static int hf_gtpv2_pti= -1;
304 static int hf_gtpv2_mm_context_sm = -1;
305 static int hf_gtpv2_mm_context_nhi = -1;
306 static int hf_gtpv2_mm_context_drxi = -1;
307 static int hf_gtpv2_mm_context_cksn = -1;
308 static int hf_gtpv2_mm_context_cksn_ksi = -1;
309 static int hf_gtpv2_mm_context_kasme = -1;
310 static int hf_gtpv2_mm_context_rand = -1;
311 static int hf_gtpv2_mm_context_xres_len = -1;
312 static int hf_gtpv2_mm_context_xres = -1;
313 static int hf_gtpv2_mm_context_autn_len = -1;
314 static int hf_gtpv2_mm_context_autn = -1;
315 static int hf_gtpv2_mm_context_drx = -1;
316 static int hf_gtpv2_mm_context_ue_net_cap_len = -1;
317 static int hf_gtpv2_mm_context_ms_net_cap_len = -1;
318 static int hf_gtpv2_mm_context_mei_len = -1;
319 static int hf_gtpv2_mm_context_vdp_len = -1;
320 static int hf_gtpv2_mm_context_higher_br_16mb_flg_len = -1;
321 static int hf_gtpv2_mm_context_higher_br_16mb_flg = -1;
322 static int hf_gtpv2_vdp_length = -1;
323
324 static int hf_gtpv2_una = -1;
325 static int hf_gtpv2_gena = -1;
326 static int hf_gtpv2_gana = -1;
327 static int hf_gtpv2_ina = -1;
328 static int hf_gtpv2_ena = -1;
329 static int hf_gtpv2_hnna = -1;
330 static int hf_gtpv2_mm_context_ksi_a= -1;
331 static int hf_gtpv2_mm_context_ksi = -1;
332 static int hf_gtpv2_mm_context_nr_tri = -1;
333 static int hf_gtpv2_mm_context_used_cipher = -1;
334 static int hf_gtpv2_mm_context_nr_qui = -1;
335 static int hf_gtpv2_mm_context_nr_qua = -1;
336 static int hf_gtpv2_mm_context_uamb_ri = -1;
337 static int hf_gtpv2_mm_context_osci = -1;
338 static int hf_gtpv2_mm_context_samb_ri = -1;
339 static int hf_gtpv2_mm_context_unipa = -1;
340 static int hf_gtpv2_mm_context_unc = -1;
341 static int hf_gtpv2_mm_context_nas_dl_cnt = -1;
342 static int hf_gtpv2_mm_context_nas_ul_cnt = -1;
343
344 static int hf_gtpv2_uli_cgi_lac= -1;
345 static int hf_gtpv2_uli_cgi_ci= -1;
346 static int hf_gtpv2_uli_sai_lac= -1;
347 static int hf_gtpv2_uli_sai_sac= -1;
348 static int hf_gtpv2_uli_rai_lac= -1;
349 static int hf_gtpv2_uli_rai_rac= -1;
350 static int hf_gtpv2_uli_tai_tac= -1;
351 static int hf_gtpv2_uli_ecgi_eci= -1;
352 static int hf_gtpv2_uli_lai_lac = -1;
353 static int hf_gtpv2_uli_ecgi_eci_spare= -1;
354 static int hf_gtpv2_nsapi = -1;
355 static int hf_gtpv2_bearer_control_mode= -1;
356
357 static int hf_gtpv2_bss_container_phx = -1;
358 static int hf_gtpv2_bss_con_sapi_flg = -1;
359 static int hf_gtpv2_bss_con_rp_flg = -1;
360 static int hf_gtpv2_bss_con_pfi_flg = -1;
361 static int hf_gtpv2_bss_con_pfi = -1;
362 static int hf_gtpv2_bss_con_rp = -1;
363 static int hf_gtpv2_bss_con_sapi = -1;
364 static int hf_gtpv2_bss_con_xid_len = -1;
365 static int hf_gtpv2_bss_con_xid = -1;
366 static int hf_gtpv2_home_enodeb_id = -1;
367 static int hf_gtpv2_tac = -1;
368
369 /* MBMS */
370 static int hf_gtpv2_mbms_service_area_nr = -1;
371 static int hf_gtpv2_mbms_service_area_id = -1;
372 static int hf_gtpv2_mbms_session_id = -1;
373 static int hf_gtpv2_mbms_flow_id = -1;
374 static int hf_gtpv2_cteid = -1;
375 static int hf_gtpv2_ip_addr_type = -1;
376 static int hf_gtpv2_ip_addr_len = -1;
377 static int hf_gtpv2_mbms_ip_mc_dist_addrv4 = -1;
378 static int hf_gtpv2_mbms_ip_mc_dist_addrv6 = -1;
379 static int hf_gtpv2_mbms_ip_mc_src_addrv4 = -1;
380 static int hf_gtpv2_mbms_ip_mc_src_addrv6 = -1;
381 static int hf_gtpv2_mbms_hc_indicator = -1;
382 static int hf_gtpv2_mbms_dist_indication = -1;
383 static int hf_gtpv2_subscriber_rfsp = -1;
384 static int hf_gtpv2_rfsp_inuse = -1;
385 static int hf_gtpv2_mbms_service_id = -1;
386 static int hf_gtpv2_add_flags_for_srvcc_ics = -1;
387 static int hf_gtpv2_vsrvcc_flag = -1;
388 static int hf_gtpv2_abs_time_mbms_data = -1;
389 static int hf_gtpv2_henb_info_report_fti = -1;
390 static int hf_gtpv2_ip4cp_subnet_prefix_len = -1;
391 static int hf_gtpv2_ip4cp_ipv4 = -1;
392 static int hf_gtpv2_change_report_flags_sncr = -1;
393 static int hf_gtpv2_change_report_flags_tzcr = -1;
394 static int hf_gtpv2_action_indication_val = -1;
395 static int hf_gtpv2_mbms_session_duration_days = -1;
396 static int hf_gtpv2_mbms_session_duration_secs = -1;
397 static int hf_gtpv2_node_features_prn = -1;
398 static int hf_gtpv2_node_features_mabr =-1;
399 static int hf_gtpv2_node_features_ntsr = -1;
400 static int hf_gtpv2_time_to_data_xfer = -1;
401 static int hf_gtpv2_arp_pvi = -1;
402 static int hf_gtpv2_arp_pl = -1;
403 static int hf_gtpv2_arp_pci = -1;
404 static int hf_gtpv2_timer_unit = -1;
405 static int hf_gtpv2_timer_value = -1;
406 static int hf_gtpv2_lapi = -1;
407
408 static gint ett_gtpv2 = -1;
409 static gint ett_gtpv2_flags = -1;
410 static gint ett_gtpv2_ie = -1;
411 static gint ett_gtpv2_uli_flags = -1;
412 static gint ett_gtpv2_uli_field = -1;
413 static gint ett_gtpv2_bearer_ctx = -1;
414 static gint ett_gtpv2_PDN_conn = -1;
415 static gint ett_gtpv2_mm_context_flag = -1;
416 static gint ett_gtpv2_pdn_numbers_nsapi = -1;
417 static gint ett_gtpv2_tra_info_trigg = -1;
418 static gint ett_gtpv2_tra_info_trigg_msc_server = -1;
419 static gint ett_gtpv2_tra_info_trigg_mgw = -1;
420 static gint ett_gtpv2_tra_info_trigg_sgsn = -1;
421 static gint ett_gtpv2_tra_info_trigg_ggsn = -1;
422 static gint ett_gtpv2_tra_info_trigg_bm_sc = -1;
423 static gint ett_gtpv2_tra_info_trigg_sgw_mme = -1;
424 static gint ett_gtpv2_tra_info_interfaces = -1;
425 static gint ett_gtpv2_tra_info_interfaces_imsc_server = -1;
426 static gint ett_gtpv2_tra_info_interfaces_lmgw = -1;
427 static gint ett_gtpv2_tra_info_interfaces_lsgsn = -1;
428 static gint ett_gtpv2_tra_info_interfaces_lggsn = -1;
429 static gint ett_gtpv2_tra_info_interfaces_lrnc = -1;
430 static gint ett_gtpv2_tra_info_interfaces_lbm_sc = -1;
431 static gint ett_gtpv2_tra_info_interfaces_lmme = -1;
432 static gint ett_gtpv2_tra_info_interfaces_lsgw = -1;
433 static gint ett_gtpv2_tra_info_interfaces_lpdn_gw = -1;
434 static gint ett_gtpv2_tra_info_interfaces_lpdn_lenb = -1;
435 static gint ett_gtpv2_tra_info_ne_types = -1;
436 static gint ett_gtpv2_rai = -1;
437 static gint ett_gtpv2_ms_mark = -1;
438 static gint ett_gtpv2_stn_sr = -1;
439 static gint ett_gtpv2_supp_codec_list = -1;
440 static gint ett_gtpv2_bss_con = -1;
441 static gint ett_gtpv2_mm_context_auth_qua = -1;
442 static gint ett_gtpv2_mm_context_auth_qui = -1;
443 static gint ett_gtpv2_mm_context_auth_tri = -1;
444 static gint ett_gtpv2_mm_context_net_cap = -1;
445 static gint ett_gtpv2_ms_network_capability = -1;
446 static gint ett_gtpv2_vd_pref = -1;
447 static gint ett_gtpv2_access_rest_data = -1;
448 static gint ett_gtpv2_qua = -1;
449 static gint ett_gtpv2_qui = -1;
450
451 static expert_field ei_gtpv2_ie_data_not_dissected = EI_INIT;
452 static expert_field ei_gtpv2_ie_len_invalid = EI_INIT;
453 static expert_field ei_gtpv2_source_type_unknown = EI_INIT;
454 static expert_field ei_gtpv2_fq_csid_type_bad = EI_INIT;
455
456 /* Definition of User Location Info (AVP 22) masks */
457 #define GTPv2_ULI_CGI_MASK          0x01
458 #define GTPv2_ULI_SAI_MASK          0x02
459 #define GTPv2_ULI_RAI_MASK          0x04
460 #define GTPv2_ULI_TAI_MASK          0x08
461 #define GTPv2_ULI_ECGI_MASK         0x10
462 #define GTPv2_ULI_LAI_MASK          0x20
463
464 #define GTPV2_CREATE_SESSION_REQUEST     32
465 #define GTPV2_CREATE_SESSION_RESPONSE    33
466 #define GTPV2_CONTEXT_RESPONSE          131
467 #define GTPV2_FORWARD_RELOCATION_REQ    133
468 #define GTPV2_FORWARD_CTX_NOTIFICATION  137
469 #define GTPV2_RAN_INFORMATION_RELAY     152
470
471 static void dissect_gtpv2_ie_common(tvbuff_t * tvb, packet_info * pinfo _U_, proto_tree * tree, gint offset, guint8 message_type);
472
473 /*Message Types for GTPv2 (Refer Pg19 29.274) (SB)*/
474 static const value_string gtpv2_message_type_vals[] = {
475     {  0, "Reserved"},
476     {  1, "Echo Request"},
477     {  2, "Echo Response"},
478     {  3, "Version Not Supported Indication"},
479     /* 4-24 Reserved for S101 interface TS 29.276 */
480     {  4, "Node Alive Request"},
481     {  5, "Node Alive Response"},
482     {  6, "Redirection Request"},
483     {  7, "Redirection Response"},
484     /* 25-31 Reserved for Sv interface TS 29.280 */
485 /*Start SRVCC Messages ETSI TS 129 280 V10.1.0 (2011-06) 5.2.1*/
486     { 25, "SRVCC PS to CS Request"},
487     { 26, "SRVCC PS to CS Response"},
488     { 27, "SRVCC PS to CS Complete Notification"},
489     { 28, "SRVCC PS to CS Complete Acknowledge"},
490     { 29, "SRVCC PS to CS Cancel Notification"},
491     { 30, "SRVCC PS to CS Cancel Acknowledge"},
492     { 31, "For Future Sv interface use"},
493 /*End SRVCC Messages*/
494     /* SGSN/MME to PGW (S4/S11, S5/S8) */
495     { 32, "Create Session Request"},
496     { 33, "Create Session Response"},
497     { 34, "Modify Bearer Request"},
498     { 35, "Modify Bearer Response"},
499     { 36, "Delete Session Request"},
500     { 37, "Delete Session Response"},
501     /* SGSN to PGW (S4, S5/S8) */
502     { 38, "Change Notification Request"},
503     { 39, "Change Notification Response"},
504     /* 40-63 For future use */
505     /* Messages without explicit response */
506     { 64, "Modify Bearer Command"},                          /* (MME/SGSN to PGW -S11/S4, S5/S8) */
507     { 65, "Modify Bearer Failure Indication"},               /*(PGW to MME/SGSN -S5/S8, S11/S4) */
508     { 66, "Delete Bearer Command"},                          /* (MME to PGW -S11, S5/S8) */
509     { 67, "Delete Bearer Failure Indication"},               /* (PGW to MME -S5/S8, S11) */
510     { 68, "Bearer Resource Command"},                        /* (MME/SGSN to PGW -S11/S4, S5/S8) */
511     { 69, "Bearer Resource Failure Indication"},             /* (PGW to MME/SGSN -S5/S8, S11/S4) */
512     { 70, "Downlink Data Notification Failure Indication"},  /*(SGSN/MME to SGW -S4/S11) */
513     { 71, "Trace Session Activation"},
514     { 72, "Trace Session Deactivation"},
515     { 73, "Stop Paging Indication"},
516     /* 74-94 For future use */
517     /* PDN-GW to SGSN/MME (S5/S8, S4/S11) */
518     { 95, "Create Bearer Request"},
519     { 96, "Create Bearer Response"},
520     { 97, "Update Bearer Request"},
521     { 98, "Update Bearer Response"},
522     { 99, "Delete Bearer Request"},
523     {100, "Delete Bearer Response"},
524     /* PGW to MME, MME to PGW, SGW to PGW, SGW to MME (S5/S8, S11) */
525     {101, "Delete PDN Connection Set Request"},
526     {102, "Delete PDN Connection Set Response"},
527     /* 103-127 For future use */
528     /* MME to MME, SGSN to MME, MME to SGSN, SGSN to SGSN (S3/10/S16) */
529     {128, "Identification Request"},
530     {129, "Identification Response"},
531     {130, "Context Request"},
532     {131, "Context Response"},
533     {132, "Context Acknowledge"},
534     {133, "Forward Relocation Request"},
535     {134, "Forward Relocation Response"},
536     {135, "Forward Relocation Complete Notification"},
537     {136, "Forward Relocation Complete Acknowledge"},
538     {137, "Forward Access Context Notification"},
539     {138, "Forward Access Context Acknowledge"},
540     {139, "Relocation Cancel Request"},
541     {140, "Relocation Cancel Response"},
542     {141, "Configuration Transfer Tunnel"},
543     /* 142-148 For future use */
544     /* SGSN to MME, MME to SGSN (S3)*/
545     {149, "Detach Notification"},
546     {150, "Detach Acknowledge"},
547     {151, "CS Paging Indication"},
548     {152, "RAN Information Relay"},
549     {153, "Alert MME Notification"},
550     {154, "Alert MME Acknowledge"},
551     {155, "UE Activity Notification"},
552     {156, "UE Activity Acknowledge"},
553     /* 157 to 159 For future use */
554     /* MME to SGW (S11) */
555     {160, "Create Forwarding Tunnel Request"},
556     {161, "Create Forwarding Tunnel Response"},
557     {162, "Suspend Notification"},
558     {163, "Suspend Acknowledge"},
559     {164, "Resume Notification"},
560     {165, "Resume Acknowledge"},
561     {166, "Create Indirect Data Forwarding Tunnel Request"},
562     {167, "Create Indirect Data Forwarding Tunnel Response"},
563     {168, "Delete Indirect Data Forwarding Tunnel Request"},
564     {169, "Delete Indirect Data Forwarding Tunnel Response"},
565     {170, "Release Access Bearers Request"},
566     {171, "Release Access Bearers Response"},
567     /* 172-175 For future use */
568     /* SGW to SGSN/MME (S4/S11) */
569     {176, "Downlink Data Notification"},
570     {177, "Downlink Data Notification Acknowledgement"},
571     {178, "Reserved. Allocated in earlier version of the specification."},
572     {179, "PGW Restart Notification"},
573     {180, "PGW Restart Notification Acknowledge"},
574     /* 181-199 For future use */
575     /* SGW to PGW, PGW to SGW (S5/S8) */
576     {200, "Update PDN Connection Set Request"},
577     {201, "Update PDN Connection Set Response"},
578     /* 202 to 210 For future use */
579     /* MME to SGW (S11) */
580     {211, "Modify Access Bearers Request"},
581     {212, "Modify Access Bearers Response"},
582     /* 213 to 230 For future use */
583     /* MBMS GW to MME/SGSN (Sm/Sn) */
584     {231, "MBMS Session Start Request"},
585     {232, "MBMS Session Start Response"},
586     {233, "MBMS Session Update Request"},
587     {234, "MBMS Session Update Response"},
588     {235, "MBMS Session Stop Request"},
589     {236, "MBMS Session Stop Response"},
590     /* 237 to 239 For future use */
591     {240, "SRVCC CS to PS Response"},               /* 5.2.9  3GPP TS 29.280 V11.5.0 (2013-09) */
592     {241, "SRVCC CS to PS Complete Notification"},      /* 5.2.10 3GPP TS 29.280 V11.5.0 (2013-09) */
593     {242, "SRVCC CS to PS Complete Acknowledge"},       /* 5.2.11 3GPP TS 29.280 V11.5.0 (2013-09) */
594     {243, "SRVCC CS to PS Cancel Notification"},        /* 5.2.12 3GPP TS 29.280 V11.5.0 (2013-09) */
595     {244, "SRVCC CS to PS Cancel Acknowledge"},     /* 5.2.13 3GPP TS 29.280 V11.5.0 (2013-09) */
596     /* 245 to 247       For future Sv interface use*/
597     /* 248 to 255 For future use */
598     {0, NULL}
599 };
600 static value_string_ext gtpv2_message_type_vals_ext = VALUE_STRING_EXT_INIT(gtpv2_message_type_vals);
601
602 #define GTPV2_IE_RESERVED                 0
603 #define GTPV2_IE_IMSI                     1
604 #define GTPV2_IE_CAUSE                    2
605 #define GTPV2_REC_REST_CNT                3
606 /*Start SRVCC Messages*/
607 #define GTPV2_IE_STN_SR                  51
608 #define GTPV2_IE_SRC_TGT_TRANS_CON       52
609 #define GTPV2_IE_TGT_SRC_TRANS_CON       53
610 #define GTPV2_IE_MM_CON_EUTRAN_SRVCC     54
611 #define GTPV2_IE_MM_CON_UTRAN_SRVCC      55
612 #define GTPV2_IE_SRVCC_CAUSE             56
613 #define GTPV2_IE_TGT_RNC_ID              57
614 #define GTPV2_IE_TGT_GLOGAL_CELL_ID      58
615 #define GTPV2_IE_TEID_C                  59
616 #define GTPV2_IE_SV_FLAGS                60
617 #define GTPV2_IE_SAI                     61
618 /* 61 - 70 for future sv interface use*/
619 /*End SRVCC Messages*/
620 #define GTPV2_APN                        71
621 #define GTPV2_AMBR                       72
622 #define GTPV2_EBI                        73
623 #define GTPV2_IP_ADDRESS                 74
624 #define GTPV2_MEI                        75
625 #define GTPV2_IE_MSISDN                  76
626 #define GTPV2_INDICATION                 77
627 #define GTPV2_PCO                        78
628 #define GTPV2_PAA                        79
629 #define GTPV2_BEARER_QOS                 80
630 #define GTPV2_IE_FLOW_QOS                81
631 #define GTPV2_IE_RAT_TYPE                82
632 #define GTPV2_IE_SERV_NET                83
633 #define GTPV2_IE_BEARER_TFT              84
634 #define GTPV2_IE_TAD                     85
635 #define GTPV2_IE_ULI                     86
636 #define GTPV2_IE_F_TEID                  87
637 #define GTPV2_IE_TMSI                    88
638 #define GTPV2_IE_GLOBAL_CNID             89
639 #define GTPV2_IE_S103PDF                 90
640 #define GTPV2_IE_S1UDF                   91
641 #define GTPV2_IE_DEL_VAL                 92
642 #define GTPV2_IE_BEARER_CTX              93
643 #define GTPV2_IE_CHAR_ID                 94
644 #define GTPV2_IE_CHAR_CHAR               95
645 #define GTPV2_IE_TRA_INFO                96
646 #define GTPV2_BEARER_FLAG                97
647 /* define GTPV2_IE_PAGING_CAUSE          98 (void) */
648 #define GTPV2_IE_PDN_TYPE                99
649 #define GTPV2_IE_PTI                    100
650 #define GTPV2_IE_DRX_PARAM              101
651 #define GTPV2_IE_UE_NET_CAPABILITY      102
652 #define GTPV2_IE_MM_CONTEXT_GSM_T       103
653 #define GTPV2_IE_MM_CONTEXT_UTMS_CQ     104
654 #define GTPV2_IE_MM_CONTEXT_GSM_CQ      105
655 #define GTPV2_IE_MM_CONTEXT_UTMS_Q      106
656 #define GTPV2_IE_MM_CONTEXT_EPS_QQ      107
657 #define GTPV2_IE_MM_CONTEXT_UTMS_QQ     108
658 #define GTPV2_IE_PDN_CONNECTION         109
659 #define GTPV2_IE_PDN_NUMBERS            110
660 #define GTPV2_IE_P_TMSI                 111
661 #define GTPV2_IE_P_TMSI_SIG             112
662 #define GTPV2_IE_HOP_COUNTER            113
663 #define GTPV2_IE_UE_TIME_ZONE           114
664 #define GTPV2_IE_TRACE_REFERENCE        115
665 #define GTPV2_IE_COMPLETE_REQUEST_MSG   116
666 #define GTPV2_IE_GUTI                   117
667 #define GTPV2_IE_F_CONTAINER            118
668 #define GTPV2_IE_F_CAUSE                119
669 #define GTPV2_IE_SEL_PLMN_ID            120
670 #define GTPV2_IE_TARGET_ID              121
671 /* GTPV2_IE_NSAPI                       122 */
672 #define GTPV2_IE_PKT_FLOW_ID            123
673 #define GTPV2_IE_RAB_CONTEXT            124
674 #define GTPV2_IE_S_RNC_PDCP_CTX_INFO    125
675 #define GTPV2_IE_UDP_S_PORT_NR          126
676 #define GTPV2_IE_APN_RESTRICTION        127
677 #define GTPV2_IE_SEL_MODE               128
678 #define GTPV2_IE_SOURCE_IDENT           129
679 #define GTPV2_IE_BEARER_CONTROL_MODE    130
680 #define GTPV2_IE_CNG_REP_ACT            131
681 #define GTPV2_IE_FQ_CSID                132
682 #define GTPV2_IE_CHANNEL_NEEDED         133
683 #define GTPV2_IE_EMLPP_PRI              134
684 #define GTPV2_IE_NODE_TYPE              135
685 #define GTPV2_IE_FQDN                   136
686 #define GTPV2_IE_TI                     137
687 #define GTPV2_IE_MBMS_SESSION_DURATION  138
688 #define GTPV2_IE_MBMS_SERVICE_AREA      139
689 #define GTPV2_IE_MBMS_SESSION_ID        140
690 #define GTPV2_IE_MBMS_FLOW_ID           141
691 #define GTPV2_IE_MBMS_IP_MC_DIST        142
692 #define GTPV2_IE_MBMS_DIST_ACK          143
693 #define GTPV2_IE_RFSP_INDEX             144
694 #define GTPV2_IE_UCI                    145
695 #define GTPV2_IE_CSG_INFO_REP_ACTION    146
696 #define GTPV2_IE_CSG_ID                 147
697 #define GTPV2_IE_CMI                    148
698 #define GTPV2_IE_SERVICE_INDICATOR      149
699 #define GTPV2_IE_DETACH_TYPE            150
700 #define GTPV2_IE_LDN                    151
701 #define GTPV2_IE_NODE_FEATURES          152
702 #define GTPV2_IE_MBMS_TIME_TO_DATA_XFER 153
703 #define GTPV2_IE_THROTTLING             154
704 #define GTPV2_IE_ARP                    155
705 #define GTPV2_IE_EPC_TIMER              156
706 #define GTPV2_IE_SIG_PRIO_IND           157
707 #define GTPV2_IE_TMGI                   158
708 #define GTPV2_IE_ADD_MM_CONT_FOR_SRVCC  159
709 #define GTPV2_IE_ADD_FLAGS_FOR_SRVCC    160
710 #define GTPV2_IE_MMBR                   161
711 #define GTPV2_IE_MDT_CONFIG             162
712 #define GTPV2_IE_APCO                   163
713 #define GTPV2_IE_ABS_MBMS_DATA_TF_TIME  164
714 #define GTPV2_IE_HENB_INFO_REPORT  165
715 #define GTPV2_IE_IP4CP 166
716 #define GTPV2_IE_CHANGE_TO_REPORT_FLAGS 167
717 #define GTPV2_IE_ACTION_INDICATION 168
718 /* 169 to 254 reserved for future use */
719 #define GTPV2_IE_PRIVATE_EXT            255
720
721 #define SPARE                               0X0
722 #define CREATE_NEW_TFT                      0X20
723 #define DELETE_TFT                          0X40
724 #define ADD_PACKET_FILTERS_TFT              0X60
725 #define REPLACE_PACKET_FILTERS_TFT          0X80
726 #define DELETE_PACKET_FILTERS_TFT           0XA0
727 #define NO_TFT_OPERATION                    0XC0
728 #define RESERVED                            0XE0
729
730
731 /* Table 8.1-1: Information Element types for GTPv2 */
732 static const value_string gtpv2_element_type_vals[] = {
733     {  0, "Reserved"},
734     {  1, "International Mobile Subscriber Identity (IMSI)"},                   /* Variable Length / 8.3 */
735     {  2, "Cause"},                                                             /* Variable Length / 8.4 */
736     {  3, "Recovery (Restart Counter)"},                                        /* Variable Length / 8.5 */
737     /* 4-50 Reserved for S101 interface Extendable / See 3GPP TS 29.276 [14] */
738     /* 51-70 Reserved for Sv interface Extendable / See 3GPP TS 29.280 [15] */
739 /*Start SRVCC Messages ETSI TS 129 280 V10.1.0 (2011-06) 6.1*/
740     { 51, "STN-SR"},                                                            /* Variable Length / 6.2 */
741     { 52, "Source to Target Transparent Container"},                            /* Variable Length / 6.3 */
742     { 53, "Target to Source Transparent Container"},                            /* Variable Length / 6.4 */
743     { 54, "MM Context for E-UTRAN SRVCC"},                                      /* Variable Length / 6.5 */
744     { 55, "MM Context for UTRAN SRVCC"},                                        /* Variable Length / 6.6 */
745     { 56, "SRVCC Cause"},                                                       /* Fixed Length / 6.7 */
746     { 57, "Target RNC ID"},                                                     /* Variable Length / 6.8 */
747     { 58, "Target Global Cell ID"},                                             /* Variable Length / 6.9 */
748     { 59, "TEID-C"},                                                            /* Extendable / 6.10 */
749     { 60, "Sv Flags"},                                                          /* Extendable / 6.11 */
750     { 61, "Service Area Identifier"},                                           /* Extendable / 6.12 */
751    /* 62-70 For future Sv interface use */
752 /*End SRVCC Messages*/
753     { 71, "Access Point Name (APN)"},                                           /* Variable Length / 8.6 */
754     { 72, "Aggregate Maximum Bit Rate (AMBR)"},                                 /* Fixed Length / 8.7 */
755     { 73, "EPS Bearer ID (EBI)"},                                               /* Extendable / 8.8 */
756     { 74, "IP Address"},                                                        /* Extendable / 8.9 */
757     { 75, "Mobile Equipment Identity (MEI)"},                                   /* Variable Length / 8.10 */
758     { 76, "MSISDN"},                                                            /* Variable Length / 8.11 */
759     { 77, "Indication"},                                                        /* Extendable / 8.12 */
760     { 78, "Protocol Configuration Options (PCO)"},                              /* Variable Length / 8.13 */
761     { 79, "PDN Address Allocation (PAA)"},                                      /* Variable Length / 8.14 */
762     { 80, "Bearer Level Quality of Service (Bearer QoS)"},                      /* Variable Length / 8.15 */
763     { 81, "Flow Quality of Service (Flow QoS)"},                                /* Extendable / 8.16 */
764     { 82, "RAT Type"},                                                          /* Extendable / 8.17 */
765     { 83, "Serving Network"},                                                   /* Extendable / 8.18 */
766     { 84, "EPS Bearer Level Traffic Flow Template (Bearer TFT)"},               /* Variable Length / 8.19 */
767     { 85, "Traffic Aggregation Description (TAD)"},                             /* Variable Length / 8.20 */
768     { 86, "User Location Info (ULI)"},                                          /* Variable Length / 8.21 */
769     { 87, "Fully Qualified Tunnel Endpoint Identifier (F-TEID)"},               /* Extendable / 8.22 */
770     { 88, "TMSI"},                                                              /* Variable Length / 8.23 */
771     { 89, "Global CN-Id"},                                                      /* Variable Length / 8.24 */
772     { 90, "S103 PDN Data Forwarding Info (S103PDF)"},                           /* Variable Length / 8.25 */
773     { 91, "S1-U Data Forwarding Info (S1UDF)"},                                 /* Variable Length/ 8.26 */
774     { 92, "Delay Value"},                                                       /* Extendable / 8.27 */
775     { 93, "Bearer Context"},                                                    /* Extendable / 8.28 */
776     { 94, "Charging ID"},                                                       /* Extendable / 8.29 */
777     { 95, "Charging Characteristics"},                                          /* Extendable / 8.30 */
778     { 96, "Trace Information"},                                                 /* Extendable / 8.31 */
779     { 97, "Bearer Flags"},                                                      /* Extendable / 8.32 */
780     { 98, "Paging Cause"},                                                      /* Variable Length / 8.33 */
781     { 99, "PDN Type"},                                                          /* Extendable / 8.34 */
782     {100, "Procedure Transaction ID"},                                          /* Extendable / 8.35 */
783     {101, "DRX Parameter"},                                                     /* Variable Length/ 8.36 */
784     {102, "UE Network Capability"},                                             /* Variable Length / 8.37 */
785     {103, "MM Context (GSM Key and Triplets)"},                                 /* Variable Length / 8.38 */
786     {104, "MM Context (UMTS Key, Used Cipher and Quintuplets)"},                /* Variable Length / 8.38 */
787     {105, "MM Context (GSM Key, Used Cipher and Quintuplets)"},                 /* Variable Length / 8.38 */
788     {106, "MM Context (UMTS Key and Quintuplets)"},                             /* Variable Length / 8.38 */
789     {107, "MM Context (EPS Security Context, Quadruplets and Quintuplets)"},    /* Variable Length / 8.38 */
790     {108, "MM Context (UMTS Key, Quadruplets and Quintuplets)"},                /* Variable Length / 8.38 */
791     {109, "PDN Connection"},                                                    /* Extendable / 8.39 */
792     {110, "PDU Numbers"},                                                       /* Extendable / 8.40 */
793     {111, "P-TMSI"},                                                            /* Variable Length / 8.41 */
794     {112, "P-TMSI Signature"},                                                  /* Variable Length / 8.42 */
795     {113, "Hop Counter"},                                                       /* Extendable / 8.43 */
796     {114, "UE Time Zone"},                                                      /* Variable Length / 8.44 */
797     {115, "Trace Reference"},                                                   /* Fixed Length / 8.45 */
798     {116, "Complete Request Message"},                                          /* Variable Length / 8.46 */
799     {117, "GUTI"},                                                              /* Variable Length / 8.47 */
800     {118, "F-Container"},                                                       /* Variable Length / 8.48 */
801     {119, "F-Cause"},                                                           /* Variable Length / 8.49 */
802     {120, "Selected PLMN ID"},                                                  /* Variable Length / 8.50 */
803     {121, "Target Identification"},                                             /* Variable Length / 8.51 */
804     {122, "NSAPI"},                                                             /* Extendable / 8.52 */
805     {123, "Packet Flow ID"},                                                    /* Variable Length / 8.53 */
806     {124, "RAB Context"},                                                       /* Fixed Length / 8.54 */
807     {125, "Source RNC PDCP Context Info"},                                      /* Variable Length / 8.55 */
808     {126, "UDP Source Port Number"},                                            /* Extendable / 8.56 */
809     {127, "APN Restriction"},                                                   /* Extendable / 8.57 */
810     {128, "Selection Mode"},                                                    /* Extendable / 8.58 */
811     {129, "Source Identification"},                                             /* Variable Length / 8.50 */
812     {130, "Bearer Control Mode"},                                               /* Extendable / 8.60 */
813     {131, "Change Reporting Action"},                                           /* Variable Length / 8.61 */
814     {132, "Fully Qualified PDN Connection Set Identifier (FQ-CSID)"},           /* Variable Length / 8.62 */
815     {133, "Channel needed"},                                                    /* Extendable / 8.63 */
816     {134, "eMLPP Priority"},                                                    /* Extendable / 8.64 */
817     {135, "Node Type"},                                                         /* Extendable / 8.65 */
818     {136, "Fully Qualified Domain Name (FQDN)"},                                /* Variable Length / 8.66 */
819     {137, "Transaction Identifier (TI)"},                                       /* Variable Length / 8.68 */
820     {138, "MBMS Session Duration"},                                             /* Duration Extendable / 8.69 */
821     {139, "MBMS Service Area"},                                                 /* Extendable / 8.70 */
822     {140, "MBMS Session Identifier"},                                           /* Extendable / 8.71 */
823     {141, "MBMS Flow Identifier"},                                              /* Extendable / 8.72 */
824     {142, "MBMS IP Multicast Distribution"},                                    /* Extendable / 8.73 */
825     {143, "MBMS Distribution Acknowledge"},                                     /* Extendable / 8.74 */
826     {144, "RFSP Index"},                                                        /* Fixed Length / 8.77 */
827     {145, "User CSG Information (UCI)"},                                        /* Extendable / 8.75 */
828     {146, "CSG Information Reporting Action"},                                  /* Extendable / 8.76 */
829     {147, "CSG ID"},                                                            /* Extendable / 8.78 */
830     {148, "CSG Membership Indication (CMI)"},                                   /* Extendable / 8.79 */
831     {149, "Service indicator"},                                                 /* Fixed Length / 8.80 */
832     {150, "Detach Type"},                                                       /* Fixed Length / 8.81 */
833     {151, "Local Distiguished Name (LDN)"},                                     /* Variable Length / 8.82 */
834     {152, "Node Features"},                                                     /* Extendable / 8.83 */
835     {153, "MBMS Time to Data Transfer"},                                        /* Extendable / 8.84 */
836     {154, "Throttling"},                                                        /* Extendable / 8.85 */
837     {155, "Allocation/Retention Priority (ARP)"},                               /* Extendable / 8.86 */
838     {156, "EPC Timer"},                                                         /* Extendable / 8.87 */
839     {157, "Signalling Priority Indication"},                                    /* Extendable / 8.88 */
840     {158, "Temporary Mobile Group Identity"},                                   /* Extendable / 8.89 */
841     {159, "Additional MM context for SRVCC"},                                   /* Extendable / 8.90 */
842     {160, "Additional flags for SRVCC"},                                        /* Extendable / 8.91 */
843     {161, "Max MBR/APN-AMBR (MMBR)"},                                           /* Extendable / 8.92 */
844     {162, "MDT Configuration"},                                                 /* Extendable / 8.93 */
845     {163, "Additional Protocol Configuration Options (APCO)"},                  /* Extendable / 8.94 */
846     {164, "Absolute Time of MBMS Data Transfer"},                               /* Extendable / 8.95 */
847     {165, "H(e)NB Information Reporting"},                                      /* Extendable / 8.96*/
848     {166, "IPv4 Configuration Parameters (IP4CP)"},                             /* Extendable / 8.97*/
849     {167, "Change to Report Flags"},                                            /* Extendable / 8.98 */
850     {168, "Action Indication"},                                                 /* Extendable / 8.99 */
851     /* 169 to 254 Spare. For future use.  */                                    /* For future use. FFS */
852     {255, "Private Extension"},                                                 /* Variable Length / 8.67 */
853     {0, NULL}
854 };
855 static value_string_ext gtpv2_element_type_vals_ext = VALUE_STRING_EXT_INIT(gtpv2_element_type_vals);
856
857 /* Code to dissect IE's */
858
859 static void
860 dissect_gtpv2_unknown(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
861 {
862     proto_tree_add_expert(tree, pinfo, &ei_gtpv2_ie_data_not_dissected, tvb, 0, length);
863 }
864
865 /*
866  * 8.3 International Mobile Subscriber Identity (IMSI)
867  *
868  * IMSI is defined in 3GPP TS 23.003
869  * Editor's note: IMSI coding will be defined in 3GPP TS 24.301
870  * Editor's note: In the first release of GTPv2 spec (TS 29.274v8.0.0) n = 8.
871  * That is, the overall length of the IE is 11 octets.
872  */
873
874 static void
875 dissect_gtpv2_imsi(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length, guint8 message_type _U_, guint8 instance _U_)
876 {
877     int          offset = 0;
878     const gchar *imsi_str;
879
880     /* Fetch the BCD encoded digits from tvb low half byte, formating the digits according to
881      * a default digit set of 0-9 returning "?" for overdecadic digits a pointer to the EP
882      * allocated string will be returned.
883      */
884     imsi_str = tvb_bcd_dig_to_wmem_packet_str( tvb, offset, length, NULL, FALSE);
885
886     proto_tree_add_string(tree, hf_gtpv2_imsi, tvb, offset, length, imsi_str);
887     proto_item_append_text(item, "%s", imsi_str);
888
889 }
890
891 /*
892  * 8.4 Cause
893  */
894
895 /* Table 8.4-1: Cause values */
896 static const value_string gtpv2_cause_vals[] = {
897     {0, "Reserved"},
898     /* Request / Initial message */
899     {  1, "Reserved"},
900     {  2, "Local Detach"},
901     {  3, "Complete Detach"},
902     {  4, "RAT changed from 3GPP to Non-3GPP"},
903     {  5, "ISR deactivation"},
904     {  6, "Error Indication received from RNC/eNodeB/S4-SGSN"},
905     {  7, "IMSI Detach Only"},
906     {  8, "Reactivation Requested"},
907     {  9, "PDN reconnection to this APN disallowed"},
908     { 10, "Access changed from Non-3GPP to 3GPP"},
909     { 11, "PDN connection inactivity timer expires"},
910     { 12, "PGW not responding"},
911     { 13, "Network Failure"},
912     { 14, "QoS parameter mismatch"},
913     /* 15 Spare. This value range is reserved for Cause values in a request message */
914     { 15, "Spare"},
915     /* Acceptance in a Response / triggered message */
916     { 16, "Request accepted"},
917     { 17, "Request accepted partially"},
918     { 18, "New PDN type due to network preference"},
919     { 19, "New PDN type due to single address bearer only"},
920     /* 20-63 Spare. This value range shall be used by Cause values in an acceptance response/triggered message */
921     { 20, "Spare"},
922     { 21, "Spare"},
923     { 22, "Spare"},
924     { 23, "Spare"},
925     { 24, "Spare"},
926     { 25, "Spare"},
927     { 26, "Spare"},
928     { 27, "Spare"},
929     { 28, "Spare"},
930     { 29, "Spare"},
931     { 30, "Spare"},
932     { 31, "Spare"},
933     { 32, "Spare"},
934     { 33, "Spare"},
935     { 34, "Spare"},
936     { 35, "Spare"},
937     { 36, "Spare"},
938     { 37, "Spare"},
939     { 38, "Spare"},
940     { 39, "Spare"},
941     { 40, "Spare"},
942     { 41, "Spare"},
943     { 42, "Spare"},
944     { 43, "Spare"},
945     { 44, "Spare"},
946     { 45, "Spare"},
947     { 46, "Spare"},
948     { 47, "Spare"},
949     { 48, "Spare"},
950     { 49, "Spare"},
951     { 50, "Spare"},
952     { 51, "Spare"},
953     { 52, "Spare"},
954     { 53, "Spare"},
955     { 54, "Spare"},
956     { 55, "Spare"},
957     { 56, "Spare"},
958     { 57, "Spare"},
959     { 58, "Spare"},
960     { 59, "Spare"},
961     { 60, "Spare"},
962     { 61, "Spare"},
963     { 62, "Spare"},
964     { 63, "Spare"},
965     /* Rejection in a Response / triggered message */
966     { 64, "Context Not Found"},
967     { 65, "Invalid Message Format"},
968     { 66, "Version not supported by next peer"},
969     { 67, "Invalid length"},
970     { 68, "Service not supported"},
971     { 69, "Mandatory IE incorrect"},
972     { 70, "Mandatory IE missing"},
973     { 71, "Shall not be used"},
974     { 72, "System failure"},
975     { 73, "No resources available"},
976     { 74, "Semantic error in the TFT operation"},
977     { 75, "Syntactic error in the TFT operation"},
978     { 76, "Semantic errors in packet filter(s)"},
979     { 77, "Syntactic errors in packet filter(s)"},
980     { 78, "Missing or unknown APN"},
981     { 79, "Shall not be used"},
982     { 80, "GRE key not found"},
983     { 81, "Relocation failure"},
984     { 82, "Denied in RAT"},
985     { 83, "Preferred PDN type not supported"},
986     { 84, "All dynamic addresses are occupied"},
987     { 85, "UE context without TFT already activated"},
988     { 86, "Protocol type not supported"},
989     { 87, "UE not responding"},
990     { 88, "UE refuses"},
991     { 89, "Service denied"},
992     { 90, "Unable to page UE"},
993     { 91, "No memory available"},
994     { 92, "User authentication failed"},
995     { 93, "APN access denied - no subscription"},
996     { 94, "Request rejected(reason not specified)"},
997     { 95, "P-TMSI Signature mismatch"},
998     { 96, "IMSI/IMEI not known"},
999     { 97, "Semantic error in the TAD operation"},
1000     { 98, "Syntactic error in the TAD operation"},
1001     { 99, "Shall not be used"},
1002     {100, "Remote peer not responding"},
1003     {101, "Collision with network initiated request"},
1004     {102, "Unable to page UE due to Suspension"},
1005     {103, "Conditional IE missing"},
1006     {104, "APN Restriction type Incompatible with currently active PDN connection"},
1007     {105, "Invalid overall length of the triggered response message and a piggybacked initial message"},
1008     {106, "Data forwarding not supported"},
1009     {107, "Invalid reply from remote peer"},
1010     {108, "Fallback to GTPv1"},
1011     {109, "Invalid peer"},
1012     {110, "Temporarily rejected due to handover procedure in progress"},
1013     {111, "Modifications not limited to S1-U bearers"},
1014     {112, "Request rejected for a PMIPv6 reason "},
1015     {113, "APN Congestion"},
1016     {114, "Bearer handling not supported"},
1017     {115, "UE already re-attached"},
1018     {116, "Multiple PDN connections for a given APN not allowed"},
1019     /* 117-239 Spare. For future use in a triggered/response message  */
1020     /* 240-255 Spare. For future use in an initial/request message */
1021     {0, NULL}
1022 };
1023 value_string_ext gtpv2_cause_vals_ext = VALUE_STRING_EXT_INIT(gtpv2_cause_vals);
1024
1025 /* Table 8.4-1: CS (Cause Source) */
1026 static const true_false_string gtpv2_cause_cs = {
1027     "Originated by remote node",
1028     "Originated by node sending the message",
1029 };
1030
1031 static void
1032 dissect_gtpv2_cause(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length, guint8 message_type _U_, guint8 instance _U_)
1033 {
1034     int    offset = 0;
1035     guint8 tmp;
1036
1037     /* Cause value octet 5 */
1038     tmp = tvb_get_guint8(tvb, offset);
1039     proto_tree_add_item(tree, hf_gtpv2_cause, tvb, offset, 1, ENC_BIG_ENDIAN);
1040
1041     /* Add Cause to ie_tree */
1042     proto_item_append_text(item, "%s (%u)", val_to_str_ext_const(tmp, &gtpv2_cause_vals_ext, "Unknown"), tmp);
1043     offset += 1;
1044
1045     /* Octet 6 Spare PCE BCE CS */
1046     proto_tree_add_bits_item(tree, hf_gtpv2_spare_bits, tvb, offset << 3, 5, ENC_BIG_ENDIAN);
1047     proto_tree_add_item(tree, hf_gtpv2_cause_pce, tvb, offset, 1, ENC_BIG_ENDIAN);
1048     proto_tree_add_item(tree, hf_gtpv2_cause_bce, tvb, offset, 1, ENC_BIG_ENDIAN);
1049     proto_tree_add_item(tree, hf_gtpv2_cause_cs, tvb, offset,  1, ENC_BIG_ENDIAN);
1050     offset += 1;
1051
1052     /* If n = 2, a = 0 and the Cause IE shall be 6 octets long.
1053      * Therefore, octets "a(n+1) to a(n+4)" will not be present.
1054      * If n = 6, a = 1 and the Cause IE will be 10 octets long.
1055      */
1056     if ( length == 2 ) {
1057         return;
1058     }
1059     /*
1060      * If the rejection is due to a mandatory IE or a verifiable conditional IE is faulty
1061      * or missing, the offending IE shall be included within an additional field "a(n+1)
1062      * to a(n+4)". Only Type and Instance fields of the offending IE that caused the
1063      * rejection have a meaning. The length in the Octet 8-9 and spare bits in the Octet 10
1064      * shall be set to "0". In this case, the value of "n" shall be "6".
1065      * Otherwise, the value of "n" is equal to "2".
1066      */
1067
1068     /* Type of the offending IE */
1069     proto_tree_add_item(tree, hf_gtpv2_cause_off_ie_t, tvb, offset, 1, ENC_BIG_ENDIAN);
1070     offset += 1;
1071
1072     /* Length */
1073     proto_tree_add_item(tree, hf_gtpv2_ie_len, tvb, offset, 2, ENC_BIG_ENDIAN);
1074     offset += 2;
1075     /* a(n+4) Spare Instance */
1076     proto_tree_add_bits_item(tree, hf_gtpv2_spare_half_octet, tvb, offset << 3, 4, ENC_BIG_ENDIAN);
1077     proto_tree_add_item(tree, hf_gtpv2_instance, tvb, offset, 1, ENC_BIG_ENDIAN);
1078
1079 }
1080
1081 /*
1082  * 8.5 Recovery (Restart Counter)
1083  */
1084 static void
1085 dissect_gtpv2_recovery(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
1086 {
1087     int    offset = 0;
1088     guint8 recovery;
1089
1090     recovery = tvb_get_guint8(tvb, offset);
1091     proto_tree_add_item(tree, hf_gtpv2_rec, tvb, offset, 1, ENC_BIG_ENDIAN);
1092     proto_item_append_text(item, "%u", recovery);
1093
1094 }
1095
1096
1097 /*Start SRVCC Messages*/
1098
1099 /* 6.2 STN-SR */
1100 static void
1101 dissect_gtpv2_stn_sr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
1102 {
1103     proto_item *stn_sr_item;
1104     proto_tree *sub_tree;
1105     tvbuff_t   *new_tvb;
1106     int         offset = 0;
1107
1108     stn_sr_item = proto_tree_add_item(tree, hf_gtpv2_stn_sr, tvb, offset, length, ENC_NA);
1109     new_tvb = tvb_new_subset_length(tvb, offset, length);
1110     sub_tree = proto_item_add_subtree(stn_sr_item, ett_gtpv2_stn_sr);
1111
1112     /* Octet 5
1113      * contains the Nature of Address and Numbering Plan Indicator (NANPI) of the "AddressString" ASN.1 type (see 3GPP
1114      * TS 29.002 [11]). Octets 6 to (n+4) contain the actual STN-SR (digits of an address encoded as a TBCD-STRING as in
1115      * the "AddressString" ASN.1 type). For an odd number of STN-SR digits, bits 8 to 5 of the last octet are encoded with the
1116      * filler "1111".
1117      */
1118     dissect_gsm_map_msisdn(new_tvb, pinfo, sub_tree);
1119 }
1120
1121 /* 6.3 Source to Target Transparent Container */
1122
1123 static void
1124 dissect_gtpv2_src_tgt_trans_con(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
1125 {
1126     int offset = 0;
1127     proto_tree_add_item(tree, hf_gtpv2_len_trans_con, tvb, offset, 1, ENC_BIG_ENDIAN);
1128     offset += 1;
1129     /*ra_type_flag = 0;*/
1130
1131     /* Transparent Container
1132      * When target network is GERAN, this container carries the Old BSS to New BSS
1133      * Information IE defined in 3GPP TS 48.008 [8]. When target network is UTRAN, this container carries the Source RNC
1134      * to Target RNC Transparent Container IE defined in 3GPP TS 25.413 [9]. The Transparent container field includes the
1135      * IE value part as it is specified in the respective specification.
1136      */
1137     proto_tree_add_text(tree, tvb, offset, length-1, "Transparent Container: %s", tvb_bytes_to_ep_str(tvb, offset, length-1));
1138     /*
1139      * bssmap_old_bss_to_new_bss_info(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo);
1140      * dissect_ranap_SourceRNC_ToTargetRNC_TransparentContainer_PDU
1141      */
1142
1143 }
1144
1145 /* 6.4 Target to Source Transparent Container */
1146 static void
1147 dissect_gtpv2_tgt_src_trans_con(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
1148 {
1149     int offset = 0;
1150     proto_tree_add_item(tree, hf_gtpv2_len_trans_con, tvb, offset, 1, ENC_BIG_ENDIAN);
1151     offset += 1;
1152
1153     /* Transparent Container */
1154     proto_tree_add_text(tree, tvb, offset, length-1, "Transparent Container: %s", tvb_bytes_to_ep_str(tvb, offset, length-1));
1155
1156
1157 }
1158
1159 /* 6.5 MM Context for E-UTRAN SRVCC */
1160 static void
1161 dissect_gtpv2_mm_con_eutran_srvcc(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
1162 {
1163     int         offset = 0;
1164     guint8      elm_len;
1165     proto_tree *ms_tree, *fi;
1166
1167     proto_tree_add_item(tree, hf_gtpv2_eksi, tvb, offset, 1, ENC_BIG_ENDIAN);
1168     offset += 1;
1169     proto_tree_add_text(tree, tvb, offset , 16, "CKsrvcc: %s ", tvb_bytes_to_ep_str(tvb, offset, 16));
1170     offset += 16;
1171     proto_tree_add_text(tree, tvb, offset, 16, "IKsrvcc: %s ", tvb_bytes_to_ep_str(tvb, offset, 16));
1172     offset += 16;
1173
1174   /* Length of Mobile Station Classmark2  */
1175     elm_len = tvb_get_guint8(tvb, offset);
1176     proto_tree_add_item(tree, hf_gtpv2_len_ms_classmark2, tvb, offset, 1, ENC_BIG_ENDIAN);
1177     offset += 1;
1178     fi = proto_tree_add_text(tree, tvb, offset, elm_len, "Mobile Station Classmark2  %s", tvb_bytes_to_ep_str(tvb, offset, elm_len));
1179     ms_tree = proto_item_add_subtree(fi, ett_gtpv2_ms_mark);
1180     de_ms_cm_2(tvb, ms_tree, pinfo, offset, elm_len, NULL, 0);
1181     offset += elm_len;
1182
1183   /* Length of Mobile Station Classmark3  */
1184     elm_len = tvb_get_guint8(tvb, offset);
1185     proto_tree_add_item(tree, hf_gtpv2_len_ms_classmark3, tvb, offset, 1, ENC_BIG_ENDIAN);
1186     offset += 1;
1187     fi = proto_tree_add_text(tree, tvb, offset, elm_len, "Mobile Station Classmark3 %s", tvb_bytes_to_ep_str(tvb, offset, elm_len));
1188     ms_tree = proto_item_add_subtree(fi, ett_gtpv2_ms_mark);
1189     de_ms_cm_3(tvb, ms_tree, pinfo, offset, elm_len, NULL, 0);
1190     offset += elm_len;
1191
1192    /*Length of Supported Codec List  */
1193     elm_len = tvb_get_guint8(tvb, offset);
1194     proto_tree_add_item(tree, hf_gtpv2_len_supp_codec_list, tvb, offset, 1, ENC_BIG_ENDIAN);
1195     offset += 1;
1196     fi = proto_tree_add_text(tree, tvb, offset, elm_len, "Supported Codec List  %s", tvb_bytes_to_ep_str(tvb, offset, elm_len));
1197     ms_tree = proto_item_add_subtree(fi, ett_gtpv2_supp_codec_list);
1198     de_sup_codec_list(tvb, ms_tree, pinfo, offset, elm_len, NULL, 0);
1199
1200 }
1201
1202 /* 6.6 MM Context for UTRAN SRVCC */
1203 static void
1204 dissect_gtpv2_mm_con_utran_srvcc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
1205 {
1206     int         offset = 0;
1207     guint8      elm_len;
1208     proto_tree *ms_tree, *fi;
1209
1210     proto_tree_add_item(tree, hf_gtpv2_ksi, tvb, offset, 1, ENC_BIG_ENDIAN);
1211     offset += 1;
1212
1213     proto_tree_add_text(tree, tvb, offset, 16, "CK'cs: %s", tvb_bytes_to_ep_str(tvb, offset, 16));
1214     offset += 16;
1215     proto_tree_add_text(tree, tvb, offset, 16, "IK'cs: %s", tvb_bytes_to_ep_str(tvb, offset, 16));
1216     offset += 16;
1217     proto_tree_add_text(tree, tvb, offset,  8, "Kc': %s",   tvb_bytes_to_ep_str(tvb, offset, 8));
1218     offset += 8;
1219     proto_tree_add_item(tree, hf_gtpv2_cksn, tvb, offset, 1, ENC_BIG_ENDIAN);
1220     offset += 1;
1221
1222     /*Length of Mobile Station Classmark2  */
1223     elm_len = tvb_get_guint8(tvb, offset);
1224     proto_tree_add_item(tree, hf_gtpv2_len_ms_classmark2, tvb, offset, 1, ENC_BIG_ENDIAN);
1225     offset += 1;
1226     fi = proto_tree_add_text(tree, tvb, offset, elm_len, "Mobile Station Classmark2  %s", tvb_bytes_to_ep_str(tvb, offset, elm_len));
1227     ms_tree = proto_item_add_subtree(fi, ett_gtpv2_ms_mark);
1228     de_ms_cm_2(tvb, ms_tree, pinfo, offset, elm_len, NULL, 0);
1229     offset += elm_len;
1230
1231     /*Length of Mobile Station Classmark3  */
1232     elm_len = tvb_get_guint8(tvb, offset);
1233     proto_tree_add_item(tree, hf_gtpv2_len_ms_classmark3, tvb, offset, 1, ENC_BIG_ENDIAN);
1234     offset += 1;
1235     fi = proto_tree_add_text(tree, tvb, offset, elm_len, "Mobile Station Classmark3  %s", tvb_bytes_to_ep_str(tvb, offset, elm_len));
1236     ms_tree = proto_item_add_subtree(fi, ett_gtpv2_ms_mark);
1237     de_ms_cm_3(tvb, ms_tree, pinfo, offset, elm_len, NULL, 0);
1238     offset += elm_len;
1239
1240     /*Length of Supported Codec List  */
1241     elm_len = tvb_get_guint8(tvb, offset);
1242     proto_tree_add_item(tree, hf_gtpv2_len_supp_codec_list, tvb, offset, 1, ENC_BIG_ENDIAN);
1243     offset += 1;
1244     fi = proto_tree_add_text(tree, tvb, offset, elm_len, "Supported Codec List  %s", tvb_bytes_to_ep_str(tvb, offset, elm_len));
1245     ms_tree = proto_item_add_subtree(fi, ett_gtpv2_supp_codec_list);
1246     de_sup_codec_list(tvb, ms_tree, pinfo, offset, elm_len, NULL, 0);
1247
1248 }
1249
1250 /* 6.7 SRVCC Cause */
1251 static const value_string gtpv2_srvcc_cause_vals[] = {
1252     {0, "Reserved"},
1253     {1, "Unspecified"},
1254     {2, "Handover/Relocation cancelled by source system "},
1255     {3, "Handover /Relocation Failure with Target system"},
1256     {4, "Handover/Relocation Target not allowed"},
1257     {5, "Unknown Target ID"},
1258     {6, "Target Cell not available"},
1259     {7, "No Radio Resources Available in Target Cell"},
1260     {8, "Failure in Radio Interface Procedure"},
1261     {9, "Permanent session leg establishment error"},
1262     {10, "Temporary session leg establishment error"},
1263
1264     {0, NULL}
1265 };
1266 static value_string_ext gtpv2_srvcc_cause_vals_ext = VALUE_STRING_EXT_INIT(gtpv2_srvcc_cause_vals);
1267
1268 static void
1269 dissect_gtpv2_srvcc_cause(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
1270 {
1271     int    offset = 0;
1272     guint8 srvcc_cause;
1273
1274     srvcc_cause = tvb_get_guint8(tvb, offset);
1275     proto_tree_add_item(tree, hf_gtpv2_srvcc_cause, tvb, offset, 1, ENC_BIG_ENDIAN);
1276     proto_item_append_text(item, "%s (%u)", val_to_str_ext_const(srvcc_cause, &gtpv2_srvcc_cause_vals_ext, "Unknown"), srvcc_cause);
1277
1278 }
1279
1280 /*
1281  * 3GPP TS 29.280 version 10.3.0
1282  * 6.8 Target RNC ID
1283  */
1284 static void
1285 dissect_gtpv2_tgt_rnc_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
1286 {
1287     int         offset = 0;
1288     guint16     rnc_id;
1289     proto_tree *subtree;
1290     proto_item *rai_item;
1291     guint32     mcc;
1292     guint32     mnc;
1293     guint32     lac;
1294     guint32     curr_offset;
1295
1296     /*ra_type_flag = 1;*/ /*Flag to be set to differentiate GERAN and UTRAN*/
1297     curr_offset = offset;
1298
1299     mcc  = (tvb_get_guint8(tvb, curr_offset)   & 0x0f) << 8;
1300     mcc |= (tvb_get_guint8(tvb, curr_offset)   & 0xf0);
1301     mcc |= (tvb_get_guint8(tvb, curr_offset+1) & 0x0f);
1302     mnc  = (tvb_get_guint8(tvb, curr_offset+2) & 0x0f) << 8;
1303     mnc |= (tvb_get_guint8(tvb, curr_offset+2) & 0xf0);
1304     mnc |= (tvb_get_guint8(tvb, curr_offset+1) & 0xf0) >> 4;
1305     if ((mnc & 0x000f) == 0x000f)
1306         mnc = mnc >> 4;
1307
1308     lac = tvb_get_ntohs(tvb, curr_offset + 3);
1309     rnc_id = tvb_get_ntohs(tvb,  curr_offset + 5);
1310
1311     rai_item = proto_tree_add_text(tree,
1312                                    tvb, curr_offset, 6,
1313                                    "Routing area identification: %x-%x-%u-%u",
1314                                    mcc, mnc, lac, rnc_id);
1315
1316     subtree = proto_item_add_subtree(rai_item, ett_gtpv2_rai);
1317     dissect_e212_mcc_mnc(tvb, pinfo, subtree, offset, TRUE);
1318     curr_offset+=3;
1319
1320     proto_tree_add_item(subtree, hf_gtpv2_lac,    tvb, curr_offset, 2, ENC_BIG_ENDIAN);
1321     curr_offset+=2;
1322     proto_tree_add_item(subtree, hf_gtpv2_rnc_id, tvb, curr_offset, 2, ENC_BIG_ENDIAN);
1323     /*curr_offset+=2;*/
1324
1325     /* no length check possible */
1326
1327
1328 }
1329
1330 /*
1331  * 3GPP TS 29.280
1332  * 6.9 Target Global Cell ID
1333  * The encoding of this IE is defined in 3GPP TS 29.002
1334  *  GlobalCellId ::= OCTET STRING (SIZE (5..7))
1335  *      -- Refers to Cell Global Identification defined in TS 3GPP TS 23.003 [17].
1336  *      -- The internal structure is defined as follows:
1337  *      -- octet 1 bits 4321    Mobile Country Code 1st digit
1338  *      --         bits 8765    Mobile Country Code 2nd digit
1339  *      -- octet 2 bits 4321    Mobile Country Code 3rd digit
1340  *      --         bits 8765    Mobile Network Code 3rd digit
1341  *      --                      or filler (1111) for 2 digit MNCs
1342  *      -- octet 3 bits 4321    Mobile Network Code 1st digit
1343  *      --         bits 8765    Mobile Network Code 2nd digit
1344  *      -- octets 4 and 5       Location Area Code according to TS 3GPP TS 24.008 [35]
1345  *      -- octets 6 and 7       Cell Identity (CI) according to TS 3GPP TS 24.008 [35]
1346  */
1347 static void
1348 dissect_gtpv2_tgt_global_cell_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
1349 {
1350     int         offset = 0;
1351     guint8      tgt_cell_id;
1352     proto_tree *subtree;
1353     proto_item *rai_item;
1354     guint32     mcc;
1355     guint32     mnc;
1356     guint32     lac;
1357     guint32     curr_offset;
1358
1359     curr_offset = offset;
1360
1361     mcc  = (tvb_get_guint8(tvb, curr_offset)   & 0x0f) << 8;
1362     mcc |= (tvb_get_guint8(tvb, curr_offset)   & 0xf0);
1363     mcc |= (tvb_get_guint8(tvb, curr_offset+1) & 0x0f);
1364     mnc  = (tvb_get_guint8(tvb, curr_offset+2) & 0x0f) << 8;
1365     mnc |= (tvb_get_guint8(tvb, curr_offset+2) & 0xf0);
1366     mnc |= (tvb_get_guint8(tvb, curr_offset+1) & 0xf0) >> 4;
1367     if ((mnc & 0x000f) == 0x000f)
1368         mnc = mnc >> 4;
1369
1370     lac = tvb_get_ntohs(tvb, curr_offset + 3);
1371     tgt_cell_id = tvb_get_guint8(tvb,  curr_offset + 5);
1372
1373     rai_item = proto_tree_add_text(tree,
1374                                    tvb, curr_offset, 6,
1375                                    "Routing area identification: %x-%x-%u-%u",
1376                                    mcc, mnc, lac, tgt_cell_id);
1377
1378     subtree = proto_item_add_subtree(rai_item, ett_gtpv2_rai);
1379     dissect_e212_mcc_mnc(tvb, pinfo, subtree, offset, TRUE);
1380
1381     proto_tree_add_item(subtree, hf_gtpv2_lac,           tvb, curr_offset + 3, 2, ENC_BIG_ENDIAN);
1382     proto_tree_add_item(subtree, hf_gtpv2_tgt_g_cell_id, tvb, curr_offset + 5, 2, ENC_BIG_ENDIAN);
1383
1384     proto_item_append_text(item, "%x-%x-%u-%u", mcc, mnc, lac, tgt_cell_id);
1385     /* no length check possible */
1386
1387 }
1388
1389 /* 6.10 Tunnel Endpoint Identifier for Control Plane (TEID-C) */
1390 static void
1391 dissect_gtpv2_teid_c(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
1392 {
1393     int offset = 0;
1394
1395     proto_tree_add_item(tree, hf_gtpv2_teid_c, tvb, offset, 4, ENC_BIG_ENDIAN);
1396     offset += 4;
1397     if (length > 4)
1398         proto_tree_add_text(tree, tvb, offset, length-4, "Spare: %s", tvb_bytes_to_ep_str(tvb, offset, length-4));
1399
1400     proto_item_append_text(item, "%u", tvb_get_ntohl(tvb, offset-4));
1401 }
1402
1403 /* 6.11 Sv Flags */
1404 static void
1405 dissect_gtpv2_sv_flags(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
1406 {
1407     int offset = 0;
1408     proto_tree_add_item(tree, hf_gtpv2_sv_sti, tvb, offset, 1, ENC_BIG_ENDIAN);
1409     proto_tree_add_item(tree, hf_gtpv2_sv_ics, tvb, offset, 1, ENC_BIG_ENDIAN);
1410     proto_tree_add_item(tree, hf_gtpv2_sv_emind, tvb, offset, 1, ENC_BIG_ENDIAN);
1411     offset += 1;
1412     if (length > 1)
1413         proto_tree_add_text(tree, tvb, offset, length-1, "Spare: %s", tvb_bytes_to_ep_str(tvb, offset, length-1));
1414 }
1415
1416 /* 6.12 Service Area Identifier */
1417
1418 static void
1419 dissect_gtpv2_sai(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
1420 {
1421     int offset = 0;
1422
1423     /* 5 MCC digit 2 MCC digit 1
1424      * 6 MNC digit 3 MCC digit 3
1425      * 7 MNC digit 2 MNC digit 1
1426      */
1427     dissect_e212_mcc_mnc(tvb, pinfo, tree, offset, TRUE);
1428     offset += 3;
1429
1430     /* The Location Area Code (LAC) consists of 2 octets. Bit 8 of Octet 8 is the most significant bit and bit 1 of Octet 9 the
1431      * least significant bit. The coding of the location area code is the responsibility of each administration. Coding using full
1432      * hexadecimal representation shall be used.
1433      */
1434     proto_tree_add_item(tree, hf_gtpv2_lac, tvb, offset, 2, ENC_BIG_ENDIAN);
1435     offset += 2;
1436
1437     /* The Service Area Code (SAC) consists of 2 octets. Bit 8 of Octet 10 is the most significant bit and bit 1 of Octet 11 the
1438      * least significant bit. The SAC is defined by the operator. See 3GPP TS 23.003 [4] subclause 12.5 for more information
1439      */
1440     proto_tree_add_item(tree, hf_gtpv2_sac, tvb, offset, 2, ENC_BIG_ENDIAN);
1441 }
1442
1443 /*End SRVCC Messages*/
1444
1445
1446 /*
1447  * 8.6 Access Point Name (APN)
1448  * The encoding the APN field follows 3GPP TS 23.003 [2] subclause 9.1.
1449  * The content of the APN field shall be the full APN with both the APN Network Identifier
1450  * and APN Operator Identifier being present as specified in 3GPP TS 23.003 [2]
1451  * subclauses 9.1.1 and 9.1.2, 3GPP TS 23.060 [35] Annex A and 3GPP TS 23.401 [3] subclauses 4.3.8.1.
1452  */
1453 static void
1454 dissect_gtpv2_apn(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length, guint8 message_type _U_, guint8 instance _U_)
1455 {
1456     int     offset = 0;
1457     guint8 *apn    = NULL;
1458     int     name_len, tmp;
1459
1460     if (length > 0) {
1461         name_len = tvb_get_guint8(tvb, offset);
1462
1463         if (name_len < 0x20) {
1464             apn = tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, length - 1, ENC_ASCII);
1465             for (;;) {
1466                 if (name_len >= length - 1)
1467                     break;
1468                 tmp = name_len;
1469                 name_len = name_len + apn[tmp] + 1;
1470                 apn[tmp] = '.';
1471             }
1472         } else{
1473             apn = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_ASCII);
1474         }
1475         proto_tree_add_string(tree, hf_gtpv2_apn, tvb, offset, length, apn);
1476     }
1477
1478     if (apn)
1479         proto_item_append_text(item, "%s", apn);
1480
1481 }
1482
1483 /*
1484  * 8.7 Aggregate Maximum Bit Rate (AMBR)
1485  */
1486
1487 static void
1488 dissect_gtpv2_ambr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
1489 {
1490     int offset = 0;
1491
1492     proto_tree_add_item(tree, hf_gtpv2_ambr_up, tvb, offset, 4, ENC_BIG_ENDIAN);
1493     offset += 4;
1494     proto_tree_add_item(tree, hf_gtpv2_ambr_down, tvb, offset, 4, ENC_BIG_ENDIAN);
1495 }
1496
1497 /*
1498  * 8.8 EPS Bearer ID (EBI)
1499  */
1500 static void
1501 dissect_gtpv2_ebi(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
1502 {
1503
1504     int    offset = 0;
1505     guint8 ebi;
1506
1507     /* Spare (all bits set to 0) B8 - B5*/
1508     proto_tree_add_bits_item(tree, hf_gtpv2_spare_bits, tvb, offset, 4, ENC_BIG_ENDIAN);
1509     /* EPS Bearer ID (EBI) B4 - B1 */
1510     ebi = tvb_get_guint8(tvb, offset);
1511     proto_tree_add_item(tree, hf_gtpv2_ebi, tvb, offset, 1, ENC_BIG_ENDIAN);
1512     proto_item_append_text(item, "%u", ebi);
1513
1514 }
1515 /*
1516  * 8.9 IP Address
1517  */
1518 static void
1519 dissect_gtpv2_ip_address(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length, guint8 message_type _U_, guint8 instance _U_)
1520 {
1521     int               offset = 0;
1522     struct e_in6_addr ipv6_address;
1523
1524     if (length == 4)
1525     {
1526         proto_tree_add_item(tree, hf_gtpv2_ip_address_ipv4, tvb, offset, length, ENC_BIG_ENDIAN);
1527         proto_item_append_text(item, "IPv4 %s", tvb_ip_to_str(tvb, offset));
1528     }
1529     else if (length == 16)
1530     {
1531         proto_tree_add_item(tree, hf_gtpv2_ip_address_ipv6, tvb, offset, length, ENC_NA);
1532         tvb_get_ipv6(tvb, offset, &ipv6_address);
1533         proto_item_append_text(item, "IPv6 %s", ip6_to_str(&ipv6_address));
1534     }
1535 }
1536 /*
1537  * 8.10 Mobile Equipment Identity (MEI)
1538  * The ME Identity field contains either the IMEI or the IMEISV
1539  * as defined in clause 6.2 of 3GPP TS 23.003 [2]. It is encoded
1540  * as specified in clause 7.7.53 of 3GPP TS 29.060 [4], beginning
1541  * with octet 4 of Figure 7.7.53.1. The IMEI(SV) digits are encoded
1542  * using BCD coding where IMEI is 15 BCD digits and IMEISV is 16 BCD
1543  * digits. For IMEI, bits 5 to 8 of the last octet shall be filled
1544  * with an end mark coded as '1111'.
1545  */
1546
1547 static void
1548 dissect_gtpv2_mei(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length, guint8 message_type _U_, guint8 instance _U_)
1549 {
1550     int          offset = 0;
1551     const gchar *mei_str;
1552
1553     /* Fetch the BCD encoded digits from tvb low half byte, formating the digits according to
1554      * a default digit set of 0-9 returning "?" for overdecadic digits a pointer to the EP
1555      * allocated string will be returned.
1556      */
1557     mei_str = tvb_bcd_dig_to_wmem_packet_str( tvb, 0, length, NULL, FALSE);
1558
1559     proto_tree_add_string(tree, hf_gtpv2_mei, tvb, offset, length, mei_str);
1560     proto_item_append_text(item, "%s", mei_str);
1561 }
1562
1563 /*
1564  * 8.11 MSISDN
1565  *
1566  * MSISDN is defined in 3GPP TS 23.003
1567  * Editor's note: MSISDN coding will be defined in TS 24.301.
1568  */
1569 static void
1570 dissect_gtpv2_msisdn(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length, guint8 message_type _U_, guint8 instance _U_)
1571 {
1572     const char *digit_str;
1573
1574     /* Octets 5 to (n+4) represent the MSISDN value is in international number format
1575      * as described in ITU-T Rec E.164 [25] and 3GPP TS 29.002 [41].
1576      * MSISDN value contains only the actual MSISDN number (does not contain the "nature of
1577      * address indicator" octet, which indicates "international number"
1578      * as in 3GPP TS 29.002 [41]) and is encoded as TBCD digits, i.e.
1579      * digits from 0 through 9 are encoded "0000" to "1001".
1580      * When there is an odd number of digits, bits 8 to 5 of the last octet are encoded with
1581      * the filler "1111".
1582      */
1583     dissect_e164_cc(tvb, tree, 0, TRUE);
1584     /* Fetch the BCD encoded digits from tvb low half byte, formating the digits according to
1585      * a default digit set of 0-9 returning "?" for overdecadic digits a pointer to the EP
1586      * allocated string will be returned.
1587      */
1588     digit_str = tvb_bcd_dig_to_wmem_packet_str( tvb, 0, length, NULL, FALSE);
1589
1590     proto_tree_add_string(tree, hf_gtpv2_address_digits, tvb, 0, length, digit_str);
1591     proto_item_append_text(item, "%s", digit_str);
1592 }
1593
1594 /*
1595  * 8.12 Indication
1596  */
1597 static void
1598 dissect_gtpv2_ind(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
1599 {
1600     int offset = 0;
1601     /* Octet 5 DAF DTF HI DFI OI ISRSI ISRAI SGWCI */
1602     proto_tree_add_item(tree, hf_gtpv2_daf,         tvb, offset, 1, ENC_BIG_ENDIAN);
1603     proto_tree_add_item(tree, hf_gtpv2_dtf,         tvb, offset, 1, ENC_BIG_ENDIAN);
1604     proto_tree_add_item(tree, hf_gtpv2_hi,          tvb, offset, 1, ENC_BIG_ENDIAN);
1605     proto_tree_add_item(tree, hf_gtpv2_dfi,         tvb, offset, 1, ENC_BIG_ENDIAN);
1606     proto_tree_add_item(tree, hf_gtpv2_oi,          tvb, offset, 1, ENC_BIG_ENDIAN);
1607     proto_tree_add_item(tree, hf_gtpv2_isrsi,       tvb, offset, 1, ENC_BIG_ENDIAN);
1608     proto_tree_add_item(tree, hf_gtpv2_israi,       tvb, offset, 1, ENC_BIG_ENDIAN);
1609     proto_tree_add_item(tree, hf_gtpv2_sgwci,       tvb, offset, 1, ENC_BIG_ENDIAN);
1610
1611     if (length == 1) {
1612         proto_tree_add_text(tree, tvb, 0, length, "Older version?, should be 2 octets in 8.0.0");
1613         return;
1614     }
1615
1616     offset += 1;
1617
1618     /* Octet 6 SQCI UIMSI CFSI CRSI P PT SI MSV
1619      * 3GPP TS 29.274 version 9.4.0 Release 9
1620      */
1621     proto_tree_add_item(tree, hf_gtpv2_sqci,          tvb, offset, 1, ENC_BIG_ENDIAN);
1622     proto_tree_add_item(tree, hf_gtpv2_uimsi,         tvb, offset, 1, ENC_BIG_ENDIAN);
1623     proto_tree_add_item(tree, hf_gtpv2_cfsi,          tvb, offset, 1, ENC_BIG_ENDIAN);
1624     proto_tree_add_item(tree, hf_gtpv2_crsi,          tvb, offset, 1, ENC_BIG_ENDIAN);
1625
1626     proto_tree_add_item(tree, hf_gtpv2_ps,          tvb, offset, 1, ENC_BIG_ENDIAN);
1627     proto_tree_add_item(tree, hf_gtpv2_pt,          tvb, offset, 1, ENC_BIG_ENDIAN);
1628     proto_tree_add_item(tree, hf_gtpv2_si,          tvb, offset, 1, ENC_BIG_ENDIAN);
1629     proto_tree_add_item(tree, hf_gtpv2_msv,         tvb, offset, 1, ENC_BIG_ENDIAN);
1630     offset += 1;
1631
1632     if (length == 2) {
1633         return;
1634     }
1635     /* Only present in version 9 and higher */
1636     /* Octet 7 Spare Spare Spare Spare Spare Spare Spare CCRSI */
1637     proto_tree_add_item(tree, hf_gtpv2_spare1,          tvb, offset, 1, ENC_BIG_ENDIAN);
1638     proto_tree_add_item(tree, hf_gtpv2_spare2,          tvb, offset, 1, ENC_BIG_ENDIAN);
1639     proto_tree_add_item(tree, hf_gtpv2_spare3,          tvb, offset, 1, ENC_BIG_ENDIAN);
1640     proto_tree_add_item(tree, hf_gtpv2_s6af,            tvb, offset, 1, ENC_BIG_ENDIAN);
1641     proto_tree_add_item(tree, hf_gtpv2_s4af,            tvb, offset, 1, ENC_BIG_ENDIAN);
1642     proto_tree_add_item(tree, hf_gtpv2_mbmdt,           tvb, offset, 1, ENC_BIG_ENDIAN);
1643     proto_tree_add_item(tree, hf_gtpv2_israu,           tvb, offset, 1, ENC_BIG_ENDIAN);
1644     proto_tree_add_item(tree, hf_gtpv2_ccrsi,           tvb, offset, 1, ENC_BIG_ENDIAN);
1645
1646
1647 }
1648
1649 /*
1650  * 8.13 Protocol Configuration Options (PCO)
1651  * Protocol Configuration Options (PCO) is transferred via GTP tunnels. The sending entity copies the value part of the
1652  * PCO into the Value field of the PCO IE. The detailed coding of the PCO field from octets 5 to (n+4) shall be specified
1653  * as per clause 10.5.6.3 of 3GPP TS 24.008 [5], starting with octet 3.
1654  * Dissected in packet-gsm_a_gm.c
1655  */
1656 static void
1657 dissect_gtpv2_pco(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
1658 {
1659     switch (message_type) {
1660     case GTPV2_CREATE_SESSION_REQUEST:
1661         /* PCO options as MS to network direction */
1662         pinfo->link_dir = P2P_DIR_UL;
1663         break;
1664     case GTPV2_CREATE_SESSION_RESPONSE:
1665         /* PCO options as Network to MS direction: */
1666         pinfo->link_dir = P2P_DIR_DL;
1667         break;
1668     default:
1669         break;
1670     }
1671     de_sm_pco(tvb, tree, pinfo, 0, length, NULL, 0);
1672 }
1673
1674 /*
1675  * 8.14 PDN Address Allocation (PAA)
1676  */
1677
1678 static const value_string gtpv2_pdn_type_vals[] = {
1679     {1, "IPv4"},
1680     {2, "IPv6"},
1681     {3, "IPv4/IPv6"},
1682     {0, NULL}
1683 };
1684
1685 static void
1686 dissect_gtpv2_paa(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
1687 {
1688     int    offset = 0;
1689     guint8 pdn_type;
1690
1691     pdn_type = tvb_get_guint8(tvb, offset);
1692     proto_tree_add_item(tree, hf_gtpv2_pdn_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1693     offset += 1;
1694     switch (pdn_type)
1695     {
1696     case 1:
1697         /* IPv4 */
1698         proto_tree_add_item(tree, hf_gtpv2_pdn_ipv4, tvb, offset, 4, ENC_BIG_ENDIAN);
1699         break;
1700     case 2:
1701         /* IPv6*/
1702         /* If PDN type value indicates IPv6, octet 6 contains the IPv6 Prefix Length.
1703          * Octets 7 through 22 contain an IPv6 Prefix and Interface Identifier.
1704          * Bit 8 of octet 7 represents the most significant bit of the IPv6 Prefix
1705          * and Interface Identifier and bit 1 of octet 22 the least significant bit.
1706          */
1707         proto_tree_add_item(tree, hf_gtpv2_pdn_ipv6_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1708         offset += 1;
1709         proto_tree_add_item(tree, hf_gtpv2_pdn_ipv6, tvb, offset, 16, ENC_NA);
1710         break;
1711     case 3:
1712         /* IPv4/IPv6 */
1713         /* If PDN type value indicates IPv4v6, octet 6 contains the IPv6 Prefix Length.
1714          * Octets 7 through 22 contain an IPv6 Prefix and Interface Identifier.
1715          * Bit 8 of octet 7 represents the most significant bit of the IPv6 Prefix
1716          * and Interface Identifier and bit 1 of octet 22 the least significant bit.
1717          * Octets 23 through 26 contain an IPv4 address. Bit 8 of octet 23 represents
1718          * the most significant bit of the IPv4 address and bit 1 of octet 26 the least
1719          * significant bit.
1720          */
1721         proto_tree_add_item(tree, hf_gtpv2_pdn_ipv6_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1722         offset += 1;
1723         proto_tree_add_item(tree, hf_gtpv2_pdn_ipv6, tvb, offset, 16, ENC_NA);
1724         offset += 16;
1725         proto_tree_add_item(tree, hf_gtpv2_pdn_ipv4, tvb, offset, 4, ENC_BIG_ENDIAN);
1726         break;
1727     default:
1728         break;
1729     }
1730 }
1731 /*
1732  * 8.15 Bearer Quality of Service (Bearer QoS)
1733  */
1734
1735 static void
1736 dissect_gtpv2_bearer_qos(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
1737 {
1738     int offset = 0;
1739     proto_tree_add_item(tree, hf_gtpv2_bearer_qos_pvi,       tvb, offset, 1, ENC_BIG_ENDIAN);
1740     proto_tree_add_item(tree, hf_gtpv2_bearer_qos_pl,        tvb, offset, 1, ENC_BIG_ENDIAN);
1741     proto_tree_add_item(tree, hf_gtpv2_bearer_qos_pci,       tvb, offset, 1, ENC_BIG_ENDIAN);
1742     offset += 1;
1743     proto_tree_add_item(tree, hf_gtpv2_bearer_qos_label_qci, tvb, offset, 1, ENC_BIG_ENDIAN);
1744     offset += 1;
1745     proto_tree_add_item(tree, hf_gtpv2_bearer_qos_mbr_up,    tvb, offset, 5, ENC_BIG_ENDIAN);
1746     offset += 5;
1747     proto_tree_add_item(tree, hf_gtpv2_bearer_qos_mbr_down,  tvb, offset, 5, ENC_BIG_ENDIAN);
1748     offset += 5;
1749     proto_tree_add_item(tree, hf_gtpv2_bearer_qos_gbr_up,    tvb, offset, 5, ENC_BIG_ENDIAN);
1750     offset += 5;
1751     proto_tree_add_item(tree, hf_gtpv2_bearer_qos_gbr_down,  tvb, offset, 5, ENC_BIG_ENDIAN);
1752 }
1753
1754 /*
1755  * 8.16 Flow Quality of Service (Flow QoS)
1756  */
1757
1758 static void
1759 dissect_gtpv2_flow_qos(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
1760 {
1761     int offset = 0;
1762     proto_tree_add_item(tree, hf_gtpv2_flow_qos_label_qci, tvb, offset, 1, ENC_BIG_ENDIAN);
1763     offset += 1;
1764     proto_tree_add_item(tree, hf_gtpv2_flow_qos_mbr_up,    tvb, offset, 5, ENC_BIG_ENDIAN);
1765     offset += 5;
1766     proto_tree_add_item(tree, hf_gtpv2_flow_qos_mbr_down,  tvb, offset, 5, ENC_BIG_ENDIAN);
1767     offset += 5;
1768     proto_tree_add_item(tree, hf_gtpv2_flow_qos_gbr_up,    tvb, offset, 5, ENC_BIG_ENDIAN);
1769     offset += 5;
1770     proto_tree_add_item(tree, hf_gtpv2_flow_qos_gbr_down,  tvb, offset, 5, ENC_BIG_ENDIAN);
1771 }
1772
1773 /*
1774  * 8.17 RAT Type
1775  */
1776 static const value_string gtpv2_rat_type_vals[] = {
1777     {0, "Reserved"},
1778     {1, "UTRAN"},
1779     {2, "GERAN"},
1780     {3, "WLAN"},
1781     {4, "GAN"},
1782     {5, "HSPA Evolution"},
1783     {6, "EUTRAN"},
1784     {7, "Virtual"},
1785     {0, NULL}
1786 };
1787 static value_string_ext gtpv2_rat_type_vals_ext = VALUE_STRING_EXT_INIT(gtpv2_rat_type_vals);
1788
1789
1790 static void
1791 dissect_gtpv2_rat_type(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
1792 {
1793     guint8 rat_type;
1794
1795     rat_type = tvb_get_guint8(tvb, 0);
1796     proto_tree_add_item(tree, hf_gtpv2_rat_type, tvb, 0, 1, ENC_BIG_ENDIAN);
1797     proto_item_append_text(item, "%s (%u)", val_to_str_ext_const(rat_type, &gtpv2_rat_type_vals_ext, "Unknown"), rat_type);
1798
1799 }
1800
1801 /*
1802  * 8.18 Serving Network
1803  */
1804 static void
1805 dissect_gtpv2_serv_net(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
1806 {
1807     gchar *mcc_mnc_str;
1808
1809     mcc_mnc_str = dissect_e212_mcc_mnc_wmem_packet_str(tvb, pinfo, tree, 0, TRUE);
1810     proto_item_append_text(item, "%s", mcc_mnc_str);
1811 }
1812
1813 /*
1814  * 8.19 EPS Bearer Level Traffic Flow Template (Bearer TFT)
1815  */
1816
1817 static void
1818 dissect_gtpv2_bearer_tft(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
1819 {
1820     /* The detailed coding of Traffic Aggregate
1821      * Description is specified in 3GPP TS 24.008 [5] ,
1822      * clause 10.5.6.12, beginning with octet 3..
1823      * Use the decoding in packet-gsm_a_gm.c
1824      */
1825     de_sm_tflow_temp(tvb, tree, pinfo, 0, length, NULL, 0);
1826
1827 }
1828  /* 8.20 Traffic Aggregate Description (TAD)
1829  */
1830 static void
1831 dissect_gtpv2_tad(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
1832 {
1833     /* The detailed coding of Traffic Aggregate
1834      * Description is specified in 3GPP TS 24.008 [5] ,
1835      * clause 10.5.6.12, beginning with octet 3..
1836      * Use the decoding in packet-gsm_a_gm.c
1837      */
1838     de_sm_tflow_temp(tvb, tree, pinfo, 0, length, NULL, 0);
1839 }
1840
1841 /*
1842  * 8.21 User Location Info (ULI)
1843  *
1844  * The flags ECGI, TAI, RAI, SAI and CGI in octed 5 indicate if the corresponding
1845  * fields are present in the IE or not. If one of these flags is set to "0",
1846  * the corresponding field is not present at all. The respective identities are defined in 3GPP
1847  * TS 23.003 [2].
1848  * Editor's Note: The definition of ECGI is missing in 3GPP TS 23.003 v8.1.0.
1849  * It can be found in 3GPP TS 36.413 v8.3.0, but it is expected that it will be moved
1850  * to 23.003 in a future version.
1851  */
1852
1853 static gchar*
1854 decode_gtpv2_uli(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 length, guint8 instance _U_, guint flags)
1855 {
1856     int         offset = 1;     /* flags are already dissected */
1857     proto_item *fi;
1858     proto_tree *part_tree;
1859     gchar      *mcc_mnc_str;
1860     gchar      *str = NULL;
1861
1862     /* 8.21.1 CGI field  */
1863     if (flags & GTPv2_ULI_CGI_MASK)
1864     {
1865         guint16 lac, ci;
1866
1867         proto_item_append_text(item, "CGI ");
1868         fi = proto_tree_add_text(tree, tvb, offset, 7, "Cell Global Identity (CGI)");
1869         part_tree = proto_item_add_subtree(fi, ett_gtpv2_uli_field);
1870         mcc_mnc_str = dissect_e212_mcc_mnc_wmem_packet_str(tvb, pinfo, part_tree, offset, TRUE);
1871         offset += 3;
1872         lac = tvb_get_ntohs(tvb, offset);
1873         proto_tree_add_item(part_tree, hf_gtpv2_uli_cgi_lac, tvb, offset, 2, ENC_BIG_ENDIAN);
1874         offset += 2;
1875         ci = tvb_get_ntohs(tvb, offset);
1876         proto_tree_add_item(part_tree, hf_gtpv2_uli_cgi_ci, tvb, offset, 2, ENC_BIG_ENDIAN);
1877         offset += 2;
1878         str = wmem_strdup_printf(wmem_packet_scope(), "%s, LAC 0x%x, CI 0x%x",
1879             mcc_mnc_str,
1880             lac,
1881             ci);
1882         if (offset == length)
1883             return str;
1884     }
1885
1886     /* 8.21.2 SAI field  */
1887     if (flags & GTPv2_ULI_SAI_MASK)
1888     {
1889         guint16 lac, sac;
1890
1891         proto_item_append_text(item, "SAI ");
1892         fi = proto_tree_add_text(tree, tvb, offset, 7, "Service Area Identity (SAI)");
1893         part_tree = proto_item_add_subtree(fi, ett_gtpv2_uli_field);
1894         mcc_mnc_str = dissect_e212_mcc_mnc_wmem_packet_str(tvb, pinfo, part_tree, offset, TRUE);
1895         offset += 3;
1896         lac = tvb_get_ntohs(tvb, offset);
1897         proto_tree_add_item(part_tree, hf_gtpv2_uli_sai_lac, tvb, offset, 2, ENC_BIG_ENDIAN);
1898         offset += 2;
1899         sac = tvb_get_ntohs(tvb, offset);
1900         proto_tree_add_item(part_tree, hf_gtpv2_uli_sai_sac, tvb, offset, 2, ENC_BIG_ENDIAN);
1901         offset += 2;
1902         str = wmem_strdup_printf(wmem_packet_scope(), "%s, LAC 0x%x, SAC 0x%x",
1903             mcc_mnc_str,
1904             lac,
1905             sac);
1906         if (offset == length)
1907             return str;
1908     }
1909     /* 8.21.3 RAI field  */
1910     if (flags & GTPv2_ULI_RAI_MASK)
1911     {
1912         guint16 lac, rac;
1913         proto_item_append_text(item, "RAI ");
1914         fi = proto_tree_add_text(tree, tvb, offset, 7, "Routeing Area Identity (RAI)");
1915         part_tree = proto_item_add_subtree(fi, ett_gtpv2_uli_field);
1916         mcc_mnc_str = dissect_e212_mcc_mnc_wmem_packet_str(tvb, pinfo, part_tree, offset, TRUE);
1917         offset += 3;
1918         lac = tvb_get_ntohs(tvb, offset);
1919         proto_tree_add_item(part_tree, hf_gtpv2_uli_rai_lac, tvb, offset, 2, ENC_BIG_ENDIAN);
1920         offset += 2;
1921         rac = tvb_get_ntohs(tvb, offset);
1922         proto_tree_add_item(part_tree, hf_gtpv2_uli_rai_rac, tvb, offset, 2, ENC_BIG_ENDIAN);
1923         offset += 2;
1924         str = wmem_strdup_printf(wmem_packet_scope(), "%s, LAC 0x%x, RAC 0x%x",
1925             mcc_mnc_str,
1926             lac,
1927             rac);
1928
1929         if (offset == length)
1930             return str;
1931     }
1932     /* 8.21.4 TAI field  */
1933     if (flags & GTPv2_ULI_TAI_MASK)
1934     {
1935         guint16 tac;
1936         proto_item_append_text(item, "TAI ");
1937         fi = proto_tree_add_text(tree, tvb, offset, 5, "Tracking Area Identity (TAI)");
1938         part_tree = proto_item_add_subtree(fi, ett_gtpv2_uli_field);
1939         mcc_mnc_str = dissect_e212_mcc_mnc_wmem_packet_str(tvb, pinfo, part_tree, offset, TRUE);
1940         offset += 3;
1941         tac = tvb_get_ntohs(tvb, offset);
1942         proto_tree_add_item(part_tree, hf_gtpv2_uli_tai_tac, tvb, offset, 2, ENC_BIG_ENDIAN);
1943         offset += 2;
1944         str = wmem_strdup_printf(wmem_packet_scope(), "%s, TAC 0x%x",
1945             mcc_mnc_str,
1946             tac);
1947         if (offset == length)
1948             return str;
1949     }
1950     /* 8.21.5 ECGI field */
1951     if (flags & GTPv2_ULI_ECGI_MASK)
1952     {
1953         guint8 octet;
1954         guint32 octet4;
1955         guint8 spare;
1956         guint32 ECGI;
1957
1958         proto_item_append_text(item, "ECGI ");
1959         fi = proto_tree_add_text(tree, tvb, offset, 7, "E-UTRAN Cell Global Identifier (ECGI)");
1960         part_tree = proto_item_add_subtree(fi, ett_gtpv2_uli_field);
1961         mcc_mnc_str = dissect_e212_mcc_mnc_wmem_packet_str(tvb, pinfo, part_tree, offset, TRUE);
1962         offset += 3;
1963         /* The bits 8 through 5, of octet e+3 (Fig 8.21.5-1 in TS 29.274 V8.2.0) are spare
1964          * and hence they would not make any difference to the hex string following it,
1965          * thus we directly read 4 bytes from the tvb
1966          */
1967
1968         octet = tvb_get_guint8(tvb, offset);
1969         spare = octet & 0xF0;
1970         octet4 = tvb_get_ntohl(tvb, offset);
1971         ECGI = octet4 & 0x0FFFFFFF;
1972         proto_tree_add_uint(part_tree, hf_gtpv2_uli_ecgi_eci_spare, tvb, offset, 1, spare);
1973         /* The coding of the E-UTRAN cell identifier is the responsibility of each administration.
1974          * Coding using full hexadecimal representation shall be used.
1975          */
1976         proto_tree_add_uint(part_tree, hf_gtpv2_uli_ecgi_eci, tvb, offset, 4, ECGI);
1977         /*proto_tree_add_item(tree, hf_gtpv2_uli_ecgi_eci, tvb, offset, 4, ENC_BIG_ENDIAN);*/
1978         offset += 4;
1979         str = wmem_strdup_printf(wmem_packet_scope(), "%s, ECGI 0x%x",
1980             mcc_mnc_str,
1981             ECGI);
1982
1983         if (offset == length)
1984             return str;
1985
1986     }
1987     /* 8.21.6  LAI field */
1988     if (flags & GTPv2_ULI_LAI_MASK)
1989     {
1990         guint16 lac;
1991         proto_item_append_text(item, "LAI ");
1992         fi = proto_tree_add_text(tree, tvb, offset, 5, "LAI (Location Area Identifier)");
1993         part_tree = proto_item_add_subtree(fi, ett_gtpv2_uli_field);
1994         mcc_mnc_str = dissect_e212_mcc_mnc_wmem_packet_str(tvb, pinfo, part_tree, offset, TRUE);
1995         offset += 3;
1996
1997         /* The Location Area Code (LAC) consists of 2 octets. Bit 8 of Octet f+3 is the most significant bit
1998          * and bit 1 of Octet f+4 the least significant bit. The coding of the location area code is the
1999          * responsibility of each administration. Coding using full hexadecimal representation shall be used.
2000          */
2001         proto_tree_add_item(part_tree, hf_gtpv2_uli_lai_lac, tvb, offset, 2, ENC_BIG_ENDIAN);
2002         lac = tvb_get_ntohs(tvb, offset);
2003         str = wmem_strdup_printf(wmem_packet_scope(), "%s, LAC 0x%x",
2004             mcc_mnc_str,
2005             lac);
2006
2007     }
2008
2009     return str;
2010
2011 }
2012
2013 static void
2014 dissect_gtpv2_uli(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 length, guint8 message_type _U_, guint8 instance _U_)
2015 {
2016     proto_item *flags_item;
2017     proto_tree *flag_tree;
2018     int         offset = 0;
2019     guint       flags;
2020
2021     flags_item = proto_tree_add_text(tree, tvb, offset, 1, "Flags");
2022     flag_tree = proto_item_add_subtree(flags_item, ett_gtpv2_uli_flags);
2023     flags = tvb_get_guint8(tvb, offset) & 0x3f;
2024     proto_tree_add_bits_item(flag_tree, hf_gtpv2_spare_bits, tvb, offset >> 3, 2, ENC_BIG_ENDIAN);
2025
2026     /* LAI B6 */
2027     proto_tree_add_item(flag_tree, hf_gtpv2_uli_lai_flg, tvb, offset, 1, ENC_BIG_ENDIAN);
2028     /* ECGI B5 */
2029     proto_tree_add_item(flag_tree, hf_gtpv2_uli_ecgi_flg, tvb, offset, 1, ENC_BIG_ENDIAN);
2030     /* TAI B4  */
2031     proto_tree_add_item(flag_tree, hf_gtpv2_uli_tai_flg, tvb, offset, 1, ENC_BIG_ENDIAN);
2032     /* RAI B3  */
2033     proto_tree_add_item(flag_tree, hf_gtpv2_uli_rai_flg, tvb, offset, 1, ENC_BIG_ENDIAN);
2034     /* SAI B2  */
2035     proto_tree_add_item(flag_tree, hf_gtpv2_uli_sai_flg, tvb, offset, 1, ENC_BIG_ENDIAN);
2036     /* CGI B1  */
2037     proto_tree_add_item(flag_tree, hf_gtpv2_uli_cgi_flg, tvb, offset, 1, ENC_BIG_ENDIAN);
2038
2039     decode_gtpv2_uli(tvb, pinfo, tree, item, length, instance, flags);
2040
2041     return;
2042 }
2043
2044 /* Diameter 3GPP AVP Code: 22 3GPP-User-Location-Info */
2045 /*
2046  * TS 29.061 v9.2.0
2047  * 16.4.7.2 Coding 3GPP Vendor-Specific RADIUS attributes
2048  *
2049  * For P-GW, the Geographic Location Type values and coding are defined as follows:
2050  *
2051  * 0        CGI
2052  * 1        SAI
2053  * 2        RAI
2054  * 3-127    Spare for future use
2055  * 128      TAI
2056  * 129      ECGI
2057  * 130      TAI and ECGI
2058  * 131-255  Spare for future use
2059  */
2060
2061
2062 static const value_string geographic_location_type_vals[] = {
2063     {0,   "CGI"},
2064     {1,   "SAI"},
2065     {2,   "RAI"},
2066     {128, "TAI"},
2067     {129, "ECGI"},
2068     {130, "TAI and ECGI"},
2069     {0, NULL}
2070 };
2071
2072 static int
2073 dissect_diameter_3gpp_uli(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
2074 {
2075     diam_sub_dis_t *diam_sub_dis = (diam_sub_dis_t*)data;
2076     int   offset = 0;
2077     guint length;
2078     guint flags;
2079     guint flags_3gpp;
2080     length       = tvb_length(tvb);
2081     flags_3gpp   = tvb_get_guint8(tvb, offset);
2082
2083     proto_tree_add_item(tree, hf_gtpv2_glt, tvb, offset, 1, ENC_BIG_ENDIAN);
2084
2085     switch (flags_3gpp)
2086     {
2087     case 0:
2088         /* CGI */
2089         flags = GTPv2_ULI_CGI_MASK;
2090         break;
2091     case 1:
2092         /* SAI */
2093         flags = GTPv2_ULI_SAI_MASK;
2094         break;
2095     case 2:
2096         /* RAI */
2097         flags = GTPv2_ULI_RAI_MASK;
2098         break;
2099     case 128:
2100         /* TAI */
2101         flags = GTPv2_ULI_TAI_MASK;
2102         break;
2103     case 129:
2104         /* ECGI */
2105         flags = GTPv2_ULI_ECGI_MASK;
2106         break;
2107     case 130:
2108         /* TAI and ECGI */
2109         flags = GTPv2_ULI_TAI_MASK + GTPv2_ULI_ECGI_MASK;
2110         break;
2111     default:
2112         proto_tree_add_text(tree, tvb, 1, -1, "Geographic Location");
2113         return length;
2114     }
2115
2116     diam_sub_dis->avp_str = decode_gtpv2_uli(tvb, pinfo, tree, NULL, length, 0, flags);
2117     return length;
2118 }
2119
2120 /*
2121  * 8.22 Fully Qualified TEID (F-TEID)
2122  */
2123 static const value_string gtpv2_f_teid_interface_type_vals[] = {
2124     { 0, "S1-U eNodeB GTP-U interface"},
2125     { 1, "S1-U SGW GTP-U interface"},
2126     { 2, "S12 RNC GTP-U interface"},
2127     { 3, "S12 SGW GTP-U interface"},
2128     { 4, "S5/S8 SGW GTP-U interface"},
2129     { 5, "S5/S8 PGW GTP-U interface"},
2130     { 6, "S5/S8 SGW GTP-C interface"},
2131     { 7, "S5/S8 PGW GTP-C interface"},
2132     { 8, "S5/S8 SGW PMIPv6 interface"}, /* (the 32 bit GRE key is encoded in 32 bit TEID field "
2133          "and since alternate CoA is not used the control plane and user plane addresses are the same for PMIPv6)"}, */
2134     { 9, "S5/S8 PGW PMIPv6 interface"}, /* (the 32 bit GRE key is encoded in 32 bit TEID field "
2135          "and the control plane and user plane addresses are the same for PMIPv6)"}, */
2136     {10, "S11 MME GTP-C interface"},
2137     {11, "S11/S4 SGW GTP-C interface"},
2138     {12, "S10 MME GTP-C interface"},
2139     {13, "S3 MME GTP-C interface"},
2140     {14, "S3 SGSN GTP-C interface"},
2141     {15, "S4 SGSN GTP-U interface"},
2142     {16, "S4 SGW GTP-U interface"},
2143     {17, "S4 SGSN GTP-C interface"},
2144     {18, "S16 SGSN GTP-C interface"},
2145     {19, "eNodeB GTP-U interface for DL data forwarding"},
2146     {20, "eNodeB GTP-U interface for UL data forwarding"},
2147     {21, "RNC GTP-U interface for data forwarding"},
2148     {22, "SGSN GTP-U interface for data forwarding"},
2149     {23, "SGW GTP-U interface for data forwarding"},
2150     {24, "Sm MBMS GW GTP-C interface"},
2151     {25, "Sn MBMS GW GTP-C interface"},
2152     {26, "Sm MME GTP-C interface"},
2153     {27, "Sn SGSN GTP-C interface"},
2154     {28, "SGW GTP-U interface for UL data forwarding"},
2155     {29, "Sn SGSN GTP-U interface"},
2156     {30, "S2b ePDG GTP-C interface"},
2157     {31, "S2b-U ePDG GTP-U interface"},
2158     {32, "S2b PGW GTP-C interface"},
2159     {33, "S2b-U PGW GTP-U interface"},
2160     {34, "S2a TWAN GTP-U interface"},
2161     {35, "S2a TWAN GTP-C interface"},
2162     {36, "S2a PGW GTP-C interface"},
2163     {37, "S2a PGW GTP-U interface"},
2164     {0, NULL}
2165 };
2166 static value_string_ext gtpv2_f_teid_interface_type_vals_ext = VALUE_STRING_EXT_INIT(gtpv2_f_teid_interface_type_vals);
2167
2168 static const true_false_string gtpv2_f_teid_v4_vals = {
2169     "IPv4 address present",
2170     "IPv4 address not present",
2171 };
2172
2173 static const true_false_string gtpv2_f_teid_v6_vals = {
2174     "IPv6 address present",
2175     "IPv6 address not present",
2176 };
2177
2178 static void
2179 dissect_gtpv2_f_teid(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
2180 {
2181     int    offset = 0;
2182     guint8 flags;
2183
2184     flags = tvb_get_guint8(tvb, offset);
2185     proto_tree_add_item(tree, hf_gtpv2_f_teid_v4, tvb, offset, 1, ENC_BIG_ENDIAN);
2186     proto_tree_add_item(tree, hf_gtpv2_f_teid_v6, tvb, offset, 1, ENC_BIG_ENDIAN);
2187     /* NOTE:  "Interface type" IE is defined with 5 bits only in the earlier releases of this specification,
2188      * thus pre-Rel-10 GTPv2-C nodes can ignore bit "6" which is marked as "Spare" in earlier releases,
2189      * allowing backward compatibility.
2190      */
2191     proto_tree_add_item(tree, hf_gtpv2_f_teid_interface_type, tvb, offset, 1, ENC_BIG_ENDIAN);
2192
2193     offset += 1;
2194     proto_tree_add_item(tree, hf_gtpv2_f_teid_gre_key, tvb, offset, 4, ENC_BIG_ENDIAN);
2195     proto_item_append_text(item, "%s, TEID/GRE Key: 0x%s",
2196                            val_to_str_ext_const((flags & 0x3f), &gtpv2_f_teid_interface_type_vals_ext, "Unknown"),
2197                            tvb_bytes_to_ep_str(tvb, offset, 4));
2198
2199     offset += 4;
2200     if (flags & 0x80)
2201     {
2202         proto_tree_add_item(tree, hf_gtpv2_f_teid_ipv4, tvb, offset, 4, ENC_BIG_ENDIAN);
2203         proto_item_append_text(item, ", IPv4 %s", tvb_ip_to_str(tvb, offset));
2204         offset += 4;
2205     }
2206     if (flags & 0x40)
2207     {
2208         proto_tree_add_item(tree, hf_gtpv2_f_teid_ipv6, tvb, offset, 16, ENC_NA);
2209         proto_item_append_text(item, ", IPv6 %s", tvb_ip6_to_str(tvb, offset));
2210     }
2211 }
2212 /*
2213  * 8.23 TMSI
2214  */
2215 static void
2216 dissect_gtpv2_tmsi(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length, guint8 message_type _U_, guint8 instance _U_)
2217 {
2218     proto_tree_add_item(tree, hf_gtpv2_tmsi, tvb, 0, 4, ENC_BIG_ENDIAN);
2219     proto_tree_add_text(item, tvb, 0, length, "TMSI: %s", tvb_bytes_to_ep_str(tvb, 0, 4));
2220 }
2221 /*
2222  * 8.24 Global CN-Id
2223  * (TS 23.003)
2224  * 12.3 CN Identifier
2225  *
2226  * A CN node is uniquely identified within a PLMN by its CN Identifier (CN-Id). The CN-Id together with the PLMN
2227  * identifier globally identifies the CN node. The CN-Id together with the PLMN-Id is used as the CN node identifier in
2228  * RANAP signalling over the Iu interface.
2229  * Global CN-Id = PLMN-Id || CN-Id
2230  * The CN-Id is defined by the operator, and set in the nodes via O&M.
2231  * For the syntax description and the use of this identifier in RANAP signalling, see 3GPP TS 25.413 [17].
2232  */
2233
2234 static void
2235 dissect_gtpv2_g_cn_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
2236 {
2237     int offset = 0;
2238
2239     dissect_e212_mcc_mnc(tvb, pinfo, tree, 0, TRUE);
2240     offset += 3;
2241
2242     /* >CN-ID M INTEGER (0..4095) */
2243     proto_tree_add_text(tree, tvb, offset, 2, "CN-Id: %s",
2244                         tvb_bytes_to_ep_str(tvb, offset, 2));
2245 }
2246 /*
2247  * 8.25 S103 PDN Data Forwarding Info (S103PDF)
2248  */
2249 static void
2250 dissect_gtpv2_s103pdf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
2251 {
2252     int         offset = 0;
2253     guint8      m, k, i;
2254
2255     /* The HSGW Address and GRE Key identify a GRE Tunnel towards a HSGW over S103 interface for a specific PDN
2256      * connection of the UE. The EPS Bearer IDs specify the EPS Bearers which require data forwarding that belonging to this
2257      * PDN connection. The number of EPS bearer Ids included is specified by the value of EPS Bearer ID Number.
2258      */
2259     /* Octet 5 HSGW Address for forwarding Length = m */
2260     m = tvb_get_guint8(tvb, offset);
2261     proto_tree_add_item(tree, hf_gtpv2_hsgw_addr_f_len, tvb, offset, 1, ENC_BIG_ENDIAN);
2262     offset += 1;
2263
2264     /* 6 to (m+5) HSGW Address for forwarding [4..16] */
2265     switch (m) {
2266     case 4:
2267         /* IPv4 */
2268         proto_tree_add_item(tree, hf_gtpv2_hsgw_addr_ipv4, tvb, offset, 1, ENC_BIG_ENDIAN);
2269         offset += 4;
2270         break;
2271     case 16:
2272         /* IPv6 */
2273         proto_tree_add_item(tree, hf_gtpv2_hsgw_addr_ipv6, tvb, offset, 1, ENC_NA);
2274         offset += 16;
2275         break;
2276     default:
2277         /* Error */
2278         proto_tree_add_expert_format(tree, pinfo, &ei_gtpv2_ie_len_invalid, tvb, 0, length,
2279                                      "Wrong length %u, should be 4 or 16", m);
2280         return;
2281     }
2282
2283     /* (m+6)- to (m+9) GRE Key */
2284     proto_tree_add_item(tree, hf_gtpv2_gre_key, tvb, offset, 4, ENC_BIG_ENDIAN);
2285     offset += 4;
2286
2287     /* (m+10) EPS Bearer ID Number = k */
2288     k = tvb_get_guint8(tvb, offset);
2289     proto_tree_add_text(tree, tvb, offset, 1, "EPS Bearer ID Number = %d", k);
2290     offset += 1;
2291
2292     /* (m+11) to (m+10+k)
2293      * Spare EPS Bearer ID
2294      */
2295     for ( i = 0; i < k; i++ ) {
2296         proto_tree_add_bits_item(tree, hf_gtpv2_spare_bits, tvb, offset << 3, 4, ENC_BIG_ENDIAN);
2297         proto_tree_add_item(tree, hf_gtpv2_ebi, tvb, offset, 1, ENC_BIG_ENDIAN);
2298         offset += 1;
2299     }
2300
2301 }
2302 /*
2303  * 8.26 S1-U Data Forwarding (S1UDF)
2304  */
2305 static void
2306 dissect_gtpv2_s1udf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
2307 {
2308     int         offset = 0;
2309     guint8      m;
2310
2311     /* 5 Spare EPS Bearer ID */
2312     proto_tree_add_bits_item(tree, hf_gtpv2_spare_bits, tvb, offset << 3, 4, ENC_BIG_ENDIAN);
2313     proto_tree_add_item(tree, hf_gtpv2_ebi, tvb, offset, 1, ENC_BIG_ENDIAN);
2314     offset += 1;
2315     /* 6 Serving GW Address Length = m */
2316     m = tvb_get_guint8(tvb, offset);
2317     proto_tree_add_text(tree, tvb, offset, 1, "Serving GW Address Length = %u", m);
2318     offset += 1;
2319     /* 7 to (m+6) Serving GW Address [4..16] */
2320     switch (m) {
2321     case 4:
2322         /* IPv4 */
2323         proto_tree_add_item(tree, hf_gtpv2_sgw_addr_ipv4, tvb, offset, 1, ENC_BIG_ENDIAN);
2324         offset += 4;
2325         break;
2326     case 16:
2327         /* IPv6 */
2328         proto_tree_add_item(tree, hf_gtpv2_sgw_addr_ipv6, tvb, offset, 1, ENC_NA);
2329         offset += 16;
2330         break;
2331     default:
2332         /* Error */
2333         proto_tree_add_expert_format(tree, pinfo, &ei_gtpv2_ie_len_invalid, tvb, 0, length,
2334                                      "Wrong length %u, should be 4 or 16", m);
2335         return;
2336     }
2337
2338     /* (m+7) to (m+10)
2339      * Serving GW S1-U TEID
2340      */
2341     proto_tree_add_item(tree, hf_gtpv2_sgw_s1u_teid, tvb, offset, 4, ENC_BIG_ENDIAN);
2342
2343 }
2344 /*
2345  * 8.27 Delay Value
2346  */
2347
2348 static void
2349 dissect_gtpv2_delay_value(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
2350 {
2351     int offset = 0;
2352
2353     proto_tree_add_item(tree, hf_gtpv2_delay_value, tvb, offset, 1, ENC_BIG_ENDIAN);
2354 }
2355
2356 /*
2357  * 8.28 Bearer Context (grouped IE)
2358  */
2359
2360 static void
2361 dissect_gtpv2_bearer_ctx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree _U_, proto_item *item, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
2362 {
2363     int         offset = 0;
2364     tvbuff_t   *new_tvb;
2365     proto_tree *grouped_tree;
2366
2367     proto_item_append_text(item, "[Grouped IE]");
2368     grouped_tree = proto_item_add_subtree(item, ett_gtpv2_bearer_ctx);
2369
2370     new_tvb = tvb_new_subset_length(tvb, offset, length);
2371     dissect_gtpv2_ie_common(new_tvb, pinfo, grouped_tree, 0, message_type);
2372 }
2373
2374 /* 8.29 Charging ID */
2375 static void
2376 dissect_gtpv2_charging_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
2377 {
2378     int offset = 0;
2379
2380     proto_tree_add_item(tree, hf_gtpv2_charging_id, tvb, offset, length, ENC_BIG_ENDIAN);
2381 }
2382
2383
2384  /* 8.30 Charging Characteristics
2385   * The charging characteristics information element is defined in 3GPP TS 32.251 [8]
2386   * and is a way of informing both the SGW and PGW of the rules for producing charging
2387   * information based on operator configured triggers. For the encoding of this
2388   * information element see 3GPP TS 32.298 [9].
2389   */
2390 static void
2391 dissect_gtpv2_char_char(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
2392 {
2393     int offset = 0;
2394
2395     proto_tree_add_item(tree, hf_gtpv2_charging_characteristic, tvb, offset, 2, ENC_BIG_ENDIAN);
2396     if (length > 2) {
2397         offset += 2;
2398         /* These octet(s) is/are present only if explicitly specified */
2399         proto_tree_add_text(tree, tvb, offset, length-2, "Remaining octets");
2400     }
2401
2402 }
2403
2404 /*
2405  * 8.30 Bearer Flag
2406  */
2407 static void
2408 dissect_gtpv2_bearer_flag(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
2409 {
2410
2411     int offset = 0;
2412
2413     /* Octet 5 Spare VB PPC */
2414     proto_tree_add_item(tree, hf_gtpv2_bearer_flag_ppc, tvb, offset, length, ENC_BIG_ENDIAN);
2415     proto_tree_add_item(tree, hf_gtpv2_bearer_flag_vb, tvb, offset, length, ENC_BIG_ENDIAN);
2416
2417 }
2418 /*
2419  * 8.34 PDN Type
2420  */
2421 static void
2422 dissect_gtpv2_pdn_type(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 length, guint8 message_type _U_, guint8 instance _U_)
2423 {
2424
2425     int offset = 0;
2426     guint8 pdn;
2427
2428     if (length != 1) {
2429         proto_tree_add_expert_format(tree, pinfo, &ei_gtpv2_ie_len_invalid, tvb, 0, length,
2430                                      "Wrong length indicated. Expected 1, got %u", length);
2431         return;
2432     }
2433
2434     proto_tree_add_bits_item(tree, hf_gtpv2_spare_bits, tvb, offset << 3, 5, ENC_BIG_ENDIAN);
2435     pdn = tvb_get_guint8(tvb, offset)& 0x7;
2436     proto_tree_add_item(tree, hf_gtpv2_pdn_type, tvb, offset, length, ENC_BIG_ENDIAN);
2437     proto_item_append_text(item, "%s", val_to_str_const(pdn, gtpv2_pdn_type_vals, "Unknown"));
2438
2439 }
2440
2441 /*
2442  * 8.31 Trace Information
2443  */
2444 static void
2445 dissect_gtpv2_tra_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 length, guint8 message_type _U_, guint8 instance _U_)
2446 {
2447     proto_item  *trigg, *msc_server, *mgw, *sgsn, *ggsn, *bm_sc, *sgw_mme, *ne_types;
2448     proto_tree  *trigg_tree, *msc_server_tree, *mgw_tree, *sgsn_tree, *ggsn_tree;
2449     proto_tree  *bm_sc_tree, *sgw_mme_tree, *ne_types_tree;
2450     proto_item  *interfaces, *imsc_server, *lmgw, *lsgsn, *lggsn, *lrnc, *lbm_sc, *lmme, *lsgw, *lpdn_gw, *lenb;
2451     proto_tree  *interfaces_tree, *imsc_server_tree, *lmgw_tree, *lsgsn_tree, *lggsn_tree, *lrnc_tree;
2452     proto_tree  *lbm_sc_tree, *lmme_tree, *lsgw_tree, *lpdn_gw_tree, *lenb_tree;
2453
2454     int         offset = 0;
2455 #if 0
2456     guint8      *trace_id = NULL;
2457 #endif
2458     guint8      tdl;
2459     guint16     tid;
2460     guint32     bit_offset;
2461
2462     dissect_e212_mcc_mnc(tvb, pinfo, tree, 0, TRUE);
2463     offset += 3;
2464
2465     /* Append Trace ID to main tree */
2466     tid = tvb_get_ntohs(tvb, offset);
2467     proto_item_append_text(item, "Trace ID: %d  ", tid);
2468
2469     /* Trace ID */
2470     /*--------------------------------------------------
2471      * trace_id = tvb_format_text(tvb, offset, 2);
2472      * proto_tree_add_string(tree, hf_gtpv2_tra_info, tvb, offset, length, trace_id);
2473      *--------------------------------------------------*/
2474     proto_tree_add_text(tree, tvb, offset, 3, "Trace ID: %d", tid);
2475     offset += 3;
2476
2477     /* Triggering Events, put all into a new tree called trigging_tree */
2478     trigg = proto_tree_add_text(tree, tvb, offset, 8, "Trigging Events");
2479     trigg_tree = proto_item_add_subtree(trigg, ett_gtpv2_tra_info_trigg);
2480
2481     /* Create all subtrees */
2482     msc_server = proto_tree_add_text(trigg_tree, tvb, offset, 2, "MSC Server");
2483     msc_server_tree = proto_item_add_subtree(msc_server, ett_gtpv2_tra_info_trigg_msc_server);
2484
2485     mgw = proto_tree_add_text(trigg_tree, tvb, offset + 2, 1, "MGW");
2486     mgw_tree = proto_item_add_subtree(mgw, ett_gtpv2_tra_info_trigg_mgw);
2487
2488     sgsn = proto_tree_add_text(trigg_tree, tvb, offset + 3, 2, "SGSN");
2489     sgsn_tree = proto_item_add_subtree(sgsn, ett_gtpv2_tra_info_trigg_sgsn);
2490
2491     ggsn = proto_tree_add_text(trigg_tree, tvb, offset + 5, 1, "GGSN");
2492     ggsn_tree = proto_item_add_subtree(ggsn, ett_gtpv2_tra_info_trigg_ggsn);
2493
2494     bm_sc = proto_tree_add_text(trigg_tree, tvb, offset + 6, 1, "BM-SC");
2495     bm_sc_tree = proto_item_add_subtree(bm_sc, ett_gtpv2_tra_info_trigg_bm_sc);
2496
2497     sgw_mme = proto_tree_add_text(trigg_tree, tvb, offset + 7, 1, "SGW MME");
2498     sgw_mme_tree = proto_item_add_subtree(sgw_mme, ett_gtpv2_tra_info_trigg_sgw_mme);
2499
2500     /* MSC Server - 2 octets */
2501     proto_tree_add_item(msc_server_tree, hf_gtpv2_tra_info_msc_momt_calls,  tvb, offset, 1, ENC_BIG_ENDIAN);
2502     proto_tree_add_item(msc_server_tree, hf_gtpv2_tra_info_msc_momt_sms,    tvb, offset, 1, ENC_BIG_ENDIAN);
2503     proto_tree_add_item(msc_server_tree, hf_gtpv2_tra_info_msc_lu_imsi_ad,  tvb, offset, 1, ENC_BIG_ENDIAN);
2504     proto_tree_add_item(msc_server_tree, hf_gtpv2_tra_info_msc_handovers,   tvb, offset, 1, ENC_BIG_ENDIAN);
2505     proto_tree_add_item(msc_server_tree, hf_gtpv2_tra_info_msc_ss,          tvb, offset, 1, ENC_BIG_ENDIAN);
2506     bit_offset = offset << 3;
2507     proto_tree_add_bits_item(msc_server_tree, hf_gtpv2_spare_bits,          tvb, bit_offset, 3, ENC_BIG_ENDIAN);
2508     offset += 1;
2509     bit_offset = offset << 3;
2510     proto_tree_add_bits_item(msc_server_tree, hf_gtpv2_spare_bits,          tvb, bit_offset, 8, ENC_BIG_ENDIAN);
2511     offset += 1;
2512
2513     /* MGW - 1 octet */
2514     proto_tree_add_item(mgw_tree, hf_gtpv2_tra_info_mgw_context,            tvb, offset, 1, ENC_BIG_ENDIAN);
2515     bit_offset = offset << 3;
2516     proto_tree_add_bits_item(mgw_tree, hf_gtpv2_spare_bits,                 tvb, bit_offset, 7, ENC_BIG_ENDIAN);
2517     offset += 1;
2518     /* SGSN - 2 octets */
2519     proto_tree_add_item(sgsn_tree, hf_gtpv2_tra_info_sgsn_pdp_context,      tvb, offset, 1, ENC_BIG_ENDIAN);
2520     proto_tree_add_item(sgsn_tree, hf_gtpv2_tra_info_sgsn_momt_sms,         tvb, offset, 1, ENC_BIG_ENDIAN);
2521     proto_tree_add_item(sgsn_tree, hf_gtpv2_tra_info_sgsn_rau_gprs_ad,      tvb, offset, 1, ENC_BIG_ENDIAN);
2522     proto_tree_add_item(sgsn_tree, hf_gtpv2_tra_info_sgsn_mbms,             tvb, offset, 1, ENC_BIG_ENDIAN);
2523     bit_offset = offset << 3;
2524     proto_tree_add_bits_item(sgsn_tree, hf_gtpv2_spare_bits,                tvb, bit_offset, 4, ENC_BIG_ENDIAN);
2525     offset += 1;
2526     proto_tree_add_item(sgsn_tree, hf_gtpv2_tra_info_sgsn_reserved,         tvb, offset, 1, ENC_BIG_ENDIAN);
2527     bit_offset = offset << 3;
2528     proto_tree_add_bits_item(sgsn_tree, hf_gtpv2_reserved,                  tvb, bit_offset, 8, ENC_BIG_ENDIAN);
2529     offset += 1;
2530     /* GGSN - 1 octet */
2531     proto_tree_add_item(ggsn_tree, hf_gtpv2_tra_info_ggsn_pdp,              tvb, offset, 1, ENC_BIG_ENDIAN);
2532     proto_tree_add_item(ggsn_tree, hf_gtpv2_tra_info_ggsn_mbms,             tvb, offset, 1, ENC_BIG_ENDIAN);
2533     bit_offset = offset << 3;
2534     proto_tree_add_bits_item(ggsn_tree, hf_gtpv2_spare_bits,                tvb, bit_offset, 6, ENC_BIG_ENDIAN);
2535     offset += 1;
2536     /* BM-SC - 1 octet */
2537     proto_tree_add_item(bm_sc_tree, hf_gtpv2_tra_info_bm_sc,                tvb, offset, 1, ENC_BIG_ENDIAN);
2538     bit_offset = offset << 3;
2539     proto_tree_add_bits_item(bm_sc_tree, hf_gtpv2_spare_bits,               tvb, bit_offset, 7, ENC_BIG_ENDIAN);
2540     offset += 1;
2541     /* MME/SGW - 1 octet */
2542     proto_tree_add_item(sgw_mme_tree, hf_gtpv2_tra_info_mme_sgw_ss,         tvb, offset, 1, ENC_BIG_ENDIAN);
2543     proto_tree_add_item(sgw_mme_tree, hf_gtpv2_tra_info_mme_sgw_sr,         tvb, offset, 1, ENC_BIG_ENDIAN);
2544     proto_tree_add_item(sgw_mme_tree, hf_gtpv2_tra_info_mme_sgw_iataud,     tvb, offset, 1, ENC_BIG_ENDIAN);
2545     bit_offset = offset << 3;
2546     proto_tree_add_bits_item(sgw_mme_tree, hf_gtpv2_spare_bits,             tvb, bit_offset, 5, ENC_BIG_ENDIAN);
2547     offset += 1;
2548
2549     /* Create NE Types subtree */
2550     ne_types = proto_tree_add_text(tree, tvb, offset, 2, "List of NE Types");
2551     ne_types_tree = proto_item_add_subtree(ne_types, ett_gtpv2_tra_info_ne_types);
2552
2553
2554     /* List of NE Types */
2555     proto_tree_add_item(ne_types_tree, hf_gtpv2_tra_info_lne_msc_s,     tvb, offset, 1, ENC_BIG_ENDIAN);
2556     proto_tree_add_item(ne_types_tree, hf_gtpv2_tra_info_lne_mgw,       tvb, offset, 1, ENC_BIG_ENDIAN);
2557     proto_tree_add_item(ne_types_tree, hf_gtpv2_tra_info_lne_sgsn,      tvb, offset, 1, ENC_BIG_ENDIAN);
2558     proto_tree_add_item(ne_types_tree, hf_gtpv2_tra_info_lne_ggsn,      tvb, offset, 1, ENC_BIG_ENDIAN);
2559     proto_tree_add_item(ne_types_tree, hf_gtpv2_tra_info_lne_rnc,       tvb, offset, 1, ENC_BIG_ENDIAN);
2560     proto_tree_add_item(ne_types_tree, hf_gtpv2_tra_info_lne_bm_sc,     tvb, offset, 1, ENC_BIG_ENDIAN);
2561     proto_tree_add_item(ne_types_tree, hf_gtpv2_tra_info_lne_mme,       tvb, offset, 1, ENC_BIG_ENDIAN);
2562     proto_tree_add_item(ne_types_tree, hf_gtpv2_tra_info_lne_sgw,       tvb, offset, 1, ENC_BIG_ENDIAN);
2563     offset += 1;
2564     proto_tree_add_item(ne_types_tree, hf_gtpv2_tra_info_lne_pdn_gw,    tvb, offset, 1, ENC_BIG_ENDIAN);
2565     proto_tree_add_item(ne_types_tree, hf_gtpv2_tra_info_lne_enb,       tvb, offset, 1, ENC_BIG_ENDIAN);
2566     bit_offset = offset << 3;
2567     proto_tree_add_bits_item(ne_types_tree, hf_gtpv2_spare_bits,        tvb, bit_offset, 6, ENC_BIG_ENDIAN);
2568     offset += 1;
2569
2570     /* Trace Depth Length */
2571     tdl = tvb_get_guint8(tvb, offset);
2572     proto_tree_add_item(tree, hf_gtpv2_tra_info_tdl,                    tvb, offset, 1, ENC_BIG_ENDIAN);
2573     offset += 1;
2574
2575     /* Trace Depth List
2576      * Will be displayed if length of Trace Depth Length is > 0
2577      * The list will only contains UTF8String, RAW DATA
2578      */
2579     proto_tree_add_text(tree, tvb, offset, tdl, "Trace Depth List: %s", tvb_bytes_to_ep_str(tvb, offset, tdl));
2580     offset += tdl;
2581
2582     /* Set up subtree interfaces and put all interfaces under it */
2583     interfaces = proto_tree_add_text(tree, tvb, offset, 12, "List of Interfaces");
2584     interfaces_tree = proto_item_add_subtree(interfaces, ett_gtpv2_tra_info_interfaces);
2585
2586     /* Create all subtrees */
2587     imsc_server = proto_tree_add_text(interfaces_tree, tvb, offset, 2, "MSC Server");
2588     imsc_server_tree = proto_item_add_subtree(imsc_server, ett_gtpv2_tra_info_interfaces_imsc_server);
2589
2590     lmgw = proto_tree_add_text(interfaces_tree, tvb, offset + 2, 1, "MGW");
2591     lmgw_tree = proto_item_add_subtree(lmgw, ett_gtpv2_tra_info_interfaces_lmgw);
2592
2593     lsgsn = proto_tree_add_text(interfaces_tree, tvb, offset + 3, 2, "SGSN");
2594     lsgsn_tree = proto_item_add_subtree(lsgsn, ett_gtpv2_tra_info_interfaces_lsgsn);
2595
2596     lggsn = proto_tree_add_text(interfaces_tree, tvb, offset + 5, 1, "GGSN");
2597     lggsn_tree = proto_item_add_subtree(lggsn, ett_gtpv2_tra_info_interfaces_lggsn);
2598
2599     lrnc = proto_tree_add_text(interfaces_tree, tvb, offset + 6, 1, "RNC");
2600     lrnc_tree = proto_item_add_subtree(lrnc, ett_gtpv2_tra_info_interfaces_lrnc);
2601
2602     lbm_sc = proto_tree_add_text(interfaces_tree, tvb, offset + 7, 1, "BM-SC");
2603     lbm_sc_tree = proto_item_add_subtree(lbm_sc, ett_gtpv2_tra_info_interfaces_lbm_sc);
2604
2605     lmme = proto_tree_add_text(interfaces_tree, tvb, offset + 8, 1, "MME");
2606     lmme_tree = proto_item_add_subtree(lmme, ett_gtpv2_tra_info_interfaces_lmme);
2607
2608     lsgw = proto_tree_add_text(interfaces_tree, tvb, offset + 9, 1, "SGW");
2609     lsgw_tree = proto_item_add_subtree(lsgw, ett_gtpv2_tra_info_interfaces_lsgw);
2610
2611     lpdn_gw = proto_tree_add_text(interfaces_tree, tvb, offset + 10, 1, "PDN GW");
2612     lpdn_gw_tree = proto_item_add_subtree(lpdn_gw, ett_gtpv2_tra_info_interfaces_lpdn_gw);
2613
2614     lenb = proto_tree_add_text(interfaces_tree, tvb, offset + 11, 1, "eNB");
2615     lenb_tree = proto_item_add_subtree(lenb, ett_gtpv2_tra_info_interfaces_lpdn_lenb);
2616
2617     /* MSC Server - 2 octests */
2618     proto_tree_add_item(imsc_server_tree, hf_gtpv2_tra_info_lmsc_a,         tvb, offset, 1, ENC_BIG_ENDIAN);
2619     proto_tree_add_item(imsc_server_tree, hf_gtpv2_tra_info_lmsc_lu,        tvb, offset, 1, ENC_BIG_ENDIAN);
2620     proto_tree_add_item(imsc_server_tree, hf_gtpv2_tra_info_lmsc_mc,        tvb, offset, 1, ENC_BIG_ENDIAN);
2621     proto_tree_add_item(imsc_server_tree, hf_gtpv2_tra_info_lmsc_map_g,     tvb, offset, 1, ENC_BIG_ENDIAN);
2622     proto_tree_add_item(imsc_server_tree, hf_gtpv2_tra_info_lmsc_map_b,     tvb, offset, 1, ENC_BIG_ENDIAN);
2623     proto_tree_add_item(imsc_server_tree, hf_gtpv2_tra_info_lmsc_map_e,     tvb, offset, 1, ENC_BIG_ENDIAN);
2624     proto_tree_add_item(imsc_server_tree, hf_gtpv2_tra_info_lmsc_map_f,     tvb, offset, 1, ENC_BIG_ENDIAN);
2625     proto_tree_add_item(imsc_server_tree, hf_gtpv2_tra_info_lmsc_cap,       tvb, offset, 1, ENC_BIG_ENDIAN);
2626     offset += 1;
2627     proto_tree_add_item(imsc_server_tree, hf_gtpv2_tra_info_lmsc_map_d,     tvb, offset, 1, ENC_BIG_ENDIAN);
2628     proto_tree_add_item(imsc_server_tree, hf_gtpv2_tra_info_lmsc_map_c,     tvb, offset, 1, ENC_BIG_ENDIAN);
2629     bit_offset = offset << 3;
2630     proto_tree_add_bits_item(imsc_server_tree, hf_gtpv2_spare_bits,         tvb, bit_offset, 6, ENC_BIG_ENDIAN);
2631     offset += 1;
2632     /* MGW - 1 octet */
2633     proto_tree_add_item(lmgw_tree, hf_gtpv2_tra_info_lmgw_mc,               tvb, offset, 1, ENC_BIG_ENDIAN);
2634     proto_tree_add_item(lmgw_tree, hf_gtpv2_tra_info_lmgw_nb_up,            tvb, offset, 1, ENC_BIG_ENDIAN);
2635     proto_tree_add_item(lmgw_tree, hf_gtpv2_tra_info_lmgw_lu_up,            tvb, offset, 1, ENC_BIG_ENDIAN);
2636     bit_offset = offset << 3;
2637     proto_tree_add_bits_item(lmgw_tree, hf_gtpv2_spare_bits,                tvb, bit_offset, 5, ENC_BIG_ENDIAN);
2638     offset += 1;
2639     /* SGSN - 2 octets */
2640     proto_tree_add_item(lsgsn_tree, hf_gtpv2_tra_info_lsgsn_gb,             tvb, offset, 1, ENC_BIG_ENDIAN);
2641     proto_tree_add_item(lsgsn_tree, hf_gtpv2_tra_info_lsgsn_lu,             tvb, offset, 1, ENC_BIG_ENDIAN);
2642     proto_tree_add_item(lsgsn_tree, hf_gtpv2_tra_info_lsgsn_gn,             tvb, offset, 1, ENC_BIG_ENDIAN);
2643     proto_tree_add_item(lsgsn_tree, hf_gtpv2_tra_info_lsgsn_map_gr,         tvb, offset, 1, ENC_BIG_ENDIAN);
2644     proto_tree_add_item(lsgsn_tree, hf_gtpv2_tra_info_lsgsn_map_gd,         tvb, offset, 1, ENC_BIG_ENDIAN);
2645     proto_tree_add_item(lsgsn_tree, hf_gtpv2_tra_info_lsgsn_map_gf,         tvb, offset, 1, ENC_BIG_ENDIAN);
2646     proto_tree_add_item(lsgsn_tree, hf_gtpv2_tra_info_lsgsn_gs,             tvb, offset, 1, ENC_BIG_ENDIAN);
2647     proto_tree_add_item(lsgsn_tree, hf_gtpv2_tra_info_lsgsn_ge,             tvb, offset, 1, ENC_BIG_ENDIAN);
2648     offset += 1;
2649     bit_offset = offset << 3;
2650     proto_tree_add_bits_item(lsgsn_tree, hf_gtpv2_spare_bits,               tvb, bit_offset, 8, ENC_BIG_ENDIAN);
2651     offset += 1;
2652
2653     /* GGSN - 1 octet */
2654     proto_tree_add_item(lggsn_tree, hf_gtpv2_tra_info_lggsn_gn,             tvb, offset, 1, ENC_BIG_ENDIAN);
2655     proto_tree_add_item(lggsn_tree, hf_gtpv2_tra_info_lggsn_gi,             tvb, offset, 1, ENC_BIG_ENDIAN);
2656     proto_tree_add_item(lggsn_tree, hf_gtpv2_tra_info_lggsn_gmb,            tvb, offset, 1, ENC_BIG_ENDIAN);
2657     bit_offset = offset << 3;
2658     proto_tree_add_bits_item(lggsn_tree, hf_gtpv2_spare_bits,               tvb, bit_offset, 5, ENC_BIG_ENDIAN);
2659     offset += 1;
2660     /* RNC - 1 octet */
2661     proto_tree_add_item(lrnc_tree, hf_gtpv2_tra_info_lrnc_lu,               tvb, offset, 1, ENC_BIG_ENDIAN);
2662     proto_tree_add_item(lrnc_tree, hf_gtpv2_tra_info_lrnc_lur,              tvb, offset, 1, ENC_BIG_ENDIAN);
2663     proto_tree_add_item(lrnc_tree, hf_gtpv2_tra_info_lrnc_lub,              tvb, offset, 1, ENC_BIG_ENDIAN);
2664     proto_tree_add_item(lrnc_tree, hf_gtpv2_tra_info_lrnc_uu,               tvb, offset, 1, ENC_BIG_ENDIAN);
2665     bit_offset = offset << 3;
2666     proto_tree_add_bits_item(lrnc_tree, hf_gtpv2_spare_bits,                tvb, bit_offset, 4, ENC_BIG_ENDIAN);
2667     offset += 1;
2668     /* BM_SC - 1 octet */
2669     proto_tree_add_item(lbm_sc_tree, hf_gtpv2_tra_info_lbm_sc_gmb,          tvb, offset, 1, ENC_BIG_ENDIAN);
2670     bit_offset = offset << 3;
2671     proto_tree_add_bits_item(lbm_sc_tree, hf_gtpv2_spare_bits,              tvb, bit_offset, 7, ENC_BIG_ENDIAN);
2672     offset += 1;
2673     /* MME - 1 octet */
2674     proto_tree_add_item(lmme_tree, hf_gtpv2_tra_info_lmme_s1_mme,           tvb, offset, 1, ENC_BIG_ENDIAN);
2675     proto_tree_add_item(lmme_tree, hf_gtpv2_tra_info_lmme_s3,               tvb, offset, 1, ENC_BIG_ENDIAN);
2676     proto_tree_add_item(lmme_tree, hf_gtpv2_tra_info_lmme_s6a,              tvb, offset, 1, ENC_BIG_ENDIAN);
2677     proto_tree_add_item(lmme_tree, hf_gtpv2_tra_info_lmme_s10,              tvb, offset, 1, ENC_BIG_ENDIAN);
2678     proto_tree_add_item(lmme_tree, hf_gtpv2_tra_info_lmme_s11,              tvb, offset, 1, ENC_BIG_ENDIAN);
2679     bit_offset = offset << 3;
2680     proto_tree_add_bits_item(lmme_tree, hf_gtpv2_spare_bits,                tvb, bit_offset, 3, ENC_BIG_ENDIAN);
2681     offset += 1;
2682     /* SGW - 1 octet */
2683     proto_tree_add_item(lsgw_tree, hf_gtpv2_tra_info_lsgw_s4,               tvb, offset, 1, ENC_BIG_ENDIAN);
2684     proto_tree_add_item(lsgw_tree, hf_gtpv2_tra_info_lsgw_s5,               tvb, offset, 1, ENC_BIG_ENDIAN);
2685     proto_tree_add_item(lsgw_tree, hf_gtpv2_tra_info_lsgw_s8b,              tvb, offset, 1, ENC_BIG_ENDIAN);
2686     proto_tree_add_item(lsgw_tree, hf_gtpv2_tra_info_lsgw_s11,              tvb, offset, 1, ENC_BIG_ENDIAN);
2687     bit_offset = offset << 3;
2688     proto_tree_add_bits_item(lsgw_tree, hf_gtpv2_spare_bits,                tvb, bit_offset, 4, ENC_BIG_ENDIAN);
2689     offset += 1;
2690     /* PDN GW - 1 octet */
2691     proto_tree_add_item(lpdn_gw_tree, hf_gtpv2_tra_info_lpdn_gw_s2a,        tvb, offset, 1, ENC_BIG_ENDIAN);
2692     proto_tree_add_item(lpdn_gw_tree, hf_gtpv2_tra_info_lpdn_gw_s2b,        tvb, offset, 1, ENC_BIG_ENDIAN);
2693     proto_tree_add_item(lpdn_gw_tree, hf_gtpv2_tra_info_lpdn_gw_s2c,        tvb, offset, 1, ENC_BIG_ENDIAN);
2694     proto_tree_add_item(lpdn_gw_tree, hf_gtpv2_tra_info_lpdn_gw_s5,         tvb, offset, 1, ENC_BIG_ENDIAN);
2695     proto_tree_add_item(lpdn_gw_tree, hf_gtpv2_tra_info_lpdn_gw_s6c,        tvb, offset, 1, ENC_BIG_ENDIAN);
2696     proto_tree_add_item(lpdn_gw_tree, hf_gtpv2_tra_info_lpdn_gw_gx,         tvb, offset, 1, ENC_BIG_ENDIAN);
2697     proto_tree_add_item(lpdn_gw_tree, hf_gtpv2_tra_info_lpdn_gw_s8b,        tvb, offset, 1, ENC_BIG_ENDIAN);
2698     proto_tree_add_item(lpdn_gw_tree, hf_gtpv2_tra_info_lpdn_gw_sgi,        tvb, offset, 1, ENC_BIG_ENDIAN);
2699     offset += 1;
2700     /* eNB - 1 octet */
2701     proto_tree_add_item(lenb_tree, hf_gtpv2_tra_info_lenb_s1_mme,           tvb, offset, 1, ENC_BIG_ENDIAN);
2702     proto_tree_add_item(lenb_tree, hf_gtpv2_tra_info_lenb_x2,               tvb, offset, 1, ENC_BIG_ENDIAN);
2703     proto_tree_add_item(lenb_tree, hf_gtpv2_tra_info_lenb_uu,               tvb, offset, 1, ENC_BIG_ENDIAN);
2704     bit_offset = offset << 3;
2705     proto_tree_add_bits_item(lenb_tree, hf_gtpv2_spare_bits,                tvb, bit_offset, 5, ENC_BIG_ENDIAN);
2706
2707     /*--------------------------------------------------
2708      * offset += 1;
2709      *--------------------------------------------------*/
2710
2711     /* IP Address of Trace Collection Entity */
2712     while ( (offset + 4) <= length ) {
2713         offset += 1;
2714         proto_tree_add_item(tree, hf_gtpv2_ipv4_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
2715         offset += 3;
2716     }
2717 }
2718
2719 /*
2720  * 8.33 Paging Cause
2721  * 8.33 Void (TS 129 274 V9.4.0 (2010-10))
2722  */
2723
2724 /* 8.35 Procedure Transaction ID (PTI) */
2725 static void
2726 dissect_gtpv2_pti(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
2727 {
2728     proto_tree_add_item(tree, hf_gtpv2_pti, tvb, 0, 1, ENC_BIG_ENDIAN);
2729 }
2730 /*
2731  * 8.36 DRX Parameter
2732  */
2733 static void
2734 dissect_gtpv2_drx_param(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
2735 {
2736     int offset = 0;
2737
2738     /* 36.413 : 9.2.1.17   Paging Cause, void */
2739     proto_tree_add_text(tree, tvb, offset, length, "DRX parameter: %s", tvb_bytes_to_ep_str(tvb, offset, (length )));
2740 }
2741
2742 /*
2743  * 8.37 UE Network Capability
2744  * UE Network Capability is coded as depicted in Figure 8.37-1. Actual coding of the UE Network Capability field is
2745  * defined in 3GPP TS 24.301
2746  */
2747 static void
2748 dissect_gtpv2_ue_net_capability(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
2749 {
2750     de_emm_ue_net_cap(tvb, tree, pinfo, 0, length, NULL, 0);
2751
2752 }
2753 /*
2754  * 8.38 MM Context
2755  */
2756 static const value_string gtpv2_mm_context_security_mode[] = {
2757     {0, "GSM Key and Triplets"},
2758     {1, "UMTS Key, Used Cipher and Quintuplets"},
2759     {2, "GSM Key, Used Cipher and Quintuplets"},
2760     {3, "UMTS Key and Quintuplets"},
2761     {4, "EPS Security Context, Quadruplets and Quintuplets" },
2762     {5, "UMTS Key, Quadruplets and Quintuplets"},
2763     {0, NULL                                                                                                    }
2764 };
2765
2766 static const true_false_string gtpv2_nhi_vals = {
2767     "NH (Next Hop) and NCC (Next Hop Chaining Count) are both present",
2768     "NH (Next Hop) and NCC (Next Hop Chaining Count) not present",
2769 };
2770
2771 /* Table 8.38-2: Used NAS Cipher Values */
2772
2773 static const value_string gtpv2_mm_context_unc_vals[] = {
2774     {0, "No ciphering"},
2775     {1, "128-EEA1"},
2776     {2, "128-EEA2"},
2777     {3, "EEA3"},
2778     {4, "EEA4"  },
2779     {5, "EEA5"},
2780     {6, "EEA6"},
2781     {7, "EEA7"},
2782     {0, NULL}
2783 };
2784
2785 /* Table 8.38-3: Used Cipher Values */
2786 static const value_string gtpv2_mm_context_used_cipher_vals[] = {
2787     {0, "No ciphering"},
2788     {1, "GEA/1"},
2789     {2, "GEA/2"},
2790     {3, "GEA/3"},
2791     {4, "GEA/4" },
2792     {5, "GEA/5"},
2793     {6, "GEA/6"},
2794     {7, "GEA/7"},
2795     {0, NULL}
2796 };
2797
2798 /* Table 8.38-4: Used NAS integrity protection algorithm Values */
2799 static const value_string gtpv2_mm_context_unipa_vals[] = {
2800     {0, "No ciphering"},
2801     {1, "128-EEA1"},
2802     {2, "128-EEA2"},
2803     {3, "EEA3"},
2804     {4, "EEA4"  },
2805     {5, "EEA5"},
2806     {6, "EEA6"},
2807     {7, "EEA7"},
2808     {0, NULL}
2809 };
2810
2811 /* Helper functions */
2812
2813 /* Figure 8.38-7: Authentication Triplet */
2814 static int
2815 dissect_gtpv2_authentication_triplets(tvbuff_t *tvb, proto_tree *tree, int offset, guint8  num_triplet)
2816 {
2817     proto_item *auth_tri_item;
2818     proto_tree *auth_tri_tree;
2819     int         i;
2820
2821     for (i = 0; i < num_triplet; i++) {
2822         auth_tri_item = proto_tree_add_text(tree, tvb, offset, 0, "Authentication Triplet %u", i);
2823         auth_tri_tree = proto_item_add_subtree(auth_tri_item, ett_gtpv2_mm_context_auth_tri);
2824         /*
2825         * Figure 8.38-8: Authentication Quintuplet
2826         * 1 to 16 RAND
2827         * 17 to 20 SRES
2828         * 21 to 28 Kc
2829         */
2830         proto_tree_add_item(auth_tri_tree, hf_gtpv2_mm_context_rand, tvb, offset, 16, ENC_NA);
2831         offset += 16;
2832         proto_tree_add_text(auth_tri_tree, tvb, offset, 4, "SRES': %s", tvb_bytes_to_ep_str(tvb, offset, 4));
2833         offset += 4;
2834         proto_tree_add_text(auth_tri_tree, tvb, offset, 8, "Kc': %s", tvb_bytes_to_ep_str(tvb, offset, 8));
2835         offset += 8;
2836
2837     }
2838
2839     return offset;
2840 }
2841
2842 static int
2843 dissect_gtpv2_authentication_quintuplets(tvbuff_t *tvb, proto_tree *tree, int offset, guint8  nr_qui)
2844 {
2845     proto_item *auth_qui_item;
2846     proto_tree *auth_qui_tree;
2847     int         i;
2848     guint8      xres_len, autn_len;
2849
2850     for (i = 0; i < nr_qui; i++) {
2851         auth_qui_item = proto_tree_add_text(tree, tvb, offset, 0, "Authentication Quintuplet %u", i);
2852         auth_qui_tree = proto_item_add_subtree(auth_qui_item, ett_gtpv2_mm_context_auth_qui);
2853         /*
2854         * Figure 8.38-8: Authentication Quintuplet
2855         * 1 to 16 RAND
2856         * 17 XRES Length
2857         * 18 to m XRES
2858         * (m+1) to (m+16) CK
2859         * (m+17) to (m+32) IK
2860         * m+33 AUTN Length
2861         * (m+34) to n AUTN
2862         */
2863         proto_tree_add_item(auth_qui_tree, hf_gtpv2_mm_context_rand, tvb, offset, 16, ENC_NA);
2864         offset += 16;
2865         xres_len = tvb_get_guint8(tvb, offset);
2866         proto_tree_add_item(auth_qui_tree, hf_gtpv2_mm_context_xres_len, tvb, offset, 1, ENC_BIG_ENDIAN);
2867         offset += 1;
2868         proto_tree_add_item(auth_qui_tree, hf_gtpv2_mm_context_xres, tvb, offset, xres_len, ENC_NA);
2869         offset += xres_len;
2870         proto_tree_add_item(auth_qui_tree, hf_gtpv2_ck, tvb, offset, 16, ENC_NA);
2871         offset += 16;
2872         proto_tree_add_item(auth_qui_tree, hf_gtpv2_ik, tvb, offset, 16, ENC_NA);
2873         offset += 16;
2874         autn_len = tvb_get_guint8(tvb, offset);
2875         proto_tree_add_item(auth_qui_tree, hf_gtpv2_mm_context_autn_len, tvb, offset, 1, ENC_BIG_ENDIAN);
2876         offset += 1;
2877         proto_tree_add_item(auth_qui_tree, hf_gtpv2_mm_context_autn, tvb, offset, autn_len, ENC_NA);
2878         offset += autn_len;
2879     }
2880
2881     return offset;
2882
2883 }
2884
2885 static int
2886 dissect_gtpv2_authentication_quadruplets(tvbuff_t *tvb, proto_tree *tree, int offset, guint8  nr_qui)
2887 {
2888     proto_item *auth_qua_item;
2889     proto_tree *auth_qua_tree;
2890     guint8      tmp;
2891     int         i;
2892
2893     for (i = 0; i < nr_qui; i++) {
2894         auth_qua_item = proto_tree_add_text(tree, tvb, offset, 0, "Authentication Quadruplet");
2895         auth_qua_tree = proto_item_add_subtree(auth_qua_item, ett_gtpv2_mm_context_auth_qua);
2896
2897         proto_tree_add_text(auth_qua_tree, tvb, offset, 16, "RAND: %s",
2898             tvb_bytes_to_ep_str(tvb, offset, 16));
2899         offset += 16;
2900
2901         tmp = tvb_get_guint8(tvb, offset++);
2902
2903         proto_tree_add_text(auth_qua_tree, tvb, offset, tmp, "XRES: %s",
2904             tvb_bytes_to_ep_str(tvb, offset, tmp));
2905         offset += tmp;
2906
2907         tmp = tvb_get_guint8(tvb, offset++);
2908
2909         proto_tree_add_text(auth_qua_tree, tvb, offset, tmp, "AUTN: %s",
2910             tvb_bytes_to_ep_str(tvb, offset, tmp));
2911         offset += tmp;
2912
2913         proto_tree_add_item(tree, hf_gtpv2_mm_context_kasme, tvb, offset, 32, ENC_NA);
2914
2915         offset += 32;
2916     }
2917     return offset;
2918 }
2919
2920 static const value_string gtpv2_mm_context_higher_br_16mb_flg_vals[] = {
2921     {0, "Not allowed"},
2922     {1, "Allowed"},
2923     {0, NULL}
2924 };
2925
2926 static int
2927 dissect_gtpv2_mm_context_common_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, guint8 samb_ri, guint8 uamb_ri)
2928 {
2929     proto_item *net_cap_item, *msnt_cap_item;
2930     proto_tree *net_cap_tree, *msnt_cap_tree;
2931     guint8      ue_net_cap_len, ms_net_cap_len, mei_len;
2932
2933     /*
2934      * If SAMBRI (Subscribed UE AMBR Indicator), bit 1 of octet 6, is set to "1",
2935      * then the Uplink/downlink Subscribed UE AMBR parameter field is present,
2936      */
2937     if (samb_ri) {
2938         /* j to (j+3) Uplink Subscribed UE AMBR */
2939         proto_tree_add_text(tree, tvb, offset, 4, "Uplink Subscribed UE AMBR: %d Kbps",
2940                 tvb_get_ntohl(tvb, offset));
2941
2942         offset += 4;
2943         /* (j+4) to (j+7) Downlink Subscribed UE AMBR */
2944         proto_tree_add_text(tree, tvb, offset, 4, "Downlink Subscribed UE AMBR: %d Kbps",
2945                 tvb_get_ntohl(tvb, offset));
2946
2947         offset += 4;
2948     }
2949     /*
2950      * If UAMBRI (Used UE AMBR Indicator), bit 2 of octet 6, is set to "1",
2951      * then the Uplink/downlink Used UE AMBR parameter field is present
2952      */
2953     if (uamb_ri) {
2954         /* i to (i+3) Uplink Used UE AMBR  */
2955         proto_tree_add_text(tree, tvb, offset, 4, "Uplink Used UE AMBR: %d Kbps",
2956                 tvb_get_ntohl(tvb, offset));
2957
2958         offset += 4;
2959         /* (i+4) to (i+7) Downlink Used UE AMBR */
2960         proto_tree_add_text(tree, tvb, offset, 4, "Downlink Used UE AMBR: %d Kbps",
2961                 tvb_get_ntohl(tvb, offset));
2962
2963         offset += 4;
2964     }
2965     /* q Length of UE Network Capability */
2966     ue_net_cap_len = tvb_get_guint8(tvb, offset);
2967     proto_tree_add_item(tree, hf_gtpv2_mm_context_ue_net_cap_len, tvb, offset, 1, ENC_BIG_ENDIAN);
2968     offset += 1;
2969     /* (q+1) to k UE Network Capability */
2970     if (ue_net_cap_len) {
2971         /* The UE Network Capability coding is specified in clause 9.9.3.34 of 3GPP TS 24.301 [23].
2972          * If Length of UE Network Capability is zero, then the UE Network Capability parameter
2973          * shall not be present.
2974          */
2975         net_cap_item = proto_tree_add_text(tree, tvb, offset, ue_net_cap_len, "UE Network Capability");
2976         net_cap_tree = proto_item_add_subtree(net_cap_item, ett_gtpv2_mm_context_net_cap);
2977         offset += de_emm_ue_net_cap(tvb, net_cap_tree, pinfo, offset, ue_net_cap_len, NULL, 0);
2978     }
2979     /* k+1 Length of MS Network Capability */
2980     ms_net_cap_len = tvb_get_guint8(tvb, offset);
2981     proto_tree_add_item(tree, hf_gtpv2_mm_context_ms_net_cap_len, tvb, offset, 1, ENC_BIG_ENDIAN);
2982     offset += 1;
2983     /* (k+2) to m MS Network Capability
2984      * The MS Network Capability coding is specified in clause 10.5.5.12 of 3GPP TS 24.008 [5].
2985      * If Length of MS Network Capability is zero, then the MS Network Capability parameter shall not be present.
2986      */
2987     if (ms_net_cap_len) {
2988         msnt_cap_item = proto_tree_add_text(tree, tvb, offset, ms_net_cap_len, "MS network capability");
2989         msnt_cap_tree = proto_item_add_subtree(msnt_cap_item, ett_gtpv2_ms_network_capability);
2990         offset += de_gmm_ms_net_cap(tvb, msnt_cap_tree, pinfo, offset, ms_net_cap_len, NULL, 0);
2991     }
2992     /* m+1 Length of Mobile Equipment Identity (MEI) */
2993     mei_len = tvb_get_guint8(tvb, offset);
2994     proto_tree_add_item(tree, hf_gtpv2_mm_context_mei_len, tvb, offset, 1, ENC_BIG_ENDIAN);
2995     offset += 1;
2996     /* (m+2) to r Mobile Equipment Identity (MEI) */
2997     if (mei_len) {
2998         const gchar *mei_str;
2999
3000         mei_str = tvb_bcd_dig_to_wmem_packet_str( tvb, offset, mei_len, NULL, FALSE);
3001         proto_tree_add_string(tree, hf_gtpv2_mei, tvb, offset, mei_len, mei_str);
3002         offset += mei_len;
3003     }
3004     return offset;
3005 }
3006
3007 static int
3008 dissect_gtpv2_access_restriction_data(tvbuff_t *tvb, proto_tree *tree, int offset)
3009 {
3010     proto_item *accrstdata_item;
3011     proto_tree *accrstdata_tree;
3012
3013     accrstdata_item = proto_tree_add_text(tree, tvb, offset, 1, "Access restriction data");
3014     accrstdata_tree = proto_item_add_subtree(accrstdata_item, ett_gtpv2_access_rest_data);
3015     /* Spare HNNA ENA INA GANA GENA UNA */
3016     proto_tree_add_bits_item(accrstdata_tree, hf_gtpv2_spare_bits, tvb, (offset << 3), 2, ENC_BIG_ENDIAN);
3017     proto_tree_add_item(accrstdata_tree, hf_gtpv2_hnna, tvb, offset, 1, ENC_BIG_ENDIAN);
3018     proto_tree_add_item(accrstdata_tree, hf_gtpv2_ena,  tvb, offset, 1, ENC_BIG_ENDIAN);
3019     proto_tree_add_item(accrstdata_tree, hf_gtpv2_ina,  tvb, offset, 1, ENC_BIG_ENDIAN);
3020     proto_tree_add_item(accrstdata_tree, hf_gtpv2_gana, tvb, offset, 1, ENC_BIG_ENDIAN);
3021     proto_tree_add_item(accrstdata_tree, hf_gtpv2_gena, tvb, offset, 1, ENC_BIG_ENDIAN);
3022     proto_tree_add_item(accrstdata_tree, hf_gtpv2_una,  tvb, offset, 1, ENC_BIG_ENDIAN);
3023     offset += 1;
3024
3025     return offset;
3026 }
3027
3028 /* Type = 103 (decimal)
3029  * Figure 8.38-1: GSM Key and Triplets
3030  */
3031 static void
3032 dissect_gtpv2_mm_context_gsm_t(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
3033 {
3034     proto_item *flag;
3035     proto_tree *flag_tree;
3036     int         offset;
3037     guint8      oct, drxi, num_triplet, uamb_ri, samb_ri;
3038
3039     offset = 0;
3040     flag = proto_tree_add_text(tree, tvb, offset, 3, "MM Context flags");
3041     flag_tree = proto_item_add_subtree(flag, ett_gtpv2_mm_context_flag);
3042
3043     /* Octet 5 */
3044     /* Security Mode | Spare | DRXI | CKSN */
3045     drxi = (tvb_get_guint8(tvb, offset) & 0x08) >> 3;
3046     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_sm,   tvb, offset,      1, ENC_BIG_ENDIAN);
3047     proto_tree_add_bits_item(flag_tree, hf_gtpv2_spare_bits, tvb, offset << 3, 1, ENC_BIG_ENDIAN);
3048     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_drxi, tvb, offset,      1, ENC_BIG_ENDIAN);
3049     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_cksn, tvb, offset,      1, ENC_BIG_ENDIAN);
3050     offset += 1;
3051     /* Octet 6 */
3052     /* Number of Triplet | Spare  | UAMB RI | SAMB RI */
3053     oct = tvb_get_guint8(tvb, offset);
3054     num_triplet = oct >> 5;
3055     uamb_ri = (oct & 0x02) >> 1;
3056     samb_ri = oct & 0x01;
3057
3058     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_nr_tri,       tvb, offset,            1, ENC_BIG_ENDIAN);
3059     proto_tree_add_bits_item(flag_tree, hf_gtpv2_spare_bits,         tvb, (offset << 3) + 3, 3, ENC_BIG_ENDIAN);
3060     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_uamb_ri,      tvb, offset,            1, ENC_BIG_ENDIAN);
3061     proto_tree_add_bits_item(flag_tree, hf_gtpv2_mm_context_samb_ri, tvb, (offset << 3) + 7, 1, ENC_BIG_ENDIAN);
3062     offset += 1;
3063
3064     /* Octet 7 Spare Used Cipher */
3065     proto_tree_add_bits_item(flag_tree, hf_gtpv2_spare_bits,         tvb, ((offset << 3)),   5, ENC_BIG_ENDIAN);
3066     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_used_cipher,  tvb, offset,            1, ENC_BIG_ENDIAN);
3067     offset += 1;
3068
3069     /* 8 to 15 Kc */
3070     proto_tree_add_text(tree, tvb, offset, 8, "Kc': %s", tvb_bytes_to_ep_str(tvb, offset, 8));
3071     offset += 8;
3072
3073     /* 16 to h Authentication Triplet [0..4] */
3074     if (num_triplet) {
3075         dissect_gtpv2_authentication_triplets(tvb, tree, offset, num_triplet);
3076     }
3077
3078     /*
3079      * (h+1) to (h+2) DRX parameter
3080      */
3081     if (drxi) {
3082         proto_tree_add_item(tree, hf_gtpv2_mm_context_drx, tvb, offset, 2, ENC_BIG_ENDIAN);
3083         offset += 2;
3084     }
3085
3086     /* Dissect octet j to r */
3087     offset = dissect_gtpv2_mm_context_common_data(tvb, pinfo, tree, offset, samb_ri, uamb_ri);
3088
3089     proto_tree_add_text(flag_tree, tvb, offset, -1, "The rest of the IE not dissected yet");
3090 }
3091
3092 /* Type = 104 (decimal)
3093  * Figure 8.38-2: UMTS Key, Used Cipher and Quintuplets
3094  */
3095 static void
3096 dissect_gtpv2_mm_context_utms_cq(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
3097 {
3098     proto_item *flag;
3099     proto_tree *flag_tree;
3100     int         offset;
3101     guint8      oct, drxi, nr_qui, uamb_ri, samb_ri, vdp_len, hbr_len;
3102
3103     offset = 0;
3104     flag = proto_tree_add_text(tree, tvb, offset, 3, "MM Context flags");
3105     flag_tree = proto_item_add_subtree(flag, ett_gtpv2_mm_context_flag);
3106
3107     /* Octet 5 */
3108     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_sm, tvb, offset, 1, ENC_BIG_ENDIAN);
3109     drxi = (tvb_get_guint8(tvb, offset) & 0x08) >> 3;
3110     proto_tree_add_bits_item(flag_tree, hf_gtpv2_spare_bits, tvb, ((offset << 3) + 3), 1, ENC_BIG_ENDIAN);
3111     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_drxi, tvb, offset, 1, ENC_BIG_ENDIAN);
3112     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_cksn_ksi, tvb, offset, 1, ENC_BIG_ENDIAN);
3113     offset += 1;
3114     /* Octet 6 */
3115     oct = tvb_get_guint8(tvb, offset);
3116     nr_qui = oct >> 5;
3117     uamb_ri = (oct & 0x02) >> 1;
3118     samb_ri = oct & 0x01;
3119     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_nr_qui, tvb, offset, 1, ENC_BIG_ENDIAN);
3120     proto_tree_add_bits_item(flag_tree, hf_gtpv2_spare_bits, tvb, (offset << 3) + 3, 3, ENC_BIG_ENDIAN);
3121     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_uamb_ri, tvb, offset, 1, ENC_BIG_ENDIAN);
3122     proto_tree_add_bits_item(flag_tree, hf_gtpv2_mm_context_samb_ri, tvb, (offset << 3) + 7, 1, ENC_BIG_ENDIAN);
3123     offset += 1;
3124     /* Octet 7 Spare Used Cipher */
3125     proto_tree_add_bits_item(flag_tree, hf_gtpv2_spare_bits, tvb, ((offset << 3)), 5, ENC_BIG_ENDIAN);
3126     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_used_cipher, tvb, offset, 1, ENC_BIG_ENDIAN);
3127     offset += 1;
3128
3129     /* Octet 8 to 23  CK */
3130     proto_tree_add_item(tree, hf_gtpv2_ck, tvb, offset, 16, ENC_NA);
3131     offset += 16;
3132     /* Octet 24 to 39 IK */
3133     proto_tree_add_item(tree, hf_gtpv2_ik, tvb, offset, 16, ENC_NA);
3134     offset += 16;
3135
3136     /*
3137      * 40 to h Authentication Quintuplet [0..4]
3138      */
3139     if (nr_qui) {
3140         offset = dissect_gtpv2_authentication_quintuplets(tvb, tree, offset, nr_qui);
3141     }
3142
3143     /*
3144      * (h+1) to (h+2) DRX parameter
3145      */
3146     if (drxi) {
3147         proto_tree_add_item(tree, hf_gtpv2_mm_context_drx, tvb, offset, 2, ENC_BIG_ENDIAN);
3148         offset += 2;
3149     }
3150
3151
3152     /* Dissect octet j to r */
3153     offset = dissect_gtpv2_mm_context_common_data(tvb, pinfo, tree, offset, samb_ri, uamb_ri);
3154
3155     /* r+1 Spare HNNA ENA INA GANA GENA UNA
3156      * The Access restriction data is composed of UNA(UTRAN Not Allowed), GENA(GERAN Not Allowed),
3157      * GANA(GAN Not Allowed), INA(I-HSPA-Evolution Not Allowed), ENA(E-UTRAN Not Allowed) and
3158      * HNNA(HO-To-Non-3GPPAccess Not Allowed).
3159      */
3160     if (offset < (gint)length) {
3161         offset = dissect_gtpv2_access_restriction_data(tvb, tree, offset);
3162     } else {
3163         return;
3164     }
3165     if (offset == (gint)length) {
3166         return;
3167     }
3168
3169     /* r+2 Length of Voice Domain Preference and UE's Usage Setting */
3170     vdp_len = tvb_get_guint8(tvb, offset);
3171     proto_tree_add_item(tree, hf_gtpv2_mm_context_vdp_len, tvb, offset, 1, ENC_BIG_ENDIAN);
3172     offset += 1;
3173     /* (r+3) to s Voice Domain Preference and UE's Usage Setting */
3174     if (vdp_len) {
3175         proto_tree_add_text(tree, tvb, offset, vdp_len, "Voice Domain Preference and UE's Usage Setting");
3176         offset += vdp_len;
3177     }
3178
3179     /* s+1 Length of Higher bitrates than 16 Mbps flag */
3180     if (offset == (gint)length) {
3181         hbr_len = tvb_get_guint8(tvb, offset);
3182         proto_tree_add_item(tree, hf_gtpv2_mm_context_higher_br_16mb_flg_len, tvb, offset, 1, ENC_BIG_ENDIAN);
3183         offset += 1;
3184         /* s+2 Higher bitrates than 16 Mbps flag */
3185         if (hbr_len) {
3186             proto_tree_add_item(tree, hf_gtpv2_mm_context_higher_br_16mb_flg, tvb, offset, 1, ENC_BIG_ENDIAN);
3187             offset += hbr_len;
3188         }
3189     } else {
3190         return;
3191     }
3192
3193     proto_tree_add_text(flag_tree, tvb, offset, -1, "The rest of the IE not dissected yet");
3194
3195 }
3196
3197 /* Type = 105 (decimal)
3198  * Figure 8.38-3: GSM Key, Used Cipher and Quintuplets
3199  */
3200 static void
3201 dissect_gtpv2_mm_context_gsm_cq(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
3202 {
3203     proto_item *flag;
3204     proto_tree *flag_tree;
3205     int         offset;
3206     guint8      oct, drxi, nr_qui, uamb_ri, samb_ri, vdp_len, hbr_len;
3207
3208     offset = 0;
3209     flag = proto_tree_add_text(tree, tvb, offset, 3, "MM Context flags");
3210     flag_tree = proto_item_add_subtree(flag, ett_gtpv2_mm_context_flag);
3211
3212     /* Octet 5 */
3213     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_sm, tvb, offset, 1, ENC_BIG_ENDIAN);
3214     drxi = (tvb_get_guint8(tvb, offset) & 0x08) >> 3;
3215     proto_tree_add_bits_item(flag_tree, hf_gtpv2_spare_bits, tvb, ((offset << 3) + 3), 1, ENC_BIG_ENDIAN);
3216     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_drxi, tvb, offset, 1, ENC_BIG_ENDIAN);
3217     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_cksn_ksi, tvb, offset, 1, ENC_BIG_ENDIAN);
3218     offset += 1;
3219     /* Octet 6 */
3220     oct = tvb_get_guint8(tvb, offset);
3221     nr_qui = oct >> 5;
3222     uamb_ri = (oct & 0x02) >> 1;
3223     samb_ri = oct & 0x01;
3224     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_nr_qui, tvb, offset, 1, ENC_BIG_ENDIAN);
3225     proto_tree_add_bits_item(flag_tree, hf_gtpv2_spare_bits, tvb, (offset << 3) + 3, 3, ENC_BIG_ENDIAN);
3226     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_uamb_ri, tvb, offset, 1, ENC_BIG_ENDIAN);
3227     proto_tree_add_bits_item(flag_tree, hf_gtpv2_mm_context_samb_ri, tvb, (offset << 3) + 7, 1, ENC_BIG_ENDIAN);
3228     offset += 1;
3229     /* Octet 7 Spare Used Cipher */
3230     proto_tree_add_bits_item(flag_tree, hf_gtpv2_spare_bits, tvb, ((offset << 3)), 5, ENC_BIG_ENDIAN);
3231     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_used_cipher, tvb, offset, 1, ENC_BIG_ENDIAN);
3232     offset += 1;
3233     /* 8 to 15 Kc */
3234     proto_tree_add_text(tree, tvb, offset, 8, "Kc': %s", tvb_bytes_to_ep_str(tvb, offset, 8));
3235     offset += 8;
3236
3237     /*
3238      * 40 to h Authentication Quintuplet [0..4]
3239      */
3240     if (nr_qui) {
3241         offset = dissect_gtpv2_authentication_quintuplets(tvb, tree, offset, nr_qui);
3242     }
3243
3244     /*
3245      * (h+1) to (h+2) DRX parameter
3246      */
3247     if (drxi) {
3248         proto_tree_add_item(tree, hf_gtpv2_mm_context_drx, tvb, offset, 2, ENC_BIG_ENDIAN);
3249         offset += 2;
3250     }
3251
3252
3253     /* Dissect octet j to r */
3254     offset = dissect_gtpv2_mm_context_common_data(tvb, pinfo, tree, offset, samb_ri, uamb_ri);
3255
3256     /* r+1 Spare HNNA ENA INA GANA GENA UNA
3257      * The Access restriction data is composed of UNA(UTRAN Not Allowed), GENA(GERAN Not Allowed),
3258      * GANA(GAN Not Allowed), INA(I-HSPA-Evolution Not Allowed), ENA(E-UTRAN Not Allowed) and
3259      * HNNA(HO-To-Non-3GPPAccess Not Allowed).
3260      */
3261     if (offset < (gint)length) {
3262         offset = dissect_gtpv2_access_restriction_data(tvb, tree, offset);
3263     } else {
3264         return;
3265     }
3266     if (offset == (gint)length) {
3267         return;
3268     }
3269
3270     /* r+2 Length of Voice Domain Preference and UE's Usage Setting */
3271     vdp_len = tvb_get_guint8(tvb, offset);
3272     proto_tree_add_item(tree, hf_gtpv2_mm_context_vdp_len, tvb, offset, 1, ENC_BIG_ENDIAN);
3273     offset += 1;
3274     /* (r+3) to s Voice Domain Preference and UE's Usage Setting */
3275     if (vdp_len) {
3276         proto_tree_add_text(tree, tvb, offset, vdp_len, "Voice Domain Preference and UE's Usage Setting");
3277         offset += vdp_len;
3278     }
3279
3280     /* s+1 Length of Higher bitrates than 16 Mbps flag */
3281     if (offset < (gint)length) {
3282         hbr_len = tvb_get_guint8(tvb, offset);
3283         proto_tree_add_item(tree, hf_gtpv2_mm_context_higher_br_16mb_flg_len, tvb, offset, 1, ENC_BIG_ENDIAN);
3284         offset += 1;
3285         /* s+2 Higher bitrates than 16 Mbps flag */
3286         if (hbr_len) {
3287             proto_tree_add_item(tree, hf_gtpv2_mm_context_higher_br_16mb_flg, tvb, offset, 1, ENC_BIG_ENDIAN);
3288             offset += hbr_len;
3289         }
3290     } else {
3291         return;
3292     }
3293
3294     proto_tree_add_text(flag_tree, tvb, offset, -1, "The rest of the IE not dissected yet");
3295
3296 }
3297
3298 /* Type = 106 (decimal)
3299  * Figure 8.38-4: UMTS Key and Quintuplets
3300  */
3301 static void
3302 dissect_gtpv2_mm_context_utms_q(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
3303 {
3304     proto_item *flag;
3305     proto_tree *flag_tree;
3306     int         offset;
3307     guint8      oct, drxi, nr_qui, uamb_ri, samb_ri, vdp_len, hbr_len;
3308
3309     offset = 0;
3310     flag = proto_tree_add_text(tree, tvb, offset, 3, "MM Context flags");
3311     flag_tree = proto_item_add_subtree(flag, ett_gtpv2_mm_context_flag);
3312
3313     /* Octet 5 */
3314     /* Security Mode Spare DRXI KSI */
3315     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_sm, tvb, offset, 1, ENC_BIG_ENDIAN);
3316     proto_tree_add_bits_item(flag_tree, hf_gtpv2_spare_bits, tvb, ((offset << 3) + 3), 1, ENC_BIG_ENDIAN);
3317     drxi = (tvb_get_guint8(tvb, offset) & 0x08) >> 3;
3318     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_drxi, tvb, offset, 1, ENC_BIG_ENDIAN);
3319     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_ksi, tvb, offset, 1, ENC_BIG_ENDIAN);
3320     offset += 1;
3321     /* Octet 6 */
3322     /* Number of Quintuplets Spare UAMB RI SAMB RI */
3323     oct = tvb_get_guint8(tvb, offset);
3324     nr_qui = oct >> 5;
3325     uamb_ri = (oct & 0x02) >> 1;
3326     samb_ri = oct & 0x01;
3327
3328     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_nr_qui, tvb, offset, 1, ENC_BIG_ENDIAN);
3329     proto_tree_add_bits_item(flag_tree, hf_gtpv2_spare_bits, tvb, (offset << 3) + 3, 3, ENC_BIG_ENDIAN);
3330     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_uamb_ri, tvb, offset, 1, ENC_BIG_ENDIAN);
3331     proto_tree_add_bits_item(flag_tree, hf_gtpv2_mm_context_samb_ri, tvb, (offset << 3) + 7, 1, ENC_BIG_ENDIAN);
3332     offset += 1;
3333     /* Octet 7 Spare */
3334     proto_tree_add_item(flag_tree, hf_gtpv2_spare, tvb, offset, 1, ENC_BIG_ENDIAN);
3335     offset += 1;
3336     /* Octet 8 to 23  CK */
3337     proto_tree_add_item(tree, hf_gtpv2_ck, tvb, offset, 16, ENC_NA);
3338     offset += 16;
3339     /* Octet 24 to 39 IK */
3340     proto_tree_add_item(tree, hf_gtpv2_ik, tvb, offset, 16, ENC_NA);
3341     offset += 16;
3342
3343     /*
3344      * 40 to h Authentication Quintuplet [0..4]
3345      */
3346     if (nr_qui) {
3347         offset = dissect_gtpv2_authentication_quintuplets(tvb, tree, offset, nr_qui);
3348     }
3349
3350     /*
3351      * (h+1) to (h+2) DRX parameter
3352      */
3353     if (drxi) {
3354         proto_tree_add_item(tree, hf_gtpv2_mm_context_drx, tvb, offset, 2, ENC_BIG_ENDIAN);
3355         offset += 2;
3356     }
3357
3358
3359     /* Dissect octet j to r */
3360     offset = dissect_gtpv2_mm_context_common_data(tvb, pinfo, tree, offset, samb_ri, uamb_ri);
3361
3362     /* r+1 Spare HNNA ENA INA GANA GENA UNA
3363      * The Access restriction data is composed of UNA(UTRAN Not Allowed), GENA(GERAN Not Allowed),
3364      * GANA(GAN Not Allowed), INA(I-HSPA-Evolution Not Allowed), ENA(E-UTRAN Not Allowed) and
3365      * HNNA(HO-To-Non-3GPPAccess Not Allowed).
3366      */
3367     if (offset < (gint)length) {
3368         offset = dissect_gtpv2_access_restriction_data(tvb, tree, offset);
3369     } else {
3370         return;
3371     }
3372     if (offset == (gint)length) {
3373         return;
3374     }
3375
3376     /* r+2 Length of Voice Domain Preference and UE's Usage Setting */
3377     vdp_len = tvb_get_guint8(tvb, offset);
3378     proto_tree_add_item(tree, hf_gtpv2_mm_context_vdp_len, tvb, offset, 1, ENC_BIG_ENDIAN);
3379     offset += 1;
3380     /* (r+3) to s Voice Domain Preference and UE's Usage Setting */
3381     if (vdp_len) {
3382         proto_tree_add_text(tree, tvb, offset, vdp_len, "Voice Domain Preference and UE's Usage Setting");
3383         offset += vdp_len;
3384     }
3385
3386     /* s+1 Length of Higher bitrates than 16 Mbps flag */
3387     if (offset < (gint)length) {
3388         hbr_len = tvb_get_guint8(tvb, offset);
3389         proto_tree_add_item(tree, hf_gtpv2_mm_context_higher_br_16mb_flg_len, tvb, offset, 1, ENC_BIG_ENDIAN);
3390         offset += 1;
3391         /* s+2 Higher bitrates than 16 Mbps flag */
3392         if (hbr_len) {
3393             proto_tree_add_item(tree, hf_gtpv2_mm_context_higher_br_16mb_flg, tvb, offset, 1, ENC_BIG_ENDIAN);
3394             offset += hbr_len;
3395         }
3396     } else {
3397         return;
3398     }
3399
3400     /* (s+3) to (n+4) These octet(s) is/are present only if explicitly specified */
3401     proto_tree_add_text(flag_tree, tvb, offset, -1, "The rest of the IE not dissected yet");
3402
3403 }
3404
3405 /* 8.38 MM Context
3406  * Type = 107 (decimal)
3407  * Figure 8.38-5: EPS Security Context and Quadruplets
3408  */
3409 static void
3410 dissect_gtpv2_mm_context_eps_qq(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
3411 {
3412     proto_item *flag_item, *qua_item, *qui_item;
3413     proto_tree *flag_tree, *qua_tree, *qui_tree;
3414     gint        offset;
3415     guint8      tmp, nhi, drxi, nr_qua, nr_qui, uamb_ri, samb_ri, vdp_len;
3416
3417     offset = 0;
3418
3419     flag_item = proto_tree_add_text(tree, tvb, offset, 3, "MM Context flags");
3420     flag_tree = proto_item_add_subtree(flag_item, ett_gtpv2_mm_context_flag);
3421
3422     /* Octet 5
3423      * Bits
3424      * 8      7     6     5     4      3      2      1
3425      * Security Mode    | NHI | DRXI | KSIASME
3426      */
3427     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_sm, tvb, offset, 1, ENC_BIG_ENDIAN);
3428     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_nhi, tvb, offset, 1, ENC_BIG_ENDIAN);
3429     /* If NHI (Next Hop Indicator), bit 5 of octet 5, is set to "1",
3430      * then the optional parameters NH (Next Hop) and NCC (Next
3431      * Hop Chaining Count) are both present, otherwise their octets are not present.
3432      */
3433     tmp = tvb_get_guint8(tvb, offset);
3434     nhi = (tmp & 0x10) >> 4;
3435     drxi = (tmp & 0x08) >> 3;
3436     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_drxi, tvb, offset, 1, ENC_BIG_ENDIAN);
3437     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_ksi_a, tvb, offset, 1, ENC_BIG_ENDIAN);
3438     offset += 1;
3439
3440     /* Octet 6
3441      * Bits
3442      * 8      7     6     5     4      3      2      1
3443      * Number of        | Number of       | UAMB  | OSCI
3444      * Quintuplets      | Quadruplet      |  RI   |
3445      */
3446     tmp = tvb_get_guint8(tvb, offset);
3447     nr_qui = (tmp & 0xe0) >> 5;
3448     nr_qua = tmp & 0x1c;
3449     nr_qua >>= 2;
3450     uamb_ri = (tmp & 0x2) >> 1;
3451
3452     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_nr_qui, tvb, offset, 1, ENC_BIG_ENDIAN);
3453     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_nr_qua, tvb, offset, 1, ENC_BIG_ENDIAN);
3454     /* UAMB RI */
3455     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_uamb_ri, tvb, offset, 1, ENC_BIG_ENDIAN);
3456     /* OSCI */
3457     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_osci, tvb, offset, 1, ENC_BIG_ENDIAN);
3458     offset += 1;
3459
3460     /* Octet 7 SAMB RI Used NAS integrity protection algorithm Used NAS Cipher*/
3461     /* SAMB RI */
3462     samb_ri = tvb_get_guint8(tvb, offset) >> 7;
3463     proto_tree_add_bits_item(flag_tree, hf_gtpv2_mm_context_samb_ri, tvb, offset << 3, 1, ENC_BIG_ENDIAN);
3464     /* Used NAS integrity protection algorithm */
3465     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_unipa, tvb, offset, 1, ENC_BIG_ENDIAN);
3466     /* Used NAS Cipher */
3467     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_unc, tvb, offset, 1, ENC_BIG_ENDIAN);
3468     offset += 1;
3469
3470     /* Octet 8-10 NAS Downlink Count*/
3471     proto_tree_add_item(tree, hf_gtpv2_mm_context_nas_dl_cnt, tvb, offset, 3, ENC_BIG_ENDIAN);
3472     offset += 3;
3473
3474     /* Octet 11-13 NAS Uplink Count */
3475     proto_tree_add_item(tree, hf_gtpv2_mm_context_nas_ul_cnt, tvb, offset, 3, ENC_BIG_ENDIAN);
3476     offset += 3;
3477
3478     /* Octet 14-45 */
3479     proto_tree_add_item(tree, hf_gtpv2_mm_context_kasme, tvb, offset, 32, ENC_NA);
3480     offset += 32;
3481
3482     qua_item = proto_tree_add_text(tree, tvb, offset, 0, "Authentication Quadruplets %u", nr_qua);
3483     if ( nr_qua ){
3484         qua_tree = proto_item_add_subtree(qua_item, ett_gtpv2_qua);
3485         offset = dissect_gtpv2_authentication_quadruplets(tvb, qua_tree, offset, nr_qua);
3486     }else {
3487         PROTO_ITEM_SET_GENERATED(qua_item);
3488     }
3489
3490     qui_item = proto_tree_add_text(tree, tvb, offset, 0, "Authentication Quintuplets %u", nr_qui);
3491     if (nr_qui) {
3492         qui_tree = proto_item_add_subtree(qui_item, ett_gtpv2_qui);
3493         offset = dissect_gtpv2_authentication_quintuplets(tvb, qui_tree, offset, nr_qui);
3494     }else{
3495         PROTO_ITEM_SET_GENERATED(qui_item);
3496     }
3497
3498     /* (h+1) to (h+2) DRX parameter */
3499     if (drxi) {
3500         proto_tree_add_item(tree, hf_gtpv2_mm_context_drx, tvb, offset, 2, ENC_BIG_ENDIAN);
3501         offset += 2;
3502     }
3503
3504     /* Octet p to p+31 & Octet p+32 */
3505     if ( nhi )
3506     {
3507         proto_tree_add_text(tree, tvb, offset, 32, "NH (Next Hop): %s",
3508             tvb_bytes_to_ep_str(tvb, offset, 32));
3509         offset += 32;
3510
3511         proto_tree_add_text(tree, tvb, offset, 1, "NCC (Next Hop Chaining Count): %d",
3512             (tvb_get_guint8(tvb, offset) & 0x0f));
3513         offset += 1;
3514     }
3515
3516
3517     /* Dissect octet j to r */
3518     offset = dissect_gtpv2_mm_context_common_data(tvb, pinfo, tree, offset, samb_ri, uamb_ri);
3519
3520     /* r+1 Spare HNNA ENA INA GANA GENA UNA */
3521     if (offset < (gint)length) {
3522         offset = dissect_gtpv2_access_restriction_data(tvb, tree, offset);
3523     } else {
3524         return;
3525     }
3526
3527     if (offset == (gint)length) {
3528         return;
3529     }
3530
3531     /* r+2 Length of Voice Domain Preference and UE's Usage Setting */
3532     vdp_len = tvb_get_guint8(tvb, offset);
3533     proto_tree_add_item(tree, hf_gtpv2_mm_context_vdp_len, tvb, offset, 1, ENC_BIG_ENDIAN);
3534     offset += 1;
3535     /* (r+3) to s Voice Domain Preference and UE's Usage Setting */
3536     if (vdp_len) {
3537         proto_tree_add_text(tree, tvb, offset, vdp_len, "Voice Domain Preference and UE's Usage Setting");
3538         /*offset += vdp_len;*/
3539     }
3540
3541 }
3542
3543 /*
3544  * Type = 108 (decimal)
3545  * Figure 8.38-6: UMTS Key, Quadruplets and Quintuplets
3546  */
3547 static void
3548 dissect_gtpv2_mm_context_utms_qq(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
3549 {
3550     proto_item *flag;
3551     proto_tree *flag_tree;
3552     guint32     offset;
3553     guint8      tmp, drxi, nr_qua, nr_qui, uamb_ri, samb_ri, vdp_length;
3554
3555     offset = 0;
3556     flag = proto_tree_add_text(tree, tvb, offset, 3, "MM Context flags");
3557     flag_tree = proto_item_add_subtree(flag, ett_gtpv2_mm_context_flag);
3558
3559     /* Octet 5
3560      * Security Mode Spare DRXI KSIASME
3561      */
3562     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_sm, tvb, offset, 1, ENC_BIG_ENDIAN);
3563     proto_tree_add_bits_item(flag_tree, hf_gtpv2_spare_bits, tvb, ((offset << 3) + 3), 1, ENC_BIG_ENDIAN);
3564     drxi = (tvb_get_guint8(tvb, offset) & 0x08) >> 3;
3565     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_drxi, tvb, offset, 1, ENC_BIG_ENDIAN);
3566     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_ksi_a, tvb, offset, 1, ENC_BIG_ENDIAN);
3567     offset += 1;
3568
3569     /* Octet 6
3570      * Bits
3571      * 8      7     6     5     4      3      2      1
3572      * Number of        | Number of       | UAMB  | SAMB
3573      * Quintuplets      | Quadruplet      |  RI   |  RI
3574      */
3575     tmp = tvb_get_guint8(tvb, offset);
3576     nr_qui = (tmp & 0xe0) >> 5;
3577     nr_qua = tmp & 0x1c;
3578     nr_qua >>= 2;
3579     uamb_ri = (tmp & 0x2) >> 1;
3580     samb_ri = tmp & 0x01;
3581
3582     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_nr_qui, tvb, offset, 1, ENC_BIG_ENDIAN);
3583     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_nr_qua, tvb, offset, 1, ENC_BIG_ENDIAN);
3584     proto_tree_add_item(flag_tree, hf_gtpv2_mm_context_uamb_ri, tvb, offset, 1, ENC_BIG_ENDIAN);
3585     proto_tree_add_bits_item(flag_tree, hf_gtpv2_mm_context_samb_ri, tvb, (offset << 3) + 7, 1, ENC_BIG_ENDIAN);
3586     offset += 1;
3587     /* Octet 7 Spare */
3588     proto_tree_add_item(flag_tree, hf_gtpv2_spare, tvb, offset, 1, ENC_BIG_ENDIAN);
3589     offset += 1;
3590     /* Octet 8 to 23  CK */
3591     proto_tree_add_item(tree, hf_gtpv2_ck, tvb, offset, 16, ENC_NA);
3592     offset += 16;
3593     /* Octet 24 to 39 IK */
3594     proto_tree_add_item(tree, hf_gtpv2_ik, tvb, offset, 16, ENC_NA);
3595     offset += 16;
3596
3597     if ( nr_qua )
3598     {
3599         offset = dissect_gtpv2_authentication_quadruplets(tvb, tree, offset, nr_qui);
3600     }
3601
3602     if (nr_qui) {
3603         offset = dissect_gtpv2_authentication_quintuplets(tvb, tree, offset, nr_qui);
3604     }
3605
3606     /* (h+1) to (h+2) DRX parameter */
3607     if (drxi) {
3608         proto_tree_add_item(tree, hf_gtpv2_mm_context_drx, tvb, offset, 2, ENC_BIG_ENDIAN);
3609         offset += 2;
3610     }
3611
3612     /* Dissect octet j to r */
3613     offset = dissect_gtpv2_mm_context_common_data(tvb, pinfo, tree, offset, samb_ri, uamb_ri);
3614
3615     if (offset >= (guint32)length) {
3616         return;
3617     }
3618     /* r+1 Spare HNNA ENA INA GANA GENA UNA */
3619     offset = dissect_gtpv2_access_restriction_data(tvb, tree, offset);
3620
3621     if (offset >= (guint32)length) {
3622         return;
3623     }
3624
3625     /* The Voice Domain Preference and UE's Usage Setting coding is specified in clause 10.5.5.28 of 3GPP TS 24.008 [5]. If
3626      * Length of Voice Domain Preference and UE's Usage Setting is zero, then the Voice Domain Preference and UE's Usage
3627      * Setting parameter shall not be present.
3628      */
3629     vdp_length = tvb_get_guint8(tvb, offset);
3630     proto_tree_add_item(tree, hf_gtpv2_vdp_length, tvb, offset, 1, ENC_BIG_ENDIAN);
3631     offset++;
3632
3633     if(vdp_length !=0){
3634         offset += de_gmm_voice_domain_pref(tvb, tree, pinfo, offset, vdp_length, NULL, 0);
3635     }
3636
3637     if (offset < (guint32)length) {
3638         proto_tree_add_text(tree, tvb, offset, -1, "The rest of the IE not dissected yet");
3639     }
3640
3641 }
3642
3643 /*
3644   * 8.39 PDN Connection (grouped IE)
3645  */
3646 static void
3647 dissect_gtpv2_PDN_conn(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree _U_, proto_item *item, guint16 length, guint8 message_type _U_, guint8 instance _U_)
3648 {
3649     int         offset = 0;
3650     proto_tree *grouped_tree;
3651     tvbuff_t   *new_tvb;
3652
3653     proto_item_append_text(item, "[Grouped IE]");
3654     grouped_tree = proto_item_add_subtree(item, ett_gtpv2_PDN_conn);
3655     new_tvb = tvb_new_subset_length(tvb, offset, length);
3656
3657     dissect_gtpv2_ie_common(new_tvb, pinfo, grouped_tree, offset, message_type);
3658 }
3659 /*
3660  * 8.40 PDU Numbers
3661  */
3662 static void
3663 dissect_gtpv2_pdn_numbers(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
3664 {
3665     proto_item *nsapi_ti;
3666     proto_tree *nsapi_tree;
3667     guint8      nsapi;
3668     guint16     dlgtpu_seq, ulgtpu_seq, send_npdu_nr, rec_npdu_nr;
3669     int         offset = 0;
3670
3671     nsapi = (tvb_get_guint8(tvb, offset) & 0x08);
3672     nsapi_ti = proto_tree_add_text(tree, tvb, offset, 1, "NSAPI: %d", nsapi);
3673     nsapi_tree = proto_item_add_subtree(nsapi_ti, ett_gtpv2_pdn_numbers_nsapi);
3674     proto_tree_add_bits_item(nsapi_tree, hf_gtpv2_spare_bits, tvb, offset << 3, 4, ENC_BIG_ENDIAN);
3675     proto_tree_add_item(nsapi_tree, hf_gtpv2_pdn_numbers_nsapi, tvb, offset, 1, ENC_BIG_ENDIAN);
3676     proto_item_append_text(item, "NSAPI: %u", nsapi);
3677     offset += 1;
3678
3679     dlgtpu_seq = tvb_get_ntohs(tvb, offset);
3680     proto_tree_add_text(tree, tvb, offset, 2, "DL GTP-U Sequence Number: %d", dlgtpu_seq);
3681     offset += 2;
3682
3683     ulgtpu_seq = tvb_get_ntohs(tvb, offset);
3684     proto_tree_add_text(tree, tvb, offset, 2, "UL GTP-U Sequence Number: %d", ulgtpu_seq);
3685     offset += 2;
3686
3687     send_npdu_nr = tvb_get_ntohs(tvb, offset);
3688     proto_tree_add_text(tree, tvb, offset, 2, "Send N-PDU Number: %d", send_npdu_nr);
3689     offset += 2;
3690
3691     rec_npdu_nr = tvb_get_ntohs(tvb, offset);
3692     proto_tree_add_text(tree, tvb, offset, 2, "Receive N-PDU Number: %d", rec_npdu_nr);
3693 }
3694
3695 /*
3696  * 8.41 Packet TMSI (P-TMSI)
3697  */
3698 static void
3699 dissect_gtpv2_p_tmsi(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
3700 {
3701     int offset = 0;
3702
3703     /* The TMSI consists of 4 octets. It can be coded using a full hexadecimal representation. */
3704     proto_tree_add_item(tree, hf_gtpv2_p_tmsi, tvb, offset, 4, ENC_BIG_ENDIAN);
3705     proto_item_append_text(item, "%s", tvb_bytes_to_ep_str(tvb, offset, 4));
3706 }
3707
3708 /*
3709  * 8.42 P-TMSI Signature
3710  */
3711 static void
3712 dissect_gtpv2_p_tmsi_sig(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
3713 {
3714     int offset = 0;
3715
3716     /* The P-TMSI Signature consists of 3 octets and may be allocated by the SGSN. */
3717     proto_tree_add_item(tree, hf_gtpv2_p_tmsi_sig, tvb, offset, 3, ENC_BIG_ENDIAN);
3718     proto_item_append_text(item, "%s", tvb_bytes_to_ep_str(tvb, offset, 3));
3719
3720 }
3721
3722 /*
3723  * 8.43 Hop Counter
3724  */
3725 static void
3726 dissect_gtpv2_hop_counter(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
3727 {
3728     int    offset = 0;
3729     guint8 hop_counter;
3730
3731     hop_counter = tvb_get_guint8(tvb, offset);
3732
3733     proto_tree_add_text(tree, tvb, offset, 1, "Hop Counter: %d", hop_counter);
3734     proto_item_append_text(item, "%d", hop_counter);
3735 }
3736
3737 /*
3738  * 8.44 UE Time Zone
3739  */
3740
3741 static const value_string gtpv2_ue_time_zone_dst_vals[] = {
3742     {0, "No Adjustments for Daylight Saving Time"},
3743     {1, "+1 Hour Adjustments for Daylight Saving Time"},
3744     {2, "+2 Hour Adjustments for Daylight Saving Time"},
3745     {3, "Spare"},
3746     {0, NULL}
3747 };
3748 static void
3749 dissect_gtpv2_ue_time_zone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
3750 {
3751     int offset = 0;
3752
3753     /*
3754      * UE Time Zone is used to indicate the offset between universal time and local time in steps of 15 minutes of where the
3755      * UE currently resides. The "Time Zone" field uses the same format as the "Time Zone" IE in 3GPP TS 24.008 [5].
3756      * (packet-gsm_a_dtap.c)
3757      */
3758     de_time_zone(tvb, tree, pinfo, offset, 1, NULL, 0);
3759     offset += 1;
3760     proto_tree_add_item(item, hf_gtpv2_ue_time_zone_dst, tvb, offset, 1, ENC_BIG_ENDIAN);
3761 }
3762
3763 /*
3764  * 8.45 Trace Reference
3765  */
3766 static void
3767 dissect_gtpv2_trace_reference(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
3768 {
3769     int      offset = 0;
3770     guint32  trace_id;
3771     gchar   *mcc_mnc_str;
3772
3773     mcc_mnc_str = dissect_e212_mcc_mnc_wmem_packet_str(tvb, pinfo, tree, 0, TRUE);
3774     offset += 3;
3775
3776     trace_id = tvb_get_ntohs(tvb, offset);
3777     proto_tree_add_text(tree, tvb, offset, 3, "Trace ID: %d", trace_id);
3778
3779     proto_item_append_text(item, "%s,Trace ID %u", mcc_mnc_str, trace_id);
3780 }
3781 /*
3782  * 8.46 Complete Request Message
3783  */
3784 static const value_string gtpv2_complete_req_msg_type_vals[] = {
3785     {0, "Complete Attach Request Message"  },
3786     {1, "Complete TAU Request Message"     },
3787     {0, NULL                               }
3788 };
3789 static void
3790 dissect_complete_request_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
3791 {
3792     tvbuff_t  *new_tvb;
3793     int        offset;
3794
3795     offset = 0;
3796
3797     proto_tree_add_item(tree, hf_gtpv2_complete_req_msg_type, tvb, offset, 1, ENC_BIG_ENDIAN);
3798
3799     offset += 1;
3800
3801     /* Add the Complete Request Message */
3802     new_tvb = tvb_new_subset_remaining(tvb, offset);
3803     call_dissector(nas_eps_handle, new_tvb, pinfo, tree);
3804
3805 }
3806
3807 /*
3808  * 8.47 GUTI
3809  */
3810 static void
3811 dissect_gtpv2_guti(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
3812 {
3813     int offset = 0;
3814
3815     offset = 0;
3816
3817     dissect_e212_mcc_mnc(tvb, pinfo, tree, 0, TRUE);
3818     offset += 3;
3819
3820     proto_tree_add_item(tree, hf_gtpv2_mme_grp_id, tvb, offset, 2, ENC_BIG_ENDIAN);
3821     offset += 2;
3822
3823     proto_tree_add_item(tree, hf_gtpv2_mme_code, tvb, offset, 1, ENC_BIG_ENDIAN);
3824     offset += 1;
3825
3826     proto_tree_add_item(tree, hf_gtpv2_m_tmsi, tvb, offset, 4, ENC_NA);
3827 }
3828
3829 /*
3830  * 8.48 Fully Qualified Container (F-Container)
3831  */
3832
3833 static const value_string gtpv2_container_type_vals[] = {
3834     {1, "UTRAN transparent container"},
3835     {2, "BSS container"},
3836     {3, "E-UTRAN transparent container"},
3837     {0, NULL}
3838 };
3839
3840
3841 static void
3842 dissect_gtpv2_F_container(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type, guint8 instance _U_)
3843 {
3844     tvbuff_t   *new_tvb;
3845     proto_item *bss_item;
3846     proto_tree *sub_tree;
3847     int         offset = 0;
3848     guint8      container_type;
3849     guint8      container_flags, xid_len;
3850
3851     /* Octets   8   7   6   5   4   3   2   1
3852      * 5            Spare     | Container Type
3853      */
3854     proto_tree_add_item(tree, hf_gtpv2_container_type, tvb, offset, 1, ENC_BIG_ENDIAN);
3855     container_type = tvb_get_guint8(tvb, offset);
3856     offset += 1;
3857     if (   (message_type == GTPV2_FORWARD_RELOCATION_REQ)
3858         || (message_type == GTPV2_CONTEXT_RESPONSE)
3859         || (message_type == GTPV2_RAN_INFORMATION_RELAY)) {
3860         switch (container_type) {
3861         case 2:
3862             /* BSS container */
3863             bss_item = proto_tree_add_text(tree, tvb, offset, length, "BSS container");
3864             sub_tree = proto_item_add_subtree(bss_item, ett_gtpv2_bss_con);
3865             /* The flags PFI, RP, SAPI and PHX in octet 6 indicate the corresponding type of paratemer */
3866             proto_tree_add_item(sub_tree, hf_gtpv2_bss_container_phx, tvb, offset, 1, ENC_BIG_ENDIAN);
3867             proto_tree_add_item(sub_tree, hf_gtpv2_bss_con_sapi_flg, tvb, offset, 1, ENC_BIG_ENDIAN);
3868             proto_tree_add_item(sub_tree, hf_gtpv2_bss_con_rp_flg, tvb, offset, 1, ENC_BIG_ENDIAN);
3869             proto_tree_add_item(sub_tree, hf_gtpv2_bss_con_pfi_flg, tvb, offset, 1, ENC_BIG_ENDIAN);
3870             container_flags = tvb_get_guint8(tvb, offset);
3871             offset += 1;
3872             if ((container_flags & 0x01) == 1) {
3873                 /* Packet Flow ID present */
3874                 proto_tree_add_item(sub_tree, hf_gtpv2_bss_con_pfi, tvb, offset, 1, ENC_BIG_ENDIAN);
3875                 offset += 1;
3876             }
3877             if (((container_flags & 0x04) == 4) || ((container_flags & 0x02) == 2)) {
3878                 if ((container_flags & 0x04) == 4) {
3879                     /* SAPI present */
3880                     proto_tree_add_item(sub_tree, hf_gtpv2_bss_con_sapi, tvb, offset, 1, ENC_BIG_ENDIAN);
3881                 }
3882                 if ((container_flags & 0x02) == 2) {
3883                     /* Radio Priority present */
3884                     proto_tree_add_item(sub_tree, hf_gtpv2_bss_con_rp, tvb, offset, 1, ENC_BIG_ENDIAN);
3885                 }
3886                 offset += 1;
3887             }
3888             if ((container_flags & 0x08) == 8) {
3889                 /* XiD parameters length is present in Octet c.
3890                  * XiD parameters are present in Octet d to n.
3891                  */
3892                 xid_len = tvb_get_guint8(tvb, offset);
3893                 proto_tree_add_item(sub_tree, hf_gtpv2_bss_con_xid_len, tvb, offset, 1, ENC_BIG_ENDIAN);
3894                 offset += 1;
3895                 proto_tree_add_item(sub_tree, hf_gtpv2_bss_con_xid, tvb, offset, xid_len, ENC_NA);
3896             }
3897             return;
3898         default:
3899             break;
3900         }
3901     }
3902     if (message_type == GTPV2_FORWARD_CTX_NOTIFICATION) {
3903         switch (container_type) {
3904         case 3:
3905             /* E-UTRAN transparent container */
3906             new_tvb = tvb_new_subset_remaining(tvb, offset);
3907             dissect_s1ap_ENB_StatusTransfer_TransparentContainer_PDU(new_tvb, pinfo, tree, NULL);
3908             return;
3909         default:
3910             break;
3911         }
3912     }
3913
3914     /* 7.3.2 Forward Relocation Response
3915      * E-UTRAN Transparent Container
3916      * This IE is conditionally included only during a handover to
3917      * E-UTRAN and contains the radio-related and core network
3918      * information. If the Cause IE contains the value "Request
3919      * accepted", this IE shall be included.
3920      */
3921     proto_tree_add_text(tree, tvb, offset, length-offset, "Not dissected yet");
3922
3923 }
3924
3925 /*
3926  * 8.49 Fully Qualified Cause (F-Cause)
3927  */
3928
3929 static const value_string gtpv2_cause_type_vals[] = {
3930     {0,  "Radio Network Layer"},
3931     {1,  "Transport Layer"},
3932     {2,  "NAS"},
3933     {3,  "Protocol"},
3934     {4,  "Miscellaneous"},
3935     {5,  "<spare>"},
3936     {6,  "<spare>"},
3937     {7,  "<spare>"},
3938     {8,  "<spare>"},
3939     {9,  "<spare>"},
3940     {10, "<spare>"},
3941     {11, "<spare>"},
3942     {12, "<spare>"},
3943     {13, "<spare>"},
3944     {14, "<spare>"},
3945     {15, "<spare>"},
3946     {0, NULL}
3947 };
3948 static value_string_ext gtpv2_cause_type_vals_ext = VALUE_STRING_EXT_INIT(gtpv2_cause_type_vals);
3949
3950 static void
3951 dissect_gtpv2_F_cause(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length, guint8 message_type _U_, guint8 instance _U_)
3952 {
3953     int    offset = 0;
3954     guint8 cause_type;
3955
3956     /* The value of Instance field of the F-Cause IE in a GTPv2 message shall indicate
3957      * whether the F-Cause field contains RANAP Cause, BSSGP Cause or RAN Cause.
3958      * If the F-Cause field contains RAN Cause, the Cause Type field shall contain
3959      * the RAN cause subcategory as specified in 3GPP TS 36.413 [10] and it shall be
3960      * encoded as in Table 8.49-1.
3961      * If the F-Cause field contains BSSGP Cause or RANAP Cause,
3962      * the Cause Type field shall be ignored by the receiver.
3963      */
3964     if (message_type == GTPV2_FORWARD_RELOCATION_REQ) {
3965         switch (instance) {
3966         case 0:
3967             proto_item_append_text(item, "[RAN Cause]");
3968             proto_tree_add_item(tree, hf_gtpv2_cause_type, tvb, offset, 1, ENC_BIG_ENDIAN);
3969             cause_type = tvb_get_guint8(tvb, offset);
3970             offset += 1;
3971             switch (cause_type) {
3972             case 0:
3973                 /* CauseRadioNetwork */
3974                 proto_tree_add_item(tree, hf_gtpv2_CauseRadioNetwork, tvb, offset, 1, ENC_BIG_ENDIAN);
3975                 break;
3976             case 1:
3977                 /* CauseTransport */
3978                 proto_tree_add_item(tree, hf_gtpv2_CauseTransport, tvb, offset, 1, ENC_BIG_ENDIAN);
3979                 break;
3980             case 2:
3981                 /* CauseNas */
3982                 proto_tree_add_item(tree, hf_gtpv2_CauseNas, tvb, offset, 1, ENC_BIG_ENDIAN);
3983                 break;
3984             case 3:
3985                 /* CauseProtocol */
3986                 proto_tree_add_item(tree, hf_gtpv2_CauseProtocol, tvb, offset, 1, ENC_BIG_ENDIAN);
3987                 break;
3988             case 4:
3989                 /* CauseMisc */
3990                 proto_tree_add_item(tree, hf_gtpv2_CauseMisc, tvb, offset, 1, ENC_BIG_ENDIAN);
3991                 break;
3992             default:
3993                 break;
3994             }
3995             return;
3996             break;
3997         case 1:
3998             proto_item_append_text(item, "[RANAP Cause]");
3999             break;
4000         case 2:
4001             proto_item_append_text(item, "[BSSGP Cause]");
4002             break;
4003         default:
4004             break;
4005         }
4006     }
4007     proto_tree_add_text(tree, tvb, offset, length-offset, "Not dissected yet");
4008
4009 }
4010
4011 /*
4012  * 8.50 Selected PLMN ID
4013  */
4014 /*
4015  * The Selected PLMN ID IE contains the core network operator selected for tne UE
4016  * in a shared network. Octets 5-7 shall be encoded as the content part of the
4017  *  "Selected PLMN Identity" parameter in 3GPP TS 36.413 [10].
4018  * -The Selected PLMN identity consists of 3 digits from MCC followed by
4019  * either -a filler digit plus 2 digits from MNC (in case of 2 digit MNC) or
4020  * -3 digits from MNC (in case of a 3 digit MNC).
4021  *
4022  *         8  7  6  5  4  3  2  1
4023  *         +--+--+--+--+--+--+--+--+
4024  * Octet 5 |MCC digit 2|MCC digit 1|
4025  *         +--+--+--+--+--+--+--+--+
4026  * Octet 6 |MNC digit 1|MCC digit 3|
4027  *         +--+--+--+--+--+--+--+--+
4028  * Octet 7 |MNC digit 3|MNC digit 2|
4029  *         +--+--+--+--+--+--+--+--+
4030  */
4031 static void
4032 dissect_gtpv2_sel_plmn_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
4033 {
4034     gchar *mcc_mnc_str;
4035
4036     mcc_mnc_str = dissect_e212_mcc_mnc_wmem_packet_str(tvb, pinfo, tree, 0, FALSE);
4037     proto_item_append_text(item, "%s", mcc_mnc_str);
4038 }
4039
4040 /*
4041  * 8.51 Target Identification
4042  */
4043
4044 static const value_string gtpv2_target_type_vals[] = {
4045     {0,  "RNC ID"},
4046     {1,  "Macro eNodeB ID"},
4047     {2,  "Cell Identifier"},
4048     {3,  "Home eNodeB ID"},
4049     {0, NULL}
4050 };
4051 static value_string_ext gtpv2_target_type_vals_ext = VALUE_STRING_EXT_INIT(gtpv2_target_type_vals);
4052
4053 static void
4054 dissect_gtpv2_target_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
4055 {
4056     tvbuff_t *new_tvb;
4057     int       offset = 0;
4058     guint8    target_type;
4059
4060     proto_tree_add_item(tree, hf_gtpv2_target_type, tvb, 0, 1, ENC_BIG_ENDIAN);
4061     target_type = tvb_get_guint8(tvb, offset);
4062     offset += 1;
4063     switch (target_type) {
4064     case 0:
4065         new_tvb = tvb_new_subset_remaining(tvb, offset);
4066         dissect_e212_mcc_mnc(new_tvb, pinfo, tree, 0, TRUE);
4067         offset += 3;
4068         /* LAC */
4069         proto_tree_add_item(tree, hf_gtpv2_lac,    tvb, offset, 2, ENC_BIG_ENDIAN);
4070         offset+=2;
4071
4072         /* RAC (see NOTE 3) */
4073         proto_tree_add_item(tree, hf_gtpv2_rac, tvb, offset, 1, ENC_BIG_ENDIAN);
4074         offset++;
4075         /* RNC ID
4076          * In this case the Target ID field shall be encoded as the Target
4077          * RNC-ID part of the "Target ID" parameter in 3GPP TS 25.413 [33]. Therefore, the "Choice Target ID" that indicates
4078          * "Target RNC-ID" (numerical value of 0x20) shall not be included (value in octet 5 specifies the target type).
4079          */
4080         proto_tree_add_item(tree, hf_gtpv2_rnc_id, tvb, offset, 2, ENC_BIG_ENDIAN);
4081         /* If the optional Extended RNC-ID is not included, then the length variable 'n' = 8 and the overall length of the IE is 11
4082          * octets. Otherwise, 'n' = 10 and the overall length of the IE is 13 octets
4083          */
4084         if(length == 11){
4085             proto_tree_add_item(tree, hf_gtpv2_ext_rnc_id, tvb, offset, 2, ENC_BIG_ENDIAN);
4086         }
4087         return;
4088     case 1:
4089         /* Macro eNodeB ID*/
4090         new_tvb = tvb_new_subset_remaining(tvb, offset);
4091         dissect_e212_mcc_mnc(new_tvb, pinfo, tree, 0, TRUE);
4092         offset += 3;
4093         /* The Macro eNodeB ID consists of 20 bits.
4094          * Bit 4 of Octet 4 is the most significant bit and bit 1 of Octet 6 is the least significant bit.
4095          */
4096         proto_tree_add_item(tree, hf_gtpv2_macro_enodeb_id, tvb, offset, 3, ENC_BIG_ENDIAN);
4097         offset += 3;
4098         /* Tracking Area Code (TAC) */
4099         proto_tree_add_item(tree, hf_gtpv2_uli_tai_tac, tvb, offset, 2, ENC_BIG_ENDIAN);
4100         return;
4101
4102     case 2:
4103         /* Cell Identifier */
4104         /* Target ID field shall be same as the Octets 3 to 10 of the Cell Identifier IEI
4105          * in 3GPP TS 48.018 [34].
4106          */
4107         new_tvb = tvb_new_subset_remaining(tvb, offset);
4108         de_bssgp_cell_id(new_tvb, tree, pinfo, 0, 0/* not used */, NULL, 0);
4109         return;
4110     case 3:
4111         /* Home eNodeB ID */
4112         new_tvb = tvb_new_subset_remaining(tvb, offset);
4113         dissect_e212_mcc_mnc(new_tvb, pinfo, tree, 0, TRUE);
4114         offset += 3;
4115         /* Octet 10 to 12 Home eNodeB ID
4116          * The Home eNodeB ID consists of 28 bits. See 3GPP TS 36.413 [10].
4117          * Bit 4 of Octet 9 is the most significant bit and bit 1 of Octet 12 is the least significant bit.
4118          * The coding of the Home eNodeB ID is the responsibility of each administration.
4119          * Coding using full hexadecimal representation shall be used.
4120          */
4121         proto_tree_add_item(tree, hf_gtpv2_home_enodeb_id, tvb, offset, 4 , ENC_BIG_ENDIAN);
4122         offset += 4;
4123         /* Octet 13 to 14 Tracking Area Code (TAC) */
4124         proto_tree_add_item(tree, hf_gtpv2_tac, tvb, offset, 2 , ENC_BIG_ENDIAN);
4125         return;
4126
4127     default:
4128         break;
4129     }
4130     proto_tree_add_text(tree, tvb, offset, length-offset, "Not dissected yet");
4131
4132 }
4133
4134 /*
4135  * 8.52 Void
4136  */
4137 /*
4138  * 8.53 Packet Flow ID
4139  */
4140 static void
4141 dissect_gtpv2_pkt_flow_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
4142 {
4143     int offset = 0;
4144
4145     /* Octet 5 Spare EBI */
4146     proto_tree_add_bits_item(tree, hf_gtpv2_spare_bits, tvb, offset << 3, 4, ENC_BIG_ENDIAN);
4147     proto_tree_add_item(tree, hf_gtpv2_ebi, tvb, offset, 2, ENC_BIG_ENDIAN);
4148     offset += 1;
4149
4150     /* Packet Flow ID */
4151     proto_tree_add_text(tree, tvb, offset, length, "Packet Flow ID: %s", tvb_bytes_to_ep_str(tvb, offset, length-1));
4152
4153 }
4154 /*
4155  * 8.54 RAB Context
4156  */
4157 static void
4158 dissect_gtpv2_rab_context(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
4159 {
4160     int     offset = 0;
4161     guint16 dlgtpu_seq, ulgtpu_seq, dl_pdcp_seq, ul_pdcp_seq;
4162
4163     /* 5 Spare NSAPI */
4164     proto_tree_add_bits_item(tree, hf_gtpv2_spare_bits, tvb, offset << 3, 4, ENC_BIG_ENDIAN);
4165     proto_tree_add_item(tree, hf_gtpv2_nsapi, tvb, offset, 1, ENC_BIG_ENDIAN);
4166     offset++;
4167
4168     /* 6 to 7 DL GTP-U Sequence Number */
4169     dlgtpu_seq = tvb_get_ntohs(tvb, offset);
4170     proto_tree_add_text(tree, tvb, offset, 2, "DL GTP-U Sequence Number: %d", dlgtpu_seq);
4171     offset += 2;
4172
4173     /* 8 to 9 UL GTP-U Sequence Number */
4174     ulgtpu_seq = tvb_get_ntohs(tvb, offset);
4175     proto_tree_add_text(tree, tvb, offset, 2, "UL GTP-U Sequence Number: %d", ulgtpu_seq);
4176     offset += 2;
4177
4178     /* 10 to 11 DL PDCP Sequence Number */
4179     dl_pdcp_seq = tvb_get_ntohs(tvb, offset);
4180     proto_tree_add_text(tree, tvb, offset, 2, "DL PDCP Sequence Number: %d", dl_pdcp_seq);
4181     offset += 2;
4182
4183     /* 12 to 13 UL PDCP Sequence Number */
4184     ul_pdcp_seq = tvb_get_ntohs(tvb, offset);
4185     proto_tree_add_text(tree, tvb, offset, 2, "UL PDCP Sequence Number: %d", ul_pdcp_seq);
4186
4187 }
4188
4189 /*
4190  * 8.55 Source RNC PDCP context info
4191  */
4192 static void
4193 dissect_gtpv2_s_rnc_pdcp_ctx_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
4194 {
4195     proto_tree_add_text(tree, tvb, 0, length, "RRC Container");
4196 }
4197
4198 /*
4199  * 8.56 UDP Source Port Number
4200  */
4201 static void
4202 dissect_udp_s_port_nr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
4203 {
4204     proto_tree_add_text(tree, tvb, 0, 2, "UPD Source Port Number: %u", tvb_get_ntohs(tvb, 0));
4205     proto_item_append_text(item, "%u", tvb_get_ntohs(tvb, 0));
4206 }
4207 /*
4208  * 8.57 APN Restriction
4209  */
4210 static void
4211 dissect_gtpv2_apn_rest(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
4212 {
4213     guint8 type_value;
4214
4215     type_value = tvb_get_guint8(tvb, 0);
4216     proto_tree_add_item(tree, hf_gtpv2_apn_rest, tvb, 0, 1, ENC_BIG_ENDIAN);
4217     proto_item_append_text(item, "value %u", type_value);
4218 }
4219
4220 /*
4221  * 8.58 Selection Mode
4222  */
4223 static const value_string gtpv2_selec_mode_vals[] = {
4224     {0, "MS or network provided APN, subscribed verified"},
4225     {1, "MS provided APN, subscription not verified"},
4226     {2, "Network provided APN, subscription not verified"},
4227     {3, "Network provided APN, subscription not verified (Basically for Future use"},
4228     {0, NULL}
4229 };
4230
4231 void
4232 dissect_gtpv2_selec_mode(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
4233 {
4234     int    offset = 0;
4235     guint8 ss_mode;
4236
4237     ss_mode = tvb_get_guint8(tvb, offset) & 0x03;
4238     proto_tree_add_item(tree, hf_gtpv2_selec_mode, tvb, offset, 1, ENC_BIG_ENDIAN);
4239     proto_item_append_text(item, "%s", val_to_str_const(ss_mode, gtpv2_selec_mode_vals, "Unknown"));
4240 }
4241
4242
4243 /*
4244  * 8.59 Source Identification
4245  */
4246 #if 0
4247 static const value_string gtpv2_source_ident_types[] = {
4248     {0, "Cell ID"},
4249     {1, "RNC ID"},
4250     {2, "eNodeB ID(Reserved, used in erlier v of proto.)"},
4251     {0, NULL}
4252 };
4253 #endif
4254 static void
4255 dissect_gtpv2_source_ident(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
4256 {
4257     int         offset = 0;
4258     guint8      source_type;
4259
4260     /* Octet 5 to 12 Target Cell ID */
4261     de_cell_id(tvb, tree, pinfo, offset, 8, NULL, 0);
4262     offset += 8;
4263     /* Octet 13 Source Type */
4264     source_type = tvb_get_guint8(tvb, offset);
4265     proto_tree_add_item(tree, hf_gtpv2_source_type, tvb, offset, 1, ENC_BIG_ENDIAN);
4266     offset += 1;
4267     /* Octet 14 to (n+4) Source ID */
4268     switch (source_type) {
4269     case 0:
4270         /* The Source Type is Cell ID for PS handover from GERAN A/Gb mode. In this case the coding of the Source ID field
4271          * shall be same as the Octets 3 to 10 of the Cell Identifier IEI in 3GPP TS 48.018 [34].
4272          */
4273         de_cell_id(tvb, tree, pinfo, offset, 8, NULL, 0);
4274         break;
4275     case 1:
4276         /* The Source Type is RNC ID for PS handover from GERAN Iu mode or for inter-RAT handover from UTRAN. In this
4277          * case the Source ID field shall be encoded as as the Source RNC-ID part of the "Source ID" parameter in 3GPP TS
4278          * 25.413 [33].
4279          */
4280         /* RNC-ID M INTEGER (0..4095) */
4281         break;
4282     case 2:
4283         break;
4284     default:
4285         proto_tree_add_expert(tree, pinfo, &ei_gtpv2_source_type_unknown, tvb, offset-1, 1);
4286         break;
4287     }
4288
4289 }
4290
4291  /*
4292   * 8.60 Bearer Control Mode
4293   */
4294 static const value_string gtpv2_bearer_control_mode_vals[] = {
4295     {0, "Selected Bearer Control Mode-'MS_only'"},
4296     {1, "Selected Bearer Control Mode-'Network_only'"},
4297     {2, "Selected Bearer Control Mode-'MS/NW'"},
4298     {0, NULL}
4299 };
4300
4301 static const value_string gtpv2_bearer_control_mode_short_vals[] = {
4302     {0, "MS_only"},
4303     {1, "Network_only"},
4304     {2, "MS/NW"},
4305     {0, NULL}
4306 };
4307
4308 static void
4309 dissect_gtpv2_bearer_control_mode(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
4310 {
4311     guint8  bcm;
4312
4313     proto_tree_add_item(tree, hf_gtpv2_bearer_control_mode, tvb, 0, 1, ENC_BIG_ENDIAN);
4314     /* Add Bearer Control Mode to tree */
4315     bcm = tvb_get_guint8(tvb, 0);
4316     proto_item_append_text(item, "%s", val_to_str_const(bcm, gtpv2_bearer_control_mode_short_vals, "Unknown"));
4317
4318 }
4319 /*
4320  * 8.61 Change Reporting Action
4321  */
4322 static const value_string gtpv2_cng_rep_act_vals[] = {
4323     {0, "Stop Reporting"},
4324     {1, "Start Reporting CGI/SAI"},
4325     {2, "Start Reporting RAI"},
4326     {3, "Start Reporting TAI"},
4327     {4, "Start Reporting ECGI"},
4328     {5, "Start Reporting CGI/SAI and RAI"},
4329     {6, "Start Reporting TAI and ECGI"},
4330     {0, NULL}
4331 };
4332
4333 static void
4334 dissect_gtpv2_cng_rep_act(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
4335 {
4336     guint8  action;
4337
4338     /* Add Action to tree */
4339     action = tvb_get_guint8(tvb, 0);
4340     proto_tree_add_item(tree, hf_gtpv2_cng_rep_act, tvb, 0, 1, ENC_BIG_ENDIAN);
4341
4342     proto_item_append_text(item, "%s", val_to_str_const(action, gtpv2_cng_rep_act_vals, "Unknown"));
4343 }
4344 /*
4345  * 8.62 Fully qualified PDN Connection Set Identifier (FQ-CSID)
4346  */
4347 #if 0
4348 static const value_string gtpv2_fq_csid_type_vals[] = {
4349     {0, "Global unicast IPv4 address"},
4350     {1, "Global unicast IPv6 address"},
4351     {2, "4 octets long field"},
4352     {0, NULL}
4353 };
4354 #endif
4355
4356 void
4357 dissect_gtpv2_fq_csid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
4358 {
4359     int         offset = 0;
4360     guint8      octet, node_id_type, csids;
4361     guint32     node_id, node_id_mcc_mnc;
4362
4363     /* Octet 5 Node-ID Type Number of CSIDs= m */
4364
4365     octet = tvb_get_guint8(tvb, offset);
4366     node_id_type = octet >> 4;
4367     csids = octet & 0x0f;
4368     proto_tree_add_item(tree, hf_gtpv2_fq_csid_type, tvb, offset, 1, ENC_BIG_ENDIAN);
4369     proto_tree_add_item(tree, hf_gtpv2_fq_csid_nr, tvb, offset, 1, ENC_BIG_ENDIAN);
4370     offset += 1;
4371
4372     switch (node_id_type) {
4373     case 0:
4374         /* Indicates that Node-ID is a global unicast IPv4 address and p = 9 */
4375         proto_tree_add_item(tree, hf_gtpv2_fq_csid_ipv4, tvb, offset, 4, ENC_BIG_ENDIAN);
4376         offset += 4;
4377         break;
4378     case 1:
4379         /* Indicates that Node-ID is a global unicast IPv6 address and p = 21 */
4380         proto_tree_add_item(tree, hf_gtpv2_fq_csid_ipv6, tvb, offset, 16, ENC_NA);
4381         offset += 16;
4382         break;
4383     case 2:
4384         /* Node-ID is a 4 octets long field with a 32 bit value stored in network order, and p= 9. The coding
4385          * of the field is specified below:
4386          * - Most significant 20 bits are the binary encoded value of (MCC * 1000 + MNC).
4387          * - Least significant 12 bits is a 12 bit integer assigned by an operator to an MME, SGW or PGW. Other values of
4388          *   Node-ID Type are reserved.
4389          */
4390         node_id = tvb_get_ntohl(tvb, offset);
4391         node_id_mcc_mnc = node_id >> 12;
4392         node_id = node_id & 0xfff;
4393         proto_tree_add_text(tree, tvb, offset, 4, "Node-ID: MCC+MNC %u, Id: %u", node_id_mcc_mnc, node_id);
4394         offset += 4;
4395         break;
4396     default:
4397         proto_tree_add_expert_format(tree, pinfo, &ei_gtpv2_fq_csid_type_bad, tvb, offset-1, 1,
4398                                      "Wrong Node-ID Type %u, should be 0-2(Or tis is a newer spec)", node_id_type);
4399         return;
4400     }
4401
4402     /* First PDN Connection Set Identifier (CSID)
4403      * Second PDN Connection Set Identifier (CSID)
4404      *  :
4405      * m-th PDN Connection Set Identifier (CSID)
4406      */
4407     while ( csids-- ) {
4408         proto_tree_add_item(tree, hf_gtpv2_fq_csid_id, tvb, offset, 2, ENC_BIG_ENDIAN);
4409         offset += 2;
4410     }
4411
4412 }
4413
4414 /*
4415  * 8.63 Channel needed
4416  */
4417 static void
4418 dissect_gtpv2_channel_needed(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
4419 {
4420     /* The Channel needed shall be coded as depicted in Figure 8.63-1. Channel needed is coded as the IEI part and the value
4421      * part of the Channel Needed IE defined in 3GPP TS 44.018[28]
4422      */
4423     de_rr_chnl_needed(tvb, tree, pinfo, 0, length, NULL, 0);
4424 }
4425
4426 /*
4427  * 8.64 eMLPP Priority
4428  * The eMLPP-Priority shall be coded as depicted in Figure 8.64-1. The eMLPP Priority is coded as the value part of the
4429  * eMLPP-Priority IE defined in 3GPP TS 48.008 [29] (not including 3GPP TS 48.008 IEI and 3GPP TS 48.008 [29]
4430  * length indicator).
4431  */
4432 static void
4433 dissect_gtpv2_emlpp_pri(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
4434 {
4435     be_emlpp_prio(tvb, tree, pinfo, 0, length, NULL, 0);
4436
4437 }
4438
4439 /*
4440  * 8.65 Node Type
4441  */
4442 static const value_string gtpv2_node_type_vals[] = {
4443     {0, "MME"},
4444     {1, "SGSN"},
4445     {0, NULL}
4446 };
4447
4448 static void
4449 dissect_gtpv2_node_type(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
4450 {
4451     guint8  node_type;
4452
4453     proto_tree_add_item(tree, hf_gtpv2_node_type, tvb, 0, 1, ENC_BIG_ENDIAN);
4454     /* Append Node Type to tree */
4455     node_type = tvb_get_guint8(tvb, 0);
4456     proto_item_append_text(item, "%s", val_to_str_const(node_type, gtpv2_node_type_vals, "Unknown"));
4457
4458 }
4459
4460  /*
4461   * 8.66 Fully Qualified Domain Name (FQDN)
4462   */
4463 static void
4464 dissect_gtpv2_fqdn(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length, guint8 message_type _U_, guint8 instance _U_)
4465 {
4466     int     offset = 0, name_len, tmp;
4467     guint8 *fqdn   = NULL;
4468
4469     /* The FQDN field encoding shall be identical to the encoding of
4470      * a FQDN within a DNS message of section 3.1 of IETF
4471      * RFC 1035 [31] but excluding the trailing zero byte.
4472      */
4473     if (length > 0) {
4474         name_len = tvb_get_guint8(tvb, offset);
4475
4476         if (name_len < 0x20) {
4477             fqdn = tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, length - 1, ENC_ASCII);
4478             for (;;) {
4479                 if (name_len >= length - 1)
4480                     break;
4481                 tmp = name_len;
4482                 name_len = name_len + fqdn[tmp] + 1;
4483                 fqdn[tmp] = '.';
4484             }
4485         } else {
4486             fqdn = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_ASCII);
4487         }
4488         proto_tree_add_string(tree, hf_gtpv2_fqdn, tvb, offset, length, fqdn);
4489         proto_item_append_text(item, "%s", fqdn);
4490     }
4491 }
4492
4493 /*
4494  * 8.67 Private Extension
4495  */
4496 static void
4497 dissect_gtpv2_private_ext(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance)
4498 {
4499     int       offset = 0;
4500     tvbuff_t *next_tvb;
4501     guint16   ext_id;
4502
4503     /* oct 5 -7 Enterprise ID */
4504     ext_id = tvb_get_ntohs(tvb, offset);
4505     proto_tree_add_item(tree, hf_gtpv2_enterprise_id, tvb, offset, 2, ENC_BIG_ENDIAN);
4506     offset += 2;
4507
4508     proto_item_append_text(item, "%s (%u)", val_to_str_ext_const(ext_id, &sminmpec_values_ext, "Unknown"), ext_id);
4509
4510     next_tvb = tvb_new_subset_length(tvb, offset, length-2);
4511     if (dissector_try_uint_new(gtpv2_priv_ext_dissector_table, ext_id, next_tvb, pinfo, tree, FALSE, GUINT_TO_POINTER((guint32)instance))){
4512         return;
4513     }
4514
4515     proto_tree_add_text(tree, tvb, offset, length-2, "Proprietary value");
4516 }
4517
4518 /*
4519  * 8.68 Transaction Identifier (TI)
4520  */
4521 static void
4522 dissect_gtpv2_ti(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
4523 {
4524     /* 5 to (n+4)  Transaction Identifier */
4525     proto_tree_add_item(tree, hf_gtpv2_ti, tvb, 0, length, ENC_NA);
4526
4527 }
4528
4529 /*
4530  * 8.69 MBMS Session Duration
4531  */
4532 void
4533 dissect_gtpv2_mbms_session_duration(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
4534 {
4535     int     offset     = 0;
4536     int     bit_offset = 0;
4537     guint32 days;
4538     guint32 hours;
4539     guint32 minutes;
4540     guint32 seconds;
4541
4542     /* From 3GPP TS 29.061 17.7.7 MBMS-Session-Duration AVP */
4543     /* Bits: ssss ssss ssss ssss sddd dddd where s bits = seconds, d bits = days */
4544     seconds = tvb_get_bits32(tvb, bit_offset, 17, ENC_BIG_ENDIAN);
4545     bit_offset += 17;
4546
4547     days = tvb_get_bits32(tvb, bit_offset, 7, ENC_BIG_ENDIAN);
4548
4549     /* Maximum allowed value for days: 18.
4550      * Maximum allowed value for seconds: 86,400 */
4551     if ((days > 18) || (seconds > 86400)) {
4552         proto_tree_add_text(tree, tvb, offset, offset + 3, "Days or Seconds out or allowed range");
4553     }
4554
4555     /* The lowest value of this AVP (i.e. all 0:s) is reserved to indicate an indefinite value to denote sessions that are expected to be always-on. */
4556     if ((seconds == 0) && (days == 0)) {
4557         proto_tree_add_item(tree, hf_gtpv2_mbms_session_duration_days, tvb, offset, 3, ENC_BIG_ENDIAN);
4558         proto_tree_add_item(tree, hf_gtpv2_mbms_session_duration_secs, tvb, offset, 3, ENC_BIG_ENDIAN);
4559         proto_item_append_text(item, "Indefinite (always-on)");
4560     } else {
4561         hours = seconds / 3600;
4562         minutes = (seconds % 3600) / 60;
4563         seconds = (seconds % 3600) % 60;
4564
4565         proto_tree_add_item(tree, hf_gtpv2_mbms_session_duration_days, tvb, offset, 3, ENC_BIG_ENDIAN);
4566         proto_tree_add_item(tree, hf_gtpv2_mbms_session_duration_secs, tvb, offset, 3, ENC_BIG_ENDIAN);
4567         proto_item_append_text(item, "%d days %02d:%02d:%02d (DD days HH:MM:SS)", days, hours, minutes, seconds);
4568     }
4569
4570     offset += 3;
4571     if (length > 3)
4572         proto_tree_add_text(tree, tvb, offset, length-3, "Spare: %s", tvb_bytes_to_ep_str(tvb, offset, length-3));
4573 }
4574
4575 /*
4576  * 8.70 MBMS Service Area
4577  */
4578 void
4579 dissect_gtpv2_mbms_service_area(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
4580 {
4581     int         offset = 0;
4582     proto_item *sai_item;
4583     guint8      binary_nr;
4584     guint16     real_nr;
4585     guint16     sai;
4586
4587     binary_nr = tvb_get_guint8(tvb, offset);
4588     real_nr = (guint16)binary_nr + 1;
4589
4590     /* 3GPP TS 29.061 17.7.6 MBMS-Service-Area AVP */
4591     proto_tree_add_uint(tree, hf_gtpv2_mbms_service_area_nr, tvb, offset, 1, real_nr);
4592     offset += 1;
4593
4594     /* A consecutive list of MBMS Service Area Identities follow, each with a length of two octets. */
4595     while (offset < length) {
4596         /* 3GPP TS 23.003 15.3 Structure of MBMS SAI */
4597         sai = tvb_get_ntohs(tvb, offset);
4598         sai_item = proto_tree_add_item(tree, hf_gtpv2_mbms_service_area_id, tvb, offset, 2, ENC_BIG_ENDIAN);
4599         /* The value 0 denotes the whole of PLMN as the MBMS Service Area */
4600         if (sai == 0) {
4601             proto_item_append_text(sai_item, " Entire PLMN");
4602         }
4603         proto_item_append_text(item, " %u", sai);
4604         offset += 2;
4605     }
4606 }
4607
4608 /*
4609  * 8.71 MBMS Session Identifier
4610  */
4611 static void
4612 dissect_gtpv2_mbms_session_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length, _U_ guint8 message_type _U_, guint8 instance _U_)
4613 {
4614     int offset = 0;
4615     /* One octet OctetString. */
4616     proto_tree_add_item(tree, hf_gtpv2_mbms_session_id, tvb, offset, 1, ENC_NA);
4617
4618     offset += 1;
4619     if (length > 1)
4620         proto_tree_add_text(tree, tvb, offset, length-1, "Spare: %s", tvb_bytes_to_ep_str(tvb, offset, length-1));
4621 }
4622
4623 /*
4624  * 8.72 MBMS Flow Identifier
4625  */
4626 static void
4627 dissect_gtpv2_mbms_flow_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
4628 {
4629     int offset = 0;
4630     /* Two octets OctetString. */
4631     proto_tree_add_item(tree, hf_gtpv2_mbms_flow_id, tvb, offset, 2, ENC_NA);
4632     proto_item_append_text(item, " %s", tvb_bytes_to_ep_str(tvb, offset, 2));
4633
4634     offset += 2;
4635     if (length > 2)
4636         proto_tree_add_text(tree, tvb, offset, length-2, "Spare: %s", tvb_bytes_to_ep_str(tvb, offset, length-2));
4637 }
4638
4639 /*
4640  * 8.73 MBMS IP Multicast Distribution
4641  */
4642 static const value_string gtpv2_mbms_hc_indicator_vals[] = {
4643     {0, "Uncompressed header"},
4644     {1, "Compressed header"},
4645     {0, NULL}
4646 };
4647
4648 static void
4649 dissect_gtpv2_mbms_ip_mc_dist(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
4650 {
4651     int offset = 0;
4652
4653     proto_tree_add_item(tree, hf_gtpv2_cteid, tvb, offset, 4, ENC_BIG_ENDIAN);
4654     offset += 4;
4655
4656     proto_tree_add_item(tree, hf_gtpv2_ip_addr_type, tvb, offset, 1, ENC_BIG_ENDIAN);
4657     proto_tree_add_item(tree, hf_gtpv2_ip_addr_len, tvb, offset, 1, ENC_BIG_ENDIAN);
4658     /* IP Multicast Distribution Address */
4659     if ((tvb_get_guint8(tvb, offset) & 0x3f) == 4) {
4660         offset += 1;
4661         proto_tree_add_item(tree, hf_gtpv2_mbms_ip_mc_dist_addrv4, tvb, offset, 4, ENC_BIG_ENDIAN);
4662         proto_item_append_text(item, " IPv4 Dist %s", tvb_ip_to_str(tvb, offset));
4663         offset += 4;
4664     } else if ((tvb_get_guint8(tvb, offset) & 0x3f) == 16) {
4665         offset += 1;
4666         proto_tree_add_item(tree, hf_gtpv2_mbms_ip_mc_dist_addrv6, tvb, offset, 16, ENC_NA);
4667         proto_item_append_text(item, " IPv6 Dist %s", tvb_ip6_to_str(tvb, offset));
4668         offset += 16;
4669     }
4670
4671     proto_tree_add_item(tree, hf_gtpv2_ip_addr_type, tvb, offset, 1, ENC_BIG_ENDIAN);
4672     proto_tree_add_item(tree, hf_gtpv2_ip_addr_len, tvb, offset, 1, ENC_BIG_ENDIAN);
4673     /* IP Multicast Source Address */
4674     if ((tvb_get_guint8(tvb, offset) & 0x3f) == 4) {
4675         offset += 1;
4676         proto_tree_add_item(tree, hf_gtpv2_mbms_ip_mc_src_addrv4, tvb, offset, 4, ENC_BIG_ENDIAN);
4677         proto_item_append_text(item, " IPv4 Src %s", tvb_ip_to_str(tvb, offset));
4678         offset += 4;
4679     } else if ((tvb_get_guint8(tvb, offset) & 0x3f) == 16) {
4680         offset += 1;
4681         proto_tree_add_item(tree, hf_gtpv2_mbms_ip_mc_src_addrv6, tvb, offset, 16, ENC_NA);
4682         proto_item_append_text(item, " IPv6 Src %s", tvb_ip6_to_str(tvb, offset));
4683         offset += 16;
4684     }
4685
4686     proto_tree_add_item(tree, hf_gtpv2_mbms_hc_indicator, tvb, offset, 1, ENC_BIG_ENDIAN);
4687
4688     offset += 1;
4689     if (length > offset)
4690         proto_tree_add_text(tree, tvb, offset, length-offset, "Spare: %s", tvb_bytes_to_ep_str(tvb, offset, length-offset));
4691
4692 }
4693
4694 /*
4695  * 8.74 MBMS Distribution Acknowledge
4696  */
4697 static const value_string gtpv2_mbms_dist_indication_vals[] = {
4698     {0, "No RNCs have accepted IP multicast distribution"},
4699     {1, "All RNCs have accepted IP multicast distribution"},
4700     {2, "Some RNCs have accepted IP multicast distribution"},
4701     {3, "Spare. For future use."},
4702     {0, NULL}
4703 };
4704
4705 static void
4706 dissect_gtpv2_mbms_dist_ack(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
4707 {
4708     int offset = 0;
4709
4710     proto_tree_add_item(tree, hf_gtpv2_mbms_dist_indication, tvb, offset, 1, ENC_BIG_ENDIAN);
4711
4712     offset += 1;
4713     if (length > 1)
4714         proto_tree_add_text(tree, tvb, offset, length-1, "Spare: %s", tvb_bytes_to_ep_str(tvb, offset, length-1));
4715 }
4716
4717 /*
4718  * 8.75 User CSG Information (UCI)
4719  */
4720 static void
4721 dissect_gtpv2_uci(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
4722 {
4723     proto_tree_add_expert(tree, pinfo, &ei_gtpv2_ie_data_not_dissected, tvb, 0, length);
4724 }
4725
4726 /* 8.76 CSG Information Reporting Action */
4727 static void
4728 dissect_gtpv2_csg_info_rep_action(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
4729 {
4730     proto_tree_add_expert(tree, pinfo, &ei_gtpv2_ie_data_not_dissected, tvb, 0, length);
4731 }
4732
4733 /* 8.77 RFSP Index */
4734 static void
4735 dissect_gtpv2_rfsp_index(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
4736 {
4737     int offset = 0;
4738
4739     if(instance == 0){
4740         proto_tree_add_item(tree, hf_gtpv2_subscriber_rfsp, tvb, offset, 2, ENC_BIG_ENDIAN);
4741     }else if(instance == 1){
4742         proto_tree_add_item(tree, hf_gtpv2_rfsp_inuse, tvb, offset, 2, ENC_BIG_ENDIAN);
4743     }
4744 }
4745
4746 /* 8.78 CSG ID */
4747 static void
4748 dissect_gtpv2_csg_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
4749 {
4750     proto_tree_add_expert(tree, pinfo, &ei_gtpv2_ie_data_not_dissected, tvb, 0, length);
4751 }
4752
4753 /* 8.79 CSG Membership Indication (CMI) */
4754 static void
4755 dissect_gtpv2_cmi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
4756 {
4757     proto_tree_add_expert(tree, pinfo, &ei_gtpv2_ie_data_not_dissected, tvb, 0, length);
4758 }
4759
4760 /* 8.80 Service indicator */
4761 static void
4762 dissect_gtpv2_service_indicator(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
4763 {
4764     proto_tree_add_expert(tree, pinfo, &ei_gtpv2_ie_data_not_dissected, tvb, 0, length);
4765 }
4766
4767 /* 8.81 Detach Type */
4768 static void
4769 dissect_gtpv2_detach_type(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
4770 {
4771     proto_tree_add_expert(tree, pinfo, &ei_gtpv2_ie_data_not_dissected, tvb, 0, length);
4772 }
4773
4774 /* 8.82 Local Distinguished Name (LDN) */
4775 static void
4776 dissect_gtpv2_ldn(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
4777 {
4778     proto_tree_add_expert(tree, pinfo, &ei_gtpv2_ie_data_not_dissected, tvb, 0, length);
4779 }
4780
4781 /* 8.83 Node Features */
4782 static void
4783 dissect_gtpv2_node_features(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
4784 {
4785     int offset = 0;
4786     proto_tree_add_item(tree, hf_gtpv2_node_features_prn, tvb, offset, 1, ENC_BIG_ENDIAN);
4787     proto_tree_add_item(tree, hf_gtpv2_node_features_mabr, tvb, offset, 1, ENC_BIG_ENDIAN);
4788     proto_tree_add_item(tree, hf_gtpv2_node_features_ntsr, tvb, offset, 1, ENC_BIG_ENDIAN);
4789     offset+=1;
4790     if (length > 1)
4791         proto_tree_add_text(tree, tvb, offset, length-1, "Spare: %s", tvb_bytes_to_ep_str(tvb, offset, length-1));
4792 }
4793
4794 /* 8.84
4795  * MBMS Time to Data Transfer
4796  */
4797 void
4798 dissect_gtpv2_mbms_time_to_data_xfer(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
4799 {
4800     int     offset = 0;
4801     guint8  binary_secs;
4802     guint16 real_secs;
4803
4804     binary_secs = tvb_get_guint8(tvb, offset);
4805     real_secs = (guint16)binary_secs + 1;
4806
4807     proto_tree_add_string_format_value(tree, hf_gtpv2_time_to_data_xfer, tvb, offset, 1, "", "%d second(s)", real_secs);
4808     proto_item_append_text(item, " %u second(s)", real_secs);
4809     offset += 1;
4810     if (length > 1)
4811         proto_tree_add_text(tree, tvb, offset, length-1, "Spare: %s", tvb_bytes_to_ep_str(tvb, offset, length-1));
4812 }
4813
4814 /* 8.85 Throttling */
4815 static void
4816 dissect_gtpv2_throttling(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
4817 {
4818     proto_tree_add_expert(tree, pinfo, &ei_gtpv2_ie_data_not_dissected, tvb, 0, length);
4819 }
4820
4821 /* 8.86 Allocation/Retention Priority (ARP) */
4822 void
4823 dissect_gtpv2_arp(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
4824 {
4825     int offset = 0;
4826
4827     proto_tree_add_item(tree, hf_gtpv2_arp_pvi, tvb, offset, 1, ENC_BIG_ENDIAN);
4828     proto_tree_add_item(tree, hf_gtpv2_arp_pl, tvb, offset, 1, ENC_BIG_ENDIAN);
4829     proto_tree_add_item(tree, hf_gtpv2_arp_pci, tvb, offset, 1, ENC_BIG_ENDIAN);
4830
4831     offset += 1;
4832     if (length > 1)
4833         proto_tree_add_text(tree, tvb, offset, length-1, "Spare: %s", tvb_bytes_to_ep_str(tvb, offset, length-1));
4834 }
4835
4836 /* 8.87 EPC Timer */
4837 static const value_string gtpv2_timer_unit_vals[] = {
4838     {0, "value is incremented in multiples of 2 seconds"},
4839     {1, "value is incremented in multiples of 1 minute"},
4840     {2, "value is incremented in multiples of 10 minutes"},
4841     {3, "value is incremented in multiples of 1 hour"},
4842     {4, "value is incremented in multiples of 1 hour"},
4843     {5, "Other values shall be interpreted as multiples of 1 minute(version 10.7.0)"},
4844     {6, "Other values shall be interpreted as multiples of 1 minute(version 10.7.0)"},
4845     {7, "value indicates that the timer is infinite"},
4846     {0, NULL}
4847 };
4848
4849 void
4850 dissect_gtpv2_epc_timer(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
4851 {
4852     proto_tree_add_item(tree, hf_gtpv2_timer_unit, tvb, 0, 1, ENC_BIG_ENDIAN);
4853     proto_tree_add_item(tree, hf_gtpv2_timer_value, tvb, 0, 1, ENC_BIG_ENDIAN);
4854
4855 }
4856
4857 /* 8.88 Signalling Priority Indication */
4858 static void
4859 dissect_gtpv2_sig_prio_ind(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
4860 {
4861     proto_tree_add_item(tree, hf_gtpv2_lapi, tvb, 0, 1, ENC_BIG_ENDIAN);
4862 }
4863
4864 /* 8.89 Temporary Mobile Group Identity (TMGI) */
4865 static void
4866 dissect_gtpv2_tmgi(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
4867 {
4868     int     offset = 0;
4869     guint64 tmgi;
4870
4871     tmgi = tvb_get_ntoh48(tvb, offset);
4872
4873     proto_item_append_text(item, "%012" G_GINT64_MODIFIER "x", tmgi);
4874
4875     proto_tree_add_item(tree, hf_gtpv2_mbms_service_id, tvb, offset, 3, ENC_NA);
4876     offset += 3;
4877
4878     dissect_e212_mcc_mnc(tvb, pinfo, tree, offset, TRUE);
4879     offset += 3;
4880
4881     if (length > offset)
4882         proto_tree_add_text(tree, tvb, offset, length-offset, "Spare: %s", tvb_bytes_to_ep_str(tvb, offset, length-offset));
4883 }
4884
4885 /*
4886  * 8.90 Additional MM context for SRVCC
4887  * 3GPP TS 29.274 Figure 8.90-1
4888  */
4889 static void
4890 dissect_gtpv2_add_mm_cont_for_srvcc(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
4891 {
4892     int         offset = 0;
4893     proto_item *ms_cm_item;
4894     proto_tree *ms_cm_tree;
4895     guint8      elm_len;
4896
4897     /* Length of Mobile Station Classmark 2 */
4898     elm_len = tvb_get_guint8(tvb, offset);
4899     proto_tree_add_item(tree, hf_gtpv2_len_ms_classmark2, tvb, offset, 1, ENC_BIG_ENDIAN);
4900     offset += 1;
4901     ms_cm_item = proto_tree_add_text(tree, tvb, offset, elm_len, "Mobile Station Classmark 2  %s", tvb_bytes_to_ep_str(tvb, offset, elm_len));
4902     ms_cm_tree = proto_item_add_subtree(ms_cm_item, ett_gtpv2_ms_mark);
4903     /* Mobile Station Classmark 2 */
4904     de_ms_cm_2(tvb, ms_cm_tree, pinfo, offset, elm_len, NULL, 0);
4905     offset += elm_len;
4906
4907     /* Length of Mobile Station Classmark 3 */
4908     elm_len = tvb_get_guint8(tvb, offset);
4909     proto_tree_add_item(tree, hf_gtpv2_len_ms_classmark3, tvb, offset, 1, ENC_BIG_ENDIAN);
4910     offset += 1;
4911     ms_cm_item = proto_tree_add_text(tree, tvb, offset, elm_len, "Mobile Station Classmark3  %s", tvb_bytes_to_ep_str(tvb, offset, elm_len));
4912     ms_cm_tree = proto_item_add_subtree(ms_cm_item, ett_gtpv2_ms_mark);
4913     /* Mobile Station Classmark 3 */
4914     de_ms_cm_3(tvb, ms_cm_tree, pinfo, offset, elm_len, NULL, 0);
4915     offset += elm_len;
4916
4917     /* Length of Supported Codec List */
4918     elm_len = tvb_get_guint8(tvb, offset);
4919     proto_tree_add_item(tree, hf_gtpv2_len_supp_codec_list, tvb, offset, 1, ENC_BIG_ENDIAN);
4920     offset += 1;
4921     ms_cm_item = proto_tree_add_text(tree, tvb, offset, elm_len, "Supported Codec List  %s", tvb_bytes_to_ep_str(tvb, offset, elm_len));
4922     ms_cm_tree = proto_item_add_subtree(ms_cm_item, ett_gtpv2_supp_codec_list);
4923     /* Supported Codec List */
4924     de_sup_codec_list(tvb, ms_cm_tree, pinfo, offset, elm_len, NULL, 0);
4925     offset += elm_len;
4926
4927     if (length > offset)
4928         proto_tree_add_text(tree, tvb, offset, length-offset, "Spare: %s", tvb_bytes_to_ep_str(tvb, offset, length-offset));
4929 }
4930
4931 /* 8.91 Additional flags for SRVCC */
4932 static void
4933 dissect_gtpv2_add_flags_for_srvcc(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
4934 {
4935     int offset = 0;
4936
4937     proto_tree_add_item(tree, hf_gtpv2_add_flags_for_srvcc_ics, tvb, offset, 1, ENC_BIG_ENDIAN);
4938     proto_tree_add_item(tree, hf_gtpv2_vsrvcc_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
4939     offset += 1;
4940
4941     if (length > 1)
4942         proto_tree_add_text(tree, tvb, offset, length-1, "Spare: %s", tvb_bytes_to_ep_str(tvb, offset, length-1));
4943 }
4944
4945 /* 8.92 Max MBR/APN-AMBR (MMBR) */
4946 static void
4947 dissect_gtpv2_mmbr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
4948 {
4949     int     offset = 0;
4950     guint32 max_ul;
4951     guint32 max_dl;
4952
4953     max_ul = tvb_get_ntohl(tvb, offset);
4954     proto_tree_add_uint_format_value(tree, hf_gtpv2_mmbr_ul, tvb, offset, 4, max_ul, "%u %s",
4955                                 (max_ul) > 1000 ? max_ul/1000 : max_ul,
4956                                 (max_ul) > 1000 ? "Mbps" : "kbps");
4957
4958     offset += 4;
4959
4960     max_dl = tvb_get_ntohl(tvb, offset);
4961     proto_tree_add_uint_format_value(tree, hf_gtpv2_mmbr_dl, tvb, offset, 4, max_dl, "%u %s",
4962                                 (max_dl) > 1000 ? max_dl/1000 : max_dl,
4963                                 (max_dl) > 1000 ? "Mbps" : "kbps");
4964 }
4965
4966 /* 8.93 MDT Configuration */
4967 static void
4968 dissect_gtpv2_mdt_config(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
4969 {
4970     proto_tree_add_expert(tree, pinfo, &ei_gtpv2_ie_data_not_dissected, tvb, 0, length);
4971 }
4972
4973 /* 8.94 Additional Protocol Configuration Options (APCO) */
4974 static void
4975 dissect_gtpv2_apco(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
4976 {
4977     switch (message_type) {
4978     case GTPV2_CREATE_SESSION_REQUEST:
4979         /* PCO options as MS to network direction */
4980         pinfo->link_dir = P2P_DIR_UL;
4981         break;
4982     case GTPV2_CREATE_SESSION_RESPONSE:
4983         /* PCO options as Network to MS direction: */
4984         pinfo->link_dir = P2P_DIR_DL;
4985         break;
4986     default:
4987         break;
4988     }
4989     de_sm_pco(tvb, tree, pinfo, 0, length, NULL, 0);
4990 }
4991
4992 /* 8.95 Absolute Time of MBMS Data Transfer */
4993 static void
4994 dissect_gtpv2_abs_mbms_data_tf_time(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
4995 {
4996     int          offset = 0;
4997     const gchar *time_str;
4998
4999     time_str = tvb_ntp_fmt_ts(tvb, offset);
5000     proto_tree_add_string(tree, hf_gtpv2_abs_time_mbms_data, tvb, offset, 8, time_str);
5001     proto_item_append_text(item, "%s", time_str);
5002
5003     offset += 8;
5004     if (length > offset)
5005         proto_tree_add_text(tree, tvb, offset, length-offset, "Spare: %s", tvb_bytes_to_ep_str(tvb, offset, length-offset));
5006 }
5007
5008 /* 8.96 H(e)NB Information Reporting */
5009 static const true_false_string gtpv2_henb_info_report_fti_vals = {
5010     "Start reporting H(e)NB local IP address and UDP port number information change",
5011     "Stop reporting H(e)NB local IP address and UDP port number information change",
5012 };
5013
5014 static void
5015 dissect_gtpv2_henb_info_report(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
5016 {
5017     int offset = 0;
5018
5019     proto_tree_add_item(tree, hf_gtpv2_henb_info_report_fti, tvb, offset, 1, ENC_BIG_ENDIAN);
5020     offset += 1;
5021
5022     if (length > 1)
5023         proto_tree_add_text(tree, tvb, offset, length-1, "Spare: %s", tvb_bytes_to_ep_str(tvb, offset, length-1));
5024 }
5025
5026 /* 8.97 IPv4 Configuration Parameters (IP4CP) */
5027 static void
5028 dissect_gtpv2_ip4cp(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
5029 {
5030     int offset = 0;
5031
5032     proto_tree_add_item(tree, hf_gtpv2_ip4cp_subnet_prefix_len, tvb, offset, 1, ENC_BIG_ENDIAN);
5033     offset += 1;
5034     proto_tree_add_item(tree, hf_gtpv2_ip4cp_ipv4, tvb, offset, 4, ENC_BIG_ENDIAN);
5035     offset += 4;
5036
5037     if (length > offset)
5038         proto_tree_add_text(tree, tvb, offset, length-offset, "Spare: %s", tvb_bytes_to_ep_str(tvb, offset, length-offset));
5039 }
5040
5041 /* 8.98 Change to Report Flags */
5042 static void
5043 dissect_gtpv2_change_report_flags(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
5044 {
5045     int offset = 0;
5046
5047     proto_tree_add_item(tree, hf_gtpv2_change_report_flags_sncr, tvb, offset, 1, ENC_BIG_ENDIAN);
5048     proto_tree_add_item(tree, hf_gtpv2_change_report_flags_tzcr, tvb, offset, 1, ENC_BIG_ENDIAN);
5049     offset += 1;
5050
5051     if (length > 1)
5052         proto_tree_add_text(tree, tvb, offset, length-1, "Spare: %s", tvb_bytes_to_ep_str(tvb, offset, length-1));
5053 }
5054
5055 /* 8.99 Action Indication */
5056 static const value_string gtpv2_action_indication_vals[] = {
5057     { 0, "No Action"},
5058     { 1, "Deactivation Indication"},
5059     { 2, "Paging Indication"},
5060     { 3, "Spare"},
5061     { 4, "Spare"},
5062     { 5, "Spare"},
5063     { 6, "Spare"},
5064     { 7, "Spare"},
5065     { 0, NULL}
5066 };
5067 static value_string_ext gtpv2_action_indication_vals_ext = VALUE_STRING_EXT_INIT(gtpv2_action_indication_vals);
5068
5069 static void
5070 dissect_gtpv2_action_indication(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
5071 {
5072     int offset = 0;
5073
5074     proto_tree_add_item(tree, hf_gtpv2_action_indication_val, tvb, offset, 1, ENC_BIG_ENDIAN);
5075     offset += 1;
5076
5077     if (length > 1)
5078         proto_tree_add_text(tree, tvb, offset, length-1, "Spare: %s", tvb_bytes_to_ep_str(tvb, offset, length-1));
5079 }
5080
5081 typedef struct _gtpv2_ie {
5082     int ie_type;
5083     void (*decode) (tvbuff_t *, packet_info *, proto_tree *, proto_item *, guint16, guint8, guint8);
5084 } gtpv2_ie_t;
5085
5086 static const gtpv2_ie_t gtpv2_ies[] = {
5087     {GTPV2_IE_IMSI, dissect_gtpv2_imsi},                                   /* 1, Internal Mobile Subscriber Identity (IMSI) */
5088     {GTPV2_IE_CAUSE, dissect_gtpv2_cause},                                 /* 2, Cause (without embedded offending IE) 8.4 */
5089     {GTPV2_REC_REST_CNT, dissect_gtpv2_recovery},                          /* 3, Recovery (Restart Counter) 8.5 */
5090                                                                            /* 4-50 Reserved for S101 interface Extendable / See 3GPP TS 29.276 [14] */
5091     /*Start SRVCC Messages 3GPP TS 29.280 */
5092     {GTPV2_IE_STN_SR, dissect_gtpv2_stn_sr},                               /* 51 STN-SR */
5093     {GTPV2_IE_SRC_TGT_TRANS_CON, dissect_gtpv2_src_tgt_trans_con},         /* 52 Source to Target Transparent Container */
5094     {GTPV2_IE_TGT_SRC_TRANS_CON , dissect_gtpv2_tgt_src_trans_con},        /* 53 Target to Source Transparent Container */
5095     {GTPV2_IE_MM_CON_EUTRAN_SRVCC, dissect_gtpv2_mm_con_eutran_srvcc},     /* 54 MM Context for E-UTRAN SRVCC */
5096     {GTPV2_IE_MM_CON_UTRAN_SRVCC, dissect_gtpv2_mm_con_utran_srvcc},       /* 55 MM Context for UTRAN SRVCC */
5097     {GTPV2_IE_SRVCC_CAUSE, dissect_gtpv2_srvcc_cause},                     /* 56 SRVCC Cause */
5098     {GTPV2_IE_TGT_RNC_ID, dissect_gtpv2_tgt_rnc_id},                       /* 57 Target RNC ID */
5099     {GTPV2_IE_TGT_GLOGAL_CELL_ID, dissect_gtpv2_tgt_global_cell_id},       /* 58 Target Global Cell ID */
5100     {GTPV2_IE_TEID_C, dissect_gtpv2_teid_c},                               /* 59 TEID-C */
5101     {GTPV2_IE_SV_FLAGS, dissect_gtpv2_sv_flags},                           /* 60 Sv Flags */
5102     {GTPV2_IE_SAI, dissect_gtpv2_sai},                                     /* 61 Service Area Identifie */
5103                                                                            /* 61-70 Reserved for Sv interface Extendable / See 3GPP TS 29.280 [15] */
5104
5105     {GTPV2_APN, dissect_gtpv2_apn},                                        /* 71, Access Point Name (APN) 8.6 */
5106     {GTPV2_AMBR, dissect_gtpv2_ambr},                                      /* 72, Aggregate Maximum Bit Rate (AMBR) */
5107     {GTPV2_EBI, dissect_gtpv2_ebi},                                        /* 73, EPS Bearer ID (EBI)  8.8 */
5108     {GTPV2_IP_ADDRESS, dissect_gtpv2_ip_address},                          /* 74, IP Address */
5109     {GTPV2_MEI, dissect_gtpv2_mei},                                        /* 74, Mobile Equipment Identity */
5110     {GTPV2_IE_MSISDN, dissect_gtpv2_msisdn},                               /* 76, MSISDN 8.11 */
5111     {GTPV2_INDICATION, dissect_gtpv2_ind},                                 /* 77 Indication 8.12 */
5112     {GTPV2_PCO, dissect_gtpv2_pco},                                        /* 78 Protocol Configuration Options (PCO) 8.13 */
5113     {GTPV2_PAA, dissect_gtpv2_paa},                                        /* 79 PDN Address Allocation (PAA) 8.14 */
5114     {GTPV2_BEARER_QOS, dissect_gtpv2_bearer_qos},                          /* 80 Bearer Level Quality of Service (Bearer QoS) 8.15 */
5115     {GTPV2_IE_FLOW_QOS, dissect_gtpv2_flow_qos},                           /* 81 Flow Quality of Service (Flow QoS) 8.16 */
5116     {GTPV2_IE_RAT_TYPE, dissect_gtpv2_rat_type},                           /* 82, RAT Type  8.17 */
5117     {GTPV2_IE_SERV_NET, dissect_gtpv2_serv_net},                           /* 83, Serving Network 8.18 */
5118     {GTPV2_IE_BEARER_TFT, dissect_gtpv2_bearer_tft},                       /* 84, Bearer TFT 8.19 */
5119     {GTPV2_IE_TAD, dissect_gtpv2_tad},                                     /* 85, Traffic Aggregate Description 8.20 */
5120     {GTPV2_IE_ULI, dissect_gtpv2_uli},                                     /* 86, User Location Info (ULI) 8.22 */
5121     {GTPV2_IE_F_TEID, dissect_gtpv2_f_teid},                               /* 87, Fully Qualified Tunnel Endpoint Identifier (F-TEID) 8.23 */
5122     {GTPV2_IE_TMSI, dissect_gtpv2_tmsi},                                   /* 88, TMSI 8.23 */
5123     {GTPV2_IE_GLOBAL_CNID, dissect_gtpv2_g_cn_id},                         /* 89, Global CN-Id 8.25 */
5124     {GTPV2_IE_S103PDF, dissect_gtpv2_s103pdf},                             /* 90, S103 PDN Data Forwarding Info (S103PDF) 8.25 */
5125     {GTPV2_IE_S1UDF, dissect_gtpv2_s1udf},                                 /* 91, S1-U Data Forwarding (S1UDF) 8.26 */
5126     {GTPV2_IE_DEL_VAL, dissect_gtpv2_delay_value},                         /* 92, Delay Value 8.29 */
5127     {GTPV2_IE_BEARER_CTX, dissect_gtpv2_bearer_ctx},                       /* 93, Bearer Context  8.31 */
5128     {GTPV2_IE_CHAR_ID, dissect_gtpv2_charging_id},                         /* 94, Charging Id */
5129     {GTPV2_IE_CHAR_CHAR, dissect_gtpv2_char_char},                         /* 95 Charging Characteristic */
5130     {GTPV2_IE_TRA_INFO, dissect_gtpv2_tra_info},                           /* 96, Trace Information 8.31 */
5131     {GTPV2_BEARER_FLAG, dissect_gtpv2_bearer_flag},                        /* 97, Bearer Flag */
5132                                                                            /* 98, Void 8.33 */
5133     {GTPV2_IE_PDN_TYPE, dissect_gtpv2_pdn_type},                           /* 99, PDN Type */
5134     {GTPV2_IE_PTI, dissect_gtpv2_pti},                                     /* 100, Procedure Transaction Id */
5135     {GTPV2_IE_DRX_PARAM, dissect_gtpv2_drx_param},                         /* 101, DRX Parameter 8.36 */
5136     {GTPV2_IE_UE_NET_CAPABILITY, dissect_gtpv2_ue_net_capability},         /* 102, UE network capability 8.37 */
5137     {GTPV2_IE_MM_CONTEXT_GSM_T, dissect_gtpv2_mm_context_gsm_t},           /* 103, MM Context 8.38 GSM Key and Triplets */
5138     {GTPV2_IE_MM_CONTEXT_UTMS_CQ, dissect_gtpv2_mm_context_utms_cq},       /* 104, MM Context 8.38 */
5139     {GTPV2_IE_MM_CONTEXT_GSM_CQ, dissect_gtpv2_mm_context_gsm_cq},         /* 105, MM Context 8.38 */
5140     {GTPV2_IE_MM_CONTEXT_UTMS_Q, dissect_gtpv2_mm_context_utms_q},         /* 106, MM Context 8.38 */
5141     {GTPV2_IE_MM_CONTEXT_EPS_QQ, dissect_gtpv2_mm_context_eps_qq},         /* 107, MM Context 8.38 */
5142     {GTPV2_IE_MM_CONTEXT_UTMS_QQ, dissect_gtpv2_mm_context_utms_qq},       /* 108, MM Context 8.38 */
5143     {GTPV2_IE_PDN_CONNECTION, dissect_gtpv2_PDN_conn},                     /* 109, PDN Connection */
5144     {GTPV2_IE_PDN_NUMBERS, dissect_gtpv2_pdn_numbers},                     /* 110, PDN Numbers 8.40 */
5145     {GTPV2_IE_P_TMSI, dissect_gtpv2_p_tmsi},                               /* 111, P-TMSI 8.41 */
5146     {GTPV2_IE_P_TMSI_SIG, dissect_gtpv2_p_tmsi_sig},                       /* 112, P-TMSI Signature 8.42 */
5147     {GTPV2_IE_HOP_COUNTER, dissect_gtpv2_hop_counter},                     /* 113, Hop Counter 8.43 */
5148     {GTPV2_IE_UE_TIME_ZONE, dissect_gtpv2_ue_time_zone},                   /* 114, UE Time Zone */
5149     {GTPV2_IE_TRACE_REFERENCE, dissect_gtpv2_trace_reference},             /* 115, Trace Reference 8.45 */
5150     {GTPV2_IE_COMPLETE_REQUEST_MSG, dissect_complete_request_msg},         /* 116, Complete Request message 8.46 */
5151     {GTPV2_IE_GUTI, dissect_gtpv2_guti},                                   /* 117, GUTI 8.47 */
5152     {GTPV2_IE_F_CONTAINER, dissect_gtpv2_F_container},                     /* 118, Fully Qualified Container (F-Container) */
5153     {GTPV2_IE_F_CAUSE, dissect_gtpv2_F_cause},                             /* 119, Fully Qualified Cause (F-Cause) */
5154     {GTPV2_IE_SEL_PLMN_ID, dissect_gtpv2_sel_plmn_id},                     /* 120, Selected PLMN ID 8.50 */
5155     {GTPV2_IE_TARGET_ID, dissect_gtpv2_target_id},                         /* 121, Target Identification */
5156                                                                            /* 122, Void 8.52 */
5157     {GTPV2_IE_PKT_FLOW_ID, dissect_gtpv2_pkt_flow_id},                     /* 123, Packet Flow ID 8.53 */
5158     {GTPV2_IE_RAB_CONTEXT, dissect_gtpv2_rab_context},                     /* 124, RAB Context 8.54 */
5159     {GTPV2_IE_S_RNC_PDCP_CTX_INFO, dissect_gtpv2_s_rnc_pdcp_ctx_info},     /* 125, Source RNC PDCP context info 8.55 */
5160     {GTPV2_IE_UDP_S_PORT_NR, dissect_udp_s_port_nr},                       /* 126, UDP Source Port Number 8.56 */
5161     {GTPV2_IE_APN_RESTRICTION, dissect_gtpv2_apn_rest},                    /* 127, APN Restriction */
5162     {GTPV2_IE_SEL_MODE, dissect_gtpv2_selec_mode},                         /* 128, Selection Mode */
5163     {GTPV2_IE_SOURCE_IDENT, dissect_gtpv2_source_ident},                   /* 129, Source Identification 8.59 */
5164     {GTPV2_IE_BEARER_CONTROL_MODE, dissect_gtpv2_bearer_control_mode},     /* 130, Bearer Control Mode */
5165     {GTPV2_IE_CNG_REP_ACT , dissect_gtpv2_cng_rep_act},                    /* 131, Change Reporting Action 8.61 */
5166     {GTPV2_IE_FQ_CSID, dissect_gtpv2_fq_csid},                             /* 132, Fully Qualified PDN Connection Set Identifier (FQ-CSID) 8.62 */
5167     {GTPV2_IE_CHANNEL_NEEDED, dissect_gtpv2_channel_needed},               /* 133, Channel Needed 8.63 */
5168     {GTPV2_IE_EMLPP_PRI, dissect_gtpv2_emlpp_pri},                         /* 134, eMLPP Priority 8.64 */
5169     {GTPV2_IE_NODE_TYPE , dissect_gtpv2_node_type},                        /* 135, Node Type 8.65 */
5170     {GTPV2_IE_FQDN, dissect_gtpv2_fqdn},                                   /* 136, 8.66 Fully Qualified Domain Name (FQDN) */
5171     {GTPV2_IE_TI, dissect_gtpv2_ti},                                       /* 137, 8.68 Transaction Identifier (TI) */
5172     {GTPV2_IE_MBMS_SESSION_DURATION, dissect_gtpv2_mbms_session_duration}, /* 138, 8.69 MBMS Session Duration */
5173     {GTPV2_IE_MBMS_SERVICE_AREA, dissect_gtpv2_mbms_service_area},         /* 139, 8.70 MBMS Service Area */
5174     {GTPV2_IE_MBMS_SESSION_ID, dissect_gtpv2_mbms_session_id},             /* 140, 8.71 MBMS Session Identifier */
5175     {GTPV2_IE_MBMS_FLOW_ID, dissect_gtpv2_mbms_flow_id},                   /* 141, 8.72 MBMS Flow Identifier */
5176     {GTPV2_IE_MBMS_IP_MC_DIST, dissect_gtpv2_mbms_ip_mc_dist},             /* 142, 8.73 MBMS IP Multicast Distribution */
5177     {GTPV2_IE_MBMS_DIST_ACK, dissect_gtpv2_mbms_dist_ack},                 /* 143, 8.74 MBMS Distribution Acknowledge */
5178     {GTPV2_IE_RFSP_INDEX, dissect_gtpv2_rfsp_index},                       /* 144, 8.77 RFSP Index */
5179     {GTPV2_IE_UCI, dissect_gtpv2_uci},                                     /* 145, 8.75 User CSG Information (UCI) */
5180     {GTPV2_IE_CSG_INFO_REP_ACTION, dissect_gtpv2_csg_info_rep_action},     /* 146, 8.76 CSG Information Reporting Action */
5181     {GTPV2_IE_CSG_ID, dissect_gtpv2_csg_id},                               /* 147, 8.78 CSG ID */
5182     {GTPV2_IE_CMI, dissect_gtpv2_cmi},                                     /* 148, 8.79 CSG Membership Indication (CMI) */
5183     {GTPV2_IE_SERVICE_INDICATOR, dissect_gtpv2_service_indicator},         /* 149, 8.80 Service indicator */
5184     {GTPV2_IE_DETACH_TYPE, dissect_gtpv2_detach_type},                     /* 150, 8.81 Detach Type */
5185     {GTPV2_IE_LDN, dissect_gtpv2_ldn},                                     /* 151, 8.82 Local Distinguished Name (LDN) */
5186     {GTPV2_IE_NODE_FEATURES, dissect_gtpv2_node_features},                 /* 152, 8.83 Node Features */
5187     {GTPV2_IE_MBMS_TIME_TO_DATA_XFER, dissect_gtpv2_mbms_time_to_data_xfer}, /* 153, 8.84 MBMS Time to Data Transfer */
5188     {GTPV2_IE_THROTTLING, dissect_gtpv2_throttling},                       /* 154, 8.85 Throttling */
5189     {GTPV2_IE_ARP, dissect_gtpv2_arp},                                     /* 155, 8.86 Allocation/Retention Priority (ARP) */
5190     {GTPV2_IE_EPC_TIMER, dissect_gtpv2_epc_timer},                         /* 156, 8.87 EPC Timer */
5191     {GTPV2_IE_SIG_PRIO_IND, dissect_gtpv2_sig_prio_ind},                   /* 157, 8.88 Signalling Priority Indication */
5192     {GTPV2_IE_TMGI, dissect_gtpv2_tmgi},                                   /* 158, 8.89 Temporary Mobile Group Identity (TMGI) */
5193     {GTPV2_IE_ADD_MM_CONT_FOR_SRVCC, dissect_gtpv2_add_mm_cont_for_srvcc}, /* 159, 8.90 Additional MM context for SRVCC */
5194     {GTPV2_IE_ADD_FLAGS_FOR_SRVCC, dissect_gtpv2_add_flags_for_srvcc},     /* 160, 8.91 Additional flags for SRVCC */
5195     {GTPV2_IE_MMBR, dissect_gtpv2_mmbr},                                   /* 161, 8.92 Max MBR/APN-AMBR (MMBR) */
5196     {GTPV2_IE_MDT_CONFIG, dissect_gtpv2_mdt_config},                       /* 162, 8.93 MDT Configuration */
5197     {GTPV2_IE_APCO, dissect_gtpv2_apco},                                   /* 163, 8.94 Additional Protocol Configuration Options (APCO) */
5198     {GTPV2_IE_ABS_MBMS_DATA_TF_TIME, dissect_gtpv2_abs_mbms_data_tf_time}, /* 164, 8.95 Absolute Time of MBMS Data Transfer */
5199     {GTPV2_IE_HENB_INFO_REPORT, dissect_gtpv2_henb_info_report}, /* 165, 8.96 H(e)NB Information Reporting */
5200     {GTPV2_IE_IP4CP, dissect_gtpv2_ip4cp}, /* 166, 8.97 IPv4 Configuration Parameters (IPv4CP) */
5201     {GTPV2_IE_CHANGE_TO_REPORT_FLAGS, dissect_gtpv2_change_report_flags}, /* 167, 8.98 Change to Report Flags */
5202     {GTPV2_IE_ACTION_INDICATION, dissect_gtpv2_action_indication}, /* 168, 8.99 Action Indication */
5203                                                     /* 169-254 Spare. For future use. FFS */
5204     {GTPV2_IE_PRIVATE_EXT, dissect_gtpv2_private_ext},
5205
5206     {0, dissect_gtpv2_unknown}
5207 };
5208
5209 static void
5210 dissect_gtpv2_ie_common(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, gint offset, guint8 message_type)
5211 {
5212     proto_tree *ie_tree;
5213     proto_item *ti;
5214     tvbuff_t   *ie_tvb;
5215     guint8      type, instance;
5216     guint16     length;
5217     int         i;
5218     /*
5219      * Octets   8   7   6   5       4   3   2   1
5220      *  1       Type
5221      *  2-3     Length = n
5222      *  4       CR          Spare   Instance
5223      * 5-(n+4)  IE specific data
5224      */
5225     while (offset < (gint)tvb_reported_length(tvb)) {
5226         /* Get the type and length */
5227
5228         type    = tvb_get_guint8(tvb, offset);
5229         length  = tvb_get_ntohs(tvb, offset + 1);
5230         ti      = proto_tree_add_text(tree, tvb, offset, 4 + length, "%s : ",
5231                                       val_to_str_ext_const(type, &gtpv2_element_type_vals_ext, "Unknown"));
5232         ie_tree = proto_item_add_subtree(ti, ett_gtpv2_ie);
5233
5234         /* Octet 1 */
5235         proto_tree_add_item(ie_tree, hf_gtpv2_ie, tvb, offset, 1, ENC_BIG_ENDIAN);
5236         offset += 1;
5237
5238         /*Octet 2 - 3 */
5239         proto_tree_add_item(ie_tree, hf_gtpv2_ie_len, tvb, offset, 2, ENC_BIG_ENDIAN);
5240         offset += 2;
5241         /* CR Spare Instance Octet 4*/
5242         proto_tree_add_item(ie_tree, hf_gtpv2_cr, tvb, offset, 1, ENC_BIG_ENDIAN);
5243
5244         instance = tvb_get_guint8(tvb, offset) & 0x0f;
5245         proto_tree_add_item(ie_tree, hf_gtpv2_instance, tvb, offset, 1, ENC_BIG_ENDIAN);
5246         offset += 1;
5247
5248         /* TODO: call IE dissector here */
5249         if (type == GTPV2_IE_RESERVED) {
5250             /* Treat IE type zero specal as type zero is used to end the loop in the else branch */
5251             proto_tree_add_text(ie_tree, tvb, offset, length, "IE type Zero is Reserved and should not be used");
5252         } else {
5253             i = -1;
5254             /* Loop over the IE dissector list to se if we find an entry;
5255                the last entry will have ie_type=0 breaking the loop */
5256             while (gtpv2_ies[++i].ie_type) {
5257                 if (gtpv2_ies[i].ie_type == type)
5258                     break;
5259             }
5260             /* Just give the IE dissector the IE */
5261             ie_tvb = tvb_new_subset_remaining(tvb, offset);
5262             (*gtpv2_ies[i].decode) (ie_tvb, pinfo , ie_tree, ti, length, message_type, instance);
5263         }
5264
5265         offset += length;
5266     }
5267 }
5268
5269 static void
5270 dissect_gtpv2(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
5271 {
5272     proto_tree *gtpv2_tree, *flags_tree;
5273     proto_item *ti, *tf;
5274     guint8      message_type, t_flag, p_flag;
5275     int         offset = 0;
5276     guint16     msg_length;
5277     tvbuff_t   *msg_tvb;
5278
5279
5280     /* Currently we get called from the GTP dissector no need to check the version */
5281     col_set_str(pinfo->cinfo, COL_PROTOCOL, "GTPv2");
5282     col_clear(pinfo->cinfo, COL_INFO);
5283
5284     /* message type is in octet 2 */
5285     message_type = tvb_get_guint8(tvb, 1);
5286     col_set_str(pinfo->cinfo, COL_INFO, val_to_str_ext_const(message_type, &gtpv2_message_type_vals_ext, "Unknown"));
5287
5288
5289     p_flag = (tvb_get_guint8(tvb, offset) & 0x10) >> 4;
5290     msg_length = tvb_get_ntohs(tvb, offset + 2);
5291     proto_tree_add_item(tree, proto_gtpv2, tvb, offset, msg_length + 4, ENC_NA);
5292
5293     if (tree) {
5294         ti = proto_tree_add_text(tree, tvb, offset, msg_length + 4, "%s",
5295                                  val_to_str_ext_const(message_type, &gtpv2_message_type_vals_ext, "Unknown"));
5296         gtpv2_tree = proto_item_add_subtree(ti, ett_gtpv2);
5297
5298         /* Control Plane GTP uses a variable length header. Control Plane GTP header
5299          * length shall be a multiple of 4 octets.
5300          * Figure 5.1-1 illustrates the format of the GTPv2-C Header.
5301          * Bits       8  7  6   5       4   3       2       1
5302          * Octets   1 Version   P       T   Spare   Spare   Spare
5303          *          2 Message Type
5304          *          3 Message Length (1st Octet)
5305          *          4 Message Length (2nd Octet)
5306          *  m-k(m+3)    If T flag is set to 1, then TEID shall be placed into octets 5-8.
5307          *              Otherwise, TEID field is not present at all.
5308          *  n-(n+2)   Sequence Number
5309          * (n+3)      Spare
5310          * Figure 5.1-1: General format of GTPv2 Header for Control Plane
5311          */
5312         tf = proto_tree_add_item(gtpv2_tree, hf_gtpv2_flags, tvb, offset, 1, ENC_BIG_ENDIAN);
5313         flags_tree = proto_item_add_subtree(tf, ett_gtpv2_flags);
5314
5315         /* Octet 1 */
5316         t_flag = (tvb_get_guint8(tvb, offset) & 0x08) >> 3;
5317         proto_tree_add_item(flags_tree, hf_gtpv2_version, tvb, offset, 1, ENC_BIG_ENDIAN);
5318         proto_tree_add_item(flags_tree, hf_gtpv2_p, tvb, offset, 1, ENC_BIG_ENDIAN);
5319         proto_tree_add_item(flags_tree, hf_gtpv2_t, tvb, offset, 1, ENC_BIG_ENDIAN);
5320         offset += 1;
5321
5322         /* Octet 2 */
5323         proto_tree_add_item(gtpv2_tree, hf_gtpv2_message_type, tvb, offset, 1, ENC_BIG_ENDIAN);
5324         offset += 1;
5325         /* Octet 3 - 4 */
5326         proto_tree_add_item(gtpv2_tree, hf_gtpv2_msg_length, tvb, offset, 2, ENC_BIG_ENDIAN);
5327         offset += 2;
5328
5329         if (t_flag) {
5330             /* Tunnel Endpoint Identifier 4 octets */
5331             proto_tree_add_item(gtpv2_tree, hf_gtpv2_teid, tvb, offset, 4, ENC_BIG_ENDIAN);
5332             offset += 4;
5333         }
5334         /* Sequence Number 3 octets */
5335         proto_tree_add_item(gtpv2_tree, hf_gtpv2_seq, tvb, offset, 3, ENC_BIG_ENDIAN);
5336         offset += 3;
5337
5338         /* Spare 1 octet */
5339         proto_tree_add_item(gtpv2_tree, hf_gtpv2_spare, tvb, offset, 1, ENC_BIG_ENDIAN);
5340         offset += 1;
5341
5342         if (p_flag) {
5343             msg_tvb = tvb_new_subset_length(tvb, 0, msg_length + 4);
5344             dissect_gtpv2_ie_common(msg_tvb, pinfo, gtpv2_tree, offset, message_type);
5345         } else {
5346             dissect_gtpv2_ie_common(tvb, pinfo, gtpv2_tree, offset, message_type);
5347         }
5348     }
5349     /* Bit 5 represents a "P" flag. If the "P" flag is set to "0",
5350      * no piggybacked message shall be present. If the "P" flag is set to "1",
5351      * then another GTPv2-C message with its own header and body shall be present
5352      * at the end of the current message.
5353      */
5354     if (p_flag) {
5355         tvbuff_t   *new_p_tvb;
5356         /* Octets 3 to 4 represent the Length field. This field shall indicate the
5357          * length of the message in octets excluding the
5358          * mandatory part of the GTP-C header (the first 4 octets).
5359          */
5360         new_p_tvb = tvb_new_subset_remaining(tvb, msg_length + 4);
5361         col_append_str(pinfo->cinfo, COL_INFO, " / ");
5362         col_set_fence(pinfo->cinfo, COL_INFO);
5363         dissect_gtpv2(new_p_tvb, pinfo, tree);
5364     }
5365
5366
5367 }
5368
5369 void proto_register_gtpv2(void)
5370 {
5371     static hf_register_info hf_gtpv2[] = {
5372         { &hf_gtpv2_reserved,
5373           {"Reserved bit(s)", "gtpv2.reserved",
5374            FT_UINT8, BASE_DEC, NULL, 0x0,
5375            "Reserved", HFILL }
5376         },
5377         { &hf_gtpv2_spare_half_octet,
5378           {"Spare half octet", "gtpv2.spare_half_octet",
5379            FT_UINT8, BASE_DEC, NULL, 0x0,
5380            NULL, HFILL }
5381         },
5382         { &hf_gtpv2_spare_bits,
5383           {"Spare bit(s)", "gtpv2.spare_bits",
5384            FT_UINT8, BASE_DEC, NULL, 0x0,
5385            NULL, HFILL }
5386         },
5387         {&hf_gtpv2_flags,
5388          {"Flags", "gtpv2.flags",
5389           FT_UINT8, BASE_HEX, NULL, 0x0,
5390           NULL, HFILL}
5391         },
5392         {&hf_gtpv2_version,
5393          {"Version", "gtpv2.version",
5394           FT_UINT8, BASE_DEC, NULL, 0xe0,
5395           NULL, HFILL}
5396         },
5397         {&hf_gtpv2_p,
5398          {"Piggybacking flag (P)", "gtpv2.p",
5399           FT_UINT8, BASE_DEC, NULL, 0x10,
5400           "If Piggybacked message is present or not", HFILL}
5401         },
5402         { &hf_gtpv2_t,
5403           {"TEID flag (T)", "gtpv2.t",
5404            FT_UINT8, BASE_DEC, NULL, 0x08,
5405            "If TEID field is present or not", HFILL}
5406         },
5407         { &hf_gtpv2_message_type,
5408           {"Message Type", "gtpv2.message_type",
5409            FT_UINT8, BASE_DEC|BASE_EXT_STRING, &gtpv2_message_type_vals_ext, 0x0,
5410            NULL, HFILL}
5411         },
5412         { &hf_gtpv2_msg_length,
5413           {"Message Length", "gtpv2.msg_lengt",
5414            FT_UINT16, BASE_DEC, NULL, 0x0,
5415            NULL, HFILL}
5416         },
5417         { &hf_gtpv2_teid,
5418           {"Tunnel Endpoint Identifier", "gtpv2.teid",
5419            FT_UINT32, BASE_DEC, NULL, 0x0,
5420            "TEID", HFILL}
5421         },
5422         { &hf_gtpv2_seq,
5423           {"Sequence Number", "gtpv2.seq",
5424            FT_UINT32, BASE_DEC, NULL, 0x0,
5425            "SEQ", HFILL}
5426         },
5427         { &hf_gtpv2_spare,
5428           {"Spare", "gtpv2.spare",
5429            FT_UINT16, BASE_DEC, NULL, 0x0,
5430            NULL, HFILL}
5431         },
5432         { &hf_gtpv2_ie,
5433           {"IE Type", "gtpv2.ie_type",
5434            FT_UINT8, BASE_DEC|BASE_EXT_STRING, &gtpv2_element_type_vals_ext, 0x0,
5435            NULL, HFILL}
5436         },
5437         { &hf_gtpv2_ie_len,
5438           {"IE Length", "gtpv2.ie_len",
5439            FT_UINT16, BASE_DEC, NULL, 0x0,
5440            "length of the information element excluding the first four octets", HFILL}
5441         },
5442         { &hf_gtpv2_cr,
5443           {"CR flag", "gtpv2.cr",
5444            FT_UINT8, BASE_DEC, NULL, 0xf0, /* SRVCC */
5445            NULL, HFILL}
5446         },
5447         { &hf_gtpv2_instance,
5448           {"Instance", "gtpv2.instance",
5449            FT_UINT8, BASE_DEC, NULL, 0x0f,
5450            NULL, HFILL}
5451         },
5452         {&hf_gtpv2_imsi,
5453          {"IMSI(International Mobile Subscriber Identity number)", "gtpv2.imsi",
5454           FT_STRING, BASE_NONE, NULL, 0,
5455           NULL, HFILL}
5456         },
5457         { &hf_gtpv2_ipv4_addr,
5458           {"IPv4 Address", "gtpv2.ipv4_addr",
5459            FT_IPv4, BASE_NONE, NULL, 0x0,
5460            NULL, HFILL}
5461         },
5462         { &hf_gtpv2_cause,
5463           {"Cause", "gtpv2.cause",
5464            FT_UINT8, BASE_DEC|BASE_EXT_STRING, &gtpv2_cause_vals_ext, 0x0,
5465            NULL, HFILL}
5466         },
5467         {&hf_gtpv2_cause_cs,
5468          {"CS (Cause Source)", "gtpv2.cs",
5469           FT_BOOLEAN, 8, TFS(&gtpv2_cause_cs), 0x01,
5470           NULL, HFILL}
5471         },
5472         { &hf_gtpv2_cause_bce,
5473           {"BCE (Bearer Context IE Error)", "gtpv2.bce",
5474            FT_BOOLEAN, 8, NULL, 0x02,
5475            NULL, HFILL}
5476         },
5477         { &hf_gtpv2_cause_pce,
5478           {"PCE (PDN Connection IE Error)", "gtpv2.pce",
5479            FT_BOOLEAN, 8, NULL, 0x04,
5480            NULL, HFILL}
5481         },
5482         { &hf_gtpv2_cause_off_ie_t,
5483           {"Type of the offending IE", "gtpv2.cause_off_ie_t",
5484            FT_UINT8, BASE_DEC|BASE_EXT_STRING, &gtpv2_element_type_vals_ext, 0x0,
5485            NULL, HFILL}
5486         },
5487         { &hf_gtpv2_rec,
5488           {"Restart Counter", "gtpv2.rec",
5489            FT_UINT8, BASE_DEC, NULL, 0x0,
5490            NULL, HFILL}
5491         },
5492 /*Start SRVCC Messages*/
5493         { &hf_gtpv2_stn_sr,
5494           {"STN-SR", "gtpv2.stn_sr",
5495            FT_BYTES, BASE_NONE, NULL, 0x0,
5496            NULL, HFILL}
5497         },
5498         { &hf_gtpv2_len_trans_con,
5499           {"Length of the Transparent Container", "gtpv2.len_trans_con",
5500            FT_UINT8, BASE_DEC, NULL, 0x0,
5501            NULL, HFILL}
5502         },
5503         { &hf_gtpv2_eksi,
5504           {"eKSI", "gtpv2.eksi",
5505            FT_UINT8, BASE_DEC, NULL, 0x07,
5506            NULL, HFILL}
5507         },
5508         { &hf_gtpv2_ck,
5509           {"CK", "gtpv2.ck",
5510            FT_BYTES, BASE_NONE, NULL, 0x0,
5511            NULL, HFILL}
5512         },
5513         { &hf_gtpv2_ik,
5514           {"IK", "gtpv2.ik",
5515            FT_BYTES, BASE_NONE, NULL, 0x0,
5516            NULL, HFILL}
5517         },
5518         { &hf_gtpv2_len_ms_classmark2,
5519           {"Length of Mobile Station Classmark2", "gtpv2.len_ms_classmark2",
5520            FT_UINT8, BASE_DEC, NULL, 0x0,
5521            NULL, HFILL}
5522         },
5523         { &hf_gtpv2_len_ms_classmark3,
5524           {"Length of Mobile Station Classmark3", "gtpv2.len_ms_classmark3",
5525            FT_UINT8, BASE_DEC, NULL, 0x0,
5526            NULL, HFILL}
5527         },
5528         { &hf_gtpv2_len_supp_codec_list,
5529           {"Length of Supported Codec List", "gtpv2.len_supp_codec_list",
5530            FT_UINT8, BASE_DEC, NULL, 0x0,
5531            NULL, HFILL}
5532         },
5533         { &hf_gtpv2_ksi,
5534           {"KSI'cs", "gtpv2.ksi",
5535            FT_UINT8, BASE_DEC, NULL, 0x0F,
5536            NULL, HFILL}
5537         },
5538         { &hf_gtpv2_cksn,
5539           {"CKSN'", "gtpv2.cksn",
5540            FT_UINT8, BASE_DEC, NULL, 0x0,
5541            NULL, HFILL}
5542         },
5543         { &hf_gtpv2_srvcc_cause,
5544           {"SRVCC Cause", "gtpv2.srvcc_cause",
5545            FT_UINT8, BASE_DEC|BASE_EXT_STRING, &gtpv2_srvcc_cause_vals_ext, 0x0,
5546            NULL, HFILL}
5547         },
5548         {&hf_gtpv2_rac,
5549          { "Routing Area Code (RAC)", "gtpv2.rac",
5550            FT_UINT8, BASE_DEC, NULL, 0,
5551            "Routing Area Code", HFILL}
5552         },
5553
5554         { &hf_gtpv2_rnc_id,
5555           {"RNC ID", "gtpv2.rnc_id",
5556            FT_UINT16, BASE_DEC, NULL, 0x0,
5557            NULL, HFILL}
5558         },
5559         { &hf_gtpv2_ext_rnc_id,
5560           {"Extended RNC-ID", "gtpv2.ext_rnc_id",
5561            FT_UINT16, BASE_DEC, NULL, 0x0,
5562            NULL, HFILL}
5563         },
5564         { &hf_gtpv2_lac,
5565           { "Location Area Code (LAC)", "gtpv2.lac",
5566             FT_UINT16, BASE_HEX_DEC, NULL, 0x00,
5567             NULL, HFILL }
5568         },
5569         { &hf_gtpv2_sac,
5570           { "Service Area Code (SAC)", "gtpv2.sac",
5571             FT_UINT16, BASE_HEX_DEC, NULL, 0x00,
5572             NULL, HFILL }
5573         },
5574         { &hf_gtpv2_tgt_g_cell_id,
5575           {"Cell ID", "gtpv2.tgt_g_cell_id",
5576            FT_UINT16, BASE_DEC, NULL, 0x0,
5577            NULL, HFILL}
5578         },
5579         {&hf_gtpv2_teid_c,
5580          {"Tunnel Endpoint Identifier for Control Plane(TEID-C)", "gtpv2.teid_c",
5581           FT_UINT32, BASE_DEC, NULL, 0x0,
5582           NULL, HFILL}
5583         },
5584         {&hf_gtpv2_sv_sti,
5585          {"STI (Session Transfer Indicator)", "gtpv2.sv_sti",
5586           FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL}
5587         },
5588         {&hf_gtpv2_sv_ics,
5589          {"ICS (IMS Centralized Service)", "gtpv2.sv_ics",
5590           FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL}
5591         },
5592         {&hf_gtpv2_sv_emind,
5593          {"EmInd(Emergency Indicator)", "gtpv2.sv_emind",
5594           FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL}
5595         },
5596
5597 /*End SRVCC Messages*/
5598         {&hf_gtpv2_apn,
5599          {"APN (Access Point Name)", "gtpv2.apn",
5600           FT_STRING, BASE_NONE, NULL, 0x0,
5601           NULL, HFILL}
5602         },
5603         {&hf_gtpv2_ambr_up,
5604          {"AMBR Uplink (Aggregate Maximum Bit Rate for Uplink)", "gtpv2.ambr_up",
5605           FT_UINT32, BASE_DEC, NULL, 0x0,
5606           NULL, HFILL}
5607         },
5608         {&hf_gtpv2_ambr_down,
5609          {"AMBR Downlink(Aggregate Maximum Bit Rate for Downlink)", "gtpv2.ambr_down",
5610           FT_UINT32, BASE_DEC, NULL, 0x0,
5611           NULL, HFILL}
5612         },
5613         {&hf_gtpv2_ebi,
5614          {"EPS Bearer ID (EBI)", "gtpv2.ebi",
5615           FT_UINT8, BASE_DEC, NULL, 0x0f,
5616           NULL, HFILL}
5617         },
5618         { &hf_gtpv2_ip_address_ipv4,
5619           {"IP address IPv4", "gtpv2.ip_address_ipv4",
5620            FT_IPv4, BASE_NONE, NULL, 0x0,
5621            NULL, HFILL}
5622         },
5623         { &hf_gtpv2_ip_address_ipv6,
5624           {"IP address IPv6", "gtpv2.ip_address_ipv6",
5625            FT_IPv6, BASE_NONE, NULL, 0x0,
5626            NULL, HFILL}
5627         },
5628         {&hf_gtpv2_mei,
5629          {"MEI(Mobile Equipment Identity)", "gtpv2.mei",
5630           FT_STRING, BASE_NONE, NULL, 0,
5631           NULL, HFILL}
5632         },
5633         { &hf_gtpv2_pdn_numbers_nsapi,
5634           {"NSAPI", "gtpv2.pdn_numbers_nsapi",
5635            FT_UINT8, BASE_DEC, NULL, 0x0f, NULL, HFILL}
5636         },
5637         { &hf_gtpv2_p_tmsi,
5638           {"Packet TMSI (P-TMSI)", "gtpv2.p_tmsi",
5639            FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5640         },
5641         { &hf_gtpv2_p_tmsi_sig,
5642           {"P-TMSI Signature", "gtpv2.p_tmsi_sig",
5643            FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
5644         },
5645         {&hf_gtpv2_daf,
5646          {"DAF (Dual Address Bearer Flag)", "gtpv2.daf",
5647           FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL}
5648         },
5649         {&hf_gtpv2_dtf,
5650          {"DTF (Direct Tunnel Flag)", "gtpv2.dtf",
5651           FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL}
5652         },
5653         {&hf_gtpv2_hi,
5654          {"HI (Handover Indication)", "gtpv2.hi",
5655           FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL}
5656         },
5657         {&hf_gtpv2_dfi,
5658          {"DFI (Direct Forwarding Indication)", "gtpv2.dfi",
5659           FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL}
5660         },
5661         {&hf_gtpv2_oi,
5662          {"OI (Operation Indication)", "gtpv2.oi",
5663           FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL}
5664         },
5665         {&hf_gtpv2_isrsi,
5666          {"ISRSI (Idle mode Signalling Reduction Supported Indication)", "gtpv2.isrsi",
5667           FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL}
5668         },
5669         {&hf_gtpv2_israi,
5670          {"ISRAI (Idle mode Signalling Reduction Activation Indication)",    "gtpv2.israi",
5671           FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL}
5672         },
5673         {&hf_gtpv2_sgwci,
5674          {"SGWCI (SGW Change Indication)", "gtpv2.sgwci",
5675           FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL}
5676         },
5677         {&hf_gtpv2_sqci,
5678          {"SQCI (Subscribed QoS Change Indication", "gtpv2.sqci",
5679           FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL}
5680         },
5681         {&hf_gtpv2_uimsi,
5682          {"UIMSI (Unauthenticated IMSI)", "gtpv2.uimsi",
5683           FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL}
5684         },
5685         {&hf_gtpv2_cfsi,
5686          {"CFSI (Change F-TEID support indication)", "gtpv2.cfsi",
5687           FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL}
5688         },
5689         {&hf_gtpv2_crsi,
5690          {"CRSI (Change Reporting support indication):", "gtpv2.crsi",
5691           FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL}
5692         },
5693         {&hf_gtpv2_ps,
5694          {"PS (Piggybacking Supported).)", "gtpv2.ps",
5695           FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL}
5696         },
5697         {&hf_gtpv2_pt,
5698          {"PT (Protocol Type)", "gtpv2.pt",
5699           FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL}
5700         },
5701         {&hf_gtpv2_si,
5702          {"SI (Scope Indication)", "gtpv2.si",
5703           FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL}
5704         },
5705         {&hf_gtpv2_msv,
5706          {"MSV (MS Validated)", "gtpv2.msv",
5707           FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL}
5708         },
5709         {&hf_gtpv2_spare1,
5710          {"Spare", "gtpv2.spare",
5711           FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL}
5712         },
5713         {&hf_gtpv2_spare2,
5714          {"Spare", "gtpv2.spare",
5715           FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL}
5716         },
5717         {&hf_gtpv2_spare3,
5718          {"Spare", "gtpv2.spare",
5719           FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL}
5720         },
5721         {&hf_gtpv2_s6af,
5722          {"S6AF (Static IPv6 Address Flag)", "gtpv2.s6af",
5723           FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL}
5724         },
5725         {&hf_gtpv2_s4af,
5726          {"S4AF (Static IPv4 Address Flag))", "gtpv2.s4af",
5727           FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL}
5728         },
5729         {&hf_gtpv2_mbmdt,
5730          {"MBMDT (Management Based MDT allowed flag)", "gtpv2.mbmdt",
5731           FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL}
5732         },
5733         {&hf_gtpv2_israu,
5734          {"ISRAU (ISR is activated for the UE)", "gtpv2.israu",
5735           FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL}
5736         },
5737         {&hf_gtpv2_ccrsi,
5738          {"CCRSI (CSG Change Reporting support indication)", "gtpv2.ccrsi",
5739           FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL}
5740         },
5741         { &hf_gtpv2_pdn_type,
5742           {"PDN Type", "gtpv2.pdn_type",
5743            FT_UINT8, BASE_DEC, VALS(gtpv2_pdn_type_vals), 0x07,
5744            NULL, HFILL}
5745         },
5746 #if 0
5747         { &hf_gtpv2_tra_info,
5748           {"Trace ID", "gtpv2.tra_info",
5749            FT_STRING, BASE_NONE, NULL, 0x0,
5750            NULL, HFILL}
5751         },
5752 #endif
5753         { &hf_gtpv2_tra_info_msc_momt_calls,
5754           {"MO and MT calls", "gtpv2.tra_info_msc_momt_calls",
5755            FT_UINT8, BASE_DEC, NULL, 0x01,
5756            "MSC Server", HFILL}
5757         },
5758         { &hf_gtpv2_tra_info_msc_momt_sms,
5759           {"MO and MT SMS", "gtpv2.tra_info_msc_momt_sms",
5760            FT_UINT8, BASE_DEC, NULL, 0x02,
5761            "MSC Server", HFILL}
5762         },
5763         { &hf_gtpv2_tra_info_msc_lu_imsi_ad,
5764           {"LU, IMSI attach, IMSI detach", "gtpv2.tra_info_msc_lu_imsi_ad",
5765            FT_UINT8, BASE_DEC, NULL, 0x04,
5766            "MSC Server", HFILL}
5767         },
5768         { &hf_gtpv2_tra_info_msc_handovers,
5769           {"Handovers", "gtpv2.tra_info_msc_handovers",
5770            FT_UINT8, BASE_DEC, NULL, 0x08,
5771            "MSC Server", HFILL}
5772         },
5773         { &hf_gtpv2_tra_info_msc_ss,
5774           {"SS", "gtpv2.tra_info_msc_ss",
5775            FT_UINT8, BASE_DEC, NULL, 0x10,
5776            "MSC Server", HFILL}
5777         },
5778         { &hf_gtpv2_tra_info_mgw_context,
5779           {"Context", "gtpv2.tra_info_mgw_context",
5780            FT_UINT8, BASE_DEC, NULL, 0x01,
5781            "MGW", HFILL}
5782         },
5783         { &hf_gtpv2_tra_info_sgsn_pdp_context,
5784           {"PDP context", "gtpv2.tra_info_sgsn_pdp_context",
5785            FT_UINT8, BASE_DEC, NULL, 0x01,
5786            "SGSN", HFILL}
5787         },
5788         { &hf_gtpv2_tra_info_sgsn_momt_sms,
5789           {"MO and MT SMS", "gtpv2.tra_info_sgsn_momt_sms",
5790            FT_UINT8, BASE_DEC, NULL, 0x02,
5791            "SGSN", HFILL}
5792         },
5793         { &hf_gtpv2_tra_info_sgsn_rau_gprs_ad,
5794           {"RAU, GPRS attach, GPRS detach", "gtpv2.tra_info_sgsn_rau_gprs_ad",
5795            FT_UINT8, BASE_DEC, NULL, 0x04,
5796            "SGSN", HFILL}
5797         },
5798         { &hf_gtpv2_tra_info_sgsn_mbms,
5799           {"MBMS Context", "gtpv2.tra_into_sgsn_mbms",
5800            FT_UINT8, BASE_DEC, NULL, 0x08,
5801            "SGSN", HFILL}
5802         },
5803         { &hf_gtpv2_tra_info_sgsn_reserved,
5804           {"Reserved", "gtpv2.",
5805            FT_UINT8, BASE_DEC, NULL, 0x0,
5806            "SGSN", HFILL}
5807         },
5808         { &hf_gtpv2_tra_info_ggsn_pdp,
5809           {"PDP Cpntext", "gtpv2.tra_info_ggsn_pdp",
5810            FT_UINT8, BASE_DEC, NULL, 0x01,
5811            "GGSN", HFILL}
5812         },
5813         { &hf_gtpv2_tra_info_ggsn_mbms,
5814           {"MBMS Context", "gtpv2.tra_info_ggsn_mbms",
5815            FT_UINT8, BASE_DEC, NULL, 0x02,
5816            "GGSN", HFILL}
5817         },
5818         { &hf_gtpv2_tra_info_bm_sc,
5819           {"MBMS Multicast service activation", "gtpv2.tra_info_bm_sc",
5820            FT_UINT8, BASE_DEC, NULL, 0x01,
5821            "BM-SC", HFILL}
5822         },
5823         { &hf_gtpv2_tra_info_mme_sgw_ss,
5824           {"Session setup", "gtpv2.tra_info_mme_sgw_ss",
5825            FT_UINT8, BASE_DEC, NULL, 0x01,
5826            "MME", HFILL}
5827         },
5828         { &hf_gtpv2_tra_info_mme_sgw_sr,
5829           {"Service Request", "gtpv2.tra_info_mme_sgw_sr",
5830            FT_UINT8, BASE_DEC, NULL, 0x02,
5831            "MME", HFILL}
5832         },
5833         { &hf_gtpv2_tra_info_mme_sgw_iataud,
5834           {"Initial Attach, Tracking area update, Detach", "gtpv2.tra_info_mme_sgw_iataud",
5835            FT_UINT8, BASE_DEC, NULL, 0x04,
5836            "MME", HFILL}
5837         },
5838         { &hf_gtpv2_tra_info_lne_msc_s,
5839           {"MSC-S", "gtpv2.tra_info_lne_msc_s",
5840            FT_UINT8, BASE_DEC, NULL, 0x01,
5841            "List of NE Types", HFILL}
5842         },
5843         { &hf_gtpv2_tra_info_lne_mgw,
5844           {"MGW", "gtpv2.tra_info_lne_mgw",
5845            FT_UINT8, BASE_DEC, NULL, 0x02,
5846            "List of NE Types", HFILL}
5847         },
5848         { &hf_gtpv2_tra_info_lne_sgsn,
5849           {"SGSN", "gtpv2.tra_info_lne_sgsn",
5850            FT_UINT8, BASE_DEC, NULL, 0x04,
5851            "List of NE Types", HFILL}
5852         },
5853         { &hf_gtpv2_tra_info_lne_ggsn,
5854           {"GGSN", "gtpv2.tra_info_lne_ggsn",
5855            FT_UINT8, BASE_DEC, NULL, 0x08,
5856            "List of NE Types", HFILL}
5857         },
5858         { &hf_gtpv2_tra_info_lne_rnc,
5859           {"RNC", "gtpv2.tra_info_lne_rnc",
5860            FT_UINT8, BASE_DEC, NULL, 0x10,
5861            "List of NE Types", HFILL}
5862         },
5863         { &hf_gtpv2_tra_info_lne_bm_sc,
5864           {"BM-SC", "gtpv2.tra_info_lne_bm_sc",
5865            FT_UINT8, BASE_DEC, NULL, 0x20,
5866            "List of NE Types", HFILL}
5867         },
5868         { &hf_gtpv2_tra_info_lne_mme,
5869           {"MME", "gtpv2.tra_info_lne_mme",
5870            FT_UINT8, BASE_DEC, NULL, 0x40,
5871            "List of NE Types", HFILL}
5872         },
5873         { &hf_gtpv2_tra_info_lne_sgw,
5874           {"SGW", "gtpv2.tra_info_lne_sgw",
5875            FT_UINT8, BASE_DEC, NULL, 0x80,
5876            "List of NE Types", HFILL}
5877         },
5878         { &hf_gtpv2_tra_info_lne_pdn_gw,
5879           {"PDN GW", "gtpv2.tra_info_lne_pdn_gw",
5880            FT_UINT8, BASE_DEC, NULL, 0x01,
5881            "List of NE Types", HFILL}
5882         },
5883         { &hf_gtpv2_tra_info_lne_enb,
5884           {"eNB", "gtpv2.tra_info_lne_enb",
5885            FT_UINT8, BASE_DEC, NULL, 0x02,
5886            "List of NE Types", HFILL}
5887         },
5888         { &hf_gtpv2_tra_info_tdl,
5889           {"Trace Depth Length", "gtpv2.tra_info_tdl",
5890            FT_UINT8, BASE_DEC, NULL, 0x0,
5891            NULL, HFILL}
5892         },
5893         { &hf_gtpv2_tra_info_lmsc_a,
5894           {"A", "gtpv2.tra_info_lmsc_a",
5895            FT_UINT8, BASE_DEC, NULL, 0x01,
5896            "MSC Server", HFILL}
5897         },
5898         { &hf_gtpv2_tra_info_lmsc_lu,
5899           {"Iu", "gtpv2.tra_info_lmsc_lu",
5900            FT_UINT8, BASE_DEC, NULL, 0x02,
5901            "MSC Server", HFILL}
5902         },
5903         { &hf_gtpv2_tra_info_lmsc_mc,
5904           {"Mc", "gtpv2.tra_info_lmsc_mc",
5905            FT_UINT8, BASE_DEC, NULL, 0x04,
5906            "MSC Server", HFILL}
5907         },
5908         { &hf_gtpv2_tra_info_lmsc_map_g,
5909           {"MAP-G", "gtpv2.tra_info_lmsc_map_g",
5910            FT_UINT8, BASE_DEC, NULL, 0x08,
5911            "MSC Server", HFILL}
5912         },
5913         { &hf_gtpv2_tra_info_lmsc_map_b,
5914           {"MAP-B", "gtpv2.tra_info_lmsc_map_b",
5915            FT_UINT8, BASE_DEC, NULL, 0x10,
5916            "MSC Server", HFILL}
5917         },
5918         { &hf_gtpv2_tra_info_lmsc_map_e,
5919           {"MAP-E", "gtpv2.tra_info_lmsc_map_e",
5920            FT_UINT8, BASE_DEC, NULL, 0x20,
5921            "MSC Server", HFILL}
5922         },
5923         { &hf_gtpv2_tra_info_lmsc_map_f,
5924           {"MAP-F", "gtpv2.tra_info_lmsc_map_f",
5925            FT_UINT8, BASE_DEC, NULL, 0x40,
5926            "MSC Server", HFILL}
5927         },
5928         { &hf_gtpv2_tra_info_lmsc_cap,
5929           {"CAP", "gtpv2.tra_info_lmsc_cap",
5930            FT_UINT8, BASE_DEC, NULL, 0x80,
5931            "MSC Server", HFILL}
5932         },
5933         { &hf_gtpv2_tra_info_lmsc_map_d,
5934           {"MAP-D", "gtpv2.tra_info_lmsc_map_d",
5935            FT_UINT8, BASE_DEC, NULL, 0x01,
5936            "MSC Server", HFILL}
5937         },
5938         { &hf_gtpv2_tra_info_lmsc_map_c,
5939           {"MAP-C", "gtpv2.tra_info_lmsc_map_c",
5940            FT_UINT8, BASE_DEC, NULL, 0x02,
5941            "MSC Server", HFILL}
5942         },
5943         { &hf_gtpv2_tra_info_lmgw_mc,
5944           {"Mc", "gtpv2.tra_info_lmgw_mc",
5945            FT_UINT8, BASE_DEC, NULL, 0x01,
5946            "MGW", HFILL}
5947         },
5948         { &hf_gtpv2_tra_info_lmgw_nb_up,
5949           {"Nb-UP", "gtpv2.tra_info_lmgw_nb_up",
5950            FT_UINT8, BASE_DEC, NULL, 0x2,
5951            "MGW", HFILL}
5952         },
5953         { &hf_gtpv2_tra_info_lmgw_lu_up,
5954           {"Iu-UP", "gtpv2.tra_info_lmgw_lu_up",
5955            FT_UINT8, BASE_DEC, NULL, 0x04,
5956            "MGW", HFILL}
5957         },
5958         { &hf_gtpv2_tra_info_lsgsn_gb,
5959           {"Gb", "gtpv2.tra_info_lsgsn_gb",
5960            FT_UINT8, BASE_DEC, NULL, 0x01,
5961            "SGSN", HFILL}
5962         },
5963         { &hf_gtpv2_tra_info_lsgsn_lu,
5964           {"Iu", "gtpv2.tra_info_lsgsn_lu",
5965            FT_UINT8, BASE_DEC, NULL, 0x02,
5966            "SGSN", HFILL}
5967         },
5968         { &hf_gtpv2_tra_info_lsgsn_gn,
5969           {"Gn", "gtpv2.tra_info_lsgsn_gn",
5970            FT_UINT8, BASE_DEC, NULL, 0x04,
5971            "SGSN", HFILL}
5972         },
5973         { &hf_gtpv2_tra_info_lsgsn_map_gr,
5974           {"MAP-Gr", "gtpv2.tra_info_lsgsn_map_gr",
5975            FT_UINT8, BASE_DEC, NULL, 0x08,
5976            "SGSN", HFILL}
5977         },
5978         { &hf_gtpv2_tra_info_lsgsn_map_gd,
5979           {"MAP-Gd", "gtpv2.tra_info_lsgsn_map_gd",
5980            FT_UINT8, BASE_DEC, NULL, 0x10,
5981            "SGSN", HFILL}
5982         },
5983         { &hf_gtpv2_tra_info_lsgsn_map_gf,
5984           {"MAP-Gf", "gtpv2.tra_info_lsgsn_map_gf",
5985            FT_UINT8, BASE_DEC, NULL, 0x20,
5986            "SGSN", HFILL}
5987         },
5988         { &hf_gtpv2_tra_info_lsgsn_gs,
5989           {"Gs", "gtpv2.tra_info_lsgsn_gs",
5990            FT_UINT8, BASE_DEC, NULL, 0x40,
5991            "SGSN", HFILL}
5992         },
5993         { &hf_gtpv2_tra_info_lsgsn_ge,
5994           {"Ge", "gtpv2.tra_info_lsgsn_ge",
5995            FT_UINT8, BASE_DEC, NULL, 0x80,
5996            "SGSN", HFILL}
5997         },
5998         { &hf_gtpv2_tra_info_lggsn_gn,
5999           {"Gn", "gtpv2.tra_info_lggsn_gn",
6000            FT_UINT8, BASE_DEC, NULL, 0x01,
6001            "GGSN", HFILL}
6002         },
6003         { &hf_gtpv2_tra_info_lggsn_gi,
6004           {"Gi", "gtpv2.tra_info_lggsn_gi",
6005            FT_UINT8, BASE_DEC, NULL, 0x02,
6006            "GGSN", HFILL}
6007         },
6008         { &hf_gtpv2_tra_info_lggsn_gmb,
6009           {"Gmb", "gtpv2.tra_info_lggsn_gmb",
6010            FT_UINT8, BASE_DEC, NULL, 0x04,
6011            "GGSN", HFILL}
6012         },
6013         { &hf_gtpv2_tra_info_lrnc_lu,
6014           {"Iu", "gtpv2.tra_info_lrnc_lu",
6015            FT_UINT8, BASE_DEC, NULL, 0x01,
6016            "RNC", HFILL}
6017         },
6018         { &hf_gtpv2_tra_info_lrnc_lur,
6019           {"Iur", "gtpv2.tra_info_lrnc_lur",
6020            FT_UINT8, BASE_DEC, NULL, 0x02,
6021            "RNC", HFILL}
6022         },
6023         { &hf_gtpv2_tra_info_lrnc_lub,
6024           {"Iub", "gtpv2.tra_info_lrnc_lub",
6025            FT_UINT8, BASE_DEC, NULL, 0x04,
6026            "RNC", HFILL}
6027         },
6028         { &hf_gtpv2_tra_info_lrnc_uu,
6029           {"Uu", "gtpv2.tra_info_lrnc_uu",
6030            FT_UINT8, BASE_DEC, NULL, 0x08,
6031            "RNC", HFILL}
6032         },
6033         { &hf_gtpv2_tra_info_lbm_sc_gmb,
6034           {"Gmb", "gtpv2.tra_info_lbm_sc_gmb",
6035            FT_UINT8, BASE_DEC, NULL, 0x01,
6036            "BM-SC", HFILL}
6037         },
6038         { &hf_gtpv2_tra_info_lmme_s1_mme,
6039           {"S1-MME", "gtpv2.tra_info_lmme_s1_mme",
6040            FT_UINT8, BASE_DEC, NULL, 0x01,
6041            "MME", HFILL}
6042         },
6043         { &hf_gtpv2_tra_info_lmme_s3,
6044           {"S3", "gtpv2.tra_info_lmme_s3",
6045            FT_UINT8, BASE_DEC, NULL, 0x02,
6046            "MME", HFILL}
6047         },
6048         { &hf_gtpv2_tra_info_lmme_s6a,
6049           {"S6a", "gtpv2.tra_info_lmme_s6a",
6050            FT_UINT8, BASE_DEC, NULL, 0x04,
6051            "MME", HFILL}
6052         },
6053         { &hf_gtpv2_tra_info_lmme_s10,
6054           {"S10", "gtpv2.tra_info_lmme_s10",
6055            FT_UINT8, BASE_DEC, NULL, 0x08,
6056            "MME", HFILL}
6057         },
6058         { &hf_gtpv2_tra_info_lmme_s11,
6059           {"S11", "gtpv2.tra_info_lmme_s11",
6060            FT_UINT8, BASE_DEC, NULL, 0x10,
6061            "MME", HFILL}
6062         },
6063         { &hf_gtpv2_tra_info_lsgw_s4,
6064           {"S4", "gtpv2.tra_info_lsgw_s4",
6065            FT_UINT8, BASE_DEC, NULL, 0x01,
6066            "SGW", HFILL}
6067         },
6068         { &hf_gtpv2_tra_info_lsgw_s5,
6069           {"S5", "gtpv2.tra_info_lsgw_s5",
6070            FT_UINT8, BASE_DEC, NULL, 0x02,
6071            "SGW", HFILL}
6072         },
6073         { &hf_gtpv2_tra_info_lsgw_s8b,
6074           {"S8b", "gtpv2.tra_info_lsgw_s8b",
6075            FT_UINT8, BASE_DEC, NULL, 0x04,
6076            "SGW", HFILL}
6077         },
6078         { &hf_gtpv2_tra_info_lsgw_s11,
6079           {"S11", "gtpv2.tra_info_lsgw_s11",
6080            FT_UINT8, BASE_DEC, NULL, 0x08,
6081            "SGW", HFILL}
6082         },
6083         { &hf_gtpv2_tra_info_lpdn_gw_s2a,
6084           {"S2a", "gtpv2.tra_info_lpdn_gw_s2a",
6085            FT_UINT8, BASE_DEC, NULL, 0x01,
6086            "PDN GW", HFILL}
6087         },
6088         { &hf_gtpv2_tra_info_lpdn_gw_s2b,
6089           {"S2b", "gtpv2.tra_info_lpdn_gw_s2b",
6090            FT_UINT8, BASE_DEC, NULL, 0x02,
6091            "PDN GW", HFILL}
6092         },
6093         { &hf_gtpv2_tra_info_lpdn_gw_s2c,
6094           {"S2c", "gtpv2.tra_info_lpdn_gw_s2c",
6095            FT_UINT8, BASE_DEC, NULL, 0x04,
6096            "PDN GW", HFILL}
6097         },
6098         { &hf_gtpv2_tra_info_lpdn_gw_s5,
6099           {"S5", "gtpv2.tra_info_lpdn_gw_s5",
6100            FT_UINT8, BASE_DEC, NULL, 0x08,
6101            "PDN GW", HFILL}
6102         },
6103         { &hf_gtpv2_tra_info_lpdn_gw_s6c,
6104           {"S6c", "gtpv2.tra_info_lpdn_gw_s6c",
6105            FT_UINT8, BASE_DEC, NULL, 0x10,
6106            "PDN GW", HFILL}
6107         },
6108         { &hf_gtpv2_tra_info_lpdn_gw_gx,
6109           {"Gx", "gtpv2.tra_info_lpdn_gw_gx",
6110            FT_UINT8, BASE_DEC, NULL, 0x20,
6111            "PDN GW", HFILL}
6112         },
6113         { &hf_gtpv2_tra_info_lpdn_gw_s8b,
6114           {"S8b", "gtpv2.tra_info_lpdn_gw_s8b",
6115            FT_UINT8, BASE_DEC, NULL, 0x40,
6116            "PDN GW", HFILL}
6117         },
6118         { &hf_gtpv2_tra_info_lpdn_gw_sgi,
6119           {"SGi", "gtpv2.tra_info_lpdn_gw_sgi",
6120            FT_UINT8, BASE_DEC, NULL, 0x80,
6121            "PDN GW", HFILL}
6122         },
6123         { &hf_gtpv2_tra_info_lenb_s1_mme,
6124           {"S1-MME", "gtpv2.tra_info_lenb_s1_mme",
6125            FT_UINT8, BASE_DEC, NULL, 0x01,
6126            "eNB", HFILL}
6127         },
6128         { &hf_gtpv2_tra_info_lenb_x2,
6129           {"X2", "gtpv2.tra_info_lenb_x2",
6130            FT_UINT8, BASE_DEC, NULL, 0x02,
6131            "eNB", HFILL}
6132         },
6133         { &hf_gtpv2_tra_info_lenb_uu,
6134           {"Uu", "gtpv2.tra_info_lenb_uu",
6135            FT_UINT8, BASE_DEC, NULL, 0x04,
6136            "eNB", HFILL}
6137         },
6138         { &hf_gtpv2_pdn_ipv4,
6139           {"PDN Address and Prefix(IPv4)", "gtpv2.pdn_addr_and_prefix.ipv4",
6140            FT_IPv4, BASE_NONE, NULL, 0x0,
6141            NULL, HFILL}
6142         },
6143         { &hf_gtpv2_pdn_ipv6_len,
6144           {"IPv6 Prefix Length", "gtpv2.pdn_ipv6_len",
6145            FT_UINT8, BASE_DEC, NULL, 0x0,
6146            NULL, HFILL}
6147         },
6148         { &hf_gtpv2_pdn_ipv6,
6149           {"PDN Address and Prefix(IPv6)", "gtpv2.pdn_addr_and_prefix.ipv6",
6150            FT_BYTES, BASE_NONE, NULL, 0x0,
6151            NULL, HFILL}
6152         },
6153         /* Bit 1 - PVI (Pre-emption Vulnerability): See 3GPP TS 29.212[29],
6154          * clause 5.3.47 Pre-emption-Vulnerability AVP.
6155          * 5.3.47 Pre-emption-Vulnerability AVP
6156          * The following values are defined:
6157          * PRE-EMPTION_VULNERABILITY_ENABLED (0)
6158          * PRE-EMPTION_VULNERABILITY_DISABLED (1)
6159          */
6160         {&hf_gtpv2_bearer_qos_pvi,
6161          {"PVI (Pre-emption Vulnerability)", "gtpv2.bearer_qos_pvi",
6162           FT_BOOLEAN, 8, TFS(&tfs_disabled_enabled), 0x01,
6163           NULL, HFILL}
6164         },
6165         {&hf_gtpv2_bearer_qos_pl,
6166          {"PL (Priority Level)", "gtpv2.bearer_qos_pl",
6167           FT_UINT8, BASE_DEC, NULL, 0x3c,
6168           NULL, HFILL}
6169         },
6170         /* Bit 7 - PCI (Pre-emption Capability): See 3GPP TS 29.212[29], clause 5.3.46 Pre-emption-Capability AVP.
6171          * clause 5.3.46 Pre-emption-Capability AVP.
6172          * 5.3.46 Pre-emption-Capability AVP
6173          * The following values are defined:
6174          * PRE-EMPTION_CAPABILITY_ENABLED (0)
6175          * PRE-EMPTION_CAPABILITY_DISABLED (1)
6176          */
6177         {&hf_gtpv2_bearer_qos_pci,
6178          {"PCI (Pre-emption Capability)", "gtpv2.bearer_qos_pci",
6179           FT_BOOLEAN, 8, TFS(&tfs_disabled_enabled), 0x40,
6180           NULL, HFILL}
6181         },
6182         {&hf_gtpv2_bearer_qos_label_qci,
6183          {"Label (QCI)", "gtpv2.bearer_qos_label_qci",
6184           FT_UINT8, BASE_DEC, NULL, 0x0,
6185           NULL, HFILL}
6186         },
6187         {&hf_gtpv2_bearer_qos_mbr_up,
6188          {"Maximum Bit Rate For Uplink", "gtpv2.bearer_qos_mbr_up",
6189           FT_UINT64, BASE_DEC, NULL, 0x0,
6190           NULL, HFILL}
6191         },
6192         {&hf_gtpv2_bearer_qos_mbr_down,
6193          {"Maximum Bit Rate For Downlink", "gtpv2.bearer_qos_mbr_down",
6194           FT_UINT64, BASE_DEC, NULL, 0x0,
6195           NULL, HFILL}
6196         },
6197         {&hf_gtpv2_bearer_qos_gbr_up,
6198          {"Guaranteed Bit Rate For Uplink", "gtpv2.bearer_qos_gbr_up",
6199           FT_UINT64, BASE_DEC, NULL, 0x0,
6200           NULL, HFILL}
6201         },
6202         {&hf_gtpv2_bearer_qos_gbr_down,
6203          {"Guaranteed Bit Rate For Downlink", "gtpv2.bearer_qos_gbr_down",
6204           FT_UINT64, BASE_DEC, NULL, 0x0,
6205           NULL, HFILL}
6206         },
6207         {&hf_gtpv2_flow_qos_label_qci,
6208          {"Label (QCI)", "gtpv2.flow_qos_label_qci",
6209           FT_UINT8, BASE_DEC, NULL, 0x0,
6210           NULL, HFILL}
6211         },
6212         {&hf_gtpv2_flow_qos_mbr_up,
6213          {"Maximum Bit Rate For Uplink", "gtpv2.flow_qos_mbr_up",
6214           FT_UINT64, BASE_DEC, NULL, 0x0,
6215           NULL, HFILL}
6216         },
6217         {&hf_gtpv2_flow_qos_mbr_down,
6218          {"Maximum Bit Rate For Downlink", "gtpv2.flow_qos_mbr_down",
6219           FT_UINT64, BASE_DEC, NULL, 0x0,
6220           NULL, HFILL}
6221         },
6222         {&hf_gtpv2_flow_qos_gbr_up,
6223          {"Guaranteed Bit Rate For Uplink", "gtpv2.flow_qos_gbr_up",
6224           FT_UINT64, BASE_DEC, NULL, 0x0,
6225           NULL, HFILL}
6226         },
6227         {&hf_gtpv2_flow_qos_gbr_down,
6228          {"Guaranteed Bit Rate For Downlink", "gtpv2.flow_qos_gbr_down",
6229           FT_UINT64, BASE_DEC, NULL, 0x0,
6230           NULL, HFILL}
6231         },
6232         { &hf_gtpv2_rat_type,
6233           {"RAT Type", "gtpv2.rat_type",
6234            FT_UINT8, BASE_DEC|BASE_EXT_STRING, &gtpv2_rat_type_vals_ext, 0x0,
6235            NULL, HFILL}
6236         },
6237         { &hf_gtpv2_uli_ecgi_flg,
6238           {"ECGI Present Flag", "gtpv2.uli_ecgi_flg",
6239            FT_BOOLEAN, 8, NULL, GTPv2_ULI_ECGI_MASK,
6240            NULL, HFILL}
6241         },
6242         { &hf_gtpv2_uli_lai_flg,
6243           {"LAI Present Flag", "gtpv2.uli_lai_flg",
6244            FT_BOOLEAN, 8, NULL, GTPv2_ULI_LAI_MASK,
6245            NULL, HFILL}
6246         },
6247         { &hf_gtpv2_uli_tai_flg,
6248           {"TAI Present Flag", "gtpv2.uli_tai_flg",
6249            FT_BOOLEAN, 8, NULL, GTPv2_ULI_TAI_MASK,
6250            NULL, HFILL}
6251         },
6252         { &hf_gtpv2_uli_rai_flg,
6253           {"RAI Present Flag", "gtpv2.uli_rai_flg",
6254            FT_BOOLEAN, 8, NULL, GTPv2_ULI_RAI_MASK,
6255            NULL, HFILL}
6256         },
6257         { &hf_gtpv2_uli_sai_flg,
6258           {"SAI Present Flag", "gtpv2.uli_sai_flg",
6259            FT_BOOLEAN, 8, NULL, GTPv2_ULI_SAI_MASK,
6260            NULL, HFILL}
6261         },
6262         { &hf_gtpv2_uli_cgi_flg,
6263           {"CGI Present Flag", "gtpv2.uli_cgi_flg",
6264            FT_BOOLEAN, 8, NULL, GTPv2_ULI_CGI_MASK,
6265            NULL, HFILL}
6266         },
6267         { &hf_gtpv2_glt,
6268           {"Geographic Location Type", "gtpv2.glt",
6269            FT_UINT8, BASE_DEC, VALS(geographic_location_type_vals), 0x0,
6270            NULL, HFILL}
6271         },
6272         { &hf_gtpv2_uli_cgi_lac,
6273           {"Location Area Code", "gtpv2.uli_cgi_lac",
6274            FT_UINT16, BASE_HEX_DEC, NULL, 0x0,
6275            NULL, HFILL}
6276         },
6277         { &hf_gtpv2_uli_cgi_ci,
6278           {"Cell Identity", "gtpv2.uli_cgi_ci",
6279            FT_UINT16, BASE_DEC, NULL, 0x0,
6280            NULL, HFILL}
6281         },
6282         { &hf_gtpv2_uli_sai_lac,
6283           {"Location Area Code", "gtpv2.uli_sai_lac",
6284            FT_UINT16, BASE_HEX_DEC, NULL, 0x0,
6285            NULL, HFILL}
6286         },
6287         { &hf_gtpv2_uli_sai_sac,
6288           {"Service Area Code", "gtpv2.uli_sai_sac",
6289            FT_UINT16, BASE_HEX_DEC, NULL, 0x0,
6290            NULL, HFILL}
6291         },
6292         { &hf_gtpv2_uli_rai_lac,
6293           {"Location Area Code", "gtpv2.uli_rai_lac",
6294            FT_UINT16, BASE_HEX_DEC, NULL, 0x0,
6295            NULL, HFILL}
6296         },
6297         { &hf_gtpv2_uli_rai_rac,
6298           {"Routing Area Code", "gtpv2.uli_rai_rac",
6299            FT_UINT16, BASE_HEX_DEC, NULL, 0x0,
6300            NULL, HFILL}
6301         },
6302         { &hf_gtpv2_uli_tai_tac,
6303           {"Tracking Area Code", "gtpv2.uli_tai_tac",
6304            FT_UINT16, BASE_HEX_DEC, NULL, 0x0,
6305            NULL, HFILL}
6306         },
6307         {&hf_gtpv2_uli_ecgi_eci,
6308          {"ECI (E-UTRAN Cell Identifier)", "gtpv2.uli_ecgi_eci",
6309           FT_UINT32, BASE_DEC, NULL, 0x0,
6310           NULL, HFILL}
6311         },
6312         {&hf_gtpv2_uli_lai_lac,
6313          {"Location Area Code (LAC)", "gtpv2.uli_lai_lac",
6314           FT_UINT16, BASE_HEX_DEC, NULL, 0x0,
6315           NULL, HFILL}
6316         },
6317         {&hf_gtpv2_uli_ecgi_eci_spare,
6318          {"Spare", "gtpv2.uli_ecgi_eci_spare",
6319           FT_UINT8, BASE_DEC, NULL, 0x0,
6320           NULL, HFILL}
6321         },
6322         { &hf_gtpv2_nsapi,
6323           {"NSAPI", "gtpv2.nsapi",
6324            FT_UINT8, BASE_DEC, NULL, 0x0f,
6325            NULL, HFILL}
6326         },
6327         {&hf_gtpv2_f_teid_v4,
6328          {"V4", "gtpv2.f_teid_v4",
6329           FT_BOOLEAN, 8, TFS(&gtpv2_f_teid_v4_vals), 0x80,
6330           NULL, HFILL}
6331         },
6332         {&hf_gtpv2_f_teid_v6,
6333          {"V6", "gtpv2.f_teid_v6",
6334           FT_BOOLEAN, 8, TFS(&gtpv2_f_teid_v6_vals), 0x40,
6335           NULL, HFILL}
6336         },
6337         {&hf_gtpv2_f_teid_interface_type,
6338          {"Interface Type", "gtpv2.f_teid_interface_type",
6339           FT_UINT8, BASE_DEC|BASE_EXT_STRING, &gtpv2_f_teid_interface_type_vals_ext, 0x3f,
6340           NULL , HFILL}
6341         },
6342         {&hf_gtpv2_f_teid_gre_key,
6343          {"TEID/GRE Key", "gtpv2.f_teid_gre_key",
6344           FT_UINT32, BASE_HEX, NULL, 0x0,
6345           NULL , HFILL}
6346         },
6347         { &hf_gtpv2_f_teid_ipv4,
6348           {"F-TEID IPv4", "gtpv2.f_teid_ipv4",
6349            FT_IPv4, BASE_NONE, NULL, 0x0,
6350            NULL, HFILL}
6351         },
6352         { &hf_gtpv2_f_teid_ipv6,
6353           {"F-TEID IPv6", "gtpv2.f_teid_ipv6",
6354            FT_IPv6, BASE_NONE, NULL, 0x0,
6355            NULL, HFILL}
6356         },
6357         { &hf_gtpv2_tmsi,
6358           {"TMSI", "gtpv2.tmsi",
6359            FT_UINT32, BASE_HEX, NULL, 0x0,
6360            NULL, HFILL}
6361         },
6362         { &hf_gtpv2_hsgw_addr_f_len,
6363           {"HSGW Address for forwarding Length", "gtpv2.hsgw_addr_f_len",
6364            FT_UINT8, BASE_DEC, NULL, 0x0,
6365            NULL, HFILL}
6366         },
6367         { &hf_gtpv2_hsgw_addr_ipv4,
6368           {"HSGW Address for forwarding", "gtpv2.hsgw_addr_ipv4",
6369            FT_IPv4, BASE_NONE, NULL, 0x0,
6370            NULL, HFILL}
6371         },
6372         { &hf_gtpv2_hsgw_addr_ipv6,
6373           {"HSGW Address for forwarding", "gtpv2.hsgw_addr_ipv6",
6374            FT_IPv6, BASE_NONE, NULL, 0x0,
6375            NULL, HFILL}
6376         },
6377         { &hf_gtpv2_gre_key,
6378           {"GRE Key", "gtpv2.gre_key",
6379            FT_UINT32, BASE_DEC, NULL, 0x0,
6380            NULL , HFILL}
6381         },
6382         { &hf_gtpv2_sgw_addr_ipv4,
6383           {"Serving GW Address", "gtpv2.sgw_addr_ipv4",
6384            FT_IPv4, BASE_NONE, NULL, 0x0,
6385            NULL, HFILL}
6386         },
6387         { &hf_gtpv2_sgw_addr_ipv6,
6388           {"Serving GW Address", "gtpv2.sgw_addr_ipv6",
6389            FT_IPv6, BASE_NONE, NULL, 0x0,
6390            NULL, HFILL}
6391         },
6392         { &hf_gtpv2_sgw_s1u_teid,
6393           {"Serving GW S1-U TEID", "gtpv2.sgw_s1u_teid",
6394            FT_UINT32, BASE_HEX, NULL, 0x0,
6395            NULL, HFILL}
6396         },
6397         {&hf_gtpv2_delay_value,
6398          {"Delay Value (In integer multiples of 50 milliseconds or zero)", "gtpv2.delay_value",
6399           FT_UINT8, BASE_DEC, NULL, 0x0,
6400           NULL, HFILL}
6401         },
6402         {&hf_gtpv2_charging_id,
6403          {"Charging id", "gtpv2.charging_id",
6404           FT_UINT32, BASE_DEC, NULL, 0x0,
6405           NULL, HFILL}
6406         },
6407         {&hf_gtpv2_charging_characteristic,
6408          {"Charging Characteristic", "gtpv2.charging_characteristic",
6409           FT_UINT16, BASE_HEX, NULL, 0xffff,
6410           NULL, HFILL}
6411         },
6412         {&hf_gtpv2_bearer_flag_ppc,
6413          {"PPC (Prohibit Payload Compression)", "gtpv2.bearer_flag.ppc",
6414           FT_BOOLEAN, 8, NULL, 0x01,
6415           NULL, HFILL}
6416         },
6417         {&hf_gtpv2_bearer_flag_vb,
6418          {"VB (Voice Bearer)", "gtpv2.bearer_flag.vb",
6419           FT_BOOLEAN, 8, NULL, 0x02,
6420           NULL, HFILL}
6421         },
6422         {&hf_gtpv2_pti,
6423          {"Procedure Transaction Id", "gtpv2.pti",
6424           FT_UINT8, BASE_DEC, NULL, 0x0,
6425           NULL, HFILL}
6426         },
6427         /* MM Context */
6428         { &hf_gtpv2_mm_context_sm,
6429           {"Security Mode", "gtpv2.mm_context_sm",
6430            FT_UINT8, BASE_DEC, VALS(gtpv2_mm_context_security_mode), 0xe0,
6431            NULL, HFILL}
6432         },
6433         { &hf_gtpv2_mm_context_nhi,
6434           {"NHI(Next Hop Indicator)", "gtpv2.mm_context_nhi",
6435            FT_BOOLEAN, 8, TFS(&gtpv2_nhi_vals), 0x10,
6436            NULL, HFILL}
6437         },
6438         { &hf_gtpv2_mm_context_drxi,
6439           {"DRXI", "gtpv2.mm_context_drxi",
6440            FT_UINT8, BASE_DEC, NULL, 0x08,
6441            NULL, HFILL}
6442         },
6443         { &hf_gtpv2_mm_context_cksn,
6444           {"CKSN", "gtpv2.mm_context_cksn",
6445            FT_UINT8, BASE_DEC, NULL, 0x07,
6446            NULL, HFILL}
6447         },
6448         { &hf_gtpv2_mm_context_cksn_ksi,
6449           {"CKSN/KSI", "gtpv2.mm_context_cksn_ksi",
6450            FT_UINT8, BASE_DEC, NULL, 0x07,
6451            NULL, HFILL}
6452         },
6453         { &hf_gtpv2_mm_context_ksi_a,
6454           {"KSI_asme", "gtpv2.mm_context_ksi_a",
6455            FT_UINT8, BASE_DEC, NULL, 0x07,
6456            NULL, HFILL}
6457         },
6458         { &hf_gtpv2_mm_context_nr_tri,
6459           {"Number of Triplet", "gtpv2.mm_context_nr_tri",
6460            FT_UINT8, BASE_DEC, NULL, 0xe0,
6461            NULL, HFILL}
6462         },
6463         { &hf_gtpv2_mm_context_used_cipher,
6464           {"Used Cipher", "gtpv2.mm_context_used_cipher",
6465            FT_UINT8, BASE_DEC, VALS(gtpv2_mm_context_used_cipher_vals), 0x07,
6466            NULL, HFILL}
6467         },
6468         { &hf_gtpv2_mm_context_unipa,
6469           {"Used NAS integrity protection algorithm", "gtpv2.mm_context_unipa",
6470            FT_UINT8, BASE_DEC, VALS(gtpv2_mm_context_unipa_vals), 0x70,
6471            NULL, HFILL}
6472         },
6473
6474         { &hf_gtpv2_mm_context_unc,
6475           {"Used NAS Cipher", "gtpv2.mm_context_unc",
6476            FT_UINT8, BASE_DEC, VALS(gtpv2_mm_context_unc_vals), 0x0f,
6477            NULL, HFILL}
6478         },
6479         { &hf_gtpv2_mm_context_nas_dl_cnt,
6480           {"NAS Downlink Count", "gtpv2.mm_context_nas_dl_cnt",
6481            FT_UINT24, BASE_DEC, NULL, 0x0,
6482            NULL, HFILL}
6483         },
6484         { &hf_gtpv2_mm_context_nas_ul_cnt,
6485           {"NAS Uplink Count", "gtpv2.mm_context_nas_ul_cnt",
6486            FT_UINT24, BASE_DEC, NULL, 0x0,
6487            NULL, HFILL}
6488         },
6489         { &hf_gtpv2_mm_context_kasme,
6490           {"Kasme", "gtpv2.mm_context_kasme",
6491            FT_BYTES, BASE_NONE, NULL, 0x0,
6492            NULL, HFILL}
6493         },
6494         { &hf_gtpv2_mm_context_rand,
6495           {"RAND", "gtpv2.mm_context_rand",
6496            FT_BYTES, BASE_NONE, NULL, 0x0,
6497            NULL, HFILL}
6498         },
6499         { &hf_gtpv2_mm_context_xres_len,
6500           {"XRES Length", "gtpv2.mm_context_xres_len",
6501            FT_UINT8, BASE_DEC, NULL, 0x0,
6502            NULL, HFILL}
6503         },
6504         { &hf_gtpv2_mm_context_xres,
6505           {"XRES", "gtpv2.mm_context_xres",
6506            FT_BYTES, BASE_NONE, NULL, 0x0,
6507            NULL, HFILL}
6508         },
6509         { &hf_gtpv2_mm_context_autn_len,
6510           {"AUTN Length", "gtpv2.mm_context_autn_len",
6511            FT_UINT8, BASE_DEC, NULL, 0x0,
6512            NULL, HFILL}
6513         },
6514         { &hf_gtpv2_mm_context_autn,
6515           {"AUTN", "gtpv2.mm_context_autn",
6516            FT_BYTES, BASE_NONE, NULL, 0x0,
6517            NULL, HFILL}
6518         },
6519         { &hf_gtpv2_mm_context_drx,
6520           {"DRX", "gtpv2.mm_context_drx",
6521            FT_UINT16, BASE_HEX, NULL, 0x0,
6522            NULL, HFILL}
6523         },
6524         { &hf_gtpv2_vdp_length,
6525           {"VDP and UE's Usage Setting length", "gtpv2.vdp_length",
6526            FT_UINT8, BASE_DEC, NULL, 0x0,
6527            NULL, HFILL}
6528         },
6529
6530         { &hf_gtpv2_mm_context_ue_net_cap_len,
6531           {"Length of UE Network Capability", "gtpv2.mm_context_ue_net_cap_len",
6532            FT_UINT8, BASE_DEC, NULL, 0x0,
6533            NULL, HFILL}
6534         },
6535         { &hf_gtpv2_mm_context_ms_net_cap_len,
6536           {"Length of MS Network Capability", "gtpv2.mm_context_ms_net_cap_len",
6537            FT_UINT8, BASE_DEC, NULL, 0x0,
6538            NULL, HFILL}
6539         },
6540         { &hf_gtpv2_mm_context_mei_len,
6541           {"Length of Mobile Equipment Identity (MEI)", "gtpv2.mm_context_mei_len",
6542            FT_UINT8, BASE_DEC, NULL, 0x0,
6543            NULL, HFILL}
6544         },
6545         { &hf_gtpv2_mm_context_vdp_len,
6546           {"Length of Voice Domain Preference and UE's Usage Setting", "gtpv2.mm_context_vdp_len",
6547            FT_UINT8, BASE_DEC, NULL, 0x0,
6548            NULL, HFILL}
6549         },
6550         { &hf_gtpv2_una,
6551           { "UTRAN", "gtpv2.mm_context.una",
6552             FT_BOOLEAN, 8, TFS(&tfs_not_allowed_allowed), 0x01,
6553             NULL, HFILL }
6554         },
6555         { &hf_gtpv2_gena,
6556           { "GERAN", "gtpv2.mm_context.gena",
6557             FT_BOOLEAN, 8, TFS(&tfs_not_allowed_allowed), 0x02,
6558             NULL, HFILL }
6559         },
6560         { &hf_gtpv2_gana,
6561           { "GAN", "gtpv2.mm_context.gana",
6562             FT_BOOLEAN, 8, TFS(&tfs_not_allowed_allowed), 0x04,
6563             NULL, HFILL }
6564         },
6565         { &hf_gtpv2_ina,
6566           { "I-HSPA-EVOLUTION", "gtpv2.mm_context.ina",
6567             FT_BOOLEAN, 8, TFS(&tfs_not_allowed_allowed), 0x08,
6568             NULL, HFILL }
6569         },
6570         { &hf_gtpv2_ena,
6571           { "E-UTRAN", "gtpv2.mm_context.ena",
6572             FT_BOOLEAN, 8, TFS(&tfs_not_allowed_allowed), 0x10,
6573             NULL, HFILL }
6574         },
6575         { &hf_gtpv2_hnna,
6576           { "HO-toNone3GPP-Access", "gtpv2.mm_context.hnna",
6577             FT_BOOLEAN, 8, TFS(&tfs_not_allowed_allowed), 0x20,
6578             NULL, HFILL }
6579         },
6580         { &hf_gtpv2_mm_context_ksi,
6581           {"KSI", "gtpv2.mm_context_ksi",
6582            FT_UINT8, BASE_DEC, NULL, 0x07,
6583            NULL, HFILL}
6584         },
6585         { &hf_gtpv2_mm_context_nr_qui,
6586           {"Number of Quintuplets", "gtpv2.mm_context_nr_qui",
6587            FT_UINT8, BASE_DEC, NULL, 0xe0,
6588            NULL, HFILL}
6589         },
6590
6591         { &hf_gtpv2_mm_context_nr_qua,
6592           {"Number of Quadruplet", "gtpv2.mm_context_nr_qua",
6593            FT_UINT8, BASE_DEC, NULL, 0x1c,
6594            NULL, HFILL}
6595         },
6596         { &hf_gtpv2_mm_context_uamb_ri,
6597           {"UAMB RI", "gtpv2.mm_context_uamb_ri",
6598            FT_BOOLEAN, 8, NULL, 0x02,
6599            NULL, HFILL}
6600         },
6601         { &hf_gtpv2_mm_context_osci,
6602           {"OSCI", "gtpv2.mm_context_osci",
6603            FT_BOOLEAN, 8, NULL, 0x02,
6604            NULL, HFILL}
6605         },
6606         { &hf_gtpv2_mm_context_samb_ri,
6607           {"SAMB RI", "gtpv2.mm_context_samb_ri",
6608            FT_BOOLEAN, 8, NULL, 0x0,
6609            NULL, HFILL}
6610         },
6611         { &hf_gtpv2_ue_time_zone_dst,
6612           {"Daylight Saving Time", "gtpv2.ue_time_zone_dst",
6613            FT_UINT8, BASE_DEC, VALS(gtpv2_ue_time_zone_dst_vals), 0x03,
6614            NULL, HFILL}
6615         },
6616         { &hf_gtpv2_fq_csid_type,
6617           {"Node-ID Type", "gtpv2.fq_csid_type",
6618            FT_UINT8, BASE_DEC, NULL, 0xf0,
6619            NULL, HFILL}
6620         },
6621         { &hf_gtpv2_fq_csid_nr,
6622           {"Number of CSIDs", "gtpv2.fq_csid_nr",
6623            FT_UINT8, BASE_DEC, NULL, 0x0f,
6624            NULL, HFILL}
6625         },
6626         { &hf_gtpv2_fq_csid_ipv4,
6627           {"Node-ID (IPv4)", "gtpv2.fq_csid_ipv4",
6628            FT_IPv4, BASE_NONE, NULL, 0x0,
6629            NULL, HFILL}
6630         },
6631         { &hf_gtpv2_fq_csid_ipv6,
6632           {"Node-ID (IPv6)", "gtpv2.fq_csid_ipv6",
6633            FT_IPv6, BASE_NONE, NULL, 0x0,
6634            NULL, HFILL}
6635         },
6636         { &hf_gtpv2_fq_csid_id,
6637           {"CSID", "gtpv2.fq_csid_id",
6638            FT_UINT16, BASE_DEC, NULL, 0x0,
6639            NULL, HFILL}
6640         },
6641         { &hf_gtpv2_complete_req_msg_type,
6642           {"Complete Request Message Type", "gtpv2.complete_req_msg_type",
6643            FT_UINT8, BASE_DEC, VALS(gtpv2_complete_req_msg_type_vals), 0x0,
6644            NULL, HFILL}
6645         },
6646         {&hf_gtpv2_mme_grp_id,
6647          {"MME Group ID", "gtpv2.mme_grp_id",
6648           FT_UINT16, BASE_DEC, NULL, 0x0,
6649           NULL, HFILL}
6650         },
6651         { &hf_gtpv2_mme_code,
6652           {"MME Code", "gtpv2.mme_code",
6653            FT_UINT8, BASE_DEC, NULL, 0x0,
6654            NULL, HFILL}
6655         },
6656         { &hf_gtpv2_m_tmsi,
6657           {"M-TMSI", "gtpv2.m_tmsi",
6658            FT_BYTES, BASE_NONE, NULL, 0x0,
6659            NULL, HFILL}
6660         },
6661         { &hf_gtpv2_container_type,
6662           {"Container Type", "gtpv2.container_type",
6663            FT_UINT8, BASE_DEC, VALS(gtpv2_container_type_vals), 0x0f,
6664            NULL, HFILL}
6665         },
6666         { &hf_gtpv2_cause_type,
6667           {"Cause Type", "gtpv2.cause_type",
6668            FT_UINT8, BASE_DEC|BASE_EXT_STRING, &gtpv2_cause_type_vals_ext, 0x0f,
6669            NULL, HFILL}
6670         },
6671         { &hf_gtpv2_CauseRadioNetwork,
6672           {"Radio Network Layer Cause", "gtpv2.CauseRadioNetwork",
6673            FT_UINT8, BASE_DEC, VALS(s1ap_CauseRadioNetwork_vals), 0x0,
6674            NULL, HFILL}
6675         },
6676         { &hf_gtpv2_CauseTransport,
6677           {"Transport Layer Cause", "gtpv2.CauseTransport",
6678            FT_UINT8, BASE_DEC, VALS(s1ap_CauseTransport_vals), 0x0,
6679            NULL, HFILL}
6680         },
6681         { &hf_gtpv2_CauseNas,
6682           {"NAS Cause", "gtpv2.CauseNas",
6683            FT_UINT8, BASE_DEC, VALS(s1ap_CauseNas_vals), 0x0,
6684            NULL, HFILL}
6685         },
6686         { &hf_gtpv2_CauseMisc,
6687           {"Miscellaneous Cause", "gtpv2.CauseMisc",
6688            FT_UINT8, BASE_DEC, VALS(s1ap_CauseMisc_vals), 0x0,
6689            NULL, HFILL}
6690         },
6691         { &hf_gtpv2_target_type,
6692           {"Target Type", "gtpv2.target_type",
6693            FT_UINT8, BASE_DEC|BASE_EXT_STRING, &gtpv2_target_type_vals_ext, 0x0,
6694            NULL, HFILL}
6695         },
6696         {&hf_gtpv2_macro_enodeb_id,
6697          {"Macro eNodeB ID", "gtpv2.macro_enodeb_id",
6698           FT_UINT24, BASE_HEX, NULL, 0x0fffff,
6699           NULL, HFILL}
6700         },
6701         { &hf_gtpv2_CauseProtocol,
6702           {"Protocol Cause", "gtpv2.CauseProtocol",
6703            FT_UINT8, BASE_DEC, VALS(s1ap_CauseProtocol_vals), 0x0,
6704            NULL, HFILL}
6705         },
6706         {&hf_gtpv2_apn_rest,
6707          {"APN Restriction", "gtpv2.apn_rest",
6708           FT_UINT8, BASE_DEC, NULL, 0x0,
6709           NULL, HFILL}
6710         },
6711         {&hf_gtpv2_selec_mode,
6712          {"Selection Mode", "gtpv2.selec_mode",
6713           FT_UINT8, BASE_DEC, VALS(gtpv2_selec_mode_vals), 0x03,
6714           NULL, HFILL}
6715         },
6716         { &hf_gtpv2_source_type,
6717           {"Source Type", "gtpv2.source_type",
6718            FT_UINT8, BASE_DEC, NULL, 0x0,
6719            NULL, HFILL}
6720         },
6721         {&hf_gtpv2_bearer_control_mode,
6722          {"Bearer Control Mode", "gtpv2.bearer_control_mode",
6723           FT_UINT8, BASE_DEC, VALS(gtpv2_bearer_control_mode_vals), 0x0,
6724           NULL, HFILL}
6725         },
6726         { &hf_gtpv2_cng_rep_act,
6727           {"Change Reporting Action", "gtpv2.cng_rep_act",
6728            FT_UINT8, BASE_DEC, VALS(gtpv2_cng_rep_act_vals), 0x0,
6729            NULL, HFILL}
6730         },
6731         { &hf_gtpv2_node_type,
6732           {"Node Type", "gtpv2.node_type",
6733            FT_UINT8, BASE_DEC, VALS(gtpv2_node_type_vals), 0x0,
6734            NULL, HFILL}
6735         },
6736         {&hf_gtpv2_fqdn,
6737          {"FQDN", "gtpv2.fqdn",
6738           FT_STRING, BASE_NONE, NULL, 0x0,
6739           NULL, HFILL}
6740         },
6741         { &hf_gtpv2_enterprise_id,
6742           {"Enterprise ID", "gtpv2.enterprise_id",
6743            FT_UINT16, BASE_DEC|BASE_EXT_STRING, &sminmpec_values_ext, 0x0,
6744            NULL, HFILL}
6745         },
6746         { &hf_gtpv2_address_digits,
6747           { "Address digits", "gtpv2.address_digits",
6748             FT_STRING, BASE_NONE, NULL, 0,
6749             NULL, HFILL }
6750         },
6751         { &hf_gtpv2_ti,
6752           {"Transaction Identifier", "gtpv2.ti",
6753            FT_BYTES, BASE_NONE, NULL, 0x0,
6754            NULL, HFILL}
6755         },
6756         { &hf_gtpv2_bss_container_phx,
6757           {"PHX", "gtpv2.bss_cont.phx",
6758            FT_BOOLEAN, 8, TFS(&tfs_present_not_present), 0x08,
6759            NULL, HFILL}
6760         },
6761         { &hf_gtpv2_bss_con_sapi_flg,
6762           {"SAPI", "gtpv2.bss_cont.sapi_flg",
6763            FT_BOOLEAN, 8, TFS(&tfs_present_not_present), 0x04,
6764            NULL, HFILL}
6765         },
6766         { &hf_gtpv2_bss_con_rp_flg,
6767           {"RP", "gtpv2.bss_cont.rp_flg",
6768            FT_BOOLEAN, 8, TFS(&tfs_present_not_present), 0x02,
6769            NULL, HFILL}
6770         },
6771         { &hf_gtpv2_bss_con_pfi_flg,
6772           {"PFI", "gtpv2.bss_cont.pfi_flg",
6773            FT_BOOLEAN, 8, TFS(&tfs_present_not_present), 0x01,
6774            NULL, HFILL}
6775         },
6776         { &hf_gtpv2_bss_con_pfi,
6777           {"Packet Flow ID(PFI)", "gtpv2.bss_cont.pfi",
6778            FT_UINT8, BASE_DEC, NULL, 0x0,
6779            NULL, HFILL}
6780         },
6781         { &hf_gtpv2_bss_con_rp,
6782           {"Radio Priority(RP)", "gtpv2.bss_cont.rp",
6783            FT_UINT8, BASE_DEC, NULL, 0x07,
6784            NULL, HFILL}
6785         },
6786         { &hf_gtpv2_bss_con_sapi,
6787           {"SAPI", "gtpv2.bss_cont.sapi",
6788            FT_UINT8, BASE_DEC, NULL, 0xf0,
6789            NULL, HFILL}
6790         },
6791         { &hf_gtpv2_bss_con_xid_len,
6792           {"XiD parameters length", "gtpv2.bss_cont.xid_len",
6793            FT_UINT8, BASE_DEC, NULL, 0x0,
6794            NULL, HFILL}
6795         },
6796         { &hf_gtpv2_bss_con_xid,
6797           {"XiD parameters", "gtpv2.bss_cont.xid",
6798            FT_BYTES, BASE_NONE, NULL, 0x0,
6799            NULL, HFILL}
6800         },
6801         { &hf_gtpv2_home_enodeb_id,
6802           {"Home eNodeB ID", "gtpv2.home_enodeb_id",
6803            FT_UINT32, BASE_HEX, NULL, 0x0fffffff,
6804            NULL, HFILL}
6805         },
6806         { &hf_gtpv2_tac,
6807           {"Tracking Area Code (TAC)", "gtpv2.tac",
6808            FT_UINT16, BASE_DEC, NULL, 0x0,
6809            NULL, HFILL}
6810         },
6811         { &hf_gtpv2_mbms_service_area_nr,
6812           {"Number of MBMS Service Area codes", "gtpv2.mbms_service_area_nr",
6813            FT_UINT16, BASE_DEC, NULL, 0x0,
6814            NULL, HFILL}
6815         },
6816         { &hf_gtpv2_mbms_service_area_id,
6817           {"MBMS Service Area code (Service Area Identity)", "gtpv2.mbms_service_area_id",
6818            FT_UINT16, BASE_DEC, NULL, 0x0,
6819            NULL, HFILL}
6820         },
6821         { &hf_gtpv2_mbms_session_id,
6822           {"MBMS Session Identifier", "gtpv2.mbms_session_id",
6823            FT_BYTES, BASE_NONE, NULL, 0x0,
6824            NULL, HFILL}
6825         },
6826         { &hf_gtpv2_mbms_flow_id,
6827           {"MBMS Flow Identifier", "gtpv2.mbms_flow_id",
6828            FT_BYTES, BASE_NONE, NULL, 0x0,
6829            NULL, HFILL}
6830         },
6831         { &hf_gtpv2_cteid,
6832           {"Common Tunnel Endpoint Identifier", "gtpv2.cetid",
6833            FT_UINT32, BASE_DEC, NULL, 0x0,
6834            NULL, HFILL}
6835         },
6836         { &hf_gtpv2_ip_addr_type,
6837           {"IP Address Type", "gtpv2.ip_addr_type",
6838            FT_UINT8, BASE_DEC, NULL, 0xc0,
6839            NULL, HFILL}
6840         },
6841         { &hf_gtpv2_ip_addr_len,
6842           {"IP Address Length", "gtpv2.ip_addr_len",
6843            FT_UINT8, BASE_DEC, NULL, 0x3f,
6844            NULL, HFILL}
6845         },
6846         { &hf_gtpv2_mbms_ip_mc_dist_addrv4,
6847           {"MBMS IP Multicast Distribution Address (IPv4)", "gtpv2.mbms_ip_mc_dist_addrv4",
6848            FT_IPv4, BASE_NONE, NULL, 0x0,
6849            NULL, HFILL}
6850         },
6851         { &hf_gtpv2_mbms_ip_mc_dist_addrv6,
6852           {"MBMS IP Multicast Distribution Address (IPv6)", "gtpv2.mbms_ip_mc_dist_addrv6",
6853            FT_IPv6, BASE_NONE, NULL, 0x0,
6854            NULL, HFILL}
6855         },
6856         { &hf_gtpv2_mbms_ip_mc_src_addrv4,
6857           {"MBMS IP Multicast Source Address (IPv4)", "gtpv2.mbms_ip_mc_src_addrv4",
6858            FT_IPv4, BASE_NONE, NULL, 0x0,
6859            NULL, HFILL}
6860         },
6861         { &hf_gtpv2_mbms_ip_mc_src_addrv6,
6862           {"MBMS IP Multicast Source Address (IPv6)", "gtpv2.mbms_ip_mc_src_addrv6",
6863            FT_IPv6, BASE_NONE, NULL, 0x0,
6864            NULL, HFILL}
6865         },
6866         { &hf_gtpv2_mbms_hc_indicator,
6867           {"MBMS HC Indicator", "gtpv2.mbms_hc_indicator",
6868            FT_UINT8, BASE_DEC, VALS(gtpv2_mbms_hc_indicator_vals), 0x0,
6869            NULL, HFILL}
6870         },
6871         { &hf_gtpv2_mbms_dist_indication,
6872           {"MBMS Distribution Indication", "gtpv2.mbms_dist_indication",
6873            FT_UINT8, BASE_DEC, VALS(gtpv2_mbms_dist_indication_vals), 0x03,
6874            NULL, HFILL}
6875         },
6876         { &hf_gtpv2_subscriber_rfsp,
6877           {"Subscribed RFSP Index", "gtpv2.subscriber_rfsp",
6878            FT_INT16, BASE_DEC, NULL, 0x0,
6879            NULL, HFILL}
6880         },
6881         { &hf_gtpv2_rfsp_inuse,
6882           {"RFSP Index in Use", "gtpv2.rfsp_inuse",
6883            FT_INT16, BASE_DEC, NULL, 0x0,
6884            NULL, HFILL}
6885         },
6886         { &hf_gtpv2_mbms_service_id,
6887           {"MBMS Service ID", "gtpv2.mbms_service_id",
6888            FT_BYTES, BASE_NONE, NULL, 0x0,
6889            NULL, HFILL}
6890         },
6891         { &hf_gtpv2_add_flags_for_srvcc_ics,
6892           {"ICS (IMS Centralized Service)", "gtpv2.add_flags_for_srvcc_ics",
6893            FT_BOOLEAN, 8, NULL, 0x01,
6894            NULL, HFILL}
6895         },
6896         { &hf_gtpv2_vsrvcc_flag,
6897           {"VF (vSRVCC Flag)", "gtpv2.vsrvcc_flag",
6898            FT_BOOLEAN, 8, NULL, 0x02,
6899            NULL, HFILL}
6900         },
6901         { &hf_gtpv2_henb_info_report_fti,
6902           {"FTI", "gtpv2.henb_info_report_fti",
6903            FT_BOOLEAN, 8, TFS(&gtpv2_henb_info_report_fti_vals), 0x01,
6904            NULL, HFILL}
6905         },
6906         { &hf_gtpv2_ip4cp_subnet_prefix_len,
6907           {"Subnet Prefix Length", "gtpv2.ip4cp_subnet_prefix_len",
6908            FT_UINT8, BASE_DEC, NULL, 0x0,
6909            NULL, HFILL}
6910         },
6911         { &hf_gtpv2_ip4cp_ipv4,
6912           {"IPv4 Default Router Address", "gtpv2.ip4cp_ipv4",
6913            FT_IPv4, BASE_NONE, NULL, 0x0,
6914            NULL, HFILL}
6915         },
6916         { &hf_gtpv2_change_report_flags_sncr,
6917           {"SNCR (Service Network Change to Report)", "gtpv2.change_report_flags_sncr",
6918            FT_BOOLEAN, 8, NULL, 0x01,
6919            NULL, HFILL}
6920         },
6921         { &hf_gtpv2_change_report_flags_tzcr,
6922           {"TZCR (Time Zone Change to Report)", "gtpv2.change_report_flags_tzcr",
6923            FT_BOOLEAN, 8, NULL, 0x02,
6924            NULL, HFILL}
6925         },
6926         {&hf_gtpv2_action_indication_val,
6927          {"Action Indication", "gtpv2.action_indication_val",
6928           FT_UINT8, BASE_DEC|BASE_EXT_STRING, &gtpv2_action_indication_vals_ext, 0x07,
6929           NULL , HFILL}
6930         },
6931         { &hf_gtpv2_abs_time_mbms_data,
6932           {"Absolute Time of MBMS Data Transfer", "gtpv2.abs_time_mbms_data",
6933            FT_STRING, BASE_NONE, NULL, 0,
6934            NULL, HFILL}
6935         },
6936         { &hf_gtpv2_mbms_session_duration_days,
6937           {"MBMS Session Duration (days)", "gtpv2.mbms_session_duration_days",
6938            FT_UINT24, BASE_DEC, NULL, 0x00007F,
6939            NULL, HFILL}
6940         },
6941         { &hf_gtpv2_mbms_session_duration_secs,
6942           {"MBMS Session Duration (seconds)", "gtpv2.mbms_session_duration_secs",
6943            FT_UINT24, BASE_DEC, NULL, 0xFFFF80,
6944            NULL, HFILL}
6945         },
6946         { &hf_gtpv2_node_features_prn,
6947           {"PGW Restart Notification (PRN)", "gtpv2.node_features_prn",
6948            FT_BOOLEAN, 8, TFS(&tfs_enabled_disabled), 0x01,
6949            NULL, HFILL}
6950         },
6951         { &hf_gtpv2_node_features_mabr,
6952           {"Modify Access Bearers Request (MABR)", "gtpv2.node_features_mabr",
6953            FT_BOOLEAN, 8, TFS(&tfs_enabled_disabled), 0x02,
6954            NULL, HFILL}
6955         },
6956         { &hf_gtpv2_node_features_ntsr,
6957           {"Network Triggered Service Restoration (NTSR)", "gtpv2.node_features_ntsr",
6958            FT_BOOLEAN, 8, TFS(&tfs_enabled_disabled), 0x04,
6959            NULL, HFILL}
6960         },
6961         { &hf_gtpv2_time_to_data_xfer,
6962           {"MBMS Time to Data Transfer", "gtpv2.time_to_data_xfer",
6963            FT_STRING, BASE_NONE, NULL, 0,
6964            NULL, HFILL}
6965         },
6966         { &hf_gtpv2_arp_pvi,
6967           {"Pre-emption Vulnerability (PVI)", "gtpv2.arp_pvi",
6968            FT_BOOLEAN, 8, TFS(&tfs_disabled_enabled), 0x01,
6969            NULL, HFILL}
6970         },
6971         { &hf_gtpv2_arp_pl,
6972           {"Priority Level", "gtpv2.arp_pl",
6973            FT_UINT8, BASE_DEC, NULL, 0x3c,
6974            NULL, HFILL}
6975         },
6976         { &hf_gtpv2_arp_pci,
6977           {"Pre-emption Capability (PCI)", "gtpv2.arp_pci",
6978            FT_BOOLEAN, 8, TFS(&tfs_disabled_enabled), 0x40,
6979            NULL, HFILL}
6980         },
6981         { &hf_gtpv2_timer_unit,
6982           {"Timer unit", "gtpv2.timer_unit",
6983            FT_UINT8, BASE_DEC, VALS(gtpv2_timer_unit_vals), 0xe0,
6984            NULL, HFILL}
6985         },
6986         { &hf_gtpv2_timer_value,
6987           {"Timer value", "gtpv2.timer_value",
6988            FT_UINT8, BASE_DEC, NULL, 0x1f,
6989            NULL, HFILL}
6990         },
6991         { &hf_gtpv2_lapi,
6992           {"LAPI (Low Access Priority Indication)", "gtpv2.lapi",
6993            FT_BOOLEAN, 8, NULL, 0x01,
6994            NULL, HFILL}
6995         },
6996         { &hf_gtpv2_mm_context_higher_br_16mb_flg_len,
6997           {"Length of Higher bitrates than 16 Mbps flag", "gtpv2.mm_context_higher_br_16mb_flg_len",
6998            FT_UINT8, BASE_DEC, NULL, 0x0,
6999            NULL, HFILL}
7000         },
7001         { &hf_gtpv2_mm_context_higher_br_16mb_flg,
7002           {"Higher bitrates than 16 Mbps flag", "gtpv2.mm_context_higher_br_16mb_flg",
7003            FT_UINT8, BASE_DEC, VALS(gtpv2_mm_context_higher_br_16mb_flg_vals), 0x0,
7004            NULL, HFILL}
7005         },
7006         { &hf_gtpv2_mmbr_ul,
7007           {"Max MBR/APN-AMBR for uplink", "gtpv2.mmbr_ul",
7008            FT_UINT32, BASE_DEC, NULL, 0x0,
7009            NULL, HFILL}
7010         },
7011         { &hf_gtpv2_mmbr_dl,
7012           {"Max MBR/APN-AMBR for downlink", "gtpv2.mmbr_dl",
7013            FT_UINT32, BASE_DEC, NULL, 0x0,
7014            NULL, HFILL}
7015         },
7016     };
7017
7018     static gint *ett_gtpv2_array[] = {
7019         &ett_gtpv2,
7020         &ett_gtpv2_flags,
7021         &ett_gtpv2_ie,
7022         &ett_gtpv2_uli_flags,
7023         &ett_gtpv2_uli_field,
7024         &ett_gtpv2_bearer_ctx,
7025         &ett_gtpv2_PDN_conn,
7026         &ett_gtpv2_mm_context_flag,
7027         &ett_gtpv2_pdn_numbers_nsapi,
7028         &ett_gtpv2_tra_info_trigg,
7029         &ett_gtpv2_tra_info_trigg_msc_server,
7030         &ett_gtpv2_tra_info_trigg_mgw,
7031         &ett_gtpv2_tra_info_trigg_sgsn,
7032         &ett_gtpv2_tra_info_trigg_ggsn,
7033         &ett_gtpv2_tra_info_trigg_bm_sc,
7034         &ett_gtpv2_tra_info_trigg_sgw_mme,
7035         &ett_gtpv2_tra_info_interfaces,
7036         &ett_gtpv2_tra_info_interfaces_imsc_server,
7037         &ett_gtpv2_tra_info_interfaces_lmgw,
7038         &ett_gtpv2_tra_info_interfaces_lsgsn,
7039         &ett_gtpv2_tra_info_interfaces_lggsn,
7040         &ett_gtpv2_tra_info_interfaces_lrnc,
7041         &ett_gtpv2_tra_info_interfaces_lbm_sc,
7042         &ett_gtpv2_tra_info_interfaces_lmme,
7043         &ett_gtpv2_tra_info_interfaces_lsgw,
7044         &ett_gtpv2_tra_info_interfaces_lpdn_gw,
7045         &ett_gtpv2_tra_info_interfaces_lpdn_lenb,
7046         &ett_gtpv2_tra_info_ne_types,
7047         &ett_gtpv2_rai,
7048         &ett_gtpv2_stn_sr,
7049         &ett_gtpv2_ms_mark,
7050         &ett_gtpv2_supp_codec_list,
7051         &ett_gtpv2_bss_con,
7052         &ett_gtpv2_mm_context_auth_qua,
7053         &ett_gtpv2_mm_context_auth_qui,
7054         &ett_gtpv2_mm_context_auth_tri,
7055         &ett_gtpv2_mm_context_net_cap,
7056         &ett_gtpv2_ms_network_capability,
7057         &ett_gtpv2_vd_pref,
7058         &ett_gtpv2_access_rest_data,
7059         &ett_gtpv2_qua,
7060         &ett_gtpv2_qui,
7061     };
7062
7063     static ei_register_info ei[] = {
7064         { &ei_gtpv2_ie_data_not_dissected, { "gtpv2.ie_data_not_dissected", PI_PROTOCOL, PI_NOTE, "IE data not dissected yet", EXPFILL }},
7065         { &ei_gtpv2_ie_len_invalid, { "gtpv2.ie_len_invalid", PI_PROTOCOL, PI_ERROR, "Wrong length", EXPFILL }},
7066         { &ei_gtpv2_source_type_unknown, { "gtpv2.source_type.unknown",  PI_PROTOCOL, PI_ERROR, "Unknown source type", EXPFILL }},
7067         { &ei_gtpv2_fq_csid_type_bad, { "gtpv2.fq_csid_type.unknown", PI_PROTOCOL, PI_ERROR, "Wrong Node-ID Type", EXPFILL }},
7068     };
7069
7070     expert_module_t* expert_gtpv2;
7071
7072     proto_gtpv2 = proto_register_protocol("GPRS Tunneling Protocol V2", "GTPv2", "gtpv2");
7073     proto_register_field_array(proto_gtpv2, hf_gtpv2, array_length(hf_gtpv2));
7074     proto_register_subtree_array(ett_gtpv2_array, array_length(ett_gtpv2_array));
7075     expert_gtpv2 = expert_register_protocol(proto_gtpv2);
7076     expert_register_field_array(expert_gtpv2, ei, array_length(ei));
7077
7078     /* AVP Code: 22 3GPP-User-Location-Info */
7079     dissector_add_uint("diameter.3gpp", 22, new_create_dissector_handle(dissect_diameter_3gpp_uli, proto_gtpv2));
7080
7081     register_dissector("gtpv2", dissect_gtpv2, proto_gtpv2);
7082     /* Dissector table for private extensions */
7083     gtpv2_priv_ext_dissector_table = register_dissector_table("gtpv2.priv_ext", "GTPv2 PRIVATE EXT", FT_UINT16, BASE_DEC);
7084 }
7085
7086 void
7087 proto_reg_handoff_gtpv2(void)
7088 {
7089     nas_eps_handle = find_dissector("nas-eps");
7090 }
7091
7092 /*
7093  * Editor modelines
7094  *
7095  * Local Variables:
7096  * c-basic-offset: 4
7097  * tab-width: 8
7098  * indent-tabs-mode: nil
7099  * End:
7100  *
7101  * ex: set shiftwidth=4 tabstop=8 expandtab:
7102  * :indentSize=4:tabSize=8:noTabs=true:
7103  */