[Feature][TCM_WG870_SW_0034][wifi] add lynq_get_connect_ap_ip api

Change-Id: I30a2fdd67c734a8fb1e4ccf9f3b3f165922d1a78
diff --git a/lib/liblynq-wifi6/libwifi6.c b/lib/liblynq-wifi6/libwifi6.c
index f4e3b8f..c682976 100755
--- a/lib/liblynq-wifi6/libwifi6.c
+++ b/lib/liblynq-wifi6/libwifi6.c
@@ -683,18 +683,18 @@
     ret = -1;
     for(i=0; i < count; i++) {
         if (curr_state->ap != NULL) {
-            p = strstr(split_lines[i], FLAG_SSID);
-            if (p != NULL) {
-                strcpy(curr_state->ap->ap_ssid, p + strlen(FLAG_SSID));
-                ret = 0;
-                continue;
-            }
             p = strstr(split_lines[i], FLAG_SBSID);
             if (p != NULL) {
                 strcpy(curr_state->ap->ap_mac, p + strlen(FLAG_SBSID));
                 ret = 0;
                 continue;
             }
+            p = strstr(split_lines[i], FLAG_SSID);
+            if (p != NULL) {
+                strcpy(curr_state->ap->ap_ssid, p + strlen(FLAG_SSID));
+                ret = 0;
+                continue;
+            }
             p = strstr(split_lines[i], FLAG_KEY_MGMT);
             if (p != NULL) {
                 curr_state->ap->auth = convert_auth_from_key_mgmt(p);
@@ -2209,6 +2209,11 @@
    int family, s;
    char host[NI_MAXHOST];
    const char * ifaName = "wlan0";
+   if (ip == NULL)
+   {
+       return -1;
+   }
+
    if (idx == 1) {
        ifaName = "tether";
    }
@@ -2348,3 +2353,41 @@
 
     return 0;
 }
+
+int lynq_get_connect_ap_ip(lynq_wifi_index_e idx, char *ip)
+{
+    int index;
+    int ip_count = 0;
+    char bssid[1024] = {0};
+    char *mac_list[128] = {0};
+    char *ip_list[128] = {0};
+
+    if (ip == NULL)
+    {
+        printf("invalid param");
+        return -1;
+    }
+
+    CHECK_IDX(idx, CTRL_STA);
+
+    if (lynq_get_connect_ap_mac(idx, bssid) != 0)
+    {
+        return -1;
+    }
+
+    ip_count = get_ip_mac_list(mac_list, ip_list);
+
+    for (index=0; index < ip_count; index++)
+    {
+        if (strcmp(bssid, mac_list[index]) == 0)
+        {
+            strcpy(ip, ip_list[index]);
+            return 0;
+        }
+    }
+
+    printf("not found\n");
+    return -1;
+}
+
+