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-simple.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-simple.c')
-rw-r--r-- | epan/dissectors/packet-simple.c | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/epan/dissectors/packet-simple.c b/epan/dissectors/packet-simple.c index 3ac7754a31..90f7ca1222 100644 --- a/epan/dissectors/packet-simple.c +++ b/epan/dissectors/packet-simple.c @@ -247,7 +247,7 @@ static gint hf_simple_status_link11_pu = -1; static gint hf_simple_status_link11_dts_host_status = -1; static gint hf_simple_status_spare_3 = -1; static gint hf_simple_checksum = -1; -static gint hf_simple_checksum_bad = -1; +static gint hf_simple_checksum_status = -1; static gint ett_simple = -1; static gint ett_packet = -1; @@ -409,10 +409,6 @@ static void dissect_simple_status(tvbuff_t *tvb, packet_info *pinfo, proto_tree static void dissect_checksum(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset) { - gint checksum = tvb_get_letohs(tvb, offset); - proto_item *checksum_item = proto_tree_add_item(tree, hf_simple_checksum, tvb, offset, 2, ENC_BIG_ENDIAN); - proto_item *hidden_item; - const guint8 * v = tvb_get_ptr(tvb, 0, offset); guint16 expected_checksum = 0; gint i; @@ -420,17 +416,8 @@ static void dissect_checksum(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree for (i = 0; i < offset; i++) expected_checksum += v[i]; - if (checksum == expected_checksum) { - hidden_item = proto_tree_add_boolean(tree, hf_simple_checksum_bad, tvb, offset, 2, FALSE); - PROTO_ITEM_SET_HIDDEN(hidden_item); - proto_item_append_text(checksum_item, " [correct]"); - } else { - hidden_item = proto_tree_add_boolean(tree, hf_simple_checksum_bad, tvb, offset, 2, TRUE); - PROTO_ITEM_SET_HIDDEN(hidden_item); - proto_item_append_text(checksum_item, " [incorrect, should be 0x%04x]", expected_checksum); - expert_add_info_format(pinfo, checksum_item, &ei_simple_checksum_bad, - "SIMPLE Checksum Incorrect, should be 0x%04x", expected_checksum); - } + proto_tree_add_checksum(tree, tvb, offset, hf_simple_checksum, hf_simple_checksum_status, &ei_simple_checksum_bad, pinfo, expected_checksum, + ENC_LITTLE_ENDIAN, PROTO_CHECKSUM_VERIFY); } static int dissect_simple(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) @@ -669,8 +656,8 @@ void proto_register_simple(void) { &hf_simple_checksum, { "Checksum", "simple.checksum", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }}, - { &hf_simple_checksum_bad, - { "Bad Checksum", "simple.checksum_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0, + { &hf_simple_checksum_status, + { "Checksum Status", "simple.checksum.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0, NULL, HFILL }} }; static gint *ett[] = { |