Compare commits

..

42 Commits

Author SHA1 Message Date
Skrilax_CZ
7bebb68631 Implement wifi_qsap_set_tx_power
Used by radio proprietary binaries from Motorola.

Change-Id: I9fd49cbba6001a4c7ddadf5cb88df06d6146f01a
2016-09-04 02:53:51 -07:00
Steve Kondik
ed3a0c2a26 qsap: Kill more logspam
Change-Id: I0a32abbf783ffb1534051fd89708d2a49014c6c3
2016-09-01 09:59:09 -07:00
Steve Kondik
fc4e0df7b2 qsap: Put files in a sane location
* And set their perms

Change-Id: Ifc61a3504433f6b7e1602432ecea70c37785c895
2016-09-01 09:59:09 -07:00
Steve Kondik
31e1ef0ca4 qsap: Don't log sensitive information
Change-Id: I3ab6d73051d4647941de6eee41c2b5507c5eddc6
2016-09-01 09:59:09 -07:00
Linux Build Service Account
f4e6d19070 Promotion of wlan-service.lnx.1.1-00019.
CRs      Change ID                                   Subject
--------------------------------------------------------------------------------------------------------------
1017907 1044315   Ic8fcabf0ad514e5a73d5a9a9ebccb6ca52dcb9b4   Softap: Add support for STA+SoftAP Concurrency

Change-Id: I7eaeacea9a9d6b45dbf87b52c65313386c1897d4
CRs-Fixed: 1017907, 1044315
2016-07-25 08:11:51 -06:00
Nalla Kartheek
f4eef25c34 Softap: Add support for STA+SoftAP Concurrency
1. Add functions to create and remove softap interface using
   NL commands.
2. Write Softap interface into hostapd.conf.

Change-Id: Ic8fcabf0ad514e5a73d5a9a9ebccb6ca52dcb9b4
CRs-Fixed: 1044315
2016-07-22 13:15:28 -07:00
Linux Build Service Account
5cf4b594e9 Promotion of wlan-service.lnx.1.1-00018.
CRs      Change ID                                   Subject
--------------------------------------------------------------------------------------------------------------
1014736   Ic2dd119b1fbfbf88b7b39000c1633792c8a628c2   qsap: add functions for calling FST manager start/stop

Change-Id: I319845b13411ff32ceea9c706d1ed1358989baff
CRs-Fixed: 1014736
2016-07-11 10:10:01 -06:00
Hamad Kadmany
421ce6f83e qsap: add functions for calling FST manager start/stop
FST manager start/stop need to be done in sync with start/stop
of softAP controller.
To support such functionality, added general functions that
can be used pre and post softAP start/stop operations.

Change-Id: Ic2dd119b1fbfbf88b7b39000c1633792c8a628c2
CRs-Fixed: 1014736
2016-06-16 12:43:56 +03:00
Linux Build Service Account
f70b065f22 Promotion of wlan-service.lnx.1.1-00008.
CRs      Change ID                                   Subject
--------------------------------------------------------------------------------------------------------------
1025722   If284ce12b1141bde8d01bee7023ac9ae94d255b7   GTK: Decrease GTK rekey interval

Change-Id: Ic7a80bf0d046869f26f397ec03f80e03cc3be8f2
CRs-Fixed: 1025722
2016-06-14 12:26:21 -06:00
c_rrajiv
c160697b1f GTK: Decrease GTK rekey interval
GTK rekey interval is reduced to match with
standard values existing with commercial APs.
This further helps in testing the GTK rekeying
functionality and offload scenarios with SAP case.

CRs-Fixed: 1025722

Change-Id: If284ce12b1141bde8d01bee7023ac9ae94d255b7
2016-06-08 00:48:54 -07:00
Linux Build Service Account
6228c9263b Merge "Promotion of wlan-service.lnx.1.1-00003." 2016-05-24 03:22:27 -07:00
Linux Build Service Account
2a1b069ae0 Promotion of wlan-service.lnx.1.1-00003.
CRs      Change ID                                   Subject
--------------------------------------------------------------------------------------------------------------
1016741   Idf747b74191de4904ca939601a263b9fb8f9e971   softap: support for starting/stopping Wigig soft AP

Change-Id: I6751c19f041b93fbd956e1e3f2626796c3557c8e
CRs-Fixed: 1016741
2016-05-23 20:33:06 -07:00
Linux Build Service Account
7cab567836 Promotion of wlan-service.lnx.1.1-00002.
CRs      Change ID                                   Subject
--------------------------------------------------------------------------------------------------------------
1016741   Idf747b74191de4904ca939601a263b9fb8f9e971   softap: support for starting/stopping Wigig soft AP

