aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-idp.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2005-03-03 08:34:48 +0000
committerGuy Harris <guy@alum.mit.edu>2005-03-03 08:34:48 +0000
commit282080e26de2f202a2a140f4424bbceac3239d48 (patch)
treebf9a054969ce499e3ef8a9906531955a4852ff49 /epan/dissectors/packet-idp.c
parent2e28b1b828f259ad37d64b82ea209080c4e3896a (diff)
Add support for what appears to be 3Com's scheme for encapsulating XNS
over Token Ring (and presumably other link layers using 802.2 LLC), and for the XNS IDP and SPP protocols. svn path=/trunk/; revision=13577
Diffstat (limited to 'epan/dissectors/packet-idp.c')
-rw-r--r--epan/dissectors/packet-idp.c212
1 files changed, 212 insertions, 0 deletions
diff --git a/epan/dissectors/packet-idp.c b/epan/dissectors/packet-idp.c
new file mode 100644
index 0000000000..ef150c89a9
--- /dev/null
+++ b/epan/dissectors/packet-idp.c
@@ -0,0 +1,212 @@
+/* packet-idp.c
+ * Routines for XNS IDP
+ * Based on the Netware IPX dissector by Gilbert Ramirez <gram@alumni.rice.edu>
+ *
+ * $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 "packet-idp.h"
+#include "etypes.h"
+
+static int proto_idp = -1;
+static int hf_idp_checksum = -1;
+static int hf_idp_len = -1;
+static int hf_idp_src = -1;
+static int hf_idp_dst = -1;
+static int hf_idp_hops = -1;
+static int hf_idp_packet_type = -1;
+static int hf_idp_dnet = -1;
+static int hf_idp_dnode = -1;
+static int hf_idp_dsocket = -1;
+static int hf_idp_snet = -1;
+static int hf_idp_snode = -1;
+static int hf_idp_ssocket = -1;
+
+static gint ett_idp = -1;
+
+static dissector_handle_t data_handle;
+
+static dissector_table_t idp_type_dissector_table;
+
+/*
+ * See
+ *
+ * "Internet Transport Protocols", XSIS 028112, December 1981
+ *
+ * if you can find it; this is based on the headers in the BSD XNS
+ * implementation.
+ */
+
+#define IDP_HEADER_LEN 30 /* It's *always* 30 bytes */
+
+static const value_string idp_packet_type_vals[] = {
+ { IDP_PACKET_TYPE_RIP, "RIP" },
+ { IDP_PACKET_TYPE_ECHO, "Echo" },
+ { IDP_PACKET_TYPE_ERROR, "Error" },
+ { IDP_PACKET_TYPE_PEP, "PEP" },
+ { IDP_PACKET_TYPE_SPP, "SPP" },
+ { 0, NULL }
+};
+
+static const value_string idp_socket_vals[] = {
+ { IDP_SOCKET_SMB, "SMB" },
+ { 0, NULL }
+};
+
+static void
+dissect_idp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+ proto_tree *idp_tree = NULL;
+ proto_item *ti = NULL;
+ guint16 length;
+ guint8 type;
+ tvbuff_t *next_tvb;
+
+ if (check_col(pinfo->cinfo, COL_PROTOCOL))
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "IDP");
+ if (check_col(pinfo->cinfo, COL_INFO))
+ col_clear(pinfo->cinfo, COL_INFO);
+
+ if (check_col(pinfo->cinfo, COL_INFO))
+ col_clear(pinfo->cinfo, COL_INFO);
+
+ if (tree) {
+ ti = proto_tree_add_item(tree, proto_idp, tvb, 0, IDP_HEADER_LEN, FALSE);
+ idp_tree = proto_item_add_subtree(ti, ett_idp);
+ }
+
+ proto_tree_add_item(idp_tree, hf_idp_checksum, tvb, 0, 2, FALSE);
+ length = tvb_get_ntohs(tvb, 2);
+ proto_tree_add_uint_format(idp_tree, hf_idp_len, tvb, 2, 2, length,
+ "Length: %u bytes", length);
+ /* Adjust the tvbuff length to include only the IDP datagram. */
+ set_actual_length(tvb, length);
+ proto_tree_add_item(idp_tree, hf_idp_hops, tvb, 4, 1, FALSE);
+ type = tvb_get_guint8(tvb, 5);
+ proto_tree_add_uint(idp_tree, hf_idp_packet_type, tvb, 5, 1, type);
+
+ /* Destination */
+ proto_tree_add_item(idp_tree, hf_idp_dnet, tvb, 6, 4, FALSE);
+ proto_tree_add_item(idp_tree, hf_idp_dnode, tvb, 10, 6, FALSE);
+ proto_tree_add_item(idp_tree, hf_idp_dsocket, tvb, 16, 2, FALSE);
+
+ /* Source */
+ proto_tree_add_item(idp_tree, hf_idp_snet, tvb, 18, 4, FALSE);
+ proto_tree_add_item(idp_tree, hf_idp_snode, tvb, 22, 6, FALSE);
+ proto_tree_add_item(idp_tree, hf_idp_ssocket, tvb, 28, 2, FALSE);
+
+ /* Make the next tvbuff */
+ next_tvb = tvb_new_subset(tvb, IDP_HEADER_LEN, -1, -1);
+
+ /*
+ * Hand off to the dissector for the packet type.
+ */
+ if (dissector_try_port(idp_type_dissector_table, type, next_tvb,
+ pinfo, tree))
+ return;
+
+ call_dissector(data_handle, next_tvb, pinfo, tree);
+}
+
+void
+proto_register_idp(void)
+{
+ static hf_register_info hf_idp[] = {
+ { &hf_idp_checksum,
+ { "Checksum", "idp.checksum", FT_UINT16, BASE_HEX,
+ NULL, 0x0, "", HFILL }},
+
+ { &hf_idp_src,
+ { "Source Address", "idp.src", FT_STRING, BASE_DEC,
+ NULL, 0x0, "Source Address", HFILL }},
+
+ { &hf_idp_dst,
+ { "Destination Address", "idp.dst", FT_STRING, BASE_DEC,
+ NULL, 0x0, "Destination Address", HFILL }},
+
+ { &hf_idp_len,
+ { "Length", "idp.len", FT_UINT16, BASE_DEC,
+ NULL, 0x0, "", HFILL }},
+
+ /* XXX - does this have separate hop count and time subfields? */
+ { &hf_idp_hops,
+ { "Transport Control (Hops)", "idp.hops", FT_UINT8, BASE_DEC,
+ NULL, 0x0, "", HFILL }},
+
+ { &hf_idp_packet_type,
+ { "Packet Type", "idp.packet_type", FT_UINT8, BASE_DEC,
+ VALS(idp_packet_type_vals), 0x0, "", HFILL }},
+
+ { &hf_idp_dnet,
+ { "Destination Network","idp.dst.net", FT_UINT32, BASE_HEX,
+ NULL, 0x0, "", HFILL }},
+
+ { &hf_idp_dnode,
+ { "Destination Node", "idp.dst.node", FT_ETHER, BASE_NONE,
+ NULL, 0x0, "", HFILL }},
+
+ { &hf_idp_dsocket,
+ { "Destination Socket", "idp.dst.socket", FT_UINT16, BASE_HEX,
+ VALS(idp_socket_vals), 0x0, "", HFILL }},
+
+ { &hf_idp_snet,
+ { "Source Network","idp.src.net", FT_UINT32, BASE_HEX,
+ NULL, 0x0, "", HFILL }},
+
+ { &hf_idp_snode,
+ { "Source Node", "idp.src.node", FT_ETHER, BASE_NONE,
+ NULL, 0x0, "", HFILL }},
+
+ { &hf_idp_ssocket,
+ { "Source Socket", "idp.src.socket", FT_UINT16, BASE_HEX,
+ VALS(idp_socket_vals), 0x0, "", HFILL }},
+ };
+
+ static gint *ett[] = {
+ &ett_idp,
+ };
+
+ proto_idp = proto_register_protocol("Internetwork Datagram Protocol",
+ "IDP", "idp");
+ proto_register_field_array(proto_idp, hf_idp, array_length(hf_idp));
+ proto_register_subtree_array(ett, array_length(ett));
+
+ idp_type_dissector_table = register_dissector_table("idp.packet_type",
+ "IDP packet type", FT_UINT8, BASE_DEC);
+}
+
+void
+proto_reg_handoff_idp(void)
+{
+ dissector_handle_t idp_handle;
+
+ idp_handle = create_dissector_handle(dissect_idp, proto_idp);
+ dissector_add("ethertype", ETHERTYPE_XNS_IDP, idp_handle);
+ dissector_add("chdlctype", ETHERTYPE_XNS_IDP, idp_handle);
+
+ data_handle = find_dissector("data");
+}