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) 1991-2001 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 #include <sys/types.h>
31 #include <sys/socket.h>
33 #include <net/if_arp.h>
34 #include <netinet/in_systm.h>
35 #include <netinet/in.h>
36 #include <netinet/if_ether.h>
41 static char *printat(uint8_t *);
43 static char *aarp_opname
[] = {
51 interpret_aarp(int flags
, char *data
, int alen
)
54 struct ether_arp
*ap
= (struct ether_arp
*)data
;
56 extern char *dst_name
;
59 if (alen
< sizeof (struct ether_arp
)) {
60 (void) snprintf(get_sum_line(), MAXLINE
,
61 "AARP (short packet)");
65 switch (ntohs(ap
->arp_op
)) {
67 (void) snprintf(get_sum_line(), MAXLINE
,
69 printat(ap
->arp_tpa
));
72 (void) snprintf(get_sum_line(), MAXLINE
,
75 printether((struct ether_addr
*)&ap
->arp_sha
));
76 dst_name
= printat(ap
->arp_tpa
);
79 (void) snprintf(get_sum_line(), MAXLINE
,
81 printat(ap
->arp_tpa
));
86 if (flags
& F_DTAIL
) {
87 show_header("AARP: ", "AARP Frame", alen
);
90 if (alen
< sizeof (struct ether_arp
)) {
91 (void) snprintf(get_line(0, 0), get_line_remain(),
92 "AARP (short packet)");
96 (void) snprintf(get_line(0, 0), get_line_remain(),
99 (void) snprintf(get_line(0, 0), get_line_remain(),
100 "Protocol type = %04X (%s)",
102 print_ethertype(ntohs(ap
->arp_pro
)));
103 (void) snprintf(get_line(0, 0), get_line_remain(),
104 "Length of hardware address = %d bytes",
106 (void) snprintf(get_line(0, 0), get_line_remain(),
107 "Length of protocol address = %d bytes",
109 (void) snprintf(get_line(0, 0), get_line_remain(),
112 aarp_opname
[ntohs(ap
->arp_op
)]);
114 if (ntohs(ap
->arp_hrd
) == ARPHRD_ETHER
&&
115 ntohs(ap
->arp_pro
) == ETHERTYPE_AT
) {
116 (void) snprintf(get_line(0, 0), get_line_remain(),
117 "Sender's hardware address = %s",
118 printether((struct ether_addr
*)&ap
->arp_sha
));
119 (void) snprintf(get_line(0, 0), get_line_remain(),
120 "Sender's protocol address = %s",
121 printat(ap
->arp_spa
));
122 (void) snprintf(get_line(0, 0), get_line_remain(),
123 "Target hardware address = %s",
124 (ntohs(ap
->arp_op
) == AARP_REQ
||
125 ntohs(ap
->arp_op
) == AARP_PROBE
) ? "?" :
126 printether((struct ether_addr
*)&ap
->arp_tha
));
127 (void) snprintf(get_line(0, 0), get_line_remain(),
128 "Target protocol address = %s",
129 ntohs(ap
->arp_op
) == REVARP_REQUEST
? "?" :
130 printat(ap
->arp_tpa
));
141 (void) snprintf(buf
, sizeof (buf
), "%d.%d", get_short(&p
[1]), p
[3]);