Skip to content

Commit 86089be

Browse files
david-cermakDavid Čermák
authored andcommitted
feat(lwip): Hardcode NETIF_API=1 to support POSIX netif API
1 parent 7bb6c67 commit 86089be

File tree

4 files changed

+24
-22
lines changed

4 files changed

+24
-22
lines changed

components/lwip/CMakeLists.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,8 @@ if(CONFIG_LWIP_ENABLE)
100100
"port/hooks/lwip_default_hooks.c"
101101
"port/debug/lwip_debug.c"
102102
"port/sockets_ext.c"
103-
"port/freertos/sys_arch.c")
104-
105-
if(CONFIG_LWIP_NETIF_API)
106-
list(APPEND srcs "port/if_index.c")
107-
endif()
103+
"port/freertos/sys_arch.c"
104+
"port/if_index.c")
108105

109106
if(CONFIG_LWIP_PPP_SUPPORT)
110107
list(APPEND srcs

components/lwip/Kconfig

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,6 @@ menu "LWIP"
1818
The default name this device will report to other devices on the network.
1919
Could be updated at runtime with esp_netif_set_hostname()
2020

21-
config LWIP_NETIF_API
22-
bool "Enable usage of standard POSIX APIs in LWIP"
23-
default n
24-
help
25-
If this feature is enabled, standard POSIX APIs: if_indextoname(), if_nametoindex()
26-
could be used to convert network interface index to name
27-
instead of IDF specific esp-netif APIs (such as esp_netif_get_netif_impl_name())
28-
2921
config LWIP_TCPIP_TASK_PRIO
3022
int "LWIP TCP/IP Task Priority"
3123
default 18

components/lwip/port/include/lwipopts.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -709,18 +709,11 @@ static inline uint32_t timeout_from_offered(uint32_t lease, uint32_t min)
709709
* LWIP_DHCP_DISCOVER_ADD_HOSTNAME==1: include hostname opt in discover packets.
710710
* If the hostname is not set in the DISCOVER packet, then some servers might issue
711711
* an OFFER with hostname configured and consequently reject the REQUEST with any other hostname.
712+
* LWIP_NETIF_API==1: Support netif APIs (if_nametoindex and if_indextoname)
712713
*/
713714
#define LWIP_NETIF_HOSTNAME 1
714715
#define LWIP_DHCP_DISCOVER_ADD_HOSTNAME 1
715-
716-
/**
717-
* LWIP_NETIF_API==1: Support netif api (in netifapi.c)
718-
*/
719-
#ifdef CONFIG_LWIP_NETIF_API
720716
#define LWIP_NETIF_API 1
721-
#else
722-
#define LWIP_NETIF_API 0
723-
#endif
724717

725718
/**
726719
* LWIP_NETIF_STATUS_CALLBACK==1: Support a callback function whenever an interface
Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66
#pragma once
7+
8+
// Need to provide declarations of if_nametoindex and if_indextoname functions
9+
// as we don't want to bring lwip specific defines
10+
// (since we're on linux target and likely using linux tcp/ip stack)
11+
12+
/**
13+
* @brief Get the interface index for the given interface name.
14+
* @param ifname The interface name.
15+
* @return The interface index.
16+
*/
17+
unsigned int if_nametoindex(const char *ifname);
18+
19+
/**
20+
* @brief Get the interface name for the given interface index.
21+
*
22+
* @param ifindex The interface index.
23+
* @param ifname The buffer to store the interface name.
24+
* @return char* The interface name.
25+
*/
26+
char *if_indextoname(unsigned int ifindex, char *ifname);

0 commit comments

Comments
 (0)