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