Compare commits

..

3 Commits

Author SHA1 Message Date
Arne Coucheron
45125f5532 qsap: Fix missing log symbols
Add liblog to LOCAL_SHARED_LIBRARIES instead of using LOCAL_LDLIBS.

Change-Id: Iaf8fbc245babce372f047f73cb1400b19c54836d
2017-09-03 06:52:18 +02:00
Linux Build Service Account
ecb4615f55 Merge 8c3357cbe4 on remote branch
Change-Id: I6a96b51363a665ff812a120aaa2ffeb37f840faf
2017-08-27 00:25:51 -06:00
Linux Build Service Account
280eb6a2e5 Merge a49496aea8 on remote branch
Change-Id: I84692a2ceead1ea746b46cc4c8729d032ca1029c
2017-08-01 13:03:51 -06:00
8 changed files with 644 additions and 287 deletions

20
softap/jni/Android.mk Normal file
View File

@@ -0,0 +1,20 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_PRELINK_MODULE := false
LOCAL_SRC_FILES := QWiFiSoftApCfg.c
LOCAL_MODULE := libQWiFiSoftApCfg
LOCAL_MODULE_TAGS := optional
LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include \
$(JNI_H_INCLUDE)
LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
LOCAL_SHARED_LIBRARIES := libsysutils libcutils libnetutils libcrypto liblog
include $(BUILD_SHARED_LIBRARY)

410
softap/jni/QWiFiSoftApCfg.c Executable file
View File

@@ -0,0 +1,410 @@
/*
* Copyright (c) 2010, The Linux Foundation. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "QWiFiSoftApCfg.h"
#define UPDATE_ERROR_CODE(msg, code) \
{ \
int rc; \
rc = snprintf(resp, sizeof(resp), "failure %s:%s",msg, code); \
if ( rc == sizeof(resp)) resp[sizeof(resp)-1] = 0; \
ALOGE("%s",resp); \
}
static struct sockaddr_nl rtnl_local;
static int rtnl_fd = -1;
static char evt_buf[MAX_EVT_BUF_SIZE];
static int evt_len;
static void softap_handle_custom_event(char * buf, int len)
{
if (strncmp(buf, "AUTO-SHUT.indication ", strlen("AUTO-SHUT.indication ")) == 0)
{
ALOGD("EVENT: Custom Event\n");
snprintf(evt_buf, sizeof(evt_buf), "105 AP Shutdown");
}
}
static void softap_handle_associated_event(char *mac_addr)
{
snprintf(evt_buf, sizeof(evt_buf), "102 Station " HWA_FORM " Associated",
HWA_ARG(mac_addr));
}
static void softap_handle_disassociated_event(char *mac_addr)
{
snprintf(evt_buf, sizeof(evt_buf), "103 Station " HWA_FORM " Disassociated",
HWA_ARG(mac_addr));
}
static void softap_handle_wireless_event(char *atr, int atrlen)
{
int len = 0;
struct iw_event iwe;
char *buffer = atr + RTA_ALIGN(RTATTRLEN);
atrlen -= RTA_ALIGN(RTATTRLEN);
while ((len + (int)IW_EV_LCP_LEN) < atrlen) {
memcpy((char *)&iwe, buffer + len, sizeof(struct iw_event));
if (iwe.len <= IW_EV_LCP_LEN)
break;
ALOGD("Received Wireless Event: cmd=0x%x len=%d", iwe.cmd, iwe.len);
switch (iwe.cmd) {
case IWEVEXPIRED:
ALOGD("EVENT: IWEVEXPIRED\n");
softap_handle_disassociated_event(iwe.u.addr.sa_data);
break;
case IWEVREGISTERED:
ALOGD("EVENT: IWEVREGISTERED\n");
softap_handle_associated_event(iwe.u.addr.sa_data);
break;
case IWEVCUSTOM:
ALOGD("EVENT: Custom Event\n");
softap_handle_custom_event(buffer + len + IW_EV_POINT_LEN, iwe.u.data.length);
break;
default:
break;
}
len += iwe.len;
}
return;
}
void softap_handle_rtm_link_event(struct nlmsghdr *hdr)
{
char *ptr = (char *)NLMSG_DATA(hdr);
struct rtattr *atr;
int atr_len;
if ((hdr->nlmsg_len - MSGHDRLEN) < IFINFOLEN) {
ALOGD("Message Length Problem1");
return;
}
if ((atr_len = hdr->nlmsg_len - NLMSG_ALIGN(IFINFOLEN)) < 0) {
ALOGD("Message Length Problem2");
return;
}
ptr += NLMSG_ALIGN(IFINFOLEN);
atr = (struct rtattr *)ptr;
while (RTA_OK(atr, atr_len)) {
switch (atr->rta_type) {
case IFLA_WIRELESS:
softap_handle_wireless_event((char *)atr,
atr->rta_len);
break;
default:
break;
}
atr = RTA_NEXT(atr, atr_len);
}
return;
}
static void softap_handle_iface_event(void)
{
int cnt, mlen = 0;
char *ptr, buffer[MAX_RECV_BUF_SIZE];
socklen_t slen;
struct nlmsghdr * hdr;
while (1) {
cnt = recvfrom(rtnl_fd, buffer, sizeof(buffer),
MSG_DONTWAIT,
(struct sockaddr *)&rtnl_local, &slen);
if (cnt <= 0) {
buffer[0] = '\0';
ALOGD("recvfrom failed");
return;
}
ptr = buffer;
while (cnt >= MSGHDRLEN) {
hdr = (struct nlmsghdr *)ptr;
mlen = hdr->nlmsg_len;
if ((mlen > cnt) || ((mlen - MSGHDRLEN) < 0)) {
break;
}
switch (hdr->nlmsg_type) {
case RTM_NEWLINK:
case RTM_DELLINK:
softap_handle_rtm_link_event(hdr);
break;
}
mlen = NLMSG_ALIGN(hdr->nlmsg_len);
cnt -= mlen;
ptr += mlen;
}
}
return;
}
static inline int softap_rtnl_wait(void)
{
fd_set fds;
int oldfd, ret;
if (rtnl_fd < 0) {
ALOGD("Netlink Socket Not Available");
return -1;
}
/* Initialize fds */
FD_ZERO(&fds);
FD_SET(rtnl_fd, &fds);
oldfd = rtnl_fd;
/* Wait for some trigger event */
ret = select(oldfd + 1, &fds, NULL, NULL, NULL);
if (ret < 0) {
/* Error Occurred */
ALOGD("Select on Netlink Socket Failed");
return ret;
} else if (!ret) {
ALOGD("Select on Netlink Socket Timed Out");
/* Timeout Occurred */
return -1;
}
/* Check if any event is available for us */
if (FD_ISSET(rtnl_fd, &fds)) {
softap_handle_iface_event();
}
return 0;
}
static void softap_rtnl_close(void)
{
close(rtnl_fd);
}
static int softap_rtnl_open(void)
{
int addr_len;
rtnl_fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
if (rtnl_fd < 0) {
ALOGE("open netlink socket failed");
return -1;
}
memset(&rtnl_local, 0, sizeof(rtnl_local));
rtnl_local.nl_family = AF_NETLINK;
rtnl_local.nl_groups = RTMGRP_LINK;
if (bind(rtnl_fd, (struct sockaddr*)&rtnl_local,
sizeof(rtnl_local)) < 0) {
ALOGE("bind netlink socket failed");
return -1;
}
addr_len = sizeof(rtnl_local);
if (getsockname(rtnl_fd, (struct sockaddr*)&rtnl_local,
(socklen_t *) &addr_len) < 0) {
ALOGE("getsockname failed");
return -1;
}
if (addr_len != sizeof(rtnl_local)) {
ALOGE("Wrong address length %d\n", addr_len);
return -1;
}
if (rtnl_local.nl_family != AF_NETLINK) {
ALOGE("Wrong address family %d\n", rtnl_local.nl_family);
return -1;
}
return 0;
}
JNIEXPORT void JNICALL
Java_com_qualcomm_wifi_softap_QWiFiSoftApCfg_SapCloseNetlink
(JNIEnv *env, jobject obj)
{
softap_rtnl_close();
return;
}
JNIEXPORT jstring JNICALL
Java_com_qualcomm_wifi_softap_QWiFiSoftApCfg_SapWaitForEvent
(JNIEnv *env, jobject obj)
{
int ret;
do {
evt_len = 0;
memset(evt_buf, 0, sizeof(evt_buf));
ret = softap_rtnl_wait();
} while (!strlen(evt_buf));
return (*env)->NewStringUTF(env, evt_buf);
}
JNIEXPORT jboolean JNICALL
Java_com_qualcomm_wifi_softap_QWiFiSoftApCfg_SapOpenNetlink
(JNIEnv *env, jobject obj)
{
if (softap_rtnl_open() != 0) {
ALOGD("Netlink Open Fail");
return JNI_FALSE;
}
return JNI_TRUE;
}
JNIEXPORT jstring JNICALL
Java_com_qualcomm_wifi_softap_QWiFiSoftApCfg_SapSendCommand
(JNIEnv *env, jobject obj, jstring jcmd)
{
const char *pcmd;
char cmd[MAX_CMD_SIZE];
char resp[MAX_RESP_SIZE];
int sock = -1;
int rc;
int done = 0;
char code[32] = {0};
int connect_retry;
strlcpy(cmd, "softap qccmd ", sizeof(cmd));
pcmd = (char *) ((*env)->GetStringUTFChars(env, jcmd, NULL));
if ( pcmd == NULL ) {
UPDATE_ERROR_CODE("Command not handled","");
goto end;
}
ALOGD("Received Command: %s\n", pcmd);
if ((strlen(cmd) + strlen(pcmd)) >= sizeof(cmd)) {
UPDATE_ERROR_CODE("Command length is larger than MAX_CMD_SIZE", "");
goto end;
}
strlcat(cmd, pcmd, sizeof(cmd));
connect_retry = 0;
while ( 1 ) {
if ((sock = socket_local_client("netd",
ANDROID_SOCKET_NAMESPACE_RESERVED,
SOCK_STREAM)) < 0) {
if (connect_retry > 3) {
UPDATE_ERROR_CODE("Error connecting",
strerror(errno));
goto end;
}
ALOGW("Unable to connect to netd, retrying ...\n");
sleep(1);
} else {
break;
}
connect_retry++;
}
if (write(sock, cmd, strlen(cmd) + 1) < 0) {
UPDATE_ERROR_CODE("Error Writing to socket", strerror(errno));
goto end;
}
while (!done) {
int i;
if ((rc = read(sock, resp, sizeof(resp))) <= 0) {
if (rc == 0) {
UPDATE_ERROR_CODE("Lost connection to Netd",
strerror(errno));
} else {
UPDATE_ERROR_CODE("Error reading data",
strerror(errno));
}
done = 1;
} else {
/* skip broadcase messages */
i = 0;
while(resp[i] && (i<(int)(sizeof(code)-1)) &&
(resp[i] != ' ') && (resp[i] != '\t')) {
code[i] = resp[i];
i++;
}
code[i] = '\0';
if ( (!strcmp(code, "success")) ||
(!strcmp(code, "failure")) ) {
done=1;
} else {
ALOGW("Code(%s)\n", code);
ALOGW("Ignore messages : %s\n", resp);
}
}
}
end:
(*env)->ReleaseStringUTFChars(env, jcmd, pcmd);
if( sock >= 0 ){
close(sock);
sock = -1;
}
return (*env)->NewStringUTF(env, resp);
}

