Compare commits

..

22 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
Ajit Vaishya
8c3357cbe4 qsap: Point the hostapd configuration location to /data/misc/wifi
1) This commit points the hostapd configuration location
   to /data/misc/wifi.
2) Aims to enable configure ctrl_interface via qsap command.

CRs-Fixed: 2091779
Change-Id: I8ebfdd4b5c359659272209ab2e0f7b92793e51c9
2017-08-14 22:47:42 +05:30
Linux Build Service Account
280eb6a2e5 Merge a49496aea8 on remote branch
Change-Id: I84692a2ceead1ea746b46cc4c8729d032ca1029c
2017-08-01 13:03:51 -06:00
Purushottam Kushwaha
0e5ec067f7 qsap: Add API to get device mac address based on interface name.
This adds new API linux_get_ifhwaddr() which can be used to get
mac address of input interface. IOCTL SIOCGIFHWADDR is used to get
the interface address.

CRs-Fixed: 2080924
Change-Id: I1b825fb2c1f35280d2d57928be4f87d23d78decb
2017-07-27 20:49:56 -07:00
Purushottam Kushwaha
a7c3aa8a21 qsap: Modify qsapsetSoftap API to set dual2g/5g configurations.
This enhances qsapsetSoftap to take arguments for dual2g and dual5g
configurations while maintaining backward compatibility to set
config file in case of standalone sap.

Additionally enhance 'set' command to configure ssid2 and bridge
parameters which are needed for dual2g/dual5g. Also when setting
ssid2, disable ssid in config files (or vice-versa).

CRs-Fixed: 2080924
Change-Id: I60bf62e6b2ad0cde3ebdfff4814f2ab98aa24b92
2017-07-27 20:49:20 -07:00
Ajit Vaishya
a21d26579d qsap: Enhance 'set' command to configure for SAP + SAP.
This enhances existing 'set' command to allow configuration of dual
SAP. It will create/read/write/update to following configuration files:
CMD: "softap qccmd set channel=6" writes to hostapd.conf
CMD: "softap qccmd set dual2g channel=6" writes to hostapd_dual2g.conf
CMD: "softap qccmd set dual5g channel=6" writes to hostapd_dual5g.conf

Additionally enable LOG_TAG for logging APIs with TAG "QCSDK" and
modify default config file location.

CRs-Fixed: 2080924
Change-Id: I46c59de7fbd2ea273793406f0b82515df94e5c38
2017-07-27 20:48:41 -07:00
Ajit Vaishya
5d72c3af41 qsap: Add APIs to control and manage bridge interface.
This adds APIs to trigger create, delete, interface up and interface
down commands on bridge interface.
It uses following IOCTLs for sending command to linux kernel:
Add bridge iface: SIOCBRADDBR
Remove bridge iface: SIOCBRDELBR
Mark iface up/down: SIOCGIFFLAGS

CRs-Fixed: 2080924
Change-Id: I3d34dc16e9ca82dc4b550cbc83fa4120c80ad54c
2017-07-27 14:08:21 -07:00
Purushottam Kushwaha
a49496aea8 qsap: Remove support for wifi_fst from QSAP APIs
wifi_fst.h is no longer part of /hardware/libhardware_legacy/ ,
therefore, compilation of libqsap_sdk would fail. Remove dependencies
for wifi_fst from QSAP.

Additionally, skip calling 'chown' after changing configuration
parameters as QSAP is not changing ownership.

CRs-Fixed: 2069881
Change-Id: Iaadfa182270f22555e486dac24a5acafc247b943
2017-07-13 12:12:08 +05:30
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
6 changed files with 479 additions and 120 deletions

View File

@@ -15,6 +15,6 @@ 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
LOCAL_SHARED_LIBRARIES := libsysutils libcutils libnetutils libcrypto liblog
include $(BUILD_SHARED_LIBRARY)

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 liblog
include $(BUILD_SHARED_LIBRARY)

View File

