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_IF_LIST_KEY "cap_if_list"
131 #define E_CAP_DATATX_UDP_CB_KEY "cap_datatx_udp_cb"
132 #define E_CAP_NOCAP_RPCAP_CB_KEY "cap_nocap_rpcap_cb"
133 #define E_CAP_REMOTE_DIALOG_PTR_KEY "cap_remote_dialog"
134 #define E_CAP_REMOTE_CALLER_PTR_KEY "cap_remote_caller"
135 #define E_REMOTE_HOST_TE_KEY "cap_remote_host"
136 #define E_REMOTE_PORT_TE_KEY "cap_remote_port"
137 #define E_REMOTE_AUTH_NULL_KEY "cap_remote_auth_null"
138 #define E_REMOTE_AUTH_PASSWD_KEY "cap_remote_auth_passwd"
139 #define E_REMOTE_USERNAME_LB_KEY "cap_remote_username_lb"
140 #define E_REMOTE_USERNAME_TE_KEY "cap_remote_username_te"
141 #define E_REMOTE_PASSWD_LB_KEY "cap_remote_passwd_lb"
142 #define E_REMOTE_PASSWD_TE_KEY "cap_remote_passwd_te"
143 #define E_CAP_OM_IFTYPE_VALUE_KEY "cap_om_iftype_value"
144 #define E_OPT_REMOTE_BT_KEY "cap_remote_opt_bt"
145 #define E_OPT_REMOTE_DIALOG_PTR_KEY "cap_remote_opt_dialog"
146 #define E_OPT_REMOTE_CALLER_PTR_KEY "cap_remote_opt_caller"
148 #ifdef HAVE_PCAP_SETSAMPLING
149 #define E_CAP_SAMP_NONE_RB_KEY "cap_samp_none_rb"
150 #define E_CAP_SAMP_COUNT_RB_KEY "cap_samp_count_rb"
151 #define E_CAP_SAMP_COUNT_SB_KEY "cap_samp_count_sb"
152 #define E_CAP_SAMP_TIMER_RB_KEY "cap_samp_timer_rb"
153 #define E_CAP_SAMP_TIMER_SB_KEY "cap_samp_timer_sb"
156 #define E_CAP_OM_LT_VALUE_KEY "cap_om_lt_value"
160 * Keep a static pointer to the current "Capture Options" window, if
161 * any, so that if somebody tries to do "Capture:Start" while there's
162 * already a "Capture Options" window up, we just pop up the existing
163 * one, rather than creating a new one.
165 static GtkWidget *cap_open_w;
166 static GtkWidget * dl_hdr_menu=NULL;
167 static GHashTable *linktype_history=NULL;
170 capture_prep_file_cb(GtkWidget *file_bt, GtkWidget *file_te);
173 select_link_type_cb(GtkWidget *w, gpointer data);
175 #ifdef HAVE_PCAP_REMOTE
177 select_if_type_cb(GtkWidget *w, gpointer data);
180 capture_remote_cb(GtkWidget *w, gpointer data);
184 capture_prep_adjust_sensitivity(GtkWidget *tb, gpointer parent_w);
187 capture_prep_destroy_cb(GtkWidget *win, gpointer user_data);
190 capture_prep_interface_changed_cb(GtkWidget *entry, gpointer parent_w);
193 capture_dlg_prep(gpointer parent_w);
196 /* stop the currently running capture */
198 capture_stop_cb(GtkWidget *w _U_, gpointer d _U_)
201 airpcap_set_toolbar_stop_capture(airpcap_if_active);
204 capture_stop(&global_capture_opts);
207 /* restart (stop - delete old file - start) running capture */
209 capture_restart_cb(GtkWidget *w _U_, gpointer d _U_)
212 airpcap_set_toolbar_start_capture(airpcap_if_active);
215 capture_restart(&global_capture_opts);
218 /* init the link type list */
219 /* (often this list has only one entry and will therefore be disabled) */
221 set_link_type_list(GtkWidget *linktype_om, GtkWidget *entry)
231 GtkWidget *lt_menu, *lt_menu_item;
233 gint linktype, linktype_select, linktype_count;
235 data_link_info_t *data_link_info;
236 gchar *linktype_menu_label;
237 guint num_supported_link_types;
238 GtkWidget *linktype_lb = g_object_get_data(G_OBJECT(linktype_om), E_CAP_LT_OM_LABEL_KEY);
240 GString *ip_str = g_string_new("IP address: ");
245 GtkWidget *advanced_bt;
248 /* Deallocate the existing menu for Datalink header type */
249 if (dl_hdr_menu != NULL)
250 gtk_widget_destroy(dl_hdr_menu);
252 lt_menu = gtk_menu_new();
253 dl_hdr_menu= lt_menu;
254 entry_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
255 if_text = g_strstrip(entry_text);
256 if_name = g_strdup(get_if_name(if_text));
258 linktype_p = g_hash_table_lookup (linktype_history, if_name);
260 linktype = *linktype_p;
262 linktype = capture_dev_user_linktype_find(if_name);
266 /* is it an airpcap interface??? */
267 /* retrieve the advanced button pointer */
268 advanced_bt = g_object_get_data(G_OBJECT(entry),AIRPCAP_OPTIONS_ADVANCED_KEY);
269 airpcap_if_selected = get_airpcap_if_from_name(airpcap_if_list,if_name);
270 airpcap_enable_toolbar_widgets(airpcap_tb,FALSE);
271 if (airpcap_if_selected != NULL) {
272 gtk_widget_set_sensitive(advanced_bt,TRUE);
274 gtk_widget_set_sensitive(advanced_bt,FALSE);
279 * If the interface name is in the list of known interfaces, get
280 * its list of link-layer types and set the option menu to display it.
282 * If it's not, don't bother - the user might be in the middle of
283 * editing the list, or it might be a remote device in which case
284 * getting the list could take an arbitrarily-long period of time.
285 * The list currently won't contain any remote devices (as
286 * "pcap_findalldevs()" doesn't know about remote devices, and neither
287 * does the code we use if "pcap_findalldevs()" isn't available), but
288 * should contain all the local devices on which you can capture.
291 if (*if_name != '\0') {
293 * Try to get the list of known interfaces.
295 #ifdef HAVE_PCAP_REMOTE
296 if (global_capture_opts.src_type == CAPTURE_IFREMOTE)
297 if_list = (GList *) g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IF_LIST_KEY);
299 if_list = capture_interface_list(&err, NULL);
301 if_list = capture_interface_list(&err, NULL);
303 if (if_list != NULL) {
305 * We have the list - check it.
307 for (if_entry = if_list; if_entry != NULL;
308 if_entry = g_list_next(if_entry)) {
309 if_info = if_entry->data;
310 if (strcmp(if_info->name, if_name) == 0) {
313 * Get the list of link-layer types for it.
315 #ifdef HAVE_PCAP_REMOTE
316 if (global_capture_opts.src_type == CAPTURE_IFLOCAL)
317 /* Not able to get link-layer for remote interfaces */
319 lt_list = capture_pcap_linktype_list(if_name, NULL);
321 /* create string of list of IP addresses of this interface */
322 for (; (curr_ip = g_slist_nth(if_info->ip_addr, ips)) != NULL; ips++) {
324 g_string_append(ip_str, ", ");
326 ip_addr = (if_addr_t *)curr_ip->data;
327 switch (ip_addr->type) {
330 g_string_append(ip_str,
331 ip_to_str((guint8 *)&ip_addr->ip_addr.ip4_addr));
335 g_string_append(ip_str,
336 ip6_to_str((struct e_in6_addr *)&ip_addr->ip_addr.ip6_addr));
340 g_assert_not_reached();
344 if (if_info->loopback)
345 g_string_append(ip_str, " (loopback)");
348 #ifdef HAVE_PCAP_REMOTE
349 /* Only delete if fetched local */
350 if (global_capture_opts.src_type == CAPTURE_IFLOCAL)
352 free_interface_list(if_list);
358 num_supported_link_types = 0;
361 for (lt_entry = lt_list; lt_entry != NULL; lt_entry = g_list_next(lt_entry)) {
362 data_link_info = lt_entry->data;
363 if (data_link_info->description != NULL) {
364 lt_menu_item = gtk_menu_item_new_with_label(data_link_info->description);
365 g_object_set_data(G_OBJECT(lt_menu_item), E_CAP_LT_OM_KEY, linktype_om);
366 g_signal_connect(lt_menu_item, "activate", G_CALLBACK(select_link_type_cb),
367 GINT_TO_POINTER(data_link_info->dlt));
368 num_supported_link_types++;
370 /* Not supported - tell them about it but don't let them select it. */
371 linktype_menu_label = g_strdup_printf("%s (not supported)",
372 data_link_info->name);
373 lt_menu_item = gtk_menu_item_new_with_label(linktype_menu_label);
374 g_free(linktype_menu_label);
376 if (data_link_info->dlt == linktype) {
377 /* Found a matching dlt, selecth this */
378 linktype_select = linktype_count;
380 gtk_menu_shell_append(GTK_MENU_SHELL(lt_menu), lt_menu_item);
381 gtk_widget_show(lt_menu_item);
384 if (lt_list == NULL) {
385 lt_menu_item = gtk_menu_item_new_with_label("(not supported)");
386 gtk_menu_shell_append(GTK_MENU_SHELL(lt_menu), lt_menu_item);
387 gtk_widget_show(lt_menu_item);
389 free_pcap_linktype_list(lt_list);
391 gtk_option_menu_set_menu(GTK_OPTION_MENU(linktype_om), lt_menu);
392 gtk_widget_set_sensitive(linktype_lb, num_supported_link_types >= 2);
393 gtk_widget_set_sensitive(linktype_om, num_supported_link_types >= 2);
395 g_object_set_data(G_OBJECT(linktype_om), E_CAP_OM_LT_VALUE_KEY, GINT_TO_POINTER(linktype));
396 global_capture_opts.linktype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(linktype_om), E_CAP_OM_LT_VALUE_KEY));
398 /* Restore the menu to the last index used */
399 gtk_option_menu_set_history(GTK_OPTION_MENU(linktype_om),linktype_select);
400 if_ip_lb = g_object_get_data(G_OBJECT(linktype_om), E_CAP_IFACE_KEY);
402 g_string_append(ip_str, "unknown");
404 gtk_label_set_text(GTK_LABEL(if_ip_lb), ip_str->str);
405 #if GTK_CHECK_VERSION(2,6,0)
406 gtk_label_set_ellipsize(GTK_LABEL(if_ip_lb), PANGO_ELLIPSIZE_MIDDLE);
408 g_string_free(ip_str, TRUE);
412 #define TIME_UNIT_SECOND 0
413 #define TIME_UNIT_MINUTE 1
414 #define TIME_UNIT_HOUR 2
415 #define TIME_UNIT_DAY 3
416 #define MAX_TIME_UNITS 4
417 static const char *time_unit_name[MAX_TIME_UNITS] = {
424 /* create one of the duration options */
425 /* (and select the matching unit depending on the given value) */
426 static GtkWidget *time_unit_option_menu_new(guint32 value) {
427 GtkWidget *unit_om, *menu, *menu_item;
430 unit_om=gtk_option_menu_new();
432 for(i=0;i<MAX_TIME_UNITS;i++){
433 menu_item=gtk_menu_item_new_with_label(time_unit_name[i]);
434 g_object_set_data(G_OBJECT(menu_item), "time_unit", GINT_TO_POINTER(i));
435 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
438 /* the selected menu item can't be changed, once the option_menu
439 is created, so set the matching menu item now */
441 if(value >= 60 * 60 * 24) {
442 gtk_menu_set_active(GTK_MENU(menu), TIME_UNIT_DAY);
445 if(value >= 60 * 60) {
446 gtk_menu_set_active(GTK_MENU(menu), TIME_UNIT_HOUR);
450 gtk_menu_set_active(GTK_MENU(menu), TIME_UNIT_MINUTE);
453 gtk_menu_set_active(GTK_MENU(menu), TIME_UNIT_SECOND);
458 gtk_option_menu_set_menu(GTK_OPTION_MENU(unit_om), menu);
463 /* convert time value from raw to displayed (e.g. 60s -> 1min) */
464 static guint32 time_unit_option_menu_convert_value(
468 if(value >= 60 * 60 * 24) {
469 return value / (60 * 60 * 24);
473 if(value >= 60 * 60) {
474 return value / (60 * 60);
486 /* get raw value from unit and value fields */
487 static guint32 time_unit_option_menu_get_value(
491 GtkWidget *menu, *menu_item;
494 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(unit_om));
495 menu_item = gtk_menu_get_active(GTK_MENU(menu));
496 unit = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(menu_item), "time_unit"));
500 case(TIME_UNIT_SECOND):
502 case(TIME_UNIT_MINUTE):
504 case(TIME_UNIT_HOUR):
505 return value * 60 * 60;
507 return value * 60 * 60 * 24;
509 g_assert_not_reached();
515 #define SIZE_UNIT_KILOBYTES 0
516 #define SIZE_UNIT_MEGABYTES 1
517 #define SIZE_UNIT_GIGABYTES 2
518 #define MAX_SIZE_UNITS 3
519 static const char *size_unit_name[MAX_SIZE_UNITS] = {
525 /* create one of the size options */
526 /* (and select the matching unit depending on the given value) */
527 static GtkWidget *size_unit_option_menu_new(guint32 value) {
528 GtkWidget *unit_om, *menu, *menu_item;
531 unit_om=gtk_option_menu_new();
533 for(i=0;i<MAX_SIZE_UNITS;i++){
534 menu_item=gtk_menu_item_new_with_label(size_unit_name[i]);
535 g_object_set_data(G_OBJECT(menu_item), "size_unit", GINT_TO_POINTER(i));
536 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
539 /* the selected menu item can't be changed, once the option_menu
540 is created, so set the matching menu item now */
542 if(value >= 1024 * 1024) {
543 gtk_menu_set_active(GTK_MENU(menu), SIZE_UNIT_GIGABYTES);
547 gtk_menu_set_active(GTK_MENU(menu), SIZE_UNIT_MEGABYTES);
550 gtk_menu_set_active(GTK_MENU(menu), SIZE_UNIT_KILOBYTES);
554 gtk_option_menu_set_menu(GTK_OPTION_MENU(unit_om), menu);
559 /* convert size value from raw to displayed (e.g. 1024 Bytes -> 1 KB) */
560 static guint32 size_unit_option_menu_set_value(
564 if(value >= 1024 * 1024) {
565 return value / (1024 * 1024);
570 return value / (1024);
577 /* get raw value from unit and value fields */
578 static guint32 size_unit_option_menu_convert_value(
582 GtkWidget *menu, *menu_item;
585 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(unit_om));
586 menu_item = gtk_menu_get_active(GTK_MENU(menu));
587 unit = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(menu_item), "size_unit"));
591 case(SIZE_UNIT_KILOBYTES):
593 case(SIZE_UNIT_MEGABYTES):
594 if(value > G_MAXINT / 1024) {
599 case(SIZE_UNIT_GIGABYTES):
600 if(value > G_MAXINT / (1024 * 1024)) {
603 return value * 1024 * 1024;
606 g_assert_not_reached();
613 * Sets the toolbar before calling the advanced dialog with for the right interface
616 options_airpcap_advanced_cb(GtkWidget *w _U_, gpointer d _U_)
620 from_widget = (gint*)g_malloc(sizeof(gint));
621 *from_widget = AIRPCAP_ADVANCED_FROM_OPTIONS;
622 g_object_set_data(G_OBJECT(airpcap_tb),AIRPCAP_ADVANCED_FROM_KEY,from_widget);
624 airpcap_if_active = airpcap_if_selected;
625 airpcap_enable_toolbar_widgets(airpcap_tb,FALSE);
626 display_airpcap_advanced_cb(w,d);
630 #ifdef HAVE_PCAP_REMOTE
631 /* PCAP interface type menu item */
637 /* List of available types of PCAP interface */
638 static struct iftype_info iftype[] = {
639 { CAPTURE_IFLOCAL, "Local" },
640 { CAPTURE_IFREMOTE, "Remote" }
643 /* Fill the menu of available types of interfaces */
645 iftype_option_menu_new(capture_source value)
647 GtkWidget *iftype_om, *menu, *menu_item;
648 unsigned int i, active = 0;
650 iftype_om = gtk_option_menu_new();
651 menu = gtk_menu_new();
653 for (i = 0; i < sizeof(iftype) / sizeof(iftype[0]); i++)
655 menu_item = gtk_menu_item_new_with_label(iftype[i].name);
656 g_object_set_data(G_OBJECT(menu_item), E_CAP_IFTYPE_OM_KEY, iftype_om);
657 g_signal_connect(menu_item, "activate", G_CALLBACK(select_if_type_cb),
658 GINT_TO_POINTER((int)iftype[i].id));
659 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
660 if (value == iftype[i].id)
664 gtk_menu_set_active(GTK_MENU(menu), active);
665 gtk_option_menu_set_menu(GTK_OPTION_MENU(iftype_om), menu);
670 /* Retrieve the list of local or remote interfaces according to selected
671 * options and re-fill inteface name combobox */
673 update_interface_list()
675 GtkWidget *if_cb, *iftype_om, *remote_bt;
676 GList *if_list, *combo_list;
680 if (cap_open_w == NULL)
683 if_cb = (GtkWidget *)g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFACE_KEY);
684 iftype_om = g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFTYPE_OM_KEY);
685 remote_bt = g_object_get_data(G_OBJECT(iftype_om), E_OPT_REMOTE_BT_KEY);
687 if_list = (GList *) g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IF_LIST_KEY);
689 free_interface_list(if_list);
691 if (global_capture_opts.src_type == CAPTURE_IFREMOTE) {
692 if_list = get_remote_interface_list(global_capture_opts.remote_host,
693 global_capture_opts.remote_port,
694 global_capture_opts.auth_type,
695 global_capture_opts.auth_username,
696 global_capture_opts.auth_password,
698 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_IF_LIST_KEY, if_list);
700 if_list = capture_interface_list(&err, &err_str);
701 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_IF_LIST_KEY, NULL);
704 if (if_list == NULL && err == CANT_GET_INTERFACE_LIST) {
705 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
708 if (global_capture_opts.src_type == CAPTURE_IFREMOTE) {
711 /* Fall back to local interfaces */
712 global_capture_opts.src_type = CAPTURE_IFLOCAL;
713 g_object_set_data(G_OBJECT(iftype_om), E_CAP_OM_IFTYPE_VALUE_KEY,
714 GINT_TO_POINTER(CAPTURE_IFLOCAL));
716 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(iftype_om));
717 gtk_menu_set_active(GTK_MENU(menu), CAPTURE_IFLOCAL);
721 gtk_combo_set_popdown_strings(GTK_COMBO(if_cb), NULL);
722 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry), "");
724 combo_list = build_capture_combo_list(if_list, TRUE);
725 gtk_combo_set_popdown_strings(GTK_COMBO(if_cb), combo_list);
726 if (combo_list == NULL)
727 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry), "");
729 free_capture_combo_list(combo_list);
730 #ifdef HAVE_PCAP_REMOTE
731 /* Only delete if fetched local */
732 if (global_capture_opts.src_type == CAPTURE_IFLOCAL)
734 free_interface_list(if_list);
736 if (global_capture_opts.src_type == CAPTURE_IFREMOTE)
737 gtk_widget_set_sensitive(remote_bt, TRUE);
739 gtk_widget_set_sensitive(remote_bt, FALSE);
742 /* User changed an interface entry of "Remote interface" dialog */
744 capture_remote_adjust_sensitivity(GtkWidget *tb _U_, gpointer parent_w)
746 GtkWidget *auth_passwd_rb,
747 *username_lb, *username_te,
748 *passwd_lb, *passwd_te;
751 auth_passwd_rb = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w),
752 E_REMOTE_AUTH_PASSWD_KEY);
753 username_lb = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w),
754 E_REMOTE_USERNAME_LB_KEY);
755 username_te = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w),
756 E_REMOTE_USERNAME_TE_KEY);
757 passwd_lb = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_REMOTE_PASSWD_LB_KEY);
758 passwd_te = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_REMOTE_PASSWD_TE_KEY);
760 state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(auth_passwd_rb));
761 gtk_widget_set_sensitive(GTK_WIDGET(username_lb), state);
762 gtk_widget_set_sensitive(GTK_WIDGET(username_te), state);
763 gtk_widget_set_sensitive(GTK_WIDGET(passwd_lb), state);
764 gtk_widget_set_sensitive(GTK_WIDGET(passwd_te), state);
767 /* user requested to destroy the dialog */
769 capture_remote_destroy_cb(GtkWidget *win, gpointer user_data _U_)
773 caller = g_object_get_data(G_OBJECT(win), E_CAP_REMOTE_CALLER_PTR_KEY);
774 g_object_set_data(G_OBJECT(caller), E_CAP_REMOTE_DIALOG_PTR_KEY, NULL);
777 /* user requested to accept remote interface options */
779 capture_remote_ok_cb(GtkWidget *win _U_, GtkWidget *remote_w)
781 GtkWidget *host_te, *port_te, *auth_pwd_rb, *username_te, *passwd_te,
782 *auth_null_rb, *auth_passwd_rb;
784 if (remote_w == NULL)
787 host_te = (GtkWidget *)g_object_get_data(G_OBJECT(remote_w), E_REMOTE_HOST_TE_KEY);
788 port_te = (GtkWidget *)g_object_get_data(G_OBJECT(remote_w), E_REMOTE_PORT_TE_KEY);
789 auth_pwd_rb = (GtkWidget *)g_object_get_data(G_OBJECT(remote_w),
790 E_REMOTE_AUTH_PASSWD_KEY);
791 username_te = (GtkWidget *)g_object_get_data(G_OBJECT(remote_w),
792 E_REMOTE_USERNAME_TE_KEY);
793 passwd_te = (GtkWidget *)g_object_get_data(G_OBJECT(remote_w), E_REMOTE_PASSWD_TE_KEY);
794 auth_null_rb = (GtkWidget *) g_object_get_data(G_OBJECT(remote_w), E_REMOTE_AUTH_NULL_KEY);
795 auth_passwd_rb = (GtkWidget *) g_object_get_data(G_OBJECT(remote_w), E_REMOTE_AUTH_PASSWD_KEY);
797 g_free(global_capture_opts.remote_host);
798 global_capture_opts.remote_host = g_strdup(gtk_entry_get_text(GTK_ENTRY(host_te)));
799 g_free(global_capture_opts.remote_port);
800 global_capture_opts.remote_port = g_strdup(gtk_entry_get_text(GTK_ENTRY(port_te)));
801 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(auth_passwd_rb)))
802 global_capture_opts.auth_type = CAPTURE_AUTH_PWD;
804 global_capture_opts.auth_type = CAPTURE_AUTH_NULL;
806 g_free(global_capture_opts.auth_username);
807 global_capture_opts.auth_username =
808 g_strdup(gtk_entry_get_text(GTK_ENTRY(username_te)));
810 g_free(global_capture_opts.auth_password);
811 global_capture_opts.auth_password =
812 g_strdup(gtk_entry_get_text(GTK_ENTRY(passwd_te)));
814 global_capture_opts.src_type = CAPTURE_IFREMOTE;
816 window_destroy(GTK_WIDGET(remote_w));
817 update_interface_list();
820 /* Show remote capture interface parameters dialog */
822 capture_remote_cb(GtkWidget *w, gpointer d _U_)
824 GtkWidget *caller, *remote_w,
826 *host_lb, *host_te, *port_lb, *port_te,
828 *auth_null_rb, *auth_passwd_rb, *auth_passwd_tb,
829 *user_lb, *user_te, *passwd_lb, *passwd_te,
830 *bbox, *ok_bt, *cancel_bt;
832 GtkTooltips *tooltips;
835 caller = gtk_widget_get_toplevel(w);
836 remote_w = g_object_get_data(G_OBJECT(caller), E_CAP_REMOTE_DIALOG_PTR_KEY);
837 if (remote_w != NULL)
839 reactivate_window(remote_w);
843 title = create_user_window_title("Wireshark: Remote Interface");
844 remote_w = dlg_window_new(title);
845 g_object_set_data(G_OBJECT(remote_w), E_CAP_REMOTE_CALLER_PTR_KEY, caller);
846 g_object_set_data(G_OBJECT(caller), E_CAP_REMOTE_DIALOG_PTR_KEY, remote_w);
849 tooltips = gtk_tooltips_new();
851 main_vb = gtk_vbox_new(FALSE, 0);
852 gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);
853 gtk_container_add(GTK_CONTAINER(remote_w), main_vb);
855 /* Host/port table */
856 host_tb = gtk_table_new(2, 2, FALSE);
857 gtk_table_set_row_spacings(GTK_TABLE(host_tb), 3);
858 gtk_table_set_col_spacings(GTK_TABLE(host_tb), 3);
859 gtk_box_pack_start(GTK_BOX(main_vb), host_tb, FALSE, FALSE, 0);
862 host_lb = gtk_label_new("Host:");
863 gtk_table_attach_defaults(GTK_TABLE(host_tb), host_lb, 0, 1, 0, 1);
865 host_te = gtk_entry_new();
866 gtk_tooltips_set_tip(tooltips, host_te,
867 "Enter the hostname or host IP address to be used as a source "
868 "for remote capture.", NULL);
869 gtk_table_attach_defaults(GTK_TABLE(host_tb), host_te, 1, 2, 0, 1);
870 if (global_capture_opts.remote_host != NULL)
871 gtk_entry_set_text(GTK_ENTRY(host_te), global_capture_opts.remote_host);
874 port_lb = gtk_label_new("Port:");
875 gtk_table_attach_defaults(GTK_TABLE(host_tb), port_lb, 0, 1, 1, 2);
877 port_te = gtk_entry_new();
878 gtk_tooltips_set_tip(tooltips, port_te,
879 "Enter the TCP port number used by RPCAP server at remote host "
880 "(leave it empty for default port number).", NULL);
881 gtk_table_attach_defaults(GTK_TABLE(host_tb), port_te, 1, 2, 1, 2);
882 if (global_capture_opts.remote_port != NULL)
883 gtk_entry_set_text(GTK_ENTRY(port_te), global_capture_opts.remote_port);
885 /* Authentication options frame */
886 auth_fr = gtk_frame_new("Authentication");
887 gtk_container_add(GTK_CONTAINER(main_vb), auth_fr);
889 auth_vb = gtk_vbox_new(FALSE, 3);
890 gtk_container_set_border_width(GTK_CONTAINER(auth_vb), 5);
891 gtk_container_add(GTK_CONTAINER(auth_fr), auth_vb);
893 auth_null_rb = gtk_radio_button_new_with_label(NULL,
894 "Null authentication");
895 gtk_box_pack_start(GTK_BOX(auth_vb), auth_null_rb, TRUE, TRUE, 0);
897 auth_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(auth_null_rb));
898 auth_passwd_rb = gtk_radio_button_new_with_label(auth_group,
899 "Password authentication");
900 gtk_box_pack_start(GTK_BOX(auth_vb), auth_passwd_rb, TRUE, TRUE, 0);
901 g_signal_connect(auth_passwd_rb, "toggled",
902 G_CALLBACK(capture_remote_adjust_sensitivity), remote_w);
904 auth_passwd_tb = gtk_table_new(2, 2, FALSE);
905 gtk_table_set_row_spacings(GTK_TABLE(auth_passwd_tb), 3);
906 gtk_table_set_col_spacings(GTK_TABLE(auth_passwd_tb), 3);
907 gtk_box_pack_start(GTK_BOX(auth_vb), auth_passwd_tb, FALSE, FALSE, 0);
909 user_lb = gtk_label_new("Username:");
910 gtk_table_attach_defaults(GTK_TABLE(auth_passwd_tb), user_lb, 0, 1, 0, 1);
912 user_te = gtk_entry_new();
913 gtk_table_attach_defaults(GTK_TABLE(auth_passwd_tb), user_te, 1, 2, 0, 1);
914 if (global_capture_opts.auth_username != NULL)
915 gtk_entry_set_text(GTK_ENTRY(user_te), global_capture_opts.auth_username);
917 passwd_lb = gtk_label_new("Password:");
918 gtk_table_attach_defaults(GTK_TABLE(auth_passwd_tb), passwd_lb, 0, 1, 1, 2);
920 passwd_te = gtk_entry_new();
921 gtk_entry_set_visibility(GTK_ENTRY(passwd_te), FALSE);
922 gtk_table_attach_defaults(GTK_TABLE(auth_passwd_tb), passwd_te, 1, 2, 1, 2);
923 if (global_capture_opts.auth_password != NULL)
924 gtk_entry_set_text(GTK_ENTRY(passwd_te), global_capture_opts.auth_password);
926 /* Button row: "Start" and "Cancel" buttons */
927 bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL);
928 gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 5);
930 ok_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK);
931 g_signal_connect(ok_bt, "clicked", G_CALLBACK(capture_remote_ok_cb), remote_w);
932 gtk_tooltips_set_tip(tooltips, ok_bt,
933 "Accept remote host parameters and lookup "
934 "remote interfaces.", NULL);
936 cancel_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
937 gtk_tooltips_set_tip(tooltips, cancel_bt,
938 "Cancel and exit dialog.", NULL);
939 window_set_cancel_button(remote_w, cancel_bt, window_cancel_button_cb);
941 gtk_widget_grab_default(ok_bt);
943 /* Catch the "activate" signal on the text
944 entries, so that if the user types Return there, we act as if the
945 "OK" button had been selected, as happens if Return is typed if some
946 widget that *doesn't* handle the Return key has the input focus. */
947 dlg_set_activate(host_te, ok_bt);
948 dlg_set_activate(port_te, ok_bt);
949 dlg_set_activate(user_te, ok_bt);
950 dlg_set_activate(passwd_te, ok_bt);
952 g_signal_connect(remote_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
953 g_signal_connect(remote_w, "destroy", G_CALLBACK(capture_remote_destroy_cb), NULL);
955 g_object_set_data(G_OBJECT(remote_w), E_REMOTE_HOST_TE_KEY, host_te);
956 g_object_set_data(G_OBJECT(remote_w), E_REMOTE_PORT_TE_KEY, port_te);
957 g_object_set_data(G_OBJECT(remote_w), E_REMOTE_AUTH_NULL_KEY, auth_null_rb);
958 g_object_set_data(G_OBJECT(remote_w), E_REMOTE_AUTH_PASSWD_KEY, auth_passwd_rb);
959 g_object_set_data(G_OBJECT(remote_w), E_REMOTE_USERNAME_LB_KEY, user_lb);
960 g_object_set_data(G_OBJECT(remote_w), E_REMOTE_USERNAME_TE_KEY, user_te);
961 g_object_set_data(G_OBJECT(remote_w), E_REMOTE_PASSWD_LB_KEY, passwd_lb);
962 g_object_set_data(G_OBJECT(remote_w), E_REMOTE_PASSWD_TE_KEY, passwd_te);
964 if (global_capture_opts.auth_type == CAPTURE_AUTH_PWD)
965 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(auth_passwd_rb), TRUE);
967 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(auth_null_rb), TRUE);
968 capture_remote_adjust_sensitivity(NULL, remote_w);
970 gtk_widget_show_all(remote_w);
971 window_present(remote_w);
974 /* user requested to destroy the dialog */
976 options_remote_destroy_cb(GtkWidget *win, gpointer user_data _U_)
980 caller = g_object_get_data(G_OBJECT(win), E_OPT_REMOTE_CALLER_PTR_KEY);
981 g_object_set_data(G_OBJECT(caller), E_OPT_REMOTE_DIALOG_PTR_KEY, NULL);
984 /* user requested to accept remote interface options */
986 options_remote_ok_cb(GtkWidget *win _U_, GtkWidget *parent_w)
988 GtkWidget *datatx_udp_cb, *nocap_rpcap_cb;
989 #ifdef HAVE_PCAP_SETSAMPLING
990 GtkWidget *samp_none_rb, *samp_count_rb, *samp_timer_rb,
991 *samp_count_sb, *samp_timer_sb;
994 if (parent_w == NULL)
997 datatx_udp_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_DATATX_UDP_CB_KEY);
998 nocap_rpcap_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_NOCAP_RPCAP_CB_KEY);
1000 #ifdef HAVE_PCAP_SETSAMPLING
1001 samp_none_rb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_NONE_RB_KEY);
1002 samp_count_rb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_COUNT_RB_KEY);
1003 samp_timer_rb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_TIMER_RB_KEY);
1004 samp_count_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_COUNT_SB_KEY);
1005 samp_timer_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_TIMER_SB_KEY);
1008 global_capture_opts.datatx_udp =
1009 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(datatx_udp_cb));
1010 global_capture_opts.nocap_rpcap =
1011 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(nocap_rpcap_cb));
1013 #ifdef HAVE_PCAP_SETSAMPLING
1014 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(samp_none_rb)))
1015 global_capture_opts.sampling_method = CAPTURE_SAMP_NONE;
1016 else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(samp_count_rb)))
1018 global_capture_opts.sampling_method = CAPTURE_SAMP_BY_COUNT;
1019 global_capture_opts.sampling_param = gtk_spin_button_get_value_as_int(
1020 GTK_SPIN_BUTTON(samp_count_sb));
1022 else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(samp_timer_rb)))
1024 global_capture_opts.sampling_method = CAPTURE_SAMP_BY_TIMER;
1025 global_capture_opts.sampling_param = gtk_spin_button_get_value_as_int(
1026 GTK_SPIN_BUTTON(samp_timer_sb));
1030 window_destroy(GTK_WIDGET(parent_w));
1033 #ifdef HAVE_PCAP_SETSAMPLING
1035 options_prep_adjust_sensitivity(GtkWidget *tb _U_, gpointer parent_w)
1037 GtkWidget *samp_count_rb, *samp_timer_rb,
1038 *samp_count_sb, *samp_timer_sb;
1040 samp_count_rb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_COUNT_RB_KEY);
1041 samp_timer_rb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_TIMER_RB_KEY);
1042 samp_count_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_COUNT_SB_KEY);
1043 samp_timer_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SAMP_TIMER_SB_KEY);
1045 if (samp_count_sb && samp_count_rb)
1046 gtk_widget_set_sensitive(GTK_WIDGET(samp_count_sb),
1047 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(samp_count_rb)));
1049 if (samp_timer_sb && samp_timer_rb)
1050 gtk_widget_set_sensitive(GTK_WIDGET(samp_timer_sb),
1051 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(samp_timer_rb)));
1056 options_remote_cb(GtkWidget *w _U_, gpointer d _U_)
1058 GtkWidget *opt_remote_w, *main_vb;
1059 GtkWidget *caller, *bbox, *ok_bt, *cancel_bt;
1060 GtkTooltips *tooltips;
1061 GtkWidget *capture_fr, *capture_vb;
1062 GtkWidget *nocap_rpcap_cb, *datatx_udp_cb;
1063 #ifdef HAVE_PCAP_SETSAMPLING
1064 GtkWidget *sampling_fr, *sampling_vb, *sampling_tb, *sampling_lb,
1065 *samp_none_rb, *samp_count_rb, *samp_timer_rb,
1066 *samp_count_sb, *samp_timer_sb;
1067 GtkAdjustment *samp_count_adj, *samp_timer_adj;
1071 caller = gtk_widget_get_toplevel(w);
1072 opt_remote_w = g_object_get_data(G_OBJECT(caller), E_OPT_REMOTE_DIALOG_PTR_KEY);
1073 if (opt_remote_w != NULL) {
1074 reactivate_window(opt_remote_w);
1078 opt_remote_w = dlg_window_new("Remote Capture Settings");
1079 g_object_set_data(G_OBJECT(opt_remote_w), E_OPT_REMOTE_CALLER_PTR_KEY, caller);
1080 g_object_set_data(G_OBJECT(caller), E_OPT_REMOTE_DIALOG_PTR_KEY, opt_remote_w);
1082 tooltips = gtk_tooltips_new();
1084 main_vb = gtk_vbox_new(FALSE, 0);
1085 gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);
1086 gtk_container_add(GTK_CONTAINER(opt_remote_w), main_vb);
1088 /* Remote capture options */
1089 capture_fr = gtk_frame_new("Capture Options");
1090 gtk_container_add(GTK_CONTAINER(main_vb), capture_fr);
1092 capture_vb = gtk_vbox_new(FALSE, 0);
1093 gtk_container_set_border_width(GTK_CONTAINER(capture_vb), 5);
1094 gtk_container_add(GTK_CONTAINER(capture_fr), capture_vb);
1096 nocap_rpcap_cb = gtk_check_button_new_with_mnemonic("Do not capture own RPCAP traffic");
1097 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(nocap_rpcap_cb),
1098 global_capture_opts.nocap_rpcap);
1099 gtk_container_add(GTK_CONTAINER(capture_vb), nocap_rpcap_cb);
1101 datatx_udp_cb = gtk_check_button_new_with_mnemonic("Use UDP for data transfer");
1102 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(datatx_udp_cb),
1103 global_capture_opts.datatx_udp);
1104 gtk_container_add(GTK_CONTAINER(capture_vb), datatx_udp_cb);
1106 #ifdef HAVE_PCAP_SETSAMPLING
1107 /* Sampling options */
1108 sampling_fr = gtk_frame_new("Sampling Options");
1109 gtk_container_add(GTK_CONTAINER(main_vb), sampling_fr);
1111 sampling_vb = gtk_vbox_new(FALSE, 0);
1112 gtk_container_set_border_width(GTK_CONTAINER(sampling_vb), 5);
1113 gtk_container_add(GTK_CONTAINER(sampling_fr), sampling_vb);
1115 sampling_tb = gtk_table_new(3, 3, FALSE);
1116 gtk_table_set_row_spacings(GTK_TABLE(sampling_tb), 1);
1117 gtk_table_set_col_spacings(GTK_TABLE(sampling_tb), 3);
1118 gtk_box_pack_start(GTK_BOX(sampling_vb), sampling_tb, FALSE, FALSE, 0);
1120 /* "No sampling" row */
1121 samp_none_rb = gtk_radio_button_new_with_label(NULL, "None");
1122 if (global_capture_opts.sampling_method == CAPTURE_SAMP_NONE)
1123 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(samp_none_rb), TRUE);
1124 g_signal_connect(samp_none_rb, "toggled",
1125 G_CALLBACK(options_prep_adjust_sensitivity), opt_remote_w);
1126 gtk_table_attach_defaults(GTK_TABLE(sampling_tb), samp_none_rb, 0, 1, 0, 1);
1128 /* "Sampling by counter" row */
1129 samp_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(samp_none_rb));
1130 samp_count_rb = gtk_radio_button_new_with_label(samp_group, "1 of");
1131 if (global_capture_opts.sampling_method == CAPTURE_SAMP_BY_COUNT)
1132 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(samp_count_rb), TRUE);
1133 g_signal_connect(samp_count_rb, "toggled",
1134 G_CALLBACK(options_prep_adjust_sensitivity), opt_remote_w);
1135 gtk_table_attach_defaults(GTK_TABLE(sampling_tb), samp_count_rb, 0, 1, 1, 2);
1137 samp_count_adj = (GtkAdjustment *) gtk_adjustment_new(
1138 (gfloat)global_capture_opts.sampling_param,
1139 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
1140 samp_count_sb = gtk_spin_button_new(samp_count_adj, 0, 0);
1141 gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(samp_count_sb), TRUE);
1142 gtk_table_attach_defaults(GTK_TABLE(sampling_tb), samp_count_sb, 1, 2, 1, 2);
1144 sampling_lb = gtk_label_new("packets");
1145 gtk_misc_set_alignment(GTK_MISC(sampling_lb), 0, 0.5);
1146 gtk_table_attach_defaults(GTK_TABLE(sampling_tb), sampling_lb, 2, 3, 1, 2);
1148 /* "Sampling by timer" row */
1149 samp_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(samp_count_rb));
1150 samp_timer_rb = gtk_radio_button_new_with_label(samp_group, "1 every");
1151 if (global_capture_opts.sampling_method == CAPTURE_SAMP_BY_TIMER)
1152 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(samp_timer_rb), TRUE);
1153 g_signal_connect(samp_timer_rb, "toggled",
1154 G_CALLBACK(options_prep_adjust_sensitivity), opt_remote_w);
1155 gtk_table_attach_defaults(GTK_TABLE(sampling_tb), samp_timer_rb, 0, 1, 2, 3);
1157 samp_timer_adj = (GtkAdjustment *) gtk_adjustment_new(
1158 (gfloat)global_capture_opts.sampling_param,
1159 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
1160 samp_timer_sb = gtk_spin_button_new(samp_timer_adj, 0, 0);
1161 gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(samp_timer_sb), TRUE);
1162 gtk_table_attach_defaults(GTK_TABLE(sampling_tb), samp_timer_sb, 1, 2, 2, 3);
1164 sampling_lb = gtk_label_new("milliseconds");
1165 gtk_misc_set_alignment(GTK_MISC(sampling_lb), 0, 0.5);
1166 gtk_table_attach_defaults(GTK_TABLE(sampling_tb), sampling_lb, 2, 3, 2, 3);
1169 /* Button row: "Start" and "Cancel" buttons */
1170 bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL);
1171 gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 5);
1173 ok_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK);
1174 g_signal_connect(ok_bt, "clicked", G_CALLBACK(options_remote_ok_cb), opt_remote_w);
1175 gtk_tooltips_set_tip(tooltips, ok_bt,
1176 "Accept parameters and close dialog.", NULL);
1178 cancel_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
1179 gtk_tooltips_set_tip(tooltips, cancel_bt,
1180 "Cancel and exit dialog.", NULL);
1181 window_set_cancel_button(opt_remote_w, cancel_bt, window_cancel_button_cb);
1183 gtk_widget_grab_default(ok_bt);
1185 g_signal_connect(opt_remote_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
1186 g_signal_connect(opt_remote_w, "destroy", G_CALLBACK(options_remote_destroy_cb), NULL);
1188 g_object_set_data(G_OBJECT(opt_remote_w), E_CAP_NOCAP_RPCAP_CB_KEY, nocap_rpcap_cb);
1189 g_object_set_data(G_OBJECT(opt_remote_w), E_CAP_DATATX_UDP_CB_KEY, datatx_udp_cb);
1191 #ifdef HAVE_PCAP_SETSAMPLING
1192 g_object_set_data(G_OBJECT(opt_remote_w), E_CAP_SAMP_NONE_RB_KEY, samp_none_rb);
1193 g_object_set_data(G_OBJECT(opt_remote_w), E_CAP_SAMP_COUNT_RB_KEY, samp_count_rb);
1194 g_object_set_data(G_OBJECT(opt_remote_w), E_CAP_SAMP_COUNT_SB_KEY, samp_count_sb);
1195 g_object_set_data(G_OBJECT(opt_remote_w), E_CAP_SAMP_TIMER_RB_KEY, samp_timer_rb);
1196 g_object_set_data(G_OBJECT(opt_remote_w), E_CAP_SAMP_TIMER_SB_KEY, samp_timer_sb);
1199 #ifdef HAVE_PCAP_SETSAMPLING
1200 /* Set the sensitivity of various widgets as per the settings of other
1202 options_prep_adjust_sensitivity(NULL, opt_remote_w);
1205 gtk_widget_show_all(opt_remote_w);
1206 window_present(opt_remote_w);
1210 /* show capture prepare (options) dialog */
1212 capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
1215 *main_hb, *left_vb, *right_vb,
1217 *capture_fr, *capture_vb,
1218 *if_hb, *if_cb, *if_lb,
1219 *if_ip_hb, *if_ip_lb, *if_ip_eb,
1220 *linktype_hb, *linktype_lb, *linktype_om,
1221 *snap_hb, *snap_cb, *snap_sb, *snap_lb,
1223 *filter_hb, *filter_bt, *filter_te, *filter_cm,
1226 *file_hb, *file_bt, *file_lb, *file_te,
1227 *multi_tb, *multi_files_on_cb,
1228 *ring_filesize_cb, *ring_filesize_sb, *ring_filesize_om,
1229 *file_duration_cb, *file_duration_sb, *file_duration_om,
1230 *ringbuffer_nbf_cb, *ringbuffer_nbf_sb, *ringbuffer_nbf_lb,
1231 *stop_files_cb, *stop_files_sb, *stop_files_lb,
1233 *limit_fr, *limit_vb, *limit_tb,
1234 *stop_packets_cb, *stop_packets_sb, *stop_packets_lb,
1235 *stop_filesize_cb, *stop_filesize_sb, *stop_filesize_om,
1236 *stop_duration_cb, *stop_duration_sb, *stop_duration_om,
1238 *display_fr, *display_vb,
1239 *sync_cb, *auto_scroll_cb, *hide_info_cb,
1241 *resolv_fr, *resolv_vb,
1242 *m_resolv_cb, *n_resolv_cb, *t_resolv_cb,
1243 *bbox, *ok_bt, *cancel_bt,
1246 GtkWidget *advanced_bt;
1247 GtkWidget *decryption_cm;
1249 #ifdef HAVE_PCAP_REMOTE
1250 GtkWidget *iftype_om;
1251 GtkWidget *remote_bt;
1253 GtkTooltips *tooltips;
1254 GtkAdjustment *snap_adj, *ringbuffer_nbf_adj,
1255 *stop_packets_adj, *stop_filesize_adj, *stop_duration_adj, *stop_files_adj, *ring_filesize_adj, *file_duration_adj;
1256 GList *if_list, *combo_list, *cfilter_list;
1261 GtkAdjustment *buffer_size_adj;
1262 GtkWidget *buffer_size_lb, *buffer_size_sb, *buffer_size_hb;
1268 if (cap_open_w != NULL) {
1269 /* There's already a "Capture Options" dialog box; reactivate it. */
1270 reactivate_window(cap_open_w);
1275 /* Is WPcap loaded? */
1279 detailed_err = cant_load_winpcap_err("Wireshark");
1280 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", detailed_err);
1281 g_free(detailed_err);
1286 /* use user-defined title if preference is set */
1287 cap_title = create_user_window_title("Wireshark: Capture Options");
1289 cap_open_w = dlg_window_new(cap_title);
1292 tooltips = gtk_tooltips_new();
1294 #ifdef HAVE_PCAP_REMOTE
1295 if (global_capture_opts.src_type == CAPTURE_IFREMOTE) {
1296 if_list = get_remote_interface_list(global_capture_opts.remote_host,
1297 global_capture_opts.remote_port,
1298 global_capture_opts.auth_type,
1299 global_capture_opts.auth_username,
1300 global_capture_opts.auth_password,
1302 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_IF_LIST_KEY, if_list);
1304 if_list = capture_interface_list(&err, &err_str);
1305 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_IF_LIST_KEY, NULL);
1308 if_list = capture_interface_list(&err, &err_str);
1310 if (if_list == NULL && err == CANT_GET_INTERFACE_LIST) {
1311 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
1316 /* update airpcap interface list */
1318 /* load the airpcap interfaces */
1319 airpcap_if_list = get_airpcap_interface_list(&err, &err_str);
1321 decryption_cm = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_DECRYPTION_KEY);
1322 update_decryption_mode_list(decryption_cm);
1324 if (airpcap_if_list == NULL && err == CANT_GET_AIRPCAP_INTERFACE_LIST) {
1325 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
1329 /* select the first ad default (THIS SHOULD BE CHANGED) */
1330 airpcap_if_active = airpcap_get_default_if(airpcap_if_list);
1333 main_vb = gtk_vbox_new(FALSE, 0);
1334 gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);
1335 gtk_container_add(GTK_CONTAINER(cap_open_w), main_vb);
1337 /* Capture-related options frame */
1338 capture_fr = gtk_frame_new("Capture");
1339 gtk_container_add(GTK_CONTAINER(main_vb), capture_fr);
1341 capture_vb = gtk_vbox_new(FALSE, 3);
1342 gtk_container_set_border_width(GTK_CONTAINER(capture_vb), 5);
1343 gtk_container_add(GTK_CONTAINER(capture_fr), capture_vb);
1346 if_hb = gtk_hbox_new(FALSE, 3);
1347 gtk_container_add(GTK_CONTAINER(capture_vb), if_hb);
1349 if_lb = gtk_label_new("Interface:");
1350 gtk_box_pack_start(GTK_BOX(if_hb), if_lb, FALSE, FALSE, 3);
1352 #ifdef HAVE_PCAP_REMOTE
1353 iftype_om = iftype_option_menu_new(global_capture_opts.src_type);
1354 g_object_set_data(G_OBJECT(iftype_om), E_CAP_OM_IFTYPE_VALUE_KEY,
1355 GINT_TO_POINTER(global_capture_opts.src_type));
1356 gtk_tooltips_set_tip(tooltips, iftype_om,
1357 "Choose to capture from local or remote interfaces.", NULL);
1358 gtk_box_pack_start(GTK_BOX(if_hb), iftype_om, FALSE, FALSE, 0);
1361 if_cb = gtk_combo_new();
1362 combo_list = build_capture_combo_list(if_list, TRUE);
1363 if (combo_list != NULL)
1364 gtk_combo_set_popdown_strings(GTK_COMBO(if_cb), combo_list);
1365 if (global_capture_opts.iface == NULL && prefs.capture_device != NULL) {
1366 /* No interface was specified on the command line or in a previous
1367 capture, but there is one specified in the preferences file;
1368 make the one from the preferences file the default */
1369 if_device = g_strdup(prefs.capture_device);
1370 global_capture_opts.iface = g_strdup(get_if_name(if_device));
1371 global_capture_opts.iface_descr = get_interface_descriptive_name(global_capture_opts.iface);
1376 /* get the airpcap interface (if it IS an airpcap interface, and update the
1377 toolbar... and of course enable the advanced button...)*/
1378 airpcap_if_selected = get_airpcap_if_from_name(airpcap_if_list,global_capture_opts.iface);
1381 if (global_capture_opts.iface != NULL) {
1382 if_device = build_capture_combo_name(if_list, global_capture_opts.iface);
1383 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry), if_device);
1385 } else if (combo_list != NULL) {
1386 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry),
1387 (char *)combo_list->data);
1389 free_capture_combo_list(combo_list);
1390 #ifdef HAVE_PCAP_REMOTE
1391 /* Only delete if fetched local */
1392 if (global_capture_opts.src_type == CAPTURE_IFLOCAL)
1394 free_interface_list(if_list);
1395 gtk_tooltips_set_tip(tooltips, GTK_COMBO(if_cb)->entry,
1396 "Choose which interface (network card) will be used to capture packets from. "
1397 "Be sure to select the correct one, as it's a common mistake to select the wrong interface.", NULL);
1398 gtk_box_pack_start(GTK_BOX(if_hb), if_cb, TRUE, TRUE, 3);
1400 if_ip_hb = gtk_hbox_new(FALSE, 3);
1401 gtk_box_pack_start(GTK_BOX(capture_vb), if_ip_hb, FALSE, FALSE, 0);
1403 if_ip_eb = gtk_event_box_new();
1404 gtk_event_box_set_visible_window (GTK_EVENT_BOX(if_ip_eb), FALSE);
1405 gtk_box_pack_start(GTK_BOX(if_ip_hb), if_ip_eb, TRUE, TRUE, 3);
1406 gtk_tooltips_set_tip(tooltips, if_ip_eb, "Lists the IP address(es) "
1407 "assigned to the selected interface. If there are "
1408 "more addresses than will fit in the window, the "
1409 "first few and the last few will be shown with \"...\" "
1413 if_ip_lb = gtk_label_new("");
1414 gtk_misc_set_alignment(GTK_MISC(if_ip_lb), 0, 0); /* Left justified */
1415 gtk_container_add(GTK_CONTAINER(if_ip_eb), if_ip_lb);
1417 main_hb = gtk_hbox_new(FALSE, 5);
1418 gtk_container_set_border_width(GTK_CONTAINER(main_hb), 0);
1419 gtk_container_add(GTK_CONTAINER(capture_vb), main_hb);
1421 left_vb = gtk_vbox_new(FALSE, 0);
1422 gtk_container_set_border_width(GTK_CONTAINER(left_vb), 0);
1423 gtk_box_pack_start(GTK_BOX(main_hb), left_vb, TRUE, TRUE, 0);
1425 #if defined (HAVE_AIRPCAP) || defined (HAVE_PCAP_REMOTE) || defined (_WIN32)
1426 /* Avoid adding the right vbox if not needed, because it steals 3 pixels */
1427 right_vb = gtk_vbox_new(FALSE, 3);
1428 gtk_container_set_border_width(GTK_CONTAINER(right_vb), 0);
1429 gtk_box_pack_start(GTK_BOX(main_hb), right_vb, FALSE, FALSE, 3);
1433 linktype_hb = gtk_hbox_new(FALSE, 3);
1434 gtk_box_pack_start(GTK_BOX(left_vb), linktype_hb, FALSE, FALSE, 0);
1436 linktype_lb = gtk_label_new("Link-layer header type:");
1437 gtk_box_pack_start(GTK_BOX(linktype_hb), linktype_lb, FALSE, FALSE, 3);
1439 linktype_om = gtk_option_menu_new();
1440 g_object_set_data(G_OBJECT(linktype_om), E_CAP_LT_OM_LABEL_KEY, linktype_lb);
1441 /* Default to "use the default" */
1442 /* Datalink menu index is not resetted, it will be restored with last used value */
1443 /* g_object_set_data(G_OBJECT(linktype_om), E_CAP_OM_LT_VALUE_KEY, GINT_TO_POINTER(-1)); */
1444 g_object_set_data(G_OBJECT(linktype_om), E_CAP_IFACE_KEY, if_ip_lb);
1446 if (linktype_history == NULL) {
1447 linktype_history = g_hash_table_new(g_str_hash, g_str_equal);
1449 set_link_type_list(linktype_om, GTK_COMBO(if_cb)->entry);
1451 * XXX - in some cases, this is "multiple link-layer header types", e.g.
1452 * some 802.11 interfaces on FreeBSD 5.2 and later, where you can request
1453 * fake Ethernet, 802.11, or 802.11-plus-radio-information headers.
1455 * In other cases, it's "multiple link-layer types", e.g., with recent
1456 * versions of libpcap, a DAG card on an "HDLC" WAN, where you can
1457 * request Cisco HDLC or PPP depending on what type of traffic is going
1458 * over the WAN, or an Ethernet interface, where you can request Ethernet
1459 * or DOCSIS, the latter being for some Cisco cable modem equipment that
1460 * can be configured to send raw DOCSIS frames over an Ethernet inside
1461 * Ethernet low-level framing, for traffic capture purposes.
1463 * We leave it as "multiple link-layer types" for now.
1465 gtk_tooltips_set_tip(tooltips, linktype_om,
1466 "The selected interface supports multiple link-layer types; select the desired one.", NULL);
1467 gtk_box_pack_start (GTK_BOX(linktype_hb), linktype_om, FALSE, FALSE, 0);
1468 g_signal_connect(GTK_ENTRY(GTK_COMBO(if_cb)->entry), "changed",
1469 G_CALLBACK(capture_prep_interface_changed_cb), linktype_om);
1471 /* Promiscuous mode row */
1472 promisc_cb = gtk_check_button_new_with_mnemonic(
1473 "Capture packets in _promiscuous mode");
1474 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(promisc_cb),
1475 global_capture_opts.promisc_mode);
1476 gtk_tooltips_set_tip(tooltips, promisc_cb,
1477 "Usually a network card will only capture the traffic sent to its own network address. "
1478 "If you want to capture all traffic that the network card can \"see\", mark this option. "
1479 "See the FAQ for some more details of capturing packets from a switched network.", NULL);
1480 gtk_container_add(GTK_CONTAINER(left_vb), promisc_cb);
1482 /* Capture length row */
1483 snap_hb = gtk_hbox_new(FALSE, 3);
1484 gtk_container_add(GTK_CONTAINER(left_vb), snap_hb);
1486 snap_cb = gtk_check_button_new_with_mnemonic("_Limit each packet to");
1487 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(snap_cb),
1488 global_capture_opts.has_snaplen);
1489 g_signal_connect(snap_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1490 gtk_tooltips_set_tip(tooltips, snap_cb,
1491 "Limit the maximum number of bytes to be captured from each packet. This size includes the "
1492 "link-layer header and all subsequent headers. ", NULL);
1493 gtk_box_pack_start(GTK_BOX(snap_hb), snap_cb, FALSE, FALSE, 0);
1495 snap_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat) global_capture_opts.snaplen,
1496 MIN_PACKET_SIZE, WTAP_MAX_PACKET_SIZE, 1.0, 10.0, 0.0);
1497 snap_sb = gtk_spin_button_new (snap_adj, 0, 0);
1498 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (snap_sb), TRUE);
1499 gtk_widget_set_size_request(snap_sb, 80, -1);
1500 gtk_box_pack_start (GTK_BOX(snap_hb), snap_sb, FALSE, FALSE, 0);
1502 snap_lb = gtk_label_new("bytes");
1503 gtk_misc_set_alignment(GTK_MISC(snap_lb), 0, 0.5);
1504 gtk_box_pack_start(GTK_BOX(snap_hb), snap_lb, FALSE, FALSE, 0);
1507 filter_hb = gtk_hbox_new(FALSE, 3);
1508 gtk_box_pack_start(GTK_BOX(capture_vb), filter_hb, FALSE, FALSE, 0);
1510 filter_bt = gtk_button_new_from_stock(WIRESHARK_STOCK_CAPTURE_FILTER_ENTRY);
1511 g_signal_connect(filter_bt, "clicked", G_CALLBACK(capture_filter_construct_cb), NULL);
1512 g_signal_connect(filter_bt, "destroy", G_CALLBACK(filter_button_destroy_cb), NULL);
1513 gtk_tooltips_set_tip(tooltips, filter_bt,
1514 "Select a capture filter to reduce the amount of packets to be captured. "
1515 "See \"Capture Filters\" in the online help for further information how to use it.",
1517 gtk_box_pack_start(GTK_BOX(filter_hb), filter_bt, FALSE, FALSE, 3);
1519 /* Create the capture filter combo */
1520 filter_cm = gtk_combo_new();
1522 cfilter_list = g_object_get_data(G_OBJECT(top_level), E_CFILTER_FL_KEY);
1523 gtk_combo_disable_activate(GTK_COMBO(filter_cm));
1524 gtk_combo_set_case_sensitive(GTK_COMBO(filter_cm), TRUE);
1525 g_object_set_data(G_OBJECT(top_level), E_CFILTER_FL_KEY, cfilter_list);
1526 g_object_set_data(G_OBJECT(top_level), E_CFILTER_CM_KEY, filter_cm);
1527 filter_te = GTK_COMBO(filter_cm)->entry;
1529 if (cfilter_list != NULL)
1530 gtk_combo_set_popdown_strings(GTK_COMBO(filter_cm), cfilter_list);
1531 if (global_capture_opts.cfilter)
1532 gtk_entry_set_text(GTK_ENTRY(filter_te), global_capture_opts.cfilter);
1533 gtk_tooltips_set_tip(tooltips, filter_te,
1534 "Enter a capture filter to reduce the amount of packets to be captured. "
1535 "See \"Capture Filters\" in the online help for further information how to use it.",
1537 gtk_box_pack_start(GTK_BOX(filter_hb), filter_cm, TRUE, TRUE, 3);
1539 /* let an eventually capture filters dialog know the text entry to fill in */
1540 g_object_set_data(G_OBJECT(filter_bt), E_FILT_TE_PTR_KEY, filter_te);
1544 advanced_bt = gtk_button_new_with_label("Wireless Settings");
1546 /* Both the callback and the data are global */
1547 g_signal_connect(advanced_bt,"clicked", G_CALLBACK(options_airpcap_advanced_cb),airpcap_tb);
1548 g_object_set_data(G_OBJECT(GTK_ENTRY(GTK_COMBO(if_cb)->entry)),AIRPCAP_OPTIONS_ADVANCED_KEY,advanced_bt);
1550 if(airpcap_if_selected != NULL) {
1551 /* It is an airpcap interface */
1552 gtk_widget_set_sensitive(advanced_bt,TRUE);
1554 gtk_widget_set_sensitive(advanced_bt,FALSE);
1557 gtk_box_pack_start(GTK_BOX(right_vb),advanced_bt,FALSE,FALSE,0);
1558 gtk_widget_show(advanced_bt);
1561 #ifdef HAVE_PCAP_REMOTE
1562 remote_bt = gtk_button_new_with_label("Remote Settings");
1563 gtk_tooltips_set_tip(tooltips, remote_bt, "Various settings for remote capture.", NULL);
1565 /* Both the callback and the data are global */
1566 g_signal_connect(remote_bt,"clicked", G_CALLBACK(options_remote_cb),NULL);
1567 g_object_set_data(G_OBJECT(iftype_om), E_OPT_REMOTE_BT_KEY, remote_bt);
1569 if (global_capture_opts.src_type == CAPTURE_IFREMOTE) {
1570 gtk_widget_set_sensitive(remote_bt, TRUE);
1572 gtk_widget_set_sensitive(remote_bt, FALSE);
1575 gtk_box_pack_start(GTK_BOX(right_vb),remote_bt,FALSE,FALSE,0);
1576 gtk_widget_show(remote_bt);
1580 buffer_size_hb = gtk_hbox_new(FALSE, 3);
1581 buffer_size_lb = gtk_label_new("Buffer size:");
1582 gtk_box_pack_start (GTK_BOX(buffer_size_hb), buffer_size_lb, FALSE, FALSE, 0);
1584 buffer_size_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat) global_capture_opts.buffer_size,
1585 1, 65535, 1.0, 10.0, 0.0);
1586 buffer_size_sb = gtk_spin_button_new (buffer_size_adj, 0, 0);
1587 gtk_spin_button_set_value(GTK_SPIN_BUTTON (buffer_size_sb), (gfloat) global_capture_opts.buffer_size);
1588 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (buffer_size_sb), TRUE);
1589 gtk_widget_set_size_request(buffer_size_sb, 80, -1);
1590 gtk_tooltips_set_tip(tooltips, buffer_size_sb,
1591 "The memory buffer size used while capturing. If you notice packet drops, you can try to increase this size.", NULL);
1592 gtk_box_pack_start (GTK_BOX(buffer_size_hb), buffer_size_sb, FALSE, FALSE, 0);
1594 buffer_size_lb = gtk_label_new("megabyte(s)");
1595 gtk_box_pack_start (GTK_BOX(buffer_size_hb), buffer_size_lb, FALSE, FALSE, 3);
1596 gtk_box_pack_start (GTK_BOX(right_vb), buffer_size_hb, FALSE, FALSE, 0);
1599 main_hb = gtk_hbox_new(FALSE, 5);
1600 gtk_container_set_border_width(GTK_CONTAINER(main_hb), 0);
1601 gtk_container_add(GTK_CONTAINER(main_vb), main_hb);
1603 left_vb = gtk_vbox_new(FALSE, 0);
1604 gtk_container_set_border_width(GTK_CONTAINER(left_vb), 0);
1605 gtk_box_pack_start(GTK_BOX(main_hb), left_vb, TRUE, TRUE, 0);
1607 right_vb = gtk_vbox_new(FALSE, 0);
1608 gtk_container_set_border_width(GTK_CONTAINER(right_vb), 0);
1609 gtk_box_pack_start(GTK_BOX(main_hb), right_vb, FALSE, FALSE, 0);
1611 /* Capture file-related options frame */
1612 file_fr = gtk_frame_new("Capture File(s)");
1613 gtk_container_add(GTK_CONTAINER(left_vb), file_fr);
1615 file_vb = gtk_vbox_new(FALSE, 3);
1616 gtk_container_set_border_width(GTK_CONTAINER(file_vb), 5);
1617 gtk_container_add(GTK_CONTAINER(file_fr), file_vb);
1620 file_hb = gtk_hbox_new(FALSE, 3);
1621 gtk_box_pack_start(GTK_BOX(file_vb), file_hb, FALSE, FALSE, 0);
1623 file_lb = gtk_label_new("File:");
1624 gtk_box_pack_start(GTK_BOX(file_hb), file_lb, FALSE, FALSE, 3);
1626 file_te = gtk_entry_new();
1627 gtk_tooltips_set_tip(tooltips, file_te,
1628 "Enter the file name to which captured data will be written. "
1629 "If you don't enter something here, a temporary file will be used.",
1631 gtk_box_pack_start(GTK_BOX(file_hb), file_te, TRUE, TRUE, 3);
1633 file_bt = gtk_button_new_from_stock(WIRESHARK_STOCK_BROWSE);
1634 gtk_tooltips_set_tip(tooltips, file_bt,
1635 "Select a file to which captured data will be written, "
1636 "instead of entering the file name directly. ",
1638 gtk_box_pack_start(GTK_BOX(file_hb), file_bt, FALSE, FALSE, 0);
1640 g_signal_connect(file_bt, "clicked", G_CALLBACK(capture_prep_file_cb), file_te);
1642 /* multiple files table */
1643 multi_tb = gtk_table_new(5, 3, FALSE);
1644 gtk_table_set_row_spacings(GTK_TABLE(multi_tb), 1);
1645 gtk_table_set_col_spacings(GTK_TABLE(multi_tb), 3);
1646 gtk_box_pack_start(GTK_BOX(file_vb), multi_tb, FALSE, FALSE, 0);
1649 /* multiple files row */
1650 multi_files_on_cb = gtk_check_button_new_with_mnemonic("Use _multiple files");
1651 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(multi_files_on_cb),
1652 global_capture_opts.multi_files_on);
1653 g_signal_connect(multi_files_on_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity),
1655 gtk_tooltips_set_tip(tooltips, multi_files_on_cb,
1656 "Instead of using a single capture file, multiple files will be created. "
1657 "The generated file names will contain an incrementing number and the start time of the capture.", NULL);
1658 gtk_table_attach_defaults(GTK_TABLE(multi_tb), multi_files_on_cb, 0, 1, row, row+1);
1661 /* Ring buffer filesize row */
1662 ring_filesize_cb = gtk_check_button_new_with_label("Next file every");
1663 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ring_filesize_cb),
1664 global_capture_opts.has_autostop_filesize || !global_capture_opts.has_file_duration);
1665 g_signal_connect(ring_filesize_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1666 gtk_tooltips_set_tip(tooltips, ring_filesize_cb,
1667 "If the selected file size is exceeded, capturing switches to the next file.\n"
1668 "PLEASE NOTE: at least one of the \"Next file every\" options MUST be selected.",
1670 gtk_table_attach_defaults(GTK_TABLE(multi_tb), ring_filesize_cb, 0, 1, row, row+1);
1672 ring_filesize_adj = (GtkAdjustment *) gtk_adjustment_new(0.0,
1673 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
1674 ring_filesize_sb = gtk_spin_button_new (ring_filesize_adj, 0, 0);
1675 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (ring_filesize_sb), TRUE);
1676 gtk_widget_set_size_request(ring_filesize_sb, 80, -1);
1677 gtk_table_attach_defaults(GTK_TABLE(multi_tb), ring_filesize_sb, 1, 2, row, row+1);
1679 ring_filesize_om = size_unit_option_menu_new(global_capture_opts.autostop_filesize);
1680 gtk_table_attach_defaults(GTK_TABLE(multi_tb), ring_filesize_om, 2, 3, row, row+1);
1682 value = size_unit_option_menu_set_value(global_capture_opts.autostop_filesize);
1683 gtk_adjustment_set_value(ring_filesize_adj, (gfloat) value);
1687 /* Ring buffer duration row */
1688 file_duration_cb = gtk_check_button_new_with_label("Next file every");
1689 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(file_duration_cb),
1690 global_capture_opts.has_file_duration);
1691 g_signal_connect(file_duration_cb, "toggled",
1692 G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1693 gtk_tooltips_set_tip(tooltips, file_duration_cb,
1694 "If the selected duration is exceeded, capturing switches to the next file.\n"
1695 "PLEASE NOTE: at least one of the \"Next file every\" options MUST be selected.",
1697 gtk_table_attach_defaults(GTK_TABLE(multi_tb), file_duration_cb, 0, 1, row, row+1);
1699 file_duration_adj = (GtkAdjustment *)gtk_adjustment_new(0.0,
1700 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
1701 file_duration_sb = gtk_spin_button_new (file_duration_adj, 0, 0);
1702 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (file_duration_sb), TRUE);
1703 gtk_widget_set_size_request(file_duration_sb, 80, -1);
1704 gtk_table_attach_defaults(GTK_TABLE(multi_tb), file_duration_sb, 1, 2, row, row+1);
1706 file_duration_om = time_unit_option_menu_new(global_capture_opts.file_duration);
1707 gtk_table_attach_defaults(GTK_TABLE(multi_tb), file_duration_om, 2, 3, row, row+1);
1709 value = time_unit_option_menu_convert_value(global_capture_opts.file_duration);
1710 gtk_adjustment_set_value(file_duration_adj, (gfloat) value);
1713 /* Ring buffer files row */
1714 ringbuffer_nbf_cb = gtk_check_button_new_with_label("Ring buffer with");
1715 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb),
1716 global_capture_opts.has_ring_num_files);
1717 g_signal_connect(ringbuffer_nbf_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1718 gtk_tooltips_set_tip(tooltips, ringbuffer_nbf_cb,
1719 "After capturing has switched to the next file and the given number of files has exceeded, "
1720 "the oldest file will be removed.",
1722 gtk_table_attach_defaults(GTK_TABLE(multi_tb), ringbuffer_nbf_cb, 0, 1, row, row+1);
1724 ringbuffer_nbf_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat) global_capture_opts.ring_num_files,
1725 2/*RINGBUFFER_MIN_NUM_FILES*/, RINGBUFFER_MAX_NUM_FILES, 1.0, 10.0, 0.0);
1726 ringbuffer_nbf_sb = gtk_spin_button_new (ringbuffer_nbf_adj, 0, 0);
1727 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (ringbuffer_nbf_sb), TRUE);
1728 gtk_widget_set_size_request(ringbuffer_nbf_sb, 80, -1);
1729 g_signal_connect(ringbuffer_nbf_sb, "changed", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1730 gtk_table_attach_defaults(GTK_TABLE(multi_tb), ringbuffer_nbf_sb, 1, 2, row, row+1);
1732 ringbuffer_nbf_lb = gtk_label_new("files");
1733 gtk_misc_set_alignment(GTK_MISC(ringbuffer_nbf_lb), 0, 0.5);
1734 gtk_table_attach_defaults(GTK_TABLE(multi_tb), ringbuffer_nbf_lb, 2, 3, row, row+1);
1738 stop_files_cb = gtk_check_button_new_with_label("Stop capture after");
1739 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stop_files_cb),
1740 global_capture_opts.has_autostop_files);
1741 g_signal_connect(stop_files_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1742 gtk_tooltips_set_tip(tooltips, stop_files_cb,
1743 "Stop capturing after the given number of \"file switches\" have been done.", NULL);
1744 gtk_table_attach_defaults(GTK_TABLE(multi_tb), stop_files_cb, 0, 1, row, row+1);
1746 stop_files_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat)global_capture_opts.autostop_files,
1747 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
1748 stop_files_sb = gtk_spin_button_new (stop_files_adj, 0, 0);
1749 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_files_sb), TRUE);
1750 gtk_widget_set_size_request(stop_files_sb, 80, -1);
1751 gtk_table_attach_defaults(GTK_TABLE(multi_tb), stop_files_sb, 1, 2, row, row+1);
1753 stop_files_lb = gtk_label_new("file(s)");
1754 gtk_misc_set_alignment(GTK_MISC(stop_files_lb), 0, 0.5);
1755 gtk_table_attach_defaults(GTK_TABLE(multi_tb), stop_files_lb, 2, 3, row, row+1);
1758 /* Capture limits frame */
1759 limit_fr = gtk_frame_new("Stop Capture ...");
1760 gtk_container_add(GTK_CONTAINER(left_vb), limit_fr);
1762 limit_vb = gtk_vbox_new(FALSE, 3);
1763 gtk_container_set_border_width(GTK_CONTAINER(limit_vb), 5);
1764 gtk_container_add(GTK_CONTAINER(limit_fr), limit_vb);
1767 limit_tb = gtk_table_new(3, 3, FALSE);
1768 gtk_table_set_row_spacings(GTK_TABLE(limit_tb), 1);
1769 gtk_table_set_col_spacings(GTK_TABLE(limit_tb), 3);
1770 gtk_box_pack_start(GTK_BOX(limit_vb), limit_tb, FALSE, FALSE, 0);
1773 /* Packet count row */
1774 stop_packets_cb = gtk_check_button_new_with_label("... after");
1775 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stop_packets_cb),
1776 global_capture_opts.has_autostop_packets);
1777 g_signal_connect(stop_packets_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1778 gtk_tooltips_set_tip(tooltips, stop_packets_cb,
1779 "Stop capturing after the given number of packets have been captured.", NULL);
1780 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_packets_cb, 0, 1, row, row+1);
1782 stop_packets_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat)global_capture_opts.autostop_packets,
1783 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
1784 stop_packets_sb = gtk_spin_button_new (stop_packets_adj, 0, 0);
1785 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_packets_sb), TRUE);
1786 gtk_widget_set_size_request(stop_packets_sb, 80, -1);
1787 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_packets_sb, 1, 2, row, row+1);
1789 stop_packets_lb = gtk_label_new("packet(s)");
1790 gtk_misc_set_alignment(GTK_MISC(stop_packets_lb), 0, 0.5);
1791 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_packets_lb, 2, 3, row, row+1);
1795 stop_filesize_cb = gtk_check_button_new_with_label("... after");
1796 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stop_filesize_cb),
1797 global_capture_opts.has_autostop_filesize);
1798 g_signal_connect(stop_filesize_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1799 gtk_tooltips_set_tip(tooltips, stop_filesize_cb,
1800 "Stop capturing after the given amount of capture data has been captured.", NULL);
1801 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_filesize_cb, 0, 1, row, row+1);
1803 stop_filesize_adj = (GtkAdjustment *) gtk_adjustment_new(0.0,
1804 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
1805 stop_filesize_sb = gtk_spin_button_new (stop_filesize_adj, 0, 0);
1806 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_filesize_sb), TRUE);
1807 gtk_widget_set_size_request(stop_filesize_sb, 80, -1);
1808 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_filesize_sb, 1, 2, row, row+1);
1810 stop_filesize_om = size_unit_option_menu_new(global_capture_opts.autostop_filesize);
1811 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_filesize_om, 2, 3, row, row+1);
1813 value = size_unit_option_menu_set_value(global_capture_opts.autostop_filesize);
1814 gtk_adjustment_set_value(stop_filesize_adj, (gfloat) value);
1819 stop_duration_cb = gtk_check_button_new_with_label("... after");
1820 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stop_duration_cb),
1821 global_capture_opts.has_autostop_duration);
1822 g_signal_connect(stop_duration_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1823 gtk_tooltips_set_tip(tooltips, stop_duration_cb,
1824 "Stop capturing after the given time is exceeded.", NULL);
1825 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_duration_cb, 0, 1, row, row+1);
1827 stop_duration_adj = (GtkAdjustment *) gtk_adjustment_new(0.0,
1828 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
1829 stop_duration_sb = gtk_spin_button_new (stop_duration_adj, 0, 0);
1830 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_duration_sb), TRUE);
1831 gtk_widget_set_size_request(stop_duration_sb, 80, -1);
1832 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_duration_sb, 1, 2, row, row+1);
1834 stop_duration_om = time_unit_option_menu_new(global_capture_opts.autostop_duration);
1835 gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_duration_om, 2, 3, row, row+1);
1837 value = time_unit_option_menu_convert_value(global_capture_opts.autostop_duration);
1838 gtk_adjustment_set_value(stop_duration_adj, (gfloat) value);
1841 /* Display-related options frame */
1842 display_fr = gtk_frame_new("Display Options");
1843 gtk_container_add(GTK_CONTAINER(right_vb), display_fr);
1845 display_vb = gtk_vbox_new(FALSE, 0);
1846 gtk_container_set_border_width(GTK_CONTAINER(display_vb), 5);
1847 gtk_container_add(GTK_CONTAINER(display_fr), display_vb);
1849 /* "Update display in real time" row */
1850 sync_cb = gtk_check_button_new_with_mnemonic(
1851 "_Update list of packets in real time");
1852 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(sync_cb),
1853 global_capture_opts.real_time_mode);
1854 g_signal_connect(sync_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
1855 gtk_tooltips_set_tip(tooltips, sync_cb,
1856 "Using this option will show the captured packets immediately on the main screen. "
1857 "Please note: this will slow down capturing, so increased packet drops might appear.", NULL);
1858 gtk_container_add(GTK_CONTAINER(display_vb), sync_cb);
1860 /* "Auto-scroll live update" row */
1861 auto_scroll_cb = gtk_check_button_new_with_mnemonic(
1862 "_Automatic scrolling in live capture");
1863 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(auto_scroll_cb), auto_scroll_live);
1864 gtk_tooltips_set_tip(tooltips, auto_scroll_cb,
1865 "This will scroll the \"Packet List\" automatically to the latest captured packet, "
1866 "when the \"Update List of packets in real time\" option is used.", NULL);
1867 gtk_container_add(GTK_CONTAINER(display_vb), auto_scroll_cb);
1869 /* "Hide capture info" row */
1870 hide_info_cb = gtk_check_button_new_with_mnemonic(
1871 "_Hide capture info dialog");
1872 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hide_info_cb), !global_capture_opts.show_info);
1873 gtk_tooltips_set_tip(tooltips, hide_info_cb,
1874 "Hide the capture info dialog while capturing.", NULL);
1875 gtk_container_add(GTK_CONTAINER(display_vb), hide_info_cb);
1877 /* Name Resolution frame */
1878 resolv_fr = gtk_frame_new("Name Resolution");
1879 gtk_container_add(GTK_CONTAINER(right_vb), resolv_fr);
1881 resolv_vb = gtk_vbox_new(FALSE, 0);
1882 gtk_container_set_border_width(GTK_CONTAINER(resolv_vb), 5);
1883 gtk_container_add(GTK_CONTAINER(resolv_fr), resolv_vb);
1885 m_resolv_cb = gtk_check_button_new_with_mnemonic(
1886 "Enable _MAC name resolution");
1887 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_resolv_cb),
1888 g_resolv_flags & RESOLV_MAC);
1889 gtk_tooltips_set_tip(tooltips, m_resolv_cb,
1890 "Perform MAC layer name resolution while capturing.", NULL);
1891 gtk_container_add(GTK_CONTAINER(resolv_vb), m_resolv_cb);
1893 n_resolv_cb = gtk_check_button_new_with_mnemonic(
1894 "Enable _network name resolution");
1895 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(n_resolv_cb),
1896 g_resolv_flags & RESOLV_NETWORK);
1897 gtk_tooltips_set_tip(tooltips, n_resolv_cb,
1898 "Perform network layer name resolution while capturing.", NULL);
1899 gtk_container_add(GTK_CONTAINER(resolv_vb), n_resolv_cb);
1901 t_resolv_cb = gtk_check_button_new_with_mnemonic(
1902 "Enable _transport name resolution");
1903 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(t_resolv_cb),
1904 g_resolv_flags & RESOLV_TRANSPORT);
1905 gtk_tooltips_set_tip(tooltips, t_resolv_cb,
1906 "Perform transport layer name resolution while capturing.", NULL);
1907 gtk_container_add(GTK_CONTAINER(resolv_vb), t_resolv_cb);
1909 /* Button row: "Start", "Cancel" and "Help" buttons */
1910 bbox = dlg_button_row_new(WIRESHARK_STOCK_CAPTURE_START, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL);
1911 gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 5);
1913 ok_bt = g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_CAPTURE_START);
1914 g_signal_connect(ok_bt, "clicked", G_CALLBACK(capture_start_cb), cap_open_w);
1915 gtk_tooltips_set_tip(tooltips, ok_bt,
1916 "Start the capture process.", NULL);
1918 cancel_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
1919 gtk_tooltips_set_tip(tooltips, cancel_bt,
1920 "Cancel and exit dialog.", NULL);
1921 window_set_cancel_button(cap_open_w, cancel_bt, window_cancel_button_cb);
1923 help_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
1924 gtk_tooltips_set_tip(tooltips, help_bt,
1925 "Show help about capturing.", NULL);
1926 g_signal_connect(help_bt, "clicked", G_CALLBACK(topic_cb), (gpointer)HELP_CAPTURE_OPTIONS_DIALOG);
1928 gtk_widget_grab_default(ok_bt);
1930 /* Attach pointers to needed widgets to the capture prefs window/object */
1931 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_IFACE_KEY, if_cb);
1932 #ifdef HAVE_PCAP_REMOTE
1933 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_IFTYPE_OM_KEY, iftype_om);
1934 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_REMOTE_DIALOG_PTR_KEY, NULL);
1936 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_SNAP_CB_KEY, snap_cb);
1937 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_SNAP_SB_KEY, snap_sb);
1938 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_LT_OM_KEY, linktype_om);
1940 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_BUFFER_SIZE_SB_KEY, buffer_size_sb);
1942 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_PROMISC_KEY, promisc_cb);
1943 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_FILT_KEY, filter_te);
1944 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_FILE_TE_KEY, file_te);
1945 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_MULTI_FILES_ON_CB_KEY, multi_files_on_cb);
1946 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_RING_NBF_CB_KEY, ringbuffer_nbf_cb);
1947 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_RING_NBF_SB_KEY, ringbuffer_nbf_sb);
1948 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_RING_NBF_LB_KEY, ringbuffer_nbf_lb);
1949 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_RING_FILESIZE_CB_KEY, ring_filesize_cb);
1950 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_RING_FILESIZE_SB_KEY, ring_filesize_sb);
1951 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_RING_FILESIZE_OM_KEY, ring_filesize_om);
1952 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_FILE_DURATION_CB_KEY, file_duration_cb);
1953 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_FILE_DURATION_SB_KEY, file_duration_sb);
1954 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_FILE_DURATION_OM_KEY, file_duration_om);
1955 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_SYNC_KEY, sync_cb);
1956 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_AUTO_SCROLL_KEY, auto_scroll_cb);
1957 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_HIDE_INFO_KEY, hide_info_cb);
1958 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_PACKETS_CB_KEY, stop_packets_cb);
1959 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_PACKETS_SB_KEY, stop_packets_sb);
1960 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_PACKETS_LB_KEY, stop_packets_lb);
1961 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILESIZE_CB_KEY, stop_filesize_cb);
1962 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILESIZE_SB_KEY, stop_filesize_sb);
1963 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILESIZE_OM_KEY, stop_filesize_om);
1964 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_DURATION_CB_KEY, stop_duration_cb);
1965 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_DURATION_SB_KEY, stop_duration_sb);
1966 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_DURATION_OM_KEY, stop_duration_om);
1967 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILES_CB_KEY, stop_files_cb);
1968 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILES_SB_KEY, stop_files_sb);
1969 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILES_LB_KEY, stop_files_lb);
1970 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_M_RESOLVE_KEY, m_resolv_cb);
1971 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_N_RESOLVE_KEY, n_resolv_cb);
1972 g_object_set_data(G_OBJECT(cap_open_w), E_CAP_T_RESOLVE_KEY, t_resolv_cb);
1974 /* Set the sensitivity of various widgets as per the settings of other
1976 capture_prep_adjust_sensitivity(NULL, cap_open_w);
1978 /* Catch the "activate" signal on the text
1979 entries, so that if the user types Return there, we act as if the
1980 "OK" button had been selected, as happens if Return is typed if some
1981 widget that *doesn't* handle the Return key has the input focus. */
1982 dlg_set_activate(GTK_COMBO(if_cb)->entry, ok_bt);
1983 dlg_set_activate(filter_te, ok_bt);
1984 dlg_set_activate(file_te, ok_bt);
1986 /* XXX - why does not
1988 gtk_widget_grab_focus(if_cb);
1990 give the initial focus to the "Interface" combo box?
1992 Or should I phrase that as "why does GTK+ continually frustrate
1993 attempts to make GUIs driveable from the keyboard?" We have to
1994 go catch the activate signal on every single GtkEntry widget
1995 (rather than having widgets whose activate signal is *not*
1996 caught not catch the Return keystroke, so that it passes on,
1997 ultimately, to the window, which can activate the default
1998 widget, i.e. the "OK" button); we have to catch the "key_press_event"
1999 signal and have the handler check for ESC, so that we can have ESC
2000 activate the "Cancel" button; in order to support Alt+<key> mnemonics
2001 for buttons and the like, we may have to construct an accelerator
2002 group by hand and set up the accelerators by hand (if that even
2003 works - I've not tried it yet); we have to do a "gtk_widget_grab_focus()"
2004 to keep some container widget from getting the initial focus, so that
2005 you don't have to tab into the first widget in order to start typing
2006 in it; and it now appears that you simply *can't* make a combo box
2007 get the initial focus, at least not in the obvious fashion. Sigh.... */
2009 g_signal_connect(cap_open_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
2010 g_signal_connect(cap_open_w, "destroy", G_CALLBACK(capture_prep_destroy_cb), NULL);
2012 /* Give the initial focus to the "Filter" entry box. */
2013 gtk_widget_grab_focus(filter_te);
2015 gtk_widget_show_all(cap_open_w);
2016 window_present(cap_open_w);
2019 /* everythings prepared, now it's really time to start the capture */
2021 capture_start_confirmed(void)
2025 /* init iface, if never used before */
2026 /* XXX - would better be doing this in main.c */
2027 if(global_capture_opts.iface == NULL) {
2029 const gchar *if_name;
2031 /* did the user ever selected a capture interface before? */
2032 if(prefs.capture_device == NULL) {
2033 simple_dialog(ESD_TYPE_CONFIRMATION,
2035 "%sNo capture interface selected!%s\n\n"
2036 "To select an interface use:\n\n"
2037 "Capture->Options (until Wireshark is stopped)\n"
2038 "Edit->Preferences/Capture (permanent, if saved)",
2039 simple_dialog_primary_start(), simple_dialog_primary_end());
2042 if_device = g_strdup(prefs.capture_device);
2043 if_name = get_if_name(if_device);
2044 global_capture_opts.iface = g_strdup(if_name);
2045 global_capture_opts.iface_descr = get_interface_descriptive_name(global_capture_opts.iface);
2050 /* XXX - we might need to init other pref data as well... */
2051 menu_auto_scroll_live_changed(auto_scroll_live);
2053 if (capture_start(&global_capture_opts)) {
2054 /* The capture succeeded, which means the capture filter syntax is
2055 valid; add this capture filter to the recent capture filter list. */
2056 cfilter_combo_add_recent(global_capture_opts.cfilter);
2060 /* user confirmed the "Save capture file..." dialog */
2062 capture_start_answered_cb(gpointer dialog _U_, gint btn, gpointer data)
2066 /* save file first */
2067 file_save_as_cmd(after_save_capture_dialog, data);
2069 case(ESD_BTN_DONT_SAVE):
2070 /* XXX - unlink old file? */
2071 /* start the capture */
2072 capture_start_confirmed();
2074 case(ESD_BTN_CANCEL):
2077 g_assert_not_reached();
2081 /* user pressed the "Start" button (in dialog or toolbar) */
2083 capture_start_cb(GtkWidget *w _U_, gpointer d _U_)
2087 gint *linktype_p = NULL;
2090 airpcap_if_active = airpcap_if_selected;
2091 airpcap_set_toolbar_start_capture(airpcap_if_active);
2095 /* Is WPcap loaded? */
2097 char * err_msg = cant_load_winpcap_err("Wireshark");
2099 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, err_msg);
2107 * There's an options dialog; get the values from it and close it.
2111 success = capture_dlg_prep(cap_open_w);
2112 window_destroy(GTK_WIDGET(cap_open_w));
2114 return; /* error in options dialog */
2117 if (global_capture_opts.iface == NULL) {
2118 if (prefs.capture_device == NULL) {
2119 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
2120 "You didn't specify an interface on which to capture packets.");
2123 if_name = g_strdup(get_if_name(prefs.capture_device));
2125 if_name = g_strdup(global_capture_opts.iface);
2128 if (linktype_history != NULL) {
2129 linktype_p = g_hash_table_lookup(linktype_history, if_name);
2130 if (linktype_p == NULL) {
2131 linktype_p = g_malloc(sizeof (int));
2132 g_hash_table_insert(linktype_history, if_name, linktype_p);
2136 *linktype_p = global_capture_opts.linktype;
2138 global_capture_opts.linktype = capture_dev_user_linktype_find(if_name);
2142 if((cfile.state != FILE_CLOSED) && !cfile.user_saved && prefs.gui_ask_unsaved) {
2143 /* user didn't saved his current file, ask him */
2144 dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_SAVE_DONTSAVE_CANCEL,
2145 "%sSave capture file before starting a new capture?%s\n\n"
2146 "If you start a new capture without saving, your current capture data will\nbe discarded.",
2147 simple_dialog_primary_start(), simple_dialog_primary_end());
2148 simple_dialog_set_cb(dialog, capture_start_answered_cb, NULL);
2150 /* unchanged file, just capture a new one */
2151 capture_start_confirmed();
2155 /* user selected a link type, convert to internal value */
2157 select_link_type_cb(GtkWidget *w, gpointer data)
2159 int new_linktype = GPOINTER_TO_INT(data);
2160 GtkWidget *linktype_om = g_object_get_data(G_OBJECT(w), E_CAP_LT_OM_KEY);
2161 int old_linktype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(linktype_om), E_CAP_OM_LT_VALUE_KEY));
2163 /* If the link is changed, update the menu and store the index and the value
2164 to reuse later when the dialog window will be reopened */
2165 if (old_linktype != new_linktype) {
2166 g_object_set_data(G_OBJECT(linktype_om), E_CAP_OM_LT_VALUE_KEY, GINT_TO_POINTER(new_linktype));
2167 global_capture_opts.linktype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(linktype_om), E_CAP_OM_LT_VALUE_KEY));
2171 #ifdef HAVE_PCAP_REMOTE
2172 /* user selected an interface type (local/remote), convert to internal value) */
2174 select_if_type_cb(GtkWidget *w, gpointer data)
2176 int new_iftype = GPOINTER_TO_INT(data);
2177 GtkWidget *iftype_om = g_object_get_data(G_OBJECT(w), E_CAP_IFTYPE_OM_KEY);
2178 int old_iftype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(iftype_om),
2179 E_CAP_OM_IFTYPE_VALUE_KEY));
2181 if (old_iftype != new_iftype)
2183 g_object_set_data(G_OBJECT(iftype_om), E_CAP_OM_IFTYPE_VALUE_KEY,
2184 GINT_TO_POINTER(new_iftype));
2186 if (new_iftype == CAPTURE_IFREMOTE)
2188 capture_remote_cb(iftype_om, NULL);
2190 else if (new_iftype != old_iftype)
2192 global_capture_opts.src_type = CAPTURE_IFLOCAL;
2193 update_interface_list();
2198 /* user pressed "File" button */
2200 capture_prep_file_cb(GtkWidget *file_bt, GtkWidget *file_te)
2202 file_selection_browse(file_bt, file_te, "Wireshark: Specify a Capture File", FILE_SELECTION_WRITE_BROWSE);
2206 /* convert dialog settings into capture_opts values */
2208 capture_dlg_prep(gpointer parent_w) {
2209 GtkWidget *if_cb, *snap_cb, *snap_sb, *promisc_cb, *filter_te, *filter_cm,
2210 *file_te, *multi_files_on_cb, *ringbuffer_nbf_sb, *ringbuffer_nbf_cb,
2211 *linktype_om, *sync_cb, *auto_scroll_cb, *hide_info_cb,
2212 *stop_packets_cb, *stop_packets_sb,
2213 *stop_filesize_cb, *stop_filesize_sb, *stop_filesize_om,
2214 *stop_duration_cb, *stop_duration_sb, *stop_duration_om,
2215 *ring_filesize_cb, *ring_filesize_sb, *ring_filesize_om,
2216 *file_duration_cb, *file_duration_sb, *file_duration_om,
2217 *stop_files_cb, *stop_files_sb,
2218 *m_resolv_cb, *n_resolv_cb, *t_resolv_cb;
2219 #ifdef HAVE_PCAP_REMOTE
2220 GtkWidget *iftype_om;
2223 GtkWidget *buffer_size_sb;
2227 const gchar *if_name;
2228 const gchar *filter_text;
2229 const gchar *g_save_file;
2234 if_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_IFACE_KEY);
2235 #ifdef HAVE_PCAP_REMOTE
2236 iftype_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_IFTYPE_OM_KEY);
2238 snap_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SNAP_CB_KEY);
2239 snap_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SNAP_SB_KEY);
2240 linktype_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_LT_OM_KEY);
2242 buffer_size_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_BUFFER_SIZE_SB_KEY);
2244 promisc_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_PROMISC_KEY);
2245 filter_cm = g_object_get_data(G_OBJECT(top_level), E_CFILTER_CM_KEY);
2246 filter_te = GTK_COMBO(filter_cm)->entry;
2247 file_te = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_TE_KEY);
2248 multi_files_on_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_MULTI_FILES_ON_CB_KEY);
2249 ringbuffer_nbf_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_NBF_CB_KEY);
2250 ringbuffer_nbf_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_NBF_SB_KEY);
2251 ring_filesize_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_CB_KEY);
2252 ring_filesize_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_SB_KEY);
2253 ring_filesize_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_OM_KEY);
2254 file_duration_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_DURATION_CB_KEY);
2255 file_duration_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_DURATION_SB_KEY);
2256 file_duration_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_DURATION_OM_KEY);
2257 sync_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SYNC_KEY);
2258 auto_scroll_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_AUTO_SCROLL_KEY);
2259 hide_info_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_HIDE_INFO_KEY);
2260 stop_packets_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_PACKETS_CB_KEY);
2261 stop_packets_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_PACKETS_SB_KEY);
2262 stop_filesize_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_CB_KEY);
2263 stop_filesize_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_SB_KEY);
2264 stop_filesize_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_OM_KEY);
2265 stop_duration_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_CB_KEY);
2266 stop_duration_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_SB_KEY);
2267 stop_duration_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_OM_KEY);
2268 stop_files_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILES_CB_KEY);
2269 stop_files_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILES_SB_KEY);
2270 m_resolv_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_M_RESOLVE_KEY);
2271 n_resolv_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_N_RESOLVE_KEY);
2272 t_resolv_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_T_RESOLVE_KEY);
2275 g_strdup(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry)));
2276 if_text = g_strstrip(entry_text);
2277 if_name = get_if_name(if_text);
2278 if (*if_name == '\0') {
2279 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
2280 "You didn't specify an interface on which to capture packets.");
2284 if (global_capture_opts.iface)
2285 g_free(global_capture_opts.iface);
2286 if (global_capture_opts.iface_descr)
2287 g_free(global_capture_opts.iface_descr);
2288 global_capture_opts.iface = g_strdup(if_name);
2289 global_capture_opts.iface_descr = get_interface_descriptive_name(global_capture_opts.iface);
2291 /* The Linktype will be stored when the interface will be changed, or if not, not datalink option is used,
2292 the acquisition will be performed on the default datalink for the device */
2293 /* global_capture_opts.linktype =
2294 GPOINTER_TO_INT(g_object_get_data(G_OBJECT(linktype_om), E_CAP_OM_LT_VALUE_KEY)); */
2296 #ifdef HAVE_PCAP_REMOTE
2297 global_capture_opts.src_type = (capture_source)
2298 GPOINTER_TO_INT(g_object_get_data(G_OBJECT(iftype_om), E_CAP_OM_IFTYPE_VALUE_KEY));
2302 global_capture_opts.buffer_size =
2303 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(buffer_size_sb));
2306 global_capture_opts.has_snaplen =
2307 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(snap_cb));
2308 if (global_capture_opts.has_snaplen) {
2309 global_capture_opts.snaplen =
2310 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(snap_sb));
2311 if (global_capture_opts.snaplen < 1)
2312 global_capture_opts.snaplen = WTAP_MAX_PACKET_SIZE;
2313 else if (global_capture_opts.snaplen < MIN_PACKET_SIZE)
2314 global_capture_opts.snaplen = MIN_PACKET_SIZE;
2317 global_capture_opts.promisc_mode =
2318 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(promisc_cb));
2320 /* XXX - don't try to get clever and set "cfile.filter" to NULL if the
2321 filter string is empty, as an indication that we don't have a filter
2322 and thus don't have to set a filter when capturing - the version of
2323 libpcap in Red Hat Linux 6.1, and versions based on later patches
2324 in that series, don't bind the AF_PACKET socket to an interface
2325 until a filter is set, which means they aren't bound at all if
2326 no filter is set, which means no packets arrive as input on that
2327 socket, which means Wireshark never sees any packets. */
2328 filter_text = gtk_entry_get_text(GTK_ENTRY(filter_te));
2329 if (global_capture_opts.cfilter)
2330 g_free(global_capture_opts.cfilter);
2331 g_assert(filter_text != NULL);
2332 global_capture_opts.cfilter = g_strdup(filter_text);
2334 /* Wireshark always saves to a capture file. */
2335 global_capture_opts.saving_to_file = TRUE;
2336 g_save_file = gtk_entry_get_text(GTK_ENTRY(file_te));
2337 if (g_save_file && g_save_file[0]) {
2338 /* User specified a file to which the capture should be written. */
2339 global_capture_opts.save_file = g_strdup(g_save_file);
2340 /* Save the directory name for future file dialogs. */
2341 cf_name = g_strdup(g_save_file);
2342 dirname = get_dirname(cf_name); /* Overwrites cf_name */
2343 set_last_open_dir(dirname);
2346 /* User didn't specify a file; save to a temporary file. */
2347 global_capture_opts.save_file = NULL;
2350 global_capture_opts.has_autostop_packets =
2351 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_packets_cb));
2352 if (global_capture_opts.has_autostop_packets)
2353 global_capture_opts.autostop_packets =
2354 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_packets_sb));
2356 global_capture_opts.has_autostop_duration =
2357 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_duration_cb));
2358 if (global_capture_opts.has_autostop_duration) {
2359 global_capture_opts.autostop_duration =
2360 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_duration_sb));
2361 global_capture_opts.autostop_duration =
2362 time_unit_option_menu_get_value(stop_duration_om, global_capture_opts.autostop_duration);
2365 global_capture_opts.real_time_mode =
2366 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sync_cb));
2369 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(auto_scroll_cb));
2371 global_capture_opts.show_info =
2372 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hide_info_cb));
2374 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_resolv_cb)))
2375 g_resolv_flags |= RESOLV_MAC;
2377 g_resolv_flags &= ~RESOLV_MAC;
2378 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(n_resolv_cb)))
2379 g_resolv_flags |= RESOLV_NETWORK;
2381 g_resolv_flags &= ~RESOLV_NETWORK;
2382 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(t_resolv_cb)))
2383 g_resolv_flags |= RESOLV_TRANSPORT;
2385 g_resolv_flags &= ~RESOLV_TRANSPORT;
2387 global_capture_opts.has_ring_num_files =
2388 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb));
2390 global_capture_opts.ring_num_files =
2391 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ringbuffer_nbf_sb));
2392 if (global_capture_opts.ring_num_files > RINGBUFFER_MAX_NUM_FILES)
2393 global_capture_opts.ring_num_files = RINGBUFFER_MAX_NUM_FILES;
2394 #if RINGBUFFER_MIN_NUM_FILES > 0
2395 else if (global_capture_opts.ring_num_files < RINGBUFFER_MIN_NUM_FILES)
2396 global_capture_opts.ring_num_files = RINGBUFFER_MIN_NUM_FILES;
2399 global_capture_opts.multi_files_on =
2400 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(multi_files_on_cb));
2402 global_capture_opts.has_file_duration =
2403 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_duration_cb));
2404 if (global_capture_opts.has_file_duration) {
2405 global_capture_opts.file_duration =
2406 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(file_duration_sb));
2407 global_capture_opts.file_duration =
2408 time_unit_option_menu_get_value(file_duration_om, global_capture_opts.file_duration);
2411 global_capture_opts.has_autostop_files =
2412 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_files_cb));
2413 if (global_capture_opts.has_autostop_files)
2414 global_capture_opts.autostop_files =
2415 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_files_sb));
2417 if (global_capture_opts.multi_files_on) {
2418 global_capture_opts.has_autostop_filesize =
2419 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb));
2420 if (global_capture_opts.has_autostop_filesize) {
2421 tmp = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ring_filesize_sb));
2422 tmp = size_unit_option_menu_convert_value(ring_filesize_om, tmp);
2424 global_capture_opts.autostop_filesize = tmp;
2426 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
2427 "%sMultiple files: Requested filesize too large!%s\n\n"
2428 "The setting \"Next file every x byte(s)\" can't be greater than %u bytes (2GB).",
2429 simple_dialog_primary_start(), simple_dialog_primary_end(), G_MAXINT);
2434 /* test if the settings are ok for a ringbuffer */
2435 if (global_capture_opts.save_file == NULL) {
2436 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
2437 "%sMultiple files: No capture file name given!%s\n\n"
2438 "You must specify a filename if you want to use multiple files.",
2439 simple_dialog_primary_start(), simple_dialog_primary_end());
2441 } else if (!global_capture_opts.has_autostop_filesize && !global_capture_opts.has_file_duration) {
2442 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
2443 "%sMultiple files: No file limit given!%s\n\n"
2444 "You must specify a file size or duration at which is switched to the next capture file\n"
2445 "if you want to use multiple files.",
2446 simple_dialog_primary_start(), simple_dialog_primary_end());
2447 g_free(global_capture_opts.save_file);
2448 global_capture_opts.save_file = NULL;
2452 global_capture_opts.has_autostop_filesize =
2453 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_filesize_cb));
2454 if (global_capture_opts.has_autostop_filesize) {
2455 tmp = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_filesize_sb));
2456 tmp = size_unit_option_menu_convert_value(stop_filesize_om, tmp);
2458 global_capture_opts.autostop_filesize = tmp;
2460 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
2461 "%sStop Capture: Requested filesize too large!%s\n\n"
2462 "The setting \"... after x byte(s)\" can't be greater than %u bytes (2GB).",
2463 simple_dialog_primary_start(), simple_dialog_primary_end(), G_MAXINT);
2467 } /* multi_files_on */
2471 /* user requested to destroy the dialog */
2473 capture_prep_destroy_cb(GtkWidget *win, gpointer user_data _U_)
2476 #ifdef HAVE_PCAP_REMOTE
2478 GtkWidget *remote_w;
2481 /* Is there a file selection dialog associated with this
2482 Capture Options dialog? */
2483 fs = g_object_get_data(G_OBJECT(win), E_FILE_SEL_DIALOG_PTR_KEY);
2485 #ifdef HAVE_PCAP_REMOTE
2486 if_list = (GList *) g_object_get_data(G_OBJECT(win), E_CAP_IF_LIST_KEY);
2488 free_interface_list(if_list);
2493 /* Yes. Destroy it. */
2497 /* Note that we no longer have a "Capture Options" dialog box. */
2501 /* update airpcap toolbar */
2502 airpcap_set_toolbar_stop_capture(airpcap_if_active);
2505 #ifdef HAVE_PCAP_REMOTE
2506 remote_w = g_object_get_data(G_OBJECT(win), E_CAP_REMOTE_DIALOG_PTR_KEY);
2507 if (remote_w != NULL)
2508 window_destroy(remote_w);
2512 /* user changed the interface entry */
2514 capture_prep_interface_changed_cb(GtkWidget *entry, gpointer argp)
2516 GtkWidget *linktype_om = argp;
2518 set_link_type_list(linktype_om, entry);
2522 * Adjust the sensitivity of various widgets as per the current setting
2526 capture_prep_adjust_sensitivity(GtkWidget *tb _U_, gpointer parent_w)
2530 *multi_files_on_cb, *ringbuffer_nbf_cb, *ringbuffer_nbf_sb, *ringbuffer_nbf_lb,
2531 *ring_filesize_cb, *ring_filesize_sb, *ring_filesize_om,
2532 *file_duration_cb, *file_duration_sb, *file_duration_om,
2533 *sync_cb, *auto_scroll_cb, *hide_info_cb,
2534 *stop_packets_cb, *stop_packets_sb, *stop_packets_lb,
2535 *stop_filesize_cb, *stop_filesize_sb, *stop_filesize_om,
2536 *stop_duration_cb, *stop_duration_sb, *stop_duration_om,
2537 *stop_files_cb, *stop_files_sb, *stop_files_lb;
2539 if_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_IFACE_KEY);
2540 snap_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SNAP_CB_KEY);
2541 snap_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SNAP_SB_KEY);
2542 multi_files_on_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_MULTI_FILES_ON_CB_KEY);
2543 ringbuffer_nbf_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_NBF_CB_KEY);
2544 ringbuffer_nbf_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_NBF_SB_KEY);
2545 ringbuffer_nbf_lb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_NBF_LB_KEY);
2546 ring_filesize_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_CB_KEY);
2547 ring_filesize_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_SB_KEY);
2548 ring_filesize_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_OM_KEY);
2549 file_duration_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_DURATION_CB_KEY);
2550 file_duration_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_DURATION_SB_KEY);
2551 file_duration_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_DURATION_OM_KEY);
2552 sync_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SYNC_KEY);
2553 auto_scroll_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_AUTO_SCROLL_KEY);
2554 hide_info_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_HIDE_INFO_KEY);
2555 stop_packets_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_PACKETS_CB_KEY);
2556 stop_packets_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_PACKETS_SB_KEY);
2557 stop_packets_lb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_PACKETS_LB_KEY);
2558 stop_filesize_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_CB_KEY);
2559 stop_filesize_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_SB_KEY);
2560 stop_filesize_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_OM_KEY);
2561 stop_duration_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_CB_KEY);
2562 stop_duration_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_SB_KEY);
2563 stop_duration_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_OM_KEY);
2564 stop_files_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILES_CB_KEY);
2565 stop_files_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILES_SB_KEY);
2566 stop_files_lb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILES_LB_KEY);
2568 /* The snapshot length spinbox is sensitive if the "Limit each packet
2569 to" checkbox is on. */
2570 gtk_widget_set_sensitive(GTK_WIDGET(snap_sb),
2571 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(snap_cb)));
2574 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sync_cb))) {
2575 /* "Update list of packets in real time" captures enabled; we don't
2576 support ring buffer mode for those captures, so turn ring buffer
2577 mode off if it's on, and make its toggle button, and the spin
2578 button for the number of ring buffer files (and the spin button's
2579 label), insensitive. */
2580 /* gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(multi_files_on_cb), FALSE);
2581 gtk_widget_set_sensitive(GTK_WIDGET(multi_files_on_cb), FALSE);*/
2583 /* Auto-scroll mode is meaningful only in "Update list of packets
2584 in real time" captures, so make its toggle button sensitive. */
2585 gtk_widget_set_sensitive(GTK_WIDGET(auto_scroll_cb), TRUE);
2587 /*gtk_widget_set_sensitive(GTK_WIDGET(hide_info_cb), TRUE);*/
2589 /* "Update list of packets in real time" captures disabled; that
2590 means ring buffer mode is OK, so make its toggle button
2592 /* gtk_widget_set_sensitive(GTK_WIDGET(multi_files_on_cb), TRUE);*/
2594 /* Auto-scroll mode is meaningful only in "Update list of packets
2595 in real time" captures, so make its toggle button insensitive. */
2596 gtk_widget_set_sensitive(GTK_WIDGET(auto_scroll_cb), FALSE);
2598 /*gtk_widget_set_sensitive(GTK_WIDGET(hide_info_cb), FALSE);*/
2601 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(multi_files_on_cb))) {
2602 /* Ring buffer mode enabled. */
2604 /* Force at least one of the "file switch" conditions (we need at least one) */
2605 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb)) == FALSE &&
2606 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_duration_cb)) == FALSE) {
2607 if (tb == ring_filesize_cb)
2608 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(file_duration_cb), TRUE);
2610 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ring_filesize_cb), TRUE);
2613 gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_cb), TRUE);
2614 gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_sb),
2615 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb)));
2616 gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_lb),
2617 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb)));
2619 /* The ring filesize spinbox is sensitive if the "Next capture file
2620 after N kilobytes" checkbox is on. */
2621 gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_cb), TRUE);
2622 gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_sb),
2623 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb)));
2624 gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_om),
2625 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb)));
2627 /* The ring duration spinbox is sensitive if the "Next capture file
2628 after N seconds" checkbox is on. */
2629 gtk_widget_set_sensitive(GTK_WIDGET(file_duration_cb), TRUE);
2630 gtk_widget_set_sensitive(GTK_WIDGET(file_duration_sb),
2631 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_duration_cb)));
2632 gtk_widget_set_sensitive(GTK_WIDGET(file_duration_om),
2633 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_duration_cb)));
2635 gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_cb), FALSE);
2636 gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_sb), FALSE);
2637 gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_om), FALSE);
2639 gtk_widget_set_sensitive(GTK_WIDGET(stop_files_cb), TRUE);
2640 gtk_widget_set_sensitive(GTK_WIDGET(stop_files_sb),
2641 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_files_cb)));
2642 gtk_widget_set_sensitive(GTK_WIDGET(stop_files_lb),
2643 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_files_cb)));
2645 /* Ring buffer mode disabled. */
2646 gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_cb), FALSE);
2647 gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_sb), FALSE);
2648 gtk_widget_set_sensitive(GTK_WIDGET(ringbuffer_nbf_lb), FALSE);
2650 gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_cb), FALSE);
2651 gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_sb),FALSE);
2652 gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_om),FALSE);
2654 gtk_widget_set_sensitive(GTK_WIDGET(file_duration_cb), FALSE);
2655 gtk_widget_set_sensitive(GTK_WIDGET(file_duration_sb),FALSE);
2656 gtk_widget_set_sensitive(GTK_WIDGET(file_duration_om),FALSE);
2658 /* The maximum file size spinbox is sensitive if the "Stop capture
2659 after N kilobytes" checkbox is on. */
2660 gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_cb), TRUE);
2661 gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_sb),
2662 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_filesize_cb)));
2663 gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_om),
2664 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_filesize_cb)));
2666 gtk_widget_set_sensitive(GTK_WIDGET(stop_files_cb), FALSE);
2667 gtk_widget_set_sensitive(GTK_WIDGET(stop_files_sb), FALSE);
2668 gtk_widget_set_sensitive(GTK_WIDGET(stop_files_lb), FALSE);
2671 /* The maximum packet count spinbox is sensitive if the "Stop capture
2672 after N packets" checkbox is on. */
2673 gtk_widget_set_sensitive(GTK_WIDGET(stop_packets_sb),
2674 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_packets_cb)));
2675 gtk_widget_set_sensitive(GTK_WIDGET(stop_packets_lb),
2676 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_packets_cb)));
2678 /* The capture duration spinbox is sensitive if the "Stop capture
2679 after N seconds" checkbox is on. */
2680 gtk_widget_set_sensitive(GTK_WIDGET(stop_duration_sb),
2681 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_duration_cb)));
2682 gtk_widget_set_sensitive(GTK_WIDGET(stop_duration_om),
2683 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_duration_cb)));
2686 #endif /* HAVE_LIBPCAP */