aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap
diff options
context:
space:
mode:
authorHadriel Kaplan <hadrielk@yahoo.com>2015-08-16 12:37:11 -0400
committerAnders Broman <a.broman58@gmail.com>2015-08-19 04:26:24 +0000
commitd64ad1de91cb8303ce5b76faf0c5bdc0bf09a930 (patch)
tree3b01dd8298f02eb111ff33e51bccdddb5863d118 /wiretap
parent3268023b877afa13ad68c08237baa36f9d6c89ec (diff)
capinfos: add more info about file and interfaces
Add more information about the capture file, and about the interface descriptions in it. Also remove long-unused g_options code. Change-Id: I93cbd70fc7b09ec1b8b2fd6c85bb885c7f749543 Reviewed-on: https://code.wireshark.org/review/10073 Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'wiretap')
-rw-r--r--wiretap/wtap.c122
-rw-r--r--wiretap/wtap.h10
2 files changed, 118 insertions, 14 deletions
diff --git a/wiretap/wtap.c b/wiretap/wtap.c
index ea8004febf..2837b69852 100644
--- a/wiretap/wtap.c
+++ b/wiretap/wtap.c
@@ -264,25 +264,87 @@ wtap_file_get_idb_info(wtap *wth)
}
gchar *
-wtap_get_debug_if_descr(const wtapng_if_descr_t *if_descr)
+wtap_get_debug_if_descr(const wtapng_if_descr_t *if_descr,
+ const int indent,
+ const char* line_end)
{
GString *info = g_string_new("");
g_assert(if_descr);
g_string_printf(info,
- "Interface description: wtap_encap=%d, time_units_per_second=%" G_GINT64_MODIFIER "u"
- ", tsprecision=%d, link_type=%u, snap_len=%u, opt_comment='%s', if_name='%s'"
- ", if_description='%s', if_speed=%" G_GINT64_MODIFIER "u, if_tsresol=%d"
- ", if_filter_str='%s', bpf_filter_len=%u, if_fcslen=%d, num_stat_entries=%u",
- if_descr->wtap_encap, if_descr->time_units_per_second, if_descr->tsprecision,
- if_descr->link_type, if_descr->snap_len,
- if_descr->opt_comment ? if_descr->opt_comment : "NONE",
- if_descr->if_name ? if_descr->if_name : "NONE",
- if_descr->if_description ? if_descr->if_description : "NONE",
- if_descr->if_speed, if_descr->if_tsresol,
- if_descr->if_filter_str ? if_descr->if_filter_str : "NONE",
- if_descr->bpf_filter_len, if_descr->if_fcslen, if_descr->num_stat_entries);
+ "%*cName = %s%s", indent, ' ',
+ if_descr->if_name ? if_descr->if_name : "UNKNOWN",
+ line_end);
+
+ g_string_append_printf(info,
+ "%*cDescription = %s%s", indent, ' ',
+ if_descr->if_description ? if_descr->if_description : "NONE",
+ line_end);
+
+ g_string_append_printf(info,
+ "%*cEncapsulation = %s (%d/%u - %s)%s", indent, ' ',
+ wtap_encap_string(if_descr->wtap_encap),
+ if_descr->wtap_encap,
+ if_descr->link_type,
+ wtap_encap_short_string(if_descr->wtap_encap),
+ line_end);
+
+ g_string_append_printf(info,
+ "%*cSpeed = %" G_GINT64_MODIFIER "u%s", indent, ' ',
+ if_descr->if_speed,
+ line_end);
+
+ g_string_append_printf(info,
+ "%*cCapture length = %u%s", indent, ' ',
+ if_descr->snap_len,
+ line_end);
+
+ g_string_append_printf(info,
+ "%*cFCS length = %d%s", indent, ' ',
+ if_descr->if_fcslen,
+ line_end);
+
+ g_string_append_printf(info,
+ "%*cTime precision = %s (%d)%s", indent, ' ',
+ wtap_tsprec_string(if_descr->tsprecision),
+ if_descr->tsprecision,
+ line_end);
+
+ g_string_append_printf(info,
+ "%*cTime ticks per second = %" G_GINT64_MODIFIER "u%s", indent, ' ',
+ if_descr->time_units_per_second,
+ line_end);
+
+ g_string_append_printf(info,
+ "%*cTime resolution = 0x%.2x%s", indent, ' ',
+ if_descr->if_tsresol,
+ line_end);
+
+ g_string_append_printf(info,
+ "%*cFilter string = %s%s", indent, ' ',
+ if_descr->if_filter_str ? if_descr->if_filter_str : "NONE",
+ line_end);
+
+ g_string_append_printf(info,
+ "%*cOperating system = %s%s", indent, ' ',
+ if_descr->if_os ? if_descr->if_os : "UNKNOWN",
+ line_end);
+
+ g_string_append_printf(info,
+ "%*cComment = %s%s", indent, ' ',
+ if_descr->opt_comment ? if_descr->opt_comment : "NONE",
+ line_end);
+
+ g_string_append_printf(info,
+ "%*cBPF filter length = %u%s", indent, ' ',
+ if_descr->bpf_filter_len,
+ line_end);
+
+ g_string_append_printf(info,
+ "%*cNumber of stat entries = %u%s", indent, ' ',
+ if_descr->num_stat_entries,
+ line_end);
return g_string_free(info, FALSE);
}
@@ -928,6 +990,40 @@ wtap_short_string_to_encap(const char *short_name)
return -1; /* no such encapsulation type */
}
+const char*
+wtap_tsprec_string(int tsprec)
+{
+ const char* s;
+ switch (tsprec) {
+ case WTAP_TSPREC_PER_PACKET:
+ s = "per-packet";
+ break;
+ case WTAP_TSPREC_SEC:
+ s = "seconds";
+ break;
+ case WTAP_TSPREC_DSEC:
+ s = "deciseconds";
+ break;
+ case WTAP_TSPREC_CSEC:
+ s = "centiseconds";
+ break;
+ case WTAP_TSPREC_MSEC:
+ s = "milliseconds";
+ break;
+ case WTAP_TSPREC_USEC:
+ s = "microseconds";
+ break;
+ case WTAP_TSPREC_NSEC:
+ s = "nanoseconds";
+ break;
+ case WTAP_TSPREC_UNKNOWN:
+ default:
+ s = "UNKNOWN";
+ break;
+ }
+ return s;
+}
+
static const char *wtap_errlist[] = {
/* WTAP_ERR_NOT_REGULAR_FILE */
"The file isn't a plain file or pipe",
diff --git a/wiretap/wtap.h b/wiretap/wtap.h
index e3b4e5166d..4c53b8706c 100644
--- a/wiretap/wtap.h
+++ b/wiretap/wtap.h
@@ -365,6 +365,7 @@ extern "C" {
#define WTAP_TSPREC_MSEC 3
#define WTAP_TSPREC_USEC 6
#define WTAP_TSPREC_NSEC 9
+/* if you add to the above, update wtap_tsprec_string() */
/*
* Maximum packet size we'll support.
@@ -1741,10 +1742,14 @@ wtapng_iface_descriptions_t *wtap_file_get_idb_info(wtap *wth);
* @note The returned pointer must be g_free'd.
*
* @param if_descr The interface description.
+ * @param indent Number of spaces to indent each line by.
+ * @param line_end A string to append to each line (e.g., "\n" or ", ").
* @return A newly allocated gcahr array string, which must be g_free'd.
*/
WS_DLL_PUBLIC
-gchar *wtap_get_debug_if_descr(const wtapng_if_descr_t *if_descr);
+gchar *wtap_get_debug_if_descr(const wtapng_if_descr_t *if_descr,
+ const int indent,
+ const char* line_end);
/**
* @brief Gets new name resolution info for new file, based on existing info.
@@ -1938,6 +1943,9 @@ WS_DLL_PUBLIC
int wtap_short_string_to_encap(const char *short_name);
WS_DLL_PUBLIC
+const char* wtap_tsprec_string(int tsprec);
+
+WS_DLL_PUBLIC
const char *wtap_strerror(int err);
/*** get available number of file types and encapsulations ***/