Compare commits
17 Commits
cm-13.0
...
cm-14.1_pr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7bebb68631 | ||
|
|
ed3a0c2a26 | ||
|
|
fc4e0df7b2 | ||
|
|
31e1ef0ca4 | ||
|
|
f4e6d19070 | ||
|
|
f4eef25c34 | ||
|
|
5cf4b594e9 | ||
|
|
421ce6f83e | ||
|
|
f70b065f22 | ||
|
|
c160697b1f | ||
|
|
6228c9263b | ||
|
|
2a1b069ae0 | ||
|
|
7cab567836 | ||
|
|
350c353182 | ||
|
|
4d6c04aa73 | ||
|
|
5c1a3abaf0 | ||
|
|
1e2073ebaf |
4
softap/sdk/Android.mk
Normal file → Executable file
4
softap/sdk/Android.mk
Normal file → Executable file
@@ -4,7 +4,7 @@ LOCAL_PATH := $(call my-dir)
|
|||||||
|
|
||||||
include $(CLEAR_VARS)
|
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
|
LOCAL_MODULE:= libqsap_sdk
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ LOCAL_SRC_FILES := qsap_api.c \
|
|||||||
|
|
||||||
LOCAL_PRELINK_MODULE := false
|
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)
|
include $(BUILD_SHARED_LIBRARY)
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,7 @@
|
|||||||
|
|
||||||
#include "qsap_api.h"
|
#include "qsap_api.h"
|
||||||
#include "qsap.h"
|
#include "qsap.h"
|
||||||
|
#include "wifi_fst.h"
|
||||||
|
|
||||||
#include <sys/system_properties.h>
|
#include <sys/system_properties.h>
|
||||||
|
|
||||||
@@ -584,3 +585,173 @@ s32 wifi_qsap_reload_softap()
|
|||||||
|
|
||||||
return eSUCCESS;
|
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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ s32 commit(void);
|
|||||||
s32 is_softap_enabled(void);
|
s32 is_softap_enabled(void);
|
||||||
s32 wifi_qsap_start_softap(void);
|
s32 wifi_qsap_start_softap(void);
|
||||||
s32 wifi_qsap_stop_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_reload_softap(void);
|
||||||
s32 wifi_qsap_unload_wifi_sta_driver(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);
|
s32 wifi_qsap_stop_softap_in_concurrency(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
s32 wifi_qsap_set_tx_power(s32);
|
||||||
|
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
}; // extern "C"
|
}; // extern "C"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
185
softap/sdk/qsap_api.c
Normal file → Executable file
185
softap/sdk/qsap_api.c
Normal file → Executable file
@@ -44,6 +44,12 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <private/android_filesystem_config.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_api.h"
|
||||||
#include "qsap.h"
|
#include "qsap.h"
|
||||||
@@ -158,6 +164,9 @@ static struct Command cmd_list[eCMD_LAST] = {
|
|||||||
{ "vht_oper_chwidth", NULL },
|
{ "vht_oper_chwidth", NULL },
|
||||||
{ "chanlist", NULL },
|
{ "chanlist", NULL },
|
||||||
{ "ht_capab", NULL },
|
{ "ht_capab", NULL },
|
||||||
|
{ "ieee80211h", NULL },
|
||||||
|
{ "enable_wigig_softap", NULL },
|
||||||
|
{ "interface", NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Command qsap_str[eSTR_LAST] = {
|
struct Command qsap_str[eSTR_LAST] = {
|
||||||
@@ -310,7 +319,7 @@ static s32 qsap_write_cfg(s8 *pfile, struct Command * pcmd, s8 *pVal, s8 *presp,
|
|||||||
s8 buf[MAX_CONF_LINE_LEN+1];
|
s8 buf[MAX_CONF_LINE_LEN+1];
|
||||||
s16 len, result = FALSE;
|
s16 len, result = FALSE;
|
||||||
|
|
||||||
ALOGD("cmd=%s, Val:%s, INI:%ld \n", pcmd->name, pVal, inifile);
|
ALOGV("cmd=%s, Val:%s, INI:%ld \n", pcmd->name, pVal, inifile);
|
||||||
|
|
||||||
/** Open the configuration file */
|
/** Open the configuration file */
|
||||||
fcfg = fopen(pfile, "r");
|
fcfg = fopen(pfile, "r");
|
||||||
@@ -345,7 +354,7 @@ static s32 qsap_write_cfg(s8 *pfile, struct Command * pcmd, s8 *pVal, s8 *presp,
|
|||||||
if(pline[len] == '=') {
|
if(pline[len] == '=') {
|
||||||
qsap_scnprintf(buf, sizeof(buf), "%s=%s\n", pcmd->name, pVal);
|
qsap_scnprintf(buf, sizeof(buf), "%s=%s\n", pcmd->name, pVal);
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
ALOGD("Updated:%s\n", buf);
|
ALOGV("Updated:%s\n", buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,7 +369,7 @@ static s32 qsap_write_cfg(s8 *pfile, struct Command * pcmd, s8 *pVal, s8 *presp,
|
|||||||
/* Add the new line at the end of file */
|
/* Add the new line at the end of file */
|
||||||
qsap_scnprintf(buf, sizeof(buf), "%s=%s\n", pcmd->name, pVal);
|
qsap_scnprintf(buf, sizeof(buf), "%s=%s\n", pcmd->name, pVal);
|
||||||
fprintf(ftmp, "%s", buf);
|
fprintf(ftmp, "%s", buf);
|
||||||
ALOGD("Adding a new line in %s file: [%s] \n", inifile ? "inifile" : "hostapd.conf", buf);
|
ALOGV("Adding a new line in %s file: [%s] \n", inifile ? "inifile" : "hostapd.conf", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(inifile) {
|
if(inifile) {
|
||||||
@@ -703,7 +712,6 @@ end:
|
|||||||
static s8 *qsap_get_allow_deny_file_name(s8 *pcfgfile, struct Command * pcmd, s8 *pfile, u32 *plen)
|
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)) {
|
if(eSUCCESS == qsap_read_cfg(pcfgfile, pcmd, pfile, plen, NULL, GET_ENABLED_ONLY)) {
|
||||||
pfile[*plen] = '\0';
|
|
||||||
return strchr(pfile, '=') + 1;
|
return strchr(pfile, '=') + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -972,7 +980,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)
|
static void qsap_update_mac_list(s8 *pfile, esap_cmd_t cNum, s8 *pVal, s8 *presp, u32 *plen)
|
||||||
{
|
{
|
||||||
ALOGD("%s : Updating file %s \n", __func__, pfile);
|
ALOGV("%s : Updating file %s \n", __func__, pfile);
|
||||||
|
|
||||||
switch(cNum) {
|
switch(cNum) {
|
||||||
case eCMD_ADD_TO_ALLOW:
|
case eCMD_ADD_TO_ALLOW:
|
||||||
@@ -1127,7 +1135,7 @@ static int qsap_read_mac_address(s8 *presp, u32 *plen)
|
|||||||
|
|
||||||
ptr++;
|
ptr++;
|
||||||
|
|
||||||
ALOGD("MAC :%s \n", ptr);
|
ALOGV("MAC :%s \n", ptr);
|
||||||
if(TRUE == isValid_MAC_address(ptr)) {
|
if(TRUE == isValid_MAC_address(ptr)) {
|
||||||
nRet = eSUCCESS;
|
nRet = eSUCCESS;
|
||||||
}
|
}
|
||||||
@@ -1163,7 +1171,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))) {
|
if(NULL == (pstate = qsap_get_config_value(pconffile, &cmd_list[eCMD_WPS_STATE], presp, &tlen))) {
|
||||||
/** unable to read the wps configuration, WPS is disabled !*/
|
/** unable to read the wps configuration, WPS is disabled !*/
|
||||||
ALOGD("%s :wps_state not in cfg file \n", __func__);
|
ALOGV("%s :wps_state not in cfg file \n", __func__);
|
||||||
status = DISABLE;
|
status = DISABLE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1218,9 +1226,9 @@ int qsap_get_operating_channel(s32 *pchan)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
ALOGE("Recv len :%d \n", wrq.u.data.length);
|
ALOGV("Recv len :%d \n", wrq.u.data.length);
|
||||||
*pchan = *(int *)(&wrq.u.name[0]);
|
*pchan = *(int *)(&wrq.u.name[0]);
|
||||||
ALOGE("Operating channel :%ld \n", *pchan);
|
ALOGV("Operating channel :%ld \n", *pchan);
|
||||||
close(sock);
|
close(sock);
|
||||||
return eSUCCESS;
|
return eSUCCESS;
|
||||||
|
|
||||||
@@ -1251,7 +1259,7 @@ int qsap_get_sap_auto_channel_selection(s32 *pautochan)
|
|||||||
|
|
||||||
if(NULL == (pif = qsap_get_config_value(pconffile,
|
if(NULL == (pif = qsap_get_config_value(pconffile,
|
||||||
&qsap_str[STR_INTERFACE], interface, &len))) {
|
&qsap_str[STR_INTERFACE], interface, &len))) {
|
||||||
ALOGD("%s :interface error \n", __func__);
|
ALOGV("%s :interface error \n", __func__);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1259,7 +1267,7 @@ int qsap_get_sap_auto_channel_selection(s32 *pautochan)
|
|||||||
|
|
||||||
sock = socket(AF_INET, SOCK_DGRAM, 0);
|
sock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
if(sock < 0) {
|
if(sock < 0) {
|
||||||
ALOGD("%s :socket error \n", __func__);
|
ALOGV("%s :socket error \n", __func__);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1282,9 +1290,9 @@ int qsap_get_sap_auto_channel_selection(s32 *pautochan)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
ALOGD("Recv len :%d \n", wrq.u.data.length);
|
ALOGV("Recv len :%d \n", wrq.u.data.length);
|
||||||
*pautochan = *(int *)(&wrq.u.name[0]);
|
*pautochan = *(int *)(&wrq.u.name[0]);
|
||||||
ALOGD("Sap auto channel selection pautochan=%ld \n", *pautochan);
|
ALOGV("Sap auto channel selection pautochan=%ld \n", *pautochan);
|
||||||
close(sock);
|
close(sock);
|
||||||
return eSUCCESS;
|
return eSUCCESS;
|
||||||
|
|
||||||
@@ -1312,7 +1320,7 @@ int qsap_get_mode(s32 *pmode)
|
|||||||
*pmode = -1;
|
*pmode = -1;
|
||||||
if(NULL == (pif = qsap_get_config_value(pconffile,
|
if(NULL == (pif = qsap_get_config_value(pconffile,
|
||||||
&qsap_str[STR_INTERFACE], interface, &len))) {
|
&qsap_str[STR_INTERFACE], interface, &len))) {
|
||||||
ALOGD("%s :interface error \n", __func__);
|
ALOGV("%s :interface error \n", __func__);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1320,7 +1328,7 @@ int qsap_get_mode(s32 *pmode)
|
|||||||
|
|
||||||
sock = socket(AF_INET, SOCK_DGRAM, 0);
|
sock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
if(sock < 0) {
|
if(sock < 0) {
|
||||||
ALOGD("%s :socket error \n", __func__);
|
ALOGV("%s :socket error \n", __func__);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1424,7 +1432,7 @@ int qsap_set_channel_range(s8 *buf)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
ALOGE("Recv len :%d\n", wrq.u.data.length);
|
ALOGV("Recv len :%d\n", wrq.u.data.length);
|
||||||
|
|
||||||
close(sock);
|
close(sock);
|
||||||
return eSUCCESS;
|
return eSUCCESS;
|
||||||
@@ -1442,7 +1450,7 @@ int qsap_read_channel(s8 *pfile, struct Command *pcmd, s8 *presp, u32 *plen, s8
|
|||||||
|
|
||||||
if(eSUCCESS == qsap_get_operating_channel(&chan)) {
|
if(eSUCCESS == qsap_get_operating_channel(&chan)) {
|
||||||
*plen = qsap_scnprintf(presp, len, "%s %s=%lu", SUCCESS, pcmd->name, chan);
|
*plen = qsap_scnprintf(presp, len, "%s %s=%lu", SUCCESS, pcmd->name, chan);
|
||||||
ALOGD("presp :%s\n", presp);
|
ALOGV("presp :%s\n", presp);
|
||||||
} else {
|
} else {
|
||||||
*plen = qsap_scnprintf(presp, len, "%s", ERR_UNKNOWN);
|
*plen = qsap_scnprintf(presp, len, "%s", ERR_UNKNOWN);
|
||||||
}
|
}
|
||||||
@@ -1754,6 +1762,7 @@ static void qsap_get_from_config(esap_cmd_t cNum, s8 *presp, u32 *plen)
|
|||||||
case eCMD_FRAG_THRESHOLD:
|
case eCMD_FRAG_THRESHOLD:
|
||||||
case eCMD_REGULATORY_DOMAIN:
|
case eCMD_REGULATORY_DOMAIN:
|
||||||
case eCMD_RTS_THRESHOLD:
|
case eCMD_RTS_THRESHOLD:
|
||||||
|
case eCMD_IEEE80211H:
|
||||||
qsap_read_cfg(pconffile, &cmd_list[cNum], presp, plen, NULL, GET_ENABLED_ONLY);
|
qsap_read_cfg(pconffile, &cmd_list[cNum], presp, plen, NULL, GET_ENABLED_ONLY);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1922,7 +1931,7 @@ static s16 is_valid_wep_key(s8 *pwep, s8 *pkey, s16 len)
|
|||||||
weplen--;
|
weplen--;
|
||||||
while(weplen--) {
|
while(weplen--) {
|
||||||
if(0 == isascii(pwep[weplen])) {
|
if(0 == isascii(pwep[weplen])) {
|
||||||
ALOGD("%c not ascii \n", pwep[weplen]);
|
ALOGV("%c not ascii \n", pwep[weplen]);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1981,6 +1990,11 @@ s16 wifi_qsap_reset_to_default(s8 *pcfgfile, s8 *pdefault)
|
|||||||
if(eERR_UNKNOWN == rename(buf, pcfgfile))
|
if(eERR_UNKNOWN == rename(buf, pcfgfile))
|
||||||
status = eERR_CONF_FILE;
|
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 */
|
/** Remove the temporary file. Dont care the return value */
|
||||||
unlink(buf);
|
unlink(buf);
|
||||||
|
|
||||||
@@ -2063,7 +2077,7 @@ static int qsap_send_cmd_to_hostapd(s8 *pcmd)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
ALOGD("Connect to :%s\n", ptr);
|
ALOGV("Connect to :%s\n", ptr);
|
||||||
|
|
||||||
sock = socket(PF_UNIX, SOCK_DGRAM, 0);
|
sock = socket(PF_UNIX, SOCK_DGRAM, 0);
|
||||||
if(sock < 0) {
|
if(sock < 0) {
|
||||||
@@ -2083,7 +2097,7 @@ static int qsap_send_cmd_to_hostapd(s8 *pcmd)
|
|||||||
|
|
||||||
ser.sun_family = AF_UNIX;
|
ser.sun_family = AF_UNIX;
|
||||||
qsap_scnprintf(ser.sun_path, sizeof(ser.sun_path), "%s", ptr);
|
qsap_scnprintf(ser.sun_path, sizeof(ser.sun_path), "%s", ptr);
|
||||||
ALOGD("Connect to: %s,(%d)\n", ser.sun_path, sock);
|
ALOGV("Connect to: %s,(%d)\n", ser.sun_path, sock);
|
||||||
|
|
||||||
ret = connect(sock, (struct sockaddr *)&ser, sizeof(ser));
|
ret = connect(sock, (struct sockaddr *)&ser, sizeof(ser));
|
||||||
if(ret < 0) {
|
if(ret < 0) {
|
||||||
@@ -2238,7 +2252,7 @@ static void qsap_config_wps_method(s8 *pVal, s8 *presp, u32 *plen)
|
|||||||
qsap_scnprintf(buf, sizeof(buf), "WPS_PBC");
|
qsap_scnprintf(buf, sizeof(buf), "WPS_PBC");
|
||||||
else {
|
else {
|
||||||
if(strlen(ptr) < WPS_KEY_LEN) {
|
if(strlen(ptr) < WPS_KEY_LEN) {
|
||||||
ALOGD("%s :Invalid WPS key length\n", __func__);
|
ALOGV("%s :Invalid WPS key length\n", __func__);
|
||||||
*plen = qsap_scnprintf(presp, *plen, "%s", ERR_INVALID_PARAM);
|
*plen = qsap_scnprintf(presp, *plen, "%s", ERR_INVALID_PARAM);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2632,6 +2646,21 @@ 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");
|
*plen = qsap_scnprintf(presp, *plen, "%s", (status==eSUCCESS) ? SUCCESS : "failure Could not enable softap");
|
||||||
return;
|
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:
|
case eCMD_SSID:
|
||||||
value = strlen(pVal);
|
value = strlen(pVal);
|
||||||
if(SSD_MAX_LEN < value)
|
if(SSD_MAX_LEN < value)
|
||||||
@@ -3010,6 +3039,15 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen)
|
|||||||
cNum = STR_AP_ENERGY_DETECT_TH;
|
cNum = STR_AP_ENERGY_DETECT_TH;
|
||||||
ini = INI_CONF_FILE;
|
ini = INI_CONF_FILE;
|
||||||
break;
|
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:
|
case eCMD_SET_CHANNEL_RANGE:
|
||||||
ALOGE("eCMD_SET_CHANNEL_RANGE pcmd :%s\n", pcmd);
|
ALOGE("eCMD_SET_CHANNEL_RANGE pcmd :%s\n", pcmd);
|
||||||
value = qsap_set_channel_range(pcmd);
|
value = qsap_set_channel_range(pcmd);
|
||||||
@@ -3022,7 +3060,7 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(ini == INI_CONF_FILE) {
|
if(ini == INI_CONF_FILE) {
|
||||||
ALOGD("WRITE TO INI FILE :%s\n", qsap_str[cNum].name);
|
ALOGV("WRITE TO INI FILE :%s\n", qsap_str[cNum].name);
|
||||||
qsap_write_cfg(fIni, &qsap_str[cNum], pVal, presp, plen, ini);
|
qsap_write_cfg(fIni, &qsap_str[cNum], pVal, presp, plen, ini);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -3051,7 +3089,7 @@ error:
|
|||||||
*/
|
*/
|
||||||
void qsap_hostd_exec_cmd(s8 *pcmd, s8 *presp, u32 *plen)
|
void qsap_hostd_exec_cmd(s8 *pcmd, s8 *presp, u32 *plen)
|
||||||
{
|
{
|
||||||
ALOGD("CMD INPUT [%s][%lu]\n", pcmd, *plen);
|
ALOGV("CMD INPUT [%s][%lu]\n", pcmd, *plen);
|
||||||
/* Skip any blank spaces */
|
/* Skip any blank spaces */
|
||||||
SKIP_BLANK_SPACE(pcmd);
|
SKIP_BLANK_SPACE(pcmd);
|
||||||
|
|
||||||
@@ -3071,12 +3109,13 @@ void qsap_hostd_exec_cmd(s8 *pcmd, s8 *presp, u32 *plen)
|
|||||||
*plen = qsap_scnprintf(presp, *plen, "%s", ERR_INVALIDREQ);
|
*plen = qsap_scnprintf(presp, *plen, "%s", ERR_INVALIDREQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
ALOGD("CMD OUTPUT [%s]\nlen :%lu\n\n", presp, *plen);
|
ALOGV("CMD OUTPUT [%s]\nlen :%lu\n\n", presp, *plen);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* netd and Froyo Native UI specific API */
|
/* netd and Froyo Native UI specific API */
|
||||||
|
#define DEFAULT_INTFERACE "wlan0"
|
||||||
#define DEFAULT_SSID "SOFTAP_SSID"
|
#define DEFAULT_SSID "SOFTAP_SSID"
|
||||||
#define DEFAULT_CHANNEL 4
|
#define DEFAULT_CHANNEL 4
|
||||||
#define DEFAULT_PASSPHRASE "12345678"
|
#define DEFAULT_PASSPHRASE "12345678"
|
||||||
@@ -3100,12 +3139,22 @@ int qsapsetSoftap(int argc, char *argv[])
|
|||||||
int hidden = 0;
|
int hidden = 0;
|
||||||
int sec = SEC_MODE_NONE;
|
int sec = SEC_MODE_NONE;
|
||||||
|
|
||||||
ALOGD("%s, %s, %s, %d\n", __FUNCTION__, argv[0], argv[1], argc);
|
ALOGV("%s, %s, %s, %d\n", __FUNCTION__, argv[0], argv[1], argc);
|
||||||
|
|
||||||
for ( i=0; i<argc;i++) {
|
for ( i=0; i<argc;i++) {
|
||||||
ALOGD("ARG: %d - %s\n", i+1, argv[i]);
|
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 */
|
/** set SSID */
|
||||||
if(argc > 3) {
|
if(argc > 3) {
|
||||||
qsap_scnprintf(cmdbuf, sizeof(cmdbuf), "set ssid=%s",argv[3]);
|
qsap_scnprintf(cmdbuf, sizeof(cmdbuf), "set ssid=%s",argv[3]);
|
||||||
@@ -3313,3 +3362,87 @@ void qsap_set_ini_filename(void)
|
|||||||
ALOGE("INI FILE PROP NOT PRESENT: Use default path %s\n", fIni);
|
ALOGE("INI FILE PROP NOT PRESENT: Use default path %s\n", fIni);
|
||||||
return;
|
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;
|
||||||
|
}
|
||||||
|
|||||||
16
softap/sdk/qsap_api.h
Normal file → Executable file
16
softap/sdk/qsap_api.h
Normal file → Executable file
@@ -77,7 +77,8 @@ enum error_val {
|
|||||||
eERR_LOAD_FAILED_SDIOIF,
|
eERR_LOAD_FAILED_SDIOIF,
|
||||||
eERR_LOAD_FAILED_SOFTAP,
|
eERR_LOAD_FAILED_SOFTAP,
|
||||||
eERR_SET_CHAN_RANGE,
|
eERR_SET_CHAN_RANGE,
|
||||||
eERR_GET_AUTO_CHAN
|
eERR_GET_AUTO_CHAN,
|
||||||
|
eERR_SET_TX_POWER
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef WIFI_DRIVER_CONF_FILE
|
#ifndef WIFI_DRIVER_CONF_FILE
|
||||||
@@ -207,7 +208,7 @@ enum error_val {
|
|||||||
#define MIN_UPC_LEN (1)
|
#define MIN_UPC_LEN (1)
|
||||||
#define MAX_UPC_LEN (128)
|
#define MAX_UPC_LEN (128)
|
||||||
|
|
||||||
#define GTK_MIN (600)
|
#define GTK_MIN (30)
|
||||||
|
|
||||||
#define MAX_INT_STR (8)
|
#define MAX_INT_STR (8)
|
||||||
|
|
||||||
@@ -329,6 +330,10 @@ typedef enum esap_cmd {
|
|||||||
eCMD_VHT_OPER_CH_WIDTH = 68,
|
eCMD_VHT_OPER_CH_WIDTH = 68,
|
||||||
eCMD_ACS_CHAN_LIST = 69,
|
eCMD_ACS_CHAN_LIST = 69,
|
||||||
eCMD_HT_CAPAB = 70,
|
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 */
|
eCMD_LAST /** New command numbers should be added above this */
|
||||||
} esap_cmd_t;
|
} esap_cmd_t;
|
||||||
@@ -580,11 +585,15 @@ typedef struct sap_auto_channel_info {
|
|||||||
/** Validate the AP shutoff time */
|
/** 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)
|
#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 */
|
/** Function declartion */
|
||||||
int qsap_hostd_exec(int argc, char ** argv);
|
int qsap_hostd_exec(int argc, char ** argv);
|
||||||
void qsap_hostd_exec_cmd(s8 *pcmd, s8 *presp, u32 *plen);
|
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);
|
s8 *qsap_get_config_value(s8 *pfile, struct Command *pcmd, s8 *pbuf, u32 *plen);
|
||||||
int qsapsetSoftap(int argc, char *argv[]);
|
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);
|
void qsap_del_ctrl_iface(void);
|
||||||
s16 wifi_qsap_reset_to_default(s8 *pcfgfile, s8 *pdefault);
|
s16 wifi_qsap_reset_to_default(s8 *pcfgfile, s8 *pdefault);
|
||||||
void check_for_configuration_files(void);
|
void check_for_configuration_files(void);
|
||||||
@@ -592,6 +601,9 @@ void qsap_set_ini_filename(void);
|
|||||||
int qsap_set_channel_range(s8 * cmd);
|
int qsap_set_channel_range(s8 * cmd);
|
||||||
int qsap_get_sap_auto_channel_slection(s32 *pautochan);
|
int qsap_get_sap_auto_channel_slection(s32 *pautochan);
|
||||||
int qsap_get_mode(s32 *pmode);
|
int qsap_get_mode(s32 *pmode);
|
||||||
|
int qsap_prepare_softap(void);
|
||||||
|
int qsap_unprepare_softap(void);
|
||||||
|
int qsap_is_fst_enabled(void);
|
||||||
|
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
}; // extern "C"
|
}; // extern "C"
|
||||||
|
|||||||
Reference in New Issue
Block a user