From 8b0e9c66728f6a39bbe3ada1029e13ad1378013a Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Thu, 21 Jul 2016 10:21:25 -0400 Subject: Follow up for proto_tree_add_checksum. Fill in the "gaps" so that all dissectors that verify checksums have both a status and expert info field. Also address comments from original proto_tree_add_checksum patch that didn't make it. Ping-Bug: 8859 Change-Id: I2e6640108fd6bb218cb959fe9e4ba98a13e43a2f Reviewed-on: https://code.wireshark.org/review/16590 Petri-Dish: Michael Mann Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- epan/dissectors/packet-rfid-pn532-hci.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'epan/dissectors/packet-rfid-pn532-hci.c') diff --git a/epan/dissectors/packet-rfid-pn532-hci.c b/epan/dissectors/packet-rfid-pn532-hci.c index cbc3f2e475..3ec5a2655a 100644 --- a/epan/dissectors/packet-rfid-pn532-hci.c +++ b/epan/dissectors/packet-rfid-pn532-hci.c @@ -36,11 +36,13 @@ static int hf_preamble = -1; static int hf_start_code = -1; static int hf_length = -1; static int hf_length_checksum = -1; +static int hf_length_checksum_status = -1; static int hf_extended_length = -1; static int hf_packet_code = -1; static int hf_postable = -1; static int hf_specific_application_level_error_code = -1; static int hf_data_checksum = -1; +static int hf_data_checksum_status = -1; static int hf_ignored = -1; static gint ett_pn532_hci = -1; @@ -126,11 +128,9 @@ dissect_pn532_hci(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat length = tvb_get_ntohs(tvb, offset); offset += 2; - proto_tree_add_item(main_tree, hf_length_checksum, tvb, offset, 1, ENC_BIG_ENDIAN); checksum = (length >> 8) + (length & 0xFF) + tvb_get_guint8(tvb, offset); - if (checksum != 0) { - proto_tree_add_expert(main_tree, pinfo, &ei_invalid_length_checksum, tvb, offset, 1); - } + proto_tree_add_checksum(main_tree, tvb, offset, hf_length_checksum, hf_length_checksum_status, &ei_invalid_length_checksum, + pinfo, checksum, ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_ZERO); offset += 1; next_tvb = tvb_new_subset_length(tvb, offset, length); @@ -142,7 +142,7 @@ dissect_pn532_hci(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat checksum += tvb_get_guint8(tvb, offset - length); length -= 1; } - proto_tree_add_checksum(main_tree, tvb, offset, hf_data_checksum, -1, &ei_invalid_data_checksum, pinfo, 0, + proto_tree_add_checksum(main_tree, tvb, offset, hf_data_checksum, hf_data_checksum_status, &ei_invalid_data_checksum, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_ZERO); offset += 1; } else { /* Normal Information Frame */ @@ -152,10 +152,9 @@ dissect_pn532_hci(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat length = tvb_get_guint8(tvb, offset); offset += 1; - proto_tree_add_item(main_tree, hf_length_checksum, tvb, offset, 1, ENC_BIG_ENDIAN); checksum = length + tvb_get_guint8(tvb, offset); - if (checksum != 0) - proto_tree_add_expert(main_tree, pinfo, &ei_invalid_length_checksum, tvb, offset, 1); + proto_tree_add_checksum(main_tree, tvb, offset, hf_length_checksum, hf_length_checksum_status, &ei_invalid_length_checksum, + pinfo, checksum, ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_ZERO); offset += 1; next_tvb = tvb_new_subset_length(tvb, offset, length); @@ -230,11 +229,21 @@ proto_register_pn532_hci(void) FT_UINT8, BASE_HEX, NULL, 0x00, NULL, HFILL } }, + { &hf_length_checksum_status, + { "Length Checksum Status", "pn532_hci.length_checksum.status", + FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x00, + NULL, HFILL } + }, { &hf_data_checksum, { "Data Checksum", "pn532_hci.data_checksum", FT_UINT8, BASE_HEX, NULL, 0x00, NULL, HFILL } }, + { &hf_data_checksum_status, + { "Data Checksum Status", "pn532_hci.data_checksum.status", + FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x00, + NULL, HFILL } + }, { &hf_specific_application_level_error_code, { "Specific Application Level Error Code","pn532_hci.specific_application_level_error_code", FT_UINT8, BASE_HEX, NULL, 0x00, -- cgit v1.2.3