2009-12-24 09:15:22 -05:00
|
|
|
/*
|
|
|
|
* hostapd - Driver operations
|
2010-03-13 14:43:00 -05:00
|
|
|
* Copyright (c) 2009-2010, Jouni Malinen <j@w1.fi>
|
2009-12-24 09:15:22 -05:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* Alternatively, this software may be distributed under the terms of BSD
|
|
|
|
* license.
|
|
|
|
*
|
|
|
|
* See README and COPYING for more details.
|
|
|
|
*/
|
|
|
|
|
2009-12-25 17:12:25 -05:00
|
|
|
#include "utils/includes.h"
|
2009-12-24 09:15:22 -05:00
|
|
|
|
2009-12-25 17:12:25 -05:00
|
|
|
#include "utils/common.h"
|
2009-12-25 17:21:22 -05:00
|
|
|
#include "drivers/driver.h"
|
2010-03-13 14:43:00 -05:00
|
|
|
#include "common/ieee802_11_defs.h"
|
2010-09-22 13:46:44 -04:00
|
|
|
#include "wps/wps.h"
|
2009-12-25 17:12:25 -05:00
|
|
|
#include "hostapd.h"
|
|
|
|
#include "ieee802_11.h"
|
|
|
|
#include "sta_info.h"
|
|
|
|
#include "ap_config.h"
|
2010-10-08 11:16:07 -04:00
|
|
|
#include "p2p_hostapd.h"
|
2009-12-25 07:20:35 -05:00
|
|
|
#include "ap_drv_ops.h"
|
2009-12-24 09:15:22 -05:00
|
|
|
|
|
|
|
|
2011-04-02 15:03:05 -04:00
|
|
|
u32 hostapd_sta_flags_to_drv(u32 flags)
|
2009-12-24 16:11:16 -05:00
|
|
|
{
|
|
|
|
int res = 0;
|
|
|
|
if (flags & WLAN_STA_AUTHORIZED)
|
|
|
|
res |= WPA_STA_AUTHORIZED;
|
|
|
|
if (flags & WLAN_STA_WMM)
|
|
|
|
res |= WPA_STA_WMM;
|
|
|
|
if (flags & WLAN_STA_SHORT_PREAMBLE)
|
|
|
|
res |= WPA_STA_SHORT_PREAMBLE;
|
|
|
|
if (flags & WLAN_STA_MFP)
|
|
|
|
res |= WPA_STA_MFP;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-26 14:14:25 -04:00
|
|
|
int hostapd_build_ap_extra_ies(struct hostapd_data *hapd,
|
|
|
|
struct wpabuf **beacon,
|
|
|
|
struct wpabuf **proberesp,
|
|
|
|
struct wpabuf **assocresp)
|
2009-12-24 09:15:22 -05:00
|
|
|
{
|
2011-08-26 14:14:25 -04:00
|
|
|
*beacon = hapd->wps_beacon_ie;
|
|
|
|
*proberesp = hapd->wps_probe_resp_ie;
|
|
|
|
*assocresp = NULL;
|
2010-04-11 13:16:43 -04:00
|
|
|
|
2010-07-18 17:30:25 -04:00
|
|
|
#ifdef CONFIG_P2P
|
|
|
|
if (hapd->wps_beacon_ie == NULL && hapd->p2p_beacon_ie == NULL)
|
2011-08-26 14:14:25 -04:00
|
|
|
*beacon = NULL;
|
2010-07-18 17:30:25 -04:00
|
|
|
else {
|
2011-08-26 14:14:25 -04:00
|
|
|
*beacon = wpabuf_alloc((hapd->wps_beacon_ie ?
|
|
|
|
wpabuf_len(hapd->wps_beacon_ie) : 0) +
|
|
|
|
(hapd->p2p_beacon_ie ?
|
|
|
|
wpabuf_len(hapd->p2p_beacon_ie) : 0));
|
|
|
|
if (*beacon == NULL)
|
2010-07-18 17:30:25 -04:00
|
|
|
return -1;
|
|
|
|
if (hapd->wps_beacon_ie)
|
2011-08-26 14:14:25 -04:00
|
|
|
wpabuf_put_buf(*beacon, hapd->wps_beacon_ie);
|
2010-07-18 17:30:25 -04:00
|
|
|
if (hapd->p2p_beacon_ie)
|
2011-08-26 14:14:25 -04:00
|
|
|
wpabuf_put_buf(*beacon, hapd->p2p_beacon_ie);
|
2010-07-18 17:30:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (hapd->wps_probe_resp_ie == NULL && hapd->p2p_probe_resp_ie == NULL)
|
2011-08-26 14:14:25 -04:00
|
|
|
*proberesp = NULL;
|
2010-07-18 17:30:25 -04:00
|
|
|
else {
|
2011-08-26 14:14:25 -04:00
|
|
|
*proberesp = wpabuf_alloc(
|
2010-07-18 17:30:25 -04:00
|
|
|
(hapd->wps_probe_resp_ie ?
|
|
|
|
wpabuf_len(hapd->wps_probe_resp_ie) : 0) +
|
|
|
|
(hapd->p2p_probe_resp_ie ?
|
|
|
|
wpabuf_len(hapd->p2p_probe_resp_ie) : 0));
|
2011-08-26 14:14:25 -04:00
|
|
|
if (*proberesp == NULL) {
|
|
|
|
wpabuf_free(*beacon);
|
2010-07-18 17:30:25 -04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (hapd->wps_probe_resp_ie)
|
2011-08-26 14:14:25 -04:00
|
|
|
wpabuf_put_buf(*proberesp, hapd->wps_probe_resp_ie);
|
2010-07-18 17:30:25 -04:00
|
|
|
if (hapd->p2p_probe_resp_ie)
|
2011-08-26 14:14:25 -04:00
|
|
|
wpabuf_put_buf(*proberesp, hapd->p2p_probe_resp_ie);
|
2010-07-18 17:30:25 -04:00
|
|
|
}
|
|
|
|
#endif /* CONFIG_P2P */
|
|
|
|
|
2010-10-08 11:16:07 -04:00
|
|
|
#ifdef CONFIG_P2P_MANAGER
|
|
|
|
if (hapd->conf->p2p & P2P_MANAGE) {
|
|
|
|
struct wpabuf *a;
|
|
|
|
|
2011-08-26 14:14:25 -04:00
|
|
|
a = wpabuf_alloc(100 + (*beacon ? wpabuf_len(*beacon) : 0));
|
2010-10-08 11:16:07 -04:00
|
|
|
if (a) {
|
|
|
|
u8 *start, *p;
|
2011-08-26 14:14:25 -04:00
|
|
|
if (*beacon)
|
|
|
|
wpabuf_put_buf(a, *beacon);
|
|
|
|
if (*beacon != hapd->wps_beacon_ie)
|
|
|
|
wpabuf_free(*beacon);
|
2010-10-08 11:16:07 -04:00
|
|
|
start = wpabuf_put(a, 0);
|
|
|
|
p = hostapd_eid_p2p_manage(hapd, start);
|
|
|
|
wpabuf_put(a, p - start);
|
2011-08-26 14:14:25 -04:00
|
|
|
*beacon = a;
|
2010-10-08 11:16:07 -04:00
|
|
|
}
|
|
|
|
|
2011-08-26 14:14:25 -04:00
|
|
|
a = wpabuf_alloc(100 + (*proberesp ? wpabuf_len(*proberesp) :
|
2010-10-08 11:16:07 -04:00
|
|
|
0));
|
|
|
|
if (a) {
|
|
|
|
u8 *start, *p;
|
2011-08-26 14:14:25 -04:00
|
|
|
if (*proberesp)
|
|
|
|
wpabuf_put_buf(a, *proberesp);
|
|
|
|
if (*proberesp != hapd->wps_probe_resp_ie)
|
|
|
|
wpabuf_free(*proberesp);
|
2010-10-08 11:16:07 -04:00
|
|
|
start = wpabuf_put(a, 0);
|
|
|
|
p = hostapd_eid_p2p_manage(hapd, start);
|
|
|
|
wpabuf_put(a, p - start);
|
2011-08-26 14:14:25 -04:00
|
|
|
*proberesp = a;
|
2010-10-08 11:16:07 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_P2P_MANAGER */
|
|
|
|
|
2010-09-22 13:46:44 -04:00
|
|
|
#ifdef CONFIG_WPS2
|
|
|
|
if (hapd->conf->wps_state)
|
2011-08-26 14:14:25 -04:00
|
|
|
*assocresp = wps_build_assoc_resp_ie();
|
2010-09-22 13:46:44 -04:00
|
|
|
#endif /* CONFIG_WPS2 */
|
|
|
|
|
2010-10-08 11:16:07 -04:00
|
|
|
#ifdef CONFIG_P2P_MANAGER
|
|
|
|
if (hapd->conf->p2p & P2P_MANAGE) {
|
|
|
|
struct wpabuf *a;
|
2011-08-26 14:14:25 -04:00
|
|
|
a = wpabuf_alloc(100 + (*assocresp ? wpabuf_len(*assocresp) :
|
2010-10-08 11:16:07 -04:00
|
|
|
0));
|
|
|
|
if (a) {
|
|
|
|
u8 *start, *p;
|
|
|
|
start = wpabuf_put(a, 0);
|
|
|
|
p = hostapd_eid_p2p_manage(hapd, start);
|
|
|
|
wpabuf_put(a, p - start);
|
2011-08-26 14:14:25 -04:00
|
|
|
if (*assocresp) {
|
|
|
|
wpabuf_put_buf(a, *assocresp);
|
|
|
|
wpabuf_free(*assocresp);
|
2010-10-08 11:16:07 -04:00
|
|
|
}
|
2011-08-26 14:14:25 -04:00
|
|
|
*assocresp = a;
|
2010-10-08 11:16:07 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_P2P_MANAGER */
|
|
|
|
|
2011-08-26 14:14:25 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-04-11 13:16:43 -04:00
|
|
|
|
2011-08-26 14:14:25 -04:00
|
|
|
void hostapd_free_ap_extra_ies(struct hostapd_data *hapd, struct wpabuf *beacon,
|
|
|
|
struct wpabuf *proberesp,
|
|
|
|
struct wpabuf *assocresp)
|
|
|
|
{
|
2010-10-08 11:16:07 -04:00
|
|
|
if (beacon != hapd->wps_beacon_ie)
|
|
|
|
wpabuf_free(beacon);
|
|
|
|
if (proberesp != hapd->wps_probe_resp_ie)
|
|
|
|
wpabuf_free(proberesp);
|
2010-09-22 13:46:44 -04:00
|
|
|
wpabuf_free(assocresp);
|
2011-08-26 14:14:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_set_ap_wps_ie(struct hostapd_data *hapd)
|
|
|
|
{
|
|
|
|
struct wpabuf *beacon, *proberesp, *assocresp;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (hapd->driver == NULL || hapd->driver->set_ap_wps_ie == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (hostapd_build_ap_extra_ies(hapd, &beacon, &proberesp, &assocresp) <
|
|
|
|
0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
ret = hapd->driver->set_ap_wps_ie(hapd->drv_priv, beacon, proberesp,
|
|
|
|
assocresp);
|
|
|
|
|
|
|
|
hostapd_free_ap_extra_ies(hapd, beacon, proberesp, assocresp);
|
2010-07-18 17:30:25 -04:00
|
|
|
|
2010-04-11 13:16:43 -04:00
|
|
|
return ret;
|
2009-12-24 09:15:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-24 09:50:06 -05:00
|
|
|
int hostapd_set_authorized(struct hostapd_data *hapd,
|
|
|
|
struct sta_info *sta, int authorized)
|
2009-12-24 13:41:30 -05:00
|
|
|
{
|
|
|
|
if (authorized) {
|
|
|
|
return hostapd_sta_set_flags(hapd, sta->addr,
|
|
|
|
hostapd_sta_flags_to_drv(
|
|
|
|
sta->flags),
|
|
|
|
WPA_STA_AUTHORIZED, ~0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hostapd_sta_set_flags(hapd, sta->addr,
|
|
|
|
hostapd_sta_flags_to_drv(sta->flags),
|
|
|
|
0, ~WPA_STA_AUTHORIZED);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-24 09:50:06 -05:00
|
|
|
int hostapd_set_sta_flags(struct hostapd_data *hapd, struct sta_info *sta)
|
2009-12-24 16:11:16 -05:00
|
|
|
{
|
|
|
|
int set_flags, total_flags, flags_and, flags_or;
|
|
|
|
total_flags = hostapd_sta_flags_to_drv(sta->flags);
|
|
|
|
set_flags = WPA_STA_SHORT_PREAMBLE | WPA_STA_WMM | WPA_STA_MFP;
|
2010-03-13 14:43:00 -05:00
|
|
|
if (((!hapd->conf->ieee802_1x && !hapd->conf->wpa) ||
|
|
|
|
sta->auth_alg == WLAN_AUTH_FT) &&
|
2009-12-24 16:11:16 -05:00
|
|
|
sta->flags & WLAN_STA_AUTHORIZED)
|
|
|
|
set_flags |= WPA_STA_AUTHORIZED;
|
|
|
|
flags_or = total_flags & set_flags;
|
|
|
|
flags_and = total_flags | ~set_flags;
|
|
|
|
return hostapd_sta_set_flags(hapd, sta->addr, total_flags,
|
|
|
|
flags_or, flags_and);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-24 09:50:06 -05:00
|
|
|
int hostapd_set_drv_ieee8021x(struct hostapd_data *hapd, const char *ifname,
|
|
|
|
int enabled)
|
2009-12-24 16:17:11 -05:00
|
|
|
{
|
|
|
|
struct wpa_bss_params params;
|
|
|
|
os_memset(¶ms, 0, sizeof(params));
|
|
|
|
params.ifname = ifname;
|
|
|
|
params.enabled = enabled;
|
|
|
|
if (enabled) {
|
|
|
|
params.wpa = hapd->conf->wpa;
|
|
|
|
params.ieee802_1x = hapd->conf->ieee802_1x;
|
|
|
|
params.wpa_group = hapd->conf->wpa_group;
|
|
|
|
params.wpa_pairwise = hapd->conf->wpa_pairwise;
|
|
|
|
params.wpa_key_mgmt = hapd->conf->wpa_key_mgmt;
|
|
|
|
params.rsn_preauth = hapd->conf->rsn_preauth;
|
2011-04-08 05:06:27 -04:00
|
|
|
#ifdef CONFIG_IEEE80211W
|
|
|
|
params.ieee80211w = hapd->conf->ieee80211w;
|
|
|
|
#endif /* CONFIG_IEEE80211W */
|
2009-12-24 16:17:11 -05:00
|
|
|
}
|
|
|
|
return hostapd_set_ieee8021x(hapd, ¶ms);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-09 09:27:15 -05:00
|
|
|
static int hostapd_set_ap_isolate(struct hostapd_data *hapd, int value)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->set_intra_bss == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->set_intra_bss(hapd->drv_priv, !value);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-24 09:50:06 -05:00
|
|
|
int hostapd_set_bss_params(struct hostapd_data *hapd, int use_protection)
|
2009-12-24 17:10:31 -05:00
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
int preamble;
|
|
|
|
#ifdef CONFIG_IEEE80211N
|
|
|
|
u8 buf[60], *ht_capab, *ht_oper, *pos;
|
|
|
|
|
|
|
|
pos = buf;
|
|
|
|
ht_capab = pos;
|
|
|
|
pos = hostapd_eid_ht_capabilities(hapd, pos);
|
|
|
|
ht_oper = pos;
|
|
|
|
pos = hostapd_eid_ht_operation(hapd, pos);
|
|
|
|
if (pos > ht_oper && ht_oper > ht_capab &&
|
2010-03-07 04:49:27 -05:00
|
|
|
hostapd_set_ht_params(hapd, ht_capab + 2, ht_capab[1],
|
2009-12-24 17:10:31 -05:00
|
|
|
ht_oper + 2, ht_oper[1])) {
|
|
|
|
wpa_printf(MSG_ERROR, "Could not set HT capabilities "
|
|
|
|
"for kernel driver");
|
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_IEEE80211N */
|
|
|
|
|
|
|
|
if (hostapd_set_cts_protect(hapd, use_protection)) {
|
|
|
|
wpa_printf(MSG_ERROR, "Failed to set CTS protect in kernel "
|
|
|
|
"driver");
|
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hapd->iface->current_mode &&
|
|
|
|
hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G &&
|
|
|
|
hostapd_set_short_slot_time(hapd,
|
|
|
|
hapd->iface->num_sta_no_short_slot_time
|
|
|
|
> 0 ? 0 : 1)) {
|
|
|
|
wpa_printf(MSG_ERROR, "Failed to set Short Slot Time option "
|
|
|
|
"in kernel driver");
|
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hapd->iface->num_sta_no_short_preamble == 0 &&
|
|
|
|
hapd->iconf->preamble == SHORT_PREAMBLE)
|
|
|
|
preamble = SHORT_PREAMBLE;
|
|
|
|
else
|
|
|
|
preamble = LONG_PREAMBLE;
|
|
|
|
if (hostapd_set_preamble(hapd, preamble)) {
|
|
|
|
wpa_printf(MSG_ERROR, "Could not set preamble for kernel "
|
|
|
|
"driver");
|
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
|
2010-11-09 09:27:15 -05:00
|
|
|
if (hostapd_set_ap_isolate(hapd, hapd->conf->isolate) &&
|
|
|
|
hapd->conf->isolate) {
|
|
|
|
wpa_printf(MSG_ERROR, "Could not enable AP isolation in "
|
|
|
|
"kernel driver");
|
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
|
2009-12-24 17:10:31 -05:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-24 09:50:06 -05:00
|
|
|
int hostapd_vlan_if_add(struct hostapd_data *hapd, const char *ifname)
|
2009-12-24 17:17:07 -05:00
|
|
|
{
|
2010-04-11 12:23:09 -04:00
|
|
|
char force_ifname[IFNAMSIZ];
|
|
|
|
u8 if_addr[ETH_ALEN];
|
2011-02-24 14:25:40 -05:00
|
|
|
return hostapd_if_add(hapd, WPA_IF_AP_VLAN, ifname, hapd->own_addr,
|
2011-03-15 07:02:49 -04:00
|
|
|
NULL, NULL, force_ifname, if_addr, NULL);
|
2009-12-24 17:17:07 -05:00
|
|
|
}
|
|
|
|
|
2010-11-24 09:50:06 -05:00
|
|
|
|
|
|
|
int hostapd_vlan_if_remove(struct hostapd_data *hapd, const char *ifname)
|
2009-12-24 17:17:07 -05:00
|
|
|
{
|
|
|
|
return hostapd_if_remove(hapd, WPA_IF_AP_VLAN, ifname);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-24 09:50:06 -05:00
|
|
|
int hostapd_set_wds_sta(struct hostapd_data *hapd, const u8 *addr, int aid,
|
|
|
|
int val)
|
2009-12-24 17:30:16 -05:00
|
|
|
{
|
2010-11-09 09:12:42 -05:00
|
|
|
const char *bridge = NULL;
|
|
|
|
|
2009-12-24 17:30:16 -05:00
|
|
|
if (hapd->driver == NULL || hapd->driver->set_wds_sta == NULL)
|
|
|
|
return 0;
|
2010-11-09 09:12:42 -05:00
|
|
|
if (hapd->conf->wds_bridge[0])
|
|
|
|
bridge = hapd->conf->wds_bridge;
|
|
|
|
else if (hapd->conf->bridge[0])
|
|
|
|
bridge = hapd->conf->bridge;
|
2010-11-24 09:50:06 -05:00
|
|
|
return hapd->driver->set_wds_sta(hapd->drv_priv, addr, aid, val,
|
|
|
|
bridge);
|
2009-12-24 17:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-29 17:05:29 -04:00
|
|
|
int hostapd_add_sta_node(struct hostapd_data *hapd, const u8 *addr,
|
|
|
|
u16 auth_alg)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->add_sta_node == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->add_sta_node(hapd->drv_priv, addr, auth_alg);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_sta_auth(struct hostapd_data *hapd, const u8 *addr,
|
|
|
|
u16 seq, u16 status, const u8 *ie, size_t len)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->sta_auth == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->sta_auth(hapd->drv_priv, hapd->own_addr, addr,
|
|
|
|
seq, status, ie, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_sta_assoc(struct hostapd_data *hapd, const u8 *addr,
|
|
|
|
int reassoc, u16 status, const u8 *ie, size_t len)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->sta_assoc == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->sta_assoc(hapd->drv_priv, hapd->own_addr, addr,
|
|
|
|
reassoc, status, ie, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-24 09:50:06 -05:00
|
|
|
int hostapd_sta_add(struct hostapd_data *hapd,
|
|
|
|
const u8 *addr, u16 aid, u16 capability,
|
|
|
|
const u8 *supp_rates, size_t supp_rates_len,
|
|
|
|
u16 listen_interval,
|
2011-07-12 13:26:52 -04:00
|
|
|
const struct ieee80211_ht_capabilities *ht_capab,
|
|
|
|
u32 flags)
|
2009-12-24 17:35:10 -05:00
|
|
|
{
|
|
|
|
struct hostapd_sta_add_params params;
|
|
|
|
|
|
|
|
if (hapd->driver == NULL)
|
|
|
|
return 0;
|
|
|
|
if (hapd->driver->sta_add == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
os_memset(¶ms, 0, sizeof(params));
|
|
|
|
params.addr = addr;
|
|
|
|
params.aid = aid;
|
|
|
|
params.capability = capability;
|
|
|
|
params.supp_rates = supp_rates;
|
|
|
|
params.supp_rates_len = supp_rates_len;
|
|
|
|
params.listen_interval = listen_interval;
|
|
|
|
params.ht_capabilities = ht_capab;
|
2011-07-12 13:26:52 -04:00
|
|
|
params.flags = hostapd_sta_flags_to_drv(flags);
|
2010-03-07 04:42:41 -05:00
|
|
|
return hapd->driver->sta_add(hapd->drv_priv, ¶ms);
|
2009-12-24 17:35:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-29 17:05:29 -04:00
|
|
|
int hostapd_add_tspec(struct hostapd_data *hapd, const u8 *addr,
|
|
|
|
u8 *tspec_ie, size_t tspec_ielen)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->add_tspec == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->add_tspec(hapd->drv_priv, addr, tspec_ie,
|
|
|
|
tspec_ielen);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-25 17:12:25 -05:00
|
|
|
int hostapd_set_privacy(struct hostapd_data *hapd, int enabled)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->set_privacy == NULL)
|
|
|
|
return 0;
|
2010-03-07 04:29:17 -05:00
|
|
|
return hapd->driver->set_privacy(hapd->drv_priv, enabled);
|
2009-12-25 17:12:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_set_generic_elem(struct hostapd_data *hapd, const u8 *elem,
|
|
|
|
size_t elem_len)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->set_generic_elem == NULL)
|
|
|
|
return 0;
|
2010-03-07 04:33:06 -05:00
|
|
|
return hapd->driver->set_generic_elem(hapd->drv_priv, elem, elem_len);
|
2009-12-25 17:12:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_get_ssid(struct hostapd_data *hapd, u8 *buf, size_t len)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->hapd_get_ssid == NULL)
|
|
|
|
return 0;
|
2010-03-07 04:36:45 -05:00
|
|
|
return hapd->driver->hapd_get_ssid(hapd->drv_priv, buf, len);
|
2009-12-25 17:12:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_set_ssid(struct hostapd_data *hapd, const u8 *buf, size_t len)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->hapd_set_ssid == NULL)
|
|
|
|
return 0;
|
2010-03-07 04:36:45 -05:00
|
|
|
return hapd->driver->hapd_set_ssid(hapd->drv_priv, buf, len);
|
2009-12-25 17:12:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_if_add(struct hostapd_data *hapd, enum wpa_driver_if_type type,
|
2010-03-06 15:22:56 -05:00
|
|
|
const char *ifname, const u8 *addr, void *bss_ctx,
|
2011-03-15 07:02:49 -04:00
|
|
|
void **drv_priv, char *force_ifname, u8 *if_addr,
|
|
|
|
const char *bridge)
|
2009-12-25 17:12:25 -05:00
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->if_add == NULL)
|
|
|
|
return -1;
|
2010-03-07 03:05:05 -05:00
|
|
|
return hapd->driver->if_add(hapd->drv_priv, type, ifname, addr,
|
2011-03-15 07:02:49 -04:00
|
|
|
bss_ctx, drv_priv, force_ifname, if_addr,
|
|
|
|
bridge);
|
2009-12-25 17:12:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_if_remove(struct hostapd_data *hapd, enum wpa_driver_if_type type,
|
|
|
|
const char *ifname)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->if_remove == NULL)
|
|
|
|
return -1;
|
|
|
|
return hapd->driver->if_remove(hapd->drv_priv, type, ifname);
|
|
|
|
}
|
2009-12-25 17:21:22 -05:00
|
|
|
|
|
|
|
|
|
|
|
int hostapd_set_ieee8021x(struct hostapd_data *hapd,
|
|
|
|
struct wpa_bss_params *params)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->set_ieee8021x == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->set_ieee8021x(hapd->drv_priv, params);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_get_seqnum(const char *ifname, struct hostapd_data *hapd,
|
|
|
|
const u8 *addr, int idx, u8 *seq)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->get_seqnum == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->get_seqnum(ifname, hapd->drv_priv, addr, idx,
|
|
|
|
seq);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_flush(struct hostapd_data *hapd)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->flush == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->flush(hapd->drv_priv);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_set_freq(struct hostapd_data *hapd, int mode, int freq,
|
|
|
|
int channel, int ht_enabled, int sec_channel_offset)
|
|
|
|
{
|
|
|
|
struct hostapd_freq_params data;
|
|
|
|
if (hapd->driver == NULL)
|
|
|
|
return 0;
|
|
|
|
if (hapd->driver->set_freq == NULL)
|
|
|
|
return 0;
|
|
|
|
os_memset(&data, 0, sizeof(data));
|
|
|
|
data.mode = mode;
|
|
|
|
data.freq = freq;
|
|
|
|
data.channel = channel;
|
|
|
|
data.ht_enabled = ht_enabled;
|
|
|
|
data.sec_channel_offset = sec_channel_offset;
|
|
|
|
return hapd->driver->set_freq(hapd->drv_priv, &data);
|
|
|
|
}
|
|
|
|
|
|
|
|
int hostapd_set_rts(struct hostapd_data *hapd, int rts)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->set_rts == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->set_rts(hapd->drv_priv, rts);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_set_frag(struct hostapd_data *hapd, int frag)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->set_frag == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->set_frag(hapd->drv_priv, frag);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_sta_set_flags(struct hostapd_data *hapd, u8 *addr,
|
|
|
|
int total_flags, int flags_or, int flags_and)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->sta_set_flags == NULL)
|
|
|
|
return 0;
|
2010-03-07 04:45:41 -05:00
|
|
|
return hapd->driver->sta_set_flags(hapd->drv_priv, addr, total_flags,
|
2009-12-25 17:21:22 -05:00
|
|
|
flags_or, flags_and);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_set_rate_sets(struct hostapd_data *hapd, int *supp_rates,
|
|
|
|
int *basic_rates, int mode)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->set_rate_sets == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->set_rate_sets(hapd->drv_priv, supp_rates,
|
|
|
|
basic_rates, mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_set_country(struct hostapd_data *hapd, const char *country)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL ||
|
|
|
|
hapd->driver->set_country == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->set_country(hapd->drv_priv, country);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_set_cts_protect(struct hostapd_data *hapd, int value)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->set_cts_protect == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->set_cts_protect(hapd->drv_priv, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_set_preamble(struct hostapd_data *hapd, int value)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->set_preamble == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->set_preamble(hapd->drv_priv, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_set_short_slot_time(struct hostapd_data *hapd, int value)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->set_short_slot_time == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->set_short_slot_time(hapd->drv_priv, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_set_tx_queue_params(struct hostapd_data *hapd, int queue, int aifs,
|
|
|
|
int cw_min, int cw_max, int burst_time)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->set_tx_queue_params == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->set_tx_queue_params(hapd->drv_priv, queue, aifs,
|
|
|
|
cw_min, cw_max, burst_time);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_valid_bss_mask(struct hostapd_data *hapd, const u8 *addr,
|
|
|
|
const u8 *mask)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->valid_bss_mask == NULL)
|
|
|
|
return 1;
|
|
|
|
return hapd->driver->valid_bss_mask(hapd->drv_priv, addr, mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct hostapd_hw_modes *
|
|
|
|
hostapd_get_hw_feature_data(struct hostapd_data *hapd, u16 *num_modes,
|
|
|
|
u16 *flags)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL ||
|
|
|
|
hapd->driver->get_hw_feature_data == NULL)
|
|
|
|
return NULL;
|
|
|
|
return hapd->driver->get_hw_feature_data(hapd->drv_priv, num_modes,
|
|
|
|
flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_driver_commit(struct hostapd_data *hapd)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->commit == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->commit(hapd->drv_priv);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-03-07 04:49:27 -05:00
|
|
|
int hostapd_set_ht_params(struct hostapd_data *hapd,
|
2009-12-25 17:21:22 -05:00
|
|
|
const u8 *ht_capab, size_t ht_capab_len,
|
|
|
|
const u8 *ht_oper, size_t ht_oper_len)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->set_ht_params == NULL ||
|
|
|
|
ht_capab == NULL || ht_oper == NULL)
|
|
|
|
return 0;
|
2010-03-07 04:49:27 -05:00
|
|
|
return hapd->driver->set_ht_params(hapd->drv_priv,
|
|
|
|
ht_capab, ht_capab_len,
|
|
|
|
ht_oper, ht_oper_len);
|
2009-12-25 17:21:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_drv_none(struct hostapd_data *hapd)
|
|
|
|
{
|
|
|
|
return hapd->driver && os_strcmp(hapd->driver->name, "none") == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_driver_scan(struct hostapd_data *hapd,
|
|
|
|
struct wpa_driver_scan_params *params)
|
|
|
|
{
|
|
|
|
if (hapd->driver && hapd->driver->scan2)
|
|
|
|
return hapd->driver->scan2(hapd->drv_priv, params);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct wpa_scan_results * hostapd_driver_get_scan_results(
|
|
|
|
struct hostapd_data *hapd)
|
|
|
|
{
|
|
|
|
if (hapd->driver && hapd->driver->get_scan_results2)
|
|
|
|
return hapd->driver->get_scan_results2(hapd->drv_priv);
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-07-08 20:14:24 -04:00
|
|
|
|
|
|
|
|
|
|
|
int hostapd_driver_set_noa(struct hostapd_data *hapd, u8 count, int start,
|
|
|
|
int duration)
|
|
|
|
{
|
|
|
|
if (hapd->driver && hapd->driver->set_noa)
|
|
|
|
return hapd->driver->set_noa(hapd->drv_priv, count, start,
|
|
|
|
duration);
|
|
|
|
return -1;
|
|
|
|
}
|
2010-11-24 10:01:21 -05:00
|
|
|
|
|
|
|
|
|
|
|
int hostapd_drv_set_key(const char *ifname, struct hostapd_data *hapd,
|
|
|
|
enum wpa_alg alg, const u8 *addr,
|
|
|
|
int key_idx, int set_tx,
|
|
|
|
const u8 *seq, size_t seq_len,
|
|
|
|
const u8 *key, size_t key_len)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->set_key == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->set_key(ifname, hapd->drv_priv, alg, addr,
|
|
|
|
key_idx, set_tx, seq, seq_len, key,
|
|
|
|
key_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_drv_send_mlme(struct hostapd_data *hapd,
|
|
|
|
const void *msg, size_t len)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->send_mlme == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->send_mlme(hapd->drv_priv, msg, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_drv_sta_deauth(struct hostapd_data *hapd,
|
|
|
|
const u8 *addr, int reason)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->sta_deauth == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->sta_deauth(hapd->drv_priv, hapd->own_addr, addr,
|
|
|
|
reason);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_drv_sta_disassoc(struct hostapd_data *hapd,
|
|
|
|
const u8 *addr, int reason)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->sta_disassoc == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->sta_disassoc(hapd->drv_priv, hapd->own_addr, addr,
|
|
|
|
reason);
|
|
|
|
}
|