From 39c5fa812df515efd9a2617fd53e385547fcef2c Mon Sep 17 00:00:00 2001 From: chenwen Date: Fri, 9 Apr 2021 19:02:18 +0800 Subject: [PATCH] wireless/wapi: Fix issue of getting the operating frequency --- include/wireless/wapi.h | 6 +++--- wireless/wapi/src/wapi.c | 6 +++++- wireless/wapi/src/wireless.c | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/wireless/wapi.h b/include/wireless/wapi.h index f6dc8d941..77ddc4ef9 100644 --- a/include/wireless/wapi.h +++ b/include/wireless/wapi.h @@ -125,8 +125,8 @@ enum wapi_route_target_e enum wapi_essid_flag_e { - WAPI_ESSID_OFF, - WAPI_ESSID_ON, + WAPI_ESSID_OFF = IW_ESSID_OFF, + WAPI_ESSID_ON = IW_ESSID_ON, /* Extended flag "WAPI_ESSID_DELAY_ON" instructs the driver * to delay the connection behavior of essid, so that which can accept @@ -155,7 +155,7 @@ enum wapi_essid_flag_e * $ renew wlan0 */ - WAPI_ESSID_DELAY_ON + WAPI_ESSID_DELAY_ON = IW_ESSID_DELAY_ON }; /* Supported operation modes. */ diff --git a/wireless/wapi/src/wapi.c b/wireless/wapi/src/wapi.c index cc8c28f3e..33a61c457 100644 --- a/wireless/wapi/src/wapi.c +++ b/wireless/wapi/src/wapi.c @@ -137,6 +137,10 @@ static const struct wapi_command_s g_wapi_commands[] = #define NCOMMANDS (sizeof(g_wapi_commands) / sizeof(struct wapi_command_s)) +/* Maximum length of the PASSPHRASE, refer to IEEE802.11i specification */ + +#define PASSPHRASE_MAX_LEN (64) + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -842,7 +846,7 @@ static int wapi_save_config_cmd(int sock, int argc, FAR char **argv) uint8_t if_flags; uint32_t value; size_t psk_len; - char psk[32]; + char psk[PASSPHRASE_MAX_LEN]; int ret; ret = netlib_getifstatus(argv[0], &if_flags); diff --git a/wireless/wapi/src/wireless.c b/wireless/wapi/src/wireless.c index 4a44ac2ab..f576f8db0 100644 --- a/wireless/wapi/src/wireless.c +++ b/wireless/wapi/src/wireless.c @@ -475,11 +475,11 @@ int wapi_get_freq(int sock, FAR const char *ifname, FAR double *freq, { /* Set flag. */ - if (IW_FREQ_AUTO == (wrq.u.freq.flags & IW_FREQ_AUTO)) + if (IW_FREQ_AUTO == wrq.u.freq.flags) { *flag = WAPI_FREQ_AUTO; } - else if (IW_FREQ_FIXED == (wrq.u.freq.flags & IW_FREQ_FIXED)) + else if (IW_FREQ_FIXED == wrq.u.freq.flags) { *flag = WAPI_FREQ_FIXED; }