epan/dissectors/pidl/ C99 drsuapi
[wireshark-sm.git] / epan / dissectors / packet-pa-hbbackup.c
blob6372643776e3f06d15535bc853cc8df0f31bbb39
1 /* packet-hbbak.c
2 * Routines for ethertype 0x8988 Paloalto heartbeat backup traffic via mgmt
4 * Copyright 2020 Joerg Mayer (see AUTHORS file)
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
13 /* 2do:
14 * - Find out the meaning of the 6 bytes header: timestamp?
15 * - Handle trailer bytes correctly
18 #include "config.h"
20 #include <epan/packet.h>
21 #include <epan/etypes.h>
23 void proto_reg_handoff_hbbak(void);
24 void proto_register_hbbak(void);
26 #define PROTO_SHORT_NAME "PA-HB-Bak"
27 #define PROTO_LONG_NAME "Palo Alto Heartbeat Backup"
29 #define HBBAK_SIZE 8
31 static int proto_hbbak;
32 static int hf_hbbak_unknown1;
33 static int hf_hbbak_etype_outer;
34 static int hf_hbbak_trailer;
36 static int ett_hbbak;
38 static dissector_handle_t hbbak_handle;
39 static dissector_handle_t ethertype_handle;
41 static int
42 dissect_hbbak(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
44 proto_tree *ti, *hbbak_tree;
45 int offset = 0;
46 uint16_t eth_type_outer;
47 ethertype_data_t ethertype_data;
49 col_set_str(pinfo->cinfo, COL_PROTOCOL, PROTO_SHORT_NAME);
50 col_clear(pinfo->cinfo, COL_INFO);
51 col_add_fstr(pinfo->cinfo, COL_INFO, PROTO_LONG_NAME);
53 hbbak_tree = NULL;
54 ti = proto_tree_add_item(tree, proto_hbbak, tvb, offset, HBBAK_SIZE, ENC_NA);
55 hbbak_tree = proto_item_add_subtree(ti, ett_hbbak);
57 proto_tree_add_item(hbbak_tree, hf_hbbak_unknown1, tvb, offset, 6, ENC_NA);
58 offset += 6;
59 eth_type_outer = tvb_get_ntohs(tvb, offset);
60 proto_tree_add_uint(hbbak_tree, hf_hbbak_etype_outer, tvb,
61 offset, 2, eth_type_outer);
63 ethertype_data.etype = eth_type_outer;
64 ethertype_data.payload_offset = HBBAK_SIZE;
65 ethertype_data.fh_tree = hbbak_tree;
66 ethertype_data.trailer_id = hf_hbbak_trailer;
67 ethertype_data.fcs_len = 0;
69 call_dissector_with_data(ethertype_handle, tvb, pinfo, tree, &ethertype_data);
71 return tvb_captured_length(tvb);
74 void
75 proto_register_hbbak(void)
77 static hf_register_info hf[] = {
78 { &hf_hbbak_unknown1,
79 { "Unknown1", "hbbak.unknown1", FT_BYTES, BASE_NONE, NULL,
80 0x0, NULL, HFILL }},
82 { &hf_hbbak_etype_outer,
83 { "Type", "hbbak.etype", FT_UINT16, BASE_HEX, VALS(etype_vals),
84 0x0, NULL, HFILL }},
86 { &hf_hbbak_trailer,
87 { "Trailer", "hbbak.trailer", FT_BYTES, BASE_NONE, NULL,
88 0x0, NULL, HFILL }},
92 static int *ett[] = {
93 &ett_hbbak,
96 proto_hbbak = proto_register_protocol(PROTO_LONG_NAME, PROTO_LONG_NAME, "hbbak");
97 proto_register_field_array(proto_hbbak, hf, array_length(hf));
98 proto_register_subtree_array(ett, array_length(ett));
99 hbbak_handle = register_dissector("hbbak", dissect_hbbak, proto_hbbak);
102 void
103 proto_reg_handoff_hbbak(void)
106 ethertype_handle = find_dissector_add_dependency("ethertype", proto_hbbak);
108 dissector_add_uint("ethertype", ETHERTYPE_PA_HBBACKUP, hbbak_handle);
112 * Editor modelines - https://www.wireshark.org/tools/modelines.html
114 * Local variables:
115 * c-basic-offset: 8
116 * tab-width: 8
117 * indent-tabs-mode: t
118 * End:
120 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
121 * :indentSize=8:tabSize=8:noTabs=false: