mirror of
https://github.com/the-tcpdump-group/tcpdump.git
synced 2024-11-27 03:53:53 +08:00
We no longer use "packetp" for anything, so eliminate it. (If any
dissector really needs source and destination MAC addresses, we should make global pointers to them - which would be null for packets lacking MAC addresses, so dissectors that need them will need to do something sensible if those pointers are null.) Don't fake up an Ethernet header if there aren't any MAC addresses to use when faking it up. "bp_chaddr" in "print-bootp.c" is an array, so "bp->bp_chaddr" cannot be null, and there's no need to test for it not being null.
This commit is contained in:
parent
c284d10cf4
commit
e070cf232f
@ -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.200 2002-12-13 00:40:34 hannes Exp $ (LBL)
|
||||
* @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.201 2002-12-18 08:53:18 guy Exp $ (LBL)
|
||||
*/
|
||||
|
||||
#ifndef tcpdump_interface_h
|
||||
@ -129,8 +129,7 @@ extern char *program_name; /* used to generate self-identifying messages */
|
||||
extern int32_t thiszone; /* seconds offset from gmt to local time */
|
||||
|
||||
extern int snaplen;
|
||||
/* global pointers to beginning and end of current packet (during printing) */
|
||||
extern const u_char *packetp;
|
||||
/* global pointer to end of current packet (during printing) */
|
||||
extern const u_char *snapend;
|
||||
|
||||
/*
|
||||
|
100
print-802_11.c
100
print-802_11.c
@ -22,7 +22,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.16 2002-12-17 09:13:45 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.17 2002-12-18 08:53:19 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -590,7 +590,9 @@ static int ctrl_body_print(u_int16_t fc, const u_char *p)
|
||||
* 1 | 1 | RA | TA | DA | SA
|
||||
*/
|
||||
|
||||
static void data_header_print(u_int16_t fc, const u_char *p)
|
||||
static void
|
||||
data_header_print(u_int16_t fc, const u_char *p, const u_int8_t **srcp,
|
||||
const u_int8_t **dstp)
|
||||
{
|
||||
#define ADDR1 (p + 4)
|
||||
#define ADDR2 (p + 10)
|
||||
@ -598,23 +600,49 @@ static void data_header_print(u_int16_t fc, const u_char *p)
|
||||
#define ADDR4 (p + 24)
|
||||
|
||||
if (!FC_TO_DS(fc)) {
|
||||
if (!FC_FROM_DS(fc))
|
||||
if (!FC_FROM_DS(fc)) {
|
||||
if (srcp != NULL)
|
||||
*srcp = ADDR2;
|
||||
if (dstp != NULL)
|
||||
*dstp = ADDR1;
|
||||
if (!eflag)
|
||||
return;
|
||||
printf("DA:%s SA:%s BSSID:%s ",
|
||||
etheraddr_string(ADDR1), etheraddr_string(ADDR2),
|
||||
etheraddr_string(ADDR3));
|
||||
else
|
||||
} else {
|
||||
if (srcp != NULL)
|
||||
*srcp = ADDR3;
|
||||
if (dstp != NULL)
|
||||
*dstp = ADDR1;
|
||||
if (!eflag)
|
||||
return;
|
||||
printf("DA:%s BSSID:%s SA:%s ",
|
||||
etheraddr_string(ADDR1), etheraddr_string(ADDR2),
|
||||
etheraddr_string(ADDR3));
|
||||
}
|
||||
} else {
|
||||
if (!FC_FROM_DS(fc))
|
||||
if (!FC_FROM_DS(fc)) {
|
||||
if (srcp != NULL)
|
||||
*srcp = ADDR2;
|
||||
if (dstp != NULL)
|
||||
*dstp = ADDR3;
|
||||
if (!eflag)
|
||||
return;
|
||||
printf("BSSID:%s SA:%s DA:%s ",
|
||||
etheraddr_string(ADDR1), etheraddr_string(ADDR2),
|
||||
etheraddr_string(ADDR3));
|
||||
else
|
||||
} else {
|
||||
if (srcp != NULL)
|
||||
*srcp = ADDR4;
|
||||
if (dstp != NULL)
|
||||
*dstp = ADDR3;
|
||||
if (!eflag)
|
||||
return;
|
||||
printf("RA:%s TA:%s DA:%s SA:%s ",
|
||||
etheraddr_string(ADDR1), etheraddr_string(ADDR2),
|
||||
etheraddr_string(ADDR3), etheraddr_string(ADDR4));
|
||||
}
|
||||
}
|
||||
|
||||
#undef ADDR1
|
||||
@ -624,17 +652,35 @@ static void data_header_print(u_int16_t fc, const u_char *p)
|
||||
}
|
||||
|
||||
|
||||
static void mgmt_header_print(const u_char *p)
|
||||
static void
|
||||
mgmt_header_print(const u_char *p, const u_int8_t **srcp,
|
||||
const u_int8_t **dstp)
|
||||
{
|
||||
const struct mgmt_header_t *hp = (const struct mgmt_header_t *) p;
|
||||
|
||||
if (srcp != NULL)
|
||||
*srcp = hp->sa;
|
||||
if (dstp != NULL)
|
||||
*dstp = hp->da;
|
||||
if (!eflag)
|
||||
return;
|
||||
|
||||
printf("BSSID:%s DA:%s SA:%s ",
|
||||
etheraddr_string((hp)->bssid), etheraddr_string((hp)->da),
|
||||
etheraddr_string((hp)->sa));
|
||||
}
|
||||
|
||||
static void ctrl_header_print(u_int16_t fc, const u_char *p)
|
||||
static void
|
||||
ctrl_header_print(u_int16_t fc, const u_char *p, const u_int8_t **srcp,
|
||||
const u_int8_t **dstp)
|
||||
{
|
||||
if (srcp != NULL)
|
||||
*srcp = NULL;
|
||||
if (dstp != NULL)
|
||||
*dstp = NULL;
|
||||
if (!eflag)
|
||||
return;
|
||||
|
||||
switch (FC_SUBTYPE(fc)) {
|
||||
case CTRL_PS_POLL:
|
||||
printf("BSSID:%s TA:%s ",
|
||||
@ -666,6 +712,7 @@ static void ctrl_header_print(u_int16_t fc, const u_char *p)
|
||||
break;
|
||||
default:
|
||||
printf("(H) Unknown Ctrl Subtype");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -718,27 +765,32 @@ static int GetHeaderLength(u_int16_t fc)
|
||||
}
|
||||
|
||||
/*
|
||||
* Print the 802.11 MAC header
|
||||
* Print the 802.11 MAC header if eflag is set, and set "*srcp" and "*dstp"
|
||||
* to point to the source and destination MAC addresses in any case if
|
||||
* "srcp" and "dstp" aren't null.
|
||||
*/
|
||||
static inline void
|
||||
ieee_802_11_hdr_print(u_int16_t fc, const u_char *p)
|
||||
ieee_802_11_hdr_print(u_int16_t fc, const u_char *p, const u_int8_t **srcp,
|
||||
const u_int8_t **dstp)
|
||||
{
|
||||
switch (FC_TYPE(fc)) {
|
||||
case T_MGMT:
|
||||
mgmt_header_print(p);
|
||||
mgmt_header_print(p, srcp, dstp);
|
||||
break;
|
||||
|
||||
case T_CTRL:
|
||||
ctrl_header_print(fc, p);
|
||||
ctrl_header_print(fc, p, srcp, dstp);
|
||||
break;
|
||||
|
||||
case T_DATA:
|
||||
data_header_print(fc, p);
|
||||
data_header_print(fc, p, srcp, dstp);
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("(header) unknown IEEE802.11 frame type (%d)",
|
||||
FC_TYPE(fc));
|
||||
*srcp = NULL;
|
||||
*dstp = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -748,6 +800,7 @@ ieee802_11_print(const u_char *p, u_int length, u_int caplen)
|
||||
{
|
||||
u_int16_t fc;
|
||||
u_int HEADER_LENGTH;
|
||||
const u_int8_t *src, *dst;
|
||||
u_short extracted_ethertype;
|
||||
|
||||
if (caplen < IEEE802_11_FC_LEN) {
|
||||
@ -763,15 +816,13 @@ ieee802_11_print(const u_char *p, u_int length, u_int caplen)
|
||||
return;
|
||||
}
|
||||
|
||||
if (eflag)
|
||||
ieee_802_11_hdr_print(fc, p);
|
||||
ieee_802_11_hdr_print(fc, p, &src, &dst);
|
||||
|
||||
/*
|
||||
* Some printers want to get back at the ethernet 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.
|
||||
* Some printers want to check that they're not walking off the
|
||||
* end of the packet.
|
||||
* Rather than pass it all the way down, we set this global.
|
||||
*/
|
||||
packetp = p;
|
||||
snapend = p + caplen;
|
||||
|
||||
length -= HEADER_LENGTH;
|
||||
@ -780,8 +831,8 @@ ieee802_11_print(const u_char *p, u_int length, u_int caplen)
|
||||
|
||||
switch (FC_TYPE(fc)) {
|
||||
case T_MGMT:
|
||||
if (!mgmt_body_print(fc, (const struct mgmt_header_t *)packetp,
|
||||
p)) {
|
||||
if (!mgmt_body_print(fc,
|
||||
(const struct mgmt_header_t *)(p - HEADER_LENGTH), p)) {
|
||||
printf("[|802.11]");
|
||||
return;
|
||||
}
|
||||
@ -802,14 +853,15 @@ ieee802_11_print(const u_char *p, u_int length, u_int caplen)
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (llc_print(p, length, caplen, packetp + 10,
|
||||
packetp + 4, &extracted_ethertype) == 0) {
|
||||
if (llc_print(p, length, caplen, dst, src,
|
||||
&extracted_ethertype) == 0) {
|
||||
/*
|
||||
* Some kinds of LLC packet we cannot
|
||||
* handle intelligently
|
||||
*/
|
||||
if (!eflag)
|
||||
ieee_802_11_hdr_print(fc, p - HEADER_LENGTH);
|
||||
ieee_802_11_hdr_print(fc, p - HEADER_LENGTH,
|
||||
NULL, NULL);
|
||||
if (extracted_ethertype) {
|
||||
printf("(LLC %s) ",
|
||||
etherproto_string(htons(extracted_ethertype)));
|
||||
|
@ -22,7 +22,7 @@
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-arcnet.c,v 1.10 2002-09-05 21:25:37 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-arcnet.c,v 1.11 2002-12-18 08:53:19 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -168,11 +168,10 @@ arcnet_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p)
|
||||
arcnet_print(p, length, phds, flag, seqid);
|
||||
|
||||
/*
|
||||
* Some printers want to get back at the ethernet 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.
|
||||
* Some printers want to check that they're not walking off the
|
||||
* end of the packet.
|
||||
* Rather than pass it all the way down, we set this global.
|
||||
*/
|
||||
packetp = p;
|
||||
snapend = p + caplen;
|
||||
|
||||
length -= archdrlen;
|
||||
|
22
print-atm.c
22
print-atm.c
@ -20,7 +20,7 @@
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.30 2002-12-11 06:55:08 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.31 2002-12-18 08:53:19 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -49,27 +49,9 @@ static const char rcsid[] =
|
||||
static void
|
||||
atm_llc_print(const u_char *p, int length, int caplen)
|
||||
{
|
||||
struct ether_header ehdr;
|
||||
u_short extracted_ethertype;
|
||||
|
||||
/*
|
||||
* Fake up an Ethernet header for the benefit of printers that
|
||||
* insist on "packetp" pointing to an Ethernet header.
|
||||
*/
|
||||
memset(&ehdr, '\0', sizeof ehdr);
|
||||
|
||||
/*
|
||||
* Some printers want to get back at the ethernet addresses.
|
||||
* Rather than pass it all the way down, we set this global.
|
||||
*
|
||||
* Actually, the only printers that use packetp are print-arp.c
|
||||
* and print-bootp.c, and they assume that packetp points to an
|
||||
* Ethernet header. The right thing to do is to fix them to know
|
||||
* which link type is in use when they excavate. XXX
|
||||
*/
|
||||
packetp = (u_char *)&ehdr;
|
||||
|
||||
if (!llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
|
||||
if (!llc_print(p, length, caplen, NULL, NULL,
|
||||
&extracted_ethertype)) {
|
||||
/* ether_type not known, print raw packet */
|
||||
if (extracted_ethertype) {
|
||||
|
@ -22,7 +22,7 @@
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.68 2002-12-11 07:13:58 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.69 2002-12-18 08:53:20 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -123,19 +123,8 @@ bootp_print(register const u_char *cp, u_short sport, u_short dport, u_int lengt
|
||||
|
||||
/* Client's Ethernet address */
|
||||
if (bp->bp_htype == 1 && bp->bp_hlen == 6) {
|
||||
register const struct ether_header *eh;
|
||||
register const char *e;
|
||||
|
||||
TCHECK2(bp->bp_chaddr[0], 6);
|
||||
eh = (const struct ether_header *)packetp;
|
||||
if (bp->bp_op == BOOTREQUEST)
|
||||
e = (const char *)ESRC(eh);
|
||||
else if (bp->bp_op == BOOTREPLY)
|
||||
e = (const char *)EDST(eh);
|
||||
else
|
||||
e = NULL;
|
||||
if ( bp->bp_chaddr != NULL )
|
||||
printf("\n\t Client Ethernet Address: %s", etheraddr_string(bp->bp_chaddr));
|
||||
printf("\n\t Client Ethernet Address: %s", etheraddr_string(bp->bp_chaddr));
|
||||
}
|
||||
|
||||
TCHECK2(bp->bp_sname[0], 1); /* check first char only */
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.24 2002-12-11 07:13:58 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.25 2002-12-18 08:53:20 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -54,11 +54,10 @@ chdlc_if_print(u_char *user _U_, const struct pcap_pkthdr *h,
|
||||
ts_print(&h->ts);
|
||||
|
||||
/*
|
||||
* 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.
|
||||
* Some printers want to check that they're not walking off the
|
||||
* end of the packet.
|
||||
* Rather than pass it all the way down, we set this global.
|
||||
*/
|
||||
packetp = p;
|
||||
snapend = p + caplen;
|
||||
|
||||
chdlc_print(p, length, caplen);
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.19 2002-09-05 21:25:38 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.20 2002-12-18 08:53:20 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -85,11 +85,10 @@ cip_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p)
|
||||
cip_print(length);
|
||||
|
||||
/*
|
||||
* Some printers want to get back at the ethernet 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.
|
||||
* Some printers want to check that they're not walking off the
|
||||
* end of the packet.
|
||||
* Rather than pass it all the way down, we set this global.
|
||||
*/
|
||||
packetp = p;
|
||||
snapend = p + caplen;
|
||||
|
||||
if (memcmp(rfcllc, p, sizeof(rfcllc)) == 0) {
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.73 2002-09-05 21:25:40 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.74 2002-12-18 08:53:21 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -38,7 +38,6 @@ static const char rcsid[] =
|
||||
|
||||
#include "ether.h"
|
||||
|
||||
const u_char *packetp;
|
||||
const u_char *snapend;
|
||||
|
||||
static inline void
|
||||
@ -76,11 +75,10 @@ ether_print(const u_char *p, u_int length, u_int caplen)
|
||||
ether_hdr_print(p, length);
|
||||
|
||||
/*
|
||||
* Some printers want to get back at the ethernet 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.
|
||||
* Some printers want to check that they're not walking off the
|
||||
* end of the packet.
|
||||
* Rather than pass it all the way down, we set this global.
|
||||
*/
|
||||
packetp = p;
|
||||
snapend = p + caplen;
|
||||
|
||||
length -= ETHER_HDRLEN;
|
||||
|
17
print-fddi.c
17
print-fddi.c
@ -21,7 +21,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.58 2002-09-05 21:25:40 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.59 2002-12-18 08:53:21 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -249,23 +249,18 @@ fddi_print(const u_char *p, u_int length, u_int caplen)
|
||||
printf("[|fddi]");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the FDDI addresses into a canonical form
|
||||
*/
|
||||
extract_fddi_addrs(fddip, (char *)ESRC(&ehdr), (char *)EDST(&ehdr));
|
||||
|
||||
/*
|
||||
* 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.
|
||||
* Some printers want to check that they're not walking off the
|
||||
* end of the packet.
|
||||
* Rather than pass it all the way down, we set this global.
|
||||
*/
|
||||
snapend = p + caplen;
|
||||
/*
|
||||
* Actually, the only printers that use packetp are print-arp.c
|
||||
* and print-bootp.c, and they assume that packetp points to an
|
||||
* Ethernet header. The right thing to do is to fix them to know
|
||||
* which link type is in use when they excavate. XXX
|
||||
*/
|
||||
packetp = (u_char *)&ehdr;
|
||||
|
||||
if (eflag)
|
||||
fddi_hdr_print(fddip, length, ESRC(&ehdr), EDST(&ehdr));
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#)$Header: /tcpdump/master/tcpdump/print-fr.c,v 1.8 2002-12-11 07:14:00 guy Exp $ (LBL)";
|
||||
"@(#)$Header: /tcpdump/master/tcpdump/print-fr.c,v 1.9 2002-12-18 08:53:21 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -231,11 +231,10 @@ fr_if_print(u_char *user _U_, const struct pcap_pkthdr *h,
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
* Some printers want to check that they're not walking off the
|
||||
* end of the packet.
|
||||
* Rather than pass it all the way down, we set this global.
|
||||
*/
|
||||
packetp = p;
|
||||
snapend = p + caplen;
|
||||
|
||||
if (eflag)
|
||||
|
16
print-ipfc.c
16
print-ipfc.c
@ -21,7 +21,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-ipfc.c,v 1.1 2002-10-18 09:17:48 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-ipfc.c,v 1.2 2002-12-18 08:53:21 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -92,19 +92,13 @@ ipfc_print(const u_char *p, u_int length, u_int caplen)
|
||||
* Get the network addresses into a canonical form
|
||||
*/
|
||||
extract_ipfc_addrs(ipfcp, (char *)ESRC(&ehdr), (char *)EDST(&ehdr));
|
||||
|
||||
/*
|
||||
* 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.
|
||||
* Some printers want to check that they're not walking off the
|
||||
* end of the packet.
|
||||
* Rather than pass it all the way down, we set this global.
|
||||
*/
|
||||
snapend = p + caplen;
|
||||
/*
|
||||
* Actually, the only printers that use packetp are print-arp.c
|
||||
* and print-bootp.c, and they assume that packetp points to an
|
||||
* Ethernet header. The right thing to do is to fix them to know
|
||||
* which link type is in use when they excavate. XXX
|
||||
*/
|
||||
packetp = (u_char *)&ehdr;
|
||||
|
||||
if (eflag)
|
||||
ipfc_hdr_print(ipfcp, length, ESRC(&ehdr), EDST(&ehdr));
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.17 2002-12-11 07:14:04 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.18 2002-12-18 08:53:22 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -122,11 +122,10 @@ lane_print(const u_char *p, u_int length, u_int caplen)
|
||||
lane_hdr_print(p, length);
|
||||
|
||||
/*
|
||||
* Some printers want to get back at the ethernet 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.
|
||||
* Some printers want to check that they're not walking off the
|
||||
* end of the packet.
|
||||
* Rather than pass it all the way down, we set this global.
|
||||
*/
|
||||
packetp = p + 2; /* skip the LECID */
|
||||
snapend = p + caplen;
|
||||
|
||||
length -= sizeof(struct lecdatahdr_8023);
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.44 2002-09-05 21:25:44 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.45 2002-12-18 08:53:22 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -121,11 +121,10 @@ null_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p)
|
||||
family = SWAPLONG(family);
|
||||
|
||||
/*
|
||||
* 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.
|
||||
* Some printers want to check that they're not walking off the
|
||||
* end of the packet.
|
||||
* Rather than pass it all the way down, we set this global.
|
||||
*/
|
||||
packetp = p;
|
||||
snapend = p + caplen;
|
||||
|
||||
length -= NULL_HDRLEN;
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-pflog.c,v 1.4 2002-09-05 21:25:44 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-pflog.c,v 1.5 2002-12-18 08:53:22 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -113,11 +113,10 @@ pflog_if_print(u_char *user _U_, const struct pcap_pkthdr *h,
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
* Some printers want to check that they're not walking off the
|
||||
* end of the packet.
|
||||
* Rather than pass it all the way down, we set this global.
|
||||
*/
|
||||
packetp = p;
|
||||
snapend = p + caplen;
|
||||
|
||||
hdr = (const struct pfloghdr *)p;
|
||||
|
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.77 2002-11-03 23:04:07 hannes Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.78 2002-12-18 08:53:23 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -1056,11 +1056,10 @@ ppp_if_print(u_char *user _U_, const struct pcap_pkthdr *h,
|
||||
}
|
||||
|
||||
/*
|
||||
* 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. */
|
||||
|
||||
packetp = p;
|
||||
* Some printers want to check that they're not walking off the
|
||||
* end of the packet.
|
||||
* Rather than pass it all the way down, we set this global.
|
||||
*/
|
||||
snapend = p + caplen;
|
||||
|
||||
#if 0
|
||||
@ -1141,11 +1140,10 @@ ppp_hdlc_if_print(u_char *user _U_, const struct pcap_pkthdr *h,
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
* Some printers want to check that they're not walking off the
|
||||
* end of the packet.
|
||||
* Rather than pass it all the way down, we set this global.
|
||||
*/
|
||||
packetp = p;
|
||||
snapend = p + caplen;
|
||||
|
||||
switch (p[0]) {
|
||||
@ -1222,11 +1220,10 @@ ppp_bsdos_if_print(u_char *user _U_, const struct pcap_pkthdr *h _U_,
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
* Some printers want to check that they're not walking off the
|
||||
* end of the packet.
|
||||
* Rather than pass it all the way down, we set this global.
|
||||
*/
|
||||
packetp = p;
|
||||
snapend = p + caplen;
|
||||
hdrlength = 0;
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-pppoe.c,v 1.18 2002-09-05 21:25:45 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-pppoe.c,v 1.19 2002-12-18 08:53:23 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -101,11 +101,10 @@ pppoe_if_print(u_char *user _U_, const struct pcap_pkthdr *h,
|
||||
ts_print(&h->ts);
|
||||
|
||||
/*
|
||||
* 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.
|
||||
* Some printers want to check that they're not walking off the
|
||||
* end of the packet.
|
||||
* Rather than pass it all the way down, we set this global.
|
||||
*/
|
||||
packetp = p;
|
||||
snapend = p + caplen;
|
||||
|
||||
hdr_len = pppoe_print(p, length);
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-raw.c,v 1.37 2002-09-05 21:25:46 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-raw.c,v 1.38 2002-12-18 08:53:23 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -51,11 +51,10 @@ raw_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p)
|
||||
ts_print(&h->ts);
|
||||
|
||||
/*
|
||||
* 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.
|
||||
* Some printers want to check that they're not walking off the
|
||||
* end of the packet.
|
||||
* Rather than pass it all the way down, we set this global.
|
||||
*/
|
||||
packetp = p;
|
||||
snapend = p + caplen;
|
||||
|
||||
if (eflag)
|
||||
|
18
print-sl.c
18
print-sl.c
@ -21,7 +21,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-sl.c,v 1.59 2002-09-05 21:25:47 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-sl.c,v 1.60 2002-12-18 08:53:24 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -62,12 +62,12 @@ sl_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p)
|
||||
printf("[|slip]");
|
||||
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.
|
||||
* Some printers want to check that they're not walking off the
|
||||
* end of the packet.
|
||||
* Rather than pass it all the way down, we set this global.
|
||||
*/
|
||||
packetp = p;
|
||||
snapend = p + caplen;
|
||||
|
||||
length -= SLIP_HDRLEN;
|
||||
@ -114,12 +114,12 @@ sl_bsdos_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p
|
||||
printf("[|slip]");
|
||||
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.
|
||||
* Some printers want to check that they're not walking off the
|
||||
* end of the packet.
|
||||
* Rather than pass it all the way down, we set this global.
|
||||
*/
|
||||
packetp = p;
|
||||
snapend = p + caplen;
|
||||
|
||||
length -= SLIP_HDRLEN;
|
||||
|
60
print-sll.c
60
print-sll.c
@ -20,7 +20,7 @@
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.9 2002-09-05 21:25:48 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.10 2002-12-18 08:53:24 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -98,8 +98,6 @@ sll_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p)
|
||||
u_int caplen = h->caplen;
|
||||
u_int length = h->len;
|
||||
register const struct sll_header *sllp;
|
||||
u_short pkttype;
|
||||
struct ether_header ehdr;
|
||||
u_short ether_type;
|
||||
u_short extracted_ethertype;
|
||||
|
||||
@ -118,61 +116,15 @@ sll_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p)
|
||||
|
||||
sllp = (const struct sll_header *)p;
|
||||
|
||||
/*
|
||||
* Fake up an Ethernet header for the benefit of printers that
|
||||
* insist on "packetp" pointing to an Ethernet header.
|
||||
*/
|
||||
pkttype = ntohs(sllp->sll_pkttype);
|
||||
|
||||
/* The source address is in the packet header */
|
||||
memcpy(ehdr.ether_shost, sllp->sll_addr, ETHER_ADDR_LEN);
|
||||
|
||||
if (pkttype != LINUX_SLL_OUTGOING) {
|
||||
/*
|
||||
* We received this packet.
|
||||
*
|
||||
* We don't know the destination address, so
|
||||
* we fake it - all 0's except that the
|
||||
* bottommost bit of the bottommost octet
|
||||
* is set for a unicast packet, all 0's except
|
||||
* that the bottommost bit of the uppermost
|
||||
* octet is set for a multicast packet, all
|
||||
* 1's for a broadcast packet.
|
||||
*/
|
||||
if (pkttype == LINUX_SLL_BROADCAST)
|
||||
memset(ehdr.ether_dhost, 0xFF, ETHER_ADDR_LEN);
|
||||
else {
|
||||
memset(ehdr.ether_dhost, 0, ETHER_ADDR_LEN);
|
||||
if (pkttype == LINUX_SLL_MULTICAST)
|
||||
ehdr.ether_dhost[0] = 1;
|
||||
else
|
||||
ehdr.ether_dhost[ETHER_ADDR_LEN-1] = 1;
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* We sent this packet; we don't know whether it's
|
||||
* broadcast, multicast, or unicast, so just make
|
||||
* the destination address all 0's.
|
||||
*/
|
||||
memset(ehdr.ether_dhost, 0, ETHER_ADDR_LEN);
|
||||
}
|
||||
|
||||
if (eflag)
|
||||
sll_print(sllp, length);
|
||||
|
||||
/*
|
||||
* Some printers want to get back at the ethernet 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.
|
||||
* Some printers want to check that they're not walking off the
|
||||
* end of the packet.
|
||||
* Rather than pass it all the way down, we set this global.
|
||||
*/
|
||||
snapend = p + caplen;
|
||||
/*
|
||||
* Actually, the only printers that use packetp are print-arp.c
|
||||
* and print-bootp.c, and they assume that packetp points to an
|
||||
* Ethernet header. The right thing to do is to fix them to know
|
||||
* which link type is in use when they excavate. XXX
|
||||
*/
|
||||
packetp = (u_char *)&ehdr;
|
||||
|
||||
length -= SLL_HDR_LEN;
|
||||
caplen -= SLL_HDR_LEN;
|
||||
@ -203,8 +155,8 @@ sll_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p)
|
||||
* 802.2.
|
||||
* Try to print the LLC-layer header & higher layers.
|
||||
*/
|
||||
if (llc_print(p, length, caplen, ESRC(&ehdr),
|
||||
EDST(&ehdr), &extracted_ethertype) == 0)
|
||||
if (llc_print(p, length, caplen, NULL, NULL,
|
||||
&extracted_ethertype) == 0)
|
||||
goto unknown; /* unknown LLC type */
|
||||
break;
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.19 2002-09-05 21:25:50 guy Exp $";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.20 2002-12-18 08:53:24 guy Exp $";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -112,23 +112,18 @@ token_print(const u_char *p, u_int length, u_int caplen)
|
||||
printf("[|token-ring]");
|
||||
return hdr_len;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the TR addresses into a canonical form
|
||||
*/
|
||||
extract_token_addrs(trp, (char*)ESRC(&ehdr), (char*)EDST(&ehdr));
|
||||
|
||||
/*
|
||||
* Some printers want to get back at the ethernet 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.
|
||||
* Some printers want to check that they're not walking off the
|
||||
* end of the packet.
|
||||
* Rather than pass it all the way down, we set this global.
|
||||
*/
|
||||
snapend = p + caplen;
|
||||
/*
|
||||
* Actually, the only printers that use packetp are print-arp.c
|
||||
* and print-bootp.c, and they assume that packetp points to an
|
||||
* Ethernet header. The right thing to do is to fix them to know
|
||||
* which link type is in use when they excavate. XXX
|
||||
*/
|
||||
packetp = (u_char *)&ehdr;
|
||||
|
||||
/* Adjust for source routing information in the MAC header */
|
||||
if (IS_SOURCE_ROUTED(trp)) {
|
||||
|
Loading…
Reference in New Issue
Block a user