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 #include <epan/dissectors/packet-sctp.h>
26 #include <epan/address.h>
28 #include <sys/types.h>
29 #include <sys/socket.h>
30 #include <netinet/in.h>
33 #define SCTP_DATA_CHUNK_ID 0
34 #define SCTP_INIT_CHUNK_ID 1
35 #define SCTP_INIT_ACK_CHUNK_ID 2
36 #define SCTP_SACK_CHUNK_ID 3
37 #define SCTP_HEARTBEAT_CHUNK_ID 4
38 #define SCTP_HEARTBEAT_ACK_CHUNK_ID 5
39 #define SCTP_ABORT_CHUNK_ID 6
40 #define SCTP_SHUTDOWN_CHUNK_ID 7
41 #define SCTP_SHUTDOWN_ACK_CHUNK_ID 8
42 #define SCTP_ERROR_CHUNK_ID 9
43 #define SCTP_COOKIE_ECHO_CHUNK_ID 10
44 #define SCTP_COOKIE_ACK_CHUNK_ID 11
46 #define CHUNK_TYPE_LENGTH 1
47 #define CHUNK_FLAGS_LENGTH 1
48 #define CHUNK_LENGTH_LENGTH 2
50 #define CHUNK_HEADER_OFFSET 0
51 #define CHUNK_TYPE_OFFSET CHUNK_HEADER_OFFSET
52 #define CHUNK_FLAGS_OFFSET (CHUNK_TYPE_OFFSET + CHUNK_TYPE_LENGTH)
53 #define CHUNK_LENGTH_OFFSET (CHUNK_FLAGS_OFFSET + CHUNK_FLAGS_LENGTH)
54 #define CHUNK_VALUE_OFFSET (CHUNK_LENGTH_OFFSET + CHUNK_LENGTH_LENGTH)
56 #define INIT_CHUNK_INITIATE_TAG_LENGTH 4
57 #define INIT_CHUNK_ADV_REC_WINDOW_CREDIT_LENGTH 4
58 #define INIT_CHUNK_NUMBER_OF_OUTBOUND_STREAMS_LENGTH 2
59 #define INIT_CHUNK_NUMBER_OF_INBOUND_STREAMS_LENGTH 2
62 #define INIT_CHUNK_INITIATE_TAG_OFFSET CHUNK_VALUE_OFFSET
63 #define INIT_CHUNK_ADV_REC_WINDOW_CREDIT_OFFSET (INIT_CHUNK_INITIATE_TAG_OFFSET + \
64 INIT_CHUNK_INITIATE_TAG_LENGTH )
65 #define INIT_CHUNK_NUMBER_OF_OUTBOUND_STREAMS_OFFSET (INIT_CHUNK_ADV_REC_WINDOW_CREDIT_OFFSET + \
66 INIT_CHUNK_ADV_REC_WINDOW_CREDIT_LENGTH )
67 #define INIT_CHUNK_NUMBER_OF_INBOUND_STREAMS_OFFSET (INIT_CHUNK_NUMBER_OF_OUTBOUND_STREAMS_OFFSET + \
68 INIT_CHUNK_NUMBER_OF_OUTBOUND_STREAMS_LENGTH )
69 #define INIT_CHUNK_INITIAL_TSN_OFFSET (INIT_CHUNK_NUMBER_OF_INBOUND_STREAMS_OFFSET + \
70 INIT_CHUNK_NUMBER_OF_INBOUND_STREAMS_LENGTH )
72 #define DATA_CHUNK_TSN_LENGTH 4
73 #define DATA_CHUNK_TSN_OFFSET (CHUNK_VALUE_OFFSET + 0)
74 #define DATA_CHUNK_STREAM_ID_OFFSET (DATA_CHUNK_TSN_OFFSET + DATA_CHUNK_TSN_LENGTH)
75 #define DATA_CHUNK_STREAM_ID_LENGTH 2
76 #define DATA_CHUNK_STREAM_SEQ_NUMBER_LENGTH 2
77 #define DATA_CHUNK_PAYLOAD_PROTOCOL_ID_LENGTH 4
78 #define DATA_CHUNK_HEADER_LENGTH (CHUNK_HEADER_LENGTH + \
79 DATA_CHUNK_TSN_LENGTH + \
80 DATA_CHUNK_STREAM_ID_LENGTH + \
81 DATA_CHUNK_STREAM_SEQ_NUMBER_LENGTH + \
82 DATA_CHUNK_PAYLOAD_PROTOCOL_ID_LENGTH)
83 #define MAX_ADDRESS_LEN 47
88 guint32 secs; /* Absolute seconds */
96 typedef struct _sctp_tmp_info {
101 guint32 verification_tag1;
102 guint32 verification_tag2;
103 guint32 initiate_tag;
107 typedef struct _sctp_min_max {
108 guint32 tmp_min_secs;
109 guint32 tmp_min_usecs;
110 guint32 tmp_max_secs;
111 guint32 tmp_max_usecs;
112 guint32 tmp_min_tsn1;
113 guint32 tmp_min_tsn2;
114 guint32 tmp_max_tsn1;
115 guint32 tmp_max_tsn2;
128 typedef struct _sctp_addr_chunk {
131 guint32 addr_count[13];
134 typedef struct _sctp_assoc_info {
139 guint32 verification_tag1;
140 guint32 verification_tag2;
141 guint32 initiate_tag;
149 guint32 n_adler32_calculated;
150 guint32 n_adler32_correct;
151 guint32 n_crc32c_calculated;
152 guint32 n_crc32c_correct;
153 gchar checksum_type[8];
154 guint32 n_checksum_errors;
155 guint32 n_bundling_errors;
156 guint32 n_padding_errors;
157 guint32 n_length_errors;
158 guint32 n_value_errors;
159 guint32 n_data_chunks;
160 guint32 n_data_bytes;
162 guint32 n_data_chunks_ep1;
163 guint32 n_data_bytes_ep1;
164 guint32 n_data_chunks_ep2;
165 guint32 n_data_bytes_ep2;
166 guint32 n_sack_chunks_ep1;
167 guint32 n_sack_chunks_ep2;
168 guint32 n_array_tsn1;
169 guint32 n_array_tsn2;
187 GList *frame_numbers;
189 GPtrArray *sort_tsn1;
190 GPtrArray *sort_sack1;
193 GPtrArray *sort_tsn2;
194 GPtrArray *sort_sack2;
196 gboolean check_address;
197 GList* error_info_list;
198 guint32 chunk_count[NUM_CHUNKS];
199 guint32 ep1_chunk_count[NUM_CHUNKS];
200 guint32 ep2_chunk_count[NUM_CHUNKS];
201 GList* addr_chunk_count;
204 typedef struct _sctp_error_info {
205 guint32 frame_number;
206 gchar chunk_info[200];
207 const gchar *info_text;
211 typedef struct _sctp_allassocs_info {
213 GList* assoc_info_list;
214 gboolean is_registered;
216 } sctp_allassocs_info_t;
221 GtkWidget *checktype;
227 GtkWidget *chunks_ep1;
228 GtkWidget *bytes_ep1;
229 GtkWidget *chunks_ep2;
230 GtkWidget *bytes_ep2;
236 GtkWidget *addr_frame;
237 GtkWidget *scrolled_window;
247 struct sctp_analyse {
248 sctp_assoc_info_t *assoc;
250 struct notes *analyse_nb;
252 guint16 num_children;
255 typedef struct _sctp_graph_t {
256 gboolean needs_redraw;
260 GtkWidget *draw_area;
273 gboolean rectangle_present;
290 guint32 tmp_min_tsn1;
291 guint32 tmp_max_tsn1;
292 guint32 tmp_min_tsn2;
293 guint32 tmp_max_tsn2;
304 sctp_assoc_info_t *assoc;
306 struct sctp_analyse *parent;
311 void register_tap_listener_sctp_stat(void);
313 const sctp_allassocs_info_t* sctp_stat_get_info(void);
315 void sctp_stat_scan(void);
317 void remove_tap_listener_sctp_stat(void);
319 void assoc_analyse(sctp_assoc_info_t* assoc);
321 const sctp_assoc_info_t* get_selected_assoc(void);
323 void create_graph(guint16 dir, struct sctp_analyse* u_data);
325 void create_byte_graph(guint16 dir, struct sctp_analyse* u_data);
327 void sctp_error_dlg_show(sctp_assoc_info_t* assoc);
329 void sctp_stat_dlg_update(void);
331 void sctp_chunk_stat_dlg_update(struct sctp_udata* udata, unsigned int direction);
333 void sctp_chunk_dlg_show(struct sctp_analyse* userdata);
335 void sctp_chunk_stat_dlg_show(unsigned int direction, struct sctp_analyse* userdata);
337 GtkWidget *get_stat_dlg(void);
339 GtkWidget *get_chunk_stat_dlg(void);
341 void update_analyse_dlg(struct sctp_analyse* u_data);
343 void sctp_analyse_start(GtkWidget *w _U_, gpointer data _U_);
345 void increase_childcount(struct sctp_analyse *parent);
347 void decrease_childcount(struct sctp_analyse *parent);
349 void set_child(struct sctp_udata *child, struct sctp_analyse *parent);
351 void remove_child(struct sctp_udata *child, struct sctp_analyse *parent);
353 void decrease_analyse_childcount(void);
355 void increase_analyse_childcount(void);
357 void set_analyse_child(struct sctp_analyse *child);
359 void remove_analyse_child(struct sctp_analyse *child);
361 void sctp_set_assoc_filter(void);