diff options
author | 1996-07-13 11:01:05 +0000 | |
---|---|---|
committer | 1996-07-13 11:01:05 +0000 | |
commit | c15d59eda0b5fa6112a8ab49f66d5a0bca0f4447 (patch) | |
tree | 8add2ec656b4a36769a955b631f3e434faf2e6fc /usr.sbin/tcpdump/print-arp.c | |
parent | this is clean code (diff) | |
download | wireguard-openbsd-c15d59eda0b5fa6112a8ab49f66d5a0bca0f4447.tar.xz wireguard-openbsd-c15d59eda0b5fa6112a8ab49f66d5a0bca0f4447.zip |
it is 3.2 now.
Diffstat (limited to 'usr.sbin/tcpdump/print-arp.c')
-rw-r--r-- | usr.sbin/tcpdump/print-arp.c | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/usr.sbin/tcpdump/print-arp.c b/usr.sbin/tcpdump/print-arp.c index 30cefdfe6af..ce70238085f 100644 --- a/usr.sbin/tcpdump/print-arp.c +++ b/usr.sbin/tcpdump/print-arp.c @@ -1,8 +1,7 @@ -/**//* $OpenBSD: print-arp.c,v 1.3 1996/06/10 07:47:29 deraadt Exp $ */ -/* $NetBSD: print-arp.c,v 1.2 1995/03/06 19:11:02 mycroft Exp $ */ +/* $OpenBSD: print-arp.c,v 1.4 1996/07/13 11:01:15 mickey Exp $ */ /* - * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 + * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,22 +23,32 @@ #ifndef lint static char rcsid[] = - "@(#) Header: print-arp.c,v 1.28 94/06/14 20:17:36 leres Exp (LBL)"; + "@(#) Header: print-arp.c,v 1.35 96/06/20 21:07:34 leres Exp (LBL)"; #endif #include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> +#if __STDC__ +struct mbuf; +struct rtentry; +#endif #include <net/if.h> #include <netinet/in.h> #include <netinet/if_ether.h> #include <stdio.h> +#include <string.h> #include "interface.h" #include "addrtoname.h" +#include "extract.h" /* must come after interface.h */ + +#ifndef ETHERTYPE_TRAIL +#define ETHERTYPE_TRAIL 0x1000 +#endif static u_char ezero[6]; @@ -48,8 +57,7 @@ arp_print(register const u_char *bp, int length, int caplen) { register const struct ether_arp *ap; register const struct ether_header *eh; - const u_char *p; - int pro, hrd, op; + register u_short pro, hrd, op; ap = (struct ether_arp *)bp; if ((u_char *)(ap + 1) > snapend) { @@ -61,15 +69,10 @@ arp_print(register const u_char *bp, int length, int caplen) default_print((u_char *)ap, length); return; } - /* - * Don't assume alignment. - */ - p = (u_char*)&ap->arp_pro; - pro = (p[0] << 8) | p[1]; - p = (u_char*)&ap->arp_hrd; - hrd = (p[0] << 8) | p[1]; - p = (u_char*)&ap->arp_op; - op = (p[0] << 8) | p[1]; + + pro = EXTRACT_SHORT(&ap->arp_pro); + hrd = EXTRACT_SHORT(&ap->arp_hrd); + op = EXTRACT_SHORT(&ap->arp_op); if ((pro != ETHERTYPE_IP && pro != ETHERTYPE_TRAIL) || ap->arp_hln != sizeof(SHA(ap)) @@ -86,19 +89,19 @@ arp_print(register const u_char *bp, int length, int caplen) case ARPOP_REQUEST: (void)printf("arp who-has %s", ipaddr_string(TPA(ap))); - if (bcmp((char *)ezero, (char *)THA(ap), 6) != 0) + if (memcmp((char *)ezero, (char *)THA(ap), 6) != 0) (void)printf(" (%s)", etheraddr_string(THA(ap))); (void)printf(" tell %s", ipaddr_string(SPA(ap))); - if (bcmp((char *)ESRC(eh), (char *)SHA(ap), 6) != 0) + if (memcmp((char *)ESRC(eh), (char *)SHA(ap), 6) != 0) (void)printf(" (%s)", etheraddr_string(SHA(ap))); break; case ARPOP_REPLY: (void)printf("arp reply %s", ipaddr_string(SPA(ap))); - if (bcmp((char *)ESRC(eh), (char *)SHA(ap), 6) != 0) + if (memcmp((char *)ESRC(eh), (char *)SHA(ap), 6) != 0) (void)printf(" (%s)", etheraddr_string(SHA(ap))); (void)printf(" is-at %s", etheraddr_string(SHA(ap))); - if (bcmp((char *)EDST(eh), (char *)THA(ap), 6) != 0) + if (memcmp((char *)EDST(eh), (char *)THA(ap), 6) != 0) (void)printf(" (%s)", etheraddr_string(THA(ap))); break; |