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