View | Details | Raw Unified | Return to bug 21880
Collapse All | Expand All

(-)print-ether.c (-1 / +1 lines)
Lines 205-211 Link Here
205
		return (1);
205
		return (1);
206
206
207
	case ETHERTYPE_8021Q:
207
	case ETHERTYPE_8021Q:
208
		printf("802.1Q vlan#%d P%d%s",
208
		printf("802.1Q vlan#%d P%d%s ",
209
		       ntohs(*(unsigned short*)p)&0xFFF,
209
		       ntohs(*(unsigned short*)p)&0xFFF,
210
		       ntohs(*(unsigned short*)p)>>13,
210
		       ntohs(*(unsigned short*)p)>>13,
211
		       (ntohs(*(unsigned short*)p)&0x1000) ? " CFI" : "");
211
		       (ntohs(*(unsigned short*)p)&0x1000) ? " CFI" : "");
(-)tcpdump.1 (+7 lines)
Lines 555-560 Link Here
555
.in -.5i
555
.in -.5i
556
where \fIp\fR is one of the above protocols.
556
where \fIp\fR is one of the above protocols.
557
Note that \fItcpdump\fR does an incomplete job of parsing these protocols.
557
Note that \fItcpdump\fR does an incomplete job of parsing these protocols.
558
.IP "\fBvlan \fI[vlan_id]\fR"
559
True if the packet is an IEEE 802.1Q VLAN packet.
560
If \fI[vlan_id]\fR is specified, only true is the packet has the specified
561
\fIvlan_id\fR.
562
Note that the first \fBvlan\fR keyword encountered in \fIexpression\fR
563
changes the decoding offsets for the remainder of \fIexpression\fR
564
on the assumption that the packet is a VLAN packet.
558
.IP  "\fIexpr relop expr\fR"
565
.IP  "\fIexpr relop expr\fR"
559
True if the relation holds, where \fIrelop\fR is one of >, <, >=, <=, =, !=,
566
True if the relation holds, where \fIrelop\fR is one of >, <, >=, <=, =, !=,
560
and \fIexpr\fR is an arithmetic expression composed of integer constants
567
and \fIexpr\fR is an arithmetic expression composed of integer constants
(-)ethertype.h (+3 lines)
Lines 74-79 Link Here
74
#ifndef ETHERTYPE_IPV6
74
#ifndef ETHERTYPE_IPV6
75
#define ETHERTYPE_IPV6		0x80f3
75
#define ETHERTYPE_IPV6		0x80f3
76
#endif
76
#endif
77
#ifndef ETHERTYPE_8021Q
78
#define ETHERTYPE_8021Q		0x8100
79
#endif
77
#ifndef	ETHERTYPE_LOOPBACK
80
#ifndef	ETHERTYPE_LOOPBACK
78
#define	ETHERTYPE_LOOPBACK	0x9000
81
#define	ETHERTYPE_LOOPBACK	0x9000
79
#endif
82
#endif
(-)gencode.c (+47 lines)
Lines 2872-2874 Link Here
2872
			  dir);
2872
			  dir);
2873
	return (b0);
2873
	return (b0);
2874
}
2874
}
2875
2876
/*
2877
 * support IEEE 802.1Q VLAN trunk over ethernet
2878
 */
2879
struct block *
2880
gen_vlan(vlan_num)
2881
	int vlan_num;