Change-Id: I17dcde26ac9275cacc600ae92fb332f89c146935
CRs-Fixed: 1016741
2016-05-22 23:36:13 -06:00
Dedy Lansky
350c353182 softap: support for starting/stopping Wigig soft AP
Support new command: eCMD_ENABLE_WIGIG_SOFTAP.

Change-Id: Idf747b74191de4904ca939601a263b9fb8f9e971
CRs-Fixed: 1016741
2016-05-17 02:14:25 -07:00
Linux Build Service Account
4d6c04aa73 Promotion of wlan-service.lnx.1.0-00014.
CRs      Change ID                                   Subject
--------------------------------------------------------------------------------------------------------------
943343 943343   I37d8927f2973f90772ab46cc767fdea1ac9cfc6b   wlan: Add support for ieee80211h hostapd config

Change-Id: I5ce5eff98aa7188b654c69a702af16406d87921a
CRs-Fixed: 943343
2016-02-03 01:23:39 -08:00
Pradeep Reddy POTTETI
5c1a3abaf0 wlan: Add support for ieee80211h hostapd config
Support for configuring ieee80211h parameter in
hostapd configuration file through soft AP SDK.

Change-Id: I37d8927f2973f90772ab46cc767fdea1ac9cfc6b
CRs-Fixed: 943343
2016-01-07 20:03:13 +05:30
Ashwini Sukhadev Patil
1e2073ebaf Softap: Avoid possible array index out-of-bounds access.
Return value of snprintf can be more than size value when output
is truncated, so copying the '\0' at return value may cause array
index out-of-bound access. And as snprintf function takes care of
terminating the string with '\0', its redundant to copy '\0' at
return value.

CRs-Fixed: 947966
Change-Id: Ic5dab6d9aa57db5000f23c82e2a22924e0154c40
2015-12-07 12:11:48 +05:30
Linux Build Service Account
c46bf72725 Merge "Modify NDC commands to write to hostapd.conf" 2015-09-22 20:58:29 -07:00
Linux Build Service Account
bb81a3fc87 Merge "wlan: Add support for 11AC, ACS hostapd config" 2015-09-22 20:58:29 -07:00
Pradeep Reddy POTTETI
a1c6f1dbe5 Provide read/write access on accept/deny files to hostapd
This commit provides read/write access on accept/deny files
to hostapd similar to hostapd.conf.

Change-Id: I1c3cda056a4067d48484cb336e748f04804b68e3
CRs-fixed: 910398
2015-09-18 20:20:16 +05:30
Ashwini Sukhadev Patil
cc16315997 Modify NDC commands to write to hostapd.conf
Provision to configure rts_threshold, fragm_threshold and
wmm_enabled in hostapd.conf through NDC commands.

CRs-Fixed: 889979
Change-Id: I94e4486573b562fbe48c641423bf1c1389d0c744
2015-09-11 19:14:22 +05:30
Manikandan Mohan
e1bfb737ad wlan: Add support for 11AC, ACS hostapd config
Support for configuring 11ac and ACS channel list parameters in
hostapd configuration file through soft AP SDK.

Change-Id: I45c4f4285357701299c44f31243dea5107b0fabb
CRs-Fixed: 892713
2015-09-09 17:38:47 -07:00
Linux Build Service Account
cddacfa293 Merge 650d036038 on remote branch
Change-Id: I622541a7fac02a2db2d869da97a513b062955b4a
2015-08-16 23:56:06 -06:00
c_rrajiv
e629e82bc8 wlan: Add softap support through ndc commands.
Changes required to support the softap commands
through ndc cli. This new support as part of the
64bit enablement and ndc is used for cli automation
in softap testcases.
Change-Id: I460a3785c3b4a44656281c7243ebdf921fe20f91
CRs-Fixed: 710050
2015-07-20 16:39:08 +05:30
Bala Krishna Bhamidipati
650d036038 Invoke qsap_set_ini_filename to set the fIni (if NULL)
If WIFI_DRIVER_CONF_FILE is not defined fIni is set to null and
hence all the set/get_cfg SAP commands fail. Thus, Invoke
qsap_set_ini_filename explicitly if fINI is NULL.

Change-Id: I9df1f95d7f4b884602cc501fe9e75ff4c26e400c
CRs-Fixed: 865432
2015-07-06 15:33:57 +05:30
Changzhi Deng
fddc6bed07 Hotspot: Set maximun client connections number
This function is for end user to set maximun client
connections number and apply this to hostapd module

