return (1);
case ETHERTYPE_8021Q:
printf("802.1Q vlan#%d P%d%s",
printf("802.1Q vlan#%d P%d%s ",
ntohs(*(unsigned short*)p)&0xFFF,
ntohs(*(unsigned short*)p)>>13,
(ntohs(*(unsigned short*)p)&0x1000) ? " CFI" : "");
.in -.5i
where \fIp\fR is one of the above protocols.
Note that \fItcpdump\fR does an incomplete job of parsing these protocols.
.IP "\fBvlan \fI[vlan_id]\fR"
True if the packet is an IEEE 802.1Q VLAN packet.
If \fI[vlan_id]\fR is specified, only true is the packet has the specified
\fIvlan_id\fR.
Note that the first \fBvlan\fR keyword encountered in \fIexpression\fR
changes the decoding offsets for the remainder of \fIexpression\fR
on the assumption that the packet is a VLAN packet.
.IP "\fIexpr relop expr\fR"
True if the relation holds, where \fIrelop\fR is one of >, <, >=, <=, =, !=,
and \fIexpr\fR is an arithmetic expression composed of integer constants
#ifndef ETHERTYPE_IPV6
#define ETHERTYPE_IPV6 0x80f3
#endif
#ifndef ETHERTYPE_8021Q
#define ETHERTYPE_8021Q 0x8100
#ifndef ETHERTYPE_LOOPBACK
#define ETHERTYPE_LOOPBACK 0x9000
dir);
return (b0);
}
/*
* support IEEE 802.1Q VLAN trunk over ethernet
*/
struct block *
gen_vlan(vlan_num)
int vlan_num;
{
static u_int orig_linktype = -1, orig_nl = -1;
struct block *b0;
* Change the offsets to point to the type and data fields within
* the VLAN packet. This is somewhat of a kludge.
if (orig_nl == (u_int)-1) {
orig_linktype = off_linktype; /* save original values */
orig_nl = off_nl;
switch (linktype) {
case DLT_EN10MB:
off_linktype = 16;
off_nl = 18;
break;
default:
bpf_error("no VLAN support for data link type 0x%x",
linktype);
return;
/* check for VLAN */
b0 = gen_cmp(orig_linktype, BPF_H, (bpf_int32)ETHERTYPE_8021Q);
/* If a specific VLAN is requested, check VLAN id */
if (vlan_num >= 0) {
struct block *b1;
b1 = gen_cmp(orig_nl, BPF_H, (bpf_int32)vlan_num);
gen_and(b0, b1);
b0 = b1;
struct block *gen_multicast(int);
struct block *gen_inbound(int);
struct block *gen_vlan(int);
void bpf_optimize(struct block **);
#if __STDC__
__dead void bpf_error(const char *, ...)
%token LEN
%token ISO ESIS ISIS
%token IPV6 ICMPV6 AH ESP
%token VLAN
%type <s> ID
%type <e> EID
| HID {
/* Decide how to parse HID based on proto */
$$.q = $<blk>0.q;
switch ($$.q.proto) {
$$.b = gen_ncode($1, 0, $$.q);
case Q_DECNET:
| HID6 '/' NUM {
#ifdef INET6
| BYTE NUM byteop NUM { $$ = gen_byteop($3, $2, $4); }
| INBOUND { $$ = gen_inbound(0); }
| OUTBOUND { $$ = gen_inbound(1); }
| VLAN pnum { $$ = gen_vlan($2); }
| VLAN { $$ = gen_vlan(-1); }
;
relop: '>' { $$ = BPF_JGT; }
| GEQ { $$ = BPF_JGE; }
inbound return INBOUND;
outbound return OUTBOUND;
vlan return VLAN;
[ \n\t] ;
[+\-*/:\[\]!<>()&|=] return yytext[0];
">=" return GEQ;