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