1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate * CDDL HEADER START
3*0Sstevel@tonic-gate *
4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
7*0Sstevel@tonic-gate * with the License.
8*0Sstevel@tonic-gate *
9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate * and limitations under the License.
13*0Sstevel@tonic-gate *
14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate *
20*0Sstevel@tonic-gate * CDDL HEADER END
21*0Sstevel@tonic-gate */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate * Copyright (c) 1991-2001 by Sun Microsystems, Inc.
24*0Sstevel@tonic-gate * All rights reserved.
25*0Sstevel@tonic-gate */
26*0Sstevel@tonic-gate
27*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
28*0Sstevel@tonic-gate
29*0Sstevel@tonic-gate #include <stdio.h>
30*0Sstevel@tonic-gate #include <sys/types.h>
31*0Sstevel@tonic-gate
32*0Sstevel@tonic-gate #include <at.h>
33*0Sstevel@tonic-gate #include <snoop.h>
34*0Sstevel@tonic-gate
35*0Sstevel@tonic-gate static char *adsp_ctrl(uint8_t);
36*0Sstevel@tonic-gate
37*0Sstevel@tonic-gate void
interpret_adsp(int flags,struct ddp_adsphdr * adp,int len)38*0Sstevel@tonic-gate interpret_adsp(int flags, struct ddp_adsphdr *adp, int len)
39*0Sstevel@tonic-gate {
40*0Sstevel@tonic-gate struct ddp_adsp_open *apo;
41*0Sstevel@tonic-gate
42*0Sstevel@tonic-gate if (flags & F_SUM) {
43*0Sstevel@tonic-gate if (len < sizeof (struct ddp_adsphdr)) {
44*0Sstevel@tonic-gate (void) snprintf(get_sum_line(), MAXLINE,
45*0Sstevel@tonic-gate "ADSP (short packet)");
46*0Sstevel@tonic-gate return;
47*0Sstevel@tonic-gate }
48*0Sstevel@tonic-gate (void) snprintf(get_sum_line(), MAXLINE,
49*0Sstevel@tonic-gate "ADSP ConnID=%u (%s)",
50*0Sstevel@tonic-gate get_short(adp->ad_connid),
51*0Sstevel@tonic-gate adsp_ctrl(adp->ad_desc));
52*0Sstevel@tonic-gate }
53*0Sstevel@tonic-gate
54*0Sstevel@tonic-gate if (flags & F_DTAIL) {
55*0Sstevel@tonic-gate show_header("ADSP: ", "ADSP Header",
56*0Sstevel@tonic-gate len - sizeof (struct ddp_adsphdr));
57*0Sstevel@tonic-gate show_space();
58*0Sstevel@tonic-gate
59*0Sstevel@tonic-gate if (len < sizeof (struct ddp_adsphdr)) {
60*0Sstevel@tonic-gate (void) snprintf(get_line(0, 0), get_line_remain(),
61*0Sstevel@tonic-gate "(short packet)");
62*0Sstevel@tonic-gate return;
63*0Sstevel@tonic-gate }
64*0Sstevel@tonic-gate
65*0Sstevel@tonic-gate (void) snprintf(get_line(0, 0), get_line_remain(),
66*0Sstevel@tonic-gate "ConnID = %u, ByteSeq = %u, RecvSeq = %u",
67*0Sstevel@tonic-gate get_short(adp->ad_connid),
68*0Sstevel@tonic-gate get_long(adp->ad_fbseq),
69*0Sstevel@tonic-gate get_long(adp->ad_nrseq));
70*0Sstevel@tonic-gate
71*0Sstevel@tonic-gate (void) snprintf(get_line(0, 0), get_line_remain(),
72*0Sstevel@tonic-gate "RcvWin = %u, Ctrl = 0x%x (%s)",
73*0Sstevel@tonic-gate get_short(adp->ad_rcvwin),
74*0Sstevel@tonic-gate adp->ad_desc,
75*0Sstevel@tonic-gate adsp_ctrl(adp->ad_desc));
76*0Sstevel@tonic-gate
77*0Sstevel@tonic-gate switch (adp->ad_desc) {
78*0Sstevel@tonic-gate case AD_CREQ: /* open requests */
79*0Sstevel@tonic-gate case AD_CACK:
80*0Sstevel@tonic-gate case AD_CREQ_ACK:
81*0Sstevel@tonic-gate case AD_CDENY:
82*0Sstevel@tonic-gate apo = (struct ddp_adsp_open *)adp;
83*0Sstevel@tonic-gate if (len < sizeof (struct ddp_adsp_open)) {
84*0Sstevel@tonic-gate (void) snprintf(get_line(0, 0),
85*0Sstevel@tonic-gate get_line_remain(),
86*0Sstevel@tonic-gate "(short packet)");
87*0Sstevel@tonic-gate return;
88*0Sstevel@tonic-gate }
89*0Sstevel@tonic-gate (void) snprintf(get_line(0, 0), get_line_remain(),
90*0Sstevel@tonic-gate "Dest ConnID = %u, AttRcvSeq = %u",
91*0Sstevel@tonic-gate get_short(apo->ad_dconnid),
92*0Sstevel@tonic-gate get_long(apo->ad_attseq));
93*0Sstevel@tonic-gate break;
94*0Sstevel@tonic-gate }
95*0Sstevel@tonic-gate
96*0Sstevel@tonic-gate if (adp->ad_desc & AD_ATT) {
97*0Sstevel@tonic-gate (void) snprintf(get_line(0, 0), get_line_remain(),
98*0Sstevel@tonic-gate "AttCode = 0x%x",
99*0Sstevel@tonic-gate get_short(((struct ddp_adsp_att *)adp)->
100*0Sstevel@tonic-gate ad_att_code));
101*0Sstevel@tonic-gate }
102*0Sstevel@tonic-gate }
103*0Sstevel@tonic-gate }
104*0Sstevel@tonic-gate
105*0Sstevel@tonic-gate static char *adsp_ctrl_msg[] = {
106*0Sstevel@tonic-gate "Probe/Ack",
107*0Sstevel@tonic-gate "OpenConnReq",
108*0Sstevel@tonic-gate "OpenConnAck",
109*0Sstevel@tonic-gate "OpenConnReq+Ack",
110*0Sstevel@tonic-gate "OpenConnDeny",
111*0Sstevel@tonic-gate "CloseConnAdv",
112*0Sstevel@tonic-gate "ForwReset",
113*0Sstevel@tonic-gate "ForwReset Ack",
114*0Sstevel@tonic-gate "RetransAdv",
115*0Sstevel@tonic-gate "9", "10", "11", "12", "13", "14", "15",
116*0Sstevel@tonic-gate };
117*0Sstevel@tonic-gate
118*0Sstevel@tonic-gate static char *
adsp_ctrl(uint8_t ctrl)119*0Sstevel@tonic-gate adsp_ctrl(uint8_t ctrl)
120*0Sstevel@tonic-gate {
121*0Sstevel@tonic-gate static char buf[50];
122*0Sstevel@tonic-gate char *p = buf;
123*0Sstevel@tonic-gate char *tail = &buf[sizeof (buf)];
124*0Sstevel@tonic-gate
125*0Sstevel@tonic-gate if (ctrl & AD_ACKREQ)
126*0Sstevel@tonic-gate p += snprintf(p, tail-p, "AckReq");
127*0Sstevel@tonic-gate
128*0Sstevel@tonic-gate if (ctrl & AD_EOM) {
129*0Sstevel@tonic-gate p += snprintf(p, tail-p, p == buf ? "EOM" : " EOM");
130*0Sstevel@tonic-gate }
131*0Sstevel@tonic-gate
132*0Sstevel@tonic-gate if (ctrl & AD_ATT) {
133*0Sstevel@tonic-gate p += snprintf(p, tail-p, p == buf ? "Att" : " Att");
134*0Sstevel@tonic-gate }
135*0Sstevel@tonic-gate
136*0Sstevel@tonic-gate if (ctrl & AD_CTRL) {
137*0Sstevel@tonic-gate (void) snprintf(p, tail-p, "%s%s", p == buf ? "" : " ",
138*0Sstevel@tonic-gate adsp_ctrl_msg[ctrl & AD_CTRL_MASK]);
139*0Sstevel@tonic-gate }
140*0Sstevel@tonic-gate
141*0Sstevel@tonic-gate return (buf);
142*0Sstevel@tonic-gate }
143