aboutsummaryrefslogtreecommitdiffstats
path: root/epan/unit_strings.h
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2016-12-11 19:16:52 -0500
committerMichael Mann <mmann78@netscape.net>2016-12-13 13:08:39 +0000
commit4e97f74f1156db5c2cb139a404bc6423cebf7236 (patch)
treebce553ff7dbbe9977fb1adbfc2dc6440be0307c4 /epan/unit_strings.h
parent97b41a494c214161b358cc99fad843a6f061b283 (diff)
Add support for adding unit names to hf_ fields.
This was inspired by the https://www.wireshark.org/lists/wireshark-dev/201505/msg00029.html thread. Used TCP and NTP dissectors as the guinea pig with sample use. Documentation updates includes some unrelated cleanup just because it was noticed. Change-Id: I59b26e1ca3b95e3473e4757f1759d7ad82976965 Reviewed-on: https://code.wireshark.org/review/19211 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/unit_strings.h')
-rw-r--r--epan/unit_strings.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/epan/unit_strings.h b/epan/unit_strings.h
new file mode 100644
index 0000000000..7d2a5204cd
--- /dev/null
+++ b/epan/unit_strings.h
@@ -0,0 +1,75 @@
+/* unit_strings.h
+ * Units to append to field values
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __UNIT_STRINGS_H__
+#define __UNIT_STRINGS_H__
+
+#include "ws_symbol_export.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/** @file
+ * Units to append to field values
+ */
+
+/* For BASE_UNIT_STRING, the display format for adding units */
+typedef struct unit_name_string {
+ char *singular; /* name to use for 1 unit */
+ char *plural; /* name to use for < 1 or > 1 units */
+} unit_name_string;
+
+WS_DLL_PUBLIC char* unit_name_string_get_value(guint32 value, unit_name_string* units);
+WS_DLL_PUBLIC char* unit_name_string_get_value64(guint64 value, unit_name_string* units);
+
+/*
+ * A default set of unit strings that dissectors can use for
+ * header fields.
+ */
+WS_DLL_PUBLIC const unit_name_string units_foot_feet;
+WS_DLL_PUBLIC const unit_name_string units_bit_bits;
+WS_DLL_PUBLIC const unit_name_string units_byte_bytes;
+WS_DLL_PUBLIC const unit_name_string units_word_words;
+WS_DLL_PUBLIC const unit_name_string units_second_seconds; // full unit name "second[s?]"
+WS_DLL_PUBLIC const unit_name_string units_seconds; //only seconds abbreviation "s"
+WS_DLL_PUBLIC const unit_name_string units_millisecond_milliseconds; // full unit name "millisecond[s?]"
+WS_DLL_PUBLIC const unit_name_string units_milliseconds; //only seconds abbreviation "ms"
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __UNIT_STRINGS_H__ */
+
+/*
+ * Editor modelines
+ *
+ * Local Variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * ex: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */