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) 2001 by Sun Microsystems, Inc.
24*7c478bd9Sstevel@tonic-gate * All rights reserved.
25*7c478bd9Sstevel@tonic-gate */
26*7c478bd9Sstevel@tonic-gate
27*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
28*7c478bd9Sstevel@tonic-gate
29*7c478bd9Sstevel@tonic-gate #include <stdio.h>
30*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
31*7c478bd9Sstevel@tonic-gate
32*7c478bd9Sstevel@tonic-gate #include <at.h>
33*7c478bd9Sstevel@tonic-gate #include <snoop.h>
34*7c478bd9Sstevel@tonic-gate
35*7c478bd9Sstevel@tonic-gate static char *atp_ci(uint8_t);
36*7c478bd9Sstevel@tonic-gate
37*7c478bd9Sstevel@tonic-gate static char *atp_trel[8] = {
38*7c478bd9Sstevel@tonic-gate "30s",
39*7c478bd9Sstevel@tonic-gate "1m",
40*7c478bd9Sstevel@tonic-gate "2m",
41*7c478bd9Sstevel@tonic-gate "4m",
42*7c478bd9Sstevel@tonic-gate "8m",
43*7c478bd9Sstevel@tonic-gate "(undef 5)",
44*7c478bd9Sstevel@tonic-gate "(undef 6)",
45*7c478bd9Sstevel@tonic-gate "(undef 7)"
46*7c478bd9Sstevel@tonic-gate };
47*7c478bd9Sstevel@tonic-gate
48*7c478bd9Sstevel@tonic-gate void
interpret_atp(int flags,struct ddp_hdr * ddp,int len)49*7c478bd9Sstevel@tonic-gate interpret_atp(int flags, struct ddp_hdr *ddp, int len)
50*7c478bd9Sstevel@tonic-gate {
51*7c478bd9Sstevel@tonic-gate struct atp_hdr *atp = (struct atp_hdr *)ddp;
52*7c478bd9Sstevel@tonic-gate int atplen = len - (DDPHDR_SIZE + ATPHDR_SIZE);
53*7c478bd9Sstevel@tonic-gate
54*7c478bd9Sstevel@tonic-gate if (flags & F_SUM) {
55*7c478bd9Sstevel@tonic-gate if (atplen < 0) {
56*7c478bd9Sstevel@tonic-gate (void) snprintf(get_sum_line(), MAXLINE,
57*7c478bd9Sstevel@tonic-gate "ATP (short packet)");
58*7c478bd9Sstevel@tonic-gate return;
59*7c478bd9Sstevel@tonic-gate }
60*7c478bd9Sstevel@tonic-gate (void) snprintf(get_sum_line(), MAXLINE,
61*7c478bd9Sstevel@tonic-gate "ATP (%s), TID=%d, L=%d",
62*7c478bd9Sstevel@tonic-gate atp_ci(atp->atp_ctrl),
63*7c478bd9Sstevel@tonic-gate get_short((uint8_t *)&atp->atp_tid),
64*7c478bd9Sstevel@tonic-gate len);
65*7c478bd9Sstevel@tonic-gate }
66*7c478bd9Sstevel@tonic-gate
67*7c478bd9Sstevel@tonic-gate if (flags & F_DTAIL) {
68*7c478bd9Sstevel@tonic-gate show_header("ATP: ", "ATP Header", 8);
69*7c478bd9Sstevel@tonic-gate show_space();
70*7c478bd9Sstevel@tonic-gate
71*7c478bd9Sstevel@tonic-gate if (atplen < 0) {
72*7c478bd9Sstevel@tonic-gate (void) snprintf(get_line(0, 0), get_line_remain(),
73*7c478bd9Sstevel@tonic-gate "ATP (short packet)");
74*7c478bd9Sstevel@tonic-gate return;
75*7c478bd9Sstevel@tonic-gate }
76*7c478bd9Sstevel@tonic-gate (void) snprintf(get_line(0, 0), get_line_remain(),
77*7c478bd9Sstevel@tonic-gate "Length = %d", len);
78*7c478bd9Sstevel@tonic-gate (void) snprintf(get_line(0, 0), get_line_remain(),
79*7c478bd9Sstevel@tonic-gate "Ctrl = 0x%x (%s), bitmap/seq = 0x%x",
80*7c478bd9Sstevel@tonic-gate atp->atp_ctrl,
81*7c478bd9Sstevel@tonic-gate atp_ci(atp->atp_ctrl),
82*7c478bd9Sstevel@tonic-gate atp->atp_seq);
83*7c478bd9Sstevel@tonic-gate (void) snprintf(get_line(0, 0), get_line_remain(),
84*7c478bd9Sstevel@tonic-gate "TID = %d, user bytes 0x%x 0x%x 0x%x 0x%x",
85*7c478bd9Sstevel@tonic-gate get_short((uint8_t *)&atp->atp_tid),
86*7c478bd9Sstevel@tonic-gate atp->atp_user[0], atp->atp_user[1],
87*7c478bd9Sstevel@tonic-gate atp->atp_user[2], atp->atp_user[3]);
88*7c478bd9Sstevel@tonic-gate show_space();
89*7c478bd9Sstevel@tonic-gate }
90*7c478bd9Sstevel@tonic-gate
91*7c478bd9Sstevel@tonic-gate if (ddp->ddp_dest_sock == DDP_TYPE_ZIP ||
92*7c478bd9Sstevel@tonic-gate ddp->ddp_src_sock == DDP_TYPE_ZIP)
93*7c478bd9Sstevel@tonic-gate interpret_atp_zip(flags, atp, atplen);
94*7c478bd9Sstevel@tonic-gate }
95*7c478bd9Sstevel@tonic-gate
96*7c478bd9Sstevel@tonic-gate static char *
atp_ci(uint8_t ci)97*7c478bd9Sstevel@tonic-gate atp_ci(uint8_t ci)
98*7c478bd9Sstevel@tonic-gate {
99*7c478bd9Sstevel@tonic-gate static char buf[50];
100*7c478bd9Sstevel@tonic-gate char *p = buf;
101*7c478bd9Sstevel@tonic-gate char *to = NULL;
102*7c478bd9Sstevel@tonic-gate char *tail = &buf[sizeof (buf)];
103*7c478bd9Sstevel@tonic-gate
104*7c478bd9Sstevel@tonic-gate switch (atp_fun(ci)) {
105*7c478bd9Sstevel@tonic-gate case ATP_TREQ:
106*7c478bd9Sstevel@tonic-gate p += snprintf(p, tail-p, "TReq");
107*7c478bd9Sstevel@tonic-gate to = atp_trel[atp_tmo(ci)];
108*7c478bd9Sstevel@tonic-gate break;
109*7c478bd9Sstevel@tonic-gate case ATP_TRESP:
110*7c478bd9Sstevel@tonic-gate p += snprintf(p, tail-p, "TResp");
111*7c478bd9Sstevel@tonic-gate break;
112*7c478bd9Sstevel@tonic-gate case ATP_TREL:
113*7c478bd9Sstevel@tonic-gate p += snprintf(p, tail-p, "TRel");
114*7c478bd9Sstevel@tonic-gate break;
115*7c478bd9Sstevel@tonic-gate }
116*7c478bd9Sstevel@tonic-gate
117*7c478bd9Sstevel@tonic-gate p += snprintf(p, tail-p, ci & ATP_FLG_XO ? " XO" : " ALO");
118*7c478bd9Sstevel@tonic-gate
119*7c478bd9Sstevel@tonic-gate if (ci & ATP_FLG_EOM)
120*7c478bd9Sstevel@tonic-gate p += snprintf(p, tail-p, " EOM");
121*7c478bd9Sstevel@tonic-gate
122*7c478bd9Sstevel@tonic-gate if (ci & ATP_FLG_STS)
123*7c478bd9Sstevel@tonic-gate p += snprintf(p, tail-p, " STS");
124*7c478bd9Sstevel@tonic-gate
125*7c478bd9Sstevel@tonic-gate if (to != NULL)
126*7c478bd9Sstevel@tonic-gate (void) snprintf(p, tail-p, " %s", to);
127*7c478bd9Sstevel@tonic-gate return (buf);
128*7c478bd9Sstevel@tonic-gate }
129