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
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]
23 * Copyright (c) 2001 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 #include <sys/types.h>
35 char *print_macaddr(uint8_t *, int);
37 static char *zip_flags(char);
38 static char *zip_flags_long(char);
41 interpret_ddp_zip(int flags
, struct zip_hdr
*zip
, int len
)
48 char defzone
[60] = "";
51 uint8_t *tail
= (uint8_t *)zip
+ len
;
54 if (len
< sizeof (struct zip_hdr
))
57 switch (zip
->zip_func
) {
59 cnt
= zip
->zip_netcnt
;
60 (void) snprintf(get_sum_line(), MAXLINE
,
61 "ZIP Query CNT = %d", cnt
);
65 cnt
= zip
->zip_netcnt
;
66 (void) snprintf(get_sum_line(), MAXLINE
,
67 "ZIP Reply CNT = %d", cnt
);
69 case ZIP_GET_NET_INFO
:
72 if ((p
+6 > tail
) || (p
+7+p
[6] > tail
))
75 (void) snprintf(get_sum_line(), MAXLINE
,
76 "ZIP GNI Zone = \"%.*s\"", p
[6], &p
[7]);
78 case ZIP_GET_NET_INFO_REPLY
:
82 (void) snprintf(get_sum_line(), MAXLINE
,
83 "ZIP GNI Rep Flags 0x%x (%s)",
84 gniflags
, zip_flags(gniflags
));
87 (void) snprintf(get_sum_line(), MAXLINE
,
88 "ZIP CMD = %d", zip
->zip_func
);
93 if (flags
& F_DTAIL
) {
94 show_header("ZIP: ", "ZIP Header", len
);
97 (void) snprintf(get_line(0, 0), get_line_remain(),
100 if (len
< sizeof (struct zip_hdr
))
103 switch (zip
->zip_func
) {
105 (void) snprintf(get_line(0, 0), get_line_remain(),
106 "Query, Network count = %d", zip
->zip_netcnt
);
107 cnt
= zip
->zip_netcnt
;
108 p
= (uint8_t *)(zip
+ 1);
114 (void) snprintf(get_line(0, 0),
115 get_line_remain(), "Net = %d", net
);
120 cnt
= zip
->zip_netcnt
;
121 (void) snprintf(get_line(0, 0), get_line_remain(),
122 "Reply, Network count = %d", cnt
);
124 p
= (uint8_t *)(zip
+ 1);
130 if (p
+1 > tail
|| (&p
[1] + p
[0]) > tail
)
132 (void) snprintf(get_line(0, 0),
134 "Network = %d, Zone = \"%.*s\"",
139 case ZIP_GET_NET_INFO
:
141 if (p
+1 > tail
|| (&p
[1] + p
[0]) > tail
)
143 (void) snprintf(get_line(0, 0), get_line_remain(),
144 "GetNetInfo Zone = \"%.*s\"", p
[0], &p
[1]);
146 case ZIP_GET_NET_INFO_REPLY
:
151 net
= get_short(&p
[2]);
152 range
= get_short(&p
[4]);
154 if (p
+7 > tail
|| (&p
[7] + p
[6]) > tail
)
156 (void) snprintf(zone
, sizeof (zone
),
157 "%.*s", p
[6], &p
[7]);
160 if ((gniflags
& ZIP_FLG_USEBRC
) == 0) {
161 if (p
+1 > tail
|| (&p
[1] + p
[0]) > tail
)
163 (void) snprintf(mcast
, sizeof (mcast
),
164 "Multicast address = %s",
165 print_macaddr(&p
[1], p
[0]));
168 if (gniflags
& ZIP_FLG_ZINV
) {
170 if (p
+1 > tail
|| (&p
[1] + p
[0]) > tail
)
172 (void) snprintf(defzone
, sizeof (defzone
),
173 "Default Zone = \"%.*s\"",
176 (void) snprintf(get_line(0, 0), get_line_remain(),
177 "GetNetInfo Reply, Flags 0x%x (%s)",
178 gniflags
, zip_flags_long(gniflags
));
180 (void) snprintf(get_line(0, 0), get_line_remain(),
181 "Network number = %d-%d", net
, range
);
183 (void) snprintf(get_line(0, 0), get_line_remain(),
184 "Zone = \"%s\"", zone
);
187 (void) snprintf(get_line(0, 0),
192 (void) snprintf(get_line(0, 0),
203 net
= get_short(&p
[2]);
204 range
= get_short(&p
[4]);
206 if (p
+7 > tail
|| (&p
[7] + p
[6]) > tail
)
208 (void) snprintf(zone
, sizeof (zone
),
209 "%.*s", p
[6], &p
[7]);
212 if ((gniflags
& ZIP_FLG_USEBRC
) == 0) {
213 if (p
+1 > tail
|| (&p
[1] + p
[0]) > tail
)
215 (void) snprintf(mcast
, sizeof (mcast
),
216 "New Multicast address = %s",
217 print_macaddr(&p
[1], p
[0]));
220 if (p
+1 > tail
|| (&p
[1] + p
[0]) > tail
)
225 if (p
+1 > tail
|| (&p
[1] + p
[0]) > tail
)
228 (void) snprintf(defzone
, sizeof (defzone
),
229 "New Default Zone = \"%.*s\"",
232 (void) snprintf(get_line(0, 0), get_line_remain(),
233 "Notify, Flags 0x%x (%s)",
234 gniflags
, zip_flags_long(gniflags
));
236 (void) snprintf(get_line(0, 0), get_line_remain(),
237 "Old Zone = \"%s\"", zone
);
240 (void) snprintf(get_line(0, 0),
241 get_line_remain(), "%s", mcast
);
244 (void) snprintf(get_line(0, 0),
245 get_line_remain(), "%s", defzone
);
249 (void) snprintf(get_line(0, 0), get_line_remain(),
250 "Op = %d", zip
->zip_func
);
257 (void) snprintf(get_sum_line(), MAXLINE
,
258 "ZIP (short packet)");
260 (void) snprintf(get_line(0, 0), get_line_remain(),
261 "ZIP (short packet)");
265 zip_flags(char flags
)
269 char *tail
= &buf
[sizeof (buf
)];
273 if (flags
& ZIP_FLG_ZINV
)
274 p
+= snprintf(p
, tail
-p
, "IZ");
276 if (flags
& ZIP_FLG_USEBRC
)
277 p
+= snprintf(p
, tail
-p
, p
== buf
? "UB" : " UB");
279 if (flags
& ZIP_FLG_ONEZ
)
280 (void) snprintf(p
, tail
-p
, p
== buf
? "OOZ" : " OOZ");
286 zip_flags_long(char flags
)
290 char *tail
= &buf
[sizeof (buf
)];
294 if (flags
& ZIP_FLG_ZINV
)
295 p
+= snprintf(p
, tail
-p
, "ZoneInvalid");
297 if (flags
& ZIP_FLG_USEBRC
)
298 p
+= snprintf(p
, tail
-p
,
299 p
== buf
? "UseBroadcast" : " UseBroadcast");
301 if (flags
& ZIP_FLG_ONEZ
)
302 (void) snprintf(p
, tail
-p
,
303 p
== buf
? "OnlyOneZone" : " OnlyOneZone");
309 interpret_atp_zip(int flags
, struct atp_hdr
*atp
, int len
)
313 uint8_t *tail
= (uint8_t *)(atp
+1) + len
;
317 (void) snprintf(get_sum_line(), MAXLINE
,
318 "ZIP (short packet)");
322 switch (atp_fun(atp
->atp_ctrl
)) {
324 switch (atp
->atp_user
[0]) {
325 case ZIP_ATP_GETMYZONE
:
326 (void) snprintf(get_sum_line(), MAXLINE
,
330 case ZIP_ATP_GETZONELIST
:
331 (void) snprintf(get_sum_line(), MAXLINE
,
335 case ZIP_ATP_GETLOCALZONES
:
336 (void) snprintf(get_sum_line(), MAXLINE
,
337 "ZIP GetLocalZones");
342 cnt
= get_short(&atp
->atp_user
[2]);
343 (void) snprintf(get_sum_line(), MAXLINE
,
344 "ZIP ZoneReply, Cnt = %d", cnt
);
350 if (flags
& F_DTAIL
) {
351 show_header("ZIP: ", "ZIP Header", len
);
355 (void) snprintf(get_line(0, 0), get_line_remain(),
356 "ZIP (short packet)");
360 switch (atp_fun(atp
->atp_ctrl
)) {
362 switch (atp
->atp_user
[0]) {
363 case ZIP_ATP_GETMYZONE
:
364 (void) snprintf(get_line(0, 0),
366 "GetMyZone, Start Index = %d",
367 get_short(&atp
->atp_user
[2]));
369 case ZIP_ATP_GETZONELIST
:
370 (void) snprintf(get_line(0, 0),
372 "GetZoneList, Start Index = %d",
373 get_short(&atp
->atp_user
[2]));
375 case ZIP_ATP_GETLOCALZONES
:
376 (void) snprintf(get_line(0, 0),
378 "GetLocalZones, Start Index = %d",
379 get_short(&atp
->atp_user
[2]));
384 cnt
= get_short(&atp
->atp_user
[2]);
385 (void) snprintf(get_line(0, 0), get_line_remain(),
386 "ZoneReply, Number of Zones = %d, Length = %d",
389 data
= (uint8_t *)atp
+ DDPHDR_SIZE
+ ATPHDR_SIZE
;
393 (&data
[1] + data
[0]) > tail
) {
394 (void) snprintf(get_line(0, 0),
396 "ZoneReply (short packet)");
399 (void) snprintf(get_line(0, 0),
401 "Zone = \"%.*s\"", data
[0], &data
[1]);