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 int proto_loop = -1;
32 static int hf_loop_skipcount = -1;
33 static int hf_loop_function = -1;
34 static int hf_loop_relevant_function = -1;
35 static int hf_loop_receipt_number = -1;
36 static int hf_loop_forwarding_address = -1;
38 static gint ett_loop = -1;
41 #define FUNC_FORWARD_DATA 2
43 static const value_string function_vals[] = {
44 { FUNC_REPLY, "Reply" },
45 { FUNC_FORWARD_DATA, "Forward Data" },
50 dissect_loop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
52 proto_tree *loop_tree = NULL;
57 gboolean set_info = TRUE;
58 gboolean more_function;
61 col_set_str(pinfo->cinfo, COL_PROTOCOL, "LOOP");
62 col_clear(pinfo->cinfo, COL_INFO);
65 ti = proto_tree_add_item(tree, proto_loop, tvb, offset, -1, ENC_NA);
66 loop_tree = proto_item_add_subtree(ti, ett_loop);
68 proto_tree_add_item(loop_tree, hf_loop_skipcount, tvb, offset, 2, ENC_LITTLE_ENDIAN);
70 skip_offset = 2 + tvb_get_letohs(tvb, offset);
74 function = tvb_get_letohs(tvb, offset);
75 if (offset == skip_offset) {
76 col_add_str(pinfo->cinfo, COL_INFO,
77 val_to_str(function, function_vals, "Unknown function (%u)"));
79 proto_tree_add_uint(loop_tree, hf_loop_relevant_function, tvb, offset, 2, function);
82 proto_tree_add_uint(loop_tree, hf_loop_function, tvb, offset, 2, function);
87 proto_tree_add_item(loop_tree, hf_loop_receipt_number, tvb, offset, 2,
90 more_function = FALSE;
93 case FUNC_FORWARD_DATA:
94 proto_tree_add_item(loop_tree, hf_loop_forwarding_address, tvb, offset,
101 more_function = FALSE;
104 } while (more_function);
107 col_set_str(pinfo->cinfo, COL_INFO, "No valid function found");
110 if (tvb_reported_length_remaining(tvb, offset) > 0)
112 next_tvb = tvb_new_subset_remaining(tvb, offset);
113 call_data_dissector(next_tvb, pinfo, tree);
115 return tvb_captured_length(tvb);
119 proto_register_loop(void)
121 static hf_register_info hf[] = {
122 { &hf_loop_skipcount,
123 { "skipCount", "loop.skipcount",
124 FT_UINT16, BASE_DEC, NULL, 0x0,
128 { "Function", "loop.function",
129 FT_UINT16, BASE_DEC, VALS(function_vals), 0x0,
132 { &hf_loop_relevant_function,
133 { "Relevant function", "loop.relevant_function",
134 FT_UINT16, BASE_DEC, VALS(function_vals), 0x0,
137 { &hf_loop_receipt_number,
138 { "Receipt number", "loop.receipt_number",
139 FT_UINT16, BASE_DEC, NULL, 0x0,
142 { &hf_loop_forwarding_address,
143 { "Forwarding address", "loop.forwarding_address",
144 FT_ETHER, BASE_NONE, NULL, 0x0,
147 static gint *ett[] = {
151 proto_loop = proto_register_protocol("Configuration Test Protocol (loopback)",
153 proto_register_field_array(proto_loop, hf, array_length(hf));
154 proto_register_subtree_array(ett, array_length(ett));
158 proto_reg_handoff_loop(void)
160 dissector_handle_t loop_handle;
162 loop_handle = create_dissector_handle(dissect_loop, proto_loop);
164 dissector_add_uint("ethertype", ETHERTYPE_LOOP, loop_handle);
168 * Editor modelines - http://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: