Wireshark 5.1.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
packet-gtp.h
1/* packet-gtp.h
2 *
3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
6 *
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 */
9
10#ifndef __PACKET_GTP_H
11#define __PACKET_GTP_H
12/*structure used to track responses to requests using sequence number*/
13typedef struct gtp_msg_hash_entry {
14 bool is_request; /*true/false*/
15 uint32_t req_frame; /*frame with request */
16 nstime_t req_time; /*req time */
17 uint32_t rep_frame; /*frame with reply */
18 int seq_nr; /*sequence number*/
19 unsigned msgtype; /*messagetype*/
20} gtp_msg_hash_t;
21
22
23typedef struct _gtp_hdr {
24 uint8_t flags; /* GTP header flags */
25 uint8_t message; /* Message type */
26 uint32_t length; /* Length of header */
27 int64_t teid; /* Tunnel End-point ID */
28} gtp_hdr_t;
29
30/* definitions of GTP messages */
31#define GTP_MSG_UNKNOWN 0x00
32#define GTP_MSG_ECHO_REQ 0x01
33#define GTP_MSG_ECHO_RESP 0x02
34#define GTP_MSG_VER_NOT_SUPP 0x03
35#define GTP_MSG_NODE_ALIVE_REQ 0x04
36#define GTP_MSG_NODE_ALIVE_RESP 0x05
37#define GTP_MSG_REDIR_REQ 0x06
38#define GTP_MSG_REDIR_RESP 0x07
39/*
40 * 8-15 For future use. Shall not be sent. If received,
41 * shall be treated as an Unknown message.
42 */
43#define GTP_MSG_CREATE_PDP_REQ 0x10
44#define GTP_MSG_CREATE_PDP_RESP 0x11
45#define GTP_MSG_UPDATE_PDP_REQ 0x12
46#define GTP_MSG_UPDATE_PDP_RESP 0x13
47#define GTP_MSG_DELETE_PDP_REQ 0x14
48#define GTP_MSG_DELETE_PDP_RESP 0x15
49#define GTP_MSG_INIT_PDP_CONTEXT_ACT_REQ 0x16 /* 2G */
50#define GTP_MSG_INIT_PDP_CONTEXT_ACT_RESP 0x17 /* 2G */
51/*
52 * 24-25 For future use. Shall not be sent. If received,
53 * shall be treated as an Unknown message.
54 */
55#define GTP_MSG_DELETE_AA_PDP_REQ 0x18 /* 2G */
56#define GTP_MSG_DELETE_AA_PDP_RESP 0x19 /* 2G */
57#define GTP_MSG_ERR_IND 0x1A
58#define GTP_MSG_PDU_NOTIFY_REQ 0x1B
59#define GTP_MSG_PDU_NOTIFY_RESP 0x1C
60#define GTP_MSG_PDU_NOTIFY_REJ_REQ 0x1D
61#define GTP_MSG_PDU_NOTIFY_REJ_RESP 0x1E
62#define GTP_MSG_SUPP_EXT_HDR 0x1F
63#define GTP_MSG_SEND_ROUT_INFO_REQ 0x20
64#define GTP_MSG_SEND_ROUT_INFO_RESP 0x21
65#define GTP_MSG_FAIL_REP_REQ 0x22
66#define GTP_MSG_FAIL_REP_RESP 0x23
67#define GTP_MSG_MS_PRESENT_REQ 0x24
68#define GTP_MSG_MS_PRESENT_RESP 0x25
69/*
70 * 38-47 For future use. Shall not be sent. If received,
71 * shall be treated as an Unknown message.
72 */
73#define GTP_MSG_IDENT_REQ 0x30
74#define GTP_MSG_IDENT_RESP 0x31
75#define GTP_MSG_SGSN_CNTXT_REQ 0x32
76#define GTP_MSG_SGSN_CNTXT_RESP 0x33
77#define GTP_MSG_SGSN_CNTXT_ACK 0x34
78#define GTP_MSG_FORW_RELOC_REQ 0x35
79#define GTP_MSG_FORW_RELOC_RESP 0x36
80#define GTP_MSG_FORW_RELOC_COMP 0x37
81#define GTP_MSG_RELOC_CANCEL_REQ 0x38
82#define GTP_MSG_RELOC_CANCEL_RESP 0x39
83#define GTP_MSG_FORW_SRNS_CNTXT 0x3A
84#define GTP_MSG_FORW_RELOC_ACK 0x3B
85#define GTP_MSG_FORW_SRNS_CNTXT_ACK 0x3C
86#define GTP_MSG_UE_REG_QUERY_REQ 0x3D
87#define GTP_MSG_UE_REG_QUERY_RESP 0x3E
88/*
89 * 63-69 For future use. Shall not be sent. If received,
90 * shall be treated as an Unknown message.
91 */
92#define GTP_MSG_RAN_INFO_RELAY 70
93/*
94 * 71-95 For future use. Shall not be sent. If received,
95 * shall be treated as an Unknown message.
96 */
97#define GTP_MBMS_NOTIFY_REQ 96
98#define GTP_MBMS_NOTIFY_RES 97
99#define GTP_MBMS_NOTIFY_REJ_REQ 98
100#define GTP_MBMS_NOTIFY_REJ_RES 99
101#define GTP_CREATE_MBMS_CNTXT_REQ 100
102#define GTP_CREATE_MBMS_CNTXT_RES 101
103#define GTP_UPD_MBMS_CNTXT_REQ 102
104#define GTP_UPD_MBMS_CNTXT_RES 103
105#define GTP_DEL_MBMS_CNTXT_REQ 104
106#define GTP_DEL_MBMS_CNTXT_RES 105
107/*
108 * 106 - 111 For future use. Shall not be sent. If received,
109 * shall be treated as an Unknown message.
110 */
111#define GTP_MBMS_REG_REQ 112
112#define GTP_MBMS_REG_RES 113
113#define GTP_MBMS_DE_REG_REQ 114
114#define GTP_MBMS_DE_REG_RES 115
115#define GTP_MBMS_SES_START_REQ 116
116#define GTP_MBMS_SES_START_RES 117
117#define GTP_MBMS_SES_STOP_REQ 118
118#define GTP_MBMS_SES_STOP_RES 119
119#define GTP_MBMS_SES_UPD_REQ 120
120#define GTP_MBMS_SES_UPD_RES 121
121/* 122-127 For future use. Shall not be sent.
122 * If received, shall be treated as an Unknown message.
123 */
124#define GTP_MS_INFO_CNG_NOT_REQ 128
125#define GTP_MS_INFO_CNG_NOT_RES 129
126/* 130-239 For future use. Shall not be sent.
127 * If received, shall be treated as an Unknown message.
128 */
129#define GTP_MSG_DATA_TRANSF_REQ 0xF0
130#define GTP_MSG_DATA_TRANSF_RESP 0xF1
131/* 242-253 For future use. Shall not be sent.
132 * If received, shall be treated as an Unknown message.
133 */
134#define GTP_MSG_END_MARKER 0xFE /* 254 */
135#define GTP_MSG_TPDU 0xFF
136
137/* This is used by custom dissectors and should be in the "install" target */
138/* PUBLIC_HEADER */
139
140extern value_string_ext cause_type_ext;
141
142static const value_string gtp_sel_mode_vals[] = {
143 { 0, "MS or network provided APN, subscription verified" },
144 { 1, "MS provided APN, subscription not verified" },
145 { 2, "Network provided APN, subscription not verified" },
146 { 3, "For future use. Shall not be sent. If received, shall be interpreted as the value 2 (Network provided APN, subscription not verified)" },
147 { 0, NULL }
148};
149
153
154typedef struct gtp_hdr_ext_info {
155 proto_item* hdr_ext_item; /* The item created when adding the type of header to the tree,
156 * used to put the name in the tree
157 */
158} gtp_hdr_ext_info_t;
159
160
161
162/* Data structures to keep track of sessions */
163extern uint32_t gtp_session_count;
164extern bool g_gtp_session;
165
166/* The <teid,ip> pair of a F-TEID */
167typedef struct {
168 uint32_t teid;
169 address addr;
171
172typedef struct session_args {
173 wmem_list_t *teid_list;
174 wmem_list_t *ip_list;
175 uint32_t last_teid;
176 address last_ip;
177 uint8_t last_cause;
178 const char *imsi;
179 wmem_list_t *replaced_list; /* <teid,ip> mappings that fill_map() replaced */
180 wmem_list_t *fteid_list; /* F-TEIDs (gtp_fteid_t) of a GTPv2 message, if not NULL */
181} session_args_t;
182
183/* Relation between frame -> session */
184extern wmem_map_t* session_table;
185
186/* Relation between session -> IMSI */
187extern wmem_map_t* session_imsi;
188
189/* Relation between <teid,ip> -> frame */
190extern wmem_map_t* frame_map;
191
192/* Relation between <teid,convid,ip> -> frame,
193 * similar to frame_map but involved when deinterlacing is enabled
194 */
195extern wmem_map_t* frame_map_deint;
196
197uint32_t get_frame(address ip, uint32_t teid, uint32_t *frame);
198
199/* Similar to get_frame() but relies on the deinterlacer Map (frame_map_deint),
200 * for the <teid,ip> in the conversation convid.
201 * GTP ignores deinterlacing, and GTPv2 supports it.
202 */
203uint32_t get_gtp_session_frame(address ip, uint32_t teid, uint32_t convid, uint32_t *frame);
204
209void remove_frame_info(uint32_t f);
210
216void remove_frame_info_lists(wmem_list_t *teid_list, wmem_list_t *ip_list, uint32_t frame);
217
218void add_gtp_session(uint32_t frame, uint32_t session);
219
220bool teid_exists(uint32_t teid, wmem_list_t *teid_list);
221
222bool ip_exists(address ip, wmem_list_t *ip_list);
223
229void fill_map(wmem_list_t *teid_list, wmem_list_t *ip_list, uint32_t frame, uint32_t convid, bool ignore_conv, wmem_allocator_t *scope, wmem_list_t *replaced_list);
230
235void fill_map_fteids(wmem_list_t *fteid_list, uint32_t frame, uint32_t convid, bool ignore_conv, wmem_allocator_t *scope, wmem_list_t *replaced_list);
236
241void remove_frame_info_fteids(wmem_list_t *fteid_list, uint32_t frame);
242
249void restore_frame_info(uint32_t frame, wmem_list_t *replaced_list);
250
251bool is_cause_accepted(uint8_t cause, uint32_t version);
252
253/* Add teid map to IMSI from ex NGAP where both are known. */
254void gtp_add_teid_imsi(uint32_t teid, const char* imsi);
255
256/* Add <teid,addr> map to IMSI from ex PFCP where the F-TEID and the IMSI are
257 * known. GTP-U to that F-TEID without a GTP session gets the IMSI. If addr is
258 * NULL or AT_NONE, the same as gtp_add_teid_imsi().
259 */
260void gtp_add_fteid_imsi(uint32_t teid, const address *addr, const char *imsi);
261
262WS_DLL_PUBLIC
263unsigned decode_qos_umts(tvbuff_t * tvb, unsigned offset, packet_info * pinfo, proto_tree * tree, const char * qos_str, uint8_t type);
264
265WS_DLL_PUBLIC
266void dissect_gtp_uli(tvbuff_t * tvb, unsigned offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
267
268#endif /* __PACKET_GTP_H*/
struct _address address
Holds a network or link-layer address of any supported type.
struct _packet_info packet_info
Represents the metadata and indexing information for a single captured frame.
proto_node proto_item
Definition proto.h:952
struct _wmem_list_t wmem_list_t
Opaque type representing a scoped, doubly-linked list in the wmem system.
Definition wmem_list.h:42
struct _wmem_map_t wmem_map_t
Opaque type representing a wmem-managed hash map.
Definition wmem_map.h:46
struct _wmem_allocator_t wmem_allocator_t
Definition wmem_core.h:44
Definition packet-gtp.h:23
Definition packet-gtp.h:167
Definition packet-gtp.h:154
Definition packet-gtp.h:13
Definition nstime.h:26
Definition packet-gtp.h:172
struct _value_string value_string
Mapping between a 32-bit integer value and its string representation.