[FIXBUG]API-174 202 203 207 211
Change-Id: I9c7308b920c3bfa32962fe67d11fd1949a61c40b
diff --git a/src/lynq/lib/liblynq-wifi6/libwifi6.c b/src/lynq/lib/liblynq-wifi6/libwifi6.c
index 746c2ef..1a79ce5 100755
--- a/src/lynq/lib/liblynq-wifi6/libwifi6.c
+++ b/src/lynq/lib/liblynq-wifi6/libwifi6.c
@@ -163,9 +163,11 @@
if(idx<0||idx>9){
return -1;
}
- if(((strlen(ap_ssid))<8) || ((strlen(ap_ssid))>32)){
+ CHECK_NULL_RETURN_VALUE(ap_ssid,"ap_ssid is null",-1);
+ if(((strlen(ap_ssid))>32)){
PRINT_AND_RETURN_VALUE("ssid is illgal",-1);
}
+
sprintf(lynq_tmp_cmd,"%s%d%s","IFNAME=wlan0 set_network ",idx," ssid ");
sprintf(lynq_wifi_ssid_cmd,"%s%s%s%s%s",lynq_tmp_cmd,"\"",ap_ssid,"\"","\n");
@@ -232,6 +234,7 @@
if((lynq_wifi_frequency != 2437) && (lynq_wifi_frequency != 5180)){
PRINT_AND_RETURN_VALUE("set frequency not in range",-1);
}
+
sprintf(lynq_wifi_frequency_cmd,"IFNAME=wlan0 set_net %d frequency %d\n", idx, lynq_wifi_frequency);
sprintf(lynq_cmd_mode, "IFNAME=wlan0 set_net %d mode 2\n", idx);
sprintf(lynq_cmd_slect, "IFNAME=wlan0 select_net %d\n", idx);
@@ -337,46 +340,30 @@
return 0;
}
-/*
+
int lynq_wifi_ap_channel_set( lynq_wifi_index_e idx,int channel)
{
FILE *fp;
- FILE *fg;
- char lynq_cmd_ret[MAX_CMD]={0};
- char lynq_tmp_cmd[MAX_RET]={0};
- char lynq_change_cmd[MAX_CMD]="/data/wl chanspec ";
- char chose_idx_cmd[MAX_CMD]="";
- sprintf(chose_idx_cmd,"%s%d%s","IFNAME=wlan0 slecet_net ",idx,"\n");
- if((fg=popen(chose_idx_cmd,"r"))==NULL){
- perror("popen error!");
+ int ret;
+ if(idx<0||idx>9){
return -1;
}
- if((fgets(lynq_cmd_ret,sizeof(lynq_cmd_ret),fp))!=NULL){
- if((strcmp(lynq_cmd_ret,g_lynq_wifi_ok))!=0){
- CLOSE_FP_RETURN_VALUE(fp);
- return -1;
- }
- }
- if((pclose(fg))==-1){
- perror("close file faild");
- return -1;
- }
- sprintf(lynq_tmp_cmd,"%s%d",lynq_change_cmd[1],channel);
+ char lynq_cmd_ret[MAX_RET]="";
+ char lynq_cmd_channel[MAX_CMD]="";
+ sprintf(lynq_cmd_channel,"/data/wl chanspec %d\n",channel);
system("/data/wl down");
- if((fp=popen(lynq_tmp_cmd,"w"))==NULL){
- perror("popen error!");
- return -1;
- }
- int ret=pclose(fp);
- if(ret==-1){
- perror("close file faild");
- return -1;
- }
- system("/data/wl up");
+ fp=popen(lynq_cmd_channel,"r");
+ if((fgets(lynq_cmd_ret,sizeof(lynq_cmd_ret),fp))!=NULL){
+ if(strncmp(lynq_cmd_ret,g_lynq_wifi_ok,2) != 0){
+ PRINT_AND_RETURN_VALUE("set channel error",-1);
+ }
+ system("/data/wl up");
+ }
+
return 0;
}
-*/
+
int lynq_wifi_ap_channel_get( lynq_wifi_index_e idx,int* channel)
{
CHECK_NULL_RETURN_VALUE(channel,"channel is null",-1);
@@ -413,6 +400,9 @@
if(idx<0||idx>9){
return -1;
}
+ if((auth !=0) && (auth !=1)){
+ PRINT_AND_RETURN_VALUE("set auth is null",-1);
+ }
switch(auth){
case LYNQ_WIFI_AUTH_OPEN:
{
@@ -477,7 +467,7 @@
int lynq_wifi_ap_auth_get(lynq_wifi_index_e idx, lynq_wifi_ap_auth_s *auth)
{
- CHECK_NULL_RETURN_VALUE(auth,"chanauthnel is null",-1);
+ CHECK_NULL_RETURN_VALUE(auth,"the auth is null",-1);
char *lynq_wifi_ssid_cmd[]={"wpa_cli -iwlan0 -p/var/run/wpa_supplicant status"};
char lynq_cmd_ret[MAX_RET]={0};
char get_str_auth[20]={0};
@@ -517,37 +507,7 @@
return 0;
}
-/*
-int lynq_wifi_ap_max_sta_set(lynq_wifi_index_e idx,int max_sta_num)
-{
- FILE * fp;
- char lynq_cmd_ret[MAX_RET]={0};
- char lynq_tmp_cmd[MAX_CMD]={0};
- sprintf(lynq_tmp_cmd,"/data/wl maxassoc %d%s",max_sta_num,"\n");
- if(idx<0||idx>9){
- return -1;
- }
- if((fp=popen(lynq_tmp_cmd,"r"))==NULL)
- {
- perror("popen error!");
- return -1;
- }
- if((fread(lynq_cmd_ret,sizeof(lynq_cmd_ret),1,fp))<0)
- {
- perror("fread fail!");
- return -1;
- }
- int ret=pclose(fp);
- if(ret==-1)
- {
- perror("close file faild");
- return -1;
- }
-
- return 0;
-}
-*/
int lynq_wifi_ap_max_sta_get(lynq_wifi_index_e idx,int* max_sta_num)
{
CHECK_NULL_RETURN_VALUE(max_sta_num,"max_sta_num is null",-1);
@@ -724,8 +684,9 @@
FILE *fp;
int ret;
int pass_len;
+ CHECK_NULL_RETURN_VALUE(password,"password is null",-1);
pass_len=strlen(password);
- if(((pass_len+1) > MAX_CMD) || pass_len<8){
+ if(((pass_len+1) > MAX_CMD) || (pass_len<8)){
PRINT_AND_RETURN_VALUE("password is illgal",-1);
}else if((lynq_get_wifi_space(password))== 1){
PRINT_AND_RETURN_VALUE("password is illgal",-1);
@@ -760,8 +721,9 @@
{
FILE *fp;
int pass_len;
+ CHECK_NULL_RETURN_VALUE(password,"password is null",-1);
pass_len=strlen(password);
- if(((pass_len+1) > MAX_CMD) || pass_len<8){
+ if(((pass_len+1) > MAX_CMD) && (pass_len<8)){
PRINT_AND_RETURN_VALUE("password is illgal",-1);
}else if((lynq_get_wifi_space(password))== 1){
PRINT_AND_RETURN_VALUE("password is illgal",-1);
@@ -804,9 +766,11 @@
if(idx<0||idx>9){
return -1;
}
+ CHECK_NULL_RETURN_VALUE(sta_ssid,"sta_ssid is null",-1);
if(((strlen(sta_ssid))>32)){
PRINT_AND_RETURN_VALUE("ssid is illgal",-1);
}
+
if((fp=popen("/usr/bin/wpa_cli -iwpa_wlan0_cmd -p/var/run/","w"))==NULL){
perror("popen error!");
return -1;
@@ -865,6 +829,10 @@
if(idx<0||idx>9){
return -1;
}
+ PRINT_AND_RETURN_VALUE("set auth is error",auth);
+ if((auth !=0) && (auth !=1)){
+ PRINT_AND_RETURN_VALUE("set auth is error",-1);
+ }
switch(auth){
case LYNQ_WIFI_STA_AUTH_OPEN:
{
@@ -928,7 +896,7 @@
int lynq_wifi_sta_auth_get(lynq_wifi_index_e idx, lynq_wifi_sta_auth_s* auth)
{
- CHECK_NULL_RETURN_VALUE(auth,"chanauthnel is null",-1);
+ CHECK_NULL_RETURN_VALUE(auth,"the auth is null",-1);
char *lynq_wifi_ssid_cmd[]={"wpa_cli -iwlan0 -p/var/run/wpa_supplicant status"};
char lynq_cmd_ret[MAX_RET]={0};
char get_str_auth[20]={0};