summaryrefslogtreecommitdiffstats
path: root/contrib/tcpdump/print-sll.c
diff options
context:
space:
mode:
authorsam <sam@FreeBSD.org>2005-05-29 18:17:16 +0000
committersam <sam@FreeBSD.org>2005-05-29 18:17:16 +0000
commit88a191f109e4bbf287e317e4115185aa904a7757 (patch)
treed59cebde657eda0af31fdab513367f5ad61113cd /contrib/tcpdump/print-sll.c
parent281e9d71408deb6e8c5046c746c2e97002b0e7fe (diff)
downloadFreeBSD-src-88a191f109e4bbf287e317e4115185aa904a7757.zip
FreeBSD-src-88a191f109e4bbf287e317e4115185aa904a7757.tar.gz
Virgin import of tcpdump v3.9.1 (alpha 096) from tcpdump.org
Diffstat (limited to 'contrib/tcpdump/print-sll.c')
-rw-r--r--contrib/tcpdump/print-sll.c52
1 files changed, 18 insertions, 34 deletions
diff --git a/contrib/tcpdump/print-sll.c b/contrib/tcpdump/print-sll.c
index df0ce59..aeb0610 100644
--- a/contrib/tcpdump/print-sll.c
+++ b/contrib/tcpdump/print-sll.c
@@ -20,7 +20,7 @@
*/
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.12.2.2 2003/11/16 08:51:44 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.16 2004/10/28 00:34:29 hannes Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -36,60 +36,44 @@ static const char rcsid[] _U_ =
#include "interface.h"
#include "addrtoname.h"
#include "ethertype.h"
+#include "extract.h"
#include "ether.h"
#include "sll.h"
+const struct tok sll_pkttype_values[] = {
+ { LINUX_SLL_HOST, "In" },
+ { LINUX_SLL_BROADCAST, "B" },
+ { LINUX_SLL_MULTICAST, "M" },
+ { LINUX_SLL_OTHERHOST, "P" },
+ { LINUX_SLL_OUTGOING, "Out" },
+ { 0, NULL}
+};
+
static inline void
sll_print(register const struct sll_header *sllp, u_int length)
{
- u_short halen;
-
- switch (ntohs(sllp->sll_pkttype)) {
-
- case LINUX_SLL_HOST:
- (void)printf("< ");
- break;
-
- case LINUX_SLL_BROADCAST:
- (void)printf("B ");
- break;
-
- case LINUX_SLL_MULTICAST:
- (void)printf("M ");
- break;
-
- case LINUX_SLL_OTHERHOST:
- (void)printf("P ");
- break;
-
- case LINUX_SLL_OUTGOING:
- (void)printf("> ");
- break;
-
- default:
- (void)printf("? ");
- break;
- }
+ printf("%3s ",tok2str(sll_pkttype_values,"?",EXTRACT_16BITS(&sllp->sll_pkttype)));
/*
* XXX - check the link-layer address type value?
* For now, we just assume 6 means Ethernet.
* XXX - print others as strings of hex?
*/
- halen = ntohs(sllp->sll_halen);
- if (halen == 6)
+ if (EXTRACT_16BITS(&sllp->sll_halen) == 6)
(void)printf("%s ", etheraddr_string(sllp->sll_addr));
if (!qflag)
- (void)printf("%s ", etherproto_string(sllp->sll_protocol));
- (void)printf("%d: ", length);
+ (void)printf("ethertype %s (0x%04x), length %u: ",
+ tok2str(ethertype_values,"Unknown", EXTRACT_16BITS(&sllp->sll_protocol)),
+ EXTRACT_16BITS(&sllp->sll_protocol),
+ length);
}
/*
* This is the top level routine of the printer. 'p' points to the
* Linux "cooked capture" header of the packet, 'h->ts' is the timestamp,
- * 'h->length' is the length of the packet off the wire, and 'h->caplen'
+ * 'h->len' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
*/
u_int
OpenPOWER on IntegriCloud