Have tap listeners specify whether the "packet" routine requires
[obnox/wireshark/wip.git] / gtk / voip_calls_dlg.c
index a04690377ed1b467d7209645d9606b49d6a94f82..75ed4c5fdcf199ba834d36005d27bfd49e058a29 100644 (file)
 #ifdef HAVE_CONFIG_H
 #  include <config.h>
 #endif
-
 #include <string.h>
 #include <ctype.h>
 
-#include "register.h"
-
-#include "graph_analysis.h"
-#include "voip_calls_dlg.h"
-#include "voip_calls.h"
+#include "gtk/gtk.h"
 
-#include "globals.h"
+#include <epan/epan.h>
+#include <epan/packet.h>
 #include "epan/filesystem.h"
-
 #include <epan/tap.h>
 #include <epan/stat_cmd_args.h>
+#include <epan/to_str.h>
+#include <epan/address.h>
+#include <epan/addr_resolv.h>
+#include <epan/dissectors/packet-h248.h>
+
+#include "../register.h"
+#include "../globals.h"
 #include "../stat_menu.h"
-#include "gui_stat_menu.h"
-#include "dlg_utils.h"
-#include "gui_utils.h"
-#include "gtkglobals.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 "image/clist_ascend.xpm"
 #include "image/clist_descend.xpm"
 #include "simple_dialog.h"
 
-#include <epan/to_str.h>
-
-#include <epan/address.h>
-#include <epan/addr_resolv.h>
-#include <epan/dissectors/packet-h248.h>
-
 #ifdef HAVE_LIBPORTAUDIO
-#include "rtp_analysis.h"
-#include "rtp_player.h"
+#include "gtk/rtp_analysis.h"
+#include "gtk/rtp_player.h"
 #endif /* HAVE_LIBPORTAUDIO */
 
 
@@ -108,6 +108,7 @@ static graph_analysis_data_t *graph_analysis_data = NULL;
 #define CALL_COL_COMMENTS              8
 static const GdkColor COLOR_SELECT = {0, 0x00ff, 0x80ff, 0x80ff};
 static const GdkColor COLOR_DEFAULT = {0, 0xffff, 0xffff, 0xffff};
+static const GdkColor COLOR_FOREGROUND = {0, 0x0000, 0x0000, 0x0000};
 
 /****************************************************************************/
 /* append a line to clist */
@@ -121,7 +122,8 @@ static void add_to_clist(voip_calls_info_t* strinfo)
        isup_calls_info_t *tmp_isupinfo;
        h323_calls_info_t *tmp_h323info;
        gboolean tmp_bool = FALSE;
-       GdkColor color = COLOR_SELECT;
+       GdkColor bg_color = COLOR_SELECT;
+       GdkColor fg_color = COLOR_FOREGROUND;
        for (c=0;c<NUM_COLS;c++){
                data[c]=&field[c][0];
        }
@@ -170,7 +172,8 @@ static void add_to_clist(voip_calls_info_t* strinfo)
        /* set the background color if selected */
        if (strinfo->selected) { 
                calls_ns++;
-               gtk_clist_set_background(GTK_CLIST(clist), added_row, &color);
+               gtk_clist_set_background(GTK_CLIST(clist), added_row, &bg_color);
+               gtk_clist_set_foreground(GTK_CLIST(clist), added_row, &fg_color);
        }
 
        /* set data pointer of last row to point to user data for that row */
@@ -184,7 +187,7 @@ static void add_to_clist(voip_calls_info_t* strinfo)
                plurality(calls_nb, "Call", "Calls"),
                calls_ns,
                plurality(calls_ns, "Call", "Calls"));
-       gtk_label_set(GTK_LABEL(top_label), label_text);
+        gtk_label_set_text(GTK_LABEL(top_label), label_text);
 
        /* Update the status label with the number of total messages */
         g_snprintf(label_text, 256,
@@ -193,7 +196,7 @@ static void add_to_clist(voip_calls_info_t* strinfo)
                        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);
+         gtk_label_set_text(GTK_LABEL(status_label), label_text);
 }
 
 
@@ -217,11 +220,11 @@ static void voip_calls_remove_tap_listener(void)
                remove_tap_listener_voip_calls();
        }
        remove_tap_listener_rtp_event();
-       if (find_tap_id("mgcp")) {
-               remove_tap_listener_mgcp_calls();
-       }
+       remove_tap_listener_mgcp_calls();
        remove_tap_listener_actrace_calls();
        remove_tap_listener_t38();
+       remove_tap_listener_skinny_calls();
+       remove_tap_listener_iax2_calls();
 }
 
 /****************************************************************************/
@@ -273,8 +276,8 @@ voip_calls_on_filter                    (GtkButton       *button _U_,
        const gchar *filter_prepend;
        gboolean isFirst = TRUE;
        GList* list;
-       guint filter_length = 0;
-       guint max_filter_length = 2048;
+       size_t filter_length = 0;
+       size_t max_filter_length = 2048;
        sip_calls_info_t *tmp_sipinfo;
        isup_calls_info_t *tmp_isupinfo;
        h323_calls_info_t *tmp_h323info;
@@ -300,18 +303,18 @@ voip_calls_on_filter                    (GtkButton       *button _U_,
        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, " (");
+       g_string_append_printf(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 );
+                       g_string_append_printf(filter_string_fwd,"%sframe.number == %d", isFirst?"":" or ", gai->frame_num );
                        isFirst = FALSE;
                }               
                list = g_list_next (list);
        }
