X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/3838a461559e68f434712a41b68996f889ec58e0..c23f7b7dcf9c014cf531d75c22cc254c7ca35e55:/print-arcnet.c?ds=sidebyside diff --git a/print-arcnet.c b/print-arcnet.c index 1e6b2308..4250c3a1 100644 --- a/print-arcnet.c +++ b/print-arcnet.c @@ -22,7 +22,11 @@ */ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-arcnet.c,v 1.1 2001-04-17 08:39:19 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-arcnet.c,v 1.6 2001-09-17 21:57:54 fenner Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" #endif #include @@ -40,16 +44,10 @@ struct rtentry; #include "interface.h" #include "arcnet.h" -const u_char *packetp; -const u_char *snapend; - int arcnet_encap_print(u_char arctype, const u_char *p, u_int length, u_int caplen); -struct arctype_map { - const int arctype; - char * const name; -} arctypemap[] = { +struct tok arctypemap[] = { { ARCTYPE_IP_OLD, "oldip" }, { ARCTYPE_ARP_OLD, "oldarp" }, { ARCTYPE_IP, "ip" }, @@ -67,9 +65,7 @@ static inline void arcnet_print(const u_char *bp, u_int length, int phds, int flag, u_int seqid) { const struct arc_header *ap; - struct arctype_map *atmp; - char *arctypename; - char typebuf[3]; + const char *arctypename; ap = (const struct arc_header *)bp; @@ -83,16 +79,7 @@ arcnet_print(const u_char *bp, u_int length, int phds, int flag, u_int seqid) return; } - for (arctypename = NULL, atmp = arctypemap; atmp->arctype; atmp++) { - if (atmp->arctype == ap->arc_type) { - arctypename = atmp->name; - break; - } - } - if (!arctypename) { - arctypename = typebuf; - (void)snprintf(typebuf, sizeof(typebuf), "%02x", ap->arc_type); - } + arctypename = tok2str(arctypemap, "%02x", ap->arc_type); if (!phds) { (void)printf("%02x %02x %s %d: ", @@ -131,12 +118,13 @@ arcnet_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) { u_int caplen = h->caplen; u_int length = h->len; - struct arc_header *ap; + const struct arc_header *ap; - int phds, flag = 0, archdrlen; + int phds, flag = 0, archdrlen = 0; u_int seqid = 0; u_char arc_type; + ++infodelay; ts_print(&h->ts); if (caplen < ARC_HDRLEN) { @@ -144,7 +132,7 @@ arcnet_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) goto out; } - ap = (struct arc_header *)p; + ap = (const struct arc_header *)p; arc_type = ap->arc_type; switch (arc_type) { @@ -212,6 +200,9 @@ arcnet_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) out: putchar('\n'); + --infodelay; + if (infoprint) + info(0); } /*