aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-extreme.c
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/dissectors/packet-extreme.c
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/dissectors/packet-extreme.c')
-rw-r--r--epan/dissectors/packet-extreme.c49
1 files changed, 8 insertions, 41 deletions
diff --git a/epan/dissectors/packet-extreme.c b/epan/dissectors/packet-extreme.c
index 92693063fa..17a39e52e5 100644
--- a/epan/dissectors/packet-extreme.c
+++ b/epan/dissectors/packet-extreme.c
@@ -159,8 +159,7 @@ static int hf_edp_version = -1;
static int hf_edp_reserved = -1;
static int hf_edp_length = -1;
static int hf_edp_checksum = -1;
-static int hf_edp_checksum_good = -1;
-static int hf_edp_checksum_bad = -1;
+static int hf_edp_checksum_status = -1;
static int hf_edp_seqno = -1;
static int hf_edp_midtype = -1;
@@ -255,7 +254,6 @@ static int hf_edp_null = -1;
static expert_field ei_edp_short_tlv = EI_INIT;
static gint ett_edp = -1;
-static gint ett_edp_checksum = -1;
static gint ett_edp_tlv_header = -1;
static gint ett_edp_display = -1;
static gint ett_edp_info = -1;
@@ -950,11 +948,7 @@ dissect_edp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
proto_item *ti;
proto_tree *edp_tree;
- proto_item *checksum_item;
- proto_tree *checksum_tree;
guint32 offset = 0;
- guint16 packet_checksum, computed_checksum;
- gboolean checksum_good, checksum_bad;
gboolean last = FALSE;
guint8 tlv_type;
guint16 tlv_length;
@@ -982,40 +976,18 @@ dissect_edp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
data_length);
offset += 2;
- packet_checksum = tvb_get_ntohs(tvb, offset);
/*
* If we have the entire ESP packet available, check the checksum.
*/
if (tvb_captured_length(tvb) >= data_length) {
/* Checksum from version to null tlv */
SET_CKSUM_VEC_TVB(cksum_vec[0], tvb, 0, data_length);
- computed_checksum = in_cksum(&cksum_vec[0], 1);
- checksum_good = (computed_checksum == 0);
- checksum_bad = !checksum_good;
- if (checksum_good) {
- checksum_item = proto_tree_add_uint_format(edp_tree,
- hf_edp_checksum, tvb, offset, 2, packet_checksum,
- "Checksum: 0x%04x [correct]",
- packet_checksum);
- } else {
- checksum_item = proto_tree_add_uint_format(edp_tree,
- hf_edp_checksum, tvb, offset, 2, packet_checksum,
- "Checksum: 0x%04x [incorrect, should be 0x%04x]",
- packet_checksum,
- in_cksum_shouldbe(packet_checksum, computed_checksum));
- }
+
+ proto_tree_add_checksum(edp_tree, tvb, offset, hf_edp_checksum, hf_edp_checksum_status, NULL, pinfo, in_cksum(&cksum_vec[0], 1),
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
} else {
- checksum_good = checksum_bad = FALSE;
- checksum_item = proto_tree_add_uint(edp_tree, hf_edp_checksum,
- tvb, offset, 2, packet_checksum);
+ proto_tree_add_checksum(edp_tree, tvb, offset, hf_edp_checksum, hf_edp_checksum_status, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
- checksum_tree = proto_item_add_subtree(checksum_item, ett_edp_checksum);
- checksum_item = proto_tree_add_boolean(checksum_tree, hf_edp_checksum_good,
- tvb, offset, 2, checksum_good);
- PROTO_ITEM_SET_GENERATED(checksum_item);
- checksum_item = proto_tree_add_boolean(checksum_tree, hf_edp_checksum_bad,
- tvb, offset, 2, checksum_bad);
- PROTO_ITEM_SET_GENERATED(checksum_item);
offset += 2;
seqno = tvb_get_ntohs(tvb, offset);
@@ -1114,13 +1086,9 @@ proto_register_edp(void)
{ "EDP checksum", "edp.checksum", FT_UINT16, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
- { &hf_edp_checksum_good,
- { "Good", "edp.checksum_good", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: checksum matches packet content; False: doesn't match content or not checked", HFILL }},
-
- { &hf_edp_checksum_bad,
- { "Bad", "edp.checksum_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: checksum doesn't match packet content; False: matches content or not checked", HFILL }},
+ { &hf_edp_checksum_status,
+ { "EDP checksum status", "edp.checksum.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
+ NULL, HFILL }},
{ &hf_edp_seqno,
{ "Sequence number", "edp.seqno", FT_UINT16, BASE_DEC, NULL,
@@ -1455,7 +1423,6 @@ proto_register_edp(void)
static gint *ett[] = {
&ett_edp,
- &ett_edp_checksum,
&ett_edp_tlv_header,
&ett_edp_vlan_flags,
&ett_edp_display,