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 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 #include <sys/types.h>
31 #include <netinet/in.h>
35 extern char *src_name
, *dst_name
;
42 static struct socktable pt_ddp
[] = {
50 static struct socktable pt_ddp_types
[] = {
62 apple_ddp_type(struct socktable
*p
, uint16_t port
)
64 for (; p
->pt_num
!= 0; p
++) {
65 if (port
== p
->pt_num
)
72 * return the short at p, regardless of alignment
78 return (p
[0] << 8 | p
[1]);
82 * return the long at p, regardless of alignment
87 return (p
[0] << 24 | p
[1] << 16 | p
[2] << 8 | p
[3]);
91 * format a MAC address
95 print_macaddr(uint8_t *ha
, int len
)
101 p
+= snprintf(p
, sizeof (buf
) - (p
- buf
),
102 len
> 0 ? "%x:" : "%x", *ha
++);
109 interpret_at(int flags
, struct ddp_hdr
*ddp
, int len
)
114 static char src_buf
[16];
115 static char dst_buf
[16];
117 if (ddp_pad(ddp
) != 0)
118 return; /* unknown AppleTalk proto */
120 ddplen
= ddp_len(ddp
);
122 (void) snprintf(src_buf
, sizeof (src_buf
),
123 "%u.%u", ntohs(ddp
->ddp_src_net
), ddp
->ddp_src_id
);
126 (void) snprintf(dst_buf
, sizeof (dst_buf
),
127 "%u.%u", ntohs(ddp
->ddp_dest_net
), ddp
->ddp_dest_id
);
128 if (ddp
->ddp_dest_id
== NODE_ID_BROADCAST
)
129 dst_name
= "(broadcast)";
134 (void) snprintf(get_sum_line(), MAXLINE
,
135 "DDP S=%u.%u:%u D=%u.%u:%u LEN=%d",
136 ntohs(ddp
->ddp_src_net
),
139 ntohs(ddp
->ddp_dest_net
),
145 if (flags
& F_DTAIL
) {
146 show_header("DDP: ", "DDP Header", ddplen
- DDPHDR_SIZE
);
148 pname
= apple_ddp_type(pt_ddp
, ddp
->ddp_src_sock
);
152 (void) snprintf(buff
, sizeof (buff
), "(%s)", pname
);
156 (void) snprintf(get_line(0, 0), get_line_remain(),
157 "Source = %s, Socket = %u %s",
158 src_name
, ddp
->ddp_src_sock
, pname
);
159 pname
= apple_ddp_type(pt_ddp
, ddp
->ddp_dest_sock
);
163 (void) snprintf(buff
, sizeof (buff
), "(%s)", pname
);
166 (void) snprintf(get_line(0, 0), get_line_remain(),
167 "Destination = %s, Socket = %u %s",
168 dst_name
, ddp
->ddp_dest_sock
, pname
);
169 (void) snprintf(get_line(0, 0), get_line_remain(),
172 (void) snprintf(get_line(0, 0), get_line_remain(),
175 (void) snprintf(get_line(0, 0), get_line_remain(),
176 "Checksum = %04x %s",
177 ntohs(ddp
->ddp_cksum
),
178 ddp
->ddp_cksum
== 0 ? "(no checksum)" : "");
179 (void) snprintf(get_line(0, 0), get_line_remain(),
180 "DDP type = %d (%s)",
182 apple_ddp_type(pt_ddp_types
, ddp
->ddp_type
));
187 /* go to the next protocol layer */
189 switch (ddp
->ddp_type
) {
191 interpret_nbp(flags
, (struct nbp_hdr
*)ddp
, ddplen
);
194 interpret_aecho(flags
, ddp
, ddplen
);
197 interpret_atp(flags
, ddp
, ddplen
);
200 interpret_ddp_zip(flags
, (struct zip_hdr
*)ddp
, ddplen
);
203 interpret_adsp(flags
, (struct ddp_adsphdr
*)ddp
, ddplen
);
205 case DDP_TYPE_RTMPRQ
:
206 case DDP_TYPE_RTMPRESP
:
207 interpret_rtmp(flags
, ddp
, ddplen
);