3 * Routines for GTP dissection
4 * Copyright 2001, Michal Melerowicz <michal.melerowicz@nokia.com>
5 * Nicolas Balkota <balkota@mac.com>
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 <epan/prefs.h>
40 #include <epan/sminmpec.h>
41 #include "packet-ipv6.h"
42 #include "packet-ppp.h"
43 #include "packet-radius.h"
44 #include "packet-bssap.h"
45 #include "packet-gsm_a.h"
47 static dissector_table_t ppp_subdissector_table;
49 #define GTPv0_PORT 3386
50 #define GTPv1C_PORT 2123 /* 3G Control PDU */
51 #define GTPv1U_PORT 2152 /* 3G T-PDU */
53 #define GTPv0_HDR_LENGTH 20
54 #define GTPv1_HDR_LENGTH 12
55 #define GTP_PRIME_HDR_LENGTH 6
57 /* to check compliance with ETSI */
58 #define GTP_MANDATORY 1
59 #define GTP_OPTIONAL 2
60 #define GTP_CONDITIONAL 4
62 static guint g_gtpv0_port = GTPv0_PORT;
63 static guint g_gtpv1c_port = GTPv1C_PORT;
64 static guint g_gtpv1u_port = GTPv1U_PORT;
66 void proto_reg_handoff_gtp(void);
68 static int proto_gtp = -1;
70 static int hf_gtp_apn = -1;
71 static int hf_gtp_cause = -1;
72 static int hf_gtp_chrg_char = -1;
73 static int hf_gtp_chrg_char_s = -1;
74 static int hf_gtp_chrg_char_n = -1;
75 static int hf_gtp_chrg_char_p = -1;
76 static int hf_gtp_chrg_char_f = -1;
77 static int hf_gtp_chrg_char_h = -1;
78 static int hf_gtp_chrg_char_r = -1;
79 static int hf_gtp_chrg_id = -1;
80 static int hf_gtp_chrg_ipv4 = -1;
81 static int hf_gtp_chrg_ipv6 = -1;
82 static int hf_gtp_ext_flow_label = -1;
83 static int hf_gtp_ext_id = -1;
84 static int hf_gtp_ext_val = -1;
85 static int hf_gtp_flags = -1;
86 static int hf_gtp_flags_ver = -1;
87 static int hf_gtp_flags_pt = -1;
88 static int hf_gtp_flags_spare1 = -1;
89 static int hf_gtp_flags_snn = -1;
90 static int hf_gtp_flags_spare2 = -1;
91 static int hf_gtp_flags_e = -1;
92 static int hf_gtp_flags_s = -1;
93 static int hf_gtp_flags_pn = -1;
94 static int hf_gtp_flow_ii = -1;
95 static int hf_gtp_flow_label = -1;
96 static int hf_gtp_flow_sig = -1;
97 static int hf_gtp_gsn_addr_len = -1;
98 static int hf_gtp_gsn_addr_type = -1;
99 static int hf_gtp_gsn_ipv4 = -1;
100 static int hf_gtp_gsn_ipv6 = -1;
101 static int hf_gtp_imsi = -1;
102 static int hf_gtp_length = -1;
103 static int hf_gtp_map_cause = -1;
104 static int hf_gtp_message_type = -1;
105 static int hf_gtp_ms_reason = -1;
106 static int hf_gtp_ms_valid = -1;
107 static int hf_gtp_msisdn = -1;
108 static int hf_gtp_next = -1;
109 static int hf_gtp_npdu_number = -1;
110 static int hf_gtp_node_ipv4 = -1;
111 static int hf_gtp_node_ipv6 = -1;
112 static int hf_gtp_nsapi = -1;
113 static int hf_gtp_ptmsi = -1;
114 static int hf_gtp_ptmsi_sig = -1;
115 static int hf_gtp_qos_version = -1;
116 static int hf_gtp_qos_spare1 = -1;
117 static int hf_gtp_qos_delay = -1;
118 static int hf_gtp_qos_mean = -1;
119 static int hf_gtp_qos_peak = -1;
120 static int hf_gtp_qos_spare2 = -1;
121 static int hf_gtp_qos_precedence = -1;
122 static int hf_gtp_qos_spare3 = -1;
123 static int hf_gtp_qos_reliability = -1;
124 static int hf_gtp_qos_al_ret_priority = -1;
125 static int hf_gtp_qos_traf_class = -1;
126 static int hf_gtp_qos_del_order = -1;
127 static int hf_gtp_qos_del_err_sdu = -1;
128 static int hf_gtp_qos_max_sdu_size = -1;
129 static int hf_gtp_qos_max_ul = -1;
130 static int hf_gtp_qos_max_dl = -1;
131 static int hf_gtp_qos_res_ber = -1;
132 static int hf_gtp_qos_sdu_err_ratio = -1;
133 static int hf_gtp_qos_trans_delay = -1;
134 static int hf_gtp_qos_traf_handl_prio = -1;
135 static int hf_gtp_qos_guar_ul = -1;
136 static int hf_gtp_qos_guar_dl = -1;
137 static int hf_gtp_pkt_flow_id = -1;
138 static int hf_gtp_rab_gtpu_dn = -1;
139 static int hf_gtp_rab_gtpu_up = -1;
140 static int hf_gtp_rab_pdu_dn = -1;
141 static int hf_gtp_rab_pdu_up = -1;
142 static int hf_gtp_rai_mcc = -1;
143 static int hf_gtp_rai_mnc = -1;
144 static int hf_gtp_rai_rac = -1;
145 static int hf_gtp_rai_lac = -1;
146 static int hf_gtp_ranap_cause = -1;
147 static int hf_gtp_recovery = -1;
148 static int hf_gtp_reorder = -1;
149 static int hf_gtp_rnc_ipv4 = -1;
150 static int hf_gtp_rnc_ipv6 = -1;
151 static int hf_gtp_rp = -1;
152 static int hf_gtp_rp_nsapi = -1;
153 static int hf_gtp_rp_sms = -1;
154 static int hf_gtp_rp_spare = -1;
155 static int hf_gtp_sel_mode = -1;
156 static int hf_gtp_seq_number = -1;
157 static int hf_gtp_sndcp_number = -1;
158 static int hf_gtp_tear_ind = -1;
159 static int hf_gtp_teid = -1;
160 static int hf_gtp_teid_cp = -1;
161 static int hf_gtp_teid_data = -1;
162 static int hf_gtp_teid_ii = -1;
163 static int hf_gtp_tft_code = -1;
164 static int hf_gtp_tft_spare = -1;
165 static int hf_gtp_tft_number = -1;
166 static int hf_gtp_tft_eval = -1;
167 static int hf_gtp_tid = -1;
168 static int hf_gtp_tlli = -1;
169 static int hf_gtp_tr_comm = -1;
170 static int hf_gtp_trace_ref = -1;
171 static int hf_gtp_trace_type = -1;
172 static int hf_gtp_unknown = -1;
173 static int hf_gtp_user_addr_pdp_org = -1;
174 static int hf_gtp_user_addr_pdp_type = -1;
175 static int hf_gtp_user_ipv4 = -1;
176 static int hf_gtp_user_ipv6 = -1;
177 static int hf_gtp_security_mode = -1;
178 static int hf_gtp_no_of_vectors = -1;
179 static int hf_gtp_cipher_algorithm = -1;
180 static int hf_gtp_cksn_ksi = -1;
181 static int hf_gtp_cksn = -1;
182 static int hf_gtp_ksi = -1;
185 /* Initialize the subtree pointers */
186 static gint ett_gtp = -1;
187 static gint ett_gtp_flags = -1;
188 static gint ett_gtp_ext = -1;
189 static gint ett_gtp_rai = -1;
190 static gint ett_gtp_qos = -1;
191 static gint ett_gtp_auth_tri = -1;
192 static gint ett_gtp_flow_ii = -1;
193 static gint ett_gtp_rab_cntxt = -1;
194 static gint ett_gtp_rp = -1;
195 static gint ett_gtp_pkt_flow_id = -1;
196 static gint ett_gtp_chrg_char = -1;
197 static gint ett_gtp_user = -1;
198 static gint ett_gtp_mm = -1;
199 static gint ett_gtp_trip = -1;
200 static gint ett_gtp_quint = -1;
201 static gint ett_gtp_pdp = -1;
202 static gint ett_gtp_apn = -1;
203 static gint ett_gtp_proto = -1;
204 static gint ett_gtp_gsn_addr = -1;
205 static gint ett_gtp_tft = -1;
206 static gint ett_gtp_tft_pf = -1;
207 static gint ett_gtp_tft_flags = -1;
208 static gint ett_gtp_rab_setup = -1;
209 static gint ett_gtp_hdr_list = -1;
210 static gint ett_gtp_chrg_addr = -1;
211 static gint ett_gtp_node_addr = -1;
212 static gint ett_gtp_rel_pack = -1;
213 static gint ett_gtp_can_pack = -1;
214 static gint ett_gtp_data_resp = -1;
215 static gint ett_gtp_priv_ext = -1;
216 static gint ett_gtp_net_cap = -1;
218 static gboolean gtp_tpdu = TRUE;
219 static gboolean gtp_over_tcp = TRUE;
220 static gboolean gtp_etsi_order = FALSE;
221 static guint gtpv0_port = 0;
222 static guint gtpv1c_port = 0;
223 static guint gtpv1u_port = 0;
225 /* Definition of flags masks */
226 #define GTP_VER_MASK 0xE0
228 static const value_string ver_types[] = {
229 { 0, "GTP release 97/98 version" },
230 { 1, "GTP release 99 version" },
239 static const value_string pt_types[] = {
245 #define GTP_PT_MASK 0x10
246 #define GTP_SPARE1_MASK 0x0E
247 #define GTP_SPARE2_MASK 0x08
248 #define GTP_E_MASK 0x04
249 #define GTP_S_MASK 0x02
250 #define GTP_SNN_MASK 0x01
251 #define GTP_PN_MASK 0x01
253 /* Definition of 3G charging characteristics masks */
254 #define GTP_MASK_CHRG_CHAR_S 0xF000
255 #define GTP_MASK_CHRG_CHAR_N 0x0800
256 #define GTP_MASK_CHRG_CHAR_P 0x0400
257 #define GTP_MASK_CHRG_CHAR_F 0x0200
258 #define GTP_MASK_CHRG_CHAR_H 0x0100
259 #define GTP_MASK_CHRG_CHAR_R 0x00FF
261 /* Traffic Flow Templates mask */
262 #define GTPv1_TFT_CODE_MASK 0xE0
263 #define GTPv1_TFT_SPARE_MASK 0x10
264 #define GTPv1_TFT_NUMBER_MASK 0x0F
266 /* Definition of GSN Address masks */
267 #define GTP_EXT_GSN_ADDR_TYPE_MASK 0xC0
268 #define GTP_EXT_GSN_ADDR_LEN_MASK 0x3F
270 /* Definition of QoS masks */
271 #define GTP_EXT_QOS_SPARE1_MASK 0xC0
272 #define GTP_EXT_QOS_DELAY_MASK 0x38
273 #define GTP_EXT_QOS_RELIABILITY_MASK 0x07
274 #define GTP_EXT_QOS_PEAK_MASK 0xF0
275 #define GTP_EXT_QOS_SPARE2_MASK 0x08
276 #define GTP_EXT_QOS_PRECEDENCE_MASK 0x07
277 #define GTP_EXT_QOS_SPARE3_MASK 0xE0
278 #define GTP_EXT_QOS_MEAN_MASK 0x1F
279 #define GTP_EXT_QOS_TRAF_CLASS_MASK 0xE0
280 #define GTP_EXT_QOS_DEL_ORDER_MASK 0x18
281 #define GTP_EXT_QOS_DEL_ERR_SDU_MASK 0x07
282 #define GTP_EXT_QOS_RES_BER_MASK 0xF0
283 #define GTP_EXT_QOS_SDU_ERR_RATIO_MASK 0x0F
284 #define GTP_EXT_QOS_TRANS_DELAY_MASK 0xFC
285 #define GTP_EXT_QOS_TRAF_HANDL_PRIORITY_MASK 0x03
287 /* Definition of Radio Priority's masks */
288 #define GTPv1_EXT_RP_NSAPI_MASK 0xF0
289 #define GTPv1_EXT_RP_SPARE_MASK 0x08
290 #define GTPv1_EXT_RP_MASK 0x07
292 /* definitions of GTP messages */
293 #define GTP_MSG_UNKNOWN 0x00
294 #define GTP_MSG_ECHO_REQ 0x01
295 #define GTP_MSG_ECHO_RESP 0x02
296 #define GTP_MSG_VER_NOT_SUPP 0x03
297 #define GTP_MSG_NODE_ALIVE_REQ 0x04
298 #define GTP_MSG_NODE_ALIVE_RESP 0x05
299 #define GTP_MSG_REDIR_REQ 0x06
300 #define GTP_MSG_REDIR_RESP 0x07
301 #define GTP_MSG_CREATE_PDP_REQ 0x10
302 #define GTP_MSG_CREATE_PDP_RESP 0x11
303 #define GTP_MSG_UPDATE_PDP_REQ 0x12
304 #define GTP_MSG_UPDATE_PDP_RESP 0x13
305 #define GTP_MSG_DELETE_PDP_REQ 0x14
306 #define GTP_MSG_DELETE_PDP_RESP 0x15
307 #define GTP_MSG_CREATE_AA_PDP_REQ 0x16 /* 2G */
308 #define GTP_MSG_CREATE_AA_PDP_RESP 0x17 /* 2G */
309 #define GTP_MSG_DELETE_AA_PDP_REQ 0x18 /* 2G */
310 #define GTP_MSG_DELETE_AA_PDP_RESP 0x19 /* 2G */
311 #define GTP_MSG_ERR_IND 0x1A
312 #define GTP_MSG_PDU_NOTIFY_REQ 0x1B
313 #define GTP_MSG_PDU_NOTIFY_RESP 0x1C
314 #define GTP_MSG_PDU_NOTIFY_REJ_REQ 0x1D
315 #define GTP_MSG_PDU_NOTIFY_REJ_RESP 0x1E
316 #define GTP_MSG_SUPP_EXT_HDR 0x1F
317 #define GTP_MSG_SEND_ROUT_INFO_REQ 0x20
318 #define GTP_MSG_SEND_ROUT_INFO_RESP 0x21
319 #define GTP_MSG_FAIL_REP_REQ 0x22
320 #define GTP_MSG_FAIL_REP_RESP 0x23
321 #define GTP_MSG_MS_PRESENT_REQ 0x24
322 #define GTP_MSG_MS_PRESENT_RESP 0x25
323 #define GTP_MSG_IDENT_REQ 0x30
324 #define GTP_MSG_IDENT_RESP 0x31
325 #define GTP_MSG_SGSN_CNTXT_REQ 0x32
326 #define GTP_MSG_SGSN_CNTXT_RESP 0x33
327 #define GTP_MSG_SGSN_CNTXT_ACK 0x34
328 #define GTP_MSG_FORW_RELOC_REQ 0x35
329 #define GTP_MSG_FORW_RELOC_RESP 0x36
330 #define GTP_MSG_FORW_RELOC_COMP 0x37
331 #define GTP_MSG_RELOC_CANCEL_REQ 0x38
332 #define GTP_MSG_RELOC_CANCEL_RESP 0x39
333 #define GTP_MSG_FORW_SRNS_CNTXT 0x3A
334 #define GTP_MSG_FORW_RELOC_ACK 0x3B
335 #define GTP_MSG_FORW_SRNS_CNTXT_ACK 0x3C
336 #define GTP_MSG_DATA_TRANSF_REQ 0xF0
337 #define GTP_MSG_DATA_TRANSF_RESP 0xF1
338 #define GTP_MSG_TPDU 0xFF
340 static const value_string message_type[] = {
341 { GTP_MSG_UNKNOWN, "For future use" },
342 { GTP_MSG_ECHO_REQ, "Echo request" },
343 { GTP_MSG_ECHO_RESP, "Echo response" },
344 { GTP_MSG_VER_NOT_SUPP, "Version not supported" },
345 { GTP_MSG_NODE_ALIVE_REQ, "Node alive request" },
346 { GTP_MSG_NODE_ALIVE_RESP, "Node alive response" },
347 { GTP_MSG_REDIR_REQ, "Redirection request" },
348 { GTP_MSG_REDIR_RESP, "Redirection response" },
349 { GTP_MSG_CREATE_PDP_REQ, "Create PDP context request" },
350 { GTP_MSG_CREATE_PDP_RESP, "Create PDP context response" },
351 { GTP_MSG_UPDATE_PDP_REQ, "Update PDP context request" },
352 { GTP_MSG_UPDATE_PDP_RESP, "Update PDP context response" },
353 { GTP_MSG_DELETE_PDP_REQ, "Delete PDP context request" },
354 { GTP_MSG_DELETE_PDP_RESP, "Delete PDP context response" },
355 { GTP_MSG_CREATE_AA_PDP_REQ, "Create AA PDP Context Request" },
356 { GTP_MSG_CREATE_AA_PDP_RESP, "Create AA PDP Context Response" },
357 { GTP_MSG_DELETE_AA_PDP_REQ, "Delete AA PDP Context Request" },
358 { GTP_MSG_DELETE_AA_PDP_RESP, "Delete AA PDP Context Response" },
359 { GTP_MSG_ERR_IND, "Error indication" },
360 { GTP_MSG_PDU_NOTIFY_REQ, "PDU notification request" },
361 { GTP_MSG_PDU_NOTIFY_RESP, "PDU notification response" },
362 { GTP_MSG_PDU_NOTIFY_REJ_REQ, "PDU notification reject request" },
363 { GTP_MSG_PDU_NOTIFY_REJ_RESP, "PDU notification reject response" },
364 { GTP_MSG_SUPP_EXT_HDR, "Supported extension header notification" },
365 { GTP_MSG_SEND_ROUT_INFO_REQ, "Send routing information for GPRS request" },
366 { GTP_MSG_SEND_ROUT_INFO_RESP, "Send routing information for GPRS response" },
367 { GTP_MSG_FAIL_REP_REQ, "Failure report request" },
368 { GTP_MSG_FAIL_REP_RESP, "Failure report response" },
369 { GTP_MSG_MS_PRESENT_REQ, "Note MS GPRS present request" },
370 { GTP_MSG_MS_PRESENT_RESP, "Note MS GPRS present response" },
371 { GTP_MSG_IDENT_REQ, "Identification request" },
372 { GTP_MSG_IDENT_RESP, "Identification response" },
373 { GTP_MSG_SGSN_CNTXT_REQ, "SGSN context request" },
374 { GTP_MSG_SGSN_CNTXT_RESP, "SGSN context response" },
375 { GTP_MSG_SGSN_CNTXT_ACK, "SGSN context acknowledgement" },
376 { GTP_MSG_FORW_RELOC_REQ, "Forward relocation request" },
377 { GTP_MSG_FORW_RELOC_RESP, "Forward relocation response" },
378 { GTP_MSG_FORW_RELOC_COMP, "Forward relocation complete" },
379 { GTP_MSG_RELOC_CANCEL_REQ, "Relocation cancel request" },
380 { GTP_MSG_RELOC_CANCEL_RESP, "Relocation cancel response" },
381 { GTP_MSG_FORW_SRNS_CNTXT, "Forward SRNS context" },
382 { GTP_MSG_FORW_RELOC_ACK, "Forward relocation complete acknowledge" },
383 { GTP_MSG_FORW_SRNS_CNTXT_ACK, "Forward SRNS context acknowledge" },
384 { GTP_MSG_DATA_TRANSF_REQ, "Data record transfer request" },
385 { GTP_MSG_DATA_TRANSF_RESP, "Data record transfer response" },
386 { GTP_MSG_TPDU, "T-PDU" },
390 /* definitions of fields in extension header */
391 #define GTP_EXT_CAUSE 0x01
392 #define GTP_EXT_IMSI 0x02
393 #define GTP_EXT_RAI 0x03
394 #define GTP_EXT_TLLI 0x04
395 #define GTP_EXT_PTMSI 0x05
396 #define GTP_EXT_QOS_GPRS 0x06
397 #define GTP_EXT_REORDER 0x08
398 #define GTP_EXT_AUTH_TRI 0x09
399 #define GTP_EXT_MAP_CAUSE 0x0B
400 #define GTP_EXT_PTMSI_SIG 0x0C
401 #define GTP_EXT_MS_VALID 0x0D
402 #define GTP_EXT_RECOVER 0x0E
403 #define GTP_EXT_SEL_MODE 0x0F
405 #define GTP_EXT_16 0x10
406 #define GTP_EXT_FLOW_LABEL 0x10
407 #define GTP_EXT_TEID 0x10 /* 0xFF10 3G */
409 #define GTP_EXT_17 0x11
410 #define GTP_EXT_FLOW_SIG 0x11
411 #define GTP_EXT_TEID_CP 0x11 /* 0xFF11 3G */
413 #define GTP_EXT_18 0x12
414 #define GTP_EXT_FLOW_II 0x12
415 #define GTP_EXT_TEID_II 0x12 /* 0xFF12 3G*/
417 #define GTP_EXT_19 0x13
418 #define GTP_EXT_MS_REASON 0x13 /* same as 0x1D GTPv1_EXT_MS_REASON */
419 #define GTP_EXT_TEAR_IND 0x13 /* 0xFF13 3G*/
421 #define GTP_EXT_NSAPI 0x14 /* 3G */
422 #define GTP_EXT_RANAP_CAUSE 0x15 /* 3G */
423 #define GTP_EXT_RAB_CNTXT 0x16 /* 3G */
424 #define GTP_EXT_RP_SMS 0x17 /* 3G */
425 #define GTP_EXT_RP 0x18 /* 3G */
426 #define GTP_EXT_PKT_FLOW_ID 0x19 /* 3G */
427 #define GTP_EXT_CHRG_CHAR 0x1A /* 3G */
428 #define GTP_EXT_TRACE_REF 0x1B /* 3G */
429 #define GTP_EXT_TRACE_TYPE 0x1C /* 3G */
430 #define GTPv1_EXT_MS_REASON 0x1D /* 3G */
431 #define GTP_EXT_TR_COMM 0x7E /* charging */
432 #define GTP_EXT_CHRG_ID 0x7F
433 #define GTP_EXT_USER_ADDR 0x80
434 #define GTP_EXT_MM_CNTXT 0x81
435 #define GTP_EXT_PDP_CNTXT 0x82
436 #define GTP_EXT_APN 0x83
437 #define GTP_EXT_PROTO_CONF 0x84
438 #define GTP_EXT_GSN_ADDR 0x85
439 #define GTP_EXT_MSISDN 0x86
440 #define GTP_EXT_QOS_UMTS 0x87 /* 3G */
441 #define GTP_EXT_AUTH_QUI 0x88 /* 3G */
442 #define GTP_EXT_TFT 0x89 /* 3G */
443 #define GTP_EXT_TARGET_ID 0x8A /* 3G */
444 #define GTP_EXT_UTRAN_CONT 0x8B /* 3G */
445 #define GTP_EXT_RAB_SETUP 0x8C /* 3G */
446 #define GTP_EXT_HDR_LIST 0x8D /* 3G */
447 #define GTP_EXT_TRIGGER_ID 0x8E /* 3G */
448 #define GTP_EXT_OMC_ID 0x8F /* 3G */
449 #define GTP_EXT_C1 0xC1
450 #define GTP_EXT_C2 0xC2
451 #define GTP_EXT_REL_PACK 0xF9 /* charging */
452 #define GTP_EXT_CAN_PACK 0xFA /* charging */
453 #define GTP_EXT_CHRG_ADDR 0xFB
454 #define GTP_EXT_DATA_REQ 0xFC /* charging */
455 #define GTP_EXT_DATA_RESP 0xFD /* charging */
456 #define GTP_EXT_NODE_ADDR 0xFE /* charging */
457 #define GTP_EXT_PRIV_EXT 0xFF
459 static const value_string gtp_val[] = {
460 { GTP_EXT_CAUSE, "Cause of operation" },
461 { GTP_EXT_IMSI, "IMSI" },
462 { GTP_EXT_RAI, "Routing Area Identity" },
463 { GTP_EXT_TLLI, "Temporary Logical Link Identity" },
464 { GTP_EXT_PTMSI, "Packet TMSI" },
465 { GTP_EXT_QOS_GPRS, "Quality of Service" },
466 { GTP_EXT_REORDER, "Reorder required" },
467 { GTP_EXT_AUTH_TRI, "Authentication triplets" },
468 { GTP_EXT_MAP_CAUSE, "MAP cause" },
469 { GTP_EXT_PTMSI_SIG, "P-TMSI signature" },
470 { GTP_EXT_MS_VALID, "MS validated" },
471 { GTP_EXT_RECOVER, "Recovery" },
472 { GTP_EXT_SEL_MODE, "Selection mode" },
474 { GTP_EXT_16, "Flow label data I" },
475 { GTP_EXT_FLOW_LABEL, "Flow label data I" },
476 { GTP_EXT_TEID, "Tunnel Endpoint Identifier Data I" }, /* 3G */
478 { GTP_EXT_17, "Flow label signalling" },
479 { GTP_EXT_FLOW_SIG, "Flow label signalling" },
480 { GTP_EXT_TEID_CP, "Tunnel Endpoint Identifier Data Control Plane" }, /* 3G */
482 { GTP_EXT_18, "Flow label data II" },
483 { GTP_EXT_FLOW_II, "Flow label data II" },
484 { GTP_EXT_TEID_II, "Tunnel Endpoint Identifier Data II" }, /* 3G */
486 { GTP_EXT_19, "MS not reachable reason" },
487 { GTP_EXT_MS_REASON, "MS not reachable reason" },
488 { GTP_EXT_TEAR_IND, "Teardown ID" }, /* 3G */
490 { GTP_EXT_NSAPI, "NSAPI" }, /* 3G */
491 { GTP_EXT_RANAP_CAUSE, "RANAP cause" }, /* 3G */
492 { GTP_EXT_RAB_CNTXT, "RAB context" }, /* 3G */
493 { GTP_EXT_RP_SMS, "Radio Priority for MO SMS" }, /* 3G */
494 { GTP_EXT_RP, "Radio Priority" }, /* 3G */
495 { GTP_EXT_PKT_FLOW_ID, "Packet Flow ID" }, /* 3G */
496 { GTP_EXT_CHRG_CHAR, "Charging characteristics" }, /* 3G */
497 { GTP_EXT_TRACE_REF, "Trace references" }, /* 3G */
498 { GTP_EXT_TRACE_TYPE, "Trace type" }, /* 3G */
499 { GTPv1_EXT_MS_REASON, "MS not reachable reason" }, /* 3G */
500 { GTP_EXT_TR_COMM, "Packet transfer command" }, /* charging */
501 { GTP_EXT_CHRG_ID, "Charging ID" },
502 { GTP_EXT_USER_ADDR, "End user address" },
503 { GTP_EXT_MM_CNTXT, "MM context" },
504 { GTP_EXT_PDP_CNTXT, "PDP context" },
505 { GTP_EXT_APN, "Access Point Name" },
506 { GTP_EXT_PROTO_CONF, "Protocol configuration options" },
507 { GTP_EXT_GSN_ADDR, "GSN address" },
508 { GTP_EXT_MSISDN, "MS international PSTN/ISDN number" },
509 { GTP_EXT_QOS_UMTS, "Quality of service (UMTS)" }, /* 3G */
510 { GTP_EXT_AUTH_QUI, "Authentication quintuplets" }, /* 3G */
511 { GTP_EXT_TFT, "Traffic Flow Template (TFT)" }, /* 3G */
512 { GTP_EXT_TARGET_ID, "Target (RNC) identification" }, /* 3G */
513 { GTP_EXT_UTRAN_CONT, "UTRAN transparent field" }, /* 3G */
514 { GTP_EXT_RAB_SETUP, "RAB setup information" }, /* 3G */
515 { GTP_EXT_HDR_LIST, "Extension Header Types List" }, /* 3G */
516 { GTP_EXT_TRIGGER_ID, "Trigger Id" }, /* 3G */
517 { GTP_EXT_OMC_ID, "OMC Identity" }, /* 3G */
518 { GTP_EXT_REL_PACK, "Sequence numbers of released packets IE" }, /* charging */
519 { GTP_EXT_CAN_PACK, "Sequence numbers of canceled packets IE" }, /* charging */
520 { GTP_EXT_CHRG_ADDR, "Charging Gateway address" },
521 { GTP_EXT_DATA_REQ, "Data record packet" }, /* charging */
522 { GTP_EXT_DATA_RESP, "Requests responded" }, /* charging */
523 { GTP_EXT_NODE_ADDR, "Address of recommended node" }, /* charging */
524 { GTP_EXT_PRIV_EXT, "Private Extension" },
528 /* GPRS: 9.60 v7.6.0, page 37
529 * UMTS: 29.060 v4.0, page 45
531 static const value_string cause_type[] = {
532 { 0, "Request IMSI" },
533 { 1, "Request IMEI" },
534 { 2, "Request IMSI and IMEI" },
535 { 3, "No identity needed" },
537 { 5, "MS is not GPRS responding" },
538 { 59, "System failure" }, /* charging */
539 { 60, "The transmit buffers are becoming full" }, /* charging */
540 { 61, "The receive buffers are becoming full" }, /* charging */
541 { 62, "Another node is about to go down" }, /* charging */
542 { 63, "This node is about to go down" }, /* charging */
543 { 128, "Request accepted" },
544 { 192, "Non-existent" },
545 { 193, "Invalid message format" },
546 { 194, "IMSI not known" },
547 { 195, "MS is GPRS detached" },
548 { 196, "MS is not GPRS responding" },
549 { 197, "MS refuses" },
550 { 198, "Version not supported" },
551 { 199, "No resource available" },
552 { 200, "Service not supported" },
553 { 201, "Mandatory IE incorrect" },
554 { 202, "Mandatory IE missing" },
555 { 203, "Optional IE incorrect" },
556 { 204, "System failure" },
557 { 205, "Roaming restriction" },
558 { 206, "P-TMSI signature mismatch" },
559 { 207, "GPRS connection suspended" },
560 { 208, "Authentication failure" },
561 { 209, "User authentication failed" },
562 { 210, "Context not found" },
563 { 211, "All PDP dynamic addresses are occupied" },
564 { 212, "No memory is available" },
565 { 213, "Relocation failure" },
566 { 214, "Unknown mandatory extension header" },
567 { 215, "Semantic error in the TFT operation" },
568 { 216, "Syntactic error in the TFT operation" },
569 { 217, "Semantic errors in packet filter(s)" },
570 { 218, "Syntactic errors in packet filter(s)" },
571 { 219, "Missing or unknown APN" },
572 { 220, "Unknown PDP address or PDP type" },
573 { 252, "Request related to possibly duplicated packets already fulfilled" }, /* charging */
574 { 253, "Request already fulfilled" }, /* charging */
575 { 254, "Sequence numbers of released/cancelled packets IE incorrect" }, /* charging */
576 { 255, "Request not fulfilled" }, /* charging */
581 * UMTS: 29.002 v4.2.1, chapter 17.5, page 268
582 * TODO: Check if all map_cause values are included
584 static const value_string map_cause_type[] = {
585 { 1, "Unknown subscriber" },
586 { 8, "Roaming not allowed" },
587 { 10, "Bearer service not provisioned" },
588 { 11, "Teleservice not provisioned" },
589 { 13, "Call barred" },
590 { 21, "Facility not supported" },
591 { 23, "Update GPRS location" },
592 { 24, "Send routing info for GPRS" },
593 { 26, "Note MS present for GPRS" },
594 { 27, "Absent subscriber" },
595 { 34, "System failure" },
596 { 35, "Data missing" },
597 { 36, "Unexpected data value" },
598 { 44, "Number chenged" },
599 { 45, "Busy subscriber" },
600 { 46, "No subscriber reply" },
601 { 48, "Facility not allowed" },
605 static const value_string gsn_addr_type[] = {
611 static const value_string pdp_type[] = {
614 { 0x02, "OSP:IHOSS" },
620 static const value_string pdp_org_type[] = {
626 static const value_string qos_delay_type[] = {
627 { 0x00, "Subscribed delay class (in MS to network direction)" },
628 { 0x01, "Delay class 1" },
629 { 0x02, "Delay class 2" },
630 { 0x03, "Delay class 3" },
631 { 0x04, "Delay class 4 (best effort)" },
632 { 0x07, "Reserved" },
636 static const value_string qos_reliability_type[] = {
637 { 0x00, "Subscribed reliability class (in MS to network direction)" },
638 { 0x01, "Ack GTP/LLC/RLC, Protected data" },
639 { 0x02, "Unack GTP, Ack LLC/RLC, Protected data" },
640 { 0x03, "Unack GTP/LLC, Ack RLC, Protected data" },
641 { 0x04, "Unack GTP/LLC/RLC, Protected data" },
642 { 0x05, "Unack GTP/LLC/RLC, Unprotected data" },
643 { 0x07, "Reserved" },
647 static const value_string qos_peak_type[] = {
648 { 0x00, "Subscribed peak throughput (in MS to network direction)" },
649 { 0x01, "Up to 1 000 oct/s" },
650 { 0x02, "Up to 2 000 oct/s" },
651 { 0x03, "Up to 4 000 oct/s" },
652 { 0x04, "Up to 8 000 oct/s" },
653 { 0x05, "Up to 16 000 oct/s" },
654 { 0x06, "Up to 32 000 oct/s" },
655 { 0x07, "Up to 64 000 oct/s" },
656 { 0x08, "Up to 128 000 oct/s" },
657 { 0x09, "Up to 256 000 oct/s" },
658 /* QoS Peak throughput classes from 0x0A to 0x0F (from 10 to 15) are subscribed */
659 { 0x0A, "Reserved" },
660 { 0x0B, "Reserved" },
661 { 0x0C, "Reserved" },
662 { 0x0D, "Reserved" },
663 { 0x0E, "Reserved" },
664 { 0x0F, "Reserved" },
668 static const value_string qos_precedence_type[] = {
669 { 0x00, "Subscribed precedence (in MS to network direction)" },
670 { 0x01, "High priority" },
671 { 0x02, "Normal priority" },
672 { 0x03, "Low priority" },
673 { 0x07, "Reserved" },
677 static const value_string qos_mean_type[] = {
678 { 0x00, "Subscribed mean throughput (in MS to network direction)" },
679 { 0x01, "100 oct/h" }, /* Class 2 */
680 { 0x02, "200 oct/h" }, /* Class 3 */
681 { 0x03, "500 oct/h" }, /* Class 4 */
682 { 0x04, "1 000 oct/h" }, /* Class 5 */
683 { 0x05, "2 000 oct/h" }, /* Class 6 */
684 { 0x06, "5 000 oct/h" }, /* Class 7 */
685 { 0x07, "10 000 oct/h" }, /* Class 8 */
686 { 0x08, "20 000 oct/h" }, /* Class 9 */
687 { 0x09, "50 000 oct/h" }, /* Class 10 */
688 { 0x0A, "100 000 oct/h" }, /* Class 11 */
689 { 0x0B, "200 000 oct/h" }, /* Class 12 */
690 { 0x0C, "500 000 oct/h" }, /* Class 13 */
691 { 0x0D, "1 000 000 oct/h" }, /* Class 14 */
692 { 0x0E, "2 000 000 oct/h" }, /* Class 15 */
693 { 0x0F, "5 000 000 oct/h" }, /* Class 16 */
694 { 0x10, "10 000 000 oct/h" }, /* Class 17 */
695 { 0x11, "20 000 000 oct/h" }, /* Class 18 */
696 { 0x12, "50 000 000 oct/h" }, /* Class 19 */
697 /* QoS Mean throughput classes from 0x13 to 0x1E (from 19 to 30) are subscribed */
698 { 0x13, "Reserved" },
699 { 0x14, "Reserved" },
700 { 0x15, "Reserved" },
701 { 0x16, "Reserved" },
702 { 0x17, "Reserved" },
703 { 0x18, "Reserved" },
704 { 0x19, "Reserved" },
705 { 0x1A, "Reserved" },
706 { 0x1B, "Reserved" },
707 { 0x1C, "Reserved" },
708 { 0x1D, "Reserved" },
709 { 0x1E, "Reserved" },
710 { 0x1F, "Best effort" }, /* Class 1 */
714 static const value_string qos_del_err_sdu[] = {
715 { 0x00, "Subscribed delivery of erroneous SDUs (in MS to network direction)" },
716 { 0x01, "No detect ('-')" },
717 { 0x02, "Erroneous SDUs are delivered ('yes')" },
718 { 0x03, "Erroneous SDUs are not delivered ('no')" },
719 { 0x07, "Reserved" }, /* All other values are reserved */
723 static const value_string qos_del_order[] = {
724 { 0x00, "Subscribed delivery order (in MS to network direction)" },
725 { 0x01, "With delivery order ('yes')" },
726 { 0x02, "Without delivery order ('no')" },
727 { 0x03, "Reserved" }, /* All other values are reserved */
731 static const value_string qos_traf_class[] = {
732 { 0x00, "Subscribed traffic class (in MS to network direction)" },
733 { 0x01, "Conversational class" },
734 { 0x02, "Streaming class" },
735 { 0x03, "Interactive class" },
736 { 0x04, "Background class" },
737 { 0x07, "Reserved" }, /* All other values are reserved */
741 static const value_string qos_max_sdu_size[] = {
742 { 0x00, "Subscribed maximum SDU size (in MS to network direction" },
743 /* For values from 0x01 to 0x96 (from 1 to 150), use a granularity of 10 octets */
744 { 0x97, "1502 octets" },
745 { 0x98, "1510 octets" },
746 { 0x99, "1520 octets" },
747 { 0, NULL } /* All other values are reserved */
750 static const value_string qos_max_ul[] = {
751 { 0x00, "Subscribed maximum bit rate for uplink (in MS to network direction)" },
752 /* For values from 0x01 to 0x3F (from 1 to 63), use a granularity of 1 kbps */
753 /* For values from 0x40 to 0x7F, value = 64 kbps + (value - 0x40) * 8 kbps */
754 /* For values from 0x80 to 0xFE, value = 576 kbps + (value - 0x80) * 64 kbps */
759 static const value_string qos_max_dl[] = {
760 { 0x00, "Subscribed maximum bit rate for downlink (in MS to network direction)" },
761 /* For values from 0x01 to 0x3F (from 1 to 63), use a granularity of 1 kbps */
762 /* For values from 0x40 to 0x7F, value = 64 kbps + (value - 0x40) * 8 kbps */
763 /* For values from 0x80 to 0xFE, value = 576 kbps + (value - 0x80) * 64 kbps */
768 static const value_string qos_res_ber[] = {
769 { 0x00, "Subscribed residual BER (in MS to network direction)" },
770 { 0x01, "1/20 = 5x10^-2" },
771 { 0x02, "1/100 = 1x10^-2" },
772 { 0x03, "1/200 = 5x10^-3" },
773 { 0x04, "1/250 = 4x10^-3" },
774 { 0x05, "1/1 000 = 1x10^-3" },
775 { 0x06, "1/10 000 = 1x10^-4" },
776 { 0x07, "1/100 000 = 1x10^-5" },
777 { 0x08, "1/1 000 000 = 1x10^-6" },
778 { 0x09, "3/50 000 000 = 6x10^-8" },
779 { 0x0F, "Reserved" }, /* All other values are reserved */
783 static const value_string qos_sdu_err_ratio[] = {
784 { 0x00, "Subscribed SDU error ratio (in MS to network direction)" },
785 { 0x01, "1/100 = 1x10^-2" },
786 { 0x02, "7/1000 = 7x10^-3" },
787 { 0x03, "1/1 000 = 1x10^-3" },
788 { 0x04, "1/10 000 = 1x10^-4" },
789 { 0x05, "1/100 000 = 1x10^-5" },
790 { 0x06, "1/1 000 000 = 1x10^-6" },
791 { 0x07, "1/10 = 1x10^-1" },
792 { 0x0F, "Reserved" }, /* All other values are reserved */
796 static const value_string qos_traf_handl_prio[] = {
797 { 0x00, "Subscribed traffic handling priority (in MS to network direction)" },
798 { 0x01, "Priority level 1" },
799 { 0x02, "Priority level 2" },
800 { 0x03, "Priority level 3" },
804 static const value_string qos_trans_delay[] = {
805 { 0x00, "Subscribed Transfer Delay (in MS to network direction)" },
806 { 0x01, "10 ms" }, /* Using a granularity of 10 ms */
821 { 0x10, "200 ms" }, /* (For values from 0x10 to 0x1F, value = 200 ms + (value - 0x10) * 50 ms */
837 { 0x20, "1000 ms" }, /* For values from 0x20 to 0x3E, value = 1000 ms + (value - 0x20) * 100 ms */
872 static const value_string qos_guar_ul[] = {
873 { 0x00, "Subscribed guaranteed bit rate for uplink (in MS to network direction)" },
874 /* For values from 0x01 to 0x3F (from 1 to 63), use a granularity of 1 kbps */
875 /* For values from 0x40 to 0x7F, value = 64 kbps + (value - 0x40) * 8 kbps */
876 /* For values from 0x80 to 0xFE, value = 576 kbps + (value - 0x80) * 64 kbps */
881 static const value_string qos_guar_dl[] = {
882 { 0x00, "Subscribed guaranteed bit rate for downlink (in MS to network direction)" },
883 /* For values from 0x01 to 0x3F (from 1 to 63), use a granularity of 1 kbps */
884 /* For values from 0x40 to 0x7F, value = 64 kbps + (value - 0x40) * 8 kbps */
885 /* For values from 0x80 to 0xFE, value = 576 kbps + (value - 0x80) * 64 kbps */
890 static const value_string sel_mode_type[] = {
891 { 0, "MS or network provided APN, subscribed verified" },
892 { 1, "MS provided APN, subscription not verified" },
893 { 2, "Network provided APN, subscription not verified" },
894 { 3, "For future use (Network provided APN, subscription not verified" },/* Shall not be sent. If received, shall be sent as value 2 */
898 static const value_string tr_comm_type[] = {
899 { 1, "Send data record packet" },
900 { 2, "Send possibly duplicated data record packet" },
901 { 3, "Cancel data record packet" },
902 { 4, "Release data record packet"},
906 /* TODO: CHeck if all ms_reasons are included */
907 static const value_string ms_not_reachable_type[] = {
908 { 0, "No paging response via the MSC" },
909 { 1, "IMSI detached" },
910 { 2, "Roaming restriction" },
911 { 3, "Deregistered in the HLR for non GPRS" },
912 { 4, "MS purge for non GPRS" },
913 { 5, "No paging response via the SGSN" },
914 { 6, "GPRS detached" },
915 { 7, "Deregistered in the HLR for non GPRS" },
916 { 8, "MS purged for GPRS" },
917 { 9, "Unidentified subscriber via the MSC" },
918 { 10, "Unidentified subscriber via the SGSN" },
922 /* UMTS: 25.413 v3.4.0, chapter 9.2.1.4, page 80
924 static const value_string ranap_cause_type[] = {
925 /* Radio Network Layer Cause (1-->64) */
926 { 1, "RAB preempted" },
927 { 2, "Trelocoverall Expiry" },
928 { 3, "Trelocprep Expiry" },
929 { 4, "Treloccomplete Expiry" },
930 { 5, "Tqueing Expiry" },
931 { 6, "Relocation Triggered" },
932 { 7, "TRELOCalloc Expiry" },
933 { 8, "Unable to Estabish During Relocation" },
934 { 9, "Unknown Target RNC" },
935 { 10, "Relocation Cancelled" },
936 { 11, "Successful Relocation" },
937 { 12, "Requested Ciphering and/or Integrity Protection Algorithms not Supported" },
938 { 13, "Change of Ciphering and/or Integrity Protection is not supported" },
939 { 14, "Failure in the Radio Interface Procedure" },
940 { 15, "Release due to UTRAN Generated Reason" },
941 { 16, "User Inactivity" },
942 { 17, "Time Critical Relocation" },
943 { 18, "Requested Traffic Class not Available" },
944 { 19, "Invalid RAB Parameters Value" },
945 { 20, "Requested Maximum Bit Rate not Available" },
946 { 21, "Requested Guaranteed Bit Rate not Available" },
947 { 22, "Requested Transfer Delay not Achievable" },
948 { 23, "Invalid RAB Parameters Combination" },
949 { 24, "Condition Violation for SDU Parameters" },
950 { 25, "Condition Violation for Traffic Handling Priority" },
951 { 26, "Condition Violation for Guaranteed Bit Rate" },
952 { 27, "User Plane Versions not Supported" },
953 { 28, "Iu UP Failure" },
954 { 29, "Relocation Failure in Target CN/RNC or Target System" },
955 { 30, "Invalid RAB ID" },
956 { 31, "No Remaining RAB" },
957 { 32, "Interaction with other procedure" },
958 { 33, "Requested Maximum Bit Rate for DL not Available" },
959 { 34, "Requested Maximum Bit Rate for UL not Available" },
960 { 35, "Requested Guaranteed Bit Rate for DL not Available" },
961 { 36, "Requested Guaranteed Bit Rate for UL not Available" },
962 { 37, "Repeated Integrity Checking Failure" },
963 { 38, "Requested Report Type not supported" },
964 { 39, "Request superseded" },
965 { 40, "Release due to UE generated signalling connection release" },
966 { 41, "Resource Optimisation Relocation" },
967 { 42, "Requested Information Not Available" },
968 { 43, "Relocation desirable for radio reasons" },
969 { 44, "Relocation not supported in Target RNC or Target System" },
970 { 45, "Directed Retry" },
971 { 46, "Radio Connection With UE Lost" },
972 /* Transport Layer Cause (65-->80) */
973 { 65, "Signalling Transport Resource Failure" },
974 { 66, "Iu Transport Connection Failed to Establish" },
975 /* NAS Cause (81-->96) */
976 { 81, "User Restriction Start Indication" },
977 { 82, "User Restriction End Indication" },
978 { 83, "Normal Release" },
979 /* Protocol Cause (97-->112) */
980 { 97, "Transfer Syntax Error" },
981 { 98, "Semantic Error" },
982 { 99, "Message not compatible with receiver state" },
983 { 100, "Abstract Syntax Error (Reject)" },
984 { 101, "Abstract Syntax Error (Ignore and Notify)" },
985 { 102, "Abstract Syntax Error (Falsely Constructed Message" },
986 /* Miscellaneous Cause (113-->128) */
987 { 113, "O & M Intervention" },
988 { 114, "No Resource Available" },
989 { 115, "Unspecified Failure" },
990 { 116, "Network Opimisation" },
991 /* Non-standard Cause (129-->255) */
995 static const value_string mm_sec_modep[] = {
996 { 0, "Used cipher value, UMTS keys and Quintuplets" },
997 { 1, "GSM key and triplets" },
998 { 2, "UMTS key and quintuplets" },
999 { 3, "GSM key and quintuplets" },
1003 static const value_string gtp_cipher_algorithm[] = {
1004 { 0, "No ciphering" },
1016 #define MM_PROTO_GROUP_CALL_CONTROL 0x00
1017 #define MM_PROTO_BROADCAST_CALL_CONTROL 0x01
1018 #define MM_PROTO_PDSS1 0x02
1019 #define MM_PROTO_CALL_CONTROL 0x03
1020 #define MM_PROTO_PDSS2 0x04
1021 #define MM_PROTO_MM_NON_GPRS 0x05
1022 #define MM_PROTO_RR_MGMT 0x06
1023 #define MM_PROTO_MM_GPRS 0x08
1024 #define MM_PROTO_SMS 0x09
1025 #define MM_PROTO_SESSION_MGMT 0x0A
1026 #define MM_PROTO_NON_CALL_RELATED 0x0B
1028 static const value_string tft_code_type[] = {
1030 { 1, "Create new TFT" },
1031 { 2, "Delete existing TFT" },
1032 { 3, "Add packet filters to existing TFT" },
1033 { 4, "Replace packet filters in existing TFT" },
1034 { 5, "Delete packet filters from existing TFT" },
1041 static dissector_handle_t ip_handle;
1042 static dissector_handle_t ipv6_handle;
1043 static dissector_handle_t ppp_handle;
1044 static dissector_handle_t data_handle;
1045 static dissector_handle_t gtpcdr_handle;
1046 static dissector_table_t bssap_pdu_type_table=NULL;
1048 static int decode_gtp_cause (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1049 static int decode_gtp_imsi (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1050 static int decode_gtp_rai (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1051 static int decode_gtp_tlli (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1052 static int decode_gtp_ptmsi (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1053 static int decode_gtp_qos_gprs (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1054 static int decode_gtp_reorder (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1055 static int decode_gtp_auth_tri (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1056 static int decode_gtp_map_cause (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1057 static int decode_gtp_ptmsi_sig (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1058 static int decode_gtp_ms_valid (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1059 static int decode_gtp_recovery (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1060 static int decode_gtp_sel_mode (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1061 static int decode_gtp_16 (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1062 static int decode_gtp_17 (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1063 static int decode_gtp_18 (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1064 static int decode_gtp_19 (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1065 static int decode_gtp_nsapi (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1066 static int decode_gtp_ranap_cause (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1067 static int decode_gtp_rab_cntxt (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1068 static int decode_gtp_rp_sms (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1069 static int decode_gtp_rp (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1070 static int decode_gtp_pkt_flow_id (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1071 static int decode_gtp_chrg_char (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1072 static int decode_gtp_trace_ref (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1073 static int decode_gtp_trace_type (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1074 static int decode_gtp_ms_reason (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1075 static int decode_gtp_tr_comm (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1076 static int decode_gtp_chrg_id (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1077 static int decode_gtp_user_addr (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1078 static int decode_gtp_mm_cntxt (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1079 static int decode_gtp_pdp_cntxt (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1080 static int decode_gtp_apn (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1081 static int decode_gtp_gsn_addr (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1082 static int decode_gtp_proto_conf (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1083 static int decode_gtp_msisdn (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1084 static int decode_gtp_qos_umts (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1085 static int decode_gtp_auth_qui (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1086 static int decode_gtp_tft (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1087 static int decode_gtp_target_id (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1088 static int decode_gtp_utran_cont (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1089 static int decode_gtp_rab_setup (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1090 static int decode_gtp_hdr_list (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1091 static int decode_gtp_trigger_id (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1092 static int decode_gtp_omc_id (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1093 static int decode_gtp_chrg_addr (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1094 static int decode_gtp_rel_pack (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1095 static int decode_gtp_can_pack (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1096 static int decode_gtp_data_req (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1097 static int decode_gtp_data_resp (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1098 static int decode_gtp_node_addr (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1099 static int decode_gtp_priv_ext (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1100 static int decode_gtp_unknown (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
1102 typedef struct _gtp_opt {
1104 int (*decode)(tvbuff_t *, int, packet_info *, proto_tree *);
1107 static const gtp_opt_t gtpopt[] = {
1108 { GTP_EXT_CAUSE, decode_gtp_cause },
1109 { GTP_EXT_IMSI, decode_gtp_imsi },
1110 { GTP_EXT_RAI, decode_gtp_rai },
1111 { GTP_EXT_TLLI, decode_gtp_tlli },
1112 { GTP_EXT_PTMSI, decode_gtp_ptmsi },
1113 { GTP_EXT_QOS_GPRS, decode_gtp_qos_gprs },
1114 { GTP_EXT_REORDER, decode_gtp_reorder },
1115 { GTP_EXT_AUTH_TRI, decode_gtp_auth_tri },
1116 { GTP_EXT_MAP_CAUSE, decode_gtp_map_cause },
1117 { GTP_EXT_PTMSI_SIG, decode_gtp_ptmsi_sig },
1118 { GTP_EXT_MS_VALID, decode_gtp_ms_valid },
1119 { GTP_EXT_RECOVER, decode_gtp_recovery },
1120 { GTP_EXT_SEL_MODE, decode_gtp_sel_mode },
1121 { GTP_EXT_16, decode_gtp_16 },
1122 { GTP_EXT_17, decode_gtp_17 },
1123 { GTP_EXT_18, decode_gtp_18 },
1124 { GTP_EXT_19, decode_gtp_19 },
1125 { GTP_EXT_NSAPI, decode_gtp_nsapi },
1126 { GTP_EXT_RANAP_CAUSE, decode_gtp_ranap_cause },
1127 { GTP_EXT_RAB_CNTXT, decode_gtp_rab_cntxt },
1128 { GTP_EXT_RP_SMS, decode_gtp_rp_sms },
1129 { GTP_EXT_RP, decode_gtp_rp },
1130 { GTP_EXT_PKT_FLOW_ID, decode_gtp_pkt_flow_id },
1131 { GTP_EXT_CHRG_CHAR, decode_gtp_chrg_char },
1132 { GTP_EXT_TRACE_REF, decode_gtp_trace_ref },
1133 { GTP_EXT_TRACE_TYPE, decode_gtp_trace_type },
1134 { GTPv1_EXT_MS_REASON, decode_gtp_ms_reason },
1135 { GTP_EXT_TR_COMM, decode_gtp_tr_comm },
1136 { GTP_EXT_CHRG_ID, decode_gtp_chrg_id },
1137 { GTP_EXT_USER_ADDR, decode_gtp_user_addr },
1138 { GTP_EXT_MM_CNTXT, decode_gtp_mm_cntxt },
1139 { GTP_EXT_PDP_CNTXT, decode_gtp_pdp_cntxt },
1140 { GTP_EXT_APN, decode_gtp_apn },
1141 { GTP_EXT_PROTO_CONF, decode_gtp_proto_conf },
1142 { GTP_EXT_GSN_ADDR, decode_gtp_gsn_addr },
1143 { GTP_EXT_MSISDN, decode_gtp_msisdn },
1144 { GTP_EXT_QOS_UMTS, decode_gtp_qos_umts }, /* 3G */
1145 { GTP_EXT_AUTH_QUI, decode_gtp_auth_qui }, /* 3G */
1146 { GTP_EXT_TFT, decode_gtp_tft }, /* 3G */
1147 { GTP_EXT_TARGET_ID, decode_gtp_target_id }, /* 3G */
1148 { GTP_EXT_UTRAN_CONT, decode_gtp_utran_cont }, /* 3G */
1149 { GTP_EXT_RAB_SETUP, decode_gtp_rab_setup }, /* 3G */
1150 { GTP_EXT_HDR_LIST, decode_gtp_hdr_list }, /* 3G */
1151 { GTP_EXT_TRIGGER_ID, decode_gtp_trigger_id }, /* 3G */
1152 { GTP_EXT_OMC_ID, decode_gtp_omc_id }, /* 3G */
1153 { GTP_EXT_REL_PACK, decode_gtp_rel_pack }, /* charging */
1154 { GTP_EXT_CAN_PACK, decode_gtp_can_pack }, /* charging */
1155 { GTP_EXT_CHRG_ADDR, decode_gtp_chrg_addr },
1156 { GTP_EXT_DATA_REQ, decode_gtp_data_req }, /* charging */
1157 { GTP_EXT_DATA_RESP, decode_gtp_data_resp }, /* charging */
1158 { GTP_EXT_NODE_ADDR, decode_gtp_node_addr },
1159 { GTP_EXT_PRIV_EXT, decode_gtp_priv_ext },
1160 { 0, decode_gtp_unknown }
1169 static guint8 gtp_version = 0;
1170 static const char *yesno[] = { "no", "yes" };
1173 col_append_str_gtp(column_info *cinfo, gint el, const gchar *proto_name) {
1177 gchar _tmp[COL_MAX_LEN];
1179 max_len = COL_MAX_LEN;
1181 for (i = 0; i < cinfo->num_cols; i++) {
1182 if (cinfo->fmt_matx[i][el]) {
1183 if (cinfo->col_data[i] != cinfo->col_buf[i]) {
1185 strncpy(cinfo->col_buf[i], cinfo->col_data[i], max_len);
1186 cinfo->col_buf[i][max_len - 1] = '\0';
1190 strcat(_tmp, proto_name);
1192 strcat(_tmp, cinfo->col_buf[i]);
1194 cinfo->col_buf[i][0] = '\0';
1195 strcat(cinfo->col_buf[i], _tmp);
1196 cinfo->col_data[i] = cinfo->col_buf[i];
1202 id_to_str(const guint8 *ad) {
1204 static gchar str[17] = " ";
1205 guint8 bits8to5, bits4to1;
1207 static const gchar hex_digits[10] = "0123456789";
1209 for (i = 0; i < 8; i++) {
1210 bits8to5 = (ad[i] >> 4) & 0x0F;
1211 bits4to1 = ad[i] & 0x0F;
1213 str[j++] = hex_digits[bits4to1];
1215 str[j++] = hex_digits[bits8to5];
1222 imsi_to_str(const guint8 *ad) {
1224 static gchar str[17] = " ";
1227 for (i = 0; i < 8; i++) {
1228 if ((ad[i] & 0x0F) <= 9) str[j++] = (ad[i] & 0x0F) + 0x30;
1229 if (((ad[i] >> 4) & 0x0F) <= 9) str[j++] = ((ad[i] >> 4) & 0x0F) + 0x30;
1237 msisdn_to_str(const guint8 *ad, int len) {
1239 static gchar str[18] = "+ ";
1240 guint8 bits8to5, bits4to1;
1242 static const gchar hex_digits[10] = "0123456789";
1244 for (i = 1; i < len && i < 9; i++) {
1245 bits8to5 = (ad[i] >> 4) & 0x0F;
1246 bits4to1 = ad[i] & 0x0F;
1248 str[j++] = hex_digits[bits4to1];
1250 str[j++] = hex_digits[bits8to5];
1257 /* Next definitions and function check_field_presence checks if given field
1258 * in GTP packet is compliant with ETSI
1260 typedef struct _header {
1265 typedef struct _message {
1267 ext_header fields[32];
1270 /* ---------------------
1272 * ---------------------*/
1273 static _gtp_mess_items gprs_mess_items[] = {
1277 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1282 GTP_MSG_ECHO_RESP, {
1283 { GTP_EXT_RECOVER, GTP_MANDATORY },
1284 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1289 GTP_MSG_VER_NOT_SUPP, {
1294 GTP_MSG_NODE_ALIVE_REQ, {
1295 { GTP_EXT_NODE_ADDR, GTP_MANDATORY },
1296 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1301 GTP_MSG_NODE_ALIVE_RESP, {
1302 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1307 GTP_MSG_REDIR_REQ, {
1308 { GTP_EXT_CAUSE, GTP_MANDATORY },
1309 { GTP_EXT_NODE_ADDR, GTP_OPTIONAL },
1310 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1315 GTP_MSG_REDIR_RESP, {
1316 { GTP_EXT_CAUSE, GTP_MANDATORY },
1317 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1322 GTP_MSG_CREATE_PDP_REQ, {
1323 { GTP_EXT_QOS_GPRS, GTP_MANDATORY },
1324 { GTP_EXT_RECOVER, GTP_OPTIONAL },
1325 { GTP_EXT_SEL_MODE, GTP_MANDATORY },
1326 { GTP_EXT_FLOW_LABEL, GTP_MANDATORY },
1327 { GTP_EXT_FLOW_SIG, GTP_MANDATORY },
1328 { GTP_EXT_MSISDN, GTP_MANDATORY },
1329 { GTP_EXT_USER_ADDR, GTP_MANDATORY },
1330 { GTP_EXT_APN, GTP_MANDATORY },
1331 { GTP_EXT_PROTO_CONF, GTP_OPTIONAL },
1332 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
1333 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
1334 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1339 GTP_MSG_CREATE_PDP_RESP, {
1340 { GTP_EXT_CAUSE, GTP_MANDATORY },
1341 { GTP_EXT_QOS_GPRS, GTP_CONDITIONAL },
1342 { GTP_EXT_REORDER, GTP_CONDITIONAL },
1343 { GTP_EXT_RECOVER, GTP_OPTIONAL },
1344 { GTP_EXT_FLOW_LABEL, GTP_CONDITIONAL },
1345 { GTP_EXT_FLOW_SIG, GTP_CONDITIONAL },
1346 { GTP_EXT_CHRG_ID, GTP_CONDITIONAL },
1347 { GTP_EXT_USER_ADDR, GTP_CONDITIONAL },
1348 { GTP_EXT_PROTO_CONF, GTP_OPTIONAL },
1349 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
1350 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
1351 { GTP_EXT_CHRG_ADDR, GTP_OPTIONAL },
1352 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1357 GTP_MSG_UPDATE_PDP_REQ, {
1358 { GTP_EXT_QOS_GPRS, GTP_MANDATORY },
1359 { GTP_EXT_RECOVER, GTP_OPTIONAL },
1360 { GTP_EXT_FLOW_LABEL, GTP_MANDATORY },
1361 { GTP_EXT_FLOW_SIG, GTP_MANDATORY },
1362 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
1363 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
1364 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1369 GTP_MSG_UPDATE_PDP_RESP, {
1370 { GTP_EXT_CAUSE, GTP_MANDATORY },
1371 { GTP_EXT_QOS_GPRS, GTP_CONDITIONAL },
1372 { GTP_EXT_RECOVER, GTP_OPTIONAL },
1373 { GTP_EXT_FLOW_LABEL, GTP_CONDITIONAL },
1374 { GTP_EXT_FLOW_SIG, GTP_CONDITIONAL },
1375 { GTP_EXT_CHRG_ID, GTP_CONDITIONAL },
1376 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
1377 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
1378 { GTP_EXT_CHRG_ADDR, GTP_OPTIONAL },
1379 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1384 GTP_MSG_DELETE_PDP_REQ, {
1385 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1390 GTP_MSG_DELETE_PDP_RESP, {
1391 { GTP_EXT_CAUSE, GTP_MANDATORY },
1392 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1397 GTP_MSG_CREATE_AA_PDP_REQ, {
1398 { GTP_EXT_QOS_GPRS, GTP_MANDATORY },
1399 { GTP_EXT_RECOVER, GTP_OPTIONAL },
1400 { GTP_EXT_SEL_MODE, GTP_MANDATORY },
1401 { GTP_EXT_FLOW_LABEL, GTP_MANDATORY },
1402 { GTP_EXT_FLOW_SIG, GTP_MANDATORY },
1403 { GTP_EXT_USER_ADDR, GTP_MANDATORY },
1404 { GTP_EXT_APN, GTP_MANDATORY },
1405 { GTP_EXT_PROTO_CONF, GTP_OPTIONAL },
1406 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
1407 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
1408 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1413 GTP_MSG_CREATE_AA_PDP_RESP, {
1414 { GTP_EXT_CAUSE, GTP_MANDATORY },
1415 { GTP_EXT_QOS_GPRS, GTP_CONDITIONAL },
1416 { GTP_EXT_REORDER, GTP_CONDITIONAL },
1417 { GTP_EXT_RECOVER, GTP_OPTIONAL },
1418 { GTP_EXT_FLOW_LABEL, GTP_CONDITIONAL },
1419 { GTP_EXT_FLOW_SIG, GTP_CONDITIONAL },
1420 { GTP_EXT_CHRG_ID, GTP_CONDITIONAL },
1421 { GTP_EXT_USER_ADDR, GTP_CONDITIONAL },
1422 { GTP_EXT_PROTO_CONF, GTP_OPTIONAL },
1423 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
1424 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
1425 { GTP_EXT_CHRG_ADDR, GTP_OPTIONAL },
1426 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1431 GTP_MSG_DELETE_AA_PDP_REQ, {
1432 { GTP_EXT_CAUSE, GTP_MANDATORY },
1433 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1438 GTP_MSG_DELETE_AA_PDP_RESP, {
1439 { GTP_EXT_CAUSE, GTP_MANDATORY },
1440 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1446 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1451 GTP_MSG_PDU_NOTIFY_REQ, {
1452 { GTP_EXT_USER_ADDR, GTP_MANDATORY },
1453 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1458 GTP_MSG_PDU_NOTIFY_RESP, {
1459 { GTP_EXT_CAUSE, GTP_MANDATORY },
1460 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1465 GTP_MSG_PDU_NOTIFY_REJ_REQ, {
1466 { GTP_EXT_CAUSE, GTP_MANDATORY },
1467 { GTP_EXT_USER_ADDR, GTP_MANDATORY },
1468 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1473 GTP_MSG_PDU_NOTIFY_REJ_RESP, {
1474 { GTP_EXT_CAUSE, GTP_MANDATORY },
1475 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1480 GTP_MSG_SEND_ROUT_INFO_REQ, {
1481 { GTP_EXT_IMSI, GTP_MANDATORY },
1482 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1487 GTP_MSG_SEND_ROUT_INFO_RESP, {
1488 { GTP_EXT_CAUSE, GTP_MANDATORY },
1489 { GTP_EXT_IMSI, GTP_MANDATORY },
1490 { GTP_EXT_MAP_CAUSE, GTP_OPTIONAL },
1491 { GTP_EXT_MS_REASON, GTP_OPTIONAL },
1492 { GTP_EXT_GSN_ADDR, GTP_OPTIONAL },
1493 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1498 GTP_MSG_FAIL_REP_REQ, {
1499 { GTP_EXT_IMSI, GTP_MANDATORY },
1500 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1505 GTP_MSG_FAIL_REP_RESP, {
1506 { GTP_EXT_CAUSE, GTP_MANDATORY },
1507 { GTP_EXT_MAP_CAUSE, GTP_OPTIONAL },
1508 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1513 GTP_MSG_MS_PRESENT_REQ, {
1514 { GTP_EXT_IMSI, GTP_MANDATORY },
1515 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
1516 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1521 GTP_MSG_MS_PRESENT_RESP, {
1522 { GTP_EXT_CAUSE, GTP_MANDATORY },
1523 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1528 GTP_MSG_IDENT_REQ, {
1529 { GTP_EXT_RAI, GTP_MANDATORY },
1530 { GTP_EXT_PTMSI, GTP_MANDATORY },
1531 { GTP_EXT_PTMSI_SIG, GTP_OPTIONAL },
1532 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1537 GTP_MSG_IDENT_RESP, {
1538 { GTP_EXT_CAUSE, GTP_MANDATORY },
1539 { GTP_EXT_IMSI, GTP_CONDITIONAL },
1540 { GTP_EXT_AUTH_TRI, GTP_OPTIONAL },
1541 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1546 GTP_MSG_SGSN_CNTXT_REQ, {
1547 { GTP_EXT_IMSI, GTP_CONDITIONAL },
1548 { GTP_EXT_RAI, GTP_MANDATORY },
1549 { GTP_EXT_TLLI, GTP_MANDATORY },
1550 { GTP_EXT_PTMSI_SIG, GTP_OPTIONAL },
1551 { GTP_EXT_MS_VALID, GTP_OPTIONAL },
1552 { GTP_EXT_FLOW_SIG, GTP_MANDATORY },
1557 GTP_MSG_SGSN_CNTXT_RESP, {
1558 { GTP_EXT_CAUSE, GTP_MANDATORY },
1559 { GTP_EXT_IMSI, GTP_CONDITIONAL },
1560 { GTP_EXT_FLOW_SIG, GTP_CONDITIONAL },
1561 { GTP_EXT_MM_CNTXT, GTP_CONDITIONAL },
1562 { GTP_EXT_PDP_CNTXT, GTP_CONDITIONAL },
1563 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1568 GTP_MSG_SGSN_CNTXT_ACK, {
1569 { GTP_EXT_CAUSE, GTP_MANDATORY },
1570 { GTP_EXT_FLOW_II, GTP_CONDITIONAL },
1571 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
1572 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1577 GTP_MSG_DATA_TRANSF_REQ, {
1578 { GTP_EXT_TR_COMM, GTP_MANDATORY },
1579 { GTP_EXT_DATA_REQ, GTP_CONDITIONAL },
1580 { GTP_EXT_REL_PACK, GTP_CONDITIONAL },
1581 { GTP_EXT_CAN_PACK, GTP_CONDITIONAL },
1582 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1587 GTP_MSG_DATA_TRANSF_RESP, {
1588 { GTP_EXT_CAUSE, GTP_MANDATORY },
1589 { GTP_EXT_DATA_RESP, GTP_MANDATORY },
1590 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1601 /* -----------------------------
1603 * -----------------------------*/
1604 static _gtp_mess_items umts_mess_items[] = {
1608 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1613 GTP_MSG_ECHO_RESP, {
1614 { GTP_EXT_RECOVER, GTP_MANDATORY },
1615 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1620 GTP_MSG_VER_NOT_SUPP, {
1625 GTP_MSG_NODE_ALIVE_REQ, {
1626 { GTP_EXT_NODE_ADDR, GTP_MANDATORY },
1627 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1632 GTP_MSG_NODE_ALIVE_RESP, {
1633 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1638 GTP_MSG_REDIR_REQ, {
1639 { GTP_EXT_CAUSE, GTP_MANDATORY },
1640 { GTP_EXT_NODE_ADDR, GTP_OPTIONAL },
1641 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1646 GTP_MSG_REDIR_REQ, {
1651 GTP_MSG_CREATE_PDP_REQ, {
1652 { GTP_EXT_IMSI, GTP_CONDITIONAL },
1653 { GTP_EXT_RECOVER, GTP_OPTIONAL },
1654 { GTP_EXT_SEL_MODE, GTP_CONDITIONAL },
1655 { GTP_EXT_TEID, GTP_MANDATORY },
1656 { GTP_EXT_TEID_CP, GTP_CONDITIONAL },
1657 { GTP_EXT_NSAPI, GTP_MANDATORY },
1658 { GTP_EXT_NSAPI, GTP_CONDITIONAL },
1659 { GTP_EXT_CHRG_CHAR, GTP_OPTIONAL },
1660 { GTP_EXT_TRACE_REF, GTP_OPTIONAL },
1661 { GTP_EXT_TRACE_TYPE, GTP_OPTIONAL },
1662 { GTP_EXT_USER_ADDR, GTP_CONDITIONAL },
1663 { GTP_EXT_APN, GTP_CONDITIONAL },
1664 { GTP_EXT_PROTO_CONF, GTP_CONDITIONAL },
1665 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
1666 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
1667 { GTP_EXT_MSISDN, GTP_CONDITIONAL },
1668 { GTP_EXT_QOS_UMTS, GTP_MANDATORY },
1669 { GTP_EXT_TFT, GTP_CONDITIONAL },
1670 { GTP_EXT_TRIGGER_ID, GTP_OPTIONAL },
1671 { GTP_EXT_OMC_ID, GTP_OPTIONAL },
1672 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1677 GTP_MSG_CREATE_PDP_RESP, {
1678 { GTP_EXT_CAUSE, GTP_MANDATORY },
1679 { GTP_EXT_REORDER, GTP_CONDITIONAL },
1680 { GTP_EXT_RECOVER, GTP_OPTIONAL },
1681 { GTP_EXT_TEID, GTP_CONDITIONAL },
1682 { GTP_EXT_TEID_CP, GTP_CONDITIONAL },
1683 { GTP_EXT_CHRG_ID, GTP_CONDITIONAL },
1684 { GTP_EXT_USER_ADDR, GTP_CONDITIONAL },
1685 { GTP_EXT_PROTO_CONF, GTP_OPTIONAL },
1686 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
1687 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
1688 { GTP_EXT_QOS_UMTS, GTP_CONDITIONAL },
1689 { GTP_EXT_CHRG_ADDR, GTP_OPTIONAL },
1690 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1694 { /* checked, SGSN -> GGSN */
1695 GTP_MSG_UPDATE_PDP_REQ, {
1696 { GTP_EXT_IMSI, GTP_CONDITIONAL },
1697 { GTP_EXT_RECOVER, GTP_OPTIONAL },
1698 { GTP_EXT_TEID, GTP_MANDATORY },
1699 { GTP_EXT_TEID_CP, GTP_CONDITIONAL },
1700 { GTP_EXT_NSAPI, GTP_MANDATORY },
1701 { GTP_EXT_TRACE_REF, GTP_OPTIONAL },
1702 { GTP_EXT_TRACE_TYPE, GTP_OPTIONAL },
1703 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
1704 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
1705 { GTP_EXT_QOS_UMTS, GTP_MANDATORY },
1706 { GTP_EXT_TFT, GTP_OPTIONAL },
1707 { GTP_EXT_TRIGGER_ID, GTP_OPTIONAL },
1708 { GTP_EXT_OMC_ID, GTP_OPTIONAL },
1709 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1713 { /* checked, GGSN -> SGSN */
1714 GTP_MSG_UPDATE_PDP_RESP, {
1715 { GTP_EXT_CAUSE, GTP_MANDATORY },
1716 { GTP_EXT_RECOVER, GTP_OPTIONAL },
1717 { GTP_EXT_TEID, GTP_CONDITIONAL },
1718 { GTP_EXT_TEID_CP, GTP_CONDITIONAL },
1719 { GTP_EXT_CHRG_ID, GTP_CONDITIONAL },
1720 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
1721 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
1722 { GTP_EXT_QOS_UMTS, GTP_CONDITIONAL },
1723 { GTP_EXT_CHRG_ADDR, GTP_OPTIONAL },
1724 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1729 GTP_MSG_DELETE_PDP_REQ, {
1730 { GTP_EXT_TEAR_IND, GTP_CONDITIONAL },
1731 { GTP_EXT_NSAPI, GTP_MANDATORY },
1732 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1737 GTP_MSG_DELETE_PDP_RESP, {
1738 { GTP_EXT_CAUSE, GTP_MANDATORY },
1739 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1745 { GTP_EXT_TEID, GTP_MANDATORY },
1746 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1751 GTP_MSG_PDU_NOTIFY_REQ, {
1752 { GTP_EXT_IMSI, GTP_MANDATORY },
1753 { GTP_EXT_TEID_CP, GTP_MANDATORY },
1754 { GTP_EXT_USER_ADDR, GTP_MANDATORY },
1755 { GTP_EXT_APN, GTP_MANDATORY },
1756 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
1757 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1762 GTP_MSG_PDU_NOTIFY_RESP, {
1763 { GTP_EXT_CAUSE, GTP_MANDATORY },
1764 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1769 GTP_MSG_PDU_NOTIFY_REJ_REQ, {
1770 { GTP_EXT_CAUSE, GTP_MANDATORY },
1771 { GTP_EXT_TEID_CP, GTP_MANDATORY },
1772 { GTP_EXT_USER_ADDR, GTP_MANDATORY },
1773 { GTP_EXT_APN, GTP_MANDATORY },
1774 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1779 GTP_MSG_PDU_NOTIFY_REJ_RESP, {
1780 { GTP_EXT_CAUSE, GTP_MANDATORY },
1781 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1786 GTP_MSG_SUPP_EXT_HDR, {
1787 { GTP_EXT_HDR_LIST, GTP_MANDATORY },
1792 GTP_MSG_SEND_ROUT_INFO_REQ, {
1793 { GTP_EXT_IMSI, GTP_MANDATORY },
1794 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1799 GTP_MSG_SEND_ROUT_INFO_RESP, {
1800 { GTP_EXT_CAUSE, GTP_MANDATORY },
1801 { GTP_EXT_IMSI, GTP_MANDATORY },
1802 { GTP_EXT_MAP_CAUSE, GTP_OPTIONAL },
1803 { GTPv1_EXT_MS_REASON, GTP_OPTIONAL },
1804 { GTP_EXT_GSN_ADDR, GTP_OPTIONAL },
1805 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1810 GTP_MSG_FAIL_REP_REQ, {
1811 { GTP_EXT_IMSI, GTP_MANDATORY },
1812 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1817 GTP_MSG_FAIL_REP_RESP, {
1818 { GTP_EXT_CAUSE, GTP_MANDATORY },
1819 { GTP_EXT_MAP_CAUSE, GTP_OPTIONAL },
1820 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1825 GTP_MSG_MS_PRESENT_REQ, {
1826 { GTP_EXT_IMSI, GTP_MANDATORY },
1827 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
1828 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1833 GTP_MSG_MS_PRESENT_RESP, {
1834 { GTP_EXT_CAUSE, GTP_MANDATORY },
1835 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1840 GTP_MSG_IDENT_REQ, {
1841 { GTP_EXT_RAI, GTP_MANDATORY },
1842 { GTP_EXT_PTMSI, GTP_MANDATORY },
1843 { GTP_EXT_PTMSI_SIG, GTP_CONDITIONAL },
1844 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1849 GTP_MSG_IDENT_RESP, {
1850 { GTP_EXT_CAUSE, GTP_MANDATORY },
1851 { GTP_EXT_IMSI, GTP_CONDITIONAL },
1852 { GTP_EXT_AUTH_TRI, GTP_CONDITIONAL },
1853 { GTP_EXT_AUTH_QUI, GTP_CONDITIONAL },
1854 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1859 GTP_MSG_SGSN_CNTXT_REQ, {
1860 { GTP_EXT_IMSI, GTP_CONDITIONAL },
1861 { GTP_EXT_RAI, GTP_MANDATORY },
1862 { GTP_EXT_TLLI, GTP_CONDITIONAL },
1863 { GTP_EXT_PTMSI, GTP_CONDITIONAL },
1864 { GTP_EXT_PTMSI_SIG, GTP_CONDITIONAL },
1865 { GTP_EXT_MS_VALID, GTP_OPTIONAL },
1866 { GTP_EXT_TEID_CP, GTP_MANDATORY },
1867 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
1868 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1873 GTP_MSG_SGSN_CNTXT_RESP, {
1874 { GTP_EXT_CAUSE, GTP_MANDATORY },
1875 { GTP_EXT_IMSI, GTP_CONDITIONAL },
1876 { GTP_EXT_TEID_CP, GTP_CONDITIONAL },
1877 { GTP_EXT_RP_SMS, GTP_OPTIONAL },
1878 { GTP_EXT_RP, GTP_OPTIONAL },
1879 { GTP_EXT_PKT_FLOW_ID, GTP_OPTIONAL },
1880 { GTP_EXT_MM_CNTXT, GTP_CONDITIONAL },
1881 { GTP_EXT_PDP_CNTXT, GTP_CONDITIONAL },
1882 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
1883 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1888 GTP_MSG_SGSN_CNTXT_ACK, {
1889 { GTP_EXT_CAUSE, GTP_MANDATORY },
1890 { GTP_EXT_TEID_II, GTP_CONDITIONAL },
1891 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
1892 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1897 GTP_MSG_FORW_RELOC_REQ, {
1898 { GTP_EXT_IMSI, GTP_MANDATORY },
1899 { GTP_EXT_TEID_CP, GTP_MANDATORY },
1900 { GTP_EXT_RANAP_CAUSE, GTP_MANDATORY },
1901 { GTP_EXT_MM_CNTXT, GTP_MANDATORY },
1902 { GTP_EXT_PDP_CNTXT, GTP_CONDITIONAL },
1903 { GTP_EXT_GSN_ADDR, GTP_MANDATORY },
1904 { GTP_EXT_TARGET_ID, GTP_MANDATORY },
1905 { GTP_EXT_UTRAN_CONT, GTP_MANDATORY },
1906 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1911 GTP_MSG_FORW_RELOC_RESP, {
1912 { GTP_EXT_CAUSE, GTP_MANDATORY },
1913 { GTP_EXT_TEID_CP, GTP_CONDITIONAL },
1914 { GTP_EXT_RANAP_CAUSE, GTP_CONDITIONAL },
1915 { GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
1916 { GTP_EXT_UTRAN_CONT, GTP_OPTIONAL },
1917 { GTP_EXT_RAB_SETUP, GTP_CONDITIONAL },
1918 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1923 GTP_MSG_FORW_RELOC_COMP, {
1924 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1929 GTP_MSG_RELOC_CANCEL_REQ, {
1930 { GTP_EXT_IMSI, GTP_MANDATORY },
1931 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1936 GTP_MSG_RELOC_CANCEL_RESP, {
1937 { GTP_EXT_CAUSE, GTP_MANDATORY },
1938 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1943 GTP_MSG_FORW_RELOC_ACK, {
1944 { GTP_EXT_CAUSE, GTP_MANDATORY },
1945 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1950 GTP_MSG_FORW_SRNS_CNTXT, {
1951 { GTP_EXT_RAB_CNTXT, GTP_MANDATORY },
1952 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1957 GTP_MSG_FORW_SRNS_CNTXT_ACK, {
1958 { GTP_EXT_CAUSE, GTP_MANDATORY },
1959 { GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
1971 check_field_presence(guint8 message, guint8 field, int *position) {
1974 _gtp_mess_items *mess_items;
1976 switch(gtp_version) {
1978 mess_items = gprs_mess_items;
1981 mess_items = umts_mess_items;
1987 while (mess_items[i].code) {
1988 if (mess_items[i].code == message) {
1990 while (mess_items[i].fields[*position].code) {
1991 if (mess_items[i].fields[*position].code == field) {
1995 if (mess_items[i].fields[*position].presence == GTP_MANDATORY) {
1996 return mess_items[i].fields[(*position)++].code;
2009 /* Decoders of fields in extension headers, each function returns no of bytes from field */
2011 /* GPRS: 9.60 v7.6.0, chapter
2012 * UMTS: 29.060 v4.0, chapter
2015 decode_gtp_cause(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2019 cause = tvb_get_guint8(tvb, offset+1);
2021 proto_tree_add_uint(tree, hf_gtp_cause, tvb, offset, 2, cause);
2026 /* GPRS: 9.60 v7.6.0, chapter 7.9.2
2027 * UMTS: 29.060 v4.0, chapter 7.7.2
2030 decode_gtp_imsi(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2035 tvb_memcpy(tvb, imsi_val, offset+1, 8);
2036 imsi_str = imsi_to_str (imsi_val);
2038 proto_tree_add_string (tree, hf_gtp_imsi, tvb, offset, 9, imsi_str);
2043 /* GPRS: 9.60 v7.6.0, chapter 7.9.3
2044 * UMTS: 29.060 v4.0, chapter 7.7.3
2047 decode_gtp_rai(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2049 proto_tree *ext_tree_rai;
2054 te = proto_tree_add_text(tree, tvb, offset, 1, val_to_str(GTP_EXT_RAI, gtp_val, "Unknown message"));
2055 ext_tree_rai = proto_item_add_subtree(te, ett_gtp_rai);
2057 byte[0] = tvb_get_guint8 (tvb, offset + 1);
2058 byte[1] = tvb_get_guint8 (tvb, offset + 2);
2059 byte[2] = tvb_get_guint8 (tvb, offset + 3);
2060 mcc = (byte[0] & 0x0F) * 100 + ((byte[0] & 0xF0) >> 4) * 10 + (byte[1] & 0x0F );
2061 if ((byte[1] & 0xF0) == 0xF0)
2062 mnc = (byte[2] & 0x0F) * 10 + ((byte[2] & 0xF0) >> 4);
2064 mnc = (byte[2] & 0x0F) * 100 + ((byte[2] & 0xF0) >> 4 ) * 10 + ((byte[1] & 0xF0) >> 4);
2066 proto_tree_add_uint(ext_tree_rai, hf_gtp_rai_mcc, tvb, offset+1, 2, mcc);
2067 proto_tree_add_uint(ext_tree_rai, hf_gtp_rai_mnc, tvb, offset+2, 2, mnc);
2068 proto_tree_add_uint(ext_tree_rai, hf_gtp_rai_lac, tvb, offset+4, 2, tvb_get_ntohs (tvb, offset+4));
2069 proto_tree_add_uint(ext_tree_rai, hf_gtp_rai_rac, tvb, offset+6, 1, tvb_get_guint8 (tvb, offset+6));
2074 /* GPRS: 9.60 v7.6.0, chapter 7.9.4, page 39
2075 * UMTS: 29.060 v4.0, chapter 7.7.4, page 47
2078 decode_gtp_tlli(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2082 tlli = tvb_get_ntohl(tvb, offset+1);
2083 proto_tree_add_uint(tree, hf_gtp_tlli, tvb, offset, 5, tlli);
2088 /* GPRS: 9.60 v7.6.0, chapter 7.9.5, page 39
2089 * UMTS: 29.060 v4.0, chapter 7.7.5, page 47
2092 decode_gtp_ptmsi(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2096 ptmsi = tvb_get_ntohl (tvb, offset+1);
2097 proto_tree_add_uint (tree, hf_gtp_ptmsi, tvb, offset, 5, ptmsi);
2102 /* adjust - how many bytes before offset should be highlighted
2105 decode_qos_gprs(tvbuff_t *tvb, int offset, proto_tree *tree, const gchar* qos_str, guint8 adjust) {
2107 guint8 spare1, delay, reliability, peak, spare2, precedence, spare3, mean;
2108 proto_tree *ext_tree_qos;
2111 spare1 = tvb_get_guint8(tvb, offset) & 0xC0;
2112 delay = tvb_get_guint8(tvb, offset) & 0x38;
2113 reliability = tvb_get_guint8(tvb, offset) & 0x07;
2114 peak = tvb_get_guint8(tvb, offset+1) & 0xF0;
2115 spare2 = tvb_get_guint8(tvb, offset+1) & 0x08;
2116 precedence = tvb_get_guint8(tvb, offset+1) & 0x07;
2117 spare3 = tvb_get_guint8(tvb, offset+2) & 0xE0;
2118 mean = tvb_get_guint8(tvb, offset+2) & 0x1F;
2120 te = proto_tree_add_text(tree, tvb, offset-adjust, 3+adjust, "%s: delay: %u, reliability: %u, peak: %u, precedence: %u, mean: %u",
2121 qos_str, (delay >> 3) & 0x07, reliability, (peak >> 4) & 0x0F, precedence, mean);
2122 ext_tree_qos = proto_item_add_subtree(te, ett_gtp_qos);
2125 proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_spare1, tvb, offset, 1, spare1);
2126 proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_delay, tvb, offset, 1, delay);
2127 proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_reliability, tvb, offset, 1, reliability);
2128 proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_peak, tvb, offset+1, 1, peak);
2129 proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_spare2, tvb, offset+1, 1, spare2);
2130 proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_precedence, tvb, offset+1, 1, precedence);
2131 proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_spare3, tvb, offset+2, 1, spare3);
2132 proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_mean, tvb, offset+2, 1, mean);
2138 /* GPRS: 9.60 v7.6.0, chapter 7.9.6, page 39
2142 * TODO: check if length is included: ETSI 4.08 vs 9.60
2145 decode_gtp_qos_gprs(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2147 return (1+decode_qos_gprs(tvb, offset+1, tree, "Quality of Service", 1));
2151 /* GPRS: 9.60 v7.6.0, chapter 7.9.7, page 39
2152 * UMTS: 29.060 v4.0, chapter 7.7.6, page 47
2155 decode_gtp_reorder(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2159 reorder = tvb_get_guint8(tvb, offset+1) & 0x01;
2160 proto_tree_add_boolean(tree, hf_gtp_reorder, tvb, offset, 2, reorder);
2165 /* GPRS: 9.60 v7.6.0, chapter 7.9.8, page 40
2166 * 4.08 v7.1.2, chapter 10.5.3.1+
2167 * UMTS: 29.060 v4.0, chapter 7.7.7
2168 * TODO: Add blurb support by registering items in the protocol registration
2171 decode_gtp_auth_tri(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2173 proto_tree *ext_tree_auth_tri;
2176 te = proto_tree_add_text(tree, tvb, offset, 29, val_to_str(GTP_EXT_AUTH_TRI, gtp_val, "Unknown message"));
2177 ext_tree_auth_tri = proto_item_add_subtree(tree, ett_gtp_auth_tri);
2179 proto_tree_add_text(ext_tree_auth_tri, tvb, offset+1, 16, "RAND: %s", tvb_bytes_to_str(tvb, offset+1, 16));
2180 proto_tree_add_text(ext_tree_auth_tri, tvb, offset+17, 4, "SRES: %s", tvb_bytes_to_str(tvb, offset+17, 4));
2181 proto_tree_add_text(ext_tree_auth_tri, tvb, offset+21, 8, "Kc: %s", tvb_bytes_to_str(tvb, offset+21, 8));
2186 /* GPRS: 9.60 v7.6.0, chapter 7.9.9, page 40
2187 * 9.02 v7.7.0, page 1090
2188 * UMTS: 29.060 v4.0, chapter 7.7.8, page 48
2189 * 29.002 v4.2.1, chapter 17.5, page 268
2192 decode_gtp_map_cause(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2196 map_cause = tvb_get_guint8(tvb, offset+1);
2197 proto_tree_add_uint (tree, hf_gtp_map_cause, tvb, offset, 2, map_cause);
2202 /* GPRS: 9.60 v7.6.0, chapter 7.9.10, page 41
2203 * UMTS: 29.060 v4.0, chapter 7.7.9, page 48
2206 decode_gtp_ptmsi_sig(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2210 ptmsi_sig = tvb_get_ntoh24(tvb, offset+1);
2211 proto_tree_add_uint(tree, hf_gtp_ptmsi_sig, tvb, offset, 4, ptmsi_sig);
2216 /* GPRS: 9.60 v7.6.0, chapter 7.9.11, page 41
2217 * UMTS: 29.060 v4.0, chapter 7.7.10, page 49
2220 decode_gtp_ms_valid(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2224 ms_valid = tvb_get_guint8(tvb, offset+1) & 0x01;
2225 proto_tree_add_boolean (tree, hf_gtp_ms_valid, tvb, offset, 2, ms_valid);
2230 /* GPRS: 9.60 v7.6.0, chapter 7.9.12, page 41
2231 * UMTS: 29.060 v4.0, chapter 7.7.11, page 49
2234 decode_gtp_recovery(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2238 recovery = tvb_get_guint8(tvb, offset+1);
2239 proto_tree_add_uint (tree, hf_gtp_recovery, tvb, offset, 2, recovery);
2244 /* GPRS: 9.60 v7.6.0, chapter 7.9.13, page 42
2245 * UMTS: 29.060 v4.0, chapter 7.7.12, page 49
2248 decode_gtp_sel_mode(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2252 sel_mode = tvb_get_guint8(tvb, offset+1) & 0x03;
2253 proto_tree_add_uint(tree, hf_gtp_sel_mode, tvb, offset, 2, sel_mode);
2258 /* GPRS: 9.60 v7.6.0, chapter 7.9.14, page 42
2259 * UMTS: 29.060 v4.0, chapter 7.7.13, page 50
2262 decode_gtp_16(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2264 guint16 ext_flow_label;
2267 switch (gtp_version) {
2269 ext_flow_label = tvb_get_ntohs(tvb, offset+1);
2270 proto_tree_add_uint(tree, hf_gtp_ext_flow_label, tvb, offset, 3, ext_flow_label);
2274 teid_data = tvb_get_ntohl(tvb, offset+1);
2275 proto_tree_add_uint(tree, hf_gtp_teid_data, tvb, offset, 5, teid_data);
2279 proto_tree_add_text(tree, tvb, offset, 1, "Flow label/TEID Data I : GTP version not supported");
2285 /* GPRS: 9.60 v7.6.0, chapter 7.9.15, page 42
2286 * UMTS: 29.060 v4.0, chapter 7.7.14, page 42
2289 decode_gtp_17(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2294 switch (gtp_version) {
2296 flow_sig = tvb_get_ntohs(tvb, offset+1);
2297 proto_tree_add_uint (tree, hf_gtp_flow_sig, tvb, offset, 3, flow_sig);
2300 teid_cp = tvb_get_ntohl(tvb, offset+1);
2301 proto_tree_add_uint (tree, hf_gtp_teid_cp, tvb, offset, 5, teid_cp);
2304 proto_tree_add_text(tree, tvb, offset, 1, "Flow label signalling/TEID control plane : GTP version not supported");
2309 /* GPRS: 9.60 v7.6.0, chapter 7.9.16, page 42
2310 * UMTS: 29.060 v4.0, chapter 7.7.15, page 51
2313 decode_gtp_18(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2317 proto_tree *ext_tree_flow_ii;
2320 switch (gtp_version) {
2322 te = proto_tree_add_text(tree, tvb, offset, 4, val_to_str(GTP_EXT_FLOW_II, gtp_val, "Unknown message"));
2323 ext_tree_flow_ii = proto_item_add_subtree (te, ett_gtp_flow_ii);
2325 proto_tree_add_uint(ext_tree_flow_ii, hf_gtp_nsapi, tvb, offset+1, 1, tvb_get_guint8(tvb, offset+1) & 0x0F);
2327 flow_ii = tvb_get_ntohs(tvb, offset+2);
2328 proto_tree_add_uint(ext_tree_flow_ii, hf_gtp_flow_ii, tvb, offset+2, 2, flow_ii);
2332 te = proto_tree_add_text (tree, tvb, offset, 6, val_to_str(GTP_EXT_TEID_II, gtp_val, "Unknown message"));
2333 ext_tree_flow_ii = proto_item_add_subtree(te, ett_gtp_flow_ii);
2335 proto_tree_add_uint(ext_tree_flow_ii, hf_gtp_nsapi, tvb, offset+1, 1, tvb_get_guint8(tvb, offset+1) & 0x0F);
2338 teid_ii = tvb_get_ntohl(tvb, offset+2);
2339 proto_tree_add_uint(ext_tree_flow_ii, hf_gtp_teid_ii, tvb, offset+2, 4, teid_ii);
2343 proto_tree_add_text(tree, tvb, offset, 1, "Flow data II/TEID Data II : GTP Version not supported");
2349 /* GPRS: 9.60 v7.6.0, chapter 7.9.16A, page 43
2350 * UMTS: 29.060 v4.0, chapter 7.7.16, page 51
2351 * Check if all ms_reason types are included
2354 decode_gtp_19(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2358 field19 = tvb_get_guint8(tvb, offset+1);
2360 switch (gtp_version) {
2362 proto_tree_add_uint(tree, hf_gtp_ms_reason, tvb, offset, 2, field19);
2365 proto_tree_add_boolean(tree, hf_gtp_tear_ind, tvb, offset, 2, field19 & 0x01);
2368 proto_tree_add_text(tree, tvb, offset, 1, "Information Element Type = 19 : GTP Version not supported");
2375 /* GPRS: not present
2376 * UMTS: 29.060 v4.0, chapter 7.7.17, page 51
2379 decode_gtp_nsapi(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2383 nsapi = tvb_get_guint8(tvb, offset+1) & 0x0F;
2384 proto_tree_add_uint(tree, hf_gtp_nsapi, tvb, offset, 2, nsapi);
2389 /* GPRS: not present
2390 * UMTS: 29.060 v4.0, chapter 7.7.18, page 52
2393 decode_gtp_ranap_cause(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2397 ranap = tvb_get_guint8(tvb, offset+1);
2399 if(ranap > 0 && ranap <=64)
2400 proto_tree_add_uint_format(tree, hf_gtp_ranap_cause, tvb, offset, 2,
2401 ranap, "%s (Radio Network Layer Cause) : %s (%u)",
2402 val_to_str(GTP_EXT_RANAP_CAUSE, gtp_val, "Unknown"),
2403 val_to_str(ranap, ranap_cause_type, "Unknown RANAP Cause"), ranap);
2405 if(ranap > 64 && ranap <=80)
2406 proto_tree_add_uint_format(tree, hf_gtp_ranap_cause, tvb, offset, 2,
2407 ranap, "%s (Transport Layer Cause) : %s (%u)",
2408 val_to_str(GTP_EXT_RANAP_CAUSE, gtp_val, "Unknown"),
2409 val_to_str(ranap, ranap_cause_type, "Unknown RANAP Cause"), ranap);
2411 if(ranap > 80 && ranap <=96)
2412 proto_tree_add_uint_format(tree, hf_gtp_ranap_cause, tvb, offset, 2,
2413 ranap, "%s (NAS Cause) : %s (%u)",
2414 val_to_str(GTP_EXT_RANAP_CAUSE, gtp_val, "Unknown"),
2415 val_to_str(ranap, ranap_cause_type, "Unknown RANAP Cause"), ranap);
2417 if(ranap > 96 && ranap <=112)
2418 proto_tree_add_uint_format(tree, hf_gtp_ranap_cause, tvb, offset, 2, ranap,
2419 "%s (Protocol Cause) : %s (%u)",
2420 val_to_str(GTP_EXT_RANAP_CAUSE, gtp_val, "Unknown"),
2421 val_to_str(ranap, ranap_cause_type, "Unknown RANAP Cause"), ranap);
2423 if(ranap > 112 && ranap <=128)
2424 proto_tree_add_uint_format(tree, hf_gtp_ranap_cause, tvb, offset, 2, ranap,
2425 "%s (Miscellaneous Cause) : %s (%u)",
2426 val_to_str(GTP_EXT_RANAP_CAUSE, gtp_val, "Unknown"),
2427 val_to_str(ranap, ranap_cause_type, "Unknown RANAP Cause"), ranap);
2429 if(ranap > 128 /* && ranap <=255 */)
2430 proto_tree_add_uint_format(tree, hf_gtp_ranap_cause, tvb, offset, 2, ranap,
2431 "%s (Non-standard Cause) : %s (%u)",
2432 val_to_str(GTP_EXT_RANAP_CAUSE, gtp_val, "Unknown"),
2433 val_to_str(ranap, ranap_cause_type, "Unknown RANAP Cause"), ranap);
2438 /* GPRS: not present
2439 * UMTS: 29.060 v4.0, chapter 7.7.19, page 52
2442 decode_gtp_rab_cntxt(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2444 guint8 nsapi, dl_pdcp_seq, ul_pdcp_seq;
2445 guint16 dl_gtpu_seq, ul_gtpu_seq;
2446 proto_tree *ext_tree_rab_cntxt;
2449 te = proto_tree_add_text(tree, tvb, offset, 8, val_to_str(GTP_EXT_RAB_CNTXT, gtp_val, "Unknown message"));
2450 ext_tree_rab_cntxt = proto_item_add_subtree(te, ett_gtp_rab_cntxt);
2452 nsapi = tvb_get_guint8(tvb, offset+1) & 0x0F;
2453 dl_gtpu_seq = tvb_get_ntohs(tvb, offset+2);
2454 ul_gtpu_seq = tvb_get_ntohs(tvb, offset+4);
2455 dl_pdcp_seq = tvb_get_guint8(tvb, offset+6);
2456 ul_pdcp_seq = tvb_get_guint8(tvb, offset+7);
2458 proto_tree_add_uint (ext_tree_rab_cntxt, hf_gtp_nsapi, tvb, offset+1, 1, nsapi);
2459 proto_tree_add_uint(ext_tree_rab_cntxt, hf_gtp_rab_gtpu_dn, tvb, offset+2, 2, dl_gtpu_seq);
2460 proto_tree_add_uint(ext_tree_rab_cntxt, hf_gtp_rab_gtpu_up, tvb, offset+4, 2, ul_gtpu_seq);
2461 proto_tree_add_uint(ext_tree_rab_cntxt, hf_gtp_rab_pdu_dn, tvb, offset+6, 1, dl_pdcp_seq);
2462 proto_tree_add_uint(ext_tree_rab_cntxt, hf_gtp_rab_pdu_up, tvb, offset+7, 1, ul_pdcp_seq);
2468 /* GPRS: not present
2469 * UMTS: 29.060 v4.0, chapter 7.7.20, page 53
2472 decode_gtp_rp_sms(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2476 rp_sms = tvb_get_guint8(tvb, offset+1) & 0x07;
2477 proto_tree_add_uint(tree, hf_gtp_rp_sms, tvb, offset, 2, rp_sms);
2482 /* GPRS: not present
2483 * UMTS: 29.060 v4.0, chapter 7.7.21, page 53
2486 decode_gtp_rp(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2488 proto_tree *ext_tree_rp;
2490 guint8 nsapi, rp, spare;
2492 nsapi = tvb_get_guint8(tvb, offset+1) & 0xF0;
2493 spare = tvb_get_guint8(tvb, offset+1) & 0x08;
2494 rp = tvb_get_guint8(tvb, offset+1) & 0x07;
2496 te = proto_tree_add_uint_format(tree, hf_gtp_rp, tvb, offset, 2, rp, "Radio Priority for NSAPI(%u) : %u", nsapi, rp);
2497 ext_tree_rp = proto_item_add_subtree(tree, ett_gtp_rp);
2499 proto_tree_add_uint(ext_tree_rp, hf_gtp_rp_nsapi, tvb, offset+1, 1, nsapi);
2500 proto_tree_add_uint(ext_tree_rp, hf_gtp_rp_spare, tvb, offset+1, 1, spare);
2501 proto_tree_add_uint(ext_tree_rp, hf_gtp_rp, tvb, offset+1, 1, rp);
2506 /* GPRS: not present
2507 * UMTS: 29.060 v4.0, chapter 7.7.22, page 53
2510 decode_gtp_pkt_flow_id(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2512 proto_tree *ext_tree_pkt_flow_id;
2514 guint8 nsapi, pkt_flow_id;
2516 nsapi = tvb_get_guint8(tvb, offset+1) & 0x0F;
2517 pkt_flow_id = tvb_get_guint8(tvb, offset+2);
2519 te = proto_tree_add_uint_format (tree, hf_gtp_pkt_flow_id, tvb, offset,
2520 3, pkt_flow_id, "Packet Flow ID for NSAPI(%u) : %u", nsapi,
2522 ext_tree_pkt_flow_id = proto_item_add_subtree(tree, ett_gtp_pkt_flow_id);
2524 proto_tree_add_uint(ext_tree_pkt_flow_id, hf_gtp_nsapi, tvb, offset+1, 1, nsapi);
2525 proto_tree_add_uint_format(ext_tree_pkt_flow_id, hf_gtp_pkt_flow_id, tvb,
2526 offset+2, 1, pkt_flow_id, "%s : %u",
2527 val_to_str(GTP_EXT_PKT_FLOW_ID, gtp_val, "Unknown message"),
2533 /* GPRS: not present
2534 * UMTS: 29.060 v4.0, chapter 7.7.23, page 53
2535 * TODO: Differenciate these uints?
2538 decode_gtp_chrg_char(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2542 proto_tree *ext_tree_chrg_char;
2544 chrg_char = tvb_get_ntohs(tvb, offset+1);
2546 te = proto_tree_add_uint (tree, hf_gtp_chrg_char, tvb, offset, 3, chrg_char);
2547 /*"%s: %x", val_to_str (GTP_EXT_CHRG_CHAR, gtp_val, "Unknown message"), chrg_char);*/
2548 ext_tree_chrg_char = proto_item_add_subtree(te, ett_gtp_chrg_char);
2550 proto_tree_add_uint (ext_tree_chrg_char, hf_gtp_chrg_char_s, tvb, offset+1, 2, chrg_char);
2551 proto_tree_add_uint (ext_tree_chrg_char, hf_gtp_chrg_char_n, tvb, offset+1, 2, chrg_char);
2552 proto_tree_add_uint (ext_tree_chrg_char, hf_gtp_chrg_char_p, tvb, offset+1, 2, chrg_char);
2553 proto_tree_add_uint (ext_tree_chrg_char, hf_gtp_chrg_char_f, tvb, offset+1, 2, chrg_char);
2554 proto_tree_add_uint (ext_tree_chrg_char, hf_gtp_chrg_char_h, tvb, offset+1, 2, chrg_char);
2555 proto_tree_add_uint (ext_tree_chrg_char, hf_gtp_chrg_char_r, tvb, offset+1, 2, chrg_char);
2560 /* GPRS: not present
2561 * UMTS: 29.060 v4.0, chapter 7.7.24, page
2564 decode_gtp_trace_ref(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2568 trace_ref = tvb_get_ntohs(tvb, offset+1);
2570 proto_tree_add_uint (tree, hf_gtp_trace_ref, tvb, offset, 3, trace_ref);
2575 /* GPRS: not present
2576 * UMTS: 29.060 v4.0, chapter 7.7.25, page
2579 decode_gtp_trace_type(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2583 trace_type = tvb_get_ntohs(tvb, offset+1);
2585 proto_tree_add_uint (tree, hf_gtp_trace_type, tvb, offset, 3, trace_type);
2590 /* GPRS: 9.60 v7.6.0, chapter 7.9.16A
2591 * UMTS: 29.060 v4.0, chapter 7.7.25A, page
2594 decode_gtp_ms_reason(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2598 reason = tvb_get_guint8(tvb, offset+1);
2600 proto_tree_add_uint (tree, hf_gtp_ms_reason, tvb, offset, 2, reason);
2606 /* GPRS: 12.15 v7.6.0, chapter 7.3.3, page 45
2610 decode_gtp_tr_comm(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2614 tr_command = tvb_get_guint8(tvb, offset+1);
2616 proto_tree_add_uint (tree, hf_gtp_tr_comm, tvb, offset, 2, tr_command);
2621 /* GPRS: 9.60 v7.6.0, chapter 7.9.17, page 43
2622 * UMTS: 29.060 v4.0, chapter 7.7.26, page 55
2625 decode_gtp_chrg_id(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2629 chrg_id = tvb_get_ntohl(tvb, offset+1);
2630 proto_tree_add_uint (tree, hf_gtp_chrg_id, tvb, offset, 5, chrg_id);
2635 /* GPRS: 9.60 v7.6.0, chapter 7.9.18, page 43
2636 * UMTS: 29.060 v4.0, chapter 7.7.27, page 55
2639 decode_gtp_user_addr(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2642 guint8 pdp_typ, pdp_org;
2644 struct e_in6_addr addr_ipv6;
2645 proto_tree *ext_tree_user;
2649 length = tvb_get_ntohs(tvb, offset+1);
2650 pdp_org = tvb_get_guint8(tvb, offset+3) & 0x0F;
2651 pdp_typ = tvb_get_guint8(tvb, offset+4);
2653 te = proto_tree_add_text(tree, tvb, offset, 3+length, "%s (%s/%s)",
2654 val_to_str(GTP_EXT_USER_ADDR, gtp_val, "Unknown message"),
2655 val_to_str(pdp_org, pdp_org_type, "Unknown PDP Organization"),
2656 val_to_str(pdp_typ, pdp_type, "Unknown PDP Type"));
2657 ext_tree_user = proto_item_add_subtree(te, ett_gtp_user);
2659 proto_tree_add_text(ext_tree_user, tvb, offset+1, 2, "Length : %u", length);
2660 proto_tree_add_uint(ext_tree_user, hf_gtp_user_addr_pdp_org, tvb, offset+3, 1, pdp_org);
2661 proto_tree_add_uint(ext_tree_user, hf_gtp_user_addr_pdp_type, tvb, offset+4, 1, pdp_typ);
2664 if (pdp_org == 0 && pdp_typ == 1)
2665 proto_item_append_text(te, " (Point to Point Protocol)");
2666 else if (pdp_typ == 2)
2667 proto_item_append_text(te, " (Octet Stream Protocol)");
2668 } else if (length > 2) {
2671 addr_ipv4 = tvb_get_ipv4(tvb, offset+5);
2672 proto_tree_add_ipv4(ext_tree_user, hf_gtp_user_ipv4, tvb, offset+5, 4, addr_ipv4);
2673 proto_item_append_text(te, " : %s", ip_to_str((guint8 *)&addr_ipv4));
2676 tvb_get_ipv6(tvb, offset+5, &addr_ipv6);
2677 proto_tree_add_ipv6 (ext_tree_user, hf_gtp_user_ipv6, tvb, offset+5, 16, (guint8 *)&addr_ipv6);
2678 proto_item_append_text(te, " : %s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
2682 proto_item_append_text(te, " : empty PDP Address");
2688 decode_triplet(tvbuff_t *tvb, int offset, proto_tree *tree, guint16 count) {
2690 proto_tree *ext_tree_trip;
2691 proto_item *te_trip;
2694 for (i=0;i<count;i++) {
2695 te_trip = proto_tree_add_text(tree, tvb, offset+i*28, 28, "Triplet no%x", i);
2696 ext_tree_trip = proto_item_add_subtree(te_trip, ett_gtp_trip);
2698 proto_tree_add_text(ext_tree_trip, tvb, offset+i*28, 16, "RAND: %s", tvb_bytes_to_str(tvb, offset+i*28, 16));
2699 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));
2700 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));
2706 /* adjust - how many bytes before quintuplet should be highlighted
2709 decode_quintuplet(tvbuff_t *tvb, int offset, proto_tree *tree, guint16 count) {
2711 proto_tree *ext_tree_quint;
2712 proto_item *te_quint;
2713 guint16 q_offset, i;
2714 guint8 xres_len, auth_len;
2718 for (i=0;i<count;i++) {
2720 te_quint = proto_tree_add_text(tree, tvb, offset, -1, "Quintuplet #%x", i+1);
2721 ext_tree_quint = proto_item_add_subtree(te_quint, ett_gtp_quint);
2724 proto_tree_add_text(ext_tree_quint, tvb, offset + q_offset, 16, "RAND: %s", tvb_bytes_to_str(tvb, offset, 16));
2725 q_offset = q_offset + 16;
2726 xres_len = tvb_get_guint8(tvb, offset+q_offset);
2727 proto_tree_add_text(ext_tree_quint, tvb, offset + q_offset, 1, "XRES length: %u", xres_len);
2729 proto_tree_add_text(ext_tree_quint, tvb, offset + q_offset, xres_len, "XRES: %s", tvb_bytes_to_str(tvb, offset + q_offset, xres_len));
2730 q_offset = q_offset + xres_len;
2731 proto_tree_add_text(ext_tree_quint, tvb ,offset + q_offset, 16, "Quintuplet Ciphering Key: %s", tvb_bytes_to_str(tvb, offset + q_offset, 16));
2732 q_offset = q_offset + 16;
2733 proto_tree_add_text(ext_tree_quint, tvb, offset + q_offset, 16, "Quintuplet Integrity Key: %s", tvb_bytes_to_str(tvb, offset + q_offset, 16));
2734 q_offset = q_offset +16;
2735 auth_len = tvb_get_guint8(tvb, offset + q_offset);
2736 proto_tree_add_text(ext_tree_quint, tvb, offset + q_offset, 1, "Authentication length: %u", auth_len);
2738 proto_tree_add_text(ext_tree_quint, tvb, offset + q_offset, auth_len, "AUTH: %s", tvb_bytes_to_str(tvb, offset + q_offset, auth_len));
2740 q_offset = q_offset+auth_len;
2741 proto_item_set_end(te_quint, tvb, offset+q_offset);
2748 /* GPRS: 9.60 v7.6.0, chapter 7.9.19 page
2749 * UMTS: 29.060 v4.0, chapter 7.7.28 page 57
2750 * TODO: - check if for quintuplets first 2 bytes are length, according to AuthQuint
2751 * - finish displaying last 3 parameters
2754 decode_gtp_mm_cntxt(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
2756 guint16 length, quint_len, con_len;
2757 guint8 cksn, count, sec_mode, len;
2758 proto_tree *ext_tree_mm;
2760 proto_item *tf = NULL;
2761 proto_tree *tf_tree = NULL;
2765 te = proto_tree_add_text(tree, tvb, offset, 1, val_to_str(GTP_EXT_MM_CNTXT, gtp_val, "Unknown message"));
2766 ext_tree_mm = proto_item_add_subtree(te, ett_gtp_mm);
2769 length = tvb_get_ntohs(tvb, offset+1);
2770 if (length < 1) return 3;
2773 cksn = tvb_get_guint8(tvb, offset+3) & 0x07;
2775 sec_mode = (tvb_get_guint8(tvb, offset+4) >> 6) & 0x03;
2776 count = (tvb_get_guint8(tvb, offset+4) >> 3) & 0x07;
2778 proto_tree_add_text(ext_tree_mm, tvb, offset+1, 2, "Length: %x", length);
2779 if (gtp_version == 0)
2784 case 0: /* Used cipher value, UMTS keys and Quintuplets */
2785 proto_tree_add_item(ext_tree_mm, hf_gtp_cksn_ksi, tvb, offset+3, 1, FALSE);
2786 proto_tree_add_item(ext_tree_mm, hf_gtp_security_mode, tvb, offset+4, 1, FALSE);
2787 proto_tree_add_item(ext_tree_mm, hf_gtp_no_of_vectors, tvb, offset+4, 1, FALSE);
2788 proto_tree_add_item(ext_tree_mm, hf_gtp_cipher_algorithm, tvb, offset+4, 1, FALSE);
2789 proto_tree_add_text(ext_tree_mm, tvb, offset+5, 16, "Ciphering key CK: %s", tvb_bytes_to_str(tvb, offset+5, 16));
2790 proto_tree_add_text(ext_tree_mm, tvb, offset+21, 16, "Integrity key IK: %s", tvb_bytes_to_str(tvb, offset+21, 16));
2791 quint_len = tvb_get_ntohs(tvb, offset+37);
2792 proto_tree_add_text(ext_tree_mm, tvb, offset+37, 2, "Quintuplets length: 0x%x (%u)", quint_len, quint_len);
2794 offset = offset + decode_quintuplet(tvb, offset+39, ext_tree_mm, count) + 39;
2798 case 1: /* GSM key and triplets */
2799 proto_tree_add_item(ext_tree_mm, hf_gtp_cksn, tvb, offset+3, 1, FALSE);
2800 if (gtp_version != 0)
2801 proto_tree_add_item(ext_tree_mm, hf_gtp_security_mode, tvb, offset+4, 1, FALSE);
2803 proto_tree_add_item(ext_tree_mm, hf_gtp_no_of_vectors, tvb, offset+4, 1, FALSE);
2804 proto_tree_add_item(ext_tree_mm, hf_gtp_cipher_algorithm, tvb, offset+4, 1, FALSE);
2805 proto_tree_add_text(ext_tree_mm, tvb, offset+5, 8, "Ciphering key Kc: %s", tvb_bytes_to_str(tvb, offset+5, 8));
2807 offset = offset + decode_triplet(tvb, offset+13, ext_tree_mm, count) + 14;
2810 case 2: /* UMTS key and quintuplets */
2811 proto_tree_add_item(ext_tree_mm, hf_gtp_ksi, tvb, offset+3, 1, FALSE);
2812 proto_tree_add_item(ext_tree_mm, hf_gtp_security_mode, tvb, offset+4, 1, FALSE);
2813 proto_tree_add_item(ext_tree_mm, hf_gtp_no_of_vectors, tvb, offset+4, 1, FALSE);
2814 proto_tree_add_text(ext_tree_mm, tvb, offset+5, 16, "Ciphering key CK: %s", tvb_bytes_to_str(tvb, offset+5, 16));
2815 proto_tree_add_text(ext_tree_mm, tvb, offset+21, 16, "Integrity key IK: %s", tvb_bytes_to_str(tvb, offset+21, 16));
2816 quint_len = tvb_get_ntohs(tvb, offset+37);
2817 proto_tree_add_text(ext_tree_mm, tvb, offset+37, 2, "Quintuplets length: 0x%x (%u)", quint_len, quint_len);
2819 offset = offset + decode_quintuplet(tvb, offset+39, ext_tree_mm, count) + 39;
2822 case 3: /* GSM key and quintuplets */
2823 proto_tree_add_item(ext_tree_mm, hf_gtp_cksn, tvb, offset+3, 1, FALSE);
2824 proto_tree_add_item(ext_tree_mm, hf_gtp_security_mode, tvb, offset+4, 1, FALSE);
2825 proto_tree_add_item(ext_tree_mm, hf_gtp_no_of_vectors, tvb, offset+4, 1, FALSE);
2826 proto_tree_add_item(ext_tree_mm, hf_gtp_cipher_algorithm, tvb, offset+4, 1, FALSE);
2827 proto_tree_add_text(ext_tree_mm, tvb, offset+5, 8, "Ciphering key Kc: %s", tvb_bytes_to_str(tvb, offset+5, 8));
2828 quint_len = tvb_get_ntohs(tvb, offset+13);
2829 proto_tree_add_text(ext_tree_mm, tvb, offset+13, 2, "Quintuplets length: 0x%x (%u)", quint_len, quint_len);
2831 offset = offset + decode_quintuplet(tvb, offset+15, ext_tree_mm, count) + 15;
2839 * 3GPP TS 24.008 10.5.5.6 ( see packet-gsm_a.c )
2841 de_gmm_drx_param(tvb, ext_tree_mm, offset, 2, NULL, 0);
2844 len = tvb_get_guint8(tvb, offset);
2845 tf = proto_tree_add_text(ext_tree_mm,
2847 "MS Network Capability");
2849 tf_tree = proto_item_add_subtree(tf, ett_gtp_net_cap);
2851 proto_tree_add_text(tf_tree, tvb, offset, 1, "Length of MS network capability contents: %u", len);
2855 * GPP TS 24.008 10.5.5.12 ( see packet-gsm_a.c )
2857 de_gmm_ms_net_cap(tvb, tf_tree, offset, len, NULL, 0);
2858 offset = offset +len;
2860 /* Container contains one or several optional information elements as described in the clause 'Overview',
2861 * from the clause 'General message format and information elements coding' in 3GPP TS 24.008.
2862 * The IMEISV shall, if available, be included in the Container.
2865 con_len = tvb_get_ntohs(tvb, offset);
2866 proto_tree_add_text(ext_tree_mm, tvb, offset, 2, "Container length: %u", con_len);
2867 offset = offset + 2;
2871 l3_tvb = tvb_new_subset(tvb, offset,con_len, con_len );
2872 if (!dissector_try_port(bssap_pdu_type_table,BSSAP_PDU_TYPE_DTAP, l3_tvb, pinfo, ext_tree_mm))
2873 call_dissector(data_handle, l3_tvb, pinfo, ext_tree_mm);
2879 /* Function to extract the value of an hexadecimal octet. Only the lower
2880 * nybble will be non-zero in the output.
2882 static guint8 hex2dec (guint8 x)
2884 if ((x >= 'a') && (x <= 'f'))
2886 else if ((x >= 'A') && (x <= 'F'))
2888 else if ((x >= '0') && (x <= '9'))
2895 /* Wrapper function to add UTF-8 decoding for QoS attributes in
2898 static guint8 wrapped_tvb_get_guint8( tvbuff_t *tvb, int offset, int type)
2901 return (hex2dec(tvb_get_guint8(tvb, offset)) << 4
2902 | hex2dec(tvb_get_guint8(tvb, offset + 1)));
2904 return tvb_get_guint8(tvb, offset);
2907 /* WARNING : actually length is coded on 2 octets for QoS profile but on 1 octet for PDP Context!
2908 * so type means length of length :-)
2910 * WARNING :) type does not mean length of length any more... see below for
2914 decode_qos_umts(tvbuff_t *tvb, int offset, proto_tree *tree, const gchar* qos_str, guint8 type) {
2917 guint8 al_ret_priority;
2918 guint8 delay, reliability, peak, precedence, mean, spare1, spare2, spare3;
2919 guint8 traf_class, del_order, del_err_sdu;
2920 guint8 max_sdu_size, max_ul, max_dl;
2921 guint8 res_ber, sdu_err_ratio;
2922 guint8 trans_delay, traf_handl_prio;
2923 guint8 guar_ul, guar_dl;
2924 proto_tree *ext_tree_qos;
2926 int mss, mu, md, gu, gd;
2928 /* Will keep if the input is UTF-8 encoded (as in RADIUS messages).
2929 * If 1, input is *not* UTF-8 encoded (i.e. each input octet corresponds
2930 * to one byte to be dissected).
2931 * If 2, input is UTF-8 encoded (i.e. each *couple* of input octets
2932 * corresponds to one byte to be dissected)
2934 guint8 utf8_type = 1;
2936 /* In RADIUS messages the QoS has a version field of two octets prepended.
2937 * As of 29.061 v.3.a.0, there is an hyphen between "Release Indicator" and
2938 * <release specific QoS IE UTF-8 encoding>. Even if it sounds rather
2939 * inconsistent and unuseful, I will check hyphen presence here and
2940 * will signal its presence.
2944 /* Will keep the value that will be returned
2950 length = tvb_get_guint8 (tvb, offset);
2951 te = proto_tree_add_text (tree, tvb, offset, length + 1, "%s", qos_str);
2952 ext_tree_qos = proto_item_add_subtree (te, ett_gtp_qos);
2953 proto_tree_add_text (ext_tree_qos, tvb, offset, 1, "Length: %u", length);
2955 retval = length + 1;
2958 length = tvb_get_ntohs (tvb, offset + 1);
2959 te = proto_tree_add_text(tree, tvb, offset, length + 3, "%s", qos_str);
2960 ext_tree_qos = proto_item_add_subtree (te, ett_gtp_qos);
2961 proto_tree_add_text (ext_tree_qos, tvb, offset + 1, 2, "Length: %u", length);
2962 offset += 3; /* +1 because of first 0x86 byte for UMTS QoS */
2963 retval = length + 3;
2966 /* For QoS inside RADIUS Client messages from GGSN */
2969 /* The field in the RADIUS message is the length of the tvb we were given */
2970 length = tvb_length(tvb);
2971 te = proto_tree_add_text (tree, tvb, offset, length, "%s", qos_str);
2973 ext_tree_qos = proto_item_add_subtree (te, ett_gtp_qos);
2975 proto_tree_add_item (ext_tree_qos, hf_gtp_qos_version, tvb, offset, 2, FALSE);
2977 /* Hyphen handling */
2978 hyphen = tvb_get_guint8(tvb, offset + 2);
2979 if (hyphen == ((guint8) '-'))
2981 /* Hyphen is present, put in protocol tree */
2982 proto_tree_add_text (ext_tree_qos, tvb, offset + 2, 1, "Hyphen separator: -");
2983 offset++; /* "Get rid" of hyphen */
2986 /* Now, we modify offset here and in order to use type later
2993 retval = length + 2; /* Actually, will be ignored. */
2996 /* XXX - what should we do with the length here? */
2999 ext_tree_qos = NULL;
3003 /* In RADIUS messages there is no allocation-retention priority
3004 * so I don't need to wrap the following call to tvb_get_guint8
3006 al_ret_priority = tvb_get_guint8 (tvb, offset);
3008 /* All calls are wrapped to take into account the possibility that the
3009 * input is UTF-8 encoded. If utf8_type is equal to 1, the final value
3010 * of the offset will be the same as in the previous version of this
3011 * dissector, and the wrapped function will serve as a dumb wrapper;
3012 * otherwise, if utf_8_type is 2, the offset is correctly shifted by
3013 * two bytes for needed shift, and the wrapped function will unencode
3014 * two values from the input.
3016 spare1 = wrapped_tvb_get_guint8(tvb, offset+(1 - 1) * utf8_type + 1, utf8_type) & 0xC0;
3017 delay = wrapped_tvb_get_guint8(tvb, offset+(1 - 1) * utf8_type + 1, utf8_type) & 0x38;
3018 reliability = wrapped_tvb_get_guint8(tvb, offset+(1 - 1) * utf8_type + 1, utf8_type) & 0x07;
3019 peak = wrapped_tvb_get_guint8(tvb, offset+(2 - 1) * utf8_type + 1, utf8_type) & 0xF0;
3020 spare2 = wrapped_tvb_get_guint8(tvb, offset+(2 - 1) * utf8_type + 1, utf8_type) & 0x08;
3021 precedence = wrapped_tvb_get_guint8(tvb, offset+(2 - 1) * utf8_type + 1, utf8_type) & 0x07;
3022 spare3 = wrapped_tvb_get_guint8(tvb, offset+(3 - 1) * utf8_type + 1, utf8_type) & 0xE0;
3023 mean = wrapped_tvb_get_guint8(tvb, offset+(3 - 1) * utf8_type + 1, utf8_type) & 0x1F;
3025 /* In RADIUS messages there is no allocation-retention priority */
3027 proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_al_ret_priority, tvb, offset, 1, al_ret_priority);
3029 /* All additions must take care of the fact that QoS fields in RADIUS
3030 * messages are UTF-8 encoded, so we have to use the same trick as above.
3032 proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_spare1, tvb, offset+(1 - 1) * utf8_type + 1, utf8_type, spare1);
3033 proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_delay, tvb, offset+(1 - 1) * utf8_type + 1, utf8_type, delay);
3034 proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_reliability, tvb, offset+(1 - 1) * utf8_type + 1, utf8_type, reliability);
3035 proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_peak, tvb, offset+(2 - 1) * utf8_type + 1, utf8_type, peak);
3036 proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_spare2, tvb, offset+(2 - 1) * utf8_type + 1, utf8_type, spare2);
3037 proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_precedence, tvb, offset+(2 - 1) * utf8_type + 1, utf8_type, precedence);
3038 proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_spare3, tvb, offset+(3 - 1) * utf8_type + 1, utf8_type, spare3);
3039 proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_mean, tvb, offset+(3 - 1) * utf8_type + 1, utf8_type, mean);
3043 /* See above for the need of wrapping
3045 traf_class = wrapped_tvb_get_guint8(tvb, offset+(4 - 1) * utf8_type + 1, utf8_type) & 0xE0;
3046 del_order = wrapped_tvb_get_guint8(tvb, offset+(4 - 1) * utf8_type + 1, utf8_type) & 0x18;
3047 del_err_sdu = wrapped_tvb_get_guint8(tvb, offset+(4 - 1) * utf8_type + 1, utf8_type) & 0x07;
3048 max_sdu_size = wrapped_tvb_get_guint8(tvb, offset+(5 - 1) * utf8_type + 1, utf8_type);
3049 max_ul = wrapped_tvb_get_guint8(tvb, offset+(6 - 1) * utf8_type + 1, utf8_type);
3050 max_dl = wrapped_tvb_get_guint8(tvb, offset+(7 - 1) * utf8_type + 1, utf8_type);
3051 res_ber = wrapped_tvb_get_guint8(tvb, offset+(8 - 1) * utf8_type + 1, utf8_type) & 0xF0;
3052 sdu_err_ratio = wrapped_tvb_get_guint8(tvb, offset+(8 - 1) * utf8_type + 1, utf8_type) & 0x0F;
3053 trans_delay = wrapped_tvb_get_guint8(tvb, offset+(9 - 1) * utf8_type + 1, utf8_type) & 0xFC;
3054 traf_handl_prio = wrapped_tvb_get_guint8(tvb, offset+(9 - 1) * utf8_type + 1, utf8_type) & 0x03;
3055 guar_ul = wrapped_tvb_get_guint8(tvb, offset+(10 - 1) * utf8_type + 1, utf8_type);
3056 guar_dl = wrapped_tvb_get_guint8(tvb, offset+(11 - 1) * utf8_type + 1, utf8_type);
3058 /* See above comments for the changes
3060 proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_traf_class, tvb, offset+(4 - 1) * utf8_type + 1, utf8_type, traf_class);
3061 proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_del_order, tvb, offset+(4 - 1) * utf8_type + 1, utf8_type, del_order);
3062 proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_del_err_sdu, tvb, offset+(4 - 1) * utf8_type + 1, utf8_type, del_err_sdu);
3063 if (max_sdu_size == 0 || max_sdu_size > 150)
3064 proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_max_sdu_size, tvb, offset+(5 - 1) * utf8_type + 1, utf8_type, max_sdu_size);
3065 if (max_sdu_size > 0 && max_sdu_size <= 150) {
3066 mss = max_sdu_size*10;
3067 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_sdu_size, tvb, offset+(5 - 1) * utf8_type + 1, utf8_type, mss, "Maximum SDU size : %u octets", mss);
3070 if(max_ul == 0 || max_ul == 255)
3071 proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset+(6 - 1) * utf8_type + 1, utf8_type, max_ul);
3072 if(max_ul > 0 && max_ul <= 63)
3073 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset+(6 - 1) * utf8_type + 1, utf8_type, max_ul, "Maximum bit rate for uplink : %u kbps", max_ul);
3074 if(max_ul > 63 && max_ul <=127) {
3075 mu = 64 + ( max_ul - 64 ) * 8;
3076 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset+(6 - 1) * utf8_type + 1, utf8_type, mu, "Maximum bit rate for uplink : %u kbps", mu);
3079 if(max_ul > 127 && max_ul <=254) {
3080 mu = 576 + ( max_ul - 128 ) * 64;
3081 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset+(6 - 1) * utf8_type + 1, utf8_type, mu, "Maximum bit rate for uplink : %u kbps", mu);
3084 if(max_dl == 0 || max_dl == 255)
3085 proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_max_dl, tvb, offset+(7 - 1) * utf8_type + 1, utf8_type, max_dl);
3086 if(max_dl > 0 && max_dl <= 63)
3087 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_dl, tvb, offset+(7 - 1) * utf8_type + 1, utf8_type, max_dl, "Maximum bit rate for downlink : %u kbps", max_dl);
3088 if(max_dl > 63 && max_dl <=127) {
3089 md = 64 + ( max_dl - 64 ) * 8;
3090 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_dl, tvb, offset+(7 - 1) * utf8_type + 1, utf8_type, md, "Maximum bit rate for downlink : %u kbps", md);
3092 if(max_dl > 127 && max_dl <=254) {
3093 md = 576 + ( max_dl - 128 ) * 64;
3094 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_dl, tvb, offset+(7 - 1) * utf8_type + 1, utf8_type, md, "Maximum bit rate for downlink : %u kbps", md);
3097 proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_res_ber, tvb, offset+(8 - 1) * utf8_type + 1, utf8_type, res_ber);
3098 proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_sdu_err_ratio, tvb, offset+(8 - 1) * utf8_type + 1, utf8_type, sdu_err_ratio);
3099 proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_trans_delay, tvb, offset+(9 - 1) * utf8_type + 1, utf8_type, trans_delay);
3100 proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_traf_handl_prio, tvb, offset+(9 - 1) * utf8_type + 1, utf8_type, traf_handl_prio);
3102 if(guar_ul == 0 || guar_ul == 255)
3103 proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset+(10 - 1) * utf8_type + 1, utf8_type, guar_ul);
3104 if(guar_ul > 0 && guar_ul <= 63)
3105 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset+(10 - 1) * utf8_type + 1, utf8_type, guar_ul, "Guaranteed bit rate for uplink : %u kbps", guar_ul);
3106 if(guar_ul > 63 && guar_ul <=127) {
3107 gu = 64 + ( guar_ul - 64 ) * 8;
3108 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset+(10 - 1) * utf8_type + 1, utf8_type, gu, "Guaranteed bit rate for uplink : %u kbps", gu);
3110 if(guar_ul > 127 && guar_ul <=254) {
3111 gu = 576 + ( guar_ul - 128 ) * 64;
3112 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset+(10 - 1) * utf8_type + 1, utf8_type, gu, "Guaranteed bit rate for uplink : %u kbps", gu);
3115 if(guar_dl == 0 || guar_dl == 255)
3116 proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_guar_dl, tvb, offset+(11 - 1) * utf8_type + 1, utf8_type, guar_dl);
3117 if(guar_dl > 0 && guar_dl <= 63)
3118 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_guar_dl, tvb, offset+(11 - 1) * utf8_type + 1, utf8_type, guar_dl, "Guaranteed bit rate for downlink : %u kbps", guar_dl);
3119 if(guar_dl > 63 && guar_dl <=127) {
3120 gd = 64 + ( guar_dl - 64 ) * 8;
3121 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_guar_dl, tvb, offset+(11 - 1) * utf8_type + 1, utf8_type, gd, "Guaranteed bit rate for downlink : %u kbps", gd);
3123 if(guar_dl > 127 && guar_dl <=254) {
3124 gd = 576 + ( guar_dl - 128 ) * 64;
3125 proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_guar_dl, tvb, offset+(11 - 1) * utf8_type + 1, utf8_type, gd, "Guaranteed bit rate for downlink : %u kbps", gd);
3133 static const gchar* dissect_radius_qos_umts(proto_tree *tree, tvbuff_t *tvb) {
3134 decode_qos_umts(tvb, 0, tree, "UMTS GTP QoS Profile", 3);
3135 return tvb_get_ephemeral_string(tvb,0,tvb_length(tvb));
3139 decode_apn(tvbuff_t *tvb, int offset, guint16 length, proto_tree *tree) {
3145 name_len = tvb_get_guint8 (tvb, offset);
3147 if (name_len < 0x20) {
3148 apn = tvb_get_ephemeral_string(tvb, offset + 1, length - 1);
3150 if (name_len >= length - 1) break;
3152 name_len = name_len + apn[tmp] + 1;
3156 apn = tvb_get_ephemeral_string(tvb, offset, length);
3158 proto_tree_add_string (tree, hf_gtp_apn, tvb, offset, length, apn);
3162 /* GPRS: 9.60 v7.6.0, chapter 7.9.20
3163 * UMTS: 29.060 v4.0, chapter 7.7.29
3164 * TODO: unify addr functions
3167 decode_gtp_pdp_cntxt(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3169 guint8 ggsn_addr_len, apn_len, trans_id, vaa, order, nsapi, sapi, pdu_send_no, pdu_rec_no, pdp_cntxt_id,
3170 pdp_type_org, pdp_type_num, pdp_addr_len;
3171 guint16 length, sn_down, sn_up, up_flow;
3172 guint32 addr_ipv4, up_teid, up_teid_cp;
3173 struct e_in6_addr addr_ipv6;
3174 proto_tree *ext_tree_pdp;
3177 length = tvb_get_ntohs(tvb, offset+1);
3179 te = proto_tree_add_text(tree, tvb, offset, length+3, val_to_str(GTP_EXT_PDP_CNTXT, gtp_val, "Unknown message"));
3180 ext_tree_pdp = proto_item_add_subtree(te, ett_gtp_pdp);
3182 vaa = (tvb_get_guint8(tvb, offset+3) >> 6) & 0x01;
3183 order = (tvb_get_guint8(tvb, offset+3) >> 4) & 0x01;
3184 nsapi = tvb_get_guint8(tvb, offset+3) & 0x0F;
3185 sapi = tvb_get_guint8(tvb, offset+4) & 0x0F;
3187 proto_tree_add_text(ext_tree_pdp, tvb, offset+3, 1, "VPLMN address allowed: %s", yesno[vaa]);
3188 proto_tree_add_text(ext_tree_pdp, tvb, offset+3, 1, "Reordering required: %s", yesno[order]);
3189 proto_tree_add_text(ext_tree_pdp, tvb, offset+3, 1, "NSAPI: %u", nsapi);
3190 proto_tree_add_text(ext_tree_pdp, tvb, offset+4, 1, "SAPI: %u", sapi);
3192 switch (gtp_version) {
3194 decode_qos_gprs(tvb, offset+5, ext_tree_pdp, "QoS subscribed", 0);
3195 decode_qos_gprs(tvb, offset+8, ext_tree_pdp, "QoS requested", 0);
3196 decode_qos_gprs(tvb, offset+11, ext_tree_pdp, "QoS negotiated", 0);
3197 offset = offset + 14;
3200 offset = offset + 5;
3201 offset = offset + decode_qos_umts(tvb, offset, ext_tree_pdp, "QoS subscribed", 1);
3202 offset = offset + decode_qos_umts(tvb, offset, ext_tree_pdp, "QoS requested", 1);
3203 offset = offset + decode_qos_umts(tvb, offset, ext_tree_pdp, "QoS negotiated", 1);
3209 sn_down = tvb_get_ntohs(tvb, offset);
3210 sn_up = tvb_get_ntohs(tvb, offset+2);
3211 pdu_send_no = tvb_get_guint8(tvb, offset+4);
3212 pdu_rec_no = tvb_get_guint8(tvb, offset+5);
3214 proto_tree_add_text(ext_tree_pdp, tvb, offset, 2, "Sequence number down: %u", sn_down);
3215 proto_tree_add_text(ext_tree_pdp, tvb, offset+2, 2, "Sequence number up: %u", sn_up);
3216 proto_tree_add_text(ext_tree_pdp, tvb, offset+4, 1, "Send N-PDU number: %u", pdu_send_no);
3217 proto_tree_add_text(ext_tree_pdp, tvb, offset+5, 1, "Receive N-PDU number: %u", pdu_rec_no);
3219 switch (gtp_version) {
3221 up_flow = tvb_get_ntohs(tvb, offset+6);
3222 proto_tree_add_text(ext_tree_pdp, tvb, offset+6, 2, "Uplink flow label signalling: %u", up_flow);
3223 offset = offset + 8;
3226 up_teid = tvb_get_ntohl(tvb, offset+6);
3227 up_teid_cp = tvb_get_ntohl(tvb, offset+10);
3228 pdp_cntxt_id = tvb_get_guint8(tvb, offset+14);
3229 proto_tree_add_text(ext_tree_pdp, tvb, offset+6, 4, "Uplink TEID: %x", up_teid);
3230 proto_tree_add_text(ext_tree_pdp, tvb, offset+10, 4, "Uplink TEID control plane: %x", up_teid_cp);
3231 proto_tree_add_text(ext_tree_pdp, tvb, offset+14, 1, "PDP context identifier: %u", pdp_cntxt_id);
3232 offset = offset + 15;
3238 pdp_type_org = tvb_get_guint8(tvb, offset) & 0x0F;
3239 pdp_type_num = tvb_get_guint8(tvb, offset+1);
3240 pdp_addr_len = tvb_get_guint8(tvb, offset+2);
3242 proto_tree_add_text(ext_tree_pdp, tvb, offset, 1, "PDP organization: %s", val_to_str(pdp_type_org, pdp_type, "Unknown PDP org"));
3243 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"));
3244 proto_tree_add_text(ext_tree_pdp, tvb, offset+2, 1, "PDP address length: %u", pdp_addr_len);
3246 if (pdp_addr_len > 0) {
3247 switch (pdp_type_num) {
3249 addr_ipv4 = tvb_get_ipv4(tvb, offset+3);
3250 proto_tree_add_text(ext_tree_pdp, tvb, offset+3, 4, "PDP address: %s", ip_to_str((guint8 *)&addr_ipv4));
3253 tvb_get_ipv6(tvb, offset+3, &addr_ipv6);
3254 proto_tree_add_text(ext_tree_pdp, tvb, offset+3, 16, "PDP address: %s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
3261 offset = offset + 3 + pdp_addr_len;
3263 ggsn_addr_len = tvb_get_guint8(tvb, offset);
3264 proto_tree_add_text(ext_tree_pdp, tvb, offset, 1, "GGSN address length: %u", ggsn_addr_len);
3266 switch (ggsn_addr_len) {
3268 addr_ipv4 = tvb_get_ipv4(tvb, offset+1);
3269 proto_tree_add_text(ext_tree_pdp, tvb, offset+1, 4, "GGSN address: %s", ip_to_str((guint8 *)&addr_ipv4));
3272 tvb_get_ipv6(tvb, offset+1, &addr_ipv6);
3273 proto_tree_add_text(ext_tree_pdp, tvb, offset+1, 16, "GGSN address: %s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
3279 offset = offset + 1 + ggsn_addr_len;
3281 if (gtp_version == 1) {
3283 ggsn_addr_len = tvb_get_guint8(tvb, offset);
3284 proto_tree_add_text(ext_tree_pdp, tvb, offset, 1, "GGSN 2 address length: %u", ggsn_addr_len);
3286 switch (ggsn_addr_len) {
3288 addr_ipv4 = tvb_get_ipv4(tvb, offset+1);
3289 proto_tree_add_text(ext_tree_pdp, tvb, offset+1, 4, "GGSN 2 address: %s", ip_to_str((guint8 *)&addr_ipv4));
3292 tvb_get_ipv6(tvb, offset+1, &addr_ipv6);
3293 proto_tree_add_text(ext_tree_pdp, tvb, offset+1, 16, "GGSN 2 address: %s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
3298 offset = offset + 1 + ggsn_addr_len;
3302 apn_len = tvb_get_guint8(tvb, offset);
3303 proto_tree_add_text(ext_tree_pdp, tvb, offset, 1, "APN length: %u", apn_len);
3304 decode_apn(tvb, offset+1, apn_len, ext_tree_pdp);
3306 offset = offset + 1 + apn_len;
3308 trans_id = tvb_get_guint8(tvb, offset);
3309 proto_tree_add_text(ext_tree_pdp, tvb, offset, 1, "Transaction identifier: %u", trans_id);
3314 /* GPRS: 9.60, v7.6.0, chapter 7.9.21
3315 * UMTS: 29.060, v4.0, chapter 7.7.30
3318 decode_gtp_apn(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3321 proto_tree *ext_tree_apn;
3324 length = tvb_get_ntohs(tvb, offset+1);
3326 te = proto_tree_add_text (tree, tvb, offset, length+3, val_to_str(GTP_EXT_APN, gtp_val, "Unknown field"));
3327 ext_tree_apn = proto_item_add_subtree(te, ett_gtp_apn);
3329 proto_tree_add_text (ext_tree_apn, tvb, offset+1, 2, "APN length : %u", length);
3330 decode_apn (tvb, offset+3, length, ext_tree_apn);
3335 /* GPRS: 9.60 v7.6.0, chapter 7.9.22
3336 * 4.08 v. 7.1.2, chapter 10.5.6.3 (p.580)
3337 * UMTS: 29.060 v4.0, chapter 7.7.31
3338 * 24.008, v4.2, chapter 10.5.6.3
3341 decode_gtp_proto_conf(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree) {
3343 guint16 length, proto_offset;
3345 guint8 conf, proto_len, cnt = 1;
3347 proto_tree *ext_tree_proto;
3349 gboolean save_writable;
3351 length = tvb_get_ntohs(tvb, offset + 1);
3353 te = proto_tree_add_text(tree, tvb, offset, length + 3, val_to_str(GTP_EXT_PROTO_CONF, gtp_val, "Unknown message"));
3354 ext_tree_proto = proto_item_add_subtree(te, ett_gtp_proto);
3356 proto_tree_add_text(ext_tree_proto, tvb, offset + 1, 2, "Length: %u", length);
3358 if (length < 1) return 3;
3360 conf = tvb_get_guint8 (tvb, offset + 3) & 0x07;
3361 proto_tree_add_text (ext_tree_proto, tvb, offset + 3, 1, "Configuration protocol (00000xxx): %u", conf);
3363 proto_offset = 1; /* ... 1st byte is conf */
3367 if (proto_offset >= length) break;
3368 proto_id = tvb_get_ntohs (tvb, offset);
3369 proto_len = tvb_get_guint8 (tvb, offset + 2);
3370 proto_offset += proto_len + 3; /* 3 = proto id + length byte */
3372 if (proto_len > 0) {
3374 proto_tree_add_text (ext_tree_proto, tvb, offset, 2, "Protocol %u ID: %s (0x%04x)",
3375 cnt, val_to_str(proto_id, ppp_vals, "Unknown"),
3377 proto_tree_add_text (ext_tree_proto, tvb, offset+2, 1, "Protocol %u length: %u", cnt, proto_len);
3380 * Don't allow the dissector for the configuration
3381 * protocol in question to update the columns - this
3384 save_writable = col_get_writable(pinfo->cinfo);
3385 col_set_writable(pinfo->cinfo, FALSE);
3388 * XXX - should we have our own dissector table,
3389 * solely for configuration protocols, so that bogus
3390 * values don't cause us to dissect the protocol
3391 * data as, for example, IP?
3393 next_tvb = tvb_new_subset (tvb, offset + 3, proto_len, proto_len);
3394 if (!dissector_try_port(ppp_subdissector_table,
3395 proto_id, next_tvb, pinfo, ext_tree_proto)) {
3396 call_dissector(data_handle, next_tvb, pinfo,
3400 col_set_writable(pinfo->cinfo, save_writable);
3403 offset += proto_len + 3;
3410 /* GPRS: 9.60 v7.6.0, chapter 7.9.23
3411 * UMTS: 29.060 v4.0, chapter 7.7.32
3414 decode_gtp_gsn_addr(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3416 guint8 addr_type, addr_len;
3419 struct e_in6_addr addr_ipv6;
3420 proto_tree *ext_tree_gsn_addr;
3423 length = tvb_get_ntohs(tvb, offset+1);
3425 te = proto_tree_add_text(tree, tvb, offset, 3+length, "GSN address : ");
3426 ext_tree_gsn_addr = proto_item_add_subtree(te, ett_gtp_gsn_addr);
3430 proto_tree_add_text(ext_tree_gsn_addr, tvb, offset+1, 2, "GSN address length : %u", length);
3431 addr_ipv4 = tvb_get_ipv4(tvb, offset+3);
3432 proto_item_append_text(te, "%s", ip_to_str((guint8 *)&addr_ipv4));
3433 proto_tree_add_ipv4(ext_tree_gsn_addr, hf_gtp_gsn_ipv4, tvb, offset+3, 4, addr_ipv4);
3436 proto_tree_add_text(ext_tree_gsn_addr, tvb, offset+1, 2, "GSN address Information Element length : %u", length);
3437 addr_type = tvb_get_guint8(tvb, offset+3) & 0xC0;
3438 proto_tree_add_uint(ext_tree_gsn_addr, hf_gtp_gsn_addr_type, tvb, offset+3, 1, addr_type);
3439 addr_len = tvb_get_guint8(tvb, offset+3) & 0x3F;
3440 proto_tree_add_uint(ext_tree_gsn_addr, hf_gtp_gsn_addr_len, tvb, offset+3, 1, addr_len);
3441 addr_ipv4 = tvb_get_ipv4(tvb, offset+4);
3442 proto_item_append_text(te, "%s", ip_to_str((guint8 *)&addr_ipv4));
3443 proto_tree_add_ipv4(ext_tree_gsn_addr, hf_gtp_gsn_ipv4, tvb, offset+4, 4, addr_ipv4);
3446 proto_tree_add_text(ext_tree_gsn_addr, tvb, offset+1, 2, "GSN address length : %u", length);
3447 tvb_get_ipv6(tvb, offset+3, &addr_ipv6);
3448 proto_item_append_text(te, "%s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
3449 proto_tree_add_ipv6(ext_tree_gsn_addr, hf_gtp_gsn_ipv6, tvb, offset+3, 16, (guint8*)&addr_ipv6);
3452 proto_tree_add_text(ext_tree_gsn_addr, tvb, offset+1, 2, "GSN address Information Element length : %u", length);
3453 addr_type = tvb_get_guint8(tvb, offset+3) & 0xC0;
3454 proto_tree_add_uint(ext_tree_gsn_addr, hf_gtp_gsn_addr_type, tvb, offset+3, 1, addr_type);
3455 addr_len = tvb_get_guint8(tvb, offset+3) & 0x3F;
3456 proto_tree_add_uint(ext_tree_gsn_addr, hf_gtp_gsn_addr_len, tvb, offset+3, 1, addr_len);
3457 tvb_get_ipv6(tvb, offset+4, &addr_ipv6);
3458 proto_item_append_text(te, "%s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
3459 proto_tree_add_ipv6(ext_tree_gsn_addr, hf_gtp_gsn_ipv6, tvb, offset+4, 16, (guint8*)&addr_ipv6);
3462 proto_item_append_text(te, "unknown type or wrong length");
3469 /* GPRS: 9.60 v7.6.0, chapter 7.9.24
3470 * UMTS: 29.060 v4.0, chapter 7.7.33
3473 decode_gtp_msisdn(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3475 const guint8 *msisdn_val;
3479 length = tvb_get_ntohs(tvb, offset+1);
3481 if (length < 1) return 3;
3483 msisdn_val = tvb_get_ptr(tvb, offset+3, length);
3484 msisdn_str = msisdn_to_str(msisdn_val, length);
3486 proto_tree_add_string(tree, hf_gtp_msisdn, tvb, offset, 3+length, msisdn_str);
3491 /* GPRS: not present
3492 * UMTS: 29.060 v4.0, chapter 7.7.34
3493 * 24.008 v4.2, chapter 10.5.6.5
3496 decode_gtp_qos_umts(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3498 return decode_qos_umts(tvb, offset, tree, "Quality of Service", 2);
3501 /* GPRS: not present
3502 * UMTS: 29.060 v4.0, chapter 7.7.35
3505 decode_gtp_auth_qui(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3507 proto_tree *ext_tree_quint;
3508 proto_item *te_quint;
3509 guint16 q_offset, q_len;
3510 guint8 xres_len, auth_len;
3515 offset = offset + q_offset;
3517 q_len = tvb_get_ntohs(tvb, offset);
3519 te_quint = proto_tree_add_text(tree, tvb, offset+1, q_len, "Quintuplet");
3520 ext_tree_quint = proto_item_add_subtree(te_quint, ett_gtp_quint);
3522 proto_tree_add_text(ext_tree_quint, tvb, offset, 2, "Length: %x", q_len);
3523 q_offset = q_offset + 2;
3525 proto_tree_add_text(ext_tree_quint, tvb, offset + q_offset, 16, "RAND: %s", tvb_bytes_to_str(tvb, offset, 16));
3526 q_offset = q_offset + 16;
3527 xres_len = tvb_get_guint8(tvb, offset+q_offset);
3528 proto_tree_add_text(ext_tree_quint, tvb, offset + q_offset, 1, "XRES length: %u", xres_len);
3530 proto_tree_add_text(ext_tree_quint, tvb, offset + q_offset, xres_len, "XRES: %s", tvb_bytes_to_str(tvb, offset + q_offset, xres_len));
3531 q_offset = q_offset + xres_len;
3532 proto_tree_add_text(ext_tree_quint, tvb ,offset + q_offset, 16, "Quintuplet Ciphering Key: %s", tvb_bytes_to_str(tvb, offset + q_offset, 16));
3533 q_offset = q_offset + 16;
3534 proto_tree_add_text(ext_tree_quint, tvb, offset + q_offset, 16, "Quintuplet Integrity Key: %s", tvb_bytes_to_str(tvb, offset + q_offset, 16));
3535 q_offset = q_offset +16;
3536 auth_len = tvb_get_guint8(tvb, offset + q_offset);
3537 proto_tree_add_text(ext_tree_quint, tvb, offset + q_offset, 1, "Authentication length: %u", auth_len);
3539 proto_tree_add_text(ext_tree_quint, tvb, offset + q_offset, auth_len, "AUTH: %s", tvb_bytes_to_str(tvb, offset + q_offset, auth_len));
3541 q_offset = q_offset+auth_len;
3543 return (1 + q_offset);
3547 /* GPRS: not present
3548 * UMTS: 29.060 v4.0, chapter 7.7.36
3549 * 24.008 v4.2, chapter 10.5.6.12
3552 decode_gtp_tft(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3554 guint16 length, port1, port2, tos;
3555 guint8 tft_flags, tft_code, no_packet_filters, i, pf_id, pf_eval, pf_len, pf_content_id, proto, spare;
3557 guint32 mask_ipv4, addr_ipv4, ipsec_id, label;
3558 struct e_in6_addr addr_ipv6, mask_ipv6;
3559 proto_tree *ext_tree_tft, *ext_tree_tft_pf, *ext_tree_tft_flags;
3560 proto_item *te, *tee, *tef;
3562 length = tvb_get_ntohs(tvb, offset+1);
3564 te = proto_tree_add_text(tree, tvb, offset, 3+length, "Traffic flow template");
3565 ext_tree_tft = proto_item_add_subtree(te, ett_gtp_tft);
3567 tft_flags = tvb_get_guint8(tvb, offset+3);
3568 tft_code = (tft_flags >> 5) & 0x07;
3569 spare = (tft_flags >> 4) & 0x01;
3570 no_packet_filters = tft_flags & 0x0F;
3572 proto_tree_add_text(ext_tree_tft, tvb, offset+1, 2, "TFT length: %u", length);
3574 tef = proto_tree_add_text (ext_tree_tft, tvb, offset + 3, 1, "TFT flags");
3575 ext_tree_tft_flags = proto_item_add_subtree (tef, ett_gtp_tft_flags);
3576 proto_tree_add_uint (ext_tree_tft_flags, hf_gtp_tft_code, tvb, offset + 3, 1, tft_flags);
3577 proto_tree_add_uint (ext_tree_tft_flags, hf_gtp_tft_spare, tvb, offset + 3, 1, tft_flags);
3578 proto_tree_add_uint (ext_tree_tft_flags, hf_gtp_tft_number, tvb, offset + 3, 1, tft_flags);
3580 offset = offset + 4;
3582 for (i=0;i<no_packet_filters;i++) {
3584 pf_id = tvb_get_guint8(tvb, offset);
3586 tee = proto_tree_add_text (ext_tree_tft, tvb, offset, 1, "Packet filter id: %u", pf_id);
3587 ext_tree_tft_pf = proto_item_add_subtree (tee, ett_gtp_tft_pf);
3590 if (tft_code != 2) {
3592 pf_eval = tvb_get_guint8(tvb, offset);
3593 pf_len = tvb_get_guint8(tvb, offset + 1);
3595 proto_tree_add_uint (ext_tree_tft_pf, hf_gtp_tft_eval, tvb, offset, 1, pf_eval);
3596 proto_tree_add_text (ext_tree_tft_pf, tvb, offset+1, 1, "Content length: %u", pf_len);
3598 offset = offset + 2;
3601 while (pf_offset < pf_len) {
3603 pf_content_id = tvb_get_guint8 (tvb, offset + pf_offset);
3605 switch (pf_content_id) {
3606 /* address IPv4 and mask = 8 bytes*/
3608 addr_ipv4 = tvb_get_ipv4 (tvb, offset + pf_offset + 1);
3609 mask_ipv4 = tvb_get_ipv4 (tvb, offset + pf_offset + 5);
3610 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));
3611 pf_offset = pf_offset + 9;
3613 /* address IPv6 and mask = 32 bytes*/
3615 tvb_get_ipv6 (tvb, offset+pf_offset+1, &addr_ipv6);
3616 tvb_get_ipv6 (tvb, offset+pf_offset+17, &mask_ipv6);
3617 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));
3618 pf_offset = pf_offset + 33;
3620 /* protocol identifier/next header type = 1 byte*/
3622 proto = tvb_get_guint8 (tvb, offset + pf_offset + 1);
3623 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);
3624 pf_offset = pf_offset + 2;
3626 /* single destination port type = 2 bytes */
3628 port1 = tvb_get_ntohs (tvb, offset + pf_offset + 1);
3629 proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 3, "ID 0x40: destination port: %u", port1);
3630 pf_offset = pf_offset + 3;
3632 /* destination port range type = 4 bytes */
3634 port1 = tvb_get_ntohs (tvb, offset + pf_offset + 1);
3635 port2 = tvb_get_ntohs (tvb, offset + pf_offset + 3);
3636 proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 5, "ID 0x41: destination port range: %u - %u", port1, port2);
3637 pf_offset = pf_offset + 5;
3639 /* single source port type = 2 bytes */
3641 port1 = tvb_get_ntohs (tvb, offset + pf_offset + 1);
3642 proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 3, "ID 0x50: source port: %u", port1);
3643 pf_offset = pf_offset + 3;
3645 /* source port range type = 4 bytes */
3647 port1 = tvb_get_ntohs (tvb, offset + pf_offset + 1);
3648 port2 = tvb_get_ntohs (tvb, offset + pf_offset + 3);
3649 proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 5, "ID 0x51: source port range: %u - %u", port1, port2);
3650 pf_offset = pf_offset + 5;
3652 /* security parameter index type = 4 bytes */
3654 ipsec_id = tvb_get_ntohl (tvb, offset + pf_offset + 1);
3655 proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 5, "ID 0x60: security parameter index: %x", ipsec_id);
3656 pf_offset = pf_offset + 5;
3658 /* type of service/traffic class type = 2 bytes */
3660 tos = tvb_get_ntohs (tvb, offset + pf_offset + 1);
3661 proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 2, "ID 0x70: Type of Service/Traffic Class: %u (%x)", tos, tos);
3662 pf_offset = pf_offset + 3;
3664 /* flow label type = 3 bytes */
3666 label = tvb_get_ntoh24(tvb, offset + pf_offset + 1) & 0x0FFFFF;
3667 proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 4, "ID 0x80: Flow Label: %u (%x)", label, label);
3668 pf_offset = pf_offset + 4;
3672 proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 1, "Unknown value: %x ", pf_content_id);
3673 pf_offset++; /* to avoid infinite loop */
3678 offset = offset + pf_offset;
3685 /* GPRS: not present
3686 * UMTS: 29.060 v4.0, chapter 7.7.37
3687 * 25.413 v3.4, chapter ???
3690 decode_gtp_target_id(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3694 length = tvb_get_ntohs(tvb, offset + 1);
3696 proto_tree_add_text(tree, tvb, offset, 3 + length, "Targer Identification");
3702 /* GPRS: not present
3703 * UMTS: 29.060 v4.0, chapter 7.7.38
3706 decode_gtp_utran_cont(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3710 length = tvb_get_ntohs(tvb, offset + 1);
3712 proto_tree_add_text(tree, tvb, offset, 3 + length, "UTRAN transparent field");
3719 /* GPRS: not present
3720 * UMTS: 29.060 v4.0, chapter 7.7.39
3723 decode_gtp_rab_setup(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3725 guint32 teid, addr_ipv4;
3728 struct e_in6_addr addr_ipv6;
3729 proto_tree *ext_tree_rab_setup;
3732 length = tvb_get_ntohs(tvb, offset + 1);
3733 nsapi = tvb_get_guint8(tvb, offset + 3) & 0x0F;
3735 te = proto_tree_add_text(tree, tvb, offset, 3+length, "Radio Access Bearer Setup Information");
3736 ext_tree_rab_setup = proto_item_add_subtree(te, ett_gtp_rab_setup);
3738 proto_tree_add_text(ext_tree_rab_setup, tvb, offset+1, 2, "RAB setup length : %u", length);
3739 proto_tree_add_uint(ext_tree_rab_setup, hf_gtp_nsapi, tvb, offset+3, 1, nsapi);
3743 teid = tvb_get_ntohl(tvb, offset + 4);
3745 proto_tree_add_uint(ext_tree_rab_setup, hf_gtp_teid_data, tvb, offset+4, 4, teid);
3749 addr_ipv4 = tvb_get_ipv4(tvb, offset+8);
3750 proto_tree_add_ipv4(ext_tree_rab_setup, hf_gtp_rnc_ipv4, tvb, offset+8, 4, addr_ipv4);
3753 tvb_get_ipv6(tvb, offset+8, &addr_ipv6);
3754 proto_tree_add_ipv6(ext_tree_rab_setup, hf_gtp_rnc_ipv6, tvb, offset+8, 16, (guint8 *)&addr_ipv6);
3765 /* GPRS: not present
3766 * UMTS: 29.060 v4.0, chapter 7.7.40
3769 decode_gtp_hdr_list(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3773 proto_tree *ext_tree_hdr_list;
3776 length = tvb_get_guint8(tvb, offset + 1);
3778 te = proto_tree_add_text(tree, tvb, offset, 2+length, "%s", val_to_str(GTP_EXT_HDR_LIST, gtp_val, "Unknown"));
3779 ext_tree_hdr_list = proto_item_add_subtree(te, ett_gtp_hdr_list);
3781 proto_tree_add_text(ext_tree_hdr_list, tvb, offset+1, 1, "Number of Extension Header Types in list (i.e., length) : %u", length);
3783 for(i=0 ; i<length ; i++) {
3784 hdr = tvb_get_guint8(tvb, offset+2+i);
3786 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);
3792 /* GPRS: not present
3793 * UMTS: 29.060 v4.0, chapter 7.7.41
3794 * TODO: find TriggerID description
3797 decode_gtp_trigger_id(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3801 length = tvb_get_ntohs(tvb, offset + 1);
3803 proto_tree_add_text(tree, tvb, offset, 3+length, "%s length : %u", val_to_str(GTP_EXT_TRIGGER_ID, gtp_val, "Unknown"), length);
3809 /* GPRS: not present
3810 * UMTS: 29.060 v4.0, chapter 7.7.42
3811 * TODO: find OMC-ID description
3814 decode_gtp_omc_id(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3818 length = tvb_get_ntohs(tvb, offset + 1);
3820 proto_tree_add_text(tree, tvb, offset, 3+length, "%s length : %u", val_to_str(GTP_EXT_OMC_ID, gtp_val, "Unknown"), length);
3826 /* GPRS: 9.60 v7.6.0, chapter 7.9.25
3827 * UMTS: 29.060 v4.0, chapter 7.7.43
3830 decode_gtp_chrg_addr(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3834 struct e_in6_addr addr_ipv6;
3835 proto_tree *ext_tree_chrg_addr;
3838 length = tvb_get_ntohs(tvb, offset+1);
3840 te = proto_tree_add_text(tree, tvb, offset, 3+length, "%s : ", val_to_str(GTP_EXT_CHRG_ADDR, gtp_val, "Unknown"));
3841 ext_tree_chrg_addr = proto_item_add_subtree(te, ett_gtp_chrg_addr);
3843 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);
3847 addr_ipv4 = tvb_get_ipv4(tvb, offset+3);
3848 proto_item_append_text(te, "%s", ip_to_str((guint8 *)&addr_ipv4));
3849 proto_tree_add_ipv4 (ext_tree_chrg_addr, hf_gtp_chrg_ipv4, tvb, offset+3, 4, addr_ipv4);
3852 tvb_get_ipv6(tvb, offset+3, &addr_ipv6);
3853 proto_item_append_text(te, "%s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
3854 proto_tree_add_ipv6 (ext_tree_chrg_addr, hf_gtp_chrg_ipv6, tvb, offset+3, 16, (guint8*)&addr_ipv6);
3857 proto_item_append_text(te, "unknown type or wrong length");
3868 decode_gtp_rel_pack(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3870 guint16 length, n, number;
3871 proto_tree *ext_tree_rel_pack;
3874 length = tvb_get_ntohs(tvb, offset + 1);
3876 te = proto_tree_add_text(tree, tvb, offset, 3 + length, "Sequence numbers of released packets IE");
3877 ext_tree_rel_pack = proto_item_add_subtree(te, ett_gtp_rel_pack);
3881 while (n < length) {
3883 number = tvb_get_ntohs(tvb, offset + 3 + n);
3884 proto_tree_add_text(ext_tree_rel_pack, tvb, offset + 3 + n, 2, "%u", number);
3896 decode_gtp_can_pack(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3898 guint16 length, n, number;
3899 proto_tree *ext_tree_can_pack;
3902 length = tvb_get_ntohs(tvb, offset + 1);
3904 te = proto_tree_add_text(tree, tvb, offset, 3 + length, "Sequence numbers of cancelled packets IE");
3905 ext_tree_can_pack = proto_item_add_subtree(te, ett_gtp_can_pack);
3909 while (n < length) {
3911 number = tvb_get_ntohs(tvb, offset + 3 + n);
3912 proto_tree_add_text(ext_tree_can_pack, tvb, offset + 3 + n, 2, "%u", number);
3919 /* CDRs dissector */
3921 decode_gtp_data_req(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3923 guint16 length, format_ver;
3925 proto_tree *ext_tree;
3929 te = proto_tree_add_text(tree, tvb, offset, 1, val_to_str(GTP_EXT_DATA_REQ, gtp_val, "Unknown message"));
3930 ext_tree = proto_item_add_subtree(te, ett_gtp_ext);
3932 length = tvb_get_ntohs(tvb, offset + 1);
3933 no = tvb_get_guint8(tvb, offset + 3);
3934 format = tvb_get_guint8(tvb, offset + 4);
3935 format_ver = tvb_get_ntohs(tvb, offset + 5);
3937 proto_tree_add_text(ext_tree, tvb, offset+1, 2, "Length: %u", length);
3938 proto_tree_add_text(ext_tree, tvb, offset+3, 1, "Number of data records: %u", no);
3939 proto_tree_add_text(ext_tree, tvb, offset+4, 1, "Data record format: %u", format);
3940 proto_tree_add_text(ext_tree, tvb, offset+5, 2, "Data record format version: %u", format_ver);
3942 if (gtpcdr_handle) {
3943 next_tvb = tvb_new_subset (tvb, offset, -1, -1);
3944 call_dissector (gtpcdr_handle, next_tvb, pinfo, tree);
3947 proto_tree_add_text (tree, tvb, offset, 0, "Data");
3956 decode_gtp_data_resp(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3958 guint16 length, n, number;
3959 proto_tree *ext_tree_data_resp;
3962 length = tvb_get_ntohs(tvb, offset + 1);
3964 te = proto_tree_add_text(tree, tvb, offset, 3 + length, "Requests responded");
3965 ext_tree_data_resp = proto_item_add_subtree(te, ett_gtp_data_resp);
3969 while (n < length) {
3971 number = tvb_get_ntohs(tvb, offset + 3 + n);
3972 proto_tree_add_text(ext_tree_data_resp, tvb, offset + 3 + n, 2, "%u", number);
3985 decode_gtp_node_addr(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
3989 struct e_in6_addr addr_ipv6;
3990 proto_tree *ext_tree_node_addr;
3993 length = tvb_get_ntohs(tvb, offset+1);
3995 te = proto_tree_add_text(tree, tvb, offset, 3+length, "Node address: ");
3996 ext_tree_node_addr = proto_item_add_subtree(te, ett_gtp_node_addr);
3998 proto_tree_add_text (ext_tree_node_addr, tvb, offset+1, 2, "Node address length: %u", length);
4002 addr_ipv4 = tvb_get_ipv4(tvb, offset+3);
4003 proto_item_append_text(te, "%s", ip_to_str((guint8 *)&addr_ipv4));
4004 proto_tree_add_ipv4 (ext_tree_node_addr, hf_gtp_node_ipv4, tvb, offset+3, 4, addr_ipv4);
4007 tvb_get_ipv6(tvb, offset+3, &addr_ipv6);
4008 proto_item_append_text(te, "%s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
4009 proto_tree_add_ipv6 (ext_tree_node_addr, hf_gtp_node_ipv6, tvb, offset+3, 16, (guint8*)&addr_ipv6);
4012 proto_item_append_text(te, "unknown type or wrong length");
4020 /* GPRS: 9.60 v7.6.0, chapter 7.9.26
4021 * UMTS: 29.060 v4.0, chapter 7.7.44
4024 decode_gtp_priv_ext(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
4026 guint16 length, ext_id;
4027 proto_tree *ext_tree_priv_ext;
4030 te = proto_tree_add_text(tree, tvb, offset, 1, val_to_str(GTP_EXT_PRIV_EXT, gtp_val, "Unknown message"));
4031 ext_tree_priv_ext = proto_item_add_subtree(te, ett_gtp_ext);
4033 length = tvb_get_ntohs(tvb, offset+1);
4035 ext_id = tvb_get_ntohs(tvb, offset+3);
4036 proto_tree_add_uint(ext_tree_priv_ext, hf_gtp_ext_id, tvb, offset+3, 2, ext_id);
4039 * XXX - is this always a text string? Or should it be
4040 * displayed as hex data?
4043 proto_tree_add_item(ext_tree_priv_ext, hf_gtp_ext_val, tvb, offset+5, length-2, FALSE);
4050 decode_gtp_unknown(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
4052 proto_tree_add_text(tree, tvb, offset, 1, "Unknown extension header");
4054 return tvb_length_remaining(tvb, offset);
4058 dissect_gtp (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
4060 struct _gtp_hdr gtp_hdr;
4061 proto_tree *gtp_tree, *flags_tree;
4062 proto_item *ti, *tf;
4063 int i, offset, length, gtp_prime, checked_field, mandatory;
4064 int seq_no, flow_label;
4065 guint8 pdu_no, next_hdr = 0, ext_hdr_val;
4066 const guint8 *tid_val;
4070 guint8 sub_proto, acfield_len = 0, control_field;
4072 if (check_col(pinfo->cinfo, COL_PROTOCOL))
4073 col_set_str(pinfo->cinfo, COL_PROTOCOL, "GTP");
4074 if (check_col(pinfo->cinfo, COL_INFO))
4075 col_clear(pinfo->cinfo, COL_INFO);
4077 tvb_memcpy(tvb, (guint8 *)>p_hdr, 0, 4);
4079 if (!(gtp_hdr.flags & 0x10))
4084 switch ((gtp_hdr.flags >> 5) & 0x07) {
4096 if (check_col(pinfo->cinfo, COL_INFO))
4097 col_add_str(pinfo->cinfo, COL_INFO, val_to_str(gtp_hdr.message, message_type, "Unknown"));
4100 ti = proto_tree_add_item (tree, proto_gtp, tvb, 0, -1, FALSE);
4101 gtp_tree = proto_item_add_subtree(ti, ett_gtp);
4103 tf = proto_tree_add_uint (gtp_tree, hf_gtp_flags, tvb, 0, 1, gtp_hdr.flags);
4104 flags_tree = proto_item_add_subtree (tf, ett_gtp_flags);
4106 proto_tree_add_uint (flags_tree, hf_gtp_flags_ver, tvb, 0, 1, gtp_hdr.flags);
4107 proto_tree_add_uint (flags_tree, hf_gtp_flags_pt, tvb, 0, 1, gtp_hdr.flags);
4109 switch (gtp_version) {
4111 proto_tree_add_uint (flags_tree, hf_gtp_flags_spare1, tvb, 0, 1, gtp_hdr.flags);
4112 proto_tree_add_boolean (flags_tree, hf_gtp_flags_snn, tvb, 0, 1, gtp_hdr.flags);
4115 proto_tree_add_uint (flags_tree, hf_gtp_flags_spare2, tvb, 0, 1, gtp_hdr.flags);
4116 proto_tree_add_boolean (flags_tree, hf_gtp_flags_e, tvb, 0, 1, gtp_hdr.flags);
4117 proto_tree_add_boolean (flags_tree, hf_gtp_flags_s, tvb, 0, 1, gtp_hdr.flags);
4118 proto_tree_add_boolean (flags_tree, hf_gtp_flags_pn, tvb, 0, 1, gtp_hdr.flags);
4124 proto_tree_add_uint (gtp_tree, hf_gtp_message_type, tvb, 1, 1, gtp_hdr.message);
4126 gtp_hdr.length = g_ntohs (gtp_hdr.length);
4127 proto_tree_add_uint (gtp_tree, hf_gtp_length, tvb, 2, 2, gtp_hdr.length);
4132 seq_no = tvb_get_ntohs (tvb, offset);
4133 proto_tree_add_uint (gtp_tree, hf_gtp_seq_number, tvb, offset, 2, seq_no);
4136 switch (gtp_version) {
4138 seq_no = tvb_get_ntohs (tvb, offset);
4139 proto_tree_add_uint (gtp_tree, hf_gtp_seq_number, tvb, offset, 2, seq_no);
4142 flow_label = tvb_get_ntohs (tvb, offset);
4143 proto_tree_add_uint (gtp_tree, hf_gtp_flow_label, tvb, offset, 2, flow_label);
4146 pdu_no = tvb_get_guint8 (tvb, offset);
4147 proto_tree_add_uint (gtp_tree, hf_gtp_sndcp_number, tvb, offset, 1, pdu_no);
4150 tid_val = tvb_get_ptr(tvb, offset, 8);
4151 tid_str = id_to_str (tid_val);
4152 proto_tree_add_string (gtp_tree, hf_gtp_tid, tvb, offset, 8, tid_str);
4156 teid = tvb_get_ntohl (tvb, offset);
4157 proto_tree_add_uint (gtp_tree, hf_gtp_teid, tvb, offset, 4, teid);
4160 if (gtp_hdr.flags & 0x07) {
4161 seq_no = tvb_get_ntohs (tvb, offset);
4162 proto_tree_add_uint (gtp_tree, hf_gtp_seq_number, tvb, offset, 2, seq_no);
4165 pdu_no = tvb_get_guint8 (tvb, offset);
4166 proto_tree_add_uint (gtp_tree, hf_gtp_npdu_number, tvb, offset, 1, pdu_no);
4169 next_hdr = tvb_get_guint8 (tvb, offset);
4170 proto_tree_add_uint (gtp_tree, hf_gtp_next, tvb, offset, 1, next_hdr);
4180 if (gtp_hdr.message != GTP_MSG_TPDU) {
4181 proto_tree_add_text(gtp_tree, tvb, 0, 0, "[--- end of GTP header, beginning of extension headers ---]");
4182 length = tvb_length (tvb);
4183 mandatory = 0; /* check order of GTP fields against ETSI */
4185 if (offset >= length)
4188 ext_hdr_val = next_hdr;
4192 ext_hdr_val = tvb_get_guint8 (tvb, offset);
4193 if (gtp_etsi_order) {
4194 checked_field = check_field_presence (gtp_hdr.message, ext_hdr_val , (int *)&mandatory);
4195 switch (checked_field) {
4196 case -2: proto_tree_add_text (gtp_tree, tvb, 0, 0, "[WARNING] message not found");
4198 case -1: proto_tree_add_text (gtp_tree, tvb, 0, 0, "[WARNING] field not present");
4201 default: proto_tree_add_text (gtp_tree, tvb, offset, 1, "[WARNING] wrong next field, should be: %s", val_to_str(checked_field, gtp_val, "Unknown extension field"));
4207 while (gtpopt[++i].optcode)
4208 if (gtpopt[i].optcode == ext_hdr_val)
4210 offset = offset + (*gtpopt[i].decode)(tvb, offset, pinfo, gtp_tree);
4215 if ((gtp_hdr.message == GTP_MSG_TPDU) && gtp_tpdu) {
4220 if (gtp_version == 1) {
4221 if (gtp_hdr.flags & 0x07) {
4223 if (tvb_get_guint8 (tvb, offset) == 0)
4232 sub_proto = tvb_get_guint8 (tvb, offset);
4234 if ((sub_proto >= 0x45) && (sub_proto <= 0x4e)) {
4235 /* this is most likely an IPv4 packet
4236 * we can exclude 0x40 - 0x44 because the minimum header size is 20 octets
4237 * 0x4f is excluded because PPP protocol type "IPv6 header compression"
4238 * with protocol field compression is more likely than a plain IPv4 packet with 60 octet header size */
4240 next_tvb = tvb_new_subset (tvb, offset, -1, -1);
4241 call_dissector(ip_handle, next_tvb, pinfo, tree);
4244 if ((sub_proto & 0xf0) == 0x60){
4245 /* this is most likely an IPv6 packet */
4246 next_tvb = tvb_new_subset (tvb, offset, -1, -1);
4247 call_dissector (ipv6_handle, next_tvb, pinfo, tree);
4249 /* this seems to be a PPP packet */
4251 if (sub_proto == 0xff) {
4252 /* this might be an address field, even it shouldn't be here */
4253 control_field = tvb_get_guint8 (tvb, offset + 1);
4254 if (control_field == 0x03)
4255 /* now we are pretty sure that address and control field are mistakenly inserted -> ignore it for PPP dissection */
4259 next_tvb = tvb_new_subset (tvb, offset + acfield_len, -1, -1);
4260 call_dissector (ppp_handle, next_tvb, pinfo, tree);
4263 if (check_col(pinfo->cinfo, COL_PROTOCOL))
4264 col_append_str_gtp(pinfo->cinfo, COL_PROTOCOL, "GTP");
4268 static const true_false_string yes_no_tfs = {
4274 proto_register_gtp(void)
4276 static hf_register_info hf_gtp[] = {
4277 { &hf_gtp_apn, { "APN", "gtp.apn", FT_STRING, BASE_DEC, NULL, 0, "Access Point Name", HFILL }},
4278 { &hf_gtp_cause, { "Cause ", "gtp.cause", FT_UINT8, BASE_DEC, VALS(cause_type), 0, "Cause of operation", HFILL }},
4279 { &hf_gtp_chrg_char, { "Charging characteristics", "gtp.chrg_char", FT_UINT16, BASE_DEC, NULL, 0, "Charging characteristics", HFILL }},
4280 { &hf_gtp_chrg_char_s, { "Spare", "gtp.chrg_char_s", FT_UINT16, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_S, "Spare", HFILL }},
4281 { &hf_gtp_chrg_char_n, { "Normal charging", "gtp.chrg_char_n", FT_UINT16, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_N, "Normal charging", HFILL }},
4282 { &hf_gtp_chrg_char_p, { "Prepaid charging", "gtp.chrg_char_p", FT_UINT16, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_P, "Prepaid charging", HFILL }},
4283 { &hf_gtp_chrg_char_f, { "Flat rate charging", "gtp.chrg_char_f", FT_UINT16, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_F, "Flat rate charging", HFILL }},
4284 { &hf_gtp_chrg_char_h, { "Hot billing charging", "gtp.chrg_char_h", FT_UINT16, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_H, "Hot billing charging", HFILL }},
4285 { &hf_gtp_chrg_char_r, { "Reserved", "gtp.chrg_char_r", FT_UINT16, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_R, "Reserved", HFILL }},
4286 { &hf_gtp_chrg_id, { "Charging ID", "gtp.chrg_id", FT_UINT32, BASE_HEX, NULL, 0, "Charging ID", HFILL }},
4287 { &hf_gtp_chrg_ipv4, { "CG address IPv4", "gtp.chrg_ipv4", FT_IPv4, BASE_DEC, NULL, 0, "Charging Gateway address IPv4", HFILL }},
4288 { &hf_gtp_chrg_ipv6, { "CG address IPv6", "gtp.chrg_ipv6", FT_IPv6, BASE_HEX, NULL, 0, "Charging Gateway address IPv6", HFILL }},
4289 { &hf_gtp_ext_flow_label, { "Flow Label Data I", "gtp.ext_flow_label", FT_UINT16, BASE_HEX, NULL, 0, "Flow label data", HFILL }},
4290 { &hf_gtp_ext_id, { "Extension identifier", "gtp.ext_id", FT_UINT16, BASE_DEC, NULL, 0, "Extension Identifier", HFILL }},
4291 { &hf_gtp_ext_val, { "Extension value", "gtp.ext_val", FT_STRING, BASE_DEC, NULL, 0, "Extension Value", HFILL }},
4292 { &hf_gtp_flags, { "Flags", "gtp.flags", FT_UINT8, BASE_HEX, NULL, 0, "Ver/PT/Spare...", HFILL }},
4293 { &hf_gtp_flags_ver,
4294 { "Version", "gtp.flags.version",
4295 FT_UINT8, BASE_DEC, VALS(ver_types), GTP_VER_MASK,
4296 "GTP Version", HFILL }
4299 { "Protocol type", "gtp.flags.payload",
4300 FT_UINT8, BASE_DEC, VALS(pt_types), GTP_PT_MASK,
4301 "Protocol Type", HFILL }
4303 { &hf_gtp_flags_spare1,
4304 { "Reserved", "gtp.flags.reserved",
4305 FT_UINT8, BASE_DEC, NULL, GTP_SPARE1_MASK,
4306 "Reserved (shall be sent as '111' )", HFILL }
4308 { &hf_gtp_flags_snn, { "Is SNDCP N-PDU included?", "gtp.flags.snn", FT_BOOLEAN, 8, TFS(&yes_no_tfs), GTP_SNN_MASK, "Is SNDCP N-PDU LLC Number included? (1 = yes, 0 = no)", HFILL }},
4309 { &hf_gtp_flags_spare2, { "Reserved", "gtp.flags.reserved", FT_UINT8, BASE_DEC, NULL, GTP_SPARE2_MASK, "Reserved (shall be sent as '1' )", HFILL }},
4310 { &hf_gtp_flags_e, { "Is Next Extension Header present?", "gtp.flags.e", FT_BOOLEAN, 8, TFS(&yes_no_tfs), GTP_E_MASK, "Is Next Extension Header present? (1 = yes, 0 = no)", HFILL }},
4311 { &hf_gtp_flags_s, { "Is Sequence Number present?", "gtp.flags.s", FT_BOOLEAN, 8, TFS(&yes_no_tfs), GTP_S_MASK, "Is Sequence Number present? (1 = yes, 0 = no)", HFILL }},
4312 { &hf_gtp_flags_pn, { "Is N-PDU number present?", "gtp.flags.pn", FT_BOOLEAN, 8, TFS(&yes_no_tfs), GTP_PN_MASK, "Is N-PDU number present? (1 = yes, 0 = no)", HFILL }},
4313 { &hf_gtp_flow_ii, { "Flow Label Data II ", "gtp.flow_ii", FT_UINT16, BASE_DEC, NULL, 0, "Downlink flow label data", HFILL }},
4314 { &hf_gtp_flow_label, { "Flow label", "gtp.flow_label", FT_UINT16, BASE_HEX, NULL, 0, "Flow label", HFILL }},
4315 { &hf_gtp_flow_sig, { "Flow label Signalling", "gtp.flow_sig", FT_UINT16, BASE_HEX, NULL, 0, "Flow label signalling", HFILL }},
4316 { &hf_gtp_gsn_addr_len, { "GSN Address Length", "gtp.gsn_addr_len", FT_UINT8, BASE_DEC, NULL, GTP_EXT_GSN_ADDR_LEN_MASK, "GSN Address Length", HFILL }},
4317 { &hf_gtp_gsn_addr_type, { "GSN Address Type", "gtp.gsn_addr_type", FT_UINT8, BASE_DEC, VALS(gsn_addr_type), GTP_EXT_GSN_ADDR_TYPE_MASK, "GSN Address Type", HFILL }},
4318 { &hf_gtp_gsn_ipv4, { "GSN address IPv4", "gtp.gsn_ipv4", FT_IPv4, BASE_DEC, NULL, 0, "GSN address IPv4", HFILL }},
4319 { &hf_gtp_gsn_ipv6, { "GSN address IPv6", "gtp.gsn_ipv6", FT_IPv6, BASE_DEC, NULL, 0, "GSN address IPv6", HFILL }},
4320 { &hf_gtp_imsi, { "IMSI", "gtp.imsi", FT_STRING, BASE_DEC, NULL, 0, "International Mobile Subscriber Identity number", HFILL }},
4321 { &hf_gtp_length, { "Length", "gtp.length", FT_UINT16, BASE_DEC, NULL, 0, "Length (i.e. number of octets after TID or TEID)", HFILL }},
4322 { &hf_gtp_map_cause, { "MAP cause", "gtp.map_cause", FT_UINT8, BASE_DEC, VALS(map_cause_type), 0, "MAP cause", HFILL }},
4323 { &hf_gtp_message_type, { "Message Type", "gtp.message", FT_UINT8, BASE_HEX, VALS(message_type), 0x0, "GTP Message Type", HFILL }},
4324 { &hf_gtp_ms_reason, { "MS not reachable reason", "gtp.ms_reason", FT_UINT8, BASE_DEC, VALS(ms_not_reachable_type), 0, "MS Not Reachable Reason", HFILL }},
4325 { &hf_gtp_ms_valid, { "MS validated", "gtp.ms_valid", FT_BOOLEAN, BASE_NONE,NULL, 0, "MS validated", HFILL }},
4326 { &hf_gtp_msisdn, { "MSISDN", "gtp.msisdn", FT_STRING, BASE_DEC, NULL, 0, "MS international PSTN/ISDN number", HFILL }},
4327 { &hf_gtp_next, { "Next extension header type", "gtp.next", FT_UINT8, BASE_HEX, NULL, 0, "Next Extension Header Type", HFILL }},
4328 { &hf_gtp_node_ipv4, { "Node address IPv4", "gtp.node_ipv4", FT_IPv4, BASE_DEC, NULL, 0, "Recommended node address IPv4", HFILL }},
4329 { &hf_gtp_node_ipv6, { "Node address IPv6", "gtp.node_ipv6", FT_IPv6, BASE_HEX, NULL, 0, "Recommended node address IPv6", HFILL }},
4330 { &hf_gtp_npdu_number, { "N-PDU Number", "gtp.npdu_number", FT_UINT8, BASE_HEX, NULL, 0, "N-PDU Number", HFILL }},
4331 { &hf_gtp_nsapi, { "NSAPI", "gtp.nsapi", FT_UINT8, BASE_DEC, NULL, 0, "Network layer Service Access Point Identifier", HFILL }},
4332 { &hf_gtp_qos_version, { "Version", "gtp.qos_version", FT_STRING, BASE_DEC, NULL, 0, "Version of the QoS Profile", HFILL }},
4333 { &hf_gtp_qos_spare1, { "Spare", "gtp.qos_spare1", FT_UINT8, BASE_DEC, NULL, GTP_EXT_QOS_SPARE1_MASK, "Spare (shall be sent as '00' )", HFILL }},
4334 { &hf_gtp_qos_delay, { "QoS delay", "gtp.qos_delay", FT_UINT8, BASE_DEC, VALS(qos_delay_type), GTP_EXT_QOS_DELAY_MASK, "Quality of Service Delay Class", HFILL }},
4335 { &hf_gtp_qos_reliability, { "QoS reliability", "gtp.qos_reliabilty", FT_UINT8, BASE_DEC, VALS(qos_reliability_type), GTP_EXT_QOS_RELIABILITY_MASK, "Quality of Service Reliability Class", HFILL }},
4336 { &hf_gtp_qos_peak, { "QoS peak", "gtp.qos_peak", FT_UINT8, BASE_DEC, VALS(qos_peak_type), GTP_EXT_QOS_PEAK_MASK, "Quality of Service Peak Throughput", HFILL }},
4337 { &hf_gtp_qos_spare2, { "Spare", "gtp.qos_spare2",FT_UINT8, BASE_DEC, NULL, GTP_EXT_QOS_SPARE2_MASK, "Spare (shall be sent as 0)", HFILL }},
4338 { &hf_gtp_qos_precedence, { "QoS precedence", "gtp.qos_precedence", FT_UINT8, BASE_DEC, VALS(qos_precedence_type), GTP_EXT_QOS_PRECEDENCE_MASK, "Quality of Service Precedence Class", HFILL }},
4339 { &hf_gtp_qos_spare3, { "Spare", "gtp.qos_spare3", FT_UINT8, BASE_DEC, NULL, GTP_EXT_QOS_SPARE3_MASK, "Spare (shall be sent as '000' )", HFILL }},
4340 { &hf_gtp_qos_mean, { "QoS mean", "gtp.qos_mean", FT_UINT8, BASE_DEC, VALS(qos_mean_type), GTP_EXT_QOS_MEAN_MASK, "Quality of Service Mean Throughput", HFILL }},
4341 { &hf_gtp_qos_al_ret_priority, { "Allocation/Retention priority ","gtp.qos_al_ret_priority", FT_UINT8, BASE_DEC, NULL, 0, "Allocation/Retention Priority", HFILL }},
4342 { &hf_gtp_qos_traf_class, { "Traffic class", "gtp.qos_traf_class", FT_UINT8, BASE_DEC, VALS(qos_traf_class), GTP_EXT_QOS_TRAF_CLASS_MASK, "Traffic Class", HFILL }},
4343 { &hf_gtp_qos_del_order, { "Delivery order", "gtp.qos_del_order", FT_UINT8, BASE_DEC, VALS(qos_del_order), GTP_EXT_QOS_DEL_ORDER_MASK, "Delivery Order", HFILL }},
4344 { &hf_gtp_qos_del_err_sdu, { "Delivery of erroneous SDU", "gtp.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 }},
4345 { &hf_gtp_qos_max_sdu_size, { "Maximum SDU size", "gtp.qos_max_sdu_size", FT_UINT8, BASE_DEC, VALS(qos_max_sdu_size), 0, "Maximum SDU size", HFILL }},
4346 { &hf_gtp_qos_max_ul, { "Maximum bit rate for uplink", "gtp.qos_max_ul", FT_UINT8, BASE_DEC, VALS(qos_max_ul), 0, "Maximum bit rate for uplink", HFILL }},
4347 { &hf_gtp_qos_max_dl, { "Maximum bit rate for downlink", "gtp.qos_max_dl", FT_UINT8, BASE_DEC, VALS(qos_max_dl), 0, "Maximum bit rate for downlink", HFILL }},
4348 { &hf_gtp_qos_res_ber, { "Residual BER", "gtp.qos_res_ber", FT_UINT8, BASE_DEC, VALS(qos_res_ber), GTP_EXT_QOS_RES_BER_MASK, "Residual Bit Error Rate", HFILL }},
4349 { &hf_gtp_qos_sdu_err_ratio, { "SDU Error ratio", "gtp.qos_sdu_err_ratio", FT_UINT8, BASE_DEC, VALS(qos_sdu_err_ratio), GTP_EXT_QOS_SDU_ERR_RATIO_MASK, "SDU Error Ratio", HFILL }},
4350 { &hf_gtp_qos_trans_delay, { "Transfer delay", "gtp.qos_trans_delay", FT_UINT8, BASE_DEC, VALS(qos_trans_delay), GTP_EXT_QOS_TRANS_DELAY_MASK, "Transfer Delay", HFILL }},
4351 { &hf_gtp_qos_traf_handl_prio, { "Traffic handling priority", "gtp.qos_traf_handl_prio", FT_UINT8, BASE_DEC, VALS(qos_traf_handl_prio), GTP_EXT_QOS_TRAF_HANDL_PRIORITY_MASK, "Traffic Handling Priority", HFILL }},
4352 { &hf_gtp_qos_guar_ul, { "Guaranteed bit rate for uplink", "gtp.qos_guar_ul", FT_UINT8, BASE_DEC, VALS(qos_guar_ul), 0, "Guaranteed bit rate for uplink", HFILL }},
4353 { &hf_gtp_qos_guar_dl, { "Guaranteed bit rate for downlink", "gtp.qos_guar_dl", FT_UINT8, BASE_DEC, VALS(qos_guar_dl), 0, "Guaranteed bit rate for downlink", HFILL }},
4354 { &hf_gtp_pkt_flow_id, { "Packet Flow ID", "gtp.pkt_flow_id", FT_UINT8, BASE_DEC, NULL, 0, "Packet Flow ID", HFILL }},
4355 { &hf_gtp_ptmsi, { "P-TMSI", "gtp.ptmsi", FT_UINT32, BASE_HEX, NULL, 0, "Packet-Temporary Mobile Subscriber Identity", HFILL }},
4356 { &hf_gtp_ptmsi_sig, { "P-TMSI Signature", "gtp.ptmsi_sig", FT_UINT24, BASE_HEX, NULL, 0, "P-TMSI Signature", HFILL }},
4357 { &hf_gtp_rab_gtpu_dn, { "Downlink GTP-U seq number", "gtp.rab_gtp_dn", FT_UINT16, BASE_DEC, NULL, 0, "Downlink GTP-U sequence number", HFILL }},
4358 { &hf_gtp_rab_gtpu_up, { "Uplink GTP-U seq number", "gtp.rab_gtp_up", FT_UINT16, BASE_DEC, NULL, 0, "Uplink GTP-U sequence number", HFILL }},
4359 { &hf_gtp_rab_pdu_dn, { "Downlink next PDCP-PDU seq number", "gtp.rab_pdu_dn", FT_UINT8, BASE_DEC, NULL, 0, "Downlink next PDCP-PDU sequence number", HFILL }},
4360 { &hf_gtp_rab_pdu_up, { "Uplink next PDCP-PDU seq number", "gtp.rab_pdu_up", FT_UINT8, BASE_DEC, NULL, 0, "Uplink next PDCP-PDU sequence number", HFILL }},
4361 { &hf_gtp_rai_mcc, { "MCC", "gtp.mcc", FT_UINT16, BASE_DEC, NULL, 0, "Mobile Country Code", HFILL }},
4362 { &hf_gtp_rai_mnc, { "MNC", "gtp.mnc", FT_UINT8, BASE_DEC, NULL, 0, "Mobile Network Code", HFILL }},
4363 { &hf_gtp_rai_rac, { "RAC", "gtp.rac", FT_UINT8, BASE_DEC, NULL, 0, "Routing Area Code", HFILL }},
4364 { &hf_gtp_rai_lac, { "LAC", "gtp.lac", FT_UINT16, BASE_DEC, NULL, 0, "Location Area Code", HFILL }},
4365 { &hf_gtp_ranap_cause, { "RANAP cause", "gtp.ranap_cause", FT_UINT8, BASE_DEC, VALS(ranap_cause_type), 0, "RANAP cause", HFILL }},
4366 { &hf_gtp_recovery, { "Recovery", "gtp.recovery", FT_UINT8, BASE_DEC, NULL, 0, "Restart counter", HFILL }},
4367 { &hf_gtp_reorder, { "Reordering required","gtp.reorder", FT_BOOLEAN, BASE_NONE,NULL, 0, "Reordering required", HFILL }},
4368 { &hf_gtp_rnc_ipv4, { "RNC address IPv4", "gtp.rnc_ipv4", FT_IPv4, BASE_DEC, NULL, 0, "Radio Network Controller address IPv4", HFILL }},
4369 { &hf_gtp_rnc_ipv6, { "RNC address IPv6", "gtp.rnc_ipv6", FT_IPv6, BASE_HEX, NULL, 0, "Radio Network Controller address IPv6", HFILL }},
4370 { &hf_gtp_rp, { "Radio Priority", "gtp.rp", FT_UINT8, BASE_DEC, NULL, GTPv1_EXT_RP_MASK, "Radio Priority for uplink tx", HFILL }},
4371 { &hf_gtp_rp_nsapi, { "NSAPI in Radio Priority", "gtp.rp_nsapi", FT_UINT8, BASE_DEC, NULL, GTPv1_EXT_RP_NSAPI_MASK, "Network layer Service Access Point Identifier in Radio Priority", HFILL }},
4372 { &hf_gtp_rp_sms, { "Radio Priority SMS", "gtp.rp_sms", FT_UINT8, BASE_DEC, NULL, 0, "Radio Priority for MO SMS", HFILL }},
4373 { &hf_gtp_rp_spare, { "Reserved", "gtp.rp_spare", FT_UINT8, BASE_DEC, NULL, GTPv1_EXT_RP_SPARE_MASK, "Spare bit", HFILL }},
4374 { &hf_gtp_sel_mode, { "Selection mode", "gtp.sel_mode", FT_UINT8, BASE_DEC, VALS(sel_mode_type), 0, "Selection Mode", HFILL }},
4375 { &hf_gtp_seq_number, { "Sequence number", "gtp.seq_number", FT_UINT16, BASE_HEX, NULL, 0, "Sequence Number", HFILL }},
4376 { &hf_gtp_sndcp_number, { "SNDCP N-PDU LLC Number", "gtp.sndcp_number", FT_UINT8, BASE_HEX, NULL, 0, "SNDCP N-PDU LLC Number", HFILL }},
4377 { &hf_gtp_tear_ind, { "Teardown Indicator", "gtp.tear_ind", FT_BOOLEAN, BASE_NONE,NULL, 0, "Teardown Indicator", HFILL }},
4378 { &hf_gtp_teid, { "TEID", "gtp.teid", FT_UINT32, BASE_HEX, NULL, 0, "Tunnel Endpoint Identifier", HFILL }},
4379 { &hf_gtp_teid_cp, { "TEID Control Plane", "gtp.teid_cp", FT_UINT32, BASE_HEX, NULL, 0, "Tunnel Endpoint Identifier Control Plane", HFILL }},
4380 { &hf_gtp_teid_data, { "TEID Data I", "gtp.teid_data", FT_UINT32, BASE_HEX, NULL, 0, "Tunnel Endpoint Identifier Data I", HFILL }},
4381 { &hf_gtp_teid_ii, { "TEID Data II", "gtp.teid_ii", FT_UINT32, BASE_HEX, NULL, 0, "Tunnel Endpoint Identifier Data II", HFILL }},
4382 { &hf_gtp_tft_code, { "TFT operation code", "gtp.tft_code", FT_UINT8, BASE_DEC, VALS (tft_code_type), GTPv1_TFT_CODE_MASK, "TFT operation code", HFILL }},
4383 { &hf_gtp_tft_spare, { "TFT spare bit", "gtp.tft_spare", FT_UINT8, BASE_DEC, NULL, GTPv1_TFT_SPARE_MASK, "TFT spare bit", HFILL }},
4384 { &hf_gtp_tft_number, { "Number of packet filters", "gtp.tft_number", FT_UINT8, BASE_DEC, NULL, GTPv1_TFT_NUMBER_MASK, "Number of packet filters", HFILL }},
4385 { &hf_gtp_tft_eval, { "Evaluation precedence", "gtp.tft_eval", FT_UINT8, BASE_DEC, NULL, 0, "Evaluation precedence", HFILL }},
4386 { &hf_gtp_tid, { "TID", "gtp.tid", FT_STRING, BASE_DEC, NULL, 0, "Tunnel Identifier", HFILL }},
4387 { &hf_gtp_tlli, { "TLLI", "gtp.tlli", FT_UINT32, BASE_HEX, NULL, 0, "Temporary Logical Link Identity", HFILL }},
4388 { &hf_gtp_tr_comm, { "Packet transfer command", "gtp.tr_comm", FT_UINT8, BASE_DEC, VALS (tr_comm_type), 0, "Packat transfer command", HFILL }},
4389 { &hf_gtp_trace_ref, { "Trace reference", "gtp.trace_ref", FT_UINT16, BASE_HEX, NULL, 0, "Trace reference", HFILL }},
4390 { &hf_gtp_trace_type, { "Trace type", "gtp.trace_type", FT_UINT16, BASE_HEX, NULL, 0, "Trace type", HFILL }},
4391 { &hf_gtp_unknown, { "Unknown data (length)", "gtp.unknown", FT_UINT16, BASE_DEC, NULL, 0, "Unknown data", HFILL }},
4392 { &hf_gtp_user_addr_pdp_org, { "PDP type organization", "gtp.user_addr_pdp_org", FT_UINT8, BASE_DEC, VALS(pdp_org_type), 0, "PDP type organization", HFILL }},
4393 { &hf_gtp_user_addr_pdp_type, { "PDP type number", "gtp.user_addr_pdp_type", FT_UINT8, BASE_HEX, VALS (pdp_type), 0, "PDP type", HFILL }},
4394 { &hf_gtp_user_ipv4, { "End user address IPv4", "gtp.user_ipv4", FT_IPv4, BASE_DEC, NULL, 0, "End user address IPv4", HFILL }},
4395 { &hf_gtp_user_ipv6, { "End user address IPv6", "gtp.user_ipv6", FT_IPv6, BASE_HEX, NULL, 0, "End user address IPv6", HFILL }},
4396 { &hf_gtp_security_mode,
4397 { "Security Mode", "gtp.security_mode",
4398 FT_UINT8, BASE_DEC, VALS(mm_sec_modep), 0xc0,
4399 "Security Mode", HFILL }
4401 { &hf_gtp_no_of_vectors,
4402 { "No of Vectors", "gtp.no_of_vectors",
4403 FT_UINT8, BASE_DEC, NULL, 0x38,
4404 "No of Vectors", HFILL }
4406 { &hf_gtp_cipher_algorithm,
4407 { "Cipher Algorithm", "gtp.no_of_vectors",
4408 FT_UINT8, BASE_DEC, VALS(gtp_cipher_algorithm), 0x07,
4409 "Cipher Algorithm", HFILL }
4412 { "Ciphering Key Sequence Number (CKSN)/Key Set Identifier (KSI)", "gtp.cksn_ksi",
4413 FT_UINT8, BASE_DEC, NULL, 0x07,
4417 { "Ciphering Key Sequence Number (CKSN)", "gtp.cksn_ksi",
4418 FT_UINT8, BASE_DEC, NULL, 0x07,
4422 { "Key Set Identifier (KSI)", "gtp.cksn_ksi",
4423 FT_UINT8, BASE_DEC, NULL, 0x07,
4428 static gint *ett_gtp_array[] = {
4438 &ett_gtp_pkt_flow_id,
4462 module_t *gtp_module;
4464 proto_gtp = proto_register_protocol ("GPRS Tunneling Protocol", "GTP", "gtp");
4465 proto_register_field_array (proto_gtp, hf_gtp, array_length (hf_gtp));
4466 proto_register_subtree_array (ett_gtp_array, array_length (ett_gtp_array));
4468 gtp_module = prefs_register_protocol(proto_gtp, proto_reg_handoff_gtp);
4470 prefs_register_uint_preference(gtp_module, "v0_port", "GTPv0 port", "GTPv0 port (default 3386)", 10, &g_gtpv0_port);
4471 prefs_register_uint_preference(gtp_module, "v1c_port", "GTPv1 control plane (GTP-C) port", "GTPv1 control plane port (default 2123)", 10, &g_gtpv1c_port);
4472 prefs_register_uint_preference(gtp_module, "v1u_port", "GTPv1 user plane (GTP-U) port", "GTPv1 user plane port (default 2152)", 10, &g_gtpv1u_port);
4473 prefs_register_bool_preference(gtp_module, "dissect_tpdu", "Dissect T-PDU", "Dissect T-PDU", >p_tpdu);
4475 prefs_register_obsolete_preference (gtp_module, "v0_dissect_cdr_as");
4476 prefs_register_obsolete_preference (gtp_module, "v0_check_etsi");
4477 prefs_register_obsolete_preference (gtp_module, "v1_check_etsi");
4478 prefs_register_bool_preference (gtp_module, "check_etsi", "Compare GTP order with ETSI", "GTP ETSI order", >p_etsi_order);
4479 prefs_register_obsolete_preference(gtp_module, "ppp_reorder");
4481 /* This preference can be used to disable the dissection of GTP over TCP. Most of the Wireless operators uses GTP over UDP.
4482 * The preference is set to TRUE by default forbackward compatibility
4484 prefs_register_bool_preference(gtp_module, "dissect_gtp_over_tcp", "Dissect GTP over TCP", "Dissect GTP over TCP", >p_over_tcp);
4486 register_dissector("gtp", dissect_gtp, proto_gtp);
4490 proto_reg_handoff_gtp(void)
4492 static int Initialized = FALSE;
4493 static dissector_handle_t gtp_handle;
4497 gtp_handle = find_dissector("gtp");
4498 ppp_subdissector_table = find_dissector_table("ppp.protocol");
4500 radius_register_avp_dissector(VENDOR_THE3GPP,5,dissect_radius_qos_umts);
4504 dissector_delete ("udp.port", gtpv0_port, gtp_handle);
4505 dissector_delete ("udp.port", gtpv1c_port, gtp_handle);
4506 dissector_delete ("udp.port", gtpv1u_port, gtp_handle);
4508 if ( !gtp_over_tcp ) {
4509 dissector_delete ("tcp.port", gtpv0_port, gtp_handle);
4510 dissector_delete ("tcp.port", gtpv1c_port, gtp_handle);
4511 dissector_delete ("tcp.port", gtpv1u_port, gtp_handle);
4516 gtpv0_port = g_gtpv0_port;
4517 gtpv1c_port = g_gtpv1c_port;
4518 gtpv1u_port = g_gtpv1u_port;
4520 dissector_add ("udp.port", g_gtpv0_port, gtp_handle);
4521 dissector_add ("udp.port", g_gtpv1c_port, gtp_handle);
4522 dissector_add ("udp.port", g_gtpv1u_port, gtp_handle);
4525 if ( gtp_over_tcp ) {
4526 dissector_add ("tcp.port", g_gtpv0_port, gtp_handle);
4527 dissector_add ("tcp.port", g_gtpv1c_port, gtp_handle);
4528 dissector_add ("tcp.port", g_gtpv1u_port, gtp_handle);
4531 ip_handle = find_dissector("ip");
4532 ipv6_handle = find_dissector("ipv6");
4533 ppp_handle = find_dissector("ppp");
4534 data_handle = find_dissector("data");
4535 gtpcdr_handle = find_dissector("gtpcdr");
4536 bssap_pdu_type_table = find_dissector_table("bssap.pdu_type");