aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-pagp.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2014-09-05 08:48:37 -0400
committerAlexis La Goutte <alexis.lagoutte@gmail.com>2014-09-06 07:44:46 +0000
commitceef7eba755cbecf670653360f72d864949dac49 (patch)
tree2cc48ebd17a4e7dc714f1b00af21f4f92546c948 /epan/dissectors/packet-pagp.c
parentf1ad9eb212a6f4c5e1b6b1963bccf5f3a4900293 (diff)
Eliminate proto_tree_add_text from some of the dissectors.
Other minor cleanups while in the area. Change-Id: I8ea59205cfe6fab643d8fe01b75ce91532004fd9 Reviewed-on: https://code.wireshark.org/review/4004 Reviewed-by: Michael Mann <mmann78@netscape.net> Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-pagp.c')
-rw-r--r--epan/dissectors/packet-pagp.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/epan/dissectors/packet-pagp.c b/epan/dissectors/packet-pagp.c
index ea1246384a..057d426d9e 100644
--- a/epan/dissectors/packet-pagp.c
+++ b/epan/dissectors/packet-pagp.c
@@ -27,6 +27,7 @@
#include "config.h"
#include <epan/packet.h>
+#include <epan/expert.h>
#include <epan/to_str.h>
void proto_register_pagp(void);
@@ -101,6 +102,7 @@ static int hf_pagp_partner_group_ifindex = -1;
static int hf_pagp_partner_count = -1;
static int hf_pagp_num_tlvs = -1;
static int hf_pagp_tlv = -1;
+static int hf_pagp_tlv_length = -1;
static int hf_pagp_tlv_device_name = -1;
static int hf_pagp_tlv_port_name = -1;
static int hf_pagp_tlv_agport_mac = -1;
@@ -115,6 +117,8 @@ static gint ett_pagp = -1;
static gint ett_pagp_flags = -1;
static gint ett_pagp_tlvs = -1;
+static expert_field ei_pagp_tlv_length = EI_INIT;
+
/* General declarations and macros */
static const char initial_sep[] = " (";
@@ -170,7 +174,7 @@ dissect_pagp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
guchar *ch;
proto_tree *pagp_tree = NULL;
- proto_item *pagp_item;
+ proto_item *pagp_item, *len_item;
proto_tree *flags_tree;
proto_item *flags_item;
proto_tree *tlv_tree;
@@ -283,7 +287,6 @@ dissect_pagp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
proto_tree_add_item(pagp_tree, hf_pagp_partner_device_id, tvb,
PAGP_PARTNER_DEVICE_ID, 6, ENC_NA);
- if (tree) {
raw_octet = tvb_get_guint8(tvb, PAGP_PARTNER_LEARN_CAP);
proto_tree_add_uint(pagp_tree, hf_pagp_partner_learn_cap, tvb,
PAGP_PARTNER_LEARN_CAP, 1, raw_octet);
@@ -318,22 +321,19 @@ dissect_pagp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
tlv = tvb_get_ntohs(tvb, offset);
len = tvb_get_ntohs(tvb, offset + 2);
- if ( len == 0 ) {
- proto_tree_add_text(pagp_tree, tvb, offset, -1,
- "Unknown data - TLV len=0");
- return;
- }
tlv_tree = proto_tree_add_subtree_format(pagp_tree, tvb, offset, len,
ett_pagp_tlvs, NULL, "TLV Entry #%d", ii+1);
- proto_tree_add_uint_format (tlv_tree, hf_pagp_tlv, tvb,
- offset,2,tlv,"Type = %d (%s)", tlv,
- val_to_str_const(tlv,tlv_types, "Unknown")) ;
- proto_tree_add_text (tlv_tree, tvb, offset+2, 2,
- "Length = %u bytes (includes Type and Length)", len) ;
+ proto_tree_add_uint(tlv_tree, hf_pagp_tlv, tvb, offset, 2, tlv);
+ len_item = proto_tree_add_uint(tlv_tree, hf_pagp_tlv_length, tvb, offset+2, 2, len);
+ if ( len == 0 ) {
+ expert_add_info_format(pinfo, len_item, &ei_pagp_tlv_length,
+ "Unknown data - TLV len=0");
+ return;
+ }
if ( tvb_reported_length_remaining(tvb, offset) < len ) {
- proto_tree_add_text(tlv_tree, tvb, offset, -1,
+ expert_add_info_format(pinfo, len_item, &ei_pagp_tlv_length,
"TLV length too large");
return;
}
@@ -360,7 +360,6 @@ dissect_pagp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
offset += len;
}
- }
}
@@ -469,10 +468,15 @@ proto_register_pagp(void)
"Number of TLVs following", HFILL }},
{ &hf_pagp_tlv,
- { "Entry", "pagp.tlv",
- FT_UINT16, BASE_DEC, NULL, 0x0,
+ { "Type", "pagp.tlv",
+ FT_UINT16, BASE_DEC, VALS(tlv_types), 0x0,
"Type/Length/Value", HFILL }},
+ { &hf_pagp_tlv_length,
+ { "Length", "pagp.tlv_length",
+ FT_UINT16, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }},
+
{ &hf_pagp_tlv_device_name,
{ "Device Name", "pagp.tlvdevname",
FT_STRING, BASE_NONE, NULL, 0x0,
@@ -513,6 +517,11 @@ proto_register_pagp(void)
&ett_pagp_tlvs,
};
+ static ei_register_info ei[] = {
+ { &ei_pagp_tlv_length, { "pagp.tlv_length.invalid", PI_PROTOCOL, PI_WARN, "Invalid TLV length", EXPFILL }},
+ };
+ expert_module_t* expert_pagp;
+
/* Register the protocol name and description */
proto_pagp = proto_register_protocol("Port Aggregation Protocol", "PAGP", "pagp");
@@ -521,7 +530,8 @@ proto_register_pagp(void)
proto_register_field_array(proto_pagp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
-
+ expert_pagp = expert_register_protocol(proto_pagp);
+ expert_register_field_array(expert_pagp, ei, array_length(ei));
}