2 * Routines for packet capture windows
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
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.
31 #ifdef HAVE_SYS_TYPES_H
32 #include <sys/types.h>
38 * main_menu.h uses FILE, but I guess <stdio.h> is included by
39 * something else before main_menu.h is included.
46 #include <epan/packet.h>
47 #include <epan/addr_resolv.h>
48 #include <epan/prefs.h>
49 #include <epan/filesystem.h>
51 #include "../capture.h"
52 #include "../globals.h"
53 #include "../capture_errs.h"
54 #include "../simple_dialog.h"
55 #include "../capture-pcap-util.h"
56 #include "../capture_ui_utils.h"
57 #include "../ringbuffer.h"
60 #include "gtk/main_menu.h"
61 #include "gtk/gui_utils.h"
62 #include "gtk/capture_dlg.h"
63 #include "gtk/filter_dlg.h"
64 #include "gtk/dlg_utils.h"
65 #include "gtk/file_dlg.h"
66 #include "gtk/stock_icons.h"
67 #include "gtk/capture_file_dlg.h"
68 #include "gtk/help_dlg.h"
69 #include "gtk/gtkglobals.h"
70 #include "gtk/capture_globals.h"
71 #include "gtk/cfilter_combo_utils.h"
74 #include "../capture-wpcap.h"
81 #include "airpcap_loader.h"
82 #include "airpcap_gui_utils.h"
83 #include "airpcap_dlg.h"
86 /* Capture callback data keys */
87 #define E_CAP_IFACE_KEY "cap_iface"
88 #define E_CAP_IFACE_IP_KEY "cap_iface_ip"
89 #define E_CAP_SNAP_CB_KEY "cap_snap_cb"
90 #define E_CAP_LT_OM_KEY "cap_lt_om"
91 #define E_CAP_LT_OM_LABEL_KEY "cap_lt_om_label"
93 #define E_CAP_BUFFER_SIZE_SB_KEY "cap_buffer_size_sb"
95 #define E_CAP_SNAP_SB_KEY "cap_snap_sb"
96 #define E_CAP_PROMISC_KEY "cap_promisc"
97 #define E_CAP_FILT_KEY "cap_filter_te"
98 #define E_CAP_FILE_TE_KEY "cap_file_te"
99 #define E_CAP_MULTI_FILES_ON_CB_KEY "cap_multi_files_on_cb"
100 #define E_CAP_RING_FILESIZE_CB_KEY "cap_ring_filesize_cb"
101 #define E_CAP_RING_FILESIZE_SB_KEY "cap_ring_filesize_sb"
102 #define E_CAP_RING_FILESIZE_OM_KEY "cap_ring_filesize_om"
103 #define E_CAP_FILE_DURATION_CB_KEY "cap_file_duration_cb"
104 #define E_CAP_FILE_DURATION_SB_KEY "cap_file_duration_sb"
105 #define E_CAP_FILE_DURATION_OM_KEY "cap_file_duration_om"
106 #define E_CAP_RING_NBF_CB_KEY "cap_ring_nbf_cb"
107 #define E_CAP_RING_NBF_SB_KEY "cap_ring_nbf_sb"
108 #define E_CAP_RING_NBF_LB_KEY "cap_ring_nbf_lb"
109 #define E_CAP_STOP_FILES_CB_KEY "cap_stop_files_cb"
110 #define E_CAP_STOP_FILES_SB_KEY "cap_stop_files_sb"
111 #define E_CAP_STOP_FILES_LB_KEY "cap_stop_files_lb"
112 #define E_CAP_SYNC_KEY "cap_sync"
113 #define E_CAP_AUTO_SCROLL_KEY "cap_auto_scroll"
114 #define E_CAP_HIDE_INFO_KEY "cap_hide_info"
115 #define E_CAP_STOP_PACKETS_CB_KEY "cap_stop_packets_cb"
116 #define E_CAP_STOP_PACKETS_SB_KEY "cap_stop_packets_sb"
117 #define E_CAP_STOP_PACKETS_LB_KEY "cap_stop_packets_lb"
118 #define E_CAP_STOP_FILESIZE_CB_KEY "cap_stop_filesize_cb"
119 #define E_CAP_STOP_FILESIZE_SB_KEY "cap_stop_filesize_sb"
120 #define E_CAP_STOP_FILESIZE_OM_KEY "cap_stop_filesize_om"
121 #define E_CAP_STOP_DURATION_CB_KEY "cap_stop_duration_cb"
122 #define E_CAP_STOP_DURATION_SB_KEY "cap_stop_duration_sb"
123 #define E_CAP_STOP_DURATION_OM_KEY "cap_stop_duration_om"
124 #define E_CAP_M_RESOLVE_KEY "cap_m_resolve"
125 #define E_CAP_N_RESOLVE_KEY "cap_n_resolve"
126 #define E_CAP_T_RESOLVE_KEY "cap_t_resolve"
128 #ifdef HAVE_PCAP_REMOTE
129 #define E_CAP_IFTYPE_OM_KEY "cap_iftype_om"
130 #define E_CAP_DATATX_UDP_CB_KEY "cap_datatx_udp_cb"
131 #define E_CAP_NOCAP_RPCAP_CB_KEY "cap_nocap_rpcap_cb"
132 #define E_CAP_REMOTE_DIALOG_PTR_KEY "cap_remote_dialog"
133 #define E_CAP_REMOTE_CALLER_PTR_KEY "cap_remote_caller"
134 #define E_REMOTE_HOST_TE_KEY "cap_remote_host"
135 #define E_REMOTE_PORT_TE_KEY "cap_remote_port"
136 #define E_REMOTE_AUTH_NULL_KEY "cap_remote_auth_null"
137 #define E_REMOTE_AUTH_PASSWD_KEY "cap_remote_auth_passwd"
138 #define E_REMOTE_USERNAME_LB_KEY "cap_remote_username_lb"
139 #define E_REMOTE_USERNAME_TE_KEY "cap_remote_username_te"
140 #define E_REMOTE_PASSWD_LB_KEY "cap_remote_passwd_lb"
141 #define E_REMOTE_PASSWD_TE_KEY "cap_remote_passwd_te"
142 #define E_CAP_OM_IFTYPE_VALUE_KEY "cap_om_iftype_value"
144 #ifdef HAVE_PCAP_SETSAMPLING
145 #define E_CAP_SAMP_NONE_RB_KEY "cap_samp_none_rb"
146 #define E_CAP_SAMP_COUNT_RB_KEY "cap_samp_count_rb"
147 #define E_CAP_SAMP_COUNT_SB_KEY "cap_samp_count_sb"
148 #define E_CAP_SAMP_TIMER_RB_KEY "cap_samp_timer_rb"
149 #define E_CAP_SAMP_TIMER_SB_KEY "cap_samp_timer_sb"
152 #define E_CAP_OM_LT_VALUE_KEY "cap_om_lt_value"
156 * Keep a static pointer to the current "Capture Options" window, if
157 * any, so that if somebody tries to do "Capture:Start" while there's
158 * already a "Capture Options" window up, we just pop up the existing
159 * one, rather than creating a new one.
161 static GtkWidget *cap_open_w;
162 static GtkWidget * dl_hdr_menu=NULL;
163 static GHashTable *linktype_history=NULL;
166 capture_prep_file_cb(GtkWidget *file_bt, GtkWidget *file_te);
169 select_link_type_cb(GtkWidget *w, gpointer data);
171 #ifdef HAVE_PCAP_REMOTE
173 select_if_type_cb(GtkWidget *w, gpointer data);
176 capture_remote_cb(GtkWidget *w, gpointer data);
180 capture_prep_adjust_sensitivity(GtkWidget *tb, gpointer parent_w);
183 capture_prep_destroy_cb(GtkWidget *win, gpointer user_data);
186 capture_prep_interface_changed_cb(GtkWidget *entry, gpointer parent_w);
189 capture_dlg_prep(gpointer parent_w);
192 /* stop the currently running capture */
194 capture_stop_cb(GtkWidget *w _U_, gpointer d _U_)
197 airpcap_set_toolbar_stop_capture(airpcap_if_active);
200 capture_stop(&global_capture_opts);
203 /* restart (stop - delete old file - start) running capture */
205 capture_restart_cb(GtkWidget *w _U_, gpointer d _U_)
208 airpcap_set_toolbar_start_capture(airpcap_if_active);
211 capture_restart(&global_capture_opts);
214 /* init the link type list */
215 /* (often this list has only one entry and will therefore be disabled) */
217 set_link_type_list(GtkWidget *linktype_om, GtkWidget *entry)
227 GtkWidget *lt_menu, *lt_menu_item;
229 gint linktype, linktype_select, linktype_count;
231 data_link_info_t *data_link_info;
232 gchar *linktype_menu_label;
233 guint num_supported_link_types;
234 GtkWidget *linktype_lb = g_object_get_data(G_OBJECT(linktype_om), E_CAP_LT_OM_LABEL_KEY);
236 GString *ip_str = g_string_new("IP address: ");
241 GtkWidget *advanced_bt;
244 /* Deallocate the existing menu for Datalink header type */
245 if (dl_hdr_menu != NULL)
246 gtk_widget_destroy(dl_hdr_menu);
248 lt_menu = gtk_menu_new();
249 dl_hdr_menu= lt_menu;
250 entry_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
251 if_text = g_strstrip(entry_text);
252 if_name = g_strdup(get_if_name(if_text));
254 linktype_p = g_hash_table_lookup (linktype_history, if_name);
256 linktype = *linktype_p;
258 linktype = capture_dev_user_linktype_find(if_name);
262 /* is it an airpcap interface??? */
263 /* retrieve the advanced button pointer */
264 advanced_bt = g_object_get_data(G_OBJECT(entry),AIRPCAP_OPTIONS_ADVANCED_KEY);
265 airpcap_if_selected = get_airpcap_if_from_name(airpcap_if_list,if_name);
266 airpcap_enable_toolbar_widgets(airpcap_tb,FALSE);
267 if (airpcap_if_selected != NULL) {
268 gtk_widget_set_sensitive(advanced_bt,TRUE);
270 gtk_widget_set_sensitive(advanced_bt,FALSE);
275 * If the interface name is in the list of known interfaces, get
276 * its list of link-layer types and set the option menu to display it.
278 * If it's not, don't bother - the user might be in the middle of
279 * editing the list, or it might be a remote device in which case
280 * getting the list could take an arbitrarily-long period of time.
281 * The list currently won't contain any remote devices (as
282 * "pcap_findalldevs()" doesn't know about remote devices, and neither
283 * does the code we use if "pcap_findalldevs()" isn't available), but
284 * should contain all the local devices on which you can capture.
287 if (*if_name != '\0') {
289 * Try to get the list of known interfaces.
291 if_list = capture_interface_list(&err, NULL);
292 if (if_list != NULL) {
294 * We have the list - check it.
296 for (if_entry = if_list; if_entry != NULL;
297 if_entry = g_list_next(if_entry)) {
298 if_info = if_entry->data;
299 if (strcmp(if_info->name, if_name) == 0) {
302 * Get the list of link-layer types for it.
304 lt_list = capture_pcap_linktype_list(if_name, NULL);
306 /* create string of list of IP addresses of this interface */
307 for (; (curr_ip = g_slist_nth(if_info->ip_addr, ips)) != NULL; ips++) {
309 g_string_append(ip_str, ", ");
311 ip_addr = (if_addr_t *)curr_ip->data;
312 switch (ip_addr->type) {
315 g_string_append(ip_str,
316 ip_to_str((guint8 *)&ip_addr->ip_addr.ip4_addr));
320 g_string_append(ip_str,
321 ip6_to_str((struct e_in6_addr *)&ip_addr->ip_addr.ip6_addr));
325 g_assert_not_reached();
329 if (if_info->loopback)
330 g_string_append(ip_str, " (loopback)");
333 free_interface_list(if_list);
339 num_supported_link_types = 0;
342 for (lt_entry = lt_list; lt_entry != NULL; lt_entry = g_list_next(lt_entry)) {
343 data_link_info = lt_entry->data;
344 if (data_link_info->description != NULL) {
345 lt_menu_item = gtk_menu_item_new_with_label(data_link_info->description);
346 g_object_set_data(G_OBJECT(lt_menu_item), E_CAP_LT_OM_KEY, linktype_om);
347 g_signal_connect(lt_menu_item, "activate", G_CALLBACK(select_link_type_cb),
348 GINT_TO_POINTER(data_link_info->dlt));
349 num_supported_link_types++;
351 /* Not supported - tell them about it but don't let them select it. */
352 linktype_menu_label = g_strdup_printf("%s (not supported)",
353 data_link_info->name);
354 lt_menu_item = gtk_menu_item_new_with_label(linktype_menu_label);
355 g_free(linktype_menu_label);
357 if (data_link_info->dlt == linktype) {
358 /* Found a matching dlt, selecth this */
359 linktype_select = linktype_count;
361 gtk_menu_shell_append(GTK_MENU_SHELL(lt_menu), lt_menu_item);
362 gtk_widget_show(lt_menu_item);
365 if (lt_list == NULL) {
366 lt_menu_item = gtk_menu_item_new_with_label("(not supported)");
367 gtk_menu_shell_append(GTK_MENU_SHELL(lt_menu), lt_menu_item);
368 gtk_widget_show(lt_menu_item);
370 free_pcap_linktype_list(lt_list);
372 gtk_option_menu_set_menu(GTK_OPTION_MENU(linktype_om), lt_menu);
373 gtk_widget_set_sensitive(linktype_lb, num_supported_link_types >= 2);
374 gtk_widget_set_sensitive(linktype_om, num_supported_link_types >= 2);
376 g_object_set_data(G_OBJECT(linktype_om), E_CAP_OM_LT_VALUE_KEY, GINT_TO_POINTER(linktype));
377 global_capture_opts.linktype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(linktype_om), E_CAP_OM_LT_VALUE_KEY));
379 /* Restore the menu to the last index used */
380 gtk_option_menu_set_history(GTK_OPTION_MENU(linktype_om),linktype_select);
381 if_ip_lb = g_object_get_data(G_OBJECT(linktype_om), E_CAP_IFACE_KEY);
383 g_string_append(ip_str, "unknown");
385 gtk_label_set_text(GTK_LABEL(if_ip_lb), ip_str->str);
386 #if GTK_CHECK_VERSION(2,6,0)
387 gtk_label_set_ellipsize(GTK_LABEL(if_ip_lb), PANGO_ELLIPSIZE_MIDDLE);
389 g_string_free(ip_str, TRUE);
393 #define TIME_UNIT_SECOND 0
394 #define TIME_UNIT_MINUTE 1
395 #define TIME_UNIT_HOUR 2
396 #define TIME_UNIT_DAY 3
397 #define MAX_TIME_UNITS 4
398 static const char *time_unit_name[MAX_TIME_UNITS] = {
405 /* create one of the duration options */
406 /* (and select the matching unit depending on the given value) */
407 static GtkWidget *time_unit_option_menu_new(guint32 value) {
408 GtkWidget *unit_om, *menu, *menu_item;
411 unit_om=gtk_option_menu_new();
413 for(i=0;i<MAX_TIME_UNITS;i++){
414 menu_item=gtk_menu_item_new_with_label(time_unit_name[i]);
415 g_object_set_data(G_OBJECT(menu_item), "time_unit", GINT_TO_POINTER(i));
416 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
419 /* the selected menu item can't be changed, once the option_menu
420 is created, so set the matching menu item now */
422 if(value >= 60 * 60 * 24) {
423 gtk_menu_set_active(GTK_MENU(menu), TIME_UNIT_DAY);
426 if(value >= 60 * 60) {
427 gtk_menu_set_active(GTK_MENU(menu), TIME_UNIT_HOUR);
431 gtk_menu_set_active(GTK_MENU(menu), TIME_UNIT_MINUTE);
434 gtk_menu_set_active(GTK_MENU(menu), TIME_UNIT_SECOND);
439 gtk_option_menu_set_menu(GTK_OPTION_MENU(unit_om), menu);
444 /* convert time value from raw to displayed (e.g. 60s -> 1min) */
445 static guint32 time_unit_option_menu_convert_value(
449 if(value >= 60 * 60 * 24) {
450 return value / (60 * 60 * 24);
454 if(value >= 60 * 60) {
455 return value / (60 * 60);
467 /* get raw value from unit and value fields */
468 static guint32 time_unit_option_menu_get_value(
472 GtkWidget *menu, *menu_item;
475 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(unit_om));
476 menu_item = gtk_menu_get_active(GTK_MENU(menu));
477 unit = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(menu_item), "time_unit"));
481 case(TIME_UNIT_SECOND):
483 case(TIME_UNIT_MINUTE):
485 case(TIME_UNIT_HOUR):
486 return value * 60 * 60;
488 return value * 60 * 60 * 24;
490 g_assert_not_reached();
496 #define SIZE_UNIT_KILOBYTES 0
497 #define SIZE_UNIT_MEGABYTES 1
498 #define SIZE_UNIT_GIGABYTES 2
499 #define MAX_SIZE_UNITS 3
500 static const char *size_unit_name[MAX_SIZE_UNITS] = {
506 /* create one of the size options */
507 /* (and select the matching unit depending on the given value) */
508 static GtkWidget *size_unit_option_menu_new(guint32 value) {
509 GtkWidget *unit_om, *menu, *menu_item;
512 unit_om=gtk_option_menu_new();
514 for(i=0;i<MAX_SIZE_UNITS;i++){
515 menu_item=gtk_menu_item_new_with_label(size_unit_name[i]);
516 g_object_set_data(G_OBJECT(menu_item), "size_unit", GINT_TO_POINTER(i));
517 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
520 /* the selected menu item can't be changed, once the option_menu
521 is created, so set the matching menu item now */
523 if(value >= 1024 * 1024) {
524 gtk_menu_set_active(GTK_MENU(menu), SIZE_UNIT_GIGABYTES);
528 gtk_menu_set_active(GTK_MENU(menu), SIZE_UNIT_MEGABYTES);
531 gtk_menu_set_active(GTK_MENU(menu), SIZE_UNIT_KILOBYTES);
535 gtk_option_menu_set_menu(GTK_OPTION_MENU(unit_om), menu);
540 /* convert size value from raw to displayed (e.g. 1024 Bytes -> 1 KB) */
541 static guint32 size_unit_option_menu_set_value(
545 if(value >= 1024 * 1024) {
546 return value / (1024 * 1024);
551 return value / (1024);
558 /* get raw value from unit and value fields */
559 static guint32 size_unit_option_menu_convert_value(
563 GtkWidget *menu, *menu_item;
566 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(unit_om));
567 menu_item = gtk_menu_get_active(GTK_MENU(menu));
568 unit = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(menu_item), "size_unit"));
572 case(SIZE_UNIT_KILOBYTES):
574 case(SIZE_UNIT_MEGABYTES):
575 if(value > G_MAXINT / 1024) {
580 case(SIZE_UNIT_GIGABYTES):
581 if(value > G_MAXINT / (1024 * 1024)) {
584 return value * 1024 * 1024;
587 g_assert_not_reached();
594 * Sets the toolbar before calling the advanced dialog with for the right interface
597 options_airpcap_advanced_cb(GtkWidget *w _U_, gpointer d _U_)
601 from_widget = (gint*)g_malloc(sizeof(gint));
602 *from_widget = AIRPCAP_ADVANCED_FROM_OPTIONS;
603 g_object_set_data(G_OBJECT(airpcap_tb),AIRPCAP_ADVANCED_FROM_KEY,from_widget);
605 airpcap_if_active = airpcap_if_selected;
606 airpcap_enable_toolbar_widgets(airpcap_tb,FALSE);
607 display_airpcap_advanced_cb(w,d);
611 #ifdef HAVE_PCAP_REMOTE
612 /* PCAP interface type menu item */
618 /* List of available types of PCAP interface */
619 static struct iftype_info iftype[] = {
620 { CAPTURE_IFLOCAL, "Local" },
621 { CAPTURE_IFREMOTE, "Remote" }
624 /* Fill the menu of available types of interfaces */
626 iftype_option_menu_new(capture_source value)
628 GtkWidget *iftype_om, *menu, *menu_item;
629 unsigned int i, active = 0;
631 iftype_om = gtk_option_menu_new();
632 menu = gtk_menu_new();
634 for (i = 0; i < sizeof(iftype) / sizeof(iftype[0]); i++)
636 menu_item = gtk_menu_item_new_with_label(iftype[i].name);
637 g_object_set_data(G_OBJECT(menu_item), E_CAP_IFTYPE_OM_KEY, iftype_om);
638 g_signal_connect(menu_item, "activate", G_CALLBACK(select_if_type_cb),
639 GINT_TO_POINTER((int)iftype[i].id));
640 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
641 if (value == iftype[i].id)
645 gtk_menu_set_active(GTK_MENU(menu), active);
646 gtk_option_menu_set_menu(GTK_OPTION_MENU(iftype_om), menu);
651 /* Retrieve the list of local or remote interfaces according to selected
652 * options and re-fill inteface name combobox */
654 update_interface_list()
657 GList *if_list, *combo_list;
661 if (cap_open_w == NULL)
664 if_cb = (GtkWidget *)g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFACE_KEY);
666 if (global_capture_opts.src_type == CAPTURE_IFREMOTE)
667 if_list = get_remote_interface_list(global_capture_opts.remote_host,
668 global_capture_opts.remote_port,
669 global_capture_opts.auth_type,
670 global_capture_opts.auth_username,
671 global_capture_opts.auth_password,
674 if_list = get_interface_list(&err, &err_str);
676 if (if_list == NULL && err == CANT_GET_INTERFACE_LIST) {
677 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
680 gtk_combo_set_popdown_strings(GTK_COMBO(if_cb), NULL);
681 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry), "");
683 combo_list = build_capture_combo_list(if_list, TRUE);
684 if (combo_list != NULL)
685 gtk_combo_set_popdown_strings(GTK_COMBO(if_cb), combo_list);
687 free_capture_combo_list(combo_list);
688 free_interface_list(if_list);
691 /* User changed an interface entry of "Remote interface" dialog */
693 capture_remote_adjust_sensitivity(GtkWidget *tb _U_, gpointer parent_w)
695 GtkWidget *auth_passwd_rb,
696 *username_lb, *username_te,
697 *passwd_lb, *passwd_te;
700 auth_passwd_rb = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w),
701 E_REMOTE_AUTH_PASSWD_KEY);
702 username_lb = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w),
703 E_REMOTE_USERNAME_LB_KEY);
704 username_te = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w),
705 E_REMOTE_USERNAME_TE_KEY);
706 passwd_lb = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_REMOTE_PASSWD_LB_KEY);
707 passwd_te = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_REMOTE_PASSWD_TE_KEY);
709 state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(auth_passwd_rb));
710 gtk_widget_set_sensitive(GTK_WIDGET(username_lb), state);
711 gtk_widget_set_sensitive(GTK_WIDGET(username_te), state);
712 gtk_widget_set_sensitive(GTK_WIDGET(passwd_lb), state);
713 gtk_widget_set_sensitive(GTK_WIDGET(passwd_te), state);
716 /* user requested to destroy the dialog */
718 capture_remote_destroy_cb(GtkWidget *win, gpointer user_data _U_)
722 caller = g_object_get_data(G_OBJECT(win), E_CAP_REMOTE_CALLER_PTR_KEY);
723 g_object_set_data(G_OBJECT(caller), E_CAP_REMOTE_DIALOG_PTR_KEY, NULL);
726 /* user requested to accept remote interface options */
728 capture_remote_ok_cb(GtkWidget *win _U_, GtkWidget *remote_w)
730 GtkWidget *host_te, *port_te, *auth_pwd_rb, *username_te, *passwd_te,
731 *auth_null_rb, *auth_passwd_rb;
733 if (remote_w == NULL)
736 host_te = (GtkWidget *)g_object_get_data(G_OBJECT(remote_w), E_REMOTE_HOST_TE_KEY);
737 port_te = (GtkWidget *)g_object_get_data(G_OBJECT(remote_w), E_REMOTE_PORT_TE_KEY);
738 auth_pwd_rb = (GtkWidget *)g_object_get_data(G_OBJECT(remote_w),
739 E_REMOTE_AUTH_PASSWD_KEY);
740 username_te = (GtkWidget *)g_object_get_data(G_OBJECT(remote_w),
741 E_REMOTE_USERNAME_TE_KEY);
742 passwd_te = (GtkWidget *)g_object_get_data(G_OBJECT(remote_w), E_REMOTE_PASSWD_TE_KEY);
743 auth_null_rb = (GtkWidget *) g_object_get_data(G_OBJECT(remote_w), E_REMOTE_AUTH_NULL_KEY);
744 auth_passwd_rb = (GtkWidget *) g_object_get_data(G_OBJECT(remote_w), E_REMOTE_AUTH_PASSWD_KEY);
746 g_free(global_capture_opts.remote_host);
747 global_capture_opts.remote_host = g_strdup(gtk_entry_get_text(GTK_ENTRY(host_te)));
748 g_free(global_capture_opts.remote_port);
749 global_capture_opts.remote_port = g_strdup(gtk_entry_get_text(GTK_ENTRY(port_te)));
750 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(auth_passwd_rb)))
751 global_capture_opts.auth_type = CAPTURE_AUTH_PWD;
753 global_capture_opts.auth_type = CAPTURE_AUTH_NULL;
755 g_free(global_capture_opts.auth_username);
756 global_capture_opts.auth_username =
757 g_strdup(gtk_entry_get_text(GTK_ENTRY(username_te)));
759 g_free(global_capture_opts.auth_password);
760 global_capture_opts.auth_password =
761 g_strdup(gtk_entry_get_text(GTK_ENTRY(passwd_te)));
763 global_capture_opts.src_type = CAPTURE_IFREMOTE;
765 window_destroy(GTK_WIDGET(remote_w));
766 update_interface_list();
769 /* Show remote capture interface parameters dialog */
771 capture_remote_cb(GtkWidget *w _U_, gpointer d _U_)
773 GtkWidget *caller, *remote_w,
775 *host_lb, *host_te, *port_lb, *port_te,
777 *auth_null_rb, *auth_passwd_rb, *auth_passwd_tb,
778 *user_lb, *user_te, *passwd_lb, *passwd_te,
779 *bbox, *ok_bt, *cancel_bt;
781 GtkTooltips *tooltips;
784 caller = gtk_widget_get_toplevel(w);
785 remote_w = g_object_get_data(G_OBJECT(caller), E_CAP_REMOTE_DIALOG_PTR_KEY);
786 if (remote_w != NULL)
788 reactivate_window(remote_w);
792 title = create_user_window_title("Wireshark: Remote Interface");
793 remote_w = dlg_window_new(title);
794 g_object_set_data(G_OBJECT(remote_w), E_CAP_REMOTE_CALLER_PTR_KEY, caller);
795 g_object_set_data(G_OBJECT(caller), E_CAP_REMOTE_DIALOG_PTR_KEY, remote_w);
798 tooltips = gtk_tooltips_new();
800 main_vb = gtk_vbox_new(FALSE, 0);
801 gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);
802 gtk_container_add(GTK_CONTAINER(remote_w), main_vb);
804 /* Host/port table */
805 host_tb = gtk_table_new(2, 2, FALSE);
806 gtk_table_set_row_spacings(GTK_TABLE(host_tb), 3);
807 gtk_table_set_col_spacings(GTK_TABLE(host_tb), 3);
808 gtk_box_pack_start(GTK_BOX(main_vb), host_tb, FALSE, FALSE, 0);
811 host_lb = gtk_label_new("Host:");
812 gtk_table_attach_defaults(GTK_TABLE(host_tb), host_lb, 0, 1, 0, 1);
814 host_te = gtk_entry_new();
815 gtk_tooltips_set_tip(tooltips, host_te,
816 "Enter the hostname or host IP address to be used as a source "
817 "for remote capture.", NULL);
818 gtk_table_attach_defaults(GTK_TABLE(host_tb), host_te, 1, 2, 0, 1);
819 if (global_capture_opts.remote_host != NULL)
820 gtk_entry_set_text(GTK_ENTRY(host_te), global_capture_opts.remote_host);
823 port_lb = gtk_label_new("Port:");
824 gtk_table_attach_defaults(GTK_TABLE(host_tb), port_lb, 0, 1, 1, 2);
826 port_te = gtk_entry_new();
827 gtk_tooltips_set_tip(tooltips, port_te,
828 "Enter the TCP port number used by RPCAP server at remote host "
829 "(leave it empty for default port number).", NULL);
830 gtk_table_attach_defaults(GTK_TABLE(host_tb), port_te, 1, 2, 1, 2);
831 if (global_capture_opts.remote_port != NULL)
832 gtk_entry_set_text(GTK_ENTRY(port_te), global_capture_opts.remote_port);
834 /* Authentication options frame */
835 auth_fr = gtk_frame_new("Authentication");
836 gtk_container_add(GTK_CONTAINER(main_vb), auth_fr);
838 auth_vb = gtk_vbox_new(FALSE, 3);
839 gtk_container_set_border_width(GTK_CONTAINER(auth_vb), 5);
840 gtk_container_add(GTK_CONTAINER(auth_fr), auth_vb);
842 auth_null_rb = gtk_radio_button_new_with_label(NULL,
843 "Null authentication");
844 gtk_box_pack_start(GTK_BOX(auth_vb), auth_null_rb, TRUE, TRUE, 0);
846 auth_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(auth_null_rb));
847 auth_passwd_rb = gtk_radio_button_new_with_label(auth_group,
848 "Password authentication");
849 gtk_box_pack_start(GTK_BOX(auth_vb), auth_passwd_rb, TRUE, TRUE, 0);
850 g_signal_connect(auth_passwd_rb, "toggled",
851 G_CALLBACK(capture_remote_adjust_sensitivity), remote_w);
853 auth_passwd_tb = gtk_table_new(2, 2, FALSE);
854 gtk_table_set_row_spacings(GTK_TABLE(auth_passwd_tb), 3);
855 gtk_table_set_col_spacings(GTK_TABLE(auth_passwd_tb), 3);
856 gtk_box_pack_start(GTK_BOX(auth_vb), auth_passwd_tb, FALSE, FALSE, 0);
858 user_lb = gtk_label_new("Username:");
859 gtk_table_attach_defaults(GTK_TABLE(auth_passwd_tb), user_lb, 0, 1, 0, 1);
861 user_te = gtk_entry_new();
862 gtk_table_attach_defaults(GTK_TABLE(auth_passwd_tb), user_te, 1, 2, 0, 1);
863 if (global_capture_opts.auth_username != NULL)
864 gtk_entry_set_text(GTK_ENTRY(user_te), global_capture_opts.auth_username);
866 passwd_lb = gtk_label_new("Password:");
867 gtk_table_attach_defaults(GTK_TABLE(auth_passwd_tb), passwd_lb, 0, 1, 1, 2);
869 passwd_te = gtk_entry_new();
870 gtk_entry_set_visibility(GTK_ENTRY(passwd_te), FALSE);
871 gtk_table_attach_defaults(GTK_TABLE(auth_passwd_tb), passwd_te, 1, 2, 1, 2);
872 if (global_capture_opts.auth_password != NULL)
873 gtk_entry_set_text(GTK_ENTRY(passwd_te), global_capture_opts.auth_password);
875 /* Button row: "Start" and "Cancel" buttons */
876 bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL);
877 gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 5);
879 ok_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK);
880 g_signal_connect(ok_bt, "clicked", G_CALLBACK(capture_remote_ok_cb), remote_w);
881 gtk_tooltips_set_tip(tooltips, ok_bt,
882 "Accept remote host parameters and lookup "
883 "remote interfaces.", NULL);
885 cancel_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
886 gtk_tooltips_set_tip(tooltips, cancel_bt,
887 "Cancel and exit dialog.", NULL);
888 window_set_cancel_button(remote_w, cancel_bt, window_cancel_button_cb);
890 gtk_widget_grab_default(ok_bt);
892 g_signal_connect(remote_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
893 g_signal_connect(remote_w, "destroy", G_CALLBACK(capture_remote_destroy_cb), NULL);
895 g_object_set_data(G_OBJECT(remote_w), E_REMOTE_HOST_TE_KEY, host_te);
896 g_object_set_data(G_OBJECT(remote_w), E_REMOTE_PORT_TE_KEY, port_te);
897 g_object_set_data(G_OBJECT(remote_w), E_REMOTE_AUTH_NULL_KEY, auth_null_rb);
898 g_object_set_data(G_OBJECT(remote_w), E_REMOTE_AUTH_PASSWD_KEY, auth_passwd_rb);
899 g_object_set_data(G_OBJECT(remote_w), E_REMOTE_USERNAME_LB_KEY, user_lb);
900 g_object_set_data(G_OBJECT(remote_w), E_REMOTE_USERNAME_TE_KEY, user_te);
901 g_object_set_data(G_OBJECT(remote_w), E_REMOTE_PASSWD_LB_KEY, passwd_lb);
902 g_object_set_data(G_OBJECT(remote_w), E_REMOTE_PASSWD_TE_KEY, passwd_te);
904 if (global_capture_opts.auth_type == CAPTURE_AUTH_PWD)
905 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(auth_passwd_rb), TRUE);
907 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(auth_null_rb), TRUE);
908 capture_remote_adjust_sensitivity(NULL, remote_w);
910 gtk_widget_show_all(remote_w);
911 window_present(remote_w);
915 /* show capture prepare (options) dialog */
917 capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
920 *main_hb, *left_vb, *right_vb,
922 *capture_fr, *capture_vb,
923 *if_hb, *if_cb, *if_lb,
924 *if_ip_hb, *if_ip_lb, *if_ip_eb,
925 *linktype_hb, *linktype_lb, *linktype_om,
926 *snap_hb, *snap_cb, *snap_sb, *snap_lb,
928 *filter_hb, *filter_bt, *filter_te, *filter_cm,
931 *file_hb, *file_bt, *file_lb, *file_te,
932 *multi_tb, *multi_files_on_cb,
933 *ring_filesize_cb, *ring_filesize_sb, *ring_filesize_om,
934 *file_duration_cb, *file_duration_sb, *file_duration_om,
935 *ringbuffer_nbf_cb, *ringbuffer_nbf_sb, *ringbuffer_nbf_lb,
936 *stop_files_cb, *stop_files_sb, *stop_files_lb,
938 *limit_fr, *limit_vb, *limit_tb,
939 *stop_packets_cb, *stop_packets_sb, *stop_packets_lb,
940 *stop_filesize_cb, *stop_filesize_sb, *stop_filesize_om,
941 *stop_duration_cb, *stop_duration_sb, *stop_duration_om,
943 *display_fr, *display_vb,
944 *sync_cb, *auto_scroll_cb, *hide_info_cb,
946 *resolv_fr, *resolv_vb,
947 *m_resolv_cb, *n_resolv_cb, *t_resolv_cb,
948 *bbox, *ok_bt, *cancel_bt,
951 GtkWidget *advanced_hb, *advanced_bt;
953 #ifdef HAVE_PCAP_REMOTE
954 GtkWidget *iftype_om, *nocap_rpcap_cb, *datatx_udp_cb;
955 #ifdef HAVE_PCAP_SETSAMPLING
956 GtkWidget *sampling_fr, *sampling_vb, *sampling_tb, *sampling_lb,
957 *samp_none_rb, *samp_count_rb, *samp_timer_rb,
958 *samp_count_sb, *samp_timer_sb;
959 GtkAdjustment *samp_count_adj, *samp_timer_adj;
963 GtkTooltips *tooltips;
964 GtkAdjustment *snap_adj, *ringbuffer_nbf_adj,
965 *stop_packets_adj, *stop_filesize_adj, *stop_duration_adj, *stop_files_adj, *ring_filesize_adj, *file_duration_adj;
966 GList *if_list, *combo_list, *cfilter_list;
971 GtkAdjustment *buffer_size_adj;
972 GtkWidget *buffer_size_lb, *buffer_size_sb;
978 GtkWidget *decryption_cm;
981 if (cap_open_w != NULL) {
982 /* There's already a "Capture Options" dialog box; reactivate it. */
983 reactivate_window(cap_open_w);
988 /* Is WPcap loaded? */
992 detailed_err = cant_load_winpcap_err("Wireshark");
993 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", detailed_err);
994 g_free(detailed_err);
999 #ifdef HAVE_PCAP_REMOTE
1000 if (global_capture_opts.src_type == CAPTURE_IFREMOTE)
1001 if_list = get_remote_interface_list(global_capture_opts.remote_host,
1002 global_capture_opts.remote_port,
1003 global_capture_opts.auth_type,
1004 global_capture_opts.auth_username,
1005 global_capture_opts.auth_password,
1008 if_list = get_interface_list(&err, &err_str);
1010 if_list = capture_interface_list(&err, &err_str);
1012 if (if_list == NULL && err == CANT_GET_INTERFACE_LIST) {
1013 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
1018 /* update airpcap interface list */
1020 /* load the airpcap interfaces */
1021 airpcap_if_list = get_airpcap_interface_list(&err, &err_str);
1023 decryption_cm = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_DECRYPTION_KEY);
1024 update_decryption_mode_list(decryption_cm);
1026 if (airpcap_if_list == NULL && err == CANT_GET_AIRPCAP_INTERFACE_LIST) {
1027 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
1031 /* select the first ad default (THIS SHOULD BE CHANGED) */
1032 airpcap_if_active = airpcap_get_default_if(airpcap_if_list);
1035 /* use user-defined title if preference is set */
1036 cap_title = create_user_window_title("Wireshark: Capture Options");
1038 cap_open_w = dlg_window_new(cap_title);
1041 tooltips = gtk_tooltips_new();
1043 main_vb = gtk_vbox_new(FALSE, 0);
1044 gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);
1045 gtk_container_add(GTK_CONTAINER(cap_open_w), main_vb);
1047 /* Capture-related options frame */
1048 capture_fr = gtk_frame_new("Capture");
1049 gtk_container_add(GTK_CONTAINER(main_vb), capture_fr);
1051 capture_vb = gtk_vbox_new(FALSE, 3);
1052 gtk_container_set_border_width(GTK_CONTAINER(capture_vb), 5);
1053 gtk_container_add(GTK_CONTAINER(capture_fr), capture_vb);
1056 if_hb = gtk_hbox_new(FALSE, 3);
1057 gtk_container_add(GTK_CONTAINER(capture_vb), if_hb);
1059 if_lb = gtk_label_new("Interface:");
1060 gtk_box_pack_start(GTK_BOX(if_hb), if_lb, FALSE, FALSE, 6);
1062 #ifdef HAVE_PCAP_REMOTE
1063 iftype_om = iftype_option_menu_new(global_capture_opts.src_type);
1064 gtk_box_pack_start(GTK_BOX(if_hb), iftype_om, FALSE, FALSE, 0);
1067 if_cb = gtk_combo_new();
1068 combo_list = build_capture_combo_list(if_list, TRUE);
1069 if (combo_list != NULL)
1070 gtk_combo_set_popdown_strings(GTK_COMBO(if_cb), combo_list);
1071 if (global_capture_opts.iface == NULL && prefs.capture_device != NULL) {
1072 /* No interface was specified on the command line or in a previous
1073 capture, but there is one specified in the preferences file;
1074 make the one from the preferences file the default */
1075 if_device = g_strdup(prefs.capture_device);
1076 global_capture_opts.iface = g_strdup(get_if_name(if_device));
1077 global_capture_opts.iface_descr = get_interface_descriptive_name(global_capture_opts.iface);
1082 /* get the airpcap interface (if it IS an airpcap interface, and update the
1083 toolbar... and of course enable the advanced button...)*/
1084 airpcap_if_selected = get_airpcap_if_from_name(airpcap_if_list,global_capture_opts.iface);
1087 if (global_capture_opts.iface != NULL) {
1088 if_device = build_capture_combo_name(if_list, global_capture_opts.iface);
1089 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry), if_device);
1091 } else if (combo_list != NULL) {
1092 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry),
1093 (char *)combo_list->data);
1095 free_capture_combo_list(combo_list);
1096 free_interface_list(if_list);
1097 gtk_tooltips_set_tip(tooltips, GTK_COMBO(if_cb)->entry,
1098 "Choose which interface (network card) will be used to capture packets from. "
1099 "Be sure to select the correct one, as it's a common mistake to select the wrong interface.", NULL);
1100 gtk_box_pack_start(GTK_BOX(if_hb), if_cb, TRUE, TRUE, 6);
1102 if_ip_hb = gtk_hbox_new(FALSE, 3);
1103 gtk_box_pack_start(GTK_BOX(capture_vb), if_ip_hb, FALSE, FALSE, 0);
1105 if_ip_eb = gtk_event_box_new();
1106 gtk_event_box_set_visible_window (GTK_EVENT_BOX(if_ip_eb), FALSE);
1107 gtk_box_pack_start(GTK_BOX(if_ip_hb), if_ip_eb, TRUE, TRUE, 6);
1108 gtk_tooltips_set_tip(tooltips, if_ip_eb, "Lists the IP address(es) "
1109 "assigned to the selected interface. If there are "
1110 "more addresses than will fit in the window, the "
1111 "first few and the last few will be shown with \"...\" "
1115 if_ip_lb = gtk_label_new("");
1116 gtk_misc_set_alignment(GTK_MISC(if_ip_lb), 0, 0); /* Left justified */
1117 gtk_container_add(GTK_CONTAINER(if_ip_eb), if_ip_lb);
1120 linktype_hb = gtk_hbox_new(FALSE, 3);
1121 gtk_box_pack_start(GTK_BOX(capture_vb), linktype_hb, FALSE, FALSE, 0);
1123 linktype_lb = gtk_label_new("Link-layer header type:");
1124 gtk_box_pack_start(GTK_BOX(linktype_hb), linktype_lb, FALSE, FALSE, 6);
1126 linktype_om = gtk_option_menu_new();
1127 g_object_set_data(G_OBJECT(linktype_om), E_CAP_LT_OM_LABEL_KEY, linktype_lb);
1128 /* Default to "use the default" */
1129 /* Datalink menu index is not resetted, it will be restored with last used value */
1130 /* g_object_set_data(G_OBJECT(linktype_om), E_CAP_OM_LT_VALUE_KEY, GINT_TO_POINTER(-1)); */
1131 g_object_set_data(G_OBJECT(linktype_om), E_CAP_IFACE_KEY, if_ip_lb);
1133 if (linktype_history == NULL) {
1134 linktype_history = g_hash_table_new(g_str_hash, g_str_equal);
1136 set_link_type_list(linktype_om, GTK_COMBO(if_cb)->entry);
1138 * XXX - in some cases, this is "multiple link-layer header types", e.g.
1139 * some 802.11 interfaces on FreeBSD 5.2 and later, where you can request
1140 * fake Ethernet, 802.11, or 802.11-plus-radio-information headers.
1142 * In other cases, it's "multiple link-layer types", e.g., with recent
1143 * versions of libpcap, a DAG card on an "HDLC" WAN, where you can
1144 * request Cisco HDLC or PPP depending on what type of traffic is going
1145 * over the WAN, or an Ethernet interface, where you can request Ethernet
1146 * or DOCSIS, the latter being for some Cisco cable modem equipment that
1147 * can be configured to send raw DOCSIS frames over an Ethernet inside
1148 * Ethernet low-level framing, for traffic capture purposes.
1150 * We leave it as "multiple link-layer types" for now.
1152 gtk_tooltips_set_tip(tooltips, linktype_om,
1153 "The selected interface supports multiple link-layer types; select the desired one.", NULL);
1154 gtk_box_pack_start (GTK_BOX(linktype_hb), linktype_om, FALSE, FALSE, 0);
1155 g_signal_connect(GTK_ENTRY(GTK_COMBO(if_cb)->entry), "changed",
1156 G_CALLBACK(capture_prep_interface_changed_cb), linktype_om);
1159 buffer_size_lb = gtk_label_new("Buffer size:");
1160 gtk_box_pack_start (GTK_BOX(linktype_hb), buffer_size_lb, FALSE, FALSE, 0);
1162 buffer_size_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat) global_capture_opts.buffer_size,
1163 1, 65535, 1.0, 10.0, 0.0);
1164 buffer_size_sb = gtk_spin_button_new (buffer_size_adj, 0, 0);
1165 gtk_spin_button_set_value(GTK_SPIN_BUTTON (buffer_size_sb), (gfloat) global_capture_opts.buffer_size);
1166 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (buffer_size_sb), TRUE);
1167 gtk_widget_set_size_request(buffer_size_sb, 80, -1);
1168 gtk_tooltips_set_tip(tooltips, buffer_size_sb,
1169 "The memory buffer size used while capturing. If you notice packet drops, you can try to increase this size.", NULL);
1170 gtk_box_pack_start (GTK_BOX(linktype_hb), buffer_size_sb, FALSE, FALSE, 0);
1172 buffer_size_lb = gtk_label_new("megabyte(s)");
1173 gtk_box_pack_start (GTK_BOX(linktype_hb), buffer_size_lb, FALSE, FALSE, 6);
1176 /* Promiscuous mode row */
1177 promisc_cb = gtk_check_button_new_with_mnemonic(
1178 "Capture packets in _promiscuous mode");
1179 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(promisc_cb),
1180 global_capture_opts.promisc_mode);
1181 gtk_tooltips_set_tip(tooltips, promisc_cb,
1182 "Usually a network card will only capture the traffic sent to its own network address. "
1183 "If you want to capture all traffic that the network card can \"see\", mark this option. "
1184 "See the FAQ for some more details of capturing packets from a switched network.", NULL);
1185 gtk_container_add(GTK_CONTAINER(capture_vb), promisc_cb);
1187 #ifdef HAVE_PCAP_REMOTE
1188 /* RPCAP-related flags */
1189 nocap_rpcap_cb = gtk_check_button_new_with_mnemonic(
1190 "Do not capture RPCAP own traffic");
1191 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(nocap_rpcap_cb),
1192 global_capture_opts.nocap_rpcap);
1193 gtk_container_add(GTK_CONTAINER(capture_vb), nocap_rpcap_cb);
1195 datatx_udp_cb = gtk_check_button_new_with_mnemonic(
1196 "Use UDP for RPCAP data transfer");
1197 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(datatx_udp_cb),
1198 global_capture_opts.datatx_udp);
1199 gtk_container_add(GTK_CONTAINER(capture_vb), datatx_udp_cb);
1202 /* Capture length row */
1203 snap_hb = gtk_hbox_new(FALSE, 3);
1204 gtk_container_add(GTK_CONTAINER(capture_vb), snap_hb);
1206 snap_cb = gtk_check_button_new_with_mnemonic("_Limit each packet to");
1207 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(snap_cb),
1208 global_capture_opts.has_snaplen);
1209 g_signal_connect(snap_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1210 gtk_tooltips_set_tip(tooltips, snap_cb,
1211 "Limit the maximum number of bytes to be captured from each packet. This size includes the "
1212 "link-layer header and all subsequent headers. ", NULL);
1213 gtk_box_pack_start(GTK_BOX(snap_hb), snap_cb, FALSE, FALSE, 0);
1215 snap_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat) global_capture_opts.snaplen,
1216 MIN_PACKET_SIZE, WTAP_MAX_PACKET_SIZE, 1.0, 10.0, 0.0);
1217 snap_sb = gtk_spin_button_new (snap_adj, 0, 0);
1218 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (snap_sb), TRUE);
1219 gtk_widget_set_size_request(snap_sb, 80, -1);
1220 gtk_box_pack_start (GTK_BOX(snap_hb), snap_sb, FALSE, FALSE, 0);
1222 snap_lb = gtk_label_new("bytes");
1223 gtk_misc_set_alignment(GTK_MISC(snap_lb), 0, 0.5);
1224 gtk_box_pack_start(GTK_BOX(snap_hb), snap_lb, FALSE, FALSE, 0);
1227 filter_hb = gtk_hbox_new(FALSE, 3);
1228 gtk_box_pack_start(GTK_BOX(capture_vb), filter_hb, FALSE, FALSE, 0);
1230 filter_bt = gtk_button_new_from_stock(WIRESHARK_STOCK_CAPTURE_FILTER_ENTRY);
1231 g_signal_connect(filter_bt, "clicked", G_CALLBACK(capture_filter_construct_cb), NULL);
1232 g_signal_connect(filter_bt, "destroy", G_CALLBACK(filter_button_destroy_cb), NULL);
1233 gtk_tooltips_set_tip(tooltips, filter_bt,
1234 "Select a capture filter to reduce the amount of packets to be captured. "
1235 "See \"Capture Filters\" in the online help for further information how to use it.",
1237 gtk_box_pack_start(GTK_BOX(filter_hb), filter_bt, FALSE, FALSE, 3);
1239 /* Create the capture filter combo */
1240 filter_cm = gtk_combo_new();
1242 cfilter_list = g_object_get_data(G_OBJECT(top_level), E_CFILTER_FL_KEY);
1243 gtk_combo_disable_activate(GTK_COMBO(filter_cm));
1244 gtk_combo_set_case_sensitive(GTK_COMBO(filter_cm), TRUE);
1245 g_object_set_data(G_OBJECT(top_level), E_CFILTER_FL_KEY, cfilter_list);
1246 g_object_set_data(G_OBJECT(top_level), E_CFILTER_CM_KEY, filter_cm);
1247 filter_te = GTK_COMBO(filter_cm)->entry;
1249 if (cfilter_list != NULL)
1250 gtk_combo_set_popdown_strings(GTK_COMBO(filter_cm), cfilter_list);
1251 if (global_capture_opts.cfilter)
1252 gtk_entry_set_text(GTK_ENTRY(filter_te), global_capture_opts.cfilter);
1253 gtk_tooltips_set_tip(tooltips, filter_te,
1254 "Enter a capture filter to reduce the amount of packets to be captured. "
1255 "See \"Capture Filters\" in the online help for further information how to use it.",
1257 gtk_widget_set_size_request(filter_cm, 400, -1);
1258 gtk_box_pack_start(GTK_BOX(filter_hb), filter_cm, FALSE, FALSE, 3);
1259 main_hb = gtk_hbox_new(FALSE, 5);
1260 gtk_container_set_border_width(GTK_CONTAINER(main_hb), 0);
1261 gtk_container_add(GTK_CONTAINER(main_vb), main_hb);
1263 left_vb = gtk_vbox_new(FALSE, 0);
1264 gtk_container_set_border_width(GTK_CONTAINER(left_vb), 0);
1265 gtk_box_pack_start(GTK_BOX(main_hb), left_vb, TRUE, TRUE, 0);
1267 right_vb = gtk_vbox_new(FALSE, 0);
1268 gtk_container_set_border_width(GTK_CONTAINER(right_vb), 0);
1269 gtk_box_pack_start(GTK_BOX(main_hb), right_vb, FALSE, FALSE, 0);
1271 /* let an eventually capture filters dialog know the text entry to fill in */
1272 g_object_set_data(G_OBJECT(filter_bt), E_FILT_TE_PTR_KEY, filter_te);
1276 advanced_hb = gtk_hbox_new(FALSE,5);
1277 gtk_box_pack_start(GTK_BOX(capture_vb), advanced_hb, FALSE, FALSE, 0);
1279 advanced_bt = gtk_button_new_with_label("Wireless Settings");
1282 /* XXX - find a way to set the GtkButton label in GTK 2.x */
1283 gtk_button_set_label(GTK_BUTTON(advanced_bt), "Wireless Settings");
1285 /* Both the callback and the data are global */
1286 g_signal_connect(advanced_bt,"clicked", G_CALLBACK(options_airpcap_advanced_cb),airpcap_tb);
1287 g_object_set_data(G_OBJECT(GTK_ENTRY(GTK_COMBO(if_cb)->entry)),AIRPCAP_OPTIONS_ADVANCED_KEY,advanced_bt);
1289 if(airpcap_if_selected != NULL) {
1290 /* It is an airpcap interface */
1291 gtk_widget_set_sensitive(advanced_bt,TRUE);
1293 gtk_widget_set_sensitive(advanced_bt,FALSE);
1296 gtk_box_pack_start(GTK_BOX(linktype_hb),advanced_bt,FALSE,FALSE,0);
1297 gtk_widget_show(advanced_bt);
1298 gtk_widget_show(advanced_hb);
1301 /* Capture file-related options frame */
1302 file_fr = gtk_frame_new("Capture File(s)");
1303 gtk_container_add(GTK_CONTAINER(left_vb), file_fr);
1305 file_vb = gtk_vbox_new(FALSE, 3);
1306 gtk_container_set_border_width(GTK_CONTAINER(file_vb), 5);
1307 gtk_container_add(GTK_CONTAINER(file_fr), file_vb);
1310 file_hb = gtk_hbox_new(FALSE, 3);
1311 gtk_box_pack_start(GTK_BOX(file_vb), file_hb, FALSE, FALSE, 0);
1313 file_lb = gtk_label_new("File:");
1314 gtk_box_pack_start(GTK_BOX(file_hb), file_lb, FALSE, FALSE, 3);
1316 file_te = gtk_entry_new();
1317 gtk_tooltips_set_tip(tooltips, file_te,
1318 "Enter the file name to which captured data will be written. "
1319 "If you don't enter something here, a temporary file will be used.",
1321 gtk_box_pack_start(GTK_BOX(file_hb), file_te, TRUE, TRUE, 3);
1323 file_bt = gtk_button_new_from_stock(WIRESHARK_STOCK_BROWSE);
1324 gtk_tooltips_set_tip(tooltips, file_bt,
1325 "Select a file to which captured data will be written, "
1326 "instead of entering the file name directly. ",
1328 gtk_box_pack_start(GTK_BOX(file_hb), file_bt, FALSE, FALSE, 3);
1330 g_signal_connect(file_bt, "clicked", G_CALLBACK(capture_prep_file_cb), file_te);
1332 /* multiple files table */
1333 multi_tb = gtk_table_new(5, 3, FALSE);
1334 gtk_table_set_row_spacings(GTK_TABLE(multi_tb), 1);
1335 gtk_table_set_col_spacings(GTK_TABLE(multi_tb), 3);
1336 gtk_box_pack_start(GTK_BOX(file_vb), multi_tb, FALSE, FALSE, 0);
1339 /* multiple files row */
1340 multi_files_on_cb = gtk_check_button_new_with_mnemonic("Use _multiple files");
1341 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(multi_files_on_cb),
1342 global_capture_opts.multi_files_on);
1343 g_signal_connect(multi_files_on_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity),
1345 gtk_tooltips_set_tip(tooltips, multi_files_on_cb,
1346 "Instead of using a single capture file, multiple files will be created. "
1347 "The generated file names will contain an incrementing number and the start time of the capture.", NULL);
1348 gtk_table_attach_defaults(GTK_TABLE(multi_tb), multi_files_on_cb, 0, 1, row, row+1);
1351 /* Ring buffer filesize row */
1352 ring_filesize_cb = gtk_check_button_new_with_label("Next file every");
1353 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ring_filesize_cb),
1354 global_capture_opts.has_autostop_filesize || !global_capture_opts.has_file_duration);
1355 g_signal_connect(ring_filesize_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1356 gtk_tooltips_set_tip(tooltips, ring_filesize_cb,
1357 "If the selected file size is exceeded, capturing switches to the next file.\n"
1358 "PLEASE NOTE: at least one of the \"Next file every\" options MUST be selected.",
1360 gtk_table_attach_defaults(GTK_TABLE(multi_tb), ring_filesize_cb, 0, 1, row, row+1);
1362 ring_filesize_adj = (GtkAdjustment *) gtk_adjustment_new(0.0,
1363 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
1364 ring_filesize_sb = gtk_spin_button_new (ring_filesize_adj, 0, 0);
1365 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (ring_filesize_sb), TRUE);
1366 gtk_widget_set_size_request(ring_filesize_sb, 80, -1);
1367 gtk_table_attach_defaults(GTK_TABLE(multi_tb), ring_filesize_sb, 1, 2, row, row+1);
1369 ring_filesize_om = size_unit_option_menu_new(global_capture_opts.autostop_filesize);
1370 gtk_table_attach_defaults(GTK_TABLE(multi_tb), ring_filesize_om, 2, 3, row, row+1);
1372 value = size_unit_option_menu_set_value(global_capture_opts.autostop_filesize);
1373 gtk_adjustment_set_value(ring_filesize_adj, (gfloat) value);
1377 /* Ring buffer duration row */
1378 file_duration_cb = gtk_check_button_new_with_label("Next file every");
1379 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(file_duration_cb),
1380 global_capture_opts.has_file_duration);
1381 g_signal_connect(file_duration_cb, "toggled",
1382 G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1383 gtk_tooltips_set_tip(tooltips, file_duration_cb,
1384 "If the selected duration is exceeded, capturing switches to the next file.\n"
1385 "PLEASE NOTE: at least one of the \"Next file every\" options MUST be selected.",
1387 gtk_table_attach_defaults(GTK_TABLE(multi_tb), file_duration_cb, 0, 1, row, row+1);
1389 file_duration_adj = (GtkAdjustment *)gtk_adjustment_new(0.0,
1390 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
1391 file_duration_sb = gtk_spin_button_new (file_duration_adj, 0, 0);
1392 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (file_duration_sb), TRUE);
1393 gtk_widget_set_size_request(file_duration_sb, 80, -1);
1394 gtk_table_attach_defaults(GTK_TABLE(multi_tb), file_duration_sb, 1, 2, row, row+1);
1396 file_duration_om = time_unit_option_menu_new(global_capture_opts.file_duration);
1397 gtk_table_attach_defaults(GTK_TABLE(multi_tb), file_duration_om, 2, 3, row, row+1);
1399 value = time_unit_option_menu_convert_value(global_capture_opts.file_duration);
1400 gtk_adjustment_set_value(file_duration_adj, (gfloat) value);
1403 /* Ring buffer files row */
1404 ringbuffer_nbf_cb = gtk_check_button_new_with_label("Ring buffer with");
1405 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb),
1406 global_capture_opts.has_ring_num_files);
1407 g_signal_connect(ringbuffer_nbf_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1408 gtk_tooltips_set_tip(tooltips, ringbuffer_nbf_cb,
1409 "After capturing has switched to the next file and the given number of files has exceeded, "
1410 "the oldest file will be removed.",
1412 gtk_table_attach_defaults(GTK_TABLE(multi_tb), ringbuffer_nbf_cb, 0, 1, row, row+1);
1414 ringbuffer_nbf_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat) global_capture_opts.ring_num_files,
1415 2/*RINGBUFFER_MIN_NUM_FILES*/, RINGBUFFER_MAX_NUM_FILES, 1.0, 10.0, 0.0);
1416 ringbuffer_nbf_sb = gtk_spin_button_new (ringbuffer_nbf_adj, 0, 0);
1417 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (ringbuffer_nbf_sb), TRUE);
1418 gtk_widget_set_size_request(ringbuffer_nbf_sb, 80, -1);
1419 g_signal_connect(ringbuffer_nbf_sb, "changed", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1420 gtk_table_attach_defaults(GTK_TABLE(multi_tb), ringbuffer_nbf_sb, 1, 2, row, row+1);
1422 ringbuffer_nbf_lb = gtk_label_new("files");
1423 gtk_misc_set_alignment(GTK_MISC(ringbuffer_nbf_lb), 0, 0.5);
1424 gtk_table_attach_defaults(GTK_TABLE(multi_tb), ringbuffer_nbf_lb, 2, 3, row, row+1);
1428 stop_files_cb = gtk_check_button_new_with_label("Stop capture after");
1429 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stop_files_cb),
1430 global_capture_opts.has_autostop_files);
1431 g_signal_connect(stop_files_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1432 gtk_tooltips_set_tip(tooltips, stop_files_cb,
1433 "Stop capturing after the given number of \"file switches\" have been done.", NULL);
1434 gtk_table_attach_defaults(GTK_TABLE(multi_tb), stop_files_cb, 0, 1, row, row+1);
1436 stop_files_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat)global_capture_opts.autostop_files,
1437 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
1438 stop_files_sb = gtk_spin_button_new (stop_files_adj, 0, 0);
1439 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_files_sb), TRUE);
1440 gtk_widget_set_size_request(stop_files_sb, 80, -1);
1441 gtk_table_attach_defaults(GTK_TABLE(multi_tb), stop_files_sb, 1, 2, row, row+1);
1443 stop_files_lb = gtk_label_new("file(s)");
1444 gtk_misc_set_alignment(GTK_MISC(stop_files_lb), 0, 0.5);
1445 gtk_table_attach_defaults(GTK_TABLE(multi_tb), stop_files_lb, 2, 3, row, row+1);
1448 /* Capture limits frame */
1449 limit_fr = gtk_frame_new("Stop Capture ...");
1450 gtk_container_add(GTK_CONTAINER(left_vb), limit_fr);
1452 limit_vb = gtk_vbox_new(FALSE, 3);
1453 gtk_container_set_border_width(GTK_CONTAINER(limit_vb), 5);
1454 gtk_container_add(GTK_CONTAINER(limit_fr), limit_vb);
1457 limit_tb = gtk_table_new(3, 3, FALSE);
1458 gtk_table_set_row_spacings(GTK_TABLE(limit_tb), 1);
1459 gtk_table_set_col_spacings(GTK_TABLE(limit_tb), 3);
1460 gtk_box_pack_start(GTK_BOX(limit_vb), limit_tb, FALSE, FALSE, 0);
1463 /* Packet count row */
1464 stop_packets_cb = gtk_check_button_new_with_label("... after");
1465 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stop_packets_cb),
1466 global_capture_opts.has_autostop_packets);
1467 g_signal_connect(stop_packets_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1468 gtk_tooltips_set_tip(tooltips, stop_packets_cb,
1469 "Stop capturing after the given number of packets have been captured.", NULL);
1470 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_packets_cb, 0, 1, row, row+1);
1472 stop_packets_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat)global_capture_opts.autostop_packets,
1473 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
1474 stop_packets_sb = gtk_spin_button_new (stop_packets_adj, 0, 0);
1475 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_packets_sb), TRUE);
1476 gtk_widget_set_size_request(stop_packets_sb, 80, -1);
1477 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_packets_sb, 1, 2, row, row+1);
1479 stop_packets_lb = gtk_label_new("packet(s)");
1480 gtk_misc_set_alignment(GTK_MISC(stop_packets_lb), 0, 0.5);
1481 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_packets_lb, 2, 3, row, row+1);
1485 stop_filesize_cb = gtk_check_button_new_with_label("... after");
1486 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stop_filesize_cb),
1487 global_capture_opts.has_autostop_filesize);
1488 g_signal_connect(stop_filesize_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1489 gtk_tooltips_set_tip(tooltips, stop_filesize_cb,
1490 "Stop capturing after the given amount of capture data has been captured.", NULL);
1491 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_filesize_cb, 0, 1, row, row+1);
1493 stop_filesize_adj = (GtkAdjustment *) gtk_adjustment_new(0.0,
1494 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
1495 stop_filesize_sb = gtk_spin_button_new (stop_filesize_adj, 0, 0);
1496 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_filesize_sb), TRUE);
1497 gtk_widget_set_size_request(stop_filesize_sb, 80, -1);
1498 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_filesize_sb, 1, 2, row, row+1);
1500 stop_filesize_om = size_unit_option_menu_new(global_capture_opts.autostop_filesize);
1501 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_filesize_om, 2, 3, row, row+1);
1503 value = size_unit_option_menu_set_value(global_capture_opts.autostop_filesize);
1504 gtk_adjustment_set_value(stop_filesize_adj, (gfloat) value);
1509 stop_duration_cb = gtk_check_button_new_with_label("... after");
1510 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stop_duration_cb),
1511 global_capture_opts.has_autostop_duration);
1512 g_signal_connect(stop_duration_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1513 gtk_tooltips_set_tip(tooltips, stop_duration_cb,
1514 "Stop capturing after the given time is exceeded.", NULL);
1515 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_duration_cb, 0, 1, row, row+1);
1517 stop_duration_adj = (GtkAdjustment *) gtk_adjustment_new(0.0,
1518 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
1519 stop_duration_sb = gtk_spin_button_new (stop_duration_adj, 0, 0);
1520 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_duration_sb), TRUE);
1521 gtk_widget_set_size_request(stop_duration_sb, 80, -1);
1522 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_duration_sb, 1, 2, row, row+1);
1524 stop_duration_om = time_unit_option_menu_new(global_capture_opts.autostop_duration);
1525 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_duration_om, 2, 3, row, row+1);
1527 value = time_unit_option_menu_convert_value(global_capture_opts.autostop_duration);
1528 gtk_adjustment_set_value(stop_duration_adj, (gfloat) value);
1531 #ifdef HAVE_PCAP_SETSAMPLING
1532 /* Sampling options */
1533 sampling_fr = gtk_frame_new("Sampling Options");
1534 gtk_container_add(GTK_CONTAINER(right_vb), sampling_fr);
1536 sampling_vb = gtk_vbox_new(FALSE, 0);
1537 gtk_container_set_border_width(GTK_CONTAINER(sampling_vb), 5);
1538 gtk_container_add(GTK_CONTAINER(sampling_fr), sampling_vb);
1540 sampling_tb = gtk_table_new(3, 3, FALSE);
1541 gtk_table_set_row_spacings(GTK_TABLE(sampling_tb), 1);
1542 gtk_table_set_col_spacings(GTK_TABLE(sampling_tb), 3);
1543 gtk_box_pack_start(GTK_BOX(sampling_vb), sampling_tb, FALSE, FALSE, 0);
1545 /* "No sampling" row */
1546 samp_none_rb = gtk_radio_button_new_with_label(NULL, "None");
1547 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(samp_none_rb),
1548 (global_capture_opts.sampling_method == CAPTURE_SAMP_NONE));
1549 g_signal_connect(samp_none_rb, "toggled",
1550 G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1551 gtk_table_attach_defaults(GTK_TABLE(sampling_tb), samp_none_rb, 0, 1, 0, 1);
1553 /* "Sampling by counter" row */
1554 samp_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(samp_none_rb));
1555 samp_count_rb = gtk_radio_button_new_with_label(samp_group, "1 of");
1556 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(samp_none_rb),
1557 (global_capture_opts.sampling_method == CAPTURE_SAMP_BY_COUNT));
1558 g_signal_connect(samp_count_rb, "toggled",
1559 G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1560 gtk_table_attach_defaults(GTK_TABLE(sampling_tb), samp_count_rb, 0, 1, 1, 2);
1562 samp_count_adj = (GtkAdjustment *) gtk_adjustment_new(
1563 (gfloat)global_capture_opts.sampling_param,
1564 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
1565 samp_count_sb = gtk_spin_button_new(samp_count_adj, 0, 0);
1566 gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(samp_count_sb), TRUE);
1567 gtk_table_attach_defaults(GTK_TABLE(sampling_tb), samp_count_sb, 1, 2, 1, 2);
1569 sampling_lb = gtk_label_new("packets");
1570 gtk_misc_set_alignment(GTK_MISC(sampling_lb), 0, 0.5);
1571 gtk_table_attach_defaults(GTK_TABLE(sampling_tb), sampling_lb, 2, 3, 1, 2);
1573 /* "Sampling by timer" row */
1574 samp_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(samp_count_rb));
1575 samp_timer_rb = gtk_radio_button_new_with_label(samp_group, "1 every");
1576 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(samp_none_rb),
1577 (global_capture_opts.sampling_method == CAPTURE_SAMP_BY_TIMER));
1578 g_signal_connect(samp_timer_rb, "toggled",
1579 G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1580 gtk_table_attach_defaults(GTK_TABLE(sampling_tb), samp_timer_rb, 0, 1, 2, 3);
1582 samp_timer_adj = (GtkAdjustment *) gtk_adjustment_new(
1583 (gfloat)global_capture_opts.sampling_param,
1584 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
1585 samp_timer_sb = gtk_spin_button_new(samp_timer_adj, 0, 0);
1586 gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(samp_timer_sb), TRUE);
1587 gtk_table_attach_defaults(GTK_TABLE(sampling_tb), samp_timer_sb, 1, 2, 2, 3);
1589 sampling_lb = gtk_label_new("milliseconds");
1590 gtk_misc_set_alignment(GTK_MISC(sampling_lb), 0, 0.5);
1591 gtk_table_attach_defaults(GTK_TABLE(sampling_tb), sampling_lb, 2, 3, 2, 3);
1594 /* Display-related options frame */
1595 display_fr = gtk_frame_new("Display Options");
1596 gtk_container_add(GTK_CONTAINER(right_vb), display_fr);
1598 display_vb = gtk_vbox_new(FALSE, 0);
1599 gtk_container_set_border_width(GTK_CONTAINER(display_vb), 5);
1600 gtk_container_add(GTK_CONTAINER(display_fr), display_vb);
1602 /* "Update display in real time" row */
1603 sync_cb = gtk_check_button_new_with_mnemonic(
1604 "_Update list of packets in real time");
1605 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(sync_cb),
1606 global_capture_opts.real_time_mode);
1607 g_signal_connect(sync_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1608 gtk_tooltips_set_tip(tooltips, sync_cb,
1609 "Using this option will show the captured packets immediately on the main screen. "
1610 "Please note: this will slow down capturing, so increased packet drops might appear.", NULL);
1611 gtk_container_add(GTK_CONTAINER(display_vb), sync_cb);
1613 /* "Auto-scroll live update" row */
1614 auto_scroll_cb = gtk_check_button_new_with_mnemonic(
1615 "_Automatic scrolling in live capture");
1616 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(auto_scroll_cb), auto_scroll_live);
1617 gtk_tooltips_set_tip(tooltips, auto_scroll_cb,
1618 "This will scroll the \"Packet List\" automatically to the latest captured packet, "
1619 "when the \"Update List of packets in real time\" option is used.", NULL);
1620 gtk_container_add(GTK_CONTAINER(display_vb), auto_scroll_cb);
1622 /* "Hide capture info" row */
1623 hide_info_cb = gtk_check_button_new_with_mnemonic(
1624 "_Hide capture info dialog");
1625 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hide_info_cb), !global_capture_opts.show_info);
1626 gtk_tooltips_set_tip(tooltips, hide_info_cb,
1627 "Hide the capture info dialog while capturing.", NULL);
1628 gtk_container_add(GTK_CONTAINER(display_vb), hide_info_cb);
1630 /* Name Resolution frame */
1631 resolv_fr = gtk_frame_new("Name Resolution");
1632 gtk_container_add(GTK_CONTAINER(right_vb), resolv_fr);
1634 resolv_vb = gtk_vbox_new(FALSE, 0);
1635 gtk_container_set_border_width(GTK_CONTAINER(resolv_vb), 5);
1636 gtk_container_add(GTK_CONTAINER(resolv_fr), resolv_vb);
1638 m_resolv_cb = gtk_check_button_new_with_mnemonic(
1639 "Enable _MAC name resolution");
1640 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_resolv_cb),
1641 g_resolv_flags & RESOLV_MAC);
1642 gtk_tooltips_set_tip(tooltips, m_resolv_cb,
1643 "Perform MAC layer name resolution while capturing.", NULL);
1644 gtk_container_add(GTK_CONTAINER(resolv_vb), m_resolv_cb);
1646 n_resolv_cb = gtk_check_button_new_with_mnemonic(
1647 "Enable _network name resolution");
1648 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(n_resolv_cb),
1649 g_resolv_flags & RESOLV_NETWORK);
1650 gtk_tooltips_set_tip(tooltips, n_resolv_cb,
1651 "Perform network layer name resolution while capturing.", NULL);
1652 gtk_container_add(GTK_CONTAINER(resolv_vb), n_resolv_cb);
1654 t_resolv_cb = gtk_check_button_new_with_mnemonic(
1655 "Enable _transport name resolution");
1656 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(t_resolv_cb),
1657 g_resolv_flags & RESOLV_TRANSPORT);
1658 gtk_tooltips_set_tip(tooltips, t_resolv_cb,
1659 "Perform transport layer name resolution while capturing.", NULL);
1660 gtk_container_add(GTK_CONTAINER(resolv_vb), t_resolv_cb);
1662 /* Button row: "Start", "Cancel" and "Help" buttons */
1663 bbox = dlg_button_row_new(WIRESHARK_STOCK_CAPTURE_START, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL);
1664 gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 5);
1666 ok_bt = g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_CAPTURE_START);
1667 g_signal_connect(ok_bt, "clicked", G_CALLBACK(capture_start_cb), cap_open_w);
1668 gtk_tooltips_set_tip(tooltips, ok_bt,
1669 "Start the capture process.", NULL);
1671 cancel_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
1672 gtk_tooltips_set_tip(tooltips, cancel_bt,
1673 "Cancel and exit dialog.", NULL);
1674 window_set_cancel_button(cap_open_w, cancel_bt, window_cancel_button_cb);
1676 help_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
1677 gtk_tooltips_set_tip(tooltips, help_bt,
1678 "Show help about capturing.", NULL);
1679 g_signal_connect(help_bt, "clicked", G_CALLBACK(topic_cb), (gpointer)HELP_CAPTURE_OPTIONS_DIALOG);
1681 gtk_widget_grab_default(ok_bt);
1683 /* Attach pointers to needed widgets to the capture prefs window/object */
1684 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_IFACE_KEY, if_cb);
1685 #ifdef HAVE_PCAP_REMOTE
1686 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_IFTYPE_OM_KEY, iftype_om);
1687 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_REMOTE_DIALOG_PTR_KEY, NULL);
1688 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_NOCAP_RPCAP_CB_KEY, nocap_rpcap_cb);
1689 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_DATATX_UDP_CB_KEY, datatx_udp_cb);
1691 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_SNAP_CB_KEY, snap_cb);
1692 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_SNAP_SB_KEY, snap_sb);
1693 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_LT_OM_KEY, linktype_om);
1695 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_BUFFER_SIZE_SB_KEY, buffer_size_sb);
1697 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_PROMISC_KEY, promisc_cb);
1698 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_FILT_KEY, filter_te);
1699 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_FILE_TE_KEY, file_te);
1700 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_MULTI_FILES_ON_CB_KEY, multi_files_on_cb);
1701 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_RING_NBF_CB_KEY, ringbuffer_nbf_cb);
1702 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_RING_NBF_SB_KEY, ringbuffer_nbf_sb);
1703 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_RING_NBF_LB_KEY, ringbuffer_nbf_lb);
1704 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_RING_FILESIZE_CB_KEY, ring_filesize_cb);
1705 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_RING_FILESIZE_SB_KEY, ring_filesize_sb);
1706 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_RING_FILESIZE_OM_KEY, ring_filesize_om);
1707 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_FILE_DURATION_CB_KEY, file_duration_cb);
1708 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_FILE_DURATION_SB_KEY, file_duration_sb);
1709 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_FILE_DURATION_OM_KEY, file_duration_om);
1710 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_SYNC_KEY, sync_cb);
1711 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_AUTO_SCROLL_KEY, auto_scroll_cb);
1712 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_HIDE_INFO_KEY, hide_info_cb);
1713 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_PACKETS_CB_KEY, stop_packets_cb);
1714 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_PACKETS_SB_KEY, stop_packets_sb);
1715 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_PACKETS_LB_KEY, stop_packets_lb);
1716 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILESIZE_CB_KEY, stop_filesize_cb);
1717 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILESIZE_SB_KEY, stop_filesize_sb);
1718 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILESIZE_OM_KEY, stop_filesize_om);
1719 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_DURATION_CB_KEY, stop_duration_cb);
1720 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_DURATION_SB_KEY, stop_duration_sb);
1721 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_DURATION_OM_KEY, stop_duration_om);
1722 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILES_CB_KEY, stop_files_cb);
1723 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILES_SB_KEY, stop_files_sb);
1724 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILES_LB_KEY, stop_files_lb);
1725 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_M_RESOLVE_KEY, m_resolv_cb);
1726 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_N_RESOLVE_KEY, n_resolv_cb);
1727 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_T_RESOLVE_KEY, t_resolv_cb);
1728 #ifdef HAVE_PCAP_SETSAMPLING
1729 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_SAMP_NONE_RB_KEY, samp_none_rb);
1730 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_SAMP_COUNT_RB_KEY, samp_count_rb);
1731 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_SAMP_COUNT_SB_KEY, samp_count_sb);
1732 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_SAMP_TIMER_RB_KEY, samp_timer_rb);
1733 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_SAMP_TIMER_SB_KEY, samp_timer_sb);
1736 /* Set the sensitivity of various widgets as per the settings of other
1738 capture_prep_adjust_sensitivity(NULL, cap_open_w);
1740 /* Catch the "activate" signal on the text
1741 entries, so that if the user types Return there, we act as if the
1742 "OK" button had been selected, as happens if Return is typed if some
1743 widget that *doesn't* handle the Return key has the input focus. */
1744 dlg_set_activate(GTK_COMBO(if_cb)->entry, ok_bt);
1745 dlg_set_activate(filter_te, ok_bt);
1746 dlg_set_activate(file_te, ok_bt);
1748 /* XXX - why does not
1750 gtk_widget_grab_focus(if_cb);
1752 give the initial focus to the "Interface" combo box?
1754 Or should I phrase that as "why does GTK+ continually frustrate
1755 attempts to make GUIs driveable from the keyboard?" We have to
1756 go catch the activate signal on every single GtkEntry widget
1757 (rather than having widgets whose activate signal is *not*
1758 caught not catch the Return keystroke, so that it passes on,
1759 ultimately, to the window, which can activate the default
1760 widget, i.e. the "OK" button); we have to catch the "key_press_event"
1761 signal and have the handler check for ESC, so that we can have ESC
1762 activate the "Cancel" button; in order to support Alt+<key> mnemonics
1763 for buttons and the like, we may have to construct an accelerator
1764 group by hand and set up the accelerators by hand (if that even
1765 works - I've not tried it yet); we have to do a "gtk_widget_grab_focus()"
1766 to keep some container widget from getting the initial focus, so that
1767 you don't have to tab into the first widget in order to start typing
1768 in it; and it now appears that you simply *can't* make a combo box
1769 get the initial focus, at least not in the obvious fashion. Sigh.... */
1771 g_signal_connect(cap_open_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
1772 g_signal_connect(cap_open_w, "destroy", G_CALLBACK(capture_prep_destroy_cb), NULL);
1774 /* Give the initial focus to the "Filter" entry box. */
1775 gtk_widget_grab_focus(filter_te);
1777 gtk_widget_show_all(cap_open_w);
1778 window_present(cap_open_w);
1781 /* everythings prepared, now it's really time to start the capture */
1783 capture_start_confirmed(void)
1787 /* init iface, if never used before */
1788 /* XXX - would better be doing this in main.c */
1789 if(global_capture_opts.iface == NULL) {
1791 const gchar *if_name;
1793 /* did the user ever selected a capture interface before? */
1794 if(prefs.capture_device == NULL) {
1795 simple_dialog(ESD_TYPE_CONFIRMATION,
1797 "%sNo capture interface selected!%s\n\n"
1798 "To select an interface use:\n\n"
1799 "Capture->Options (until Wireshark is stopped)\n"
1800 "Edit->Preferences/Capture (permanent, if saved)",
1801 simple_dialog_primary_start(), simple_dialog_primary_end());
1804 if_device = g_strdup(prefs.capture_device);
1805 if_name = get_if_name(if_device);
1806 global_capture_opts.iface = g_strdup(if_name);
1807 global_capture_opts.iface_descr = get_interface_descriptive_name(global_capture_opts.iface);
1812 /* XXX - we might need to init other pref data as well... */
1813 menu_auto_scroll_live_changed(auto_scroll_live);
1815 if (capture_start(&global_capture_opts)) {
1816 /* The capture succeeded, which means the capture filter syntax is
1817 valid; add this capture filter to the recent capture filter list. */
1818 cfilter_combo_add_recent(global_capture_opts.cfilter);
1822 /* user confirmed the "Save capture file..." dialog */
1824 capture_start_answered_cb(gpointer dialog _U_, gint btn, gpointer data)
1828 /* save file first */
1829 file_save_as_cmd(after_save_capture_dialog, data);
1831 case(ESD_BTN_DONT_SAVE):
1832 /* XXX - unlink old file? */
1833 /* start the capture */
1834 capture_start_confirmed();
1836 case(ESD_BTN_CANCEL):
1839 g_assert_not_reached();
1843 /* user pressed the "Start" button (in dialog or toolbar) */
1845 capture_start_cb(GtkWidget *w _U_, gpointer d _U_)
1849 gint *linktype_p = NULL;
1852 airpcap_if_active = airpcap_if_selected;
1853 airpcap_set_toolbar_start_capture(airpcap_if_active);
1857 /* Is WPcap loaded? */
1859 char * err_msg = cant_load_winpcap_err("Wireshark");
1861 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, err_msg);
1869 * There's an options dialog; get the values from it and close it.
1873 success = capture_dlg_prep(cap_open_w);
1874 window_destroy(GTK_WIDGET(cap_open_w));
1876 return; /* error in options dialog */
1879 if (global_capture_opts.iface == NULL) {
1880 if (prefs.capture_device == NULL) {
1881 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
1882 "You didn't specify an interface on which to capture packets.");
1885 if_name = g_strdup(get_if_name(prefs.capture_device));
1887 if_name = g_strdup(global_capture_opts.iface);
1890 if (linktype_history != NULL) {
1891 linktype_p = g_hash_table_lookup(linktype_history, if_name);
1892 if (linktype_p == NULL) {
1893 linktype_p = g_malloc(sizeof (int));
1894 g_hash_table_insert(linktype_history, if_name, linktype_p);
1898 *linktype_p = global_capture_opts.linktype;
1900 global_capture_opts.linktype = capture_dev_user_linktype_find(if_name);
1904 if((cfile.state != FILE_CLOSED) && !cfile.user_saved && prefs.gui_ask_unsaved) {
1905 /* user didn't saved his current file, ask him */
1906 dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_SAVE_DONTSAVE_CANCEL,
1907 "%sSave capture file before starting a new capture?%s\n\n"
1908 "If you start a new capture without saving, your current capture data will\nbe discarded.",
1909 simple_dialog_primary_start(), simple_dialog_primary_end());
1910 simple_dialog_set_cb(dialog, capture_start_answered_cb, NULL);
1912 /* unchanged file, just capture a new one */
1913 capture_start_confirmed();
1917 /* user selected a link type, convert to internal value */
1919 select_link_type_cb(GtkWidget *w, gpointer data)
1921 int new_linktype = GPOINTER_TO_INT(data);
1922 GtkWidget *linktype_om = g_object_get_data(G_OBJECT(w), E_CAP_LT_OM_KEY);
1923 int old_linktype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(linktype_om), E_CAP_OM_LT_VALUE_KEY));
1925 /* If the link is changed, update the menu and store the index and the value
1926 to reuse later when the dialog window will be reopened */
1927 if (old_linktype != new_linktype) {
1928 g_object_set_data(G_OBJECT(linktype_om), E_CAP_OM_LT_VALUE_KEY, GINT_TO_POINTER(new_linktype));
1929 global_capture_opts.linktype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(linktype_om), E_CAP_OM_LT_VALUE_KEY));
1933 #ifdef HAVE_PCAP_REMOTE
1934 /* user selected an interface type (local/remote), convert to internal value) */
1936 select_if_type_cb(GtkWidget *w, gpointer data)
1938 int new_iftype = GPOINTER_TO_INT(data);
1939 GtkWidget *iftype_om = g_object_get_data(G_OBJECT(w), E_CAP_IFTYPE_OM_KEY);
1940 int old_iftype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(iftype_om),
1941 E_CAP_OM_IFTYPE_VALUE_KEY));
1943 if (old_iftype != new_iftype)
1945 g_object_set_data(G_OBJECT(iftype_om), E_CAP_OM_IFTYPE_VALUE_KEY,
1946 GINT_TO_POINTER(new_iftype));
1948 if (new_iftype == CAPTURE_IFREMOTE)
1950 capture_remote_cb(iftype_om, NULL);
1952 else if (new_iftype != old_iftype)
1954 global_capture_opts.src_type = CAPTURE_IFLOCAL;
1955 update_interface_list();
1960 /* user pressed "File" button */
1962 capture_prep_file_cb(GtkWidget *file_bt, GtkWidget *file_te)
1964 file_selection_browse(file_bt, file_te, "Wireshark: Specify a Capture File", FILE_SELECTION_WRITE_BROWSE);
1968 /* convert dialog settings into capture_opts values */
1970 capture_dlg_prep(gpointer parent_w) {
1971 GtkWidget *if_cb, *snap_cb, *snap_sb, *promisc_cb, *filter_te, *filter_cm,
1972 *file_te, *multi_files_on_cb, *ringbuffer_nbf_sb, *ringbuffer_nbf_cb,
1973 *linktype_om, *sync_cb, *auto_scroll_cb, *hide_info_cb,
1974 *stop_packets_cb, *stop_packets_sb,
1975 *stop_filesize_cb, *stop_filesize_sb, *stop_filesize_om,
1976 *stop_duration_cb, *stop_duration_sb, *stop_duration_om,
1977 *ring_filesize_cb, *ring_filesize_sb, *ring_filesize_om,
1978 *file_duration_cb, *file_duration_sb, *file_duration_om,
1979 *stop_files_cb, *stop_files_sb,
1980 *m_resolv_cb, *n_resolv_cb, *t_resolv_cb;
1981 #ifdef HAVE_PCAP_REMOTE
1982 GtkWidget *iftype_om, *datatx_udp_cb, *nocap_rpcap_cb;
1984 #ifdef HAVE_PCAP_SETSAMPLING
1985 GtkWidget *samp_none_rb, *samp_count_rb, *samp_timer_rb,
1986 *samp_count_sb, *samp_timer_sb;
1989 GtkWidget *buffer_size_sb;
1993 const gchar *if_name;
1994 const gchar *filter_text;
1995 const gchar *g_save_file;
2000 if_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_IFACE_KEY);
2001 #ifdef HAVE_PCAP_REMOTE
2002 iftype_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_IFTYPE_OM_KEY);
2003 datatx_udp_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_DATATX_UDP_CB_KEY);
2004 nocap_rpcap_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_NOCAP_RPCAP_CB_KEY);
2006 snap_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SNAP_CB_KEY);
2007 snap_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SNAP_SB_KEY);
2008 linktype_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_LT_OM_KEY);
2010 buffer_size_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_BUFFER_SIZE_SB_KEY);
2012 promisc_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_PROMISC_KEY);
2013 filter_cm = g_object_get_data(G_OBJECT(top_level), E_CFILTER_CM_KEY);
2014 filter_te = GTK_COMBO(filter_cm)->entry;
2015 file_te = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_TE_KEY);
2016 multi_files_on_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_MULTI_FILES_ON_CB_KEY);
2017 ringbuffer_nbf_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_NBF_CB_KEY);
2018 ringbuffer_nbf_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_NBF_SB_KEY);
2019 ring_filesize_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_CB_KEY);
2020 ring_filesize_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_SB_KEY);
2021 ring_filesize_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_OM_KEY);
2022 file_duration_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_DURATION_CB_KEY);
2023 file_duration_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_DURATION_SB_KEY);
2024 file_duration_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_DURATION_OM_KEY);
2025 sync_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SYNC_KEY);
2026 auto_scroll_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_AUTO_SCROLL_KEY);
2027 hide_info_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_HIDE_INFO_KEY);
2028 stop_packets_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_PACKETS_CB_KEY);
2029 stop_packets_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_PACKETS_SB_KEY);
2030 stop_filesize_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_CB_KEY);
2031 stop_filesize_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_SB_KEY);
2032 stop_filesize_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_OM_KEY);
2033 stop_duration_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_CB_KEY);
2034 stop_duration_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_SB_KEY);
2035 stop_duration_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_OM_KEY);
2036 stop_files_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILES_CB_KEY);
2037 stop_files_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILES_SB_KEY);
2038 m_resolv_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_M_RESOLVE_KEY);
2039 n_resolv_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_N_RESOLVE_KEY);
2040 t_resolv_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_T_RESOLVE_KEY);
2041 #ifdef HAVE_PCAP_SETSAMPLING
2042 samp_none_rb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_NONE_RB_KEY);
2043 samp_count_rb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_COUNT_RB_KEY);
2044 samp_timer_rb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_TIMER_RB_KEY);
2045 samp_count_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_COUNT_SB_KEY);
2046 samp_timer_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_TIMER_SB_KEY);
2050 g_strdup(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry)));
2051 if_text = g_strstrip(entry_text);
2052 if_name = get_if_name(if_text);
2053 if (*if_name == '\0') {
2054 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
2055 "You didn't specify an interface on which to capture packets.");
2059 if (global_capture_opts.iface)
2060 g_free(global_capture_opts.iface);
2061 if (global_capture_opts.iface_descr)
2062 g_free(global_capture_opts.iface_descr);
2063 global_capture_opts.iface = g_strdup(if_name);
2064 global_capture_opts.iface_descr = get_interface_descriptive_name(global_capture_opts.iface);
2066 /* The Linktype will be stored when the interface will be changed, or if not, not datalink option is used,
2067 the acquisition will be performed on the default datalink for the device */
2068 /* global_capture_opts.linktype =
2069 GPOINTER_TO_INT(g_object_get_data(G_OBJECT(linktype_om), E_CAP_OM_LT_VALUE_KEY)); */
2071 #ifdef HAVE_PCAP_REMOTE
2072 global_capture_opts.src_type = (capture_source)
2073 GPOINTER_TO_INT(g_object_get_data(G_OBJECT(iftype_om), E_CAP_OM_IFTYPE_VALUE_KEY));
2074 global_capture_opts.datatx_udp =
2075 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(datatx_udp_cb));
2076 global_capture_opts.nocap_rpcap =
2077 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(nocap_rpcap_cb));
2079 #ifdef HAVE_PCAP_SETSAMPLING
2080 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(samp_none_rb)))
2081 global_capture_opts.sampling_method = CAPTURE_SAMP_NONE;
2082 else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(samp_count_rb)))
2084 global_capture_opts.sampling_method = CAPTURE_SAMP_BY_COUNT;
2085 global_capture_opts.sampling_param = gtk_spin_button_get_value_as_int(
2086 GTK_SPIN_BUTTON(samp_count_sb));
2088 else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(samp_timer_rb)))
2090 global_capture_opts.sampling_method = CAPTURE_SAMP_BY_TIMER;
2091 global_capture_opts.sampling_param = gtk_spin_button_get_value_as_int(
2092 GTK_SPIN_BUTTON(samp_timer_sb));
2097 global_capture_opts.buffer_size =
2098 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(buffer_size_sb));
2101 global_capture_opts.has_snaplen =
2102 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(snap_cb));
2103 if (global_capture_opts.has_snaplen) {
2104 global_capture_opts.snaplen =
2105 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(snap_sb));
2106 if (global_capture_opts.snaplen < 1)
2107 global_capture_opts.snaplen = WTAP_MAX_PACKET_SIZE;
2108 else if (global_capture_opts.snaplen < MIN_PACKET_SIZE)
2109 global_capture_opts.snaplen = MIN_PACKET_SIZE;
2112 global_capture_opts.promisc_mode =
2113 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(promisc_cb));
2115 /* XXX - don't try to get clever and set "cfile.filter" to NULL if the
2116 filter string is empty, as an indication that we don't have a filter
2117 and thus don't have to set a filter when capturing - the version of
2118 libpcap in Red Hat Linux 6.1, and versions based on later patches
2119 in that series, don't bind the AF_PACKET socket to an interface
2120 until a filter is set, which means they aren't bound at all if
2121 no filter is set, which means no packets arrive as input on that
2122 socket, which means Wireshark never sees any packets. */
2123 filter_text = gtk_entry_get_text(GTK_ENTRY(filter_te));
2124 if (global_capture_opts.cfilter)
2125 g_free(global_capture_opts.cfilter);
2126 g_assert(filter_text != NULL);
2127 global_capture_opts.cfilter = g_strdup(filter_text);
2129 /* Wireshark always saves to a capture file. */
2130 global_capture_opts.saving_to_file = TRUE;
2131 g_save_file = gtk_entry_get_text(GTK_ENTRY(file_te));
2132 if (g_save_file && g_save_file[0]) {
2133 /* User specified a file to which the capture should be written. */
2134 global_capture_opts.save_file = g_strdup(g_save_file);
2135 /* Save the directory name for future file dialogs. */
2136 cf_name = g_strdup(g_save_file);
2137 dirname = get_dirname(cf_name); /* Overwrites cf_name */
2138 set_last_open_dir(dirname);
2141 /* User didn't specify a file; save to a temporary file. */
2142 global_capture_opts.save_file = NULL;
2145 global_capture_opts.has_autostop_packets =
2146 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_packets_cb));
2147 if (global_capture_opts.has_autostop_packets)
2148 global_capture_opts.autostop_packets =
2149 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_packets_sb));
2151 global_capture_opts.has_autostop_duration =
2152 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_duration_cb));
2153 if (global_capture_opts.has_autostop_duration) {
2154 global_capture_opts.autostop_duration =
2155 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_duration_sb));
2156 global_capture_opts.autostop_duration =
2157 time_unit_option_menu_get_value(stop_duration_om, global_capture_opts.autostop_duration);
2160 global_capture_opts.real_time_mode =
2161 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sync_cb));
2164 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(auto_scroll_cb));
2166 global_capture_opts.show_info =
2167 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hide_info_cb));
2169 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_resolv_cb)))
2170 g_resolv_flags |= RESOLV_MAC;
2172 g_resolv_flags &= ~RESOLV_MAC;
2173 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(n_resolv_cb)))
2174 g_resolv_flags |= RESOLV_NETWORK;
2176 g_resolv_flags &= ~RESOLV_NETWORK;
2177 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(t_resolv_cb)))
2178 g_resolv_flags |= RESOLV_TRANSPORT;
2180 g_resolv_flags &= ~RESOLV_TRANSPORT;
2182 global_capture_opts.has_ring_num_files =
2183 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb));
2185 global_capture_opts.ring_num_files =
2186 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ringbuffer_nbf_sb));
2187 if (global_capture_opts.ring_num_files > RINGBUFFER_MAX_NUM_FILES)
2188 global_capture_opts.ring_num_files = RINGBUFFER_MAX_NUM_FILES;
2189 #if RINGBUFFER_MIN_NUM_FILES > 0
2190 else if (global_capture_opts.ring_num_files < RINGBUFFER_MIN_NUM_FILES)
2191 global_capture_opts.ring_num_files = RINGBUFFER_MIN_NUM_FILES;
2194 global_capture_opts.multi_files_on =
2195 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(multi_files_on_cb));
2197 global_capture_opts.has_file_duration =
2198 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_duration_cb));
2199 if (global_capture_opts.has_file_duration) {
2200 global_capture_opts.file_duration =
2201 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(file_duration_sb));
2202 global_capture_opts.file_duration =
2203 time_unit_option_menu_get_value(file_duration_om, global_capture_opts.file_duration);
2206 global_capture_opts.has_autostop_files =
2207 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_files_cb));
2208 if (global_capture_opts.has_autostop_files)
2209 global_capture_opts.autostop_files =
2210 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_files_sb));
2212 if (global_capture_opts.multi_files_on) {
2213 global_capture_opts.has_autostop_filesize =
2214 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb));
2215 if (global_capture_opts.has_autostop_filesize) {
2216 tmp = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ring_filesize_sb));
2217 tmp = size_unit_option_menu_convert_value(ring_filesize_om, tmp);
2219 global_capture_opts.autostop_filesize = tmp;
2221 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
2222 "%sMultiple files: Requested filesize too large!%s\n\n"
2223 "The setting \"Next file every x byte(s)\" can't be greater than %u bytes (2GB).",
2224 simple_dialog_primary_start(), simple_dialog_primary_end(), G_MAXINT);
2229 /* test if the settings are ok for a ringbuffer */
2230 if (global_capture_opts.save_file == NULL) {
2231 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
2232 "%sMultiple files: No capture file name given!%s\n\n"
2233 "You must specify a filename if you want to use multiple files.",
2234 simple_dialog_primary_start(), simple_dialog_primary_end());
2236 } else if (!global_capture_opts.has_autostop_filesize && !global_capture_opts.has_file_duration) {
2237 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
2238 "%sMultiple files: No file limit given!%s\n\n"
2239 "You must specify a file size or duration at which is switched to the next capture file\n"
2240 "if you want to use multiple files.",
2241 simple_dialog_primary_start(), simple_dialog_primary_end());
2242 g_free(global_capture_opts.save_file);
2243 global_capture_opts.save_file = NULL;
2247 global_capture_opts.has_autostop_filesize =
2248 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_filesize_cb));
2249 if (global_capture_opts.has_autostop_filesize) {
2250 tmp = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_filesize_sb));
2251 tmp = size_unit_option_menu_convert_value(stop_filesize_om, tmp);
2253 global_capture_opts.autostop_filesize = tmp;
2255 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
2256 "%sStop Capture: Requested filesize too large!%s\n\n"
2257 "The setting \"... after x byte(s)\" can't be greater than %u bytes (2GB).",
2258 simple_dialog_primary_start(), simple_dialog_primary_end(), G_MAXINT);
2262 } /* multi_files_on */
2266 /* user requested to destroy the dialog */
2268 capture_prep_destroy_cb(GtkWidget *win, gpointer user_data _U_)
2271 #ifdef HAVE_PCAP_REMOTE
2272 GtkWidget *remote_w;
2275 /* Is there a file selection dialog associated with this
2276 Capture Options dialog? */
2277 fs = g_object_get_data(G_OBJECT(win), E_FILE_SEL_DIALOG_PTR_KEY);
2280 /* Yes. Destroy it. */
2284 /* Note that we no longer have a "Capture Options" dialog box. */
2288 /* update airpcap toolbar */
2289 airpcap_set_toolbar_stop_capture(airpcap_if_active);
2292 #ifdef HAVE_PCAP_REMOTE
2293 remote_w = g_object_get_data(G_OBJECT(win), E_CAP_REMOTE_DIALOG_PTR_KEY);
2294 if (remote_w != NULL)
2295 window_destroy(remote_w);
2299 /* user changed the interface entry */
2301 capture_prep_interface_changed_cb(GtkWidget *entry, gpointer argp)
2303 GtkWidget *linktype_om = argp;
2305 set_link_type_list(linktype_om, entry);
2309 * Adjust the sensitivity of various widgets as per the current setting
2313 capture_prep_adjust_sensitivity(GtkWidget *tb _U_, gpointer parent_w)
2317 *multi_files_on_cb, *ringbuffer_nbf_cb, *ringbuffer_nbf_sb, *ringbuffer_nbf_lb,
2318 *ring_filesize_cb, *ring_filesize_sb, *ring_filesize_om,
2319 *file_duration_cb, *file_duration_sb, *file_duration_om,
2320 *sync_cb, *auto_scroll_cb, *hide_info_cb,
2321 *stop_packets_cb, *stop_packets_sb, *stop_packets_lb,
2322 *stop_filesize_cb, *stop_filesize_sb, *stop_filesize_om,
2323 *stop_duration_cb, *stop_duration_sb, *stop_duration_om,
2324 *stop_files_cb, *stop_files_sb, *stop_files_lb;
2325 #ifdef HAVE_PCAP_SETSAMPLING
2326 GtkWidget *samp_count_rb, *samp_timer_rb,
2327 *samp_count_sb, *samp_timer_sb;
2331 if_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_IFACE_KEY);
2332 snap_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SNAP_CB_KEY);
2333 snap_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SNAP_SB_KEY);
2334 multi_files_on_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_MULTI_FILES_ON_CB_KEY);
2335 ringbuffer_nbf_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_NBF_CB_KEY);
2336 ringbuffer_nbf_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_NBF_SB_KEY);
2337 ringbuffer_nbf_lb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_NBF_LB_KEY);
2338 ring_filesize_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_CB_KEY);
2339 ring_filesize_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_SB_KEY);
2340 ring_filesize_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_OM_KEY);
2341 file_duration_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_DURATION_CB_KEY);
2342 file_duration_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_DURATION_SB_KEY);
2343 file_duration_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_DURATION_OM_KEY);
2344 sync_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SYNC_KEY);
2345 auto_scroll_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_AUTO_SCROLL_KEY);
2346 hide_info_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_HIDE_INFO_KEY);
2347 stop_packets_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_PACKETS_CB_KEY);
2348 stop_packets_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_PACKETS_SB_KEY);
2349 stop_packets_lb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_PACKETS_LB_KEY);
2350 stop_filesize_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_CB_KEY);
2351 stop_filesize_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_SB_KEY);
2352 stop_filesize_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_OM_KEY);
2353 stop_duration_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_CB_KEY);
2354 stop_duration_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_SB_KEY);
2355 stop_duration_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_OM_KEY);
2356 stop_files_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILES_CB_KEY);
2357 stop_files_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILES_SB_KEY);
2358 stop_files_lb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILES_LB_KEY);
2359 #ifdef HAVE_PCAP_SETSAMPLING
2360 samp_count_rb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_COUNT_RB_KEY);
2361 samp_timer_rb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_TIMER_RB_KEY);
2362 samp_count_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_COUNT_SB_KEY);
2363 samp_timer_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_TIMER_SB_KEY);
2366 /* The snapshot length spinbox is sensitive if the "Limit each packet
2367 to" checkbox is on. */
2368 gtk_widget_set_sensitive(GTK_WIDGET(snap_sb),
2369 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(snap_cb)));
2372 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sync_cb))) {
2373 /* "Update list of packets in real time" captures enabled; we don't
2374 support ring buffer mode for those captures, so turn ring buffer
2375 mode off if it's on, and make its toggle button, and the spin
2376 button for the number of ring buffer files (and the spin button's
2377 label), insensitive. */
2378 /* gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(multi_files_on_cb), FALSE);
2379 gtk_widget_set_sensitive(GTK_WIDGET(multi_files_on_cb), FALSE);*/
2381 /* Auto-scroll mode is meaningful only in "Update list of packets
2382 in real time" captures, so make its toggle button sensitive. */
2383 gtk_widget_set_sensitive(GTK_WIDGET(auto_scroll_cb), TRUE);
2385 /*gtk_widget_set_sensitive(GTK_WIDGET(hide_info_cb), TRUE);*/
2387 /* "Update list of packets in real time" captures disabled; that
2388 means ring buffer mode is OK, so make its toggle button
2390 /* gtk_widget_set_sensitive(GTK_WIDGET(multi_files_on_cb), TRUE);*/
2392 /* Auto-scroll mode is meaningful only in "Update list of packets
2393 in real time" captures, so make its toggle button insensitive. */
2394 gtk_widget_set_sensitive(GTK_WIDGET(auto_scroll_cb), FALSE);
2396 /*gtk_widget_set_sensitive(GTK_WIDGET(hide_info_cb), FALSE);*/
2399 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(multi_files_on_cb))) {
2400 /* Ring buffer mode enabled. */
2402 /* Force at least one of the "file switch" conditions (we need at least one) */
2403 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb)) == FALSE &&
2404 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_duration_cb)) == FALSE) {
2405 if (tb == ring_filesize_cb)
2406 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(file_duration_cb), TRUE);
2408 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ring_filesize_cb), TRUE);
2411 gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_cb), TRUE);
2412 gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_sb),
2413 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb)));
2414 gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_lb),
2415 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb)));
2417 /* The ring filesize spinbox is sensitive if the "Next capture file
2418 after N kilobytes" checkbox is on. */
2419 gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_cb), TRUE);
2420 gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_sb),
2421 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb)));
2422 gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_om),
2423 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb)));
2425 /* The ring duration spinbox is sensitive if the "Next capture file
2426 after N seconds" checkbox is on. */
2427 gtk_widget_set_sensitive(GTK_WIDGET(file_duration_cb), TRUE);
2428 gtk_widget_set_sensitive(GTK_WIDGET(file_duration_sb),
2429 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_duration_cb)));
2430 gtk_widget_set_sensitive(GTK_WIDGET(file_duration_om),
2431 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_duration_cb)));
2433 gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_cb), FALSE);
2434 gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_sb), FALSE);
2435 gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_om), FALSE);
2437 gtk_widget_set_sensitive(GTK_WIDGET(stop_files_cb), TRUE);
2438 gtk_widget_set_sensitive(GTK_WIDGET(stop_files_sb),
2439 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_files_cb)));
2440 gtk_widget_set_sensitive(GTK_WIDGET(stop_files_lb),
2441 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_files_cb)));
2443 /* Ring buffer mode disabled. */
2444 gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_cb), FALSE);
2445 gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_sb), FALSE);
2446 gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_lb), FALSE);
2448 gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_cb), FALSE);
2449 gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_sb),FALSE);
2450 gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_om),FALSE);
2452 gtk_widget_set_sensitive(GTK_WIDGET(file_duration_cb), FALSE);
2453 gtk_widget_set_sensitive(GTK_WIDGET(file_duration_sb),FALSE);
2454 gtk_widget_set_sensitive(GTK_WIDGET(file_duration_om),FALSE);
2456 /* The maximum file size spinbox is sensitive if the "Stop capture
2457 after N kilobytes" checkbox is on. */
2458 gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_cb), TRUE);
2459 gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_sb),
2460 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_filesize_cb)));
2461 gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_om),
2462 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_filesize_cb)));
2464 gtk_widget_set_sensitive(GTK_WIDGET(stop_files_cb), FALSE);
2465 gtk_widget_set_sensitive(GTK_WIDGET(stop_files_sb), FALSE);
2466 gtk_widget_set_sensitive(GTK_WIDGET(stop_files_lb), FALSE);
2469 /* The maximum packet count spinbox is sensitive if the "Stop capture
2470 after N packets" checkbox is on. */
2471 gtk_widget_set_sensitive(GTK_WIDGET(stop_packets_sb),
2472 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_packets_cb)));
2473 gtk_widget_set_sensitive(GTK_WIDGET(stop_packets_lb),
2474 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_packets_cb)));
2476 /* The capture duration spinbox is sensitive if the "Stop capture
2477 after N seconds" checkbox is on. */
2478 gtk_widget_set_sensitive(GTK_WIDGET(stop_duration_sb),
2479 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_duration_cb)));
2480 gtk_widget_set_sensitive(GTK_WIDGET(stop_duration_om),
2481 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_duration_cb)));
2483 #ifdef HAVE_PCAP_SETSAMPLING
2484 gtk_widget_set_sensitive(GTK_WIDGET(samp_count_sb),
2485 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(samp_count_rb)));
2486 gtk_widget_set_sensitive(GTK_WIDGET(samp_timer_sb),
2487 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(samp_timer_rb)));
2491 #endif /* HAVE_LIBPCAP */