2005-03-03 08:34:48 +00:00
|
|
|
/* packet-idp.c
|
|
|
|
* Routines for XNS IDP
|
|
|
|
* Based on the Netware IPX dissector by Gilbert Ramirez <gram@alumni.rice.edu>
|
|
|
|
*
|
2006-05-21 04:49:01 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2005-03-03 08:34:48 +00:00
|
|
|
* 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
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2005-03-03 08:34:48 +00:00
|
|
|
*/
|
|
|
|
|
2012-09-20 02:03:38 +00:00
|
|
|
#include "config.h"
|
2005-03-03 08:34:48 +00:00
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include <epan/packet.h>
|
|
|
|
#include "packet-idp.h"
|
2005-09-17 00:02:31 +00:00
|
|
|
#include <epan/etypes.h>
|
2005-03-03 08:34:48 +00:00
|
|
|
|
2013-12-14 12:45:57 +00:00
|
|
|
void proto_register_idp(void);
|
|
|
|
void proto_reg_handoff_idp(void);
|
|
|
|
|
2005-03-03 08:34:48 +00:00
|
|
|
static int proto_idp = -1;
|
|
|
|
static int hf_idp_checksum = -1;
|
|
|
|
static int hf_idp_len = -1;
|
2013-01-31 17:55:31 +00:00
|
|
|
/* static int hf_idp_src = -1; */
|
|
|
|
/* static int hf_idp_dst = -1; */
|
2005-03-03 08:34:48 +00:00
|
|
|
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;
|
2011-10-20 14:07:54 +00:00
|
|
|
|
2009-08-09 06:26:46 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "IDP");
|
2009-08-09 07:36:13 +00:00
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
2005-03-03 08:34:48 +00:00
|
|
|
|
|
|
|
if (tree) {
|
2011-10-21 02:10:19 +00:00
|
|
|
ti = proto_tree_add_item(tree, proto_idp, tvb, 0, IDP_HEADER_LEN, ENC_NA);
|
2005-03-03 08:34:48 +00:00
|
|
|
idp_tree = proto_item_add_subtree(ti, ett_idp);
|
|
|
|
}
|
|
|
|
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(idp_tree, hf_idp_checksum, tvb, 0, 2, ENC_BIG_ENDIAN);
|
2005-03-03 08:34:48 +00:00
|
|
|
length = tvb_get_ntohs(tvb, 2);
|
2013-09-15 01:48:30 +00:00
|
|
|
proto_tree_add_uint_format_value(idp_tree, hf_idp_len, tvb, 2, 2, length,
|
|
|
|
"%u bytes", length);
|
2005-03-03 08:34:48 +00:00
|
|
|
/* Adjust the tvbuff length to include only the IDP datagram. */
|
|
|
|
set_actual_length(tvb, length);
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(idp_tree, hf_idp_hops, tvb, 4, 1, ENC_BIG_ENDIAN);
|
2005-03-03 08:34:48 +00:00
|
|
|
type = tvb_get_guint8(tvb, 5);
|
|
|
|
proto_tree_add_uint(idp_tree, hf_idp_packet_type, tvb, 5, 1, type);
|
|
|
|
|
2005-03-06 20:13:58 +00:00
|
|
|
pinfo->ptype = PT_IDP;
|
|
|
|
|
2005-03-03 08:34:48 +00:00
|
|
|
/* Destination */
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(idp_tree, hf_idp_dnet, tvb, 6, 4, ENC_BIG_ENDIAN);
|
2011-10-20 14:07:54 +00:00
|
|
|
proto_tree_add_item(idp_tree, hf_idp_dnode, tvb, 10, 6, ENC_NA);
|
2005-03-06 20:13:58 +00:00
|
|
|
pinfo->destport = tvb_get_ntohs(tvb, 16);
|
|
|
|
proto_tree_add_uint(idp_tree, hf_idp_dsocket, tvb, 16, 2,
|
|
|
|
pinfo->destport);
|
2005-03-03 08:34:48 +00:00
|
|
|
|
|
|
|
/* Source */
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(idp_tree, hf_idp_snet, tvb, 18, 4, ENC_BIG_ENDIAN);
|
2011-10-20 14:07:54 +00:00
|
|
|
proto_tree_add_item(idp_tree, hf_idp_snode, tvb, 22, 6, ENC_NA);
|
2005-03-06 20:13:58 +00:00
|
|
|
pinfo->srcport = tvb_get_ntohs(tvb, 28);
|
|
|
|
proto_tree_add_uint(idp_tree, hf_idp_ssocket, tvb, 28, 2,
|
|
|
|
pinfo->srcport);
|
2005-03-03 08:34:48 +00:00
|
|
|
|
|
|
|
/* Make the next tvbuff */
|
2009-08-16 12:36:22 +00:00
|
|
|
next_tvb = tvb_new_subset_remaining(tvb, IDP_HEADER_LEN);
|
2005-03-03 08:34:48 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Hand off to the dissector for the packet type.
|
|
|
|
*/
|
2010-12-20 05:35:29 +00:00
|
|
|
if (dissector_try_uint(idp_type_dissector_table, type, next_tvb,
|
2005-03-03 08:34:48 +00:00
|
|
|
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,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, 0x0, NULL, HFILL }},
|
2005-03-03 08:34:48 +00:00
|
|
|
|
2013-01-31 17:55:31 +00:00
|
|
|
#if 0
|
2005-03-03 08:34:48 +00:00
|
|
|
{ &hf_idp_src,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
{ "Source Address", "idp.src", FT_STRING, BASE_NONE,
|
|
|
|
NULL, 0x0, NULL, HFILL }},
|
2013-01-31 17:55:31 +00:00
|
|
|
#endif
|
2005-03-03 08:34:48 +00:00
|
|
|
|
2013-01-31 17:55:31 +00:00
|
|
|
#if 0
|
2005-03-03 08:34:48 +00:00
|
|
|
{ &hf_idp_dst,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
{ "Destination Address", "idp.dst", FT_STRING, BASE_NONE,
|
|
|
|
NULL, 0x0, NULL, HFILL }},
|
2013-01-31 17:55:31 +00:00
|
|
|
#endif
|
2005-03-03 08:34:48 +00:00
|
|
|
|
|
|
|
{ &hf_idp_len,
|
|
|
|
{ "Length", "idp.len", FT_UINT16, BASE_DEC,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, 0x0, NULL, HFILL }},
|
2005-03-03 08:34:48 +00:00
|
|
|
|
|
|
|
/* XXX - does this have separate hop count and time subfields? */
|
|
|
|
{ &hf_idp_hops,
|
|
|
|
{ "Transport Control (Hops)", "idp.hops", FT_UINT8, BASE_DEC,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, 0x0, NULL, HFILL }},
|
2005-03-03 08:34:48 +00:00
|
|
|
|
|
|
|
{ &hf_idp_packet_type,
|
|
|
|
{ "Packet Type", "idp.packet_type", FT_UINT8, BASE_DEC,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
VALS(idp_packet_type_vals), 0x0, NULL, HFILL }},
|
2005-03-03 08:34:48 +00:00
|
|
|
|
|
|
|
{ &hf_idp_dnet,
|
|
|
|
{ "Destination Network","idp.dst.net", FT_UINT32, BASE_HEX,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, 0x0, NULL, HFILL }},
|
2005-03-03 08:34:48 +00:00
|
|
|
|
|
|
|
{ &hf_idp_dnode,
|
|
|
|
{ "Destination Node", "idp.dst.node", FT_ETHER, BASE_NONE,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, 0x0, NULL, HFILL }},
|
2005-03-03 08:34:48 +00:00
|
|
|
|
|
|
|
{ &hf_idp_dsocket,
|
|
|
|
{ "Destination Socket", "idp.dst.socket", FT_UINT16, BASE_HEX,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
VALS(idp_socket_vals), 0x0, NULL, HFILL }},
|
2005-03-03 08:34:48 +00:00
|
|
|
|
|
|
|
{ &hf_idp_snet,
|
|
|
|
{ "Source Network","idp.src.net", FT_UINT32, BASE_HEX,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, 0x0, NULL, HFILL }},
|
2005-03-03 08:34:48 +00:00
|
|
|
|
|
|
|
{ &hf_idp_snode,
|
|
|
|
{ "Source Node", "idp.src.node", FT_ETHER, BASE_NONE,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, 0x0, NULL, HFILL }},
|
2005-03-03 08:34:48 +00:00
|
|
|
|
|
|
|
{ &hf_idp_ssocket,
|
|
|
|
{ "Source Socket", "idp.src.socket", FT_UINT16, BASE_HEX,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
VALS(idp_socket_vals), 0x0, NULL, HFILL }},
|
2005-03-03 08:34:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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);
|
2010-12-20 05:35:29 +00:00
|
|
|
dissector_add_uint("ethertype", ETHERTYPE_XNS_IDP, idp_handle);
|
2013-09-11 21:37:58 +00:00
|
|
|
dissector_add_uint("chdlc.protocol", ETHERTYPE_XNS_IDP, idp_handle);
|
2005-03-03 08:34:48 +00:00
|
|
|
|
|
|
|
data_handle = find_dissector("data");
|
|
|
|
}
|