esp-netif: Fix non-lwip build using esp_netif loopback

This partially backports 8142a6f9fc633c5f3ef461af41528eb5a6794755.
allowing esp_netif build with loopback only

Closes https://github.com/espressif/esp-idf/issues/10587
This commit is contained in:
David Cermak 2022-09-26 13:22:20 +02:00 committed by David Čermák
parent f944418ca4
commit a3ca732e5d
3 changed files with 35 additions and 26 deletions

View File

@ -6,37 +6,40 @@ if(${target} STREQUAL "linux")
return()
endif()
set(srcs_lwip
"lwip/esp_netif_lwip.c"
"lwip/esp_netif_lwip_defaults.c"
"lwip/netif/wlanif.c"
"lwip/netif/ethernetif.c"
"lwip/netif/esp_pbuf_ref.c")
set(srcs
"esp_netif_handlers.c"
"esp_netif_objects.c"
"esp_netif_defaults.c"
"lwip/esp_netif_lwip.c"
"lwip/esp_netif_lwip_defaults.c"
"lwip/netif/wlanif.c"
"lwip/netif/ethernetif.c"
"lwip/netif/esp_pbuf_ref.c" )
"esp_netif_defaults.c")
set(include_dirs "include")
set(priv_include_dirs "lwip" "private_include")
set(priv_include_dirs "private_include")
if(CONFIG_PPP_SUPPORT)
list(APPEND srcs
"lwip/esp_netif_lwip_ppp.c")
list(APPEND srcs_lwip lwip/esp_netif_lwip_ppp.c)
endif()
if(CONFIG_LWIP_NETIF_LOOPBACK)
list(APPEND srcs
"loopback/esp_netif_loopback.c")
endif()
if(CONFIG_ESP_NETIF_L2_TAP)
list(APPEND srcs
"vfs_l2tap/esp_vfs_l2tap.c")
list(APPEND srcs vfs_l2tap/esp_vfs_l2tap.c)
endif()
if(CONFIG_ESP_NETIF_BRIDGE_EN)
list(APPEND srcs
"lwip/esp_netif_br_glue.c")
list(APPEND srcs_lwip lwip/esp_netif_br_glue.c)
endif()
if(CONFIG_ESP_NETIF_LOOPBACK)
list(APPEND srcs loopback/esp_netif_loopback.c)
elseif(CONFIG_ESP_NETIF_TCPIP_LWIP)
list(APPEND srcs ${srcs_lwip})
list(APPEND priv_include_dirs lwip)
endif()
idf_component_register(SRCS "${srcs}"
@ -50,5 +53,6 @@ if(CONFIG_ESP_NETIF_L2_TAP OR CONFIG_ESP_NETIF_BRIDGE_EN)
idf_component_optional_requires(PRIVATE esp_eth vfs)
endif()
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
target_compile_definitions(${COMPONENT_LIB} PRIVATE ESP_NETIF_COMPONENT_BUILD)

View File

@ -32,6 +32,11 @@ static bool s_netif_up = false;
*
*
*/
#ifndef NETIF_MAX_HWADDR_LEN
#define NETIF_MAX_HWADDR_LEN 6U
#endif
struct esp_netif_obj {
// default interface addresses
uint8_t mac[NETIF_MAX_HWADDR_LEN];
@ -112,9 +117,9 @@ static esp_err_t esp_netif_init_configuration(esp_netif_t *esp_netif, const esp_
// Configure general esp-netif properties
memcpy(esp_netif->mac, cfg->base->mac, NETIF_MAX_HWADDR_LEN);
if (cfg->base->ip_info == NULL) {
ip4_addr_set_zero(&esp_netif->ip_info->ip);
ip4_addr_set_zero(&esp_netif->ip_info->gw);
ip4_addr_set_zero(&esp_netif->ip_info->netmask);
esp_netif->ip_info->ip.addr = 0;
esp_netif->ip_info->gw.addr = 0;
esp_netif->ip_info->netmask.addr = 0;
} else {
memcpy(esp_netif->ip_info, cfg->base->ip_info, sizeof(esp_netif_ip_info_t));
}
@ -450,7 +455,7 @@ esp_err_t esp_netif_leave_ip6_multicast_group(esp_netif_t *esp_netif, const esp_
return ESP_ERR_NOT_SUPPORTED;
}
esp_err_t esp_netif_add_ip6_address(esp_netif_t *esp_netif, const esp_ip6_addr_t *addr, uint8_t preference)
esp_err_t esp_netif_add_ip6_address(esp_netif_t *esp_netif, const ip_event_add_ip6_t *addr)
{
return ESP_ERR_NOT_SUPPORTED;
}

View File

@ -7,9 +7,9 @@
#include "esp_netif.h"
#include "esp_netif_lwip_internal.h"
#include "lwip/esp_netif_net_stack.h"
#if defined(CONFIG_PPP_SUPPORT)
#include "esp_netif_lwip_ppp.h"
#if defined(CONFIG_ESP_NETIF_TCPIP_LWIP)
#endif
#if CONFIG_ESP_NETIF_BRIDGE_EN
#include "netif/bridgeif.h"
@ -48,6 +48,7 @@ static const struct esp_netif_netstack_config s_wifi_netif_config_sta = {
}
};
#if defined(CONFIG_PPP_SUPPORT)
static const struct esp_netif_netstack_config s_netif_config_ppp = {
.lwip_ppp = {
.input_fn = esp_netif_lwip_ppp_input,
@ -57,10 +58,9 @@ static const struct esp_netif_netstack_config s_netif_config_ppp = {
}
}
};
const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_ppp = &s_netif_config_ppp;
#endif // CONFIG_PPP_SUPPORT
const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_eth = &s_eth_netif_config;
const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_wifi_sta = &s_wifi_netif_config_sta;
const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_wifi_ap = &s_wifi_netif_config_ap;
const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_ppp = &s_netif_config_ppp;
#endif /*CONFIG_ESP_NETIF_TCPIP_LWIP*/