2 * VoIP calls summary addition for ethereal
6 * Copyright 2004, Ericsson , Spain
7 * By Francisco Alcoba <francisco.alcoba@ericsson.com>
9 * based on h323_calls_dlg.c
10 * Copyright 2004, Iskratel, Ltd, Kranj
11 * By Miha Jemec <m.jemec@iskratel.si>
13 * H323, RTP and Graph Support
14 * By Alejandro Vaquero, alejandro.vaquero@verso.com
15 * Copyright 2005, Verso Technologies Inc.
17 * Ethereal - Network traffic analyzer
18 * By Gerald Combs <gerald@ethereal.com>
19 * Copyright 1998 Gerald Combs
21 * This program is free software; you can redistribute it and/or
22 * modify it under the terms of the GNU General Public License
23 * as published by the Free Software Foundation; either version 2
24 * of the License, or (at your option) any later version.
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
31 * You should have received a copy of the GNU General Public License
32 * along with this program; if not, write to the Free Software
33 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
45 #include "graph_analysis.h"
46 #include "voip_calls_dlg.h"
47 #include "voip_calls.h"
50 #include "epan/filesystem.h"
54 #include "dlg_utils.h"
56 #include "compat_macros.h"
57 #include "gtkglobals.h"
58 #include "webbrowser.h"
60 #include "image/clist_ascend.xpm"
61 #include "image/clist_descend.xpm"
62 #include "simple_dialog.h"
64 #include <epan/to_str.h>
68 #include <epan/address.h>
69 #include <epan/addr_resolv.h>
71 static const gchar FWD_LABEL_TEXT[] = "Select one call.";
73 /****************************************************************************/
74 /* pointer to the one and only dialog window */
75 static GtkWidget *voip_calls_dlg = NULL;
77 static GtkWidget *clist = NULL;
78 static GtkWidget *top_label = NULL;
79 static GtkWidget *status_label = NULL;
80 static GtkWidget *label_fwd = NULL;
82 /*static GtkWidet *bt_unselect = NULL;*/
83 static GtkWidget *bt_filter = NULL;
84 static GtkWidget *bt_graph = NULL;
87 static voip_calls_info_t* selected_call_fwd = NULL; /* current selection */
88 static GList *last_list = NULL;
90 static guint32 calls_nb = 0; /* number of displayed calls */
91 static guint32 calls_ns = 0; /* number of selected calls */
93 static graph_analysis_data_t *graph_analysis_data;
97 /****************************************************************************/
98 /* append a line to clist */
99 static void add_to_clist(voip_calls_info_t* strinfo)
101 gchar label_text[256];
103 gchar *data[NUM_COLS];
104 gchar field[NUM_COLS][50];
106 isup_calls_info_t *tmp_isupinfo;
107 h323_calls_info_t *tmp_h323info;
108 gboolean tmp_bool = FALSE;
109 for (c=0;c<NUM_COLS;c++){
110 data[c]=&field[c][0];
114 g_snprintf(field[0], 15, "%i.%2i", strinfo->start_sec, strinfo->start_usec/10000);
115 g_snprintf(field[1], 15, "%i.%2i", strinfo->stop_sec, strinfo->stop_usec/10000);
116 /* xxx display_signed_time(data[0], sizeof(field[0]), strinfo->start_sec, strinfo->start_usec, USECS); */
117 /* display_signed_time(data[1], sizeof(field[0]), strinfo->stop_sec, strinfo->stop_usec, USECS); */
118 g_snprintf(field[2], 30, "%s", get_addr_name(&(strinfo->initial_speaker)));
119 g_snprintf(field[3], 50, "%s", strinfo->from_identity);
120 g_snprintf(field[4], 50, "%s", strinfo->to_identity);
121 g_snprintf(field[5], 15, "%s", voip_protocol_name[strinfo->protocol]);
122 g_snprintf(field[6], 15, "%u", strinfo->npackets);
123 g_snprintf(field[7], 15, "%s", voip_call_state_name[strinfo->call_state]);
125 /* Add comments based on the protocol */
126 switch(strinfo->protocol){
128 tmp_isupinfo = strinfo->prot_info;
129 g_snprintf(field[8],30, "%i-%i -> %i-%i", tmp_isupinfo->ni, tmp_isupinfo->opc,
130 tmp_isupinfo->ni, tmp_isupinfo->dpc);
133 tmp_h323info = strinfo->prot_info;
134 if (strinfo->call_state == VOIP_CALL_SETUP)
135 tmp_bool = tmp_h323info->is_faststart_Setup;
137 if ((tmp_h323info->is_faststart_Setup == TRUE) && (tmp_h323info->is_faststart_Proc == TRUE)) tmp_bool = TRUE;
138 g_snprintf(field[8],35, "Tunneling: %s Fast Start: %s", (tmp_h323info->is_h245Tunneling==TRUE?"ON":"OFF"),
139 (tmp_bool==TRUE?"ON":"OFF"));
146 added_row = gtk_clist_append(GTK_CLIST(clist), data);
148 /* set data pointer of last row to point to user data for that row */
149 gtk_clist_set_row_data(GTK_CLIST(clist), added_row, strinfo);
151 /* Update the top label with the number of detected calls */
153 g_snprintf(label_text, 256,
154 "Detected %d VoIP %s. Selected %d %s.",
156 plurality(calls_nb, "Call", "Calls"),
158 plurality(calls_ns, "Call", "Calls"));
159 gtk_label_set(GTK_LABEL(top_label), label_text);
161 /* Update the status label with the number of total messages */
162 g_snprintf(label_text, 256,
163 "Total: Calls: %d Start packets: %d Completed calls: %d Rejected calls: %d",
164 g_list_length(voip_calls_get_info()->strinfo_list),
165 voip_calls_get_info()->start_packets,
166 voip_calls_get_info()->completed_calls,
167 voip_calls_get_info()->rejected_calls);
168 gtk_label_set(GTK_LABEL(status_label), label_text);
172 void voip_calls_remove_tap_listener(void)
174 /* Remove the calls tap listener */
175 remove_tap_listener_sip_calls();
176 remove_tap_listener_isup_calls();
177 remove_tap_listener_mtp3_calls();
178 remove_tap_listener_h225_calls();
179 remove_tap_listener_h245dg_calls();
180 remove_tap_listener_q931_calls();
181 remove_tap_listener_sdp_calls();
182 remove_tap_listener_rtp();
183 remove_tap_listener_rtp_event();
184 if (find_tap_id("mgcp")) {
185 remove_tap_listener_mgcp_calls();
189 /****************************************************************************/
191 /****************************************************************************/
193 voip_calls_on_destroy (GtkObject *object _U_,
194 gpointer user_data _U_)
196 /* remove_tap_listeners */
197 voip_calls_remove_tap_listener();
199 /* Clean up memory used by calls tap */
200 voip_calls_reset((voip_calls_tapinfo_t*) voip_calls_get_info());
202 /* Note that we no longer have a "VoIP Calls" dialog box. */
203 voip_calls_dlg = NULL;
207 /****************************************************************************/
209 voip_calls_on_unselect (GtkButton *button _U_,
210 gpointer user_data _U_)
212 selected_call_fwd = NULL;
213 gtk_clist_unselect_all(GTK_CLIST(clist));
214 gtk_label_set_text(GTK_LABEL(label_fwd), FWD_LABEL_TEXT);
216 /*gtk_widget_set_sensitive(bt_unselect, FALSE);*/
217 gtk_widget_set_sensitive(bt_filter, FALSE);
218 gtk_widget_set_sensitive(bt_graph, FALSE);
222 /****************************************************************************/
224 voip_calls_on_filter (GtkButton *button _U_,
225 gpointer user_data _U_)
227 const gchar *filter_string;
229 GString *filter_string_fwd;
230 gchar *filter_prepend;
231 gboolean isFirst = TRUE;
233 guint filter_length = 0;
234 guint max_filter_length = 2048;
235 sip_calls_info_t *tmp_sipinfo;
236 isup_calls_info_t *tmp_isupinfo;
237 h323_calls_info_t *tmp_h323info;
238 h245_address_t *h245_add = NULL;
240 graph_analysis_item_t *gai;
242 if (selected_call_fwd==NULL)
245 filter_string=gtk_entry_get_text(GTK_ENTRY(main_display_filter_widget));
246 filter_length = strlen(filter_string);
248 while ((c = *filter_string++) != '\0') {
249 if (!isspace((guchar)c)) {
250 /* The filter string isn't blank, so there's already
251 an expression; we OR in the new expression */
252 filter_prepend = " or ";
257 filter_string_fwd = g_string_new(filter_prepend);
259 /* look in the Graph and get all the frame_num for this call */
260 g_string_sprintfa(filter_string_fwd, " (");
261 list = g_list_first(voip_calls_get_info()->graph_analysis->list);
265 if (gai->conv_num == selected_call_fwd->call_num){
266 g_string_sprintfa(filter_string_fwd,"%sframe.number == %d", isFirst?"":" or ", gai->frame_num );
269 list = g_list_next (list);
271 g_string_sprintfa(filter_string_fwd, ") ");
272 filter_length = filter_length + filter_string_fwd->len;
274 if (filter_length < max_filter_length){
275 gtk_entry_append_text(GTK_ENTRY(main_display_filter_widget), filter_string_fwd->str);
279 g_string_free(filter_string_fwd, TRUE);
280 filter_string_fwd = g_string_new(filter_prepend);
282 switch(selected_call_fwd->protocol){
284 tmp_sipinfo = selected_call_fwd->prot_info;
285 g_string_sprintfa(filter_string_fwd,
286 "(sip.Call-ID == \"%s\") ",
287 tmp_sipinfo->call_identifier
289 gtk_entry_append_text(GTK_ENTRY(main_display_filter_widget), filter_string_fwd->str);
292 tmp_isupinfo = selected_call_fwd->prot_info;
293 g_string_sprintfa(filter_string_fwd,
294 "(isup.cic == %i and frame.number >=%i and frame.number<=%i and mtp3.network_indicator == %i and ((mtp3.dpc == %i) and (mtp3.opc == %i)) or((mtp3.dpc == %i) and (mtp3.opc == %i))) ",
295 tmp_isupinfo->cic,selected_call_fwd->first_frame_num,
296 selected_call_fwd->last_frame_num,
297 tmp_isupinfo->ni, tmp_isupinfo->dpc, tmp_isupinfo->opc,
298 tmp_isupinfo->opc, tmp_isupinfo->dpc
300 gtk_entry_append_text(GTK_ENTRY(main_display_filter_widget), filter_string_fwd->str);
303 tmp_h323info = selected_call_fwd->prot_info;
304 g_string_sprintfa(filter_string_fwd,
305 "((h225.guid == %x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x || q931.call_ref == %x:%x || q931.call_ref == %x:%x) ",
306 (guint8)tmp_h323info->guid[0], (guint8)tmp_h323info->guid[1], (guint8)tmp_h323info->guid[2],
307 (guint8)tmp_h323info->guid[3], (guint8)tmp_h323info->guid[4], (guint8)tmp_h323info->guid[5], (guint8)tmp_h323info->guid[6],
308 (guint8)tmp_h323info->guid[7], (guint8)tmp_h323info->guid[8], (guint8)tmp_h323info->guid[9], (guint8)tmp_h323info->guid[10],
309 (guint8)tmp_h323info->guid[11], (guint8)tmp_h323info->guid[12], (guint8)tmp_h323info->guid[13], (guint8)tmp_h323info->guid[14],
310 (guint8)tmp_h323info->guid[15], (guint8)(tmp_h323info->q931_crv & 0xff), (guint8)((tmp_h323info->q931_crv & 0xff00)>>8)
311 , (guint8)(tmp_h323info->q931_crv2 & 0xff), (guint8)((tmp_h323info->q931_crv2 & 0xff00)>>8));
312 list = g_list_first(tmp_h323info->h245_list);
316 g_string_sprintfa(filter_string_fwd,
317 " || (ip.addr == %s && tcp.port == %d && h245) ",
318 ip_to_str((guint8 *)&(h245_add->h245_address)), h245_add->h245_port);
319 list = g_list_next(list);
321 g_string_sprintfa(filter_string_fwd, ") ");
322 gtk_entry_append_text(GTK_ENTRY(main_display_filter_widget), filter_string_fwd->str);
325 /* XXX - not supported */
331 g_string_free(filter_string_fwd, TRUE);
337 /****************************************************************************/
339 static void help_bt_clicked( GtkButton *button _U_)
341 browser_open_url("http://wiki.ethereal.com/VoIP_20calls");
346 on_graph_bt_clicked (GtkButton *button _U_,
347 gpointer user_data _U_)
349 graph_analysis_item_t *gai;
352 voip_calls_info_t *tmp_listinfo;
354 /* reset the "display" parameter in graph analysis */
355 list2 = g_list_first(voip_calls_get_info()->graph_analysis->list);
358 gai->display = FALSE;
359 list2 = g_list_next(list2);
363 /* set the display for selected calls */
364 list = g_list_first(voip_calls_get_info()->strinfo_list);
366 tmp_listinfo=list->data;
367 if (tmp_listinfo->selected){
368 list2 = g_list_first(voip_calls_get_info()->graph_analysis->list);
371 if (gai->conv_num == tmp_listinfo->call_num){
374 list2 = g_list_next(list2);
377 list = g_list_next(list);
380 /* create or refresh the graph windows */
381 if (graph_analysis_data->dlg.window == NULL) /* create the window */
382 graph_analysis_create(graph_analysis_data);
384 graph_analysis_update(graph_analysis_data); /* refresh it */
387 static const GdkColor COLOR_SELECT = {0, 0x00ff, 0x80ff, 0x80ff};
388 static const GdkColor COLOR_DEFAULT = {0, 0xffff, 0xffff, 0xffff};
390 /****************************************************************************/
391 /* when the user selects a row in the calls list */
393 voip_calls_on_select_row(GtkCList *clist,
396 GdkEventButton *event _U_,
397 gpointer user_data _U_)
399 GdkColor color = COLOR_DEFAULT;
400 gchar label_text[80];
402 selected_call_fwd = gtk_clist_get_row_data(GTK_CLIST(clist), row);
404 if (!selected_call_fwd->selected)
409 g_snprintf(label_text, 256,
410 "Detected %d VoIP %s. Selected %d %s.",
412 plurality(calls_nb, "Call", "Calls"),
414 plurality(calls_ns, "Call", "Calls"));
415 gtk_label_set(GTK_LABEL(top_label), label_text);
417 g_snprintf(label_text, 80, "Selected Call: From %s To %s, starting time %i.%i",
418 selected_call_fwd->from_identity,
419 selected_call_fwd->to_identity,
420 selected_call_fwd->start_sec,
421 selected_call_fwd->start_usec
423 gtk_label_set_text(GTK_LABEL(label_fwd), label_text);
425 selected_call_fwd->selected=!selected_call_fwd->selected;
426 if (selected_call_fwd->selected)
427 color = COLOR_SELECT;
429 color = COLOR_DEFAULT;
431 gtk_clist_set_background(GTK_CLIST(clist), row, &color);
433 /*gtk_widget_set_sensitive(bt_unselect, TRUE);*/
434 gtk_widget_set_sensitive(bt_filter, TRUE);
435 gtk_widget_set_sensitive(bt_graph, TRUE);
437 /* TODO: activate other buttons when implemented */
441 /****************************************************************************/
443 typedef struct column_arrows {
445 GtkWidget *ascend_pm;
446 GtkWidget *descend_pm;
450 /****************************************************************************/
452 voip_calls_click_column_cb(GtkCList *clist, gint column, gpointer data)
454 column_arrows *col_arrows = (column_arrows *) data;
457 gtk_clist_freeze(clist);
459 for (i=0; i<NUM_COLS; i++) {
460 gtk_widget_hide(col_arrows[i].ascend_pm);
461 gtk_widget_hide(col_arrows[i].descend_pm);
464 if (column == clist->sort_column) {
465 if (clist->sort_type == GTK_SORT_ASCENDING) {
466 clist->sort_type = GTK_SORT_DESCENDING;
467 gtk_widget_show(col_arrows[column].descend_pm);
469 clist->sort_type = GTK_SORT_ASCENDING;
470 gtk_widget_show(col_arrows[column].ascend_pm);
473 clist->sort_type = GTK_SORT_ASCENDING;
474 gtk_widget_show(col_arrows[column].ascend_pm);
475 gtk_clist_set_sort_column(clist, column);
477 gtk_clist_thaw(clist);
479 gtk_clist_sort(clist);
483 /****************************************************************************/
485 voip_calls_sort_column(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2)
491 const GtkCListRow *row1 = (const GtkCListRow *) ptr1;
492 const GtkCListRow *row2 = (const GtkCListRow *) ptr2;
494 text1 = GTK_CELL_TEXT (row1->cell[clist->sort_column])->text;
495 text2 = GTK_CELL_TEXT (row2->cell[clist->sort_column])->text;
497 switch(clist->sort_column){
500 if ((sscanf(text1, "%u.%u", &i1, &i2) != 2) ||
501 (sscanf(text2, "%u.%u", &i3, &i4) != 2) ){
515 return strcmp (text1, text2);
521 g_assert_not_reached();
526 /****************************************************************************/
528 /****************************************************************************/
530 static void voip_calls_dlg_create (void)
532 GtkWidget *voip_calls_dlg_w;
534 GtkWidget *scrolledwindow;
535 GtkWidget *hbuttonbox;
538 GtkTooltips *tooltips = gtk_tooltips_new();
540 gchar *titles[NUM_COLS] = {"Start Time", "Stop Time", "Initial Speaker", "From", "To", "Protocol", "Packets", "State", "Comments"};
541 column_arrows *col_arrows;
542 GtkWidget *column_lb;
545 voip_calls_dlg_w=window_new(GTK_WINDOW_TOPLEVEL, "Ethereal: VoIP Calls");
547 gtk_window_set_default_size(GTK_WINDOW(voip_calls_dlg_w), 840, 350);
549 main_vb = gtk_vbox_new (FALSE, 0);
550 gtk_container_add(GTK_CONTAINER(voip_calls_dlg_w), main_vb);
551 gtk_container_set_border_width (GTK_CONTAINER (main_vb), 12);
553 top_label = gtk_label_new ("Detected 0 VoIP Calls. Selected 0 Calls.");
554 gtk_box_pack_start (GTK_BOX (main_vb), top_label, FALSE, FALSE, 8);
556 scrolledwindow = scrolled_window_new (NULL, NULL);
557 gtk_box_pack_start (GTK_BOX (main_vb), scrolledwindow, TRUE, TRUE, 0);
559 clist = gtk_clist_new (NUM_COLS);
560 gtk_container_add (GTK_CONTAINER (scrolledwindow), clist);
562 gtk_clist_set_column_width (GTK_CLIST (clist), 0, 60);
563 gtk_clist_set_column_width (GTK_CLIST (clist), 1, 60);
564 gtk_clist_set_column_width (GTK_CLIST (clist), 2, 80);
565 gtk_clist_set_column_width (GTK_CLIST (clist), 3, 130);
566 gtk_clist_set_column_width (GTK_CLIST (clist), 4, 130);
567 gtk_clist_set_column_width (GTK_CLIST (clist), 5, 50);
568 gtk_clist_set_column_width (GTK_CLIST (clist), 6, 45);
569 gtk_clist_set_column_width (GTK_CLIST (clist), 7, 60);
570 gtk_clist_set_column_width (GTK_CLIST (clist), 8, 100);
572 gtk_clist_set_column_justification(GTK_CLIST(clist), 0, GTK_JUSTIFY_LEFT);
573 gtk_clist_set_column_justification(GTK_CLIST(clist), 1, GTK_JUSTIFY_LEFT);
574 gtk_clist_set_column_justification(GTK_CLIST(clist), 2, GTK_JUSTIFY_LEFT);
575 gtk_clist_set_column_justification(GTK_CLIST(clist), 3, GTK_JUSTIFY_LEFT);
576 gtk_clist_set_column_justification(GTK_CLIST(clist), 4, GTK_JUSTIFY_LEFT);
577 gtk_clist_set_column_justification(GTK_CLIST(clist), 5, GTK_JUSTIFY_CENTER);
578 gtk_clist_set_column_justification(GTK_CLIST(clist), 6, GTK_JUSTIFY_CENTER);
579 gtk_clist_set_column_justification(GTK_CLIST(clist), 7, GTK_JUSTIFY_LEFT);
580 gtk_clist_set_column_justification(GTK_CLIST(clist), 8, GTK_JUSTIFY_LEFT);
582 gtk_clist_column_titles_show (GTK_CLIST (clist));
584 gtk_clist_set_compare_func(GTK_CLIST(clist), voip_calls_sort_column);
585 gtk_clist_set_sort_column(GTK_CLIST(clist), 0);
586 gtk_clist_set_sort_type(GTK_CLIST(clist), GTK_SORT_ASCENDING);
588 gtk_widget_show(voip_calls_dlg_w);
590 /* sort by column feature */
591 col_arrows = (column_arrows *) g_malloc(sizeof(column_arrows) * NUM_COLS);
593 for (i=0; i<NUM_COLS; i++) {
594 col_arrows[i].table = gtk_table_new(2, 2, FALSE);
595 gtk_table_set_col_spacings(GTK_TABLE(col_arrows[i].table), 5);
596 column_lb = gtk_label_new(titles[i]);
597 gtk_table_attach(GTK_TABLE(col_arrows[i].table), column_lb, 0, 1, 0, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
598 gtk_widget_show(column_lb);
600 col_arrows[i].ascend_pm = xpm_to_widget(clist_ascend_xpm);
601 gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].ascend_pm, 1, 2, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
602 col_arrows[i].descend_pm = xpm_to_widget(clist_descend_xpm);
603 gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].descend_pm, 1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
604 /* make start time be the default sort order */
606 gtk_widget_show(col_arrows[i].ascend_pm);
608 gtk_clist_set_column_widget(GTK_CLIST(clist), i, col_arrows[i].table);
609 gtk_widget_show(col_arrows[i].table);
612 SIGNAL_CONNECT(clist, "click-column", voip_calls_click_column_cb, col_arrows);
614 label_fwd = gtk_label_new (FWD_LABEL_TEXT);
615 gtk_box_pack_start (GTK_BOX (main_vb), label_fwd, FALSE, FALSE, 0);
617 status_label = gtk_label_new ("Total: Calls: 0 Start packets: 0 Completed calls: 0 Rejected calls: 0");
618 gtk_box_pack_start (GTK_BOX (main_vb), status_label, FALSE, FALSE, 8);
621 hbuttonbox = gtk_hbutton_box_new ();
622 gtk_box_pack_start (GTK_BOX (main_vb), hbuttonbox, FALSE, FALSE, 0);
623 gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox), GTK_BUTTONBOX_SPREAD);
624 gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbuttonbox), 30);
626 bt_help = BUTTON_NEW_FROM_STOCK(GTK_STOCK_HELP);
627 gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_help);
628 SIGNAL_CONNECT(bt_help, "clicked", help_bt_clicked, NULL);
629 gtk_tooltips_set_tip (tooltips, bt_help, "Go to the help page", NULL);
631 /*bt_unselect = gtk_button_new_with_label ("Unselect");
632 gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_unselect);
633 gtk_tooltips_set_tip (tooltips, bt_unselect, "Unselect this conversation", NULL);*/
635 bt_filter = gtk_button_new_with_label ("Prepare Filter");
636 gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_filter);
637 gtk_tooltips_set_tip (tooltips, bt_filter, "Prepare a display filter of the selected conversation", NULL);
639 bt_graph = gtk_button_new_with_label("Graph");
640 gtk_container_add(GTK_CONTAINER(hbuttonbox), bt_graph);
641 SIGNAL_CONNECT(bt_graph, "clicked", on_graph_bt_clicked, NULL);
642 gtk_tooltips_set_tip (tooltips, bt_graph, "Show a flow graph of the selected calls.", NULL);
644 bt_close = BUTTON_NEW_FROM_STOCK(GTK_STOCK_CLOSE);
645 gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_close);
646 GTK_WIDGET_SET_FLAGS(bt_close, GTK_CAN_DEFAULT);
647 gtk_tooltips_set_tip (tooltips, bt_close, "Close this dialog", NULL);
649 SIGNAL_CONNECT(clist, "select_row", voip_calls_on_select_row, NULL);
650 /*SIGNAL_CONNECT(bt_unselect, "clicked", voip_calls_on_unselect, NULL);*/
651 SIGNAL_CONNECT(bt_filter, "clicked", voip_calls_on_filter, NULL);
653 window_set_cancel_button(voip_calls_dlg_w, bt_close, window_cancel_button_cb);
655 SIGNAL_CONNECT(voip_calls_dlg_w, "delete_event", window_delete_event_cb, NULL);
656 SIGNAL_CONNECT(voip_calls_dlg_w, "destroy", voip_calls_on_destroy, NULL);
658 gtk_widget_show_all(voip_calls_dlg_w);
659 window_present(voip_calls_dlg_w);
661 voip_calls_on_unselect(NULL, NULL);
663 voip_calls_dlg = voip_calls_dlg_w;
667 /****************************************************************************/
669 /****************************************************************************/
671 /****************************************************************************/
672 /* update the contents of the dialog box clist */
673 /* list: pointer to list of voip_calls_info_t* */
675 void voip_calls_dlg_update(GList *list)
677 gchar label_text[256];
679 if (voip_calls_dlg != NULL) {
680 gtk_clist_clear(GTK_CLIST(clist));
683 g_snprintf(label_text, 256,
684 "Total: Calls: %d Start packets: %d Completed calls: %d Rejected calls: %d",
685 g_list_length(voip_calls_get_info()->strinfo_list),
686 voip_calls_get_info()->start_packets,
687 voip_calls_get_info()->completed_calls,
688 voip_calls_get_info()->rejected_calls);
689 gtk_label_set(GTK_LABEL(status_label), label_text);
691 foo= g_list_length(list);
692 list = g_list_first(list);
695 add_to_clist((voip_calls_info_t*)(list->data));
696 list = g_list_next(list);
699 g_snprintf(label_text, 256,
700 "Detected %d VoIP %s. Selected %d %s.",
702 plurality(calls_nb, "Call", "Calls"),
704 plurality(calls_ns, "Call", "Calls"));
705 gtk_label_set(GTK_LABEL(top_label), label_text);
707 voip_calls_on_unselect(NULL, NULL);
714 /****************************************************************************/
715 /* draw function for tap listeners to keep the window up to date */
716 void voip_calls_dlg_draw(void *ptr _U_)
718 voip_calls_dlg_update(voip_calls_get_info()->strinfo_list);
721 /* reset function for tap listeners to clear window, if necessary */
722 void voip_calls_dlg_reset(void *ptr _U_)
724 /* Clean up memory used by calls tap */
725 voip_calls_reset((voip_calls_tapinfo_t*) voip_calls_get_info());
728 /* init function for tap */
730 voip_calls_init_tap(char *dummy _U_)
732 graph_analysis_data_init();
734 /* Clean up memory used by calls tap */
735 voip_calls_reset((voip_calls_tapinfo_t*) voip_calls_get_info());
737 /* Register the tap listener */
738 sip_calls_init_tap();
739 mtp3_calls_init_tap();
740 isup_calls_init_tap();
741 h225_calls_init_tap();
742 h245dg_calls_init_tap();
743 q931_calls_init_tap();
744 sdp_calls_init_tap();
746 rtp_event_init_tap();
747 /* We don't register this tap, if we don't have the mgcp plugin loaded.*/
748 if (find_tap_id("mgcp")) {
749 mgcp_calls_init_tap();
752 /* init the Graph Analysys */
753 graph_analysis_data = graph_analysis_init();
754 graph_analysis_data->graph_info = voip_calls_get_info()->graph_analysis;
756 /* create dialog box if necessary */
757 if (voip_calls_dlg == NULL) {
758 voip_calls_dlg_create();
760 /* There's already a dialog box; reactivate it. */
761 reactivate_window(voip_calls_dlg);
764 /* Scan for VoIP calls calls (redissect all packets) */
765 cf_retap_packets(&cfile);
767 /* Tap listener will be removed and cleaned up in voip_calls_on_destroy */
771 /****************************************************************************/
772 /* entry point when called via the GTK menu */
773 void voip_calls_launch(GtkWidget *w _U_, gpointer data _U_)
775 voip_calls_init_tap("");
778 /****************************************************************************/
780 register_tap_listener_voip_calls_dlg(void)
782 register_tap_listener_cmd_arg("voip,calls",voip_calls_init_tap);
783 register_tap_menu_item("VoIP Calls...", REGISTER_TAP_GROUP_TELEPHONY,
784 voip_calls_launch, NULL, NULL, NULL);