@@ -585,44 +585,113 @@ s32 wifi_qsap_reload_softap()
return eSUCCESS;
}
s32 wifi_qsap_set_tx_power(s32 tx_power)
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()
{
#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;
int ret;
int destfd;
if(NULL == (iface = qsap_get_config_value(CONFIG_FILE, &qsap_str[STR_INTERFACE], interface, (u32*)&len))) {
ALOGE("%s :interface error \n", __func__);
return ret;
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;
}
/* Issue QCSAP_IOCTL_SET_MAX_TX_POWER ioctl */
sock = socket(AF_INET, SOCK_DGRAM, 0);
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);
if (sock < 0) {
ALOGE("%s :socket error \n", __func__);
return eERR_SET_TX_POWER;
/* 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;
}
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;
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 ret;
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;
}

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,8 +54,6 @@ 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

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

@@ -44,6 +44,13 @@
#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>
#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"
@@ -58,7 +65,7 @@
#define QCSAP_PARAM_GET_AUTO_CHANNEL 9
#define WE_SET_SAP_CHANNELS 3
//#define LOG_TAG "QCSDK-"
#define LOG_TAG "QCSDK"
#include "cutils/properties.h"
#include "cutils/log.h"
@@ -78,6 +85,15 @@ s8 *Cmd_req[eCMD_REQ_LAST] = {
"set"
};
/** Supported config file requests.
* WANRING: The enum eConf_req in the file qsap_api.h should be
* updated if Conf_req[], us updated
*/
s8 *Conf_req[CONF_REQ_LAST] = {
"dual2g",
"dual5g"
};
/*
* WARNING: On updating the cmd_list, the enum esap_cmd in file
* qsap_api.h must be updates to reflect the changes
@@ -158,6 +174,12 @@ static struct Command cmd_list[eCMD_LAST] = {
{ "vht_oper_chwidth", NULL },
{ "chanlist", NULL },
{ "ht_capab", NULL },
{ "ieee80211h", NULL },
{ "enable_wigig_softap", NULL },
{ "interface", NULL },
{ "ssid2", NULL },
{ "bridge", NULL },
{ "ctrl_interface", NULL },
};
struct Command qsap_str[eSTR_LAST] = {
@@ -310,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;
ALOGV("cmd=%s, Val:%s, INI:%ld \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");
@@ -345,7 +367,7 @@ static s32 qsap_write_cfg(s8 *pfile, struct Command * pcmd, s8 *pVal, s8 *presp,
if(pline[len] == '=') {
qsap_scnprintf(buf, sizeof(buf), "%s=%s\n", pcmd->name, pVal);
result = TRUE;
ALOGV("Updated:%s\n", buf);
ALOGD("Updated:%s\n", buf);
}
}
@@ -360,7 +382,7 @@ static s32 qsap_write_cfg(s8 *pfile, struct Command * pcmd, s8 *pVal, s8 *presp,
/* Add the new line at the end of file */
qsap_scnprintf(buf, sizeof(buf), "%s=%s\n", pcmd->name, pVal);
fprintf(ftmp, "%s", buf);
ALOGV("Adding a new line in %s file: [%s] \n", inifile ? "inifile" : "hostapd.conf", buf);
ALOGD("Adding a new line in %s file: [%s] \n", inifile ? "inifile" : "hostapd.conf", buf);
}
if(inifile) {
@@ -390,14 +412,6 @@ static s32 qsap_write_cfg(s8 *pfile, struct Command * pcmd, s8 *pVal, s8 *presp,
unlink(pfile);
return -1;
}
if (chown(pfile, AID_SYSTEM, AID_WIFI) < 0) {
ALOGE("Error changing group ownership of %s to %d: %s",
pfile, AID_WIFI, strerror(errno));
unlink(pfile);
return -1;
}
if(result == eERR_UNKNOWN)
return eERR_FEATURE_NOT_ENABLED;
@@ -543,14 +557,6 @@ static s32 qsap_change_cfg(s8 *pfile, struct Command * pcmd, u32 status)
unlink(pfile);
return -1;
}
if (chown(pfile, AID_SYSTEM, AID_WIFI) < 0) {
ALOGE("Error changing group ownership of %s to %d: %s",
pfile, AID_WIFI, strerror(errno));
unlink(pfile);
return -1;
}
return 0;
}
@@ -703,7 +709,6 @@ 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;
}
@@ -972,7 +977,7 @@ static void qsap_remove_from_file(s8 *pfile, s8 *pVal, s8 *presp, u32 *plen)
*/
static void qsap_update_mac_list(s8 *pfile, esap_cmd_t cNum, s8 *pVal, s8 *presp, u32 *plen)
{
ALOGV("%s : Updating file %s \n", __func__, pfile);
ALOGD("%s : Updating file %s \n", __func__, pfile);
switch(cNum) {
case eCMD_ADD_TO_ALLOW:
@@ -1127,7 +1132,7 @@ static int qsap_read_mac_address(s8 *presp, u32 *plen)
ptr++;
ALOGV("MAC :%s \n", ptr);
ALOGD("MAC :%s \n", ptr);
if(TRUE == isValid_MAC_address(ptr)) {
nRet = eSUCCESS;
}
@@ -1163,7 +1168,7 @@ static void qsap_read_wps_state(s8 *presp, u32 *plen)
if(NULL == (pstate = qsap_get_config_value(pconffile, &cmd_list[eCMD_WPS_STATE], presp, &tlen))) {
/** unable to read the wps configuration, WPS is disabled !*/
ALOGV("%s :wps_state not in cfg file \n", __func__);
ALOGD("%s :wps_state not in cfg file \n", __func__);
status = DISABLE;
}
else {
@@ -1218,9 +1223,9 @@ int qsap_get_operating_channel(s32 *pchan)
goto error;
}
ALOGV("Recv len :%d \n", wrq.u.data.length);
ALOGE("Recv len :%d \n", wrq.u.data.length);
*pchan = *(int *)(&wrq.u.name[0]);
ALOGV("Operating channel :%ld \n", *pchan);
ALOGE("Operating channel :%ld \n", *pchan);
close(sock);
return eSUCCESS;
@@ -1251,7 +1256,7 @@ int qsap_get_sap_auto_channel_selection(s32 *pautochan)
if(NULL == (pif = qsap_get_config_value(pconffile,
&qsap_str[STR_INTERFACE], interface, &len))) {
ALOGV("%s :interface error \n", __func__);
ALOGD("%s :interface error \n", __func__);
goto error;
}
@@ -1259,7 +1264,7 @@ int qsap_get_sap_auto_channel_selection(s32 *pautochan)
sock = socket(AF_INET, SOCK_DGRAM, 0);
if(sock < 0) {
ALOGV("%s :socket error \n", __func__);
ALOGD("%s :socket error \n", __func__);
goto error;
}
@@ -1282,9 +1287,9 @@ int qsap_get_sap_auto_channel_selection(s32 *pautochan)
goto error;
}
ALOGV("Recv len :%d \n", wrq.u.data.length);
ALOGD("Recv len :%d \n", wrq.u.data.length);
*pautochan = *(int *)(&wrq.u.name[0]);
ALOGV("Sap auto channel selection pautochan=%ld \n", *pautochan);
ALOGD("Sap auto channel selection pautochan=%ld \n", *pautochan);
close(sock);
return eSUCCESS;
@@ -1312,7 +1317,7 @@ int qsap_get_mode(s32 *pmode)
*pmode = -1;
if(NULL == (pif = qsap_get_config_value(pconffile,
&qsap_str[STR_INTERFACE], interface, &len))) {
ALOGV("%s :interface error \n", __func__);
ALOGD("%s :interface error \n", __func__);
goto error;
}
@@ -1320,7 +1325,7 @@ int qsap_get_mode(s32 *pmode)
sock = socket(AF_INET, SOCK_DGRAM, 0);
if(sock < 0) {
ALOGV("%s :socket error \n", __func__);
ALOGD("%s :socket error \n", __func__);
goto error;
}
@@ -1424,7 +1429,7 @@ int qsap_set_channel_range(s8 *buf)
goto error;
}
ALOGV("Recv len :%d\n", wrq.u.data.length);
ALOGE("Recv len :%d\n", wrq.u.data.length);
close(sock);
return eSUCCESS;
@@ -1442,7 +1447,7 @@ int qsap_read_channel(s8 *pfile, struct Command *pcmd, s8 *presp, u32 *plen, s8
if(eSUCCESS == qsap_get_operating_channel(&chan)) {
*plen = qsap_scnprintf(presp, len, "%s %s=%lu", SUCCESS, pcmd->name, chan);
ALOGV("presp :%s\n", presp);
ALOGD("presp :%s\n", presp);
} else {
*plen = qsap_scnprintf(presp, len, "%s", ERR_UNKNOWN);
}
@@ -1754,6 +1759,7 @@ static void qsap_get_from_config(esap_cmd_t cNum, s8 *presp, u32 *plen)
case eCMD_FRAG_THRESHOLD:
case eCMD_REGULATORY_DOMAIN:
case eCMD_RTS_THRESHOLD:
case eCMD_IEEE80211H:
qsap_read_cfg(pconffile, &cmd_list[cNum], presp, plen, NULL, GET_ENABLED_ONLY);
break;
@@ -1922,7 +1928,7 @@ static s16 is_valid_wep_key(s8 *pwep, s8 *pkey, s16 len)
weplen--;
while(weplen--) {
if(0 == isascii(pwep[weplen])) {
ALOGV("%c not ascii \n", pwep[weplen]);
ALOGD("%c not ascii \n", pwep[weplen]);
return FALSE;
}
}
@@ -1981,11 +1987,6 @@ s16 wifi_qsap_reset_to_default(s8 *pcfgfile, s8 *pdefault)
if(eERR_UNKNOWN == rename(buf, pcfgfile))
status = eERR_CONF_FILE;
if (chown(pcfgfile, AID_WIFI, AID_WIFI) < 0) {
ALOGE("Error changing group ownership of %s to %d: %s",
pcfgfile, AID_WIFI, strerror(errno));
}
/** Remove the temporary file. Dont care the return value */
unlink(buf);
@@ -2068,7 +2069,7 @@ static int qsap_send_cmd_to_hostapd(s8 *pcmd)
goto error;
}
ALOGV("Connect to :%s\n", ptr);
ALOGD("Connect to :%s\n", ptr);
sock = socket(PF_UNIX, SOCK_DGRAM, 0);
if(sock < 0) {
@@ -2088,7 +2089,7 @@ static int qsap_send_cmd_to_hostapd(s8 *pcmd)
ser.sun_family = AF_UNIX;
qsap_scnprintf(ser.sun_path, sizeof(ser.sun_path), "%s", ptr);
ALOGV("Connect to: %s,(%d)\n", ser.sun_path, sock);
ALOGD("Connect to: %s,(%d)\n", ser.sun_path, sock);
ret = connect(sock, (struct sockaddr *)&ser, sizeof(ser));
if(ret < 0) {
@@ -2243,7 +2244,7 @@ static void qsap_config_wps_method(s8 *pVal, s8 *presp, u32 *plen)
qsap_scnprintf(buf, sizeof(buf), "WPS_PBC");
else {
if(strlen(ptr) < WPS_KEY_LEN) {
ALOGV("%s :Invalid WPS key length\n", __func__);
ALOGD("%s :Invalid WPS key length\n", __func__);
*plen = qsap_scnprintf(presp, *plen, "%s", ERR_INVALID_PARAM);
return;
}
@@ -2435,6 +2436,7 @@ static int qsap_set_operating_mode(s32 mode, s8 *pmode, int pmode_len, s8 *tbuf,
qsap_change_cfg(pcfg, &cmd_list[eCMD_REQUIRE_HT],ENABLE);
/* fall through */
case HW_MODE_N:
case HW_MODE_G:
case HW_MODE_A:
ulen = *tlen;
qsap_write_cfg(pcfg, &cmd_list[eCMD_IEEE80211N],ieee11n_enable, tbuf, &ulen, HOSTAPD_CONF_QCOM_FILE);
@@ -2524,6 +2526,15 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen)
SKIP_BLANK_SPACE(pcmd);
if(!(strncmp(pcmd, Conf_req[CONF_2g], strlen(Conf_req[CONF_2g])))) {
pcmd += strlen(Conf_req[CONF_2g]);
SKIP_BLANK_SPACE(pcmd);
} else if (!(strncmp(pcmd, Conf_req[CONF_5g], strlen(Conf_req[CONF_5g])))) {
pcmd += strlen(Conf_req[CONF_5g]);
SKIP_BLANK_SPACE(pcmd);
} else {
// DO NOTHING
}
cNum = qsap_get_cmd_num(pcmd);
if(cNum == eCMD_INVALID) {
*plen = qsap_scnprintf(presp, *plen, "%s", ERR_INVALID_ARG);
@@ -2637,10 +2648,27 @@ 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;
/* Disable ssid2 while setting ssid */
qsap_change_cfg(pcfg, &cmd_list[eCMD_SSID2], DISABLE);
break;
case eCMD_SET_MAX_CLIENTS:
@@ -3015,19 +3043,32 @@ 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);
*plen = qsap_scnprintf(presp, *plen, "%s", (value == eSUCCESS) ? SUCCESS :
ERR_UNKNOWN);
return;
case eCMD_SSID2:
/* Disable ssid while setting ssid2 */
qsap_change_cfg(pcfg, &cmd_list[eCMD_SSID], DISABLE);
break;
default: ;
/** Do not goto error, in default case */
}
if(ini == INI_CONF_FILE) {
ALOGV("WRITE TO INI FILE :%s\n", qsap_str[cNum].name);
ALOGD("WRITE TO INI FILE :%s\n", qsap_str[cNum].name);
qsap_write_cfg(fIni, &qsap_str[cNum], pVal, presp, plen, ini);
}
else {
@@ -3056,10 +3097,20 @@ error:
*/
void qsap_hostd_exec_cmd(s8 *pcmd, s8 *presp, u32 *plen)
{
ALOGV("CMD INPUT [%s][%lu]\n", pcmd, *plen);
ALOGD("CMD INPUT [%s][%lu]\n", pcmd, *plen);
/* Skip any blank spaces */
SKIP_BLANK_SPACE(pcmd);
if(!(strncmp(pcmd, Cmd_req[eCMD_SET], strlen(Cmd_req[eCMD_SET])))) {
if(!(strncmp(pcmd+4, Conf_req[CONF_2g], strlen(Conf_req[CONF_2g])))) {
pconffile = CONFIG_FILE_2G;
} else if (!(strncmp(pcmd+4, Conf_req[CONF_5g], strlen(Conf_req[CONF_5g])))) {
pconffile = CONFIG_FILE_5G;
} else {
pconffile = CONFIG_FILE;
}
}
check_for_configuration_files();
if(fIni == NULL)
qsap_set_ini_filename();
@@ -3076,18 +3127,20 @@ void qsap_hostd_exec_cmd(s8 *pcmd, s8 *presp, u32 *plen)
*plen = qsap_scnprintf(presp, *plen, "%s", ERR_INVALIDREQ);
}
ALOGV("CMD OUTPUT [%s]\nlen :%lu\n\n", presp, *plen);
ALOGD("CMD OUTPUT [%s]\nlen :%lu\n\n", presp, *plen);
return;
}
/* netd and Froyo Native UI specific API */
#define DEFAULT_INTFERACE "wlan0"
#define DEFAULT_SSID "SOFTAP_SSID"
#define DEFAULT_CHANNEL 4
#define DEFAULT_PASSPHRASE "12345678"
#define DEFAULT_AUTH_ALG 1
#define RECV_BUF_LEN 255
#define CMD_BUF_LEN 255
#define SET_BUF_LEN 15
/** Command input
argv[3] = SSID,
@@ -3104,19 +3157,48 @@ int qsapsetSoftap(int argc, char *argv[])
int i;
int hidden = 0;
int sec = SEC_MODE_NONE;
char setCmd[SET_BUF_LEN];
int offset = 0;
ALOGV("%s, %s, %s, %d\n", __FUNCTION__, argv[0], argv[1], argc);
ALOGD("%s, %s, %s, %d\n", __FUNCTION__, argv[0], argv[1], argc);
for ( i=0; i<argc;i++) {
ALOGV("ARG: %d - %s\n", i+1, argv[i]);
ALOGD("ARG: %d - %s\n", i+1, argv[i]);
}
// 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 */
if (argc > 2) {
snprintf(cmdbuf, CMD_BUF_LEN, "%s interface=%s", setCmd, argv[2 + offset]);
}
else {
snprintf(cmdbuf, CMD_BUF_LEN, "%s interface=%s", setCmd, 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]);
// In case of dual2g/5g, Set ssid2 with hex values to accomodate sapce and special characters.
if (offset)
qsap_scnprintf(cmdbuf, sizeof(cmdbuf), "%s ssid2=%s", setCmd, argv[3 + offset]);
else
qsap_scnprintf(cmdbuf, sizeof(cmdbuf), "%s ssid=%s",setCmd, argv[3]);
}
else {
qsap_scnprintf(cmdbuf, sizeof(cmdbuf), "set ssid=%s_%d", DEFAULT_SSID, rand());
qsap_scnprintf(cmdbuf, sizeof(cmdbuf), "%s ssid=%s_%d", setCmd, DEFAULT_SSID, rand());
}
(void) qsap_hostd_exec_cmd(cmdbuf, respbuf, &rlen);
@@ -3127,10 +3209,10 @@ int qsapsetSoftap(int argc, char *argv[])
rlen = RECV_BUF_LEN;
if (argc > 4) {
if (strcmp(argv[4], "hidden") == 0) {
if (strcmp(argv[4 + offset], "hidden") == 0) {
hidden = 1;
}
snprintf(cmdbuf, CMD_BUF_LEN, "set ignore_broadcast_ssid=%d", hidden);
snprintf(cmdbuf, CMD_BUF_LEN, "%s ignore_broadcast_ssid=%d", setCmd, hidden);
(void) qsap_hostd_exec_cmd(cmdbuf, respbuf, &rlen);
if(strncmp("success", respbuf, rlen) != 0) {
ALOGE("Failed to set ignore_broadcast_ssid \n");
@@ -3140,7 +3222,7 @@ int qsapsetSoftap(int argc, char *argv[])
/** channel */
rlen = RECV_BUF_LEN;
if(argc > 5) {
snprintf(cmdbuf, CMD_BUF_LEN, "set channel=%d", atoi(argv[5]));
snprintf(cmdbuf, CMD_BUF_LEN, "%s channel=%d", setCmd, atoi(argv[5 + offset]));
(void) qsap_hostd_exec_cmd(cmdbuf, respbuf, &rlen);
if(strncmp("success", respbuf, rlen) != 0) {
@@ -3154,22 +3236,22 @@ int qsapsetSoftap(int argc, char *argv[])
if(argc > 6) {
/**TODO : need to identify the SEC strings for "wep", "wpa", "wpa2" */
if(!strcmp(argv[6], "open"))
if(!strcmp(argv[6 + offset], "open"))
sec = SEC_MODE_NONE;
else if(!strcmp(argv[6], "wep"))
else if(!strcmp(argv[6 + offset], "wep"))
sec = SEC_MODE_WEP;
else if(!strcmp(argv[6], "wpa-psk"))
else if(!strcmp(argv[6 + offset], "wpa-psk"))
sec = SEC_MODE_WPA_PSK;
else if(!strcmp(argv[6], "wpa2-psk"))
else if(!strcmp(argv[6 + offset], "wpa2-psk"))
sec = SEC_MODE_WPA2_PSK;
qsap_scnprintf(cmdbuf, sizeof(cmdbuf), "set security_mode=%d",sec);
qsap_scnprintf(cmdbuf, sizeof(cmdbuf), "%s security_mode=%d",setCmd, sec);
}
else {
qsap_scnprintf(cmdbuf, sizeof(cmdbuf) , "set security_mode=%d", DEFAULT_AUTH_ALG);
qsap_scnprintf(cmdbuf, sizeof(cmdbuf) , "%s security_mode=%d", setCmd, DEFAULT_AUTH_ALG);
}
(void) qsap_hostd_exec_cmd(cmdbuf, respbuf, &rlen);
@@ -3184,11 +3266,11 @@ int qsapsetSoftap(int argc, char *argv[])
if ( (sec == SEC_MODE_WPA_PSK) || (sec == SEC_MODE_WPA2_PSK) ) {
if(argc > 7) {
/* If the input passphrase is more than 63 characters, consider first 63 characters only*/
if ( strlen(argv[7]) > 63 ) argv[7][63] = '\0';
qsap_scnprintf(cmdbuf, CMD_BUF_LEN, "set wpa_passphrase=%s",argv[7]);
if ( strlen(argv[7 + offset]) > 63 ) argv[7 + offset][63] = '\0';
qsap_scnprintf(cmdbuf, CMD_BUF_LEN, "%s wpa_passphrase=%s",setCmd, argv[7 + offset]);
}
else {
qsap_scnprintf(cmdbuf, sizeof(cmdbuf), "set wpa_passphrase=%s", DEFAULT_PASSPHRASE);
qsap_scnprintf(cmdbuf, sizeof(cmdbuf), "%s wpa_passphrase=%s", setCmd, DEFAULT_PASSPHRASE);
}
}
@@ -3200,7 +3282,7 @@ int qsapsetSoftap(int argc, char *argv[])
rlen = RECV_BUF_LEN;
if(argc > 8) {
qsap_scnprintf(cmdbuf, sizeof(cmdbuf), "set max_num_sta=%d",atoi(argv[8]));
qsap_scnprintf(cmdbuf, sizeof(cmdbuf), "%s max_num_sta=%d",setCmd, atoi(argv[8 + offset]));
}
(void) qsap_hostd_exec_cmd(cmdbuf, respbuf, &rlen);
@@ -3210,7 +3292,7 @@ int qsapsetSoftap(int argc, char *argv[])
}
rlen = RECV_BUF_LEN;
qsap_scnprintf(cmdbuf, sizeof(cmdbuf), "set commit");
qsap_scnprintf(cmdbuf, sizeof(cmdbuf), "%s commit", setCmd);
(void) qsap_hostd_exec_cmd(cmdbuf, respbuf, &rlen);
@@ -3244,14 +3326,14 @@ void check_for_configuration_files(void)
/* Check if configuration files are present, if not create the default files */
/* If configuration file does not exist copy the default file */
if ( NULL == (fp = fopen(CONFIG_FILE, "r")) ) {
wifi_qsap_reset_to_default(CONFIG_FILE, DEFAULT_CONFIG_FILE_PATH);
if ( NULL == (fp = fopen(pconffile, "r")) ) {
wifi_qsap_reset_to_default(pconffile, DEFAULT_CONFIG_FILE_PATH);
}
else {
/* The configuration file could be of 0 byte size, replace with default */
if (check_for_config_file_size(fp) <= 0)
wifi_qsap_reset_to_default(CONFIG_FILE, DEFAULT_CONFIG_FILE_PATH);
wifi_qsap_reset_to_default(pconffile, DEFAULT_CONFIG_FILE_PATH);
fclose(fp);
}
@@ -3275,12 +3357,6 @@ void check_for_configuration_files(void)
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);
@@ -3300,12 +3376,6 @@ void check_for_configuration_files(void)
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;
}
@@ -3318,3 +3388,196 @@ void qsap_set_ini_filename(void)
ALOGE("INI FILE PROP NOT PRESENT: Use default path %s\n", fIni);
return;
}
// IOCTL command to create and delete bridge interface //
#ifndef SIOCBRADDBR
#define SIOCBRADDBR 0x89a0
#endif
#ifndef SIOCBRDELBR
#define SIOCBRDELBR 0x89a1
#endif
static int linux_set_iface_flags(int sock, const char *ifname, int dev_up)
{
struct ifreq ifr;
int ret;
if (sock < 0)
return -1;
memset(&ifr, 0, sizeof(ifr));
strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
if (ioctl(sock, SIOCGIFFLAGS, &ifr) != 0) {
ret = errno ? -errno : -999;
ALOGE("Could not read interface %s flags: %s",
ifname, strerror(errno));
return ret;
}
if (dev_up) {
if (ifr.ifr_flags & IFF_UP)
return 0;
ifr.ifr_flags |= IFF_UP;
} else {
if (!(ifr.ifr_flags & IFF_UP))
return 0;
ifr.ifr_flags &= ~IFF_UP;
}
if (ioctl(sock, SIOCSIFFLAGS, &ifr) != 0) {
ret = errno ? -errno : -999;
ALOGE("Could not set interface %s flags (%s): %s",
ifname, dev_up ? "UP" : "DOWN", strerror(errno));
return ret;
}
return 0;
}
int qsap_control_bridge(int argc, char ** argv)
{
int br_socket;
if (argc < 4) {
ALOGE("Command not supported");
return -1;
}
br_socket = socket(PF_INET, SOCK_DGRAM, 0);
if (br_socket < 0) {
ALOGE("socket(PF_INET,SOCK_DGRAM): %s",strerror(errno));
return -1;
}
if (!strncmp(argv[2],"create", 6)) {
if (ioctl(br_socket, SIOCBRADDBR, argv[3]) < 0) {
ALOGE("Could not add bridge %s: %s", argv[3], strerror(errno));
return -1;
}
} else if (!strncmp(argv[2],"remove", 6)) {
if (ioctl(br_socket, SIOCBRDELBR, argv[3]) < 0) {
ALOGE("Could not add remove %s: %s", argv[3], strerror(errno));
return -1;
}
} else if (!strncmp(argv[2],"up", 2)) {
return linux_set_iface_flags(br_socket, argv[3], 1);
} else if (!strncmp(argv[2],"down", 4)) {
return linux_set_iface_flags(br_socket, argv[3], 0);
} else {
ALOGE("Command %s not handled.", argv[2]);
return -1;
}
return 0;
}
int linux_get_ifhwaddr(const char *ifname, char *addr)
{
struct ifreq ifr;
int sock = socket(AF_INET, SOCK_DGRAM, 0);
#ifndef MAC2STR
#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
#endif
memset(&ifr, 0, sizeof(ifr));
strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
if (ioctl(sock, SIOCGIFHWADDR, &ifr)) {
ALOGE("Could not get interface %s hwaddr: %s", ifname, strerror(errno));
return -1;
}
if (ifr.ifr_hwaddr.sa_family != ARPHRD_ETHER) {
ALOGE("%s: Invalid HW-addr family 0x%04x", ifname, ifr.ifr_hwaddr.sa_family);
return -1;
}
memcpy(addr, ifr.ifr_hwaddr.sa_data, ETH_ALEN);
ALOGE("%s: " MACSTR, ifname, MAC2STR(addr));
return 0;
}
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;
}

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

@@ -34,7 +34,7 @@
#if __cplusplus
extern "C" {
#endif
#include <android/log.h>
typedef unsigned char u8;
typedef char s8;
typedef unsigned short int u16;
@@ -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
@@ -89,6 +88,10 @@ enum error_val {
#define WIFI_DRIVER_DEF_CONF_FILE NULL
#endif
/** Configuration file name for SAP+SAP*/
#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/misc/wifi/hostapd.conf"
@@ -208,7 +211,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)
@@ -245,6 +248,14 @@ enum eCmd_req {
eCMD_REQ_LAST
};
/** config request index - in the array Conf_req[] */
enum eConf_req {
CONF_2g = 0,
CONF_5g = 1,
CONF_REQ_LAST
};
/**
* Command numbers, these numbers form the index into the array of
* command names stored in the 'cmd_list'.
@@ -330,6 +341,13 @@ typedef enum esap_cmd {
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_SSID2 = 74,
eCMD_BRIDGE = 75,
eCMD_CTRL_INTERFACE = 76,
eCMD_LAST /** New command numbers should be added above this */
} esap_cmd_t;
@@ -581,11 +599,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);
@@ -593,6 +615,11 @@ 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);
int qsap_control_bridge(int argc, char ** argv);
int linux_get_ifhwaddr(const char *ifname, char *addr);
#if __cplusplus
}; // extern "C"