diff --git a/components/esp_eth/include/esp_eth.h b/components/esp_eth/include/esp_eth.h new file mode 100644 index 0000000000..d37353550b --- /dev/null +++ b/components/esp_eth/include/esp_eth.h @@ -0,0 +1,16 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#pragma once + +/** + * Purpose of this file is to create a common header for the typical ethernet usecase, + * so using the ethernet driver and the default glue layer to its network interface. + * + * If you prefer to create a custom network interface or use the Ethernet as a driver only, + * then it is recommended to include the "esp_eth_driver.h" only. + */ +#include "esp_eth_driver.h" +#include "esp_eth_netif_glue.h" diff --git a/components/esp_netif/CMakeLists.txt b/components/esp_netif/CMakeLists.txt index 44c9ef8e0d..c18bd3552b 100644 --- a/components/esp_netif/CMakeLists.txt +++ b/components/esp_netif/CMakeLists.txt @@ -10,7 +10,6 @@ set(srcs "esp_netif_handlers.c" "esp_netif_objects.c" "esp_netif_defaults.c" - "vfs_l2tap/esp_vfs_l2tap.c" "lwip/esp_netif_lwip.c" "lwip/esp_netif_lwip_defaults.c" "lwip/esp_netif_sta_list.c") @@ -33,7 +32,17 @@ list(APPEND srcs "loopback/esp_netif_loopback.c") endif() +if(CONFIG_ESP_NETIF_L2_TAP) +list(APPEND srcs + "vfs_l2tap/esp_vfs_l2tap.c") +endif() + idf_component_register(SRCS "${srcs}" INCLUDE_DIRS "${include_dirs}" PRIV_INCLUDE_DIRS "${priv_include_dirs}" - REQUIRES lwip esp_eth) + REQUIRES lwip) + + +if(CONFIG_ESP_NETIF_L2_TAP) +idf_component_optional_requires(PRIVATE esp_eth) +endif() diff --git a/components/esp_netif/esp_netif_defaults.c b/components/esp_netif/esp_netif_defaults.c index 3a1297da18..70cefa4961 100644 --- a/components/esp_netif/esp_netif_defaults.c +++ b/components/esp_netif/esp_netif_defaults.c @@ -6,9 +6,6 @@ #include "esp_netif.h" #include "esp_wifi_default.h" -#if CONFIG_ETH_ENABLED -#include "esp_eth.h" -#endif // // Purpose of this module is to provide diff --git a/components/esp_netif/include/esp_netif.h b/components/esp_netif/include/esp_netif.h index d0d076626e..bd0f2847b5 100644 --- a/components/esp_netif/include/esp_netif.h +++ b/components/esp_netif/include/esp_netif.h @@ -14,10 +14,6 @@ #include "esp_netif_types.h" #include "esp_netif_defaults.h" -#ifdef CONFIG_ETH_ENABLED -#include "esp_eth_netif_glue.h" -#endif - #ifdef __cplusplus extern "C" { diff --git a/components/esp_netif/test/CMakeLists.txt b/components/esp_netif/test/CMakeLists.txt index c6b2652edd..1015ae9683 100644 --- a/components/esp_netif/test/CMakeLists.txt +++ b/components/esp_netif/test/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "../private_include" "." - PRIV_REQUIRES cmock test_utils esp_netif nvs_flash driver) + PRIV_REQUIRES cmock test_utils esp_netif nvs_flash driver esp_eth) diff --git a/components/esp_netif/vfs_l2tap/esp_vfs_l2tap.c b/components/esp_netif/vfs_l2tap/esp_vfs_l2tap.c index e6e93800d0..45af6099a3 100644 --- a/components/esp_netif/vfs_l2tap/esp_vfs_l2tap.c +++ b/components/esp_netif/vfs_l2tap/esp_vfs_l2tap.c @@ -19,12 +19,12 @@ #include "esp_log.h" #include "esp_check.h" #include "esp_netif.h" +#include "esp_eth.h" #include "freertos/FreeRTOS.h" #include "freertos/semphr.h" #include "freertos/queue.h" -#if CONFIG_ESP_NETIF_L2_TAP #define INVALID_FD (-1) @@ -624,4 +624,3 @@ esp_err_t esp_vfs_l2tap_intf_unregister(const char *base_path) return ESP_OK; } -#endif // CONFIG_ESP_NETIF_L2_TAP diff --git a/components/mdns/CMakeLists.txt b/components/mdns/CMakeLists.txt index cb3ed49960..bdb439fce9 100644 --- a/components/mdns/CMakeLists.txt +++ b/components/mdns/CMakeLists.txt @@ -20,3 +20,7 @@ idf_component_register( PRIV_INCLUDE_DIRS "private_include" REQUIRES ${dependencies} PRIV_REQUIRES ${private_dependencies}) + +if(CONFIG_ETH_ENABLED) + idf_component_optional_requires(PRIVATE esp_eth) +endif() diff --git a/components/mdns/mdns.c b/components/mdns/mdns.c index 15b32e3388..71cb073244 100644 --- a/components/mdns/mdns.c +++ b/components/mdns/mdns.c @@ -17,6 +17,10 @@ #include "mdns_networking.h" #include "esp_log.h" #include "esp_random.h" +#if CONFIG_ETH_ENABLED +#include "esp_eth.h" +#endif + #ifdef MDNS_ENABLE_DEBUG void mdns_debug_packet(const uint8_t * data, size_t len); diff --git a/components/mqtt/test/CMakeLists.txt b/components/mqtt/test/CMakeLists.txt index a86bbd002c..a5b760667b 100644 --- a/components/mqtt/test/CMakeLists.txt +++ b/components/mqtt/test/CMakeLists.txt @@ -1,2 +1,2 @@ idf_component_register(SRC_DIRS "." - PRIV_REQUIRES cmock test_utils mqtt nvs_flash app_update) + PRIV_REQUIRES cmock test_utils mqtt nvs_flash app_update esp_eth) diff --git a/examples/common_components/protocol_examples_common/CMakeLists.txt b/examples/common_components/protocol_examples_common/CMakeLists.txt index 5f9317e17d..5f903a75d0 100644 --- a/examples/common_components/protocol_examples_common/CMakeLists.txt +++ b/examples/common_components/protocol_examples_common/CMakeLists.txt @@ -1,4 +1,4 @@ idf_component_register(SRCS "connect.c" "stdin_out.c" "addr_from_stdin.c" INCLUDE_DIRS "include" - PRIV_REQUIRES esp_netif driver + PRIV_REQUIRES esp_netif driver esp_eth ) diff --git a/examples/common_components/protocol_examples_common/include/protocol_examples_common.h b/examples/common_components/protocol_examples_common/include/protocol_examples_common.h index 7afc78a745..d43e94e0d0 100644 --- a/examples/common_components/protocol_examples_common/include/protocol_examples_common.h +++ b/examples/common_components/protocol_examples_common/include/protocol_examples_common.h @@ -15,6 +15,7 @@ extern "C" { #include "esp_err.h" #include "esp_netif.h" +#include "esp_eth.h" #ifdef CONFIG_EXAMPLE_CONNECT_ETHERNET #define EXAMPLE_INTERFACE get_example_netif() diff --git a/examples/ethernet/enc28j60/components/eth_enc28j60/CMakeLists.txt b/examples/ethernet/enc28j60/components/eth_enc28j60/CMakeLists.txt index 1ee84a2a4a..64babbe55b 100644 --- a/examples/ethernet/enc28j60/components/eth_enc28j60/CMakeLists.txt +++ b/examples/ethernet/enc28j60/components/eth_enc28j60/CMakeLists.txt @@ -1,4 +1,4 @@ idf_component_register(SRCS "esp_eth_mac_enc28j60.c" "esp_eth_phy_enc28j60.c" - PRIV_REQUIRES driver + PRIV_REQUIRES driver esp_eth INCLUDE_DIRS ".") diff --git a/examples/ethernet/eth2ap/main/ethernet_example_main.c b/examples/ethernet/eth2ap/main/ethernet_example_main.c index 4f11e4591b..a5ca36fe1f 100644 --- a/examples/ethernet/eth2ap/main/ethernet_example_main.c +++ b/examples/ethernet/eth2ap/main/ethernet_example_main.c @@ -14,7 +14,7 @@ #include "freertos/queue.h" #include "esp_event.h" #include "esp_log.h" -#include "esp_eth.h" +#include "esp_eth_driver.h" #include "esp_wifi.h" #include "nvs_flash.h" #include "esp_private/wifi.h" diff --git a/examples/network/simple_sniffer/main/cmd_sniffer.h b/examples/network/simple_sniffer/main/cmd_sniffer.h index d20085a127..ae0563efc1 100644 --- a/examples/network/simple_sniffer/main/cmd_sniffer.h +++ b/examples/network/simple_sniffer/main/cmd_sniffer.h @@ -8,6 +8,8 @@ */ #pragma once +#include "esp_eth.h" + #ifdef __cplusplus extern "C" { #endif