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-cattp.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-cattp.c')
-rw-r--r-- | epan/dissectors/packet-cattp.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/epan/dissectors/packet-cattp.c b/epan/dissectors/packet-cattp.c index 277a1e1376..10e489c536 100644 --- a/epan/dissectors/packet-cattp.c +++ b/epan/dissectors/packet-cattp.c @@ -87,6 +87,7 @@ static int hf_cattp_seq = -1; static int hf_cattp_ack = -1; static int hf_cattp_windowsize = -1; static int hf_cattp_checksum = -1; +static int hf_cattp_checksum_status = -1; static int hf_cattp_identification = -1; static int hf_cattp_iccid = -1; static int hf_cattp_idlen = -1; @@ -218,12 +219,11 @@ dissect_cattp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U const char *pdutype = "[Unknown PDU]"; proto_item *ti, *cattp_tree; guint32 offset; - gushort computed_chksum; vec_t cksum_vec[1]; int header_offset; guint cksum_data_len; guint8 flags, first_byte, hlen, ver; - guint16 plen, chksum, ackno, seqno, wsize, sport, dport; + guint16 plen, ackno, seqno, wsize, sport, dport; col_set_str(pinfo->cinfo, COL_PROTOCOL, CATTP_SHORTNAME); @@ -294,28 +294,16 @@ dissect_cattp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U /* Parse and verify checksum */ header_offset = 0; cksum_data_len = hlen + plen; - chksum = tvb_get_ntohs(tvb, offset); if (!cattp_check_checksum) { /* We have turned checksum checking off; we do NOT checksum it. */ - proto_tree_add_uint_format_value(cattp_tree, hf_cattp_checksum, tvb, offset, 2, - chksum, "0x%X [validation disabled]", chksum); + proto_tree_add_checksum(cattp_tree, tvb, offset, hf_cattp_checksum, hf_cattp_checksum_status, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS); } else { /* We haven't turned checksum checking off; checksum it. */ /* Unlike TCP, CATTP does not make use of a pseudo-header for checksum */ SET_CKSUM_VEC_TVB(cksum_vec[0], tvb, header_offset, cksum_data_len); - computed_chksum = in_cksum(cksum_vec, 1); - - if (computed_chksum == 0) { - /* Checksum is valid */ - proto_tree_add_uint_format_value(cattp_tree, hf_cattp_checksum, tvb, offset, 2, - chksum, "0x%X [validated]", chksum); - } else { - /* Checksum is invalid. Let's compute the expected checksum, based on the data we have */ - proto_tree_add_uint_format_value(cattp_tree, hf_cattp_checksum, tvb, offset, 2, chksum, - "0x%X [incorrect, correct: 0x%X]", chksum, - in_cksum_shouldbe(chksum, computed_chksum)); - } + proto_tree_add_checksum(cattp_tree, tvb, offset, hf_cattp_checksum, hf_cattp_checksum_status, NULL, pinfo, in_cksum(cksum_vec, 1), + ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM); } /* End of checksum code */ offset += 2; @@ -478,6 +466,13 @@ proto_register_cattp(void) } }, { + &hf_cattp_checksum_status, + { + "Checksum Status", "cattp.checksum.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0, + NULL, HFILL + } + }, + { &hf_cattp_identification, { "Identification", "cattp.identification", FT_BYTES, BASE_NONE, NULL, 0x0, |