#include "config.h"
#include <stdio.h>
+#include <stdlib.h>
#ifdef HAVE_LIBPCAP
void
-capture_opts_init(capture_options *capture_opts, void *cf)
+capture_opts_init(capture_options *capture_opts)
{
- capture_opts->cf = cf;
capture_opts->ifaces = g_array_new(FALSE, FALSE, sizeof(interface_options));
capture_opts->all_ifaces = g_array_new(FALSE, FALSE, sizeof(interface_t));
capture_opts->num_selected = 0;
capture_opts->default_options.cfilter = NULL;
capture_opts->default_options.has_snaplen = FALSE;
capture_opts->default_options.snaplen = WTAP_MAX_PACKET_SIZE;
- capture_opts->default_options.linktype = -1;
+ capture_opts->default_options.linktype = -1; /* use interface default */
capture_opts->default_options.promisc_mode = TRUE;
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
capture_opts->default_options.buffer_size = DEFAULT_CAPTURE_BUFFER_SIZE;
capture_opts->show_info = TRUE;
capture_opts->quit_after_cap = getenv("WIRESHARK_QUIT_AFTER_CAPTURE") ? TRUE : FALSE;
capture_opts->restart = FALSE;
+ capture_opts->orig_save_file = NULL;
capture_opts->multi_files_on = FALSE;
capture_opts->has_file_duration = FALSE;
capture_opts->has_autostop_packets = FALSE;
capture_opts->autostop_packets = 0;
capture_opts->has_autostop_filesize = FALSE;
- capture_opts->autostop_filesize = 1024; /* 1 MB */
+ capture_opts->autostop_filesize = 1000; /* 1 MB */
capture_opts->has_autostop_duration = FALSE;
capture_opts->autostop_duration = 60; /* 1 min */
+ capture_opts->capture_comment = NULL;
-
- capture_opts->fork_child = -1; /* invalid process handle */
-#ifdef _WIN32
- capture_opts->signal_pipe_write_fd = -1;
-#endif
- capture_opts->state = CAPTURE_STOPPED;
capture_opts->output_to_pipe = FALSE;
-#ifndef _WIN32
- capture_opts->owner = getuid();
- capture_opts->group = getgid();
-#endif
- capture_opts->session_started = FALSE;
+ capture_opts->capture_child = FALSE;
}
guint i;
g_log(log_domain, log_level, "CAPTURE OPTIONS :");
- g_log(log_domain, log_level, "CFile : %p", capture_opts->cf);
for (i = 0; i < capture_opts->ifaces->len; i++) {
interface_options interface_opts;
g_log(log_domain, log_level, "AutostopPackets (%u) : %u", capture_opts->has_autostop_packets, capture_opts->autostop_packets);
g_log(log_domain, log_level, "AutostopFilesize(%u) : %u (KB)", capture_opts->has_autostop_filesize, capture_opts->autostop_filesize);
g_log(log_domain, log_level, "AutostopDuration(%u) : %u", capture_opts->has_autostop_duration, capture_opts->autostop_duration);
-
- g_log(log_domain, log_level, "ForkChild : %d", capture_opts->fork_child);
-#ifdef _WIN32
- g_log(log_domain, log_level, "SignalPipeWrite : %d", capture_opts->signal_pipe_write_fd);
-#endif
}
/*
cmdarg_err("There is no interface with that adapter index");
return 1;
}
- if_list = capture_interface_list(&err, &err_str);
+ if_list = capture_interface_list(&err, &err_str, NULL);
if (if_list == NULL) {
switch (err) {
interface_opts.console_display_name = g_strdup(if_info->name);
}
free_interface_list(if_list);
+ } else if (capture_opts->capture_child) {
+ /* In Wireshark capture child mode, thus proper device name is supplied. */
+ /* No need for trying to match it for friendly names. */
+ interface_opts.name = g_strdup(optarg_str_p);
+ interface_opts.console_display_name = g_strdup(optarg_str_p);
} else {
/*
* Retrieve the interface list so that we can search for the
* the interface name, so that the user can try specifying an
* interface explicitly for testing purposes.
*/
- if_list = capture_interface_list(&err, &err_str);
+ if_list = capture_interface_list(&err, NULL, NULL);
if (if_list != NULL) {
/* try and do an exact match (case insensitive) */
GList *if_entry;
int status, snaplen;
switch(opt) {
+ case LONGOPT_NUM_CAP_COMMENT: /* capture comment */
+ if (capture_opts->capture_comment) {
+ cmdarg_err("--capture-comment can be set only once per file");
+ return 1;
+ }
+ capture_opts->capture_comment = g_strdup(optarg_str_p);
+ break;
case 'a': /* autostop criteria */
if (set_autostop_criterion(capture_opts, optarg_str_p) == FALSE) {
cmdarg_err("Invalid or unknown -a flag \"%s\"", optarg_str_p);
#endif
}
-
+/*
+ * If no interface was specified explicitly, pick a default.
+ */
int
-capture_opts_trim_iface(capture_options *capture_opts, const char *capture_device)
+capture_opts_default_iface_if_necessary(capture_options *capture_opts,
+ const char *capture_device)
{
int status;