diff options
Diffstat (limited to 'gtk')
155 files changed, 4247 insertions, 4247 deletions
diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 8f2b6e2cc5..928f53b43a 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -1,7 +1,7 @@ # Makefile.am # Automake file for the GTK interface routines for Ethereal # -# $Id: Makefile.am,v 1.107 2004/07/09 23:02:37 guy Exp $ +# $Id$ # # Ethereal - Network traffic analyzer # By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/Makefile.common b/gtk/Makefile.common index 6b92a0b343..58d776b670 100644 --- a/gtk/Makefile.common +++ b/gtk/Makefile.common @@ -3,7 +3,7 @@ # a) common to both files and # b) portable between both files # -# $Id: Makefile.common,v 1.16 2004/06/21 17:25:19 ulfl Exp $ +# $Id$ # # Ethereal - Network traffic analyzer # By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/Makefile.nmake b/gtk/Makefile.nmake index 7856f18de0..eca004a5b7 100644 --- a/gtk/Makefile.nmake +++ b/gtk/Makefile.nmake @@ -1,7 +1,7 @@ ## Makefile for building ethereal.exe with Microsoft C and nmake ## Use: $(MAKE) /$(MAKEFLAGS) -f makefile.nmake # -# $Id: Makefile.nmake,v 1.79 2004/07/07 16:23:13 ulfl Exp $ +# $Id$ include ..\config.nmake diff --git a/gtk/about_dlg.c b/gtk/about_dlg.c index 4c99412519..a98b37279a 100644 --- a/gtk/about_dlg.c +++ b/gtk/about_dlg.c @@ -1,6 +1,6 @@ /* about_dlg.c * - * $Id: about_dlg.c,v 1.23 2004/07/07 07:01:37 guy Exp $ + * $Id$ * * Ulf Lamping <ulf.lamping@web.de> * diff --git a/gtk/about_dlg.h b/gtk/about_dlg.h index 9955c21f18..28a4bfbe1f 100644 --- a/gtk/about_dlg.h +++ b/gtk/about_dlg.h @@ -1,7 +1,7 @@ /* about_dlg.h * Declarations of routines for the "About" dialog * - * $Id: about_dlg.h,v 1.6 2004/07/04 12:15:41 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/ansi_a_stat.c b/gtk/ansi_a_stat.c index 8ba09badd3..68d9e90e16 100644 --- a/gtk/ansi_a_stat.c +++ b/gtk/ansi_a_stat.c @@ -5,7 +5,7 @@ * * MUCH code modified from service_response_time_table.c. * - * $Id: ansi_a_stat.c,v 1.18 2004/05/23 23:24:05 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/ansi_map_stat.c b/gtk/ansi_map_stat.c index e51993044d..6b334ccdfc 100644 --- a/gtk/ansi_map_stat.c +++ b/gtk/ansi_map_stat.c @@ -5,7 +5,7 @@ * * MUCH code modified from service_response_time_table.c. * - * $Id: ansi_map_stat.c,v 1.23 2004/05/26 11:37:36 jmayer Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/bootp_stat.c b/gtk/bootp_stat.c index cf313cc562..6af60e1b8f 100644 --- a/gtk/bootp_stat.c +++ b/gtk/bootp_stat.c @@ -1,7 +1,7 @@ /* bootp_stat.c * boop_stat 2003 Jean-Michel FAYARD * - * $Id: bootp_stat.c,v 1.27 2004/05/23 23:24:05 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/capture_combo_utils.c b/gtk/capture_combo_utils.c index 881130baeb..a49cb9bba3 100644 --- a/gtk/capture_combo_utils.c +++ b/gtk/capture_combo_utils.c @@ -1,7 +1,7 @@ /* capture_combo_utils.c * Utilities for combo box of interface names * - * $Id: capture_combo_utils.c,v 1.4 2003/12/21 12:17:58 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/capture_combo_utils.h b/gtk/capture_combo_utils.h index 337db59861..d87ceead1f 100644 --- a/gtk/capture_combo_utils.h +++ b/gtk/capture_combo_utils.h @@ -1,7 +1,7 @@ /* capture_combo_utils.c * Declarations of tilities for combo box of interface names * - * $Id: capture_combo_utils.h,v 1.2 2004/06/01 20:28:04 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/capture_dlg.c b/gtk/capture_dlg.c index 9c42786c99..4b9f3a335e 100644 --- a/gtk/capture_dlg.c +++ b/gtk/capture_dlg.c @@ -1,1715 +1,1715 @@ -/* capture_dlg.c
- * Routines for packet capture windows
- *
- * $Id: capture_dlg.c,v 1.138 2004/07/13 07:15:43 guy Exp $
- *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
- * Copyright 1998 Gerald Combs
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#ifdef HAVE_LIBPCAP
-
-#include <pcap.h>
-#include <string.h>
-#include <gtk/gtk.h>
-
-#include <epan/packet.h>
-#include "capture.h"
-#include "globals.h"
-#include <epan/resolv.h>
-#include "main.h"
-#include "ui_util.h"
-#include "capture_dlg.h"
-#include "filter_prefs.h"
-#include "simple_dialog.h"
-#include "dlg_utils.h"
-#include "pcap-util.h"
-#include "capture_combo_utils.h"
-#include "prefs.h"
-#include "ringbuffer.h"
-#include <epan/filesystem.h>
-#include "compat_macros.h"
-#include "file_dlg.h"
-#include "help_dlg.h"
-#include "gtkglobals.h"
-
-#ifdef _WIN32
-#include "capture-wpcap.h"
-#endif
-
-/* Capture callback data keys */
-#define E_CAP_IFACE_KEY "cap_iface"
-#define E_CAP_IFACE_IP_KEY "cap_iface_ip"
-#define E_CAP_SNAP_CB_KEY "cap_snap_cb"
-#define E_CAP_LT_OM_KEY "cap_lt_om"
-#define E_CAP_LT_OM_LABEL_KEY "cap_lt_om_label"
-#ifdef _WIN32
-#define E_CAP_BUFFER_SIZE_SB_KEY "cap_buffer_size_sb"
-#endif
-#define E_CAP_SNAP_SB_KEY "cap_snap_sb"
-#define E_CAP_PROMISC_KEY "cap_promisc"
-#define E_CAP_FILT_KEY "cap_filter_te"
-#define E_CAP_FILE_TE_KEY "cap_file_te"
-#define E_CAP_MULTI_FILES_ON_CB_KEY "cap_multi_files_on_cb"
-#define E_CAP_RING_FILESIZE_CB_KEY "cap_ring_filesize_cb"
-#define E_CAP_RING_FILESIZE_SB_KEY "cap_ring_filesize_sb"
-#define E_CAP_RING_FILESIZE_OM_KEY "cap_ring_filesize_om"
-#define E_CAP_FILE_DURATION_CB_KEY "cap_file_duration_cb"
-#define E_CAP_FILE_DURATION_SB_KEY "cap_file_duration_sb"
-#define E_CAP_FILE_DURATION_OM_KEY "cap_file_duration_om"
-#define E_CAP_RING_NBF_CB_KEY "cap_ring_nbf_cb"
-#define E_CAP_RING_NBF_SB_KEY "cap_ring_nbf_sb"
-#define E_CAP_RING_NBF_LB_KEY "cap_ring_nbf_lb"
-#define E_CAP_STOP_FILES_CB_KEY "cap_stop_files_cb"
-#define E_CAP_STOP_FILES_SB_KEY "cap_stop_files_sb"
-#define E_CAP_STOP_FILES_LB_KEY "cap_stop_files_lb"
-#define E_CAP_SYNC_KEY "cap_sync"
-#define E_CAP_AUTO_SCROLL_KEY "cap_auto_scroll"
-#define E_CAP_HIDE_INFO_KEY "cap_hide_info"
-#define E_CAP_STOP_PACKETS_CB_KEY "cap_stop_packets_cb"
-#define E_CAP_STOP_PACKETS_SB_KEY "cap_stop_packets_sb"
-#define E_CAP_STOP_PACKETS_LB_KEY "cap_stop_packets_lb"
-#define E_CAP_STOP_FILESIZE_CB_KEY "cap_stop_filesize_cb"
-#define E_CAP_STOP_FILESIZE_SB_KEY "cap_stop_filesize_sb"
-#define E_CAP_STOP_FILESIZE_OM_KEY "cap_stop_filesize_om"
-#define E_CAP_STOP_DURATION_CB_KEY "cap_stop_duration_cb"
-#define E_CAP_STOP_DURATION_SB_KEY "cap_stop_duration_sb"
-#define E_CAP_STOP_DURATION_OM_KEY "cap_stop_duration_om"
-#define E_CAP_M_RESOLVE_KEY "cap_m_resolve"
-#define E_CAP_N_RESOLVE_KEY "cap_n_resolve"
-#define E_CAP_T_RESOLVE_KEY "cap_t_resolve"
-
-#define E_CAP_OM_LT_VALUE_KEY "cap_om_lt_value"
-
-static void
-capture_prep_file_cb(GtkWidget *file_bt, GtkWidget *file_te);
-
-static void
-select_link_type_cb(GtkWidget *w, gpointer data);
-
-static void
-capture_prep_adjust_sensitivity(GtkWidget *tb, gpointer parent_w);
-
-static void
-capture_prep_ok_cb(GtkWidget *ok_bt, gpointer parent_w);
-
-static void
-capture_prep_destroy_cb(GtkWidget *win, gpointer user_data);
-
-static void
-capture_prep_interface_changed_cb(GtkWidget *entry, gpointer parent_w);
-
-void
-capture_stop_cb(GtkWidget *w _U_, gpointer d _U_)
-{
- capture_stop();
-}
-
-/*
- * Given text that contains an interface name possibly prefixed by an
- * interface description, extract the interface name.
- */
-static char *
-get_if_name(char *if_text)
-{
- char *if_name;
-
-#ifdef WIN32
- /*
- * We cannot assume that the interface name doesn't contain a space;
- * some names on Windows OT do.
- *
- * We also can't assume it begins with "\Device\", either, as, on
- * Windows OT, WinPcap doesn't put "\Device\" in front of the name.
- *
- * As I remember, we can't assume that the interface description
- * doesn't contain a colon, either; I think some do.
- *
- * We can probably assume that the interface *name* doesn't contain
- * a colon, however; if any interface name does contain a colon on
- * Windows, it'll be time to just get rid of the damn interface
- * descriptions in the drop-down list, have just the names in the
- * drop-down list, and have a "Browse..." button to browse for interfaces,
- * with names, descriptions, IP addresses, blah blah blah available when
- * possible.
- *
- * So we search backwards for a colon. If we don't find it, just
- * return the entire string; otherwise, skip the colon and any blanks
- * after it, and return that string.
- */
- if_name = if_text + strlen(if_text);
- for (;;) {
- if (if_name == if_text) {
- /* We're at the beginning of the string; return it. */
- break;
- }
- if_name--;
- if (*if_name == ':') {
- /*
- * We've found a colon.
- * Unfortunately, a colon is used in the string "rpcap://",
- * which is used in case of a remote capture.
- * So we'll check to make sure the colon isn't followed by "//";
- * it'll be followed by a blank if it separates the description
- * and the interface name. (We don't wire in "rpcap", in case we
- * support other protocols in the same syntax.)
- */
- if (strncmp(if_name, "://", 3) != 0) {
- /*
- * OK, we've found a colon not followed by "//". Skip blanks
- * following it.
- */
- if_name++;
- while (*if_name == ' ')
- if_name++;
- break;
- }
- }
- /* Keep looking for a colon not followed by "//". */
- }
-#else
- /*
- * There's a space between the interface description and name, and
- * the interface name shouldn't have a space in it (it doesn't, on
- * UNIX systems); look backwards in the string for a space.
- *
- * (An interface name might, however, contain a colon in it, which
- * is why we don't use the colon search on UNIX.)
- */
- if_name = strrchr(if_text, ' ');
- if (if_name == NULL) {
- if_name = if_text;
- } else {
- if_name++;
- }
-#endif
- return if_name;
-}
-
-/*
- * Keep a static pointer to the current "Capture Options" window, if
- * any, so that if somebody tries to do "Capture:Start" while there's
- * already a "Capture Options" window up, we just pop up the existing
- * one, rather than creating a new one.
- */
-static GtkWidget *cap_open_w;
-
-
-/* From tcptraceroute, convert a numeric IP address to a string */
-/* XXX - this functionality is already somewhere in our code */
-#define IPTOSBUFFERS 12
-char *iptos(u_long in)
-{
- static char output[IPTOSBUFFERS][3*4+3+1];
- static short which;
- u_char *p;
-
- p = (u_char *)∈
- which = (which + 1 == IPTOSBUFFERS ? 0 : which + 1);
- sprintf(output[which], "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
- return output[which];
-}
-
-
-static void
-set_link_type_list(GtkWidget *linktype_om, GtkWidget *entry)
-{
- gchar *entry_text;
- gchar *if_text;
- gchar *if_name;
- GList *if_list;
- GList *if_entry;
- if_info_t *if_info;
- GList *lt_list;
- int err;
- char err_buf[PCAP_ERRBUF_SIZE];
- GtkWidget *lt_menu, *lt_menu_item;
- GList *lt_entry;
- data_link_info_t *data_link_info;
- gchar *linktype_menu_label;
- guint num_supported_link_types;
- GtkWidget *linktype_lb = OBJECT_GET_DATA(linktype_om, E_CAP_LT_OM_LABEL_KEY);
- GtkWidget *if_ip_lb;
- GString *ip_str = g_string_new("IP address: ");
- int ips = 0;
- GSList *curr_ip;
-
- lt_menu = gtk_menu_new();
- entry_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
- if_text = g_strstrip(entry_text);
- if_name = get_if_name(if_text);
-
- /*
- * If the interface name is in the list of known interfaces, get
- * its list of link-layer types and set the option menu to display it.
- *
- * If it's not, don't bother - the user might be in the middle of
- * editing the list, or it might be a remote device in which case
- * getting the list could take an arbitrarily-long period of time.
- * The list currently won't contain any remote devices (as
- * "pcap_findalldevs()" doesn't know about remote devices, and neither
- * does the code we use if "pcap_findalldevs()" isn't available), but
- * should contain all the local devices on which you can capture.
- */
- lt_list = NULL;
- if (*if_name != '\0') {
- /*
- * Try to get the list of known interfaces.
- */
- if_list = get_interface_list(&err, err_buf);
- if (if_list != NULL) {
- /*
- * We have the list - check it.
- */
- for (if_entry = if_list; if_entry != NULL;
- if_entry = g_list_next(if_entry)) {
- if_info = if_entry->data;
- if (strcmp(if_info->name, if_name) == 0) {
- /*
- * It's in the list.
- * Get the list of link-layer types for it.
- */
- lt_list = get_pcap_linktype_list(if_name, err_buf);
-
- /* create string of list of IP addresses of this interface */
- for( ; curr_ip = g_slist_nth(if_info->ip_addr, ips); ips++) {
- if (ips != 0) {
- g_string_append(ip_str, ", ");
- }
-
- g_string_append(ip_str, iptos(*((guint32 *)curr_ip->data)));
- }
-
- if(if_info->loopback) {
- g_string_append(ip_str, " (loopback)");
- }
- }
- }
- free_interface_list(if_list);
- }
- }
- g_free(entry_text);
- num_supported_link_types = 0;
- for (lt_entry = lt_list; lt_entry != NULL; lt_entry = g_list_next(lt_entry)) {
- data_link_info = lt_entry->data;
- if (data_link_info->description != NULL) {
- lt_menu_item = gtk_menu_item_new_with_label(data_link_info->description);
- OBJECT_SET_DATA(lt_menu_item, E_CAP_LT_OM_KEY, linktype_om);
- SIGNAL_CONNECT(lt_menu_item, "activate", select_link_type_cb,
- GINT_TO_POINTER(data_link_info->dlt));
- num_supported_link_types++;
- } else {
- /* Not supported - tell them about it but don't let them select it. */
- linktype_menu_label = g_strdup_printf("%s (not supported)",
- data_link_info->name);
- lt_menu_item = gtk_menu_item_new_with_label(linktype_menu_label);
- g_free(linktype_menu_label);
- gtk_widget_set_sensitive(lt_menu_item, FALSE);
- }
- gtk_menu_append(GTK_MENU(lt_menu), lt_menu_item);
- }
- if (lt_list != NULL)
- free_pcap_linktype_list(lt_list);
- gtk_option_menu_set_menu(GTK_OPTION_MENU(linktype_om), lt_menu);
- gtk_widget_set_sensitive(linktype_lb, num_supported_link_types >= 2);
- gtk_widget_set_sensitive(linktype_om, num_supported_link_types >= 2);
-
- if_ip_lb = OBJECT_GET_DATA(linktype_om, E_CAP_IFACE_KEY);
- if(ips == 0) {
- g_string_append(ip_str, "unknown");
- }
- gtk_label_set_text(GTK_LABEL(if_ip_lb), ip_str->str);
- g_string_free(ip_str, TRUE);
-}
-
-
-#define TIME_UNIT_SECOND 0
-#define TIME_UNIT_MINUTE 1
-#define TIME_UNIT_HOUR 2
-#define TIME_UNIT_DAY 3
-#define MAX_TIME_UNITS 4
-static char *time_unit_name[MAX_TIME_UNITS] = {
- "second(s)",
- "minute(s)",
- "hour(s)",
- "day(s)",
-};
-
-static GtkWidget *time_unit_option_menu_new(guint32 value) {
- GtkWidget *unit_om, *menu, *menu_item;
- int i;
-
- unit_om=gtk_option_menu_new();
- menu=gtk_menu_new();
- for(i=0;i<MAX_TIME_UNITS;i++){
- menu_item=gtk_menu_item_new_with_label(time_unit_name[i]);
- OBJECT_SET_DATA(menu_item, "time_unit", GINT_TO_POINTER(i));
- gtk_menu_append(GTK_MENU(menu), menu_item);
- }
-
- /* the selected menu item can't be changed, once the option_menu
- is created, so set the matching menu item now */
- /* days */
- if(value >= 60 * 60 * 24) {
- gtk_menu_set_active(GTK_MENU(menu), TIME_UNIT_DAY);
- } else {
- /* hours */
- if(value >= 60 * 60) {
- gtk_menu_set_active(GTK_MENU(menu), TIME_UNIT_HOUR);
- } else {
- /* minutes */
- if(value >= 60) {
- gtk_menu_set_active(GTK_MENU(menu), TIME_UNIT_MINUTE);
- } else {
- /* seconds */
- gtk_menu_set_active(GTK_MENU(menu), TIME_UNIT_SECOND);
- }
- }
- }
-
- gtk_option_menu_set_menu(GTK_OPTION_MENU(unit_om), menu);
-
- return unit_om;
-}
-
-static guint32 time_unit_option_menu_convert_value(
-guint32 value)
-{
- /* days */
- if(value >= 60 * 60 * 24) {
- return value / (60 * 60 * 24);
- }
-
- /* hours */
- if(value >= 60 * 60) {
- return value / (60 * 60);
- }
-
- /* minutes */
- if(value >= 60) {
- return value / 60;
- }
-
- /* seconds */
- return value;
-}
-
-static guint32 time_unit_option_menu_get_value(
-GtkWidget *unit_om,
-guint32 value)
-{
- GtkWidget *menu, *menu_item;
- int unit;
-
- menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(unit_om));
- menu_item = gtk_menu_get_active(GTK_MENU(menu));
- unit = GPOINTER_TO_INT(OBJECT_GET_DATA(menu_item, "time_unit"));
-
-
- switch(unit) {
- case(TIME_UNIT_SECOND):
- return value;
- break;
- case(TIME_UNIT_MINUTE):
- return value * 60;
- break;
- case(TIME_UNIT_HOUR):
- return value * 60 * 60;
- break;
- case(TIME_UNIT_DAY):
- return value * 60 * 60 * 24;
- break;
- default:
- g_assert_not_reached();
- return 0;
- }
-}
-
-
-#define SIZE_UNIT_BYTES 0
-#define SIZE_UNIT_KILOBYTES 1
-#define SIZE_UNIT_MEGABYTES 2
-#define SIZE_UNIT_GIGABYTES 3
-#define MAX_SIZE_UNITS 4
-static char *size_unit_name[MAX_SIZE_UNITS] = {
- "byte(s)",
- "kilobyte(s)",
- "megabyte(s)",
- "gigabyte(s)",
-};
-
-static GtkWidget *size_unit_option_menu_new(guint32 value) {
- GtkWidget *unit_om, *menu, *menu_item;
- int i;
-
- unit_om=gtk_option_menu_new();
- menu=gtk_menu_new();
- for(i=0;i<MAX_SIZE_UNITS;i++){
- menu_item=gtk_menu_item_new_with_label(size_unit_name[i]);
- OBJECT_SET_DATA(menu_item, "size_unit", GINT_TO_POINTER(i));
- gtk_menu_append(GTK_MENU(menu), menu_item);
- }
-
- /* the selected menu item can't be changed, once the option_menu
- is created, so set the matching menu item now */
- /* gigabytes */
- if(value >= 1024 * 1024 * 1024) {
- gtk_menu_set_active(GTK_MENU(menu), SIZE_UNIT_GIGABYTES);
- } else {
- /* megabytes */
- if(value >= 1024 * 1024) {
- gtk_menu_set_active(GTK_MENU(menu), SIZE_UNIT_MEGABYTES);
- } else {
- /* kilobytes */
- if(value >= 1024) {
- gtk_menu_set_active(GTK_MENU(menu), SIZE_UNIT_KILOBYTES);
- } else {
- /* bytes */
- gtk_menu_set_active(GTK_MENU(menu), SIZE_UNIT_BYTES);
- }
- }
- }
-
- gtk_option_menu_set_menu(GTK_OPTION_MENU(unit_om), menu);
-
- return unit_om;
-}
-
-static guint32 size_unit_option_menu_set_value(
-guint32 value)
-{
- /* gigabytes */
- if(value >= 1024 * 1024 * 1024) {
- return value / (1024 * 1024 * 1024);
- }
-
- /* megabytes */
- if(value >= 1024 * 1024) {
- return value / (1024 * 1024);
- }
-
- /* kilobytes */
- if(value >= 1024) {
- return value / 1024;
- }
-
- /* bytes */
- return value;
-}
-
-static guint32 size_unit_option_menu_convert_value(
-GtkWidget *unit_om,
-guint32 value)
-{
- GtkWidget *menu, *menu_item;
- int unit;
-
- menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(unit_om));
- menu_item = gtk_menu_get_active(GTK_MENU(menu));
- unit = GPOINTER_TO_INT(OBJECT_GET_DATA(menu_item, "size_unit"));
-
-
- switch(unit) {
- case(SIZE_UNIT_BYTES):
- return value;
- break;
- case(SIZE_UNIT_KILOBYTES):
- if(value > G_MAXINT / 1024) {
- return 0;
- } else {
- return value * 1024;
- }
- break;
- case(SIZE_UNIT_MEGABYTES):
- if(value > G_MAXINT / (1024 * 1024)) {
- return 0;
- } else {
- return value * 1024 * 1024;
- }
- break;
- case(SIZE_UNIT_GIGABYTES):
- if(value > G_MAXINT / (1024 * 1024 * 1024)) {
- return 0;
- } else {
- return value * 1024 * 1024 * 1024;
- }
- break;
- default:
- g_assert_not_reached();
- return 0;
- }
-}
-
-
-void
-capture_prep(void)
-{
- GtkWidget *main_vb,
- *main_hb, *left_vb, *right_vb,
-
- *capture_fr, *capture_vb,
- *if_hb, *if_cb, *if_lb,
- *if_ip_hb, *if_ip_lb,
- *linktype_hb, *linktype_lb, *linktype_om,
- *snap_hb, *snap_cb, *snap_sb, *snap_lb,
- *promisc_cb,
- *filter_hb, *filter_bt, *filter_te,
-
- *file_fr, *file_vb,
- *file_hb, *file_bt, *file_lb, *file_te,
- *multi_tb, *multi_files_on_cb,
- *ring_filesize_cb, *ring_filesize_sb, *ring_filesize_om,
- *file_duration_cb, *file_duration_sb, *file_duration_om,
- *ringbuffer_nbf_cb, *ringbuffer_nbf_sb, *ringbuffer_nbf_lb,
- *stop_files_cb, *stop_files_sb, *stop_files_lb,
-
- *limit_fr, *limit_vb, *limit_tb,
- *stop_packets_cb, *stop_packets_sb, *stop_packets_lb,
- *stop_filesize_cb, *stop_filesize_sb, *stop_filesize_om,
- *stop_duration_cb, *stop_duration_sb, *stop_duration_om,
-
- *display_fr, *display_vb,
- *sync_cb, *auto_scroll_cb, *hide_info_cb,
-
- *resolv_fr, *resolv_vb,
- *m_resolv_cb, *n_resolv_cb, *t_resolv_cb,
- *bbox, *ok_bt, *cancel_bt,
- *help_bt;
-#if GTK_MAJOR_VERSION < 2
- GtkAccelGroup *accel_group;
-#endif
- GtkTooltips *tooltips;
- GtkAdjustment *snap_adj, *ringbuffer_nbf_adj,
- *stop_packets_adj, *stop_filesize_adj, *stop_duration_adj, *stop_files_adj, *ring_filesize_adj, *file_duration_adj;
- GList *if_list, *combo_list;
- int err;
- int row;
- char err_str[PCAP_ERRBUF_SIZE];
- gchar *cant_get_if_list_errstr;
-#ifdef _WIN32
- GtkAdjustment *buffer_size_adj;
- GtkWidget *buffer_size_lb, *buffer_size_sb;
-#endif
- guint32 value;
-
- if (cap_open_w != NULL) {
- /* There's already a "Capture Options" dialog box; reactivate it. */
- reactivate_window(cap_open_w);
- return;
- }
-
-#ifdef _WIN32
- /* Is WPcap loaded? */
- if (!has_wpcap) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- "Unable to load WinPcap (wpcap.dll); Ethereal will not be able\n"
- "to capture packets.\n\n"
- "In order to capture packets, WinPcap must be installed; see\n"
- "\n"
- " http://winpcap.polito.it/\n"
- "\n"
- "or the mirror at\n"
- "\n"
- " http://winpcap.mirror.ethereal.com/\n"
- "\n"
- "or the mirror at\n"
- "\n"
- " http://www.mirrors.wiretapped.net/security/packet-capture/winpcap/\n"
- "\n"
- "for a downloadable version of WinPcap and for instructions\n"
- "on how to install WinPcap.");
- return;
- }
-#endif
-
- if_list = get_interface_list(&err, err_str);
- if (if_list == NULL && err == CANT_GET_INTERFACE_LIST) {
- cant_get_if_list_errstr = cant_get_if_list_error_message(err_str);
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s",
- cant_get_if_list_errstr);
- g_free(cant_get_if_list_errstr);
- }
-
- cap_open_w = dlg_window_new("Ethereal: Capture Options");
-
- tooltips = gtk_tooltips_new();
-
-#if GTK_MAJOR_VERSION < 2
- /* Accelerator group for the accelerators (or, as they're called in
- Windows and, I think, in Motif, "mnemonics"; Alt+<key> is a mnemonic,
- Ctrl+<key> is an accelerator). */
- accel_group = gtk_accel_group_new();
- gtk_window_add_accel_group(GTK_WINDOW(cap_open_w), accel_group);
-#endif
-
- main_vb = gtk_vbox_new(FALSE, 0);
- gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
- gtk_container_add(GTK_CONTAINER(cap_open_w), main_vb);
-
- /* Capture-related options frame */
- capture_fr = gtk_frame_new("Capture");
- gtk_container_add(GTK_CONTAINER(main_vb), capture_fr);
-
- capture_vb = gtk_vbox_new(FALSE, 3);
- gtk_container_border_width(GTK_CONTAINER(capture_vb), 5);
- gtk_container_add(GTK_CONTAINER(capture_fr), capture_vb);
-
- /* Interface row */
- if_hb = gtk_hbox_new(FALSE, 3);
- gtk_container_add(GTK_CONTAINER(capture_vb), if_hb);
-
- if_lb = gtk_label_new("Interface:");
- gtk_box_pack_start(GTK_BOX(if_hb), if_lb, FALSE, FALSE, 6);
-
- if_cb = gtk_combo_new();
- combo_list = build_capture_combo_list(if_list, TRUE);
- if (combo_list != NULL)
- gtk_combo_set_popdown_strings(GTK_COMBO(if_cb), combo_list);
- if (cfile.iface == NULL && prefs.capture_device != NULL) {
- /* No interface was specified on the command line or in a previous
- capture, but there is one specified in the preferences file;
- make the one from the preferences file the default */
- cfile.iface = g_strdup(prefs.capture_device);
- }
- if (cfile.iface != NULL)
- gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry), cfile.iface);
- else if (combo_list != NULL) {
- gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry),
- (char *)combo_list->data);
- }
- free_capture_combo_list(combo_list);
- free_interface_list(if_list);
- gtk_tooltips_set_tip(tooltips, GTK_COMBO(if_cb)->entry,
- "Choose which interface (network card) will be used to capture packets from. "
- "Be sure to select the correct one, as it's a common mistake to select the wrong interface.", NULL);
- gtk_box_pack_start(GTK_BOX(if_hb), if_cb, TRUE, TRUE, 6);
-
- if_ip_hb = gtk_hbox_new(FALSE, 3);
- gtk_box_pack_start(GTK_BOX(capture_vb), if_ip_hb, FALSE, FALSE, 0);
-
- if_ip_lb = gtk_label_new("");
- gtk_box_pack_start(GTK_BOX(if_ip_hb), if_ip_lb, FALSE, FALSE, 6);
-
- /* Linktype row */
- linktype_hb = gtk_hbox_new(FALSE, 3);
- gtk_box_pack_start(GTK_BOX(capture_vb), linktype_hb, FALSE, FALSE, 0);
-
- linktype_lb = gtk_label_new("Link-layer header type:");
- gtk_box_pack_start(GTK_BOX(linktype_hb), linktype_lb, FALSE, FALSE, 6);
-
- linktype_om = gtk_option_menu_new();
- OBJECT_SET_DATA(linktype_om, E_CAP_LT_OM_LABEL_KEY, linktype_lb);
- /* Default to "use the default" */
- OBJECT_SET_DATA(linktype_om, E_CAP_OM_LT_VALUE_KEY, GINT_TO_POINTER(-1));
- OBJECT_SET_DATA(linktype_om, E_CAP_IFACE_KEY, if_ip_lb);
- set_link_type_list(linktype_om, GTK_COMBO(if_cb)->entry);
- /*
- * XXX - in some cases, this is "multiple link-layer header types", e.g.
- * some 802.11 interfaces on FreeBSD 5.2 and later, where you can request
- * fake Ethernet, 802.11, or 802.11-plus-radio-information headers.
- *
- * In other cases, it's "multiple link-layer types", e.g., with recent
- * versions of libpcap, a DAG card on an "HDLC" WAN, where you can
- * request Cisco HDLC or PPP depending on what type of traffic is going
- * over the WAN, or an Ethernet interface, where you can request Ethernet
- * or DOCSIS, the latter being for some Cisco cable modem equipment that
- * can be configured to send raw DOCSIS frames over an Ethernet inside
- * Ethernet low-level framing, for traffic capture purposes.
- *
- * We leave it as "multiple link-layer types" for now.
- */
- gtk_tooltips_set_tip(tooltips, linktype_om,
- "The selected interface supports multiple link-layer types; select the desired one.", NULL);
- gtk_box_pack_start (GTK_BOX(linktype_hb), linktype_om, FALSE, FALSE, 0);
- SIGNAL_CONNECT(GTK_ENTRY(GTK_COMBO(if_cb)->entry), "changed",
- capture_prep_interface_changed_cb, linktype_om);
-
-#ifdef _WIN32
- buffer_size_lb = gtk_label_new("Buffer size:");
- gtk_box_pack_start (GTK_BOX(linktype_hb), buffer_size_lb, FALSE, FALSE, 0);
-
- buffer_size_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat) capture_opts.buffer_size,
- 1, 65535, 1.0, 10.0, 0.0);
- buffer_size_sb = gtk_spin_button_new (buffer_size_adj, 0, 0);
- gtk_spin_button_set_value(GTK_SPIN_BUTTON (buffer_size_sb), (gfloat) capture_opts.buffer_size);
- gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (buffer_size_sb), TRUE);
- WIDGET_SET_SIZE(buffer_size_sb, 80, -1);
- gtk_tooltips_set_tip(tooltips, buffer_size_sb,
- "The memory buffer size used while capturing. If you notice packet drops, you can try to increase this size.", NULL);
- gtk_box_pack_start (GTK_BOX(linktype_hb), buffer_size_sb, FALSE, FALSE, 0);
-
- buffer_size_lb = gtk_label_new("megabyte(s)");
- gtk_box_pack_start (GTK_BOX(linktype_hb), buffer_size_lb, FALSE, FALSE, 0);
-#endif
-
- /* Promiscuous mode row */
- promisc_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC(
- "Capture packets in _promiscuous mode", accel_group);
- gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(promisc_cb),
- capture_opts.promisc_mode);
- gtk_tooltips_set_tip(tooltips, promisc_cb,
- "Usually a network card will only capture the traffic sent to its own network address. "
- "If you want to capture all traffic that the network card can \"see\", mark this option. "
- "See the FAQ for some more details of capturing packets from a switched network.", NULL);
- gtk_container_add(GTK_CONTAINER(capture_vb), promisc_cb);
-
- /* Capture length row */
- snap_hb = gtk_hbox_new(FALSE, 3);
- gtk_container_add(GTK_CONTAINER(capture_vb), snap_hb);
-
- snap_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC("_Limit each packet to", accel_group);
- gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(snap_cb),
- capture_opts.has_snaplen);
- SIGNAL_CONNECT(snap_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w);
- gtk_tooltips_set_tip(tooltips, snap_cb,
- "Limit the maximum number of bytes to be captured from each packet. This size includes the "
- "link-layer header and all subsequent headers. ", NULL);
- gtk_box_pack_start(GTK_BOX(snap_hb), snap_cb, FALSE, FALSE, 0);
-
- snap_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat) capture_opts.snaplen,
- MIN_PACKET_SIZE, WTAP_MAX_PACKET_SIZE, 1.0, 10.0, 0.0);
- snap_sb = gtk_spin_button_new (snap_adj, 0, 0);
- gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (snap_sb), TRUE);
- WIDGET_SET_SIZE(snap_sb, 80, -1);
- gtk_box_pack_start (GTK_BOX(snap_hb), snap_sb, FALSE, FALSE, 0);
-
- snap_lb = gtk_label_new("bytes");
- gtk_misc_set_alignment(GTK_MISC(snap_lb), 0, 0.5);
- gtk_box_pack_start(GTK_BOX(snap_hb), snap_lb, FALSE, FALSE, 0);
-
- /* Filter row */
- filter_hb = gtk_hbox_new(FALSE, 3);
- gtk_box_pack_start(GTK_BOX(capture_vb), filter_hb, FALSE, FALSE, 0);
-
- filter_bt = BUTTON_NEW_FROM_STOCK(ETHEREAL_STOCK_CAPTURE_FILTER_ENTRY);
- SIGNAL_CONNECT(filter_bt, "clicked", capture_filter_construct_cb, NULL);
- SIGNAL_CONNECT(filter_bt, "destroy", filter_button_destroy_cb, NULL);
- gtk_tooltips_set_tip(tooltips, filter_bt,
- "Select a capture filter to reduce the amount of packets to be captured. "
- "See \"Capture Filters\" in the online help for further information how to use it.",
- NULL);
- gtk_box_pack_start(GTK_BOX(filter_hb), filter_bt, FALSE, FALSE, 3);
-
- filter_te = gtk_entry_new();
- if (cfile.cfilter) gtk_entry_set_text(GTK_ENTRY(filter_te), cfile.cfilter);
- OBJECT_SET_DATA(filter_bt, E_FILT_TE_PTR_KEY, filter_te);
- gtk_tooltips_set_tip(tooltips, filter_te,
- "Enter a capture filter to reduce the amount of packets to be captured. "
- "See \"Capture Filters\" in the online help for further information how to use it.",
- NULL);
- gtk_box_pack_start(GTK_BOX(filter_hb), filter_te, TRUE, TRUE, 3);
-
- main_hb = gtk_hbox_new(FALSE, 5);
- gtk_container_border_width(GTK_CONTAINER(main_hb), 0);
- gtk_container_add(GTK_CONTAINER(main_vb), main_hb);
-
- left_vb = gtk_vbox_new(FALSE, 0);
- gtk_container_border_width(GTK_CONTAINER(left_vb), 0);
- gtk_box_pack_start(GTK_BOX(main_hb), left_vb, TRUE, TRUE, 0);
-
- right_vb = gtk_vbox_new(FALSE, 0);
- gtk_container_border_width(GTK_CONTAINER(right_vb), 0);
- gtk_box_pack_start(GTK_BOX(main_hb), right_vb, FALSE, FALSE, 0);
-
-
- /* Capture file-related options frame */
- file_fr = gtk_frame_new("Capture File(s)");
- gtk_container_add(GTK_CONTAINER(left_vb), file_fr);
-
- file_vb = gtk_vbox_new(FALSE, 3);
- gtk_container_border_width(GTK_CONTAINER(file_vb), 5);
- gtk_container_add(GTK_CONTAINER(file_fr), file_vb);
-
- /* File row */
- file_hb = gtk_hbox_new(FALSE, 3);
- gtk_box_pack_start(GTK_BOX(file_vb), file_hb, FALSE, FALSE, 0);
-
- file_lb = gtk_label_new("File:");
- gtk_box_pack_start(GTK_BOX(file_hb), file_lb, FALSE, FALSE, 3);
-
- file_te = gtk_entry_new();
- gtk_tooltips_set_tip(tooltips, file_te,
- "Enter the file name to which captured data will be written. "
- "If you don't enter something here, a temporary file will be used.",
- NULL);
- gtk_box_pack_start(GTK_BOX(file_hb), file_te, TRUE, TRUE, 3);
-
- file_bt = BUTTON_NEW_FROM_STOCK(ETHEREAL_STOCK_BROWSE);
- gtk_tooltips_set_tip(tooltips, file_bt,
- "Select a file to which captured data will be written, "
- "instead of entering the file name directly. ",
- NULL);
- gtk_box_pack_start(GTK_BOX(file_hb), file_bt, FALSE, FALSE, 3);
-
- SIGNAL_CONNECT(file_bt, "clicked", capture_prep_file_cb, file_te);
-
- /* multiple files table */
- multi_tb = gtk_table_new(5, 3, FALSE);
- gtk_table_set_row_spacings(GTK_TABLE(multi_tb), 1);
- gtk_table_set_col_spacings(GTK_TABLE(multi_tb), 3);
- gtk_box_pack_start(GTK_BOX(file_vb), multi_tb, FALSE, FALSE, 0);
- row = 0;
-
- /* multiple files row */
- multi_files_on_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC("Use _multiple files", accel_group);
- gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(multi_files_on_cb),
- capture_opts.multi_files_on);
- SIGNAL_CONNECT(multi_files_on_cb, "toggled", capture_prep_adjust_sensitivity,
- cap_open_w);
- gtk_tooltips_set_tip(tooltips, multi_files_on_cb,
- "Instead of using a single capture file, multiple files will be created. "
- "The generated file names will contain an incrementing number and the start time of the capture.", NULL);
- gtk_table_attach_defaults(GTK_TABLE(multi_tb), multi_files_on_cb, 0, 1, row, row+1);
- row++;
-
- /* Ring buffer filesize row */
- ring_filesize_cb = gtk_check_button_new_with_label("Next file every");
- gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(ring_filesize_cb),
- capture_opts.has_autostop_filesize);
- SIGNAL_CONNECT(ring_filesize_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w);
- gtk_tooltips_set_tip(tooltips, ring_filesize_cb,
- "If the selected file size is exceeded, capturing switches to the next file.",
- NULL);
- gtk_table_attach_defaults(GTK_TABLE(multi_tb), ring_filesize_cb, 0, 1, row, row+1);
-
- ring_filesize_adj = (GtkAdjustment *) gtk_adjustment_new(0.0,
- 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
- ring_filesize_sb = gtk_spin_button_new (ring_filesize_adj, 0, 0);
- gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (ring_filesize_sb), TRUE);
- WIDGET_SET_SIZE(ring_filesize_sb, 80, -1);
- gtk_table_attach_defaults(GTK_TABLE(multi_tb), ring_filesize_sb, 1, 2, row, row+1);
-
- ring_filesize_om = size_unit_option_menu_new(capture_opts.autostop_filesize);
- gtk_table_attach_defaults(GTK_TABLE(multi_tb), ring_filesize_om, 2, 3, row, row+1);
-
- value = size_unit_option_menu_set_value(capture_opts.autostop_filesize);
- gtk_adjustment_set_value(ring_filesize_adj, (gfloat) value);
-
- row++;
-
- /* Ring buffer duration row */
- file_duration_cb = gtk_check_button_new_with_label("Next file every");
- gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(file_duration_cb),
- capture_opts.has_file_duration);
- SIGNAL_CONNECT(file_duration_cb, "toggled",
- capture_prep_adjust_sensitivity, cap_open_w);
- gtk_tooltips_set_tip(tooltips, file_duration_cb,
- "If the selected duration is exceeded, capturing switches to the next file.",
- NULL);
- gtk_table_attach_defaults(GTK_TABLE(multi_tb), file_duration_cb, 0, 1, row, row+1);
-
- file_duration_adj = (GtkAdjustment *)gtk_adjustment_new(0.0,
- 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
- file_duration_sb = gtk_spin_button_new (file_duration_adj, 0, 0);
- gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (file_duration_sb), TRUE);
- WIDGET_SET_SIZE(file_duration_sb, 80, -1);
- gtk_table_attach_defaults(GTK_TABLE(multi_tb), file_duration_sb, 1, 2, row, row+1);
-
- file_duration_om = time_unit_option_menu_new(capture_opts.file_duration);
- gtk_table_attach_defaults(GTK_TABLE(multi_tb), file_duration_om, 2, 3, row, row+1);
-
- value = time_unit_option_menu_convert_value(capture_opts.file_duration);
- gtk_adjustment_set_value(file_duration_adj, (gfloat) value);
- row++;
-
- /* Ring buffer files row */
- ringbuffer_nbf_cb = gtk_check_button_new_with_label("Ring buffer with");
- gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb),
- capture_opts.has_ring_num_files);
- SIGNAL_CONNECT(ringbuffer_nbf_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w);
- gtk_tooltips_set_tip(tooltips, ringbuffer_nbf_cb,
- "After capturing has switched to the next file and the given number of files has exceeded, "
- "the oldest file will be removed.",
- NULL);
- gtk_table_attach_defaults(GTK_TABLE(multi_tb), ringbuffer_nbf_cb, 0, 1, row, row+1);
-
- ringbuffer_nbf_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat) capture_opts.ring_num_files,
- 2/*RINGBUFFER_MIN_NUM_FILES*/, RINGBUFFER_MAX_NUM_FILES, 1.0, 10.0, 0.0);
- ringbuffer_nbf_sb = gtk_spin_button_new (ringbuffer_nbf_adj, 0, 0);
- gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (ringbuffer_nbf_sb), TRUE);
- WIDGET_SET_SIZE(ringbuffer_nbf_sb, 80, -1);
- SIGNAL_CONNECT(ringbuffer_nbf_sb, "changed", capture_prep_adjust_sensitivity, cap_open_w);
- gtk_table_attach_defaults(GTK_TABLE(multi_tb), ringbuffer_nbf_sb, 1, 2, row, row+1);
-
- ringbuffer_nbf_lb = gtk_label_new("files");
- gtk_misc_set_alignment(GTK_MISC(ringbuffer_nbf_lb), 0, 0.5);
- gtk_table_attach_defaults(GTK_TABLE(multi_tb), ringbuffer_nbf_lb, 2, 3, row, row+1);
- row++;
-
- /* Files row */
- stop_files_cb = gtk_check_button_new_with_label("Stop capture after");
- gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(stop_files_cb),
- capture_opts.has_autostop_files);
- SIGNAL_CONNECT(stop_files_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w);
- gtk_tooltips_set_tip(tooltips, stop_files_cb,
- "Stop capturing after the given number of \"file switches\" have been done.", NULL);
- gtk_table_attach_defaults(GTK_TABLE(multi_tb), stop_files_cb, 0, 1, row, row+1);
-
- stop_files_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat)capture_opts.autostop_files,
- 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
- stop_files_sb = gtk_spin_button_new (stop_files_adj, 0, 0);
- gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_files_sb), TRUE);
- WIDGET_SET_SIZE(stop_files_sb, 80, -1);
- gtk_table_attach_defaults(GTK_TABLE(multi_tb), stop_files_sb, 1, 2, row, row+1);
-
- stop_files_lb = gtk_label_new("file(s)");
- gtk_misc_set_alignment(GTK_MISC(stop_files_lb), 0, 0.5);
- gtk_table_attach_defaults(GTK_TABLE(multi_tb), stop_files_lb, 2, 3, row, row+1);
- row++;
-
- /* Capture limits frame */
- limit_fr = gtk_frame_new("Stop Capture ...");
- gtk_container_add(GTK_CONTAINER(left_vb), limit_fr);
-
- limit_vb = gtk_vbox_new(FALSE, 3);
- gtk_container_border_width(GTK_CONTAINER(limit_vb), 5);
- gtk_container_add(GTK_CONTAINER(limit_fr), limit_vb);
-
- /* limits table */
- limit_tb = gtk_table_new(3, 3, FALSE);
- gtk_table_set_row_spacings(GTK_TABLE(limit_tb), 1);
- gtk_table_set_col_spacings(GTK_TABLE(limit_tb), 3);
- gtk_box_pack_start(GTK_BOX(limit_vb), limit_tb, FALSE, FALSE, 0);
- row = 0;
-
- /* Packet count row */
- stop_packets_cb = gtk_check_button_new_with_label("... after");
- gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(stop_packets_cb),
- capture_opts.has_autostop_packets);
- SIGNAL_CONNECT(stop_packets_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w);
- gtk_tooltips_set_tip(tooltips, stop_packets_cb,
- "Stop capturing after the given number of packets have been captured.", NULL);
- gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_packets_cb, 0, 1, row, row+1);
-
- stop_packets_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat)capture_opts.autostop_packets,
- 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
- stop_packets_sb = gtk_spin_button_new (stop_packets_adj, 0, 0);
- gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_packets_sb), TRUE);
- WIDGET_SET_SIZE(stop_packets_sb, 80, -1);
- gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_packets_sb, 1, 2, row, row+1);
-
- stop_packets_lb = gtk_label_new("packet(s)");
- gtk_misc_set_alignment(GTK_MISC(stop_packets_lb), 0, 0.5);
- gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_packets_lb, 2, 3, row, row+1);
- row++;
-
- /* Filesize row */
- stop_filesize_cb = gtk_check_button_new_with_label("... after");
- gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(stop_filesize_cb),
- capture_opts.has_autostop_filesize);
- SIGNAL_CONNECT(stop_filesize_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w);
- gtk_tooltips_set_tip(tooltips, stop_filesize_cb,
- "Stop capturing after the given amount of capture data has been captured.", NULL);
- gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_filesize_cb, 0, 1, row, row+1);
-
- stop_filesize_adj = (GtkAdjustment *) gtk_adjustment_new(0.0,
- 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
- stop_filesize_sb = gtk_spin_button_new (stop_filesize_adj, 0, 0);
- gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_filesize_sb), TRUE);
- WIDGET_SET_SIZE(stop_filesize_sb, 80, -1);
- gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_filesize_sb, 1, 2, row, row+1);
-
- stop_filesize_om = size_unit_option_menu_new(capture_opts.autostop_filesize);
- gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_filesize_om, 2, 3, row, row+1);
-
- value = size_unit_option_menu_set_value(capture_opts.autostop_filesize);
- gtk_adjustment_set_value(stop_filesize_adj, (gfloat) value);
-
- row++;
-
- /* Duration row */
- stop_duration_cb = gtk_check_button_new_with_label("... after");
- gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(stop_duration_cb),
- capture_opts.has_autostop_duration);
- SIGNAL_CONNECT(stop_duration_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w);
- gtk_tooltips_set_tip(tooltips, stop_duration_cb,
- "Stop capturing after the given time is exceeded.", NULL);
- gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_duration_cb, 0, 1, row, row+1);
-
- stop_duration_adj = (GtkAdjustment *) gtk_adjustment_new(0.0,
- 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
- stop_duration_sb = gtk_spin_button_new (stop_duration_adj, 0, 0);
- gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_duration_sb), TRUE);
- WIDGET_SET_SIZE(stop_duration_sb, 80, -1);
- gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_duration_sb, 1, 2, row, row+1);
-
- stop_duration_om = time_unit_option_menu_new(capture_opts.autostop_duration);
- gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_duration_om, 2, 3, row, row+1);
-
- value = time_unit_option_menu_convert_value(capture_opts.autostop_duration);
- gtk_adjustment_set_value(stop_duration_adj, (gfloat) value);
- row++;
-
- /* Display-related options frame */
- display_fr = gtk_frame_new("Display Options");
- gtk_container_add(GTK_CONTAINER(right_vb), display_fr);
-
- display_vb = gtk_vbox_new(FALSE, 0);
- gtk_container_border_width(GTK_CONTAINER(display_vb), 5);
- gtk_container_add(GTK_CONTAINER(display_fr), display_vb);
-
- /* "Update display in real time" row */
- sync_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC(
- "_Update list of packets in real time", accel_group);
- gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(sync_cb),
- capture_opts.sync_mode);
- SIGNAL_CONNECT(sync_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w);
- gtk_tooltips_set_tip(tooltips, sync_cb,
- "Using this option will show the captured packets immediately on the main screen. "
- "Please note: this will slow down capturing, so increased packet drops might appear.", NULL);
- gtk_container_add(GTK_CONTAINER(display_vb), sync_cb);
-
- /* "Auto-scroll live update" row */
- auto_scroll_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC(
- "_Automatic scrolling in live capture", accel_group);
- gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(auto_scroll_cb), auto_scroll_live);
- gtk_tooltips_set_tip(tooltips, auto_scroll_cb,
- "This will scroll the \"Packet List\" automatically to the latest captured packet, "
- "when the \"Update List of packets in real time\" option is used.", NULL);
- gtk_container_add(GTK_CONTAINER(display_vb), auto_scroll_cb);
-
- /* "Hide capture info" row */
- hide_info_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC(
- "_Hide capture info dialog", accel_group);
- gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(hide_info_cb), !capture_opts.show_info);
- gtk_tooltips_set_tip(tooltips, hide_info_cb,
- "Hide the capture info dialog while capturing.", NULL);
- gtk_container_add(GTK_CONTAINER(display_vb), hide_info_cb);
-
- /* Name Resolution frame */
- resolv_fr = gtk_frame_new("Name Resolution");
- gtk_container_add(GTK_CONTAINER(right_vb), resolv_fr);
-
- resolv_vb = gtk_vbox_new(FALSE, 0);
- gtk_container_border_width(GTK_CONTAINER(resolv_vb), 5);
- gtk_container_add(GTK_CONTAINER(resolv_fr), resolv_vb);
-
- m_resolv_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC(
- "Enable _MAC name resolution", accel_group);
- gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(m_resolv_cb),
- g_resolv_flags & RESOLV_MAC);
- gtk_tooltips_set_tip(tooltips, m_resolv_cb,
- "Perform MAC layer name resolution while capturing.", NULL);
- gtk_container_add(GTK_CONTAINER(resolv_vb), m_resolv_cb);
-
- n_resolv_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC(
- "Enable _network name resolution", accel_group);
- gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(n_resolv_cb),
- g_resolv_flags & RESOLV_NETWORK);
- gtk_tooltips_set_tip(tooltips, n_resolv_cb,
- "Perform network layer name resolution while capturing.", NULL);
- gtk_container_add(GTK_CONTAINER(resolv_vb), n_resolv_cb);
-
- t_resolv_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC(
- "Enable _transport name resolution", accel_group);
- gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(t_resolv_cb),
- g_resolv_flags & RESOLV_TRANSPORT);
- gtk_tooltips_set_tip(tooltips, t_resolv_cb,
- "Perform transport layer name resolution while capturing.", NULL);
- gtk_container_add(GTK_CONTAINER(resolv_vb), t_resolv_cb);
-
- /* Button row: OK and cancel buttons */
- bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL);
- gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 5);
-
- ok_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_OK);
- SIGNAL_CONNECT(ok_bt, "clicked", capture_prep_ok_cb, cap_open_w);
- gtk_tooltips_set_tip(tooltips, ok_bt,
- "Start the capture process.", NULL);
-
- cancel_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CANCEL);
- gtk_tooltips_set_tip(tooltips, cancel_bt,
- "Cancel and exit dialog.", NULL);
- window_set_cancel_button(cap_open_w, cancel_bt, window_cancel_button_cb);
-
- help_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_HELP);
- gtk_tooltips_set_tip(tooltips, help_bt,
- "Show help about capturing.", NULL);
- SIGNAL_CONNECT(help_bt, "clicked", help_topic_cb, "Capturing");
-
- gtk_widget_grab_default(ok_bt);
-
- /* Attach pointers to needed widgets to the capture prefs window/object */
- OBJECT_SET_DATA(cap_open_w, E_CAP_IFACE_KEY, if_cb);
- OBJECT_SET_DATA(cap_open_w, E_CAP_SNAP_CB_KEY, snap_cb);
- OBJECT_SET_DATA(cap_open_w, E_CAP_SNAP_SB_KEY, snap_sb);
- OBJECT_SET_DATA(cap_open_w, E_CAP_LT_OM_KEY, linktype_om);
-#ifdef _WIN32
- OBJECT_SET_DATA(cap_open_w, E_CAP_BUFFER_SIZE_SB_KEY, buffer_size_sb);
-#endif
- OBJECT_SET_DATA(cap_open_w, E_CAP_PROMISC_KEY, promisc_cb);
- OBJECT_SET_DATA(cap_open_w, E_CAP_FILT_KEY, filter_te);
- OBJECT_SET_DATA(cap_open_w, E_CAP_FILE_TE_KEY, file_te);
- OBJECT_SET_DATA(cap_open_w, E_CAP_MULTI_FILES_ON_CB_KEY, multi_files_on_cb);
- OBJECT_SET_DATA(cap_open_w, E_CAP_RING_NBF_CB_KEY, ringbuffer_nbf_cb);
- OBJECT_SET_DATA(cap_open_w, E_CAP_RING_NBF_SB_KEY, ringbuffer_nbf_sb);
- OBJECT_SET_DATA(cap_open_w, E_CAP_RING_NBF_LB_KEY, ringbuffer_nbf_lb);
- OBJECT_SET_DATA(cap_open_w, E_CAP_RING_FILESIZE_CB_KEY, ring_filesize_cb);
- OBJECT_SET_DATA(cap_open_w, E_CAP_RING_FILESIZE_SB_KEY, ring_filesize_sb);
- OBJECT_SET_DATA(cap_open_w, E_CAP_RING_FILESIZE_OM_KEY, ring_filesize_om);
- OBJECT_SET_DATA(cap_open_w, E_CAP_FILE_DURATION_CB_KEY, file_duration_cb);
- OBJECT_SET_DATA(cap_open_w, E_CAP_FILE_DURATION_SB_KEY, file_duration_sb);
- OBJECT_SET_DATA(cap_open_w, E_CAP_FILE_DURATION_OM_KEY, file_duration_om);
- OBJECT_SET_DATA(cap_open_w, E_CAP_SYNC_KEY, sync_cb);
- OBJECT_SET_DATA(cap_open_w, E_CAP_AUTO_SCROLL_KEY, auto_scroll_cb);
- OBJECT_SET_DATA(cap_open_w, E_CAP_HIDE_INFO_KEY, hide_info_cb);
- OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_PACKETS_CB_KEY, stop_packets_cb);
- OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_PACKETS_SB_KEY, stop_packets_sb);
- OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_PACKETS_LB_KEY, stop_packets_lb);
- OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_FILESIZE_CB_KEY, stop_filesize_cb);
- OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_FILESIZE_SB_KEY, stop_filesize_sb);
- OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_FILESIZE_OM_KEY, stop_filesize_om);
- OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_DURATION_CB_KEY, stop_duration_cb);
- OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_DURATION_SB_KEY, stop_duration_sb);
- OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_DURATION_OM_KEY, stop_duration_om);
- OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_FILES_CB_KEY, stop_files_cb);
- OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_FILES_SB_KEY, stop_files_sb);
- OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_FILES_LB_KEY, stop_files_lb);
- OBJECT_SET_DATA(cap_open_w, E_CAP_M_RESOLVE_KEY, m_resolv_cb);
- OBJECT_SET_DATA(cap_open_w, E_CAP_N_RESOLVE_KEY, n_resolv_cb);
- OBJECT_SET_DATA(cap_open_w, E_CAP_T_RESOLVE_KEY, t_resolv_cb);
-
- /* Set the sensitivity of various widgets as per the settings of other
- widgets. */
- capture_prep_adjust_sensitivity(NULL, cap_open_w);
-
- /* Catch the "activate" signal on the text
- entries, so that if the user types Return there, we act as if the
- "OK" button had been selected, as happens if Return is typed if some
- widget that *doesn't* handle the Return key has the input focus. */
- dlg_set_activate(GTK_COMBO(if_cb)->entry, ok_bt);
- dlg_set_activate(filter_te, ok_bt);
- dlg_set_activate(file_te, ok_bt);
-
- /* XXX - why does not
-
- gtk_widget_grab_focus(if_cb);
-
- give the initial focus to the "Interface" combo box?
-
- Or should I phrase that as "why does GTK+ continually frustrate
- attempts to make GUIs driveable from the keyboard?" We have to
- go catch the activate signal on every single GtkEntry widget
- (rather than having widgets whose activate signal is *not*
- caught not catch the Return keystroke, so that it passes on,
- ultimately, to the window, which can activate the default
- widget, i.e. the "OK" button); we have to catch the "key_press_event"
- signal and have the handler check for ESC, so that we can have ESC
- activate the "Cancel" button; in order to support Alt+<key> mnemonics
- for buttons and the like, we may have to construct an accelerator
- group by hand and set up the accelerators by hand (if that even
- works - I've not tried it yet); we have to do a "gtk_widget_grab_focus()"
- to keep some container widget from getting the initial focus, so that
- you don't have to tab into the first widget in order to start typing
- in it; and it now appears that you simply *can't* make a combo box
- get the initial focus, at least not in the obvious fashion. Sigh.... */
-
- SIGNAL_CONNECT(cap_open_w, "delete_event", window_delete_event_cb, NULL);
- SIGNAL_CONNECT(cap_open_w, "destroy", capture_prep_destroy_cb, NULL);
-
- gtk_widget_show_all(cap_open_w);
- window_present(cap_open_w);
-}
-
-static void
-capture_prep_answered_cb(gpointer dialog _U_, gint btn, gpointer data)
-{
- switch(btn) {
- case(ESD_BTN_SAVE):
- /* save file first */
- file_save_as_cmd(after_save_capture_dialog, data);
- break;
- case(ESD_BTN_DONT_SAVE):
- capture_prep();
- break;
- case(ESD_BTN_CANCEL):
- break;
- default:
- g_assert_not_reached();
- }
-}
-
-void
-capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
-{
- gpointer dialog;
-
- if((cfile.state != FILE_CLOSED) && !cfile.user_saved && prefs.gui_ask_unsaved) {
- /* user didn't saved his current file, ask him */
- dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_SAVE_DONTSAVE_CANCEL,
- PRIMARY_TEXT_START "Save capture file before starting a new capture?" PRIMARY_TEXT_END "\n\n"
- "If you start a new capture without saving, your current capture data will\nbe discarded.");
- simple_dialog_set_cb(dialog, capture_prep_answered_cb, NULL);
- } else {
- /* unchanged file, just capture a new one */
- capture_prep();
- }
-}
-
-static void
-select_link_type_cb(GtkWidget *w, gpointer data)
-{
- int new_linktype = GPOINTER_TO_INT(data);
- GtkWidget *linktype_om = OBJECT_GET_DATA(w, E_CAP_LT_OM_KEY);
- int old_linktype = GPOINTER_TO_INT(OBJECT_GET_DATA(linktype_om, E_CAP_OM_LT_VALUE_KEY));
-
- if (old_linktype != new_linktype)
- OBJECT_SET_DATA(linktype_om, E_CAP_OM_LT_VALUE_KEY, GINT_TO_POINTER(new_linktype));
-}
-
-static void
-capture_prep_file_cb(GtkWidget *file_bt, GtkWidget *file_te)
-{
- file_selection_browse(file_bt, file_te, "Ethereal: Specify a Capture File", FILE_SELECTION_OPEN);
-}
-
-
-static void
-capture_prep_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w) {
- GtkWidget *if_cb, *snap_cb, *snap_sb, *promisc_cb, *filter_te,
- *file_te, *multi_files_on_cb, *ringbuffer_nbf_sb, *ringbuffer_nbf_cb,
- *linktype_om, *sync_cb, *auto_scroll_cb, *hide_info_cb,
- *stop_packets_cb, *stop_packets_sb,
- *stop_filesize_cb, *stop_filesize_sb, *stop_filesize_om,
- *stop_duration_cb, *stop_duration_sb, *stop_duration_om,
- *ring_filesize_cb, *ring_filesize_sb, *ring_filesize_om,
- *file_duration_cb, *file_duration_sb, *file_duration_om,
- *stop_files_cb, *stop_files_sb,
- *m_resolv_cb, *n_resolv_cb, *t_resolv_cb;
-#ifdef _WIN32
- GtkWidget *buffer_size_sb;
-#endif
- gchar *entry_text;
- gchar *if_text;
- gchar *if_name;
- const gchar *filter_text;
- gchar *save_file;
- const gchar *g_save_file;
- gchar *cf_name;
- gchar *dirname;
- gint32 tmp;
-
- if_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_IFACE_KEY);
- snap_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_SNAP_CB_KEY);
- snap_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_SNAP_SB_KEY);
- linktype_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_LT_OM_KEY);
-#ifdef _WIN32
- buffer_size_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_BUFFER_SIZE_SB_KEY);
-#endif
- promisc_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_PROMISC_KEY);
- filter_te = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILT_KEY);
- file_te = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILE_TE_KEY);
- multi_files_on_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_MULTI_FILES_ON_CB_KEY);
- ringbuffer_nbf_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_NBF_CB_KEY);
- ringbuffer_nbf_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_NBF_SB_KEY);
- ring_filesize_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_FILESIZE_CB_KEY);
- ring_filesize_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_FILESIZE_SB_KEY);
- ring_filesize_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_FILESIZE_OM_KEY);
- file_duration_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILE_DURATION_CB_KEY);
- file_duration_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILE_DURATION_SB_KEY);
- file_duration_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILE_DURATION_OM_KEY);
- sync_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_SYNC_KEY);
- auto_scroll_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_AUTO_SCROLL_KEY);
- hide_info_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_HIDE_INFO_KEY);
- stop_packets_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_PACKETS_CB_KEY);
- stop_packets_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_PACKETS_SB_KEY);
- stop_filesize_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILESIZE_CB_KEY);
- stop_filesize_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILESIZE_SB_KEY);
- stop_filesize_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILESIZE_OM_KEY);
- stop_duration_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_DURATION_CB_KEY);
- stop_duration_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_DURATION_SB_KEY);
- stop_duration_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_DURATION_OM_KEY);
- stop_files_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILES_CB_KEY);
- stop_files_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILES_SB_KEY);
- m_resolv_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_M_RESOLVE_KEY);
- n_resolv_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_N_RESOLVE_KEY);
- t_resolv_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_T_RESOLVE_KEY);
-
- entry_text =
- g_strdup(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry)));
- if_text = g_strstrip(entry_text);
- if_name = get_if_name(if_text);
- if (*if_name == '\0') {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- "You didn't specify an interface on which to capture packets.");
- g_free(entry_text);
- return;
- }
- if (cfile.iface)
- g_free(cfile.iface);
- cfile.iface = g_strdup(if_name);
- g_free(entry_text);
-
- capture_opts.linktype =
- GPOINTER_TO_INT(OBJECT_GET_DATA(linktype_om, E_CAP_OM_LT_VALUE_KEY));
-
-#ifdef _WIN32
- capture_opts.buffer_size =
- gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(buffer_size_sb));
-#endif
-
- capture_opts.has_snaplen =
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(snap_cb));
- if (capture_opts.has_snaplen) {
- capture_opts.snaplen =
- gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(snap_sb));
- if (capture_opts.snaplen < 1)
- capture_opts.snaplen = WTAP_MAX_PACKET_SIZE;
- else if (capture_opts.snaplen < MIN_PACKET_SIZE)
- capture_opts.snaplen = MIN_PACKET_SIZE;
- }
-
- capture_opts.promisc_mode =
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(promisc_cb));
-
- /* XXX - don't try to get clever and set "cfile.filter" to NULL if the
- filter string is empty, as an indication that we don't have a filter
- and thus don't have to set a filter when capturing - the version of
- libpcap in Red Hat Linux 6.1, and versions based on later patches
- in that series, don't bind the AF_PACKET socket to an interface
- until a filter is set, which means they aren't bound at all if
- no filter is set, which means no packets arrive as input on that
- socket, which means Ethereal never sees any packets. */
- filter_text = gtk_entry_get_text(GTK_ENTRY(filter_te));
- if (cfile.cfilter)
- g_free(cfile.cfilter);
- g_assert(filter_text != NULL);
- cfile.cfilter = g_strdup(filter_text);
-
- g_save_file = gtk_entry_get_text(GTK_ENTRY(file_te));
- if (g_save_file && g_save_file[0]) {
- /* User specified a file to which the capture should be written. */
- save_file = g_strdup(g_save_file);
- /* Save the directory name for future file dialogs. */
- cf_name = g_strdup(g_save_file);
- dirname = get_dirname(cf_name); /* Overwrites cf_name */
- set_last_open_dir(dirname);
- g_free(cf_name);
- } else {
- /* User didn't specify a file; save to a temporary file. */
- save_file = NULL;
- }
-
- capture_opts.has_autostop_packets =
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_packets_cb));
- if (capture_opts.has_autostop_packets)
- capture_opts.autostop_packets =
- gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_packets_sb));
-
- capture_opts.has_autostop_duration =
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_duration_cb));
- if (capture_opts.has_autostop_duration) {
- capture_opts.autostop_duration =
- gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_duration_sb));
- capture_opts.autostop_duration =
- time_unit_option_menu_get_value(stop_duration_om, capture_opts.autostop_duration);
- }
-
- capture_opts.sync_mode =
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sync_cb));
-
- auto_scroll_live =
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(auto_scroll_cb));
-
- capture_opts.show_info =
- !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hide_info_cb));
-
- g_resolv_flags |= g_resolv_flags & RESOLV_CONCURRENT;
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_resolv_cb)))
- g_resolv_flags |= RESOLV_MAC;
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(n_resolv_cb)))
- g_resolv_flags |= RESOLV_NETWORK;
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(t_resolv_cb)))
- g_resolv_flags |= RESOLV_TRANSPORT;
-
- capture_opts.has_ring_num_files =
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb));
-
- capture_opts.ring_num_files =
- gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ringbuffer_nbf_sb));
- if (capture_opts.ring_num_files > RINGBUFFER_MAX_NUM_FILES)
- capture_opts.ring_num_files = RINGBUFFER_MAX_NUM_FILES;
-#if RINGBUFFER_MIN_NUM_FILES > 0
- else if (capture_opts.ring_num_files < RINGBUFFER_MIN_NUM_FILES)
- capture_opts.ring_num_files = RINGBUFFER_MIN_NUM_FILES;
-#endif
-
- capture_opts.multi_files_on =
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(multi_files_on_cb));
-
- if(capture_opts.sync_mode)
- capture_opts.multi_files_on = FALSE;
-
- if (capture_opts.multi_files_on) {
- capture_opts.has_autostop_filesize =
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb));
- if (capture_opts.has_autostop_filesize) {
- tmp = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ring_filesize_sb));
- tmp = size_unit_option_menu_convert_value(ring_filesize_om, tmp);
- if(tmp != 0) {
- capture_opts.autostop_filesize = tmp;
- } else {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- PRIMARY_TEXT_START "Multiple files: Requested filesize too large!\n\n" PRIMARY_TEXT_END
- "The setting \"Next file every x byte(s)\" can't be greater than %u bytes (2GB).", G_MAXINT);
- return;
- }
- }
-
- /* test if the settings are ok for a ringbuffer */
- if (save_file == NULL) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- PRIMARY_TEXT_START "Multiple files: No capture file name given!\n\n" PRIMARY_TEXT_END
- "You must specify a filename if you want to use multiple files.");
- return;
- } else if (!capture_opts.has_autostop_filesize) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- PRIMARY_TEXT_START "Multiple files: No file limit given!\n\n" PRIMARY_TEXT_END
- "You must specify a file size at which is switched to the next capture file\n"
- "if you want to use multiple files.");
- g_free(save_file);
- return;
- }
- } else {
- capture_opts.has_autostop_filesize =
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_filesize_cb));
- if (capture_opts.has_autostop_filesize) {
- tmp = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_filesize_sb));
- tmp = size_unit_option_menu_convert_value(stop_filesize_om, tmp);
- if(tmp != 0) {
- capture_opts.autostop_filesize = tmp;
- } else {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- PRIMARY_TEXT_START "Stop Capture: Requested filesize too large!\n\n" PRIMARY_TEXT_END
- "The setting \"... after x byte(s)\" can't be greater than %u bytes (2GB).", G_MAXINT);
- return;
- }
- }
- }
-
- capture_opts.has_file_duration =
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_duration_cb));
- if (capture_opts.has_file_duration) {
- capture_opts.file_duration =
- gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(file_duration_sb));
- capture_opts.file_duration =
- time_unit_option_menu_get_value(file_duration_om, capture_opts.file_duration);
- }
-
- capture_opts.has_autostop_files =
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_files_cb));
- if (capture_opts.has_autostop_files)
- capture_opts.autostop_files =
- gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_files_sb));
-
- window_destroy(GTK_WIDGET(parent_w));
-
- do_capture(save_file);
- if (save_file != NULL)
- g_free(save_file);
-}
-
-static void
-capture_prep_destroy_cb(GtkWidget *win, gpointer user_data _U_)
-{
- GtkWidget *fs;
-
- /* Is there a file selection dialog associated with this
- Capture Options dialog? */
- fs = OBJECT_GET_DATA(win, E_FILE_SEL_DIALOG_PTR_KEY);
-
- if (fs != NULL) {
- /* Yes. Destroy it. */
- window_destroy(fs);
- }
-
- /* Note that we no longer have a "Capture Options" dialog box. */
- cap_open_w = NULL;
-}
-
-static void
-capture_prep_interface_changed_cb(GtkWidget *entry, gpointer argp)
-{
- GtkWidget *linktype_om = argp;
-
- set_link_type_list(linktype_om, entry);
-}
-
-/*
- * Adjust the sensitivity of various widgets as per the current setting
- * of other widgets.
- */
-static void
-capture_prep_adjust_sensitivity(GtkWidget *tb _U_, gpointer parent_w)
-{
- GtkWidget *if_cb,
- *snap_cb, *snap_sb,
- *multi_files_on_cb, *ringbuffer_nbf_cb, *ringbuffer_nbf_sb, *ringbuffer_nbf_lb,
- *ring_filesize_cb, *ring_filesize_sb, *ring_filesize_om,
- *file_duration_cb, *file_duration_sb, *file_duration_om,
- *sync_cb, *auto_scroll_cb, *hide_info_cb,
- *stop_packets_cb, *stop_packets_sb, *stop_packets_lb,
- *stop_filesize_cb, *stop_filesize_sb, *stop_filesize_om,
- *stop_duration_cb, *stop_duration_sb, *stop_duration_om,
- *stop_files_cb, *stop_files_sb, *stop_files_lb;
-
-
- if_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_IFACE_KEY);
- snap_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_SNAP_CB_KEY);
- snap_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_SNAP_SB_KEY);
- multi_files_on_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_MULTI_FILES_ON_CB_KEY);
- ringbuffer_nbf_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_NBF_CB_KEY);
- ringbuffer_nbf_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_NBF_SB_KEY);
- ringbuffer_nbf_lb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_NBF_LB_KEY);
- ring_filesize_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_FILESIZE_CB_KEY);
- ring_filesize_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_FILESIZE_SB_KEY);
- ring_filesize_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_FILESIZE_OM_KEY);
- file_duration_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILE_DURATION_CB_KEY);
- file_duration_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILE_DURATION_SB_KEY);
- file_duration_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILE_DURATION_OM_KEY);
- sync_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_SYNC_KEY);
- auto_scroll_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_AUTO_SCROLL_KEY);
- hide_info_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_HIDE_INFO_KEY);
- stop_packets_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_PACKETS_CB_KEY);
- stop_packets_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_PACKETS_SB_KEY);
- stop_packets_lb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_PACKETS_LB_KEY);
- stop_filesize_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILESIZE_CB_KEY);
- stop_filesize_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILESIZE_SB_KEY);
- stop_filesize_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILESIZE_OM_KEY);
- stop_duration_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_DURATION_CB_KEY);
- stop_duration_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_DURATION_SB_KEY);
- stop_duration_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_DURATION_OM_KEY);
- stop_files_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILES_CB_KEY);
- stop_files_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILES_SB_KEY);
- stop_files_lb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILES_LB_KEY);
-
- /* The snapshot length spinbox is sensitive if the "Limit each packet
- to" checkbox is on. */
- gtk_widget_set_sensitive(GTK_WIDGET(snap_sb),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(snap_cb)));
-
-
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sync_cb))) {
- /* "Update list of packets in real time" captures enabled; we don't
- support ring buffer mode for those captures, so turn ring buffer
- mode off if it's on, and make its toggle button, and the spin
- button for the number of ring buffer files (and the spin button's
- label), insensitive. */
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(multi_files_on_cb), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(multi_files_on_cb), FALSE);
-
- /* Auto-scroll mode is meaningful only in "Update list of packets
- in real time" captures, so make its toggle button sensitive. */
- gtk_widget_set_sensitive(GTK_WIDGET(auto_scroll_cb), TRUE);
-
- gtk_widget_set_sensitive(GTK_WIDGET(hide_info_cb), TRUE);
- } else {
- /* "Update list of packets in real time" captures disabled; that
- means ring buffer mode is OK, so make its toggle button
- sensitive. */
- gtk_widget_set_sensitive(GTK_WIDGET(multi_files_on_cb), TRUE);
-
- /* Auto-scroll mode is meaningful only in "Update list of packets
- in real time" captures, so make its toggle button insensitive. */
- gtk_widget_set_sensitive(GTK_WIDGET(auto_scroll_cb), FALSE);
-
- gtk_widget_set_sensitive(GTK_WIDGET(hide_info_cb), FALSE);
- }
-
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(multi_files_on_cb))) {
- /* Ring buffer mode enabled. */
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ring_filesize_cb), TRUE);
-
- gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_cb), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_sb),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb)));
- gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_lb),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb)));
-
- /* The ring filesize spinbox is sensitive if the "Next capture file
- after N kilobytes" checkbox is on. */
- gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_cb), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_sb),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb)));
- gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_om),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb)));
-
- /* The ring duration spinbox is sensitive if the "Next capture file
- after N seconds" checkbox is on. */
- gtk_widget_set_sensitive(GTK_WIDGET(file_duration_cb), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(file_duration_sb),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_duration_cb)));
- gtk_widget_set_sensitive(GTK_WIDGET(file_duration_om),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_duration_cb)));
-
- gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_cb), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_sb), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_om), FALSE);
-
- gtk_widget_set_sensitive(GTK_WIDGET(stop_files_cb), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(stop_files_sb),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_files_cb)));
- gtk_widget_set_sensitive(GTK_WIDGET(stop_files_lb),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_files_cb)));
- } else {
- /* Ring buffer mode disabled. */
- gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_cb), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_sb), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_lb), FALSE);
-
- gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_cb), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_sb),FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_om),FALSE);
-
- gtk_widget_set_sensitive(GTK_WIDGET(file_duration_cb), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(file_duration_sb),FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(file_duration_om),FALSE);
-
- /* The maximum file size spinbox is sensitive if the "Stop capture
- after N kilobytes" checkbox is on. */
- gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_cb), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_sb),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_filesize_cb)));
- gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_om),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_filesize_cb)));
-
- gtk_widget_set_sensitive(GTK_WIDGET(stop_files_cb), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(stop_files_sb), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(stop_files_lb), FALSE);
- }
-
- /* The maximum packet count spinbox is sensitive if the "Stop capture
- after N packets" checkbox is on. */
- gtk_widget_set_sensitive(GTK_WIDGET(stop_packets_sb),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_packets_cb)));
- gtk_widget_set_sensitive(GTK_WIDGET(stop_packets_lb),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_packets_cb)));
-
- /* The capture duration spinbox is sensitive if the "Stop capture
- after N seconds" checkbox is on. */
- gtk_widget_set_sensitive(GTK_WIDGET(stop_duration_sb),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_duration_cb)));
- gtk_widget_set_sensitive(GTK_WIDGET(stop_duration_om),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_duration_cb)));
-}
-
-#endif /* HAVE_LIBPCAP */
+/* capture_dlg.c + * Routines for packet capture windows + * + * $Id$ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#ifdef HAVE_LIBPCAP + +#include <pcap.h> +#include <string.h> +#include <gtk/gtk.h> + +#include <epan/packet.h> +#include "capture.h" +#include "globals.h" +#include <epan/resolv.h> +#include "main.h" +#include "ui_util.h" +#include "capture_dlg.h" +#include "filter_prefs.h" +#include "simple_dialog.h" +#include "dlg_utils.h" +#include "pcap-util.h" +#include "capture_combo_utils.h" +#include "prefs.h" +#include "ringbuffer.h" +#include <epan/filesystem.h> +#include "compat_macros.h" +#include "file_dlg.h" +#include "help_dlg.h" +#include "gtkglobals.h" + +#ifdef _WIN32 +#include "capture-wpcap.h" +#endif + +/* Capture callback data keys */ +#define E_CAP_IFACE_KEY "cap_iface" +#define E_CAP_IFACE_IP_KEY "cap_iface_ip" +#define E_CAP_SNAP_CB_KEY "cap_snap_cb" +#define E_CAP_LT_OM_KEY "cap_lt_om" +#define E_CAP_LT_OM_LABEL_KEY "cap_lt_om_label" +#ifdef _WIN32 +#define E_CAP_BUFFER_SIZE_SB_KEY "cap_buffer_size_sb" +#endif +#define E_CAP_SNAP_SB_KEY "cap_snap_sb" +#define E_CAP_PROMISC_KEY "cap_promisc" +#define E_CAP_FILT_KEY "cap_filter_te" +#define E_CAP_FILE_TE_KEY "cap_file_te" +#define E_CAP_MULTI_FILES_ON_CB_KEY "cap_multi_files_on_cb" +#define E_CAP_RING_FILESIZE_CB_KEY "cap_ring_filesize_cb" +#define E_CAP_RING_FILESIZE_SB_KEY "cap_ring_filesize_sb" +#define E_CAP_RING_FILESIZE_OM_KEY "cap_ring_filesize_om" +#define E_CAP_FILE_DURATION_CB_KEY "cap_file_duration_cb" +#define E_CAP_FILE_DURATION_SB_KEY "cap_file_duration_sb" +#define E_CAP_FILE_DURATION_OM_KEY "cap_file_duration_om" +#define E_CAP_RING_NBF_CB_KEY "cap_ring_nbf_cb" +#define E_CAP_RING_NBF_SB_KEY "cap_ring_nbf_sb" +#define E_CAP_RING_NBF_LB_KEY "cap_ring_nbf_lb" +#define E_CAP_STOP_FILES_CB_KEY "cap_stop_files_cb" +#define E_CAP_STOP_FILES_SB_KEY "cap_stop_files_sb" +#define E_CAP_STOP_FILES_LB_KEY "cap_stop_files_lb" +#define E_CAP_SYNC_KEY "cap_sync" +#define E_CAP_AUTO_SCROLL_KEY "cap_auto_scroll" +#define E_CAP_HIDE_INFO_KEY "cap_hide_info" +#define E_CAP_STOP_PACKETS_CB_KEY "cap_stop_packets_cb" +#define E_CAP_STOP_PACKETS_SB_KEY "cap_stop_packets_sb" +#define E_CAP_STOP_PACKETS_LB_KEY "cap_stop_packets_lb" +#define E_CAP_STOP_FILESIZE_CB_KEY "cap_stop_filesize_cb" +#define E_CAP_STOP_FILESIZE_SB_KEY "cap_stop_filesize_sb" +#define E_CAP_STOP_FILESIZE_OM_KEY "cap_stop_filesize_om" +#define E_CAP_STOP_DURATION_CB_KEY "cap_stop_duration_cb" +#define E_CAP_STOP_DURATION_SB_KEY "cap_stop_duration_sb" +#define E_CAP_STOP_DURATION_OM_KEY "cap_stop_duration_om" +#define E_CAP_M_RESOLVE_KEY "cap_m_resolve" +#define E_CAP_N_RESOLVE_KEY "cap_n_resolve" +#define E_CAP_T_RESOLVE_KEY "cap_t_resolve" + +#define E_CAP_OM_LT_VALUE_KEY "cap_om_lt_value" + +static void +capture_prep_file_cb(GtkWidget *file_bt, GtkWidget *file_te); + +static void +select_link_type_cb(GtkWidget *w, gpointer data); + +static void +capture_prep_adjust_sensitivity(GtkWidget *tb, gpointer parent_w); + +static void +capture_prep_ok_cb(GtkWidget *ok_bt, gpointer parent_w); + +static void +capture_prep_destroy_cb(GtkWidget *win, gpointer user_data); + +static void +capture_prep_interface_changed_cb(GtkWidget *entry, gpointer parent_w); + +void +capture_stop_cb(GtkWidget *w _U_, gpointer d _U_) +{ + capture_stop(); +} + +/* + * Given text that contains an interface name possibly prefixed by an + * interface description, extract the interface name. + */ +static char * +get_if_name(char *if_text) +{ + char *if_name; + +#ifdef WIN32 + /* + * We cannot assume that the interface name doesn't contain a space; + * some names on Windows OT do. + * + * We also can't assume it begins with "\Device\", either, as, on + * Windows OT, WinPcap doesn't put "\Device\" in front of the name. + * + * As I remember, we can't assume that the interface description + * doesn't contain a colon, either; I think some do. + * + * We can probably assume that the interface *name* doesn't contain + * a colon, however; if any interface name does contain a colon on + * Windows, it'll be time to just get rid of the damn interface + * descriptions in the drop-down list, have just the names in the + * drop-down list, and have a "Browse..." button to browse for interfaces, + * with names, descriptions, IP addresses, blah blah blah available when + * possible. + * + * So we search backwards for a colon. If we don't find it, just + * return the entire string; otherwise, skip the colon and any blanks + * after it, and return that string. + */ + if_name = if_text + strlen(if_text); + for (;;) { + if (if_name == if_text) { + /* We're at the beginning of the string; return it. */ + break; + } + if_name--; + if (*if_name == ':') { + /* + * We've found a colon. + * Unfortunately, a colon is used in the string "rpcap://", + * which is used in case of a remote capture. + * So we'll check to make sure the colon isn't followed by "//"; + * it'll be followed by a blank if it separates the description + * and the interface name. (We don't wire in "rpcap", in case we + * support other protocols in the same syntax.) + */ + if (strncmp(if_name, "://", 3) != 0) { + /* + * OK, we've found a colon not followed by "//". Skip blanks + * following it. + */ + if_name++; + while (*if_name == ' ') + if_name++; + break; + } + } + /* Keep looking for a colon not followed by "//". */ + } +#else + /* + * There's a space between the interface description and name, and + * the interface name shouldn't have a space in it (it doesn't, on + * UNIX systems); look backwards in the string for a space. + * + * (An interface name might, however, contain a colon in it, which + * is why we don't use the colon search on UNIX.) + */ + if_name = strrchr(if_text, ' '); + if (if_name == NULL) { + if_name = if_text; + } else { + if_name++; + } +#endif + return if_name; +} + +/* + * Keep a static pointer to the current "Capture Options" window, if + * any, so that if somebody tries to do "Capture:Start" while there's + * already a "Capture Options" window up, we just pop up the existing + * one, rather than creating a new one. + */ +static GtkWidget *cap_open_w; + + +/* From tcptraceroute, convert a numeric IP address to a string */ +/* XXX - this functionality is already somewhere in our code */ +#define IPTOSBUFFERS 12 +char *iptos(u_long in) +{ + static char output[IPTOSBUFFERS][3*4+3+1]; + static short which; + u_char *p; + + p = (u_char *)∈ + which = (which + 1 == IPTOSBUFFERS ? 0 : which + 1); + sprintf(output[which], "%d.%d.%d.%d", p[0], p[1], p[2], p[3]); + return output[which]; +} + + +static void +set_link_type_list(GtkWidget *linktype_om, GtkWidget *entry) +{ + gchar *entry_text; + gchar *if_text; + gchar *if_name; + GList *if_list; + GList *if_entry; + if_info_t *if_info; + GList *lt_list; + int err; + char err_buf[PCAP_ERRBUF_SIZE]; + GtkWidget *lt_menu, *lt_menu_item; + GList *lt_entry; + data_link_info_t *data_link_info; + gchar *linktype_menu_label; + guint num_supported_link_types; + GtkWidget *linktype_lb = OBJECT_GET_DATA(linktype_om, E_CAP_LT_OM_LABEL_KEY); + GtkWidget *if_ip_lb; + GString *ip_str = g_string_new("IP address: "); + int ips = 0; + GSList *curr_ip; + + lt_menu = gtk_menu_new(); + entry_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry))); + if_text = g_strstrip(entry_text); + if_name = get_if_name(if_text); + + /* + * If the interface name is in the list of known interfaces, get + * its list of link-layer types and set the option menu to display it. + * + * If it's not, don't bother - the user might be in the middle of + * editing the list, or it might be a remote device in which case + * getting the list could take an arbitrarily-long period of time. + * The list currently won't contain any remote devices (as + * "pcap_findalldevs()" doesn't know about remote devices, and neither + * does the code we use if "pcap_findalldevs()" isn't available), but + * should contain all the local devices on which you can capture. + */ + lt_list = NULL; + if (*if_name != '\0') { + /* + * Try to get the list of known interfaces. + */ + if_list = get_interface_list(&err, err_buf); + if (if_list != NULL) { + /* + * We have the list - check it. + */ + for (if_entry = if_list; if_entry != NULL; + if_entry = g_list_next(if_entry)) { + if_info = if_entry->data; + if (strcmp(if_info->name, if_name) == 0) { + /* + * It's in the list. + * Get the list of link-layer types for it. + */ + lt_list = get_pcap_linktype_list(if_name, err_buf); + + /* create string of list of IP addresses of this interface */ + for( ; curr_ip = g_slist_nth(if_info->ip_addr, ips); ips++) { + if (ips != 0) { + g_string_append(ip_str, ", "); + } + + g_string_append(ip_str, iptos(*((guint32 *)curr_ip->data))); + } + + if(if_info->loopback) { + g_string_append(ip_str, " (loopback)"); + } + } + } + free_interface_list(if_list); + } + } + g_free(entry_text); + num_supported_link_types = 0; + for (lt_entry = lt_list; lt_entry != NULL; lt_entry = g_list_next(lt_entry)) { + data_link_info = lt_entry->data; + if (data_link_info->description != NULL) { + lt_menu_item = gtk_menu_item_new_with_label(data_link_info->description); + OBJECT_SET_DATA(lt_menu_item, E_CAP_LT_OM_KEY, linktype_om); + SIGNAL_CONNECT(lt_menu_item, "activate", select_link_type_cb, + GINT_TO_POINTER(data_link_info->dlt)); + num_supported_link_types++; + } else { + /* Not supported - tell them about it but don't let them select it. */ + linktype_menu_label = g_strdup_printf("%s (not supported)", + data_link_info->name); + lt_menu_item = gtk_menu_item_new_with_label(linktype_menu_label); + g_free(linktype_menu_label); + gtk_widget_set_sensitive(lt_menu_item, FALSE); + } + gtk_menu_append(GTK_MENU(lt_menu), lt_menu_item); + } + if (lt_list != NULL) + free_pcap_linktype_list(lt_list); + gtk_option_menu_set_menu(GTK_OPTION_MENU(linktype_om), lt_menu); + gtk_widget_set_sensitive(linktype_lb, num_supported_link_types >= 2); + gtk_widget_set_sensitive(linktype_om, num_supported_link_types >= 2); + + if_ip_lb = OBJECT_GET_DATA(linktype_om, E_CAP_IFACE_KEY); + if(ips == 0) { + g_string_append(ip_str, "unknown"); + } + gtk_label_set_text(GTK_LABEL(if_ip_lb), ip_str->str); + g_string_free(ip_str, TRUE); +} + + +#define TIME_UNIT_SECOND 0 +#define TIME_UNIT_MINUTE 1 +#define TIME_UNIT_HOUR 2 +#define TIME_UNIT_DAY 3 +#define MAX_TIME_UNITS 4 +static char *time_unit_name[MAX_TIME_UNITS] = { + "second(s)", + "minute(s)", + "hour(s)", + "day(s)", +}; + +static GtkWidget *time_unit_option_menu_new(guint32 value) { + GtkWidget *unit_om, *menu, *menu_item; + int i; + + unit_om=gtk_option_menu_new(); + menu=gtk_menu_new(); + for(i=0;i<MAX_TIME_UNITS;i++){ + menu_item=gtk_menu_item_new_with_label(time_unit_name[i]); + OBJECT_SET_DATA(menu_item, "time_unit", GINT_TO_POINTER(i)); + gtk_menu_append(GTK_MENU(menu), menu_item); + } + + /* the selected menu item can't be changed, once the option_menu + is created, so set the matching menu item now */ + /* days */ + if(value >= 60 * 60 * 24) { + gtk_menu_set_active(GTK_MENU(menu), TIME_UNIT_DAY); + } else { + /* hours */ + if(value >= 60 * 60) { + gtk_menu_set_active(GTK_MENU(menu), TIME_UNIT_HOUR); + } else { + /* minutes */ + if(value >= 60) { + gtk_menu_set_active(GTK_MENU(menu), TIME_UNIT_MINUTE); + } else { + /* seconds */ + gtk_menu_set_active(GTK_MENU(menu), TIME_UNIT_SECOND); + } + } + } + + gtk_option_menu_set_menu(GTK_OPTION_MENU(unit_om), menu); + + return unit_om; +} + +static guint32 time_unit_option_menu_convert_value( +guint32 value) +{ + /* days */ + if(value >= 60 * 60 * 24) { + return value / (60 * 60 * 24); + } + + /* hours */ + if(value >= 60 * 60) { + return value / (60 * 60); + } + + /* minutes */ + if(value >= 60) { + return value / 60; + } + + /* seconds */ + return value; +} + +static guint32 time_unit_option_menu_get_value( +GtkWidget *unit_om, +guint32 value) +{ + GtkWidget *menu, *menu_item; + int unit; + + menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(unit_om)); + menu_item = gtk_menu_get_active(GTK_MENU(menu)); + unit = GPOINTER_TO_INT(OBJECT_GET_DATA(menu_item, "time_unit")); + + + switch(unit) { + case(TIME_UNIT_SECOND): + return value; + break; + case(TIME_UNIT_MINUTE): + return value * 60; + break; + case(TIME_UNIT_HOUR): + return value * 60 * 60; + break; + case(TIME_UNIT_DAY): + return value * 60 * 60 * 24; + break; + default: + g_assert_not_reached(); + return 0; + } +} + + +#define SIZE_UNIT_BYTES 0 +#define SIZE_UNIT_KILOBYTES 1 +#define SIZE_UNIT_MEGABYTES 2 +#define SIZE_UNIT_GIGABYTES 3 +#define MAX_SIZE_UNITS 4 +static char *size_unit_name[MAX_SIZE_UNITS] = { + "byte(s)", + "kilobyte(s)", + "megabyte(s)", + "gigabyte(s)", +}; + +static GtkWidget *size_unit_option_menu_new(guint32 value) { + GtkWidget *unit_om, *menu, *menu_item; + int i; + + unit_om=gtk_option_menu_new(); + menu=gtk_menu_new(); + for(i=0;i<MAX_SIZE_UNITS;i++){ + menu_item=gtk_menu_item_new_with_label(size_unit_name[i]); + OBJECT_SET_DATA(menu_item, "size_unit", GINT_TO_POINTER(i)); + gtk_menu_append(GTK_MENU(menu), menu_item); + } + + /* the selected menu item can't be changed, once the option_menu + is created, so set the matching menu item now */ + /* gigabytes */ + if(value >= 1024 * 1024 * 1024) { + gtk_menu_set_active(GTK_MENU(menu), SIZE_UNIT_GIGABYTES); + } else { + /* megabytes */ + if(value >= 1024 * 1024) { + gtk_menu_set_active(GTK_MENU(menu), SIZE_UNIT_MEGABYTES); + } else { + /* kilobytes */ + if(value >= 1024) { + gtk_menu_set_active(GTK_MENU(menu), SIZE_UNIT_KILOBYTES); + } else { + /* bytes */ + gtk_menu_set_active(GTK_MENU(menu), SIZE_UNIT_BYTES); + } + } + } + + gtk_option_menu_set_menu(GTK_OPTION_MENU(unit_om), menu); + + return unit_om; +} + +static guint32 size_unit_option_menu_set_value( +guint32 value) +{ + /* gigabytes */ + if(value >= 1024 * 1024 * 1024) { + return value / (1024 * 1024 * 1024); + } + + /* megabytes */ + if(value >= 1024 * 1024) { + return value / (1024 * 1024); + } + + /* kilobytes */ + if(value >= 1024) { + return value / 1024; + } + + /* bytes */ + return value; +} + +static guint32 size_unit_option_menu_convert_value( +GtkWidget *unit_om, +guint32 value) +{ + GtkWidget *menu, *menu_item; + int unit; + + menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(unit_om)); + menu_item = gtk_menu_get_active(GTK_MENU(menu)); + unit = GPOINTER_TO_INT(OBJECT_GET_DATA(menu_item, "size_unit")); + + + switch(unit) { + case(SIZE_UNIT_BYTES): + return value; + break; + case(SIZE_UNIT_KILOBYTES): + if(value > G_MAXINT / 1024) { + return 0; + } else { + return value * 1024; + } + break; + case(SIZE_UNIT_MEGABYTES): + if(value > G_MAXINT / (1024 * 1024)) { + return 0; + } else { + return value * 1024 * 1024; + } + break; + case(SIZE_UNIT_GIGABYTES): + if(value > G_MAXINT / (1024 * 1024 * 1024)) { + return 0; + } else { + return value * 1024 * 1024 * 1024; + } + break; + default: + g_assert_not_reached(); + return 0; + } +} + + +void +capture_prep(void) +{ + GtkWidget *main_vb, + *main_hb, *left_vb, *right_vb, + + *capture_fr, *capture_vb, + *if_hb, *if_cb, *if_lb, + *if_ip_hb, *if_ip_lb, + *linktype_hb, *linktype_lb, *linktype_om, + *snap_hb, *snap_cb, *snap_sb, *snap_lb, + *promisc_cb, + *filter_hb, *filter_bt, *filter_te, + + *file_fr, *file_vb, + *file_hb, *file_bt, *file_lb, *file_te, + *multi_tb, *multi_files_on_cb, + *ring_filesize_cb, *ring_filesize_sb, *ring_filesize_om, + *file_duration_cb, *file_duration_sb, *file_duration_om, + *ringbuffer_nbf_cb, *ringbuffer_nbf_sb, *ringbuffer_nbf_lb, + *stop_files_cb, *stop_files_sb, *stop_files_lb, + + *limit_fr, *limit_vb, *limit_tb, + *stop_packets_cb, *stop_packets_sb, *stop_packets_lb, + *stop_filesize_cb, *stop_filesize_sb, *stop_filesize_om, + *stop_duration_cb, *stop_duration_sb, *stop_duration_om, + + *display_fr, *display_vb, + *sync_cb, *auto_scroll_cb, *hide_info_cb, + + *resolv_fr, *resolv_vb, + *m_resolv_cb, *n_resolv_cb, *t_resolv_cb, + *bbox, *ok_bt, *cancel_bt, + *help_bt; +#if GTK_MAJOR_VERSION < 2 + GtkAccelGroup *accel_group; +#endif + GtkTooltips *tooltips; + GtkAdjustment *snap_adj, *ringbuffer_nbf_adj, + *stop_packets_adj, *stop_filesize_adj, *stop_duration_adj, *stop_files_adj, *ring_filesize_adj, *file_duration_adj; + GList *if_list, *combo_list; + int err; + int row; + char err_str[PCAP_ERRBUF_SIZE]; + gchar *cant_get_if_list_errstr; +#ifdef _WIN32 + GtkAdjustment *buffer_size_adj; + GtkWidget *buffer_size_lb, *buffer_size_sb; +#endif + guint32 value; + + if (cap_open_w != NULL) { + /* There's already a "Capture Options" dialog box; reactivate it. */ + reactivate_window(cap_open_w); + return; + } + +#ifdef _WIN32 + /* Is WPcap loaded? */ + if (!has_wpcap) { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + "Unable to load WinPcap (wpcap.dll); Ethereal will not be able\n" + "to capture packets.\n\n" + "In order to capture packets, WinPcap must be installed; see\n" + "\n" + " http://winpcap.polito.it/\n" + "\n" + "or the mirror at\n" + "\n" + " http://winpcap.mirror.ethereal.com/\n" + "\n" + "or the mirror at\n" + "\n" + " http://www.mirrors.wiretapped.net/security/packet-capture/winpcap/\n" + "\n" + "for a downloadable version of WinPcap and for instructions\n" + "on how to install WinPcap."); + return; + } +#endif + + if_list = get_interface_list(&err, err_str); + if (if_list == NULL && err == CANT_GET_INTERFACE_LIST) { + cant_get_if_list_errstr = cant_get_if_list_error_message(err_str); + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", + cant_get_if_list_errstr); + g_free(cant_get_if_list_errstr); + } + + cap_open_w = dlg_window_new("Ethereal: Capture Options"); + + tooltips = gtk_tooltips_new(); + +#if GTK_MAJOR_VERSION < 2 + /* Accelerator group for the accelerators (or, as they're called in + Windows and, I think, in Motif, "mnemonics"; Alt+<key> is a mnemonic, + Ctrl+<key> is an accelerator). */ + accel_group = gtk_accel_group_new(); + gtk_window_add_accel_group(GTK_WINDOW(cap_open_w), accel_group); +#endif + + main_vb = gtk_vbox_new(FALSE, 0); + gtk_container_border_width(GTK_CONTAINER(main_vb), 5); + gtk_container_add(GTK_CONTAINER(cap_open_w), main_vb); + + /* Capture-related options frame */ + capture_fr = gtk_frame_new("Capture"); + gtk_container_add(GTK_CONTAINER(main_vb), capture_fr); + + capture_vb = gtk_vbox_new(FALSE, 3); + gtk_container_border_width(GTK_CONTAINER(capture_vb), 5); + gtk_container_add(GTK_CONTAINER(capture_fr), capture_vb); + + /* Interface row */ + if_hb = gtk_hbox_new(FALSE, 3); + gtk_container_add(GTK_CONTAINER(capture_vb), if_hb); + + if_lb = gtk_label_new("Interface:"); + gtk_box_pack_start(GTK_BOX(if_hb), if_lb, FALSE, FALSE, 6); + + if_cb = gtk_combo_new(); + combo_list = build_capture_combo_list(if_list, TRUE); + if (combo_list != NULL) + gtk_combo_set_popdown_strings(GTK_COMBO(if_cb), combo_list); + if (cfile.iface == NULL && prefs.capture_device != NULL) { + /* No interface was specified on the command line or in a previous + capture, but there is one specified in the preferences file; + make the one from the preferences file the default */ + cfile.iface = g_strdup(prefs.capture_device); + } + if (cfile.iface != NULL) + gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry), cfile.iface); + else if (combo_list != NULL) { + gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry), + (char *)combo_list->data); + } + free_capture_combo_list(combo_list); + free_interface_list(if_list); + gtk_tooltips_set_tip(tooltips, GTK_COMBO(if_cb)->entry, + "Choose which interface (network card) will be used to capture packets from. " + "Be sure to select the correct one, as it's a common mistake to select the wrong interface.", NULL); + gtk_box_pack_start(GTK_BOX(if_hb), if_cb, TRUE, TRUE, 6); + + if_ip_hb = gtk_hbox_new(FALSE, 3); + gtk_box_pack_start(GTK_BOX(capture_vb), if_ip_hb, FALSE, FALSE, 0); + + if_ip_lb = gtk_label_new(""); + gtk_box_pack_start(GTK_BOX(if_ip_hb), if_ip_lb, FALSE, FALSE, 6); + + /* Linktype row */ + linktype_hb = gtk_hbox_new(FALSE, 3); + gtk_box_pack_start(GTK_BOX(capture_vb), linktype_hb, FALSE, FALSE, 0); + + linktype_lb = gtk_label_new("Link-layer header type:"); + gtk_box_pack_start(GTK_BOX(linktype_hb), linktype_lb, FALSE, FALSE, 6); + + linktype_om = gtk_option_menu_new(); + OBJECT_SET_DATA(linktype_om, E_CAP_LT_OM_LABEL_KEY, linktype_lb); + /* Default to "use the default" */ + OBJECT_SET_DATA(linktype_om, E_CAP_OM_LT_VALUE_KEY, GINT_TO_POINTER(-1)); + OBJECT_SET_DATA(linktype_om, E_CAP_IFACE_KEY, if_ip_lb); + set_link_type_list(linktype_om, GTK_COMBO(if_cb)->entry); + /* + * XXX - in some cases, this is "multiple link-layer header types", e.g. + * some 802.11 interfaces on FreeBSD 5.2 and later, where you can request + * fake Ethernet, 802.11, or 802.11-plus-radio-information headers. + * + * In other cases, it's "multiple link-layer types", e.g., with recent + * versions of libpcap, a DAG card on an "HDLC" WAN, where you can + * request Cisco HDLC or PPP depending on what type of traffic is going + * over the WAN, or an Ethernet interface, where you can request Ethernet + * or DOCSIS, the latter being for some Cisco cable modem equipment that + * can be configured to send raw DOCSIS frames over an Ethernet inside + * Ethernet low-level framing, for traffic capture purposes. + * + * We leave it as "multiple link-layer types" for now. + */ + gtk_tooltips_set_tip(tooltips, linktype_om, + "The selected interface supports multiple link-layer types; select the desired one.", NULL); + gtk_box_pack_start (GTK_BOX(linktype_hb), linktype_om, FALSE, FALSE, 0); + SIGNAL_CONNECT(GTK_ENTRY(GTK_COMBO(if_cb)->entry), "changed", + capture_prep_interface_changed_cb, linktype_om); + +#ifdef _WIN32 + buffer_size_lb = gtk_label_new("Buffer size:"); + gtk_box_pack_start (GTK_BOX(linktype_hb), buffer_size_lb, FALSE, FALSE, 0); + + buffer_size_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat) capture_opts.buffer_size, + 1, 65535, 1.0, 10.0, 0.0); + buffer_size_sb = gtk_spin_button_new (buffer_size_adj, 0, 0); + gtk_spin_button_set_value(GTK_SPIN_BUTTON (buffer_size_sb), (gfloat) capture_opts.buffer_size); + gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (buffer_size_sb), TRUE); + WIDGET_SET_SIZE(buffer_size_sb, 80, -1); + gtk_tooltips_set_tip(tooltips, buffer_size_sb, + "The memory buffer size used while capturing. If you notice packet drops, you can try to increase this size.", NULL); + gtk_box_pack_start (GTK_BOX(linktype_hb), buffer_size_sb, FALSE, FALSE, 0); + + buffer_size_lb = gtk_label_new("megabyte(s)"); + gtk_box_pack_start (GTK_BOX(linktype_hb), buffer_size_lb, FALSE, FALSE, 0); +#endif + + /* Promiscuous mode row */ + promisc_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC( + "Capture packets in _promiscuous mode", accel_group); + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(promisc_cb), + capture_opts.promisc_mode); + gtk_tooltips_set_tip(tooltips, promisc_cb, + "Usually a network card will only capture the traffic sent to its own network address. " + "If you want to capture all traffic that the network card can \"see\", mark this option. " + "See the FAQ for some more details of capturing packets from a switched network.", NULL); + gtk_container_add(GTK_CONTAINER(capture_vb), promisc_cb); + + /* Capture length row */ + snap_hb = gtk_hbox_new(FALSE, 3); + gtk_container_add(GTK_CONTAINER(capture_vb), snap_hb); + + snap_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC("_Limit each packet to", accel_group); + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(snap_cb), + capture_opts.has_snaplen); + SIGNAL_CONNECT(snap_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w); + gtk_tooltips_set_tip(tooltips, snap_cb, + "Limit the maximum number of bytes to be captured from each packet. This size includes the " + "link-layer header and all subsequent headers. ", NULL); + gtk_box_pack_start(GTK_BOX(snap_hb), snap_cb, FALSE, FALSE, 0); + + snap_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat) capture_opts.snaplen, + MIN_PACKET_SIZE, WTAP_MAX_PACKET_SIZE, 1.0, 10.0, 0.0); + snap_sb = gtk_spin_button_new (snap_adj, 0, 0); + gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (snap_sb), TRUE); + WIDGET_SET_SIZE(snap_sb, 80, -1); + gtk_box_pack_start (GTK_BOX(snap_hb), snap_sb, FALSE, FALSE, 0); + + snap_lb = gtk_label_new("bytes"); + gtk_misc_set_alignment(GTK_MISC(snap_lb), 0, 0.5); + gtk_box_pack_start(GTK_BOX(snap_hb), snap_lb, FALSE, FALSE, 0); + + /* Filter row */ + filter_hb = gtk_hbox_new(FALSE, 3); + gtk_box_pack_start(GTK_BOX(capture_vb), filter_hb, FALSE, FALSE, 0); + + filter_bt = BUTTON_NEW_FROM_STOCK(ETHEREAL_STOCK_CAPTURE_FILTER_ENTRY); + SIGNAL_CONNECT(filter_bt, "clicked", capture_filter_construct_cb, NULL); + SIGNAL_CONNECT(filter_bt, "destroy", filter_button_destroy_cb, NULL); + gtk_tooltips_set_tip(tooltips, filter_bt, + "Select a capture filter to reduce the amount of packets to be captured. " + "See \"Capture Filters\" in the online help for further information how to use it.", + NULL); + gtk_box_pack_start(GTK_BOX(filter_hb), filter_bt, FALSE, FALSE, 3); + + filter_te = gtk_entry_new(); + if (cfile.cfilter) gtk_entry_set_text(GTK_ENTRY(filter_te), cfile.cfilter); + OBJECT_SET_DATA(filter_bt, E_FILT_TE_PTR_KEY, filter_te); + gtk_tooltips_set_tip(tooltips, filter_te, + "Enter a capture filter to reduce the amount of packets to be captured. " + "See \"Capture Filters\" in the online help for further information how to use it.", + NULL); + gtk_box_pack_start(GTK_BOX(filter_hb), filter_te, TRUE, TRUE, 3); + + main_hb = gtk_hbox_new(FALSE, 5); + gtk_container_border_width(GTK_CONTAINER(main_hb), 0); + gtk_container_add(GTK_CONTAINER(main_vb), main_hb); + + left_vb = gtk_vbox_new(FALSE, 0); + gtk_container_border_width(GTK_CONTAINER(left_vb), 0); + gtk_box_pack_start(GTK_BOX(main_hb), left_vb, TRUE, TRUE, 0); + + right_vb = gtk_vbox_new(FALSE, 0); + gtk_container_border_width(GTK_CONTAINER(right_vb), 0); + gtk_box_pack_start(GTK_BOX(main_hb), right_vb, FALSE, FALSE, 0); + + + /* Capture file-related options frame */ + file_fr = gtk_frame_new("Capture File(s)"); + gtk_container_add(GTK_CONTAINER(left_vb), file_fr); + + file_vb = gtk_vbox_new(FALSE, 3); + gtk_container_border_width(GTK_CONTAINER(file_vb), 5); + gtk_container_add(GTK_CONTAINER(file_fr), file_vb); + + /* File row */ + file_hb = gtk_hbox_new(FALSE, 3); + gtk_box_pack_start(GTK_BOX(file_vb), file_hb, FALSE, FALSE, 0); + + file_lb = gtk_label_new("File:"); + gtk_box_pack_start(GTK_BOX(file_hb), file_lb, FALSE, FALSE, 3); + + file_te = gtk_entry_new(); + gtk_tooltips_set_tip(tooltips, file_te, + "Enter the file name to which captured data will be written. " + "If you don't enter something here, a temporary file will be used.", + NULL); + gtk_box_pack_start(GTK_BOX(file_hb), file_te, TRUE, TRUE, 3); + + file_bt = BUTTON_NEW_FROM_STOCK(ETHEREAL_STOCK_BROWSE); + gtk_tooltips_set_tip(tooltips, file_bt, + "Select a file to which captured data will be written, " + "instead of entering the file name directly. ", + NULL); + gtk_box_pack_start(GTK_BOX(file_hb), file_bt, FALSE, FALSE, 3); + + SIGNAL_CONNECT(file_bt, "clicked", capture_prep_file_cb, file_te); + + /* multiple files table */ + multi_tb = gtk_table_new(5, 3, FALSE); + gtk_table_set_row_spacings(GTK_TABLE(multi_tb), 1); + gtk_table_set_col_spacings(GTK_TABLE(multi_tb), 3); + gtk_box_pack_start(GTK_BOX(file_vb), multi_tb, FALSE, FALSE, 0); + row = 0; + + /* multiple files row */ + multi_files_on_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC("Use _multiple files", accel_group); + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(multi_files_on_cb), + capture_opts.multi_files_on); + SIGNAL_CONNECT(multi_files_on_cb, "toggled", capture_prep_adjust_sensitivity, + cap_open_w); + gtk_tooltips_set_tip(tooltips, multi_files_on_cb, + "Instead of using a single capture file, multiple files will be created. " + "The generated file names will contain an incrementing number and the start time of the capture.", NULL); + gtk_table_attach_defaults(GTK_TABLE(multi_tb), multi_files_on_cb, 0, 1, row, row+1); + row++; + + /* Ring buffer filesize row */ + ring_filesize_cb = gtk_check_button_new_with_label("Next file every"); + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(ring_filesize_cb), + capture_opts.has_autostop_filesize); + SIGNAL_CONNECT(ring_filesize_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w); + gtk_tooltips_set_tip(tooltips, ring_filesize_cb, + "If the selected file size is exceeded, capturing switches to the next file.", + NULL); + gtk_table_attach_defaults(GTK_TABLE(multi_tb), ring_filesize_cb, 0, 1, row, row+1); + + ring_filesize_adj = (GtkAdjustment *) gtk_adjustment_new(0.0, + 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0); + ring_filesize_sb = gtk_spin_button_new (ring_filesize_adj, 0, 0); + gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (ring_filesize_sb), TRUE); + WIDGET_SET_SIZE(ring_filesize_sb, 80, -1); + gtk_table_attach_defaults(GTK_TABLE(multi_tb), ring_filesize_sb, 1, 2, row, row+1); + + ring_filesize_om = size_unit_option_menu_new(capture_opts.autostop_filesize); + gtk_table_attach_defaults(GTK_TABLE(multi_tb), ring_filesize_om, 2, 3, row, row+1); + + value = size_unit_option_menu_set_value(capture_opts.autostop_filesize); + gtk_adjustment_set_value(ring_filesize_adj, (gfloat) value); + + row++; + + /* Ring buffer duration row */ + file_duration_cb = gtk_check_button_new_with_label("Next file every"); + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(file_duration_cb), + capture_opts.has_file_duration); + SIGNAL_CONNECT(file_duration_cb, "toggled", + capture_prep_adjust_sensitivity, cap_open_w); + gtk_tooltips_set_tip(tooltips, file_duration_cb, + "If the selected duration is exceeded, capturing switches to the next file.", + NULL); + gtk_table_attach_defaults(GTK_TABLE(multi_tb), file_duration_cb, 0, 1, row, row+1); + + file_duration_adj = (GtkAdjustment *)gtk_adjustment_new(0.0, + 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0); + file_duration_sb = gtk_spin_button_new (file_duration_adj, 0, 0); + gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (file_duration_sb), TRUE); + WIDGET_SET_SIZE(file_duration_sb, 80, -1); + gtk_table_attach_defaults(GTK_TABLE(multi_tb), file_duration_sb, 1, 2, row, row+1); + + file_duration_om = time_unit_option_menu_new(capture_opts.file_duration); + gtk_table_attach_defaults(GTK_TABLE(multi_tb), file_duration_om, 2, 3, row, row+1); + + value = time_unit_option_menu_convert_value(capture_opts.file_duration); + gtk_adjustment_set_value(file_duration_adj, (gfloat) value); + row++; + + /* Ring buffer files row */ + ringbuffer_nbf_cb = gtk_check_button_new_with_label("Ring buffer with"); + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb), + capture_opts.has_ring_num_files); + SIGNAL_CONNECT(ringbuffer_nbf_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w); + gtk_tooltips_set_tip(tooltips, ringbuffer_nbf_cb, + "After capturing has switched to the next file and the given number of files has exceeded, " + "the oldest file will be removed.", + NULL); + gtk_table_attach_defaults(GTK_TABLE(multi_tb), ringbuffer_nbf_cb, 0, 1, row, row+1); + + ringbuffer_nbf_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat) capture_opts.ring_num_files, + 2/*RINGBUFFER_MIN_NUM_FILES*/, RINGBUFFER_MAX_NUM_FILES, 1.0, 10.0, 0.0); + ringbuffer_nbf_sb = gtk_spin_button_new (ringbuffer_nbf_adj, 0, 0); + gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (ringbuffer_nbf_sb), TRUE); + WIDGET_SET_SIZE(ringbuffer_nbf_sb, 80, -1); + SIGNAL_CONNECT(ringbuffer_nbf_sb, "changed", capture_prep_adjust_sensitivity, cap_open_w); + gtk_table_attach_defaults(GTK_TABLE(multi_tb), ringbuffer_nbf_sb, 1, 2, row, row+1); + + ringbuffer_nbf_lb = gtk_label_new("files"); + gtk_misc_set_alignment(GTK_MISC(ringbuffer_nbf_lb), 0, 0.5); + gtk_table_attach_defaults(GTK_TABLE(multi_tb), ringbuffer_nbf_lb, 2, 3, row, row+1); + row++; + + /* Files row */ + stop_files_cb = gtk_check_button_new_with_label("Stop capture after"); + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(stop_files_cb), + capture_opts.has_autostop_files); + SIGNAL_CONNECT(stop_files_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w); + gtk_tooltips_set_tip(tooltips, stop_files_cb, + "Stop capturing after the given number of \"file switches\" have been done.", NULL); + gtk_table_attach_defaults(GTK_TABLE(multi_tb), stop_files_cb, 0, 1, row, row+1); + + stop_files_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat)capture_opts.autostop_files, + 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0); + stop_files_sb = gtk_spin_button_new (stop_files_adj, 0, 0); + gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_files_sb), TRUE); + WIDGET_SET_SIZE(stop_files_sb, 80, -1); + gtk_table_attach_defaults(GTK_TABLE(multi_tb), stop_files_sb, 1, 2, row, row+1); + + stop_files_lb = gtk_label_new("file(s)"); + gtk_misc_set_alignment(GTK_MISC(stop_files_lb), 0, 0.5); + gtk_table_attach_defaults(GTK_TABLE(multi_tb), stop_files_lb, 2, 3, row, row+1); + row++; + + /* Capture limits frame */ + limit_fr = gtk_frame_new("Stop Capture ..."); + gtk_container_add(GTK_CONTAINER(left_vb), limit_fr); + + limit_vb = gtk_vbox_new(FALSE, 3); + gtk_container_border_width(GTK_CONTAINER(limit_vb), 5); + gtk_container_add(GTK_CONTAINER(limit_fr), limit_vb); + + /* limits table */ + limit_tb = gtk_table_new(3, 3, FALSE); + gtk_table_set_row_spacings(GTK_TABLE(limit_tb), 1); + gtk_table_set_col_spacings(GTK_TABLE(limit_tb), 3); + gtk_box_pack_start(GTK_BOX(limit_vb), limit_tb, FALSE, FALSE, 0); + row = 0; + + /* Packet count row */ + stop_packets_cb = gtk_check_button_new_with_label("... after"); + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(stop_packets_cb), + capture_opts.has_autostop_packets); + SIGNAL_CONNECT(stop_packets_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w); + gtk_tooltips_set_tip(tooltips, stop_packets_cb, + "Stop capturing after the given number of packets have been captured.", NULL); + gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_packets_cb, 0, 1, row, row+1); + + stop_packets_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat)capture_opts.autostop_packets, + 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0); + stop_packets_sb = gtk_spin_button_new (stop_packets_adj, 0, 0); + gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_packets_sb), TRUE); + WIDGET_SET_SIZE(stop_packets_sb, 80, -1); + gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_packets_sb, 1, 2, row, row+1); + + stop_packets_lb = gtk_label_new("packet(s)"); + gtk_misc_set_alignment(GTK_MISC(stop_packets_lb), 0, 0.5); + gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_packets_lb, 2, 3, row, row+1); + row++; + + /* Filesize row */ + stop_filesize_cb = gtk_check_button_new_with_label("... after"); + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(stop_filesize_cb), + capture_opts.has_autostop_filesize); + SIGNAL_CONNECT(stop_filesize_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w); + gtk_tooltips_set_tip(tooltips, stop_filesize_cb, + "Stop capturing after the given amount of capture data has been captured.", NULL); + gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_filesize_cb, 0, 1, row, row+1); + + stop_filesize_adj = (GtkAdjustment *) gtk_adjustment_new(0.0, + 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0); + stop_filesize_sb = gtk_spin_button_new (stop_filesize_adj, 0, 0); + gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_filesize_sb), TRUE); + WIDGET_SET_SIZE(stop_filesize_sb, 80, -1); + gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_filesize_sb, 1, 2, row, row+1); + + stop_filesize_om = size_unit_option_menu_new(capture_opts.autostop_filesize); + gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_filesize_om, 2, 3, row, row+1); + + value = size_unit_option_menu_set_value(capture_opts.autostop_filesize); + gtk_adjustment_set_value(stop_filesize_adj, (gfloat) value); + + row++; + + /* Duration row */ + stop_duration_cb = gtk_check_button_new_with_label("... after"); + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(stop_duration_cb), + capture_opts.has_autostop_duration); + SIGNAL_CONNECT(stop_duration_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w); + gtk_tooltips_set_tip(tooltips, stop_duration_cb, + "Stop capturing after the given time is exceeded.", NULL); + gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_duration_cb, 0, 1, row, row+1); + + stop_duration_adj = (GtkAdjustment *) gtk_adjustment_new(0.0, + 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0); + stop_duration_sb = gtk_spin_button_new (stop_duration_adj, 0, 0); + gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_duration_sb), TRUE); + WIDGET_SET_SIZE(stop_duration_sb, 80, -1); + gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_duration_sb, 1, 2, row, row+1); + + stop_duration_om = time_unit_option_menu_new(capture_opts.autostop_duration); + gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_duration_om, 2, 3, row, row+1); + + value = time_unit_option_menu_convert_value(capture_opts.autostop_duration); + gtk_adjustment_set_value(stop_duration_adj, (gfloat) value); + row++; + + /* Display-related options frame */ + display_fr = gtk_frame_new("Display Options"); + gtk_container_add(GTK_CONTAINER(right_vb), display_fr); + + display_vb = gtk_vbox_new(FALSE, 0); + gtk_container_border_width(GTK_CONTAINER(display_vb), 5); + gtk_container_add(GTK_CONTAINER(display_fr), display_vb); + + /* "Update display in real time" row */ + sync_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC( + "_Update list of packets in real time", accel_group); + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(sync_cb), + capture_opts.sync_mode); + SIGNAL_CONNECT(sync_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w); + gtk_tooltips_set_tip(tooltips, sync_cb, + "Using this option will show the captured packets immediately on the main screen. " + "Please note: this will slow down capturing, so increased packet drops might appear.", NULL); + gtk_container_add(GTK_CONTAINER(display_vb), sync_cb); + + /* "Auto-scroll live update" row */ + auto_scroll_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC( + "_Automatic scrolling in live capture", accel_group); + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(auto_scroll_cb), auto_scroll_live); + gtk_tooltips_set_tip(tooltips, auto_scroll_cb, + "This will scroll the \"Packet List\" automatically to the latest captured packet, " + "when the \"Update List of packets in real time\" option is used.", NULL); + gtk_container_add(GTK_CONTAINER(display_vb), auto_scroll_cb); + + /* "Hide capture info" row */ + hide_info_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC( + "_Hide capture info dialog", accel_group); + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(hide_info_cb), !capture_opts.show_info); + gtk_tooltips_set_tip(tooltips, hide_info_cb, + "Hide the capture info dialog while capturing.", NULL); + gtk_container_add(GTK_CONTAINER(display_vb), hide_info_cb); + + /* Name Resolution frame */ + resolv_fr = gtk_frame_new("Name Resolution"); + gtk_container_add(GTK_CONTAINER(right_vb), resolv_fr); + + resolv_vb = gtk_vbox_new(FALSE, 0); + gtk_container_border_width(GTK_CONTAINER(resolv_vb), 5); + gtk_container_add(GTK_CONTAINER(resolv_fr), resolv_vb); + + m_resolv_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC( + "Enable _MAC name resolution", accel_group); + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(m_resolv_cb), + g_resolv_flags & RESOLV_MAC); + gtk_tooltips_set_tip(tooltips, m_resolv_cb, + "Perform MAC layer name resolution while capturing.", NULL); + gtk_container_add(GTK_CONTAINER(resolv_vb), m_resolv_cb); + + n_resolv_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC( + "Enable _network name resolution", accel_group); + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(n_resolv_cb), + g_resolv_flags & RESOLV_NETWORK); + gtk_tooltips_set_tip(tooltips, n_resolv_cb, + "Perform network layer name resolution while capturing.", NULL); + gtk_container_add(GTK_CONTAINER(resolv_vb), n_resolv_cb); + + t_resolv_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC( + "Enable _transport name resolution", accel_group); + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(t_resolv_cb), + g_resolv_flags & RESOLV_TRANSPORT); + gtk_tooltips_set_tip(tooltips, t_resolv_cb, + "Perform transport layer name resolution while capturing.", NULL); + gtk_container_add(GTK_CONTAINER(resolv_vb), t_resolv_cb); + + /* Button row: OK and cancel buttons */ + bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL); + gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 5); + + ok_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_OK); + SIGNAL_CONNECT(ok_bt, "clicked", capture_prep_ok_cb, cap_open_w); + gtk_tooltips_set_tip(tooltips, ok_bt, + "Start the capture process.", NULL); + + cancel_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CANCEL); + gtk_tooltips_set_tip(tooltips, cancel_bt, + "Cancel and exit dialog.", NULL); + window_set_cancel_button(cap_open_w, cancel_bt, window_cancel_button_cb); + + help_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_HELP); + gtk_tooltips_set_tip(tooltips, help_bt, + "Show help about capturing.", NULL); + SIGNAL_CONNECT(help_bt, "clicked", help_topic_cb, "Capturing"); + + gtk_widget_grab_default(ok_bt); + + /* Attach pointers to needed widgets to the capture prefs window/object */ + OBJECT_SET_DATA(cap_open_w, E_CAP_IFACE_KEY, if_cb); + OBJECT_SET_DATA(cap_open_w, E_CAP_SNAP_CB_KEY, snap_cb); + OBJECT_SET_DATA(cap_open_w, E_CAP_SNAP_SB_KEY, snap_sb); + OBJECT_SET_DATA(cap_open_w, E_CAP_LT_OM_KEY, linktype_om); +#ifdef _WIN32 + OBJECT_SET_DATA(cap_open_w, E_CAP_BUFFER_SIZE_SB_KEY, buffer_size_sb); +#endif + OBJECT_SET_DATA(cap_open_w, E_CAP_PROMISC_KEY, promisc_cb); + OBJECT_SET_DATA(cap_open_w, E_CAP_FILT_KEY, filter_te); + OBJECT_SET_DATA(cap_open_w, E_CAP_FILE_TE_KEY, file_te); + OBJECT_SET_DATA(cap_open_w, E_CAP_MULTI_FILES_ON_CB_KEY, multi_files_on_cb); + OBJECT_SET_DATA(cap_open_w, E_CAP_RING_NBF_CB_KEY, ringbuffer_nbf_cb); + OBJECT_SET_DATA(cap_open_w, E_CAP_RING_NBF_SB_KEY, ringbuffer_nbf_sb); + OBJECT_SET_DATA(cap_open_w, E_CAP_RING_NBF_LB_KEY, ringbuffer_nbf_lb); + OBJECT_SET_DATA(cap_open_w, E_CAP_RING_FILESIZE_CB_KEY, ring_filesize_cb); + OBJECT_SET_DATA(cap_open_w, E_CAP_RING_FILESIZE_SB_KEY, ring_filesize_sb); + OBJECT_SET_DATA(cap_open_w, E_CAP_RING_FILESIZE_OM_KEY, ring_filesize_om); + OBJECT_SET_DATA(cap_open_w, E_CAP_FILE_DURATION_CB_KEY, file_duration_cb); + OBJECT_SET_DATA(cap_open_w, E_CAP_FILE_DURATION_SB_KEY, file_duration_sb); + OBJECT_SET_DATA(cap_open_w, E_CAP_FILE_DURATION_OM_KEY, file_duration_om); + OBJECT_SET_DATA(cap_open_w, E_CAP_SYNC_KEY, sync_cb); + OBJECT_SET_DATA(cap_open_w, E_CAP_AUTO_SCROLL_KEY, auto_scroll_cb); + OBJECT_SET_DATA(cap_open_w, E_CAP_HIDE_INFO_KEY, hide_info_cb); + OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_PACKETS_CB_KEY, stop_packets_cb); + OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_PACKETS_SB_KEY, stop_packets_sb); + OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_PACKETS_LB_KEY, stop_packets_lb); + OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_FILESIZE_CB_KEY, stop_filesize_cb); + OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_FILESIZE_SB_KEY, stop_filesize_sb); + OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_FILESIZE_OM_KEY, stop_filesize_om); + OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_DURATION_CB_KEY, stop_duration_cb); + OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_DURATION_SB_KEY, stop_duration_sb); + OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_DURATION_OM_KEY, stop_duration_om); + OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_FILES_CB_KEY, stop_files_cb); + OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_FILES_SB_KEY, stop_files_sb); + OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_FILES_LB_KEY, stop_files_lb); + OBJECT_SET_DATA(cap_open_w, E_CAP_M_RESOLVE_KEY, m_resolv_cb); + OBJECT_SET_DATA(cap_open_w, E_CAP_N_RESOLVE_KEY, n_resolv_cb); + OBJECT_SET_DATA(cap_open_w, E_CAP_T_RESOLVE_KEY, t_resolv_cb); + + /* Set the sensitivity of various widgets as per the settings of other + widgets. */ + capture_prep_adjust_sensitivity(NULL, cap_open_w); + + /* Catch the "activate" signal on the text + entries, so that if the user types Return there, we act as if the + "OK" button had been selected, as happens if Return is typed if some + widget that *doesn't* handle the Return key has the input focus. */ + dlg_set_activate(GTK_COMBO(if_cb)->entry, ok_bt); + dlg_set_activate(filter_te, ok_bt); + dlg_set_activate(file_te, ok_bt); + + /* XXX - why does not + + gtk_widget_grab_focus(if_cb); + + give the initial focus to the "Interface" combo box? + + Or should I phrase that as "why does GTK+ continually frustrate + attempts to make GUIs driveable from the keyboard?" We have to + go catch the activate signal on every single GtkEntry widget + (rather than having widgets whose activate signal is *not* + caught not catch the Return keystroke, so that it passes on, + ultimately, to the window, which can activate the default + widget, i.e. the "OK" button); we have to catch the "key_press_event" + signal and have the handler check for ESC, so that we can have ESC + activate the "Cancel" button; in order to support Alt+<key> mnemonics + for buttons and the like, we may have to construct an accelerator + group by hand and set up the accelerators by hand (if that even + works - I've not tried it yet); we have to do a "gtk_widget_grab_focus()" + to keep some container widget from getting the initial focus, so that + you don't have to tab into the first widget in order to start typing + in it; and it now appears that you simply *can't* make a combo box + get the initial focus, at least not in the obvious fashion. Sigh.... */ + + SIGNAL_CONNECT(cap_open_w, "delete_event", window_delete_event_cb, NULL); + SIGNAL_CONNECT(cap_open_w, "destroy", capture_prep_destroy_cb, NULL); + + gtk_widget_show_all(cap_open_w); + window_present(cap_open_w); +} + +static void +capture_prep_answered_cb(gpointer dialog _U_, gint btn, gpointer data) +{ + switch(btn) { + case(ESD_BTN_SAVE): + /* save file first */ + file_save_as_cmd(after_save_capture_dialog, data); + break; + case(ESD_BTN_DONT_SAVE): + capture_prep(); + break; + case(ESD_BTN_CANCEL): + break; + default: + g_assert_not_reached(); + } +} + +void +capture_prep_cb(GtkWidget *w _U_, gpointer d _U_) +{ + gpointer dialog; + + if((cfile.state != FILE_CLOSED) && !cfile.user_saved && prefs.gui_ask_unsaved) { + /* user didn't saved his current file, ask him */ + dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_SAVE_DONTSAVE_CANCEL, + PRIMARY_TEXT_START "Save capture file before starting a new capture?" PRIMARY_TEXT_END "\n\n" + "If you start a new capture without saving, your current capture data will\nbe discarded."); + simple_dialog_set_cb(dialog, capture_prep_answered_cb, NULL); + } else { + /* unchanged file, just capture a new one */ + capture_prep(); + } +} + +static void +select_link_type_cb(GtkWidget *w, gpointer data) +{ + int new_linktype = GPOINTER_TO_INT(data); + GtkWidget *linktype_om = OBJECT_GET_DATA(w, E_CAP_LT_OM_KEY); + int old_linktype = GPOINTER_TO_INT(OBJECT_GET_DATA(linktype_om, E_CAP_OM_LT_VALUE_KEY)); + + if (old_linktype != new_linktype) + OBJECT_SET_DATA(linktype_om, E_CAP_OM_LT_VALUE_KEY, GINT_TO_POINTER(new_linktype)); +} + +static void +capture_prep_file_cb(GtkWidget *file_bt, GtkWidget *file_te) +{ + file_selection_browse(file_bt, file_te, "Ethereal: Specify a Capture File", FILE_SELECTION_OPEN); +} + + +static void +capture_prep_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w) { + GtkWidget *if_cb, *snap_cb, *snap_sb, *promisc_cb, *filter_te, + *file_te, *multi_files_on_cb, *ringbuffer_nbf_sb, *ringbuffer_nbf_cb, + *linktype_om, *sync_cb, *auto_scroll_cb, *hide_info_cb, + *stop_packets_cb, *stop_packets_sb, + *stop_filesize_cb, *stop_filesize_sb, *stop_filesize_om, + *stop_duration_cb, *stop_duration_sb, *stop_duration_om, + *ring_filesize_cb, *ring_filesize_sb, *ring_filesize_om, + *file_duration_cb, *file_duration_sb, *file_duration_om, + *stop_files_cb, *stop_files_sb, + *m_resolv_cb, *n_resolv_cb, *t_resolv_cb; +#ifdef _WIN32 + GtkWidget *buffer_size_sb; +#endif + gchar *entry_text; + gchar *if_text; + gchar *if_name; + const gchar *filter_text; + gchar *save_file; + const gchar *g_save_file; + gchar *cf_name; + gchar *dirname; + gint32 tmp; + + if_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_IFACE_KEY); + snap_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_SNAP_CB_KEY); + snap_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_SNAP_SB_KEY); + linktype_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_LT_OM_KEY); +#ifdef _WIN32 + buffer_size_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_BUFFER_SIZE_SB_KEY); +#endif + promisc_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_PROMISC_KEY); + filter_te = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILT_KEY); + file_te = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILE_TE_KEY); + multi_files_on_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_MULTI_FILES_ON_CB_KEY); + ringbuffer_nbf_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_NBF_CB_KEY); + ringbuffer_nbf_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_NBF_SB_KEY); + ring_filesize_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_FILESIZE_CB_KEY); + ring_filesize_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_FILESIZE_SB_KEY); + ring_filesize_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_FILESIZE_OM_KEY); + file_duration_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILE_DURATION_CB_KEY); + file_duration_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILE_DURATION_SB_KEY); + file_duration_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILE_DURATION_OM_KEY); + sync_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_SYNC_KEY); + auto_scroll_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_AUTO_SCROLL_KEY); + hide_info_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_HIDE_INFO_KEY); + stop_packets_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_PACKETS_CB_KEY); + stop_packets_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_PACKETS_SB_KEY); + stop_filesize_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILESIZE_CB_KEY); + stop_filesize_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILESIZE_SB_KEY); + stop_filesize_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILESIZE_OM_KEY); + stop_duration_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_DURATION_CB_KEY); + stop_duration_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_DURATION_SB_KEY); + stop_duration_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_DURATION_OM_KEY); + stop_files_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILES_CB_KEY); + stop_files_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILES_SB_KEY); + m_resolv_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_M_RESOLVE_KEY); + n_resolv_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_N_RESOLVE_KEY); + t_resolv_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_T_RESOLVE_KEY); + + entry_text = + g_strdup(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry))); + if_text = g_strstrip(entry_text); + if_name = get_if_name(if_text); + if (*if_name == '\0') { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + "You didn't specify an interface on which to capture packets."); + g_free(entry_text); + return; + } + if (cfile.iface) + g_free(cfile.iface); + cfile.iface = g_strdup(if_name); + g_free(entry_text); + + capture_opts.linktype = + GPOINTER_TO_INT(OBJECT_GET_DATA(linktype_om, E_CAP_OM_LT_VALUE_KEY)); + +#ifdef _WIN32 + capture_opts.buffer_size = + gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(buffer_size_sb)); +#endif + + capture_opts.has_snaplen = + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(snap_cb)); + if (capture_opts.has_snaplen) { + capture_opts.snaplen = + gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(snap_sb)); + if (capture_opts.snaplen < 1) + capture_opts.snaplen = WTAP_MAX_PACKET_SIZE; + else if (capture_opts.snaplen < MIN_PACKET_SIZE) + capture_opts.snaplen = MIN_PACKET_SIZE; + } + + capture_opts.promisc_mode = + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(promisc_cb)); + + /* XXX - don't try to get clever and set "cfile.filter" to NULL if the + filter string is empty, as an indication that we don't have a filter + and thus don't have to set a filter when capturing - the version of + libpcap in Red Hat Linux 6.1, and versions based on later patches + in that series, don't bind the AF_PACKET socket to an interface + until a filter is set, which means they aren't bound at all if + no filter is set, which means no packets arrive as input on that + socket, which means Ethereal never sees any packets. */ + filter_text = gtk_entry_get_text(GTK_ENTRY(filter_te)); + if (cfile.cfilter) + g_free(cfile.cfilter); + g_assert(filter_text != NULL); + cfile.cfilter = g_strdup(filter_text); + + g_save_file = gtk_entry_get_text(GTK_ENTRY(file_te)); + if (g_save_file && g_save_file[0]) { + /* User specified a file to which the capture should be written. */ + save_file = g_strdup(g_save_file); + /* Save the directory name for future file dialogs. */ + cf_name = g_strdup(g_save_file); + dirname = get_dirname(cf_name); /* Overwrites cf_name */ + set_last_open_dir(dirname); + g_free(cf_name); + } else { + /* User didn't specify a file; save to a temporary file. */ + save_file = NULL; + } + + capture_opts.has_autostop_packets = + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_packets_cb)); + if (capture_opts.has_autostop_packets) + capture_opts.autostop_packets = + gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_packets_sb)); + + capture_opts.has_autostop_duration = + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_duration_cb)); + if (capture_opts.has_autostop_duration) { + capture_opts.autostop_duration = + gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_duration_sb)); + capture_opts.autostop_duration = + time_unit_option_menu_get_value(stop_duration_om, capture_opts.autostop_duration); + } + + capture_opts.sync_mode = + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sync_cb)); + + auto_scroll_live = + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(auto_scroll_cb)); + + capture_opts.show_info = + !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hide_info_cb)); + + g_resolv_flags |= g_resolv_flags & RESOLV_CONCURRENT; + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_resolv_cb))) + g_resolv_flags |= RESOLV_MAC; + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(n_resolv_cb))) + g_resolv_flags |= RESOLV_NETWORK; + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(t_resolv_cb))) + g_resolv_flags |= RESOLV_TRANSPORT; + + capture_opts.has_ring_num_files = + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb)); + + capture_opts.ring_num_files = + gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ringbuffer_nbf_sb)); + if (capture_opts.ring_num_files > RINGBUFFER_MAX_NUM_FILES) + capture_opts.ring_num_files = RINGBUFFER_MAX_NUM_FILES; +#if RINGBUFFER_MIN_NUM_FILES > 0 + else if (capture_opts.ring_num_files < RINGBUFFER_MIN_NUM_FILES) + capture_opts.ring_num_files = RINGBUFFER_MIN_NUM_FILES; +#endif + + capture_opts.multi_files_on = + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(multi_files_on_cb)); + + if(capture_opts.sync_mode) + capture_opts.multi_files_on = FALSE; + + if (capture_opts.multi_files_on) { + capture_opts.has_autostop_filesize = + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb)); + if (capture_opts.has_autostop_filesize) { + tmp = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ring_filesize_sb)); + tmp = size_unit_option_menu_convert_value(ring_filesize_om, tmp); + if(tmp != 0) { + capture_opts.autostop_filesize = tmp; + } else { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + PRIMARY_TEXT_START "Multiple files: Requested filesize too large!\n\n" PRIMARY_TEXT_END + "The setting \"Next file every x byte(s)\" can't be greater than %u bytes (2GB).", G_MAXINT); + return; + } + } + + /* test if the settings are ok for a ringbuffer */ + if (save_file == NULL) { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + PRIMARY_TEXT_START "Multiple files: No capture file name given!\n\n" PRIMARY_TEXT_END + "You must specify a filename if you want to use multiple files."); + return; + } else if (!capture_opts.has_autostop_filesize) { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + PRIMARY_TEXT_START "Multiple files: No file limit given!\n\n" PRIMARY_TEXT_END + "You must specify a file size at which is switched to the next capture file\n" + "if you want to use multiple files."); + g_free(save_file); + return; + } + } else { + capture_opts.has_autostop_filesize = + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_filesize_cb)); + if (capture_opts.has_autostop_filesize) { + tmp = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_filesize_sb)); + tmp = size_unit_option_menu_convert_value(stop_filesize_om, tmp); + if(tmp != 0) { + capture_opts.autostop_filesize = tmp; + } else { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + PRIMARY_TEXT_START "Stop Capture: Requested filesize too large!\n\n" PRIMARY_TEXT_END + "The setting \"... after x byte(s)\" can't be greater than %u bytes (2GB).", G_MAXINT); + return; + } + } + } + + capture_opts.has_file_duration = + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_duration_cb)); + if (capture_opts.has_file_duration) { + capture_opts.file_duration = + gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(file_duration_sb)); + capture_opts.file_duration = + time_unit_option_menu_get_value(file_duration_om, capture_opts.file_duration); + } + + capture_opts.has_autostop_files = + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_files_cb)); + if (capture_opts.has_autostop_files) + capture_opts.autostop_files = + gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_files_sb)); + + window_destroy(GTK_WIDGET(parent_w)); + + do_capture(save_file); + if (save_file != NULL) + g_free(save_file); +} + +static void +capture_prep_destroy_cb(GtkWidget *win, gpointer user_data _U_) +{ + GtkWidget *fs; + + /* Is there a file selection dialog associated with this + Capture Options dialog? */ + fs = OBJECT_GET_DATA(win, E_FILE_SEL_DIALOG_PTR_KEY); + + if (fs != NULL) { + /* Yes. Destroy it. */ + window_destroy(fs); + } + + /* Note that we no longer have a "Capture Options" dialog box. */ + cap_open_w = NULL; +} + +static void +capture_prep_interface_changed_cb(GtkWidget *entry, gpointer argp) +{ + GtkWidget *linktype_om = argp; + + set_link_type_list(linktype_om, entry); +} + +/* + * Adjust the sensitivity of various widgets as per the current setting + * of other widgets. + */ +static void +capture_prep_adjust_sensitivity(GtkWidget *tb _U_, gpointer parent_w) +{ + GtkWidget *if_cb, + *snap_cb, *snap_sb, + *multi_files_on_cb, *ringbuffer_nbf_cb, *ringbuffer_nbf_sb, *ringbuffer_nbf_lb, + *ring_filesize_cb, *ring_filesize_sb, *ring_filesize_om, + *file_duration_cb, *file_duration_sb, *file_duration_om, + *sync_cb, *auto_scroll_cb, *hide_info_cb, + *stop_packets_cb, *stop_packets_sb, *stop_packets_lb, + *stop_filesize_cb, *stop_filesize_sb, *stop_filesize_om, + *stop_duration_cb, *stop_duration_sb, *stop_duration_om, + *stop_files_cb, *stop_files_sb, *stop_files_lb; + + + if_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_IFACE_KEY); + snap_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_SNAP_CB_KEY); + snap_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_SNAP_SB_KEY); + multi_files_on_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_MULTI_FILES_ON_CB_KEY); + ringbuffer_nbf_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_NBF_CB_KEY); + ringbuffer_nbf_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_NBF_SB_KEY); + ringbuffer_nbf_lb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_NBF_LB_KEY); + ring_filesize_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_FILESIZE_CB_KEY); + ring_filesize_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_FILESIZE_SB_KEY); + ring_filesize_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_FILESIZE_OM_KEY); + file_duration_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILE_DURATION_CB_KEY); + file_duration_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILE_DURATION_SB_KEY); + file_duration_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILE_DURATION_OM_KEY); + sync_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_SYNC_KEY); + auto_scroll_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_AUTO_SCROLL_KEY); + hide_info_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_HIDE_INFO_KEY); + stop_packets_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_PACKETS_CB_KEY); + stop_packets_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_PACKETS_SB_KEY); + stop_packets_lb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_PACKETS_LB_KEY); + stop_filesize_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILESIZE_CB_KEY); + stop_filesize_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILESIZE_SB_KEY); + stop_filesize_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILESIZE_OM_KEY); + stop_duration_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_DURATION_CB_KEY); + stop_duration_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_DURATION_SB_KEY); + stop_duration_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_DURATION_OM_KEY); + stop_files_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILES_CB_KEY); + stop_files_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILES_SB_KEY); + stop_files_lb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILES_LB_KEY); + + /* The snapshot length spinbox is sensitive if the "Limit each packet + to" checkbox is on. */ + gtk_widget_set_sensitive(GTK_WIDGET(snap_sb), + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(snap_cb))); + + + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sync_cb))) { + /* "Update list of packets in real time" captures enabled; we don't + support ring buffer mode for those captures, so turn ring buffer + mode off if it's on, and make its toggle button, and the spin + button for the number of ring buffer files (and the spin button's + label), insensitive. */ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(multi_files_on_cb), FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(multi_files_on_cb), FALSE); + + /* Auto-scroll mode is meaningful only in "Update list of packets + in real time" captures, so make its toggle button sensitive. */ + gtk_widget_set_sensitive(GTK_WIDGET(auto_scroll_cb), TRUE); + + gtk_widget_set_sensitive(GTK_WIDGET(hide_info_cb), TRUE); + } else { + /* "Update list of packets in real time" captures disabled; that + means ring buffer mode is OK, so make its toggle button + sensitive. */ + gtk_widget_set_sensitive(GTK_WIDGET(multi_files_on_cb), TRUE); + + /* Auto-scroll mode is meaningful only in "Update list of packets + in real time" captures, so make its toggle button insensitive. */ + gtk_widget_set_sensitive(GTK_WIDGET(auto_scroll_cb), FALSE); + + gtk_widget_set_sensitive(GTK_WIDGET(hide_info_cb), FALSE); + } + + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(multi_files_on_cb))) { + /* Ring buffer mode enabled. */ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ring_filesize_cb), TRUE); + + gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_cb), TRUE); + gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_sb), + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb))); + gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_lb), + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb))); + + /* The ring filesize spinbox is sensitive if the "Next capture file + after N kilobytes" checkbox is on. */ + gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_cb), TRUE); + gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_sb), + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb))); + gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_om), + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb))); + + /* The ring duration spinbox is sensitive if the "Next capture file + after N seconds" checkbox is on. */ + gtk_widget_set_sensitive(GTK_WIDGET(file_duration_cb), TRUE); + gtk_widget_set_sensitive(GTK_WIDGET(file_duration_sb), + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_duration_cb))); + gtk_widget_set_sensitive(GTK_WIDGET(file_duration_om), + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_duration_cb))); + + gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_cb), FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_sb), FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_om), FALSE); + + gtk_widget_set_sensitive(GTK_WIDGET(stop_files_cb), TRUE); + gtk_widget_set_sensitive(GTK_WIDGET(stop_files_sb), + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_files_cb))); + gtk_widget_set_sensitive(GTK_WIDGET(stop_files_lb), + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_files_cb))); + } else { + /* Ring buffer mode disabled. */ + gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_cb), FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_sb), FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_lb), FALSE); + + gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_cb), FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_sb),FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_om),FALSE); + + gtk_widget_set_sensitive(GTK_WIDGET(file_duration_cb), FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(file_duration_sb),FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(file_duration_om),FALSE); + + /* The maximum file size spinbox is sensitive if the "Stop capture + after N kilobytes" checkbox is on. */ + gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_cb), TRUE); + gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_sb), + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_filesize_cb))); + gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_om), + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_filesize_cb))); + + gtk_widget_set_sensitive(GTK_WIDGET(stop_files_cb), FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(stop_files_sb), FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(stop_files_lb), FALSE); + } + + /* The maximum packet count spinbox is sensitive if the "Stop capture + after N packets" checkbox is on. */ + gtk_widget_set_sensitive(GTK_WIDGET(stop_packets_sb), + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_packets_cb))); + gtk_widget_set_sensitive(GTK_WIDGET(stop_packets_lb), + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_packets_cb))); + + /* The capture duration spinbox is sensitive if the "Stop capture + after N seconds" checkbox is on. */ + gtk_widget_set_sensitive(GTK_WIDGET(stop_duration_sb), + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_duration_cb))); + gtk_widget_set_sensitive(GTK_WIDGET(stop_duration_om), + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_duration_cb))); +} + +#endif /* HAVE_LIBPCAP */ diff --git a/gtk/capture_dlg.h b/gtk/capture_dlg.h index c6df90775b..74407a8b72 100644 --- a/gtk/capture_dlg.h +++ b/gtk/capture_dlg.h @@ -1,67 +1,67 @@ -/* capture_dlg.h
- * Definitions for packet capture windows
- *
- * $Id: capture_dlg.h,v 1.6 2004/06/04 20:05:30 ulfl Exp $
- *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
- * Copyright 1998 Gerald Combs
- *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef __CAPTURE_DLG_H__
-#define __CAPTURE_DLG_H__
-
-/** @file
- * "Capture Options" dialog box.
- * @ingroup dialog_group
- */
-
-/** User requested the "Capture Options" dialog box by menu or toolbar.
- *
- * @param widget parent widget (unused)
- * @param data unused
- */
-void capture_prep_cb(GtkWidget *widget, gpointer data);
-
-/** User requested capture stop by menu or toolbar.
- *
- * @param widget parent widget (unused)
- * @param data unused
- */
-void capture_stop_cb(GtkWidget *widget, gpointer data);
-
-/** Create the "Capture Options" dialog box.
- */
-void capture_prep(void);
-
-/** User requested the "Capture Interfaces" dialog box by menu or toolbar.
- *
- * @param widget parent widget (unused)
- * @param data unused
- */
-void
-capture_if_cb(GtkWidget *widget, gpointer data);
-
-/** User requested the "Capture Interfaces" dialog box by menu or toolbar.
- *
- * @param capture_in_progress capture is in progress
- */
-void
-set_capture_if_dialog_for_capture_in_progress(gboolean capture_in_progress);
-
-#endif /* capture.h */
+/* capture_dlg.h + * Definitions for packet capture windows + * + * $Id$ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@zing.org> + * Copyright 1998 Gerald Combs + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __CAPTURE_DLG_H__ +#define __CAPTURE_DLG_H__ + +/** @file + * "Capture Options" dialog box. + * @ingroup dialog_group + */ + +/** User requested the "Capture Options" dialog box by menu or toolbar. + * + * @param widget parent widget (unused) + * @param data unused + */ +void capture_prep_cb(GtkWidget *widget, gpointer data); + +/** User requested capture stop by menu or toolbar. + * + * @param widget parent widget (unused) + * @param data unused + */ +void capture_stop_cb(GtkWidget *widget, gpointer data); + +/** Create the "Capture Options" dialog box. + */ +void capture_prep(void); + +/** User requested the "Capture Interfaces" dialog box by menu or toolbar. + * + * @param widget parent widget (unused) + * @param data unused + */ +void +capture_if_cb(GtkWidget *widget, gpointer data); + +/** User requested the "Capture Interfaces" dialog box by menu or toolbar. + * + * @param capture_in_progress capture is in progress + */ +void +set_capture_if_dialog_for_capture_in_progress(gboolean capture_in_progress); + +#endif /* capture.h */ diff --git a/gtk/capture_if_dlg.c b/gtk/capture_if_dlg.c index f4d7eb21ae..7e0847d119 100644 --- a/gtk/capture_if_dlg.c +++ b/gtk/capture_if_dlg.c @@ -1,486 +1,486 @@ -/* capture_if_dlg.c
- * Routines for the capture interface dialog
- *
- * $Id: capture_if_dlg.c,v 1.254 2004/06/30 06:58:56 guy Exp $
- *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
- * Copyright 1998 Gerald Combs
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-/* With MSVC and a libethereal.dll this file needs to import some variables
- in a special way. Therefore _NEED_VAR_IMPORT_ is defined. */
-/*#define _NEED_VAR_IMPORT_*/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#ifdef HAVE_LIBPCAP
-
-#ifdef HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
-#ifdef HAVE_SYS_WAIT_H
-# include <sys/wait.h>
-#endif
-
-
-#include <pcap.h>
-
-#include <gtk/gtk.h>
-
-#include "globals.h"
-#include "pcap-util.h"
-
-#ifdef _WIN32
-#include "capture-wpcap.h"
-#endif
-
-#include "compat_macros.h"
-#include "simple_dialog.h"
-#include "capture_dlg.h"
-
-#include "ui_util.h"
-#include "dlg_utils.h"
-
-#include "wtap.h"
-#include "capture.h"
-
-
-extern char *iptos(u_long in);
-
-extern gboolean is_capture_in_progress(void);
-
-/*
- * Keep a static pointer to the current "Capture Interfaces" window, if
- * any, so that if somebody tries to do "Capture:Start" while there's
- * already a "Capture Interfaces" window up, we just pop up the existing
- * one, rather than creating a new one.
- */
-static GtkWidget *cap_if_w;
-
-GList *if_data = NULL;
-
-guint timer_id;
-
-GtkWidget *stop_bt;
-
-GList *if_list;
-
-/*
- * Timeout, in milliseconds, for reads from the stream of captured packets.
- */
-#define CAP_READ_TIMEOUT 250
-
-
-/* the "runtime" data of one interface */
-typedef struct if_dlg_data_s {
- pcap_t *pch;
- GtkWidget *device_lb;
- GtkWidget *descr_lb;
- GtkWidget *ip_lb;
- GtkWidget *curr_lb;
- GtkWidget *last_lb;
- GtkWidget *capture_bt;
- GtkWidget *prepare_bt;
- guint32 last_packets;
- gchar *device;
-} if_dlg_data_t;
-
-void update_if(if_dlg_data_t *if_dlg_data);
-
-
-/* start capture button was pressed */
-static void
-capture_do_cb(GtkWidget *capture_bt _U_, gpointer if_data)
-{
- if_dlg_data_t *if_dlg_data = if_data;
-
- if (cfile.iface)
- g_free(cfile.iface);
-
- cfile.iface = g_strdup(if_dlg_data->device);
-
- do_capture(NULL /* save_file */);
-}
-
-
-/* prepare capture button was pressed */
-static void
-capture_prepare_cb(GtkWidget *prepare_bt _U_, gpointer if_data)
-{
- if_dlg_data_t *if_dlg_data = if_data;
-
- if (cfile.iface)
- g_free(cfile.iface);
-
- cfile.iface = g_strdup(if_dlg_data->device);
-
- capture_prep_cb(NULL, NULL);
-}
-
-
-/* open a single interface */
-void
-open_if(gchar *name, if_dlg_data_t *if_dlg_data)
-{
- gchar open_err_str[PCAP_ERRBUF_SIZE];
-
- if_dlg_data->pch = pcap_open_live(name,
- WTAP_MAX_PACKET_SIZE,
- capture_opts.promisc_mode, CAP_READ_TIMEOUT,
- open_err_str);
-
- if (if_dlg_data->pch != NULL) {
- update_if(if_dlg_data);
- } else {
- printf("open_if: %s\n", open_err_str);
- gtk_label_set_text(GTK_LABEL(if_dlg_data->curr_lb), "error");
- gtk_label_set_text(GTK_LABEL(if_dlg_data->last_lb), "error");
- }
-}
-
-/* update a single interface */
-void
-update_if(if_dlg_data_t *if_dlg_data)
-{
- struct pcap_stat stats;
- gchar *str;
- guint diff;
-
-
- /* pcap_stats() stats values differ on libpcap and winpcap!
- * libpcap: returns the number of packets since pcap_open_live
- * winpcap: returns the number of packets since the last pcap_stats call
- */
- if (if_dlg_data->pch) {
- if(pcap_stats(if_dlg_data->pch, &stats) >= 0) {
-#if WIN32
- diff = stats.ps_recv - if_dlg_data->last_packets;
- if_dlg_data->last_packets = stats.ps_recv;
-#else
- diff = stats.ps_recv;
- if_dlg_data->last_packets = stats.ps_recv + if_dlg_data->last_packets;
-#endif
-
- str = g_strdup_printf("%u", if_dlg_data->last_packets);
- gtk_label_set_text(GTK_LABEL(if_dlg_data->curr_lb), str);
- g_free(str);
- str = g_strdup_printf("%u", diff);
- gtk_label_set_text(GTK_LABEL(if_dlg_data->last_lb), str);
- g_free(str);
-
- gtk_widget_set_sensitive(if_dlg_data->curr_lb, diff);
- gtk_widget_set_sensitive(if_dlg_data->last_lb, diff);
- } else {
- gtk_label_set_text(GTK_LABEL(if_dlg_data->curr_lb), "error");
- gtk_label_set_text(GTK_LABEL(if_dlg_data->last_lb), "error");
- }
- }
-}
-
-
-/* close a single interface */
-void
-close_if(if_dlg_data_t *if_dlg_data)
-{
- if(if_dlg_data->pch)
- pcap_close(if_dlg_data->pch);
-}
-
-
-
-/* update all interfaces */
-gboolean
-update_all(gpointer data)
-{
- GList *curr;
- int ifs;
-
-
- if(!cap_if_w) {
- return FALSE;
- }
-
- for(ifs = 0; (curr = g_list_nth(data, ifs)); ifs++) {
- update_if(curr->data);
- }
-
- return TRUE;
-}
-
-
-/* a live capture has started or stopped */
-void
-set_capture_if_dialog_for_capture_in_progress(gboolean capture_in_progress)
-{
- GList *curr;
- int ifs;
-
- if(cap_if_w) {
- gtk_widget_set_sensitive(stop_bt, capture_in_progress);
-
- for(ifs = 0; (curr = g_list_nth(if_data, ifs)); ifs++) {
- if_dlg_data_t *if_dlg_data = curr->data;
-
- gtk_widget_set_sensitive(if_dlg_data->capture_bt, !capture_in_progress);
- gtk_widget_set_sensitive(if_dlg_data->prepare_bt, !capture_in_progress);
- }
- }
-}
-
-
-/* the window was closed, cleanup things */
-static void
-capture_if_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
-{
- GList *curr;
- int ifs;
-
- gtk_timeout_remove(timer_id);
-
- for(ifs = 0; (curr = g_list_nth(if_data, ifs)); ifs++) {
- if_dlg_data_t *if_dlg_data = curr->data;
-
- close_if(if_dlg_data);
- g_free(curr->data);
- }
-
- if_data = NULL;
-
- free_interface_list(if_list);
-
- /* Note that we no longer have a "Capture Options" dialog box. */
- cap_if_w = NULL;
-}
-
-
-/* start getting capture stats from all interfaces */
-void
-capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
-{
- GtkWidget *main_vb, *bbox, *close_bt;
-
- GtkWidget *if_tb;
- GtkWidget *if_lb;
-#if GTK_MAJOR_VERSION < 2
- GtkAccelGroup *accel_group;
-#endif
- GtkTooltips *tooltips;
- int err;
- char err_str[PCAP_ERRBUF_SIZE];
- gchar *cant_get_if_list_errstr;
- int row;
- if_dlg_data_t *if_dlg_data;
- int ifs;
- GList *curr;
- if_info_t *if_info;
- GSList *curr_ip;
- guint32 ip_addr;
- GString *if_tool_str = g_string_new("");
- gchar *tmp_str;
-
-
- if (cap_if_w != NULL) {
- /* There's already a "Capture Interfaces" dialog box; reactivate it. */
- reactivate_window(cap_if_w);
- return;
- }
-
-#ifdef _WIN32
- /* Is WPcap loaded? */
- if (!has_wpcap) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- "Unable to load WinPcap (wpcap.dll); Ethereal will not be able\n"
- "to capture packets.\n\n"
- "In order to capture packets, WinPcap must be installed; see\n"
- "\n"
- " http://winpcap.polito.it/\n"
- "\n"
- "or the mirror at\n"
- "\n"
- " http://winpcap.mirror.ethereal.com/\n"
- "\n"
- "or the mirror at\n"
- "\n"
- " http://www.mirrors.wiretapped.net/security/packet-capture/winpcap/\n"
- "\n"
- "for a downloadable version of WinPcap and for instructions\n"
- "on how to install WinPcap.");
- return;
- }
-#endif
-
- if_list = get_interface_list(&err, err_str);
- if (if_list == NULL && err == CANT_GET_INTERFACE_LIST) {
- cant_get_if_list_errstr = cant_get_if_list_error_message(err_str);
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s",
- cant_get_if_list_errstr);
- g_free(cant_get_if_list_errstr);
- return;
- }
-
- cap_if_w = window_new(GTK_WINDOW_TOPLEVEL, "Ethereal: Capture Interfaces");
-
- tooltips = gtk_tooltips_new();
-
-#if GTK_MAJOR_VERSION < 2
- /* Accelerator group for the accelerators (or, as they're called in
- Windows and, I think, in Motif, "mnemonics"; Alt+<key> is a mnemonic,
- Ctrl+<key> is an accelerator). */
- accel_group = gtk_accel_group_new();
- gtk_window_add_accel_group(GTK_WINDOW(cap_if_w), accel_group);
-#endif
-
- main_vb = gtk_vbox_new(FALSE, 0);
- gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
- gtk_container_add(GTK_CONTAINER(cap_if_w), main_vb);
-
-
- if_tb = gtk_table_new(6,1, FALSE);
- gtk_table_set_row_spacings(GTK_TABLE(if_tb), 3);
- gtk_table_set_col_spacings(GTK_TABLE(if_tb), 3);
- gtk_container_add(GTK_CONTAINER(main_vb), if_tb);
-
- row = 0;
-
-#ifndef WIN32
- if_lb = gtk_label_new("Device");
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 0, 1, row, row+1);
-#endif
-
- if_lb = gtk_label_new("Description");
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 1, 2, row, row+1);
-
- if_lb = gtk_label_new(" IP ");
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 2, 3, row, row+1);
-
- if_lb = gtk_label_new("Packets");
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 3, 4, row, row+1);
-
- if_lb = gtk_label_new(" Packets/s ");
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 4, 5, row, row+1);
-
- stop_bt = BUTTON_NEW_FROM_STOCK(GTK_STOCK_STOP);
- gtk_tooltips_set_tip(tooltips, stop_bt,
- "Stop a running capture.", NULL);
- gtk_table_attach_defaults(GTK_TABLE(if_tb), stop_bt, 5, 7, row, row+1);
- SIGNAL_CONNECT(stop_bt, "clicked", capture_stop_cb, NULL);
-
- row++;
-
- for(ifs = 0; (curr = g_list_nth(if_list, ifs)); ifs++) {
- g_string_assign(if_tool_str, "");
- if_info = curr->data;
- if_dlg_data = g_malloc0(sizeof(if_dlg_data_t));
-
- /* device name */
- if_dlg_data->device_lb = gtk_label_new(if_info->name);
- if_dlg_data->device = if_info->name;
-#ifndef WIN32
- gtk_misc_set_alignment(GTK_MISC(if_dlg_data->device_lb), 0.0, 0.5);
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->device_lb, 0, 1, row, row+1);
-#endif
- g_string_append(if_tool_str, "Device: ");
- g_string_append(if_tool_str, if_info->name);
- g_string_append(if_tool_str, "\n");
-
- /* description */
- if_dlg_data->descr_lb = gtk_label_new(if_info->description);
- gtk_misc_set_alignment(GTK_MISC(if_dlg_data->descr_lb), 0.0, 0.5);
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->descr_lb, 1, 2, row, row+1);
-
- g_string_append(if_tool_str, "Description: ");
- g_string_append(if_tool_str, if_info->description);
- g_string_append(if_tool_str, "\n");
-
- /* IP address */
- /* only one IP address will be shown */
- g_string_append(if_tool_str, "IP: ");
- curr_ip = g_slist_nth(if_info->ip_addr, 0);
- if(curr_ip) {
- ip_addr = *((guint32 *)curr_ip->data);
- if_dlg_data->ip_lb = gtk_label_new(iptos(ip_addr));
- g_string_append(if_tool_str, iptos(ip_addr));
- } else {
- ip_addr = 0;
- if_dlg_data->ip_lb = gtk_label_new("unknown");
- g_string_append(if_tool_str, "unknown");
- }
- gtk_widget_set_sensitive(if_dlg_data->ip_lb, ip_addr);
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->ip_lb, 2, 3, row, row+1);
- g_string_append(if_tool_str, "\n");
-
- /* packets */
- if_dlg_data->curr_lb = gtk_label_new("-");
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->curr_lb, 3, 4, row, row+1);
-
- /* packets/s */
- if_dlg_data->last_lb = gtk_label_new("-");
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->last_lb, 4, 5, row, row+1);
-
- /* capture button */
- if_dlg_data->capture_bt = gtk_button_new_with_label("Capture");
- SIGNAL_CONNECT(if_dlg_data->capture_bt, "clicked", capture_do_cb, if_dlg_data);
- tmp_str = g_strdup_printf("Immediately start a capture from this interface:\n\n%s", if_tool_str->str);
- gtk_tooltips_set_tip(tooltips, if_dlg_data->capture_bt,
- tmp_str, NULL);
- g_free(tmp_str);
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->capture_bt, 5, 6, row, row+1);
-
- /* prepare button */
- if_dlg_data->prepare_bt = gtk_button_new_with_label("Prepare");
- SIGNAL_CONNECT(if_dlg_data->prepare_bt, "clicked", capture_prepare_cb, if_dlg_data);
- gtk_tooltips_set_tip(tooltips, if_dlg_data->prepare_bt,
- "Open the capture options dialog with this interface selected.", NULL);
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->prepare_bt, 6, 7, row, row+1);
-
- open_if(if_info->name, if_dlg_data);
-
- if_data = g_list_append(if_data, if_dlg_data);
-
- row++;
- }
-
- g_string_free(if_tool_str, TRUE);
-
- /* Button row: close button */
- bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
- gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 5);
-
- close_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CLOSE);
- window_set_cancel_button(cap_if_w, close_bt, window_cancel_button_cb);
- gtk_tooltips_set_tip(tooltips, close_bt, "Close this window.", NULL);
-
- gtk_widget_grab_default(close_bt);
-
- SIGNAL_CONNECT(cap_if_w, "delete_event", window_delete_event_cb, NULL);
- SIGNAL_CONNECT(cap_if_w, "destroy", capture_if_destroy_cb, NULL);
-
- gtk_widget_show_all(cap_if_w);
- window_present(cap_if_w);
-
- set_capture_if_dialog_for_capture_in_progress(is_capture_in_progress());
-
- /* update the interface list every 1000ms */
- timer_id = gtk_timeout_add(1000, update_all, if_data);
-}
-
-
-#endif /* HAVE_LIBPCAP */
+/* capture_if_dlg.c + * Routines for the capture interface dialog + * + * $Id$ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/* With MSVC and a libethereal.dll this file needs to import some variables + in a special way. Therefore _NEED_VAR_IMPORT_ is defined. */ +/*#define _NEED_VAR_IMPORT_*/ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#ifdef HAVE_LIBPCAP + +#ifdef HAVE_SYS_STAT_H +# include <sys/stat.h> +#endif + +#ifdef HAVE_SYS_WAIT_H +# include <sys/wait.h> +#endif + + +#include <pcap.h> + +#include <gtk/gtk.h> + +#include "globals.h" +#include "pcap-util.h" + +#ifdef _WIN32 +#include "capture-wpcap.h" +#endif + +#include "compat_macros.h" +#include "simple_dialog.h" +#include "capture_dlg.h" + +#include "ui_util.h" +#include "dlg_utils.h" + +#include "wtap.h" +#include "capture.h" + + +extern char *iptos(u_long in); + +extern gboolean is_capture_in_progress(void); + +/* + * Keep a static pointer to the current "Capture Interfaces" window, if + * any, so that if somebody tries to do "Capture:Start" while there's + * already a "Capture Interfaces" window up, we just pop up the existing + * one, rather than creating a new one. + */ +static GtkWidget *cap_if_w; + +GList *if_data = NULL; + +guint timer_id; + +GtkWidget *stop_bt; + +GList *if_list; + +/* + * Timeout, in milliseconds, for reads from the stream of captured packets. + */ +#define CAP_READ_TIMEOUT 250 + + +/* the "runtime" data of one interface */ +typedef struct if_dlg_data_s { + pcap_t *pch; + GtkWidget *device_lb; + GtkWidget *descr_lb; + GtkWidget *ip_lb; + GtkWidget *curr_lb; + GtkWidget *last_lb; + GtkWidget *capture_bt; + GtkWidget *prepare_bt; + guint32 last_packets; + gchar *device; +} if_dlg_data_t; + +void update_if(if_dlg_data_t *if_dlg_data); + + +/* start capture button was pressed */ +static void +capture_do_cb(GtkWidget *capture_bt _U_, gpointer if_data) +{ + if_dlg_data_t *if_dlg_data = if_data; + + if (cfile.iface) + g_free(cfile.iface); + + cfile.iface = g_strdup(if_dlg_data->device); + + do_capture(NULL /* save_file */); +} + + +/* prepare capture button was pressed */ +static void +capture_prepare_cb(GtkWidget *prepare_bt _U_, gpointer if_data) +{ + if_dlg_data_t *if_dlg_data = if_data; + + if (cfile.iface) + g_free(cfile.iface); + + cfile.iface = g_strdup(if_dlg_data->device); + + capture_prep_cb(NULL, NULL); +} + + +/* open a single interface */ +void +open_if(gchar *name, if_dlg_data_t *if_dlg_data) +{ + gchar open_err_str[PCAP_ERRBUF_SIZE]; + + if_dlg_data->pch = pcap_open_live(name, + WTAP_MAX_PACKET_SIZE, + capture_opts.promisc_mode, CAP_READ_TIMEOUT, + open_err_str); + + if (if_dlg_data->pch != NULL) { + update_if(if_dlg_data); + } else { + printf("open_if: %s\n", open_err_str); + gtk_label_set_text(GTK_LABEL(if_dlg_data->curr_lb), "error"); + gtk_label_set_text(GTK_LABEL(if_dlg_data->last_lb), "error"); + } +} + +/* update a single interface */ +void +update_if(if_dlg_data_t *if_dlg_data) +{ + struct pcap_stat stats; + gchar *str; + guint diff; + + + /* pcap_stats() stats values differ on libpcap and winpcap! + * libpcap: returns the number of packets since pcap_open_live + * winpcap: returns the number of packets since the last pcap_stats call + */ + if (if_dlg_data->pch) { + if(pcap_stats(if_dlg_data->pch, &stats) >= 0) { +#if WIN32 + diff = stats.ps_recv - if_dlg_data->last_packets; + if_dlg_data->last_packets = stats.ps_recv; +#else + diff = stats.ps_recv; + if_dlg_data->last_packets = stats.ps_recv + if_dlg_data->last_packets; +#endif + + str = g_strdup_printf("%u", if_dlg_data->last_packets); + gtk_label_set_text(GTK_LABEL(if_dlg_data->curr_lb), str); + g_free(str); + str = g_strdup_printf("%u", diff); + gtk_label_set_text(GTK_LABEL(if_dlg_data->last_lb), str); + g_free(str); + + gtk_widget_set_sensitive(if_dlg_data->curr_lb, diff); + gtk_widget_set_sensitive(if_dlg_data->last_lb, diff); + } else { + gtk_label_set_text(GTK_LABEL(if_dlg_data->curr_lb), "error"); + gtk_label_set_text(GTK_LABEL(if_dlg_data->last_lb), "error"); + } + } +} + + +/* close a single interface */ +void +close_if(if_dlg_data_t *if_dlg_data) +{ + if(if_dlg_data->pch) + pcap_close(if_dlg_data->pch); +} + + + +/* update all interfaces */ +gboolean +update_all(gpointer data) +{ + GList *curr; + int ifs; + + + if(!cap_if_w) { + return FALSE; + } + + for(ifs = 0; (curr = g_list_nth(data, ifs)); ifs++) { + update_if(curr->data); + } + + return TRUE; +} + + +/* a live capture has started or stopped */ +void +set_capture_if_dialog_for_capture_in_progress(gboolean capture_in_progress) +{ + GList *curr; + int ifs; + + if(cap_if_w) { + gtk_widget_set_sensitive(stop_bt, capture_in_progress); + + for(ifs = 0; (curr = g_list_nth(if_data, ifs)); ifs++) { + if_dlg_data_t *if_dlg_data = curr->data; + + gtk_widget_set_sensitive(if_dlg_data->capture_bt, !capture_in_progress); + gtk_widget_set_sensitive(if_dlg_data->prepare_bt, !capture_in_progress); + } + } +} + + +/* the window was closed, cleanup things */ +static void +capture_if_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_) +{ + GList *curr; + int ifs; + + gtk_timeout_remove(timer_id); + + for(ifs = 0; (curr = g_list_nth(if_data, ifs)); ifs++) { + if_dlg_data_t *if_dlg_data = curr->data; + + close_if(if_dlg_data); + g_free(curr->data); + } + + if_data = NULL; + + free_interface_list(if_list); + + /* Note that we no longer have a "Capture Options" dialog box. */ + cap_if_w = NULL; +} + + +/* start getting capture stats from all interfaces */ +void +capture_if_cb(GtkWidget *w _U_, gpointer d _U_) +{ + GtkWidget *main_vb, *bbox, *close_bt; + + GtkWidget *if_tb; + GtkWidget *if_lb; +#if GTK_MAJOR_VERSION < 2 + GtkAccelGroup *accel_group; +#endif + GtkTooltips *tooltips; + int err; + char err_str[PCAP_ERRBUF_SIZE]; + gchar *cant_get_if_list_errstr; + int row; + if_dlg_data_t *if_dlg_data; + int ifs; + GList *curr; + if_info_t *if_info; + GSList *curr_ip; + guint32 ip_addr; + GString *if_tool_str = g_string_new(""); + gchar *tmp_str; + + + if (cap_if_w != NULL) { + /* There's already a "Capture Interfaces" dialog box; reactivate it. */ + reactivate_window(cap_if_w); + return; + } + +#ifdef _WIN32 + /* Is WPcap loaded? */ + if (!has_wpcap) { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + "Unable to load WinPcap (wpcap.dll); Ethereal will not be able\n" + "to capture packets.\n\n" + "In order to capture packets, WinPcap must be installed; see\n" + "\n" + " http://winpcap.polito.it/\n" + "\n" + "or the mirror at\n" + "\n" + " http://winpcap.mirror.ethereal.com/\n" + "\n" + "or the mirror at\n" + "\n" + " http://www.mirrors.wiretapped.net/security/packet-capture/winpcap/\n" + "\n" + "for a downloadable version of WinPcap and for instructions\n" + "on how to install WinPcap."); + return; + } +#endif + + if_list = get_interface_list(&err, err_str); + if (if_list == NULL && err == CANT_GET_INTERFACE_LIST) { + cant_get_if_list_errstr = cant_get_if_list_error_message(err_str); + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", + cant_get_if_list_errstr); + g_free(cant_get_if_list_errstr); + return; + } + + cap_if_w = window_new(GTK_WINDOW_TOPLEVEL, "Ethereal: Capture Interfaces"); + + tooltips = gtk_tooltips_new(); + +#if GTK_MAJOR_VERSION < 2 + /* Accelerator group for the accelerators (or, as they're called in + Windows and, I think, in Motif, "mnemonics"; Alt+<key> is a mnemonic, + Ctrl+<key> is an accelerator). */ + accel_group = gtk_accel_group_new(); + gtk_window_add_accel_group(GTK_WINDOW(cap_if_w), accel_group); +#endif + + main_vb = gtk_vbox_new(FALSE, 0); + gtk_container_border_width(GTK_CONTAINER(main_vb), 5); + gtk_container_add(GTK_CONTAINER(cap_if_w), main_vb); + + + if_tb = gtk_table_new(6,1, FALSE); + gtk_table_set_row_spacings(GTK_TABLE(if_tb), 3); + gtk_table_set_col_spacings(GTK_TABLE(if_tb), 3); + gtk_container_add(GTK_CONTAINER(main_vb), if_tb); + + row = 0; + +#ifndef WIN32 + if_lb = gtk_label_new("Device"); + gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 0, 1, row, row+1); +#endif + + if_lb = gtk_label_new("Description"); + gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 1, 2, row, row+1); + + if_lb = gtk_label_new(" IP "); + gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 2, 3, row, row+1); + + if_lb = gtk_label_new("Packets"); + gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 3, 4, row, row+1); + + if_lb = gtk_label_new(" Packets/s "); + gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 4, 5, row, row+1); + + stop_bt = BUTTON_NEW_FROM_STOCK(GTK_STOCK_STOP); + gtk_tooltips_set_tip(tooltips, stop_bt, + "Stop a running capture.", NULL); + gtk_table_attach_defaults(GTK_TABLE(if_tb), stop_bt, 5, 7, row, row+1); + SIGNAL_CONNECT(stop_bt, "clicked", capture_stop_cb, NULL); + + row++; + + for(ifs = 0; (curr = g_list_nth(if_list, ifs)); ifs++) { + g_string_assign(if_tool_str, ""); + if_info = curr->data; + if_dlg_data = g_malloc0(sizeof(if_dlg_data_t)); + + /* device name */ + if_dlg_data->device_lb = gtk_label_new(if_info->name); + if_dlg_data->device = if_info->name; +#ifndef WIN32 + gtk_misc_set_alignment(GTK_MISC(if_dlg_data->device_lb), 0.0, 0.5); + gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->device_lb, 0, 1, row, row+1); +#endif + g_string_append(if_tool_str, "Device: "); + g_string_append(if_tool_str, if_info->name); + g_string_append(if_tool_str, "\n"); + + /* description */ + if_dlg_data->descr_lb = gtk_label_new(if_info->description); + gtk_misc_set_alignment(GTK_MISC(if_dlg_data->descr_lb), 0.0, 0.5); + gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->descr_lb, 1, 2, row, row+1); + + g_string_append(if_tool_str, "Description: "); + g_string_append(if_tool_str, if_info->description); + g_string_append(if_tool_str, "\n"); + + /* IP address */ + /* only one IP address will be shown */ + g_string_append(if_tool_str, "IP: "); + curr_ip = g_slist_nth(if_info->ip_addr, 0); + if(curr_ip) { + ip_addr = *((guint32 *)curr_ip->data); + if_dlg_data->ip_lb = gtk_label_new(iptos(ip_addr)); + g_string_append(if_tool_str, iptos(ip_addr)); + } else { + ip_addr = 0; + if_dlg_data->ip_lb = gtk_label_new("unknown"); + g_string_append(if_tool_str, "unknown"); + } + gtk_widget_set_sensitive(if_dlg_data->ip_lb, ip_addr); + gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->ip_lb, 2, 3, row, row+1); + g_string_append(if_tool_str, "\n"); + + /* packets */ + if_dlg_data->curr_lb = gtk_label_new("-"); + gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->curr_lb, 3, 4, row, row+1); + + /* packets/s */ + if_dlg_data->last_lb = gtk_label_new("-"); + gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->last_lb, 4, 5, row, row+1); + + /* capture button */ + if_dlg_data->capture_bt = gtk_button_new_with_label("Capture"); + SIGNAL_CONNECT(if_dlg_data->capture_bt, "clicked", capture_do_cb, if_dlg_data); + tmp_str = g_strdup_printf("Immediately start a capture from this interface:\n\n%s", if_tool_str->str); + gtk_tooltips_set_tip(tooltips, if_dlg_data->capture_bt, + tmp_str, NULL); + g_free(tmp_str); + gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->capture_bt, 5, 6, row, row+1); + + /* prepare button */ + if_dlg_data->prepare_bt = gtk_button_new_with_label("Prepare"); + SIGNAL_CONNECT(if_dlg_data->prepare_bt, "clicked", capture_prepare_cb, if_dlg_data); + gtk_tooltips_set_tip(tooltips, if_dlg_data->prepare_bt, + "Open the capture options dialog with this interface selected.", NULL); + gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->prepare_bt, 6, 7, row, row+1); + + open_if(if_info->name, if_dlg_data); + + if_data = g_list_append(if_data, if_dlg_data); + + row++; + } + + g_string_free(if_tool_str, TRUE); + + /* Button row: close button */ + bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL); + gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 5); + + close_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CLOSE); + window_set_cancel_button(cap_if_w, close_bt, window_cancel_button_cb); + gtk_tooltips_set_tip(tooltips, close_bt, "Close this window.", NULL); + + gtk_widget_grab_default(close_bt); + + SIGNAL_CONNECT(cap_if_w, "delete_event", window_delete_event_cb, NULL); + SIGNAL_CONNECT(cap_if_w, "destroy", capture_if_destroy_cb, NULL); + + gtk_widget_show_all(cap_if_w); + window_present(cap_if_w); + + set_capture_if_dialog_for_capture_in_progress(is_capture_in_progress()); + + /* update the interface list every 1000ms */ + timer_id = gtk_timeout_add(1000, update_all, if_data); +} + + +#endif /* HAVE_LIBPCAP */ diff --git a/gtk/capture_info_dlg.c b/gtk/capture_info_dlg.c index 3f0648bf27..44d4807d61 100644 --- a/gtk/capture_info_dlg.c +++ b/gtk/capture_info_dlg.c @@ -1,7 +1,7 @@ /* capture_info_dlg.c * Routines for packet capture info dialog * - * $Id: capture_info_dlg.c,v 1.17 2004/05/27 17:26:46 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/capture_prefs.c b/gtk/capture_prefs.c index 8f9381a5ac..7207f1113f 100644 --- a/gtk/capture_prefs.c +++ b/gtk/capture_prefs.c @@ -1,7 +1,7 @@ /* capture_prefs.c * Dialog box for capture preferences * - * $Id: capture_prefs.c,v 1.39 2004/07/13 05:43:59 guy Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/capture_prefs.h b/gtk/capture_prefs.h index 234dbde473..cdc0d22907 100644 --- a/gtk/capture_prefs.h +++ b/gtk/capture_prefs.h @@ -1,7 +1,7 @@ /* capture_prefs.h * Definitions for capture preferences window * - * $Id: capture_prefs.h,v 1.5 2004/06/04 20:05:30 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/color_dlg.c b/gtk/color_dlg.c index 00faa09a45..ea94f62dc8 100644 --- a/gtk/color_dlg.c +++ b/gtk/color_dlg.c @@ -1,7 +1,7 @@ /* color_dlg.c * Definitions for dialog boxes for color filters * - * $Id: color_dlg.c,v 1.52 2004/06/05 10:13:37 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/color_dlg.h b/gtk/color_dlg.h index 383f95ef90..163467c585 100644 --- a/gtk/color_dlg.h +++ b/gtk/color_dlg.h @@ -1,7 +1,7 @@ /* color_dlg.h * Definitions for dialog boxes for color filters * - * $Id: color_dlg.h,v 1.6 2004/06/04 20:05:30 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> diff --git a/gtk/color_filters.c b/gtk/color_filters.c index a971e499d1..fa5793f0ac 100644 --- a/gtk/color_filters.c +++ b/gtk/color_filters.c @@ -1,7 +1,7 @@ /* color_filters.c * Routines for color filters * - * $Id: color_filters.c,v 1.10 2004/04/16 19:36:36 guy Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/color_filters.h b/gtk/color_filters.h index 8c5d2bd573..d6db23f8e3 100644 --- a/gtk/color_filters.h +++ b/gtk/color_filters.h @@ -1,7 +1,7 @@ /* color_filters.h * Definitions for color filters * - * $Id: color_filters.h,v 1.7 2004/06/01 20:28:04 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/color_utils.c b/gtk/color_utils.c index 8bf665dd77..6fca4eadfa 100644 --- a/gtk/color_utils.c +++ b/gtk/color_utils.c @@ -2,7 +2,7 @@ * Utilities for converting between "toolkit-independent" and GDK * notions of color * - * $Id: color_utils.c,v 1.4 2002/09/23 19:09:49 oabad Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> diff --git a/gtk/color_utils.h b/gtk/color_utils.h index 836595b425..36f27ce2f9 100644 --- a/gtk/color_utils.h +++ b/gtk/color_utils.h @@ -2,7 +2,7 @@ * Declarations of utilities for converting between "toolkit-independent" * and GDK notions of color * - * $Id: color_utils.h,v 1.3 2004/06/01 20:28:04 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> diff --git a/gtk/colors.c b/gtk/colors.c index 23ad9d81af..3d9ad7f1ce 100644 --- a/gtk/colors.c +++ b/gtk/colors.c @@ -1,7 +1,7 @@ /* colors.c * Routines for colors * - * $Id: colors.c,v 1.28 2004/01/31 03:22:39 guy Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/colors.h b/gtk/colors.h index f66a522eaf..4ff136d8c2 100644 --- a/gtk/colors.h +++ b/gtk/colors.h @@ -1,7 +1,7 @@ /* colors.h * Definitions for color structures and routines * - * $Id: colors.h,v 1.12 2004/06/01 20:28:04 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/column_prefs.c b/gtk/column_prefs.c index 3f42ca939f..9600cea0ef 100644 --- a/gtk/column_prefs.c +++ b/gtk/column_prefs.c @@ -1,7 +1,7 @@ /* column_prefs.c * Dialog box for column preferences * - * $Id: column_prefs.c,v 1.24 2004/05/27 16:48:36 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/column_prefs.h b/gtk/column_prefs.h index 378343cf59..02968977d6 100644 --- a/gtk/column_prefs.h +++ b/gtk/column_prefs.h @@ -1,7 +1,7 @@ /* column_prefs.h * Definitions for column preferences window * - * $Id: column_prefs.h,v 1.7 2004/06/04 20:05:30 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> diff --git a/gtk/compat_macros.h b/gtk/compat_macros.h index 888a6d7369..be990fa9f9 100644 --- a/gtk/compat_macros.h +++ b/gtk/compat_macros.h @@ -1,7 +1,7 @@ /* compat_macros.h * GTK-related Global defines, etc. * - * $Id: compat_macros.h,v 1.21 2004/07/13 07:15:44 guy Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/dcerpc_stat.c b/gtk/dcerpc_stat.c index 918ea20a13..c9d86e2d04 100644 --- a/gtk/dcerpc_stat.c +++ b/gtk/dcerpc_stat.c @@ -1,7 +1,7 @@ /* dcerpc_stat.c * dcerpc_stat 2002 Ronnie Sahlberg * - * $Id: dcerpc_stat.c,v 1.58 2004/06/02 07:12:09 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/decode_as_dlg.c b/gtk/decode_as_dlg.c index 4c9729196d..a9bb26577b 100644 --- a/gtk/decode_as_dlg.c +++ b/gtk/decode_as_dlg.c @@ -1,6 +1,6 @@ /* decode_as_dlg.c * - * $Id: decode_as_dlg.c,v 1.41 2004/06/10 09:46:26 guy Exp $ + * $Id$ * * Routines to modify dissector tables on the fly. * diff --git a/gtk/decode_as_dlg.h b/gtk/decode_as_dlg.h index f080e7ce94..57ceb84c7f 100644 --- a/gtk/decode_as_dlg.h +++ b/gtk/decode_as_dlg.h @@ -1,6 +1,6 @@ /* decode_as_dlg.h * - * $Id: decode_as_dlg.h,v 1.6 2004/06/04 20:05:30 ulfl Exp $ + * $Id$ * * Routines to modify dissector tables on the fly. * diff --git a/gtk/dfilter_expr_dlg.c b/gtk/dfilter_expr_dlg.c index ff120dfdbc..1fbae8d561 100644 --- a/gtk/dfilter_expr_dlg.c +++ b/gtk/dfilter_expr_dlg.c @@ -7,7 +7,7 @@ * Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com> and * Guy Harris <guy@alum.mit.edu> * - * $Id: dfilter_expr_dlg.c,v 1.60 2004/06/10 20:16:50 guy Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/dfilter_expr_dlg.h b/gtk/dfilter_expr_dlg.h index d0d331c82f..024819c68a 100644 --- a/gtk/dfilter_expr_dlg.h +++ b/gtk/dfilter_expr_dlg.h @@ -1,7 +1,7 @@ /* dfilter_expr_dlg.h * Definitions for dialog boxes for display filter expression construction * - * $Id: dfilter_expr_dlg.h,v 1.4 2004/06/04 20:05:30 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> diff --git a/gtk/dlg_utils.c b/gtk/dlg_utils.c index 0ace9be012..532a249d6b 100644 --- a/gtk/dlg_utils.c +++ b/gtk/dlg_utils.c @@ -1,7 +1,7 @@ /* dlg_utils.c * Utilities to use when constructing dialogs * - * $Id: dlg_utils.c,v 1.42 2004/07/13 07:15:44 guy Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/dlg_utils.h b/gtk/dlg_utils.h index 3be89cb3a4..e8dc130d0a 100644 --- a/gtk/dlg_utils.h +++ b/gtk/dlg_utils.h @@ -1,7 +1,7 @@ /* dlg_utils.h * Declarations of utilities to use when constructing dialogs * - * $Id: dlg_utils.h,v 1.21 2004/06/05 12:12:13 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/endpoint_talkers_eth.c b/gtk/endpoint_talkers_eth.c index 7136d72a96..1318fd6e66 100644 --- a/gtk/endpoint_talkers_eth.c +++ b/gtk/endpoint_talkers_eth.c @@ -1,7 +1,7 @@ /* endpoint_talkers_eth.c * endpoint_talkers_eth 2003 Ronnie Sahlberg * - * $Id: endpoint_talkers_eth.c,v 1.25 2004/05/02 17:25:09 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/endpoint_talkers_fc.c b/gtk/endpoint_talkers_fc.c index 3172771e66..7d3ea9413c 100644 --- a/gtk/endpoint_talkers_fc.c +++ b/gtk/endpoint_talkers_fc.c @@ -1,7 +1,7 @@ /* endpoint_talkers_fc.c * endpoint_talkers_fc 2003 Ronnie Sahlberg * - * $Id: endpoint_talkers_fc.c,v 1.25 2004/05/02 17:25:10 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/endpoint_talkers_fddi.c b/gtk/endpoint_talkers_fddi.c index 7e49090777..40c31794cc 100644 --- a/gtk/endpoint_talkers_fddi.c +++ b/gtk/endpoint_talkers_fddi.c @@ -1,7 +1,7 @@ /* endpoint_talkers_fddi.c * endpoint_talkers_fddi 2003 Ronnie Sahlberg * - * $Id: endpoint_talkers_fddi.c,v 1.20 2004/05/02 17:25:10 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/endpoint_talkers_ip.c b/gtk/endpoint_talkers_ip.c index 1d3ae17eaf..3d97e37300 100644 --- a/gtk/endpoint_talkers_ip.c +++ b/gtk/endpoint_talkers_ip.c @@ -1,7 +1,7 @@ /* endpoint_talkers_ip.c * endpoint_talkers_ip 2003 Ronnie Sahlberg * - * $Id: endpoint_talkers_ip.c,v 1.26 2004/05/02 17:25:10 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/endpoint_talkers_ipx.c b/gtk/endpoint_talkers_ipx.c index 47de417e3a..4e2dfa0392 100644 --- a/gtk/endpoint_talkers_ipx.c +++ b/gtk/endpoint_talkers_ipx.c @@ -1,7 +1,7 @@ /* endpoint_talkers_ipx.c * endpoint_talkers_ipx 2003 Ronnie Sahlberg * - * $Id: endpoint_talkers_ipx.c,v 1.24 2004/05/02 17:25:10 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/endpoint_talkers_table.c b/gtk/endpoint_talkers_table.c index aec06db0b4..b74dce51ba 100644 --- a/gtk/endpoint_talkers_table.c +++ b/gtk/endpoint_talkers_table.c @@ -4,7 +4,7 @@ * endpoint_talkers_table 2003 Ronnie Sahlberg * Helper routines common to all endpoint talkers tap. * - * $Id: endpoint_talkers_table.c,v 1.47 2004/07/13 18:14:00 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/endpoint_talkers_table.h b/gtk/endpoint_talkers_table.h index d92f521a8d..9b8b3c6a43 100644 --- a/gtk/endpoint_talkers_table.h +++ b/gtk/endpoint_talkers_table.h @@ -2,7 +2,7 @@ * endpoint_talkers_table 2003 Ronnie Sahlberg * Helper routines common to all endpoint talkers taps. * - * $Id: endpoint_talkers_table.h,v 1.14 2004/06/05 13:28:13 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/endpoint_talkers_tcpip.c b/gtk/endpoint_talkers_tcpip.c index cf25358406..004ef62a4c 100644 --- a/gtk/endpoint_talkers_tcpip.c +++ b/gtk/endpoint_talkers_tcpip.c @@ -1,7 +1,7 @@ /* endpoint_talkers_tcpip.c * endpoint_talkers_tcpip 2003 Ronnie Sahlberg * - * $Id: endpoint_talkers_tcpip.c,v 1.27 2004/05/02 17:25:10 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/endpoint_talkers_tr.c b/gtk/endpoint_talkers_tr.c index dc904df3e5..cf5708a3a0 100644 --- a/gtk/endpoint_talkers_tr.c +++ b/gtk/endpoint_talkers_tr.c @@ -1,7 +1,7 @@ /* endpoint_talkers_tr.c * endpoint_talkers_tr 2003 Ronnie Sahlberg * - * $Id: endpoint_talkers_tr.c,v 1.26 2004/05/02 17:25:10 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/endpoint_talkers_udpip.c b/gtk/endpoint_talkers_udpip.c index 56de56e028..706990358f 100644 --- a/gtk/endpoint_talkers_udpip.c +++ b/gtk/endpoint_talkers_udpip.c @@ -1,7 +1,7 @@ /* endpoint_talkers_udpip.c * endpoint_talkers_udpip 2003 Ronnie Sahlberg * - * $Id: endpoint_talkers_udpip.c,v 1.27 2004/05/02 17:25:10 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/ethclist.c b/gtk/ethclist.c index 8def115a12..b263c165b7 100644 --- a/gtk/ethclist.c +++ b/gtk/ethclist.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball, Josh MacDonald, * Copyright (C) 1997-1998 Jay Painter <jpaint@serv.net><jpaint@gimp.org> * - * $Id: ethclist.c,v 1.1 2004/01/09 08:36:22 guy Exp $ + * $Id$ * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public diff --git a/gtk/ethclist.h b/gtk/ethclist.h index b90ba1e6b7..9d45f28703 100644 --- a/gtk/ethclist.h +++ b/gtk/ethclist.h @@ -2,7 +2,7 @@ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball, Josh MacDonald * Copyright (C) 1997-1998 Jay Painter <jpaint@serv.net><jpaint@gimp.org> * - * $Id: ethclist.h,v 1.4 2004/06/01 21:56:03 ulfl Exp $ + * $Id$ * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public diff --git a/gtk/fc_stat.c b/gtk/fc_stat.c index f27476ea7c..a5187e526e 100644 --- a/gtk/fc_stat.c +++ b/gtk/fc_stat.c @@ -1,7 +1,7 @@ /* fc_stat.c * fc_stat 2003 Ronnie Sahlberg * - * $Id: fc_stat.c,v 1.34 2004/06/02 07:12:09 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/file_dlg.c b/gtk/file_dlg.c index 947ed555ba..e70de62299 100644 --- a/gtk/file_dlg.c +++ b/gtk/file_dlg.c @@ -1,7 +1,7 @@ /* file_dlg.c * Dialog boxes for handling files * - * $Id: file_dlg.c,v 1.128 2004/07/13 07:15:44 guy Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/file_dlg.h b/gtk/file_dlg.h index 59923ac166..143bce5ef8 100644 --- a/gtk/file_dlg.h +++ b/gtk/file_dlg.h @@ -1,7 +1,7 @@ /* file_dlg.h * Definitions for dialog boxes for handling files * - * $Id: file_dlg.h,v 1.13 2004/06/17 21:53:25 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/filter_prefs.c b/gtk/filter_prefs.c index 0147618be5..c33c387a1c 100644 --- a/gtk/filter_prefs.c +++ b/gtk/filter_prefs.c @@ -3,7 +3,7 @@ * (This used to be a notebook page under "Preferences", hence the * "prefs" in the file name.) * - * $Id: filter_prefs.c,v 1.67 2004/06/05 10:27:38 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/filter_prefs.h b/gtk/filter_prefs.h index 2d2e9aa5c6..8459337329 100644 --- a/gtk/filter_prefs.h +++ b/gtk/filter_prefs.h @@ -3,7 +3,7 @@ * (This used to be a notebook page under "Preferences", hence the * "prefs" in the file name.) * - * $Id: filter_prefs.h,v 1.21 2004/06/05 12:12:13 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/find_dlg.c b/gtk/find_dlg.c index 4bbde48a77..76c5b1e8fe 100644 --- a/gtk/find_dlg.c +++ b/gtk/find_dlg.c @@ -1,7 +1,7 @@ /* find_dlg.c * Routines for "find frame" window * - * $Id: find_dlg.c,v 1.53 2004/05/26 03:49:23 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/find_dlg.h b/gtk/find_dlg.h index c5a89c4c55..41ddfe3c4c 100644 --- a/gtk/find_dlg.h +++ b/gtk/find_dlg.h @@ -1,7 +1,7 @@ /* find_dlg.h * Definitions for "find frame" window * - * $Id: find_dlg.h,v 1.8 2004/06/04 20:05:31 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> diff --git a/gtk/follow_dlg.c b/gtk/follow_dlg.c index e13ff16ed3..dd4518bde2 100644 --- a/gtk/follow_dlg.c +++ b/gtk/follow_dlg.c @@ -1,6 +1,6 @@ /* follow_dlg.c * - * $Id: follow_dlg.c,v 1.69 2004/07/09 23:02:37 guy Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/follow_dlg.h b/gtk/follow_dlg.h index 7316f5bf3d..423da70eab 100644 --- a/gtk/follow_dlg.h +++ b/gtk/follow_dlg.h @@ -1,6 +1,6 @@ /* follow_dlg.c * - * $Id: follow_dlg.h,v 1.6 2004/06/04 20:05:31 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> diff --git a/gtk/font_utils.c b/gtk/font_utils.c index 0242644585..4a5c2590a0 100644 --- a/gtk/font_utils.c +++ b/gtk/font_utils.c @@ -1,7 +1,7 @@ /* font_utils.c * Utilities to use for font manipulation * - * $Id: font_utils.c,v 1.1 2004/06/17 16:35:24 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/font_utils.h b/gtk/font_utils.h index e8a3b5faa7..ac91a43943 100644 --- a/gtk/font_utils.h +++ b/gtk/font_utils.h @@ -1,7 +1,7 @@ /* font_utils.h * Declarations of utilities to use for font manipulation * - * $Id: font_utils.h,v 1.1 2004/06/17 16:35:24 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/goto_dlg.c b/gtk/goto_dlg.c index ef9ade53e1..2199bc1206 100644 --- a/gtk/goto_dlg.c +++ b/gtk/goto_dlg.c @@ -1,7 +1,7 @@ /* goto_dlg.c * Routines for "go to packet" window * - * $Id: goto_dlg.c,v 1.27 2004/06/01 17:33:36 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/goto_dlg.h b/gtk/goto_dlg.h index 0e04ec3b43..0614acd167 100644 --- a/gtk/goto_dlg.h +++ b/gtk/goto_dlg.h @@ -1,7 +1,7 @@ /* goto_dlg.h * Definitions for "go to frame" window * - * $Id: goto_dlg.h,v 1.4 2004/06/04 20:05:31 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> diff --git a/gtk/gsm_a_stat.c b/gtk/gsm_a_stat.c index 7a20d98874..e79910e886 100644 --- a/gtk/gsm_a_stat.c +++ b/gtk/gsm_a_stat.c @@ -5,7 +5,7 @@ * * MUCH code modified from service_response_time_table.c. * - * $Id: gsm_a_stat.c,v 1.18 2004/05/23 23:24:05 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/gsm_map_stat.c b/gtk/gsm_map_stat.c index ebd5e784ec..aac5582da1 100644 --- a/gtk/gsm_map_stat.c +++ b/gtk/gsm_map_stat.c @@ -5,7 +5,7 @@ * * MUCH code modified from service_response_time_table.c. * - * $Id: gsm_map_stat.c,v 1.9 2004/05/23 23:24:05 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/gsm_map_stat.h b/gtk/gsm_map_stat.h index dabede3235..283aac6b69 100644 --- a/gtk/gsm_map_stat.h +++ b/gtk/gsm_map_stat.h @@ -1,6 +1,6 @@ /* gsm_map_stat.h * - * $Id: gsm_map_stat.h,v 1.3 2004/06/05 11:03:14 ulfl Exp $ + * $Id$ * * Copyright 2004, Michael Lum <mlum [AT] telostech.com>, * In association with Telos Technology Inc. diff --git a/gtk/gsm_map_summary.c b/gtk/gsm_map_summary.c index 9071c7fdf9..53c207283b 100644 --- a/gtk/gsm_map_summary.c +++ b/gtk/gsm_map_summary.c @@ -6,7 +6,7 @@ * * Modified from summary_dlg.c * - * $Id: gsm_map_summary.c,v 1.3 2004/05/23 23:24:05 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/gtk_stat_util.c b/gtk/gtk_stat_util.c index 9250a4eb65..3ee77a30e7 100644 --- a/gtk/gtk_stat_util.c +++ b/gtk/gtk_stat_util.c @@ -2,7 +2,7 @@ * gui functions used by stats * Copyright 2003 Lars Roland * - * $Id: gtk_stat_util.c,v 1.6 2004/06/01 21:56:04 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/gtk_stat_util.h b/gtk/gtk_stat_util.h index ee85295fa4..4cbb6a011b 100644 --- a/gtk/gtk_stat_util.h +++ b/gtk/gtk_stat_util.h @@ -2,7 +2,7 @@ * gui functions used by stats * Copyright 2003 Lars Roland * - * $Id: gtk_stat_util.h,v 1.4 2004/06/01 21:56:04 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/gtkglobals.h b/gtk/gtkglobals.h index 3469e8c378..c1226e6cbb 100644 --- a/gtk/gtkglobals.h +++ b/gtk/gtkglobals.h @@ -1,7 +1,7 @@ /* gtkglobals.h * GTK-related Global defines, etc. * - * $Id: gtkglobals.h,v 1.31 2004/07/09 23:02:38 guy Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/gui_prefs.c b/gtk/gui_prefs.c index 1cc621bb55..87eb3a2191 100644 --- a/gtk/gui_prefs.c +++ b/gtk/gui_prefs.c @@ -1,7 +1,7 @@ /* gui_prefs.c * Dialog box for GUI preferences * - * $Id: gui_prefs.c,v 1.77 2004/07/14 08:04:39 guy Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/gui_prefs.h b/gtk/gui_prefs.h index 048cf82e07..b88e0eae28 100644 --- a/gtk/gui_prefs.h +++ b/gtk/gui_prefs.h @@ -1,7 +1,7 @@ /* gui_prefs.h * Definitions for GUI preferences window * - * $Id: gui_prefs.h,v 1.8 2004/06/04 20:05:31 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> diff --git a/gtk/h225_counter.c b/gtk/h225_counter.c index 307f9f9a70..be0f4bd200 100644 --- a/gtk/h225_counter.c +++ b/gtk/h225_counter.c @@ -2,7 +2,7 @@ * h225 message counter for ethereal * Copyright 2003 Lars Roland * - * $Id: h225_counter.c,v 1.22 2004/06/02 07:12:10 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/h225_ras_srt.c b/gtk/h225_ras_srt.c index 3344d67a06..2a9d78cdf8 100644 --- a/gtk/h225_ras_srt.c +++ b/gtk/h225_ras_srt.c @@ -2,7 +2,7 @@ * h225 RAS Service Response Time statistics for ethereal * Copyright 2003 Lars Roland * - * $Id: h225_ras_srt.c,v 1.19 2004/06/02 07:12:10 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/help_dlg.c b/gtk/help_dlg.c index cb9397bb3b..20d1ee1b52 100644 --- a/gtk/help_dlg.c +++ b/gtk/help_dlg.c @@ -1,6 +1,6 @@ /* help_dlg.c * - * $Id: help_dlg.c,v 1.56 2004/06/05 09:57:10 ulfl Exp $ + * $Id$ * * Laurent Deniel <laurent.deniel@free.fr> * diff --git a/gtk/help_dlg.h b/gtk/help_dlg.h index 9e3a687842..df06f21a6b 100644 --- a/gtk/help_dlg.h +++ b/gtk/help_dlg.h @@ -1,6 +1,6 @@ /* help_dlg.h * - * $Id: help_dlg.h,v 1.8 2004/06/04 20:05:31 ulfl Exp $ + * $Id$ * * Laurent Deniel <laurent.deniel@free.fr> * diff --git a/gtk/hostlist_eth.c b/gtk/hostlist_eth.c index e70d1c1312..88c61e346c 100644 --- a/gtk/hostlist_eth.c +++ b/gtk/hostlist_eth.c @@ -1,7 +1,7 @@ /* hostlist_eth.c 2004 Ian Schorr * modified from endpoint_talkers_eth.c 2003 Ronnie Sahlberg * - * $Id: hostlist_eth.c,v 1.6 2004/05/02 21:16:08 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/hostlist_fc.c b/gtk/hostlist_fc.c index 562c815d70..5ac88f55c8 100644 --- a/gtk/hostlist_fc.c +++ b/gtk/hostlist_fc.c @@ -1,7 +1,7 @@ /* hostlist_fc.c 2004 Ian Schorr * modified from endpoint_talkers_fc.c 2003 Ronnie Sahlberg * - * $Id: hostlist_fc.c,v 1.6 2004/05/02 21:16:08 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/hostlist_fddi.c b/gtk/hostlist_fddi.c index 9e890655f6..62098070dc 100644 --- a/gtk/hostlist_fddi.c +++ b/gtk/hostlist_fddi.c @@ -1,7 +1,7 @@ /* hostlist_fddi.c 2004 Ian Schorr * modified from endpoint_talkers_fddi.c 2003 Ronnie Sahlberg * - * $Id: hostlist_fddi.c,v 1.6 2004/05/02 21:16:08 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/hostlist_ip.c b/gtk/hostlist_ip.c index a16210c411..a738f897a8 100644 --- a/gtk/hostlist_ip.c +++ b/gtk/hostlist_ip.c @@ -1,7 +1,7 @@ /* hostlist_ip.c 2004 Ian Schorr * modified from endpoint_talkers_ip.c 2003 Ronnie Sahlberg * - * $Id: hostlist_ip.c,v 1.6 2004/05/02 21:16:08 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/hostlist_ipx.c b/gtk/hostlist_ipx.c index 70e51ad2d2..7d9903456b 100644 --- a/gtk/hostlist_ipx.c +++ b/gtk/hostlist_ipx.c @@ -1,7 +1,7 @@ /* hostlist_ipx.c 2004 Ian Schorr * modified from endpoint_talkers_ipx.c 2003 Ronnie Sahlberg * - * $Id: hostlist_ipx.c,v 1.6 2004/05/02 21:16:08 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/hostlist_table.c b/gtk/hostlist_table.c index dd6b0e997d..8d71c28791 100644 --- a/gtk/hostlist_table.c +++ b/gtk/hostlist_table.c @@ -2,7 +2,7 @@ * modified from endpoint_talkers_table.c 2003 Ronnie Sahlberg * Helper routines common to all host list taps. * - * $Id: hostlist_table.c,v 1.19 2004/07/13 18:14:00 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/hostlist_table.h b/gtk/hostlist_table.h index 63749f2582..4fbb77e960 100644 --- a/gtk/hostlist_table.h +++ b/gtk/hostlist_table.h @@ -2,7 +2,7 @@ * modified from endpoint_talkers_table 2003 Ronnie Sahlberg * Helper routines common to all host talkers taps. * - * $Id: hostlist_table.h,v 1.8 2004/06/05 13:28:13 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/hostlist_tcpip.c b/gtk/hostlist_tcpip.c index 171ddf7167..e47c337ef0 100644 --- a/gtk/hostlist_tcpip.c +++ b/gtk/hostlist_tcpip.c @@ -1,7 +1,7 @@ /* hostlist_tcpip.c 2004 Ian Schorr * modified from endpoint_talkers_tcpip.c 2003 Ronnie Sahlberg * - * $Id: hostlist_tcpip.c,v 1.6 2004/05/02 21:16:09 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/hostlist_tr.c b/gtk/hostlist_tr.c index f3ade56f09..f68d56ea70 100644 --- a/gtk/hostlist_tr.c +++ b/gtk/hostlist_tr.c @@ -1,7 +1,7 @@ /* hostlist_tr.c 2004 Ian Schorr * modified from endpoint_talkers_tr.c 2003 Ronnie Sahlberg * - * $Id: hostlist_tr.c,v 1.6 2004/05/02 21:16:09 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/hostlist_udpip.c b/gtk/hostlist_udpip.c index 01f63366c8..9640c245eb 100644 --- a/gtk/hostlist_udpip.c +++ b/gtk/hostlist_udpip.c @@ -1,7 +1,7 @@ /* hostlist_udpip.c 2004 Ian Schorr * modified from endpoint_talkers_udpip.c 2003 Ronnie Sahlberg * - * $Id: hostlist_udpip.c,v 1.6 2004/05/02 21:16:09 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/http_stat.c b/gtk/http_stat.c index f1fb482456..4a7f9c7031 100644 --- a/gtk/http_stat.c +++ b/gtk/http_stat.c @@ -1,7 +1,7 @@ /* http_stat.c * http_stat 2003 Jean-Michel FAYARD * - * $Id: http_stat.c,v 1.30 2004/05/23 23:24:06 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/io_stat.c b/gtk/io_stat.c index da0e0475c7..912a89dd7d 100644 --- a/gtk/io_stat.c +++ b/gtk/io_stat.c @@ -1,7 +1,7 @@ /* io_stat.c * io_stat 2002 Ronnie Sahlberg * - * $Id: io_stat.c,v 1.76 2004/05/23 23:24:06 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/isprint.h b/gtk/isprint.h index 274fc43e3d..cd4a836120 100644 --- a/gtk/isprint.h +++ b/gtk/isprint.h @@ -2,7 +2,7 @@ * Temporary redefinition of "isprint()" to cope with GTK+ 1.3 and * later using UTF-8 strings * - * $Id: isprint.h,v 1.1 2004/07/09 23:02:38 guy Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/isup_stat.c b/gtk/isup_stat.c index 16c97a6df3..d186cb4fac 100644 --- a/gtk/isup_stat.c +++ b/gtk/isup_stat.c @@ -5,7 +5,7 @@ * * MUCH code modified from service_response_time_table.c. * - * $Id: isup_stat.c,v 1.23 2004/05/23 23:24:06 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/keys.h b/gtk/keys.h index 5433915a11..afa0295f2c 100644 --- a/gtk/keys.h +++ b/gtk/keys.h @@ -1,7 +1,7 @@ /* keys.h * Key definitions for various objects * - * $Id: keys.h,v 1.15 2004/06/01 21:56:04 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/layout_prefs.c b/gtk/layout_prefs.c index 66b229581e..36d1edfe7e 100644 --- a/gtk/layout_prefs.c +++ b/gtk/layout_prefs.c @@ -1,7 +1,7 @@ /* layout_prefs.c * Dialog box for layout preferences * - * $Id: layout_prefs.c,v 1.8 2004/05/05 07:31:05 guy Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/layout_prefs.h b/gtk/layout_prefs.h index 8bc016db84..34fb157633 100644 --- a/gtk/layout_prefs.h +++ b/gtk/layout_prefs.h @@ -1,7 +1,7 @@ /* layout_prefs.h * Definitions for layout preferences window * - * $Id: layout_prefs.h,v 1.6 2004/06/04 20:05:31 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/ldap_stat.c b/gtk/ldap_stat.c index b4a1ddc44e..a48d509bcd 100644 --- a/gtk/ldap_stat.c +++ b/gtk/ldap_stat.c @@ -1,7 +1,7 @@ /* ldap_stat.c * ldap_stat 2003 Ronnie Sahlberg * - * $Id: ldap_stat.c,v 1.22 2004/06/02 07:12:10 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/main.c b/gtk/main.c index d0a3744d02..ab88812f5a 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -1,6 +1,6 @@ /* main.c * - * $Id: main.c,v 1.458 2004/07/13 07:15:44 guy Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/main.h b/gtk/main.h index 205a5fcd8d..3cd7339081 100644 --- a/gtk/main.h +++ b/gtk/main.h @@ -1,7 +1,7 @@ /* main.h * Global defines, etc. * - * $Id: main.h,v 1.56 2004/06/23 01:38:39 guy Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/menu.c b/gtk/menu.c index b642d02b23..7f49b475b0 100644 --- a/gtk/menu.c +++ b/gtk/menu.c @@ -1,1828 +1,1828 @@ -/* menu.c
- * Menu routines
- *
- * $Id: menu.c,v 1.208 2004/07/07 16:26:52 ulfl Exp $
- *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
- * Copyright 1998 Gerald Combs
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <gtk/gtk.h>
-
-#include <string.h>
-
-#include "main.h"
-#include "menu.h"
-#include "tap_menu.h"
-#include <epan/packet.h>
-#include <epan/resolv.h>
-#include "prefs.h"
-#include "about_dlg.h"
-#include "capture_dlg.h"
-#include "color_dlg.h"
-#include "filter_prefs.h"
-#include "dlg_utils.h"
-#include "file_dlg.h"
-#include "find_dlg.h"
-#include "goto_dlg.h"
-#include "summary_dlg.h"
-#include "prefs_dlg.h"
-#include "packet_win.h"
-#include "print.h"
-#include "follow_dlg.h"
-#include "decode_as_dlg.h"
-#include "help_dlg.h"
-#include "supported_protos_dlg.h"
-#include "proto_dlg.h"
-#include "proto_hier_stats_dlg.h"
-#include "keys.h"
-#include <epan/plugins.h>
-#include <epan/epan_dissect.h>
-#include "compat_macros.h"
-#include "toolbar.h"
-#include "gtkglobals.h"
-#include "register.h"
-#include "../tap.h"
-#include "../menu.h"
-#include "../ipproto.h"
-#include "packet_list.h"
-#include "ethclist.h"
-#include "recent.h"
-#include "../ui_util.h"
-#include "proto_draw.h"
-#include "endpoint_talkers_table.h"
-#include "hostlist_table.h"
-#include "simple_dialog.h"
-#include <epan/timestamp.h>
-
-GtkWidget *popup_menu_object;
-
-static void
-clear_menu_recent_capture_file_cmd_cb(GtkWidget *w, gpointer unused _U_);
-
-typedef struct _menu_item {
- char *name;
- gint group;
- gboolean enabled;
- GtkItemFactoryCallback callback;
- gpointer callback_data;
- gboolean (*selected_packet_enabled)(frame_data *, epan_dissect_t *);
- gboolean (*selected_tree_row_enabled)(field_info *);
- GList *children;
-} menu_item_t;
-
-static GList *tap_menu_tree_root = NULL;
-
-static void
-merge_all_tap_menus(GList *node);
-
-#define GTK_MENU_FUNC(a) ((GtkItemFactoryCallback)(a))
-
-static void menus_init(void);
-static void set_menu_sensitivity (GtkItemFactory *, const gchar *, gint);
-static void main_toolbar_show_cb(GtkWidget *w _U_, gpointer d _U_);
-static void filter_toolbar_show_cb(GtkWidget *w _U_, gpointer d _U_);
-static void packet_list_show_cb(GtkWidget *w _U_, gpointer d _U_);
-static void tree_view_show_cb(GtkWidget *w _U_, gpointer d _U_);
-static void byte_view_show_cb(GtkWidget *w _U_, gpointer d _U_);
-static void statusbar_show_cb(GtkWidget *w _U_, gpointer d _U_);
-static void timestamp_absolute_cb(GtkWidget *w _U_, gpointer d _U_);
-static void timestamp_absolute_date_cb(GtkWidget *w _U_, gpointer d _U_);
-static void timestamp_relative_cb(GtkWidget *w _U_, gpointer d _U_);
-static void timestamp_delta_cb(GtkWidget *w _U_, gpointer d _U_);
-static void name_resolution_mac_cb(GtkWidget *w _U_, gpointer d _U_);
-static void name_resolution_network_cb(GtkWidget *w _U_, gpointer d _U_);
-static void name_resolution_transport_cb(GtkWidget *w _U_, gpointer d _U_);
-#ifdef HAVE_LIBPCAP
-static void auto_scroll_live_cb(GtkWidget *w _U_, gpointer d _U_);
-#endif
-
-/* This is the GtkItemFactoryEntry structure used to generate new menus.
- Item 1: The menu path. The letter after the underscore indicates an
- accelerator key once the menu is open.
- Item 2: The accelerator key for the entry
- Item 3: The callback function.
- Item 4: The callback action. This changes the parameters with
- which the function is called. The default is 0.
- Item 5: The item type, used to define what kind of an item it is.
- Here are the possible values:
-
- NULL -> "<Item>"
- "" -> "<Item>"
- "<Title>" -> create a title item
- "<Item>" -> create a simple item
- "<ImageItem>" -> create an item holding an image (gtk2)
- "<StockItem>" -> create an item holding a stock image (gtk2)
- "<CheckItem>" -> create a check item
- "<ToggleItem>" -> create a toggle item
- "<RadioItem>" -> create a radio item
- <path> -> path of a radio item to link against
- "<Separator>" -> create a separator
- "<Tearoff>" -> create a tearoff separator (gtk2)
- "<Branch>" -> create an item to hold sub items (optional)
- "<LastBranch>" -> create a right justified branch
- Item 6: extra data needed for ImageItem and StockItem (gtk2)
- */
-
-/* main menu */
-static GtkItemFactoryEntry menu_items[] =
-{
- ITEM_FACTORY_ENTRY("/_File", NULL, NULL, 0, "<Branch>", NULL),
- ITEM_FACTORY_STOCK_ENTRY("/File/_Open...", "<control>O", file_open_cmd_cb,
- 0, GTK_STOCK_OPEN),
- ITEM_FACTORY_ENTRY("/File/Open _Recent", NULL, NULL, 0, "<Branch>", NULL),
- ITEM_FACTORY_ENTRY("/File/_Merge...", NULL, file_merge_cmd_cb, 0, NULL, NULL),
- ITEM_FACTORY_STOCK_ENTRY("/File/_Close", "<control>W", file_close_cmd_cb,
- 0, GTK_STOCK_CLOSE),
- ITEM_FACTORY_ENTRY("/File/<separator>", NULL, NULL, 0, "<Separator>", NULL),
- ITEM_FACTORY_STOCK_ENTRY("/File/_Save", "<control>S", file_save_cmd_cb,
- 0, GTK_STOCK_SAVE),
- ITEM_FACTORY_STOCK_ENTRY("/File/Save _As...", "<shift><control>S", file_save_as_cmd_cb,
- 0, GTK_STOCK_SAVE_AS),
- ITEM_FACTORY_ENTRY("/File/<separator>", NULL, NULL, 0, "<Separator>", NULL),
- ITEM_FACTORY_ENTRY("/File/_Export", NULL, NULL, 0, "<Branch>", NULL),
- ITEM_FACTORY_ENTRY("/File/Export/as \"Plain _Text\" file...", NULL, export_text_cmd_cb,
- 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/File/Export/as \"_PostScript\" file...", NULL, export_ps_cmd_cb,
- 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/File/Export/as XML - \"P_SML\" (packet summary) file...", NULL, export_psml_cmd_cb,
- 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/File/Export/as XML - \"P_DML\" (packet details) file...", NULL, export_pdml_cmd_cb,
- 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/File/Export/<separator>", NULL, NULL, 0, "<Separator>", NULL),
- ITEM_FACTORY_ENTRY("/File/Export/Selected Packet _Bytes...", "<control>H", savehex_cb,
- 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/File/<separator>", NULL, NULL, 0, "<Separator>", NULL),
- ITEM_FACTORY_STOCK_ENTRY("/File/_Print...", "<control>P", file_print_cmd_cb,
- 0, GTK_STOCK_PRINT),
- ITEM_FACTORY_ENTRY("/File/<separator>", NULL, NULL, 0, "<Separator>", NULL),
- ITEM_FACTORY_STOCK_ENTRY("/File/_Quit", "<control>Q", file_quit_cmd_cb,
- 0, GTK_STOCK_QUIT),
- ITEM_FACTORY_ENTRY("/_Edit", NULL, NULL, 0, "<Branch>", NULL),
-#if 0
- /* Un-#if this when we actually implement Cut/Copy/Paste. */
- ITEM_FACTORY_STOCK_ENTRY("/Edit/Cut", "<control>X", NULL,
- 0, GTK_STOCK_CUT),
- ITEM_FACTORY_STOCK_ENTRY("/Edit/Copy", "<control>C", NULL,
- 0, GTK_STOCK_COPY),
- ITEM_FACTORY_STOCK_ENTRY("/Edit/Paste", "<control>V", NULL,
- 0, GTK_STOCK_PASTE),
- ITEM_FACTORY_ENTRY("/Edit/<separator>", NULL, NULL, 0, "<Separator>"),
-#endif
- ITEM_FACTORY_STOCK_ENTRY("/Edit/_Find Packet...", "<control>F",
- find_frame_cb, 0, GTK_STOCK_FIND),
- ITEM_FACTORY_STOCK_ENTRY("/Edit/Find Ne_xt", "<control>N", find_next_cb,
- 0, GTK_STOCK_GO_FORWARD),
- ITEM_FACTORY_STOCK_ENTRY("/Edit/Find Pre_vious", "<control>B",
- find_previous_cb, 0, GTK_STOCK_GO_BACK),
- ITEM_FACTORY_ENTRY("/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL),
- ITEM_FACTORY_ENTRY("/Edit/_Time Reference", NULL, NULL, 0, "<Branch>", NULL),
- ITEM_FACTORY_ENTRY("/Edit/Time Reference/Set Time Reference (toggle)", "<control>T", reftime_frame_cb, REFTIME_TOGGLE, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Edit/Time Reference/Find Next", NULL, reftime_frame_cb, REFTIME_FIND_NEXT, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Edit/Time Reference/Find Previous", NULL, reftime_frame_cb, REFTIME_FIND_PREV, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Edit/_Mark Packet", "<control>M", mark_frame_cb,
- 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Edit/Mark _All Packets", NULL, mark_all_frames_cb,
- 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Edit/_Unmark All Packets", NULL, unmark_all_frames_cb,
- 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL),
- ITEM_FACTORY_STOCK_ENTRY("/Edit/_Preferences...", "<shift><control>P", prefs_cb,
- 0, GTK_STOCK_PREFERENCES),
- ITEM_FACTORY_ENTRY("/_View", NULL, NULL, 0, "<Branch>", NULL),
- ITEM_FACTORY_ENTRY("/View/_Main Toolbar", NULL, main_toolbar_show_cb, 0, "<CheckItem>", NULL),
- ITEM_FACTORY_ENTRY("/View/_Filter Toolbar", NULL, filter_toolbar_show_cb, 0, "<CheckItem>", NULL),
- ITEM_FACTORY_ENTRY("/View/_Statusbar", NULL, statusbar_show_cb, 0, "<CheckItem>", NULL),
- ITEM_FACTORY_ENTRY("/View/<separator>", NULL, NULL, 0, "<Separator>", NULL),
- ITEM_FACTORY_ENTRY("/View/Packet _List", NULL, packet_list_show_cb, 0, "<CheckItem>", NULL),
- ITEM_FACTORY_ENTRY("/View/Packet _Details", NULL, tree_view_show_cb, 0, "<CheckItem>", NULL),
- ITEM_FACTORY_ENTRY("/View/Packet _Bytes", NULL, byte_view_show_cb, 0, "<CheckItem>", NULL),
- ITEM_FACTORY_ENTRY("/View/<separator>", NULL, NULL, 0, "<Separator>", NULL),
- ITEM_FACTORY_ENTRY("/View/_Time Display Format", NULL, NULL, 0, "<Branch>", NULL),
- ITEM_FACTORY_ENTRY("/View/Time Display Format/Time of Day", NULL, timestamp_absolute_cb,
- 0, "<RadioItem>", NULL),
- ITEM_FACTORY_ENTRY("/View/Time Display Format/Date and Time of Day", NULL, timestamp_absolute_date_cb,
- 0, "/View/Time Display Format/Time of Day", NULL),
- ITEM_FACTORY_ENTRY("/View/Time Display Format/Seconds Since Beginning of Capture", NULL, timestamp_relative_cb,
- 0, "/View/Time Display Format/Time of Day", NULL),
- ITEM_FACTORY_ENTRY("/View/Time Display Format/Seconds Since Previous Packet", NULL, timestamp_delta_cb,
- 0, "/View/Time Display Format/Time of Day", NULL),
- ITEM_FACTORY_ENTRY("/View/Name Resol_ution", NULL, NULL, 0, "<Branch>", NULL),
- ITEM_FACTORY_ENTRY("/View/Name Resolution/_Resolve Name", NULL, resolve_name_cb, 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/View/Name Resolution/<separator>", NULL, NULL, 0, "<Separator>", NULL),
- ITEM_FACTORY_ENTRY("/View/Name Resolution/Enable for _MAC Layer", NULL, name_resolution_mac_cb, 0, "<CheckItem>", NULL),
- ITEM_FACTORY_ENTRY("/View/Name Resolution/Enable for _Network Layer", NULL, name_resolution_network_cb, 0, "<CheckItem>", NULL),
- ITEM_FACTORY_ENTRY("/View/Name Resolution/Enable for _Transport Layer", NULL, name_resolution_transport_cb, 0, "<CheckItem>", NULL),
-#ifdef HAVE_LIBPCAP
- ITEM_FACTORY_ENTRY("/View/Auto Scroll in Li_ve Capture", NULL, auto_scroll_live_cb, 0, "<CheckItem>", NULL),
-#endif
- ITEM_FACTORY_ENTRY("/View/<separator>", NULL, NULL, 0, "<Separator>", NULL),
- ITEM_FACTORY_STOCK_ENTRY("/View/_Zoom In", "<control>plus", view_zoom_in_cb,
- 0, GTK_STOCK_ZOOM_IN),
- ITEM_FACTORY_STOCK_ENTRY("/View/Zoom _Out", "<control>minus", view_zoom_out_cb,
- 0, GTK_STOCK_ZOOM_OUT),
- ITEM_FACTORY_STOCK_ENTRY("/View/_Normal Size", "<control>equal", view_zoom_100_cb,
- 0, GTK_STOCK_ZOOM_100),
- ITEM_FACTORY_ENTRY("/View/<separator>", NULL, NULL, 0, "<Separator>", NULL),
- ITEM_FACTORY_ENTRY("/View/Collapse _All", NULL, collapse_all_cb,
- 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/View/_Expand All", NULL, expand_all_cb,
- 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/View/Expand Tree", NULL, expand_tree_cb, 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/View/<separator>", NULL, NULL, 0, "<Separator>", NULL),
- ITEM_FACTORY_STOCK_ENTRY("/View/_Coloring Rules...", NULL, color_display_cb,
- 0, GTK_STOCK_SELECT_COLOR),
- ITEM_FACTORY_ENTRY("/View/<separator>", NULL, NULL, 0, "<Separator>", NULL),
- ITEM_FACTORY_ENTRY("/View/Show Packet in New _Window", NULL,
- new_window_cb, 0, NULL, NULL),
- ITEM_FACTORY_STOCK_ENTRY("/View/_Reload", "<control>R", file_reload_cmd_cb,
- 0, GTK_STOCK_REFRESH),
- ITEM_FACTORY_ENTRY("/_Go", NULL, NULL, 0, "<Branch>", NULL),
- ITEM_FACTORY_STOCK_ENTRY("/Go/_Go to Packet...", "<control>G",
- goto_frame_cb, 0, GTK_STOCK_JUMP_TO),
- ITEM_FACTORY_ENTRY("/Go/Go to _Corresponding Packet", NULL, goto_framenum_cb,
- 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Go/<separator>", NULL, NULL, 0, "<Separator>", NULL),
- ITEM_FACTORY_STOCK_ENTRY("/Go/_First Packet", NULL,
- goto_top_frame_cb, 0, GTK_STOCK_GOTO_TOP),
- ITEM_FACTORY_STOCK_ENTRY("/Go/_Last Packet", NULL,
- goto_bottom_frame_cb, 0, GTK_STOCK_GOTO_BOTTOM),
-#ifdef HAVE_LIBPCAP
- ITEM_FACTORY_ENTRY("/_Capture", NULL, NULL, 0, "<Branch>", NULL),
- ITEM_FACTORY_STOCK_ENTRY("/Capture/_Start...", "<control>K",
- capture_prep_cb, 0, ETHEREAL_STOCK_CAPTURE_START),
- ITEM_FACTORY_STOCK_ENTRY("/Capture/S_top", "<control>E", capture_stop_cb,
- 0, GTK_STOCK_STOP),
- ITEM_FACTORY_ENTRY("/Capture/_Interfaces...", NULL,
- capture_if_cb, 0, NULL, NULL),
- ITEM_FACTORY_STOCK_ENTRY("/Capture/_Capture Filters...", NULL, cfilter_dialog_cb,
- 0, ETHEREAL_STOCK_CAPTURE_FILTER),
-#endif /* HAVE_LIBPCAP */
- ITEM_FACTORY_ENTRY("/_Analyze", NULL, NULL, 0, "<Branch>", NULL),
- ITEM_FACTORY_STOCK_ENTRY("/Analyze/_Display Filters...", NULL, dfilter_dialog_cb,
- 0, ETHEREAL_STOCK_DISPLAY_FILTER),
- ITEM_FACTORY_ENTRY("/Analyze/Appl_y as Filter", NULL, NULL, 0, "<Branch>", NULL),
- ITEM_FACTORY_ENTRY("/Analyze/Apply as Filter/_Selected", NULL, match_selected_ptree_cb,
- MATCH_SELECTED_REPLACE|MATCH_SELECTED_APPLY_NOW, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Analyze/Apply as Filter/_Not Selected", NULL, match_selected_ptree_cb,
- MATCH_SELECTED_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Analyze/Apply as Filter/... _and Selected", NULL, match_selected_ptree_cb,
- MATCH_SELECTED_AND|MATCH_SELECTED_APPLY_NOW, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Analyze/Apply as Filter/... _or Selected", NULL, match_selected_ptree_cb,
- MATCH_SELECTED_OR|MATCH_SELECTED_APPLY_NOW, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Analyze/Apply as Filter/... a_nd not Selected", NULL, match_selected_ptree_cb,
- MATCH_SELECTED_AND_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Analyze/Apply as Filter/... o_r not Selected", NULL, match_selected_ptree_cb,
- MATCH_SELECTED_OR_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Analyze/_Prepare a Filter", NULL, NULL, 0, "<Branch>", NULL),
- ITEM_FACTORY_ENTRY("/Analyze/Prepare a Filter/_Selected", NULL, match_selected_ptree_cb,
- MATCH_SELECTED_REPLACE, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Analyze/Prepare a Filter/_Not Selected", NULL, match_selected_ptree_cb,
- MATCH_SELECTED_NOT, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Analyze/Prepare a Filter/... _and Selected", NULL, match_selected_ptree_cb,
- MATCH_SELECTED_AND, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Analyze/Prepare a Filter/... _or Selected", NULL, match_selected_ptree_cb,
- MATCH_SELECTED_OR, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Analyze/Prepare a Filter/... a_nd not Selected", NULL, match_selected_ptree_cb,
- MATCH_SELECTED_AND_NOT, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Analyze/Prepare a Filter/... o_r not Selected", NULL, match_selected_ptree_cb,
- MATCH_SELECTED_OR_NOT, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Analyze/<separator>", NULL, NULL, 0, "<Separator>", NULL),
- ITEM_FACTORY_ENTRY("/Analyze/_Enabled Protocols...", "<shift><control>R", proto_cb, 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Analyze/Decode _As...", NULL, decode_as_cb,
- 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Analyze/_User Specified Decodes...", NULL,
- decode_show_cb, 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Analyze/<separator>", NULL, NULL, 0, "<Separator>", NULL),
- ITEM_FACTORY_ENTRY("/Analyze/_Follow TCP Stream", NULL,
- follow_stream_cb, 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/_Statistics", NULL, NULL, 0, "<Branch>", NULL),
- ITEM_FACTORY_ENTRY("/Statistics/_Summary", NULL, summary_open_cb, 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Statistics/_Protocol Hierarchy", NULL,
- proto_hier_stats_cb, 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Statistics/Conversations", NULL,
- init_ett_notebook_cb, 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Statistics/Endpoints", NULL,
- init_hostlist_notebook_cb, 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/_Help", NULL, NULL, 0, "<Branch>", NULL),
- ITEM_FACTORY_STOCK_ENTRY("/Help/_Contents", "F1", help_cb, 0, GTK_STOCK_HELP),
- ITEM_FACTORY_ENTRY("/Help/_Supported Protocols", NULL, supported_cb, 0, NULL, NULL),
-#if (GLIB_MAJOR_VERSION >= 2)
- /* currently, glib1.x can't start a webbrowser, see webbrowser.c for details */
- ITEM_FACTORY_ENTRY("/Help/Manual Pages", NULL, NULL, 0, "<Branch>", NULL),
- ITEM_FACTORY_ENTRY("/Help/Manual Pages/Ethereal", NULL, url_localpage_cb, LOCALPAGE_MAN_ETHEREAL, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Help/Manual Pages/Ethereal Filter", NULL, url_localpage_cb, LOCALPAGE_MAN_ETHEREAL_FILTER, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Help/Manual Pages/<separator>", NULL, NULL, 0, "<Separator>", NULL),
- ITEM_FACTORY_ENTRY("/Help/Manual Pages/Tethereal", NULL, url_localpage_cb, LOCALPAGE_MAN_TETHEREAL, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Help/Manual Pages/Mergecap", NULL, url_localpage_cb, LOCALPAGE_MAN_MERGECAP, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Help/Manual Pages/Editcap", NULL, url_localpage_cb, LOCALPAGE_MAN_EDITCAP, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Help/Manual Pages/Text2pcap", NULL, url_localpage_cb, LOCALPAGE_MAN_TEXT2PCAP, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Help/Ethereal Online", NULL, NULL, 0, "<Branch>", NULL),
- ITEM_FACTORY_STOCK_ENTRY("/Help/Ethereal Online/Home Page", NULL, url_onlinepage_cb, ONLINEPAGE_HOME, GTK_STOCK_HOME),
- ITEM_FACTORY_ENTRY("/Help/Ethereal Online/User's Guide", NULL, url_onlinepage_cb, ONLINEPAGE_USERGUIDE, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Help/Ethereal Online/FAQ's", NULL, url_onlinepage_cb, ONLINEPAGE_FAQ, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Help/Ethereal Online/Downloads", NULL, url_onlinepage_cb, ONLINEPAGE_DOWNLOAD, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Help/Ethereal Online/Example Files", NULL, url_onlinepage_cb, ONLINEPAGE_SAMPLE, NULL, NULL),
-#endif
- ITEM_FACTORY_ENTRY("/Help/<separator>", NULL, NULL, 0, "<Separator>", NULL),
- ITEM_FACTORY_ENTRY("/Help/_About Ethereal", NULL, about_ethereal_cb,
- 0, NULL, NULL)
-};
-
-
-/* calculate the number of menu_items */
-static int nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]);
-
-/* packet list popup */
-static GtkItemFactoryEntry packet_list_menu_items[] =
-{
- ITEM_FACTORY_ENTRY("/Follow TCP Stream", NULL, follow_stream_cb,
- 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Decode As...", NULL, decode_as_cb, 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Display Filters...", NULL, dfilter_dialog_cb,
- 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/<separator>", NULL, NULL, 0, "<Separator>", NULL),
- ITEM_FACTORY_ENTRY("/Mark Packet", NULL, mark_frame_cb, 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Time Reference", NULL, NULL, 0, "<Branch>", NULL),
- ITEM_FACTORY_ENTRY("/Time Reference/Set Time Reference (toggle)", NULL, reftime_frame_cb, REFTIME_TOGGLE, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Time Reference/Find Next", NULL, reftime_frame_cb, REFTIME_FIND_NEXT, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Time Reference/Find Previous", NULL, reftime_frame_cb, REFTIME_FIND_PREV, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Apply as Filter", NULL, NULL, 0, "<Branch>", NULL),
- ITEM_FACTORY_ENTRY("/Apply as Filter/_Selected", NULL, match_selected_plist_cb,
- MATCH_SELECTED_REPLACE|MATCH_SELECTED_APPLY_NOW, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Apply as Filter/_Not Selected", NULL, match_selected_plist_cb,
- MATCH_SELECTED_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Apply as Filter/... _and Selected", NULL, match_selected_plist_cb,
- MATCH_SELECTED_AND|MATCH_SELECTED_APPLY_NOW, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Apply as Filter/... _or Selected", NULL, match_selected_plist_cb,
- MATCH_SELECTED_OR|MATCH_SELECTED_APPLY_NOW, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Apply as Filter/... a_nd not Selected", NULL, match_selected_plist_cb,
- MATCH_SELECTED_AND_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Apply as Filter/... o_r not Selected", NULL, match_selected_plist_cb,
- MATCH_SELECTED_OR_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL),
-
- ITEM_FACTORY_ENTRY("/Prepare a Filter", NULL, NULL, 0, "<Branch>", NULL),
- ITEM_FACTORY_ENTRY("/Prepare a Filter/_Selected", NULL, match_selected_plist_cb,
- MATCH_SELECTED_REPLACE, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Prepare a Filter/_Not Selected", NULL, match_selected_plist_cb,
- MATCH_SELECTED_NOT, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Prepare a Filter/... _and Selected", NULL, match_selected_plist_cb,
- MATCH_SELECTED_AND, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Prepare a Filter/... _or Selected", NULL, match_selected_plist_cb,
- MATCH_SELECTED_OR, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Prepare a Filter/... a_nd not Selected", NULL, match_selected_plist_cb,
- MATCH_SELECTED_AND_NOT, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Prepare a Filter/... o_r not Selected", NULL, match_selected_plist_cb,
- MATCH_SELECTED_OR_NOT, NULL, NULL),
-
- ITEM_FACTORY_ENTRY("/<separator>", NULL, NULL, 0, "<Separator>", NULL),
- ITEM_FACTORY_ENTRY("/Coloring Rules...", NULL, color_display_cb,
- 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Print...", NULL, file_print_cmd_cb, 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Show Packet in New Window", NULL, new_window_cb,
- 0, NULL, NULL),
-};
-
-static GtkItemFactoryEntry tree_view_menu_items[] =
-{
- ITEM_FACTORY_ENTRY("/Follow TCP Stream", NULL, follow_stream_cb,
- 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Decode As...", NULL, decode_as_cb, 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Display Filters...", NULL, dfilter_dialog_cb,
- 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/<separator>", NULL, NULL, 0, "<Separator>", NULL),
- ITEM_FACTORY_ENTRY("/_Resolve Name", NULL, resolve_name_cb, 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/_Go to Corresponding Packet", NULL, goto_framenum_cb, 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/_Export Selected Packet Bytes...", NULL, savehex_cb,
- 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Protocol Preferences...", NULL, properties_cb,
- 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Apply as Filter", NULL, NULL, 0, "<Branch>", NULL),
- ITEM_FACTORY_ENTRY("/Apply as Filter/_Selected", NULL, match_selected_ptree_cb,
- MATCH_SELECTED_REPLACE|MATCH_SELECTED_APPLY_NOW, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Apply as Filter/_Not Selected", NULL, match_selected_ptree_cb,
- MATCH_SELECTED_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Apply as Filter/... _and Selected", NULL, match_selected_ptree_cb,
- MATCH_SELECTED_AND|MATCH_SELECTED_APPLY_NOW, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Apply as Filter/... _or Selected", NULL, match_selected_ptree_cb,
- MATCH_SELECTED_OR|MATCH_SELECTED_APPLY_NOW, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Apply as Filter/... a_nd not Selected", NULL, match_selected_ptree_cb,
- MATCH_SELECTED_AND_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Apply as Filter/... o_r not Selected", NULL, match_selected_ptree_cb,
- MATCH_SELECTED_OR_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL),
-
- ITEM_FACTORY_ENTRY("/Prepare a Filter", NULL, NULL, 0, "<Branch>", NULL),
- ITEM_FACTORY_ENTRY("/Prepare a Filter/_Selected", NULL, match_selected_ptree_cb,
- MATCH_SELECTED_REPLACE, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Prepare a Filter/_Not Selected", NULL, match_selected_ptree_cb,
- MATCH_SELECTED_NOT, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Prepare a Filter/... _and Selected", NULL, match_selected_ptree_cb,
- MATCH_SELECTED_AND, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Prepare a Filter/... _or Selected", NULL, match_selected_ptree_cb,
- MATCH_SELECTED_OR, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Prepare a Filter/... a_nd not Selected", NULL, match_selected_ptree_cb,
- MATCH_SELECTED_AND_NOT, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Prepare a Filter/... o_r not Selected", NULL, match_selected_ptree_cb,
- MATCH_SELECTED_OR_NOT, NULL, NULL),
- ITEM_FACTORY_ENTRY("/<separator>", NULL, NULL, 0, "<Separator>", NULL),
- ITEM_FACTORY_ENTRY("/Collapse All", NULL, collapse_all_cb, 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Expand All", NULL, expand_all_cb, 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Expand Tree", NULL, expand_tree_cb, 0, NULL, NULL)
-};
-
-static GtkItemFactoryEntry hexdump_menu_items[] =
-{
- ITEM_FACTORY_ENTRY("/Follow TCP Stream", NULL, follow_stream_cb,
- 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Decode As...", NULL, decode_as_cb, 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Display Filters...", NULL, dfilter_dialog_cb,
- 0, NULL, NULL),
- ITEM_FACTORY_ENTRY("/Export Selected Packet Bytes...", NULL, savehex_cb,
- 0, NULL, NULL)
-};
-
-static int initialize = TRUE;
-static GtkItemFactory *main_menu_factory = NULL;
-static GtkItemFactory *packet_list_menu_factory = NULL;
-static GtkItemFactory *tree_view_menu_factory = NULL;
-static GtkItemFactory *hexdump_menu_factory = NULL;
-
-static GSList *popup_menu_list = NULL;
-
-static GtkAccelGroup *grp;
-
-GtkWidget *
-main_menu_new(GtkAccelGroup ** table) {
- GtkWidget *menubar;
-
- grp = gtk_accel_group_new();
-
- if (initialize)
- menus_init();
-
- menubar = main_menu_factory->widget;
-
- if (table)
- *table = grp;
-
- return menubar;
-}
-
-static void
-menus_init(void) {
- if (initialize) {
- initialize = FALSE;
-
- /* popup */
- packet_list_menu_factory = gtk_item_factory_new(GTK_TYPE_MENU, "<main>", NULL);
- popup_menu_object = gtk_menu_new();
- gtk_item_factory_create_items_ac(packet_list_menu_factory, sizeof(packet_list_menu_items)/sizeof(packet_list_menu_items[0]), packet_list_menu_items, popup_menu_object, 2);
- OBJECT_SET_DATA(popup_menu_object, PM_PACKET_LIST_KEY,
- packet_list_menu_factory->widget);
- popup_menu_list = g_slist_append((GSList *)popup_menu_list, packet_list_menu_factory);
-
- tree_view_menu_factory = gtk_item_factory_new(GTK_TYPE_MENU, "<main>", NULL);
- gtk_item_factory_create_items_ac(tree_view_menu_factory, sizeof(tree_view_menu_items)/sizeof(tree_view_menu_items[0]), tree_view_menu_items, popup_menu_object, 2);
- OBJECT_SET_DATA(popup_menu_object, PM_TREE_VIEW_KEY,
- tree_view_menu_factory->widget);
- popup_menu_list = g_slist_append((GSList *)popup_menu_list, tree_view_menu_factory);
-
- hexdump_menu_factory = gtk_item_factory_new(GTK_TYPE_MENU, "<main>", NULL);
- gtk_item_factory_create_items_ac(hexdump_menu_factory, sizeof(hexdump_menu_items)/sizeof(hexdump_menu_items[0]), hexdump_menu_items, popup_menu_object, 2);
- OBJECT_SET_DATA(popup_menu_object, PM_HEXDUMP_KEY,
- hexdump_menu_factory->widget);
- popup_menu_list = g_slist_append((GSList *)popup_menu_list, hexdump_menu_factory);
-
- /* main */
- main_menu_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", grp);
- gtk_item_factory_create_items_ac(main_menu_factory, nmenu_items, menu_items, NULL, 2);
-
- merge_all_tap_menus(tap_menu_tree_root);
-
- /* Initialize enabled/disabled state of menu items */
- set_menus_for_unsaved_capture_file(FALSE);
- set_menus_for_capture_file(FALSE);
-#if 0
- /* Un-#if this when we actually implement Cut/Copy/Paste.
- Then make sure you enable them when they can be done. */
- set_menu_sensitivity(main_menu_factory, "/Edit/Cut", FALSE);
- set_menu_sensitivity(main_menu_factory, "/Edit/Copy", FALSE);
- set_menu_sensitivity(main_menu_factory, "/Edit/Paste", FALSE);
-#endif
-
- set_menus_for_captured_packets(FALSE);
- set_menus_for_selected_packet(&cfile);
- set_menus_for_selected_tree_row(&cfile);
-
- /* init with an empty recent files list */
- clear_menu_recent_capture_file_cmd_cb(NULL, NULL);
- }
-}
-
-
-gint tap_menu_item_add_compare(gconstpointer a, gconstpointer b)
-{
- return strcmp(
- ((const menu_item_t *) a)->name,
- ((const menu_item_t *) b)->name);
-}
-
-
-/* add a menuitem below the current node */
-GList * tap_menu_item_add(
- char *name,
- gint group,
- GtkItemFactoryCallback callback,
- gboolean (*selected_packet_enabled)(frame_data *, epan_dissect_t *),
- gboolean (*selected_tree_row_enabled)(field_info *),
- gpointer callback_data,
- GList *curnode)
-{
- menu_item_t *curr;
- menu_item_t *child;
-
-
- child = g_malloc(sizeof (menu_item_t));
- child->group = group;
- child->name = name;
- child->callback = callback;
- child->selected_packet_enabled = selected_packet_enabled;
- child->selected_tree_row_enabled = selected_tree_row_enabled;
- child->callback_data = callback_data;
- child->enabled = FALSE;
- child->children = NULL;
-
- /* insert the new child node into the parent */
- curr = curnode->data;
- curr->children = g_list_insert_sorted(curr->children, child, tap_menu_item_add_compare);
-
- /* return the new node */
- /* XXX: improve this */
- return g_list_find(curr->children, child);
-}
-
-/*
- * Add a new menu item for a tap.
- * This must be called after we've created the main menu, so it can't
- * be called from the routine that registers taps - we have to introduce
- * another per-tap registration routine.
- *
- * "callback" gets called when the menu item is selected; it should do
- * the work of creating the tap window.
- *
- * "selected_packet_enabled" gets called by "set_menus_for_selected_packet()";
- * it's passed a Boolean that's TRUE if a packet is selected and FALSE
- * otherwise, and should return TRUE if the tap will work now (which
- * might depend on whether a packet is selected and, if one is, on the
- * packet) and FALSE if not.
- *
- * "selected_tree_row_enabled" gets called by
- * "set_menus_for_selected_tree_row()"; it's passed a Boolean that's TRUE if
- * a protocol tree row is selected and FALSE otherwise, and should return
- * TRUE if the tap will work now (which might depend on whether a tree row
- * is selected and, if one is, on the tree row) and FALSE if not.
- */
-void
-register_tap_menu_item(
- char *name,
- REGISTER_TAP_GROUP_E group,
- GtkItemFactoryCallback callback,
- gboolean (*selected_packet_enabled)(frame_data *, epan_dissect_t *),
- gboolean (*selected_tree_row_enabled)(field_info *),
- gpointer callback_data)
-{
- /*static const char toolspath[] = "/Statistics/";*/
- char *toolspath;
- char *p;
- char *menupath;
- size_t menupathlen;
- menu_item_t *child;
- GList *curnode;
- GList *childnode;
-
- /*
- * The menu path must be relative.
- */
- g_assert(*name != '/');
-
- switch(group) {
- case(REGISTER_TAP_GROUP_GENERIC): toolspath = "/Statistics/"; break;
- case(REGISTER_TAP_GROUP_CONVERSATION_LIST): toolspath = "/Statistics/_Conversation List/"; break;
- case(REGISTER_TAP_GROUP_ENDPOINT_LIST): toolspath = "/Statistics/_Endpoint List/"; break;
- case(REGISTER_TAP_GROUP_RESPONSE_TIME): toolspath = "/Statistics/Service _Response Time/"; break;
- case(REGISTER_TAP_GROUP_NONE): toolspath = "/Statistics/"; break;
- default:
- g_assert(0);
- toolspath = NULL;
- }
-
- /* add the (empty) root node, if not already done */
- if(tap_menu_tree_root == NULL) {
- child = g_malloc0(sizeof (menu_item_t));
- tap_menu_tree_root = g_list_append(NULL, child);
- }
-
- /*
- * Create any submenus required.
- */
- curnode = tap_menu_tree_root;
- p = name;
- while ((p = strchr(p, '/')) != NULL) {
- /*
- * OK, everything between "name" and "p" is
- * a menu relative subtree into which the menu item
- * will be placed.
- *
- * Construct the absolute path name of that subtree.
- */
- menupathlen = strlen(toolspath) + 1 + (p - name);
- menupath = g_malloc(menupathlen);
- strcpy(menupath, toolspath);
- strncat(menupath, name, p - name);
-
- /*
- * Does there exist an entry with that path at this
- * level of the Analyze menu tree?
- */
- child = curnode->data;
- for (childnode = child->children; childnode != NULL; childnode = childnode->next) {
- child = childnode->data;
- if (strcmp(child->name, menupath) == 0)
- break;
- }
- if (childnode == NULL) {
- /*
- * No. Create such an item as a subtree, and
- * add it to the Tools menu tree.
- */
- childnode = tap_menu_item_add(
- menupath, group, NULL, NULL ,NULL, NULL, curnode);
- } else {
- /*
- * Yes. We don't need this "menupath" any longer.
- */
- g_free(menupath);
- }
- curnode = childnode;
-
- /*
- * Skip over the '/' we found.
- */
- p++;
- }
-
- /*
- * Construct the main menu path for the menu item.
- */
- menupathlen = strlen(toolspath) + 1 + strlen(name);
- menupath = g_malloc(menupathlen);
- strcpy(menupath, toolspath);
- strcat(menupath, name);
-
- /*
- * Construct an item factory entry for the item, and add it to
- * the main menu.
- */
- tap_menu_item_add(
- menupath, group, callback,
- selected_packet_enabled, selected_tree_row_enabled,
- callback_data, curnode);
-}
-
-
-guint merge_tap_menus_layered(GList *node, gint group) {
- GtkItemFactoryEntry *entry;
- GList *child;
- guint added = 0;
- menu_item_t *node_data = node->data;
-
- /*
- * Is this a leaf node or an interior node?
- */
- if (node_data->children == NULL) {
- /*
- * It's a leaf node.
- */
-
- /*
- * The root node doesn't correspond to a menu tree item; it
- * has a null name pointer.
- */
- if (node_data->name != NULL && group == node_data->group) {
- entry = g_malloc0(sizeof (GtkItemFactoryEntry));
- entry->path = node_data->name;
- entry->callback = node_data->callback;
- gtk_item_factory_create_item(main_menu_factory, entry, node_data->callback_data, 2);
- set_menu_sensitivity(main_menu_factory, node_data->name, FALSE); /* no capture file yet */
- added++;
- }
- } else {
- /*
- * It's an interior node; call
- * "merge_tap_menus_layered()" on all its children
- */
-
- /*
- * The root node doesn't correspond to a menu tree item; it
- * has a null name pointer.
- */
- if (node_data->name != NULL && group == node_data->group) {
- entry = g_malloc0(sizeof (GtkItemFactoryEntry));
- entry->path = node_data->name;
- entry->item_type = "<Branch>";
- gtk_item_factory_create_item(main_menu_factory, entry,
- NULL, 2);
- set_menu_sensitivity(main_menu_factory, node_data->name,
- FALSE); /* no children yet */
- added++;
- }
-
- for (child = node_data->children; child != NULL; child =
- child->next) {
- added += merge_tap_menus_layered(child, group);
- }
- }
-
- return added;
-}
-
-
-void merge_all_tap_menus(GList *node) {
- GtkItemFactoryEntry *entry;
-
- entry = g_malloc0(sizeof (GtkItemFactoryEntry));
- entry->item_type = "<Separator>";
- entry->path = "/Statistics/";
-
- /*
- * merge only the menu items of the specific group,
- * and then append a seperator
- */
- if (merge_tap_menus_layered(node, REGISTER_TAP_GROUP_GENERIC)) {
- gtk_item_factory_create_item(main_menu_factory, entry, NULL, 2);
- }
- if (merge_tap_menus_layered(node, REGISTER_TAP_GROUP_CONVERSATION_LIST)) {
- /*gtk_item_factory_create_item(main_menu_factory, entry, NULL, 2);*/
- }
- if (merge_tap_menus_layered(node, REGISTER_TAP_GROUP_ENDPOINT_LIST)) {
- /*gtk_item_factory_create_item(main_menu_factory, entry, NULL, 2);*/
- }
- if (merge_tap_menus_layered(node, REGISTER_TAP_GROUP_RESPONSE_TIME)) {
- gtk_item_factory_create_item(main_menu_factory, entry, NULL, 2);
- }
- if (merge_tap_menus_layered(node, REGISTER_TAP_GROUP_NONE)) {
- /*gtk_item_factory_create_item(main_menu_factory, entry, NULL, 2);*/
- }
-}
-
-
-
-/*
- * Enable/disable menu sensitivity.
- */
-static void
-set_menu_sensitivity(GtkItemFactory *ifactory, const gchar *path, gint val)
-{
- GSList *menu_list;
- GtkWidget *menu_item;
- gchar *dup;
- gchar *dest;
-
-
- /* the underscore character regularly confuses things, as it will prevent finding
- * the menu_item, so it has to be removed first */
- dup = g_strdup(path);
- dest = dup;
- while(*path) {
- if (*path != '_') {
- *dest = *path;
- dest++;
- }
- path++;
- }
- *dest = '\0';
-
- if (ifactory == NULL) {
- /*
- * Do it for all pop-up menus.
- */
- for (menu_list = popup_menu_list; menu_list != NULL;
- menu_list = g_slist_next(menu_list))
- set_menu_sensitivity(menu_list->data, dup, val);
- } else {
- /*
- * Do it for that particular menu.
- */
- if ((menu_item = gtk_item_factory_get_widget(ifactory, dup)) != NULL) {
- if (GTK_IS_MENU(menu_item)) {
- /*
- * "dup" refers to a submenu; "gtk_item_factory_get_widget()"
- * gets the menu, not the item that, when selected, pops up
- * the submenu.
- *
- * We have to change the latter item's sensitivity, so that
- * it shows up normally if sensitive and grayed-out if
- * insensitive.
- */
- menu_item = gtk_menu_get_attach_widget(GTK_MENU(menu_item));
- }
- gtk_widget_set_sensitive(menu_item, val);
- } else{
- /* be sure this menu item *is* existing */
- g_assert_not_reached();
- }
- }
-
- g_free(dup);
-}
-
-void
-set_menu_object_data_meat(GtkItemFactory *ifactory, gchar *path, gchar *key, gpointer data)
-{
- GtkWidget *menu = NULL;
-
- if ((menu = gtk_item_factory_get_widget(ifactory, path)) != NULL)
- OBJECT_SET_DATA(menu, key, data);
-}
-
-void
-set_menu_object_data (gchar *path, gchar *key, gpointer data) {
- GSList *menu_list = popup_menu_list;
- gchar *shortpath = strrchr(path, '/');
-
- set_menu_object_data_meat(main_menu_factory, path, key, data);
- while (menu_list != NULL) {
- set_menu_object_data_meat(menu_list->data, shortpath, key, data);
- menu_list = g_slist_next(menu_list);
- }
-}
-
-
-/* Recently used capture files submenu:
- * Submenu containing the recently used capture files.
- * The capture filenames are always kept with the absolute path, to be independant
- * of the current path.
- * They are only stored inside the labels of the submenu (no separate list). */
-
-#define MENU_RECENT_FILES_PATH "/File/Open Recent"
-#define MENU_RECENT_FILES_KEY "Recent File Name"
-
-void
-update_menu_recent_capture_file1(GtkWidget *widget, gpointer cnt) {
- gchar *widget_cf_name;
-
- widget_cf_name = OBJECT_GET_DATA(widget, MENU_RECENT_FILES_KEY);
-
- /* if this menu item is a file, count it */
- if (widget_cf_name) {
- (*(guint *)cnt)++;
- }
-}
-
-
-/* update the menu */
-void
-update_menu_recent_capture_file(GtkWidget *submenu_recent_files) {
- guint cnt = 0;
-
- gtk_container_foreach(GTK_CONTAINER(submenu_recent_files),
- update_menu_recent_capture_file1, &cnt);
-
- /* make parent menu item sensitive only, if we have any valid files in the list */
- set_menu_sensitivity(main_menu_factory, MENU_RECENT_FILES_PATH, cnt);
-}
-
-
-/* remove the capture filename from the "Recent Files" menu */
-void
-remove_menu_recent_capture_file(GtkWidget *widget, gpointer unused _U_) {
- GtkWidget *submenu_recent_files;
- gchar *widget_cf_name;
-
-
- widget_cf_name = OBJECT_GET_DATA(widget, MENU_RECENT_FILES_KEY);
- g_free(widget_cf_name);
-
- /* get the submenu container item */
- submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH);
-
- /* XXX: is this all we need to do, to free the menu item and its label?
- The reference count of widget will go to 0, so it'll be freed;
- will that free the label? */
- gtk_container_remove(GTK_CONTAINER(submenu_recent_files), widget);
-}
-
-
-/* callback, if the user pushed the <Clear File List> item */
-static void
-clear_menu_recent_capture_file_cmd_cb(GtkWidget *w _U_, gpointer unused _U_) {
- GtkWidget *submenu_recent_files;
-
-
- submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH);
-
- gtk_container_foreach(GTK_CONTAINER(submenu_recent_files),
- remove_menu_recent_capture_file, NULL);
-
- update_menu_recent_capture_file(submenu_recent_files);
-}
-
-
-/* callback, if the user pushed a recent file submenu item */
-void
-menu_open_recent_file_cmd(GtkWidget *w)
-{
- GtkWidget *submenu_recent_files;
- GtkWidget *menu_item_child;
- gchar *cf_name;
- int err;
-
- submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH);
-
- /* get capture filename from the menu item label */
- menu_item_child = (GTK_BIN(w))->child;
- gtk_label_get(GTK_LABEL(menu_item_child), &cf_name);
-
- /* open and read the capture file (this will close an existing file) */
- if ((err = cf_open(cf_name, FALSE, &cfile)) == 0) {
- cf_read(&cfile);
- } else {
- /* the capture file isn't existing any longer, remove menu item */
- /* XXX: ask user to remove item, it's maybe only a temporary problem */
- remove_menu_recent_capture_file(w, NULL);
- }
-
- update_menu_recent_capture_file(submenu_recent_files);
-}
-
-static void menu_open_recent_file_answered_cb(gpointer dialog _U_, gint btn, gpointer data _U_)
-{
- switch(btn) {
- case(ESD_BTN_YES):
- /* save file first */
- file_save_as_cmd(after_save_open_recent_file, data);
- break;
- case(ESD_BTN_NO):
- cf_close(&cfile);
- menu_open_recent_file_cmd(data);
- break;
- case(ESD_BTN_CANCEL):
- break;
- default:
- g_assert_not_reached();
- }
-}
-
-void
-menu_open_recent_file_cmd_cb(GtkWidget *widget, gpointer data _U_) {
- gpointer dialog;
-
-
- if((cfile.state != FILE_CLOSED) && !cfile.user_saved && prefs.gui_ask_unsaved) {
- /* user didn't saved his current file, ask him */
- dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_YES_NO_CANCEL,
- PRIMARY_TEXT_START "Save capture file before opening a new one?" PRIMARY_TEXT_END "\n\n"
- "If you open a new capture file without saving, your current capture data will be discarded.");
- simple_dialog_set_cb(dialog, menu_open_recent_file_answered_cb, widget);
- } else {
- /* unchanged file */
- menu_open_recent_file_cmd(widget);
- }
-}
-
-/* add the capture filename (with an absolute path) to the "Recent Files" menu */
-void
-add_menu_recent_capture_file_absolute(gchar *cf_name) {
- GtkWidget *submenu_recent_files;
- GList *menu_item_list;
- GList *li;
- gchar *widget_cf_name;
- gchar *normalized_cf_name;
- GtkWidget *menu_item;
- guint cnt;
-
-
-
- normalized_cf_name = g_strdup(cf_name);
-#ifdef WIN32
- /* replace all slashes by backslashes */
- g_strdelimit(normalized_cf_name, "/", '\\');
-#endif
-
- /* get the submenu container item */
- submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH);
-
- /* convert container to a GList */
- menu_item_list = gtk_container_children(GTK_CONTAINER(submenu_recent_files));
-
- /* iterate through list items of menu_item_list,
- * removing special items, a maybe duplicate entry and every item above count_max */
- cnt = 1;
- for (li = g_list_first(menu_item_list); li; li = li->next, cnt++) {
- /* get capture filename */
- menu_item = GTK_WIDGET(li->data);
- widget_cf_name = OBJECT_GET_DATA(menu_item, MENU_RECENT_FILES_KEY);
-
- /* if this element string is one of our special items (seperator, ...) or
- * already in the list or
- * this element is above maximum count (too old), remove it */
- if (!widget_cf_name ||
-#ifdef WIN32
- /* do a case insensitive compare on win32 */
-#if GLIB_MAJOR_VERSION < 2
- g_strncasecmp(widget_cf_name, normalized_cf_name, 1000) == 0 ||
-#else
- g_ascii_strncasecmp(widget_cf_name, normalized_cf_name, 1000) == 0 ||
-#endif
-#else /* WIN32 */
- /* do a case sensitive compare on unix */
- strncmp(widget_cf_name, normalized_cf_name, 1000) == 0 ||
-#endif
- cnt >= prefs.gui_recent_files_count_max) {
- remove_menu_recent_capture_file(li->data, NULL);
- cnt--;
- }
- }
-
- g_list_free(menu_item_list);
-
- /* add new item at latest position */
- menu_item = gtk_menu_item_new_with_label(normalized_cf_name);
- OBJECT_SET_DATA(menu_item, MENU_RECENT_FILES_KEY, normalized_cf_name);
- gtk_menu_prepend (GTK_MENU(submenu_recent_files), menu_item);
- SIGNAL_CONNECT_OBJECT(GTK_OBJECT(menu_item), "activate",
- menu_open_recent_file_cmd_cb, (GtkObject *) menu_item);
- gtk_widget_show (menu_item);
-
- /* add seperator at last position */
- menu_item = gtk_menu_item_new();
- gtk_menu_append (GTK_MENU(submenu_recent_files), menu_item);
- gtk_widget_show (menu_item);
-
- /* add new "clear list" item at last position */
-#if GTK_MAJOR_VERSION < 2
- menu_item = gtk_menu_item_new_with_label("<Clear File List>");
-#else
- menu_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLEAR, NULL);
-#endif
- gtk_menu_append (GTK_MENU(submenu_recent_files), menu_item);
- SIGNAL_CONNECT_OBJECT(GTK_OBJECT(menu_item), "activate",
- clear_menu_recent_capture_file_cmd_cb, (GtkObject *) menu_item);
- gtk_widget_show (menu_item);
-
- update_menu_recent_capture_file(submenu_recent_files);
-}
-
-
-/* add the capture filename to the "Recent Files" menu */
-/* (will change nothing, if this filename is already in the menu) */
-void
-add_menu_recent_capture_file(gchar *cf_name) {
- gchar *curr;
- gchar *absolute;
-
-
- /* if this filename is an absolute path, we can use it directly */
- if (g_path_is_absolute(cf_name)) {
- add_menu_recent_capture_file_absolute(cf_name);
- return;
- }
-
- /* this filename is not an absolute path, prepend the current dir */
- curr = g_get_current_dir();
- absolute = g_strdup_printf("%s%s%s", curr, G_DIR_SEPARATOR_S, cf_name);
- add_menu_recent_capture_file_absolute(absolute);
- g_free(curr);
- g_free(absolute);
-}
-
-
-/* write all capture filenames of the menu to the user's recent file */
-void
-menu_recent_file_write_all(FILE *rf) {
- GtkWidget *submenu_recent_files;
- GList *children;
- GList *child;
- gchar *cf_name;
-
-
- submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH);
-
- /* we have to iterate backwards through the children's list,
- * so we get the latest item last in the file.
- * (don't use gtk_container_foreach() here, it will return the wrong iteration order) */
- children = gtk_container_children(GTK_CONTAINER(submenu_recent_files));
- child = g_list_last(children);
- while(child != NULL) {
- /* get capture filename from the menu item label */
- cf_name = OBJECT_GET_DATA(child->data, MENU_RECENT_FILES_KEY);
- if (cf_name) {
- fprintf (rf, RECENT_KEY_CAPTURE_FILE ": %s\n", cf_name);
- }
-
- child = g_list_previous(child);
- }
-
- g_list_free(children);
-}
-
-
-static void
-main_toolbar_show_cb(GtkWidget *w _U_, gpointer d _U_)
-{
-
- /* save current setting in recent */
- recent.main_toolbar_show = GTK_CHECK_MENU_ITEM(w)->active;
-
- main_widgets_show_or_hide();
-}
-
-
-static void
-filter_toolbar_show_cb(GtkWidget *w _U_, gpointer d _U_)
-{
-
- /* save current setting in recent */
- recent.filter_toolbar_show = GTK_CHECK_MENU_ITEM(w)->active;
-
- main_widgets_show_or_hide();
-}
-
-
-static void
-packet_list_show_cb(GtkWidget *w _U_, gpointer d _U_)
-{
-
- /* save current setting in recent */
- recent.packet_list_show = GTK_CHECK_MENU_ITEM(w)->active;
-
- main_widgets_show_or_hide();
-}
-
-
-static void
-tree_view_show_cb(GtkWidget *w _U_, gpointer d _U_)
-{
-
- /* save current setting in recent */
- recent.tree_view_show = GTK_CHECK_MENU_ITEM(w)->active;
-
- main_widgets_show_or_hide();
-}
-
-
-static void
-byte_view_show_cb(GtkWidget *w _U_, gpointer d _U_)
-{
-
- /* save current setting in recent */
- recent.byte_view_show = GTK_CHECK_MENU_ITEM(w)->active;
-
- main_widgets_show_or_hide();
-}
-
-
-static void
-statusbar_show_cb(GtkWidget *w _U_, gpointer d _U_)
-{
-
- /* save current setting in recent */
- recent.statusbar_show = GTK_CHECK_MENU_ITEM(w)->active;
-
- main_widgets_show_or_hide();
-}
-
-
-static void
-timestamp_absolute_cb(GtkWidget *w _U_, gpointer d _U_)
-{
- if (recent.gui_time_format != TS_ABSOLUTE) {
- set_timestamp_setting(TS_ABSOLUTE);
- recent.gui_time_format = TS_ABSOLUTE;
- change_time_formats(&cfile);
- }
-}
-
-static void
-timestamp_absolute_date_cb(GtkWidget *w _U_, gpointer d _U_)
-{
- if (recent.gui_time_format != TS_ABSOLUTE_WITH_DATE) {
- set_timestamp_setting(TS_ABSOLUTE_WITH_DATE);
- recent.gui_time_format = TS_ABSOLUTE_WITH_DATE;
- change_time_formats(&cfile);
- }
-}
-
-static void
-timestamp_relative_cb(GtkWidget *w _U_, gpointer d _U_)
-{
- if (recent.gui_time_format != TS_RELATIVE) {
- set_timestamp_setting(TS_RELATIVE);
- recent.gui_time_format = TS_RELATIVE;
- change_time_formats(&cfile);
- }
-}
-
-static void
-timestamp_delta_cb(GtkWidget *w _U_, gpointer d _U_)
-{
- if (recent.gui_time_format != TS_DELTA) {
- set_timestamp_setting(TS_DELTA);
- recent.gui_time_format = TS_DELTA;
- change_time_formats(&cfile);
- }
-}
-
-void
-menu_name_resolution_changed(void)
-{
- GtkWidget *menu = NULL;
-
- menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Name Resolution/Enable for MAC Layer");
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), g_resolv_flags & RESOLV_MAC);
-
- menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Name Resolution/Enable for Network Layer");
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), g_resolv_flags & RESOLV_NETWORK);
-
- menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Name Resolution/Enable for Transport Layer");
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), g_resolv_flags & RESOLV_TRANSPORT);
-}
-
-static void
-name_resolution_mac_cb(GtkWidget *w _U_, gpointer d _U_)
-{
- if (GTK_CHECK_MENU_ITEM(w)->active) {
- g_resolv_flags |= RESOLV_MAC;
- } else {
- g_resolv_flags &= ~RESOLV_MAC;
- }
-}
-
-static void
-name_resolution_network_cb(GtkWidget *w _U_, gpointer d _U_)
-{
- if (GTK_CHECK_MENU_ITEM(w)->active) {
- g_resolv_flags |= RESOLV_NETWORK;
- } else {
- g_resolv_flags &= ~RESOLV_NETWORK;
- }
-}
-
-static void
-name_resolution_transport_cb(GtkWidget *w _U_, gpointer d _U_)
-{
- if (GTK_CHECK_MENU_ITEM(w)->active) {
- g_resolv_flags |= RESOLV_TRANSPORT;
- } else {
- g_resolv_flags &= ~RESOLV_TRANSPORT;
- }
-}
-
-#ifdef HAVE_LIBPCAP
-static void
-auto_scroll_live_cb(GtkWidget *w _U_, gpointer d _U_)
-{
- auto_scroll_live = GTK_CHECK_MENU_ITEM(w)->active;
-}
-#endif
-
-/* the recent file read has finished, update the menu corresponding */
-void
-menu_recent_read_finished(void) {
- GtkWidget *menu = NULL;
-
- menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Main Toolbar");
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.main_toolbar_show);
-
- menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Filter Toolbar");
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.filter_toolbar_show);
-
- menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Statusbar");
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.statusbar_show);
-
- menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Packet List");
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.packet_list_show);
-
- menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Packet Details");
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.tree_view_show);
-
- menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Packet Bytes");
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.byte_view_show);
-
- menu_name_resolution_changed();
-
-#ifdef HAVE_LIBPCAP
- menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Auto Scroll in Live Capture");
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), auto_scroll_live);
-#endif
-
- main_widgets_rearrange();
-
- /* don't change the time format, if we had a command line value */
- if (get_timestamp_setting() != TS_NOT_SET) {
- recent.gui_time_format = get_timestamp_setting();
- }
-
- switch(recent.gui_time_format) {
- case(TS_ABSOLUTE):
- menu = gtk_item_factory_get_widget(main_menu_factory,
- "/View/Time Display Format/Time of Day");
- /* set_active will not trigger the callback when activating an active item! */
- recent.gui_time_format = -1;
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), FALSE);
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
- break;
- case(TS_ABSOLUTE_WITH_DATE):
- menu = gtk_item_factory_get_widget(main_menu_factory,
- "/View/Time Display Format/Date and Time of Day");
- recent.gui_time_format = -1;
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
- break;
- case(TS_RELATIVE):
- menu = gtk_item_factory_get_widget(main_menu_factory,
- "/View/Time Display Format/Seconds Since Beginning of Capture");
- recent.gui_time_format = -1;
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
- break;
- case(TS_DELTA):
- menu = gtk_item_factory_get_widget(main_menu_factory,
- "/View/Time Display Format/Seconds Since Previous Packet");
- recent.gui_time_format = -1;
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
- break;
- default:
- g_assert_not_reached();
- }
-}
-
-
-gint
-popup_menu_handler(GtkWidget *widget, GdkEvent *event, gpointer data)
-{
- GtkWidget *menu = (GtkWidget *)data;
- GdkEventButton *event_button = NULL;
- gint row, column;
-
- if(widget == NULL || event == NULL || data == NULL) {
- return FALSE;
- }
-
- /*
- * If we ever want to make the menu differ based on what row
- * and/or column we're above, we'd use "eth_clist_get_selection_info()"
- * to find the row and column number for the coordinates; a CTree is,
- * I guess, like a CList with one column(?) and the expander widget
- * as a pixmap.
- */
- /* Check if we are on packet_list object */
- if (widget == OBJECT_GET_DATA(popup_menu_object, E_MPACKET_LIST_KEY)) {
- if (packet_list_get_event_row_column(widget, (GdkEventButton *)event,
- &row, &column)) {
- OBJECT_SET_DATA(popup_menu_object, E_MPACKET_LIST_ROW_KEY,
- GINT_TO_POINTER(row));
- OBJECT_SET_DATA(popup_menu_object, E_MPACKET_LIST_COL_KEY,
- GINT_TO_POINTER(column));
- packet_list_set_selected_row(row);
- }
- }
-
- /* Check if we are on tree_view object */
- if (widget == tree_view) {
- tree_view_select(widget, (GdkEventButton *) event);
- }
-
- /* Check if we are on byte_view object */
- if(widget == get_notebook_bv_ptr(byte_nb_ptr)) {
- byte_view_select(widget, (GdkEventButton *) event);
- }
-
- /* context menu handler (but the byte view notebook pages have their own handler) */
- if(event->type == GDK_BUTTON_PRESS && widget != byte_nb_ptr) {
- event_button = (GdkEventButton *) event;
-
- /* To qoute the "Gdk Event Structures" doc:
- * "Normally button 1 is the left mouse button, 2 is the middle button, and 3 is the right button" */
- if(event_button->button == 3) {
- gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
- event_button->button,
- event_button->time);
- SIGNAL_EMIT_STOP_BY_NAME(widget, "button_press_event");
- return TRUE;
- }
- }
-#if GTK_MAJOR_VERSION >= 2
- /* GDK_2BUTTON_PRESS is a doubleclick -> expand/collapse tree row */
- /* GTK version 1 seems to be doing this automatically */
- if (widget == tree_view && event->type == GDK_2BUTTON_PRESS) {
- GtkTreePath *path;
-
- if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget),
- (gint) (((GdkEventButton *)event)->x),
- (gint) (((GdkEventButton *)event)->y),
- &path, NULL, NULL, NULL))
- {
- if (gtk_tree_view_row_expanded(GTK_TREE_VIEW(widget), path))
- gtk_tree_view_collapse_row(GTK_TREE_VIEW(widget), path);
- else
- gtk_tree_view_expand_row(GTK_TREE_VIEW(widget), path,
- FALSE);
- gtk_tree_path_free(path);
- }
- }
-#endif
- return FALSE;
-}
-
-/* Enable or disable menu items based on whether you have a capture file
- you've finished reading. */
-void
-set_menus_for_capture_file(gboolean have_capture_file)
-{
- set_menu_sensitivity(main_menu_factory, "/File/Open...", have_capture_file);
- set_menu_sensitivity(main_menu_factory, "/File/Open Recent", have_capture_file);
- set_menu_sensitivity(main_menu_factory, "/File/Merge...", have_capture_file);
- set_menu_sensitivity(main_menu_factory, "/File/Close", have_capture_file);
- set_menu_sensitivity(main_menu_factory, "/File/Save As...",
- have_capture_file);
- set_menu_sensitivity(main_menu_factory, "/File/Export", have_capture_file);
- set_menu_sensitivity(main_menu_factory, "/View/Reload", have_capture_file);
- set_toolbar_for_capture_file(have_capture_file);
- packets_bar_update();
-}
-
-/* Enable or disable menu items based on whether you have an unsaved
- capture file you've finished reading. */
-void
-set_menus_for_unsaved_capture_file(gboolean have_unsaved_capture_file)
-{
- set_menu_sensitivity(main_menu_factory, "/File/Save",
- have_unsaved_capture_file);
- set_toolbar_for_unsaved_capture_file(have_unsaved_capture_file);
-}
-
-/* Enable or disable menu items based on whether there's a capture in
- progress. */
-void
-set_menus_for_capture_in_progress(gboolean capture_in_progress)
-{
- set_menu_sensitivity(main_menu_factory, "/File/Open...",
- !capture_in_progress);
- set_menu_sensitivity(main_menu_factory, "/File/Open Recent",
- !capture_in_progress);
-#ifdef HAVE_LIBPCAP
- set_menu_sensitivity(main_menu_factory, "/Capture/Start...",
- !capture_in_progress);
- set_menu_sensitivity(main_menu_factory, "/Capture/Stop",
- capture_in_progress);
-#endif /* HAVE_LIBPCAP */
- set_toolbar_for_capture_in_progress(capture_in_progress);
-
- set_capture_if_dialog_for_capture_in_progress(capture_in_progress);
-}
-
-/* Enable or disable menu items based on whether you have some captured
- packets. */
-static gboolean
-walk_menu_tree_for_captured_packets(GList *node,
- gboolean have_captured_packets)
-{
- gboolean is_enabled;
- GList *child;
- menu_item_t *node_data = node->data;
-
- /*
- * Is this a leaf node or an interior node?
- */
- if (node_data->children == NULL) {
- /*
- * It's a leaf node.
- *
- * If it has no "selected_packet_enabled()" or
- * "selected_tree_row_enabled()" routines, we enable
- * it. This allows tap windows to be popped up even
- * if you have no capture file; this is done to let
- * the user pop up multiple tap windows before reading
- * in a capture file, so that they can be processed in
- * parallel while the capture file is being read rather
- * than one at at time as you pop up the windows, and to
- * let the user pop up tap windows before starting an
- * "Update list of packets in real time" capture, so that
- * the statistics can be displayed while the capture is
- * in progress.
- *
- * If it has either of those routines, we disable it for
- * now - as long as, when a capture is first available,
- * we don't get called after a packet or tree row is
- * selected, that's OK.
- * XXX - that should be done better.
- */
- if (node_data->selected_packet_enabled == NULL &&
- node_data->selected_tree_row_enabled == NULL)
- node_data->enabled = TRUE;
- else
- node_data->enabled = FALSE;
- } else {
- /*
- * It's an interior node; call
- * "walk_menu_tree_for_captured_packets()" on all its
- * children and, if any of them are enabled, enable
- * this node, otherwise disable it.
- *
- * XXX - should we just leave all interior nodes enabled?
- * Which is a better UI choice?
- */
- is_enabled = FALSE;
- for (child = node_data->children; child != NULL; child =
- child->next) {
- if (walk_menu_tree_for_captured_packets(child,
- have_captured_packets))
- is_enabled = TRUE;
- }
- node_data->enabled = is_enabled;
- }
-
- /*
- * The root node doesn't correspond to a menu tree item; it
- * has a null name pointer.
- */
- if (node_data->name != NULL) {
- set_menu_sensitivity(main_menu_factory, node_data->name,
- node_data->enabled);
- }
- return node_data->enabled;
-}
-
-void
-set_menus_for_captured_packets(gboolean have_captured_packets)
-{
- set_menu_sensitivity(main_menu_factory, "/File/Print...",
- have_captured_packets);
- set_menu_sensitivity(packet_list_menu_factory, "/Print...",
- have_captured_packets);
- set_menu_sensitivity(main_menu_factory, "/Edit/Find Packet...",
- have_captured_packets);
- set_menu_sensitivity(main_menu_factory, "/Edit/Find Next",
- have_captured_packets);
- set_menu_sensitivity(main_menu_factory, "/Edit/Find Previous",
- have_captured_packets);
- set_menu_sensitivity(main_menu_factory, "/View/Zoom In",
- have_captured_packets);
- set_menu_sensitivity(main_menu_factory, "/View/Zoom Out",
- have_captured_packets);
- set_menu_sensitivity(main_menu_factory, "/View/Normal Size",
- have_captured_packets);
- set_menu_sensitivity(packet_list_menu_factory, "/Coloring Rules...",
- have_captured_packets);
- set_menu_sensitivity(main_menu_factory, "/Go/Go to Packet...",
- have_captured_packets);
- set_menu_sensitivity(main_menu_factory, "/Go/First Packet",
- have_captured_packets);
- set_menu_sensitivity(main_menu_factory, "/Go/Last Packet",
- have_captured_packets);
- set_menu_sensitivity(main_menu_factory, "/Statistics/Summary",
- have_captured_packets);
- set_menu_sensitivity(main_menu_factory, "/Statistics/Protocol Hierarchy",
- have_captured_packets);
-
- walk_menu_tree_for_captured_packets(tap_menu_tree_root,
- have_captured_packets);
- set_toolbar_for_captured_packets(have_captured_packets);
- packets_bar_update();
-}
-
-/* Enable or disable menu items based on whether a packet is selected and,
- if so, on the properties of the packet. */
-static gboolean
-walk_menu_tree_for_selected_packet(GList *node, frame_data *fd,
- epan_dissect_t *edt)
-{
- gboolean is_enabled;
- GList *child;
- menu_item_t *node_data = node->data;
-
- /*
- * Is this a leaf node or an interior node?
- */
- if (node_data->children == NULL) {
- /*
- * It's a leaf node.
- *
- * If it has no "selected_packet_enabled()" routine,
- * leave its enabled/disabled status alone - it
- * doesn't depend on whether we have a packet selected
- * or not or on the selected packet.
- *
- * If it has a "selected_packet_enabled()" routine,
- * call it and set the item's enabled/disabled status
- * based on its return value.
- */
- if (node_data->selected_packet_enabled != NULL)
- node_data->enabled = node_data->selected_packet_enabled(fd, edt);
- } else {
- /*
- * It's an interior node; call
- * "walk_menu_tree_for_selected_packet()" on all its
- * children and, if any of them are enabled, enable
- * this node, otherwise disable it.
- *
- * XXX - should we just leave all interior nodes enabled?
- * Which is a better UI choice?
- */
- is_enabled = FALSE;
- for (child = node_data->children; child != NULL; child =
- child->next) {
- if (walk_menu_tree_for_selected_packet(child, fd, edt))
- is_enabled = TRUE;
- }
- node_data->enabled = is_enabled;
- }
-
- /*
- * The root node doesn't correspond to a menu tree item; it
- * has a null name pointer.
- */
- if (node_data->name != NULL) {
- set_menu_sensitivity(main_menu_factory, node_data->name,
- node_data->enabled);
- }
- return node_data->enabled;
-}
-
-void
-set_menus_for_selected_packet(capture_file *cf)
-{
- set_menu_sensitivity(main_menu_factory, "/Edit/Mark Packet",
- cf->current_frame != NULL);
- set_menu_sensitivity(packet_list_menu_factory, "/Mark Packet",
- cf->current_frame != NULL);
- set_menu_sensitivity(main_menu_factory, "/Edit/Time Reference",
- cf->current_frame != NULL);
- set_menu_sensitivity(packet_list_menu_factory, "/Time Reference",
- cf->current_frame != NULL);
- set_menu_sensitivity(main_menu_factory, "/Edit/Mark All Packets",
- cf->current_frame != NULL);
- set_menu_sensitivity(main_menu_factory, "/Edit/Unmark All Packets",
- cf->current_frame != NULL);
- set_menu_sensitivity(main_menu_factory, "/View/Collapse All",
- cf->current_frame != NULL);
- set_menu_sensitivity(tree_view_menu_factory, "/Collapse All",
- cf->current_frame != NULL);
- set_menu_sensitivity(main_menu_factory, "/View/Expand All",
- cf->current_frame != NULL);
- set_menu_sensitivity(tree_view_menu_factory, "/Expand All",
- cf->current_frame != NULL);
- set_menu_sensitivity(main_menu_factory, "/View/Show Packet in New Window",
- cf->current_frame != NULL);
- set_menu_sensitivity(packet_list_menu_factory, "/Show Packet in New Window",
- cf->current_frame != NULL);
- set_menu_sensitivity(main_menu_factory, "/Analyze/Follow TCP Stream",
- cf->current_frame != NULL ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE);
- set_menu_sensitivity(NULL, "/Follow TCP Stream",
- cf->current_frame != NULL ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE);
- set_menu_sensitivity(main_menu_factory, "/Analyze/Decode As...",
- cf->current_frame != NULL && decode_as_ok());
- set_menu_sensitivity(NULL, "/Decode As...",
- cf->current_frame != NULL && decode_as_ok());
- set_menu_sensitivity(main_menu_factory, "/View/Name Resolution/Resolve Name",
- cf->current_frame != NULL && (g_resolv_flags & RESOLV_ALL_ADDRS) != RESOLV_ALL_ADDRS);
- set_menu_sensitivity(tree_view_menu_factory, "/Resolve Name",
- cf->current_frame != NULL && (g_resolv_flags & RESOLV_ALL_ADDRS) != RESOLV_ALL_ADDRS);
- set_menu_sensitivity(packet_list_menu_factory, "/Apply as Filter",
- cf->current_frame != NULL);
- set_menu_sensitivity(packet_list_menu_factory, "/Prepare a Filter",
- cf->current_frame != NULL);
-
- walk_menu_tree_for_selected_packet(tap_menu_tree_root, cf->current_frame,
- cf->edt);
- packets_bar_update();
-}
-
-/* Enable or disable menu items based on whether a tree row is selected
- and, if so, on the properties of the tree row. */
-static gboolean
-walk_menu_tree_for_selected_tree_row(GList *node, field_info *fi)
-{
- gboolean is_enabled;
- GList *child;
- menu_item_t *node_data = node->data;
-
- /*
- * Is this a leaf node or an interior node?
- */
- if (node_data->children == NULL) {
- /*
- * It's a leaf node.
- *
- * If it has no "selected_tree_row_enabled()" routine,
- * leave its enabled/disabled status alone - it
- * doesn't depend on whether we have a tree row selected
- * or not or on the selected tree row.
- *
- * If it has a "selected_tree_row_enabled()" routine,
- * call it and set the item's enabled/disabled status
- * based on its return value.
- */
- if (node_data->selected_tree_row_enabled != NULL)
- node_data->enabled = node_data->selected_tree_row_enabled(fi);
- } else {
- /*
- * It's an interior node; call
- * "walk_menu_tree_for_selected_tree_row()" on all its
- * children and, if any of them are enabled, enable
- * this node, otherwise disable it.
- *
- * XXX - should we just leave all interior nodes enabled?
- * Which is a better UI choice?
- */
- is_enabled = FALSE;
- for (child = node_data->children; child != NULL; child =
- child->next) {
- if (walk_menu_tree_for_selected_tree_row(child, fi))
- is_enabled = TRUE;
- }
- node_data->enabled = is_enabled;
- }
-
- /*
- * The root node doesn't correspond to a menu tree item; it
- * has a null name pointer.
- */
- if (node_data->name != NULL) {
- set_menu_sensitivity(main_menu_factory, node_data->name,
- node_data->enabled);
- }
- return node_data->enabled;
-}
-
-void
-set_menus_for_selected_tree_row(capture_file *cf)
-{
- gboolean properties;
-
-
- set_menu_sensitivity(main_menu_factory, "/File/Export/Selected Packet Bytes...",
- cf->finfo_selected != NULL);
- set_menu_sensitivity(tree_view_menu_factory, "/Export Selected Packet Bytes...",
- cf->finfo_selected != NULL);
- set_menu_sensitivity(hexdump_menu_factory, "/Export Selected Packet Bytes...",
- cf->finfo_selected != NULL);
-
- if (cf->finfo_selected != NULL) {
- header_field_info *hfinfo = cf->finfo_selected->hfinfo;
- if (hfinfo->parent == -1) {
- properties = prefs_is_registered_protocol(hfinfo->abbrev);
- } else {
- properties = prefs_is_registered_protocol(proto_registrar_get_abbrev(hfinfo->parent));
- }
- set_menu_sensitivity(main_menu_factory,
- "/Go/Go to Corresponding Packet", hfinfo->type == FT_FRAMENUM);
- set_menu_sensitivity(tree_view_menu_factory,
- "/Go to Corresponding Packet", hfinfo->type == FT_FRAMENUM);
- set_menu_sensitivity(main_menu_factory, "/Analyze/Apply as Filter",
- proto_can_match_selected(cf->finfo_selected, cf->edt));
- set_menu_sensitivity(tree_view_menu_factory, "/Apply as Filter",
- proto_can_match_selected(cf->finfo_selected, cf->edt));
- set_menu_sensitivity(main_menu_factory, "/Analyze/Prepare a Filter",
- proto_can_match_selected(cf->finfo_selected, cf->edt));
- set_menu_sensitivity(tree_view_menu_factory, "/Prepare a Filter",
- proto_can_match_selected(cf->finfo_selected, cf->edt));
- set_menu_sensitivity(tree_view_menu_factory, "/Protocol Preferences...",
- properties);
- set_menu_sensitivity(main_menu_factory, "/View/Expand Tree", cf->finfo_selected->tree_type != -1);
- set_menu_sensitivity(tree_view_menu_factory, "/Expand Tree", cf->finfo_selected->tree_type != -1);
- } else {
- set_menu_sensitivity(main_menu_factory,
- "/Go/Go to Corresponding Packet", FALSE);
- set_menu_sensitivity(tree_view_menu_factory,
- "/Go to Corresponding Packet", FALSE);
- set_menu_sensitivity(main_menu_factory, "/Analyze/Apply as Filter", FALSE);
- set_menu_sensitivity(tree_view_menu_factory, "/Apply as Filter", FALSE);
- set_menu_sensitivity(main_menu_factory, "/Analyze/Prepare a Filter", FALSE);
- set_menu_sensitivity(tree_view_menu_factory, "/Prepare a Filter", FALSE);
- set_menu_sensitivity(tree_view_menu_factory, "/Protocol Preferences...",
- FALSE);
- set_menu_sensitivity(main_menu_factory, "/View/Expand Tree", FALSE);
- set_menu_sensitivity(tree_view_menu_factory, "/Expand Tree", FALSE);
- }
-
- walk_menu_tree_for_selected_tree_row(tap_menu_tree_root, cf->finfo_selected);
-}
+/* menu.c + * Menu routines + * + * $Id$ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <gtk/gtk.h> + +#include <string.h> + +#include "main.h" +#include "menu.h" +#include "tap_menu.h" +#include <epan/packet.h> +#include <epan/resolv.h> +#include "prefs.h" +#include "about_dlg.h" +#include "capture_dlg.h" +#include "color_dlg.h" +#include "filter_prefs.h" +#include "dlg_utils.h" +#include "file_dlg.h" +#include "find_dlg.h" +#include "goto_dlg.h" +#include "summary_dlg.h" +#include "prefs_dlg.h" +#include "packet_win.h" +#include "print.h" +#include "follow_dlg.h" +#include "decode_as_dlg.h" +#include "help_dlg.h" +#include "supported_protos_dlg.h" +#include "proto_dlg.h" +#include "proto_hier_stats_dlg.h" +#include "keys.h" +#include <epan/plugins.h> +#include <epan/epan_dissect.h> +#include "compat_macros.h" +#include "toolbar.h" +#include "gtkglobals.h" +#include "register.h" +#include "../tap.h" +#include "../menu.h" +#include "../ipproto.h" +#include "packet_list.h" +#include "ethclist.h" +#include "recent.h" +#include "../ui_util.h" +#include "proto_draw.h" +#include "endpoint_talkers_table.h" +#include "hostlist_table.h" +#include "simple_dialog.h" +#include <epan/timestamp.h> + +GtkWidget *popup_menu_object; + +static void +clear_menu_recent_capture_file_cmd_cb(GtkWidget *w, gpointer unused _U_); + +typedef struct _menu_item { + char *name; + gint group; + gboolean enabled; + GtkItemFactoryCallback callback; + gpointer callback_data; + gboolean (*selected_packet_enabled)(frame_data *, epan_dissect_t *); + gboolean (*selected_tree_row_enabled)(field_info *); + GList *children; +} menu_item_t; + +static GList *tap_menu_tree_root = NULL; + +static void +merge_all_tap_menus(GList *node); + +#define GTK_MENU_FUNC(a) ((GtkItemFactoryCallback)(a)) + +static void menus_init(void); +static void set_menu_sensitivity (GtkItemFactory *, const gchar *, gint); +static void main_toolbar_show_cb(GtkWidget *w _U_, gpointer d _U_); +static void filter_toolbar_show_cb(GtkWidget *w _U_, gpointer d _U_); +static void packet_list_show_cb(GtkWidget *w _U_, gpointer d _U_); +static void tree_view_show_cb(GtkWidget *w _U_, gpointer d _U_); +static void byte_view_show_cb(GtkWidget *w _U_, gpointer d _U_); +static void statusbar_show_cb(GtkWidget *w _U_, gpointer d _U_); +static void timestamp_absolute_cb(GtkWidget *w _U_, gpointer d _U_); +static void timestamp_absolute_date_cb(GtkWidget *w _U_, gpointer d _U_); +static void timestamp_relative_cb(GtkWidget *w _U_, gpointer d _U_); +static void timestamp_delta_cb(GtkWidget *w _U_, gpointer d _U_); +static void name_resolution_mac_cb(GtkWidget *w _U_, gpointer d _U_); +static void name_resolution_network_cb(GtkWidget *w _U_, gpointer d _U_); +static void name_resolution_transport_cb(GtkWidget *w _U_, gpointer d _U_); +#ifdef HAVE_LIBPCAP +static void auto_scroll_live_cb(GtkWidget *w _U_, gpointer d _U_); +#endif + +/* This is the GtkItemFactoryEntry structure used to generate new menus. + Item 1: The menu path. The letter after the underscore indicates an + accelerator key once the menu is open. + Item 2: The accelerator key for the entry + Item 3: The callback function. + Item 4: The callback action. This changes the parameters with + which the function is called. The default is 0. + Item 5: The item type, used to define what kind of an item it is. + Here are the possible values: + + NULL -> "<Item>" + "" -> "<Item>" + "<Title>" -> create a title item + "<Item>" -> create a simple item + "<ImageItem>" -> create an item holding an image (gtk2) + "<StockItem>" -> create an item holding a stock image (gtk2) + "<CheckItem>" -> create a check item + "<ToggleItem>" -> create a toggle item + "<RadioItem>" -> create a radio item + <path> -> path of a radio item to link against + "<Separator>" -> create a separator + "<Tearoff>" -> create a tearoff separator (gtk2) + "<Branch>" -> create an item to hold sub items (optional) + "<LastBranch>" -> create a right justified branch + Item 6: extra data needed for ImageItem and StockItem (gtk2) + */ + +/* main menu */ +static GtkItemFactoryEntry menu_items[] = +{ + ITEM_FACTORY_ENTRY("/_File", NULL, NULL, 0, "<Branch>", NULL), + ITEM_FACTORY_STOCK_ENTRY("/File/_Open...", "<control>O", file_open_cmd_cb, + 0, GTK_STOCK_OPEN), + ITEM_FACTORY_ENTRY("/File/Open _Recent", NULL, NULL, 0, "<Branch>", NULL), + ITEM_FACTORY_ENTRY("/File/_Merge...", NULL, file_merge_cmd_cb, 0, NULL, NULL), + ITEM_FACTORY_STOCK_ENTRY("/File/_Close", "<control>W", file_close_cmd_cb, + 0, GTK_STOCK_CLOSE), + ITEM_FACTORY_ENTRY("/File/<separator>", NULL, NULL, 0, "<Separator>", NULL), + ITEM_FACTORY_STOCK_ENTRY("/File/_Save", "<control>S", file_save_cmd_cb, + 0, GTK_STOCK_SAVE), + ITEM_FACTORY_STOCK_ENTRY("/File/Save _As...", "<shift><control>S", file_save_as_cmd_cb, + 0, GTK_STOCK_SAVE_AS), + ITEM_FACTORY_ENTRY("/File/<separator>", NULL, NULL, 0, "<Separator>", NULL), + ITEM_FACTORY_ENTRY("/File/_Export", NULL, NULL, 0, "<Branch>", NULL), + ITEM_FACTORY_ENTRY("/File/Export/as \"Plain _Text\" file...", NULL, export_text_cmd_cb, + 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/File/Export/as \"_PostScript\" file...", NULL, export_ps_cmd_cb, + 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/File/Export/as XML - \"P_SML\" (packet summary) file...", NULL, export_psml_cmd_cb, + 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/File/Export/as XML - \"P_DML\" (packet details) file...", NULL, export_pdml_cmd_cb, + 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/File/Export/<separator>", NULL, NULL, 0, "<Separator>", NULL), + ITEM_FACTORY_ENTRY("/File/Export/Selected Packet _Bytes...", "<control>H", savehex_cb, + 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/File/<separator>", NULL, NULL, 0, "<Separator>", NULL), + ITEM_FACTORY_STOCK_ENTRY("/File/_Print...", "<control>P", file_print_cmd_cb, + 0, GTK_STOCK_PRINT), + ITEM_FACTORY_ENTRY("/File/<separator>", NULL, NULL, 0, "<Separator>", NULL), + ITEM_FACTORY_STOCK_ENTRY("/File/_Quit", "<control>Q", file_quit_cmd_cb, + 0, GTK_STOCK_QUIT), + ITEM_FACTORY_ENTRY("/_Edit", NULL, NULL, 0, "<Branch>", NULL), +#if 0 + /* Un-#if this when we actually implement Cut/Copy/Paste. */ + ITEM_FACTORY_STOCK_ENTRY("/Edit/Cut", "<control>X", NULL, + 0, GTK_STOCK_CUT), + ITEM_FACTORY_STOCK_ENTRY("/Edit/Copy", "<control>C", NULL, + 0, GTK_STOCK_COPY), + ITEM_FACTORY_STOCK_ENTRY("/Edit/Paste", "<control>V", NULL, + 0, GTK_STOCK_PASTE), + ITEM_FACTORY_ENTRY("/Edit/<separator>", NULL, NULL, 0, "<Separator>"), +#endif + ITEM_FACTORY_STOCK_ENTRY("/Edit/_Find Packet...", "<control>F", + find_frame_cb, 0, GTK_STOCK_FIND), + ITEM_FACTORY_STOCK_ENTRY("/Edit/Find Ne_xt", "<control>N", find_next_cb, + 0, GTK_STOCK_GO_FORWARD), + ITEM_FACTORY_STOCK_ENTRY("/Edit/Find Pre_vious", "<control>B", + find_previous_cb, 0, GTK_STOCK_GO_BACK), + ITEM_FACTORY_ENTRY("/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL), + ITEM_FACTORY_ENTRY("/Edit/_Time Reference", NULL, NULL, 0, "<Branch>", NULL), + ITEM_FACTORY_ENTRY("/Edit/Time Reference/Set Time Reference (toggle)", "<control>T", reftime_frame_cb, REFTIME_TOGGLE, NULL, NULL), + ITEM_FACTORY_ENTRY("/Edit/Time Reference/Find Next", NULL, reftime_frame_cb, REFTIME_FIND_NEXT, NULL, NULL), + ITEM_FACTORY_ENTRY("/Edit/Time Reference/Find Previous", NULL, reftime_frame_cb, REFTIME_FIND_PREV, NULL, NULL), + ITEM_FACTORY_ENTRY("/Edit/_Mark Packet", "<control>M", mark_frame_cb, + 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/Edit/Mark _All Packets", NULL, mark_all_frames_cb, + 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/Edit/_Unmark All Packets", NULL, unmark_all_frames_cb, + 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL), + ITEM_FACTORY_STOCK_ENTRY("/Edit/_Preferences...", "<shift><control>P", prefs_cb, + 0, GTK_STOCK_PREFERENCES), + ITEM_FACTORY_ENTRY("/_View", NULL, NULL, 0, "<Branch>", NULL), + ITEM_FACTORY_ENTRY("/View/_Main Toolbar", NULL, main_toolbar_show_cb, 0, "<CheckItem>", NULL), + ITEM_FACTORY_ENTRY("/View/_Filter Toolbar", NULL, filter_toolbar_show_cb, 0, "<CheckItem>", NULL), + ITEM_FACTORY_ENTRY("/View/_Statusbar", NULL, statusbar_show_cb, 0, "<CheckItem>", NULL), + ITEM_FACTORY_ENTRY("/View/<separator>", NULL, NULL, 0, "<Separator>", NULL), + ITEM_FACTORY_ENTRY("/View/Packet _List", NULL, packet_list_show_cb, 0, "<CheckItem>", NULL), + ITEM_FACTORY_ENTRY("/View/Packet _Details", NULL, tree_view_show_cb, 0, "<CheckItem>", NULL), + ITEM_FACTORY_ENTRY("/View/Packet _Bytes", NULL, byte_view_show_cb, 0, "<CheckItem>", NULL), + ITEM_FACTORY_ENTRY("/View/<separator>", NULL, NULL, 0, "<Separator>", NULL), + ITEM_FACTORY_ENTRY("/View/_Time Display Format", NULL, NULL, 0, "<Branch>", NULL), + ITEM_FACTORY_ENTRY("/View/Time Display Format/Time of Day", NULL, timestamp_absolute_cb, + 0, "<RadioItem>", NULL), + ITEM_FACTORY_ENTRY("/View/Time Display Format/Date and Time of Day", NULL, timestamp_absolute_date_cb, + 0, "/View/Time Display Format/Time of Day", NULL), + ITEM_FACTORY_ENTRY("/View/Time Display Format/Seconds Since Beginning of Capture", NULL, timestamp_relative_cb, + 0, "/View/Time Display Format/Time of Day", NULL), + ITEM_FACTORY_ENTRY("/View/Time Display Format/Seconds Since Previous Packet", NULL, timestamp_delta_cb, + 0, "/View/Time Display Format/Time of Day", NULL), + ITEM_FACTORY_ENTRY("/View/Name Resol_ution", NULL, NULL, 0, "<Branch>", NULL), + ITEM_FACTORY_ENTRY("/View/Name Resolution/_Resolve Name", NULL, resolve_name_cb, 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/View/Name Resolution/<separator>", NULL, NULL, 0, "<Separator>", NULL), + ITEM_FACTORY_ENTRY("/View/Name Resolution/Enable for _MAC Layer", NULL, name_resolution_mac_cb, 0, "<CheckItem>", NULL), + ITEM_FACTORY_ENTRY("/View/Name Resolution/Enable for _Network Layer", NULL, name_resolution_network_cb, 0, "<CheckItem>", NULL), + ITEM_FACTORY_ENTRY("/View/Name Resolution/Enable for _Transport Layer", NULL, name_resolution_transport_cb, 0, "<CheckItem>", NULL), +#ifdef HAVE_LIBPCAP + ITEM_FACTORY_ENTRY("/View/Auto Scroll in Li_ve Capture", NULL, auto_scroll_live_cb, 0, "<CheckItem>", NULL), +#endif + ITEM_FACTORY_ENTRY("/View/<separator>", NULL, NULL, 0, "<Separator>", NULL), + ITEM_FACTORY_STOCK_ENTRY("/View/_Zoom In", "<control>plus", view_zoom_in_cb, + 0, GTK_STOCK_ZOOM_IN), + ITEM_FACTORY_STOCK_ENTRY("/View/Zoom _Out", "<control>minus", view_zoom_out_cb, + 0, GTK_STOCK_ZOOM_OUT), + ITEM_FACTORY_STOCK_ENTRY("/View/_Normal Size", "<control>equal", view_zoom_100_cb, + 0, GTK_STOCK_ZOOM_100), + ITEM_FACTORY_ENTRY("/View/<separator>", NULL, NULL, 0, "<Separator>", NULL), + ITEM_FACTORY_ENTRY("/View/Collapse _All", NULL, collapse_all_cb, + 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/View/_Expand All", NULL, expand_all_cb, + 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/View/Expand Tree", NULL, expand_tree_cb, 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/View/<separator>", NULL, NULL, 0, "<Separator>", NULL), + ITEM_FACTORY_STOCK_ENTRY("/View/_Coloring Rules...", NULL, color_display_cb, + 0, GTK_STOCK_SELECT_COLOR), + ITEM_FACTORY_ENTRY("/View/<separator>", NULL, NULL, 0, "<Separator>", NULL), + ITEM_FACTORY_ENTRY("/View/Show Packet in New _Window", NULL, + new_window_cb, 0, NULL, NULL), + ITEM_FACTORY_STOCK_ENTRY("/View/_Reload", "<control>R", file_reload_cmd_cb, + 0, GTK_STOCK_REFRESH), + ITEM_FACTORY_ENTRY("/_Go", NULL, NULL, 0, "<Branch>", NULL), + ITEM_FACTORY_STOCK_ENTRY("/Go/_Go to Packet...", "<control>G", + goto_frame_cb, 0, GTK_STOCK_JUMP_TO), + ITEM_FACTORY_ENTRY("/Go/Go to _Corresponding Packet", NULL, goto_framenum_cb, + 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/Go/<separator>", NULL, NULL, 0, "<Separator>", NULL), + ITEM_FACTORY_STOCK_ENTRY("/Go/_First Packet", NULL, + goto_top_frame_cb, 0, GTK_STOCK_GOTO_TOP), + ITEM_FACTORY_STOCK_ENTRY("/Go/_Last Packet", NULL, + goto_bottom_frame_cb, 0, GTK_STOCK_GOTO_BOTTOM), +#ifdef HAVE_LIBPCAP + ITEM_FACTORY_ENTRY("/_Capture", NULL, NULL, 0, "<Branch>", NULL), + ITEM_FACTORY_STOCK_ENTRY("/Capture/_Start...", "<control>K", + capture_prep_cb, 0, ETHEREAL_STOCK_CAPTURE_START), + ITEM_FACTORY_STOCK_ENTRY("/Capture/S_top", "<control>E", capture_stop_cb, + 0, GTK_STOCK_STOP), + ITEM_FACTORY_ENTRY("/Capture/_Interfaces...", NULL, + capture_if_cb, 0, NULL, NULL), + ITEM_FACTORY_STOCK_ENTRY("/Capture/_Capture Filters...", NULL, cfilter_dialog_cb, + 0, ETHEREAL_STOCK_CAPTURE_FILTER), +#endif /* HAVE_LIBPCAP */ + ITEM_FACTORY_ENTRY("/_Analyze", NULL, NULL, 0, "<Branch>", NULL), + ITEM_FACTORY_STOCK_ENTRY("/Analyze/_Display Filters...", NULL, dfilter_dialog_cb, + 0, ETHEREAL_STOCK_DISPLAY_FILTER), + ITEM_FACTORY_ENTRY("/Analyze/Appl_y as Filter", NULL, NULL, 0, "<Branch>", NULL), + ITEM_FACTORY_ENTRY("/Analyze/Apply as Filter/_Selected", NULL, match_selected_ptree_cb, + MATCH_SELECTED_REPLACE|MATCH_SELECTED_APPLY_NOW, NULL, NULL), + ITEM_FACTORY_ENTRY("/Analyze/Apply as Filter/_Not Selected", NULL, match_selected_ptree_cb, + MATCH_SELECTED_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL), + ITEM_FACTORY_ENTRY("/Analyze/Apply as Filter/... _and Selected", NULL, match_selected_ptree_cb, + MATCH_SELECTED_AND|MATCH_SELECTED_APPLY_NOW, NULL, NULL), + ITEM_FACTORY_ENTRY("/Analyze/Apply as Filter/... _or Selected", NULL, match_selected_ptree_cb, + MATCH_SELECTED_OR|MATCH_SELECTED_APPLY_NOW, NULL, NULL), + ITEM_FACTORY_ENTRY("/Analyze/Apply as Filter/... a_nd not Selected", NULL, match_selected_ptree_cb, + MATCH_SELECTED_AND_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL), + ITEM_FACTORY_ENTRY("/Analyze/Apply as Filter/... o_r not Selected", NULL, match_selected_ptree_cb, + MATCH_SELECTED_OR_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL), + ITEM_FACTORY_ENTRY("/Analyze/_Prepare a Filter", NULL, NULL, 0, "<Branch>", NULL), + ITEM_FACTORY_ENTRY("/Analyze/Prepare a Filter/_Selected", NULL, match_selected_ptree_cb, + MATCH_SELECTED_REPLACE, NULL, NULL), + ITEM_FACTORY_ENTRY("/Analyze/Prepare a Filter/_Not Selected", NULL, match_selected_ptree_cb, + MATCH_SELECTED_NOT, NULL, NULL), + ITEM_FACTORY_ENTRY("/Analyze/Prepare a Filter/... _and Selected", NULL, match_selected_ptree_cb, + MATCH_SELECTED_AND, NULL, NULL), + ITEM_FACTORY_ENTRY("/Analyze/Prepare a Filter/... _or Selected", NULL, match_selected_ptree_cb, + MATCH_SELECTED_OR, NULL, NULL), + ITEM_FACTORY_ENTRY("/Analyze/Prepare a Filter/... a_nd not Selected", NULL, match_selected_ptree_cb, + MATCH_SELECTED_AND_NOT, NULL, NULL), + ITEM_FACTORY_ENTRY("/Analyze/Prepare a Filter/... o_r not Selected", NULL, match_selected_ptree_cb, + MATCH_SELECTED_OR_NOT, NULL, NULL), + ITEM_FACTORY_ENTRY("/Analyze/<separator>", NULL, NULL, 0, "<Separator>", NULL), + ITEM_FACTORY_ENTRY("/Analyze/_Enabled Protocols...", "<shift><control>R", proto_cb, 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/Analyze/Decode _As...", NULL, decode_as_cb, + 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/Analyze/_User Specified Decodes...", NULL, + decode_show_cb, 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/Analyze/<separator>", NULL, NULL, 0, "<Separator>", NULL), + ITEM_FACTORY_ENTRY("/Analyze/_Follow TCP Stream", NULL, + follow_stream_cb, 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/_Statistics", NULL, NULL, 0, "<Branch>", NULL), + ITEM_FACTORY_ENTRY("/Statistics/_Summary", NULL, summary_open_cb, 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/Statistics/_Protocol Hierarchy", NULL, + proto_hier_stats_cb, 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/Statistics/Conversations", NULL, + init_ett_notebook_cb, 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/Statistics/Endpoints", NULL, + init_hostlist_notebook_cb, 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/_Help", NULL, NULL, 0, "<Branch>", NULL), + ITEM_FACTORY_STOCK_ENTRY("/Help/_Contents", "F1", help_cb, 0, GTK_STOCK_HELP), + ITEM_FACTORY_ENTRY("/Help/_Supported Protocols", NULL, supported_cb, 0, NULL, NULL), +#if (GLIB_MAJOR_VERSION >= 2) + /* currently, glib1.x can't start a webbrowser, see webbrowser.c for details */ + ITEM_FACTORY_ENTRY("/Help/Manual Pages", NULL, NULL, 0, "<Branch>", NULL), + ITEM_FACTORY_ENTRY("/Help/Manual Pages/Ethereal", NULL, url_localpage_cb, LOCALPAGE_MAN_ETHEREAL, NULL, NULL), + ITEM_FACTORY_ENTRY("/Help/Manual Pages/Ethereal Filter", NULL, url_localpage_cb, LOCALPAGE_MAN_ETHEREAL_FILTER, NULL, NULL), + ITEM_FACTORY_ENTRY("/Help/Manual Pages/<separator>", NULL, NULL, 0, "<Separator>", NULL), + ITEM_FACTORY_ENTRY("/Help/Manual Pages/Tethereal", NULL, url_localpage_cb, LOCALPAGE_MAN_TETHEREAL, NULL, NULL), + ITEM_FACTORY_ENTRY("/Help/Manual Pages/Mergecap", NULL, url_localpage_cb, LOCALPAGE_MAN_MERGECAP, NULL, NULL), + ITEM_FACTORY_ENTRY("/Help/Manual Pages/Editcap", NULL, url_localpage_cb, LOCALPAGE_MAN_EDITCAP, NULL, NULL), + ITEM_FACTORY_ENTRY("/Help/Manual Pages/Text2pcap", NULL, url_localpage_cb, LOCALPAGE_MAN_TEXT2PCAP, NULL, NULL), + ITEM_FACTORY_ENTRY("/Help/Ethereal Online", NULL, NULL, 0, "<Branch>", NULL), + ITEM_FACTORY_STOCK_ENTRY("/Help/Ethereal Online/Home Page", NULL, url_onlinepage_cb, ONLINEPAGE_HOME, GTK_STOCK_HOME), + ITEM_FACTORY_ENTRY("/Help/Ethereal Online/User's Guide", NULL, url_onlinepage_cb, ONLINEPAGE_USERGUIDE, NULL, NULL), + ITEM_FACTORY_ENTRY("/Help/Ethereal Online/FAQ's", NULL, url_onlinepage_cb, ONLINEPAGE_FAQ, NULL, NULL), + ITEM_FACTORY_ENTRY("/Help/Ethereal Online/Downloads", NULL, url_onlinepage_cb, ONLINEPAGE_DOWNLOAD, NULL, NULL), + ITEM_FACTORY_ENTRY("/Help/Ethereal Online/Example Files", NULL, url_onlinepage_cb, ONLINEPAGE_SAMPLE, NULL, NULL), +#endif + ITEM_FACTORY_ENTRY("/Help/<separator>", NULL, NULL, 0, "<Separator>", NULL), + ITEM_FACTORY_ENTRY("/Help/_About Ethereal", NULL, about_ethereal_cb, + 0, NULL, NULL) +}; + + +/* calculate the number of menu_items */ +static int nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]); + +/* packet list popup */ +static GtkItemFactoryEntry packet_list_menu_items[] = +{ + ITEM_FACTORY_ENTRY("/Follow TCP Stream", NULL, follow_stream_cb, + 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/Decode As...", NULL, decode_as_cb, 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/Display Filters...", NULL, dfilter_dialog_cb, + 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/<separator>", NULL, NULL, 0, "<Separator>", NULL), + ITEM_FACTORY_ENTRY("/Mark Packet", NULL, mark_frame_cb, 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/Time Reference", NULL, NULL, 0, "<Branch>", NULL), + ITEM_FACTORY_ENTRY("/Time Reference/Set Time Reference (toggle)", NULL, reftime_frame_cb, REFTIME_TOGGLE, NULL, NULL), + ITEM_FACTORY_ENTRY("/Time Reference/Find Next", NULL, reftime_frame_cb, REFTIME_FIND_NEXT, NULL, NULL), + ITEM_FACTORY_ENTRY("/Time Reference/Find Previous", NULL, reftime_frame_cb, REFTIME_FIND_PREV, NULL, NULL), + ITEM_FACTORY_ENTRY("/Apply as Filter", NULL, NULL, 0, "<Branch>", NULL), + ITEM_FACTORY_ENTRY("/Apply as Filter/_Selected", NULL, match_selected_plist_cb, + MATCH_SELECTED_REPLACE|MATCH_SELECTED_APPLY_NOW, NULL, NULL), + ITEM_FACTORY_ENTRY("/Apply as Filter/_Not Selected", NULL, match_selected_plist_cb, + MATCH_SELECTED_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL), + ITEM_FACTORY_ENTRY("/Apply as Filter/... _and Selected", NULL, match_selected_plist_cb, + MATCH_SELECTED_AND|MATCH_SELECTED_APPLY_NOW, NULL, NULL), + ITEM_FACTORY_ENTRY("/Apply as Filter/... _or Selected", NULL, match_selected_plist_cb, + MATCH_SELECTED_OR|MATCH_SELECTED_APPLY_NOW, NULL, NULL), + ITEM_FACTORY_ENTRY("/Apply as Filter/... a_nd not Selected", NULL, match_selected_plist_cb, + MATCH_SELECTED_AND_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL), + ITEM_FACTORY_ENTRY("/Apply as Filter/... o_r not Selected", NULL, match_selected_plist_cb, + MATCH_SELECTED_OR_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL), + + ITEM_FACTORY_ENTRY("/Prepare a Filter", NULL, NULL, 0, "<Branch>", NULL), + ITEM_FACTORY_ENTRY("/Prepare a Filter/_Selected", NULL, match_selected_plist_cb, + MATCH_SELECTED_REPLACE, NULL, NULL), + ITEM_FACTORY_ENTRY("/Prepare a Filter/_Not Selected", NULL, match_selected_plist_cb, + MATCH_SELECTED_NOT, NULL, NULL), + ITEM_FACTORY_ENTRY("/Prepare a Filter/... _and Selected", NULL, match_selected_plist_cb, + MATCH_SELECTED_AND, NULL, NULL), + ITEM_FACTORY_ENTRY("/Prepare a Filter/... _or Selected", NULL, match_selected_plist_cb, + MATCH_SELECTED_OR, NULL, NULL), + ITEM_FACTORY_ENTRY("/Prepare a Filter/... a_nd not Selected", NULL, match_selected_plist_cb, + MATCH_SELECTED_AND_NOT, NULL, NULL), + ITEM_FACTORY_ENTRY("/Prepare a Filter/... o_r not Selected", NULL, match_selected_plist_cb, + MATCH_SELECTED_OR_NOT, NULL, NULL), + + ITEM_FACTORY_ENTRY("/<separator>", NULL, NULL, 0, "<Separator>", NULL), + ITEM_FACTORY_ENTRY("/Coloring Rules...", NULL, color_display_cb, + 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/Print...", NULL, file_print_cmd_cb, 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/Show Packet in New Window", NULL, new_window_cb, + 0, NULL, NULL), +}; + +static GtkItemFactoryEntry tree_view_menu_items[] = +{ + ITEM_FACTORY_ENTRY("/Follow TCP Stream", NULL, follow_stream_cb, + 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/Decode As...", NULL, decode_as_cb, 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/Display Filters...", NULL, dfilter_dialog_cb, + 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/<separator>", NULL, NULL, 0, "<Separator>", NULL), + ITEM_FACTORY_ENTRY("/_Resolve Name", NULL, resolve_name_cb, 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/_Go to Corresponding Packet", NULL, goto_framenum_cb, 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/_Export Selected Packet Bytes...", NULL, savehex_cb, + 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/Protocol Preferences...", NULL, properties_cb, + 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/Apply as Filter", NULL, NULL, 0, "<Branch>", NULL), + ITEM_FACTORY_ENTRY("/Apply as Filter/_Selected", NULL, match_selected_ptree_cb, + MATCH_SELECTED_REPLACE|MATCH_SELECTED_APPLY_NOW, NULL, NULL), + ITEM_FACTORY_ENTRY("/Apply as Filter/_Not Selected", NULL, match_selected_ptree_cb, + MATCH_SELECTED_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL), + ITEM_FACTORY_ENTRY("/Apply as Filter/... _and Selected", NULL, match_selected_ptree_cb, + MATCH_SELECTED_AND|MATCH_SELECTED_APPLY_NOW, NULL, NULL), + ITEM_FACTORY_ENTRY("/Apply as Filter/... _or Selected", NULL, match_selected_ptree_cb, + MATCH_SELECTED_OR|MATCH_SELECTED_APPLY_NOW, NULL, NULL), + ITEM_FACTORY_ENTRY("/Apply as Filter/... a_nd not Selected", NULL, match_selected_ptree_cb, + MATCH_SELECTED_AND_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL), + ITEM_FACTORY_ENTRY("/Apply as Filter/... o_r not Selected", NULL, match_selected_ptree_cb, + MATCH_SELECTED_OR_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL), + + ITEM_FACTORY_ENTRY("/Prepare a Filter", NULL, NULL, 0, "<Branch>", NULL), + ITEM_FACTORY_ENTRY("/Prepare a Filter/_Selected", NULL, match_selected_ptree_cb, + MATCH_SELECTED_REPLACE, NULL, NULL), + ITEM_FACTORY_ENTRY("/Prepare a Filter/_Not Selected", NULL, match_selected_ptree_cb, + MATCH_SELECTED_NOT, NULL, NULL), + ITEM_FACTORY_ENTRY("/Prepare a Filter/... _and Selected", NULL, match_selected_ptree_cb, + MATCH_SELECTED_AND, NULL, NULL), + ITEM_FACTORY_ENTRY("/Prepare a Filter/... _or Selected", NULL, match_selected_ptree_cb, + MATCH_SELECTED_OR, NULL, NULL), + ITEM_FACTORY_ENTRY("/Prepare a Filter/... a_nd not Selected", NULL, match_selected_ptree_cb, + MATCH_SELECTED_AND_NOT, NULL, NULL), + ITEM_FACTORY_ENTRY("/Prepare a Filter/... o_r not Selected", NULL, match_selected_ptree_cb, + MATCH_SELECTED_OR_NOT, NULL, NULL), + ITEM_FACTORY_ENTRY("/<separator>", NULL, NULL, 0, "<Separator>", NULL), + ITEM_FACTORY_ENTRY("/Collapse All", NULL, collapse_all_cb, 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/Expand All", NULL, expand_all_cb, 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/Expand Tree", NULL, expand_tree_cb, 0, NULL, NULL) +}; + +static GtkItemFactoryEntry hexdump_menu_items[] = +{ + ITEM_FACTORY_ENTRY("/Follow TCP Stream", NULL, follow_stream_cb, + 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/Decode As...", NULL, decode_as_cb, 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/Display Filters...", NULL, dfilter_dialog_cb, + 0, NULL, NULL), + ITEM_FACTORY_ENTRY("/Export Selected Packet Bytes...", NULL, savehex_cb, + 0, NULL, NULL) +}; + +static int initialize = TRUE; +static GtkItemFactory *main_menu_factory = NULL; +static GtkItemFactory *packet_list_menu_factory = NULL; +static GtkItemFactory *tree_view_menu_factory = NULL; +static GtkItemFactory *hexdump_menu_factory = NULL; + +static GSList *popup_menu_list = NULL; + +static GtkAccelGroup *grp; + +GtkWidget * +main_menu_new(GtkAccelGroup ** table) { + GtkWidget *menubar; + + grp = gtk_accel_group_new(); + + if (initialize) + menus_init(); + + menubar = main_menu_factory->widget; + + if (table) + *table = grp; + + return menubar; +} + +static void +menus_init(void) { + if (initialize) { + initialize = FALSE; + + /* popup */ + packet_list_menu_factory = gtk_item_factory_new(GTK_TYPE_MENU, "<main>", NULL); + popup_menu_object = gtk_menu_new(); + gtk_item_factory_create_items_ac(packet_list_menu_factory, sizeof(packet_list_menu_items)/sizeof(packet_list_menu_items[0]), packet_list_menu_items, popup_menu_object, 2); + OBJECT_SET_DATA(popup_menu_object, PM_PACKET_LIST_KEY, + packet_list_menu_factory->widget); + popup_menu_list = g_slist_append((GSList *)popup_menu_list, packet_list_menu_factory); + + tree_view_menu_factory = gtk_item_factory_new(GTK_TYPE_MENU, "<main>", NULL); + gtk_item_factory_create_items_ac(tree_view_menu_factory, sizeof(tree_view_menu_items)/sizeof(tree_view_menu_items[0]), tree_view_menu_items, popup_menu_object, 2); + OBJECT_SET_DATA(popup_menu_object, PM_TREE_VIEW_KEY, + tree_view_menu_factory->widget); + popup_menu_list = g_slist_append((GSList *)popup_menu_list, tree_view_menu_factory); + + hexdump_menu_factory = gtk_item_factory_new(GTK_TYPE_MENU, "<main>", NULL); + gtk_item_factory_create_items_ac(hexdump_menu_factory, sizeof(hexdump_menu_items)/sizeof(hexdump_menu_items[0]), hexdump_menu_items, popup_menu_object, 2); + OBJECT_SET_DATA(popup_menu_object, PM_HEXDUMP_KEY, + hexdump_menu_factory->widget); + popup_menu_list = g_slist_append((GSList *)popup_menu_list, hexdump_menu_factory); + + /* main */ + main_menu_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", grp); + gtk_item_factory_create_items_ac(main_menu_factory, nmenu_items, menu_items, NULL, 2); + + merge_all_tap_menus(tap_menu_tree_root); + + /* Initialize enabled/disabled state of menu items */ + set_menus_for_unsaved_capture_file(FALSE); + set_menus_for_capture_file(FALSE); +#if 0 + /* Un-#if this when we actually implement Cut/Copy/Paste. + Then make sure you enable them when they can be done. */ + set_menu_sensitivity(main_menu_factory, "/Edit/Cut", FALSE); + set_menu_sensitivity(main_menu_factory, "/Edit/Copy", FALSE); + set_menu_sensitivity(main_menu_factory, "/Edit/Paste", FALSE); +#endif + + set_menus_for_captured_packets(FALSE); + set_menus_for_selected_packet(&cfile); + set_menus_for_selected_tree_row(&cfile); + + /* init with an empty recent files list */ + clear_menu_recent_capture_file_cmd_cb(NULL, NULL); + } +} + + +gint tap_menu_item_add_compare(gconstpointer a, gconstpointer b) +{ + return strcmp( + ((const menu_item_t *) a)->name, + ((const menu_item_t *) b)->name); +} + + +/* add a menuitem below the current node */ +GList * tap_menu_item_add( + char *name, + gint group, + GtkItemFactoryCallback callback, + gboolean (*selected_packet_enabled)(frame_data *, epan_dissect_t *), + gboolean (*selected_tree_row_enabled)(field_info *), + gpointer callback_data, + GList *curnode) +{ + menu_item_t *curr; + menu_item_t *child; + + + child = g_malloc(sizeof (menu_item_t)); + child->group = group; + child->name = name; + child->callback = callback; + child->selected_packet_enabled = selected_packet_enabled; + child->selected_tree_row_enabled = selected_tree_row_enabled; + child->callback_data = callback_data; + child->enabled = FALSE; + child->children = NULL; + + /* insert the new child node into the parent */ + curr = curnode->data; + curr->children = g_list_insert_sorted(curr->children, child, tap_menu_item_add_compare); + + /* return the new node */ + /* XXX: improve this */ + return g_list_find(curr->children, child); +} + +/* + * Add a new menu item for a tap. + * This must be called after we've created the main menu, so it can't + * be called from the routine that registers taps - we have to introduce + * another per-tap registration routine. + * + * "callback" gets called when the menu item is selected; it should do + * the work of creating the tap window. + * + * "selected_packet_enabled" gets called by "set_menus_for_selected_packet()"; + * it's passed a Boolean that's TRUE if a packet is selected and FALSE + * otherwise, and should return TRUE if the tap will work now (which + * might depend on whether a packet is selected and, if one is, on the + * packet) and FALSE if not. + * + * "selected_tree_row_enabled" gets called by + * "set_menus_for_selected_tree_row()"; it's passed a Boolean that's TRUE if + * a protocol tree row is selected and FALSE otherwise, and should return + * TRUE if the tap will work now (which might depend on whether a tree row + * is selected and, if one is, on the tree row) and FALSE if not. + */ +void +register_tap_menu_item( + char *name, + REGISTER_TAP_GROUP_E group, + GtkItemFactoryCallback callback, + gboolean (*selected_packet_enabled)(frame_data *, epan_dissect_t *), + gboolean (*selected_tree_row_enabled)(field_info *), + gpointer callback_data) +{ + /*static const char toolspath[] = "/Statistics/";*/ + char *toolspath; + char *p; + char *menupath; + size_t menupathlen; + menu_item_t *child; + GList *curnode; + GList *childnode; + + /* + * The menu path must be relative. + */ + g_assert(*name != '/'); + + switch(group) { + case(REGISTER_TAP_GROUP_GENERIC): toolspath = "/Statistics/"; break; + case(REGISTER_TAP_GROUP_CONVERSATION_LIST): toolspath = "/Statistics/_Conversation List/"; break; + case(REGISTER_TAP_GROUP_ENDPOINT_LIST): toolspath = "/Statistics/_Endpoint List/"; break; + case(REGISTER_TAP_GROUP_RESPONSE_TIME): toolspath = "/Statistics/Service _Response Time/"; break; + case(REGISTER_TAP_GROUP_NONE): toolspath = "/Statistics/"; break; + default: + g_assert(0); + toolspath = NULL; + } + + /* add the (empty) root node, if not already done */ + if(tap_menu_tree_root == NULL) { + child = g_malloc0(sizeof (menu_item_t)); + tap_menu_tree_root = g_list_append(NULL, child); + } + + /* + * Create any submenus required. + */ + curnode = tap_menu_tree_root; + p = name; + while ((p = strchr(p, '/')) != NULL) { + /* + * OK, everything between "name" and "p" is + * a menu relative subtree into which the menu item + * will be placed. + * + * Construct the absolute path name of that subtree. + */ + menupathlen = strlen(toolspath) + 1 + (p - name); + menupath = g_malloc(menupathlen); + strcpy(menupath, toolspath); + strncat(menupath, name, p - name); + + /* + * Does there exist an entry with that path at this + * level of the Analyze menu tree? + */ + child = curnode->data; + for (childnode = child->children; childnode != NULL; childnode = childnode->next) { + child = childnode->data; + if (strcmp(child->name, menupath) == 0) + break; + } + if (childnode == NULL) { + /* + * No. Create such an item as a subtree, and + * add it to the Tools menu tree. + */ + childnode = tap_menu_item_add( + menupath, group, NULL, NULL ,NULL, NULL, curnode); + } else { + /* + * Yes. We don't need this "menupath" any longer. + */ + g_free(menupath); + } + curnode = childnode; + + /* + * Skip over the '/' we found. + */ + p++; + } + + /* + * Construct the main menu path for the menu item. + */ + menupathlen = strlen(toolspath) + 1 + strlen(name); + menupath = g_malloc(menupathlen); + strcpy(menupath, toolspath); + strcat(menupath, name); + + /* + * Construct an item factory entry for the item, and add it to + * the main menu. + */ + tap_menu_item_add( + menupath, group, callback, + selected_packet_enabled, selected_tree_row_enabled, + callback_data, curnode); +} + + +guint merge_tap_menus_layered(GList *node, gint group) { + GtkItemFactoryEntry *entry; + GList *child; + guint added = 0; + menu_item_t *node_data = node->data; + + /* + * Is this a leaf node or an interior node? + */ + if (node_data->children == NULL) { + /* + * It's a leaf node. + */ + + /* + * The root node doesn't correspond to a menu tree item; it + * has a null name pointer. + */ + if (node_data->name != NULL && group == node_data->group) { + entry = g_malloc0(sizeof (GtkItemFactoryEntry)); + entry->path = node_data->name; + entry->callback = node_data->callback; + gtk_item_factory_create_item(main_menu_factory, entry, node_data->callback_data, 2); + set_menu_sensitivity(main_menu_factory, node_data->name, FALSE); /* no capture file yet */ + added++; + } + } else { + /* + * It's an interior node; call + * "merge_tap_menus_layered()" on all its children + */ + + /* + * The root node doesn't correspond to a menu tree item; it + * has a null name pointer. + */ + if (node_data->name != NULL && group == node_data->group) { + entry = g_malloc0(sizeof (GtkItemFactoryEntry)); + entry->path = node_data->name; + entry->item_type = "<Branch>"; + gtk_item_factory_create_item(main_menu_factory, entry, + NULL, 2); + set_menu_sensitivity(main_menu_factory, node_data->name, + FALSE); /* no children yet */ + added++; + } + + for (child = node_data->children; child != NULL; child = + child->next) { + added += merge_tap_menus_layered(child, group); + } + } + + return added; +} + + +void merge_all_tap_menus(GList *node) { + GtkItemFactoryEntry *entry; + + entry = g_malloc0(sizeof (GtkItemFactoryEntry)); + entry->item_type = "<Separator>"; + entry->path = "/Statistics/"; + + /* + * merge only the menu items of the specific group, + * and then append a seperator + */ + if (merge_tap_menus_layered(node, REGISTER_TAP_GROUP_GENERIC)) { + gtk_item_factory_create_item(main_menu_factory, entry, NULL, 2); + } + if (merge_tap_menus_layered(node, REGISTER_TAP_GROUP_CONVERSATION_LIST)) { + /*gtk_item_factory_create_item(main_menu_factory, entry, NULL, 2);*/ + } + if (merge_tap_menus_layered(node, REGISTER_TAP_GROUP_ENDPOINT_LIST)) { + /*gtk_item_factory_create_item(main_menu_factory, entry, NULL, 2);*/ + } + if (merge_tap_menus_layered(node, REGISTER_TAP_GROUP_RESPONSE_TIME)) { + gtk_item_factory_create_item(main_menu_factory, entry, NULL, 2); + } + if (merge_tap_menus_layered(node, REGISTER_TAP_GROUP_NONE)) { + /*gtk_item_factory_create_item(main_menu_factory, entry, NULL, 2);*/ + } +} + + + +/* + * Enable/disable menu sensitivity. + */ +static void +set_menu_sensitivity(GtkItemFactory *ifactory, const gchar *path, gint val) +{ + GSList *menu_list; + GtkWidget *menu_item; + gchar *dup; + gchar *dest; + + + /* the underscore character regularly confuses things, as it will prevent finding + * the menu_item, so it has to be removed first */ + dup = g_strdup(path); + dest = dup; + while(*path) { + if (*path != '_') { + *dest = *path; + dest++; + } + path++; + } + *dest = '\0'; + + if (ifactory == NULL) { + /* + * Do it for all pop-up menus. + */ + for (menu_list = popup_menu_list; menu_list != NULL; + menu_list = g_slist_next(menu_list)) + set_menu_sensitivity(menu_list->data, dup, val); + } else { + /* + * Do it for that particular menu. + */ + if ((menu_item = gtk_item_factory_get_widget(ifactory, dup)) != NULL) { + if (GTK_IS_MENU(menu_item)) { + /* + * "dup" refers to a submenu; "gtk_item_factory_get_widget()" + * gets the menu, not the item that, when selected, pops up + * the submenu. + * + * We have to change the latter item's sensitivity, so that + * it shows up normally if sensitive and grayed-out if + * insensitive. + */ + menu_item = gtk_menu_get_attach_widget(GTK_MENU(menu_item)); + } + gtk_widget_set_sensitive(menu_item, val); + } else{ + /* be sure this menu item *is* existing */ + g_assert_not_reached(); + } + } + + g_free(dup); +} + +void +set_menu_object_data_meat(GtkItemFactory *ifactory, gchar *path, gchar *key, gpointer data) +{ + GtkWidget *menu = NULL; + + if ((menu = gtk_item_factory_get_widget(ifactory, path)) != NULL) + OBJECT_SET_DATA(menu, key, data); +} + +void +set_menu_object_data (gchar *path, gchar *key, gpointer data) { + GSList *menu_list = popup_menu_list; + gchar *shortpath = strrchr(path, '/'); + + set_menu_object_data_meat(main_menu_factory, path, key, data); + while (menu_list != NULL) { + set_menu_object_data_meat(menu_list->data, shortpath, key, data); + menu_list = g_slist_next(menu_list); + } +} + + +/* Recently used capture files submenu: + * Submenu containing the recently used capture files. + * The capture filenames are always kept with the absolute path, to be independant + * of the current path. + * They are only stored inside the labels of the submenu (no separate list). */ + +#define MENU_RECENT_FILES_PATH "/File/Open Recent" +#define MENU_RECENT_FILES_KEY "Recent File Name" + +void +update_menu_recent_capture_file1(GtkWidget *widget, gpointer cnt) { + gchar *widget_cf_name; + + widget_cf_name = OBJECT_GET_DATA(widget, MENU_RECENT_FILES_KEY); + + /* if this menu item is a file, count it */ + if (widget_cf_name) { + (*(guint *)cnt)++; + } +} + + +/* update the menu */ +void +update_menu_recent_capture_file(GtkWidget *submenu_recent_files) { + guint cnt = 0; + + gtk_container_foreach(GTK_CONTAINER(submenu_recent_files), + update_menu_recent_capture_file1, &cnt); + + /* make parent menu item sensitive only, if we have any valid files in the list */ + set_menu_sensitivity(main_menu_factory, MENU_RECENT_FILES_PATH, cnt); +} + + +/* remove the capture filename from the "Recent Files" menu */ +void +remove_menu_recent_capture_file(GtkWidget *widget, gpointer unused _U_) { + GtkWidget *submenu_recent_files; + gchar *widget_cf_name; + + + widget_cf_name = OBJECT_GET_DATA(widget, MENU_RECENT_FILES_KEY); + g_free(widget_cf_name); + + /* get the submenu container item */ + submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH); + + /* XXX: is this all we need to do, to free the menu item and its label? + The reference count of widget will go to 0, so it'll be freed; + will that free the label? */ + gtk_container_remove(GTK_CONTAINER(submenu_recent_files), widget); +} + + +/* callback, if the user pushed the <Clear File List> item */ +static void +clear_menu_recent_capture_file_cmd_cb(GtkWidget *w _U_, gpointer unused _U_) { + GtkWidget *submenu_recent_files; + + + submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH); + + gtk_container_foreach(GTK_CONTAINER(submenu_recent_files), + remove_menu_recent_capture_file, NULL); + + update_menu_recent_capture_file(submenu_recent_files); +} + + +/* callback, if the user pushed a recent file submenu item */ +void +menu_open_recent_file_cmd(GtkWidget *w) +{ + GtkWidget *submenu_recent_files; + GtkWidget *menu_item_child; + gchar *cf_name; + int err; + + submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH); + + /* get capture filename from the menu item label */ + menu_item_child = (GTK_BIN(w))->child; + gtk_label_get(GTK_LABEL(menu_item_child), &cf_name); + + /* open and read the capture file (this will close an existing file) */ + if ((err = cf_open(cf_name, FALSE, &cfile)) == 0) { + cf_read(&cfile); + } else { + /* the capture file isn't existing any longer, remove menu item */ + /* XXX: ask user to remove item, it's maybe only a temporary problem */ + remove_menu_recent_capture_file(w, NULL); + } + + update_menu_recent_capture_file(submenu_recent_files); +} + +static void menu_open_recent_file_answered_cb(gpointer dialog _U_, gint btn, gpointer data _U_) +{ + switch(btn) { + case(ESD_BTN_YES): + /* save file first */ + file_save_as_cmd(after_save_open_recent_file, data); + break; + case(ESD_BTN_NO): + cf_close(&cfile); + menu_open_recent_file_cmd(data); + break; + case(ESD_BTN_CANCEL): + break; + default: + g_assert_not_reached(); + } +} + +void +menu_open_recent_file_cmd_cb(GtkWidget *widget, gpointer data _U_) { + gpointer dialog; + + + if((cfile.state != FILE_CLOSED) && !cfile.user_saved && prefs.gui_ask_unsaved) { + /* user didn't saved his current file, ask him */ + dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_YES_NO_CANCEL, + PRIMARY_TEXT_START "Save capture file before opening a new one?" PRIMARY_TEXT_END "\n\n" + "If you open a new capture file without saving, your current capture data will be discarded."); + simple_dialog_set_cb(dialog, menu_open_recent_file_answered_cb, widget); + } else { + /* unchanged file */ + menu_open_recent_file_cmd(widget); + } +} + +/* add the capture filename (with an absolute path) to the "Recent Files" menu */ +void +add_menu_recent_capture_file_absolute(gchar *cf_name) { + GtkWidget *submenu_recent_files; + GList *menu_item_list; + GList *li; + gchar *widget_cf_name; + gchar *normalized_cf_name; + GtkWidget *menu_item; + guint cnt; + + + + normalized_cf_name = g_strdup(cf_name); +#ifdef WIN32 + /* replace all slashes by backslashes */ + g_strdelimit(normalized_cf_name, "/", '\\'); +#endif + + /* get the submenu container item */ + submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH); + + /* convert container to a GList */ + menu_item_list = gtk_container_children(GTK_CONTAINER(submenu_recent_files)); + + /* iterate through list items of menu_item_list, + * removing special items, a maybe duplicate entry and every item above count_max */ + cnt = 1; + for (li = g_list_first(menu_item_list); li; li = li->next, cnt++) { + /* get capture filename */ + menu_item = GTK_WIDGET(li->data); + widget_cf_name = OBJECT_GET_DATA(menu_item, MENU_RECENT_FILES_KEY); + + /* if this element string is one of our special items (seperator, ...) or + * already in the list or + * this element is above maximum count (too old), remove it */ + if (!widget_cf_name || +#ifdef WIN32 + /* do a case insensitive compare on win32 */ +#if GLIB_MAJOR_VERSION < 2 + g_strncasecmp(widget_cf_name, normalized_cf_name, 1000) == 0 || +#else + g_ascii_strncasecmp(widget_cf_name, normalized_cf_name, 1000) == 0 || +#endif +#else /* WIN32 */ + /* do a case sensitive compare on unix */ + strncmp(widget_cf_name, normalized_cf_name, 1000) == 0 || +#endif + cnt >= prefs.gui_recent_files_count_max) { + remove_menu_recent_capture_file(li->data, NULL); + cnt--; + } + } + + g_list_free(menu_item_list); + + /* add new item at latest position */ + menu_item = gtk_menu_item_new_with_label(normalized_cf_name); + OBJECT_SET_DATA(menu_item, MENU_RECENT_FILES_KEY, normalized_cf_name); + gtk_menu_prepend (GTK_MENU(submenu_recent_files), menu_item); + SIGNAL_CONNECT_OBJECT(GTK_OBJECT(menu_item), "activate", + menu_open_recent_file_cmd_cb, (GtkObject *) menu_item); + gtk_widget_show (menu_item); + + /* add seperator at last position */ + menu_item = gtk_menu_item_new(); + gtk_menu_append (GTK_MENU(submenu_recent_files), menu_item); + gtk_widget_show (menu_item); + + /* add new "clear list" item at last position */ +#if GTK_MAJOR_VERSION < 2 + menu_item = gtk_menu_item_new_with_label("<Clear File List>"); +#else + menu_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLEAR, NULL); +#endif + gtk_menu_append (GTK_MENU(submenu_recent_files), menu_item); + SIGNAL_CONNECT_OBJECT(GTK_OBJECT(menu_item), "activate", + clear_menu_recent_capture_file_cmd_cb, (GtkObject *) menu_item); + gtk_widget_show (menu_item); + + update_menu_recent_capture_file(submenu_recent_files); +} + + +/* add the capture filename to the "Recent Files" menu */ +/* (will change nothing, if this filename is already in the menu) */ +void +add_menu_recent_capture_file(gchar *cf_name) { + gchar *curr; + gchar *absolute; + + + /* if this filename is an absolute path, we can use it directly */ + if (g_path_is_absolute(cf_name)) { + add_menu_recent_capture_file_absolute(cf_name); + return; + } + + /* this filename is not an absolute path, prepend the current dir */ + curr = g_get_current_dir(); + absolute = g_strdup_printf("%s%s%s", curr, G_DIR_SEPARATOR_S, cf_name); + add_menu_recent_capture_file_absolute(absolute); + g_free(curr); + g_free(absolute); +} + + +/* write all capture filenames of the menu to the user's recent file */ +void +menu_recent_file_write_all(FILE *rf) { + GtkWidget *submenu_recent_files; + GList *children; + GList *child; + gchar *cf_name; + + + submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH); + + /* we have to iterate backwards through the children's list, + * so we get the latest item last in the file. + * (don't use gtk_container_foreach() here, it will return the wrong iteration order) */ + children = gtk_container_children(GTK_CONTAINER(submenu_recent_files)); + child = g_list_last(children); + while(child != NULL) { + /* get capture filename from the menu item label */ + cf_name = OBJECT_GET_DATA(child->data, MENU_RECENT_FILES_KEY); + if (cf_name) { + fprintf (rf, RECENT_KEY_CAPTURE_FILE ": %s\n", cf_name); + } + + child = g_list_previous(child); + } + + g_list_free(children); +} + + +static void +main_toolbar_show_cb(GtkWidget *w _U_, gpointer d _U_) +{ + + /* save current setting in recent */ + recent.main_toolbar_show = GTK_CHECK_MENU_ITEM(w)->active; + + main_widgets_show_or_hide(); +} + + +static void +filter_toolbar_show_cb(GtkWidget *w _U_, gpointer d _U_) +{ + + /* save current setting in recent */ + recent.filter_toolbar_show = GTK_CHECK_MENU_ITEM(w)->active; + + main_widgets_show_or_hide(); +} + + +static void +packet_list_show_cb(GtkWidget *w _U_, gpointer d _U_) +{ + + /* save current setting in recent */ + recent.packet_list_show = GTK_CHECK_MENU_ITEM(w)->active; + + main_widgets_show_or_hide(); +} + + +static void +tree_view_show_cb(GtkWidget *w _U_, gpointer d _U_) +{ + + /* save current setting in recent */ + recent.tree_view_show = GTK_CHECK_MENU_ITEM(w)->active; + + main_widgets_show_or_hide(); +} + + +static void +byte_view_show_cb(GtkWidget *w _U_, gpointer d _U_) +{ + + /* save current setting in recent */ + recent.byte_view_show = GTK_CHECK_MENU_ITEM(w)->active; + + main_widgets_show_or_hide(); +} + + +static void +statusbar_show_cb(GtkWidget *w _U_, gpointer d _U_) +{ + + /* save current setting in recent */ + recent.statusbar_show = GTK_CHECK_MENU_ITEM(w)->active; + + main_widgets_show_or_hide(); +} + + +static void +timestamp_absolute_cb(GtkWidget *w _U_, gpointer d _U_) +{ + if (recent.gui_time_format != TS_ABSOLUTE) { + set_timestamp_setting(TS_ABSOLUTE); + recent.gui_time_format = TS_ABSOLUTE; + change_time_formats(&cfile); + } +} + +static void +timestamp_absolute_date_cb(GtkWidget *w _U_, gpointer d _U_) +{ + if (recent.gui_time_format != TS_ABSOLUTE_WITH_DATE) { + set_timestamp_setting(TS_ABSOLUTE_WITH_DATE); + recent.gui_time_format = TS_ABSOLUTE_WITH_DATE; + change_time_formats(&cfile); + } +} + +static void +timestamp_relative_cb(GtkWidget *w _U_, gpointer d _U_) +{ + if (recent.gui_time_format != TS_RELATIVE) { + set_timestamp_setting(TS_RELATIVE); + recent.gui_time_format = TS_RELATIVE; + change_time_formats(&cfile); + } +} + +static void +timestamp_delta_cb(GtkWidget *w _U_, gpointer d _U_) +{ + if (recent.gui_time_format != TS_DELTA) { + set_timestamp_setting(TS_DELTA); + recent.gui_time_format = TS_DELTA; + change_time_formats(&cfile); + } +} + +void +menu_name_resolution_changed(void) +{ + GtkWidget *menu = NULL; + + menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Name Resolution/Enable for MAC Layer"); + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), g_resolv_flags & RESOLV_MAC); + + menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Name Resolution/Enable for Network Layer"); + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), g_resolv_flags & RESOLV_NETWORK); + + menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Name Resolution/Enable for Transport Layer"); + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), g_resolv_flags & RESOLV_TRANSPORT); +} + +static void +name_resolution_mac_cb(GtkWidget *w _U_, gpointer d _U_) +{ + if (GTK_CHECK_MENU_ITEM(w)->active) { + g_resolv_flags |= RESOLV_MAC; + } else { + g_resolv_flags &= ~RESOLV_MAC; + } +} + +static void +name_resolution_network_cb(GtkWidget *w _U_, gpointer d _U_) +{ + if (GTK_CHECK_MENU_ITEM(w)->active) { + g_resolv_flags |= RESOLV_NETWORK; + } else { + g_resolv_flags &= ~RESOLV_NETWORK; + } +} + +static void +name_resolution_transport_cb(GtkWidget *w _U_, gpointer d _U_) +{ + if (GTK_CHECK_MENU_ITEM(w)->active) { + g_resolv_flags |= RESOLV_TRANSPORT; + } else { + g_resolv_flags &= ~RESOLV_TRANSPORT; + } +} + +#ifdef HAVE_LIBPCAP +static void +auto_scroll_live_cb(GtkWidget *w _U_, gpointer d _U_) +{ + auto_scroll_live = GTK_CHECK_MENU_ITEM(w)->active; +} +#endif + +/* the recent file read has finished, update the menu corresponding */ +void +menu_recent_read_finished(void) { + GtkWidget *menu = NULL; + + menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Main Toolbar"); + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.main_toolbar_show); + + menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Filter Toolbar"); + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.filter_toolbar_show); + + menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Statusbar"); + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.statusbar_show); + + menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Packet List"); + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.packet_list_show); + + menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Packet Details"); + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.tree_view_show); + + menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Packet Bytes"); + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.byte_view_show); + + menu_name_resolution_changed(); + +#ifdef HAVE_LIBPCAP + menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Auto Scroll in Live Capture"); + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), auto_scroll_live); +#endif + + main_widgets_rearrange(); + + /* don't change the time format, if we had a command line value */ + if (get_timestamp_setting() != TS_NOT_SET) { + recent.gui_time_format = get_timestamp_setting(); + } + + switch(recent.gui_time_format) { + case(TS_ABSOLUTE): + menu = gtk_item_factory_get_widget(main_menu_factory, + "/View/Time Display Format/Time of Day"); + /* set_active will not trigger the callback when activating an active item! */ + recent.gui_time_format = -1; + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), FALSE); + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE); + break; + case(TS_ABSOLUTE_WITH_DATE): + menu = gtk_item_factory_get_widget(main_menu_factory, + "/View/Time Display Format/Date and Time of Day"); + recent.gui_time_format = -1; + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE); + break; + case(TS_RELATIVE): + menu = gtk_item_factory_get_widget(main_menu_factory, + "/View/Time Display Format/Seconds Since Beginning of Capture"); + recent.gui_time_format = -1; + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE); + break; + case(TS_DELTA): + menu = gtk_item_factory_get_widget(main_menu_factory, + "/View/Time Display Format/Seconds Since Previous Packet"); + recent.gui_time_format = -1; + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE); + break; + default: + g_assert_not_reached(); + } +} + + +gint +popup_menu_handler(GtkWidget *widget, GdkEvent *event, gpointer data) +{ + GtkWidget *menu = (GtkWidget *)data; + GdkEventButton *event_button = NULL; + gint row, column; + + if(widget == NULL || event == NULL || data == NULL) { + return FALSE; + } + + /* + * If we ever want to make the menu differ based on what row + * and/or column we're above, we'd use "eth_clist_get_selection_info()" + * to find the row and column number for the coordinates; a CTree is, + * I guess, like a CList with one column(?) and the expander widget + * as a pixmap. + */ + /* Check if we are on packet_list object */ + if (widget == OBJECT_GET_DATA(popup_menu_object, E_MPACKET_LIST_KEY)) { + if (packet_list_get_event_row_column(widget, (GdkEventButton *)event, + &row, &column)) { + OBJECT_SET_DATA(popup_menu_object, E_MPACKET_LIST_ROW_KEY, + GINT_TO_POINTER(row)); + OBJECT_SET_DATA(popup_menu_object, E_MPACKET_LIST_COL_KEY, + GINT_TO_POINTER(column)); + packet_list_set_selected_row(row); + } + } + + /* Check if we are on tree_view object */ + if (widget == tree_view) { + tree_view_select(widget, (GdkEventButton *) event); + } + + /* Check if we are on byte_view object */ + if(widget == get_notebook_bv_ptr(byte_nb_ptr)) { + byte_view_select(widget, (GdkEventButton *) event); + } + + /* context menu handler (but the byte view notebook pages have their own handler) */ + if(event->type == GDK_BUTTON_PRESS && widget != byte_nb_ptr) { + event_button = (GdkEventButton *) event; + + /* To qoute the "Gdk Event Structures" doc: + * "Normally button 1 is the left mouse button, 2 is the middle button, and 3 is the right button" */ + if(event_button->button == 3) { + gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, + event_button->button, + event_button->time); + SIGNAL_EMIT_STOP_BY_NAME(widget, "button_press_event"); + return TRUE; + } + } +#if GTK_MAJOR_VERSION >= 2 + /* GDK_2BUTTON_PRESS is a doubleclick -> expand/collapse tree row */ + /* GTK version 1 seems to be doing this automatically */ + if (widget == tree_view && event->type == GDK_2BUTTON_PRESS) { + GtkTreePath *path; + + if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), + (gint) (((GdkEventButton *)event)->x), + (gint) (((GdkEventButton *)event)->y), + &path, NULL, NULL, NULL)) + { + if (gtk_tree_view_row_expanded(GTK_TREE_VIEW(widget), path)) + gtk_tree_view_collapse_row(GTK_TREE_VIEW(widget), path); + else + gtk_tree_view_expand_row(GTK_TREE_VIEW(widget), path, + FALSE); + gtk_tree_path_free(path); + } + } +#endif + return FALSE; +} + +/* Enable or disable menu items based on whether you have a capture file + you've finished reading. */ +void +set_menus_for_capture_file(gboolean have_capture_file) +{ + set_menu_sensitivity(main_menu_factory, "/File/Open...", have_capture_file); + set_menu_sensitivity(main_menu_factory, "/File/Open Recent", have_capture_file); + set_menu_sensitivity(main_menu_factory, "/File/Merge...", have_capture_file); + set_menu_sensitivity(main_menu_factory, "/File/Close", have_capture_file); + set_menu_sensitivity(main_menu_factory, "/File/Save As...", + have_capture_file); + set_menu_sensitivity(main_menu_factory, "/File/Export", have_capture_file); + set_menu_sensitivity(main_menu_factory, "/View/Reload", have_capture_file); + set_toolbar_for_capture_file(have_capture_file); + packets_bar_update(); +} + +/* Enable or disable menu items based on whether you have an unsaved + capture file you've finished reading. */ +void +set_menus_for_unsaved_capture_file(gboolean have_unsaved_capture_file) +{ + set_menu_sensitivity(main_menu_factory, "/File/Save", + have_unsaved_capture_file); + set_toolbar_for_unsaved_capture_file(have_unsaved_capture_file); +} + +/* Enable or disable menu items based on whether there's a capture in + progress. */ +void +set_menus_for_capture_in_progress(gboolean capture_in_progress) +{ + set_menu_sensitivity(main_menu_factory, "/File/Open...", + !capture_in_progress); + set_menu_sensitivity(main_menu_factory, "/File/Open Recent", + !capture_in_progress); +#ifdef HAVE_LIBPCAP + set_menu_sensitivity(main_menu_factory, "/Capture/Start...", + !capture_in_progress); + set_menu_sensitivity(main_menu_factory, "/Capture/Stop", + capture_in_progress); +#endif /* HAVE_LIBPCAP */ + set_toolbar_for_capture_in_progress(capture_in_progress); + + set_capture_if_dialog_for_capture_in_progress(capture_in_progress); +} + +/* Enable or disable menu items based on whether you have some captured + packets. */ +static gboolean +walk_menu_tree_for_captured_packets(GList *node, + gboolean have_captured_packets) +{ + gboolean is_enabled; + GList *child; + menu_item_t *node_data = node->data; + + /* + * Is this a leaf node or an interior node? + */ + if (node_data->children == NULL) { + /* + * It's a leaf node. + * + * If it has no "selected_packet_enabled()" or + * "selected_tree_row_enabled()" routines, we enable + * it. This allows tap windows to be popped up even + * if you have no capture file; this is done to let + * the user pop up multiple tap windows before reading + * in a capture file, so that they can be processed in + * parallel while the capture file is being read rather + * than one at at time as you pop up the windows, and to + * let the user pop up tap windows before starting an + * "Update list of packets in real time" capture, so that + * the statistics can be displayed while the capture is + * in progress. + * + * If it has either of those routines, we disable it for + * now - as long as, when a capture is first available, + * we don't get called after a packet or tree row is + * selected, that's OK. + * XXX - that should be done better. + */ + if (node_data->selected_packet_enabled == NULL && + node_data->selected_tree_row_enabled == NULL) + node_data->enabled = TRUE; + else + node_data->enabled = FALSE; + } else { + /* + * It's an interior node; call + * "walk_menu_tree_for_captured_packets()" on all its + * children and, if any of them are enabled, enable + * this node, otherwise disable it. + * + * XXX - should we just leave all interior nodes enabled? + * Which is a better UI choice? + */ + is_enabled = FALSE; + for (child = node_data->children; child != NULL; child = + child->next) { + if (walk_menu_tree_for_captured_packets(child, + have_captured_packets)) + is_enabled = TRUE; + } + node_data->enabled = is_enabled; + } + + /* + * The root node doesn't correspond to a menu tree item; it + * has a null name pointer. + */ + if (node_data->name != NULL) { + set_menu_sensitivity(main_menu_factory, node_data->name, + node_data->enabled); + } + return node_data->enabled; +} + +void +set_menus_for_captured_packets(gboolean have_captured_packets) +{ + set_menu_sensitivity(main_menu_factory, "/File/Print...", + have_captured_packets); + set_menu_sensitivity(packet_list_menu_factory, "/Print...", + have_captured_packets); + set_menu_sensitivity(main_menu_factory, "/Edit/Find Packet...", + have_captured_packets); + set_menu_sensitivity(main_menu_factory, "/Edit/Find Next", + have_captured_packets); + set_menu_sensitivity(main_menu_factory, "/Edit/Find Previous", + have_captured_packets); + set_menu_sensitivity(main_menu_factory, "/View/Zoom In", + have_captured_packets); + set_menu_sensitivity(main_menu_factory, "/View/Zoom Out", + have_captured_packets); + set_menu_sensitivity(main_menu_factory, "/View/Normal Size", + have_captured_packets); + set_menu_sensitivity(packet_list_menu_factory, "/Coloring Rules...", + have_captured_packets); + set_menu_sensitivity(main_menu_factory, "/Go/Go to Packet...", + have_captured_packets); + set_menu_sensitivity(main_menu_factory, "/Go/First Packet", + have_captured_packets); + set_menu_sensitivity(main_menu_factory, "/Go/Last Packet", + have_captured_packets); + set_menu_sensitivity(main_menu_factory, "/Statistics/Summary", + have_captured_packets); + set_menu_sensitivity(main_menu_factory, "/Statistics/Protocol Hierarchy", + have_captured_packets); + + walk_menu_tree_for_captured_packets(tap_menu_tree_root, + have_captured_packets); + set_toolbar_for_captured_packets(have_captured_packets); + packets_bar_update(); +} + +/* Enable or disable menu items based on whether a packet is selected and, + if so, on the properties of the packet. */ +static gboolean +walk_menu_tree_for_selected_packet(GList *node, frame_data *fd, + epan_dissect_t *edt) +{ + gboolean is_enabled; + GList *child; + menu_item_t *node_data = node->data; + + /* + * Is this a leaf node or an interior node? + */ + if (node_data->children == NULL) { + /* + * It's a leaf node. + * + * If it has no "selected_packet_enabled()" routine, + * leave its enabled/disabled status alone - it + * doesn't depend on whether we have a packet selected + * or not or on the selected packet. + * + * If it has a "selected_packet_enabled()" routine, + * call it and set the item's enabled/disabled status + * based on its return value. + */ + if (node_data->selected_packet_enabled != NULL) + node_data->enabled = node_data->selected_packet_enabled(fd, edt); + } else { + /* + * It's an interior node; call + * "walk_menu_tree_for_selected_packet()" on all its + * children and, if any of them are enabled, enable + * this node, otherwise disable it. + * + * XXX - should we just leave all interior nodes enabled? + * Which is a better UI choice? + */ + is_enabled = FALSE; + for (child = node_data->children; child != NULL; child = + child->next) { + if (walk_menu_tree_for_selected_packet(child, fd, edt)) + is_enabled = TRUE; + } + node_data->enabled = is_enabled; + } + + /* + * The root node doesn't correspond to a menu tree item; it + * has a null name pointer. + */ + if (node_data->name != NULL) { + set_menu_sensitivity(main_menu_factory, node_data->name, + node_data->enabled); + } + return node_data->enabled; +} + +void +set_menus_for_selected_packet(capture_file *cf) +{ + set_menu_sensitivity(main_menu_factory, "/Edit/Mark Packet", + cf->current_frame != NULL); + set_menu_sensitivity(packet_list_menu_factory, "/Mark Packet", + cf->current_frame != NULL); + set_menu_sensitivity(main_menu_factory, "/Edit/Time Reference", + cf->current_frame != NULL); + set_menu_sensitivity(packet_list_menu_factory, "/Time Reference", + cf->current_frame != NULL); + set_menu_sensitivity(main_menu_factory, "/Edit/Mark All Packets", + cf->current_frame != NULL); + set_menu_sensitivity(main_menu_factory, "/Edit/Unmark All Packets", + cf->current_frame != NULL); + set_menu_sensitivity(main_menu_factory, "/View/Collapse All", + cf->current_frame != NULL); + set_menu_sensitivity(tree_view_menu_factory, "/Collapse All", + cf->current_frame != NULL); + set_menu_sensitivity(main_menu_factory, "/View/Expand All", + cf->current_frame != NULL); + set_menu_sensitivity(tree_view_menu_factory, "/Expand All", + cf->current_frame != NULL); + set_menu_sensitivity(main_menu_factory, "/View/Show Packet in New Window", + cf->current_frame != NULL); + set_menu_sensitivity(packet_list_menu_factory, "/Show Packet in New Window", + cf->current_frame != NULL); + set_menu_sensitivity(main_menu_factory, "/Analyze/Follow TCP Stream", + cf->current_frame != NULL ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE); + set_menu_sensitivity(NULL, "/Follow TCP Stream", + cf->current_frame != NULL ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE); + set_menu_sensitivity(main_menu_factory, "/Analyze/Decode As...", + cf->current_frame != NULL && decode_as_ok()); + set_menu_sensitivity(NULL, "/Decode As...", + cf->current_frame != NULL && decode_as_ok()); + set_menu_sensitivity(main_menu_factory, "/View/Name Resolution/Resolve Name", + cf->current_frame != NULL && (g_resolv_flags & RESOLV_ALL_ADDRS) != RESOLV_ALL_ADDRS); + set_menu_sensitivity(tree_view_menu_factory, "/Resolve Name", + cf->current_frame != NULL && (g_resolv_flags & RESOLV_ALL_ADDRS) != RESOLV_ALL_ADDRS); + set_menu_sensitivity(packet_list_menu_factory, "/Apply as Filter", + cf->current_frame != NULL); + set_menu_sensitivity(packet_list_menu_factory, "/Prepare a Filter", + cf->current_frame != NULL); + + walk_menu_tree_for_selected_packet(tap_menu_tree_root, cf->current_frame, + cf->edt); + packets_bar_update(); +} + +/* Enable or disable menu items based on whether a tree row is selected + and, if so, on the properties of the tree row. */ +static gboolean +walk_menu_tree_for_selected_tree_row(GList *node, field_info *fi) +{ + gboolean is_enabled; + GList *child; + menu_item_t *node_data = node->data; + + /* + * Is this a leaf node or an interior node? + */ + if (node_data->children == NULL) { + /* + * It's a leaf node. + * + * If it has no "selected_tree_row_enabled()" routine, + * leave its enabled/disabled status alone - it + * doesn't depend on whether we have a tree row selected + * or not or on the selected tree row. + * + * If it has a "selected_tree_row_enabled()" routine, + * call it and set the item's enabled/disabled status + * based on its return value. + */ + if (node_data->selected_tree_row_enabled != NULL) + node_data->enabled = node_data->selected_tree_row_enabled(fi); + } else { + /* + * It's an interior node; call + * "walk_menu_tree_for_selected_tree_row()" on all its + * children and, if any of them are enabled, enable + * this node, otherwise disable it. + * + * XXX - should we just leave all interior nodes enabled? + * Which is a better UI choice? + */ + is_enabled = FALSE; + for (child = node_data->children; child != NULL; child = + child->next) { + if (walk_menu_tree_for_selected_tree_row(child, fi)) + is_enabled = TRUE; + } + node_data->enabled = is_enabled; + } + + /* + * The root node doesn't correspond to a menu tree item; it + * has a null name pointer. + */ + if (node_data->name != NULL) { + set_menu_sensitivity(main_menu_factory, node_data->name, + node_data->enabled); + } + return node_data->enabled; +} + +void +set_menus_for_selected_tree_row(capture_file *cf) +{ + gboolean properties; + + + set_menu_sensitivity(main_menu_factory, "/File/Export/Selected Packet Bytes...", + cf->finfo_selected != NULL); + set_menu_sensitivity(tree_view_menu_factory, "/Export Selected Packet Bytes...", + cf->finfo_selected != NULL); + set_menu_sensitivity(hexdump_menu_factory, "/Export Selected Packet Bytes...", + cf->finfo_selected != NULL); + + if (cf->finfo_selected != NULL) { + header_field_info *hfinfo = cf->finfo_selected->hfinfo; + if (hfinfo->parent == -1) { + properties = prefs_is_registered_protocol(hfinfo->abbrev); + } else { + properties = prefs_is_registered_protocol(proto_registrar_get_abbrev(hfinfo->parent)); + } + set_menu_sensitivity(main_menu_factory, + "/Go/Go to Corresponding Packet", hfinfo->type == FT_FRAMENUM); + set_menu_sensitivity(tree_view_menu_factory, + "/Go to Corresponding Packet", hfinfo->type == FT_FRAMENUM); + set_menu_sensitivity(main_menu_factory, "/Analyze/Apply as Filter", + proto_can_match_selected(cf->finfo_selected, cf->edt)); + set_menu_sensitivity(tree_view_menu_factory, "/Apply as Filter", + proto_can_match_selected(cf->finfo_selected, cf->edt)); + set_menu_sensitivity(main_menu_factory, "/Analyze/Prepare a Filter", + proto_can_match_selected(cf->finfo_selected, cf->edt)); + set_menu_sensitivity(tree_view_menu_factory, "/Prepare a Filter", + proto_can_match_selected(cf->finfo_selected, cf->edt)); + set_menu_sensitivity(tree_view_menu_factory, "/Protocol Preferences...", + properties); + set_menu_sensitivity(main_menu_factory, "/View/Expand Tree", cf->finfo_selected->tree_type != -1); + set_menu_sensitivity(tree_view_menu_factory, "/Expand Tree", cf->finfo_selected->tree_type != -1); + } else { + set_menu_sensitivity(main_menu_factory, + "/Go/Go to Corresponding Packet", FALSE); + set_menu_sensitivity(tree_view_menu_factory, + "/Go to Corresponding Packet", FALSE); + set_menu_sensitivity(main_menu_factory, "/Analyze/Apply as Filter", FALSE); + set_menu_sensitivity(tree_view_menu_factory, "/Apply as Filter", FALSE); + set_menu_sensitivity(main_menu_factory, "/Analyze/Prepare a Filter", FALSE); + set_menu_sensitivity(tree_view_menu_factory, "/Prepare a Filter", FALSE); + set_menu_sensitivity(tree_view_menu_factory, "/Protocol Preferences...", + FALSE); + set_menu_sensitivity(main_menu_factory, "/View/Expand Tree", FALSE); + set_menu_sensitivity(tree_view_menu_factory, "/Expand Tree", FALSE); + } + + walk_menu_tree_for_selected_tree_row(tap_menu_tree_root, cf->finfo_selected); +} diff --git a/gtk/menu.h b/gtk/menu.h index 16d1c5d733..e79637c322 100644 --- a/gtk/menu.h +++ b/gtk/menu.h @@ -1,7 +1,7 @@ /* menu.h * Menu definitions * - * $Id: menu.h,v 1.20 2004/06/04 17:16:57 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/mgcp_stat.c b/gtk/mgcp_stat.c index e84427b15e..247ee317ca 100644 --- a/gtk/mgcp_stat.c +++ b/gtk/mgcp_stat.c @@ -2,7 +2,7 @@ * mgcp-statistics for ethereal * Copyright 2003 Lars Roland * - * $Id: mgcp_stat.c,v 1.37 2004/06/02 07:12:10 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/mtp3_stat.c b/gtk/mtp3_stat.c index 4199fb5bca..02d46ebd21 100644 --- a/gtk/mtp3_stat.c +++ b/gtk/mtp3_stat.c @@ -5,7 +5,7 @@ * * Modified from gsm_map_stat.c * - * $Id: mtp3_stat.c,v 1.2 2004/05/23 23:24:06 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/mtp3_stat.h b/gtk/mtp3_stat.h index 26844fc536..3aded4a8fe 100644 --- a/gtk/mtp3_stat.h +++ b/gtk/mtp3_stat.h @@ -1,6 +1,6 @@ /* mtp3_stat.h * - * $Id: mtp3_stat.h,v 1.2 2004/06/02 18:44:10 ulfl Exp $ + * $Id$ * * Copyright 2004, Michael Lum <mlum [AT] telostech.com>, * In association with Telos Technology Inc. diff --git a/gtk/mtp3_summary.c b/gtk/mtp3_summary.c index 32eb053595..585bd020c3 100644 --- a/gtk/mtp3_summary.c +++ b/gtk/mtp3_summary.c @@ -6,7 +6,7 @@ * * Modified from gsm_map_summary.c * - * $Id: mtp3_summary.c,v 1.3 2004/05/23 23:24:06 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/nameres_prefs.c b/gtk/nameres_prefs.c index 2a85ede0a5..262d18ffa0 100644 --- a/gtk/nameres_prefs.c +++ b/gtk/nameres_prefs.c @@ -1,7 +1,7 @@ /* nameres_prefs.c * Dialog box for name resolution preferences * - * $Id: nameres_prefs.c,v 1.11 2004/05/27 16:43:01 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/nameres_prefs.h b/gtk/nameres_prefs.h index 9600d0fcf8..22866adc35 100644 --- a/gtk/nameres_prefs.h +++ b/gtk/nameres_prefs.h @@ -1,7 +1,7 @@ /* nameres_prefs.h * Definitions for name resolution preferences window * - * $Id: nameres_prefs.h,v 1.5 2004/06/04 20:05:31 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/packet_list.c b/gtk/packet_list.c index b6e4549cb8..abf61293d4 100644 --- a/gtk/packet_list.c +++ b/gtk/packet_list.c @@ -1,7 +1,7 @@ /* packet_list.c * packet list related functions 2002 Olivier Abad * - * $Id: packet_list.c,v 1.21 2004/06/17 16:35:25 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/packet_list.h b/gtk/packet_list.h index 1b4fe0cd44..a3f10bd385 100644 --- a/gtk/packet_list.h +++ b/gtk/packet_list.h @@ -1,7 +1,7 @@ /* packet_list.h * Declarations of GTK+-specific routines for managing the packet list. * - * $Id: packet_list.h,v 1.5 2004/06/17 16:35:25 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/packet_win.c b/gtk/packet_win.c index 34b9b1865e..cc232b56c6 100644 --- a/gtk/packet_win.c +++ b/gtk/packet_win.c @@ -3,7 +3,7 @@ * * Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com> * - * $Id: packet_win.c,v 1.45 2004/05/26 03:49:23 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/packet_win.h b/gtk/packet_win.h index 7f5d711dd2..e582ade17f 100644 --- a/gtk/packet_win.h +++ b/gtk/packet_win.h @@ -3,7 +3,7 @@ * * Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com> * - * $Id: packet_win.h,v 1.10 2004/06/02 18:44:10 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> diff --git a/gtk/plugins_dlg.c b/gtk/plugins_dlg.c index 3be4629d86..7d39128f85 100644 --- a/gtk/plugins_dlg.c +++ b/gtk/plugins_dlg.c @@ -1,7 +1,7 @@ /* plugins_dlg.c * Dialog boxes for plugins * - * $Id: plugins_dlg.c,v 1.37 2004/05/26 03:49:23 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/prefs_dlg.c b/gtk/prefs_dlg.c index 6e73d31a4c..b995eed15f 100644 --- a/gtk/prefs_dlg.c +++ b/gtk/prefs_dlg.c @@ -1,7 +1,7 @@ /* prefs_dlg.c * Routines for handling preferences * - * $Id: prefs_dlg.c,v 1.87 2004/06/10 10:09:58 guy Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/prefs_dlg.h b/gtk/prefs_dlg.h index 2c485e07a3..96cc238786 100644 --- a/gtk/prefs_dlg.h +++ b/gtk/prefs_dlg.h @@ -1,7 +1,7 @@ /* prefs_dlg.h * Definitions for preference handling routines * - * $Id: prefs_dlg.h,v 1.12 2004/06/04 20:05:31 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/print_dlg.c b/gtk/print_dlg.c index c37b2c2cf8..bd111dc078 100644 --- a/gtk/print_dlg.c +++ b/gtk/print_dlg.c @@ -1,7 +1,7 @@ /* print_dlg.c * Dialog boxes for printing and exporting to text files * - * $Id: print_dlg.c,v 1.81 2004/07/08 10:36:29 guy Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/print_mswin.c b/gtk/print_mswin.c index 9cd86eae06..4f805f6cf0 100644 --- a/gtk/print_mswin.c +++ b/gtk/print_mswin.c @@ -1,7 +1,7 @@ /* print_mswin.c * Printing support for MSWindows * - * $Id: print_mswin.c,v 1.7 2003/11/11 13:59:53 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/print_mswin.h b/gtk/print_mswin.h index 923dc3ff78..0f221eae62 100644 --- a/gtk/print_mswin.h +++ b/gtk/print_mswin.h @@ -1,7 +1,7 @@ /* print_mswin.h * Printing support for MSWindows * - * $Id: print_mswin.h,v 1.5 2004/06/02 20:14:51 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/print_prefs.c b/gtk/print_prefs.c index e867ee443c..c536dbd20e 100644 --- a/gtk/print_prefs.c +++ b/gtk/print_prefs.c @@ -1,7 +1,7 @@ /* print_prefs.c * Dialog boxes for preferences for printing * - * $Id: print_prefs.c,v 1.22 2004/05/26 04:21:49 guy Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/print_prefs.h b/gtk/print_prefs.h index 92d7388b0d..80df32775f 100644 --- a/gtk/print_prefs.h +++ b/gtk/print_prefs.h @@ -1,7 +1,7 @@ /* print_prefs.h * Definitions for print preferences window * - * $Id: print_prefs.h,v 1.9 2004/06/04 20:05:31 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> diff --git a/gtk/progress_dlg.c b/gtk/progress_dlg.c index 786078cf67..85231aed50 100644 --- a/gtk/progress_dlg.c +++ b/gtk/progress_dlg.c @@ -1,7 +1,7 @@ /* progress_dlg.c * Routines for progress-bar (modal) dialog * - * $Id: progress_dlg.c,v 1.23 2004/05/26 03:49:24 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/proto_dlg.c b/gtk/proto_dlg.c index 7053a263fb..cf7580fbe5 100644 --- a/gtk/proto_dlg.c +++ b/gtk/proto_dlg.c @@ -1,6 +1,6 @@ /* proto_dlg.c * - * $Id: proto_dlg.c,v 1.35 2004/06/10 10:09:58 guy Exp $ + * $Id$ * * Laurent Deniel <laurent.deniel@free.fr> * diff --git a/gtk/proto_dlg.h b/gtk/proto_dlg.h index fe0efa6e15..fb2c331f91 100644 --- a/gtk/proto_dlg.h +++ b/gtk/proto_dlg.h @@ -1,6 +1,6 @@ /* proto_dlg.h * - * $Id: proto_dlg.h,v 1.5 2004/06/04 20:05:31 ulfl Exp $ + * $Id$ * * Laurent Deniel <laurent.deniel@free.fr> * diff --git a/gtk/proto_draw.c b/gtk/proto_draw.c index fde570ef57..fa3eb1c39e 100644 --- a/gtk/proto_draw.c +++ b/gtk/proto_draw.c @@ -1,7 +1,7 @@ /* proto_draw.c * Routines for GTK+ packet display * - * $Id: proto_draw.c,v 1.108 2004/07/09 23:02:38 guy Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/proto_draw.h b/gtk/proto_draw.h index ce8d117840..6f9a95f3d0 100644 --- a/gtk/proto_draw.h +++ b/gtk/proto_draw.h @@ -1,7 +1,7 @@ /* proto_draw.h * Definitions for GTK+ packet display structures and routines * - * $Id: proto_draw.h,v 1.29 2004/06/05 13:28:13 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/proto_hier_stats_dlg.c b/gtk/proto_hier_stats_dlg.c index 4f98863f18..0777e190e8 100644 --- a/gtk/proto_hier_stats_dlg.c +++ b/gtk/proto_hier_stats_dlg.c @@ -1,6 +1,6 @@ /* proto_hier_stats_dlg.c * - * $Id: proto_hier_stats_dlg.c,v 1.18 2004/05/23 23:24:06 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/proto_hier_stats_dlg.h b/gtk/proto_hier_stats_dlg.h index 9bde408feb..6725ee9718 100644 --- a/gtk/proto_hier_stats_dlg.h +++ b/gtk/proto_hier_stats_dlg.h @@ -1,6 +1,6 @@ /* proto_hier_stats_dlg.h * - * $Id: proto_hier_stats_dlg.h,v 1.3 2004/06/02 22:13:04 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> diff --git a/gtk/range_utils.c b/gtk/range_utils.c index bc52e04699..fb00ccd566 100644 --- a/gtk/range_utils.c +++ b/gtk/range_utils.c @@ -1,7 +1,7 @@ /* range_utils.c * Packet range routines (save, print, ...) for GTK things * - * $Id: range_utils.c,v 1.3 2004/04/25 08:01:06 ulfl Exp $ + * $Id$ * * Ulf Lamping <ulf.lamping@web.de> * diff --git a/gtk/range_utils.h b/gtk/range_utils.h index 823217a470..3bd4303f4b 100644 --- a/gtk/range_utils.h +++ b/gtk/range_utils.h @@ -1,7 +1,7 @@ /* range_utils.h * Declarations of utilities to with range_utils.c (packet range dialog) * - * $Id: range_utils.h,v 1.2 2004/06/02 22:13:04 ulfl Exp $ + * $Id$ * * Ulf Lamping <ulf.lamping@web.de> * diff --git a/gtk/recent.c b/gtk/recent.c index 5a4e2781e6..bcf2137720 100644 --- a/gtk/recent.c +++ b/gtk/recent.c @@ -2,7 +2,7 @@ * Recent "preference" handling routines * Copyright 2004, Ulf Lamping <ulf.lamping@web.de> * - * $Id: recent.c,v 1.18 2004/07/09 21:13:22 guy Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/recent.h b/gtk/recent.h index 3c6d8e74b5..6307b58b1d 100644 --- a/gtk/recent.h +++ b/gtk/recent.h @@ -2,7 +2,7 @@ * Definitions for recent "preference" handling routines * Copyright 2004, Ulf Lamping <ulf.lamping@web.de> * - * $Id: recent.h,v 1.11 2004/06/04 17:16:58 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/rpc_progs.c b/gtk/rpc_progs.c index 3059bf47dc..af5ecf0c9b 100644 --- a/gtk/rpc_progs.c +++ b/gtk/rpc_progs.c @@ -1,7 +1,7 @@ /* rpc_progs.c * rpc_progs 2002 Ronnie Sahlberg * - * $Id: rpc_progs.c,v 1.25 2004/05/23 23:24:06 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/rpc_stat.c b/gtk/rpc_stat.c index 1c1a5b08cb..aea44c6919 100644 --- a/gtk/rpc_stat.c +++ b/gtk/rpc_stat.c @@ -1,7 +1,7 @@ /* rpc_stat.c * rpc_stat 2002 Ronnie Sahlberg * - * $Id: rpc_stat.c,v 1.48 2004/06/02 07:12:10 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/rtp_analysis.c b/gtk/rtp_analysis.c index c1e36d708a..615058cf2b 100644 --- a/gtk/rtp_analysis.c +++ b/gtk/rtp_analysis.c @@ -1,7 +1,7 @@ /* rtp_analysis.c * RTP analysis addition for ethereal * - * $Id: rtp_analysis.c,v 1.47 2004/06/30 06:58:58 guy Exp $ + * $Id$ * * Copyright 2003, Alcatel Business Systems * By Lars Ruoff <lars.ruoff@gmx.net> diff --git a/gtk/rtp_analysis.h b/gtk/rtp_analysis.h index b18fa0bebd..4adb04def6 100644 --- a/gtk/rtp_analysis.h +++ b/gtk/rtp_analysis.h @@ -1,7 +1,7 @@ /* rtp_analysis.h * RTP analysis addition for ethereal * - * $Id: rtp_analysis.h,v 1.2 2004/06/02 22:13:04 ulfl Exp $ + * $Id$ * * Copyright 2003, Alcatel Business Systems * By Lars Ruoff <lars.ruoff@gmx.net> diff --git a/gtk/rtp_stream.c b/gtk/rtp_stream.c index 647a01934a..44d38355e4 100644 --- a/gtk/rtp_stream.c +++ b/gtk/rtp_stream.c @@ -1,7 +1,7 @@ /* rtp_stream.c * RTP streams summary addition for ethereal * - * $Id: rtp_stream.c,v 1.15 2004/06/29 20:46:29 ulfl Exp $ + * $Id$ * * Copyright 2003, Alcatel Business Systems * By Lars Ruoff <lars.ruoff@gmx.net> diff --git a/gtk/rtp_stream.h b/gtk/rtp_stream.h index 6d7a387b7a..fa4f7278ee 100644 --- a/gtk/rtp_stream.h +++ b/gtk/rtp_stream.h @@ -1,7 +1,7 @@ /* rtp_stream.h * RTP streams summary addition for ethereal * - * $Id: rtp_stream.h,v 1.7 2004/06/04 20:05:31 ulfl Exp $ + * $Id$ * * Copyright 2003, Alcatel Business Systems * By Lars Ruoff <lars.ruoff@gmx.net> diff --git a/gtk/rtp_stream_dlg.c b/gtk/rtp_stream_dlg.c index c5fe83432a..e4a67c5567 100644 --- a/gtk/rtp_stream_dlg.c +++ b/gtk/rtp_stream_dlg.c @@ -1,7 +1,7 @@ /* rtp_stream_dlg.c * RTP streams summary addition for ethereal * - * $Id: rtp_stream_dlg.c,v 1.26 2004/06/30 21:17:55 etxrab Exp $ + * $Id$ * * Copyright 2003, Alcatel Business Systems * By Lars Ruoff <lars.ruoff@gmx.net> diff --git a/gtk/rtp_stream_dlg.h b/gtk/rtp_stream_dlg.h index a3efd09fb1..4f5cc5b82f 100644 --- a/gtk/rtp_stream_dlg.h +++ b/gtk/rtp_stream_dlg.h @@ -1,7 +1,7 @@ /* rtp_stream_dlg.h * RTP streams summary addition for ethereal * - * $Id: rtp_stream_dlg.h,v 1.2 2004/06/02 22:13:04 ulfl Exp $ + * $Id$ * * Copyright 2003, Alcatel Business Systems * By Lars Ruoff <lars.ruoff@gmx.net> @@ -2,7 +2,7 @@ * 2003 Ronnie Sahlberg * Sub-address types for MAC addresses * - * $Id: sat.h,v 1.1 2004/06/03 21:46:27 guy Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/service_response_time_table.c b/gtk/service_response_time_table.c index 8e1da8ceb0..db9ecc8fa6 100644 --- a/gtk/service_response_time_table.c +++ b/gtk/service_response_time_table.c @@ -3,7 +3,7 @@ * Helper routines common to all service response time statistics * tap. * - * $Id: service_response_time_table.c,v 1.19 2004/06/02 07:12:11 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/service_response_time_table.h b/gtk/service_response_time_table.h index f99bb3d527..223c9e8998 100644 --- a/gtk/service_response_time_table.h +++ b/gtk/service_response_time_table.h @@ -3,7 +3,7 @@ * Helper routines common to all service response time statistics * tap. * - * $Id: service_response_time_table.h,v 1.4 2004/06/05 12:12:13 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/simple_dialog.c b/gtk/simple_dialog.c index 64f81b0caf..a602a60e1b 100644 --- a/gtk/simple_dialog.c +++ b/gtk/simple_dialog.c @@ -1,7 +1,7 @@ /* simple_dialog.c * Simple message dialog box routines. * - * $Id: simple_dialog.c,v 1.40 2004/07/13 07:15:45 guy Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/sip_stat.c b/gtk/sip_stat.c index 3d68fdc244..6e37ffca44 100644 --- a/gtk/sip_stat.c +++ b/gtk/sip_stat.c @@ -1,7 +1,7 @@ /* sip_stat.c * sip_stat 2004 Martin Mathieson * - * $Id: sip_stat.c,v 1.6 2004/05/23 23:24:06 ulfl Exp $ + * $Id$ * Copied from http_stat.c * * Ethereal - Network traffic analyzer diff --git a/gtk/smb_stat.c b/gtk/smb_stat.c index 06ddd5d426..2463b0152e 100644 --- a/gtk/smb_stat.c +++ b/gtk/smb_stat.c @@ -1,7 +1,7 @@ /* smb_stat.c * smb_stat 2003 Ronnie Sahlberg * - * $Id: smb_stat.c,v 1.45 2004/06/02 07:12:11 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/stream_prefs.c b/gtk/stream_prefs.c index d3f3874087..bac2ebfac1 100644 --- a/gtk/stream_prefs.c +++ b/gtk/stream_prefs.c @@ -1,7 +1,7 @@ /* stream_prefs.c * Dialog boxes for preferences for the stream window * - * $Id: stream_prefs.c,v 1.20 2004/03/11 00:22:41 gerald Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/stream_prefs.h b/gtk/stream_prefs.h index 94a486e7ad..0e934d68ea 100644 --- a/gtk/stream_prefs.h +++ b/gtk/stream_prefs.h @@ -1,7 +1,7 @@ /* stream_prefs.h * Definitions for stream preferences window * - * $Id: stream_prefs.h,v 1.7 2004/06/04 20:05:31 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> diff --git a/gtk/summary_dlg.c b/gtk/summary_dlg.c index 13357c98bb..71dcd55cbb 100644 --- a/gtk/summary_dlg.c +++ b/gtk/summary_dlg.c @@ -1,7 +1,7 @@ /* summary_dlg.c * Routines for capture file summary window * - * $Id: summary_dlg.c,v 1.35 2004/06/18 20:23:10 guy Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/summary_dlg.h b/gtk/summary_dlg.h index 840d4d0109..3b33cd0804 100644 --- a/gtk/summary_dlg.h +++ b/gtk/summary_dlg.h @@ -1,7 +1,7 @@ /* summary_dlg.h * Routines for capture file summary window * - * $Id: summary_dlg.h,v 1.3 2004/06/02 22:13:04 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> diff --git a/gtk/supported_protos_dlg.c b/gtk/supported_protos_dlg.c index 29991eaffd..046528eeaf 100644 --- a/gtk/supported_protos_dlg.c +++ b/gtk/supported_protos_dlg.c @@ -2,7 +2,7 @@ * * Laurent Deniel <laurent.deniel@free.fr> * - * $Id: supported_protos_dlg.c,v 1.12 2004/06/17 16:35:25 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/supported_protos_dlg.h b/gtk/supported_protos_dlg.h index 360c39fed8..ef9dd8bd37 100644 --- a/gtk/supported_protos_dlg.h +++ b/gtk/supported_protos_dlg.h @@ -2,7 +2,7 @@ * * Laurent Deniel <laurent.deniel@free.fr> * - * $Id: supported_protos_dlg.h,v 1.3 2004/06/02 22:13:04 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> diff --git a/gtk/tap_dfilter_dlg.c b/gtk/tap_dfilter_dlg.c index 06f770b8f5..61ad674808 100644 --- a/gtk/tap_dfilter_dlg.c +++ b/gtk/tap_dfilter_dlg.c @@ -2,7 +2,7 @@ * Routines for display filter dialog used by gui taps * Copyright 2003 Lars Roland * - * $Id: tap_dfilter_dlg.c,v 1.10 2004/06/02 07:12:11 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/tap_dfilter_dlg.h b/gtk/tap_dfilter_dlg.h index b11645a0ca..331d003214 100644 --- a/gtk/tap_dfilter_dlg.h +++ b/gtk/tap_dfilter_dlg.h @@ -2,7 +2,7 @@ * Header file for display filter dialog used by GTK gui taps * Copyright 2003 Lars Roland * - * $Id: tap_dfilter_dlg.h,v 1.3 2004/06/02 22:13:04 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/tap_menu.h b/gtk/tap_menu.h index e4820e4fd8..0a4aefd723 100644 --- a/gtk/tap_menu.h +++ b/gtk/tap_menu.h @@ -1,7 +1,7 @@ /* tap_menu.h * Menu definitions for use by taps * - * $Id: tap_menu.h,v 1.6 2004/06/03 02:14:14 guy Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/tcp_graph.c b/gtk/tcp_graph.c index fc893ecf8f..446a525c01 100644 --- a/gtk/tcp_graph.c +++ b/gtk/tcp_graph.c @@ -3,7 +3,7 @@ * By Pavel Mores <pvl@uh.cz> * Win32 port: rwh@unifiedtech.com * - * $Id: tcp_graph.c,v 1.64 2004/06/17 16:35:25 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/text_page.c b/gtk/text_page.c index cdc7b433c5..5bdb519b45 100644 --- a/gtk/text_page.c +++ b/gtk/text_page.c @@ -1,6 +1,6 @@ /* text_page.c * - * $Id: text_page.c,v 1.3 2004/06/17 16:35:26 ulfl Exp $ + * $Id$ * * Ulf Lamping * diff --git a/gtk/text_page.h b/gtk/text_page.h index d21c3e93b2..893d371cc7 100644 --- a/gtk/text_page.h +++ b/gtk/text_page.h @@ -1,7 +1,7 @@ /* text_page.h * Declarations of routine to construct a simple text page from a file. * - * $Id: text_page.h,v 1.4 2004/06/05 09:57:11 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/toolbar.c b/gtk/toolbar.c index 209de0af68..81e8b62bf0 100644 --- a/gtk/toolbar.c +++ b/gtk/toolbar.c @@ -2,7 +2,7 @@ * The main toolbar * Copyright 2003, Ulf Lamping <ulf.lamping@web.de> * - * $Id: toolbar.c,v 1.29 2004/07/13 07:15:45 guy Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/toolbar.h b/gtk/toolbar.h index b6833c4b4d..ad01fe4ab2 100644 --- a/gtk/toolbar.h +++ b/gtk/toolbar.h @@ -2,7 +2,7 @@ * Definitions for toolbar utility routines * Copyright 2003, Ulf Lamping <ulf.lamping@web.de> * - * $Id: toolbar.h,v 1.9 2004/06/04 17:16:58 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/ui_util.c b/gtk/ui_util.c index 7fb8864e25..8132f9174e 100644 --- a/gtk/ui_util.c +++ b/gtk/ui_util.c @@ -1,7 +1,7 @@ /* ui_util.c * UI utility routines * - * $Id: ui_util.c,v 1.29 2004/07/07 05:36:10 guy Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/ui_util.h b/gtk/ui_util.h index 4100ece8c3..9ac69a2e89 100644 --- a/gtk/ui_util.h +++ b/gtk/ui_util.h @@ -1,7 +1,7 @@ /* ui_util.h * Definitions for UI utility routines * - * $Id: ui_util.h,v 1.16 2004/07/07 05:36:10 guy Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/webbrowser.h b/gtk/webbrowser.h index 1b8348d5c8..7765f0b127 100644 --- a/gtk/webbrowser.h +++ b/gtk/webbrowser.h @@ -1,7 +1,7 @@ /* webbrowser.h * Web browser activation functions * - * $Id: webbrowser.h,v 1.3 2004/07/01 09:35:33 jmayer Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/wsp_stat.c b/gtk/wsp_stat.c index a3a3713144..3809208584 100644 --- a/gtk/wsp_stat.c +++ b/gtk/wsp_stat.c @@ -1,7 +1,7 @@ /* wsp_stat.c * wsp_stat 2003 Jean-Michel FAYARD * - * $Id: wsp_stat.c,v 1.27 2004/05/23 23:24:07 ulfl Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> |