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

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

commit 7bf20f1a8965c579e5d170dadec357dcb61be1a5
Author: meijian <meij...@xiaomi.com>
AuthorDate: Wed Nov 29 20:12:54 2023 +0800

    [wireless] add set/get pmksa api for fast-auth
    
    Signed-off-by: meijian <meij...@xiaomi.com>
---
 include/wireless/wapi.h      | 22 ++++++++++++++
 wireless/wapi/src/util.c     |  6 ++++
 wireless/wapi/src/wireless.c | 68 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 96 insertions(+)

diff --git a/include/wireless/wapi.h b/include/wireless/wapi.h
index e7fa77695..dae250ba5 100644
--- a/include/wireless/wapi.h
+++ b/include/wireless/wapi.h
@@ -964,6 +964,28 @@ int wapi_set_pta_prio(int sock, FAR const char *ifname,
 int wapi_get_pta_prio(int sock, FAR const char *ifname,
                       enum wapi_pta_prio_e *pta_prio);
 
+/****************************************************************************
+ * Name: wapi_set_pmksa
+ *
+ * Description:
+ *   Set the wlan pmksa.
+ *
+ ****************************************************************************/
+
+int wapi_set_pmksa(int sock, FAR const char *ifname,
+                   FAR const uint8_t *pmk, int len);
+
+/****************************************************************************
+ * Name: wapi_get_pmksa
+ *
+ * Description:
+ *   Get the wlan pmksa.
+ *
+ ****************************************************************************/
+
+int wapi_get_pmksa(int sock, FAR const char *ifname,
+                   FAR uint8_t *pmk, int len);
+
 /****************************************************************************
  * Name: wapi_extend_params
  *
diff --git a/wireless/wapi/src/util.c b/wireless/wapi/src/util.c
index d20fb3443..9104d28e9 100644
--- a/wireless/wapi/src/util.c
+++ b/wireless/wapi/src/util.c
@@ -275,6 +275,12 @@ FAR const char *wapi_ioctl_command_name(int cmd)
     case SIOCSIWPTAPRIO:
       return "SIOCSIWPTAPRIO";
 
+    case SIOCSIWPMKSA:
+      return "SIOCSIWPMKSA";
+
+    case SIOCGIWPMKSA:
+      return "SIOCGIWPMKSA";
+
     default:
       snprintf(g_ioctl_command_namebuf, WAPI_IOCTL_COMMAND_NAMEBUFSIZ,
                "0x%x", cmd);
diff --git a/wireless/wapi/src/wireless.c b/wireless/wapi/src/wireless.c
index 94dc29245..56f67fc81 100644
--- a/wireless/wapi/src/wireless.c
+++ b/wireless/wapi/src/wireless.c
@@ -1628,6 +1628,74 @@ int wapi_get_pta_prio(int sock, FAR const char *ifname,
   return ret;
 }
 
+/****************************************************************************
+ * Name: wapi_set_pmksa
+ *
+ * Description:
+ *   Set the wlan pmksa.
+ *
+ ****************************************************************************/
+
+int wapi_set_pmksa(int sock, FAR const char *ifname,
+                   FAR const uint8_t *pmk, int len)
+{
+  struct iwreq wrq =
+  {
+  };
+
+  int ret;
+
+  WAPI_VALIDATE_PTR(pmk);
+
+  wrq.u.data.pointer = (FAR void *)pmk;
+  wrq.u.data.length = len;
+
+  strlcpy(wrq.ifr_name, ifname, IFNAMSIZ);
+  ret = ioctl(sock, SIOCSIWPMKSA, (unsigned long)((uintptr_t)&wrq));
+  if (ret < 0)
+    {
+      int errcode = errno;
+      WAPI_IOCTL_STRERROR(SIOCSIWPMKSA, errcode);
+      ret = -errcode;
+    }
+
+  return ret;
+}
+
+/****************************************************************************
+ * Name: wapi_get_pmksa
+ *
+ * Description:
+ *   Get the wlan pmksa.
+ *
+ ****************************************************************************/
+
+int wapi_get_pmksa(int sock, FAR const char *ifname,
+                   FAR uint8_t *pmk, int len)
+{
+  struct iwreq wrq =
+  {
+  };
+
+  int ret;
+
+  WAPI_VALIDATE_PTR(pmk);
+
+  wrq.u.data.pointer = pmk;
+  wrq.u.data.length = len;
+
+  strlcpy(wrq.ifr_name, ifname, IFNAMSIZ);
+  ret = ioctl(sock, SIOCGIWPMKSA, (unsigned long)((uintptr_t)&wrq));
+  if (ret < 0)
+    {
+      int errcode = errno;
+      WAPI_IOCTL_STRERROR(SIOCGIWPMKSA, errcode);
+      ret = -errcode;
+    }
+
+  return ret;
+}
+
 /****************************************************************************
  * Name: wapi_extend_params
  *

Reply via email to