Change-Id: I6150b376d22756e8c04ebabe666d81cf3af8fc87
2015-06-09 18:23:27 -07:00
Linux Build Service Account
4659de289b Merge "qcom-softap: Replace strcat & strcpy with strlcat & strlcpy" 2015-03-28 09:49:54 -07:00
Naresh Jayaram
71846207cc qcom-softap: Replace strcat & strcpy with strlcat & strlcpy
strcpy and strcat are not safe, instead use strlcpy and strlcat
which have control over the number of bytes to be written to
the output str or buffer.

CRs-Fixed: 802872
Change-Id: I7b6748946633dda551a1015678d41846c19adeb2
2015-03-24 10:28:18 +05:30
Linux Build Service Account
120aeacf0f Merge "Merge d98f57876f on remote branch" 2014-12-09 03:11:03 -08:00
Linux Build Service Account
64f15fc591 Merge d98f57876f on remote branch
Change-Id: I539218e4d40ef020b4913e1540ab8acbf7db1d88
2014-12-08 00:06:00 -07:00
Linux Build Service Account
d98f57876f Merge "framework: Fix for making SAP sdk code 64 bit compliant" 2014-12-06 12:18:56 -08:00
Linux Build Service Account
e9159df711 Merge "Merge 04a6a9712e on remote branch" 2014-12-05 02:45:36 -08:00
Ravi Joshi
5620bb1611 framework: Fix for making SAP sdk code 64 bit compliant
Fix for making SAP SDK code 64 bit compliant. The typedefs
were incorrect on an LP64 architecture since a long int will
be 64-bits.

Change-Id: I4c9f5f2fb2b820193fbe03fdf8e2307c281ea014
CRs-Fixed: 640894
2014-12-04 11:18:00 -08:00
Linux Build Service Account
a9fe9d38bd Merge "wlan: Change location of hostapd files." 2014-12-04 08:27:25 -08:00
Linux Build Service Account
e601816b24 Merge 04a6a9712e on remote branch
Change-Id: Icb0d8a1efb21abd2c03a539c8c2af5a2da39f4f6
2014-12-03 19:36:53 -07:00
Linux Build Service Account
04a6a9712e Merge "framework: Fix for making SAP sdk code 64 bit compliant" 2014-11-30 11:38:37 -08:00
Linux Build Service Account
56710aac73 Merge "wlan: Change location of hostapd files." 2014-11-26 19:20:37 -08:00
Ravi Joshi
9b8ed11141 framework: Fix for making SAP sdk code 64 bit compliant
Fix for making SAP SDK code 64 bit compliant. The typedefs
were incorrect on an LP64 architecture since a long int will
be 64-bits.

Change-Id: I4c9f5f2fb2b820193fbe03fdf8e2307c281ea014
CRs-Fixed: 640894
2014-11-23 22:05:50 -08:00
Linux Build Service Account
92dd0a5d38 Merge "wlan: Fix for OSS build compilation issue" 2014-11-20 07:38:22 -08:00
Linux Build Service Account
f5fecdcc36 Merge "wlan: Change location of hostapd files." 2014-11-20 00:34:55 -08:00
Neelansh Mittal
587b8b3d67 wlan: Change location of hostapd files.
Change location of hostapd accept and deny files
from /data/hostapd to /data/misc/wifi because
SElinux does not allow netd and hostapd to access
/data/hostapd directory.

Change-Id: I61e8521b3a4b6aab759d3b7cbc04acd3da3c8cf3
CRs-Fixed: 756614
2014-11-19 17:59:02 +05:30
Mahesh A Saptasagar
8e9475b346 wlan: Fix for OSS build compilation issue
Do not include "wpa_ctrl.h" in qsap.c file to avoid compilation
errors on OSS builds.

Change-Id: Ie3afa0bc564a5b2d9c2245b85f4681b83c1d1644
CRs-Fixed: 758764
2014-11-18 20:11:25 +05:30
6 changed files with 412 additions and 27 deletions

View File

