wireless/wapi: support WPA3 on wapi psk
command
Similarly to the alg_flag (which can be set by text), the ver_flag is able to select the WPA version which will be sent to the Wi-Fi driver through the `IW_AUTH_WPA_VERSION` command. A new bit field (IW_AUTH_WPA_VERSION_WPA3) was created to indicate WPA3 is set. It's up to the arch's Wi-Fi driver to implement handling of this new bit field and config the underlying driver to handle WPA3 on AP and/or STA mode. This implementation doesn't interfere with commonly used commands. `wapi psk wlan0 mypasswd 3` still selects CCMP algorithm and WPA2 and is equivalent to `wapi psk wlan0 mypasswd 3 WPA_VER_2`. One can use `wapi psk wlan0 mypasswd 3 WPA_VER_3` to set WPA3.
This commit is contained in:
parent
fe8232fba0
commit
3516a5d2ee
@ -265,6 +265,14 @@ enum wpa_alg_e
|
||||
WPA_ALG_BIP_CMAC_256
|
||||
};
|
||||
|
||||
enum wpa_ver_e
|
||||
{
|
||||
WPA_VER_NONE = 0,
|
||||
WPA_VER_1,
|
||||
WPA_VER_2,
|
||||
WPA_VER_3
|
||||
};
|
||||
|
||||
/* This structure provides the wireless configuration to
|
||||
* wpa_driver_wext_associate().
|
||||
*/
|
||||
@ -324,6 +332,10 @@ EXTERN FAR const char *g_wapi_essid_flags[];
|
||||
|
||||
EXTERN FAR const char *g_wapi_alg_flags[];
|
||||
|
||||
/* Passphrase WPA Version flag names. */
|
||||
|
||||
EXTERN FAR const char *g_wapi_wpa_ver_flags[];
|
||||
|
||||
/* Supported operation mode names. */
|
||||
|
||||
EXTERN FAR const char *g_wapi_modes[];
|
||||
|
@ -545,6 +545,7 @@ static int wapi_essid_cmd(int sock, int argc, FAR char **argv)
|
||||
static int wapi_psk_cmd(int sock, int argc, FAR char **argv)
|
||||
{
|
||||
enum wpa_alg_e alg_flag;
|
||||
enum wpa_ver_e ver_flag;
|
||||
uint8_t auth_wpa;
|
||||
int passlen;
|
||||
int cipher;
|
||||
@ -561,17 +562,39 @@ static int wapi_psk_cmd(int sock, int argc, FAR char **argv)
|
||||
|
||||
/* Convert input strings to values */
|
||||
|
||||
alg_flag = (enum wpa_alg_e)wapi_str2ndx(argv[2], g_wapi_alg_flags);
|
||||
|
||||
if (argc > 3)
|
||||
{
|
||||
auth_wpa = atoi(argv[3]);
|
||||
ver_flag = (enum wpa_ver_e)wapi_str2ndx(argv[3], g_wapi_wpa_ver_flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
auth_wpa = IW_AUTH_WPA_VERSION_WPA2;
|
||||
ver_flag = WPA_VER_2;
|
||||
}
|
||||
|
||||
switch (ver_flag)
|
||||
{
|
||||
case WPA_VER_NONE:
|
||||
auth_wpa = IW_AUTH_WPA_VERSION_DISABLED;
|
||||
break;
|
||||
|
||||
case WPA_VER_1:
|
||||
auth_wpa = IW_AUTH_WPA_VERSION_WPA;
|
||||
break;
|
||||
|
||||
case WPA_VER_2:
|
||||
auth_wpa = IW_AUTH_WPA_VERSION_WPA2;
|
||||
break;
|
||||
|
||||
case WPA_VER_3:
|
||||
auth_wpa = IW_AUTH_WPA_VERSION_WPA3;
|
||||
break;
|
||||
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
alg_flag = (enum wpa_alg_e)wapi_str2ndx(argv[2], g_wapi_alg_flags);
|
||||
|
||||
switch (alg_flag)
|
||||
{
|
||||
case WPA_ALG_NONE:
|
||||
@ -1081,7 +1104,7 @@ static void wapi_showusage(FAR const char *progname, int exitcode)
|
||||
fprintf(stderr, "\t%s essid <ifname> <essid> <index/flag>\n",
|
||||
progname);
|
||||
fprintf(stderr, "\t%s psk <ifname> <passphrase> <index/flag> "
|
||||
"<wpa>\n", progname);
|
||||
"[wpa]\n", progname);
|
||||
fprintf(stderr, "\t%s disconnect <ifname>\n", progname);
|
||||
fprintf(stderr, "\t%s mode <ifname> <index/mode>\n",
|
||||
progname);
|
||||
@ -1119,6 +1142,12 @@ static void wapi_showusage(FAR const char *progname, int exitcode)
|
||||
fprintf(stderr, "\t[%d] %s\n", i, g_wapi_alg_flags[i]);
|
||||
}
|
||||
|
||||
fprintf(stderr, "\nPassphrase WPA version:\n");
|
||||
for (i = 0; g_wapi_wpa_ver_flags[i]; i++)
|
||||
{
|
||||
fprintf(stderr, "\t[%d] %s\n", i, g_wapi_wpa_ver_flags[i]);
|
||||
}
|
||||
|
||||
fprintf(stderr, "\nOperating Modes:\n");
|
||||
for (i = 0; g_wapi_modes[i]; i++)
|
||||
{
|
||||
|
@ -132,6 +132,17 @@ FAR const char *g_wapi_alg_flags[] =
|
||||
NULL
|
||||
};
|
||||
|
||||
/* Passphrase WPA Version */
|
||||
|
||||
FAR const char *g_wapi_wpa_ver_flags[] =
|
||||
{
|
||||
"WPA_VER_NONE",
|
||||
"WPA_VER_1",
|
||||
"WPA_VER_2",
|
||||
"WPA_VER_3",
|
||||
NULL
|
||||
};
|
||||
|
||||
/* PTA PRIORITY */
|
||||
|
||||
FAR const char *g_wapi_pta_prio_flags[] =
|
||||
|
Loading…
Reference in New Issue
Block a user