aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-carp.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2014-08-01 10:08:57 -0400
committerMichael Mann <mmann78@netscape.net>2014-08-03 16:30:10 +0000
commit5db1352526e71727091ff0e1c0e97821eec4e4cb (patch)
tree01f836967616b7ae8b2840c488b500c7ff13d55c /epan/dissectors/packet-carp.c
parent3fa5625ea074908d5617111a7edfcf6d95e6108a (diff)
Eliminate proto_tree_add_text from some dissectors.
Change-Id: I398e9cf4f6882e76644aa758e12c39a39159e95f Reviewed-on: https://code.wireshark.org/review/3319 Petri-Dish: Michael Mann <mmann78@netscape.net> Petri-Dish: Evan Huus <eapache@gmail.com> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/dissectors/packet-carp.c')
-rw-r--r--epan/dissectors/packet-carp.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/epan/dissectors/packet-carp.c b/epan/dissectors/packet-carp.c
index b9d5e347bd..36a05ee243 100644
--- a/epan/dissectors/packet-carp.c
+++ b/epan/dissectors/packet-carp.c
@@ -46,6 +46,7 @@ static gint hf_carp_demotion = -1;
static gint hf_carp_advbase = -1;
static gint hf_carp_counter = -1;
static gint hf_carp_hmac = -1;
+static gint hf_carp_checksum = -1;
#define CARP_VERSION_MASK 0xf0
#define CARP_TYPE_MASK 0x0f
@@ -134,6 +135,7 @@ dissect_carp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
offset++;
cksum = tvb_get_ntohs(tvb, offset);
+ ti = proto_tree_add_item(carp_tree, hf_carp_checksum, tvb, offset, 2, ENC_BIG_ENDIAN);
carp_len = (gint)tvb_reported_length(tvb);
if (!pinfo->fragmented && (gint)tvb_length(tvb) >= carp_len) {
/* The packet isn't part of a fragmented datagram
@@ -142,19 +144,13 @@ dissect_carp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
cksum_vec[0].len = carp_len;
computed_cksum = in_cksum(&cksum_vec[0], 1);
if (computed_cksum == 0) {
- proto_tree_add_text(carp_tree, tvb, offset, 2,
- "Checksum: 0x%04x [correct]",
- cksum);
+ proto_item_append_text(ti, " [correct]");
} else {
- proto_tree_add_text(carp_tree, tvb, offset, 2,
- "Checksum: 0x%04x [incorrect, should be 0x%04x]",
- cksum,
+ proto_item_append_text(ti, " [incorrect, should be 0x%04x]",
in_cksum_shouldbe(cksum, computed_cksum));
}
- } else {
- proto_tree_add_text(carp_tree, tvb, offset, 2,
- "Checksum: 0x%04x", cksum);
}
+
offset+=2;
/* Counter */
@@ -229,6 +225,11 @@ void proto_register_carp(void)
{"HMAC", "carp.hmac",
FT_BYTES, BASE_NONE, NULL, 0x0,
"SHA-1 HMAC", HFILL }},
+
+ { &hf_carp_checksum,
+ {"Checksum", "carp.checksum",
+ FT_UINT16, BASE_HEX, NULL, 0x0,
+ NULL, HFILL }},
};
static gint *ett[] = {