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