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