[Bugfix][API-1022] fix can't get connect ap ip of iQOO pro
[Bugfix][API-1031] fix can't get hostname
Change-Id: I7dc3bfa8e913c6326b5d214d1c5d6fb0913dece5
diff --git a/src/lynq/lib/liblynq-wifi6/libwifi6.c b/src/lynq/lib/liblynq-wifi6/libwifi6.c
index 96c4579..51b3ea2 100755
--- a/src/lynq/lib/liblynq-wifi6/libwifi6.c
+++ b/src/lynq/lib/liblynq-wifi6/libwifi6.c
@@ -1075,6 +1075,9 @@
static int inner_get_hostname_by_ip(char *ip, char *hostname) {
struct in_addr addr ={0};
struct hostent *ht;
+ char cmd[64] = {0};
+ char * p;
+ int ret;
if (ip == NULL || *ip == '\0' || hostname == NULL)
{
@@ -1093,6 +1096,19 @@
if (ht == NULL)
{
+ hostname[0] = '\0';
+ sprintf(cmd, "grep -F '%s' /run/wg870/ap0.lease | awk '{print $4}' | tail -1", ip);
+ ret = exec_cmd(cmd, hostname, 32);
+ if (ret == 0)
+ {
+ p = strchr(hostname, '\n');
+ if (p != NULL)
+ {
+ *p = '\0';
+ }
+ return 0;
+ }
+ hostname[0] = '\0';
RLOGE("---gethostbyaddr fail\n");
herror(NULL);
return -1;
@@ -2851,7 +2867,7 @@
DO_OK_FAIL_REQUEST(cmd_disconnect);
- system("echo \"\" > /tmp/dhcpcd.log");
+ system("echo \"\" > /tmp/wlan0_dhcpcd_router");
usleep(200*1000);
ret = inner_sta_start_stop(net_no, 1, 1);
@@ -3696,7 +3712,7 @@
if (ip[0] == '\0' || strchr(ip, ':') != NULL) //temp change, not ok
{
ip[0] = '\0';
- ret = exec_cmd("grep \"offered\" /tmp/dhcpcd.log | awk -F \"from\" '{print $2}'| tail -1", ip, 32);
+ ret = exec_cmd("grep \"new_router\" /tmp/wlan0_dhcpcd_router | awk '{print $2}'| tail -1", ip, 32);
if (ret != 0)
{
ip[0] = '\0';