aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-redback.c
diff options
context:
space:
mode:
Diffstat (limited to 'epan/dissectors/packet-redback.c')
-rw-r--r--epan/dissectors/packet-redback.c142
1 files changed, 76 insertions, 66 deletions
diff --git a/epan/dissectors/packet-redback.c b/epan/dissectors/packet-redback.c
index a10dd7447c..1df0c5c744 100644
--- a/epan/dissectors/packet-redback.c
+++ b/epan/dissectors/packet-redback.c
@@ -8,9 +8,6 @@
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
-
-#define NEW_PROTO_TREE_API
-
#include "config.h"
#include <epan/packet.h>
@@ -23,7 +20,7 @@ void proto_reg_handoff_redback(void);
static dissector_handle_t redback_handle;
-static gint ett_redback = -1;
+static gint ett_redback;
static dissector_table_t osinl_incl_subdissector_table;
static dissector_table_t osinl_excl_subdissector_table;
@@ -36,38 +33,19 @@ static dissector_handle_t arp_handle;
static dissector_handle_t ppp_handle;
static dissector_handle_t ppphdlc_handle;
-static header_field_info *hfi_redback = NULL;
-
-#define REDBACK_HFI_INIT HFI_INIT(proto_redback)
-
-static header_field_info hfi_redback_context REDBACK_HFI_INIT =
- { "Context", "redback.context", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL };
-
-static header_field_info hfi_redback_flags REDBACK_HFI_INIT =
- { "Flags", "redback.flags", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL };
-
-static header_field_info hfi_redback_circuit REDBACK_HFI_INIT =
- { "Circuit", "redback.circuit", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL };
-
-static header_field_info hfi_redback_length REDBACK_HFI_INIT =
- { "Length", "redback.length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL };
-
-static header_field_info hfi_redback_protocol REDBACK_HFI_INIT =
- { "Protocol", "redback.protocol", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL };
-
-static header_field_info hfi_redback_l3offset REDBACK_HFI_INIT =
- { "Layer 3 Offset", "redback.l3offset", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL };
-
-static header_field_info hfi_redback_dataoffset REDBACK_HFI_INIT =
- { "Data Offset", "redback.dataoffset", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL };
-
-static header_field_info hfi_redback_padding REDBACK_HFI_INIT =
- { "Padding", "redback.padding", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL };
+static int proto_redback;
-static header_field_info hfi_redback_unknown REDBACK_HFI_INIT =
- { "Unknown", "redback.unknown", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL };
+static int hf_redback_circuit;
+static int hf_redback_context;
+static int hf_redback_dataoffset;
+static int hf_redback_flags;
+static int hf_redback_l3offset;
+static int hf_redback_length;
+static int hf_redback_padding;
+static int hf_redback_protocol;
+static int hf_redback_unknown;
-static expert_field ei_redback_protocol = EI_INIT;
+static expert_field ei_redback_protocol;
static int
dissect_redback(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
@@ -82,19 +60,19 @@ dissect_redback(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data
dataoff = tvb_get_ntohs(tvb, 20);
l3off = tvb_get_ntohs(tvb, 22);
- ti = proto_tree_add_item(tree, hfi_redback, tvb, 0, -1, ENC_NA);
+ ti = proto_tree_add_item(tree, proto_redback, tvb, 0, -1, ENC_NA);
rbtree = proto_item_add_subtree(ti, ett_redback);
- proto_tree_add_item(rbtree, &hfi_redback_context, tvb, 0, 4, ENC_BIG_ENDIAN);
- proto_tree_add_item(rbtree, &hfi_redback_flags, tvb, 4, 4, ENC_BIG_ENDIAN);
- proto_tree_add_item(rbtree, &hfi_redback_circuit, tvb, 8, 8, ENC_BIG_ENDIAN);
- proto_tree_add_item(rbtree, &hfi_redback_length, tvb, 16, 2, ENC_BIG_ENDIAN);
- protocol_item = proto_tree_add_item(rbtree, &hfi_redback_protocol, tvb, 18, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(rbtree, &hfi_redback_dataoffset, tvb, 20, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(rbtree, &hfi_redback_l3offset, tvb, 22, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_item(rbtree, hf_redback_context, tvb, 0, 4, ENC_BIG_ENDIAN);
+ proto_tree_add_item(rbtree, hf_redback_flags, tvb, 4, 4, ENC_BIG_ENDIAN);
+ proto_tree_add_item(rbtree, hf_redback_circuit, tvb, 8, 8, ENC_BIG_ENDIAN);
+ proto_tree_add_item(rbtree, hf_redback_length, tvb, 16, 2, ENC_BIG_ENDIAN);
+ protocol_item = proto_tree_add_item(rbtree, hf_redback_protocol, tvb, 18, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_item(rbtree, hf_redback_dataoffset, tvb, 20, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_item(rbtree, hf_redback_l3offset, tvb, 22, 2, ENC_BIG_ENDIAN);
if (dataoff > 24) {
- proto_tree_add_item(rbtree, &hfi_redback_padding, tvb, 24, dataoff-24, ENC_NA);
+ proto_tree_add_item(rbtree, hf_redback_padding, tvb, 24, dataoff-24, ENC_NA);
}
proto = tvb_get_ntohs(tvb, 18);
@@ -148,7 +126,7 @@ dissect_redback(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data
next_tvb = tvb_new_subset_remaining(tvb, dataoff);
} else {
if (tree)
- proto_tree_add_item(rbtree, &hfi_redback_unknown, tvb, dataoff, 4, ENC_NA);
+ proto_tree_add_item(rbtree, hf_redback_unknown, tvb, dataoff, 4, ENC_NA);
next_tvb = tvb_new_subset_remaining(tvb, dataoff+4);
}
@@ -182,19 +160,53 @@ dissect_redback(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data
void
proto_register_redback(void)
{
-#ifndef HAVE_HFI_SECTION_INIT
- static header_field_info *hfi[] = {
- &hfi_redback_context,
- &hfi_redback_flags,
- &hfi_redback_circuit,
- &hfi_redback_length,
- &hfi_redback_protocol,
- &hfi_redback_l3offset,
- &hfi_redback_dataoffset,
- &hfi_redback_padding,
- &hfi_redback_unknown,
+ static hf_register_info hf[] = {
+ { &hf_redback_context,
+ { "Context", "redback.context",
+ FT_UINT32, BASE_HEX, NULL, 0x0,
+ NULL, HFILL }
+ },
+ { &hf_redback_flags,
+ { "Flags", "redback.flags",
+ FT_UINT32, BASE_HEX, NULL, 0x0,
+ NULL, HFILL }
+ },
+ { &hf_redback_circuit,
+ { "Circuit", "redback.circuit",
+ FT_UINT64, BASE_HEX, NULL, 0x0,
+ NULL, HFILL }
+ },
+ { &hf_redback_length,
+ { "Length", "redback.length",
+ FT_UINT16, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }
+ },
+ { &hf_redback_protocol,
+ { "Protocol", "redback.protocol",
+ FT_UINT16, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }
+ },
+ { &hf_redback_l3offset,
+ { "Layer 3 Offset", "redback.l3offset",
+ FT_UINT16, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }
+ },
+ { &hf_redback_dataoffset,
+ { "Data Offset", "redback.dataoffset",
+ FT_UINT16, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }
+ },
+ { &hf_redback_padding,
+ { "Padding", "redback.padding",
+ FT_BYTES, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }
+ },
+ { &hf_redback_unknown,
+ { "Unknown", "redback.unknown",
+ FT_BYTES, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }
+ },
};
-#endif
static gint *ett[] = {
&ett_redback
@@ -205,13 +217,11 @@ proto_register_redback(void)
};
expert_module_t* expert_redback;
- int proto_redback;
proto_redback = proto_register_protocol("Redback", "Redback", "redback");
- hfi_redback = proto_registrar_get_nth(proto_redback);
+ proto_register_field_array(proto_redback, hf, array_length(hf));
redback_handle = register_dissector("redback", dissect_redback, proto_redback);
- proto_register_fields(proto_redback, hfi, array_length(hfi));
proto_register_subtree_array(ett, array_length(ett));
expert_redback = expert_register_protocol(proto_redback);
expert_register_field_array(expert_redback, ei, array_length(ei));
@@ -223,13 +233,13 @@ proto_reg_handoff_redback(void)
osinl_incl_subdissector_table = find_dissector_table("osinl.incl");
osinl_excl_subdissector_table = find_dissector_table("osinl.excl");
- ipv4_handle = find_dissector_add_dependency("ip", hfi_redback->id);
- ipv6_handle = find_dissector_add_dependency("ipv6", hfi_redback->id);
- ethnofcs_handle = find_dissector_add_dependency("eth_withoutfcs", hfi_redback->id);
- clnp_handle = find_dissector_add_dependency("clnp", hfi_redback->id);
- arp_handle = find_dissector_add_dependency("arp", hfi_redback->id);
- ppp_handle = find_dissector_add_dependency("ppp", hfi_redback->id);
- ppphdlc_handle = find_dissector_add_dependency("ppp_hdlc", hfi_redback->id);
+ ipv4_handle = find_dissector_add_dependency("ip", proto_redback);
+ ipv6_handle = find_dissector_add_dependency("ipv6", proto_redback);
+ ethnofcs_handle = find_dissector_add_dependency("eth_withoutfcs", proto_redback);
+ clnp_handle = find_dissector_add_dependency("clnp", proto_redback);
+ arp_handle = find_dissector_add_dependency("arp", proto_redback);
+ ppp_handle = find_dissector_add_dependency("ppp", proto_redback);
+ ppphdlc_handle = find_dissector_add_dependency("ppp_hdlc", proto_redback);
dissector_add_uint("wtap_encap", WTAP_ENCAP_REDBACK, redback_handle);
}