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