Merge "Fix: SIGPIPE issue while querying softap enabled status"

This commit is contained in:
Linux Build Service Account
2013-10-18 00:48:18 -07:00
committed by Gerrit - the friendly Code Review server
2 changed files with 61 additions and 14 deletions

View File

@@ -434,26 +434,22 @@ s32 wifi_qsap_stop_bss(void)
s32 is_softap_enabled(void)
{
FILE *fp;
char buf[1024];
s32 mode = 0;
int ret;
fp = popen("ps", "r");
if (fp == NULL) {
ALOGE("Failed to open file");
ret = qsap_get_mode(&mode);
if (eSUCCESS != ret) {
ALOGD("Failed to get the mode of operation\n");
return eERR_UNKNOWN;
}
while (fgets(buf, sizeof(buf)-1, fp) != NULL) {
if(NULL !=(strstr(buf,"hostapd")))
{
pclose(fp);
ALOGD("HOSTAPD enabled\n");
return ENABLE;
}
if (mode == IW_MODE_MASTER) {
ALOGD("HOSTAPD Enabled\n");
return ENABLE;
}
ALOGD("HOSTAPD disabled\n");
pclose(fp);
ALOGD("HOSTAPD Disabled\n");
return DISABLE;
}

View File

@@ -1256,6 +1256,57 @@ error:
return eERR_GET_AUTO_CHAN;
}
/**
* Get the mode of operation.
*/
int qsap_get_mode(s32 *pmode)
{
int sock;
struct iwreq wrq;
s8 interface[MAX_CONF_LINE_LEN];
u32 len = MAX_CONF_LINE_LEN;
s8 *pif;
int ret;
sap_auto_channel_info sap_autochan_info;
s32 *pchan;
*pmode = -1;
if(NULL == (pif = qsap_get_config_value(pconffile,
&qsap_str[STR_INTERFACE], interface, &len))) {
ALOGD("%s :interface error \n", __func__);
goto error;
}
interface[len] = '\0';
sock = socket(AF_INET, SOCK_DGRAM, 0);
if(sock < 0) {
ALOGD("%s :socket error \n", __func__);
goto error;
}
memset(&wrq, 0, sizeof(wrq));
strlcpy(wrq.ifr_name, pif, sizeof(wrq.ifr_name));
ret = ioctl(sock, SIOCGIWMODE, &wrq);
if(ret < 0) {
ALOGE("%s: ioctl failure \n",__func__);
close(sock);
goto error;
}
*pmode = *(s32 *)(&wrq.u.mode);
ALOGE("%s: ioctl Get Mode = %d \n",__func__, *pmode);
close(sock);
return eSUCCESS;
error:
*pmode = -1;
ALOGE("%s: (Failure) ioctl Get Mode = %d \n",__func__, *pmode);
return eERR_UNKNOWN;
}
/**
* Set the channel Range for soft AP.
*/