aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Dodd <atd7@cornell.edu>2012-08-12 14:08:32 -0400
committerAndrew Dodd <atd7@cornell.edu>2012-08-12 21:17:06 -0400
commitf0bd0fea57b62ac0927d7f505e064dad1a3216c8 (patch)
tree41ed80978df17d0d724f87f9fdddd22ec359c3c3
parent1e653943e85ccd9efaa105459d4b7df14d24c49e (diff)
downloadandroid_external_wpa_supplicant_8-f0bd0fea57b62ac0927d7f505e064dad1a3216c8.tar.gz
android_external_wpa_supplicant_8-f0bd0fea57b62ac0927d7f505e064dad1a3216c8.tar.bz2
android_external_wpa_supplicant_8-f0bd0fea57b62ac0927d7f505e064dad1a3216c8.zip
Use legacy NL80211 STA events for older drivers
This allows tethering on devices with older bcmdhd drivers to be fixed. It conditionally reverts b638fe75d3cb9d21c67386173f10afe65053cc4d "nl80211: Use native cfg80211 sta events" for these boards. Use BOARD_LEGACY_NL80211_STA_EVENTS to enable this conditional revert. Change-Id: I4e436c57819944515455725cfd7ac7eeb31552ca
-rw-r--r--hostapd/Android.mk4
-rw-r--r--src/drivers/driver_nl80211.c119
-rw-r--r--wpa_supplicant/Android.mk4
3 files changed, 122 insertions, 5 deletions
diff --git a/hostapd/Android.mk b/hostapd/Android.mk
index 9ec55d5b..78c5707c 100644
--- a/hostapd/Android.mk
+++ b/hostapd/Android.mk
@@ -33,6 +33,10 @@ L_CFLAGS += -DANDROID_QCOM_PATCH
L_CFLAGS += -DANDROID_P2P
endif
+ifeq ($(BOARD_LEGACY_NL80211_STA_EVENTS),true)
+L_CFLAGS += -DLEGACY_STA_EVENTS
+endif
+
ifdef USES_TI_MAC80211
# Use Android specific directory for control interface sockets
L_CFLAGS += -DCONFIG_CTRL_IFACE_CLIENT_DIR=\"/data/misc/wifi/sockets\"
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index c8eddaa4..dc874387 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -1075,6 +1075,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");
@@ -1108,6 +1122,9 @@ 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);
}
@@ -1241,6 +1258,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;
@@ -1325,6 +1350,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) {
@@ -1335,6 +1367,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) {
@@ -2499,7 +2538,8 @@ broken_combination:
WPA_DRIVER_FLAGS_TDLS_EXTERNAL_SETUP;
}
}
-#ifndef ANDROID_P2P
+
+#if !defined (ANDROID_P2P) || defined (LEGACY_STA_EVENTS)
if (tb[NL80211_ATTR_DEVICE_AP_SME])
#endif
info->device_ap_sme = 1;
@@ -5192,6 +5232,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)
@@ -5201,7 +5249,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) {
/*
@@ -5418,7 +5466,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);
@@ -5456,8 +5506,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;
}
}
@@ -6154,7 +6210,7 @@ static int nl80211_setup_ap(struct i802_bss *bss)
if (nl80211_mgmt_subscribe_ap(bss))
return -1;
-#ifndef ANDROID_P2P
+#if defined (LEGACY_STA_EVENTS)
if (drv->device_ap_sme && !drv->use_monitor)
if (nl80211_mgmt_subscribe_ap_dev_sme(bss))
return -1;
@@ -6179,6 +6235,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;
}
@@ -6241,7 +6305,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)
@@ -8201,7 +8266,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);
diff --git a/wpa_supplicant/Android.mk b/wpa_supplicant/Android.mk
index 6b685ece..061709f8 100644
--- a/wpa_supplicant/Android.mk
+++ b/wpa_supplicant/Android.mk
@@ -38,6 +38,10 @@ L_CFLAGS += -DANDROID_QCOM_PATCH
L_CFLAGS += -DANDROID_P2P
endif
+ifeq ($(BOARD_LEGACY_NL80211_STA_EVENTS),true)
+L_CFLAGS += -DLEGACY_STA_EVENTS
+endif
+
# Use Android specific directory for control interface sockets
L_CFLAGS += -DCONFIG_CTRL_IFACE_CLIENT_DIR=\"/data/misc/wifi/sockets\"
L_CFLAGS += -DCONFIG_CTRL_IFACE_DIR=\"/data/system/wpa_supplicant\"