@@ -319,7 +319,7 @@ JNIEXPORT jstring JNICALL
char code[32] = {0};
int connect_retry;
strncpy(cmd, "softap qccmd ", sizeof(cmd));
strlcpy(cmd, "softap qccmd ", sizeof(cmd));
pcmd = (char *) ((*env)->GetStringUTFChars(env, jcmd, NULL));
@@ -330,12 +330,12 @@ JNIEXPORT jstring JNICALL
ALOGD("Received Command: %s\n", pcmd);
if ((strlen(cmd) + strlen(pcmd)) > sizeof(cmd)) {
if ((strlen(cmd) + strlen(pcmd)) >= sizeof(cmd)) {
UPDATE_ERROR_CODE("Command length is larger than MAX_CMD_SIZE", "");
goto end;
}
strcat(cmd, pcmd);
strlcat(cmd, pcmd, sizeof(cmd));
connect_retry = 0;

4
softap/sdk/Android.mk Normal file → Executable file
View File

@@ -4,7 +4,7 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES :=
LOCAL_C_INCLUDES := $(TOP)/hardware/libhardware_legacy/wifi $(TOP)/external/libnl/include $(TOP)/external/wpa_supplicant_8/wpa_supplicant/src/drivers
LOCAL_MODULE:= libqsap_sdk
@@ -61,7 +61,7 @@ LOCAL_SRC_FILES := qsap_api.c \
LOCAL_PRELINK_MODULE := false
LOCAL_SHARED_LIBRARIES := libnetutils libutils libbinder libcutils
LOCAL_SHARED_LIBRARIES := libnetutils libutils libbinder libcutils libhardware_legacy libnl
include $(BUILD_SHARED_LIBRARY)

View File

@@ -54,6 +54,7 @@
#include "qsap_api.h"
#include "qsap.h"
#include "wifi_fst.h"
#include <sys/system_properties.h>
@@ -584,3 +585,173 @@ s32 wifi_qsap_reload_softap()
return eSUCCESS;
}
static pid_t wigigSoftApPid = 0;
static const char WIGIG_ENTROPY_FILE[] = "/data/misc/wifi/wigig_entropy.bin";
static unsigned char dummy_key[21] = { 0x02, 0x11, 0xbe, 0x33, 0x43, 0x35,
0x68, 0x47, 0x84, 0x99, 0xa9, 0x2b,
0x1c, 0xd3, 0xee, 0xff, 0xf1, 0xe2,
0xf3, 0xf4, 0xf5 };
static const char HOSTAPD_BIN_FILE[] = "/system/bin/hostapd";
static const char WIGIG_HOSTAPD_CONF_FILE[] = "/data/misc/wifi/wigig_hostapd.conf";
#define AP_BSS_START_DELAY 200000
#define AP_BSS_STOP_DELAY 500000
int wigig_ensure_entropy_file_exists()
{
int ret;
int destfd;
ret = access(WIGIG_ENTROPY_FILE, R_OK|W_OK);
if ((ret == 0) || (errno == EACCES)) {
if ((ret != 0) &&
(chmod(WIGIG_ENTROPY_FILE, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) != 0)) {
ALOGE("Cannot set RW to \"%s\": %s", WIGIG_ENTROPY_FILE, strerror(errno));
return -1;
}
return 0;
}
destfd = TEMP_FAILURE_RETRY(open(WIGIG_ENTROPY_FILE, O_CREAT|O_RDWR, 0660));
if (destfd < 0) {
ALOGE("Cannot create \"%s\": %s", WIGIG_ENTROPY_FILE, strerror(errno));
return -1;
}
if (TEMP_FAILURE_RETRY(write(destfd, dummy_key, sizeof(dummy_key))) != sizeof(dummy_key)) {
ALOGE("Error writing \"%s\": %s", WIGIG_ENTROPY_FILE, strerror(errno));
close(destfd);
return -1;
}
close(destfd);
/* chmod is needed because open() didn't set permisions properly */
if (chmod(WIGIG_ENTROPY_FILE, 0660) < 0) {
ALOGE("Error changing permissions of %s to 0660: %s",
WIGIG_ENTROPY_FILE, strerror(errno));
unlink(WIGIG_ENTROPY_FILE);
return -1;
}
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;
}
return 0;
}
s32 wifi_qsap_start_wigig_softap(void)
{
pid_t pid = 1;
ALOGD("%s", __func__);
if (wigigSoftApPid) {
ALOGE("Wigig SoftAP is already running");
return eERR_START_SAP;
}
if (wigig_ensure_entropy_file_exists() < 0) {
ALOGE("Wigig entropy file was not created");
}
if ((pid = fork()) < 0) {
ALOGE("fork failed (%s)", strerror(errno));
return eERR_START_SAP;
}
if (!pid) {
if (execl(HOSTAPD_BIN_FILE, HOSTAPD_BIN_FILE,
"-e", WIGIG_ENTROPY_FILE, "-dd",
WIGIG_HOSTAPD_CONF_FILE, (char *) NULL)) {
ALOGE("execl failed (%s)", strerror(errno));
}
ALOGE("Wigig SoftAP failed to start. Exiting child process...");
exit(-1);
}
wigigSoftApPid = pid;
ALOGD("Wigig SoftAP started successfully");
usleep(AP_BSS_START_DELAY);
return eSUCCESS;
}
s32 wifi_qsap_stop_wigig_softap(void)
{
ALOGD("%s", __func__);
if (wigigSoftApPid == 0) {
ALOGE("Wigig SoftAP is not running");
return eSUCCESS;
}
ALOGD("Stopping the Wigig SoftAP...");
kill(wigigSoftApPid, SIGTERM);
waitpid(wigigSoftApPid, NULL, 0);
wigigSoftApPid = 0;
ALOGD("Wigig SoftAP stopped successfully");
usleep(AP_BSS_STOP_DELAY);
return eSUCCESS;
}
int qsap_prepare_softap()
{
ALOGD("Starting fstman\n");
return wifi_start_fstman(TRUE);
}
int qsap_unprepare_softap()
{
ALOGD("Stopping fstman\n");
return wifi_stop_fstman(TRUE);
}
int qsap_is_fst_enabled()
{
return is_fst_enabled();
}
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: %ld\n", __func__, ret);
ret = eERR_SET_TX_POWER;
} else {
ALOGD("%s :IOCTL set tx power issued\n", __func__);
ret = eSUCCESS;
}
return ret;
}

