3 * Based on the Netware IPX dissector by Gilbert Ramirez <gram@alumni.rice.edu>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #include <epan/packet.h>
32 #include "packet-idp.h"
33 #include <epan/etypes.h>
35 static int proto_idp = -1;
36 static int hf_idp_checksum = -1;
37 static int hf_idp_len = -1;
38 static int hf_idp_src = -1;
39 static int hf_idp_dst = -1;
40 static int hf_idp_hops = -1;
41 static int hf_idp_packet_type = -1;
42 static int hf_idp_dnet = -1;
43 static int hf_idp_dnode = -1;
44 static int hf_idp_dsocket = -1;
45 static int hf_idp_snet = -1;
46 static int hf_idp_snode = -1;
47 static int hf_idp_ssocket = -1;
49 static gint ett_idp = -1;
51 static dissector_handle_t data_handle;
53 static dissector_table_t idp_type_dissector_table;
58 * "Internet Transport Protocols", XSIS 028112, December 1981
60 * if you can find it; this is based on the headers in the BSD XNS
64 #define IDP_HEADER_LEN 30 /* It's *always* 30 bytes */
66 static const value_string idp_packet_type_vals[] = {
67 { IDP_PACKET_TYPE_RIP, "RIP" },
68 { IDP_PACKET_TYPE_ECHO, "Echo" },
69 { IDP_PACKET_TYPE_ERROR, "Error" },
70 { IDP_PACKET_TYPE_PEP, "PEP" },
71 { IDP_PACKET_TYPE_SPP, "SPP" },
75 static const value_string idp_socket_vals[] = {
76 { IDP_SOCKET_SMB, "SMB" },
81 dissect_idp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
83 proto_tree *idp_tree = NULL;
84 proto_item *ti = NULL;
89 col_set_str(pinfo->cinfo, COL_PROTOCOL, "IDP");
90 if (check_col(pinfo->cinfo, COL_INFO))
91 col_clear(pinfo->cinfo, COL_INFO);
93 if (check_col(pinfo->cinfo, COL_INFO))
94 col_clear(pinfo->cinfo, COL_INFO);
97 ti = proto_tree_add_item(tree, proto_idp, tvb, 0, IDP_HEADER_LEN, FALSE);
98 idp_tree = proto_item_add_subtree(ti, ett_idp);
101 proto_tree_add_item(idp_tree, hf_idp_checksum, tvb, 0, 2, FALSE);
102 length = tvb_get_ntohs(tvb, 2);
103 proto_tree_add_uint_format(idp_tree, hf_idp_len, tvb, 2, 2, length,
104 "Length: %u bytes", length);
105 /* Adjust the tvbuff length to include only the IDP datagram. */
106 set_actual_length(tvb, length);
107 proto_tree_add_item(idp_tree, hf_idp_hops, tvb, 4, 1, FALSE);
108 type = tvb_get_guint8(tvb, 5);
109 proto_tree_add_uint(idp_tree, hf_idp_packet_type, tvb, 5, 1, type);
111 pinfo->ptype = PT_IDP;
114 proto_tree_add_item(idp_tree, hf_idp_dnet, tvb, 6, 4, FALSE);
115 proto_tree_add_item(idp_tree, hf_idp_dnode, tvb, 10, 6, FALSE);
116 pinfo->destport = tvb_get_ntohs(tvb, 16);
117 proto_tree_add_uint(idp_tree, hf_idp_dsocket, tvb, 16, 2,
121 proto_tree_add_item(idp_tree, hf_idp_snet, tvb, 18, 4, FALSE);
122 proto_tree_add_item(idp_tree, hf_idp_snode, tvb, 22, 6, FALSE);
123 pinfo->srcport = tvb_get_ntohs(tvb, 28);
124 proto_tree_add_uint(idp_tree, hf_idp_ssocket, tvb, 28, 2,
127 /* Make the next tvbuff */
128 next_tvb = tvb_new_subset(tvb, IDP_HEADER_LEN, -1, -1);
131 * Hand off to the dissector for the packet type.
133 if (dissector_try_port(idp_type_dissector_table, type, next_tvb,
137 call_dissector(data_handle, next_tvb, pinfo, tree);
141 proto_register_idp(void)
143 static hf_register_info hf_idp[] = {
145 { "Checksum", "idp.checksum", FT_UINT16, BASE_HEX,
146 NULL, 0x0, NULL, HFILL }},
149 { "Source Address", "idp.src", FT_STRING, BASE_NONE,
150 NULL, 0x0, NULL, HFILL }},
153 { "Destination Address", "idp.dst", FT_STRING, BASE_NONE,
154 NULL, 0x0, NULL, HFILL }},
157 { "Length", "idp.len", FT_UINT16, BASE_DEC,
158 NULL, 0x0, NULL, HFILL }},
160 /* XXX - does this have separate hop count and time subfields? */
162 { "Transport Control (Hops)", "idp.hops", FT_UINT8, BASE_DEC,
163 NULL, 0x0, NULL, HFILL }},
165 { &hf_idp_packet_type,
166 { "Packet Type", "idp.packet_type", FT_UINT8, BASE_DEC,
167 VALS(idp_packet_type_vals), 0x0, NULL, HFILL }},
170 { "Destination Network","idp.dst.net", FT_UINT32, BASE_HEX,
171 NULL, 0x0, NULL, HFILL }},
174 { "Destination Node", "idp.dst.node", FT_ETHER, BASE_NONE,
175 NULL, 0x0, NULL, HFILL }},
178 { "Destination Socket", "idp.dst.socket", FT_UINT16, BASE_HEX,
179 VALS(idp_socket_vals), 0x0, NULL, HFILL }},
182 { "Source Network","idp.src.net", FT_UINT32, BASE_HEX,
183 NULL, 0x0, NULL, HFILL }},
186 { "Source Node", "idp.src.node", FT_ETHER, BASE_NONE,
187 NULL, 0x0, NULL, HFILL }},
190 { "Source Socket", "idp.src.socket", FT_UINT16, BASE_HEX,
191 VALS(idp_socket_vals), 0x0, NULL, HFILL }},
194 static gint *ett[] = {
198 proto_idp = proto_register_protocol("Internetwork Datagram Protocol",
200 proto_register_field_array(proto_idp, hf_idp, array_length(hf_idp));
201 proto_register_subtree_array(ett, array_length(ett));
203 idp_type_dissector_table = register_dissector_table("idp.packet_type",
204 "IDP packet type", FT_UINT8, BASE_DEC);
208 proto_reg_handoff_idp(void)
210 dissector_handle_t idp_handle;
212 idp_handle = create_dissector_handle(dissect_idp, proto_idp);
213 dissector_add("ethertype", ETHERTYPE_XNS_IDP, idp_handle);
214 dissector_add("chdlctype", ETHERTYPE_XNS_IDP, idp_handle);
216 data_handle = find_dissector("data");