aboutsummaryrefslogtreecommitdiffstats
path: root/epan/proto.h
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2016-07-10 23:47:28 -0400
committerMichael Mann <mmann78@netscape.net>2016-07-21 12:35:22 +0000
commitad6fc87d64de30cdcdca18168a117d2ec24591da (patch)
treeb5df109654ae6806db7544933f8bf1a848a02ae7 /epan/proto.h
parent1e19f55f0c44b850bc6304be28d5b272a3553204 (diff)
Add proto_tree_add_checksum.
This is an attempt to standardize display/handling of checksum fields for all dissectors. The main target is for dissectors that do validation, but dissectors that just report the checksum were also included just to make them easier to find in the future. Bug: 10620 Bug: 12058 Ping-Bug: 8859 Change-Id: Ia8abd86e42eaf8ed50de6b173409e914b17993bf Reviewed-on: https://code.wireshark.org/review/16380 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Jeff Morriss <jeff.morriss.ws@gmail.com> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/proto.h')
-rw-r--r--epan/proto.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/epan/proto.h b/epan/proto.h
index b48ecadeb7..de96b7cec7 100644
--- a/epan/proto.h
+++ b/epan/proto.h
@@ -45,6 +45,8 @@
#include "wsutil/nstime.h"
#include "time_fmt.h"
#include "tvbuff.h"
+#include "value_string.h"
+#include "packet_info.h"
#include "ftypes/ftypes.h"
#include "register.h"
#include "ws_symbol_export.h"
@@ -2847,6 +2849,47 @@ WS_DLL_PUBLIC proto_item *
proto_tree_add_ascii_7bits_item(proto_tree *tree, const int hfindex, tvbuff_t *tvb,
const guint bit_offset, const gint no_of_chars);
+/** Add a checksum filed to a proto_tree.
+ This standardizes the display of a checksum field as well as any
+ status and expert info supporting it.
+ @param tree the tree to append this item to
+ @param tvb the tv buffer of the current data
+ @param offset start of data in tvb
+ @param hf_checksum checksum field index
+ @param hf_checksum_status optional checksum status field index. If none
+ exists, just pass -1
+ @param bad_checksum_expert optional expert info for a bad checksum. If
+ none exists, just pass NULL
+ @pinfo Packet info used for optional expert info. If unused, NULL can
+ be passed
+ @param computed_checksum Checksum to verify against
+ @param encoding data encoding of checksum from tvb
+ @param flags bitmask field of PROTO_CHECKSUM_ options
+ @return the newly created item */
+WS_DLL_PUBLIC proto_item *
+proto_tree_add_checksum(proto_tree *tree, tvbuff_t *tvb, const guint offset,
+ const int hf_checksum, const int hf_checksum_status, struct expert_field* bad_checksum_expert,
+ packet_info *pinfo, guint32 computed_checksum, const guint encoding, const guint flags);
+
+typedef enum
+{
+ PROTO_CHECKSUM_E_BAD = 0,
+ PROTO_CHECKSUM_E_GOOD,
+ PROTO_CHECKSUM_E_UNVERIFIED,
+ PROTO_CHECKSUM_E_NOT_PRESENT
+
+} proto_checksum_enum_e;
+
+#define PROTO_CHECKSUM_NO_FLAGS 0x00 /**< Don't use any flags */
+#define PROTO_CHECKSUM_VERIFY 0x01 /**< Compare against computed checksum */
+#define PROTO_CHECKSUM_GENERATED 0x02 /**< Checksum is generated only */
+#define PROTO_CHECKSUM_IN_CKSUM 0x04 /**< Internet checksum routine used for computation */
+#define PROTO_CHECKSUM_ZERO 0x08 /**< Computed checksum must be zero (but correct checksum can't be calculated) */
+#define PROTO_CHECKSUM_NOT_PRESENT 0x10 /**< Checksum field is not present (Just populates status field) */
+
+WS_DLL_PUBLIC const value_string proto_checksum_vals[];
+
+
/** Check if given string is a valid field name
@param field_name the field name to check
@return 0 if valid, else first illegal character */