2 * Copyright 2004, Irene Ruengeler <i.ruengeler [AT] fh-muenster.de>
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@ethereal.com>
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
89 guint32 secs; /* Absolute seconds */
96 typedef struct _sctp_tmp_info {
101 guint32 verification_tag1;
102 guint32 verification_tag2;
106 typedef struct _sctp_min_max {
107 guint32 tmp_min_secs;
108 guint32 tmp_min_usecs;
109 guint32 tmp_max_secs;
110 guint32 tmp_max_usecs;
111 guint32 tmp_min_tsn1;
112 guint32 tmp_min_tsn2;
113 guint32 tmp_max_tsn1;
114 guint32 tmp_max_tsn2;
126 typedef struct _sctp_addr_chunk {
129 guint32 addr_count[13];
132 typedef struct _sctp_assoc_info {
137 guint32 verification_tag1;
138 guint32 verification_tag2;
146 guint32 n_adler32_calculated;
147 guint32 n_adler32_correct;
148 guint32 n_crc32c_calculated;
149 guint32 n_crc32c_correct;
150 guint8 checksum_type[8];
151 guint32 n_checksum_errors;
152 guint32 n_bundling_errors;
153 guint32 n_padding_errors;
154 guint32 n_length_errors;
155 guint32 n_value_errors;
156 guint32 n_data_chunks;
157 guint32 n_data_bytes;
159 guint32 n_data_chunks_ep1;
160 guint32 n_data_bytes_ep1;
161 guint32 n_data_chunks_ep2;
162 guint32 n_data_bytes_ep2;
163 guint32 n_sack_chunks_ep1;
164 guint32 n_sack_chunks_ep2;
165 guint32 n_array_tsn1;
166 guint32 n_array_tsn2;
184 GList *frame_numbers;
186 GPtrArray *sort_tsn1;
187 GPtrArray *sort_sack1;
190 GPtrArray *sort_tsn2;
191 GPtrArray *sort_sack2;
193 gboolean check_address;
194 GList* error_info_list;
195 guint32 chunk_count[NUM_CHUNKS];
196 guint32 ep1_chunk_count[NUM_CHUNKS];
197 guint32 ep2_chunk_count[NUM_CHUNKS];
198 GList* addr_chunk_count;
201 typedef struct _sctp_error_info {
202 guint32 frame_number;
203 gchar chunk_info[200];
204 const gchar *info_text;
208 typedef struct _sctp_allassocs_info {
210 GList* assoc_info_list;
211 gboolean is_registered;
213 } sctp_allassocs_info_t;
218 GtkWidget *checktype;
224 GtkWidget *chunks_ep1;
225 GtkWidget *bytes_ep1;
226 GtkWidget *chunks_ep2;
227 GtkWidget *bytes_ep2;
233 GtkWidget *addr_frame;
234 GtkWidget *scrolled_window;
244 struct sctp_analyse {
245 sctp_assoc_info_t *assoc;
247 struct notes *analyse_nb;
249 guint16 num_children;
252 typedef struct _sctp_graph_t {
253 gboolean needs_redraw;
257 GtkWidget *draw_area;
278 guint32 tmp_min_tsn1;
279 guint32 tmp_max_tsn1;
280 guint32 tmp_min_tsn2;
281 guint32 tmp_max_tsn2;
291 sctp_assoc_info_t *assoc;
293 struct sctp_analyse *parent;
298 void register_tap_listener_sctp_stat(void);
300 const sctp_allassocs_info_t* sctp_stat_get_info(void);
302 void sctp_stat_scan(void);
304 void remove_tap_listener_sctp_stat(void);
306 void assoc_analyse(sctp_assoc_info_t* assoc);
308 const sctp_assoc_info_t* get_selected_assoc(void);
310 void create_graph(guint16 dir, struct sctp_analyse* u_data);
312 void create_byte_graph(guint16 dir, struct sctp_analyse* u_data);
314 void sctp_error_dlg_show(sctp_assoc_info_t* assoc);
316 void sctp_stat_dlg_update(void);
318 void sctp_chunk_stat_dlg_update(struct sctp_udata* udata, unsigned int direction);
320 void sctp_chunk_dlg_show(struct sctp_analyse* userdata);
322 void sctp_chunk_stat_dlg_show(unsigned int direction, struct sctp_analyse* userdata);
324 GtkWidget *get_stat_dlg(void);
326 GtkWidget *get_chunk_stat_dlg(void);
328 void update_analyse_dlg(struct sctp_analyse* u_data);
330 void sctp_analyse_start(GtkWidget *w _U_, gpointer data _U_);
332 void increase_childcount(struct sctp_analyse *parent);
334 void decrease_childcount(struct sctp_analyse *parent);
336 void set_child(struct sctp_udata *child, struct sctp_analyse *parent);
338 void remove_child(struct sctp_udata *child, struct sctp_analyse *parent);
340 void decrease_analyse_childcount(void);
342 void increase_analyse_childcount(void);
344 void set_analyse_child(struct sctp_analyse *child);
346 void remove_analyse_child(struct sctp_analyse *child);