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_box_pack_start(GTK_BOX(if_ip_hb), if_ip_eb, TRUE, TRUE, 6);
1107 gtk_tooltips_set_tip(tooltips, if_ip_eb, "Lists the IP address(es) "
1108 "assigned to the selected interface. If there are "
1109 "more addresses than will fit in the window, the "
1110 "first few and the last few will be shown with \"...\" "
1114 if_ip_lb = gtk_label_new("");
1115 gtk_misc_set_alignment(GTK_MISC(if_ip_lb), 0, 0); /* Left justified */
1116 gtk_container_add(GTK_CONTAINER(if_ip_eb), if_ip_lb);
1119 linktype_hb = gtk_hbox_new(FALSE, 3);
1120 gtk_box_pack_start(GTK_BOX(capture_vb), linktype_hb, FALSE, FALSE, 0);
1122 linktype_lb = gtk_label_new("Link-layer header type:");
1123 gtk_box_pack_start(GTK_BOX(linktype_hb), linktype_lb, FALSE, FALSE, 6);
1125 linktype_om = gtk_option_menu_new();
1126 g_object_set_data(G_OBJECT(linktype_om), E_CAP_LT_OM_LABEL_KEY, linktype_lb);
1127 /* Default to "use the default" */
1128 /* Datalink menu index is not resetted, it will be restored with last used value */
1129 /* g_object_set_data(G_OBJECT(linktype_om), E_CAP_OM_LT_VALUE_KEY, GINT_TO_POINTER(-1)); */
1130 g_object_set_data(G_OBJECT(linktype_om), E_CAP_IFACE_KEY, if_ip_lb);
1132 if (linktype_history == NULL) {
1133 linktype_history = g_hash_table_new(g_str_hash, g_str_equal);
1135 set_link_type_list(linktype_om, GTK_COMBO(if_cb)->entry);
1137 * XXX - in some cases, this is "multiple link-layer header types", e.g.
1138 * some 802.11 interfaces on FreeBSD 5.2 and later, where you can request
1139 * fake Ethernet, 802.11, or 802.11-plus-radio-information headers.
1141 * In other cases, it's "multiple link-layer types", e.g., with recent
1142 * versions of libpcap, a DAG card on an "HDLC" WAN, where you can
1143 * request Cisco HDLC or PPP depending on what type of traffic is going
1144 * over the WAN, or an Ethernet interface, where you can request Ethernet
1145 * or DOCSIS, the latter being for some Cisco cable modem equipment that
1146 * can be configured to send raw DOCSIS frames over an Ethernet inside
1147 * Ethernet low-level framing, for traffic capture purposes.
1149 * We leave it as "multiple link-layer types" for now.
1151 gtk_tooltips_set_tip(tooltips, linktype_om,
1152 "The selected interface supports multiple link-layer types; select the desired one.", NULL);
1153 gtk_box_pack_start (GTK_BOX(linktype_hb), linktype_om, FALSE, FALSE, 0);
1154 g_signal_connect(GTK_ENTRY(GTK_COMBO(if_cb)->entry), "changed",
1155 G_CALLBACK(capture_prep_interface_changed_cb), linktype_om);
1158 buffer_size_lb = gtk_label_new("Buffer size:");
1159 gtk_box_pack_start (GTK_BOX(linktype_hb), buffer_size_lb, FALSE, FALSE, 0);
1161 buffer_size_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat) global_capture_opts.buffer_size,
1162 1, 65535, 1.0, 10.0, 0.0);
1163 buffer_size_sb = gtk_spin_button_new (buffer_size_adj, 0, 0);
1164 gtk_spin_button_set_value(GTK_SPIN_BUTTON (buffer_size_sb), (gfloat) global_capture_opts.buffer_size);
1165 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (buffer_size_sb), TRUE);
1166 gtk_widget_set_size_request(buffer_size_sb, 80, -1);
1167 gtk_tooltips_set_tip(tooltips, buffer_size_sb,
1168 "The memory buffer size used while capturing. If you notice packet drops, you can try to increase this size.", NULL);
1169 gtk_box_pack_start (GTK_BOX(linktype_hb), buffer_size_sb, FALSE, FALSE, 0);
1171 buffer_size_lb = gtk_label_new("megabyte(s)");
1172 gtk_box_pack_start (GTK_BOX(linktype_hb), buffer_size_lb, FALSE, FALSE, 6);
1175 /* Promiscuous mode row */
1176 promisc_cb = gtk_check_button_new_with_mnemonic(
1177 "Capture packets in _promiscuous mode");
1178 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(promisc_cb),
1179 global_capture_opts.promisc_mode);
1180 gtk_tooltips_set_tip(tooltips, promisc_cb,
1181 "Usually a network card will only capture the traffic sent to its own network address. "
1182 "If you want to capture all traffic that the network card can \"see\", mark this option. "
1183 "See the FAQ for some more details of capturing packets from a switched network.", NULL);
1184 gtk_container_add(GTK_CONTAINER(capture_vb), promisc_cb);
1186 #ifdef HAVE_PCAP_REMOTE
1187 /* RPCAP-related flags */
1188 nocap_rpcap_cb = gtk_check_button_new_with_mnemonic(
1189 "Do not capture RPCAP own traffic");
1190 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(nocap_rpcap_cb),
1191 global_capture_opts.nocap_rpcap);
1192 gtk_container_add(GTK_CONTAINER(capture_vb), nocap_rpcap_cb);
1194 datatx_udp_cb = gtk_check_button_new_with_mnemonic(
1195 "Use UDP for RPCAP data transfer");
1196 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(datatx_udp_cb),
1197 global_capture_opts.datatx_udp);
1198 gtk_container_add(GTK_CONTAINER(capture_vb), datatx_udp_cb);
1201 /* Capture length row */
1202 snap_hb = gtk_hbox_new(FALSE, 3);
1203 gtk_container_add(GTK_CONTAINER(capture_vb), snap_hb);
1205 snap_cb = gtk_check_button_new_with_mnemonic("_Limit each packet to");
1206 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(snap_cb),
1207 global_capture_opts.has_snaplen);
1208 g_signal_connect(snap_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1209 gtk_tooltips_set_tip(tooltips, snap_cb,
1210 "Limit the maximum number of bytes to be captured from each packet. This size includes the "
1211 "link-layer header and all subsequent headers. ", NULL);
1212 gtk_box_pack_start(GTK_BOX(snap_hb), snap_cb, FALSE, FALSE, 0);
1214 snap_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat) global_capture_opts.snaplen,
1215 MIN_PACKET_SIZE, WTAP_MAX_PACKET_SIZE, 1.0, 10.0, 0.0);
1216 snap_sb = gtk_spin_button_new (snap_adj, 0, 0);
1217 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (snap_sb), TRUE);
1218 gtk_widget_set_size_request(snap_sb, 80, -1);
1219 gtk_box_pack_start (GTK_BOX(snap_hb), snap_sb, FALSE, FALSE, 0);
1221 snap_lb = gtk_label_new("bytes");
1222 gtk_misc_set_alignment(GTK_MISC(snap_lb), 0, 0.5);
1223 gtk_box_pack_start(GTK_BOX(snap_hb), snap_lb, FALSE, FALSE, 0);
1226 filter_hb = gtk_hbox_new(FALSE, 3);
1227 gtk_box_pack_start(GTK_BOX(capture_vb), filter_hb, FALSE, FALSE, 0);
1229 filter_bt = gtk_button_new_from_stock(WIRESHARK_STOCK_CAPTURE_FILTER_ENTRY);
1230 g_signal_connect(filter_bt, "clicked", G_CALLBACK(capture_filter_construct_cb), NULL);
1231 g_signal_connect(filter_bt, "destroy", G_CALLBACK(filter_button_destroy_cb), NULL);
1232 gtk_tooltips_set_tip(tooltips, filter_bt,
1233 "Select a capture filter to reduce the amount of packets to be captured. "
1234 "See \"Capture Filters\" in the online help for further information how to use it.",
1236 gtk_box_pack_start(GTK_BOX(filter_hb), filter_bt, FALSE, FALSE, 3);
1238 /* Create the capture filter combo */
1239 filter_cm = gtk_combo_new();
1241 cfilter_list = g_object_get_data(G_OBJECT(top_level), E_CFILTER_FL_KEY);
1242 gtk_combo_disable_activate(GTK_COMBO(filter_cm));
1243 gtk_combo_set_case_sensitive(GTK_COMBO(filter_cm), TRUE);
1244 g_object_set_data(G_OBJECT(top_level), E_CFILTER_FL_KEY, cfilter_list);
1245 g_object_set_data(G_OBJECT(top_level), E_CFILTER_CM_KEY, filter_cm);
1246 filter_te = GTK_COMBO(filter_cm)->entry;
1248 if (cfilter_list != NULL)
1249 gtk_combo_set_popdown_strings(GTK_COMBO(filter_cm), cfilter_list);
1250 if (global_capture_opts.cfilter)
1251 gtk_entry_set_text(GTK_ENTRY(filter_te), global_capture_opts.cfilter);
1252 gtk_tooltips_set_tip(tooltips, filter_te,
1253 "Enter a capture filter to reduce the amount of packets to be captured. "
1254 "See \"Capture Filters\" in the online help for further information how to use it.",
1256 gtk_widget_set_size_request(filter_cm, 400, -1);
1257 gtk_box_pack_start(GTK_BOX(filter_hb), filter_cm, FALSE, FALSE, 3);
1258 main_hb = gtk_hbox_new(FALSE, 5);
1259 gtk_container_set_border_width(GTK_CONTAINER(main_hb), 0);
1260 gtk_container_add(GTK_CONTAINER(main_vb), main_hb);
1262 left_vb = gtk_vbox_new(FALSE, 0);
1263 gtk_container_set_border_width(GTK_CONTAINER(left_vb), 0);
1264 gtk_box_pack_start(GTK_BOX(main_hb), left_vb, TRUE, TRUE, 0);
1266 right_vb = gtk_vbox_new(FALSE, 0);
1267 gtk_container_set_border_width(GTK_CONTAINER(right_vb), 0);
1268 gtk_box_pack_start(GTK_BOX(main_hb), right_vb, FALSE, FALSE, 0);
1270 /* let an eventually capture filters dialog know the text entry to fill in */
1271 g_object_set_data(G_OBJECT(filter_bt), E_FILT_TE_PTR_KEY, filter_te);
1275 advanced_hb = gtk_hbox_new(FALSE,5);
1276 gtk_box_pack_start(GTK_BOX(capture_vb), advanced_hb, FALSE, FALSE, 0);
1278 advanced_bt = gtk_button_new_with_label("Wireless Settings");
1281 /* XXX - find a way to set the GtkButton label in GTK 2.x */
1282 gtk_button_set_label(GTK_BUTTON(advanced_bt), "Wireless Settings");
1284 /* Both the callback and the data are global */
1285 g_signal_connect(advanced_bt,"clicked", G_CALLBACK(options_airpcap_advanced_cb),airpcap_tb);
1286 g_object_set_data(G_OBJECT(GTK_ENTRY(GTK_COMBO(if_cb)->entry)),AIRPCAP_OPTIONS_ADVANCED_KEY,advanced_bt);
1288 if(airpcap_if_selected != NULL) {
1289 /* It is an airpcap interface */
1290 gtk_widget_set_sensitive(advanced_bt,TRUE);
1292 gtk_widget_set_sensitive(advanced_bt,FALSE);
1295 gtk_box_pack_start(GTK_BOX(linktype_hb),advanced_bt,FALSE,FALSE,0);
1296 gtk_widget_show(advanced_bt);
1297 gtk_widget_show(advanced_hb);
1300 /* Capture file-related options frame */
1301 file_fr = gtk_frame_new("Capture File(s)");
1302 gtk_container_add(GTK_CONTAINER(left_vb), file_fr);
1304 file_vb = gtk_vbox_new(FALSE, 3);
1305 gtk_container_set_border_width(GTK_CONTAINER(file_vb), 5);
1306 gtk_container_add(GTK_CONTAINER(file_fr), file_vb);
1309 file_hb = gtk_hbox_new(FALSE, 3);
1310 gtk_box_pack_start(GTK_BOX(file_vb), file_hb, FALSE, FALSE, 0);
1312 file_lb = gtk_label_new("File:");
1313 gtk_box_pack_start(GTK_BOX(file_hb), file_lb, FALSE, FALSE, 3);
1315 file_te = gtk_entry_new();
1316 gtk_tooltips_set_tip(tooltips, file_te,
1317 "Enter the file name to which captured data will be written. "
1318 "If you don't enter something here, a temporary file will be used.",
1320 gtk_box_pack_start(GTK_BOX(file_hb), file_te, TRUE, TRUE, 3);
1322 file_bt = gtk_button_new_from_stock(WIRESHARK_STOCK_BROWSE);
1323 gtk_tooltips_set_tip(tooltips, file_bt,
1324 "Select a file to which captured data will be written, "
1325 "instead of entering the file name directly. ",
1327 gtk_box_pack_start(GTK_BOX(file_hb), file_bt, FALSE, FALSE, 3);
1329 g_signal_connect(file_bt, "clicked", G_CALLBACK(capture_prep_file_cb), file_te);
1331 /* multiple files table */
1332 multi_tb = gtk_table_new(5, 3, FALSE);
1333 gtk_table_set_row_spacings(GTK_TABLE(multi_tb), 1);
1334 gtk_table_set_col_spacings(GTK_TABLE(multi_tb), 3);
1335 gtk_box_pack_start(GTK_BOX(file_vb), multi_tb, FALSE, FALSE, 0);
1338 /* multiple files row */
1339 multi_files_on_cb = gtk_check_button_new_with_mnemonic("Use _multiple files");
1340 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(multi_files_on_cb),
1341 global_capture_opts.multi_files_on);
1342 g_signal_connect(multi_files_on_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity),
1344 gtk_tooltips_set_tip(tooltips, multi_files_on_cb,
1345 "Instead of using a single capture file, multiple files will be created. "
1346 "The generated file names will contain an incrementing number and the start time of the capture.", NULL);
1347 gtk_table_attach_defaults(GTK_TABLE(multi_tb), multi_files_on_cb, 0, 1, row, row+1);
1350 /* Ring buffer filesize row */
1351 ring_filesize_cb = gtk_check_button_new_with_label("Next file every");
1352 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ring_filesize_cb),
1353 global_capture_opts.has_autostop_filesize || !global_capture_opts.has_file_duration);
1354 g_signal_connect(ring_filesize_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1355 gtk_tooltips_set_tip(tooltips, ring_filesize_cb,
1356 "If the selected file size is exceeded, capturing switches to the next file.\n"
1357 "PLEASE NOTE: at least one of the \"Next file every\" options MUST be selected.",
1359 gtk_table_attach_defaults(GTK_TABLE(multi_tb), ring_filesize_cb, 0, 1, row, row+1);
1361 ring_filesize_adj = (GtkAdjustment *) gtk_adjustment_new(0.0,
1362 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
1363 ring_filesize_sb = gtk_spin_button_new (ring_filesize_adj, 0, 0);
1364 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (ring_filesize_sb), TRUE);
1365 gtk_widget_set_size_request(ring_filesize_sb, 80, -1);
1366 gtk_table_attach_defaults(GTK_TABLE(multi_tb), ring_filesize_sb, 1, 2, row, row+1);
1368 ring_filesize_om = size_unit_option_menu_new(global_capture_opts.autostop_filesize);
1369 gtk_table_attach_defaults(GTK_TABLE(multi_tb), ring_filesize_om, 2, 3, row, row+1);
1371 value = size_unit_option_menu_set_value(global_capture_opts.autostop_filesize);
1372 gtk_adjustment_set_value(ring_filesize_adj, (gfloat) value);
1376 /* Ring buffer duration row */
1377 file_duration_cb = gtk_check_button_new_with_label("Next file every");
1378 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(file_duration_cb),
1379 global_capture_opts.has_file_duration);
1380 g_signal_connect(file_duration_cb, "toggled",
1381 G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1382 gtk_tooltips_set_tip(tooltips, file_duration_cb,
1383 "If the selected duration is exceeded, capturing switches to the next file.\n"
1384 "PLEASE NOTE: at least one of the \"Next file every\" options MUST be selected.",
1386 gtk_table_attach_defaults(GTK_TABLE(multi_tb), file_duration_cb, 0, 1, row, row+1);
1388 file_duration_adj = (GtkAdjustment *)gtk_adjustment_new(0.0,
1389 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
1390 file_duration_sb = gtk_spin_button_new (file_duration_adj, 0, 0);
1391 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (file_duration_sb), TRUE);
1392 gtk_widget_set_size_request(file_duration_sb, 80, -1);
1393 gtk_table_attach_defaults(GTK_TABLE(multi_tb), file_duration_sb, 1, 2, row, row+1);
1395 file_duration_om = time_unit_option_menu_new(global_capture_opts.file_duration);
1396 gtk_table_attach_defaults(GTK_TABLE(multi_tb), file_duration_om, 2, 3, row, row+1);
1398 value = time_unit_option_menu_convert_value(global_capture_opts.file_duration);
1399 gtk_adjustment_set_value(file_duration_adj, (gfloat) value);
1402 /* Ring buffer files row */
1403 ringbuffer_nbf_cb = gtk_check_button_new_with_label("Ring buffer with");
1404 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb),
1405 global_capture_opts.has_ring_num_files);
1406 g_signal_connect(ringbuffer_nbf_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1407 gtk_tooltips_set_tip(tooltips, ringbuffer_nbf_cb,
1408 "After capturing has switched to the next file and the given number of files has exceeded, "
1409 "the oldest file will be removed.",
1411 gtk_table_attach_defaults(GTK_TABLE(multi_tb), ringbuffer_nbf_cb, 0, 1, row, row+1);
1413 ringbuffer_nbf_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat) global_capture_opts.ring_num_files,
1414 2/*RINGBUFFER_MIN_NUM_FILES*/, RINGBUFFER_MAX_NUM_FILES, 1.0, 10.0, 0.0);
1415 ringbuffer_nbf_sb = gtk_spin_button_new (ringbuffer_nbf_adj, 0, 0);
1416 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (ringbuffer_nbf_sb), TRUE);
1417 gtk_widget_set_size_request(ringbuffer_nbf_sb, 80, -1);
1418 g_signal_connect(ringbuffer_nbf_sb, "changed", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1419 gtk_table_attach_defaults(GTK_TABLE(multi_tb), ringbuffer_nbf_sb, 1, 2, row, row+1);
1421 ringbuffer_nbf_lb = gtk_label_new("files");
1422 gtk_misc_set_alignment(GTK_MISC(ringbuffer_nbf_lb), 0, 0.5);
1423 gtk_table_attach_defaults(GTK_TABLE(multi_tb), ringbuffer_nbf_lb, 2, 3, row, row+1);
1427 stop_files_cb = gtk_check_button_new_with_label("Stop capture after");
1428 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stop_files_cb),
1429 global_capture_opts.has_autostop_files);
1430 g_signal_connect(stop_files_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1431 gtk_tooltips_set_tip(tooltips, stop_files_cb,
1432 "Stop capturing after the given number of \"file switches\" have been done.", NULL);
1433 gtk_table_attach_defaults(GTK_TABLE(multi_tb), stop_files_cb, 0, 1, row, row+1);
1435 stop_files_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat)global_capture_opts.autostop_files,
1436 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
1437 stop_files_sb = gtk_spin_button_new (stop_files_adj, 0, 0);
1438 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_files_sb), TRUE);
1439 gtk_widget_set_size_request(stop_files_sb, 80, -1);
1440 gtk_table_attach_defaults(GTK_TABLE(multi_tb), stop_files_sb, 1, 2, row, row+1);
1442 stop_files_lb = gtk_label_new("file(s)");
1443 gtk_misc_set_alignment(GTK_MISC(stop_files_lb), 0, 0.5);
1444 gtk_table_attach_defaults(GTK_TABLE(multi_tb), stop_files_lb, 2, 3, row, row+1);
1447 /* Capture limits frame */
1448 limit_fr = gtk_frame_new("Stop Capture ...");
1449 gtk_container_add(GTK_CONTAINER(left_vb), limit_fr);
1451 limit_vb = gtk_vbox_new(FALSE, 3);
1452 gtk_container_set_border_width(GTK_CONTAINER(limit_vb), 5);
1453 gtk_container_add(GTK_CONTAINER(limit_fr), limit_vb);
1456 limit_tb = gtk_table_new(3, 3, FALSE);
1457 gtk_table_set_row_spacings(GTK_TABLE(limit_tb), 1);
1458 gtk_table_set_col_spacings(GTK_TABLE(limit_tb), 3);
1459 gtk_box_pack_start(GTK_BOX(limit_vb), limit_tb, FALSE, FALSE, 0);
1462 /* Packet count row */
1463 stop_packets_cb = gtk_check_button_new_with_label("... after");
1464 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stop_packets_cb),
1465 global_capture_opts.has_autostop_packets);
1466 g_signal_connect(stop_packets_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1467 gtk_tooltips_set_tip(tooltips, stop_packets_cb,
1468 "Stop capturing after the given number of packets have been captured.", NULL);
1469 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_packets_cb, 0, 1, row, row+1);
1471 stop_packets_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat)global_capture_opts.autostop_packets,
1472 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
1473 stop_packets_sb = gtk_spin_button_new (stop_packets_adj, 0, 0);
1474 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_packets_sb), TRUE);
1475 gtk_widget_set_size_request(stop_packets_sb, 80, -1);
1476 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_packets_sb, 1, 2, row, row+1);
1478 stop_packets_lb = gtk_label_new("packet(s)");
1479 gtk_misc_set_alignment(GTK_MISC(stop_packets_lb), 0, 0.5);
1480 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_packets_lb, 2, 3, row, row+1);
1484 stop_filesize_cb = gtk_check_button_new_with_label("... after");
1485 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stop_filesize_cb),
1486 global_capture_opts.has_autostop_filesize);
1487 g_signal_connect(stop_filesize_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1488 gtk_tooltips_set_tip(tooltips, stop_filesize_cb,
1489 "Stop capturing after the given amount of capture data has been captured.", NULL);
1490 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_filesize_cb, 0, 1, row, row+1);
1492 stop_filesize_adj = (GtkAdjustment *) gtk_adjustment_new(0.0,
1493 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
1494 stop_filesize_sb = gtk_spin_button_new (stop_filesize_adj, 0, 0);
1495 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_filesize_sb), TRUE);
1496 gtk_widget_set_size_request(stop_filesize_sb, 80, -1);
1497 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_filesize_sb, 1, 2, row, row+1);
1499 stop_filesize_om = size_unit_option_menu_new(global_capture_opts.autostop_filesize);
1500 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_filesize_om, 2, 3, row, row+1);
1502 value = size_unit_option_menu_set_value(global_capture_opts.autostop_filesize);
1503 gtk_adjustment_set_value(stop_filesize_adj, (gfloat) value);
1508 stop_duration_cb = gtk_check_button_new_with_label("... after");
1509 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stop_duration_cb),
1510 global_capture_opts.has_autostop_duration);
1511 g_signal_connect(stop_duration_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1512 gtk_tooltips_set_tip(tooltips, stop_duration_cb,
1513 "Stop capturing after the given time is exceeded.", NULL);
1514 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_duration_cb, 0, 1, row, row+1);
1516 stop_duration_adj = (GtkAdjustment *) gtk_adjustment_new(0.0,
1517 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
1518 stop_duration_sb = gtk_spin_button_new (stop_duration_adj, 0, 0);
1519 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_duration_sb), TRUE);
1520 gtk_widget_set_size_request(stop_duration_sb, 80, -1);
1521 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_duration_sb, 1, 2, row, row+1);
1523 stop_duration_om = time_unit_option_menu_new(global_capture_opts.autostop_duration);
1524 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_duration_om, 2, 3, row, row+1);
1526 value = time_unit_option_menu_convert_value(global_capture_opts.autostop_duration);
1527 gtk_adjustment_set_value(stop_duration_adj, (gfloat) value);
1530 #ifdef HAVE_PCAP_SETSAMPLING
1531 /* Sampling options */
1532 sampling_fr = gtk_frame_new("Sampling Options");
1533 gtk_container_add(GTK_CONTAINER(right_vb), sampling_fr);
1535 sampling_vb = gtk_vbox_new(FALSE, 0);
1536 gtk_container_set_border_width(GTK_CONTAINER(sampling_vb), 5);
1537 gtk_container_add(GTK_CONTAINER(sampling_fr), sampling_vb);
1539 sampling_tb = gtk_table_new(3, 3, FALSE);
1540 gtk_table_set_row_spacings(GTK_TABLE(sampling_tb), 1);
1541 gtk_table_set_col_spacings(GTK_TABLE(sampling_tb), 3);
1542 gtk_box_pack_start(GTK_BOX(sampling_vb), sampling_tb, FALSE, FALSE, 0);
1544 /* "No sampling" row */
1545 samp_none_rb = gtk_radio_button_new_with_label(NULL, "None");
1546 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(samp_none_rb),
1547 (global_capture_opts.sampling_method == CAPTURE_SAMP_NONE));
1548 g_signal_connect(samp_none_rb, "toggled",
1549 G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1550 gtk_table_attach_defaults(GTK_TABLE(sampling_tb), samp_none_rb, 0, 1, 0, 1);
1552 /* "Sampling by counter" row */
1553 samp_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(samp_none_rb));
1554 samp_count_rb = gtk_radio_button_new_with_label(samp_group, "1 of");
1555 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(samp_none_rb),
1556 (global_capture_opts.sampling_method == CAPTURE_SAMP_BY_COUNT));
1557 g_signal_connect(samp_count_rb, "toggled",
1558 G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1559 gtk_table_attach_defaults(GTK_TABLE(sampling_tb), samp_count_rb, 0, 1, 1, 2);
1561 samp_count_adj = (GtkAdjustment *) gtk_adjustment_new(
1562 (gfloat)global_capture_opts.sampling_param,
1563 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
1564 samp_count_sb = gtk_spin_button_new(samp_count_adj, 0, 0);
1565 gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(samp_count_sb), TRUE);
1566 gtk_table_attach_defaults(GTK_TABLE(sampling_tb), samp_count_sb, 1, 2, 1, 2);
1568 sampling_lb = gtk_label_new("packets");
1569 gtk_misc_set_alignment(GTK_MISC(sampling_lb), 0, 0.5);
1570 gtk_table_attach_defaults(GTK_TABLE(sampling_tb), sampling_lb, 2, 3, 1, 2);
1572 /* "Sampling by timer" row */
1573 samp_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(samp_count_rb));
1574 samp_timer_rb = gtk_radio_button_new_with_label(samp_group, "1 every");
1575 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(samp_none_rb),
1576 (global_capture_opts.sampling_method == CAPTURE_SAMP_BY_TIMER));
1577 g_signal_connect(samp_timer_rb, "toggled",
1578 G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1579 gtk_table_attach_defaults(GTK_TABLE(sampling_tb), samp_timer_rb, 0, 1, 2, 3);
1581 samp_timer_adj = (GtkAdjustment *) gtk_adjustment_new(
1582 (gfloat)global_capture_opts.sampling_param,
1583 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
1584 samp_timer_sb = gtk_spin_button_new(samp_timer_adj, 0, 0);
1585 gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(samp_timer_sb), TRUE);
1586 gtk_table_attach_defaults(GTK_TABLE(sampling_tb), samp_timer_sb, 1, 2, 2, 3);
1588 sampling_lb = gtk_label_new("milliseconds");
1589 gtk_misc_set_alignment(GTK_MISC(sampling_lb), 0, 0.5);
1590 gtk_table_attach_defaults(GTK_TABLE(sampling_tb), sampling_lb, 2, 3, 2, 3);
1593 /* Display-related options frame */
1594 display_fr = gtk_frame_new("Display Options");
1595 gtk_container_add(GTK_CONTAINER(right_vb), display_fr);
1597 display_vb = gtk_vbox_new(FALSE, 0);
1598 gtk_container_set_border_width(GTK_CONTAINER(display_vb), 5);
1599 gtk_container_add(GTK_CONTAINER(display_fr), display_vb);
1601 /* "Update display in real time" row */
1602 sync_cb = gtk_check_button_new_with_mnemonic(
1603 "_Update list of packets in real time");
1604 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(sync_cb),
1605 global_capture_opts.real_time_mode);
1606 g_signal_connect(sync_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1607 gtk_tooltips_set_tip(tooltips, sync_cb,
1608 "Using this option will show the captured packets immediately on the main screen. "
1609 "Please note: this will slow down capturing, so increased packet drops might appear.", NULL);
1610 gtk_container_add(GTK_CONTAINER(display_vb), sync_cb);
1612 /* "Auto-scroll live update" row */
1613 auto_scroll_cb = gtk_check_button_new_with_mnemonic(
1614 "_Automatic scrolling in live capture");
1615 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(auto_scroll_cb), auto_scroll_live);
1616 gtk_tooltips_set_tip(tooltips, auto_scroll_cb,
1617 "This will scroll the \"Packet List\" automatically to the latest captured packet, "
1618 "when the \"Update List of packets in real time\" option is used.", NULL);
1619 gtk_container_add(GTK_CONTAINER(display_vb), auto_scroll_cb);
1621 /* "Hide capture info" row */
1622 hide_info_cb = gtk_check_button_new_with_mnemonic(
1623 "_Hide capture info dialog");
1624 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hide_info_cb), !global_capture_opts.show_info);
1625 gtk_tooltips_set_tip(tooltips, hide_info_cb,
1626 "Hide the capture info dialog while capturing.", NULL);
1627 gtk_container_add(GTK_CONTAINER(display_vb), hide_info_cb);
1629 /* Name Resolution frame */
1630 resolv_fr = gtk_frame_new("Name Resolution");
1631 gtk_container_add(GTK_CONTAINER(right_vb), resolv_fr);
1633 resolv_vb = gtk_vbox_new(FALSE, 0);
1634 gtk_container_set_border_width(GTK_CONTAINER(resolv_vb), 5);
1635 gtk_container_add(GTK_CONTAINER(resolv_fr), resolv_vb);
1637 m_resolv_cb = gtk_check_button_new_with_mnemonic(
1638 "Enable _MAC name resolution");
1639 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_resolv_cb),
1640 g_resolv_flags & RESOLV_MAC);
1641 gtk_tooltips_set_tip(tooltips, m_resolv_cb,
1642 "Perform MAC layer name resolution while capturing.", NULL);
1643 gtk_container_add(GTK_CONTAINER(resolv_vb), m_resolv_cb);
1645 n_resolv_cb = gtk_check_button_new_with_mnemonic(
1646 "Enable _network name resolution");
1647 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(n_resolv_cb),
1648 g_resolv_flags & RESOLV_NETWORK);
1649 gtk_tooltips_set_tip(tooltips, n_resolv_cb,
1650 "Perform network layer name resolution while capturing.", NULL);
1651 gtk_container_add(GTK_CONTAINER(resolv_vb), n_resolv_cb);
1653 t_resolv_cb = gtk_check_button_new_with_mnemonic(
1654 "Enable _transport name resolution");
1655 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(t_resolv_cb),
1656 g_resolv_flags & RESOLV_TRANSPORT);
1657 gtk_tooltips_set_tip(tooltips, t_resolv_cb,
1658 "Perform transport layer name resolution while capturing.", NULL);
1659 gtk_container_add(GTK_CONTAINER(resolv_vb), t_resolv_cb);
1661 /* Button row: "Start", "Cancel" and "Help" buttons */
1662 bbox = dlg_button_row_new(WIRESHARK_STOCK_CAPTURE_START, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL);
1663 gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 5);
1665 ok_bt = g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_CAPTURE_START);
1666 g_signal_connect(ok_bt, "clicked", G_CALLBACK(capture_start_cb), cap_open_w);
1667 gtk_tooltips_set_tip(tooltips, ok_bt,
1668 "Start the capture process.", NULL);
1670 cancel_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
1671 gtk_tooltips_set_tip(tooltips, cancel_bt,
1672 "Cancel and exit dialog.", NULL);
1673 window_set_cancel_button(cap_open_w, cancel_bt, window_cancel_button_cb);
1675 help_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
1676 gtk_tooltips_set_tip(tooltips, help_bt,
1677 "Show help about capturing.", NULL);
1678 g_signal_connect(help_bt, "clicked", G_CALLBACK(topic_cb), (gpointer)HELP_CAPTURE_OPTIONS_DIALOG);
1680 gtk_widget_grab_default(ok_bt);
1682 /* Attach pointers to needed widgets to the capture prefs window/object */
1683 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_IFACE_KEY, if_cb);
1684 #ifdef HAVE_PCAP_REMOTE
1685 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_IFTYPE_OM_KEY, iftype_om);
1686 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_REMOTE_DIALOG_PTR_KEY, NULL);
1687 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_NOCAP_RPCAP_CB_KEY, nocap_rpcap_cb);
1688 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_DATATX_UDP_CB_KEY, datatx_udp_cb);
1690 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_SNAP_CB_KEY, snap_cb);
1691 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_SNAP_SB_KEY, snap_sb);
1692 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_LT_OM_KEY, linktype_om);
1694 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_BUFFER_SIZE_SB_KEY, buffer_size_sb);
1696 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_PROMISC_KEY, promisc_cb);
1697 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_FILT_KEY, filter_te);
1698 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_FILE_TE_KEY, file_te);
1699 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_MULTI_FILES_ON_CB_KEY, multi_files_on_cb);
1700 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_RING_NBF_CB_KEY, ringbuffer_nbf_cb);
1701 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_RING_NBF_SB_KEY, ringbuffer_nbf_sb);
1702 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_RING_NBF_LB_KEY, ringbuffer_nbf_lb);
1703 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_RING_FILESIZE_CB_KEY, ring_filesize_cb);
1704 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_RING_FILESIZE_SB_KEY, ring_filesize_sb);
1705 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_RING_FILESIZE_OM_KEY, ring_filesize_om);
1706 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_FILE_DURATION_CB_KEY, file_duration_cb);
1707 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_FILE_DURATION_SB_KEY, file_duration_sb);
1708 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_FILE_DURATION_OM_KEY, file_duration_om);
1709 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_SYNC_KEY, sync_cb);
1710 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_AUTO_SCROLL_KEY, auto_scroll_cb);
1711 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_HIDE_INFO_KEY, hide_info_cb);
1712 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_PACKETS_CB_KEY, stop_packets_cb);
1713 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_PACKETS_SB_KEY, stop_packets_sb);
1714 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_PACKETS_LB_KEY, stop_packets_lb);
1715 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILESIZE_CB_KEY, stop_filesize_cb);
1716 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILESIZE_SB_KEY, stop_filesize_sb);
1717 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILESIZE_OM_KEY, stop_filesize_om);
1718 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_DURATION_CB_KEY, stop_duration_cb);
1719 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_DURATION_SB_KEY, stop_duration_sb);
1720 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_DURATION_OM_KEY, stop_duration_om);
1721 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILES_CB_KEY, stop_files_cb);
1722 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILES_SB_KEY, stop_files_sb);
1723 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILES_LB_KEY, stop_files_lb);
1724 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_M_RESOLVE_KEY, m_resolv_cb);
1725 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_N_RESOLVE_KEY, n_resolv_cb);
1726 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_T_RESOLVE_KEY, t_resolv_cb);
1727 #ifdef HAVE_PCAP_SETSAMPLING
1728 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_SAMP_NONE_RB_KEY, samp_none_rb);
1729 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_SAMP_COUNT_RB_KEY, samp_count_rb);
1730 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_SAMP_COUNT_SB_KEY, samp_count_sb);
1731 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_SAMP_TIMER_RB_KEY, samp_timer_rb);
1732 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_SAMP_TIMER_SB_KEY, samp_timer_sb);
1735 /* Set the sensitivity of various widgets as per the settings of other
1737 capture_prep_adjust_sensitivity(NULL, cap_open_w);
1739 /* Catch the "activate" signal on the text
1740 entries, so that if the user types Return there, we act as if the
1741 "OK" button had been selected, as happens if Return is typed if some
1742 widget that *doesn't* handle the Return key has the input focus. */
1743 dlg_set_activate(GTK_COMBO(if_cb)->entry, ok_bt);
1744 dlg_set_activate(filter_te, ok_bt);
1745 dlg_set_activate(file_te, ok_bt);
1747 /* XXX - why does not
1749 gtk_widget_grab_focus(if_cb);
1751 give the initial focus to the "Interface" combo box?
1753 Or should I phrase that as "why does GTK+ continually frustrate
1754 attempts to make GUIs driveable from the keyboard?" We have to
1755 go catch the activate signal on every single GtkEntry widget
1756 (rather than having widgets whose activate signal is *not*
1757 caught not catch the Return keystroke, so that it passes on,
1758 ultimately, to the window, which can activate the default
1759 widget, i.e. the "OK" button); we have to catch the "key_press_event"
1760 signal and have the handler check for ESC, so that we can have ESC
1761 activate the "Cancel" button; in order to support Alt+<key> mnemonics
1762 for buttons and the like, we may have to construct an accelerator
1763 group by hand and set up the accelerators by hand (if that even
1764 works - I've not tried it yet); we have to do a "gtk_widget_grab_focus()"
1765 to keep some container widget from getting the initial focus, so that
1766 you don't have to tab into the first widget in order to start typing
1767 in it; and it now appears that you simply *can't* make a combo box
1768 get the initial focus, at least not in the obvious fashion. Sigh.... */
1770 g_signal_connect(cap_open_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
1771 g_signal_connect(cap_open_w, "destroy", G_CALLBACK(capture_prep_destroy_cb), NULL);
1773 /* Give the initial focus to the "Filter" entry box. */
1774 gtk_widget_grab_focus(filter_te);
1776 gtk_widget_show_all(cap_open_w);
1777 window_present(cap_open_w);
1780 /* everythings prepared, now it's really time to start the capture */
1782 capture_start_confirmed(void)
1786 /* init iface, if never used before */
1787 /* XXX - would better be doing this in main.c */
1788 if(global_capture_opts.iface == NULL) {
1790 const gchar *if_name;
1792 /* did the user ever selected a capture interface before? */
1793 if(prefs.capture_device == NULL) {
1794 simple_dialog(ESD_TYPE_CONFIRMATION,
1796 "%sNo capture interface selected!%s\n\n"
1797 "To select an interface use:\n\n"
1798 "Capture->Options (until Wireshark is stopped)\n"
1799 "Edit->Preferences/Capture (permanent, if saved)",
1800 simple_dialog_primary_start(), simple_dialog_primary_end());
1803 if_device = g_strdup(prefs.capture_device);
1804 if_name = get_if_name(if_device);
1805 global_capture_opts.iface = g_strdup(if_name);
1806 global_capture_opts.iface_descr = get_interface_descriptive_name(global_capture_opts.iface);
1811 /* XXX - we might need to init other pref data as well... */
1812 menu_auto_scroll_live_changed(auto_scroll_live);
1814 if (capture_start(&global_capture_opts)) {
1815 /* The capture succeeded, which means the capture filter syntax is
1816 valid; add this capture filter to the recent capture filter list. */
1817 cfilter_combo_add_recent(global_capture_opts.cfilter);
1821 /* user confirmed the "Save capture file..." dialog */
1823 capture_start_answered_cb(gpointer dialog _U_, gint btn, gpointer data)
1827 /* save file first */
1828 file_save_as_cmd(after_save_capture_dialog, data);
1830 case(ESD_BTN_DONT_SAVE):
1831 /* XXX - unlink old file? */
1832 /* start the capture */
1833 capture_start_confirmed();
1835 case(ESD_BTN_CANCEL):
1838 g_assert_not_reached();
1842 /* user pressed the "Start" button (in dialog or toolbar) */
1844 capture_start_cb(GtkWidget *w _U_, gpointer d _U_)
1848 gint *linktype_p = NULL;
1851 airpcap_if_active = airpcap_if_selected;
1852 airpcap_set_toolbar_start_capture(airpcap_if_active);
1856 /* Is WPcap loaded? */
1858 char * err_msg = cant_load_winpcap_err("Wireshark");
1860 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, err_msg);
1866 /* get the values and close the options dialog */
1868 capture_dlg_prep(cap_open_w);
1869 window_destroy(GTK_WIDGET(cap_open_w));
1872 if (global_capture_opts.iface == NULL) {
1873 gchar *if_device = g_strdup(prefs.capture_device);
1874 if_name = g_strdup(get_if_name(if_device));
1877 if_name = g_strdup(global_capture_opts.iface);
1880 if (linktype_history != NULL) {
1881 linktype_p = g_hash_table_lookup(linktype_history, if_name);
1882 if (linktype_p == NULL) {
1883 linktype_p = g_malloc(sizeof (int));
1884 g_hash_table_insert(linktype_history, if_name, linktype_p);
1888 *linktype_p = global_capture_opts.linktype;
1890 global_capture_opts.linktype = capture_dev_user_linktype_find(if_name);
1894 if((cfile.state != FILE_CLOSED) && !cfile.user_saved && prefs.gui_ask_unsaved) {
1895 /* user didn't saved his current file, ask him */
1896 dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_SAVE_DONTSAVE_CANCEL,
1897 "%sSave capture file before starting a new capture?%s\n\n"
1898 "If you start a new capture without saving, your current capture data will\nbe discarded.",
1899 simple_dialog_primary_start(), simple_dialog_primary_end());
1900 simple_dialog_set_cb(dialog, capture_start_answered_cb, NULL);
1902 /* unchanged file, just capture a new one */
1903 capture_start_confirmed();
1907 /* user selected a link type, convert to internal value */
1909 select_link_type_cb(GtkWidget *w, gpointer data)
1911 int new_linktype = GPOINTER_TO_INT(data);
1912 GtkWidget *linktype_om = g_object_get_data(G_OBJECT(w), E_CAP_LT_OM_KEY);
1913 int old_linktype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(linktype_om), E_CAP_OM_LT_VALUE_KEY));
1915 /* If the link is changed, update the menu and store the index and the value
1916 to reuse later when the dialog window will be reopened */
1917 if (old_linktype != new_linktype) {
1918 g_object_set_data(G_OBJECT(linktype_om), E_CAP_OM_LT_VALUE_KEY, GINT_TO_POINTER(new_linktype));
1919 global_capture_opts.linktype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(linktype_om), E_CAP_OM_LT_VALUE_KEY));
1923 #ifdef HAVE_PCAP_REMOTE
1924 /* user selected an interface type (local/remote), convert to internal value) */
1926 select_if_type_cb(GtkWidget *w, gpointer data)
1928 int new_iftype = GPOINTER_TO_INT(data);
1929 GtkWidget *iftype_om = g_object_get_data(G_OBJECT(w), E_CAP_IFTYPE_OM_KEY);
1930 int old_iftype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(iftype_om),
1931 E_CAP_OM_IFTYPE_VALUE_KEY));
1933 if (old_iftype != new_iftype)
1935 g_object_set_data(G_OBJECT(iftype_om), E_CAP_OM_IFTYPE_VALUE_KEY,
1936 GINT_TO_POINTER(new_iftype));
1938 if (new_iftype == CAPTURE_IFREMOTE)
1940 capture_remote_cb(iftype_om, NULL);
1942 else if (new_iftype != old_iftype)
1944 global_capture_opts.src_type = CAPTURE_IFLOCAL;
1945 update_interface_list();
1950 /* user pressed "File" button */
1952 capture_prep_file_cb(GtkWidget *file_bt, GtkWidget *file_te)
1954 file_selection_browse(file_bt, file_te, "Wireshark: Specify a Capture File", FILE_SELECTION_WRITE_BROWSE);
1958 /* convert dialog settings into capture_opts values */
1960 capture_dlg_prep(gpointer parent_w) {
1961 GtkWidget *if_cb, *snap_cb, *snap_sb, *promisc_cb, *filter_te, *filter_cm,
1962 *file_te, *multi_files_on_cb, *ringbuffer_nbf_sb, *ringbuffer_nbf_cb,
1963 *linktype_om, *sync_cb, *auto_scroll_cb, *hide_info_cb,
1964 *stop_packets_cb, *stop_packets_sb,
1965 *stop_filesize_cb, *stop_filesize_sb, *stop_filesize_om,
1966 *stop_duration_cb, *stop_duration_sb, *stop_duration_om,
1967 *ring_filesize_cb, *ring_filesize_sb, *ring_filesize_om,
1968 *file_duration_cb, *file_duration_sb, *file_duration_om,
1969 *stop_files_cb, *stop_files_sb,
1970 *m_resolv_cb, *n_resolv_cb, *t_resolv_cb;
1971 #ifdef HAVE_PCAP_REMOTE
1972 GtkWidget *iftype_om, *datatx_udp_cb, *nocap_rpcap_cb;
1974 #ifdef HAVE_PCAP_SETSAMPLING
1975 GtkWidget *samp_none_rb, *samp_count_rb, *samp_timer_rb,
1976 *samp_count_sb, *samp_timer_sb;
1979 GtkWidget *buffer_size_sb;
1983 const gchar *if_name;
1984 const gchar *filter_text;
1985 const gchar *g_save_file;
1990 if_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_IFACE_KEY);
1991 #ifdef HAVE_PCAP_REMOTE
1992 iftype_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_IFTYPE_OM_KEY);
1993 datatx_udp_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_DATATX_UDP_CB_KEY);
1994 nocap_rpcap_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_NOCAP_RPCAP_CB_KEY);
1996 snap_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SNAP_CB_KEY);
1997 snap_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SNAP_SB_KEY);
1998 linktype_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_LT_OM_KEY);
2000 buffer_size_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_BUFFER_SIZE_SB_KEY);
2002 promisc_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_PROMISC_KEY);
2003 filter_cm = g_object_get_data(G_OBJECT(top_level), E_CFILTER_CM_KEY);
2004 filter_te = GTK_COMBO(filter_cm)->entry;
2005 file_te = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_TE_KEY);
2006 multi_files_on_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_MULTI_FILES_ON_CB_KEY);
2007 ringbuffer_nbf_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_NBF_CB_KEY);
2008 ringbuffer_nbf_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_NBF_SB_KEY);
2009 ring_filesize_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_CB_KEY);
2010 ring_filesize_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_SB_KEY);
2011 ring_filesize_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_OM_KEY);
2012 file_duration_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_DURATION_CB_KEY);
2013 file_duration_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_DURATION_SB_KEY);
2014 file_duration_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_DURATION_OM_KEY);
2015 sync_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SYNC_KEY);
2016 auto_scroll_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_AUTO_SCROLL_KEY);
2017 hide_info_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_HIDE_INFO_KEY);
2018 stop_packets_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_PACKETS_CB_KEY);
2019 stop_packets_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_PACKETS_SB_KEY);
2020 stop_filesize_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_CB_KEY);
2021 stop_filesize_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_SB_KEY);
2022 stop_filesize_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_OM_KEY);
2023 stop_duration_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_CB_KEY);
2024 stop_duration_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_SB_KEY);
2025 stop_duration_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_OM_KEY);
2026 stop_files_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILES_CB_KEY);
2027 stop_files_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILES_SB_KEY);
2028 m_resolv_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_M_RESOLVE_KEY);
2029 n_resolv_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_N_RESOLVE_KEY);
2030 t_resolv_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_T_RESOLVE_KEY);
2031 #ifdef HAVE_PCAP_SETSAMPLING
2032 samp_none_rb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_NONE_RB_KEY);
2033 samp_count_rb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_COUNT_RB_KEY);
2034 samp_timer_rb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_TIMER_RB_KEY);
2035 samp_count_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_COUNT_SB_KEY);
2036 samp_timer_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_TIMER_SB_KEY);
2040 g_strdup(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry)));
2041 if_text = g_strstrip(entry_text);
2042 if_name = get_if_name(if_text);
2043 if (*if_name == '\0') {
2044 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
2045 "You didn't specify an interface on which to capture packets.");
2049 if (global_capture_opts.iface)
2050 g_free(global_capture_opts.iface);
2051 if (global_capture_opts.iface_descr)
2052 g_free(global_capture_opts.iface_descr);
2053 global_capture_opts.iface = g_strdup(if_name);
2054 global_capture_opts.iface_descr = get_interface_descriptive_name(global_capture_opts.iface);
2056 /* The Linktype will be stored when the interface will be changed, or if not, not datalink option is used,
2057 the acquisition will be performed on the default datalink for the device */
2058 /* global_capture_opts.linktype =
2059 GPOINTER_TO_INT(g_object_get_data(G_OBJECT(linktype_om), E_CAP_OM_LT_VALUE_KEY)); */
2061 #ifdef HAVE_PCAP_REMOTE
2062 global_capture_opts.src_type = (capture_source)
2063 GPOINTER_TO_INT(g_object_get_data(G_OBJECT(iftype_om), E_CAP_OM_IFTYPE_VALUE_KEY));
2064 global_capture_opts.datatx_udp =
2065 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(datatx_udp_cb));
2066 global_capture_opts.nocap_rpcap =
2067 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(nocap_rpcap_cb));
2069 #ifdef HAVE_PCAP_SETSAMPLING
2070 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(samp_none_rb)))
2071 global_capture_opts.sampling_method = CAPTURE_SAMP_NONE;
2072 else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(samp_count_rb)))
2074 global_capture_opts.sampling_method = CAPTURE_SAMP_BY_COUNT;
2075 global_capture_opts.sampling_param = gtk_spin_button_get_value_as_int(
2076 GTK_SPIN_BUTTON(samp_count_sb));
2078 else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(samp_timer_rb)))
2080 global_capture_opts.sampling_method = CAPTURE_SAMP_BY_TIMER;
2081 global_capture_opts.sampling_param = gtk_spin_button_get_value_as_int(
2082 GTK_SPIN_BUTTON(samp_timer_sb));
2087 global_capture_opts.buffer_size =
2088 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(buffer_size_sb));
2091 global_capture_opts.has_snaplen =
2092 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(snap_cb));
2093 if (global_capture_opts.has_snaplen) {
2094 global_capture_opts.snaplen =
2095 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(snap_sb));
2096 if (global_capture_opts.snaplen < 1)
2097 global_capture_opts.snaplen = WTAP_MAX_PACKET_SIZE;
2098 else if (global_capture_opts.snaplen < MIN_PACKET_SIZE)
2099 global_capture_opts.snaplen = MIN_PACKET_SIZE;
2102 global_capture_opts.promisc_mode =
2103 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(promisc_cb));
2105 /* XXX - don't try to get clever and set "cfile.filter" to NULL if the
2106 filter string is empty, as an indication that we don't have a filter
2107 and thus don't have to set a filter when capturing - the version of
2108 libpcap in Red Hat Linux 6.1, and versions based on later patches
2109 in that series, don't bind the AF_PACKET socket to an interface
2110 until a filter is set, which means they aren't bound at all if
2111 no filter is set, which means no packets arrive as input on that
2112 socket, which means Wireshark never sees any packets. */
2113 filter_text = gtk_entry_get_text(GTK_ENTRY(filter_te));
2114 if (global_capture_opts.cfilter)
2115 g_free(global_capture_opts.cfilter);
2116 g_assert(filter_text != NULL);
2117 global_capture_opts.cfilter = g_strdup(filter_text);
2119 /* Wireshark always saves to a capture file. */
2120 global_capture_opts.saving_to_file = TRUE;
2121 g_save_file = gtk_entry_get_text(GTK_ENTRY(file_te));
2122 if (g_save_file && g_save_file[0]) {
2123 /* User specified a file to which the capture should be written. */
2124 global_capture_opts.save_file = g_strdup(g_save_file);
2125 /* Save the directory name for future file dialogs. */
2126 cf_name = g_strdup(g_save_file);
2127 dirname = get_dirname(cf_name); /* Overwrites cf_name */
2128 set_last_open_dir(dirname);
2131 /* User didn't specify a file; save to a temporary file. */
2132 global_capture_opts.save_file = NULL;
2135 global_capture_opts.has_autostop_packets =
2136 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_packets_cb));
2137 if (global_capture_opts.has_autostop_packets)
2138 global_capture_opts.autostop_packets =
2139 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_packets_sb));
2141 global_capture_opts.has_autostop_duration =
2142 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_duration_cb));
2143 if (global_capture_opts.has_autostop_duration) {
2144 global_capture_opts.autostop_duration =
2145 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_duration_sb));
2146 global_capture_opts.autostop_duration =
2147 time_unit_option_menu_get_value(stop_duration_om, global_capture_opts.autostop_duration);
2150 global_capture_opts.real_time_mode =
2151 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sync_cb));
2154 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(auto_scroll_cb));
2156 global_capture_opts.show_info =
2157 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hide_info_cb));
2159 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_resolv_cb)))
2160 g_resolv_flags |= RESOLV_MAC;
2162 g_resolv_flags &= ~RESOLV_MAC;
2163 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(n_resolv_cb)))
2164 g_resolv_flags |= RESOLV_NETWORK;
2166 g_resolv_flags &= ~RESOLV_NETWORK;
2167 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(t_resolv_cb)))
2168 g_resolv_flags |= RESOLV_TRANSPORT;
2170 g_resolv_flags &= ~RESOLV_TRANSPORT;
2172 global_capture_opts.has_ring_num_files =
2173 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb));
2175 global_capture_opts.ring_num_files =
2176 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ringbuffer_nbf_sb));
2177 if (global_capture_opts.ring_num_files > RINGBUFFER_MAX_NUM_FILES)
2178 global_capture_opts.ring_num_files = RINGBUFFER_MAX_NUM_FILES;
2179 #if RINGBUFFER_MIN_NUM_FILES > 0
2180 else if (global_capture_opts.ring_num_files < RINGBUFFER_MIN_NUM_FILES)
2181 global_capture_opts.ring_num_files = RINGBUFFER_MIN_NUM_FILES;
2184 global_capture_opts.multi_files_on =
2185 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(multi_files_on_cb));
2187 global_capture_opts.has_file_duration =
2188 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_duration_cb));
2189 if (global_capture_opts.has_file_duration) {
2190 global_capture_opts.file_duration =
2191 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(file_duration_sb));
2192 global_capture_opts.file_duration =
2193 time_unit_option_menu_get_value(file_duration_om, global_capture_opts.file_duration);
2196 global_capture_opts.has_autostop_files =
2197 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_files_cb));
2198 if (global_capture_opts.has_autostop_files)
2199 global_capture_opts.autostop_files =
2200 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_files_sb));
2202 if (global_capture_opts.multi_files_on) {
2203 global_capture_opts.has_autostop_filesize =
2204 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb));
2205 if (global_capture_opts.has_autostop_filesize) {
2206 tmp = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ring_filesize_sb));
2207 tmp = size_unit_option_menu_convert_value(ring_filesize_om, tmp);
2209 global_capture_opts.autostop_filesize = tmp;
2211 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
2212 "%sMultiple files: Requested filesize too large!%s\n\n"
2213 "The setting \"Next file every x byte(s)\" can't be greater than %u bytes (2GB).",
2214 simple_dialog_primary_start(), simple_dialog_primary_end(), G_MAXINT);
2219 /* test if the settings are ok for a ringbuffer */
2220 if (global_capture_opts.save_file == NULL) {
2221 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
2222 "%sMultiple files: No capture file name given!%s\n\n"
2223 "You must specify a filename if you want to use multiple files.",
2224 simple_dialog_primary_start(), simple_dialog_primary_end());
2226 } else if (!global_capture_opts.has_autostop_filesize && !global_capture_opts.has_file_duration) {
2227 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
2228 "%sMultiple files: No file limit given!%s\n\n"
2229 "You must specify a file size or duration at which is switched to the next capture file\n"
2230 "if you want to use multiple files.",
2231 simple_dialog_primary_start(), simple_dialog_primary_end());
2232 g_free(global_capture_opts.save_file);
2233 global_capture_opts.save_file = NULL;
2237 global_capture_opts.has_autostop_filesize =
2238 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_filesize_cb));
2239 if (global_capture_opts.has_autostop_filesize) {
2240 tmp = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_filesize_sb));
2241 tmp = size_unit_option_menu_convert_value(stop_filesize_om, tmp);
2243 global_capture_opts.autostop_filesize = tmp;
2245 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
2246 "%sStop Capture: Requested filesize too large!%s\n\n"
2247 "The setting \"... after x byte(s)\" can't be greater than %u bytes (2GB).",
2248 simple_dialog_primary_start(), simple_dialog_primary_end(), G_MAXINT);
2252 } /* multi_files_on */
2255 /* user requested to destroy the dialog */
2257 capture_prep_destroy_cb(GtkWidget *win, gpointer user_data _U_)
2260 #ifdef HAVE_PCAP_REMOTE
2261 GtkWidget *remote_w;
2264 /* Is there a file selection dialog associated with this
2265 Capture Options dialog? */
2266 fs = g_object_get_data(G_OBJECT(win), E_FILE_SEL_DIALOG_PTR_KEY);
2269 /* Yes. Destroy it. */
2273 /* Note that we no longer have a "Capture Options" dialog box. */
2277 /* update airpcap toolbar */
2278 airpcap_set_toolbar_stop_capture(airpcap_if_active);
2281 #ifdef HAVE_PCAP_REMOTE
2282 remote_w = g_object_get_data(G_OBJECT(win), E_CAP_REMOTE_DIALOG_PTR_KEY);
2283 if (remote_w != NULL)
2284 window_destroy(remote_w);
2288 /* user changed the interface entry */
2290 capture_prep_interface_changed_cb(GtkWidget *entry, gpointer argp)
2292 GtkWidget *linktype_om = argp;
2294 set_link_type_list(linktype_om, entry);
2298 * Adjust the sensitivity of various widgets as per the current setting
2302 capture_prep_adjust_sensitivity(GtkWidget *tb _U_, gpointer parent_w)
2306 *multi_files_on_cb, *ringbuffer_nbf_cb, *ringbuffer_nbf_sb, *ringbuffer_nbf_lb,
2307 *ring_filesize_cb, *ring_filesize_sb, *ring_filesize_om,
2308 *file_duration_cb, *file_duration_sb, *file_duration_om,
2309 *sync_cb, *auto_scroll_cb, *hide_info_cb,
2310 *stop_packets_cb, *stop_packets_sb, *stop_packets_lb,
2311 *stop_filesize_cb, *stop_filesize_sb, *stop_filesize_om,
2312 *stop_duration_cb, *stop_duration_sb, *stop_duration_om,
2313 *stop_files_cb, *stop_files_sb, *stop_files_lb;
2314 #ifdef HAVE_PCAP_SETSAMPLING
2315 GtkWidget *samp_count_rb, *samp_timer_rb,
2316 *samp_count_sb, *samp_timer_sb;
2320 if_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_IFACE_KEY);
2321 snap_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SNAP_CB_KEY);
2322 snap_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SNAP_SB_KEY);
2323 multi_files_on_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_MULTI_FILES_ON_CB_KEY);
2324 ringbuffer_nbf_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_NBF_CB_KEY);
2325 ringbuffer_nbf_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_NBF_SB_KEY);
2326 ringbuffer_nbf_lb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_NBF_LB_KEY);
2327 ring_filesize_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_CB_KEY);
2328 ring_filesize_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_SB_KEY);
2329 ring_filesize_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_OM_KEY);
2330 file_duration_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_DURATION_CB_KEY);
2331 file_duration_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_DURATION_SB_KEY);
2332 file_duration_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_DURATION_OM_KEY);
2333 sync_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SYNC_KEY);
2334 auto_scroll_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_AUTO_SCROLL_KEY);
2335 hide_info_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_HIDE_INFO_KEY);
2336 stop_packets_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_PACKETS_CB_KEY);
2337 stop_packets_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_PACKETS_SB_KEY);
2338 stop_packets_lb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_PACKETS_LB_KEY);
2339 stop_filesize_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_CB_KEY);
2340 stop_filesize_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_SB_KEY);
2341 stop_filesize_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_OM_KEY);
2342 stop_duration_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_CB_KEY);
2343 stop_duration_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_SB_KEY);
2344 stop_duration_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_OM_KEY);
2345 stop_files_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILES_CB_KEY);
2346 stop_files_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILES_SB_KEY);
2347 stop_files_lb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILES_LB_KEY);
2348 #ifdef HAVE_PCAP_SETSAMPLING
2349 samp_count_rb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_COUNT_RB_KEY);
2350 samp_timer_rb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_TIMER_RB_KEY);
2351 samp_count_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_COUNT_SB_KEY);
2352 samp_timer_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_TIMER_SB_KEY);
2355 /* The snapshot length spinbox is sensitive if the "Limit each packet
2356 to" checkbox is on. */
2357 gtk_widget_set_sensitive(GTK_WIDGET(snap_sb),
2358 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(snap_cb)));
2361 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sync_cb))) {
2362 /* "Update list of packets in real time" captures enabled; we don't
2363 support ring buffer mode for those captures, so turn ring buffer
2364 mode off if it's on, and make its toggle button, and the spin
2365 button for the number of ring buffer files (and the spin button's
2366 label), insensitive. */
2367 /* gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(multi_files_on_cb), FALSE);
2368 gtk_widget_set_sensitive(GTK_WIDGET(multi_files_on_cb), FALSE);*/
2370 /* Auto-scroll mode is meaningful only in "Update list of packets
2371 in real time" captures, so make its toggle button sensitive. */
2372 gtk_widget_set_sensitive(GTK_WIDGET(auto_scroll_cb), TRUE);
2374 /*gtk_widget_set_sensitive(GTK_WIDGET(hide_info_cb), TRUE);*/
2376 /* "Update list of packets in real time" captures disabled; that
2377 means ring buffer mode is OK, so make its toggle button
2379 /* gtk_widget_set_sensitive(GTK_WIDGET(multi_files_on_cb), TRUE);*/
2381 /* Auto-scroll mode is meaningful only in "Update list of packets
2382 in real time" captures, so make its toggle button insensitive. */
2383 gtk_widget_set_sensitive(GTK_WIDGET(auto_scroll_cb), FALSE);
2385 /*gtk_widget_set_sensitive(GTK_WIDGET(hide_info_cb), FALSE);*/
2388 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(multi_files_on_cb))) {
2389 /* Ring buffer mode enabled. */
2391 /* Force at least one of the "file switch" conditions (we need at least one) */
2392 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb)) == FALSE &&
2393 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_duration_cb)) == FALSE) {
2394 if (tb == ring_filesize_cb)
2395 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(file_duration_cb), TRUE);
2397 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ring_filesize_cb), TRUE);
2400 gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_cb), TRUE);
2401 gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_sb),
2402 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb)));
2403 gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_lb),
2404 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb)));
2406 /* The ring filesize spinbox is sensitive if the "Next capture file
2407 after N kilobytes" checkbox is on. */
2408 gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_cb), TRUE);
2409 gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_sb),
2410 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb)));
2411 gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_om),
2412 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb)));
2414 /* The ring duration spinbox is sensitive if the "Next capture file
2415 after N seconds" checkbox is on. */
2416 gtk_widget_set_sensitive(GTK_WIDGET(file_duration_cb), TRUE);
2417 gtk_widget_set_sensitive(GTK_WIDGET(file_duration_sb),
2418 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_duration_cb)));
2419 gtk_widget_set_sensitive(GTK_WIDGET(file_duration_om),
2420 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_duration_cb)));
2422 gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_cb), FALSE);
2423 gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_sb), FALSE);
2424 gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_om), FALSE);
2426 gtk_widget_set_sensitive(GTK_WIDGET(stop_files_cb), TRUE);
2427 gtk_widget_set_sensitive(GTK_WIDGET(stop_files_sb),
2428 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_files_cb)));
2429 gtk_widget_set_sensitive(GTK_WIDGET(stop_files_lb),
2430 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_files_cb)));
2432 /* Ring buffer mode disabled. */
2433 gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_cb), FALSE);
2434 gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_sb), FALSE);
2435 gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_lb), FALSE);
2437 gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_cb), FALSE);
2438 gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_sb),FALSE);
2439 gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_om),FALSE);
2441 gtk_widget_set_sensitive(GTK_WIDGET(file_duration_cb), FALSE);
2442 gtk_widget_set_sensitive(GTK_WIDGET(file_duration_sb),FALSE);
2443 gtk_widget_set_sensitive(GTK_WIDGET(file_duration_om),FALSE);
2445 /* The maximum file size spinbox is sensitive if the "Stop capture
2446 after N kilobytes" checkbox is on. */
2447 gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_cb), TRUE);
2448 gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_sb),
2449 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_filesize_cb)));
2450 gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_om),
2451 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_filesize_cb)));
2453 gtk_widget_set_sensitive(GTK_WIDGET(stop_files_cb), FALSE);
2454 gtk_widget_set_sensitive(GTK_WIDGET(stop_files_sb), FALSE);
2455 gtk_widget_set_sensitive(GTK_WIDGET(stop_files_lb), FALSE);
2458 /* The maximum packet count spinbox is sensitive if the "Stop capture
2459 after N packets" checkbox is on. */
2460 gtk_widget_set_sensitive(GTK_WIDGET(stop_packets_sb),
2461 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_packets_cb)));
2462 gtk_widget_set_sensitive(GTK_WIDGET(stop_packets_lb),
2463 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_packets_cb)));
2465 /* The capture duration spinbox is sensitive if the "Stop capture
2466 after N seconds" checkbox is on. */
2467 gtk_widget_set_sensitive(GTK_WIDGET(stop_duration_sb),
2468 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_duration_cb)));
2469 gtk_widget_set_sensitive(GTK_WIDGET(stop_duration_om),
2470 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_duration_cb)));
2472 #ifdef HAVE_PCAP_SETSAMPLING
2473 gtk_widget_set_sensitive(GTK_WIDGET(samp_count_sb),
2474 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(samp_count_rb)));
2475 gtk_widget_set_sensitive(GTK_WIDGET(samp_timer_sb),
2476 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(samp_timer_rb)));
2480 #endif /* HAVE_LIBPCAP */