aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-hip.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2016-07-10 23:47:28 -0400
committerMichael Mann <mmann78@netscape.net>2016-07-21 12:35:22 +0000
commitad6fc87d64de30cdcdca18168a117d2ec24591da (patch)
treeb5df109654ae6806db7544933f8bf1a848a02ae7 /epan/dissectors/packet-hip.c
parent1e19f55f0c44b850bc6304be28d5b272a3553204 (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-hip.c')
-rw-r--r--epan/dissectors/packet-hip.c32
1 files changed, 8 insertions, 24 deletions
diff --git a/epan/dissectors/packet-hip.c b/epan/dissectors/packet-hip.c
index 928e446293..c98a52956b 100644
--- a/epan/dissectors/packet-hip.c
+++ b/epan/dissectors/packet-hip.c
@@ -421,7 +421,7 @@ dissect_hip_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean
proto_tree *hip_tree, *hip_tlv_tree=NULL;
proto_item *ti, *ti_tlv;
int length, offset = 0, newoffset = 0;
- guint16 control_h, checksum_h, computed_checksum;
+ guint16 control_h, checksum_h;
guint16 tlv_type_h, tlv_length_h; /* For storing in host order */
guint len;
guint reported_len;
@@ -510,32 +510,16 @@ dissect_hip_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean
}
/* pointer to the HIP header (packet data) */
SET_CKSUM_VEC_TVB(cksum_vec[3], tvb, 0, reported_len);
- computed_checksum = in_cksum(cksum_vec, 4);
- if (computed_checksum == 0) {
- proto_tree_add_uint_format_value(hip_tree, hf_hip_checksum, tvb,
- offset+4, 2, checksum_h,
- "0x%04x (correct)",
- checksum_h);
+ if (checksum_h == 0 && udp) {
+ proto_tree_add_checksum(hip_tree, tvb, offset+4, hf_hip_checksum, -1, NULL, pinfo, 0,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
} else {
- if (checksum_h == 0 && udp) {
- proto_tree_add_uint_format_value(hip_tree, hf_hip_checksum, tvb,
- offset+4, 2, checksum_h,
- "0x%04x (correct)",
- checksum_h);
- } else {
- proto_tree_add_uint_format_value(hip_tree, hf_hip_checksum, tvb,
- offset+4, 2, checksum_h,
- "0x%04x (incorrect, should be 0x%04x)",
- checksum_h,
- in_cksum_shouldbe(checksum_h,
- computed_checksum));
- }
+ proto_tree_add_checksum(hip_tree, tvb, offset+4, hf_hip_checksum, -1, NULL, pinfo, in_cksum(cksum_vec, 4),
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
}
} else {
- proto_tree_add_uint_format_value(hip_tree, hf_hip_checksum, tvb,
- offset+4, 2, checksum_h,
- "0x%04x (unverified)",
- checksum_h);
+ proto_tree_add_checksum(hip_tree, tvb, offset+4, hf_hip_checksum, -1, NULL, pinfo, 0,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
ti = proto_tree_add_item(hip_tree, hf_hip_controls, tvb, offset+6, 2, ENC_BIG_ENDIAN);