aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2004-09-23 18:48:11 +0000
committerGuy Harris <guy@alum.mit.edu>2004-09-23 18:48:11 +0000
commit7126c58e561f84a2a02c573b9d0903c06ff84283 (patch)
treedf544845320efac0170e40057c238e121cccaf58
parent29753bf6b2576c71421ae8d9c3e1ac50af8e8873 (diff)
Add support for the Ethernet Configuration Testing Protocol.
svn path=/trunk/; revision=12074
-rw-r--r--epan/dissectors/Makefile.common1
-rw-r--r--epan/dissectors/packet-ethertype.c17
-rw-r--r--epan/dissectors/packet-loop.c145
3 files changed, 149 insertions, 14 deletions
diff --git a/epan/dissectors/Makefile.common b/epan/dissectors/Makefile.common
index 3b2d95c6ad..4e35af4b51 100644
--- a/epan/dissectors/Makefile.common
+++ b/epan/dissectors/Makefile.common
@@ -317,6 +317,7 @@ DISSECTOR_SRC = \
packet-llc.c \
packet-lmi.c \
packet-lmp.c \
+ packet-loop.c \
packet-lpd.c \
packet-lwapp.c \
packet-m2pa.c \
diff --git a/epan/dissectors/packet-ethertype.c b/epan/dissectors/packet-ethertype.c
index f1219e25a5..520ed84b8c 100644
--- a/epan/dissectors/packet-ethertype.c
+++ b/epan/dissectors/packet-ethertype.c
@@ -217,20 +217,9 @@ ethertype(guint16 etype, tvbuff_t *tvb, int offset_after_etype,
call_dissector(data_handle,next_tvb, pinfo, tree);
/* Label protocol */
- switch (etype) {
-
- case ETHERTYPE_LOOP:
- if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
- col_add_fstr(pinfo->cinfo, COL_PROTOCOL, "LOOP");
- }
- break;
-
- default:
- if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
- col_add_fstr(pinfo->cinfo, COL_PROTOCOL, "0x%04x",
- etype);
- }
- break;
+ if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
+ col_add_fstr(pinfo->cinfo, COL_PROTOCOL, "0x%04x",
+ etype);
}
if (check_col(pinfo->cinfo, COL_INFO)) {
description = match_strval(etype, etype_vals);
diff --git a/epan/dissectors/packet-loop.c b/epan/dissectors/packet-loop.c
new file mode 100644
index 0000000000..3403b7cc90
--- /dev/null
+++ b/epan/dissectors/packet-loop.c
@@ -0,0 +1,145 @@
+/* packet-loop.c
+ * Routines for Ethernet loopback/Configuration Test Protocol dissection
+ *
+ * See
+ *
+ * http://stuff.mit.edu/people/jhawk/ctp.html
+ *
+ * $Id$
+ *
+ * Ethereal - Network traffic analyzer
+ * By Gerald Combs <gerald@ethereal.com>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <glib.h>
+#include <epan/packet.h>
+#include "etypes.h"
+
+static int proto_loop = -1;
+static int hf_loop_skipcount = -1;
+static int hf_loop_function = -1;
+static int hf_loop_forwarding_address = -1;
+
+static gint ett_loop = -1;
+
+static dissector_handle_t data_handle;
+
+#define FUNC_REPLY 1
+#define FUNC_FORWARD_DATA 2
+
+static const value_string function_vals[] = {
+ { FUNC_REPLY, "Reply" },
+ { FUNC_FORWARD_DATA, "Forward Data" },
+ { 0, NULL }
+};
+
+static void
+dissect_loop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+ proto_tree *loop_tree = NULL;
+ proto_item *ti;
+ guint16 function;
+ int offset = 0;
+ gboolean set_info = FALSE;
+ tvbuff_t *next_tvb;
+
+ if (check_col(pinfo->cinfo, COL_PROTOCOL))
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "LOOP");
+ if (check_col(pinfo->cinfo, COL_INFO))
+ col_clear(pinfo->cinfo, COL_INFO);
+
+ if (tree) {
+ ti = proto_tree_add_item(tree, proto_loop, tvb, 0, -1, FALSE);
+ loop_tree = proto_item_add_subtree(ti, ett_loop);
+ }
+
+ for (;;) {
+ if (tree)
+ proto_tree_add_item(loop_tree, hf_loop_skipcount, tvb, offset, 2, FALSE);
+ offset += 2;
+ function = tvb_get_ntohs(tvb, 2);
+ if (!set_info) {
+ if (check_col(pinfo->cinfo, COL_INFO)) {
+ col_add_str(pinfo->cinfo, COL_INFO,
+ val_to_str(function, function_vals, "Unknown function (%u)"));
+ }
+ set_info = TRUE;
+ }
+ if (tree)
+ proto_tree_add_uint(loop_tree, hf_loop_function, tvb, offset, 2, function);
+ offset += 2;
+ switch (function) {
+
+ case FUNC_REPLY:
+ default:
+ next_tvb = tvb_new_subset(tvb, 4, -1, -1);
+ call_dissector(data_handle, next_tvb, pinfo, tree);
+ return;
+
+ case FUNC_FORWARD_DATA:
+ if (tree)
+ proto_tree_add_item(loop_tree, hf_loop_forwarding_address, tvb, offset,
+ 6, FALSE);
+ offset += 6;
+ break;
+ }
+ }
+}
+
+void
+proto_register_loop(void)
+{
+ static hf_register_info hf[] = {
+ { &hf_loop_skipcount,
+ { "skipCount", "loop.skipcount",
+ FT_UINT16, BASE_DEC, NULL, 0x0,
+ "", HFILL }},
+
+ { &hf_loop_function,
+ { "function", "loop.function",
+ FT_UINT16, BASE_DEC, VALS(function_vals), 0x0,
+ "", HFILL }},
+
+ { &hf_loop_forwarding_address,
+ { "Forwarding address", "loop.forwarding_address",
+ FT_ETHER, BASE_NONE, NULL, 0x0,
+ "", HFILL }},
+ };
+ static gint *ett[] = {
+ &ett_loop,
+ };
+
+ proto_loop = proto_register_protocol("Configuration Test Protocol (loopback)",
+ "LOOP", "loop");
+ proto_register_field_array(proto_loop, hf, array_length(hf));
+ proto_register_subtree_array(ett, array_length(ett));
+}
+
+void
+proto_reg_handoff_loop(void)
+{
+ dissector_handle_t loop_handle;
+
+ loop_handle = create_dissector_handle(dissect_loop, proto_loop);
+
+ dissector_add("ethertype", ETHERTYPE_LOOP, loop_handle);
+}