replace WIDGET_SET_SIZE with gtk_widget_set_size_request
[obnox/wireshark/wip.git] / gtk / sctp_assoc_analyse.c
1 /* 
2  * Copyright 2004, Irene Ruengeler <i.ruengeler [AT] fh-muenster.de>
3  *
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
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.
14  *
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.
19  *
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.
23  */
24  
25 #ifdef HAVE_CONFIG_H
26 #  include <config.h>
27 #endif
28
29 #include <gtk/gtk.h>
30 #include <string.h>  /* for memmove */
31 #include "globals.h"
32 #include "simple_dialog.h"
33 #include <epan/epan_dissect.h>
34 #include "epan/filesystem.h"
35 #include "register.h"
36 #include "../stat_menu.h"
37 #include "gui_stat_menu.h"
38 #include "dlg_utils.h"
39 #include "gui_utils.h"
40 #include "main.h"
41 #include "compat_macros.h"
42 #include <epan/strutil.h>
43
44 #include "sctp_stat.h"
45 #include "gtkglobals.h"
46
47 static sctp_assoc_info_t static_assoc;
48
49 void
50 decrease_childcount(struct sctp_analyse *parent)
51 {
52         if (parent->num_children > 0)
53                 parent->num_children--;
54 }
55
56 void
57 increase_childcount(struct sctp_analyse *parent)
58 {
59         parent->num_children++;
60 }
61
62 void
63 set_child(struct sctp_udata *child, struct sctp_analyse *parent)
64 {
65         parent->children = g_list_append(parent->children, child);
66 }
67
68 void
69 remove_child(struct sctp_udata *child, struct sctp_analyse *parent)
70 {
71         parent->children = g_list_remove(parent->children, child);
72 }
73
74 static void
75 on_destroy(GtkObject *object _U_, gpointer user_data)
76 {
77         struct sctp_analyse *u_data;
78         guint16 i, j;
79         GList *list;
80         struct sctp_udata *child_data;
81
82         u_data = (struct sctp_analyse*)user_data;
83
84         if (u_data->window)
85         {
86                 gtk_grab_remove(GTK_WIDGET(u_data->window));
87                 gtk_widget_destroy(GTK_WIDGET(u_data->window));
88         }
89         if (u_data->num_children>0)
90         {
91                 j = u_data->num_children;
92                 for (i=0; i<j; i++)
93                 {
94                         list = g_list_last(u_data->children);
95                         child_data = (struct sctp_udata *)list->data;
96                         gtk_grab_remove(GTK_WIDGET(child_data->io->window));
97                         gtk_widget_destroy(GTK_WIDGET(child_data->io->window));
98                         list = g_list_previous(list);
99                 }
100                 g_list_free(u_data->children);
101                 u_data->children = NULL;
102         }
103         
104         g_free(u_data->analyse_nb->page2);
105         g_free(u_data->analyse_nb->page3);
106         g_free(u_data->analyse_nb);
107         if (sctp_stat_get_info()->children != NULL)
108         {
109                 remove_analyse_child(u_data);
110                 decrease_analyse_childcount();
111         }
112         g_free(u_data);
113 }
114
115 static void
116 on_notebook_switch_page(void)
117 {
118 }
119
120 static void on_chunk_stat_bt(GtkWidget *widget _U_, struct sctp_analyse* u_data)
121 {
122         sctp_assoc_info_t* assinfo = NULL;
123         int i;
124
125         assinfo = g_malloc(sizeof(sctp_assoc_info_t));
126         assinfo = &static_assoc;
127         assinfo->addr_chunk_count = (static_assoc.addr_chunk_count);
128         for (i=0; i<NUM_CHUNKS; i++)
129         {
130                 assinfo->chunk_count[i]     = static_assoc.chunk_count[i];
131                 assinfo->ep1_chunk_count[i] = static_assoc.ep1_chunk_count[i];
132                 assinfo->ep2_chunk_count[i] = static_assoc.ep2_chunk_count[i];
133         }
134         u_data->assoc = assinfo;
135         sctp_chunk_dlg_show(u_data);
136 }
137
138 static void on_close_dlg(GtkWidget *widget _U_, struct sctp_analyse* u_data)
139 {
140
141         if (u_data->window)
142         {
143                 gtk_grab_remove(GTK_WIDGET(u_data->window));
144                 gtk_widget_destroy(GTK_WIDGET(u_data->window));
145         }
146 }
147
148 static void on_chunk1_dlg(GtkWidget *widget _U_, struct sctp_analyse* u_data)
149 {
150 sctp_assoc_info_t* assinfo = NULL;
151         
152         assinfo = g_malloc(sizeof(sctp_assoc_info_t));
153         assinfo = &static_assoc;
154         assinfo->addr_chunk_count = (static_assoc.addr_chunk_count);
155         u_data->assoc = assinfo;
156         sctp_chunk_stat_dlg_show(1, u_data);
157 }
158
159 static void on_chunk2_dlg(GtkWidget *widget _U_, struct sctp_analyse* u_data)
160 {
161 sctp_assoc_info_t* assinfo=NULL;
162
163         assinfo = g_malloc(sizeof(sctp_assoc_info_t));
164         assinfo = &static_assoc;
165         assinfo->addr_chunk_count = (static_assoc.addr_chunk_count);    
166         u_data->assoc = assinfo;
167         sctp_chunk_stat_dlg_show(2, u_data);
168 }
169
170 static void on_graph1_dlg(GtkWidget *widget _U_, struct sctp_analyse* u_data)
171 {
172         create_graph(1, u_data);
173 }
174
175 static void on_graph2_dlg(GtkWidget *widget _U_, struct sctp_analyse* u_data)
176 {
177         create_graph(2, u_data);
178 }
179
180 static void on_graph_byte1_dlg(GtkWidget *widget _U_, struct sctp_analyse* u_data)
181 {
182         create_byte_graph(1, u_data);
183 }
184
185 static void on_graph_byte2_dlg(GtkWidget *widget _U_, struct sctp_analyse* u_data)
186 {
187         create_byte_graph(2, u_data);
188 }
189
190 void
191 update_analyse_dlg(struct sctp_analyse* u_data)
192 {
193         gchar label_txt[50];
194         gchar *data[1];
195         gchar field[1][MAX_ADDRESS_LEN];
196         gint added_row;
197         GList *list;
198         address *store = NULL;
199
200         if (u_data->assoc == NULL)
201                 return;
202
203         if (u_data->window != NULL)
204         {
205                 gtk_clist_clear(GTK_CLIST(u_data->analyse_nb->page2->clist));
206                 gtk_clist_clear(GTK_CLIST(u_data->analyse_nb->page3->clist));
207         }
208
209
210         g_snprintf(label_txt, 50,"Checksum Type: %s",u_data->assoc->checksum_type);
211         gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->checktype), label_txt);
212         g_snprintf(label_txt, 50,"Checksum Errors: %u",u_data->assoc->n_checksum_errors);
213         gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->checksum), label_txt);
214         g_snprintf(label_txt, 50,"Bundling Errors: %u",u_data->assoc->n_bundling_errors);
215         gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->bundling), label_txt);
216         g_snprintf(label_txt, 50,"Padding Errors: %u",u_data->assoc->n_padding_errors);
217         gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->padding), label_txt);
218         g_snprintf(label_txt, 50,"Length Errors: %u",u_data->assoc->n_length_errors);
219         gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->length), label_txt);
220         g_snprintf(label_txt, 50,"Value Errors: %u",u_data->assoc->n_value_errors);
221         gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->value), label_txt);
222         g_snprintf(label_txt, 50,"No of Data Chunks from EP1 to EP2: %u",u_data->assoc->n_data_chunks_ep1);
223         gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->chunks_ep1), label_txt);
224         g_snprintf(label_txt, 50,"No of Data Bytes from EP1 to EP2: %u",u_data->assoc->n_data_bytes_ep1);
225         gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->bytes_ep1), label_txt);
226         g_snprintf(label_txt, 50,"No of Data Chunks from EP2 to EP1: %u",u_data->assoc->n_data_chunks_ep2);
227         gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->chunks_ep2), label_txt);
228         g_snprintf(label_txt, 50,"No of Data Bytes from EP2 to EP1: %u",u_data->assoc->n_data_bytes_ep2);
229         gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->bytes_ep2), label_txt);
230
231         if (u_data->assoc->init == TRUE)
232                 gtk_frame_set_label(GTK_FRAME (u_data->analyse_nb->page2->addr_frame), "Complete list of IP-Addresses as provided in the INIT-Chunk");
233         else if (u_data->assoc->initack == TRUE && u_data->assoc->initack_dir == 1)
234                 gtk_frame_set_label(GTK_FRAME (u_data->analyse_nb->page2->addr_frame), "Complete list of IP-Addresses as provided in the INITACK-Chunk");
235         else
236                 gtk_frame_set_label(GTK_FRAME (u_data->analyse_nb->page2->addr_frame), "List of used IP-Addresses");
237
238
239
240         if (u_data->assoc->addr1 != NULL)
241         {
242                 list = g_list_first(u_data->assoc->addr1);
243                 while (list)
244                 {
245                         data[0] = &field[0][0];
246                         store = (address *) (list->data);
247                         if (store->type == AT_IPv4)
248                         {
249                                 g_snprintf(field[0], 30, "%s", ip_to_str((const guint8 *)(store->data)));
250                         }
251                         else if (store->type == AT_IPv6)
252                         {               
253                                 g_snprintf(field[0], 40, "%s", ip6_to_str((const struct e_in6_addr *)(store->data)));
254                         }
255                         added_row = gtk_clist_append(GTK_CLIST(u_data->analyse_nb->page2->clist), data);
256                         gtk_clist_set_row_data(GTK_CLIST(u_data->analyse_nb->page2->clist), added_row, u_data->assoc);
257                         list = g_list_next(list);
258                 }
259         }
260         else
261         {
262                 return;
263         }
264         g_snprintf(label_txt, 50,"Port: %u",u_data->assoc->port1);
265         gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page2->port), label_txt);
266         g_snprintf(label_txt, 50,"Sent Verification Tag: 0x%x",u_data->assoc->verification_tag1);
267         gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page2->veritag), label_txt);
268
269         if (u_data->assoc->init == TRUE || (u_data->assoc->initack == TRUE && u_data->assoc->initack_dir == 1))
270         {
271                 g_snprintf(label_txt, 50,"Requested Number of Inbound Streams: %u",u_data->assoc->instream1);
272                 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page2->max_in), label_txt);
273                 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));
274                 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page2->min_in), label_txt);
275
276                 g_snprintf(label_txt, 50,"Provided Number of Outbound Streams: %u",u_data->assoc->outstream1);
277                 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page2->max_out), label_txt);
278                 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));
279                 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page2->max_out), label_txt);
280         }
281         else
282         {
283                 g_snprintf(label_txt, 50,"Used Number of Inbound Streams: %u",u_data->assoc->instream1);
284                 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page2->max_in), label_txt);
285                 g_snprintf(label_txt, 50,"Used Number of Outbound Streams: %u",u_data->assoc->outstream1);
286                 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page2->max_out), label_txt);
287         }
288
289         if (u_data->assoc->initack == TRUE && u_data->assoc->initack_dir == 2)
290                 gtk_frame_set_label(GTK_FRAME (u_data->analyse_nb->page3->addr_frame), "Complete list of IP-Addresses as provided in the INITACK-Chunk");
291         else
292                 gtk_frame_set_label(GTK_FRAME (u_data->analyse_nb->page3->addr_frame), "List of used IP-Addresses");
293
294
295         if (u_data->assoc->addr2 != NULL)
296         {
297
298                 list = g_list_first(u_data->assoc->addr2);
299
300                 while (list)
301                 {
302                         data[0] = &field[0][0];
303                         store = (address *) (list->data);
304                         if (store->type == AT_IPv4)
305                         {
306                                 g_snprintf(field[0], 30, "%s", ip_to_str((const guint8 *)(store->data)));
307                         }
308                         else if (store->type == AT_IPv6)
309                         {
310                                 g_snprintf(field[0], 40, "%s", ip6_to_str((const struct e_in6_addr *)(store->data)));
311                         }
312                         added_row = gtk_clist_append(GTK_CLIST(u_data->analyse_nb->page3->clist), data);
313                         gtk_clist_set_row_data(GTK_CLIST(u_data->analyse_nb->page3->clist), added_row, u_data->assoc);
314                         list = g_list_next(list);
315                 }
316         }
317                 else
318         {
319                 return;
320         }
321
322         g_snprintf(label_txt, 50,"Port: %u",u_data->assoc->port2);
323         gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page3->port), label_txt);
324         g_snprintf(label_txt, 50,"Sent Verification Tag: 0x%x",u_data->assoc->verification_tag2);
325         gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page3->veritag), label_txt);
326
327         if (u_data->assoc->initack == TRUE)
328         {
329                 g_snprintf(label_txt, 50,"Requested Number of Inbound Streams: %u",u_data->assoc->instream2);
330                 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page3->max_in), label_txt);
331                 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));
332                 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page3->min_in), label_txt);
333
334                 g_snprintf(label_txt, 50,"Provided Number of Outbound Streams: %u",u_data->assoc->outstream2);
335                 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page3->max_out), label_txt);
336                 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));
337                 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page3->min_out), label_txt);
338         }
339         else
340         {
341                 g_snprintf(label_txt, 50,"Used Number of Inbound Streams: %u",u_data->assoc->instream2);
342                 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page3->max_in), label_txt);
343                 g_snprintf(label_txt, 50,"Used Number of Outbound Streams: %u",u_data->assoc->outstream2);
344                 gtk_label_set_text(GTK_LABEL(u_data->analyse_nb->page3->min_out), label_txt);
345         }
346 }
347
348
349 void
350 sctp_set_filter (GtkButton *button _U_, struct sctp_analyse* u_data)
351 {
352         gchar *f_string = NULL;
353         GList *srclist, *dstlist;
354         gchar *str=NULL;
355         GString *gstring=NULL;
356         struct sockaddr_in *infosrc=NULL;
357         struct sockaddr_in *infodst=NULL;
358         sctp_assoc_info_t *selected_stream;
359         gchar *filter_string = NULL;
360         selected_stream=u_data->assoc;
361         
362         if (selected_stream->check_address==FALSE)
363         {
364                 f_string = g_strdup_printf("((sctp.srcport==%u && sctp.dstport==%u && ((sctp.verification_tag==0x%x && sctp.verification_tag!=0x0) || "
365                                                 "(sctp.verification_tag==0x0 && sctp.initiate_tag==0x%x) || "
366                                                 "(sctp.verification_tag==0x%x && (sctp.abort_t_bit==1 || sctp.shutdown_complete_t_bit==1)))) ||"
367                                                 "(sctp.srcport==%u && sctp.dstport==%u && ((sctp.verification_tag==0x%x && sctp.verification_tag!=0x0) || "
368                                                 "(sctp.verification_tag==0x0 && sctp.initiate_tag==0x%x) ||"
369                                                 "(sctp.verification_tag==0x%x && (sctp.abort_t_bit==1 || sctp.shutdown_complete_t_bit==1)))))",
370                 selected_stream->port1,
371                 selected_stream->port2,
372                 selected_stream->verification_tag1,
373                 /*selected_stream->verification_tag2,*/
374                 selected_stream->initiate_tag,
375                 selected_stream->verification_tag2,
376                 selected_stream->port2,
377                 selected_stream->port1,
378                 selected_stream->verification_tag2,
379                 /*selected_stream->verification_tag1,*/
380                 selected_stream->initiate_tag,
381                 selected_stream->verification_tag1);
382                 filter_string = f_string;
383         }
384         else
385         {
386                 srclist = g_list_first(selected_stream->addr1);
387                 infosrc=(struct sockaddr_in *) (srclist->data);
388                 gstring = g_string_new(g_strdup_printf("((sctp.srcport==%u && sctp.dstport==%u && (ip.src==%s",
389                         selected_stream->port1, selected_stream->port2, ip_to_str((const guint8 *)&(infosrc->sin_addr.s_addr))));
390                 srclist= g_list_next(srclist);
391
392                 while (srclist)
393                 {
394                         infosrc=(struct sockaddr_in *) (srclist->data);
395                         str =g_strdup_printf("|| ip.src==%s",ip_to_str((const guint8 *)&(infosrc->sin_addr.s_addr)));
396                         g_string_append(gstring, str);
397                         srclist= g_list_next(srclist);
398                 }
399
400                 dstlist = g_list_first(selected_stream->addr2);
401                 infodst=(struct sockaddr_in *) (dstlist->data);
402                 str = g_strdup_printf(") && (ip.dst==%s",ip_to_str((const guint8 *)&(infodst->sin_addr.s_addr)));
403                 g_string_append(gstring, str);
404                 dstlist= g_list_next(dstlist);
405                 while (dstlist)
406                 {
407                         infodst=(struct sockaddr_in *) (dstlist->data);
408                         str =g_strdup_printf("|| ip.dst==%s",ip_to_str((const guint8 *)&(infodst->sin_addr.s_addr)));
409                         g_string_append(gstring, str);
410                         dstlist= g_list_next(dstlist);
411                 }
412
413                 srclist = g_list_first(selected_stream->addr1);
414                 infosrc=(struct sockaddr_in *) (srclist->data);
415                 str = g_strdup_printf(")) || (sctp.dstport==%u && sctp.srcport==%u && (ip.dst==%s",
416                         selected_stream->port1, selected_stream->port2, ip_to_str((const guint8 *)&(infosrc->sin_addr.s_addr)));
417                 g_string_append(gstring, str);
418                 srclist= g_list_next(srclist);
419
420                 while (srclist)
421                 {
422                         infosrc=(struct sockaddr_in *) (srclist->data);
423                         str =g_strdup_printf("|| ip.dst==%s",ip_to_str((const guint8 *)&(infosrc->sin_addr.s_addr)));
424                         g_string_append(gstring, str);
425                         srclist= g_list_next(srclist);
426                 }
427
428                 dstlist = g_list_first(selected_stream->addr2);
429                 infodst=(struct sockaddr_in *) (dstlist->data);
430                 str = g_strdup_printf(") && (ip.src==%s",ip_to_str((const guint8 *)&(infodst->sin_addr.s_addr)));
431                 g_string_append(gstring, str);
432                 dstlist= g_list_next(dstlist);
433                 while (dstlist)
434                 {
435                         infodst=(struct sockaddr_in *) (dstlist->data);
436                         str =g_strdup_printf("|| ip.src==%s",ip_to_str((const guint8 *)&(infodst->sin_addr.s_addr)));
437                         g_string_append(gstring, str);
438                         dstlist= g_list_next(dstlist);
439                 }
440                 str = g_strdup_printf(")))");
441                 g_string_append(gstring, str);
442                 filter_string = gstring->str;
443                 g_string_free(gstring,FALSE);
444         }
445         
446         if (filter_string != NULL) {
447                 gtk_entry_set_text(GTK_ENTRY(main_display_filter_widget), filter_string);
448         } else {
449                 g_assert_not_reached();
450         }
451 }
452
453 static void analyse_window_set_title(struct sctp_analyse *u_data)
454 {
455         char *title;
456         
457         if(!u_data->window){
458                 return;
459         }
460         title = g_strdup_printf("SCTP Analyse Association: %s Port1 %u  Port2 %u", cf_get_display_name(&cfile), u_data->assoc->port1, u_data->assoc->port2);
461         gtk_window_set_title(GTK_WINDOW(u_data->window), title);
462         g_free(title);
463 }
464
465 static void create_analyse_window(struct sctp_analyse* u_data)
466 {
467         GtkWidget *window = NULL;
468         GtkWidget *notebook;
469         GtkWidget *main_vb, *page1, *page2, *page3, *hbox, *vbox_l, *vbox_r, *addr_hb, *stat_fr;
470         GtkWidget *hbox_l1, *hbox_l2,*label, *h_button_box;
471         GtkWidget *chunk_stat_bt, *close_bt, *graph_bt1, *graph_bt2, *chunk_bt1, *bt_filter;
472
473         u_data->analyse_nb = g_malloc(sizeof(struct notes));
474         window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
475         gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
476         SIGNAL_CONNECT(window, "destroy", on_destroy,u_data);
477
478         /* Container for each row of widgets */
479         main_vb = gtk_vbox_new(FALSE, 2);
480         gtk_container_border_width(GTK_CONTAINER(main_vb), 2);
481         gtk_container_add(GTK_CONTAINER(window), main_vb);
482         gtk_widget_show(main_vb);
483
484         /* Start a notebook for flipping between sets of changes */
485         notebook = gtk_notebook_new();
486         gtk_container_add(GTK_CONTAINER(main_vb), notebook);
487         g_object_set_data(G_OBJECT(window), "notebook", notebook);
488         SIGNAL_CONNECT(notebook, "switch_page", on_notebook_switch_page,NULL);
489
490         page1 = gtk_vbox_new(FALSE, 8);
491         gtk_container_set_border_width(GTK_CONTAINER(page1), 8);
492
493         u_data->analyse_nb->checktype = gtk_label_new("");
494         gtk_box_pack_start(GTK_BOX(page1), u_data->analyse_nb->checktype, TRUE, TRUE, 0);
495
496         gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->checktype),0,0);
497
498         u_data->analyse_nb->checksum = gtk_label_new("");
499         gtk_box_pack_start(GTK_BOX(page1), u_data->analyse_nb->checksum, TRUE, TRUE, 0);
500         gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->checksum),0,0);
501
502         u_data->analyse_nb->bundling = gtk_label_new("");
503         gtk_box_pack_start(GTK_BOX(page1), u_data->analyse_nb->bundling, TRUE, TRUE, 0);
504         gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->bundling),0,0);
505
506         u_data->analyse_nb->padding = gtk_label_new("");
507         gtk_box_pack_start(GTK_BOX(page1), u_data->analyse_nb->padding, TRUE, TRUE, 0);
508         gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->padding),0,0);
509
510         u_data->analyse_nb->length = gtk_label_new("");
511         gtk_box_pack_start(GTK_BOX(page1), u_data->analyse_nb->length, TRUE, TRUE, 0);
512         gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->length),0,0);
513
514         u_data->analyse_nb->value = gtk_label_new("");
515         gtk_box_pack_start(GTK_BOX(page1), u_data->analyse_nb->value, TRUE, TRUE, 0);
516         gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->value),0,0);
517
518
519         u_data->analyse_nb->chunks_ep1 = gtk_label_new("");
520         gtk_box_pack_start(GTK_BOX(page1), u_data->analyse_nb->chunks_ep1, TRUE, TRUE, 0);
521         gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->chunks_ep1),0,0);
522         u_data->analyse_nb->bytes_ep1 = gtk_label_new("");
523         gtk_box_pack_start(GTK_BOX(page1), u_data->analyse_nb->bytes_ep1, TRUE, TRUE, 0);
524         gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->bytes_ep1),0,0);
525         u_data->analyse_nb->chunks_ep2 = gtk_label_new("");
526         gtk_box_pack_start(GTK_BOX(page1), u_data->analyse_nb->chunks_ep2, TRUE, TRUE, 0);
527         gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->chunks_ep2),0,0);
528         u_data->analyse_nb->bytes_ep2 = gtk_label_new("");
529         gtk_box_pack_start(GTK_BOX(page1), u_data->analyse_nb->bytes_ep2, TRUE, TRUE, 0);
530         gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->bytes_ep2),0,0);
531
532         hbox = gtk_hbutton_box_new();
533         gtk_box_pack_start(GTK_BOX(page1), hbox, FALSE, FALSE, 0);
534         gtk_container_set_border_width(GTK_CONTAINER(hbox), 10);
535         gtk_button_box_set_layout(GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_SPREAD);
536         gtk_button_box_set_spacing(GTK_BUTTON_BOX (hbox), 0);
537         gtk_button_box_set_child_ipadding(GTK_BUTTON_BOX (hbox), 4, 0);
538         gtk_widget_show(hbox);
539
540         chunk_stat_bt = gtk_button_new_with_label ("Chunk Statistics");
541         gtk_box_pack_start(GTK_BOX(hbox), chunk_stat_bt, FALSE, FALSE, 0);
542         gtk_widget_show(chunk_stat_bt);
543         SIGNAL_CONNECT(chunk_stat_bt, "clicked", on_chunk_stat_bt, u_data);
544
545         bt_filter = gtk_button_new_with_label ("Set filter");
546         gtk_box_pack_start(GTK_BOX(hbox), bt_filter, FALSE, FALSE, 0);
547         gtk_widget_show (bt_filter);
548         SIGNAL_CONNECT(bt_filter, "clicked", sctp_set_filter, u_data);
549
550         close_bt = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
551         gtk_box_pack_start(GTK_BOX(hbox), close_bt, FALSE, FALSE, 0);
552         gtk_widget_show(close_bt);
553         SIGNAL_CONNECT(close_bt, "clicked", on_close_dlg, u_data);
554
555         /* tab */
556         label = gtk_label_new(" Statistics ");
557         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page1, label);
558
559
560         /*  page for endpoint 1 */
561         page2 = gtk_vbox_new(FALSE, 8);
562         gtk_container_set_border_width(GTK_CONTAINER(page2), 8);
563
564         u_data->analyse_nb->page2 = g_malloc(sizeof(struct page));
565
566         u_data->analyse_nb->page2->addr_frame = gtk_frame_new(NULL);
567         gtk_container_add(GTK_CONTAINER(page2), u_data->analyse_nb->page2->addr_frame);
568
569         addr_hb = gtk_hbox_new(FALSE, 3);
570         gtk_container_border_width(GTK_CONTAINER(addr_hb), 5);
571         gtk_container_add(GTK_CONTAINER(u_data->analyse_nb->page2->addr_frame), addr_hb);
572
573         u_data->analyse_nb->page2->scrolled_window = scrolled_window_new(NULL, NULL);
574         gtk_widget_set_size_request(u_data->analyse_nb->page2->scrolled_window, 560, 100);
575
576         u_data->analyse_nb->page2->clist = gtk_clist_new(1);
577         gtk_widget_show(u_data->analyse_nb->page2->clist);
578
579         gtk_clist_set_column_width(GTK_CLIST(u_data->analyse_nb->page2->clist), 0, 200);
580         gtk_clist_set_column_justification(GTK_CLIST(u_data->analyse_nb->page2->clist), 0, GTK_JUSTIFY_LEFT);
581
582         gtk_container_add(GTK_CONTAINER(u_data->analyse_nb->page2->scrolled_window), u_data->analyse_nb->page2->clist);
583
584         gtk_box_pack_start(GTK_BOX(addr_hb), u_data->analyse_nb->page2->scrolled_window, TRUE, TRUE, 0);
585         gtk_widget_show(u_data->analyse_nb->page2->scrolled_window);
586
587         stat_fr = gtk_frame_new(NULL);
588         gtk_container_add(GTK_CONTAINER(page2), stat_fr);
589
590         hbox = gtk_hbox_new(FALSE,3);
591         gtk_container_border_width(GTK_CONTAINER(hbox), 5);
592         gtk_container_add(GTK_CONTAINER(stat_fr), hbox);
593
594         vbox_l = gtk_vbox_new(FALSE, 3);
595         gtk_box_pack_start(GTK_BOX(hbox), vbox_l, TRUE, TRUE, 0);
596
597
598
599         hbox_l1 = gtk_hbox_new(FALSE,3);
600         gtk_box_pack_start(GTK_BOX(vbox_l), hbox_l1, TRUE, TRUE, 0);
601
602         u_data->analyse_nb->page2->port = gtk_label_new("");
603         gtk_box_pack_start(GTK_BOX(hbox_l1), u_data->analyse_nb->page2->port, TRUE, TRUE, 0);
604         gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->page2->port),0,0);
605
606         hbox_l2 = gtk_hbox_new(FALSE,3);
607         gtk_box_pack_start(GTK_BOX(vbox_l), hbox_l2, TRUE, TRUE, 0);
608
609
610         u_data->analyse_nb->page2->veritag = gtk_label_new("");
611
612         gtk_box_pack_start(GTK_BOX(hbox_l2), u_data->analyse_nb->page2->veritag, TRUE, TRUE, 0);
613         gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->page2->veritag),0,0);
614         gtk_widget_show(vbox_l);
615
616         vbox_r = gtk_vbox_new(FALSE, 3);
617         gtk_box_pack_start(GTK_BOX(hbox), vbox_r, TRUE, TRUE, 0);
618
619         u_data->analyse_nb->page2->max_in = gtk_label_new("");
620         gtk_box_pack_start(GTK_BOX(vbox_r), u_data->analyse_nb->page2->max_in, TRUE, TRUE, 0);
621         gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->page2->max_in),0,0);
622         u_data->analyse_nb->page2->min_in = gtk_label_new("");
623         gtk_box_pack_start(GTK_BOX(vbox_r), u_data->analyse_nb->page2->min_in, TRUE, TRUE, 0);
624         gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->page2->min_in),0,0);
625
626         u_data->analyse_nb->page2->max_out = gtk_label_new("");
627         gtk_box_pack_start(GTK_BOX(vbox_r), u_data->analyse_nb->page2->max_out, TRUE, TRUE, 0);
628         gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->page2->max_out),0,0);
629         u_data->analyse_nb->page2->min_out = gtk_label_new("");
630         gtk_box_pack_start(GTK_BOX(vbox_r), u_data->analyse_nb->page2->min_out, TRUE, TRUE, 0);
631         gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->page2->min_out),0,0);
632
633
634         gtk_widget_show(vbox_r);
635
636         h_button_box=gtk_hbutton_box_new();
637         gtk_box_pack_start(GTK_BOX(page2), h_button_box, FALSE, FALSE, 0);
638         gtk_container_set_border_width(GTK_CONTAINER(h_button_box), 10);
639         gtk_button_box_set_layout(GTK_BUTTON_BOX (h_button_box), GTK_BUTTONBOX_SPREAD);
640         gtk_button_box_set_spacing(GTK_BUTTON_BOX (h_button_box), 0);
641         gtk_button_box_set_child_ipadding(GTK_BUTTON_BOX (h_button_box), 4, 0);
642         gtk_widget_show(h_button_box);
643         
644         chunk_bt1 = gtk_button_new_with_label("Chunk Statistics");
645         gtk_box_pack_start(GTK_BOX(h_button_box), chunk_bt1, FALSE, FALSE, 0);
646         gtk_widget_show(chunk_bt1);
647         SIGNAL_CONNECT(chunk_bt1, "clicked", on_chunk1_dlg,u_data);
648
649         graph_bt1 = gtk_button_new_with_label("Graph TSN");
650         gtk_box_pack_start(GTK_BOX(h_button_box), graph_bt1, FALSE, FALSE, 0);
651         gtk_widget_show(graph_bt1);
652         SIGNAL_CONNECT(graph_bt1, "clicked", on_graph1_dlg,u_data);
653
654         graph_bt2 = gtk_button_new_with_label("Graph Bytes");
655         gtk_box_pack_start(GTK_BOX(h_button_box), graph_bt2, FALSE, FALSE, 0);
656         gtk_widget_show(graph_bt2);
657         SIGNAL_CONNECT(graph_bt2, "clicked", on_graph_byte1_dlg,u_data);
658         if (u_data->assoc->n_array_tsn1==0)
659         {
660                 gtk_widget_set_sensitive(graph_bt1, FALSE);
661                 gtk_widget_set_sensitive(graph_bt2, FALSE);
662         }
663         close_bt = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
664         gtk_box_pack_start(GTK_BOX(h_button_box), close_bt, FALSE, FALSE, 0);
665         gtk_widget_show(close_bt);
666         SIGNAL_CONNECT(close_bt, "clicked", on_close_dlg, u_data);
667
668         label = gtk_label_new(" Endpoint 1 ");
669         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page2, label);
670
671         /* same page for endpoint 2*/
672
673         page3 = gtk_vbox_new(FALSE, 8);
674         gtk_container_set_border_width(GTK_CONTAINER(page3), 8);
675         u_data->analyse_nb->page3 = g_malloc(sizeof(struct page));
676         u_data->analyse_nb->page3->addr_frame = gtk_frame_new(NULL);
677
678         gtk_container_add(GTK_CONTAINER(page3), u_data->analyse_nb->page3->addr_frame);
679
680         addr_hb = gtk_hbox_new(FALSE, 3);
681         gtk_container_border_width(GTK_CONTAINER(addr_hb), 5);
682         gtk_container_add(GTK_CONTAINER(u_data->analyse_nb->page3->addr_frame), addr_hb);
683
684         u_data->analyse_nb->page3->scrolled_window = scrolled_window_new(NULL, NULL);
685         gtk_widget_set_size_request(u_data->analyse_nb->page3->scrolled_window, 560, 100);
686
687         u_data->analyse_nb->page3->clist = gtk_clist_new(1);
688         gtk_widget_show(u_data->analyse_nb->page3->clist);              
689
690         gtk_clist_set_column_width(GTK_CLIST(u_data->analyse_nb->page3->clist), 0, 200);
691         gtk_clist_set_column_justification(GTK_CLIST(u_data->analyse_nb->page3->clist), 0, GTK_JUSTIFY_LEFT);
692
693         gtk_container_add(GTK_CONTAINER(u_data->analyse_nb->page3->scrolled_window),
694         u_data->analyse_nb->page3->clist);
695
696         gtk_box_pack_start(GTK_BOX(addr_hb), u_data->analyse_nb->page3->scrolled_window, TRUE, TRUE, 0);
697         gtk_widget_show(u_data->analyse_nb->page3->scrolled_window);
698
699         stat_fr = gtk_frame_new(NULL);
700         gtk_container_add(GTK_CONTAINER(page3), stat_fr);
701
702         hbox = gtk_hbox_new(FALSE,3);
703         gtk_container_border_width(GTK_CONTAINER(hbox), 5);
704         gtk_container_add(GTK_CONTAINER(stat_fr), hbox);
705
706         vbox_l = gtk_vbox_new(FALSE, 3);
707         gtk_box_pack_start(GTK_BOX(hbox), vbox_l, TRUE, TRUE, 0);
708                 
709         hbox_l1 = gtk_hbox_new(FALSE,3);
710         gtk_box_pack_start(GTK_BOX(vbox_l), hbox_l1, TRUE, TRUE, 0);
711
712         u_data->analyse_nb->page3->port = gtk_label_new("");
713         gtk_box_pack_start(GTK_BOX(hbox_l1), u_data->analyse_nb->page3->port, TRUE, TRUE, 0);
714         gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->page3->port),0,0);
715
716         hbox_l2 = gtk_hbox_new(FALSE,3);
717         gtk_box_pack_start(GTK_BOX(vbox_l), hbox_l2, TRUE, TRUE, 0);
718
719
720         u_data->analyse_nb->page3->veritag = gtk_label_new("");
721         gtk_box_pack_start(GTK_BOX(hbox_l2), u_data->analyse_nb->page3->veritag, TRUE, TRUE, 0);
722         gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->page3->veritag),0,0);
723         gtk_widget_show(vbox_l);
724
725         vbox_r=gtk_vbox_new(FALSE, 3);
726         gtk_box_pack_start(GTK_BOX(hbox), vbox_r, TRUE, TRUE, 0);
727
728         u_data->analyse_nb->page3->max_in = gtk_label_new("");
729         gtk_box_pack_start(GTK_BOX(vbox_r), u_data->analyse_nb->page3->max_in, TRUE, TRUE, 0);
730         gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->page3->max_in),0,0);
731         u_data->analyse_nb->page3->min_in = gtk_label_new("");
732         gtk_box_pack_start(GTK_BOX(vbox_r), u_data->analyse_nb->page3->min_in, TRUE, TRUE, 0);
733         gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->page3->min_in),0,0);               
734
735         u_data->analyse_nb->page3->max_out = gtk_label_new("");
736         gtk_box_pack_start(GTK_BOX(vbox_r), u_data->analyse_nb->page3->max_out, TRUE, TRUE, 0);
737         gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->page3->max_out),0,0);
738         u_data->analyse_nb->page3->min_out = gtk_label_new("");
739         gtk_box_pack_start(GTK_BOX(vbox_r), u_data->analyse_nb->page3->min_out, TRUE, TRUE, 0);
740         gtk_misc_set_alignment (GTK_MISC(u_data->analyse_nb->page3->min_out),0,0);
741
742         gtk_widget_show(vbox_r);
743
744         h_button_box=gtk_hbutton_box_new();
745         gtk_box_pack_start(GTK_BOX(page3), h_button_box, FALSE, FALSE, 0);
746         gtk_container_set_border_width(GTK_CONTAINER(h_button_box), 10);
747         gtk_button_box_set_layout(GTK_BUTTON_BOX (h_button_box), GTK_BUTTONBOX_SPREAD);
748         gtk_button_box_set_spacing(GTK_BUTTON_BOX (h_button_box), 0);
749         gtk_button_box_set_child_ipadding(GTK_BUTTON_BOX (h_button_box), 4, 0);
750         gtk_widget_show(h_button_box);
751         
752         chunk_bt1 = gtk_button_new_with_label("Chunk Statistics");
753         gtk_box_pack_start(GTK_BOX(h_button_box), chunk_bt1, FALSE, FALSE, 0);
754         gtk_widget_show(chunk_bt1);
755         SIGNAL_CONNECT(chunk_bt1, "clicked", on_chunk2_dlg, u_data);
756         
757         graph_bt1 = gtk_button_new_with_label("Graph TSN");
758         gtk_box_pack_start(GTK_BOX(h_button_box), graph_bt1, FALSE, FALSE, 0);
759         gtk_widget_show(graph_bt1);
760         SIGNAL_CONNECT(graph_bt1, "clicked", on_graph2_dlg, u_data);
761         graph_bt2 = gtk_button_new_with_label("Graph Bytes");
762         gtk_box_pack_start(GTK_BOX(h_button_box), graph_bt2, FALSE, FALSE, 0);
763         gtk_widget_show(graph_bt2);
764         SIGNAL_CONNECT(graph_bt2, "clicked", on_graph_byte2_dlg,u_data);
765         if (u_data->assoc->n_array_tsn2==0)
766         {
767                 gtk_widget_set_sensitive(graph_bt1, FALSE);
768                 gtk_widget_set_sensitive(graph_bt2, FALSE);
769         }
770         close_bt = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
771         gtk_box_pack_start(GTK_BOX(h_button_box), close_bt, FALSE, FALSE, 0);
772         gtk_widget_show(close_bt);
773         SIGNAL_CONNECT(close_bt, "clicked", on_close_dlg, u_data);
774
775         label = gtk_label_new(" Endpoint 2 ");
776         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page3, label);
777
778         /* show all notebooks */
779         gtk_widget_show_all(notebook);
780
781         gtk_widget_show(window);
782
783         u_data->window = window;
784         analyse_window_set_title(u_data);
785
786         update_analyse_dlg(u_data);
787 }
788
789
790
791 void assoc_analyse(sctp_assoc_info_t* assoc)
792 {
793         struct sctp_analyse* u_data;
794         int i;
795
796         u_data = g_malloc(sizeof(struct sctp_analyse));
797         u_data->assoc = assoc;
798         u_data->assoc->addr_chunk_count = assoc->addr_chunk_count;
799         u_data->window = NULL;
800         u_data->analyse_nb = NULL;
801         u_data->children = NULL;
802         u_data->num_children = 0;
803         static_assoc.addr_chunk_count =assoc->addr_chunk_count;
804         static_assoc.port1 = assoc->port1;
805         static_assoc.port2 = assoc->port2;
806         for (i=0; i<NUM_CHUNKS; i++)
807         {
808                 static_assoc.chunk_count[i]     = assoc->chunk_count[i];
809                 static_assoc.ep1_chunk_count[i] = assoc->ep1_chunk_count[i];
810                 static_assoc.ep2_chunk_count[i] = assoc->ep2_chunk_count[i];
811         }
812         set_analyse_child(u_data);
813         increase_analyse_childcount();
814         static_assoc.addr_chunk_count = assoc->addr_chunk_count;
815         create_analyse_window(u_data);
816 }
817
818
819 static void sctp_analyse_cb(struct sctp_analyse* u_data, gboolean ext)
820 {
821         guint8* ip_src;
822         guint16 srcport;
823         guint8* ip_dst;
824         guint16 dstport;
825         GList *list, *framelist;
826         dfilter_t *sfcode;
827         capture_file *cf;
828         epan_dissect_t *edt;
829         gint err;
830         gchar *err_info;
831         gboolean frame_matched, frame_found = FALSE;
832         frame_data *fdata;
833         gchar filter_text[256];
834         sctp_assoc_info_t* assoc = NULL;
835         int i;
836         guint32 *fn;
837
838         g_strlcpy(filter_text,"sctp",250);
839         if (!dfilter_compile(filter_text, &sfcode)) {
840                 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, dfilter_error_msg);
841                 return;
842         }
843
844         cf = &cfile;
845         fdata = cf->current_frame;
846
847         /* we are on the selected frame now */
848         if (fdata == NULL)
849                 return; /* if we exit here it's an error */
850
851         /* dissect the current frame */
852         if (!wtap_seek_read(cf->wth, fdata->file_off, &cf->pseudo_header,
853             cf->pd, fdata->cap_len, &err, &err_info)) {
854                 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
855                         cf_read_error_message(err, err_info), cf->filename);
856                 return;
857         }
858
859         edt = epan_dissect_new(TRUE, FALSE);
860         epan_dissect_prime_dfilter(edt, sfcode);
861         epan_dissect_run(edt, &cf->pseudo_header, cf->pd, fdata, NULL);
862         frame_matched = dfilter_apply_edt(sfcode, edt);
863
864         /* if it is not an sctp frame, show the dialog */
865
866         if (frame_matched != 1) {
867                 epan_dissect_free(edt);
868                 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
869                     "Please choose an SCTP packet!");
870                 return;
871         }
872
873         ip_src = g_malloc(edt->pi.net_src.len);
874         memcpy(ip_src, edt->pi.net_src.data, edt->pi.net_src.len);
875         ip_dst = g_malloc(edt->pi.net_dst.len);
876         memcpy(ip_dst, edt->pi.net_dst.data, edt->pi.net_dst.len);
877         srcport = edt->pi.srcport;
878         dstport = edt->pi.destport;
879         list = g_list_first(sctp_stat_get_info()->assoc_info_list);
880
881         while (list)
882         {
883                 assoc = (sctp_assoc_info_t*)(list->data);
884                 framelist = g_list_first(assoc->frame_numbers);
885                 while(framelist)
886                 {
887                         fn = (guint32 *)framelist->data;
888                         if (*fn == fdata->num)
889                         {
890                                 frame_found = TRUE;
891                                 break;
892                         }
893                         framelist = g_list_next(framelist);
894                 }
895                 if (frame_found)
896                 {
897                         u_data->assoc = assoc;
898                         u_data->assoc->addr_chunk_count = assoc->addr_chunk_count;
899                         static_assoc.addr_chunk_count = assoc->addr_chunk_count;
900                         static_assoc.port1 = assoc->port1;
901                         static_assoc.port2 = assoc->port2;
902                         for (i=0; i<NUM_CHUNKS; i++)
903                         {
904                                 static_assoc.chunk_count[i]     = assoc->chunk_count[i];
905                                 static_assoc.ep1_chunk_count[i] = assoc->ep1_chunk_count[i];
906                                 static_assoc.ep2_chunk_count[i] = assoc->ep2_chunk_count[i];
907                         }
908                         if (ext == FALSE)
909                                 create_analyse_window(u_data);
910                         return;
911                 }
912                 else
913                         list = g_list_next(list);
914
915         }
916         if (!frame_found)
917                 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Assoc not found!");
918 }
919
920 void sctp_set_assoc_filter(void)
921 {
922 struct sctp_analyse * u_data;
923
924         /* Register the tap listener */
925         if (sctp_stat_get_info()->is_registered == FALSE)
926                 register_tap_listener_sctp_stat();
927         /* (redissect all packets) */
928
929         sctp_stat_scan();
930         u_data = g_malloc(sizeof(struct sctp_analyse));
931         u_data->assoc        = NULL;
932         u_data->children     = NULL;
933         u_data->analyse_nb   = NULL;
934         u_data->window       = NULL;
935         u_data->num_children = 0;
936         cf_retap_packets(&cfile, FALSE);
937         sctp_analyse_cb(u_data, TRUE);
938         sctp_set_filter(NULL, u_data);
939 }
940
941 void sctp_analyse_start(GtkWidget *w _U_, gpointer data _U_)
942 {
943         struct sctp_analyse * u_data;
944
945         /* Register the tap listener */
946         if (sctp_stat_get_info()->is_registered == FALSE)
947                 register_tap_listener_sctp_stat();
948         /* (redissect all packets) */
949         
950         sctp_stat_scan();
951
952         u_data = g_malloc(sizeof(struct sctp_analyse));
953         u_data->assoc        = NULL;
954         u_data->children     = NULL;
955         u_data->analyse_nb   = NULL;
956         u_data->window       = NULL;
957         u_data->num_children = 0;
958
959         cf_retap_packets(&cfile, FALSE);
960         sctp_analyse_cb(u_data, FALSE);
961 }
962
963
964 void
965 register_tap_listener_sctp_analyse(void)
966 {
967         register_stat_menu_item("SCTP/Analyse this Association", REGISTER_STAT_GROUP_TELEPHONY,
968                                sctp_analyse_start, NULL, NULL, NULL);
969 }