2 * Routines for packet capture windows
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@ethereal.com>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
35 #include <epan/packet.h>
38 #include <epan/addr_resolv.h>
41 #include "capture_dlg.h"
42 #include "filter_dlg.h"
43 #include "simple_dialog.h"
44 #include "dlg_utils.h"
45 #include "pcap-util.h"
46 #include "capture_combo_utils.h"
48 #include "ringbuffer.h"
49 #include <epan/filesystem.h>
50 #include "compat_macros.h"
53 #include "gtkglobals.h"
56 #include "capture-wpcap.h"
59 /* Capture callback data keys */
60 #define E_CAP_IFACE_KEY "cap_iface"
61 #define E_CAP_IFACE_IP_KEY "cap_iface_ip"
62 #define E_CAP_SNAP_CB_KEY "cap_snap_cb"
63 #define E_CAP_LT_OM_KEY "cap_lt_om"
64 #define E_CAP_LT_OM_LABEL_KEY "cap_lt_om_label"
66 #define E_CAP_BUFFER_SIZE_SB_KEY "cap_buffer_size_sb"
68 #define E_CAP_SNAP_SB_KEY "cap_snap_sb"
69 #define E_CAP_PROMISC_KEY "cap_promisc"
70 #define E_CAP_FILT_KEY "cap_filter_te"
71 #define E_CAP_FILE_TE_KEY "cap_file_te"
72 #define E_CAP_MULTI_FILES_ON_CB_KEY "cap_multi_files_on_cb"
73 #define E_CAP_RING_FILESIZE_CB_KEY "cap_ring_filesize_cb"
74 #define E_CAP_RING_FILESIZE_SB_KEY "cap_ring_filesize_sb"
75 #define E_CAP_RING_FILESIZE_OM_KEY "cap_ring_filesize_om"
76 #define E_CAP_FILE_DURATION_CB_KEY "cap_file_duration_cb"
77 #define E_CAP_FILE_DURATION_SB_KEY "cap_file_duration_sb"
78 #define E_CAP_FILE_DURATION_OM_KEY "cap_file_duration_om"
79 #define E_CAP_RING_NBF_CB_KEY "cap_ring_nbf_cb"
80 #define E_CAP_RING_NBF_SB_KEY "cap_ring_nbf_sb"
81 #define E_CAP_RING_NBF_LB_KEY "cap_ring_nbf_lb"
82 #define E_CAP_STOP_FILES_CB_KEY "cap_stop_files_cb"
83 #define E_CAP_STOP_FILES_SB_KEY "cap_stop_files_sb"
84 #define E_CAP_STOP_FILES_LB_KEY "cap_stop_files_lb"
85 #define E_CAP_SYNC_KEY "cap_sync"
86 #define E_CAP_AUTO_SCROLL_KEY "cap_auto_scroll"
87 #define E_CAP_HIDE_INFO_KEY "cap_hide_info"
88 #define E_CAP_STOP_PACKETS_CB_KEY "cap_stop_packets_cb"
89 #define E_CAP_STOP_PACKETS_SB_KEY "cap_stop_packets_sb"
90 #define E_CAP_STOP_PACKETS_LB_KEY "cap_stop_packets_lb"
91 #define E_CAP_STOP_FILESIZE_CB_KEY "cap_stop_filesize_cb"
92 #define E_CAP_STOP_FILESIZE_SB_KEY "cap_stop_filesize_sb"
93 #define E_CAP_STOP_FILESIZE_OM_KEY "cap_stop_filesize_om"
94 #define E_CAP_STOP_DURATION_CB_KEY "cap_stop_duration_cb"
95 #define E_CAP_STOP_DURATION_SB_KEY "cap_stop_duration_sb"
96 #define E_CAP_STOP_DURATION_OM_KEY "cap_stop_duration_om"
97 #define E_CAP_M_RESOLVE_KEY "cap_m_resolve"
98 #define E_CAP_N_RESOLVE_KEY "cap_n_resolve"
99 #define E_CAP_T_RESOLVE_KEY "cap_t_resolve"
101 #define E_CAP_OM_LT_VALUE_KEY "cap_om_lt_value"
104 capture_prep_file_cb(GtkWidget *file_bt, GtkWidget *file_te);
107 select_link_type_cb(GtkWidget *w, gpointer data);
110 capture_prep_adjust_sensitivity(GtkWidget *tb, gpointer parent_w);
113 capture_prep_ok_cb(GtkWidget *ok_bt, gpointer parent_w);
116 capture_prep_destroy_cb(GtkWidget *win, gpointer user_data);
119 capture_prep_interface_changed_cb(GtkWidget *entry, gpointer parent_w);
122 capture_stop_cb(GtkWidget *w _U_, gpointer d _U_)
128 * Keep a static pointer to the current "Capture Options" window, if
129 * any, so that if somebody tries to do "Capture:Start" while there's
130 * already a "Capture Options" window up, we just pop up the existing
131 * one, rather than creating a new one.
133 static GtkWidget *cap_open_w;
136 set_link_type_list(GtkWidget *linktype_om, GtkWidget *entry)
146 char err_buf[PCAP_ERRBUF_SIZE];
147 GtkWidget *lt_menu, *lt_menu_item;
149 data_link_info_t *data_link_info;
150 gchar *linktype_menu_label;
151 guint num_supported_link_types;
152 GtkWidget *linktype_lb = OBJECT_GET_DATA(linktype_om, E_CAP_LT_OM_LABEL_KEY);
154 GString *ip_str = g_string_new("IP address: ");
159 lt_menu = gtk_menu_new();
160 entry_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
161 if_text = g_strstrip(entry_text);
162 if_name = get_if_name(if_text);
165 * If the interface name is in the list of known interfaces, get
166 * its list of link-layer types and set the option menu to display it.
168 * If it's not, don't bother - the user might be in the middle of
169 * editing the list, or it might be a remote device in which case
170 * getting the list could take an arbitrarily-long period of time.
171 * The list currently won't contain any remote devices (as
172 * "pcap_findalldevs()" doesn't know about remote devices, and neither
173 * does the code we use if "pcap_findalldevs()" isn't available), but
174 * should contain all the local devices on which you can capture.
177 if (*if_name != '\0') {
179 * Try to get the list of known interfaces.
181 if_list = get_interface_list(&err, err_buf);
182 if (if_list != NULL) {
184 * We have the list - check it.
186 for (if_entry = if_list; if_entry != NULL;
187 if_entry = g_list_next(if_entry)) {
188 if_info = if_entry->data;
189 if (strcmp(if_info->name, if_name) == 0) {
192 * Get the list of link-layer types for it.
194 lt_list = get_pcap_linktype_list(if_name, err_buf);
196 /* create string of list of IP addresses of this interface */
197 for (; (curr_ip = g_slist_nth(if_info->ip_addr, ips)) != NULL; ips++) {
199 g_string_append(ip_str, ", ");
201 ip_addr = (if_addr_t *)curr_ip->data;
202 switch (ip_addr->type) {
205 g_string_append(ip_str,
206 ip_to_str((guint8 *)&ip_addr->ip_addr.ip4_addr));
210 g_string_append(ip_str,
211 ip6_to_str((struct e_in6_addr *)&ip_addr->ip_addr.ip6_addr));
215 g_assert_not_reached();
219 if (if_info->loopback)
220 g_string_append(ip_str, " (loopback)");
223 free_interface_list(if_list);
227 num_supported_link_types = 0;
228 for (lt_entry = lt_list; lt_entry != NULL; lt_entry = g_list_next(lt_entry)) {
229 data_link_info = lt_entry->data;
230 if (data_link_info->description != NULL) {
231 lt_menu_item = gtk_menu_item_new_with_label(data_link_info->description);
232 OBJECT_SET_DATA(lt_menu_item, E_CAP_LT_OM_KEY, linktype_om);
233 SIGNAL_CONNECT(lt_menu_item, "activate", select_link_type_cb,
234 GINT_TO_POINTER(data_link_info->dlt));
235 num_supported_link_types++;
237 /* Not supported - tell them about it but don't let them select it. */
238 linktype_menu_label = g_strdup_printf("%s (not supported)",
239 data_link_info->name);
240 lt_menu_item = gtk_menu_item_new_with_label(linktype_menu_label);
241 g_free(linktype_menu_label);
242 gtk_widget_set_sensitive(lt_menu_item, FALSE);
244 gtk_menu_append(GTK_MENU(lt_menu), lt_menu_item);
247 free_pcap_linktype_list(lt_list);
248 gtk_option_menu_set_menu(GTK_OPTION_MENU(linktype_om), lt_menu);
249 gtk_widget_set_sensitive(linktype_lb, num_supported_link_types >= 2);
250 gtk_widget_set_sensitive(linktype_om, num_supported_link_types >= 2);
252 if_ip_lb = OBJECT_GET_DATA(linktype_om, E_CAP_IFACE_KEY);
254 g_string_append(ip_str, "unknown");
256 gtk_label_set_text(GTK_LABEL(if_ip_lb), ip_str->str);
257 g_string_free(ip_str, TRUE);
261 #define TIME_UNIT_SECOND 0
262 #define TIME_UNIT_MINUTE 1
263 #define TIME_UNIT_HOUR 2
264 #define TIME_UNIT_DAY 3
265 #define MAX_TIME_UNITS 4
266 static char *time_unit_name[MAX_TIME_UNITS] = {
273 static GtkWidget *time_unit_option_menu_new(guint32 value) {
274 GtkWidget *unit_om, *menu, *menu_item;
277 unit_om=gtk_option_menu_new();
279 for(i=0;i<MAX_TIME_UNITS;i++){
280 menu_item=gtk_menu_item_new_with_label(time_unit_name[i]);
281 OBJECT_SET_DATA(menu_item, "time_unit", GINT_TO_POINTER(i));
282 gtk_menu_append(GTK_MENU(menu), menu_item);
285 /* the selected menu item can't be changed, once the option_menu
286 is created, so set the matching menu item now */
288 if(value >= 60 * 60 * 24) {
289 gtk_menu_set_active(GTK_MENU(menu), TIME_UNIT_DAY);
292 if(value >= 60 * 60) {
293 gtk_menu_set_active(GTK_MENU(menu), TIME_UNIT_HOUR);
297 gtk_menu_set_active(GTK_MENU(menu), TIME_UNIT_MINUTE);
300 gtk_menu_set_active(GTK_MENU(menu), TIME_UNIT_SECOND);
305 gtk_option_menu_set_menu(GTK_OPTION_MENU(unit_om), menu);
310 static guint32 time_unit_option_menu_convert_value(
314 if(value >= 60 * 60 * 24) {
315 return value / (60 * 60 * 24);
319 if(value >= 60 * 60) {
320 return value / (60 * 60);
332 static guint32 time_unit_option_menu_get_value(
336 GtkWidget *menu, *menu_item;
339 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(unit_om));
340 menu_item = gtk_menu_get_active(GTK_MENU(menu));
341 unit = GPOINTER_TO_INT(OBJECT_GET_DATA(menu_item, "time_unit"));
345 case(TIME_UNIT_SECOND):
348 case(TIME_UNIT_MINUTE):
351 case(TIME_UNIT_HOUR):
352 return value * 60 * 60;
355 return value * 60 * 60 * 24;
358 g_assert_not_reached();
364 #define SIZE_UNIT_BYTES 0
365 #define SIZE_UNIT_KILOBYTES 1
366 #define SIZE_UNIT_MEGABYTES 2
367 #define SIZE_UNIT_GIGABYTES 3
368 #define MAX_SIZE_UNITS 4
369 static char *size_unit_name[MAX_SIZE_UNITS] = {
376 static GtkWidget *size_unit_option_menu_new(guint32 value) {
377 GtkWidget *unit_om, *menu, *menu_item;
380 unit_om=gtk_option_menu_new();
382 for(i=0;i<MAX_SIZE_UNITS;i++){
383 menu_item=gtk_menu_item_new_with_label(size_unit_name[i]);
384 OBJECT_SET_DATA(menu_item, "size_unit", GINT_TO_POINTER(i));
385 gtk_menu_append(GTK_MENU(menu), menu_item);
388 /* the selected menu item can't be changed, once the option_menu
389 is created, so set the matching menu item now */
391 if(value >= 1024 * 1024 * 1024) {
392 gtk_menu_set_active(GTK_MENU(menu), SIZE_UNIT_GIGABYTES);
395 if(value >= 1024 * 1024) {
396 gtk_menu_set_active(GTK_MENU(menu), SIZE_UNIT_MEGABYTES);
400 gtk_menu_set_active(GTK_MENU(menu), SIZE_UNIT_KILOBYTES);
403 gtk_menu_set_active(GTK_MENU(menu), SIZE_UNIT_BYTES);
408 gtk_option_menu_set_menu(GTK_OPTION_MENU(unit_om), menu);
413 static guint32 size_unit_option_menu_set_value(
417 if(value >= 1024 * 1024 * 1024) {
418 return value / (1024 * 1024 * 1024);
422 if(value >= 1024 * 1024) {
423 return value / (1024 * 1024);
435 static guint32 size_unit_option_menu_convert_value(
439 GtkWidget *menu, *menu_item;
442 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(unit_om));
443 menu_item = gtk_menu_get_active(GTK_MENU(menu));
444 unit = GPOINTER_TO_INT(OBJECT_GET_DATA(menu_item, "size_unit"));
448 case(SIZE_UNIT_BYTES):
451 case(SIZE_UNIT_KILOBYTES):
452 if(value > G_MAXINT / 1024) {
458 case(SIZE_UNIT_MEGABYTES):
459 if(value > G_MAXINT / (1024 * 1024)) {
462 return value * 1024 * 1024;
465 case(SIZE_UNIT_GIGABYTES):
466 if(value > G_MAXINT / (1024 * 1024 * 1024)) {
469 return value * 1024 * 1024 * 1024;
473 g_assert_not_reached();
483 *main_hb, *left_vb, *right_vb,
485 *capture_fr, *capture_vb,
486 *if_hb, *if_cb, *if_lb,
487 *if_ip_hb, *if_ip_lb,
488 *linktype_hb, *linktype_lb, *linktype_om,
489 *snap_hb, *snap_cb, *snap_sb, *snap_lb,
491 *filter_hb, *filter_bt, *filter_te,
494 *file_hb, *file_bt, *file_lb, *file_te,
495 *multi_tb, *multi_files_on_cb,
496 *ring_filesize_cb, *ring_filesize_sb, *ring_filesize_om,
497 *file_duration_cb, *file_duration_sb, *file_duration_om,
498 *ringbuffer_nbf_cb, *ringbuffer_nbf_sb, *ringbuffer_nbf_lb,
499 *stop_files_cb, *stop_files_sb, *stop_files_lb,
501 *limit_fr, *limit_vb, *limit_tb,
502 *stop_packets_cb, *stop_packets_sb, *stop_packets_lb,
503 *stop_filesize_cb, *stop_filesize_sb, *stop_filesize_om,
504 *stop_duration_cb, *stop_duration_sb, *stop_duration_om,
506 *display_fr, *display_vb,
507 *sync_cb, *auto_scroll_cb, *hide_info_cb,
509 *resolv_fr, *resolv_vb,
510 *m_resolv_cb, *n_resolv_cb, *t_resolv_cb,
511 *bbox, *ok_bt, *cancel_bt,
513 #if GTK_MAJOR_VERSION < 2
514 GtkAccelGroup *accel_group;
516 GtkTooltips *tooltips;
517 GtkAdjustment *snap_adj, *ringbuffer_nbf_adj,
518 *stop_packets_adj, *stop_filesize_adj, *stop_duration_adj, *stop_files_adj, *ring_filesize_adj, *file_duration_adj;
519 GList *if_list, *combo_list;
522 char err_str[PCAP_ERRBUF_SIZE];
523 gchar *cant_get_if_list_errstr;
525 GtkAdjustment *buffer_size_adj;
526 GtkWidget *buffer_size_lb, *buffer_size_sb;
530 if (cap_open_w != NULL) {
531 /* There's already a "Capture Options" dialog box; reactivate it. */
532 reactivate_window(cap_open_w);
537 /* Is WPcap loaded? */
539 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
540 "Unable to load WinPcap (wpcap.dll); Ethereal will not be able\n"
541 "to capture packets.\n\n"
542 "In order to capture packets, WinPcap must be installed; see\n"
544 " http://winpcap.polito.it/\n"
548 " http://winpcap.mirror.ethereal.com/\n"
552 " http://www.mirrors.wiretapped.net/security/packet-capture/winpcap/\n"
554 "for a downloadable version of WinPcap and for instructions\n"
555 "on how to install WinPcap.");
560 if_list = get_interface_list(&err, err_str);
561 if (if_list == NULL && err == CANT_GET_INTERFACE_LIST) {
562 cant_get_if_list_errstr = cant_get_if_list_error_message(err_str);
563 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s",
564 cant_get_if_list_errstr);
565 g_free(cant_get_if_list_errstr);
568 cap_open_w = dlg_window_new("Ethereal: Capture Options");
570 tooltips = gtk_tooltips_new();
572 #if GTK_MAJOR_VERSION < 2
573 /* Accelerator group for the accelerators (or, as they're called in
574 Windows and, I think, in Motif, "mnemonics"; Alt+<key> is a mnemonic,
575 Ctrl+<key> is an accelerator). */
576 accel_group = gtk_accel_group_new();
577 gtk_window_add_accel_group(GTK_WINDOW(cap_open_w), accel_group);
580 main_vb = gtk_vbox_new(FALSE, 0);
581 gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
582 gtk_container_add(GTK_CONTAINER(cap_open_w), main_vb);
584 /* Capture-related options frame */
585 capture_fr = gtk_frame_new("Capture");
586 gtk_container_add(GTK_CONTAINER(main_vb), capture_fr);
588 capture_vb = gtk_vbox_new(FALSE, 3);
589 gtk_container_border_width(GTK_CONTAINER(capture_vb), 5);
590 gtk_container_add(GTK_CONTAINER(capture_fr), capture_vb);
593 if_hb = gtk_hbox_new(FALSE, 3);
594 gtk_container_add(GTK_CONTAINER(capture_vb), if_hb);
596 if_lb = gtk_label_new("Interface:");
597 gtk_box_pack_start(GTK_BOX(if_hb), if_lb, FALSE, FALSE, 6);
599 if_cb = gtk_combo_new();
600 combo_list = build_capture_combo_list(if_list, TRUE);
601 if (combo_list != NULL)
602 gtk_combo_set_popdown_strings(GTK_COMBO(if_cb), combo_list);
603 if (cfile.iface == NULL && prefs.capture_device != NULL) {
604 /* No interface was specified on the command line or in a previous
605 capture, but there is one specified in the preferences file;
606 make the one from the preferences file the default */
607 cfile.iface = g_strdup(prefs.capture_device);
609 if (cfile.iface != NULL)
610 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry), cfile.iface);
611 else if (combo_list != NULL) {
612 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry),
613 (char *)combo_list->data);
615 free_capture_combo_list(combo_list);
616 free_interface_list(if_list);
617 gtk_tooltips_set_tip(tooltips, GTK_COMBO(if_cb)->entry,
618 "Choose which interface (network card) will be used to capture packets from. "
619 "Be sure to select the correct one, as it's a common mistake to select the wrong interface.", NULL);
620 gtk_box_pack_start(GTK_BOX(if_hb), if_cb, TRUE, TRUE, 6);
622 if_ip_hb = gtk_hbox_new(FALSE, 3);
623 gtk_box_pack_start(GTK_BOX(capture_vb), if_ip_hb, FALSE, FALSE, 0);
625 if_ip_lb = gtk_label_new("");
626 gtk_box_pack_start(GTK_BOX(if_ip_hb), if_ip_lb, FALSE, FALSE, 6);
629 linktype_hb = gtk_hbox_new(FALSE, 3);
630 gtk_box_pack_start(GTK_BOX(capture_vb), linktype_hb, FALSE, FALSE, 0);
632 linktype_lb = gtk_label_new("Link-layer header type:");
633 gtk_box_pack_start(GTK_BOX(linktype_hb), linktype_lb, FALSE, FALSE, 6);
635 linktype_om = gtk_option_menu_new();
636 OBJECT_SET_DATA(linktype_om, E_CAP_LT_OM_LABEL_KEY, linktype_lb);
637 /* Default to "use the default" */
638 OBJECT_SET_DATA(linktype_om, E_CAP_OM_LT_VALUE_KEY, GINT_TO_POINTER(-1));
639 OBJECT_SET_DATA(linktype_om, E_CAP_IFACE_KEY, if_ip_lb);
640 set_link_type_list(linktype_om, GTK_COMBO(if_cb)->entry);
642 * XXX - in some cases, this is "multiple link-layer header types", e.g.
643 * some 802.11 interfaces on FreeBSD 5.2 and later, where you can request
644 * fake Ethernet, 802.11, or 802.11-plus-radio-information headers.
646 * In other cases, it's "multiple link-layer types", e.g., with recent
647 * versions of libpcap, a DAG card on an "HDLC" WAN, where you can
648 * request Cisco HDLC or PPP depending on what type of traffic is going
649 * over the WAN, or an Ethernet interface, where you can request Ethernet
650 * or DOCSIS, the latter being for some Cisco cable modem equipment that
651 * can be configured to send raw DOCSIS frames over an Ethernet inside
652 * Ethernet low-level framing, for traffic capture purposes.
654 * We leave it as "multiple link-layer types" for now.
656 gtk_tooltips_set_tip(tooltips, linktype_om,
657 "The selected interface supports multiple link-layer types; select the desired one.", NULL);
658 gtk_box_pack_start (GTK_BOX(linktype_hb), linktype_om, FALSE, FALSE, 0);
659 SIGNAL_CONNECT(GTK_ENTRY(GTK_COMBO(if_cb)->entry), "changed",
660 capture_prep_interface_changed_cb, linktype_om);
663 buffer_size_lb = gtk_label_new("Buffer size:");
664 gtk_box_pack_start (GTK_BOX(linktype_hb), buffer_size_lb, FALSE, FALSE, 0);
666 buffer_size_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat) capture_opts.buffer_size,
667 1, 65535, 1.0, 10.0, 0.0);
668 buffer_size_sb = gtk_spin_button_new (buffer_size_adj, 0, 0);
669 gtk_spin_button_set_value(GTK_SPIN_BUTTON (buffer_size_sb), (gfloat) capture_opts.buffer_size);
670 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (buffer_size_sb), TRUE);
671 WIDGET_SET_SIZE(buffer_size_sb, 80, -1);
672 gtk_tooltips_set_tip(tooltips, buffer_size_sb,
673 "The memory buffer size used while capturing. If you notice packet drops, you can try to increase this size.", NULL);
674 gtk_box_pack_start (GTK_BOX(linktype_hb), buffer_size_sb, FALSE, FALSE, 0);
676 buffer_size_lb = gtk_label_new("megabyte(s)");
677 gtk_box_pack_start (GTK_BOX(linktype_hb), buffer_size_lb, FALSE, FALSE, 0);
680 /* Promiscuous mode row */
681 promisc_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC(
682 "Capture packets in _promiscuous mode", accel_group);
683 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(promisc_cb),
684 capture_opts.promisc_mode);
685 gtk_tooltips_set_tip(tooltips, promisc_cb,
686 "Usually a network card will only capture the traffic sent to its own network address. "
687 "If you want to capture all traffic that the network card can \"see\", mark this option. "
688 "See the FAQ for some more details of capturing packets from a switched network.", NULL);
689 gtk_container_add(GTK_CONTAINER(capture_vb), promisc_cb);
691 /* Capture length row */
692 snap_hb = gtk_hbox_new(FALSE, 3);
693 gtk_container_add(GTK_CONTAINER(capture_vb), snap_hb);
695 snap_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC("_Limit each packet to", accel_group);
696 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(snap_cb),
697 capture_opts.has_snaplen);
698 SIGNAL_CONNECT(snap_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w);
699 gtk_tooltips_set_tip(tooltips, snap_cb,
700 "Limit the maximum number of bytes to be captured from each packet. This size includes the "
701 "link-layer header and all subsequent headers. ", NULL);
702 gtk_box_pack_start(GTK_BOX(snap_hb), snap_cb, FALSE, FALSE, 0);
704 snap_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat) capture_opts.snaplen,
705 MIN_PACKET_SIZE, WTAP_MAX_PACKET_SIZE, 1.0, 10.0, 0.0);
706 snap_sb = gtk_spin_button_new (snap_adj, 0, 0);
707 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (snap_sb), TRUE);
708 WIDGET_SET_SIZE(snap_sb, 80, -1);
709 gtk_box_pack_start (GTK_BOX(snap_hb), snap_sb, FALSE, FALSE, 0);
711 snap_lb = gtk_label_new("bytes");
712 gtk_misc_set_alignment(GTK_MISC(snap_lb), 0, 0.5);
713 gtk_box_pack_start(GTK_BOX(snap_hb), snap_lb, FALSE, FALSE, 0);
716 filter_hb = gtk_hbox_new(FALSE, 3);
717 gtk_box_pack_start(GTK_BOX(capture_vb), filter_hb, FALSE, FALSE, 0);
719 filter_bt = BUTTON_NEW_FROM_STOCK(ETHEREAL_STOCK_CAPTURE_FILTER_ENTRY);
720 SIGNAL_CONNECT(filter_bt, "clicked", capture_filter_construct_cb, NULL);
721 SIGNAL_CONNECT(filter_bt, "destroy", filter_button_destroy_cb, NULL);
722 gtk_tooltips_set_tip(tooltips, filter_bt,
723 "Select a capture filter to reduce the amount of packets to be captured. "
724 "See \"Capture Filters\" in the online help for further information how to use it.",
726 gtk_box_pack_start(GTK_BOX(filter_hb), filter_bt, FALSE, FALSE, 3);
728 filter_te = gtk_entry_new();
729 if (cfile.cfilter) gtk_entry_set_text(GTK_ENTRY(filter_te), cfile.cfilter);
730 OBJECT_SET_DATA(filter_bt, E_FILT_TE_PTR_KEY, filter_te);
731 gtk_tooltips_set_tip(tooltips, filter_te,
732 "Enter a capture filter to reduce the amount of packets to be captured. "
733 "See \"Capture Filters\" in the online help for further information how to use it.",
735 gtk_box_pack_start(GTK_BOX(filter_hb), filter_te, TRUE, TRUE, 3);
737 main_hb = gtk_hbox_new(FALSE, 5);
738 gtk_container_border_width(GTK_CONTAINER(main_hb), 0);
739 gtk_container_add(GTK_CONTAINER(main_vb), main_hb);
741 left_vb = gtk_vbox_new(FALSE, 0);
742 gtk_container_border_width(GTK_CONTAINER(left_vb), 0);
743 gtk_box_pack_start(GTK_BOX(main_hb), left_vb, TRUE, TRUE, 0);
745 right_vb = gtk_vbox_new(FALSE, 0);
746 gtk_container_border_width(GTK_CONTAINER(right_vb), 0);
747 gtk_box_pack_start(GTK_BOX(main_hb), right_vb, FALSE, FALSE, 0);
750 /* Capture file-related options frame */
751 file_fr = gtk_frame_new("Capture File(s)");
752 gtk_container_add(GTK_CONTAINER(left_vb), file_fr);
754 file_vb = gtk_vbox_new(FALSE, 3);
755 gtk_container_border_width(GTK_CONTAINER(file_vb), 5);
756 gtk_container_add(GTK_CONTAINER(file_fr), file_vb);
759 file_hb = gtk_hbox_new(FALSE, 3);
760 gtk_box_pack_start(GTK_BOX(file_vb), file_hb, FALSE, FALSE, 0);
762 file_lb = gtk_label_new("File:");
763 gtk_box_pack_start(GTK_BOX(file_hb), file_lb, FALSE, FALSE, 3);
765 file_te = gtk_entry_new();
766 gtk_tooltips_set_tip(tooltips, file_te,
767 "Enter the file name to which captured data will be written. "
768 "If you don't enter something here, a temporary file will be used.",
770 gtk_box_pack_start(GTK_BOX(file_hb), file_te, TRUE, TRUE, 3);
772 file_bt = BUTTON_NEW_FROM_STOCK(ETHEREAL_STOCK_BROWSE);
773 gtk_tooltips_set_tip(tooltips, file_bt,
774 "Select a file to which captured data will be written, "
775 "instead of entering the file name directly. ",
777 gtk_box_pack_start(GTK_BOX(file_hb), file_bt, FALSE, FALSE, 3);
779 SIGNAL_CONNECT(file_bt, "clicked", capture_prep_file_cb, file_te);
781 /* multiple files table */
782 multi_tb = gtk_table_new(5, 3, FALSE);
783 gtk_table_set_row_spacings(GTK_TABLE(multi_tb), 1);
784 gtk_table_set_col_spacings(GTK_TABLE(multi_tb), 3);
785 gtk_box_pack_start(GTK_BOX(file_vb), multi_tb, FALSE, FALSE, 0);
788 /* multiple files row */
789 multi_files_on_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC("Use _multiple files", accel_group);
790 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(multi_files_on_cb),
791 capture_opts.multi_files_on);
792 SIGNAL_CONNECT(multi_files_on_cb, "toggled", capture_prep_adjust_sensitivity,
794 gtk_tooltips_set_tip(tooltips, multi_files_on_cb,
795 "Instead of using a single capture file, multiple files will be created. "
796 "The generated file names will contain an incrementing number and the start time of the capture.", NULL);
797 gtk_table_attach_defaults(GTK_TABLE(multi_tb), multi_files_on_cb, 0, 1, row, row+1);
800 /* Ring buffer filesize row */
801 ring_filesize_cb = gtk_check_button_new_with_label("Next file every");
802 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(ring_filesize_cb),
803 capture_opts.has_autostop_filesize);
804 SIGNAL_CONNECT(ring_filesize_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w);
805 gtk_tooltips_set_tip(tooltips, ring_filesize_cb,
806 "If the selected file size is exceeded, capturing switches to the next file.",
808 gtk_table_attach_defaults(GTK_TABLE(multi_tb), ring_filesize_cb, 0, 1, row, row+1);
810 ring_filesize_adj = (GtkAdjustment *) gtk_adjustment_new(0.0,
811 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
812 ring_filesize_sb = gtk_spin_button_new (ring_filesize_adj, 0, 0);
813 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (ring_filesize_sb), TRUE);
814 WIDGET_SET_SIZE(ring_filesize_sb, 80, -1);
815 gtk_table_attach_defaults(GTK_TABLE(multi_tb), ring_filesize_sb, 1, 2, row, row+1);
817 ring_filesize_om = size_unit_option_menu_new(capture_opts.autostop_filesize);
818 gtk_table_attach_defaults(GTK_TABLE(multi_tb), ring_filesize_om, 2, 3, row, row+1);
820 value = size_unit_option_menu_set_value(capture_opts.autostop_filesize);
821 gtk_adjustment_set_value(ring_filesize_adj, (gfloat) value);
825 /* Ring buffer duration row */
826 file_duration_cb = gtk_check_button_new_with_label("Next file every");
827 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(file_duration_cb),
828 capture_opts.has_file_duration);
829 SIGNAL_CONNECT(file_duration_cb, "toggled",
830 capture_prep_adjust_sensitivity, cap_open_w);
831 gtk_tooltips_set_tip(tooltips, file_duration_cb,
832 "If the selected duration is exceeded, capturing switches to the next file.",
834 gtk_table_attach_defaults(GTK_TABLE(multi_tb), file_duration_cb, 0, 1, row, row+1);
836 file_duration_adj = (GtkAdjustment *)gtk_adjustment_new(0.0,
837 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
838 file_duration_sb = gtk_spin_button_new (file_duration_adj, 0, 0);
839 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (file_duration_sb), TRUE);
840 WIDGET_SET_SIZE(file_duration_sb, 80, -1);
841 gtk_table_attach_defaults(GTK_TABLE(multi_tb), file_duration_sb, 1, 2, row, row+1);
843 file_duration_om = time_unit_option_menu_new(capture_opts.file_duration);
844 gtk_table_attach_defaults(GTK_TABLE(multi_tb), file_duration_om, 2, 3, row, row+1);
846 value = time_unit_option_menu_convert_value(capture_opts.file_duration);
847 gtk_adjustment_set_value(file_duration_adj, (gfloat) value);
850 /* Ring buffer files row */
851 ringbuffer_nbf_cb = gtk_check_button_new_with_label("Ring buffer with");
852 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb),
853 capture_opts.has_ring_num_files);
854 SIGNAL_CONNECT(ringbuffer_nbf_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w);
855 gtk_tooltips_set_tip(tooltips, ringbuffer_nbf_cb,
856 "After capturing has switched to the next file and the given number of files has exceeded, "
857 "the oldest file will be removed.",
859 gtk_table_attach_defaults(GTK_TABLE(multi_tb), ringbuffer_nbf_cb, 0, 1, row, row+1);
861 ringbuffer_nbf_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat) capture_opts.ring_num_files,
862 2/*RINGBUFFER_MIN_NUM_FILES*/, RINGBUFFER_MAX_NUM_FILES, 1.0, 10.0, 0.0);
863 ringbuffer_nbf_sb = gtk_spin_button_new (ringbuffer_nbf_adj, 0, 0);
864 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (ringbuffer_nbf_sb), TRUE);
865 WIDGET_SET_SIZE(ringbuffer_nbf_sb, 80, -1);
866 SIGNAL_CONNECT(ringbuffer_nbf_sb, "changed", capture_prep_adjust_sensitivity, cap_open_w);
867 gtk_table_attach_defaults(GTK_TABLE(multi_tb), ringbuffer_nbf_sb, 1, 2, row, row+1);
869 ringbuffer_nbf_lb = gtk_label_new("files");
870 gtk_misc_set_alignment(GTK_MISC(ringbuffer_nbf_lb), 0, 0.5);
871 gtk_table_attach_defaults(GTK_TABLE(multi_tb), ringbuffer_nbf_lb, 2, 3, row, row+1);
875 stop_files_cb = gtk_check_button_new_with_label("Stop capture after");
876 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(stop_files_cb),
877 capture_opts.has_autostop_files);
878 SIGNAL_CONNECT(stop_files_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w);
879 gtk_tooltips_set_tip(tooltips, stop_files_cb,
880 "Stop capturing after the given number of \"file switches\" have been done.", NULL);
881 gtk_table_attach_defaults(GTK_TABLE(multi_tb), stop_files_cb, 0, 1, row, row+1);
883 stop_files_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat)capture_opts.autostop_files,
884 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
885 stop_files_sb = gtk_spin_button_new (stop_files_adj, 0, 0);
886 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_files_sb), TRUE);
887 WIDGET_SET_SIZE(stop_files_sb, 80, -1);
888 gtk_table_attach_defaults(GTK_TABLE(multi_tb), stop_files_sb, 1, 2, row, row+1);
890 stop_files_lb = gtk_label_new("file(s)");
891 gtk_misc_set_alignment(GTK_MISC(stop_files_lb), 0, 0.5);
892 gtk_table_attach_defaults(GTK_TABLE(multi_tb), stop_files_lb, 2, 3, row, row+1);
895 /* Capture limits frame */
896 limit_fr = gtk_frame_new("Stop Capture ...");
897 gtk_container_add(GTK_CONTAINER(left_vb), limit_fr);
899 limit_vb = gtk_vbox_new(FALSE, 3);
900 gtk_container_border_width(GTK_CONTAINER(limit_vb), 5);
901 gtk_container_add(GTK_CONTAINER(limit_fr), limit_vb);
904 limit_tb = gtk_table_new(3, 3, FALSE);
905 gtk_table_set_row_spacings(GTK_TABLE(limit_tb), 1);
906 gtk_table_set_col_spacings(GTK_TABLE(limit_tb), 3);
907 gtk_box_pack_start(GTK_BOX(limit_vb), limit_tb, FALSE, FALSE, 0);
910 /* Packet count row */
911 stop_packets_cb = gtk_check_button_new_with_label("... after");
912 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(stop_packets_cb),
913 capture_opts.has_autostop_packets);
914 SIGNAL_CONNECT(stop_packets_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w);
915 gtk_tooltips_set_tip(tooltips, stop_packets_cb,
916 "Stop capturing after the given number of packets have been captured.", NULL);
917 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_packets_cb, 0, 1, row, row+1);
919 stop_packets_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat)capture_opts.autostop_packets,
920 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
921 stop_packets_sb = gtk_spin_button_new (stop_packets_adj, 0, 0);
922 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_packets_sb), TRUE);
923 WIDGET_SET_SIZE(stop_packets_sb, 80, -1);
924 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_packets_sb, 1, 2, row, row+1);
926 stop_packets_lb = gtk_label_new("packet(s)");
927 gtk_misc_set_alignment(GTK_MISC(stop_packets_lb), 0, 0.5);
928 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_packets_lb, 2, 3, row, row+1);
932 stop_filesize_cb = gtk_check_button_new_with_label("... after");
933 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(stop_filesize_cb),
934 capture_opts.has_autostop_filesize);
935 SIGNAL_CONNECT(stop_filesize_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w);
936 gtk_tooltips_set_tip(tooltips, stop_filesize_cb,
937 "Stop capturing after the given amount of capture data has been captured.", NULL);
938 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_filesize_cb, 0, 1, row, row+1);
940 stop_filesize_adj = (GtkAdjustment *) gtk_adjustment_new(0.0,
941 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
942 stop_filesize_sb = gtk_spin_button_new (stop_filesize_adj, 0, 0);
943 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_filesize_sb), TRUE);
944 WIDGET_SET_SIZE(stop_filesize_sb, 80, -1);
945 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_filesize_sb, 1, 2, row, row+1);
947 stop_filesize_om = size_unit_option_menu_new(capture_opts.autostop_filesize);
948 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_filesize_om, 2, 3, row, row+1);
950 value = size_unit_option_menu_set_value(capture_opts.autostop_filesize);
951 gtk_adjustment_set_value(stop_filesize_adj, (gfloat) value);
956 stop_duration_cb = gtk_check_button_new_with_label("... after");
957 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(stop_duration_cb),
958 capture_opts.has_autostop_duration);
959 SIGNAL_CONNECT(stop_duration_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w);
960 gtk_tooltips_set_tip(tooltips, stop_duration_cb,
961 "Stop capturing after the given time is exceeded.", NULL);
962 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_duration_cb, 0, 1, row, row+1);
964 stop_duration_adj = (GtkAdjustment *) gtk_adjustment_new(0.0,
965 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
966 stop_duration_sb = gtk_spin_button_new (stop_duration_adj, 0, 0);
967 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_duration_sb), TRUE);
968 WIDGET_SET_SIZE(stop_duration_sb, 80, -1);
969 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_duration_sb, 1, 2, row, row+1);
971 stop_duration_om = time_unit_option_menu_new(capture_opts.autostop_duration);
972 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_duration_om, 2, 3, row, row+1);
974 value = time_unit_option_menu_convert_value(capture_opts.autostop_duration);
975 gtk_adjustment_set_value(stop_duration_adj, (gfloat) value);
978 /* Display-related options frame */
979 display_fr = gtk_frame_new("Display Options");
980 gtk_container_add(GTK_CONTAINER(right_vb), display_fr);
982 display_vb = gtk_vbox_new(FALSE, 0);
983 gtk_container_border_width(GTK_CONTAINER(display_vb), 5);
984 gtk_container_add(GTK_CONTAINER(display_fr), display_vb);
986 /* "Update display in real time" row */
987 sync_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC(
988 "_Update list of packets in real time", accel_group);
989 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(sync_cb),
990 capture_opts.sync_mode);
991 SIGNAL_CONNECT(sync_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w);
992 gtk_tooltips_set_tip(tooltips, sync_cb,
993 "Using this option will show the captured packets immediately on the main screen. "
994 "Please note: this will slow down capturing, so increased packet drops might appear.", NULL);
995 gtk_container_add(GTK_CONTAINER(display_vb), sync_cb);
997 /* "Auto-scroll live update" row */
998 auto_scroll_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC(
999 "_Automatic scrolling in live capture", accel_group);
1000 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(auto_scroll_cb), auto_scroll_live);
1001 gtk_tooltips_set_tip(tooltips, auto_scroll_cb,
1002 "This will scroll the \"Packet List\" automatically to the latest captured packet, "
1003 "when the \"Update List of packets in real time\" option is used.", NULL);
1004 gtk_container_add(GTK_CONTAINER(display_vb), auto_scroll_cb);
1006 /* "Hide capture info" row */
1007 hide_info_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC(
1008 "_Hide capture info dialog", accel_group);
1009 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(hide_info_cb), !capture_opts.show_info);
1010 gtk_tooltips_set_tip(tooltips, hide_info_cb,
1011 "Hide the capture info dialog while capturing.", NULL);
1012 gtk_container_add(GTK_CONTAINER(display_vb), hide_info_cb);
1014 /* Name Resolution frame */
1015 resolv_fr = gtk_frame_new("Name Resolution");
1016 gtk_container_add(GTK_CONTAINER(right_vb), resolv_fr);
1018 resolv_vb = gtk_vbox_new(FALSE, 0);
1019 gtk_container_border_width(GTK_CONTAINER(resolv_vb), 5);
1020 gtk_container_add(GTK_CONTAINER(resolv_fr), resolv_vb);
1022 m_resolv_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC(
1023 "Enable _MAC name resolution", accel_group);
1024 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(m_resolv_cb),
1025 g_resolv_flags & RESOLV_MAC);
1026 gtk_tooltips_set_tip(tooltips, m_resolv_cb,
1027 "Perform MAC layer name resolution while capturing.", NULL);
1028 gtk_container_add(GTK_CONTAINER(resolv_vb), m_resolv_cb);
1030 n_resolv_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC(
1031 "Enable _network name resolution", accel_group);
1032 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(n_resolv_cb),
1033 g_resolv_flags & RESOLV_NETWORK);
1034 gtk_tooltips_set_tip(tooltips, n_resolv_cb,
1035 "Perform network layer name resolution while capturing.", NULL);
1036 gtk_container_add(GTK_CONTAINER(resolv_vb), n_resolv_cb);
1038 t_resolv_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC(
1039 "Enable _transport name resolution", accel_group);
1040 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(t_resolv_cb),
1041 g_resolv_flags & RESOLV_TRANSPORT);
1042 gtk_tooltips_set_tip(tooltips, t_resolv_cb,
1043 "Perform transport layer name resolution while capturing.", NULL);
1044 gtk_container_add(GTK_CONTAINER(resolv_vb), t_resolv_cb);
1046 /* Button row: OK and cancel buttons */
1047 bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL);
1048 gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 5);
1050 ok_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_OK);
1051 SIGNAL_CONNECT(ok_bt, "clicked", capture_prep_ok_cb, cap_open_w);
1052 gtk_tooltips_set_tip(tooltips, ok_bt,
1053 "Start the capture process.", NULL);
1055 cancel_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CANCEL);
1056 gtk_tooltips_set_tip(tooltips, cancel_bt,
1057 "Cancel and exit dialog.", NULL);
1058 window_set_cancel_button(cap_open_w, cancel_bt, window_cancel_button_cb);
1060 help_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_HELP);
1061 gtk_tooltips_set_tip(tooltips, help_bt,
1062 "Show help about capturing.", NULL);
1063 #ifdef ETHEREAL_EUG_DIR
1064 SIGNAL_CONNECT(help_bt, "clicked", url_page_cb, HELP_CAPTURE_OPTIONS_DIALOG);
1066 SIGNAL_CONNECT(help_bt, "clicked", help_topic_cb, "Capturing");
1069 gtk_widget_grab_default(ok_bt);
1071 /* Attach pointers to needed widgets to the capture prefs window/object */
1072 OBJECT_SET_DATA(cap_open_w, E_CAP_IFACE_KEY, if_cb);
1073 OBJECT_SET_DATA(cap_open_w, E_CAP_SNAP_CB_KEY, snap_cb);
1074 OBJECT_SET_DATA(cap_open_w, E_CAP_SNAP_SB_KEY, snap_sb);
1075 OBJECT_SET_DATA(cap_open_w, E_CAP_LT_OM_KEY, linktype_om);
1077 OBJECT_SET_DATA(cap_open_w, E_CAP_BUFFER_SIZE_SB_KEY, buffer_size_sb);
1079 OBJECT_SET_DATA(cap_open_w, E_CAP_PROMISC_KEY, promisc_cb);
1080 OBJECT_SET_DATA(cap_open_w, E_CAP_FILT_KEY, filter_te);
1081 OBJECT_SET_DATA(cap_open_w, E_CAP_FILE_TE_KEY, file_te);
1082 OBJECT_SET_DATA(cap_open_w, E_CAP_MULTI_FILES_ON_CB_KEY, multi_files_on_cb);
1083 OBJECT_SET_DATA(cap_open_w, E_CAP_RING_NBF_CB_KEY, ringbuffer_nbf_cb);
1084 OBJECT_SET_DATA(cap_open_w, E_CAP_RING_NBF_SB_KEY, ringbuffer_nbf_sb);
1085 OBJECT_SET_DATA(cap_open_w, E_CAP_RING_NBF_LB_KEY, ringbuffer_nbf_lb);
1086 OBJECT_SET_DATA(cap_open_w, E_CAP_RING_FILESIZE_CB_KEY, ring_filesize_cb);
1087 OBJECT_SET_DATA(cap_open_w, E_CAP_RING_FILESIZE_SB_KEY, ring_filesize_sb);
1088 OBJECT_SET_DATA(cap_open_w, E_CAP_RING_FILESIZE_OM_KEY, ring_filesize_om);
1089 OBJECT_SET_DATA(cap_open_w, E_CAP_FILE_DURATION_CB_KEY, file_duration_cb);
1090 OBJECT_SET_DATA(cap_open_w, E_CAP_FILE_DURATION_SB_KEY, file_duration_sb);
1091 OBJECT_SET_DATA(cap_open_w, E_CAP_FILE_DURATION_OM_KEY, file_duration_om);
1092 OBJECT_SET_DATA(cap_open_w, E_CAP_SYNC_KEY, sync_cb);
1093 OBJECT_SET_DATA(cap_open_w, E_CAP_AUTO_SCROLL_KEY, auto_scroll_cb);
1094 OBJECT_SET_DATA(cap_open_w, E_CAP_HIDE_INFO_KEY, hide_info_cb);
1095 OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_PACKETS_CB_KEY, stop_packets_cb);
1096 OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_PACKETS_SB_KEY, stop_packets_sb);
1097 OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_PACKETS_LB_KEY, stop_packets_lb);
1098 OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_FILESIZE_CB_KEY, stop_filesize_cb);
1099 OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_FILESIZE_SB_KEY, stop_filesize_sb);
1100 OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_FILESIZE_OM_KEY, stop_filesize_om);
1101 OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_DURATION_CB_KEY, stop_duration_cb);
1102 OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_DURATION_SB_KEY, stop_duration_sb);
1103 OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_DURATION_OM_KEY, stop_duration_om);
1104 OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_FILES_CB_KEY, stop_files_cb);
1105 OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_FILES_SB_KEY, stop_files_sb);
1106 OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_FILES_LB_KEY, stop_files_lb);
1107 OBJECT_SET_DATA(cap_open_w, E_CAP_M_RESOLVE_KEY, m_resolv_cb);
1108 OBJECT_SET_DATA(cap_open_w, E_CAP_N_RESOLVE_KEY, n_resolv_cb);
1109 OBJECT_SET_DATA(cap_open_w, E_CAP_T_RESOLVE_KEY, t_resolv_cb);
1111 /* Set the sensitivity of various widgets as per the settings of other
1113 capture_prep_adjust_sensitivity(NULL, cap_open_w);
1115 /* Catch the "activate" signal on the text
1116 entries, so that if the user types Return there, we act as if the
1117 "OK" button had been selected, as happens if Return is typed if some
1118 widget that *doesn't* handle the Return key has the input focus. */
1119 dlg_set_activate(GTK_COMBO(if_cb)->entry, ok_bt);
1120 dlg_set_activate(filter_te, ok_bt);
1121 dlg_set_activate(file_te, ok_bt);
1123 /* XXX - why does not
1125 gtk_widget_grab_focus(if_cb);
1127 give the initial focus to the "Interface" combo box?
1129 Or should I phrase that as "why does GTK+ continually frustrate
1130 attempts to make GUIs driveable from the keyboard?" We have to
1131 go catch the activate signal on every single GtkEntry widget
1132 (rather than having widgets whose activate signal is *not*
1133 caught not catch the Return keystroke, so that it passes on,
1134 ultimately, to the window, which can activate the default
1135 widget, i.e. the "OK" button); we have to catch the "key_press_event"
1136 signal and have the handler check for ESC, so that we can have ESC
1137 activate the "Cancel" button; in order to support Alt+<key> mnemonics
1138 for buttons and the like, we may have to construct an accelerator
1139 group by hand and set up the accelerators by hand (if that even
1140 works - I've not tried it yet); we have to do a "gtk_widget_grab_focus()"
1141 to keep some container widget from getting the initial focus, so that
1142 you don't have to tab into the first widget in order to start typing
1143 in it; and it now appears that you simply *can't* make a combo box
1144 get the initial focus, at least not in the obvious fashion. Sigh.... */
1146 SIGNAL_CONNECT(cap_open_w, "delete_event", window_delete_event_cb, NULL);
1147 SIGNAL_CONNECT(cap_open_w, "destroy", capture_prep_destroy_cb, NULL);
1149 /* Give the initial focus to the "Filter" entry box. */
1150 gtk_widget_grab_focus(filter_te);
1152 gtk_widget_show_all(cap_open_w);
1153 window_present(cap_open_w);
1157 capture_prep_answered_cb(gpointer dialog _U_, gint btn, gpointer data)
1161 /* save file first */
1162 file_save_as_cmd(after_save_capture_dialog, data);
1164 case(ESD_BTN_DONT_SAVE):
1167 case(ESD_BTN_CANCEL):
1170 g_assert_not_reached();
1175 capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
1179 if((cfile.state != FILE_CLOSED) && !cfile.user_saved && prefs.gui_ask_unsaved) {
1180 /* user didn't saved his current file, ask him */
1181 dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_SAVE_DONTSAVE_CANCEL,
1182 PRIMARY_TEXT_START "Save capture file before starting a new capture?" PRIMARY_TEXT_END "\n\n"
1183 "If you start a new capture without saving, your current capture data will\nbe discarded.");
1184 simple_dialog_set_cb(dialog, capture_prep_answered_cb, NULL);
1186 /* unchanged file, just capture a new one */
1192 select_link_type_cb(GtkWidget *w, gpointer data)
1194 int new_linktype = GPOINTER_TO_INT(data);
1195 GtkWidget *linktype_om = OBJECT_GET_DATA(w, E_CAP_LT_OM_KEY);
1196 int old_linktype = GPOINTER_TO_INT(OBJECT_GET_DATA(linktype_om, E_CAP_OM_LT_VALUE_KEY));
1198 if (old_linktype != new_linktype)
1199 OBJECT_SET_DATA(linktype_om, E_CAP_OM_LT_VALUE_KEY, GINT_TO_POINTER(new_linktype));
1203 capture_prep_file_cb(GtkWidget *file_bt, GtkWidget *file_te)
1205 file_selection_browse(file_bt, file_te, "Ethereal: Specify a Capture File", FILE_SELECTION_OPEN);
1210 capture_prep_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w) {
1211 GtkWidget *if_cb, *snap_cb, *snap_sb, *promisc_cb, *filter_te,
1212 *file_te, *multi_files_on_cb, *ringbuffer_nbf_sb, *ringbuffer_nbf_cb,
1213 *linktype_om, *sync_cb, *auto_scroll_cb, *hide_info_cb,
1214 *stop_packets_cb, *stop_packets_sb,
1215 *stop_filesize_cb, *stop_filesize_sb, *stop_filesize_om,
1216 *stop_duration_cb, *stop_duration_sb, *stop_duration_om,
1217 *ring_filesize_cb, *ring_filesize_sb, *ring_filesize_om,
1218 *file_duration_cb, *file_duration_sb, *file_duration_om,
1219 *stop_files_cb, *stop_files_sb,
1220 *m_resolv_cb, *n_resolv_cb, *t_resolv_cb;
1222 GtkWidget *buffer_size_sb;
1227 const gchar *filter_text;
1229 const gchar *g_save_file;
1234 if_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_IFACE_KEY);
1235 snap_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_SNAP_CB_KEY);
1236 snap_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_SNAP_SB_KEY);
1237 linktype_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_LT_OM_KEY);
1239 buffer_size_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_BUFFER_SIZE_SB_KEY);
1241 promisc_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_PROMISC_KEY);
1242 filter_te = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILT_KEY);
1243 file_te = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILE_TE_KEY);
1244 multi_files_on_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_MULTI_FILES_ON_CB_KEY);
1245 ringbuffer_nbf_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_NBF_CB_KEY);
1246 ringbuffer_nbf_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_NBF_SB_KEY);
1247 ring_filesize_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_FILESIZE_CB_KEY);
1248 ring_filesize_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_FILESIZE_SB_KEY);
1249 ring_filesize_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_FILESIZE_OM_KEY);
1250 file_duration_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILE_DURATION_CB_KEY);
1251 file_duration_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILE_DURATION_SB_KEY);
1252 file_duration_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILE_DURATION_OM_KEY);
1253 sync_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_SYNC_KEY);
1254 auto_scroll_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_AUTO_SCROLL_KEY);
1255 hide_info_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_HIDE_INFO_KEY);
1256 stop_packets_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_PACKETS_CB_KEY);
1257 stop_packets_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_PACKETS_SB_KEY);
1258 stop_filesize_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILESIZE_CB_KEY);
1259 stop_filesize_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILESIZE_SB_KEY);
1260 stop_filesize_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILESIZE_OM_KEY);
1261 stop_duration_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_DURATION_CB_KEY);
1262 stop_duration_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_DURATION_SB_KEY);
1263 stop_duration_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_DURATION_OM_KEY);
1264 stop_files_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILES_CB_KEY);
1265 stop_files_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILES_SB_KEY);
1266 m_resolv_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_M_RESOLVE_KEY);
1267 n_resolv_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_N_RESOLVE_KEY);
1268 t_resolv_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_T_RESOLVE_KEY);
1271 g_strdup(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry)));
1272 if_text = g_strstrip(entry_text);
1273 if_name = get_if_name(if_text);
1274 if (*if_name == '\0') {
1275 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
1276 "You didn't specify an interface on which to capture packets.");
1281 g_free(cfile.iface);
1282 cfile.iface = g_strdup(if_name);
1285 capture_opts.linktype =
1286 GPOINTER_TO_INT(OBJECT_GET_DATA(linktype_om, E_CAP_OM_LT_VALUE_KEY));
1289 capture_opts.buffer_size =
1290 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(buffer_size_sb));
1293 capture_opts.has_snaplen =
1294 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(snap_cb));
1295 if (capture_opts.has_snaplen) {
1296 capture_opts.snaplen =
1297 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(snap_sb));
1298 if (capture_opts.snaplen < 1)
1299 capture_opts.snaplen = WTAP_MAX_PACKET_SIZE;
1300 else if (capture_opts.snaplen < MIN_PACKET_SIZE)
1301 capture_opts.snaplen = MIN_PACKET_SIZE;
1304 capture_opts.promisc_mode =
1305 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(promisc_cb));
1307 /* XXX - don't try to get clever and set "cfile.filter" to NULL if the
1308 filter string is empty, as an indication that we don't have a filter
1309 and thus don't have to set a filter when capturing - the version of
1310 libpcap in Red Hat Linux 6.1, and versions based on later patches
1311 in that series, don't bind the AF_PACKET socket to an interface
1312 until a filter is set, which means they aren't bound at all if
1313 no filter is set, which means no packets arrive as input on that
1314 socket, which means Ethereal never sees any packets. */
1315 filter_text = gtk_entry_get_text(GTK_ENTRY(filter_te));
1317 g_free(cfile.cfilter);
1318 g_assert(filter_text != NULL);
1319 cfile.cfilter = g_strdup(filter_text);
1321 g_save_file = gtk_entry_get_text(GTK_ENTRY(file_te));
1322 if (g_save_file && g_save_file[0]) {
1323 /* User specified a file to which the capture should be written. */
1324 save_file = g_strdup(g_save_file);
1325 /* Save the directory name for future file dialogs. */
1326 cf_name = g_strdup(g_save_file);
1327 dirname = get_dirname(cf_name); /* Overwrites cf_name */
1328 set_last_open_dir(dirname);
1331 /* User didn't specify a file; save to a temporary file. */
1335 capture_opts.has_autostop_packets =
1336 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_packets_cb));
1337 if (capture_opts.has_autostop_packets)
1338 capture_opts.autostop_packets =
1339 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_packets_sb));
1341 capture_opts.has_autostop_duration =
1342 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_duration_cb));
1343 if (capture_opts.has_autostop_duration) {
1344 capture_opts.autostop_duration =
1345 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_duration_sb));
1346 capture_opts.autostop_duration =
1347 time_unit_option_menu_get_value(stop_duration_om, capture_opts.autostop_duration);
1350 capture_opts.sync_mode =
1351 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sync_cb));
1354 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(auto_scroll_cb));
1356 capture_opts.show_info =
1357 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hide_info_cb));
1359 g_resolv_flags |= g_resolv_flags & RESOLV_CONCURRENT;
1360 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_resolv_cb)))
1361 g_resolv_flags |= RESOLV_MAC;
1362 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(n_resolv_cb)))
1363 g_resolv_flags |= RESOLV_NETWORK;
1364 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(t_resolv_cb)))
1365 g_resolv_flags |= RESOLV_TRANSPORT;
1367 capture_opts.has_ring_num_files =
1368 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb));
1370 capture_opts.ring_num_files =
1371 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ringbuffer_nbf_sb));
1372 if (capture_opts.ring_num_files > RINGBUFFER_MAX_NUM_FILES)
1373 capture_opts.ring_num_files = RINGBUFFER_MAX_NUM_FILES;
1374 #if RINGBUFFER_MIN_NUM_FILES > 0
1375 else if (capture_opts.ring_num_files < RINGBUFFER_MIN_NUM_FILES)
1376 capture_opts.ring_num_files = RINGBUFFER_MIN_NUM_FILES;
1379 capture_opts.multi_files_on =
1380 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(multi_files_on_cb));
1382 if(capture_opts.sync_mode)
1383 capture_opts.multi_files_on = FALSE;
1385 if (capture_opts.multi_files_on) {
1386 capture_opts.has_autostop_filesize =
1387 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb));
1388 if (capture_opts.has_autostop_filesize) {
1389 tmp = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ring_filesize_sb));
1390 tmp = size_unit_option_menu_convert_value(ring_filesize_om, tmp);
1392 capture_opts.autostop_filesize = tmp;
1394 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
1395 PRIMARY_TEXT_START "Multiple files: Requested filesize too large!\n\n" PRIMARY_TEXT_END
1396 "The setting \"Next file every x byte(s)\" can't be greater than %u bytes (2GB).", G_MAXINT);
1401 /* test if the settings are ok for a ringbuffer */
1402 if (save_file == NULL) {
1403 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
1404 PRIMARY_TEXT_START "Multiple files: No capture file name given!\n\n" PRIMARY_TEXT_END
1405 "You must specify a filename if you want to use multiple files.");
1407 } else if (!capture_opts.has_autostop_filesize) {
1408 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
1409 PRIMARY_TEXT_START "Multiple files: No file limit given!\n\n" PRIMARY_TEXT_END
1410 "You must specify a file size at which is switched to the next capture file\n"
1411 "if you want to use multiple files.");
1416 capture_opts.has_autostop_filesize =
1417 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_filesize_cb));
1418 if (capture_opts.has_autostop_filesize) {
1419 tmp = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_filesize_sb));
1420 tmp = size_unit_option_menu_convert_value(stop_filesize_om, tmp);
1422 capture_opts.autostop_filesize = tmp;
1424 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
1425 PRIMARY_TEXT_START "Stop Capture: Requested filesize too large!\n\n" PRIMARY_TEXT_END
1426 "The setting \"... after x byte(s)\" can't be greater than %u bytes (2GB).", G_MAXINT);
1432 capture_opts.has_file_duration =
1433 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_duration_cb));
1434 if (capture_opts.has_file_duration) {
1435 capture_opts.file_duration =
1436 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(file_duration_sb));
1437 capture_opts.file_duration =
1438 time_unit_option_menu_get_value(file_duration_om, capture_opts.file_duration);
1441 capture_opts.has_autostop_files =
1442 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_files_cb));
1443 if (capture_opts.has_autostop_files)
1444 capture_opts.autostop_files =
1445 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_files_sb));
1447 window_destroy(GTK_WIDGET(parent_w));
1449 do_capture(save_file);
1450 if (save_file != NULL)
1455 capture_prep_destroy_cb(GtkWidget *win, gpointer user_data _U_)
1459 /* Is there a file selection dialog associated with this
1460 Capture Options dialog? */
1461 fs = OBJECT_GET_DATA(win, E_FILE_SEL_DIALOG_PTR_KEY);
1464 /* Yes. Destroy it. */
1468 /* Note that we no longer have a "Capture Options" dialog box. */
1473 capture_prep_interface_changed_cb(GtkWidget *entry, gpointer argp)
1475 GtkWidget *linktype_om = argp;
1477 set_link_type_list(linktype_om, entry);
1481 * Adjust the sensitivity of various widgets as per the current setting
1485 capture_prep_adjust_sensitivity(GtkWidget *tb _U_, gpointer parent_w)
1489 *multi_files_on_cb, *ringbuffer_nbf_cb, *ringbuffer_nbf_sb, *ringbuffer_nbf_lb,
1490 *ring_filesize_cb, *ring_filesize_sb, *ring_filesize_om,
1491 *file_duration_cb, *file_duration_sb, *file_duration_om,
1492 *sync_cb, *auto_scroll_cb, *hide_info_cb,
1493 *stop_packets_cb, *stop_packets_sb, *stop_packets_lb,
1494 *stop_filesize_cb, *stop_filesize_sb, *stop_filesize_om,
1495 *stop_duration_cb, *stop_duration_sb, *stop_duration_om,
1496 *stop_files_cb, *stop_files_sb, *stop_files_lb;
1499 if_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_IFACE_KEY);
1500 snap_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_SNAP_CB_KEY);
1501 snap_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_SNAP_SB_KEY);
1502 multi_files_on_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_MULTI_FILES_ON_CB_KEY);
1503 ringbuffer_nbf_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_NBF_CB_KEY);
1504 ringbuffer_nbf_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_NBF_SB_KEY);
1505 ringbuffer_nbf_lb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_NBF_LB_KEY);
1506 ring_filesize_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_FILESIZE_CB_KEY);
1507 ring_filesize_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_FILESIZE_SB_KEY);
1508 ring_filesize_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_FILESIZE_OM_KEY);
1509 file_duration_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILE_DURATION_CB_KEY);
1510 file_duration_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILE_DURATION_SB_KEY);
1511 file_duration_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILE_DURATION_OM_KEY);
1512 sync_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_SYNC_KEY);
1513 auto_scroll_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_AUTO_SCROLL_KEY);
1514 hide_info_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_HIDE_INFO_KEY);
1515 stop_packets_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_PACKETS_CB_KEY);
1516 stop_packets_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_PACKETS_SB_KEY);
1517 stop_packets_lb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_PACKETS_LB_KEY);
1518 stop_filesize_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILESIZE_CB_KEY);
1519 stop_filesize_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILESIZE_SB_KEY);
1520 stop_filesize_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILESIZE_OM_KEY);
1521 stop_duration_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_DURATION_CB_KEY);
1522 stop_duration_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_DURATION_SB_KEY);
1523 stop_duration_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_DURATION_OM_KEY);
1524 stop_files_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILES_CB_KEY);
1525 stop_files_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILES_SB_KEY);
1526 stop_files_lb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILES_LB_KEY);
1528 /* The snapshot length spinbox is sensitive if the "Limit each packet
1529 to" checkbox is on. */
1530 gtk_widget_set_sensitive(GTK_WIDGET(snap_sb),
1531 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(snap_cb)));
1534 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sync_cb))) {
1535 /* "Update list of packets in real time" captures enabled; we don't
1536 support ring buffer mode for those captures, so turn ring buffer
1537 mode off if it's on, and make its toggle button, and the spin
1538 button for the number of ring buffer files (and the spin button's
1539 label), insensitive. */
1540 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(multi_files_on_cb), FALSE);
1541 gtk_widget_set_sensitive(GTK_WIDGET(multi_files_on_cb), FALSE);
1543 /* Auto-scroll mode is meaningful only in "Update list of packets
1544 in real time" captures, so make its toggle button sensitive. */
1545 gtk_widget_set_sensitive(GTK_WIDGET(auto_scroll_cb), TRUE);
1547 gtk_widget_set_sensitive(GTK_WIDGET(hide_info_cb), TRUE);
1549 /* "Update list of packets in real time" captures disabled; that
1550 means ring buffer mode is OK, so make its toggle button
1552 gtk_widget_set_sensitive(GTK_WIDGET(multi_files_on_cb), TRUE);
1554 /* Auto-scroll mode is meaningful only in "Update list of packets
1555 in real time" captures, so make its toggle button insensitive. */
1556 gtk_widget_set_sensitive(GTK_WIDGET(auto_scroll_cb), FALSE);
1558 gtk_widget_set_sensitive(GTK_WIDGET(hide_info_cb), FALSE);
1561 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(multi_files_on_cb))) {
1562 /* Ring buffer mode enabled. */
1563 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ring_filesize_cb), TRUE);
1565 gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_cb), TRUE);
1566 gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_sb),
1567 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb)));
1568 gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_lb),
1569 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb)));
1571 /* The ring filesize spinbox is sensitive if the "Next capture file
1572 after N kilobytes" checkbox is on. */
1573 gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_cb), TRUE);
1574 gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_sb),
1575 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb)));
1576 gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_om),
1577 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb)));
1579 /* The ring duration spinbox is sensitive if the "Next capture file
1580 after N seconds" checkbox is on. */
1581 gtk_widget_set_sensitive(GTK_WIDGET(file_duration_cb), TRUE);
1582 gtk_widget_set_sensitive(GTK_WIDGET(file_duration_sb),
1583 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_duration_cb)));
1584 gtk_widget_set_sensitive(GTK_WIDGET(file_duration_om),
1585 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_duration_cb)));
1587 gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_cb), FALSE);
1588 gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_sb), FALSE);
1589 gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_om), FALSE);
1591 gtk_widget_set_sensitive(GTK_WIDGET(stop_files_cb), TRUE);
1592 gtk_widget_set_sensitive(GTK_WIDGET(stop_files_sb),
1593 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_files_cb)));
1594 gtk_widget_set_sensitive(GTK_WIDGET(stop_files_lb),
1595 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_files_cb)));
1597 /* Ring buffer mode disabled. */
1598 gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_cb), FALSE);
1599 gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_sb), FALSE);
1600 gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_lb), FALSE);
1602 gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_cb), FALSE);
1603 gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_sb),FALSE);
1604 gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_om),FALSE);
1606 gtk_widget_set_sensitive(GTK_WIDGET(file_duration_cb), FALSE);
1607 gtk_widget_set_sensitive(GTK_WIDGET(file_duration_sb),FALSE);
1608 gtk_widget_set_sensitive(GTK_WIDGET(file_duration_om),FALSE);
1610 /* The maximum file size spinbox is sensitive if the "Stop capture
1611 after N kilobytes" checkbox is on. */
1612 gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_cb), TRUE);
1613 gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_sb),
1614 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_filesize_cb)));
1615 gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_om),
1616 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_filesize_cb)));
1618 gtk_widget_set_sensitive(GTK_WIDGET(stop_files_cb), FALSE);
1619 gtk_widget_set_sensitive(GTK_WIDGET(stop_files_sb), FALSE);
1620 gtk_widget_set_sensitive(GTK_WIDGET(stop_files_lb), FALSE);
1623 /* The maximum packet count spinbox is sensitive if the "Stop capture
1624 after N packets" checkbox is on. */
1625 gtk_widget_set_sensitive(GTK_WIDGET(stop_packets_sb),
1626 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_packets_cb)));
1627 gtk_widget_set_sensitive(GTK_WIDGET(stop_packets_lb),
1628 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_packets_cb)));
1630 /* The capture duration spinbox is sensitive if the "Stop capture
1631 after N seconds" checkbox is on. */
1632 gtk_widget_set_sensitive(GTK_WIDGET(stop_duration_sb),
1633 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_duration_cb)));
1634 gtk_widget_set_sensitive(GTK_WIDGET(stop_duration_om),
1635 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_duration_cb)));
1638 #endif /* HAVE_LIBPCAP */