diff options
-rw-r--r-- | usr.sbin/wpa/l2_packet.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/usr.sbin/wpa/l2_packet.c b/usr.sbin/wpa/l2_packet.c index 541bcbe..b8beb78 100644 --- a/usr.sbin/wpa/l2_packet.c +++ b/usr.sbin/wpa/l2_packet.c @@ -20,6 +20,7 @@ */ #include <stdlib.h> #include <stdio.h> +#include <string.h> #include <errno.h> #include <pcap.h> @@ -38,6 +39,9 @@ #include "eloop.h" #include "l2_packet.h" +static const u8 pae_group_addr[ETH_ALEN] = + { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x03 }; + struct l2_packet_data { pcap_t *pcap; char ifname[100]; @@ -149,7 +153,7 @@ static int l2_packet_init_libpcap(struct l2_packet_data *l2, unsigned short protocol) { bpf_u_int32 pcap_maskp, pcap_netp; - char pcap_filter[100], pcap_err[PCAP_ERRBUF_SIZE]; + char pcap_filter[200], pcap_err[PCAP_ERRBUF_SIZE]; struct bpf_program pcap_fp; pcap_lookupnet(l2->ifname, &pcap_netp, &pcap_maskp, pcap_err); @@ -161,13 +165,17 @@ l2_packet_init_libpcap(struct l2_packet_data *l2, unsigned short protocol) } if (pcap_datalink(l2->pcap) != DLT_EN10MB && pcap_set_datalink(l2->pcap, DLT_EN10MB) < 0) { - fprintf(stderr, "pcap_set_datalinke(DLT_EN10MB): %s\n", + fprintf(stderr, "pcap_set_datalink(DLT_EN10MB): %s\n", pcap_geterr(l2->pcap)); return -1; } snprintf(pcap_filter, sizeof(pcap_filter), - "ether dst " MACSTR " and ether proto 0x%x", - MAC2STR(l2->own_addr), protocol); + "not ether src " MACSTR " and " + "( ether dst " MACSTR " or ether dst " MACSTR " ) and " + "ether proto 0x%x", + MAC2STR(l2->own_addr), /* do not receive own packets */ + MAC2STR(l2->own_addr), MAC2STR(pae_group_addr), + 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; |