dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / cmd-inet / usr.sbin / snoop / snoop_adsp.c
blobe77183718e2fcc45ef37684dc61664f5656e308b
1 /*
2 * CDDL HEADER START
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.
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.
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]
20 * CDDL HEADER END
23 * Copyright (c) 1991-2001 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <stdio.h>
30 #include <sys/types.h>
32 #include <at.h>
33 #include <snoop.h>
35 static char *adsp_ctrl(uint8_t);
37 void
38 interpret_adsp(int flags, struct ddp_adsphdr *adp, int len)
40 struct ddp_adsp_open *apo;
42 if (flags & F_SUM) {
43 if (len < sizeof (struct ddp_adsphdr)) {
44 (void) snprintf(get_sum_line(), MAXLINE,
45 "ADSP (short packet)");
46 return;
48 (void) snprintf(get_sum_line(), MAXLINE,
49 "ADSP ConnID=%u (%s)",
50 get_short(adp->ad_connid),
51 adsp_ctrl(adp->ad_desc));
54 if (flags & F_DTAIL) {
55 show_header("ADSP: ", "ADSP Header",
56 len - sizeof (struct ddp_adsphdr));
57 show_space();
59 if (len < sizeof (struct ddp_adsphdr)) {
60 (void) snprintf(get_line(0, 0), get_line_remain(),
61 "(short packet)");
62 return;
65 (void) snprintf(get_line(0, 0), get_line_remain(),
66 "ConnID = %u, ByteSeq = %u, RecvSeq = %u",
67 get_short(adp->ad_connid),
68 get_long(adp->ad_fbseq),
69 get_long(adp->ad_nrseq));
71 (void) snprintf(get_line(0, 0), get_line_remain(),
72 "RcvWin = %u, Ctrl = 0x%x (%s)",
73 get_short(adp->ad_rcvwin),
74 adp->ad_desc,
75 adsp_ctrl(adp->ad_desc));
77 switch (adp->ad_desc) {
78 case AD_CREQ: /* open requests */
79 case AD_CACK:
80 case AD_CREQ_ACK:
81 case AD_CDENY:
82 apo = (struct ddp_adsp_open *)adp;
83 if (len < sizeof (struct ddp_adsp_open)) {
84 (void) snprintf(get_line(0, 0),
85 get_line_remain(),
86 "(short packet)");
87 return;
89 (void) snprintf(get_line(0, 0), get_line_remain(),
90 "Dest ConnID = %u, AttRcvSeq = %u",
91 get_short(apo->ad_dconnid),
92 get_long(apo->ad_attseq));
93 break;
96 if (adp->ad_desc & AD_ATT) {
97 (void) snprintf(get_line(0, 0), get_line_remain(),
98 "AttCode = 0x%x",
99 get_short(((struct ddp_adsp_att *)adp)->
100 ad_att_code));
105 static char *adsp_ctrl_msg[] = {
106 "Probe/Ack",
107 "OpenConnReq",
108 "OpenConnAck",
109 "OpenConnReq+Ack",
110 "OpenConnDeny",
111 "CloseConnAdv",
112 "ForwReset",
113 "ForwReset Ack",
114 "RetransAdv",
115 "9", "10", "11", "12", "13", "14", "15",
118 static char *
119 adsp_ctrl(uint8_t ctrl)
121 static char buf[50];
122 char *p = buf;
123 char *tail = &buf[sizeof (buf)];
125 if (ctrl & AD_ACKREQ)
126 p += snprintf(p, tail-p, "AckReq");
128 if (ctrl & AD_EOM) {
129 p += snprintf(p, tail-p, p == buf ? "EOM" : " EOM");
132 if (ctrl & AD_ATT) {
133 p += snprintf(p, tail-p, p == buf ? "Att" : " Att");
136 if (ctrl & AD_CTRL) {
137 (void) snprintf(p, tail-p, "%s%s", p == buf ? "" : " ",
138 adsp_ctrl_msg[ctrl & AD_CTRL_MASK]);
141 return (buf);