Have a #define for whether the capture buffer size can be set.

It can be set if either 1) this is Windows (where we're assumed to be
using WinPcap, which includes calls to set the buffer size) or 2) we
have pcap_create() (in which case we also have pcap_set_buffer_size(),
at least in a normal libpcap release).

Use that rather than testing "defined(_WIN32) ||
defined(HAVE_PCAP_CREATE)"; that makes it a bit more obvious what's
being tested.

Change-Id: Id9f8455019d19206b04dd6820a748cb97ae5ad12
Reviewed-on: https://code.wireshark.org/review/7816
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2015-03-24 20:22:00 -07:00
parent 493ddd5963
commit 083f6b6e6d
20 changed files with 109 additions and 91 deletions

View File

@ -646,7 +646,14 @@ install a newer version of the header file.])
AC_CHECK_FUNCS(pcap_datalink_val_to_description)
AC_CHECK_FUNCS(pcap_list_datalinks pcap_set_datalink pcap_lib_version)
AC_CHECK_FUNCS(pcap_get_selectable_fd pcap_free_datalinks)
AC_CHECK_FUNCS(pcap_create bpf_image pcap_set_tstamp_precision)
AC_CHECK_FUNC(pcap_create,
[
AC_DEFINE(HAVE_PCAP_CREATE, 1,
[Define to 1 if you have the `pcap_create' function.])
AC_DEFINE(CAN_SET_CAPTURE_BUFFER_SIZE, 1,
[Define to 1 if the capture buffer size can be set.])
])
AC_CHECK_FUNCS(bpf_image pcap_set_tstamp_precision)
fi
LIBS="$ac_save_LIBS"
])

View File

@ -359,7 +359,7 @@ sync_pipe_start(capture_options *capture_opts, capture_session *cap_session, voi
char ssampling[ARGV_NUMBER_LEN];
#endif
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
char buffer_size[ARGV_NUMBER_LEN];
#endif
@ -503,7 +503,7 @@ sync_pipe_start(capture_options *capture_opts, capture_session *cap_session, voi
argv = sync_pipe_add_arg(argv, &argc, "-p");
}
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
if (interface_opts.buffer_size != DEFAULT_CAPTURE_BUFFER_SIZE) {
argv = sync_pipe_add_arg(argv, &argc, "-B");
if(interface_opts.buffer_size == 0x00)

View File

@ -71,7 +71,7 @@ capture_opts_init(capture_options *capture_opts)
capture_opts->default_options.extcap_args = NULL;
capture_opts->default_options.extcap_pid = INVALID_EXTCAP_PID;
#endif
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
capture_opts->default_options.buffer_size = DEFAULT_CAPTURE_BUFFER_SIZE;
#endif
capture_opts->default_options.monitor_mode = FALSE;
@ -148,7 +148,7 @@ capture_opts_log(const char *log_domain, GLogLevelFlags log_level, capture_optio
g_log(log_domain, log_level, "Extcap FIFO[%02d] : %s", i, interface_opts.extcap_fifo ? interface_opts.extcap_fifo : "(unspecified)");
g_log(log_domain, log_level, "Extcap PID[%02d] : %d", i, interface_opts.extcap_pid);
#endif
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
g_log(log_domain, log_level, "Buffer size[%02d] : %d (MB)", i, interface_opts.buffer_size);
#endif
g_log(log_domain, log_level, "Monitor Mode[%02d] : %s", i, interface_opts.monitor_mode?"TRUE":"FALSE");
@ -188,7 +188,7 @@ capture_opts_log(const char *log_domain, GLogLevelFlags log_level, capture_optio
g_log(log_domain, log_level, "Extcap[df] : %s", capture_opts->default_options.extcap ? capture_opts->default_options.extcap : "(unspecified)");
g_log(log_domain, log_level, "Extcap FIFO[df] : %s", capture_opts->default_options.extcap_fifo ? capture_opts->default_options.extcap_fifo : "(unspecified)");
#endif
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
g_log(log_domain, log_level, "Buffer size[df] : %d (MB)", capture_opts->default_options.buffer_size);
#endif
g_log(log_domain, log_level, "Monitor Mode[df] : %s", capture_opts->default_options.monitor_mode?"TRUE":"FALSE");
@ -611,7 +611,7 @@ capture_opts_add_iface_opt(capture_options *capture_opts, const char *optarg_str
interface_opts.extcap_args = NULL;
interface_opts.extcap_pid = INVALID_EXTCAP_PID;
#endif
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
interface_opts.buffer_size = capture_opts->default_options.buffer_size;
#endif
interface_opts.monitor_mode = capture_opts->default_options.monitor_mode;
@ -671,7 +671,7 @@ capture_opts_add_opt(capture_options *capture_opts, int opt, const char *optarg_
return 1;
}
break;
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
case 'B': /* Buffer size */
if (capture_opts->ifaces->len > 0) {
interface_options interface_opts;
@ -1097,7 +1097,7 @@ collect_ifaces(capture_options *capture_opts)
if (interface_opts.extcap_args)
g_hash_table_ref(interface_opts.extcap_args);
#endif
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
interface_opts.buffer_size = device.buffer;
#endif
#ifdef HAVE_PCAP_CREATE

View File

@ -74,7 +74,7 @@ extern "C" {
#define OPTSTRING_A ""
#endif
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
#define LONGOPT_BUFFER_SIZE \
{(char *)"buffer-size", required_argument, NULL, 'B'},
#define OPTSTRING_B "B:"
@ -179,7 +179,7 @@ typedef struct interface_tag {
gboolean has_snaplen;
int snaplen;
gboolean local;
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
gint buffer;
#endif
#ifdef HAVE_PCAP_CREATE
@ -229,7 +229,7 @@ typedef struct interface_options_tag {
GPid extcap_pid; /* pid of running process or INVALID_EXTCAP_PID */
guint extcap_child_watch;
#endif
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
int buffer_size;
#endif
gboolean monitor_mode;

View File

@ -63,8 +63,19 @@ check_function_exists( "pcap_freecode" HAVE_PCAP_FREECODE )
check_function_exists( "pcap_breakloop" HAVE_PCAP_BREAKLOOP )
# FIXME: The code (at least) in dumpcap assumes that PCAP_CREATE is not
# available on Windows
if( NOT WIN32 )
if( WIN32 )
#
# This is always the case with WinPcap.
#
set(CAN_SET_CAPTURE_BUFFER_SIZE TRUE)
else()
check_function_exists( "pcap_create" HAVE_PCAP_CREATE )
if ( HAVE_PCAP_CREATE )
#
# For libpcap, we can set the buffer size if we have pcap_create().
#
set( CAN_SET_CAPTURE_BUFFER_SIZE TRUE )
endif()
endif()
check_function_exists( "pcap_datalink_name_to_val" HAVE_PCAP_DATALINK_NAME_TO_VAL )
check_function_exists( "pcap_datalink_val_to_description" HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION )

View File

@ -205,6 +205,9 @@
/* Define to 1 if you have the `pcap_create' function. */
#cmakedefine HAVE_PCAP_CREATE 1
/* Define to 1 if the capture buffer size can be set. */
#cmakedefine CAN_SET_CAPTURE_BUFFER_SIZE 1
/* Define to 1 if you have the `pcap_datalink_name_to_val' function. */
#cmakedefine HAVE_PCAP_DATALINK_NAME_TO_VAL 1

View File

@ -48,10 +48,15 @@
@HAVE_LIBPCAP@
@HAVE_PCAP_BREAKLOOP@
@HAVE_PCAP_FINDALLDEVS@
@HAVE_PCAP_DATALINK_NAME_TO_VAL@
@HAVE_PCAP_DATALINK_VAL_TO_NAME@
/* Always true in WinPcap, even without pcap_capture(). */
/* Define to 1 if the capture buffer size can be set. */
#define CAN_SET_CAPTURE_BUFFER_SIZE 1
@HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION@
@HAVE_PCAP_DATALINK_VAL_TO_NAME@
@HAVE_PCAP_FINDALLDEVS@
@HAVE_PCAP_LIST_DATALINKS@
@HAVE_PCAP_FREE_DATALINKS@

View File

@ -488,7 +488,7 @@ print_usage(FILE *output)
#ifdef HAVE_PCAP_CREATE
fprintf(output, " -I capture in monitor mode, if available\n");
#endif
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
fprintf(output, " -B <buffer size> size of kernel buffer in MiB (def: %dMiB)\n", DEFAULT_CAPTURE_BUFFER_SIZE);
#endif
fprintf(output, " -y <link type> link layer type (def: first appropriate)\n");
@ -4602,9 +4602,9 @@ DIAG_ON(cast-qual)
#ifdef HAVE_PCAP_SETSAMPLING
case 'm': /* Sampling */
#endif
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
case 'B': /* Buffer size */
#endif /* _WIN32 or HAVE_PCAP_CREATE */
#endif
#ifdef HAVE_PCAP_CREATE
case 'I': /* Monitor mode */
#endif

View File

@ -167,7 +167,7 @@ static const gchar *capture_cols[7] = {
};
#define CAPTURE_COL_TYPE_DESCRIPTION \
"Possible values: INTERFACE, LINK, PMODE, SNAPLEN, MONITOR, BUFFER, FILTER\n"
#elif defined(_WIN32) && !defined (HAVE_PCAP_CREATE)
#elif defined(CAN_SET_CAPTURE_BUFFER_SIZE)
/* Can set buffer size but not monitor mode. */
static gint num_capture_cols = 6;
static const gchar *capture_cols[6] = {
@ -2389,7 +2389,7 @@ prefs_register_modules(void)
"By default, capture in monitor mode on interface? (Ex: eth0,eth3,...)",
(const char **)&prefs.capture_devices_monitor_mode);
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
prefs_register_string_preference(capture_module, "devices_buffersize", "Interface buffer size",
"Interface buffer size (Ex: en0(1),en1(143),...)",
((const char **)&prefs.capture_devices_buffersize));

View File

@ -188,7 +188,7 @@ typedef struct _e_prefs {
gchar *capture_devices_descr;
gchar *capture_devices_hide;
gchar *capture_devices_monitor_mode;
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
gchar *capture_devices_buffersize;
#endif
gchar *capture_devices_snaplen;

View File

@ -310,7 +310,7 @@ print_usage(FILE *output)
#ifdef HAVE_PCAP_CREATE
fprintf(output, " -I capture in monitor mode, if available\n");
#endif
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
fprintf(output, " -B <buffer size> size of kernel buffer (def: %dMB)\n", DEFAULT_CAPTURE_BUFFER_SIZE);
#endif
fprintf(output, " -y <link type> link layer type (def: first appropriate)\n");
@ -1378,9 +1378,9 @@ DIAG_ON(cast-qual)
case 'w': /* Write to capture file x */
case 'y': /* Set the pcap data link type */
case LONGOPT_NUM_CAP_COMMENT: /* add a capture comment */
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
case 'B': /* Buffer size */
#endif /* _WIN32 or HAVE_PCAP_CREATE */
#endif
#ifdef HAVE_LIBPCAP
status = capture_opts_add_opt(&global_capture_opts, opt, optarg, &start_capture);
if (status != 0) {

View File

@ -145,7 +145,7 @@ capture_dev_user_linktype_find(const gchar *if_name)
return capture_dev_get_if_int_property(prefs.capture_devices_linktypes, if_name);
}
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
gint
capture_dev_user_buffersize_find(const gchar *if_name)
{

View File

@ -54,7 +54,7 @@ char *capture_dev_user_descr_find(const gchar *if_name);
*/
gint capture_dev_user_linktype_find(const gchar *if_name);
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
/**
* Find user-specified buffer size that matches interface
* name, if any.

View File

@ -85,14 +85,6 @@
#include "ui/gtk/extcap_gtk.h"
#endif
/*
* If this is WinPcap or if we have pcap_create(), we can set the
* buffer size.
*/
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#define HAVE_BUFFER_SIZE
#endif
/*
* Symbolic names for column indices.
*/
@ -104,7 +96,7 @@ enum
LINK,
PMODE,
SNAPLEN,
#ifdef HAVE_BUFFER_SIZE
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
BUFFER,
#endif
#ifdef HAVE_PCAP_CREATE
@ -133,7 +125,7 @@ enum
#define E_CAP_SNAP_CB_KEY "cap_snap_cb"
#define E_CAP_LT_CBX_KEY "cap_lt_cbx"
#define E_CAP_LT_CBX_LABEL_KEY "cap_lt_cbx_label"
#ifdef HAVE_BUFFER_SIZE
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
#define E_CAP_BUFFER_SIZE_SB_KEY "cap_buffer_size_sb"
#endif
#define E_CAP_SNAP_SB_KEY "cap_snap_sb"
@ -329,7 +321,7 @@ gchar *col_index_to_name(gint indx)
break;
case SNAPLEN: col_name = g_strdup("SNAPLEN");
break;
#ifdef HAVE_BUFFER_SIZE
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
case BUFFER: col_name = g_strdup("BUFFER");
break;
#endif
@ -352,7 +344,7 @@ gint col_title_to_index(const gchar *name)
if (strcmp(name, "Link-layer header") == 0) return LINK;
if (strcmp(name, "Prom. Mode") == 0) return PMODE;
if (strcmp(name, "Snaplen [B]") == 0) return SNAPLEN;
#ifdef HAVE_BUFFER_SIZE
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
if (strcmp(name, "Buffer [MiB]") == 0) return BUFFER;
#endif
#ifdef HAVE_PCAP_CREATE
@ -1275,7 +1267,7 @@ insert_new_rows(GList *list)
} else {
device.display_name = g_strdup(if_string);
}
#ifdef HAVE_BUFFER_SIZE
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
if ((device.buffer = capture_dev_user_buffersize_find(if_string)) == -1) {
device.buffer = global_capture_opts.default_options.buffer_size;
}
@ -1391,7 +1383,7 @@ insert_new_rows(GList *list)
#if defined(HAVE_PCAP_CREATE)
gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, FALSE, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp, LINK, link_type_name, PMODE, (device.pmode?"enabled":"disabled"), SNAPLEN, snaplen_string, BUFFER, device.buffer, MONITOR, "no",FILTER, "",-1);
#elif defined(HAVE_BUFFER_SIZE)
#elif defined(CAN_SET_CAPTURE_BUFFER_SIZE)
gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, FALSE, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp, LINK, link_type_name, PMODE, (device.pmode?"enabled":"disabled"), SNAPLEN, snaplen_string, BUFFER, device.buffer, FILTER, "",-1);
#else
gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, FALSE, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp, LINK, link_type_name, PMODE, (device.pmode?"enabled":"disabled"), SNAPLEN, snaplen_string, -1);
@ -2357,7 +2349,7 @@ update_options_table(gint indx)
}
#if defined(HAVE_PCAP_CREATE)
gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp, LINK, linkname, PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, BUFFER, (guint) device.buffer, MONITOR, device.monitor_mode_supported?(device.monitor_mode_enabled?"enabled":"disabled"):"n/a", FILTER, device.cfilter, -1);
#elif defined(HAVE_BUFFER_SIZE)
#elif defined(CAN_SET_CAPTURE_BUFFER_SIZE)
gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp,LINK, linkname, PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, BUFFER, (guint) device.buffer, FILTER, device.cfilter, -1);
#else
gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp,LINK, linkname, PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, FILTER, device.cfilter, -1);
@ -2396,7 +2388,7 @@ save_options_cb(GtkWidget *win _U_, gpointer user_data _U_)
*monitor_cb,
#endif
*filter_cm, *linktype_combo_box;
#ifdef HAVE_BUFFER_SIZE
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
GtkWidget *buffer_size_sb;
#endif
#ifdef HAVE_EXTCAP
@ -2412,7 +2404,7 @@ save_options_cb(GtkWidget *win _U_, gpointer user_data _U_)
global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, marked_interface);
snap_cb = (GtkWidget *) g_object_get_data(G_OBJECT(opt_edit_w), E_CAP_SNAP_CB_KEY);
snap_sb = (GtkWidget *) g_object_get_data(G_OBJECT(opt_edit_w), E_CAP_SNAP_SB_KEY);
#ifdef HAVE_BUFFER_SIZE
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
buffer_size_sb = (GtkWidget *) g_object_get_data(G_OBJECT(opt_edit_w), E_CAP_BUFFER_SIZE_SB_KEY);
#endif
promisc_cb = (GtkWidget *) g_object_get_data(G_OBJECT(opt_edit_w), E_CAP_PROMISC_KEY);
@ -2439,7 +2431,7 @@ save_options_cb(GtkWidget *win _U_, gpointer user_data _U_)
}
}
device.active_dlt = dlt;
#ifdef HAVE_BUFFER_SIZE
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
device.buffer = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(buffer_size_sb));
#endif
device.pmode = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(promisc_cb));
@ -2548,12 +2540,12 @@ static GtkWidget *build_extcap_options(const gchar *name, GHashTable *hash) {
* We avoid having the right column if we don't need it, because it
* steals 3 pixels.
*/
#if defined(HAVE_AIRPCAP) || defined(HAVE_PCAP_REMOTE) || defined(HAVE_BUFFER_SIZE)
#if defined(HAVE_AIRPCAP) || defined(HAVE_PCAP_REMOTE) || defined(CAN_SET_CAPTURE_BUFFER_SIZE)
#define HAVE_TWO_SETTING_COLUMNS
# if !defined(HAVE_PCAP_REMOTE)
# define BUFFER_SIZE_IN_RIGHT_COLUMN
# endif /* !defined(HAVE_PCAP_REMOTE) */
#endif /* defined(HAVE_AIRPCAP) || defined(HAVE_PCAP_REMOTE) || defined(HAVE_BUFFER_SIZE) */
#endif /* defined(HAVE_AIRPCAP) || defined(HAVE_PCAP_REMOTE) || defined(CAN_SET_CAPTURE_BUFFER_SIZE) */
void options_interface_cb(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *column _U_, gpointer userdata)
{
@ -2584,7 +2576,7 @@ void options_interface_cb(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColum
GList *cf_entry, *list, *cfilter_list;
GtkAdjustment *snap_adj;
#ifdef HAVE_BUFFER_SIZE
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
GtkAdjustment *buffer_size_adj;
GtkWidget *buffer_size_lb, *buffer_size_sb, *buffer_size_hb;
#endif
@ -2631,7 +2623,7 @@ void options_interface_cb(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColum
device.has_snaplen = FALSE;
device.snaplen = 65535;
device.cfilter = NULL;
#ifdef HAVE_BUFFER_SIZE
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
device.buffer = DEFAULT_CAPTURE_BUFFER_SIZE;
#endif
#ifdef HAVE_EXTCAP
@ -2943,7 +2935,7 @@ void options_interface_cb(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColum
gtk_box_pack_start(GTK_BOX(filter_hb), compile_bt, FALSE, FALSE, 3);
#endif
#ifdef HAVE_BUFFER_SIZE
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
buffer_size_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
buffer_size_lb = gtk_label_new("Buffer size:");
gtk_box_pack_start (GTK_BOX(buffer_size_hb), buffer_size_lb, FALSE, FALSE, 0);
@ -2966,7 +2958,7 @@ void options_interface_cb(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColum
#else /* BUFFER_SIZE_IN_RIGHT_COLUMN */
gtk_box_pack_start (GTK_BOX(left_vb), buffer_size_hb, FALSE, FALSE, 0);
#endif /* BUFFER_SIZE_IN_RIGHT_COLUMN */
#endif /* HAVE_BUFFER_SIZE */
#endif /* CAN_SET_CAPTURE_BUFFER_SIZE */
#ifdef HAVE_PCAP_REMOTE
/*
@ -3369,7 +3361,7 @@ static void change_pipe_name_cb(gpointer dialog _U_, gint btn, gpointer data)
if (strcmp(optname, pipe_name) == 0) {
#if defined(HAVE_PCAP_CREATE)
gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp, LINK, "", PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, BUFFER, (guint) device.buffer, MONITOR, device.monitor_mode_supported?(device.monitor_mode_enabled?"enabled":"disabled"):"n/a", FILTER, device.cfilter, -1);
#elif defined(HAVE_BUFFER_SIZE)
#elif defined(CAN_SET_CAPTURE_BUFFER_SIZE)
gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp,LINK, "", PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, BUFFER, (guint) device.buffer, FILTER, device.cfilter, -1);
#else
gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp,LINK, "", PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, FILTER, device.cfilter, -1);
@ -3477,7 +3469,7 @@ add_pipe_cb(gpointer w _U_)
device.no_addresses = 0;
device.last_packets = 0;
device.links = NULL;
#ifdef HAVE_BUFFER_SIZE
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
device.buffer = DEFAULT_CAPTURE_BUFFER_SIZE;
#endif
device.active_dlt = -1;
@ -3507,7 +3499,7 @@ add_pipe_cb(gpointer w _U_)
gtk_list_store_append (GTK_LIST_STORE(model), &iter);
#if defined(HAVE_PCAP_CREATE)
gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp, LINK, "", PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, BUFFER, (guint) device.buffer, MONITOR, device.monitor_mode_supported?(device.monitor_mode_enabled?"enabled":"disabled"):"n/a", FILTER, device.cfilter, -1);
#elif defined(HAVE_BUFFER_SIZE)
#elif defined(CAN_SET_CAPTURE_BUFFER_SIZE)
gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp,LINK, "", PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, BUFFER, (guint) device.buffer, FILTER, device.cfilter, -1);
#else
gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp,LINK, "", PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, FILTER, device.cfilter, -1);
@ -4724,7 +4716,7 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
gtk_tree_view_column_set_visible(column, FALSE);
g_object_set(renderer, "xalign", 0.5f, NULL);
#ifdef HAVE_BUFFER_SIZE
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
renderer = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes("Buffer [MiB]", renderer, "text", BUFFER, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
@ -5663,7 +5655,7 @@ create_and_fill_model(GtkTreeView *view)
guint i;
link_row *linkr = NULL;
interface_t device;
#ifdef HAVE_BUFFER_SIZE
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
gint buffer;
#endif
gint snaplen;
@ -5671,7 +5663,7 @@ create_and_fill_model(GtkTreeView *view)
#if defined(HAVE_PCAP_CREATE)
store = gtk_list_store_new (9, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING);
#elif defined(HAVE_BUFFER_SIZE)
#elif defined(CAN_SET_CAPTURE_BUFFER_SIZE)
store = gtk_list_store_new (8, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING);
#else
store = gtk_list_store_new (7, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
@ -5712,7 +5704,7 @@ create_and_fill_model(GtkTreeView *view)
snaplen_string = g_strdup_printf("%d", device.snaplen);
#ifdef HAVE_BUFFER_SIZE
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
if (capture_dev_user_buffersize_find(device.name) != -1) {
buffer = capture_dev_user_buffersize_find(device.name);
device.buffer = buffer;
@ -5725,7 +5717,7 @@ create_and_fill_model(GtkTreeView *view)
gtk_list_store_append (store, &iter);
#if defined(HAVE_PCAP_CREATE)
gtk_list_store_set (store, &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp, LINK, linkname, PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, BUFFER, (guint) device.buffer, MONITOR, device.monitor_mode_supported?(device.monitor_mode_enabled?"enabled":"disabled"):"n/a", FILTER, device.cfilter, -1);
#elif defined(HAVE_BUFFER_SIZE)
#elif defined(CAN_SET_CAPTURE_BUFFER_SIZE)
gtk_list_store_set (store, &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp, LINK, linkname, PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, BUFFER, (guint) device.buffer, FILTER, device.cfilter, -1);
#else
gtk_list_store_set (store, &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp, LINK, linkname, PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, FILTER, device.cfilter, -1);
@ -5780,7 +5772,7 @@ query_tooltip_tree_view_cb (GtkWidget *widget,
case SNAPLEN: g_snprintf(buffer, sizeof(buffer), "Limit the maximum number of bytes to be captured from each packet. This size includes the "
"link-layer header and all subsequent headers.");
break;
#ifdef HAVE_BUFFER_SIZE
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
case BUFFER: g_snprintf (buffer, sizeof(buffer), "The memory buffer size used while capturing. "
"If you notice packet drops, you can try increasing this size.");
break;

View File

@ -1198,7 +1198,7 @@ print_usage(gboolean for_help_option) {
#ifdef HAVE_PCAP_CREATE
fprintf(output, " -I capture in monitor mode, if available\n");
#endif
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
fprintf(output, " -B <buffer size> size of kernel buffer (def: %dMB)\n", DEFAULT_CAPTURE_BUFFER_SIZE);
#endif
fprintf(output, " -y <link type> link layer type (def: first appropriate)\n");
@ -2604,9 +2604,9 @@ DIAG_ON(cast-qual)
case 'S': /* "Sync" mode: used for following file ala tail -f */
case 'w': /* Write to capture file xxx */
case 'y': /* Set the pcap data link type */
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
case 'B': /* Buffer size */
#endif /* _WIN32 or HAVE_PCAP_CREATE */
#endif
#ifdef HAVE_LIBPCAP
status = capture_opts_add_opt(&global_capture_opts, opt, optarg,
&start_capture);

View File

@ -71,7 +71,7 @@ static GtkWidget *cur_list, *if_dev_lb, *if_name_lb, *if_linktype_lb, *if_linkty
#ifdef HAVE_PCAP_CREATE
static GtkWidget *if_monitor_lb, *if_monitor_cb;
#endif
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
static GtkWidget *if_buffersize_lb, *if_buffersize_cb;
#endif
static GtkWidget *if_snaplen_lb, *if_snaplen_cb, *if_snaplen_tg, *if_pmode_lb, *if_pmode_cb;
@ -90,7 +90,7 @@ static void ifopts_edit_monitor_changed_cb(GtkToggleButton *tbt, gpointer udata)
static void ifopts_edit_linktype_changed_cb(GtkComboBox *ed, gpointer udata);
static void ifopts_edit_descr_changed_cb(GtkEditable *ed, gpointer udata);
static void ifopts_edit_hide_changed_cb(GtkToggleButton *tbt, gpointer udata);
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
static void ifopts_edit_buffersize_changed_cb(GtkSpinButton *ed, gpointer udata);
#endif
static void ifopts_edit_snaplen_changed_cb(GtkSpinButton *ed, gpointer udata);
@ -103,7 +103,7 @@ static void ifopts_if_liststore_add(void);
static void ifopts_write_new_monitor_mode(void);
#endif
static void ifopts_write_new_linklayer(void);
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
static void ifopts_write_new_buffersize(void);
#endif
static void ifopts_write_new_snaplen(void);
@ -116,7 +116,7 @@ static void prom_mode_cb(GtkToggleButton *tbt, gpointer udata);
#ifdef HAVE_PCAP_CREATE
static GtkWidget *col_monitor_cb;
#endif
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
static GtkWidget *col_buf_cb;
#endif
static GtkWidget *col_snap_cb;
@ -344,7 +344,7 @@ enum
#ifdef HAVE_PCAP_CREATE
DEF_MONITOR_MODE_COLUMN,
#endif
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
BUF_COLUMN,
#endif
HASSNAP_COLUMN,
@ -368,7 +368,7 @@ colopts_edit_cb(GtkWidget *w, gpointer data _U_)
#ifdef HAVE_PCAP_CREATE
*col_monitor_lb,
#endif
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
*col_buf_lb,
#endif
*col_filter_lb, *col_pmode_lb,
@ -464,7 +464,7 @@ colopts_edit_cb(GtkWidget *w, gpointer data _U_)
gtk_widget_show(col_snap_lb);
row++;
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
/* create "Buffer in Megabytes" label and button */
col_buf_cb = gtk_check_button_new();
ws_gtk_grid_attach_defaults(GTK_GRID(main_grid), col_buf_cb, 0, row, 1, 1);
@ -566,7 +566,7 @@ ifopts_edit_cb(GtkWidget *w, gpointer data _U_)
GtkCellRenderer *renderer;
GtkTreeView *list_view;
GtkTreeSelection *selection;
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
GtkAdjustment *buffer_size_adj;
#endif
GtkAdjustment *snaplen_adj;
@ -612,7 +612,7 @@ ifopts_edit_cb(GtkWidget *w, gpointer data _U_)
#ifdef HAVE_PCAP_CREATE
G_TYPE_BOOLEAN, /* Monitor mode */
#endif
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
G_TYPE_INT, /* Buffer size */
#endif
G_TYPE_BOOLEAN, /* Has snap length */
@ -675,7 +675,7 @@ ifopts_edit_cb(GtkWidget *w, gpointer data _U_)
gtk_tree_view_append_column (list_view, column);
#endif
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
renderer = gtk_cell_renderer_spin_new ();
buffer_size_adj = (GtkAdjustment *) gtk_adjustment_new(DEFAULT_CAPTURE_BUFFER_SIZE, 1, 65535, 1.0, 10.0, 0.0);
g_object_set(G_OBJECT(renderer), "adjustment", buffer_size_adj, NULL);
@ -829,7 +829,7 @@ ifopts_edit_cb(GtkWidget *w, gpointer data _U_)
row++;
#endif
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
if_buffersize_lb = gtk_label_new("Default buffer size (MiB):");
ws_gtk_grid_attach_defaults(GTK_GRID(main_grid), if_buffersize_lb, 0, row, 1, 1);
gtk_misc_set_alignment(GTK_MISC(if_buffersize_lb), 1.0f, 0.5f);
@ -973,7 +973,7 @@ colopts_edit_ok_cb(GtkWidget *w _U_, gpointer parent_w)
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(col_snap_cb))) {
prefs.capture_columns = g_list_append(prefs.capture_columns, g_strdup("SNAPLEN"));
}
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(col_buf_cb))) {
prefs.capture_columns = g_list_append(prefs.capture_columns, g_strdup("BUFFER"));
}
@ -1016,7 +1016,7 @@ ifopts_edit_ok_cb(GtkWidget *w _U_, gpointer parent_w)
/* create/write new "hidden" interfaces string */
ifopts_write_new_hide();
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
/* create/write new "buffersize" interfaces string */
ifopts_write_new_buffersize();
#endif
@ -1116,7 +1116,7 @@ ifopts_edit_ifsel_cb(GtkTreeSelection *selection _U_,
#ifdef HAVE_PCAP_CREATE
gboolean monitor_mode;
#endif
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
gint buffersize;
#endif
gint snaplen;
@ -1134,7 +1134,7 @@ ifopts_edit_ifsel_cb(GtkTreeSelection *selection _U_,
#ifdef HAVE_PCAP_CREATE
DEF_MONITOR_MODE_COLUMN, &monitor_mode,
#endif
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
BUF_COLUMN, &buffersize,
#endif
HASSNAP_COLUMN, &hassnap,
@ -1151,7 +1151,7 @@ ifopts_edit_ifsel_cb(GtkTreeSelection *selection _U_,
/* display the interface name from current interfaces selection */
gtk_label_set_text(GTK_LABEL(if_name_lb), desc);
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
/* display the buffer size from current interfaces selection */
gtk_spin_button_set_value(GTK_SPIN_BUTTON (if_buffersize_cb), buffersize);
#endif
@ -1397,7 +1397,7 @@ ifopts_edit_linktype_changed_cb(GtkComboBox *cb, gpointer udata)
}
}
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
/*
* Buffer size entry changed callback; update list_store for currently selected interface.
*/
@ -1600,7 +1600,7 @@ ifopts_options_add(GtkListStore *list_store, if_info_t *if_info)
gboolean monitor_mode;
#endif
gint linktype;
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
gint buffersize;
#endif
gint snaplen;
@ -1647,7 +1647,7 @@ ifopts_options_add(GtkListStore *list_store, if_info_t *if_info)
free_if_capabilities(caps);
}
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
buffersize = capture_dev_user_buffersize_find(if_info->name);
if (buffersize == -1) {
buffersize = DEFAULT_CAPTURE_BUFFER_SIZE;
@ -1733,7 +1733,7 @@ ifopts_options_add(GtkListStore *list_store, if_info_t *if_info)
#ifdef HAVE_PCAP_CREATE
DEF_MONITOR_MODE_COLUMN, monitor_mode,
#endif
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
BUF_COLUMN, buffersize,
#endif
HASSNAP_COLUMN, hassnap,
@ -1906,7 +1906,7 @@ ifopts_write_new_linklayer(void)
}
}
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
/*
* Create/write new interfaces buffer size string based on current CList.
* Put it into the preferences value.

View File

@ -285,7 +285,7 @@ scan_local_interfaces(void (*update_cb)(void))
device.snaplen = global_capture_opts.default_options.snaplen;
}
device.cfilter = g_strdup(global_capture_opts.default_options.cfilter);
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
if ((device.buffer = capture_dev_user_buffersize_find(if_info->name)) == -1) {
device.buffer = global_capture_opts.default_options.buffer_size;
}
@ -350,7 +350,7 @@ scan_local_interfaces(void (*update_cb)(void))
device.hidden = FALSE;
device.selected = TRUE;
device.type = IF_PIPE;
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
device.buffer = interface_opts.buffer_size;
#endif
#if defined(HAVE_PCAP_CREATE)

View File

@ -65,7 +65,7 @@
const int stat_update_interval_ = 1000; // ms
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
#define SHOW_BUFFER_COLUMN 1
#endif

View File

@ -271,7 +271,7 @@ void ManageInterfacesDialog::pipeAccepted()
device.no_addresses = 0;
device.last_packets = 0;
device.links = NULL;
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
device.buffer = DEFAULT_CAPTURE_BUFFER_SIZE;
#endif
device.active_dlt = -1;
@ -535,7 +535,7 @@ void ManageInterfacesDialog::addRemoteInterfaces(GList* rlist, remote_options *r
} else {
device.display_name = g_strdup(if_string);
}
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
if ((device.buffer = capture_dev_user_buffersize_find(if_string)) == -1) {
device.buffer = global_capture_opts.default_options.buffer_size;
}

View File

@ -183,7 +183,7 @@ print_usage(gboolean for_help_option) {
#ifdef HAVE_PCAP_CREATE
fprintf(output, " -I capture in monitor mode, if available\n");
#endif
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
fprintf(output, " -B <buffer size> size of kernel buffer (def: %dMB)\n", DEFAULT_CAPTURE_BUFFER_SIZE);
#endif
fprintf(output, " -y <link type> link layer type (def: first appropriate)\n");
@ -896,9 +896,9 @@ DIAG_ON(cast-qual)
case 'S': /* "Sync" mode: used for following file ala tail -f */
case 'w': /* Write to capture file xxx */
case 'y': /* Set the pcap data link type */
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
case 'B': /* Buffer size */
#endif /* _WIN32 or HAVE_PCAP_CREATE */
#endif
#ifdef HAVE_LIBPCAP
status = capture_opts_add_opt(&global_capture_opts, opt, optarg,
&start_capture);