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.
30 #include <string.h> /* for memmove */
32 #include "simple_dialog.h"
33 #include <epan/epan_dissect.h>
34 #include "epan/filesystem.h"
37 #include "dlg_utils.h"
40 #include "compat_macros.h"
42 #include "sctp_stat.h"
44 static sctp_assoc_info_t static_assoc;
47 decrease_childcount(struct sctp_analyse *parent)
49 if (parent->num_children>0)
50 parent->num_children--;
54 increase_childcount(struct sctp_analyse *parent)
56 parent->num_children++;
60 set_child(struct sctp_udata *child, struct sctp_analyse *parent)
62 parent->children=g_list_append(parent->children, child);
66 remove_child(struct sctp_udata *child, struct sctp_analyse *parent)
68 parent->children=g_list_remove(parent->children, child);
72 on_destroy(GtkObject *object _U_, gpointer user_data)
74 struct sctp_analyse *u_data;
77 struct sctp_udata *child_data;
79 u_data=(struct sctp_analyse*)user_data;
83 gtk_grab_remove(GTK_WIDGET(u_data->window));
84 gtk_widget_destroy(GTK_WIDGET(u_data->window));
86 if (u_data->num_children>0)
88 j=u_data->num_children;
91 list=g_list_last(u_data->children);
92 child_data=(struct sctp_udata *)list->data;
93 gtk_grab_remove(GTK_WIDGET(child_data->io->window));
94 gtk_widget_destroy(GTK_WIDGET(child_data->io->window));
95 list=g_list_previous(list);
97 g_list_free(u_data->children);
98 u_data->children = NULL;
101 g_free(u_data->analyse_nb->page2);
102 g_free(u_data->analyse_nb->page3);
103 g_free(u_data->analyse_nb);
104 if (sctp_stat_get_info()->children!=NULL)
106 remove_analyse_child(u_data);
107 decrease_analyse_childcount();
113 on_notebook_switch_page()
117 static void on_chunk_stat_bt(GtkWidget *widget _U_, struct sctp_analyse* u_data)
119 sctp_assoc_info_t* assinfo=NULL;
122 assinfo = g_malloc(sizeof(sctp_assoc_info_t));
123 assinfo=&static_assoc;
124 assinfo->addr_chunk_count=(static_assoc.addr_chunk_count);
125 for (i=0; i<NUM_CHUNKS; i++)
127 assinfo->chunk_count[i]=static_assoc.chunk_count[i];
128 assinfo->ep1_chunk_count[i]=static_assoc.ep1_chunk_count[i];
129 assinfo->ep2_chunk_count[i]=static_assoc.ep2_chunk_count[i];
131 u_data->assoc=assinfo;
132 sctp_chunk_dlg_show(u_data);
135 static void on_close_dlg(GtkWidget *widget _U_, struct sctp_analyse* u_data)
140 gtk_grab_remove(GTK_WIDGET(u_data->window));
141 gtk_widget_destroy(GTK_WIDGET(u_data->window));
145 static void on_chunk1_dlg(GtkWidget *widget _U_, struct sctp_analyse* u_data)
147 sctp_assoc_info_t* assinfo=NULL;
149 assinfo = g_malloc(sizeof(sctp_assoc_info_t));
150 assinfo=&static_assoc;
151 assinfo->addr_chunk_count=(static_assoc.addr_chunk_count);
152 u_data->assoc=assinfo;
153 sctp_chunk_stat_dlg_show(1, u_data);
156 static void on_chunk2_dlg(GtkWidget *widget _U_, struct sctp_analyse* u_data)
158 sctp_assoc_info_t* assinfo=NULL;
160 assinfo = g_malloc(sizeof(sctp_assoc_info_t));
161 assinfo=&static_assoc;
162 assinfo->addr_chunk_count=(static_assoc.addr_chunk_count);
163 u_data->assoc=assinfo;
164 sctp_chunk_stat_dlg_show(2, u_data);
167 static void on_graph1_dlg(GtkWidget *widget _U_, struct sctp_analyse* u_data)
169 create_graph(1, u_data);
172 static void on_graph2_dlg(GtkWidget *widget _U_, struct sctp_analyse* u_data)
174 create_graph(2, u_data);
177 static void on_graph_byte1_dlg(GtkWidget *widget _U_, struct sctp_analyse* u_data)
179 create_byte_graph(1, u_data);
182 static void on_graph_byte2_dlg(GtkWidget *widget _U_, struct sctp_analyse* u_data)
184 create_byte_graph(2, u_data);
188 update_analyse_dlg(struct sctp_analyse* u_data)
192 gchar field[1][MAX_ADDRESS_LEN];
197 if (u_data->assoc==NULL)
200 if (u_data->window != NULL)
202 gtk_clist_clear(GTK_CLIST(u_data->analyse_nb->page2->clist));
203 gtk_clist_clear(GTK_CLIST(u_data->analyse_nb->page3->clist));
207 g_snprintf(label_txt, 50,"Checksum Type: %s",u_data->assoc->checksum_type);
208 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->checktype), label_txt);
209 g_snprintf(label_txt, 50,"Checksum Errors: %u",u_data->assoc->n_checksum_errors);
210 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->checksum), label_txt);
211 g_snprintf(label_txt, 50,"Bundling Errors: %u",u_data->assoc->n_bundling_errors);
212 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->bundling), label_txt);
213 g_snprintf(label_txt, 50,"Padding Errors: %u",u_data->assoc->n_padding_errors);
214 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->padding), label_txt);
215 g_snprintf(label_txt, 50,"Length Errors: %u",u_data->assoc->n_length_errors);
216 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->length), label_txt);
217 g_snprintf(label_txt, 50,"Value Errors: %u",u_data->assoc->n_value_errors);
218 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->value), label_txt);
219 g_snprintf(label_txt, 50,"No of Data Chunks from EP1 to EP2: %u",u_data->assoc->n_data_chunks_ep1);
220 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->chunks_ep1), label_txt);
221 g_snprintf(label_txt, 50,"No of Data Bytes from EP1 to EP2: %u",u_data->assoc->n_data_bytes_ep1);
222 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->bytes_ep1), label_txt);
223 g_snprintf(label_txt, 50,"No of Data Chunks from EP2 to EP1: %u",u_data->assoc->n_data_chunks_ep2);
224 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->chunks_ep2), label_txt);
225 g_snprintf(label_txt, 50,"No of Data Bytes from EP2 to EP1: %u",u_data->assoc->n_data_bytes_ep2);
226 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->bytes_ep2), label_txt);
228 if (u_data->assoc->init==TRUE)
229 gtk_frame_set_label(GTK_FRAME (u_data->analyse_nb->page2->addr_frame), "Complete list of IP-Addresses as provided in the INIT-Chunk");
230 else if (u_data->assoc->initack==TRUE && u_data->assoc->initack_dir==1)
231 gtk_frame_set_label(GTK_FRAME (u_data->analyse_nb->page2->addr_frame), "Complete list of IP-Addresses as provided in the INITACK-Chunk");
233 gtk_frame_set_label(GTK_FRAME (u_data->analyse_nb->page2->addr_frame), "List of used IP-Addresses");
237 if (u_data->assoc->addr1!=NULL)
239 list = g_list_first(u_data->assoc->addr1);
242 data[0]=&field[0][0];
243 store = (address *) (list->data);
244 if (store->type==AT_IPv4)
246 g_snprintf(field[0], 30, "%s", ip_to_str((const guint8 *)(store->data)));
248 else if (store->type==AT_IPv6)
250 g_snprintf(field[0], 40, "%s", ip6_to_str((const struct e_in6_addr *)(store->data)));
252 added_row = gtk_clist_append(GTK_CLIST(u_data->analyse_nb->page2->clist), data);
253 gtk_clist_set_row_data(GTK_CLIST(u_data->analyse_nb->page2->clist), added_row, u_data->assoc);
254 list = g_list_next(list);
261 g_snprintf(label_txt, 50,"Port: %u",u_data->assoc->port1);
262 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page2->port), label_txt);
263 g_snprintf(label_txt, 50,"Sent Verification Tag: 0x%x",u_data->assoc->verification_tag1);
264 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page2->veritag), label_txt);
266 if (u_data->assoc->init==TRUE || (u_data->assoc->initack==TRUE && u_data->assoc->initack_dir==1))
268 g_snprintf(label_txt, 50,"Requested Number of Inbound Streams: %u",u_data->assoc->instream1);
269 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page2->max_in), label_txt);
270 g_snprintf(label_txt, 50,"Minimum Number of Inbound Streams: %u",((u_data->assoc->instream1>u_data->assoc->outstream2)?u_data->assoc->outstream2:u_data->assoc->instream1));
271 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page2->min_in), label_txt);
273 g_snprintf(label_txt, 50,"Provided Number of Outbound Streams: %u",u_data->assoc->outstream1);
274 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page2->max_out), label_txt);
275 g_snprintf(label_txt, 50,"Minimum Number of Outbound Streams: %u",((u_data->assoc->outstream1>u_data->assoc->instream2)?u_data->assoc->instream2:u_data->assoc->outstream1));
276 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page2->max_out), label_txt);
280 g_snprintf(label_txt, 50,"Used Number of Inbound Streams: %u",u_data->assoc->instream1);
281 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page2->max_in), label_txt);
282 g_snprintf(label_txt, 50,"Used Number of Outbound Streams: %u",u_data->assoc->outstream1);
283 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page2->max_out), label_txt);
286 if (u_data->assoc->initack==TRUE && u_data->assoc->initack_dir==2)
287 gtk_frame_set_label(GTK_FRAME (u_data->analyse_nb->page3->addr_frame), "Complete list of IP-Addresses as provided in the INITACK-Chunk");
289 gtk_frame_set_label(GTK_FRAME (u_data->analyse_nb->page3->addr_frame), "List of used IP-Addresses");
292 if (u_data->assoc->addr2!=NULL)
295 list = g_list_first(u_data->assoc->addr2);
299 data[0]=&field[0][0];
300 store = (address *) (list->data);
301 if (store->type==AT_IPv4)
303 g_snprintf(field[0], 30, "%s", ip_to_str((const guint8 *)(store->data)));
305 else if (store->type==AT_IPv6)
307 g_snprintf(field[0], 40, "%s", ip6_to_str((const struct e_in6_addr *)(store->data)));
309 added_row = gtk_clist_append(GTK_CLIST(u_data->analyse_nb->page3->clist), data);
310 gtk_clist_set_row_data(GTK_CLIST(u_data->analyse_nb->page3->clist), added_row, u_data->assoc);
311 list = g_list_next(list);
319 g_snprintf(label_txt, 50,"Port: %u",u_data->assoc->port2);
320 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page3->port), label_txt);
321 g_snprintf(label_txt, 50,"Sent Verification Tag: 0x%x",u_data->assoc->verification_tag2);
322 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page3->veritag), label_txt);
324 if (u_data->assoc->initack==TRUE)
326 g_snprintf(label_txt, 50,"Requested Number of Inbound Streams: %u",u_data->assoc->instream2);
327 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page3->max_in), label_txt);
328 g_snprintf(label_txt, 50,"Minimum Number of Inbound Streams: %u",((u_data->assoc->instream2>u_data->assoc->outstream1)?u_data->assoc->outstream1:u_data->assoc->instream2));
329 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page3->min_in), label_txt);
331 g_snprintf(label_txt, 50,"Provided Number of Outbound Streams: %u",u_data->assoc->outstream2);
332 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page3->max_out), label_txt);
333 g_snprintf(label_txt, 50,"Minimum Number of Outbound Streams: %u",((u_data->assoc->outstream2>u_data->assoc->instream1)?u_data->assoc->instream1:u_data->assoc->outstream2));
334 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page3->min_out), label_txt);
338 g_snprintf(label_txt, 50,"Used Number of Inbound Streams: %u",u_data->assoc->instream2);
339 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page3->max_in), label_txt);
340 g_snprintf(label_txt, 50,"Used Number of Outbound Streams: %u",u_data->assoc->outstream2);
341 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page3->min_out), label_txt);
345 static void analyse_window_set_title(struct sctp_analyse *u_data)
352 title = g_strdup_printf("SCTP Analyse Association: %s Port1 %u Port2 %u",
353 cf_get_display_name(&cfile), u_data->assoc->port1, u_data->assoc->port2);
354 gtk_window_set_title(GTK_WINDOW(u_data->window), title);
358 void create_analyse_window(struct sctp_analyse* u_data)
360 GtkWidget *window = NULL;
362 GtkWidget *main_vb, *page1, *page2, *page3, *hbox, *vbox_l, *vbox_r, *addr_hb, *stat_fr;
363 GtkWidget *hbox_l1, *hbox_l2,*label, *h_button_box;
364 GtkWidget *chunk_stat_bt, *close_bt, *graph_bt1, *graph_bt2, *chunk_bt1;
366 u_data->analyse_nb = g_malloc(sizeof(struct notes));
367 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
368 gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
369 SIGNAL_CONNECT(window, "destroy", on_destroy,u_data);
371 /* Container for each row of widgets */
372 main_vb = gtk_vbox_new(FALSE, 2);
373 gtk_container_border_width(GTK_CONTAINER(main_vb), 2);
374 gtk_container_add(GTK_CONTAINER(window), main_vb);
375 gtk_widget_show(main_vb);
377 /* Start a notebook for flipping between sets of changes */
378 notebook = gtk_notebook_new();
379 gtk_container_add(GTK_CONTAINER(main_vb), notebook);
380 OBJECT_SET_DATA(window, "notebook", notebook);
381 SIGNAL_CONNECT(notebook, "switch_page", on_notebook_switch_page,NULL);
383 page1 = gtk_vbox_new(FALSE, 8);
384 gtk_container_set_border_width(GTK_CONTAINER(page1), 8);
386 u_data->analyse_nb->checktype = gtk_label_new("");
387 gtk_box_pack_start(GTK_BOX(page1), u_data->analyse_nb->checktype, TRUE, TRUE, 0);
389 gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->checktype),0,0);
391 u_data->analyse_nb->checksum = gtk_label_new("");
392 gtk_box_pack_start(GTK_BOX(page1), u_data->analyse_nb->checksum, TRUE, TRUE, 0);
393 gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->checksum),0,0);
395 u_data->analyse_nb->bundling = gtk_label_new("");
396 gtk_box_pack_start(GTK_BOX(page1), u_data->analyse_nb->bundling, TRUE, TRUE, 0);
397 gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->bundling),0,0);
399 u_data->analyse_nb->padding = gtk_label_new("");
400 gtk_box_pack_start(GTK_BOX(page1), u_data->analyse_nb->padding, TRUE, TRUE, 0);
401 gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->padding),0,0);
403 u_data->analyse_nb->length = gtk_label_new("");
404 gtk_box_pack_start(GTK_BOX(page1), u_data->analyse_nb->length, TRUE, TRUE, 0);
405 gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->length),0,0);
407 u_data->analyse_nb->value = gtk_label_new("");
408 gtk_box_pack_start(GTK_BOX(page1), u_data->analyse_nb->value, TRUE, TRUE, 0);
409 gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->value),0,0);
412 u_data->analyse_nb->chunks_ep1 = gtk_label_new("");
413 gtk_box_pack_start(GTK_BOX(page1), u_data->analyse_nb->chunks_ep1, TRUE, TRUE, 0);
414 gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->chunks_ep1),0,0);
415 u_data->analyse_nb->bytes_ep1 = gtk_label_new("");
416 gtk_box_pack_start(GTK_BOX(page1), u_data->analyse_nb->bytes_ep1, TRUE, TRUE, 0);
417 gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->bytes_ep1),0,0);
418 u_data->analyse_nb->chunks_ep2 = gtk_label_new("");
419 gtk_box_pack_start(GTK_BOX(page1), u_data->analyse_nb->chunks_ep2, TRUE, TRUE, 0);
420 gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->chunks_ep2),0,0);
421 u_data->analyse_nb->bytes_ep2 = gtk_label_new("");
422 gtk_box_pack_start(GTK_BOX(page1), u_data->analyse_nb->bytes_ep2, TRUE, TRUE, 0);
423 gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->bytes_ep2),0,0);
425 hbox = gtk_hbutton_box_new();
426 gtk_box_pack_start(GTK_BOX(page1), hbox, FALSE, FALSE, 0);
427 gtk_container_set_border_width(GTK_CONTAINER(hbox), 10);
428 gtk_button_box_set_layout(GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_SPREAD);
429 gtk_button_box_set_spacing(GTK_BUTTON_BOX (hbox), 0);
430 gtk_button_box_set_child_ipadding(GTK_BUTTON_BOX (hbox), 4, 0);
431 gtk_widget_show(hbox);
433 chunk_stat_bt = gtk_button_new_with_label ("Chunk Statistics");
434 gtk_box_pack_start(GTK_BOX(hbox), chunk_stat_bt, FALSE, FALSE, 0);
435 gtk_widget_show(chunk_stat_bt);
436 SIGNAL_CONNECT(chunk_stat_bt, "clicked", on_chunk_stat_bt, u_data);
439 close_bt = BUTTON_NEW_FROM_STOCK(GTK_STOCK_CLOSE);
440 gtk_box_pack_start(GTK_BOX(hbox), close_bt, FALSE, FALSE, 0);
441 gtk_widget_show(close_bt);
442 SIGNAL_CONNECT(close_bt, "clicked", on_close_dlg, u_data);
445 label = gtk_label_new(" Statistics ");
446 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page1, label);
449 /* page for endpoint 1 */
450 page2 = gtk_vbox_new(FALSE, 8);
451 gtk_container_set_border_width(GTK_CONTAINER(page2), 8);
453 u_data->analyse_nb->page2 = g_malloc(sizeof(struct page));
455 u_data->analyse_nb->page2->addr_frame = gtk_frame_new(NULL);
456 gtk_container_add(GTK_CONTAINER(page2), u_data->analyse_nb->page2->addr_frame);
458 addr_hb = gtk_hbox_new(FALSE, 3);
459 gtk_container_border_width(GTK_CONTAINER(addr_hb), 5);
460 gtk_container_add(GTK_CONTAINER(u_data->analyse_nb->page2->addr_frame), addr_hb);
462 u_data->analyse_nb->page2->scrolled_window = scrolled_window_new(NULL, NULL);
463 WIDGET_SET_SIZE(u_data->analyse_nb->page2->scrolled_window, 560, 100);
465 u_data->analyse_nb->page2->clist = gtk_clist_new(1);
466 gtk_widget_show(u_data->analyse_nb->page2->clist);
468 gtk_clist_set_column_width(GTK_CLIST(u_data->analyse_nb->page2->clist), 0, 200);
469 gtk_clist_set_column_justification(GTK_CLIST(u_data->analyse_nb->page2->clist), 0, GTK_JUSTIFY_LEFT);
471 gtk_container_add(GTK_CONTAINER(u_data->analyse_nb->page2->scrolled_window),
472 u_data->analyse_nb->page2->clist);
474 gtk_box_pack_start(GTK_BOX(addr_hb), u_data->analyse_nb->page2->scrolled_window, TRUE, TRUE, 0);
475 gtk_widget_show(u_data->analyse_nb->page2->scrolled_window);
477 stat_fr = gtk_frame_new(NULL);
478 gtk_container_add(GTK_CONTAINER(page2), stat_fr);
480 hbox = gtk_hbox_new(FALSE,3);
481 gtk_container_border_width(GTK_CONTAINER(hbox), 5);
482 gtk_container_add(GTK_CONTAINER(stat_fr), hbox);
484 vbox_l=gtk_vbox_new(FALSE, 3);
485 gtk_box_pack_start(GTK_BOX(hbox), vbox_l, TRUE, TRUE, 0);
489 hbox_l1=gtk_hbox_new(FALSE,3);
490 gtk_box_pack_start(GTK_BOX(vbox_l), hbox_l1, TRUE, TRUE, 0);
492 u_data->analyse_nb->page2->port = gtk_label_new("");
493 gtk_box_pack_start(GTK_BOX(hbox_l1), u_data->analyse_nb->page2->port, TRUE, TRUE, 0);
494 gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->page2->port),0,0);
496 hbox_l2=gtk_hbox_new(FALSE,3);
497 gtk_box_pack_start(GTK_BOX(vbox_l), hbox_l2, TRUE, TRUE, 0);
500 u_data->analyse_nb->page2->veritag = gtk_label_new("");
502 gtk_box_pack_start(GTK_BOX(hbox_l2), u_data->analyse_nb->page2->veritag, TRUE, TRUE, 0);
503 gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->page2->veritag),0,0);
504 gtk_widget_show(vbox_l);
506 vbox_r=gtk_vbox_new(FALSE, 3);
507 gtk_box_pack_start(GTK_BOX(hbox), vbox_r, TRUE, TRUE, 0);
509 u_data->analyse_nb->page2->max_in = gtk_label_new("");
510 gtk_box_pack_start(GTK_BOX(vbox_r), u_data->analyse_nb->page2->max_in, TRUE, TRUE, 0);
511 gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->page2->max_in),0,0);
512 u_data->analyse_nb->page2->min_in = gtk_label_new("");
513 gtk_box_pack_start(GTK_BOX(vbox_r), u_data->analyse_nb->page2->min_in, TRUE, TRUE, 0);
514 gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->page2->min_in),0,0);
516 u_data->analyse_nb->page2->max_out = gtk_label_new("");
517 gtk_box_pack_start(GTK_BOX(vbox_r), u_data->analyse_nb->page2->max_out, TRUE, TRUE, 0);
518 gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->page2->max_out),0,0);
519 u_data->analyse_nb->page2->min_out = gtk_label_new("");
520 gtk_box_pack_start(GTK_BOX(vbox_r), u_data->analyse_nb->page2->min_out, TRUE, TRUE, 0);
521 gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->page2->min_out),0,0);
524 gtk_widget_show(vbox_r);
526 h_button_box=gtk_hbutton_box_new();
527 gtk_box_pack_start(GTK_BOX(page2), h_button_box, FALSE, FALSE, 0);
528 gtk_container_set_border_width(GTK_CONTAINER(h_button_box), 10);
529 gtk_button_box_set_layout(GTK_BUTTON_BOX (h_button_box), GTK_BUTTONBOX_SPREAD);
530 gtk_button_box_set_spacing(GTK_BUTTON_BOX (h_button_box), 0);
531 gtk_button_box_set_child_ipadding(GTK_BUTTON_BOX (h_button_box), 4, 0);
532 gtk_widget_show(h_button_box);
534 chunk_bt1 = gtk_button_new_with_label("Chunk Statistics");
535 gtk_box_pack_start(GTK_BOX(h_button_box), chunk_bt1, FALSE, FALSE, 0);
536 gtk_widget_show(chunk_bt1);
537 SIGNAL_CONNECT(chunk_bt1, "clicked", on_chunk1_dlg,u_data);
539 graph_bt1 = gtk_button_new_with_label("Graph TSN");
540 gtk_box_pack_start(GTK_BOX(h_button_box), graph_bt1, FALSE, FALSE, 0);
541 gtk_widget_show(graph_bt1);
542 SIGNAL_CONNECT(graph_bt1, "clicked", on_graph1_dlg,u_data);
544 graph_bt2 = gtk_button_new_with_label("Graph Bytes");
545 gtk_box_pack_start(GTK_BOX(h_button_box), graph_bt2, FALSE, FALSE, 0);
546 gtk_widget_show(graph_bt2);
547 SIGNAL_CONNECT(graph_bt2, "clicked", on_graph_byte1_dlg,u_data);
549 close_bt = BUTTON_NEW_FROM_STOCK(GTK_STOCK_CLOSE);
550 gtk_box_pack_start(GTK_BOX(h_button_box), close_bt, FALSE, FALSE, 0);
551 gtk_widget_show(close_bt);
552 SIGNAL_CONNECT(close_bt, "clicked", on_close_dlg, u_data);
554 label = gtk_label_new(" Endpoint 1 ");
555 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page2, label);
557 /* same page for endpoint 2*/
559 page3 = gtk_vbox_new(FALSE, 8);
560 gtk_container_set_border_width(GTK_CONTAINER(page3), 8);
561 u_data->analyse_nb->page3 = g_malloc(sizeof(struct page));
562 u_data->analyse_nb->page3->addr_frame = gtk_frame_new(NULL);
564 gtk_container_add(GTK_CONTAINER(page3), u_data->analyse_nb->page3->addr_frame);
566 addr_hb = gtk_hbox_new(FALSE, 3);
567 gtk_container_border_width(GTK_CONTAINER(addr_hb), 5);
568 gtk_container_add(GTK_CONTAINER(u_data->analyse_nb->page3->addr_frame), addr_hb);
570 u_data->analyse_nb->page3->scrolled_window = scrolled_window_new(NULL, NULL);
571 WIDGET_SET_SIZE(u_data->analyse_nb->page3->scrolled_window, 560, 100);
573 u_data->analyse_nb->page3->clist = gtk_clist_new(1);
574 gtk_widget_show(u_data->analyse_nb->page3->clist);
576 gtk_clist_set_column_width(GTK_CLIST(u_data->analyse_nb->page3->clist), 0, 200);
577 gtk_clist_set_column_justification(GTK_CLIST(u_data->analyse_nb->page3->clist), 0, GTK_JUSTIFY_LEFT);
579 gtk_container_add(GTK_CONTAINER(u_data->analyse_nb->page3->scrolled_window),
580 u_data->analyse_nb->page3->clist);
582 gtk_box_pack_start(GTK_BOX(addr_hb), u_data->analyse_nb->page3->scrolled_window, TRUE, TRUE, 0);
583 gtk_widget_show(u_data->analyse_nb->page3->scrolled_window);
585 stat_fr = gtk_frame_new(NULL);
586 gtk_container_add(GTK_CONTAINER(page3), stat_fr);
588 hbox = gtk_hbox_new(FALSE,3);
589 gtk_container_border_width(GTK_CONTAINER(hbox), 5);
590 gtk_container_add(GTK_CONTAINER(stat_fr), hbox);
592 vbox_l=gtk_vbox_new(FALSE, 3);
593 gtk_box_pack_start(GTK_BOX(hbox), vbox_l, TRUE, TRUE, 0);
595 hbox_l1=gtk_hbox_new(FALSE,3);
596 gtk_box_pack_start(GTK_BOX(vbox_l), hbox_l1, TRUE, TRUE, 0);
598 u_data->analyse_nb->page3->port = gtk_label_new("");
599 gtk_box_pack_start(GTK_BOX(hbox_l1), u_data->analyse_nb->page3->port, TRUE, TRUE, 0);
600 gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->page3->port),0,0);
602 hbox_l2=gtk_hbox_new(FALSE,3);
603 gtk_box_pack_start(GTK_BOX(vbox_l), hbox_l2, TRUE, TRUE, 0);
606 u_data->analyse_nb->page3->veritag = gtk_label_new("");
607 gtk_box_pack_start(GTK_BOX(hbox_l2), u_data->analyse_nb->page3->veritag, TRUE, TRUE, 0);
608 gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->page3->veritag),0,0);
609 gtk_widget_show(vbox_l);
611 vbox_r=gtk_vbox_new(FALSE, 3);
612 gtk_box_pack_start(GTK_BOX(hbox), vbox_r, TRUE, TRUE, 0);
614 u_data->analyse_nb->page3->max_in = gtk_label_new("");
615 gtk_box_pack_start(GTK_BOX(vbox_r), u_data->analyse_nb->page3->max_in, TRUE, TRUE, 0);
616 gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->page3->max_in),0,0);
617 u_data->analyse_nb->page3->min_in = gtk_label_new("");
618 gtk_box_pack_start(GTK_BOX(vbox_r), u_data->analyse_nb->page3->min_in, TRUE, TRUE, 0);
619 gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->page3->min_in),0,0);
621 u_data->analyse_nb->page3->max_out = gtk_label_new("");
622 gtk_box_pack_start(GTK_BOX(vbox_r), u_data->analyse_nb->page3->max_out, TRUE, TRUE, 0);
623 gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->page3->max_out),0,0);
624 u_data->analyse_nb->page3->min_out = gtk_label_new("");
625 gtk_box_pack_start(GTK_BOX(vbox_r), u_data->analyse_nb->page3->min_out, TRUE, TRUE, 0);
626 gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->page3->min_out),0,0);
628 gtk_widget_show(vbox_r);
630 h_button_box=gtk_hbutton_box_new();
631 gtk_box_pack_start(GTK_BOX(page3), h_button_box, FALSE, FALSE, 0);
632 gtk_container_set_border_width(GTK_CONTAINER(h_button_box), 10);
633 gtk_button_box_set_layout(GTK_BUTTON_BOX (h_button_box), GTK_BUTTONBOX_SPREAD);
634 gtk_button_box_set_spacing(GTK_BUTTON_BOX (h_button_box), 0);
635 gtk_button_box_set_child_ipadding(GTK_BUTTON_BOX (h_button_box), 4, 0);
636 gtk_widget_show(h_button_box);
638 chunk_bt1 = gtk_button_new_with_label("Chunk Statistics");
639 gtk_box_pack_start(GTK_BOX(h_button_box), chunk_bt1, FALSE, FALSE, 0);
640 gtk_widget_show(chunk_bt1);
641 SIGNAL_CONNECT(chunk_bt1, "clicked", on_chunk2_dlg, u_data);
643 graph_bt1 = gtk_button_new_with_label("Graph");
644 gtk_box_pack_start(GTK_BOX(h_button_box), graph_bt1, FALSE, FALSE, 0);
645 gtk_widget_show(graph_bt1);
646 SIGNAL_CONNECT(graph_bt1, "clicked", on_graph2_dlg, u_data);
648 graph_bt2 = gtk_button_new_with_label("Graph Bytes");
649 gtk_box_pack_start(GTK_BOX(h_button_box), graph_bt2, FALSE, FALSE, 0);
650 gtk_widget_show(graph_bt2);
651 SIGNAL_CONNECT(graph_bt2, "clicked", on_graph_byte2_dlg,u_data);
654 close_bt = BUTTON_NEW_FROM_STOCK(GTK_STOCK_CLOSE);
655 gtk_box_pack_start(GTK_BOX(h_button_box), close_bt, FALSE, FALSE, 0);
656 gtk_widget_show(close_bt);
657 SIGNAL_CONNECT(close_bt, "clicked", on_close_dlg, u_data);
659 label = gtk_label_new(" Endpoint 2 ");
660 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page3, label);
662 /* show all notebooks */
663 gtk_widget_show_all(notebook);
665 gtk_widget_show(window);
667 u_data->window=window;
668 analyse_window_set_title(u_data);
670 update_analyse_dlg(u_data);
675 void assoc_analyse(sctp_assoc_info_t* assoc)
677 struct sctp_analyse* u_data;
680 u_data = g_malloc(sizeof(struct sctp_analyse));
682 u_data->assoc->addr_chunk_count=assoc->addr_chunk_count;
684 u_data->analyse_nb=NULL;
685 u_data->children=NULL;
686 u_data->num_children=0;
687 static_assoc.addr_chunk_count=assoc->addr_chunk_count;
688 static_assoc.port1=assoc->port1;
689 static_assoc.port2=assoc->port2;
690 for (i=0; i<NUM_CHUNKS; i++)
692 static_assoc.chunk_count[i]=assoc->chunk_count[i];
693 static_assoc.ep1_chunk_count[i]=assoc->ep1_chunk_count[i];
694 static_assoc.ep2_chunk_count[i]=assoc->ep2_chunk_count[i];
696 set_analyse_child(u_data);
697 increase_analyse_childcount();
698 static_assoc.addr_chunk_count=assoc->addr_chunk_count;
699 create_analyse_window(u_data);
703 void sctp_analyse_cb(struct sctp_analyse* u_data)
709 GList *list, *srclist, *dstlist;
715 gboolean frame_matched;
717 gchar filter_text[256];
718 sctp_assoc_info_t* assoc=NULL;
722 strcpy(filter_text,"sctp");
723 if (!dfilter_compile(filter_text, &sfcode)) {
724 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, dfilter_error_msg);
729 fdata = cf->current_frame;
731 /* we are on the selected frame now */
733 return; /* if we exit here it's an error */
735 /* dissect the current frame */
736 if (!wtap_seek_read(cf->wth, fdata->file_off, &cf->pseudo_header,
737 cf->pd, fdata->cap_len, &err, &err_info)) {
738 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
739 cf_read_error_message(err, err_info), cf->filename);
743 edt = epan_dissect_new(TRUE, FALSE);
744 epan_dissect_prime_dfilter(edt, sfcode);
745 epan_dissect_run(edt, &cf->pseudo_header, cf->pd, fdata, &cf->cinfo);
746 frame_matched = dfilter_apply_edt(sfcode, edt);
748 /* if it is not an sctp frame, show the dialog */
750 if (frame_matched != 1) {
751 epan_dissect_free(edt);
752 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
753 "Please choose an SCTP packet!");
757 ip_src = malloc(edt->pi.src.len);
758 memcpy(ip_src, edt->pi.src.data, edt->pi.src.len);
759 ip_dst = malloc(edt->pi.dst.len);
760 memcpy(ip_dst, edt->pi.dst.data, edt->pi.dst.len);
761 srcport = edt->pi.srcport;
762 dstport = edt->pi.destport;
764 list = g_list_first(sctp_stat_get_info()->assoc_info_list);
768 assoc = (sctp_assoc_info_t*)(list->data);
770 if (assoc->port1 == srcport && assoc->port2 == dstport)
772 srclist = g_list_first(assoc->addr1);
775 src = (address *)(srclist->data);
777 if (*src->data == *ip_src)
779 dstlist = g_list_first(assoc->addr2);
782 dst = (address *)(dstlist->data);
783 if (*dst->data == *ip_dst)
786 u_data->assoc->addr_chunk_count=assoc->addr_chunk_count;
787 static_assoc.addr_chunk_count=assoc->addr_chunk_count;
788 static_assoc.port1=assoc->port1;
789 static_assoc.port2=assoc->port2;
790 for (i=0; i<NUM_CHUNKS; i++)
792 static_assoc.chunk_count[i]=assoc->chunk_count[i];
793 static_assoc.ep1_chunk_count[i]=assoc->ep1_chunk_count[i];
794 static_assoc.ep2_chunk_count[i]=assoc->ep2_chunk_count[i];
796 create_analyse_window(u_data);
800 dstlist = g_list_next(dstlist);
804 srclist = g_list_next(srclist);
806 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Assoc not found!");
809 else if (assoc->port2 == srcport && assoc->port1 == dstport)
811 srclist = g_list_first(assoc->addr2);
814 src = (address *)(srclist->data);
815 if (*src->data == *ip_src)
817 dstlist = g_list_first(assoc->addr1);
820 dst = (address *)(dstlist->data);
821 if (*dst->data == *ip_dst)
824 u_data->assoc->addr_chunk_count=assoc->addr_chunk_count;
825 static_assoc.addr_chunk_count=assoc->addr_chunk_count;
826 static_assoc.port1=assoc->port1;
827 static_assoc.port2=assoc->port2;
828 for (i=0; i<NUM_CHUNKS; i++)
830 static_assoc.chunk_count[i]=assoc->chunk_count[i];
831 static_assoc.ep1_chunk_count[i]=assoc->ep1_chunk_count[i];
832 static_assoc.ep2_chunk_count[i]=assoc->ep2_chunk_count[i];
834 create_analyse_window(u_data);
838 dstlist = g_list_next(dstlist);
842 srclist = g_list_next(srclist);
844 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Assoc not found!");
848 list = g_list_next(list);
854 void sctp_analyse_start(GtkWidget *w _U_, gpointer data _U_)
856 struct sctp_analyse * u_data;
858 /* Register the tap listener */
859 if (sctp_stat_get_info()->is_registered==FALSE)
860 register_tap_listener_sctp_stat();
861 /* (redissect all packets) */
865 u_data = g_malloc(sizeof(struct sctp_analyse));
867 u_data->children=NULL;
868 u_data->analyse_nb=NULL;
870 u_data->num_children=0;
872 cf_retap_packets(&cfile);
873 sctp_analyse_cb(u_data);
878 register_tap_listener_sctp_analyse(void)
880 register_tap_menu_item("SCTP/Analyse Association", REGISTER_TAP_GROUP_NONE,
881 sctp_analyse_start, NULL, NULL, NULL);