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-xip-serval.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-xip-serval.c')
-rw-r--r-- | epan/dissectors/packet-xip-serval.c | 25 |
1 files changed, 3 insertions, 22 deletions
diff --git a/epan/dissectors/packet-xip-serval.c b/epan/dissectors/packet-xip-serval.c index acf852c066..ae1219ff1d 100644 --- a/epan/dissectors/packet-xip-serval.c +++ b/epan/dissectors/packet-xip-serval.c @@ -179,12 +179,11 @@ static void display_xip_serval(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { proto_tree *xip_serval_tree; - proto_item *ti, *check_ti, *hl_ti; + proto_item *ti, *hl_ti; tvbuff_t *next_tvb; vec_t cksum_vec; gint offset; - guint16 packet_checksum, actual_checksum; guint8 xsh_len, protocol, bytes_remaining; /* Get XIP Serval header length, stored as number of 32-bit words. */ @@ -216,27 +215,9 @@ display_xip_serval(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* Compute checksum. */ SET_CKSUM_VEC_TVB(cksum_vec, tvb, 0, xsh_len); - actual_checksum = in_cksum(&cksum_vec, 1); - /* Get XIP Serval checksum. */ - packet_checksum = tvb_get_ntohs(tvb, XSRVL_CHK); - - if (actual_checksum == 0) { - /* Add XIP Serval checksum as correct. */ - proto_tree_add_uint_format(xip_serval_tree, - hf_xip_serval_check, tvb, XSRVL_CHK, 2, packet_checksum, - "Header checksum: 0x%04x [correct]", packet_checksum); - } else { - /* Add XIP Serval checksum as incorrect. */ - check_ti = proto_tree_add_uint_format(xip_serval_tree, - hf_xip_serval_check, tvb, XSRVL_CHK, 2, packet_checksum, - "Header checksum: 0x%04x [incorrect, should be 0x%04x]", - packet_checksum, - in_cksum_shouldbe(packet_checksum, actual_checksum)); - - expert_add_info_format(pinfo, check_ti, - &ei_xip_serval_bad_checksum, "Bad checksum"); - } + proto_tree_add_checksum(xip_serval_tree, tvb, XSRVL_CHK, hf_xip_serval_check, -1, &ei_xip_serval_bad_checksum, pinfo, in_cksum(&cksum_vec, 1), + ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM); offset = XSRVL_EXT; /* If there's still more room, check for extension headers. */ |