lwip: added config option to enable LWIP_NETIF_API

This commit is contained in:
Jiri Schiebel
2021-02-01 08:47:42 +01:00
committed by bot
parent 8c4d9fa66e
commit 0c58d5fc6a
3 changed files with 19 additions and 0 deletions

View File

@@ -7,6 +7,15 @@ menu "LWIP"
The default name this device will report to other devices on the network. The default name this device will report to other devices on the network.
Could be updated at runtime with esp_netif_set_hostname() 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 config LWIP_DNS_SUPPORT_MDNS_QUERIES
bool "Enable mDNS queries in resolving host name" bool "Enable mDNS queries in resolving host name"
default y default y

View File

@@ -448,6 +448,11 @@
*/ */
#define LWIP_NETIF_TX_SINGLE_PBUF 1 #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 ---------- ---------- LOOPIF options ----------
@@ -949,6 +954,7 @@
#define ESP_IP4_ATON 1 #define ESP_IP4_ATON 1
#define ESP_LIGHT_SLEEP 1 #define ESP_LIGHT_SLEEP 1
#define ESP_L2_TO_L3_COPY CONFIG_LWIP_L2_TO_L3_COPY #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_MEM CONFIG_LWIP_STATS
#define ESP_STATS_DROP CONFIG_LWIP_STATS #define ESP_STATS_DROP CONFIG_LWIP_STATS
#define ESP_STATS_TCP 0 #define ESP_STATS_TCP 0

View File

@@ -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 #if CONFIG_EXAMPLE_BIND_SOCKET_TO_NETIF_NAME
struct ifreq ifr; struct ifreq ifr;
#if !CONFIG_LWIP_NETIF_API
esp_netif_get_netif_impl_name(esp_netif, ifr.ifr_name); 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)); int ret = setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, (void*)&ifr, sizeof(struct ifreq));
if (ret < 0) { if (ret < 0) {
ESP_LOGE(TAG, "\"%s\" Unable to bind socket to specified interface: errno %d", netif_name, errno); ESP_LOGE(TAG, "\"%s\" Unable to bind socket to specified interface: errno %d", netif_name, errno);