mirror of
https://github.com/the-tcpdump-group/tcpdump.git
synced 2024-11-27 12:03:44 +08:00
Put the infodelay wrapping into the remaining "XXX_if_print()" routines.
Split the Cisco HDLC printer into "chdlc_if_print()", which does the stuff expected of a low-level print routine (printing the time stamp, printing the final newline, doing the infodelay stuff) and "chdlc_print()", which doesn't do that stuff. This lets us clean up "ppp_hdlc_if_print()" a bit - it can just print the time stamp at the beginning, and do the infodelay stuff at the end, without having to treat Cisco HDLC specially by skipping the time stamp printing. (This also ensures that the time stamp is always printed, which wasn't the case before.) Print the missing final newline in "pppoe_if_print()".
This commit is contained in:
parent
2cfe2bf4a5
commit
176a3e4986
@ -18,7 +18,7 @@
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.165 2001-07-04 22:03:13 fenner Exp $ (LBL)
|
||||
* @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.166 2001-07-05 18:54:13 guy Exp $ (LBL)
|
||||
*/
|
||||
|
||||
#ifndef tcpdump_interface_h
|
||||
@ -249,6 +249,7 @@ extern void sl_bsdos_if_print(u_char *, const struct pcap_pkthdr *,
|
||||
const u_char *);
|
||||
extern void chdlc_if_print(u_char *, const struct pcap_pkthdr *,
|
||||
const u_char *);
|
||||
extern void chdlc_print(register const u_char *, u_int, u_int);
|
||||
extern void sll_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
|
||||
extern void snmp_print(const u_char *, u_int);
|
||||
extern void sunrpcrequest_print(const u_char *, u_int, const u_char *);
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.4 2001-06-15 07:39:43 itojun Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.5 2001-07-05 18:54:13 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -771,6 +771,7 @@ ieee802_11_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
|
||||
u_int HEADER_LENGTH;
|
||||
u_short extracted_ethertype;
|
||||
|
||||
++infodelay;
|
||||
ts_print(&h->ts);
|
||||
|
||||
if (caplen < IEEE802_11_FC_LEN) {
|
||||
@ -851,4 +852,7 @@ ieee802_11_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
|
||||
default_print(p, caplen);
|
||||
out:
|
||||
putchar('\n');
|
||||
--infodelay;
|
||||
if (infoprint)
|
||||
info(0);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-arcnet.c,v 1.3 2001-05-22 06:23:29 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-arcnet.c,v 1.4 2001-07-05 18:54:14 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -141,6 +141,7 @@ arcnet_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
|
||||
u_int seqid = 0;
|
||||
u_char arc_type;
|
||||
|
||||
++infodelay;
|
||||
ts_print(&h->ts);
|
||||
|
||||
if (caplen < ARC_HDRLEN) {
|
||||
@ -216,6 +217,9 @@ arcnet_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
|
||||
|
||||
out:
|
||||
putchar('\n');
|
||||
--infodelay;
|
||||
if (infoprint)
|
||||
info(0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.66 2001-06-18 08:52:53 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.67 2001-07-05 18:54:14 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -90,11 +90,15 @@ void
|
||||
ltalk_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
|
||||
{
|
||||
snapend = p + h->caplen;
|
||||
++infodelay;
|
||||
ts_print(&h->ts);
|
||||
llap_print(p, h->caplen);
|
||||
if(xflag)
|
||||
default_print(p, h->caplen);
|
||||
putchar('\n');
|
||||
--infodelay;
|
||||
if (infoprint)
|
||||
info(0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.20 2000-12-22 22:45:09 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.21 2001-07-05 18:54:14 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -53,6 +53,7 @@ atm_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
|
||||
u_int length = h->len;
|
||||
u_short ethertype;
|
||||
|
||||
++infodelay;
|
||||
ts_print(&h->ts);
|
||||
|
||||
if (caplen < 8) {
|
||||
@ -141,4 +142,7 @@ atm_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
|
||||
default_print(p, caplen);
|
||||
out:
|
||||
putchar('\n');
|
||||
--infodelay;
|
||||
if (infoprint)
|
||||
info(0);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.11 2000-10-09 01:53:19 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.12 2001-07-05 18:54:14 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -54,25 +54,38 @@ chdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
|
||||
{
|
||||
register u_int length = h->len;
|
||||
register u_int caplen = h->caplen;
|
||||
const struct ip *ip;
|
||||
u_int proto;
|
||||
|
||||
++infodelay;
|
||||
ts_print(&h->ts);
|
||||
|
||||
if (caplen < CHDLC_HDRLEN) {
|
||||
printf("[|chdlc]");
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Some printers want to get back at the link level addresses,
|
||||
* and/or check that they're not walking off the end of the packet.
|
||||
* Rather than pass them all the way down, we set these globals.
|
||||
*/
|
||||
proto = ntohs(*(u_short *)&p[2]);
|
||||
packetp = p;
|
||||
snapend = p + caplen;
|
||||
|
||||
chdlc_print(p, length, caplen);
|
||||
|
||||
putchar('\n');
|
||||
--infodelay;
|
||||
if (infoprint)
|
||||
info(0);
|
||||
}
|
||||
|
||||
void
|
||||
chdlc_print(register const u_char *p, u_int length, u_int caplen)
|
||||
{
|
||||
const struct ip *ip;
|
||||
u_int proto;
|
||||
|
||||
if (caplen < CHDLC_HDRLEN) {
|
||||
printf("[|chdlc]");
|
||||
return;
|
||||
}
|
||||
|
||||
proto = ntohs(*(u_short *)&p[2]);
|
||||
if (eflag) {
|
||||
switch (p[0]) {
|
||||
case CHDLC_UNICAST:
|
||||
@ -110,8 +123,6 @@ chdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
|
||||
}
|
||||
if (xflag)
|
||||
default_print((const u_char *)ip, caplen - CHDLC_HDRLEN);
|
||||
out:
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
struct cisco_slarp {
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.13 2001-06-08 04:48:23 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.14 2001-07-05 18:54:15 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -96,6 +96,7 @@ cip_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
|
||||
u_short extracted_ethertype;
|
||||
u_short *bp;
|
||||
|
||||
++infodelay;
|
||||
ts_print(&h->ts);
|
||||
|
||||
if (memcmp(rfcllc, p, sizeof(rfcllc))==0 && caplen < RFC1483LLC_LEN) {
|
||||
@ -155,4 +156,7 @@ cip_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
|
||||
default_print(p, caplen);
|
||||
out:
|
||||
putchar('\n');
|
||||
--infodelay;
|
||||
if (infoprint)
|
||||
info(0);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.11 2000-12-22 22:45:11 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.12 2001-07-05 18:54:15 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -81,6 +81,7 @@ lane_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
|
||||
u_short ether_type;
|
||||
u_short extracted_ethertype;
|
||||
|
||||
++infodelay;
|
||||
ts_print(&h->ts);
|
||||
|
||||
if (caplen < sizeof(struct lecdatahdr_8023)) {
|
||||
@ -136,4 +137,7 @@ lane_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
|
||||
default_print(p, caplen);
|
||||
out:
|
||||
putchar('\n');
|
||||
--infodelay;
|
||||
if (infoprint)
|
||||
info(0);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.40 2000-12-16 22:00:50 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.41 2001-07-05 18:54:15 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -113,6 +113,7 @@ null_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
|
||||
const struct ip *ip;
|
||||
u_int family;
|
||||
|
||||
++infodelay;
|
||||
ts_print(&h->ts);
|
||||
|
||||
memcpy((char *)&family, (char *)p, sizeof(family));
|
||||
@ -160,5 +161,8 @@ null_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
|
||||
if (xflag)
|
||||
default_print((const u_char *)ip, caplen - NULL_HDRLEN);
|
||||
putchar('\n');
|
||||
--infodelay;
|
||||
if (infoprint)
|
||||
info(0);
|
||||
}
|
||||
|
||||
|
25
print-ppp.c
25
print-ppp.c
@ -31,7 +31,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.61 2001-06-11 10:33:03 itojun Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.62 2001-07-05 18:54:16 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -1032,6 +1032,7 @@ ppp_if_print(u_char *user, const struct pcap_pkthdr *h,
|
||||
register u_int length = h->len;
|
||||
register u_int caplen = h->caplen;
|
||||
|
||||
++infodelay;
|
||||
ts_print(&h->ts);
|
||||
|
||||
if (caplen < PPP_HDRLEN) {
|
||||
@ -1094,6 +1095,9 @@ ppp_if_print(u_char *user, const struct pcap_pkthdr *h,
|
||||
default_print(p, caplen);
|
||||
out:
|
||||
putchar('\n');
|
||||
--infodelay;
|
||||
if (infoprint)
|
||||
info(0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1113,6 +1117,9 @@ ppp_hdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
|
||||
register u_int caplen = h->caplen;
|
||||
u_int proto;
|
||||
|
||||
++infodelay;
|
||||
ts_print(&h->ts);
|
||||
|
||||
if (caplen < 2) {
|
||||
printf("[|ppp]");
|
||||
goto out;
|
||||
@ -1134,7 +1141,6 @@ ppp_hdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
|
||||
goto out;
|
||||
}
|
||||
|
||||
ts_print(&h->ts);
|
||||
if (eflag)
|
||||
printf("%02x %02x %d ", p[0], p[1], length);
|
||||
p += 2;
|
||||
@ -1151,14 +1157,10 @@ ppp_hdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
|
||||
|
||||
case CHDLC_UNICAST:
|
||||
case CHDLC_BCAST:
|
||||
/*
|
||||
* Have the Cisco HDLC print routine do all the work.
|
||||
*/
|
||||
chdlc_if_print(user, h, p);
|
||||
return;
|
||||
chdlc_print(p, length, caplen);
|
||||
goto out;
|
||||
|
||||
default:
|
||||
ts_print(&h->ts);
|
||||
if (eflag)
|
||||
printf("%02x %02x %d ", p[0], p[1], length);
|
||||
p += 2;
|
||||
@ -1177,6 +1179,9 @@ ppp_hdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
|
||||
default_print(p, caplen);
|
||||
out:
|
||||
putchar('\n');
|
||||
--infodelay;
|
||||
if (infoprint)
|
||||
info(0);
|
||||
}
|
||||
|
||||
|
||||
@ -1231,6 +1236,7 @@ ppp_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h,
|
||||
const u_char *q;
|
||||
int i;
|
||||
|
||||
++infodelay;
|
||||
ts_print(&h->ts);
|
||||
|
||||
if (caplen < PPP_BSDI_HDRLEN) {
|
||||
@ -1372,5 +1378,8 @@ printx:
|
||||
default_print((const u_char *)p, caplen - hdrlength);
|
||||
out:
|
||||
putchar('\n');
|
||||
--infodelay;
|
||||
if (infoprint)
|
||||
info(0);
|
||||
#endif /* __bsdi__ */
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-pppoe.c,v 1.14 2001-06-20 07:40:44 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-pppoe.c,v 1.15 2001-07-05 18:54:17 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -100,6 +100,7 @@ pppoe_if_print(u_char *user, const struct pcap_pkthdr *h,
|
||||
register u_int length = h->len;
|
||||
register u_int caplen = h->caplen;
|
||||
|
||||
++infodelay;
|
||||
ts_print(&h->ts);
|
||||
|
||||
/*
|
||||
@ -111,6 +112,10 @@ pppoe_if_print(u_char *user, const struct pcap_pkthdr *h,
|
||||
snapend = p + caplen;
|
||||
|
||||
pppoe_print(p, length);
|
||||
putchar('\n');
|
||||
--infodelay;
|
||||
if (infoprint)
|
||||
info(0);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-raw.c,v 1.33 2000-10-06 04:23:13 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-raw.c,v 1.34 2001-07-05 18:54:17 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -53,6 +53,7 @@ raw_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
|
||||
u_int length = h->len;
|
||||
u_int caplen = h->caplen;
|
||||
|
||||
++infodelay;
|
||||
ts_print(&h->ts);
|
||||
|
||||
/*
|
||||
@ -71,4 +72,7 @@ raw_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
|
||||
if (xflag)
|
||||
default_print(p, caplen);
|
||||
putchar('\n');
|
||||
--infodelay;
|
||||
if (infoprint)
|
||||
info(0);
|
||||
}
|
||||
|
10
print-sl.c
10
print-sl.c
@ -21,7 +21,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-sl.c,v 1.56 2000-10-10 05:06:10 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-sl.c,v 1.57 2001-07-05 18:54:17 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -60,6 +60,7 @@ sl_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
|
||||
register u_int length = h->len;
|
||||
register const struct ip *ip;
|
||||
|
||||
++infodelay;
|
||||
ts_print(&h->ts);
|
||||
|
||||
if (caplen < SLIP_HDRLEN) {
|
||||
@ -98,6 +99,9 @@ sl_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
|
||||
default_print((u_char *)ip, caplen - SLIP_HDRLEN);
|
||||
out:
|
||||
putchar('\n');
|
||||
--infodelay;
|
||||
if (infoprint)
|
||||
info(0);
|
||||
}
|
||||
|
||||
|
||||
@ -108,6 +112,7 @@ sl_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
|
||||
register u_int length = h->len;
|
||||
register const struct ip *ip;
|
||||
|
||||
++infodelay;
|
||||
ts_print(&h->ts);
|
||||
|
||||
if (caplen < SLIP_HDRLEN) {
|
||||
@ -137,6 +142,9 @@ sl_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
|
||||
default_print((u_char *)ip, caplen - SLIP_HDRLEN);
|
||||
out:
|
||||
putchar('\n');
|
||||
--infodelay;
|
||||
if (infoprint)
|
||||
info(0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.5 2001-06-08 04:48:23 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.6 2001-07-05 18:54:18 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -110,6 +110,7 @@ sll_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
|
||||
u_short ether_type;
|
||||
u_short extracted_ethertype;
|
||||
|
||||
++infodelay;
|
||||
ts_print(&h->ts);
|
||||
|
||||
if (caplen < SLL_HDR_LEN) {
|
||||
@ -239,4 +240,7 @@ sll_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
|
||||
default_print(p, caplen);
|
||||
out:
|
||||
putchar('\n');
|
||||
--infodelay;
|
||||
if (infoprint)
|
||||
info(0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user