b43683a17d4a9942d1d06bbd1fd06fd00b77454f
[obnox/wireshark/wip.git] / gtk / flow_graph.c
1 /* flow_graph.c
2  * $Id:$
3  * Allows to display a flow graph of the currently displayed packets
4  *
5  * Copyright 2004, Ericsson , Spain
6  * By Francisco Alcoba <francisco.alcoba@ericsson.com>
7  *
8  * Ethereal - Network traffic analyzer
9  * By Gerald Combs <gerald@ethereal.com>
10  * Copyright 1998 Gerald Combs
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation,  Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25  */
26
27 #ifdef HAVE_CONFIG_H
28 #  include <config.h>
29 #endif
30
31 #include "register.h"
32
33 #include "globals.h"
34 #include "epan/filesystem.h"
35
36 #include "graph_analysis.h"
37 #include <epan/stat_cmd_args.h>
38 #include "../stat_menu.h"
39 #include "gui_stat_menu.h"
40 #include "dlg_utils.h"
41 #include "gui_utils.h"
42 #include "compat_macros.h"
43 #include "gtkglobals.h"
44
45 #include "simple_dialog.h"
46
47 #include <epan/to_str.h>
48 #include <epan/tap.h>
49 #include <epan/dissectors/packet-tcp.h>
50
51 #include <string.h>
52
53 #define DISPLAYED 0
54 #define ALL 1
55 #define GENERAL 0
56 #define TCP 1
57 #define SRCDST 0
58 #define NET_SRCDST 1
59
60 static int type_of_packets = DISPLAYED;
61 static int type_of_flow = GENERAL;
62 static int node_addr_type = SRCDST;
63
64 static int tap_identifier;
65 static gboolean have_frame_tap_listener=FALSE;
66 static gboolean have_tcp_tap_listener=FALSE;
67 static graph_analysis_info_t *graph_analysis = NULL;
68 static graph_analysis_data_t *graph_analysis_data;
69
70 static GtkWidget *flow_graph_dlg = NULL;
71
72 static GtkWidget *select_all_rb;
73 static GtkWidget *select_displayed_rb;
74 static GtkWidget *select_general_rb;
75 static GtkWidget *select_tcp_rb;
76 static GtkWidget *src_dst_rb;
77 static GtkWidget *net_src_dst_rb;
78
79 void flow_graph_data_init(void);
80
81
82 /****************************************************************************/
83 /* free up memory and initialize the pointers */
84
85 static void flow_graph_reset(void *ptr _U_)
86 {
87
88         graph_analysis_item_t *graph_item;
89         
90         GList* list;
91
92         if (graph_analysis !=NULL){
93
94                 /* free the graph data items */
95                 list = g_list_first(graph_analysis->list);
96                 while (list)
97                 {
98                         graph_item = list->data;
99                         g_free(graph_item->frame_label);
100                         g_free(graph_item->comment);
101                         g_free(list->data);
102                         list = g_list_next(list);
103                 }
104                 g_list_free(graph_analysis->list);
105                 graph_analysis->nconv = 0;
106                 graph_analysis->list = NULL;
107         }
108         return;
109 }
110
111 /****************************************************************************/
112 void flow_graph_data_init(void) {
113         graph_analysis = g_malloc(sizeof(graph_analysis_info_t));
114         graph_analysis->nconv = 0;
115         graph_analysis->list = NULL;
116         return;
117 }
118
119 /* XXX just copied from gtk/rpc_stat.c */
120 void protect_thread_critical_region(void);
121 void unprotect_thread_critical_region(void);
122
123 /****************************************************************************/
124 static void
125 remove_tap_listener_flow_graph(void)
126 {
127         protect_thread_critical_region();
128         remove_tap_listener(&(tap_identifier));
129         unprotect_thread_critical_region();
130
131         have_frame_tap_listener=FALSE;
132         have_tcp_tap_listener=FALSE;
133 }
134
135
136 /****************************************************************************/
137 /* CALLBACKS                                                                */
138 /****************************************************************************/
139 static void
140 flow_graph_on_destroy(GtkObject *object _U_, gpointer user_data _U_)
141 {
142         /* remove_tap_listeners */
143         remove_tap_listener_flow_graph();
144
145         /* Clean up memory used by tap */
146         flow_graph_reset(NULL);
147
148         /* Note that we no longer have a "Flow Graph" dialog box. */
149         flow_graph_dlg = NULL;
150 }
151
152         
153 /****************************************************************************/
154 static void
155 toggle_select_all(GtkWidget *widget _U_, gpointer user_data _U_)
156 {
157   /* is the button now active? */
158         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(select_all_rb))) {
159                 type_of_packets = ALL;
160         }
161 }
162
163 /****************************************************************************/
164 static void
165 toggle_select_displayed(GtkWidget *widget _U_, gpointer user_data _U_)
166 {
167   /* is the button now active? */
168         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(select_displayed_rb))) {
169                 type_of_packets = DISPLAYED;
170         }
171 }
172
173 /****************************************************************************/
174 static void
175 toggle_select_general(GtkWidget *widget _U_, gpointer user_data _U_)
176 {
177   /* is the button now active? */
178         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(select_general_rb))) {
179                 type_of_flow = GENERAL;
180         }
181 }
182
183 /****************************************************************************/
184 static void
185 toggle_select_tcp(GtkWidget *widget _U_, gpointer user_data _U_)
186 {
187   /* is the button now active? */
188         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(select_tcp_rb))) {
189                 type_of_flow = TCP;
190         }
191 }
192
193 /****************************************************************************/
194 static void
195 toggle_select_srcdst(GtkWidget *widget _U_, gpointer user_data _U_)
196 {
197   /* is the button now active? */
198         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(src_dst_rb))) {
199                 node_addr_type = SRCDST;
200         }
201 }
202
203 /****************************************************************************/
204 static void
205 toggle_select_netsrcdst(GtkWidget *widget _U_, gpointer user_data _U_)
206 {
207   /* is the button now active? */
208         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(net_src_dst_rb))) {
209                 node_addr_type = NET_SRCDST;
210         }
211 }
212
213 /****************************************************************************/
214 /* Add a new frame into the graph */
215 static int flow_graph_frame_add_to_graph(packet_info *pinfo)
216 {
217         graph_analysis_item_t *gai;
218         int i;
219         gchar *protocol;
220         gchar *colinfo;
221         
222         protocol=NULL;
223         colinfo=NULL;
224
225         gai = g_malloc(sizeof(graph_analysis_item_t));
226         gai->frame_num = pinfo->fd->num;
227         gai->time= nstime_to_sec(&pinfo->fd->rel_ts);
228         if (node_addr_type == NET_SRCDST) {
229                 COPY_ADDRESS(&(gai->src_addr),&(pinfo->net_src));
230             COPY_ADDRESS(&(gai->dst_addr),&(pinfo->net_dst));
231         } else {
232                 COPY_ADDRESS(&(gai->src_addr),&(pinfo->src));
233                 COPY_ADDRESS(&(gai->dst_addr),&(pinfo->dst));
234         }
235         gai->port_src=pinfo->srcport;
236         gai->port_dst=pinfo->destport;
237         gai->comment=NULL;
238         gai->frame_label=NULL;
239
240         if (gai->comment!=NULL){
241                 g_free(gai->comment);
242         }
243         if (gai->frame_label!=NULL){
244                 g_free(gai->frame_label);
245         }
246
247
248         if (pinfo->cinfo->col_first[COL_INFO]>=0){
249                 
250                 for (i = pinfo->cinfo->col_first[COL_INFO]; i <= pinfo->cinfo->col_last[COL_INFO]; i++) {
251                 if (pinfo->cinfo->fmt_matx[i][COL_INFO]) {
252                                 colinfo = g_strdup(pinfo->cinfo->col_data[i]);
253                         }
254                 }
255         }
256
257         if (pinfo->cinfo->col_first[COL_PROTOCOL]>=0){
258                 
259                 for (i = pinfo->cinfo->col_first[COL_PROTOCOL]; i <= pinfo->cinfo->col_last[COL_PROTOCOL]; i++) {
260                 if (pinfo->cinfo->fmt_matx[i][COL_PROTOCOL]) {
261                                 protocol = g_strdup(pinfo->cinfo->col_data[i]);
262
263                         }
264                 }
265         }
266                 
267         if (colinfo != NULL) {
268                 if (protocol != NULL) {
269                         gai->frame_label = g_strdup_printf("%.19s", colinfo);
270                         gai->comment = g_strdup_printf("%s: %s", protocol, colinfo);
271                 } else {
272                         gai->frame_label = g_strdup_printf("%.19s", colinfo);
273                         gai->comment = g_strdup_printf("%s", colinfo);
274                 }
275         } else {
276                 /* This will probably never happen...*/
277                 if (protocol != NULL) {
278                         gai->frame_label = g_strdup_printf("%.19s", protocol);
279                         gai->comment = g_strdup_printf("%s", protocol);
280                 } else {
281                         gai->frame_label = NULL;
282                         gai->comment = NULL;
283                 }
284         }
285  
286         if (protocol!=NULL){
287                 g_free(protocol);
288         }
289         if (colinfo!=NULL){
290                 g_free(colinfo);
291         }
292
293         gai->line_style=1;
294         gai->conv_num=0;
295         gai->display=TRUE;
296
297         graph_analysis->list = g_list_append(graph_analysis->list, gai);
298
299         return 1;
300
301 }
302
303 /****************************************************************************/
304 /* Add a new tcp frame into the graph */
305 static int flow_graph_tcp_add_to_graph(packet_info *pinfo, const struct tcpheader *tcph)
306 {
307         graph_analysis_item_t *gai;
308         /* copied from packet-tcp */
309         const gchar *fstr[] = {"FIN", "SYN", "RST", "PSH", "ACK", "URG", "ECN", "CWR" };
310         guint i, bpos;
311         guint fpos = 0;
312         gchar flags[64] = "<None>";
313
314         gai = g_malloc(sizeof(graph_analysis_item_t));
315         gai->frame_num = pinfo->fd->num;
316         gai->time= nstime_to_sec(&pinfo->fd->rel_ts);
317   if (node_addr_type == NET_SRCDST) {
318     COPY_ADDRESS(&(gai->src_addr),&(pinfo->net_src));
319     COPY_ADDRESS(&(gai->dst_addr),&(pinfo->net_dst));
320   } else {
321     COPY_ADDRESS(&(gai->src_addr),&(pinfo->src));
322     COPY_ADDRESS(&(gai->dst_addr),&(pinfo->dst));
323   }
324         gai->port_src=pinfo->srcport;
325         gai->port_dst=pinfo->destport;
326
327     for (i = 0; i < 8; i++) {
328       bpos = 1 << i;
329       if (tcph->th_flags & bpos) {
330         if (fpos) {
331           strcpy(&flags[fpos], ", ");
332           fpos += 2;
333         }
334         strcpy(&flags[fpos], fstr[i]);
335         fpos += 3;
336       }
337     }
338     flags[fpos] = '\0';
339     if ((tcph->th_have_seglen)&&(tcph->th_seglen!=0)){
340       gai->frame_label = g_strdup_printf("%s - Len: %u",flags, tcph->th_seglen);
341         }
342         else{
343       gai->frame_label = g_strdup(flags);
344         }      
345
346         gai->comment = g_strdup_printf("Seq = %i Ack = %i",tcph->th_seq, tcph->th_ack);
347
348         gai->line_style=1;
349         gai->conv_num=0;
350         gai->display=TRUE;
351
352         graph_analysis->list = g_list_append(graph_analysis->list, gai);
353
354         return 1;
355
356 }
357
358
359
360 /****************************************************************************/
361 /* whenever a frame packet is seen by the tap listener */
362 static int 
363 flow_graph_frame_packet( void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U_, const void *dummy _U_)
364 {
365
366         if ((type_of_packets == ALL)||(pinfo->fd->flags.passed_dfilter==1)){
367                 flow_graph_frame_add_to_graph(pinfo);  
368         }
369         
370         return 1;
371 }
372
373 /****************************************************************************/
374 /* whenever a TCP packet is seen by the tap listener */
375 static int 
376 flow_graph_tcp_packet( void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U_, const void *tcp_info)
377 {
378         const struct tcpheader *tcph = tcp_info;
379
380         if ((type_of_packets == ALL)||(pinfo->fd->flags.passed_dfilter==1)){
381                 flow_graph_tcp_add_to_graph(pinfo,tcph);  
382         }
383         
384         return 1;
385 }
386
387
388 static void flow_graph_packet_draw(void *prs _U_)
389 {
390         return; 
391 }
392
393 /****************************************************************************/
394 static void
395 flow_graph_on_ok                    (GtkButton       *button _U_,
396                                         gpointer         user_data _U_)
397 {
398
399         if ((have_frame_tap_listener==TRUE)
400                 ||(have_tcp_tap_listener==TRUE))
401         { 
402                 /* remove_tap_listeners */
403                 remove_tap_listener_flow_graph();
404         }
405         
406         /* Scan for displayed packets (retap all packets) */
407
408         if (type_of_flow == GENERAL){
409                 /* Register the tap listener */
410
411                 if(have_frame_tap_listener==FALSE)
412                 {
413                         /* don't register tap listener, if we have it already */
414                         register_tap_listener("frame", &tap_identifier, NULL,
415                                 flow_graph_reset, 
416                                 flow_graph_frame_packet, 
417                                 flow_graph_packet_draw
418                                 );
419                         have_frame_tap_listener=TRUE;
420                 }
421
422                 cf_retap_packets(&cfile, TRUE);
423         }
424         else if (type_of_flow == TCP){
425         /* Register the tap listener */
426
427                 if(have_tcp_tap_listener==FALSE)
428                 {
429                         /* don't register tap listener, if we have it already */
430                         register_tap_listener("tcp", &tap_identifier, NULL,
431                                 flow_graph_reset, 
432                                 flow_graph_tcp_packet, 
433                                 flow_graph_packet_draw
434                                 );
435                         have_tcp_tap_listener=TRUE;
436                 }
437
438                 cf_retap_packets(&cfile, FALSE);
439         }
440
441         if (graph_analysis_data->dlg.window != NULL){ /* if we still have a window */
442                 graph_analysis_update(graph_analysis_data);             /* refresh it xxx */
443         }
444         else{
445                 graph_analysis_create(graph_analysis_data);
446         }
447
448 }
449
450
451 /****************************************************************************/
452 /* INTERFACE                                                                */
453 /****************************************************************************/
454
455 static void flow_graph_dlg_create (void)
456 {
457         
458         GtkWidget *flow_graph_dlg_w;
459         GtkWidget *main_vb;
460         GtkWidget *hbuttonbox;
461         GtkWidget *bt_close, *bt_ok;
462 #if 0
463         GtkWidget *top_label = NULL;
464 #endif
465         GtkWidget *flow_type_fr, *range_fr, *range_tb, *flow_type_tb, *node_addr_fr, *node_addr_tb;
466 #if GTK_MAJOR_VERSION < 2
467   GtkAccelGroup *accel_group;
468 #endif
469
470
471         GtkTooltips *tooltips = gtk_tooltips_new();
472
473         flow_graph_dlg_w=window_new(GTK_WINDOW_TOPLEVEL, "Ethereal: Flow Graph");
474
475         gtk_window_set_default_size(GTK_WINDOW(flow_graph_dlg_w), 350, 150);
476
477         main_vb = gtk_vbox_new (FALSE, 0);
478         gtk_container_add(GTK_CONTAINER(flow_graph_dlg_w), main_vb);
479         gtk_container_set_border_width (GTK_CONTAINER (main_vb), 12);
480
481 #if GTK_MAJOR_VERSION < 2
482   /* Accelerator group for the accelerators (or, as they're called in
483      Windows and, I think, in Motif, "mnemonics"; Alt+<key> is a mnemonic,
484      Ctrl+<key> is an accelerator). */
485   accel_group = gtk_accel_group_new();
486   gtk_window_add_accel_group(GTK_WINDOW(main_vb), accel_group);
487 #endif
488
489 #if 0
490         top_label = gtk_label_new ("Choose packets to include in the graph");
491         gtk_box_pack_start (GTK_BOX (main_vb), top_label, FALSE, FALSE, 8);
492 #endif
493         
494         gtk_widget_show(flow_graph_dlg_w);
495
496         /*** Packet range frame ***/
497         range_fr = gtk_frame_new("Choose packets");
498         gtk_box_pack_start(GTK_BOX(main_vb), range_fr, FALSE, FALSE, 0);
499
500     range_tb = gtk_table_new(4, 4, FALSE);
501     gtk_container_border_width(GTK_CONTAINER(range_tb), 5);
502         gtk_container_add(GTK_CONTAINER(range_fr), range_tb);
503
504         /* Process all packets */
505         select_all_rb = RADIO_BUTTON_NEW_WITH_MNEMONIC(NULL, "_All packets", accel_group);
506         gtk_tooltips_set_tip (tooltips, select_all_rb, 
507                 ("Process all packets"), NULL);
508         SIGNAL_CONNECT(select_all_rb, "toggled", toggle_select_all, NULL);
509         gtk_table_attach_defaults(GTK_TABLE(range_tb), select_all_rb, 0, 1, 0, 1);
510         if (type_of_packets == ALL) {
511                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(select_all_rb),TRUE);
512         }
513         gtk_widget_show(select_all_rb);
514
515         /* Process displayed packets */
516         select_displayed_rb = RADIO_BUTTON_NEW_WITH_MNEMONIC(select_all_rb, "_Displayed packets", accel_group);
517         gtk_tooltips_set_tip (tooltips, select_displayed_rb, 
518                 ("Process displayed packets"), NULL);
519         SIGNAL_CONNECT(select_displayed_rb, "toggled", toggle_select_displayed, NULL);
520         gtk_table_attach_defaults(GTK_TABLE(range_tb), select_displayed_rb, 1, 2, 0, 1);
521         if (type_of_packets == DISPLAYED) {
522                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(select_displayed_rb),TRUE);
523         }
524         gtk_widget_show(select_displayed_rb);
525
526         gtk_widget_show(range_tb);
527
528         gtk_widget_show(range_fr);
529
530         /*** Flow type frame ***/
531         flow_type_fr = gtk_frame_new("Choose flow type");
532         gtk_box_pack_start(GTK_BOX(main_vb), flow_type_fr, FALSE, FALSE, 0);
533
534     flow_type_tb = gtk_table_new(4, 4, FALSE);
535     gtk_container_border_width(GTK_CONTAINER(flow_type_tb), 5);
536         gtk_container_add(GTK_CONTAINER(flow_type_fr), flow_type_tb);
537
538         /* General information */
539         select_general_rb = RADIO_BUTTON_NEW_WITH_MNEMONIC(NULL, "_General flow", accel_group);
540         gtk_tooltips_set_tip (tooltips, select_general_rb, 
541                 ("Show all packets, with general information"), NULL);
542         SIGNAL_CONNECT(select_general_rb, "toggled", toggle_select_general, NULL);
543         gtk_table_attach_defaults(GTK_TABLE(flow_type_tb), select_general_rb, 0, 1, 0, 1);
544         if (type_of_flow == GENERAL) {
545                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(select_general_rb),TRUE);
546         }
547         gtk_widget_show(select_general_rb);
548
549         /* TCP specific information */
550         select_tcp_rb = RADIO_BUTTON_NEW_WITH_MNEMONIC(select_general_rb, "_TCP flow", accel_group);
551         gtk_tooltips_set_tip (tooltips, select_tcp_rb, 
552                 ("Show only TCP packets, with TCP specific information"), NULL);
553         SIGNAL_CONNECT(select_tcp_rb, "toggled", toggle_select_tcp, NULL);
554         gtk_table_attach_defaults(GTK_TABLE(flow_type_tb), select_tcp_rb, 1, 2, 0, 1);
555         if (type_of_flow == TCP) {
556                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(select_tcp_rb),TRUE);
557         }
558
559         gtk_widget_show(select_tcp_rb);
560
561         gtk_widget_show(flow_type_tb);
562         gtk_widget_show(flow_type_fr);
563
564         /*** Node address type frame ***/
565         node_addr_fr = gtk_frame_new("Choose node address type");
566         gtk_box_pack_start(GTK_BOX(main_vb), node_addr_fr, FALSE, FALSE, 0);
567
568     node_addr_tb = gtk_table_new(4, 4, FALSE);
569     gtk_container_border_width(GTK_CONTAINER(node_addr_tb), 5);
570         gtk_container_add(GTK_CONTAINER(node_addr_fr), node_addr_tb);
571
572         /* Source / Dest address */
573         src_dst_rb = RADIO_BUTTON_NEW_WITH_MNEMONIC(NULL, "_Standard source/destination addresses", accel_group);
574         gtk_tooltips_set_tip (tooltips, src_dst_rb, 
575                 ("Nodes in the diagram are identified with source and destination addresses"), NULL);
576         SIGNAL_CONNECT(src_dst_rb, "toggled", toggle_select_srcdst, NULL);
577         gtk_table_attach_defaults(GTK_TABLE(node_addr_tb), src_dst_rb, 0, 1, 0, 1);
578         if (node_addr_type == SRCDST) {
579                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(src_dst_rb),TRUE);
580         }
581         gtk_widget_show(src_dst_rb);
582
583         /* Network source / dest address */
584         net_src_dst_rb = RADIO_BUTTON_NEW_WITH_MNEMONIC(src_dst_rb, "_Network source/destination addresses", accel_group);
585         gtk_tooltips_set_tip (tooltips, net_src_dst_rb, 
586                 ("Nodes in the diagram are identified with network source and destination addresses"), NULL);
587         SIGNAL_CONNECT(net_src_dst_rb, "toggled", toggle_select_netsrcdst, NULL);
588         gtk_table_attach_defaults(GTK_TABLE(node_addr_tb), net_src_dst_rb, 1, 2, 0, 1);
589         if (node_addr_type == NET_SRCDST) {
590                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(net_src_dst_rb),TRUE);
591         }
592
593         gtk_widget_show(net_src_dst_rb);
594
595         gtk_widget_show(node_addr_tb);
596         gtk_widget_show(node_addr_fr);
597
598         /* button row */
599         hbuttonbox = gtk_hbutton_box_new ();
600         gtk_box_pack_start (GTK_BOX (main_vb), hbuttonbox, FALSE, FALSE, 0);
601         gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox), GTK_BUTTONBOX_SPREAD);
602         gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbuttonbox), 30);
603
604         bt_ok = BUTTON_NEW_FROM_STOCK(GTK_STOCK_OK);
605         gtk_container_add(GTK_CONTAINER(hbuttonbox), bt_ok);
606         gtk_tooltips_set_tip (tooltips, bt_ok, "Show the flow graph", NULL);
607         SIGNAL_CONNECT(bt_ok, "clicked", flow_graph_on_ok, NULL);
608         gtk_widget_show(bt_ok);
609
610         bt_close = BUTTON_NEW_FROM_STOCK(GTK_STOCK_CLOSE);
611         gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_close);
612         GTK_WIDGET_SET_FLAGS(bt_close, GTK_CAN_DEFAULT);
613         gtk_tooltips_set_tip (tooltips, bt_close, "Close this dialog", NULL);
614         window_set_cancel_button(flow_graph_dlg_w, bt_close, window_cancel_button_cb);
615
616         SIGNAL_CONNECT(flow_graph_dlg_w, "delete_event", window_delete_event_cb, NULL);
617         SIGNAL_CONNECT(flow_graph_dlg_w, "destroy", flow_graph_on_destroy, NULL);
618
619         gtk_widget_show_all(flow_graph_dlg_w);
620         window_present(flow_graph_dlg_w);
621
622         flow_graph_dlg = flow_graph_dlg_w;
623 }       
624
625 /****************************************************************************/
626 /* PUBLIC                                                                   */
627 /****************************************************************************/
628
629 /* init function for tap */
630 static void
631 flow_graph_init_tap(const char *dummy _U_)
632 {
633
634         /* initialize graph items store */
635         flow_graph_data_init();
636         
637         /* init the Graph Analysys */
638         graph_analysis_data = graph_analysis_init();
639         graph_analysis_data->graph_info = graph_analysis;
640
641         /* create dialog box if necessary */
642         if (flow_graph_dlg == NULL) {
643                 flow_graph_dlg_create();
644         } else {
645                 /* There's already a dialog box; reactivate it. */
646                 reactivate_window(flow_graph_dlg);
647         }
648
649 }
650
651
652 /****************************************************************************/
653 /* entry point when called via the GTK menu */
654 static void flow_graph_launch(GtkWidget *w _U_, gpointer data _U_)
655 {
656         flow_graph_init_tap("");
657 }
658
659 /****************************************************************************/
660 void
661 register_tap_listener_flow_graph(void)
662 {
663         register_stat_cmd_arg("flow_graph",flow_graph_init_tap);
664         register_stat_menu_item("Flo_w Graph...", REGISTER_STAT_GROUP_NONE,
665             flow_graph_launch, NULL, NULL, NULL);
666             
667 }
668