View File

@@ -0,0 +1,87 @@
/*
* Copyright (c) 2010, The Linux Foundation. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __QWIFISOFTAPCFG
#define __QWIFISOFTAPCFG
#define LOG_TAG "QWIFIAPCFG"
#include "jni.h"
#include <utils/Log.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include <errno.h>
#include <fcntl.h>
#include <ctype.h>
#include <sys/ioctl.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/select.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/un.h>
#include <linux/if.h>
#include <linux/if_arp.h>
#include <linux/if_ether.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#include <linux/wireless.h>
#include <cutils/sockets.h>
#include <private/android_filesystem_config.h>
typedef unsigned char u8;
#define HWA_FORM "%02X:%02X:%02X:%02X:%02X:%02X"
#define HWA_ARG(x) *(((u8 *)x + 0)), *(((u8 *)x + 1)), \
*(((u8 *)x + 2)), *(((u8 *)x + 3)), \
*(((u8 *)x + 4)), *(((u8 *)x + 5))
#define MAX_RESP_SIZE 256
#define MAX_CMD_SIZE 256
#define MAX_EVT_BUF_SIZE 256
#define MAX_RECV_BUF_SIZE 256
#define MSGHDRLEN ((int)(sizeof(struct nlmsghdr)))
#define IFINFOLEN ((int)(sizeof(struct ifinfomsg)))
#define RTATTRLEN ((int)(sizeof(struct rtattr)))
#ifndef IFLA_WIRELESS
#define IFLA_WIRELESS (IFLA_MASTER + 1)
#endif
#endif

View File

@@ -1,5 +1,5 @@
ifneq ($(TARGET_USES_LOCAL_QSAP),true)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
@@ -10,14 +10,11 @@ LOCAL_MODULE:= libqsap_sdk
LOCAL_MODULE_TAGS := optional
LOCAL_VENDOR_MODULE := true
LOCAL_CFLAGS += -DSDK_VERSION=\"0.0.1.0\"
LOCAL_USE_VNDK := true
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/qsap_api.h \
$(LOCAL_PATH)/qsap.h
LOCAL_COPY_HEADERS_TO := sdk/softap/include
LOCAL_COPY_HEADERS := qsap_api.h
LOCAL_COPY_HEADERS += qsap.h
ifdef WIFI_DRIVER_MODULE_PATH
LOCAL_CFLAGS += -DWIFI_DRIVER_MODULE_PATH=\"$(WIFI_DRIVER_MODULE_PATH)\"
@@ -59,8 +56,6 @@ ifdef WIFI_DRIVER_DEF_CONF_FILE
LOCAL_CFLAGS += -DWIFI_DRIVER_DEF_CONF_FILE=\"$(WIFI_DRIVER_DEF_CONF_FILE)\"
endif
LOCAL_CFLAGS += -Wall -Wextra -Werror
LOCAL_SRC_FILES := qsap_api.c \
qsap.c
@@ -68,13 +63,5 @@ LOCAL_PRELINK_MODULE := false
LOCAL_SHARED_LIBRARIES := libnetutils libutils libbinder libcutils libhardware_legacy libnl liblog
LOCAL_HEADER_LIBRARIES := libcutils_headers
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libqsap_headers
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
LOCAL_VENDOR_MODULE := true
include $(BUILD_HEADER_LIBRARY)
endif

View File

@@ -33,8 +33,6 @@
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <sched.h>
#include <sys/socket.h>
#include <linux/if.h>
@@ -48,12 +46,11 @@
#define LOG_TAG "QCLDR-"
#include <log/log.h>
#include <cutils/memory.h>
#include <cutils/misc.h>
#include <cutils/properties.h>
#include <grp.h>
#include <pwd.h>
#include "cutils/log.h"
#include "cutils/memory.h"
#include "cutils/misc.h"
#include "cutils/properties.h"
#include "private/android_filesystem_config.h"
#include "qsap_api.h"
#include "qsap.h"
@@ -196,7 +193,9 @@ static const char DRIVER_CFG80211_MODULE_ARG[] = WIFI_CFG80211_DRIVER_MODULE_A
s32 wifi_qsap_load_driver(void)
{
s32 size;
s32 ret = -1;
s32 retry;
if (system(SDIO_POLLING_ON)) {
@@ -291,6 +290,7 @@ s32 qsap_send_init_ap(void)
int s, ret;
struct iwreq wrq;
s32 status = eSUCCESS;
u32 *params = (u32 *)&wrq.u;
/* Equivalent to: iwpriv wlan0 initAP */
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) >= 0) {
@@ -318,6 +318,7 @@ s32 qsap_send_exit_ap(void)
int s, ret;
struct iwreq wrq;
s32 status = eSUCCESS;
u32 *params = (u32 *)&wrq.u;
/* Equivalent to: iwpriv wlan0 exitAP */
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) >= 0) {
@@ -387,6 +388,7 @@ s32 wifi_qsap_stop_bss(void)
s8 *iface;
s32 len = 128;
struct iwreq wrq;
struct iw_priv_args *priv_ptr;
if(ENABLE != is_softap_enabled()) {
ret = eERR_BSS_NOT_STARTED;
@@ -418,7 +420,7 @@ s32 wifi_qsap_stop_bss(void)
close(sock);
if (ret) {
ALOGE("IOCTL stopbss failed: %d", ret);
ALOGE("IOCTL stopbss failed: %ld", ret);
ret = eERR_STOP_BSS;
} else {
ALOGD("STOP BSS ISSUED");
@@ -478,6 +480,7 @@ s32 commit(void)
s32 wifi_qsap_start_softap()
{
s32 retry = 4;
FILE * fp;
ALOGD("Starting Soft AP...\n");
@@ -597,8 +600,6 @@ int wigig_ensure_entropy_file_exists()
{
int ret;
int destfd;
struct passwd *pw;
struct group *gr;
ret = access(WIGIG_ENTROPY_FILE, R_OK|W_OK);
if ((ret == 0) || (errno == EACCES)) {
@@ -630,17 +631,9 @@ int wigig_ensure_entropy_file_exists()
return -1;
}
pw = getpwnam("system");
gr = getgrnam("wifi");
if (pw && gr) {
if (chown(WIGIG_ENTROPY_FILE, pw->pw_uid, gr->gr_gid) < 0) {
ALOGE("Error changing group ownership of %s to %d: %s",
WIGIG_ENTROPY_FILE, gr->gr_gid, strerror(errno));
unlink(WIGIG_ENTROPY_FILE);
return -1;
}
} else {
ALOGE("Cannot get pw_uid or gr_gid : %s", strerror(errno));
if (chown(WIGIG_ENTROPY_FILE, AID_SYSTEM, AID_WIFI) < 0) {
ALOGE("Error changing group ownership of %s to %d: %s",
WIGIG_ENTROPY_FILE, AID_WIFI, strerror(errno));
unlink(WIGIG_ENTROPY_FILE);
return -1;
}
@@ -702,45 +695,3 @@ s32 wifi_qsap_stop_wigig_softap(void)
usleep(AP_BSS_STOP_DELAY);
return eSUCCESS;
}
s32 wifi_qsap_set_tx_power(s32 tx_power)
{
#define QCSAP_IOCTL_SET_MAX_TX_POWER (SIOCIWFIRSTPRIV + 22)
s32 sock;
s32 ret = eERR_SET_TX_POWER;
s8 interface[128];
s8 *iface;
s32 len = 128;
struct iwreq wrq;
if(NULL == (iface = qsap_get_config_value(CONFIG_FILE, &qsap_str[STR_INTERFACE], interface, (u32*)&len))) {
ALOGE("%s :interface error \n", __func__);
return ret;
}
/* Issue QCSAP_IOCTL_SET_MAX_TX_POWER ioctl */
sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock < 0) {
ALOGE("%s :socket error \n", __func__);
return eERR_SET_TX_POWER;
}
strlcpy(wrq.ifr_name, iface, sizeof(wrq.ifr_name));
wrq.u.data.length = sizeof(s32);
wrq.u.data.pointer = &tx_power;
wrq.u.data.flags = 0;
ret = ioctl(sock, QCSAP_IOCTL_SET_MAX_TX_POWER, &wrq);
close(sock);
if (ret) {
ALOGE("%s :IOCTL set tx power failed: %d\n", __func__, ret);
ret = eERR_SET_TX_POWER;
} else {
ALOGD("%s :IOCTL set tx power issued\n", __func__);
ret = eSUCCESS;
}
return ret;
}

View File

@@ -48,7 +48,6 @@ s32 wifi_qsap_start_wigig_softap(void);
s32 wifi_qsap_stop_wigig_softap(void);
s32 wifi_qsap_reload_softap(void);
s32 wifi_qsap_unload_wifi_sta_driver(void);
s32 wifi_qsap_set_tx_power(s32 tx_power);
#ifdef QCOM_WLAN_CONCURRENCY
s32 wifi_qsap_start_softap_in_concurrency(void);

267
softap/sdk/qsap_api.c Normal file → Executable file
View File

@@ -43,6 +43,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <private/android_filesystem_config.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <netlink/netlink.h>
@@ -66,13 +67,11 @@
#define LOG_TAG "QCSDK"
#include <cutils/properties.h>
#include <log/log.h>
#include "cutils/properties.h"
#include "cutils/log.h"
#define SKIP_BLANK_SPACE(x) {while(*x != '\0') { if((*x == ' ') || (*x == '\t')) x++; else break; }}
#define UNUSED __attribute__ ((unused))
/** If this variable is enabled, the soft AP is reloaded, after the commit
* command is received */
static volatile int gIniUpdated = 0;
@@ -92,9 +91,7 @@ s8 *Cmd_req[eCMD_REQ_LAST] = {
*/
s8 *Conf_req[CONF_REQ_LAST] = {
"dual2g",
"dual5g",
"owe",
"60g",
"dual5g"
};
/*
@@ -183,18 +180,6 @@ static struct Command cmd_list[eCMD_LAST] = {
{ "ssid2", NULL },
{ "bridge", NULL },
{ "ctrl_interface", NULL },
{ "vendor_elements", NULL },
{ "assocresp_elements", NULL },
{ "acs_exclude_dfs", NULL },
{ "wowlan_triggers", "any" },
{ "accept_mac_file", NULL },
{ "deny_mac_file", NULL },
{ "owe_transition_ifname", NULL },
{ "sae_require_mfp", NULL },
{ "ieee80211ax", NULL },
{ "enable_edmg", NULL },
{ "edmg_channel", NULL },
};
struct Command qsap_str[eSTR_LAST] = {
@@ -221,7 +206,7 @@ struct Command qsap_str[eSTR_LAST] = {
/** Supported operating mode */
char *hw_mode[HW_MODE_UNKNOWN] = {
"b", "g", "n", "g-only", "n-only", "a", "any", "ad"
"b", "g", "n", "g-only", "n-only", "a"
};
/** configuration file path */
@@ -275,9 +260,6 @@ static s32 qsap_read_cfg(s8 *pfile, struct Command * pcmd, s8 *presp, u32 *plen,
while(NULL != fgets(buf, MAX_CONF_LINE_LEN, fcfg)) {
s8 *pline = buf;
if (strlen(buf) == 0)
continue;
/** Skip the commented lines */
if(buf[0] == '#') {
if (ignore_comment) {
@@ -350,7 +332,7 @@ static s32 qsap_write_cfg(s8 *pfile, struct Command * pcmd, s8 *pVal, s8 *presp,
s8 buf[MAX_CONF_LINE_LEN+1];
s16 len, result = FALSE;
ALOGD("cmd=%s, Val:%s, INI:%d \n", pcmd->name, pVal, inifile);
ALOGD("cmd=%s, Val:%s, INI:%ld \n", pcmd->name, pVal, inifile);
/** Open the configuration file */
fcfg = fopen(pfile, "r");
@@ -624,7 +606,7 @@ static void qsap_set_security_mode(s8 *pfile, u32 sec_mode, s8 *presp, u32 *plen
}
else {
/** WPA, WPA2 and mixed-mode security */
u16 wpa_val = 0;
u16 wpa_val;
u32 tmp = *plen;
wep = DISABLE;
@@ -1039,7 +1021,7 @@ static void qsap_get_mac_list(s8 *fconfile, esap_cmd_t cNum, s8 *presp, u32 *ple
FILE *fp;
u32 len_remain;
s8 *pfile, *pOut;
esap_str_t sNum;
esap_cmd_t sNum;
int cnt = 0;
/** Identify the allow or deny file */
@@ -1193,7 +1175,7 @@ static void qsap_read_wps_state(s8 *presp, u32 *plen)
status = (atoi(pstate) == WPS_STATE_ENABLE) ? ENABLE : DISABLE;
}
*plen = qsap_scnprintf(presp, *plen, "success %s=%d", cmd_list[eCMD_WPS_STATE].name, status);
*plen = qsap_scnprintf(presp, *plen, "success %s=%ld", cmd_list[eCMD_WPS_STATE].name, status);
return;
}
@@ -1243,7 +1225,7 @@ int qsap_get_operating_channel(s32 *pchan)
ALOGE("Recv len :%d \n", wrq.u.data.length);
*pchan = *(int *)(&wrq.u.name[0]);
ALOGE("Operating channel :%d \n", *pchan);
ALOGE("Operating channel :%ld \n", *pchan);
close(sock);
return eSUCCESS;
@@ -1265,6 +1247,7 @@ int qsap_get_sap_auto_channel_selection(s32 *pautochan)
s8 *pif;
int ret;
sap_auto_channel_info sap_autochan_info;
s32 *pchan;
if(ENABLE != is_softap_enabled()) {
ALOGE("%s :is_softap_enabled() goto error \n", __func__);
@@ -1306,7 +1289,7 @@ int qsap_get_sap_auto_channel_selection(s32 *pautochan)
ALOGD("Recv len :%d \n", wrq.u.data.length);
*pautochan = *(int *)(&wrq.u.name[0]);
ALOGD("Sap auto channel selection pautochan=%d \n", *pautochan);
ALOGD("Sap auto channel selection pautochan=%ld \n", *pautochan);
close(sock);
return eSUCCESS;
@@ -1317,105 +1300,54 @@ error:
}
static int iftypeCallback(struct nl_msg* msg, void* arg)
{
struct nlmsghdr* ret_hdr = nlmsg_hdr(msg);
struct nlattr *tb_msg[NL80211_ATTR_MAX + 1];
int* type = arg;
struct genlmsghdr *gnlh = (struct genlmsghdr*) nlmsg_data(ret_hdr);
nla_parse(tb_msg, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
genlmsg_attrlen(gnlh, 0), NULL);
if (tb_msg[NL80211_ATTR_IFTYPE]) {
*type = nla_get_u32(tb_msg[NL80211_ATTR_IFTYPE]);
}
return NL_SKIP;
}
/**
* Get the mode of operation.
*/
int qsap_get_mode(s32 *pmode)
{
int ret = eERR_UNKNOWN;
struct nl_sock* sk = NULL;
int nl80211_id = -1;
int if_type = -1;
int sock;
struct iwreq wrq;
s8 interface[MAX_CONF_LINE_LEN];
u32 len = MAX_CONF_LINE_LEN;
s8 *pif;
struct nl_msg* msg = NULL;
int ret;
sap_auto_channel_info sap_autochan_info;
s32 *pchan;
//get interface name
*pmode = -1;
if(NULL == (pif = qsap_get_config_value(pconffile,
&qsap_str[STR_INTERFACE], interface, &len))) {
ALOGD("%s :interface error \n", __func__);
goto nla_put_failure;
goto error;
}
interface[len] = '\0';
//allocate socket
sk = nl_socket_alloc();
//return if socket allocation fails
if(sk == NULL){
ALOGE( "socket allocation failure");
return ret;
sock = socket(AF_INET, SOCK_DGRAM, 0);
if(sock < 0) {
ALOGD("%s :socket error \n", __func__);
goto error;
}
//connect to generic netlink
if (genl_connect(sk)) {
ALOGE( "Netlink socket Connection failure");
ret = eERR_UNKNOWN;
goto nla_put_failure;
memset(&wrq, 0, sizeof(wrq));
strlcpy(wrq.ifr_name, pif, sizeof(wrq.ifr_name));
ret = ioctl(sock, SIOCGIWMODE, &wrq);
if(ret < 0) {
ALOGE("%s: ioctl failure \n",__func__);
close(sock);
goto error;
}
//find the nl80211 driver ID
nl80211_id = genl_ctrl_resolve(sk, "nl80211");
*pmode = *(s32 *)(&wrq.u.mode);
ALOGE("%s: ioctl Get Mode = %d \n",__func__, (int)*pmode);
close(sock);
return eSUCCESS;
//attach a callback
nl_socket_modify_cb(sk, NL_CB_VALID, NL_CB_CUSTOM,
iftypeCallback, &if_type);
//allocate a message
msg = nlmsg_alloc();
//return if message allocation fails
if(msg == NULL){
ALOGE( "message allocation failure");
goto nla_put_failure;
}
// setup the message
genlmsg_put(msg, 0, 0, nl80211_id, 0, 0, NL80211_CMD_GET_INTERFACE, 0);
//add message attributes
NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(pif));
// Send the message
ret = nl_send_auto_complete(sk, msg);
if (ret < 0 ) {
ALOGE( "nl_send_auto_complete failure");
ret = eERR_UNKNOWN;
goto nla_put_failure;
}
//block for message to return
nl_recvmsgs_default(sk);
*pmode = if_type;
ALOGI("%s: (%s) NL80211 Get Mode = %d \n",__func__, pif, (int)*pmode);
ret = eSUCCESS;
nla_put_failure:
if (sk)
nl_socket_free(sk);
if (msg)
nlmsg_free(msg);
return ret;
error:
*pmode = -1;
ALOGE("%s: (Failure) ioctl Get Mode = %d \n",__func__, (int)*pmode);
return eERR_UNKNOWN;
}
/**
@@ -1429,7 +1361,7 @@ int qsap_set_channel_range(s8 *buf)
u32 len = MAX_CONF_LINE_LEN;
s8 *pif;
s8 *temp;
int ret;
int ret, i;
sap_channel_info sap_chan_range;
sta_channel_info sta_chan_range;
@@ -1507,8 +1439,9 @@ error:
return eERR_SET_CHAN_RANGE;
}
int qsap_read_channel(UNUSED s8 *pfile, struct Command *pcmd, s8 *presp, u32 *plen, UNUSED s8 *pvar)
int qsap_read_channel(s8 *pfile, struct Command *pcmd, s8 *presp, u32 *plen, s8 *pvar)
{
s8 *pval;
s32 chan;
u32 len = *plen;
@@ -1522,10 +1455,12 @@ int qsap_read_channel(UNUSED s8 *pfile, struct Command *pcmd, s8 *presp, u32 *pl
return eSUCCESS;
}
int qsap_read_auto_channel(UNUSED struct Command *pcmd, s8 *presp, u32 *plen)
int qsap_read_auto_channel(struct Command *pcmd, s8 *presp, u32 *plen)
{
s8 *pval, *pautoval;
s32 pautochan;
u32 len = *plen;
int autochan;
ALOGE("%s :\n", __func__);
@@ -1555,7 +1490,7 @@ static int qsap_mac_to_macstr(s8 *pmac, u32 slen, s8 *pmstr, u32 *plen)
}
if(totlen > 0) {
pmstr--;
*pmstr--;
totlen--;
}
*pmstr = '\0';
@@ -1660,7 +1595,7 @@ static void qsap_read_wep_key(s8 *pfile, struct Command *pcmd, s8 *presp, u32 *p
pkey++;
pwep++;
}
pkey--;
*pkey--;
*pkey = '\0';
*plen -= 2;
}
@@ -1675,7 +1610,8 @@ void qsap_read_ap_stats(s8 *presp, u32 *plen)
s8 interface[MAX_CONF_LINE_LEN];
u32 len = MAX_CONF_LINE_LEN;
s8 *pif;
s8 *pbuf;
s8 *pbuf, *pout;
u32 tlen;
if(ENABLE != is_softap_enabled()) {
*plen = qsap_scnprintf(presp, *plen, "%s", ERR_SOFTAP_NOT_STARTED);
@@ -1742,7 +1678,7 @@ void qsap_read_autoshutoff(s8 *presp, u32 *plen)
time = time / 60; /** Convert seconds to minutes */
}
*plen = qsap_scnprintf(presp, *plen, "success %s=%d", cmd_list[eCMD_AP_AUTOSHUTOFF].name, time);
*plen = qsap_scnprintf(presp, *plen, "success %s=%ld", cmd_list[eCMD_AP_AUTOSHUTOFF].name, time);
return;
}
@@ -1767,6 +1703,7 @@ static void qsap_get_from_config(esap_cmd_t cNum, s8 *presp, u32 *plen)
{
u32 len;
int status;
s8 * pval;
switch(cNum) {
case eCMD_ENABLE_SOFTAP:
@@ -1919,7 +1856,6 @@ static esap_cmd_t qsap_get_cmd_num(s8 *cName)
for(i=0; i<eCMD_LAST; i++) {
len = strlen(cmd_list[i].name);
if(!strncmp(cmd_list[i].name, cName, len)) {
if((cName[len] == '=') || (cName[len] == '\0'))
return i;
@@ -2433,10 +2369,6 @@ static int qsap_set_channel(s32 channel, s8 *tbuf, u32 *tlen)
ulen = *tlen;
/* Do not worry about hw_mode if intention is to use ACS (channel=0) */
if (channel == 0)
goto end;
/** Read the current operating mode */
if(NULL == (pcfgval = qsap_get_config_value(pconffile, &cmd_list[eCMD_HW_MODE], tbuf, &ulen))) {
return eERR_UNKNOWN;
@@ -2473,8 +2405,7 @@ static int qsap_set_channel(s32 channel, s8 *tbuf, u32 *tlen)
}
}
end:
qsap_scnprintf(schan, sizeof(schan), "%d", channel);
qsap_scnprintf(schan, sizeof(schan), "%ld", channel);
return qsap_write_cfg(pcfg, &cmd_list[eCMD_CHAN], schan, tbuf, tlen, HOSTAPD_CONF_QCOM_FILE);
}
@@ -2482,7 +2413,11 @@ end:
static int qsap_set_operating_mode(s32 mode, s8 *pmode, int pmode_len, s8 *tbuf, u32 *tlen)
{
u32 ulen;
s8 *pcfgval;
s32 channel;
s8 sconf[MAX_INT_STR+1];
s8 *pcfg = pconffile;
s32 rate_idx;
s8 ieee11n_enable[] = "1";
s8 ieee11n_disable[] = "0";
@@ -2503,7 +2438,6 @@ static int qsap_set_operating_mode(s32 mode, s8 *pmode, int pmode_len, s8 *tbuf,
case HW_MODE_N:
case HW_MODE_G:
case HW_MODE_A:
case HW_MODE_ANY:
ulen = *tlen;
qsap_write_cfg(pcfg, &cmd_list[eCMD_IEEE80211N],ieee11n_enable, tbuf, &ulen, HOSTAPD_CONF_QCOM_FILE);
break;
@@ -2511,10 +2445,6 @@ static int qsap_set_operating_mode(s32 mode, s8 *pmode, int pmode_len, s8 *tbuf,
ulen = *tlen;
qsap_write_cfg(pcfg, &cmd_list[eCMD_IEEE80211N],ieee11n_disable, tbuf, &ulen, HOSTAPD_CONF_QCOM_FILE);
break;
case HW_MODE_AD:
/** For 802.11ad, disable the 802.11 HT */
qsap_change_cfg(pcfg, &cmd_list[eCMD_HT_CAPAB], DISABLE);
break;
}
if(mode == HW_MODE_G_ONLY || mode == HW_MODE_N_ONLY || mode == HW_MODE_N ) {
qsap_scnprintf(pmode, pmode_len, "%s",hw_mode[HW_MODE_G]);
@@ -2549,7 +2479,7 @@ static int qsap_set_data_rate(s32 drate_idx, s8 *presp, u32 *plen)
goto end;
}
qsap_scnprintf(sconf, sizeof(sconf), "%d", drate_idx);
qsap_scnprintf(sconf, sizeof(sconf), "%ld", drate_idx);
/** Update the rate index in the configuration */
return qsap_write_cfg(fIni, &qsap_str[STR_DATA_RATE_IN_INI], sconf, presp, plen, INI_CONF_FILE);
@@ -2602,12 +2532,6 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen)
} else if (!(strncmp(pcmd, Conf_req[CONF_5g], strlen(Conf_req[CONF_5g])))) {
pcmd += strlen(Conf_req[CONF_5g]);
SKIP_BLANK_SPACE(pcmd);
} else if (!(strncmp(pcmd, Conf_req[CONF_owe], strlen(Conf_req[CONF_owe])))) {
pcmd += strlen(Conf_req[CONF_owe]);
SKIP_BLANK_SPACE(pcmd);
} else if (!(strncmp(pcmd, Conf_req[CONF_60g], strlen(Conf_req[CONF_60g])))) {
pcmd += strlen(Conf_req[CONF_60g]);
SKIP_BLANK_SPACE(pcmd);
} else {
// DO NOTHING
}
@@ -2620,7 +2544,7 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen)
pVal = pcmd + strlen(cmd_list[cNum].name);
if( (cNum != eCMD_COMMIT) &&
(cNum != eCMD_RESET_TO_DEFAULT) &&
((*pVal != '=') || (((eCMD_PASSPHRASE != cNum)) && (strlen(pVal) < 2)))) {
((*pVal != '=') || (strlen(pVal) < 2)) ) {
*plen = qsap_scnprintf(presp, *plen, "%s", ERR_INVALID_ARG);
return;
}
@@ -2654,7 +2578,7 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen)
/** Write back the integer value. This is to avoid values like 01, 001, 0001
* being written to the configuration.
*/
qsap_scnprintf(pVal, strlen(pVal)+1, "%d", value);
qsap_scnprintf(pVal, strlen(pVal)+1, "%ld", value);
qsap_set_security_mode(pconffile, value, presp, plen);
return;
@@ -2666,7 +2590,7 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen)
/** Write back the integer value. This is to avoid values like 01, 001, 0001
* being written to the configuration
*/
qsap_scnprintf(pVal, strlen(pVal)+1, "%d", value);
qsap_scnprintf(pVal, strlen(pVal)+1, "%ld", value);
if(ACL_ALLOW_LIST == value) {
value = ENABLE;
@@ -2757,7 +2681,7 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen)
/** Write back the integer value. This is to avoid values like 01, 001, 0001
* being written to the configuration
*/
qsap_scnprintf(pVal, strlen(pVal)+1, "%d", value);
qsap_scnprintf(pVal, strlen(pVal)+1, "%ld", value);
break;
case eCMD_PASSPHRASE:
value = strlen(pVal);
@@ -2781,7 +2705,7 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen)
/** Write back the integer value. This is to avoid values like 01, 001, 0001
* being written to the configuration
*/
qsap_scnprintf(pVal, strlen(pVal)+1, "%d", value);
qsap_scnprintf(pVal, strlen(pVal)+1, "%ld", value);
break;
case eCMD_DTIM_PERIOD:
@@ -2791,7 +2715,7 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen)
/** Write back the integer value. This is to avoid values like 01, 001, 0001
* being written to the configuration
*/
qsap_scnprintf(pVal, strlen(pVal)+1, "%d", value);
qsap_scnprintf(pVal, strlen(pVal)+1, "%ld", value);
break;
case eCMD_HW_MODE:
@@ -2820,7 +2744,7 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen)
/** Write back the integer value. This is to avoid values like 01, 001, 0001
* being written to the configuration
*/
qsap_scnprintf(pVal, strlen(pVal)+1, "%d", value);
qsap_scnprintf(pVal, strlen(pVal)+1, "%ld", value);
break;
case eCMD_DEFAULT_KEY:
@@ -2830,7 +2754,7 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen)
/** Write back the integer value. This is to avoid values like 01, 001, 0001
* being written to the configuration
*/
qsap_scnprintf(pVal, strlen(pVal)+1, "%d", value);
qsap_scnprintf(pVal, strlen(pVal)+1, "%ld", value);
qsap_write_cfg(pcfg, &cmd_list[cNum], pVal, presp, plen, ini);
@@ -2885,7 +2809,7 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen)
case eCMD_RESET_AP:
value = atoi(pVal);
ALOGE("Reset :%d \n", value);
ALOGE("Reset :%ld \n", value);
if(SAP_RESET_BSS == value) {
status = wifi_qsap_stop_softap();
if(status == eSUCCESS) {
@@ -3011,7 +2935,7 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen)
if(TRUE != IS_VALID_WMM_STATE(value))
goto error;
qsap_scnprintf(pVal, strlen(pVal)+1, "%d", value);
qsap_scnprintf(pVal, strlen(pVal)+1, "%ld", value);
break;
case eCMD_WPS_STATE:
value = atoi(pVal);
@@ -3020,7 +2944,7 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen)
/** Write back the integer value. This is to avoid values like 01, 001, 0001
* being written to the configuration
*/
qsap_scnprintf(pVal, strlen(pVal)+1, "%d", value);
qsap_scnprintf(pVal, strlen(pVal)+1, "%ld", value);
qsap_update_wps_config(pVal, presp, plen);
return;
@@ -3032,8 +2956,8 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen)
value = atoi(pVal);
if(TRUE != IS_VALID_PROTECTION(value))
goto error;
qsap_scnprintf(pVal, strlen(pVal)+1, "%d", value);
sNum = STR_PROT_FLAG_IN_INI;
qsap_scnprintf(pVal, strlen(pVal)+1, "%ld", value);
cNum = STR_PROT_FLAG_IN_INI;
ini = INI_CONF_FILE;
break;
@@ -3041,7 +2965,7 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen)
value = atoi(pVal);
if(TRUE != IS_VALID_FRAG_THRESHOLD(value))
goto error;
qsap_scnprintf(pVal, strlen(pVal)+1, "%d", value);
qsap_scnprintf(pVal, strlen(pVal)+1, "%ld", value);
break;
case eCMD_REGULATORY_DOMAIN:
@@ -3050,14 +2974,14 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen)
if(TRUE != IS_VALID_802DOT11D_STATE(value))
goto error;
qsap_scnprintf(pVal, strlen(pVal)+1, "%d", value);
qsap_scnprintf(pVal, strlen(pVal)+1, "%ld", value);
break;
case eCMD_RTS_THRESHOLD:
value = atoi(pVal);
if(TRUE != IS_VALID_RTS_THRESHOLD(value))
goto error;
qsap_scnprintf(pVal, strlen(pVal)+1, "%d", value);
qsap_scnprintf(pVal, strlen(pVal)+1, "%ld", value);
break;
case eCMD_GTK_TIMEOUT:
@@ -3071,8 +2995,8 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen)
value = atoi(pVal);
if(TRUE != IS_VALID_TX_POWER(value))
goto error;
qsap_scnprintf(pVal, strlen(pVal)+1, "%d", value);
sNum = STR_TX_POWER_IN_INI;
qsap_scnprintf(pVal, strlen(pVal)+1, "%ld", value);
cNum = STR_TX_POWER_IN_INI;
ini = INI_CONF_FILE;
break;
@@ -3105,8 +3029,8 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen)
goto error;
/* copy a larger value back to pVal. Please pay special care
* in caller to make sure that the buffer has sufficient size. */
qsap_scnprintf(pVal, MAX_INT_STR, "%d", value*60);
sNum = STR_AP_AUTOSHUTOFF;
qsap_scnprintf(pVal, MAX_INT_STR, "%ld", value*60);
cNum = STR_AP_AUTOSHUTOFF;
ini = INI_CONF_FILE;
break;
@@ -3115,8 +3039,8 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen)
if(TRUE != IS_VALID_ENERGY_DETECT_TH(value))
goto error;
qsap_scnprintf(pVal, strlen(pVal)+1, "%d", value);
sNum = STR_AP_ENERGY_DETECT_TH;
qsap_scnprintf(pVal, strlen(pVal)+1, "%ld", value);
cNum = STR_AP_ENERGY_DETECT_TH;
ini = INI_CONF_FILE;
break;
@@ -3125,7 +3049,7 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen)
if(TRUE != IS_VALID_DFS_STATE(value))
goto error;
qsap_scnprintf(pVal, strlen(pVal)+1, "%d", value);
qsap_scnprintf(pVal, strlen(pVal)+1, "%ld", value);
break;
case eCMD_SET_CHANNEL_RANGE:
@@ -3144,8 +3068,8 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen)
}
if(ini == INI_CONF_FILE) {
ALOGD("WRITE TO INI FILE :%s\n", qsap_str[sNum].name);
qsap_write_cfg(fIni, &qsap_str[sNum], pVal, presp, plen, ini);
ALOGD("WRITE TO INI FILE :%s\n", qsap_str[cNum].name);
qsap_write_cfg(fIni, &qsap_str[cNum], pVal, presp, plen, ini);
}
else {
qsap_write_cfg(pcfg, &cmd_list[cNum], pVal, presp, plen, ini);
@@ -3173,7 +3097,7 @@ error:
*/
void qsap_hostd_exec_cmd(s8 *pcmd, s8 *presp, u32 *plen)
{
ALOGD("CMD INPUT [%s][%u]\n", pcmd, *plen);
ALOGD("CMD INPUT [%s][%lu]\n", pcmd, *plen);
/* Skip any blank spaces */
SKIP_BLANK_SPACE(pcmd);
@@ -3182,16 +3106,14 @@ void qsap_hostd_exec_cmd(s8 *pcmd, s8 *presp, u32 *plen)
pconffile = CONFIG_FILE_2G;
} else if (!(strncmp(pcmd+4, Conf_req[CONF_5g], strlen(Conf_req[CONF_5g])))) {
pconffile = CONFIG_FILE_5G;
} else if (!(strncmp(pcmd+4, Conf_req[CONF_owe], strlen(Conf_req[CONF_owe])))) {
pconffile = CONFIG_FILE_OWE;
} else if (!(strncmp(pcmd+4, Conf_req[CONF_60g], strlen(Conf_req[CONF_60g])))) {
pconffile = CONFIG_FILE_60G;
} else {
pconffile = CONFIG_FILE;
}
}
check_for_configuration_files();
if(fIni == NULL)
qsap_set_ini_filename();
if(!strncmp(pcmd, Cmd_req[eCMD_GET], strlen(Cmd_req[eCMD_GET])) && isblank(pcmd[strlen(Cmd_req[eCMD_GET])])) {
qsap_handle_get_request(pcmd, presp, plen);
@@ -3205,7 +3127,7 @@ void qsap_hostd_exec_cmd(s8 *pcmd, s8 *presp, u32 *plen)
*plen = qsap_scnprintf(presp, *plen, "%s", ERR_INVALIDREQ);
}
ALOGD("CMD OUTPUT [%s]\nlen :%u\n\n", presp, *plen);
ALOGD("CMD OUTPUT [%s]\nlen :%lu\n\n", presp, *plen);
return;
}
@@ -3235,7 +3157,7 @@ int qsapsetSoftap(int argc, char *argv[])
int i;
int hidden = 0;
int sec = SEC_MODE_NONE;
char setCmd[SET_BUF_LEN] = "set";
char setCmd[SET_BUF_LEN];
int offset = 0;
ALOGD("%s, %s, %s, %d\n", __FUNCTION__, argv[0], argv[1], argc);
@@ -3244,14 +3166,17 @@ int qsapsetSoftap(int argc, char *argv[])
ALOGD("ARG: %d - %s\n", i+1, argv[i]);
}
// check if 2nd arg is dual2g/dual5g/owe/60g
if (argc > 2
&& (strncmp(argv[2], Conf_req[CONF_2g], 4) == 0
|| strncmp(argv[2], Conf_req[CONF_owe], 3) == 0
|| strncmp(argv[2], Conf_req[CONF_60g], 3) == 0)) {
// check if 2nd arg is dual2g/dual5g
if (argc > 2) {
// just match 'dual'
if (strncmp(argv[2], Conf_req[CONF_2g], 4) == 0) {
snprintf(setCmd, SET_BUF_LEN, "set %s", argv[2]);
offset = 1;
argc--;
} else {
snprintf(setCmd, SET_BUF_LEN, "set");
offset = 0;
}
}
/* set interface */
@@ -3456,7 +3381,7 @@ void check_for_configuration_files(void)
void qsap_set_ini_filename(void)
{
if (property_get("vendor.wlan.driver.config", ini_file, NULL)) {
if (property_get("wlan.driver.config", ini_file, NULL)) {
fIni = ini_file;
ALOGE("INI FILE PROP PRESENT %s\n", fIni);
} else

46
softap/sdk/qsap_api.h Normal file → Executable file
View File

@@ -77,8 +77,7 @@ enum error_val {
eERR_LOAD_FAILED_SDIOIF,
eERR_LOAD_FAILED_SOFTAP,
eERR_SET_CHAN_RANGE,
eERR_GET_AUTO_CHAN,
eERR_SET_TX_POWER
eERR_GET_AUTO_CHAN
};
#ifndef WIFI_DRIVER_CONF_FILE
@@ -90,36 +89,32 @@ enum error_val {
#endif
/** Configuration file name for SAP+SAP*/
#define CONFIG_FILE_2G "/data/vendor/wifi/hostapd/hostapd_dual2g.conf"
#define CONFIG_FILE_5G "/data/vendor/wifi/hostapd/hostapd_dual5g.conf"
#define CONFIG_FILE_60G "/data/vendor/wifi/hostapd/hostapd_60g.conf"
/** Configuration file name for OWE-transition */
#define CONFIG_FILE_OWE "/data/vendor/wifi/hostapd/hostapd_owe.conf"
#define CONFIG_FILE_2G "/data/vendor/wifi/hostapd_dual2g.conf"
#define CONFIG_FILE_5G "/data/vendor/wifi/hostapd_dual5g.conf"
/** Configuration file name */
#define CONFIG_FILE "/data/vendor/wifi/hostapd/hostapd.conf"
#define CONFIG_FILE "/data/misc/wifi/hostapd.conf"
/** Default configuration file path */
#define DEFAULT_CONFIG_FILE_PATH "/vendor/etc/hostapd/hostapd_default.conf"
#define DEFAULT_CONFIG_FILE_PATH "/system/etc/hostapd/hostapd_default.conf"
/** Default Accept list file name */
#define DEFAULT_ACCEPT_LIST_FILE_PATH "/vendor/etc/hostapd/hostapd.accept"
#define DEFAULT_ACCEPT_LIST_FILE_PATH "/system/etc/hostapd/hostapd.accept"
/** Accept list file name */
#define ACCEPT_LIST_FILE "/data/vendor/wifi/hostapd/hostapd.accept"
#define ACCEPT_LIST_FILE "/data/misc/wifi/hostapd.accept"
/** Default Deny list file name */
#define DEFAULT_DENY_LIST_FILE_PATH "/vendor/etc/hostapd/hostapd.deny"
#define DEFAULT_DENY_LIST_FILE_PATH "/system/etc/hostapd/hostapd.deny"
/** Deny list file name */
#define DENY_LIST_FILE "/data/vendor/wifi/hostapd/hostapd.deny"
#define DENY_LIST_FILE "/data/misc/wifi/hostapd.deny"
/** Default Ini file */
#define DEFAULT_INI_FILE "/persist/qcom/softap/qcom_cfg_default.ini"
/** SDK control interface path */
#define SDK_CTRL_IF "/data/vendor/wifi/hostapd/ctrl/softap_sdk_ctrl"
#define SDK_CTRL_IF "/data/misc/wifi/softap_sdk_ctrl"
/** Maximum length of the line in the configuration file */
#define MAX_CONF_LINE_LEN (156)
@@ -257,8 +252,6 @@ enum eCmd_req {
enum eConf_req {
CONF_2g = 0,
CONF_5g = 1,
CONF_owe = 2,
CONF_60g = 3,
CONF_REQ_LAST
};
@@ -355,19 +348,6 @@ typedef enum esap_cmd {
eCMD_SSID2 = 74,
eCMD_BRIDGE = 75,
eCMD_CTRL_INTERFACE = 76,
eCMD_VENDOR_ELEMENT = 77,
eCMD_ASSOCRESP_ELEMENT = 78,
eCMD_ACS_EXCLUDE_DFS = 79,
eCMD_WOWLAN_TRIGGERS = 80,
eCMD_ACCEPT_MAC_FILE = 81,
eCMD_DENY_MAC_FILE = 82,
eCMD_OWE_TRANS_IFNAME = 83,
eCMD_SAE_REQUIRE_MPF = 84,
eCMD_IEEE80211AX = 85,
eCMD_ENABLE_EDMG = 86,
eCMD_EDMG_CHANNEL = 87,
eCMD_LAST /** New command numbers should be added above this */
} esap_cmd_t;
@@ -432,8 +412,6 @@ enum oper_mode {
HW_MODE_G_ONLY = 3,
HW_MODE_N_ONLY = 4,
HW_MODE_A = 5,
HW_MODE_ANY = 6,
HW_MODE_AD = 7,
HW_MODE_UNKNOWN
};
@@ -531,7 +509,7 @@ typedef struct sap_auto_channel_info {
#define IS_VALID_BSSID(x) (((value == ENABLE) || (value == DISABLE)) ? TRUE: FALSE)
/** Validate the length of the passphrase */
#define IS_VALID_PASSPHRASE_LEN(x) ((((x >= PASSPHRASE_MIN) && (x <= PASSPHRASE_MAX)) || (x == 0)) ? TRUE: FALSE)
#define IS_VALID_PASSPHRASE_LEN(x) (((x >= PASSPHRASE_MIN) && (x <= PASSPHRASE_MAX)) ? TRUE: FALSE)
/** Validate the beacon interval */
#define IS_VALID_BEACON(x) (((x >= BCN_INTERVAL_MIN) && (x <= BCN_INTERVAL_MAX)) ? TRUE: FALSE)
@@ -544,7 +522,7 @@ typedef struct sap_auto_channel_info {
/** Validate the pairwise encryption */
#define IS_VALID_PAIRWISE(x) (((!strcmp(x, "TKIP")) || (!strcmp(x, "CCMP")) || \
(!strcmp(x, "TKIP CCMP")) || (!strcmp(x, "CCMP TKIP")) || (!strcmp(x, "GCMP"))) ? TRUE : FALSE)
(!strcmp(x, "TKIP CCMP")) || (!strcmp(x, "CCMP TKIP"))) ? TRUE : FALSE)
/** Validate the WMM status */
#define IS_VALID_WMM_STATE(x) (((x >= WMM_AUTO_IN_INI) && (x <= WMM_DISABLED_IN_INI)) ? TRUE: FALSE)