X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/bbedebc666a341d8e14922dce37a92766400c798..f08288f5a932c263aad34f1fa9cdbc00bb9edf7b:/print-arp.c diff --git a/print-arp.c b/print-arp.c index b1cc7fc7..eff97c46 100644 --- a/print-arp.c +++ b/print-arp.c @@ -19,20 +19,21 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#define NETDISSECT_REWORKED +/* \summary: Address Resolution Protocol (ARP) printer */ + #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include +#include #include -#include "interface.h" +#include "netdissect.h" #include "addrtoname.h" #include "ether.h" #include "ethertype.h" -#include "extract.h" /* must come after interface.h */ +#include "extract.h" static const char tstr[] = "[|ARP]"; @@ -176,7 +177,17 @@ struct atmarp_pkthdr { #define ATMTSA(ap) (aar_tsa(ap)) #define ATMTPA(ap) (aar_tpa(ap)) -static u_char ezero[6]; +static int +isnonzero(const u_char *a, size_t len) +{ + while (len > 0) { + if (*a != 0) + return (1); + a++; + len--; + } + return (0); +} static void atmarp_addr_print(netdissect_options *ndo, @@ -357,7 +368,7 @@ arp_print(netdissect_options *ndo, case ARPOP_REQUEST: ND_PRINT((ndo, "who-has %s", ipaddr_string(ndo, TPA(ap)))); - if (memcmp((const char *)ezero, (const char *)THA(ap), HRD_LEN(ap)) != 0) + if (isnonzero((const u_char *)THA(ap), HRD_LEN(ap))) ND_PRINT((ndo, " (%s)", linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap)))); ND_PRINT((ndo, " tell %s", ipaddr_string(ndo, SPA(ap)))); @@ -389,8 +400,8 @@ arp_print(netdissect_options *ndo, case ARPOP_INVREPLY: ND_PRINT((ndo,"%s at %s", - linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap)), - ipaddr_string(ndo, TPA(ap)))); + linkaddr_string(ndo, SHA(ap), linkaddr, HRD_LEN(ap)), + ipaddr_string(ndo, SPA(ap)))); break; default: