HPEXT: Convert to old proto tree API

Related with #17774.
This commit is contained in:
João Valverde 2021-12-09 02:30:52 +00:00
parent 165384f74f
commit b9ed05f6b8
1 changed files with 25 additions and 34 deletions

View File

@ -8,9 +8,6 @@
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#define NEW_PROTO_TREE_API
#include "config.h"
#include <epan/packet.h>
@ -32,23 +29,11 @@ static const value_string xsap_vals[] = {
{ 0x00, NULL }
};
static int proto_hpext = -1;
static header_field_info *hfi_hpext = NULL;
#define HPEXT_HFI_INIT HFI_INIT(proto_hpext)
static header_field_info hfi_hpext_dxsap HPEXT_HFI_INIT =
{ "DXSAP", "hpext.dxsap", FT_UINT16, BASE_HEX,
VALS(xsap_vals), 0x0, NULL, HFILL };
static header_field_info hfi_hpext_sxsap HPEXT_HFI_INIT =
{ "SXSAP", "hpext.sxsap", FT_UINT16, BASE_HEX,
VALS(xsap_vals), 0x0, NULL, HFILL };
static header_field_info hfi_hpext_reserved HPEXT_HFI_INIT =
{ "Reserved", "hpext.reserved", FT_UINT24, BASE_HEX,
NULL, 0x0, NULL, HFILL };
static int hf_hpext_dxsap = -1;
static int hf_hpext_reserved = -1;
static int hf_hpext_sxsap = -1;
static gint ett_hpext = -1;
@ -66,12 +51,12 @@ dissect_hpext(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U
sxsap = tvb_get_ntohs(tvb, 5);
if (tree) {
ti = proto_tree_add_item(tree, hfi_hpext, tvb, 0, 7, ENC_NA);
ti = proto_tree_add_item(tree, proto_hpext, tvb, 0, 7, ENC_NA);
hpext_tree = proto_item_add_subtree(ti, ett_hpext);
proto_tree_add_item(hpext_tree, &hfi_hpext_reserved, tvb, 0, 3, ENC_NA);
proto_tree_add_uint(hpext_tree, &hfi_hpext_dxsap, tvb, 3,
proto_tree_add_item(hpext_tree, hf_hpext_reserved, tvb, 0, 3, ENC_NA);
proto_tree_add_uint(hpext_tree, hf_hpext_dxsap, tvb, 3,
2, dxsap);
proto_tree_add_uint(hpext_tree, &hfi_hpext_sxsap, tvb, 5,
proto_tree_add_uint(hpext_tree, hf_hpext_sxsap, tvb, 5,
2, sxsap);
}
@ -93,25 +78,31 @@ dissect_hpext(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U
void
proto_register_hpext(void)
{
#ifndef HAVE_HFI_SECTION_INIT
static header_field_info *hfi[] = {
&hfi_hpext_reserved,
&hfi_hpext_dxsap,
&hfi_hpext_sxsap,
static hf_register_info hf[] = {
{ &hf_hpext_dxsap,
{ "DXSAP", "hpext.dxsap",
FT_UINT16, BASE_HEX, VALS(xsap_vals), 0x0,
NULL, HFILL }
},
{ &hf_hpext_sxsap,
{ "SXSAP", "hpext.sxsap",
FT_UINT16, BASE_HEX, VALS(xsap_vals), 0x0,
NULL, HFILL }
},
{ &hf_hpext_reserved,
{ "Reserved", "hpext.reserved",
FT_UINT24, BASE_HEX, NULL, 0x0,
NULL, HFILL }
},
};
#endif
static gint *ett[] = {
&ett_hpext
};
int proto_hpext;
proto_hpext = proto_register_protocol(
"HP Extended Local-Link Control", "HPEXT", "hpext");
hfi_hpext = proto_registrar_get_nth(proto_hpext);
proto_register_fields(proto_hpext, hfi, array_length(hfi));
proto_register_field_array(proto_hpext, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
/* subdissector code */