3 * Routines for GTP dissection
4 * Copyright 2001, Michal Melerowicz <michal.melerowicz@nokia.com>
5 * Nicolas Balkota <balkota@mac.com>
7 * $Id: packet-gtp.c,v 1.54 2003/04/29 17:56:47 guy Exp $
9 * Ethereal - Network traffic analyzer
10 * By Gerald Combs <gerald@ethereal.com>
11 * Copyright 1998 Gerald Combs
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
38 #include <epan/packet.h>
39 #include "packet-gtp.h"
40 #include "packet-ipv6.h"
41 #include "packet-ppp.h"
44 static dissector_table_t ppp_subdissector_table;
47 * All data related to GTP v0 (GPRS) uses "gtpv0" or "GTPv0",
48 * all data related to GTP v1 (UMTS) uses "gtpv1" or "GTPv1",
49 * if there is any gtp alone statement it means that this data is common
50 * for both: GPRS and UMTS
53 #define GTPv0_PORT 3386
54 #define GTPv1C_PORT 2123 /* 3G Control PDU */
55 #define GTPv1U_PORT 2152 /* 3G T-PDU */
57 #define GTPv0_HDR_LENGTH 20
58 #define GTPv1_HDR_LENGTH 12
59 #define GTP_PRIME_HDR_LENGTH 6
61 /* for function checking compliance with ETSI */
62 #define GTP_MANDATORY 1
63 #define GTP_OPTIONAL 2
64 #define GTP_CONDITIONAL 4
66 static int g_gtpv0_port = GTPv0_PORT;
67 static int g_gtpv1c_port = GTPv1C_PORT;
68 static int g_gtpv1u_port = GTPv1U_PORT;
70 void proto_reg_handoff_gtp(void);
72 static int proto_gtp = -1;
73 static int proto_gtpv0 = -1;
74 static int proto_gtpv1 = -1;
76 static int hf_gtpv0_flags = -1;
77 static int hf_gtpv0_flags_ver = -1;
78 static int hf_gtpv0_flags_pt = -1;
79 static int hf_gtpv0_flags_spare = -1;
80 #ifdef GTP_UNUSED_HANDLES
81 static int hf_gtpv0_flags_e = -1;
82 static int hf_gtpv0_flags_s = -1;
83 static int hf_gtpv0_flags_pn = -1;
85 static int hf_gtpv0_flags_snn = -1;
86 static int hf_gtpv0_message_type = -1;
87 static int hf_gtpv0_length = -1;
88 static int hf_gtpv0_seq_number = -1;
89 static int hf_gtpv0_flow_label = -1;
90 static int hf_gtpv0_sndcp_number = -1;
91 #ifdef GTP_UNUSED_HANDLES
92 static int hf_gtpv0_npdu_number = -1;
94 static int hf_gtpv0_tid = -1;
95 #ifdef GTP_UNUSED_HANDLES
96 static int hf_gtpv0_teid = -1;
97 static int hf_gtpv0_next = -1;
99 static int hf_gtpv0_cause = -1;
100 static int hf_gtpv0_imsi = -1;
101 static int hf_gtpv0_rai_mcc = -1;
102 static int hf_gtpv0_rai_mnc = -1;
103 static int hf_gtpv0_rai_rac = -1;
104 static int hf_gtpv0_rai_lac = -1;
105 static int hf_gtpv0_tlli = -1;
106 static int hf_gtpv0_ptmsi = -1;
107 static int hf_gtpv0_qos_spare1 = -1;
108 static int hf_gtpv0_qos_delay = -1;
109 static int hf_gtpv0_qos_mean = -1;
110 static int hf_gtpv0_qos_peak = -1;
111 static int hf_gtpv0_qos_spare2 = -1;
112 static int hf_gtpv0_qos_precedence = -1;
113 static int hf_gtpv0_qos_spare3 = -1;
114 static int hf_gtpv0_qos_reliability = -1;
115 static int hf_gtpv0_reorder = -1;
116 static int hf_gtpv0_map_cause = -1;
117 static int hf_gtpv0_ptmsi_sig = -1;
118 static int hf_gtpv0_ms_valid = -1;
119 static int hf_gtpv0_recovery = -1;
120 static int hf_gtpv0_sel_mode = -1;
121 static int hf_gtpv0_ext_flow_label = -1;
122 #ifdef GTP_UNUSED_HANDLES
123 static int hf_gtpv0_teid_data = -1; /* 3G */
125 static int hf_gtpv0_flow_sig = -1;
126 #ifdef GTP_UNUSED_HANDLES
127 static int hf_gtpv0_teid_cp = -1; /* 3G */
129 static int hf_gtpv0_nsapi = -1;
130 static int hf_gtpv0_flow_ii = -1;
131 #ifdef GTP_UNUSED_HANDLES
132 static int hf_gtpv0_teid_ii = -1; /* 3G */
134 static int hf_gtpv0_ms_reason = -1;
135 #ifdef GTP_UNUSED_HANDLES
136 static int hf_gtpv0_tear_ind = -1; /* 3G */
137 static int hf_gtpv0_ranap_cause = -1; /* 3G */
138 static int hf_gtpv0_rab_gtpu_dn = -1; /* 3G */
139 static int hf_gtpv0_rab_gtpu_up = -1; /* 3G */
140 static int hf_gtpv0_rab_pdu_dn = -1; /* 3G */
141 static int hf_gtpv0_rab_pdu_up = -1; /* 3G */
142 static int hf_gtpv0_rp_sms = -1; /* 3G */
143 static int hf_gtpv0_rp_spare = -1; /* 3G */
144 static int hf_gtpv0_rp_nsapi = -1; /* 3G */
145 static int hf_gtpv0_rp = -1; /* 3G */
146 static int hf_gtpv0_pkt_flow_id = -1; /* 3G */
147 static int hf_gtpv0_chrg_char_s = -1; /* 3G */
148 static int hf_gtpv0_chrg_char_n = -1; /* 3G */
149 static int hf_gtpv0_chrg_char_p = -1; /* 3G */
150 static int hf_gtpv0_chrg_char_f = -1; /* 3G */
151 static int hf_gtpv0_chrg_char_h = -1; /* 3G */
152 static int hf_gtpv0_chrg_char_r = -1; /* 3G */
153 static int hf_gtpv0_trace_ref = -1; /* 3G */
154 static int hf_gtpv0_trace_type = -1; /* 3G */
156 static int hf_gtpv0_tr_comm = -1; /* charging */
157 static int hf_gtpv0_chrg_id = -1;
158 static int hf_gtpv0_user_ipv4 = -1;
159 static int hf_gtpv0_user_ipv6 = -1;
160 static int hf_gtpv0_user_addr_pdp_org = -1;
161 static int hf_gtpv0_user_addr_pdp_type = -1;
162 static int hf_gtpv0_apn = -1;
163 static int hf_gtpv0_gsn_ipv4 = -1;
164 static int hf_gtpv0_gsn_ipv6 = -1;
165 static int hf_gtpv0_gsn_addr_type = -1;
166 static int hf_gtpv0_gsn_addr_len = -1;
167 static int hf_gtpv0_msisdn = -1;
168 #ifdef GTP_UNUSED_HANDLES
169 static int hf_gtpv0_qos_al_ret_priority = -1;
170 static int hf_gtpv0_qos_traf_class = -1;
171 static int hf_gtpv0_qos_del_order = -1;
172 static int hf_gtpv0_qos_del_err_sdu = -1;
173 static int hf_gtpv0_qos_max_sdu_size = -1;
174 static int hf_gtpv0_qos_max_ul = -1;
175 static int hf_gtpv0_qos_max_dl = -1;
176 static int hf_gtpv0_qos_res_ber = -1;
177 static int hf_gtpv0_qos_sdu_err_ratio = -1;
178 static int hf_gtpv0_qos_trans_delay = -1;
179 static int hf_gtpv0_qos_traf_handl_prio = -1;
180 static int hf_gtpv0_qos_guar_ul = -1;
181 static int hf_gtpv0_qos_guar_dl = -1;
182 static int hf_gtpv0_rnc_ipv4 = -1;
183 static int hf_gtpv0_rnc_ipv6 = -1;
185 static int hf_gtpv0_chrg_ipv4 = -1;
186 static int hf_gtpv0_chrg_ipv6 = -1;
187 static int hf_gtpv0_node_ipv4 = -1;
188 static int hf_gtpv0_node_ipv6 = -1;
189 static int hf_gtpv0_ext_id = -1;
190 static int hf_gtpv0_ext_val = -1;
191 static int hf_gtpv0_unknown = -1;
193 static int hf_gtpv1_flags = -1;
194 static int hf_gtpv1_flags_ver = -1;
195 static int hf_gtpv1_flags_pt = -1;
196 static int hf_gtpv1_flags_spare = -1;
197 static int hf_gtpv1_flags_e = -1;
198 static int hf_gtpv1_flags_s = -1;
199 static int hf_gtpv1_flags_pn = -1;
200 #ifdef GTP_UNUSED_HANDLES
201 static int hf_gtpv1_flags_snn = -1;
203 static int hf_gtpv1_message_type = -1;
204 static int hf_gtpv1_length = -1;
205 static int hf_gtpv1_seq_number = -1;
206 #ifdef GTP_UNUSED_HANDLES
207 static int hf_gtpv1_flow_label = -1;
208 static int hf_gtpv1_sndcp_number = -1;
210 static int hf_gtpv1_npdu_number = -1;
211 #ifdef GTP_UNUSED_HANDLES
212 static int hf_gtpv1_tid = -1;
214 static int hf_gtpv1_teid = -1;
215 static int hf_gtpv1_next = -1;
216 static int hf_gtpv1_cause = -1;
217 static int hf_gtpv1_imsi = -1;
218 static int hf_gtpv1_rai_mcc = -1;
219 static int hf_gtpv1_rai_mnc = -1;
220 static int hf_gtpv1_rai_rac = -1;
221 static int hf_gtpv1_rai_lac = -1;
222 static int hf_gtpv1_tlli = -1;
223 static int hf_gtpv1_ptmsi = -1;
224 static int hf_gtpv1_qos_spare1 = -1;
225 static int hf_gtpv1_qos_delay = -1;
226 static int hf_gtpv1_qos_mean = -1;
227 static int hf_gtpv1_qos_peak = -1;
228 static int hf_gtpv1_qos_spare2 = -1;
229 static int hf_gtpv1_qos_precedence = -1;
230 static int hf_gtpv1_qos_spare3 = -1;
231 static int hf_gtpv1_qos_reliability = -1;
232 static int hf_gtpv1_reorder = -1;
233 static int hf_gtpv1_map_cause = -1;
234 static int hf_gtpv1_ptmsi_sig = -1;
235 static int hf_gtpv1_ms_valid = -1;
236 static int hf_gtpv1_recovery = -1;
237 static int hf_gtpv1_sel_mode = -1;
238 #ifdef GTP_UNUSED_HANDLES
239 static int hf_gtpv1_ext_flow_label = -1;
241 static int hf_gtpv1_teid_data = -1; /* 3G */
242 #ifdef GTP_UNUSED_HANDLES
243 static int hf_gtpv1_flow_sig = -1;
245 static int hf_gtpv1_teid_cp = -1; /* 3G */
246 static int hf_gtpv1_nsapi = -1;
247 #ifdef GTP_UNUSED_HANDLES
248 static int hf_gtpv1_flow_ii = -1;
250 static int hf_gtpv1_teid_ii = -1; /* 3G */
251 static int hf_gtpv1_ms_reason = -1;
252 static int hf_gtpv1_tear_ind = -1; /* 3G */
253 static int hf_gtpv1_ranap_cause = -1; /* 3G */
254 static int hf_gtpv1_rab_gtpu_dn = -1; /* 3G */
255 static int hf_gtpv1_rab_gtpu_up = -1; /* 3G */
256 static int hf_gtpv1_rab_pdu_dn = -1; /* 3G */
257 static int hf_gtpv1_rab_pdu_up = -1; /* 3G */
258 static int hf_gtpv1_rp_sms = -1; /* 3G */
259 static int hf_gtpv1_rp_spare = -1; /* 3G */
260 static int hf_gtpv1_rp_nsapi = -1; /* 3G */
261 static int hf_gtpv1_rp = -1; /* 3G */
262 static int hf_gtpv1_pkt_flow_id = -1; /* 3G */
263 static int hf_gtpv1_chrg_char_s = -1; /* 3G */
264 static int hf_gtpv1_chrg_char_n = -1; /* 3G */
265 static int hf_gtpv1_chrg_char_p = -1; /* 3G */
266 static int hf_gtpv1_chrg_char_f = -1; /* 3G */
267 static int hf_gtpv1_chrg_char_h = -1; /* 3G */
268 static int hf_gtpv1_chrg_char_r = -1; /* 3G */
269 static int hf_gtpv1_trace_ref = -1; /* 3G */
270 static int hf_gtpv1_trace_type = -1; /* 3G */
271 static int hf_gtpv1_tr_comm = -1; /* charging */
272 static int hf_gtpv1_chrg_id = -1;
273 static int hf_gtpv1_user_ipv4 = -1;
274 static int hf_gtpv1_user_ipv6 = -1;
275 static int hf_gtpv1_user_addr_pdp_org = -1;
276 static int hf_gtpv1_user_addr_pdp_type = -1;
277 static int hf_gtpv1_apn = -1;
278 static int hf_gtpv1_gsn_ipv4 = -1;
279 static int hf_gtpv1_gsn_ipv6 = -1;
280 static int hf_gtpv1_gsn_addr_type = -1;
281 static int hf_gtpv1_gsn_addr_len = -1;
282 static int hf_gtpv1_msisdn = -1;
283 static int hf_gtpv1_qos_al_ret_priority = -1;
284 static int hf_gtpv1_qos_traf_class = -1;
285 static int hf_gtpv1_qos_del_order = -1;
286 static int hf_gtpv1_qos_del_err_sdu = -1;
287 static int hf_gtpv1_qos_max_sdu_size = -1;
288 static int hf_gtpv1_qos_max_ul = -1;
289 static int hf_gtpv1_qos_max_dl = -1;
290 static int hf_gtpv1_qos_res_ber = -1;
291 static int hf_gtpv1_qos_sdu_err_ratio = -1;
292 static int hf_gtpv1_qos_trans_delay = -1;
293 static int hf_gtpv1_qos_traf_handl_prio = -1;
294 static int hf_gtpv1_qos_guar_ul = -1;
295 static int hf_gtpv1_qos_guar_dl = -1;
296 static int hf_gtpv1_tft_code = -1;
297 static int hf_gtpv1_tft_spare = -1;
298 static int hf_gtpv1_tft_number = -1;
299 static int hf_gtpv1_tft_eval = -1;
300 static int hf_gtpv1_rnc_ipv4 = -1;
301 static int hf_gtpv1_rnc_ipv6 = -1;
302 static int hf_gtpv1_chrg_ipv4 = -1;
303 static int hf_gtpv1_chrg_ipv6 = -1;
304 static int hf_gtpv1_node_ipv4 = -1;
305 static int hf_gtpv1_node_ipv6 = -1;
306 static int hf_gtpv1_ext_id = -1;
307 static int hf_gtpv1_ext_val = -1;
308 static int hf_gtpv1_unknown = -1;
310 /* Initialize the subtree pointers */
311 static gint ett_gtp = -1;
312 static gint ett_gtp_flags = -1;
313 static gint ett_gtp_ext = -1;
314 static gint ett_gtp_rai = -1;
315 static gint ett_gtp_qos = -1;
316 static gint ett_gtp_auth_tri = -1;
317 static gint ett_gtp_flow_ii = -1;
318 static gint ett_gtp_rab_cntxt = -1;
319 static gint ett_gtp_rp = -1;
320 static gint ett_gtp_pkt_flow_id = -1;
321 static gint ett_gtp_chrg_char = -1;
322 static gint ett_gtp_user = -1;
323 static gint ett_gtp_mm = -1;
324 static gint ett_gtp_trip = -1;
325 static gint ett_gtp_quint = -1;
326 static gint ett_gtp_pdp = -1;
327 static gint ett_gtp_apn = -1;
328 static gint ett_gtp_proto = -1;
329 static gint ett_gtp_gsn_addr = -1;
330 static gint ett_gtp_tft = -1;
331 static gint ett_gtp_tft_pf = -1;
332 static gint ett_gtp_tft_flags = -1;
333 static gint ett_gtp_rab_setup = -1;
334 static gint ett_gtp_hdr_list = -1;
335 static gint ett_gtp_chrg_addr = -1;
336 static gint ett_gtp_node_addr = -1;
337 static gint ett_gtp_rel_pack = -1;
338 static gint ett_gtp_can_pack = -1;
339 static gint ett_gtp_data_resp = -1;
340 static gint ett_gtp_priv_ext = -1;
342 /* Definition of user preferences panel fields */
343 #define DONT_DISSECT_CDRS 2
345 static gboolean gtp_tpdu = TRUE;
346 static gint gtpv0_cdr_as = DONT_DISSECT_CDRS; /* 2 = do not dissect */
347 static gboolean gtpv0_etsi_order = FALSE;
348 static gboolean gtpv1_etsi_order = FALSE;
349 static int gtpv0_port = 0;
350 static int gtpv1c_port = 0;
351 static int gtpv1u_port = 0;
353 /* Definition of flags masks */
354 #define GTP_VER_MASK 0xE0
356 static const value_string ver_types[] = {
357 { 0, "GTP release 97/98 version" },
358 { 1, "GTP release 99 version" },
368 #define GTP_PT_MASK 0x10
369 #define GTP_SPARE_MASK 0x0E
370 #define GTPv1_SPARE_MASK 0x08
371 #define GTPv1_E_MASK 0x04
372 #define GTPv1_S_MASK 0x02
373 #define GTP_SNN_MASK 0x01
374 #define GTPv1_PN_MASK 0x01
376 /* Definition of 3G charging characteristics masks */
377 #define GTP_MASK_CHRG_CHAR_S 0xF000
378 #define GTP_MASK_CHRG_CHAR_N 0x0800
379 #define GTP_MASK_CHRG_CHAR_P 0x0400
380 #define GTP_MASK_CHRG_CHAR_F 0x0200
381 #define GTP_MASK_CHRG_CHAR_H 0x0100
382 #define GTP_MASK_CHRG_CHAR_R 0x00FF
384 /* Traffic Flow Templates mask */
385 #define GTPv1_TFT_CODE_MASK 0xE0
386 #define GTPv1_TFT_SPARE_MASK 0x10
387 #define GTPv1_TFT_NUMBER_MASK 0x0F
389 /* Definition of GSN Address masks */
390 #define GTP_EXT_GSN_ADDR_TYPE_MASK 0xC0
391 #define GTP_EXT_GSN_ADDR_LEN_MASK 0x3F
393 /* Definition of QoS masks */
394 #define GTP_EXT_QOS_SPARE1_MASK 0xC0
395 #define GTP_EXT_QOS_DELAY_MASK 0x38
396 #define GTP_EXT_QOS_RELIABILITY_MASK 0x07
397 #define GTP_EXT_QOS_PEAK_MASK 0xF0
398 #define GTP_EXT_QOS_SPARE2_MASK 0x08
399 #define GTP_EXT_QOS_PRECEDENCE_MASK 0x07
400 #define GTP_EXT_QOS_SPARE3_MASK 0xE0
401 #define GTP_EXT_QOS_MEAN_MASK 0x1F
402 #define GTP_EXT_QOS_TRAF_CLASS_MASK 0xE0
403 #define GTP_EXT_QOS_DEL_ORDER_MASK 0x18
404 #define GTP_EXT_QOS_DEL_ERR_SDU_MASK 0x07
405 #define GTP_EXT_QOS_RES_BER_MASK 0xF0
406 #define GTP_EXT_QOS_SDU_ERR_RATIO_MASK 0x0F
407 #define GTP_EXT_QOS_TRANS_DELAY_MASK 0xFC
408 #define GTP_EXT_QOS_TRAF_HANDL_PRIORITY_MASK 0x03
410 /* Definition of Radio Priority's masks */
411 #define GTPv1_EXT_RP_NSAPI_MASK 0xF0
412 #define GTPv1_EXT_RP_SPARE_MASK 0x08
413 #define GTPv1_EXT_RP_MASK 0x07
415 /* definitions of GTP messages */
416 #define GTP_MSG_UNKNOWN 0x00
417 #define GTP_MSG_ECHO_REQ 0x01
418 #define GTP_MSG_ECHO_RESP 0x02
419 #define GTP_MSG_VER_NOT_SUPP 0x03
420 #define GTP_MSG_NODE_ALIVE_REQ 0x04
421 #define GTP_MSG_NODE_ALIVE_RESP 0x05
422 #define GTP_MSG_REDIR_REQ 0x06
423 #define GTP_MSG_REDIR_RESP 0x07
424 #define GTP_MSG_CREATE_PDP_REQ 0x10
425 #define GTP_MSG_CREATE_PDP_RESP 0x11
426 #define GTP_MSG_UPDATE_PDP_REQ 0x12
427 #define GTP_MSG_UPDATE_PDP_RESP 0x13
428 #define GTP_MSG_DELETE_PDP_REQ 0x14
429 #define GTP_MSG_DELETE_PDP_RESP 0x15
430 #define GTP_MSG_CREATE_AA_PDP_REQ 0x16 /* 2G */
431 #define GTP_MSG_CREATE_AA_PDP_RESP 0x17 /* 2G */
432 #define GTP_MSG_DELETE_AA_PDP_REQ 0x18 /* 2G */
433 #define GTP_MSG_DELETE_AA_PDP_RESP 0x19 /* 2G */
434 #define GTP_MSG_ERR_IND 0x1A
435 #define GTP_MSG_PDU_NOTIFY_REQ 0x1B
436 #define GTP_MSG_PDU_NOTIFY_RESP 0x1C
437 #define GTP_MSG_PDU_NOTIFY_REJ_REQ 0x1D
438 #define GTP_MSG_PDU_NOTIFY_REJ_RESP 0x1E
439 #define GTP_MSG_SUPP_EXT_HDR 0x1F
440 #define GTP_MSG_SEND_ROUT_INFO_REQ 0x20
441 #define GTP_MSG_SEND_ROUT_INFO_RESP 0x21
442 #define GTP_MSG_FAIL_REP_REQ 0x22
443 #define GTP_MSG_FAIL_REP_RESP 0x23
444 #define GTP_MSG_MS_PRESENT_REQ 0x24
445 #define GTP_MSG_MS_PRESENT_RESP 0x25
446 #define GTP_MSG_IDENT_REQ 0x30
447 #define GTP_MSG_IDENT_RESP 0x31
448 #define GTP_MSG_SGSN_CNTXT_REQ 0x32
449 #define GTP_MSG_SGSN_CNTXT_RESP 0x33
450 #define GTP_MSG_SGSN_CNTXT_ACK 0x34
451 #define GTP_MSG_FORW_RELOC_REQ 0x35
452 #define GTP_MSG_FORW_RELOC_RESP 0x36
453 #define GTP_MSG_FORW_RELOC_COMP 0x37
454 #define GTP_MSG_RELOC_CANCEL_REQ 0x38
455 #define GTP_MSG_RELOC_CANCEL_RESP 0x39
456 #define GTP_MSG_FORW_SRNS_CNTXT 0x3A
457 #define GTP_MSG_FORW_RELOC_ACK 0x3B
458 #define GTP_MSG_FORW_SRNS_CNTXT_ACK 0x3C
459 #define GTP_MSG_DATA_TRANSF_REQ 0xF0
460 #define GTP_MSG_DATA_TRANSF_RESP 0xF1
461 #define GTP_MSG_TPDU 0xFF
463 static const value_string message_type[] = {
464 { GTP_MSG_UNKNOWN, "For future use" },
465 { GTP_MSG_ECHO_REQ, "Echo request" },
466 { GTP_MSG_ECHO_RESP, "Echo response" },
467 { GTP_MSG_VER_NOT_SUPP, "Version not supported" },
468 { GTP_MSG_NODE_ALIVE_REQ, "Node alive request" },
469 { GTP_MSG_NODE_ALIVE_RESP, "Node alive response" },
470 { GTP_MSG_REDIR_REQ, "Redirection request" },
471 { GTP_MSG_REDIR_RESP, "Redirection response" },
472 { GTP_MSG_CREATE_PDP_REQ, "Create PDP context request" },
473 { GTP_MSG_CREATE_PDP_RESP, "Create PDP context response" },
474 { GTP_MSG_UPDATE_PDP_REQ, "Update PDP context request" },
475 { GTP_MSG_UPDATE_PDP_RESP, "Update PDP context response" },
476 { GTP_MSG_DELETE_PDP_REQ, "Delete PDP context request" },
477 { GTP_MSG_DELETE_PDP_RESP, "Delete PDP context response" },
478 { GTP_MSG_CREATE_AA_PDP_REQ, "Create AA PDP Context Request" },
479 { GTP_MSG_CREATE_AA_PDP_RESP, "Create AA PDP Context Response" },
480 { GTP_MSG_DELETE_AA_PDP_REQ, "Delete AA PDP Context Request" },
481 { GTP_MSG_DELETE_AA_PDP_RESP, "Delete AA PDP Context Response" },
482 { GTP_MSG_ERR_IND, "Error indication" },
483 { GTP_MSG_PDU_NOTIFY_REQ, "PDU notification request" },
484 { GTP_MSG_PDU_NOTIFY_RESP, "PDU notification response" },
485 { GTP_MSG_PDU_NOTIFY_REJ_REQ, "PDU notification reject request" },
486 { GTP_MSG_PDU_NOTIFY_REJ_RESP, "PDU notification reject response" },
487 { GTP_MSG_SUPP_EXT_HDR, "Supported extension header notification" },
488 { GTP_MSG_SEND_ROUT_INFO_REQ, "Send routing information for GPRS request" },
489 { GTP_MSG_SEND_ROUT_INFO_RESP, "Send routing information for GPRS response" },
490 { GTP_MSG_FAIL_REP_REQ, "Failure report request" },
491 { GTP_MSG_FAIL_REP_RESP, "Failure report response" },
492 { GTP_MSG_MS_PRESENT_REQ, "Note MS GPRS present request" },
493 { GTP_MSG_MS_PRESENT_RESP, "Note MS GPRS present response" },
494 { GTP_MSG_IDENT_REQ, "Identification request" },
495 { GTP_MSG_IDENT_RESP, "Identification response" },
496 { GTP_MSG_SGSN_CNTXT_REQ, "SGSN context request" },
497 { GTP_MSG_SGSN_CNTXT_RESP, "SGSN context response" },
498 { GTP_MSG_SGSN_CNTXT_ACK, "SGSN context acknowledgement" },
499 { GTP_MSG_FORW_RELOC_REQ, "Forward relocation request" },
500 { GTP_MSG_FORW_RELOC_RESP, "Forward relocation response" },
501 { GTP_MSG_FORW_RELOC_COMP, "Forward relocation complete" },
502 { GTP_MSG_RELOC_CANCEL_REQ, "Relocation cancel request" },
503 { GTP_MSG_RELOC_CANCEL_RESP, "Relocation cancel response" },
504 { GTP_MSG_FORW_SRNS_CNTXT, "Forward SRNS context" },
505 { GTP_MSG_FORW_RELOC_ACK, "Forward relocation complete acknowledge" },
506 { GTP_MSG_FORW_SRNS_CNTXT_ACK, "Forward SRNS context acknowledge" },
507 { GTP_MSG_DATA_TRANSF_REQ, "Data record transfer request" },
508 { GTP_MSG_DATA_TRANSF_RESP, "Data record transfer response" },
509 { GTP_MSG_TPDU, "T-PDU" },
513 /* definitions of fields in extension header */
514 #define GTP_EXT_CAUSE 0x01
515 #define GTP_EXT_IMSI 0x02
516 #define GTP_EXT_RAI 0x03
517 #define GTP_EXT_TLLI 0x04
518 #define GTP_EXT_PTMSI 0x05
519 #define GTP_EXT_QOS_GPRS 0x06
520 #define GTP_EXT_REORDER 0x08
521 #define GTP_EXT_AUTH_TRI 0x09
522 #define GTP_EXT_MAP_CAUSE 0x0B
523 #define GTP_EXT_PTMSI_SIG 0x0C
524 #define GTP_EXT_MS_VALID 0x0D
525 #define GTP_EXT_RECOVER 0x0E
526 #define GTP_EXT_SEL_MODE 0x0F
528 #define GTP_EXT_16 0x10
529 #define GTP_EXT_FLOW_LABEL 0x10
530 #define GTP_EXT_TEID 0x10 /* 0xFF10 3G */
532 #define GTP_EXT_17 0x11
533 #define GTP_EXT_FLOW_SIG 0x11
534 #define GTP_EXT_TEID_CP 0x11 /* 0xFF11 3G */
536 #define GTP_EXT_18 0x12
537 #define GTP_EXT_FLOW_II 0x12
538 #define GTP_EXT_TEID_II 0x12 /* 0xFF12 3G*/
540 #define GTP_EXT_19 0x13
541 #define GTP_EXT_MS_REASON 0x13 /* same as 0x1D GTPv1_EXT_MS_REASON */
542 #define GTP_EXT_TEAR_IND 0x13 /* 0xFF13 3G*/
544 #define GTP_EXT_NSAPI 0x14 /* 3G */
545 #define GTP_EXT_RANAP_CAUSE 0x15 /* 3G */
546 #define GTP_EXT_RAB_CNTXT 0x16 /* 3G */
547 #define GTP_EXT_RP_SMS 0x17 /* 3G */
548 #define GTP_EXT_RP 0x18 /* 3G */
549 #define GTP_EXT_PKT_FLOW_ID 0x19 /* 3G */
550 #define GTP_EXT_CHRG_CHAR 0x1A /* 3G */
551 #define GTP_EXT_TRACE_REF 0x1B /* 3G */
552 #define GTP_EXT_TRACE_TYPE 0x1C /* 3G */
553 #define GTPv1_EXT_MS_REASON 0x1D /* 3G */
554 #define GTP_EXT_TR_COMM 0x7E /* charging */
555 #define GTP_EXT_CHRG_ID 0x7F
556 #define GTP_EXT_USER_ADDR 0x80
557 #define GTP_EXT_MM_CNTXT 0x81
558 #define GTP_EXT_PDP_CNTXT 0x82
559 #define GTP_EXT_APN 0x83
560 #define GTP_EXT_PROTO_CONF 0x84
561 #define GTP_EXT_GSN_ADDR 0x85
562 #define GTP_EXT_MSISDN 0x86
563 #define GTP_EXT_QOS_UMTS 0x87 /* 3G */
564 #define GTP_EXT_AUTH_QUI 0x88 /* 3G */
565 #define GTP_EXT_TFT 0x89 /* 3G */
566 #define GTP_EXT_TARGET_ID 0x8A /* 3G */
567 #define GTP_EXT_UTRAN_CONT 0x8B /* 3G */
568 #define GTP_EXT_RAB_SETUP 0x8C /* 3G */
569 #define GTP_EXT_HDR_LIST 0x8D /* 3G */
570 #define GTP_EXT_TRIGGER_ID 0x8E /* 3G */
571 #define GTP_EXT_OMC_ID 0x8F /* 3G */
572 #define GTP_EXT_REL_PACK 0xF9 /* charging */
573 #define GTP_EXT_CAN_PACK 0xFA /* charging */
574 #define GTP_EXT_CHRG_ADDR 0xFB
575 #define GTP_EXT_DATA_REQ 0xFC /* charging */
576 #define GTP_EXT_DATA_RESP 0xFD /* charging */
577 #define GTP_EXT_NODE_ADDR 0xFE /* charging */
578 #define GTP_EXT_PRIV_EXT 0xFF
580 static const value_string gtp_val[] = {
581 { GTP_EXT_CAUSE, "Cause of operation" },
582 { GTP_EXT_IMSI, "IMSI" },
583 { GTP_EXT_RAI, "Routing Area Identity" },
584 { GTP_EXT_TLLI, "Temporary Logical Link Identity" },
585 { GTP_EXT_PTMSI, "Packet TMSI" },
586 { GTP_EXT_QOS_GPRS, "Quality of Service" },
587 { GTP_EXT_REORDER, "Reorder required" },
588 { GTP_EXT_AUTH_TRI, "Authentication triplets" },
589 { GTP_EXT_MAP_CAUSE, "MAP cause" },
590 { GTP_EXT_PTMSI_SIG, "P-TMSI signature" },
591 { GTP_EXT_MS_VALID, "MS validated" },
592 { GTP_EXT_RECOVER, "Recovery" },
593 { GTP_EXT_SEL_MODE, "Selection mode" },
595 { GTP_EXT_16, "Flow label data I" },
596 { GTP_EXT_FLOW_LABEL, "Flow label data I" },
597 { GTP_EXT_TEID, "Tunnel Endpoint Identifier Data I" }, /* 3G */
599 { GTP_EXT_17, "Flow label signalling" },
600 { GTP_EXT_FLOW_SIG, "Flow label signalling" },
601 { GTP_EXT_TEID_CP, "Tunnel Endpoint Identifier Data Control Plane" }, /* 3G */
603 { GTP_EXT_18, "Flow label data II" },
604 { GTP_EXT_FLOW_II, "Flow label data II" },
605 { GTP_EXT_TEID_II, "Tunnel Endpoint Identifier Data II" }, /* 3G */
607 { GTP_EXT_19, "MS not reachable reason" },
608 { GTP_EXT_MS_REASON, "MS not reachable reason" },
609 { GTP_EXT_TEAR_IND, "Teardown ID" }, /* 3G */
611 { GTP_EXT_NSAPI, "NSAPI" }, /* 3G */
612 { GTP_EXT_RANAP_CAUSE, "RANAP cause" }, /* 3G */
613 { GTP_EXT_RAB_CNTXT, "RAB context" }, /* 3G */
614 { GTP_EXT_RP_SMS, "Radio Priority for MO SMS" }, /* 3G */
615 { GTP_EXT_RP, "Radio Priority" }, /* 3G */
616 { GTP_EXT_PKT_FLOW_ID, "Packet Flow ID" }, /* 3G */
617 { GTP_EXT_CHRG_CHAR, "Charging characteristics" }, /* 3G */
618 { GTP_EXT_TRACE_REF, "Trace references" }, /* 3G */
619 { GTP_EXT_TRACE_TYPE, "Trace type" }, /* 3G */
620 { GTPv1_EXT_MS_REASON, "MS not reachable reason" }, /* 3G */
621 { GTP_EXT_TR_COMM, "Packet transfer command" }, /* charging */
622 { GTP_EXT_CHRG_ID, "Charging ID" },
623 { GTP_EXT_USER_ADDR, "End user address" },
624 { GTP_EXT_MM_CNTXT, "MM context" },
625 { GTP_EXT_PDP_CNTXT, "PDP context" },
626 { GTP_EXT_APN, "Access Point Name" },
627 { GTP_EXT_PROTO_CONF, "Protocol configuration options" },
628 { GTP_EXT_GSN_ADDR, "GSN address" },
629 { GTP_EXT_MSISDN, "MS international PSTN/ISDN number" },
630 { GTP_EXT_QOS_UMTS, "Quality of service (UMTS)" }, /* 3G */
631 { GTP_EXT_AUTH_QUI, "Authentication quintuplets" }, /* 3G */
632 { GTP_EXT_TFT, "Traffic Flow Template (TFT)" }, /* 3G */
633 { GTP_EXT_TARGET_ID, "Target (RNC) identification" }, /* 3G */
634 { GTP_EXT_UTRAN_CONT, "UTRAN transparent field" }, /* 3G */
635 { GTP_EXT_RAB_SETUP, "RAB setup information" }, /* 3G */
636 { GTP_EXT_HDR_LIST, "Extension Header Types List" }, /* 3G */
637 { GTP_EXT_TRIGGER_ID, "Trigger Id" }, /* 3G */
638 { GTP_EXT_OMC_ID, "OMC Identity" }, /* 3G */
639 { GTP_EXT_REL_PACK, "Sequence numbers of released packets IE" }, /* charging */
640 { GTP_EXT_CAN_PACK, "Sequence numbers of canceled packets IE" }, /* charging */
641 { GTP_EXT_CHRG_ADDR, "Charging Gateway address" },
642 { GTP_EXT_DATA_REQ, "Data record packet" }, /* charging */
643 { GTP_EXT_DATA_RESP, "Requests responded" }, /* charging */
644 { GTP_EXT_NODE_ADDR, "Address of recommended node" }, /* charging */
645 { GTP_EXT_PRIV_EXT, "Private Extension" },
649 /* GPRS: 9.60 v7.6.0, page 37
650 * UMTS: 29.060 v4.0, page 45
652 static const value_string cause_type[] = {
653 { 0, "Request IMSI" },
654 { 1, "Request IMEI" },
655 { 2, "Request IMSI and IMEI" },
656 { 3, "No identity needed" },
658 { 5, "MS is not GPRS responding" },
659 { 59, "System failure" }, /* charging */
660 { 60, "The transmit buffers are becoming full" }, /* charging */
661 { 61, "The receive buffers are becoming full" }, /* charging */
662 { 62, "Another node is about to go down" }, /* charging */
663 { 63, "This node is about to go down" }, /* charging */
664 { 128, "Request accepted" },
665 { 192, "Non-existent" },
666 { 193, "Invalid message format" },
667 { 194, "IMSI not known" },
668 { 195, "MS is GPRS detached" },
669 { 196, "MS is not GPRS responding" },
670 { 197, "MS refuses" },
671 { 198, "Version not supported" },
672 { 199, "No resource available" },
673 { 200, "Service not supported" },
674 { 201, "Mandatory IE incorrect" },
675 { 202, "Mandatory IE missing" },
676 { 203, "Optional IE incorrect" },
677 { 204, "System failure" },
678 { 205, "Roaming restriction" },
679 { 206, "P-TMSI signature mismatch" },
680 { 207, "GPRS connection suspended" },
681 { 208, "Authentication failure" },
682 { 209, "User authentication failed" },
683 { 210, "Context not found" },
684 { 211, "All PDP dynamic addresses are occupied" },
685 { 212, "No memory is available" },
686 { 213, "Relocation failure" },
687 { 214, "Unknown mandatory extension header" },
688 { 215, "Semantic error in the TFT operation" },
689 { 216, "Syntactic error in the TFT operation" },
690 { 217, "Semantic errors in packet filter(s)" },
691 { 218, "Syntactic errors in packet filter(s)" },
692 { 219, "Missing or unknown APN" },
693 { 220, "Unknown PDP address or PDP type" },
694 { 252, "Request related to possibly duplicated packets already fulfilled" }, /* charging */
695 { 253, "Request already fulfilled" }, /* charging */
696 { 254, "Sequence numbers of released/cancelled packets IE incorrect" }, /* charging */
697 { 255, "Request not fulfilled" }, /* charging */
702 * UMTS: 29.002 v4.2.1, chapter 17.5, page 268
703 * TODO: Check if all map_cause values are included
705 static const value_string map_cause_type[] = {
706 { 1, "Unknown subscriber" },
707 { 8, "Roaming not allowed" },
708 { 10, "Bearer service not provisioned" },
709 { 11, "Teleservice not provisioned" },
710 { 13, "Call barred" },
711 { 21, "Facility not supported" },
712 { 23, "Update GPRS location" },
713 { 24, "Send routing info for GPRS" },
714 { 26, "Note MS present for GPRS" },
715 { 27, "Absent subscriber" },
716 { 34, "System failure" },
717 { 35, "Data missing" },
718 { 36, "Unexpected data value" },
719 { 44, "Number chenged" },
720 { 45, "Busy subscriber" },
721 { 46, "No subscriber reply" },
722 { 48, "Facility not allowed" },
726 static const value_string gsn_addr_type[] = {
732 static const value_string pdp_type[] = {
735 { 0x02, "OSP:IHOSS" },
741 static const value_string pdp_org_type[] = {
747 static const value_string qos_delay_type[] = {
748 { 0x00, "Subsribed delay class (in MS to network direction)" },
749 { 0x01, "Delay class 1" },
750 { 0x02, "Delay class 2" },
751 { 0x03, "Delay class 3" },
752 { 0x04, "Delay class 4 (best effort)" },
753 { 0x07, "Reserved" },
757 static const value_string qos_reliability_type[] = {
758 { 0x00, "Subscribed reliability class (in MS to network direction)" },
759 { 0x01, "Ack GTP/LLC/RLC, Protected data" },
760 { 0x02, "Unack GTP, Ack LLC/RLC, Protected data" },
761 { 0x03, "Unack GTP/LLC, Ack RLC, Protected data" },
762 { 0x04, "Unack GTP/LLC/RLC, Protected data" },
763 { 0x05, "Unack GTP/LLC/RLC, Unprotected data" },
764 { 0x07, "Reserved" },
768 static const value_string qos_peak_type[] = {
769 { 0x00, "Subscribed peak throughput (in MS to network direction)" },
770 { 0x01, "Up to 1 000 oct/s" },
771 { 0x02, "Up to 2 000 oct/s" },
772 { 0x03, "Up to 4 000 oct/s" },
773 { 0x04, "Up to 8 000 oct/s" },
774 { 0x05, "Up to 16 000 oct/s" },
775 { 0x06, "Up to 32 000 oct/s" },
776 { 0x07, "Up to 64 000 oct/s" },
777 { 0x08, "Up to 128 000 oct/s" },
778 { 0x09, "Up to 256 000 oct/s" },
779 /* QoS Peak throughput classes from 0x0A to 0x0F (from 10 to 15) are subscribed */
780 { 0x0A, "Reserved" },
781 { 0x0B, "Reserved" },
782 { 0x0C, "Reserved" },
783 { 0x0D, "Reserved" },
784 { 0x0E, "Reserved" },
785 { 0x0F, "Reserved" },
789 static const value_string qos_precedence_type[] = {
790 { 0x00, "Subscribed precedence (in MS to network direction)" },
791 { 0x01, "High priority" },
792 { 0x02, "Normal priority" },
793 { 0x03, "Low priority" },
794 { 0x07, "Reserved" },
798 static const value_string qos_mean_type[] = {
799 { 0x00, "Subscribed mean throughput (in MS to network direction)" },
800 { 0x01, "100 oct/h" }, /* Class 2 */
801 { 0x02, "200 oct/h" }, /* Class 3 */
802 { 0x03, "500 oct/h" }, /* Class 4 */
803 { 0x04, "1 000 oct/h" }, /* Class 5 */
804 { 0x05, "2 000 oct/h" }, /* Class 6 */
805 { 0x06, "5 000 oct/h" }, /* Class 7 */
806 { 0x07, "10 000 oct/h" }, /* Class 8 */
807 { 0x08, "20 000 oct/h" }, /* Class 9 */
808 { 0x09, "50 000 oct/h" }, /* Class 10 */
809 { 0x0A, "100 000 oct/h" }, /* Class 11 */
810 { 0x0B, "200 000 oct/h" }, /* Class 12 */
811 { 0x0C, "500 000 oct/h" }, /* Class 13 */
812 { 0x0D, "1 000 000 oct/h" }, /* Class 14 */
813 { 0x0E, "2 000 000 oct/h" }, /* Class 15 */
814 { 0x0F, "5 000 000 oct/h" }, /* Class 16 */
815 { 0x10, "10 000 000 oct/h" }, /* Class 17 */
816 { 0x11, "20 000 000 oct/h" }, /* Class 18 */
817 { 0x12, "50 000 000 oct/h" }, /* Class 19 */
818 /* QoS Mean throughput classes from 0x13 to 0x1E (from 19 to 30) are subscribed */
819 { 0x13, "Reserved" },
820 { 0x14, "Reserved" },
821 { 0x15, "Reserved" },
822 { 0x16, "Reserved" },
823 { 0x17, "Reserved" },
824 { 0x18, "Reserved" },
825 { 0x19, "Reserved" },
826 { 0x1A, "Reserved" },
827 { 0x1B, "Reserved" },
828 { 0x1C, "Reserved" },
829 { 0x1D, "Reserved" },
830 { 0x1E, "Reserved" },
831 { 0x1F, "Best effort" }, /* Class 1 */
835 static const value_string qos_del_err_sdu[] = {
836 { 0x00, "Subscribed delivery of erroneous SDUs (in MS to network direction)" },
837 { 0x01, "No detect ('-')" },
838 { 0x02, "Erroneous SDUs are delivered ('yes')" },
839 { 0x03, "Erroneous SDUs are not delivered ('no')" },
840 { 0x07, "Reserved" }, /* All other values are reserved */
844 static const value_string qos_del_order[] = {
845 { 0x00, "Subscribed delivery order (in MS to network direction)" },
846 { 0x01, "With delivery order ('yes')" },
847 { 0x02, "Without delivery order ('no')" },
848 { 0x03, "Reserved" }, /* All other values are reserved */
852 static const value_string qos_traf_class[] = {
853 { 0x00, "Subscribed traffic class (in MS to network direction)" },
854 { 0x01, "Conversational class" },
855 { 0x02, "Streaming class" },
856 { 0x03, "Interactive class" },
857 { 0x04, "Background class" },
858 { 0x07, "Reserved" }, /* All other values are reserved */
862 static const value_string qos_max_sdu_size[] = {
863 { 0x00, "Subscribed maximum SDU size (in MS to network direction" },
864 /* For values from 0x01 to 0x96 (from 1 to 150), use a granularity of 10 octets */
865 { 0x97, "1502 octets" },
866 { 0x98, "1510 octets" },
867 { 0x99, "1520 octets" },
868 { 0, NULL } /* All other values are reserved */
871 static const value_string qos_max_ul[] = {
872 { 0x00, "Subscribed maximum bit rate for uplink (in MS to network direction)" },
873 /* For values from 0x01 to 0x3F (from 1 to 63), use a granularity of 1 kbps */
874 /* For values from 0x40 to 0x7F, value = 64 kbps + (value - 0x40) * 8 kbps */
875 /* For values from 0x80 to 0xFE, value = 576 kbps + (value - 0x80) * 64 kbps */
880 static const value_string qos_max_dl[] = {
881 { 0x00, "Subscribed maximum bit rate for downlink (in MS to network direction)" },
882 /* For values from 0x01 to 0x3F (from 1 to 63), use a granularity of 1 kbps */
883 /* For values from 0x40 to 0x7F, value = 64 kbps + (value - 0x40) * 8 kbps */
884 /* For values from 0x80 to 0xFE, value = 576 kbps + (value - 0x80) * 64 kbps */
889 static const value_string qos_res_ber[] = {
890 { 0x00, "Subscribed residual BER (in MS to network direction)" },
891 { 0x01, "1/20 = 5x10^-2" },
892 { 0x02, "1/100 = 1x10^-2" },
893 { 0x03, "1/200 = 5x10^-3" },
894 { 0x04, "1/250 = 4x10^-3" },
895 { 0x05, "1/1 000 = 1x10^-3" },
896 { 0x06, "1/10 000 = 1x10^-4" },
897 { 0x07, "1/100 000 = 1x10^-5" },
898 { 0x08, "1/1 000 000 = 1x10^-6" },
899 { 0x09, "3/50 000 000 = 6x10^-8" },
900 { 0x0F, "Reserved" }, /* All other values are reserved */
904 static const value_string qos_sdu_err_ratio[] = {
905 { 0x00, "Subscribed SDU error ratio (in MS to network direction)" },
906 { 0x01, "1/100 = 1x10^-2" },
907 { 0x02, "7/1000 = 7x10^-3" },
908 { 0x03, "1/1 000 = 1x10^-3" },
909 { 0x04, "1/10 000 = 1x10^-4" },
910 { 0x05, "1/100 000 = 1x10^-5" },
911 { 0x06, "1/1 000 000 = 1x10^-6" },
912 { 0x07, "1/10 = 1x10^-1" },
913 { 0x0F, "Reserved" }, /* All other values are reserved */
917 static const value_string qos_traf_handl_prio[] = {
918 { 0x00, "Subscribed traffic handling priority (in MS to network direction)" },
919 { 0x01, "Priority level 1" },
920 { 0x02, "Priority level 2" },
921 { 0x03, "Priority level 3" },
925 static const value_string qos_trans_delay[] = {
926 { 0x00, "Subscribed Transfer Delay (in MS to network direction)" },
927 { 0x01, "10 ms" }, /* Using a granularity of 10 ms */
942 { 0x10, "200 ms" }, /* (For values from 0x10 to 0x1F, value = 200 ms + (value - 0x10) * 50 ms */
958 { 0x20, "1000 ms" }, /* For values from 0x20 to 0x3E, value = 1000 ms + (value - 0x20) * 100 ms */
993 static const value_string qos_guar_ul[] = {
994 { 0x00, "Subscribed guaranteed bit rate for uplink (in MS to network direction)" },
995 /* For values from 0x01 to 0x3F (from 1 to 63), use a granularity of 1 kbps */
996 /* For values from 0x40 to 0x7F, value = 64 kbps + (value - 0x40) * 8 kbps */
997 /* For values from 0x80 to 0xFE, value = 576 kbps + (value - 0x80) * 64 kbps */
1002 static const value_string qos_guar_dl[] = {
1003 { 0x00, "Subscribed guaranteed bit rate for downlink (in MS to network direction)" },
1004 /* For values from 0x01 to 0x3F (from 1 to 63), use a granularity of 1 kbps */
1005 /* For values from 0x40 to 0x7F, value = 64 kbps + (value - 0x40) * 8 kbps */
1006 /* For values from 0x80 to 0xFE, value = 576 kbps + (value - 0x80) * 64 kbps */
1011 static const value_string sel_mode_type[] = {
1012 { 0, "MS or network provided APN, subscribed verified" },
1013 { 1, "MS provided APN, subscription not verified" },
1014 { 2, "Network provided APN, subscription not verified" },
1015 { 3, "For future use (Network provided APN, subscription not verified" },/* Shall not be sent. If received, shall be sent as value 2 */
1019 static const value_string tr_comm_type[] = {
1020 { 1, "Send data record packet" },
1021 { 2, "Send possibly duplicated data record packet" },
1022 { 3, "Cancel data record packet" },
1023 { 4, "Release data record packet"},
1027 /* TODO: CHeck if all ms_reasons are included */
1028 static const value_string ms_not_reachable_type[] = {
1029 { 0, "No paging response via the MSC" },
1030 { 1, "IMSI detached" },
1031 { 2, "Roaming restriction" },
1032 { 3, "Deregistered in the HLR for non GPRS" },
1033 { 4, "MS purge for non GPRS" },
1034 { 5, "No paging response via the SGSN" },
1035 { 6, "GPRS detached" },
1036 { 7, "Deregistered in the HLR for non GPRS" },
1037 { 8, "MS purged for GPRS" },
1038 { 9, "Unidentified subscriber via the MSC" },
1039 { 10, "Unidentified subscriber via the SGSN" },
1043 /* UMTS: 25.413 v3.4.0, chapter 9.2.1.4, page 80
1045 static const value_string ranap_cause_type[] = {
1046 /* Radio Network Layer Cause (1-->64) */
1047 { 1, "RAB preempted" },
1048 { 2, "Trelocoverall Expiry" },
1049 { 3, "Trelocprep Expiry" },
1050 { 4, "Treloccomplete Expiry" },
1051 { 5, "Tqueing Expiry" },
1052 { 6, "Relocation Triggered" },
1053 { 7, "TRELOCalloc Expiry" },
1054 { 8, "Unable to Estabish During Relocation" },
1055 { 9, "Unknown Target RNC" },
1056 { 10, "Relocation Cancelled" },
1057 { 11, "Successful Relocation" },
1058 { 12, "Requested Ciphering and/or Integrity Protection Algorithms not Supported" },
1059 { 13, "Change of Ciphering and/or Integrity Protection is not supported" },
1060 { 14, "Failure in the Radio Interface Procedure" },
1061 { 15, "Release due to UTRAN Generated Reason" },
1062 { 16, "User Inactivity" },
1063 { 17, "Time Critical Relocation" },
1064 { 18, "Requested Traffic Class not Available" },
1065 { 19, "Invalid RAB Parameters Value" },
1066 { 20, "Requested Maximum Bit Rate not Available" },
1067 { 21, "Requested Guaranteed Bit Rate not Available" },
1068 { 22, "Requested Transfer Delay not Achievable" },
1069 { 23, "Invalid RAB Parameters Combination" },
1070 { 24, "Condition Violation for SDU Parameters" },
1071 { 25, "Condition Violation for Traffic Handling Priority" },
1072 { 26, "Condition Violation for Guaranteed Bit Rate" },
1073 { 27, "User Plane Versions not Supported" },
1074 { 28, "Iu UP Failure" },
1075 { 29, "Relocation Failure in Target CN/RNC or Target System" },
1076 { 30, "Invalid RAB ID" },
1077 { 31, "No Remaining RAB" },
1078 { 32, "Interaction with other procedure" },
1079 { 33, "Requested Maximum Bit Rate for DL not Available" },
1080 { 34, "Requested Maximum Bit Rate for UL not Available" },
1081 { 35, "Requested Guaranteed Bit Rate for DL not Available" },
1082 { 36, "Requested Guaranteed Bit Rate for UL not Available" },
1083 { 37, "Repeated Integrity Checking Failure" },
1084 { 38, "Requested Report Type not supported" },
1085 { 39, "Request superseded" },
1086 { 40, "Release due to UE generated signalling connection release" },
1087 { 41, "Resource Optimisation Relocation" },
1088 { 42, "Requested Information Not Available" },
1089 { 43, "Relocation desirable for radio reasons" },
1090 { 44, "Relocation not supported in Target RNC or Target System" },
1091 { 45, "Directed Retry" },
1092 { 46, "Radio Connection With UE Lost" },
1093 /* Transport Layer Cause (65-->80) */
1094 { 65, "Signalling Transport Resource Failure" },
1095 { 66, "Iu Transport Connection Failed to Establish" },
1096 /* NAS Cause (81-->96) */
1097 { 81, "User Restriction Start Indication" },
1098 { 82, "User Restriction End Indication" },
1099 { 83, "Normal Release" },
1100 /* Protocol Cause (97-->112) */
1101 { 97, "Transfer Syntax Error" },
1102 { 98, "Semantic Error" },
1103 { 99, "Message not compatible with receiver state" },
1104 { 100, "Abstract Syntax Error (Reject)" },
1105 { 101, "Abstract Syntax Error (Ignore and Notify)" },
1106 { 102, "Abstract Syntax Error (Falsely Constructed Message" },
1107 /* Miscellaneous Cause (113-->128) */
1108 { 113, "O & M Intervention" },
1109 { 114, "No Resource Available" },
1110 { 115, "Unspecified Failure" },
1111 { 116, "Network Opimisation" },
1112 /* Non-standard Cause (129-->255) */
1116 static const value_string mm_sec_modep[] = {
1117 { 0, "Used cipher value, UMTS keys and Quintuplets" },
1118 { 1, "GSM key and triplets" },
1119 { 2, "UMTS key and quintuplets" },
1120 { 3, "GSM key and quintuplets" },
1124 static const value_string mm_proto_disc[] = {
1125 { 0x00, "Group call control" },
1126 { 0x01, "Broadcast call control" },
1128 { 0x03, "Call control; call related SS messages" },
1130 { 0x05, "Mobility Management messages for non-GPRS services" },
1131 { 0x06, "Radio Resource management messages" },
1132 { 0x08, "Mobility Management messages for GPRS services" },
1134 { 0x0A, "Session Management messages" },
1135 { 0x0B, "Non-call related SS messages" },
1139 static const value_string mm_rr_mess[] = {
1140 { 0x3C, "RR initialization request" },
1141 { 0x3B, "Additional assignment" },
1142 { 0x3F, "Immediate assignment" },
1143 { 0x39, "Immediate assignment extended" },
1144 { 0x3A, "Immediate assignment reject" },
1146 { 0x35, "Ciphering mode command" },
1147 { 0x32, "Ciphering mode complete" },
1149 { 0x30, "Configuration change command" },
1150 { 0x31, "Configuration change ack" },
1151 { 0x33, "Configuration change reject" },
1153 { 0x2E, "Assignment command" },
1154 { 0x29, "Assignment complete" },
1155 { 0x2F, "Assigment failure" },
1156 { 0x2B, "Handover command" },
1157 { 0x2C, "Handover complete" },
1158 { 0x28, "Handover failure" },
1159 { 0x2D, "Physical information" },
1161 { 0x08, "RR-cell change order" },
1162 { 0x23, "PDCH assignment command" },
1164 { 0x0D, "Channel release" },
1165 { 0x0A, "Partial release" },
1166 { 0x0F, "PArtial release complete" },
1168 { 0x21, "Paging request type 1" },
1169 { 0x22, "Paging request type 2" },
1170 { 0x24, "Paging request type 3" },
1171 { 0x27, "Paging response" },
1172 { 0x20, "Notification/NCH" },
1173 { 0x25, "Notification/FACCH" },
1174 { 0x26, "Reserved" },
1175 { 0x0B, "Reserved" },
1177 { 0x18, "System information type 8" },
1178 { 0x19, "System information type 1" },
1179 { 0x1A, "System information type 2" },
1180 { 0x1B, "System information type 3" },
1181 { 0x1C, "System information type 4" },
1182 { 0x1D, "System information type 5" },
1183 { 0x1E, "System information type 6" },
1184 { 0x1F, "System information type 7" },
1186 { 0x02, "System information type 2bis" },
1187 { 0x03, "System information type 2ter" },
1188 { 0x05, "System information type 5bis" },
1189 { 0x06, "System information type 5ter" },
1190 { 0x04, "System information 9" },
1191 { 0x00, "System information 13" },
1192 { 0x01, "System information 14" },
1194 { 0x3D, "System information type 16" },
1195 { 0x3E, "System information type 17" },
1197 { 0x10, "Channel mode modify" },
1198 { 0x12, "RR status" },
1199 { 0x17, "Channel mode modify ack" },
1200 { 0x14, "Frequency redefinition" },
1201 { 0x15, "Measurement report" },
1202 { 0x16, "Classmark change" },
1203 { 0x13, "Classmark enquiry" },
1204 { 0x36, "Extended measurement report" },
1205 { 0x37, "Extended measurement order" },
1206 { 0x34, "GPRS suspension request" },
1208 { 0x09, "VGCS uplink grant" },
1209 { 0x0E, "Uplink release" },
1210 { 0x0C, "Uplink free" },
1211 { 0x2A, "Uplink busy" },
1212 { 0x11, "Talker indication" },
1217 static const value_string mm_mm_mess[] = {
1218 { 0x01, "IMSI DETACH INDICATION" },
1219 { 0x02, "LOCATION UPDATING ACCEPT" },
1220 { 0x04, "LOCATION UPDATING REJECT" },
1221 { 0x08, "LOCATION UPDATING REQUEST" },
1222 { 0x11, "AUTHENTICATION REJECT" },
1223 { 0x12, "AUTHENTICATION REQUEST" },
1224 { 0x14, "AUTHENTICATION RESPONSE" },
1225 { 0x18, "IDENTITY REQUEST" },
1226 { 0x19, "IDENTITY RESPONSE" },
1227 { 0x1A, "TMSI REALLOCATION COMMAND" },
1228 { 0x1B, "TMSI REALLOCATION COMPLETE" },
1229 { 0x21, "CM SERVICE ACCEPT" },
1230 { 0x22, "CM SERVICE REJECT" },
1231 { 0x23, "CM SERVICE ABORT" },
1232 { 0x24, "CM SERVICE REQUEST" },
1233 { 0x25, "CM SERVICE PROMPT" },
1234 { 0x26, "NOTIFICATION RESPONSE" },
1235 { 0x28, "CM RE-ESTABLISHMENT REQUEST" },
1237 { 0x30, "MM NULL" },
1238 { 0x31, "MM STATUS" },
1239 { 0x32, "MM INFORMATION" },
1243 static const value_string mm_cc_mess[] = {
1244 { 0x00, "escape to nationally specific" },
1245 /*{ 0 x 0 0, "- - - Call establishment messages:" },*/
1246 { 0x01, "ALERTING" },
1247 { 0x08, "CALL CONFIRMED" },
1248 { 0x02, "CALL PROCEEDING" },
1249 { 0x07, "CONNECT" },
1250 { 0x0F, "CONNECT ACKNOWLEDGE" },
1251 { 0x0E, "EMERGENCY SETUP" },
1252 { 0x03, "PROGRESS" },
1253 { 0x04, "CC-ESTABLISHMENT" },
1254 { 0x06, "CC-ESTABLISHMENT CONFIRMED" },
1256 { 0x09, "START CC" },
1258 /*{ 0 x 0 1, "- - - Call information phase messages:" },*/
1260 { 0x1F, "MODIFY COMPLETE" },
1261 { 0x13, "MODIFY REJECT" },
1262 { 0x10, "USER INFORMATION" },
1264 { 0x19, "HOLD ACKNOWLEDGE" },
1265 { 0x1A, "HOLD REJECT" },
1266 { 0x1C, "RETRIEVE" },
1267 { 0x1D, "RETRIEVE ACKNOWLEDGE" },
1268 { 0x1E, "RETRIEVE REJECT" },
1269 /*{ 0 x 1 0, "- - - Call clearing messages:" },*/
1270 { 0x25, "DISCONNECT" },
1271 { 0x2D, "RELEASE" },
1272 { 0x2A, "RELEASE COMPLETE" },
1273 /*{ 0 x 1 1, "- - - Miscellaneous messages:" },*/
1274 { 0x39, "CONGESTION CONTROL" },
1277 { 0x34, "STATUS ENQUIRY" },
1278 { 0x35, "START DTMF" },
1279 { 0x31, "STOP DTMF" },
1280 { 0x32, "STOP DTMF ACKNOWLEDGE" },
1281 { 0x36, "START DTMF ACKNOWLEDGE" },
1282 { 0x37, "START DTMF REJECT" },
1283 { 0x3A, "FACILITY" },
1287 static const value_string mm_gprs_mess[] = {
1288 { 0x01, "Attach request" },
1289 { 0x02, "Attach accept" },
1290 { 0x03, "Attach complete" },
1291 { 0x04, "Attach reject" },
1292 { 0x05, "Detach request" },
1293 { 0x06, "Detach accept" },
1294 { 0x08, "Routing area update request" },
1295 { 0x09, "Routing area update accept" },
1296 { 0x0A, "Routing area update complete" },
1297 { 0x0B, "Routing area update reject" },
1298 { 0x10, "P-TMSI reallocation command" },
1299 { 0x11, "P-TMSI reallocation complete" },
1300 { 0x12, "Authentication and ciphering req" },
1301 { 0x13, "Authentication and ciphering resp" },
1302 { 0x14, "Authentication and ciphering rej" },
1303 { 0x15, "Identity request" },
1304 { 0x16, "Identity response" },
1305 { 0x20, "GMM status" },
1306 { 0x21, "GMM information" },
1310 static const value_string tft_code_type[] = {
1312 { 1, "Create new TFT" },
1313 { 2, "Delete existing TFT" },
1314 { 3, "Add packet filters to existing TFT" },
1315 { 4, "Replace packet filters in existing TFT" },
1316 { 5, "Delete packet filters from existing TFT" },
1322 static const value_string cdr_close_type[] = {
1323 { 0, "PDP release" },
1324 { 1, "Volume limit" },
1325 { 2, "Time limit" },
1326 { 3, "SGSN change" },
1327 { 4, "Max changes" },
1328 { 6, "Management" },
1333 static dissector_handle_t ip_handle;
1334 static dissector_handle_t ipv6_handle;
1335 static dissector_handle_t ppp_handle;
1336 static dissector_handle_t data_handle;
1338 static int decode_gtp_cause (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1339 static int decode_gtp_imsi (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1340 static int decode_gtp_rai (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1341 static int decode_gtp_tlli (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1342 static int decode_gtp_ptmsi (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1343 static int decode_gtp_qos_gprs (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1344 static int decode_gtp_reorder (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1345 static int decode_gtp_auth_tri (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1346 static int decode_gtp_map_cause (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1347 static int decode_gtp_ptmsi_sig (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1348 static int decode_gtp_ms_valid (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1349 static int decode_gtp_recovery (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1350 static int decode_gtp_sel_mode (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1351 static int decode_gtp_16 (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1352 static int decode_gtp_17 (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1353 static int decode_gtp_18 (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1354 static int decode_gtp_19 (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1355 static int decode_gtp_nsapi (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1356 static int decode_gtp_ranap_cause (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1357 static int decode_gtp_rab_cntxt (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1358 static int decode_gtp_rp_sms (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1359 static int decode_gtp_rp (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1360 static int decode_gtp_pkt_flow_id (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1361 static int decode_gtp_chrg_char (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1362 static int decode_gtp_trace_ref (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1363 static int decode_gtp_trace_type (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1364 static int decode_gtp_ms_reason (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1365 static int decode_gtp_tr_comm (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1366 static int decode_gtp_chrg_id (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1367 static int decode_gtp_user_addr (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1368 static int decode_gtp_mm_cntxt (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1369 static int decode_gtp_pdp_cntxt (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1370 static int decode_gtp_apn (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1371 static int decode_gtp_gsn_addr (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1372 static int decode_gtp_proto_conf (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1373 static int decode_gtp_msisdn (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1374 static int decode_gtp_qos_umts (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1375 static int decode_gtp_auth_qui (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1376 static int decode_gtp_tft (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1377 static int decode_gtp_target_id (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1378 static int decode_gtp_utran_cont (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1379 static int decode_gtp_rab_setup (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1380 static int decode_gtp_hdr_list (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1381 static int decode_gtp_trigger_id (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1382 static int decode_gtp_omc_id (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1383 static int decode_gtp_chrg_addr (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1384 static int decode_gtp_rel_pack (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1385 static int decode_gtp_can_pack (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1386 static int decode_gtp_data_req (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1387 static int decode_gtp_data_resp (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1388 static int decode_gtp_node_addr (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1389 static int decode_gtp_priv_ext (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1390 static int decode_gtp_unknown (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1392 typedef struct _gtp_opt {
1395 int (*decode)(tvbuff_t *, int, packet_info *, proto_tree *);
1398 static const gtp_opt_t gtpopt[] = {
1399 { GTP_EXT_CAUSE, decode_gtp_cause },
1400 { GTP_EXT_IMSI, decode_gtp_imsi },
1401 { GTP_EXT_RAI, decode_gtp_rai },
1402 { GTP_EXT_TLLI, decode_gtp_tlli },
1403 { GTP_EXT_PTMSI, decode_gtp_ptmsi },
1404 { GTP_EXT_QOS_GPRS, decode_gtp_qos_gprs },
1405 { GTP_EXT_REORDER, decode_gtp_reorder },
1406 { GTP_EXT_AUTH_TRI, decode_gtp_auth_tri },
1407 { GTP_EXT_MAP_CAUSE, decode_gtp_map_cause },
1408 { GTP_EXT_PTMSI_SIG, decode_gtp_ptmsi_sig },
1409 { GTP_EXT_MS_VALID, decode_gtp_ms_valid },
1410 { GTP_EXT_RECOVER, decode_gtp_recovery },
1411 { GTP_EXT_SEL_MODE, decode_gtp_sel_mode },
1412 { GTP_EXT_16, decode_gtp_16 },
1413 { GTP_EXT_17, decode_gtp_17 },
1414 { GTP_EXT_18, decode_gtp_18 },
1415 { GTP_EXT_19, decode_gtp_19 },
1416 { GTP_EXT_NSAPI, decode_gtp_nsapi },
1417 { GTP_EXT_RANAP_CAUSE, decode_gtp_ranap_cause },
1418 { GTP_EXT_RAB_CNTXT, decode_gtp_rab_cntxt },
1419 { GTP_EXT_RP_SMS, decode_gtp_rp_sms },
1420 { GTP_EXT_RP, decode_gtp_rp },
1421 { GTP_EXT_PKT_FLOW_ID, decode_gtp_pkt_flow_id },
1422 { GTP_EXT_CHRG_CHAR, decode_gtp_chrg_char },
1423 { GTP_EXT_TRACE_REF, decode_gtp_trace_ref },
1424 { GTP_EXT_TRACE_TYPE, decode_gtp_trace_type },
1425 { GTPv1_EXT_MS_REASON, decode_gtp_ms_reason },
1426 { GTP_EXT_TR_COMM, decode_gtp_tr_comm },
1427 { GTP_EXT_CHRG_ID, decode_gtp_chrg_id },
1428 { GTP_EXT_USER_ADDR, decode_gtp_user_addr },
1429 { GTP_EXT_MM_CNTXT, decode_gtp_mm_cntxt },
1430 { GTP_EXT_PDP_CNTXT, decode_gtp_pdp_cntxt },
1431 { GTP_EXT_APN, decode_gtp_apn },
1432 { GTP_EXT_PROTO_CONF, decode_gtp_proto_conf },
1433 { GTP_EXT_GSN_ADDR, decode_gtp_gsn_addr },
1434 { GTP_EXT_MSISDN, decode_gtp_msisdn },
1435 { GTP_EXT_QOS_UMTS, decode_gtp_qos_umts }, /* 3G */
1436 { GTP_EXT_AUTH_QUI, decode_gtp_auth_qui }, /* 3G */
1437 { GTP_EXT_TFT, decode_gtp_tft }, /* 3G */
1438 { GTP_EXT_TARGET_ID, decode_gtp_target_id }, /* 3G */
1439 { GTP_EXT_UTRAN_CONT, decode_gtp_utran_cont }, /* 3G */
1440 { GTP_EXT_RAB_SETUP, decode_gtp_rab_setup }, /* 3G */
1441 { GTP_EXT_HDR_LIST, decode_gtp_hdr_list }, /* 3G */
1442 { GTP_EXT_TRIGGER_ID, decode_gtp_trigger_id }, /* 3G */
1443 { GTP_EXT_OMC_ID, decode_gtp_omc_id }, /* 3G */
1444 { GTP_EXT_REL_PACK, decode_gtp_rel_pack }, /* charging */
1445 { GTP_EXT_CAN_PACK, decode_gtp_can_pack }, /* charging */
1446 { GTP_EXT_CHRG_ADDR, decode_gtp_chrg_addr },
1447 { GTP_EXT_DATA_REQ, decode_gtp_data_req }, /* charging */
1448 { GTP_EXT_DATA_RESP, decode_gtp_data_resp }, /* charging */
1449 { GTP_EXT_NODE_ADDR, decode_gtp_node_addr },
1450 { GTP_EXT_PRIV_EXT, decode_gtp_priv_ext },
1451 { 0, decode_gtp_unknown }
1472 static struct gcdr_ { /* GCDR 118B */
1493 typedef struct change_ {
1503 static struct _scdr { /* SCDR 277B */
1513 guint8 msclass_notused[12];
1514 guint8 msclass_caplen;
1516 guint16 msclass_capomit;
1541 typedef struct mmchange_ {
1548 static struct _mcdr { /* MCDR 147B */
1556 guint8 msclass_notused[12];
1557 guint8 msclass_caplen;
1559 guint16 msclass_capomit;
1563 guint8 change_count;
1564 mmchange_t change[5];
1567 /* guint8 opening[8]; */
1579 static struct _socdr { /* SOCDR 80B */
1586 guint8 msclass_notused[12];
1587 guint8 msclass_caplen;
1589 guint16 msclass_capomit;
1590 guint8 serv_centr[9];
1602 static struct _stcdr { /* STCDR 79B */
1609 guint8 msclass_notused[12];
1610 guint8 msclass_caplen;
1612 guint16 msclass_capomit;
1613 guint8 serv_centr[9];
1623 static guint8 gtp_version = 0;
1624 static char *yesno[] = { "False", "True" };
1627 col_append_str_gtp(column_info *cinfo, gint el, gchar *proto_name) {
1631 gchar _tmp[COL_MAX_LEN];
1633 max_len = COL_MAX_LEN;
1635 for (i = 0; i < cinfo->num_cols; i++) {
1636 if (cinfo->fmt_matx[i][el]) {
1637 if (cinfo->col_data[i] != cinfo->col_buf[i]) {
1639 strncpy(cinfo->col_buf[i], cinfo->col_data[i], max_len);
1640 cinfo->col_buf[i][max_len - 1] = '\0';
1644 strcat(_tmp, proto_name);
1646 strcat(_tmp, cinfo->col_buf[i]);
1648 cinfo->col_buf[i][0] = '\0';
1649 strcat(cinfo->col_buf[i], _tmp);
1650 cinfo->col_data[i] = cinfo->col_buf[i];
1656 id_to_str(const guint8 *ad) {
1658 static gchar *str[17];
1660 guint8 bits8to5, bits4to1, i;
1661 static const gchar hex_digits[10] = "0123456789";
1663 p = (gchar *)&str[17];
1667 bits8to5 = (ad[i] >> 4) & 0x0F;
1668 bits4to1 = ad[i] & 0x0F;
1669 if (bits8to5 < 0xA) *--p = hex_digits[bits8to5];
1670 if (bits4to1 < 0xA) *--p = hex_digits[bits4to1];
1678 imsi_to_str(const guint8 *ad) {
1680 static gchar *str[16];
1684 p = (gchar *)&str[0];
1686 if ((ad[i] & 0x0F) <= 9) p[j++] = (ad[i] & 0x0F) + 0x30;
1687 if (((ad[i] >> 4) & 0x0F) <= 9) p[j++] = ((ad[i] >> 4) & 0x0F) + 0x30;
1695 msisdn_to_str(const guint8 *ad, int len) {
1697 static gchar *str[17];
1699 guint8 bits8to5, bits4to1, i;
1700 static const gchar hex_digits[16] = "0123456789 ";
1702 p = (gchar *)&str[0];
1706 bits8to5 = (ad[i] >> 4) & 0x0F;
1707 bits4to1 = ad[i] & 0x0F;
1708 if (bits4to1 < 0xA) *++p = hex_digits[bits4to1];
1709 if (bits8to5 < 0xA) *++p = hex_digits[bits8to5];
1710 if (i == len-1) break;
1714 return (gchar *)&str[0];
1718 time_int_to_str (guint32 time)
1726 return abs_time_to_str (&nstime);
1730 rel_time_int_to_str (guint32 time)
1738 return rel_time_to_str (&nstime);
1741 /* Next definitions and function check_field_presence checks if given field
1742 * in GTP packet is compliant with ETSI
1744 typedef struct _header {
1749 typedef struct _message {
1751 ext_header fields[32];
1754 /* ---------------------
1756 * ---------------------*/
1757 static _gtp_mess_items gprs_mess_items[] = {
1761 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1766 GTP_MSG_ECHO_RESP, {
1767 { GTP_EXT_RECOVER, GTP_MANDATORY },
1768 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1773 GTP_MSG_VER_NOT_SUPP, {
1778 GTP_MSG_NODE_ALIVE_REQ, {
1779 { GTP_EXT_NODE_ADDR, GTP_MANDATORY },
1780 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1785 GTP_MSG_NODE_ALIVE_RESP, {
1786 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1791 GTP_MSG_REDIR_REQ, {
1792 { GTP_EXT_CAUSE, GTP_MANDATORY },
1793 { GTP_EXT_NODE_ADDR, GTP_OPTIONAL },
1794 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1799 GTP_MSG_REDIR_RESP, {
1800 { GTP_EXT_CAUSE, GTP_MANDATORY },
1801 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1806 GTP_MSG_CREATE_PDP_REQ, {
1807 { GTP_EXT_QOS_GPRS, GTP_MANDATORY },
1808 { GTP_EXT_RECOVER, GTP_OPTIONAL },
1809 { GTP_EXT_SEL_MODE, GTP_MANDATORY },
1810 { GTP_EXT_FLOW_LABEL, GTP_MANDATORY },
1811 { GTP_EXT_FLOW_SIG, GTP_MANDATORY },
1812 { GTP_EXT_MSISDN, GTP_MANDATORY },
1813 { GTP_EXT_USER_ADDR, GTP_MANDATORY },
1814 { GTP_EXT_APN, GTP_MANDATORY },
1815 { GTP_EXT_PROTO_CONF, GTP_OPTIONAL },
1816 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
1817 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
1818 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1823 GTP_MSG_CREATE_PDP_RESP, {
1824 { GTP_EXT_CAUSE, GTP_MANDATORY },
1825 { GTP_EXT_QOS_GPRS, GTP_CONDITIONAL },
1826 { GTP_EXT_REORDER, GTP_CONDITIONAL },
1827 { GTP_EXT_RECOVER, GTP_OPTIONAL },
1828 { GTP_EXT_FLOW_LABEL, GTP_CONDITIONAL },
1829 { GTP_EXT_FLOW_SIG, GTP_CONDITIONAL },
1830 { GTP_EXT_CHRG_ID, GTP_CONDITIONAL },
1831 { GTP_EXT_USER_ADDR, GTP_CONDITIONAL },
1832 { GTP_EXT_PROTO_CONF, GTP_OPTIONAL },
1833 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
1834 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
1835 { GTP_EXT_CHRG_ADDR, GTP_OPTIONAL },
1836 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1841 GTP_MSG_UPDATE_PDP_REQ, {
1842 { GTP_EXT_QOS_GPRS, GTP_MANDATORY },
1843 { GTP_EXT_RECOVER, GTP_OPTIONAL },
1844 { GTP_EXT_FLOW_LABEL, GTP_MANDATORY },
1845 { GTP_EXT_FLOW_SIG, GTP_MANDATORY },
1846 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
1847 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
1848 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1853 GTP_MSG_UPDATE_PDP_RESP, {
1854 { GTP_EXT_CAUSE, GTP_MANDATORY },
1855 { GTP_EXT_QOS_GPRS, GTP_CONDITIONAL },
1856 { GTP_EXT_RECOVER, GTP_OPTIONAL },
1857 { GTP_EXT_FLOW_LABEL, GTP_CONDITIONAL },
1858 { GTP_EXT_FLOW_SIG, GTP_CONDITIONAL },
1859 { GTP_EXT_CHRG_ID, GTP_CONDITIONAL },
1860 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
1861 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
1862 { GTP_EXT_CHRG_ADDR, GTP_OPTIONAL },
1863 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1868 GTP_MSG_DELETE_PDP_REQ, {
1869 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1874 GTP_MSG_DELETE_PDP_RESP, {
1875 { GTP_EXT_CAUSE, GTP_MANDATORY },
1876 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1881 GTP_MSG_CREATE_AA_PDP_REQ, {
1882 { GTP_EXT_QOS_GPRS, GTP_MANDATORY },
1883 { GTP_EXT_RECOVER, GTP_OPTIONAL },
1884 { GTP_EXT_SEL_MODE, GTP_MANDATORY },
1885 { GTP_EXT_FLOW_LABEL, GTP_MANDATORY },
1886 { GTP_EXT_FLOW_SIG, GTP_MANDATORY },
1887 { GTP_EXT_USER_ADDR, GTP_MANDATORY },
1888 { GTP_EXT_APN, GTP_MANDATORY },
1889 { GTP_EXT_PROTO_CONF, GTP_OPTIONAL },
1890 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
1891 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
1892 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1897 GTP_MSG_CREATE_AA_PDP_RESP, {
1898 { GTP_EXT_CAUSE, GTP_MANDATORY },
1899 { GTP_EXT_QOS_GPRS, GTP_CONDITIONAL },
1900 { GTP_EXT_REORDER, GTP_CONDITIONAL },
1901 { GTP_EXT_RECOVER, GTP_OPTIONAL },
1902 { GTP_EXT_FLOW_LABEL, GTP_CONDITIONAL },
1903 { GTP_EXT_FLOW_SIG, GTP_CONDITIONAL },
1904 { GTP_EXT_CHRG_ID, GTP_CONDITIONAL },
1905 { GTP_EXT_USER_ADDR, GTP_CONDITIONAL },
1906 { GTP_EXT_PROTO_CONF, GTP_OPTIONAL },
1907 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
1908 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
1909 { GTP_EXT_CHRG_ADDR, GTP_OPTIONAL },
1910 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1915 GTP_MSG_DELETE_AA_PDP_REQ, {
1916 { GTP_EXT_CAUSE, GTP_MANDATORY },
1917 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1922 GTP_MSG_DELETE_AA_PDP_RESP, {
1923 { GTP_EXT_CAUSE, GTP_MANDATORY },
1924 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1930 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1935 GTP_MSG_PDU_NOTIFY_REQ, {
1936 { GTP_EXT_USER_ADDR, GTP_MANDATORY },
1937 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1942 GTP_MSG_PDU_NOTIFY_RESP, {
1943 { GTP_EXT_CAUSE, GTP_MANDATORY },
1944 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1949 GTP_MSG_PDU_NOTIFY_REJ_REQ, {
1950 { GTP_EXT_CAUSE, GTP_MANDATORY },
1951 { GTP_EXT_USER_ADDR, GTP_MANDATORY },
1952 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1957 GTP_MSG_PDU_NOTIFY_REJ_RESP, {
1958 { GTP_EXT_CAUSE, GTP_MANDATORY },
1959 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1964 GTP_MSG_SEND_ROUT_INFO_REQ, {
1965 { GTP_EXT_IMSI, GTP_MANDATORY },
1966 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1971 GTP_MSG_SEND_ROUT_INFO_RESP, {
1972 { GTP_EXT_CAUSE, GTP_MANDATORY },
1973 { GTP_EXT_IMSI, GTP_MANDATORY },
1974 { GTP_EXT_MAP_CAUSE, GTP_OPTIONAL },
1975 { GTP_EXT_MS_REASON, GTP_OPTIONAL },
1976 { GTP_EXT_GSN_ADDR, GTP_OPTIONAL },
1977 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1982 GTP_MSG_FAIL_REP_REQ, {
1983 { GTP_EXT_IMSI, GTP_MANDATORY },
1984 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1989 GTP_MSG_FAIL_REP_RESP, {
1990 { GTP_EXT_CAUSE, GTP_MANDATORY },
1991 { GTP_EXT_MAP_CAUSE, GTP_OPTIONAL },
1992 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1997 GTP_MSG_MS_PRESENT_REQ, {
1998 { GTP_EXT_IMSI, GTP_MANDATORY },
1999 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
2000 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2005 GTP_MSG_MS_PRESENT_RESP, {
2006 { GTP_EXT_CAUSE, GTP_MANDATORY },
2007 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2012 GTP_MSG_IDENT_REQ, {
2013 { GTP_EXT_RAI, GTP_MANDATORY },
2014 { GTP_EXT_PTMSI, GTP_MANDATORY },
2015 { GTP_EXT_PTMSI_SIG, GTP_OPTIONAL },
2016 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2021 GTP_MSG_IDENT_RESP, {
2022 { GTP_EXT_CAUSE, GTP_MANDATORY },
2023 { GTP_EXT_IMSI, GTP_CONDITIONAL },
2024 { GTP_EXT_AUTH_TRI, GTP_OPTIONAL },
2025 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2030 GTP_MSG_SGSN_CNTXT_REQ, {
2031 { GTP_EXT_IMSI, GTP_CONDITIONAL },
2032 { GTP_EXT_RAI, GTP_MANDATORY },
2033 { GTP_EXT_TLLI, GTP_MANDATORY },
2034 { GTP_EXT_PTMSI_SIG, GTP_OPTIONAL },
2035 { GTP_EXT_MS_VALID, GTP_OPTIONAL },
2036 { GTP_EXT_FLOW_SIG, GTP_MANDATORY },
2041 GTP_MSG_SGSN_CNTXT_RESP, {
2042 { GTP_EXT_CAUSE, GTP_MANDATORY },
2043 { GTP_EXT_IMSI, GTP_CONDITIONAL },
2044 { GTP_EXT_FLOW_SIG, GTP_CONDITIONAL },
2045 { GTP_EXT_MM_CNTXT, GTP_CONDITIONAL },
2046 { GTP_EXT_PDP_CNTXT, GTP_CONDITIONAL },
2047 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2052 GTP_MSG_SGSN_CNTXT_ACK, {
2053 { GTP_EXT_CAUSE, GTP_MANDATORY },
2054 { GTP_EXT_FLOW_II, GTP_CONDITIONAL },
2055 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
2056 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2061 GTP_MSG_DATA_TRANSF_REQ, {
2062 { GTP_EXT_TR_COMM, GTP_MANDATORY },
2063 { GTP_EXT_DATA_REQ, GTP_CONDITIONAL },
2064 { GTP_EXT_REL_PACK, GTP_CONDITIONAL },
2065 { GTP_EXT_CAN_PACK, GTP_CONDITIONAL },
2066 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2071 GTP_MSG_DATA_TRANSF_RESP, {
2072 { GTP_EXT_CAUSE, GTP_MANDATORY },
2073 { GTP_EXT_DATA_RESP, GTP_MANDATORY },
2074 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2085 /* -----------------------------
2087 * -----------------------------*/
2088 static _gtp_mess_items umts_mess_items[] = {
2092 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2097 GTP_MSG_ECHO_RESP, {
2098 { GTP_EXT_RECOVER, GTP_MANDATORY },
2099 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2104 GTP_MSG_VER_NOT_SUPP, {
2109 GTP_MSG_NODE_ALIVE_REQ, {
2110 { GTP_EXT_NODE_ADDR, GTP_MANDATORY },
2111 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2116 GTP_MSG_NODE_ALIVE_RESP, {
2117 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2122 GTP_MSG_REDIR_REQ, {
2123 { GTP_EXT_CAUSE, GTP_MANDATORY },
2124 { GTP_EXT_NODE_ADDR, GTP_OPTIONAL },
2125 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2130 GTP_MSG_REDIR_REQ, {
2135 GTP_MSG_CREATE_PDP_REQ, {
2136 { GTP_EXT_IMSI, GTP_CONDITIONAL },
2137 { GTP_EXT_RECOVER, GTP_OPTIONAL },
2138 { GTP_EXT_SEL_MODE, GTP_CONDITIONAL },
2139 { GTP_EXT_TEID, GTP_MANDATORY },
2140 { GTP_EXT_TEID_CP, GTP_CONDITIONAL },
2141 { GTP_EXT_NSAPI, GTP_MANDATORY },
2142 { GTP_EXT_NSAPI, GTP_CONDITIONAL },
2143 { GTP_EXT_CHRG_CHAR, GTP_OPTIONAL },
2144 { GTP_EXT_TRACE_REF, GTP_OPTIONAL },
2145 { GTP_EXT_TRACE_TYPE, GTP_OPTIONAL },
2146 { GTP_EXT_USER_ADDR, GTP_CONDITIONAL },
2147 { GTP_EXT_APN, GTP_CONDITIONAL },
2148 { GTP_EXT_PROTO_CONF, GTP_CONDITIONAL },
2149 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
2150 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
2151 { GTP_EXT_MSISDN, GTP_CONDITIONAL },
2152 { GTP_EXT_QOS_UMTS, GTP_MANDATORY },
2153 { GTP_EXT_TFT, GTP_CONDITIONAL },
2154 { GTP_EXT_TRIGGER_ID, GTP_OPTIONAL },
2155 { GTP_EXT_OMC_ID, GTP_OPTIONAL },
2156 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2161 GTP_MSG_CREATE_PDP_RESP, {
2162 { GTP_EXT_CAUSE, GTP_MANDATORY },
2163 { GTP_EXT_REORDER, GTP_CONDITIONAL },
2164 { GTP_EXT_RECOVER, GTP_OPTIONAL },
2165 { GTP_EXT_TEID, GTP_CONDITIONAL },
2166 { GTP_EXT_TEID_CP, GTP_CONDITIONAL },
2167 { GTP_EXT_CHRG_ID, GTP_CONDITIONAL },
2168 { GTP_EXT_USER_ADDR, GTP_CONDITIONAL },
2169 { GTP_EXT_PROTO_CONF, GTP_OPTIONAL },
2170 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
2171 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
2172 { GTP_EXT_QOS_UMTS, GTP_CONDITIONAL },
2173 { GTP_EXT_CHRG_ADDR, GTP_OPTIONAL },
2174 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2178 { /* checked, SGSN -> GGSN */
2179 GTP_MSG_UPDATE_PDP_REQ, {
2180 { GTP_EXT_IMSI, GTP_CONDITIONAL },
2181 { GTP_EXT_RECOVER, GTP_OPTIONAL },
2182 { GTP_EXT_TEID, GTP_MANDATORY },
2183 { GTP_EXT_TEID_CP, GTP_CONDITIONAL },
2184 { GTP_EXT_NSAPI, GTP_MANDATORY },
2185 { GTP_EXT_TRACE_REF, GTP_OPTIONAL },
2186 { GTP_EXT_TRACE_TYPE, GTP_OPTIONAL },
2187 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
2188 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
2189 { GTP_EXT_QOS_UMTS, GTP_MANDATORY },
2190 { GTP_EXT_TFT, GTP_OPTIONAL },
2191 { GTP_EXT_TRIGGER_ID, GTP_OPTIONAL },
2192 { GTP_EXT_OMC_ID, GTP_OPTIONAL },
2193 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2197 { /* checked, GGSN -> SGSN */
2198 GTP_MSG_UPDATE_PDP_RESP, {
2199 { GTP_EXT_CAUSE, GTP_MANDATORY },
2200 { GTP_EXT_RECOVER, GTP_OPTIONAL },
2201 { GTP_EXT_TEID, GTP_CONDITIONAL },
2202 { GTP_EXT_TEID_CP, GTP_CONDITIONAL },
2203 { GTP_EXT_CHRG_ID, GTP_CONDITIONAL },
2204 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
2205 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
2206 { GTP_EXT_QOS_UMTS, GTP_CONDITIONAL },
2207 { GTP_EXT_CHRG_ADDR, GTP_OPTIONAL },
2208 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2213 GTP_MSG_DELETE_PDP_REQ, {
2214 { GTP_EXT_TEAR_IND, GTP_CONDITIONAL },
2215 { GTP_EXT_NSAPI, GTP_MANDATORY },
2216 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2221 GTP_MSG_DELETE_PDP_RESP, {
2222 { GTP_EXT_CAUSE, GTP_MANDATORY },
2223 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2229 { GTP_EXT_TEID, GTP_MANDATORY },
2230 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2235 GTP_MSG_PDU_NOTIFY_REQ, {
2236 { GTP_EXT_IMSI, GTP_MANDATORY },
2237 { GTP_EXT_TEID_CP, GTP_MANDATORY },
2238 { GTP_EXT_USER_ADDR, GTP_MANDATORY },
2239 { GTP_EXT_APN, GTP_MANDATORY },
2240 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
2241 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2246 GTP_MSG_PDU_NOTIFY_RESP, {
2247 { GTP_EXT_CAUSE, GTP_MANDATORY },
2248 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2253 GTP_MSG_PDU_NOTIFY_REJ_REQ, {
2254 { GTP_EXT_CAUSE, GTP_MANDATORY },
2255 { GTP_EXT_TEID_CP, GTP_MANDATORY },
2256 { GTP_EXT_USER_ADDR, GTP_MANDATORY },
2257 { GTP_EXT_APN, GTP_MANDATORY },
2258 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2263 GTP_MSG_PDU_NOTIFY_REJ_RESP, {
2264 { GTP_EXT_CAUSE, GTP_MANDATORY },
2265 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2270 GTP_MSG_SUPP_EXT_HDR, {
2271 { GTP_EXT_HDR_LIST, GTP_MANDATORY },
2276 GTP_MSG_SEND_ROUT_INFO_REQ, {
2277 { GTP_EXT_IMSI, GTP_MANDATORY },
2278 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2283 GTP_MSG_SEND_ROUT_INFO_RESP, {
2284 { GTP_EXT_CAUSE, GTP_MANDATORY },
2285 { GTP_EXT_IMSI, GTP_MANDATORY },
2286 { GTP_EXT_MAP_CAUSE, GTP_OPTIONAL },
2287 { GTPv1_EXT_MS_REASON, GTP_OPTIONAL },
2288 { GTP_EXT_GSN_ADDR, GTP_OPTIONAL },
2289 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2294 GTP_MSG_FAIL_REP_REQ, {
2295 { GTP_EXT_IMSI, GTP_MANDATORY },
2296 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2301 GTP_MSG_FAIL_REP_RESP, {
2302 { GTP_EXT_CAUSE, GTP_MANDATORY },
2303 { GTP_EXT_MAP_CAUSE, GTP_OPTIONAL },
2304 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2309 GTP_MSG_MS_PRESENT_REQ, {
2310 { GTP_EXT_IMSI, GTP_MANDATORY },
2311 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
2312 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2317 GTP_MSG_MS_PRESENT_RESP, {
2318 { GTP_EXT_CAUSE, GTP_MANDATORY },
2319 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2324 GTP_MSG_IDENT_REQ, {
2325 { GTP_EXT_RAI, GTP_MANDATORY },
2326 { GTP_EXT_PTMSI, GTP_MANDATORY },
2327 { GTP_EXT_PTMSI_SIG, GTP_CONDITIONAL },
2328 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2333 GTP_MSG_IDENT_RESP, {
2334 { GTP_EXT_CAUSE, GTP_MANDATORY },
2335 { GTP_EXT_IMSI, GTP_CONDITIONAL },
2336 { GTP_EXT_AUTH_TRI, GTP_CONDITIONAL },
2337 { GTP_EXT_AUTH_QUI, GTP_CONDITIONAL },
2338 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2343 GTP_MSG_SGSN_CNTXT_REQ, {
2344 { GTP_EXT_IMSI, GTP_CONDITIONAL },
2345 { GTP_EXT_RAI, GTP_MANDATORY },
2346 { GTP_EXT_TLLI, GTP_CONDITIONAL },
2347 { GTP_EXT_PTMSI, GTP_CONDITIONAL },
2348 { GTP_EXT_PTMSI_SIG, GTP_CONDITIONAL },
2349 { GTP_EXT_MS_VALID, GTP_OPTIONAL },
2350 { GTP_EXT_TEID_CP, GTP_MANDATORY },
2351 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
2352 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2357 GTP_MSG_SGSN_CNTXT_RESP, {
2358 { GTP_EXT_CAUSE, GTP_MANDATORY },
2359 { GTP_EXT_IMSI, GTP_CONDITIONAL },
2360 { GTP_EXT_TEID_CP, GTP_CONDITIONAL },
2361 { GTP_EXT_RP_SMS, GTP_OPTIONAL },
2362 { GTP_EXT_RP, GTP_OPTIONAL },
2363 { GTP_EXT_PKT_FLOW_ID, GTP_OPTIONAL },
2364 { GTP_EXT_MM_CNTXT, GTP_CONDITIONAL },
2365 { GTP_EXT_PDP_CNTXT, GTP_CONDITIONAL },
2366 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
2367 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2372 GTP_MSG_SGSN_CNTXT_ACK, {
2373 { GTP_EXT_CAUSE, GTP_MANDATORY },
2374 { GTP_EXT_TEID_II, GTP_CONDITIONAL },
2375 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
2376 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2381 GTP_MSG_FORW_RELOC_REQ, {
2382 { GTP_EXT_IMSI, GTP_MANDATORY },
2383 { GTP_EXT_TEID_CP, GTP_MANDATORY },
2384 { GTP_EXT_RANAP_CAUSE, GTP_MANDATORY },
2385 { GTP_EXT_MM_CNTXT, GTP_MANDATORY },
2386 { GTP_EXT_PDP_CNTXT, GTP_CONDITIONAL },
2387 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
2388 { GTP_EXT_TARGET_ID, GTP_MANDATORY },
2389 { GTP_EXT_UTRAN_CONT, GTP_MANDATORY },
2390 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2395 GTP_MSG_FORW_RELOC_RESP, {
2396 { GTP_EXT_CAUSE, GTP_MANDATORY },
2397 { GTP_EXT_TEID_CP, GTP_CONDITIONAL },
2398 { GTP_EXT_RANAP_CAUSE, GTP_CONDITIONAL },
2399 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
2400 { GTP_EXT_UTRAN_CONT, GTP_OPTIONAL },
2401 { GTP_EXT_RAB_SETUP, GTP_CONDITIONAL },
2402 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2407 GTP_MSG_FORW_RELOC_COMP, {
2408 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2413 GTP_MSG_RELOC_CANCEL_REQ, {
2414 { GTP_EXT_IMSI, GTP_MANDATORY },
2415 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2420 GTP_MSG_RELOC_CANCEL_RESP, {
2421 { GTP_EXT_CAUSE, GTP_MANDATORY },
2422 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2427 GTP_MSG_FORW_RELOC_ACK, {
2428 { GTP_EXT_CAUSE, GTP_MANDATORY },
2429 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2434 GTP_MSG_FORW_SRNS_CNTXT, {
2435 { GTP_EXT_RAB_CNTXT, GTP_MANDATORY },
2436 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2441 GTP_MSG_FORW_SRNS_CNTXT_ACK, {
2442 { GTP_EXT_CAUSE, GTP_MANDATORY },
2443 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2455 check_field_presence(guint8 message, guint8 field, int *position) {
2458 _gtp_mess_items *mess_items;
2460 switch(gtp_version) {
2462 mess_items = gprs_mess_items;
2465 mess_items = umts_mess_items;
2471 while (mess_items[i].code) {
2472 if (mess_items[i].code == message) {
2474 while (mess_items[i].fields[*position].code) {
2475 if (mess_items[i].fields[*position].code == field) {
2479 if (mess_items[i].fields[*position].presence == GTP_MANDATORY) {
2480 return mess_items[i].fields[(*position)++].code;
2493 /* Decoders of fields in extension headers, each function returns no of bytes from field */
2495 /* GPRS: 9.60 v7.6.0, chapter
2496 * UMTS: 29.060 v4.0, chapter
2499 decode_gtp_cause(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2503 cause = tvb_get_guint8(tvb, offset+1);
2505 proto_tree_add_uint(tree, gtp_version ? hf_gtpv1_cause : hf_gtpv0_cause, tvb, offset, 2, cause);
2510 /* GPRS: 9.60 v7.6.0, chapter 7.9.2
2511 * UMTS: 29.060 v4.0, chapter 7.7.2
2514 decode_gtp_imsi(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2519 tvb_memcpy(tvb, imsi_val, offset+1, 8);
2520 imsi_str = imsi_to_str (imsi_val);
2522 proto_tree_add_string(tree, gtp_version ? hf_gtpv1_imsi : hf_gtpv0_imsi, tvb, offset, 9, imsi_str);
2527 /* GPRS: 9.60 v7.6.0, chapter 7.9.3
2528 * UMTS: 29.060 v4.0, chapter 7.7.3
2529 * TODO: Add details about MCC, MNC, LAC, RAC (show each digit) ?
2532 decode_gtp_rai(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2534 proto_tree *ext_tree_rai;
2538 te = proto_tree_add_text(tree, tvb, offset, 1, val_to_str(GTP_EXT_RAI, gtp_val, "Unknown message"));
2539 ext_tree_rai = proto_item_add_subtree(te, ett_gtp_rai);
2541 /* tvb_memcpy (tvb, (guint8 *)&byte, offset + 1, 3); */
2542 byte[1] = tvb_get_guint8 (tvb, offset + 1);
2543 byte[2] = tvb_get_guint8 (tvb, offset + 2);
2544 byte[3] = tvb_get_guint8 (tvb, offset + 3);
2547 proto_tree_add_uint(ext_tree_rai, gtp_version ? hf_gtpv1_rai_mcc : hf_gtpv0_rai_mcc, tvb, offset+1, 2, (byte[1] & 0x0F) * 100 + ((byte[1] & 0xF0) >> 4) * 10 + (byte[2] & 0x0F ));
2548 proto_tree_add_uint(ext_tree_rai, gtp_version ? hf_gtpv1_rai_mnc : hf_gtpv0_rai_mnc, tvb, offset+2, 2, ((byte[3] & 0xF0) >> 4 ) * 10 + (byte[3] & 0x0F));
2549 proto_tree_add_uint(ext_tree_rai, gtp_version ? hf_gtpv1_rai_lac : hf_gtpv0_rai_lac, tvb, offset+4, 2, tvb_get_ntohs (tvb, offset+4));
2550 proto_tree_add_uint(ext_tree_rai, gtp_version ? hf_gtpv1_rai_rac : hf_gtpv0_rai_rac, tvb, offset+6, 1, tvb_get_guint8 (tvb, offset+6));
2555 /* GPRS: 9.60 v7.6.0, chapter 7.9.4, page 39
2556 * UMTS: 29.060 v4.0, chapter 7.7.4, page 47
2559 decode_gtp_tlli(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2563 tlli = tvb_get_ntohl(tvb, offset+1);
2564 proto_tree_add_uint(tree, gtp_version ? hf_gtpv1_tlli : hf_gtpv0_tlli, tvb, offset, 5, tlli);
2569 /* GPRS: 9.60 v7.6.0, chapter 7.9.5, page 39
2570 * UMTS: 29.060 v4.0, chapter 7.7.5, page 47
2573 decode_gtp_ptmsi(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2577 ptmsi = tvb_get_ntohl(tvb, offset);
2578 proto_tree_add_uint(tree, gtp_version ? hf_gtpv1_ptmsi : hf_gtpv0_ptmsi, tvb, offset, 5, ptmsi);
2583 /* adjust - how many bytes before offset should be highlighted
2586 decode_qos_gprs(tvbuff_t *tvb, int offset, proto_tree *tree, gchar* qos_str, guint8 adjust) {
2588 guint8 spare1, delay, reliability, peak, spare2, precedence, spare3, mean;
2589 proto_tree *ext_tree_qos;
2592 spare1 = tvb_get_guint8(tvb, offset) & 0xC0;
2593 delay = tvb_get_guint8(tvb, offset) & 0x38;
2594 reliability = tvb_get_guint8(tvb, offset) & 0x07;
2595 peak = tvb_get_guint8(tvb, offset+1) & 0xF0;
2596 spare2 = tvb_get_guint8(tvb, offset+1) & 0x08;
2597 precedence = tvb_get_guint8(tvb, offset+1) & 0x07;
2598 spare3 = tvb_get_guint8(tvb, offset+2) & 0xE0;
2599 mean = tvb_get_guint8(tvb, offset+2) & 0x1F;
2601 te = proto_tree_add_text(tree, tvb, offset-adjust, 3+adjust, "%s: delay: %u, reliability: %u, peak: %u, precedence: %u, mean: %u",
2602 qos_str, delay, reliability, peak, precedence, mean);
2603 ext_tree_qos = proto_item_add_subtree(te, ett_gtp_qos);
2606 proto_tree_add_uint(ext_tree_qos, hf_gtpv0_qos_spare1, tvb, offset, 1, spare1);
2607 proto_tree_add_uint(ext_tree_qos, hf_gtpv0_qos_delay, tvb, offset, 1, delay);
2608 proto_tree_add_uint(ext_tree_qos, hf_gtpv0_qos_reliability, tvb, offset, 1, reliability);
2609 proto_tree_add_uint(ext_tree_qos, hf_gtpv0_qos_peak, tvb, offset+1, 1, peak);
2610 proto_tree_add_uint(ext_tree_qos, hf_gtpv0_qos_spare2, tvb, offset+1, 1, spare2);
2611 proto_tree_add_uint(ext_tree_qos, hf_gtpv0_qos_precedence, tvb, offset+1, 1, precedence);
2612 proto_tree_add_uint(ext_tree_qos, hf_gtpv0_qos_spare3, tvb, offset+2, 1, spare3);
2613 proto_tree_add_uint(ext_tree_qos, hf_gtpv0_qos_mean, tvb, offset+2, 1, mean);
2619 /* GPRS: 9.60 v7.6.0, chapter 7.9.6, page 39
2623 * TODO: check if length is included: ETSI 4.08 vs 9.60
2626 decode_gtp_qos_gprs(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2628 return (1+decode_qos_gprs(tvb, offset+1, tree, "Quality of Service", 1));
2632 /* GPRS: 9.60 v7.6.0, chapter 7.9.7, page 39
2633 * UMTS: 29.060 v4.0, chapter 7.7.6, page 47
2636 decode_gtp_reorder(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2640 reorder = tvb_get_guint8(tvb, offset+1) & 0x01;
2641 proto_tree_add_boolean(tree, gtp_version ? hf_gtpv1_reorder : hf_gtpv0_reorder, tvb, offset, 2, reorder);
2646 /* GPRS: 9.60 v7.6.0, chapter 7.9.8, page 40
2647 * 4.08 v7.1.2, chapter 10.5.3.1+
2648 * UMTS: 29.060 v4.0, chapter 7.7.7
2649 * TODO: Add blurb support by registering items in the protocol registration
2652 decode_gtp_auth_tri(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2654 proto_tree *ext_tree_auth_tri;
2657 te = proto_tree_add_text(tree, tvb, offset, 29, val_to_str(GTP_EXT_AUTH_TRI, gtp_val, "Unknown message"));
2658 ext_tree_auth_tri = proto_item_add_subtree(tree, ett_gtp_auth_tri);
2660 proto_tree_add_text(ext_tree_auth_tri, tvb, offset+1, 16, "RAND: %s", tvb_bytes_to_str(tvb, offset+1, 16));
2661 proto_tree_add_text(ext_tree_auth_tri, tvb, offset+17, 4, "SRES: %s", tvb_bytes_to_str(tvb, offset+17, 4));
2662 proto_tree_add_text(ext_tree_auth_tri, tvb, offset+21, 8, "Kc: %s", tvb_bytes_to_str(tvb, offset+21, 8));
2667 /* GPRS: 9.60 v7.6.0, chapter 7.9.9, page 40
2668 * 9.02 v7.7.0, page 1090
2669 * UMTS: 29.060 v4.0, chapter 7.7.8, page 48
2670 * 29.002 v4.2.1, chapter 17.5, page 268
2673 decode_gtp_map_cause(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2677 map_cause = tvb_get_guint8(tvb, offset+1);
2678 proto_tree_add_uint(tree, gtp_version ? hf_gtpv1_map_cause : hf_gtpv0_map_cause, tvb, offset, 2, map_cause);
2683 /* GPRS: 9.60 v7.6.0, chapter 7.9.10, page 41
2684 * UMTS: 29.060 v4.0, chapter 7.7.9, page 48
2687 decode_gtp_ptmsi_sig(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2691 ptmsi_sig = tvb_get_ntoh24(tvb, offset+1);
2692 proto_tree_add_uint(tree, gtp_version ? hf_gtpv1_ptmsi_sig : hf_gtpv0_ptmsi_sig, tvb, offset, 4, ptmsi_sig);
2697 /* GPRS: 9.60 v7.6.0, chapter 7.9.11, page 41
2698 * UMTS: 29.060 v4.0, chapter 7.7.10, page 49
2701 decode_gtp_ms_valid(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2705 ms_valid = tvb_get_guint8(tvb, offset+1) & 0x01;
2706 proto_tree_add_boolean(tree, gtp_version ? hf_gtpv1_ms_valid : hf_gtpv0_ms_valid, tvb, offset, 2, ms_valid);
2711 /* GPRS: 9.60 v7.6.0, chapter 7.9.12, page 41
2712 * UMTS: 29.060 v4.0, chapter 7.7.11, page 49
2715 decode_gtp_recovery(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2719 recovery = tvb_get_guint8(tvb, offset+1);
2720 proto_tree_add_uint(tree, gtp_version ? hf_gtpv1_recovery : hf_gtpv0_recovery, tvb, offset, 2, recovery);
2725 /* GPRS: 9.60 v7.6.0, chapter 7.9.13, page 42
2726 * UMTS: 29.060 v4.0, chapter 7.7.12, page 49
2729 decode_gtp_sel_mode(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2733 sel_mode = tvb_get_guint8(tvb, offset+1) & 0x03;
2734 proto_tree_add_uint(tree, gtp_version ? hf_gtpv1_sel_mode : hf_gtpv0_sel_mode, tvb, offset, 2, sel_mode);
2739 /* GPRS: 9.60 v7.6.0, chapter 7.9.14, page 42
2740 * UMTS: 29.060 v4.0, chapter 7.7.13, page 50
2743 decode_gtp_16(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2745 guint16 ext_flow_label;
2748 switch (gtp_version) {
2750 ext_flow_label = tvb_get_ntohs(tvb, offset+1);
2751 proto_tree_add_uint(tree, hf_gtpv0_ext_flow_label, tvb, offset, 3, ext_flow_label);
2755 teid_data = tvb_get_ntohl(tvb, offset+1);
2756 proto_tree_add_uint(tree, hf_gtpv1_teid_data, tvb, offset, 5, teid_data);
2760 proto_tree_add_text(tree, tvb, offset, 1, "Flow label/TEID Data I : GTP version not supported");
2766 /* GPRS: 9.60 v7.6.0, chapter 7.9.15, page 42
2767 * UMTS: 29.060 v4.0, chapter 7.7.14, page 42
2770 decode_gtp_17(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2775 switch (gtp_version) {
2777 flow_sig = tvb_get_ntohs(tvb, offset+1);
2778 proto_tree_add_uint(tree, hf_gtpv0_flow_sig, tvb, offset, 3, flow_sig);
2782 teid_cp = tvb_get_ntohl(tvb, offset+1);
2783 proto_tree_add_uint(tree, hf_gtpv1_teid_cp, tvb, offset, 5, teid_cp);
2787 proto_tree_add_text(tree, tvb, offset, 1, "Flow label signalling/TEID control plane : GTP version not supported");
2793 /* GPRS: 9.60 v7.6.0, chapter 7.9.16, page 42
2794 * UMTS: 29.060 v4.0, chapter 7.7.15, page 51
2797 decode_gtp_18(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2801 proto_tree *ext_tree_flow_ii;
2804 switch (gtp_version) {
2806 te = proto_tree_add_text(tree, tvb, offset, 4, val_to_str(GTP_EXT_FLOW_II, gtp_val, "Unknown message"));
2807 ext_tree_flow_ii = proto_item_add_subtree(te, ett_gtp_flow_ii);
2809 proto_tree_add_uint(ext_tree_flow_ii, hf_gtpv0_nsapi, tvb, offset+1, 1, tvb_get_guint8(tvb, offset+1) & 0x0F);
2811 flow_ii = tvb_get_ntohs(tvb, offset+2);
2812 proto_tree_add_uint(ext_tree_flow_ii, hf_gtpv0_flow_ii, tvb, offset+2, 2, flow_ii);
2816 te = proto_tree_add_text(tree, tvb, offset, 6, val_to_str(GTP_EXT_TEID_II, gtp_val, "Unknown message"));
2817 ext_tree_flow_ii = proto_item_add_subtree(te, ett_gtp_flow_ii);
2819 proto_tree_add_uint(ext_tree_flow_ii, hf_gtpv1_nsapi, tvb, offset+1, 1, tvb_get_guint8(tvb, offset+1) & 0x0F);
2822 teid_ii = tvb_get_ntohl(tvb, offset+2);
2823 proto_tree_add_uint(ext_tree_flow_ii, hf_gtpv1_teid_ii, tvb, offset+2, 4, teid_ii);
2827 proto_tree_add_text(tree, tvb, offset, 1, "Flow data II/TEID Data II : GTP Version not supported");
2833 /* GPRS: 9.60 v7.6.0, chapter 7.9.16A, page 43
2834 * UMTS: 29.060 v4.0, chapter 7.7.16, page 51
2835 * Check if all ms_reason types are included
2838 decode_gtp_19(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2842 field19 = tvb_get_guint8(tvb, offset+1);
2844 switch (gtp_version) {
2846 proto_tree_add_uint(tree, hf_gtpv0_ms_reason, tvb, offset, 2, field19);
2850 proto_tree_add_boolean(tree, hf_gtpv1_tear_ind, tvb, offset, 2, field19 & 0x01);
2854 proto_tree_add_text(tree, tvb, offset, 1, "Information Element Type = 19 : GTP Version not supported");
2862 /* GPRS: not present
2863 * UMTS: 29.060 v4.0, chapter 7.7.17, page 51
2866 decode_gtp_nsapi(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2870 nsapi = tvb_get_guint8(tvb, offset+1) & 0x0F;
2871 proto_tree_add_uint(tree, hf_gtpv1_nsapi, tvb, offset, 2, nsapi);
2876 /* GPRS: not present
2877 * UMTS: 29.060 v4.0, chapter 7.7.18, page 52
2880 decode_gtp_ranap_cause(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2884 ranap = tvb_get_guint8(tvb, offset+1);
2886 if(ranap > 0 && ranap <=64)
2887 proto_tree_add_uint_format(tree, hf_gtpv1_ranap_cause, tvb, offset, 2, ranap, "%s (Radio Network Layer Cause) : %s (%u)", val_to_str(GTP_EXT_RANAP_CAUSE, gtp_val, "Unknown"), val_to_str(ranap, ranap_cause_type, "Unknown RANAP Cause"), ranap);
2889 if(ranap > 64 && ranap <=80)
2890 proto_tree_add_uint_format(tree, hf_gtpv1_ranap_cause, tvb, offset, 2, ranap, "%s (Transport Layer Cause) : %s (%u)", val_to_str(GTP_EXT_RANAP_CAUSE, gtp_val, "Unknown"), val_to_str(ranap, ranap_cause_type, "Unknown RANAP Cause"), ranap);
2892 if(ranap > 80 && ranap <=96)
2893 proto_tree_add_uint_format(tree, hf_gtpv1_ranap_cause, tvb, offset, 2, ranap, "%s (NAS Cause) : %s (%u)", val_to_str(GTP_EXT_RANAP_CAUSE, gtp_val, "Unknown"), val_to_str(ranap, ranap_cause_type, "Unknown RANAP Cause"), ranap);
2895 if(ranap > 96 && ranap <=112)
2896 proto_tree_add_uint_format(tree, hf_gtpv1_ranap_cause, tvb, offset, 2, ranap, "%s (Protocol Cause) : %s (%u)", val_to_str(GTP_EXT_RANAP_CAUSE, gtp_val, "Unknown"), val_to_str(ranap, ranap_cause_type, "Unknown RANAP Cause"), ranap);
2898 if(ranap > 112 && ranap <=128)
2899 proto_tree_add_uint_format(tree, hf_gtpv1_ranap_cause, tvb, offset, 2, ranap, "%s (Miscellaneous Cause) : %s (%u)", val_to_str(GTP_EXT_RANAP_CAUSE, gtp_val, "Unknown"), val_to_str(ranap, ranap_cause_type, "Unknown RANAP Cause"), ranap);
2901 if(ranap > 128 && ranap <=255)
2902 proto_tree_add_uint_format(tree, hf_gtpv1_ranap_cause, tvb, offset, 2, ranap, "%s (Non-standard Cause) : %s (%u)", val_to_str(GTP_EXT_RANAP_CAUSE, gtp_val, "Unknown"), val_to_str(ranap, ranap_cause_type, "Unknown RANAP Cause"), ranap);
2907 /* GPRS: not present
2908 * UMTS: 29.060 v4.0, chapter 7.7.19, page 52
2911 decode_gtp_rab_cntxt(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2913 guint8 nsapi, dl_pdcp_seq, ul_pdcp_seq;
2914 guint16 dl_gtpu_seq, ul_gtpu_seq;
2915 proto_tree *ext_tree_rab_cntxt;
2918 te = proto_tree_add_text(tree, tvb, offset, 8, val_to_str(GTP_EXT_RAB_CNTXT, gtp_val, "Unknown message"));
2919 ext_tree_rab_cntxt = proto_item_add_subtree(te, ett_gtp_rab_cntxt);
2921 nsapi = tvb_get_guint8(tvb, offset+1) & 0x0F;
2922 dl_gtpu_seq = tvb_get_ntohs(tvb, offset+2);
2923 ul_gtpu_seq = tvb_get_ntohs(tvb, offset+4);
2924 dl_pdcp_seq = tvb_get_guint8(tvb, offset+6);
2925 ul_pdcp_seq = tvb_get_guint8(tvb, offset+7);
2927 proto_tree_add_uint(ext_tree_rab_cntxt, hf_gtpv1_nsapi, tvb, offset+1, 1, nsapi);
2928 proto_tree_add_uint(ext_tree_rab_cntxt, hf_gtpv1_rab_gtpu_dn, tvb, offset+2, 2, dl_gtpu_seq);
2929 proto_tree_add_uint(ext_tree_rab_cntxt, hf_gtpv1_rab_gtpu_up, tvb, offset+4, 2, ul_gtpu_seq);
2930 proto_tree_add_uint(ext_tree_rab_cntxt, hf_gtpv1_rab_pdu_dn, tvb, offset+6, 1, dl_pdcp_seq);
2931 proto_tree_add_uint(ext_tree_rab_cntxt, hf_gtpv1_rab_pdu_up, tvb, offset+7, 1, ul_pdcp_seq);
2937 /* GPRS: not present
2938 * UMTS: 29.060 v4.0, chapter 7.7.20, page 53
2941 decode_gtp_rp_sms(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2945 rp_sms = tvb_get_guint8(tvb, offset+1) & 0x07;
2946 proto_tree_add_uint(tree, hf_gtpv1_rp_sms, tvb, offset, 2, rp_sms);
2951 /* GPRS: not present
2952 * UMTS: 29.060 v4.0, chapter 7.7.21, page 53
2955 decode_gtp_rp(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2957 proto_tree *ext_tree_rp;
2959 guint8 nsapi, rp, spare;
2961 nsapi = tvb_get_guint8(tvb, offset+1) & 0xF0;
2962 spare = tvb_get_guint8(tvb, offset+1) & 0x08;
2963 rp = tvb_get_guint8(tvb, offset+1) & 0x07;
2965 te = proto_tree_add_uint_format(tree, hf_gtpv1_rp, tvb, offset, 2, rp, "Radio Priority for NSAPI(%u) : %u", nsapi, rp);
2966 ext_tree_rp = proto_item_add_subtree(tree, ett_gtp_rp);
2968 proto_tree_add_uint(ext_tree_rp, hf_gtpv1_rp_nsapi, tvb, offset+1, 1, nsapi);
2969 proto_tree_add_uint(ext_tree_rp, hf_gtpv1_rp_spare, tvb, offset+1, 1, spare);
2970 proto_tree_add_uint(ext_tree_rp, hf_gtpv1_rp, tvb, offset+1, 1, rp);
2975 /* GPRS: not present
2976 * UMTS: 29.060 v4.0, chapter 7.7.22, page 53
2979 decode_gtp_pkt_flow_id(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2981 proto_tree *ext_tree_pkt_flow_id;
2983 guint8 nsapi, pkt_flow_id;
2985 nsapi = tvb_get_guint8(tvb, offset+1) & 0x0F;
2986 pkt_flow_id = tvb_get_guint8(tvb, offset+2);
2988 te = proto_tree_add_uint_format(tree, hf_gtpv1_pkt_flow_id, tvb, offset, 3, pkt_flow_id, "Packet Flow ID for NSAPI(%u) : %u", nsapi, pkt_flow_id);
2989 ext_tree_pkt_flow_id = proto_item_add_subtree(tree, ett_gtp_pkt_flow_id);
2991 proto_tree_add_uint(ext_tree_pkt_flow_id, hf_gtpv1_nsapi, tvb, offset+1, 1, nsapi);
2992 proto_tree_add_uint_format(ext_tree_pkt_flow_id, hf_gtpv1_pkt_flow_id, tvb, offset+2, 1, pkt_flow_id, "%s : %u", val_to_str(GTP_EXT_PKT_FLOW_ID, gtp_val, "Unknown message"), pkt_flow_id);
2997 /* GPRS: not present
2998 * UMTS: 29.060 v4.0, chapter 7.7.23, page 53
2999 * TODO: Differenciate these uints?
3002 decode_gtp_chrg_char(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3006 proto_tree *ext_tree_chrg_char;
3008 chrg_char = tvb_get_ntohs(tvb, offset+1);
3010 te = proto_tree_add_text(tree, tvb, offset, 3, "%s: %x", val_to_str(GTP_EXT_CHRG_CHAR, gtp_val, "Unknown message"), chrg_char);
3011 ext_tree_chrg_char = proto_item_add_subtree(te, ett_gtp_chrg_char);
3013 proto_tree_add_uint(ext_tree_chrg_char, hf_gtpv1_chrg_char_s, tvb, offset+1, 2, chrg_char);
3014 proto_tree_add_uint(ext_tree_chrg_char, hf_gtpv1_chrg_char_n, tvb, offset+1, 2, chrg_char);
3015 proto_tree_add_uint(ext_tree_chrg_char, hf_gtpv1_chrg_char_p, tvb, offset+1, 2, chrg_char);
3016 proto_tree_add_uint(ext_tree_chrg_char, hf_gtpv1_chrg_char_f, tvb, offset+1, 2, chrg_char);
3017 proto_tree_add_uint(ext_tree_chrg_char, hf_gtpv1_chrg_char_h, tvb, offset+1, 2, chrg_char);
3018 proto_tree_add_uint(ext_tree_chrg_char, hf_gtpv1_chrg_char_r, tvb, offset+1, 2, chrg_char);
3023 /* GPRS: not present
3024 * UMTS: 29.060 v4.0, chapter 7.7.24, page
3027 decode_gtp_trace_ref(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3031 trace_ref = tvb_get_ntohs(tvb, offset+1);
3033 proto_tree_add_uint(tree, hf_gtpv1_trace_ref, tvb, offset, 3, trace_ref);
3038 /* GPRS: not present
3039 * UMTS: 29.060 v4.0, chapter 7.7.25, page
3042 decode_gtp_trace_type(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3046 trace_type = tvb_get_ntohs(tvb, offset+1);
3048 proto_tree_add_uint(tree, hf_gtpv1_trace_type, tvb, offset, 3, trace_type);
3053 /* GPRS: 9.60 v7.6.0, chapter 7.9.16A
3054 * UMTS: 29.060 v4.0, chapter 7.7.25A, page
3057 decode_gtp_ms_reason(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3061 reason = tvb_get_guint8(tvb, offset+1);
3063 proto_tree_add_uint(tree, gtp_version ? hf_gtpv1_ms_reason : hf_gtpv0_ms_reason, tvb, offset, 2, reason);
3069 /* GPRS: 12.15 v7.6.0, chapter 7.3.3, page 45
3073 decode_gtp_tr_comm(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3077 tr_command = tvb_get_guint8(tvb, offset+1);
3079 proto_tree_add_uint(tree, gtp_version ? hf_gtpv1_tr_comm : hf_gtpv0_tr_comm, tvb, offset, 2, tr_command);
3084 /* GPRS: 9.60 v7.6.0, chapter 7.9.17, page 43
3085 * UMTS: 29.060 v4.0, chapter 7.7.26, page 55
3088 decode_gtp_chrg_id(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3092 chrg_id = tvb_get_ntohl(tvb, offset+1);
3093 proto_tree_add_uint(tree, gtp_version ? hf_gtpv1_chrg_id : hf_gtpv0_chrg_id, tvb, offset, 5, chrg_id);
3098 /* GPRS: 9.60 v7.6.0, chapter 7.9.18, page 43
3099 * UMTS: 29.060 v4.0, chapter 7.7.27, page 55
3102 decode_gtp_user_addr(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3105 guint8 pdp_typ, pdp_org;
3107 struct e_in6_addr addr_ipv6;
3108 proto_tree *ext_tree_user;
3112 length = tvb_get_ntohs(tvb, offset+1);
3113 pdp_org = tvb_get_guint8(tvb, offset+3) & 0x0F;
3114 pdp_typ = tvb_get_guint8(tvb, offset+4);
3116 te = proto_tree_add_text(tree, tvb, offset, 3+length, "%s (%s/%s)",
3117 val_to_str(GTP_EXT_USER_ADDR, gtp_val, "Unknown message"),
3118 val_to_str(pdp_org, pdp_org_type, "Unknown PDP Organization"),
3119 val_to_str(pdp_typ, pdp_type, "Unknown PDP Type"));
3120 ext_tree_user = proto_item_add_subtree(te, ett_gtp_user);
3122 proto_tree_add_text(ext_tree_user, tvb, offset+1, 2, "Length : %u", length);
3123 proto_tree_add_uint(ext_tree_user, gtp_version ? hf_gtpv1_user_addr_pdp_org : hf_gtpv0_user_addr_pdp_org, tvb, offset+3, 1, pdp_org);
3124 proto_tree_add_uint(ext_tree_user, gtp_version ? hf_gtpv1_user_addr_pdp_type : hf_gtpv0_user_addr_pdp_type, tvb, offset+4, 1, pdp_typ);
3127 if (pdp_org == 0 && pdp_typ == 1)
3128 proto_item_append_text(te, " (Point to Point Protocol)");
3129 else if (pdp_typ == 2)
3130 proto_item_append_text(te, " (Octet Stream Protocol)");
3131 } else if (length > 2) {
3134 tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+5, sizeof addr_ipv4);
3135 proto_tree_add_ipv4(ext_tree_user, gtp_version ? hf_gtpv1_user_ipv4 : hf_gtpv0_user_ipv4, tvb, offset+5, 4, addr_ipv4);
3136 proto_item_append_text(te, " : %s", ip_to_str((guint8 *)&addr_ipv4));
3139 tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+5, sizeof addr_ipv6);
3140 proto_tree_add_ipv6(ext_tree_user, gtp_version ? hf_gtpv1_user_ipv6 : hf_gtpv0_user_ipv6, tvb, offset+5, 16, (guint8 *)&addr_ipv6);
3141 proto_item_append_text(te, " : %s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
3145 proto_item_append_text(te, " : empty PDP Address");
3151 decode_triplet(tvbuff_t *tvb, int offset, proto_tree *tree, guint16 count) {
3153 proto_tree *ext_tree_trip;
3154 proto_item *te_trip;
3157 for (i=0;i<count;i++) {
3158 te_trip = proto_tree_add_text(tree, tvb, offset+i*28, 28, "Triplet no%x", i);
3159 ext_tree_trip = proto_item_add_subtree(te_trip, ett_gtp_trip);
3161 proto_tree_add_text(ext_tree_trip, tvb, offset+i*28, 16, "RAND: %s", tvb_bytes_to_str(tvb, offset+i*28, 16));
3162 proto_tree_add_text(ext_tree_trip, tvb, offset+i*28+16, 4, "SRES: %s", tvb_bytes_to_str(tvb, offset+i*28+16, 4));
3163 proto_tree_add_text(ext_tree_trip, tvb, offset+i*28+20, 8, "Kc: %s", tvb_bytes_to_str(tvb, offset+i*28+20, 8));
3169 /* adjust - how many bytes before quintuplet should be highlighted
3172 decode_quintuplet(tvbuff_t *tvb, int offset, proto_tree *tree, guint16 count, guint8 adjust) {
3174 proto_tree *ext_tree_quint;
3175 proto_item *te_quint;
3176 guint16 q_len, xres_len, auth_len, q_offset, i;
3180 for (i=0;i<count;i++) {
3182 offset = offset + q_offset;
3184 q_len = tvb_get_ntohs(tvb, offset);
3186 te_quint = proto_tree_add_text(tree, tvb, offset-adjust, q_len+adjust, "Quintuplet #%x", i);
3187 ext_tree_quint = proto_item_add_subtree(te_quint, ett_gtp_quint);
3189 proto_tree_add_text(ext_tree_quint, tvb, offset, 2, "Length: %x", q_len);
3190 proto_tree_add_text(ext_tree_quint, tvb, offset+2, 16, "RAND: %s", tvb_bytes_to_str(tvb, offset+2, 16));
3191 xres_len = tvb_get_ntohs(tvb, offset+18);
3192 proto_tree_add_text(ext_tree_quint, tvb, offset+18, 2, "XRES length: %u", xres_len);
3193 proto_tree_add_text(ext_tree_quint, tvb, offset+20, xres_len, "XRES: %s", tvb_bytes_to_str(tvb, offset+20, xres_len));
3194 proto_tree_add_text(ext_tree_quint, tvb, offset+20+xres_len, 16, "Quintuplet ciphering key: %s", tvb_bytes_to_str(tvb, offset+20+xres_len, 16));
3195 proto_tree_add_text(ext_tree_quint, tvb, offset+36+xres_len, 16, "Quintuplet integrity key: %s", tvb_bytes_to_str(tvb, offset+36+xres_len, 16));
3196 auth_len = tvb_get_ntohs(tvb, offset+52+xres_len);
3197 proto_tree_add_text(ext_tree_quint, tvb, offset+52+xres_len, 2, "Authentication length: %u", auth_len);
3198 proto_tree_add_text(ext_tree_quint, tvb, offset+54+xres_len, auth_len, "AUTH: %s", tvb_bytes_to_str(tvb, offset+54+xres_len, auth_len));
3200 q_offset = q_offset + q_len + 2;
3206 /* GPRS: 9.60 v7.6.0, chapter 7.9.19 page
3207 * UMTS: 29.060 v4.0, chapter 7.7.28 page 57
3208 * TODO: - check if for quintuplets first 2 bytes are length, according to AuthQuint
3209 * - finish displaying last 3 parameters
3212 decode_gtp_mm_cntxt(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3214 guint16 length, quint_len, net_cap, con_len;
3215 guint8 cksn, count, sec_mode, cipher, trans_id, proto_disc, message, drx_split, drx_len, drx_ccch, non_drx_timer;
3216 proto_tree *ext_tree_mm;
3219 te = proto_tree_add_text(tree, tvb, offset, 1, val_to_str(GTP_EXT_MM_CNTXT, gtp_val, "Unknown message"));
3220 ext_tree_mm = proto_item_add_subtree(te, ett_gtp_mm);
3222 length = tvb_get_ntohs(tvb, offset+1);
3223 if (length < 1) return 3;
3225 cksn = tvb_get_guint8(tvb, offset+3) & 0x07;
3226 sec_mode = (tvb_get_guint8(tvb, offset+4) >> 6) & 0x03;
3227 count = (tvb_get_guint8(tvb, offset+4) >> 3) & 0x07;
3228 cipher = tvb_get_guint8(tvb, offset+4) & 0x07;
3230 proto_tree_add_text(ext_tree_mm, tvb, offset+1, 2, "Length: %x", length);
3231 proto_tree_add_text(ext_tree_mm, tvb, offset+3, 1, "Ciphering Key Sequence Number: %u", cksn);
3232 if (gtp_version != 0) {
3233 proto_tree_add_text(ext_tree_mm, tvb, offset+3, 1, "Security type: %u", sec_mode);
3238 proto_tree_add_text(ext_tree_mm, tvb, offset+4, 1, "No of triplets: %u", count);
3243 proto_tree_add_text(ext_tree_mm, tvb, offset+4, 1, "Ciphering: no ciphering");
3245 proto_tree_add_text(ext_tree_mm, tvb, offset+4, 1, "Ciphering: GEA/%u", cipher);
3247 proto_tree_add_text(ext_tree_mm, tvb, offset+5, 16, "Ciphering key CK: %s", tvb_bytes_to_str(tvb, offset+5, 16));
3248 proto_tree_add_text(ext_tree_mm, tvb, offset+21, 16, "Integrity key CK: %s", tvb_bytes_to_str(tvb, offset+21, 16));
3249 quint_len = tvb_get_ntohs(tvb, offset+37);
3250 proto_tree_add_text(ext_tree_mm, tvb, offset+37, 2, "Quintuplets length: %x", quint_len);
3252 offset = offset + decode_quintuplet(tvb, offset+39, ext_tree_mm, count, 0) + 39;
3258 proto_tree_add_text(ext_tree_mm, tvb, offset+4, 1, "Ciphering: no ciphering");
3260 proto_tree_add_text(ext_tree_mm, tvb, offset+4, 1, "Ciphering: GEA/%u", cipher);
3262 proto_tree_add_text(ext_tree_mm, tvb, offset+5, 8, "Ciphering key Kc: %s", tvb_bytes_to_str(tvb, offset+5, 8));
3264 offset = offset + decode_triplet(tvb, offset+13, ext_tree_mm, count) + 13;
3268 proto_tree_add_text(ext_tree_mm, tvb, offset+5, 16, "Ciphering key CK: %s", tvb_bytes_to_str(tvb, offset+5, 16));
3269 proto_tree_add_text(ext_tree_mm, tvb, offset+21, 16, "Integrity key CK: %s", tvb_bytes_to_str(tvb, offset+21, 16));
3270 quint_len = tvb_get_ntohs(tvb, offset+37);
3271 proto_tree_add_text(ext_tree_mm, tvb, offset+37, 2, "Quintuplets length: %x", quint_len);
3273 offset = offset + decode_quintuplet(tvb, offset+39, ext_tree_mm, count, 0) + 39;
3278 proto_tree_add_text(ext_tree_mm, tvb, offset+4, 1, "Ciphering: no ciphering");
3280 proto_tree_add_text(ext_tree_mm, tvb, offset+4, 1, "Ciphering: GEA/%u", cipher);
3282 proto_tree_add_text(ext_tree_mm, tvb, offset+5, 8, "Ciphering key Kc: %s", tvb_bytes_to_str(tvb, offset+5, 8));
3283 quint_len = tvb_get_ntohs(tvb, offset+13);
3284 proto_tree_add_text(ext_tree_mm, tvb, offset+13, 2, "Quintuplets length: %x", quint_len);
3286 offset = offset + decode_quintuplet(tvb, offset+15, ext_tree_mm, count, 0) + 15;
3294 drx_split = tvb_get_guint8(tvb, offset);
3295 drx_len = (tvb_get_guint8(tvb, offset+1) >> 4) & 0x0F;
3296 drx_ccch = (tvb_get_guint8(tvb, offset+1) >> 3) & 0x01;
3297 non_drx_timer = tvb_get_guint8(tvb, offset+1) & 0x07;
3299 net_cap = tvb_get_ntohs(tvb, offset+2);
3300 con_len = tvb_get_ntohs(tvb, offset+4);
3302 proto_tree_add_text(ext_tree_mm, tvb, offset, 1, "DRX: split PG cycle code: %u", drx_split);
3303 proto_tree_add_text(ext_tree_mm, tvb, offset+1, 1, "DRX: CN specific DRX cycle length coefficient: %u", drx_len);
3304 proto_tree_add_text(ext_tree_mm, tvb, offset+1, 1, "DRX: split PG cycle on CCCH supported by MS: %s", yesno[drx_ccch]);
3305 if (non_drx_timer == 0) {
3306 proto_tree_add_text(ext_tree_mm, tvb, offset+1, 1, "DRX: no non-DRX mode after transfer state");
3308 proto_tree_add_text(ext_tree_mm, tvb, offset+1, 1, "DRX: max sec non-DRX mode after transfer state: 2^%u", non_drx_timer-1);
3311 proto_tree_add_text(ext_tree_mm, tvb, offset+2, 2, "MS network capability: %u", net_cap);
3312 proto_tree_add_text(ext_tree_mm, tvb, offset+4, 2, "Container length: %u", con_len);
3315 trans_id = (tvb_get_guint8(tvb, offset+6) >> 4) & 0x0F;
3316 proto_disc = tvb_get_guint8(tvb, offset+6) & 0x0F;
3317 message = tvb_get_guint8(tvb, offset+7);
3323 /* Function to extract the value of an hexadecimal octet. Only the lower
3324 * nybble will be non-zero in the output.
3326 static guint8 hex2dec (guint8 x)
3328 if ((x >= 'a') && (x <= 'f'))
3330 else if ((x >= 'A') && (x <= 'F'))
3332 else if ((x >= '0') && (x <= '9'))
3339 /* Wrapper function to add UTF-8 decoding for QoS attributes in
3342 static guint8 wrapped_tvb_get_guint8(
3343 tvbuff_t *tvb, int offset, int type)
3346 return (hex2dec(tvb_get_guint8(tvb, offset)) << 4
3347 | hex2dec(tvb_get_guint8(tvb, offset + 1)));
3349 return tvb_get_guint8(tvb, offset);
3352 /* WARNING : actually length is coded on 2 octets for QoS profile but on 1 octet for PDP Context!
3353 * so type means length of length :-)
3355 * WARNING :) type does not mean length of length any more... see below for
3359 decode_qos_umts(tvbuff_t *tvb, int offset, proto_tree *tree, gchar* qos_str, guint8 type) {
3362 guint8 al_ret_priority;
3363 guint8 delay, reliability, peak, precedence, mean, spare1, spare2, spare3;
3364 guint8 traf_class, del_order, del_err_sdu;
3365 guint8 max_sdu_size, max_ul, max_dl;
3366 guint8 res_ber, sdu_err_ratio;
3367 guint8 trans_delay, traf_handl_prio;
3368 guint8 guar_ul, guar_dl;
3369 proto_tree *ext_tree_qos;
3371 int mss, mu, md, gu, gd;
3373 /* Will keep if the input is UTF-8 encoded (as in RADIUS messages).
3374 * If 1, input is *not* UTF-8 encoded (i.e. each input octet corresponds
3375 * to one byte to be dissected).
3376 * If 2, input is UTF-8 encoded (i.e. each *couple* of input octets
3377 * corresponds to one byte to be dissected)
3379 guint8 utf8_type = 1;
3381 /* In RADIUS messages the QoS has a version field of two octets prepended.
3382 * As of 29.061 v.3.a.0, there is an hyphen between "Release Indicator" and
3383 * <release specific QoS IE UTF-8 encoding>. Even if it sounds rather
3384 * inconsistent and unuseful, I will check hyphen presence here and
3385 * will signal its presence.
3387 guint8 version_buffer[2];
3390 /* Will keep the value that will be returned
3396 length = tvb_get_guint8 (tvb, offset);
3397 te = proto_tree_add_text (tree, tvb, offset, length + 1, "%s", qos_str);
3398 ext_tree_qos = proto_item_add_subtree (te, ett_gtp_qos);
3399 proto_tree_add_text (ext_tree_qos, tvb, offset, 1, "Length: %u", length);
3401 retval = length + 1;
3404 length = tvb_get_ntohs (tvb, offset + 1);
3405 te = proto_tree_add_text(tree, tvb, offset, length + 3, "%s", qos_str);
3406 ext_tree_qos = proto_item_add_subtree (te, ett_gtp_qos);
3407 proto_tree_add_text (ext_tree_qos, tvb, offset + 1, 2, "Length: %u", length);
3408 offset += 3; /* +1 because of first 0x86 byte for UMTS QoS */
3409 retval = length + 3;
3412 /* For QoS inside RADIUS Client messages from GGSN */
3415 /* The field in the RADIUS message starts one byte before :) */
3416 length = tvb_get_guint8 (tvb, offset);
3417 te = proto_tree_add_text (tree, tvb, offset - 1, length, "%s", qos_str);
3419 ext_tree_qos = proto_item_add_subtree (te, ett_gtp_qos);
3420 version_buffer[0] = tvb_get_guint8(tvb, offset + 1);
3421 version_buffer[1] = tvb_get_guint8(tvb, offset + 2);
3422 proto_tree_add_text (ext_tree_qos, tvb, offset + 1, 2, "Version: %c%c", version_buffer[0], version_buffer[1]);
3424 /* Hyphen handling */
3425 hyphen = tvb_get_guint8(tvb, offset + 3);
3426 if (hyphen == ((guint8) '-'))
3428 /* Hyphen is present, put in protocol tree */
3429 proto_tree_add_text (ext_tree_qos, tvb, offset + 3, 1, "Hyphen separator: -");
3430 offset++; /* "Get rid" of hyphen */
3433 /* Now, we modify offset here and in order to use type later
3436 retval = length + 3; /* Actually, will be ignored. */
3439 /* XXX - what should we do with the length here? */
3442 ext_tree_qos = NULL;
3446 /* In RADIUS messages there is no allocation-retention priority
3447 * so I don't need to wrap the following call to tvb_get_guint8
3449 al_ret_priority = tvb_get_guint8 (tvb, offset);
3451 /* All calls are wrapped to take into account the possibility that the
3452 * input is UTF-8 encoded. If utf8_type is equal to 1, the final value
3453 * of the offset will be the same as in the previous version of this
3454 * dissector, and the wrapped function will serve as a dumb wrapper;
3455 * otherwise, if utf_8_type is 2, the offset is correctly shifted by
3456 * two bytes for needed shift, and the wrapped function will unencode
3457 * two values from the input.
3459 spare1 = wrapped_tvb_get_guint8(tvb, offset+(1 - 1) * utf8_type + 1, utf8_type) & 0xC0;
3460 delay = wrapped_tvb_get_guint8(tvb, offset+(1 - 1) * utf8_type + 1, utf8_type) & 0x38;
3461 reliability = wrapped_tvb_get_guint8(tvb, offset+(1 - 1) * utf8_type + 1, utf8_type) & 0x07;
3462 peak = wrapped_tvb_get_guint8(tvb, offset+(2 - 1) * utf8_type + 1, utf8_type) & 0xF0;
3463 spare2 = wrapped_tvb_get_guint8(tvb, offset+(2 - 1) * utf8_type + 1, utf8_type) & 0x08;
3464 precedence = wrapped_tvb_get_guint8(tvb, offset+(2 - 1) * utf8_type + 1, utf8_type) & 0x07;
3465 spare3 = wrapped_tvb_get_guint8(tvb, offset+(3 - 1) * utf8_type + 1, utf8_type) & 0xE0;
3466 mean = wrapped_tvb_get_guint8(tvb, offset+(3 - 1) * utf8_type + 1, utf8_type) & 0x1F;
3468 /* In RADIUS messages there is no allocation-retention priority */
3470 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_al_ret_priority, tvb, offset, 1, al_ret_priority);
3472 /* All additions must take care of the fact that QoS fields in RADIUS
3473 * messages are UTF-8 encoded, so we have to use the same trick as above.
3475 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_spare1, tvb, offset+(1 - 1) * utf8_type + 1, utf8_type, spare1);
3476 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_delay, tvb, offset+(1 - 1) * utf8_type + 1, utf8_type, delay);
3477 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_reliability, tvb, offset+(1 - 1) * utf8_type + 1, utf8_type, reliability);
3478 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_peak, tvb, offset+(2 - 1) * utf8_type + 1, utf8_type, peak);
3479 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_spare2, tvb, offset+(2 - 1) * utf8_type + 1, utf8_type, spare2);
3480 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_precedence, tvb, offset+(2 - 1) * utf8_type + 1, utf8_type, precedence);
3481 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_spare3, tvb, offset+(3 - 1) * utf8_type + 1, utf8_type, spare3);
3482 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_mean, tvb, offset+(3 - 1) * utf8_type + 1, utf8_type, mean);
3486 /* See above for the need of wrapping
3488 traf_class = wrapped_tvb_get_guint8(tvb, offset+(4 - 1) * utf8_type + 1, utf8_type) & 0xE0;
3489 del_order = wrapped_tvb_get_guint8(tvb, offset+(4 - 1) * utf8_type + 1, utf8_type) & 0x18;
3490 del_err_sdu = wrapped_tvb_get_guint8(tvb, offset+(4 - 1) * utf8_type + 1, utf8_type) & 0x07;
3491 max_sdu_size = wrapped_tvb_get_guint8(tvb, offset+(5 - 1) * utf8_type + 1, utf8_type);
3492 max_ul = wrapped_tvb_get_guint8(tvb, offset+(6 - 1) * utf8_type + 1, utf8_type);
3493 max_dl = wrapped_tvb_get_guint8(tvb, offset+(7 - 1) * utf8_type + 1, utf8_type);
3494 res_ber = wrapped_tvb_get_guint8(tvb, offset+(8 - 1) * utf8_type + 1, utf8_type) & 0xF0;
3495 sdu_err_ratio = wrapped_tvb_get_guint8(tvb, offset+(8 - 1) * utf8_type + 1, utf8_type) & 0x0F;
3496 trans_delay = wrapped_tvb_get_guint8(tvb, offset+(9 - 1) * utf8_type + 1, utf8_type) & 0xFC;
3497 traf_handl_prio = wrapped_tvb_get_guint8(tvb, offset+(9 - 1) * utf8_type + 1, utf8_type) & 0x03;
3498 guar_ul = wrapped_tvb_get_guint8(tvb, offset+(10 - 1) * utf8_type + 1, utf8_type);
3499 guar_dl = wrapped_tvb_get_guint8(tvb, offset+(11 - 1) * utf8_type + 1, utf8_type);
3501 /* See above comments for the changes
3503 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_traf_class, tvb, offset+(4 - 1) * utf8_type + 1, utf8_type, traf_class);
3504 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_del_order, tvb, offset+(4 - 1) * utf8_type + 1, utf8_type, del_order);
3505 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_del_err_sdu, tvb, offset+(4 - 1) * utf8_type + 1, utf8_type, del_err_sdu);
3506 if (max_sdu_size == 0 || max_sdu_size > 150)
3507 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_max_sdu_size, tvb, offset+(5 - 1) * utf8_type + 1, utf8_type, max_sdu_size);
3508 if (max_sdu_size > 0 && max_sdu_size <= 150) {
3509 mss = max_sdu_size*10;
3510 proto_tree_add_uint_format(ext_tree_qos, hf_gtpv1_qos_max_sdu_size, tvb, offset+(5 - 1) * utf8_type + 1, utf8_type, mss, "Maximum SDU size : %u octets", mss);
3513 if(max_ul == 0 || max_ul == 255)
3514 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_max_ul, tvb, offset+(6 - 1) * utf8_type + 1, utf8_type, max_ul);
3515 if(max_ul > 0 && max_ul <= 63)
3516 proto_tree_add_uint_format(ext_tree_qos, hf_gtpv1_qos_max_ul, tvb, offset+(6 - 1) * utf8_type + 1, utf8_type, max_ul, "Maximum bit rate for uplink : %u kbps", max_ul);
3517 if(max_ul > 63 && max_ul <=127) {
3518 mu = 64 + ( max_ul - 64 ) * 8;
3519 proto_tree_add_uint_format(ext_tree_qos, hf_gtpv1_qos_max_ul, tvb, offset+(6 - 1) * utf8_type + 1, utf8_type, mu, "Maximum bit rate for uplink : %u kbps", mu);
3522 if(max_ul > 127 && max_ul <=254) {
3523 mu = 576 + ( max_ul - 128 ) * 64;
3524 proto_tree_add_uint_format(ext_tree_qos, hf_gtpv1_qos_max_ul, tvb, offset+(6 - 1) * utf8_type + 1, utf8_type, mu, "Maximum bit rate for uplink : %u kbps", mu);
3527 if(max_dl == 0 || max_dl == 255)
3528 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_max_dl, tvb, offset+(7 - 1) * utf8_type + 1, utf8_type, max_dl);
3529 if(max_dl > 0 && max_dl <= 63)
3530 proto_tree_add_uint_format(ext_tree_qos, hf_gtpv1_qos_max_dl, tvb, offset+(7 - 1) * utf8_type + 1, utf8_type, max_dl, "Maximum bit rate for downlink : %u kbps", max_dl);
3531 if(max_dl > 63 && max_dl <=127) {
3532 md = 64 + ( max_dl - 64 ) * 8;
3533 proto_tree_add_uint_format(ext_tree_qos, hf_gtpv1_qos_max_dl, tvb, offset+(7 - 1) * utf8_type + 1, utf8_type, md, "Maximum bit rate for downlink : %u kbps", md);
3535 if(max_dl > 127 && max_dl <=254) {
3536 md = 576 + ( max_dl - 128 ) * 64;
3537 proto_tree_add_uint_format(ext_tree_qos, hf_gtpv1_qos_max_dl, tvb, offset+(7 - 1) * utf8_type + 1, utf8_type, md, "Maximum bit rate for downlink : %u kbps", md);
3540 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_res_ber, tvb, offset+(8 - 1) * utf8_type + 1, utf8_type, res_ber);
3541 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_sdu_err_ratio, tvb, offset+(8 - 1) * utf8_type + 1, utf8_type, sdu_err_ratio);
3542 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_trans_delay, tvb, offset+(9 - 1) * utf8_type + 1, utf8_type, trans_delay);
3543 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_traf_handl_prio, tvb, offset+(9 - 1) * utf8_type + 1, utf8_type, traf_handl_prio);
3545 if(guar_ul == 0 || guar_ul == 255)
3546 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_guar_ul, tvb, offset+(10 - 1) * utf8_type + 1, utf8_type, guar_ul);
3547 if(guar_ul > 0 && guar_ul <= 63)
3548 proto_tree_add_uint_format(ext_tree_qos, hf_gtpv1_qos_guar_ul, tvb, offset+(10 - 1) * utf8_type + 1, utf8_type, guar_ul, "Guaranteed bit rate for uplink : %u kbps", guar_ul);
3549 if(guar_ul > 63 && guar_ul <=127) {
3550 gu = 64 + ( guar_ul - 64 ) * 8;
3551 proto_tree_add_uint_format(ext_tree_qos, hf_gtpv1_qos_guar_ul, tvb, offset+(10 - 1) * utf8_type + 1, utf8_type, gu, "Guaranteed bit rate for uplink : %u kbps", gu);
3553 if(guar_ul > 127 && guar_ul <=254) {
3554 gu = 576 + ( guar_ul - 128 ) * 64;
3555 proto_tree_add_uint_format(ext_tree_qos, hf_gtpv1_qos_guar_ul, tvb, offset+(10 - 1) * utf8_type + 1, utf8_type, gu, "Guaranteed bit rate for uplink : %u kbps", gu);
3558 if(guar_dl == 0 || guar_dl == 255)
3559 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_guar_dl, tvb, offset+(11 - 1) * utf8_type + 1, utf8_type, guar_dl);
3560 if(guar_dl > 0 && guar_dl <= 63)
3561 proto_tree_add_uint_format(ext_tree_qos, hf_gtpv1_qos_guar_dl, tvb, offset+(11 - 1) * utf8_type + 1, utf8_type, guar_dl, "Guaranteed bit rate for downlink : %u kbps", guar_dl);
3562 if(guar_dl > 63 && guar_dl <=127) {
3563 gd = 64 + ( guar_dl - 64 ) * 8;
3564 proto_tree_add_uint_format(ext_tree_qos, hf_gtpv1_qos_guar_dl, tvb, offset+(11 - 1) * utf8_type + 1, utf8_type, gd, "Guaranteed bit rate for downlink : %u kbps", gd);
3566 if(guar_dl > 127 && guar_dl <=254) {
3567 gd = 576 + ( guar_dl - 128 ) * 64;
3568 proto_tree_add_uint_format(ext_tree_qos, hf_gtpv1_qos_guar_dl, tvb, offset+(11 - 1) * utf8_type + 1, utf8_type, gd, "Guaranteed bit rate for downlink : %u kbps", gd);
3577 decode_apn(tvbuff_t *tvb, int offset, guint16 length, proto_tree *tree) {
3580 guint8 name_len, tmp;
3583 apn = g_malloc (length + 1);
3584 name_len = tvb_get_guint8 (tvb, offset);
3586 if (name_len < 0x20) {
3587 tvb_memcpy (tvb, apn, offset + 1, length);
3589 if (name_len >= length - 1) break;
3591 name_len = name_len + apn[tmp] + 1;
3595 tvb_memcpy (tvb, apn, offset, length);
3598 apn[length-1] = '\0';
3599 proto_tree_add_string(tree, gtp_version ? hf_gtpv1_apn : hf_gtpv0_apn, tvb, offset, length, apn);
3604 /* GPRS: 9.60 v7.6.0, chapter 7.9.20
3605 * UMTS: 29.060 v4.0, chapter 7.7.29
3606 * TODO: unify addr functions
3609 decode_gtp_pdp_cntxt(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3611 guint8 ggsn_addr_len, apn_len, trans_id, vaa, order, nsapi, sapi, pdu_send_no, pdu_rec_no, pdp_cntxt_id,
3612 pdp_type_org, pdp_type_num, pdp_addr_len;
3613 guint16 length, sn_down, sn_up, up_flow;
3614 guint32 addr_ipv4, up_teid, up_teid_cp;
3615 struct e_in6_addr addr_ipv6;
3616 proto_tree *ext_tree_pdp;
3619 length = tvb_get_ntohs(tvb, offset+1);
3621 te = proto_tree_add_text(tree, tvb, offset, length+3, val_to_str(GTP_EXT_PDP_CNTXT, gtp_val, "Unknown message"));
3622 ext_tree_pdp = proto_item_add_subtree(te, ett_gtp_pdp);
3624 vaa = (tvb_get_guint8(tvb, offset+3) >> 6) & 0x01;
3625 order = (tvb_get_guint8(tvb, offset+3) >> 4) & 0x01;
3626 nsapi = tvb_get_guint8(tvb, offset+3) & 0x0F;
3627 sapi = tvb_get_guint8(tvb, offset+4) & 0x0F;
3629 proto_tree_add_text(ext_tree_pdp, tvb, offset+3, 1, "VPLMN address allowed: %s", yesno[vaa]);
3630 proto_tree_add_text(ext_tree_pdp, tvb, offset+3, 1, "Reordering required: %s", yesno[order]);
3631 proto_tree_add_text(ext_tree_pdp, tvb, offset+3, 1, "NSAPI: %u", nsapi);
3632 proto_tree_add_text(ext_tree_pdp, tvb, offset+4, 1, "SAPI: %u", sapi);
3634 switch (gtp_version) {
3636 decode_qos_gprs(tvb, offset+5, ext_tree_pdp, "QoS subscribed", 0);
3637 decode_qos_gprs(tvb, offset+8, ext_tree_pdp, "QoS requested", 0);
3638 decode_qos_gprs(tvb, offset+11, ext_tree_pdp, "QoS negotiated", 0);
3639 offset = offset + 14;
3642 offset = offset + 5;
3643 offset = offset + decode_qos_umts(tvb, offset, ext_tree_pdp, "QoS subscribed", 1);
3644 offset = offset + decode_qos_umts(tvb, offset, ext_tree_pdp, "QoS requested", 1);
3645 offset = offset + decode_qos_umts(tvb, offset, ext_tree_pdp, "QoS negotiated", 1);
3651 sn_down = tvb_get_ntohs(tvb, offset);
3652 sn_up = tvb_get_ntohs(tvb, offset+2);
3653 pdu_send_no = tvb_get_guint8(tvb, offset+4);
3654 pdu_rec_no = tvb_get_guint8(tvb, offset+5);
3656 proto_tree_add_text(ext_tree_pdp, tvb, offset, 2, "Sequence number down: %u", sn_down);
3657 proto_tree_add_text(ext_tree_pdp, tvb, offset+2, 2, "Sequence number up: %u", sn_up);
3658 proto_tree_add_text(ext_tree_pdp, tvb, offset+4, 1, "Send N-PDU number: %u", pdu_send_no);
3659 proto_tree_add_text(ext_tree_pdp, tvb, offset+5, 1, "Receive N-PDU number: %u", pdu_rec_no);
3661 switch (gtp_version) {
3663 up_flow = tvb_get_ntohs(tvb, offset+6);
3664 proto_tree_add_text(ext_tree_pdp, tvb, offset+6, 2, "Uplink flow label signalling: %u", up_flow);
3665 offset = offset + 8;
3668 up_teid = tvb_get_ntohl(tvb, offset+6);
3669 up_teid_cp = tvb_get_ntohl(tvb, offset+10);
3670 pdp_cntxt_id = tvb_get_guint8(tvb, offset+14);
3671 proto_tree_add_text(ext_tree_pdp, tvb, offset+6, 4, "Uplink TEID: %x", up_teid);
3672 proto_tree_add_text(ext_tree_pdp, tvb, offset+10, 4, "Uplink TEID control plane: %x", up_teid_cp);
3673 proto_tree_add_text(ext_tree_pdp, tvb, offset+14, 1, "PDP context identifier: %u", pdp_cntxt_id);
3674 offset = offset + 15;
3680 pdp_type_org = tvb_get_guint8(tvb, offset) & 0x0F;
3681 pdp_type_num = tvb_get_guint8(tvb, offset+1);
3682 pdp_addr_len = tvb_get_guint8(tvb, offset+2);
3684 proto_tree_add_text(ext_tree_pdp, tvb, offset, 1, "PDP organization: %s", val_to_str(pdp_type_org, pdp_type, "Unknown PDP org"));
3685 proto_tree_add_text(ext_tree_pdp, tvb, offset+1, 1, "PDP type: %s", val_to_str(pdp_type_num, pdp_org_type, "Unknown PDP type"));
3686 proto_tree_add_text(ext_tree_pdp, tvb, offset+2, 1, "PDP address length: %u", pdp_addr_len);
3688 if (pdp_addr_len > 0) {
3689 switch (pdp_type_num) {
3691 tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+3, sizeof addr_ipv4);
3692 proto_tree_add_text(ext_tree_pdp, tvb, offset+3, 4, "PDP address: %s", ip_to_str((guint8 *)&addr_ipv4));
3695 tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+3, sizeof addr_ipv6);
3696 proto_tree_add_text(ext_tree_pdp, tvb, offset+3, 16, "PDP address: %s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
3703 offset = offset + 3 + pdp_addr_len;
3705 ggsn_addr_len = tvb_get_guint8(tvb, offset);
3706 proto_tree_add_text(ext_tree_pdp, tvb, offset, 1, "GGSN address length: %u", ggsn_addr_len);
3708 switch (ggsn_addr_len) {
3710 tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+1, sizeof addr_ipv4);
3711 proto_tree_add_text(ext_tree_pdp, tvb, offset+1, 4, "GGSN address: %s", ip_to_str((guint8 *)&addr_ipv4));
3714 tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+1, sizeof addr_ipv6);
3715 proto_tree_add_text(ext_tree_pdp, tvb, offset+1, 16, "GGSN address: %s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
3721 offset = offset + 1 + ggsn_addr_len;
3723 if (gtp_version == 1) {
3725 ggsn_addr_len = tvb_get_guint8(tvb, offset);
3726 proto_tree_add_text(ext_tree_pdp, tvb, offset, 1, "GGSN 2 address length: %u", ggsn_addr_len);
3728 switch (ggsn_addr_len) {
3730 tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+1, sizeof addr_ipv4);
3731 proto_tree_add_text(ext_tree_pdp, tvb, offset+1, 4, "GGSN 2 address: %s", ip_to_str((guint8 *)&addr_ipv4));
3734 tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+1, sizeof addr_ipv6);
3735 proto_tree_add_text(ext_tree_pdp, tvb, offset+1, 16, "GGSN 2 address: %s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
3740 offset = offset + 1 + ggsn_addr_len;
3744 apn_len = tvb_get_guint8(tvb, offset);
3745 proto_tree_add_text(ext_tree_pdp, tvb, offset, 1, "APN length: %u", apn_len);
3746 decode_apn(tvb, offset+1, apn_len, ext_tree_pdp);
3748 offset = offset + 1 + apn_len;
3750 trans_id = tvb_get_guint8(tvb, offset);
3751 proto_tree_add_text(ext_tree_pdp, tvb, offset, 1, "Transaction identifier: %u", trans_id);
3756 /* GPRS: 9.60, v7.6.0, chapter 7.9.21
3757 * UMTS: 29.060, v4.0, chapter 7.7.30
3760 decode_gtp_apn(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3763 proto_tree *ext_tree_apn;
3766 length = tvb_get_ntohs(tvb, offset+1);
3768 te = proto_tree_add_text(tree, tvb, offset, length+3, val_to_str(GTP_EXT_APN, gtp_val, "Unknown field"));
3769 ext_tree_apn = proto_item_add_subtree(te, ett_gtp_apn);
3771 proto_tree_add_text(ext_tree_apn, tvb, offset+1, 2, "APN length : %u", length);
3772 decode_apn(tvb, offset+3, length, ext_tree_apn);
3777 /* GPRS: 9.60 v7.6.0, chapter 7.9.22
3778 * 4.08 v. 7.1.2, chapter 10.5.6.3 (p.580)
3779 * UMTS: 29.060 v4.0, chapter 7.7.31
3780 * 24.008, v4.2, chapter 10.5.6.3
3783 decode_gtp_proto_conf(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree) {
3785 guint16 length, proto_offset;
3787 guint8 conf, proto_len, cnt = 1;
3789 proto_tree *ext_tree_proto;
3791 gboolean save_writable;
3793 length = tvb_get_ntohs(tvb, offset + 1);
3795 te = proto_tree_add_text(tree, tvb, offset, length + 3, val_to_str(GTP_EXT_PROTO_CONF, gtp_val, "Unknown message"));
3796 ext_tree_proto = proto_item_add_subtree(te, ett_gtp_proto);
3798 proto_tree_add_text(ext_tree_proto, tvb, offset + 1, 2, "Length: %u", length);
3800 if (length < 1) return 3;
3802 conf = tvb_get_guint8 (tvb, offset + 3) & 0x07;
3803 proto_tree_add_text (ext_tree_proto, tvb, offset + 3, 1, "Configuration protocol (00000xxx): %u", conf);
3805 proto_offset = 1; /* ... 1st byte is conf */
3809 if (proto_offset >= length) break;
3810 proto_id = tvb_get_ntohs (tvb, offset);
3811 proto_len = tvb_get_guint8 (tvb, offset + 2);
3812 proto_offset += proto_len + 3; /* 3 = proto id + length byte */
3814 if (proto_len > 0) {
3816 proto_tree_add_text (ext_tree_proto, tvb, offset, 2, "Protocol %u ID: %s (0x%04x)",
3817 cnt, val_to_str(proto_id, ppp_vals, "Unknown"),
3819 proto_tree_add_text (ext_tree_proto, tvb, offset+2, 1, "Protocol %u length: %u", cnt, proto_len);
3822 * Don't allow the dissector for the configuration
3823 * protocol in question to update the columns - this
3826 save_writable = col_get_writable(pinfo->cinfo);
3827 col_set_writable(pinfo->cinfo, FALSE);
3830 * XXX - should we have our own dissector table,
3831 * solely for configuration protocols, so that bogus
3832 * values don't cause us to dissect the protocol
3833 * data as, for example, IP?
3835 next_tvb = tvb_new_subset (tvb, offset + 3, proto_len, proto_len);
3836 if (!dissector_try_port(ppp_subdissector_table,
3837 proto_id, next_tvb, pinfo, ext_tree_proto)) {
3838 call_dissector(data_handle, next_tvb, pinfo,
3842 col_set_writable(pinfo->cinfo, save_writable);
3845 offset += proto_len + 3;
3852 /* GPRS: 9.60 v7.6.0, chapter 7.9.23
3853 * UMTS: 29.060 v4.0, chapter 7.7.32
3856 decode_gtp_gsn_addr(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3858 guint8 addr_type, addr_len;
3861 struct e_in6_addr addr_ipv6;
3862 proto_tree *ext_tree_gsn_addr;
3865 length = tvb_get_ntohs(tvb, offset+1);
3867 te = proto_tree_add_text(tree, tvb, offset, 3+length, "GSN address : ");
3868 ext_tree_gsn_addr = proto_item_add_subtree(te, ett_gtp_gsn_addr);
3872 proto_tree_add_text(ext_tree_gsn_addr, tvb, offset+1, 2, "GSN address length : %u", length);
3873 tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+3, sizeof addr_ipv4);
3874 proto_item_append_text(te, "%s", ip_to_str((guint8 *)&addr_ipv4));
3875 proto_tree_add_ipv4(ext_tree_gsn_addr, gtp_version ? hf_gtpv1_gsn_ipv4 : hf_gtpv0_gsn_ipv4, tvb, offset+3, 4, addr_ipv4);
3878 proto_tree_add_text(ext_tree_gsn_addr, tvb, offset+1, 2, "GSN address Information Element length : %u", length);
3879 addr_type = tvb_get_guint8(tvb, offset+3) & 0xC0;
3880 proto_tree_add_uint(ext_tree_gsn_addr, gtp_version ? hf_gtpv1_gsn_addr_type : hf_gtpv0_gsn_addr_type, tvb, offset+3, 1, addr_type);
3881 addr_len = tvb_get_guint8(tvb, offset+3) & 0x3F;
3882 proto_tree_add_uint(ext_tree_gsn_addr, gtp_version ? hf_gtpv1_gsn_addr_len : hf_gtpv0_gsn_addr_len, tvb, offset+3, 1, addr_len);
3883 tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+4, sizeof addr_ipv4);
3884 proto_item_append_text(te, "%s", ip_to_str((guint8 *)&addr_ipv4));
3885 proto_tree_add_ipv4(ext_tree_gsn_addr, gtp_version ? hf_gtpv1_gsn_ipv4 : hf_gtpv0_gsn_ipv4, tvb, offset+4, 4, addr_ipv4);
3888 proto_tree_add_text(ext_tree_gsn_addr, tvb, offset+1, 2, "GSN address length : %u", length);
3889 tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+3, sizeof addr_ipv6);
3890 proto_item_append_text(te, "%s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
3891 proto_tree_add_ipv6(ext_tree_gsn_addr, gtp_version ? hf_gtpv1_gsn_ipv6 : hf_gtpv0_gsn_ipv6, tvb, offset+3, 16, (guint8*)&addr_ipv6);
3894 proto_tree_add_text(ext_tree_gsn_addr, tvb, offset+1, 2, "GSN address Information Element length : %u", length);
3895 addr_type = tvb_get_guint8(tvb, offset+3) & 0xC0;
3896 proto_tree_add_uint(ext_tree_gsn_addr, gtp_version ? hf_gtpv1_gsn_addr_type : hf_gtpv0_gsn_addr_type, tvb, offset+3, 1, addr_type);
3897 addr_len = tvb_get_guint8(tvb, offset+3) & 0x3F;
3898 proto_tree_add_uint(ext_tree_gsn_addr, gtp_version ? hf_gtpv1_gsn_addr_len : hf_gtpv0_gsn_addr_len, tvb, offset+3, 1, addr_len);
3899 tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+4, sizeof addr_ipv6);
3900 proto_item_append_text(te, "%s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
3901 proto_tree_add_ipv6(ext_tree_gsn_addr, gtp_version ? hf_gtpv1_gsn_ipv6 : hf_gtpv0_gsn_ipv6, tvb, offset+4, 16, (guint8*)&addr_ipv6);
3904 proto_item_append_text(te, "unknown type or wrong length");
3911 /* GPRS: 9.60 v7.6.0, chapter 7.9.24
3912 * UMTS: 29.060 v4.0, chapter 7.7.33
3915 decode_gtp_msisdn(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3917 const guint8 *msisdn_val;
3921 length = tvb_get_ntohs(tvb, offset+1);
3923 if (length < 1) return 3;
3925 msisdn_val = tvb_get_ptr(tvb, offset+3, length);
3926 msisdn_str = msisdn_to_str(msisdn_val, length);
3928 proto_tree_add_string(tree, gtp_version ? hf_gtpv1_msisdn : hf_gtpv0_msisdn, tvb, offset, 3+length, msisdn_str);
3933 /* GPRS: not present
3934 * UMTS: 29.060 v4.0, chapter 7.7.34
3935 * 24.008 v4.2, chapter 10.5.6.5
3938 decode_gtp_qos_umts(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3940 return decode_qos_umts(tvb, offset, tree, "Quality of Service", 2);
3943 /* GPRS: not present
3944 * UMTS: 29.060 v4.0, chapter 7.7.35
3947 decode_gtp_auth_qui(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3949 return (1 + decode_quintuplet(tvb, offset+1, tree, 1, 1));
3953 /* GPRS: not present
3954 * UMTS: 29.060 v4.0, chapter 7.7.36
3955 * 24.008 v4.2, chapter 10.5.6.12
3958 decode_gtp_tft(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3960 guint16 length, port1, port2, tos;
3961 guint8 tft_flags, tft_code, no_packet_filters, i, pf_id, pf_eval, pf_len, pf_content_id, proto, spare;
3963 guint32 mask_ipv4, addr_ipv4, ipsec_id, label;
3964 struct e_in6_addr addr_ipv6, mask_ipv6;
3965 proto_tree *ext_tree_tft, *ext_tree_tft_pf, *ext_tree_tft_flags;
3966 proto_item *te, *tee, *tef;
3968 length = tvb_get_ntohs(tvb, offset+1);
3970 te = proto_tree_add_text(tree, tvb, offset, 3+length, "Traffic flow template");
3971 ext_tree_tft = proto_item_add_subtree(te, ett_gtp_tft);
3973 tft_flags = tvb_get_guint8(tvb, offset+3);
3974 tft_code = (tft_flags >> 5) & 0x07;
3975 spare = (tft_flags >> 4) & 0x01;
3976 no_packet_filters = tft_flags & 0x0F;
3978 proto_tree_add_text(ext_tree_tft, tvb, offset+1, 2, "TFT length: %u", length);
3980 tef = proto_tree_add_text (ext_tree_tft, tvb, offset + 3, 1, "TFT flags");
3981 ext_tree_tft_flags = proto_item_add_subtree (tef, ett_gtp_tft_flags);
3982 proto_tree_add_uint (ext_tree_tft_flags, hf_gtpv1_tft_code, tvb, offset + 3, 1, tft_flags);
3983 proto_tree_add_uint (ext_tree_tft_flags, hf_gtpv1_tft_spare, tvb, offset + 3, 1, tft_flags);
3984 proto_tree_add_uint (ext_tree_tft_flags, hf_gtpv1_tft_number, tvb, offset + 3, 1, tft_flags);
3986 offset = offset + 4;
3988 for (i=0;i<no_packet_filters;i++) {
3990 pf_id = tvb_get_guint8(tvb, offset);
3992 tee = proto_tree_add_text (ext_tree_tft, tvb, offset, 1, "Packet filter id: %u", pf_id);
3993 ext_tree_tft_pf = proto_item_add_subtree (tee, ett_gtp_tft_pf);
3996 if (tft_code != 2) {
3998 pf_eval = tvb_get_guint8(tvb, offset);
3999 pf_len = tvb_get_guint8(tvb, offset + 1);
4001 proto_tree_add_uint (ext_tree_tft_pf, hf_gtpv1_tft_eval, tvb, offset, 1, pf_eval);
4002 proto_tree_add_text (ext_tree_tft_pf, tvb, offset+1, 1, "Content length: %u", pf_len);
4004 offset = offset + 2;
4007 while (pf_offset < pf_len) {
4009 pf_content_id = tvb_get_guint8 (tvb, offset + pf_offset);
4011 switch (pf_content_id) {
4012 /* address IPv4 and mask = 8 bytes*/
4014 tvb_memcpy (tvb, (guint8 *)&addr_ipv4, offset + pf_offset + 1, sizeof addr_ipv4);
4015 tvb_memcpy (tvb, (guint8 *)&mask_ipv4, offset + pf_offset + 5, sizeof mask_ipv4);
4016 proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 9, "ID 0x10: IPv4/mask: %s/%s", ip_to_str ((guint8 *)&addr_ipv4), ip_to_str ((guint8 *)&mask_ipv4));
4017 pf_offset = pf_offset + 9;
4019 /* address IPv6 and mask = 32 bytes*/
4021 tvb_memcpy (tvb, (guint8 *)&addr_ipv6, offset+pf_offset+1, sizeof addr_ipv6);
4022 tvb_memcpy (tvb, (guint8 *)&mask_ipv6, offset+pf_offset+17, sizeof mask_ipv6);
4023 proto_tree_add_text (ext_tree_tft_pf, tvb, offset+pf_offset, 33, "ID 0x20: IPv6/mask: %s/%s", ip6_to_str ((struct e_in6_addr*)&addr_ipv6), ip6_to_str ((struct e_in6_addr*)&mask_ipv6));
4024 pf_offset = pf_offset + 33;
4026 /* protocol identifier/next header type = 1 byte*/
4028 proto = tvb_get_guint8 (tvb, offset + pf_offset + 1);
4029 proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 2, "ID 0x30: IPv4 protocol identifier/IPv6 next header: %u (%x)", proto, proto);
4030 pf_offset = pf_offset + 2;
4032 /* single destination port type = 2 bytes */
4034 port1 = tvb_get_ntohs (tvb, offset + pf_offset + 1);
4035 proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 3, "ID 0x40: destination port: %u", port1);
4036 pf_offset = pf_offset + 3;
4038 /* destination port range type = 4 bytes */
4040 port1 = tvb_get_ntohs (tvb, offset + pf_offset + 1);
4041 port2 = tvb_get_ntohs (tvb, offset + pf_offset + 3);
4042 proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 5, "ID 0x41: destination port range: %u - %u", port1, port2);
4043 pf_offset = pf_offset + 5;
4045 /* single source port type = 2 bytes */
4047 port1 = tvb_get_ntohs (tvb, offset + pf_offset + 1);
4048 proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 3, "ID 0x50: source port: %u", port1);
4049 pf_offset = pf_offset + 3;
4051 /* source port range type = 4 bytes */
4053 port1 = tvb_get_ntohs (tvb, offset + pf_offset + 1);
4054 port2 = tvb_get_ntohs (tvb, offset + pf_offset + 3);
4055 proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 5, "ID 0x51: source port range: %u - %u", port1, port2);
4056 pf_offset = pf_offset + 5;
4058 /* security parameter index type = 4 bytes */
4060 ipsec_id = tvb_get_ntohl (tvb, offset + pf_offset + 1);
4061 proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 5, "ID 0x60: security parameter index: %x", ipsec_id);
4062 pf_offset = pf_offset + 5;
4064 /* type of service/traffic class type = 2 bytes */
4066 tos = tvb_get_ntohs (tvb, offset + pf_offset + 1);
4067 proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 2, "ID 0x70: Type of Service/Traffic Class: %u (%x)", tos, tos);
4068 pf_offset = pf_offset + 3;
4070 /* flow label type = 3 bytes */
4072 label = tvb_get_ntoh24(tvb, offset + pf_offset + 1) & 0x0FFFFF;;
4073 proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 4, "ID 0x80: Flow Label: %u (%x)", label, label);
4074 pf_offset = pf_offset + 4;
4078 proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 1, "Unknown value: %x ", pf_content_id);
4079 pf_offset++; /* to avoid infinite loop */
4084 offset = offset + pf_offset;
4091 /* GPRS: not present
4092 * UMTS: 29.060 v4.0, chapter 7.7.37
4093 * 25.413 v3.4, chapter ???
4096 decode_gtp_target_id(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
4100 length = tvb_get_ntohs(tvb, offset + 1);
4102 proto_tree_add_text(tree, tvb, offset, 3 + length, "Targer Identification");
4108 /* GPRS: not present
4109 * UMTS: 29.060 v4.0, chapter 7.7.38
4112 decode_gtp_utran_cont(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
4116 length = tvb_get_ntohs(tvb, offset + 1);
4118 proto_tree_add_text(tree, tvb, offset, 3 + length, "UTRAN transparent field");
4125 /* GPRS: not present
4126 * UMTS: 29.060 v4.0, chapter 7.7.39
4129 decode_gtp_rab_setup(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
4131 guint32 teid, addr_ipv4;
4134 struct e_in6_addr addr_ipv6;
4135 proto_tree *ext_tree_rab_setup;
4138 length = tvb_get_ntohs(tvb, offset + 1);
4139 nsapi = tvb_get_guint8(tvb, offset + 3) & 0x0F;
4141 te = proto_tree_add_text(tree, tvb, offset, 3+length, "Radio Access Bearer Setup Information");
4142 ext_tree_rab_setup = proto_item_add_subtree(te, ett_gtp_rab_setup);
4144 proto_tree_add_text(ext_tree_rab_setup, tvb, offset+1, 2, "RAB setup length : %u", length);
4145 proto_tree_add_uint(ext_tree_rab_setup, hf_gtpv1_nsapi, tvb, offset+3, 1, nsapi);
4149 teid = tvb_get_ntohl(tvb, offset + 4);
4151 proto_tree_add_uint(ext_tree_rab_setup, hf_gtpv1_teid_data, tvb, offset+4, 4, teid);
4155 tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+8, sizeof addr_ipv4);
4156 proto_tree_add_ipv4(ext_tree_rab_setup, hf_gtpv1_rnc_ipv4, tvb, offset+8, 4, addr_ipv4);
4159 tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+8, sizeof addr_ipv6);
4160 proto_tree_add_ipv6(ext_tree_rab_setup, hf_gtpv1_rnc_ipv6, tvb, offset+8, 16, (guint8 *)&addr_ipv6);
4171 /* GPRS: not present
4172 * UMTS: 29.060 v4.0, chapter 7.7.40
4175 decode_gtp_hdr_list(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
4179 proto_tree *ext_tree_hdr_list;
4182 length = tvb_get_guint8(tvb, offset + 1);
4184 te = proto_tree_add_text(tree, tvb, offset, 2+length, "%s", val_to_str(GTP_EXT_HDR_LIST, gtp_val, "Unknown"));
4185 ext_tree_hdr_list = proto_item_add_subtree(te, ett_gtp_hdr_list);
4187 proto_tree_add_text(ext_tree_hdr_list, tvb, offset+1, 1, "Number of Extension Header Types in list (i.e., length) : %u", length);
4189 for(i=0 ; i<length ; i++) {
4190 hdr = tvb_get_guint8(tvb, offset+2+i);
4192 proto_tree_add_text(ext_tree_hdr_list, tvb, offset+2+i, 1, "No. %u --> Extension Header Type value : %s (%u)", i+1, val_to_str(hdr, gtp_val, "Unknown Extension Header Type"), hdr);
4198 /* GPRS: not present
4199 * UMTS: 29.060 v4.0, chapter 7.7.41
4200 * TODO: find TriggerID description
4203 decode_gtp_trigger_id(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
4207 length = tvb_get_ntohs(tvb, offset + 1);
4209 proto_tree_add_text(tree, tvb, offset, 3+length, "%s length : %u", val_to_str(GTP_EXT_TRIGGER_ID, gtp_val, "Unknown"), length);
4215 /* GPRS: not present
4216 * UMTS: 29.060 v4.0, chapter 7.7.42
4217 * TODO: find OMC-ID description
4220 decode_gtp_omc_id(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
4224 length = tvb_get_ntohs(tvb, offset + 1);
4226 proto_tree_add_text(tree, tvb, offset, 3+length, "%s length : %u", val_to_str(GTP_EXT_OMC_ID, gtp_val, "Unknown"), length);
4232 /* GPRS: 9.60 v7.6.0, chapter 7.9.25
4233 * UMTS: 29.060 v4.0, chapter 7.7.43
4236 decode_gtp_chrg_addr(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
4240 struct e_in6_addr addr_ipv6;
4241 proto_tree *ext_tree_chrg_addr;
4244 length = tvb_get_ntohs(tvb, offset+1);
4246 te = proto_tree_add_text(tree, tvb, offset, 3+length, "%s : ", val_to_str(GTP_EXT_CHRG_ADDR, gtp_val, "Unknown"));
4247 ext_tree_chrg_addr = proto_item_add_subtree(te, ett_gtp_chrg_addr);
4249 proto_tree_add_text(ext_tree_chrg_addr, tvb, offset+1, 2, "%s length : %u", val_to_str(GTP_EXT_CHRG_ADDR, gtp_val, "Unknown"), length);
4253 tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+3, sizeof addr_ipv4);
4254 proto_item_append_text(te, "%s", ip_to_str((guint8 *)&addr_ipv4));
4255 proto_tree_add_ipv4(ext_tree_chrg_addr, gtp_version ? hf_gtpv1_chrg_ipv4 : hf_gtpv0_chrg_ipv4, tvb, offset+3, 4, addr_ipv4);
4258 tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+3, sizeof addr_ipv6);
4259 proto_item_append_text(te, "%s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
4260 proto_tree_add_ipv6(ext_tree_chrg_addr, gtp_version ? hf_gtpv1_chrg_ipv6 : hf_gtpv0_chrg_ipv6, tvb, offset+3, 16, (guint8*)&addr_ipv6);
4263 proto_item_append_text(te, "unknown type or wrong length");
4274 decode_gtp_rel_pack(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
4276 guint16 length, n, number;
4277 proto_tree *ext_tree_rel_pack;
4280 length = tvb_get_ntohs(tvb, offset + 1);
4282 te = proto_tree_add_text(tree, tvb, offset, 3 + length, "Sequence numbers of released packets IE");
4283 ext_tree_rel_pack = proto_item_add_subtree(te, ett_gtp_rel_pack);
4287 while (n < length) {
4289 number = tvb_get_ntohs(tvb, offset + 3 + n);
4290 proto_tree_add_text(ext_tree_rel_pack, tvb, offset + 3 + n, 2, "%u", number);
4302 decode_gtp_can_pack(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
4304 guint16 length, n, number;
4305 proto_tree *ext_tree_can_pack;
4308 length = tvb_get_ntohs(tvb, offset + 1);
4310 te = proto_tree_add_text(tree, tvb, offset, 3 + length, "Sequence numbers of cancelled packets IE");
4311 ext_tree_can_pack = proto_item_add_subtree(te, ett_gtp_can_pack);
4315 while (n < length) {
4317 number = tvb_get_ntohs(tvb, offset + 3 + n);
4318 proto_tree_add_text(ext_tree_can_pack, tvb, offset + 3 + n, 2, "%u", number);
4326 /* CDRs dissector */
4328 decode_gtp_data_req(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
4330 guint16 length, format_ver, data_len, i, j;
4331 guint8 no, format, rectype;
4332 proto_tree *ext_tree, *cdr_tree;
4333 proto_item *te, *ce;
4335 te = proto_tree_add_text(tree, tvb, offset, 1, val_to_str(GTP_EXT_DATA_REQ, gtp_val, "Unknown message"));
4336 ext_tree = proto_item_add_subtree(te, ett_gtp_ext);
4338 length = tvb_get_ntohs(tvb, offset + 1);
4339 no = tvb_get_guint8(tvb, offset + 3);
4340 format = tvb_get_guint8(tvb, offset + 4);
4341 format_ver = tvb_get_ntohs(tvb, offset + 5);
4343 proto_tree_add_text(ext_tree, tvb, offset+1, 2, "Length: %u", length);
4344 proto_tree_add_text(ext_tree, tvb, offset+3, 1, "Number of data records: %u", no);
4345 proto_tree_add_text(ext_tree, tvb, offset+4, 1, "Data record format: %u", format);
4346 proto_tree_add_text(ext_tree, tvb, offset+5, 2, "Data record format version: %u", format_ver);
4349 offset = offset + 7;
4351 if (gtpv0_cdr_as != DONT_DISSECT_CDRS) {
4353 for (i = 0; i < no; i++) {
4354 data_len = tvb_get_ntohs(tvb, offset);
4355 rectype = tvb_get_guint8(tvb, offset+2);
4357 case 0x13: /* GCDR */
4358 if (tvb_length_remaining(tvb, offset) < 3 + 118) {
4359 proto_tree_add_text(ext_tree, tvb, offset, tvb_length_remaining(tvb, offset), "GCDR fragmented, can't dissect");
4363 tvb_memcpy(tvb, gcdr.imsi, offset+3, 8);
4364 tvb_memcpy(tvb, (guint8 *)&gcdr.ggsnaddr, offset+11, sizeof gcdr.ggsnaddr);
4365 gcdr.chrgid = tvb_get_ntohl(tvb, offset+15);
4366 tvb_memcpy(tvb, (guint8 *)&gcdr.sgsnaddr, offset+19, sizeof gcdr.sgsnaddr);
4367 tvb_memcpy(tvb, gcdr.apn, offset+23, 63);
4368 gcdr.pdporg = tvb_get_guint8(tvb, offset+86);
4369 gcdr.pdptype = tvb_get_guint8(tvb, offset+87);
4370 tvb_memcpy(tvb, (guint8 *)&gcdr.pdpaddr, offset+88, sizeof gcdr.pdpaddr);
4371 gcdr.addrflag = tvb_get_guint8(tvb, offset+92);
4372 gcdr.uplink = tvb_get_ntohl(tvb, offset+96);
4373 gcdr.downlink = tvb_get_ntohl(tvb, offset+100);
4374 gcdr.timestamp = tvb_get_ntohl(tvb, offset+104);
4375 gcdr.opening = tvb_get_ntohl(tvb, offset+108);
4376 gcdr.duration = tvb_get_ntohl(tvb, offset+112);
4377 gcdr.closecause = tvb_get_guint8(tvb, offset+116);
4378 gcdr.seqno = tvb_get_ntohl(tvb, offset+117);
4380 ce = proto_tree_add_text(ext_tree, tvb, offset, data_len + 2, "GCDR (0x13), sequence number: %u", gcdr.seqno);
4381 cdr_tree = proto_item_add_subtree(ce, ett_gtp_ext);
4382 proto_tree_add_text(cdr_tree, tvb, offset, 2, "Length: %u", data_len);
4383 proto_tree_add_text(cdr_tree, tvb, offset+2, 1, "Type: %u (%x)", rectype, rectype);
4384 proto_tree_add_text(cdr_tree, tvb, offset+3, 8, "IMSI: %s", id_to_str(gcdr.imsi));
4385 proto_tree_add_text(cdr_tree, tvb, offset+11, 4, "GGSN address: %s", ip_to_str((guint8 *)&gcdr.ggsnaddr));
4386 proto_tree_add_text(cdr_tree, tvb, offset+15, 4, "Charging ID: %x", gcdr.chrgid);
4387 proto_tree_add_text(cdr_tree, tvb, offset+19, 4, "SGSN address: %s", ip_to_str((guint8 *)&gcdr.sgsnaddr));
4388 proto_tree_add_text(cdr_tree, tvb, offset+23, 63, "APN: %s", gcdr.apn);
4389 proto_tree_add_text(cdr_tree, tvb, offset+86, 1, "PDP org: %s", val_to_str(gcdr.pdporg, pdp_org_type, "Unknown PDP org"));
4390 proto_tree_add_text(cdr_tree, tvb, offset+87, 1, "PDP type: %s", val_to_str(gcdr.pdptype, pdp_type, "Unknown PDP type"));
4391 proto_tree_add_text(cdr_tree, tvb, offset+88, 4, "PDP address: %s", ip_to_str((guint8 *)&gcdr.pdpaddr));
4392 proto_tree_add_text(cdr_tree, tvb, offset+92, 1, "PDP address type: %u", gcdr.addrflag);
4393 decode_qos_gprs(tvb, offset+93, cdr_tree, "QoS", 0);
4394 proto_tree_add_text(cdr_tree, tvb, offset+96, 4, "Uplink volume: %u", gcdr.uplink);
4395 proto_tree_add_text(cdr_tree, tvb, offset+100, 4, "Downlink volume: %u", gcdr.downlink);
4396 proto_tree_add_text(cdr_tree, tvb, offset+104, 4, "Timestamp: %s", time_int_to_str(gcdr.timestamp));
4397 proto_tree_add_text(cdr_tree, tvb, offset+108, 4, "Record opening time: %s", time_int_to_str(gcdr.opening));
4398 proto_tree_add_text(cdr_tree, tvb, offset+112, 4, "Duration: %s", rel_time_int_to_str(gcdr.duration));
4399 proto_tree_add_text(cdr_tree, tvb, offset+116, 1, "Cause for close: %s (%u)", val_to_str(gcdr.closecause, cdr_close_type, "Unknown cause"), gcdr.closecause);
4400 proto_tree_add_text(cdr_tree, tvb, offset+117, 4, "Sequence number: %u", gcdr.seqno);
4402 if (data_len > 119) {
4403 tvb_memcpy (tvb, gcdr.msisdn, offset + 121, 9);
4404 proto_tree_add_text(cdr_tree, tvb, offset+121, 9, "MSISDN: %s", msisdn_to_str (gcdr.msisdn, 9));
4409 case 0x12: /* SCDR */
4410 if (tvb_length_remaining(tvb, offset) < 3 + 277) {
4411 proto_tree_add_text(ext_tree, tvb, offset, tvb_length_remaining(tvb, offset), "SCDR fragmented, can't dissect");
4415 scdr.len = tvb_get_letohs(tvb, offset+3);
4416 scdr.netini = tvb_get_guint8(tvb, offset+5);
4417 scdr.anon = tvb_get_guint8(tvb, offset+6);
4418 scdr.imsilen = tvb_get_guint8(tvb, offset+7);
4419 tvb_memcpy(tvb, scdr.imsi, offset+8, 8);
4420 tvb_memcpy(tvb, scdr.imei, offset+16, 8);
4421 scdr.msisdnlen = tvb_get_guint8(tvb, offset+24);
4422 tvb_memcpy(tvb, scdr.msisdn, offset+25, 10);
4423 tvb_memcpy(tvb, (guint8 *)&scdr.sgsnaddr, offset+35, sizeof scdr.sgsnaddr);
4424 tvb_memcpy(tvb, scdr.msclass_notused, offset+39, 12);
4425 scdr.msclass_caplen = tvb_get_guint8(tvb, offset+51);
4426 scdr.msclass_cap = tvb_get_guint8(tvb, offset+52);
4427 scdr.msclass_capomit = tvb_get_ntohs(tvb, offset+53);
4428 scdr.lac = tvb_get_ntohs(tvb, offset+55);
4429 scdr.rac = tvb_get_guint8(tvb, offset+57);
4430 scdr.cid = tvb_get_ntohs(tvb, offset+58);
4431 scdr.chrgid = tvb_get_ntohl(tvb, offset+60);
4432 tvb_memcpy(tvb, (guint8 *)&scdr.ggsnaddr, offset+64, sizeof scdr.ggsnaddr);
4433 tvb_memcpy(tvb, scdr.apn, offset+68, 64);
4434 scdr.pdporg = tvb_get_guint8(tvb, offset+132);
4435 scdr.pdptype = tvb_get_guint8(tvb, offset+133);
4436 tvb_memcpy(tvb, (guint8 *)&scdr.pdpaddr, offset+134, sizeof scdr.pdpaddr);
4437 scdr.listind = tvb_get_guint8(tvb, offset+138);
4439 scdr.change[j].change = tvb_get_guint8(tvb, offset+139+23*j);
4440 scdr.change[j].time1 = tvb_get_ntohl(tvb, offset+140+23*j);
4441 scdr.change[j].time2 = tvb_get_ntohl(tvb, offset+144+23*j);
4442 scdr.change[j].uplink = tvb_get_ntohl(tvb, offset+148+23*j);
4443 scdr.change[j].downlink = tvb_get_ntohl(tvb, offset+152+23*j);
4444 /* tvb_memcpy(tvb, scdr.change[j].qos_req, offset+156+23*j, 3);
4445 tvb_memcpy(tvb, scdr.change[j].qos_neg, offset+159+23*j, 3);*/
4447 scdr.timestamp = tvb_get_ntohl(tvb, offset+254);
4448 scdr.opening = tvb_get_ntohl(tvb, offset+258);
4449 scdr.duration = tvb_get_ntohl(tvb, offset+262);
4450 scdr.sgsnchange = tvb_get_guint8(tvb, offset+266);
4451 scdr.closecause = tvb_get_guint8(tvb, offset+267);
4452 scdr.diag1 = tvb_get_guint8(tvb, offset+268);
4453 scdr.diag2 = tvb_get_guint8(tvb, offset+269);
4454 scdr.diag3 = tvb_get_guint8(tvb, offset+270);
4455 scdr.diag4 = tvb_get_guint8(tvb, offset+271);
4456 scdr.diag5 = tvb_get_ntohl(tvb, offset+272);
4457 scdr.seqno = tvb_get_ntohl(tvb, offset+276);
4459 ce = proto_tree_add_text(ext_tree, tvb, offset, data_len + 2, "SCDR (type %x), sequence number: %u", rectype, scdr.seqno);
4460 cdr_tree = proto_item_add_subtree(ce, ett_gtp_ext);
4461 proto_tree_add_text(cdr_tree, tvb, offset, 2, "Length: %u", data_len);
4462 proto_tree_add_text(cdr_tree, tvb, offset+2, 1, "Type: %u (%x)", rectype, rectype);
4463 proto_tree_add_text(cdr_tree, tvb, offset+3, 2, "CDR length: %u", scdr.len);
4464 proto_tree_add_text(cdr_tree, tvb, offset+5, 1, "Network initiated PDP context: %s", yesno[scdr.netini]);
4465 proto_tree_add_text(cdr_tree, tvb, offset+6, 1, "Anonymous acces: %s", yesno[scdr.anon]);
4466 proto_tree_add_text(cdr_tree, tvb, offset+7, 1, "IMSI length: %u", scdr.imsilen);
4467 proto_tree_add_text(cdr_tree, tvb, offset+8, 8, "IMSI: %s", id_to_str(scdr.imsi));
4468 proto_tree_add_text(cdr_tree, tvb, offset+16, 8, "IMEI: %s", id_to_str(scdr.imei));
4469 proto_tree_add_text(cdr_tree, tvb, offset+24, 1, "MSISDN length: %u", scdr.msisdnlen);
4470 proto_tree_add_text(cdr_tree, tvb, offset+25, 10, "MSISDN: %s", msisdn_to_str(scdr.msisdn, 10));
4471 proto_tree_add_text(cdr_tree, tvb, offset+35, 4, "SGSN address: %s", ip_to_str((guint8 *)&scdr.sgsnaddr));
4472 proto_tree_add_text(cdr_tree, tvb, offset+39, 12, "(not used)");
4473 proto_tree_add_text(cdr_tree, tvb, offset+51, 1, "MS network capability length: %u", scdr.msclass_caplen);
4475 /* cap_id = proto_tree_add_text(cdr_tree, tvb, offset+52, 1, "MS network capability: %u", scdr.msclass_cap);
4476 cap_tree = proto_item_add_subtree(cap_id, ett_chrg_cap);
4477 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_gea, tvb, offset+52, 1, scdr.cap);
4478 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_sm_gsm, tvb, offset+52, 1, scdr.cap);
4479 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_sm_gprs, tvb, offset+52, 1, scdr.cap);
4480 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_ucs2, tvb, offset+52, 1, scdr.cap);
4481 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_ss, tvb, offset+52, 1, scdr.cap);
4482 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_solsa, tvb, offset+52, 1, scdr.cap);
4483 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_pad, tvb, offset+52, 1, scdr.cap);
4486 proto_tree_add_text(cdr_tree, tvb, offset+53, 2, "MS network capability omitted: %u", scdr.msclass_capomit);
4487 proto_tree_add_text(cdr_tree, tvb, offset+55, 2, "LAC: %u", scdr.lac);
4488 proto_tree_add_text(cdr_tree, tvb, offset+57, 1, "RAC: %u", scdr.rac);
4489 proto_tree_add_text(cdr_tree, tvb, offset+58, 2, "Cell ID: %u", scdr.cid);
4490 proto_tree_add_text(cdr_tree, tvb, offset+60, 4, "Charging ID: %x", scdr.chrgid);
4491 proto_tree_add_text(cdr_tree, tvb, offset+64, 4, "GGSN address: %s", ip_to_str((guint8 *)&scdr.ggsnaddr));
4492 proto_tree_add_text(cdr_tree, tvb, offset+68, 64, "APN: %s", scdr.apn);
4493 proto_tree_add_text(cdr_tree, tvb, offset+132, 1, "PDP org: %s", val_to_str(scdr.pdporg, pdp_org_type, "Unknown PDP org"));
4494 proto_tree_add_text(cdr_tree, tvb, offset+133, 1, "PDP type: %s", val_to_str(scdr.pdptype, pdp_type, "Unknown PDP type"));
4495 proto_tree_add_text(cdr_tree, tvb, offset+134, 4, "PDP address: %s", ip_to_str((guint8 *)&scdr.pdpaddr));
4496 proto_tree_add_text(cdr_tree, tvb, offset+138, 1, "List of data volume index: %u", scdr.listind);
4498 proto_tree_add_text(cdr_tree, tvb, offset+139+23*j, 1, "List of data vol change condition: %u", scdr.change[j].change);
4499 proto_tree_add_text(cdr_tree, tvb, offset+140+23*j, 4, "Time1: %x", scdr.change[j].time1);
4500 proto_tree_add_text(cdr_tree, tvb, offset+144+23*j, 4, "Time2: %x", scdr.change[j].time2);
4501 proto_tree_add_text(cdr_tree, tvb, offset+148+23*j, 4, "Uplink: %x", scdr.change[j].uplink);
4502 proto_tree_add_text(cdr_tree, tvb, offset+152+23*j, 4, "Downlink: %x", scdr.change[j].downlink);
4503 decode_qos_gprs(tvb, offset+156, cdr_tree, "QoS requested", 0);
4504 decode_qos_gprs(tvb, offset+159, cdr_tree, "QoS negotiated", 0);
4506 proto_tree_add_text(cdr_tree, tvb, offset+254, 4, "Timestamp: %s", time_int_to_str(scdr.timestamp));
4507 proto_tree_add_text(cdr_tree, tvb, offset+258, 4, "Opening: %s", time_int_to_str(scdr.opening));
4508 proto_tree_add_text(cdr_tree, tvb, offset+262, 4, "Duration: %s", rel_time_int_to_str(scdr.duration));
4509 proto_tree_add_text(cdr_tree, tvb, offset+266, 1, "SGSN change: %u", scdr.sgsnchange);
4510 proto_tree_add_text(cdr_tree, tvb, offset+267, 1, "Cause for close: %s (%u)", val_to_str(scdr.closecause, cdr_close_type, "Unknown cause"), scdr.closecause);
4511 proto_tree_add_text(cdr_tree, tvb, offset+268, 1, "Diagnostics 1: %u", scdr.diag1);
4512 proto_tree_add_text(cdr_tree, tvb, offset+269, 1, "Diagnostics 2: %u", scdr.diag2);
4513 proto_tree_add_text(cdr_tree, tvb, offset+270, 1, "Diagnostics 3: %u", scdr.diag3);
4514 proto_tree_add_text(cdr_tree, tvb, offset+271, 1, "Diagnostics 4: %u", scdr.diag4);
4515 proto_tree_add_text(cdr_tree, tvb, offset+272, 4, "Diagnostics 5: %u", scdr.diag5);
4516 proto_tree_add_text(cdr_tree, tvb, offset+276, 4, "Sequence number: %u", scdr.seqno);
4518 case 0x14: /* MCDR */
4519 if (tvb_length_remaining(tvb, offset) < 3 + 147) {
4520 proto_tree_add_text(ext_tree, tvb, offset, tvb_length_remaining(tvb, offset), "MCDR fragmented, can't dissect");
4524 mcdr.len = tvb_get_ntohs(tvb, offset+3);
4525 mcdr.imsilen = tvb_get_guint8(tvb, offset+5);
4526 tvb_memcpy(tvb, mcdr.imsi, offset+6, 8);
4527 tvb_memcpy(tvb, mcdr.imei, offset+14, 8);
4528 mcdr.msisdnlen = tvb_get_guint8(tvb, offset+22);
4529 tvb_memcpy(tvb, mcdr.msisdn, offset+23, 10);
4530 tvb_memcpy(tvb, (guint8 *)&mcdr.sgsnaddr, offset+33, sizeof mcdr.sgsnaddr);
4531 tvb_memcpy(tvb, mcdr.msclass_notused, offset+37, 12);
4532 mcdr.msclass_caplen = tvb_get_guint8(tvb, offset+49);
4533 mcdr.msclass_cap = tvb_get_guint8(tvb, offset+50);
4534 mcdr.msclass_capomit = tvb_get_ntohs(tvb, offset+51);
4535 mcdr.lac = tvb_get_ntohs(tvb, offset+53);
4536 mcdr.rac = tvb_get_guint8(tvb, offset+55);
4537 mcdr.cid = tvb_get_ntohs(tvb, offset+56);
4538 mcdr.change_count = tvb_get_guint8(tvb, offset+58);
4540 mcdr.change[j].lac = tvb_get_ntohs(tvb, offset+59+13*j);
4541 mcdr.change[j].rac = tvb_get_guint8(tvb, offset+61+13*j);
4542 mcdr.change[j].cid = tvb_get_ntohs(tvb, offset+62+13*j);
4543 tvb_memcpy(tvb, mcdr.change[j].omit, offset+64+13*j, 8);
4545 mcdr.timestamp = tvb_get_ntohl(tvb, offset+124);
4546 mcdr.opening = tvb_get_ntohl(tvb, offset+128);
4547 mcdr.duration = tvb_get_ntohl(tvb, offset+132);
4548 mcdr.sgsnchange = tvb_get_guint8(tvb, offset+136);
4549 mcdr.closecause = tvb_get_guint8(tvb, offset+137);
4550 mcdr.diag1 = tvb_get_guint8(tvb, offset+138);
4551 mcdr.diag2 = tvb_get_guint8(tvb, offset+139);
4552 mcdr.diag3 = tvb_get_guint8(tvb, offset+140);
4553 mcdr.diag4 = tvb_get_guint8(tvb, offset+141);
4554 mcdr.diag5 = tvb_get_ntohl(tvb, offset+142);
4555 mcdr.seqno = tvb_get_ntohl(tvb, offset+146);
4557 ce = proto_tree_add_text(ext_tree, tvb, offset, data_len + 2, "MCDR (0x14), sequence number: %u", mcdr.seqno);
4558 cdr_tree = proto_item_add_subtree(ce, ett_gtp_ext);
4559 proto_tree_add_text(cdr_tree, tvb, offset, 2, "Length: %u", data_len);
4560 proto_tree_add_text(cdr_tree, tvb, offset+2, 1, "Type: %u (%x)", rectype, rectype);
4561 proto_tree_add_text(cdr_tree, tvb, offset+3, 2, "MCDR length: %u", mcdr.len);
4562 proto_tree_add_text(cdr_tree, tvb, offset+5, 1, "IMSI length: %u", mcdr.imsilen);
4563 proto_tree_add_text(cdr_tree, tvb, offset+6, 8, "IMSI: %s", id_to_str(mcdr.imsi));
4564 proto_tree_add_text(cdr_tree, tvb, offset+14, 8, "IMEI: %s", id_to_str(mcdr.imei));
4565 proto_tree_add_text(cdr_tree, tvb, offset+22, 1, "MSISDN length: %u", mcdr.msisdnlen);
4566 proto_tree_add_text(cdr_tree, tvb, offset+23, 10, "MSISDN: %s", msisdn_to_str(mcdr.msisdn, 10));
4567 proto_tree_add_text(cdr_tree, tvb, offset+33, 4, "SGSN address: %s", ip_to_str((guint8 *)&mcdr.sgsnaddr));
4568 proto_tree_add_text(cdr_tree, tvb, offset+37, 12, "(not used)");
4569 proto_tree_add_text(cdr_tree, tvb, offset+49, 1, "MS network capability length: %u", mcdr.msclass_caplen);
4571 /* cap_id = proto_tree_add_text(cdr_tree, tvb, offset+50, 1, "MS network capability: %u", mcdr.msclass_cap);
4572 cap_tree = proto_item_add_subtree(cap_id, ett_chrg_cap);
4573 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_gea, tvb, offset+50, 1, mcdr.cap);
4574 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_sm_gsm, tvb, offset+50, 1, mcdr.cap);
4575 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_sm_gprs, tvb, offset+50, 1, mcdr.cap);
4576 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_ucs2, tvb, offset+50, 1, mcdr.cap);
4577 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_ss, tvb, offset+50, 1, mcdr.cap);
4578 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_solsa, tvb, offset+50, 1, mcdr.cap);
4579 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_pad, tvb, offset+50, 1, mcdr.cap);
4581 proto_tree_add_text(cdr_tree, tvb, offset+51, 2, "MS network capability omitted: %u", mcdr.msclass_capomit);
4582 proto_tree_add_text(cdr_tree, tvb, offset+53, 2, "LAC: %u", mcdr.lac);
4583 proto_tree_add_text(cdr_tree, tvb, offset+55, 1, "RAC: %u", mcdr.rac);
4584 proto_tree_add_text(cdr_tree, tvb, offset+56, 2, "Cell ID: %u", mcdr.cid);
4585 proto_tree_add_text(cdr_tree, tvb, offset+58, 1, "List of data volume changes: %u", mcdr.change_count);
4587 proto_tree_add_text(cdr_tree, tvb, offset+59+13*j, 2, "LAC: %u", mcdr.change[j].lac);
4588 proto_tree_add_text(cdr_tree, tvb, offset+61+13*j, 1, "RAC: %u", mcdr.change[j].rac);
4589 proto_tree_add_text(cdr_tree, tvb, offset+62+13*j, 2, "CID: %u", mcdr.change[j].cid);
4590 proto_tree_add_text(cdr_tree, tvb, offset+64+13*j, 8, "(omitted)");
4593 proto_tree_add_text(cdr_tree, tvb, offset+124, 4, "Timestamp: %s", time_int_to_str(mcdr.timestamp));
4594 proto_tree_add_text(cdr_tree, tvb, offset+128, 4, "Record opening time: %s", time_int_to_str(mcdr.opening));
4595 proto_tree_add_text(cdr_tree, tvb, offset+132, 4, "Duration: %s", rel_time_int_to_str(mcdr.duration));
4596 proto_tree_add_text(cdr_tree, tvb, offset+136, 1, "SGSN change: %u", mcdr.sgsnchange);
4597 proto_tree_add_text(cdr_tree, tvb, offset+137, 1, "Cause for close: %s (%u)", val_to_str(mcdr.closecause, cdr_close_type, "Unknown cause"), mcdr.closecause);
4598 proto_tree_add_text(cdr_tree, tvb, offset+138, 1, "Diagnostics 1: %u", mcdr.diag1);
4599 proto_tree_add_text(cdr_tree, tvb, offset+139, 1, "Diagnostics 2: %u", mcdr.diag2);
4600 proto_tree_add_text(cdr_tree, tvb, offset+140, 1, "Diagnostics 3: %u", mcdr.diag3);
4601 proto_tree_add_text(cdr_tree, tvb, offset+141, 1, "Diagnostics 4: %u", mcdr.diag4);
4602 proto_tree_add_text(cdr_tree, tvb, offset+142, 4, "Diagnostics 5: %u", mcdr.diag5);
4603 proto_tree_add_text(cdr_tree, tvb, offset+146, 4, "Sequence number: %u", mcdr.seqno);
4606 case 0x15: /* SOCDR */
4607 if (tvb_length_remaining(tvb, offset) < 3 + 80) {
4608 proto_tree_add_text(ext_tree, tvb, offset, tvb_length_remaining(tvb, offset), "SOCDR fragmented, can't dissect");
4612 socdr.len = tvb_get_ntohs(tvb, offset+3);
4613 socdr.imsilen = tvb_get_guint8(tvb, offset+5);
4614 tvb_memcpy(tvb, socdr.imsi, offset+6, 8);
4615 tvb_memcpy(tvb, socdr.imei, offset+14, 8);
4616 socdr.msisdnlen = tvb_get_guint8(tvb, offset+22);
4617 tvb_memcpy(tvb, socdr.msisdn, offset+23, 10);
4618 tvb_memcpy(tvb, socdr.msclass_notused, offset+33, 12);
4619 socdr.msclass_caplen = tvb_get_guint8(tvb, offset+45);
4620 socdr.msclass_cap = tvb_get_guint8(tvb, offset+46);
4621 socdr.msclass_capomit = tvb_get_ntohs(tvb, offset+47);
4622 tvb_memcpy(tvb, socdr.serv_centr, offset+49, 9);
4623 tvb_memcpy(tvb, socdr.rec_ent, offset+58, 9);
4624 socdr.lac = tvb_get_ntohs(tvb, offset+67);
4625 socdr.rac = tvb_get_guint8(tvb, offset+69);
4626 socdr.cid = tvb_get_ntohs(tvb, offset+70);
4627 socdr.time1 = tvb_get_ntohl(tvb, offset+72);
4628 socdr.time2 = tvb_get_ntohl(tvb, offset+76);
4629 socdr.messref = tvb_get_guint8(tvb, offset+80);
4630 socdr.smsres = tvb_get_ntohs(tvb, offset+81);
4632 ce = proto_tree_add_text(ext_tree, tvb, offset, data_len + 2, "SOCDR (0x15)");
4633 cdr_tree = proto_item_add_subtree(ce, ett_gtp_ext);
4634 proto_tree_add_text(cdr_tree, tvb, offset, 2, "Length: %u", data_len);
4635 proto_tree_add_text(cdr_tree, tvb, offset+2, 1, "Type: %u (%x)", rectype, rectype);
4636 proto_tree_add_text(cdr_tree, tvb, offset+3, 2, "MCDR length: %u", socdr.len);
4637 proto_tree_add_text(cdr_tree, tvb, offset+5, 1, "IMSI length: %u", socdr.imsilen);
4638 proto_tree_add_text(cdr_tree, tvb, offset+6, 8, "IMSI: %s", id_to_str(socdr.imsi));
4639 proto_tree_add_text(cdr_tree, tvb, offset+14, 8, "IMEI: %s", id_to_str(socdr.imei));
4640 proto_tree_add_text(cdr_tree, tvb, offset+22, 1, "MSISDN length: %u", socdr.msisdnlen);
4641 proto_tree_add_text(cdr_tree, tvb, offset+23, 10, "MSISDN: %s", msisdn_to_str(socdr.msisdn, 10));
4642 proto_tree_add_text(cdr_tree, tvb, offset+33, 12, "(not used)");
4643 proto_tree_add_text(cdr_tree, tvb, offset+45, 1, "MS network capability length: %u", socdr.msclass_caplen);
4645 /* cap_id = proto_tree_add_text(cdr_tree, tvb, offset+46, 1, "MS network capability: %u", socdr.msclass_cap);
4646 cap_tree = proto_item_add_subtree(cap_id, ett_chrg_cap);
4647 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_gea, tvb, offset+46, 1, socdr.cap);
4648 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_sm_gsm, tvb, offset+46, 1, socdr.cap);
4649 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_sm_gprs, tvb, offset+46, 1, socdr.cap);
4650 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_ucs2, tvb, offset+46, 1, socdr.cap);
4651 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_ss, tvb, offset+46, 1, socdr.cap);
4652 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_solsa, tvb, offset+46, 1, socdr.cap);
4654 proto_tree_add_text(cdr_tree, tvb, offset+47, 2, "MS network capability omitted: %u", stcdr.msclass_capomit);
4655 proto_tree_add_text(cdr_tree, tvb, offset+49, 9, "SMSC E.164 address: %s", msisdn_to_str(socdr.serv_centr, 9));
4656 proto_tree_add_text(cdr_tree, tvb, offset+58, 9, "SGSN E.164 address: %s", msisdn_to_str(socdr.rec_ent, 9));
4657 proto_tree_add_text(cdr_tree, tvb, offset+67, 2, "LAC: %u", socdr.lac);
4658 proto_tree_add_text(cdr_tree, tvb, offset+69, 1, "RAC: %u", socdr.rac);
4659 proto_tree_add_text(cdr_tree, tvb, offset+70, 2, "Cell ID: %u", socdr.cid);
4660 proto_tree_add_text(cdr_tree, tvb, offset+72, 4, "Time1: %s", time_int_to_str(socdr.time1));
4661 proto_tree_add_text(cdr_tree, tvb, offset+76, 4, "Time2: %s", time_int_to_str(socdr.time2));
4662 proto_tree_add_text(cdr_tree, tvb, offset+80, 1, "Message reference: %u", socdr.messref);
4663 proto_tree_add_text(cdr_tree, tvb, offset+81, 2, "Delivery result: %u", socdr.smsres);
4666 case 0x16: /* STCDR */
4667 if (tvb_length_remaining(tvb, offset) < 3 + 79) {
4668 proto_tree_add_text(ext_tree, tvb, offset, tvb_length_remaining(tvb, offset), "STCDR fragmented, can't dissect");
4672 stcdr.len = tvb_get_ntohs(tvb, offset+3);
4673 stcdr.imsilen = tvb_get_guint8(tvb, offset+5);
4674 tvb_memcpy(tvb, stcdr.imsi, offset+6, 8);
4675 tvb_memcpy(tvb, stcdr.imei, offset+14, 8);
4676 stcdr.msisdnlen = tvb_get_guint8(tvb, offset+22);
4677 tvb_memcpy(tvb, stcdr.msisdn, offset+23, 10);
4678 tvb_memcpy(tvb, stcdr.msclass_notused, offset+33, 12);
4679 stcdr.msclass_caplen = tvb_get_guint8(tvb, offset+45);
4680 stcdr.msclass_cap = tvb_get_guint8(tvb, offset+46);
4681 stcdr.msclass_capomit = tvb_get_ntohs(tvb, offset+47);
4682 tvb_memcpy(tvb, stcdr.serv_centr, offset+49, 9);
4683 tvb_memcpy(tvb, stcdr.rec_ent, offset+58, 9);
4684 stcdr.lac = tvb_get_ntohs(tvb, offset+67);
4685 stcdr.rac = tvb_get_guint8(tvb, offset+69);
4686 stcdr.cid = tvb_get_ntohs(tvb, offset+70);
4687 stcdr.time1 = tvb_get_ntohl(tvb, offset+72);
4688 stcdr.time2 = tvb_get_ntohl(tvb, offset+76);
4689 stcdr.smsres = tvb_get_ntohs(tvb, offset+80);
4691 ce = proto_tree_add_text(ext_tree, tvb, offset, data_len + 2, "STCDR (0x16)");
4692 cdr_tree = proto_item_add_subtree(ce, ett_gtp_ext);
4693 proto_tree_add_text(cdr_tree, tvb, offset, 2, "Length: %u", data_len);
4694 proto_tree_add_text(cdr_tree, tvb, offset+2, 1, "Type: %u (%x)", rectype, rectype);
4695 proto_tree_add_text(cdr_tree, tvb, offset+3, 2, "MCDR length: %u", stcdr.len);
4696 proto_tree_add_text(cdr_tree, tvb, offset+5, 1, "IMSI length: %u", stcdr.imsilen);
4697 proto_tree_add_text(cdr_tree, tvb, offset+6, 8, "IMSI: %s", id_to_str(stcdr.imsi));
4698 proto_tree_add_text(cdr_tree, tvb, offset+14, 8, "IMEI: %s", id_to_str(stcdr.imei));
4699 proto_tree_add_text(cdr_tree, tvb, offset+22, 1, "MSISDN length: %u", stcdr.msisdnlen);
4700 proto_tree_add_text(cdr_tree, tvb, offset+23, 10, "MSISDN: %s", msisdn_to_str(stcdr.msisdn, 10));
4701 proto_tree_add_text(cdr_tree, tvb, offset+33, 12, "(not used)");
4702 proto_tree_add_text(cdr_tree, tvb, offset+45, 1, "MS network capability length: %u", stcdr.msclass_caplen);
4704 /* cap_id = proto_tree_add_text(cdr_tree, tvb, offset+46, 1, "MS network capability: %u", stcdr.msclass_cap);
4705 cap_tree = proto_item_add_subtree(cap_id, ett_chrg_cap);
4706 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_gea, tvb, offset+46, 1, stcdr.cap);
4707 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_sm_gsm, tvb, offset+46, 1, stcdr.cap);
4708 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_sm_gprs, tvb, offset+46, 1, stcdr.cap);
4709 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_ucs2, tvb, offset+46, 1, stcdr.cap);
4710 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_ss, tvb, offset+46, 1, stcdr.cap);
4711 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_solsa, tvb, offset+46, 1, stcdr.cap);
4713 proto_tree_add_text(cdr_tree, tvb, offset+47, 2, "MS network capability omitted: %u", stcdr.msclass_capomit);
4714 proto_tree_add_text(cdr_tree, tvb, offset+49, 9, "SMSC E.164 address: %s", msisdn_to_str(stcdr.serv_centr, 9));
4715 proto_tree_add_text(cdr_tree, tvb, offset+58, 9, "SGSN E.164 address: %s", msisdn_to_str(stcdr.rec_ent, 9));
4716 proto_tree_add_text(cdr_tree, tvb, offset+67, 2, "LAC: %u", stcdr.lac);
4717 proto_tree_add_text(cdr_tree, tvb, offset+69, 1, "RAC: %u", stcdr.rac);
4718 proto_tree_add_text(cdr_tree, tvb, offset+70, 2, "Cell ID: %u", stcdr.cid);
4719 proto_tree_add_text(cdr_tree, tvb, offset+72, 4, "Time1: %s", time_int_to_str(stcdr.time1));
4720 proto_tree_add_text(cdr_tree, tvb, offset+76, 4, "Time2: %s", time_int_to_str(stcdr.time2));
4721 proto_tree_add_text(cdr_tree, tvb, offset+80, 2, "Delivery result: %u", stcdr.smsres);
4724 offset = offset + 2 + data_len;
4734 decode_gtp_data_resp(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
4736 guint16 length, n, number;
4737 proto_tree *ext_tree_data_resp;
4740 length = tvb_get_ntohs(tvb, offset + 1);
4742 te = proto_tree_add_text(tree, tvb, offset, 3 + length, "Requests responded");
4743 ext_tree_data_resp = proto_item_add_subtree(te, ett_gtp_data_resp);
4747 while (n < length) {
4749 number = tvb_get_ntohs(tvb, offset + 3 + n);
4750 proto_tree_add_text(ext_tree_data_resp, tvb, offset + 3 + n, 2, "%u", number);
4763 decode_gtp_node_addr(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
4767 struct e_in6_addr addr_ipv6;
4768 proto_tree *ext_tree_node_addr;
4771 length = tvb_get_ntohs(tvb, offset+1);
4773 te = proto_tree_add_text(tree, tvb, offset, 3+length, "Node address: ");
4774 ext_tree_node_addr = proto_item_add_subtree(te, ett_gtp_node_addr);
4776 proto_tree_add_text(ext_tree_node_addr, tvb, offset+1, 2, "Node address length: %u", length);
4780 tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+3, sizeof addr_ipv4);
4781 proto_item_append_text(te, "%s", ip_to_str((guint8 *)&addr_ipv4));
4782 proto_tree_add_ipv4(ext_tree_node_addr, gtp_version ? hf_gtpv1_node_ipv4 : hf_gtpv0_node_ipv4, tvb, offset+3, 4, addr_ipv4);
4785 tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+3, sizeof addr_ipv6);
4786 proto_item_append_text(te, "%s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
4787 proto_tree_add_ipv6(ext_tree_node_addr, gtp_version ? hf_gtpv1_node_ipv6 : hf_gtpv0_node_ipv6, tvb, offset+3, 16, (guint8*)&addr_ipv6);
4790 proto_item_append_text(te, "unknown type or wrong length");
4798 /* GPRS: 9.60 v7.6.0, chapter 7.9.26
4799 * UMTS: 29.060 v4.0, chapter 7.7.44
4802 decode_gtp_priv_ext(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
4804 guint16 length, ext_id;
4806 proto_tree *ext_tree_priv_ext;
4809 te = proto_tree_add_text(tree, tvb, offset, 1, val_to_str(GTP_EXT_PRIV_EXT, gtp_val, "Unknown message"));
4810 ext_tree_priv_ext = proto_item_add_subtree(te, ett_gtp_ext);
4812 length = tvb_get_ntohs(tvb, offset+1);
4813 if (length < 1) return 3+length;
4815 ext_id = tvb_get_ntohs(tvb, offset+3);
4816 tvb_memcpy(tvb, ext_val, offset+5, length > 65 ? 63 : length-2);
4817 ext_val[length > 65 ? 64 : length-1] = '\0';
4818 proto_tree_add_uint(ext_tree_priv_ext, gtp_version ? hf_gtpv1_ext_id : hf_gtpv0_ext_id, tvb, offset+3, 2, ext_id);
4819 proto_tree_add_string(ext_tree_priv_ext, gtp_version ? hf_gtpv1_ext_val : hf_gtpv0_ext_val, tvb, offset+5, length-2, ext_val);
4825 decode_gtp_unknown(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
4827 proto_tree_add_text(tree, tvb, offset, 1, "Unknown extension header");
4829 return tvb_length_remaining(tvb, offset);
4833 dissect_gtpv0(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
4836 _gtpv0_hdr gtpv0_hdr;
4837 proto_item *ti, *tf;
4838 proto_tree *gtpv0_tree, *flags_tree;
4841 const guint8 *tid_val;
4843 int offset, length, i, mandatory, checked_field, gtp_prime = 0;
4845 if (check_col(pinfo->cinfo, COL_PROTOCOL))
4846 col_set_str(pinfo->cinfo, COL_PROTOCOL, "GTP");
4847 if (check_col(pinfo->cinfo, COL_INFO))
4848 col_clear(pinfo->cinfo, COL_INFO);
4850 tvb_memcpy(tvb, (guint8 *)>pv0_hdr, 0, 12);
4851 tid_val = tvb_get_ptr(tvb, 12, 8);
4852 tid_str = id_to_str(tid_val);
4853 gtp_version = (gtpv0_hdr.flags >> 5) & 0x07;
4855 if (!((gtpv0_hdr.flags >> 4) & 1)) {
4857 if (check_col(pinfo->cinfo, COL_PROTOCOL))
4858 col_set_str(pinfo->cinfo, COL_PROTOCOL, "GTP-CDR");
4860 switch ((gtpv0_hdr.flags >> 5) & 0x07) {
4861 case 0: if (check_col(pinfo->cinfo, COL_PROTOCOL))
4862 col_set_str(pinfo->cinfo, COL_PROTOCOL, "GTP");
4864 case 1: if (check_col(pinfo->cinfo, COL_PROTOCOL))
4865 col_set_str(pinfo->cinfo, COL_PROTOCOL, "GTPv1");
4866 default: if (check_col(pinfo->cinfo, COL_PROTOCOL))
4867 col_set_str(pinfo->cinfo, COL_PROTOCOL, "GTPv?");
4872 if (check_col(pinfo->cinfo, COL_INFO))
4873 col_add_str(pinfo->cinfo, COL_INFO, val_to_str(gtpv0_hdr.message, message_type, "Unknown"));
4877 /* dissect GTP header */
4878 ti = proto_tree_add_item(tree, proto_gtpv0, tvb, 0, -1, FALSE);
4879 gtpv0_tree = proto_item_add_subtree(ti, ett_gtp);
4881 tf = proto_tree_add_uint(gtpv0_tree, hf_gtpv0_flags, tvb, 0, 1, gtpv0_hdr.flags);
4883 flags_tree = proto_item_add_subtree(tf, ett_gtp_flags);
4884 proto_tree_add_uint(flags_tree, hf_gtpv0_flags_ver, tvb, 0, 1, gtpv0_hdr.flags);
4885 proto_tree_add_uint(flags_tree, hf_gtpv0_flags_pt, tvb, 0, 1, gtpv0_hdr.flags);
4886 proto_tree_add_uint(flags_tree, hf_gtpv0_flags_spare, tvb, 0, 1, gtpv0_hdr.flags);
4887 proto_tree_add_boolean(flags_tree, hf_gtpv0_flags_snn, tvb, 0, 1, gtpv0_hdr.flags);
4889 gtpv0_hdr.length = g_ntohs(gtpv0_hdr.length);
4890 gtpv0_hdr.seq_no = g_ntohs(gtpv0_hdr.seq_no);
4891 gtpv0_hdr.flow_label = g_ntohs(gtpv0_hdr.flow_label);
4892 proto_tree_add_uint(gtpv0_tree, hf_gtpv0_message_type, tvb, 1, 1, gtpv0_hdr.message);
4893 proto_tree_add_uint(gtpv0_tree, hf_gtpv0_length, tvb, 2, 2, gtpv0_hdr.length);
4894 proto_tree_add_uint(gtpv0_tree, hf_gtpv0_seq_number, tvb, 4, 2, gtpv0_hdr.seq_no);
4896 /* GTP' has 6 bytes of length */
4898 proto_tree_add_uint(gtpv0_tree, hf_gtpv0_flow_label, tvb, 6, 2, gtpv0_hdr.flow_label);
4899 proto_tree_add_uint(gtpv0_tree, hf_gtpv0_sndcp_number, tvb, 8, 1, gtpv0_hdr.sndcp_no);
4900 proto_tree_add_string(gtpv0_tree, hf_gtpv0_tid, tvb, 12, 8, tid_str);
4903 if (gtpv0_hdr.message != GTP_MSG_TPDU) {
4905 proto_tree_add_text(gtpv0_tree, tvb, 0, 0, "[--- end of GTPv0 header, beginning of extension headers ---]");
4907 offset = gtp_prime ? GTP_PRIME_HDR_LENGTH : GTPv0_HDR_LENGTH;
4909 length = tvb_length(tvb);
4911 mandatory = 0; /* check order of GTP fields against ETSI */
4915 if (offset >= length) break;
4916 ext_hdr_val = tvb_get_guint8(tvb, offset);
4918 if (gtpv0_etsi_order) {
4919 checked_field = check_field_presence (gtpv0_hdr.message, ext_hdr_val , (int *)&mandatory);
4920 switch (checked_field) {
4921 case -2: proto_tree_add_text(gtpv0_tree, tvb, 0, 0, "[WARNING] message not found");
4923 case -1: proto_tree_add_text(gtpv0_tree, tvb, 0, 0, "[WARNING] field not present");
4926 default: proto_tree_add_text(gtpv0_tree, tvb, offset, 1, "[WARNING] wrong next field, should be: %s", val_to_str(checked_field, gtp_val, "Unknown extension field"));
4931 while (gtpopt[++i].optcode) if (gtpopt[i].optcode == ext_hdr_val) break;
4932 offset = offset + (*gtpopt[i].decode)(tvb, offset, pinfo, gtpv0_tree);
4937 /* next part dissects sublayers of GTP */
4939 if ((gtpv0_hdr.message == GTP_MSG_TPDU) && gtp_tpdu) {
4942 sub_proto = tvb_get_guint8(tvb,GTPv0_HDR_LENGTH);
4944 if ((sub_proto >= 0x45) && (sub_proto <= 0x4e)) {
4945 /* this is most likely an IPv4 packet */
4946 /* we can exclude 0x40 - 0x44 because the minimum header size is 20 octets */
4947 /* 0x4f is excluded because PPP protocol type "IPv6 header compression"
4948 with protocol field compression is more likely than a plain IPv4 packet with 60 octet header size */
4950 next_tvb = tvb_new_subset(tvb, GTPv0_HDR_LENGTH, -1, -1);
4951 call_dissector(ip_handle, next_tvb, pinfo, tree);
4953 if ((sub_proto & 0xf0) == 0x60) {
4954 /* this is most likely an IPv6 packet */
4955 next_tvb = tvb_new_subset(tvb, GTPv0_HDR_LENGTH, -1, -1);
4956 call_dissector(ipv6_handle, next_tvb, pinfo, tree);
4958 /* this seems to be a PPP packet */
4959 guint8 acfield_len = 0;
4961 if (sub_proto == 0xff) {
4962 /* this might be an address field, even it shouldn't be here */
4963 guint8 control_field = tvb_get_guint8(tvb,GTPv0_HDR_LENGTH + 1);
4964 if (control_field == 0x03) {
4965 /* now we are pretty sure that address and control field are mistakenly inserted -> ignore it for PPP dissection */
4969 next_tvb = tvb_new_subset(tvb, GTPv0_HDR_LENGTH + acfield_len, -1, -1);
4970 call_dissector(ppp_handle, next_tvb, pinfo, tree);
4972 if (check_col(pinfo->cinfo, COL_PROTOCOL))
4973 col_append_str_gtp(pinfo->cinfo, COL_PROTOCOL, "GTP");
4977 /* GTP v1 dissector */
4979 dissect_gtpv1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
4981 _gtpv1_hdr gtpv1_hdr;
4982 proto_item *ti, *tf;
4983 proto_tree *gtpv1_tree, *flags_tree;
4985 guint8 ext_hdr_val, i, hdr_offset = 4, next_hdr, npdu_no, sub_proto;
4987 int offset, length, mandatory, checked_field, gtp_prime = 0;
4989 if (check_col(pinfo->cinfo, COL_PROTOCOL))
4990 col_set_str(pinfo->cinfo, COL_PROTOCOL, "GTP-C");
4991 if (check_col(pinfo->cinfo, COL_INFO))
4992 col_clear(pinfo->cinfo, COL_INFO);
4994 tvb_memcpy(tvb, (guint8 *)>pv1_hdr, 0, 8);
4995 gtp_version = (gtpv1_hdr.flags >> 5) & 0x07;
4997 if (check_col(pinfo->cinfo, COL_INFO))
4998 col_add_str(pinfo->cinfo, COL_INFO, val_to_str(gtpv1_hdr.message, message_type, "Unknown"));
5002 ti = proto_tree_add_item(tree, proto_gtpv1, tvb, 0, -1, FALSE);
5003 gtpv1_tree = proto_item_add_subtree(ti, ett_gtp);
5005 tf = proto_tree_add_uint(gtpv1_tree, hf_gtpv1_flags, tvb, 0, 1, gtpv1_hdr.flags);
5006 flags_tree = proto_item_add_subtree(tf, ett_gtp_flags);
5008 proto_tree_add_uint(flags_tree, hf_gtpv1_flags_ver, tvb, 0, 1, gtpv1_hdr.flags);
5009 proto_tree_add_uint(flags_tree, hf_gtpv1_flags_pt, tvb, 0, 1, gtpv1_hdr.flags);
5010 proto_tree_add_uint(flags_tree, hf_gtpv1_flags_spare, tvb, 0, 1, gtpv1_hdr.flags);
5011 proto_tree_add_boolean(flags_tree, hf_gtpv1_flags_e, tvb, 0, 1, gtpv1_hdr.flags);
5012 proto_tree_add_boolean(flags_tree, hf_gtpv1_flags_s, tvb, 0, 1, gtpv1_hdr.flags);
5013 proto_tree_add_boolean(flags_tree, hf_gtpv1_flags_pn, tvb, 0, 1, gtpv1_hdr.flags);
5015 proto_tree_add_uint(gtpv1_tree, hf_gtpv1_message_type, tvb, 1, 1, gtpv1_hdr.message);
5017 gtpv1_hdr.length = g_ntohs(gtpv1_hdr.length);
5018 proto_tree_add_uint(gtpv1_tree, hf_gtpv1_length, tvb, 2, 2, gtpv1_hdr.length);
5020 gtp_prime = (gtpv1_hdr.flags & 0x01) >> 4;
5022 /* GTP' has 6 bytes of length */
5026 gtpv1_hdr.teid = g_ntohl(gtpv1_hdr.teid);
5027 proto_tree_add_uint(gtpv1_tree, hf_gtpv1_teid, tvb, 4, 4, gtpv1_hdr.teid);
5029 if (gtpv1_hdr.flags & 0x07) {
5030 seq_no = tvb_get_ntohs (tvb, 8);
5031 proto_tree_add_uint (gtpv1_tree, hf_gtpv1_seq_number, tvb, 8, 2, seq_no);
5032 npdu_no = tvb_get_guint8 (tvb, 10);
5033 proto_tree_add_uint (gtpv1_tree, hf_gtpv1_npdu_number, tvb, 10, 1, npdu_no);
5034 next_hdr = tvb_get_guint8(tvb, 11);
5035 proto_tree_add_uint(gtpv1_tree, hf_gtpv1_next, tvb, 11, 1, next_hdr);
5038 if (next_hdr) hdr_offset = 1;
5039 else hdr_offset = 0;
5043 if (gtpv1_hdr.message != GTP_MSG_TPDU) {
5045 proto_tree_add_text(gtpv1_tree, tvb, 0, 0, "[--- end of GTP v1 header, beginning of extension headers ---]");
5047 offset = gtp_prime ? GTP_PRIME_HDR_LENGTH: GTPv1_HDR_LENGTH - hdr_offset;
5048 length = tvb_length(tvb);
5050 mandatory = 0; /* check order of GTP fields against ETSI */
5054 if (offset >= length) break;
5055 ext_hdr_val = tvb_get_guint8(tvb, offset);
5057 if (gtpv1_etsi_order) {
5058 checked_field = check_field_presence (gtpv1_hdr.message, ext_hdr_val , (int *)&mandatory);
5059 switch (checked_field) {
5060 case -2: proto_tree_add_text(gtpv1_tree, tvb, 0, 0, "[WARNING] message not found");
5062 case -1: proto_tree_add_text(gtpv1_tree, tvb, 0, 0, "[WARNING] field not present");
5065 default: proto_tree_add_text(gtpv1_tree, tvb, offset, 1, "[WARNING] wrong next field, should be: %s", val_to_str(checked_field, gtp_val, "Unknown extension field"));
5070 while (gtpopt[++i].optcode) if (gtpopt[i].optcode == ext_hdr_val) break;
5071 offset = offset + (*gtpopt[i].decode)(tvb, offset, pinfo, gtpv1_tree);
5076 if (gtpv1_hdr.message == GTP_MSG_ERR_IND)
5077 if (check_col(pinfo->cinfo, COL_PROTOCOL))
5078 col_add_str(pinfo->cinfo, COL_PROTOCOL, "GTP-U");
5081 if ((gtpv1_hdr.message == GTP_MSG_TPDU) && gtp_tpdu) {
5083 if (gtpv1_hdr.flags & 0x07) {
5084 if (tvb_get_guint8 (tvb, 11))
5085 hdr_offset = 1; /* if next_hdr != 0 */
5090 sub_proto = tvb_get_guint8(tvb,GTPv1_HDR_LENGTH - hdr_offset);
5092 if ((sub_proto >= 0x45) && (sub_proto <= 0x4e)) {
5093 /* this is most likely an IPv4 packet */
5094 /* we can exclude 0x40 - 0x44 because the minimum header size is 20 octets */
5095 /* 0x4f is excluded because PPP protocol type "IPv6 header compression"
5096 with protocol field compression is more likely than a plain IPv4 packet with 60 octet header size */
5098 next_tvb = tvb_new_subset(tvb, GTPv1_HDR_LENGTH - hdr_offset, -1, -1);
5099 call_dissector(ip_handle, next_tvb, pinfo, tree);
5101 if ((sub_proto & 0xf0) == 0x60)
5103 /* this is most likely an IPv6 packet */
5104 next_tvb = tvb_new_subset(tvb, GTPv1_HDR_LENGTH - hdr_offset, -1, -1);
5105 call_dissector(ipv6_handle, next_tvb, pinfo, tree);
5107 /* this seems to be a PPP packet */
5108 guint8 acfield_len = 0;
5110 if (sub_proto == 0xff) {
5111 /* this might be an address field, even it shouldn't be here */
5112 guint8 control_field;
5113 control_field = tvb_get_guint8(tvb,GTPv1_HDR_LENGTH - hdr_offset + 1);
5114 if (control_field == 0x03)
5116 /* now we are pretty sure that address and control field are mistakenly inserted -> ignore it for PPP dissection */
5120 next_tvb = tvb_new_subset(tvb, GTPv1_HDR_LENGTH - hdr_offset + acfield_len, -1, -1);
5121 call_dissector(ppp_handle, next_tvb, pinfo, tree);
5123 if (check_col(pinfo->cinfo, COL_PROTOCOL))
5124 col_append_str_gtp(pinfo->cinfo, COL_PROTOCOL, "GTP-U");
5128 static const true_false_string yes_no_tfs = {
5134 proto_register_gtp(void)
5137 static hf_register_info hf_gtpv0[] = {
5139 { &hf_gtpv0_flags, { "Flags", "gtpv0.flags", FT_UINT8, BASE_HEX, NULL, 0, "Ver/PT/Spare/SNN", HFILL }},
5140 { &hf_gtpv0_flags_ver, { "Version", "gtpv0.flags.version", FT_UINT8, BASE_DEC, VALS(ver_types), GTP_VER_MASK, "GTP Version", HFILL }},
5141 { &hf_gtpv0_flags_pt, { "Protocol type", "gtpv0.flags.payload", FT_UINT8, BASE_DEC, NULL, GTP_PT_MASK, "Protocol Type (1 = GTP, 0 = GTP' )", HFILL }},
5142 { &hf_gtpv0_flags_spare, { "Reserved", "gtpv0.flags.reserved", FT_UINT8, BASE_DEC, NULL, GTP_SPARE_MASK, "Reserved (shall be sent as '111' )", HFILL }},
5143 { &hf_gtpv0_flags_snn, { "Is SNDCP N-PDU included?", "gtpv0.flags.snn", FT_BOOLEAN, 8, TFS(&yes_no_tfs), GTP_SNN_MASK, "Is SNDCP N-PDU LLC Number included? (1 = yes, 0 = no)", HFILL }},
5144 { &hf_gtpv0_message_type, { "Message type", "gtpv0.message", FT_UINT8, BASE_HEX, VALS(message_type), 0x0, "GTP Message Type", HFILL }},
5145 { &hf_gtpv0_length, { "Length", "gtpv0.length", FT_UINT16, BASE_DEC, NULL, 0, "Length (i.e. number of octets after TID or TEID)", HFILL }},
5146 { &hf_gtpv0_seq_number, { "Sequence number", "gtpv0.seq_number", FT_UINT16, BASE_HEX, NULL, 0, "Sequence Number", HFILL }},
5147 { &hf_gtpv0_flow_label, { "Flow label", "gtpv0.flow_label", FT_UINT16, BASE_HEX, NULL, 0, "Flow label", HFILL }},
5148 { &hf_gtpv0_sndcp_number, { "SNDCP N-PDU LLC Number", "gtpv0.sndcp_number", FT_UINT8, BASE_HEX, NULL, 0, "SNDCP N-PDU LLC Number", HFILL }},
5149 { &hf_gtpv0_tid, { "TID", "gtpv0.tid", FT_STRING, BASE_DEC, NULL, 0, "Tunnel Identifier", HFILL }},
5150 { &hf_gtpv0_cause, { "Cause", "gtpv0.cause", FT_UINT8, BASE_DEC, VALS(cause_type), 0, "Cause of operation", HFILL }},
5151 { &hf_gtpv0_imsi, { "IMSI", "gtpv0.imsi", FT_STRING, BASE_DEC, NULL, 0, "International Mobile Subscriber Identity number", HFILL }},
5152 { &hf_gtpv0_rai_mcc, { "MCC", "gtpv0.mcc", FT_UINT16, BASE_DEC, NULL, 0, "Mobile Country Code", HFILL }},
5153 { &hf_gtpv0_rai_mnc, { "MNC", "gtpv0.mnc", FT_UINT8, BASE_DEC, NULL, 0, "Mobile Network Code", HFILL }},
5154 { &hf_gtpv0_rai_rac, { "RAC", "gtpv0.rac", FT_UINT8, BASE_DEC, NULL, 0, "Routing Area Code", HFILL }},
5155 { &hf_gtpv0_rai_lac, { "LAC", "gtpv0.lac", FT_UINT16, BASE_DEC, NULL, 0, "Location Area Code", HFILL }},
5156 { &hf_gtpv0_tlli, { "TLLI", "gtpv0.tlli", FT_UINT32, BASE_HEX, NULL, 0, "Temporary Logical Link Identity", HFILL }},
5157 { &hf_gtpv0_ptmsi, { "P-TMSI", "gtpv0.ptmsi", FT_UINT32, BASE_HEX, NULL, 0, "Packet-Temporary Mobile Subscriber Identity", HFILL }},
5158 { &hf_gtpv0_qos_spare1, { "Spare", "gtpv0.qos_spare1", FT_UINT8, BASE_DEC, NULL, GTP_EXT_QOS_SPARE1_MASK, "Spare (shall be sent as '00' )", HFILL }},
5159 { &hf_gtpv0_qos_delay, { "QoS delay", "gtpv0.qos_delay", FT_UINT8, BASE_DEC, VALS(qos_delay_type), GTP_EXT_QOS_DELAY_MASK, "Quality of Service Delay Class", HFILL }},
5160 { &hf_gtpv0_qos_reliability, { "QoS reliability", "gtpv0.qos_reliabilty", FT_UINT8, BASE_DEC, VALS(qos_reliability_type), GTP_EXT_QOS_RELIABILITY_MASK, "Quality of Service Reliability Class", HFILL }},
5161 { &hf_gtpv0_qos_peak, { "QoS peak", "gtpv0.qos_peak", FT_UINT8, BASE_DEC, VALS(qos_peak_type), GTP_EXT_QOS_PEAK_MASK, "Quality of Service Peak Throughput", HFILL }},
5162 { &hf_gtpv0_qos_spare2, { "Spare", "gtpv0.qos_spare2", FT_UINT8, BASE_DEC, NULL, GTP_EXT_QOS_SPARE2_MASK, "Spare (shall be sent as 0)", HFILL }},
5163 { &hf_gtpv0_qos_precedence, { "QoS precedence", "gtpv0.qos_precedence", FT_UINT8, BASE_DEC, VALS(qos_precedence_type), GTP_EXT_QOS_PRECEDENCE_MASK, "Quality of Service Precedence Class", HFILL }},
5164 { &hf_gtpv0_qos_spare3, { "Spare", "gtpv0.qos_spare3", FT_UINT8, BASE_DEC, NULL, GTP_EXT_QOS_SPARE3_MASK, "Spare (shall be sent as '000' )", HFILL }},
5165 { &hf_gtpv0_qos_mean, { "QoS mean", "gtpv0.qos_mean", FT_UINT8, BASE_DEC, VALS(qos_mean_type), GTP_EXT_QOS_MEAN_MASK, "Quality of Service Mean Throughput", HFILL }},
5166 { &hf_gtpv0_reorder, { "Reordering required","gtpv0.reorder", FT_BOOLEAN, BASE_NONE,NULL, 0, "Reordering required", HFILL }},
5167 { &hf_gtpv0_map_cause, { "MAP cause", "gtpv0.map_cause", FT_UINT8, BASE_DEC, VALS(map_cause_type), 0, "MAP cause", HFILL }},
5168 { &hf_gtpv0_ptmsi_sig, { "P-TMSI signature", "gtpv0.ptmsi_sig", FT_UINT24, BASE_HEX, NULL, 0, "P-TMSI Signature", HFILL }},
5169 { &hf_gtpv0_ms_valid, { "MS validated", "gtpv0.ms_valid", FT_BOOLEAN, BASE_NONE,NULL, 0, "MS validated", HFILL }},
5170 { &hf_gtpv0_recovery, { "Recovery", "gtpv0.recovery", FT_UINT8, BASE_DEC, NULL, 0, "Restart counter", HFILL }},
5171 { &hf_gtpv0_sel_mode, { "Selection mode", "gtpv0.sel_mode", FT_UINT8, BASE_DEC, VALS(sel_mode_type), 0, "Selection Mode", HFILL }},
5172 { &hf_gtpv0_ext_flow_label, { "Flow Label Data I", "gtpv0.ext_flow_label", FT_UINT16, BASE_HEX, NULL, 0, "Flow label data", HFILL }},
5173 { &hf_gtpv0_flow_sig, { "Flow label Signalling", "gtpv0.flow_sig", FT_UINT16, BASE_HEX, NULL, 0, "Flow label signalling", HFILL }},
5174 { &hf_gtpv0_nsapi, { "NSAPI ", "gtpv0.nsapi", FT_UINT8, BASE_DEC, NULL, 0, "Network layer Service Access Point Identifier", HFILL }},
5175 { &hf_gtpv0_flow_ii, { "Flow Label Data II ","gtpv0.flow_ii", FT_UINT16, BASE_DEC, NULL, 0, "Downlink flow label data", HFILL }},
5176 { &hf_gtpv0_ms_reason, { "MS not reachable reason", "gtpv0.ms_reason", FT_UINT8, BASE_DEC, VALS(ms_not_reachable_type), 0, "MS Not Reachable Reason", HFILL }},
5177 { &hf_gtpv0_tr_comm, { "Packet transfer command", "gtpv0.tr_comm", FT_UINT8, BASE_DEC, VALS(tr_comm_type), 0, "Packat transfer command", HFILL }},
5178 { &hf_gtpv0_chrg_id, { "Charging ID ", "gtpv0.chrg_id", FT_UINT32, BASE_HEX, NULL, 0, "Charging ID", HFILL }},
5179 { &hf_gtpv0_user_ipv4, { "End user address IPv4", "gtpv0.user_ipv4", FT_IPv4, BASE_DEC, NULL, 0, "End user address IPv4", HFILL }},
5180 { &hf_gtpv0_user_ipv6, { "End user address IPv6", "gtpv0.user_ipv6", FT_IPv6, BASE_HEX, NULL, 0, "End user address IPv6", HFILL }},
5181 { &hf_gtpv0_user_addr_pdp_org, { "PDP type organization", "gtpv0.user_addr_pdp_org", FT_UINT8, BASE_DEC, VALS(pdp_org_type), 0, "PDP type organization", HFILL }},
5182 { &hf_gtpv0_user_addr_pdp_type, { "PDP type number", "gtpv0.user_addr_pdp_type", FT_UINT8, BASE_HEX, VALS(pdp_type), 0, "PDP type", HFILL }},
5183 { &hf_gtpv0_apn, { "APN", "gtpv0.apn", FT_STRING, BASE_DEC, NULL, 0, "Access Point Name", HFILL }},
5184 { &hf_gtpv0_gsn_addr_type, { "GSN address type", "gtpv0.gsn_addr_type", FT_UINT8, BASE_DEC, VALS(gsn_addr_type), GTP_EXT_GSN_ADDR_TYPE_MASK, "GSN Address Type", HFILL }},
5185 { &hf_gtpv0_gsn_addr_len, { "GSN address length", "gtpv0.gsn_addr_len", FT_UINT8, BASE_DEC, NULL, GTP_EXT_GSN_ADDR_LEN_MASK, "GSN Address Length", HFILL }},
5186 { &hf_gtpv0_gsn_ipv4, { "GSN address IPv4", "gtpv0.gsn_ipv4", FT_IPv4, BASE_DEC, NULL, 0, "GSN address IPv4", HFILL }},
5187 { &hf_gtpv0_gsn_ipv6, { "GSN address IPv6", "gtpv0.gsn_ipv6", FT_IPv6, BASE_DEC, NULL, 0, "GSN address IPv6", HFILL }},
5188 { &hf_gtpv0_msisdn, { "MSISDN", "gtpv0.msisdn", FT_STRING, BASE_DEC, NULL, 0, "MS international PSTN/ISDN number", HFILL }},
5189 { &hf_gtpv0_chrg_ipv4, { "CG address IPv4", "gtpv0.chrg_ipv4", FT_IPv4, BASE_DEC, NULL, 0, "Charging Gateway address IPv4", HFILL }},
5190 { &hf_gtpv0_chrg_ipv6, { "CG address IPv6", "gtpv0.chrg_ipv6", FT_IPv6, BASE_HEX, NULL, 0, "Charging Gateway address IPv6", HFILL }},
5191 { &hf_gtpv0_node_ipv4, { "Node address IPv4", "gtpv0.node_ipv4", FT_IPv4, BASE_DEC, NULL, 0, "Recommended node address IPv4", HFILL }},
5192 { &hf_gtpv0_node_ipv6, { "Node address IPv6", "gtpv0.node_ipv6", FT_IPv6, BASE_HEX, NULL, 0, "Recommended node address IPv6", HFILL }},
5193 { &hf_gtpv0_ext_id, { "Extension identifier", "gtpv0.ext_id", FT_UINT16, BASE_DEC, NULL, 0, "Extension Identifier", HFILL }},
5194 { &hf_gtpv0_ext_val, { "Extension value", "gtpv0.ext_val", FT_STRING, BASE_DEC, NULL, 0, "Extension Value", HFILL }},
5195 { &hf_gtpv0_unknown, { "Unknown data (length)", "gtpv0.unknown", FT_UINT16, BASE_DEC, NULL, 0, "Unknown data", HFILL }},
5200 static hf_register_info hf_gtpv1[] = {
5202 { &hf_gtpv1_flags, { "Flags", "gtpv1.flags", FT_UINT8, BASE_HEX, NULL, 0, "Ver/PT/Spare/E/S/PN", HFILL }},
5203 { &hf_gtpv1_flags_ver, { "Version", "gtpv1.flags.version", FT_UINT8, BASE_DEC, VALS(ver_types), GTP_VER_MASK, "GTP Version", HFILL }},
5204 { &hf_gtpv1_flags_pt, { "Protocol type", "gtpv1.flags.payload_type", FT_UINT8, BASE_DEC, NULL, GTP_PT_MASK, "Protocol Type (1 = GTP, 0 = GPRS charging protocol : GTP' )", HFILL }},
5205 { &hf_gtpv1_flags_spare, { "Spare bit", "gtpv1.flags.spare", FT_UINT8, BASE_DEC, NULL, GTPv1_SPARE_MASK, "Spare bit (shall be sent as 0)", HFILL }},
5206 { &hf_gtpv1_flags_e, { "Is Next Extension Header present?", "gtpv1.flags.e", FT_BOOLEAN, 8, TFS(&yes_no_tfs), GTPv1_E_MASK, "Is Next Extension Header present? (1 = yes, 0 = no)", HFILL }},
5207 { &hf_gtpv1_flags_s, { "Is Sequence Number present?", "gtpv1.flags.s", FT_BOOLEAN, 8, TFS(&yes_no_tfs), GTPv1_S_MASK, "Is Sequence Number present? (1 = yes, 0 = no)", HFILL }},
5208 { &hf_gtpv1_flags_pn, { "Is N-PDU number present?", "gtpv1.flags.pn", FT_BOOLEAN, 8, TFS(&yes_no_tfs), GTPv1_PN_MASK, "Is N-PDU number present? (1 = yes, 0 = no)", HFILL }},
5209 { &hf_gtpv1_message_type, { "Message Type", "gtpv1.message", FT_UINT8, BASE_HEX, VALS(message_type), 0x0, "GTP Message Type", HFILL }},
5210 { &hf_gtpv1_length, { "Length", "gtpv1.length", FT_UINT16, BASE_DEC, NULL, 0, "Length (i.e. number of octets after TID or TEID)", HFILL }},
5211 { &hf_gtpv1_seq_number, { "Sequence Number", "gtpv1.seq_number", FT_UINT16, BASE_HEX, NULL, 0, "Sequence Number", HFILL }},
5212 { &hf_gtpv1_teid, { "TEID", "gtpv1.teid", FT_UINT32, BASE_HEX, NULL, 0, "Tunnel Endpoint Identifier", HFILL }},
5213 { &hf_gtpv1_npdu_number, { "N-PDU Number", "gtpv1.npdu_number", FT_UINT8, BASE_HEX, NULL, 0, "N-PDU Number", HFILL }},
5214 { &hf_gtpv1_next, { "Next extension header type", "gtpv1.next", FT_UINT8, BASE_HEX, NULL, 0, "Next Extension Header Type", HFILL }},
5215 { &hf_gtpv1_cause, { "Cause ", "gtpv1.cause", FT_UINT8, BASE_DEC, VALS(cause_type), 0, "Cause of operation", HFILL }},
5216 { &hf_gtpv1_imsi, { "IMSI", "gtpv1.imsi", FT_STRING, BASE_DEC, NULL, 0, "International Mobile Subscriber Identity number", HFILL }},
5217 { &hf_gtpv1_rai_mcc, { "MCC", "gtpv1.mcc", FT_UINT16, BASE_DEC, NULL, 0, "Mobile Country Code", HFILL }},
5218 { &hf_gtpv1_rai_mnc, { "MNC", "gtpv1.mnc", FT_UINT8, BASE_DEC, NULL, 0, "Mobile Network Code", HFILL }},
5219 { &hf_gtpv1_rai_rac, { "RAC", "gtpv1.rac", FT_UINT8, BASE_DEC, NULL, 0, "Routing Area Code", HFILL }},
5220 { &hf_gtpv1_rai_lac, { "LAC", "gtpv1.lac", FT_UINT16, BASE_DEC, NULL, 0, "Location Area Code", HFILL }},
5221 { &hf_gtpv1_tlli, { "TLLI", "gtpv1.tlli", FT_UINT32, BASE_HEX, NULL, 0, "Temporary Logical Link Identity", HFILL }},
5222 { &hf_gtpv1_ptmsi, { "P-TMSI", "gtpv1.ptmsi", FT_UINT32, BASE_HEX, NULL, 0, "Packet-Temporary Mobile Subscriber Identity", HFILL }},
5223 { &hf_gtpv1_qos_spare1, { "Spare", "gtpv1.qos_spare1", FT_UINT8, BASE_DEC, NULL, GTP_EXT_QOS_SPARE1_MASK, "Spare (shall be sent as '00' )", HFILL }},
5224 { &hf_gtpv1_qos_delay, { "QoS Delay", "gtpv1.qos_delay", FT_UINT8, BASE_DEC, VALS(qos_delay_type), GTP_EXT_QOS_DELAY_MASK, "Quality of Service Delay Class", HFILL }},
5225 { &hf_gtpv1_qos_reliability, { "QoS Reliability", "gtpv1.qos_reliabilty", FT_UINT8, BASE_DEC, VALS(qos_reliability_type), GTP_EXT_QOS_RELIABILITY_MASK, "Quality of Service Reliability Class", HFILL }},
5226 { &hf_gtpv1_qos_peak, { "QoS Peak", "gtpv1.qos_peak", FT_UINT8, BASE_DEC, VALS(qos_peak_type), GTP_EXT_QOS_PEAK_MASK, "Quality of Service Peak Throughput", HFILL }},
5227 { &hf_gtpv1_qos_spare2, { "Spare", "gtpv1.qos_spare2", FT_UINT8, BASE_DEC, NULL, GTP_EXT_QOS_SPARE2_MASK, "Spare (shall be sent as 0)", HFILL }},
5228 { &hf_gtpv1_qos_precedence, { "QoS Precedence", "gtpv1.qos_precedence", FT_UINT8, BASE_DEC, VALS(qos_precedence_type), GTP_EXT_QOS_PRECEDENCE_MASK, "Quality of Service Precedence Class", HFILL }},
5229 { &hf_gtpv1_qos_spare3, { "Spare", "gtpv1.qos_spare3", FT_UINT8, BASE_DEC, NULL, GTP_EXT_QOS_SPARE3_MASK, "Spare (shall be sent as '000' )", HFILL }},
5230 { &hf_gtpv1_qos_mean, { "QoS Mean", "gtpv1.qos_mean", FT_UINT8, BASE_DEC, VALS(qos_mean_type), GTP_EXT_QOS_MEAN_MASK, "Quality of Service Mean Throughput", HFILL }},
5231 { &hf_gtpv1_reorder, { "Reordering required","gtpv1.reorder", FT_BOOLEAN, BASE_NONE,NULL, 0, "Reordering required", HFILL }},
5232 { &hf_gtpv1_map_cause, { "MAP cause", "gtpv1.map_cause", FT_UINT8, BASE_DEC, VALS(map_cause_type), 0, "MAP cause", HFILL }},
5233 { &hf_gtpv1_ptmsi_sig, { "P-TMSI Signature", "gtpv1.ptmsi_sig", FT_UINT24, BASE_HEX, NULL, 0, "P-TMSI Signature", HFILL }},
5234 { &hf_gtpv1_ms_valid, { "MS validated", "gtpv1.ms_valid", FT_BOOLEAN, BASE_NONE,NULL, 0, "MS validated", HFILL }},
5235 { &hf_gtpv1_recovery, { "Recovery", "gtpv1.recovery", FT_UINT8, BASE_DEC, NULL, 0, "Restart counter", HFILL }},
5236 { &hf_gtpv1_sel_mode, { "Selection Mode", "gtpv1.sel_mode", FT_UINT8, BASE_DEC, VALS(sel_mode_type), 0, "Selection Mode", HFILL }},
5237 { &hf_gtpv1_teid_data, { "TEID Data I", "gtpv1.teid_data", FT_UINT32, BASE_HEX, NULL, 0, "Tunnel Endpoint Identifier Data I", HFILL }},
5238 { &hf_gtpv1_teid_cp, { "TEID Control Plane", "gtpv1.teid_cp", FT_UINT32, BASE_HEX, NULL, 0, "Tunnel Endpoint Identifier Control Plane", HFILL }},
5239 { &hf_gtpv1_nsapi, { "NSAPI", "gtpv1.nsapi", FT_UINT8, BASE_DEC, NULL, 0, "Network layer Service Access Point Identifier", HFILL }},
5240 { &hf_gtpv1_teid_ii, { "TEID Data II", "gtpv1.teid_ii", FT_UINT32, BASE_HEX, NULL, 0, "Tunnel Endpoint Identifier Data II", HFILL }},
5241 { &hf_gtpv1_tear_ind, { "Teardown Indicator","gtpv1.tear_ind", FT_BOOLEAN, BASE_NONE,NULL, 0, "Teardown Indicator", HFILL }},
5242 { &hf_gtpv1_ranap_cause, { "RANAP cause", "gtpv1.ranap_cause", FT_UINT8, BASE_DEC, VALS(ranap_cause_type), 0, "RANAP cause", HFILL }},
5243 { &hf_gtpv1_rab_gtpu_dn, { "Downlink GTP-U seq number", "gtpv1.rab_gtp_dn", FT_UINT16, BASE_DEC, NULL, 0, "Downlink GTP-U sequence number", HFILL }},
5244 { &hf_gtpv1_rab_gtpu_up, { "Uplink GTP-U seq number", "gtpv1.rab_gtp_up", FT_UINT16, BASE_DEC, NULL, 0, "Uplink GTP-U sequence number", HFILL }},
5245 { &hf_gtpv1_rab_pdu_dn, { "Downlink next PDCP-PDU seq number", "gtpv1.rab_pdu_dn", FT_UINT8, BASE_DEC, NULL, 0, "Downlink next PDCP-PDU sequence number", HFILL }},
5246 { &hf_gtpv1_rab_pdu_up, { "Uplink next PDCP-PDU seq number", "gtpv1.rab_pdu_up", FT_UINT8, BASE_DEC, NULL, 0, "Uplink next PDCP-PDU sequence number", HFILL }},
5247 { &hf_gtpv1_rp_sms, { "Radio Priority SMS", "gtpv1.rp_sms", FT_UINT8, BASE_DEC, NULL, 0, "Radio Priority for MO SMS", HFILL }},
5248 { &hf_gtpv1_rp_nsapi, { "NSAPI in Radio Priority", "gtpv1.rp_nsapi", FT_UINT8, BASE_DEC, NULL, GTPv1_EXT_RP_NSAPI_MASK, "Network layer Service Access Point Identifier in Radio Priority", HFILL }},
5249 { &hf_gtpv1_rp_spare, { "Reserved", "gtpv1.rp_spare", FT_UINT8, BASE_DEC, NULL, GTPv1_EXT_RP_SPARE_MASK, "Spare bit", HFILL }},
5250 { &hf_gtpv1_rp, { "Radio Priority", "gtpv1.rp", FT_UINT8, BASE_DEC, NULL, GTPv1_EXT_RP_MASK, "Radio Priority for uplink tx", HFILL }},
5251 { &hf_gtpv1_pkt_flow_id, { "Packet Flow ID", "gtpv1.pkt_flow_id", FT_UINT8, BASE_DEC, NULL, 0, "Packet Flow ID", HFILL }},
5252 { &hf_gtpv1_chrg_char_s, { "Spare", "gtpv1.chrg_char_s", FT_UINT8, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_S, "Spare", HFILL }},
5253 { &hf_gtpv1_chrg_char_n, { "Normal charging", "gtpv1.chrg_char_n", FT_UINT8, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_N, "Normal charging", HFILL }},
5254 { &hf_gtpv1_chrg_char_p, { "Prepaid charging", "gtpv1.chrg_char_p", FT_UINT8, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_P, "Prepaid charging", HFILL }},
5255 { &hf_gtpv1_chrg_char_f, { "Flat rate charging", "gtpv1.chrg_char_f", FT_UINT8, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_F, "Flat rate charging", HFILL }},
5256 { &hf_gtpv1_chrg_char_h, { "Hot billing charging", "gtpv1.chrg_char_h", FT_UINT8, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_H, "Hot billing charging", HFILL }},
5257 { &hf_gtpv1_chrg_char_r, { "Reserved", "gtpv1.chrg_char_r", FT_UINT8, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_R, "Reserved", HFILL }},
5258 { &hf_gtpv1_trace_ref, { "Trace reference", "gtpv1.trace_ref", FT_UINT16, BASE_HEX, NULL, 0, "Trace reference", HFILL }},
5259 { &hf_gtpv1_trace_type, { "Trace type", "gtpv1.trace_type", FT_UINT16, BASE_HEX, NULL, 0, "Trace type", HFILL }},
5260 { &hf_gtpv1_ms_reason, { "MS not reachable reason", "gtpv1.ms_reason", FT_UINT8, BASE_DEC, VALS(ms_not_reachable_type), 0, "MS not reachable reason", HFILL }},
5261 { &hf_gtpv1_tr_comm, { "Packet transfer command", "gtpv1.tr_comm", FT_UINT8, BASE_DEC, VALS(tr_comm_type), 0, "Packat transfer command", HFILL }},
5262 { &hf_gtpv1_chrg_id, { "Charging ID", "gtpv1.chrg_id", FT_UINT32, BASE_HEX, NULL, 0, "Charging ID", HFILL }},
5263 { &hf_gtpv1_user_ipv4, { "End user address IPv4", "gtpv1.user_ipv4", FT_IPv4, BASE_DEC, NULL, 0, "End user address IPv4", HFILL }},
5264 { &hf_gtpv1_user_ipv6, { "End user address IPv6", "gtpv1.user_ipv6", FT_IPv6, BASE_HEX, NULL, 0, "End user address IPv6", HFILL }},
5265 { &hf_gtpv1_user_addr_pdp_org, { "PDP type organization", "gtpv1.user_addr_pdp_org", FT_UINT8, BASE_DEC, VALS(pdp_org_type), 0, "PDP type organization", HFILL }},
5266 { &hf_gtpv1_user_addr_pdp_type, { "PDP type number", "gtpv1.user_addr_pdp_type", FT_UINT8, BASE_HEX, VALS(pdp_type), 0, "PDP type", HFILL }},
5267 { &hf_gtpv1_apn, { "APN", "gtpv1.apn", FT_STRING, BASE_DEC, NULL, 0, "Access Point Name", HFILL }},
5268 { &hf_gtpv1_gsn_addr_type, { "GSN Address Type", "gtpv1.gsn_addr_type", FT_UINT8, BASE_DEC, VALS(gsn_addr_type), GTP_EXT_GSN_ADDR_TYPE_MASK, "GSN Address Type", HFILL }},
5269 { &hf_gtpv1_gsn_addr_len, { "GSN Address Length", "gtpv1.gsn_addr_len", FT_UINT8, BASE_DEC, NULL, GTP_EXT_GSN_ADDR_LEN_MASK, "GSN Address Length", HFILL }},
5270 { &hf_gtpv1_gsn_ipv4, { "GSN address IPv4", "gtpv1.gsn_ipv4", FT_IPv4, BASE_DEC, NULL, 0, "GSN address IPv4", HFILL }},
5271 { &hf_gtpv1_gsn_ipv6, { "GSN address IPv6", "gtpv1.gsn_ipv6", FT_IPv6, BASE_DEC, NULL, 0, "GSN address IPv6", HFILL }},
5272 { &hf_gtpv1_msisdn, { "MSISDN", "gtpv1.msisdn", FT_STRING, BASE_DEC, NULL, 0, "MS international PSTN/ISDN number", HFILL }},
5273 { &hf_gtpv1_qos_al_ret_priority, { "Allocation/Retention priority ","gtpv1.qos_al_ret_priority", FT_UINT8, BASE_DEC, NULL, 0, "Allocation/Retention Priority", HFILL }},
5274 { &hf_gtpv1_qos_traf_class, { "Traffic class", "gtpv1.qos_traf_class", FT_UINT8, BASE_DEC, VALS(qos_traf_class), GTP_EXT_QOS_TRAF_CLASS_MASK, "Traffic Class", HFILL }},
5275 { &hf_gtpv1_qos_del_order, { "Delivery order", "gtpv1.qos_del_order", FT_UINT8, BASE_DEC, VALS(qos_del_order), GTP_EXT_QOS_DEL_ORDER_MASK, "Delivery Order", HFILL }},
5276 { &hf_gtpv1_qos_del_err_sdu, { "Delivery of erroneous SDU", "gtpv1.qos_del_err_sdu", FT_UINT8, BASE_DEC, VALS(qos_del_err_sdu), GTP_EXT_QOS_DEL_ERR_SDU_MASK, "Delivery of Erroneous SDU", HFILL }},
5277 { &hf_gtpv1_qos_max_sdu_size, { "Maximum SDU size", "gtpv1.qos_max_sdu_size", FT_UINT8, BASE_DEC, VALS(qos_max_sdu_size), 0, "Maximum SDU size", HFILL }},
5278 { &hf_gtpv1_qos_max_ul, { "Maximum bit rate for uplink", "gtpv1.qos_max_ul", FT_UINT8, BASE_DEC, VALS(qos_max_ul), 0, "Maximum bit rate for uplink", HFILL }},
5279 { &hf_gtpv1_qos_max_dl, { "Maximum bit rate for downlink", "gtpv1.qos_max_dl", FT_UINT8, BASE_DEC, VALS(qos_max_dl), 0, "Maximum bit rate for downlink", HFILL }},
5280 { &hf_gtpv1_qos_res_ber, { "Residual BER", "gtpv1.qos_res_ber", FT_UINT8, BASE_DEC, VALS(qos_res_ber), GTP_EXT_QOS_RES_BER_MASK, "Residual Bit Error Rate", HFILL }},
5281 { &hf_gtpv1_qos_sdu_err_ratio, { "SDU Error ratio", "gtpv1.qos_sdu_err_ratio", FT_UINT8, BASE_DEC, VALS(qos_sdu_err_ratio), GTP_EXT_QOS_SDU_ERR_RATIO_MASK, "SDU Error Ratio", HFILL }},
5282 { &hf_gtpv1_qos_trans_delay, { "Transfer delay", "gtpv1.qos_trans_delay", FT_UINT8, BASE_DEC, VALS(qos_trans_delay), GTP_EXT_QOS_TRANS_DELAY_MASK, "Transfer Delay", HFILL }},
5283 { &hf_gtpv1_qos_traf_handl_prio, { "Traffic handling priority", "gtpv1.qos_traf_handl_prio", FT_UINT8, BASE_DEC, VALS(qos_traf_handl_prio), GTP_EXT_QOS_TRAF_HANDL_PRIORITY_MASK, "Traffic Handling Priority", HFILL }},
5284 { &hf_gtpv1_qos_guar_ul, { "Guaranteed bit rate for uplink", "gtpv1.qos_guar_ul", FT_UINT8, BASE_DEC, VALS(qos_guar_ul), 0, "Guaranteed bit rate for uplink", HFILL }},
5285 { &hf_gtpv1_qos_guar_dl, { "Guaranteed bit rate for downlink", "gtpv1.qos_guar_dl", FT_UINT8, BASE_DEC, VALS(qos_guar_dl), 0, "Guaranteed bit rate for downlink", HFILL }},
5287 { &hf_gtpv1_tft_code, { "TFT operation code", "gtpv1.tft_code", FT_UINT8, BASE_DEC, VALS (tft_code_type), GTPv1_TFT_CODE_MASK, "TFT operation code", HFILL }},
5288 { &hf_gtpv1_tft_spare, { "TFT spare bit", "gtpv1.tft_spare", FT_UINT8, BASE_DEC, NULL, GTPv1_TFT_SPARE_MASK, "TFT spare bit", HFILL }},
5289 { &hf_gtpv1_tft_number, { "Number of packet filters", "gtpv1.tft_number", FT_UINT8, BASE_DEC, NULL, GTPv1_TFT_NUMBER_MASK, "Number of packet filters", HFILL }},
5290 { &hf_gtpv1_tft_eval, { "Evaluation precedence", "gtpv1.tft_eval", FT_UINT8, BASE_DEC, NULL, 0, "Evaluation precedence", HFILL }},
5292 { &hf_gtpv1_rnc_ipv4, { "RNC address IPv4", "gtpv1.rnc_ipv4", FT_IPv4, BASE_DEC, NULL, 0, "Radio Network Controller address IPv4", HFILL }},
5293 { &hf_gtpv1_rnc_ipv6, { "RNC address IPv6", "gtpv1.rnc_ipv6", FT_IPv6, BASE_HEX, NULL, 0, "Radio Network Controller address IPv6", HFILL }},
5294 { &hf_gtpv1_chrg_ipv4, { "CG address IPv4", "gtpv1.chrg_ipv4", FT_IPv4, BASE_DEC, NULL, 0, "Charging Gateway address IPv4", HFILL }},
5295 { &hf_gtpv1_chrg_ipv6, { "CG address IPv6", "gtpv1.chrg_ipv6", FT_IPv6, BASE_HEX, NULL, 0, "Charging Gateway address IPv6", HFILL }},
5296 { &hf_gtpv1_node_ipv4, { "Node address IPv4", "gtpv1.node_ipv4", FT_IPv4, BASE_DEC, NULL, 0, "Recommended node address IPv4", HFILL }},
5297 { &hf_gtpv1_node_ipv6, { "Node address IPv6", "gtpv1.node_ipv6", FT_IPv6, BASE_HEX, NULL, 0, "Recommended node address IPv6", HFILL }},
5298 { &hf_gtpv1_ext_id, { "Extensio Identifier","gtpv1.ext_id", FT_UINT16, BASE_DEC, NULL, 0, "Extension Identifier", HFILL }},
5299 { &hf_gtpv1_ext_val, { "Extension Value", "gtpv1.ext_val", FT_STRING, BASE_DEC, NULL, 0, "Extension Value", HFILL }},
5300 { &hf_gtpv1_unknown, { "Unknown data (length)", "gtpv1.unknown", FT_UINT16, BASE_DEC, NULL, 0, "Unknown data", HFILL }},
5304 static gint *ett_gtp_array[] = {
5314 &ett_gtp_pkt_flow_id,
5337 module_t *gtp_module;
5339 static enum_val_t gtpv0_cdr_options[] = {
5340 { "GSM 12.15 (not implemented yet)", 0 },
5346 /* proto_gtp defined only for preference tab */
5347 proto_gtp = proto_register_protocol ("GPRS Tunneling Protocol", "GTP", "gtp");
5349 proto_gtpv0 = proto_register_protocol ("GPRS Tunnelling Protocol v0", "GTPv0", "gtpv0");
5350 proto_register_field_array(proto_gtpv0, hf_gtpv0, array_length(hf_gtpv0));
5351 proto_register_subtree_array(ett_gtp_array, array_length(ett_gtp_array));
5353 proto_gtpv1 = proto_register_protocol("GPRS Tunnelling Protocol v1", "GTPv1", "gtpv1");
5354 proto_register_field_array(proto_gtpv1, hf_gtpv1, array_length(hf_gtpv1));
5355 proto_register_subtree_array(ett_gtp_array, array_length(ett_gtp_array));
5357 gtp_module = prefs_register_protocol(proto_gtp, proto_reg_handoff_gtp);
5359 prefs_register_uint_preference(gtp_module, "v0_port", "GTPv0 port", "GTPv0 port (default 3386)", 10, &g_gtpv0_port);
5360 prefs_register_uint_preference(gtp_module, "v1c_port", "GTPv1 control plane (GTP-C) port", "GTPv1 control plane port (default 2123)", 10, &g_gtpv1c_port);
5361 prefs_register_uint_preference(gtp_module, "v1u_port", "GTPv1 user plane (GTP-U) port", "GTPv1 user plane port (default 2152)", 10, &g_gtpv1u_port);
5362 prefs_register_bool_preference(gtp_module, "dissect_tpdu", "Dissect T-PDU", "Dissect T-PDU", >p_tpdu);
5363 prefs_register_enum_preference(gtp_module, "v0_dissect_cdr_as", "Dissect GTP'v0 CDRs as", "Dissect GTP'v0 CDRs as", >pv0_cdr_as, gtpv0_cdr_options, FALSE);
5364 prefs_register_bool_preference(gtp_module, "v0_check_etsi", "Compare GTPv0 order with ETSI", "GTPv0 ETSI order", >pv0_etsi_order);
5365 prefs_register_bool_preference(gtp_module, "v1_check_etsi", "Compare GTPv1 order with ETSI", "GTPv1 ETSI order", >pv1_etsi_order);
5366 prefs_register_obsolete_preference(gtp_module, "ppp_reorder");
5368 register_dissector("gtpv0", dissect_gtpv0, proto_gtpv0);
5369 register_dissector("gtpv1", dissect_gtpv1, proto_gtpv1);
5373 proto_reg_handoff_gtp(void)
5375 static int Initialized = FALSE;
5376 static dissector_handle_t gtpv0_handle;
5377 static dissector_handle_t gtpv1_handle;
5381 gtpv0_handle = find_dissector("gtpv0");
5383 gtpv1_handle = find_dissector("gtpv1");
5385 ppp_subdissector_table = find_dissector_table("ppp.protocol");
5391 dissector_delete("udp.port", gtpv0_port, gtpv0_handle);
5392 dissector_delete("tcp.port", gtpv0_port, gtpv0_handle);
5394 dissector_delete("udp.port", gtpv1c_port, gtpv1_handle);
5395 dissector_delete("tcp.port", gtpv1c_port, gtpv1_handle);
5396 dissector_delete("udp.port", gtpv1u_port, gtpv1_handle);
5397 dissector_delete("tcp.port", gtpv1u_port, gtpv1_handle);
5400 gtpv0_port = g_gtpv0_port;
5401 gtpv1c_port = g_gtpv1c_port;
5402 gtpv1u_port = g_gtpv1u_port;
5406 dissector_add("udp.port", g_gtpv0_port, gtpv0_handle);
5407 dissector_add("tcp.port", g_gtpv0_port, gtpv0_handle);
5411 dissector_add("udp.port", g_gtpv1c_port, gtpv1_handle);
5412 dissector_add("tcp.port", g_gtpv1c_port, gtpv1_handle);
5413 dissector_add("udp.port", g_gtpv1u_port, gtpv1_handle);
5414 dissector_add("tcp.port", g_gtpv1u_port, gtpv1_handle);
5416 ip_handle = find_dissector("ip");
5417 ipv6_handle = find_dissector("ipv6");
5418 ppp_handle = find_dissector("ppp");
5419 data_handle = find_dissector("data");