3 * Based on the Netware IPX dissector by Gilbert Ramirez <gram@alumni.rice.edu>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
14 #include <epan/packet.h>
15 #include "packet-idp.h"
16 #include <epan/etypes.h>
17 #include <epan/unit_strings.h>
19 void proto_register_idp(void);
20 void proto_reg_handoff_idp(void);
22 static dissector_handle_t idp_handle
;
25 static int hf_idp_checksum
;
26 static int hf_idp_len
;
27 /* static int hf_idp_src; */
28 /* static int hf_idp_dst; */
29 static int hf_idp_hops
;
30 static int hf_idp_packet_type
;
31 static int hf_idp_dnet
;
32 static int hf_idp_dnode
;
33 static int hf_idp_dsocket
;
34 static int hf_idp_snet
;
35 static int hf_idp_snode
;
36 static int hf_idp_ssocket
;
40 static dissector_table_t idp_type_dissector_table
;
45 * "Internet Transport Protocols", XSIS 028112, December 1981
47 * if you can find it; this is based on the headers in the BSD XNS
51 #define IDP_HEADER_LEN 30 /* It's *always* 30 bytes */
53 static const value_string idp_packet_type_vals
[] = {
54 { IDP_PACKET_TYPE_RIP
, "RIP" },
55 { IDP_PACKET_TYPE_ECHO
, "Echo" },
56 { IDP_PACKET_TYPE_ERROR
, "Error" },
57 { IDP_PACKET_TYPE_PEP
, "PEP" },
58 { IDP_PACKET_TYPE_SPP
, "SPP" },
62 static const value_string idp_socket_vals
[] = {
63 { IDP_SOCKET_SMB
, "SMB" },
68 dissect_idp(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
76 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "IDP");
77 col_clear(pinfo
->cinfo
, COL_INFO
);
79 ti
= proto_tree_add_item(tree
, proto_idp
, tvb
, 0, IDP_HEADER_LEN
, ENC_NA
);
80 idp_tree
= proto_item_add_subtree(ti
, ett_idp
);
82 proto_tree_add_checksum(idp_tree
, tvb
, 0, hf_idp_checksum
, -1, NULL
, pinfo
, 0, ENC_BIG_ENDIAN
, PROTO_CHECKSUM_NO_FLAGS
);
83 length
= tvb_get_ntohs(tvb
, 2);
84 proto_tree_add_uint(idp_tree
, hf_idp_len
, tvb
, 2, 2, length
);
85 /* Adjust the tvbuff length to include only the IDP datagram. */
86 set_actual_length(tvb
, length
);
87 proto_tree_add_item(idp_tree
, hf_idp_hops
, tvb
, 4, 1, ENC_BIG_ENDIAN
);
88 type
= tvb_get_uint8(tvb
, 5);
89 proto_tree_add_uint(idp_tree
, hf_idp_packet_type
, tvb
, 5, 1, type
);
91 pinfo
->ptype
= PT_IDP
;
94 proto_tree_add_item(idp_tree
, hf_idp_dnet
, tvb
, 6, 4, ENC_BIG_ENDIAN
);
95 proto_tree_add_item(idp_tree
, hf_idp_dnode
, tvb
, 10, 6, ENC_NA
);
96 pinfo
->destport
= tvb_get_ntohs(tvb
, 16);
97 proto_tree_add_uint(idp_tree
, hf_idp_dsocket
, tvb
, 16, 2,
101 proto_tree_add_item(idp_tree
, hf_idp_snet
, tvb
, 18, 4, ENC_BIG_ENDIAN
);
102 proto_tree_add_item(idp_tree
, hf_idp_snode
, tvb
, 22, 6, ENC_NA
);
103 pinfo
->srcport
= tvb_get_ntohs(tvb
, 28);
104 proto_tree_add_uint(idp_tree
, hf_idp_ssocket
, tvb
, 28, 2,
107 /* Make the next tvbuff */
108 next_tvb
= tvb_new_subset_remaining(tvb
, IDP_HEADER_LEN
);
111 * Hand off to the dissector for the packet type.
113 if (!dissector_try_uint(idp_type_dissector_table
, type
, next_tvb
,
116 call_data_dissector(next_tvb
, pinfo
, tree
);
118 return tvb_captured_length(tvb
);
122 proto_register_idp(void)
124 static hf_register_info hf_idp
[] = {
126 { "Checksum", "idp.checksum", FT_UINT16
, BASE_HEX
,
127 NULL
, 0x0, NULL
, HFILL
}},
131 { "Source Address", "idp.src", FT_STRING
, BASE_NONE
,
132 NULL
, 0x0, NULL
, HFILL
}},
137 { "Destination Address", "idp.dst", FT_STRING
, BASE_NONE
,
138 NULL
, 0x0, NULL
, HFILL
}},
142 { "Length", "idp.len", FT_UINT16
, BASE_DEC
|BASE_UNIT_STRING
,
143 UNS(&units_byte_bytes
), 0x0, NULL
, HFILL
}},
145 /* XXX - does this have separate hop count and time subfields? */
147 { "Transport Control (Hops)", "idp.hops", FT_UINT8
, BASE_DEC
,
148 NULL
, 0x0, NULL
, HFILL
}},
150 { &hf_idp_packet_type
,
151 { "Packet Type", "idp.packet_type", FT_UINT8
, BASE_DEC
,
152 VALS(idp_packet_type_vals
), 0x0, NULL
, HFILL
}},
155 { "Destination Network","idp.dst.net", FT_UINT32
, BASE_HEX
,
156 NULL
, 0x0, NULL
, HFILL
}},
159 { "Destination Node", "idp.dst.node", FT_ETHER
, BASE_NONE
,
160 NULL
, 0x0, NULL
, HFILL
}},
163 { "Destination Socket", "idp.dst.socket", FT_UINT16
, BASE_HEX
,
164 VALS(idp_socket_vals
), 0x0, NULL
, HFILL
}},
167 { "Source Network","idp.src.net", FT_UINT32
, BASE_HEX
,
168 NULL
, 0x0, NULL
, HFILL
}},
171 { "Source Node", "idp.src.node", FT_ETHER
, BASE_NONE
,
172 NULL
, 0x0, NULL
, HFILL
}},
175 { "Source Socket", "idp.src.socket", FT_UINT16
, BASE_HEX
,
176 VALS(idp_socket_vals
), 0x0, NULL
, HFILL
}},
179 static int *ett
[] = {
183 proto_idp
= proto_register_protocol("Internetwork Datagram Protocol",
185 proto_register_field_array(proto_idp
, hf_idp
, array_length(hf_idp
));
186 proto_register_subtree_array(ett
, array_length(ett
));
188 idp_type_dissector_table
= register_dissector_table("idp.packet_type",
189 "IDP packet type", proto_idp
, FT_UINT8
, BASE_DEC
);
191 idp_handle
= register_dissector("idp", dissect_idp
, proto_idp
);
195 proto_reg_handoff_idp(void)
197 dissector_add_uint("ethertype", ETHERTYPE_XNS_IDP
, idp_handle
);
198 dissector_add_uint("chdlc.protocol", ETHERTYPE_XNS_IDP
, idp_handle
);
202 * Editor modelines - https://www.wireshark.org/tools/modelines.html
207 * indent-tabs-mode: t
210 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
211 * :indentSize=8:tabSize=8:noTabs=false: