This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new e4cddb1  wapi/conf: convert mac address
e4cddb1 is described below

commit e4cddb169ab5516bb63d0e5692a9a7900259c295
Author: chao.an <anc...@xiaomi.com>
AuthorDate: Tue Dec 8 20:57:01 2020 +0800

    wapi/conf: convert mac address
    
    N/A
    
    Signed-off-by: chao.an <anc...@xiaomi.com>
---
 wireless/wapi/src/util.c | 9 ++++++++-
 wireless/wapi/src/wapi.c | 4 +++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/wireless/wapi/src/util.c b/wireless/wapi/src/util.c
index 09b544c..5907482 100644
--- a/wireless/wapi/src/util.c
+++ b/wireless/wapi/src/util.c
@@ -307,6 +307,7 @@ FAR void *wapi_load_config(FAR const char *ifname,
                            FAR const char *confname,
                            FAR struct wpa_wconfig_s *conf)
 {
+  FAR struct ether_addr *ap;
   FAR cJSON *ifobj;
   FAR cJSON *root;
   FAR cJSON *obj;
@@ -336,6 +337,8 @@ FAR void *wapi_load_config(FAR const char *ifname,
       goto errout;
     }
 
+  memset(conf, 0, sizeof(*conf));
+
   obj = cJSON_GetObjectItem(ifobj, "mode");
   if (!obj)
     {
@@ -382,7 +385,11 @@ FAR void *wapi_load_config(FAR const char *ifname,
       goto errout;
     }
 
-  conf->bssid = (FAR const char *)obj->valuestring;
+  ap = ether_aton(obj->valuestring);
+  if (ap != NULL)
+    {
+      conf->bssid = (FAR const char *)ap->ether_addr_octet;
+    }
 
   obj = cJSON_GetObjectItem(ifobj, "psk");
   if (!obj || !obj->valuestring)
diff --git a/wireless/wapi/src/wapi.c b/wireless/wapi/src/wapi.c
index 840a6f7..853c2d2 100644
--- a/wireless/wapi/src/wapi.c
+++ b/wireless/wapi/src/wapi.c
@@ -48,6 +48,8 @@
 #include <netinet/in.h>
 #include <arpa/inet.h>
 
+#include <netinet/ether.h>
+
 #include "netutils/netlib.h"
 
 #include "wireless/wapi.h"
@@ -834,7 +836,7 @@ static int wapi_save_config_cmd(int sock, int argc, FAR 
char **argv)
       return ret;
     }
 
-  conf.bssid = (FAR const char *)ap.ether_addr_octet;
+  conf.bssid = ether_ntoa(&ap);
 
   memset(psk, 0, sizeof(psk));
   ret = wpa_driver_wext_get_key_ext(sock,

Reply via email to