2 * Routines for Ethernet loopback/Configuration Test Protocol dissection,
3 * as documented in section 8 "Ethernet Configuration Testing Protocol" of
4 * the v2.0 DIX Ethernet specification.
8 * http://decnet.ipv7.net/docs/dundas/aa-k759b-tk.pdf
10 * for a copy of the DIX spec and
12 * http://stuff.mit.edu/people/jhawk/ctp.html
16 * Wireshark - Network traffic analyzer
17 * By Gerald Combs <gerald@wireshark.org>
18 * Copyright 1998 Gerald Combs
20 * SPDX-License-Identifier: GPL-2.0-or-later
25 #include <epan/packet.h>
26 #include <epan/etypes.h>
28 void proto_register_loop(void);
29 void proto_reg_handoff_loop(void);
31 static dissector_handle_t loop_handle
;
33 static int proto_loop
;
34 static int hf_loop_skipcount
;
35 static int hf_loop_function
;
36 static int hf_loop_relevant_function
;
37 static int hf_loop_receipt_number
;
38 static int hf_loop_forwarding_address
;
43 #define FUNC_FORWARD_DATA 2
45 static const value_string function_vals
[] = {
46 { FUNC_REPLY
, "Reply" },
47 { FUNC_FORWARD_DATA
, "Forward Data" },
52 dissect_loop(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
54 proto_tree
*loop_tree
= NULL
;
63 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "LOOP");
64 col_clear(pinfo
->cinfo
, COL_INFO
);
67 ti
= proto_tree_add_item(tree
, proto_loop
, tvb
, offset
, -1, ENC_NA
);
68 loop_tree
= proto_item_add_subtree(ti
, ett_loop
);
70 proto_tree_add_item(loop_tree
, hf_loop_skipcount
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
72 skip_offset
= 2 + tvb_get_letohs(tvb
, offset
);
76 function
= tvb_get_letohs(tvb
, offset
);
77 if (offset
== skip_offset
) {
78 col_add_str(pinfo
->cinfo
, COL_INFO
,
79 val_to_str(function
, function_vals
, "Unknown function (%u)"));
81 proto_tree_add_uint(loop_tree
, hf_loop_relevant_function
, tvb
, offset
, 2, function
);
84 proto_tree_add_uint(loop_tree
, hf_loop_function
, tvb
, offset
, 2, function
);
89 proto_tree_add_item(loop_tree
, hf_loop_receipt_number
, tvb
, offset
, 2,
92 more_function
= false;
95 case FUNC_FORWARD_DATA
:
96 proto_tree_add_item(loop_tree
, hf_loop_forwarding_address
, tvb
, offset
,
103 more_function
= false;
106 } while (more_function
);
109 col_set_str(pinfo
->cinfo
, COL_INFO
, "No valid function found");
112 if (tvb_reported_length_remaining(tvb
, offset
) > 0)
114 next_tvb
= tvb_new_subset_remaining(tvb
, offset
);
115 call_data_dissector(next_tvb
, pinfo
, tree
);
117 return tvb_captured_length(tvb
);
121 proto_register_loop(void)
123 static hf_register_info hf
[] = {
124 { &hf_loop_skipcount
,
125 { "skipCount", "loop.skipcount",
126 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
130 { "Function", "loop.function",
131 FT_UINT16
, BASE_DEC
, VALS(function_vals
), 0x0,
134 { &hf_loop_relevant_function
,
135 { "Relevant function", "loop.relevant_function",
136 FT_UINT16
, BASE_DEC
, VALS(function_vals
), 0x0,
139 { &hf_loop_receipt_number
,
140 { "Receipt number", "loop.receipt_number",
141 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
144 { &hf_loop_forwarding_address
,
145 { "Forwarding address", "loop.forwarding_address",
146 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
149 static int *ett
[] = {
153 proto_loop
= proto_register_protocol("Configuration Test Protocol (loopback)",
155 proto_register_field_array(proto_loop
, hf
, array_length(hf
));
156 proto_register_subtree_array(ett
, array_length(ett
));
158 loop_handle
= register_dissector("loop", dissect_loop
, proto_loop
);
162 proto_reg_handoff_loop(void)
164 dissector_add_uint("ethertype", ETHERTYPE_LOOP
, loop_handle
);
168 * Editor modelines - https://www.wireshark.org/tools/modelines.html
173 * indent-tabs-mode: nil
176 * ex: set shiftwidth=2 tabstop=8 expandtab:
177 * :indentSize=2:tabSize=8:noTabs=true: