aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-ipsec-udp.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2014-08-09 13:43:44 -0400
committerMichael Mann <mmann78@netscape.net>2014-08-10 21:39:20 +0000
commit3635d7bed70aaf14e8172654f2b40be318e7dbfe (patch)
tree4b0fce1dba327df9a24b4ddc267a83375c817683 /epan/dissectors/packet-ipsec-udp.c
parent18346c84778019fe6eee6906758daa120f84d5d0 (diff)
Eliminate proto_tree_add_text from some dissectors.
Other minor cleanup while in the neighborhood. Change-Id: Ib76f4a9f89b5933425760af0a980c6a549031b8f Reviewed-on: https://code.wireshark.org/review/3537 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/dissectors/packet-ipsec-udp.c')
-rw-r--r--epan/dissectors/packet-ipsec-udp.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/epan/dissectors/packet-ipsec-udp.c b/epan/dissectors/packet-ipsec-udp.c
index d2e8717638..78eb0275e2 100644
--- a/epan/dissectors/packet-ipsec-udp.c
+++ b/epan/dissectors/packet-ipsec-udp.c
@@ -31,6 +31,10 @@ void proto_register_udpencap(void);
void proto_reg_handoff_udpencap(void);
static int proto_udpencap = -1;
+
+static int hf_nat_keepalive = -1;
+static int hf_non_esp_marker = -1;
+
static gint ett_udpencap = -1;
static dissector_handle_t esp_handle;
@@ -44,39 +48,32 @@ static void
dissect_udpencap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
tvbuff_t *next_tvb;
- proto_tree *udpencap_tree = NULL;
- proto_item *ti = NULL;
+ proto_tree *udpencap_tree;
+ proto_item *ti;
guint32 spi;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "UDPENCAP");
col_clear(pinfo->cinfo, COL_INFO);
- if (tree) {
- ti = proto_tree_add_item(tree, proto_udpencap, tvb, 0, -1, ENC_NA);
- udpencap_tree = proto_item_add_subtree(ti, ett_udpencap);
- }
+ ti = proto_tree_add_item(tree, proto_udpencap, tvb, 0, -1, ENC_NA);
+ udpencap_tree = proto_item_add_subtree(ti, ett_udpencap);
/* 1 byte of 0xFF indicates NAT-keepalive */
if ((tvb_length(tvb) == 1) && (tvb_get_guint8(tvb, 0) == 0xff)) {
col_set_str(pinfo->cinfo, COL_INFO, "NAT-keepalive");
- if (tree)
- proto_tree_add_text(udpencap_tree, tvb, 0, 1, "NAT-keepalive packet");
+ proto_tree_add_item(udpencap_tree, hf_nat_keepalive, tvb, 0, 1, ENC_NA);
} else {
/* SPI of zero indicates IKE traffic, otherwise it's ESP */
- tvb_memcpy(tvb, (guint8 *)&spi, 0, sizeof(spi));
+ spi = tvb_get_ntohl(tvb, 0);
if (spi == 0) {
col_set_str(pinfo->cinfo, COL_INFO, "ISAKMP");
- if (tree) {
- proto_tree_add_text(udpencap_tree, tvb, 0, sizeof(spi),
- "Non-ESP Marker");
- proto_item_set_len(ti, sizeof(spi));
- }
- next_tvb = tvb_new_subset_remaining(tvb, sizeof(spi));
+ proto_tree_add_item(udpencap_tree, hf_non_esp_marker, tvb, 0, 4, ENC_NA);
+ proto_item_set_len(ti, 4);
+ next_tvb = tvb_new_subset_remaining(tvb, 4);
call_dissector(isakmp_handle, next_tvb, pinfo, tree);
} else {
col_set_str(pinfo->cinfo, COL_INFO, "ESP");
- if (tree)
- proto_item_set_len(ti, 0);
+ proto_item_set_len(ti, 0);
call_dissector(esp_handle, tvb, pinfo, tree);
}
}
@@ -85,12 +82,20 @@ dissect_udpencap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
void
proto_register_udpencap(void)
{
+ static hf_register_info hf[] = {
+ { &hf_nat_keepalive, { "NAT-keepalive packet", "udpencap.nat_keepalive",
+ FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }},
+ { &hf_non_esp_marker, { "Non-ESP Marker", "udpencap.non_esp_marker",
+ FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }},
+ };
+
static gint *ett[] = {
&ett_udpencap,
};
proto_udpencap = proto_register_protocol(
"UDP Encapsulation of IPsec Packets", "UDPENCAP", "udpencap");
+ proto_register_field_array(proto_udpencap, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
}