diff options
| author | Xin LI <delphij@FreeBSD.org> | 2012-05-14 05:12:56 +0000 |
|---|---|---|
| committer | Xin LI <delphij@FreeBSD.org> | 2012-05-14 05:12:56 +0000 |
| commit | d1e8733132ce92d068898e4b3fe25ce17d634590 (patch) | |
| tree | 158e6045ed438c41ac8de6cb27ac3c73cdc6643a /contrib/libpcap/gencode.c | |
| parent | 47db53c31a5ec643382c4b08c3f68dd4ccdf79d9 (diff) | |
| parent | 5a0615f5c40ce036a7e13cfffe00927f845ad563 (diff) | |
Notes
Diffstat (limited to 'contrib/libpcap/gencode.c')
| -rw-r--r-- | contrib/libpcap/gencode.c | 521 |
1 files changed, 318 insertions, 203 deletions
diff --git a/contrib/libpcap/gencode.c b/contrib/libpcap/gencode.c index 2d28406be108..fd10aed86b88 100644 --- a/contrib/libpcap/gencode.c +++ b/contrib/libpcap/gencode.c @@ -49,7 +49,7 @@ static const char rcsid[] _U_ = * XXX - why was this included even on UNIX? */ #ifdef __MINGW32__ -#include "IP6_misc.h" +#include "ip6_misc.h" #endif #ifndef WIN32 @@ -774,7 +774,8 @@ static int reg_off_ll; * This is the offset of the beginning of the MAC-layer header from * the beginning of the link-layer header. * It's usually 0, except for ATM LANE, where it's the offset, relative - * to the beginning of the raw packet data, of the Ethernet header. + * to the beginning of the raw packet data, of the Ethernet header, and + * for Ethernet with various additional information. */ static u_int off_mac; @@ -1240,26 +1241,6 @@ init_linktype(p) off_nl_nosnap = 0; /* no 802.2 LLC */ return; - case DLT_LINUX_IRDA: - /* - * Currently, only raw "link[N:M]" filtering is supported. - */ - off_linktype = -1; - off_macpl = -1; - off_nl = -1; - off_nl_nosnap = -1; - return; - - case DLT_DOCSIS: - /* - * Currently, only raw "link[N:M]" filtering is supported. - */ - off_linktype = -1; - off_macpl = -1; - off_nl = -1; - off_nl_nosnap = -1; - return; - case DLT_SYMANTEC_FIREWALL: off_linktype = 6; off_macpl = 44; @@ -1368,6 +1349,16 @@ init_linktype(p) off_nl_nosnap = -1; return; + case DLT_JUNIPER_VS: + case DLT_JUNIPER_SRX_E2E: + case DLT_JUNIPER_FIBRECHANNEL: + case DLT_JUNIPER_ATM_CEMIC: + off_linktype = 8; + off_macpl = -1; + off_nl = -1; + off_nl_nosnap = -1; + return; + case DLT_MTP2: off_li = 2; off_sio = 3; @@ -1413,126 +1404,6 @@ init_linktype(p) return; #endif - case DLT_LINUX_LAPD: - /* - * Currently, only raw "link[N:M]" filtering is supported. - */ - off_linktype = -1; - off_macpl = -1; - off_nl = -1; - off_nl_nosnap = -1; - return; - - case DLT_USB: - /* - * Currently, only raw "link[N:M]" filtering is supported. - */ - off_linktype = -1; - off_macpl = -1; - off_nl = -1; - off_nl_nosnap = -1; - return; - - case DLT_BLUETOOTH_HCI_H4: - /* - * Currently, only raw "link[N:M]" filtering is supported. - */ - off_linktype = -1; - off_macpl = -1; - off_nl = -1; - off_nl_nosnap = -1; - return; - - case DLT_USB_LINUX: - /* - * Currently, only raw "link[N:M]" filtering is supported. - */ - off_linktype = -1; - off_macpl = -1; - off_nl = -1; - off_nl_nosnap = -1; - return; - - case DLT_CAN20B: - /* - * Currently, only raw "link[N:M]" filtering is supported. - */ - off_linktype = -1; - off_macpl = -1; - off_nl = -1; - off_nl_nosnap = -1; - return; - - case DLT_IEEE802_15_4_LINUX: - /* - * Currently, only raw "link[N:M]" filtering is supported. - */ - off_linktype = -1; - off_macpl = -1; - off_nl = -1; - off_nl_nosnap = -1; - return; - - case DLT_IEEE802_16_MAC_CPS_RADIO: - /* - * Currently, only raw "link[N:M]" filtering is supported. - */ - off_linktype = -1; - off_macpl = -1; - off_nl = -1; - off_nl_nosnap = -1; - return; - - case DLT_IEEE802_15_4: - /* - * Currently, only raw "link[N:M]" filtering is supported. - */ - off_linktype = -1; - off_macpl = -1; - off_nl = -1; - off_nl_nosnap = -1; - return; - - case DLT_SITA: - /* - * Currently, only raw "link[N:M]" filtering is supported. - */ - off_linktype = -1; - off_macpl = -1; - off_nl = -1; - off_nl_nosnap = -1; - return; - - case DLT_RAIF1: - /* - * Currently, only raw "link[N:M]" filtering is supported. - */ - off_linktype = -1; - off_macpl = -1; - off_nl = -1; - off_nl_nosnap = -1; - return; - - case DLT_IPMB: - /* - * Currently, only raw "link[N:M]" filtering is supported. - */ - off_linktype = -1; - off_macpl = -1; - off_nl = -1; - off_nl_nosnap = -1; - return; - - case DLT_BLUETOOTH_HCI_H4_WITH_PHDR: - /* - * Currently, only raw "link[N:M]" filtering is supported. - */ - off_linktype = -1; - off_macpl = -1; - off_nl = -1; - off_nl_nosnap = -1; - return; - case DLT_AX25_KISS: /* * Currently, only raw "link[N:M]" filtering is supported. @@ -1544,52 +1415,43 @@ init_linktype(p) off_mac = 1; /* step over the kiss length byte */ return; - case DLT_IEEE802_15_4_NONASK_PHY: - /* - * Currently, only raw "link[N:M]" filtering is supported. - */ - off_linktype = -1; - off_macpl = -1; - off_nl = -1; + case DLT_IPNET: + off_linktype = 1; + off_macpl = 24; /* ipnet header length */ + off_nl = 0; off_nl_nosnap = -1; return; - case DLT_MPLS: - /* - * Currently, only raw "link[N:M]" filtering is supported. - */ - off_linktype = -1; - off_macpl = -1; - off_nl = -1; - off_nl_nosnap = -1; + case DLT_NETANALYZER: + off_mac = 4; /* MAC header is past 4-byte pseudo-header */ + off_linktype = 16; /* includes 4-byte pseudo-header */ + off_macpl = 18; /* pseudo-header+Ethernet header length */ + off_nl = 0; /* Ethernet II */ + off_nl_nosnap = 3; /* 802.3+802.2 */ return; - case DLT_USB_LINUX_MMAPPED: - /* - * Currently, only raw "link[N:M]" filtering is supported. - */ - off_linktype = -1; - off_macpl = -1; - off_nl = -1; - off_nl_nosnap = -1; + case DLT_NETANALYZER_TRANSPARENT: + off_mac = 12; /* MAC header is past 4-byte pseudo-header, preamble, and SFD */ + off_linktype = 24; /* includes 4-byte pseudo-header+preamble+SFD */ + off_macpl = 26; /* pseudo-header+preamble+SFD+Ethernet header length */ + off_nl = 0; /* Ethernet II */ + off_nl_nosnap = 3; /* 802.3+802.2 */ return; - case DLT_CAN_SOCKETCAN: + default: /* - * Currently, only raw "link[N:M]" filtering is supported. + * For values in the range in which we've assigned new + * DLT_ values, only raw "link[N:M]" filtering is supported. */ - off_linktype = -1; - off_macpl = -1; - off_nl = -1; - off_nl_nosnap = -1; - return; + if (linktype >= DLT_MATCHING_MIN && + linktype <= DLT_MATCHING_MAX) { + off_linktype = -1; + off_macpl = -1; + off_nl = -1; + off_nl_nosnap = -1; + return; + } - case DLT_IPNET: - off_linktype = 1; - off_macpl = 24; /* ipnet header length */ - off_nl = 0; - off_nl_nosnap = -1; - return; } bpf_error("unknown data link type %d", linktype); /* NOTREACHED */ @@ -3061,6 +2923,8 @@ gen_linktype(proto) switch (linktype) { case DLT_EN10MB: + case DLT_NETANALYZER: + case DLT_NETANALYZER_TRANSPARENT: return gen_ether_linktype(proto); /*NOTREACHED*/ break; @@ -3464,6 +3328,11 @@ gen_linktype(proto) case DLT_JUNIPER_VP: case DLT_JUNIPER_ST: case DLT_JUNIPER_ISM: + case DLT_JUNIPER_VS: + case DLT_JUNIPER_SRX_E2E: + case DLT_JUNIPER_FIBRECHANNEL: + case DLT_JUNIPER_ATM_CEMIC: + /* just lets verify the magic number for now - * on ATM we may have up to 6 different encapsulations on the wire * and need a lot of heuristics to figure out that the payload @@ -3513,6 +3382,7 @@ gen_linktype(proto) case DLT_IEEE802_15_4: case DLT_IEEE802_15_4_LINUX: case DLT_IEEE802_15_4_NONASK_PHY: + case DLT_IEEE802_15_4_NOFCS: bpf_error("IEEE 802.15.4 link-layer type filtering not implemented"); case DLT_IEEE802_16_MAC_CPS_RADIO: @@ -3787,6 +3657,30 @@ gen_ehostop(eaddr, dir) b1 = gen_ehostop(eaddr, Q_DST); gen_or(b0, b1); return b1; + + case Q_ADDR1: + bpf_error("'addr1' is only supported on 802.11 with 802.11 headers"); + break; + + case Q_ADDR2: + bpf_error("'addr2' is only supported on 802.11 with 802.11 headers"); + break; + + case Q_ADDR3: + bpf_error("'addr3' is only supported on 802.11 with 802.11 headers"); + break; + + case Q_ADDR4: + bpf_error("'addr4' is only supported on 802.11 with 802.11 headers"); + break; + + case Q_RA: + bpf_error("'ra' is only supported on 802.11 with 802.11 headers"); + break; + + case Q_TA: + bpf_error("'ta' is only supported on 802.11 with 802.11 headers"); + break; } abort(); /* NOTREACHED */ @@ -3829,6 +3723,30 @@ gen_fhostop(eaddr, dir) b1 = gen_fhostop(eaddr, Q_DST); gen_or(b0, b1); return b1; + + case Q_ADDR1: + bpf_error("'addr1' is only supported on 802.11"); + break; + + case Q_ADDR2: + bpf_error("'addr2' is only supported on 802.11"); + break; + + case Q_ADDR3: + bpf_error("'addr3' is only supported on 802.11"); + break; + + case Q_ADDR4: + bpf_error("'addr4' is only supported on 802.11"); + break; + + case Q_RA: + bpf_error("'ra' is only supported on 802.11"); + break; + + case Q_TA: + bpf_error("'ta' is only supported on 802.11"); + break; } abort(); /* NOTREACHED */ @@ -3863,6 +3781,30 @@ gen_thostop(eaddr, dir) b1 = gen_thostop(eaddr, Q_DST); gen_or(b0, b1); return b1; + + case Q_ADDR1: + bpf_error("'addr1' is only supported on 802.11"); + break; + + case Q_ADDR2: + bpf_error("'addr2' is only supported on 802.11"); + break; + + case Q_ADDR3: + bpf_error("'addr3' is only supported on 802.11"); + break; + + case Q_ADDR4: + bpf_error("'addr4' is only supported on 802.11"); + break; + + case Q_RA: + bpf_error("'ra' is only supported on 802.11"); + break; + + case Q_TA: + bpf_error("'ta' is only supported on 802.11"); + break; } abort(); /* NOTREACHED */ @@ -4156,8 +4098,79 @@ gen_wlanhostop(eaddr, dir) gen_and(b1, b0); return b0; + case Q_RA: + /* + * Not present in management frames; addr1 in other + * frames. + */ + + /* + * If the high-order bit of the type value is 0, this + * is a management frame. + * I.e, check "(link[0] & 0x08)". + */ + s = gen_load_a(OR_LINK, 0, BPF_B); + b1 = new_block(JMP(BPF_JSET)); + b1->s.k = 0x08; + b1->stmts = s; + + /* + * Check addr1. + */ + b0 = gen_bcmp(OR_LINK, 4, 6, eaddr); + + /* + * AND that with the check of addr1. + */ + gen_and(b1, b0); + return (b0); + + case Q_TA: + /* + * Not present in management frames; addr2, if present, + * in other frames. + */ + + /* + * Not present in CTS or ACK control frames. + */ + b0 = gen_mcmp(OR_LINK, 0, BPF_B, IEEE80211_FC0_TYPE_CTL, + IEEE80211_FC0_TYPE_MASK); + gen_not(b0); + b1 = gen_mcmp(OR_LINK, 0, BPF_B, IEEE80211_FC0_SUBTYPE_CTS, + IEEE80211_FC0_SUBTYPE_MASK); + gen_not(b1); + b2 = gen_mcmp(OR_LINK, 0, BPF_B, IEEE80211_FC0_SUBTYPE_ACK, + IEEE80211_FC0_SUBTYPE_MASK); + gen_not(b2); + gen_and(b1, b2); + gen_or(b0, b2); + + /* + * If the high-order bit of the type value is 0, this + * is a management frame. + * I.e, check "(link[0] & 0x08)". + */ + s = gen_load_a(OR_LINK, 0, BPF_B); + b1 = new_block(JMP(BPF_JSET)); + b1->s.k = 0x08; + b1->stmts = s; + + /* + * AND that with the check for frames other than + * CTS and ACK frames. + */ + gen_and(b1, b2); + + /* + * Check addr2. + */ + b1 = gen_bcmp(OR_LINK, 10, 6, eaddr); + gen_and(b2, b1); + return b1; + /* - * XXX - add RA, TA, and BSSID keywords? + * XXX - add BSSID keyword? */ case Q_ADDR1: return (gen_bcmp(OR_LINK, 4, 6, eaddr)); @@ -4253,6 +4266,30 @@ gen_ipfchostop(eaddr, dir) b1 = gen_ipfchostop(eaddr, Q_DST); gen_or(b0, b1); return b1; + + case Q_ADDR1: + bpf_error("'addr1' is only supported on 802.11"); + break; + + case Q_ADDR2: + bpf_error("'addr2' is only supported on 802.11"); + break; + + case Q_ADDR3: + bpf_error("'addr3' is only supported on 802.11"); + break; + + case Q_ADDR4: + bpf_error("'addr4' is only supported on 802.11"); + break; + + case Q_RA: + bpf_error("'ra' is only supported on 802.11"); + break; + + case Q_TA: + bpf_error("'ta' is only supported on 802.11"); + break; } abort(); /* NOTREACHED */ @@ -4446,6 +4483,9 @@ gen_host(addr, mask, proto, dir, type) case Q_VRRP: bpf_error("'vrrp' modifier applied to %s", typestr); + case Q_CARP: + bpf_error("'carp' modifier applied to %s", typestr); + case Q_ATALK: bpf_error("ATALK host filtering not implemented"); @@ -4565,6 +4605,9 @@ gen_host6(addr, mask, proto, dir, type) case Q_VRRP: bpf_error("'vrrp' modifier applied to %s", typestr); + case Q_CARP: + bpf_error("'carp' modifier applied to %s", typestr); + case Q_ATALK: bpf_error("ATALK host filtering not implemented"); @@ -4649,6 +4692,8 @@ gen_gateway(eaddr, alist, proto, dir) case Q_RARP: switch (linktype) { case DLT_EN10MB: + case DLT_NETANALYZER: + case DLT_NETANALYZER_TRANSPARENT: b0 = gen_ehostop(eaddr, Q_OR); break; case DLT_FDDI: @@ -4778,6 +4823,14 @@ gen_proto_abbrev(proto) b1 = gen_proto(IPPROTO_VRRP, Q_IP, Q_DEFAULT); break; +#ifndef IPPROTO_CARP +#define IPPROTO_CARP 112 +#endif + + case Q_CARP: + b1 = gen_proto(IPPROTO_CARP, Q_IP, Q_DEFAULT); + break; + case Q_IP: b1 = gen_linktype(ETHERTYPE_IP); break; @@ -4959,7 +5012,7 @@ gen_ipfrag() struct slist *s; struct block *b; - /* not ip frag */ + /* not IPv4 frag other than the first frag */ s = gen_load_a(OR_NET, 6, BPF_H); b = new_block(JMP(BPF_JSET)); b->s.k = 0x1fff; @@ -5002,7 +5055,7 @@ gen_portop(port, proto, dir) { struct block *b0, *b1, *tmp; - /* ip proto 'proto' */ + /* ip proto 'proto' and not a fragment other than the first fragment */ tmp = gen_cmp(OR_NET, 9, BPF_B, (bpf_int32)proto); b0 = gen_ipfrag(); gen_and(tmp, b0); @@ -5094,6 +5147,7 @@ gen_portop6(port, proto, dir) struct block *b0, *b1, *tmp; /* ip6 proto 'proto' */ + /* XXX - catch the first fragment of a fragmented packet? */ b0 = gen_cmp(OR_NET, 6, BPF_B, (bpf_int32)proto); switch (dir) { @@ -5195,7 +5249,7 @@ gen_portrangeop(port1, port2, proto, dir) { struct block *b0, *b1, *tmp; - /* ip proto 'proto' */ + /* ip proto 'proto' and not a fragment other than the first fragment */ tmp = gen_cmp(OR_NET, 9, BPF_B, (bpf_int32)proto); b0 = gen_ipfrag(); gen_and(tmp, b0); @@ -5299,6 +5353,7 @@ gen_portrangeop6(port1, port2, proto, dir) struct block *b0, *b1, *tmp; /* ip6 proto 'proto' */ + /* XXX - catch the first fragment of a fragmented packet? */ b0 = gen_cmp(OR_NET, 6, BPF_B, (bpf_int32)proto); switch (dir) { @@ -5576,12 +5631,9 @@ gen_protochain(v, proto, dir) /* * in short, - * A = P[X]; - * X = X + (P[X + 1] + 1) * 8; + * A = P[X + packet head]; + * X = X + (P[X + packet head + 1] + 1) * 8; */ - /* A = X */ - s[i] = new_stmt(BPF_MISC|BPF_TXA); - i++; /* A = P[X + packet head] */ s[i] = new_stmt(BPF_LD|BPF_IND|BPF_B); s[i]->s.k = off_macpl + off_nl; @@ -5590,19 +5642,9 @@ gen_protochain(v, proto, dir) s[i] = new_stmt(BPF_ST); s[i]->s.k = reg2; i++; - /* A = X */ - s[i] = new_stmt(BPF_MISC|BPF_TXA); - i++; - /* A += 1 */ - s[i] = new_stmt(BPF_ALU|BPF_ADD|BPF_K); - s[i]->s.k = 1; - i++; - /* X = A */ - s[i] = new_stmt(BPF_MISC|BPF_TAX); - i++; - /* A = P[X + packet head]; */ + /* A = P[X + packet head + 1]; */ s[i] = new_stmt(BPF_LD|BPF_IND|BPF_B); - s[i]->s.k = off_macpl + off_nl; + s[i]->s.k = off_macpl + off_nl + 1; i++; /* A += 1 */ s[i] = new_stmt(BPF_ALU|BPF_ADD|BPF_K); @@ -5612,6 +5654,10 @@ gen_protochain(v, proto, dir) s[i] = new_stmt(BPF_ALU|BPF_MUL|BPF_K); s[i]->s.k = 8; i++; + /* A += X */ + s[i] = new_stmt(BPF_ALU|BPF_ADD|BPF_X); + s[i]->s.k = 0; + i++; /* X = A; */ s[i] = new_stmt(BPF_MISC|BPF_TAX); i++; @@ -5935,6 +5981,10 @@ gen_proto(v, proto, dir) bpf_error("'vrrp proto' is bogus"); /* NOTREACHED */ + case Q_CARP: + bpf_error("'carp proto' is bogus"); + /* NOTREACHED */ + #ifdef INET6 case Q_IPV6: b0 = gen_linktype(ETHERTYPE_IPV6); @@ -6018,6 +6068,8 @@ gen_scode(name, q) switch (linktype) { case DLT_EN10MB: + case DLT_NETANALYZER: + case DLT_NETANALYZER_TRANSPARENT: eaddr = pcap_ether_hostton(name); if (eaddr == NULL) bpf_error( @@ -6199,6 +6251,10 @@ gen_scode(name, q) /* override PROTO_UNDEF */ real_proto = IPPROTO_SCTP; } + if (port < 0) + bpf_error("illegal port number %d < 0", port); + if (port > 65535) + bpf_error("illegal port number %d > 65535", port); #ifndef INET6 return gen_port(port, real_proto, dir); #else @@ -6240,6 +6296,15 @@ gen_scode(name, q) /* override PROTO_UNDEF */ real_proto = IPPROTO_SCTP; } + if (port1 < 0) + bpf_error("illegal port number %d < 0", port1); + if (port1 > 65535) + bpf_error("illegal port number %d > 65535", port1); + if (port2 < 0) + bpf_error("illegal port number %d < 0", port2); + if (port2 > 65535) + bpf_error("illegal port number %d > 65535", port2); + #ifndef INET6 return gen_portrange(port1, port2, real_proto, dir); #else @@ -6391,6 +6456,9 @@ gen_ncode(s, v, q) else bpf_error("illegal qualifier of 'port'"); + if (v > 65535) + bpf_error("illegal port number %u > 65535", v); + #ifndef INET6 return gen_port((int)v, proto, dir); #else @@ -6414,6 +6482,9 @@ gen_ncode(s, v, q) else bpf_error("illegal qualifier of 'portrange'"); + if (v > 65535) + bpf_error("illegal port number %u > 65535", v); + #ifndef INET6 return gen_portrange((int)v, (int)v, proto, dir); #else @@ -6518,6 +6589,8 @@ gen_ecode(eaddr, q) if ((q.addr == Q_HOST || q.addr == Q_DEFAULT) && q.proto == Q_LINK) { switch (linktype) { case DLT_EN10MB: + case DLT_NETANALYZER: + case DLT_NETANALYZER_TRANSPARENT: return gen_ehostop(eaddr, (int)q.dir); case DLT_FDDI: return gen_fhostop(eaddr, (int)q.dir); @@ -6647,7 +6720,7 @@ gen_load(proto, inst, size) /* * Load into the X register the offset computed into the - * register specifed by "index". + * register specified by "index". */ s = xfer_to_x(inst); @@ -6679,7 +6752,7 @@ gen_load(proto, inst, size) * the link-layer header. Add to it the offset computed * into the register specified by "index", and move that * into the X register. Otherwise, just load into the X - * register the offset computed into the register specifed + * register the offset computed into the register specified * by "index". */ if (s != NULL) { @@ -6728,7 +6801,7 @@ gen_load(proto, inst, size) * payload. Add to it the offset computed into the * register specified by "index", and move that into * the X register. Otherwise, just load into the X - * register the offset computed into the register specifed + * register the offset computed into the register specified * by "index". */ if (s != NULL) { @@ -6773,6 +6846,7 @@ gen_load(proto, inst, size) case Q_IGRP: case Q_PIM: case Q_VRRP: + case Q_CARP: /* * The offset is relative to the beginning of * the transport-layer header. @@ -7121,6 +7195,8 @@ gen_broadcast(proto) case DLT_ARCNET_LINUX: return gen_ahostop(abroadcast, Q_DST); case DLT_EN10MB: + case DLT_NETANALYZER: + case DLT_NETANALYZER_TRANSPARENT: return gen_ehostop(ebroadcast, Q_DST); case DLT_FDDI: return gen_fhostop(ebroadcast, Q_DST); @@ -7216,6 +7292,8 @@ gen_multicast(proto) /* all ARCnet multicasts use the same address */ return gen_ahostop(abroadcast, Q_DST); case DLT_EN10MB: + case DLT_NETANALYZER: + case DLT_NETANALYZER_TRANSPARENT: /* ether[0] & 1 != 0 */ return gen_mac_multicast(0); case DLT_FDDI: @@ -7479,6 +7557,11 @@ gen_inbound(dir) case DLT_JUNIPER_VP: case DLT_JUNIPER_ST: case DLT_JUNIPER_ISM: + case DLT_JUNIPER_VS: + case DLT_JUNIPER_SRX_E2E: + case DLT_JUNIPER_FIBRECHANNEL: + case DLT_JUNIPER_ATM_CEMIC: + /* juniper flags (including direction) are stored * the byte after the 3-byte magic number */ if (dir) { @@ -7759,6 +7842,30 @@ gen_ahostop(eaddr, dir) b1 = gen_ahostop(eaddr, Q_DST); gen_or(b0, b1); return b1; + + case Q_ADDR1: + bpf_error("'addr1' is only supported on 802.11"); + break; + + case Q_ADDR2: + bpf_error("'addr2' is only supported on 802.11"); + break; + + case Q_ADDR3: + bpf_error("'addr3' is only supported on 802.11"); + break; + + case Q_ADDR4: + bpf_error("'addr4' is only supported on 802.11"); + break; + + case Q_RA: + bpf_error("'ra' is only supported on 802.11"); + break; + + case Q_TA: + bpf_error("'ta' is only supported on 802.11"); + break; } abort(); /* NOTREACHED */ @@ -7813,9 +7920,15 @@ gen_vlan(vlan_num) switch (linktype) { case DLT_EN10MB: - /* check for VLAN */ + case DLT_NETANALYZER: + case DLT_NETANALYZER_TRANSPARENT: + /* check for VLAN, including QinQ */ b0 = gen_cmp(OR_LINK, off_linktype, BPF_H, (bpf_int32)ETHERTYPE_8021Q); + b1 = gen_cmp(OR_LINK, off_linktype, BPF_H, + (bpf_int32)ETHERTYPE_8021QINQ); + gen_or(b0,b1); + b0 = b1; /* If a specific VLAN is requested, check VLAN id */ if (vlan_num >= 0) { @@ -7876,6 +7989,8 @@ gen_mpls(label_num) case DLT_C_HDLC: /* fall through */ case DLT_EN10MB: + case DLT_NETANALYZER: + case DLT_NETANALYZER_TRANSPARENT: b0 = gen_linktype(ETHERTYPE_MPLS); break; |
