aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-zrtp.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-zrtp.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-zrtp.c')
-rw-r--r--epan/dissectors/packet-zrtp.c46
1 files changed, 9 insertions, 37 deletions
diff --git a/epan/dissectors/packet-zrtp.c b/epan/dissectors/packet-zrtp.c
index d34ea79b44..b73509193a 100644
--- a/epan/dissectors/packet-zrtp.c
+++ b/epan/dissectors/packet-zrtp.c
@@ -113,8 +113,7 @@ static int hf_zrtp_msg_ping_ssrc = -1;
Checksum Data
*/
static int hf_zrtp_checksum = -1;
-static int hf_zrtp_checksum_good = -1;
-static int hf_zrtp_checksum_bad = -1;
+static int hf_zrtp_checksum_status = -1;
/*
Sub-Tree
@@ -318,14 +317,13 @@ dissect_zrtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
proto_tree *zrtp_tree;
proto_tree *zrtp_msg_tree;
proto_tree *zrtp_msg_data_tree;
- proto_tree *checksum_tree;
proto_item *ti;
int linelen;
int checksum_offset;
unsigned char message_type[9];
unsigned int prime_offset = 0;
unsigned int msg_offset = 12;
- guint32 sent_crc, calc_crc;
+ guint32 calc_crc;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "ZRTP");
@@ -416,27 +414,10 @@ dissect_zrtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
dissect_PingACK(tvb, pinfo, zrtp_msg_data_tree);
}
- sent_crc = tvb_get_ntohl(tvb, msg_offset+checksum_offset);
calc_crc = ~crc32c_tvb_offset_calculate(tvb, 0, msg_offset+checksum_offset, CRC32C_PRELOAD);
- if (sent_crc == calc_crc) {
- ti = proto_tree_add_uint_format_value(zrtp_tree, hf_zrtp_checksum, tvb, msg_offset+checksum_offset, 4, sent_crc,
- "0x%04x [correct]", sent_crc);
- checksum_tree = proto_item_add_subtree(ti, ett_zrtp_checksum);
- ti = proto_tree_add_boolean(checksum_tree, hf_zrtp_checksum_good, tvb, msg_offset+checksum_offset, 4, TRUE);
- PROTO_ITEM_SET_GENERATED(ti);
- ti = proto_tree_add_boolean(checksum_tree, hf_zrtp_checksum_bad, tvb, msg_offset+checksum_offset, 4, FALSE);
- PROTO_ITEM_SET_GENERATED(ti);
- } else {
- ti = proto_tree_add_uint_format_value(zrtp_tree, hf_zrtp_checksum, tvb, msg_offset+checksum_offset, 4, sent_crc,
- "0x%04x [incorrect, should be 0x%04x]", sent_crc, calc_crc);
- checksum_tree = proto_item_add_subtree(ti, ett_zrtp_checksum);
- ti = proto_tree_add_boolean(checksum_tree, hf_zrtp_checksum_good, tvb, msg_offset+checksum_offset, 4, FALSE);
- PROTO_ITEM_SET_GENERATED(ti);
- ti = proto_tree_add_boolean(checksum_tree, hf_zrtp_checksum_bad, tvb, msg_offset+checksum_offset, 4, TRUE);
- PROTO_ITEM_SET_GENERATED(ti);
- }
-
+ proto_tree_add_checksum(zrtp_tree, tvb, msg_offset+checksum_offset, hf_zrtp_checksum, hf_zrtp_checksum_status, NULL, pinfo, calc_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
return tvb_captured_length(tvb);
}
@@ -1098,21 +1079,12 @@ proto_register_zrtp(void)
}
},
- {&hf_zrtp_checksum_good,
+ {&hf_zrtp_checksum_status,
{
- "Good", "zrtp.checksum_good",
- FT_BOOLEAN, BASE_NONE,
- NULL, 0x0,
- "True: checksum matches packet content; False: doesn't match content", HFILL
- }
- },
-
- {&hf_zrtp_checksum_bad,
- {
- "Bad", "zrtp.checksum_bad",
- FT_BOOLEAN, BASE_NONE,
- NULL, 0x0,
- "True: checksum doesn't match packet content; False: matches content", HFILL
+ "Checksum Status", "zrtp.checksum.status",
+ FT_UINT8, BASE_NONE,
+ VALS(proto_checksum_vals), 0x0,
+ NULL, HFILL
}
},