/* voip_calls_dlg.c
- * VoIP calls summary addition for ethereal
+ * VoIP calls summary addition for Wireshark
*
* $Id$
*
* By Alejandro Vaquero, alejandro.vaquero@verso.com
* Copyright 2005, Verso Technologies Inc.
*
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
# include <config.h>
#endif
+#include <stdio.h>
#include <string.h>
#include <ctype.h>
-#include "register.h"
+#include "gtk/gtk.h"
-#include "graph_analysis.h"
-#include "voip_calls_dlg.h"
-#include "voip_calls.h"
-
-#include "globals.h"
+#include <epan/epan.h>
+#include <epan/packet.h>
#include "epan/filesystem.h"
-
#include <epan/tap.h>
-#include "tap_menu.h"
-#include "dlg_utils.h"
-#include "ui_util.h"
-#include "compat_macros.h"
-#include "gtkglobals.h"
-
-#include "image/clist_ascend.xpm"
-#include "image/clist_descend.xpm"
-#include "simple_dialog.h"
-
+#include <epan/stat_cmd_args.h>
#include <epan/to_str.h>
-
-#include <string.h>
-#include <ctype.h>
#include <epan/address.h>
#include <epan/addr_resolv.h>
-
-static const gchar FWD_LABEL_TEXT[] = "Select one call.";
+#include <epan/dissectors/packet-h248.h>
+
+#include "../globals.h"
+#include "../stat_menu.h"
+
+#include "gtk/graph_analysis.h"
+#include "gtk/voip_calls_dlg.h"
+#include "gtk/voip_calls.h"
+#include "gtk/gui_stat_menu.h"
+#include "gtk/dlg_utils.h"
+#include "gtk/gui_utils.h"
+#include "gtk/gtkglobals.h"
+#include "gtk/stock_icons.h"
+
+#include "simple_dialog.h"
+
+#ifdef HAVE_LIBPORTAUDIO
+#include "gtk/rtp_analysis.h"
+#include "gtk/rtp_player.h"
+#endif /* HAVE_LIBPORTAUDIO */
+
+#include "gtk/old-gtk-compat.h"
/****************************************************************************/
/* pointer to the one and only dialog window */
static GtkWidget *voip_calls_dlg = NULL;
-static GtkWidget *clist = NULL;
-static GtkWidget *top_label = NULL;
-static GtkWidget *status_label = NULL;
-static GtkWidget *label_fwd = NULL;
-
-/*static GtkWidet *bt_unselect = NULL;*/
-static GtkWidget *bt_filter = NULL;
-static GtkWidget *bt_graph = NULL;
+static GtkListStore *list_store = NULL;
+static GtkTreeIter list_iter;
+static GtkWidget *list = NULL;
+static GtkWidget *top_label = NULL;
+static GtkWidget *status_label = NULL;
-static voip_calls_info_t* selected_call_fwd = NULL; /* current selection */
-static GList *last_list = NULL;
+/*static GtkWidet *bt_unselect = NULL;*/
+static GtkWidget *bt_filter = NULL;
+static GtkWidget *bt_graph = NULL;
+#ifdef HAVE_LIBPORTAUDIO
+static GtkWidget *bt_player = NULL;
+#endif /* HAVE_LIBPORTAUDIO */
static guint32 calls_nb = 0; /* number of displayed calls */
static guint32 calls_ns = 0; /* number of selected calls */
-static graph_analysis_data_t *graph_analysis_data;
+static graph_analysis_data_t *graph_analysis_data = NULL;
-#define NUM_COLS 9
-
-/****************************************************************************/
-/* append a line to clist */
-static void add_to_clist(voip_calls_info_t* strinfo)
+enum
{
- gchar label_text[256];
- gint added_row;
- gchar *data[NUM_COLS];
- gchar field[NUM_COLS][50];
- gint c;
- isup_calls_info_t *tmp_isupinfo;
- h323_calls_info_t *tmp_h323info;
- gboolean tmp_bool = FALSE;
- for (c=0;c<NUM_COLS;c++){
- data[c]=&field[c][0];
- }
-
-
- g_snprintf(field[0], 15, "%i.%2i", strinfo->start_sec, strinfo->start_usec/10000);
- g_snprintf(field[1], 15, "%i.%2i", strinfo->stop_sec, strinfo->stop_usec/10000);
-/* xxx display_signed_time(data[0], sizeof(field[0]), strinfo->start_sec, strinfo->start_usec, USECS); */
-/* display_signed_time(data[1], sizeof(field[0]), strinfo->stop_sec, strinfo->stop_usec, USECS); */
- g_snprintf(field[2], 30, "%s", get_addr_name(&(strinfo->initial_speaker)));
- g_snprintf(field[3], 50, "%s", strinfo->from_identity);
- g_snprintf(field[4], 50, "%s", strinfo->to_identity);
- g_snprintf(field[5], 15, "%s", voip_protocol_name[strinfo->protocol]);
- g_snprintf(field[6], 15, "%u", strinfo->npackets);
- g_snprintf(field[7], 15, "%s", voip_call_state_name[strinfo->call_state]);
-
- /* Add comments based on the protocol */
- switch(strinfo->protocol){
- case VOIP_ISUP:
- tmp_isupinfo = strinfo->prot_info;
- g_snprintf(field[8],30, "%i-%i -> %i-%i", tmp_isupinfo->ni, tmp_isupinfo->opc,
- tmp_isupinfo->ni, tmp_isupinfo->dpc);
- break;
- case VOIP_H323:
- tmp_h323info = strinfo->prot_info;
- if (strinfo->call_state == VOIP_CALL_SETUP)
- tmp_bool = tmp_h323info->is_faststart_Setup;
- else
- if ((tmp_h323info->is_faststart_Setup == TRUE) && (tmp_h323info->is_faststart_Proc == TRUE)) tmp_bool = TRUE;
- g_snprintf(field[8],35, "Tunneling: %s Fast Start: %s", (tmp_h323info->is_h245Tunneling==TRUE?"ON":"OFF"),
- (tmp_bool==TRUE?"ON":"OFF"));
- break;
- default:
- field[8][0]='\0';
- }
-
-
- added_row = gtk_clist_append(GTK_CLIST(clist), data);
-
- /* set data pointer of last row to point to user data for that row */
- gtk_clist_set_row_data(GTK_CLIST(clist), added_row, strinfo);
-
- /* Update the top label with the number of detected calls */
- calls_nb++;
- g_snprintf(label_text, 256,
- "Detected %d VoIP %s. Selected %d %s.",
- calls_nb,
- plurality(calls_nb, "Call", "Calls"),
- calls_ns,
- plurality(calls_ns, "Call", "Calls"));
- gtk_label_set(GTK_LABEL(top_label), label_text);
-
- /* Update the status label with the number of total messages */
- g_snprintf(label_text, 256,
- "Total: Calls: %d Start packets: %d Completed calls: %d Rejected calls: %d",
- g_list_length(voip_calls_get_info()->strinfo_list),
- voip_calls_get_info()->start_packets,
- voip_calls_get_info()->completed_calls,
- voip_calls_get_info()->rejected_calls);
- gtk_label_set(GTK_LABEL(status_label), label_text);
-}
+ CALL_COL_START_TIME,
+ CALL_COL_STOP_TIME,
+ CALL_COL_INITIAL_SPEAKER,
+ CALL_COL_FROM,
+ CALL_COL_TO,
+ CALL_COL_PROTOCOL,
+ CALL_COL_PACKETS,
+ CALL_COL_STATE,
+ CALL_COL_COMMENTS,
+ CALL_COL_DATA,
+ NUM_COLS /* The number of columns */
+};
-void voip_calls_remove_tap_listener(void)
+/****************************************************************************/
+static void
+voip_calls_remove_tap_listener(void)
{
/* Remove the calls tap listener */
remove_tap_listener_sip_calls();
remove_tap_listener_h225_calls();
remove_tap_listener_h245dg_calls();
remove_tap_listener_q931_calls();
+ remove_tap_listener_h248_calls();
+ remove_tap_listener_sccp_calls();
remove_tap_listener_sdp_calls();
remove_tap_listener_rtp();
- remove_tap_listener_rtp_event();
- if (find_tap_id("mgcp")) {
- remove_tap_listener_mgcp_calls();
+ if (find_tap_id("unistim")) { /* The plugin may be missing */
+ remove_tap_listener_unistim_calls();
+ }
+ if (find_tap_id("voip")) {
+ remove_tap_listener_voip_calls();
}
+ remove_tap_listener_rtp_event();
+ remove_tap_listener_mgcp_calls();
+ remove_tap_listener_actrace_calls();
+ remove_tap_listener_skinny_calls();
+ remove_tap_listener_iax2_calls();
+ remove_tap_listener_t38();
}
/****************************************************************************/
/* CALLBACKS */
/****************************************************************************/
static void
-voip_calls_on_destroy (GtkObject *object _U_,
- gpointer user_data _U_)
+voip_calls_on_destroy(GObject *object _U_, gpointer user_data _U_)
{
/* remove_tap_listeners */
voip_calls_remove_tap_listener();
/* Clean up memory used by calls tap */
- voip_calls_reset((voip_calls_tapinfo_t*) voip_calls_get_info());
+ voip_calls_dlg_reset(NULL);
/* Note that we no longer have a "VoIP Calls" dialog box. */
voip_calls_dlg = NULL;
-}
+ /* Clean up graph analysis memory */
+ g_free(graph_analysis_data);
+ graph_analysis_data = NULL;
+}
/****************************************************************************/
static void
-voip_calls_on_unselect (GtkButton *button _U_,
- gpointer user_data _U_)
+voip_calls_on_unselect(GtkButton *button _U_, gpointer user_data _U_)
{
- selected_call_fwd = NULL;
- gtk_clist_unselect_all(GTK_CLIST(clist));
- gtk_label_set_text(GTK_LABEL(label_fwd), FWD_LABEL_TEXT);
-
/*gtk_widget_set_sensitive(bt_unselect, FALSE);*/
gtk_widget_set_sensitive(bt_filter, FALSE);
gtk_widget_set_sensitive(bt_graph, FALSE);
+#ifdef HAVE_LIBPORTAUDIO
+ gtk_widget_set_sensitive(bt_player, FALSE);
+#endif /* HAVE_LIBPORTAUDIO */
}
-
/****************************************************************************/
static void
-voip_calls_on_filter (GtkButton *button _U_,
- gpointer user_data _U_)
+voip_calls_on_filter(GtkButton *button _U_, gpointer user_data _U_)
{
- const gchar *filter_string;
- gchar c;
+ gchar *filter_string;
GString *filter_string_fwd;
- gchar *filter_prepend;
- gboolean isFirst = TRUE;
- GList* list;
- guint filter_length = 0;
- guint max_filter_length = 2048;
- sip_calls_info_t *tmp_sipinfo;
- isup_calls_info_t *tmp_isupinfo;
- h323_calls_info_t *tmp_h323info;
- h245_address_t *h245_add = NULL;
-
+ const gchar *filter_prepend;
+ gboolean is_first = TRUE;
+ GList* lista;
+ GList* listb;
+ voip_calls_info_t *listinfo;
graph_analysis_item_t *gai;
+ size_t filter_length;
+ size_t max_filter_length = 2048; /* What's this based on ? */
+ int pos;
- if (selected_call_fwd==NULL)
- return;
+ const sip_calls_info_t *sipinfo;
+ const isup_calls_info_t *isupinfo;
+ const h323_calls_info_t *h323info;
+ const h245_address_t *h245_add = NULL;
+ const gcp_ctx_t* ctx;
- filter_string=gtk_entry_get_text(GTK_ENTRY(main_display_filter_widget));
+ filter_string = g_strdup(gtk_entry_get_text(GTK_ENTRY(main_display_filter_widget)));
filter_length = strlen(filter_string);
- filter_prepend = "";
- while ((c = *filter_string++) != '\0') {
- if (!isspace((guchar)c)) {
- /* The filter string isn't blank, so there's already
- an expression; we OR in the new expression */
- filter_prepend = " or ";
- break;
- }
- }
-
+ pos = (int)filter_length; /* we assume the filter won't be more than 2^31-1 octets long */
+ g_strstrip(filter_string);
+
+ if (strlen(filter_string) > 0)
+ filter_prepend = " or ";
+ else
+ filter_prepend = "";
+ g_free(filter_string);
+
filter_string_fwd = g_string_new(filter_prepend);
-
+
/* look in the Graph and get all the frame_num for this call */
- g_string_sprintfa(filter_string_fwd, " (");
- list = g_list_first(voip_calls_get_info()->graph_analysis->list);
- while (list)
- {
- gai = list->data;
- if (gai->conv_num == selected_call_fwd->call_num){
- g_string_sprintfa(filter_string_fwd,"%sframe.number == %d", isFirst?"":" or ", gai->frame_num );
- isFirst = FALSE;
- }
- list = g_list_next (list);
+ g_string_append_printf(filter_string_fwd, "(");
+
+ /* Build a new filter based on frame numbers */
+ lista = g_list_first(voip_calls_get_info()->callsinfo_list);
+ while (lista) {
+ listinfo = lista->data;
+ if (listinfo->selected) {
+ listb = g_list_first(voip_calls_get_info()->graph_analysis->list);
+ while (listb) {
+ gai = listb->data;
+ if (gai->conv_num == listinfo->call_num) {
+ g_string_append_printf(filter_string_fwd, "%sframe.number == %u", is_first?"":" or ", gai->frame_num);
+ is_first = FALSE;
+ }
+ listb = g_list_next(listb);
+ }
+ }
+ lista = g_list_next(lista);
}
- g_string_sprintfa(filter_string_fwd, ") ");
- filter_length = filter_length + filter_string_fwd->len;
- if (filter_length < max_filter_length){
- gtk_entry_append_text(GTK_ENTRY(main_display_filter_widget), filter_string_fwd->str);
- }
- else{
+ g_string_append_printf(filter_string_fwd, ")");
+ filter_length += filter_string_fwd->len;
+ if (filter_length < max_filter_length) {
+ gtk_editable_insert_text(GTK_EDITABLE(main_display_filter_widget), filter_string_fwd->str, -1, &pos);
+ } else {
g_string_free(filter_string_fwd, TRUE);
filter_string_fwd = g_string_new(filter_prepend);
- switch(selected_call_fwd->protocol){
- case VOIP_SIP:
- tmp_sipinfo = selected_call_fwd->prot_info;
- g_string_sprintfa(filter_string_fwd,
- "(sip.Call-ID == \"%s\") ",
- tmp_sipinfo->call_identifier
- );
- gtk_entry_append_text(GTK_ENTRY(main_display_filter_widget), filter_string_fwd->str);
- break;
- case VOIP_ISUP:
- tmp_isupinfo = selected_call_fwd->prot_info;
- g_string_sprintfa(filter_string_fwd,
- "(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))) ",
- tmp_isupinfo->cic,selected_call_fwd->first_frame_num,
- selected_call_fwd->last_frame_num,
- tmp_isupinfo->ni, tmp_isupinfo->dpc, tmp_isupinfo->opc,
- tmp_isupinfo->opc, tmp_isupinfo->dpc
- );
- gtk_entry_append_text(GTK_ENTRY(main_display_filter_widget), filter_string_fwd->str);
- break;
- case VOIP_H323:
- tmp_h323info = selected_call_fwd->prot_info;
- g_string_sprintfa(filter_string_fwd,
- "((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) ",
- (guint8)tmp_h323info->guid[0], (guint8)tmp_h323info->guid[1], (guint8)tmp_h323info->guid[2],
- (guint8)tmp_h323info->guid[3], (guint8)tmp_h323info->guid[4], (guint8)tmp_h323info->guid[5], (guint8)tmp_h323info->guid[6],
- (guint8)tmp_h323info->guid[7], (guint8)tmp_h323info->guid[8], (guint8)tmp_h323info->guid[9], (guint8)tmp_h323info->guid[10],
- (guint8)tmp_h323info->guid[11], (guint8)tmp_h323info->guid[12], (guint8)tmp_h323info->guid[13], (guint8)tmp_h323info->guid[14],
- (guint8)tmp_h323info->guid[15], (guint8)(tmp_h323info->q931_crv & 0xff), (guint8)((tmp_h323info->q931_crv & 0xff00)>>8)
- , (guint8)(tmp_h323info->q931_crv2 & 0xff), (guint8)((tmp_h323info->q931_crv2 & 0xff00)>>8));
- list = g_list_first(tmp_h323info->h245_list);
- while (list)
- {
- h245_add=list->data;
- g_string_sprintfa(filter_string_fwd,
- " || (ip.addr == %s && tcp.port == %d && h245) ",
- ip_to_str((guint8 *)&(h245_add->h245_address)), h245_add->h245_port);
- list = g_list_next(list);
+ g_string_append_printf(filter_string_fwd, "(");
+ is_first = TRUE;
+ /* Build a new filter based on protocol fields */
+ lista = g_list_first(voip_calls_get_info()->callsinfo_list);
+ while (lista) {
+ listinfo = lista->data;
+ if (listinfo->selected) {
+ if (!is_first)
+ g_string_append_printf(filter_string_fwd, " or ");
+ switch (listinfo->protocol) {
+ case VOIP_SIP:
+ sipinfo = listinfo->prot_info;
+ g_string_append_printf(filter_string_fwd,
+ "(sip.Call-ID == \"%s\")",
+ sipinfo->call_identifier
+ );
+ break;
+ case VOIP_ISUP:
+ isupinfo = listinfo->prot_info;
+ g_string_append_printf(filter_string_fwd,
+ "(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)))",
+ isupinfo->cic, listinfo->first_frame_num,
+ listinfo->last_frame_num,
+ isupinfo->ni, isupinfo->dpc, isupinfo->opc,
+ isupinfo->opc, isupinfo->dpc
+ );
+ break;
+ case VOIP_H323:
+ h323info = listinfo->prot_info;
+ g_string_append_printf(filter_string_fwd,
+ "((h225.guid == %s || q931.call_ref == %x:%x || q931.call_ref == %x:%x)",
+ guid_to_str(&h323info->guid[0]),
+ (guint8) (h323info->q931_crv & 0x00ff),
+ (guint8)((h323info->q931_crv & 0xff00)>>8),
+ (guint8) (h323info->q931_crv2 & 0x00ff),
+ (guint8)((h323info->q931_crv2 & 0xff00)>>8));
+ listb = g_list_first(h323info->h245_list);
+ while (listb) {
+ h245_add = listb->data;
+ g_string_append_printf(filter_string_fwd,
+ " || (ip.addr == %s && tcp.port == %d && h245)",
+ ip_to_str((guint8 *)(h245_add->h245_address.data)), h245_add->h245_port);
+ listb = g_list_next(listb);
+ }
+ g_string_append_printf(filter_string_fwd, ")");
+ break;
+ case TEL_H248:
+ ctx = listinfo->prot_info;
+ g_string_append_printf(filter_string_fwd,
+ "(h248.ctx == 0x%x)", ctx->id);
+ break;
+ default:
+ /* placeholder to assure valid display filter expression */
+ g_string_append_printf(filter_string_fwd,
+ "(frame)");
+ break;
}
- g_string_sprintfa(filter_string_fwd, ") ");
- gtk_entry_append_text(GTK_ENTRY(main_display_filter_widget), filter_string_fwd->str);
- break;
- case VOIP_MGCP:
- /* XXX - not supported */
- break;
+ is_first = FALSE;
+ }
+ lista = g_list_next(lista);
}
-
+
+ g_string_append_printf(filter_string_fwd, ")");
+ gtk_editable_insert_text(GTK_EDITABLE(main_display_filter_widget), filter_string_fwd->str, -1, &pos);
}
-
+
g_string_free(filter_string_fwd, TRUE);
}
-
-
-
/****************************************************************************/
-
-static void help_bt_clicked( GtkButton *button _U_)
+static void
+voip_calls_on_select_all(GtkButton *button _U_, gpointer user_data _U_)
{
- browser_open_url("http://wiki.ethereal.com/VoIP_20calls");
-}
-
+ GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(list));
+ gtk_tree_selection_select_all(selection);
+}
+/****************************************************************************/
static void
-on_graph_bt_clicked (GtkButton *button _U_,
- gpointer user_data _U_)
+on_graph_bt_clicked(GtkButton *button _U_, gpointer user_data _U_)
{
graph_analysis_item_t *gai;
- GList* list;
- GList* list2;
- voip_calls_info_t *tmp_listinfo;
+ GList* lista;
+ GList* listb;
+ voip_calls_info_t *listinfo;
/* reset the "display" parameter in graph analysis */
- list2 = g_list_first(voip_calls_get_info()->graph_analysis->list);
- while (list2){
- gai = list2->data;
+ listb = g_list_first(voip_calls_get_info()->graph_analysis->list);
+ while (listb) {
+ gai = listb->data;
gai->display = FALSE;
- list2 = g_list_next(list2);
+ listb = g_list_next(listb);
}
-
/* set the display for selected calls */
- list = g_list_first(voip_calls_get_info()->strinfo_list);
- while (list){
- tmp_listinfo=list->data;
- if (tmp_listinfo->selected){
- list2 = g_list_first(voip_calls_get_info()->graph_analysis->list);
- while (list2){
- gai = list2->data;
- if (gai->conv_num == tmp_listinfo->call_num){
+ lista = g_list_first(voip_calls_get_info()->callsinfo_list);
+ while (lista) {
+ listinfo = lista->data;
+ if (listinfo->selected) {
+ listb = g_list_first(voip_calls_get_info()->graph_analysis->list);
+ while (listb) {
+ gai = listb->data;
+ if (gai->conv_num == listinfo->call_num) {
gai->display = TRUE;
}
- list2 = g_list_next(list2);
+ listb = g_list_next(listb);
}
}
- list = g_list_next(list);
+ lista = g_list_next(lista);
}
/* create or refresh the graph windows */
- if (graph_analysis_data->dlg.window == NULL) /* create the window */
- graph_analysis_create(graph_analysis_data);
+ if (graph_analysis_data->dlg.window == NULL)
+ graph_analysis_create(graph_analysis_data); /* create the window */
else
- graph_analysis_update(graph_analysis_data); /* refresh it */
+ graph_analysis_update(graph_analysis_data); /* refresh it */
}
-static const GdkColor COLOR_SELECT = {0, 0x00ff, 0x80ff, 0x80ff};
-static const GdkColor COLOR_DEFAULT = {0, 0xffff, 0xffff, 0xffff};
+/****************************************************************************/
+#ifdef HAVE_LIBPORTAUDIO
+static void
+on_player_bt_clicked(GtkButton *button _U_, gpointer user_data _U_)
+{
+ rtp_player_init(voip_calls_get_info());
+}
+#endif /* HAVE_LIBPORTAUDIO */
/****************************************************************************/
/* when the user selects a row in the calls list */
+static gboolean
+voip_calls_mark_selected(GtkTreeModel *model, GtkTreePath *path _U_, GtkTreeIter *iter, gpointer data)
+{
+ GtkTreeSelection *selection = (GtkTreeSelection *)data;
+ voip_calls_info_t* strinfo;
+
+ gtk_tree_model_get(model, iter, CALL_COL_DATA, &strinfo, -1);
+ strinfo->selected = gtk_tree_selection_iter_is_selected(selection, iter);
+
+ return FALSE;
+}
+
static void
-voip_calls_on_select_row(GtkCList *clist,
- gint row _U_,
- gint column _U_,
- GdkEventButton *event _U_,
- gpointer user_data _U_)
+voip_calls_on_select_row_cb(GtkTreeSelection *selection, gpointer data _U_)
{
- GdkColor color = COLOR_DEFAULT;
gchar label_text[80];
-
- selected_call_fwd = gtk_clist_get_row_data(GTK_CLIST(clist), row);
- if (!selected_call_fwd->selected)
- calls_ns++;
- else
- calls_ns--;
+ gtk_tree_model_foreach(GTK_TREE_MODEL(list_store), voip_calls_mark_selected, selection);
+
+ calls_ns = gtk_tree_selection_count_selected_rows(selection);
- g_snprintf(label_text, 256,
- "Detected %d VoIP %s. Selected %d %s.",
- calls_nb,
- plurality(calls_nb, "Call", "Calls"),
+ g_snprintf(label_text, 80,
+ "Detected %u VoIP %s. Selected %u %s.",
+ calls_nb,
+ plurality(calls_nb, "Call", "Calls"),
calls_ns,
plurality(calls_ns, "Call", "Calls"));
- gtk_label_set(GTK_LABEL(top_label), label_text);
-
- g_snprintf(label_text, 80, "Selected Call: From %s To %s, starting time %i.%i",
- selected_call_fwd->from_identity,
- selected_call_fwd->to_identity,
- selected_call_fwd->start_sec,
- selected_call_fwd->start_usec
- );
- gtk_label_set_text(GTK_LABEL(label_fwd), label_text);
-
- selected_call_fwd->selected=!selected_call_fwd->selected;
- if (selected_call_fwd->selected)
- color = COLOR_SELECT;
- else
- color = COLOR_DEFAULT;
+ gtk_label_set_text(GTK_LABEL(top_label), label_text);
- gtk_clist_set_background(GTK_CLIST(clist), row, &color);
-
- /*gtk_widget_set_sensitive(bt_unselect, TRUE);*/
- gtk_widget_set_sensitive(bt_filter, TRUE);
- gtk_widget_set_sensitive(bt_graph, TRUE);
-
- /* TODO: activate other buttons when implemented */
+ gtk_widget_set_sensitive(bt_filter, calls_ns ? TRUE : FALSE);
+ gtk_widget_set_sensitive(bt_graph, calls_ns ? TRUE : FALSE);
+#ifdef HAVE_LIBPORTAUDIO
+ gtk_widget_set_sensitive(bt_player, calls_ns ? TRUE : FALSE);
+#endif /* HAVE_LIBPORTAUDIO */
}
-
/****************************************************************************/
-
-typedef struct column_arrows {
- GtkWidget *table;
- GtkWidget *ascend_pm;
- GtkWidget *descend_pm;
-} column_arrows;
-
-
+/* Tree view constructors */
/****************************************************************************/
+/* append a line to list */
static void
-voip_calls_click_column_cb(GtkCList *clist, gint column, gpointer data)
+add_to_list_store(voip_calls_info_t* strinfo)
{
- column_arrows *col_arrows = (column_arrows *) data;
- int i;
-
- gtk_clist_freeze(clist);
-
- for (i=0; i<NUM_COLS; i++) {
- gtk_widget_hide(col_arrows[i].ascend_pm);
- gtk_widget_hide(col_arrows[i].descend_pm);
- }
+ gchar field[NUM_COLS][50];
+ isup_calls_info_t *isupinfo;
+ h323_calls_info_t *h323info;
+ gboolean flag = FALSE;
+
+ g_snprintf(field[CALL_COL_INITIAL_SPEAKER], 30, "%s", get_addr_name(&(strinfo->initial_speaker)));
+ g_snprintf(field[CALL_COL_FROM], 50, "%s", strinfo->from_identity);
+ g_snprintf(field[CALL_COL_TO], 50, "%s", strinfo->to_identity);
+ g_snprintf(field[CALL_COL_PROTOCOL], 15, "%s",
+ ((strinfo->protocol==VOIP_COMMON)&&strinfo->protocol_name)?
+ strinfo->protocol_name:voip_protocol_name[strinfo->protocol]);
+ g_snprintf(field[CALL_COL_STATE], 15, "%s", voip_call_state_name[strinfo->call_state]);
- if (column == clist->sort_column) {
- if (clist->sort_type == GTK_SORT_ASCENDING) {
- clist->sort_type = GTK_SORT_DESCENDING;
- gtk_widget_show(col_arrows[column].descend_pm);
- } else {
- clist->sort_type = GTK_SORT_ASCENDING;
- gtk_widget_show(col_arrows[column].ascend_pm);
- }
- } else {
- clist->sort_type = GTK_SORT_ASCENDING;
- gtk_widget_show(col_arrows[column].ascend_pm);
- gtk_clist_set_sort_column(clist, column);
+ /* Add comments based on the protocol */
+ switch (strinfo->protocol) {
+ case VOIP_ISUP:
+ isupinfo = strinfo->prot_info;
+ g_snprintf(field[CALL_COL_COMMENTS],30, "%i-%i -> %i-%i", isupinfo->ni, isupinfo->opc,
+ isupinfo->ni, isupinfo->dpc);
+ break;
+ case VOIP_H323:
+ h323info = strinfo->prot_info;
+ if (strinfo->call_state == VOIP_CALL_SETUP)
+ flag = h323info->is_faststart_Setup;
+ else
+ if ((h323info->is_faststart_Setup == TRUE) && (h323info->is_faststart_Proc == TRUE))
+ flag = TRUE;
+ g_snprintf(field[CALL_COL_COMMENTS],35, "Tunneling: %s Fast Start: %s",
+ (h323info->is_h245Tunneling==TRUE?"ON":"OFF"),
+ (flag==TRUE?"ON":"OFF"));
+ break;
+ case VOIP_COMMON:
+ field[CALL_COL_COMMENTS][0]='\0';
+ if (strinfo->call_comment)
+ g_snprintf(field[CALL_COL_COMMENTS],30, "%s", strinfo->call_comment);
+ break;
+ default:
+ field[CALL_COL_COMMENTS][0]='\0';
}
- gtk_clist_thaw(clist);
- gtk_clist_sort(clist);
+ /* Acquire an iterator */
+ gtk_list_store_append(list_store, &list_iter);
+
+ /* Fill the new row */
+ gtk_list_store_set(list_store, &list_iter,
+ CALL_COL_START_TIME, nstime_to_sec(&strinfo->start_rel),
+ CALL_COL_STOP_TIME, nstime_to_sec(&strinfo->stop_rel),
+ CALL_COL_INITIAL_SPEAKER, &field[CALL_COL_INITIAL_SPEAKER][0],
+ CALL_COL_FROM, &field[CALL_COL_FROM][0],
+ CALL_COL_TO, &field[CALL_COL_TO][0],
+ CALL_COL_PROTOCOL, &field[CALL_COL_PROTOCOL][0],
+ CALL_COL_PACKETS, strinfo->npackets,
+ CALL_COL_STATE, &field[CALL_COL_STATE][0],
+ CALL_COL_COMMENTS, &field[CALL_COL_COMMENTS][0],
+ CALL_COL_DATA, strinfo,
+ -1);
+
+ calls_nb += 1;
}
-
/****************************************************************************/
-static gint
-voip_calls_sort_column(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2)
+/* Create list view */
+static void
+create_list_view(void)
{
- char *text1 = NULL;
- char *text2 = NULL;
- int i1, i2, i3, i4;
-
- const GtkCListRow *row1 = (const GtkCListRow *) ptr1;
- const GtkCListRow *row2 = (const GtkCListRow *) ptr2;
-
- text1 = GTK_CELL_TEXT (row1->cell[clist->sort_column])->text;
- text2 = GTK_CELL_TEXT (row2->cell[clist->sort_column])->text;
-
- switch(clist->sort_column){
- case 0:
- case 1:
- if ((sscanf(text1, "%u.%u", &i1, &i2) != 2) ||
- (sscanf(text2, "%u.%u", &i3, &i4) != 2) ){
- return 0;
- }
- if (i1>i3)
- return 1;
- if (i1<i3)
- return -1;
- return (i3-i4);
- case 2:
- case 3:
- case 4:
- case 5:
- case 7:
- case 8:
- return strcmp (text1, text2);
- case 6:
- i1=atoi(text1);
- i2=atoi(text2);
- return i1-i2;
- }
- g_assert_not_reached();
- return 0;
-}
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
+ GtkTreeSortable *sortable;
+ GtkTreeView *list_view;
+ GtkTreeSelection *selection;
+
+ /* Create the store */
+ list_store = gtk_list_store_new(NUM_COLS, /* Total number of columns XXX */
+ G_TYPE_DOUBLE, /* Start Time */
+ G_TYPE_DOUBLE, /* Stop Time */
+ G_TYPE_STRING, /* Initial Speaker */
+ G_TYPE_STRING, /* From */
+ G_TYPE_STRING, /* To */
+ G_TYPE_STRING, /* Protocol */
+ G_TYPE_UINT, /* Packets */
+ G_TYPE_STRING, /* State */
+ G_TYPE_STRING, /* Comments */
+ G_TYPE_POINTER /* Data */
+ );
+
+ /* Create a view */
+ list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(list_store));
+
+ /* The view now holds a reference. We can get rid of our own reference */
+ g_object_unref(G_OBJECT(list_store));
+
+ list_view = GTK_TREE_VIEW(list);
+ sortable = GTK_TREE_SORTABLE(list_store);
+
+ /* Speed up the list display */
+ gtk_tree_view_set_fixed_height_mode(list_view, TRUE);
+
+ /* Setup the sortable columns */
+ gtk_tree_sortable_set_sort_column_id(sortable, CALL_COL_START_TIME, GTK_SORT_ASCENDING);
+ gtk_tree_view_set_headers_clickable(list_view, FALSE);
+
+ /* Start Time */
+ renderer = gtk_cell_renderer_text_new();
+ g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL); /* right align */
+ g_object_set(G_OBJECT(renderer), "xpad", 10, NULL);
+ column = gtk_tree_view_column_new_with_attributes("Start Time", renderer,
+ "text", CALL_COL_START_TIME,
+ NULL);
+ gtk_tree_view_column_set_sort_column_id(column, CALL_COL_START_TIME);
+ gtk_tree_view_column_set_resizable(column, TRUE);
+ gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
+ gtk_tree_view_column_set_min_width(column, 60);
+ gtk_tree_view_column_set_fixed_width(column, 100);
+ /* Add the column to the view. */
+ gtk_tree_view_append_column(list_view, column);
+
+ /* Stop Time */
+ renderer = gtk_cell_renderer_text_new();
+ g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL); /* right align */
+ g_object_set(G_OBJECT(renderer), "xpad", 10, NULL);
+ column = gtk_tree_view_column_new_with_attributes("Stop Time", renderer,
+ "text", CALL_COL_STOP_TIME,
+ NULL);
+ gtk_tree_view_column_set_sort_column_id(column, CALL_COL_STOP_TIME);
+ gtk_tree_view_column_set_resizable(column, TRUE);
+ gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
+ gtk_tree_view_column_set_min_width(column, 60);
+ gtk_tree_view_column_set_fixed_width(column, 100);
+ gtk_tree_view_append_column(list_view, column);
+
+ /* Initial Speaker */
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes("Initial Speaker", renderer,
+ "text", CALL_COL_INITIAL_SPEAKER,
+ NULL);
+ gtk_tree_view_column_set_sort_column_id(column, CALL_COL_INITIAL_SPEAKER);
+ gtk_tree_view_column_set_resizable(column, TRUE);
+ gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
+ gtk_tree_view_column_set_min_width(column, 80);
+ gtk_tree_view_column_set_fixed_width(column, 120);
+ gtk_tree_view_append_column(list_view, column);
+
+ /* From */
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes("From", renderer,
+ "text", CALL_COL_FROM,
+ NULL);
+ gtk_tree_view_column_set_sort_column_id(column, CALL_COL_FROM);
+ gtk_tree_view_column_set_resizable(column, TRUE);
+ gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
+ gtk_tree_view_column_set_min_width(column, 130);
+ gtk_tree_view_column_set_fixed_width(column, 140);
+ gtk_tree_view_append_column(list_view, column);
+
+ /* To */
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes("To", renderer,
+ "text", CALL_COL_TO,
+ NULL);
+ gtk_tree_view_column_set_sort_column_id(column, CALL_COL_TO);
+ gtk_tree_view_column_set_resizable(column, TRUE);
+ gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
+ gtk_tree_view_column_set_min_width(column, 130);
+ gtk_tree_view_column_set_fixed_width(column, 140);
+ gtk_tree_view_append_column(list_view, column);
+
+ /* Protocol */
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes("Protocol", renderer,
+ "text", CALL_COL_PROTOCOL,
+ NULL);
+ gtk_tree_view_column_set_sort_column_id(column, CALL_COL_PROTOCOL);
+ gtk_tree_view_column_set_resizable(column, TRUE);
+ gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
+ gtk_tree_view_column_set_min_width(column, 50);
+ gtk_tree_view_column_set_fixed_width(column, 80);
+ gtk_tree_view_append_column(list_view, column);
+
+ /* Packets */
+ renderer = gtk_cell_renderer_text_new();
+ g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL); /* right align numbers */
+ g_object_set(G_OBJECT(renderer), "xpad", 10, NULL);
+ column = gtk_tree_view_column_new_with_attributes("Packets", renderer,
+ "text", CALL_COL_PACKETS,
+ NULL);
+ gtk_tree_view_column_set_sort_column_id(column, CALL_COL_PACKETS);
+ gtk_tree_view_column_set_resizable(column, TRUE);
+ gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
+ gtk_tree_view_column_set_min_width(column, 70);
+ gtk_tree_view_column_set_fixed_width(column, 80);
+ gtk_tree_view_append_column(list_view, column);
+
+ /* State */
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes("State", renderer,
+ "text", CALL_COL_STATE,
+ NULL);
+ gtk_tree_view_column_set_sort_column_id(column, CALL_COL_STATE);
+ gtk_tree_view_column_set_resizable(column, TRUE);
+ gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
+ gtk_tree_view_column_set_min_width(column, 60);
+ gtk_tree_view_column_set_fixed_width(column, 80);
+ gtk_tree_view_append_column(list_view, column);
+
+ /* Comments */
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes("Comments", renderer,
+ "text", CALL_COL_COMMENTS,
+ NULL);
+ gtk_tree_view_column_set_sort_column_id(column, CALL_COL_COMMENTS);
+ gtk_tree_view_column_set_resizable(column, TRUE);
+ gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
+ gtk_tree_view_column_set_min_width(column, 100);
+ gtk_tree_view_column_set_fixed_width(column, 140);
+ gtk_tree_view_append_column(list_view, column);
+
+ /* Now enable the sorting of each column */
+ gtk_tree_view_set_rules_hint(list_view, TRUE);
+ gtk_tree_view_set_headers_clickable(list_view, TRUE);
+
+ /* Setup the selection handler */
+ selection = gtk_tree_view_get_selection(list_view);
+ gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
+
+ g_signal_connect(G_OBJECT(selection), "changed", /* select_row */
+ G_CALLBACK(voip_calls_on_select_row_cb),
+ NULL);
+}
/****************************************************************************/
/* INTERFACE */
/****************************************************************************/
-
-static void voip_calls_dlg_create (void)
+static void
+voip_calls_dlg_create(void)
{
GtkWidget *voip_calls_dlg_w;
GtkWidget *main_vb;
GtkWidget *scrolledwindow;
GtkWidget *hbuttonbox;
GtkWidget *bt_close;
- GtkWidget *bt_help;
- GtkTooltips *tooltips = gtk_tooltips_new();
+ GtkWidget *bt_select_all;
+ const gchar *title_name_ptr;
+ gchar *win_name;
- gchar *titles[NUM_COLS] = {"Start Time", "Stop Time", "Initial Speaker", "From", "To", "Protocol", "Packets", "State", "Comments"};
- column_arrows *col_arrows;
- GtkWidget *column_lb;
- int i;
+ title_name_ptr = cf_get_display_name(&cfile);
+ win_name = g_strdup_printf("%s - VoIP Calls", title_name_ptr);
+ voip_calls_dlg_w = dlg_window_new(win_name); /* transient_for top_level */
+ gtk_window_set_destroy_with_parent(GTK_WINDOW(voip_calls_dlg_w), TRUE);
- voip_calls_dlg_w=window_new(GTK_WINDOW_TOPLEVEL, "Ethereal: VoIP Calls");
+ gtk_window_set_default_size(GTK_WINDOW(voip_calls_dlg_w), 1000, 350);
- gtk_window_set_default_size(GTK_WINDOW(voip_calls_dlg_w), 840, 350);
-
- main_vb = gtk_vbox_new (FALSE, 0);
+ main_vb = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(voip_calls_dlg_w), main_vb);
- gtk_container_set_border_width (GTK_CONTAINER (main_vb), 12);
-
- top_label = gtk_label_new ("Detected 0 VoIP Calls. Selected 0 Calls.");
- gtk_box_pack_start (GTK_BOX (main_vb), top_label, FALSE, FALSE, 8);
-
- scrolledwindow = scrolled_window_new (NULL, NULL);
- gtk_box_pack_start (GTK_BOX (main_vb), scrolledwindow, TRUE, TRUE, 0);
-
- clist = gtk_clist_new (NUM_COLS);
- gtk_container_add (GTK_CONTAINER (scrolledwindow), clist);
-
- gtk_clist_set_column_width (GTK_CLIST (clist), 0, 60);
- gtk_clist_set_column_width (GTK_CLIST (clist), 1, 60);
- gtk_clist_set_column_width (GTK_CLIST (clist), 2, 80);
- gtk_clist_set_column_width (GTK_CLIST (clist), 3, 130);
- gtk_clist_set_column_width (GTK_CLIST (clist), 4, 130);
- gtk_clist_set_column_width (GTK_CLIST (clist), 5, 50);
- gtk_clist_set_column_width (GTK_CLIST (clist), 6, 45);
- gtk_clist_set_column_width (GTK_CLIST (clist), 7, 60);
- gtk_clist_set_column_width (GTK_CLIST (clist), 8, 100);
-
- gtk_clist_set_column_justification(GTK_CLIST(clist), 0, GTK_JUSTIFY_LEFT);
- gtk_clist_set_column_justification(GTK_CLIST(clist), 1, GTK_JUSTIFY_LEFT);
- gtk_clist_set_column_justification(GTK_CLIST(clist), 2, GTK_JUSTIFY_LEFT);
- gtk_clist_set_column_justification(GTK_CLIST(clist), 3, GTK_JUSTIFY_LEFT);
- gtk_clist_set_column_justification(GTK_CLIST(clist), 4, GTK_JUSTIFY_LEFT);
- gtk_clist_set_column_justification(GTK_CLIST(clist), 5, GTK_JUSTIFY_CENTER);
- gtk_clist_set_column_justification(GTK_CLIST(clist), 6, GTK_JUSTIFY_CENTER);
- gtk_clist_set_column_justification(GTK_CLIST(clist), 7, GTK_JUSTIFY_LEFT);
- gtk_clist_set_column_justification(GTK_CLIST(clist), 8, GTK_JUSTIFY_LEFT);
-
- gtk_clist_column_titles_show (GTK_CLIST (clist));
-
- gtk_clist_set_compare_func(GTK_CLIST(clist), voip_calls_sort_column);
- gtk_clist_set_sort_column(GTK_CLIST(clist), 0);
- gtk_clist_set_sort_type(GTK_CLIST(clist), GTK_SORT_ASCENDING);
-
- gtk_widget_show(voip_calls_dlg_w);
+ gtk_container_set_border_width(GTK_CONTAINER (main_vb), 12);
- /* sort by column feature */
- col_arrows = (column_arrows *) g_malloc(sizeof(column_arrows) * NUM_COLS);
-
- for (i=0; i<NUM_COLS; i++) {
- col_arrows[i].table = gtk_table_new(2, 2, FALSE);
- gtk_table_set_col_spacings(GTK_TABLE(col_arrows[i].table), 5);
- column_lb = gtk_label_new(titles[i]);
- gtk_table_attach(GTK_TABLE(col_arrows[i].table), column_lb, 0, 1, 0, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
- gtk_widget_show(column_lb);
-
- col_arrows[i].ascend_pm = xpm_to_widget(clist_ascend_xpm);
- gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].ascend_pm, 1, 2, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
- col_arrows[i].descend_pm = xpm_to_widget(clist_descend_xpm);
- gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].descend_pm, 1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
- /* make start time be the default sort order */
- if (i == 0) {
- gtk_widget_show(col_arrows[i].ascend_pm);
- }
- gtk_clist_set_column_widget(GTK_CLIST(clist), i, col_arrows[i].table);
- gtk_widget_show(col_arrows[i].table);
- }
+ top_label = gtk_label_new("Detected 0 VoIP Calls. Selected 0 Calls.");
+ gtk_box_pack_start(GTK_BOX (main_vb), top_label, FALSE, FALSE, 8);
- SIGNAL_CONNECT(clist, "click-column", voip_calls_click_column_cb, col_arrows);
+ scrolledwindow = scrolled_window_new(NULL, NULL);
+ gtk_box_pack_start(GTK_BOX (main_vb), scrolledwindow, TRUE, TRUE, 0);
- label_fwd = gtk_label_new (FWD_LABEL_TEXT);
- gtk_box_pack_start (GTK_BOX (main_vb), label_fwd, FALSE, FALSE, 0);
+ create_list_view();
+ gtk_container_add(GTK_CONTAINER(scrolledwindow), list);
+ gtk_widget_show(voip_calls_dlg_w);
- status_label = gtk_label_new ("Total: Calls: 0 Start packets: 0 Completed calls: 0 Rejected calls: 0");
- gtk_box_pack_start (GTK_BOX (main_vb), status_label, FALSE, FALSE, 8);
+ status_label = gtk_label_new("Total: Calls: 0 Start packets: 0 Completed calls: 0 Rejected calls: 0");
+ gtk_box_pack_start(GTK_BOX(main_vb), status_label, FALSE, FALSE, 8);
- /* button row */
- hbuttonbox = gtk_hbutton_box_new ();
- gtk_box_pack_start (GTK_BOX (main_vb), hbuttonbox, FALSE, FALSE, 0);
- gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox), GTK_BUTTONBOX_SPREAD);
- gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbuttonbox), 30);
+ /* button row */
+ hbuttonbox = gtk_hbutton_box_new();
+ gtk_box_pack_start(GTK_BOX(main_vb), hbuttonbox, FALSE, FALSE, 0);
+ gtk_button_box_set_layout(GTK_BUTTON_BOX (hbuttonbox), GTK_BUTTONBOX_SPREAD);
+ gtk_box_set_spacing(GTK_BOX(hbuttonbox), 30);
- bt_help = BUTTON_NEW_FROM_STOCK(GTK_STOCK_HELP);
- gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_help);
- SIGNAL_CONNECT(bt_help, "clicked", help_bt_clicked, NULL);
- gtk_tooltips_set_tip (tooltips, bt_help, "Go to the help page", NULL);
-
/*bt_unselect = gtk_button_new_with_label ("Unselect");
gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_unselect);
- gtk_tooltips_set_tip (tooltips, bt_unselect, "Unselect this conversation", NULL);*/
+ gtk_widget_set_tooltip_text (bt_unselect, "Unselect this conversation");*/
- bt_filter = gtk_button_new_with_label ("Prepare Filter");
- gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_filter);
- gtk_tooltips_set_tip (tooltips, bt_filter, "Prepare a display filter of the selected conversation", NULL);
+ bt_filter = gtk_button_new_from_stock(WIRESHARK_STOCK_PREPARE_FILTER);
+ gtk_container_add(GTK_CONTAINER(hbuttonbox), bt_filter);
+ gtk_widget_set_tooltip_text(bt_filter, "Prepare a display filter of the selected conversation");
- bt_graph = gtk_button_new_with_label("Graph");
+ bt_graph = gtk_button_new_from_stock(WIRESHARK_STOCK_VOIP_FLOW);
gtk_container_add(GTK_CONTAINER(hbuttonbox), bt_graph);
- SIGNAL_CONNECT(bt_graph, "clicked", on_graph_bt_clicked, NULL);
- gtk_tooltips_set_tip (tooltips, bt_graph, "Show a flow graph of the selected calls.", NULL);
+ gtk_widget_show(bt_graph);
+ g_signal_connect(bt_graph, "clicked", G_CALLBACK(on_graph_bt_clicked), NULL);
+ gtk_widget_set_tooltip_text(bt_graph, "Show a flow graph of the selected calls.");
+
+#ifdef HAVE_LIBPORTAUDIO
+ bt_player = gtk_button_new_from_stock(WIRESHARK_STOCK_AUDIO_PLAYER);
+ gtk_container_add(GTK_CONTAINER(hbuttonbox), bt_player);
+ gtk_widget_show(bt_player);
+ g_signal_connect(bt_player, "clicked", G_CALLBACK(on_player_bt_clicked), NULL);
+ gtk_widget_set_tooltip_text(bt_player, "Launch the RTP player to listen the selected calls.");
+#endif /* HAVE_LIBPORTAUDIO */
+
+ bt_select_all = gtk_button_new_from_stock(GTK_STOCK_SELECT_ALL);
+ gtk_container_add(GTK_CONTAINER(hbuttonbox), bt_select_all);
+#if GTK_CHECK_VERSION(2,18,0)
+ gtk_widget_set_can_default(bt_select_all, TRUE);
+#else
+ GTK_WIDGET_SET_FLAGS(bt_select_all, GTK_CAN_DEFAULT);
+#endif
+ gtk_widget_set_tooltip_text(bt_select_all, "Select all the calls");
- bt_close = BUTTON_NEW_FROM_STOCK(GTK_STOCK_CLOSE);
- gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_close);
+ bt_close = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
+ gtk_container_add(GTK_CONTAINER (hbuttonbox), bt_close);
+#if GTK_CHECK_VERSION(2,18,0)
+ gtk_widget_set_can_default(bt_close, TRUE);
+#else
GTK_WIDGET_SET_FLAGS(bt_close, GTK_CAN_DEFAULT);
- gtk_tooltips_set_tip (tooltips, bt_close, "Close this dialog", NULL);
+#endif
+ gtk_widget_set_tooltip_text(bt_close, "Close this dialog");
- SIGNAL_CONNECT(clist, "select_row", voip_calls_on_select_row, NULL);
- /*SIGNAL_CONNECT(bt_unselect, "clicked", voip_calls_on_unselect, NULL);*/
- SIGNAL_CONNECT(bt_filter, "clicked", voip_calls_on_filter, NULL);
+ /*g_signal_connect(bt_unselect, "clicked", G_CALLBACK(voip_calls_on_unselect), NULL);*/
+ g_signal_connect(bt_filter, "clicked", G_CALLBACK(voip_calls_on_filter), NULL);
window_set_cancel_button(voip_calls_dlg_w, bt_close, window_cancel_button_cb);
- SIGNAL_CONNECT(voip_calls_dlg_w, "delete_event", window_delete_event_cb, NULL);
- SIGNAL_CONNECT(voip_calls_dlg_w, "destroy", voip_calls_on_destroy, NULL);
+ g_signal_connect(voip_calls_dlg_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
+ g_signal_connect(voip_calls_dlg_w, "destroy", G_CALLBACK(voip_calls_on_destroy), NULL);
+ g_signal_connect(bt_select_all, "clicked", G_CALLBACK(voip_calls_on_select_all), NULL);
gtk_widget_show_all(voip_calls_dlg_w);
window_present(voip_calls_dlg_w);
voip_calls_on_unselect(NULL, NULL);
voip_calls_dlg = voip_calls_dlg_w;
+
+ g_free(win_name);
}
/****************************************************************************/
-/* PUBLIC */
+/* PUBLIC */
/****************************************************************************/
/****************************************************************************/
-/* update the contents of the dialog box clist */
+/* update the contents of the list view */
/* list: pointer to list of voip_calls_info_t* */
-
-void voip_calls_dlg_update(GList *list)
+void
+voip_calls_dlg_update(GList *listx)
{
gchar label_text[256];
-guint foo;
if (voip_calls_dlg != NULL) {
- gtk_clist_clear(GTK_CLIST(clist));
calls_nb = 0;
calls_ns = 0;
- g_snprintf(label_text, 256,
- "Total: Calls: %d Start packets: %d Completed calls: %d Rejected calls: %d",
- g_list_length(voip_calls_get_info()->strinfo_list),
- voip_calls_get_info()->start_packets,
+ gtk_list_store_clear(list_store);
+
+ g_snprintf(label_text, sizeof(label_text),
+ "Total: Calls: %u Start packets: %u Completed calls: %u Rejected calls: %u",
+ g_list_length(voip_calls_get_info()->callsinfo_list),
+ voip_calls_get_info()->start_packets,
voip_calls_get_info()->completed_calls,
voip_calls_get_info()->rejected_calls);
- gtk_label_set(GTK_LABEL(status_label), label_text);
-
- foo= g_list_length(list);
- list = g_list_first(list);
- while (list)
- {
- add_to_clist((voip_calls_info_t*)(list->data));
- list = g_list_next(list);
+ gtk_label_set_text(GTK_LABEL(status_label), label_text);
+
+ listx = g_list_first(listx);
+ while (listx) {
+ add_to_list_store((voip_calls_info_t*)(listx->data));
+ listx = g_list_next(listx);
}
- g_snprintf(label_text, 256,
- "Detected %d VoIP %s. Selected %d %s.",
- calls_nb,
+ g_snprintf(label_text, sizeof(label_text),
+ "Detected %u VoIP %s. Selected %u %s.",
+ calls_nb,
plurality(calls_nb, "Call", "Calls"),
calls_ns,
plurality(calls_ns, "Call", "Calls"));
- gtk_label_set(GTK_LABEL(top_label), label_text);
-
- voip_calls_on_unselect(NULL, NULL);
+ gtk_label_set_text(GTK_LABEL(top_label), label_text);
}
-
- last_list = list;
}
-
/****************************************************************************/
/* draw function for tap listeners to keep the window up to date */
-void voip_calls_dlg_draw(void *ptr _U_)
+void
+voip_calls_dlg_draw(void *ptr _U_)
{
- voip_calls_dlg_update(voip_calls_get_info()->strinfo_list);
+ if (voip_calls_get_info()->redraw) {
+ voip_calls_dlg_update(voip_calls_get_info()->callsinfo_list);
+ voip_calls_get_info()->redraw = FALSE;
+ }
}
+/****************************************************************************/
/* reset function for tap listeners to clear window, if necessary */
-void voip_calls_dlg_reset(void *ptr _U_)
+void
+voip_calls_dlg_reset(void *ptr _U_)
{
/* Clean up memory used by calls tap */
- voip_calls_reset((voip_calls_tapinfo_t*) voip_calls_get_info());
+ voip_calls_reset(voip_calls_get_info());
+
+ /* close the graph window if open */
+ if (graph_analysis_data && graph_analysis_data->dlg.window != NULL) {
+ window_cancel_button_cb(NULL, graph_analysis_data->dlg.window);
+ graph_analysis_data->dlg.window = NULL;
+ }
}
+/****************************************************************************/
/* init function for tap */
static void
-voip_calls_init_tap(char *dummy _U_)
+voip_calls_init_tap(const char *dummy _U_, void* userdata _U_)
{
- graph_analysis_data_init();
+ if (graph_analysis_data == NULL) {
+ graph_analysis_data_init();
+ /* init the Graph Analysys */
+ graph_analysis_data = graph_analysis_init();
+ graph_analysis_data->graph_info = voip_calls_get_info()->graph_analysis;
+ }
/* Clean up memory used by calls tap */
- voip_calls_reset((voip_calls_tapinfo_t*) voip_calls_get_info());
+ voip_calls_reset(voip_calls_get_info());
/* Register the tap listener */
sip_calls_init_tap();
h225_calls_init_tap();
h245dg_calls_init_tap();
q931_calls_init_tap();
+ h248_calls_init_tap();
+ sccp_calls_init_tap();
sdp_calls_init_tap();
+ /* We don't register this tap, if we don't have the unistim plugin loaded.*/
+ if (find_tap_id("unistim")) {
+ unistim_calls_init_tap();
+ }
+ if (find_tap_id("voip")) {
+ VoIPcalls_init_tap();
+ }
rtp_init_tap();
rtp_event_init_tap();
- /* We don't register this tap, if we don't have the mgcp plugin loaded.*/
- if (find_tap_id("mgcp")) {
- mgcp_calls_init_tap();
- }
-
- /* init the Graph Analysys */
- graph_analysis_data = graph_analysis_init();
- graph_analysis_data->graph_info = voip_calls_get_info()->graph_analysis;
+ mgcp_calls_init_tap();
+ actrace_calls_init_tap();
+ skinny_calls_init_tap();
+ iax2_calls_init_tap();
+ t38_init_tap();
/* create dialog box if necessary */
if (voip_calls_dlg == NULL) {
/* There's already a dialog box; reactivate it. */
reactivate_window(voip_calls_dlg);
}
-
+
+ voip_calls_get_info()->redraw = TRUE;
+ voip_calls_dlg_draw(NULL);
+ voip_calls_get_info()->redraw = TRUE;
+
/* Scan for VoIP calls calls (redissect all packets) */
cf_retap_packets(&cfile);
-
+ gdk_window_raise(gtk_widget_get_window(voip_calls_dlg));
/* Tap listener will be removed and cleaned up in voip_calls_on_destroy */
}
/****************************************************************************/
/* entry point when called via the GTK menu */
-void voip_calls_launch(GtkWidget *w _U_, gpointer data _U_)
+#ifdef MAIN_MENU_USE_UIMANAGER
+void
+voip_calls_launch(GtkAction *action _U_, gpointer user_data _U_)
+{
+ voip_calls_init_tap("", NULL);
+}
+#else
+static void
+voip_calls_launch(GtkWidget *w _U_, gpointer data _U_)
{
- voip_calls_init_tap("");
+ voip_calls_init_tap("", NULL);
}
+#endif
/****************************************************************************/
void
register_tap_listener_voip_calls_dlg(void)
{
- register_tap_listener_cmd_arg("voip,calls",voip_calls_init_tap);
- register_tap_menu_item("VoIP Calls...", REGISTER_TAP_GROUP_TELEPHONY,
- voip_calls_launch, NULL, NULL, NULL);
-
+ register_stat_cmd_arg("voip,calls", voip_calls_init_tap, NULL);
+#ifdef MAIN_MENU_USE_UIMANAGER
+#else
+ register_stat_menu_item_stock("_VoIP Calls",
+ REGISTER_STAT_GROUP_TELEPHONY, WIRESHARK_STOCK_TELEPHONE,
+ voip_calls_launch, NULL, NULL, NULL);
+#endif
}