diff options
Diffstat (limited to 'src/drivers')
-rw-r--r-- | src/drivers/driver_nl80211.c | 121 |
1 files changed, 118 insertions, 3 deletions
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 4574938..5be2d48 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -306,6 +306,11 @@ static int android_pno_start(struct i802_bss *bss, static int android_pno_stop(struct i802_bss *bss); #endif /* ANDROID */ #ifdef ANDROID_P2P +#ifdef LEGACY_STA_EVENTS +static void mlme_event_deauth_disassoc(struct wpa_driver_nl80211_data *drv, + enum wpa_event_type type, + const u8 *frame, size_t len); +#endif /* LEGACY_STA_EVENTS */ int wpa_driver_set_p2p_noa(void *priv, u8 count, int start, int duration); int wpa_driver_get_p2p_noa(void *priv, u8 *buf, size_t len); int wpa_driver_set_p2p_ps(void *priv, int legacy_ps, int opp_ps, int ctwindow); @@ -1098,6 +1103,20 @@ static void mlme_event_assoc(struct wpa_driver_nl80211_data *drv, u16 status; mgmt = (const struct ieee80211_mgmt *) frame; +#if (defined (CONFIG_AP) || defined (HOSTAPD) ) && defined (LEGACY_STA_EVENTS) + if (drv->nlmode == NL80211_IFTYPE_AP || drv->nlmode == NL80211_IFTYPE_P2P_GO) { + if (len < 24 + sizeof(mgmt->u.assoc_req)) { + wpa_printf(MSG_DEBUG, "nl80211: Too short association event " + "frame"); + return; + } + os_memset(&event, 0, sizeof(event)); + event.assoc_info.freq = drv->assoc_freq; + event.assoc_info.req_ies = (u8 *) mgmt->u.assoc_req.variable; + event.assoc_info.req_ies_len = len - 24 - sizeof(mgmt->u.assoc_req); + event.assoc_info.addr = mgmt->sa; + } else { +#endif if (len < 24 + sizeof(mgmt->u.assoc_resp)) { wpa_printf(MSG_DEBUG, "nl80211: Too short association event " "frame"); @@ -1132,6 +1151,10 @@ static void mlme_event_assoc(struct wpa_driver_nl80211_data *drv, event.assoc_info.freq = drv->assoc_freq; +#if (defined (CONFIG_AP) || defined(HOSTAPD)) && defined (LEGACY_STA_EVENTS) + } +#endif + wpa_supplicant_event(drv->ctx, EVENT_ASSOC, &event); } @@ -1304,6 +1327,14 @@ static void mlme_event_mgmt(struct wpa_driver_nl80211_data *drv, event.rx_action.data = &mgmt->u.action.category + 1; event.rx_action.len = frame + len - event.rx_action.data; wpa_supplicant_event(drv->ctx, EVENT_RX_ACTION, &event); +#if defined (LEGACY_STA_EVENTS) + } else if (stype == WLAN_FC_STYPE_ASSOC_REQ) { + mlme_event_assoc(drv, frame, len); + } else if (stype == WLAN_FC_STYPE_DISASSOC) { + mlme_event_deauth_disassoc(drv, EVENT_DISASSOC, frame, len); + } else if (stype == WLAN_FC_STYPE_DEAUTH) { + mlme_event_deauth_disassoc(drv, EVENT_DEAUTH, frame, len); +#endif } else { event.rx_mgmt.frame = frame; event.rx_mgmt.frame_len = len; @@ -1389,6 +1420,13 @@ static void mlme_event_deauth_disassoc(struct wpa_driver_nl80211_data *drv, if (type == EVENT_DISASSOC) { event.disassoc_info.locally_generated = !os_memcmp(mgmt->sa, drv->first_bss.addr, ETH_ALEN); + +#if defined (LEGACY_STA_EVENTS) + if (drv->nlmode == NL80211_IFTYPE_AP || + drv->nlmode == NL80211_IFTYPE_P2P_GO) { + event.disassoc_info.addr = mgmt->sa; + } else +#endif event.disassoc_info.addr = bssid; event.disassoc_info.reason_code = reason_code; if (frame + len > mgmt->u.disassoc.variable) { @@ -1399,6 +1437,13 @@ static void mlme_event_deauth_disassoc(struct wpa_driver_nl80211_data *drv, } else { event.deauth_info.locally_generated = !os_memcmp(mgmt->sa, drv->first_bss.addr, ETH_ALEN); + +#if defined (LEGACY_STA_EVENTS) + if (drv->nlmode == NL80211_IFTYPE_AP || + drv->nlmode == NL80211_IFTYPE_P2P_GO) { + event.deauth_info.addr = mgmt->sa; + } else +#endif event.deauth_info.addr = bssid; event.deauth_info.reason_code = reason_code; if (frame + len > mgmt->u.deauth.variable) { @@ -2669,7 +2714,7 @@ static int wpa_driver_nl80211_capa(struct wpa_driver_nl80211_data *drv) drv->poll_command_supported = info.poll_command_supported; drv->data_tx_status = info.data_tx_status; -#ifdef ANDROID_P2P +#if defined(ANDROID_P2P) && !defined(LEGACY_STA_EVENTS) if(drv->capa.flags & WPA_DRIVER_FLAGS_OFFCHANNEL_TX) { /* Driver is new enough to support monitorless mode*/ wpa_printf(MSG_DEBUG, "nl80211: Driver is new " @@ -5328,6 +5373,14 @@ static int wpa_driver_nl80211_send_mlme_freq(struct i802_bss *bss, data, data_len, NULL, 1, noack, 1); } +#if defined (LEGACY_STA_EVENTS) + if (freq == 0) + freq = bss->freq; + if ( is_ap_interface(drv->nlmode)) { + return nl80211_send_frame_cmd(bss, freq, 0, + data, data_len, &drv->send_action_cookie, 0, noack, 1); + } +#else if (drv->device_ap_sme && is_ap_interface(drv->nlmode)) { if (freq == 0) @@ -5339,7 +5392,7 @@ static int wpa_driver_nl80211_send_mlme_freq(struct i802_bss *bss, &drv->send_action_cookie, no_cck, noack, offchanok); } - +#endif if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT && WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_AUTH) { /* @@ -5567,6 +5620,9 @@ static int wpa_driver_nl80211_set_ap(void *priv, params->short_slot_time, params->ht_opmode, params->isolate, params->basic_rates); } +#if defined(HOSTAPD) && defined(LEGACY_STA_EVENTS) + wpa_driver_nl80211_probe_req_report(priv, 1); +#endif return ret; nla_put_failure: nlmsg_free(msg); @@ -5604,8 +5660,14 @@ static int wpa_driver_nl80211_set_freq(struct i802_bss *bss, NL80211_CHAN_HT40PLUS); break; default: +#if !(defined (ANDROID_P2P) || defined (LEGACY_STA_EVENTS)) +/* Should be change to HT20 as a default value because P2P firmware does not support 11n for BCM4329 */ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, NL80211_CHAN_HT20); +#else + NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, + NL80211_CHAN_NO_HT); +#endif break; } } @@ -6329,6 +6391,14 @@ static int nl80211_setup_ap(struct i802_bss *bss) /* Try to survive without this */ } +#if defined (LEGACY_STA_EVENTS) + /* For AP mode, enable probe req report even if device_ap_sme + * is not enabled + */ + wpa_printf(MSG_DEBUG, "nl80211: Enabling probe req report"); + wpa_driver_nl80211_probe_req_report(bss, 1); +#endif + return 0; } @@ -6391,7 +6461,8 @@ static int wpa_driver_nl80211_hapd_send_eapol( u8 *pos; int res; int qos = flags & WPA_STA_WMM; -#ifndef ANDROID_P2P + +#if defined (LEGACY_STA_EVENTS) || !defined (ANDROID_P2P) if (drv->device_ap_sme || !drv->use_monitor) #else if (drv->device_ap_sme && !drv->use_monitor) @@ -8402,7 +8473,51 @@ static int wpa_driver_nl80211_probe_req_report(void *priv, int report) (WLAN_FC_STYPE_PROBE_REQ << 4), NULL, 0) < 0) goto out_err; +#if defined (LEGACY_STA_EVENTS) + if (drv->nlmode != NL80211_IFTYPE_AP && + drv->nlmode != NL80211_IFTYPE_P2P_GO) { + wpa_printf(MSG_DEBUG, "nl80211: probe_req_report control only " + "allowed in AP or P2P GO mode (iftype=%d)", + drv->nlmode); + goto done; + } + if (nl80211_register_frame(bss, bss->nl_preq, + (WLAN_FC_TYPE_MGMT << 2) | + (WLAN_FC_STYPE_ASSOC_REQ << 4), + NULL, 0) < 0) { + goto out_err; + } + if (nl80211_register_frame(bss, bss->nl_preq, + (WLAN_FC_TYPE_MGMT << 2) | + (WLAN_FC_STYPE_REASSOC_REQ << 4), + NULL, 0) < 0) { + goto out_err; + } + + if (nl80211_register_frame(bss, bss->nl_preq, + (WLAN_FC_TYPE_MGMT << 2) | + (WLAN_FC_STYPE_DISASSOC << 4), + NULL, 0) < 0) { + goto out_err; + } + + if (nl80211_register_frame(bss, bss->nl_preq, + (WLAN_FC_TYPE_MGMT << 2) | + (WLAN_FC_STYPE_DEAUTH << 4), + NULL, 0) < 0) { + goto out_err; + } + + if (nl80211_register_frame(bss, bss->nl_preq, + (WLAN_FC_TYPE_MGMT << 2) | + (WLAN_FC_STYPE_ACTION << 4), + NULL, 0) < 0) { + goto out_err; + } + +done: +#endif /* ANDROID_P2P */ eloop_register_read_sock(nl_socket_get_fd(bss->nl_preq), wpa_driver_nl80211_event_receive, bss->nl_cb, bss->nl_preq); |