summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSubhani Shaik <subhanis@codeaurora.org>2014-07-18 18:50:37 -0700
committerLinux Build Service Account <lnxbuild@localhost>2014-11-04 08:44:57 -0700
commitc9e584f83bc95880f9fcce4711122d2f8c60d1bc (patch)
treee8ee1bcd5ee74691e931a2cd7f3c7fe81ce3a324
parent9f55c074736f657fafa084511288e2eb6ced10f0 (diff)
downloadandroid_system_netd-c9e584f83bc95880f9fcce4711122d2f8c60d1bc.tar.gz
android_system_netd-c9e584f83bc95880f9fcce4711122d2f8c60d1bc.tar.bz2
android_system_netd-c9e584f83bc95880f9fcce4711122d2f8c60d1bc.zip
wlan: Add softap support through ndc commands.
Changes required to support the softap commands through ndc cli. This new support as part of the 64bit enablement and ndc is used for cli automation in softap testcases. Change-Id: I460a3785c3b4a44656281c7243ebdf921fe20f91 CRs-Fixed: 710050
-rwxr-xr-xserver/Android.mk7
-rw-r--r--server/CommandListener.cpp8
-rw-r--r--server/CommandListener.h9
-rw-r--r--server/QsoftapCmd.cpp167
4 files changed, 191 insertions, 0 deletions
diff --git a/server/Android.mk b/server/Android.mk
index f3011a4e..cb94bc6c 100755
--- a/server/Android.mk
+++ b/server/Android.mk
@@ -70,6 +70,13 @@ LOCAL_SRC_FILES := \
QcRouteController.cpp \
+ifeq ($(BOARD_HAS_QCOM_WLAN), true)
+ LOCAL_SRC_FILES += QsoftapCmd.cpp
+ LOCAL_CFLAGS += -DQSAP_WLAN
+ LOCAL_SHARED_LIBRARIES += libqsap_sdk
+ LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/sdk/softap/include
+endif
+
include $(BUILD_EXECUTABLE)
include $(CLEAR_VARS)
diff --git a/server/CommandListener.cpp b/server/CommandListener.cpp
index 6b17f5e9..b57ec756 100644
--- a/server/CommandListener.cpp
+++ b/server/CommandListener.cpp
@@ -50,6 +50,10 @@
#include "UidRanges.h"
#include "QcRouteController.h"
+#ifdef QSAP_WLAN
+#include "qsap_api.h"
+#endif
+
#include <string>
#include <vector>
@@ -222,7 +226,11 @@ CommandListener::CommandListener() :
registerCmd(new NatCmd());
registerCmd(new ListTtysCmd());
registerCmd(new PppdCmd());
+#ifdef QSAP_WLAN
+ registerCmd(new QsoftapCmd());
+#else
registerCmd(new SoftapCmd());
+#endif
registerCmd(new BandwidthControlCmd());
registerCmd(new IdletimerControlCmd());
registerCmd(new ResolverCmd());
diff --git a/server/CommandListener.h b/server/CommandListener.h
index 7b60163d..7819db60 100644
--- a/server/CommandListener.h
+++ b/server/CommandListener.h
@@ -64,6 +64,15 @@ private:
int runCommand(SocketClient *c, int argc, char ** argv);
};
+#ifdef QSAP_WLAN
+ class QsoftapCmd : public SoftapCmd {
+ public:
+ QsoftapCmd();
+ virtual ~QsoftapCmd() {}
+ int runCommand(SocketClient *c, int argc, char ** argv);
+ };
+#endif
+
class InterfaceCmd : public NetdCommand {
public:
InterfaceCmd();
diff --git a/server/QsoftapCmd.cpp b/server/QsoftapCmd.cpp
new file mode 100644
index 00000000..8f578560
--- /dev/null
+++ b/server/QsoftapCmd.cpp
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 2013, The Linux Foundation. All rights reserved.
+ * Not a Contribution.
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <stdlib.h>
+#include <string.h>
+
+#define LOG_TAG "QsoftapCmd"
+#include <cutils/log.h>
+
+#include "CommandListener.h"
+#include "ResponseCode.h"
+
+#include "qsap_api.h"
+
+#include <cutils/properties.h>
+static char ath6kl_supported[PROPERTY_VALUE_MAX];
+
+CommandListener::QsoftapCmd::QsoftapCmd() :
+ SoftapCmd::SoftapCmd() {
+}
+
+int CommandListener::QsoftapCmd::runCommand(SocketClient *cli,
+ int argc, char **argv) {
+ int rc = 0;
+
+ if (argc < 2) {
+ cli->sendMsg(ResponseCode::CommandSyntaxError, "Softap Missing argument", false);
+ return 0;
+ }
+
+ if (!strcmp(argv[1], "qccmd")) {
+#define MAX_CMD_SIZE 256
+ char qcCmdBuf[MAX_CMD_SIZE], *pCmdBuf;
+ int len = MAX_CMD_SIZE, i = 2, ret;
+
+ if ( argc < 4 ) {
+ cli->sendMsg(ResponseCode::OperationFailed, "failure: invalid arguments", true);
+ return 0;
+ }
+
+ argc -= 2;
+ pCmdBuf = qcCmdBuf;
+#ifdef QSAP_STA_CONCURRENCY
+ //SAP STA Concurrency Customization
+ // Cmd Format Example "set sap_sta_concurrency=6" where 6 is STA Mode channel
+ if (!strncmp(argv[3], "sap_sta_concurrency=",20) && !strcmp(argv[2], "set")) {
+ //Extract STA Mode channel number from cmd
+ int sta_channel = atoi(&argv[3][20]);
+ int sap_channel;
+ //Get SAP Mode channel from SoftAP SDK
+ ret = snprintf(pCmdBuf, len, " get channel");
+ len = MAX_CMD_SIZE;
+ //Send cmd to SoftAP SDK
+ qsap_hostd_exec_cmd(qcCmdBuf, qcCmdBuf, (u32*)&len);
+ cli->sendMsg(qcCmdBuf);
+
+ sap_channel = atoi(&qcCmdBuf[16]);
+ ALOGD("SAP STA Concurrency GET CHANNEL Rsp %s STA Channel %d SAP Channel %d",qcCmdBuf,sta_channel,sap_channel);
+
+ //StopSoftAP and exitAP if channels are different
+ if(sta_channel != sap_channel) {
+ rc = sSoftapCtrl->stopSoftap();
+ if (!rc) {
+ cli->sendMsg(ResponseCode::CommandOkay, "Softap operation succeeded", false);
+ } else {
+ cli->sendMsg(ResponseCode::OperationFailed, "Softap operation failed", true);
+ }
+ //Send exitAP cmd to SoftAP SDK
+ len = MAX_CMD_SIZE;
+ ret = snprintf(pCmdBuf, len, " set reset_ap=5");
+ qsap_hostd_exec_cmd(qcCmdBuf, qcCmdBuf, (u32*)&len);
+ cli->sendMsg(qcCmdBuf);
+ ALOGD("SAP STA Concurrency result for exitAP %s",qcCmdBuf);
+ }
+
+ return 0;
+ }
+ // Cmd Format Example "set sta_assoc_complete_ind"
+ else if (!strcmp(argv[3], "sta_assoc_complete_ind") && !strcmp(argv[2], "set")) {
+ //StartSoftAP and initAP if SoftAP is down
+ if(!sSoftapCtrl->isSoftapStarted()) {
+ //Send initAP cmd to SoftAP SDK
+ len = MAX_CMD_SIZE;
+ ret = snprintf(pCmdBuf, len, " set reset_ap=4");
+ //Send cmd to SoftAP SDK
+ qsap_hostd_exec_cmd(qcCmdBuf, qcCmdBuf, (u32*)&len);
+ cli->sendMsg(qcCmdBuf);
+ ALOGD("SAP STA Concurrency result for initAP %s",qcCmdBuf);
+
+ rc = sSoftapCtrl->startSoftap();
+ if (!rc) {
+ cli->sendMsg(ResponseCode::CommandOkay, "Softap operation succeeded", false);
+ } else {
+ cli->sendMsg(ResponseCode::OperationFailed, "Softap operation failed", true);
+ }
+ }
+ return 0;
+ } //SAP STA Concurrency Customization Ends
+ else
+#endif //QSAP_STA_CONCURRENCY
+ {
+
+ while (argc--) {
+ ret = snprintf(pCmdBuf, len, " %s", argv[i]);
+ if ((ret < 0) || (ret >= len)) {
+ /* Error case */
+ /* TODO: Command too long send the error message */
+ *pCmdBuf = '\0';
+ break;
+ }
+ pCmdBuf += ret;
+ len -= ret;
+ i++;
+ }
+
+ len = MAX_CMD_SIZE;
+ qsap_hostd_exec_cmd(qcCmdBuf, qcCmdBuf, (u32*)&len);
+ cli->sendMsg(ResponseCode::CommandOkay, qcCmdBuf, false);
+ return 0;
+ }
+ } else if (!strcmp(argv[1], "set")) {
+ /* When the WLAN is AR6004, use the Android native
+ SoftapController command. */
+ property_get("wlan.driver.ath", ath6kl_supported, 0);
+ if (*ath6kl_supported == '2') {
+ return SoftapCmd::runCommand(cli, argc, argv);
+ }
+
+ /* override processing of the "softap set" command. The
+ default class will install a hostapd.conf which contains
+ just the settings supported by the Android framework, and
+ will do this every time Soft AP is enabled. This will
+ destroy the hostapd.conf used to store the settings used by
+ the QSoftAP SDK */
+ ALOGD("Got softap set command we are overriding");
+ rc = qsapsetSoftap(argc, argv);
+ } else {
+ /* all other commands will be handed off to the native handler */
+ ALOGD("Got softap %s command we are passing on", argv[1]);
+ return SoftapCmd::runCommand(cli, argc, argv);
+ }
+
+ if (!rc) {
+ cli->sendMsg(ResponseCode::CommandOkay, "Softap operation succeeded", false);
+ } else {
+ cli->sendMsg(ResponseCode::OperationFailed, "Softap operation failed", true);
+ }
+
+ return 0;
+}