2 * Routines for the disassembly of the "Far End Failure Detection"
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * Copied from packet-udld.c
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include <epan/packet.h>
30 #include <epan/strutil.h>
33 #include <epan/nlpid.h>
37 /* Offsets in TLV structure. */
41 static int proto_fefd
= -1;
42 static int hf_fefd_version
= -1;
43 static int hf_fefd_opcode
= -1;
44 static int hf_fefd_flags
= -1;
45 static int hf_fefd_flags_rt
= -1;
46 static int hf_fefd_flags_rsy
= -1;
47 static int hf_fefd_checksum
= -1;
48 static int hf_fefd_tlvtype
= -1;
49 static int hf_fefd_tlvlength
= -1;
51 static gint ett_fefd
= -1;
52 static gint ett_fefd_flags
= -1;
53 static gint ett_fefd_tlv
= -1;
55 static dissector_handle_t data_handle
;
57 #define TYPE_DEVICE_ID 0x0001
58 #define TYPE_PORT_ID 0x0002
59 #define TYPE_ECHO 0x0003
60 #define TYPE_MESSAGE_INTERVAL 0x0004
61 #define TYPE_TIMEOUT_INTERVAL 0x0005
62 #define TYPE_DEVICE_NAME 0x0006
63 #define TYPE_SEQUENCE_NUMBER 0x0007
66 static const value_string type_vals
[] = {
67 { TYPE_DEVICE_ID
, "Device ID" },
68 { TYPE_PORT_ID
, "Port ID" },
69 { TYPE_ECHO
, "Echo" },
70 { TYPE_MESSAGE_INTERVAL
, "Message interval" },
71 { TYPE_TIMEOUT_INTERVAL
, "Timeout interval" },
72 { TYPE_DEVICE_NAME
, "Device name" },
73 { TYPE_SEQUENCE_NUMBER
, "Sequence number" },
77 #define OPCODE_RESERVED 0x00
78 #define OPCODE_PROBE 0x01
79 #define OPCODE_ECHO 0x02
80 #define OPCODE_FLUSH 0x03
82 static const value_string opcode_vals
[] = {
83 { OPCODE_RESERVED
, "Reserved" },
84 { OPCODE_PROBE
, "Probe" },
85 { OPCODE_ECHO
, "Echo" },
86 { OPCODE_FLUSH
, "Flush" },
91 dissect_fefd(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
94 proto_tree
*fefd_tree
= NULL
;
102 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "FEFD");
103 col_clear(pinfo
->cinfo
, COL_INFO
);
106 proto_item
*flags_ti
;
107 proto_tree
*flags_tree
;
109 ti
= proto_tree_add_item(tree
, proto_fefd
, tvb
, offset
, -1, ENC_NA
);
110 fefd_tree
= proto_item_add_subtree(ti
, ett_fefd
);
113 proto_tree_add_item(fefd_tree
, hf_fefd_version
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
114 proto_tree_add_item(fefd_tree
, hf_fefd_opcode
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
116 flags_ti
= proto_tree_add_item(fefd_tree
, hf_fefd_flags
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
117 flags_tree
= proto_item_add_subtree(flags_ti
, ett_fefd_flags
);
118 proto_tree_add_item(flags_tree
, hf_fefd_flags_rt
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
119 proto_tree_add_item(flags_tree
, hf_fefd_flags_rsy
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
121 proto_tree_add_item(fefd_tree
, hf_fefd_checksum
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
124 offset
+= 4; /* The version/opcode/flags/checksum fields from above */
127 while (tvb_reported_length_remaining(tvb
, offset
) != 0) {
128 type
= tvb_get_ntohs(tvb
, offset
+ TLV_TYPE
);
129 length
= tvb_get_ntohs(tvb
, offset
+ TLV_LENGTH
);
132 tlvi
= proto_tree_add_text(fefd_tree
, tvb
, offset
, 4,
133 "TLV with invalid length %u (< 4)",
135 tlv_tree
= proto_item_add_subtree(tlvi
, ett_fefd_tlv
);
136 proto_tree_add_uint(tlv_tree
, hf_fefd_tlvtype
, tvb
,
137 offset
+ TLV_TYPE
, 2, type
);
138 proto_tree_add_uint(tlv_tree
, hf_fefd_tlvlength
, tvb
,
139 offset
+ TLV_LENGTH
, 2, length
);
150 col_append_sep_fstr(pinfo
->cinfo
, COL_INFO
, NULL
,
152 tvb_format_stringzpad(tvb
, offset
+ 4,
156 tlvi
= proto_tree_add_text(fefd_tree
, tvb
, offset
,
157 length
, "Device ID: %s",
158 tvb_format_stringzpad(tvb
, offset
+ 4, length
- 4));
159 tlv_tree
= proto_item_add_subtree(tlvi
, ett_fefd_tlv
);
160 proto_tree_add_uint(tlv_tree
, hf_fefd_tlvtype
, tvb
,
161 offset
+ TLV_TYPE
, 2, type
);
162 proto_tree_add_uint(tlv_tree
, hf_fefd_tlvlength
, tvb
,
163 offset
+ TLV_LENGTH
, 2, length
);
164 proto_tree_add_text(tlv_tree
, tvb
, offset
+ 4,
165 length
- 4, "Device ID: %s",
166 tvb_format_stringzpad(tvb
, offset
+ 4, length
- 4));
172 real_length
= length
;
173 if (tvb_get_guint8(tvb
, offset
+ real_length
) != 0x00) {
174 /* The length in the TLV doesn't appear to be the
175 length of the TLV, as the byte just past it
176 isn't the first byte of a 2-byte big-endian
177 small integer; make the length of the TLV the length
178 in the TLV, plus 4 bytes for the TLV type and length,
179 minus 1 because that's what makes one capture work. */
180 real_length
= length
+ 3;
183 col_append_sep_fstr(pinfo
->cinfo
, COL_INFO
, NULL
,
185 tvb_format_stringzpad(tvb
, offset
+ 4, real_length
- 4));
188 tlvi
= proto_tree_add_text(fefd_tree
, tvb
, offset
,
189 real_length
, "Port ID: %s",
190 tvb_format_text(tvb
, offset
+ 4, real_length
- 4));
191 tlv_tree
= proto_item_add_subtree(tlvi
, ett_fefd_tlv
);
192 proto_tree_add_uint(tlv_tree
, hf_fefd_tlvtype
, tvb
,
193 offset
+ TLV_TYPE
, 2, type
);
194 proto_tree_add_uint(tlv_tree
, hf_fefd_tlvlength
, tvb
,
195 offset
+ TLV_LENGTH
, 2, length
);
196 proto_tree_add_text(tlv_tree
, tvb
, offset
+ 4,
198 "Sent through Interface: %s",
199 tvb_format_text(tvb
, offset
+ 4, real_length
- 4));
201 offset
+= real_length
;
205 case TYPE_MESSAGE_INTERVAL
:
206 case TYPE_TIMEOUT_INTERVAL
:
207 case TYPE_DEVICE_NAME
:
208 case TYPE_SEQUENCE_NUMBER
:
210 tlvi
= proto_tree_add_text(fefd_tree
, tvb
, offset
,
211 length
, "Type: %s, length: %u",
212 val_to_str(type
, type_vals
, "Unknown (0x%04x)"),
214 tlv_tree
= proto_item_add_subtree(tlvi
, ett_fefd_tlv
);
215 proto_tree_add_uint(tlv_tree
, hf_fefd_tlvtype
, tvb
,
216 offset
+ TLV_TYPE
, 2, type
);
217 proto_tree_add_uint(tlv_tree
, hf_fefd_tlvlength
, tvb
,
218 offset
+ TLV_LENGTH
, 2, length
);
220 proto_tree_add_text(tlv_tree
, tvb
, offset
+ 4,
229 call_dissector(data_handle
, tvb_new_subset_remaining(tvb
, offset
), pinfo
, fefd_tree
);
233 proto_register_fefd(void)
235 static hf_register_info hf
[] = {
237 { "Version", "fefd.version", FT_UINT8
, BASE_DEC
, NULL
, 0xE0,
241 { "Opcode", "fefd.opcode", FT_UINT8
, BASE_DEC
, VALS(opcode_vals
), 0x1F,
245 { "Flags", "fefd.flags", FT_UINT8
, BASE_HEX
, NULL
, 0x0,
249 { "Recommended timeout", "fefd.flags.rt", FT_BOOLEAN
, 8, NULL
, 0x80,
252 { &hf_fefd_flags_rsy
,
253 { "ReSynch", "fefd.flags.rsy", FT_BOOLEAN
, 8, NULL
, 0x40,
257 { "Checksum", "fefd.checksum", FT_UINT16
, BASE_HEX
, NULL
, 0x0,
261 { "Type", "fefd.tlv.type", FT_UINT16
, BASE_HEX
, VALS(type_vals
), 0x0,
264 { &hf_fefd_tlvlength
,
265 { "Length", "fefd.tlv.len", FT_UINT16
, BASE_DEC
, NULL
, 0x0,
268 static gint
*ett
[] = {
274 proto_fefd
= proto_register_protocol("Far End Failure Detection", "FEFD", "fefd");
275 proto_register_field_array(proto_fefd
, hf
, array_length(hf
));
276 proto_register_subtree_array(ett
, array_length(ett
));
280 proto_reg_handoff_fefd(void)
282 dissector_handle_t fefd_handle
;
284 data_handle
= find_dissector("data");
285 fefd_handle
= create_dissector_handle(dissect_fefd
, proto_fefd
);
286 dissector_add_uint("llc.force10_pid", 0x0111, fefd_handle
);