summaryrefslogtreecommitdiffstats
path: root/contrib/tcpdump/tcpdump.c
diff options
context:
space:
mode:
authorsam <sam@FreeBSD.org>2006-09-04 20:04:42 +0000
committersam <sam@FreeBSD.org>2006-09-04 20:04:42 +0000
commit498672d44881880f8839eb7839500652b77e08b9 (patch)
tree13652f8bd7a5a6bc4657d530dd6ddfbeef554e16 /contrib/tcpdump/tcpdump.c
parent6dcc5281a5e8c0e636fcbf5736a3125dd9d14880 (diff)
downloadFreeBSD-src-498672d44881880f8839eb7839500652b77e08b9.zip
FreeBSD-src-498672d44881880f8839eb7839500652b77e08b9.tar.gz
Import of tcpdump v3.9.4
Diffstat (limited to 'contrib/tcpdump/tcpdump.c')
-rw-r--r--contrib/tcpdump/tcpdump.c57
1 files changed, 44 insertions, 13 deletions
diff --git a/contrib/tcpdump/tcpdump.c b/contrib/tcpdump/tcpdump.c
index 6c47f50..b7bedfe 100644
--- a/contrib/tcpdump/tcpdump.c
+++ b/contrib/tcpdump/tcpdump.c
@@ -30,7 +30,7 @@ static const char copyright[] _U_ =
"@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\
The Regents of the University of California. All rights reserved.\n";
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.253.2.8 2005/07/05 21:09:05 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.253.2.11 2005/08/23 10:29:41 hannes Exp $ (LBL)";
#endif
/*
@@ -253,6 +253,18 @@ static struct printer printers[] = {
#ifdef DLT_JUNIPER_SERVICES
{ juniper_services_print, DLT_JUNIPER_SERVICES },
#endif
+#ifdef DLT_JUNIPER_ETHER
+ { juniper_ether_print, DLT_JUNIPER_ETHER },
+#endif
+#ifdef DLT_JUNIPER_PPP
+ { juniper_ppp_print, DLT_JUNIPER_PPP },
+#endif
+#ifdef DLT_JUNIPER_FRELAY
+ { juniper_frelay_print, DLT_JUNIPER_FRELAY },
+#endif
+#ifdef DLT_JUNIPER_CHDLC
+ { juniper_chdlc_print, DLT_JUNIPER_CHDLC },
+#endif
{ NULL, 0 },
};
@@ -492,8 +504,6 @@ main(int argc, char **argv)
break;
case 'A':
- ++xflag;
- ++Xflag;
++Aflag;
break;
@@ -655,6 +665,7 @@ main(int argc, char **argv)
case 'q':
++qflag;
+ ++suppress_default_print;
break;
case 'r':
@@ -735,10 +746,12 @@ main(int argc, char **argv)
case 'x':
++xflag;
+ ++suppress_default_print;
break;
case 'X':
++Xflag;
+ ++suppress_default_print;
break;
case 'y':
@@ -1224,9 +1237,28 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
snapend = sp + h->caplen;
hdrlen = (*print_info->printer)(h, sp);
- if (xflag) {
+ if (Xflag) {
/*
- * Print the raw packet data.
+ * Print the raw packet data in hex and ASCII.
+ */
+ if (Xflag > 1) {
+ /*
+ * Include the link-layer header.
+ */
+ hex_and_ascii_print("\n\t", sp, h->caplen);
+ } else {
+ /*
+ * Don't include the link-layer header - and if
+ * we have nothing past the link-layer header,
+ * print nothing.
+ */
+ if (h->caplen > hdrlen)
+ hex_and_ascii_print("\n\t", sp + hdrlen,
+ h->caplen - hdrlen);
+ }
+ } else if (xflag) {
+ /*
+ * Print the raw packet data in hex.
*/
if (xflag > 1) {
/*
@@ -1243,15 +1275,15 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
hex_print("\n\t", sp + hdrlen,
h->caplen - hdrlen);
}
- } else if (Xflag) {
+ } else if (Aflag) {
/*
- * Print the raw packet data.
+ * Print the raw packet data in ASCII.
*/
- if (Xflag > 1) {
+ if (Aflag > 1) {
/*
* Include the link-layer header.
*/
- ascii_print("\n\t", sp, h->caplen);
+ ascii_print(sp, h->caplen);
} else {
/*
* Don't include the link-layer header - and if
@@ -1259,8 +1291,7 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
* print nothing.
*/
if (h->caplen > hdrlen)
- ascii_print("\n\t", sp + hdrlen,
- h->caplen - hdrlen);
+ ascii_print(sp + hdrlen, h->caplen - hdrlen);
}
}
@@ -1299,12 +1330,12 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
#endif
/*
- * By default, print the specified data out in hex.
+ * By default, print the specified data out in hex and ASCII.
*/
static void
ndo_default_print(netdissect_options *ndo _U_, const u_char *bp, u_int length)
{
- ascii_print("\n\t", bp, length); /* pass on lf and identation string */
+ hex_and_ascii_print("\n\t", bp, length); /* pass on lf and identation string */
}
void
OpenPOWER on IntegriCloud