2882
{
2883
	static u_int	orig_linktype = -1, orig_nl = -1;
2884
	struct	block	*b0;
2885
2886
	/*
2887
	 * Change the offsets to point to the type and data fields within
2888
	 * the VLAN packet.  This is somewhat of a kludge.
2889
	 */
2890
	if (orig_nl == (u_int)-1) {
2891
		orig_linktype = off_linktype;	/* save original values */
2892
		orig_nl = off_nl;
2893
2894
		switch (linktype) {
2895
2896
		case DLT_EN10MB:
2897
			off_linktype = 16;
2898
			off_nl = 18;
2899
			break;
2900
2901
		default:
2902
			bpf_error("no VLAN support for data link type 0x%x",
2903
				  linktype);
2904
			return;
2905
		}
2906
	}
2907
2908
	/* check for VLAN */
2909
	b0 = gen_cmp(orig_linktype, BPF_H, (bpf_int32)ETHERTYPE_8021Q);
2910
2911
	/* If a specific VLAN is requested, check VLAN id */
2912
	if (vlan_num >= 0) {
2913
		struct block *b1;
2914
2915
		b1 = gen_cmp(orig_nl, BPF_H, (bpf_int32)vlan_num);
2916
		gen_and(b0, b1);
2917
		b0 = b1;
2918
	}
2919
2920
	return (b0);
2921
}
(-)gencode.h (+2 lines)
Lines 180-185 Link Here
180
struct block *gen_multicast(int);
180
struct block *gen_multicast(int);
181
struct block *gen_inbound(int);
181
struct block *gen_inbound(int);
182
182
183
struct block *gen_vlan(int);
184
183
void bpf_optimize(struct block **);
185
void bpf_optimize(struct block **);
184
#if __STDC__
186
#if __STDC__
185
__dead void bpf_error(const char *, ...)
187
__dead void bpf_error(const char *, ...)
(-)grammar.y (-8 / +4 lines)
Lines 115-120 Link Here
115
%token  LEN
115
%token  LEN
116
%token  ISO ESIS ISIS
116
%token  ISO ESIS ISIS
117
%token  IPV6 ICMPV6 AH ESP
117
%token  IPV6 ICMPV6 AH ESP
118
%token	VLAN
118
119
119
%type	<s> ID
120
%type	<s> ID
120
%type	<e> EID
121
%type	<e> EID
Lines 161-174 Link Here
161
	| HID			{
162
	| HID			{
162
				  /* Decide how to parse HID based on proto */
163
				  /* Decide how to parse HID based on proto */
163
				  $$.q = $<blk>0.q;
164
				  $$.q = $<blk>0.q;
164
				  switch ($$.q.proto) {
165
				  $$.b = gen_ncode($1, 0, $$.q);
165
				  case Q_DECNET:
166
					$$.b = gen_ncode($1, 0, $$.q);
167
					break;
168
				  default:
169
					$$.b = gen_ncode($1, 0, $$.q);
170
					break;
171
				  }
172
				}
166
				}
173
	| HID6 '/' NUM		{
167
	| HID6 '/' NUM		{
174
#ifdef INET6
168
#ifdef INET6
Lines 273-278 Link Here
273
	| BYTE NUM byteop NUM	{ $$ = gen_byteop($3, $2, $4); }
267
	| BYTE NUM byteop NUM	{ $$ = gen_byteop($3, $2, $4); }
274
	| INBOUND		{ $$ = gen_inbound(0); }
268
	| INBOUND		{ $$ = gen_inbound(0); }
275
	| OUTBOUND		{ $$ = gen_inbound(1); }
269
	| OUTBOUND		{ $$ = gen_inbound(1); }
270
	| VLAN pnum		{ $$ = gen_vlan($2); }
271
	| VLAN			{ $$ = gen_vlan(-1); }
276
	;
272
	;
277
relop:	  '>'			{ $$ = BPF_JGT; }
273
relop:	  '>'			{ $$ = BPF_JGT; }
278
	| GEQ			{ $$ = BPF_JGE; }
274
	| GEQ			{ $$ = BPF_JGE; }
(-)scanner.l (+2 lines)
Lines 232-237 Link Here
232
inbound		return INBOUND;
232
inbound		return INBOUND;
233
outbound	return OUTBOUND;
233
outbound	return OUTBOUND;
234
234
235
vlan		return VLAN;
236
235
[ \n\t]			;
237
[ \n\t]			;
236
[+\-*/:\[\]!<>()&|=]	return yytext[0];
238
[+\-*/:\[\]!<>()&|=]	return yytext[0];
237
">="			return GEQ;
239
">="			return GEQ;

Return to bug 21880