From 0f08a5b1231800a2684b2639b9ba6cb664be0e47 Mon Sep 17 00:00:00 2001 From: Abhik Roy Date: Wed, 17 Apr 2024 23:56:11 +1000 Subject: [PATCH 1/7] feat(lwip): Added multiple dns ip support (v5.3) LWIP submodule update on v5.3: git log --oneline f7922143..f1746813 - feat(lwip): Added multiple dns ip support (espressif/esp-lwip@f1746813) - api_msg: Fix crash to fail-safe error if cannot get semaphore (espressif/esp-lwip@a1bd9e44) --- components/lwip/Kconfig | 14 ++++++++++---- components/lwip/lwip | 2 +- components/lwip/port/include/lwipopts.h | 6 +++++- docs/en/api-guides/lwip.rst | 4 ++++ 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/components/lwip/Kconfig b/components/lwip/Kconfig index 1904ba5b70..5d80561043 100644 --- a/components/lwip/Kconfig +++ b/components/lwip/Kconfig @@ -669,7 +669,7 @@ menu "LWIP" LWIP_TCP_RECCVMBOX_SIZE packets for each TCP socket, so the maximum possible cached TCP packets for all TCP sockets is LWIP_TCP_RECCVMBOX_SIZE multiples the maximum TCP socket number. In other words, the bigger LWIP_TCP_RECVMBOX_SIZE means more memory. - On the other hand, if the receiv mail box is too small, the mail box may be full. If the + On the other hand, if the receive mail box is too small, the mail box may be full. If the mail box is full, the LWIP drops the packets. So generally we need to make sure the TCP receive mail box is big enough to avoid packet drop between LWIP core and application. @@ -813,7 +813,7 @@ menu "LWIP" UDP_RECCVMBOX_SIZE packets for each UDP socket, so the maximum possible cached UDP packets for all UDP sockets is UDP_RECCVMBOX_SIZE multiples the maximum UDP socket number. In other words, the bigger UDP_RECVMBOX_SIZE means more memory. - On the other hand, if the receiv mail box is too small, the mail box may be full. If the + On the other hand, if the receive mail box is too small, the mail box may be full. If the mail box is full, the LWIP drops the packets. So generally we need to make sure the UDP receive mail box is big enough to avoid packet drop between LWIP core and application. @@ -1060,12 +1060,12 @@ menu "LWIP" SNTP callback for such replies should be set accordingly (see sntp_servermode_dhcp() func.) config LWIP_DHCP_MAX_NTP_SERVERS - int "Maximum number of NTP servers aquired via DHCP" + int "Maximum number of NTP servers acquired via DHCP" default 1 range 1 16 depends on LWIP_DHCP_GET_NTP_SRV help - Set maximum number of NTP servers aquired via DHCP-offer. + Set maximum number of NTP servers acquired via DHCP-offer. Should be less or equal to "Maximum number of NTP servers", any extra servers would be just ignored. config LWIP_SNTP_UPDATE_DELAY @@ -1101,6 +1101,12 @@ menu "LWIP" menu "DNS" + config LWIP_DNS_MAX_HOST_IP + int "Maximum number of IP addresses per host" + default 1 + help + Maximum number of IP addresses that can be returned by DNS queries for a single host. + config LWIP_DNS_MAX_SERVERS int "Maximum number of DNS servers" default 3 diff --git a/components/lwip/lwip b/components/lwip/lwip index f79221431f..f174681317 160000 --- a/components/lwip/lwip +++ b/components/lwip/lwip @@ -1 +1 @@ -Subproject commit f79221431fa9042b3572d271d687de66da7560c4 +Subproject commit f174681317a00d209e374c66d9691ef79b4195de diff --git a/components/lwip/port/include/lwipopts.h b/components/lwip/port/include/lwipopts.h index 51e3c3c3d0..e95d647029 100644 --- a/components/lwip/port/include/lwipopts.h +++ b/components/lwip/port/include/lwipopts.h @@ -470,6 +470,10 @@ static inline uint32_t timeout_from_offered(uint32_t lease, uint32_t min) */ #define LWIP_DNS 1 +/** The maximum number of IP addresses per host + */ +#define DNS_MAX_HOST_IP CONFIG_LWIP_DNS_MAX_HOST_IP + /** The maximum of DNS servers */ #define DNS_MAX_SERVERS CONFIG_LWIP_DNS_MAX_SERVERS @@ -1103,7 +1107,7 @@ static inline uint32_t timeout_from_offered(uint32_t lease, uint32_t min) /** * PPP_MAXIDLEFLAG: Max Xmit idle time (in ms) before resend flag char. * TODO: If PPP_MAXIDLEFLAG > 0 and next package is send during PPP_MAXIDLEFLAG time, - * then 0x7E is not added at the begining of PPP package but 0x7E termination + * then 0x7E is not added at the beginning of PPP package but 0x7E termination * is always at the end. This behaviour brokes PPP dial with GSM (PPPoS). * The PPP package should always start and end with 0x7E. */ diff --git a/docs/en/api-guides/lwip.rst b/docs/en/api-guides/lwip.rst index 56e9c54f67..462ded4e9e 100644 --- a/docs/en/api-guides/lwip.rst +++ b/docs/en/api-guides/lwip.rst @@ -459,6 +459,10 @@ Limitations ESP-IDF additions to lwIP still suffer from the global DNS limitation, described in :ref:`lwip-dns-limitation`. To address this limitation from application code, the ``FALLBACK_DNS_SERVER_ADDRESS()`` macro can be utilized to define a global DNS fallback server accessible from all interfaces. Alternatively, you have the option to maintain per-interface DNS servers and reconfigure them whenever the default interface changes. +The number of IP addresses returned by network database APIs such as ``getaddrinfo()`` and ``gethostbyname()`` is restricted by the macro ``DNS_MAX_HOST_IP``. By default, the value of this macro is set to 1. + +In the implementation of ``getaddrinfo()``, the canonical name is not available. Therefore, the ``ai_canonname`` field of the first returned ``addrinfo`` structure will always refer to the ``nodename`` argument or a string with the same contents. + Calling ``send()`` or ``sendto()`` repeatedly on a UDP socket may eventually fail with ``errno`` equal to ``ENOMEM``. This failure occurs due to the limitations of buffer sizes in the lower-layer network interface drivers. If all driver transmit buffers are full, the UDP transmission will fail. For applications that transmit a high volume of UDP datagrams and aim to avoid any dropped datagrams by the sender, it is advisable to implement error code checking and employ a retransmission mechanism with a short delay. .. only:: esp32 From cf65f557cc4aebf06a132b2cdcbcc3c57b97ed80 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Tue, 21 May 2024 16:57:06 +0200 Subject: [PATCH 2/7] fix(esp_netif): Restore DNS servers per netif when setting it default(5.3) Introducing config option `CONFIG_ESP_NETIF_SET_DNS_PER_DEFAULT_NETIF` to overcome LWIP limitation of using global DNS server info. This config option enables LWIP callbacks to collect per netif DNS server info and then restores global DNS servers of whichever network interface is selected as default. LWIP submodule update v5.3: git log --oneline f1746813..3a3d1fb3 - dns: Allow storing dnsserver per netif (espressif/esp-lwip@3a3d1fb3) - api_msg: Fix unused local variable if LWIP_NETCONN_SEM_PER_THREAD=1 (espressif/esp-lwip@aa4f6e78) - lwip: fix gcc -fanalyzer warnings (espressif/esp-lwip@4297782b) --- components/esp_netif/Kconfig | 13 ++- components/esp_netif/include/esp_netif.h | 10 ++ components/esp_netif/lwip/esp_netif_lwip.c | 98 ++++++++++++++----- .../esp_netif/lwip/esp_netif_lwip_internal.h | 17 +++- .../esp_netif/lwip/esp_netif_lwip_ppp.c | 1 + components/lwip/Kconfig | 9 ++ components/lwip/lwip | 2 +- components/lwip/port/include/lwipopts.h | 11 +++ 8 files changed, 131 insertions(+), 30 deletions(-) diff --git a/components/esp_netif/Kconfig b/components/esp_netif/Kconfig index c4117e0e6e..3d7568ed05 100644 --- a/components/esp_netif/Kconfig +++ b/components/esp_netif/Kconfig @@ -76,5 +76,16 @@ menu "ESP NETIF Adapter" default n help Enable LwIP IEEE 802.1D bridge support in ESP-NETIF. Note that "Number of clients store data in netif" - (LWIP_NUM_NETIF_CLIENT_DATA) option needs to be properly configured to be LwIP bridge avaiable! + (LWIP_NUM_NETIF_CLIENT_DATA) option needs to be properly configured to be LwIP bridge available! + + config ESP_NETIF_SET_DNS_PER_DEFAULT_NETIF + bool "Enable DNS server per interface" + default n + select LWIP_DNS_SETSERVER_WITH_NETIF + help + Enable this option to use the DNS server which belongs to the selected default network interface. + This feature collects DNS server and netif information from LWIP core modules. + Whenever a new default netif is selected, global DNS servers in LWIP are updated with the netif + related servers. + endmenu diff --git a/components/esp_netif/include/esp_netif.h b/components/esp_netif/include/esp_netif.h index 6dd6601509..c63b084f29 100644 --- a/components/esp_netif/include/esp_netif.h +++ b/components/esp_netif/include/esp_netif.h @@ -715,6 +715,11 @@ esp_err_t esp_netif_dhcps_get_clients_by_mac(esp_netif_t *esp_netif, int num, es * and is designed to be set via this API. * If DHCP client is disabled, all DNS server types can be set via this API only. * + * Note that LWIP stores DNS server information globally, not per interface, so the first parameter is unused + * in the default LWIP configuration. + * If CONFIG_ESP_NETIF_SET_DNS_PER_DEFAULT_NETIF=1 this API sets internal DNS server information per + * netif. It's also possible set the global DNS server info by supplying esp_netif=NULL + * * If DHCP server is enabled, the Main DNS Server setting is used by the DHCP server to provide a DNS Server option * to DHCP clients (Wi-Fi stations). * - The default Main DNS server is typically the IP of the DHCP server itself. @@ -740,6 +745,11 @@ esp_err_t esp_netif_set_dns_info(esp_netif_t *esp_netif, esp_netif_dns_type_t ty * This may be result of a previous call to esp_netif_set_dns_info(). If the interface's DHCP client is enabled, * the Main or Backup DNS Server may be set by the current DHCP lease. * + * Note that LWIP stores DNS server information globally, not per interface, so the first parameter is unused + * in the default LWIP configuration. + * If CONFIG_ESP_NETIF_SET_DNS_PER_DEFAULT_NETIF=1 this API returns internally saved DNS server information per + * netif. It's also possible to ask for the global DNS server info by supplying esp_netif=NULL + * * @param[in] esp_netif Handle to esp-netif instance * @param[in] type Type of DNS Server to get: ESP_NETIF_DNS_MAIN, ESP_NETIF_DNS_BACKUP, ESP_NETIF_DNS_FALLBACK * @param[out] dns DNS Server result is written here on success diff --git a/components/esp_netif/lwip/esp_netif_lwip.c b/components/esp_netif/lwip/esp_netif_lwip.c index bf5560f496..75cf37972d 100644 --- a/components/esp_netif/lwip/esp_netif_lwip.c +++ b/components/esp_netif/lwip/esp_netif_lwip.c @@ -113,16 +113,6 @@ do { action; \ } while(0) -// -// Internal types -// -typedef enum esp_netif_action { - ESP_NETIF_UNDEF, - ESP_NETIF_STARTED, - ESP_NETIF_STOPPED, - ESP_NETIF_SET_DEFAULT, -} esp_netif_action_t; - // // Internal variables for this module // @@ -306,6 +296,11 @@ static void esp_netif_set_default_netif_internal(esp_netif_t *esp_netif) } else { netif_set_default(esp_netif->lwip_netif); } +#ifdef CONFIG_ESP_NETIF_SET_DNS_PER_DEFAULT_NETIF + for (int i = 0; i < DNS_MAX_SERVERS; ++i) { + dns_setserver(i, &esp_netif->dns[i]); + } +#endif } /** @@ -316,7 +311,7 @@ static void esp_netif_set_default_netif_internal(esp_netif_t *esp_netif) static esp_err_t esp_netif_update_default_netif_lwip(esp_netif_api_msg_t *msg) { esp_netif_t *esp_netif = msg->esp_netif; - esp_netif_action_t action = (esp_netif_action_t)msg->data; + esp_netif_route_prio_action_t action = (esp_netif_route_prio_action_t)msg->data; ESP_LOGD(TAG, "%s %p", __func__, esp_netif); @@ -336,6 +331,7 @@ static esp_err_t esp_netif_update_default_netif_lwip(esp_netif_api_msg_t *msg) esp_netif_set_default_netif_internal(s_last_default_esp_netif); break; case ESP_NETIF_STARTED: + case ESP_NETIF_GOT_IP: { // check if previously default interface hasn't been destroyed in the meantime s_last_default_esp_netif = esp_netif_is_active(s_last_default_esp_netif); @@ -351,6 +347,7 @@ static esp_err_t esp_netif_update_default_netif_lwip(esp_netif_api_msg_t *msg) default: case ESP_NETIF_STOPPED: + case ESP_NETIF_LOST_IP: { s_last_default_esp_netif = NULL; esp_netif_t *netif = esp_netif_next_unsafe(NULL); @@ -382,7 +379,7 @@ static esp_err_t esp_netif_update_default_netif_lwip(esp_netif_api_msg_t *msg) * @param esp_netif current interface which just updated state * @param action updating action (on-off) */ -static esp_err_t esp_netif_update_default_netif(esp_netif_t *esp_netif, esp_netif_action_t action) +esp_err_t esp_netif_update_default_netif(esp_netif_t *esp_netif, esp_netif_route_prio_action_t action) { return esp_netif_lwip_ipc_call(esp_netif_update_default_netif_lwip, esp_netif, (void*)action); } @@ -502,6 +499,24 @@ void* esp_netif_get_netif_impl(esp_netif_t *esp_netif) return NULL; } +#if CONFIG_ESP_NETIF_SET_DNS_PER_DEFAULT_NETIF +static void store_dnsserver_info(struct netif* netif, u8_t numdns, const ip_addr_t *dnsserver) +{ + if (netif == NULL) { + return; + } + esp_netif_t *esp_netif = lwip_get_esp_netif(netif); + if (esp_netif == NULL || !esp_netif_is_netif_listed(esp_netif)) { + return; + } + if (!ip_addr_isany(dnsserver)) { + ip_addr_copy(esp_netif->dns[numdns], *dnsserver); + } else { + ip_addr_copy(esp_netif->dns[numdns], *IP_ADDR_ANY); + } +} +#endif + static void tcpip_init_done(void *arg) { sys_sem_t *init_sem = arg; @@ -545,6 +560,12 @@ esp_err_t esp_netif_init(void) sys_sem_wait(&init_sem); sys_sem_free(&init_sem); ESP_LOGD(TAG, "LwIP stack has been initialized"); +#if CONFIG_ESP_NETIF_SET_DNS_PER_DEFAULT_NETIF + if (dns_setserver_callback(store_dnsserver_info) != ERR_OK) { + ESP_LOGE(TAG, "Feiled to configure DNS set server callback"); + return ESP_FAIL; + } +#endif } #if !LWIP_TCPIP_CORE_LOCKING @@ -1071,11 +1092,7 @@ static esp_err_t esp_netif_start_api(esp_netif_api_msg_t *msg) ESP_LOGD(TAG, "%s %p", __func__, esp_netif); if (ESP_NETIF_IS_POINT2POINT_TYPE(esp_netif, PPP_LWIP_NETIF)) { #if CONFIG_PPP_SUPPORT - esp_err_t ret = esp_netif_start_ppp(esp_netif); - if (ret == ESP_OK) { - esp_netif_update_default_netif(esp_netif, ESP_NETIF_STARTED); - } - return ret; + return esp_netif_start_ppp(esp_netif); #endif } @@ -1152,8 +1169,10 @@ static esp_err_t esp_netif_start_api(esp_netif_api_msg_t *msg) LOG_NETIF_DISABLED_AND_DO("IPv4's DHCP Client", return ESP_ERR_NOT_SUPPORTED); #endif } - - esp_netif_update_default_netif(esp_netif, ESP_NETIF_STARTED); + // For netifs with (active) DHCP client: we update the default netif after getting a valid IP + if (!((esp_netif->flags & ESP_NETIF_DHCP_CLIENT) && esp_netif->dhcpc_status != ESP_NETIF_DHCP_STOPPED)) { + esp_netif_update_default_netif(esp_netif, ESP_NETIF_STARTED); + } return ESP_OK; } @@ -1302,7 +1321,7 @@ static void esp_netif_internal_dhcpc_cb(struct netif *netif) if (memcmp(ip_info, ip_info_old, sizeof(esp_netif_ip_info_t))) { evt.ip_changed = true; } - + esp_netif_update_default_netif(esp_netif, ESP_NETIF_GOT_IP); memcpy(&evt.ip_info, ip_info, sizeof(esp_netif_ip_info_t)); memcpy(ip_info_old, ip_info, sizeof(esp_netif_ip_info_t)); ESP_LOGD(TAG, "if%p ip changed=%d", esp_netif, evt.ip_changed); @@ -1343,7 +1362,7 @@ static void esp_netif_ip_lost_timer(void *arg) .esp_netif = esp_netif, }; int ret; - + esp_netif_update_default_netif(esp_netif, ESP_NETIF_LOST_IP); ESP_LOGD(TAG, "if%p ip lost tmr: raise ip lost event", esp_netif); memset(esp_netif->ip_info_old, 0, sizeof(esp_netif_ip_info_t)); if (esp_netif->lost_ip_event) { @@ -1662,7 +1681,10 @@ static esp_err_t esp_netif_up_api(esp_netif_api_msg_t *msg) netif_set_up(lwip_netif); netif_set_link_up(lwip_netif); - esp_netif_update_default_netif(esp_netif, ESP_NETIF_STARTED); + // For netifs with (active) DHCP client: we update the default netif after getting a valid IP + if (!((esp_netif->flags & ESP_NETIF_DHCP_CLIENT) && esp_netif->dhcpc_status != ESP_NETIF_DHCP_STOPPED)) { + esp_netif_update_default_netif(esp_netif, ESP_NETIF_STARTED); + } return ESP_OK; } @@ -1841,7 +1863,7 @@ static esp_err_t esp_netif_set_ip_info_api(esp_netif_api_msg_t *msg) if (memcmp(ip_info, esp_netif->ip_info_old, sizeof(esp_netif_ip_info_t))) { evt.ip_changed = true; } - + esp_netif_update_default_netif(esp_netif, ESP_NETIF_GOT_IP); memcpy(&evt.ip_info, ip_info, sizeof(esp_netif_ip_info_t)); memcpy(esp_netif->ip_info_old, ip_info, sizeof(esp_netif_ip_info_t)); ret = esp_event_post(IP_EVENT, evt_id, &evt, sizeof(evt), 0); @@ -1902,7 +1924,7 @@ static esp_err_t esp_netif_set_dns_info_api(esp_netif_api_msg_t *msg) ip_addr_t lwip_ip = {}; ESPIP_TO_IP(&dns->ip, &lwip_ip); - if (esp_netif->flags & ESP_NETIF_DHCP_SERVER) { + if (esp_netif && esp_netif->flags & ESP_NETIF_DHCP_SERVER) { #if ESP_DHCPS // if DHCP server configured to set DNS in dhcps API if (type != ESP_NETIF_DNS_MAIN) { @@ -1915,7 +1937,17 @@ static esp_err_t esp_netif_set_dns_info_api(esp_netif_api_msg_t *msg) LOG_NETIF_DISABLED_AND_DO("DHCP Server", return ESP_ERR_NOT_SUPPORTED); #endif } else { +#ifdef CONFIG_ESP_NETIF_SET_DNS_PER_DEFAULT_NETIF + if (esp_netif) { + store_dnsserver_info(esp_netif->lwip_netif, type, &lwip_ip); + } + if (esp_netif == s_last_default_esp_netif || // if this is the default one -> need to update global DNS servers + esp_netif == NULL) { // if the netif ptr is set to NULL -> we explicitly require the update + dns_setserver(type, &lwip_ip); + } +#else dns_setserver(type, &lwip_ip); +#endif } return ESP_OK; @@ -1923,9 +1955,11 @@ static esp_err_t esp_netif_set_dns_info_api(esp_netif_api_msg_t *msg) esp_err_t esp_netif_set_dns_info(esp_netif_t *esp_netif, esp_netif_dns_type_t type, esp_netif_dns_info_t *dns) { +#ifndef CONFIG_ESP_NETIF_SET_DNS_PER_DEFAULT_NETIF if (esp_netif == NULL) { return ESP_ERR_ESP_NETIF_INVALID_PARAMS; } +#endif if (dns == NULL) { ESP_LOGD(TAG, "set dns null dns"); @@ -1953,7 +1987,7 @@ static esp_err_t esp_netif_get_dns_info_api(esp_netif_api_msg_t *msg) ESP_LOGD(TAG, "esp_netif_get_dns_info: esp_netif=%p type=%d", esp_netif, type); - if (esp_netif->flags & ESP_NETIF_DHCP_SERVER) { + if (esp_netif && esp_netif->flags & ESP_NETIF_DHCP_SERVER) { #if ESP_DHCPS ip4_addr_t dns_ip; dhcps_dns_getserver(esp_netif->dhcps, &dns_ip); @@ -1964,7 +1998,15 @@ static esp_err_t esp_netif_get_dns_info_api(esp_netif_api_msg_t *msg) #endif } else { const ip_addr_t* dns_ip = NULL; +#ifdef CONFIG_ESP_NETIF_SET_DNS_PER_DEFAULT_NETIF + if (esp_netif == NULL) { // by setting esp_netif to NULL we require the global DNS server entry + dns_ip = dns_getserver(type); + } else { + dns_ip = &esp_netif->dns[type]; + } +#else dns_ip = dns_getserver(type); +#endif if(dns_ip != NULL) { IP_TO_ESPIP(dns_ip, &dns->ip); } @@ -1975,9 +2017,11 @@ static esp_err_t esp_netif_get_dns_info_api(esp_netif_api_msg_t *msg) esp_err_t esp_netif_get_dns_info(esp_netif_t *esp_netif, esp_netif_dns_type_t type, esp_netif_dns_info_t *dns) { +#ifndef CONFIG_ESP_NETIF_SET_DNS_PER_DEFAULT_NETIF if (esp_netif == NULL) { return ESP_ERR_ESP_NETIF_INVALID_PARAMS; } +#endif if (dns == NULL) { ESP_LOGE(TAG, "%s: dns_info cannot be NULL", __func__); @@ -2073,7 +2117,7 @@ static void esp_netif_internal_nd6_cb(struct netif *netif, uint8_t ip_index) ESP_LOGW(TAG,"CONFIG_LWIP_ESP_MLDV6_REPORT not enabled, but esp-netif configured with ESP_NETIF_FLAG_MLDV6_REPORT"); #endif } - + esp_netif_update_default_netif(esp_netif, ESP_NETIF_GOT_IP); memcpy(&evt.ip6_info, &ip6_info, sizeof(esp_netif_ip6_info_t)); int ret = esp_event_post(IP_EVENT, IP_EVENT_GOT_IP6, &evt, sizeof(evt), 0); if (ESP_OK != ret) { @@ -2612,7 +2656,7 @@ static esp_err_t esp_netif_add_ip6_address_api(esp_netif_api_msg_t *msg) err_t err = netif_add_ip6_address(msg->esp_netif->lwip_netif, &ip6addr, &index); ESP_RETURN_ON_FALSE(err == ERR_OK && index >= 0, ESP_ERR_ESP_NETIF_IP6_ADDR_FAILED, TAG, "Failed to add ip6 address"); - + esp_netif_update_default_netif(msg->esp_netif, ESP_NETIF_GOT_IP); netif_ip6_addr_set_state(msg->esp_netif->lwip_netif, index, addr->preferred ? IP6_ADDR_PREFERRED : IP6_ADDR_DEPRECATED); ip_event_got_ip6_t evt = {.esp_netif = msg->esp_netif, .ip_index = index}; diff --git a/components/esp_netif/lwip/esp_netif_lwip_internal.h b/components/esp_netif/lwip/esp_netif_lwip_internal.h index 842fc81735..4d5130379f 100644 --- a/components/esp_netif/lwip/esp_netif_lwip_internal.h +++ b/components/esp_netif/lwip/esp_netif_lwip_internal.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -114,4 +114,19 @@ struct esp_netif_obj { #endif // CONFIG_ESP_NETIF_BRIDGE_EN // mldv6 timer bool mldv6_report_timer_started; + +#ifdef CONFIG_ESP_NETIF_SET_DNS_PER_DEFAULT_NETIF + ip_addr_t dns[DNS_MAX_SERVERS]; +#endif }; + +typedef enum esp_netif_set_default_state { + ESP_NETIF_UNDEF, + ESP_NETIF_STARTED, + ESP_NETIF_GOT_IP, + ESP_NETIF_STOPPED, + ESP_NETIF_LOST_IP, + ESP_NETIF_SET_DEFAULT, +} esp_netif_route_prio_action_t; + +esp_err_t esp_netif_update_default_netif(esp_netif_t *esp_netif, esp_netif_route_prio_action_t action); diff --git a/components/esp_netif/lwip/esp_netif_lwip_ppp.c b/components/esp_netif/lwip/esp_netif_lwip_ppp.c index 7e4a61a17f..03a11bafe3 100644 --- a/components/esp_netif/lwip/esp_netif_lwip_ppp.c +++ b/components/esp_netif/lwip/esp_netif_lwip_ppp.c @@ -75,6 +75,7 @@ static void on_ppp_status_changed(ppp_pcb *pcb, int err_code, void *ctx) break; case PPPERR_CONNECT: /* Connection lost */ ESP_LOGI(TAG, "Connection lost"); + esp_netif_update_default_netif(netif, ESP_NETIF_LOST_IP); err = esp_event_post(IP_EVENT, netif->lost_ip_event, &evt, sizeof(evt), 0); if (ESP_OK != err) { diff --git a/components/lwip/Kconfig b/components/lwip/Kconfig index 5d80561043..c3588ef1f4 100644 --- a/components/lwip/Kconfig +++ b/components/lwip/Kconfig @@ -1130,6 +1130,15 @@ menu "LWIP" help This option allows you to config dns fallback server address. + config LWIP_DNS_SETSERVER_WITH_NETIF + bool "Enable DNS server settings with netif" + default n + help + This option allows collecting DNS server settings per netif using + configurable callback function. + It's typically used with CONFIG_ESP_NETIF_SET_DNS_PER_DEFAULT_NETIF + which configures a callback to collect the DNS info on esp_netif layer. + endmenu # DNS config LWIP_BRIDGEIF_MAX_PORTS diff --git a/components/lwip/lwip b/components/lwip/lwip index f174681317..3a3d1fb3e3 160000 --- a/components/lwip/lwip +++ b/components/lwip/lwip @@ -1 +1 @@ -Subproject commit f174681317a00d209e374c66d9691ef79b4195de +Subproject commit 3a3d1fb3e3bc23cf86cf653ce5928eda47e2c15d diff --git a/components/lwip/port/include/lwipopts.h b/components/lwip/port/include/lwipopts.h index e95d647029..1c93752d14 100644 --- a/components/lwip/port/include/lwipopts.h +++ b/components/lwip/port/include/lwipopts.h @@ -503,6 +503,17 @@ static inline uint32_t timeout_from_offered(uint32_t lease, uint32_t min) #define LWIP_DNS_SUPPORT_MDNS_QUERIES 0 #endif +/** + * LWIP_DNS_SETSERVER_WITH_NETIF: If this is turned on, the dns_setserver_with_netif() is enabled and called + * from all internal modules (instead of dns_setserver()) allowing to setup a user callback to collect DNS server + * information acquired by the related network interface. + */ +#ifdef CONFIG_LWIP_DNS_SETSERVER_WITH_NETIF +#define LWIP_DNS_SETSERVER_WITH_NETIF 1 +#else +#define LWIP_DNS_SETSERVER_WITH_NETIF 0 +#endif + /* --------------------------------- ---------- UDP options ---------- From d716e64138666f7f956ac2dea08b2712abfa19a0 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Wed, 19 Jun 2024 11:08:39 +0200 Subject: [PATCH 3/7] fix(esp_netif): Add unit test of getter/setter API for DNS servers --- components/esp_netif/include/esp_netif.h | 2 +- .../test_app_esp_netif/main/esp_netif_test.c | 76 +++++++++++++++++++ .../test_app_esp_netif/pytest_esp_netif.py | 7 +- .../sdkconfig.ci.dns_per_netif | 1 + .../sdkconfig.ci.global_dns | 1 + 5 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 components/esp_netif/test_apps/test_app_esp_netif/sdkconfig.ci.dns_per_netif create mode 100644 components/esp_netif/test_apps/test_app_esp_netif/sdkconfig.ci.global_dns diff --git a/components/esp_netif/include/esp_netif.h b/components/esp_netif/include/esp_netif.h index c63b084f29..5940a43e4f 100644 --- a/components/esp_netif/include/esp_netif.h +++ b/components/esp_netif/include/esp_netif.h @@ -718,7 +718,7 @@ esp_err_t esp_netif_dhcps_get_clients_by_mac(esp_netif_t *esp_netif, int num, es * Note that LWIP stores DNS server information globally, not per interface, so the first parameter is unused * in the default LWIP configuration. * If CONFIG_ESP_NETIF_SET_DNS_PER_DEFAULT_NETIF=1 this API sets internal DNS server information per - * netif. It's also possible set the global DNS server info by supplying esp_netif=NULL + * netif. It's also possible to set the global DNS server info by supplying esp_netif=NULL * * If DHCP server is enabled, the Main DNS Server setting is used by the DHCP server to provide a DNS Server option * to DHCP clients (Wi-Fi stations). diff --git a/components/esp_netif/test_apps/test_app_esp_netif/main/esp_netif_test.c b/components/esp_netif/test_apps/test_app_esp_netif/main/esp_netif_test.c index 84705bc784..080f565ec5 100644 --- a/components/esp_netif/test_apps/test_app_esp_netif/main/esp_netif_test.c +++ b/components/esp_netif/test_apps/test_app_esp_netif/main/esp_netif_test.c @@ -502,6 +502,81 @@ TEST(esp_netif, route_priority) } } +// to probe DNS server info directly in LWIP +const ip_addr_t * dns_getserver(u8_t numdns); + +TEST(esp_netif, set_get_dnsserver) +{ + // create a couple of netifs + test_case_uses_tcpip(); + const char *if_keys[] = {"if0", "if1", "if2", "if3", "if4", "if5", "if6", "if7", "if8", "if9"}; + const int nr_of_netifs = sizeof(if_keys) / sizeof(char *); + esp_netif_t *netifs[nr_of_netifs]; + esp_netif_driver_ifconfig_t driver_config = { .handle = (void*)1, .transmit = dummy_transmit }; + // create 10 netifs with different route prio + for (int i = 0; i < nr_of_netifs; ++i) { + esp_netif_inherent_config_t base_netif_config = { .if_key = if_keys[i], .route_prio = i }; + esp_netif_config_t cfg = { .base = &base_netif_config, + .stack = ESP_NETIF_NETSTACK_DEFAULT_WIFI_STA, + .driver = &driver_config }; + netifs[i] = esp_netif_new(&cfg); + TEST_ASSERT_NOT_NULL(netifs[i]); + // set the interface up and connected -- to enable the default netif based on route_prio + esp_netif_action_start(netifs[i], 0, 0, 0); + esp_netif_action_connected(netifs[i], 0, 0, 0); + } + + esp_netif_dns_info_t dns[2]; + esp_netif_dns_info_t get_dns; + TEST_ASSERT_EQUAL(ESP_OK, esp_netif_str_to_ip4("1.2.3.4", &dns[0].ip.u_addr.ip4)); + TEST_ASSERT_EQUAL(ESP_OK, esp_netif_str_to_ip4("5.6.7.8", &dns[1].ip.u_addr.ip4)); + + // set DNS info to one netif + TEST_ASSERT_EQUAL(ESP_OK, esp_netif_set_dns_info(netifs[3], ESP_NETIF_DNS_MAIN, &dns[0])); + TEST_ASSERT_EQUAL(ESP_OK, esp_netif_set_dns_info(netifs[3], ESP_NETIF_DNS_BACKUP, &dns[1])); +#ifndef CONFIG_ESP_NETIF_SET_DNS_PER_DEFAULT_NETIF + // check that calling setters/getters with 'esp_netif==NULL' is invalid + TEST_ASSERT_NOT_EQUAL(ESP_OK, esp_netif_set_dns_info(NULL, ESP_NETIF_DNS_BACKUP, &dns[1])); + TEST_ASSERT_NOT_EQUAL(ESP_OK, esp_netif_get_dns_info(NULL, ESP_NETIF_DNS_BACKUP, &get_dns)); + + // check that the global DNS is configured the same way + const ip_addr_t *ip = dns_getserver(0); + TEST_ASSERT_EQUAL(ip->u_addr.ip4.addr, dns[0].ip.u_addr.ip4.addr); + ip = dns_getserver(1); + TEST_ASSERT_EQUAL(ip->u_addr.ip4.addr, dns[1].ip.u_addr.ip4.addr); + + // check that we get the same DNS information for all netifs + for (int i=0; i < nr_of_netifs; ++i) { + TEST_ASSERT_EQUAL(ESP_OK, esp_netif_get_dns_info(netifs[i], ESP_NETIF_DNS_MAIN, &get_dns)); + TEST_ASSERT_EQUAL(get_dns.ip.u_addr.ip4.addr, dns[0].ip.u_addr.ip4.addr); + TEST_ASSERT_EQUAL(ESP_OK, esp_netif_get_dns_info(netifs[i], ESP_NETIF_DNS_BACKUP, &get_dns)); + TEST_ASSERT_EQUAL(get_dns.ip.u_addr.ip4.addr, dns[1].ip.u_addr.ip4.addr); + } +#else + // check that calling setters/getters with 'esp_netif==NULL' is valid, they set/get global DNS servers + TEST_ASSERT_EQUAL(ESP_OK, esp_netif_set_dns_info(NULL, ESP_NETIF_DNS_MAIN, &dns[0])); + TEST_ASSERT_EQUAL(ESP_OK, esp_netif_get_dns_info(NULL, ESP_NETIF_DNS_BACKUP, &get_dns)); + const ip_addr_t *ip = dns_getserver(0); + TEST_ASSERT_EQUAL(ip->u_addr.ip4.addr, dns[0].ip.u_addr.ip4.addr); + ip = dns_getserver(1); + TEST_ASSERT_EQUAL(ip->u_addr.ip4.addr, get_dns.ip.u_addr.ip4.addr); // same as what we got at the esp-netif layer + TEST_ASSERT_NOT_EQUAL(ip->u_addr.ip4.addr, dns[1].ip.u_addr.ip4.addr); // but different from what we set earlier per netif + + // now we set the netif[3] as default one and check again + esp_netif_set_default_netif(netifs[3]); + ip = dns_getserver(1); + TEST_ASSERT_EQUAL(ip->u_addr.ip4.addr, dns[1].ip.u_addr.ip4.addr); // now the ESP_NETIF_DNS_BACKUP[3[ should be set globally + + // check that we get a different DNS server with another netif + TEST_ASSERT_EQUAL(ESP_OK, esp_netif_get_dns_info(netifs[5], ESP_NETIF_DNS_MAIN, &get_dns)); + TEST_ASSERT_NOT_EQUAL(dns[0].ip.u_addr.ip4.addr, get_dns.ip.u_addr.ip4.addr); +#endif + + for (int i=0; i < nr_of_netifs; ++i) { + esp_netif_destroy(netifs[i]); + TEST_ASSERT_FALSE(esp_netif_is_netif_listed(netifs[i])); + } +} TEST_GROUP_RUNNER(esp_netif) { @@ -531,6 +606,7 @@ TEST_GROUP_RUNNER(esp_netif) RUN_TEST_CASE(esp_netif, dhcp_server_state_transitions_mesh) #endif RUN_TEST_CASE(esp_netif, route_priority) + RUN_TEST_CASE(esp_netif, set_get_dnsserver) } void app_main(void) diff --git a/components/esp_netif/test_apps/test_app_esp_netif/pytest_esp_netif.py b/components/esp_netif/test_apps/test_app_esp_netif/pytest_esp_netif.py index 841d825360..43c0125637 100644 --- a/components/esp_netif/test_apps/test_app_esp_netif/pytest_esp_netif.py +++ b/components/esp_netif/test_apps/test_app_esp_netif/pytest_esp_netif.py @@ -1,6 +1,5 @@ -# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD +# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: CC0-1.0 - import pytest from pytest_embedded import Dut @@ -8,5 +7,9 @@ from pytest_embedded import Dut @pytest.mark.esp32s2 @pytest.mark.esp32c3 @pytest.mark.generic +@pytest.mark.parametrize('config', [ + 'global_dns', + 'dns_per_netif', +], indirect=True) def test_esp_netif(dut: Dut) -> None: dut.expect_unity_test_output() diff --git a/components/esp_netif/test_apps/test_app_esp_netif/sdkconfig.ci.dns_per_netif b/components/esp_netif/test_apps/test_app_esp_netif/sdkconfig.ci.dns_per_netif new file mode 100644 index 0000000000..3abbf3a3bc --- /dev/null +++ b/components/esp_netif/test_apps/test_app_esp_netif/sdkconfig.ci.dns_per_netif @@ -0,0 +1 @@ +CONFIG_ESP_NETIF_SET_DNS_PER_DEFAULT_NETIF=y diff --git a/components/esp_netif/test_apps/test_app_esp_netif/sdkconfig.ci.global_dns b/components/esp_netif/test_apps/test_app_esp_netif/sdkconfig.ci.global_dns new file mode 100644 index 0000000000..ba627cbf81 --- /dev/null +++ b/components/esp_netif/test_apps/test_app_esp_netif/sdkconfig.ci.global_dns @@ -0,0 +1 @@ +CONFIG_ESP_NETIF_SET_DNS_PER_DEFAULT_NETIF=n From 1237b8c66949bc9ce8a64b93d7550de1d0d1decb Mon Sep 17 00:00:00 2001 From: David Cermak Date: Fri, 24 May 2024 11:53:25 +0200 Subject: [PATCH 4/7] feat(lwip): Add support for PPP Auth using mbedTLS (v5.3) LWIP submodule update (v5.3): git log --oneline 3a3d1fb3..e8d05138 - PPP/Auth: Add mbedtls includes if lwip uses it (espressif/esp-lwip@e8d05138) Closes https://github.com/espressif/esp-idf/issues/13597 --- components/lwip/CMakeLists.txt | 20 ++++++++++++++------ components/lwip/Kconfig | 11 +++++++++++ components/lwip/lwip | 2 +- components/lwip/port/include/lwipopts.h | 9 +++++++++ 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/components/lwip/CMakeLists.txt b/components/lwip/CMakeLists.txt index 4485886153..3f7d520de8 100644 --- a/components/lwip/CMakeLists.txt +++ b/components/lwip/CMakeLists.txt @@ -132,12 +132,7 @@ if(CONFIG_LWIP_ENABLE) "lwip/src/netif/ppp/pppos.c" "lwip/src/netif/ppp/upap.c" "lwip/src/netif/ppp/utils.c" - "lwip/src/netif/ppp/vj.c" - "lwip/src/netif/ppp/polarssl/arc4.c" - "lwip/src/netif/ppp/polarssl/des.c" - "lwip/src/netif/ppp/polarssl/md4.c" - "lwip/src/netif/ppp/polarssl/md5.c" - "lwip/src/netif/ppp/polarssl/sha1.c") + "lwip/src/netif/ppp/vj.c") endif() if(NOT ${target} STREQUAL "linux") @@ -160,6 +155,15 @@ if(CONFIG_LWIP_ENABLE) "apps/ping/ping_sock.c") endif() + if(NOT CONFIG_LWIP_USE_EXTERNAL_MBEDTLS) + list(APPEND srcs + "lwip/src/netif/ppp/polarssl/arc4.c" + "lwip/src/netif/ppp/polarssl/des.c" + "lwip/src/netif/ppp/polarssl/md4.c" + "lwip/src/netif/ppp/polarssl/md5.c" + "lwip/src/netif/ppp/polarssl/sha1.c") + endif() + if(CONFIG_LWIP_DHCPS) list(APPEND srcs "apps/dhcpserver/dhcpserver.c") endif() @@ -215,6 +219,10 @@ if(CONFIG_LWIP_ENABLE) idf_component_optional_requires(PRIVATE nvs_flash) endif() + if(CONFIG_LWIP_USE_EXTERNAL_MBEDTLS) + idf_component_optional_requires(PRIVATE mbedtls) + endif() + if(${target} STREQUAL "linux") set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) diff --git a/components/lwip/Kconfig b/components/lwip/Kconfig index c3588ef1f4..5f2bb733e8 100644 --- a/components/lwip/Kconfig +++ b/components/lwip/Kconfig @@ -992,6 +992,17 @@ menu "LWIP" help Enable PPP debug log output + config LWIP_USE_EXTERNAL_MBEDTLS + bool "Use mbedTLS instead of internal polarSSL" + depends on LWIP_PPP_SUPPORT + depends on !LWIP_PPP_MPPE_SUPPORT && !LWIP_PPP_MSCHAP_SUPPORT + default n + help + This option uses mbedTLS crypto functions (instead of internal PolarSSL + implementation) for PPP authentication modes (PAP, CHAP, etc.). + You can use this option to address symbol duplication issues, since + the internal functions are not namespaced (e.g. md5_init()). + menuconfig LWIP_SLIP_SUPPORT bool "Enable SLIP support (new/experimental)" default n diff --git a/components/lwip/lwip b/components/lwip/lwip index 3a3d1fb3e3..e8d0513898 160000 --- a/components/lwip/lwip +++ b/components/lwip/lwip @@ -1 +1 @@ -Subproject commit 3a3d1fb3e3bc23cf86cf653ce5928eda47e2c15d +Subproject commit e8d0513898ce96d7851b41bc6acb7af3259a447b diff --git a/components/lwip/port/include/lwipopts.h b/components/lwip/port/include/lwipopts.h index 1c93752d14..db4ef60bcf 100644 --- a/components/lwip/port/include/lwipopts.h +++ b/components/lwip/port/include/lwipopts.h @@ -1151,6 +1151,15 @@ static inline uint32_t timeout_from_offered(uint32_t lease, uint32_t min) #define PPP_SUPPORT 0 #endif /* CONFIG_LWIP_PPP_SUPPORT */ +/** + * LWIP_USE_EXTERNAL_MBEDTLS: Use external mbed TLS library for crypto implementation used in PPP AUTH + */ +#ifdef CONFIG_LWIP_USE_EXTERNAL_MBEDTLS +#define LWIP_USE_EXTERNAL_MBEDTLS 1 +#else +#define LWIP_USE_EXTERNAL_MBEDTLS 0 +#endif + /* -------------------------------------- ---------- Checksum options ---------- From fec0c43edd18b10064f75fdc4504a7ab3aca12b6 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Fri, 24 May 2024 14:37:57 +0200 Subject: [PATCH 5/7] fix(esp_netif): Remove unused leftover pppapi_set_auth() call --- components/esp_netif/lwip/esp_netif_lwip.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/components/esp_netif/lwip/esp_netif_lwip.c b/components/esp_netif/lwip/esp_netif_lwip.c index 75cf37972d..cedd7807c9 100644 --- a/components/esp_netif/lwip/esp_netif_lwip.c +++ b/components/esp_netif/lwip/esp_netif_lwip.c @@ -2559,15 +2559,6 @@ esp_err_t esp_netif_ppp_set_auth(esp_netif_t *esp_netif, esp_netif_auth_type_t a { set_auth_msg_t msg = { .authtype = authtype, .user = user, .passwd = passwd }; return esp_netif_lwip_ipc_call(esp_netif_ppp_set_auth_api, esp_netif, &msg); -#if PPP_AUTH_SUPPORT - lwip_peer2peer_ctx_t *ppp_ctx = (lwip_peer2peer_ctx_t *)netif->related_data; - assert(ppp_ctx->base.netif_type == PPP_LWIP_NETIF); - pppapi_set_auth(ppp_ctx->ppp, authtype, user, passwd); - return ESP_OK; -#else - ESP_LOGE(TAG, "%s failed: No authorisation enabled in menuconfig", __func__); - return ESP_ERR_ESP_NETIF_IF_NOT_READY; -#endif } esp_err_t esp_netif_napt_disable(esp_netif_t *esp_netif) From a84d13600214d8640b720a37e5fd826b86094879 Mon Sep 17 00:00:00 2001 From: Abhik Roy Date: Thu, 18 Jul 2024 23:24:33 +1000 Subject: [PATCH 6/7] fix(lwip): Fixed incorrect handling of 0.0.0.0 in dns (v5.3) LWIP submodule update: git log --oneline e8d05138..bced058f - dns: Fixed incorrect handling of 0.0.0.0 (espressif/esp-lwip@bced058f) --- components/lwip/lwip | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/lwip/lwip b/components/lwip/lwip index e8d0513898..bced058f73 160000 --- a/components/lwip/lwip +++ b/components/lwip/lwip @@ -1 +1 @@ -Subproject commit e8d0513898ce96d7851b41bc6acb7af3259a447b +Subproject commit bced058f737eaabea1aa193f3c365ee78ff555f3 From d6450302108a66059d9b9d5042564900a2a412b3 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Fri, 23 Aug 2024 12:57:52 +0200 Subject: [PATCH 7/7] fix(esp_netif): Correct spelling erros --- components/esp_netif/Kconfig | 2 +- components/esp_netif/include/esp_netif.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/esp_netif/Kconfig b/components/esp_netif/Kconfig index 3d7568ed05..6d4681ce17 100644 --- a/components/esp_netif/Kconfig +++ b/components/esp_netif/Kconfig @@ -9,7 +9,7 @@ menu "ESP NETIF Adapter" The IP address may be lost because of some reasons, e.g. when the station disconnects from soft-AP, or when DHCP IP renew fails etc. If the IP lost timer is enabled, it will - be started everytime the IP is lost. Event SYSTEM_EVENT_STA_LOST_IP will be raised if + be started every time the IP is lost. Event SYSTEM_EVENT_STA_LOST_IP will be raised if the timer expires. The IP lost timer is stopped if the station get the IP again before the timer expires. diff --git a/components/esp_netif/include/esp_netif.h b/components/esp_netif/include/esp_netif.h index 5940a43e4f..e44c5ba168 100644 --- a/components/esp_netif/include/esp_netif.h +++ b/components/esp_netif/include/esp_netif.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -112,7 +112,7 @@ esp_err_t esp_netif_attach(esp_netif_t *esp_netif, esp_netif_iodriver_handle dri * to TCP/IP stack. Similarly esp_netif_transmit is called from the TCP/IP stack whenever * a packet ought to output to the communication media. * - * @note These IO functions are registerd (installed) automatically for default interfaces + * @note These IO functions are registered (installed) automatically for default interfaces * (interfaces with the keys such as WIFI_STA_DEF, WIFI_AP_DEF, ETH_DEF). Custom interface * has to register these IO functions when creating interface using @ref esp_netif_new * @@ -908,7 +908,7 @@ esp_err_t esp_netif_str_to_ip4(const char *src, esp_ip4_addr_t *dst); /** * @brief Converts Ascii internet IPv6 address into esp_ip4_addr_t - * Zeros in the IP address can be stripped or completely ommited: "2001:db8:85a3:0:0:0:2:1" or "2001:db8::2:1") + * Zeros in the IP address can be stripped or completely omitted: "2001:db8:85a3:0:0:0:2:1" or "2001:db8::2:1") * * @param[in] src IPv6 address in ascii representation (e.g. ""2001:0db8:85a3:0000:0000:0000:0002:0001") * @param[out] dst Address of the target esp_ip6_addr_t structure to receive converted address @@ -982,7 +982,7 @@ const char *esp_netif_get_desc(esp_netif_t *esp_netif); * * @param[in] esp_netif Handle to esp-netif instance * - * @return Integer representing the instance's route-prio, or -1 if invalid paramters + * @return Integer representing the instance's route-prio, or -1 if invalid parameters */ int esp_netif_get_route_prio(esp_netif_t *esp_netif);