summaryrefslogtreecommitdiff
path: root/plugins/irda/packet-sir.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2016-07-21 10:21:25 -0400
committerAnders Broman <a.broman58@gmail.com>2016-07-27 03:40:02 +0000
commit8b0e9c66728f6a39bbe3ada1029e13ad1378013a (patch)
treec0c1b4da1845069520d4e131db96e6143e4ca772 /plugins/irda/packet-sir.c
parentb7f1e99f7f4c75fa4bac1ccba77087fb0e50b8ac (diff)
downloadwireshark-8b0e9c66728f6a39bbe3ada1029e13ad1378013a.tar.gz
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 <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'plugins/irda/packet-sir.c')
-rw-r--r--plugins/irda/packet-sir.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/plugins/irda/packet-sir.c b/plugins/irda/packet-sir.c
index 13534a7c5f..ff7ded56fb 100644
--- a/plugins/irda/packet-sir.c
+++ b/plugins/irda/packet-sir.c
@@ -25,6 +25,7 @@
#include "config.h"
#include <epan/packet.h>
+#include <epan/expert.h>
#include <epan/crc16-tvb.h>
/** Serial infrared port. */
@@ -60,6 +61,8 @@ static int hf_sir_fcs_status = -1;
static int hf_sir_length = -1;
static int hf_sir_preamble = -1;
+static expert_field ei_sir_fcs = EI_INIT;
+
/* Copied and renamed from proto.c because global value_strings don't work for plugins */
static const value_string plugin_proto_checksum_vals[] = {
{ PROTO_CHECKSUM_E_BAD, "Bad" },
@@ -101,13 +104,13 @@ unescape_data(tvbuff_t *tvb, packet_info *pinfo)
/** Checksums the data. */
static tvbuff_t *
-checksum_data(tvbuff_t *tvb, proto_tree *tree)
+checksum_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
int len = tvb_reported_length(tvb) - 2;
if (len < 0)
return tvb;
- proto_tree_add_checksum(tree, tvb, len, hf_sir_fcs, hf_sir_fcs_status, NULL, NULL, crc16_ccitt_tvb(tvb, len),
+ proto_tree_add_checksum(tree, tvb, len, hf_sir_fcs, hf_sir_fcs_status, &ei_sir_fcs, pinfo, crc16_ccitt_tvb(tvb, len),
ENC_LITTLE_ENDIAN, PROTO_CHECKSUM_VERIFY);
return tvb_new_subset_length(tvb, 0, len);
@@ -153,11 +156,11 @@ dissect_sir(tvbuff_t *tvb, packet_info *pinfo, proto_tree *root, void* data _U_)
bof_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_uint(tree, hf_sir_length,
next_tvb, 0, data_len, data_len);
- next_tvb = checksum_data(next_tvb, tree);
+ next_tvb = checksum_data(next_tvb, pinfo, tree);
proto_tree_add_item(tree, hf_sir_eof, tvb,
eof_offset, 1, ENC_BIG_ENDIAN);
} else {
- next_tvb = checksum_data(next_tvb, NULL);
+ next_tvb = checksum_data(next_tvb, pinfo, NULL);
}
call_dissector(irda_handle, next_tvb, pinfo, root);
}
@@ -216,12 +219,18 @@ proto_register_irsir(void)
NULL, HFILL }}
};
- proto_sir = proto_register_protocol(
- "Serial Infrared", "SIR", "sir");
+ static ei_register_info ei[] = {
+ { &ei_sir_fcs, { "sir.bad_checksum", PI_CHECKSUM, PI_ERROR, "Bad checksum", EXPFILL }},
+ };
+
+ expert_module_t* expert_sir;
+
+ proto_sir = proto_register_protocol("Serial Infrared", "SIR", "sir");
register_dissector("sir", dissect_sir, proto_sir);
proto_register_subtree_array(ett, array_length(ett));
- proto_register_field_array(
- proto_sir, hf_sir, array_length(hf_sir));
+ proto_register_field_array( proto_sir, hf_sir, array_length(hf_sir));
+ expert_sir = expert_register_protocol(proto_sir);
+ expert_register_field_array(expert_sir, ei, array_length(ei));
}
/*