-       g_string_sprintfa(filter_string_fwd, ") ");
+       g_string_append_printf(filter_string_fwd, ") ");
        filter_length = filter_length + filter_string_fwd->len;
 
        if (filter_length < max_filter_length){
@@ -323,7 +326,7 @@ voip_calls_on_filter                    (GtkButton       *button _U_,
                switch(selected_call_fwd->protocol){
                        case VOIP_SIP:
                                tmp_sipinfo = selected_call_fwd->prot_info;
-                               g_string_sprintfa(filter_string_fwd,
+                               g_string_append_printf(filter_string_fwd,
                                   "(sip.Call-ID == \"%s\") ",
                                   tmp_sipinfo->call_identifier 
                                   );
@@ -331,7 +334,7 @@ voip_calls_on_filter                    (GtkButton       *button _U_,
                                break;
                        case VOIP_ISUP:
                                tmp_isupinfo = selected_call_fwd->prot_info;
-                               g_string_sprintfa(filter_string_fwd,
+                               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))) ",
                                   tmp_isupinfo->cic,selected_call_fwd->first_frame_num,
                                   selected_call_fwd->last_frame_num, 
@@ -342,7 +345,7 @@ voip_calls_on_filter                    (GtkButton       *button _U_,
                                break;
                        case VOIP_H323:
                                tmp_h323info = selected_call_fwd->prot_info;
-                               g_string_sprintfa(filter_string_fwd,
+                               g_string_append_printf(filter_string_fwd,
                                   "((h225.guid == %s || q931.call_ref == %x:%x || q931.call_ref == %x:%x) ",
                                   guid_to_str(&tmp_h323info->guid[0]),
                                   (guint8)(tmp_h323info->q931_crv & 0xff),
@@ -353,12 +356,12 @@ voip_calls_on_filter                    (GtkButton       *button _U_,
                                while (list)
                                {
                                        h245_add=list->data;
-                                       g_string_sprintfa(filter_string_fwd,
+                                       g_string_append_printf(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_sprintfa(filter_string_fwd, ") ");
+                               g_string_append_printf(filter_string_fwd, ") ");
                                gtk_entry_append_text(GTK_ENTRY(main_display_filter_widget), filter_string_fwd->str);
                                break;
                        case TEL_H248: {
@@ -374,6 +377,8 @@ voip_calls_on_filter                    (GtkButton       *button _U_,
                        case TEL_BSSMAP:
                        case TEL_RANAP:
                        case VOIP_UNISTIM:
+                       case VOIP_SKINNY:
+                       case VOIP_IAX2:
                        case VOIP_COMMON:
                                /* XXX - not supported */
                                break;
@@ -484,7 +489,7 @@ voip_calls_on_select_row(GtkCList *clist,
             plurality(calls_nb, "Call", "Calls"),
                        calls_ns,
                        plurality(calls_ns, "Call", "Calls"));
-       gtk_label_set(GTK_LABEL(top_label), label_text);
+        gtk_label_set_text(GTK_LABEL(top_label), label_text);
 
 
        if      (calls_ns > 0) {
@@ -542,7 +547,7 @@ voip_calls_on_unselect_row(GtkCList *clist,
             plurality(calls_nb, "Call", "Calls"),
                        calls_ns,
                        plurality(calls_ns, "Call", "Calls"));
-       gtk_label_set(GTK_LABEL(top_label), label_text);
+        gtk_label_set_text(GTK_LABEL(top_label), label_text);
 
        if      (calls_ns > 0) {
                gtk_widget_set_sensitive(bt_filter, TRUE);
@@ -757,7 +762,7 @@ static void voip_calls_dlg_create (void)
        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);
+       gtk_box_set_spacing (GTK_BOX (hbuttonbox), 30);
 
        /*bt_unselect = gtk_button_new_with_label ("Unselect");
        gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_unselect);
@@ -834,7 +839,7 @@ void voip_calls_dlg_update(GList *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);
+                gtk_label_set_text(GTK_LABEL(status_label), label_text);
 
                gtk_clist_freeze(GTK_CLIST(clist));
                gtk_clist_clear(GTK_CLIST(clist));
@@ -852,7 +857,7 @@ void voip_calls_dlg_update(GList *list)
                        plurality(calls_nb, "Call", "Calls"),
                        calls_ns,
                        plurality(calls_ns, "Call", "Calls"));
-               gtk_label_set(GTK_LABEL(top_label), label_text);
+                gtk_label_set_text(GTK_LABEL(top_label), label_text);
        }
 
        last_list = list;
@@ -920,12 +925,11 @@ voip_calls_init_tap(const char *dummy _U_, void* userdata _U_)
        }
        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();
-       }
+       mgcp_calls_init_tap();
        actrace_calls_init_tap();
        t38_init_tap();
+       skinny_calls_init_tap();
+       iax2_calls_init_tap();
 
        /* create dialog box if necessary */
        if (voip_calls_dlg == NULL) {
@@ -946,8 +950,8 @@ voip_calls_init_tap(const char *dummy _U_, void* userdata _U_)
        gtk_clist_append(GTK_CLIST(clist), data);
        
        /* Scan for VoIP calls calls (redissect all packets) */
-       cf_retap_packets(&cfile, FALSE);
-
+       cf_retap_packets(&cfile);
+       gdk_window_raise(voip_calls_dlg->window);
        /* Tap listener will be removed and cleaned up in voip_calls_on_destroy */
 }