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"
59 #include "image/clist_ascend.xpm"
60 #include "image/clist_descend.xpm"
61 #include "simple_dialog.h"
63 #include <epan/to_str.h>
67 #include <epan/address.h>
68 #include <epan/addr_resolv.h>
70 static const gchar FWD_LABEL_TEXT[] = "Select one call.";
72 /****************************************************************************/
73 /* pointer to the one and only dialog window */
74 static GtkWidget *voip_calls_dlg = NULL;
76 static GtkWidget *clist = NULL;
77 static GtkWidget *top_label = NULL;
78 static GtkWidget *status_label = NULL;
79 static GtkWidget *label_fwd = NULL;
81 /*static GtkWidet *bt_unselect = NULL;*/
82 static GtkWidget *bt_filter = NULL;
83 static GtkWidget *bt_graph = NULL;
86 static voip_calls_info_t* selected_call_fwd = NULL; /* current selection */
87 static GList *last_list = NULL;
89 static guint32 calls_nb = 0; /* number of displayed calls */
90 static guint32 calls_ns = 0; /* number of selected calls */
92 static graph_analysis_data_t *graph_analysis_data = NULL;
95 static const GdkColor COLOR_SELECT = {0, 0x00ff, 0x80ff, 0x80ff};
96 static const GdkColor COLOR_DEFAULT = {0, 0xffff, 0xffff, 0xffff};
98 /****************************************************************************/
99 /* append a line to clist */
100 static void add_to_clist(voip_calls_info_t* strinfo)
102 gchar label_text[256];
104 gchar *data[NUM_COLS];
105 gchar field[NUM_COLS][50];
107 isup_calls_info_t *tmp_isupinfo;
108 h323_calls_info_t *tmp_h323info;
109 gboolean tmp_bool = FALSE;
110 GdkColor color = COLOR_SELECT;
111 for (c=0;c<NUM_COLS;c++){
112 data[c]=&field[c][0];
115 /* strinfo->selected = FALSE;*/
117 g_snprintf(field[0], 15, "%i.%2i", strinfo->start_sec, strinfo->start_usec/10000);
118 g_snprintf(field[1], 15, "%i.%2i", strinfo->stop_sec, strinfo->stop_usec/10000);
119 /* xxx display_signed_time(data[0], sizeof(field[0]), strinfo->start_sec, strinfo->start_usec, USECS); */
120 /* display_signed_time(data[1], sizeof(field[0]), strinfo->stop_sec, strinfo->stop_usec, USECS); */
121 g_snprintf(field[2], 30, "%s", get_addr_name(&(strinfo->initial_speaker)));
122 g_snprintf(field[3], 50, "%s", strinfo->from_identity);
123 g_snprintf(field[4], 50, "%s", strinfo->to_identity);
124 g_snprintf(field[5], 15, "%s", voip_protocol_name[strinfo->protocol]);
125 g_snprintf(field[6], 15, "%u", strinfo->npackets);
126 g_snprintf(field[7], 15, "%s", voip_call_state_name[strinfo->call_state]);
128 /* Add comments based on the protocol */
129 switch(strinfo->protocol){
131 tmp_isupinfo = strinfo->prot_info;
132 g_snprintf(field[8],30, "%i-%i -> %i-%i", tmp_isupinfo->ni, tmp_isupinfo->opc,
133 tmp_isupinfo->ni, tmp_isupinfo->dpc);
136 tmp_h323info = strinfo->prot_info;
137 if (strinfo->call_state == VOIP_CALL_SETUP)
138 tmp_bool = tmp_h323info->is_faststart_Setup;
140 if ((tmp_h323info->is_faststart_Setup == TRUE) && (tmp_h323info->is_faststart_Proc == TRUE)) tmp_bool = TRUE;
141 g_snprintf(field[8],35, "Tunneling: %s Fast Start: %s", (tmp_h323info->is_h245Tunneling==TRUE?"ON":"OFF"),
142 (tmp_bool==TRUE?"ON":"OFF"));
149 added_row = gtk_clist_append(GTK_CLIST(clist), data);
151 /* set the background color if selected */
152 if (strinfo->selected) {
154 gtk_clist_set_background(GTK_CLIST(clist), added_row, &color);
157 /* set data pointer of last row to point to user data for that row */
158 gtk_clist_set_row_data(GTK_CLIST(clist), added_row, strinfo);
160 /* Update the top label with the number of detected calls */
162 g_snprintf(label_text, 256,
163 "Detected %d VoIP %s. Selected %d %s.",
165 plurality(calls_nb, "Call", "Calls"),
167 plurality(calls_ns, "Call", "Calls"));
168 gtk_label_set(GTK_LABEL(top_label), label_text);
170 /* Update the status label with the number of total messages */
171 g_snprintf(label_text, 256,
172 "Total: Calls: %d Start packets: %d Completed calls: %d Rejected calls: %d",
173 g_list_length(voip_calls_get_info()->strinfo_list),
174 voip_calls_get_info()->start_packets,
175 voip_calls_get_info()->completed_calls,
176 voip_calls_get_info()->rejected_calls);
177 gtk_label_set(GTK_LABEL(status_label), label_text);
181 void voip_calls_remove_tap_listener(void)
183 /* Remove the calls tap listener */
184 remove_tap_listener_sip_calls();
185 remove_tap_listener_isup_calls();
186 remove_tap_listener_mtp3_calls();
187 remove_tap_listener_h225_calls();
188 remove_tap_listener_h245dg_calls();
189 remove_tap_listener_q931_calls();
190 remove_tap_listener_sdp_calls();
191 remove_tap_listener_rtp();
192 remove_tap_listener_rtp_event();
193 if (find_tap_id("mgcp")) {
194 remove_tap_listener_mgcp_calls();
196 remove_tap_listener_actrace_calls();
199 /****************************************************************************/
201 /****************************************************************************/
203 voip_calls_on_destroy (GtkObject *object _U_,
204 gpointer user_data _U_)
206 /* remove_tap_listeners */
207 voip_calls_remove_tap_listener();
209 /* Clean up memory used by calls tap */
210 voip_calls_dlg_reset(NULL);
212 /* Note that we no longer have a "VoIP Calls" dialog box. */
213 voip_calls_dlg = NULL;
215 graph_analysis_data = NULL;
219 /****************************************************************************/
221 voip_calls_on_unselect (GtkButton *button _U_,
222 gpointer user_data _U_)
224 selected_call_fwd = NULL;
225 gtk_clist_unselect_all(GTK_CLIST(clist));
226 gtk_label_set_text(GTK_LABEL(label_fwd), FWD_LABEL_TEXT);
228 /*gtk_widget_set_sensitive(bt_unselect, FALSE);*/
229 gtk_widget_set_sensitive(bt_filter, FALSE);
230 gtk_widget_set_sensitive(bt_graph, FALSE);
234 /****************************************************************************/
236 voip_calls_on_filter (GtkButton *button _U_,
237 gpointer user_data _U_)
239 const gchar *filter_string;
241 GString *filter_string_fwd;
242 const gchar *filter_prepend;
243 gboolean isFirst = TRUE;
245 guint filter_length = 0;
246 guint max_filter_length = 2048;
247 sip_calls_info_t *tmp_sipinfo;
248 isup_calls_info_t *tmp_isupinfo;
249 h323_calls_info_t *tmp_h323info;
250 h245_address_t *h245_add = NULL;
252 graph_analysis_item_t *gai;
254 if (selected_call_fwd==NULL)
257 filter_string=gtk_entry_get_text(GTK_ENTRY(main_display_filter_widget));
258 filter_length = strlen(filter_string);
260 while ((c = *filter_string++) != '\0') {
261 if (!isspace((guchar)c)) {
262 /* The filter string isn't blank, so there's already
263 an expression; we OR in the new expression */
264 filter_prepend = " or ";
269 filter_string_fwd = g_string_new(filter_prepend);
271 /* look in the Graph and get all the frame_num for this call */
272 g_string_sprintfa(filter_string_fwd, " (");
273 list = g_list_first(voip_calls_get_info()->graph_analysis->list);
277 if (gai->conv_num == selected_call_fwd->call_num){
278 g_string_sprintfa(filter_string_fwd,"%sframe.number == %d", isFirst?"":" or ", gai->frame_num );
281 list = g_list_next (list);
283 g_string_sprintfa(filter_string_fwd, ") ");
284 filter_length = filter_length + filter_string_fwd->len;
286 if (filter_length < max_filter_length){
287 gtk_entry_append_text(GTK_ENTRY(main_display_filter_widget), filter_string_fwd->str);
291 g_string_free(filter_string_fwd, TRUE);
292 filter_string_fwd = g_string_new(filter_prepend);
294 switch(selected_call_fwd->protocol){
296 tmp_sipinfo = selected_call_fwd->prot_info;
297 g_string_sprintfa(filter_string_fwd,
298 "(sip.Call-ID == \"%s\") ",
299 tmp_sipinfo->call_identifier
301 gtk_entry_append_text(GTK_ENTRY(main_display_filter_widget), filter_string_fwd->str);
304 tmp_isupinfo = selected_call_fwd->prot_info;
305 g_string_sprintfa(filter_string_fwd,
306 "(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))) ",
307 tmp_isupinfo->cic,selected_call_fwd->first_frame_num,
308 selected_call_fwd->last_frame_num,
309 tmp_isupinfo->ni, tmp_isupinfo->dpc, tmp_isupinfo->opc,
310 tmp_isupinfo->opc, tmp_isupinfo->dpc
312 gtk_entry_append_text(GTK_ENTRY(main_display_filter_widget), filter_string_fwd->str);
315 tmp_h323info = selected_call_fwd->prot_info;
316 g_string_sprintfa(filter_string_fwd,
317 "((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) ",
318 (guint8)tmp_h323info->guid[0], (guint8)tmp_h323info->guid[1], (guint8)tmp_h323info->guid[2],
319 (guint8)tmp_h323info->guid[3], (guint8)tmp_h323info->guid[4], (guint8)tmp_h323info->guid[5], (guint8)tmp_h323info->guid[6],
320 (guint8)tmp_h323info->guid[7], (guint8)tmp_h323info->guid[8], (guint8)tmp_h323info->guid[9], (guint8)tmp_h323info->guid[10],
321 (guint8)tmp_h323info->guid[11], (guint8)tmp_h323info->guid[12], (guint8)tmp_h323info->guid[13], (guint8)tmp_h323info->guid[14],
322 (guint8)tmp_h323info->guid[15], (guint8)(tmp_h323info->q931_crv & 0xff), (guint8)((tmp_h323info->q931_crv & 0xff00)>>8)
323 , (guint8)(tmp_h323info->q931_crv2 & 0xff), (guint8)((tmp_h323info->q931_crv2 & 0xff00)>>8));
324 list = g_list_first(tmp_h323info->h245_list);
328 g_string_sprintfa(filter_string_fwd,
329 " || (ip.addr == %s && tcp.port == %d && h245) ",
330 ip_to_str((guint8 *)&(h245_add->h245_address)), h245_add->h245_port);
331 list = g_list_next(list);
333 g_string_sprintfa(filter_string_fwd, ") ");
334 gtk_entry_append_text(GTK_ENTRY(main_display_filter_widget), filter_string_fwd->str);
339 /* XXX - not supported */
345 g_string_free(filter_string_fwd, TRUE);
351 /****************************************************************************/
353 on_graph_bt_clicked (GtkButton *button _U_,
354 gpointer user_data _U_)
356 graph_analysis_item_t *gai;
359 voip_calls_info_t *tmp_listinfo;
361 /* reset the "display" parameter in graph analysis */
362 list2 = g_list_first(voip_calls_get_info()->graph_analysis->list);
365 gai->display = FALSE;
366 list2 = g_list_next(list2);
370 /* set the display for selected calls */
371 list = g_list_first(voip_calls_get_info()->strinfo_list);
373 tmp_listinfo=list->data;
374 if (tmp_listinfo->selected){
375 list2 = g_list_first(voip_calls_get_info()->graph_analysis->list);
378 if (gai->conv_num == tmp_listinfo->call_num){
381 list2 = g_list_next(list2);
384 list = g_list_next(list);
387 /* create or refresh the graph windows */
388 if (graph_analysis_data->dlg.window == NULL) /* create the window */
389 graph_analysis_create(graph_analysis_data);
391 graph_analysis_update(graph_analysis_data); /* refresh it */
394 /****************************************************************************/
395 /* when the user selects a row in the calls list */
397 voip_calls_on_select_row(GtkCList *clist,
400 GdkEventButton *event _U_,
401 gpointer user_data _U_)
403 GdkColor color = COLOR_DEFAULT;
404 gchar label_text[80];
406 selected_call_fwd = gtk_clist_get_row_data(GTK_CLIST(clist), row);
408 if (selected_call_fwd==NULL)
411 if (!selected_call_fwd->selected)
416 g_snprintf(label_text, 256,
417 "Detected %d VoIP %s. Selected %d %s.",
419 plurality(calls_nb, "Call", "Calls"),
421 plurality(calls_ns, "Call", "Calls"));
422 gtk_label_set(GTK_LABEL(top_label), label_text);
424 g_snprintf(label_text, 80, "Selected Call: From %s To %s, starting time %i.%i",
425 selected_call_fwd->from_identity,
426 selected_call_fwd->to_identity,
427 selected_call_fwd->start_sec,
428 selected_call_fwd->start_usec
430 gtk_label_set_text(GTK_LABEL(label_fwd), label_text);
432 selected_call_fwd->selected=!selected_call_fwd->selected;
433 if (selected_call_fwd->selected)
434 color = COLOR_SELECT;
436 color = COLOR_DEFAULT;
438 gtk_clist_set_background(GTK_CLIST(clist), row, &color);
441 gtk_widget_set_sensitive(bt_filter, TRUE);
442 gtk_widget_set_sensitive(bt_graph, TRUE);
444 gtk_widget_set_sensitive(bt_filter, FALSE);
445 gtk_widget_set_sensitive(bt_graph, FALSE);
448 /* TODO: activate other buttons when implemented */
452 /****************************************************************************/
454 typedef struct column_arrows {
456 GtkWidget *ascend_pm;
457 GtkWidget *descend_pm;
461 /****************************************************************************/
463 voip_calls_click_column_cb(GtkCList *clist, gint column, gpointer data)
465 column_arrows *col_arrows = (column_arrows *) data;
468 gtk_clist_freeze(clist);
470 for (i=0; i<NUM_COLS; i++) {
471 gtk_widget_hide(col_arrows[i].ascend_pm);
472 gtk_widget_hide(col_arrows[i].descend_pm);
475 if (column == clist->sort_column) {
476 if (clist->sort_type == GTK_SORT_ASCENDING) {
477 clist->sort_type = GTK_SORT_DESCENDING;
478 gtk_widget_show(col_arrows[column].descend_pm);
480 clist->sort_type = GTK_SORT_ASCENDING;
481 gtk_widget_show(col_arrows[column].ascend_pm);
484 clist->sort_type = GTK_SORT_ASCENDING;
485 gtk_widget_show(col_arrows[column].ascend_pm);
486 gtk_clist_set_sort_column(clist, column);
488 gtk_clist_thaw(clist);
490 gtk_clist_sort(clist);
494 /****************************************************************************/
496 voip_calls_sort_column(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2)
502 const GtkCListRow *row1 = (const GtkCListRow *) ptr1;
503 const GtkCListRow *row2 = (const GtkCListRow *) ptr2;
505 text1 = GTK_CELL_TEXT (row1->cell[clist->sort_column])->text;
506 text2 = GTK_CELL_TEXT (row2->cell[clist->sort_column])->text;
508 switch(clist->sort_column){
511 if ((sscanf(text1, "%u.%u", &i1, &i2) != 2) ||
512 (sscanf(text2, "%u.%u", &i3, &i4) != 2) ){
526 return strcmp (text1, text2);
532 g_assert_not_reached();
537 /****************************************************************************/
539 /****************************************************************************/
541 static void voip_calls_dlg_create (void)
543 GtkWidget *voip_calls_dlg_w;
545 GtkWidget *scrolledwindow;
546 GtkWidget *hbuttonbox;
548 GtkTooltips *tooltips = gtk_tooltips_new();
550 const gchar *titles[NUM_COLS] = {"Start Time", "Stop Time", "Initial Speaker", "From", "To", "Protocol", "Packets", "State", "Comments"};
551 column_arrows *col_arrows;
552 GtkWidget *column_lb;
555 voip_calls_dlg_w=window_new(GTK_WINDOW_TOPLEVEL, "Ethereal: VoIP Calls");
557 gtk_window_set_default_size(GTK_WINDOW(voip_calls_dlg_w), 840, 350);
559 main_vb = gtk_vbox_new (FALSE, 0);
560 gtk_container_add(GTK_CONTAINER(voip_calls_dlg_w), main_vb);
561 gtk_container_set_border_width (GTK_CONTAINER (main_vb), 12);
563 top_label = gtk_label_new ("Detected 0 VoIP Calls. Selected 0 Calls.");
564 gtk_box_pack_start (GTK_BOX (main_vb), top_label, FALSE, FALSE, 8);
566 scrolledwindow = scrolled_window_new (NULL, NULL);
567 gtk_box_pack_start (GTK_BOX (main_vb), scrolledwindow, TRUE, TRUE, 0);
569 clist = gtk_clist_new (NUM_COLS);
570 gtk_container_add (GTK_CONTAINER (scrolledwindow), clist);
572 gtk_clist_set_column_width (GTK_CLIST (clist), 0, 60);
573 gtk_clist_set_column_width (GTK_CLIST (clist), 1, 60);
574 gtk_clist_set_column_width (GTK_CLIST (clist), 2, 80);
575 gtk_clist_set_column_width (GTK_CLIST (clist), 3, 130);
576 gtk_clist_set_column_width (GTK_CLIST (clist), 4, 130);
577 gtk_clist_set_column_width (GTK_CLIST (clist), 5, 50);
578 gtk_clist_set_column_width (GTK_CLIST (clist), 6, 45);
579 gtk_clist_set_column_width (GTK_CLIST (clist), 7, 60);
580 gtk_clist_set_column_width (GTK_CLIST (clist), 8, 100);
582 gtk_clist_set_column_justification(GTK_CLIST(clist), 0, GTK_JUSTIFY_LEFT);
583 gtk_clist_set_column_justification(GTK_CLIST(clist), 1, GTK_JUSTIFY_LEFT);
584 gtk_clist_set_column_justification(GTK_CLIST(clist), 2, GTK_JUSTIFY_LEFT);
585 gtk_clist_set_column_justification(GTK_CLIST(clist), 3, GTK_JUSTIFY_LEFT);
586 gtk_clist_set_column_justification(GTK_CLIST(clist), 4, GTK_JUSTIFY_LEFT);
587 gtk_clist_set_column_justification(GTK_CLIST(clist), 5, GTK_JUSTIFY_CENTER);
588 gtk_clist_set_column_justification(GTK_CLIST(clist), 6, GTK_JUSTIFY_CENTER);
589 gtk_clist_set_column_justification(GTK_CLIST(clist), 7, GTK_JUSTIFY_LEFT);
590 gtk_clist_set_column_justification(GTK_CLIST(clist), 8, GTK_JUSTIFY_LEFT);
592 gtk_clist_column_titles_show (GTK_CLIST (clist));
594 gtk_clist_set_compare_func(GTK_CLIST(clist), voip_calls_sort_column);
595 gtk_clist_set_sort_column(GTK_CLIST(clist), 0);
596 gtk_clist_set_sort_type(GTK_CLIST(clist), GTK_SORT_ASCENDING);
598 gtk_widget_show(voip_calls_dlg_w);
600 /* sort by column feature */
601 col_arrows = (column_arrows *) g_malloc(sizeof(column_arrows) * NUM_COLS);
603 for (i=0; i<NUM_COLS; i++) {
604 col_arrows[i].table = gtk_table_new(2, 2, FALSE);
605 gtk_table_set_col_spacings(GTK_TABLE(col_arrows[i].table), 5);
606 column_lb = gtk_label_new(titles[i]);
607 gtk_table_attach(GTK_TABLE(col_arrows[i].table), column_lb, 0, 1, 0, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
608 gtk_widget_show(column_lb);
610 col_arrows[i].ascend_pm = xpm_to_widget(clist_ascend_xpm);
611 gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].ascend_pm, 1, 2, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
612 col_arrows[i].descend_pm = xpm_to_widget(clist_descend_xpm);
613 gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].descend_pm, 1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
614 /* make start time be the default sort order */
616 gtk_widget_show(col_arrows[i].ascend_pm);
618 gtk_clist_set_column_widget(GTK_CLIST(clist), i, col_arrows[i].table);
619 gtk_widget_show(col_arrows[i].table);
622 SIGNAL_CONNECT(clist, "click-column", voip_calls_click_column_cb, col_arrows);
624 label_fwd = gtk_label_new (FWD_LABEL_TEXT);
625 gtk_box_pack_start (GTK_BOX (main_vb), label_fwd, FALSE, FALSE, 0);
627 status_label = gtk_label_new ("Total: Calls: 0 Start packets: 0 Completed calls: 0 Rejected calls: 0");
628 gtk_box_pack_start (GTK_BOX (main_vb), status_label, FALSE, FALSE, 8);
631 hbuttonbox = gtk_hbutton_box_new ();
632 gtk_box_pack_start (GTK_BOX (main_vb), hbuttonbox, FALSE, FALSE, 0);
633 gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox), GTK_BUTTONBOX_SPREAD);
634 gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbuttonbox), 30);
636 /*bt_unselect = gtk_button_new_with_label ("Unselect");
637 gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_unselect);
638 gtk_tooltips_set_tip (tooltips, bt_unselect, "Unselect this conversation", NULL);*/
640 bt_filter = gtk_button_new_with_label ("Prepare Filter");
641 gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_filter);
642 gtk_tooltips_set_tip (tooltips, bt_filter, "Prepare a display filter of the selected conversation", NULL);
644 bt_graph = gtk_button_new_with_label("Graph");
645 gtk_container_add(GTK_CONTAINER(hbuttonbox), bt_graph);
646 gtk_widget_show(bt_graph);
647 SIGNAL_CONNECT(bt_graph, "clicked", on_graph_bt_clicked, NULL);
648 gtk_tooltips_set_tip (tooltips, bt_graph, "Show a flow graph of the selected calls.", NULL);
650 bt_close = BUTTON_NEW_FROM_STOCK(GTK_STOCK_CLOSE);
651 gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_close);
652 GTK_WIDGET_SET_FLAGS(bt_close, GTK_CAN_DEFAULT);
653 gtk_tooltips_set_tip (tooltips, bt_close, "Close this dialog", NULL);
655 SIGNAL_CONNECT(clist, "select_row", voip_calls_on_select_row, NULL);
656 /*SIGNAL_CONNECT(bt_unselect, "clicked", voip_calls_on_unselect, NULL);*/
657 SIGNAL_CONNECT(bt_filter, "clicked", voip_calls_on_filter, NULL);
659 window_set_cancel_button(voip_calls_dlg_w, bt_close, window_cancel_button_cb);
661 SIGNAL_CONNECT(voip_calls_dlg_w, "delete_event", window_delete_event_cb, NULL);
662 SIGNAL_CONNECT(voip_calls_dlg_w, "destroy", voip_calls_on_destroy, NULL);
664 gtk_widget_show_all(voip_calls_dlg_w);
665 window_present(voip_calls_dlg_w);
667 voip_calls_on_unselect(NULL, NULL);
669 voip_calls_dlg = voip_calls_dlg_w;
673 /****************************************************************************/
675 /****************************************************************************/
677 /****************************************************************************/
678 /* update the contents of the dialog box clist */
679 /* list: pointer to list of voip_calls_info_t* */
681 void voip_calls_dlg_update(GList *list)
683 gchar label_text[256];
684 if (voip_calls_dlg != NULL) {
688 g_snprintf(label_text, 256,
689 "Total: Calls: %d Start packets: %d Completed calls: %d Rejected calls: %d",
690 g_list_length(voip_calls_get_info()->strinfo_list),
691 voip_calls_get_info()->start_packets,
692 voip_calls_get_info()->completed_calls,
693 voip_calls_get_info()->rejected_calls);
694 gtk_label_set(GTK_LABEL(status_label), label_text);
696 gtk_clist_freeze(GTK_CLIST(clist));
697 gtk_clist_clear(GTK_CLIST(clist));
698 list = g_list_first(list);
701 add_to_clist((voip_calls_info_t*)(list->data));
702 list = g_list_next(list);
704 gtk_clist_thaw(GTK_CLIST(clist));
706 g_snprintf(label_text, 256,
707 "Detected %d VoIP %s. Selected %d %s.",
709 plurality(calls_nb, "Call", "Calls"),
711 plurality(calls_ns, "Call", "Calls"));
712 gtk_label_set(GTK_LABEL(top_label), label_text);
719 /****************************************************************************/
720 /* draw function for tap listeners to keep the window up to date */
721 void voip_calls_dlg_draw(void *ptr _U_)
723 if (voip_calls_get_info()->redraw) {
724 voip_calls_dlg_update(voip_calls_get_info()->strinfo_list);
725 voip_calls_get_info()->redraw = FALSE;
729 /* reset function for tap listeners to clear window, if necessary */
730 void voip_calls_dlg_reset(void *ptr _U_)
732 /* Clean up memory used by calls tap */
733 voip_calls_reset((voip_calls_tapinfo_t*) voip_calls_get_info());
735 /* close the graph window if open */
736 if (graph_analysis_data->dlg.window != NULL) {
737 window_cancel_button_cb(NULL, graph_analysis_data->dlg.window);
738 graph_analysis_data->dlg.window = NULL;
742 /* init function for tap */
744 voip_calls_init_tap(const char *dummy _U_)
747 gchar *data[NUM_COLS];
748 gchar field[NUM_COLS][50];
750 if (graph_analysis_data == NULL) {
751 graph_analysis_data_init();
752 /* init the Graph Analysys */
753 graph_analysis_data = graph_analysis_init();
754 graph_analysis_data->graph_info = voip_calls_get_info()->graph_analysis;
757 /* Clean up memory used by calls tap */
758 voip_calls_reset((voip_calls_tapinfo_t*) voip_calls_get_info());
760 /* Register the tap listener */
761 sip_calls_init_tap();
762 mtp3_calls_init_tap();
763 isup_calls_init_tap();
764 h225_calls_init_tap();
765 h245dg_calls_init_tap();
766 q931_calls_init_tap();
767 sdp_calls_init_tap();
769 rtp_event_init_tap();
770 /* We don't register this tap, if we don't have the mgcp plugin loaded.*/
771 if (find_tap_id("mgcp")) {
772 mgcp_calls_init_tap();
774 actrace_calls_init_tap();
776 /* create dialog box if necessary */
777 if (voip_calls_dlg == NULL) {
778 voip_calls_dlg_create();
780 /* There's already a dialog box; reactivate it. */
781 reactivate_window(voip_calls_dlg);
784 voip_calls_get_info()->redraw = TRUE;
785 voip_calls_dlg_draw(NULL);
786 voip_calls_get_info()->redraw = TRUE;
787 for (c=0;c<NUM_COLS;c++){
788 data[c]=&field[c][0];
791 g_snprintf(field[3], 50, "Please wait...");
792 gtk_clist_append(GTK_CLIST(clist), data);
794 /* Scan for VoIP calls calls (redissect all packets) */
795 cf_retap_packets(&cfile);
797 /* Tap listener will be removed and cleaned up in voip_calls_on_destroy */
801 /****************************************************************************/
802 /* entry point when called via the GTK menu */
803 void voip_calls_launch(GtkWidget *w _U_, gpointer data _U_)
805 voip_calls_init_tap("");
808 /****************************************************************************/
810 register_tap_listener_voip_calls_dlg(void)
812 register_tap_listener_cmd_arg("voip,calls",voip_calls_init_tap);
813 register_tap_menu_item("VoIP Calls...", REGISTER_TAP_GROUP_TELEPHONY,
814 voip_calls_launch, NULL, NULL, NULL);