diff options
Diffstat (limited to 'contrib/tcpdump/tcpdump.c')
-rw-r--r-- | contrib/tcpdump/tcpdump.c | 57 |
1 files changed, 44 insertions, 13 deletions
diff --git a/contrib/tcpdump/tcpdump.c b/contrib/tcpdump/tcpdump.c index 3263824..1730463 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 /* $FreeBSD$ */ @@ -255,6 +255,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 }, }; @@ -494,8 +506,6 @@ main(int argc, char **argv) break; case 'A': - ++xflag; - ++Xflag; ++Aflag; break; @@ -657,6 +667,7 @@ main(int argc, char **argv) case 'q': ++qflag; + ++suppress_default_print; break; case 'r': @@ -737,10 +748,12 @@ main(int argc, char **argv) case 'x': ++xflag; + ++suppress_default_print; break; case 'X': ++Xflag; + ++suppress_default_print; break; case 'y': @@ -1226,9 +1239,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) { /* @@ -1245,15 +1277,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 @@ -1261,8 +1293,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); } } @@ -1301,12 +1332,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 |