View File

@@ -44,6 +44,8 @@ s32 commit(void);
s32 is_softap_enabled(void);
s32 wifi_qsap_start_softap(void);
s32 wifi_qsap_stop_softap(void);
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);
@@ -52,6 +54,8 @@ s32 wifi_qsap_start_softap_in_concurrency(void);
s32 wifi_qsap_stop_softap_in_concurrency(void);
#endif
s32 wifi_qsap_set_tx_power(s32);
#if __cplusplus
}; // extern "C"
#endif

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

@@ -44,6 +44,12 @@
#include <sys/types.h>
#include <unistd.h>
#include <private/android_filesystem_config.h>
#include <net/if.h>
#include <netlink/netlink.h>
#include <netlink/genl/genl.h>
#include <netlink/genl/family.h>
#include <netlink/genl/ctrl.h>
#include "nl80211_copy.h"
#include "qsap_api.h"
#include "qsap.h"
@@ -153,6 +159,14 @@ static struct Command cmd_list[eCMD_LAST] = {
{ "autochannel", NULL },
{ "ieee80211w", NULL },
{ "wpa_key_mgmt", NULL },
{ "max_num_sta", "8" },
{ "ieee80211ac", NULL },
{ "vht_oper_chwidth", NULL },
{ "chanlist", NULL },
{ "ht_capab", NULL },
{ "ieee80211h", NULL },
{ "enable_wigig_softap", NULL },
{ "interface", NULL },
};
struct Command qsap_str[eSTR_LAST] = {
@@ -698,13 +712,46 @@ end:
static s8 *qsap_get_allow_deny_file_name(s8 *pcfgfile, struct Command * pcmd, s8 *pfile, u32 *plen)
{
if(eSUCCESS == qsap_read_cfg(pcfgfile, pcmd, pfile, plen, NULL, GET_ENABLED_ONLY)) {
pfile[*plen] = '\0';
return strchr(pfile, '=') + 1;
}
return NULL;
}
int qsap_hostd_exec(int argc, char ** argv) {
#define MAX_CMD_SIZE 256
char qcCmdBuf[MAX_CMD_SIZE], *pCmdBuf;
u32 len = MAX_CMD_SIZE;
int i = 2, ret;
if ( argc < 4 ) {
ALOGD("failure: invalid arguments");
return -1;
}
argc -= 2;
pCmdBuf = qcCmdBuf;
while (argc--) {
ret = snprintf(pCmdBuf, len, " %s", argv[i]);
if ((ret < 0) || (ret >= (int)len)) {
/* Error case */
/* TODO: Command too long send the error message */
*pCmdBuf = '\0';
break;
}
ALOGD("argv[%d] (%s)",i, argv[i]);
pCmdBuf += ret;
len -= ret;
i++;
}
ALOGD("QCCMD data (%s)", pCmdBuf);
len = MAX_CMD_SIZE;
qsap_hostd_exec_cmd(qcCmdBuf, qcCmdBuf, (u32*)&len);
return 0;
}
/** Function to identify a valid MAC address */
static int isValid_MAC_address(char *pMac)
{
@@ -1713,15 +1760,10 @@ static void qsap_get_from_config(esap_cmd_t cNum, s8 *presp, u32 *plen)
break;
case eCMD_FRAG_THRESHOLD:
qsap_read_cfg(fIni, &qsap_str[STR_FRAG_THRESHOLD_IN_INI], presp, plen, cmd_list[eCMD_FRAG_THRESHOLD].name, GET_ENABLED_ONLY);
break;
case eCMD_REGULATORY_DOMAIN:
qsap_read_cfg(pconffile, &cmd_list[cNum], presp, plen, NULL, GET_ENABLED_ONLY);
break;
case eCMD_RTS_THRESHOLD:
qsap_read_cfg(fIni, &qsap_str[STR_RTS_THRESHOLD_IN_INI], presp, plen, cmd_list[eCMD_RTS_THRESHOLD].name, GET_ENABLED_ONLY);
case eCMD_IEEE80211H:
qsap_read_cfg(pconffile, &cmd_list[cNum], presp, plen, NULL, GET_ENABLED_ONLY);
break;
case eCMD_ALLOW_LIST: /* fall through */
@@ -1740,7 +1782,7 @@ static void qsap_get_from_config(esap_cmd_t cNum, s8 *presp, u32 *plen)
break;
case eCMD_WMM_STATE:
qsap_read_cfg(fIni, &qsap_str[STR_WMM_IN_INI], presp, plen, cmd_list[eCMD_WMM_STATE].name, GET_ENABLED_ONLY);
qsap_read_cfg(pconffile, &cmd_list[cNum], presp, plen, NULL, GET_ENABLED_ONLY);
break;
case eCMD_WPS_STATE:
@@ -2604,12 +2646,30 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen)
}
*plen = qsap_scnprintf(presp, *plen, "%s", (status==eSUCCESS) ? SUCCESS : "failure Could not enable softap");
return;
case eCMD_ENABLE_WIGIG_SOFTAP:
value = atoi(pVal);
if (TRUE != IS_VALID_SOFTAP_ENABLE(value))
goto error;
if ( *pVal == '0' ) {
status = wifi_qsap_stop_wigig_softap();
}
else {
status = wifi_qsap_start_wigig_softap();
}
*plen = qsap_scnprintf(presp, *plen, "%s", (status==eSUCCESS) ? SUCCESS : "failure Could not enable Wigig softap");
return;
case eCMD_SSID:
value = strlen(pVal);
if(SSD_MAX_LEN < value)
goto error;
break;
case eCMD_SET_MAX_CLIENTS:
value = strlen(pVal);
break;
case eCMD_BSSID:
value = atoi(pVal);
if(FALSE == IS_VALID_BSSID(value))
@@ -2872,8 +2932,6 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen)
goto error;
qsap_scnprintf(pVal, strlen(pVal)+1, "%ld", value);
cNum = STR_WMM_IN_INI;
ini = INI_CONF_FILE;
break;
case eCMD_WPS_STATE:
value = atoi(pVal);
@@ -2904,9 +2962,6 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen)
if(TRUE != IS_VALID_FRAG_THRESHOLD(value))
goto error;
qsap_scnprintf(pVal, strlen(pVal)+1, "%ld", value);
cNum = STR_FRAG_THRESHOLD_IN_INI;
ini = INI_CONF_FILE;
break;
case eCMD_REGULATORY_DOMAIN:
@@ -2923,8 +2978,6 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen)
if(TRUE != IS_VALID_RTS_THRESHOLD(value))
goto error;
qsap_scnprintf(pVal, strlen(pVal)+1, "%ld", value);
cNum = STR_RTS_THRESHOLD_IN_INI;
ini = INI_CONF_FILE;
break;
case eCMD_GTK_TIMEOUT:
@@ -2938,7 +2991,6 @@ 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_set_ini_filename();
qsap_scnprintf(pVal, strlen(pVal)+1, "%ld", value);
cNum = STR_TX_POWER_IN_INI;
ini = INI_CONF_FILE;
@@ -2987,6 +3039,15 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen)
cNum = STR_AP_ENERGY_DETECT_TH;
ini = INI_CONF_FILE;
break;
case eCMD_IEEE80211H:
value = atoi(pVal);
if(TRUE != IS_VALID_DFS_STATE(value))
goto error;
qsap_scnprintf(pVal, strlen(pVal)+1, "%ld", value);
break;
case eCMD_SET_CHANNEL_RANGE:
ALOGE("eCMD_SET_CHANNEL_RANGE pcmd :%s\n", pcmd);
value = qsap_set_channel_range(pcmd);
@@ -3033,6 +3094,8 @@ void qsap_hostd_exec_cmd(s8 *pcmd, s8 *presp, u32 *plen)
SKIP_BLANK_SPACE(pcmd);
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);
@@ -3052,6 +3115,7 @@ void qsap_hostd_exec_cmd(s8 *pcmd, s8 *presp, u32 *plen)
}
/* netd and Froyo Native UI specific API */
#define DEFAULT_INTFERACE "wlan0"
#define DEFAULT_SSID "SOFTAP_SSID"
#define DEFAULT_CHANNEL 4
#define DEFAULT_PASSPHRASE "12345678"
@@ -3081,6 +3145,16 @@ int qsapsetSoftap(int argc, char *argv[])
ALOGV("ARG: %d - %s\n", i+1, argv[i]);
}
/* set interface */
if (argc > 2) {
snprintf(cmdbuf, CMD_BUF_LEN, "set interface=%s",argv[2]);
}
else {
snprintf(cmdbuf, CMD_BUF_LEN, "set interface=%s", DEFAULT_INTFERACE);
}
(void) qsap_hostd_exec_cmd(cmdbuf, respbuf, &rlen);
/** set SSID */
if(argc > 3) {
qsap_scnprintf(cmdbuf, sizeof(cmdbuf), "set ssid=%s",argv[3]);
@@ -3168,6 +3242,16 @@ int qsapsetSoftap(int argc, char *argv[])
return -1;
}
rlen = RECV_BUF_LEN;
if(argc > 8) {
qsap_scnprintf(cmdbuf, sizeof(cmdbuf), "set max_num_sta=%d",atoi(argv[8]));
}
(void) qsap_hostd_exec_cmd(cmdbuf, respbuf, &rlen);
if(strncmp("success", respbuf, rlen) != 0) {
ALOGE("Failed to set maximun client connections number \n");
return -1;
}
rlen = RECV_BUF_LEN;
qsap_scnprintf(cmdbuf, sizeof(cmdbuf), "set commit");
@@ -3199,9 +3283,9 @@ static int check_for_config_file_size(FILE *fp)
void check_for_configuration_files(void)
{
FILE * fp;
char *pfile;
/* Check if configuration files are present, if not create the default files */
mkdir("/data/hostapd", 0771);
/* If configuration file does not exist copy the default file */
if ( NULL == (fp = fopen(CONFIG_FILE, "r")) ) {
@@ -3229,6 +3313,18 @@ void check_for_configuration_files(void)
fclose(fp);
}
/* Provide read and write permissions to the owner */
pfile = ACCEPT_LIST_FILE;
if (chmod(pfile, 0660) < 0) {
ALOGE("Error changing permissions of %s to 0660: %s",
pfile, strerror(errno));
}
if (chown(pfile, AID_SYSTEM, AID_WIFI) < 0) {
ALOGE("Error changing group ownership of %s to %d: %s",
pfile, AID_WIFI, strerror(errno));
}
/* If deny MAC list file does not exist, copy the default file */
if ( NULL == (fp = fopen(DENY_LIST_FILE, "r")) ) {
wifi_qsap_reset_to_default(DENY_LIST_FILE, DEFAULT_DENY_LIST_FILE_PATH);
@@ -3242,6 +3338,18 @@ void check_for_configuration_files(void)
fclose(fp);
}
/* Provide read and write permissions to the owner */
pfile = DENY_LIST_FILE;
if (chmod(pfile, 0660) < 0) {
ALOGE("Error changing permissions of %s to 0660: %s",
pfile, strerror(errno));
}
if (chown(pfile, AID_SYSTEM, AID_WIFI) < 0) {
ALOGE("Error changing group ownership of %s to %d: %s",
pfile, AID_WIFI, strerror(errno));
}
return;
}
@@ -3254,3 +3362,87 @@ void qsap_set_ini_filename(void)
ALOGE("INI FILE PROP NOT PRESENT: Use default path %s\n", fIni);
return;
}
int qsap_add_or_remove_interface(const char *newIface , int createIface)
{
const char *wlanIface = "wlan0";
int retVal = 0;
struct nl_msg *msg = NULL;
struct nl_cb *cb = NULL;
struct nl_cb *s_cb = NULL;
struct nl_sock *nl_sock = NULL;
int nl80211_id;
enum nl80211_iftype type = NL80211_IFTYPE_AP;
/* Allocate a netlink socket */
s_cb = nl_cb_alloc(NL_CB_DEFAULT);
if (!s_cb) {
ALOGE( "Failed to allocate Netlink Socket");
retVal = -ENOMEM;
goto nla_put_failure;
}
nl_sock = nl_socket_alloc_cb(s_cb);
if (!nl_sock) {
ALOGE( "Netlink socket Allocation failure");
retVal = -ENOMEM;
goto nla_put_failure;
}
/* connect to generic netlink socket */
if (genl_connect(nl_sock)) {
ALOGE( "Netlink socket Connection failure");
retVal = -ENOLINK;
goto nla_put_failure;
}
nl80211_id = genl_ctrl_resolve(nl_sock, "nl80211");
if (nl80211_id < 0) {
ALOGE( "nl80211 generic netlink not found");
retVal = -ENOENT;
goto nla_put_failure;
}
msg = nlmsg_alloc();
if(!msg) {
ALOGE( "Failed to allocate netlink message");
retVal = -ENOMEM;
goto nla_put_failure;
}
cb = nl_cb_alloc(NL_CB_DEFAULT);
if (!cb) {
ALOGE( "Failed to allocate netlink callback");
retVal = -ENOMEM;
goto nla_put_failure;
}
if (createIface == 1) {
/* Issue NL80211_CMD_NEW_INTERFACE */
genlmsg_put( msg, 0, 0, nl80211_id, 0, 0, NL80211_CMD_NEW_INTERFACE, 0);
nla_put_u32( msg, NL80211_ATTR_IFINDEX, if_nametoindex( wlanIface ));
NLA_PUT_STRING( msg, NL80211_ATTR_IFNAME, newIface);
nla_put_u32( msg, NL80211_ATTR_IFTYPE, type);
} else {
genlmsg_put( msg, 0, 0, nl80211_id, 0, 0, NL80211_CMD_DEL_INTERFACE, 0);
nla_put_u32( msg, NL80211_ATTR_IFINDEX, if_nametoindex( newIface ));
}
retVal = nl_send_auto_complete(nl_sock, msg );
if (retVal < 0 ) {
goto nla_put_failure;
}
else {
ALOGD("Interface %s is %s - Ok", (createIface == 1 ? "created":"removed") ,newIface);
}
nla_put_failure:
if (nl_sock)
nl_socket_free(nl_sock);
if (s_cb)
nl_cb_put(s_cb);
if (msg)
nlmsg_free(msg);
if (cb)
nl_cb_put(cb);
return retVal;
}

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

