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