aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--capture_opts.c6
-rw-r--r--capture_opts.h1
-rw-r--r--capture_sync.c41
-rw-r--r--dumpcap.c3
-rw-r--r--ui/iface_lists.c22
5 files changed, 68 insertions, 5 deletions
diff --git a/capture_opts.c b/capture_opts.c
index cc5bf10ef9..e9a3a2327d 100644
--- a/capture_opts.c
+++ b/capture_opts.c
@@ -114,6 +114,7 @@ capture_opts_init(capture_options *capture_opts)
capture_opts->autostop_duration = 60; /* 1 min */
capture_opts->output_to_pipe = FALSE;
+ capture_opts->capture_child = FALSE;
}
@@ -488,6 +489,11 @@ capture_opts_add_iface_opt(capture_options *capture_opts, const char *optarg_str
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
diff --git a/capture_opts.h b/capture_opts.h
index 7d966bc559..4cd77c63c5 100644
--- a/capture_opts.h
+++ b/capture_opts.h
@@ -202,6 +202,7 @@ typedef struct capture_options_tag {
/* internally used (don't touch from outside) */
gboolean output_to_pipe; /**< save_file is a pipe (named or stdout) */
+ gboolean capture_child; /**< hidden option: Wireshark child mode */
} capture_options;
/* initialize the capture_options with some reasonable values */
diff --git a/capture_sync.c b/capture_sync.c
index 7bff5e6c48..5914977c6c 100644
--- a/capture_sync.c
+++ b/capture_sync.c
@@ -956,7 +956,7 @@ sync_pipe_close_command(int *data_read_fd, int *message_read_fd,
/* XXX - assumes PIPE_BUF_SIZE > SP_MAX_MSG_LEN */
#define PIPE_BUF_SIZE 5120
static int
-sync_pipe_run_command(char** argv, gchar **data, gchar **primary_msg,
+sync_pipe_run_command_actual(char** argv, gchar **data, gchar **primary_msg,
gchar **secondary_msg)
{
gchar *msg;
@@ -1128,6 +1128,43 @@ sync_pipe_run_command(char** argv, gchar **data, gchar **primary_msg,
return ret;
}
+/* centralised logging and timing for sync_pipe_run_command_actual(),
+* redirects to sync_pipe_run_command_actual()
+*/
+static int
+sync_pipe_run_command(char** argv, gchar **data, gchar **primary_msg,
+ gchar **secondary_msg)
+{
+ int ret, i;
+ GTimeVal start_time;
+ GTimeVal end_time;
+ float elapsed;
+ int logging_enabled;
+
+ /* check if logging is actually enabled, otherwise don't expend the CPU generating logging */
+ logging_enabled=( (G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_INFO) & G_LOG_LEVEL_MASK & prefs.console_log_level);
+ if(logging_enabled){
+ g_get_current_time(&start_time);
+ g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_INFO, "sync_pipe_run_command() starts");
+ for(i=0; argv[i] != 0; i++) {
+ g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, " argv[%d]: %s", i, argv[i]);
+ }
+ }
+ /* do the actual sync pipe run command */
+ ret=sync_pipe_run_command_actual(argv, data, primary_msg, secondary_msg);
+
+ if(logging_enabled){
+ g_get_current_time(&end_time);
+ elapsed = (float) ((end_time.tv_sec - start_time.tv_sec) +
+ ((end_time.tv_usec - start_time.tv_usec) / 1e6));
+
+ g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_INFO, "sync_pipe_run_command() ends, taking %.3fs, result=%d", elapsed, ret);
+
+ }
+ return ret;
+}
+
+
int
sync_interface_set_80211_chan(const gchar *iface, const char *freq, const gchar *type,
gchar **data, gchar **primary_msg,
@@ -1236,7 +1273,7 @@ sync_if_capabilities_open(const gchar *ifname, gboolean monitor_mode,
int argc;
char **argv;
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "sync_linktype_list_open");
+ g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "sync_if_capabilities_open");
argv = init_pipe_args(&argc);
diff --git a/dumpcap.c b/dumpcap.c
index 56a01aa4bb..286c3e457f 100644
--- a/dumpcap.c
+++ b/dumpcap.c
@@ -4459,6 +4459,9 @@ main(int argc, char *argv[])
global_capture_opts.saving_to_file = TRUE;
global_capture_opts.has_ring_num_files = TRUE;
+ /* Pass on capture_child mode for capture_opts */
+ global_capture_opts.capture_child = capture_child;
+
/* Now get our args */
while ((opt = getopt(argc, argv, OPTSTRING)) != -1) {
switch (opt) {
diff --git a/ui/iface_lists.c b/ui/iface_lists.c
index aec2e91ecf..4741424859 100644
--- a/ui/iface_lists.c
+++ b/ui/iface_lists.c
@@ -38,6 +38,7 @@
#include "ui/capture_globals.h"
#include "ui/iface_lists.h"
+#include "../log.h"
/*
* Used when sorting an interface list into alphabetical order by
@@ -341,18 +342,33 @@ scan_local_interfaces(void)
}
/*
- * Get the global interface list. Generate it if we haven't
- * done so already.
+ * Get the global interface list. Generate it if we haven't done so
+ * already. This can be quite time consuming the first time, so
+ * record how long it takes in the info log.
*/
void
fill_in_local_interfaces(void)
{
- static gboolean initialized = FALSE;
+ GTimeVal start_time;
+ GTimeVal end_time;
+ float elapsed;
+ static gboolean initialized = FALSE;
+ /* record the time we started, so we can log total time later */
+ g_get_current_time(&start_time);
+ g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_INFO, "fill_in_local_interfaces() starts");
+
if (!initialized) {
+ /* do the actual work */
scan_local_interfaces();
initialized = TRUE;
}
+ /* log how long it took */
+ g_get_current_time(&end_time);
+ elapsed = (float) ((end_time.tv_sec - start_time.tv_sec) +
+ ((end_time.tv_usec - start_time.tv_usec) / 1e6));
+
+ g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_INFO, "fill_in_local_interfaces() ends, taking %.3fs", elapsed);
}
void