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