beginning of the raw packet data, the captured length of the raw packet
data, and the length of the link-layer header, and:
if "-e" was specified, prints all the raw packet data;
if "-e" was not specified, prints all the raw packet data past
the link-layer header, if there is any.
Use that routine in all the "xxx_if_print()" routines if "-x" was
specified.
Make "arcnet_encap_print()" static - it's not used outside
"print-arcnet.c".
Add missing info printing code to "atm_if_print()".
Print the packet data in "lane_if_print()", not in "lane_print()", as
"lane_print()" can be called from other "xxx_if_print()" routines, and
those routines will also print the packet data if "-x" was specified -
no need to print it twice.
19 files changed:
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.201 2002-12-18 08:53:18 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.202 2002-12-18 09:41:13 guy Exp $ (LBL)
*/
#ifndef tcpdump_interface_h
*/
#ifndef tcpdump_interface_h
extern void decnet_print(const u_char *, u_int, u_int);
extern void default_print(const u_char *, u_int);
extern void default_print_unaligned(const u_char *, u_int);
extern void decnet_print(const u_char *, u_int, u_int);
extern void default_print(const u_char *, u_int);
extern void default_print_unaligned(const u_char *, u_int);
+extern void default_print_packet(const u_char *, u_int, u_int);
extern void dvmrp_print(const u_char *, u_int);
extern void egp_print(const u_char *);
extern void pflog_if_print(u_char *, const struct pcap_pkthdr *,
extern void dvmrp_print(const u_char *, u_int);
extern void egp_print(const u_char *);
extern void pflog_if_print(u_char *, const struct pcap_pkthdr *,
#ifndef lint
static const char rcsid[] =
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.17 2002-12-18 08:53:19 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.18 2002-12-18 09:41:14 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#endif
#ifdef HAVE_CONFIG_H
{
u_int16_t fc;
u_int HEADER_LENGTH;
{
u_int16_t fc;
u_int HEADER_LENGTH;
+ const u_char *orig_p;
+ u_int orig_caplen;
const u_int8_t *src, *dst;
u_short extracted_ethertype;
const u_int8_t *src, *dst;
u_short extracted_ethertype;
+ /*
+ * Save the information for the full packet, so we can print
+ * everything if "-e" and "-x" are both specified.
+ */
+ orig_p = p;
+ orig_caplen = caplen;
+
+ /*
+ * Go past the 802.11 header.
+ */
length -= HEADER_LENGTH;
caplen -= HEADER_LENGTH;
p += HEADER_LENGTH;
length -= HEADER_LENGTH;
caplen -= HEADER_LENGTH;
p += HEADER_LENGTH;
- default_print(p, caplen);
+ default_print_packet(orig_p, orig_caplen, HEADER_LENGTH);
*/
#ifndef lint
static const char rcsid[] =
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-arcnet.c,v 1.11 2002-12-18 08:53:19 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-arcnet.c,v 1.12 2002-12-18 09:41:14 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#endif
#ifdef HAVE_CONFIG_H
#include "interface.h"
#include "arcnet.h"
#include "interface.h"
#include "arcnet.h"
-int arcnet_encap_print(u_char arctype, const u_char *p,
+static int arcnet_encap_print(u_char arctype, const u_char *p,
u_int length, u_int caplen);
struct tok arctypemap[] = {
u_int length, u_int caplen);
struct tok arctypemap[] = {
{
u_int caplen = h->caplen;
u_int length = h->len;
{
u_int caplen = h->caplen;
u_int length = h->len;
+ const u_char *orig_p;
+ u_int orig_caplen;
const struct arc_header *ap;
int phds, flag = 0, archdrlen = 0;
const struct arc_header *ap;
int phds, flag = 0, archdrlen = 0;
+ /*
+ * Save the information for the full packet, so we can print
+ * everything if "-e" and "-x" are both specified.
+ */
+ orig_p = p;
+ orig_caplen = caplen;
+
+ /*
+ * Go past the ARCNET header.
+ */
length -= archdrlen;
caplen -= archdrlen;
p += archdrlen;
length -= archdrlen;
caplen -= archdrlen;
p += archdrlen;
- default_print(p, caplen);
+ default_print_packet(orig_p, orig_caplen, archdrlen);
arcnet_encap_print(u_char arctype, const u_char *p,
u_int length, u_int caplen)
{
arcnet_encap_print(u_char arctype, const u_char *p,
u_int length, u_int caplen)
{
*/
#ifndef lint
static const char rcsid[] =
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.31 2002-12-18 08:53:19 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.32 2002-12-18 09:41:14 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#endif
#ifdef HAVE_CONFIG_H
default_print(p, caplen);
out:
putchar('\n');
default_print(p, caplen);
out:
putchar('\n');
+ --infodelay;
+ if (infoprint)
+ info(0);
#ifndef lint
static const char rcsid[] =
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.25 2002-12-18 08:53:20 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.26 2002-12-18 09:41:15 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#endif
#ifdef HAVE_CONFIG_H
- default_print((const u_char *)ip, caplen - CHDLC_HDRLEN);
+ default_print_packet(p, caplen, CHDLC_HDRLEN);
*/
#ifndef lint
static const char rcsid[] =
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.74 2002-12-18 08:53:21 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.75 2002-12-18 09:41:15 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#endif
#ifdef HAVE_CONFIG_H
ether_print(p, length, caplen);
/*
ether_print(p, length, caplen);
/*
- * If "-x" was specified, print stuff past the Ethernet header,
- * if there's anything to print.
+ * If "-x" was specified, print packet data in hex.
- if (xflag && caplen > ETHER_HDRLEN)
- default_print(p + ETHER_HDRLEN, caplen - ETHER_HDRLEN);
+ if (xflag)
+ default_print_packet(p, caplen, ETHER_HDRLEN);
#ifndef lint
static const char rcsid[] =
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.59 2002-12-18 08:53:21 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.60 2002-12-18 09:41:15 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#endif
#ifdef HAVE_CONFIG_H
fddi_print(p, length, caplen);
/*
fddi_print(p, length, caplen);
/*
- * If "-x" was specified, print stuff past the FDDI header,
- * if there's anything to print.
+ * If "-x" was specified, print packet data in hex.
- if (xflag && caplen > FDDI_HDRLEN)
- default_print(p + FDDI_HDRLEN, caplen - FDDI_HDRLEN);
+ if (xflag)
+ default_print_packet(p, caplen, FDDI_HDRLEN);
#ifndef lint
static const char rcsid[] =
#ifndef lint
static const char rcsid[] =
- "@(#)$Header: /tcpdump/master/tcpdump/print-fr.c,v 1.9 2002-12-18 08:53:21 guy Exp $ (LBL)";
+ "@(#)$Header: /tcpdump/master/tcpdump/print-fr.c,v 1.10 2002-12-18 09:41:16 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#endif
#ifdef HAVE_CONFIG_H
{
register u_int length = h->len;
register u_int caplen = h->caplen;
{
register u_int length = h->len;
register u_int caplen = h->caplen;
+ const u_char *orig_p;
+ u_int orig_caplen;
u_char protocol;
int layer2_len;
u_short extracted_ethertype;
u_char protocol;
int layer2_len;
u_short extracted_ethertype;
if (eflag)
fr_hdr_print(p, length);
if (eflag)
fr_hdr_print(p, length);
+ /*
+ * Save the information for the full packet, so we can print
+ * everything if "-e" and "-x" are both specified.
+ */
+ orig_p = p;
+ orig_caplen = caplen;
+
protocol = FR_PROTOCOL(p);
layer2_len = LAYER2_LEN(p);
p += layer2_len;
protocol = FR_PROTOCOL(p);
layer2_len = LAYER2_LEN(p);
p += layer2_len;
- default_print(p, caplen);
+ default_print_packet(orig_p, orig_caplen, layer2_len);
#ifndef lint
static const char rcsid[] =
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ipfc.c,v 1.2 2002-12-18 08:53:21 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ipfc.c,v 1.3 2002-12-18 09:41:16 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#endif
#ifdef HAVE_CONFIG_H
ipfc_print(p, length, caplen);
/*
ipfc_print(p, length, caplen);
/*
- * If "-x" was specified, print stuff past the Network_Header,
- * if there's anything to print.
+ * If "-x" was specified, print packet data in hex.
- if (xflag && caplen > IPFC_HDRLEN)
- default_print(p + IPFC_HDRLEN, caplen - IPFC_HDRLEN);
+ if (xflag)
+ default_print_packet(p, caplen, IPFC_HDRLEN);
#ifndef lint
static const char rcsid[] =
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.18 2002-12-18 08:53:22 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.19 2002-12-18 09:41:16 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#endif
#ifdef HAVE_CONFIG_H
+ /*
+ * Go past the LANE header.
+ */
length -= sizeof(struct lecdatahdr_8023);
caplen -= sizeof(struct lecdatahdr_8023);
ep = (struct lecdatahdr_8023 *)p;
length -= sizeof(struct lecdatahdr_8023);
caplen -= sizeof(struct lecdatahdr_8023);
ep = (struct lecdatahdr_8023 *)p;
if (!xflag && !qflag)
default_print(p, caplen);
}
if (!xflag && !qflag)
default_print(p, caplen);
}
- if (xflag)
- default_print(p, caplen);
lane_print(p, length, caplen);
lane_print(p, length, caplen);
+ /*
+ * If "-x" was specified, print packet data in hex.
+ */
+ if (xflag)
+ default_print_packet(p, caplen,
+ sizeof(struct lecdatahdr_8023));
+
putchar('\n');
--infodelay;
if (infoprint)
putchar('\n');
--infodelay;
if (infoprint)
#ifndef lint
static const char rcsid[] =
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.45 2002-12-18 08:53:22 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.46 2002-12-18 09:41:16 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#endif
#ifdef HAVE_CONFIG_H
- default_print((const u_char *)ip, caplen - NULL_HDRLEN);
+ default_print_packet(p, caplen, NULL_HDRLEN);
putchar('\n');
--infodelay;
if (infoprint)
putchar('\n');
--infodelay;
if (infoprint)
#ifndef lint
static const char rcsid[] =
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-pflog.c,v 1.5 2002-12-18 08:53:22 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-pflog.c,v 1.6 2002-12-18 09:41:17 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#endif
#ifdef HAVE_CONFIG_H
{
u_int length = h->len;
u_int caplen = h->caplen;
{
u_int length = h->len;
u_int caplen = h->caplen;
+ const u_char *orig_p;
+ u_int orig_caplen;
const struct pfloghdr *hdr;
u_int8_t af;
const struct pfloghdr *hdr;
u_int8_t af;
+ /*
+ * Save the information for the full packet, so we can print
+ * everything if "-e" and "-x" are both specified.
+ */
+ orig_p = p;
+ orig_caplen = caplen;
+
hdr = (const struct pfloghdr *)p;
if (eflag)
pflog_print(hdr);
hdr = (const struct pfloghdr *)p;
if (eflag)
pflog_print(hdr);
- default_print(p, caplen);
+ default_print_packet(orig_p, orig_caplen, PFLOG_HDRLEN);
out:
putchar('\n');
--infodelay;
out:
putchar('\n');
--infodelay;
#ifndef lint
static const char rcsid[] =
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.78 2002-12-18 08:53:23 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.79 2002-12-18 09:41:17 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#endif
#ifdef HAVE_CONFIG_H
{
register u_int length = h->len;
register u_int caplen = h->caplen;
{
register u_int length = h->len;
register u_int caplen = h->caplen;
+ const u_char *orig_p;
+ u_int orig_caplen;
u_int proto;
++infodelay;
u_int proto;
++infodelay;
+ /*
+ * Save the information for the full packet, so we can print
+ * everything if "-e" and "-x" are both specified.
+ */
+ orig_p = p;
+ orig_caplen = caplen;
+
switch (p[0]) {
case PPP_ADDRESS:
switch (p[0]) {
case PPP_ADDRESS:
- default_print(p, caplen);
+ default_print_packet(orig_p, orig_caplen, p - orig_p);
out:
putchar('\n');
--infodelay;
out:
putchar('\n');
--infodelay;
#ifdef __bsdi__
register u_int length = h->len;
register u_int caplen = h->caplen;
#ifdef __bsdi__
register u_int length = h->len;
register u_int caplen = h->caplen;
register int hdrlength;
u_int16_t ptype;
const u_char *q;
register int hdrlength;
u_int16_t ptype;
const u_char *q;
snapend = p + caplen;
hdrlength = 0;
snapend = p + caplen;
hdrlength = 0;
+ /*
+ * Save the information for the full packet, so we can print
+ * everything if "-e" and "-x" are both specified.
+ */
+ orig_p = p;
+
#if 0
if (p[0] == PPP_ADDRESS && p[1] == PPP_CONTROL) {
if (eflag)
#if 0
if (p[0] == PPP_ADDRESS && p[1] == PPP_CONTROL) {
if (eflag)
- default_print((const u_char *)p, caplen - hdrlength);
+ default_print_packet(orig_p, caplen, hdrlength);
out:
putchar('\n');
--infodelay;
out:
putchar('\n');
--infodelay;
#ifndef lint
static const char rcsid[] =
#ifndef lint
static const char rcsid[] =
-"@(#) $Header: /tcpdump/master/tcpdump/print-pppoe.c,v 1.19 2002-12-18 08:53:23 guy Exp $ (LBL)";
+"@(#) $Header: /tcpdump/master/tcpdump/print-pppoe.c,v 1.20 2002-12-18 09:41:17 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#endif
#ifdef HAVE_CONFIG_H
hdr_len = pppoe_print(p, length);
/*
hdr_len = pppoe_print(p, length);
/*
- * If "-x" was specified, print stuff past the PPPoE and PPP headers,
- * if there's anything to print.
+ * If "-x" was specified, print packet data in hex.
- if (xflag && caplen > hdr_len)
- default_print(p + hdr_len, caplen - hdr_len);
+ if (xflag)
+ default_print_packet(p, caplen, hdr_len);
#ifndef lint
static const char rcsid[] =
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-sl.c,v 1.60 2002-12-18 08:53:24 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-sl.c,v 1.61 2002-12-18 09:41:17 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#endif
#ifdef HAVE_CONFIG_H
- default_print((u_char *)ip, caplen - SLIP_HDRLEN);
+ default_print_packet(p, caplen, SLIP_HDRLEN);
out:
putchar('\n');
--infodelay;
out:
putchar('\n');
--infodelay;
ip_print((u_char *)ip, length);
if (xflag)
ip_print((u_char *)ip, length);
if (xflag)
- default_print((u_char *)ip, caplen - SLIP_HDRLEN);
+ default_print_packet(p, caplen, SLIP_HDRLEN);
out:
putchar('\n');
--infodelay;
out:
putchar('\n');
--infodelay;
*/
#ifndef lint
static const char rcsid[] =
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.10 2002-12-18 08:53:24 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.11 2002-12-18 09:41:18 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#endif
#ifdef HAVE_CONFIG_H
{
u_int caplen = h->caplen;
u_int length = h->len;
{
u_int caplen = h->caplen;
u_int length = h->len;
+ const u_char *orig_p;
+ u_int orig_caplen;
register const struct sll_header *sllp;
u_short ether_type;
u_short extracted_ethertype;
register const struct sll_header *sllp;
u_short ether_type;
u_short extracted_ethertype;
+ /*
+ * Save the information for the full packet, so we can print
+ * everything if "-e" and "-x" are both specified.
+ */
+ orig_p = p;
+ orig_caplen = caplen;
+
+ /*
+ * Go past the cooked-mode header.
+ */
length -= SLL_HDR_LEN;
caplen -= SLL_HDR_LEN;
p += SLL_HDR_LEN;
length -= SLL_HDR_LEN;
caplen -= SLL_HDR_LEN;
p += SLL_HDR_LEN;
default_print(p, caplen);
}
if (xflag)
default_print(p, caplen);
}
if (xflag)
- default_print(p, caplen);
+ default_print_packet(orig_p, orig_caplen, SLL_HDR_LEN);
out:
putchar('\n');
--infodelay;
out:
putchar('\n');
--infodelay;
*/
#ifndef lint
static const char rcsid[] =
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.20 2002-12-18 08:53:24 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.21 2002-12-18 09:41:18 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
#endif
#ifdef HAVE_CONFIG_H
hdr_len = token_print(p, length, caplen);
/*
hdr_len = token_print(p, length, caplen);
/*
- * If "-x" was specified, print stuff past the Token Ring header,
- * if there's anything to print.
+ * If "-x" was specified, print packet data in hex.
- if (xflag && caplen > hdr_len)
- default_print(p + hdr_len, caplen - hdr_len);
+ if (xflag)
+ default_print_packet(p, caplen, hdr_len);
-.\" @(#) $Header: /tcpdump/master/tcpdump/Attic/tcpdump.1,v 1.131 2002-12-05 23:59:42 hannes Exp $ (LBL)
+.\" @(#) $Header: /tcpdump/master/tcpdump/Attic/tcpdump.1,v 1.132 2002-12-18 09:41:18 guy Exp $ (LBL)
.\"
.\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1997
.\" The Regents of the University of California. All rights reserved.
.\"
.\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1997
.\" The Regents of the University of California. All rights reserved.
Standard output is used if \fIfile\fR is ``-''.
.TP
.B \-x
Standard output is used if \fIfile\fR is ``-''.
.TP
.B \-x
-Print each packet (minus its link level header) in hex.
+Print each packet (minus its link level header, unless
+.B \-e
+is specified)
+in hex.
The smaller of the entire packet or
.I snaplen
bytes will be printed. Note that this is the entire link-layer
The smaller of the entire packet or
.I snaplen
bytes will be printed. Note that this is the entire link-layer
"@(#) 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[] =
"@(#) 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[] =
- "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.189 2002-12-12 07:28:36 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.190 2002-12-18 09:41:19 guy Exp $ (LBL)";
- * By default, print the packet out in hex.
+ * By default, print the specified data out in hex.
*/
void
default_print(register const u_char *bp, register u_int length)
*/
void
default_print(register const u_char *bp, register u_int length)
default_print_unaligned(bp, length);
}
default_print_unaligned(bp, length);
}
+/*
+ * By default, print the packet out in hex; if eflag is set, print
+ * everything, otherwise print everything except for the link-layer
+ * header.
+ */
+void
+default_print_packet(register const u_char *bp, register u_int length,
+ u_int hdr_length)
+{
+ if (eflag) {
+ /*
+ * Include the link-layer header.
+ */
+ default_print_unaligned(bp, length);
+ } else {
+ /*
+ * Don't include the link-layer header - and if we have
+ * nothing past the link-layer header, print nothing.
+ */
+ if (length > hdr_length)
+ default_print_unaligned(bp + hdr_length,
+ length - hdr_length);
+ }
+}
+
#ifdef SIGINFO
RETSIGTYPE requestinfo(int signo _U_)
{
#ifdef SIGINFO
RETSIGTYPE requestinfo(int signo _U_)
{