2 * Routines for the disassembly of the "Far End Failure Detection"
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * Copied from packet-udld.c
10 * SPDX-License-Identifier: GPL-2.0-or-later
15 #include <epan/packet.h>
18 void proto_register_fefd(void);
19 void proto_reg_handoff_fefd(void);
21 static dissector_handle_t fefd_handle
;
23 /* Offsets in TLV structure. */
27 static int proto_fefd
;
28 static int hf_fefd_version
;
29 static int hf_fefd_opcode
;
30 static int hf_fefd_flags
;
31 static int hf_fefd_flags_rt
;
32 static int hf_fefd_flags_rsy
;
33 static int hf_fefd_checksum
;
34 static int hf_fefd_tlvtype
;
35 static int hf_fefd_tlvlength
;
36 static int hf_fefd_device_id
;
37 static int hf_fefd_sent_through_interface
;
38 static int hf_fefd_data
;
41 static int ett_fefd_flags
;
42 static int ett_fefd_tlv
;
44 #define TYPE_DEVICE_ID 0x0001
45 #define TYPE_PORT_ID 0x0002
46 #define TYPE_ECHO 0x0003
47 #define TYPE_MESSAGE_INTERVAL 0x0004
48 #define TYPE_TIMEOUT_INTERVAL 0x0005
49 #define TYPE_DEVICE_NAME 0x0006
50 #define TYPE_SEQUENCE_NUMBER 0x0007
53 static const value_string type_vals
[] = {
54 { TYPE_DEVICE_ID
, "Device ID" },
55 { TYPE_PORT_ID
, "Port ID" },
56 { TYPE_ECHO
, "Echo" },
57 { TYPE_MESSAGE_INTERVAL
, "Message interval" },
58 { TYPE_TIMEOUT_INTERVAL
, "Timeout interval" },
59 { TYPE_DEVICE_NAME
, "Device name" },
60 { TYPE_SEQUENCE_NUMBER
, "Sequence number" },
64 #define OPCODE_RESERVED 0x00
65 #define OPCODE_PROBE 0x01
66 #define OPCODE_ECHO 0x02
67 #define OPCODE_FLUSH 0x03
69 static const value_string opcode_vals
[] = {
70 { OPCODE_RESERVED
, "Reserved" },
71 { OPCODE_PROBE
, "Probe" },
72 { OPCODE_ECHO
, "Echo" },
73 { OPCODE_FLUSH
, "Flush" },
78 dissect_fefd(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
81 proto_tree
*fefd_tree
= NULL
;
87 static int * const flags
[] = {
92 static int * const headers
[] = {
98 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "FEFD");
99 col_clear(pinfo
->cinfo
, COL_INFO
);
101 ti
= proto_tree_add_item(tree
, proto_fefd
, tvb
, offset
, -1, ENC_NA
);
102 fefd_tree
= proto_item_add_subtree(ti
, ett_fefd
);
105 proto_tree_add_bitmask_list(fefd_tree
, tvb
, offset
, 1, headers
, ENC_BIG_ENDIAN
);
107 proto_tree_add_bitmask(fefd_tree
, tvb
, offset
, hf_fefd_flags
, ett_fefd_flags
, flags
, ENC_BIG_ENDIAN
);
109 proto_tree_add_checksum(fefd_tree
, tvb
, offset
, hf_fefd_checksum
, -1, NULL
, pinfo
, 0, ENC_BIG_ENDIAN
, PROTO_CHECKSUM_NO_FLAGS
);
112 while (tvb_reported_length_remaining(tvb
, offset
) != 0) {
113 type
= tvb_get_ntohs(tvb
, offset
+ TLV_TYPE
);
114 length
= tvb_get_ntohs(tvb
, offset
+ TLV_LENGTH
);
117 tlv_tree
= proto_tree_add_subtree_format(fefd_tree
, tvb
, offset
, 4, /* XXX - expert info? */
118 ett_fefd_tlv
, NULL
, "TLV with invalid length %u (< 4)",
120 proto_tree_add_uint(tlv_tree
, hf_fefd_tlvtype
, tvb
,
121 offset
+ TLV_TYPE
, 2, type
);
122 proto_tree_add_uint(tlv_tree
, hf_fefd_tlvlength
, tvb
,
123 offset
+ TLV_LENGTH
, 2, length
);
134 col_append_sep_fstr(pinfo
->cinfo
, COL_INFO
, NULL
,
136 tvb_format_stringzpad(pinfo
->pool
, tvb
, offset
+ 4,
140 tlv_tree
= proto_tree_add_subtree_format(fefd_tree
, tvb
, offset
,
141 length
, ett_fefd_tlv
, NULL
, "Device ID: %s",
142 tvb_format_stringzpad(pinfo
->pool
, tvb
, offset
+ 4, length
- 4));
143 proto_tree_add_uint(tlv_tree
, hf_fefd_tlvtype
, tvb
,
144 offset
+ TLV_TYPE
, 2, type
);
145 proto_tree_add_uint(tlv_tree
, hf_fefd_tlvlength
, tvb
,
146 offset
+ TLV_LENGTH
, 2, length
);
147 proto_tree_add_item(tlv_tree
, hf_fefd_device_id
, tvb
, offset
+ 4,
148 length
- 4, ENC_NA
|ENC_ASCII
);
154 real_length
= length
;
155 if (tvb_get_uint8(tvb
, offset
+ real_length
) != 0x00) {
156 /* The length in the TLV doesn't appear to be the
157 length of the TLV, as the byte just past it
158 isn't the first byte of a 2-byte big-endian
159 small integer; make the length of the TLV the length
160 in the TLV, plus 4 bytes for the TLV type and length,
161 minus 1 because that's what makes one capture work. */
162 real_length
= length
+ 3;
165 col_append_sep_fstr(pinfo
->cinfo
, COL_INFO
, NULL
,
167 tvb_format_stringzpad(pinfo
->pool
, tvb
, offset
+ 4, real_length
- 4));
170 tlv_tree
= proto_tree_add_subtree_format(fefd_tree
, tvb
, offset
,
171 real_length
, ett_fefd_tlv
, NULL
, "Port ID: %s",
172 tvb_format_text(pinfo
->pool
, tvb
, offset
+ 4, real_length
- 4));
173 proto_tree_add_uint(tlv_tree
, hf_fefd_tlvtype
, tvb
,
174 offset
+ TLV_TYPE
, 2, type
);
175 proto_tree_add_uint(tlv_tree
, hf_fefd_tlvlength
, tvb
,
176 offset
+ TLV_LENGTH
, 2, length
);
177 proto_tree_add_item(tlv_tree
, hf_fefd_sent_through_interface
, tvb
, offset
+ 4,
178 real_length
- 4, ENC_NA
|ENC_ASCII
);
180 offset
+= real_length
;
184 case TYPE_MESSAGE_INTERVAL
:
185 case TYPE_TIMEOUT_INTERVAL
:
186 case TYPE_DEVICE_NAME
:
187 case TYPE_SEQUENCE_NUMBER
:
189 tlv_tree
= proto_tree_add_subtree_format(fefd_tree
, tvb
, offset
,
190 length
, ett_fefd_tlv
, NULL
, "Type: %s, length: %u",
191 val_to_str(type
, type_vals
, "Unknown (0x%04x)"),
193 proto_tree_add_uint(tlv_tree
, hf_fefd_tlvtype
, tvb
,
194 offset
+ TLV_TYPE
, 2, type
);
195 proto_tree_add_uint(tlv_tree
, hf_fefd_tlvlength
, tvb
,
196 offset
+ TLV_LENGTH
, 2, length
);
198 proto_tree_add_item(tlv_tree
, hf_fefd_data
, tvb
, offset
+ 4,
201 return tvb_captured_length(tvb
);
207 call_data_dissector(tvb_new_subset_remaining(tvb
, offset
), pinfo
, fefd_tree
);
208 return tvb_captured_length(tvb
);
212 proto_register_fefd(void)
214 static hf_register_info hf
[] = {
216 { "Version", "fefd.version", FT_UINT8
, BASE_DEC
, NULL
, 0xE0,
220 { "Opcode", "fefd.opcode", FT_UINT8
, BASE_DEC
, VALS(opcode_vals
), 0x1F,
224 { "Flags", "fefd.flags", FT_UINT8
, BASE_HEX
, NULL
, 0x0,
228 { "Recommended timeout", "fefd.flags.rt", FT_BOOLEAN
, 8, NULL
, 0x80,
231 { &hf_fefd_flags_rsy
,
232 { "ReSynch", "fefd.flags.rsy", FT_BOOLEAN
, 8, NULL
, 0x40,
236 { "Checksum", "fefd.checksum", FT_UINT16
, BASE_HEX
, NULL
, 0x0,
240 { "Type", "fefd.tlv.type", FT_UINT16
, BASE_HEX
, VALS(type_vals
), 0x0,
243 { &hf_fefd_tlvlength
,
244 { "Length", "fefd.tlv.len", FT_UINT16
, BASE_DEC
, NULL
, 0x0,
247 { &hf_fefd_device_id
,
248 { "Device ID", "fefd.device_id", FT_STRINGZ
, BASE_NONE
, NULL
, 0x0,
251 { &hf_fefd_sent_through_interface
,
252 { "Sent through Interface", "fefd.sent_through_interface", FT_STRING
, BASE_NONE
, NULL
, 0x0,
256 { "Data", "fefd.data", FT_BYTES
, BASE_NONE
, NULL
, 0x0,
260 static int *ett
[] = {
266 proto_fefd
= proto_register_protocol("Far End Failure Detection", "FEFD", "fefd");
267 proto_register_field_array(proto_fefd
, hf
, array_length(hf
));
268 proto_register_subtree_array(ett
, array_length(ett
));
270 fefd_handle
= register_dissector("fefd", dissect_fefd
, proto_fefd
);
274 proto_reg_handoff_fefd(void)
276 dissector_add_uint("llc.force10_pid", 0x0111, fefd_handle
);
280 * Editor modelines - https://www.wireshark.org/tools/modelines.html
285 * indent-tabs-mode: nil
288 * vi: set shiftwidth=4 tabstop=8 expandtab:
289 * :indentSize=4:tabSize=8:noTabs=true: