Add P2P support for BRCM CFG80211 driver
Change-Id: Iafec4bedbd33836d0a64e7ea054d8a46ef8ec204
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
diff --git a/src/ap/beacon.c b/src/ap/beacon.c
index 5544925..0091064 100644
--- a/src/ap/beacon.c
+++ b/src/ap/beacon.c
@@ -215,11 +215,12 @@
return;
ie_len = len - (IEEE80211_HDRLEN + sizeof(mgmt->u.probe_req));
+#ifndef ANDROID_BRCM_P2P_PATCH
for (i = 0; hapd->probereq_cb && i < hapd->num_probereq_cb; i++)
if (hapd->probereq_cb[i].cb(hapd->probereq_cb[i].ctx,
mgmt->sa, ie, ie_len) > 0)
return;
-
+#endif
if (!hapd->iconf->send_probe_response)
return;
diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c
index fc4bc31..10e3af9 100644
--- a/src/ap/drv_callbacks.c
+++ b/src/ap/drv_callbacks.c
@@ -227,6 +227,11 @@
sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC);
wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_DISCONNECTED MACSTR,
MAC2STR(sta->addr));
+#ifdef ANDROID_BRCM_P2P_PATCH
+ if(hapd->msg_ctx_parent)
+ wpa_msg(hapd->msg_ctx_parent, MSG_INFO, AP_STA_DISCONNECTED MACSTR,
+ MAC2STR(sta->addr));
+#endif /* ANDROID_BRCM_P2P_PATCH */
wpa_auth_sm_event(sta->wpa_sm, WPA_DISASSOC);
sta->acct_terminate_cause = RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST;
ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h
index d4501a1..3764be4 100644
--- a/src/ap/hostapd.h
+++ b/src/ap/hostapd.h
@@ -81,6 +81,10 @@
struct sta_info *sta, int reassoc);
void *msg_ctx; /* ctx for wpa_msg() calls */
+#ifdef ANDROID_BRCM_P2P_PATCH
+ /* Sending the event to parent is required as SSL listens on parent ctrl iface */
+ void *msg_ctx_parent; /* ctx for wpa_msg() calls */
+#endif /*ANDROID_BRCM_P2P_PATCH*/
struct radius_client_data *radius;
u32 acct_session_id_hi, acct_session_id_lo;
diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c
index 4d8dd25..e0a3a36 100644
--- a/src/ap/ieee802_11.c
+++ b/src/ap/ieee802_11.c
@@ -1163,6 +1163,12 @@
sta->flags &= ~(WLAN_STA_ASSOC | WLAN_STA_ASSOC_REQ_OK);
wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_DISCONNECTED MACSTR,
MAC2STR(sta->addr));
+#ifdef ANDROID_BRCM_P2P_PATCH
+ if(hapd->msg_ctx_parent)
+ wpa_msg(hapd->msg_ctx_parent, MSG_INFO, AP_STA_DISCONNECTED MACSTR,
+ MAC2STR(sta->addr));
+#endif /* ANDROID_BRCM_P2P_PATCH */
+
wpa_auth_sm_event(sta->wpa_sm, WPA_DISASSOC);
hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
HOSTAPD_LEVEL_INFO, "disassociated");
@@ -1214,6 +1220,11 @@
WLAN_STA_ASSOC_REQ_OK);
wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_DISCONNECTED MACSTR,
MAC2STR(sta->addr));
+#ifdef ANDROID_BRCM_P2P_PATCH
+ if(hapd->msg_ctx_parent)
+ wpa_msg(hapd->msg_ctx_parent, MSG_INFO, AP_STA_DISCONNECTED MACSTR,
+ MAC2STR(sta->addr));
+#endif /* ANDROID_BRCM_P2P_PATCH */
wpa_auth_sm_event(sta->wpa_sm, WPA_DEAUTH);
hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
HOSTAPD_LEVEL_DEBUG, "deauthenticated");
@@ -1679,6 +1690,12 @@
ap_sta_set_authorized(hapd, sta, 1);
wpa_msg(hapd->msg_ctx, MSG_INFO,
AP_STA_CONNECTED MACSTR, MAC2STR(sta->addr));
+#ifdef ANDROID_BRCM_P2P_PATCH
+ /* Sending the event to parent is required as SSL listens on parent ctrl iface */
+ if(hapd->msg_ctx_parent)
+ wpa_msg(hapd->msg_ctx_parent, MSG_INFO,
+ AP_STA_CONNECTED MACSTR, MAC2STR(sta->addr));
+#endif /* ANDROID_BRCM_P2P_PATCH */
}
if (reassoc)
diff --git a/src/ap/ieee802_1x.c b/src/ap/ieee802_1x.c
index 6b6fd4b..8737455 100644
--- a/src/ap/ieee802_1x.c
+++ b/src/ap/ieee802_1x.c
@@ -89,18 +89,32 @@
return;
if (authorized) {
- if (!ap_sta_is_authorized(sta))
+ if (!ap_sta_is_authorized(sta)) {
wpa_msg(hapd->msg_ctx, MSG_INFO,
AP_STA_CONNECTED MACSTR, MAC2STR(sta->addr));
+#ifdef ANDROID_BRCM_P2P_PATCH
+ /* Sending the event to parent is required as SSL listens on parent ctrl iface */
+ if(hapd->msg_ctx_parent)
+ wpa_msg(hapd->msg_ctx_parent, MSG_INFO,
+ AP_STA_CONNECTED MACSTR, MAC2STR(sta->addr));
+#endif /* ANDROID_BRCM_P2P_PATCH */
+ }
ap_sta_set_authorized(hapd, sta, 1);
res = hostapd_set_authorized(hapd, sta, 1);
hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE8021X,
HOSTAPD_LEVEL_DEBUG, "authorizing port");
} else {
- if (ap_sta_is_authorized(sta) && (sta->flags & WLAN_STA_ASSOC))
+ if (ap_sta_is_authorized(sta) && (sta->flags & WLAN_STA_ASSOC)) {
wpa_msg(hapd->msg_ctx, MSG_INFO,
AP_STA_DISCONNECTED MACSTR,
MAC2STR(sta->addr));
+#ifdef ANDROID_BRCM_P2P_PATCH
+ if(hapd->msg_ctx_parent)
+ wpa_msg(hapd->msg_ctx_parent, MSG_INFO,
+ AP_STA_DISCONNECTED MACSTR,
+ MAC2STR(sta->addr));
+#endif /* ANDROID_BRCM_P2P_PATCH */
+ }
ap_sta_set_authorized(hapd, sta, 0);
res = hostapd_set_authorized(hapd, sta, 0);
hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE8021X,
diff --git a/src/ap/wpa_auth_ie.c b/src/ap/wpa_auth_ie.c
index 5e8d134..9d4aa67 100644
--- a/src/ap/wpa_auth_ie.c
+++ b/src/ap/wpa_auth_ie.c
@@ -253,10 +253,19 @@
capab |= WPA_CAPABILITY_PREAUTH;
if (conf->peerkey)
capab |= WPA_CAPABILITY_PEERKEY_ENABLED;
+#ifdef ANDROID_BRCM_P2P_PATCH
+ /* WAR: we should make an get_wpa_rsnie_cap() to get the cap of peer supp
+ * Temporally we force tp set replay counter tp 0x3
+ * as if wmm is enable in all of supp device
+ */
+ capab |= (RSN_NUM_REPLAY_COUNTERS_16 << 2);
+#else
if (conf->wmm_enabled) {
/* 4 PTKSA replay counters when using WMM */
capab |= (RSN_NUM_REPLAY_COUNTERS_16 << 2);
}
+#endif /* ANDROID_BRCM_P2P_PATCH */
+
#ifdef CONFIG_IEEE80211W
if (conf->ieee80211w != NO_MGMT_FRAME_PROTECTION) {
capab |= WPA_CAPABILITY_MFPC;