2010-10-13 09:11:12 +02:00
|
|
|
/*
|
2012-12-26 09:38:38 +01:00
|
|
|
* Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
|
2010-10-13 09:11:12 +02:00
|
|
|
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met:
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above
|
|
|
|
* copyright notice, this list of conditions and the following
|
|
|
|
* disclaimer in the documentation and/or other materials provided
|
|
|
|
* with the distribution.
|
2012-12-26 09:38:38 +01:00
|
|
|
* * Neither the name of The Linux Foundation, Inc. nor the names of its
|
2010-10-13 09:11:12 +02:00
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
|
|
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
|
|
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
|
|
|
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
|
|
|
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2012-12-26 09:38:38 +01:00
|
|
|
#include <sys/socket.h>
|
2010-10-13 09:11:12 +02:00
|
|
|
#include <linux/if.h>
|
|
|
|
#include <linux/wireless.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
|
|
|
#define LOG_TAG "QCLDR-"
|
|
|
|
|
|
|
|
#include "cutils/log.h"
|
|
|
|
#include "cutils/memory.h"
|
|
|
|
#include "cutils/misc.h"
|
|
|
|
#include "cutils/properties.h"
|
|
|
|
#include "private/android_filesystem_config.h"
|
|
|
|
|
|
|
|
#include "qsap_api.h"
|
|
|
|
#include "qsap.h"
|
|
|
|
#include "libwpa_client/wpa_ctrl.h"
|
|
|
|
|
|
|
|
#include <sys/system_properties.h>
|
|
|
|
|
|
|
|
#ifndef WIFI_DRIVER_MODULE_PATH
|
|
|
|
#define WIFI_DRIVER_MODULE_PATH "/system/lib/modules/wlan.ko"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WIFI_DRIVER_MODULE_NAME
|
|
|
|
#define WIFI_DRIVER_MODULE_NAME "wlan"
|
|
|
|
#endif
|
|
|
|
|
2011-07-15 10:47:15 +02:00
|
|
|
#ifdef WIFI_DRIVER_MODULE_ARG
|
|
|
|
#undef WIFI_DRIVER_MODULE_ARG
|
|
|
|
#endif
|
|
|
|
|
2011-12-22 13:54:56 +01:00
|
|
|
#define WIFI_DRIVER_MODULE_ARG ""
|
2011-07-15 10:47:15 +02:00
|
|
|
|
|
|
|
/* WIFI_SDIO_IF_DRIVER_MODULE_NAME must be defined if sdioif driver required */
|
|
|
|
#ifdef WIFI_SDIO_IF_DRIVER_MODULE_NAME
|
|
|
|
|
2010-10-13 09:11:12 +02:00
|
|
|
#ifndef WIFI_SDIO_IF_DRIVER_MODULE_PATH
|
|
|
|
#define WIFI_SDIO_IF_DRIVER_MODULE_PATH "/system/lib/modules/librasdioif.ko"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef WIFI_SDIO_IF_DRIVER_MODULE_ARG
|
|
|
|
#define WIFI_SDIO_IF_DRIVER_MODULE_ARG ""
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2012-07-17 15:12:07 +02:00
|
|
|
#ifndef WIFI_CFG80211_DRIVER_MODULE_PATH
|
|
|
|
#define WIFI_CFG80211_DRIVER_MODULE_PATH ""
|
|
|
|
#endif
|
|
|
|
#ifndef WIFI_CFG80211_DRIVER_MODULE_NAME
|
|
|
|
#define WIFI_CFG80211_DRIVER_MODULE_NAME ""
|
|
|
|
#endif
|
|
|
|
#ifndef WIFI_CFG80211_DRIVER_MODULE_ARG
|
|
|
|
#define WIFI_CFG80211_DRIVER_MODULE_ARG ""
|
|
|
|
#endif
|
|
|
|
|
2010-10-13 09:11:12 +02:00
|
|
|
|
|
|
|
extern int init_module(const char *name, u32, const s8 *);
|
|
|
|
extern int delete_module(const char *name, int);
|
|
|
|
|
2010-11-15 02:47:11 +01:00
|
|
|
extern struct Command qsap_str[];
|
|
|
|
|
2010-10-13 09:11:12 +02:00
|
|
|
static s32 check_driver_loaded( const s8 * tag)
|
|
|
|
{
|
|
|
|
FILE *proc;
|
|
|
|
s8 line[126];
|
|
|
|
|
|
|
|
if ((proc = fopen("/proc/modules", "r")) == NULL) {
|
2012-07-17 15:12:07 +02:00
|
|
|
ALOGW("Could not open %s: %s", "/proc/modules", strerror(errno));
|
2010-10-13 09:11:12 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
while ((fgets(line, sizeof(line), proc)) != NULL) {
|
|
|
|
if (strncmp(line, tag, strlen(tag)) == 0) {
|
|
|
|
fclose(proc);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(proc);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static s32 insmod(const s8 *filename, const s8 *args, const s8 * tag)
|
|
|
|
{
|
|
|
|
#ifndef SDK_TEST
|
|
|
|
void *module;
|
|
|
|
s32 size;
|
|
|
|
s32 ret = 0;
|
|
|
|
|
|
|
|
if ( check_driver_loaded(tag) ) {
|
2012-07-17 15:12:07 +02:00
|
|
|
ALOGE("Driver: %s already loaded\n", filename);
|
2010-10-13 09:11:12 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-07-17 15:12:07 +02:00
|
|
|
ALOGD("Loading Driver: %s %s\n", filename, args);
|
2010-10-13 09:11:12 +02:00
|
|
|
|
|
|
|
module = (void*)load_file(filename, (unsigned int*)&size);
|
|
|
|
|
|
|
|
if (!module) {
|
2012-07-17 15:12:07 +02:00
|
|
|
ALOGE("Cannot load file: %s\n", filename);
|
2010-10-13 09:11:12 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = init_module(module, size, args);
|
|
|
|
|
|
|
|
if ( ret ) {
|
2012-07-17 15:12:07 +02:00
|
|
|
ALOGE("init_module (%s:%d) failed\n", filename, (int)size);
|
2010-10-13 09:11:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
free(module);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static s32 rmmod(const s8 *modname)
|
|
|
|
{
|
|
|
|
#ifndef SDK_TEST
|
|
|
|
s32 ret = 0;
|
|
|
|
s32 maxtry = 10;
|
|
|
|
|
|
|
|
while (maxtry-- > 0) {
|
|
|
|
ret = delete_module(modname, O_NONBLOCK | O_EXCL);
|
|
|
|
|
|
|
|
if (ret < 0 && errno == EAGAIN){
|
|
|
|
usleep(50000);
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret != 0) {
|
2012-07-17 15:12:07 +02:00
|
|
|
ALOGD("Unable to unload driver module \"%s\": %s\n",
|
2010-10-13 09:11:12 +02:00
|
|
|
modname, strerror(errno));
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static const s8 SDIO_POLLING_ON[] = "/etc/init.qcom.sdio.sh 1";
|
|
|
|
static const s8 SDIO_POLLING_OFF[] = "/etc/init.qcom.sdio.sh 0";
|
2012-07-17 15:12:07 +02:00
|
|
|
static const char DRIVER_CFG80211_MODULE_NAME[] = WIFI_CFG80211_DRIVER_MODULE_NAME;
|
|
|
|
static const char DRIVER_CFG80211_MODULE_PATH[] = WIFI_CFG80211_DRIVER_MODULE_PATH;
|
|
|
|
static const char DRIVER_CFG80211_MODULE_ARG[] = WIFI_CFG80211_DRIVER_MODULE_ARG;
|
2010-10-13 09:11:12 +02:00
|
|
|
|
|
|
|
s32 wifi_qsap_load_driver(void)
|
|
|
|
{
|
|
|
|
s32 size;
|
2012-07-17 15:12:07 +02:00
|
|
|
s32 ret = -1;
|
2010-10-13 09:11:12 +02:00
|
|
|
s32 retry;
|
|
|
|
|
|
|
|
|
|
|
|
if (system(SDIO_POLLING_ON)) {
|
2012-07-17 15:12:07 +02:00
|
|
|
// ALOGE("Could not turn on the polling...");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ('\0' != *DRIVER_CFG80211_MODULE_PATH) {
|
|
|
|
if (insmod(DRIVER_CFG80211_MODULE_PATH, DRIVER_CFG80211_MODULE_ARG,DRIVER_CFG80211_MODULE_NAME) < 0) {
|
|
|
|
ALOGE("Could not load cfg80211...");
|
|
|
|
return ret;
|
|
|
|
}
|
2010-10-13 09:11:12 +02:00
|
|
|
}
|
|
|
|
|
2011-07-15 10:47:15 +02:00
|
|
|
#ifdef WIFI_SDIO_IF_DRIVER_MODULE_NAME
|
|
|
|
ret = insmod(WIFI_SDIO_IF_DRIVER_MODULE_PATH, WIFI_SDIO_IF_DRIVER_MODULE_ARG, WIFI_SDIO_IF_DRIVER_MODULE_NAME " ");
|
2010-10-13 09:11:12 +02:00
|
|
|
|
2011-07-15 10:47:15 +02:00
|
|
|
if ( ret != 0 ) {
|
2012-07-17 15:12:07 +02:00
|
|
|
ALOGE("init_module failed sdioif\n");
|
2011-07-15 10:47:15 +02:00
|
|
|
ret = eERR_LOAD_FAILED_SDIOIF;
|
|
|
|
goto end;
|
2011-07-06 20:23:58 +02:00
|
|
|
}
|
2010-10-13 09:11:12 +02:00
|
|
|
|
2011-07-15 10:47:15 +02:00
|
|
|
sched_yield();
|
|
|
|
#endif
|
|
|
|
|
2010-10-13 09:11:12 +02:00
|
|
|
ret = insmod(WIFI_DRIVER_MODULE_PATH, WIFI_DRIVER_MODULE_ARG, WIFI_DRIVER_MODULE_NAME " ");
|
|
|
|
|
|
|
|
if ( ret != 0 ) {
|
2011-07-15 10:47:15 +02:00
|
|
|
#ifdef WIFI_SDIO_IF_DRIVER_MODULE_NAME
|
|
|
|
if ( check_driver_loaded(WIFI_SDIO_IF_DRIVER_MODULE_NAME " ") ) {
|
|
|
|
if ( rmmod(WIFI_SDIO_IF_DRIVER_MODULE_NAME) ) {
|
2012-07-17 15:12:07 +02:00
|
|
|
ALOGE("Unable to unload the station mode librasdioif driver\n");
|
2010-10-13 09:11:12 +02:00
|
|
|
}
|
|
|
|
}
|
2011-07-15 10:47:15 +02:00
|
|
|
#endif
|
2012-07-17 15:12:07 +02:00
|
|
|
if ('\0' != *DRIVER_CFG80211_MODULE_NAME) {
|
|
|
|
rmmod(DRIVER_CFG80211_MODULE_NAME);
|
|
|
|
}
|
|
|
|
ALOGE("init_module failed libra_softap\n");
|
2010-10-13 09:11:12 +02:00
|
|
|
ret = eERR_LOAD_FAILED_SOFTAP;
|
2012-07-17 15:12:07 +02:00
|
|
|
goto end;
|
2010-10-13 09:11:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sched_yield();
|
|
|
|
|
|
|
|
ret = eSUCCESS;
|
|
|
|
|
|
|
|
end:
|
|
|
|
if(system(SDIO_POLLING_OFF)) {
|
2012-07-17 15:12:07 +02:00
|
|
|
// ALOGE("Could not turn off the polling...");
|
2010-10-13 09:11:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-03-12 19:21:45 +01:00
|
|
|
void qsap_send_module_down_indication(void)
|
|
|
|
{
|
|
|
|
int s, ret;
|
|
|
|
struct iwreq wrq;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the driver is loaded, ask it to broadcast a netlink message
|
|
|
|
* that it will be closing, so listeners can close their sockets.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/* Equivalent to: iwpriv wlan0 sendModuleInd */
|
|
|
|
if ((s = socket(PF_INET, SOCK_DGRAM, 0)) >= 0) {
|
|
|
|
strncpy(wrq.ifr_name, "wlan0", IFNAMSIZ);
|
|
|
|
wrq.u.data.length = 0; /* No Set arguments */
|
|
|
|
wrq.u.mode = 5; /* WE_MODULE_DOWN_IND sub-command */
|
|
|
|
ret = ioctl(s, (SIOCIWFIRSTPRIV + 1), &wrq);
|
|
|
|
if (ret < 0 ) {
|
2011-07-06 20:23:58 +02:00
|
|
|
strncpy(wrq.ifr_name, "softap.0", IFNAMSIZ);
|
|
|
|
ret = ioctl(s, (SIOCIWFIRSTPRIV + 1), &wrq);
|
|
|
|
if (ret < 0 ) {
|
2012-07-17 15:12:07 +02:00
|
|
|
ALOGE("ioctl failed: %s", strerror(errno));
|
2011-07-06 20:23:58 +02:00
|
|
|
}
|
2011-03-12 19:21:45 +01:00
|
|
|
}
|
2011-07-06 20:23:58 +02:00
|
|
|
close(s);
|
2011-03-12 19:21:45 +01:00
|
|
|
sched_yield();
|
|
|
|
}
|
|
|
|
else {
|
2012-07-17 15:12:07 +02:00
|
|
|
ALOGE("Socket open failed: %s", strerror(errno));
|
2011-03-12 19:21:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-31 01:56:29 +01:00
|
|
|
|
|
|
|
s32 qsap_send_init_ap(void)
|
|
|
|
{
|
|
|
|
int s, ret;
|
|
|
|
struct iwreq wrq;
|
|
|
|
s32 status = eSUCCESS;
|
|
|
|
u32 *params = (u32 *)&wrq.u;
|
|
|
|
|
|
|
|
/* Equivalent to: iwpriv wlan0 initAP */
|
|
|
|
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) >= 0) {
|
|
|
|
strncpy(wrq.ifr_name, "wlan0", IFNAMSIZ);
|
|
|
|
wrq.u.data.length = 0; /* No Set arguments */
|
|
|
|
wrq.u.data.flags = 2; /* WE_INIT_AP sub-command */
|
|
|
|
ret = ioctl(s, (SIOCIWFIRSTPRIV + 6), &wrq);
|
|
|
|
if (ret < 0 ) {
|
2012-07-17 15:12:07 +02:00
|
|
|
ALOGE("ioctl failed: %s", strerror(errno));
|
2012-01-31 01:56:29 +01:00
|
|
|
status = eERR_START_SAP;
|
|
|
|
}
|
|
|
|
close(s);
|
|
|
|
sched_yield();
|
|
|
|
}
|
|
|
|
else {
|
2012-07-17 15:12:07 +02:00
|
|
|
ALOGE("Socket open failed: %s", strerror(errno));
|
2012-01-31 01:56:29 +01:00
|
|
|
status = eERR_START_SAP;
|
|
|
|
}
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
s32 qsap_send_exit_ap(void)
|
|
|
|
{
|
|
|
|
int s, ret;
|
|
|
|
struct iwreq wrq;
|
|
|
|
s32 status = eSUCCESS;
|
|
|
|
u32 *params = (u32 *)&wrq.u;
|
|
|
|
|
|
|
|
/* Equivalent to: iwpriv wlan0 exitAP */
|
|
|
|
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) >= 0) {
|
|
|
|
strncpy(wrq.ifr_name, "wlan0", IFNAMSIZ);
|
|
|
|
wrq.u.data.length = 0; /* No Set arguments */
|
|
|
|
wrq.u.data.flags = 3; /*WE_EXIT_AP sub-command */
|
|
|
|
|
|
|
|
ret = ioctl(s, (SIOCIWFIRSTPRIV + 6), &wrq);
|
|
|
|
if (ret < 0 ) {
|
2012-07-17 15:12:07 +02:00
|
|
|
ALOGE("ioctl failed: %s", strerror(errno));
|
2012-01-31 01:56:29 +01:00
|
|
|
status = eERR_STOP_SAP;
|
|
|
|
}
|
|
|
|
close(s);
|
|
|
|
sched_yield();
|
|
|
|
}
|
|
|
|
else {
|
2012-07-17 15:12:07 +02:00
|
|
|
ALOGE("Socket open failed: %s", strerror(errno));
|
2012-01-31 01:56:29 +01:00
|
|
|
status = eERR_STOP_SAP;
|
|
|
|
}
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2010-10-13 09:11:12 +02:00
|
|
|
s32 wifi_qsap_unload_driver()
|
|
|
|
{
|
|
|
|
s32 ret = eSUCCESS;
|
|
|
|
|
|
|
|
if(system(SDIO_POLLING_ON)) {
|
2012-07-17 15:12:07 +02:00
|
|
|
ALOGE("Could not turn on the polling...");
|
2010-10-13 09:11:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( check_driver_loaded(WIFI_DRIVER_MODULE_NAME " ") ) {
|
2011-03-12 19:21:45 +01:00
|
|
|
qsap_send_module_down_indication();
|
2010-10-13 09:11:12 +02:00
|
|
|
if ( rmmod(WIFI_DRIVER_MODULE_NAME) ) {
|
2012-07-17 15:12:07 +02:00
|
|
|
ALOGE("Unable to unload the libra_softap driver\n");
|
2010-10-13 09:11:12 +02:00
|
|
|
ret = eERR_UNLOAD_FAILED_SOFTAP;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sched_yield();
|
|
|
|
|
2011-07-15 10:47:15 +02:00
|
|
|
#ifdef WIFI_SDIO_IF_DRIVER_MODULE_NAME
|
2010-10-13 09:11:12 +02:00
|
|
|
if ( check_driver_loaded(WIFI_SDIO_IF_DRIVER_MODULE_NAME " ") ) {
|
|
|
|
if ( rmmod(WIFI_SDIO_IF_DRIVER_MODULE_NAME) ) {
|
2012-07-17 15:12:07 +02:00
|
|
|
ALOGE("Unable to unload the librasdioif driver\n");
|
2010-10-13 09:11:12 +02:00
|
|
|
ret = eERR_UNLOAD_FAILED_SDIO;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
}
|
2011-07-15 10:47:15 +02:00
|
|
|
#endif
|
|
|
|
|
2010-10-13 09:11:12 +02:00
|
|
|
end:
|
|
|
|
if(system(SDIO_POLLING_OFF)) {
|
2012-07-17 15:12:07 +02:00
|
|
|
ALOGE("Could not turn off the polling...");
|
2010-10-13 09:11:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 wifi_qsap_stop_bss(void)
|
|
|
|
{
|
|
|
|
#define QCIEEE80211_IOCTL_STOPBSS (SIOCIWFIRSTPRIV + 6)
|
|
|
|
s32 sock;
|
|
|
|
s32 ret = eERR_STOP_BSS;
|
|
|
|
s8 cmd[] = "stopbss";
|
|
|
|
s8 interface[128];
|
|
|
|
s8 *iface;
|
|
|
|
s32 len = 128;
|
|
|
|
struct iwreq wrq;
|
|
|
|
struct iw_priv_args *priv_ptr;
|
|
|
|
|
|
|
|
if(ENABLE != is_softap_enabled()) {
|
|
|
|
ret = eERR_BSS_NOT_STARTED;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-11-15 02:47:11 +01:00
|
|
|
if(NULL == (iface = qsap_get_config_value(CONFIG_FILE, &qsap_str[STR_INTERFACE], interface, (u32*)&len))) {
|
2012-07-17 15:12:07 +02:00
|
|
|
ALOGE("%s :interface error \n", __func__);
|
2010-10-13 09:11:12 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Issue the stopbss command to driver */
|
|
|
|
sock = socket(AF_INET, SOCK_DGRAM, 0);
|
|
|
|
|
|
|
|
if (sock < 0) {
|
2012-07-17 15:12:07 +02:00
|
|
|
ALOGE("Failed to open socket");
|
2010-10-13 09:11:12 +02:00
|
|
|
return eERR_STOP_BSS;
|
|
|
|
}
|
|
|
|
|
|
|
|
strncpy(wrq.ifr_name, iface, sizeof(wrq.ifr_name));
|
|
|
|
wrq.u.data.length = sizeof(cmd);
|
|
|
|
wrq.u.data.pointer = cmd;
|
|
|
|
wrq.u.data.flags = 0;
|
|
|
|
|
|
|
|
ret = ioctl(sock, QCIEEE80211_IOCTL_STOPBSS, &wrq);
|
|
|
|
|
|
|
|
/* Here IOCTL is always returning non Zero: temporary fix untill driver is fixed*/
|
|
|
|
ret = 0;
|
|
|
|
close(sock);
|
|
|
|
|
|
|
|
if (ret) {
|
2012-07-17 15:12:07 +02:00
|
|
|
ALOGE("IOCTL stopbss failed: %ld", ret);
|
2010-10-13 09:11:12 +02:00
|
|
|
ret = eERR_STOP_BSS;
|
|
|
|
} else {
|
2012-07-17 15:12:07 +02:00
|
|
|
ALOGD("STOP BSS ISSUED");
|
2010-10-13 09:11:12 +02:00
|
|
|
ret = eSUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
sched_yield();
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 is_softap_enabled(void)
|
|
|
|
{
|
2013-10-01 16:07:51 +02:00
|
|
|
s32 mode = 0;
|
|
|
|
int ret;
|
2012-12-26 09:38:38 +01:00
|
|
|
|
2013-10-01 16:07:51 +02:00
|
|
|
ret = qsap_get_mode(&mode);
|
|
|
|
if (eSUCCESS != ret) {
|
|
|
|
ALOGD("Failed to get the mode of operation\n");
|
2012-12-26 09:38:38 +01:00
|
|
|
return eERR_UNKNOWN;
|
|
|
|
}
|
2010-10-13 09:11:12 +02:00
|
|
|
|
2013-10-01 16:07:51 +02:00
|
|
|
if (mode == IW_MODE_MASTER) {
|
|
|
|
ALOGD("HOSTAPD Enabled\n");
|
|
|
|
return ENABLE;
|
2010-10-13 09:11:12 +02:00
|
|
|
}
|
|
|
|
|
2013-10-01 16:07:51 +02:00
|
|
|
ALOGD("HOSTAPD Disabled\n");
|
|
|
|
|
2010-10-13 09:11:12 +02:00
|
|
|
return DISABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 commit(void)
|
|
|
|
{
|
|
|
|
#ifndef SDK_TEST
|
|
|
|
s32 ret = eERR_COMMIT;
|
|
|
|
|
|
|
|
if ( is_softap_enabled() ) {
|
|
|
|
/** Stop BSS */
|
|
|
|
if(eSUCCESS != (ret = wifi_qsap_stop_bss())) {
|
2012-07-17 15:12:07 +02:00
|
|
|
ALOGE("%s: stop bss failed \n", __func__);
|
2010-10-13 09:11:12 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
sleep(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = wifi_qsap_start_softap();
|
|
|
|
|
|
|
|
if( eSUCCESS != ret )
|
|
|
|
wifi_qsap_unload_driver();
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
#else
|
|
|
|
return eSUCCESS;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 wifi_qsap_start_softap()
|
|
|
|
{
|
|
|
|
s32 retry = 4;
|
2010-11-15 02:47:11 +01:00
|
|
|
FILE * fp;
|
2010-10-13 09:11:12 +02:00
|
|
|
|
2012-07-17 15:12:07 +02:00
|
|
|
ALOGD("Starting Soft AP...\n");
|
2010-10-13 09:11:12 +02:00
|
|
|
|
2010-11-15 02:47:11 +01:00
|
|
|
/* Check if configuration files are present, if not create the default files */
|
|
|
|
check_for_configuration_files();
|
|
|
|
|
2010-10-13 09:11:12 +02:00
|
|
|
/* Delete control interface if it was left over because of previous crash */
|
|
|
|
if ( !is_softap_enabled() ) {
|
|
|
|
qsap_del_ctrl_iface();
|
|
|
|
}
|
|
|
|
|
2011-11-16 06:23:32 +01:00
|
|
|
/* Ensure correct path for ini file name */
|
|
|
|
qsap_set_ini_filename();
|
|
|
|
|
2010-11-15 02:47:11 +01:00
|
|
|
while(retry--) {
|
|
|
|
/* May be the configuration file is corrupted or not available, */
|
|
|
|
/* copy the default configuration file */
|
|
|
|
if ( retry == 1 )
|
|
|
|
wifi_qsap_reset_to_default(CONFIG_FILE, DEFAULT_CONFIG_FILE_PATH);
|
|
|
|
|
2010-10-13 09:11:12 +02:00
|
|
|
/** Stop hostapd */
|
|
|
|
if(0 != property_set("ctl.start", "hostapd")) {
|
2012-07-17 15:12:07 +02:00
|
|
|
ALOGE("failed \n");
|
2010-10-13 09:11:12 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
sleep(1);
|
|
|
|
|
|
|
|
if ( is_softap_enabled() ) {
|
2012-07-17 15:12:07 +02:00
|
|
|
ALOGD("success \n");
|
2010-10-13 09:11:12 +02:00
|
|
|
return eSUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-17 15:12:07 +02:00
|
|
|
ALOGE("Unable to start the SoftAP\n");
|
2010-10-13 09:11:12 +02:00
|
|
|
return eERR_START_SAP;
|
|
|
|
}
|
|
|
|
|
2012-01-31 01:56:29 +01:00
|
|
|
#ifdef QCOM_WLAN_CONCURRENCY
|
|
|
|
s32 wifi_qsap_start_softap_in_concurrency()
|
|
|
|
{
|
|
|
|
s32 status;
|
|
|
|
/*Send initAP IOCTL to Driver. Hostapd start is done by Netd.*/
|
|
|
|
status = qsap_send_init_ap();
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 wifi_qsap_stop_softap_in_concurrency()
|
|
|
|
{
|
|
|
|
s32 status;
|
|
|
|
/*Send exitAP IOCTL to Driver. Hostapd stop is done by Netd.*/
|
|
|
|
status = qsap_send_exit_ap();
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2010-10-13 09:11:12 +02:00
|
|
|
s32 wifi_qsap_stop_softap()
|
|
|
|
{
|
|
|
|
s32 ret = eSUCCESS;
|
|
|
|
|
|
|
|
if ( is_softap_enabled() ) {
|
2012-07-17 15:12:07 +02:00
|
|
|
ALOGD("Stopping BSS ..... ");
|
2010-10-13 09:11:12 +02:00
|
|
|
|
|
|
|
/** Stop the BSS */
|
|
|
|
if (eSUCCESS != (ret = wifi_qsap_stop_bss()) ) {
|
2012-07-17 15:12:07 +02:00
|
|
|
ALOGE("failed \n");
|
2010-10-13 09:11:12 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
sleep(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 wifi_qsap_reload_softap()
|
|
|
|
{
|
|
|
|
s32 ret = eERR_RELOAD_SAP;
|
|
|
|
|
|
|
|
/** SDK API to reload the firmware */
|
|
|
|
if (eSUCCESS != (ret = wifi_qsap_stop_softap())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (eSUCCESS != (ret = wifi_qsap_unload_driver())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
usleep(500000);
|
|
|
|
|
|
|
|
if (eSUCCESS != (ret = wifi_qsap_load_driver())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
sleep(1);
|
|
|
|
|
|
|
|
if (eSUCCESS != (ret = wifi_qsap_start_softap())) {
|
|
|
|
wifi_qsap_unload_driver();
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return eSUCCESS;
|
|
|
|
}
|