mirror of
https://gitee.com/openharmony/communication_wifi.git
synced 2025-02-17 07:21:44 +00:00
commit
4e73f6a177
@ -130,9 +130,15 @@ int CreateUnixServer(const char *path, int backlog)
|
||||
return -1;
|
||||
}
|
||||
int keepAlive = 1;
|
||||
setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (void *)&keepAlive, sizeof(keepAlive));
|
||||
if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (void *)&keepAlive, sizeof(keepAlive)) < 0) {
|
||||
LOGE("setsockopt failed!");
|
||||
return -1;
|
||||
}
|
||||
int reuseaddr = 1;
|
||||
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&reuseaddr, sizeof(reuseaddr));
|
||||
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&reuseaddr, sizeof(reuseaddr)) < 0) {
|
||||
LOGE("setsockopt failed!");
|
||||
return -1;
|
||||
}
|
||||
int ret = bind(sock, (struct sockaddr *)&sockAddr, sizeof(sockAddr));
|
||||
if (ret < 0) {
|
||||
LOGE("bind failed, ret: %{public}d, errno: %{public}d!", ret, errno);
|
||||
|
@ -49,8 +49,16 @@ static int OnAccept(RpcServer *server, unsigned int mask)
|
||||
if (fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
SetNonBlock(fd, 1);
|
||||
fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||||
if (SetNonBlock(fd, 1) != 0) {
|
||||
LOGE("OnAccept SetNonBlock failed!");
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) {
|
||||
LOGE("OnAccept fcntl failed!");
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
Context *context = CreateContext(CONTEXT_BUFFER_MIN_SIZE);
|
||||
if (context != NULL) {
|
||||
context->fd = fd;
|
||||
|
@ -32,7 +32,11 @@ int WifiControllerMachine::mWifiStartFailCount{0};
|
||||
int WifiControllerMachine::mSoftapStartFailCount{0};
|
||||
|
||||
WifiControllerMachine::WifiControllerMachine()
|
||||
: StateMachine("WifiControllerMachine"), pEnableState(nullptr), pDisableState(nullptr), pDefaultState(nullptr)
|
||||
: StateMachine("WifiControllerMachine"),
|
||||
mApidStopWifi(0),
|
||||
pEnableState(nullptr),
|
||||
pDisableState(nullptr),
|
||||
pDefaultState(nullptr)
|
||||
{}
|
||||
|
||||
WifiControllerMachine::~WifiControllerMachine()
|
||||
|
@ -48,6 +48,7 @@ ScanStateMachine::ScanStateMachine(int instId)
|
||||
runningHwPnoFlag(false),
|
||||
remainWaitResultTimer(false),
|
||||
runningSwPnoFlag(false),
|
||||
lastScanStartTime(0),
|
||||
m_instId(instId)
|
||||
{}
|
||||
|
||||
|
@ -82,6 +82,7 @@ StaStateMachine::StaStateMachine(int instId)
|
||||
enableSignalPoll(true),
|
||||
isRoam(false),
|
||||
netNoWorkNum(0),
|
||||
portalFlag(false),
|
||||
networkStatusHistoryInserted(false),
|
||||
pDhcpResultNotify(nullptr),
|
||||
pRootState(nullptr),
|
||||
|
@ -60,9 +60,8 @@ struct QUESTION {
|
||||
unsigned short qclass;
|
||||
};
|
||||
|
||||
DnsChecker::DnsChecker() : socketCreated(false), isRunning(true)
|
||||
{
|
||||
}
|
||||
DnsChecker::DnsChecker() : dnsSocket(0), socketCreated(false), isRunning(true)
|
||||
{}
|
||||
|
||||
DnsChecker::~DnsChecker()
|
||||
{
|
||||
@ -135,7 +134,7 @@ void DnsChecker::StopDnsCheck()
|
||||
bool DnsChecker::DoDnsCheck(std::string url, int timeoutMillis)
|
||||
{
|
||||
LOGI("DoDnsCheck Enter.");
|
||||
int len1 = url.find("/generate_204");
|
||||
int len1 = (int)url.find("/generate_204");
|
||||
int len = len1 - strlen("http://");
|
||||
std::string host = url.substr(strlen("http://"), len);
|
||||
host = host + ".";
|
||||
|
@ -51,8 +51,12 @@ pid_t GetPID(const char *pidFile)
|
||||
return -1;
|
||||
}
|
||||
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
|
||||
off_t offset = lseek(fd, 0, SEEK_SET);
|
||||
if (offset < 0) {
|
||||
LOGE("GetPID lseek fail!");
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
char buf[PID_MAX_LENGTH] = {0};
|
||||
ssize_t bytes;
|
||||
if ((bytes = read(fd, buf, sb.st_size)) < 0) {
|
||||
|
@ -45,7 +45,11 @@ static int ReadConfigModuleName(char *name, int size)
|
||||
}
|
||||
int flag = 0;
|
||||
do {
|
||||
fseek(fp, 0, SEEK_END);
|
||||
if (fseek(fp, 0, SEEK_END) != 0) {
|
||||
LOGE("ReadConfigModuleName fseek failed!");
|
||||
fclose(fp);
|
||||
return HAL_FAILURE;
|
||||
}
|
||||
int len = ftell(fp);
|
||||
if ((len >= size) || (len == -1)) {
|
||||
LOGE("config file size too big, config file may not correct!");
|
||||
|
@ -31,7 +31,9 @@ int RpcStartSoftAp(RpcServer *server, Context *context)
|
||||
return HAL_FAILURE;
|
||||
}
|
||||
char ifaceName[IFACENAME_LEN];
|
||||
ReadStr(context, ifaceName, sizeof(ifaceName));
|
||||
if (ReadStr(context, ifaceName, sizeof(ifaceName)) != 0) {
|
||||
return HAL_FAILURE;
|
||||
}
|
||||
WifiErrorNo err = StartSoftAp(id, ifaceName);
|
||||
WriteBegin(context, 0);
|
||||
WriteInt(context, err);
|
||||
|
@ -135,7 +135,10 @@ int RpcGetIface(RpcServer *server, Context *context)
|
||||
if (pstr == NULL) {
|
||||
return HAL_FAILURE;
|
||||
}
|
||||
ReadStr(context, pstr, len);
|
||||
if (ReadStr(context, pstr, len) != 0) {
|
||||
free(pstr);
|
||||
return HAL_FAILURE;
|
||||
}
|
||||
}
|
||||
WifiErrorNo err = GetIface((pstr == NULL) ? ifname : pstr, &wifiIface);
|
||||
WriteBegin(context, 0);
|
||||
@ -196,7 +199,10 @@ int RpcRemoveIface(RpcServer *server, Context *context)
|
||||
if (pstr == NULL) {
|
||||
return HAL_FAILURE;
|
||||
}
|
||||
ReadStr(context, pstr, len);
|
||||
if (ReadStr(context, pstr, len) != 0) {
|
||||
free(pstr);
|
||||
return HAL_FAILURE;
|
||||
}
|
||||
}
|
||||
WifiErrorNo err = RemoveIface((pstr == NULL) ? ifname : pstr);
|
||||
WriteBegin(context, 0);
|
||||
|
@ -646,7 +646,10 @@ int RpcP2pReqServiceDiscovery(RpcServer *server, Context *context)
|
||||
if (pDiscoverInfo == NULL) {
|
||||
return HAL_FAILURE;
|
||||
}
|
||||
ReadStr(context, pDiscoverInfo, len + 1);
|
||||
if (ReadStr(context, pDiscoverInfo, len + 1) != 0) {
|
||||
free(pDiscoverInfo);
|
||||
return HAL_FAILURE;
|
||||
}
|
||||
}
|
||||
int retSize = 0;
|
||||
if (ReadInt(context, &retSize) < 0 || retSize <= 0) {
|
||||
@ -728,7 +731,10 @@ int RpcP2pRespServerDiscovery(RpcServer *server, Context *context)
|
||||
if (info.tlvs == NULL) {
|
||||
return HAL_FAILURE;
|
||||
}
|
||||
ReadStr(context, info.tlvs, tlvsLen + 1);
|
||||
if (ReadStr(context, info.tlvs, tlvsLen + 1) != 0) {
|
||||
free(info.tlvs);
|
||||
return HAL_FAILURE;
|
||||
}
|
||||
WifiErrorNo err = P2pRespServerDiscovery(&info);
|
||||
WriteBegin(context, 0);
|
||||
WriteInt(context, err);
|
||||
|
@ -480,7 +480,10 @@ int RpcRunCmd(RpcServer *server, Context *context)
|
||||
if (pIfName == NULL) {
|
||||
return HAL_FAILURE;
|
||||
}
|
||||
ReadStr(context, pIfName, len);
|
||||
if (ReadStr(context, pIfName, len) != 0) {
|
||||
free(pIfName);
|
||||
return HAL_FAILURE;
|
||||
}
|
||||
}
|
||||
int cmdid = 0;
|
||||
int bufsize = 0;
|
||||
@ -746,7 +749,10 @@ static char **ReadRoamBlockList(Context *context, int size)
|
||||
if (list[i] == NULL) {
|
||||
break;
|
||||
}
|
||||
ReadStr(context, list[i], len);
|
||||
if (ReadStr(context, list[i], len) != 0) {
|
||||
free(list[i]);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (i < size) {
|
||||
for (int j = 0; j <= i; ++j) {
|
||||
|
@ -193,7 +193,11 @@ WifiErrorNo P2pStart(void)
|
||||
|
||||
if (AddP2pIface() != WIFI_HAL_SUCCESS || P2pConnectSupplicant() != WIFI_HAL_SUCCESS) {
|
||||
LOGE("SupplicantHal connect p2p_wpa_supplicant failed!");
|
||||
StopP2pWpaAndWpaHal();
|
||||
WifiErrorNo ret = StopP2pWpaAndWpaHal();
|
||||
if (ret == WIFI_HAL_FAILED) {
|
||||
LOGE("StopP2pWpaAndWpaHal failed!");
|
||||
return WIFI_HAL_FAILED;
|
||||
}
|
||||
P2pHalCbConnectSupplicantFailed();
|
||||
return WIFI_HAL_CONN_SUPPLICANT_FAILED;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user