2 * Copyright (c) 1988-1990 The Regents of the University of California.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
24 "@(#) $Header: print-arp.c,v 1.16 91/04/19 10:45:56 mccanne Exp $ (LBL)";
27 #include <sys/param.h>
28 #include <sys/types.h>
29 #include <sys/socket.h>
31 #include <netinet/in.h>
32 #include <netinet/if_ether.h>
34 #include "interface.h"
35 #include "addrtoname.h"
38 arp_print(ap, length, caplen)
39 register struct ether_arp *ap;
43 if ((u_char *)(ap + 1) > snapend) {
47 if (length < sizeof(struct ether_arp)) {
48 (void)printf("truncated-arp");
49 default_print((u_short *)ap, length);
57 if (ap->arp_hrd != ARPHRD_ETHER
58 || (ap->arp_pro != ETHERTYPE_IP
59 && ap->arp_pro != ETHERTYPE_TRAIL)
60 || ap->arp_hln != sizeof(SHA(ap))
61 || ap->arp_pln != sizeof(SPA(ap))) {
62 (void)printf("arp-req #%d for proto #%d (%d) hardware %d (%d)",
63 ap->arp_op, ap->arp_pro, ap->arp_pln,
64 ap->arp_hrd, ap->arp_hln);
67 if (ap->arp_pro == ETHERTYPE_TRAIL)
68 (void)printf("trailer");
72 (void)printf("arp who-has %s tell %s",
73 ipaddr_string(TPA(ap)),
74 ipaddr_string(SPA(ap)));
78 (void)printf("arp reply %s is-at %s",
79 ipaddr_string(SPA(ap)),
80 etheraddr_string(SHA(ap)));
84 (void)printf("rarp who-is %s tell %s",
85 etheraddr_string(THA(ap)),
86 etheraddr_string(SHA(ap)));
90 (void)printf("rarp reply %s at %s",
91 etheraddr_string(THA(ap)),
92 ipaddr_string(TPA(ap)));
96 (void)printf("arp-%d", ap->arp_op);
97 default_print((u_short *)ap, caplen);