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 #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 char *print_macaddr(uint8_t *, int);
34*7c478bd9Sstevel@tonic-gate 
35*7c478bd9Sstevel@tonic-gate static char *zip_flags(char);
36*7c478bd9Sstevel@tonic-gate static char *zip_flags_long(char);
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate void
interpret_ddp_zip(int flags,struct zip_hdr * zip,int len)39*7c478bd9Sstevel@tonic-gate interpret_ddp_zip(int flags, struct zip_hdr *zip, int len)
40*7c478bd9Sstevel@tonic-gate {
41*7c478bd9Sstevel@tonic-gate 	int cnt;
42*7c478bd9Sstevel@tonic-gate 	uint16_t net;
43*7c478bd9Sstevel@tonic-gate 	uint16_t range;
44*7c478bd9Sstevel@tonic-gate 	uint8_t *p;
45*7c478bd9Sstevel@tonic-gate 	char zone[33];
46*7c478bd9Sstevel@tonic-gate 	char defzone[60] = "";
47*7c478bd9Sstevel@tonic-gate 	char mcast[50] = "";
48*7c478bd9Sstevel@tonic-gate 	uint8_t gniflags;
49*7c478bd9Sstevel@tonic-gate 	uint8_t *tail = (uint8_t *)zip + len;
50*7c478bd9Sstevel@tonic-gate 
51*7c478bd9Sstevel@tonic-gate 	if (flags & F_SUM) {
52*7c478bd9Sstevel@tonic-gate 		if (len < sizeof (struct zip_hdr))
53*7c478bd9Sstevel@tonic-gate 			goto out;
54*7c478bd9Sstevel@tonic-gate 
55*7c478bd9Sstevel@tonic-gate 		switch (zip->zip_func) {
56*7c478bd9Sstevel@tonic-gate 		case ZIP_QUERY:
57*7c478bd9Sstevel@tonic-gate 			cnt = zip->zip_netcnt;
58*7c478bd9Sstevel@tonic-gate 			(void) snprintf(get_sum_line(), MAXLINE,
59*7c478bd9Sstevel@tonic-gate 			    "ZIP Query CNT = %d", cnt);
60*7c478bd9Sstevel@tonic-gate 			break;
61*7c478bd9Sstevel@tonic-gate 		case ZIP_REPLY:
62*7c478bd9Sstevel@tonic-gate 		case ZIP_EXT_REPLY:
63*7c478bd9Sstevel@tonic-gate 			cnt = zip->zip_netcnt;
64*7c478bd9Sstevel@tonic-gate 			(void) snprintf(get_sum_line(), MAXLINE,
65*7c478bd9Sstevel@tonic-gate 			    "ZIP Reply CNT = %d", cnt);
66*7c478bd9Sstevel@tonic-gate 			break;
67*7c478bd9Sstevel@tonic-gate 		case ZIP_GET_NET_INFO:
68*7c478bd9Sstevel@tonic-gate 			p = &zip->zip_func;
69*7c478bd9Sstevel@tonic-gate 
70*7c478bd9Sstevel@tonic-gate 			if ((p+6 > tail) || (p+7+p[6] > tail))
71*7c478bd9Sstevel@tonic-gate 				goto out;
72*7c478bd9Sstevel@tonic-gate 
73*7c478bd9Sstevel@tonic-gate 			(void) snprintf(get_sum_line(), MAXLINE,
74*7c478bd9Sstevel@tonic-gate 			    "ZIP GNI Zone = \"%.*s\"", p[6], &p[7]);
75*7c478bd9Sstevel@tonic-gate 			break;
76*7c478bd9Sstevel@tonic-gate 		case ZIP_GET_NET_INFO_REPLY:
77*7c478bd9Sstevel@tonic-gate 			p = &zip->zip_func;
78*7c478bd9Sstevel@tonic-gate 
79*7c478bd9Sstevel@tonic-gate 			gniflags = p[1];
80*7c478bd9Sstevel@tonic-gate 			(void) snprintf(get_sum_line(), MAXLINE,
81*7c478bd9Sstevel@tonic-gate 			    "ZIP GNI Rep Flags 0x%x (%s)",
82*7c478bd9Sstevel@tonic-gate 			    gniflags, zip_flags(gniflags));
83*7c478bd9Sstevel@tonic-gate 			break;
84*7c478bd9Sstevel@tonic-gate 		default:
85*7c478bd9Sstevel@tonic-gate 			(void) snprintf(get_sum_line(), MAXLINE,
86*7c478bd9Sstevel@tonic-gate 			    "ZIP CMD = %d", zip->zip_func);
87*7c478bd9Sstevel@tonic-gate 			break;
88*7c478bd9Sstevel@tonic-gate 		}
89*7c478bd9Sstevel@tonic-gate 	}
90*7c478bd9Sstevel@tonic-gate 
91*7c478bd9Sstevel@tonic-gate 	if (flags & F_DTAIL) {
92*7c478bd9Sstevel@tonic-gate 		show_header("ZIP:  ", "ZIP Header", len);
93*7c478bd9Sstevel@tonic-gate 		show_space();
94*7c478bd9Sstevel@tonic-gate 
95*7c478bd9Sstevel@tonic-gate 		(void) snprintf(get_line(0, 0), get_line_remain(),
96*7c478bd9Sstevel@tonic-gate 		    "Length = %d", len);
97*7c478bd9Sstevel@tonic-gate 
98*7c478bd9Sstevel@tonic-gate 		if (len < sizeof (struct zip_hdr))
99*7c478bd9Sstevel@tonic-gate 			goto out;
100*7c478bd9Sstevel@tonic-gate 
101*7c478bd9Sstevel@tonic-gate 		switch (zip->zip_func) {
102*7c478bd9Sstevel@tonic-gate 		case ZIP_QUERY:
103*7c478bd9Sstevel@tonic-gate 			(void) snprintf(get_line(0, 0), get_line_remain(),
104*7c478bd9Sstevel@tonic-gate 			    "Query, Network count = %d", zip->zip_netcnt);
105*7c478bd9Sstevel@tonic-gate 			cnt = zip->zip_netcnt;
106*7c478bd9Sstevel@tonic-gate 			p = (uint8_t *)(zip + 1);
107*7c478bd9Sstevel@tonic-gate 			while (cnt--) {
108*7c478bd9Sstevel@tonic-gate 				if (p+2 > tail)
109*7c478bd9Sstevel@tonic-gate 					goto out;
110*7c478bd9Sstevel@tonic-gate 				net = get_short(p);
111*7c478bd9Sstevel@tonic-gate 				p += 2;
112*7c478bd9Sstevel@tonic-gate 				(void) snprintf(get_line(0, 0),
113*7c478bd9Sstevel@tonic-gate 				    get_line_remain(), "Net = %d", net);
114*7c478bd9Sstevel@tonic-gate 			}
115*7c478bd9Sstevel@tonic-gate 			break;
116*7c478bd9Sstevel@tonic-gate 		case ZIP_REPLY:
117*7c478bd9Sstevel@tonic-gate 		case ZIP_EXT_REPLY:
118*7c478bd9Sstevel@tonic-gate 			cnt = zip->zip_netcnt;
119*7c478bd9Sstevel@tonic-gate 			(void) snprintf(get_line(0, 0), get_line_remain(),
120*7c478bd9Sstevel@tonic-gate 			    "Reply, Network count = %d", cnt);
121*7c478bd9Sstevel@tonic-gate 
122*7c478bd9Sstevel@tonic-gate 			p = (uint8_t *)(zip + 1);
123*7c478bd9Sstevel@tonic-gate 			while (cnt--) {
124*7c478bd9Sstevel@tonic-gate 				if (p+2 > tail)
125*7c478bd9Sstevel@tonic-gate 					goto out;
126*7c478bd9Sstevel@tonic-gate 				net = get_short(p);
127*7c478bd9Sstevel@tonic-gate 				p += 2;
128*7c478bd9Sstevel@tonic-gate 				if (p+1 > tail || (&p[1] + p[0]) > tail)
129*7c478bd9Sstevel@tonic-gate 					goto out;
130*7c478bd9Sstevel@tonic-gate 				(void) snprintf(get_line(0, 0),
131*7c478bd9Sstevel@tonic-gate 				    get_line_remain(),
132*7c478bd9Sstevel@tonic-gate 				    "Network = %d, Zone = \"%.*s\"",
133*7c478bd9Sstevel@tonic-gate 				    net, p[0], &p[1]);
134*7c478bd9Sstevel@tonic-gate 				p += p[0] + 1;
135*7c478bd9Sstevel@tonic-gate 			}
136*7c478bd9Sstevel@tonic-gate 			break;
137*7c478bd9Sstevel@tonic-gate 		case ZIP_GET_NET_INFO:
138*7c478bd9Sstevel@tonic-gate 			p = &zip->zip_func;
139*7c478bd9Sstevel@tonic-gate 			if (p+1 > tail || (&p[1] + p[0]) > tail)
140*7c478bd9Sstevel@tonic-gate 				goto out;
141*7c478bd9Sstevel@tonic-gate 			(void) snprintf(get_line(0, 0), get_line_remain(),
142*7c478bd9Sstevel@tonic-gate 			    "GetNetInfo Zone = \"%.*s\"", p[0], &p[1]);
143*7c478bd9Sstevel@tonic-gate 			break;
144*7c478bd9Sstevel@tonic-gate 		case ZIP_GET_NET_INFO_REPLY:
145*7c478bd9Sstevel@tonic-gate 			p = &zip->zip_func;
146*7c478bd9Sstevel@tonic-gate 			if (p+5 > tail)
147*7c478bd9Sstevel@tonic-gate 				goto out;
148*7c478bd9Sstevel@tonic-gate 			gniflags = p[1];
149*7c478bd9Sstevel@tonic-gate 			net = get_short(&p[2]);
150*7c478bd9Sstevel@tonic-gate 			range = get_short(&p[4]);
151*7c478bd9Sstevel@tonic-gate 
152*7c478bd9Sstevel@tonic-gate 			if (p+7 > tail || (&p[7] + p[6]) > tail)
153*7c478bd9Sstevel@tonic-gate 				goto out;
154*7c478bd9Sstevel@tonic-gate 			(void) snprintf(zone, sizeof (zone),
155*7c478bd9Sstevel@tonic-gate 			    "%.*s", p[6], &p[7]);
156*7c478bd9Sstevel@tonic-gate 			p = &p[7] + p[6];
157*7c478bd9Sstevel@tonic-gate 
158*7c478bd9Sstevel@tonic-gate 			if ((gniflags & ZIP_FLG_USEBRC) == 0) {
159*7c478bd9Sstevel@tonic-gate 				if (p+1 > tail || (&p[1] + p[0]) > tail)
160*7c478bd9Sstevel@tonic-gate 					goto out;
161*7c478bd9Sstevel@tonic-gate 				(void) snprintf(mcast, sizeof (mcast),
162*7c478bd9Sstevel@tonic-gate 				    "Multicast address = %s",
163*7c478bd9Sstevel@tonic-gate 				    print_macaddr(&p[1], p[0]));
164*7c478bd9Sstevel@tonic-gate 			}
165*7c478bd9Sstevel@tonic-gate 
166*7c478bd9Sstevel@tonic-gate 			if (gniflags & ZIP_FLG_ZINV) {
167*7c478bd9Sstevel@tonic-gate 				p = &p[1] + p[0];
168*7c478bd9Sstevel@tonic-gate 				if (p+1 > tail || (&p[1] + p[0]) > tail)
169*7c478bd9Sstevel@tonic-gate 					goto out;
170*7c478bd9Sstevel@tonic-gate 				(void) snprintf(defzone, sizeof (defzone),
171*7c478bd9Sstevel@tonic-gate 				    "Default Zone = \"%.*s\"",
172*7c478bd9Sstevel@tonic-gate 				    p[0], &p[1]);
173*7c478bd9Sstevel@tonic-gate 			}
174*7c478bd9Sstevel@tonic-gate 			(void) snprintf(get_line(0, 0), get_line_remain(),
175*7c478bd9Sstevel@tonic-gate 			    "GetNetInfo Reply, Flags 0x%x (%s)",
176*7c478bd9Sstevel@tonic-gate 			    gniflags, zip_flags_long(gniflags));
177*7c478bd9Sstevel@tonic-gate 
178*7c478bd9Sstevel@tonic-gate 			(void) snprintf(get_line(0, 0), get_line_remain(),
179*7c478bd9Sstevel@tonic-gate 			    "Network number = %d-%d", net, range);
180*7c478bd9Sstevel@tonic-gate 
181*7c478bd9Sstevel@tonic-gate 			(void) snprintf(get_line(0, 0), get_line_remain(),
182*7c478bd9Sstevel@tonic-gate 			    "Zone = \"%s\"", zone);
183*7c478bd9Sstevel@tonic-gate 
184*7c478bd9Sstevel@tonic-gate 			if (mcast[0])
185*7c478bd9Sstevel@tonic-gate 				(void) snprintf(get_line(0, 0),
186*7c478bd9Sstevel@tonic-gate 				    get_line_remain(),
187*7c478bd9Sstevel@tonic-gate 				    "%s", mcast);
188*7c478bd9Sstevel@tonic-gate 
189*7c478bd9Sstevel@tonic-gate 			if (defzone[0])
190*7c478bd9Sstevel@tonic-gate 				(void) snprintf(get_line(0, 0),
191*7c478bd9Sstevel@tonic-gate 				    get_line_remain(),
192*7c478bd9Sstevel@tonic-gate 				    "%s", defzone);
193*7c478bd9Sstevel@tonic-gate 
194*7c478bd9Sstevel@tonic-gate 			break;
195*7c478bd9Sstevel@tonic-gate 		case ZIP_NOTIFY:
196*7c478bd9Sstevel@tonic-gate 			p = &zip->zip_func;
197*7c478bd9Sstevel@tonic-gate 			if (p+5 > tail)
198*7c478bd9Sstevel@tonic-gate 				goto out;
199*7c478bd9Sstevel@tonic-gate 
200*7c478bd9Sstevel@tonic-gate 			gniflags = p[1];
201*7c478bd9Sstevel@tonic-gate 			net = get_short(&p[2]);
202*7c478bd9Sstevel@tonic-gate 			range = get_short(&p[4]);
203*7c478bd9Sstevel@tonic-gate 
204*7c478bd9Sstevel@tonic-gate 			if (p+7 > tail || (&p[7] + p[6]) > tail)
205*7c478bd9Sstevel@tonic-gate 				goto out;
206*7c478bd9Sstevel@tonic-gate 			(void) snprintf(zone, sizeof (zone),
207*7c478bd9Sstevel@tonic-gate 			    "%.*s", p[6], &p[7]);
208*7c478bd9Sstevel@tonic-gate 			p = &p[7] + p[6];
209*7c478bd9Sstevel@tonic-gate 
210*7c478bd9Sstevel@tonic-gate 			if ((gniflags & ZIP_FLG_USEBRC) == 0) {
211*7c478bd9Sstevel@tonic-gate 				if (p+1 > tail || (&p[1] + p[0]) > tail)
212*7c478bd9Sstevel@tonic-gate 					goto out;
213*7c478bd9Sstevel@tonic-gate 				(void) snprintf(mcast, sizeof (mcast),
214*7c478bd9Sstevel@tonic-gate 				    "New Multicast address = %s",
215*7c478bd9Sstevel@tonic-gate 				    print_macaddr(&p[1], p[0]));
216*7c478bd9Sstevel@tonic-gate 			}
217*7c478bd9Sstevel@tonic-gate 
218*7c478bd9Sstevel@tonic-gate 			if (p+1 > tail || (&p[1] + p[0]) > tail)
219*7c478bd9Sstevel@tonic-gate 				goto out;
220*7c478bd9Sstevel@tonic-gate 
221*7c478bd9Sstevel@tonic-gate 			p = &p[1] + p[0];
222*7c478bd9Sstevel@tonic-gate 
223*7c478bd9Sstevel@tonic-gate 			if (p+1 > tail || (&p[1] + p[0]) > tail)
224*7c478bd9Sstevel@tonic-gate 				goto out;
225*7c478bd9Sstevel@tonic-gate 
226*7c478bd9Sstevel@tonic-gate 			(void) snprintf(defzone, sizeof (defzone),
227*7c478bd9Sstevel@tonic-gate 			    "New Default Zone = \"%.*s\"",
228*7c478bd9Sstevel@tonic-gate 			    p[0], &p[1]);
229*7c478bd9Sstevel@tonic-gate 
230*7c478bd9Sstevel@tonic-gate 			(void) snprintf(get_line(0, 0), get_line_remain(),
231*7c478bd9Sstevel@tonic-gate 			    "Notify, Flags 0x%x (%s)",
232*7c478bd9Sstevel@tonic-gate 			    gniflags, zip_flags_long(gniflags));
233*7c478bd9Sstevel@tonic-gate 
234*7c478bd9Sstevel@tonic-gate 			(void) snprintf(get_line(0, 0), get_line_remain(),
235*7c478bd9Sstevel@tonic-gate 			    "Old Zone = \"%s\"", zone);
236*7c478bd9Sstevel@tonic-gate 
237*7c478bd9Sstevel@tonic-gate 			if (mcast[0])
238*7c478bd9Sstevel@tonic-gate 				(void) snprintf(get_line(0, 0),
239*7c478bd9Sstevel@tonic-gate 				    get_line_remain(), "%s", mcast);
240*7c478bd9Sstevel@tonic-gate 
241*7c478bd9Sstevel@tonic-gate 			if (defzone[0])
242*7c478bd9Sstevel@tonic-gate 				(void) snprintf(get_line(0, 0),
243*7c478bd9Sstevel@tonic-gate 				    get_line_remain(), "%s", defzone);
244*7c478bd9Sstevel@tonic-gate 
245*7c478bd9Sstevel@tonic-gate 			break;
246*7c478bd9Sstevel@tonic-gate 		default:
247*7c478bd9Sstevel@tonic-gate 			(void) snprintf(get_line(0, 0), get_line_remain(),
248*7c478bd9Sstevel@tonic-gate 			    "Op = %d", zip->zip_func);
249*7c478bd9Sstevel@tonic-gate 			break;
250*7c478bd9Sstevel@tonic-gate 		}
251*7c478bd9Sstevel@tonic-gate 	}
252*7c478bd9Sstevel@tonic-gate 	return;
253*7c478bd9Sstevel@tonic-gate out:
254*7c478bd9Sstevel@tonic-gate 	if (flags & F_SUM)
255*7c478bd9Sstevel@tonic-gate 		(void) snprintf(get_sum_line(), MAXLINE,
256*7c478bd9Sstevel@tonic-gate 		    "ZIP (short packet)");
257*7c478bd9Sstevel@tonic-gate 	if (flags & F_DTAIL)
258*7c478bd9Sstevel@tonic-gate 		(void) snprintf(get_line(0, 0), get_line_remain(),
259*7c478bd9Sstevel@tonic-gate 		    "ZIP (short packet)");
260*7c478bd9Sstevel@tonic-gate }
261*7c478bd9Sstevel@tonic-gate 
262*7c478bd9Sstevel@tonic-gate static char *
zip_flags(char flags)263*7c478bd9Sstevel@tonic-gate zip_flags(char flags)
264*7c478bd9Sstevel@tonic-gate {
265*7c478bd9Sstevel@tonic-gate 	static char buf[50];
266*7c478bd9Sstevel@tonic-gate 	char *p = buf;
267*7c478bd9Sstevel@tonic-gate 	char *tail = &buf[sizeof (buf)];
268*7c478bd9Sstevel@tonic-gate 
269*7c478bd9Sstevel@tonic-gate 	buf[0] = '\0';
270*7c478bd9Sstevel@tonic-gate 
271*7c478bd9Sstevel@tonic-gate 	if (flags & ZIP_FLG_ZINV)
272*7c478bd9Sstevel@tonic-gate 		p += snprintf(p, tail-p, "IZ");
273*7c478bd9Sstevel@tonic-gate 
274*7c478bd9Sstevel@tonic-gate 	if (flags & ZIP_FLG_USEBRC)
275*7c478bd9Sstevel@tonic-gate 		p += snprintf(p, tail-p, p == buf ? "UB" : " UB");
276*7c478bd9Sstevel@tonic-gate 
277*7c478bd9Sstevel@tonic-gate 	if (flags & ZIP_FLG_ONEZ)
278*7c478bd9Sstevel@tonic-gate 		(void) snprintf(p, tail-p, p == buf ? "OOZ" : " OOZ");
279*7c478bd9Sstevel@tonic-gate 
280*7c478bd9Sstevel@tonic-gate 	return (buf);
281*7c478bd9Sstevel@tonic-gate }
282*7c478bd9Sstevel@tonic-gate 
283*7c478bd9Sstevel@tonic-gate static char *
zip_flags_long(char flags)284*7c478bd9Sstevel@tonic-gate zip_flags_long(char flags)
285*7c478bd9Sstevel@tonic-gate {
286*7c478bd9Sstevel@tonic-gate 	static char buf[50];
287*7c478bd9Sstevel@tonic-gate 	char *p = buf;
288*7c478bd9Sstevel@tonic-gate 	char *tail = &buf[sizeof (buf)];
289*7c478bd9Sstevel@tonic-gate 
290*7c478bd9Sstevel@tonic-gate 	buf[0] = '\0';
291*7c478bd9Sstevel@tonic-gate 
292*7c478bd9Sstevel@tonic-gate 	if (flags & ZIP_FLG_ZINV)
293*7c478bd9Sstevel@tonic-gate 		p += snprintf(p, tail-p, "ZoneInvalid");
294*7c478bd9Sstevel@tonic-gate 
295*7c478bd9Sstevel@tonic-gate 	if (flags & ZIP_FLG_USEBRC)
296*7c478bd9Sstevel@tonic-gate 		p += snprintf(p, tail-p,
297*7c478bd9Sstevel@tonic-gate 		    p == buf ? "UseBroadcast" : " UseBroadcast");
298*7c478bd9Sstevel@tonic-gate 
299*7c478bd9Sstevel@tonic-gate 	if (flags & ZIP_FLG_ONEZ)
300*7c478bd9Sstevel@tonic-gate 		(void) snprintf(p, tail-p,
301*7c478bd9Sstevel@tonic-gate 		    p == buf ? "OnlyOneZone" : " OnlyOneZone");
302*7c478bd9Sstevel@tonic-gate 
303*7c478bd9Sstevel@tonic-gate 	return (buf);
304*7c478bd9Sstevel@tonic-gate }
305*7c478bd9Sstevel@tonic-gate 
306*7c478bd9Sstevel@tonic-gate void
interpret_atp_zip(int flags,struct atp_hdr * atp,int len)307*7c478bd9Sstevel@tonic-gate interpret_atp_zip(int flags, struct atp_hdr *atp, int len)
308*7c478bd9Sstevel@tonic-gate {
309*7c478bd9Sstevel@tonic-gate 	int cnt;
310*7c478bd9Sstevel@tonic-gate 	uint8_t *data;
311*7c478bd9Sstevel@tonic-gate 	uint8_t *tail = (uint8_t *)(atp+1) + len;
312*7c478bd9Sstevel@tonic-gate 
313*7c478bd9Sstevel@tonic-gate 	if (flags & F_SUM) {
314*7c478bd9Sstevel@tonic-gate 		if (len < 0) {
315*7c478bd9Sstevel@tonic-gate 			(void) snprintf(get_sum_line(), MAXLINE,
316*7c478bd9Sstevel@tonic-gate 			    "ZIP (short packet)");
317*7c478bd9Sstevel@tonic-gate 			return;
318*7c478bd9Sstevel@tonic-gate 		}
319*7c478bd9Sstevel@tonic-gate 
320*7c478bd9Sstevel@tonic-gate 		switch (atp_fun(atp->atp_ctrl)) {
321*7c478bd9Sstevel@tonic-gate 		case ATP_TREQ:
322*7c478bd9Sstevel@tonic-gate 			switch (atp->atp_user[0]) {
323*7c478bd9Sstevel@tonic-gate 			case ZIP_ATP_GETMYZONE:
324*7c478bd9Sstevel@tonic-gate 				(void) snprintf(get_sum_line(), MAXLINE,
325*7c478bd9Sstevel@tonic-gate 				    "ZIP GetMyZone");
326*7c478bd9Sstevel@tonic-gate 				break;
327*7c478bd9Sstevel@tonic-gate 
328*7c478bd9Sstevel@tonic-gate 			case ZIP_ATP_GETZONELIST:
329*7c478bd9Sstevel@tonic-gate 				(void) snprintf(get_sum_line(), MAXLINE,
330*7c478bd9Sstevel@tonic-gate 				    "ZIP GetZoneList");
331*7c478bd9Sstevel@tonic-gate 				break;
332*7c478bd9Sstevel@tonic-gate 
333*7c478bd9Sstevel@tonic-gate 			case ZIP_ATP_GETLOCALZONES:
334*7c478bd9Sstevel@tonic-gate 				(void) snprintf(get_sum_line(), MAXLINE,
335*7c478bd9Sstevel@tonic-gate 				    "ZIP GetLocalZones");
336*7c478bd9Sstevel@tonic-gate 				break;
337*7c478bd9Sstevel@tonic-gate 			}
338*7c478bd9Sstevel@tonic-gate 			break;
339*7c478bd9Sstevel@tonic-gate 		case ATP_TRESP:
340*7c478bd9Sstevel@tonic-gate 			cnt = get_short(&atp->atp_user[2]);
341*7c478bd9Sstevel@tonic-gate 			(void) snprintf(get_sum_line(), MAXLINE,
342*7c478bd9Sstevel@tonic-gate 			    "ZIP ZoneReply, Cnt = %d", cnt);
343*7c478bd9Sstevel@tonic-gate 
344*7c478bd9Sstevel@tonic-gate 			break;
345*7c478bd9Sstevel@tonic-gate 		}
346*7c478bd9Sstevel@tonic-gate 	}
347*7c478bd9Sstevel@tonic-gate 
348*7c478bd9Sstevel@tonic-gate 	if (flags & F_DTAIL) {
349*7c478bd9Sstevel@tonic-gate 		show_header("ZIP:  ", "ZIP Header", len);
350*7c478bd9Sstevel@tonic-gate 		show_space();
351*7c478bd9Sstevel@tonic-gate 
352*7c478bd9Sstevel@tonic-gate 		if (len < 0) {
353*7c478bd9Sstevel@tonic-gate 			(void) snprintf(get_line(0, 0), get_line_remain(),
354*7c478bd9Sstevel@tonic-gate 			    "ZIP (short packet)");
355*7c478bd9Sstevel@tonic-gate 			return;
356*7c478bd9Sstevel@tonic-gate 		}
357*7c478bd9Sstevel@tonic-gate 
358*7c478bd9Sstevel@tonic-gate 		switch (atp_fun(atp->atp_ctrl)) {
359*7c478bd9Sstevel@tonic-gate 		case ATP_TREQ:
360*7c478bd9Sstevel@tonic-gate 			switch (atp->atp_user[0]) {
361*7c478bd9Sstevel@tonic-gate 			case ZIP_ATP_GETMYZONE:
362*7c478bd9Sstevel@tonic-gate 				(void) snprintf(get_line(0, 0),
363*7c478bd9Sstevel@tonic-gate 				    get_line_remain(),
364*7c478bd9Sstevel@tonic-gate 				    "GetMyZone, Start Index = %d",
365*7c478bd9Sstevel@tonic-gate 				    get_short(&atp->atp_user[2]));
366*7c478bd9Sstevel@tonic-gate 				break;
367*7c478bd9Sstevel@tonic-gate 			case ZIP_ATP_GETZONELIST:
368*7c478bd9Sstevel@tonic-gate 				(void) snprintf(get_line(0, 0),
369*7c478bd9Sstevel@tonic-gate 				    get_line_remain(),
370*7c478bd9Sstevel@tonic-gate 				    "GetZoneList, Start Index = %d",
371*7c478bd9Sstevel@tonic-gate 				    get_short(&atp->atp_user[2]));
372*7c478bd9Sstevel@tonic-gate 				break;
373*7c478bd9Sstevel@tonic-gate 			case ZIP_ATP_GETLOCALZONES:
374*7c478bd9Sstevel@tonic-gate 				(void) snprintf(get_line(0, 0),
375*7c478bd9Sstevel@tonic-gate 				    get_line_remain(),
376*7c478bd9Sstevel@tonic-gate 				    "GetLocalZones, Start Index = %d",
377*7c478bd9Sstevel@tonic-gate 				    get_short(&atp->atp_user[2]));
378*7c478bd9Sstevel@tonic-gate 				break;
379*7c478bd9Sstevel@tonic-gate 			}
380*7c478bd9Sstevel@tonic-gate 			break;
381*7c478bd9Sstevel@tonic-gate 		case ATP_TRESP:
382*7c478bd9Sstevel@tonic-gate 			cnt = get_short(&atp->atp_user[2]);
383*7c478bd9Sstevel@tonic-gate 			(void) snprintf(get_line(0, 0), get_line_remain(),
384*7c478bd9Sstevel@tonic-gate 			    "ZoneReply, Number of Zones = %d, Length = %d",
385*7c478bd9Sstevel@tonic-gate 			    cnt, len);
386*7c478bd9Sstevel@tonic-gate 
387*7c478bd9Sstevel@tonic-gate 			data = (uint8_t *)atp + DDPHDR_SIZE + ATPHDR_SIZE;
388*7c478bd9Sstevel@tonic-gate 
389*7c478bd9Sstevel@tonic-gate 			while (cnt--) {
390*7c478bd9Sstevel@tonic-gate 				if (data > tail ||
391*7c478bd9Sstevel@tonic-gate 				    (&data[1] + data[0]) > tail) {
392*7c478bd9Sstevel@tonic-gate 					(void) snprintf(get_line(0, 0),
393*7c478bd9Sstevel@tonic-gate 					    get_line_remain(),
394*7c478bd9Sstevel@tonic-gate 					    "ZoneReply (short packet)");
395*7c478bd9Sstevel@tonic-gate 					return;
396*7c478bd9Sstevel@tonic-gate 				}
397*7c478bd9Sstevel@tonic-gate 				(void) snprintf(get_line(0, 0),
398*7c478bd9Sstevel@tonic-gate 				    get_line_remain(),
399*7c478bd9Sstevel@tonic-gate 				    "Zone = \"%.*s\"", data[0], &data[1]);
400*7c478bd9Sstevel@tonic-gate 				data += data[0] + 1;
401*7c478bd9Sstevel@tonic-gate 			}
402*7c478bd9Sstevel@tonic-gate 			break;
403*7c478bd9Sstevel@tonic-gate 		}
404*7c478bd9Sstevel@tonic-gate 	}
405*7c478bd9Sstevel@tonic-gate }
406