为什么 Bpf 允许 ether[0:2] 和 ether[0:4] 但不允许 ether[0:3]?

Why does Bpf allow ether[0:2] and ether[0:4] but not ether[0:3]?

为什么 Berkeley Packet Filter 允许过滤 ether[0:2] 和 ether[0:4] 但不允许 ether[0:3] 是供应商?tcpdump 'ether[0:3] = 0x000000' returns 与 tcpdump: data size must be 1, 2, or 4

pcap-filter 手册页(搜索“字节偏移量”)证实了这一点,但它也没有提供额外信息。

我的猜测是 libpcap refuses to create a program that compares three bytes at a time because the classic BPF programs it generates do not have instructions 直接支持此类比较。它可以将一个字节、一个半字(两个字节)或一个字(四个字节)加载到其中一个寄存器中,并将其与一个值进行比较,但它不能处理三字节长的值。

我想解决方法是分两步比较值,ether[0:2] 然后 ether[2]