2 * Routines for SSCOP (Q.2110, Q.SAAL) frame disassembly
3 * Guy Harris <guy@alum.mit.edu>
5 * $Id: packet-sscop.c,v 1.6 2000/03/12 04:47:50 gram Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@zing.org>
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #ifdef HAVE_SYS_TYPES_H
32 # include <sys/types.h>
39 #include "packet-q2931.h"
41 static int proto_sscop = -1;
43 static gint ett_sscop = -1;
48 * http://www.protocols.com/pbook/atmsig.htm
50 * for some information on SSCOP, although, alas, not the actual PDU
51 * type values - those I got from the FreeBSD 3.2 ATM code.
57 #define SSCOP_TYPE_MASK 0x0f
59 #define SSCOP_BGN 0x01 /* Begin */
60 #define SSCOP_BGAK 0x02 /* Begin Acknowledge */
61 #define SSCOP_BGREJ 0x07 /* Begin Reject */
62 #define SSCOP_END 0x03 /* End */
63 #define SSCOP_ENDAK 0x04 /* End Acknowledge */
64 #define SSCOP_RS 0x05 /* Resynchronization */
65 #define SSCOP_RSAK 0x06 /* Resynchronization Acknowledge */
66 #define SSCOP_SD 0x08 /* Sequenced Data */
67 #define SSCOP_SDP 0x09 /* Sequenced Data with Poll */
68 #define SSCOP_POLL 0x0a /* Status Request */
69 #define SSCOP_STAT 0x0b /* Solicited Status Response */
70 #define SSCOP_USTAT 0x0c /* Unsolicited Status Response */
71 #define SSCOP_UD 0x0d /* Unnumbered Data */
72 #define SSCOP_MD 0x0e /* Management Data */
73 #define SSCOP_ER 0x09 /* Error Recovery */
74 #define SSCOP_ERAK 0x0f /* Error Acknowledge */
76 #define SSCOP_S 0x10 /* Source bit in End PDU */
79 * XXX - how to distinguish SDP from ER?
81 static const value_string sscop_type_vals[] = {
82 { SSCOP_BGN, "Begin" },
83 { SSCOP_BGAK, "Begin Acknowledge" },
84 { SSCOP_BGREJ, "Begin Reject" },
86 { SSCOP_ENDAK, "End Acknowledge" },
87 { SSCOP_RS, "Resynchronization" },
88 { SSCOP_RSAK, "Resynchronization Acknowledge" },
89 { SSCOP_SD, "Sequenced Data" },
91 { SSCOP_SDP, "Sequenced Data with Poll" },
93 { SSCOP_POLL, "Status Request" },
94 { SSCOP_STAT, "Solicited Status Response" },
95 { SSCOP_USTAT, "Unsolicited Status Response" },
96 { SSCOP_UD, "Unnumbered Data" },
97 { SSCOP_MD, "Management Data" },
98 { SSCOP_ER, "Error Recovery" },
99 { SSCOP_ERAK, "Error Acknowledge" },
104 * The SSCOP "header" is a trailer, so the "offsets" are computed based
105 * on the length of the packet.
111 #define SSCOP_PDU_TYPE (pi.len - 4) /* single byte */
114 * Begin PDU, Begin Acknowledge PDU (no N(SQ) in it), Resynchronization
115 * PDU, Resynchronization Acknowledge PDU (no N(SQ) in it in Q.SAAL),
116 * Error Recovery PDU, Error Recovery Acknoledge PDU (no N(SQ) in it).
118 #define SSCOP_N_SQ (pi.len - 5) /* One byte */
119 #define SSCOP_N_MR (pi.len - 4) /* lower 3 bytes thereof */
122 * Sequenced Data PDU (no N(PS) in it), Sequenced Data with Poll PDU,
125 #define SSCOP_N_PS (pi.len - 8) /* lower 3 bytes thereof */
126 #define SSCOP_N_S (pi.len - 4) /* lower 3 bytes thereof */
129 * Solicited Status PDU, Unsolicited Status PDU (no N(PS) in it).
131 #define SSCOP_SS_N_PS (pi.len - 12) /* lower 3 bytes thereof */
132 #define SSCOP_SS_N_MR (pi.len - 8) /* lower 3 bytes thereof */
133 #define SSCOP_SS_N_R (pi.len - 4) /* lower 3 bytes thereof */
136 dissect_sscop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
139 proto_tree *sscop_tree = NULL;
145 * The SSCOP "header" is a trailer, and the PDU type is in the
146 * last-minus-3 byte of the frame; if the captured length is less
147 * than the actual length by 3 or more bytes, give up, as we don't
150 if ((pi.len - pi.captured_len) >= 3) {
151 dissect_data(pd, offset, fd, tree);
154 pdu_type = pd[SSCOP_PDU_TYPE] & SSCOP_TYPE_MASK;
155 if (check_col(fd, COL_PROTOCOL))
156 col_add_str(fd, COL_PROTOCOL, "SSCOP");
157 if (check_col(fd, COL_INFO))
158 col_add_str(fd, COL_INFO, val_to_str(pdu_type, sscop_type_vals,
159 "Unknown PDU type (0x%02x)"));
162 * Find the length of the PDU and, if there's any payload and
163 * padding, the length of the padding.
168 pad_len = (pd[SSCOP_PDU_TYPE] >> 6) & 0x03;
180 pad_len = (pd[SSCOP_PDU_TYPE] >> 6) & 0x03;
185 pad_len = (pd[SSCOP_PDU_TYPE] >> 6) & 0x03;
191 pdu_len = pi.len; /* No payload, just SSCOP */
195 ti = proto_tree_add_protocol_format(tree, proto_sscop, pi.len - pdu_len,
197 sscop_tree = proto_item_add_subtree(ti, ett_sscop);
199 proto_tree_add_text(sscop_tree, SSCOP_PDU_TYPE, 1,
201 val_to_str(pdu_type, sscop_type_vals,
202 "Unknown (0x%02x)"));
209 proto_tree_add_text(sscop_tree, SSCOP_N_SQ, 1,
210 "N(SQ): %u", pd[SSCOP_N_SQ]);
211 proto_tree_add_text(sscop_tree, SSCOP_N_MR + 1, 3,
212 "N(MR): %u", pntohl(&pd[SSCOP_N_MR]) & 0xFFFFFF);
216 proto_tree_add_text(sscop_tree, SSCOP_PDU_TYPE, 1,
217 "Source: %s", (pd[SSCOP_PDU_TYPE] & SSCOP_S) ? "SSCOP" : "User");
222 proto_tree_add_text(sscop_tree, SSCOP_N_MR + 1, 3,
223 "N(MR): %u", pntohl(&pd[SSCOP_N_MR]) & 0xFFFFFF);
227 proto_tree_add_text(sscop_tree, SSCOP_N_MR + 3, 3,
228 "N(MR): %u", pntohl(&pd[SSCOP_N_MR]) & 0xFFFFFF);
232 proto_tree_add_text(sscop_tree, SSCOP_N_S + 1, 3,
233 "N(S): %u", pntohl(&pd[SSCOP_N_S]) & 0xFFFFFF);
240 proto_tree_add_text(sscop_tree, SSCOP_N_PS + 1, 3,
241 "N(PS): %u", pntohl(&pd[SSCOP_N_PS]) & 0xFFFFFF);
242 proto_tree_add_text(sscop_tree, SSCOP_N_S + 1, 3,
243 "N(S): %u", pntohl(&pd[SSCOP_N_S]) & 0xFFFFFF);
248 * XXX - dissect the list elements....
250 proto_tree_add_text(sscop_tree, SSCOP_SS_N_PS + 1, 3,
251 "N(PS): %u", pntohl(&pd[SSCOP_SS_N_PS]) & 0xFFFFFF);
252 proto_tree_add_text(sscop_tree, SSCOP_SS_N_MR + 1, 3,
253 "N(MR): %u", pntohl(&pd[SSCOP_SS_N_MR]) & 0xFFFFFF);
254 proto_tree_add_text(sscop_tree, SSCOP_SS_N_R + 1, 3,
255 "N(R): %u", pntohl(&pd[SSCOP_SS_N_R]) & 0xFFFFFF);
260 * XXX - dissect the list elements....
262 proto_tree_add_text(sscop_tree, SSCOP_SS_N_MR + 1, 3,
263 "N(MR): %u", pntohl(&pd[SSCOP_SS_N_MR]) & 0xFFFFFF);
264 proto_tree_add_text(sscop_tree, SSCOP_SS_N_R + 1, 3,
265 "N(R): %u", pntohl(&pd[SSCOP_SS_N_R]) & 0xFFFFFF);
271 * Dissect the payload, if any.
273 * XXX - what about a Management Data PDU?
288 proto_tree_add_text(sscop_tree, SSCOP_PDU_TYPE, 1,
289 "Pad length: %u", pad_len);
293 * Compute length of data in PDU - subtract the trailer length
294 * and the pad length.
296 pi.len -= (pdu_len + pad_len);
297 if (pi.len < pi.captured_len)
298 pi.captured_len = pi.len;
301 * XXX - if more than just Q.2931 uses SSCOP, we need to tell
302 * SSCOP what dissector to use here.
305 if (pdu_type == SSCOP_SD)
306 dissect_q2931(pd, offset, fd, tree);
308 dissect_data(pd, offset, fd, tree);
315 proto_register_sscop(void)
317 static gint *ett[] = {
320 proto_sscop = proto_register_protocol("SSCOP", "sscop");
321 proto_register_subtree_array(ett, array_length(ett));