|
|
|
@ -155,6 +155,59 @@ static int hostapd_ctrl_iface_new_sta(struct hostapd_data *hapd,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_P2P_MANAGER
|
|
|
|
|
static int p2p_manager_disconnect(struct hostapd_data *hapd, u16 stype,
|
|
|
|
|
u8 minor_reason_code, const u8 *addr)
|
|
|
|
|
{
|
|
|
|
|
struct ieee80211_mgmt *mgmt;
|
|
|
|
|
int ret;
|
|
|
|
|
u8 *pos;
|
|
|
|
|
|
|
|
|
|
if (hapd->driver->send_frame == NULL)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
mgmt = os_zalloc(sizeof(*mgmt) + 100);
|
|
|
|
|
if (mgmt == NULL)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "P2P: Disconnect STA " MACSTR " with minor "
|
|
|
|
|
"reason code %u (stype=%u)",
|
|
|
|
|
MAC2STR(addr), minor_reason_code, stype);
|
|
|
|
|
|
|
|
|
|
mgmt->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT, stype);
|
|
|
|
|
os_memcpy(mgmt->da, addr, ETH_ALEN);
|
|
|
|
|
os_memcpy(mgmt->sa, hapd->own_addr, ETH_ALEN);
|
|
|
|
|
os_memcpy(mgmt->bssid, hapd->own_addr, ETH_ALEN);
|
|
|
|
|
if (stype == WLAN_FC_STYPE_DEAUTH) {
|
|
|
|
|
mgmt->u.deauth.reason_code =
|
|
|
|
|
host_to_le16(WLAN_REASON_PREV_AUTH_NOT_VALID);
|
|
|
|
|
pos = (u8 *) (&mgmt->u.deauth.reason_code + 1);
|
|
|
|
|
} else {
|
|
|
|
|
mgmt->u.disassoc.reason_code =
|
|
|
|
|
host_to_le16(WLAN_REASON_PREV_AUTH_NOT_VALID);
|
|
|
|
|
pos = (u8 *) (&mgmt->u.disassoc.reason_code + 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*pos++ = WLAN_EID_VENDOR_SPECIFIC;
|
|
|
|
|
*pos++ = 4 + 3 + 1;
|
|
|
|
|
WPA_PUT_BE24(pos, OUI_WFA);
|
|
|
|
|
pos += 3;
|
|
|
|
|
*pos++ = P2P_OUI_TYPE;
|
|
|
|
|
|
|
|
|
|
*pos++ = P2P_ATTR_MINOR_REASON_CODE;
|
|
|
|
|
WPA_PUT_LE16(pos, 1);
|
|
|
|
|
pos += 2;
|
|
|
|
|
*pos++ = minor_reason_code;
|
|
|
|
|
|
|
|
|
|
ret = hapd->driver->send_frame(hapd->drv_priv, (u8 *) mgmt,
|
|
|
|
|
pos - (u8 *) mgmt, 1);
|
|
|
|
|
os_free(mgmt);
|
|
|
|
|
|
|
|
|
|
return ret < 0 ? -1 : 0;
|
|
|
|
|
}
|
|
|
|
|
#endif /* CONFIG_P2P_MANAGER */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int hostapd_ctrl_iface_deauthenticate(struct hostapd_data *hapd,
|
|
|
|
|
const char *txtaddr)
|
|
|
|
|
{
|
|
|
|
@ -191,6 +244,14 @@ static int hostapd_ctrl_iface_deauthenticate(struct hostapd_data *hapd,
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_P2P_MANAGER
|
|
|
|
|
pos = os_strstr(txtaddr, " p2p=");
|
|
|
|
|
if (pos) {
|
|
|
|
|
return p2p_manager_disconnect(hapd, WLAN_FC_STYPE_DEAUTH,
|
|
|
|
|
atoi(pos + 5), addr);
|
|
|
|
|
}
|
|
|
|
|
#endif /* CONFIG_P2P_MANAGER */
|
|
|
|
|
|
|
|
|
|
hapd->drv.sta_deauth(hapd, addr, WLAN_REASON_PREV_AUTH_NOT_VALID);
|
|
|
|
|
sta = ap_get_sta(hapd, addr);
|
|
|
|
|
if (sta)
|
|
|
|
@ -237,6 +298,14 @@ static int hostapd_ctrl_iface_disassociate(struct hostapd_data *hapd,
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_P2P_MANAGER
|
|
|
|
|
pos = os_strstr(txtaddr, " p2p=");
|
|
|
|
|
if (pos) {
|
|
|
|
|
return p2p_manager_disconnect(hapd, WLAN_FC_STYPE_DISASSOC,
|
|
|
|
|
atoi(pos + 5), addr);
|
|
|
|
|
}
|
|
|
|
|
#endif /* CONFIG_P2P_MANAGER */
|
|
|
|
|
|
|
|
|
|
hapd->drv.sta_disassoc(hapd, addr, WLAN_REASON_PREV_AUTH_NOT_VALID);
|
|
|
|
|
sta = ap_get_sta(hapd, addr);
|
|
|
|
|
if (sta)
|
|
|
|
|