#include "version_info.h"
#include "capture-pcap-util.h"
+#ifdef _WIN32
+#include "capture-wpcap.h"
+#endif /* _WIN32 */
#include "pcapio.h"
output = stdout;
fprintf(output,
"Dumpcap " VERSION "%s\n"
- "Capture network packets and dump them into a libpcap file.\n"
+ "Capture network packets and dump them into a pcapng file.\n"
"See http://www.wireshark.org for more information.\n",
wireshark_svnversion);
} else {
fprintf(output, " -b <ringbuffer opt.> ... duration:NUM - switch to next file after NUM secs\n");
fprintf(output, " filesize:NUM - switch to next file after NUM KB\n");
fprintf(output, " files:NUM - ringbuffer: replace after NUM files\n");
- fprintf(output, " -n use pcapng format instead of pcap\n");
+ fprintf(output, " -n use pcapng format instead of pcap (default)\n");
+ fprintf(output, " -P use libpcap format instead of pcapng\n");
fprintf(output, "\n");
fprintf(output, "Miscellaneous:\n");
fprintf(output, " -t use a separate thread per interface\n");
fprintf(output, " -v print version information and exit\n");
fprintf(output, " -h display this help and exit\n");
fprintf(output, "\n");
- fprintf(output, "Example: dumpcap -i eth0 -a duration:60 -w output.pcap\n");
- fprintf(output, "\"Capture network packets from interface eth0 until 60s passed into output.pcap\"\n");
+ fprintf(output, "Example: dumpcap -i eth0 -a duration:60 -w output.pcapng\n");
+ fprintf(output, "\"Capture network packets from interface eth0 until 60s passed into output.pcapng\"\n");
fprintf(output, "\n");
fprintf(output, "Use Ctrl-C to stop capturing at any time.\n");
}
libpcap_warn = "";
g_snprintf(errmsg, (gulong) errmsg_len,
"The capture session could not be initiated (%s).", open_err_str);
-#ifndef _WIN32
+#ifdef _WIN32
+ if (!has_wpcap) {
+ g_snprintf(secondary_errmsg, (gulong) secondary_errmsg_len,
+ "\n"
+ "In order to capture packets, WinPcap must be installed; see\n"
+ "\n"
+ " http://www.winpcap.org/\n"
+ "\n"
+ "or the mirror at\n"
+ "\n"
+ " http://www.mirrors.wiretapped.net/security/packet-capture/winpcap/\n"
+ "\n"
+ "or the mirror at\n"
+ "\n"
+ " http://winpcap.cs.pu.edu.tw/\n"
+ "\n"
+ "for a downloadable version of WinPcap and for instructions on how to install\n"
+ "WinPcap.");
+ } else {
+ g_snprintf(secondary_errmsg, (gulong) secondary_errmsg_len,
+ "\n"
+ "Please check that \"%s\" is the proper interface.\n"
+ "\n"
+ "\n"
+ "Help can be found at:\n"
+ "\n"
+ " http://wiki.wireshark.org/WinPcap\n"
+ " http://wiki.wireshark.org/CaptureSetup\n",
+ iface);
+ }
+#else
g_snprintf(secondary_errmsg, (gulong) secondary_errmsg_len,
"Please check to make sure you have sufficient permissions, and that you have "
"the proper interface or pipe specified.%s", libpcap_warn);
-#else
- g_snprintf(secondary_errmsg, (gulong) secondary_errmsg_len,
- "\n"
- "Please check that \"%s\" is the proper interface.\n"
- "\n"
- "\n"
- "Help can be found at:\n"
- "\n"
- " http://wiki.wireshark.org/WinPcap\n"
- " http://wiki.wireshark.org/CaptureSetup\n",
- iface);
#endif /* _WIN32 */
}
if (if_list == NULL) {
switch (err) {
case CANT_GET_INTERFACE_LIST:
+ case DONT_HAVE_PCAP:
cmdarg_err("%s", err_str);
g_free(err_str);
break;
&err);
}
} else {
- interface_opts = g_array_index(capture_opts->ifaces, interface_options, 0);
pcap_opts = g_array_index(ld->pcaps, pcap_options *, 0);
if (pcap_opts->from_cap_pipe) {
pcap_opts->snaplen = pcap_opts->cap_pipe_hdr.snaplen;
&global_ld.err);
}
} else {
- interface_opts = g_array_index(capture_opts->ifaces, interface_options, 0);
pcap_opts = g_array_index(global_ld.pcaps, pcap_options *, 0);
successful = libpcap_write_file_header(global_ld.pdh, pcap_opts->linktype, pcap_opts->snaplen,
&global_ld.bytes_written, &global_ld.err);
interface_options interface_opts;
guint i, error_index = 0;
- interface_opts = capture_opts->default_options;
*errmsg = '\0';
*secondary_errmsg = '\0';
#if defined(__APPLE__) && defined(__LP64__)
struct utsname osinfo;
#endif
+ GString *str;
#ifdef _WIN32
arg_list_utf_16to8(argc, argv);
if (if_list == NULL) {
switch (err) {
case CANT_GET_INTERFACE_LIST:
+ case DONT_HAVE_PCAP:
cmdarg_err("%s", err_str);
g_free(err_str);
exit_main(2);
/* Let the user know what interfaces were chosen. */
/* get_interface_descriptive_name() is not available! */
- for (j = 0; j < global_capture_opts.ifaces->len; j++) {
- interface_options interface_opts;
+ if (capture_child) {
+ for (j = 0; j < global_capture_opts.ifaces->len; j++) {
+ interface_options interface_opts;
- interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, j);
- g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "Interface: %s", interface_opts.name);
+ interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, j);
+ g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "Interface: %s\n",
+ interface_opts.name);
+ }
+ } else {
+ str = g_string_new("");
+#ifdef _WIN32
+ if (global_capture_opts.ifaces->len < 2) {
+#else
+ if (global_capture_opts.ifaces->len < 4) {
+#endif
+ for (j = 0; j < global_capture_opts.ifaces->len; j++) {
+ interface_options interface_opts;
+
+ interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, j);
+ if (j > 0) {
+ if (global_capture_opts.ifaces->len > 2) {
+ g_string_append_printf(str, ",");
+ }
+ g_string_append_printf(str, " ");
+ if (j == global_capture_opts.ifaces->len - 1) {
+ g_string_append_printf(str, "and ");
+ }
+ }
+ g_string_append_printf(str, "%s", interface_opts.name);
+ }
+ } else {
+ g_string_append_printf(str, "%u interfaces", global_capture_opts.ifaces->len);
+ }
+ fprintf(stderr, "Capturing on %s\n", str->str);
+ g_string_free(str, TRUE);
}
if (list_link_layer_types) {
* the error message below.
*/
interface_opts = g_array_index(capture_opts->ifaces, interface_options, i);
- fprintf(stderr,
- "Invalid capture filter \"%s\" for interface %s!\n"
+ cmdarg_err(
+ "Invalid capture filter: \"%s\" for interface %s!\n"
"\n"
"That string isn't a valid capture filter (%s).\n"
- "See the User's Guide for a description of the capture filter syntax.\n",
+ "See the User's Guide for a description of the capture filter syntax.",
interface_opts.cfilter, interface_opts.name, errmsg);
}
}
"Secondary Error: %s", secondary_error_msg);
sync_pipe_errmsg_to_parent(2, error_msg, secondary_error_msg);
} else {
- fprintf(stderr, "%s\n", error_msg);
+ cmdarg_err("%s", error_msg);
if (secondary_error_msg[0] != '\0')
- fprintf(stderr, "%s\n", secondary_error_msg);
+ cmdarg_err_cont("%s", secondary_error_msg);
}
}