PERFORCE change 117747 for review

Sam Leffler sam at FreeBSD.org
Mon Apr 9 16:31:06 UTC 2007


http://perforce.freebsd.org/chv.cgi?CH=117747

Change 117747 by sam at sam_ebb on 2007/04/09 16:30:22

	change bpf program to filter frames w/ our src address
	and to accept frames from the multicast address; this
	enables use of wpa_supplicant on wired networks
	Submitted by:	"Jouke Witteveen" <j.witteveen at gmail.com>

Affected files ...

.. //depot/projects/wifi/usr.sbin/wpa/l2_packet.c#4 edit

Differences ...

==== //depot/projects/wifi/usr.sbin/wpa/l2_packet.c#4 (text+ko) ====

@@ -38,6 +38,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 +152,7 @@
 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 +164,17 @@
 	}
 	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;


More information about the p4-projects mailing list