sec_vt_header: dissect cont_id + opnum
[wireshark-wip.git] / ui / tap-sctp-analysis.h
blob5efc4c416efe34492f70ed0d5061d8708e5019e0
1 /*
2 * Copyright 2004-2013, Irene Ruengeler <i.ruengeler [AT] fh-muenster.de>
4 * $Id$
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #ifndef __TAP_SCTP_ANALYSIS_H__
26 #define __TAP_SCTP_ANALYSIS_H__
28 #include <epan/dissectors/packet-sctp.h>
29 #include <epan/address.h>
30 #ifndef _WIN32
31 #include <sys/types.h>
32 #include <sys/socket.h>
33 #include <netinet/in.h>
34 #else
35 #ifdef HAVE_WINSOCK2_H
36 #include <winsock2.h>
37 #endif
38 #endif
40 #define SCTP_DATA_CHUNK_ID 0
41 #define SCTP_INIT_CHUNK_ID 1
42 #define SCTP_INIT_ACK_CHUNK_ID 2
43 #define SCTP_SACK_CHUNK_ID 3
44 #define SCTP_HEARTBEAT_CHUNK_ID 4
45 #define SCTP_HEARTBEAT_ACK_CHUNK_ID 5
46 #define SCTP_ABORT_CHUNK_ID 6
47 #define SCTP_SHUTDOWN_CHUNK_ID 7
48 #define SCTP_SHUTDOWN_ACK_CHUNK_ID 8
49 #define SCTP_ERROR_CHUNK_ID 9
50 #define SCTP_COOKIE_ECHO_CHUNK_ID 10
51 #define SCTP_COOKIE_ACK_CHUNK_ID 11
52 #define SCTP_ECNE_CHUNK_ID 12
53 #define SCTP_CWR_CHUNK_ID 13
54 #define SCTP_SHUTDOWN_COMPLETE_CHUNK_ID 14
55 #define SCTP_AUTH_CHUNK_ID 15
56 #define SCTP_NR_SACK_CHUNK_ID 16
57 #define SCTP_FORWARD_TSN_CHUNK_ID 0xc0
58 #define SCTP_ASCONF_ACK_CHUNK_ID 0x80
59 #define SCTP_PKTDROP_CHUNK_ID 0x81
60 #define SCTP_ASCONF_CHUNK_ID 0xc1
61 #define SCTP_IETF_EXT 255
63 #define IS_SCTP_CHUNK_TYPE(t) \
64 (((t) <= 16) || ((t) == 0xC0) || ((t) == 0xC1) || ((t) == 0x80) || ((t) == 0x81))
66 #define CHUNK_TYPE_LENGTH 1
67 #define CHUNK_FLAGS_LENGTH 1
68 #define CHUNK_LENGTH_LENGTH 2
70 #define CHUNK_HEADER_OFFSET 0
71 #define CHUNK_TYPE_OFFSET CHUNK_HEADER_OFFSET
72 #define CHUNK_FLAGS_OFFSET (CHUNK_TYPE_OFFSET + CHUNK_TYPE_LENGTH)
73 #define CHUNK_LENGTH_OFFSET (CHUNK_FLAGS_OFFSET + CHUNK_FLAGS_LENGTH)
74 #define CHUNK_VALUE_OFFSET (CHUNK_LENGTH_OFFSET + CHUNK_LENGTH_LENGTH)
76 #define INIT_CHUNK_INITIATE_TAG_LENGTH 4
77 #define INIT_CHUNK_ADV_REC_WINDOW_CREDIT_LENGTH 4
78 #define INIT_CHUNK_NUMBER_OF_OUTBOUND_STREAMS_LENGTH 2
79 #define INIT_CHUNK_NUMBER_OF_INBOUND_STREAMS_LENGTH 2
82 #define INIT_CHUNK_INITIATE_TAG_OFFSET CHUNK_VALUE_OFFSET
83 #define INIT_CHUNK_ADV_REC_WINDOW_CREDIT_OFFSET (INIT_CHUNK_INITIATE_TAG_OFFSET + \
84 INIT_CHUNK_INITIATE_TAG_LENGTH )
85 #define INIT_CHUNK_NUMBER_OF_OUTBOUND_STREAMS_OFFSET (INIT_CHUNK_ADV_REC_WINDOW_CREDIT_OFFSET + \
86 INIT_CHUNK_ADV_REC_WINDOW_CREDIT_LENGTH )
87 #define INIT_CHUNK_NUMBER_OF_INBOUND_STREAMS_OFFSET (INIT_CHUNK_NUMBER_OF_OUTBOUND_STREAMS_OFFSET + \
88 INIT_CHUNK_NUMBER_OF_OUTBOUND_STREAMS_LENGTH )
89 #define INIT_CHUNK_INITIAL_TSN_OFFSET (INIT_CHUNK_NUMBER_OF_INBOUND_STREAMS_OFFSET + \
90 INIT_CHUNK_NUMBER_OF_INBOUND_STREAMS_LENGTH )
92 #define DATA_CHUNK_TSN_LENGTH 4
93 #define DATA_CHUNK_TSN_OFFSET (CHUNK_VALUE_OFFSET + 0)
94 #define DATA_CHUNK_STREAM_ID_OFFSET (DATA_CHUNK_TSN_OFFSET + DATA_CHUNK_TSN_LENGTH)
95 #define DATA_CHUNK_STREAM_ID_LENGTH 2
96 #define DATA_CHUNK_STREAM_SEQ_NUMBER_LENGTH 2
97 #define DATA_CHUNK_PAYLOAD_PROTOCOL_ID_LENGTH 4
98 #define DATA_CHUNK_HEADER_LENGTH (CHUNK_HEADER_LENGTH + \
99 DATA_CHUNK_TSN_LENGTH + \
100 DATA_CHUNK_STREAM_ID_LENGTH + \
101 DATA_CHUNK_STREAM_SEQ_NUMBER_LENGTH + \
102 DATA_CHUNK_PAYLOAD_PROTOCOL_ID_LENGTH)
103 #define MAX_ADDRESS_LEN 47
105 #define SCTP_ABORT_CHUNK_T_BIT 0x01
107 #define PARAMETER_TYPE_LENGTH 2
108 #define PARAMETER_LENGTH_LENGTH 2
109 #define PARAMETER_HEADER_LENGTH (PARAMETER_TYPE_LENGTH + PARAMETER_LENGTH_LENGTH)
111 #define PARAMETER_HEADER_OFFSET 0
112 #define PARAMETER_TYPE_OFFSET PARAMETER_HEADER_OFFSET
113 #define PARAMETER_LENGTH_OFFSET (PARAMETER_TYPE_OFFSET + PARAMETER_TYPE_LENGTH)
114 #define PARAMETER_VALUE_OFFSET (PARAMETER_LENGTH_OFFSET + PARAMETER_LENGTH_LENGTH)
116 #define IPV6_ADDRESS_LENGTH 16
117 #define IPV6_ADDRESS_OFFSET PARAMETER_VALUE_OFFSET
118 #define IPV4_ADDRESS_LENGTH 4
119 #define IPV4_ADDRESS_OFFSET PARAMETER_VALUE_OFFSET
120 #define IPV4ADDRESS_PARAMETER_ID 0x0005
121 #define IPV6ADDRESS_PARAMETER_ID 0x0006
123 #define SACK_CHUNK_CUMULATIVE_TSN_ACK_LENGTH 4
124 #define SACK_CHUNK_CUMULATIVE_TSN_ACK_OFFSET (CHUNK_VALUE_OFFSET + 0)
125 #define SACK_CHUNK_ADV_REC_WINDOW_CREDIT_LENGTH 4
126 #define SACK_CHUNK_ADV_REC_WINDOW_CREDIT_OFFSET (SACK_CHUNK_CUMULATIVE_TSN_ACK_OFFSET + \
127 SACK_CHUNK_CUMULATIVE_TSN_ACK_LENGTH)
129 #define INIT_CHUNK_INITIAL_TSN_LENGTH 4
130 #define INIT_CHUNK_FIXED_PARAMTERS_LENGTH (INIT_CHUNK_INITIATE_TAG_LENGTH + \
131 INIT_CHUNK_ADV_REC_WINDOW_CREDIT_LENGTH + \
132 INIT_CHUNK_NUMBER_OF_OUTBOUND_STREAMS_LENGTH + \
133 INIT_CHUNK_NUMBER_OF_INBOUND_STREAMS_LENGTH + \
134 INIT_CHUNK_INITIAL_TSN_LENGTH)
135 #define CHUNK_HEADER_LENGTH (CHUNK_TYPE_LENGTH + \
136 CHUNK_FLAGS_LENGTH + \
137 CHUNK_LENGTH_LENGTH)
138 #define INIT_CHUNK_VARIABLE_LENGTH_PARAMETER_OFFSET (INIT_CHUNK_INITIAL_TSN_OFFSET + \
139 INIT_CHUNK_INITIAL_TSN_LENGTH )
141 /* The below value is 256 */
142 #define NUM_CHUNKS 0xff
144 /* This variable is used as an index into arrays
145 * which store the cumulative information corresponding
146 * all chunks with Chunk Type greater > 16
147 * The value for the below variable is 17
149 #define OTHER_CHUNKS_INDEX 0xfe
151 /* VNB */
152 /* This variable stores the maximum chunk type value
153 * that can be associated with a sctp chunk.
155 #define MAX_SCTP_CHUNK_TYPE 256
157 typedef struct _tsn {
158 guint32 frame_number;
159 guint32 secs; /* Absolute seconds */
160 guint32 usecs;
161 address src;
162 address dst;
163 guint32 first_tsn;
164 GList *tsns;
165 } tsn_t;
167 typedef struct _sctp_tmp_info {
168 address src;
169 address dst;
170 guint16 port1;
171 guint16 port2;
172 guint32 verification_tag1;
173 guint32 verification_tag2;
174 guint32 initiate_tag;
175 guint32 n_tvbs;
176 } sctp_tmp_info_t;
178 typedef struct _sctp_min_max {
179 guint32 tmp_min_secs;
180 guint32 tmp_min_usecs;
181 guint32 tmp_max_secs;
182 guint32 tmp_max_usecs;
183 guint32 tmp_min_tsn1;
184 guint32 tmp_min_tsn2;
185 guint32 tmp_max_tsn1;
186 guint32 tmp_max_tsn2;
187 gint tmp_secs;
188 } sctp_min_max_t;
190 struct tsn_sort{
191 guint32 tsnumber;
192 guint32 secs;
193 guint32 usecs;
194 guint32 offset;
195 guint32 length;
196 guint32 framenumber;
199 typedef struct _sctp_addr_chunk {
200 guint32 direction;
201 address* addr;
202 /* The array is initialized to MAX_SCTP_CHUNK_TYPE
203 * so that there is no memory overwrite
204 * when accessed using sctp chunk type as index.
206 guint32 addr_count[MAX_SCTP_CHUNK_TYPE];
207 } sctp_addr_chunk;
209 typedef struct _sctp_assoc_info {
210 address src;
211 address dst;
212 guint16 port1;
213 guint16 port2;
214 guint32 verification_tag1;
215 guint32 verification_tag2;
216 guint32 initiate_tag;
217 guint32 n_tvbs;
218 GList *addr1;
219 GList *addr2;
220 guint16 instream1;
221 guint16 outstream1;
222 guint16 instream2;
223 guint16 outstream2;
224 guint32 n_adler32_calculated;
225 guint32 n_adler32_correct;
226 guint32 n_crc32c_calculated;
227 guint32 n_crc32c_correct;
228 gchar checksum_type[8];
229 guint32 n_checksum_errors;
230 guint32 n_bundling_errors;
231 guint32 n_padding_errors;
232 guint32 n_length_errors;
233 guint32 n_value_errors;
234 guint32 n_data_chunks;
235 guint32 n_forward_chunks;
236 guint32 n_forward_chunks_ep1;
237 guint32 n_forward_chunks_ep2;
238 guint32 n_data_bytes;
239 guint32 n_packets;
240 guint32 n_data_chunks_ep1;
241 guint32 n_data_bytes_ep1;
242 guint32 n_data_chunks_ep2;
243 guint32 n_data_bytes_ep2;
244 guint32 n_sack_chunks_ep1;
245 guint32 n_sack_chunks_ep2;
246 guint32 n_array_tsn1;
247 guint32 n_array_tsn2;
248 guint32 max_window1;
249 guint32 max_window2;
250 gboolean init;
251 gboolean initack;
252 guint8 initack_dir;
253 guint8 direction;
254 guint32 min_secs;
255 guint32 min_usecs;
256 guint32 max_secs;
257 guint32 max_usecs;
258 guint32 min_tsn1;
259 guint32 min_tsn2;
260 guint32 max_tsn1;
261 guint32 max_tsn2;
262 guint32 max_bytes1;
263 guint32 max_bytes2;
264 GSList *min_max;
265 GList *frame_numbers;
266 GList *tsn1;
267 GPtrArray *sort_tsn1;
268 GPtrArray *sort_sack1;
269 GList *sack1;
270 GList *tsn2;
271 GPtrArray *sort_tsn2;
272 GPtrArray *sort_sack2;
273 GList *sack2;
274 gboolean check_address;
275 GList* error_info_list;
276 /* The array is initialized to MAX_SCTP_CHUNK_TYPE
277 * so that there is no memory overwrite
278 * when accessed using sctp chunk type as index.
280 guint32 chunk_count[MAX_SCTP_CHUNK_TYPE];
281 guint32 ep1_chunk_count[MAX_SCTP_CHUNK_TYPE];
282 guint32 ep2_chunk_count[MAX_SCTP_CHUNK_TYPE];
283 GList* addr_chunk_count;
284 } sctp_assoc_info_t;
286 typedef struct _sctp_error_info {
287 guint32 frame_number;
288 gchar chunk_info[200];
289 const gchar *info_text;
290 } sctp_error_info_t;
293 typedef struct _sctp_allassocs_info {
294 guint32 sum_tvbs;
295 GList* assoc_info_list;
296 gboolean is_registered;
297 GList* children;
298 } sctp_allassocs_info_t;
302 void register_tap_listener_sctp_stat(void);
304 const sctp_allassocs_info_t* sctp_stat_get_info(void);
306 void sctp_stat_scan(void);
308 void remove_tap_listener_sctp_stat(void);
311 const sctp_assoc_info_t* get_selected_assoc(void);
316 #endif /* __TAP_SCTP_ANALYSIS_H__ */