softap: support for starting/stopping Wigig soft AP
Support new command: eCMD_ENABLE_WIGIG_SOFTAP. Change-Id: Idf747b74191de4904ca939601a263b9fb8f9e971 CRs-Fixed: 1016741
This commit is contained in:
committed by
Gerrit - the friendly Code Review server
parent
4d6c04aa73
commit
350c353182
@@ -584,3 +584,114 @@ 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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -159,6 +159,8 @@ static struct Command cmd_list[eCMD_LAST] = {
|
||||
{ "chanlist", NULL },
|
||||
{ "ht_capab", NULL },
|
||||
{ "ieee80211h", NULL },
|
||||
|
||||
{ "enable_wigig_softap", NULL },
|
||||
};
|
||||
|
||||
struct Command qsap_str[eSTR_LAST] = {
|
||||
@@ -2633,6 +2635,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");
|
||||
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)
|
||||
|
||||
@@ -331,6 +331,8 @@ typedef enum esap_cmd {
|
||||
eCMD_HT_CAPAB = 70,
|
||||
eCMD_IEEE80211H = 71,
|
||||
|
||||
eCMD_ENABLE_WIGIG_SOFTAP = 72,
|
||||
|
||||
eCMD_LAST /** New command numbers should be added above this */
|
||||
} esap_cmd_t;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user