Windows: don't attempt to set the capture buffer size on remote (rpcap) devices.

Also move the code for setting the buffer size on Windows near the code for
setting it when we have pcap_create(): into open_capture_device().

Bug: 9067
Change-Id: Ica45f74b98094958d8bb0a38de23248aaa251d4b
Reviewed-on: https://code.wireshark.org/review/8551
Petri-Dish: Jeff Morriss <jeff.morriss.ws@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Jeff Morriss <jeff.morriss.ws@gmail.com>
This commit is contained in:
Jeff Morriss 2015-05-20 11:28:04 -04:00
parent 2772a11bd5
commit 187e8f61dc
1 changed files with 19 additions and 17 deletions

View File

@ -787,6 +787,25 @@ open_capture_device(capture_options *capture_opts
*open_err_str);
g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG,
"pcap_open_live() returned %p.", (void *)pcap_h);
/* Windows doesn't have pcap_create() yet */
#ifdef _WIN32
/* try to set the capture buffer size -- but not for remote devices */
if (interface_opts->buffer_size > 1 &&
pcap_setbuff(pcap_h, interface_opts->buffer_size * 1024 * 1024) != 0) {
gchar *sync_secondary_msg_str;
sync_secondary_msg_str = g_strdup_printf(
"The capture buffer size of %d MiB seems to be too high for your machine,\n"
"the default of %d MiB will be used.\n"
"\n"
"Nonetheless, the capture is started.\n",
interface_opts->buffer_size, DEFAULT_CAPTURE_BUFFER_SIZE);
report_capture_error("Couldn't set the capture buffer size.",
sync_secondary_msg_str);
g_free(sync_secondary_msg_str);
}
#endif
#endif
}
g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "open_capture_device %s : %s", pcap_h ? "SUCCESS" : "FAILURE", interface_opts->name);
@ -2635,7 +2654,6 @@ capture_loop_open_input(capture_options *capture_opts, loop_data *ld,
guint i;
#ifdef _WIN32
int err;
gchar *sync_secondary_msg_str;
WORD wVersionRequested;
WSADATA wsaData;
#endif
@ -2755,22 +2773,6 @@ capture_loop_open_input(capture_options *capture_opts, loop_data *ld,
pcap_opts->ts_nsec = have_high_resolution_timestamp(pcap_opts->pcap_h);
#endif
#ifdef _WIN32
/* try to set the capture buffer size */
if (interface_opts.buffer_size > 1 &&
pcap_setbuff(pcap_opts->pcap_h, interface_opts.buffer_size * 1024 * 1024) != 0) {
sync_secondary_msg_str = g_strdup_printf(
"The capture buffer size of %d MiB seems to be too high for your machine,\n"
"the default of %d MiB will be used.\n"
"\n"
"Nonetheless, the capture is started.\n",
interface_opts.buffer_size, DEFAULT_CAPTURE_BUFFER_SIZE);
report_capture_error("Couldn't set the capture buffer size.",
sync_secondary_msg_str);
g_free(sync_secondary_msg_str);
}
#endif
#if defined(HAVE_PCAP_SETSAMPLING)
if (interface_opts.sampling_method != CAPTURE_SAMP_NONE) {
struct pcap_samp *samp;