diff --git a/components/lwip/Kconfig b/components/lwip/Kconfig index 39cb3e25ee..d3c0f64b1d 100644 --- a/components/lwip/Kconfig +++ b/components/lwip/Kconfig @@ -7,6 +7,15 @@ menu "LWIP" The default name this device will report to other devices on the network. Could be updated at runtime with esp_netif_set_hostname() + config LWIP_NETIF_API + bool "Enable usage of standard POSIX APIs in LWIP" + default n + help + If this feature is enabled, standard POSIX APIs: if_indextoname(), if_nametoindex() + could be used to convert network interface index to name + instead of IDF specific esp-netif APIs (such as esp_netif_get_netif_impl_name()) + + config LWIP_DNS_SUPPORT_MDNS_QUERIES bool "Enable mDNS queries in resolving host name" default y diff --git a/components/lwip/port/esp32/include/lwipopts.h b/components/lwip/port/esp32/include/lwipopts.h index d3ceca640c..d8a20ce72f 100644 --- a/components/lwip/port/esp32/include/lwipopts.h +++ b/components/lwip/port/esp32/include/lwipopts.h @@ -448,6 +448,11 @@ */ #define LWIP_NETIF_TX_SINGLE_PBUF 1 +/** + * LWIP_NETIF_API==1: Enable usage of standard POSIX APIs in LWIP. + */ +#define LWIP_NETIF_API CONFIG_LWIP_NETIF_API + /* ------------------------------------ ---------- LOOPIF options ---------- @@ -949,6 +954,7 @@ #define ESP_IP4_ATON 1 #define ESP_LIGHT_SLEEP 1 #define ESP_L2_TO_L3_COPY CONFIG_LWIP_L2_TO_L3_COPY +#define LWIP_NETIF_API CONFIG_LWIP_NETIF_API #define ESP_STATS_MEM CONFIG_LWIP_STATS #define ESP_STATS_DROP CONFIG_LWIP_STATS #define ESP_STATS_TCP 0 diff --git a/examples/protocols/sockets/tcp_client_multi_net/main/tcp_client_multiple.c b/examples/protocols/sockets/tcp_client_multi_net/main/tcp_client_multiple.c index 57547fd526..d537adf1bd 100644 --- a/examples/protocols/sockets/tcp_client_multi_net/main/tcp_client_multiple.c +++ b/examples/protocols/sockets/tcp_client_multi_net/main/tcp_client_multiple.c @@ -47,7 +47,11 @@ static void app_multiple_handle(esp_ip4_addr_t *ip4_addr, esp_netif_t *esp_netif */ #if CONFIG_EXAMPLE_BIND_SOCKET_TO_NETIF_NAME struct ifreq ifr; +#if !CONFIG_LWIP_NETIF_API esp_netif_get_netif_impl_name(esp_netif, ifr.ifr_name); +#else + if_indextoname(esp_netif_get_netif_impl_index(esp_netif), ifr.ifr_name); +#endif int ret = setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, (void*)&ifr, sizeof(struct ifreq)); if (ret < 0) { ESP_LOGE(TAG, "\"%s\" Unable to bind socket to specified interface: errno %d", netif_name, errno);