2 * Routines for packet capture windows
4 * $Id: capture_dlg.c,v 1.134 2004/06/20 13:39:44 ulfl Exp $
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/resolv.h>
41 #include "capture_dlg.h"
42 #include "filter_prefs.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_SNAP_CB_KEY "cap_snap_cb"
62 #define E_CAP_LT_OM_KEY "cap_lt_om"
63 #define E_CAP_LT_OM_LABEL_KEY "cap_lt_om_label"
65 #define E_CAP_BUFFER_SIZE_SB_KEY "cap_buffer_size_sb"
67 #define E_CAP_SNAP_SB_KEY "cap_snap_sb"
68 #define E_CAP_PROMISC_KEY "cap_promisc"
69 #define E_CAP_FILT_KEY "cap_filter_te"
70 #define E_CAP_FILE_TE_KEY "cap_file_te"
71 #define E_CAP_MULTI_FILES_ON_CB_KEY "cap_multi_files_on_cb"
72 #define E_CAP_RING_FILESIZE_CB_KEY "cap_ring_filesize_cb"
73 #define E_CAP_RING_FILESIZE_SB_KEY "cap_ring_filesize_sb"
74 #define E_CAP_RING_FILESIZE_OM_KEY "cap_ring_filesize_om"
75 #define E_CAP_FILE_DURATION_CB_KEY "cap_file_duration_cb"
76 #define E_CAP_FILE_DURATION_SB_KEY "cap_file_duration_sb"
77 #define E_CAP_FILE_DURATION_OM_KEY "cap_file_duration_om"
78 #define E_CAP_RING_NBF_CB_KEY "cap_ring_nbf_cb"
79 #define E_CAP_RING_NBF_SB_KEY "cap_ring_nbf_sb"
80 #define E_CAP_RING_NBF_LB_KEY "cap_ring_nbf_lb"
81 #define E_CAP_STOP_FILES_CB_KEY "cap_stop_files_cb"
82 #define E_CAP_STOP_FILES_SB_KEY "cap_stop_files_sb"
83 #define E_CAP_STOP_FILES_LB_KEY "cap_stop_files_lb"
84 #define E_CAP_SYNC_KEY "cap_sync"
85 #define E_CAP_AUTO_SCROLL_KEY "cap_auto_scroll"
86 #define E_CAP_HIDE_INFO_KEY "cap_hide_info"
87 #define E_CAP_STOP_PACKETS_CB_KEY "cap_stop_packets_cb"
88 #define E_CAP_STOP_PACKETS_SB_KEY "cap_stop_packets_sb"
89 #define E_CAP_STOP_PACKETS_LB_KEY "cap_stop_packets_lb"
90 #define E_CAP_STOP_FILESIZE_CB_KEY "cap_stop_filesize_cb"
91 #define E_CAP_STOP_FILESIZE_SB_KEY "cap_stop_filesize_sb"
92 #define E_CAP_STOP_FILESIZE_OM_KEY "cap_stop_filesize_om"
93 #define E_CAP_STOP_DURATION_CB_KEY "cap_stop_duration_cb"
94 #define E_CAP_STOP_DURATION_SB_KEY "cap_stop_duration_sb"
95 #define E_CAP_STOP_DURATION_OM_KEY "cap_stop_duration_om"
96 #define E_CAP_M_RESOLVE_KEY "cap_m_resolve"
97 #define E_CAP_N_RESOLVE_KEY "cap_n_resolve"
98 #define E_CAP_T_RESOLVE_KEY "cap_t_resolve"
100 #define E_CAP_OM_LT_VALUE_KEY "cap_om_lt_value"
103 capture_prep_file_cb(GtkWidget *file_bt, GtkWidget *file_te);
106 select_link_type_cb(GtkWidget *w, gpointer data);
109 capture_prep_adjust_sensitivity(GtkWidget *tb, gpointer parent_w);
112 capture_prep_ok_cb(GtkWidget *ok_bt, gpointer parent_w);
115 capture_prep_destroy_cb(GtkWidget *win, gpointer user_data);
118 capture_prep_interface_changed_cb(GtkWidget *entry, gpointer parent_w);
121 capture_stop_cb(GtkWidget *w _U_, gpointer d _U_)
127 * Given text that contains an interface name possibly prefixed by an
128 * interface description, extract the interface name.
131 get_if_name(char *if_text)
137 * We cannot assume that the interface name doesn't contain a space;
138 * some names on Windows OT do.
140 * We also can't assume it begins with "\Device\", either, as, on
141 * Windows OT, WinPcap doesn't put "\Device\" in front of the name.
143 * As I remember, we can't assume that the interface description
144 * doesn't contain a colon, either; I think some do.
146 * We can probably assume that the interface *name* doesn't contain
147 * a colon, however; if any interface name does contain a colon on
148 * Windows, it'll be time to just get rid of the damn interface
149 * descriptions in the drop-down list, have just the names in the
150 * drop-down list, and have a "Browse..." button to browse for interfaces,
151 * with names, descriptions, IP addresses, blah blah blah available when
154 * So we search backwards for a colon. If we don't find it, just
155 * return the entire string; otherwise, skip the colon and any blanks
156 * after it, and return that string.
158 if_name = if_text + strlen(if_text);
160 if (if_name == if_text) {
161 /* We're at the beginning of the string; return it. */
165 if (*if_name == ':') {
167 * We've found a colon.
168 * Unfortunately, a colon is used in the string "rpcap://",
169 * which is used in case of a remote capture.
170 * So we'll check to make sure the colon isn't followed by "//";
171 * it'll be followed by a blank if it separates the description
172 * and the interface name. (We don't wire in "rpcap", in case we
173 * support other protocols in the same syntax.)
175 if (strncmp(if_name, "://", 3) != 0) {
177 * OK, we've found a colon not followed by "//". Skip blanks
181 while (*if_name == ' ')
186 /* Keep looking for a colon not followed by "//". */
190 * There's a space between the interface description and name, and
191 * the interface name shouldn't have a space in it (it doesn't, on
192 * UNIX systems); look backwards in the string for a space.
194 * (An interface name might, however, contain a colon in it, which
195 * is why we don't use the colon search on UNIX.)
197 if_name = strrchr(if_text, ' ');
198 if (if_name == NULL) {
208 * Keep a static pointer to the current "Capture Options" window, if
209 * any, so that if somebody tries to do "Capture:Start" while there's
210 * already a "Capture Options" window up, we just pop up the existing
211 * one, rather than creating a new one.
213 static GtkWidget *cap_open_w;
216 set_link_type_list(GtkWidget *linktype_om, GtkWidget *entry)
226 char err_buf[PCAP_ERRBUF_SIZE];
227 GtkWidget *lt_menu, *lt_menu_item;
229 data_link_info_t *data_link_info;
230 gchar *linktype_menu_label;
231 guint num_supported_link_types;
232 GtkWidget *linktype_lb = OBJECT_GET_DATA(linktype_om, E_CAP_LT_OM_LABEL_KEY);
234 lt_menu = gtk_menu_new();
235 entry_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
236 if_text = g_strstrip(entry_text);
237 if_name = get_if_name(if_text);
240 * If the interface name is in the list of known interfaces, get
241 * its list of link-layer types and set the option menu to display it.
243 * If it's not, don't bother - the user might be in the middle of
244 * editing the list, or it might be a remote device in which case
245 * getting the list could take an arbitrarily-long period of time.
246 * The list currently won't contain any remote devices (as
247 * "pcap_findalldevs()" doesn't know about remote devices, and neither
248 * does the code we use if "pcap_findalldevs()" isn't available), but
249 * should contain all the local devices on which you can capture.
252 if (*if_name != '\0') {
254 * Try to get the list of known interfaces.
256 if_list = get_interface_list(&err, err_buf);
257 if (if_list != NULL) {
259 * We have the list - check it.
261 for (if_entry = if_list; if_entry != NULL;
262 if_entry = g_list_next(if_entry)) {
263 if_info = if_entry->data;
264 if (strcmp(if_info->name, if_name) == 0) {
267 * Get the list of link-layer types for it.
269 lt_list = get_pcap_linktype_list(if_name, err_buf);
272 free_interface_list(if_list);
276 num_supported_link_types = 0;
277 for (lt_entry = lt_list; lt_entry != NULL; lt_entry = g_list_next(lt_entry)) {
278 data_link_info = lt_entry->data;
279 if (data_link_info->description != NULL) {
280 lt_menu_item = gtk_menu_item_new_with_label(data_link_info->description);
281 OBJECT_SET_DATA(lt_menu_item, E_CAP_LT_OM_KEY, linktype_om);
282 SIGNAL_CONNECT(lt_menu_item, "activate", select_link_type_cb,
283 GINT_TO_POINTER(data_link_info->dlt));
284 num_supported_link_types++;
286 /* Not supported - tell them about it but don't let them select it. */
287 linktype_menu_label = g_strdup_printf("%s (not supported)",
288 data_link_info->name);
289 lt_menu_item = gtk_menu_item_new_with_label(linktype_menu_label);
290 g_free(linktype_menu_label);
291 gtk_widget_set_sensitive(lt_menu_item, FALSE);
293 gtk_menu_append(GTK_MENU(lt_menu), lt_menu_item);
296 free_pcap_linktype_list(lt_list);
297 gtk_option_menu_set_menu(GTK_OPTION_MENU(linktype_om), lt_menu);
298 gtk_widget_set_sensitive(linktype_lb, num_supported_link_types >= 2);
299 gtk_widget_set_sensitive(linktype_om, num_supported_link_types >= 2);
303 #define TIME_UNIT_SECOND 0
304 #define TIME_UNIT_MINUTE 1
305 #define TIME_UNIT_HOUR 2
306 #define TIME_UNIT_DAY 3
307 #define MAX_TIME_UNITS 4
308 static char *time_unit_name[MAX_TIME_UNITS] = {
315 GtkWidget *time_unit_option_menu_new(void) {
316 GtkWidget *unit_om, *menu, *menu_item;
319 unit_om=gtk_option_menu_new();
321 for(i=0;i<MAX_TIME_UNITS;i++){
322 menu_item=gtk_menu_item_new_with_label(time_unit_name[i]);
323 OBJECT_SET_DATA(menu_item, "time_unit", GINT_TO_POINTER(i));
324 gtk_menu_append(GTK_MENU(menu), menu_item);
326 gtk_menu_set_active(GTK_MENU(menu), TIME_UNIT_MINUTE);
328 gtk_option_menu_set_menu(GTK_OPTION_MENU(unit_om), menu);
333 guint32 time_unit_option_menu_get_value(
337 GtkWidget *menu, *menu_item;
340 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(unit_om));
341 menu_item = gtk_menu_get_active(GTK_MENU(menu));
342 unit = GPOINTER_TO_INT(OBJECT_GET_DATA(menu_item, "time_unit"));
346 case(TIME_UNIT_SECOND):
349 case(TIME_UNIT_MINUTE):
352 case(TIME_UNIT_HOUR):
353 return value * 60 * 60;
356 return value * 60 * 60 * 24;
359 g_assert_not_reached();
365 #define SIZE_UNIT_BYTES 0
366 #define SIZE_UNIT_KILOBYTES 1
367 #define SIZE_UNIT_MEGABYTES 2
368 #define SIZE_UNIT_GIGABYTES 3
369 #define MAX_SIZE_UNITS 4
370 static char *size_unit_name[MAX_SIZE_UNITS] = {
377 GtkWidget *size_unit_option_menu_new(void) {
378 GtkWidget *unit_om, *menu, *menu_item;
381 unit_om=gtk_option_menu_new();
383 for(i=0;i<MAX_SIZE_UNITS;i++){
384 menu_item=gtk_menu_item_new_with_label(size_unit_name[i]);
385 OBJECT_SET_DATA(menu_item, "size_unit", GINT_TO_POINTER(i));
386 gtk_menu_append(GTK_MENU(menu), menu_item);
388 gtk_menu_set_active(GTK_MENU(menu), SIZE_UNIT_MEGABYTES);
390 gtk_option_menu_set_menu(GTK_OPTION_MENU(unit_om), menu);
395 guint32 size_unit_option_menu_get_value(
399 GtkWidget *menu, *menu_item;
402 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(unit_om));
403 menu_item = gtk_menu_get_active(GTK_MENU(menu));
404 unit = GPOINTER_TO_INT(OBJECT_GET_DATA(menu_item, "size_unit"));
408 case(SIZE_UNIT_BYTES):
411 case(SIZE_UNIT_KILOBYTES):
412 if(value > G_MAXINT / 1024) {
418 case(SIZE_UNIT_MEGABYTES):
419 if(value > G_MAXINT / (1024 * 1024)) {
422 return value * 1024 * 1024;
425 case(SIZE_UNIT_GIGABYTES):
426 if(value > G_MAXINT / (1024 * 1024 * 1024)) {
429 return value * 1024 * 1024 * 1024;
433 g_assert_not_reached();
443 *main_hb, *left_vb, *right_vb,
445 *capture_fr, *capture_vb,
446 *if_hb, *if_cb, *if_lb,
447 *linktype_hb, *linktype_lb, *linktype_om,
448 *snap_hb, *snap_cb, *snap_sb, *snap_lb,
450 *filter_hb, *filter_bt, *filter_te,
453 *file_hb, *file_bt, *file_lb, *file_te,
454 *multi_tb, *multi_files_on_cb,
455 *ring_filesize_cb, *ring_filesize_sb, *ring_filesize_om,
456 *file_duration_cb, *file_duration_sb, *file_duration_om,
457 *ringbuffer_nbf_cb, *ringbuffer_nbf_sb, *ringbuffer_nbf_lb,
458 *stop_files_cb, *stop_files_sb, *stop_files_lb,
460 *limit_fr, *limit_vb, *limit_tb,
461 *stop_packets_cb, *stop_packets_sb, *stop_packets_lb,
462 *stop_filesize_cb, *stop_filesize_sb, *stop_filesize_om,
463 *stop_duration_cb, *stop_duration_sb, *stop_duration_om,
465 *display_fr, *display_vb,
466 *sync_cb, *auto_scroll_cb, *hide_info_cb,
468 *resolv_fr, *resolv_vb,
469 *m_resolv_cb, *n_resolv_cb, *t_resolv_cb,
470 *bbox, *ok_bt, *cancel_bt,
472 #if GTK_MAJOR_VERSION < 2
473 GtkAccelGroup *accel_group;
475 GtkTooltips *tooltips;
476 GtkAdjustment *snap_adj, *ringbuffer_nbf_adj,
477 *stop_packets_adj, *stop_filesize_adj, *stop_duration_adj, *stop_files_adj, *ring_filesize_adj, *file_duration_adj;
478 GList *if_list, *combo_list;
481 char err_str[PCAP_ERRBUF_SIZE];
482 gchar *cant_get_if_list_errstr;
484 GtkAdjustment *buffer_size_adj;
485 GtkWidget *buffer_size_lb, *buffer_size_sb;
488 if (cap_open_w != NULL) {
489 /* There's already a "Capture Options" dialog box; reactivate it. */
490 reactivate_window(cap_open_w);
495 /* Is WPcap loaded? */
497 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
498 "Unable to load WinPcap (wpcap.dll); Ethereal will not be able\n"
499 "to capture packets.\n\n"
500 "In order to capture packets, WinPcap must be installed; see\n"
502 " http://winpcap.polito.it/\n"
506 " http://winpcap.mirror.ethereal.com/\n"
510 " http://www.mirrors.wiretapped.net/security/packet-capture/winpcap/\n"
512 "for a downloadable version of WinPcap and for instructions\n"
513 "on how to install WinPcap.");
518 if_list = get_interface_list(&err, err_str);
519 if (if_list == NULL && err == CANT_GET_INTERFACE_LIST) {
520 cant_get_if_list_errstr = cant_get_if_list_error_message(err_str);
521 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s",
522 cant_get_if_list_errstr);
523 g_free(cant_get_if_list_errstr);
526 cap_open_w = dlg_window_new("Ethereal: Capture Options");
528 tooltips = gtk_tooltips_new();
530 #if GTK_MAJOR_VERSION < 2
531 /* Accelerator group for the accelerators (or, as they're called in
532 Windows and, I think, in Motif, "mnemonics"; Alt+<key> is a mnemonic,
533 Ctrl+<key> is an accelerator). */
534 accel_group = gtk_accel_group_new();
535 gtk_window_add_accel_group(GTK_WINDOW(cap_open_w), accel_group);
538 main_vb = gtk_vbox_new(FALSE, 0);
539 gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
540 gtk_container_add(GTK_CONTAINER(cap_open_w), main_vb);
542 /* Capture-related options frame */
543 capture_fr = gtk_frame_new("Capture");
544 gtk_container_add(GTK_CONTAINER(main_vb), capture_fr);
546 capture_vb = gtk_vbox_new(FALSE, 3);
547 gtk_container_border_width(GTK_CONTAINER(capture_vb), 5);
548 gtk_container_add(GTK_CONTAINER(capture_fr), capture_vb);
551 if_hb = gtk_hbox_new(FALSE, 3);
552 gtk_container_add(GTK_CONTAINER(capture_vb), if_hb);
554 if_lb = gtk_label_new("Interface:");
555 gtk_box_pack_start(GTK_BOX(if_hb), if_lb, FALSE, FALSE, 6);
557 if_cb = gtk_combo_new();
558 combo_list = build_capture_combo_list(if_list, TRUE);
559 if (combo_list != NULL)
560 gtk_combo_set_popdown_strings(GTK_COMBO(if_cb), combo_list);
561 if (cfile.iface == NULL && prefs.capture_device != NULL) {
562 /* No interface was specified on the command line or in a previous
563 capture, but there is one specified in the preferences file;
564 make the one from the preferences file the default */
565 cfile.iface = g_strdup(prefs.capture_device);
567 if (cfile.iface != NULL)
568 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry), cfile.iface);
569 else if (combo_list != NULL) {
570 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry),
571 (char *)combo_list->data);
573 free_capture_combo_list(combo_list);
574 free_interface_list(if_list);
575 gtk_tooltips_set_tip(tooltips, GTK_COMBO(if_cb)->entry,
576 "Choose which interface (network card) will be used to capture packets from. "
577 "Be sure to select the correct one, as it's a common mistake to select the wrong interface.", NULL);
578 gtk_box_pack_start(GTK_BOX(if_hb), if_cb, TRUE, TRUE, 6);
581 linktype_hb = gtk_hbox_new(FALSE, 3);
582 gtk_box_pack_start(GTK_BOX(capture_vb), linktype_hb, FALSE, FALSE, 0);
584 linktype_lb = gtk_label_new("Link-layer header type:");
585 gtk_box_pack_start(GTK_BOX(linktype_hb), linktype_lb, FALSE, FALSE, 6);
587 linktype_om = gtk_option_menu_new();
588 OBJECT_SET_DATA(linktype_om, E_CAP_LT_OM_LABEL_KEY, linktype_lb);
589 /* Default to "use the default" */
590 OBJECT_SET_DATA(linktype_om, E_CAP_OM_LT_VALUE_KEY, GINT_TO_POINTER(-1));
591 set_link_type_list(linktype_om, GTK_COMBO(if_cb)->entry);
593 * XXX - in some cases, this is "multiple link-layer header types", e.g.
594 * some 802.11 interfaces on FreeBSD 5.2 and later, where you can request
595 * fake Ethernet, 802.11, or 802.11-plus-radio-information headers.
597 * In other cases, it's "multiple link-layer types", e.g., with recent
598 * versions of libpcap, a DAG card on an "HDLC" WAN, where you can
599 * request Cisco HDLC or PPP depending on what type of traffic is going
600 * over the WAN, or an Ethernet interface, where you can request Ethernet
601 * or DOCSIS, the latter being for some Cisco cable modem equipment that
602 * can be configured to send raw DOCSIS frames over an Ethernet inside
603 * Ethernet low-level framing, for traffic capture purposes.
605 * We leave it as "multiple link-layer types" for now.
607 gtk_tooltips_set_tip(tooltips, linktype_om,
608 "The selected interface supports multiple link-layer types; select the desired one.", NULL);
609 gtk_box_pack_start (GTK_BOX(linktype_hb), linktype_om, FALSE, FALSE, 0);
610 SIGNAL_CONNECT(GTK_ENTRY(GTK_COMBO(if_cb)->entry), "changed",
611 capture_prep_interface_changed_cb, linktype_om);
614 buffer_size_lb = gtk_label_new("Buffer size:");
615 gtk_box_pack_start (GTK_BOX(linktype_hb), buffer_size_lb, FALSE, FALSE, 0);
617 buffer_size_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat) capture_opts.buffer_size,
618 1, 65535, 1.0, 10.0, 0.0);
619 buffer_size_sb = gtk_spin_button_new (buffer_size_adj, 0, 0);
620 gtk_spin_button_set_value(GTK_SPIN_BUTTON (buffer_size_sb), (gfloat) capture_opts.buffer_size);
621 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (buffer_size_sb), TRUE);
622 WIDGET_SET_SIZE(buffer_size_sb, 80, -1);
623 gtk_tooltips_set_tip(tooltips, buffer_size_sb,
624 "The memory buffer size used while capturing. If you notice packet drops, you can try to increase this size.", NULL);
625 gtk_box_pack_start (GTK_BOX(linktype_hb), buffer_size_sb, FALSE, FALSE, 0);
627 buffer_size_lb = gtk_label_new("megabyte(s)");
628 gtk_box_pack_start (GTK_BOX(linktype_hb), buffer_size_lb, FALSE, FALSE, 0);
631 /* Promiscuous mode row */
632 promisc_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC(
633 "Capture packets in _promiscuous mode", accel_group);
634 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(promisc_cb),
635 capture_opts.promisc_mode);
636 gtk_tooltips_set_tip(tooltips, promisc_cb,
637 "Usually a network card will only capture the traffic sent to its own network address. "
638 "If you want to capture all traffic that the network card can \"see\", mark this option. "
639 "See the FAQ for some more details of capturing packets from a switched network.", NULL);
640 gtk_container_add(GTK_CONTAINER(capture_vb), promisc_cb);
642 /* Capture length row */
643 snap_hb = gtk_hbox_new(FALSE, 3);
644 gtk_container_add(GTK_CONTAINER(capture_vb), snap_hb);
646 snap_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC("_Limit each packet to", accel_group);
647 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(snap_cb),
648 capture_opts.has_snaplen);
649 SIGNAL_CONNECT(snap_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w);
650 gtk_tooltips_set_tip(tooltips, snap_cb,
651 "Limit the maximum number of bytes to be captured from each packet. This size includes the "
652 "link-layer header and all subsequent headers. ", NULL);
653 gtk_box_pack_start(GTK_BOX(snap_hb), snap_cb, FALSE, FALSE, 0);
655 snap_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat) capture_opts.snaplen,
656 MIN_PACKET_SIZE, WTAP_MAX_PACKET_SIZE, 1.0, 10.0, 0.0);
657 snap_sb = gtk_spin_button_new (snap_adj, 0, 0);
658 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (snap_sb), TRUE);
659 WIDGET_SET_SIZE(snap_sb, 80, -1);
660 gtk_box_pack_start (GTK_BOX(snap_hb), snap_sb, FALSE, FALSE, 0);
662 snap_lb = gtk_label_new("bytes");
663 gtk_misc_set_alignment(GTK_MISC(snap_lb), 0, 0.5);
664 gtk_box_pack_start(GTK_BOX(snap_hb), snap_lb, FALSE, FALSE, 0);
667 filter_hb = gtk_hbox_new(FALSE, 3);
668 gtk_box_pack_start(GTK_BOX(capture_vb), filter_hb, FALSE, FALSE, 0);
670 filter_bt = BUTTON_NEW_FROM_STOCK(ETHEREAL_STOCK_CAPTURE_FILTER_ENTRY);
671 SIGNAL_CONNECT(filter_bt, "clicked", capture_filter_construct_cb, NULL);
672 SIGNAL_CONNECT(filter_bt, "destroy", filter_button_destroy_cb, NULL);
673 gtk_tooltips_set_tip(tooltips, filter_bt,
674 "Select a capture filter to reduce the amount of packets to be captured. "
675 "See \"Capture Filters\" in the online help for further information how to use it.",
677 gtk_box_pack_start(GTK_BOX(filter_hb), filter_bt, FALSE, FALSE, 3);
679 filter_te = gtk_entry_new();
680 if (cfile.cfilter) gtk_entry_set_text(GTK_ENTRY(filter_te), cfile.cfilter);
681 OBJECT_SET_DATA(filter_bt, E_FILT_TE_PTR_KEY, filter_te);
682 gtk_tooltips_set_tip(tooltips, filter_te,
683 "Enter a capture filter to reduce the amount of packets to be captured. "
684 "See \"Capture Filters\" in the online help for further information how to use it.",
686 gtk_box_pack_start(GTK_BOX(filter_hb), filter_te, TRUE, TRUE, 3);
688 main_hb = gtk_hbox_new(FALSE, 5);
689 gtk_container_border_width(GTK_CONTAINER(main_hb), 0);
690 gtk_container_add(GTK_CONTAINER(main_vb), main_hb);
692 left_vb = gtk_vbox_new(FALSE, 0);
693 gtk_container_border_width(GTK_CONTAINER(left_vb), 0);
694 gtk_box_pack_start(GTK_BOX(main_hb), left_vb, TRUE, TRUE, 0);
696 right_vb = gtk_vbox_new(FALSE, 0);
697 gtk_container_border_width(GTK_CONTAINER(right_vb), 0);
698 gtk_box_pack_start(GTK_BOX(main_hb), right_vb, FALSE, FALSE, 0);
701 /* Capture file-related options frame */
702 file_fr = gtk_frame_new("Capture File(s)");
703 gtk_container_add(GTK_CONTAINER(left_vb), file_fr);
705 file_vb = gtk_vbox_new(FALSE, 3);
706 gtk_container_border_width(GTK_CONTAINER(file_vb), 5);
707 gtk_container_add(GTK_CONTAINER(file_fr), file_vb);
710 file_hb = gtk_hbox_new(FALSE, 3);
711 gtk_box_pack_start(GTK_BOX(file_vb), file_hb, FALSE, FALSE, 0);
713 file_lb = gtk_label_new("File:");
714 gtk_box_pack_start(GTK_BOX(file_hb), file_lb, FALSE, FALSE, 3);
716 file_te = gtk_entry_new();
717 gtk_tooltips_set_tip(tooltips, file_te,
718 "Enter the file name to which captured data will be written. "
719 "If you don't enter something here, a temporary file will be used.",
721 gtk_box_pack_start(GTK_BOX(file_hb), file_te, TRUE, TRUE, 3);
723 file_bt = BUTTON_NEW_FROM_STOCK(ETHEREAL_STOCK_BROWSE);
724 gtk_tooltips_set_tip(tooltips, file_bt,
725 "Select a file to which captured data will be written, "
726 "instead of entering the file name directly. ",
728 gtk_box_pack_start(GTK_BOX(file_hb), file_bt, FALSE, FALSE, 3);
730 SIGNAL_CONNECT(file_bt, "clicked", capture_prep_file_cb, file_te);
732 /* multiple files table */
733 multi_tb = gtk_table_new(5, 3, FALSE);
734 gtk_table_set_row_spacings(GTK_TABLE(multi_tb), 1);
735 gtk_table_set_col_spacings(GTK_TABLE(multi_tb), 3);
736 gtk_box_pack_start(GTK_BOX(file_vb), multi_tb, FALSE, FALSE, 0);
739 /* multiple files row */
740 multi_files_on_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC("Use _multiple files", accel_group);
741 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(multi_files_on_cb),
742 capture_opts.multi_files_on);
743 SIGNAL_CONNECT(multi_files_on_cb, "toggled", capture_prep_adjust_sensitivity,
745 gtk_tooltips_set_tip(tooltips, multi_files_on_cb,
746 "Instead of using a single capture file, multiple files will be created. "
747 "The generated file names will contain an incrementing number and the start time of the capture.", NULL);
748 gtk_table_attach_defaults(GTK_TABLE(multi_tb), multi_files_on_cb, 0, 1, row, row+1);
751 /* Ring buffer filesize row */
752 ring_filesize_cb = gtk_check_button_new_with_label("Next file every");
753 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(ring_filesize_cb),
754 capture_opts.has_autostop_filesize);
755 SIGNAL_CONNECT(ring_filesize_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w);
756 gtk_tooltips_set_tip(tooltips, ring_filesize_cb,
757 "If the selected file size is exceeded, capturing switches to the next file.",
759 gtk_table_attach_defaults(GTK_TABLE(multi_tb), ring_filesize_cb, 0, 1, row, row+1);
761 ring_filesize_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat)capture_opts.autostop_filesize,
762 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
763 ring_filesize_sb = gtk_spin_button_new (ring_filesize_adj, 0, 0);
764 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (ring_filesize_sb), TRUE);
765 WIDGET_SET_SIZE(ring_filesize_sb, 80, -1);
766 gtk_table_attach_defaults(GTK_TABLE(multi_tb), ring_filesize_sb, 1, 2, row, row+1);
768 ring_filesize_om = size_unit_option_menu_new();
769 gtk_table_attach_defaults(GTK_TABLE(multi_tb), ring_filesize_om, 2, 3, row, row+1);
772 /* Ring buffer duration row */
773 file_duration_cb = gtk_check_button_new_with_label("Next file every");
774 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(file_duration_cb),
775 capture_opts.has_file_duration);
776 SIGNAL_CONNECT(file_duration_cb, "toggled",
777 capture_prep_adjust_sensitivity, cap_open_w);
778 gtk_tooltips_set_tip(tooltips, file_duration_cb,
779 "If the selected duration is exceeded, capturing switches to the next file.",
781 gtk_table_attach_defaults(GTK_TABLE(multi_tb), file_duration_cb, 0, 1, row, row+1);
783 file_duration_adj = (GtkAdjustment *)gtk_adjustment_new((gfloat)capture_opts.file_duration,
784 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
785 file_duration_sb = gtk_spin_button_new (file_duration_adj, 0, 0);
786 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (file_duration_sb), TRUE);
787 WIDGET_SET_SIZE(file_duration_sb, 80, -1);
788 gtk_table_attach_defaults(GTK_TABLE(multi_tb), file_duration_sb, 1, 2, row, row+1);
790 file_duration_om = time_unit_option_menu_new();
791 gtk_table_attach_defaults(GTK_TABLE(multi_tb), file_duration_om, 2, 3, row, row+1);
794 /* Ring buffer files row */
795 ringbuffer_nbf_cb = gtk_check_button_new_with_label("Ring buffer with");
796 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb),
797 capture_opts.has_ring_num_files);
798 SIGNAL_CONNECT(ringbuffer_nbf_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w);
799 gtk_tooltips_set_tip(tooltips, ringbuffer_nbf_cb,
800 "After capturing has switched to the next file and the given number of files has exceeded, "
801 "the oldest file will be removed.",
803 gtk_table_attach_defaults(GTK_TABLE(multi_tb), ringbuffer_nbf_cb, 0, 1, row, row+1);
805 ringbuffer_nbf_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat) capture_opts.ring_num_files,
806 2/*RINGBUFFER_MIN_NUM_FILES*/, RINGBUFFER_MAX_NUM_FILES, 1.0, 10.0, 0.0);
807 ringbuffer_nbf_sb = gtk_spin_button_new (ringbuffer_nbf_adj, 0, 0);
808 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (ringbuffer_nbf_sb), TRUE);
809 WIDGET_SET_SIZE(ringbuffer_nbf_sb, 80, -1);
810 SIGNAL_CONNECT(ringbuffer_nbf_sb, "changed", capture_prep_adjust_sensitivity, cap_open_w);
811 gtk_table_attach_defaults(GTK_TABLE(multi_tb), ringbuffer_nbf_sb, 1, 2, row, row+1);
813 ringbuffer_nbf_lb = gtk_label_new("files");
814 gtk_misc_set_alignment(GTK_MISC(ringbuffer_nbf_lb), 0, 0.5);
815 gtk_table_attach_defaults(GTK_TABLE(multi_tb), ringbuffer_nbf_lb, 2, 3, row, row+1);
819 stop_files_cb = gtk_check_button_new_with_label("Stop capture after");
820 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(stop_files_cb),
821 capture_opts.has_autostop_files);
822 SIGNAL_CONNECT(stop_files_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w);
823 gtk_tooltips_set_tip(tooltips, stop_files_cb,
824 "Stop capturing after the given number of \"file switches\" have been done.", NULL);
825 gtk_table_attach_defaults(GTK_TABLE(multi_tb), stop_files_cb, 0, 1, row, row+1);
827 stop_files_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat)capture_opts.autostop_files,
828 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
829 stop_files_sb = gtk_spin_button_new (stop_files_adj, 0, 0);
830 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_files_sb), TRUE);
831 WIDGET_SET_SIZE(stop_files_sb, 80, -1);
832 gtk_table_attach_defaults(GTK_TABLE(multi_tb), stop_files_sb, 1, 2, row, row+1);
834 stop_files_lb = gtk_label_new("file(s)");
835 gtk_misc_set_alignment(GTK_MISC(stop_files_lb), 0, 0.5);
836 gtk_table_attach_defaults(GTK_TABLE(multi_tb), stop_files_lb, 2, 3, row, row+1);
839 /* Capture limits frame */
840 limit_fr = gtk_frame_new("Stop Capture ...");
841 gtk_container_add(GTK_CONTAINER(left_vb), limit_fr);
843 limit_vb = gtk_vbox_new(FALSE, 3);
844 gtk_container_border_width(GTK_CONTAINER(limit_vb), 5);
845 gtk_container_add(GTK_CONTAINER(limit_fr), limit_vb);
848 limit_tb = gtk_table_new(3, 3, FALSE);
849 gtk_table_set_row_spacings(GTK_TABLE(limit_tb), 1);
850 gtk_table_set_col_spacings(GTK_TABLE(limit_tb), 3);
851 gtk_box_pack_start(GTK_BOX(limit_vb), limit_tb, FALSE, FALSE, 0);
854 /* Packet count row */
855 stop_packets_cb = gtk_check_button_new_with_label("... after");
856 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(stop_packets_cb),
857 capture_opts.has_autostop_packets);
858 SIGNAL_CONNECT(stop_packets_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w);
859 gtk_tooltips_set_tip(tooltips, stop_packets_cb,
860 "Stop capturing after the given number of packets have been captured.", NULL);
861 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_packets_cb, 0, 1, row, row+1);
863 stop_packets_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat)capture_opts.autostop_packets,
864 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
865 stop_packets_sb = gtk_spin_button_new (stop_packets_adj, 0, 0);
866 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_packets_sb), TRUE);
867 WIDGET_SET_SIZE(stop_packets_sb, 80, -1);
868 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_packets_sb, 1, 2, row, row+1);
870 stop_packets_lb = gtk_label_new("packet(s)");
871 gtk_misc_set_alignment(GTK_MISC(stop_packets_lb), 0, 0.5);
872 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_packets_lb, 2, 3, row, row+1);
876 stop_filesize_cb = gtk_check_button_new_with_label("... after");
877 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(stop_filesize_cb),
878 capture_opts.has_autostop_filesize);
879 SIGNAL_CONNECT(stop_filesize_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w);
880 gtk_tooltips_set_tip(tooltips, stop_filesize_cb,
881 "Stop capturing after the given amount of capture data has been captured.", NULL);
882 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_filesize_cb, 0, 1, row, row+1);
884 stop_filesize_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat)capture_opts.autostop_filesize,
885 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
886 stop_filesize_sb = gtk_spin_button_new (stop_filesize_adj, 0, 0);
887 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_filesize_sb), TRUE);
888 WIDGET_SET_SIZE(stop_filesize_sb, 80, -1);
889 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_filesize_sb, 1, 2, row, row+1);
891 stop_filesize_om = size_unit_option_menu_new();
892 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_filesize_om, 2, 3, row, row+1);
896 stop_duration_cb = gtk_check_button_new_with_label("... after");
897 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(stop_duration_cb),
898 capture_opts.has_autostop_duration);
899 SIGNAL_CONNECT(stop_duration_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w);
900 gtk_tooltips_set_tip(tooltips, stop_duration_cb,
901 "Stop capturing after the given time is exceeded.", NULL);
902 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_duration_cb, 0, 1, row, row+1);
904 stop_duration_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat)capture_opts.autostop_duration,
905 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
906 stop_duration_sb = gtk_spin_button_new (stop_duration_adj, 0, 0);
907 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_duration_sb), TRUE);
908 WIDGET_SET_SIZE(stop_duration_sb, 80, -1);
909 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_duration_sb, 1, 2, row, row+1);
911 stop_duration_om = time_unit_option_menu_new();
912 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_duration_om, 2, 3, row, row+1);
915 /* Display-related options frame */
916 display_fr = gtk_frame_new("Display Options");
917 gtk_container_add(GTK_CONTAINER(right_vb), display_fr);
919 display_vb = gtk_vbox_new(FALSE, 0);
920 gtk_container_border_width(GTK_CONTAINER(display_vb), 5);
921 gtk_container_add(GTK_CONTAINER(display_fr), display_vb);
923 /* "Update display in real time" row */
924 sync_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC(
925 "_Update list of packets in real time", accel_group);
926 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(sync_cb),
927 capture_opts.sync_mode);
928 SIGNAL_CONNECT(sync_cb, "toggled", capture_prep_adjust_sensitivity, cap_open_w);
929 gtk_tooltips_set_tip(tooltips, sync_cb,
930 "Using this option will show the captured packets immediately on the main screen. "
931 "Please note: this will slow down capturing, so increased packet drops might appear.", NULL);
932 gtk_container_add(GTK_CONTAINER(display_vb), sync_cb);
934 /* "Auto-scroll live update" row */
935 auto_scroll_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC(
936 "_Automatic scrolling in live capture", accel_group);
937 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(auto_scroll_cb), auto_scroll_live);
938 gtk_tooltips_set_tip(tooltips, auto_scroll_cb,
939 "This will scroll the \"Packet List\" automatically to the latest captured packet, "
940 "when the \"Update List of packets in real time\" option is used.", NULL);
941 gtk_container_add(GTK_CONTAINER(display_vb), auto_scroll_cb);
943 /* "Hide capture info" row */
944 hide_info_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC(
945 "_Hide capture info dialog", accel_group);
946 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(hide_info_cb), !capture_opts.show_info);
947 gtk_tooltips_set_tip(tooltips, hide_info_cb,
948 "Hide the capture info dialog while capturing.", NULL);
949 gtk_container_add(GTK_CONTAINER(display_vb), hide_info_cb);
951 /* Name Resolution frame */
952 resolv_fr = gtk_frame_new("Name Resolution");
953 gtk_container_add(GTK_CONTAINER(right_vb), resolv_fr);
955 resolv_vb = gtk_vbox_new(FALSE, 0);
956 gtk_container_border_width(GTK_CONTAINER(resolv_vb), 5);
957 gtk_container_add(GTK_CONTAINER(resolv_fr), resolv_vb);
959 m_resolv_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC(
960 "Enable _MAC name resolution", accel_group);
961 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(m_resolv_cb),
962 g_resolv_flags & RESOLV_MAC);
963 gtk_tooltips_set_tip(tooltips, m_resolv_cb,
964 "Perform MAC layer name resolution while capturing.", NULL);
965 gtk_container_add(GTK_CONTAINER(resolv_vb), m_resolv_cb);
967 n_resolv_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC(
968 "Enable _network name resolution", accel_group);
969 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(n_resolv_cb),
970 g_resolv_flags & RESOLV_NETWORK);
971 gtk_tooltips_set_tip(tooltips, n_resolv_cb,
972 "Perform network layer name resolution while capturing.", NULL);
973 gtk_container_add(GTK_CONTAINER(resolv_vb), n_resolv_cb);
975 t_resolv_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC(
976 "Enable _transport name resolution", accel_group);
977 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(t_resolv_cb),
978 g_resolv_flags & RESOLV_TRANSPORT);
979 gtk_tooltips_set_tip(tooltips, t_resolv_cb,
980 "Perform transport layer name resolution while capturing.", NULL);
981 gtk_container_add(GTK_CONTAINER(resolv_vb), t_resolv_cb);
983 /* Button row: OK and cancel buttons */
984 bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL);
985 gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 5);
987 ok_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_OK);
988 SIGNAL_CONNECT(ok_bt, "clicked", capture_prep_ok_cb, cap_open_w);
989 gtk_tooltips_set_tip(tooltips, ok_bt,
990 "Start the capture process.", NULL);
992 cancel_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CANCEL);
993 gtk_tooltips_set_tip(tooltips, cancel_bt,
994 "Cancel and exit dialog.", NULL);
995 window_set_cancel_button(cap_open_w, cancel_bt, window_cancel_button_cb);
997 help_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_HELP);
998 gtk_tooltips_set_tip(tooltips, help_bt,
999 "Show help about capturing.", NULL);
1000 SIGNAL_CONNECT(help_bt, "clicked", help_topic_cb, "Capturing");
1002 gtk_widget_grab_default(ok_bt);
1004 /* Attach pointers to needed widgets to the capture prefs window/object */
1005 OBJECT_SET_DATA(cap_open_w, E_CAP_IFACE_KEY, if_cb);
1006 OBJECT_SET_DATA(cap_open_w, E_CAP_SNAP_CB_KEY, snap_cb);
1007 OBJECT_SET_DATA(cap_open_w, E_CAP_SNAP_SB_KEY, snap_sb);
1008 OBJECT_SET_DATA(cap_open_w, E_CAP_LT_OM_KEY, linktype_om);
1010 OBJECT_SET_DATA(cap_open_w, E_CAP_BUFFER_SIZE_SB_KEY, buffer_size_sb);
1012 OBJECT_SET_DATA(cap_open_w, E_CAP_PROMISC_KEY, promisc_cb);
1013 OBJECT_SET_DATA(cap_open_w, E_CAP_FILT_KEY, filter_te);
1014 OBJECT_SET_DATA(cap_open_w, E_CAP_FILE_TE_KEY, file_te);
1015 OBJECT_SET_DATA(cap_open_w, E_CAP_MULTI_FILES_ON_CB_KEY, multi_files_on_cb);
1016 OBJECT_SET_DATA(cap_open_w, E_CAP_RING_NBF_CB_KEY, ringbuffer_nbf_cb);
1017 OBJECT_SET_DATA(cap_open_w, E_CAP_RING_NBF_SB_KEY, ringbuffer_nbf_sb);
1018 OBJECT_SET_DATA(cap_open_w, E_CAP_RING_NBF_LB_KEY, ringbuffer_nbf_lb);
1019 OBJECT_SET_DATA(cap_open_w, E_CAP_RING_FILESIZE_CB_KEY, ring_filesize_cb);
1020 OBJECT_SET_DATA(cap_open_w, E_CAP_RING_FILESIZE_SB_KEY, ring_filesize_sb);
1021 OBJECT_SET_DATA(cap_open_w, E_CAP_RING_FILESIZE_OM_KEY, ring_filesize_om);
1022 OBJECT_SET_DATA(cap_open_w, E_CAP_FILE_DURATION_CB_KEY, file_duration_cb);
1023 OBJECT_SET_DATA(cap_open_w, E_CAP_FILE_DURATION_SB_KEY, file_duration_sb);
1024 OBJECT_SET_DATA(cap_open_w, E_CAP_FILE_DURATION_OM_KEY, file_duration_om);
1025 OBJECT_SET_DATA(cap_open_w, E_CAP_SYNC_KEY, sync_cb);
1026 OBJECT_SET_DATA(cap_open_w, E_CAP_AUTO_SCROLL_KEY, auto_scroll_cb);
1027 OBJECT_SET_DATA(cap_open_w, E_CAP_HIDE_INFO_KEY, hide_info_cb);
1028 OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_PACKETS_CB_KEY, stop_packets_cb);
1029 OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_PACKETS_SB_KEY, stop_packets_sb);
1030 OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_PACKETS_LB_KEY, stop_packets_lb);
1031 OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_FILESIZE_CB_KEY, stop_filesize_cb);
1032 OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_FILESIZE_SB_KEY, stop_filesize_sb);
1033 OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_FILESIZE_OM_KEY, stop_filesize_om);
1034 OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_DURATION_CB_KEY, stop_duration_cb);
1035 OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_DURATION_SB_KEY, stop_duration_sb);
1036 OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_DURATION_OM_KEY, stop_duration_om);
1037 OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_FILES_CB_KEY, stop_files_cb);
1038 OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_FILES_SB_KEY, stop_files_sb);
1039 OBJECT_SET_DATA(cap_open_w, E_CAP_STOP_FILES_LB_KEY, stop_files_lb);
1040 OBJECT_SET_DATA(cap_open_w, E_CAP_M_RESOLVE_KEY, m_resolv_cb);
1041 OBJECT_SET_DATA(cap_open_w, E_CAP_N_RESOLVE_KEY, n_resolv_cb);
1042 OBJECT_SET_DATA(cap_open_w, E_CAP_T_RESOLVE_KEY, t_resolv_cb);
1044 /* Set the sensitivity of various widgets as per the settings of other
1046 capture_prep_adjust_sensitivity(NULL, cap_open_w);
1048 /* Catch the "activate" signal on the text
1049 entries, so that if the user types Return there, we act as if the
1050 "OK" button had been selected, as happens if Return is typed if some
1051 widget that *doesn't* handle the Return key has the input focus. */
1052 dlg_set_activate(GTK_COMBO(if_cb)->entry, ok_bt);
1053 dlg_set_activate(filter_te, ok_bt);
1054 dlg_set_activate(file_te, ok_bt);
1056 /* XXX - why does not
1058 gtk_widget_grab_focus(if_cb);
1060 give the initial focus to the "Interface" combo box?
1062 Or should I phrase that as "why does GTK+ continually frustrate
1063 attempts to make GUIs driveable from the keyboard?" We have to
1064 go catch the activate signal on every single GtkEntry widget
1065 (rather than having widgets whose activate signal is *not*
1066 caught not catch the Return keystroke, so that it passes on,
1067 ultimately, to the window, which can activate the default
1068 widget, i.e. the "OK" button); we have to catch the "key_press_event"
1069 signal and have the handler check for ESC, so that we can have ESC
1070 activate the "Cancel" button; in order to support Alt+<key> mnemonics
1071 for buttons and the like, we may have to construct an accelerator
1072 group by hand and set up the accelerators by hand (if that even
1073 works - I've not tried it yet); we have to do a "gtk_widget_grab_focus()"
1074 to keep some container widget from getting the initial focus, so that
1075 you don't have to tab into the first widget in order to start typing
1076 in it; and it now appears that you simply *can't* make a combo box
1077 get the initial focus, at least not in the obvious fashion. Sigh.... */
1079 SIGNAL_CONNECT(cap_open_w, "delete_event", window_delete_event_cb, NULL);
1080 SIGNAL_CONNECT(cap_open_w, "destroy", capture_prep_destroy_cb, NULL);
1082 gtk_widget_show_all(cap_open_w);
1083 window_present(cap_open_w);
1087 capture_prep_answered_cb(gpointer dialog _U_, gint btn, gpointer data)
1091 /* save file first */
1092 file_save_as_cmd(after_save_capture_dialog, data);
1097 case(ESD_BTN_CANCEL):
1100 g_assert_not_reached();
1105 capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
1109 if((cfile.state != FILE_CLOSED) && !cfile.user_saved) {
1110 /* user didn't saved his current file, ask him */
1111 dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_YES_NO_CANCEL,
1112 PRIMARY_TEXT_START "Save capture file before starting a new capture?" PRIMARY_TEXT_END "\n\n"
1113 "If you start a new capture without saving, your current capture data will be discarded.");
1114 simple_dialog_set_cb(dialog, capture_prep_answered_cb, NULL);
1116 /* unchanged file, just capture a new one */
1122 select_link_type_cb(GtkWidget *w, gpointer data)
1124 int new_linktype = GPOINTER_TO_INT(data);
1125 GtkWidget *linktype_om = OBJECT_GET_DATA(w, E_CAP_LT_OM_KEY);
1126 int old_linktype = GPOINTER_TO_INT(OBJECT_GET_DATA(linktype_om, E_CAP_OM_LT_VALUE_KEY));
1128 if (old_linktype != new_linktype)
1129 OBJECT_SET_DATA(linktype_om, E_CAP_OM_LT_VALUE_KEY, GINT_TO_POINTER(new_linktype));
1133 capture_prep_file_cb(GtkWidget *file_bt, GtkWidget *file_te)
1135 file_selection_browse(file_bt, file_te, "Ethereal: Specify a Capture File", FILE_SELECTION_OPEN);
1140 capture_prep_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w) {
1141 GtkWidget *if_cb, *snap_cb, *snap_sb, *promisc_cb, *filter_te,
1142 *file_te, *multi_files_on_cb, *ringbuffer_nbf_sb, *ringbuffer_nbf_cb,
1143 *linktype_om, *sync_cb, *auto_scroll_cb, *hide_info_cb,
1144 *stop_packets_cb, *stop_packets_sb,
1145 *stop_filesize_cb, *stop_filesize_sb, *stop_filesize_om,
1146 *stop_duration_cb, *stop_duration_sb, *stop_duration_om,
1147 *ring_filesize_cb, *ring_filesize_sb, *ring_filesize_om,
1148 *file_duration_cb, *file_duration_sb, *file_duration_om,
1149 *stop_files_cb, *stop_files_sb,
1150 *m_resolv_cb, *n_resolv_cb, *t_resolv_cb;
1152 GtkWidget *buffer_size_sb;
1157 const gchar *filter_text;
1159 const gchar *g_save_file;
1164 if_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_IFACE_KEY);
1165 snap_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_SNAP_CB_KEY);
1166 snap_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_SNAP_SB_KEY);
1167 linktype_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_LT_OM_KEY);
1169 buffer_size_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_BUFFER_SIZE_SB_KEY);
1171 promisc_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_PROMISC_KEY);
1172 filter_te = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILT_KEY);
1173 file_te = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILE_TE_KEY);
1174 multi_files_on_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_MULTI_FILES_ON_CB_KEY);
1175 ringbuffer_nbf_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_NBF_CB_KEY);
1176 ringbuffer_nbf_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_NBF_SB_KEY);
1177 ring_filesize_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_FILESIZE_CB_KEY);
1178 ring_filesize_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_FILESIZE_SB_KEY);
1179 ring_filesize_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_FILESIZE_OM_KEY);
1180 file_duration_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILE_DURATION_CB_KEY);
1181 file_duration_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILE_DURATION_SB_KEY);
1182 file_duration_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILE_DURATION_OM_KEY);
1183 sync_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_SYNC_KEY);
1184 auto_scroll_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_AUTO_SCROLL_KEY);
1185 hide_info_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_HIDE_INFO_KEY);
1186 stop_packets_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_PACKETS_CB_KEY);
1187 stop_packets_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_PACKETS_SB_KEY);
1188 stop_filesize_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILESIZE_CB_KEY);
1189 stop_filesize_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILESIZE_SB_KEY);
1190 stop_filesize_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILESIZE_OM_KEY);
1191 stop_duration_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_DURATION_CB_KEY);
1192 stop_duration_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_DURATION_SB_KEY);
1193 stop_duration_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_DURATION_OM_KEY);
1194 stop_files_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILES_CB_KEY);
1195 stop_files_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILES_SB_KEY);
1196 m_resolv_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_M_RESOLVE_KEY);
1197 n_resolv_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_N_RESOLVE_KEY);
1198 t_resolv_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_T_RESOLVE_KEY);
1201 g_strdup(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry)));
1202 if_text = g_strstrip(entry_text);
1203 if_name = get_if_name(if_text);
1204 if (*if_name == '\0') {
1205 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
1206 "You didn't specify an interface on which to capture packets.");
1211 g_free(cfile.iface);
1212 cfile.iface = g_strdup(if_name);
1215 capture_opts.linktype =
1216 GPOINTER_TO_INT(OBJECT_GET_DATA(linktype_om, E_CAP_OM_LT_VALUE_KEY));
1219 capture_opts.buffer_size =
1220 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(buffer_size_sb));
1223 capture_opts.has_snaplen =
1224 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(snap_cb));
1225 if (capture_opts.has_snaplen) {
1226 capture_opts.snaplen =
1227 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(snap_sb));
1228 if (capture_opts.snaplen < 1)
1229 capture_opts.snaplen = WTAP_MAX_PACKET_SIZE;
1230 else if (capture_opts.snaplen < MIN_PACKET_SIZE)
1231 capture_opts.snaplen = MIN_PACKET_SIZE;
1234 capture_opts.promisc_mode =
1235 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(promisc_cb));
1237 /* XXX - don't try to get clever and set "cfile.filter" to NULL if the
1238 filter string is empty, as an indication that we don't have a filter
1239 and thus don't have to set a filter when capturing - the version of
1240 libpcap in Red Hat Linux 6.1, and versions based on later patches
1241 in that series, don't bind the AF_PACKET socket to an interface
1242 until a filter is set, which means they aren't bound at all if
1243 no filter is set, which means no packets arrive as input on that
1244 socket, which means Ethereal never sees any packets. */
1245 filter_text = gtk_entry_get_text(GTK_ENTRY(filter_te));
1247 g_free(cfile.cfilter);
1248 g_assert(filter_text != NULL);
1249 cfile.cfilter = g_strdup(filter_text);
1251 g_save_file = gtk_entry_get_text(GTK_ENTRY(file_te));
1252 if (g_save_file && g_save_file[0]) {
1253 /* User specified a file to which the capture should be written. */
1254 save_file = g_strdup(g_save_file);
1255 /* Save the directory name for future file dialogs. */
1256 cf_name = g_strdup(g_save_file);
1257 dirname = get_dirname(cf_name); /* Overwrites cf_name */
1258 set_last_open_dir(dirname);
1261 /* User didn't specify a file; save to a temporary file. */
1265 capture_opts.has_autostop_packets =
1266 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_packets_cb));
1267 if (capture_opts.has_autostop_packets)
1268 capture_opts.autostop_packets =
1269 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_packets_sb));
1271 capture_opts.has_autostop_duration =
1272 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_duration_cb));
1273 if (capture_opts.has_autostop_duration) {
1274 capture_opts.autostop_duration =
1275 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_duration_sb));
1276 capture_opts.autostop_duration =
1277 time_unit_option_menu_get_value(stop_duration_om, capture_opts.autostop_duration);
1280 capture_opts.sync_mode =
1281 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sync_cb));
1284 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(auto_scroll_cb));
1286 capture_opts.show_info =
1287 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hide_info_cb));
1289 g_resolv_flags |= g_resolv_flags & RESOLV_CONCURRENT;
1290 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_resolv_cb)))
1291 g_resolv_flags |= RESOLV_MAC;
1292 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(n_resolv_cb)))
1293 g_resolv_flags |= RESOLV_NETWORK;
1294 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(t_resolv_cb)))
1295 g_resolv_flags |= RESOLV_TRANSPORT;
1297 capture_opts.has_ring_num_files =
1298 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb));
1300 capture_opts.ring_num_files =
1301 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ringbuffer_nbf_sb));
1302 if (capture_opts.ring_num_files > RINGBUFFER_MAX_NUM_FILES)
1303 capture_opts.ring_num_files = RINGBUFFER_MAX_NUM_FILES;
1304 #if RINGBUFFER_MIN_NUM_FILES > 0
1305 else if (capture_opts.ring_num_files < RINGBUFFER_MIN_NUM_FILES)
1306 capture_opts.ring_num_files = RINGBUFFER_MIN_NUM_FILES;
1309 capture_opts.multi_files_on =
1310 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(multi_files_on_cb));
1312 if(capture_opts.sync_mode)
1313 capture_opts.multi_files_on = FALSE;
1315 if (capture_opts.multi_files_on) {
1316 capture_opts.has_autostop_filesize =
1317 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb));
1318 if (capture_opts.has_autostop_filesize) {
1319 tmp = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ring_filesize_sb));
1320 tmp = size_unit_option_menu_get_value(ring_filesize_om, tmp);
1322 capture_opts.autostop_filesize = tmp;
1324 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
1325 PRIMARY_TEXT_START "Multiple files: Requested filesize too large!\n\n" PRIMARY_TEXT_END
1326 "The setting \"Next file every x byte(s)\" can't be greater than %u bytes (2GB).", G_MAXINT);
1331 /* test if the settings are ok for a ringbuffer */
1332 if (save_file == NULL) {
1333 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
1334 PRIMARY_TEXT_START "Multiple files: No capture file name given!\n\n" PRIMARY_TEXT_END
1335 "You must specify a filename if you want to use multiple files.");
1337 } else if (!capture_opts.has_autostop_filesize) {
1338 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
1339 PRIMARY_TEXT_START "Multiple files: No file limit given!\n\n" PRIMARY_TEXT_END
1340 "You must specify a file size at which is switched to the next capture file\n"
1341 "if you want to use multiple files.");
1346 capture_opts.has_autostop_filesize =
1347 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_filesize_cb));
1348 if (capture_opts.has_autostop_filesize) {
1349 tmp = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_filesize_sb));
1350 tmp = size_unit_option_menu_get_value(stop_filesize_om, tmp);
1352 capture_opts.autostop_filesize = tmp;
1354 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
1355 PRIMARY_TEXT_START "Stop Capture: Requested filesize too large!\n\n" PRIMARY_TEXT_END
1356 "The setting \"... after x byte(s)\" can't be greater than %u bytes (2GB).", G_MAXINT);
1362 capture_opts.has_file_duration =
1363 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_duration_cb));
1364 if (capture_opts.has_file_duration) {
1365 capture_opts.file_duration =
1366 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(file_duration_sb));
1367 capture_opts.file_duration =
1368 time_unit_option_menu_get_value(file_duration_om, capture_opts.file_duration);
1371 capture_opts.has_autostop_files =
1372 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_files_cb));
1373 if (capture_opts.has_autostop_files)
1374 capture_opts.autostop_files =
1375 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_files_sb));
1377 window_destroy(GTK_WIDGET(parent_w));
1379 do_capture(save_file);
1380 if (save_file != NULL)
1385 capture_prep_destroy_cb(GtkWidget *win, gpointer user_data _U_)
1389 /* Is there a file selection dialog associated with this
1390 Capture Options dialog? */
1391 fs = OBJECT_GET_DATA(win, E_FILE_SEL_DIALOG_PTR_KEY);
1394 /* Yes. Destroy it. */
1398 /* Note that we no longer have a "Capture Options" dialog box. */
1403 capture_prep_interface_changed_cb(GtkWidget *entry, gpointer argp)
1405 GtkWidget *linktype_om = argp;
1407 set_link_type_list(linktype_om, entry);
1411 * Adjust the sensitivity of various widgets as per the current setting
1415 capture_prep_adjust_sensitivity(GtkWidget *tb _U_, gpointer parent_w)
1419 *multi_files_on_cb, *ringbuffer_nbf_cb, *ringbuffer_nbf_sb, *ringbuffer_nbf_lb,
1420 *ring_filesize_cb, *ring_filesize_sb, *ring_filesize_om,
1421 *file_duration_cb, *file_duration_sb, *file_duration_om,
1422 *sync_cb, *auto_scroll_cb, *hide_info_cb,
1423 *stop_packets_cb, *stop_packets_sb, *stop_packets_lb,
1424 *stop_filesize_cb, *stop_filesize_sb, *stop_filesize_om,
1425 *stop_duration_cb, *stop_duration_sb, *stop_duration_om,
1426 *stop_files_cb, *stop_files_sb, *stop_files_lb;
1429 if_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_IFACE_KEY);
1430 snap_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_SNAP_CB_KEY);
1431 snap_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_SNAP_SB_KEY);
1432 multi_files_on_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_MULTI_FILES_ON_CB_KEY);
1433 ringbuffer_nbf_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_NBF_CB_KEY);
1434 ringbuffer_nbf_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_NBF_SB_KEY);
1435 ringbuffer_nbf_lb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_NBF_LB_KEY);
1436 ring_filesize_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_FILESIZE_CB_KEY);
1437 ring_filesize_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_FILESIZE_SB_KEY);
1438 ring_filesize_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_RING_FILESIZE_OM_KEY);
1439 file_duration_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILE_DURATION_CB_KEY);
1440 file_duration_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILE_DURATION_SB_KEY);
1441 file_duration_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_FILE_DURATION_OM_KEY);
1442 sync_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_SYNC_KEY);
1443 auto_scroll_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_AUTO_SCROLL_KEY);
1444 hide_info_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_HIDE_INFO_KEY);
1445 stop_packets_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_PACKETS_CB_KEY);
1446 stop_packets_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_PACKETS_SB_KEY);
1447 stop_packets_lb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_PACKETS_LB_KEY);
1448 stop_filesize_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILESIZE_CB_KEY);
1449 stop_filesize_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILESIZE_SB_KEY);
1450 stop_filesize_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILESIZE_OM_KEY);
1451 stop_duration_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_DURATION_CB_KEY);
1452 stop_duration_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_DURATION_SB_KEY);
1453 stop_duration_om = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_DURATION_OM_KEY);
1454 stop_files_cb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILES_CB_KEY);
1455 stop_files_sb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILES_SB_KEY);
1456 stop_files_lb = (GtkWidget *) OBJECT_GET_DATA(parent_w, E_CAP_STOP_FILES_LB_KEY);
1458 /* The snapshot length spinbox is sensitive if the "Limit each packet
1459 to" checkbox is on. */
1460 gtk_widget_set_sensitive(GTK_WIDGET(snap_sb),
1461 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(snap_cb)));
1464 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sync_cb))) {
1465 /* "Update list of packets in real time" captures enabled; we don't
1466 support ring buffer mode for those captures, so turn ring buffer
1467 mode off if it's on, and make its toggle button, and the spin
1468 button for the number of ring buffer files (and the spin button's
1469 label), insensitive. */
1470 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(multi_files_on_cb), FALSE);
1471 gtk_widget_set_sensitive(GTK_WIDGET(multi_files_on_cb), FALSE);
1473 /* Auto-scroll mode is meaningful only in "Update list of packets
1474 in real time" captures, so make its toggle button sensitive. */
1475 gtk_widget_set_sensitive(GTK_WIDGET(auto_scroll_cb), TRUE);
1477 gtk_widget_set_sensitive(GTK_WIDGET(hide_info_cb), TRUE);
1479 /* "Update list of packets in real time" captures disabled; that
1480 means ring buffer mode is OK, so make its toggle button
1482 gtk_widget_set_sensitive(GTK_WIDGET(multi_files_on_cb), TRUE);
1484 /* Auto-scroll mode is meaningful only in "Update list of packets
1485 in real time" captures, so make its toggle button insensitive. */
1486 gtk_widget_set_sensitive(GTK_WIDGET(auto_scroll_cb), FALSE);
1488 gtk_widget_set_sensitive(GTK_WIDGET(hide_info_cb), FALSE);
1491 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(multi_files_on_cb))) {
1492 /* Ring buffer mode enabled. */
1493 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ring_filesize_cb), TRUE);
1495 gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_cb), TRUE);
1496 gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_sb),
1497 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb)));
1498 gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_lb),
1499 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb)));
1501 /* The ring filesize spinbox is sensitive if the "Next capture file
1502 after N kilobytes" checkbox is on. */
1503 gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_cb), TRUE);
1504 gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_sb),
1505 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb)));
1506 gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_om),
1507 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb)));
1509 /* The ring duration spinbox is sensitive if the "Next capture file
1510 after N seconds" checkbox is on. */
1511 gtk_widget_set_sensitive(GTK_WIDGET(file_duration_cb), TRUE);
1512 gtk_widget_set_sensitive(GTK_WIDGET(file_duration_sb),
1513 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_duration_cb)));
1514 gtk_widget_set_sensitive(GTK_WIDGET(file_duration_om),
1515 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_duration_cb)));
1517 gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_cb), FALSE);
1518 gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_sb), FALSE);
1519 gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_om), FALSE);
1521 gtk_widget_set_sensitive(GTK_WIDGET(stop_files_cb), TRUE);
1522 gtk_widget_set_sensitive(GTK_WIDGET(stop_files_sb),
1523 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_files_cb)));
1524 gtk_widget_set_sensitive(GTK_WIDGET(stop_files_lb),
1525 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_files_cb)));
1527 /* Ring buffer mode disabled. */
1528 gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_cb), FALSE);
1529 gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_sb), FALSE);
1530 gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_lb), FALSE);
1532 gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_cb), FALSE);
1533 gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_sb),FALSE);
1534 gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_om),FALSE);
1536 gtk_widget_set_sensitive(GTK_WIDGET(file_duration_cb), FALSE);
1537 gtk_widget_set_sensitive(GTK_WIDGET(file_duration_sb),FALSE);
1538 gtk_widget_set_sensitive(GTK_WIDGET(file_duration_om),FALSE);
1540 /* The maximum file size spinbox is sensitive if the "Stop capture
1541 after N kilobytes" checkbox is on. */
1542 gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_cb), TRUE);
1543 gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_sb),
1544 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_filesize_cb)));
1545 gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_om),
1546 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_filesize_cb)));
1548 gtk_widget_set_sensitive(GTK_WIDGET(stop_files_cb), FALSE);
1549 gtk_widget_set_sensitive(GTK_WIDGET(stop_files_sb), FALSE);
1550 gtk_widget_set_sensitive(GTK_WIDGET(stop_files_lb), FALSE);
1553 /* The maximum packet count spinbox is sensitive if the "Stop capture
1554 after N packets" checkbox is on. */
1555 gtk_widget_set_sensitive(GTK_WIDGET(stop_packets_sb),
1556 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_packets_cb)));
1557 gtk_widget_set_sensitive(GTK_WIDGET(stop_packets_lb),
1558 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_packets_cb)));
1560 /* The capture duration spinbox is sensitive if the "Stop capture
1561 after N seconds" checkbox is on. */
1562 gtk_widget_set_sensitive(GTK_WIDGET(stop_duration_sb),
1563 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_duration_cb)));
1564 gtk_widget_set_sensitive(GTK_WIDGET(stop_duration_om),
1565 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_duration_cb)));
1568 #endif /* HAVE_LIBPCAP */