# include <sys/stat.h>
#endif
-#ifdef NEED_STRERROR_H
-#include "wsutil/strerror.h"
-#endif
-
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#else
case FT_STRING:
case FT_STRINGZ:
- case FT_EBCDIC:
/* The selector for this table is a string. */
break;
case FT_STRING:
case FT_STRINGZ:
- case FT_EBCDIC:
/* The selector for this table is a string. */
dissector_change_string(table_name, selector_str, dissector_matching);
break;
int status;
GList *if_list;
gchar *err_str;
+ guint i;
+ interface_options interface_opts;
#else
gboolean capture_option_specified = FALSE;
#endif
gboolean quiet = FALSE;
+#ifdef PCAP_NG_DEFAULT
+ int out_file_type = WTAP_FILE_PCAPNG;
+#else
int out_file_type = WTAP_FILE_PCAP;
+#endif
gboolean out_file_name_res = FALSE;
gchar *cf_name = NULL, *rfilter = NULL;
#ifdef HAVE_PCAP_OPEN_DEAD
if (gpf_path != NULL) {
if (gpf_open_errno != 0) {
cmdarg_err("Can't open global preferences file \"%s\": %s.",
- pf_path, strerror(gpf_open_errno));
+ pf_path, g_strerror(gpf_open_errno));
}
if (gpf_read_errno != 0) {
cmdarg_err("I/O error reading global preferences file \"%s\": %s.",
- pf_path, strerror(gpf_read_errno));
+ pf_path, g_strerror(gpf_read_errno));
}
}
if (pf_path != NULL) {
if (pf_open_errno != 0) {
cmdarg_err("Can't open your preferences file \"%s\": %s.", pf_path,
- strerror(pf_open_errno));
+ g_strerror(pf_open_errno));
}
if (pf_read_errno != 0) {
cmdarg_err("I/O error reading your preferences file \"%s\": %s.",
- pf_path, strerror(pf_read_errno));
+ pf_path, g_strerror(pf_read_errno));
}
g_free(pf_path);
pf_path = NULL;
if (gdp_path != NULL) {
if (gdp_open_errno != 0) {
cmdarg_err("Could not open global disabled protocols file\n\"%s\": %s.",
- gdp_path, strerror(gdp_open_errno));
+ gdp_path, g_strerror(gdp_open_errno));
}
if (gdp_read_errno != 0) {
cmdarg_err("I/O error reading global disabled protocols file\n\"%s\": %s.",
- gdp_path, strerror(gdp_read_errno));
+ gdp_path, g_strerror(gdp_read_errno));
}
g_free(gdp_path);
}
if (dp_open_errno != 0) {
cmdarg_err(
"Could not open your disabled protocols file\n\"%s\": %s.", dp_path,
- strerror(dp_open_errno));
+ g_strerror(dp_open_errno));
}
if (dp_read_errno != 0) {
cmdarg_err(
"I/O error reading your disabled protocols file\n\"%s\": %s.", dp_path,
- strerror(dp_read_errno));
+ g_strerror(dp_read_errno));
}
g_free(dp_path);
}
timestamp_set_type(TS_DELTA_DIS);
else if (strcmp(optarg, "e") == 0)
timestamp_set_type(TS_EPOCH);
+ else if (strcmp(optarg, "u") == 0)
+ timestamp_set_type(TS_UTC);
+ else if (strcmp(optarg, "ud") == 0)
+ timestamp_set_type(TS_UTC_WITH_DATE);
else {
cmdarg_err("Invalid time stamp type \"%s\"",
optarg);
if (cf_name != NULL) {
if (rfilter != NULL) {
cmdarg_err("Read filters were specified both with \"-R\" "
- "and with additional command-line arguments");
+ "and with additional command-line arguments.");
return 1;
}
rfilter = get_args_as_string(argc, argv, optind);
} else {
#ifdef HAVE_LIBPCAP
- if (global_capture_opts.cfilter) {
- cmdarg_err("Capture filters were specified both with \"-f\""
- " and with additional command-line arguments");
+ if (global_capture_opts.default_options.cfilter) {
+ cmdarg_err("A default capture filter was specified both with \"-f\""
+ " and with additional command-line arguments.");
return 1;
}
- global_capture_opts.cfilter = get_args_as_string(argc, argv, optind);
+ for (i = 0; i < global_capture_opts.ifaces->len; i++) {
+ interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, i);
+ if (interface_opts.cfilter == NULL) {
+ interface_opts.cfilter = get_args_as_string(argc, argv, optind);
+ global_capture_opts.ifaces = g_array_remove_index(global_capture_opts.ifaces, i);
+ g_array_insert_val(global_capture_opts.ifaces, i, interface_opts);
+ } else {
+ cmdarg_err("A capture filter was specified both with \"-f\""
+ " and with additional command-line arguments.");
+ return 1;
+ }
+ }
+ global_capture_opts.default_options.cfilter = get_args_as_string(argc, argv, optind);
#else
capture_option_specified = TRUE;
#endif
support in capture files we read). */
#ifdef HAVE_LIBPCAP
if (cf_name != NULL) {
- if (global_capture_opts.cfilter) {
+ if (global_capture_opts.default_options.cfilter) {
cmdarg_err("Only read filters, not capture filters, "
"can be specified when reading a capture file.");
return 1;
if (global_capture_opts.saving_to_file) {
/* They specified a "-w" flag, so we'll be saving to a capture file. */
- /* When capturing, we only support writing libpcap format. */
- if (out_file_type != WTAP_FILE_PCAP) {
+ /* When capturing, we only support writing pcap or pcap-ng format. */
+ if (out_file_type != WTAP_FILE_PCAP && out_file_type != WTAP_FILE_PCAPNG) {
cmdarg_err("Live captures can only be saved in libpcap format.");
return 1;
}
/* capture child detected an capture filter related error */
void
-capture_input_cfilter_error_message(capture_options *capture_opts, char *error_message)
+capture_input_cfilter_error_message(capture_options *capture_opts, guint i, char *error_message)
{
dfilter_t *rfcode = NULL;
+ interface_options interface_opts;
+ g_assert(i < capture_opts->ifaces->len);
+ interface_opts = g_array_index(capture_opts->ifaces, interface_options, i);
- if (dfilter_compile(capture_opts->cfilter, &rfcode) && rfcode != NULL) {
+ if (dfilter_compile(interface_opts.cfilter, &rfcode) && rfcode != NULL) {
cmdarg_err(
- "Invalid capture filter: \"%s\"!\n"
+ "Invalid capture filter \"%s\" for interface %s!\n"
"\n"
"That string looks like a valid display filter; however, it isn't a valid\n"
"capture filter (%s).\n"
"so you can't use most display filter expressions as capture filters.\n"
"\n"
"See the User's Guide for a description of the capture filter syntax.",
- capture_opts->cfilter, error_message);
+ interface_opts.cfilter, interface_opts.descr, error_message);
dfilter_free(rfcode);
} else {
cmdarg_err(
- "Invalid capture filter: \"%s\"!\n"
+ "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.",
- capture_opts->cfilter, error_message);
+ interface_opts.cfilter, interface_opts.descr, error_message);
}
}
gboolean filtering_tap_listeners;
guint tap_flags;
+#ifdef PCAP_NG_DEFAULT
+ linktype = WTAP_ENCAP_PER_PACKET;
+#else
linktype = wtap_file_encap(cf->wth);
+#endif
if (save_file != NULL) {
/* Get a string that describes what we're writing to */
save_file_string = output_file_description(save_file);
case WTAP_ERR_UNSUPPORTED_ENCAP:
case WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED:
cmdarg_err("The capture file being read can't be written in "
- "that format.");
+ "the format \"%s\".", wtap_encap_short_string(linktype));
break;
case WTAP_ERR_CANT_OPEN:
case COL_CLS_TIME:
case COL_REL_TIME:
case COL_ABS_TIME:
- case COL_ABS_DATE_TIME: /* XXX - wider */
+ case COL_ABS_DATE_TIME:
+ case COL_UTC_TIME:
+ case COL_UTC_DATE_TIME: /* XXX - wider */
column_len = strlen(cf->cinfo.col_data[i]);
if (column_len < 10)
column_len = 10;
default:
cmdarg_err("An error occurred while printing packets: %s.",
- strerror(err));
+ g_strerror(err));
break;
}
}
read_failure_message(const char *filename, int err)
{
cmdarg_err("An error occurred while reading from the file \"%s\": %s.",
- filename, strerror(err));
+ filename, g_strerror(err));
}
/*
write_failure_message(const char *filename, int err)
{
cmdarg_err("An error occurred while writing to the file \"%s\": %s.",
- filename, strerror(err));
+ filename, g_strerror(err));
}
/*