Skip to content

Commit dd928cf

Browse files
committed
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).
1 parent 86f96f8 commit dd928cf

File tree

7 files changed

+20
-22
lines changed

7 files changed

+20
-22
lines changed

print-ether.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
#ifndef lint
2222
static const char rcsid[] _U_ =
23-
"@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.99 2005-07-10 14:41:34 hannes Exp $ (LBL)";
23+
"@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.100 2005-11-13 12:12:41 guy Exp $ (LBL)";
2424
#endif
2525

2626
#ifdef HAVE_CONFIG_H
@@ -47,7 +47,7 @@ const struct tok ethertype_values[] = {
4747
{ ETHERTYPE_VMAN, "VMAN" },
4848
{ ETHERTYPE_PUP, "PUP" },
4949
{ ETHERTYPE_ARP, "ARP"},
50-
{ ETHERTYPE_REVARP , "Reverse ARP"},
50+
{ ETHERTYPE_REVARP, "Reverse ARP"},
5151
{ ETHERTYPE_NS, "NS" },
5252
{ ETHERTYPE_SPRITE, "Sprite" },
5353
{ ETHERTYPE_TRAIL, "Trail" },
@@ -128,7 +128,6 @@ ether_print(const u_char *p, u_int length, u_int caplen)
128128
/*
129129
* Is it (gag) an 802.3 encapsulation?
130130
*/
131-
extracted_ether_type = 0;
132131
if (ether_type <= ETHERMTU) {
133132
/* Try to print the LLC-layer header & higher layers */
134133
if (llc_print(p, length, caplen, ESRC(ep), EDST(ep),

print-fddi.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#ifndef lint
2323
static const char rcsid[] _U_ =
24-
"@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.65 2005-07-07 01:22:18 guy Exp $ (LBL)";
24+
"@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.66 2005-11-13 12:12:41 guy Exp $ (LBL)";
2525
#endif
2626

2727
#ifdef HAVE_CONFIG_H
@@ -264,7 +264,6 @@ fddi_print(const u_char *p, u_int length, u_int caplen)
264264
caplen -= FDDI_HDRLEN;
265265

266266
/* Frame Control field determines interpretation of packet */
267-
extracted_ethertype = 0;
268267
if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_LLC_ASYNC) {
269268
/* Try to print the LLC-layer header & higher layers */
270269
if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr),

print-ipfc.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#ifndef lint
2323
static const char rcsid[] _U_ =
24-
"@(#) $Header: /tcpdump/master/tcpdump/print-ipfc.c,v 1.8 2005-07-07 01:22:19 guy Exp $ (LBL)";
24+
"@(#) $Header: /tcpdump/master/tcpdump/print-ipfc.c,v 1.9 2005-11-13 12:12:42 guy Exp $ (LBL)";
2525
#endif
2626

2727
#ifdef HAVE_CONFIG_H
@@ -101,8 +101,6 @@ ipfc_print(const u_char *p, u_int length, u_int caplen)
101101
p += IPFC_HDRLEN;
102102
caplen -= IPFC_HDRLEN;
103103

104-
/* Frame Control field determines interpretation of packet */
105-
extracted_ethertype = 0;
106104
/* Try to print the LLC-layer header & higher layers */
107105
if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
108106
&extracted_ethertype) == 0) {

print-lane.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#ifndef lint
2424
static const char rcsid[] _U_ =
25-
"@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.24 2005-07-07 01:22:19 guy Exp $ (LBL)";
25+
"@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.25 2005-11-13 12:12:42 guy Exp $ (LBL)";
2626
#endif
2727

2828
#ifdef HAVE_CONFIG_H
@@ -134,7 +134,6 @@ lane_print(const u_char *p, u_int length, u_int caplen)
134134
/*
135135
* Is it (gag) an 802.3 encapsulation?
136136
*/
137-
extracted_ethertype = 0;
138137
if (ether_type <= ETHERMTU) {
139138
/* Try to print the LLC-layer header & higher layers */
140139
if (llc_print(p, length, caplen, ep->h_source, ep->h_dest,

print-llc.c

+10-8
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
#ifndef lint
2626
static const char rcsid[] _U_ =
27-
"@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.66 2005-09-29 07:37:08 hannes Exp $";
27+
"@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.67 2005-11-13 12:12:42 guy Exp $";
2828
#endif
2929

3030
#ifdef HAVE_CONFIG_H
@@ -138,16 +138,16 @@ llc_print(const u_char *p, u_int length, u_int caplen,
138138
int is_u;
139139
register int ret;
140140

141+
*extracted_ethertype = 0;
142+
141143
if (caplen < 3) {
142144
(void)printf("[|llc]");
143145
default_print((u_char *)p, caplen);
144146
return(0);
145147
}
146148

147149
dsap_field = *p;
148-
dsap = dsap_field & ~LLC_IG;
149150
ssap_field = *(p + 1);
150-
ssap = ssap_field & ~LLC_GSAP;
151151

152152
/*
153153
* 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,
179179
is_u = 0;
180180
}
181181

182-
if (ssap == LLCSAP_GLOBAL && dsap == LLCSAP_GLOBAL) {
182+
if (ssap_field == LLCSAP_GLOBAL && dsap_field == LLCSAP_GLOBAL) {
183183
/*
184184
* This is an Ethernet_802.3 IPX frame; it has an
185185
* 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,
202202
return (1);
203203
}
204204

205+
dsap = dsap_field & ~LLC_IG;
206+
ssap = ssap_field & ~LLC_GSAP;
207+
205208
if (eflag) {
206209
printf("LLC, dsap %s (0x%02x), ssap %s (0x%02x)",
207210
tok2str(llc_values, "Unknown", dsap),
@@ -319,7 +322,7 @@ llc_print(const u_char *p, u_int length, u_int caplen,
319322
if (is_u) {
320323
printf("Unnumbered, %s, Flags [%s], length %u",
321324
tok2str(llc_cmd_values, "%02x", LLC_U_CMD(control)),
322-
bittok2str(llc_flag_values,"?",(ssap) | (control & LLC_U_POLL)),
325+
tok2str(llc_flag_values,"?",(ssap_field & LLC_GSAP) | (control & LLC_U_POLL)),
323326
length);
324327

325328
p += 3;
@@ -335,18 +338,17 @@ llc_print(const u_char *p, u_int length, u_int caplen,
335338
}
336339
}
337340
} else {
338-
339341
if ((control & LLC_S_FMT) == LLC_S_FMT) {
340342
(void)printf("Supervisory, %s, rcv seq %u, Flags [%s], length %u",
341343
tok2str(llc_supervisory_values,"?",LLC_S_CMD(control)),
342344
LLC_IS_NR(control),
343-
bittok2str(llc_flag_values,"?",(ssap) | (control & LLC_IS_POLL)),
345+
tok2str(llc_flag_values,"?",(ssap_field & LLC_GSAP) | (control & LLC_IS_POLL)),
344346
length);
345347
} else {
346348
(void)printf("Information, send seq %u, rcv seq %u, Flags [%s], length %u",
347349
LLC_I_NS(control),
348350
LLC_IS_NR(control),
349-
bittok2str(llc_flag_values,"?",(ssap) | (control & LLC_IS_POLL)),
351+
tok2str(llc_flag_values,"?",(ssap_field & LLC_GSAP) | (control & LLC_IS_POLL)),
350352
length);
351353
}
352354
p += 4;

print-sll.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
#ifndef lint
2222
static const char rcsid[] _U_ =
23-
"@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.18 2005-07-07 01:22:21 guy Exp $ (LBL)";
23+
"@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.19 2005-11-13 12:12:43 guy Exp $ (LBL)";
2424
#endif
2525

2626
#ifdef HAVE_CONFIG_H
@@ -148,7 +148,6 @@ sll_if_print(const struct pcap_pkthdr *h, const u_char *p)
148148
* Is it (gag) an 802.3 encapsulation, or some non-Ethernet
149149
* packet type?
150150
*/
151-
extracted_ethertype = 0;
152151
if (ether_type <= ETHERMTU) {
153152
/*
154153
* Yes - what type is it?
@@ -173,6 +172,9 @@ sll_if_print(const struct pcap_pkthdr *h, const u_char *p)
173172
break;
174173

175174
default:
175+
extracted_ethertype = 0;
176+
/*FALLTHROUGH*/
177+
176178
unknown:
177179
/* ether_type not known, print raw packet */
178180
if (!eflag)

print-token.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*/
2626
#ifndef lint
2727
static const char rcsid[] _U_ =
28-
"@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.26 2005-07-07 01:22:21 guy Exp $";
28+
"@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.27 2005-11-13 12:12:43 guy Exp $";
2929
#endif
3030

3131
#ifdef HAVE_CONFIG_H
@@ -153,7 +153,6 @@ token_print(const u_char *p, u_int length, u_int caplen)
153153
caplen -= hdr_len;
154154

155155
/* Frame Control field determines interpretation of packet */
156-
extracted_ethertype = 0;
157156
if (FRAME_TYPE(trp) == TOKEN_FC_LLC) {
158157
/* Try to print the LLC-layer header & higher layers */
159158
if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr),

0 commit comments

Comments
 (0)