@@ -39,8 +39,8 @@ typedef unsigned char u8;
typedef char s8;
typedef unsigned short int u16;
typedef signed short int s16;
typedef unsigned long int u32;
typedef signed long int s32;
typedef unsigned int u32;
typedef signed int s32;
/** Success and error messages */
#define SUCCESS "success"
@@ -77,7 +77,8 @@ enum error_val {
eERR_LOAD_FAILED_SDIOIF,
eERR_LOAD_FAILED_SOFTAP,
eERR_SET_CHAN_RANGE,
eERR_GET_AUTO_CHAN
eERR_GET_AUTO_CHAN,
eERR_SET_TX_POWER
};
#ifndef WIFI_DRIVER_CONF_FILE
@@ -207,7 +208,7 @@ enum error_val {
#define MIN_UPC_LEN (1)
#define MAX_UPC_LEN (128)
#define GTK_MIN (600)
#define GTK_MIN (30)
#define MAX_INT_STR (8)
@@ -324,6 +325,15 @@ typedef enum esap_cmd {
eCMD_GET_AUTO_CHANNEL = 63,
eCMD_IEEE80211W = 64,
eCMD_WPA_KEY_MGMT = 65,
eCMD_SET_MAX_CLIENTS = 66,
eCMD_IEEE80211AC = 67,
eCMD_VHT_OPER_CH_WIDTH = 68,
eCMD_ACS_CHAN_LIST = 69,
eCMD_HT_CAPAB = 70,
eCMD_IEEE80211H = 71,
eCMD_ENABLE_WIGIG_SOFTAP = 72,
eCMD_INTERFACE = 73,
eCMD_LAST /** New command numbers should be added above this */
} esap_cmd_t;
@@ -575,10 +585,15 @@ typedef struct sap_auto_channel_info {
/** Validate the AP shutoff time */
#define IS_VALID_ENERGY_DETECT_TH(x) ((((x >= AP_ENERGY_DETECT_TH_MIN) && (x <= AP_ENERGY_DETECT_TH_MAX)) ||( x == 128)) ? TRUE : FALSE)
/** Validate the 802dot11h state */
#define IS_VALID_DFS_STATE(x) (((x == ENABLE) || (x == DISABLE)) ? TRUE: FALSE)
/** Function declartion */
int qsap_hostd_exec(int argc, char ** argv);
void qsap_hostd_exec_cmd(s8 *pcmd, s8 *presp, u32 *plen);
s8 *qsap_get_config_value(s8 *pfile, struct Command *pcmd, s8 *pbuf, u32 *plen);
int qsapsetSoftap(int argc, char *argv[]);
int qsap_add_or_remove_interface(const char *iface_name, int create_iface);
void qsap_del_ctrl_iface(void);
s16 wifi_qsap_reset_to_default(s8 *pcfgfile, s8 *pdefault);
void check_for_configuration_files(void);
@@ -586,6 +601,9 @@ void qsap_set_ini_filename(void);
int qsap_set_channel_range(s8 * cmd);
int qsap_get_sap_auto_channel_slection(s32 *pautochan);
int qsap_get_mode(s32 *pmode);
int qsap_prepare_softap(void);
int qsap_unprepare_softap(void);
int qsap_is_fst_enabled(void);
#if __cplusplus
}; // extern "C"