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-fc.c | |
parent | 1e19f55f0c44b850bc6304be28d5b272a3553204 (diff) | |
download | wireshark-ad6fc87d64de30cdcdca18168a117d2ec24591da.tar.gz |
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-fc.c')
-rw-r--r-- | epan/dissectors/packet-fc.c | 46 |
1 files changed, 12 insertions, 34 deletions
diff --git a/epan/dissectors/packet-fc.c b/epan/dissectors/packet-fc.c index 839b667e3b..7bfb35d79a 100644 --- a/epan/dissectors/packet-fc.c +++ b/epan/dissectors/packet-fc.c @@ -1270,37 +1270,28 @@ dissect_fc_ifcp (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data static int dissect_fcsof(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) { - proto_item *it = NULL; - proto_tree *fcsof_tree = NULL; - tvbuff_t *next_tvb, *checksum_tvb; - guint32 sof = 0; - guint32 crc = 0; - guint32 crc_computed = 0; - guint32 eof = 0; - gint crc_offset = 0; - gint eof_offset = 0; - gint sof_offset = 0; + proto_item *it; + proto_tree *fcsof_tree; + tvbuff_t *next_tvb; + guint32 sof; + guint32 crc_computed; + guint32 eof; const gint FCSOF_TRAILER_LEN = 8; const gint FCSOF_HEADER_LEN = 4; - gint frame_len_for_checksum = 0; + gint crc_offset = tvb_reported_length(tvb) - FCSOF_TRAILER_LEN; + gint eof_offset = crc_offset + 4; + gint sof_offset = 0; + gint frame_len_for_checksum; fc_data_t fc_data; col_set_str(pinfo->cinfo, COL_PROTOCOL, "FC"); - crc_offset = tvb_reported_length(tvb) - FCSOF_TRAILER_LEN; - eof_offset = crc_offset + 4; - sof_offset = 0; - /* Get SOF */ sof = tvb_get_ntohl(tvb, 0); - /* GET CRC */ - crc = tvb_get_ntohl(tvb, crc_offset); - /* GET Computed CRC */ frame_len_for_checksum = crc_offset - FCSOF_HEADER_LEN; - checksum_tvb = tvb_new_subset_length(tvb, 4, frame_len_for_checksum); - crc_computed = crc32_802_tvb(checksum_tvb, frame_len_for_checksum); + crc_computed = crc32_802_tvb(tvb_new_subset_length(tvb, 4, frame_len_for_checksum), frame_len_for_checksum); /* Get EOF */ eof = tvb_get_ntohl(tvb, eof_offset); @@ -1314,20 +1305,7 @@ dissect_fcsof(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U proto_tree_add_uint(fcsof_tree, hf_fcsof, tvb, sof_offset, 4, sof); - if (crc == crc_computed) { - proto_tree_add_uint_format_value(fcsof_tree, hf_fccrc, tvb, - crc_offset, 4, crc, - "%8.8x [valid]", crc); - } else { - it = proto_tree_add_uint_format_value(fcsof_tree, hf_fccrc, tvb, - crc_offset, 4, crc, - "%8.8x [error: should be %8.8x]", - crc, crc_computed); - - expert_add_info_format(pinfo, it, &ei_fccrc, - "Bad FC CRC %8.8x %8.x", - crc, crc_computed); - } + proto_tree_add_checksum(fcsof_tree, tvb, crc_offset, hf_fccrc, -1, &ei_fccrc, pinfo, crc_computed, ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY); proto_tree_add_uint(fcsof_tree, hf_fceof, tvb, eof_offset, 4, eof); |