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.50 2003/01/02 20:33:45 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"
45 * All data related to GTP v0 (GPRS) uses "gtpv0" or "GTPv0",
46 * all data related to GTP v1 (UMTS) uses "gtpv1" or "GTPv1",
47 * if there is any gtp alone statement it means that this data is common
48 * for both: GPRS and UMTS
51 #define GTPv0_PORT 3386
52 #define GTPv1C_PORT 2123 /* 3G Control PDU */
53 #define GTPv1U_PORT 2152 /* 3G T-PDU */
55 #define GTPv0_HDR_LENGTH 20
56 #define GTPv1_HDR_LENGTH 12
57 #define GTP_PRIME_HDR_LENGTH 6
59 /* for function checking compliance with ETSI */
60 #define GTP_MANDATORY 1
61 #define GTP_OPTIONAL 2
62 #define GTP_CONDITIONAL 4
64 static int g_gtpv0_port = GTPv0_PORT;
65 static int g_gtpv1c_port = GTPv1C_PORT;
66 static int g_gtpv1u_port = GTPv1U_PORT;
68 void proto_reg_handoff_gtp(void);
70 static int proto_gtp = -1;
71 static int proto_gtpv0 = -1;
72 static int proto_gtpv1 = -1;
74 static int hf_gtpv0_flags = -1;
75 static int hf_gtpv0_flags_ver = -1;
76 static int hf_gtpv0_flags_pt = -1;
77 static int hf_gtpv0_flags_spare = -1;
78 #ifdef GTP_UNUSED_HANDLES
79 static int hf_gtpv0_flags_e = -1;
80 static int hf_gtpv0_flags_s = -1;
81 static int hf_gtpv0_flags_pn = -1;
83 static int hf_gtpv0_flags_snn = -1;
84 static int hf_gtpv0_message_type = -1;
85 static int hf_gtpv0_length = -1;
86 static int hf_gtpv0_seq_number = -1;
87 static int hf_gtpv0_flow_label = -1;
88 static int hf_gtpv0_sndcp_number = -1;
89 #ifdef GTP_UNUSED_HANDLES
90 static int hf_gtpv0_npdu_number = -1;
92 static int hf_gtpv0_tid = -1;
93 #ifdef GTP_UNUSED_HANDLES
94 static int hf_gtpv0_teid = -1;
95 static int hf_gtpv0_next = -1;
97 static int hf_gtpv0_cause = -1;
98 static int hf_gtpv0_imsi = -1;
99 static int hf_gtpv0_rai_mcc = -1;
100 static int hf_gtpv0_rai_mnc = -1;
101 static int hf_gtpv0_rai_rac = -1;
102 static int hf_gtpv0_rai_lac = -1;
103 static int hf_gtpv0_tlli = -1;
104 static int hf_gtpv0_ptmsi = -1;
105 static int hf_gtpv0_qos_spare1 = -1;
106 static int hf_gtpv0_qos_delay = -1;
107 static int hf_gtpv0_qos_mean = -1;
108 static int hf_gtpv0_qos_peak = -1;
109 static int hf_gtpv0_qos_spare2 = -1;
110 static int hf_gtpv0_qos_precedence = -1;
111 static int hf_gtpv0_qos_spare3 = -1;
112 static int hf_gtpv0_qos_reliability = -1;
113 static int hf_gtpv0_reorder = -1;
114 static int hf_gtpv0_map_cause = -1;
115 static int hf_gtpv0_ptmsi_sig = -1;
116 static int hf_gtpv0_ms_valid = -1;
117 static int hf_gtpv0_recovery = -1;
118 static int hf_gtpv0_sel_mode = -1;
119 static int hf_gtpv0_ext_flow_label = -1;
120 #ifdef GTP_UNUSED_HANDLES
121 static int hf_gtpv0_teid_data = -1; /* 3G */
123 static int hf_gtpv0_flow_sig = -1;
124 #ifdef GTP_UNUSED_HANDLES
125 static int hf_gtpv0_teid_cp = -1; /* 3G */
127 static int hf_gtpv0_nsapi = -1;
128 static int hf_gtpv0_flow_ii = -1;
129 #ifdef GTP_UNUSED_HANDLES
130 static int hf_gtpv0_teid_ii = -1; /* 3G */
132 static int hf_gtpv0_ms_reason = -1;
133 #ifdef GTP_UNUSED_HANDLES
134 static int hf_gtpv0_tear_ind = -1; /* 3G */
135 static int hf_gtpv0_ranap_cause = -1; /* 3G */
136 static int hf_gtpv0_rab_gtpu_dn = -1; /* 3G */
137 static int hf_gtpv0_rab_gtpu_up = -1; /* 3G */
138 static int hf_gtpv0_rab_pdu_dn = -1; /* 3G */
139 static int hf_gtpv0_rab_pdu_up = -1; /* 3G */
140 static int hf_gtpv0_rp_sms = -1; /* 3G */
141 static int hf_gtpv0_rp_spare = -1; /* 3G */
142 static int hf_gtpv0_rp_nsapi = -1; /* 3G */
143 static int hf_gtpv0_rp = -1; /* 3G */
144 static int hf_gtpv0_pkt_flow_id = -1; /* 3G */
145 static int hf_gtpv0_chrg_char_s = -1; /* 3G */
146 static int hf_gtpv0_chrg_char_n = -1; /* 3G */
147 static int hf_gtpv0_chrg_char_p = -1; /* 3G */
148 static int hf_gtpv0_chrg_char_f = -1; /* 3G */
149 static int hf_gtpv0_chrg_char_h = -1; /* 3G */
150 static int hf_gtpv0_chrg_char_r = -1; /* 3G */
151 static int hf_gtpv0_trace_ref = -1; /* 3G */
152 static int hf_gtpv0_trace_type = -1; /* 3G */
154 static int hf_gtpv0_tr_comm = -1; /* charging */
155 static int hf_gtpv0_chrg_id = -1;
156 static int hf_gtpv0_user_ipv4 = -1;
157 static int hf_gtpv0_user_ipv6 = -1;
158 static int hf_gtpv0_user_addr_pdp_org = -1;
159 static int hf_gtpv0_user_addr_pdp_type = -1;
160 static int hf_gtpv0_apn = -1;
161 static int hf_gtpv0_gsn_ipv4 = -1;
162 static int hf_gtpv0_gsn_ipv6 = -1;
163 static int hf_gtpv0_gsn_addr_type = -1;
164 static int hf_gtpv0_gsn_addr_len = -1;
165 static int hf_gtpv0_msisdn = -1;
166 #ifdef GTP_UNUSED_HANDLES
167 static int hf_gtpv0_qos_al_ret_priority = -1;
168 static int hf_gtpv0_qos_traf_class = -1;
169 static int hf_gtpv0_qos_del_order = -1;
170 static int hf_gtpv0_qos_del_err_sdu = -1;
171 static int hf_gtpv0_qos_max_sdu_size = -1;
172 static int hf_gtpv0_qos_max_ul = -1;
173 static int hf_gtpv0_qos_max_dl = -1;
174 static int hf_gtpv0_qos_res_ber = -1;
175 static int hf_gtpv0_qos_sdu_err_ratio = -1;
176 static int hf_gtpv0_qos_trans_delay = -1;
177 static int hf_gtpv0_qos_traf_handl_prio = -1;
178 static int hf_gtpv0_qos_guar_ul = -1;
179 static int hf_gtpv0_qos_guar_dl = -1;
180 static int hf_gtpv0_rnc_ipv4 = -1;
181 static int hf_gtpv0_rnc_ipv6 = -1;
183 static int hf_gtpv0_chrg_ipv4 = -1;
184 static int hf_gtpv0_chrg_ipv6 = -1;
185 static int hf_gtpv0_node_ipv4 = -1;
186 static int hf_gtpv0_node_ipv6 = -1;
187 static int hf_gtpv0_ext_id = -1;
188 static int hf_gtpv0_ext_val = -1;
189 static int hf_gtpv0_unknown = -1;
191 static int hf_gtpv1_flags = -1;
192 static int hf_gtpv1_flags_ver = -1;
193 static int hf_gtpv1_flags_pt = -1;
194 static int hf_gtpv1_flags_spare = -1;
195 static int hf_gtpv1_flags_e = -1;
196 static int hf_gtpv1_flags_s = -1;
197 static int hf_gtpv1_flags_pn = -1;
198 #ifdef GTP_UNUSED_HANDLES
199 static int hf_gtpv1_flags_snn = -1;
201 static int hf_gtpv1_message_type = -1;
202 static int hf_gtpv1_length = -1;
203 static int hf_gtpv1_seq_number = -1;
204 #ifdef GTP_UNUSED_HANDLES
205 static int hf_gtpv1_flow_label = -1;
206 static int hf_gtpv1_sndcp_number = -1;
208 static int hf_gtpv1_npdu_number = -1;
209 #ifdef GTP_UNUSED_HANDLES
210 static int hf_gtpv1_tid = -1;
212 static int hf_gtpv1_teid = -1;
213 static int hf_gtpv1_next = -1;
214 static int hf_gtpv1_cause = -1;
215 static int hf_gtpv1_imsi = -1;
216 static int hf_gtpv1_rai_mcc = -1;
217 static int hf_gtpv1_rai_mnc = -1;
218 static int hf_gtpv1_rai_rac = -1;
219 static int hf_gtpv1_rai_lac = -1;
220 static int hf_gtpv1_tlli = -1;
221 static int hf_gtpv1_ptmsi = -1;
222 static int hf_gtpv1_qos_spare1 = -1;
223 static int hf_gtpv1_qos_delay = -1;
224 static int hf_gtpv1_qos_mean = -1;
225 static int hf_gtpv1_qos_peak = -1;
226 static int hf_gtpv1_qos_spare2 = -1;
227 static int hf_gtpv1_qos_precedence = -1;
228 static int hf_gtpv1_qos_spare3 = -1;
229 static int hf_gtpv1_qos_reliability = -1;
230 static int hf_gtpv1_reorder = -1;
231 static int hf_gtpv1_map_cause = -1;
232 static int hf_gtpv1_ptmsi_sig = -1;
233 static int hf_gtpv1_ms_valid = -1;
234 static int hf_gtpv1_recovery = -1;
235 static int hf_gtpv1_sel_mode = -1;
236 #ifdef GTP_UNUSED_HANDLES
237 static int hf_gtpv1_ext_flow_label = -1;
239 static int hf_gtpv1_teid_data = -1; /* 3G */
240 #ifdef GTP_UNUSED_HANDLES
241 static int hf_gtpv1_flow_sig = -1;
243 static int hf_gtpv1_teid_cp = -1; /* 3G */
244 static int hf_gtpv1_nsapi = -1;
245 #ifdef GTP_UNUSED_HANDLES
246 static int hf_gtpv1_flow_ii = -1;
248 static int hf_gtpv1_teid_ii = -1; /* 3G */
249 static int hf_gtpv1_ms_reason = -1;
250 static int hf_gtpv1_tear_ind = -1; /* 3G */
251 static int hf_gtpv1_ranap_cause = -1; /* 3G */
252 static int hf_gtpv1_rab_gtpu_dn = -1; /* 3G */
253 static int hf_gtpv1_rab_gtpu_up = -1; /* 3G */
254 static int hf_gtpv1_rab_pdu_dn = -1; /* 3G */
255 static int hf_gtpv1_rab_pdu_up = -1; /* 3G */
256 static int hf_gtpv1_rp_sms = -1; /* 3G */
257 static int hf_gtpv1_rp_spare = -1; /* 3G */
258 static int hf_gtpv1_rp_nsapi = -1; /* 3G */
259 static int hf_gtpv1_rp = -1; /* 3G */
260 static int hf_gtpv1_pkt_flow_id = -1; /* 3G */
261 static int hf_gtpv1_chrg_char_s = -1; /* 3G */
262 static int hf_gtpv1_chrg_char_n = -1; /* 3G */
263 static int hf_gtpv1_chrg_char_p = -1; /* 3G */
264 static int hf_gtpv1_chrg_char_f = -1; /* 3G */
265 static int hf_gtpv1_chrg_char_h = -1; /* 3G */
266 static int hf_gtpv1_chrg_char_r = -1; /* 3G */
267 static int hf_gtpv1_trace_ref = -1; /* 3G */
268 static int hf_gtpv1_trace_type = -1; /* 3G */
269 static int hf_gtpv1_tr_comm = -1; /* charging */
270 static int hf_gtpv1_chrg_id = -1;
271 static int hf_gtpv1_user_ipv4 = -1;
272 static int hf_gtpv1_user_ipv6 = -1;
273 static int hf_gtpv1_user_addr_pdp_org = -1;
274 static int hf_gtpv1_user_addr_pdp_type = -1;
275 static int hf_gtpv1_apn = -1;
276 static int hf_gtpv1_gsn_ipv4 = -1;
277 static int hf_gtpv1_gsn_ipv6 = -1;
278 static int hf_gtpv1_gsn_addr_type = -1;
279 static int hf_gtpv1_gsn_addr_len = -1;
280 static int hf_gtpv1_msisdn = -1;
281 static int hf_gtpv1_qos_al_ret_priority = -1;
282 static int hf_gtpv1_qos_traf_class = -1;
283 static int hf_gtpv1_qos_del_order = -1;
284 static int hf_gtpv1_qos_del_err_sdu = -1;
285 static int hf_gtpv1_qos_max_sdu_size = -1;
286 static int hf_gtpv1_qos_max_ul = -1;
287 static int hf_gtpv1_qos_max_dl = -1;
288 static int hf_gtpv1_qos_res_ber = -1;
289 static int hf_gtpv1_qos_sdu_err_ratio = -1;
290 static int hf_gtpv1_qos_trans_delay = -1;
291 static int hf_gtpv1_qos_traf_handl_prio = -1;
292 static int hf_gtpv1_qos_guar_ul = -1;
293 static int hf_gtpv1_qos_guar_dl = -1;
294 static int hf_gtpv1_tft_code = -1;
295 static int hf_gtpv1_tft_spare = -1;
296 static int hf_gtpv1_tft_number = -1;
297 static int hf_gtpv1_tft_eval = -1;
298 static int hf_gtpv1_rnc_ipv4 = -1;
299 static int hf_gtpv1_rnc_ipv6 = -1;
300 static int hf_gtpv1_chrg_ipv4 = -1;
301 static int hf_gtpv1_chrg_ipv6 = -1;
302 static int hf_gtpv1_node_ipv4 = -1;
303 static int hf_gtpv1_node_ipv6 = -1;
304 static int hf_gtpv1_ext_id = -1;
305 static int hf_gtpv1_ext_val = -1;
306 static int hf_gtpv1_unknown = -1;
308 /* Initialize the subtree pointers */
309 static gint ett_gtp = -1;
310 static gint ett_gtp_flags = -1;
311 static gint ett_gtp_ext = -1;
312 static gint ett_gtp_rai = -1;
313 static gint ett_gtp_qos = -1;
314 static gint ett_gtp_auth_tri = -1;
315 static gint ett_gtp_flow_ii = -1;
316 static gint ett_gtp_rab_cntxt = -1;
317 static gint ett_gtp_rp = -1;
318 static gint ett_gtp_pkt_flow_id = -1;
319 static gint ett_gtp_chrg_char = -1;
320 static gint ett_gtp_user = -1;
321 static gint ett_gtp_mm = -1;
322 static gint ett_gtp_trip = -1;
323 static gint ett_gtp_quint = -1;
324 static gint ett_gtp_pdp = -1;
325 static gint ett_gtp_apn = -1;
326 static gint ett_gtp_proto = -1;
327 static gint ett_gtp_gsn_addr = -1;
328 static gint ett_gtp_tft = -1;
329 static gint ett_gtp_tft_pf = -1;
330 static gint ett_gtp_tft_flags = -1;
331 static gint ett_gtp_rab_setup = -1;
332 static gint ett_gtp_hdr_list = -1;
333 static gint ett_gtp_chrg_addr = -1;
334 static gint ett_gtp_node_addr = -1;
335 static gint ett_gtp_rel_pack = -1;
336 static gint ett_gtp_can_pack = -1;
337 static gint ett_gtp_data_resp = -1;
338 static gint ett_gtp_priv_ext = -1;
340 /* Definition of user preferences panel fields */
341 #define DONT_DISSECT_CDRS 2
343 static gboolean gtp_tpdu = TRUE;
344 static gint gtpv0_cdr_as = DONT_DISSECT_CDRS; /* 2 = do not dissect */
345 static gboolean gtpv0_etsi_order = FALSE;
346 static gboolean gtpv1_etsi_order = FALSE;
347 static int gtpv0_port = 0;
348 static int gtpv1c_port = 0;
349 static int gtpv1u_port = 0;
351 /* Definition of flags masks */
352 #define GTP_VER_MASK 0xE0
354 static const value_string ver_types[] = {
355 { 0, "GTP release 97/98 version" },
356 { 1, "GTP release 99 version" },
366 #define GTP_PT_MASK 0x10
367 #define GTP_SPARE_MASK 0x0E
368 #define GTPv1_SPARE_MASK 0x08
369 #define GTPv1_E_MASK 0x04
370 #define GTPv1_S_MASK 0x02
371 #define GTP_SNN_MASK 0x01
372 #define GTPv1_PN_MASK 0x01
374 /* Definition of 3G charging characteristics masks */
375 #define GTP_MASK_CHRG_CHAR_S 0xF000
376 #define GTP_MASK_CHRG_CHAR_N 0x0800
377 #define GTP_MASK_CHRG_CHAR_P 0x0400
378 #define GTP_MASK_CHRG_CHAR_F 0x0200
379 #define GTP_MASK_CHRG_CHAR_H 0x0100
380 #define GTP_MASK_CHRG_CHAR_R 0x00FF
382 /* Traffic Flow Templates mask */
383 #define GTPv1_TFT_CODE_MASK 0xE0
384 #define GTPv1_TFT_SPARE_MASK 0x10
385 #define GTPv1_TFT_NUMBER_MASK 0x0F
387 /* Definition of GSN Address masks */
388 #define GTP_EXT_GSN_ADDR_TYPE_MASK 0xC0
389 #define GTP_EXT_GSN_ADDR_LEN_MASK 0x3F
391 /* Definition of QoS masks */
392 #define GTP_EXT_QOS_SPARE1_MASK 0xC0
393 #define GTP_EXT_QOS_DELAY_MASK 0x38
394 #define GTP_EXT_QOS_RELIABILITY_MASK 0x07
395 #define GTP_EXT_QOS_PEAK_MASK 0xF0
396 #define GTP_EXT_QOS_SPARE2_MASK 0x08
397 #define GTP_EXT_QOS_PRECEDENCE_MASK 0x07
398 #define GTP_EXT_QOS_SPARE3_MASK 0xE0
399 #define GTP_EXT_QOS_MEAN_MASK 0x1F
400 #define GTP_EXT_QOS_TRAF_CLASS_MASK 0xE0
401 #define GTP_EXT_QOS_DEL_ORDER_MASK 0x18
402 #define GTP_EXT_QOS_DEL_ERR_SDU_MASK 0x07
403 #define GTP_EXT_QOS_RES_BER_MASK 0xF0
404 #define GTP_EXT_QOS_SDU_ERR_RATIO_MASK 0x0F
405 #define GTP_EXT_QOS_TRANS_DELAY_MASK 0xFC
406 #define GTP_EXT_QOS_TRAF_HANDL_PRIORITY_MASK 0x03
408 /* Definition of Radio Priority's masks */
409 #define GTPv1_EXT_RP_NSAPI_MASK 0xF0
410 #define GTPv1_EXT_RP_SPARE_MASK 0x08
411 #define GTPv1_EXT_RP_MASK 0x07
413 /* definitions of GTP messages */
414 #define GTP_MSG_UNKNOWN 0x00
415 #define GTP_MSG_ECHO_REQ 0x01
416 #define GTP_MSG_ECHO_RESP 0x02
417 #define GTP_MSG_VER_NOT_SUPP 0x03
418 #define GTP_MSG_NODE_ALIVE_REQ 0x04
419 #define GTP_MSG_NODE_ALIVE_RESP 0x05
420 #define GTP_MSG_REDIR_REQ 0x06
421 #define GTP_MSG_REDIR_RESP 0x07
422 #define GTP_MSG_CREATE_PDP_REQ 0x10
423 #define GTP_MSG_CREATE_PDP_RESP 0x11
424 #define GTP_MSG_UPDATE_PDP_REQ 0x12
425 #define GTP_MSG_UPDATE_PDP_RESP 0x13
426 #define GTP_MSG_DELETE_PDP_REQ 0x14
427 #define GTP_MSG_DELETE_PDP_RESP 0x15
428 #define GTP_MSG_CREATE_AA_PDP_REQ 0x16 /* 2G */
429 #define GTP_MSG_CREATE_AA_PDP_RESP 0x17 /* 2G */
430 #define GTP_MSG_DELETE_AA_PDP_REQ 0x18 /* 2G */
431 #define GTP_MSG_DELETE_AA_PDP_RESP 0x19 /* 2G */
432 #define GTP_MSG_ERR_IND 0x1A
433 #define GTP_MSG_PDU_NOTIFY_REQ 0x1B
434 #define GTP_MSG_PDU_NOTIFY_RESP 0x1C
435 #define GTP_MSG_PDU_NOTIFY_REJ_REQ 0x1D
436 #define GTP_MSG_PDU_NOTIFY_REJ_RESP 0x1E
437 #define GTP_MSG_SUPP_EXT_HDR 0x1F
438 #define GTP_MSG_SEND_ROUT_INFO_REQ 0x20
439 #define GTP_MSG_SEND_ROUT_INFO_RESP 0x21
440 #define GTP_MSG_FAIL_REP_REQ 0x22
441 #define GTP_MSG_FAIL_REP_RESP 0x23
442 #define GTP_MSG_MS_PRESENT_REQ 0x24
443 #define GTP_MSG_MS_PRESENT_RESP 0x25
444 #define GTP_MSG_IDENT_REQ 0x30
445 #define GTP_MSG_IDENT_RESP 0x31
446 #define GTP_MSG_SGSN_CNTXT_REQ 0x32
447 #define GTP_MSG_SGSN_CNTXT_RESP 0x33
448 #define GTP_MSG_SGSN_CNTXT_ACK 0x34
449 #define GTP_MSG_FORW_RELOC_REQ 0x35
450 #define GTP_MSG_FORW_RELOC_RESP 0x36
451 #define GTP_MSG_FORW_RELOC_COMP 0x37
452 #define GTP_MSG_RELOC_CANCEL_REQ 0x38
453 #define GTP_MSG_RELOC_CANCEL_RESP 0x39
454 #define GTP_MSG_FORW_SRNS_CNTXT 0x3A
455 #define GTP_MSG_FORW_RELOC_ACK 0x3B
456 #define GTP_MSG_FORW_SRNS_CNTXT_ACK 0x3C
457 #define GTP_MSG_DATA_TRANSF_REQ 0xF0
458 #define GTP_MSG_DATA_TRANSF_RESP 0xF1
459 #define GTP_MSG_TPDU 0xFF
461 static const value_string message_type[] = {
462 { GTP_MSG_UNKNOWN, "For future use" },
463 { GTP_MSG_ECHO_REQ, "Echo request" },
464 { GTP_MSG_ECHO_RESP, "Echo response" },
465 { GTP_MSG_VER_NOT_SUPP, "Version not supported" },
466 { GTP_MSG_NODE_ALIVE_REQ, "Node alive request" },
467 { GTP_MSG_NODE_ALIVE_RESP, "Node alive response" },
468 { GTP_MSG_REDIR_REQ, "Redirection request" },
469 { GTP_MSG_REDIR_RESP, "Redirection response" },
470 { GTP_MSG_CREATE_PDP_REQ, "Create PDP context request" },
471 { GTP_MSG_CREATE_PDP_RESP, "Create PDP context response" },
472 { GTP_MSG_UPDATE_PDP_REQ, "Update PDP context request" },
473 { GTP_MSG_UPDATE_PDP_RESP, "Update PDP context response" },
474 { GTP_MSG_DELETE_PDP_REQ, "Delete PDP context request" },
475 { GTP_MSG_DELETE_PDP_RESP, "Delete PDP context response" },
476 { GTP_MSG_CREATE_AA_PDP_REQ, "Create AA PDP Context Request" },
477 { GTP_MSG_CREATE_AA_PDP_RESP, "Create AA PDP Context Response" },
478 { GTP_MSG_DELETE_AA_PDP_REQ, "Delete AA PDP Context Request" },
479 { GTP_MSG_DELETE_AA_PDP_RESP, "Delete AA PDP Context Response" },
480 { GTP_MSG_ERR_IND, "Error indication" },
481 { GTP_MSG_PDU_NOTIFY_REQ, "PDU notification request" },
482 { GTP_MSG_PDU_NOTIFY_RESP, "PDU notification response" },
483 { GTP_MSG_PDU_NOTIFY_REJ_REQ, "PDU notification reject request" },
484 { GTP_MSG_PDU_NOTIFY_REJ_RESP, "PDU notification reject response" },
485 { GTP_MSG_SUPP_EXT_HDR, "Supported extension header notification" },
486 { GTP_MSG_SEND_ROUT_INFO_REQ, "Send routing information for GPRS request" },
487 { GTP_MSG_SEND_ROUT_INFO_RESP, "Send routing information for GPRS response" },
488 { GTP_MSG_FAIL_REP_REQ, "Failure report request" },
489 { GTP_MSG_FAIL_REP_RESP, "Failure report response" },
490 { GTP_MSG_MS_PRESENT_REQ, "Note MS GPRS present request" },
491 { GTP_MSG_MS_PRESENT_RESP, "Note MS GPRS present response" },
492 { GTP_MSG_IDENT_REQ, "Identification request" },
493 { GTP_MSG_IDENT_RESP, "Identification response" },
494 { GTP_MSG_SGSN_CNTXT_REQ, "SGSN context request" },
495 { GTP_MSG_SGSN_CNTXT_RESP, "SGSN context response" },
496 { GTP_MSG_SGSN_CNTXT_ACK, "SGSN context acknowledgement" },
497 { GTP_MSG_FORW_RELOC_REQ, "Forward relocation request" },
498 { GTP_MSG_FORW_RELOC_RESP, "Forward relocation response" },
499 { GTP_MSG_FORW_RELOC_COMP, "Forward relocation complete" },
500 { GTP_MSG_RELOC_CANCEL_REQ, "Relocation cancel request" },
501 { GTP_MSG_RELOC_CANCEL_RESP, "Relocation cancel response" },
502 { GTP_MSG_FORW_SRNS_CNTXT, "Forward SRNS context" },
503 { GTP_MSG_FORW_RELOC_ACK, "Forward relocation complete acknowledge" },
504 { GTP_MSG_FORW_SRNS_CNTXT_ACK, "Forward SRNS context acknowledge" },
505 { GTP_MSG_DATA_TRANSF_REQ, "Data record transfer request" },
506 { GTP_MSG_DATA_TRANSF_RESP, "Data record transfer response" },
507 { GTP_MSG_TPDU, "T-PDU" },
511 /* definitions of fields in extension header */
512 #define GTP_EXT_CAUSE 0x01
513 #define GTP_EXT_IMSI 0x02
514 #define GTP_EXT_RAI 0x03
515 #define GTP_EXT_TLLI 0x04
516 #define GTP_EXT_PTMSI 0x05
517 #define GTP_EXT_QOS_GPRS 0x06
518 #define GTP_EXT_REORDER 0x08
519 #define GTP_EXT_AUTH_TRI 0x09
520 #define GTP_EXT_MAP_CAUSE 0x0B
521 #define GTP_EXT_PTMSI_SIG 0x0C
522 #define GTP_EXT_MS_VALID 0x0D
523 #define GTP_EXT_RECOVER 0x0E
524 #define GTP_EXT_SEL_MODE 0x0F
526 #define GTP_EXT_16 0x10
527 #define GTP_EXT_FLOW_LABEL 0x10
528 #define GTP_EXT_TEID 0x10 /* 0xFF10 3G */
530 #define GTP_EXT_17 0x11
531 #define GTP_EXT_FLOW_SIG 0x11
532 #define GTP_EXT_TEID_CP 0x11 /* 0xFF11 3G */
534 #define GTP_EXT_18 0x12
535 #define GTP_EXT_FLOW_II 0x12
536 #define GTP_EXT_TEID_II 0x12 /* 0xFF12 3G*/
538 #define GTP_EXT_19 0x13
539 #define GTP_EXT_MS_REASON 0x13 /* same as 0x1D GTPv1_EXT_MS_REASON */
540 #define GTP_EXT_TEAR_IND 0x13 /* 0xFF13 3G*/
542 #define GTP_EXT_NSAPI 0x14 /* 3G */
543 #define GTP_EXT_RANAP_CAUSE 0x15 /* 3G */
544 #define GTP_EXT_RAB_CNTXT 0x16 /* 3G */
545 #define GTP_EXT_RP_SMS 0x17 /* 3G */
546 #define GTP_EXT_RP 0x18 /* 3G */
547 #define GTP_EXT_PKT_FLOW_ID 0x19 /* 3G */
548 #define GTP_EXT_CHRG_CHAR 0x1A /* 3G */
549 #define GTP_EXT_TRACE_REF 0x1B /* 3G */
550 #define GTP_EXT_TRACE_TYPE 0x1C /* 3G */
551 #define GTPv1_EXT_MS_REASON 0x1D /* 3G */
552 #define GTP_EXT_TR_COMM 0x7E /* charging */
553 #define GTP_EXT_CHRG_ID 0x7F
554 #define GTP_EXT_USER_ADDR 0x80
555 #define GTP_EXT_MM_CNTXT 0x81
556 #define GTP_EXT_PDP_CNTXT 0x82
557 #define GTP_EXT_APN 0x83
558 #define GTP_EXT_PROTO_CONF 0x84
559 #define GTP_EXT_GSN_ADDR 0x85
560 #define GTP_EXT_MSISDN 0x86
561 #define GTP_EXT_QOS_UMTS 0x87 /* 3G */
562 #define GTP_EXT_AUTH_QUI 0x88 /* 3G */
563 #define GTP_EXT_TFT 0x89 /* 3G */
564 #define GTP_EXT_TARGET_ID 0x8A /* 3G */
565 #define GTP_EXT_UTRAN_CONT 0x8B /* 3G */
566 #define GTP_EXT_RAB_SETUP 0x8C /* 3G */
567 #define GTP_EXT_HDR_LIST 0x8D /* 3G */
568 #define GTP_EXT_TRIGGER_ID 0x8E /* 3G */
569 #define GTP_EXT_OMC_ID 0x8F /* 3G */
570 #define GTP_EXT_REL_PACK 0xF9 /* charging */
571 #define GTP_EXT_CAN_PACK 0xFA /* charging */
572 #define GTP_EXT_CHRG_ADDR 0xFB
573 #define GTP_EXT_DATA_REQ 0xFC /* charging */
574 #define GTP_EXT_DATA_RESP 0xFD /* charging */
575 #define GTP_EXT_NODE_ADDR 0xFE /* charging */
576 #define GTP_EXT_PRIV_EXT 0xFF
578 static const value_string gtp_val[] = {
579 { GTP_EXT_CAUSE, "Cause of operation" },
580 { GTP_EXT_IMSI, "IMSI" },
581 { GTP_EXT_RAI, "Routing Area Identity" },
582 { GTP_EXT_TLLI, "Temporary Logical Link Identity" },
583 { GTP_EXT_PTMSI, "Packet TMSI" },
584 { GTP_EXT_QOS_GPRS, "Quality of Service" },
585 { GTP_EXT_REORDER, "Reorder required" },
586 { GTP_EXT_AUTH_TRI, "Authentication triplets" },
587 { GTP_EXT_MAP_CAUSE, "MAP cause" },
588 { GTP_EXT_PTMSI_SIG, "P-TMSI signature" },
589 { GTP_EXT_MS_VALID, "MS validated" },
590 { GTP_EXT_RECOVER, "Recovery" },
591 { GTP_EXT_SEL_MODE, "Selection mode" },
593 { GTP_EXT_16, "Flow label data I" },
594 { GTP_EXT_FLOW_LABEL, "Flow label data I" },
595 { GTP_EXT_TEID, "Tunnel Endpoint Identifier Data I" }, /* 3G */
597 { GTP_EXT_17, "Flow label signalling" },
598 { GTP_EXT_FLOW_SIG, "Flow label signalling" },
599 { GTP_EXT_TEID_CP, "Tunnel Endpoint Identifier Data Control Plane" }, /* 3G */
601 { GTP_EXT_18, "Flow label data II" },
602 { GTP_EXT_FLOW_II, "Flow label data II" },
603 { GTP_EXT_TEID_II, "Tunnel Endpoint Identifier Data II" }, /* 3G */
605 { GTP_EXT_19, "MS not reachable reason" },
606 { GTP_EXT_MS_REASON, "MS not reachable reason" },
607 { GTP_EXT_TEAR_IND, "Teardown ID" }, /* 3G */
609 { GTP_EXT_NSAPI, "NSAPI" }, /* 3G */
610 { GTP_EXT_RANAP_CAUSE, "RANAP cause" }, /* 3G */
611 { GTP_EXT_RAB_CNTXT, "RAB context" }, /* 3G */
612 { GTP_EXT_RP_SMS, "Radio Priority for MO SMS" }, /* 3G */
613 { GTP_EXT_RP, "Radio Priority" }, /* 3G */
614 { GTP_EXT_PKT_FLOW_ID, "Packet Flow ID" }, /* 3G */
615 { GTP_EXT_CHRG_CHAR, "Charging characteristics" }, /* 3G */
616 { GTP_EXT_TRACE_REF, "Trace references" }, /* 3G */
617 { GTP_EXT_TRACE_TYPE, "Trace type" }, /* 3G */
618 { GTPv1_EXT_MS_REASON, "MS not reachable reason" }, /* 3G */
619 { GTP_EXT_TR_COMM, "Packet transfer command" }, /* charging */
620 { GTP_EXT_CHRG_ID, "Charging ID" },
621 { GTP_EXT_USER_ADDR, "End user address" },
622 { GTP_EXT_MM_CNTXT, "MM context" },
623 { GTP_EXT_PDP_CNTXT, "PDP context" },
624 { GTP_EXT_APN, "Access Point Name" },
625 { GTP_EXT_PROTO_CONF, "Protocol configuration options" },
626 { GTP_EXT_GSN_ADDR, "GSN address" },
627 { GTP_EXT_MSISDN, "MS international PSTN/ISDN number" },
628 { GTP_EXT_QOS_UMTS, "Quality of service (UMTS)" }, /* 3G */
629 { GTP_EXT_AUTH_QUI, "Authentication quintuplets" }, /* 3G */
630 { GTP_EXT_TFT, "Traffic Flow Template (TFT)" }, /* 3G */
631 { GTP_EXT_TARGET_ID, "Target (RNC) identification" }, /* 3G */
632 { GTP_EXT_UTRAN_CONT, "UTRAN transparent field" }, /* 3G */
633 { GTP_EXT_RAB_SETUP, "RAB setup information" }, /* 3G */
634 { GTP_EXT_HDR_LIST, "Extension Header Types List" }, /* 3G */
635 { GTP_EXT_TRIGGER_ID, "Trigger Id" }, /* 3G */
636 { GTP_EXT_OMC_ID, "OMC Identity" }, /* 3G */
637 { GTP_EXT_REL_PACK, "Sequence numbers of released packets IE" }, /* charging */
638 { GTP_EXT_CAN_PACK, "Sequence numbers of canceled packets IE" }, /* charging */
639 { GTP_EXT_CHRG_ADDR, "Charging Gateway address" },
640 { GTP_EXT_DATA_REQ, "Data record packet" }, /* charging */
641 { GTP_EXT_DATA_RESP, "Requests responded" }, /* charging */
642 { GTP_EXT_NODE_ADDR, "Address of recommended node" }, /* charging */
643 { GTP_EXT_PRIV_EXT, "Private Extension" },
647 /* GPRS: 9.60 v7.6.0, page 37
648 * UMTS: 29.060 v4.0, page 45
650 static const value_string cause_type[] = {
651 { 0, "Request IMSI" },
652 { 1, "Request IMEI" },
653 { 2, "Request IMSI and IMEI" },
654 { 3, "No identity needed" },
656 { 5, "MS is not GPRS responding" },
657 { 59, "System failure" }, /* charging */
658 { 60, "The transmit buffers are becoming full" }, /* charging */
659 { 61, "The receive buffers are becoming full" }, /* charging */
660 { 62, "Another node is about to go down" }, /* charging */
661 { 63, "This node is about to go down" }, /* charging */
662 { 128, "Request accepted" },
663 { 192, "Non-existent" },
664 { 193, "Invalid message format" },
665 { 194, "IMSI not known" },
666 { 195, "MS is GPRS detached" },
667 { 196, "MS is not GPRS responding" },
668 { 197, "MS refuses" },
669 { 198, "Version not supported" },
670 { 199, "No resource available" },
671 { 200, "Service not supported" },
672 { 201, "Mandatory IE incorrect" },
673 { 202, "Mandatory IE missing" },
674 { 203, "Optional IE incorrect" },
675 { 204, "System failure" },
676 { 205, "Roaming restriction" },
677 { 206, "P-TMSI signature mismatch" },
678 { 207, "GPRS connection suspended" },
679 { 208, "Authentication failure" },
680 { 209, "User authentication failed" },
681 { 210, "Context not found" },
682 { 211, "All PDP dynamic addresses are occupied" },
683 { 212, "No memory is available" },
684 { 213, "Relocation failure" },
685 { 214, "Unknown mandatory extension header" },
686 { 215, "Semantic error in the TFT operation" },
687 { 216, "Syntactic error in the TFT operation" },
688 { 217, "Semantic errors in packet filter(s)" },
689 { 218, "Syntactic errors in packet filter(s)" },
690 { 219, "Missing or unknown APN" },
691 { 220, "Unknown PDP address or PDP type" },
692 { 252, "Request related to possibly duplicated packets already fulfilled" }, /* charging */
693 { 253, "Request already fulfilled" }, /* charging */
694 { 254, "Sequence numbers of released/cancelled packets IE incorrect" }, /* charging */
695 { 255, "Request not fulfilled" }, /* charging */
700 * UMTS: 29.002 v4.2.1, chapter 17.5, page 268
701 * TODO: Check if all map_cause values are included
703 static const value_string map_cause_type[] = {
704 { 1, "Unknown subscriber" },
705 { 8, "Roaming not allowed" },
706 { 10, "Bearer service not provisioned" },
707 { 11, "Teleservice not provisioned" },
708 { 13, "Call barred" },
709 { 21, "Facility not supported" },
710 { 23, "Update GPRS location" },
711 { 24, "Send routing info for GPRS" },
712 { 26, "Note MS present for GPRS" },
713 { 27, "Absent subscriber" },
714 { 34, "System failure" },
715 { 35, "Data missing" },
716 { 36, "Unexpected data value" },
717 { 44, "Number chenged" },
718 { 45, "Busy subscriber" },
719 { 46, "No subscriber reply" },
720 { 48, "Facility not allowed" },
724 static const value_string gsn_addr_type[] = {
730 static const value_string pdp_type[] = {
733 { 0x02, "OSP:IHOSS" },
739 static const value_string pdp_org_type[] = {
745 static const value_string qos_delay_type[] = {
746 { 0x00, "Subsribed delay class (in MS to network direction)" },
747 { 0x01, "Delay class 1" },
748 { 0x02, "Delay class 2" },
749 { 0x03, "Delay class 3" },
750 { 0x04, "Delay class 4 (best effort)" },
751 { 0x07, "Reserved" },
755 static const value_string qos_reliability_type[] = {
756 { 0x00, "Subscribed reliability class (in MS to network direction)" },
757 { 0x01, "Ack GTP/LLC/RLC, Protected data" },
758 { 0x02, "Unack GTP, Ack LLC/RLC, Protected data" },
759 { 0x03, "Unack GTP/LLC, Ack RLC, Protected data" },
760 { 0x04, "Unack GTP/LLC/RLC, Protected data" },
761 { 0x05, "Unack GTP/LLC/RLC, Unprotected data" },
762 { 0x07, "Reserved" },
766 static const value_string qos_peak_type[] = {
767 { 0x00, "Subscribed peak throughput (in MS to network direction)" },
768 { 0x01, "Up to 1 000 oct/s" },
769 { 0x02, "Up to 2 000 oct/s" },
770 { 0x03, "Up to 4 000 oct/s" },
771 { 0x04, "Up to 8 000 oct/s" },
772 { 0x05, "Up to 16 000 oct/s" },
773 { 0x06, "Up to 32 000 oct/s" },
774 { 0x07, "Up to 64 000 oct/s" },
775 { 0x08, "Up to 128 000 oct/s" },
776 { 0x09, "Up to 256 000 oct/s" },
777 /* QoS Peak throughput classes from 0x0A to 0x0F (from 10 to 15) are subscribed */
778 { 0x0A, "Reserved" },
779 { 0x0B, "Reserved" },
780 { 0x0C, "Reserved" },
781 { 0x0D, "Reserved" },
782 { 0x0E, "Reserved" },
783 { 0x0F, "Reserved" },
787 static const value_string qos_precedence_type[] = {
788 { 0x00, "Subscribed precedence (in MS to network direction)" },
789 { 0x01, "High priority" },
790 { 0x02, "Normal priority" },
791 { 0x03, "Low priority" },
792 { 0x07, "Reserved" },
796 static const value_string qos_mean_type[] = {
797 { 0x00, "Subscribed mean throughput (in MS to network direction)" },
798 { 0x01, "100 oct/h" }, /* Class 2 */
799 { 0x02, "200 oct/h" }, /* Class 3 */
800 { 0x03, "500 oct/h" }, /* Class 4 */
801 { 0x04, "1 000 oct/h" }, /* Class 5 */
802 { 0x05, "2 000 oct/h" }, /* Class 6 */
803 { 0x06, "5 000 oct/h" }, /* Class 7 */
804 { 0x07, "10 000 oct/h" }, /* Class 8 */
805 { 0x08, "20 000 oct/h" }, /* Class 9 */
806 { 0x09, "50 000 oct/h" }, /* Class 10 */
807 { 0x0A, "100 000 oct/h" }, /* Class 11 */
808 { 0x0B, "200 000 oct/h" }, /* Class 12 */
809 { 0x0C, "500 000 oct/h" }, /* Class 13 */
810 { 0x0D, "1 000 000 oct/h" }, /* Class 14 */
811 { 0x0E, "2 000 000 oct/h" }, /* Class 15 */
812 { 0x0F, "5 000 000 oct/h" }, /* Class 16 */
813 { 0x10, "10 000 000 oct/h" }, /* Class 17 */
814 { 0x11, "20 000 000 oct/h" }, /* Class 18 */
815 { 0x12, "50 000 000 oct/h" }, /* Class 19 */
816 /* QoS Mean throughput classes from 0x13 to 0x1E (from 19 to 30) are subscribed */
817 { 0x13, "Reserved" },
818 { 0x14, "Reserved" },
819 { 0x15, "Reserved" },
820 { 0x16, "Reserved" },
821 { 0x17, "Reserved" },
822 { 0x18, "Reserved" },
823 { 0x19, "Reserved" },
824 { 0x1A, "Reserved" },
825 { 0x1B, "Reserved" },
826 { 0x1C, "Reserved" },
827 { 0x1D, "Reserved" },
828 { 0x1E, "Reserved" },
829 { 0x1F, "Best effort" }, /* Class 1 */
833 static const value_string qos_del_err_sdu[] = {
834 { 0x00, "Subscribed delivery of erroneous SDUs (in MS to network direction)" },
835 { 0x01, "No detect ('-')" },
836 { 0x02, "Erroneous SDUs are delivered ('yes')" },
837 { 0x03, "Erroneous SDUs are not delivered ('no')" },
838 { 0x07, "Reserved" }, /* All other values are reserved */
842 static const value_string qos_del_order[] = {
843 { 0x00, "Subscribed delivery order (in MS to network direction)" },
844 { 0x01, "With delivery order ('yes')" },
845 { 0x02, "Without delivery order ('no')" },
846 { 0x03, "Reserved" }, /* All other values are reserved */
850 static const value_string qos_traf_class[] = {
851 { 0x00, "Subscribed traffic class (in MS to network direction)" },
852 { 0x01, "Conversational class" },
853 { 0x02, "Streaming class" },
854 { 0x03, "Interactive class" },
855 { 0x04, "Background class" },
856 { 0x07, "Reserved" }, /* All other values are reserved */
860 static const value_string qos_max_sdu_size[] = {
861 { 0x00, "Subscribed maximum SDU size (in MS to network direction" },
862 /* For values from 0x01 to 0x96 (from 1 to 150), use a granularity of 10 octets */
863 { 0x97, "1502 octets" },
864 { 0x98, "1510 octets" },
865 { 0x99, "1520 octets" },
866 { 0, NULL } /* All other values are reserved */
869 static const value_string qos_max_ul[] = {
870 { 0x00, "Subscribed maximum bit rate for uplink (in MS to network direction)" },
871 /* For values from 0x01 to 0x3F (from 1 to 63), use a granularity of 1 kbps */
872 /* For values from 0x40 to 0x7F, value = 64 kbps + (value - 0x40) * 8 kbps */
873 /* For values from 0x80 to 0xFE, value = 576 kbps + (value - 0x80) * 64 kbps */
878 static const value_string qos_max_dl[] = {
879 { 0x00, "Subscribed maximum bit rate for downlink (in MS to network direction)" },
880 /* For values from 0x01 to 0x3F (from 1 to 63), use a granularity of 1 kbps */
881 /* For values from 0x40 to 0x7F, value = 64 kbps + (value - 0x40) * 8 kbps */
882 /* For values from 0x80 to 0xFE, value = 576 kbps + (value - 0x80) * 64 kbps */
887 static const value_string qos_res_ber[] = {
888 { 0x00, "Subscribed residual BER (in MS to network direction)" },
889 { 0x01, "1/20 = 5x10^-2" },
890 { 0x02, "1/100 = 1x10^-2" },
891 { 0x03, "1/200 = 5x10^-3" },
892 { 0x04, "1/250 = 4x10^-3" },
893 { 0x05, "1/1 000 = 1x10^-3" },
894 { 0x06, "1/10 000 = 1x10^-4" },
895 { 0x07, "1/100 000 = 1x10^-5" },
896 { 0x08, "1/1 000 000 = 1x10^-6" },
897 { 0x09, "3/50 000 000 = 6x10^-8" },
898 { 0x0F, "Reserved" }, /* All other values are reserved */
902 static const value_string qos_sdu_err_ratio[] = {
903 { 0x00, "Subscribed SDU error ratio (in MS to network direction)" },
904 { 0x01, "1/100 = 1x10^-2" },
905 { 0x02, "7/1000 = 7x10^-3" },
906 { 0x03, "1/1 000 = 1x10^-3" },
907 { 0x04, "1/10 000 = 1x10^-4" },
908 { 0x05, "1/100 000 = 1x10^-5" },
909 { 0x06, "1/1 000 000 = 1x10^-6" },
910 { 0x07, "1/10 = 1x10^-1" },
911 { 0x0F, "Reserved" }, /* All other values are reserved */
915 static const value_string qos_traf_handl_prio[] = {
916 { 0x00, "Subscribed traffic handling priority (in MS to network direction)" },
917 { 0x01, "Priority level 1" },
918 { 0x02, "Priority level 2" },
919 { 0x03, "Priority level 3" },
923 static const value_string qos_trans_delay[] = {
924 { 0x00, "Subscribed Transfer Delay (in MS to network direction)" },
925 { 0x01, "10 ms" }, /* Using a granularity of 10 ms */
940 { 0x10, "200 ms" }, /* (For values from 0x10 to 0x1F, value = 200 ms + (value - 0x10) * 50 ms */
956 { 0x20, "1000 ms" }, /* For values from 0x20 to 0x3E, value = 1000 ms + (value - 0x20) * 100 ms */
991 static const value_string qos_guar_ul[] = {
992 { 0x00, "Subscribed guaranteed bit rate for uplink (in MS to network direction)" },
993 /* For values from 0x01 to 0x3F (from 1 to 63), use a granularity of 1 kbps */
994 /* For values from 0x40 to 0x7F, value = 64 kbps + (value - 0x40) * 8 kbps */
995 /* For values from 0x80 to 0xFE, value = 576 kbps + (value - 0x80) * 64 kbps */
1000 static const value_string qos_guar_dl[] = {
1001 { 0x00, "Subscribed guaranteed bit rate for downlink (in MS to network direction)" },
1002 /* For values from 0x01 to 0x3F (from 1 to 63), use a granularity of 1 kbps */
1003 /* For values from 0x40 to 0x7F, value = 64 kbps + (value - 0x40) * 8 kbps */
1004 /* For values from 0x80 to 0xFE, value = 576 kbps + (value - 0x80) * 64 kbps */
1009 static const value_string sel_mode_type[] = {
1010 { 0, "MS or network provided APN, subscribed verified" },
1011 { 1, "MS provided APN, subscription not verified" },
1012 { 2, "Network provided APN, subscription not verified" },
1013 { 3, "For future use (Network provided APN, subscription not verified" },/* Shall not be sent. If received, shall be sent as value 2 */
1017 static const value_string tr_comm_type[] = {
1018 { 1, "Send data record packet" },
1019 { 2, "Send possibly duplicated data record packet" },
1020 { 3, "Cancel data record packet" },
1021 { 4, "Release data record packet"},
1025 /* TODO: CHeck if all ms_reasons are included */
1026 static const value_string ms_not_reachable_type[] = {
1027 { 0, "No paging response via the MSC" },
1028 { 1, "IMSI detached" },
1029 { 2, "Roaming restriction" },
1030 { 3, "Deregistered in the HLR for non GPRS" },
1031 { 4, "MS purge for non GPRS" },
1032 { 5, "No paging response via the SGSN" },
1033 { 6, "GPRS detached" },
1034 { 7, "Deregistered in the HLR for non GPRS" },
1035 { 8, "MS purged for GPRS" },
1036 { 9, "Unidentified subscriber via the MSC" },
1037 { 10, "Unidentified subscriber via the SGSN" },
1041 /* UMTS: 25.413 v3.4.0, chapter 9.2.1.4, page 80
1043 static const value_string ranap_cause_type[] = {
1044 /* Radio Network Layer Cause (1-->64) */
1045 { 1, "RAB preempted" },
1046 { 2, "Trelocoverall Expiry" },
1047 { 3, "Trelocprep Expiry" },
1048 { 4, "Treloccomplete Expiry" },
1049 { 5, "Tqueing Expiry" },
1050 { 6, "Relocation Triggered" },
1051 { 7, "TRELOCalloc Expiry" },
1052 { 8, "Unable to Estabish During Relocation" },
1053 { 9, "Unknown Target RNC" },
1054 { 10, "Relocation Cancelled" },
1055 { 11, "Successful Relocation" },
1056 { 12, "Requested Ciphering and/or Integrity Protection Algorithms not Supported" },
1057 { 13, "Change of Ciphering and/or Integrity Protection is not supported" },
1058 { 14, "Failure in the Radio Interface Procedure" },
1059 { 15, "Release due to UTRAN Generated Reason" },
1060 { 16, "User Inactivity" },
1061 { 17, "Time Critical Relocation" },
1062 { 18, "Requested Traffic Class not Available" },
1063 { 19, "Invalid RAB Parameters Value" },
1064 { 20, "Requested Maximum Bit Rate not Available" },
1065 { 21, "Requested Guaranteed Bit Rate not Available" },
1066 { 22, "Requested Transfer Delay not Achievable" },
1067 { 23, "Invalid RAB Parameters Combination" },
1068 { 24, "Condition Violation for SDU Parameters" },
1069 { 25, "Condition Violation for Traffic Handling Priority" },
1070 { 26, "Condition Violation for Guaranteed Bit Rate" },
1071 { 27, "User Plane Versions not Supported" },
1072 { 28, "Iu UP Failure" },
1073 { 29, "Relocation Failure in Target CN/RNC or Target System" },
1074 { 30, "Invalid RAB ID" },
1075 { 31, "No Remaining RAB" },
1076 { 32, "Interaction with other procedure" },
1077 { 33, "Requested Maximum Bit Rate for DL not Available" },
1078 { 34, "Requested Maximum Bit Rate for UL not Available" },
1079 { 35, "Requested Guaranteed Bit Rate for DL not Available" },
1080 { 36, "Requested Guaranteed Bit Rate for UL not Available" },
1081 { 37, "Repeated Integrity Checking Failure" },
1082 { 38, "Requested Report Type not supported" },
1083 { 39, "Request superseded" },
1084 { 40, "Release due to UE generated signalling connection release" },
1085 { 41, "Resource Optimisation Relocation" },
1086 { 42, "Requested Information Not Available" },
1087 { 43, "Relocation desirable for radio reasons" },
1088 { 44, "Relocation not supported in Target RNC or Target System" },
1089 { 45, "Directed Retry" },
1090 { 46, "Radio Connection With UE Lost" },
1091 /* Transport Layer Cause (65-->80) */
1092 { 65, "Signalling Transport Resource Failure" },
1093 { 66, "Iu Transport Connection Failed to Establish" },
1094 /* NAS Cause (81-->96) */
1095 { 81, "User Restriction Start Indication" },
1096 { 82, "User Restriction End Indication" },
1097 { 83, "Normal Release" },
1098 /* Protocol Cause (97-->112) */
1099 { 97, "Transfer Syntax Error" },
1100 { 98, "Semantic Error" },
1101 { 99, "Message not compatible with receiver state" },
1102 { 100, "Abstract Syntax Error (Reject)" },
1103 { 101, "Abstract Syntax Error (Ignore and Notify)" },
1104 { 102, "Abstract Syntax Error (Falsely Constructed Message" },
1105 /* Miscellaneous Cause (113-->128) */
1106 { 113, "O & M Intervention" },
1107 { 114, "No Resource Available" },
1108 { 115, "Unspecified Failure" },
1109 { 116, "Network Opimisation" },
1110 /* Non-standard Cause (129-->255) */
1114 static const value_string mm_sec_modep[] = {
1115 { 0, "Used cipher value, UMTS keys and Quintuplets" },
1116 { 1, "GSM key and triplets" },
1117 { 2, "UMTS key and quintuplets" },
1118 { 3, "GSM key and quintuplets" },
1122 static const value_string mm_proto_disc[] = {
1123 { 0x00, "Group call control" },
1124 { 0x01, "Broadcast call control" },
1126 { 0x03, "Call control; call related SS messages" },
1128 { 0x05, "Mobility Management messages for non-GPRS services" },
1129 { 0x06, "Radio Resource management messages" },
1130 { 0x08, "Mobility Management messages for GPRS services" },
1132 { 0x0A, "Session Management messages" },
1133 { 0x0B, "Non-call related SS messages" },
1137 static const value_string mm_rr_mess[] = {
1138 { 0x3C, "RR initialization request" },
1139 { 0x3B, "Additional assignment" },
1140 { 0x3F, "Immediate assignment" },
1141 { 0x39, "Immediate assignment extended" },
1142 { 0x3A, "Immediate assignment reject" },
1144 { 0x35, "Ciphering mode command" },
1145 { 0x32, "Ciphering mode complete" },
1147 { 0x30, "Configuration change command" },
1148 { 0x31, "Configuration change ack" },
1149 { 0x33, "Configuration change reject" },
1151 { 0x2E, "Assignment command" },
1152 { 0x29, "Assignment complete" },
1153 { 0x2F, "Assigment failure" },
1154 { 0x2B, "Handover command" },
1155 { 0x2C, "Handover complete" },
1156 { 0x28, "Handover failure" },
1157 { 0x2D, "Physical information" },
1159 { 0x08, "RR-cell change order" },
1160 { 0x23, "PDCH assignment command" },
1162 { 0x0D, "Channel release" },
1163 { 0x0A, "Partial release" },
1164 { 0x0F, "PArtial release complete" },
1166 { 0x21, "Paging request type 1" },
1167 { 0x22, "Paging request type 2" },
1168 { 0x24, "Paging request type 3" },
1169 { 0x27, "Paging response" },
1170 { 0x20, "Notification/NCH" },
1171 { 0x25, "Notification/FACCH" },
1172 { 0x26, "Reserved" },
1173 { 0x0B, "Reserved" },
1175 { 0x18, "System information type 8" },
1176 { 0x19, "System information type 1" },
1177 { 0x1A, "System information type 2" },
1178 { 0x1B, "System information type 3" },
1179 { 0x1C, "System information type 4" },
1180 { 0x1D, "System information type 5" },
1181 { 0x1E, "System information type 6" },
1182 { 0x1F, "System information type 7" },
1184 { 0x02, "System information type 2bis" },
1185 { 0x03, "System information type 2ter" },
1186 { 0x05, "System information type 5bis" },
1187 { 0x06, "System information type 5ter" },
1188 { 0x04, "System information 9" },
1189 { 0x00, "System information 13" },
1190 { 0x01, "System information 14" },
1192 { 0x3D, "System information type 16" },
1193 { 0x3E, "System information type 17" },
1195 { 0x10, "Channel mode modify" },
1196 { 0x12, "RR status" },
1197 { 0x17, "Channel mode modify ack" },
1198 { 0x14, "Frequency redefinition" },
1199 { 0x15, "Measurement report" },
1200 { 0x16, "Classmark change" },
1201 { 0x13, "Classmark enquiry" },
1202 { 0x36, "Extended measurement report" },
1203 { 0x37, "Extended measurement order" },
1204 { 0x34, "GPRS suspension request" },
1206 { 0x09, "VGCS uplink grant" },
1207 { 0x0E, "Uplink release" },
1208 { 0x0C, "Uplink free" },
1209 { 0x2A, "Uplink busy" },
1210 { 0x11, "Talker indication" },
1215 static const value_string mm_mm_mess[] = {
1216 { 0x01, "IMSI DETACH INDICATION" },
1217 { 0x02, "LOCATION UPDATING ACCEPT" },
1218 { 0x04, "LOCATION UPDATING REJECT" },
1219 { 0x08, "LOCATION UPDATING REQUEST" },
1220 { 0x11, "AUTHENTICATION REJECT" },
1221 { 0x12, "AUTHENTICATION REQUEST" },
1222 { 0x14, "AUTHENTICATION RESPONSE" },
1223 { 0x18, "IDENTITY REQUEST" },
1224 { 0x19, "IDENTITY RESPONSE" },
1225 { 0x1A, "TMSI REALLOCATION COMMAND" },
1226 { 0x1B, "TMSI REALLOCATION COMPLETE" },
1227 { 0x21, "CM SERVICE ACCEPT" },
1228 { 0x22, "CM SERVICE REJECT" },
1229 { 0x23, "CM SERVICE ABORT" },
1230 { 0x24, "CM SERVICE REQUEST" },
1231 { 0x25, "CM SERVICE PROMPT" },
1232 { 0x26, "NOTIFICATION RESPONSE" },
1233 { 0x28, "CM RE-ESTABLISHMENT REQUEST" },
1235 { 0x30, "MM NULL" },
1236 { 0x31, "MM STATUS" },
1237 { 0x32, "MM INFORMATION" },
1241 static const value_string mm_cc_mess[] = {
1242 { 0x00, "escape to nationally specific" },
1243 /*{ 0 x 0 0, "- - - Call establishment messages:" },*/
1244 { 0x01, "ALERTING" },
1245 { 0x08, "CALL CONFIRMED" },
1246 { 0x02, "CALL PROCEEDING" },
1247 { 0x07, "CONNECT" },
1248 { 0x0F, "CONNECT ACKNOWLEDGE" },
1249 { 0x0E, "EMERGENCY SETUP" },
1250 { 0x03, "PROGRESS" },
1251 { 0x04, "CC-ESTABLISHMENT" },
1252 { 0x06, "CC-ESTABLISHMENT CONFIRMED" },
1254 { 0x09, "START CC" },
1256 /*{ 0 x 0 1, "- - - Call information phase messages:" },*/
1258 { 0x1F, "MODIFY COMPLETE" },
1259 { 0x13, "MODIFY REJECT" },
1260 { 0x10, "USER INFORMATION" },
1262 { 0x19, "HOLD ACKNOWLEDGE" },
1263 { 0x1A, "HOLD REJECT" },
1264 { 0x1C, "RETRIEVE" },
1265 { 0x1D, "RETRIEVE ACKNOWLEDGE" },
1266 { 0x1E, "RETRIEVE REJECT" },
1267 /*{ 0 x 1 0, "- - - Call clearing messages:" },*/
1268 { 0x25, "DISCONNECT" },
1269 { 0x2D, "RELEASE" },
1270 { 0x2A, "RELEASE COMPLETE" },
1271 /*{ 0 x 1 1, "- - - Miscellaneous messages:" },*/
1272 { 0x39, "CONGESTION CONTROL" },
1275 { 0x34, "STATUS ENQUIRY" },
1276 { 0x35, "START DTMF" },
1277 { 0x31, "STOP DTMF" },
1278 { 0x32, "STOP DTMF ACKNOWLEDGE" },
1279 { 0x36, "START DTMF ACKNOWLEDGE" },
1280 { 0x37, "START DTMF REJECT" },
1281 { 0x3A, "FACILITY" },
1285 static const value_string mm_gprs_mess[] = {
1286 { 0x01, "Attach request" },
1287 { 0x02, "Attach accept" },
1288 { 0x03, "Attach complete" },
1289 { 0x04, "Attach reject" },
1290 { 0x05, "Detach request" },
1291 { 0x06, "Detach accept" },
1292 { 0x08, "Routing area update request" },
1293 { 0x09, "Routing area update accept" },
1294 { 0x0A, "Routing area update complete" },
1295 { 0x0B, "Routing area update reject" },
1296 { 0x10, "P-TMSI reallocation command" },
1297 { 0x11, "P-TMSI reallocation complete" },
1298 { 0x12, "Authentication and ciphering req" },
1299 { 0x13, "Authentication and ciphering resp" },
1300 { 0x14, "Authentication and ciphering rej" },
1301 { 0x15, "Identity request" },
1302 { 0x16, "Identity response" },
1303 { 0x20, "GMM status" },
1304 { 0x21, "GMM information" },
1308 static const value_string tft_code_type[] = {
1310 { 1, "Create new TFT" },
1311 { 2, "Delete existing TFT" },
1312 { 3, "Add packet filters to existing TFT" },
1313 { 4, "Replace packet filters in existing TFT" },
1314 { 5, "Delete packet filters from existing TFT" },
1320 static const value_string cdr_close_type[] = {
1321 { 0, "PDP release" },
1322 { 1, "Volume limit" },
1323 { 2, "Time limit" },
1324 { 3, "SGSN change" },
1325 { 4, "Max changes" },
1326 { 6, "Management" },
1331 static dissector_handle_t ip_handle;
1332 static dissector_handle_t ipv6_handle;
1333 static dissector_handle_t ppp_handle;
1334 static dissector_handle_t data_handle;
1336 static int decode_gtp_cause (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1337 static int decode_gtp_imsi (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1338 static int decode_gtp_rai (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1339 static int decode_gtp_tlli (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1340 static int decode_gtp_ptmsi (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1341 static int decode_gtp_qos_gprs (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1342 static int decode_gtp_reorder (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1343 static int decode_gtp_auth_tri (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1344 static int decode_gtp_map_cause (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1345 static int decode_gtp_ptmsi_sig (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1346 static int decode_gtp_ms_valid (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1347 static int decode_gtp_recovery (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1348 static int decode_gtp_sel_mode (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1349 static int decode_gtp_16 (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1350 static int decode_gtp_17 (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1351 static int decode_gtp_18 (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1352 static int decode_gtp_19 (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1353 static int decode_gtp_nsapi (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1354 static int decode_gtp_ranap_cause (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1355 static int decode_gtp_rab_cntxt (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1356 static int decode_gtp_rp_sms (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1357 static int decode_gtp_rp (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1358 static int decode_gtp_pkt_flow_id (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1359 static int decode_gtp_chrg_char (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1360 static int decode_gtp_trace_ref (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1361 static int decode_gtp_trace_type (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1362 static int decode_gtp_ms_reason (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1363 static int decode_gtp_tr_comm (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1364 static int decode_gtp_chrg_id (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1365 static int decode_gtp_user_addr (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1366 static int decode_gtp_mm_cntxt (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1367 static int decode_gtp_pdp_cntxt (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1368 static int decode_gtp_apn (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1369 static int decode_gtp_gsn_addr (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1370 static int decode_gtp_proto_conf (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1371 static int decode_gtp_msisdn (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1372 static int decode_gtp_qos_umts (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1373 static int decode_gtp_auth_qui (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1374 static int decode_gtp_tft (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1375 static int decode_gtp_target_id (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1376 static int decode_gtp_utran_cont (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1377 static int decode_gtp_rab_setup (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1378 static int decode_gtp_hdr_list (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1379 static int decode_gtp_trigger_id (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1380 static int decode_gtp_omc_id (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1381 static int decode_gtp_chrg_addr (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1382 static int decode_gtp_rel_pack (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1383 static int decode_gtp_can_pack (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1384 static int decode_gtp_data_req (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1385 static int decode_gtp_data_resp (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1386 static int decode_gtp_node_addr (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1387 static int decode_gtp_priv_ext (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1388 static int decode_gtp_unknown (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1390 typedef struct _gtp_opt {
1393 int (*decode)(tvbuff_t *, int, packet_info *, proto_tree *);
1396 static const gtp_opt_t gtpopt[] = {
1397 { GTP_EXT_CAUSE, decode_gtp_cause },
1398 { GTP_EXT_IMSI, decode_gtp_imsi },
1399 { GTP_EXT_RAI, decode_gtp_rai },
1400 { GTP_EXT_TLLI, decode_gtp_tlli },
1401 { GTP_EXT_PTMSI, decode_gtp_ptmsi },
1402 { GTP_EXT_QOS_GPRS, decode_gtp_qos_gprs },
1403 { GTP_EXT_REORDER, decode_gtp_reorder },
1404 { GTP_EXT_AUTH_TRI, decode_gtp_auth_tri },
1405 { GTP_EXT_MAP_CAUSE, decode_gtp_map_cause },
1406 { GTP_EXT_PTMSI_SIG, decode_gtp_ptmsi_sig },
1407 { GTP_EXT_MS_VALID, decode_gtp_ms_valid },
1408 { GTP_EXT_RECOVER, decode_gtp_recovery },
1409 { GTP_EXT_SEL_MODE, decode_gtp_sel_mode },
1410 { GTP_EXT_16, decode_gtp_16 },
1411 { GTP_EXT_17, decode_gtp_17 },
1412 { GTP_EXT_18, decode_gtp_18 },
1413 { GTP_EXT_19, decode_gtp_19 },
1414 { GTP_EXT_NSAPI, decode_gtp_nsapi },
1415 { GTP_EXT_RANAP_CAUSE, decode_gtp_ranap_cause },
1416 { GTP_EXT_RAB_CNTXT, decode_gtp_rab_cntxt },
1417 { GTP_EXT_RP_SMS, decode_gtp_rp_sms },
1418 { GTP_EXT_RP, decode_gtp_rp },
1419 { GTP_EXT_PKT_FLOW_ID, decode_gtp_pkt_flow_id },
1420 { GTP_EXT_CHRG_CHAR, decode_gtp_chrg_char },
1421 { GTP_EXT_TRACE_REF, decode_gtp_trace_ref },
1422 { GTP_EXT_TRACE_TYPE, decode_gtp_trace_type },
1423 { GTPv1_EXT_MS_REASON, decode_gtp_ms_reason },
1424 { GTP_EXT_TR_COMM, decode_gtp_tr_comm },
1425 { GTP_EXT_CHRG_ID, decode_gtp_chrg_id },
1426 { GTP_EXT_USER_ADDR, decode_gtp_user_addr },
1427 { GTP_EXT_MM_CNTXT, decode_gtp_mm_cntxt },
1428 { GTP_EXT_PDP_CNTXT, decode_gtp_pdp_cntxt },
1429 { GTP_EXT_APN, decode_gtp_apn },
1430 { GTP_EXT_PROTO_CONF, decode_gtp_proto_conf },
1431 { GTP_EXT_GSN_ADDR, decode_gtp_gsn_addr },
1432 { GTP_EXT_MSISDN, decode_gtp_msisdn },
1433 { GTP_EXT_QOS_UMTS, decode_gtp_qos_umts }, /* 3G */
1434 { GTP_EXT_AUTH_QUI, decode_gtp_auth_qui }, /* 3G */
1435 { GTP_EXT_TFT, decode_gtp_tft }, /* 3G */
1436 { GTP_EXT_TARGET_ID, decode_gtp_target_id }, /* 3G */
1437 { GTP_EXT_UTRAN_CONT, decode_gtp_utran_cont }, /* 3G */
1438 { GTP_EXT_RAB_SETUP, decode_gtp_rab_setup }, /* 3G */
1439 { GTP_EXT_HDR_LIST, decode_gtp_hdr_list }, /* 3G */
1440 { GTP_EXT_TRIGGER_ID, decode_gtp_trigger_id }, /* 3G */
1441 { GTP_EXT_OMC_ID, decode_gtp_omc_id }, /* 3G */
1442 { GTP_EXT_REL_PACK, decode_gtp_rel_pack }, /* charging */
1443 { GTP_EXT_CAN_PACK, decode_gtp_can_pack }, /* charging */
1444 { GTP_EXT_CHRG_ADDR, decode_gtp_chrg_addr },
1445 { GTP_EXT_DATA_REQ, decode_gtp_data_req }, /* charging */
1446 { GTP_EXT_DATA_RESP, decode_gtp_data_resp }, /* charging */
1447 { GTP_EXT_NODE_ADDR, decode_gtp_node_addr },
1448 { GTP_EXT_PRIV_EXT, decode_gtp_priv_ext },
1449 { 0, decode_gtp_unknown }
1470 static struct gcdr_ { /* GCDR 118B */
1491 typedef struct change_ {
1501 static struct _scdr { /* SCDR 277B */
1511 guint8 msclass_notused[12];
1512 guint8 msclass_caplen;
1514 guint16 msclass_capomit;
1539 typedef struct mmchange_ {
1546 static struct _mcdr { /* MCDR 147B */
1554 guint8 msclass_notused[12];
1555 guint8 msclass_caplen;
1557 guint16 msclass_capomit;
1561 guint8 change_count;
1562 mmchange_t change[5];
1565 /* guint8 opening[8]; */
1577 static struct _socdr { /* SOCDR 80B */
1584 guint8 msclass_notused[12];
1585 guint8 msclass_caplen;
1587 guint16 msclass_capomit;
1588 guint8 serv_centr[9];
1600 static struct _stcdr { /* STCDR 79B */
1607 guint8 msclass_notused[12];
1608 guint8 msclass_caplen;
1610 guint16 msclass_capomit;
1611 guint8 serv_centr[9];
1621 static guint8 gtp_version = 0;
1622 static char *yesno[] = { "False", "True" };
1625 col_append_str_gtp(column_info *cinfo, gint el, gchar *proto_name) {
1629 gchar _tmp[COL_MAX_LEN];
1631 max_len = COL_MAX_LEN;
1633 for (i = 0; i < cinfo->num_cols; i++) {
1634 if (cinfo->fmt_matx[i][el]) {
1635 if (cinfo->col_data[i] != cinfo->col_buf[i]) {
1637 strncpy(cinfo->col_buf[i], cinfo->col_data[i], max_len);
1638 cinfo->col_buf[i][max_len - 1] = '\0';
1642 strcat(_tmp, proto_name);
1644 strcat(_tmp, cinfo->col_buf[i]);
1646 cinfo->col_buf[i][0] = '\0';
1647 strcat(cinfo->col_buf[i], _tmp);
1648 cinfo->col_data[i] = cinfo->col_buf[i];
1654 id_to_str(const guint8 *ad) {
1656 static gchar *str[17];
1658 guint8 bits8to5, bits4to1, i;
1659 static const gchar hex_digits[10] = "0123456789";
1661 p = (gchar *)&str[17];
1665 bits8to5 = (ad[i] >> 4) & 0x0F;
1666 bits4to1 = ad[i] & 0x0F;
1667 if (bits8to5 < 0xA) *--p = hex_digits[bits8to5];
1668 if (bits4to1 < 0xA) *--p = hex_digits[bits4to1];
1676 imsi_to_str(const guint8 *ad) {
1678 static gchar *str[16];
1682 p = (gchar *)&str[0];
1684 if ((ad[i] & 0x0F) <= 9) p[j++] = (ad[i] & 0x0F) + 0x30;
1685 if (((ad[i] >> 4) & 0x0F) <= 9) p[j++] = ((ad[i] >> 4) & 0x0F) + 0x30;
1693 msisdn_to_str(const guint8 *ad, int len) {
1695 static gchar *str[17];
1697 guint8 bits8to5, bits4to1, i;
1698 static const gchar hex_digits[16] = "0123456789 ";
1700 p = (gchar *)&str[0];
1704 bits8to5 = (ad[i] >> 4) & 0x0F;
1705 bits4to1 = ad[i] & 0x0F;
1706 if (bits4to1 < 0xA) *++p = hex_digits[bits4to1];
1707 if (bits8to5 < 0xA) *++p = hex_digits[bits8to5];
1708 if (i == len-1) break;
1712 return (gchar *)&str[0];
1716 time_int_to_str (guint32 time)
1724 return abs_time_to_str (&nstime);
1728 rel_time_int_to_str (guint32 time)
1736 return rel_time_to_str (&nstime);
1739 /* Next definitions and function check_field_presence checks if given field
1740 * in GTP packet is compliant with ETSI
1742 typedef struct _header {
1747 typedef struct _message {
1749 ext_header fields[32];
1752 /* ---------------------
1754 * ---------------------*/
1755 static _gtp_mess_items gprs_mess_items[] = {
1759 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1764 GTP_MSG_ECHO_RESP, {
1765 { GTP_EXT_RECOVER, GTP_MANDATORY },
1766 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1771 GTP_MSG_VER_NOT_SUPP, {
1776 GTP_MSG_NODE_ALIVE_REQ, {
1777 { GTP_EXT_NODE_ADDR, GTP_MANDATORY },
1778 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1783 GTP_MSG_NODE_ALIVE_RESP, {
1784 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1789 GTP_MSG_REDIR_REQ, {
1790 { GTP_EXT_CAUSE, GTP_MANDATORY },
1791 { GTP_EXT_NODE_ADDR, GTP_OPTIONAL },
1792 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1797 GTP_MSG_REDIR_RESP, {
1798 { GTP_EXT_CAUSE, GTP_MANDATORY },
1799 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1804 GTP_MSG_CREATE_PDP_REQ, {
1805 { GTP_EXT_QOS_GPRS, GTP_MANDATORY },
1806 { GTP_EXT_RECOVER, GTP_OPTIONAL },
1807 { GTP_EXT_SEL_MODE, GTP_MANDATORY },
1808 { GTP_EXT_FLOW_LABEL, GTP_MANDATORY },
1809 { GTP_EXT_FLOW_SIG, GTP_MANDATORY },
1810 { GTP_EXT_MSISDN, GTP_MANDATORY },
1811 { GTP_EXT_USER_ADDR, GTP_MANDATORY },
1812 { GTP_EXT_APN, GTP_MANDATORY },
1813 { GTP_EXT_PROTO_CONF, GTP_OPTIONAL },
1814 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
1815 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
1816 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1821 GTP_MSG_CREATE_PDP_RESP, {
1822 { GTP_EXT_CAUSE, GTP_MANDATORY },
1823 { GTP_EXT_QOS_GPRS, GTP_CONDITIONAL },
1824 { GTP_EXT_REORDER, GTP_CONDITIONAL },
1825 { GTP_EXT_RECOVER, GTP_OPTIONAL },
1826 { GTP_EXT_FLOW_LABEL, GTP_CONDITIONAL },
1827 { GTP_EXT_FLOW_SIG, GTP_CONDITIONAL },
1828 { GTP_EXT_CHRG_ID, GTP_CONDITIONAL },
1829 { GTP_EXT_USER_ADDR, GTP_CONDITIONAL },
1830 { GTP_EXT_PROTO_CONF, GTP_OPTIONAL },
1831 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
1832 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
1833 { GTP_EXT_CHRG_ADDR, GTP_OPTIONAL },
1834 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1839 GTP_MSG_UPDATE_PDP_REQ, {
1840 { GTP_EXT_QOS_GPRS, GTP_MANDATORY },
1841 { GTP_EXT_RECOVER, GTP_OPTIONAL },
1842 { GTP_EXT_FLOW_LABEL, GTP_MANDATORY },
1843 { GTP_EXT_FLOW_SIG, GTP_MANDATORY },
1844 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
1845 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
1846 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1851 GTP_MSG_UPDATE_PDP_RESP, {
1852 { GTP_EXT_CAUSE, GTP_MANDATORY },
1853 { GTP_EXT_QOS_GPRS, GTP_CONDITIONAL },
1854 { GTP_EXT_RECOVER, GTP_OPTIONAL },
1855 { GTP_EXT_FLOW_LABEL, GTP_CONDITIONAL },
1856 { GTP_EXT_FLOW_SIG, GTP_CONDITIONAL },
1857 { GTP_EXT_CHRG_ID, GTP_CONDITIONAL },
1858 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
1859 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
1860 { GTP_EXT_CHRG_ADDR, GTP_OPTIONAL },
1861 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1866 GTP_MSG_DELETE_PDP_REQ, {
1867 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1872 GTP_MSG_DELETE_PDP_RESP, {
1873 { GTP_EXT_CAUSE, GTP_MANDATORY },
1874 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1879 GTP_MSG_CREATE_AA_PDP_REQ, {
1880 { GTP_EXT_QOS_GPRS, GTP_MANDATORY },
1881 { GTP_EXT_RECOVER, GTP_OPTIONAL },
1882 { GTP_EXT_SEL_MODE, GTP_MANDATORY },
1883 { GTP_EXT_FLOW_LABEL, GTP_MANDATORY },
1884 { GTP_EXT_FLOW_SIG, GTP_MANDATORY },
1885 { GTP_EXT_USER_ADDR, GTP_MANDATORY },
1886 { GTP_EXT_APN, GTP_MANDATORY },
1887 { GTP_EXT_PROTO_CONF, GTP_OPTIONAL },
1888 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
1889 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
1890 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1895 GTP_MSG_CREATE_AA_PDP_RESP, {
1896 { GTP_EXT_CAUSE, GTP_MANDATORY },
1897 { GTP_EXT_QOS_GPRS, GTP_CONDITIONAL },
1898 { GTP_EXT_REORDER, GTP_CONDITIONAL },
1899 { GTP_EXT_RECOVER, GTP_OPTIONAL },
1900 { GTP_EXT_FLOW_LABEL, GTP_CONDITIONAL },
1901 { GTP_EXT_FLOW_SIG, GTP_CONDITIONAL },
1902 { GTP_EXT_CHRG_ID, GTP_CONDITIONAL },
1903 { GTP_EXT_USER_ADDR, GTP_CONDITIONAL },
1904 { GTP_EXT_PROTO_CONF, GTP_OPTIONAL },
1905 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
1906 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
1907 { GTP_EXT_CHRG_ADDR, GTP_OPTIONAL },
1908 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1913 GTP_MSG_DELETE_AA_PDP_REQ, {
1914 { GTP_EXT_CAUSE, GTP_MANDATORY },
1915 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1920 GTP_MSG_DELETE_AA_PDP_RESP, {
1921 { GTP_EXT_CAUSE, GTP_MANDATORY },
1922 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1928 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1933 GTP_MSG_PDU_NOTIFY_REQ, {
1934 { GTP_EXT_USER_ADDR, GTP_MANDATORY },
1935 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1940 GTP_MSG_PDU_NOTIFY_RESP, {
1941 { GTP_EXT_CAUSE, GTP_MANDATORY },
1942 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1947 GTP_MSG_PDU_NOTIFY_REJ_REQ, {
1948 { GTP_EXT_CAUSE, GTP_MANDATORY },
1949 { GTP_EXT_USER_ADDR, GTP_MANDATORY },
1950 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1955 GTP_MSG_PDU_NOTIFY_REJ_RESP, {
1956 { GTP_EXT_CAUSE, GTP_MANDATORY },
1957 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1962 GTP_MSG_SEND_ROUT_INFO_REQ, {
1963 { GTP_EXT_IMSI, GTP_MANDATORY },
1964 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1969 GTP_MSG_SEND_ROUT_INFO_RESP, {
1970 { GTP_EXT_CAUSE, GTP_MANDATORY },
1971 { GTP_EXT_IMSI, GTP_MANDATORY },
1972 { GTP_EXT_MAP_CAUSE, GTP_OPTIONAL },
1973 { GTP_EXT_MS_REASON, GTP_OPTIONAL },
1974 { GTP_EXT_GSN_ADDR, GTP_OPTIONAL },
1975 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1980 GTP_MSG_FAIL_REP_REQ, {
1981 { GTP_EXT_IMSI, GTP_MANDATORY },
1982 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1987 GTP_MSG_FAIL_REP_RESP, {
1988 { GTP_EXT_CAUSE, GTP_MANDATORY },
1989 { GTP_EXT_MAP_CAUSE, GTP_OPTIONAL },
1990 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1995 GTP_MSG_MS_PRESENT_REQ, {
1996 { GTP_EXT_IMSI, GTP_MANDATORY },
1997 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
1998 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2003 GTP_MSG_MS_PRESENT_RESP, {
2004 { GTP_EXT_CAUSE, GTP_MANDATORY },
2005 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2010 GTP_MSG_IDENT_REQ, {
2011 { GTP_EXT_RAI, GTP_MANDATORY },
2012 { GTP_EXT_PTMSI, GTP_MANDATORY },
2013 { GTP_EXT_PTMSI_SIG, GTP_OPTIONAL },
2014 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2019 GTP_MSG_IDENT_RESP, {
2020 { GTP_EXT_CAUSE, GTP_MANDATORY },
2021 { GTP_EXT_IMSI, GTP_CONDITIONAL },
2022 { GTP_EXT_AUTH_TRI, GTP_OPTIONAL },
2023 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2028 GTP_MSG_SGSN_CNTXT_REQ, {
2029 { GTP_EXT_IMSI, GTP_CONDITIONAL },
2030 { GTP_EXT_RAI, GTP_MANDATORY },
2031 { GTP_EXT_TLLI, GTP_MANDATORY },
2032 { GTP_EXT_PTMSI_SIG, GTP_OPTIONAL },
2033 { GTP_EXT_MS_VALID, GTP_OPTIONAL },
2034 { GTP_EXT_FLOW_SIG, GTP_MANDATORY },
2039 GTP_MSG_SGSN_CNTXT_RESP, {
2040 { GTP_EXT_CAUSE, GTP_MANDATORY },
2041 { GTP_EXT_IMSI, GTP_CONDITIONAL },
2042 { GTP_EXT_FLOW_SIG, GTP_CONDITIONAL },
2043 { GTP_EXT_MM_CNTXT, GTP_CONDITIONAL },
2044 { GTP_EXT_PDP_CNTXT, GTP_CONDITIONAL },
2045 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2050 GTP_MSG_SGSN_CNTXT_ACK, {
2051 { GTP_EXT_CAUSE, GTP_MANDATORY },
2052 { GTP_EXT_FLOW_II, GTP_CONDITIONAL },
2053 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
2054 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2059 GTP_MSG_DATA_TRANSF_REQ, {
2060 { GTP_EXT_TR_COMM, GTP_MANDATORY },
2061 { GTP_EXT_DATA_REQ, GTP_CONDITIONAL },
2062 { GTP_EXT_REL_PACK, GTP_CONDITIONAL },
2063 { GTP_EXT_CAN_PACK, GTP_CONDITIONAL },
2064 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2069 GTP_MSG_DATA_TRANSF_RESP, {
2070 { GTP_EXT_CAUSE, GTP_MANDATORY },
2071 { GTP_EXT_DATA_RESP, GTP_MANDATORY },
2072 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2083 /* -----------------------------
2085 * -----------------------------*/
2086 static _gtp_mess_items umts_mess_items[] = {
2090 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2095 GTP_MSG_ECHO_RESP, {
2096 { GTP_EXT_RECOVER, GTP_MANDATORY },
2097 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2102 GTP_MSG_VER_NOT_SUPP, {
2107 GTP_MSG_NODE_ALIVE_REQ, {
2108 { GTP_EXT_NODE_ADDR, GTP_MANDATORY },
2109 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2114 GTP_MSG_NODE_ALIVE_RESP, {
2115 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2120 GTP_MSG_REDIR_REQ, {
2121 { GTP_EXT_CAUSE, GTP_MANDATORY },
2122 { GTP_EXT_NODE_ADDR, GTP_OPTIONAL },
2123 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2128 GTP_MSG_REDIR_REQ, {
2133 GTP_MSG_CREATE_PDP_REQ, {
2134 { GTP_EXT_IMSI, GTP_CONDITIONAL },
2135 { GTP_EXT_RECOVER, GTP_OPTIONAL },
2136 { GTP_EXT_SEL_MODE, GTP_CONDITIONAL },
2137 { GTP_EXT_TEID, GTP_MANDATORY },
2138 { GTP_EXT_TEID_CP, GTP_CONDITIONAL },
2139 { GTP_EXT_NSAPI, GTP_MANDATORY },
2140 { GTP_EXT_NSAPI, GTP_CONDITIONAL },
2141 { GTP_EXT_CHRG_CHAR, GTP_OPTIONAL },
2142 { GTP_EXT_TRACE_REF, GTP_OPTIONAL },
2143 { GTP_EXT_TRACE_TYPE, GTP_OPTIONAL },
2144 { GTP_EXT_USER_ADDR, GTP_CONDITIONAL },
2145 { GTP_EXT_APN, GTP_CONDITIONAL },
2146 { GTP_EXT_PROTO_CONF, GTP_CONDITIONAL },
2147 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
2148 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
2149 { GTP_EXT_MSISDN, GTP_CONDITIONAL },
2150 { GTP_EXT_QOS_UMTS, GTP_MANDATORY },
2151 { GTP_EXT_TFT, GTP_CONDITIONAL },
2152 { GTP_EXT_TRIGGER_ID, GTP_OPTIONAL },
2153 { GTP_EXT_OMC_ID, GTP_OPTIONAL },
2154 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2159 GTP_MSG_CREATE_PDP_RESP, {
2160 { GTP_EXT_CAUSE, GTP_MANDATORY },
2161 { GTP_EXT_REORDER, GTP_CONDITIONAL },
2162 { GTP_EXT_RECOVER, GTP_OPTIONAL },
2163 { GTP_EXT_TEID, GTP_CONDITIONAL },
2164 { GTP_EXT_TEID_CP, GTP_CONDITIONAL },
2165 { GTP_EXT_CHRG_ID, GTP_CONDITIONAL },
2166 { GTP_EXT_USER_ADDR, GTP_CONDITIONAL },
2167 { GTP_EXT_PROTO_CONF, GTP_OPTIONAL },
2168 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
2169 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
2170 { GTP_EXT_QOS_UMTS, GTP_CONDITIONAL },
2171 { GTP_EXT_CHRG_ADDR, GTP_OPTIONAL },
2172 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2176 { /* checked, SGSN -> GGSN */
2177 GTP_MSG_UPDATE_PDP_REQ, {
2178 { GTP_EXT_IMSI, GTP_CONDITIONAL },
2179 { GTP_EXT_RECOVER, GTP_OPTIONAL },
2180 { GTP_EXT_TEID, GTP_MANDATORY },
2181 { GTP_EXT_TEID_CP, GTP_CONDITIONAL },
2182 { GTP_EXT_NSAPI, GTP_MANDATORY },
2183 { GTP_EXT_TRACE_REF, GTP_OPTIONAL },
2184 { GTP_EXT_TRACE_TYPE, GTP_OPTIONAL },
2185 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
2186 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
2187 { GTP_EXT_QOS_UMTS, GTP_MANDATORY },
2188 { GTP_EXT_TFT, GTP_OPTIONAL },
2189 { GTP_EXT_TRIGGER_ID, GTP_OPTIONAL },
2190 { GTP_EXT_OMC_ID, GTP_OPTIONAL },
2191 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2195 { /* checked, GGSN -> SGSN */
2196 GTP_MSG_UPDATE_PDP_RESP, {
2197 { GTP_EXT_CAUSE, GTP_MANDATORY },
2198 { GTP_EXT_RECOVER, GTP_OPTIONAL },
2199 { GTP_EXT_TEID, GTP_CONDITIONAL },
2200 { GTP_EXT_TEID_CP, GTP_CONDITIONAL },
2201 { GTP_EXT_CHRG_ID, GTP_CONDITIONAL },
2202 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
2203 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
2204 { GTP_EXT_QOS_UMTS, GTP_CONDITIONAL },
2205 { GTP_EXT_CHRG_ADDR, GTP_OPTIONAL },
2206 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2211 GTP_MSG_DELETE_PDP_REQ, {
2212 { GTP_EXT_TEAR_IND, GTP_CONDITIONAL },
2213 { GTP_EXT_NSAPI, GTP_MANDATORY },
2214 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2219 GTP_MSG_DELETE_PDP_RESP, {
2220 { GTP_EXT_CAUSE, GTP_MANDATORY },
2221 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2227 { GTP_EXT_TEID, GTP_MANDATORY },
2228 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2233 GTP_MSG_PDU_NOTIFY_REQ, {
2234 { GTP_EXT_IMSI, GTP_MANDATORY },
2235 { GTP_EXT_TEID_CP, GTP_MANDATORY },
2236 { GTP_EXT_USER_ADDR, GTP_MANDATORY },
2237 { GTP_EXT_APN, GTP_MANDATORY },
2238 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
2239 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2244 GTP_MSG_PDU_NOTIFY_RESP, {
2245 { GTP_EXT_CAUSE, GTP_MANDATORY },
2246 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2251 GTP_MSG_PDU_NOTIFY_REJ_REQ, {
2252 { GTP_EXT_CAUSE, GTP_MANDATORY },
2253 { GTP_EXT_TEID_CP, GTP_MANDATORY },
2254 { GTP_EXT_USER_ADDR, GTP_MANDATORY },
2255 { GTP_EXT_APN, GTP_MANDATORY },
2256 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2261 GTP_MSG_PDU_NOTIFY_REJ_RESP, {
2262 { GTP_EXT_CAUSE, GTP_MANDATORY },
2263 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2268 GTP_MSG_SUPP_EXT_HDR, {
2269 { GTP_EXT_HDR_LIST, GTP_MANDATORY },
2274 GTP_MSG_SEND_ROUT_INFO_REQ, {
2275 { GTP_EXT_IMSI, GTP_MANDATORY },
2276 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2281 GTP_MSG_SEND_ROUT_INFO_RESP, {
2282 { GTP_EXT_CAUSE, GTP_MANDATORY },
2283 { GTP_EXT_IMSI, GTP_MANDATORY },
2284 { GTP_EXT_MAP_CAUSE, GTP_OPTIONAL },
2285 { GTPv1_EXT_MS_REASON, GTP_OPTIONAL },
2286 { GTP_EXT_GSN_ADDR, GTP_OPTIONAL },
2287 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2292 GTP_MSG_FAIL_REP_REQ, {
2293 { GTP_EXT_IMSI, GTP_MANDATORY },
2294 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2299 GTP_MSG_FAIL_REP_RESP, {
2300 { GTP_EXT_CAUSE, GTP_MANDATORY },
2301 { GTP_EXT_MAP_CAUSE, GTP_OPTIONAL },
2302 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2307 GTP_MSG_MS_PRESENT_REQ, {
2308 { GTP_EXT_IMSI, GTP_MANDATORY },
2309 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
2310 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2315 GTP_MSG_MS_PRESENT_RESP, {
2316 { GTP_EXT_CAUSE, GTP_MANDATORY },
2317 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2322 GTP_MSG_IDENT_REQ, {
2323 { GTP_EXT_RAI, GTP_MANDATORY },
2324 { GTP_EXT_PTMSI, GTP_MANDATORY },
2325 { GTP_EXT_PTMSI_SIG, GTP_CONDITIONAL },
2326 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2331 GTP_MSG_IDENT_RESP, {
2332 { GTP_EXT_CAUSE, GTP_MANDATORY },
2333 { GTP_EXT_IMSI, GTP_CONDITIONAL },
2334 { GTP_EXT_AUTH_TRI, GTP_CONDITIONAL },
2335 { GTP_EXT_AUTH_QUI, GTP_CONDITIONAL },
2336 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2341 GTP_MSG_SGSN_CNTXT_REQ, {
2342 { GTP_EXT_IMSI, GTP_CONDITIONAL },
2343 { GTP_EXT_RAI, GTP_MANDATORY },
2344 { GTP_EXT_TLLI, GTP_CONDITIONAL },
2345 { GTP_EXT_PTMSI, GTP_CONDITIONAL },
2346 { GTP_EXT_PTMSI_SIG, GTP_CONDITIONAL },
2347 { GTP_EXT_MS_VALID, GTP_OPTIONAL },
2348 { GTP_EXT_TEID_CP, GTP_MANDATORY },
2349 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
2350 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2355 GTP_MSG_SGSN_CNTXT_RESP, {
2356 { GTP_EXT_CAUSE, GTP_MANDATORY },
2357 { GTP_EXT_IMSI, GTP_CONDITIONAL },
2358 { GTP_EXT_TEID_CP, GTP_CONDITIONAL },
2359 { GTP_EXT_RP_SMS, GTP_OPTIONAL },
2360 { GTP_EXT_RP, GTP_OPTIONAL },
2361 { GTP_EXT_PKT_FLOW_ID, GTP_OPTIONAL },
2362 { GTP_EXT_MM_CNTXT, GTP_CONDITIONAL },
2363 { GTP_EXT_PDP_CNTXT, GTP_CONDITIONAL },
2364 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
2365 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2370 GTP_MSG_SGSN_CNTXT_ACK, {
2371 { GTP_EXT_CAUSE, GTP_MANDATORY },
2372 { GTP_EXT_TEID_II, GTP_CONDITIONAL },
2373 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
2374 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2379 GTP_MSG_FORW_RELOC_REQ, {
2380 { GTP_EXT_IMSI, GTP_MANDATORY },
2381 { GTP_EXT_TEID_CP, GTP_MANDATORY },
2382 { GTP_EXT_RANAP_CAUSE, GTP_MANDATORY },
2383 { GTP_EXT_MM_CNTXT, GTP_MANDATORY },
2384 { GTP_EXT_PDP_CNTXT, GTP_CONDITIONAL },
2385 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
2386 { GTP_EXT_TARGET_ID, GTP_MANDATORY },
2387 { GTP_EXT_UTRAN_CONT, GTP_MANDATORY },
2388 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2393 GTP_MSG_FORW_RELOC_RESP, {
2394 { GTP_EXT_CAUSE, GTP_MANDATORY },
2395 { GTP_EXT_TEID_CP, GTP_CONDITIONAL },
2396 { GTP_EXT_RANAP_CAUSE, GTP_CONDITIONAL },
2397 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
2398 { GTP_EXT_UTRAN_CONT, GTP_OPTIONAL },
2399 { GTP_EXT_RAB_SETUP, GTP_CONDITIONAL },
2400 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2405 GTP_MSG_FORW_RELOC_COMP, {
2406 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2411 GTP_MSG_RELOC_CANCEL_REQ, {
2412 { GTP_EXT_IMSI, GTP_MANDATORY },
2413 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2418 GTP_MSG_RELOC_CANCEL_RESP, {
2419 { GTP_EXT_CAUSE, GTP_MANDATORY },
2420 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2425 GTP_MSG_FORW_RELOC_ACK, {
2426 { GTP_EXT_CAUSE, GTP_MANDATORY },
2427 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2432 GTP_MSG_FORW_SRNS_CNTXT, {
2433 { GTP_EXT_RAB_CNTXT, GTP_MANDATORY },
2434 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2439 GTP_MSG_FORW_SRNS_CNTXT_ACK, {
2440 { GTP_EXT_CAUSE, GTP_MANDATORY },
2441 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
2453 check_field_presence(guint8 message, guint8 field, int *position) {
2456 _gtp_mess_items *mess_items;
2458 switch(gtp_version) {
2460 mess_items = gprs_mess_items;
2463 mess_items = umts_mess_items;
2469 while (mess_items[i].code) {
2470 if (mess_items[i].code == message) {
2472 while (mess_items[i].fields[*position].code) {
2473 if (mess_items[i].fields[*position].code == field) {
2477 if (mess_items[i].fields[*position].presence == GTP_MANDATORY) {
2478 return mess_items[i].fields[(*position)++].code;
2491 /* Decoders of fields in extension headers, each function returns no of bytes from field */
2493 /* GPRS: 9.60 v7.6.0, chapter
2494 * UMTS: 29.060 v4.0, chapter
2497 decode_gtp_cause(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2501 cause = tvb_get_guint8(tvb, offset+1);
2503 proto_tree_add_uint(tree, gtp_version ? hf_gtpv1_cause : hf_gtpv0_cause, tvb, offset, 2, cause);
2508 /* GPRS: 9.60 v7.6.0, chapter 7.9.2
2509 * UMTS: 29.060 v4.0, chapter 7.7.2
2512 decode_gtp_imsi(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2517 tvb_memcpy(tvb, imsi_val, offset+1, 8);
2518 imsi_str = imsi_to_str (imsi_val);
2520 proto_tree_add_string(tree, gtp_version ? hf_gtpv1_imsi : hf_gtpv0_imsi, tvb, offset, 9, imsi_str);
2525 /* GPRS: 9.60 v7.6.0, chapter 7.9.3
2526 * UMTS: 29.060 v4.0, chapter 7.7.3
2527 * TODO: Add details about MCC, MNC, LAC, RAC (show each digit) ?
2530 decode_gtp_rai(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2532 proto_tree *ext_tree_rai;
2536 te = proto_tree_add_text(tree, tvb, offset, 1, val_to_str(GTP_EXT_RAI, gtp_val, "Unknown message"));
2537 ext_tree_rai = proto_item_add_subtree(te, ett_gtp_rai);
2539 /* tvb_memcpy (tvb, (guint8 *)&byte, offset + 1, 3); */
2540 byte[1] = tvb_get_guint8 (tvb, offset + 1);
2541 byte[2] = tvb_get_guint8 (tvb, offset + 2);
2542 byte[3] = tvb_get_guint8 (tvb, offset + 3);
2545 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 ));
2546 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));
2547 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));
2548 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));
2553 /* GPRS: 9.60 v7.6.0, chapter 7.9.4, page 39
2554 * UMTS: 29.060 v4.0, chapter 7.7.4, page 47
2557 decode_gtp_tlli(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2561 tlli = tvb_get_ntohl(tvb, offset+1);
2562 proto_tree_add_uint(tree, gtp_version ? hf_gtpv1_tlli : hf_gtpv0_tlli, tvb, offset, 5, tlli);
2567 /* GPRS: 9.60 v7.6.0, chapter 7.9.5, page 39
2568 * UMTS: 29.060 v4.0, chapter 7.7.5, page 47
2571 decode_gtp_ptmsi(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2575 ptmsi = tvb_get_ntohl(tvb, offset);
2576 proto_tree_add_uint(tree, gtp_version ? hf_gtpv1_ptmsi : hf_gtpv0_ptmsi, tvb, offset, 5, ptmsi);
2581 /* adjust - how many bytes before offset should be highlighted
2584 decode_qos_gprs(tvbuff_t *tvb, int offset, proto_tree *tree, gchar* qos_str, guint8 adjust) {
2586 guint8 spare1, delay, reliability, peak, spare2, precedence, spare3, mean;
2587 proto_tree *ext_tree_qos;
2590 spare1 = tvb_get_guint8(tvb, offset) & 0xC0;
2591 delay = tvb_get_guint8(tvb, offset) & 0x38;
2592 reliability = tvb_get_guint8(tvb, offset) & 0x07;
2593 peak = tvb_get_guint8(tvb, offset+1) & 0xF0;
2594 spare2 = tvb_get_guint8(tvb, offset+1) & 0x08;
2595 precedence = tvb_get_guint8(tvb, offset+1) & 0x07;
2596 spare3 = tvb_get_guint8(tvb, offset+2) & 0xE0;
2597 mean = tvb_get_guint8(tvb, offset+2) & 0x1F;
2599 te = proto_tree_add_text(tree, tvb, offset-adjust, 3+adjust, "%s: delay: %u, reliability: %u, peak: %u, precedence: %u, mean: %u",
2600 qos_str, delay, reliability, peak, precedence, mean);
2601 ext_tree_qos = proto_item_add_subtree(te, ett_gtp_qos);
2604 proto_tree_add_uint(ext_tree_qos, hf_gtpv0_qos_spare1, tvb, offset, 1, spare1);
2605 proto_tree_add_uint(ext_tree_qos, hf_gtpv0_qos_delay, tvb, offset, 1, delay);
2606 proto_tree_add_uint(ext_tree_qos, hf_gtpv0_qos_reliability, tvb, offset, 1, reliability);
2607 proto_tree_add_uint(ext_tree_qos, hf_gtpv0_qos_peak, tvb, offset+1, 1, peak);
2608 proto_tree_add_uint(ext_tree_qos, hf_gtpv0_qos_spare2, tvb, offset+1, 1, spare2);
2609 proto_tree_add_uint(ext_tree_qos, hf_gtpv0_qos_precedence, tvb, offset+1, 1, precedence);
2610 proto_tree_add_uint(ext_tree_qos, hf_gtpv0_qos_spare3, tvb, offset+2, 1, spare3);
2611 proto_tree_add_uint(ext_tree_qos, hf_gtpv0_qos_mean, tvb, offset+2, 1, mean);
2617 /* GPRS: 9.60 v7.6.0, chapter 7.9.6, page 39
2621 * TODO: check if length is included: ETSI 4.08 vs 9.60
2624 decode_gtp_qos_gprs(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2626 return (1+decode_qos_gprs(tvb, offset+1, tree, "Quality of Service", 1));
2630 /* GPRS: 9.60 v7.6.0, chapter 7.9.7, page 39
2631 * UMTS: 29.060 v4.0, chapter 7.7.6, page 47
2634 decode_gtp_reorder(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2638 reorder = tvb_get_guint8(tvb, offset+1) & 0x01;
2639 proto_tree_add_boolean(tree, gtp_version ? hf_gtpv1_reorder : hf_gtpv0_reorder, tvb, offset, 2, reorder);
2644 /* GPRS: 9.60 v7.6.0, chapter 7.9.8, page 40
2645 * 4.08 v7.1.2, chapter 10.5.3.1+
2646 * UMTS: 29.060 v4.0, chapter 7.7.7
2647 * TODO: Add blurb support by registering items in the protocol registration
2650 decode_gtp_auth_tri(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2652 proto_tree *ext_tree_auth_tri;
2655 te = proto_tree_add_text(tree, tvb, offset, 29, val_to_str(GTP_EXT_AUTH_TRI, gtp_val, "Unknown message"));
2656 ext_tree_auth_tri = proto_item_add_subtree(tree, ett_gtp_auth_tri);
2658 proto_tree_add_text(ext_tree_auth_tri, tvb, offset+1, 16, "RAND: %s", tvb_bytes_to_str(tvb, offset+1, 16));
2659 proto_tree_add_text(ext_tree_auth_tri, tvb, offset+17, 4, "SRES: %s", tvb_bytes_to_str(tvb, offset+17, 4));
2660 proto_tree_add_text(ext_tree_auth_tri, tvb, offset+21, 8, "Kc: %s", tvb_bytes_to_str(tvb, offset+21, 8));
2665 /* GPRS: 9.60 v7.6.0, chapter 7.9.9, page 40
2666 * 9.02 v7.7.0, page 1090
2667 * UMTS: 29.060 v4.0, chapter 7.7.8, page 48
2668 * 29.002 v4.2.1, chapter 17.5, page 268
2671 decode_gtp_map_cause(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2675 map_cause = tvb_get_guint8(tvb, offset+1);
2676 proto_tree_add_uint(tree, gtp_version ? hf_gtpv1_map_cause : hf_gtpv0_map_cause, tvb, offset, 2, map_cause);
2681 /* GPRS: 9.60 v7.6.0, chapter 7.9.10, page 41
2682 * UMTS: 29.060 v4.0, chapter 7.7.9, page 48
2685 decode_gtp_ptmsi_sig(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2689 ptmsi_sig = tvb_get_ntoh24(tvb, offset+1);
2690 proto_tree_add_uint(tree, gtp_version ? hf_gtpv1_ptmsi_sig : hf_gtpv0_ptmsi_sig, tvb, offset, 4, ptmsi_sig);
2695 /* GPRS: 9.60 v7.6.0, chapter 7.9.11, page 41
2696 * UMTS: 29.060 v4.0, chapter 7.7.10, page 49
2699 decode_gtp_ms_valid(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2703 ms_valid = tvb_get_guint8(tvb, offset+1) & 0x01;
2704 proto_tree_add_boolean(tree, gtp_version ? hf_gtpv1_ms_valid : hf_gtpv0_ms_valid, tvb, offset, 2, ms_valid);
2709 /* GPRS: 9.60 v7.6.0, chapter 7.9.12, page 41
2710 * UMTS: 29.060 v4.0, chapter 7.7.11, page 49
2713 decode_gtp_recovery(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2717 recovery = tvb_get_guint8(tvb, offset+1);
2718 proto_tree_add_uint(tree, gtp_version ? hf_gtpv1_recovery : hf_gtpv0_recovery, tvb, offset, 2, recovery);
2723 /* GPRS: 9.60 v7.6.0, chapter 7.9.13, page 42
2724 * UMTS: 29.060 v4.0, chapter 7.7.12, page 49
2727 decode_gtp_sel_mode(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2731 sel_mode = tvb_get_guint8(tvb, offset+1) & 0x03;
2732 proto_tree_add_uint(tree, gtp_version ? hf_gtpv1_sel_mode : hf_gtpv0_sel_mode, tvb, offset, 2, sel_mode);
2737 /* GPRS: 9.60 v7.6.0, chapter 7.9.14, page 42
2738 * UMTS: 29.060 v4.0, chapter 7.7.13, page 50
2741 decode_gtp_16(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2743 guint16 ext_flow_label;
2746 switch (gtp_version) {
2748 ext_flow_label = tvb_get_ntohs(tvb, offset+1);
2749 proto_tree_add_uint(tree, hf_gtpv0_ext_flow_label, tvb, offset, 3, ext_flow_label);
2753 teid_data = tvb_get_ntohl(tvb, offset+1);
2754 proto_tree_add_uint(tree, hf_gtpv1_teid_data, tvb, offset, 5, teid_data);
2758 proto_tree_add_text(tree, tvb, offset, 1, "Flow label/TEID Data I : GTP version not supported");
2764 /* GPRS: 9.60 v7.6.0, chapter 7.9.15, page 42
2765 * UMTS: 29.060 v4.0, chapter 7.7.14, page 42
2768 decode_gtp_17(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2773 switch (gtp_version) {
2775 flow_sig = tvb_get_ntohs(tvb, offset+1);
2776 proto_tree_add_uint(tree, hf_gtpv0_flow_sig, tvb, offset, 3, flow_sig);
2780 teid_cp = tvb_get_ntohl(tvb, offset+1);
2781 proto_tree_add_uint(tree, hf_gtpv1_teid_cp, tvb, offset, 5, teid_cp);
2785 proto_tree_add_text(tree, tvb, offset, 1, "Flow label signalling/TEID control plane : GTP version not supported");
2791 /* GPRS: 9.60 v7.6.0, chapter 7.9.16, page 42
2792 * UMTS: 29.060 v4.0, chapter 7.7.15, page 51
2795 decode_gtp_18(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2799 proto_tree *ext_tree_flow_ii;
2802 switch (gtp_version) {
2804 te = proto_tree_add_text(tree, tvb, offset, 4, val_to_str(GTP_EXT_FLOW_II, gtp_val, "Unknown message"));
2805 ext_tree_flow_ii = proto_item_add_subtree(te, ett_gtp_flow_ii);
2807 proto_tree_add_uint(ext_tree_flow_ii, hf_gtpv0_nsapi, tvb, offset+1, 1, tvb_get_guint8(tvb, offset+1) & 0x0F);
2809 flow_ii = tvb_get_ntohs(tvb, offset+2);
2810 proto_tree_add_uint(ext_tree_flow_ii, hf_gtpv0_flow_ii, tvb, offset+2, 2, flow_ii);
2814 te = proto_tree_add_text(tree, tvb, offset, 6, val_to_str(GTP_EXT_TEID_II, gtp_val, "Unknown message"));
2815 ext_tree_flow_ii = proto_item_add_subtree(te, ett_gtp_flow_ii);
2817 proto_tree_add_uint(ext_tree_flow_ii, hf_gtpv1_nsapi, tvb, offset+1, 1, tvb_get_guint8(tvb, offset+1) & 0x0F);
2820 teid_ii = tvb_get_ntohl(tvb, offset+2);
2821 proto_tree_add_uint(ext_tree_flow_ii, hf_gtpv1_teid_ii, tvb, offset+2, 4, teid_ii);
2825 proto_tree_add_text(tree, tvb, offset, 1, "Flow data II/TEID Data II : GTP Version not supported");
2831 /* GPRS: 9.60 v7.6.0, chapter 7.9.16A, page 43
2832 * UMTS: 29.060 v4.0, chapter 7.7.16, page 51
2833 * Check if all ms_reason types are included
2836 decode_gtp_19(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2840 field19 = tvb_get_guint8(tvb, offset+1);
2842 switch (gtp_version) {
2844 proto_tree_add_uint(tree, hf_gtpv0_ms_reason, tvb, offset, 2, field19);
2848 proto_tree_add_boolean(tree, hf_gtpv1_tear_ind, tvb, offset, 2, field19 & 0x01);
2852 proto_tree_add_text(tree, tvb, offset, 1, "Information Element Type = 19 : GTP Version not supported");
2860 /* GPRS: not present
2861 * UMTS: 29.060 v4.0, chapter 7.7.17, page 51
2864 decode_gtp_nsapi(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2868 nsapi = tvb_get_guint8(tvb, offset+1) & 0x0F;
2869 proto_tree_add_uint(tree, hf_gtpv1_nsapi, tvb, offset, 2, nsapi);
2874 /* GPRS: not present
2875 * UMTS: 29.060 v4.0, chapter 7.7.18, page 52
2878 decode_gtp_ranap_cause(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2882 ranap = tvb_get_guint8(tvb, offset+1);
2884 if(ranap > 0 && ranap <=64)
2885 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);
2887 if(ranap > 64 && ranap <=80)
2888 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);
2890 if(ranap > 80 && ranap <=96)
2891 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);
2893 if(ranap > 96 && ranap <=112)
2894 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);
2896 if(ranap > 112 && ranap <=128)
2897 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);
2899 if(ranap > 128 && ranap <=255)
2900 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);
2905 /* GPRS: not present
2906 * UMTS: 29.060 v4.0, chapter 7.7.19, page 52
2909 decode_gtp_rab_cntxt(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2911 guint8 nsapi, dl_pdcp_seq, ul_pdcp_seq;
2912 guint16 dl_gtpu_seq, ul_gtpu_seq;
2913 proto_tree *ext_tree_rab_cntxt;
2916 te = proto_tree_add_text(tree, tvb, offset, 8, val_to_str(GTP_EXT_RAB_CNTXT, gtp_val, "Unknown message"));
2917 ext_tree_rab_cntxt = proto_item_add_subtree(te, ett_gtp_rab_cntxt);
2919 nsapi = tvb_get_guint8(tvb, offset+1) & 0x0F;
2920 dl_gtpu_seq = tvb_get_ntohs(tvb, offset+2);
2921 ul_gtpu_seq = tvb_get_ntohs(tvb, offset+4);
2922 dl_pdcp_seq = tvb_get_guint8(tvb, offset+6);
2923 ul_pdcp_seq = tvb_get_guint8(tvb, offset+7);
2925 proto_tree_add_uint(ext_tree_rab_cntxt, hf_gtpv1_nsapi, tvb, offset+1, 1, nsapi);
2926 proto_tree_add_uint(ext_tree_rab_cntxt, hf_gtpv1_rab_gtpu_dn, tvb, offset+2, 2, dl_gtpu_seq);
2927 proto_tree_add_uint(ext_tree_rab_cntxt, hf_gtpv1_rab_gtpu_up, tvb, offset+4, 2, ul_gtpu_seq);
2928 proto_tree_add_uint(ext_tree_rab_cntxt, hf_gtpv1_rab_pdu_dn, tvb, offset+6, 1, dl_pdcp_seq);
2929 proto_tree_add_uint(ext_tree_rab_cntxt, hf_gtpv1_rab_pdu_up, tvb, offset+7, 1, ul_pdcp_seq);
2935 /* GPRS: not present
2936 * UMTS: 29.060 v4.0, chapter 7.7.20, page 53
2939 decode_gtp_rp_sms(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2943 rp_sms = tvb_get_guint8(tvb, offset+1) & 0x07;
2944 proto_tree_add_uint(tree, hf_gtpv1_rp_sms, tvb, offset, 2, rp_sms);
2949 /* GPRS: not present
2950 * UMTS: 29.060 v4.0, chapter 7.7.21, page 53
2953 decode_gtp_rp(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2955 proto_tree *ext_tree_rp;
2957 guint8 nsapi, rp, spare;
2959 nsapi = tvb_get_guint8(tvb, offset+1) & 0xF0;
2960 spare = tvb_get_guint8(tvb, offset+1) & 0x08;
2961 rp = tvb_get_guint8(tvb, offset+1) & 0x07;
2963 te = proto_tree_add_uint_format(tree, hf_gtpv1_rp, tvb, offset, 2, rp, "Radio Priority for NSAPI(%u) : %u", nsapi, rp);
2964 ext_tree_rp = proto_item_add_subtree(tree, ett_gtp_rp);
2966 proto_tree_add_uint(ext_tree_rp, hf_gtpv1_rp_nsapi, tvb, offset+1, 1, nsapi);
2967 proto_tree_add_uint(ext_tree_rp, hf_gtpv1_rp_spare, tvb, offset+1, 1, spare);
2968 proto_tree_add_uint(ext_tree_rp, hf_gtpv1_rp, tvb, offset+1, 1, rp);
2973 /* GPRS: not present
2974 * UMTS: 29.060 v4.0, chapter 7.7.22, page 53
2977 decode_gtp_pkt_flow_id(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2979 proto_tree *ext_tree_pkt_flow_id;
2981 guint8 nsapi, pkt_flow_id;
2983 nsapi = tvb_get_guint8(tvb, offset+1) & 0x0F;
2984 pkt_flow_id = tvb_get_guint8(tvb, offset+2);
2986 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);
2987 ext_tree_pkt_flow_id = proto_item_add_subtree(tree, ett_gtp_pkt_flow_id);
2989 proto_tree_add_uint(ext_tree_pkt_flow_id, hf_gtpv1_nsapi, tvb, offset+1, 1, nsapi);
2990 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);
2995 /* GPRS: not present
2996 * UMTS: 29.060 v4.0, chapter 7.7.23, page 53
2997 * TODO: Differenciate these uints?
3000 decode_gtp_chrg_char(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3004 proto_tree *ext_tree_chrg_char;
3006 chrg_char = tvb_get_ntohs(tvb, offset+1);
3008 te = proto_tree_add_text(tree, tvb, offset, 3, "%s: %x", val_to_str(GTP_EXT_CHRG_CHAR, gtp_val, "Unknown message"), chrg_char);
3009 ext_tree_chrg_char = proto_item_add_subtree(te, ett_gtp_chrg_char);
3011 proto_tree_add_uint(ext_tree_chrg_char, hf_gtpv1_chrg_char_s, tvb, offset+1, 2, chrg_char);
3012 proto_tree_add_uint(ext_tree_chrg_char, hf_gtpv1_chrg_char_n, tvb, offset+1, 2, chrg_char);
3013 proto_tree_add_uint(ext_tree_chrg_char, hf_gtpv1_chrg_char_p, tvb, offset+1, 2, chrg_char);
3014 proto_tree_add_uint(ext_tree_chrg_char, hf_gtpv1_chrg_char_f, tvb, offset+1, 2, chrg_char);
3015 proto_tree_add_uint(ext_tree_chrg_char, hf_gtpv1_chrg_char_h, tvb, offset+1, 2, chrg_char);
3016 proto_tree_add_uint(ext_tree_chrg_char, hf_gtpv1_chrg_char_r, tvb, offset+1, 2, chrg_char);
3021 /* GPRS: not present
3022 * UMTS: 29.060 v4.0, chapter 7.7.24, page
3025 decode_gtp_trace_ref(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3029 trace_ref = tvb_get_ntohs(tvb, offset+1);
3031 proto_tree_add_uint(tree, hf_gtpv1_trace_ref, tvb, offset, 3, trace_ref);
3036 /* GPRS: not present
3037 * UMTS: 29.060 v4.0, chapter 7.7.25, page
3040 decode_gtp_trace_type(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3044 trace_type = tvb_get_ntohs(tvb, offset+1);
3046 proto_tree_add_uint(tree, hf_gtpv1_trace_type, tvb, offset, 3, trace_type);
3051 /* GPRS: 9.60 v7.6.0, chapter 7.9.16A
3052 * UMTS: 29.060 v4.0, chapter 7.7.25A, page
3055 decode_gtp_ms_reason(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3059 reason = tvb_get_guint8(tvb, offset+1);
3061 proto_tree_add_uint(tree, gtp_version ? hf_gtpv1_ms_reason : hf_gtpv0_ms_reason, tvb, offset, 2, reason);
3067 /* GPRS: 12.15 v7.6.0, chapter 7.3.3, page 45
3071 decode_gtp_tr_comm(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3075 tr_command = tvb_get_guint8(tvb, offset+1);
3077 proto_tree_add_uint(tree, gtp_version ? hf_gtpv1_tr_comm : hf_gtpv0_tr_comm, tvb, offset, 2, tr_command);
3082 /* GPRS: 9.60 v7.6.0, chapter 7.9.17, page 43
3083 * UMTS: 29.060 v4.0, chapter 7.7.26, page 55
3086 decode_gtp_chrg_id(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3090 chrg_id = tvb_get_ntohl(tvb, offset+1);
3091 proto_tree_add_uint(tree, gtp_version ? hf_gtpv1_chrg_id : hf_gtpv0_chrg_id, tvb, offset, 5, chrg_id);
3096 /* GPRS: 9.60 v7.6.0, chapter 7.9.18, page 43
3097 * UMTS: 29.060 v4.0, chapter 7.7.27, page 55
3100 decode_gtp_user_addr(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3103 guint8 pdp_typ, pdp_org;
3105 struct e_in6_addr addr_ipv6;
3106 proto_tree *ext_tree_user;
3110 length = tvb_get_ntohs(tvb, offset+1);
3111 pdp_org = tvb_get_guint8(tvb, offset+3) & 0x0F;
3112 pdp_typ = tvb_get_guint8(tvb, offset+4);
3114 te = proto_tree_add_text(tree, tvb, offset, 3+length, "%s (%s/%s)",
3115 val_to_str(GTP_EXT_USER_ADDR, gtp_val, "Unknown message"),
3116 val_to_str(pdp_org, pdp_org_type, "Unknown PDP Organization"),
3117 val_to_str(pdp_typ, pdp_type, "Unknown PDP Type"));
3118 ext_tree_user = proto_item_add_subtree(te, ett_gtp_user);
3120 proto_tree_add_text(ext_tree_user, tvb, offset+1, 2, "Length : %u", length);
3121 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);
3122 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);
3125 if (pdp_org == 0 && pdp_typ == 1)
3126 proto_item_append_text(te, " (Point to Point Protocol)");
3127 else if (pdp_typ == 2)
3128 proto_item_append_text(te, " (Octet Stream Protocol)");
3129 } else if (length > 2) {
3132 tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+5, sizeof addr_ipv4);
3133 proto_tree_add_ipv4(ext_tree_user, gtp_version ? hf_gtpv1_user_ipv4 : hf_gtpv0_user_ipv4, tvb, offset+5, 4, addr_ipv4);
3134 proto_item_append_text(te, " : %s", ip_to_str((guint8 *)&addr_ipv4));
3137 tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+5, sizeof addr_ipv6);
3138 proto_tree_add_ipv6(ext_tree_user, gtp_version ? hf_gtpv1_user_ipv6 : hf_gtpv0_user_ipv6, tvb, offset+5, 16, (guint8 *)&addr_ipv6);
3139 proto_item_append_text(te, " : %s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
3143 proto_item_append_text(te, " : empty PDP Address");
3149 decode_triplet(tvbuff_t *tvb, int offset, proto_tree *tree, guint16 count) {
3151 proto_tree *ext_tree_trip;
3152 proto_item *te_trip;
3155 for (i=0;i<count;i++) {
3156 te_trip = proto_tree_add_text(tree, tvb, offset+i*28, 28, "Triplet no%x", i);
3157 ext_tree_trip = proto_item_add_subtree(te_trip, ett_gtp_trip);
3159 proto_tree_add_text(ext_tree_trip, tvb, offset+i*28, 16, "RAND: %s", tvb_bytes_to_str(tvb, offset+i*28, 16));
3160 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));
3161 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));
3167 /* adjust - how many bytes before quintuplet should be highlighted
3170 decode_quintuplet(tvbuff_t *tvb, int offset, proto_tree *tree, guint16 count, guint8 adjust) {
3172 proto_tree *ext_tree_quint;
3173 proto_item *te_quint;
3174 guint16 q_len, xres_len, auth_len, q_offset, i;
3178 for (i=0;i<count;i++) {
3180 offset = offset + q_offset;
3182 q_len = tvb_get_ntohs(tvb, offset);
3184 te_quint = proto_tree_add_text(tree, tvb, offset-adjust, q_len+adjust, "Quintuplet #%x", i);
3185 ext_tree_quint = proto_item_add_subtree(te_quint, ett_gtp_quint);
3187 proto_tree_add_text(ext_tree_quint, tvb, offset, 2, "Length: %x", q_len);
3188 proto_tree_add_text(ext_tree_quint, tvb, offset+2, 16, "RAND: %s", tvb_bytes_to_str(tvb, offset+2, 16));
3189 xres_len = tvb_get_ntohs(tvb, offset+18);
3190 proto_tree_add_text(ext_tree_quint, tvb, offset+18, 2, "XRES length: %u", xres_len);
3191 proto_tree_add_text(ext_tree_quint, tvb, offset+20, xres_len, "XRES: %s", tvb_bytes_to_str(tvb, offset+20, xres_len));
3192 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));
3193 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));
3194 auth_len = tvb_get_ntohs(tvb, offset+52+xres_len);
3195 proto_tree_add_text(ext_tree_quint, tvb, offset+52+xres_len, 2, "Authentication length: %u", auth_len);
3196 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));
3198 q_offset = q_offset + q_len + 2;
3204 /* GPRS: 9.60 v7.6.0, chapter 7.9.19 page
3205 * UMTS: 29.060 v4.0, chapter 7.7.28 page 57
3206 * TODO: - check if for quintuplets first 2 bytes are length, according to AuthQuint
3207 * - finish displaying last 3 parameters
3210 decode_gtp_mm_cntxt(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3212 guint16 length, quint_len, net_cap, con_len;
3213 guint8 cksn, count, sec_mode, cipher, trans_id, proto_disc, message, drx_split, drx_len, drx_ccch, non_drx_timer;
3214 proto_tree *ext_tree_mm;
3217 te = proto_tree_add_text(tree, tvb, offset, 1, val_to_str(GTP_EXT_MM_CNTXT, gtp_val, "Unknown message"));
3218 ext_tree_mm = proto_item_add_subtree(te, ett_gtp_mm);
3220 length = tvb_get_ntohs(tvb, offset+1);
3221 if (length < 1) return 3;
3223 cksn = tvb_get_guint8(tvb, offset+3) & 0x07;
3224 sec_mode = (tvb_get_guint8(tvb, offset+4) >> 6) & 0x03;
3225 count = (tvb_get_guint8(tvb, offset+4) >> 3) & 0x07;
3226 cipher = tvb_get_guint8(tvb, offset+4) & 0x07;
3228 proto_tree_add_text(ext_tree_mm, tvb, offset+1, 2, "Length: %x", length);
3229 proto_tree_add_text(ext_tree_mm, tvb, offset+3, 1, "Ciphering Key Sequence Number: %u", cksn);
3230 if (gtp_version != 0) {
3231 proto_tree_add_text(ext_tree_mm, tvb, offset+3, 1, "Security type: %u", sec_mode);
3236 proto_tree_add_text(ext_tree_mm, tvb, offset+4, 1, "No of triplets: %u", count);
3241 proto_tree_add_text(ext_tree_mm, tvb, offset+4, 1, "Ciphering: no ciphering");
3243 proto_tree_add_text(ext_tree_mm, tvb, offset+4, 1, "Ciphering: GEA/%u", cipher);
3245 proto_tree_add_text(ext_tree_mm, tvb, offset+5, 16, "Ciphering key CK: %s", tvb_bytes_to_str(tvb, offset+5, 16));
3246 proto_tree_add_text(ext_tree_mm, tvb, offset+21, 16, "Integrity key CK: %s", tvb_bytes_to_str(tvb, offset+21, 16));
3247 quint_len = tvb_get_ntohs(tvb, offset+37);
3248 proto_tree_add_text(ext_tree_mm, tvb, offset+37, 2, "Quintuplets length: %x", quint_len);
3250 offset = offset + decode_quintuplet(tvb, offset+39, ext_tree_mm, count, 0) + 39;
3256 proto_tree_add_text(ext_tree_mm, tvb, offset+4, 1, "Ciphering: no ciphering");
3258 proto_tree_add_text(ext_tree_mm, tvb, offset+4, 1, "Ciphering: GEA/%u", cipher);
3260 proto_tree_add_text(ext_tree_mm, tvb, offset+5, 8, "Ciphering key Kc: %s", tvb_bytes_to_str(tvb, offset+5, 8));
3262 offset = offset + decode_triplet(tvb, offset+13, ext_tree_mm, count) + 13;
3266 proto_tree_add_text(ext_tree_mm, tvb, offset+5, 16, "Ciphering key CK: %s", tvb_bytes_to_str(tvb, offset+5, 16));
3267 proto_tree_add_text(ext_tree_mm, tvb, offset+21, 16, "Integrity key CK: %s", tvb_bytes_to_str(tvb, offset+21, 16));
3268 quint_len = tvb_get_ntohs(tvb, offset+37);
3269 proto_tree_add_text(ext_tree_mm, tvb, offset+37, 2, "Quintuplets length: %x", quint_len);
3271 offset = offset + decode_quintuplet(tvb, offset+39, ext_tree_mm, count, 0) + 39;
3276 proto_tree_add_text(ext_tree_mm, tvb, offset+4, 1, "Ciphering: no ciphering");
3278 proto_tree_add_text(ext_tree_mm, tvb, offset+4, 1, "Ciphering: GEA/%u", cipher);
3280 proto_tree_add_text(ext_tree_mm, tvb, offset+5, 8, "Ciphering key Kc: %s", tvb_bytes_to_str(tvb, offset+5, 8));
3281 quint_len = tvb_get_ntohs(tvb, offset+13);
3282 proto_tree_add_text(ext_tree_mm, tvb, offset+13, 2, "Quintuplets length: %x", quint_len);
3284 offset = offset + decode_quintuplet(tvb, offset+15, ext_tree_mm, count, 0) + 15;
3292 drx_split = tvb_get_guint8(tvb, offset);
3293 drx_len = (tvb_get_guint8(tvb, offset+1) >> 4) & 0x0F;
3294 drx_ccch = (tvb_get_guint8(tvb, offset+1) >> 3) & 0x01;
3295 non_drx_timer = tvb_get_guint8(tvb, offset+1) & 0x07;
3297 net_cap = tvb_get_ntohs(tvb, offset+2);
3298 con_len = tvb_get_ntohs(tvb, offset+4);
3300 proto_tree_add_text(ext_tree_mm, tvb, offset, 1, "DRX: split PG cycle code: %u", drx_split);
3301 proto_tree_add_text(ext_tree_mm, tvb, offset+1, 1, "DRX: CN specific DRX cycle length coefficient: %u", drx_len);
3302 proto_tree_add_text(ext_tree_mm, tvb, offset+1, 1, "DRX: split PG cycle on CCCH supported by MS: %s", yesno[drx_ccch]);
3303 if (non_drx_timer == 0) {
3304 proto_tree_add_text(ext_tree_mm, tvb, offset+1, 1, "DRX: no non-DRX mode after transfer state");
3306 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);
3309 proto_tree_add_text(ext_tree_mm, tvb, offset+2, 2, "MS network capability: %u", net_cap);
3310 proto_tree_add_text(ext_tree_mm, tvb, offset+4, 2, "Container length: %u", con_len);
3313 trans_id = (tvb_get_guint8(tvb, offset+6) >> 4) & 0x0F;
3314 proto_disc = tvb_get_guint8(tvb, offset+6) & 0x0F;
3315 message = tvb_get_guint8(tvb, offset+7);
3321 /* Function to extract the value of an hexadecimal octet. Only the lower
3322 * nybble will be non-zero in the output.
3324 static guint8 hex2dec (guint8 x)
3326 if ((x >= 'a') && (x <= 'f'))
3328 else if ((x >= 'A') && (x <= 'F'))
3330 else if ((x >= '0') && (x <= '9'))
3337 /* Wrapper function to add UTF-8 decoding for QoS attributes in
3340 static guint8 wrapped_tvb_get_guint8(
3341 tvbuff_t *tvb, int offset, int type)
3344 return (hex2dec(tvb_get_guint8(tvb, offset)) << 4
3345 | hex2dec(tvb_get_guint8(tvb, offset + 1)));
3347 return tvb_get_guint8(tvb, offset);
3350 /* WARNING : actually length is coded on 2 octets for QoS profile but on 1 octet for PDP Context!
3351 * so type means length of length :-)
3353 * WARNING :) type does not mean length of length any more... see below for
3357 decode_qos_umts(tvbuff_t *tvb, int offset, proto_tree *tree, gchar* qos_str, guint8 type) {
3360 guint8 al_ret_priority;
3361 guint8 delay, reliability, peak, precedence, mean, spare1, spare2, spare3;
3362 guint8 traf_class, del_order, del_err_sdu;
3363 guint8 max_sdu_size, max_ul, max_dl;
3364 guint8 res_ber, sdu_err_ratio;
3365 guint8 trans_delay, traf_handl_prio;
3366 guint8 guar_ul, guar_dl;
3367 proto_tree *ext_tree_qos;
3369 int mss, mu, md, gu, gd;
3371 /* Will keep if the input is UTF-8 encoded (as in RADIUS messages).
3372 * If 1, input is *not* UTF-8 encoded (i.e. each input octet corresponds
3373 * to one byte to be dissected).
3374 * If 2, input is UTF-8 encoded (i.e. each *couple* of input octets
3375 * corresponds to one byte to be dissected)
3377 guint8 utf8_type = 1;
3379 /* In RADIUS messages the QoS has a version field of two octets prepended.
3380 * As of 29.061 v.3.a.0, there is an hyphen between "Release Indicator" and
3381 * <release specific QoS IE UTF-8 encoding>. Even if it sounds rather
3382 * inconsistent and unuseful, I will check hyphen presence here and
3383 * will signal its presence.
3385 guint8 version_buffer[2];
3388 /* Will keep the value that will be returned
3394 length = tvb_get_guint8 (tvb, offset);
3395 te = proto_tree_add_text (tree, tvb, offset, length + 1, "%s", qos_str);
3396 ext_tree_qos = proto_item_add_subtree (te, ett_gtp_qos);
3397 proto_tree_add_text (ext_tree_qos, tvb, offset, 1, "Length: %u", length);
3399 retval = length + 1;
3402 length = tvb_get_ntohs (tvb, offset + 1);
3403 te = proto_tree_add_text(tree, tvb, offset, length + 3, "%s", qos_str);
3404 ext_tree_qos = proto_item_add_subtree (te, ett_gtp_qos);
3405 proto_tree_add_text (ext_tree_qos, tvb, offset + 1, 2, "Length: %u", length);
3406 offset += 3; /* +1 because of first 0x86 byte for UMTS QoS */
3407 retval = length + 3;
3410 /* For QoS inside RADIUS Client messages from GGSN */
3413 /* The field in the RADIUS message starts one byte before :) */
3414 length = tvb_get_guint8 (tvb, offset);
3415 te = proto_tree_add_text (tree, tvb, offset - 1, length, "%s", qos_str);
3417 ext_tree_qos = proto_item_add_subtree (te, ett_gtp_qos);
3418 version_buffer[0] = tvb_get_guint8(tvb, offset + 1);
3419 version_buffer[1] = tvb_get_guint8(tvb, offset + 2);
3420 proto_tree_add_text (ext_tree_qos, tvb, offset + 1, 2, "Version: %c%c", version_buffer[0], version_buffer[1]);
3422 /* Hyphen handling */
3423 hyphen = tvb_get_guint8(tvb, offset + 3);
3424 if (hyphen == ((guint8) '-'))
3426 /* Hyphen is present, put in protocol tree */
3427 proto_tree_add_text (ext_tree_qos, tvb, offset + 3, 1, "Hyphen separator: -");
3428 offset++; /* "Get rid" of hyphen */
3431 /* Now, we modify offset here and in order to use type later
3434 retval = length + 3; /* Actually, will be ignored. */
3437 /* XXX - what should we do with the length here? */
3440 ext_tree_qos = NULL;
3444 /* In RADIUS messages there is no allocation-retention priority
3445 * so I don't need to wrap the following call to tvb_get_guint8
3447 al_ret_priority = tvb_get_guint8 (tvb, offset);
3449 /* All calls are wrapped to take into account the possibility that the
3450 * input is UTF-8 encoded. If utf8_type is equal to 1, the final value
3451 * of the offset will be the same as in the previous version of this
3452 * dissector, and the wrapped function will serve as a dumb wrapper;
3453 * otherwise, if utf_8_type is 2, the offset is correctly shifted by
3454 * two bytes for needed shift, and the wrapped function will unencode
3455 * two values from the input.
3457 spare1 = wrapped_tvb_get_guint8(tvb, offset+(1 - 1) * utf8_type + 1, utf8_type) & 0xC0;
3458 delay = wrapped_tvb_get_guint8(tvb, offset+(1 - 1) * utf8_type + 1, utf8_type) & 0x38;
3459 reliability = wrapped_tvb_get_guint8(tvb, offset+(1 - 1) * utf8_type + 1, utf8_type) & 0x07;
3460 peak = wrapped_tvb_get_guint8(tvb, offset+(2 - 1) * utf8_type + 1, utf8_type) & 0xF0;
3461 spare2 = wrapped_tvb_get_guint8(tvb, offset+(2 - 1) * utf8_type + 1, utf8_type) & 0x08;
3462 precedence = wrapped_tvb_get_guint8(tvb, offset+(2 - 1) * utf8_type + 1, utf8_type) & 0x07;
3463 spare3 = wrapped_tvb_get_guint8(tvb, offset+(3 - 1) * utf8_type + 1, utf8_type) & 0xE0;
3464 mean = wrapped_tvb_get_guint8(tvb, offset+(3 - 1) * utf8_type + 1, utf8_type) & 0x1F;
3466 /* In RADIUS messages there is no allocation-retention priority */
3468 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_al_ret_priority, tvb, offset, 1, al_ret_priority);
3470 /* All additions must take care of the fact that QoS fields in RADIUS
3471 * messages are UTF-8 encoded, so we have to use the same trick as above.
3473 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_spare1, tvb, offset+(1 - 1) * utf8_type + 1, utf8_type, spare1);
3474 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_delay, tvb, offset+(1 - 1) * utf8_type + 1, utf8_type, delay);
3475 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_reliability, tvb, offset+(1 - 1) * utf8_type + 1, utf8_type, reliability);
3476 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_peak, tvb, offset+(2 - 1) * utf8_type + 1, utf8_type, peak);
3477 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_spare2, tvb, offset+(2 - 1) * utf8_type + 1, utf8_type, spare2);
3478 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_precedence, tvb, offset+(2 - 1) * utf8_type + 1, utf8_type, precedence);
3479 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_spare3, tvb, offset+(3 - 1) * utf8_type + 1, utf8_type, spare3);
3480 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_mean, tvb, offset+(3 - 1) * utf8_type + 1, utf8_type, mean);
3484 /* See above for the need of wrapping
3486 traf_class = wrapped_tvb_get_guint8(tvb, offset+(4 - 1) * utf8_type + 1, utf8_type) & 0xE0;
3487 del_order = wrapped_tvb_get_guint8(tvb, offset+(4 - 1) * utf8_type + 1, utf8_type) & 0x18;
3488 del_err_sdu = wrapped_tvb_get_guint8(tvb, offset+(4 - 1) * utf8_type + 1, utf8_type) & 0x07;
3489 max_sdu_size = wrapped_tvb_get_guint8(tvb, offset+(5 - 1) * utf8_type + 1, utf8_type);
3490 max_ul = wrapped_tvb_get_guint8(tvb, offset+(6 - 1) * utf8_type + 1, utf8_type);
3491 max_dl = wrapped_tvb_get_guint8(tvb, offset+(7 - 1) * utf8_type + 1, utf8_type);
3492 res_ber = wrapped_tvb_get_guint8(tvb, offset+(8 - 1) * utf8_type + 1, utf8_type) & 0xF0;
3493 sdu_err_ratio = wrapped_tvb_get_guint8(tvb, offset+(8 - 1) * utf8_type + 1, utf8_type) & 0x0F;
3494 trans_delay = wrapped_tvb_get_guint8(tvb, offset+(9 - 1) * utf8_type + 1, utf8_type) & 0xFC;
3495 traf_handl_prio = wrapped_tvb_get_guint8(tvb, offset+(9 - 1) * utf8_type + 1, utf8_type) & 0x03;
3496 guar_ul = wrapped_tvb_get_guint8(tvb, offset+(10 - 1) * utf8_type + 1, utf8_type);
3497 guar_dl = wrapped_tvb_get_guint8(tvb, offset+(11 - 1) * utf8_type + 1, utf8_type);
3499 /* See above comments for the changes
3501 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_traf_class, tvb, offset+(4 - 1) * utf8_type + 1, utf8_type, traf_class);
3502 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_del_order, tvb, offset+(4 - 1) * utf8_type + 1, utf8_type, del_order);
3503 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);
3504 if (max_sdu_size == 0 || max_sdu_size > 150)
3505 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);
3506 if (max_sdu_size > 0 && max_sdu_size <= 150) {
3507 mss = max_sdu_size*10;
3508 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);
3511 if(max_ul == 0 || max_ul == 255)
3512 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_max_ul, tvb, offset+(6 - 1) * utf8_type + 1, utf8_type, max_ul);
3513 if(max_ul > 0 && max_ul <= 63)
3514 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);
3515 if(max_ul > 63 && max_ul <=127) {
3516 mu = 64 + ( max_ul - 64 ) * 8;
3517 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);
3520 if(max_ul > 127 && max_ul <=254) {
3521 mu = 576 + ( max_ul - 128 ) * 64;
3522 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);
3525 if(max_dl == 0 || max_dl == 255)
3526 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_max_dl, tvb, offset+(7 - 1) * utf8_type + 1, utf8_type, max_dl);
3527 if(max_dl > 0 && max_dl <= 63)
3528 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);
3529 if(max_dl > 63 && max_dl <=127) {
3530 md = 64 + ( max_dl - 64 ) * 8;
3531 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);
3533 if(max_dl > 127 && max_dl <=254) {
3534 md = 576 + ( max_dl - 128 ) * 64;
3535 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);
3538 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_res_ber, tvb, offset+(8 - 1) * utf8_type + 1, utf8_type, res_ber);
3539 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);
3540 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_trans_delay, tvb, offset+(9 - 1) * utf8_type + 1, utf8_type, trans_delay);
3541 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);
3543 if(guar_ul == 0 || guar_ul == 255)
3544 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_guar_ul, tvb, offset+(10 - 1) * utf8_type + 1, utf8_type, guar_ul);
3545 if(guar_ul > 0 && guar_ul <= 63)
3546 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);
3547 if(guar_ul > 63 && guar_ul <=127) {
3548 gu = 64 + ( guar_ul - 64 ) * 8;
3549 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);
3551 if(guar_ul > 127 && guar_ul <=254) {
3552 gu = 576 + ( guar_ul - 128 ) * 64;
3553 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);
3556 if(guar_dl == 0 || guar_dl == 255)
3557 proto_tree_add_uint(ext_tree_qos, hf_gtpv1_qos_guar_dl, tvb, offset+(11 - 1) * utf8_type + 1, utf8_type, guar_dl);
3558 if(guar_dl > 0 && guar_dl <= 63)
3559 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);
3560 if(guar_dl > 63 && guar_dl <=127) {
3561 gd = 64 + ( guar_dl - 64 ) * 8;
3562 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);
3564 if(guar_dl > 127 && guar_dl <=254) {
3565 gd = 576 + ( guar_dl - 128 ) * 64;
3566 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);
3575 decode_apn(tvbuff_t *tvb, int offset, guint16 length, proto_tree *tree) {
3578 guint8 name_len, tmp;
3581 apn = g_malloc (length + 1);
3582 name_len = tvb_get_guint8 (tvb, offset);
3584 if (name_len < 0x20) {
3585 tvb_memcpy (tvb, apn, offset + 1, length);
3587 if (name_len >= length - 1) break;
3589 name_len = name_len + apn[tmp] + 1;
3593 tvb_memcpy (tvb, apn, offset, length);
3596 apn[length-1] = '\0';
3597 proto_tree_add_string(tree, gtp_version ? hf_gtpv1_apn : hf_gtpv0_apn, tvb, offset, length, apn);
3602 /* GPRS: 9.60 v7.6.0, chapter 7.9.20
3603 * UMTS: 29.060 v4.0, chapter 7.7.29
3604 * TODO: unify addr functions
3607 decode_gtp_pdp_cntxt(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3609 guint8 ggsn_addr_len, apn_len, trans_id, vaa, order, nsapi, sapi, pdu_send_no, pdu_rec_no, pdp_cntxt_id,
3610 pdp_type_org, pdp_type_num, pdp_addr_len;
3611 guint16 length, sn_down, sn_up, up_flow;
3612 guint32 addr_ipv4, up_teid, up_teid_cp;
3613 struct e_in6_addr addr_ipv6;
3614 proto_tree *ext_tree_pdp;
3617 length = tvb_get_ntohs(tvb, offset+1);
3619 te = proto_tree_add_text(tree, tvb, offset, length+3, val_to_str(GTP_EXT_PDP_CNTXT, gtp_val, "Unknown message"));
3620 ext_tree_pdp = proto_item_add_subtree(te, ett_gtp_pdp);
3622 vaa = (tvb_get_guint8(tvb, offset+3) >> 6) & 0x01;
3623 order = (tvb_get_guint8(tvb, offset+3) >> 4) & 0x01;
3624 nsapi = tvb_get_guint8(tvb, offset+3) & 0x0F;
3625 sapi = tvb_get_guint8(tvb, offset+4) & 0x0F;
3627 proto_tree_add_text(ext_tree_pdp, tvb, offset+3, 1, "VPLMN address allowed: %s", yesno[vaa]);
3628 proto_tree_add_text(ext_tree_pdp, tvb, offset+3, 1, "Reordering required: %s", yesno[order]);
3629 proto_tree_add_text(ext_tree_pdp, tvb, offset+3, 1, "NSAPI: %u", nsapi);
3630 proto_tree_add_text(ext_tree_pdp, tvb, offset+4, 1, "SAPI: %u", sapi);
3632 switch (gtp_version) {
3634 decode_qos_gprs(tvb, offset+5, ext_tree_pdp, "QoS subscribed", 0);
3635 decode_qos_gprs(tvb, offset+8, ext_tree_pdp, "QoS requested", 0);
3636 decode_qos_gprs(tvb, offset+11, ext_tree_pdp, "QoS negotiated", 0);
3637 offset = offset + 14;
3640 offset = offset + 5;
3641 offset = offset + decode_qos_umts(tvb, offset, ext_tree_pdp, "QoS subscribed", 1);
3642 offset = offset + decode_qos_umts(tvb, offset, ext_tree_pdp, "QoS requested", 1);
3643 offset = offset + decode_qos_umts(tvb, offset, ext_tree_pdp, "QoS negotiated", 1);
3649 sn_down = tvb_get_ntohs(tvb, offset);
3650 sn_up = tvb_get_ntohs(tvb, offset+2);
3651 pdu_send_no = tvb_get_guint8(tvb, offset+4);
3652 pdu_rec_no = tvb_get_guint8(tvb, offset+5);
3654 proto_tree_add_text(ext_tree_pdp, tvb, offset, 2, "Sequence number down: %u", sn_down);
3655 proto_tree_add_text(ext_tree_pdp, tvb, offset+2, 2, "Sequence number up: %u", sn_up);
3656 proto_tree_add_text(ext_tree_pdp, tvb, offset+4, 1, "Send N-PDU number: %u", pdu_send_no);
3657 proto_tree_add_text(ext_tree_pdp, tvb, offset+5, 1, "Receive N-PDU number: %u", pdu_rec_no);
3659 switch (gtp_version) {
3661 up_flow = tvb_get_ntohs(tvb, offset+6);
3662 proto_tree_add_text(ext_tree_pdp, tvb, offset+6, 2, "Uplink flow label signalling: %u", up_flow);
3663 offset = offset + 8;
3666 up_teid = tvb_get_ntohl(tvb, offset+6);
3667 up_teid_cp = tvb_get_ntohl(tvb, offset+10);
3668 pdp_cntxt_id = tvb_get_guint8(tvb, offset+14);
3669 proto_tree_add_text(ext_tree_pdp, tvb, offset+6, 4, "Uplink TEID: %x", up_teid);
3670 proto_tree_add_text(ext_tree_pdp, tvb, offset+10, 4, "Uplink TEID control plane: %x", up_teid_cp);
3671 proto_tree_add_text(ext_tree_pdp, tvb, offset+14, 1, "PDP context identifier: %u", pdp_cntxt_id);
3672 offset = offset + 15;
3678 pdp_type_org = tvb_get_guint8(tvb, offset) & 0x0F;
3679 pdp_type_num = tvb_get_guint8(tvb, offset+1);
3680 pdp_addr_len = tvb_get_guint8(tvb, offset+2);
3682 proto_tree_add_text(ext_tree_pdp, tvb, offset, 1, "PDP organization: %s", val_to_str(pdp_type_org, pdp_type, "Unknown PDP org"));
3683 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"));
3684 proto_tree_add_text(ext_tree_pdp, tvb, offset+2, 1, "PDP address length: %u", pdp_addr_len);
3686 if (pdp_addr_len > 0) {
3687 switch (pdp_type_num) {
3689 tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+3, sizeof addr_ipv4);
3690 proto_tree_add_text(ext_tree_pdp, tvb, offset+3, 4, "PDP address: %s", ip_to_str((guint8 *)&addr_ipv4));
3693 tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+3, sizeof addr_ipv6);
3694 proto_tree_add_text(ext_tree_pdp, tvb, offset+3, 16, "PDP address: %s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
3701 offset = offset + 3 + pdp_addr_len;
3703 ggsn_addr_len = tvb_get_guint8(tvb, offset);
3704 proto_tree_add_text(ext_tree_pdp, tvb, offset, 1, "GGSN address length: %u", ggsn_addr_len);
3706 switch (ggsn_addr_len) {
3708 tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+1, sizeof addr_ipv4);
3709 proto_tree_add_text(ext_tree_pdp, tvb, offset+1, 4, "GGSN address: %s", ip_to_str((guint8 *)&addr_ipv4));
3712 tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+1, sizeof addr_ipv6);
3713 proto_tree_add_text(ext_tree_pdp, tvb, offset+1, 16, "GGSN address: %s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
3719 offset = offset + 1 + ggsn_addr_len;
3721 if (gtp_version == 1) {
3723 ggsn_addr_len = tvb_get_guint8(tvb, offset);
3724 proto_tree_add_text(ext_tree_pdp, tvb, offset, 1, "GGSN 2 address length: %u", ggsn_addr_len);
3726 switch (ggsn_addr_len) {
3728 tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+1, sizeof addr_ipv4);
3729 proto_tree_add_text(ext_tree_pdp, tvb, offset+1, 4, "GGSN 2 address: %s", ip_to_str((guint8 *)&addr_ipv4));
3732 tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+1, sizeof addr_ipv6);
3733 proto_tree_add_text(ext_tree_pdp, tvb, offset+1, 16, "GGSN 2 address: %s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
3738 offset = offset + 1 + ggsn_addr_len;
3742 apn_len = tvb_get_guint8(tvb, offset);
3743 proto_tree_add_text(ext_tree_pdp, tvb, offset, 1, "APN length: %u", apn_len);
3744 decode_apn(tvb, offset+1, apn_len, ext_tree_pdp);
3746 offset = offset + 1 + apn_len;
3748 trans_id = tvb_get_guint8(tvb, offset);
3749 proto_tree_add_text(ext_tree_pdp, tvb, offset, 1, "Transaction identifier: %u", trans_id);
3754 /* GPRS: 9.60, v7.6.0, chapter 7.9.21
3755 * UMTS: 29.060, v4.0, chapter 7.7.30
3758 decode_gtp_apn(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3761 proto_tree *ext_tree_apn;
3764 length = tvb_get_ntohs(tvb, offset+1);
3766 te = proto_tree_add_text(tree, tvb, offset, length+3, val_to_str(GTP_EXT_APN, gtp_val, "Unknown field"));
3767 ext_tree_apn = proto_item_add_subtree(te, ett_gtp_apn);
3769 proto_tree_add_text(ext_tree_apn, tvb, offset+1, 2, "APN length : %u", length);
3770 decode_apn(tvb, offset+3, length, ext_tree_apn);
3775 /* GPRS: 9.60 v7.6.0, chapter 7.9.22
3776 * 4.08 v. 7.1.2, chapter 10.5.6.3 (p.580)
3777 * UMTS: 29.060 v4.0, chapter 7.7.31
3778 * 24.008, v4.2, chapter 10.5.6.3
3781 decode_gtp_proto_conf(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree) {
3783 guint16 length, proto_offset;
3785 guint8 conf, proto_len, cnt = 1;
3787 proto_tree *ext_tree_proto;
3789 gboolean save_writable;
3791 length = tvb_get_ntohs(tvb, offset + 1);
3793 te = proto_tree_add_text(tree, tvb, offset, length + 3, val_to_str(GTP_EXT_PROTO_CONF, gtp_val, "Unknown message"));
3794 ext_tree_proto = proto_item_add_subtree(te, ett_gtp_proto);
3796 proto_tree_add_text(ext_tree_proto, tvb, offset + 1, 2, "Length: %u", length);
3798 if (length < 1) return 3;
3800 conf = tvb_get_guint8 (tvb, offset + 3) & 0x07;
3801 proto_tree_add_text (ext_tree_proto, tvb, offset + 3, 1, "Configuration protocol (00000xxx): %u", conf);
3803 proto_offset = 1; /* ... 1st byte is conf */
3807 if (proto_offset >= length) break;
3808 proto_id = tvb_get_ntohs (tvb, offset);
3809 proto_len = tvb_get_guint8 (tvb, offset + 2);
3810 proto_offset += proto_len + 3; /* 3 = proto id + length byte */
3812 if (proto_len > 0) {
3814 proto_tree_add_text (ext_tree_proto, tvb, offset, 2, "Protocol %u ID: %s (0x%04x)",
3815 cnt, val_to_str(proto_id, ppp_vals, "Unknown"),
3817 proto_tree_add_text (ext_tree_proto, tvb, offset+2, 1, "Protocol %u length: %u", cnt, proto_len);
3820 * Don't allow the dissector for the configuration
3821 * protocol in question to update the columns - this
3824 save_writable = col_get_writable(pinfo->cinfo);
3825 col_set_writable(pinfo->cinfo, FALSE);
3828 * XXX - should we have our own dissector table,
3829 * solely for configuration protocols, so that bogus
3830 * values don't cause us to dissect the protocol
3831 * data as, for example, IP?
3833 next_tvb = tvb_new_subset (tvb, offset + 3, proto_len, proto_len);
3834 if (!dissector_try_port(ppp_subdissector_table,
3835 proto_id, next_tvb, pinfo, ext_tree_proto)) {
3836 call_dissector(data_handle, next_tvb, pinfo,
3840 col_set_writable(pinfo->cinfo, save_writable);
3843 offset += proto_len + 3;
3850 /* GPRS: 9.60 v7.6.0, chapter 7.9.23
3851 * UMTS: 29.060 v4.0, chapter 7.7.32
3854 decode_gtp_gsn_addr(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3856 guint8 addr_type, addr_len;
3859 struct e_in6_addr addr_ipv6;
3860 proto_tree *ext_tree_gsn_addr;
3863 length = tvb_get_ntohs(tvb, offset+1);
3865 te = proto_tree_add_text(tree, tvb, offset, 3+length, "GSN address : ");
3866 ext_tree_gsn_addr = proto_item_add_subtree(te, ett_gtp_gsn_addr);
3870 proto_tree_add_text(ext_tree_gsn_addr, tvb, offset+1, 2, "GSN address length : %u", length);
3871 tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+3, sizeof addr_ipv4);
3872 proto_item_append_text(te, "%s", ip_to_str((guint8 *)&addr_ipv4));
3873 proto_tree_add_ipv4(ext_tree_gsn_addr, gtp_version ? hf_gtpv1_gsn_ipv4 : hf_gtpv0_gsn_ipv4, tvb, offset+3, 4, addr_ipv4);
3876 proto_tree_add_text(ext_tree_gsn_addr, tvb, offset+1, 2, "GSN address Information Element length : %u", length);
3877 addr_type = tvb_get_guint8(tvb, offset+3) & 0xC0;
3878 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);
3879 addr_len = tvb_get_guint8(tvb, offset+3) & 0x3F;
3880 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);
3881 tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+4, sizeof addr_ipv4);
3882 proto_item_append_text(te, "%s", ip_to_str((guint8 *)&addr_ipv4));
3883 proto_tree_add_ipv4(ext_tree_gsn_addr, gtp_version ? hf_gtpv1_gsn_ipv4 : hf_gtpv0_gsn_ipv4, tvb, offset+4, 4, addr_ipv4);
3886 proto_tree_add_text(ext_tree_gsn_addr, tvb, offset+1, 2, "GSN address length : %u", length);
3887 tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+3, sizeof addr_ipv6);
3888 proto_item_append_text(te, "%s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
3889 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);
3892 proto_tree_add_text(ext_tree_gsn_addr, tvb, offset+1, 2, "GSN address Information Element length : %u", length);
3893 addr_type = tvb_get_guint8(tvb, offset+3) & 0xC0;
3894 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);
3895 addr_len = tvb_get_guint8(tvb, offset+3) & 0x3F;
3896 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);
3897 tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+4, sizeof addr_ipv6);
3898 proto_item_append_text(te, "%s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
3899 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);
3902 proto_item_append_text(te, "unknown type or wrong length");
3909 /* GPRS: 9.60 v7.6.0, chapter 7.9.24
3910 * UMTS: 29.060 v4.0, chapter 7.7.33
3913 decode_gtp_msisdn(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3915 const guint8 *msisdn_val;
3919 length = tvb_get_ntohs(tvb, offset+1);
3921 if (length < 1) return 3;
3923 msisdn_val = tvb_get_ptr(tvb, offset+3, length);
3924 msisdn_str = msisdn_to_str(msisdn_val, length);
3926 proto_tree_add_string(tree, gtp_version ? hf_gtpv1_msisdn : hf_gtpv0_msisdn, tvb, offset, 3+length, msisdn_str);
3931 /* GPRS: not present
3932 * UMTS: 29.060 v4.0, chapter 7.7.34
3933 * 24.008 v4.2, chapter 10.5.6.5
3936 decode_gtp_qos_umts(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3938 return decode_qos_umts(tvb, offset, tree, "Quality of Service", 2);
3941 /* GPRS: not present
3942 * UMTS: 29.060 v4.0, chapter 7.7.35
3945 decode_gtp_auth_qui(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3947 return (1 + decode_quintuplet(tvb, offset+1, tree, 1, 1));
3951 /* GPRS: not present
3952 * UMTS: 29.060 v4.0, chapter 7.7.36
3953 * 24.008 v4.2, chapter 10.5.6.12
3956 decode_gtp_tft(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3958 guint16 length, port1, port2, tos;
3959 guint8 tft_flags, tft_code, no_packet_filters, i, pf_id, pf_eval, pf_len, pf_content_id, pf_offset, proto, spare;
3960 guint32 mask_ipv4, addr_ipv4, ipsec_id, label;
3961 struct e_in6_addr addr_ipv6, mask_ipv6;
3962 proto_tree *ext_tree_tft, *ext_tree_tft_pf, *ext_tree_tft_flags;
3963 proto_item *te, *tee, *tef;
3965 length = tvb_get_ntohs(tvb, offset+1);
3967 te = proto_tree_add_text(tree, tvb, offset, 3+length, "Traffic flow template");
3968 ext_tree_tft = proto_item_add_subtree(te, ett_gtp_tft);
3970 tft_flags = tvb_get_guint8(tvb, offset+3);
3971 tft_code = (tft_flags >> 5) & 0x07;
3972 spare = (tft_flags >> 4) & 0x01;
3973 no_packet_filters = tft_flags & 0x0F;
3975 proto_tree_add_text(ext_tree_tft, tvb, offset+1, 2, "TFT length: %u", length);
3977 tef = proto_tree_add_text (ext_tree_tft, tvb, offset + 3, 1, "TFT flags");
3978 ext_tree_tft_flags = proto_item_add_subtree (tef, ett_gtp_tft_flags);
3979 proto_tree_add_uint (ext_tree_tft_flags, hf_gtpv1_tft_code, tvb, offset + 3, 1, tft_flags);
3980 proto_tree_add_uint (ext_tree_tft_flags, hf_gtpv1_tft_spare, tvb, offset + 3, 1, tft_flags);
3981 proto_tree_add_uint (ext_tree_tft_flags, hf_gtpv1_tft_number, tvb, offset + 3, 1, tft_flags);
3983 offset = offset + 4;
3985 for (i=0;i<no_packet_filters;i++) {
3987 pf_id = tvb_get_guint8(tvb, offset);
3989 tee = proto_tree_add_text (ext_tree_tft, tvb, offset, 1, "Packet filter id: %u", pf_id);
3990 ext_tree_tft_pf = proto_item_add_subtree (tee, ett_gtp_tft_pf);
3993 if (tft_code != 2) {
3995 pf_eval = tvb_get_guint8(tvb, offset);
3996 pf_len = tvb_get_guint8(tvb, offset + 1);
3998 proto_tree_add_uint (ext_tree_tft_pf, hf_gtpv1_tft_eval, tvb, offset, 1, pf_eval);
3999 proto_tree_add_text (ext_tree_tft_pf, tvb, offset+1, 1, "Content length: %u", pf_len);
4001 offset = offset + 2;
4004 while (pf_offset < pf_len) {
4006 pf_content_id = tvb_get_guint8 (tvb, offset + pf_offset);
4008 switch (pf_content_id) {
4009 /* address IPv4 and mask = 8 bytes*/
4011 tvb_memcpy (tvb, (guint8 *)&addr_ipv4, offset + pf_offset + 1, sizeof addr_ipv4);
4012 tvb_memcpy (tvb, (guint8 *)&mask_ipv4, offset + pf_offset + 5, sizeof mask_ipv4);
4013 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));
4014 pf_offset = pf_offset + 9;
4016 /* address IPv6 and mask = 32 bytes*/
4018 tvb_memcpy (tvb, (guint8 *)&addr_ipv6, offset+pf_offset+1, sizeof addr_ipv6);
4019 tvb_memcpy (tvb, (guint8 *)&mask_ipv6, offset+pf_offset+17, sizeof mask_ipv6);
4020 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));
4021 pf_offset = pf_offset + 33;
4023 /* protocol identifier/next header type = 1 byte*/
4025 proto = tvb_get_guint8 (tvb, offset + pf_offset + 1);
4026 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);
4027 pf_offset = pf_offset + 2;
4029 /* single destination port type = 2 bytes */
4031 port1 = tvb_get_ntohs (tvb, offset + pf_offset + 1);
4032 proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 3, "ID 0x40: destination port: %u", port1);
4033 pf_offset = pf_offset + 3;
4035 /* destination port range type = 4 bytes */
4037 port1 = tvb_get_ntohs (tvb, offset + pf_offset + 1);
4038 port2 = tvb_get_ntohs (tvb, offset + pf_offset + 3);
4039 proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 5, "ID 0x41: destination port range: %u - %u", port1, port2);
4040 pf_offset = pf_offset + 5;
4042 /* single source port type = 2 bytes */
4044 port1 = tvb_get_ntohs (tvb, offset + pf_offset + 1);
4045 proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 3, "ID 0x50: source port: %u", port1);
4046 pf_offset = pf_offset + 3;
4048 /* source port range type = 4 bytes */
4050 port1 = tvb_get_ntohs (tvb, offset + pf_offset + 1);
4051 port2 = tvb_get_ntohs (tvb, offset + pf_offset + 3);
4052 proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 5, "ID 0x51: source port range: %u - %u", port1, port2);
4053 pf_offset = pf_offset + 5;
4055 /* security parameter index type = 4 bytes */
4057 ipsec_id = tvb_get_ntohl (tvb, offset + pf_offset + 1);
4058 proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 5, "ID 0x60: security parameter index: %x", ipsec_id);
4059 pf_offset = pf_offset + 5;
4061 /* type of service/traffic class type = 2 bytes */
4063 tos = tvb_get_ntohs (tvb, offset + pf_offset + 1);
4064 proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 2, "ID 0x70: Type of Service/Traffic Class: %u (%x)", tos, tos);
4065 pf_offset = pf_offset + 3;
4067 /* flow label type = 3 bytes */
4069 label = tvb_get_ntoh24(tvb, offset + pf_offset + 1) & 0x0FFFFF;;
4070 proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 4, "ID 0x80: Flow Label: %u (%x)", label, label);
4071 pf_offset = pf_offset + 4;
4075 proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 1, "Unknown value: %x ", pf_content_id);
4076 pf_offset++; /* to avoid infinite loop */
4081 offset = offset + pf_offset;
4088 /* GPRS: not present
4089 * UMTS: 29.060 v4.0, chapter 7.7.37
4090 * 25.413 v3.4, chapter ???
4093 decode_gtp_target_id(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
4097 length = tvb_get_ntohs(tvb, offset + 1);
4099 proto_tree_add_text(tree, tvb, offset, 3 + length, "Targer Identification");
4105 /* GPRS: not present
4106 * UMTS: 29.060 v4.0, chapter 7.7.38
4109 decode_gtp_utran_cont(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
4113 length = tvb_get_ntohs(tvb, offset + 1);
4115 proto_tree_add_text(tree, tvb, offset, 3 + length, "UTRAN transparent field");
4122 /* GPRS: not present
4123 * UMTS: 29.060 v4.0, chapter 7.7.39
4126 decode_gtp_rab_setup(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
4128 guint32 teid, addr_ipv4;
4131 struct e_in6_addr addr_ipv6;
4132 proto_tree *ext_tree_rab_setup;
4135 length = tvb_get_ntohs(tvb, offset + 1);
4136 nsapi = tvb_get_guint8(tvb, offset + 3) & 0x0F;
4138 te = proto_tree_add_text(tree, tvb, offset, 3+length, "Radio Access Bearer Setup Information");
4139 ext_tree_rab_setup = proto_item_add_subtree(te, ett_gtp_rab_setup);
4141 proto_tree_add_text(ext_tree_rab_setup, tvb, offset+1, 2, "RAB setup length : %u", length);
4142 proto_tree_add_uint(ext_tree_rab_setup, hf_gtpv1_nsapi, tvb, offset+3, 1, nsapi);
4146 teid = tvb_get_ntohl(tvb, offset + 4);
4148 proto_tree_add_uint(ext_tree_rab_setup, hf_gtpv1_teid_data, tvb, offset+4, 4, teid);
4152 tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+8, sizeof addr_ipv4);
4153 proto_tree_add_ipv4(ext_tree_rab_setup, hf_gtpv1_rnc_ipv4, tvb, offset+8, 4, addr_ipv4);
4156 tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+8, sizeof addr_ipv6);
4157 proto_tree_add_ipv6(ext_tree_rab_setup, hf_gtpv1_rnc_ipv6, tvb, offset+8, 16, (guint8 *)&addr_ipv6);
4168 /* GPRS: not present
4169 * UMTS: 29.060 v4.0, chapter 7.7.40
4172 decode_gtp_hdr_list(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
4176 proto_tree *ext_tree_hdr_list;
4179 length = tvb_get_guint8(tvb, offset + 1);
4181 te = proto_tree_add_text(tree, tvb, offset, 2+length, "%s", val_to_str(GTP_EXT_HDR_LIST, gtp_val, "Unknown"));
4182 ext_tree_hdr_list = proto_item_add_subtree(te, ett_gtp_hdr_list);
4184 proto_tree_add_text(ext_tree_hdr_list, tvb, offset+1, 1, "Number of Extension Header Types in list (i.e., length) : %u", length);
4186 for(i=0 ; i<length ; i++) {
4187 hdr = tvb_get_guint8(tvb, offset+2+i);
4189 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);
4195 /* GPRS: not present
4196 * UMTS: 29.060 v4.0, chapter 7.7.41
4197 * TODO: find TriggerID description
4200 decode_gtp_trigger_id(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
4204 length = tvb_get_ntohs(tvb, offset + 1);
4206 proto_tree_add_text(tree, tvb, offset, 3+length, "%s length : %u", val_to_str(GTP_EXT_TRIGGER_ID, gtp_val, "Unknown"), length);
4212 /* GPRS: not present
4213 * UMTS: 29.060 v4.0, chapter 7.7.42
4214 * TODO: find OMC-ID description
4217 decode_gtp_omc_id(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
4221 length = tvb_get_ntohs(tvb, offset + 1);
4223 proto_tree_add_text(tree, tvb, offset, 3+length, "%s length : %u", val_to_str(GTP_EXT_OMC_ID, gtp_val, "Unknown"), length);
4229 /* GPRS: 9.60 v7.6.0, chapter 7.9.25
4230 * UMTS: 29.060 v4.0, chapter 7.7.43
4233 decode_gtp_chrg_addr(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
4237 struct e_in6_addr addr_ipv6;
4238 proto_tree *ext_tree_chrg_addr;
4241 length = tvb_get_ntohs(tvb, offset+1);
4243 te = proto_tree_add_text(tree, tvb, offset, 3+length, "%s : ", val_to_str(GTP_EXT_CHRG_ADDR, gtp_val, "Unknown"));
4244 ext_tree_chrg_addr = proto_item_add_subtree(te, ett_gtp_chrg_addr);
4246 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);
4250 tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+3, sizeof addr_ipv4);
4251 proto_item_append_text(te, "%s", ip_to_str((guint8 *)&addr_ipv4));
4252 proto_tree_add_ipv4(ext_tree_chrg_addr, gtp_version ? hf_gtpv1_chrg_ipv4 : hf_gtpv0_chrg_ipv4, tvb, offset+3, 4, addr_ipv4);
4255 tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+3, sizeof addr_ipv6);
4256 proto_item_append_text(te, "%s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
4257 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);
4260 proto_item_append_text(te, "unknown type or wrong length");
4271 decode_gtp_rel_pack(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
4273 guint16 length, n, number;
4274 proto_tree *ext_tree_rel_pack;
4277 length = tvb_get_ntohs(tvb, offset + 1);
4279 te = proto_tree_add_text(tree, tvb, offset, 3 + length, "Sequence numbers of released packets IE");
4280 ext_tree_rel_pack = proto_item_add_subtree(te, ett_gtp_rel_pack);
4284 while (n < length) {
4286 number = tvb_get_ntohs(tvb, offset + 3 + n);
4287 proto_tree_add_text(ext_tree_rel_pack, tvb, offset + 3 + n, 2, "%u", number);
4299 decode_gtp_can_pack(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
4301 guint16 length, n, number;
4302 proto_tree *ext_tree_can_pack;
4305 length = tvb_get_ntohs(tvb, offset + 1);
4307 te = proto_tree_add_text(tree, tvb, offset, 3 + length, "Sequence numbers of cancelled packets IE");
4308 ext_tree_can_pack = proto_item_add_subtree(te, ett_gtp_can_pack);
4312 while (n < length) {
4314 number = tvb_get_ntohs(tvb, offset + 3 + n);
4315 proto_tree_add_text(ext_tree_can_pack, tvb, offset + 3 + n, 2, "%u", number);
4323 /* CDRs dissector */
4325 decode_gtp_data_req(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
4327 guint16 length, format_ver, data_len, i, j;
4328 guint8 no, format, rectype;
4329 proto_tree *ext_tree, *cdr_tree;
4330 proto_item *te, *ce;
4332 te = proto_tree_add_text(tree, tvb, offset, 1, val_to_str(GTP_EXT_DATA_REQ, gtp_val, "Unknown message"));
4333 ext_tree = proto_item_add_subtree(te, ett_gtp_ext);
4335 length = tvb_get_ntohs(tvb, offset + 1);
4336 no = tvb_get_guint8(tvb, offset + 3);
4337 format = tvb_get_guint8(tvb, offset + 4);
4338 format_ver = tvb_get_ntohs(tvb, offset + 5);
4340 proto_tree_add_text(ext_tree, tvb, offset+1, 2, "Length: %u", length);
4341 proto_tree_add_text(ext_tree, tvb, offset+3, 1, "Number of data records: %u", no);
4342 proto_tree_add_text(ext_tree, tvb, offset+4, 1, "Data record format: %u", format);
4343 proto_tree_add_text(ext_tree, tvb, offset+5, 2, "Data record format version: %u", format_ver);
4346 offset = offset + 7;
4348 if (gtpv0_cdr_as != DONT_DISSECT_CDRS) {
4350 for (i = 0; i < no; i++) {
4351 data_len = tvb_get_ntohs(tvb, offset);
4352 rectype = tvb_get_guint8(tvb, offset+2);
4354 case 0x13: /* GCDR */
4355 if (tvb_length_remaining(tvb, offset) < 3 + 118) {
4356 proto_tree_add_text(ext_tree, tvb, offset, tvb_length_remaining(tvb, offset), "GCDR fragmented, can't dissect");
4360 tvb_memcpy(tvb, gcdr.imsi, offset+3, 8);
4361 tvb_memcpy(tvb, (guint8 *)&gcdr.ggsnaddr, offset+11, sizeof gcdr.ggsnaddr);
4362 gcdr.chrgid = tvb_get_ntohl(tvb, offset+15);
4363 tvb_memcpy(tvb, (guint8 *)&gcdr.sgsnaddr, offset+19, sizeof gcdr.sgsnaddr);
4364 tvb_memcpy(tvb, gcdr.apn, offset+23, 63);
4365 gcdr.pdporg = tvb_get_guint8(tvb, offset+86);
4366 gcdr.pdptype = tvb_get_guint8(tvb, offset+87);
4367 tvb_memcpy(tvb, (guint8 *)&gcdr.pdpaddr, offset+88, sizeof gcdr.pdpaddr);
4368 gcdr.addrflag = tvb_get_guint8(tvb, offset+92);
4369 gcdr.uplink = tvb_get_ntohl(tvb, offset+96);
4370 gcdr.downlink = tvb_get_ntohl(tvb, offset+100);
4371 gcdr.timestamp = tvb_get_ntohl(tvb, offset+104);
4372 gcdr.opening = tvb_get_ntohl(tvb, offset+108);
4373 gcdr.duration = tvb_get_ntohl(tvb, offset+112);
4374 gcdr.closecause = tvb_get_guint8(tvb, offset+116);
4375 gcdr.seqno = tvb_get_ntohl(tvb, offset+117);
4377 ce = proto_tree_add_text(ext_tree, tvb, offset, data_len + 2, "GCDR (0x13), sequence number: %u", gcdr.seqno);
4378 cdr_tree = proto_item_add_subtree(ce, ett_gtp_ext);
4379 proto_tree_add_text(cdr_tree, tvb, offset, 2, "Length: %u", data_len);
4380 proto_tree_add_text(cdr_tree, tvb, offset+2, 1, "Type: %u (%x)", rectype, rectype);
4381 proto_tree_add_text(cdr_tree, tvb, offset+3, 8, "IMSI: %s", id_to_str(gcdr.imsi));
4382 proto_tree_add_text(cdr_tree, tvb, offset+11, 4, "GGSN address: %s", ip_to_str((guint8 *)&gcdr.ggsnaddr));
4383 proto_tree_add_text(cdr_tree, tvb, offset+15, 4, "Charging ID: %x", gcdr.chrgid);
4384 proto_tree_add_text(cdr_tree, tvb, offset+19, 4, "SGSN address: %s", ip_to_str((guint8 *)&gcdr.sgsnaddr));
4385 proto_tree_add_text(cdr_tree, tvb, offset+23, 63, "APN: %s", gcdr.apn);
4386 proto_tree_add_text(cdr_tree, tvb, offset+86, 1, "PDP org: %s", val_to_str(gcdr.pdporg, pdp_org_type, "Unknown PDP org"));
4387 proto_tree_add_text(cdr_tree, tvb, offset+87, 1, "PDP type: %s", val_to_str(gcdr.pdptype, pdp_type, "Unknown PDP type"));
4388 proto_tree_add_text(cdr_tree, tvb, offset+88, 4, "PDP address: %s", ip_to_str((guint8 *)&gcdr.pdpaddr));
4389 proto_tree_add_text(cdr_tree, tvb, offset+92, 1, "PDP address type: %u", gcdr.addrflag);
4390 decode_qos_gprs(tvb, offset+93, cdr_tree, "QoS", 0);
4391 proto_tree_add_text(cdr_tree, tvb, offset+96, 4, "Uplink volume: %u", gcdr.uplink);
4392 proto_tree_add_text(cdr_tree, tvb, offset+100, 4, "Downlink volume: %u", gcdr.downlink);
4393 proto_tree_add_text(cdr_tree, tvb, offset+104, 4, "Timestamp: %s", time_int_to_str(gcdr.timestamp));
4394 proto_tree_add_text(cdr_tree, tvb, offset+108, 4, "Record opening time: %s", time_int_to_str(gcdr.opening));
4395 proto_tree_add_text(cdr_tree, tvb, offset+112, 4, "Duration: %s", rel_time_int_to_str(gcdr.duration));
4396 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);
4397 proto_tree_add_text(cdr_tree, tvb, offset+117, 4, "Sequence number: %u", gcdr.seqno);
4399 if (data_len > 119) {
4400 tvb_memcpy (tvb, gcdr.msisdn, offset + 121, 9);
4401 proto_tree_add_text(cdr_tree, tvb, offset+121, 9, "MSISDN: %s", msisdn_to_str (gcdr.msisdn, 9));
4406 case 0x12: /* SCDR */
4407 if (tvb_length_remaining(tvb, offset) < 3 + 277) {
4408 proto_tree_add_text(ext_tree, tvb, offset, tvb_length_remaining(tvb, offset), "SCDR fragmented, can't dissect");
4412 scdr.len = tvb_get_letohs(tvb, offset+3);
4413 scdr.netini = tvb_get_guint8(tvb, offset+5);
4414 scdr.anon = tvb_get_guint8(tvb, offset+6);
4415 scdr.imsilen = tvb_get_guint8(tvb, offset+7);
4416 tvb_memcpy(tvb, scdr.imsi, offset+8, 8);
4417 tvb_memcpy(tvb, scdr.imei, offset+16, 8);
4418 scdr.msisdnlen = tvb_get_guint8(tvb, offset+24);
4419 tvb_memcpy(tvb, scdr.msisdn, offset+25, 10);
4420 tvb_memcpy(tvb, (guint8 *)&scdr.sgsnaddr, offset+35, sizeof scdr.sgsnaddr);
4421 tvb_memcpy(tvb, scdr.msclass_notused, offset+39, 12);
4422 scdr.msclass_caplen = tvb_get_guint8(tvb, offset+51);
4423 scdr.msclass_cap = tvb_get_guint8(tvb, offset+52);
4424 scdr.msclass_capomit = tvb_get_ntohs(tvb, offset+53);
4425 scdr.lac = tvb_get_ntohs(tvb, offset+55);
4426 scdr.rac = tvb_get_guint8(tvb, offset+57);
4427 scdr.cid = tvb_get_ntohs(tvb, offset+58);
4428 scdr.chrgid = tvb_get_ntohl(tvb, offset+60);
4429 tvb_memcpy(tvb, (guint8 *)&scdr.ggsnaddr, offset+64, sizeof scdr.ggsnaddr);
4430 tvb_memcpy(tvb, scdr.apn, offset+68, 64);
4431 scdr.pdporg = tvb_get_guint8(tvb, offset+132);
4432 scdr.pdptype = tvb_get_guint8(tvb, offset+133);
4433 tvb_memcpy(tvb, (guint8 *)&scdr.pdpaddr, offset+134, sizeof scdr.pdpaddr);
4434 scdr.listind = tvb_get_guint8(tvb, offset+138);
4436 scdr.change[j].change = tvb_get_guint8(tvb, offset+139+23*j);
4437 scdr.change[j].time1 = tvb_get_ntohl(tvb, offset+140+23*j);
4438 scdr.change[j].time2 = tvb_get_ntohl(tvb, offset+144+23*j);
4439 scdr.change[j].uplink = tvb_get_ntohl(tvb, offset+148+23*j);
4440 scdr.change[j].downlink = tvb_get_ntohl(tvb, offset+152+23*j);
4441 /* tvb_memcpy(tvb, scdr.change[j].qos_req, offset+156+23*j, 3);
4442 tvb_memcpy(tvb, scdr.change[j].qos_neg, offset+159+23*j, 3);*/
4444 scdr.timestamp = tvb_get_ntohl(tvb, offset+254);
4445 scdr.opening = tvb_get_ntohl(tvb, offset+258);
4446 scdr.duration = tvb_get_ntohl(tvb, offset+262);
4447 scdr.sgsnchange = tvb_get_guint8(tvb, offset+266);
4448 scdr.closecause = tvb_get_guint8(tvb, offset+267);
4449 scdr.diag1 = tvb_get_guint8(tvb, offset+268);
4450 scdr.diag2 = tvb_get_guint8(tvb, offset+269);
4451 scdr.diag3 = tvb_get_guint8(tvb, offset+270);
4452 scdr.diag4 = tvb_get_guint8(tvb, offset+271);
4453 scdr.diag5 = tvb_get_ntohl(tvb, offset+272);
4454 scdr.seqno = tvb_get_ntohl(tvb, offset+276);
4456 ce = proto_tree_add_text(ext_tree, tvb, offset, data_len + 2, "SCDR (type %x), sequence number: %u", rectype, scdr.seqno);
4457 cdr_tree = proto_item_add_subtree(ce, ett_gtp_ext);
4458 proto_tree_add_text(cdr_tree, tvb, offset, 2, "Length: %u", data_len);
4459 proto_tree_add_text(cdr_tree, tvb, offset+2, 1, "Type: %u (%x)", rectype, rectype);
4460 proto_tree_add_text(cdr_tree, tvb, offset+3, 2, "CDR length: %u", scdr.len);
4461 proto_tree_add_text(cdr_tree, tvb, offset+5, 1, "Network initiated PDP context: %s", yesno[scdr.netini]);
4462 proto_tree_add_text(cdr_tree, tvb, offset+6, 1, "Anonymous acces: %s", yesno[scdr.anon]);
4463 proto_tree_add_text(cdr_tree, tvb, offset+7, 1, "IMSI length: %u", scdr.imsilen);
4464 proto_tree_add_text(cdr_tree, tvb, offset+8, 8, "IMSI: %s", id_to_str(scdr.imsi));
4465 proto_tree_add_text(cdr_tree, tvb, offset+16, 8, "IMEI: %s", id_to_str(scdr.imei));
4466 proto_tree_add_text(cdr_tree, tvb, offset+24, 1, "MSISDN length: %u", scdr.msisdnlen);
4467 proto_tree_add_text(cdr_tree, tvb, offset+25, 10, "MSISDN: %s", msisdn_to_str(scdr.msisdn, 10));
4468 proto_tree_add_text(cdr_tree, tvb, offset+35, 4, "SGSN address: %s", ip_to_str((guint8 *)&scdr.sgsnaddr));
4469 proto_tree_add_text(cdr_tree, tvb, offset+39, 12, "(not used)");
4470 proto_tree_add_text(cdr_tree, tvb, offset+51, 1, "MS network capability length: %u", scdr.msclass_caplen);
4472 /* cap_id = proto_tree_add_text(cdr_tree, tvb, offset+52, 1, "MS network capability: %u", scdr.msclass_cap);
4473 cap_tree = proto_item_add_subtree(cap_id, ett_chrg_cap);
4474 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_gea, tvb, offset+52, 1, scdr.cap);
4475 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_sm_gsm, tvb, offset+52, 1, scdr.cap);
4476 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_sm_gprs, tvb, offset+52, 1, scdr.cap);
4477 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_ucs2, tvb, offset+52, 1, scdr.cap);
4478 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_ss, tvb, offset+52, 1, scdr.cap);
4479 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_solsa, tvb, offset+52, 1, scdr.cap);
4480 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_pad, tvb, offset+52, 1, scdr.cap);
4483 proto_tree_add_text(cdr_tree, tvb, offset+53, 2, "MS network capability omitted: %u", scdr.msclass_capomit);
4484 proto_tree_add_text(cdr_tree, tvb, offset+55, 2, "LAC: %u", scdr.lac);
4485 proto_tree_add_text(cdr_tree, tvb, offset+57, 1, "RAC: %u", scdr.rac);
4486 proto_tree_add_text(cdr_tree, tvb, offset+58, 2, "Cell ID: %u", scdr.cid);
4487 proto_tree_add_text(cdr_tree, tvb, offset+60, 4, "Charging ID: %x", scdr.chrgid);
4488 proto_tree_add_text(cdr_tree, tvb, offset+64, 4, "GGSN address: %s", ip_to_str((guint8 *)&scdr.ggsnaddr));
4489 proto_tree_add_text(cdr_tree, tvb, offset+68, 64, "APN: %s", scdr.apn);
4490 proto_tree_add_text(cdr_tree, tvb, offset+132, 1, "PDP org: %s", val_to_str(scdr.pdporg, pdp_org_type, "Unknown PDP org"));
4491 proto_tree_add_text(cdr_tree, tvb, offset+133, 1, "PDP type: %s", val_to_str(scdr.pdptype, pdp_type, "Unknown PDP type"));
4492 proto_tree_add_text(cdr_tree, tvb, offset+134, 4, "PDP address: %s", ip_to_str((guint8 *)&scdr.pdpaddr));
4493 proto_tree_add_text(cdr_tree, tvb, offset+138, 1, "List of data volume index: %u", scdr.listind);
4495 proto_tree_add_text(cdr_tree, tvb, offset+139+23*j, 1, "List of data vol change condition: %u", scdr.change[j].change);
4496 proto_tree_add_text(cdr_tree, tvb, offset+140+23*j, 4, "Time1: %x", scdr.change[j].time1);
4497 proto_tree_add_text(cdr_tree, tvb, offset+144+23*j, 4, "Time2: %x", scdr.change[j].time2);
4498 proto_tree_add_text(cdr_tree, tvb, offset+148+23*j, 4, "Uplink: %x", scdr.change[j].uplink);
4499 proto_tree_add_text(cdr_tree, tvb, offset+152+23*j, 4, "Downlink: %x", scdr.change[j].downlink);
4500 decode_qos_gprs(tvb, offset+156, cdr_tree, "QoS requested", 0);
4501 decode_qos_gprs(tvb, offset+159, cdr_tree, "QoS negotiated", 0);
4503 proto_tree_add_text(cdr_tree, tvb, offset+254, 4, "Timestamp: %s", time_int_to_str(scdr.timestamp));
4504 proto_tree_add_text(cdr_tree, tvb, offset+258, 4, "Opening: %s", time_int_to_str(scdr.opening));
4505 proto_tree_add_text(cdr_tree, tvb, offset+262, 4, "Duration: %s", rel_time_int_to_str(scdr.duration));
4506 proto_tree_add_text(cdr_tree, tvb, offset+266, 1, "SGSN change: %u", scdr.sgsnchange);
4507 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);
4508 proto_tree_add_text(cdr_tree, tvb, offset+268, 1, "Diagnostics 1: %u", scdr.diag1);
4509 proto_tree_add_text(cdr_tree, tvb, offset+269, 1, "Diagnostics 2: %u", scdr.diag2);
4510 proto_tree_add_text(cdr_tree, tvb, offset+270, 1, "Diagnostics 3: %u", scdr.diag3);
4511 proto_tree_add_text(cdr_tree, tvb, offset+271, 1, "Diagnostics 4: %u", scdr.diag4);
4512 proto_tree_add_text(cdr_tree, tvb, offset+272, 4, "Diagnostics 5: %u", scdr.diag5);
4513 proto_tree_add_text(cdr_tree, tvb, offset+276, 4, "Sequence number: %u", scdr.seqno);
4515 case 0x14: /* MCDR */
4516 if (tvb_length_remaining(tvb, offset) < 3 + 147) {
4517 proto_tree_add_text(ext_tree, tvb, offset, tvb_length_remaining(tvb, offset), "MCDR fragmented, can't dissect");
4521 mcdr.len = tvb_get_ntohs(tvb, offset+3);
4522 mcdr.imsilen = tvb_get_guint8(tvb, offset+5);
4523 tvb_memcpy(tvb, mcdr.imsi, offset+6, 8);
4524 tvb_memcpy(tvb, mcdr.imei, offset+14, 8);
4525 mcdr.msisdnlen = tvb_get_guint8(tvb, offset+22);
4526 tvb_memcpy(tvb, mcdr.msisdn, offset+23, 10);
4527 tvb_memcpy(tvb, (guint8 *)&mcdr.sgsnaddr, offset+33, sizeof mcdr.sgsnaddr);
4528 tvb_memcpy(tvb, mcdr.msclass_notused, offset+37, 12);
4529 mcdr.msclass_caplen = tvb_get_guint8(tvb, offset+49);
4530 mcdr.msclass_cap = tvb_get_guint8(tvb, offset+50);
4531 mcdr.msclass_capomit = tvb_get_ntohs(tvb, offset+51);
4532 mcdr.lac = tvb_get_ntohs(tvb, offset+53);
4533 mcdr.rac = tvb_get_guint8(tvb, offset+55);
4534 mcdr.cid = tvb_get_ntohs(tvb, offset+56);
4535 mcdr.change_count = tvb_get_guint8(tvb, offset+58);
4537 mcdr.change[j].lac = tvb_get_ntohs(tvb, offset+59+13*j);
4538 mcdr.change[j].rac = tvb_get_guint8(tvb, offset+61+13*j);
4539 mcdr.change[j].cid = tvb_get_ntohs(tvb, offset+62+13*j);
4540 tvb_memcpy(tvb, mcdr.change[j].omit, offset+64+13*j, 8);
4542 mcdr.timestamp = tvb_get_ntohl(tvb, offset+124);
4543 mcdr.opening = tvb_get_ntohl(tvb, offset+128);
4544 mcdr.duration = tvb_get_ntohl(tvb, offset+132);
4545 mcdr.sgsnchange = tvb_get_guint8(tvb, offset+136);
4546 mcdr.closecause = tvb_get_guint8(tvb, offset+137);
4547 mcdr.diag1 = tvb_get_guint8(tvb, offset+138);
4548 mcdr.diag2 = tvb_get_guint8(tvb, offset+139);
4549 mcdr.diag3 = tvb_get_guint8(tvb, offset+140);
4550 mcdr.diag4 = tvb_get_guint8(tvb, offset+141);
4551 mcdr.diag5 = tvb_get_ntohl(tvb, offset+142);
4552 mcdr.seqno = tvb_get_ntohl(tvb, offset+146);
4554 ce = proto_tree_add_text(ext_tree, tvb, offset, data_len + 2, "MCDR (0x14), sequence number: %u", mcdr.seqno);
4555 cdr_tree = proto_item_add_subtree(ce, ett_gtp_ext);
4556 proto_tree_add_text(cdr_tree, tvb, offset, 2, "Length: %u", data_len);
4557 proto_tree_add_text(cdr_tree, tvb, offset+2, 1, "Type: %u (%x)", rectype, rectype);
4558 proto_tree_add_text(cdr_tree, tvb, offset+3, 2, "MCDR length: %u", mcdr.len);
4559 proto_tree_add_text(cdr_tree, tvb, offset+5, 1, "IMSI length: %u", mcdr.imsilen);
4560 proto_tree_add_text(cdr_tree, tvb, offset+6, 8, "IMSI: %s", id_to_str(mcdr.imsi));
4561 proto_tree_add_text(cdr_tree, tvb, offset+14, 8, "IMEI: %s", id_to_str(mcdr.imei));
4562 proto_tree_add_text(cdr_tree, tvb, offset+22, 1, "MSISDN length: %u", mcdr.msisdnlen);
4563 proto_tree_add_text(cdr_tree, tvb, offset+23, 10, "MSISDN: %s", msisdn_to_str(mcdr.msisdn, 10));
4564 proto_tree_add_text(cdr_tree, tvb, offset+33, 4, "SGSN address: %s", ip_to_str((guint8 *)&mcdr.sgsnaddr));
4565 proto_tree_add_text(cdr_tree, tvb, offset+37, 12, "(not used)");
4566 proto_tree_add_text(cdr_tree, tvb, offset+49, 1, "MS network capability length: %u", mcdr.msclass_caplen);
4568 /* cap_id = proto_tree_add_text(cdr_tree, tvb, offset+50, 1, "MS network capability: %u", mcdr.msclass_cap);
4569 cap_tree = proto_item_add_subtree(cap_id, ett_chrg_cap);
4570 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_gea, tvb, offset+50, 1, mcdr.cap);
4571 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_sm_gsm, tvb, offset+50, 1, mcdr.cap);
4572 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_sm_gprs, tvb, offset+50, 1, mcdr.cap);
4573 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_ucs2, tvb, offset+50, 1, mcdr.cap);
4574 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_ss, tvb, offset+50, 1, mcdr.cap);
4575 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_solsa, tvb, offset+50, 1, mcdr.cap);
4576 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_pad, tvb, offset+50, 1, mcdr.cap);
4578 proto_tree_add_text(cdr_tree, tvb, offset+51, 2, "MS network capability omitted: %u", mcdr.msclass_capomit);
4579 proto_tree_add_text(cdr_tree, tvb, offset+53, 2, "LAC: %u", mcdr.lac);
4580 proto_tree_add_text(cdr_tree, tvb, offset+55, 1, "RAC: %u", mcdr.rac);
4581 proto_tree_add_text(cdr_tree, tvb, offset+56, 2, "Cell ID: %u", mcdr.cid);
4582 proto_tree_add_text(cdr_tree, tvb, offset+58, 1, "List of data volume changes: %u", mcdr.change_count);
4584 proto_tree_add_text(cdr_tree, tvb, offset+59+13*j, 2, "LAC: %u", mcdr.change[j].lac);
4585 proto_tree_add_text(cdr_tree, tvb, offset+61+13*j, 1, "RAC: %u", mcdr.change[j].rac);
4586 proto_tree_add_text(cdr_tree, tvb, offset+62+13*j, 2, "CID: %u", mcdr.change[j].cid);
4587 proto_tree_add_text(cdr_tree, tvb, offset+64+13*j, 8, "(omitted)");
4590 proto_tree_add_text(cdr_tree, tvb, offset+124, 4, "Timestamp: %s", time_int_to_str(mcdr.timestamp));
4591 proto_tree_add_text(cdr_tree, tvb, offset+128, 4, "Record opening time: %s", time_int_to_str(mcdr.opening));
4592 proto_tree_add_text(cdr_tree, tvb, offset+132, 4, "Duration: %s", rel_time_int_to_str(mcdr.duration));
4593 proto_tree_add_text(cdr_tree, tvb, offset+136, 1, "SGSN change: %u", mcdr.sgsnchange);
4594 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);
4595 proto_tree_add_text(cdr_tree, tvb, offset+138, 1, "Diagnostics 1: %u", mcdr.diag1);
4596 proto_tree_add_text(cdr_tree, tvb, offset+139, 1, "Diagnostics 2: %u", mcdr.diag2);
4597 proto_tree_add_text(cdr_tree, tvb, offset+140, 1, "Diagnostics 3: %u", mcdr.diag3);
4598 proto_tree_add_text(cdr_tree, tvb, offset+141, 1, "Diagnostics 4: %u", mcdr.diag4);
4599 proto_tree_add_text(cdr_tree, tvb, offset+142, 4, "Diagnostics 5: %u", mcdr.diag5);
4600 proto_tree_add_text(cdr_tree, tvb, offset+146, 4, "Sequence number: %u", mcdr.seqno);
4603 case 0x15: /* SOCDR */
4604 if (tvb_length_remaining(tvb, offset) < 3 + 80) {
4605 proto_tree_add_text(ext_tree, tvb, offset, tvb_length_remaining(tvb, offset), "SOCDR fragmented, can't dissect");
4609 socdr.len = tvb_get_ntohs(tvb, offset+3);
4610 socdr.imsilen = tvb_get_guint8(tvb, offset+5);
4611 tvb_memcpy(tvb, socdr.imsi, offset+6, 8);
4612 tvb_memcpy(tvb, socdr.imei, offset+14, 8);
4613 socdr.msisdnlen = tvb_get_guint8(tvb, offset+22);
4614 tvb_memcpy(tvb, socdr.msisdn, offset+23, 10);
4615 tvb_memcpy(tvb, socdr.msclass_notused, offset+33, 12);
4616 socdr.msclass_caplen = tvb_get_guint8(tvb, offset+45);
4617 socdr.msclass_cap = tvb_get_guint8(tvb, offset+46);
4618 socdr.msclass_capomit = tvb_get_ntohs(tvb, offset+47);
4619 tvb_memcpy(tvb, socdr.serv_centr, offset+49, 9);
4620 tvb_memcpy(tvb, socdr.rec_ent, offset+58, 9);
4621 socdr.lac = tvb_get_ntohs(tvb, offset+67);
4622 socdr.rac = tvb_get_guint8(tvb, offset+69);
4623 socdr.cid = tvb_get_ntohs(tvb, offset+70);
4624 socdr.time1 = tvb_get_ntohl(tvb, offset+72);
4625 socdr.time2 = tvb_get_ntohl(tvb, offset+76);
4626 socdr.messref = tvb_get_guint8(tvb, offset+80);
4627 socdr.smsres = tvb_get_ntohs(tvb, offset+81);
4629 ce = proto_tree_add_text(ext_tree, tvb, offset, data_len + 2, "SOCDR (0x15)");
4630 cdr_tree = proto_item_add_subtree(ce, ett_gtp_ext);
4631 proto_tree_add_text(cdr_tree, tvb, offset, 2, "Length: %u", data_len);
4632 proto_tree_add_text(cdr_tree, tvb, offset+2, 1, "Type: %u (%x)", rectype, rectype);
4633 proto_tree_add_text(cdr_tree, tvb, offset+3, 2, "MCDR length: %u", socdr.len);
4634 proto_tree_add_text(cdr_tree, tvb, offset+5, 1, "IMSI length: %u", socdr.imsilen);
4635 proto_tree_add_text(cdr_tree, tvb, offset+6, 8, "IMSI: %s", id_to_str(socdr.imsi));
4636 proto_tree_add_text(cdr_tree, tvb, offset+14, 8, "IMEI: %s", id_to_str(socdr.imei));
4637 proto_tree_add_text(cdr_tree, tvb, offset+22, 1, "MSISDN length: %u", socdr.msisdnlen);
4638 proto_tree_add_text(cdr_tree, tvb, offset+23, 10, "MSISDN: %s", msisdn_to_str(socdr.msisdn, 10));
4639 proto_tree_add_text(cdr_tree, tvb, offset+33, 12, "(not used)");
4640 proto_tree_add_text(cdr_tree, tvb, offset+45, 1, "MS network capability length: %u", socdr.msclass_caplen);
4642 /* cap_id = proto_tree_add_text(cdr_tree, tvb, offset+46, 1, "MS network capability: %u", socdr.msclass_cap);
4643 cap_tree = proto_item_add_subtree(cap_id, ett_chrg_cap);
4644 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_gea, tvb, offset+46, 1, socdr.cap);
4645 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_sm_gsm, tvb, offset+46, 1, socdr.cap);
4646 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_sm_gprs, tvb, offset+46, 1, socdr.cap);
4647 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_ucs2, tvb, offset+46, 1, socdr.cap);
4648 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_ss, tvb, offset+46, 1, socdr.cap);
4649 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_solsa, tvb, offset+46, 1, socdr.cap);
4651 proto_tree_add_text(cdr_tree, tvb, offset+47, 2, "MS network capability omitted: %u", stcdr.msclass_capomit);
4652 proto_tree_add_text(cdr_tree, tvb, offset+49, 9, "SMSC E.164 address: %s", msisdn_to_str(socdr.serv_centr, 9));
4653 proto_tree_add_text(cdr_tree, tvb, offset+58, 9, "SGSN E.164 address: %s", msisdn_to_str(socdr.rec_ent, 9));
4654 proto_tree_add_text(cdr_tree, tvb, offset+67, 2, "LAC: %u", socdr.lac);
4655 proto_tree_add_text(cdr_tree, tvb, offset+69, 1, "RAC: %u", socdr.rac);
4656 proto_tree_add_text(cdr_tree, tvb, offset+70, 2, "Cell ID: %u", socdr.cid);
4657 proto_tree_add_text(cdr_tree, tvb, offset+72, 4, "Time1: %s", time_int_to_str(socdr.time1));
4658 proto_tree_add_text(cdr_tree, tvb, offset+76, 4, "Time2: %s", time_int_to_str(socdr.time2));
4659 proto_tree_add_text(cdr_tree, tvb, offset+80, 1, "Message reference: %u", socdr.messref);
4660 proto_tree_add_text(cdr_tree, tvb, offset+81, 2, "Delivery result: %u", socdr.smsres);
4663 case 0x16: /* STCDR */
4664 if (tvb_length_remaining(tvb, offset) < 3 + 79) {
4665 proto_tree_add_text(ext_tree, tvb, offset, tvb_length_remaining(tvb, offset), "STCDR fragmented, can't dissect");
4669 stcdr.len = tvb_get_ntohs(tvb, offset+3);
4670 stcdr.imsilen = tvb_get_guint8(tvb, offset+5);
4671 tvb_memcpy(tvb, stcdr.imsi, offset+6, 8);
4672 tvb_memcpy(tvb, stcdr.imei, offset+14, 8);
4673 stcdr.msisdnlen = tvb_get_guint8(tvb, offset+22);
4674 tvb_memcpy(tvb, stcdr.msisdn, offset+23, 10);
4675 tvb_memcpy(tvb, stcdr.msclass_notused, offset+33, 12);
4676 stcdr.msclass_caplen = tvb_get_guint8(tvb, offset+45);
4677 stcdr.msclass_cap = tvb_get_guint8(tvb, offset+46);
4678 stcdr.msclass_capomit = tvb_get_ntohs(tvb, offset+47);
4679 tvb_memcpy(tvb, stcdr.serv_centr, offset+49, 9);
4680 tvb_memcpy(tvb, stcdr.rec_ent, offset+58, 9);
4681 stcdr.lac = tvb_get_ntohs(tvb, offset+67);
4682 stcdr.rac = tvb_get_guint8(tvb, offset+69);
4683 stcdr.cid = tvb_get_ntohs(tvb, offset+70);
4684 stcdr.time1 = tvb_get_ntohl(tvb, offset+72);
4685 stcdr.time2 = tvb_get_ntohl(tvb, offset+76);
4686 stcdr.smsres = tvb_get_ntohs(tvb, offset+80);
4688 ce = proto_tree_add_text(ext_tree, tvb, offset, data_len + 2, "STCDR (0x16)");
4689 cdr_tree = proto_item_add_subtree(ce, ett_gtp_ext);
4690 proto_tree_add_text(cdr_tree, tvb, offset, 2, "Length: %u", data_len);
4691 proto_tree_add_text(cdr_tree, tvb, offset+2, 1, "Type: %u (%x)", rectype, rectype);
4692 proto_tree_add_text(cdr_tree, tvb, offset+3, 2, "MCDR length: %u", stcdr.len);
4693 proto_tree_add_text(cdr_tree, tvb, offset+5, 1, "IMSI length: %u", stcdr.imsilen);
4694 proto_tree_add_text(cdr_tree, tvb, offset+6, 8, "IMSI: %s", id_to_str(stcdr.imsi));
4695 proto_tree_add_text(cdr_tree, tvb, offset+14, 8, "IMEI: %s", id_to_str(stcdr.imei));
4696 proto_tree_add_text(cdr_tree, tvb, offset+22, 1, "MSISDN length: %u", stcdr.msisdnlen);
4697 proto_tree_add_text(cdr_tree, tvb, offset+23, 10, "MSISDN: %s", msisdn_to_str(stcdr.msisdn, 10));
4698 proto_tree_add_text(cdr_tree, tvb, offset+33, 12, "(not used)");
4699 proto_tree_add_text(cdr_tree, tvb, offset+45, 1, "MS network capability length: %u", stcdr.msclass_caplen);
4701 /* cap_id = proto_tree_add_text(cdr_tree, tvb, offset+46, 1, "MS network capability: %u", stcdr.msclass_cap);
4702 cap_tree = proto_item_add_subtree(cap_id, ett_chrg_cap);
4703 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_gea, tvb, offset+46, 1, stcdr.cap);
4704 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_sm_gsm, tvb, offset+46, 1, stcdr.cap);
4705 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_sm_gprs, tvb, offset+46, 1, stcdr.cap);
4706 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_ucs2, tvb, offset+46, 1, stcdr.cap);
4707 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_ss, tvb, offset+46, 1, stcdr.cap);
4708 proto_tree_add_uint(cap_tree, hf_gtpv0_chrg_cap_solsa, tvb, offset+46, 1, stcdr.cap);
4710 proto_tree_add_text(cdr_tree, tvb, offset+47, 2, "MS network capability omitted: %u", stcdr.msclass_capomit);
4711 proto_tree_add_text(cdr_tree, tvb, offset+49, 9, "SMSC E.164 address: %s", msisdn_to_str(stcdr.serv_centr, 9));
4712 proto_tree_add_text(cdr_tree, tvb, offset+58, 9, "SGSN E.164 address: %s", msisdn_to_str(stcdr.rec_ent, 9));
4713 proto_tree_add_text(cdr_tree, tvb, offset+67, 2, "LAC: %u", stcdr.lac);
4714 proto_tree_add_text(cdr_tree, tvb, offset+69, 1, "RAC: %u", stcdr.rac);
4715 proto_tree_add_text(cdr_tree, tvb, offset+70, 2, "Cell ID: %u", stcdr.cid);
4716 proto_tree_add_text(cdr_tree, tvb, offset+72, 4, "Time1: %s", time_int_to_str(stcdr.time1));
4717 proto_tree_add_text(cdr_tree, tvb, offset+76, 4, "Time2: %s", time_int_to_str(stcdr.time2));
4718 proto_tree_add_text(cdr_tree, tvb, offset+80, 2, "Delivery result: %u", stcdr.smsres);
4721 offset = offset + 2 + data_len;
4731 decode_gtp_data_resp(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
4733 guint16 length, n, number;
4734 proto_tree *ext_tree_data_resp;
4737 length = tvb_get_ntohs(tvb, offset + 1);
4739 te = proto_tree_add_text(tree, tvb, offset, 3 + length, "Requests responded");
4740 ext_tree_data_resp = proto_item_add_subtree(te, ett_gtp_data_resp);
4744 while (n < length) {
4746 number = tvb_get_ntohs(tvb, offset + 3 + n);
4747 proto_tree_add_text(ext_tree_data_resp, tvb, offset + 3 + n, 2, "%u", number);
4760 decode_gtp_node_addr(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
4764 struct e_in6_addr addr_ipv6;
4765 proto_tree *ext_tree_node_addr;
4768 length = tvb_get_ntohs(tvb, offset+1);
4770 te = proto_tree_add_text(tree, tvb, offset, 3+length, "Node address: ");
4771 ext_tree_node_addr = proto_item_add_subtree(te, ett_gtp_node_addr);
4773 proto_tree_add_text(ext_tree_node_addr, tvb, offset+1, 2, "Node address length: %u", length);
4777 tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+3, sizeof addr_ipv4);
4778 proto_item_append_text(te, "%s", ip_to_str((guint8 *)&addr_ipv4));
4779 proto_tree_add_ipv4(ext_tree_node_addr, gtp_version ? hf_gtpv1_node_ipv4 : hf_gtpv0_node_ipv4, tvb, offset+3, 4, addr_ipv4);
4782 tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+3, sizeof addr_ipv6);
4783 proto_item_append_text(te, "%s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
4784 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);
4787 proto_item_append_text(te, "unknown type or wrong length");
4795 /* GPRS: 9.60 v7.6.0, chapter 7.9.26
4796 * UMTS: 29.060 v4.0, chapter 7.7.44
4799 decode_gtp_priv_ext(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
4801 guint16 length, ext_id;
4803 proto_tree *ext_tree_priv_ext;
4806 te = proto_tree_add_text(tree, tvb, offset, 1, val_to_str(GTP_EXT_PRIV_EXT, gtp_val, "Unknown message"));
4807 ext_tree_priv_ext = proto_item_add_subtree(te, ett_gtp_ext);
4809 length = tvb_get_ntohs(tvb, offset+1);
4810 if (length < 1) return 3+length;
4812 ext_id = tvb_get_ntohs(tvb, offset+3);
4813 tvb_memcpy(tvb, ext_val, offset+5, length > 65 ? 63 : length-2);
4814 ext_val[length > 65 ? 64 : length-1] = '\0';
4815 proto_tree_add_uint(ext_tree_priv_ext, gtp_version ? hf_gtpv1_ext_id : hf_gtpv0_ext_id, tvb, offset+3, 2, ext_id);
4816 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);
4822 decode_gtp_unknown(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
4824 proto_tree_add_text(tree, tvb, offset, 1, "Unknown extension header");
4826 return tvb_length_remaining(tvb, offset);
4830 dissect_gtpv0(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
4833 _gtpv0_hdr gtpv0_hdr;
4834 proto_item *ti, *tf;
4835 proto_tree *gtpv0_tree, *flags_tree;
4838 const guint8 *tid_val;
4840 int offset, length, i, mandatory, checked_field, gtp_prime = 0;
4842 if (check_col(pinfo->cinfo, COL_PROTOCOL))
4843 col_set_str(pinfo->cinfo, COL_PROTOCOL, "GTP");
4844 if (check_col(pinfo->cinfo, COL_INFO))
4845 col_clear(pinfo->cinfo, COL_INFO);
4847 tvb_memcpy(tvb, (guint8 *)>pv0_hdr, 0, 12);
4848 tid_val = tvb_get_ptr(tvb, 12, 8);
4849 tid_str = id_to_str(tid_val);
4850 gtp_version = (gtpv0_hdr.flags >> 5) & 0x07;
4852 if (!((gtpv0_hdr.flags >> 4) & 1)) {
4854 if (check_col(pinfo->cinfo, COL_PROTOCOL))
4855 col_set_str(pinfo->cinfo, COL_PROTOCOL, "GTP-CDR");
4857 switch ((gtpv0_hdr.flags >> 5) & 0x07) {
4858 case 0: if (check_col(pinfo->cinfo, COL_PROTOCOL))
4859 col_set_str(pinfo->cinfo, COL_PROTOCOL, "GTP");
4861 case 1: if (check_col(pinfo->cinfo, COL_PROTOCOL))
4862 col_set_str(pinfo->cinfo, COL_PROTOCOL, "GTPv1");
4863 default: if (check_col(pinfo->cinfo, COL_PROTOCOL))
4864 col_set_str(pinfo->cinfo, COL_PROTOCOL, "GTPv?");
4869 if (check_col(pinfo->cinfo, COL_INFO))
4870 col_add_str(pinfo->cinfo, COL_INFO, val_to_str(gtpv0_hdr.message, message_type, "Unknown"));
4874 /* dissect GTP header */
4875 ti = proto_tree_add_item(tree, proto_gtpv0, tvb, 0, -1, FALSE);
4876 gtpv0_tree = proto_item_add_subtree(ti, ett_gtp);
4878 tf = proto_tree_add_uint(gtpv0_tree, hf_gtpv0_flags, tvb, 0, 1, gtpv0_hdr.flags);
4880 flags_tree = proto_item_add_subtree(tf, ett_gtp_flags);
4881 proto_tree_add_uint(flags_tree, hf_gtpv0_flags_ver, tvb, 0, 1, gtpv0_hdr.flags);
4882 proto_tree_add_uint(flags_tree, hf_gtpv0_flags_pt, tvb, 0, 1, gtpv0_hdr.flags);
4883 proto_tree_add_uint(flags_tree, hf_gtpv0_flags_spare, tvb, 0, 1, gtpv0_hdr.flags);
4884 proto_tree_add_boolean(flags_tree, hf_gtpv0_flags_snn, tvb, 0, 1, gtpv0_hdr.flags);
4886 gtpv0_hdr.length = g_ntohs(gtpv0_hdr.length);
4887 gtpv0_hdr.seq_no = g_ntohs(gtpv0_hdr.seq_no);
4888 gtpv0_hdr.flow_label = g_ntohs(gtpv0_hdr.flow_label);
4889 proto_tree_add_uint(gtpv0_tree, hf_gtpv0_message_type, tvb, 1, 1, gtpv0_hdr.message);
4890 proto_tree_add_uint(gtpv0_tree, hf_gtpv0_length, tvb, 2, 2, gtpv0_hdr.length);
4891 proto_tree_add_uint(gtpv0_tree, hf_gtpv0_seq_number, tvb, 4, 2, gtpv0_hdr.seq_no);
4893 /* GTP' has 6 bytes of length */
4895 proto_tree_add_uint(gtpv0_tree, hf_gtpv0_flow_label, tvb, 6, 2, gtpv0_hdr.flow_label);
4896 proto_tree_add_uint(gtpv0_tree, hf_gtpv0_sndcp_number, tvb, 8, 1, gtpv0_hdr.sndcp_no);
4897 proto_tree_add_string(gtpv0_tree, hf_gtpv0_tid, tvb, 12, 8, tid_str);
4900 if (gtpv0_hdr.message != GTP_MSG_TPDU) {
4902 proto_tree_add_text(gtpv0_tree, tvb, 0, 0, "[--- end of GTPv0 header, beginning of extension headers ---]");
4904 offset = gtp_prime ? GTP_PRIME_HDR_LENGTH : GTPv0_HDR_LENGTH;
4906 length = tvb_length(tvb);
4908 mandatory = 0; /* check order of GTP fields against ETSI */
4912 if (offset >= length) break;
4913 ext_hdr_val = tvb_get_guint8(tvb, offset);
4915 if (gtpv0_etsi_order) {
4916 checked_field = check_field_presence (gtpv0_hdr.message, ext_hdr_val , (int *)&mandatory);
4917 switch (checked_field) {
4918 case -2: proto_tree_add_text(gtpv0_tree, tvb, 0, 0, "[WARNING] message not found");
4920 case -1: proto_tree_add_text(gtpv0_tree, tvb, 0, 0, "[WARNING] field not present");
4923 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"));
4928 while (gtpopt[++i].optcode) if (gtpopt[i].optcode == ext_hdr_val) break;
4929 offset = offset + (*gtpopt[i].decode)(tvb, offset, pinfo, gtpv0_tree);
4934 /* next part dissects sublayers of GTP */
4936 if ((gtpv0_hdr.message == GTP_MSG_TPDU) && gtp_tpdu) {
4939 sub_proto = tvb_get_guint8(tvb,GTPv0_HDR_LENGTH);
4941 if ((sub_proto >= 0x45) && (sub_proto <= 0x4e)) {
4942 /* this is most likely an IPv4 packet */
4943 /* we can exclude 0x40 - 0x44 because the minimum header size is 20 octets */
4944 /* 0x4f is excluded because PPP protocol type "IPv6 header compression"
4945 with protocol field compression is more likely than a plain IPv4 packet with 60 octet header size */
4947 next_tvb = tvb_new_subset(tvb, GTPv0_HDR_LENGTH, -1, -1);
4948 call_dissector(ip_handle, next_tvb, pinfo, tree);
4950 if ((sub_proto & 0xf0) == 0x60) {
4951 /* this is most likely an IPv6 packet */
4952 next_tvb = tvb_new_subset(tvb, GTPv0_HDR_LENGTH, -1, -1);
4953 call_dissector(ipv6_handle, next_tvb, pinfo, tree);
4955 /* this seems to be a PPP packet */
4956 guint8 acfield_len = 0;
4958 if (sub_proto == 0xff) {
4959 /* this might be an address field, even it shouldn't be here */
4960 guint8 control_field = tvb_get_guint8(tvb,GTPv0_HDR_LENGTH + 1);
4961 if (control_field == 0x03) {
4962 /* now we are pretty sure that address and control field are mistakenly inserted -> ignore it for PPP dissection */
4966 next_tvb = tvb_new_subset(tvb, GTPv0_HDR_LENGTH + acfield_len, -1, -1);
4967 call_dissector(ppp_handle, next_tvb, pinfo, tree);
4969 if (check_col(pinfo->cinfo, COL_PROTOCOL))
4970 col_append_str_gtp(pinfo->cinfo, COL_PROTOCOL, "GTP");
4974 /* GTP v1 dissector */
4976 dissect_gtpv1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
4978 _gtpv1_hdr gtpv1_hdr;
4979 proto_item *ti, *tf;
4980 proto_tree *gtpv1_tree, *flags_tree;
4982 guint8 ext_hdr_val, i, hdr_offset = 4, next_hdr, npdu_no, sub_proto;
4984 int offset, length, mandatory, checked_field, gtp_prime = 0;
4986 if (check_col(pinfo->cinfo, COL_PROTOCOL))
4987 col_set_str(pinfo->cinfo, COL_PROTOCOL, "GTP-C");
4988 if (check_col(pinfo->cinfo, COL_INFO))
4989 col_clear(pinfo->cinfo, COL_INFO);
4991 tvb_memcpy(tvb, (guint8 *)>pv1_hdr, 0, 8);
4992 gtp_version = (gtpv1_hdr.flags >> 5) & 0x07;
4994 if (check_col(pinfo->cinfo, COL_INFO))
4995 col_add_str(pinfo->cinfo, COL_INFO, val_to_str(gtpv1_hdr.message, message_type, "Unknown"));
4999 ti = proto_tree_add_item(tree, proto_gtpv1, tvb, 0, -1, FALSE);
5000 gtpv1_tree = proto_item_add_subtree(ti, ett_gtp);
5002 tf = proto_tree_add_uint(gtpv1_tree, hf_gtpv1_flags, tvb, 0, 1, gtpv1_hdr.flags);
5003 flags_tree = proto_item_add_subtree(tf, ett_gtp_flags);
5005 proto_tree_add_uint(flags_tree, hf_gtpv1_flags_ver, tvb, 0, 1, gtpv1_hdr.flags);
5006 proto_tree_add_uint(flags_tree, hf_gtpv1_flags_pt, tvb, 0, 1, gtpv1_hdr.flags);
5007 proto_tree_add_uint(flags_tree, hf_gtpv1_flags_spare, tvb, 0, 1, gtpv1_hdr.flags);
5008 proto_tree_add_boolean(flags_tree, hf_gtpv1_flags_e, tvb, 0, 1, gtpv1_hdr.flags);
5009 proto_tree_add_boolean(flags_tree, hf_gtpv1_flags_s, tvb, 0, 1, gtpv1_hdr.flags);
5010 proto_tree_add_boolean(flags_tree, hf_gtpv1_flags_pn, tvb, 0, 1, gtpv1_hdr.flags);
5012 proto_tree_add_uint(gtpv1_tree, hf_gtpv1_message_type, tvb, 1, 1, gtpv1_hdr.message);
5014 gtpv1_hdr.length = g_ntohs(gtpv1_hdr.length);
5015 proto_tree_add_uint(gtpv1_tree, hf_gtpv1_length, tvb, 2, 2, gtpv1_hdr.length);
5017 gtp_prime = (gtpv1_hdr.flags & 0x01) >> 4;
5019 /* GTP' has 6 bytes of length */
5023 gtpv1_hdr.teid = g_ntohl(gtpv1_hdr.teid);
5024 proto_tree_add_uint(gtpv1_tree, hf_gtpv1_teid, tvb, 4, 4, gtpv1_hdr.teid);
5026 if (gtpv1_hdr.flags & 0x07) {
5027 seq_no = tvb_get_ntohs (tvb, 8);
5028 proto_tree_add_uint (gtpv1_tree, hf_gtpv1_seq_number, tvb, 8, 2, seq_no);
5029 npdu_no = tvb_get_guint8 (tvb, 10);
5030 proto_tree_add_uint (gtpv1_tree, hf_gtpv1_npdu_number, tvb, 10, 1, npdu_no);
5031 next_hdr = tvb_get_guint8(tvb, 11);
5032 proto_tree_add_uint(gtpv1_tree, hf_gtpv1_next, tvb, 11, 1, next_hdr);
5035 if (next_hdr) hdr_offset = 1;
5036 else hdr_offset = 0;
5040 if (gtpv1_hdr.message != GTP_MSG_TPDU) {
5042 proto_tree_add_text(gtpv1_tree, tvb, 0, 0, "[--- end of GTP v1 header, beginning of extension headers ---]");
5044 offset = gtp_prime ? GTP_PRIME_HDR_LENGTH: GTPv1_HDR_LENGTH - hdr_offset;
5045 length = tvb_length(tvb);
5047 mandatory = 0; /* check order of GTP fields against ETSI */
5051 if (offset >= length) break;
5052 ext_hdr_val = tvb_get_guint8(tvb, offset);
5054 if (gtpv1_etsi_order) {
5055 checked_field = check_field_presence (gtpv1_hdr.message, ext_hdr_val , (int *)&mandatory);
5056 switch (checked_field) {
5057 case -2: proto_tree_add_text(gtpv1_tree, tvb, 0, 0, "[WARNING] message not found");
5059 case -1: proto_tree_add_text(gtpv1_tree, tvb, 0, 0, "[WARNING] field not present");
5062 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"));
5067 while (gtpopt[++i].optcode) if (gtpopt[i].optcode == ext_hdr_val) break;
5068 offset = offset + (*gtpopt[i].decode)(tvb, offset, pinfo, gtpv1_tree);
5073 if (gtpv1_hdr.message == GTP_MSG_ERR_IND)
5074 if (check_col(pinfo->cinfo, COL_PROTOCOL))
5075 col_add_str(pinfo->cinfo, COL_PROTOCOL, "GTP-U");
5078 if ((gtpv1_hdr.message == GTP_MSG_TPDU) && gtp_tpdu) {
5080 if (gtpv1_hdr.flags & 0x07) {
5081 if (tvb_get_guint8 (tvb, 11))
5082 hdr_offset = 1; /* if next_hdr != 0 */
5087 sub_proto = tvb_get_guint8(tvb,GTPv1_HDR_LENGTH - hdr_offset);
5089 if ((sub_proto >= 0x45) && (sub_proto <= 0x4e)) {
5090 /* this is most likely an IPv4 packet */
5091 /* we can exclude 0x40 - 0x44 because the minimum header size is 20 octets */
5092 /* 0x4f is excluded because PPP protocol type "IPv6 header compression"
5093 with protocol field compression is more likely than a plain IPv4 packet with 60 octet header size */
5095 next_tvb = tvb_new_subset(tvb, GTPv1_HDR_LENGTH - hdr_offset, -1, -1);
5096 call_dissector(ip_handle, next_tvb, pinfo, tree);
5098 if ((sub_proto & 0xf0) == 0x60)
5100 /* this is most likely an IPv6 packet */
5101 next_tvb = tvb_new_subset(tvb, GTPv1_HDR_LENGTH - hdr_offset, -1, -1);
5102 call_dissector(ipv6_handle, next_tvb, pinfo, tree);
5104 /* this seems to be a PPP packet */
5105 guint8 acfield_len = 0;
5107 if (sub_proto == 0xff) {
5108 /* this might be an address field, even it shouldn't be here */
5109 guint8 control_field;
5110 control_field = tvb_get_guint8(tvb,GTPv1_HDR_LENGTH - hdr_offset + 1);
5111 if (control_field == 0x03)
5113 /* now we are pretty sure that address and control field are mistakenly inserted -> ignore it for PPP dissection */
5117 next_tvb = tvb_new_subset(tvb, GTPv1_HDR_LENGTH - hdr_offset + acfield_len, -1, -1);
5118 call_dissector(ppp_handle, next_tvb, pinfo, tree);
5120 if (check_col(pinfo->cinfo, COL_PROTOCOL))
5121 col_append_str_gtp(pinfo->cinfo, COL_PROTOCOL, "GTP-U");
5125 static const true_false_string yes_no_tfs = {
5131 proto_register_gtp(void)
5134 static hf_register_info hf_gtpv0[] = {
5136 { &hf_gtpv0_flags, { "Flags", "gtpv0.flags", FT_UINT8, BASE_HEX, NULL, 0, "Ver/PT/Spare/SNN", HFILL }},
5137 { &hf_gtpv0_flags_ver, { "Version", "gtpv0.flags.version", FT_UINT8, BASE_DEC, VALS(ver_types), GTP_VER_MASK, "GTP Version", HFILL }},
5138 { &hf_gtpv0_flags_pt, { "Protocol type", "gtpv0.flags.payload", FT_UINT8, BASE_DEC, NULL, GTP_PT_MASK, "Protocol Type (1 = GTP, 0 = GTP' )", HFILL }},
5139 { &hf_gtpv0_flags_spare, { "Reserved", "gtpv0.flags.reserved", FT_UINT8, BASE_DEC, NULL, GTP_SPARE_MASK, "Reserved (shall be sent as '111' )", HFILL }},
5140 { &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 }},
5141 { &hf_gtpv0_message_type, { "Message type", "gtpv0.message", FT_UINT8, BASE_HEX, VALS(message_type), 0x0, "GTP Message Type", HFILL }},
5142 { &hf_gtpv0_length, { "Length", "gtpv0.length", FT_UINT16, BASE_DEC, NULL, 0, "Length (i.e. number of octets after TID or TEID)", HFILL }},
5143 { &hf_gtpv0_seq_number, { "Sequence number", "gtpv0.seq_number", FT_UINT16, BASE_HEX, NULL, 0, "Sequence Number", HFILL }},
5144 { &hf_gtpv0_flow_label, { "Flow label", "gtpv0.flow_label", FT_UINT16, BASE_HEX, NULL, 0, "Flow label", HFILL }},
5145 { &hf_gtpv0_sndcp_number, { "SNDCP N-PDU LLC Number", "gtpv0.sndcp_number", FT_UINT8, BASE_HEX, NULL, 0, "SNDCP N-PDU LLC Number", HFILL }},
5146 { &hf_gtpv0_tid, { "TID", "gtpv0.tid", FT_STRING, BASE_DEC, NULL, 0, "Tunnel Identifier", HFILL }},
5147 { &hf_gtpv0_cause, { "Cause", "gtpv0.cause", FT_UINT8, BASE_DEC, VALS(cause_type), 0, "Cause of operation", HFILL }},
5148 { &hf_gtpv0_imsi, { "IMSI", "gtpv0.imsi", FT_STRING, BASE_DEC, NULL, 0, "International Mobile Subscriber Identity number", HFILL }},
5149 { &hf_gtpv0_rai_mcc, { "MCC", "gtpv0.mcc", FT_UINT16, BASE_DEC, NULL, 0, "Mobile Country Code", HFILL }},
5150 { &hf_gtpv0_rai_mnc, { "MNC", "gtpv0.mnc", FT_UINT8, BASE_DEC, NULL, 0, "Mobile Network Code", HFILL }},
5151 { &hf_gtpv0_rai_rac, { "RAC", "gtpv0.rac", FT_UINT8, BASE_DEC, NULL, 0, "Routing Area Code", HFILL }},
5152 { &hf_gtpv0_rai_lac, { "LAC", "gtpv0.lac", FT_UINT16, BASE_DEC, NULL, 0, "Location Area Code", HFILL }},
5153 { &hf_gtpv0_tlli, { "TLLI", "gtpv0.tlli", FT_UINT32, BASE_HEX, NULL, 0, "Temporary Logical Link Identity", HFILL }},
5154 { &hf_gtpv0_ptmsi, { "P-TMSI", "gtpv0.ptmsi", FT_UINT32, BASE_HEX, NULL, 0, "Packet-Temporary Mobile Subscriber Identity", HFILL }},
5155 { &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 }},
5156 { &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 }},
5157 { &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 }},
5158 { &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 }},
5159 { &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 }},
5160 { &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 }},
5161 { &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 }},
5162 { &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 }},
5163 { &hf_gtpv0_reorder, { "Reordering required","gtpv0.reorder", FT_BOOLEAN, BASE_NONE,NULL, 0, "Reordering required", HFILL }},
5164 { &hf_gtpv0_map_cause, { "MAP cause", "gtpv0.map_cause", FT_UINT8, BASE_DEC, VALS(map_cause_type), 0, "MAP cause", HFILL }},
5165 { &hf_gtpv0_ptmsi_sig, { "P-TMSI signature", "gtpv0.ptmsi_sig", FT_UINT24, BASE_HEX, NULL, 0, "P-TMSI Signature", HFILL }},
5166 { &hf_gtpv0_ms_valid, { "MS validated", "gtpv0.ms_valid", FT_BOOLEAN, BASE_NONE,NULL, 0, "MS validated", HFILL }},
5167 { &hf_gtpv0_recovery, { "Recovery", "gtpv0.recovery", FT_UINT8, BASE_DEC, NULL, 0, "Restart counter", HFILL }},
5168 { &hf_gtpv0_sel_mode, { "Selection mode", "gtpv0.sel_mode", FT_UINT8, BASE_DEC, VALS(sel_mode_type), 0, "Selection Mode", HFILL }},
5169 { &hf_gtpv0_ext_flow_label, { "Flow Label Data I", "gtpv0.ext_flow_label", FT_UINT16, BASE_DEC, NULL, 0, "Flow label data", HFILL }},
5170 { &hf_gtpv0_flow_sig, { "Flow label Signalling", "gtpv0.flow_sig", FT_UINT16, BASE_DEC, NULL, 0, "Flow label signalling", HFILL }},
5171 { &hf_gtpv0_nsapi, { "NSAPI ", "gtpv0.nsapi", FT_UINT8, BASE_DEC, NULL, 0, "Network layer Service Access Point Identifier", HFILL }},
5172 { &hf_gtpv0_flow_ii, { "Flow Label Data II ","gtpv0.flow_ii", FT_UINT16, BASE_DEC, NULL, 0, "Downlink flow label data", HFILL }},
5173 { &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 }},
5174 { &hf_gtpv0_tr_comm, { "Packet transfer command", "gtpv0.tr_comm", FT_UINT8, BASE_DEC, VALS(tr_comm_type), 0, "Packat transfer command", HFILL }},
5175 { &hf_gtpv0_chrg_id, { "Charging ID ", "gtpv0.chrg_id", FT_UINT32, BASE_HEX, NULL, 0, "Charging ID", HFILL }},
5176 { &hf_gtpv0_user_ipv4, { "End user address IPv4", "gtpv0.user_ipv4", FT_IPv4, BASE_DEC, NULL, 0, "End user address IPv4", HFILL }},
5177 { &hf_gtpv0_user_ipv6, { "End user address IPv6", "gtpv0.user_ipv6", FT_IPv6, BASE_HEX, NULL, 0, "End user address IPv6", HFILL }},
5178 { &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 }},
5179 { &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 }},
5180 { &hf_gtpv0_apn, { "APN", "gtpv0.apn", FT_STRING, BASE_DEC, NULL, 0, "Access Point Name", HFILL }},
5181 { &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 }},
5182 { &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 }},
5183 { &hf_gtpv0_gsn_ipv4, { "GSN address IPv4", "gtpv0.gsn_ipv4", FT_IPv4, BASE_DEC, NULL, 0, "GSN address IPv4", HFILL }},
5184 { &hf_gtpv0_gsn_ipv6, { "GSN address IPv6", "gtpv0.gsn_ipv6", FT_IPv6, BASE_DEC, NULL, 0, "GSN address IPv6", HFILL }},
5185 { &hf_gtpv0_msisdn, { "MSISDN", "gtpv0.msisdn", FT_STRING, BASE_DEC, NULL, 0, "MS international PSTN/ISDN number", HFILL }},
5186 { &hf_gtpv0_chrg_ipv4, { "CG address IPv4", "gtpv0.chrg_ipv4", FT_IPv4, BASE_DEC, NULL, 0, "Charging Gateway address IPv4", HFILL }},
5187 { &hf_gtpv0_chrg_ipv6, { "CG address IPv6", "gtpv0.chrg_ipv6", FT_IPv6, BASE_HEX, NULL, 0, "Charging Gateway address IPv6", HFILL }},
5188 { &hf_gtpv0_node_ipv4, { "Node address IPv4", "gtpv0.node_ipv4", FT_IPv4, BASE_DEC, NULL, 0, "Recommended node address IPv4", HFILL }},
5189 { &hf_gtpv0_node_ipv6, { "Node address IPv6", "gtpv0.node_ipv6", FT_IPv6, BASE_HEX, NULL, 0, "Recommended node address IPv6", HFILL }},
5190 { &hf_gtpv0_ext_id, { "Extension identifier", "gtpv0.ext_id", FT_UINT16, BASE_DEC, NULL, 0, "Extension Identifier", HFILL }},
5191 { &hf_gtpv0_ext_val, { "Extension value", "gtpv0.ext_val", FT_STRING, BASE_DEC, NULL, 0, "Extension Value", HFILL }},
5192 { &hf_gtpv0_unknown, { "Unknown data (length)", "gtpv0.unknown", FT_UINT16, BASE_DEC, NULL, 0, "Unknown data", HFILL }},
5197 static hf_register_info hf_gtpv1[] = {
5199 { &hf_gtpv1_flags, { "Flags", "gtpv1.flags", FT_UINT8, BASE_HEX, NULL, 0, "Ver/PT/Spare/E/S/PN", HFILL }},
5200 { &hf_gtpv1_flags_ver, { "Version", "gtpv1.flags.version", FT_UINT8, BASE_DEC, VALS(ver_types), GTP_VER_MASK, "GTP Version", HFILL }},
5201 { &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 }},
5202 { &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 }},
5203 { &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 }},
5204 { &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 }},
5205 { &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 }},
5206 { &hf_gtpv1_message_type, { "Message Type", "gtpv1.message", FT_UINT8, BASE_HEX, VALS(message_type), 0x0, "GTP Message Type", HFILL }},
5207 { &hf_gtpv1_length, { "Length", "gtpv1.length", FT_UINT16, BASE_DEC, NULL, 0, "Length (i.e. number of octets after TID or TEID)", HFILL }},
5208 { &hf_gtpv1_seq_number, { "Sequence Number", "gtpv1.seq_number", FT_UINT16, BASE_HEX, NULL, 0, "Sequence Number", HFILL }},
5209 { &hf_gtpv1_teid, { "TEID", "gtpv1.teid", FT_UINT32, BASE_HEX, NULL, 0, "Tunnel Endpoint Identifier", HFILL }},
5210 { &hf_gtpv1_npdu_number, { "N-PDU Number", "gtpv1.npdu_number", FT_UINT8, BASE_HEX, NULL, 0, "N-PDU Number", HFILL }},
5211 { &hf_gtpv1_next, { "Next extension header type", "gtpv1.next", FT_UINT8, BASE_HEX, NULL, 0, "Next Extension Header Type", HFILL }},
5212 { &hf_gtpv1_cause, { "Cause ", "gtpv1.cause", FT_UINT8, BASE_DEC, VALS(cause_type), 0, "Cause of operation", HFILL }},
5213 { &hf_gtpv1_imsi, { "IMSI", "gtpv1.imsi", FT_STRING, BASE_DEC, NULL, 0, "International Mobile Subscriber Identity number", HFILL }},
5214 { &hf_gtpv1_rai_mcc, { "MCC", "gtpv1.mcc", FT_UINT16, BASE_DEC, NULL, 0, "Mobile Country Code", HFILL }},
5215 { &hf_gtpv1_rai_mnc, { "MNC", "gtpv1.mnc", FT_UINT8, BASE_DEC, NULL, 0, "Mobile Network Code", HFILL }},
5216 { &hf_gtpv1_rai_rac, { "RAC", "gtpv1.rac", FT_UINT8, BASE_DEC, NULL, 0, "Routing Area Code", HFILL }},
5217 { &hf_gtpv1_rai_lac, { "LAC", "gtpv1.lac", FT_UINT16, BASE_DEC, NULL, 0, "Location Area Code", HFILL }},
5218 { &hf_gtpv1_tlli, { "TLLI", "gtpv1.tlli", FT_UINT32, BASE_HEX, NULL, 0, "Temporary Logical Link Identity", HFILL }},
5219 { &hf_gtpv1_ptmsi, { "P-TMSI", "gtpv1.ptmsi", FT_UINT32, BASE_HEX, NULL, 0, "Packet-Temporary Mobile Subscriber Identity", HFILL }},
5220 { &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 }},
5221 { &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 }},
5222 { &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 }},
5223 { &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 }},
5224 { &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 }},
5225 { &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 }},
5226 { &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 }},
5227 { &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 }},
5228 { &hf_gtpv1_reorder, { "Reordering required","gtpv1.reorder", FT_BOOLEAN, BASE_NONE,NULL, 0, "Reordering required", HFILL }},
5229 { &hf_gtpv1_map_cause, { "MAP cause", "gtpv1.map_cause", FT_UINT8, BASE_DEC, VALS(map_cause_type), 0, "MAP cause", HFILL }},
5230 { &hf_gtpv1_ptmsi_sig, { "P-TMSI Signature", "gtpv1.ptmsi_sig", FT_UINT24, BASE_HEX, NULL, 0, "P-TMSI Signature", HFILL }},
5231 { &hf_gtpv1_ms_valid, { "MS validated", "gtpv1.ms_valid", FT_BOOLEAN, BASE_NONE,NULL, 0, "MS validated", HFILL }},
5232 { &hf_gtpv1_recovery, { "Recovery", "gtpv1.recovery", FT_UINT8, BASE_DEC, NULL, 0, "Restart counter", HFILL }},
5233 { &hf_gtpv1_sel_mode, { "Selection Mode", "gtpv1.sel_mode", FT_UINT8, BASE_DEC, VALS(sel_mode_type), 0, "Selection Mode", HFILL }},
5234 { &hf_gtpv1_teid_data, { "TEID Data I", "gtpv1.teid_data", FT_UINT32, BASE_HEX, NULL, 0, "Tunnel Endpoint Identifier Data I", HFILL }},
5235 { &hf_gtpv1_teid_cp, { "TEID Control Plane", "gtpv1.teid_cp", FT_UINT32, BASE_HEX, NULL, 0, "Tunnel Endpoint Identifier Control Plane", HFILL }},
5236 { &hf_gtpv1_nsapi, { "NSAPI", "gtpv1.nsapi", FT_UINT8, BASE_DEC, NULL, 0, "Network layer Service Access Point Identifier", HFILL }},
5237 { &hf_gtpv1_teid_ii, { "TEID Data II", "gtpv1.teid_ii", FT_UINT32, BASE_HEX, NULL, 0, "Tunnel Endpoint Identifier Data II", HFILL }},
5238 { &hf_gtpv1_tear_ind, { "Teardown Indicator","gtpv1.tear_ind", FT_BOOLEAN, BASE_NONE,NULL, 0, "Teardown Indicator", HFILL }},
5239 { &hf_gtpv1_ranap_cause, { "RANAP cause", "gtpv1.ranap_cause", FT_UINT8, BASE_DEC, VALS(ranap_cause_type), 0, "RANAP cause", HFILL }},
5240 { &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 }},
5241 { &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 }},
5242 { &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 }},
5243 { &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 }},
5244 { &hf_gtpv1_rp_sms, { "Radio Priority SMS", "gtpv1.rp_sms", FT_UINT8, BASE_DEC, NULL, 0, "Radio Priority for MO SMS", HFILL }},
5245 { &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 }},
5246 { &hf_gtpv1_rp_spare, { "Reserved", "gtpv1.rp_spare", FT_UINT8, BASE_DEC, NULL, GTPv1_EXT_RP_SPARE_MASK, "Spare bit", HFILL }},
5247 { &hf_gtpv1_rp, { "Radio Priority", "gtpv1.rp", FT_UINT8, BASE_DEC, NULL, GTPv1_EXT_RP_MASK, "Radio Priority for uplink tx", HFILL }},
5248 { &hf_gtpv1_pkt_flow_id, { "Packet Flow ID", "gtpv1.pkt_flow_id", FT_UINT8, BASE_DEC, NULL, 0, "Packet Flow ID", HFILL }},
5249 { &hf_gtpv1_chrg_char_s, { "Spare", "gtpv1.chrg_char_s", FT_UINT8, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_S, "Spare", HFILL }},
5250 { &hf_gtpv1_chrg_char_n, { "Normal charging", "gtpv1.chrg_char_n", FT_UINT8, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_N, "Normal charging", HFILL }},
5251 { &hf_gtpv1_chrg_char_p, { "Prepaid charging", "gtpv1.chrg_char_p", FT_UINT8, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_P, "Prepaid charging", HFILL }},
5252 { &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 }},
5253 { &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 }},
5254 { &hf_gtpv1_chrg_char_r, { "Reserved", "gtpv1.chrg_char_r", FT_UINT8, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_R, "Reserved", HFILL }},
5255 { &hf_gtpv1_trace_ref, { "Trace reference", "gtpv1.trace_ref", FT_UINT16, BASE_HEX, NULL, 0, "Trace reference", HFILL }},
5256 { &hf_gtpv1_trace_type, { "Trace type", "gtpv1.trace_type", FT_UINT16, BASE_HEX, NULL, 0, "Trace type", HFILL }},
5257 { &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 }},
5258 { &hf_gtpv1_tr_comm, { "Packet transfer command", "gtpv1.tr_comm", FT_UINT8, BASE_DEC, VALS(tr_comm_type), 0, "Packat transfer command", HFILL }},
5259 { &hf_gtpv1_chrg_id, { "Charging ID", "gtpv1.chrg_id", FT_UINT32, BASE_HEX, NULL, 0, "Charging ID", HFILL }},
5260 { &hf_gtpv1_user_ipv4, { "End user address IPv4", "gtpv1.user_ipv4", FT_IPv4, BASE_DEC, NULL, 0, "End user address IPv4", HFILL }},
5261 { &hf_gtpv1_user_ipv6, { "End user address IPv6", "gtpv1.user_ipv6", FT_IPv6, BASE_HEX, NULL, 0, "End user address IPv6", HFILL }},
5262 { &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 }},
5263 { &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 }},
5264 { &hf_gtpv1_apn, { "APN", "gtpv1.apn", FT_STRING, BASE_DEC, NULL, 0, "Access Point Name", HFILL }},
5265 { &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 }},
5266 { &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 }},
5267 { &hf_gtpv1_gsn_ipv4, { "GSN address IPv4", "gtpv1.gsn_ipv4", FT_IPv4, BASE_DEC, NULL, 0, "GSN address IPv4", HFILL }},
5268 { &hf_gtpv1_gsn_ipv6, { "GSN address IPv6", "gtpv1.gsn_ipv6", FT_IPv6, BASE_DEC, NULL, 0, "GSN address IPv6", HFILL }},
5269 { &hf_gtpv1_msisdn, { "MSISDN", "gtpv1.msisdn", FT_STRING, BASE_DEC, NULL, 0, "MS international PSTN/ISDN number", HFILL }},
5270 { &hf_gtpv1_qos_al_ret_priority, { "Allocation/Retention priority ","gtpv1.qos_al_ret_priority", FT_UINT8, BASE_DEC, NULL, 0, "Allocation/Retention Priority", HFILL }},
5271 { &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 }},
5272 { &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 }},
5273 { &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 }},
5274 { &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 }},
5275 { &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 }},
5276 { &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 }},
5277 { &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 }},
5278 { &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 }},
5279 { &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 }},
5280 { &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 }},
5281 { &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 }},
5282 { &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 }},
5284 { &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 }},
5285 { &hf_gtpv1_tft_spare, { "TFT spare bit", "gtpv1.tft_spare", FT_UINT8, BASE_DEC, NULL, GTPv1_TFT_SPARE_MASK, "TFT spare bit", HFILL }},
5286 { &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 }},
5287 { &hf_gtpv1_tft_eval, { "Evaluation precedence", "gtpv1.tft_eval", FT_UINT8, BASE_DEC, NULL, 0, "Evaluation precedence", HFILL }},
5289 { &hf_gtpv1_rnc_ipv4, { "RNC address IPv4", "gtpv1.rnc_ipv4", FT_IPv4, BASE_DEC, NULL, 0, "Radio Network Controller address IPv4", HFILL }},
5290 { &hf_gtpv1_rnc_ipv6, { "RNC address IPv6", "gtpv1.rnc_ipv6", FT_IPv6, BASE_HEX, NULL, 0, "Radio Network Controller address IPv6", HFILL }},
5291 { &hf_gtpv1_chrg_ipv4, { "CG address IPv4", "gtpv1.chrg_ipv4", FT_IPv4, BASE_DEC, NULL, 0, "Charging Gateway address IPv4", HFILL }},
5292 { &hf_gtpv1_chrg_ipv6, { "CG address IPv6", "gtpv1.chrg_ipv6", FT_IPv6, BASE_HEX, NULL, 0, "Charging Gateway address IPv6", HFILL }},
5293 { &hf_gtpv1_node_ipv4, { "Node address IPv4", "gtpv1.node_ipv4", FT_IPv4, BASE_DEC, NULL, 0, "Recommended node address IPv4", HFILL }},
5294 { &hf_gtpv1_node_ipv6, { "Node address IPv6", "gtpv1.node_ipv6", FT_IPv6, BASE_HEX, NULL, 0, "Recommended node address IPv6", HFILL }},
5295 { &hf_gtpv1_ext_id, { "Extensio Identifier","gtpv1.ext_id", FT_UINT16, BASE_DEC, NULL, 0, "Extension Identifier", HFILL }},
5296 { &hf_gtpv1_ext_val, { "Extension Value", "gtpv1.ext_val", FT_STRING, BASE_DEC, NULL, 0, "Extension Value", HFILL }},
5297 { &hf_gtpv1_unknown, { "Unknown data (length)", "gtpv1.unknown", FT_UINT16, BASE_DEC, NULL, 0, "Unknown data", HFILL }},
5301 static gint *ett_gtp_array[] = {
5311 &ett_gtp_pkt_flow_id,
5334 module_t *gtp_module;
5336 static enum_val_t gtpv0_cdr_options[] = {
5337 { "GSM 12.15 (not implemented yet)", 0 },
5343 /* proto_gtp defined only for preference tab */
5344 proto_gtp = proto_register_protocol ("GPRS Tunneling Protocol", "GTP", "gtp");
5346 proto_gtpv0 = proto_register_protocol ("GPRS Tunnelling Protocol v0", "GTPv0", "gtpv0");
5347 proto_register_field_array(proto_gtpv0, hf_gtpv0, array_length(hf_gtpv0));
5348 proto_register_subtree_array(ett_gtp_array, array_length(ett_gtp_array));
5350 proto_gtpv1 = proto_register_protocol("GPRS Tunnelling Protocol v1", "GTPv1", "gtpv1");
5351 proto_register_field_array(proto_gtpv1, hf_gtpv1, array_length(hf_gtpv1));
5352 proto_register_subtree_array(ett_gtp_array, array_length(ett_gtp_array));
5354 gtp_module = prefs_register_protocol(proto_gtp, proto_reg_handoff_gtp);
5356 prefs_register_uint_preference(gtp_module, "gtpv0_port", "GTPv0 port ", "GTPv0 port (default 3386)", 10, &g_gtpv0_port);
5357 prefs_register_uint_preference(gtp_module, "gtpv1c_port", "GTPv1 control plane (GTP-C) port ", "GTPv1 control plane port (default 2123)", 10, &g_gtpv1c_port);
5358 prefs_register_uint_preference(gtp_module, "gtpv1u_port", "GTPv1 user plane (GTP-U) port ", "GTPv1 user plane port (default 2152)", 10, &g_gtpv1u_port);
5359 prefs_register_bool_preference(gtp_module, "gtp_dissect_tpdu", "Dissect T-PDU ", "Dissect T-PDU", >p_tpdu);
5360 prefs_register_enum_preference(gtp_module, "gtpv0_dissect_cdr_as", "Dissect GTP'v0 CDRs as ", "Dissect GTP'v0 CDRs as", >pv0_cdr_as, gtpv0_cdr_options, FALSE);
5361 prefs_register_bool_preference(gtp_module, "gtpv0_check_etsi", "Compare GTPv0 order with ETSI ", "GTPv0 ETSI order", >pv0_etsi_order);
5362 prefs_register_bool_preference(gtp_module, "gtpv1_check_etsi", "Compare GTPv1 order with ETSI ", "GTPv1 ETSI order", >pv1_etsi_order);
5363 prefs_register_obsolete_preference(gtp_module, "ppp_reorder");
5365 register_dissector("gtpv0", dissect_gtpv0, proto_gtpv0);
5366 register_dissector("gtpv1", dissect_gtpv1, proto_gtpv1);
5370 proto_reg_handoff_gtp(void)
5372 static int Initialized = FALSE;
5373 static dissector_handle_t gtpv0_handle;
5374 static dissector_handle_t gtpv1_handle;
5378 gtpv0_handle = find_dissector("gtpv0");
5380 gtpv1_handle = find_dissector("gtpv1");
5386 dissector_delete("udp.port", gtpv0_port, gtpv0_handle);
5387 dissector_delete("tcp.port", gtpv0_port, gtpv0_handle);
5389 dissector_delete("udp.port", gtpv1c_port, gtpv1_handle);
5390 dissector_delete("tcp.port", gtpv1c_port, gtpv1_handle);
5391 dissector_delete("udp.port", gtpv1u_port, gtpv1_handle);
5392 dissector_delete("tcp.port", gtpv1u_port, gtpv1_handle);
5395 gtpv0_port = g_gtpv0_port;
5396 gtpv1c_port = g_gtpv1c_port;
5397 gtpv1u_port = g_gtpv1u_port;
5401 dissector_add("udp.port", g_gtpv0_port, gtpv0_handle);
5402 dissector_add("tcp.port", g_gtpv0_port, gtpv0_handle);
5406 dissector_add("udp.port", g_gtpv1c_port, gtpv1_handle);
5407 dissector_add("tcp.port", g_gtpv1c_port, gtpv1_handle);
5408 dissector_add("udp.port", g_gtpv1u_port, gtpv1_handle);
5409 dissector_add("tcp.port", g_gtpv1u_port, gtpv1_handle);
5411 ip_handle = find_dissector("ip");
5412 ipv6_handle = find_dissector("ipv6");
5413 ppp_handle = find_dissector("ppp");
5414 data_handle = find_dissector("data");