From 4ca34ac5b5ccadd243a7dcffd5eea4d204ff7a47 Mon Sep 17 00:00:00 2001 From: chenwen Date: Fri, 9 Apr 2021 11:48:01 +0800 Subject: [PATCH] risc-v/esp32c3: Fix the issue of getting wrong Wi-Fi password --- .../risc-v/src/esp32c3/esp32c3_wifi_adapter.c | 20 +++++++++---------- arch/risc-v/src/esp32c3/esp32c3_wlan.c | 6 +++++- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c b/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c index bdd666a40f4..22d7d9da791 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c +++ b/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c @@ -5120,13 +5120,6 @@ int esp_wifi_sta_password(struct iwreq *iwr, bool set) DEBUGASSERT(ext != NULL); pdata = ext->key; - len = ext->key_len; - - if (set && len > PWD_MAX_LEN) - { - return -EINVAL; - } - memset(&wifi_cfg, 0x0, sizeof(wifi_config_t)); ret = esp_wifi_get_config(WIFI_IF_STA, &wifi_cfg); if (ret) @@ -5137,6 +5130,12 @@ int esp_wifi_sta_password(struct iwreq *iwr, bool set) if (set) { + len = ext->key_len; + if (len > PWD_MAX_LEN) + { + return -EINVAL; + } + memcpy(wifi_cfg.sta.password, pdata, len); wifi_cfg.sta.pmf_cfg.capable = true; @@ -5150,6 +5149,7 @@ int esp_wifi_sta_password(struct iwreq *iwr, bool set) } else { + len = iwr->u.encoding.length - sizeof(*ext); size = strnlen((char *)wifi_cfg.sta.password, PWD_MAX_LEN); if (len < size) { @@ -5157,8 +5157,8 @@ int esp_wifi_sta_password(struct iwreq *iwr, bool set) } else { - len = size; - memcpy(pdata, wifi_cfg.sta.password, len); + ext->key_len = size; + memcpy(pdata, wifi_cfg.sta.password, ext->key_len); } if (g_sta_connected) @@ -5862,7 +5862,7 @@ int esp_wifi_sta_country(struct iwreq *iwr, bool set) country_code = (char *)iwr->u.data.pointer; if (strlen(country_code) != 2) { - wlerr("ERROR: Invalid input arguments\r\n"); + wlerr("ERROR: Invalid input arguments\n"); return -EINVAL; } diff --git a/arch/risc-v/src/esp32c3/esp32c3_wlan.c b/arch/risc-v/src/esp32c3/esp32c3_wlan.c index ba549d6e52e..295d0df4baf 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_wlan.c +++ b/arch/risc-v/src/esp32c3/esp32c3_wlan.c @@ -271,6 +271,10 @@ static int wlan_sta_set_linkstatus(FAR struct net_driver_s *dev, bool linkstatus); #endif +#ifdef CONFIG_NET_ICMPv6 +static void wlan_ipv6multicast(FAR struct wlan_priv_s *priv); +#endif + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -1215,7 +1219,7 @@ static int wlan_ifup(FAR struct net_driver_s *dev) (uint8_t)(dev->d_ipaddr >> 16), (uint8_t)(dev->d_ipaddr >> 24)); #endif #ifdef CONFIG_NET_IPv6 - winfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", + ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", dev->d_ipv6addr[0], dev->d_ipv6addr[1], dev->d_ipv6addr[2], dev->d_ipv6addr[3], dev->d_ipv6addr[4], dev->d_ipv6addr[5], dev->d_ipv6addr[6], dev->d_ipv6addr[7]);