diff options
author | Michael Mann <mmann78@netscape.net> | 2016-07-10 23:47:28 -0400 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2016-07-21 12:35:22 +0000 |
commit | ad6fc87d64de30cdcdca18168a117d2ec24591da (patch) | |
tree | b5df109654ae6806db7544933f8bf1a848a02ae7 /epan/dissectors/packet-shim6.c | |
parent | 1e19f55f0c44b850bc6304be28d5b272a3553204 (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-shim6.c')
-rw-r--r-- | epan/dissectors/packet-shim6.c | 49 |
1 files changed, 8 insertions, 41 deletions
diff --git a/epan/dissectors/packet-shim6.c b/epan/dissectors/packet-shim6.c index 6393f088b3..bb88dbdaf2 100644 --- a/epan/dissectors/packet-shim6.c +++ b/epan/dissectors/packet-shim6.c @@ -102,8 +102,7 @@ static int hf_shim6_ct = -1; static int hf_shim6_type = -1; static int hf_shim6_proto = -1; static int hf_shim6_checksum = -1; -static int hf_shim6_checksum_bad = -1; -static int hf_shim6_checksum_good = -1; +static int hf_shim6_checksum_status= -1; static int hf_shim6_inonce = -1; /* also for request nonce */ static int hf_shim6_rnonce = -1; static int hf_shim6_reserved = -1; @@ -563,26 +562,6 @@ static const value_string shimctrlvals[] = { { 0, NULL } }; -static void -add_shim6_checksum_additional_info(tvbuff_t * tvb, packet_info * pinfo, - proto_item * it_cksum, int offset, gboolean is_cksum_correct) -{ - proto_tree *checksum_tree; - proto_item *item; - - checksum_tree = proto_item_add_subtree(it_cksum, ett_shim6_cksum); - item = proto_tree_add_boolean(checksum_tree, hf_shim6_checksum_good, tvb, - offset, 2, is_cksum_correct); - PROTO_ITEM_SET_GENERATED(item); - item = proto_tree_add_boolean(checksum_tree, hf_shim6_checksum_bad, tvb, - offset, 2, !is_cksum_correct); - PROTO_ITEM_SET_GENERATED(item); - if (!is_cksum_correct) { - expert_add_info(pinfo, item, &ei_shim6_checksum_bad); - col_append_str(pinfo->cinfo, COL_INFO, " [Shim6 CHECKSUM INCORRECT]"); - } -} - static int dissect_shim6(tvbuff_t *tvb, packet_info * pinfo, proto_tree *tree, void* data _U_) { @@ -656,17 +635,10 @@ dissect_shim6(tvbuff_t *tvb, packet_info * pinfo, proto_tree *tree, void* data _ /* Checksum */ csum = shim6_checksum(tvb, offset, len); - - if (csum == 0) { - ti = proto_tree_add_uint_format_value(shim_tree, hf_shim6_checksum, tvb, p, 2, - tvb_get_ntohs(tvb, p), "0x%04x [correct]", tvb_get_ntohs(tvb, p)); - add_shim6_checksum_additional_info(tvb, pinfo, ti, p, TRUE); - } else { - ti = proto_tree_add_uint_format_value(shim_tree, hf_shim6_checksum, tvb, p, 2, - tvb_get_ntohs(tvb, p), "0x%04x [incorrect: should be 0x%04x]", - tvb_get_ntohs(tvb, p), in_cksum_shouldbe(tvb_get_ntohs(tvb, p), csum)); - add_shim6_checksum_additional_info(tvb, pinfo, ti, p, FALSE); - } + proto_tree_add_checksum(shim_tree, tvb, p, hf_shim6_checksum, hf_shim6_checksum_status, &ei_shim6_checksum_bad, pinfo, csum, + ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM); + if (csum != 0) + col_append_str(pinfo->cinfo, COL_INFO, " [Shim6 CHECKSUM INCORRECT]"); p += 2; /* Type specific data */ @@ -726,14 +698,9 @@ proto_register_shim6(void) FT_UINT16, BASE_HEX, NULL, 0x0, "Shim6 Checksum", HFILL } }, - { &hf_shim6_checksum_bad, - { "Bad Checksum", "shim6.checksum_bad", - FT_BOOLEAN, BASE_NONE, NULL, 0x0, - "Shim6 Bad Checksum", HFILL } - }, - { &hf_shim6_checksum_good, - { "Good Checksum", "shim6.checksum_good", - FT_BOOLEAN, BASE_NONE, NULL, 0x0, + { &hf_shim6_checksum_status, + { "Checksum Status", "shim6.checksum.status", + FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0, NULL, HFILL } }, { &hf_shim6_inonce, |