Have print_llc() clear out the extracted_ethertype argument, rather than

having its callers do so - some of its callers *weren't* doing so,
leaving random junk in that argument in some cases.

When checking for "802.3-encapsulated" IPX, check the raw values of the
SSAP and DSAP for 0xFF, don't check them after the low-order bit has
been masked off.

The "flag" values in the LLC header aren't bits, they're combinations of
bits, including the combination "no bits"; don't use "bittok2str()" on
them.  Also, combine the proper bits, namely the C/R bit (which we
weren't combining) and the P/F bit (which we were).
This commit is contained in:
guy 2005-11-13 12:12:41 +00:00
parent 86f96f8a7b
commit dd928cfb35
7 changed files with 20 additions and 22 deletions

View File

@ -20,7 +20,7 @@
*/
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.99 2005-07-10 14:41:34 hannes Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.100 2005-11-13 12:12:41 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -47,7 +47,7 @@ const struct tok ethertype_values[] = {
{ ETHERTYPE_VMAN, "VMAN" },
{ ETHERTYPE_PUP, "PUP" },
{ ETHERTYPE_ARP, "ARP"},
{ ETHERTYPE_REVARP , "Reverse ARP"},
{ ETHERTYPE_REVARP, "Reverse ARP"},
{ ETHERTYPE_NS, "NS" },
{ ETHERTYPE_SPRITE, "Sprite" },
{ ETHERTYPE_TRAIL, "Trail" },
@ -128,7 +128,6 @@ ether_print(const u_char *p, u_int length, u_int caplen)
/*
* Is it (gag) an 802.3 encapsulation?
*/
extracted_ether_type = 0;
if (ether_type <= ETHERMTU) {
/* Try to print the LLC-layer header & higher layers */
if (llc_print(p, length, caplen, ESRC(ep), EDST(ep),

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.65 2005-07-07 01:22:18 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.66 2005-11-13 12:12:41 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -264,7 +264,6 @@ fddi_print(const u_char *p, u_int length, u_int caplen)
caplen -= FDDI_HDRLEN;
/* Frame Control field determines interpretation of packet */
extracted_ethertype = 0;
if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_LLC_ASYNC) {
/* Try to print the LLC-layer header & higher layers */
if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr),

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-ipfc.c,v 1.8 2005-07-07 01:22:19 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-ipfc.c,v 1.9 2005-11-13 12:12:42 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -101,8 +101,6 @@ ipfc_print(const u_char *p, u_int length, u_int caplen)
p += IPFC_HDRLEN;
caplen -= IPFC_HDRLEN;
/* Frame Control field determines interpretation of packet */
extracted_ethertype = 0;
/* Try to print the LLC-layer header & higher layers */
if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
&extracted_ethertype) == 0) {

View File

@ -22,7 +22,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.24 2005-07-07 01:22:19 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.25 2005-11-13 12:12:42 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -134,7 +134,6 @@ lane_print(const u_char *p, u_int length, u_int caplen)
/*
* Is it (gag) an 802.3 encapsulation?
*/
extracted_ethertype = 0;
if (ether_type <= ETHERMTU) {
/* Try to print the LLC-layer header & higher layers */
if (llc_print(p, length, caplen, ep->h_source, ep->h_dest,

View File

@ -24,7 +24,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.66 2005-09-29 07:37:08 hannes Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.67 2005-11-13 12:12:42 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -138,6 +138,8 @@ llc_print(const u_char *p, u_int length, u_int caplen,
int is_u;
register int ret;
*extracted_ethertype = 0;
if (caplen < 3) {
(void)printf("[|llc]");
default_print((u_char *)p, caplen);
@ -145,9 +147,7 @@ llc_print(const u_char *p, u_int length, u_int caplen,
}
dsap_field = *p;
dsap = dsap_field & ~LLC_IG;
ssap_field = *(p + 1);
ssap = ssap_field & ~LLC_GSAP;
/*
* OK, what type of LLC frame is this? The length
@ -179,7 +179,7 @@ llc_print(const u_char *p, u_int length, u_int caplen,
is_u = 0;
}
if (ssap == LLCSAP_GLOBAL && dsap == LLCSAP_GLOBAL) {
if (ssap_field == LLCSAP_GLOBAL && dsap_field == LLCSAP_GLOBAL) {
/*
* This is an Ethernet_802.3 IPX frame; it has an
* 802.3 header (i.e., an Ethernet header where the
@ -202,6 +202,9 @@ llc_print(const u_char *p, u_int length, u_int caplen,
return (1);
}
dsap = dsap_field & ~LLC_IG;
ssap = ssap_field & ~LLC_GSAP;
if (eflag) {
printf("LLC, dsap %s (0x%02x), ssap %s (0x%02x)",
tok2str(llc_values, "Unknown", dsap),
@ -319,7 +322,7 @@ llc_print(const u_char *p, u_int length, u_int caplen,
if (is_u) {
printf("Unnumbered, %s, Flags [%s], length %u",
tok2str(llc_cmd_values, "%02x", LLC_U_CMD(control)),
bittok2str(llc_flag_values,"?",(ssap) | (control & LLC_U_POLL)),
tok2str(llc_flag_values,"?",(ssap_field & LLC_GSAP) | (control & LLC_U_POLL)),
length);
p += 3;
@ -335,18 +338,17 @@ llc_print(const u_char *p, u_int length, u_int caplen,
}
}
} else {
if ((control & LLC_S_FMT) == LLC_S_FMT) {
(void)printf("Supervisory, %s, rcv seq %u, Flags [%s], length %u",
tok2str(llc_supervisory_values,"?",LLC_S_CMD(control)),
LLC_IS_NR(control),
bittok2str(llc_flag_values,"?",(ssap) | (control & LLC_IS_POLL)),
tok2str(llc_flag_values,"?",(ssap_field & LLC_GSAP) | (control & LLC_IS_POLL)),
length);
} else {
(void)printf("Information, send seq %u, rcv seq %u, Flags [%s], length %u",
LLC_I_NS(control),
LLC_IS_NR(control),
bittok2str(llc_flag_values,"?",(ssap) | (control & LLC_IS_POLL)),
tok2str(llc_flag_values,"?",(ssap_field & LLC_GSAP) | (control & LLC_IS_POLL)),
length);
}
p += 4;

View File

@ -20,7 +20,7 @@
*/
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.18 2005-07-07 01:22:21 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.19 2005-11-13 12:12:43 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -148,7 +148,6 @@ sll_if_print(const struct pcap_pkthdr *h, const u_char *p)
* Is it (gag) an 802.3 encapsulation, or some non-Ethernet
* packet type?
*/
extracted_ethertype = 0;
if (ether_type <= ETHERMTU) {
/*
* Yes - what type is it?
@ -173,6 +172,9 @@ sll_if_print(const struct pcap_pkthdr *h, const u_char *p)
break;
default:
extracted_ethertype = 0;
/*FALLTHROUGH*/
unknown:
/* ether_type not known, print raw packet */
if (!eflag)

View File

@ -25,7 +25,7 @@
*/
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.26 2005-07-07 01:22:21 guy Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.27 2005-11-13 12:12:43 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -153,7 +153,6 @@ token_print(const u_char *p, u_int length, u_int caplen)
caplen -= hdr_len;
/* Frame Control field determines interpretation of packet */
extracted_ethertype = 0;
if (FRAME_TYPE(trp) == TOKEN_FC_LLC) {
/* Try to print the LLC-layer header & higher layers */
if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr),