3 * Based on the Netware SPX 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include <epan/packet.h>
30 #include "packet-idp.h"
32 static int proto_spp
= -1;
33 static int hf_spp_connection_control
= -1;
34 static int hf_spp_connection_control_sys
= -1;
35 static int hf_spp_connection_control_send_ack
= -1;
36 static int hf_spp_connection_control_attn
= -1;
37 static int hf_spp_connection_control_eom
= -1;
38 static int hf_spp_datastream_type
= -1;
39 static int hf_spp_src_id
= -1;
40 static int hf_spp_dst_id
= -1;
41 static int hf_spp_seq_nr
= -1;
42 static int hf_spp_ack_nr
= -1;
43 static int hf_spp_all_nr
= -1;
44 /* static int hf_spp_rexmt_frame = -1; */
46 static gint ett_spp
= -1;
47 static gint ett_spp_connctrl
= -1;
49 static dissector_handle_t data_handle
;
51 static dissector_table_t spp_socket_dissector_table
;
56 * "Internet Transport Protocols", XSIS 028112, December 1981
58 * if you can find it; this is based on the headers in the BSD XNS
62 #define SPP_SYS_PACKET 0x80
63 #define SPP_SEND_ACK 0x40
68 spp_conn_ctrl(guint8 ctrl
)
70 static const value_string conn_vals
[] = {
71 { 0x00, "Data, No Ack Required" },
72 { SPP_EOM
, "End-of-Message" },
73 { SPP_ATTN
, "Attention" },
74 { SPP_SEND_ACK
, "Acknowledgment Required"},
75 { SPP_SEND_ACK
|SPP_EOM
, "Send Ack: End Message"},
76 { SPP_SYS_PACKET
, "System Packet"},
77 { SPP_SYS_PACKET
|SPP_SEND_ACK
, "System Packet: Send Ack"},
81 return val_to_str_const((ctrl
& 0xf0), conn_vals
, "Unknown");
85 spp_datastream(guint8 type
)
89 return "End-of-Connection";
91 return "End-of-Connection Acknowledgment";
97 #define SPP_HEADER_LEN 12
100 * XXX - do reassembly, using the EOM flag. (Then do that in the Netware
101 * SPX implementation, too.)
103 * XXX - hand off to subdissectors based on the socket number.
106 dissect_spp(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
108 proto_tree
*spp_tree
= NULL
;
113 guint8 datastream_type
;
114 const char *datastream_type_string
;
116 const char *spp_msg_string
;
117 guint16 low_socket
, high_socket
;
119 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "SPP");
120 col_set_str(pinfo
->cinfo
, COL_INFO
, "SPP");
123 ti
= proto_tree_add_item(tree
, proto_spp
, tvb
, 0, SPP_HEADER_LEN
, ENC_NA
);
124 spp_tree
= proto_item_add_subtree(ti
, ett_spp
);
127 conn_ctrl
= tvb_get_guint8(tvb
, 0);
128 spp_msg_string
= spp_conn_ctrl(conn_ctrl
);
129 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " %s", spp_msg_string
);
131 ti
= proto_tree_add_uint_format_value(spp_tree
, hf_spp_connection_control
, tvb
,
134 spp_msg_string
, conn_ctrl
);
135 cc_tree
= proto_item_add_subtree(ti
, ett_spp_connctrl
);
136 proto_tree_add_boolean(cc_tree
, hf_spp_connection_control_sys
, tvb
,
138 proto_tree_add_boolean(cc_tree
, hf_spp_connection_control_send_ack
, tvb
,
140 proto_tree_add_boolean(cc_tree
, hf_spp_connection_control_attn
, tvb
,
142 proto_tree_add_boolean(cc_tree
, hf_spp_connection_control_eom
, tvb
,
146 datastream_type
= tvb_get_guint8(tvb
, 1);
147 datastream_type_string
= spp_datastream(datastream_type
);
148 if (datastream_type_string
!= NULL
) {
149 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " (%s)", datastream_type_string
);
152 if (datastream_type_string
!= NULL
) {
153 proto_tree_add_uint_format_value(spp_tree
, hf_spp_datastream_type
, tvb
,
154 1, 1, datastream_type
,
156 datastream_type_string
,
159 proto_tree_add_uint(spp_tree
, hf_spp_datastream_type
, tvb
,
160 1, 1, datastream_type
);
162 proto_tree_add_item(spp_tree
, hf_spp_src_id
, tvb
, 2, 2, ENC_BIG_ENDIAN
);
163 proto_tree_add_item(spp_tree
, hf_spp_dst_id
, tvb
, 4, 2, ENC_BIG_ENDIAN
);
165 spp_seq
= tvb_get_ntohs(tvb
, 6);
167 proto_tree_add_uint(spp_tree
, hf_spp_seq_nr
, tvb
, 6, 2, spp_seq
);
168 proto_tree_add_item(spp_tree
, hf_spp_ack_nr
, tvb
, 8, 2, ENC_BIG_ENDIAN
);
169 proto_tree_add_item(spp_tree
, hf_spp_all_nr
, tvb
, 10, 2, ENC_BIG_ENDIAN
);
172 if (tvb_reported_length_remaining(tvb
, SPP_HEADER_LEN
) > 0) {
173 if (pinfo
->srcport
> pinfo
->destport
) {
174 low_socket
= pinfo
->destport
;
175 high_socket
= pinfo
->srcport
;
177 low_socket
= pinfo
->srcport
;
178 high_socket
= pinfo
->destport
;
181 next_tvb
= tvb_new_subset_remaining(tvb
, SPP_HEADER_LEN
);
182 if (dissector_try_uint(spp_socket_dissector_table
, low_socket
,
183 next_tvb
, pinfo
, tree
))
185 if (dissector_try_uint(spp_socket_dissector_table
, high_socket
,
186 next_tvb
, pinfo
, tree
))
188 call_dissector(data_handle
, next_tvb
, pinfo
, tree
);
194 proto_register_spp(void)
196 static hf_register_info hf_spp
[] = {
197 { &hf_spp_connection_control
,
198 { "Connection Control", "spp.ctl",
199 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
202 { &hf_spp_connection_control_sys
,
203 { "System Packet", "spp.ctl.sys",
204 FT_BOOLEAN
, 8, NULL
, SPP_SYS_PACKET
,
207 { &hf_spp_connection_control_send_ack
,
208 { "Send Ack", "spp.ctl.send_ack",
209 FT_BOOLEAN
, 8, NULL
, SPP_SEND_ACK
,
212 { &hf_spp_connection_control_attn
,
213 { "Attention", "spp.ctl.attn",
214 FT_BOOLEAN
, 8, NULL
, SPP_ATTN
,
217 { &hf_spp_connection_control_eom
,
218 { "End of Message", "spp.ctl.eom",
219 FT_BOOLEAN
, 8, NULL
, SPP_EOM
,
222 { &hf_spp_datastream_type
,
223 { "Datastream Type", "spp.type",
224 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
228 { "Source Connection ID", "spp.src",
229 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
233 { "Destination Connection ID", "spp.dst",
234 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
238 { "Sequence Number", "spp.seq",
239 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
243 { "Acknowledgment Number", "spp.ack",
244 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
248 { "Allocation Number", "spp.alloc",
249 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
253 { &hf_spp_rexmt_frame
,
254 { "Retransmitted Frame Number", "spp.rexmt_frame",
255 FT_FRAMENUM
, BASE_NONE
, NULL
, 0x0,
260 static gint
*ett
[] = {
265 proto_spp
= proto_register_protocol("Sequenced Packet Protocol",
267 proto_register_field_array(proto_spp
, hf_spp
, array_length(hf_spp
));
268 proto_register_subtree_array(ett
, array_length(ett
));
270 spp_socket_dissector_table
= register_dissector_table("spp.socket",
271 "SPP socket", FT_UINT16
, BASE_HEX
);
275 proto_reg_handoff_spp(void)
277 dissector_handle_t spp_handle
;
279 spp_handle
= create_dissector_handle(dissect_spp
, proto_spp
);
280 dissector_add_uint("idp.packet_type", IDP_PACKET_TYPE_SPP
, spp_handle
);
282 data_handle
= find_dissector("data");