[Bufgix][wifi][api] fix while country code be CN set frequency 5180 cuse wpa_supplicant error
Change-Id: Ib7733e9438fe3f8af5ef0c0d59c8dd19a3a3b32c
diff --git a/src/lynq/lib/liblynq-wifi6/libwifi6.c b/src/lynq/lib/liblynq-wifi6/libwifi6.c
index 18c7fe5..2525771 100755
--- a/src/lynq/lib/liblynq-wifi6/libwifi6.c
+++ b/src/lynq/lib/liblynq-wifi6/libwifi6.c
@@ -597,7 +597,7 @@
if (NULL == mac || NULL == ip)
return -1;
memset(ip, 0, ip_len);
- sprintf(cmd, "ip neigh | grep \"lladdr\" | grep \"tether\" | grep \"%s\" | head -1 | awk '{print $1}'", mac);
+ sprintf(cmd, "ip n s | grep \"lladdr\" | grep \"%s\" | head -1 | awk '{print $1}'", mac);
ret = exec_cmd(cmd, ip, ip_len);
p = strchr(ip, '\n');
if (NULL != p)
@@ -934,6 +934,27 @@
return 0;
}
+
+static int lynq_check_frequencyby_country_code(int input_frequency)
+{
+ char str_cnc[]="CN";
+ char str_dest[20]="";
+
+ if( lynq_get_country_code(1,str_dest) != 0 )
+ {
+ printf("get country_code error\n");
+ return -1;
+ }
+ if( strncmp(str_dest,str_cnc,2) != 0 )
+ {
+ return 0;
+ }else if( 2473 < input_frequency && input_frequency < 5744)
+ {
+ printf("input frequency is bad\n");
+ return -1;
+ }
+ return 0;
+}
int lynq_wifi_ap_frequency_set(lynq_wifi_index_e idx,int lynq_wifi_frequency)
{
int check;
@@ -948,6 +969,13 @@
printf("do check frequency error\n");
return -1;
}
+ check = lynq_check_frequencyby_country_code(lynq_wifi_frequency);
+ if(check != 0)
+ {
+ printf("do check frequency error\n");
+ return -1;
+ }
+
if (lynq_check_network_number(idx, CTRL_AP, AP_NETWORK_0) != 0)
{
return -1;
@@ -1611,9 +1639,12 @@
continue;
}
- strcpy(password, p);
+ if (*p == '\"')
+ p++;
+ strncpy(password, p, 64);
- while(*password != '\0') {
+ p = password;
+ while(password - p < 64 && *password != '\0') {
if (*password == '\"') {
*password = '\0';
break;
@@ -2612,7 +2643,8 @@
int lynq_get_connect_ap_ip(lynq_wifi_index_e idx, char *ip)
{
- char bssid[1024] = {0};
+ curr_status_info curr_state;
+ ap_info_s ap;
if (ip == NULL)
{
@@ -2622,12 +2654,15 @@
CHECK_IDX(idx, CTRL_STA);
- if (lynq_get_connect_ap_mac(idx, bssid) != 0)
+ memset(&ap, 0, sizeof (ap));
+ curr_state.ap = ≈
+ curr_state.state = NULL;
+ if (inner_get_status_info(idx, &curr_state) != 0)
{
return -1;
}
-
- return inner_get_ip_by_mac(bssid, ip, 32); //better input by user
+ strcpy(ip, curr_state.ap->ap_ip);
+ return 0;
}
int lynq_ap_connect_num(int sta_number)