From d0ea69c72121281843d9dcf2243c4a437b9ace1b Mon Sep 17 00:00:00 2001 From: Deepthi Gowri Date: Wed, 26 Dec 2012 14:08:38 +0530 Subject: [PATCH] wlan: SAP changes. 1. Fix Compilation error. 3. Changes to make qsap compatible w.r.t android framework. 4. Changes to check if SAP is enabled or not. Change-Id: I8a21585bc1af92f5fbc885d981227349bb56b0f9 --- softap/sdk/qsap.c | 30 ++++++++++++++++++++---------- softap/sdk/qsap_api.c | 40 ++++++++++++++++++++-------------------- 2 files changed, 40 insertions(+), 30 deletions(-) diff --git a/softap/sdk/qsap.c b/softap/sdk/qsap.c index 466db64..676b1a8 100755 --- a/softap/sdk/qsap.c +++ b/softap/sdk/qsap.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Code Aurora Forum. All rights reserved. + * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -10,7 +10,7 @@ * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. - * * Neither the name of Code Aurora Forum, Inc. nor the names of its + * * Neither the name of The Linux Foundation, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. @@ -34,10 +34,10 @@ #include #include +#include #include #include #include -#include #include #include #include @@ -252,7 +252,6 @@ end: return ret; } - void qsap_send_module_down_indication(void) { int s, ret; @@ -435,15 +434,26 @@ s32 wifi_qsap_stop_bss(void) s32 is_softap_enabled(void) { - s8 stat[32] = {0}; + FILE *fp; + char buf[1024]; - if ( property_get("wifi.hostapd", stat, NULL) && - (strcmp(stat, "1") == 0)) { - ALOGD("HOSTAPD enabled \n"); - return ENABLE; + fp = popen("ps", "r"); + if (fp == NULL) { + ALOGE("Failed to open file"); + return eERR_UNKNOWN; } - ALOGD("HOSTAPD disabled \n"); + while (fgets(buf, sizeof(buf)-1, fp) != NULL) { + if(NULL !=(strstr(buf,"hostapd"))) + { + pclose(fp); + ALOGD("HOSTAPD enabled\n"); + return ENABLE; + } + } + + ALOGD("HOSTAPD disabled\n"); + pclose(fp); return DISABLE; } diff --git a/softap/sdk/qsap_api.c b/softap/sdk/qsap_api.c index 8e4b9f2..4ca5db7 100755 --- a/softap/sdk/qsap_api.c +++ b/softap/sdk/qsap_api.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Code Aurora Forum. All rights reserved. + * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -10,7 +10,7 @@ * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. - * * Neither the name of Code Aurora Forum, Inc. nor the names of its + * * Neither the name of The Linux Foundation, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. @@ -2997,12 +2997,12 @@ void qsap_hostd_exec_cmd(s8 *pcmd, s8 *presp, u32 *plen) #define CMD_BUF_LEN 255 /** Command input - argv[4] = SSID, - argv[5] = SEC, - argv[6] = 12345, - argv[7] = CHANNEL - argv[8] = PREAMBLE, - argv[9] = MAX_SCB, + argv[3] = SSID, + argv[4] = SEC, + argv[5] = 12345, + argv[6] = CHANNEL + argv[7] = PREAMBLE, + argv[8] = MAX_SCB, */ int qsapsetSoftap(int argc, char *argv[]) { @@ -3019,8 +3019,8 @@ int qsapsetSoftap(int argc, char *argv[]) } /** set SSID */ - if(argc > 4) { - snprintf(cmdbuf, CMD_BUF_LEN, "set ssid=%s",argv[4]); + if(argc > 3) { + snprintf(cmdbuf, CMD_BUF_LEN, "set ssid=%s",argv[3]); } else { snprintf(cmdbuf, CMD_BUF_LEN, "set ssid=%s_%d", DEFAULT_SSID, rand()); @@ -3034,19 +3034,19 @@ int qsapsetSoftap(int argc, char *argv[]) /** Security */ rlen = RECV_BUF_LEN; - if(argc > 5) { + if(argc > 4) { /**TODO : need to identify the SEC strings for "wep", "wpa", "wpa2" */ - if(!strcmp(argv[5], "open")) + if(!strcmp(argv[4], "open")) sec = SEC_MODE_NONE; - else if(!strcmp(argv[5], "wep")) + else if(!strcmp(argv[4], "wep")) sec = SEC_MODE_WEP; - else if(!strcmp(argv[5], "wpa-psk")) + else if(!strcmp(argv[4], "wpa-psk")) sec = SEC_MODE_WPA_PSK; - else if(!strcmp(argv[5], "wpa2-psk")) + else if(!strcmp(argv[4], "wpa2-psk")) sec = SEC_MODE_WPA2_PSK; snprintf(cmdbuf, CMD_BUF_LEN, "set security_mode=%d",sec); @@ -3065,10 +3065,10 @@ int qsapsetSoftap(int argc, char *argv[]) /** Key -- passphrase */ rlen = RECV_BUF_LEN; if ( (sec == SEC_MODE_WPA_PSK) || (sec == SEC_MODE_WPA2_PSK) ) { - if(argc > 6) { + if(argc > 5) { /* If the input passphrase is more than 63 characters, consider first 63 characters only*/ - if ( strlen(argv[6]) > 63 ) argv[6][63] = '\0'; - snprintf(cmdbuf, CMD_BUF_LEN, "set wpa_passphrase=%s",argv[6]); + if ( strlen(argv[5]) > 63 ) argv[5][63] = '\0'; + snprintf(cmdbuf, CMD_BUF_LEN, "set wpa_passphrase=%s",argv[5]); } else { snprintf(cmdbuf, CMD_BUF_LEN, "set wpa_passphrase=%s", DEFAULT_PASSPHRASE); @@ -3083,8 +3083,8 @@ int qsapsetSoftap(int argc, char *argv[]) /** channel */ rlen = RECV_BUF_LEN; - if(argc > 7) { - snprintf(cmdbuf, CMD_BUF_LEN, "set channel=%d", atoi(argv[7])); + if(argc > 6) { + snprintf(cmdbuf, CMD_BUF_LEN, "set channel=%d", atoi(argv[6])); (void) qsap_hostd_exec_cmd(cmdbuf, respbuf, &rlen); if(strncmp("success", respbuf, rlen) != 0) {