Skip to content

Commit 7bf20f1

Browse files
Meissi-jiananchao
authored andcommitted
[wireless] add set/get pmksa api for fast-auth
Signed-off-by: meijian <[email protected]>
1 parent cf7491a commit 7bf20f1

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed

include/wireless/wapi.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,28 @@ int wapi_set_pta_prio(int sock, FAR const char *ifname,
964964
int wapi_get_pta_prio(int sock, FAR const char *ifname,
965965
enum wapi_pta_prio_e *pta_prio);
966966

967+
/****************************************************************************
968+
* Name: wapi_set_pmksa
969+
*
970+
* Description:
971+
* Set the wlan pmksa.
972+
*
973+
****************************************************************************/
974+
975+
int wapi_set_pmksa(int sock, FAR const char *ifname,
976+
FAR const uint8_t *pmk, int len);
977+
978+
/****************************************************************************
979+
* Name: wapi_get_pmksa
980+
*
981+
* Description:
982+
* Get the wlan pmksa.
983+
*
984+
****************************************************************************/
985+
986+
int wapi_get_pmksa(int sock, FAR const char *ifname,
987+
FAR uint8_t *pmk, int len);
988+
967989
/****************************************************************************
968990
* Name: wapi_extend_params
969991
*

wireless/wapi/src/util.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,12 @@ FAR const char *wapi_ioctl_command_name(int cmd)
275275
case SIOCSIWPTAPRIO:
276276
return "SIOCSIWPTAPRIO";
277277

278+
case SIOCSIWPMKSA:
279+
return "SIOCSIWPMKSA";
280+
281+
case SIOCGIWPMKSA:
282+
return "SIOCGIWPMKSA";
283+
278284
default:
279285
snprintf(g_ioctl_command_namebuf, WAPI_IOCTL_COMMAND_NAMEBUFSIZ,
280286
"0x%x", cmd);

wireless/wapi/src/wireless.c

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,6 +1628,74 @@ int wapi_get_pta_prio(int sock, FAR const char *ifname,
16281628
return ret;
16291629
}
16301630

1631+
/****************************************************************************
1632+
* Name: wapi_set_pmksa
1633+
*
1634+
* Description:
1635+
* Set the wlan pmksa.
1636+
*
1637+
****************************************************************************/
1638+
1639+
int wapi_set_pmksa(int sock, FAR const char *ifname,
1640+
FAR const uint8_t *pmk, int len)
1641+
{
1642+
struct iwreq wrq =
1643+
{
1644+
};
1645+
1646+
int ret;
1647+
1648+
WAPI_VALIDATE_PTR(pmk);
1649+
1650+
wrq.u.data.pointer = (FAR void *)pmk;
1651+
wrq.u.data.length = len;
1652+
1653+
strlcpy(wrq.ifr_name, ifname, IFNAMSIZ);
1654+
ret = ioctl(sock, SIOCSIWPMKSA, (unsigned long)((uintptr_t)&wrq));
1655+
if (ret < 0)
1656+
{
1657+
int errcode = errno;
1658+
WAPI_IOCTL_STRERROR(SIOCSIWPMKSA, errcode);
1659+
ret = -errcode;
1660+
}
1661+
1662+
return ret;
1663+
}
1664+
1665+
/****************************************************************************
1666+
* Name: wapi_get_pmksa
1667+
*
1668+
* Description:
1669+
* Get the wlan pmksa.
1670+
*
1671+
****************************************************************************/
1672+
1673+
int wapi_get_pmksa(int sock, FAR const char *ifname,
1674+
FAR uint8_t *pmk, int len)
1675+
{
1676+
struct iwreq wrq =
1677+
{
1678+
};
1679+
1680+
int ret;
1681+
1682+
WAPI_VALIDATE_PTR(pmk);
1683+
1684+
wrq.u.data.pointer = pmk;
1685+
wrq.u.data.length = len;
1686+
1687+
strlcpy(wrq.ifr_name, ifname, IFNAMSIZ);
1688+
ret = ioctl(sock, SIOCGIWPMKSA, (unsigned long)((uintptr_t)&wrq));
1689+
if (ret < 0)
1690+
{
1691+
int errcode = errno;
1692+
WAPI_IOCTL_STRERROR(SIOCGIWPMKSA, errcode);
1693+
ret = -errcode;
1694+
}
1695+
1696+
return ret;
1697+
}
1698+
16311699
/****************************************************************************
16321700
* Name: wapi_extend_params
16331701
*

0 commit comments

Comments
 (0)