From d4ae515851ff23bb8d0e79ebf629fe88c40646f1 Mon Sep 17 00:00:00 2001 From: Eyal Shapira Date: Wed, 12 Sep 2012 02:30:00 +0300 Subject: nl80211: reconfigure RX filters whenever a new interface is added (ANDROID) This is used to reconfigure RX filters to include a new filter whenever the P2P group interface is added. The new filter matches any unicast frame sent to a dest mac which matches the P2P group interface mac. This is important as otherwise we wouldn't allow any data frames through to this interface. Signed-off-by: Eyal Shapira --- src/drivers/driver_nl80211.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src') diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index d29095e..e0bf84f 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -207,6 +207,10 @@ struct i802_bss { struct nl80211_wiphy_data *wiphy_data; struct dl_list wiphy_list; + +#ifdef ANDROID + int rx_filter_idx; +#endif }; struct wpa_driver_nl80211_data { @@ -3011,6 +3015,9 @@ static void * wpa_driver_nl80211_init(void *ctx, const char *ifname, bss = &drv->first_bss; bss->drv = drv; os_strlcpy(bss->ifname, ifname, sizeof(bss->ifname)); +#ifdef ANDROID + bss->rx_filter_idx = -1; +#endif drv->monitor_ifidx = -1; drv->monitor_sock = -1; drv->eapol_tx_sock = -1; @@ -7961,6 +7968,10 @@ static int wpa_driver_nl80211_if_add(void *priv, enum wpa_driver_if_type type, struct i802_bss *bss = priv; struct wpa_driver_nl80211_data *drv = bss->drv; int ifidx; +#ifdef ANDROID + int filter_idx; +#endif + #ifdef HOSTAPD struct i802_bss *new_bss = NULL; @@ -8021,6 +8032,26 @@ static int wpa_driver_nl80211_if_add(void *priv, enum wpa_driver_if_type type, } #endif /* CONFIG_P2P */ +#if defined(ANDROID) && !defined(HOSTAPD) + static u8 eth_addr_mask[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; + + filter_idx = nl80211_register_rx_filter(bss, "unicast", + if_addr, ETH_ALEN, + eth_addr_mask, + NL80211_WOWLAN_ACTION_ALLOW); + if (filter_idx < 0) { + nl80211_remove_iface(drv, ifidx); + return -1; + } + + if (bss->rx_filter_idx != -1) + wpa_printf(MSG_WARNING, "nl80211: Rx filter is already " + "configured when it shouldn't be (idx=%d)", + bss->rx_filter_idx); + + bss->rx_filter_idx = filter_idx; +#endif /* ANDROID && !HOSTAPD */ + #ifdef HOSTAPD if (bridge && i802_check_bridge(drv, new_bss, bridge, ifname) < 0) { @@ -8093,6 +8124,10 @@ static int wpa_driver_nl80211_if_remove(void *priv, nl80211_remove_iface(drv, ifindex); +#ifdef ANDROID + nl80211_unregister_rx_filter(bss, bss->rx_filter_idx); +#endif + #ifdef HOSTAPD if (type != WPA_IF_AP_BSS) return 0; -- cgit v1.1