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 static void show_nbp_tuples(uint8_t *, int, uint8_t *);
37 static char *nbp_short
[] = {
57 interpret_nbp(int flags
, struct nbp_hdr
*nbp
, int len
)
60 int nbp_cnt
= nbp
->nbp_fun_cnt
& 0xf; /* lower four bits */
61 int nbp_op
= (nbp
->nbp_fun_cnt
>> 4) & 0xf; /* upper four bits */
63 data
= (uint8_t *)(nbp
+ 1);
66 if (len
< sizeof (struct nbp_hdr
)) {
67 (void) snprintf(get_sum_line(), MAXLINE
,
68 "NBP (short packet)");
71 (void) snprintf(get_sum_line(), MAXLINE
,
72 "NBP F=%s CNT=%d ID=%d", nbp_short
[nbp_op
],
73 nbp_cnt
, nbp
->nbp_id
);
76 if (flags
& F_DTAIL
) {
77 show_header("NBP: ", "NBP Header", len
);
80 if (len
< sizeof (struct nbp_hdr
)) {
81 (void) snprintf(get_line(0, 0), get_line_remain(),
82 "NBP (short packet)");
85 (void) snprintf(get_line(0, 0), get_line_remain(),
88 (void) snprintf(get_line(0, 0), get_line_remain(),
89 "Func = %d (%s)", nbp_op
, nbp_short
[nbp_op
]);
91 (void) snprintf(get_line(0, 0), get_line_remain(),
92 "Tuple count = %d", nbp_cnt
);
93 (void) snprintf(get_line(0, 0), get_line_remain(),
94 "Id = %d", nbp
->nbp_id
);
95 show_nbp_tuples(data
, nbp_cnt
, ((uint8_t *)nbp
) + len
);
100 show_nbp_tuples(uint8_t *p
, int tuples
, uint8_t *tail
)
108 char *otail
= &obj
[sizeof (obj
)];
120 if (p
> tail
|| &p
[1]+p
[0] > tail
)
122 op
+= snprintf(op
, otail
-op
, "%.*s", p
[0], &p
[1]);
125 if (p
> tail
|| &p
[1]+p
[0] > tail
)
127 op
+= snprintf(op
, otail
-op
, ":%.*s", p
[0], &p
[1]);
130 if (p
> tail
|| &p
[1]+p
[0] > tail
)
132 (void) snprintf(op
, otail
-op
, "@%.*s", p
[0], &p
[1]);
135 (void) snprintf(get_line(0, 0), get_line_remain(),
136 "Name = \"%s\"", obj
);
137 (void) snprintf(get_line(0, 0), get_line_remain(),
138 "Net = %d, node = %d, sock = %d, enum = %d",
139 net
, node
, sock
, enumer
);
143 (void) snprintf(get_line(0, 0), get_line_remain(),
144 "NBP (short tuple)");