2009-02-19 15:27:07 +01:00
|
|
|
/*
|
|
|
|
* hostapd / Driver interaction with Atheros driver
|
|
|
|
* Copyright (c) 2004, Sam Leffler <sam@errno.com>
|
|
|
|
* Copyright (c) 2004, Video54 Technologies
|
|
|
|
* Copyright (c) 2005-2007, Jouni Malinen <j@w1.fi>
|
|
|
|
* Copyright (c) 2009, Atheros Communications
|
|
|
|
*
|
2012-06-30 18:36:04 +02:00
|
|
|
* This software may be distributed under the terms of the BSD license.
|
|
|
|
* See README for more details.
|
2009-02-19 15:27:07 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "includes.h"
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
2011-09-08 19:52:23 +02:00
|
|
|
#include "common.h"
|
|
|
|
#include "eloop.h"
|
|
|
|
#include "common/ieee802_11_defs.h"
|
|
|
|
#include "l2_packet/l2_packet.h"
|
|
|
|
#include "p2p/p2p.h"
|
|
|
|
|
2009-02-19 15:27:07 +01:00
|
|
|
#include "common.h"
|
|
|
|
#ifndef _BYTE_ORDER
|
|
|
|
#ifdef WORDS_BIGENDIAN
|
|
|
|
#define _BYTE_ORDER _BIG_ENDIAN
|
|
|
|
#else
|
|
|
|
#define _BYTE_ORDER _LITTLE_ENDIAN
|
|
|
|
#endif
|
|
|
|
#endif /* _BYTE_ORDER */
|
|
|
|
|
2010-04-17 20:47:13 +02:00
|
|
|
/*
|
|
|
|
* Note, the ATH_WPS_IE setting must match with the driver build.. If the
|
|
|
|
* driver does not include this, the IEEE80211_IOCTL_GETWPAIE ioctl will fail.
|
|
|
|
*/
|
|
|
|
#define ATH_WPS_IE
|
|
|
|
|
2011-09-26 10:49:22 +02:00
|
|
|
#include "ieee80211_external.h"
|
2009-02-19 15:27:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_WPS
|
|
|
|
#include <netpacket/packet.h>
|
2012-06-08 19:27:45 +02:00
|
|
|
#endif /* CONFIG_WPS */
|
2009-02-19 15:27:07 +01:00
|
|
|
|
|
|
|
#ifndef ETH_P_80211_RAW
|
|
|
|
#define ETH_P_80211_RAW 0x0019
|
|
|
|
#endif
|
|
|
|
|
2011-11-15 19:03:00 +01:00
|
|
|
#include "linux_wext.h"
|
2009-02-19 15:27:07 +01:00
|
|
|
|
|
|
|
#include "driver.h"
|
|
|
|
#include "eloop.h"
|
|
|
|
#include "priv_netlink.h"
|
|
|
|
#include "l2_packet/l2_packet.h"
|
2009-11-29 16:51:55 +01:00
|
|
|
#include "common/ieee802_11_defs.h"
|
2009-12-18 17:24:13 +01:00
|
|
|
#include "netlink.h"
|
2010-01-03 21:08:26 +01:00
|
|
|
#include "linux_ioctl.h"
|
2009-02-19 15:27:07 +01:00
|
|
|
|
|
|
|
|
2010-12-20 11:35:57 +01:00
|
|
|
struct atheros_driver_data {
|
2009-02-19 15:27:07 +01:00
|
|
|
struct hostapd_data *hapd; /* back pointer */
|
|
|
|
|
|
|
|
char iface[IFNAMSIZ + 1];
|
|
|
|
int ifindex;
|
|
|
|
struct l2_packet_data *sock_xmit; /* raw packet xmit socket */
|
|
|
|
struct l2_packet_data *sock_recv; /* raw packet recv socket */
|
|
|
|
int ioctl_sock; /* socket for ioctl() use */
|
2009-12-18 17:24:13 +01:00
|
|
|
struct netlink_data *netlink;
|
2009-02-19 15:27:07 +01:00
|
|
|
int we_version;
|
|
|
|
u8 acct_mac[ETH_ALEN];
|
|
|
|
struct hostap_sta_driver_data acct_data;
|
|
|
|
|
|
|
|
struct l2_packet_data *sock_raw; /* raw 802.11 management frames */
|
2011-01-05 12:44:53 +01:00
|
|
|
struct wpabuf *wpa_ie;
|
|
|
|
struct wpabuf *wps_beacon_ie;
|
|
|
|
struct wpabuf *wps_probe_resp_ie;
|
2012-02-16 18:57:33 +01:00
|
|
|
u8 own_addr[ETH_ALEN];
|
2009-02-19 15:27:07 +01:00
|
|
|
};
|
|
|
|
|
2010-12-20 11:35:57 +01:00
|
|
|
static int atheros_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr,
|
2009-04-17 10:37:22 +02:00
|
|
|
int reason_code);
|
2010-12-20 11:35:57 +01:00
|
|
|
static int atheros_set_privacy(void *priv, int enabled);
|
2009-02-19 15:27:07 +01:00
|
|
|
|
2010-04-17 20:45:34 +02:00
|
|
|
static const char * athr_get_ioctl_name(int op)
|
|
|
|
{
|
|
|
|
switch (op) {
|
|
|
|
case IEEE80211_IOCTL_SETPARAM:
|
|
|
|
return "SETPARAM";
|
|
|
|
case IEEE80211_IOCTL_GETPARAM:
|
|
|
|
return "GETPARAM";
|
|
|
|
case IEEE80211_IOCTL_SETKEY:
|
|
|
|
return "SETKEY";
|
|
|
|
case IEEE80211_IOCTL_SETWMMPARAMS:
|
|
|
|
return "SETWMMPARAMS";
|
|
|
|
case IEEE80211_IOCTL_DELKEY:
|
|
|
|
return "DELKEY";
|
|
|
|
case IEEE80211_IOCTL_GETWMMPARAMS:
|
|
|
|
return "GETWMMPARAMS";
|
|
|
|
case IEEE80211_IOCTL_SETMLME:
|
|
|
|
return "SETMLME";
|
|
|
|
case IEEE80211_IOCTL_GETCHANINFO:
|
|
|
|
return "GETCHANINFO";
|
|
|
|
case IEEE80211_IOCTL_SETOPTIE:
|
|
|
|
return "SETOPTIE";
|
|
|
|
case IEEE80211_IOCTL_GETOPTIE:
|
|
|
|
return "GETOPTIE";
|
|
|
|
case IEEE80211_IOCTL_ADDMAC:
|
|
|
|
return "ADDMAC";
|
|
|
|
case IEEE80211_IOCTL_DELMAC:
|
|
|
|
return "DELMAC";
|
|
|
|
case IEEE80211_IOCTL_GETCHANLIST:
|
|
|
|
return "GETCHANLIST";
|
|
|
|
case IEEE80211_IOCTL_SETCHANLIST:
|
|
|
|
return "SETCHANLIST";
|
|
|
|
case IEEE80211_IOCTL_KICKMAC:
|
|
|
|
return "KICKMAC";
|
|
|
|
case IEEE80211_IOCTL_CHANSWITCH:
|
|
|
|
return "CHANSWITCH";
|
|
|
|
case IEEE80211_IOCTL_GETMODE:
|
|
|
|
return "GETMODE";
|
|
|
|
case IEEE80211_IOCTL_SETMODE:
|
|
|
|
return "SETMODE";
|
|
|
|
case IEEE80211_IOCTL_GET_APPIEBUF:
|
|
|
|
return "GET_APPIEBUF";
|
|
|
|
case IEEE80211_IOCTL_SET_APPIEBUF:
|
|
|
|
return "SET_APPIEBUF";
|
|
|
|
case IEEE80211_IOCTL_SET_ACPARAMS:
|
|
|
|
return "SET_ACPARAMS";
|
|
|
|
case IEEE80211_IOCTL_FILTERFRAME:
|
|
|
|
return "FILTERFRAME";
|
|
|
|
case IEEE80211_IOCTL_SET_RTPARAMS:
|
|
|
|
return "SET_RTPARAMS";
|
|
|
|
case IEEE80211_IOCTL_SET_MEDENYENTRY:
|
|
|
|
return "SET_MEDENYENTRY";
|
|
|
|
case IEEE80211_IOCTL_GET_MACADDR:
|
|
|
|
return "GET_MACADDR";
|
|
|
|
case IEEE80211_IOCTL_SET_HBRPARAMS:
|
|
|
|
return "SET_HBRPARAMS";
|
|
|
|
case IEEE80211_IOCTL_SET_RXTIMEOUT:
|
|
|
|
return "SET_RXTIMEOUT";
|
|
|
|
case IEEE80211_IOCTL_STA_STATS:
|
|
|
|
return "STA_STATS";
|
|
|
|
case IEEE80211_IOCTL_GETWPAIE:
|
|
|
|
return "GETWPAIE";
|
|
|
|
default:
|
|
|
|
return "??";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static const char * athr_get_param_name(int op)
|
|
|
|
{
|
|
|
|
switch (op) {
|
|
|
|
case IEEE80211_IOC_MCASTCIPHER:
|
|
|
|
return "MCASTCIPHER";
|
|
|
|
case IEEE80211_PARAM_MCASTKEYLEN:
|
|
|
|
return "MCASTKEYLEN";
|
|
|
|
case IEEE80211_PARAM_UCASTCIPHERS:
|
|
|
|
return "UCASTCIPHERS";
|
|
|
|
case IEEE80211_PARAM_KEYMGTALGS:
|
|
|
|
return "KEYMGTALGS";
|
|
|
|
case IEEE80211_PARAM_RSNCAPS:
|
|
|
|
return "RSNCAPS";
|
|
|
|
case IEEE80211_PARAM_WPA:
|
|
|
|
return "WPA";
|
|
|
|
case IEEE80211_PARAM_AUTHMODE:
|
|
|
|
return "AUTHMODE";
|
|
|
|
case IEEE80211_PARAM_PRIVACY:
|
|
|
|
return "PRIVACY";
|
|
|
|
case IEEE80211_PARAM_COUNTERMEASURES:
|
|
|
|
return "COUNTERMEASURES";
|
|
|
|
default:
|
|
|
|
return "??";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-02-19 15:27:07 +01:00
|
|
|
static int
|
2010-12-20 11:35:57 +01:00
|
|
|
set80211priv(struct atheros_driver_data *drv, int op, void *data, int len)
|
2009-02-19 15:27:07 +01:00
|
|
|
{
|
|
|
|
struct iwreq iwr;
|
|
|
|
int do_inline = len < IFNAMSIZ;
|
|
|
|
|
|
|
|
/* Certain ioctls must use the non-inlined method */
|
|
|
|
if (op == IEEE80211_IOCTL_SET_APPIEBUF ||
|
|
|
|
op == IEEE80211_IOCTL_FILTERFRAME)
|
|
|
|
do_inline = 0;
|
|
|
|
|
|
|
|
memset(&iwr, 0, sizeof(iwr));
|
|
|
|
os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
|
|
|
|
if (do_inline) {
|
|
|
|
/*
|
|
|
|
* Argument data fits inline; put it there.
|
|
|
|
*/
|
|
|
|
memcpy(iwr.u.name, data, len);
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Argument data too big for inline transfer; setup a
|
|
|
|
* parameter block instead; the kernel will transfer
|
|
|
|
* the data for the driver.
|
|
|
|
*/
|
|
|
|
iwr.u.data.pointer = data;
|
|
|
|
iwr.u.data.length = len;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ioctl(drv->ioctl_sock, op, &iwr) < 0) {
|
2010-04-17 20:45:34 +02:00
|
|
|
wpa_printf(MSG_DEBUG, "atheros: %s: %s: ioctl op=0x%x "
|
|
|
|
"(%s) len=%d failed: %d (%s)",
|
|
|
|
__func__, drv->iface, op,
|
|
|
|
athr_get_ioctl_name(op),
|
|
|
|
len, errno, strerror(errno));
|
2009-02-19 15:27:07 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-12-20 11:35:57 +01:00
|
|
|
set80211param(struct atheros_driver_data *drv, int op, int arg)
|
2009-02-19 15:27:07 +01:00
|
|
|
{
|
|
|
|
struct iwreq iwr;
|
|
|
|
|
|
|
|
memset(&iwr, 0, sizeof(iwr));
|
|
|
|
os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
|
|
|
|
iwr.u.mode = op;
|
|
|
|
memcpy(iwr.u.name+sizeof(__u32), &arg, sizeof(arg));
|
|
|
|
|
|
|
|
if (ioctl(drv->ioctl_sock, IEEE80211_IOCTL_SETPARAM, &iwr) < 0) {
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_INFO,
|
|
|
|
"%s: %s: Failed to set parameter (op %d (%s) arg %d): ioctl[IEEE80211_IOCTL_SETPARAM]: %s",
|
|
|
|
__func__, drv->iface, op, athr_get_param_name(op),
|
|
|
|
arg, strerror(errno));
|
2009-02-19 15:27:07 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef CONFIG_NO_STDOUT_DEBUG
|
|
|
|
static const char *
|
|
|
|
ether_sprintf(const u8 *addr)
|
|
|
|
{
|
|
|
|
static char buf[sizeof(MACSTR)];
|
|
|
|
|
|
|
|
if (addr != NULL)
|
|
|
|
snprintf(buf, sizeof(buf), MACSTR, MAC2STR(addr));
|
|
|
|
else
|
|
|
|
snprintf(buf, sizeof(buf), MACSTR, 0,0,0,0,0,0);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_NO_STDOUT_DEBUG */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Configure WPA parameters.
|
|
|
|
*/
|
|
|
|
static int
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_configure_wpa(struct atheros_driver_data *drv,
|
2009-12-12 22:50:29 +01:00
|
|
|
struct wpa_bss_params *params)
|
2009-02-19 15:27:07 +01:00
|
|
|
{
|
|
|
|
int v;
|
|
|
|
|
2009-12-12 22:50:29 +01:00
|
|
|
switch (params->wpa_group) {
|
2009-02-19 15:27:07 +01:00
|
|
|
case WPA_CIPHER_CCMP:
|
|
|
|
v = IEEE80211_CIPHER_AES_CCM;
|
|
|
|
break;
|
2014-06-09 18:19:30 +02:00
|
|
|
#ifdef ATH_GCM_SUPPORT
|
|
|
|
case WPA_CIPHER_CCMP_256:
|
|
|
|
v = IEEE80211_CIPHER_AES_CCM_256;
|
|
|
|
break;
|
|
|
|
case WPA_CIPHER_GCMP:
|
|
|
|
v = IEEE80211_CIPHER_AES_GCM;
|
|
|
|
break;
|
|
|
|
case WPA_CIPHER_GCMP_256:
|
|
|
|
v = IEEE80211_CIPHER_AES_GCM_256;
|
|
|
|
break;
|
|
|
|
#endif /* ATH_GCM_SUPPORT */
|
2009-02-19 15:27:07 +01:00
|
|
|
case WPA_CIPHER_TKIP:
|
|
|
|
v = IEEE80211_CIPHER_TKIP;
|
|
|
|
break;
|
|
|
|
case WPA_CIPHER_WEP104:
|
|
|
|
v = IEEE80211_CIPHER_WEP;
|
|
|
|
break;
|
|
|
|
case WPA_CIPHER_WEP40:
|
|
|
|
v = IEEE80211_CIPHER_WEP;
|
|
|
|
break;
|
|
|
|
case WPA_CIPHER_NONE:
|
|
|
|
v = IEEE80211_CIPHER_NONE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
wpa_printf(MSG_ERROR, "Unknown group key cipher %u",
|
2009-12-12 22:50:29 +01:00
|
|
|
params->wpa_group);
|
2009-02-19 15:27:07 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: group key cipher=%d", __func__, v);
|
|
|
|
if (set80211param(drv, IEEE80211_PARAM_MCASTCIPHER, v)) {
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_INFO, "Unable to set group key cipher to %u", v);
|
2009-02-19 15:27:07 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (v == IEEE80211_CIPHER_WEP) {
|
|
|
|
/* key length is done only for specific ciphers */
|
2009-12-12 22:50:29 +01:00
|
|
|
v = (params->wpa_group == WPA_CIPHER_WEP104 ? 13 : 5);
|
2009-02-19 15:27:07 +01:00
|
|
|
if (set80211param(drv, IEEE80211_PARAM_MCASTKEYLEN, v)) {
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_INFO,
|
|
|
|
"Unable to set group key length to %u", v);
|
2009-02-19 15:27:07 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
v = 0;
|
2009-12-12 22:50:29 +01:00
|
|
|
if (params->wpa_pairwise & WPA_CIPHER_CCMP)
|
2009-02-19 15:27:07 +01:00
|
|
|
v |= 1<<IEEE80211_CIPHER_AES_CCM;
|
2014-06-09 18:19:30 +02:00
|
|
|
#ifdef ATH_GCM_SUPPORT
|
|
|
|
if (params->wpa_pairwise & WPA_CIPHER_CCMP_256)
|
|
|
|
v |= 1<<IEEE80211_CIPHER_AES_CCM_256;
|
|
|
|
if (params->wpa_pairwise & WPA_CIPHER_GCMP)
|
|
|
|
v |= 1<<IEEE80211_CIPHER_AES_GCM;
|
|
|
|
if (params->wpa_pairwise & WPA_CIPHER_GCMP_256)
|
|
|
|
v |= 1<<IEEE80211_CIPHER_AES_GCM_256;
|
|
|
|
#endif /* ATH_GCM_SUPPORT */
|
2009-12-12 22:50:29 +01:00
|
|
|
if (params->wpa_pairwise & WPA_CIPHER_TKIP)
|
2009-02-19 15:27:07 +01:00
|
|
|
v |= 1<<IEEE80211_CIPHER_TKIP;
|
2009-12-12 22:50:29 +01:00
|
|
|
if (params->wpa_pairwise & WPA_CIPHER_NONE)
|
2009-02-19 15:27:07 +01:00
|
|
|
v |= 1<<IEEE80211_CIPHER_NONE;
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: pairwise key ciphers=0x%x", __func__, v);
|
|
|
|
if (set80211param(drv, IEEE80211_PARAM_UCASTCIPHERS, v)) {
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_INFO,
|
|
|
|
"Unable to set pairwise key ciphers to 0x%x", v);
|
2009-02-19 15:27:07 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: key management algorithms=0x%x",
|
2009-12-12 22:50:29 +01:00
|
|
|
__func__, params->wpa_key_mgmt);
|
|
|
|
if (set80211param(drv, IEEE80211_PARAM_KEYMGTALGS,
|
|
|
|
params->wpa_key_mgmt)) {
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_INFO,
|
|
|
|
"Unable to set key management algorithms to 0x%x",
|
|
|
|
params->wpa_key_mgmt);
|
2009-02-19 15:27:07 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
v = 0;
|
2009-12-12 22:50:29 +01:00
|
|
|
if (params->rsn_preauth)
|
2009-02-19 15:27:07 +01:00
|
|
|
v |= BIT(0);
|
2011-04-08 11:06:27 +02:00
|
|
|
#ifdef CONFIG_IEEE80211W
|
|
|
|
if (params->ieee80211w != NO_MGMT_FRAME_PROTECTION) {
|
|
|
|
v |= BIT(7);
|
|
|
|
if (params->ieee80211w == MGMT_FRAME_PROTECTION_REQUIRED)
|
|
|
|
v |= BIT(6);
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_IEEE80211W */
|
|
|
|
|
2012-09-05 18:01:11 +02:00
|
|
|
wpa_printf(MSG_DEBUG, "%s: rsn capabilities=0x%x", __func__, v);
|
2009-02-19 15:27:07 +01:00
|
|
|
if (set80211param(drv, IEEE80211_PARAM_RSNCAPS, v)) {
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_INFO, "Unable to set RSN capabilities to 0x%x",
|
|
|
|
v);
|
2009-02-19 15:27:07 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-12-12 22:50:29 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "%s: enable WPA=0x%x", __func__, params->wpa);
|
|
|
|
if (set80211param(drv, IEEE80211_PARAM_WPA, params->wpa)) {
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_INFO, "Unable to set WPA to %u", params->wpa);
|
2009-02-19 15:27:07 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_set_ieee8021x(void *priv, struct wpa_bss_params *params)
|
2009-02-19 15:27:07 +01:00
|
|
|
{
|
2010-12-20 11:35:57 +01:00
|
|
|
struct atheros_driver_data *drv = priv;
|
2009-02-19 15:27:07 +01:00
|
|
|
|
2009-12-12 22:50:29 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "%s: enabled=%d", __func__, params->enabled);
|
2009-02-19 15:27:07 +01:00
|
|
|
|
2009-12-12 22:50:29 +01:00
|
|
|
if (!params->enabled) {
|
2009-02-19 15:27:07 +01:00
|
|
|
/* XXX restore state */
|
2010-05-28 20:51:31 +02:00
|
|
|
if (set80211param(priv, IEEE80211_PARAM_AUTHMODE,
|
|
|
|
IEEE80211_AUTH_AUTO) < 0)
|
|
|
|
return -1;
|
|
|
|
/* IEEE80211_AUTH_AUTO ends up enabling Privacy; clear that */
|
2010-12-20 11:35:57 +01:00
|
|
|
return atheros_set_privacy(drv, 0);
|
2009-02-19 15:27:07 +01:00
|
|
|
}
|
2009-12-12 22:50:29 +01:00
|
|
|
if (!params->wpa && !params->ieee802_1x) {
|
2013-11-05 23:19:46 +01:00
|
|
|
wpa_printf(MSG_WARNING, "No 802.1X or WPA enabled!");
|
2009-02-19 15:27:07 +01:00
|
|
|
return -1;
|
|
|
|
}
|
2010-12-20 11:35:57 +01:00
|
|
|
if (params->wpa && atheros_configure_wpa(drv, params) != 0) {
|
2013-11-05 23:19:46 +01:00
|
|
|
wpa_printf(MSG_WARNING, "Error configuring WPA state!");
|
2009-02-19 15:27:07 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (set80211param(priv, IEEE80211_PARAM_AUTHMODE,
|
2009-12-12 22:50:29 +01:00
|
|
|
(params->wpa ? IEEE80211_AUTH_WPA : IEEE80211_AUTH_8021X))) {
|
2013-11-05 23:19:46 +01:00
|
|
|
wpa_printf(MSG_WARNING, "Error enabling WPA/802.1X!");
|
2009-02-19 15:27:07 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_set_privacy(void *priv, int enabled)
|
2009-02-19 15:27:07 +01:00
|
|
|
{
|
2010-12-20 11:35:57 +01:00
|
|
|
struct atheros_driver_data *drv = priv;
|
2009-02-19 15:27:07 +01:00
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: enabled=%d", __func__, enabled);
|
|
|
|
|
|
|
|
return set80211param(drv, IEEE80211_PARAM_PRIVACY, enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_set_sta_authorized(void *priv, const u8 *addr, int authorized)
|
2009-02-19 15:27:07 +01:00
|
|
|
{
|
2010-12-20 11:35:57 +01:00
|
|
|
struct atheros_driver_data *drv = priv;
|
2009-02-19 15:27:07 +01:00
|
|
|
struct ieee80211req_mlme mlme;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: addr=%s authorized=%d",
|
|
|
|
__func__, ether_sprintf(addr), authorized);
|
|
|
|
|
|
|
|
if (authorized)
|
|
|
|
mlme.im_op = IEEE80211_MLME_AUTHORIZE;
|
|
|
|
else
|
|
|
|
mlme.im_op = IEEE80211_MLME_UNAUTHORIZE;
|
|
|
|
mlme.im_reason = 0;
|
|
|
|
memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
|
|
|
|
ret = set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme));
|
|
|
|
if (ret < 0) {
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: Failed to %sauthorize STA " MACSTR,
|
|
|
|
__func__, authorized ? "" : "un", MAC2STR(addr));
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_sta_set_flags(void *priv, const u8 *addr,
|
2010-03-06 19:44:31 +01:00
|
|
|
int total_flags, int flags_or, int flags_and)
|
2009-02-19 15:27:07 +01:00
|
|
|
{
|
|
|
|
/* For now, only support setting Authorized flag */
|
2009-12-13 10:35:39 +01:00
|
|
|
if (flags_or & WPA_STA_AUTHORIZED)
|
2010-12-20 11:35:57 +01:00
|
|
|
return atheros_set_sta_authorized(priv, addr, 1);
|
2009-12-13 10:35:39 +01:00
|
|
|
if (!(flags_and & WPA_STA_AUTHORIZED))
|
2010-12-20 11:35:57 +01:00
|
|
|
return atheros_set_sta_authorized(priv, addr, 0);
|
2009-02-19 15:27:07 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_del_key(void *priv, const u8 *addr, int key_idx)
|
2009-02-19 15:27:07 +01:00
|
|
|
{
|
2010-12-20 11:35:57 +01:00
|
|
|
struct atheros_driver_data *drv = priv;
|
2009-02-19 15:27:07 +01:00
|
|
|
struct ieee80211req_del_key wk;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: addr=%s key_idx=%d",
|
|
|
|
__func__, ether_sprintf(addr), key_idx);
|
|
|
|
|
|
|
|
memset(&wk, 0, sizeof(wk));
|
|
|
|
if (addr != NULL) {
|
|
|
|
memcpy(wk.idk_macaddr, addr, IEEE80211_ADDR_LEN);
|
|
|
|
wk.idk_keyix = (u8) IEEE80211_KEYIX_NONE;
|
|
|
|
} else {
|
|
|
|
wk.idk_keyix = key_idx;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = set80211priv(drv, IEEE80211_IOCTL_DELKEY, &wk, sizeof(wk));
|
|
|
|
if (ret < 0) {
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: Failed to delete key (addr %s"
|
|
|
|
" key_idx %d)", __func__, ether_sprintf(addr),
|
|
|
|
key_idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_set_key(const char *ifname, void *priv, enum wpa_alg alg,
|
2009-12-26 09:35:08 +01:00
|
|
|
const u8 *addr, int key_idx, int set_tx, const u8 *seq,
|
|
|
|
size_t seq_len, const u8 *key, size_t key_len)
|
2009-02-19 15:27:07 +01:00
|
|
|
{
|
2010-12-20 11:35:57 +01:00
|
|
|
struct atheros_driver_data *drv = priv;
|
2009-02-19 15:27:07 +01:00
|
|
|
struct ieee80211req_key wk;
|
|
|
|
u_int8_t cipher;
|
|
|
|
int ret;
|
|
|
|
|
2009-03-25 16:49:22 +01:00
|
|
|
if (alg == WPA_ALG_NONE)
|
2010-12-20 11:35:57 +01:00
|
|
|
return atheros_del_key(drv, addr, key_idx);
|
2009-02-19 15:27:07 +01:00
|
|
|
|
2009-03-25 16:49:22 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "%s: alg=%d addr=%s key_idx=%d",
|
2009-02-19 15:27:07 +01:00
|
|
|
__func__, alg, ether_sprintf(addr), key_idx);
|
|
|
|
|
2009-03-25 16:49:22 +01:00
|
|
|
switch (alg) {
|
|
|
|
case WPA_ALG_WEP:
|
2009-02-19 15:27:07 +01:00
|
|
|
cipher = IEEE80211_CIPHER_WEP;
|
2009-03-25 16:49:22 +01:00
|
|
|
break;
|
|
|
|
case WPA_ALG_TKIP:
|
2009-02-19 15:27:07 +01:00
|
|
|
cipher = IEEE80211_CIPHER_TKIP;
|
2009-03-25 16:49:22 +01:00
|
|
|
break;
|
|
|
|
case WPA_ALG_CCMP:
|
2009-02-19 15:27:07 +01:00
|
|
|
cipher = IEEE80211_CIPHER_AES_CCM;
|
2009-03-25 16:49:22 +01:00
|
|
|
break;
|
2014-06-09 18:19:30 +02:00
|
|
|
#ifdef ATH_GCM_SUPPORT
|
|
|
|
case WPA_ALG_CCMP_256:
|
|
|
|
cipher = IEEE80211_CIPHER_AES_CCM_256;
|
|
|
|
break;
|
|
|
|
case WPA_ALG_GCMP:
|
|
|
|
cipher = IEEE80211_CIPHER_AES_GCM;
|
|
|
|
break;
|
|
|
|
case WPA_ALG_GCMP_256:
|
|
|
|
cipher = IEEE80211_CIPHER_AES_GCM_256;
|
|
|
|
break;
|
|
|
|
#endif /* ATH_GCM_SUPPORT */
|
2011-04-08 11:06:27 +02:00
|
|
|
#ifdef CONFIG_IEEE80211W
|
|
|
|
case WPA_ALG_IGTK:
|
|
|
|
cipher = IEEE80211_CIPHER_AES_CMAC;
|
|
|
|
break;
|
2014-06-09 18:19:30 +02:00
|
|
|
#ifdef ATH_GCM_SUPPORT
|
|
|
|
case WPA_ALG_BIP_CMAC_256:
|
|
|
|
cipher = IEEE80211_CIPHER_AES_CMAC_256;
|
|
|
|
break;
|
|
|
|
case WPA_ALG_BIP_GMAC_128:
|
|
|
|
cipher = IEEE80211_CIPHER_AES_GMAC;
|
|
|
|
break;
|
|
|
|
case WPA_ALG_BIP_GMAC_256:
|
|
|
|
cipher = IEEE80211_CIPHER_AES_GMAC_256;
|
|
|
|
break;
|
|
|
|
#endif /* ATH_GCM_SUPPORT */
|
2011-04-08 11:06:27 +02:00
|
|
|
#endif /* CONFIG_IEEE80211W */
|
2009-03-25 16:49:22 +01:00
|
|
|
default:
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_INFO, "%s: unknown/unsupported algorithm %d",
|
|
|
|
__func__, alg);
|
2009-02-19 15:27:07 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (key_len > sizeof(wk.ik_keydata)) {
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_INFO, "%s: key length %lu too big", __func__,
|
|
|
|
(unsigned long) key_len);
|
2009-02-19 15:27:07 +01:00
|
|
|
return -3;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&wk, 0, sizeof(wk));
|
|
|
|
wk.ik_type = cipher;
|
|
|
|
wk.ik_flags = IEEE80211_KEY_RECV | IEEE80211_KEY_XMIT;
|
2011-01-09 18:44:28 +01:00
|
|
|
if (addr == NULL || is_broadcast_ether_addr(addr)) {
|
2009-02-19 15:27:07 +01:00
|
|
|
memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN);
|
|
|
|
wk.ik_keyix = key_idx;
|
2011-03-11 16:55:43 +01:00
|
|
|
if (set_tx)
|
|
|
|
wk.ik_flags |= IEEE80211_KEY_DEFAULT;
|
2009-02-19 15:27:07 +01:00
|
|
|
} else {
|
|
|
|
memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
|
|
|
|
wk.ik_keyix = IEEE80211_KEYIX_NONE;
|
|
|
|
}
|
|
|
|
wk.ik_keylen = key_len;
|
|
|
|
memcpy(wk.ik_keydata, key, key_len);
|
|
|
|
|
|
|
|
ret = set80211priv(drv, IEEE80211_IOCTL_SETKEY, &wk, sizeof(wk));
|
|
|
|
if (ret < 0) {
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: Failed to set key (addr %s"
|
2009-03-25 16:49:22 +01:00
|
|
|
" key_idx %d alg %d key_len %lu set_tx %d)",
|
2009-02-19 15:27:07 +01:00
|
|
|
__func__, ether_sprintf(wk.ik_macaddr), key_idx,
|
2009-03-25 16:49:22 +01:00
|
|
|
alg, (unsigned long) key_len, set_tx);
|
2009-02-19 15:27:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_get_seqnum(const char *ifname, void *priv, const u8 *addr, int idx,
|
2009-02-19 15:27:07 +01:00
|
|
|
u8 *seq)
|
|
|
|
{
|
2010-12-20 11:35:57 +01:00
|
|
|
struct atheros_driver_data *drv = priv;
|
2009-02-19 15:27:07 +01:00
|
|
|
struct ieee80211req_key wk;
|
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: addr=%s idx=%d",
|
|
|
|
__func__, ether_sprintf(addr), idx);
|
|
|
|
|
|
|
|
memset(&wk, 0, sizeof(wk));
|
|
|
|
if (addr == NULL)
|
|
|
|
memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN);
|
|
|
|
else
|
|
|
|
memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
|
|
|
|
wk.ik_keyix = idx;
|
|
|
|
|
|
|
|
if (set80211priv(drv, IEEE80211_IOCTL_GETKEY, &wk, sizeof(wk))) {
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: Failed to get encryption data "
|
|
|
|
"(addr " MACSTR " key_idx %d)",
|
|
|
|
__func__, MAC2STR(wk.ik_macaddr), idx);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef WORDS_BIGENDIAN
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* wk.ik_keytsc is in host byte order (big endian), need to
|
|
|
|
* swap it to match with the byte order used in WPA.
|
|
|
|
*/
|
|
|
|
int i;
|
2010-04-17 20:04:26 +02:00
|
|
|
#ifndef WPA_KEY_RSC_LEN
|
|
|
|
#define WPA_KEY_RSC_LEN 8
|
|
|
|
#endif
|
2009-02-19 15:27:07 +01:00
|
|
|
u8 tmp[WPA_KEY_RSC_LEN];
|
|
|
|
memcpy(tmp, &wk.ik_keytsc, sizeof(wk.ik_keytsc));
|
|
|
|
for (i = 0; i < WPA_KEY_RSC_LEN; i++) {
|
|
|
|
seq[i] = tmp[WPA_KEY_RSC_LEN - i - 1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else /* WORDS_BIGENDIAN */
|
|
|
|
memcpy(seq, &wk.ik_keytsc, sizeof(wk.ik_keytsc));
|
|
|
|
#endif /* WORDS_BIGENDIAN */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_flush(void *priv)
|
2009-02-19 15:27:07 +01:00
|
|
|
{
|
|
|
|
u8 allsta[IEEE80211_ADDR_LEN];
|
|
|
|
memset(allsta, 0xff, IEEE80211_ADDR_LEN);
|
2010-12-20 11:35:57 +01:00
|
|
|
return atheros_sta_deauth(priv, NULL, allsta,
|
2009-04-17 10:37:22 +02:00
|
|
|
IEEE80211_REASON_AUTH_LEAVE);
|
2009-02-19 15:27:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_read_sta_driver_data(void *priv, struct hostap_sta_driver_data *data,
|
2009-02-19 15:27:07 +01:00
|
|
|
const u8 *addr)
|
|
|
|
{
|
2010-12-20 11:35:57 +01:00
|
|
|
struct atheros_driver_data *drv = priv;
|
2009-02-19 15:27:07 +01:00
|
|
|
struct ieee80211req_sta_stats stats;
|
|
|
|
|
|
|
|
memset(data, 0, sizeof(*data));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fetch statistics for station from the system.
|
|
|
|
*/
|
|
|
|
memset(&stats, 0, sizeof(stats));
|
|
|
|
memcpy(stats.is_u.macaddr, addr, IEEE80211_ADDR_LEN);
|
|
|
|
if (set80211priv(drv, IEEE80211_IOCTL_STA_STATS,
|
|
|
|
&stats, sizeof(stats))) {
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: Failed to fetch STA stats (addr "
|
|
|
|
MACSTR ")", __func__, MAC2STR(addr));
|
|
|
|
if (memcmp(addr, drv->acct_mac, ETH_ALEN) == 0) {
|
|
|
|
memcpy(data, &drv->acct_data, sizeof(*data));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_INFO,
|
|
|
|
"Failed to get station stats information element");
|
2009-02-19 15:27:07 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
data->rx_packets = stats.is_stats.ns_rx_data;
|
|
|
|
data->rx_bytes = stats.is_stats.ns_rx_bytes;
|
|
|
|
data->tx_packets = stats.is_stats.ns_tx_data;
|
|
|
|
data->tx_bytes = stats.is_stats.ns_tx_bytes;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_sta_clear_stats(void *priv, const u8 *addr)
|
2009-02-19 15:27:07 +01:00
|
|
|
{
|
2010-12-20 11:35:57 +01:00
|
|
|
struct atheros_driver_data *drv = priv;
|
2009-02-19 15:27:07 +01:00
|
|
|
struct ieee80211req_mlme mlme;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: addr=%s", __func__, ether_sprintf(addr));
|
|
|
|
|
|
|
|
mlme.im_op = IEEE80211_MLME_CLEAR_STATS;
|
|
|
|
memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
|
|
|
|
ret = set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme,
|
|
|
|
sizeof(mlme));
|
|
|
|
if (ret < 0) {
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: Failed to clear STA stats (addr "
|
|
|
|
MACSTR ")", __func__, MAC2STR(addr));
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_set_opt_ie(void *priv, const u8 *ie, size_t ie_len)
|
2009-02-19 15:27:07 +01:00
|
|
|
{
|
2011-01-05 12:44:53 +01:00
|
|
|
struct atheros_driver_data *drv = priv;
|
|
|
|
u8 buf[512];
|
|
|
|
struct ieee80211req_getset_appiebuf *app_ie;
|
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "%s buflen = %lu", __func__,
|
|
|
|
(unsigned long) ie_len);
|
2011-10-17 16:56:59 +02:00
|
|
|
wpa_hexdump(MSG_DEBUG, "atheros: set_generic_elem", ie, ie_len);
|
2011-01-05 12:44:53 +01:00
|
|
|
|
|
|
|
wpabuf_free(drv->wpa_ie);
|
|
|
|
drv->wpa_ie = wpabuf_alloc_copy(ie, ie_len);
|
|
|
|
|
|
|
|
app_ie = (struct ieee80211req_getset_appiebuf *) buf;
|
|
|
|
os_memcpy(&(app_ie->app_buf[0]), ie, ie_len);
|
|
|
|
app_ie->app_buflen = ie_len;
|
|
|
|
|
|
|
|
app_ie->app_frmtype = IEEE80211_APPIE_FRAME_BEACON;
|
|
|
|
|
|
|
|
/* append WPS IE for Beacon */
|
|
|
|
if (drv->wps_beacon_ie != NULL) {
|
|
|
|
os_memcpy(&(app_ie->app_buf[ie_len]),
|
|
|
|
wpabuf_head(drv->wps_beacon_ie),
|
|
|
|
wpabuf_len(drv->wps_beacon_ie));
|
|
|
|
app_ie->app_buflen = ie_len + wpabuf_len(drv->wps_beacon_ie);
|
|
|
|
}
|
2011-10-17 16:56:59 +02:00
|
|
|
wpa_hexdump(MSG_DEBUG, "atheros: SET_APPIEBUF(Beacon)",
|
|
|
|
app_ie->app_buf, app_ie->app_buflen);
|
2011-01-05 12:44:53 +01:00
|
|
|
set80211priv(drv, IEEE80211_IOCTL_SET_APPIEBUF, app_ie,
|
|
|
|
sizeof(struct ieee80211req_getset_appiebuf) +
|
|
|
|
app_ie->app_buflen);
|
|
|
|
|
|
|
|
/* append WPS IE for Probe Response */
|
|
|
|
app_ie->app_frmtype = IEEE80211_APPIE_FRAME_PROBE_RESP;
|
|
|
|
if (drv->wps_probe_resp_ie != NULL) {
|
|
|
|
os_memcpy(&(app_ie->app_buf[ie_len]),
|
|
|
|
wpabuf_head(drv->wps_probe_resp_ie),
|
|
|
|
wpabuf_len(drv->wps_probe_resp_ie));
|
|
|
|
app_ie->app_buflen = ie_len +
|
|
|
|
wpabuf_len(drv->wps_probe_resp_ie);
|
|
|
|
} else
|
|
|
|
app_ie->app_buflen = ie_len;
|
2011-10-17 16:56:59 +02:00
|
|
|
wpa_hexdump(MSG_DEBUG, "atheros: SET_APPIEBUF(ProbeResp)",
|
|
|
|
app_ie->app_buf, app_ie->app_buflen);
|
2011-01-05 12:44:53 +01:00
|
|
|
set80211priv(drv, IEEE80211_IOCTL_SET_APPIEBUF, app_ie,
|
|
|
|
sizeof(struct ieee80211req_getset_appiebuf) +
|
|
|
|
app_ie->app_buflen);
|
2009-02-19 15:27:07 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr,
|
2009-04-17 10:37:22 +02:00
|
|
|
int reason_code)
|
2009-02-19 15:27:07 +01:00
|
|
|
{
|
2010-12-20 11:35:57 +01:00
|
|
|
struct atheros_driver_data *drv = priv;
|
2009-02-19 15:27:07 +01:00
|
|
|
struct ieee80211req_mlme mlme;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: addr=%s reason_code=%d",
|
|
|
|
__func__, ether_sprintf(addr), reason_code);
|
|
|
|
|
|
|
|
mlme.im_op = IEEE80211_MLME_DEAUTH;
|
|
|
|
mlme.im_reason = reason_code;
|
|
|
|
memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
|
|
|
|
ret = set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme));
|
|
|
|
if (ret < 0) {
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: Failed to deauth STA (addr " MACSTR
|
|
|
|
" reason %d)",
|
|
|
|
__func__, MAC2STR(addr), reason_code);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_sta_disassoc(void *priv, const u8 *own_addr, const u8 *addr,
|
2009-04-17 10:37:22 +02:00
|
|
|
int reason_code)
|
2009-02-19 15:27:07 +01:00
|
|
|
{
|
2010-12-20 11:35:57 +01:00
|
|
|
struct atheros_driver_data *drv = priv;
|
2009-02-19 15:27:07 +01:00
|
|
|
struct ieee80211req_mlme mlme;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: addr=%s reason_code=%d",
|
|
|
|
__func__, ether_sprintf(addr), reason_code);
|
|
|
|
|
|
|
|
mlme.im_op = IEEE80211_MLME_DISASSOC;
|
|
|
|
mlme.im_reason = reason_code;
|
|
|
|
memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
|
|
|
|
ret = set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme));
|
|
|
|
if (ret < 0) {
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: Failed to disassoc STA (addr "
|
|
|
|
MACSTR " reason %d)",
|
|
|
|
__func__, MAC2STR(addr), reason_code);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-07-24 11:26:26 +02:00
|
|
|
static int atheros_set_qos_map(void *ctx, const u8 *qos_map_set,
|
|
|
|
u8 qos_map_set_len)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_ATHEROS_QOS_MAP
|
|
|
|
struct atheros_driver_data *drv = ctx;
|
|
|
|
struct ieee80211req_athdbg req;
|
|
|
|
struct ieee80211_qos_map *qos_map = &req.data.qos_map;
|
|
|
|
struct iwreq iwr;
|
|
|
|
int i, up_start;
|
|
|
|
|
|
|
|
if (qos_map_set_len < 16 || qos_map_set_len > 58 ||
|
|
|
|
qos_map_set_len & 1) {
|
|
|
|
wpa_printf(MSG_ERROR, "Invalid QoS Map");
|
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
memset(&req, 0, sizeof(struct ieee80211req_athdbg));
|
|
|
|
req.cmd = IEEE80211_DBGREQ_SETQOSMAPCONF;
|
|
|
|
os_memset(&iwr, 0, sizeof(iwr));
|
2013-10-26 10:42:09 +02:00
|
|
|
os_strlcpy(iwr.ifr_name, drv->iface, sizeof(iwr.ifr_name));
|
2013-07-24 11:26:26 +02:00
|
|
|
iwr.u.data.pointer = (void *) &req;
|
|
|
|
iwr.u.data.length = sizeof(struct ieee80211req_athdbg);
|
|
|
|
}
|
|
|
|
|
|
|
|
qos_map->valid = 1;
|
|
|
|
qos_map->num_dscp_except = (qos_map_set_len - 16) / 2;
|
|
|
|
if (qos_map->num_dscp_except) {
|
|
|
|
for (i = 0; i < qos_map->num_dscp_except; i++) {
|
|
|
|
qos_map->dscp_exception[i].dscp = qos_map_set[i * 2];
|
|
|
|
qos_map->dscp_exception[i].up = qos_map_set[i * 2 + 1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
up_start = qos_map_set_len - 16;
|
|
|
|
for (i = 0; i < IEEE80211_MAX_QOS_UP_RANGE; i++) {
|
|
|
|
qos_map->up[i].low = qos_map_set[up_start + (i * 2)];
|
|
|
|
qos_map->up[i].high = qos_map_set[up_start + (i * 2) + 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ioctl(drv->ioctl_sock, IEEE80211_IOCTL_DBGREQ, &iwr) < 0) {
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_ERROR,
|
|
|
|
"%s: %s: Failed to set QoS Map: ioctl[IEEE80211_IOCTL_DBGREQ]: %s",
|
|
|
|
__func__, drv->iface, strerror(errno));
|
2013-07-24 11:26:26 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_ATHEROS_QOS_MAP */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-12-01 07:02:45 +01:00
|
|
|
#if defined(CONFIG_WPS) || defined(CONFIG_IEEE80211R) || defined(CONFIG_WNM) || defined(CONFIG_HS20)
|
|
|
|
static void atheros_raw_receive(void *ctx, const u8 *src_addr, const u8 *buf,
|
|
|
|
size_t len)
|
2012-02-26 16:28:42 +01:00
|
|
|
{
|
|
|
|
struct atheros_driver_data *drv = ctx;
|
|
|
|
const struct ieee80211_mgmt *mgmt;
|
2014-12-01 07:02:45 +01:00
|
|
|
union wpa_event_data event;
|
|
|
|
u16 fc, stype;
|
|
|
|
int ielen;
|
|
|
|
const u8 *iebuf;
|
2012-02-26 16:28:42 +01:00
|
|
|
|
|
|
|
if (len < IEEE80211_HDRLEN)
|
|
|
|
return;
|
2014-12-01 07:02:45 +01:00
|
|
|
|
2012-02-26 16:28:42 +01:00
|
|
|
mgmt = (const struct ieee80211_mgmt *) buf;
|
|
|
|
|
|
|
|
fc = le_to_host16(mgmt->frame_control);
|
|
|
|
|
|
|
|
if (WLAN_FC_GET_TYPE(fc) != WLAN_FC_TYPE_MGMT)
|
|
|
|
return;
|
2014-12-01 07:02:45 +01:00
|
|
|
|
2012-02-26 16:28:42 +01:00
|
|
|
stype = WLAN_FC_GET_STYPE(fc);
|
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: subtype 0x%x len %d", __func__, stype,
|
|
|
|
(int) len);
|
|
|
|
|
2014-12-01 07:02:45 +01:00
|
|
|
if (stype == WLAN_FC_STYPE_PROBE_REQ) {
|
|
|
|
if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.probe_req))
|
|
|
|
return;
|
|
|
|
|
|
|
|
os_memset(&event, 0, sizeof(event));
|
|
|
|
event.rx_probe_req.sa = mgmt->sa;
|
|
|
|
event.rx_probe_req.da = mgmt->da;
|
|
|
|
event.rx_probe_req.bssid = mgmt->bssid;
|
|
|
|
event.rx_probe_req.ie = mgmt->u.probe_req.variable;
|
|
|
|
event.rx_probe_req.ie_len =
|
|
|
|
len - (IEEE80211_HDRLEN + sizeof(mgmt->u.probe_req));
|
|
|
|
wpa_supplicant_event(drv->hapd, EVENT_RX_PROBE_REQ, &event);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-02-26 16:28:42 +01:00
|
|
|
if (os_memcmp(drv->own_addr, mgmt->bssid, ETH_ALEN) != 0) {
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: BSSID does not match - ignore",
|
|
|
|
__func__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (stype) {
|
2014-12-01 07:02:45 +01:00
|
|
|
case WLAN_FC_STYPE_ASSOC_REQ:
|
|
|
|
if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.assoc_req))
|
|
|
|
break;
|
|
|
|
ielen = len - (IEEE80211_HDRLEN + sizeof(mgmt->u.assoc_req));
|
|
|
|
iebuf = mgmt->u.assoc_req.variable;
|
|
|
|
drv_event_assoc(drv->hapd, mgmt->sa, iebuf, ielen, 0);
|
|
|
|
break;
|
|
|
|
case WLAN_FC_STYPE_REASSOC_REQ:
|
|
|
|
if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.reassoc_req))
|
|
|
|
break;
|
|
|
|
ielen = len - (IEEE80211_HDRLEN + sizeof(mgmt->u.reassoc_req));
|
|
|
|
iebuf = mgmt->u.reassoc_req.variable;
|
|
|
|
drv_event_assoc(drv->hapd, mgmt->sa, iebuf, ielen, 1);
|
|
|
|
break;
|
2012-02-26 16:28:42 +01:00
|
|
|
case WLAN_FC_STYPE_ACTION:
|
|
|
|
os_memset(&event, 0, sizeof(event));
|
2013-12-29 10:22:23 +01:00
|
|
|
event.rx_mgmt.frame = buf;
|
|
|
|
event.rx_mgmt.frame_len = len;
|
|
|
|
wpa_supplicant_event(drv->hapd, EVENT_RX_MGMT, &event);
|
2012-02-26 16:28:42 +01:00
|
|
|
break;
|
2014-12-01 07:02:45 +01:00
|
|
|
case WLAN_FC_STYPE_AUTH:
|
|
|
|
if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.auth))
|
|
|
|
break;
|
|
|
|
os_memset(&event, 0, sizeof(event));
|
|
|
|
os_memcpy(event.auth.peer, mgmt->sa, ETH_ALEN);
|
|
|
|
os_memcpy(event.auth.bssid, mgmt->bssid, ETH_ALEN);
|
|
|
|
event.auth.auth_type = le_to_host16(mgmt->u.auth.auth_alg);
|
|
|
|
event.auth.status_code =
|
|
|
|
le_to_host16(mgmt->u.auth.status_code);
|
|
|
|
event.auth.auth_transaction =
|
|
|
|
le_to_host16(mgmt->u.auth.auth_transaction);
|
|
|
|
event.auth.ies = mgmt->u.auth.variable;
|
|
|
|
event.auth.ies_len = len - IEEE80211_HDRLEN -
|
|
|
|
sizeof(mgmt->u.auth);
|
|
|
|
wpa_supplicant_event(drv->hapd, EVENT_AUTH, &event);
|
|
|
|
break;
|
2012-02-26 16:28:42 +01:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-12-01 07:02:45 +01:00
|
|
|
#endif
|
2012-02-16 18:57:33 +01:00
|
|
|
|
|
|
|
static int atheros_receive_pkt(struct atheros_driver_data *drv)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
2009-02-19 15:27:07 +01:00
|
|
|
struct ieee80211req_set_filter filt;
|
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "%s Enter", __func__);
|
2012-02-16 18:57:33 +01:00
|
|
|
filt.app_filterype = 0;
|
|
|
|
#ifdef CONFIG_WPS
|
|
|
|
filt.app_filterype |= IEEE80211_FILTER_TYPE_PROBE_REQ;
|
|
|
|
#endif /* CONFIG_WPS */
|
|
|
|
#ifdef CONFIG_IEEE80211R
|
|
|
|
filt.app_filterype |= (IEEE80211_FILTER_TYPE_ASSOC_REQ |
|
2011-08-22 23:35:26 +02:00
|
|
|
IEEE80211_FILTER_TYPE_AUTH |
|
|
|
|
IEEE80211_FILTER_TYPE_ACTION);
|
2012-02-16 18:57:33 +01:00
|
|
|
#endif
|
2012-12-16 17:22:54 +01:00
|
|
|
#ifdef CONFIG_WNM
|
2012-02-26 16:28:42 +01:00
|
|
|
filt.app_filterype |= IEEE80211_FILTER_TYPE_ACTION;
|
2012-12-16 17:22:54 +01:00
|
|
|
#endif /* CONFIG_WNM */
|
2011-10-24 23:34:52 +02:00
|
|
|
#ifdef CONFIG_HS20
|
|
|
|
filt.app_filterype |= IEEE80211_FILTER_TYPE_ACTION;
|
|
|
|
#endif /* CONFIG_HS20 */
|
2012-02-16 18:57:33 +01:00
|
|
|
if (filt.app_filterype) {
|
|
|
|
ret = set80211priv(drv, IEEE80211_IOCTL_FILTERFRAME, &filt,
|
|
|
|
sizeof(struct ieee80211req_set_filter));
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
}
|
2009-02-19 15:27:07 +01:00
|
|
|
|
2012-06-23 19:33:50 +02:00
|
|
|
#if defined(CONFIG_WPS) || defined(CONFIG_IEEE80211R)
|
2009-02-19 15:27:07 +01:00
|
|
|
drv->sock_raw = l2_packet_init(drv->iface, NULL, ETH_P_80211_RAW,
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_raw_receive, drv, 1);
|
2009-02-19 15:27:07 +01:00
|
|
|
if (drv->sock_raw == NULL)
|
|
|
|
return -1;
|
2012-06-23 19:33:50 +02:00
|
|
|
#endif /* CONFIG_WPS || CONFIG_IEEE80211R */
|
2009-02-19 15:27:07 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-02-16 15:25:07 +01:00
|
|
|
static int atheros_reset_appfilter(struct atheros_driver_data *drv)
|
|
|
|
{
|
|
|
|
struct ieee80211req_set_filter filt;
|
|
|
|
filt.app_filterype = 0;
|
|
|
|
return set80211priv(drv, IEEE80211_IOCTL_FILTERFRAME, &filt,
|
|
|
|
sizeof(struct ieee80211req_set_filter));
|
|
|
|
}
|
|
|
|
|
2009-02-19 15:27:07 +01:00
|
|
|
#ifdef CONFIG_WPS
|
|
|
|
static int
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_set_wps_ie(void *priv, const u8 *ie, size_t len, u32 frametype)
|
2009-02-19 15:27:07 +01:00
|
|
|
{
|
2010-12-20 11:35:57 +01:00
|
|
|
struct atheros_driver_data *drv = priv;
|
2011-01-05 12:44:53 +01:00
|
|
|
u8 buf[512];
|
2009-02-19 15:27:07 +01:00
|
|
|
struct ieee80211req_getset_appiebuf *beac_ie;
|
|
|
|
|
2011-10-17 16:56:59 +02:00
|
|
|
wpa_printf(MSG_DEBUG, "%s buflen = %lu frametype=%u", __func__,
|
|
|
|
(unsigned long) len, frametype);
|
|
|
|
wpa_hexdump(MSG_DEBUG, "atheros: IE", ie, len);
|
2009-02-19 15:27:07 +01:00
|
|
|
|
|
|
|
beac_ie = (struct ieee80211req_getset_appiebuf *) buf;
|
|
|
|
beac_ie->app_frmtype = frametype;
|
|
|
|
beac_ie->app_buflen = len;
|
2011-01-05 12:44:53 +01:00
|
|
|
os_memcpy(&(beac_ie->app_buf[0]), ie, len);
|
|
|
|
|
|
|
|
/* append the WPA/RSN IE if it is set already */
|
|
|
|
if (((frametype == IEEE80211_APPIE_FRAME_BEACON) ||
|
|
|
|
(frametype == IEEE80211_APPIE_FRAME_PROBE_RESP)) &&
|
|
|
|
(drv->wpa_ie != NULL)) {
|
2011-10-17 16:56:59 +02:00
|
|
|
wpa_hexdump_buf(MSG_DEBUG, "atheros: Append WPA/RSN IE",
|
|
|
|
drv->wpa_ie);
|
2011-01-05 12:44:53 +01:00
|
|
|
os_memcpy(&(beac_ie->app_buf[len]), wpabuf_head(drv->wpa_ie),
|
|
|
|
wpabuf_len(drv->wpa_ie));
|
|
|
|
beac_ie->app_buflen += wpabuf_len(drv->wpa_ie);
|
|
|
|
}
|
2009-02-19 15:27:07 +01:00
|
|
|
|
2011-10-17 16:56:59 +02:00
|
|
|
wpa_hexdump(MSG_DEBUG, "atheros: SET_APPIEBUF",
|
|
|
|
beac_ie->app_buf, beac_ie->app_buflen);
|
2009-02-19 15:27:07 +01:00
|
|
|
return set80211priv(drv, IEEE80211_IOCTL_SET_APPIEBUF, beac_ie,
|
2011-01-05 12:44:53 +01:00
|
|
|
sizeof(struct ieee80211req_getset_appiebuf) +
|
|
|
|
beac_ie->app_buflen);
|
2009-02-19 15:27:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_set_ap_wps_ie(void *priv, const struct wpabuf *beacon,
|
2010-09-22 19:46:44 +02:00
|
|
|
const struct wpabuf *proberesp,
|
|
|
|
const struct wpabuf *assocresp)
|
2009-02-19 15:27:07 +01:00
|
|
|
{
|
2011-01-05 12:44:53 +01:00
|
|
|
struct atheros_driver_data *drv = priv;
|
|
|
|
|
2011-10-17 16:56:59 +02:00
|
|
|
wpa_hexdump_buf(MSG_DEBUG, "atheros: set_ap_wps_ie - beacon", beacon);
|
|
|
|
wpa_hexdump_buf(MSG_DEBUG, "atheros: set_ap_wps_ie - proberesp",
|
|
|
|
proberesp);
|
|
|
|
wpa_hexdump_buf(MSG_DEBUG, "atheros: set_ap_wps_ie - assocresp",
|
|
|
|
assocresp);
|
2011-01-05 12:44:53 +01:00
|
|
|
wpabuf_free(drv->wps_beacon_ie);
|
|
|
|
drv->wps_beacon_ie = beacon ? wpabuf_dup(beacon) : NULL;
|
|
|
|
wpabuf_free(drv->wps_probe_resp_ie);
|
|
|
|
drv->wps_probe_resp_ie = proberesp ? wpabuf_dup(proberesp) : NULL;
|
|
|
|
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_set_wps_ie(priv, assocresp ? wpabuf_head(assocresp) : NULL,
|
2010-09-22 19:46:44 +02:00
|
|
|
assocresp ? wpabuf_len(assocresp) : 0,
|
|
|
|
IEEE80211_APPIE_FRAME_ASSOC_RESP);
|
2010-12-20 11:35:57 +01:00
|
|
|
if (atheros_set_wps_ie(priv, beacon ? wpabuf_head(beacon) : NULL,
|
2009-12-24 18:46:06 +01:00
|
|
|
beacon ? wpabuf_len(beacon) : 0,
|
|
|
|
IEEE80211_APPIE_FRAME_BEACON))
|
|
|
|
return -1;
|
2010-12-20 11:35:57 +01:00
|
|
|
return atheros_set_wps_ie(priv,
|
2009-12-24 18:46:06 +01:00
|
|
|
proberesp ? wpabuf_head(proberesp) : NULL,
|
|
|
|
proberesp ? wpabuf_len(proberesp): 0,
|
2009-02-19 15:27:07 +01:00
|
|
|
IEEE80211_APPIE_FRAME_PROBE_RESP);
|
|
|
|
}
|
|
|
|
#else /* CONFIG_WPS */
|
2010-12-20 11:35:57 +01:00
|
|
|
#define atheros_set_ap_wps_ie NULL
|
2009-02-19 15:27:07 +01:00
|
|
|
#endif /* CONFIG_WPS */
|
|
|
|
|
2012-02-16 18:57:33 +01:00
|
|
|
#ifdef CONFIG_IEEE80211R
|
|
|
|
static int
|
|
|
|
atheros_sta_auth(void *priv, const u8 *own_addr, const u8 *addr, u16 seq,
|
|
|
|
u16 status_code, const u8 *ie, size_t len)
|
|
|
|
{
|
|
|
|
struct atheros_driver_data *drv = priv;
|
|
|
|
struct ieee80211req_mlme mlme;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: addr=%s status_code=%d",
|
|
|
|
__func__, ether_sprintf(addr), status_code);
|
|
|
|
|
|
|
|
mlme.im_op = IEEE80211_MLME_AUTH;
|
|
|
|
mlme.im_reason = status_code;
|
|
|
|
mlme.im_seq = seq;
|
|
|
|
os_memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
|
|
|
|
mlme.im_optie_len = len;
|
|
|
|
if (len) {
|
|
|
|
if (len < IEEE80211_MAX_OPT_IE) {
|
|
|
|
os_memcpy(mlme.im_optie, ie, len);
|
|
|
|
} else {
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: Not enough space to copy "
|
|
|
|
"opt_ie STA (addr " MACSTR " reason %d, "
|
|
|
|
"ie_len %d)",
|
|
|
|
__func__, MAC2STR(addr), status_code,
|
|
|
|
(int) len);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ret = set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme));
|
|
|
|
if (ret < 0) {
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: Failed to auth STA (addr " MACSTR
|
|
|
|
" reason %d)",
|
|
|
|
__func__, MAC2STR(addr), status_code);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
atheros_sta_assoc(void *priv, const u8 *own_addr, const u8 *addr,
|
|
|
|
int reassoc, u16 status_code, const u8 *ie, size_t len)
|
|
|
|
{
|
|
|
|
struct atheros_driver_data *drv = priv;
|
|
|
|
struct ieee80211req_mlme mlme;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: addr=%s status_code=%d reassoc %d",
|
|
|
|
__func__, ether_sprintf(addr), status_code, reassoc);
|
|
|
|
|
|
|
|
if (reassoc)
|
|
|
|
mlme.im_op = IEEE80211_MLME_REASSOC;
|
|
|
|
else
|
|
|
|
mlme.im_op = IEEE80211_MLME_ASSOC;
|
|
|
|
mlme.im_reason = status_code;
|
|
|
|
os_memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
|
|
|
|
mlme.im_optie_len = len;
|
|
|
|
if (len) {
|
|
|
|
if (len < IEEE80211_MAX_OPT_IE) {
|
|
|
|
os_memcpy(mlme.im_optie, ie, len);
|
|
|
|
} else {
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: Not enough space to copy "
|
|
|
|
"opt_ie STA (addr " MACSTR " reason %d, "
|
|
|
|
"ie_len %d)",
|
|
|
|
__func__, MAC2STR(addr), status_code,
|
|
|
|
(int) len);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ret = set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme));
|
|
|
|
if (ret < 0) {
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: Failed to assoc STA (addr " MACSTR
|
|
|
|
" reason %d)",
|
|
|
|
__func__, MAC2STR(addr), status_code);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_IEEE80211R */
|
|
|
|
|
2010-01-03 17:22:22 +01:00
|
|
|
static void
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_new_sta(struct atheros_driver_data *drv, u8 addr[IEEE80211_ADDR_LEN])
|
2009-02-19 15:27:07 +01:00
|
|
|
{
|
|
|
|
struct hostapd_data *hapd = drv->hapd;
|
|
|
|
struct ieee80211req_wpaie ie;
|
2010-01-03 17:22:22 +01:00
|
|
|
int ielen = 0;
|
2009-02-19 15:27:07 +01:00
|
|
|
u8 *iebuf = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fetch negotiated WPA/RSN parameters from the system.
|
|
|
|
*/
|
|
|
|
memset(&ie, 0, sizeof(ie));
|
|
|
|
memcpy(ie.wpa_macaddr, addr, IEEE80211_ADDR_LEN);
|
|
|
|
if (set80211priv(drv, IEEE80211_IOCTL_GETWPAIE, &ie, sizeof(ie))) {
|
|
|
|
/*
|
|
|
|
* See ATH_WPS_IE comment in the beginning of the file for a
|
|
|
|
* possible cause for the failure..
|
|
|
|
*/
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: Failed to get WPA/RSN IE: %s",
|
|
|
|
__func__, strerror(errno));
|
|
|
|
goto no_ie;
|
|
|
|
}
|
2010-12-20 11:35:57 +01:00
|
|
|
wpa_hexdump(MSG_MSGDUMP, "atheros req WPA IE",
|
2009-02-19 15:27:07 +01:00
|
|
|
ie.wpa_ie, IEEE80211_MAX_OPT_IE);
|
2010-12-20 11:35:57 +01:00
|
|
|
wpa_hexdump(MSG_MSGDUMP, "atheros req RSN IE",
|
2009-02-19 15:27:07 +01:00
|
|
|
ie.rsn_ie, IEEE80211_MAX_OPT_IE);
|
2010-09-25 02:01:03 +02:00
|
|
|
#ifdef ATH_WPS_IE
|
2010-12-20 11:35:57 +01:00
|
|
|
wpa_hexdump(MSG_MSGDUMP, "atheros req WPS IE",
|
2010-09-25 02:01:03 +02:00
|
|
|
ie.wps_ie, IEEE80211_MAX_OPT_IE);
|
|
|
|
#endif /* ATH_WPS_IE */
|
2009-02-19 15:27:07 +01:00
|
|
|
iebuf = ie.wpa_ie;
|
2010-12-20 11:35:57 +01:00
|
|
|
/* atheros seems to return some random data if WPA/RSN IE is not set.
|
2009-02-19 15:27:07 +01:00
|
|
|
* Assume the IE was not included if the IE type is unknown. */
|
|
|
|
if (iebuf[0] != WLAN_EID_VENDOR_SPECIFIC)
|
|
|
|
iebuf[1] = 0;
|
|
|
|
if (iebuf[1] == 0 && ie.rsn_ie[1] > 0) {
|
2010-12-20 11:35:57 +01:00
|
|
|
/* atheros-ng svn #1453 added rsn_ie. Use it, if wpa_ie was not
|
2009-02-19 15:27:07 +01:00
|
|
|
* set. This is needed for WPA2. */
|
|
|
|
iebuf = ie.rsn_ie;
|
|
|
|
if (iebuf[0] != WLAN_EID_RSN)
|
|
|
|
iebuf[1] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ielen = iebuf[1];
|
2010-09-25 02:01:03 +02:00
|
|
|
|
|
|
|
#ifdef ATH_WPS_IE
|
|
|
|
/* if WPS IE is present, preference is given to WPS */
|
|
|
|
if (ie.wps_ie &&
|
|
|
|
(ie.wps_ie[1] > 0 && (ie.wps_ie[0] == WLAN_EID_VENDOR_SPECIFIC))) {
|
|
|
|
iebuf = ie.wps_ie;
|
|
|
|
ielen = ie.wps_ie[1];
|
|
|
|
}
|
|
|
|
#endif /* ATH_WPS_IE */
|
|
|
|
|
2009-02-19 15:27:07 +01:00
|
|
|
if (ielen == 0)
|
|
|
|
iebuf = NULL;
|
|
|
|
else
|
|
|
|
ielen += 2;
|
|
|
|
|
|
|
|
no_ie:
|
2010-10-25 12:50:34 +02:00
|
|
|
drv_event_assoc(hapd, addr, iebuf, ielen, 0);
|
2009-02-19 15:27:07 +01:00
|
|
|
|
|
|
|
if (memcmp(addr, drv->acct_mac, ETH_ALEN) == 0) {
|
|
|
|
/* Cached accounting data is not valid anymore. */
|
|
|
|
memset(drv->acct_mac, 0, ETH_ALEN);
|
|
|
|
memset(&drv->acct_data, 0, sizeof(drv->acct_data));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_wireless_event_wireless_custom(struct atheros_driver_data *drv,
|
2009-02-19 15:27:07 +01:00
|
|
|
char *custom, char *end)
|
|
|
|
{
|
|
|
|
wpa_printf(MSG_DEBUG, "Custom wireless event: '%s'", custom);
|
|
|
|
|
|
|
|
if (strncmp(custom, "MLME-MICHAELMICFAILURE.indication", 33) == 0) {
|
|
|
|
char *pos;
|
|
|
|
u8 addr[ETH_ALEN];
|
|
|
|
pos = strstr(custom, "addr=");
|
|
|
|
if (pos == NULL) {
|
|
|
|
wpa_printf(MSG_DEBUG,
|
|
|
|
"MLME-MICHAELMICFAILURE.indication "
|
|
|
|
"without sender address ignored");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
pos += 5;
|
|
|
|
if (hwaddr_aton(pos, addr) == 0) {
|
2009-12-13 20:17:11 +01:00
|
|
|
union wpa_event_data data;
|
|
|
|
os_memset(&data, 0, sizeof(data));
|
|
|
|
data.michael_mic_failure.unicast = 1;
|
|
|
|
data.michael_mic_failure.src = addr;
|
|
|
|
wpa_supplicant_event(drv->hapd,
|
|
|
|
EVENT_MICHAEL_MIC_FAILURE, &data);
|
2009-02-19 15:27:07 +01:00
|
|
|
} else {
|
|
|
|
wpa_printf(MSG_DEBUG,
|
|
|
|
"MLME-MICHAELMICFAILURE.indication "
|
|
|
|
"with invalid MAC address");
|
|
|
|
}
|
|
|
|
} else if (strncmp(custom, "STA-TRAFFIC-STAT", 16) == 0) {
|
|
|
|
char *key, *value;
|
|
|
|
u32 val;
|
|
|
|
key = custom;
|
|
|
|
while ((key = strchr(key, '\n')) != NULL) {
|
|
|
|
key++;
|
|
|
|
value = strchr(key, '=');
|
|
|
|
if (value == NULL)
|
|
|
|
continue;
|
|
|
|
*value++ = '\0';
|
|
|
|
val = strtoul(value, NULL, 10);
|
|
|
|
if (strcmp(key, "mac") == 0)
|
|
|
|
hwaddr_aton(value, drv->acct_mac);
|
|
|
|
else if (strcmp(key, "rx_packets") == 0)
|
|
|
|
drv->acct_data.rx_packets = val;
|
|
|
|
else if (strcmp(key, "tx_packets") == 0)
|
|
|
|
drv->acct_data.tx_packets = val;
|
|
|
|
else if (strcmp(key, "rx_bytes") == 0)
|
|
|
|
drv->acct_data.rx_bytes = val;
|
|
|
|
else if (strcmp(key, "tx_bytes") == 0)
|
|
|
|
drv->acct_data.tx_bytes = val;
|
|
|
|
key = value;
|
|
|
|
}
|
|
|
|
#ifdef CONFIG_WPS
|
|
|
|
} else if (strncmp(custom, "PUSH-BUTTON.indication", 22) == 0) {
|
|
|
|
/* Some atheros kernels send push button as a wireless event */
|
|
|
|
/* PROBLEM! this event is received for ALL BSSs ...
|
|
|
|
* so all are enabled for WPS... ugh.
|
|
|
|
*/
|
2009-12-13 20:21:10 +01:00
|
|
|
wpa_supplicant_event(drv->hapd, EVENT_WPS_BUTTON_PUSHED, NULL);
|
2012-02-16 18:57:33 +01:00
|
|
|
#endif /* CONFIG_WPS */
|
2011-10-24 23:34:52 +02:00
|
|
|
#if defined(CONFIG_WPS) || defined(CONFIG_IEEE80211R) || defined(CONFIG_HS20)
|
|
|
|
#define MGMT_FRAM_TAG_SIZE 30 /* hardcoded in driver */
|
2009-02-19 15:27:07 +01:00
|
|
|
} else if (strncmp(custom, "Manage.prob_req ", 16) == 0) {
|
|
|
|
/*
|
|
|
|
* Atheros driver uses a hack to pass Probe Request frames as a
|
|
|
|
* binary data in the custom wireless event. The old way (using
|
|
|
|
* packet sniffing) didn't work when bridging.
|
|
|
|
* Format: "Manage.prob_req <frame len>" | zero padding | frame
|
|
|
|
*/
|
|
|
|
int len = atoi(custom + 16);
|
2011-10-24 23:34:52 +02:00
|
|
|
if (len < 0 || custom + MGMT_FRAM_TAG_SIZE + len > end) {
|
2009-02-19 15:27:07 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "Invalid Manage.prob_req event "
|
|
|
|
"length %d", len);
|
|
|
|
return;
|
|
|
|
}
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_raw_receive(drv, NULL,
|
2011-10-24 23:34:52 +02:00
|
|
|
(u8 *) custom + MGMT_FRAM_TAG_SIZE, len);
|
2012-02-16 18:57:33 +01:00
|
|
|
} else if (strncmp(custom, "Manage.assoc_req ", 17) == 0) {
|
|
|
|
/* Format: "Manage.assoc_req <frame len>" | zero padding |
|
|
|
|
* frame */
|
|
|
|
int len = atoi(custom + 17);
|
2011-10-24 23:34:52 +02:00
|
|
|
if (len < 0 || custom + MGMT_FRAM_TAG_SIZE + len > end) {
|
2012-02-16 18:57:33 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "Invalid Manage.prob_req/"
|
|
|
|
"assoc_req/auth event length %d", len);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
atheros_raw_receive(drv, NULL,
|
2011-10-24 23:34:52 +02:00
|
|
|
(u8 *) custom + MGMT_FRAM_TAG_SIZE, len);
|
2012-02-16 18:57:33 +01:00
|
|
|
} else if (strncmp(custom, "Manage.action ", 14) == 0) {
|
|
|
|
/* Format: "Manage.assoc_req <frame len>" | zero padding |
|
|
|
|
* frame */
|
|
|
|
int len = atoi(custom + 14);
|
2011-10-24 23:34:52 +02:00
|
|
|
if (len < 0 || custom + MGMT_FRAM_TAG_SIZE + len > end) {
|
2012-02-16 18:57:33 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "Invalid Manage.prob_req/"
|
|
|
|
"assoc_req/auth event length %d", len);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
atheros_raw_receive(drv, NULL,
|
2011-10-24 23:34:52 +02:00
|
|
|
(u8 *) custom + MGMT_FRAM_TAG_SIZE, len);
|
2012-02-16 18:57:33 +01:00
|
|
|
} else if (strncmp(custom, "Manage.auth ", 12) == 0) {
|
|
|
|
/* Format: "Manage.auth <frame len>" | zero padding | frame
|
|
|
|
*/
|
|
|
|
int len = atoi(custom + 12);
|
2011-10-24 23:34:52 +02:00
|
|
|
if (len < 0 || custom + MGMT_FRAM_TAG_SIZE + len > end) {
|
2012-02-16 18:57:33 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "Invalid Manage.prob_req/"
|
|
|
|
"assoc_req/auth event length %d", len);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
atheros_raw_receive(drv, NULL,
|
2011-10-24 23:34:52 +02:00
|
|
|
(u8 *) custom + MGMT_FRAM_TAG_SIZE, len);
|
2012-02-16 18:57:33 +01:00
|
|
|
#endif /* CONFIG_WPS or CONFIG_IEEE80211R */
|
2009-02-19 15:27:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-08 19:52:23 +02:00
|
|
|
/*
|
|
|
|
* Handle size of data problem. WEXT only allows data of 256 bytes for custom
|
|
|
|
* events, and p2p data can be much bigger. So the athr driver sends a small
|
|
|
|
* event telling me to collect the big data with an ioctl.
|
|
|
|
* On the first event, send all pending events to supplicant.
|
|
|
|
*/
|
|
|
|
static void fetch_pending_big_events(struct atheros_driver_data *drv)
|
|
|
|
{
|
|
|
|
union wpa_event_data event;
|
|
|
|
const struct ieee80211_mgmt *mgmt;
|
|
|
|
u8 tbuf[IW_PRIV_SIZE_MASK]; /* max size is 2047 bytes */
|
|
|
|
u16 fc, stype;
|
|
|
|
struct iwreq iwr;
|
|
|
|
size_t data_len;
|
|
|
|
u32 freq, frame_type;
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
os_memset(&iwr, 0, sizeof(iwr));
|
2013-10-26 10:42:09 +02:00
|
|
|
os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
|
2011-09-08 19:52:23 +02:00
|
|
|
|
|
|
|
iwr.u.data.pointer = (void *) tbuf;
|
|
|
|
iwr.u.data.length = sizeof(tbuf);
|
|
|
|
iwr.u.data.flags = IEEE80211_IOC_P2P_FETCH_FRAME;
|
|
|
|
|
|
|
|
if (ioctl(drv->ioctl_sock, IEEE80211_IOCTL_P2P_BIG_PARAM, &iwr)
|
|
|
|
< 0) {
|
|
|
|
if (errno == ENOSPC) {
|
|
|
|
wpa_printf(MSG_DEBUG, "%s:%d exit",
|
|
|
|
__func__, __LINE__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
wpa_printf(MSG_DEBUG, "athr: %s: P2P_BIG_PARAM["
|
|
|
|
"P2P_FETCH_FRAME] failed: %s",
|
|
|
|
__func__, strerror(errno));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
data_len = iwr.u.data.length;
|
|
|
|
wpa_hexdump(MSG_DEBUG, "athr: P2P_FETCH_FRAME data",
|
|
|
|
(u8 *) tbuf, data_len);
|
|
|
|
if (data_len < sizeof(freq) + sizeof(frame_type) + 24) {
|
|
|
|
wpa_printf(MSG_DEBUG, "athr: frame too short");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
os_memcpy(&freq, tbuf, sizeof(freq));
|
|
|
|
os_memcpy(&frame_type, &tbuf[sizeof(freq)],
|
|
|
|
sizeof(frame_type));
|
|
|
|
mgmt = (void *) &tbuf[sizeof(freq) + sizeof(frame_type)];
|
|
|
|
data_len -= sizeof(freq) + sizeof(frame_type);
|
|
|
|
|
|
|
|
if (frame_type == IEEE80211_EV_RX_MGMT) {
|
|
|
|
fc = le_to_host16(mgmt->frame_control);
|
|
|
|
stype = WLAN_FC_GET_STYPE(fc);
|
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "athr: EV_RX_MGMT stype=%u "
|
|
|
|
"freq=%u len=%u", stype, freq, (int) data_len);
|
|
|
|
|
|
|
|
if (stype == WLAN_FC_STYPE_ACTION) {
|
|
|
|
os_memset(&event, 0, sizeof(event));
|
|
|
|
event.rx_mgmt.frame = (const u8 *) mgmt;
|
|
|
|
event.rx_mgmt.frame_len = data_len;
|
|
|
|
wpa_supplicant_event(drv->hapd, EVENT_RX_MGMT,
|
|
|
|
&event);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
wpa_printf(MSG_DEBUG, "athr: %s unknown type %d",
|
|
|
|
__func__, frame_type);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
atheros_wireless_event_atheros_custom(struct atheros_driver_data *drv,
|
|
|
|
int opcode, char *buf, int len)
|
|
|
|
{
|
|
|
|
switch (opcode) {
|
|
|
|
case IEEE80211_EV_RX_MGMT:
|
|
|
|
wpa_printf(MSG_DEBUG, "WEXT: EV_RX_MGMT");
|
|
|
|
fetch_pending_big_events(drv);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-19 15:27:07 +01:00
|
|
|
static void
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_wireless_event_wireless(struct atheros_driver_data *drv,
|
2009-02-19 15:27:07 +01:00
|
|
|
char *data, int len)
|
|
|
|
{
|
|
|
|
struct iw_event iwe_buf, *iwe = &iwe_buf;
|
|
|
|
char *pos, *end, *custom, *buf;
|
|
|
|
|
|
|
|
pos = data;
|
|
|
|
end = data + len;
|
|
|
|
|
|
|
|
while (pos + IW_EV_LCP_LEN <= end) {
|
|
|
|
/* Event data may be unaligned, so make a local, aligned copy
|
|
|
|
* before processing. */
|
|
|
|
memcpy(&iwe_buf, pos, IW_EV_LCP_LEN);
|
|
|
|
wpa_printf(MSG_MSGDUMP, "Wireless event: cmd=0x%x len=%d",
|
|
|
|
iwe->cmd, iwe->len);
|
|
|
|
if (iwe->len <= IW_EV_LCP_LEN)
|
|
|
|
return;
|
|
|
|
|
|
|
|
custom = pos + IW_EV_POINT_LEN;
|
|
|
|
if (drv->we_version > 18 &&
|
|
|
|
(iwe->cmd == IWEVMICHAELMICFAILURE ||
|
|
|
|
iwe->cmd == IWEVASSOCREQIE ||
|
|
|
|
iwe->cmd == IWEVCUSTOM)) {
|
|
|
|
/* WE-19 removed the pointer from struct iw_point */
|
|
|
|
char *dpos = (char *) &iwe_buf.u.data.length;
|
|
|
|
int dlen = dpos - (char *) &iwe_buf;
|
|
|
|
memcpy(dpos, pos + IW_EV_LCP_LEN,
|
|
|
|
sizeof(struct iw_event) - dlen);
|
|
|
|
} else {
|
|
|
|
memcpy(&iwe_buf, pos, sizeof(struct iw_event));
|
|
|
|
custom += IW_EV_POINT_OFF;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (iwe->cmd) {
|
|
|
|
case IWEVEXPIRED:
|
2010-01-03 17:22:22 +01:00
|
|
|
drv_event_disassoc(drv->hapd,
|
|
|
|
(u8 *) iwe->u.addr.sa_data);
|
2009-02-19 15:27:07 +01:00
|
|
|
break;
|
|
|
|
case IWEVREGISTERED:
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_new_sta(drv, (u8 *) iwe->u.addr.sa_data);
|
2009-02-19 15:27:07 +01:00
|
|
|
break;
|
|
|
|
case IWEVASSOCREQIE:
|
|
|
|
/* Driver hack.. Use IWEVASSOCREQIE to bypass
|
|
|
|
* IWEVCUSTOM size limitations. Need to handle this
|
|
|
|
* just like IWEVCUSTOM.
|
|
|
|
*/
|
|
|
|
case IWEVCUSTOM:
|
|
|
|
if (custom + iwe->u.data.length > end)
|
|
|
|
return;
|
|
|
|
buf = malloc(iwe->u.data.length + 1);
|
|
|
|
if (buf == NULL)
|
|
|
|
return; /* XXX */
|
|
|
|
memcpy(buf, custom, iwe->u.data.length);
|
|
|
|
buf[iwe->u.data.length] = '\0';
|
2011-09-08 19:52:23 +02:00
|
|
|
|
|
|
|
if (iwe->u.data.flags != 0) {
|
|
|
|
atheros_wireless_event_atheros_custom(
|
|
|
|
drv, (int) iwe->u.data.flags,
|
|
|
|
buf, len);
|
|
|
|
} else {
|
|
|
|
atheros_wireless_event_wireless_custom(
|
|
|
|
drv, buf, buf + iwe->u.data.length);
|
|
|
|
}
|
2009-02-19 15:27:07 +01:00
|
|
|
free(buf);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pos += iwe->len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_wireless_event_rtm_newlink(void *ctx,
|
2009-12-18 17:24:13 +01:00
|
|
|
struct ifinfomsg *ifi, u8 *buf, size_t len)
|
2009-02-19 15:27:07 +01:00
|
|
|
{
|
2010-12-20 11:35:57 +01:00
|
|
|
struct atheros_driver_data *drv = ctx;
|
2009-12-18 17:24:13 +01:00
|
|
|
int attrlen, rta_len;
|
|
|
|
struct rtattr *attr;
|
2009-02-19 15:27:07 +01:00
|
|
|
|
|
|
|
if (ifi->ifi_index != drv->ifindex)
|
|
|
|
return;
|
|
|
|
|
2009-12-18 17:24:13 +01:00
|
|
|
attrlen = len;
|
|
|
|
attr = (struct rtattr *) buf;
|
2009-02-19 15:27:07 +01:00
|
|
|
|
|
|
|
rta_len = RTA_ALIGN(sizeof(struct rtattr));
|
|
|
|
while (RTA_OK(attr, attrlen)) {
|
|
|
|
if (attr->rta_type == IFLA_WIRELESS) {
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_wireless_event_wireless(
|
2009-02-19 15:27:07 +01:00
|
|
|
drv, ((char *) attr) + rta_len,
|
|
|
|
attr->rta_len - rta_len);
|
|
|
|
}
|
|
|
|
attr = RTA_NEXT(attr, attrlen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_get_we_version(struct atheros_driver_data *drv)
|
2009-02-19 15:27:07 +01:00
|
|
|
{
|
|
|
|
struct iw_range *range;
|
|
|
|
struct iwreq iwr;
|
|
|
|
int minlen;
|
|
|
|
size_t buflen;
|
|
|
|
|
|
|
|
drv->we_version = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Use larger buffer than struct iw_range in order to allow the
|
|
|
|
* structure to grow in the future.
|
|
|
|
*/
|
|
|
|
buflen = sizeof(struct iw_range) + 500;
|
|
|
|
range = os_zalloc(buflen);
|
|
|
|
if (range == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
memset(&iwr, 0, sizeof(iwr));
|
|
|
|
os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
|
|
|
|
iwr.u.data.pointer = (caddr_t) range;
|
|
|
|
iwr.u.data.length = buflen;
|
|
|
|
|
|
|
|
minlen = ((char *) &range->enc_capa) - (char *) range +
|
|
|
|
sizeof(range->enc_capa);
|
|
|
|
|
|
|
|
if (ioctl(drv->ioctl_sock, SIOCGIWRANGE, &iwr) < 0) {
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_ERROR, "ioctl[SIOCGIWRANGE]: %s",
|
|
|
|
strerror(errno));
|
|
|
|
os_free(range);
|
2009-02-19 15:27:07 +01:00
|
|
|
return -1;
|
|
|
|
} else if (iwr.u.data.length >= minlen &&
|
|
|
|
range->we_version_compiled >= 18) {
|
|
|
|
wpa_printf(MSG_DEBUG, "SIOCGIWRANGE: WE(compiled)=%d "
|
|
|
|
"WE(source)=%d enc_capa=0x%x",
|
|
|
|
range->we_version_compiled,
|
|
|
|
range->we_version_source,
|
|
|
|
range->enc_capa);
|
|
|
|
drv->we_version = range->we_version_compiled;
|
|
|
|
}
|
|
|
|
|
2011-06-25 14:41:46 +02:00
|
|
|
os_free(range);
|
2009-02-19 15:27:07 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_wireless_event_init(struct atheros_driver_data *drv)
|
2009-02-19 15:27:07 +01:00
|
|
|
{
|
2009-12-18 17:24:13 +01:00
|
|
|
struct netlink_config *cfg;
|
2009-02-19 15:27:07 +01:00
|
|
|
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_get_we_version(drv);
|
2009-02-19 15:27:07 +01:00
|
|
|
|
2009-12-18 17:24:13 +01:00
|
|
|
cfg = os_zalloc(sizeof(*cfg));
|
|
|
|
if (cfg == NULL)
|
2009-02-19 15:27:07 +01:00
|
|
|
return -1;
|
2009-12-18 17:24:13 +01:00
|
|
|
cfg->ctx = drv;
|
2010-12-20 11:35:57 +01:00
|
|
|
cfg->newlink_cb = atheros_wireless_event_rtm_newlink;
|
2009-12-18 17:24:13 +01:00
|
|
|
drv->netlink = netlink_init(cfg);
|
|
|
|
if (drv->netlink == NULL) {
|
|
|
|
os_free(cfg);
|
2009-02-19 15:27:07 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_send_eapol(void *priv, const u8 *addr, const u8 *data, size_t data_len,
|
2011-04-02 21:03:05 +02:00
|
|
|
int encrypt, const u8 *own_addr, u32 flags)
|
2009-02-19 15:27:07 +01:00
|
|
|
{
|
2010-12-20 11:35:57 +01:00
|
|
|
struct atheros_driver_data *drv = priv;
|
2009-02-19 15:27:07 +01:00
|
|
|
unsigned char buf[3000];
|
|
|
|
unsigned char *bp = buf;
|
|
|
|
struct l2_ethhdr *eth;
|
|
|
|
size_t len;
|
|
|
|
int status;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Prepend the Ethernet header. If the caller left us
|
|
|
|
* space at the front we could just insert it but since
|
|
|
|
* we don't know we copy to a local buffer. Given the frequency
|
|
|
|
* and size of frames this probably doesn't matter.
|
|
|
|
*/
|
|
|
|
len = data_len + sizeof(struct l2_ethhdr);
|
|
|
|
if (len > sizeof(buf)) {
|
|
|
|
bp = malloc(len);
|
|
|
|
if (bp == NULL) {
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_INFO,
|
|
|
|
"EAPOL frame discarded, cannot malloc temp buffer of size %lu!",
|
|
|
|
(unsigned long) len);
|
2009-02-19 15:27:07 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
eth = (struct l2_ethhdr *) bp;
|
|
|
|
memcpy(eth->h_dest, addr, ETH_ALEN);
|
|
|
|
memcpy(eth->h_source, own_addr, ETH_ALEN);
|
|
|
|
eth->h_proto = host_to_be16(ETH_P_EAPOL);
|
|
|
|
memcpy(eth+1, data, data_len);
|
|
|
|
|
|
|
|
wpa_hexdump(MSG_MSGDUMP, "TX EAPOL", bp, len);
|
|
|
|
|
|
|
|
status = l2_packet_send(drv->sock_xmit, addr, ETH_P_EAPOL, bp, len);
|
|
|
|
|
|
|
|
if (bp != buf)
|
|
|
|
free(bp);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
handle_read(void *ctx, const u8 *src_addr, const u8 *buf, size_t len)
|
|
|
|
{
|
2010-12-20 11:35:57 +01:00
|
|
|
struct atheros_driver_data *drv = ctx;
|
2010-01-03 17:35:01 +01:00
|
|
|
drv_event_eapol_rx(drv->hapd, src_addr, buf + sizeof(struct l2_ethhdr),
|
|
|
|
len - sizeof(struct l2_ethhdr));
|
2009-02-19 15:27:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_init(struct hostapd_data *hapd, struct wpa_init_params *params)
|
2009-02-19 15:27:07 +01:00
|
|
|
{
|
2010-12-20 11:35:57 +01:00
|
|
|
struct atheros_driver_data *drv;
|
2009-02-19 15:27:07 +01:00
|
|
|
struct ifreq ifr;
|
|
|
|
struct iwreq iwr;
|
2010-01-16 14:19:58 +01:00
|
|
|
char brname[IFNAMSIZ];
|
2009-02-19 15:27:07 +01:00
|
|
|
|
2010-12-20 11:35:57 +01:00
|
|
|
drv = os_zalloc(sizeof(struct atheros_driver_data));
|
2009-02-19 15:27:07 +01:00
|
|
|
if (drv == NULL) {
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_INFO,
|
|
|
|
"Could not allocate memory for atheros driver data");
|
2009-02-19 15:27:07 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
drv->hapd = hapd;
|
|
|
|
drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
|
|
|
|
if (drv->ioctl_sock < 0) {
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_ERROR, "socket[PF_INET,SOCK_DGRAM]: %s",
|
|
|
|
strerror(errno));
|
2009-02-19 15:27:07 +01:00
|
|
|
goto bad;
|
|
|
|
}
|
2009-04-09 22:28:21 +02:00
|
|
|
memcpy(drv->iface, params->ifname, sizeof(drv->iface));
|
2009-02-19 15:27:07 +01:00
|
|
|
|
|
|
|
memset(&ifr, 0, sizeof(ifr));
|
|
|
|
os_strlcpy(ifr.ifr_name, drv->iface, sizeof(ifr.ifr_name));
|
|
|
|
if (ioctl(drv->ioctl_sock, SIOCGIFINDEX, &ifr) != 0) {
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_ERROR, "ioctl(SIOCGIFINDEX): %s",
|
|
|
|
strerror(errno));
|
2009-02-19 15:27:07 +01:00
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
drv->ifindex = ifr.ifr_ifindex;
|
|
|
|
|
|
|
|
drv->sock_xmit = l2_packet_init(drv->iface, NULL, ETH_P_EAPOL,
|
|
|
|
handle_read, drv, 1);
|
|
|
|
if (drv->sock_xmit == NULL)
|
|
|
|
goto bad;
|
2009-04-17 10:55:51 +02:00
|
|
|
if (l2_packet_get_own_addr(drv->sock_xmit, params->own_addr))
|
2009-02-19 15:27:07 +01:00
|
|
|
goto bad;
|
2012-11-11 15:07:28 +01:00
|
|
|
os_memcpy(drv->own_addr, params->own_addr, ETH_ALEN);
|
2009-04-09 22:28:21 +02:00
|
|
|
if (params->bridge[0]) {
|
2009-02-19 15:27:07 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "Configure bridge %s for EAPOL traffic.",
|
2009-04-09 22:28:21 +02:00
|
|
|
params->bridge[0]);
|
|
|
|
drv->sock_recv = l2_packet_init(params->bridge[0], NULL,
|
2009-02-19 15:27:07 +01:00
|
|
|
ETH_P_EAPOL, handle_read, drv,
|
|
|
|
1);
|
|
|
|
if (drv->sock_recv == NULL)
|
|
|
|
goto bad;
|
2010-01-16 14:19:58 +01:00
|
|
|
} else if (linux_br_get(brname, drv->iface) == 0) {
|
|
|
|
wpa_printf(MSG_DEBUG, "Interface in bridge %s; configure for "
|
|
|
|
"EAPOL receive", brname);
|
|
|
|
drv->sock_recv = l2_packet_init(brname, NULL, ETH_P_EAPOL,
|
|
|
|
handle_read, drv, 1);
|
|
|
|
if (drv->sock_recv == NULL)
|
|
|
|
goto bad;
|
2009-02-19 15:27:07 +01:00
|
|
|
} else
|
|
|
|
drv->sock_recv = drv->sock_xmit;
|
|
|
|
|
|
|
|
memset(&iwr, 0, sizeof(iwr));
|
|
|
|
os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
|
|
|
|
|
|
|
|
iwr.u.mode = IW_MODE_MASTER;
|
|
|
|
|
|
|
|
if (ioctl(drv->ioctl_sock, SIOCSIWMODE, &iwr) < 0) {
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_ERROR,
|
|
|
|
"Could not set interface to master mode! ioctl[SIOCSIWMODE]: %s",
|
|
|
|
strerror(errno));
|
2009-02-19 15:27:07 +01:00
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
2010-01-03 21:08:26 +01:00
|
|
|
/* mark down during setup */
|
|
|
|
linux_set_iface_flags(drv->ioctl_sock, drv->iface, 0);
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_set_privacy(drv, 0); /* default to no privacy */
|
2009-02-19 15:27:07 +01:00
|
|
|
|
2012-12-25 12:50:41 +01:00
|
|
|
if (atheros_receive_pkt(drv))
|
|
|
|
goto bad;
|
2009-02-19 15:27:07 +01:00
|
|
|
|
2010-12-20 11:35:57 +01:00
|
|
|
if (atheros_wireless_event_init(drv))
|
2009-04-03 10:51:40 +02:00
|
|
|
goto bad;
|
|
|
|
|
2009-02-19 15:27:07 +01:00
|
|
|
return drv;
|
|
|
|
bad:
|
2012-12-25 12:50:41 +01:00
|
|
|
atheros_reset_appfilter(drv);
|
|
|
|
if (drv->sock_raw)
|
|
|
|
l2_packet_deinit(drv->sock_raw);
|
2010-09-05 12:03:26 +02:00
|
|
|
if (drv->sock_recv != NULL && drv->sock_recv != drv->sock_xmit)
|
|
|
|
l2_packet_deinit(drv->sock_recv);
|
2009-02-19 15:27:07 +01:00
|
|
|
if (drv->sock_xmit != NULL)
|
|
|
|
l2_packet_deinit(drv->sock_xmit);
|
|
|
|
if (drv->ioctl_sock >= 0)
|
|
|
|
close(drv->ioctl_sock);
|
2015-06-23 19:04:14 +02:00
|
|
|
os_free(drv);
|
2009-02-19 15:27:07 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_deinit(void *priv)
|
2009-02-19 15:27:07 +01:00
|
|
|
{
|
2010-12-20 11:35:57 +01:00
|
|
|
struct atheros_driver_data *drv = priv;
|
2009-02-19 15:27:07 +01:00
|
|
|
|
2012-02-16 15:25:07 +01:00
|
|
|
atheros_reset_appfilter(drv);
|
2015-03-24 14:05:43 +01:00
|
|
|
|
|
|
|
if (drv->wpa_ie || drv->wps_beacon_ie || drv->wps_probe_resp_ie) {
|
|
|
|
wpabuf_free(drv->wpa_ie);
|
|
|
|
wpabuf_free(drv->wps_beacon_ie);
|
|
|
|
wpabuf_free(drv->wps_probe_resp_ie);
|
|
|
|
atheros_set_opt_ie(priv, NULL, 0);
|
|
|
|
}
|
2009-12-18 17:24:13 +01:00
|
|
|
netlink_deinit(drv->netlink);
|
2010-01-03 21:08:26 +01:00
|
|
|
(void) linux_set_iface_flags(drv->ioctl_sock, drv->iface, 0);
|
2009-02-19 15:27:07 +01:00
|
|
|
if (drv->ioctl_sock >= 0)
|
|
|
|
close(drv->ioctl_sock);
|
|
|
|
if (drv->sock_recv != NULL && drv->sock_recv != drv->sock_xmit)
|
|
|
|
l2_packet_deinit(drv->sock_recv);
|
|
|
|
if (drv->sock_xmit != NULL)
|
|
|
|
l2_packet_deinit(drv->sock_xmit);
|
|
|
|
if (drv->sock_raw)
|
|
|
|
l2_packet_deinit(drv->sock_raw);
|
2015-06-23 19:04:14 +02:00
|
|
|
os_free(drv);
|
2009-02-19 15:27:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_set_ssid(void *priv, const u8 *buf, int len)
|
2009-02-19 15:27:07 +01:00
|
|
|
{
|
2010-12-20 11:35:57 +01:00
|
|
|
struct atheros_driver_data *drv = priv;
|
2009-02-19 15:27:07 +01:00
|
|
|
struct iwreq iwr;
|
|
|
|
|
|
|
|
memset(&iwr, 0, sizeof(iwr));
|
|
|
|
os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
|
|
|
|
iwr.u.essid.flags = 1; /* SSID active */
|
|
|
|
iwr.u.essid.pointer = (caddr_t) buf;
|
|
|
|
iwr.u.essid.length = len + 1;
|
|
|
|
|
|
|
|
if (ioctl(drv->ioctl_sock, SIOCSIWESSID, &iwr) < 0) {
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_ERROR, "ioctl[SIOCSIWESSID,len=%d]: %s",
|
|
|
|
len, strerror(errno));
|
2009-02-19 15:27:07 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_get_ssid(void *priv, u8 *buf, int len)
|
2009-02-19 15:27:07 +01:00
|
|
|
{
|
2010-12-20 11:35:57 +01:00
|
|
|
struct atheros_driver_data *drv = priv;
|
2009-02-19 15:27:07 +01:00
|
|
|
struct iwreq iwr;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
memset(&iwr, 0, sizeof(iwr));
|
|
|
|
os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
|
|
|
|
iwr.u.essid.pointer = (caddr_t) buf;
|
2011-09-22 14:42:03 +02:00
|
|
|
iwr.u.essid.length = (len > IW_ESSID_MAX_SIZE) ?
|
|
|
|
IW_ESSID_MAX_SIZE : len;
|
2009-02-19 15:27:07 +01:00
|
|
|
|
|
|
|
if (ioctl(drv->ioctl_sock, SIOCGIWESSID, &iwr) < 0) {
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_ERROR, "ioctl[SIOCGIWESSID]: %s",
|
|
|
|
strerror(errno));
|
2009-02-19 15:27:07 +01:00
|
|
|
ret = -1;
|
|
|
|
} else
|
|
|
|
ret = iwr.u.essid.length;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_set_countermeasures(void *priv, int enabled)
|
2009-02-19 15:27:07 +01:00
|
|
|
{
|
2010-12-20 11:35:57 +01:00
|
|
|
struct atheros_driver_data *drv = priv;
|
2009-02-19 15:27:07 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "%s: enabled=%d", __FUNCTION__, enabled);
|
|
|
|
return set80211param(drv, IEEE80211_PARAM_COUNTERMEASURES, enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-12-20 11:35:57 +01:00
|
|
|
atheros_commit(void *priv)
|
2009-02-19 15:27:07 +01:00
|
|
|
{
|
2010-12-20 11:35:57 +01:00
|
|
|
struct atheros_driver_data *drv = priv;
|
2010-01-03 21:08:26 +01:00
|
|
|
return linux_set_iface_flags(drv->ioctl_sock, drv->iface, 1);
|
2009-02-19 15:27:07 +01:00
|
|
|
}
|
|
|
|
|
2011-05-20 17:27:53 +02:00
|
|
|
static int atheros_set_authmode(void *priv, int auth_algs)
|
|
|
|
{
|
|
|
|
int authmode;
|
|
|
|
|
|
|
|
if ((auth_algs & WPA_AUTH_ALG_OPEN) &&
|
|
|
|
(auth_algs & WPA_AUTH_ALG_SHARED))
|
|
|
|
authmode = IEEE80211_AUTH_AUTO;
|
|
|
|
else if (auth_algs & WPA_AUTH_ALG_OPEN)
|
|
|
|
authmode = IEEE80211_AUTH_OPEN;
|
|
|
|
else if (auth_algs & WPA_AUTH_ALG_SHARED)
|
|
|
|
authmode = IEEE80211_AUTH_SHARED;
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return set80211param(priv, IEEE80211_PARAM_AUTHMODE, authmode);
|
|
|
|
}
|
|
|
|
|
2011-10-17 20:36:28 +02:00
|
|
|
static int atheros_set_ap(void *priv, struct wpa_driver_ap_params *params)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* TODO: Use this to replace set_authmode, set_privacy, set_ieee8021x,
|
|
|
|
* set_generic_elem, and hapd_set_ssid.
|
|
|
|
*/
|
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "atheros: set_ap - pairwise_ciphers=0x%x "
|
|
|
|
"group_cipher=0x%x key_mgmt_suites=0x%x auth_algs=0x%x "
|
|
|
|
"wpa_version=0x%x privacy=%d interworking=%d",
|
|
|
|
params->pairwise_ciphers, params->group_cipher,
|
|
|
|
params->key_mgmt_suites, params->auth_algs,
|
|
|
|
params->wpa_version, params->privacy, params->interworking);
|
|
|
|
wpa_hexdump_ascii(MSG_DEBUG, "atheros: SSID",
|
|
|
|
params->ssid, params->ssid_len);
|
|
|
|
if (params->hessid)
|
|
|
|
wpa_printf(MSG_DEBUG, "atheros: HESSID " MACSTR,
|
|
|
|
MAC2STR(params->hessid));
|
|
|
|
wpa_hexdump_buf(MSG_DEBUG, "atheros: beacon_ies",
|
|
|
|
params->beacon_ies);
|
|
|
|
wpa_hexdump_buf(MSG_DEBUG, "atheros: proberesp_ies",
|
|
|
|
params->proberesp_ies);
|
|
|
|
wpa_hexdump_buf(MSG_DEBUG, "atheros: assocresp_ies",
|
|
|
|
params->assocresp_ies);
|
|
|
|
|
2015-03-02 05:59:07 +01:00
|
|
|
#if defined(CONFIG_HS20) && (defined(IEEE80211_PARAM_OSEN) || defined(CONFIG_ATHEROS_OSEN))
|
2013-08-23 09:40:33 +02:00
|
|
|
if (params->osen) {
|
|
|
|
struct wpa_bss_params bss_params;
|
|
|
|
|
|
|
|
os_memset(&bss_params, 0, sizeof(struct wpa_bss_params));
|
|
|
|
bss_params.enabled = 1;
|
|
|
|
bss_params.wpa = 2;
|
|
|
|
bss_params.wpa_pairwise = WPA_CIPHER_CCMP;
|
|
|
|
bss_params.wpa_group = WPA_CIPHER_CCMP;
|
|
|
|
bss_params.ieee802_1x = 1;
|
|
|
|
|
|
|
|
if (atheros_set_privacy(priv, 1) ||
|
|
|
|
set80211param(priv, IEEE80211_PARAM_OSEN, 1))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return atheros_set_ieee8021x(priv, &bss_params);
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_HS20 && IEEE80211_PARAM_OSEN */
|
|
|
|
|
2011-10-17 20:36:28 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-02-16 18:57:33 +01:00
|
|
|
|
|
|
|
#ifdef CONFIG_IEEE80211R
|
|
|
|
|
|
|
|
static int atheros_send_mgmt(void *priv, const u8 *frm, size_t data_len,
|
2015-06-10 10:43:34 +02:00
|
|
|
int noack, unsigned int freq)
|
2012-02-16 18:57:33 +01:00
|
|
|
{
|
|
|
|
struct atheros_driver_data *drv = priv;
|
|
|
|
u8 buf[1510];
|
|
|
|
const struct ieee80211_mgmt *mgmt;
|
|
|
|
struct ieee80211req_mgmtbuf *mgmt_frm;
|
|
|
|
|
|
|
|
mgmt = (const struct ieee80211_mgmt *) frm;
|
|
|
|
wpa_printf(MSG_DEBUG, "%s frmlen = %lu " MACSTR, __func__,
|
|
|
|
(unsigned long) data_len, MAC2STR(mgmt->da));
|
|
|
|
mgmt_frm = (struct ieee80211req_mgmtbuf *) buf;
|
|
|
|
memcpy(mgmt_frm->macaddr, (u8 *)mgmt->da, IEEE80211_ADDR_LEN);
|
|
|
|
mgmt_frm->buflen = data_len;
|
|
|
|
if (&mgmt_frm->buf[0] + data_len > buf + sizeof(buf)) {
|
|
|
|
wpa_printf(MSG_INFO, "atheros: Too long frame for "
|
|
|
|
"atheros_send_mgmt (%u)", (unsigned int) data_len);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
os_memcpy(&mgmt_frm->buf[0], frm, data_len);
|
|
|
|
return set80211priv(drv, IEEE80211_IOCTL_SEND_MGMT, mgmt_frm,
|
|
|
|
sizeof(struct ieee80211req_mgmtbuf) + data_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int atheros_add_tspec(void *priv, const u8 *addr, u8 *tspec_ie,
|
|
|
|
size_t tspec_ielen)
|
|
|
|
{
|
|
|
|
struct atheros_driver_data *drv = priv;
|
|
|
|
int retv;
|
|
|
|
struct ieee80211req_res req;
|
|
|
|
struct ieee80211req_res_addts *addts = &req.u.addts;
|
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "%s", __func__);
|
|
|
|
req.type = IEEE80211_RESREQ_ADDTS;
|
|
|
|
os_memcpy(&req.macaddr[0], addr, IEEE80211_ADDR_LEN);
|
|
|
|
os_memcpy(addts->tspecie, tspec_ie, tspec_ielen);
|
|
|
|
retv = set80211priv(drv, IEEE80211_IOCTL_RES_REQ, &req,
|
|
|
|
sizeof(struct ieee80211req_res));
|
|
|
|
if (retv < 0) {
|
|
|
|
wpa_printf(MSG_DEBUG, "%s IEEE80211_IOCTL_RES_REQ FAILED "
|
|
|
|
"retv = %d", __func__, retv);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
os_memcpy(tspec_ie, addts->tspecie, tspec_ielen);
|
|
|
|
return addts->status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int atheros_add_sta_node(void *priv, const u8 *addr, u16 auth_alg)
|
|
|
|
{
|
|
|
|
struct atheros_driver_data *drv = priv;
|
|
|
|
struct ieee80211req_res req;
|
|
|
|
struct ieee80211req_res_addnode *addnode = &req.u.addnode;
|
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "%s", __func__);
|
|
|
|
req.type = IEEE80211_RESREQ_ADDNODE;
|
|
|
|
os_memcpy(&req.macaddr[0], addr, IEEE80211_ADDR_LEN);
|
|
|
|
addnode->auth_alg = auth_alg;
|
|
|
|
return set80211priv(drv, IEEE80211_IOCTL_RES_REQ, &req,
|
|
|
|
sizeof(struct ieee80211req_res));
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_IEEE80211R */
|
|
|
|
|
|
|
|
|
2011-09-08 19:52:23 +02:00
|
|
|
/* Use only to set a big param, get will not work. */
|
|
|
|
static int
|
|
|
|
set80211big(struct atheros_driver_data *drv, int op, const void *data, int len)
|
|
|
|
{
|
|
|
|
struct iwreq iwr;
|
|
|
|
|
|
|
|
os_memset(&iwr, 0, sizeof(iwr));
|
|
|
|
os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
|
|
|
|
|
|
|
|
iwr.u.data.pointer = (void *) data;
|
|
|
|
iwr.u.data.length = len;
|
|
|
|
iwr.u.data.flags = op;
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: op=0x%x=%d (%s) len=0x%x",
|
|
|
|
__func__, op, op, athr_get_param_name(op), len);
|
|
|
|
|
|
|
|
if (ioctl(drv->ioctl_sock, IEEE80211_IOCTL_P2P_BIG_PARAM, &iwr) < 0) {
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: op=0x%x (%s) subop=0x%x=%d "
|
|
|
|
"value=0x%x,0x%x failed: %d (%s)",
|
|
|
|
__func__, op, athr_get_ioctl_name(op), iwr.u.mode,
|
|
|
|
iwr.u.mode, iwr.u.data.length,
|
|
|
|
iwr.u.data.flags, errno, strerror(errno));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int atheros_send_action(void *priv, unsigned int freq,
|
|
|
|
unsigned int wait,
|
|
|
|
const u8 *dst, const u8 *src,
|
|
|
|
const u8 *bssid,
|
|
|
|
const u8 *data, size_t data_len, int no_cck)
|
|
|
|
{
|
|
|
|
struct atheros_driver_data *drv = priv;
|
|
|
|
struct ieee80211_p2p_send_action *act;
|
|
|
|
int res;
|
|
|
|
|
|
|
|
act = os_zalloc(sizeof(*act) + data_len);
|
|
|
|
if (act == NULL)
|
|
|
|
return -1;
|
|
|
|
act->freq = freq;
|
|
|
|
os_memcpy(act->dst_addr, dst, ETH_ALEN);
|
|
|
|
os_memcpy(act->src_addr, src, ETH_ALEN);
|
|
|
|
os_memcpy(act->bssid, bssid, ETH_ALEN);
|
|
|
|
os_memcpy(act + 1, data, data_len);
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: freq=%d, wait=%u, dst=" MACSTR ", src="
|
|
|
|
MACSTR ", bssid=" MACSTR,
|
|
|
|
__func__, act->freq, wait, MAC2STR(act->dst_addr),
|
|
|
|
MAC2STR(act->src_addr), MAC2STR(act->bssid));
|
|
|
|
wpa_hexdump(MSG_MSGDUMP, "athr: act", (u8 *) act, sizeof(*act));
|
|
|
|
wpa_hexdump(MSG_MSGDUMP, "athr: data", data, data_len);
|
|
|
|
|
|
|
|
res = set80211big(drv, IEEE80211_IOC_P2P_SEND_ACTION,
|
|
|
|
act, sizeof(*act) + data_len);
|
|
|
|
os_free(act);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-30 01:02:16 +02:00
|
|
|
#if defined(CONFIG_WNM) && defined(IEEE80211_APPIE_FRAME_WNM)
|
2012-02-26 16:28:42 +01:00
|
|
|
static int athr_wnm_tfs(struct atheros_driver_data *drv, const u8* peer,
|
|
|
|
u8 *ie, u16 *len, enum wnm_oper oper)
|
|
|
|
{
|
|
|
|
#define IEEE80211_APPIE_MAX 1024 /* max appie buffer size */
|
|
|
|
u8 buf[IEEE80211_APPIE_MAX];
|
|
|
|
struct ieee80211req_getset_appiebuf *tfs_ie;
|
|
|
|
u16 val;
|
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "atheros: ifname=%s, WNM TFS IE oper=%d " MACSTR,
|
|
|
|
drv->iface, oper, MAC2STR(peer));
|
|
|
|
|
|
|
|
switch (oper) {
|
|
|
|
case WNM_SLEEP_TFS_REQ_IE_SET:
|
|
|
|
if (*len > IEEE80211_APPIE_MAX -
|
|
|
|
sizeof(struct ieee80211req_getset_appiebuf)) {
|
|
|
|
wpa_printf(MSG_DEBUG, "TFS Req IE(s) too large");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
tfs_ie = (struct ieee80211req_getset_appiebuf *) buf;
|
|
|
|
tfs_ie->app_frmtype = IEEE80211_APPIE_FRAME_WNM;
|
|
|
|
tfs_ie->app_buflen = ETH_ALEN + 2 + 2 + *len;
|
|
|
|
|
|
|
|
/* Command header for driver */
|
|
|
|
os_memcpy(&(tfs_ie->app_buf[0]), peer, ETH_ALEN);
|
|
|
|
val = oper;
|
|
|
|
os_memcpy(&(tfs_ie->app_buf[0]) + ETH_ALEN, &val, 2);
|
|
|
|
val = *len;
|
|
|
|
os_memcpy(&(tfs_ie->app_buf[0]) + ETH_ALEN + 2, &val, 2);
|
|
|
|
|
|
|
|
/* copy the ie */
|
|
|
|
os_memcpy(&(tfs_ie->app_buf[0]) + ETH_ALEN + 2 + 2, ie, *len);
|
|
|
|
|
|
|
|
if (set80211priv(drv, IEEE80211_IOCTL_SET_APPIEBUF, tfs_ie,
|
|
|
|
IEEE80211_APPIE_MAX)) {
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: Failed to set WNM TFS IE: "
|
|
|
|
"%s", __func__, strerror(errno));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WNM_SLEEP_TFS_RESP_IE_ADD:
|
|
|
|
tfs_ie = (struct ieee80211req_getset_appiebuf *) buf;
|
|
|
|
tfs_ie->app_frmtype = IEEE80211_APPIE_FRAME_WNM;
|
|
|
|
tfs_ie->app_buflen = IEEE80211_APPIE_MAX -
|
|
|
|
sizeof(struct ieee80211req_getset_appiebuf);
|
|
|
|
/* Command header for driver */
|
|
|
|
os_memcpy(&(tfs_ie->app_buf[0]), peer, ETH_ALEN);
|
|
|
|
val = oper;
|
|
|
|
os_memcpy(&(tfs_ie->app_buf[0]) + ETH_ALEN, &val, 2);
|
|
|
|
val = 0;
|
|
|
|
os_memcpy(&(tfs_ie->app_buf[0]) + ETH_ALEN + 2, &val, 2);
|
|
|
|
|
|
|
|
if (set80211priv(drv, IEEE80211_IOCTL_GET_APPIEBUF, tfs_ie,
|
|
|
|
IEEE80211_APPIE_MAX)) {
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: Failed to get WNM TFS IE: "
|
|
|
|
"%s", __func__, strerror(errno));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
*len = tfs_ie->app_buflen;
|
|
|
|
os_memcpy(ie, &(tfs_ie->app_buf[0]), *len);
|
|
|
|
wpa_printf(MSG_DEBUG, "atheros: %c len=%d", tfs_ie->app_buf[0],
|
|
|
|
*len);
|
|
|
|
break;
|
|
|
|
case WNM_SLEEP_TFS_RESP_IE_NONE:
|
|
|
|
*len = 0;
|
|
|
|
break;
|
|
|
|
case WNM_SLEEP_TFS_IE_DEL:
|
|
|
|
tfs_ie = (struct ieee80211req_getset_appiebuf *) buf;
|
|
|
|
tfs_ie->app_frmtype = IEEE80211_APPIE_FRAME_WNM;
|
|
|
|
tfs_ie->app_buflen = IEEE80211_APPIE_MAX -
|
|
|
|
sizeof(struct ieee80211req_getset_appiebuf);
|
|
|
|
/* Command header for driver */
|
|
|
|
os_memcpy(&(tfs_ie->app_buf[0]), peer, ETH_ALEN);
|
|
|
|
val = oper;
|
|
|
|
os_memcpy(&(tfs_ie->app_buf[0]) + ETH_ALEN, &val, 2);
|
|
|
|
val = 0;
|
|
|
|
os_memcpy(&(tfs_ie->app_buf[0]) + ETH_ALEN + 2, &val, 2);
|
|
|
|
|
|
|
|
if (set80211priv(drv, IEEE80211_IOCTL_SET_APPIEBUF, tfs_ie,
|
|
|
|
IEEE80211_APPIE_MAX)) {
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: Failed to set WNM TFS IE: "
|
|
|
|
"%s", __func__, strerror(errno));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
wpa_printf(MSG_DEBUG, "Unsupported TFS oper %d", oper);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int atheros_wnm_sleep(struct atheros_driver_data *drv,
|
|
|
|
const u8 *peer, enum wnm_oper oper)
|
|
|
|
{
|
|
|
|
u8 *data, *pos;
|
|
|
|
size_t dlen;
|
|
|
|
int ret;
|
|
|
|
u16 val;
|
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "atheros: WNM-Sleep Oper %d, " MACSTR,
|
|
|
|
oper, MAC2STR(peer));
|
|
|
|
|
|
|
|
dlen = ETH_ALEN + 2 + 2;
|
|
|
|
data = os_malloc(dlen);
|
|
|
|
if (data == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* Command header for driver */
|
|
|
|
pos = data;
|
|
|
|
os_memcpy(pos, peer, ETH_ALEN);
|
|
|
|
pos += ETH_ALEN;
|
|
|
|
|
|
|
|
val = oper;
|
|
|
|
os_memcpy(pos, &val, 2);
|
|
|
|
pos += 2;
|
|
|
|
|
|
|
|
val = 0;
|
|
|
|
os_memcpy(pos, &val, 2);
|
|
|
|
|
|
|
|
ret = atheros_set_wps_ie(drv, data, dlen, IEEE80211_APPIE_FRAME_WNM);
|
|
|
|
|
|
|
|
os_free(data);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int atheros_wnm_oper(void *priv, enum wnm_oper oper, const u8 *peer,
|
|
|
|
u8 *buf, u16 *buf_len)
|
|
|
|
{
|
|
|
|
struct atheros_driver_data *drv = priv;
|
|
|
|
|
|
|
|
switch (oper) {
|
|
|
|
case WNM_SLEEP_ENTER_CONFIRM:
|
|
|
|
case WNM_SLEEP_ENTER_FAIL:
|
|
|
|
case WNM_SLEEP_EXIT_CONFIRM:
|
|
|
|
case WNM_SLEEP_EXIT_FAIL:
|
|
|
|
return atheros_wnm_sleep(drv, peer, oper);
|
|
|
|
case WNM_SLEEP_TFS_REQ_IE_SET:
|
|
|
|
case WNM_SLEEP_TFS_RESP_IE_ADD:
|
|
|
|
case WNM_SLEEP_TFS_RESP_IE_NONE:
|
|
|
|
case WNM_SLEEP_TFS_IE_DEL:
|
|
|
|
return athr_wnm_tfs(drv, peer, buf, buf_len, oper);
|
|
|
|
default:
|
|
|
|
wpa_printf(MSG_DEBUG, "atheros: Unsupported WNM operation %d",
|
|
|
|
oper);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
2013-08-30 01:02:16 +02:00
|
|
|
#endif /* CONFIG_WNM && IEEE80211_APPIE_FRAME_WNM */
|
2012-02-26 16:28:42 +01:00
|
|
|
|
|
|
|
|
2009-04-09 12:40:12 +02:00
|
|
|
const struct wpa_driver_ops wpa_driver_atheros_ops = {
|
2009-02-19 15:27:07 +01:00
|
|
|
.name = "atheros",
|
2010-12-20 11:35:57 +01:00
|
|
|
.hapd_init = atheros_init,
|
|
|
|
.hapd_deinit = atheros_deinit,
|
|
|
|
.set_ieee8021x = atheros_set_ieee8021x,
|
|
|
|
.set_privacy = atheros_set_privacy,
|
|
|
|
.set_key = atheros_set_key,
|
|
|
|
.get_seqnum = atheros_get_seqnum,
|
|
|
|
.flush = atheros_flush,
|
|
|
|
.set_generic_elem = atheros_set_opt_ie,
|
|
|
|
.sta_set_flags = atheros_sta_set_flags,
|
|
|
|
.read_sta_data = atheros_read_sta_driver_data,
|
|
|
|
.hapd_send_eapol = atheros_send_eapol,
|
|
|
|
.sta_disassoc = atheros_sta_disassoc,
|
|
|
|
.sta_deauth = atheros_sta_deauth,
|
|
|
|
.hapd_set_ssid = atheros_set_ssid,
|
|
|
|
.hapd_get_ssid = atheros_get_ssid,
|
|
|
|
.set_countermeasures = atheros_set_countermeasures,
|
|
|
|
.sta_clear_stats = atheros_sta_clear_stats,
|
|
|
|
.commit = atheros_commit,
|
|
|
|
.set_ap_wps_ie = atheros_set_ap_wps_ie,
|
2011-05-20 17:27:53 +02:00
|
|
|
.set_authmode = atheros_set_authmode,
|
2011-10-17 20:36:28 +02:00
|
|
|
.set_ap = atheros_set_ap,
|
2012-02-16 18:57:33 +01:00
|
|
|
#ifdef CONFIG_IEEE80211R
|
|
|
|
.sta_assoc = atheros_sta_assoc,
|
|
|
|
.sta_auth = atheros_sta_auth,
|
|
|
|
.send_mlme = atheros_send_mgmt,
|
|
|
|
.add_tspec = atheros_add_tspec,
|
|
|
|
.add_sta_node = atheros_add_sta_node,
|
|
|
|
#endif /* CONFIG_IEEE80211R */
|
2011-09-08 19:52:23 +02:00
|
|
|
.send_action = atheros_send_action,
|
2013-08-30 01:02:16 +02:00
|
|
|
#if defined(CONFIG_WNM) && defined(IEEE80211_APPIE_FRAME_WNM)
|
2012-02-26 16:28:42 +01:00
|
|
|
.wnm_oper = atheros_wnm_oper,
|
2013-08-30 01:02:16 +02:00
|
|
|
#endif /* CONFIG_WNM && IEEE80211_APPIE_FRAME_WNM */
|
2013-07-24 11:26:26 +02:00
|
|
|
.set_qos_map = atheros_set_qos_map,
|
2009-02-19 15:27:07 +01:00
|
|
|
};
|