summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--capture.c13
-rw-r--r--capture_ui_utils.c8
-rw-r--r--cfile.c1
-rw-r--r--cfile.h1
-rw-r--r--file.c39
-rw-r--r--file.h18
-rw-r--r--gtk/main.c7
7 files changed, 76 insertions, 11 deletions
diff --git a/capture.c b/capture.c
index 68f2fbb9d6..6b799e0e24 100644
--- a/capture.c
+++ b/capture.c
@@ -133,7 +133,7 @@ gboolean
capture_start(capture_options *capture_opts)
{
gboolean ret;
-
+ GString *source = g_string_new("");
/* close the currently loaded capture file */
cf_close(capture_opts->cf);
@@ -143,6 +143,13 @@ capture_start(capture_options *capture_opts)
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Start ...");
+ g_string_printf(source, "%s", get_iface_description(capture_opts));
+ if(capture_opts->cfilter && capture_opts->cfilter[0]) {
+ g_string_append_printf(source, " (%s)", capture_opts->cfilter);
+ }
+ cf_set_tempfile_source(capture_opts->cf, source->str);
+ g_string_free(source, TRUE);
+
/* try to start the capture child process */
ret = sync_pipe_start(capture_opts);
if(!ret) {
@@ -209,13 +216,12 @@ guint32 drops)
{
int err;
-
/* Capture succeeded; attempt to open the capture file. */
if (cf_open(capture_opts->cf, capture_opts->save_file, is_tempfile, &err) != CF_OK) {
/* We're not doing a capture any more, so we don't have a save file. */
return FALSE;
}
-
+
/* Set the read filter to NULL. */
/* XXX - this is odd here; try to put it somewhere where it fits better */
cf_set_rfcode(capture_opts->cf, NULL);
@@ -301,7 +307,6 @@ capture_input_new_file(capture_options *capture_opts, gchar *new_file)
gboolean is_tempfile;
int err;
-
if(capture_opts->state == CAPTURE_PREPARING) {
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture started!");
}
diff --git a/capture_ui_utils.c b/capture_ui_utils.c
index f64e638993..f6ff8c3fb8 100644
--- a/capture_ui_utils.c
+++ b/capture_ui_utils.c
@@ -34,7 +34,8 @@
#include <ctype.h>
#include <glib.h>
-#include <epan/prefs.h>
+#include "epan/prefs.h"
+#include "epan/ex-opt.h"
#include "capture_ifinfo.h"
#include "capture_ui_utils.h"
@@ -155,6 +156,11 @@ get_interface_descriptive_name(const char *if_name)
if (descr != NULL) {
/* Yes - make a copy of that. */
descr = g_strdup(descr);
+ } else if (strcmp(if_name, "-") == 0) {
+ descr = g_strdup(ex_opt_get_nth("stdin_descr", 0));
+ if (!descr) {
+ descr = g_strdup("Standard input");
+ }
} else {
/* No, we don't have a user-supplied description; did we get
one from the OS or libpcap? */
diff --git a/cfile.c b/cfile.c
index d7e53298bf..89ab953d40 100644
--- a/cfile.c
+++ b/cfile.c
@@ -41,6 +41,7 @@ cap_file_init(capture_file *cf)
cf->plist_end = NULL;
cf->wth = NULL;
cf->filename = NULL;
+ cf->source = NULL;
cf->user_saved = FALSE;
cf->is_tempfile = FALSE;
cf->rfcode = NULL;
diff --git a/cfile.h b/cfile.h
index d46c4962ce..f98f1e74f7 100644
--- a/cfile.h
+++ b/cfile.h
@@ -44,6 +44,7 @@ typedef enum {
typedef struct _capture_file {
file_state state; /* Current state of capture file */
gchar *filename; /* Name of capture file */
+ gchar *source; /* Temp file source, e.g. "Pipe from elsewhere" */
gboolean is_tempfile; /* Is capture file a temporary file? */
gboolean user_saved; /* If capture file is temporary, has it been saved by user yet? */
gint64 f_datalen; /* Size of capture file data (uncompressed) */
diff --git a/file.c b/file.c
index bf233d5c7c..eb6b9f060d 100644
--- a/file.c
+++ b/file.c
@@ -1024,11 +1024,35 @@ cf_get_display_name(capture_file *cf)
} else {
/* The file we read is a temporary file from a live capture;
we don't mention its name. */
- displayname = "(Untitled)";
+ if (cf->source) {
+ displayname = cf->source;
+ } else {
+ displayname = "(Untitled)";
+ }
}
return displayname;
}
+void cf_set_tempfile_source(capture_file *cf, gchar *source) {
+ if (cf->source) {
+ g_free(cf->source);
+ }
+
+ if (source) {
+ cf->source = g_strdup(source);
+ } else {
+ cf->source = g_strdup("");
+ }
+}
+
+const gchar *cf_get_tempfile_source(capture_file *cf) {
+ if (!cf->source) {
+ return "";
+ }
+
+ return cf->source;
+}
+
/* XXX - use a macro instead? */
int
cf_get_packet_count(capture_file *cf)
@@ -4623,3 +4647,16 @@ cf_reload(capture_file *cf) {
we should free up our copy. */
g_free(filename);
}
+
+/*
+ * Editor modelines
+ *
+ * Local Variables:
+ * c-basic-offset: 2
+ * tab-width: 2
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * ex: set shiftwidth=2 tabstop=2 expandtab
+ * :indentSize=2:tabSize=2:noTabs=true:
+ */
diff --git a/file.h b/file.h
index 0fe0bb43f2..b546f3e86f 100644
--- a/file.h
+++ b/file.h
@@ -171,6 +171,24 @@ cf_status_t cf_save(capture_file * cf, const char *fname, packet_range_t *range,
const gchar *cf_get_display_name(capture_file *cf);
/**
+ * Set the source of the capture data for temporary files, e.g.
+ * "Interface eth0" or "Pipe from Pong"
+ *
+ * @param cf the capture file
+ * @param source the source description. this will be copied internally.
+ */
+void cf_set_tempfile_source(capture_file *cf, gchar *source);
+
+/**
+ * Get the source of the capture data for temporary files. Guaranteed to
+ * return a non-null value. The returned value should not be freed.
+ *
+ * @param cf the capture file
+ * @param source the source description. this will be copied internally.
+ */
+const gchar *cf_get_tempfile_source(capture_file *cf);
+
+/**
* Get the number of packets in the capture file.
*
* @param cf the capture file
diff --git a/gtk/main.c b/gtk/main.c
index 93d667f2ae..c853bf37ca 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -1457,12 +1457,9 @@ main_capture_set_main_window_title(capture_options *capture_opts)
{
GString *title = g_string_new("");
- if(capture_opts->iface) {
- g_string_append_printf(title, "%s: ", get_iface_description(capture_opts));
- }
g_string_append(title, "Capturing ");
- if(capture_opts->cfilter && capture_opts->cfilter[0]) {
- g_string_append_printf(title, "(%s) ", capture_opts->cfilter);
+ if(capture_opts->iface) {
+ g_string_append_printf(title, "from %s ", cf_get_tempfile_source(capture_opts->cf));
}
g_string_append(title, "- Wireshark");