X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/aebfcfe1f67c99367a67614a252aba3de3c8979c..f1ba3be3963a45f50dc8f47d8434ea29760138ad:/print-arp.c?ds=inline diff --git a/print-arp.c b/print-arp.c index d7f42fe4..fbc8411e 100644 --- a/print-arp.c +++ b/print-arp.c @@ -19,11 +19,6 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#ifndef lint -static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.65 2006-02-11 22:11:40 hannes Exp $ (LBL)"; -#endif - #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -39,6 +34,8 @@ static const char rcsid[] _U_ = #include "ethertype.h" #include "extract.h" /* must come after interface.h */ +static const char tstr[] = "[|ARP]"; + /* * Address Resolution Protocol. * @@ -99,7 +96,7 @@ struct arp_pkthdr { #define TPA(ap) (ar_tpa(ap)) -struct tok arpop_values[] = { +static const struct tok arpop_values[] = { { ARPOP_REQUEST, "Request" }, { ARPOP_REPLY, "Reply" }, { ARPOP_REVREQUEST, "Reverse Request" }, @@ -110,7 +107,7 @@ struct tok arpop_values[] = { { 0, NULL } }; -struct tok arphrd_values[] = { +static const struct tok arphrd_values[] = { { ARPHRD_ETHER, "Ethernet" }, { ARPHRD_IEEE802, "TokenRing" }, { ARPHRD_ARCNET, "ArcNet" }, @@ -190,7 +187,7 @@ atmarp_addr_print(netdissect_options *ndo, ND_PRINT((ndo, "")); else { ND_PRINT((ndo, "%s", linkaddr_string(ha, LINKADDR_ATM, ha_len))); - if (srca_len != 0) + if (srca_len != 0) ND_PRINT((ndo, ",%s", linkaddr_string(srca, LINKADDR_ATM, srca_len))); } @@ -211,21 +208,20 @@ atmarp_print(netdissect_options *ndo, op = ATMOP(ap); if (!ND_TTEST2(*aar_tpa(ap), ATMTPROTO_LEN(ap))) { - ND_PRINT((ndo, "[|ARP]")); + ND_PRINT((ndo, "%s", tstr)); ND_DEFAULTPRINT((const u_char *)ap, length); return; } if (!ndo->ndo_eflag) { - ND_PRINT((ndo, "ARP")); + ND_PRINT((ndo, "ARP, ")); } if ((pro != ETHERTYPE_IP && pro != ETHERTYPE_TRAIL) || ATMSPROTO_LEN(ap) != 4 || ATMTPROTO_LEN(ap) != 4 || ndo->ndo_vflag) { - ND_PRINT((ndo, "%s%s, %s (len %u/%u)", - ndo->ndo_eflag ? "" : ", ", + ND_PRINT((ndo, "%s, %s (len %u/%u)", tok2str(arphrd_values, "Unknown Hardware (%u)", hrd), tok2str(ethertype_values, "Unknown Protocol (0x%04x)", pro), ATMSPROTO_LEN(ap), @@ -238,7 +234,9 @@ atmarp_print(netdissect_options *ndo, } /* print operation */ - printf(", %s ", tok2str(arpop_values, "Unknown (%u)", op)); + printf("%s%s ", + ndo->ndo_vflag ? ", " : "", + tok2str(arpop_values, "Unknown (%u)", op)); switch (op) { @@ -288,7 +286,7 @@ atmarp_print(netdissect_options *ndo, return; trunc: - ND_PRINT((ndo, "[|ARP]")); + ND_PRINT((ndo, "%s", tstr)); } void @@ -305,7 +303,7 @@ arp_print(netdissect_options *ndo, pro = PRO(ap); op = OP(ap); - + /* if its ATM then call the ATM ARP printer for Frame-relay ARP most of the fields are similar to Ethernet so overload the Ethernet Printer @@ -317,19 +315,20 @@ arp_print(netdissect_options *ndo, return; case ARPHRD_FRELAY: linkaddr = LINKADDR_FRELAY; + break; default: linkaddr = LINKADDR_ETHER; break; } if (!ND_TTEST2(*ar_tpa(ap), PROTO_LEN(ap))) { - ND_PRINT((ndo, "[|ARP]")); + ND_PRINT((ndo, "%s", tstr)); ND_DEFAULTPRINT((const u_char *)ap, length); return; } if (!ndo->ndo_eflag) { - ND_PRINT((ndo, "ARP")); + ND_PRINT((ndo, "ARP, ")); } /* print hardware type/len and proto type/len */ @@ -337,8 +336,7 @@ arp_print(netdissect_options *ndo, PROTO_LEN(ap) != 4 || HRD_LEN(ap) == 0 || ndo->ndo_vflag) { - ND_PRINT((ndo, "%s%s (len %u), %s (len %u)", - ndo->ndo_eflag ? "" : ", ", + ND_PRINT((ndo, "%s (len %u), %s (len %u)", tok2str(arphrd_values, "Unknown Hardware (%u)", hrd), HRD_LEN(ap), tok2str(ethertype_values, "Unknown Protocol (0x%04x)", pro), @@ -351,7 +349,9 @@ arp_print(netdissect_options *ndo, } /* print operation */ - printf(", %s ", tok2str(arpop_values, "Unknown (%u)", op)); + printf("%s%s ", + ndo->ndo_vflag ? ", " : "", + tok2str(arpop_values, "Unknown (%u)", op)); switch (op) { @@ -403,7 +403,7 @@ arp_print(netdissect_options *ndo, return; trunc: - ND_PRINT((ndo, "[|ARP]")); + ND_PRINT((ndo, "%s", tstr)); } /*