diff --git a/include/wireless/wapi.h b/include/wireless/wapi.h index a30492438..696294e95 100644 --- a/include/wireless/wapi.h +++ b/include/wireless/wapi.h @@ -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[]; diff --git a/wireless/wapi/src/wapi.c b/wireless/wapi/src/wapi.c index 3016f52af..89e763e42 100644 --- a/wireless/wapi/src/wapi.c +++ b/wireless/wapi/src/wapi.c @@ -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 \n", progname); fprintf(stderr, "\t%s psk " - "\n", progname); + "[wpa]\n", progname); fprintf(stderr, "\t%s disconnect \n", progname); fprintf(stderr, "\t%s 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++) { diff --git a/wireless/wapi/src/wireless.c b/wireless/wapi/src/wireless.c index 93fee02e0..ea52a750a 100644 --- a/wireless/wapi/src/wireless.c +++ b/wireless/wapi/src/wireless.c @@ -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[] =