2 * Routines for Veritas Low Latency Transport (LLT) dissection
3 * Copyright 2006, Stephen Fisher (see AUTHORS file)
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include <epan/packet.h>
29 #include <epan/prefs.h>
30 #include <epan/etypes.h>
32 void proto_register_llt(void);
33 void proto_reg_handoff_llt(void);
35 static const value_string message_type_vs[] = {
36 { 0x0a, "heartbeat" },
40 /* Variables for our preferences */
41 static guint preference_alternate_ethertype = 0x0;
43 /* Initialize the protocol and registered fields */
44 static int proto_llt = -1;
46 static int hf_llt_cluster_num = -1;
47 static int hf_llt_node_id = -1;
48 static int hf_llt_message_type = -1;
49 static int hf_llt_sequence_num = -1;
50 static int hf_llt_message_time = -1;
52 /* Initialize the subtree pointers */
53 static gint ett_llt = -1;
55 /* Code to actually dissect the packets */
57 dissect_llt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
59 /* Set up structures needed to add the protocol subtree and manage it */
64 /* Make entries in Protocol column and Info column on summary display */
65 col_set_str(pinfo->cinfo, COL_PROTOCOL, "LLT");
67 message_type = tvb_get_guint8(tvb, 3);
69 col_add_fstr(pinfo->cinfo, COL_INFO, "Message type: %s", val_to_str(message_type, message_type_vs, "Unknown (0x%02x)"));
71 ti = proto_tree_add_item(tree, proto_llt, tvb, 0, -1, ENC_NA);
72 llt_tree = proto_item_add_subtree(ti, ett_llt);
74 proto_tree_add_item(llt_tree, hf_llt_cluster_num, tvb, 2, 1, ENC_BIG_ENDIAN);
75 proto_tree_add_item(llt_tree, hf_llt_message_type, tvb, 3, 1, ENC_BIG_ENDIAN);
76 proto_tree_add_item(llt_tree, hf_llt_node_id, tvb, 7, 1, ENC_BIG_ENDIAN);
77 proto_tree_add_item(llt_tree, hf_llt_sequence_num, tvb, 24, 4, ENC_BIG_ENDIAN);
78 proto_tree_add_item(llt_tree, hf_llt_message_time, tvb, 40, 4, ENC_BIG_ENDIAN);
82 /* Register the protocol with Wireshark */
84 proto_register_llt(void)
88 static hf_register_info hf[] = {
90 { &hf_llt_cluster_num, { "Cluster number", "llt.cluster_num",
91 FT_UINT8, BASE_DEC, NULL, 0,
92 "Cluster number that this node belongs to", HFILL } },
94 { &hf_llt_message_type, { "Message type", "llt.message_type",
95 FT_UINT8, BASE_HEX, VALS(message_type_vs), 0,
96 "Type of LLT message contained in this frame", HFILL } },
98 { &hf_llt_node_id, { "Node ID", "llt.node_id",
99 FT_UINT8, BASE_DEC, NULL, 0,
100 "Number identifying this node within the cluster", HFILL } },
102 { &hf_llt_sequence_num, { "Sequence number", "llt.sequence_num",
103 FT_UINT32, BASE_DEC, NULL, 0,
104 "Sequence number of this frame", HFILL } },
106 { &hf_llt_message_time, { "Message time", "llt.message_time",
107 FT_UINT32, BASE_DEC, NULL, 0,
108 "Number of ticks since this node was last rebooted", HFILL } }
111 /* Setup protocol subtree array */
112 static gint *ett[] = {
116 /* Register the protocol name and description */
117 proto_llt = proto_register_protocol("Veritas Low Latency Transport (LLT)", "LLT", "llt");
119 /* Required function calls to register the header fields and subtrees used */
120 proto_register_field_array(proto_llt, hf, array_length(hf));
121 proto_register_subtree_array(ett, array_length(ett));
123 /* Register preferences module */
124 llt_module = prefs_register_protocol(proto_llt, proto_reg_handoff_llt);
126 /* Register our preferences */
127 prefs_register_uint_preference(llt_module, "alternate_ethertype", "Alternate ethertype value (in hex)",
128 "Dissect this ethertype as LLT traffic in addition to the default, 0xCAFE.",
129 16, &preference_alternate_ethertype); /* A base-16 (hexadecimal) value */
135 proto_reg_handoff_llt(void)
137 static gboolean initialized = FALSE;
138 static dissector_handle_t llt_handle;
139 static guint preference_alternate_ethertype_last;
142 llt_handle = create_dissector_handle(dissect_llt, proto_llt);
143 dissector_add_uint("ethertype", ETHERTYPE_LLT, llt_handle);
146 if (preference_alternate_ethertype_last != 0x0) {
147 dissector_delete_uint("ethertype", preference_alternate_ethertype_last, llt_handle);
151 /* Save the setting to see if it has changed later */
152 preference_alternate_ethertype_last = preference_alternate_ethertype;
154 if (preference_alternate_ethertype != 0x0) {
155 /* Register the new ethertype setting */
156 dissector_add_uint("ethertype", preference_alternate_ethertype, llt_handle);