2 * Copyright 2004, Irene Ruengeler <i.ruengeler [AT] fh-muenster.de>
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 #ifndef __SCTP_STAT_H__
26 #define __SCTP_STAT_H__
28 #include <epan/dissectors/packet-sctp.h>
29 #include <epan/address.h>
31 #include <sys/types.h>
32 #include <sys/socket.h>
33 #include <netinet/in.h>
35 #ifdef HAVE_WINSOCK2_H
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 /* The below value is 256 */
106 #define NUM_CHUNKS 0xff
108 /* This variable is used as an index into arrays
109 * which store the cumulative information corresponding
110 * all chunks with Chunk Type greater > 16
111 * The value for the below variable is 17
113 #define OTHER_CHUNKS_INDEX 0xfe
116 /* This variable stores the maximum chunk type value
117 * that can be associated with a sctp chunk.
119 #define MAX_SCTP_CHUNK_TYPE 256
121 typedef struct _tsn {
122 guint32 frame_number;
123 guint32 secs; /* Absolute seconds */
131 typedef struct _sctp_tmp_info {
136 guint32 verification_tag1;
137 guint32 verification_tag2;
138 guint32 initiate_tag;
142 typedef struct _sctp_min_max {
143 guint32 tmp_min_secs;
144 guint32 tmp_min_usecs;
145 guint32 tmp_max_secs;
146 guint32 tmp_max_usecs;
147 guint32 tmp_min_tsn1;
148 guint32 tmp_min_tsn2;
149 guint32 tmp_max_tsn1;
150 guint32 tmp_max_tsn2;
163 typedef struct _sctp_addr_chunk {
166 /* The array is initialized to MAX_SCTP_CHUNK_TYPE
167 * so that there is no memory overwrite
168 * when accessed using sctp chunk type as index.
170 guint32 addr_count[MAX_SCTP_CHUNK_TYPE];
173 typedef struct _sctp_assoc_info {
178 guint32 verification_tag1;
179 guint32 verification_tag2;
180 guint32 initiate_tag;
188 guint32 n_adler32_calculated;
189 guint32 n_adler32_correct;
190 guint32 n_crc32c_calculated;
191 guint32 n_crc32c_correct;
192 gchar checksum_type[8];
193 guint32 n_checksum_errors;
194 guint32 n_bundling_errors;
195 guint32 n_padding_errors;
196 guint32 n_length_errors;
197 guint32 n_value_errors;
198 guint32 n_data_chunks;
199 guint32 n_data_bytes;
201 guint32 n_data_chunks_ep1;
202 guint32 n_data_bytes_ep1;
203 guint32 n_data_chunks_ep2;
204 guint32 n_data_bytes_ep2;
205 guint32 n_sack_chunks_ep1;
206 guint32 n_sack_chunks_ep2;
207 guint32 n_array_tsn1;
208 guint32 n_array_tsn2;
226 GList *frame_numbers;
228 GPtrArray *sort_tsn1;
229 GPtrArray *sort_sack1;
232 GPtrArray *sort_tsn2;
233 GPtrArray *sort_sack2;
235 gboolean check_address;
236 GList* error_info_list;
237 /* The array is initialized to MAX_SCTP_CHUNK_TYPE
238 * so that there is no memory overwrite
239 * when accessed using sctp chunk type as index.
241 guint32 chunk_count[MAX_SCTP_CHUNK_TYPE];
242 guint32 ep1_chunk_count[MAX_SCTP_CHUNK_TYPE];
243 guint32 ep2_chunk_count[MAX_SCTP_CHUNK_TYPE];
244 GList* addr_chunk_count;
247 typedef struct _sctp_error_info {
248 guint32 frame_number;
249 gchar chunk_info[200];
250 const gchar *info_text;
254 typedef struct _sctp_allassocs_info {
256 GList* assoc_info_list;
257 gboolean is_registered;
259 } sctp_allassocs_info_t;
264 GtkWidget *checktype;
270 GtkWidget *chunks_ep1;
271 GtkWidget *bytes_ep1;
272 GtkWidget *chunks_ep2;
273 GtkWidget *bytes_ep2;
279 GtkWidget *addr_frame;
280 GtkWidget *scrolled_window;
290 struct sctp_analyse {
291 sctp_assoc_info_t *assoc;
293 struct notes *analyse_nb;
295 guint16 num_children;
298 typedef struct _sctp_graph_t {
299 gboolean needs_redraw;
303 GtkWidget *draw_area;
316 gboolean rectangle_present;
333 guint32 tmp_min_tsn1;
334 guint32 tmp_max_tsn1;
335 guint32 tmp_min_tsn2;
336 guint32 tmp_max_tsn2;
347 sctp_assoc_info_t *assoc;
349 struct sctp_analyse *parent;
354 void register_tap_listener_sctp_stat(void);
356 const sctp_allassocs_info_t* sctp_stat_get_info(void);
358 void sctp_stat_scan(void);
360 void remove_tap_listener_sctp_stat(void);
362 void assoc_analyse(sctp_assoc_info_t* assoc);
364 const sctp_assoc_info_t* get_selected_assoc(void);
366 void create_graph(guint16 dir, struct sctp_analyse* u_data);
368 void create_byte_graph(guint16 dir, struct sctp_analyse* u_data);
370 void sctp_error_dlg_show(sctp_assoc_info_t* assoc);
372 void sctp_stat_dlg_update(void);
374 void sctp_chunk_stat_dlg_update(struct sctp_udata* udata, unsigned int direction);
376 void sctp_chunk_dlg_show(struct sctp_analyse* userdata);
378 void sctp_chunk_stat_dlg_show(unsigned int direction, struct sctp_analyse* userdata);
380 GtkWidget *get_stat_dlg(void);
382 GtkWidget *get_chunk_stat_dlg(void);
384 void update_analyse_dlg(struct sctp_analyse* u_data);
386 void sctp_analyse_start(GtkWidget *w _U_, gpointer data _U_);
388 void increase_childcount(struct sctp_analyse *parent);
390 void decrease_childcount(struct sctp_analyse *parent);
392 void set_child(struct sctp_udata *child, struct sctp_analyse *parent);
394 void remove_child(struct sctp_udata *child, struct sctp_analyse *parent);
396 void decrease_analyse_childcount(void);
398 void increase_analyse_childcount(void);
400 void set_analyse_child(struct sctp_analyse *child);
402 void remove_analyse_child(struct sctp_analyse *child);
404 void sctp_set_assoc_filter(void);
406 #endif /* __SCTP_STAT_H__ */