diff --git a/wpa_supplicant/Android.mk b/wpa_supplicant/Android.mk new file mode 100644 index 0000000..e314dd7 --- /dev/null +++ b/wpa_supplicant/Android.mk @@ -0,0 +1,66 @@ +# +# Copyright (C) 2008 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +LOCAL_PATH := $(call my-dir) + +ifeq ($(WPA_SUPPLICANT_VERSION),VER_0_8_X) +$(warning Build wpa_supplicant_lib...) +ifneq ($(BOARD_WPA_SUPPLICANT_DRIVER),) + CONFIG_DRIVER_$(BOARD_WPA_SUPPLICANT_DRIVER) := y +endif + +WPA_SUPPL_DIR = external/wpa_supplicant_8 +WPA_SRC_FILE := + +include $(WPA_SUPPL_DIR)/wpa_supplicant/android.config + +WPA_SUPPL_DIR_INCLUDE = $(WPA_SUPPL_DIR)/src \ + $(WPA_SUPPL_DIR)/src/common \ + $(WPA_SUPPL_DIR)/src/drivers \ + $(WPA_SUPPL_DIR)/src/l2_packet \ + $(WPA_SUPPL_DIR)/src/utils \ + $(WPA_SUPPL_DIR)/src/wps \ + $(WPA_SUPPL_DIR)/wpa_supplicant \ + external/libnl/include + +ifdef CONFIG_DRIVER_NL80211 +WPA_SUPPL_DIR_INCLUDE += external/libnl-headers +WPA_SRC_FILE += mediatek_driver_cmd_nl80211.c +endif + +ifdef CONFIG_DRIVER_WEXT +#error doesn't support CONFIG_DRIVER_WEXT +endif + +# To force sizeof(enum) = 4 +L_CFLAGS += -mabi=aapcs-linux + +ifdef CONFIG_ANDROID_LOG +L_CFLAGS += -DCONFIG_ANDROID_LOG +endif + +######################## + +include $(CLEAR_VARS) +LOCAL_MODULE := lib_driver_cmd_mt66xx +LOCAL_SHARED_LIBRARIES := libc libcutils +LOCAL_CFLAGS := $(L_CFLAGS) +LOCAL_SRC_FILES := $(WPA_SRC_FILE) +LOCAL_C_INCLUDES := $(WPA_SUPPL_DIR_INCLUDE) +include $(BUILD_STATIC_LIBRARY) + +######################## + +endif diff --git a/wpa_supplicant/mediatek_driver_cmd_nl80211.c b/wpa_supplicant/mediatek_driver_cmd_nl80211.c new file mode 100644 index 0000000..ba79633 --- /dev/null +++ b/wpa_supplicant/mediatek_driver_cmd_nl80211.c @@ -0,0 +1,439 @@ +/* + * Driver interaction with extended Linux CFG8021 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Alternatively, this software may be distributed under the terms of BSD + * license. + * + */ + +#include "mediatek_driver_nl80211.h" +#include "wpa_supplicant_i.h" +#include "config.h" +#include "driver_i.h" + +#ifdef ANDROID +#include "android_drv.h" +#endif + +int send_and_recv_msgs(struct wpa_driver_nl80211_data *drv, struct nl_msg *msg, + int (*valid_handler)(struct nl_msg *, void *), + void *valid_data); + +static int testmode_sta_statistics_handler(struct nl_msg *msg, void *arg) +{ + struct nlattr *tb[NL80211_ATTR_MAX + 1]; + struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); + struct nlattr *sinfo[NL80211_TESTMODE_STA_STATISTICS_NUM]; + struct wpa_driver_sta_statistics_s *sta_statistics = (struct wpa_driver_sta_statistics_s *)arg; + unsigned char i = 0; + static struct nla_policy policy[NL80211_TESTMODE_STA_STATISTICS_NUM] = { + [NL80211_TESTMODE_STA_STATISTICS_VERSION] = { .type = NLA_U8 }, + [NL80211_TESTMODE_STA_STATISTICS_MAC] = { .type = NLA_UNSPEC }, + [NL80211_TESTMODE_STA_STATISTICS_LINK_SCORE] = { .type = NLA_U8 }, + [NL80211_TESTMODE_STA_STATISTICS_FLAG] = { .type = NLA_U32 }, + [NL80211_TESTMODE_STA_STATISTICS_PER] = { .type = NLA_U8 }, + [NL80211_TESTMODE_STA_STATISTICS_RSSI] = { .type = NLA_U8 }, + [NL80211_TESTMODE_STA_STATISTICS_PHY_MODE] = { .type = NLA_U32 }, + [NL80211_TESTMODE_STA_STATISTICS_TX_RATE] = { .type = NLA_U16 }, + [NL80211_TESTMODE_STA_STATISTICS_FAIL_CNT] = { .type = NLA_U32 }, + [NL80211_TESTMODE_STA_STATISTICS_TIMEOUT_CNT] = { .type = NLA_U32 }, + [NL80211_TESTMODE_STA_STATISTICS_AVG_AIR_TIME] = { .type = NLA_U32 }, + [NL80211_TESTMODE_STA_STATISTICS_TOTAL_CNT] = { .type = NLA_U32 }, + [NL80211_TESTMODE_STA_STATISTICS_THRESHOLD_CNT] = { .type = NLA_U32 }, + [NL80211_TESTMODE_STA_STATISTICS_AVG_PROCESS_TIME] = { .type = NLA_U32 }, + [NL80211_TESTMODE_STA_STATISTICS_TC_EMPTY_CNT_ARRAY] = { .type = NLA_UNSPEC }, + [NL80211_TESTMODE_STA_STATISTICS_TC_QUE_LEN_ARRAY] = { .type = NLA_UNSPEC }, + [NL80211_TESTMODE_STA_STATISTICS_TC_AVG_QUE_LEN_ARRAY] = { .type = NLA_UNSPEC }, + [NL80211_TESTMODE_STA_STATISTICS_TC_CUR_QUE_LEN_ARRAY] = { .type = NLA_UNSPEC }, + [NL80211_TESTMODE_STA_STATISTICS_RESERVED_ARRAY] = { .type = NLA_UNSPEC } + }; + + nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), + genlmsg_attrlen(gnlh, 0), NULL); + + if (!tb[NL80211_ATTR_TESTDATA] || + nla_parse_nested(sinfo, NL80211_TESTMODE_STA_STATISTICS_MAX, tb[NL80211_ATTR_TESTDATA], policy)) + return NL_SKIP; + + for(i=1; i < NL80211_TESTMODE_STA_STATISTICS_NUM; i++) { + if(sinfo[i]) { + switch(i) { + case NL80211_TESTMODE_STA_STATISTICS_VERSION: + sta_statistics->version = nla_get_u8(sinfo[i]); + break; + case NL80211_TESTMODE_STA_STATISTICS_MAC: + nla_memcpy(sta_statistics->addr, sinfo[i], ETH_ALEN); + break; + case NL80211_TESTMODE_STA_STATISTICS_LINK_SCORE: + sta_statistics->link_score = nla_get_u8(sinfo[i]); + break; + case NL80211_TESTMODE_STA_STATISTICS_FLAG: + sta_statistics->flag = nla_get_u32(sinfo[i]); + break; + case NL80211_TESTMODE_STA_STATISTICS_PER: + sta_statistics->per = nla_get_u8(sinfo[i]); + break; + case NL80211_TESTMODE_STA_STATISTICS_RSSI: + sta_statistics->rssi = (((int)nla_get_u8(sinfo[i]) - 220) / 2); + break; + case NL80211_TESTMODE_STA_STATISTICS_PHY_MODE: + sta_statistics->phy_mode = nla_get_u32(sinfo[i]); + break; + case NL80211_TESTMODE_STA_STATISTICS_TX_RATE: + sta_statistics->tx_rate = (((double)nla_get_u16(sinfo[i])) / 2); + break; + case NL80211_TESTMODE_STA_STATISTICS_FAIL_CNT: + sta_statistics->tx_fail_cnt = nla_get_u32(sinfo[i]); + break; + case NL80211_TESTMODE_STA_STATISTICS_TIMEOUT_CNT: + sta_statistics->tx_timeout_cnt = nla_get_u32(sinfo[i]); + break; + case NL80211_TESTMODE_STA_STATISTICS_AVG_AIR_TIME: + sta_statistics->tx_avg_air_time = nla_get_u32(sinfo[i]); + break; + case NL80211_TESTMODE_STA_STATISTICS_TOTAL_CNT: + sta_statistics->tx_total_cnt = nla_get_u32(sinfo[i]); + break; + case NL80211_TESTMODE_STA_STATISTICS_THRESHOLD_CNT: + sta_statistics->tx_exc_threshold_cnt = nla_get_u32(sinfo[i]); + break; + case NL80211_TESTMODE_STA_STATISTICS_AVG_PROCESS_TIME: + sta_statistics->tx_avg_process_time = nla_get_u32(sinfo[i]); + break; + case NL80211_TESTMODE_STA_STATISTICS_TC_EMPTY_CNT_ARRAY: + nla_memcpy(sta_statistics->tc_buf_full_cnt, sinfo[i], sizeof(sta_statistics->tc_buf_full_cnt)); + break; + case NL80211_TESTMODE_STA_STATISTICS_TC_QUE_LEN_ARRAY: + nla_memcpy(sta_statistics->tc_que_len, sinfo[i], sizeof(sta_statistics->tc_que_len)); + break; + case NL80211_TESTMODE_STA_STATISTICS_TC_AVG_QUE_LEN_ARRAY: + nla_memcpy(sta_statistics->tc_avg_que_len, sinfo[i], sizeof(sta_statistics->tc_avg_que_len)); + break; + case NL80211_TESTMODE_STA_STATISTICS_TC_CUR_QUE_LEN_ARRAY: + nla_memcpy(sta_statistics->tc_cur_que_len, sinfo[i], sizeof(sta_statistics->tc_cur_que_len)); + break; + case NL80211_TESTMODE_STA_STATISTICS_RESERVED_ARRAY: + nla_memcpy(sta_statistics->reserved, sinfo[i], sizeof(sta_statistics->reserved)); + break; + default: + break; + } + } + } + + return NL_SKIP; +} + +static void * nl80211_cmd(struct wpa_driver_nl80211_data *drv, + struct nl_msg *msg, int flags, uint8_t cmd) +{ + return genlmsg_put(msg, 0, 0, drv->global->nl80211_id, + 0, flags, cmd, 0); +} + +static int wpa_driver_nl80211_testmode(void *priv, const u8 *data, + size_t data_len) +{ + struct i802_bss *bss = priv; + struct wpa_driver_nl80211_data *drv = bss->drv; + struct nl_msg *msg, *cqm = NULL; + struct wpa_driver_testmode_params *params; + int index; + + msg = nlmsg_alloc(); + if (!msg) + return -1; + + wpa_printf(MSG_DEBUG, "nl80211: Test Mode buflen = %d", data_len); + + nl80211_cmd(drv, msg, 0, NL80211_CMD_TESTMODE); + + NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, drv->ifindex); + NLA_PUT(msg, NL80211_ATTR_TESTDATA, data_len, data); + + params = (struct wpa_driver_testmode_params *)data; + + /* Mask version field */ + index = params->hdr.index & BITS(0, 23); + + switch(index) { + case 0x10: + { + struct wpa_driver_get_sta_statistics_params *sta_params = data; + + return send_and_recv_msgs(drv, msg, testmode_sta_statistics_handler, sta_params->buf); + } + default: + return send_and_recv_msgs(drv, msg, NULL, NULL); + } + + nla_put_failure: + return -ENOBUFS; + +} + +static int wpa_driver_nl80211_driver_sw_cmd(void *priv, + int set, unsigned long *adr, unsigned long *dat) +{ + struct i802_bss *bss = priv; + struct wpa_driver_nl80211_data *drv = bss->drv; + struct wpa_driver_sw_cmd_params params; + struct nl_msg *msg, *cqm = NULL; + int ret = 0; + + os_memset(¶ms, 0, sizeof(params)); + + params.hdr.index = 1; + params.hdr.index = params.hdr.index | (0x01 << 24); + params.hdr.buflen = sizeof(struct wpa_driver_sw_cmd_params); + + params.adr = *adr; + params.data = *dat; + + if(set) + params.set = 1; + else + params.set = 0; + + wpa_driver_nl80211_testmode(priv, (u8 *)¶ms, sizeof(struct wpa_driver_sw_cmd_params)); + return 0; +} + +/************************************************************* +OVERLAPPED functins, previous defination is in driver_nl80211.c, +it will be modified +**************************************************************/ + +/**************************************************************************/ +extern int wpa_config_write(const char *name, struct wpa_config *config); + +static int wpa_driver_mediatek_set_country(void *priv, const char *alpha2_arg) +{ + struct i802_bss *bss = priv; + struct wpa_driver_nl80211_data *drv = bss->drv; + int ioctl_sock=-1; + struct iwreq iwr; + int ret=-1; + char buf[11]; + + wpa_printf(MSG_DEBUG, "wpa_driver_nl80211_set_country"); + ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0); + if (ioctl_sock < 0) { + wpa_printf(MSG_ERROR, "%s: socket(PF_INET,SOCK_DGRAM)", __func__); + return -1; + } + os_memset(&iwr, 0, sizeof(iwr)); + os_strncpy(iwr.ifr_name, drv->first_bss.ifname, IFNAMSIZ); + sprintf(buf,"COUNTRY %s",alpha2_arg); + iwr.u.data.pointer = buf; + iwr.u.data.length = strlen(buf); + if ((ret = ioctl(ioctl_sock, 0x8B0C, &iwr)) < 0) {//SIOCSIWPRIV + wpa_printf(MSG_DEBUG, "ioctl[SIOCSIWPRIV]: %s",buf); + close(ioctl_sock); + return ret; + } + else { + close(ioctl_sock); + return 0; + } + +} + +extern const struct wpa_driver_ops wpa_driver_nl80211_ops; +int wpa_driver_nl80211_driver_cmd(void *priv, char *cmd, char *buf, + size_t buf_len ) +{ + struct i802_bss *bss = priv; + struct wpa_driver_nl80211_data *drv = bss->drv; + struct wpa_supplicant *wpa_s; + int ret = -1; + + if (drv == NULL) { + wpa_printf(MSG_ERROR, "%s: drv is NULL. Exiting", __func__); + return -1; + } + if (drv->ctx == NULL) { + wpa_printf(MSG_ERROR, "%s: drv->ctx is NULL. Exiting", __func__); + return -1; + } + wpa_s = (struct wpa_supplicant *)(drv->ctx); + if (wpa_s->conf == NULL) { + wpa_printf(MSG_ERROR, "%s: wpa_s->conf is NULL. Exiting", __func__); + return -1; + } + + wpa_printf(MSG_DEBUG, "iface %s recv cmd %s ignored", bss->ifname, cmd); + + if (os_strncasecmp(cmd, "POWERMODE ", 10) == 0) { + int state; + state = atoi(cmd + 10); + wpa_printf(MSG_DEBUG, "POWERMODE=%d", state); + } else if (os_strncmp(cmd, "MACADDR", os_strlen("MACADDR"))==0) { + u8 macaddr[ETH_ALEN] = {}; + os_memcpy(&macaddr, wpa_s->own_addr, ETH_ALEN); + ret = snprintf(buf, buf_len, "Macaddr = " MACSTR "\n", MAC2STR(macaddr)); + wpa_printf(MSG_DEBUG, "%s", buf); + } else if(os_strncasecmp(cmd, "COUNTRY", os_strlen("COUNTRY"))==0) { + wpa_printf(MSG_DEBUG, "set country: %s", cmd+8); + //ret = wpa_drv_set_country(wpa_s, cmd+8); + if(ret == 0) { + //os_memcpy(wpa_s->conf->country,cmd+8,2); + //ret = wpa_config_write(wpa_s->confname, wpa_s->conf); + } + wpa_printf(MSG_DEBUG, "skip cmd %s", cmd); + } else if (os_strcasecmp(cmd, "start") == 0) { + wpa_printf(MSG_DEBUG,"skip cmd %s", cmd); + } else if (os_strcasecmp(cmd, "stop") == 0) { +// [Android4.3] remove disassociate function +// ret = wpa_driver_nl80211_ops.disassociate(bss, drv->bssid, WLAN_REASON_DEAUTH_LEAVING); + //ret = wpa_driver_wext_driver_start(drv, 1); + if (ret == 0) + wpa_msg(drv->ctx, MSG_INFO, "CTRL-EVENT-DRIVER-STATE STOPPED"); + wpa_printf(MSG_DEBUG,"DRIVER-STOP: %d", ret); + if (linux_set_iface_flags(drv->global->ioctl_sock, + drv->first_bss.ifname, 0)) { + wpa_printf(MSG_INFO, "nl80211: Could not set interface Down \n"); + } + } else if (os_strncasecmp(cmd, "getpower", 8) == 0) { + u32 mode; +// ret = wpa_driver_wext_driver_get_power(drv, &mode); + if (ret == 0) { + ret = snprintf(buf, buf_len, "powermode = %u\n", mode); + wpa_printf(MSG_DEBUG, "%s", buf); + if (ret < (int)buf_len) { + return( ret ); + } + } + } else if (os_strncasecmp(cmd, "get-rts-threshold", 17) == 0) { + u32 thd; +// ret = wpa_driver_wext_driver_get_rts(drv, &thd); + if (ret == 0) { + ret = snprintf(buf, buf_len, "rts-threshold = %u\n", thd); + wpa_printf(MSG_DEBUG, "%s", buf); + if (ret < (int)buf_len) + return ret; + } + } else if (os_strncasecmp(cmd, "set-rts-threshold", 17) == 0) { + u32 thd = 0; + char *cp = cmd + 17; + char *endp; + if (*cp != '\0') { + thd = (u32)strtol(cp, &endp, 0); +// if (endp != cp) +// ret = wpa_driver_wext_driver_set_rts(drv, thd); + } + } else if (os_strncasecmp(cmd, "rxfilter-add", 12) == 0 ) { + unsigned long sw_cmd = 0x9F000000; + unsigned long idx = 0; + char *cp = cmd + 12; + char *endp; + + if (*cp != '\0') { + idx = (u32)strtol(cp, &endp, 0); + if (endp != cp) { + idx += 0x00900200; + wpa_driver_nl80211_driver_sw_cmd(priv, 1, &sw_cmd, &idx); + ret = 0; + } + } + } else if (os_strncasecmp(cmd, "rxfilter-remove", 15) == 0 ) { + unsigned long sw_cmd = 0x9F000000; + unsigned long idx = 0; + char *cp = cmd + 15; + char *endp; + + if (*cp != '\0') { + idx = (u32)strtol(cp, &endp, 0); + if (endp != cp) { + idx += 0x00900300; + wpa_driver_nl80211_driver_sw_cmd(priv, 1, &sw_cmd, &idx); + ret = 0; + } + } + } else if (os_strncasecmp(cmd, "rxfilter-stop", 13) == 0 ) { + unsigned long sw_cmd = 0x9F000000; + unsigned long idx = 0x00900000; + wpa_driver_nl80211_driver_sw_cmd(priv, 1, &sw_cmd, &idx); + ret = 0; + } else if (os_strncasecmp(cmd, "rxfilter-start", 14) == 0 ) { + unsigned long sw_cmd = 0x9F000000; + unsigned long idx = 0x00900100; + wpa_driver_nl80211_driver_sw_cmd(priv, 1, &sw_cmd, &idx); + ret = 0; + } else if (os_strcasecmp(cmd, "btcoexscan-start") == 0) { + ret = 0; /* mt5921 linux driver not implement yet */ + } else if (os_strcasecmp(cmd, "btcoexscan-stop") == 0) { + ret = 0; /* mt5921 linux driver not implement yet */ + } else if( os_strncasecmp(cmd, "btcoexmode", 10) == 0 ) { + ret = 0; /* mt5921 linux driver not implement yet */ + } else if (os_strncasecmp(cmd, "smt-rate", 8) == 0 ) { + unsigned long sw_cmd = 0xFFFF0123; + unsigned long idx = 0; + char *cp = cmd + 8; + char *endp; + + if (*cp != '\0') { + idx = (u32)strtol(cp, &endp, 0); + if (endp != cp) { + wpa_driver_nl80211_driver_sw_cmd(priv, 1, &sw_cmd, &idx); + ret = 0; + } + } + } else if (os_strncasecmp(cmd, "smt-test-on", 11) == 0 ) { + unsigned long sw_cmd = 0xFFFF1234; + unsigned long idx = 0; + wpa_driver_nl80211_driver_sw_cmd(priv, 1, &sw_cmd, &idx); + ret = 0; + } else if (os_strncasecmp(cmd, "smt-test-off", 12) == 0 ) { + unsigned long sw_cmd = 0xFFFF1235; + unsigned long idx = 0; + wpa_driver_nl80211_driver_sw_cmd(priv, 1, &sw_cmd, &idx); + ret = 0; + } else { + wpa_printf(MSG_DEBUG,"Unsupported command"); + } + + return ret; +} + +int wpa_driver_set_p2p_noa(void *priv, u8 count, int start, int duration) +{ + struct i802_bss *bss = priv; + struct wpa_driver_nl80211_data *drv = bss->drv; + + wpa_printf(MSG_DEBUG, "iface %s P2P_SET_NOA %d %d %d, ignored", bss->ifname, count, start, duration); + return -1; +} + +int wpa_driver_get_p2p_noa(void *priv, u8 *buf, size_t len) +{ + struct i802_bss *bss = priv; + struct wpa_driver_nl80211_data *drv = bss->drv; + + wpa_printf(MSG_DEBUG, "iface %s P2P_GET_NOA, ignored"); + return -1; +} + +int wpa_driver_set_p2p_ps(void *priv, int legacy_ps, int opp_ps, int ctwindow) +{ + struct i802_bss *bss = priv; + struct wpa_driver_nl80211_data *drv = bss->drv; + + wpa_printf(MSG_DEBUG, "iface %s P2P_SET_PS, ignored"); + return -1; +} + +int wpa_driver_set_ap_wps_p2p_ie(void *priv, const struct wpabuf *beacon, + const struct wpabuf *proberesp, + const struct wpabuf *assocresp) +{ + struct i802_bss *bss = priv; + struct wpa_driver_nl80211_data *drv = bss->drv; + + wpa_printf(MSG_DEBUG, "iface %s set_ap_wps_p2p_ie, ignored"); + return -1; +} diff --git a/wpa_supplicant/mediatek_driver_nl80211.h b/wpa_supplicant/mediatek_driver_nl80211.h new file mode 100644 index 0000000..8fa39fb --- /dev/null +++ b/wpa_supplicant/mediatek_driver_nl80211.h @@ -0,0 +1,467 @@ +/* + * Driver interaction with Linux nl80211/cfg80211 + * Copyright (c) 2002-2010, Jouni Malinen + * Copyright (c) 2003-2004, Instant802 Networks, Inc. + * Copyright (c) 2005-2006, Devicescape Software, Inc. + * Copyright (c) 2007, Johannes Berg + * Copyright (c) 2009-2010, Atheros Communications + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Alternatively, this software may be distributed under the terms of BSD + * license. + * + * See README and COPYING for more details. + */ + +#ifndef _DRIVER_NL80211_H_ +#define _DRIVER_NL80211_H_ + +#include "includes.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "nl80211_copy.h" + +#include "common.h" +#include "eloop.h" +#include "utils/list.h" +#include "common/ieee802_11_defs.h" +#include "netlink.h" +#include "linux_ioctl.h" +#include "radiotap.h" +#include "radiotap_iter.h" +#include "rfkill.h" +#include "driver.h" + +#ifdef CONFIG_LIBNL20 +/* libnl 2.0 compatibility code */ +#define nl_handle nl_sock +#define nl80211_handle_alloc nl_socket_alloc_cb +#define nl80211_handle_destroy nl_socket_free +#endif /* CONFIG_LIBNL20 */ + +#ifndef IFF_LOWER_UP +#define IFF_LOWER_UP 0x10000 /* driver signals L1 up */ +#endif +#ifndef IFF_DORMANT +#define IFF_DORMANT 0x20000 /* driver signals dormant */ +#endif + +#ifndef IF_OPER_DORMANT +#define IF_OPER_DORMANT 5 +#endif +#ifndef IF_OPER_UP +#define IF_OPER_UP 6 +#endif + +#ifndef BITS +/* Eddie */ +/* bits range: for example BITS(16,23) = 0xFF0000 + * ==> (BIT(m)-1) = 0x0000FFFF ~(BIT(m)-1) => 0xFFFF0000 + * ==> (BIT(n+1)-1) = 0x00FFFFFF + */ +#define BITS(m,n) (~(BIT(m)-1) & ((BIT(n) - 1) | BIT(n))) +#endif /* BIT */ + +struct iw_point +{ + void __user *pointer; /* Pointer to the data (in user space) */ + __u16 length; /* number of fields or size in bytes */ + __u16 flags; /* Optional params */ +}; +struct iw_param +{ + __s32 value; /* The value of the parameter itself */ + __u8 fixed; /* Hardware should not use auto select */ + __u8 disabled; /* Disable the feature */ + __u16 flags; /* Various specifc flags (if any) */ +}; +struct iw_freq +{ + __s32 m; /* Mantissa */ + __s16 e; /* Exponent */ + __u8 i; /* List index (when in range struct) */ + __u8 flags; /* Flags (fixed/auto) */ +}; +struct iw_quality +{ + __u8 qual; /* link quality (%retries, SNR, + %missed beacons or better...) */ + __u8 level; /* signal level (dBm) */ + __u8 noise; /* noise level (dBm) */ + __u8 updated; /* Flags to know if updated */ +}; + +union iwreq_data +{ + /* Config - generic */ + char name[IFNAMSIZ]; + /* Name : used to verify the presence of wireless extensions. + * Name of the protocol/provider... */ + + struct iw_point essid; /* Extended network name */ + struct iw_param nwid; /* network id (or domain - the cell) */ + struct iw_freq freq; /* frequency or channel : + * 0-1000 = channel + * > 1000 = frequency in Hz */ + + struct iw_param sens; /* signal level threshold */ + struct iw_param bitrate; /* default bit rate */ + struct iw_param txpower; /* default transmit power */ + struct iw_param rts; /* RTS threshold threshold */ + struct iw_param frag; /* Fragmentation threshold */ + __u32 mode; /* Operation mode */ + struct iw_param retry; /* Retry limits & lifetime */ + + struct iw_point encoding; /* Encoding stuff : tokens */ + struct iw_param power; /* PM duration/timeout */ + struct iw_quality qual; /* Quality part of statistics */ + + struct sockaddr ap_addr; /* Access point address */ + struct sockaddr addr; /* Destination address (hw/mac) */ + + struct iw_param param; /* Other small parameters */ + struct iw_point data; /* Other large parameters */ +}; +struct iwreq +{ + union + { + char ifrn_name[IFNAMSIZ]; /* if name, e.g. "eth0" */ + } ifr_ifrn; + + /* Data part (defined just above) */ + union iwreq_data u; +}; + +struct nl80211_global { + struct dl_list interfaces; + int if_add_ifindex; + struct netlink_data *netlink; + struct nl_cb *nl_cb; + struct nl_handle *nl; + int nl80211_id; + int ioctl_sock; /* socket for ioctl() use */ + + struct nl_handle *nl_event; +}; + +struct nl80211_wiphy_data { + struct dl_list list; + struct dl_list bsss; + struct dl_list drvs; + + struct nl_handle *nl_beacons; + struct nl_cb *nl_cb; + + int wiphy_idx; +}; + +struct i802_bss { + struct wpa_driver_nl80211_data *drv; + struct i802_bss *next; + int ifindex; + char ifname[IFNAMSIZ + 1]; + char brname[IFNAMSIZ]; + unsigned int beacon_set:1; + unsigned int added_if_into_bridge:1; + unsigned int added_bridge:1; + unsigned int in_deinit:1; + + u8 addr[ETH_ALEN]; + + int freq; + + struct nl_handle *nl_preq, *nl_mgmt; + struct nl_cb *nl_cb; + + struct nl80211_wiphy_data *wiphy_data; + struct dl_list wiphy_list; +}; + +struct wpa_driver_test_mode_info { + u32 index; + u32 buflen; +}; + + +/* P2P Sigma*/ +struct wpa_driver_p2p_sigma_params { + struct wpa_driver_test_mode_info hdr; + u32 idx; + u32 value; +}; + +struct wpa_driver_testmode_params { + struct wpa_driver_test_mode_info hdr; + u8 *buf; +}; + +struct wpa_driver_get_sta_statistics_params { + struct wpa_driver_test_mode_info hdr; + u32 version; + u32 flag; + u8 addr[ETH_ALEN]; + + u8 *buf; +}; + + +/* Hotspot Client Management */ +struct wpa_driver_hotspot_params { + struct wpa_driver_test_mode_info hdr; + u8 blocked; + u8 bssid[ETH_ALEN]; +}; + + +/* SW CMD */ +struct wpa_driver_sw_cmd_params { + struct wpa_driver_test_mode_info hdr; + u8 set; + unsigned long adr; + unsigned long data; +}; + +/* CONFIG_MTK_WFD */ +struct wpa_driver_wfd_data_s { + struct wpa_driver_test_mode_info hdr; + u32 WfdCmdType; + u8 WfdEnable; + u8 WfdCoupleSinkStatus; + u8 WfdSessionAvailable; + u8 WfdSigmaMode; + u16 WfdDevInfo; + u16 WfdControlPort; + u16 WfdMaximumTp; + u16 WfdExtendCap; + u8 WfdCoupleSinkAddress[ETH_ALEN]; + u8 WfdAssociatedBssid[ETH_ALEN]; + u8 WfdVideoIp[4]; + u8 WfdAudioIp[4]; + u16 WfdVideoPort; + u16 WfdAudioPort; + u32 WfdFlag; + u32 WfdPolicy; + u32 WfdState; + u8 WfdSessionInformationIE[24*8]; // Include Subelement ID, length + u16 WfdSessionInformationIELen; + u8 Reverved1[2]; + u8 WfdPrimarySinkMac[ETH_ALEN]; + u8 WfdSecondarySinkMac[ETH_ALEN]; + u32 WfdAdvancedFlag; + /* Group 1 64 bytes */ + u8 WfdLocalIp[4]; + u16 WfdLifetimeAc2; /* Unit is 2 TU */ + u16 WfdLifetimeAc3; /* Unit is 2 TU */ + u16 WfdCounterThreshold; /* Unit is ms */ + u8 Reverved2[54]; + /* Group 2 64 bytes */ + u8 Reverved3[64]; + /* Group 3 64 bytes */ + u8 Reverved4[64]; +}wfd_data; + +enum nl80211_testmode_sta_link_statistics_attr{ + __NL80211_TESTMODE_STA_STATISTICS_INVALID = 0, + NL80211_TESTMODE_STA_STATISTICS_VERSION, + NL80211_TESTMODE_STA_STATISTICS_MAC, + NL80211_TESTMODE_STA_STATISTICS_LINK_SCORE, + NL80211_TESTMODE_STA_STATISTICS_FLAG, + + NL80211_TESTMODE_STA_STATISTICS_PER, + NL80211_TESTMODE_STA_STATISTICS_RSSI, + NL80211_TESTMODE_STA_STATISTICS_PHY_MODE, + NL80211_TESTMODE_STA_STATISTICS_TX_RATE, + + NL80211_TESTMODE_STA_STATISTICS_TOTAL_CNT, + NL80211_TESTMODE_STA_STATISTICS_THRESHOLD_CNT, + NL80211_TESTMODE_STA_STATISTICS_AVG_PROCESS_TIME, + + NL80211_TESTMODE_STA_STATISTICS_FAIL_CNT, + NL80211_TESTMODE_STA_STATISTICS_TIMEOUT_CNT, + NL80211_TESTMODE_STA_STATISTICS_AVG_AIR_TIME, + + NL80211_TESTMODE_STA_STATISTICS_TC_EMPTY_CNT_ARRAY, + NL80211_TESTMODE_STA_STATISTICS_TC_QUE_LEN_ARRAY, + + NL80211_TESTMODE_STA_STATISTICS_TC_AVG_QUE_LEN_ARRAY, + NL80211_TESTMODE_STA_STATISTICS_TC_CUR_QUE_LEN_ARRAY, + + NL80211_TESTMODE_STA_STATISTICS_RESERVED_ARRAY, + + NL80211_TESTMODE_STA_STATISTICS_NUM, + NL80211_TESTMODE_STA_STATISTICS_MAX = NL80211_TESTMODE_STA_STATISTICS_NUM - 1 +}; + +typedef enum _ENUM_TRAFFIC_CLASS_INDEX_T { + TC0_INDEX = 0, + TC1_INDEX, + TC2_INDEX, + TC3_INDEX, + TC_DATA_NUM, + TC4_INDEX = TC_DATA_NUM, + TC5_INDEX, + TC_NUM +} ENUM_TRAFFIC_CLASS_INDEX_T; + +struct wpa_driver_sta_statistics_s { + u8 version; + u8 addr[ETH_ALEN]; + u32 flag; + + u8 link_score; + u8 per; + int rssi; + u32 phy_mode; + double tx_rate; + + u32 tx_total_cnt; + u32 tx_exc_threshold_cnt; + u32 tx_avg_process_time; + u32 tx_fail_cnt; + u32 tx_timeout_cnt; + u32 tx_avg_air_time; + + u32 tc_buf_full_cnt[TC_DATA_NUM]; + u32 tc_que_len[TC_DATA_NUM]; + + u32 tc_avg_que_len[TC_DATA_NUM]; + u32 tc_cur_que_len[TC_DATA_NUM]; + + u8 reserved[32]; +}; + +#ifdef CONFIG_WAPI_SUPPORT +/* SIOCSIWENCODEEXT definitions */ +#define IW_ENCODE_SEQ_MAX_SIZE 8 +/* struct iw_encode_ext ->alg */ +#define IW_ENCODE_ALG_NONE 0 +#define IW_ENCODE_ALG_WEP 1 +#define IW_ENCODE_ALG_TKIP 2 +#define IW_ENCODE_ALG_CCMP 3 +#define IW_ENCODE_ALG_PMK 4 +#define IW_ENCODE_ALG_AES_CMAC 5 +/* struct iw_encode_ext ->ext_flags */ +#define IW_ENCODE_EXT_TX_SEQ_VALID 0x00000001 +#define IW_ENCODE_EXT_RX_SEQ_VALID 0x00000002 +#define IW_ENCODE_EXT_GROUP_KEY 0x00000004 +#define IW_ENCODE_EXT_SET_TX_KEY 0x00000008 + +/* WAPI */ +struct iw_encode_ext +{ + u32 ext_flags; /* IW_ENCODE_EXT_* */ + u8 tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */ + u8 rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */ + u8 addr[ETH_ALEN]; /* ff:ff:ff:ff:ff:ff for broadcast/multicast + * (group) keys or unicast address for + * individual keys */ + u16 alg; /* IW_ENCODE_ALG_* */ + u16 key_len; + u8 key[32]; +}; + +struct wpa_driver_wapi_key_params { + struct wpa_driver_test_mode_info hdr; + u8 key_index; + u8 key_len; + struct iw_encode_ext extparams; +}; +#endif + + +/*-----------------------------------------------*/ +struct wpa_driver_nl80211_data { + struct nl80211_global *global; + struct dl_list list; + struct dl_list wiphy_list; + char phyname[32]; + void *ctx; + int ifindex; + int if_removed; + int if_disabled; + int ignore_if_down_event; + struct rfkill_data *rfkill; + struct wpa_driver_capa capa; + int has_capability; + + int operstate; + + int scan_complete_events; + + struct nl_cb *nl_cb; + + u8 auth_bssid[ETH_ALEN]; + u8 bssid[ETH_ALEN]; + int associated; + u8 ssid[32]; + size_t ssid_len; + enum nl80211_iftype nlmode; + enum nl80211_iftype ap_scan_as_station; + unsigned int assoc_freq; + + int monitor_sock; + int monitor_ifidx; + int monitor_refcount; + + unsigned int disabled_11b_rates:1; + unsigned int pending_remain_on_chan:1; + unsigned int in_interface_list:1; + unsigned int device_ap_sme:1; + unsigned int poll_command_supported:1; + unsigned int data_tx_status:1; + unsigned int scan_for_auth:1; + unsigned int retry_auth:1; + unsigned int use_monitor:1; + + u64 remain_on_chan_cookie; + u64 send_action_cookie; + + unsigned int last_mgmt_freq; + + struct wpa_driver_scan_filter *filter_ssids; + size_t num_filter_ssids; + + struct i802_bss first_bss; + + int eapol_tx_sock; + +#ifdef HOSTAPD + int eapol_sock; /* socket for EAPOL frames */ + + int default_if_indices[16]; + int *if_indices; + int num_if_indices; + + int last_freq; + int last_freq_ht; +#endif /* HOSTAPD */ + + /* From failed authentication command */ + int auth_freq; + u8 auth_bssid_[ETH_ALEN]; + u8 auth_ssid[32]; + size_t auth_ssid_len; + int auth_alg; + u8 *auth_ie; + size_t auth_ie_len; + u8 auth_wep_key[4][16]; + size_t auth_wep_key_len[4]; + int auth_wep_tx_keyidx; + int auth_local_state_change; + int auth_p2p; +}; + +#endif