/*
* Driver interaction with Linux nl80211/cfg80211
* Copyright (c) 2002-2015, Jouni Malinen <[email protected]>
* Copyright (c) 2003-2004, Instant802 Networks, Inc.
* Copyright (c) 2005-2006, Devicescape Software, Inc.
* Copyright (c) 2007, Johannes Berg <[email protected]>
* Copyright (c) 2009-2010, Atheros Communications
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
*/
#include "includes.h"
#include <sys/types.h>
#include <fcntl.h>
#include <net/if.h>
#include <netlink/genl/genl.h>
#include <netlink/genl/ctrl.h>
#ifdef CONFIG_LIBNL3_ROUTE
#include <netlink/route/neighbour.h>
#endif /* CONFIG_LIBNL3_ROUTE */
#include <linux/rtnetlink.h>
#include <netpacket/packet.h>
#include <linux/errqueue.h>
#include "common.h"
#include "eloop.h"
#include "common/qca-vendor.h"
#include "common/qca-vendor-attr.h"
#include "common/brcm_vendor.h"
#include "common/ieee802_11_defs.h"
#include "common/ieee802_11_common.h"
#include "common/wpa_common.h"
#include "netlink.h"
#include "linux_defines.h"
#include "linux_ioctl.h"
#include "radiotap.h"
#include "radiotap_iter.h"
#include "rfkill.h"
#include "driver_nl80211.h"
#ifndef NETLINK_CAP_ACK
#define NETLINK_CAP_ACK 10
#endif /* NETLINK_CAP_ACK */
/* support for extack if compilation headers are too old */
#ifndef NETLINK_EXT_ACK
#define NETLINK_EXT_ACK 11
enum nlmsgerr_attrs {
NLMSGERR_ATTR_UNUSED,
NLMSGERR_ATTR_MSG,
NLMSGERR_ATTR_OFFS,
NLMSGERR_ATTR_COOKIE,
__NLMSGERR_ATTR_MAX,
NLMSGERR_ATTR_MAX = __NLMSGERR_ATTR_MAX - 1
};
#endif
#ifndef NLM_F_CAPPED
#define NLM_F_CAPPED 0x100
#endif
#ifndef NLM_F_ACK_TLVS
#define NLM_F_ACK_TLVS 0x200
#endif
#ifndef SOL_NETLINK
#define SOL_NETLINK 270
#endif
#ifdef ANDROID
/* system/core/libnl_2 does not include nl_socket_set_nonblocking() */
#undef nl_socket_set_nonblocking
#define nl_socket_set_nonblocking(h) android_nl_socket_set_nonblocking(h)
#endif /* ANDROID */
static struct nl_sock * nl_create_handle(struct nl_cb *cb, const char *dbg)
{
struct nl_sock *handle;
handle = nl_socket_alloc_cb(cb);
if (handle == NULL) {
wpa_printf(MSG_ERROR, "nl80211: Failed to allocate netlink "
"callbacks (%s)", dbg);
return NULL;
}
if (genl_connect(handle)) {
wpa_printf(MSG_ERROR, "nl80211: Failed to connect to generic "
"netlink (%s)", dbg);
nl_socket_free(handle);
return NULL;
}
return handle;
}
static void nl_destroy_handles(struct nl_sock **handle)
{
if (*handle == NULL)
return;
nl_socket_free(*handle);
*handle = NULL;
}
#if __WORDSIZE == 64
#define ELOOP_SOCKET_INVALID (intptr_t) 0x8888888888888889ULL
#else
#define ELOOP_SOCKET_INVALID (intptr_t) 0x88888889ULL
#endif
static void nl80211_register_eloop_read(struct nl_sock **handle,
eloop_sock_handler handler,
void *eloop_data, int persist)
{
/*
* libnl uses a pretty small buffer (32 kB that gets converted to 64 kB)
* by default. It is possible to hit that limit in some cases where
* operations are blocked, e.g., with a burst of Deauthentication frames
* to hostapd and STA entry deletion. Try to increase the buffer to make
* this less likely to occur.
*/
int err;
err = nl_socket_set_buffer_size(*handle, 262144, 0);
if (err < 0) {
wpa_printf(MSG_DEBUG,
"nl80211: Could not set nl_socket RX buffer size: %s",
nl_geterror(err));
/* continue anyway with the default (smaller) buffer */
}
nl_socket_set_nonblocking(*handle);
eloop_register_read_sock(nl_socket_get_fd(*handle), handler,
eloop_data, *handle);
if (!persist)
*handle = (void *) (((intptr_t) *handle) ^
ELOOP_SOCKET_INVALID);
}
static void nl80211_destroy_eloop_handle(struct nl_sock **handle, int persist)
{
if (!persist)
*handle = (void *) (((intptr_t) *handle) ^
ELOOP_SOCKET_INVALID);
eloop_unregister_read_sock(nl_socket_get_fd(*handle));
nl_destroy_handles(handle);
}
static void nl80211_global_deinit(void *priv);
static void nl80211_check_global(struct nl80211_global *global);
static void wpa_driver_nl80211_deinit(struct i802_bss *bss);
static int wpa_driver_nl80211_set_mode_ibss(struct i802_bss *bss,
struct hostapd_freq_params *freq);
static int
wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv,
const u8 *set_addr, int first,
const char *driver_params);
static int nl80211_send_frame_cmd(struct i802_bss *bss,
unsigned int freq, unsigned int wait,
const u8 *buf, size_t buf_len,
int save_cookie,
int no_cck, int no_ack, int offchanok,
const u16 *csa_offs, size_t csa_offs_len);
static int wpa_driver_nl80211_probe_req_report(struct i802_bss *bss,
int report);
#define IFIDX_ANY -1
static void add_ifidx(struct wpa_driver_nl80211_data *drv, int ifidx,
int ifidx_reason);
static void del_ifidx(struct wpa_driver_nl80211_data *drv, int ifidx,
int ifidx_reason);
static int have_ifidx(struct wpa_driver_nl80211_data *drv, int ifidx,
int ifidx_reason);
static int nl80211_set_channel(struct i802_bss *bss,
struct hostapd_freq_params *freq, int set_chan);
static int nl80211_disable_11b_rates(struct wpa_driver_nl80211_data *drv,
int ifindex, int disabled);
static int nl80211_leave_ibss(struct wpa_driver_nl80211_data *drv,
int reset_mode);
static int i802_set_iface_flags(struct i802_bss *bss, int up);
static int nl80211_set_param(void *priv, const char *param);
#ifdef CONFIG_MESH
static int nl80211_put_mesh_config(struct nl_msg *msg,
struct wpa_driver_mesh_bss_params *params);
#endif /* CONFIG_MESH */
static int i802_sta_disassoc(void *priv, const u8 *own_addr, const u8 *addr,
u16 reason);
/* Converts nl80211_chan_width to a common format */
enum chan_width convert2width(int width)
{
switch (width) {
case NL80211_CHAN_WIDTH_20_NOHT:
return CHAN_WIDTH_20_NOHT;
case NL80211_CHAN_WIDTH_20:
return CHAN_WIDTH_20;
case NL80211_CHAN_WIDTH_40:
return CHAN_WIDTH_40;
case NL80211_CHAN_WIDTH_80:
return CHAN_WIDTH_80;
case NL80211_CHAN_WIDTH_80P80:
return CHAN_WIDTH_80P80;
case NL80211_CHAN_WIDTH_160:
return CHAN_WIDTH_160;
}
return CHAN_WIDTH_UNKNOWN;
}
int is_ap_interface(enum nl80211_iftype nlmode)
{
return nlmode == NL80211_IFTYPE_AP ||
nlmode == NL80211_IFTYPE_P2P_GO;
}
int is_sta_interface(enum nl80211_iftype nlmode)
{
return nlmode == NL80211_IFTYPE_STATION ||
nlmode == NL80211_IFTYPE_P2P_CLIENT;
}
static int is_p2p_net_interface(enum nl80211_iftype nlmode)
{
return nlmode == NL80211_IFTYPE_P2P_CLIENT ||
nlmode == NL80211_IFTYPE_P2P_GO;
}
struct i802_bss * get_bss_ifindex(struct wpa_driver_nl80211_data *drv,
int ifindex)
{
struct i802_bss *bss;
for (bss = drv->first_bss; bss; bss = bss->next) {
if (bss->ifindex == ifindex)
return bss;
}
return NULL;
}
static int is_mesh_interface(enum nl80211_iftype nlmode)
{
return nlmode == NL80211_IFTYPE_MESH_POINT;
}
void nl80211_mark_disconnected(struct wpa_driver_nl80211_data *drv)
{
if (drv->associated)
os_memcpy(drv->prev_bssid, drv->bssid, ETH_ALEN);
drv->associated = 0;
os_memset(drv->bssid, 0, ETH_ALEN);
drv->first_bss->freq = 0;
}
/* nl80211 code */
static int ack_handler(struct nl_msg *msg, void *arg)
{
int *err = arg;
*err = 0;
return NL_STOP;
}
struct nl80211_ack_ext_arg {
int *err;
void *ext_data;
};
static int ack_handler_cookie(struct nl_msg *msg, void *arg)
{
struct nl80211_ack_ext_arg *ext_arg = arg;
struct nlattr *tb[NLMSGERR_ATTR_MAX + 1];
u64 *cookie = ext_arg->ext_data;
struct nlattr *attrs;
size_t ack_len, attr_len;
*ext_arg->err = 0;
ack_len = sizeof(struct nlmsghdr) + sizeof(int) +
sizeof(struct nlmsghdr);
attrs = (struct nlattr *)
((u8 *) nlmsg_data(nlmsg_hdr(msg)) + sizeof(struct nlmsghdr) +
sizeof(int));
if (nlmsg_hdr(msg)->nlmsg_len <= ack_len)
return NL_STOP;
attr_len = nlmsg_hdr(msg)->nlmsg_len - ack_len;
if(!(nlmsg_hdr(msg)->nlmsg_flags & NLM_F_ACK_TLVS))
return NL_STOP;
nla_parse(tb, N
没有合适的资源?快使用搜索试试~ 我知道了~
wpa-supplicant是跨平台的开源软件
共1837个文件
c:870个
h:584个
makefile:52个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 157 浏览量
2023-05-26
17:29:46
上传
评论
收藏 7.89MB ZIP 举报
温馨提示
wpa_supplicant是跨平台的开源软件,支持WPA、WPA2、WPA3(IEEE 802.11i)等Wlan接入技术,可用于台式机、笔记本电脑、手机和其他嵌入式系统。 在OpenHarmony中,wpa_supplicant用来提供Wi-Fi接入和Wi-Fi热点开启的协议栈。
资源推荐
资源详情
资源评论
收起资源包目录
wpa-supplicant是跨平台的开源软件 (1837个子文件)
hostapd_cli.1 2KB
hostapd_cli.1 2KB
60_wpa_supplicant 267B
60_wpa_supplicant 267B
hostapd.8 1KB
hostapd.8 1KB
hostapd.accept 276B
hostapd.accept 276B
ISupplicant.aidl 2KB
ISupplicant.aidl 2KB
ISupplicantCallbacks.aidl 599B
ISupplicantCallbacks.aidl 599B
IIface.aidl 411B
IIface.aidl 411B
ohos.build 899B
driver_nl80211.c 333KB
ctrl_iface.c 321KB
driver_nl80211.c 300KB
p2p_supplicant.c 287KB
ctrl_iface.c 278KB
p2p_supplicant.c 272KB
dpp.c 262KB
wpa_supplicant.c 238KB
wpa_supplicant.c 207KB
ieee802_11.c 204KB
dbus_new_handlers.c 164KB
events.c 159KB
wpa_auth.c 153KB
ieee802_11.c 149KB
dbus_new_handlers.c 147KB
p2p.c 146KB
tls_openssl.c 144KB
wpa.c 144KB
p2p.c 143KB
wpa_auth.c 140KB
tls_openssl.c 138KB
ap_config_file.c 137KB
events.c 136KB
dbus_new.c 132KB
config.c 132KB
wpa_cli.c 131KB
wpa.c 130KB
ap_config_file.c 129KB
ap_ctrl_iface.c 129KB
dbus_new.c 128KB
wpa_auth_ft.c 127KB
wpa_cli.c 122KB
wpa_auth_ft.c 121KB
config.c 119KB
ap_ctrl_iface.c 111KB
dpp_supplicant.c 109KB
dpp.c 107KB
ieee802_1x_kay.c 106KB
ieee802_1x_kay.c 105KB
wps_registrar.c 102KB
wps_registrar.c 101KB
wpa_common.c 100KB
hostapd.c 95KB
driver_nl80211_event.c 93KB
scan.c 90KB
hostapd.c 90KB
osu_client.c 88KB
osu_client.c 88KB
eap.c 87KB
eap.c 85KB
sme.c 85KB
driver_ndis.c 85KB
driver_ndis.c 84KB
tdls.c 84KB
ieee802_1x.c 83KB
dbus_new_handlers_p2p.c 83KB
interworking.c 83KB
tdls.c 82KB
ieee802_1x.c 82KB
interworking.c 82KB
dbus_new_handlers_p2p.c 81KB
wps_supplicant.c 81KB
scan.c 81KB
wps_supplicant.c 79KB
driver_nl80211_event.c 79KB
radius_server.c 77KB
libtommath.c 76KB
libtommath.c 76KB
dpp_hostapd.c 75KB
sme.c 74KB
radius_server.c 71KB
driver_nl80211_capa.c 70KB
wpa_common.c 69KB
crypto_openssl.c 68KB
sae.c 66KB
crypto_module_tests.c 66KB
dpp_crypto.c 65KB
ieee802_11_common.c 65KB
driver_wext.c 65KB
driver_wext.c 64KB
dpp_supplicant.c 64KB
driver_atheros.c 64KB
driver_nl80211_capa.c 63KB
driver_atheros.c 63KB
wpa_hal.c 63KB
共 1837 条
- 1
- 2
- 3
- 4
- 5
- 6
- 19
资源评论
Java程序员-张凯
- 粉丝: 1w+
- 资源: 6732
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功