diff --git a/src/l2_packet/l2_packet_freebsd.c b/src/l2_packet/l2_packet_freebsd.c index 60de9fe6b..3f0b29924 100644 --- a/src/l2_packet/l2_packet_freebsd.c +++ b/src/l2_packet/l2_packet_freebsd.c @@ -20,6 +20,7 @@ #include #endif /* __sun__ */ +#include #include #include #include @@ -94,6 +95,13 @@ static void l2_packet_receive(int sock, void *eloop_ctx, void *sock_ctx) } else { buf = (unsigned char *) (ethhdr + 1); len = hdr.caplen - sizeof(*ethhdr); + + /* Handle IEEE 802.1Q encapsulated frames */ + if (len >= ETHER_VLAN_ENCAP_LEN && + ethhdr->h_proto == htons(ETH_P_8021Q)) { + buf += ETHER_VLAN_ENCAP_LEN; + len -= ETHER_VLAN_ENCAP_LEN; + } } l2->rx_callback(l2->rx_callback_ctx, ethhdr->h_source, buf, len); } @@ -122,10 +130,10 @@ static int l2_packet_init_libpcap(struct l2_packet_data *l2, os_snprintf(pcap_filter, sizeof(pcap_filter), "not ether src " MACSTR " and " "( ether dst " MACSTR " or ether dst " MACSTR " ) and " - "ether proto 0x%x", + "( ether proto 0x%x or ( vlan 0 and ether proto 0x%x ) )", MAC2STR(l2->own_addr), /* do not receive own packets */ MAC2STR(l2->own_addr), MAC2STR(pae_group_addr), - protocol); + protocol, protocol); if (pcap_compile(l2->pcap, &pcap_fp, pcap_filter, 1, pcap_netp) < 0) { fprintf(stderr, "pcap_compile: %s\n", pcap_geterr(l2->pcap)); return -1;