2008-02-28 02:34:43 +01:00
|
|
|
/*
|
|
|
|
* WPA Supplicant - driver interaction with BSD net80211 layer
|
|
|
|
* Copyright (c) 2004, Sam Leffler <sam@errno.com>
|
2009-04-09 12:40:12 +02:00
|
|
|
* Copyright (c) 2004, 2Wire, Inc
|
2008-02-28 02:34:43 +01:00
|
|
|
*
|
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.
|
2008-02-28 02:34:43 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "includes.h"
|
|
|
|
#include <sys/ioctl.h>
|
2011-02-27 13:01:39 +01:00
|
|
|
#include <sys/sysctl.h>
|
2008-02-28 02:34:43 +01:00
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "driver.h"
|
|
|
|
#include "eloop.h"
|
2009-11-29 16:51:55 +01:00
|
|
|
#include "common/ieee802_11_defs.h"
|
2010-12-09 20:29:26 +01:00
|
|
|
#include "common/wpa_common.h"
|
2008-02-28 02:34:43 +01:00
|
|
|
|
|
|
|
#include <net/if.h>
|
2010-02-08 20:14:22 +01:00
|
|
|
#include <net/if_media.h>
|
2009-02-08 12:28:37 +01:00
|
|
|
|
|
|
|
#ifdef __NetBSD__
|
|
|
|
#include <net/if_ether.h>
|
|
|
|
#else
|
2008-02-28 02:34:43 +01:00
|
|
|
#include <net/ethernet.h>
|
2009-02-08 12:28:37 +01:00
|
|
|
#endif
|
2009-05-21 10:21:09 +02:00
|
|
|
#include <net/route.h>
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2009-10-12 08:56:57 +02:00
|
|
|
#ifdef __DragonFly__
|
|
|
|
#include <netproto/802_11/ieee80211_ioctl.h>
|
|
|
|
#include <netproto/802_11/ieee80211_dragonfly.h>
|
|
|
|
#else /* __DragonFly__ */
|
2010-03-06 09:16:47 +01:00
|
|
|
#ifdef __GLIBC__
|
|
|
|
#include <netinet/ether.h>
|
|
|
|
#endif /* __GLIBC__ */
|
2008-02-28 02:34:43 +01:00
|
|
|
#include <net80211/ieee80211.h>
|
|
|
|
#include <net80211/ieee80211_ioctl.h>
|
2010-01-09 10:04:44 +01:00
|
|
|
#include <net80211/ieee80211_crypto.h>
|
2010-03-06 09:16:47 +01:00
|
|
|
#endif /* __DragonFly__ || __GLIBC__ */
|
|
|
|
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
2009-05-21 10:21:09 +02:00
|
|
|
#include <net80211/ieee80211_freebsd.h>
|
|
|
|
#endif
|
|
|
|
#if __NetBSD__
|
|
|
|
#include <net80211/ieee80211_netbsd.h>
|
|
|
|
#endif
|
|
|
|
|
2010-02-08 20:33:59 +01:00
|
|
|
#include "l2_packet/l2_packet.h"
|
|
|
|
|
2016-01-09 02:39:43 +01:00
|
|
|
struct bsd_driver_global {
|
2016-03-15 14:02:08 +01:00
|
|
|
void *ctx;
|
2016-01-09 02:39:43 +01:00
|
|
|
int sock; /* socket for 802.11 ioctls */
|
|
|
|
int route; /* routing socket for events */
|
|
|
|
char *event_buf;
|
|
|
|
size_t event_buf_len;
|
|
|
|
struct dl_list ifaces; /* list of interfaces */
|
|
|
|
};
|
|
|
|
|
2010-02-13 12:50:19 +01:00
|
|
|
struct bsd_driver_data {
|
2016-01-09 02:39:43 +01:00
|
|
|
struct dl_list list;
|
|
|
|
struct bsd_driver_global *global;
|
2020-01-28 17:58:26 +01:00
|
|
|
void *ctx;
|
2010-02-13 12:50:19 +01:00
|
|
|
|
|
|
|
struct l2_packet_data *sock_xmit;/* raw packet xmit socket */
|
|
|
|
char ifname[IFNAMSIZ+1]; /* interface name */
|
2016-01-19 18:48:01 +01:00
|
|
|
int flags;
|
2010-02-13 12:50:19 +01:00
|
|
|
unsigned int ifindex; /* interface index */
|
2016-03-15 14:02:08 +01:00
|
|
|
int if_removed; /* has the interface been removed? */
|
2010-02-13 12:50:19 +01:00
|
|
|
struct wpa_driver_capa capa; /* driver capability */
|
|
|
|
int is_ap; /* Access point mode */
|
|
|
|
int prev_roaming; /* roaming state to restore on deinit */
|
|
|
|
int prev_privacy; /* privacy state to restore on deinit */
|
|
|
|
int prev_wpa; /* wpa state to restore on deinit */
|
2013-08-07 09:57:10 +02:00
|
|
|
enum ieee80211_opmode opmode; /* operation mode */
|
2010-02-13 12:50:19 +01:00
|
|
|
};
|
|
|
|
|
2009-05-29 21:38:55 +02:00
|
|
|
/* Generic functions for hostapd and wpa_supplicant */
|
|
|
|
|
2016-01-09 02:39:43 +01:00
|
|
|
static struct bsd_driver_data *
|
|
|
|
bsd_get_drvindex(void *priv, unsigned int ifindex)
|
|
|
|
{
|
|
|
|
struct bsd_driver_global *global = priv;
|
|
|
|
struct bsd_driver_data *drv;
|
|
|
|
|
|
|
|
dl_list_for_each(drv, &global->ifaces, struct bsd_driver_data, list) {
|
|
|
|
if (drv->ifindex == ifindex)
|
|
|
|
return drv;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-03-15 14:02:08 +01:00
|
|
|
#ifndef HOSTAPD
|
|
|
|
static struct bsd_driver_data *
|
|
|
|
bsd_get_drvname(void *priv, const char *ifname)
|
|
|
|
{
|
|
|
|
struct bsd_driver_global *global = priv;
|
|
|
|
struct bsd_driver_data *drv;
|
|
|
|
|
|
|
|
dl_list_for_each(drv, &global->ifaces, struct bsd_driver_data, list) {
|
|
|
|
if (os_strcmp(drv->ifname, ifname) == 0)
|
|
|
|
return drv;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#endif /* HOSTAPD */
|
|
|
|
|
2009-05-29 21:38:55 +02:00
|
|
|
static int
|
2010-02-13 12:59:29 +01:00
|
|
|
bsd_set80211(void *priv, int op, int val, const void *arg, int arg_len)
|
2009-05-29 21:38:55 +02:00
|
|
|
{
|
2010-02-13 12:59:29 +01:00
|
|
|
struct bsd_driver_data *drv = priv;
|
2009-05-29 21:38:55 +02:00
|
|
|
struct ieee80211req ireq;
|
|
|
|
|
2016-03-15 14:02:08 +01:00
|
|
|
if (drv->ifindex == 0 || drv->if_removed)
|
2016-01-20 18:13:12 +01:00
|
|
|
return -1;
|
|
|
|
|
2009-05-29 21:38:55 +02:00
|
|
|
os_memset(&ireq, 0, sizeof(ireq));
|
2010-02-13 12:59:29 +01:00
|
|
|
os_strlcpy(ireq.i_name, drv->ifname, sizeof(ireq.i_name));
|
2009-05-29 21:38:55 +02:00
|
|
|
ireq.i_type = op;
|
2010-02-13 12:59:29 +01:00
|
|
|
ireq.i_val = val;
|
2009-05-29 21:38:55 +02:00
|
|
|
ireq.i_data = (void *) arg;
|
2010-02-13 12:59:29 +01:00
|
|
|
ireq.i_len = arg_len;
|
2009-05-29 21:38:55 +02:00
|
|
|
|
2016-01-09 02:39:43 +01:00
|
|
|
if (ioctl(drv->global->sock, SIOCS80211, &ireq) < 0) {
|
2010-02-13 12:59:29 +01:00
|
|
|
wpa_printf(MSG_ERROR, "ioctl[SIOCS80211, op=%u, val=%u, "
|
|
|
|
"arg_len=%u]: %s", op, val, arg_len,
|
|
|
|
strerror(errno));
|
2009-05-29 21:38:55 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-02-13 12:59:29 +01:00
|
|
|
bsd_get80211(void *priv, struct ieee80211req *ireq, int op, void *arg,
|
|
|
|
int arg_len)
|
2009-05-29 21:38:55 +02:00
|
|
|
{
|
2010-02-13 12:59:29 +01:00
|
|
|
struct bsd_driver_data *drv = priv;
|
2009-05-29 21:38:55 +02:00
|
|
|
|
2010-02-13 12:59:29 +01:00
|
|
|
os_memset(ireq, 0, sizeof(*ireq));
|
|
|
|
os_strlcpy(ireq->i_name, drv->ifname, sizeof(ireq->i_name));
|
|
|
|
ireq->i_type = op;
|
|
|
|
ireq->i_len = arg_len;
|
|
|
|
ireq->i_data = arg;
|
2009-05-29 21:38:55 +02:00
|
|
|
|
2016-01-09 02:39:43 +01:00
|
|
|
if (ioctl(drv->global->sock, SIOCG80211, ireq) < 0) {
|
2019-04-13 02:50:56 +02:00
|
|
|
wpa_printf(MSG_ERROR, "ioctl[SIOCG80211, op=%u, "
|
2010-02-13 12:59:29 +01:00
|
|
|
"arg_len=%u]: %s", op, arg_len, strerror(errno));
|
2009-05-29 21:38:55 +02:00
|
|
|
return -1;
|
|
|
|
}
|
2010-02-13 12:59:29 +01:00
|
|
|
return 0;
|
2009-05-29 21:38:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-02-13 12:59:29 +01:00
|
|
|
get80211var(struct bsd_driver_data *drv, int op, void *arg, int arg_len)
|
2009-05-29 21:38:55 +02:00
|
|
|
{
|
|
|
|
struct ieee80211req ireq;
|
|
|
|
|
2010-02-13 12:59:29 +01:00
|
|
|
if (bsd_get80211(drv, &ireq, op, arg, arg_len) < 0)
|
2009-05-29 21:38:55 +02:00
|
|
|
return -1;
|
2010-02-13 12:59:29 +01:00
|
|
|
return ireq.i_len;
|
2010-02-13 12:52:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
set80211var(struct bsd_driver_data *drv, int op, const void *arg, int arg_len)
|
2009-05-29 21:38:55 +02:00
|
|
|
{
|
2010-02-13 12:59:29 +01:00
|
|
|
return bsd_set80211(drv, op, 0, arg, arg_len);
|
2010-02-13 12:52:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
set80211param(struct bsd_driver_data *drv, int op, int arg)
|
|
|
|
{
|
2010-02-13 12:59:29 +01:00
|
|
|
return bsd_set80211(drv, op, arg, NULL, 0);
|
2010-02-13 12:52:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-03-07 10:36:45 +01:00
|
|
|
bsd_get_ssid(void *priv, u8 *ssid, int len)
|
2010-02-13 12:52:03 +01:00
|
|
|
{
|
|
|
|
struct bsd_driver_data *drv = priv;
|
2009-05-29 21:38:55 +02:00
|
|
|
#ifdef SIOCG80211NWID
|
|
|
|
struct ieee80211_nwid nwid;
|
|
|
|
struct ifreq ifr;
|
|
|
|
|
|
|
|
os_memset(&ifr, 0, sizeof(ifr));
|
2010-02-13 12:52:03 +01:00
|
|
|
os_strlcpy(ifr.ifr_name, drv->ifname, sizeof(ifr.ifr_name));
|
2009-05-29 21:38:55 +02:00
|
|
|
ifr.ifr_data = (void *)&nwid;
|
2016-01-09 02:39:43 +01:00
|
|
|
if (ioctl(drv->global->sock, SIOCG80211NWID, &ifr) < 0 ||
|
2009-05-29 21:38:55 +02:00
|
|
|
nwid.i_len > IEEE80211_NWID_LEN)
|
|
|
|
return -1;
|
|
|
|
os_memcpy(ssid, nwid.i_nwid, nwid.i_len);
|
|
|
|
return nwid.i_len;
|
|
|
|
#else
|
2010-02-13 12:52:03 +01:00
|
|
|
return get80211var(drv, IEEE80211_IOC_SSID, ssid, IEEE80211_NWID_LEN);
|
2009-05-29 21:38:55 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-03-07 10:36:45 +01:00
|
|
|
bsd_set_ssid(void *priv, const u8 *ssid, int ssid_len)
|
2009-05-29 21:38:55 +02:00
|
|
|
{
|
2010-02-13 12:52:03 +01:00
|
|
|
struct bsd_driver_data *drv = priv;
|
2009-05-29 21:38:55 +02:00
|
|
|
#ifdef SIOCS80211NWID
|
|
|
|
struct ieee80211_nwid nwid;
|
|
|
|
struct ifreq ifr;
|
|
|
|
|
|
|
|
os_memcpy(nwid.i_nwid, ssid, ssid_len);
|
|
|
|
nwid.i_len = ssid_len;
|
|
|
|
os_memset(&ifr, 0, sizeof(ifr));
|
2010-02-13 12:52:03 +01:00
|
|
|
os_strlcpy(ifr.ifr_name, drv->ifname, sizeof(ifr.ifr_name));
|
2009-05-29 21:38:55 +02:00
|
|
|
ifr.ifr_data = (void *)&nwid;
|
2016-01-09 02:39:43 +01:00
|
|
|
return ioctl(drv->global->sock, SIOCS80211NWID, &ifr);
|
2009-05-29 21:38:55 +02:00
|
|
|
#else
|
2010-02-13 12:52:03 +01:00
|
|
|
return set80211var(drv, IEEE80211_IOC_SSID, ssid, ssid_len);
|
2009-05-29 21:38:55 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-02-08 20:14:22 +01:00
|
|
|
static int
|
2010-02-13 12:52:03 +01:00
|
|
|
bsd_get_if_media(void *priv)
|
2010-02-08 20:14:22 +01:00
|
|
|
{
|
2010-02-13 12:52:03 +01:00
|
|
|
struct bsd_driver_data *drv = priv;
|
2010-02-08 20:14:22 +01:00
|
|
|
struct ifmediareq ifmr;
|
|
|
|
|
|
|
|
os_memset(&ifmr, 0, sizeof(ifmr));
|
2010-02-13 12:52:03 +01:00
|
|
|
os_strlcpy(ifmr.ifm_name, drv->ifname, sizeof(ifmr.ifm_name));
|
2010-02-08 20:14:22 +01:00
|
|
|
|
2016-01-09 02:39:43 +01:00
|
|
|
if (ioctl(drv->global->sock, SIOCGIFMEDIA, &ifmr) < 0) {
|
2010-02-08 20:14:22 +01:00
|
|
|
wpa_printf(MSG_ERROR, "%s: SIOCGIFMEDIA %s", __func__,
|
|
|
|
strerror(errno));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ifmr.ifm_current;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-02-13 12:52:03 +01:00
|
|
|
bsd_set_if_media(void *priv, int media)
|
2010-02-08 20:14:22 +01:00
|
|
|
{
|
2010-02-13 12:52:03 +01:00
|
|
|
struct bsd_driver_data *drv = priv;
|
2010-02-08 20:14:22 +01:00
|
|
|
struct ifreq ifr;
|
|
|
|
|
|
|
|
os_memset(&ifr, 0, sizeof(ifr));
|
2010-02-13 12:52:03 +01:00
|
|
|
os_strlcpy(ifr.ifr_name, drv->ifname, sizeof(ifr.ifr_name));
|
2010-02-08 20:14:22 +01:00
|
|
|
ifr.ifr_media = media;
|
|
|
|
|
2016-01-09 02:39:43 +01:00
|
|
|
if (ioctl(drv->global->sock, SIOCSIFMEDIA, &ifr) < 0) {
|
2010-02-08 20:14:22 +01:00
|
|
|
wpa_printf(MSG_ERROR, "%s: SIOCSIFMEDIA %s", __func__,
|
|
|
|
strerror(errno));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-02-13 12:52:03 +01:00
|
|
|
bsd_set_mediaopt(void *priv, uint32_t mask, uint32_t mode)
|
2010-02-08 20:14:22 +01:00
|
|
|
{
|
2010-02-13 12:52:03 +01:00
|
|
|
int media = bsd_get_if_media(priv);
|
2010-02-08 20:14:22 +01:00
|
|
|
|
|
|
|
if (media < 0)
|
|
|
|
return -1;
|
|
|
|
media &= ~mask;
|
|
|
|
media |= mode;
|
2010-02-13 12:52:03 +01:00
|
|
|
if (bsd_set_if_media(priv, media) < 0)
|
2010-02-08 20:14:22 +01:00
|
|
|
return -1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-02-08 20:18:09 +01:00
|
|
|
static int
|
2010-02-13 12:52:03 +01:00
|
|
|
bsd_del_key(void *priv, const u8 *addr, int key_idx)
|
2010-02-08 20:18:09 +01:00
|
|
|
{
|
|
|
|
struct ieee80211req_del_key wk;
|
|
|
|
|
|
|
|
os_memset(&wk, 0, sizeof(wk));
|
|
|
|
if (addr == NULL) {
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: key_idx=%d", __func__, key_idx);
|
|
|
|
wk.idk_keyix = key_idx;
|
|
|
|
} else {
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: addr=" MACSTR, __func__,
|
|
|
|
MAC2STR(addr));
|
|
|
|
os_memcpy(wk.idk_macaddr, addr, IEEE80211_ADDR_LEN);
|
|
|
|
wk.idk_keyix = (u_int8_t) IEEE80211_KEYIX_NONE; /* XXX */
|
|
|
|
}
|
|
|
|
|
2010-02-13 12:52:03 +01:00
|
|
|
return set80211var(priv, IEEE80211_IOC_DELKEY, &wk, sizeof(wk));
|
2010-02-08 20:18:09 +01:00
|
|
|
}
|
|
|
|
|
2010-02-08 20:21:23 +01:00
|
|
|
static int
|
2010-02-13 12:52:03 +01:00
|
|
|
bsd_send_mlme_param(void *priv, const u8 op, const u16 reason, const u8 *addr)
|
2010-02-08 20:21:23 +01:00
|
|
|
{
|
|
|
|
struct ieee80211req_mlme mlme;
|
|
|
|
|
|
|
|
os_memset(&mlme, 0, sizeof(mlme));
|
|
|
|
mlme.im_op = op;
|
|
|
|
mlme.im_reason = reason;
|
|
|
|
os_memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
|
2010-02-13 12:52:03 +01:00
|
|
|
return set80211var(priv, IEEE80211_IOC_MLME, &mlme, sizeof(mlme));
|
2010-02-08 20:21:23 +01:00
|
|
|
}
|
|
|
|
|
2010-02-08 20:23:28 +01:00
|
|
|
static int
|
2010-02-13 12:52:03 +01:00
|
|
|
bsd_ctrl_iface(void *priv, int enable)
|
2010-02-08 20:23:28 +01:00
|
|
|
{
|
2010-02-13 12:52:03 +01:00
|
|
|
struct bsd_driver_data *drv = priv;
|
2010-02-08 20:23:28 +01:00
|
|
|
struct ifreq ifr;
|
|
|
|
|
|
|
|
os_memset(&ifr, 0, sizeof(ifr));
|
2010-02-13 12:52:03 +01:00
|
|
|
os_strlcpy(ifr.ifr_name, drv->ifname, sizeof(ifr.ifr_name));
|
2010-02-08 20:23:28 +01:00
|
|
|
|
2016-01-09 02:39:43 +01:00
|
|
|
if (ioctl(drv->global->sock, SIOCGIFFLAGS, &ifr) < 0) {
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_ERROR, "ioctl[SIOCGIFFLAGS]: %s",
|
|
|
|
strerror(errno));
|
2010-02-08 20:23:28 +01:00
|
|
|
return -1;
|
|
|
|
}
|
2016-01-19 18:48:01 +01:00
|
|
|
drv->flags = ifr.ifr_flags;
|
2010-02-08 20:23:28 +01:00
|
|
|
|
2013-08-07 09:54:16 +02:00
|
|
|
if (enable) {
|
|
|
|
if (ifr.ifr_flags & IFF_UP)
|
|
|
|
return 0;
|
2010-02-08 20:23:28 +01:00
|
|
|
ifr.ifr_flags |= IFF_UP;
|
2013-08-07 09:54:16 +02:00
|
|
|
} else {
|
|
|
|
if (!(ifr.ifr_flags & IFF_UP))
|
|
|
|
return 0;
|
2010-02-08 20:23:28 +01:00
|
|
|
ifr.ifr_flags &= ~IFF_UP;
|
2013-08-07 09:54:16 +02:00
|
|
|
}
|
2010-02-08 20:23:28 +01:00
|
|
|
|
2016-01-09 02:39:43 +01:00
|
|
|
if (ioctl(drv->global->sock, SIOCSIFFLAGS, &ifr) < 0) {
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_ERROR, "ioctl[SIOCSIFFLAGS]: %s",
|
|
|
|
strerror(errno));
|
2010-02-08 20:23:28 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-01-19 18:48:01 +01:00
|
|
|
drv->flags = ifr.ifr_flags;
|
2010-02-08 20:23:28 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-02-08 20:25:18 +01:00
|
|
|
static int
|
2020-01-08 21:15:18 +01:00
|
|
|
bsd_set_key(void *priv, struct wpa_driver_set_key_params *params)
|
2010-02-08 20:25:18 +01:00
|
|
|
{
|
|
|
|
struct ieee80211req_key wk;
|
2013-11-26 03:43:37 +01:00
|
|
|
#ifdef IEEE80211_KEY_NOREPLAY
|
2013-08-07 09:57:10 +02:00
|
|
|
struct bsd_driver_data *drv = priv;
|
2013-11-26 03:43:37 +01:00
|
|
|
#endif /* IEEE80211_KEY_NOREPLAY */
|
2020-01-08 21:15:18 +01:00
|
|
|
enum wpa_alg alg = params->alg;
|
|
|
|
const u8 *addr = params->addr;
|
|
|
|
int key_idx = params->key_idx;
|
|
|
|
int set_tx = params->set_tx;
|
|
|
|
const u8 *seq = params->seq;
|
|
|
|
size_t seq_len = params->seq_len;
|
|
|
|
const u8 *key = params->key;
|
|
|
|
size_t key_len = params->key_len;
|
2010-02-08 20:25:18 +01:00
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: alg=%d addr=%p key_idx=%d set_tx=%d "
|
|
|
|
"seq_len=%zu key_len=%zu", __func__, alg, addr, key_idx,
|
|
|
|
set_tx, seq_len, key_len);
|
|
|
|
|
2010-02-13 12:52:03 +01:00
|
|
|
if (alg == WPA_ALG_NONE) {
|
|
|
|
#ifndef HOSTAPD
|
2011-01-09 18:44:28 +01:00
|
|
|
if (addr == NULL || is_broadcast_ether_addr(addr))
|
2010-02-13 12:52:03 +01:00
|
|
|
return bsd_del_key(priv, NULL, key_idx);
|
|
|
|
else
|
|
|
|
#endif /* HOSTAPD */
|
|
|
|
return bsd_del_key(priv, addr, key_idx);
|
|
|
|
}
|
|
|
|
|
2010-02-08 20:25:18 +01:00
|
|
|
os_memset(&wk, 0, sizeof(wk));
|
|
|
|
switch (alg) {
|
|
|
|
case WPA_ALG_WEP:
|
|
|
|
wk.ik_type = IEEE80211_CIPHER_WEP;
|
|
|
|
break;
|
|
|
|
case WPA_ALG_TKIP:
|
|
|
|
wk.ik_type = IEEE80211_CIPHER_TKIP;
|
|
|
|
break;
|
|
|
|
case WPA_ALG_CCMP:
|
|
|
|
wk.ik_type = IEEE80211_CIPHER_AES_CCM;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
wpa_printf(MSG_ERROR, "%s: unknown alg=%d", __func__, alg);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
wk.ik_flags = IEEE80211_KEY_RECV;
|
|
|
|
if (set_tx)
|
|
|
|
wk.ik_flags |= IEEE80211_KEY_XMIT;
|
|
|
|
|
|
|
|
if (addr == NULL) {
|
|
|
|
os_memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN);
|
|
|
|
wk.ik_keyix = key_idx;
|
|
|
|
} else {
|
|
|
|
os_memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
|
|
|
|
/*
|
|
|
|
* Deduce whether group/global or unicast key by checking
|
|
|
|
* the address (yech). Note also that we can only mark global
|
|
|
|
* keys default; doing this for a unicast key is an error.
|
|
|
|
*/
|
2011-01-09 18:44:28 +01:00
|
|
|
if (is_broadcast_ether_addr(addr)) {
|
2010-02-08 20:25:18 +01:00
|
|
|
wk.ik_flags |= IEEE80211_KEY_GROUP;
|
|
|
|
wk.ik_keyix = key_idx;
|
|
|
|
} else {
|
|
|
|
wk.ik_keyix = key_idx == 0 ? IEEE80211_KEYIX_NONE :
|
|
|
|
key_idx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (wk.ik_keyix != IEEE80211_KEYIX_NONE && set_tx)
|
|
|
|
wk.ik_flags |= IEEE80211_KEY_DEFAULT;
|
2013-08-07 09:57:10 +02:00
|
|
|
#ifndef HOSTAPD
|
2013-11-26 03:43:37 +01:00
|
|
|
#ifdef IEEE80211_KEY_NOREPLAY
|
2013-08-07 09:57:10 +02:00
|
|
|
/*
|
|
|
|
* Ignore replay failures in IBSS and AHDEMO mode.
|
|
|
|
*/
|
|
|
|
if (drv->opmode == IEEE80211_M_IBSS ||
|
|
|
|
drv->opmode == IEEE80211_M_AHDEMO)
|
|
|
|
wk.ik_flags |= IEEE80211_KEY_NOREPLAY;
|
2013-11-26 03:43:37 +01:00
|
|
|
#endif /* IEEE80211_KEY_NOREPLAY */
|
2013-08-07 09:57:10 +02:00
|
|
|
#endif /* HOSTAPD */
|
2010-02-08 20:25:18 +01:00
|
|
|
wk.ik_keylen = key_len;
|
2011-06-23 14:47:21 +02:00
|
|
|
if (seq) {
|
|
|
|
#ifdef WORDS_BIGENDIAN
|
|
|
|
/*
|
|
|
|
* wk.ik_keyrsc is in host byte order (big endian), need to
|
|
|
|
* swap it to match with the byte order used in WPA.
|
|
|
|
*/
|
|
|
|
int i;
|
|
|
|
u8 *keyrsc = (u8 *) &wk.ik_keyrsc;
|
|
|
|
for (i = 0; i < seq_len; i++)
|
|
|
|
keyrsc[WPA_KEY_RSC_LEN - i - 1] = seq[i];
|
|
|
|
#else /* WORDS_BIGENDIAN */
|
2011-01-09 11:09:04 +01:00
|
|
|
os_memcpy(&wk.ik_keyrsc, seq, seq_len);
|
2011-06-23 14:47:21 +02:00
|
|
|
#endif /* WORDS_BIGENDIAN */
|
|
|
|
}
|
2010-02-08 20:25:18 +01:00
|
|
|
os_memcpy(wk.ik_keydata, key, key_len);
|
|
|
|
|
2010-02-13 12:52:03 +01:00
|
|
|
return set80211var(priv, IEEE80211_IOC_WPAKEY, &wk, sizeof(wk));
|
2010-02-08 20:25:18 +01:00
|
|
|
}
|
|
|
|
|
2009-04-09 12:40:12 +02:00
|
|
|
static int
|
2010-02-13 12:52:03 +01:00
|
|
|
bsd_configure_wpa(void *priv, struct wpa_bss_params *params)
|
2009-04-09 12:40:12 +02:00
|
|
|
{
|
2010-02-13 12:57:39 +01:00
|
|
|
#ifndef IEEE80211_IOC_APPIE
|
2009-04-09 12:40:12 +02:00
|
|
|
static const char *ciphernames[] =
|
|
|
|
{ "WEP", "TKIP", "AES-OCB", "AES-CCM", "CKIP", "NONE" };
|
|
|
|
int v;
|
|
|
|
|
2009-12-12 22:50:29 +01:00
|
|
|
switch (params->wpa_group) {
|
2009-04-09 12:40:12 +02:00
|
|
|
case WPA_CIPHER_CCMP:
|
|
|
|
v = IEEE80211_CIPHER_AES_CCM;
|
|
|
|
break;
|
|
|
|
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:
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_INFO, "Unknown group key cipher %u",
|
|
|
|
params->wpa_group);
|
2009-04-09 12:40:12 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: group key cipher=%s (%u)",
|
|
|
|
__func__, ciphernames[v], v);
|
2010-02-13 12:52:03 +01:00
|
|
|
if (set80211param(priv, IEEE80211_IOC_MCASTCIPHER, v)) {
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_INFO,
|
|
|
|
"Unable to set group key cipher to %u (%s)",
|
|
|
|
v, ciphernames[v]);
|
2009-04-09 12:40:12 +02: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);
|
2010-02-13 12:52:03 +01:00
|
|
|
if (set80211param(priv, IEEE80211_IOC_MCASTKEYLEN, v)) {
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_INFO,
|
|
|
|
"Unable to set group key length to %u", v);
|
2009-04-09 12:40:12 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
v = 0;
|
2009-12-12 22:50:29 +01:00
|
|
|
if (params->wpa_pairwise & WPA_CIPHER_CCMP)
|
2009-04-09 12:40:12 +02:00
|
|
|
v |= 1<<IEEE80211_CIPHER_AES_CCM;
|
2009-12-12 22:50:29 +01:00
|
|
|
if (params->wpa_pairwise & WPA_CIPHER_TKIP)
|
2009-04-09 12:40:12 +02:00
|
|
|
v |= 1<<IEEE80211_CIPHER_TKIP;
|
2009-12-12 22:50:29 +01:00
|
|
|
if (params->wpa_pairwise & WPA_CIPHER_NONE)
|
2009-04-09 12:40:12 +02:00
|
|
|
v |= 1<<IEEE80211_CIPHER_NONE;
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: pairwise key ciphers=0x%x", __func__, v);
|
2010-02-13 12:52:03 +01:00
|
|
|
if (set80211param(priv, IEEE80211_IOC_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-04-09 12:40:12 +02: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);
|
2010-02-13 12:52:03 +01:00
|
|
|
if (set80211param(priv, IEEE80211_IOC_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-04-09 12:40:12 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
v = 0;
|
2009-12-12 22:50:29 +01:00
|
|
|
if (params->rsn_preauth)
|
2009-04-09 12:40:12 +02:00
|
|
|
v |= BIT(0);
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: rsn capabilities=0x%x",
|
2009-12-12 22:50:29 +01:00
|
|
|
__func__, params->rsn_preauth);
|
2010-02-13 12:52:03 +01:00
|
|
|
if (set80211param(priv, IEEE80211_IOC_RSNCAPS, v)) {
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_INFO, "Unable to set RSN capabilities to 0x%x",
|
|
|
|
v);
|
2009-04-09 12:40:12 +02:00
|
|
|
return -1;
|
|
|
|
}
|
2010-02-13 12:57:39 +01:00
|
|
|
#endif /* IEEE80211_IOC_APPIE */
|
2009-04-09 12:40:12 +02:00
|
|
|
|
2009-12-12 22:50:29 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "%s: enable WPA= 0x%x", __func__, params->wpa);
|
2010-02-13 12:52:03 +01:00
|
|
|
if (set80211param(priv, IEEE80211_IOC_WPA, params->wpa)) {
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_INFO, "Unable to set WPA to %u", params->wpa);
|
2009-04-09 12:40:12 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-02-13 12:52:03 +01:00
|
|
|
bsd_set_ieee8021x(void *priv, struct wpa_bss_params *params)
|
2009-04-09 12:40:12 +02:00
|
|
|
{
|
2009-12-12 22:50:29 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "%s: enabled=%d", __func__, params->enabled);
|
2009-04-09 12:40:12 +02:00
|
|
|
|
2009-12-12 22:50:29 +01:00
|
|
|
if (!params->enabled) {
|
2009-04-09 12:40:12 +02:00
|
|
|
/* XXX restore state */
|
2010-02-13 12:52:03 +01:00
|
|
|
return set80211param(priv, IEEE80211_IOC_AUTHMODE,
|
|
|
|
IEEE80211_AUTH_AUTO);
|
2009-04-09 12:40:12 +02:00
|
|
|
}
|
2009-12-12 22:50:29 +01:00
|
|
|
if (!params->wpa && !params->ieee802_1x) {
|
2010-02-08 20:33:59 +01:00
|
|
|
wpa_printf(MSG_ERROR, "%s: No 802.1X or WPA enabled",
|
|
|
|
__func__);
|
2009-04-09 12:40:12 +02:00
|
|
|
return -1;
|
|
|
|
}
|
2010-02-13 12:52:03 +01:00
|
|
|
if (params->wpa && bsd_configure_wpa(priv, params) != 0) {
|
2010-02-08 20:33:59 +01:00
|
|
|
wpa_printf(MSG_ERROR, "%s: Failed to configure WPA state",
|
|
|
|
__func__);
|
2009-04-09 12:40:12 +02:00
|
|
|
return -1;
|
|
|
|
}
|
2010-02-13 12:52:03 +01:00
|
|
|
if (set80211param(priv, IEEE80211_IOC_AUTHMODE,
|
2009-12-12 22:50:29 +01:00
|
|
|
(params->wpa ? IEEE80211_AUTH_WPA : IEEE80211_AUTH_8021X))) {
|
2010-02-08 20:33:59 +01:00
|
|
|
wpa_printf(MSG_ERROR, "%s: Failed to enable WPA/802.1X",
|
|
|
|
__func__);
|
2009-04-09 12:40:12 +02:00
|
|
|
return -1;
|
|
|
|
}
|
2010-02-13 12:52:03 +01:00
|
|
|
return bsd_ctrl_iface(priv, 1);
|
2009-04-09 12:40:12 +02:00
|
|
|
}
|
|
|
|
|
2010-02-08 20:33:59 +01:00
|
|
|
static void
|
2010-02-13 12:52:03 +01:00
|
|
|
bsd_new_sta(void *priv, void *ctx, u8 addr[IEEE80211_ADDR_LEN])
|
2010-02-08 20:33:59 +01:00
|
|
|
{
|
|
|
|
struct ieee80211req_wpaie ie;
|
|
|
|
int ielen = 0;
|
|
|
|
u8 *iebuf = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fetch and validate any negotiated WPA/RSN parameters.
|
|
|
|
*/
|
|
|
|
memset(&ie, 0, sizeof(ie));
|
|
|
|
memcpy(ie.wpa_macaddr, addr, IEEE80211_ADDR_LEN);
|
2010-02-13 12:52:03 +01:00
|
|
|
if (get80211var(priv, IEEE80211_IOC_WPAIE, &ie, sizeof(ie)) < 0) {
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_INFO,
|
|
|
|
"Failed to get WPA/RSN information element");
|
2010-02-08 20:33:59 +01:00
|
|
|
goto no_ie;
|
|
|
|
}
|
|
|
|
iebuf = ie.wpa_ie;
|
|
|
|
ielen = ie.wpa_ie[1];
|
|
|
|
if (ielen == 0)
|
|
|
|
iebuf = NULL;
|
|
|
|
else
|
|
|
|
ielen += 2;
|
|
|
|
|
|
|
|
no_ie:
|
2010-10-25 12:50:34 +02:00
|
|
|
drv_event_assoc(ctx, addr, iebuf, ielen, 0);
|
2010-02-08 20:33:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-02-13 12:52:03 +01:00
|
|
|
bsd_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)
|
2010-02-08 20:33:59 +01:00
|
|
|
{
|
2010-02-13 12:52:03 +01:00
|
|
|
struct bsd_driver_data *drv = priv;
|
|
|
|
|
2010-02-08 20:33:59 +01:00
|
|
|
wpa_hexdump(MSG_MSGDUMP, "TX EAPOL", data, data_len);
|
|
|
|
|
2010-02-13 12:52:03 +01:00
|
|
|
return l2_packet_send(drv->sock_xmit, addr, ETH_P_EAPOL, data,
|
|
|
|
data_len);
|
2009-04-09 12:40:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-05-23 11:20:33 +02:00
|
|
|
bsd_set_freq(void *priv, struct hostapd_freq_params *freq)
|
2010-02-08 20:33:59 +01:00
|
|
|
{
|
2010-02-13 12:52:03 +01:00
|
|
|
struct bsd_driver_data *drv = priv;
|
2010-02-08 20:41:51 +01:00
|
|
|
#ifdef SIOCS80211CHANNEL
|
2010-02-08 20:33:59 +01:00
|
|
|
struct ieee80211chanreq creq;
|
2010-02-13 12:54:27 +01:00
|
|
|
#endif /* SIOCS80211CHANNEL */
|
2010-02-08 20:33:59 +01:00
|
|
|
u32 mode;
|
2010-05-23 11:20:33 +02:00
|
|
|
int channel = freq->channel;
|
2010-02-08 20:33:59 +01:00
|
|
|
|
2011-04-14 21:22:24 +02:00
|
|
|
if (channel < 14) {
|
|
|
|
mode =
|
|
|
|
#ifdef CONFIG_IEEE80211N
|
|
|
|
freq->ht_enabled ? IFM_IEEE80211_11NG :
|
|
|
|
#endif /* CONFIG_IEEE80211N */
|
|
|
|
IFM_IEEE80211_11G;
|
|
|
|
} else if (channel == 14) {
|
2010-02-08 20:33:59 +01:00
|
|
|
mode = IFM_IEEE80211_11B;
|
2011-04-14 21:22:24 +02:00
|
|
|
} else {
|
|
|
|
mode =
|
|
|
|
#ifdef CONFIG_IEEE80211N
|
|
|
|
freq->ht_enabled ? IFM_IEEE80211_11NA :
|
|
|
|
#endif /* CONFIG_IEEE80211N */
|
|
|
|
IFM_IEEE80211_11A;
|
|
|
|
}
|
2010-02-13 12:52:03 +01:00
|
|
|
if (bsd_set_mediaopt(drv, IFM_MMASK, mode) < 0) {
|
2010-02-08 20:33:59 +01:00
|
|
|
wpa_printf(MSG_ERROR, "%s: failed to set modulation mode",
|
|
|
|
__func__);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2010-02-13 12:54:27 +01:00
|
|
|
#ifdef SIOCS80211CHANNEL
|
2010-02-08 20:33:59 +01:00
|
|
|
os_memset(&creq, 0, sizeof(creq));
|
2010-02-13 12:52:03 +01:00
|
|
|
os_strlcpy(creq.i_name, drv->ifname, sizeof(creq.i_name));
|
2010-05-23 11:20:33 +02:00
|
|
|
creq.i_channel = (u_int16_t)channel;
|
2016-01-09 02:39:43 +01:00
|
|
|
return ioctl(drv->global->sock, SIOCS80211CHANNEL, &creq);
|
2010-02-13 12:54:27 +01:00
|
|
|
#else /* SIOCS80211CHANNEL */
|
|
|
|
return set80211param(priv, IEEE80211_IOC_CHANNEL, channel);
|
|
|
|
#endif /* SIOCS80211CHANNEL */
|
2010-02-08 20:33:59 +01:00
|
|
|
}
|
|
|
|
|
2010-02-13 12:57:39 +01:00
|
|
|
static int
|
2010-03-07 10:33:06 +01:00
|
|
|
bsd_set_opt_ie(void *priv, const u8 *ie, size_t ie_len)
|
2010-02-13 12:57:39 +01:00
|
|
|
{
|
|
|
|
#ifdef IEEE80211_IOC_APPIE
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: set WPA+RSN ie (len %lu)", __func__,
|
|
|
|
(unsigned long)ie_len);
|
2010-02-13 12:59:29 +01:00
|
|
|
return bsd_set80211(priv, IEEE80211_IOC_APPIE, IEEE80211_APPIE_WPA,
|
|
|
|
ie, ie_len);
|
2010-02-13 12:57:39 +01:00
|
|
|
#endif /* IEEE80211_IOC_APPIE */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-01-07 14:56:06 +01:00
|
|
|
static size_t
|
2011-02-27 13:01:39 +01:00
|
|
|
rtbuf_len(void)
|
|
|
|
{
|
|
|
|
size_t len;
|
|
|
|
|
2011-04-12 22:09:14 +02:00
|
|
|
int mib[6] = {CTL_NET, AF_ROUTE, 0, AF_INET, NET_RT_DUMP, 0};
|
2011-02-27 13:01:39 +01:00
|
|
|
|
|
|
|
if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0) {
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_WARNING, "%s failed: %s", __func__,
|
2011-02-27 13:01:39 +01:00
|
|
|
strerror(errno));
|
2011-04-12 22:09:14 +02:00
|
|
|
len = 2048;
|
2011-02-27 13:01:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
2010-02-08 20:33:59 +01:00
|
|
|
|
|
|
|
#ifdef HOSTAPD
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Avoid conflicts with hostapd definitions by undefining couple of defines
|
|
|
|
* from net80211 header files.
|
|
|
|
*/
|
|
|
|
#undef RSN_VERSION
|
|
|
|
#undef WPA_VERSION
|
|
|
|
#undef WPA_OUI_TYPE
|
|
|
|
|
|
|
|
static int bsd_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr,
|
2019-04-22 19:17:38 +02:00
|
|
|
u16 reason_code);
|
2010-02-08 20:33:59 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-03-07 10:29:17 +01:00
|
|
|
bsd_set_privacy(void *priv, int enabled)
|
2009-04-09 12:40:12 +02:00
|
|
|
{
|
2010-02-08 20:33:59 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "%s: enabled=%d", __func__, enabled);
|
|
|
|
|
2010-02-13 12:52:03 +01:00
|
|
|
return set80211param(priv, IEEE80211_IOC_PRIVACY, enabled);
|
2009-04-09 12:40:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
bsd_get_seqnum(const char *ifname, void *priv, const u8 *addr, int idx,
|
|
|
|
u8 *seq)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
2010-02-13 12:52:03 +01:00
|
|
|
if (get80211var(priv, IEEE80211_IOC_WPAKEY, &wk, sizeof(wk)) < 0) {
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_INFO, "Failed to get encryption");
|
2009-04-09 12:40:12 +02:00
|
|
|
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;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-12-27 16:11:27 +01:00
|
|
|
static int
|
2009-04-09 12:40:12 +02:00
|
|
|
bsd_flush(void *priv)
|
|
|
|
{
|
|
|
|
u8 allsta[IEEE80211_ADDR_LEN];
|
|
|
|
|
|
|
|
memset(allsta, 0xff, IEEE80211_ADDR_LEN);
|
2009-04-17 10:37:22 +02:00
|
|
|
return bsd_sta_deauth(priv, NULL, allsta, IEEE80211_REASON_AUTH_LEAVE);
|
2009-04-09 12:40:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
bsd_read_sta_driver_data(void *priv, struct hostap_sta_driver_data *data,
|
|
|
|
const u8 *addr)
|
|
|
|
{
|
|
|
|
struct ieee80211req_sta_stats stats;
|
|
|
|
|
|
|
|
memcpy(stats.is_u.macaddr, addr, IEEE80211_ADDR_LEN);
|
2010-02-13 12:52:03 +01:00
|
|
|
if (get80211var(priv, IEEE80211_IOC_STA_STATS, &stats, sizeof(stats))
|
|
|
|
> 0) {
|
2009-04-09 12:40:12 +02:00
|
|
|
/* XXX? do packets counts include non-data frames? */
|
|
|
|
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
|
2019-04-22 19:17:38 +02:00
|
|
|
bsd_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr, u16 reason_code)
|
2009-04-09 12:40:12 +02:00
|
|
|
{
|
2010-02-13 12:52:03 +01:00
|
|
|
return bsd_send_mlme_param(priv, IEEE80211_MLME_DEAUTH, reason_code,
|
|
|
|
addr);
|
2009-04-09 12:40:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2009-04-17 10:37:22 +02:00
|
|
|
bsd_sta_disassoc(void *priv, const u8 *own_addr, const u8 *addr,
|
2019-04-22 19:17:38 +02:00
|
|
|
u16 reason_code)
|
2009-04-09 12:40:12 +02:00
|
|
|
{
|
2010-02-13 12:52:03 +01:00
|
|
|
return bsd_send_mlme_param(priv, IEEE80211_MLME_DISASSOC, reason_code,
|
|
|
|
addr);
|
2009-04-09 12:40:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
bsd_wireless_event_receive(int sock, void *ctx, void *sock_ctx)
|
|
|
|
{
|
2016-01-09 02:39:43 +01:00
|
|
|
struct bsd_driver_global *global = sock_ctx;
|
|
|
|
struct bsd_driver_data *drv;
|
2009-04-09 12:40:12 +02:00
|
|
|
struct if_announcemsghdr *ifan;
|
|
|
|
struct rt_msghdr *rtm;
|
|
|
|
struct ieee80211_michael_event *mic;
|
|
|
|
struct ieee80211_join_event *join;
|
|
|
|
struct ieee80211_leave_event *leave;
|
2014-01-07 14:56:06 +01:00
|
|
|
int n;
|
2009-12-13 20:17:11 +01:00
|
|
|
union wpa_event_data data;
|
2009-04-09 12:40:12 +02:00
|
|
|
|
2016-01-09 02:39:43 +01:00
|
|
|
n = read(sock, global->event_buf, global->event_buf_len);
|
2009-04-09 12:40:12 +02:00
|
|
|
if (n < 0) {
|
|
|
|
if (errno != EINTR && errno != EAGAIN)
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_ERROR, "%s read() failed: %s",
|
2011-02-27 13:01:39 +01:00
|
|
|
__func__, strerror(errno));
|
2009-04-09 12:40:12 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-01-09 02:39:43 +01:00
|
|
|
rtm = (struct rt_msghdr *) global->event_buf;
|
2009-04-09 12:40:12 +02:00
|
|
|
if (rtm->rtm_version != RTM_VERSION) {
|
2011-02-27 13:01:39 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "Invalid routing message version=%d",
|
|
|
|
rtm->rtm_version);
|
2009-04-09 12:40:12 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
switch (rtm->rtm_type) {
|
|
|
|
case RTM_IEEE80211:
|
2016-01-09 02:39:43 +01:00
|
|
|
ifan = (struct if_announcemsghdr *) rtm;
|
2016-01-19 17:36:45 +01:00
|
|
|
drv = bsd_get_drvindex(global, ifan->ifan_index);
|
|
|
|
if (drv == NULL)
|
|
|
|
return;
|
2009-04-09 12:40:12 +02:00
|
|
|
switch (ifan->ifan_what) {
|
|
|
|
case RTM_IEEE80211_ASSOC:
|
|
|
|
case RTM_IEEE80211_REASSOC:
|
|
|
|
case RTM_IEEE80211_DISASSOC:
|
|
|
|
case RTM_IEEE80211_SCAN:
|
|
|
|
break;
|
|
|
|
case RTM_IEEE80211_LEAVE:
|
|
|
|
leave = (struct ieee80211_leave_event *) &ifan[1];
|
2020-01-28 17:58:26 +01:00
|
|
|
drv_event_disassoc(drv->ctx, leave->iev_addr);
|
2009-04-09 12:40:12 +02:00
|
|
|
break;
|
|
|
|
case RTM_IEEE80211_JOIN:
|
|
|
|
#ifdef RTM_IEEE80211_REJOIN
|
|
|
|
case RTM_IEEE80211_REJOIN:
|
|
|
|
#endif
|
|
|
|
join = (struct ieee80211_join_event *) &ifan[1];
|
2020-01-28 17:58:26 +01:00
|
|
|
bsd_new_sta(drv, drv->ctx, join->iev_addr);
|
2009-04-09 12:40:12 +02:00
|
|
|
break;
|
|
|
|
case RTM_IEEE80211_REPLAY:
|
|
|
|
/* ignore */
|
|
|
|
break;
|
|
|
|
case RTM_IEEE80211_MICHAEL:
|
|
|
|
mic = (struct ieee80211_michael_event *) &ifan[1];
|
|
|
|
wpa_printf(MSG_DEBUG,
|
|
|
|
"Michael MIC failure wireless event: "
|
|
|
|
"keyix=%u src_addr=" MACSTR, mic->iev_keyix,
|
|
|
|
MAC2STR(mic->iev_src));
|
2009-12-13 20:17:11 +01:00
|
|
|
os_memset(&data, 0, sizeof(data));
|
|
|
|
data.michael_mic_failure.unicast = 1;
|
|
|
|
data.michael_mic_failure.src = mic->iev_src;
|
2020-01-28 17:58:26 +01:00
|
|
|
wpa_supplicant_event(drv->ctx,
|
2009-12-13 20:17:11 +01:00
|
|
|
EVENT_MICHAEL_MIC_FAILURE, &data);
|
2009-04-09 12:40:12 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
handle_read(void *ctx, const u8 *src_addr, const u8 *buf, size_t len)
|
|
|
|
{
|
|
|
|
struct bsd_driver_data *drv = ctx;
|
2020-01-28 17:58:26 +01:00
|
|
|
drv_event_eapol_rx(drv->ctx, src_addr, buf, len);
|
2009-04-09 12:40:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
2009-04-09 22:28:21 +02:00
|
|
|
bsd_init(struct hostapd_data *hapd, struct wpa_init_params *params)
|
2009-04-09 12:40:12 +02:00
|
|
|
{
|
|
|
|
struct bsd_driver_data *drv;
|
|
|
|
|
|
|
|
drv = os_zalloc(sizeof(struct bsd_driver_data));
|
|
|
|
if (drv == NULL) {
|
2014-01-07 14:58:01 +01:00
|
|
|
wpa_printf(MSG_ERROR, "Could not allocate memory for bsd driver data");
|
|
|
|
return NULL;
|
2009-04-09 12:40:12 +02:00
|
|
|
}
|
|
|
|
|
2016-01-09 02:39:43 +01:00
|
|
|
drv->ifindex = if_nametoindex(params->ifname);
|
|
|
|
if (drv->ifindex == 0) {
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: interface %s does not exist",
|
|
|
|
__func__, params->ifname);
|
2014-01-07 14:56:06 +01:00
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
2020-01-28 17:58:26 +01:00
|
|
|
drv->ctx = hapd;
|
2016-01-09 02:39:43 +01:00
|
|
|
drv->global = params->global_priv;
|
2010-02-13 12:48:52 +01:00
|
|
|
os_strlcpy(drv->ifname, params->ifname, sizeof(drv->ifname));
|
2009-04-09 12:40:12 +02:00
|
|
|
|
2010-02-13 12:48:52 +01:00
|
|
|
drv->sock_xmit = l2_packet_init(drv->ifname, NULL, ETH_P_EAPOL,
|
2010-02-08 20:28:59 +01:00
|
|
|
handle_read, drv, 0);
|
2009-04-09 12:40:12 +02:00
|
|
|
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-04-09 12:40:12 +02:00
|
|
|
goto bad;
|
|
|
|
|
2010-02-08 20:23:28 +01:00
|
|
|
/* mark down during setup */
|
2010-02-13 12:52:03 +01:00
|
|
|
if (bsd_ctrl_iface(drv, 0) < 0)
|
2010-02-08 20:23:28 +01:00
|
|
|
goto bad;
|
2010-02-13 12:48:52 +01:00
|
|
|
|
2010-02-13 12:52:03 +01:00
|
|
|
if (bsd_set_mediaopt(drv, IFM_OMASK, IFM_IEEE80211_HOSTAP) < 0) {
|
2010-02-08 20:14:22 +01:00
|
|
|
wpa_printf(MSG_ERROR, "%s: failed to set operation mode",
|
|
|
|
__func__);
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
2016-01-09 02:39:43 +01:00
|
|
|
dl_list_add(&drv->global->ifaces, &drv->list);
|
|
|
|
|
2009-04-09 12:40:12 +02:00
|
|
|
return drv;
|
|
|
|
bad:
|
|
|
|
if (drv->sock_xmit != NULL)
|
|
|
|
l2_packet_deinit(drv->sock_xmit);
|
2015-06-23 17:20:24 +02:00
|
|
|
os_free(drv);
|
2009-04-09 12:40:12 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
bsd_deinit(void *priv)
|
|
|
|
{
|
|
|
|
struct bsd_driver_data *drv = priv;
|
|
|
|
|
2016-01-20 18:13:12 +01:00
|
|
|
if (drv->ifindex != 0)
|
|
|
|
bsd_ctrl_iface(drv, 0);
|
2009-04-09 12:40:12 +02:00
|
|
|
if (drv->sock_xmit != NULL)
|
|
|
|
l2_packet_deinit(drv->sock_xmit);
|
2010-02-08 20:11:52 +01:00
|
|
|
os_free(drv);
|
2009-04-09 12:40:12 +02:00
|
|
|
}
|
|
|
|
|
2014-02-02 22:06:14 +01:00
|
|
|
|
|
|
|
static int
|
|
|
|
bsd_commit(void *priv)
|
|
|
|
{
|
|
|
|
return bsd_ctrl_iface(priv, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
bsd_set_sta_authorized(void *priv, const u8 *addr,
|
2015-07-07 11:33:38 +02:00
|
|
|
unsigned int total_flags, unsigned int flags_or,
|
|
|
|
unsigned int flags_and)
|
2014-02-02 22:06:14 +01:00
|
|
|
{
|
|
|
|
int authorized = -1;
|
|
|
|
|
|
|
|
/* For now, only support setting Authorized flag */
|
|
|
|
if (flags_or & WPA_STA_AUTHORIZED)
|
|
|
|
authorized = 1;
|
|
|
|
if (!(flags_and & WPA_STA_AUTHORIZED))
|
|
|
|
authorized = 0;
|
|
|
|
|
|
|
|
if (authorized < 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return bsd_send_mlme_param(priv, authorized ?
|
|
|
|
IEEE80211_MLME_AUTHORIZE :
|
|
|
|
IEEE80211_MLME_UNAUTHORIZE, 0, addr);
|
|
|
|
}
|
2009-04-09 12:40:12 +02:00
|
|
|
#else /* HOSTAPD */
|
|
|
|
|
2008-02-28 02:34:43 +01:00
|
|
|
static int
|
2010-02-13 12:50:19 +01:00
|
|
|
get80211param(struct bsd_driver_data *drv, int op)
|
2008-02-28 02:34:43 +01:00
|
|
|
{
|
|
|
|
struct ieee80211req ireq;
|
|
|
|
|
2010-02-13 12:59:29 +01:00
|
|
|
if (bsd_get80211(drv, &ireq, op, NULL, 0) < 0)
|
2008-02-28 02:34:43 +01:00
|
|
|
return -1;
|
|
|
|
return ireq.i_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
wpa_driver_bsd_get_bssid(void *priv, u8 *bssid)
|
|
|
|
{
|
2010-02-13 12:50:19 +01:00
|
|
|
struct bsd_driver_data *drv = priv;
|
2009-05-29 21:38:55 +02:00
|
|
|
#ifdef SIOCG80211BSSID
|
2009-05-21 10:34:54 +02:00
|
|
|
struct ieee80211_bssid bs;
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2010-02-13 12:52:03 +01:00
|
|
|
os_strlcpy(bs.i_name, drv->ifname, sizeof(bs.i_name));
|
2016-01-09 02:39:43 +01:00
|
|
|
if (ioctl(drv->global->sock, SIOCG80211BSSID, &bs) < 0)
|
2009-05-21 10:34:54 +02:00
|
|
|
return -1;
|
|
|
|
os_memcpy(bssid, bs.i_bssid, sizeof(bs.i_bssid));
|
|
|
|
return 0;
|
|
|
|
#else
|
2008-02-28 02:34:43 +01:00
|
|
|
return get80211var(drv, IEEE80211_IOC_BSSID,
|
|
|
|
bssid, IEEE80211_ADDR_LEN) < 0 ? -1 : 0;
|
2009-05-21 10:34:54 +02:00
|
|
|
#endif
|
2008-02-28 02:34:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
wpa_driver_bsd_get_ssid(void *priv, u8 *ssid)
|
|
|
|
{
|
2010-02-13 12:50:19 +01:00
|
|
|
struct bsd_driver_data *drv = priv;
|
2010-03-10 22:33:10 +01:00
|
|
|
return bsd_get_ssid(drv, ssid, 0);
|
2008-02-28 02:34:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-02-13 12:50:19 +01:00
|
|
|
wpa_driver_bsd_set_wpa_ie(struct bsd_driver_data *drv, const u8 *wpa_ie,
|
|
|
|
size_t wpa_ie_len)
|
2008-02-28 02:34:43 +01:00
|
|
|
{
|
2010-01-09 10:04:44 +01:00
|
|
|
#ifdef IEEE80211_IOC_APPIE
|
2010-03-07 10:33:06 +01:00
|
|
|
return bsd_set_opt_ie(drv, wpa_ie, wpa_ie_len);
|
2010-01-09 10:04:44 +01:00
|
|
|
#else /* IEEE80211_IOC_APPIE */
|
2008-02-28 02:34:43 +01:00
|
|
|
return set80211var(drv, IEEE80211_IOC_OPTIE, wpa_ie, wpa_ie_len);
|
2010-01-09 10:04:44 +01:00
|
|
|
#endif /* IEEE80211_IOC_APPIE */
|
2008-02-28 02:34:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
wpa_driver_bsd_set_wpa_internal(void *priv, int wpa, int privacy)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: wpa=%d privacy=%d",
|
2016-01-19 16:33:17 +01:00
|
|
|
__func__, wpa, privacy);
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2010-02-13 12:52:03 +01:00
|
|
|
if (!wpa && wpa_driver_bsd_set_wpa_ie(priv, NULL, 0) < 0)
|
2008-02-28 02:34:43 +01:00
|
|
|
ret = -1;
|
2010-02-13 12:52:03 +01:00
|
|
|
if (set80211param(priv, IEEE80211_IOC_PRIVACY, privacy) < 0)
|
2008-02-28 02:34:43 +01:00
|
|
|
ret = -1;
|
2010-02-13 12:52:03 +01:00
|
|
|
if (set80211param(priv, IEEE80211_IOC_WPA, wpa) < 0)
|
2008-02-28 02:34:43 +01:00
|
|
|
ret = -1;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
wpa_driver_bsd_set_wpa(void *priv, int enabled)
|
|
|
|
{
|
2016-01-19 16:33:17 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "%s: enabled=%d", __func__, enabled);
|
2008-02-28 02:34:43 +01:00
|
|
|
|
|
|
|
return wpa_driver_bsd_set_wpa_internal(priv, enabled ? 3 : 0, enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
wpa_driver_bsd_set_countermeasures(void *priv, int enabled)
|
|
|
|
{
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: enabled=%d", __func__, enabled);
|
2010-02-13 12:52:03 +01:00
|
|
|
return set80211param(priv, IEEE80211_IOC_COUNTERMEASURES, enabled);
|
2008-02-28 02:34:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
wpa_driver_bsd_set_drop_unencrypted(void *priv, int enabled)
|
|
|
|
{
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: enabled=%d", __func__, enabled);
|
2010-02-13 12:52:03 +01:00
|
|
|
return set80211param(priv, IEEE80211_IOC_DROPUNENCRYPTED, enabled);
|
2008-02-28 02:34:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2019-04-22 19:17:38 +02:00
|
|
|
wpa_driver_bsd_deauthenticate(void *priv, const u8 *addr, u16 reason_code)
|
2008-02-28 02:34:43 +01:00
|
|
|
{
|
2010-02-13 12:52:03 +01:00
|
|
|
return bsd_send_mlme_param(priv, IEEE80211_MLME_DEAUTH, reason_code,
|
|
|
|
addr);
|
2008-02-28 02:34:43 +01:00
|
|
|
}
|
|
|
|
|
2009-12-07 20:35:35 +01:00
|
|
|
static int
|
|
|
|
wpa_driver_bsd_set_auth_alg(void *priv, int auth_alg)
|
|
|
|
{
|
|
|
|
int authmode;
|
|
|
|
|
2010-01-03 20:14:40 +01:00
|
|
|
if ((auth_alg & WPA_AUTH_ALG_OPEN) &&
|
|
|
|
(auth_alg & WPA_AUTH_ALG_SHARED))
|
2009-12-07 20:35:35 +01:00
|
|
|
authmode = IEEE80211_AUTH_AUTO;
|
2010-01-03 20:14:40 +01:00
|
|
|
else if (auth_alg & WPA_AUTH_ALG_SHARED)
|
2009-12-07 20:35:35 +01:00
|
|
|
authmode = IEEE80211_AUTH_SHARED;
|
|
|
|
else
|
|
|
|
authmode = IEEE80211_AUTH_OPEN;
|
|
|
|
|
2010-02-13 12:52:03 +01:00
|
|
|
return set80211param(priv, IEEE80211_IOC_AUTHMODE, authmode);
|
2009-12-07 20:35:35 +01:00
|
|
|
}
|
|
|
|
|
2010-02-08 20:33:59 +01:00
|
|
|
static void
|
|
|
|
handle_read(void *ctx, const u8 *src_addr, const u8 *buf, size_t len)
|
|
|
|
{
|
2010-02-13 12:50:19 +01:00
|
|
|
struct bsd_driver_data *drv = ctx;
|
2010-02-08 20:33:59 +01:00
|
|
|
|
|
|
|
drv_event_eapol_rx(drv->ctx, src_addr, buf, len);
|
|
|
|
}
|
|
|
|
|
2008-02-28 02:34:43 +01:00
|
|
|
static int
|
|
|
|
wpa_driver_bsd_associate(void *priv, struct wpa_driver_associate_params *params)
|
|
|
|
{
|
2010-02-13 12:50:19 +01:00
|
|
|
struct bsd_driver_data *drv = priv;
|
2008-02-28 02:34:43 +01:00
|
|
|
struct ieee80211req_mlme mlme;
|
2010-02-08 20:33:59 +01:00
|
|
|
u32 mode;
|
2008-02-28 02:34:43 +01:00
|
|
|
int privacy;
|
2009-11-23 19:22:38 +01:00
|
|
|
int ret = 0;
|
2008-02-28 02:34:43 +01:00
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG,
|
|
|
|
"%s: ssid '%.*s' wpa ie len %u pairwise %u group %u key mgmt %u"
|
|
|
|
, __func__
|
2009-05-29 21:34:07 +02:00
|
|
|
, (unsigned int) params->ssid_len, params->ssid
|
|
|
|
, (unsigned int) params->wpa_ie_len
|
2008-02-28 02:34:43 +01:00
|
|
|
, params->pairwise_suite
|
|
|
|
, params->group_suite
|
|
|
|
, params->key_mgmt_suite
|
|
|
|
);
|
|
|
|
|
2010-02-08 20:33:59 +01:00
|
|
|
switch (params->mode) {
|
|
|
|
case IEEE80211_MODE_INFRA:
|
|
|
|
mode = 0 /* STA */;
|
|
|
|
break;
|
|
|
|
case IEEE80211_MODE_IBSS:
|
|
|
|
mode = IFM_IEEE80211_IBSS;
|
|
|
|
break;
|
|
|
|
case IEEE80211_MODE_AP:
|
|
|
|
mode = IFM_IEEE80211_HOSTAP;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
wpa_printf(MSG_ERROR, "%s: unknown operation mode", __func__);
|
|
|
|
return -1;
|
|
|
|
}
|
2010-02-13 12:52:03 +01:00
|
|
|
if (bsd_set_mediaopt(drv, IFM_OMASK, mode) < 0) {
|
2010-02-08 20:33:59 +01:00
|
|
|
wpa_printf(MSG_ERROR, "%s: failed to set operation mode",
|
|
|
|
__func__);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (params->mode == IEEE80211_MODE_AP) {
|
|
|
|
drv->sock_xmit = l2_packet_init(drv->ifname, NULL, ETH_P_EAPOL,
|
|
|
|
handle_read, drv, 0);
|
|
|
|
if (drv->sock_xmit == NULL)
|
|
|
|
return -1;
|
|
|
|
drv->is_ap = 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-23 19:22:38 +01:00
|
|
|
if (wpa_driver_bsd_set_drop_unencrypted(drv, params->drop_unencrypted)
|
|
|
|
< 0)
|
|
|
|
ret = -1;
|
|
|
|
if (wpa_driver_bsd_set_auth_alg(drv, params->auth_alg) < 0)
|
|
|
|
ret = -1;
|
2008-02-28 02:34:43 +01:00
|
|
|
/* XXX error handling is wrong but unclear what to do... */
|
|
|
|
if (wpa_driver_bsd_set_wpa_ie(drv, params->wpa_ie, params->wpa_ie_len) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2013-12-30 18:33:39 +01:00
|
|
|
privacy = !(params->pairwise_suite == WPA_CIPHER_NONE &&
|
|
|
|
params->group_suite == WPA_CIPHER_NONE &&
|
|
|
|
params->key_mgmt_suite == WPA_KEY_MGMT_NONE &&
|
2008-02-28 02:34:43 +01:00
|
|
|
params->wpa_ie_len == 0);
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: set PRIVACY %u", __func__, privacy);
|
|
|
|
|
|
|
|
if (set80211param(drv, IEEE80211_IOC_PRIVACY, privacy) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (params->wpa_ie_len &&
|
|
|
|
set80211param(drv, IEEE80211_IOC_WPA,
|
|
|
|
params->wpa_ie[0] == WLAN_EID_RSN ? 2 : 1) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
os_memset(&mlme, 0, sizeof(mlme));
|
|
|
|
mlme.im_op = IEEE80211_MLME_ASSOC;
|
|
|
|
if (params->ssid != NULL)
|
|
|
|
os_memcpy(mlme.im_ssid, params->ssid, params->ssid_len);
|
|
|
|
mlme.im_ssid_len = params->ssid_len;
|
|
|
|
if (params->bssid != NULL)
|
|
|
|
os_memcpy(mlme.im_macaddr, params->bssid, IEEE80211_ADDR_LEN);
|
|
|
|
if (set80211var(drv, IEEE80211_IOC_MLME, &mlme, sizeof(mlme)) < 0)
|
|
|
|
return -1;
|
2009-11-23 19:22:38 +01:00
|
|
|
return ret;
|
2008-02-28 02:34:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2009-11-23 20:13:46 +01:00
|
|
|
wpa_driver_bsd_scan(void *priv, struct wpa_driver_scan_params *params)
|
2008-02-28 02:34:43 +01:00
|
|
|
{
|
2010-02-13 12:50:19 +01:00
|
|
|
struct bsd_driver_data *drv = priv;
|
2010-02-13 12:57:39 +01:00
|
|
|
#ifdef IEEE80211_IOC_SCAN_MAX_SSID
|
|
|
|
struct ieee80211_scan_req sr;
|
|
|
|
int i;
|
|
|
|
#endif /* IEEE80211_IOC_SCAN_MAX_SSID */
|
|
|
|
|
|
|
|
if (bsd_set_mediaopt(drv, IFM_OMASK, 0 /* STA */) < 0) {
|
|
|
|
wpa_printf(MSG_ERROR, "%s: failed to set operation mode",
|
|
|
|
__func__);
|
|
|
|
return -1;
|
|
|
|
}
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2010-02-08 20:33:59 +01:00
|
|
|
if (set80211param(drv, IEEE80211_IOC_ROAMING,
|
|
|
|
IEEE80211_ROAMING_MANUAL) < 0) {
|
|
|
|
wpa_printf(MSG_ERROR, "%s: failed to set "
|
|
|
|
"wpa_supplicant-based roaming: %s", __func__,
|
|
|
|
strerror(errno));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wpa_driver_bsd_set_wpa(drv, 1) < 0) {
|
|
|
|
wpa_printf(MSG_ERROR, "%s: failed to set wpa: %s", __func__,
|
|
|
|
strerror(errno));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2008-02-28 02:34:43 +01:00
|
|
|
/* NB: interface must be marked UP to do a scan */
|
2010-02-13 12:52:03 +01:00
|
|
|
if (bsd_ctrl_iface(drv, 1) < 0)
|
2008-02-28 02:34:43 +01:00
|
|
|
return -1;
|
|
|
|
|
2010-02-13 12:57:39 +01:00
|
|
|
#ifdef IEEE80211_IOC_SCAN_MAX_SSID
|
|
|
|
os_memset(&sr, 0, sizeof(sr));
|
|
|
|
sr.sr_flags = IEEE80211_IOC_SCAN_ACTIVE | IEEE80211_IOC_SCAN_ONCE |
|
|
|
|
IEEE80211_IOC_SCAN_NOJOIN;
|
|
|
|
sr.sr_duration = IEEE80211_IOC_SCAN_FOREVER;
|
|
|
|
if (params->num_ssids > 0) {
|
|
|
|
sr.sr_nssid = params->num_ssids;
|
|
|
|
#if 0
|
|
|
|
/* Boundary check is done by upper layer */
|
|
|
|
if (sr.sr_nssid > IEEE80211_IOC_SCAN_MAX_SSID)
|
|
|
|
sr.sr_nssid = IEEE80211_IOC_SCAN_MAX_SSID;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* NB: check scan cache first */
|
|
|
|
sr.sr_flags |= IEEE80211_IOC_SCAN_CHECK;
|
|
|
|
}
|
|
|
|
for (i = 0; i < sr.sr_nssid; i++) {
|
|
|
|
sr.sr_ssid[i].len = params->ssids[i].ssid_len;
|
|
|
|
os_memcpy(sr.sr_ssid[i].ssid, params->ssids[i].ssid,
|
|
|
|
sr.sr_ssid[i].len);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* NB: net80211 delivers a scan complete event so no need to poll */
|
|
|
|
return set80211var(drv, IEEE80211_IOC_SCAN_REQ, &sr, sizeof(sr));
|
|
|
|
#else /* IEEE80211_IOC_SCAN_MAX_SSID */
|
2008-02-28 02:34:43 +01:00
|
|
|
/* set desired ssid before scan */
|
2010-03-10 22:33:10 +01:00
|
|
|
if (bsd_set_ssid(drv, params->ssids[0].ssid,
|
2010-02-13 12:57:39 +01:00
|
|
|
params->ssids[0].ssid_len) < 0)
|
2008-02-28 02:34:43 +01:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* NB: net80211 delivers a scan complete event so no need to poll */
|
|
|
|
return set80211param(drv, IEEE80211_IOC_SCAN_REQ, 0);
|
2010-02-13 12:57:39 +01:00
|
|
|
#endif /* IEEE80211_IOC_SCAN_MAX_SSID */
|
2008-02-28 02:34:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wpa_driver_bsd_event_receive(int sock, void *ctx, void *sock_ctx)
|
|
|
|
{
|
2016-01-09 02:39:43 +01:00
|
|
|
struct bsd_driver_global *global = sock_ctx;
|
|
|
|
struct bsd_driver_data *drv;
|
2008-02-28 02:34:43 +01:00
|
|
|
struct if_announcemsghdr *ifan;
|
2016-01-19 17:36:45 +01:00
|
|
|
struct if_msghdr *ifm;
|
2008-02-28 02:34:43 +01:00
|
|
|
struct rt_msghdr *rtm;
|
|
|
|
union wpa_event_data event;
|
|
|
|
struct ieee80211_michael_event *mic;
|
2010-02-08 20:33:59 +01:00
|
|
|
struct ieee80211_leave_event *leave;
|
|
|
|
struct ieee80211_join_event *join;
|
2014-01-07 14:56:06 +01:00
|
|
|
int n;
|
2011-02-27 13:01:39 +01:00
|
|
|
|
2016-01-09 02:39:43 +01:00
|
|
|
n = read(sock, global->event_buf, global->event_buf_len);
|
2008-02-28 02:34:43 +01:00
|
|
|
if (n < 0) {
|
|
|
|
if (errno != EINTR && errno != EAGAIN)
|
2014-12-24 11:43:35 +01:00
|
|
|
wpa_printf(MSG_ERROR, "%s read() failed: %s",
|
2011-02-27 13:01:39 +01:00
|
|
|
__func__, strerror(errno));
|
2008-02-28 02:34:43 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-01-09 02:39:43 +01:00
|
|
|
rtm = (struct rt_msghdr *) global->event_buf;
|
2008-02-28 02:34:43 +01:00
|
|
|
if (rtm->rtm_version != RTM_VERSION) {
|
2011-02-27 13:01:39 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "Invalid routing message version=%d",
|
|
|
|
rtm->rtm_version);
|
2008-02-28 02:34:43 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
os_memset(&event, 0, sizeof(event));
|
|
|
|
switch (rtm->rtm_type) {
|
|
|
|
case RTM_IFANNOUNCE:
|
|
|
|
ifan = (struct if_announcemsghdr *) rtm;
|
|
|
|
switch (ifan->ifan_what) {
|
|
|
|
case IFAN_DEPARTURE:
|
2016-03-15 14:02:08 +01:00
|
|
|
drv = bsd_get_drvindex(global, ifan->ifan_index);
|
|
|
|
if (drv)
|
|
|
|
drv->if_removed = 1;
|
2008-02-28 02:34:43 +01:00
|
|
|
event.interface_status.ievent = EVENT_INTERFACE_REMOVED;
|
2016-03-15 14:02:08 +01:00
|
|
|
break;
|
|
|
|
case IFAN_ARRIVAL:
|
|
|
|
drv = bsd_get_drvname(global, ifan->ifan_name);
|
|
|
|
if (drv) {
|
|
|
|
drv->ifindex = ifan->ifan_index;
|
|
|
|
drv->if_removed = 0;
|
|
|
|
}
|
|
|
|
event.interface_status.ievent = EVENT_INTERFACE_ADDED;
|
2016-01-20 18:13:12 +01:00
|
|
|
break;
|
2008-02-28 02:34:43 +01:00
|
|
|
default:
|
2016-03-15 14:02:08 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "RTM_IFANNOUNCE: unknown action");
|
2008-02-28 02:34:43 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
wpa_printf(MSG_DEBUG, "RTM_IFANNOUNCE: Interface '%s' %s",
|
2016-03-15 14:02:08 +01:00
|
|
|
ifan->ifan_name,
|
2008-02-28 02:34:43 +01:00
|
|
|
ifan->ifan_what == IFAN_DEPARTURE ?
|
|
|
|
"removed" : "added");
|
2016-03-15 14:02:08 +01:00
|
|
|
os_strlcpy(event.interface_status.ifname, ifan->ifan_name,
|
|
|
|
sizeof(event.interface_status.ifname));
|
|
|
|
if (drv) {
|
|
|
|
wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_STATUS,
|
|
|
|
&event);
|
|
|
|
/*
|
|
|
|
* Set ifindex to zero after sending the event as the
|
|
|
|
* event might query the driver to ensure a match.
|
|
|
|
*/
|
|
|
|
if (ifan->ifan_what == IFAN_DEPARTURE)
|
|
|
|
drv->ifindex = 0;
|
|
|
|
} else {
|
|
|
|
wpa_supplicant_event_global(global->ctx,
|
|
|
|
EVENT_INTERFACE_STATUS,
|
|
|
|
&event);
|
|
|
|
}
|
2008-02-28 02:34:43 +01:00
|
|
|
break;
|
|
|
|
case RTM_IEEE80211:
|
|
|
|
ifan = (struct if_announcemsghdr *) rtm;
|
2016-01-19 17:36:45 +01:00
|
|
|
drv = bsd_get_drvindex(global, ifan->ifan_index);
|
|
|
|
if (drv == NULL)
|
|
|
|
return;
|
2008-02-28 02:34:43 +01:00
|
|
|
switch (ifan->ifan_what) {
|
|
|
|
case RTM_IEEE80211_ASSOC:
|
|
|
|
case RTM_IEEE80211_REASSOC:
|
2010-02-08 20:33:59 +01:00
|
|
|
if (drv->is_ap)
|
|
|
|
break;
|
2016-01-19 17:36:45 +01:00
|
|
|
wpa_supplicant_event(drv->ctx, EVENT_ASSOC, NULL);
|
2008-02-28 02:34:43 +01:00
|
|
|
break;
|
|
|
|
case RTM_IEEE80211_DISASSOC:
|
2010-02-08 20:33:59 +01:00
|
|
|
if (drv->is_ap)
|
|
|
|
break;
|
2016-01-19 17:36:45 +01:00
|
|
|
wpa_supplicant_event(drv->ctx, EVENT_DISASSOC, NULL);
|
2008-02-28 02:34:43 +01:00
|
|
|
break;
|
|
|
|
case RTM_IEEE80211_SCAN:
|
2010-02-08 20:33:59 +01:00
|
|
|
if (drv->is_ap)
|
|
|
|
break;
|
2016-01-19 17:36:45 +01:00
|
|
|
wpa_supplicant_event(drv->ctx, EVENT_SCAN_RESULTS,
|
|
|
|
NULL);
|
2008-02-28 02:34:43 +01:00
|
|
|
break;
|
2010-02-08 20:33:59 +01:00
|
|
|
case RTM_IEEE80211_LEAVE:
|
|
|
|
leave = (struct ieee80211_leave_event *) &ifan[1];
|
2016-01-19 17:36:45 +01:00
|
|
|
drv_event_disassoc(drv->ctx, leave->iev_addr);
|
2010-02-08 20:33:59 +01:00
|
|
|
break;
|
|
|
|
case RTM_IEEE80211_JOIN:
|
|
|
|
#ifdef RTM_IEEE80211_REJOIN
|
|
|
|
case RTM_IEEE80211_REJOIN:
|
|
|
|
#endif
|
|
|
|
join = (struct ieee80211_join_event *) &ifan[1];
|
2016-01-19 17:36:45 +01:00
|
|
|
bsd_new_sta(drv, drv->ctx, join->iev_addr);
|
2010-02-08 20:33:59 +01:00
|
|
|
break;
|
2008-02-28 02:34:43 +01:00
|
|
|
case RTM_IEEE80211_REPLAY:
|
|
|
|
/* ignore */
|
|
|
|
break;
|
|
|
|
case RTM_IEEE80211_MICHAEL:
|
|
|
|
mic = (struct ieee80211_michael_event *) &ifan[1];
|
|
|
|
wpa_printf(MSG_DEBUG,
|
|
|
|
"Michael MIC failure wireless event: "
|
|
|
|
"keyix=%u src_addr=" MACSTR, mic->iev_keyix,
|
|
|
|
MAC2STR(mic->iev_src));
|
|
|
|
|
|
|
|
os_memset(&event, 0, sizeof(event));
|
|
|
|
event.michael_mic_failure.unicast =
|
|
|
|
!IEEE80211_IS_MULTICAST(mic->iev_dst);
|
2016-01-19 17:36:45 +01:00
|
|
|
wpa_supplicant_event(drv->ctx,
|
|
|
|
EVENT_MICHAEL_MIC_FAILURE, &event);
|
2008-02-28 02:34:43 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RTM_IFINFO:
|
2016-01-19 17:36:45 +01:00
|
|
|
ifm = (struct if_msghdr *) rtm;
|
|
|
|
drv = bsd_get_drvindex(global, ifm->ifm_index);
|
|
|
|
if (drv == NULL)
|
|
|
|
return;
|
2016-01-19 18:48:01 +01:00
|
|
|
if ((ifm->ifm_flags & IFF_UP) == 0 &&
|
|
|
|
(drv->flags & IFF_UP) != 0) {
|
2008-02-28 02:34:43 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "RTM_IFINFO: Interface '%s' DOWN",
|
2016-01-19 18:48:01 +01:00
|
|
|
drv->ifname);
|
|
|
|
wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_DISABLED,
|
|
|
|
NULL);
|
|
|
|
} else if ((ifm->ifm_flags & IFF_UP) != 0 &&
|
|
|
|
(drv->flags & IFF_UP) == 0) {
|
|
|
|
wpa_printf(MSG_DEBUG, "RTM_IFINFO: Interface '%s' UP",
|
|
|
|
drv->ifname);
|
|
|
|
wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_ENABLED,
|
|
|
|
NULL);
|
2008-02-28 02:34:43 +01:00
|
|
|
}
|
2016-01-19 18:48:01 +01:00
|
|
|
drv->flags = ifm->ifm_flags;
|
2008-02-28 02:34:43 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-21 10:34:54 +02:00
|
|
|
static void
|
|
|
|
wpa_driver_bsd_add_scan_entry(struct wpa_scan_results *res,
|
|
|
|
struct ieee80211req_scan_result *sr)
|
2008-02-28 02:34:43 +01:00
|
|
|
{
|
2009-05-21 10:34:54 +02:00
|
|
|
struct wpa_scan_res *result, **tmp;
|
|
|
|
size_t extra_len;
|
|
|
|
u8 *pos;
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2009-05-21 10:34:54 +02:00
|
|
|
extra_len = 2 + sr->isr_ssid_len;
|
|
|
|
extra_len += 2 + sr->isr_nrates;
|
|
|
|
extra_len += 3; /* ERP IE */
|
|
|
|
extra_len += sr->isr_ie_len;
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2009-05-21 10:34:54 +02:00
|
|
|
result = os_zalloc(sizeof(*result) + extra_len);
|
|
|
|
if (result == NULL)
|
|
|
|
return;
|
|
|
|
os_memcpy(result->bssid, sr->isr_bssid, ETH_ALEN);
|
|
|
|
result->freq = sr->isr_freq;
|
|
|
|
result->beacon_int = sr->isr_intval;
|
|
|
|
result->caps = sr->isr_capinfo;
|
|
|
|
result->qual = sr->isr_rssi;
|
|
|
|
result->noise = sr->isr_noise;
|
2016-04-11 10:56:20 +02:00
|
|
|
|
|
|
|
#ifdef __FreeBSD__
|
2013-08-07 09:57:51 +02:00
|
|
|
/*
|
|
|
|
* the rssi value reported by the kernel is in 0.5dB steps relative to
|
|
|
|
* the reported noise floor. see ieee80211_node.h for details.
|
|
|
|
*/
|
|
|
|
result->level = sr->isr_rssi / 2 + sr->isr_noise;
|
2016-04-11 10:56:20 +02:00
|
|
|
#else
|
|
|
|
result->level = sr->isr_rssi;
|
|
|
|
#endif
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2009-05-21 10:34:54 +02:00
|
|
|
pos = (u8 *)(result + 1);
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2009-05-21 10:34:54 +02:00
|
|
|
*pos++ = WLAN_EID_SSID;
|
|
|
|
*pos++ = sr->isr_ssid_len;
|
|
|
|
os_memcpy(pos, sr + 1, sr->isr_ssid_len);
|
|
|
|
pos += sr->isr_ssid_len;
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2009-05-21 10:34:54 +02:00
|
|
|
/*
|
|
|
|
* Deal all rates as supported rate.
|
|
|
|
* Because net80211 doesn't report extended supported rate or not.
|
|
|
|
*/
|
|
|
|
*pos++ = WLAN_EID_SUPP_RATES;
|
|
|
|
*pos++ = sr->isr_nrates;
|
|
|
|
os_memcpy(pos, sr->isr_rates, sr->isr_nrates);
|
|
|
|
pos += sr->isr_nrates;
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2009-05-21 10:34:54 +02:00
|
|
|
*pos++ = WLAN_EID_ERP_INFO;
|
|
|
|
*pos++ = 1;
|
|
|
|
*pos++ = sr->isr_erp;
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2015-01-06 15:08:37 +01:00
|
|
|
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
|
|
|
os_memcpy(pos, (u8 *)(sr + 1) + sr->isr_ssid_len + sr->isr_meshid_len,
|
|
|
|
sr->isr_ie_len);
|
|
|
|
#else
|
2009-05-21 10:34:54 +02:00
|
|
|
os_memcpy(pos, (u8 *)(sr + 1) + sr->isr_ssid_len, sr->isr_ie_len);
|
2015-01-06 15:08:37 +01:00
|
|
|
#endif
|
2009-05-21 10:34:54 +02:00
|
|
|
pos += sr->isr_ie_len;
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2009-05-21 10:34:54 +02:00
|
|
|
result->ie_len = pos - (u8 *)(result + 1);
|
|
|
|
|
2012-08-13 20:21:23 +02:00
|
|
|
tmp = os_realloc_array(res->res, res->num + 1,
|
|
|
|
sizeof(struct wpa_scan_res *));
|
2009-05-21 10:34:54 +02:00
|
|
|
if (tmp == NULL) {
|
|
|
|
os_free(result);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
tmp[res->num++] = result;
|
|
|
|
res->res = tmp;
|
2008-02-28 02:34:43 +01:00
|
|
|
}
|
|
|
|
|
2009-05-21 10:34:54 +02:00
|
|
|
struct wpa_scan_results *
|
|
|
|
wpa_driver_bsd_get_scan_results2(void *priv)
|
2008-02-28 02:34:43 +01:00
|
|
|
{
|
|
|
|
struct ieee80211req_scan_result *sr;
|
2009-05-21 10:34:54 +02:00
|
|
|
struct wpa_scan_results *res;
|
|
|
|
int len, rest;
|
|
|
|
uint8_t buf[24*1024], *pos;
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2010-02-13 12:52:03 +01:00
|
|
|
len = get80211var(priv, IEEE80211_IOC_SCAN_RESULTS, buf, 24*1024);
|
2008-02-28 02:34:43 +01:00
|
|
|
if (len < 0)
|
2009-05-21 10:34:54 +02:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
res = os_zalloc(sizeof(*res));
|
|
|
|
if (res == NULL)
|
|
|
|
return NULL;
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2009-05-21 10:34:54 +02:00
|
|
|
pos = buf;
|
|
|
|
rest = len;
|
|
|
|
while (rest >= sizeof(struct ieee80211req_scan_result)) {
|
|
|
|
sr = (struct ieee80211req_scan_result *)pos;
|
|
|
|
wpa_driver_bsd_add_scan_entry(res, sr);
|
|
|
|
pos += sr->isr_len;
|
|
|
|
rest -= sr->isr_len;
|
2008-02-28 02:34:43 +01:00
|
|
|
}
|
|
|
|
|
2009-05-21 10:34:54 +02:00
|
|
|
wpa_printf(MSG_DEBUG, "Received %d bytes of scan results (%lu BSSes)",
|
|
|
|
len, (unsigned long)res->num);
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2009-05-21 10:34:54 +02:00
|
|
|
return res;
|
2008-02-28 02:34:43 +01:00
|
|
|
}
|
|
|
|
|
2010-02-13 12:50:19 +01:00
|
|
|
static int wpa_driver_bsd_capa(struct bsd_driver_data *drv)
|
2010-02-08 20:33:59 +01:00
|
|
|
{
|
2010-02-16 18:47:00 +01:00
|
|
|
#ifdef IEEE80211_IOC_DEVCAPS
|
|
|
|
/* kernel definitions copied from net80211/ieee80211_var.h */
|
|
|
|
#define IEEE80211_CIPHER_WEP 0
|
|
|
|
#define IEEE80211_CIPHER_TKIP 1
|
|
|
|
#define IEEE80211_CIPHER_AES_CCM 3
|
|
|
|
#define IEEE80211_CRYPTO_WEP (1<<IEEE80211_CIPHER_WEP)
|
|
|
|
#define IEEE80211_CRYPTO_TKIP (1<<IEEE80211_CIPHER_TKIP)
|
|
|
|
#define IEEE80211_CRYPTO_AES_CCM (1<<IEEE80211_CIPHER_AES_CCM)
|
|
|
|
#define IEEE80211_C_HOSTAP 0x00000400 /* CAPABILITY: HOSTAP avail */
|
|
|
|
#define IEEE80211_C_WPA1 0x00800000 /* CAPABILITY: WPA1 avail */
|
|
|
|
#define IEEE80211_C_WPA2 0x01000000 /* CAPABILITY: WPA2 avail */
|
|
|
|
struct ieee80211_devcaps_req devcaps;
|
|
|
|
|
|
|
|
if (get80211var(drv, IEEE80211_IOC_DEVCAPS, &devcaps,
|
|
|
|
sizeof(devcaps)) < 0) {
|
|
|
|
wpa_printf(MSG_ERROR, "failed to IEEE80211_IOC_DEVCAPS: %s",
|
|
|
|
strerror(errno));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: drivercaps=0x%08x,cryptocaps=0x%08x",
|
|
|
|
__func__, devcaps.dc_drivercaps, devcaps.dc_cryptocaps);
|
|
|
|
|
|
|
|
if (devcaps.dc_drivercaps & IEEE80211_C_WPA1)
|
|
|
|
drv->capa.key_mgmt = WPA_DRIVER_CAPA_KEY_MGMT_WPA |
|
|
|
|
WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK;
|
|
|
|
if (devcaps.dc_drivercaps & IEEE80211_C_WPA2)
|
|
|
|
drv->capa.key_mgmt = WPA_DRIVER_CAPA_KEY_MGMT_WPA2 |
|
|
|
|
WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK;
|
|
|
|
|
|
|
|
if (devcaps.dc_cryptocaps & IEEE80211_CRYPTO_WEP)
|
|
|
|
drv->capa.enc |= WPA_DRIVER_CAPA_ENC_WEP40 |
|
|
|
|
WPA_DRIVER_CAPA_ENC_WEP104;
|
|
|
|
if (devcaps.dc_cryptocaps & IEEE80211_CRYPTO_TKIP)
|
|
|
|
drv->capa.enc |= WPA_DRIVER_CAPA_ENC_TKIP;
|
|
|
|
if (devcaps.dc_cryptocaps & IEEE80211_CRYPTO_AES_CCM)
|
|
|
|
drv->capa.enc |= WPA_DRIVER_CAPA_ENC_CCMP;
|
|
|
|
|
|
|
|
if (devcaps.dc_drivercaps & IEEE80211_C_HOSTAP)
|
|
|
|
drv->capa.flags |= WPA_DRIVER_FLAGS_AP;
|
|
|
|
#undef IEEE80211_CIPHER_WEP
|
|
|
|
#undef IEEE80211_CIPHER_TKIP
|
|
|
|
#undef IEEE80211_CIPHER_AES_CCM
|
|
|
|
#undef IEEE80211_CRYPTO_WEP
|
|
|
|
#undef IEEE80211_CRYPTO_TKIP
|
|
|
|
#undef IEEE80211_CRYPTO_AES_CCM
|
|
|
|
#undef IEEE80211_C_HOSTAP
|
|
|
|
#undef IEEE80211_C_WPA1
|
|
|
|
#undef IEEE80211_C_WPA2
|
|
|
|
#else /* IEEE80211_IOC_DEVCAPS */
|
2010-02-08 20:33:59 +01:00
|
|
|
/* For now, assume TKIP, CCMP, WPA, WPA2 are supported */
|
|
|
|
drv->capa.key_mgmt = WPA_DRIVER_CAPA_KEY_MGMT_WPA |
|
|
|
|
WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK |
|
|
|
|
WPA_DRIVER_CAPA_KEY_MGMT_WPA2 |
|
|
|
|
WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK;
|
|
|
|
drv->capa.enc = WPA_DRIVER_CAPA_ENC_WEP40 |
|
|
|
|
WPA_DRIVER_CAPA_ENC_WEP104 |
|
|
|
|
WPA_DRIVER_CAPA_ENC_TKIP |
|
|
|
|
WPA_DRIVER_CAPA_ENC_CCMP;
|
2010-02-16 18:47:00 +01:00
|
|
|
drv->capa.flags |= WPA_DRIVER_FLAGS_AP;
|
|
|
|
#endif /* IEEE80211_IOC_DEVCAPS */
|
2010-02-13 12:57:39 +01:00
|
|
|
#ifdef IEEE80211_IOC_SCAN_MAX_SSID
|
|
|
|
drv->capa.max_scan_ssids = IEEE80211_IOC_SCAN_MAX_SSID;
|
2010-02-16 18:47:00 +01:00
|
|
|
#else /* IEEE80211_IOC_SCAN_MAX_SSID */
|
|
|
|
drv->capa.max_scan_ssids = 1;
|
2010-02-13 12:57:39 +01:00
|
|
|
#endif /* IEEE80211_IOC_SCAN_MAX_SSID */
|
2010-02-16 18:47:00 +01:00
|
|
|
drv->capa.auth = WPA_DRIVER_AUTH_OPEN |
|
|
|
|
WPA_DRIVER_AUTH_SHARED |
|
|
|
|
WPA_DRIVER_AUTH_LEAP;
|
2010-02-08 20:33:59 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-02-02 22:06:14 +01:00
|
|
|
static enum ieee80211_opmode
|
|
|
|
get80211opmode(struct bsd_driver_data *drv)
|
|
|
|
{
|
|
|
|
struct ifmediareq ifmr;
|
|
|
|
|
|
|
|
(void) memset(&ifmr, 0, sizeof(ifmr));
|
|
|
|
(void) os_strlcpy(ifmr.ifm_name, drv->ifname, sizeof(ifmr.ifm_name));
|
|
|
|
|
2016-01-09 02:39:43 +01:00
|
|
|
if (ioctl(drv->global->sock, SIOCGIFMEDIA, (caddr_t)&ifmr) >= 0) {
|
2014-02-02 22:06:14 +01:00
|
|
|
if (ifmr.ifm_current & IFM_IEEE80211_ADHOC) {
|
|
|
|
if (ifmr.ifm_current & IFM_FLAG0)
|
|
|
|
return IEEE80211_M_AHDEMO;
|
|
|
|
else
|
|
|
|
return IEEE80211_M_IBSS;
|
|
|
|
}
|
|
|
|
if (ifmr.ifm_current & IFM_IEEE80211_HOSTAP)
|
|
|
|
return IEEE80211_M_HOSTAP;
|
|
|
|
if (ifmr.ifm_current & IFM_IEEE80211_MONITOR)
|
|
|
|
return IEEE80211_M_MONITOR;
|
|
|
|
#ifdef IEEE80211_M_MBSS
|
|
|
|
if (ifmr.ifm_current & IFM_IEEE80211_MBSS)
|
|
|
|
return IEEE80211_M_MBSS;
|
|
|
|
#endif /* IEEE80211_M_MBSS */
|
|
|
|
}
|
|
|
|
return IEEE80211_M_STA;
|
|
|
|
}
|
|
|
|
|
2008-02-28 02:34:43 +01:00
|
|
|
static void *
|
2016-01-09 02:39:43 +01:00
|
|
|
wpa_driver_bsd_init(void *ctx, const char *ifname, void *priv)
|
2008-02-28 02:34:43 +01:00
|
|
|
{
|
|
|
|
#define GETPARAM(drv, param, v) \
|
|
|
|
(((v) = get80211param(drv, param)) != -1)
|
2010-02-13 12:50:19 +01:00
|
|
|
struct bsd_driver_data *drv;
|
2008-02-28 02:34:43 +01:00
|
|
|
|
|
|
|
drv = os_zalloc(sizeof(*drv));
|
|
|
|
if (drv == NULL)
|
|
|
|
return NULL;
|
2014-01-07 14:56:06 +01:00
|
|
|
|
2008-02-28 02:34:43 +01:00
|
|
|
/*
|
|
|
|
* NB: We require the interface name be mappable to an index.
|
|
|
|
* This implies we do not support having wpa_supplicant
|
|
|
|
* wait for an interface to appear. This seems ok; that
|
|
|
|
* doesn't belong here; it's really the job of devd.
|
|
|
|
*/
|
|
|
|
drv->ifindex = if_nametoindex(ifname);
|
|
|
|
if (drv->ifindex == 0) {
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: interface %s does not exist",
|
|
|
|
__func__, ifname);
|
2016-01-09 02:39:43 +01:00
|
|
|
goto fail;
|
2008-02-28 02:34:43 +01:00
|
|
|
}
|
2016-01-09 02:39:43 +01:00
|
|
|
|
|
|
|
drv->ctx = ctx;
|
|
|
|
drv->global = priv;
|
2013-08-07 10:01:12 +02:00
|
|
|
os_strlcpy(drv->ifname, ifname, sizeof(drv->ifname));
|
|
|
|
|
2008-02-28 02:34:43 +01:00
|
|
|
if (!GETPARAM(drv, IEEE80211_IOC_ROAMING, drv->prev_roaming)) {
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: failed to get roaming state: %s",
|
|
|
|
__func__, strerror(errno));
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
if (!GETPARAM(drv, IEEE80211_IOC_PRIVACY, drv->prev_privacy)) {
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: failed to get privacy state: %s",
|
|
|
|
__func__, strerror(errno));
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
if (!GETPARAM(drv, IEEE80211_IOC_WPA, drv->prev_wpa)) {
|
|
|
|
wpa_printf(MSG_DEBUG, "%s: failed to get wpa state: %s",
|
|
|
|
__func__, strerror(errno));
|
|
|
|
goto fail;
|
|
|
|
}
|
2010-02-08 20:14:22 +01:00
|
|
|
|
2010-02-08 20:33:59 +01:00
|
|
|
if (wpa_driver_bsd_capa(drv))
|
2008-02-28 02:34:43 +01:00
|
|
|
goto fail;
|
2009-11-23 19:22:38 +01:00
|
|
|
|
2016-03-15 11:39:24 +01:00
|
|
|
/* Down interface during setup. */
|
|
|
|
if (bsd_ctrl_iface(drv, 0) < 0)
|
|
|
|
goto fail;
|
|
|
|
|
2013-08-07 09:57:10 +02:00
|
|
|
drv->opmode = get80211opmode(drv);
|
2016-01-09 02:39:43 +01:00
|
|
|
dl_list_add(&drv->global->ifaces, &drv->list);
|
2013-08-07 09:57:10 +02:00
|
|
|
|
2008-02-28 02:34:43 +01:00
|
|
|
return drv;
|
|
|
|
fail:
|
|
|
|
os_free(drv);
|
|
|
|
return NULL;
|
|
|
|
#undef GETPARAM
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wpa_driver_bsd_deinit(void *priv)
|
|
|
|
{
|
2010-02-13 12:50:19 +01:00
|
|
|
struct bsd_driver_data *drv = priv;
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2016-03-15 14:02:08 +01:00
|
|
|
if (drv->ifindex != 0 && !drv->if_removed) {
|
2016-01-20 18:13:12 +01:00
|
|
|
wpa_driver_bsd_set_wpa(drv, 0);
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2016-01-20 18:13:12 +01:00
|
|
|
/* NB: mark interface down */
|
|
|
|
bsd_ctrl_iface(drv, 0);
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2016-01-20 18:13:12 +01:00
|
|
|
wpa_driver_bsd_set_wpa_internal(drv, drv->prev_wpa,
|
|
|
|
drv->prev_privacy);
|
2016-01-09 02:39:43 +01:00
|
|
|
|
2016-01-20 18:13:12 +01:00
|
|
|
if (set80211param(drv, IEEE80211_IOC_ROAMING, drv->prev_roaming)
|
|
|
|
< 0)
|
|
|
|
wpa_printf(MSG_DEBUG,
|
|
|
|
"%s: failed to restore roaming state",
|
|
|
|
__func__);
|
|
|
|
}
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2010-02-08 20:33:59 +01:00
|
|
|
if (drv->sock_xmit != NULL)
|
|
|
|
l2_packet_deinit(drv->sock_xmit);
|
2016-01-09 02:39:43 +01:00
|
|
|
dl_list_del(&drv->list);
|
2008-02-28 02:34:43 +01:00
|
|
|
os_free(drv);
|
|
|
|
}
|
|
|
|
|
2010-02-08 20:33:59 +01:00
|
|
|
static int
|
|
|
|
wpa_driver_bsd_get_capa(void *priv, struct wpa_driver_capa *capa)
|
|
|
|
{
|
2010-02-13 12:50:19 +01:00
|
|
|
struct bsd_driver_data *drv = priv;
|
2010-02-08 20:33:59 +01:00
|
|
|
|
|
|
|
os_memcpy(capa, &drv->capa, sizeof(*capa));
|
|
|
|
return 0;
|
|
|
|
}
|
2010-02-13 12:52:03 +01:00
|
|
|
#endif /* HOSTAPD */
|
2010-02-08 20:33:59 +01:00
|
|
|
|
2016-01-09 02:39:43 +01:00
|
|
|
static void *
|
2016-03-15 14:02:08 +01:00
|
|
|
bsd_global_init(void *ctx)
|
2016-01-09 02:39:43 +01:00
|
|
|
{
|
|
|
|
struct bsd_driver_global *global;
|
2019-09-18 13:50:36 +02:00
|
|
|
#if defined(RO_MSGFILTER) || defined(ROUTE_MSGFILTER)
|
|
|
|
unsigned char msgfilter[] = {
|
|
|
|
RTM_IEEE80211,
|
|
|
|
#ifndef HOSTAPD
|
|
|
|
RTM_IFINFO, RTM_IFANNOUNCE,
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
#ifdef ROUTE_MSGFILTER
|
|
|
|
unsigned int i, msgfilter_mask;
|
|
|
|
#endif
|
2016-01-09 02:39:43 +01:00
|
|
|
|
|
|
|
global = os_zalloc(sizeof(*global));
|
|
|
|
if (global == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2016-03-15 14:02:08 +01:00
|
|
|
global->ctx = ctx;
|
2016-01-09 02:39:43 +01:00
|
|
|
dl_list_init(&global->ifaces);
|
|
|
|
|
|
|
|
global->sock = socket(PF_INET, SOCK_DGRAM, 0);
|
|
|
|
if (global->sock < 0) {
|
|
|
|
wpa_printf(MSG_ERROR, "socket[PF_INET,SOCK_DGRAM]: %s",
|
|
|
|
strerror(errno));
|
|
|
|
goto fail1;
|
|
|
|
}
|
|
|
|
|
|
|
|
global->route = socket(PF_ROUTE, SOCK_RAW, 0);
|
|
|
|
if (global->route < 0) {
|
|
|
|
wpa_printf(MSG_ERROR, "socket[PF_ROUTE,SOCK_RAW]: %s",
|
|
|
|
strerror(errno));
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2019-09-18 13:50:36 +02:00
|
|
|
#if defined(RO_MSGFILTER)
|
|
|
|
if (setsockopt(global->route, PF_ROUTE, RO_MSGFILTER,
|
|
|
|
&msgfilter, sizeof(msgfilter)) < 0)
|
|
|
|
wpa_printf(MSG_ERROR, "socket[PF_ROUTE,RO_MSGFILTER]: %s",
|
|
|
|
strerror(errno));
|
|
|
|
#elif defined(ROUTE_MSGFILTER)
|
|
|
|
msgfilter_mask = 0;
|
|
|
|
for (i = 0; i < (sizeof(msgfilter) / sizeof(msgfilter[0])); i++)
|
|
|
|
msgfilter_mask |= ROUTE_FILTER(msgfilter[i]);
|
|
|
|
if (setsockopt(global->route, PF_ROUTE, ROUTE_MSGFILTER,
|
|
|
|
&msgfilter_mask, sizeof(msgfilter_mask)) < 0)
|
|
|
|
wpa_printf(MSG_ERROR, "socket[PF_ROUTE,ROUTE_MSGFILTER]: %s",
|
|
|
|
strerror(errno));
|
|
|
|
#endif
|
|
|
|
|
2016-01-09 02:39:43 +01:00
|
|
|
global->event_buf_len = rtbuf_len();
|
|
|
|
global->event_buf = os_malloc(global->event_buf_len);
|
|
|
|
if (global->event_buf == NULL) {
|
|
|
|
wpa_printf(MSG_ERROR, "%s: os_malloc() failed", __func__);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HOSTAPD
|
|
|
|
eloop_register_read_sock(global->route, bsd_wireless_event_receive,
|
|
|
|
NULL, global);
|
|
|
|
|
|
|
|
#else /* HOSTAPD */
|
|
|
|
eloop_register_read_sock(global->route, wpa_driver_bsd_event_receive,
|
|
|
|
NULL, global);
|
|
|
|
#endif /* HOSTAPD */
|
|
|
|
|
|
|
|
return global;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
close(global->sock);
|
|
|
|
fail1:
|
|
|
|
os_free(global);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
bsd_global_deinit(void *priv)
|
|
|
|
{
|
|
|
|
struct bsd_driver_global *global = priv;
|
|
|
|
|
|
|
|
eloop_unregister_read_sock(global->route);
|
|
|
|
(void) close(global->route);
|
|
|
|
(void) close(global->sock);
|
|
|
|
os_free(global);
|
|
|
|
}
|
|
|
|
|
2008-02-28 02:34:43 +01:00
|
|
|
|
|
|
|
const struct wpa_driver_ops wpa_driver_bsd_ops = {
|
|
|
|
.name = "bsd",
|
2009-05-29 21:38:55 +02:00
|
|
|
.desc = "BSD 802.11 support",
|
2016-01-09 02:39:43 +01:00
|
|
|
.global_init = bsd_global_init,
|
|
|
|
.global_deinit = bsd_global_deinit,
|
2010-02-13 12:52:03 +01:00
|
|
|
#ifdef HOSTAPD
|
|
|
|
.hapd_init = bsd_init,
|
|
|
|
.hapd_deinit = bsd_deinit,
|
|
|
|
.set_privacy = bsd_set_privacy,
|
|
|
|
.get_seqnum = bsd_get_seqnum,
|
|
|
|
.flush = bsd_flush,
|
|
|
|
.read_sta_data = bsd_read_sta_driver_data,
|
|
|
|
.sta_disassoc = bsd_sta_disassoc,
|
|
|
|
.sta_deauth = bsd_sta_deauth,
|
2013-08-07 10:02:55 +02:00
|
|
|
.sta_set_flags = bsd_set_sta_authorized,
|
2013-08-07 10:03:44 +02:00
|
|
|
.commit = bsd_commit,
|
2010-02-13 12:52:03 +01:00
|
|
|
#else /* HOSTAPD */
|
2016-01-09 02:39:43 +01:00
|
|
|
.init2 = wpa_driver_bsd_init,
|
2008-02-28 02:34:43 +01:00
|
|
|
.deinit = wpa_driver_bsd_deinit,
|
|
|
|
.get_bssid = wpa_driver_bsd_get_bssid,
|
|
|
|
.get_ssid = wpa_driver_bsd_get_ssid,
|
|
|
|
.set_countermeasures = wpa_driver_bsd_set_countermeasures,
|
2009-11-23 20:13:46 +01:00
|
|
|
.scan2 = wpa_driver_bsd_scan,
|
2009-05-21 10:34:54 +02:00
|
|
|
.get_scan_results2 = wpa_driver_bsd_get_scan_results2,
|
2008-02-28 02:34:43 +01:00
|
|
|
.deauthenticate = wpa_driver_bsd_deauthenticate,
|
|
|
|
.associate = wpa_driver_bsd_associate,
|
2010-02-08 20:33:59 +01:00
|
|
|
.get_capa = wpa_driver_bsd_get_capa,
|
2009-04-09 12:40:12 +02:00
|
|
|
#endif /* HOSTAPD */
|
2010-05-23 11:20:33 +02:00
|
|
|
.set_freq = bsd_set_freq,
|
2010-02-13 12:52:03 +01:00
|
|
|
.set_key = bsd_set_key,
|
|
|
|
.set_ieee8021x = bsd_set_ieee8021x,
|
|
|
|
.hapd_set_ssid = bsd_set_ssid,
|
|
|
|
.hapd_get_ssid = bsd_get_ssid,
|
|
|
|
.hapd_send_eapol = bsd_send_eapol,
|
2010-02-13 12:57:39 +01:00
|
|
|
.set_generic_elem = bsd_set_opt_ie,
|
2010-02-13 12:52:03 +01:00
|
|
|
};
|