feat(esp_netif): Add support for IPv6 autoconfig flag per netif

This commit is contained in:
David Cermak 2024-06-07 16:52:32 +02:00 committed by David Čermák
parent 48b3e4f76f
commit 95169eb929
4 changed files with 13 additions and 6 deletions

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -36,9 +36,15 @@ extern "C" {
#define ESP_NETIF_DEFAULT_MLDV6_REPORT_FLAGS (0)
#endif
#ifdef CONFIG_LWIP_IPV6_AUTOCONFIG
#define ESP_NETIF_DEFAULT_IPV6_AUTOCONFIG_FLAGS (ESP_NETIF_FLAG_IPV6_AUTOCONFIG_ENABLED)
#else
#define ESP_NETIF_DEFAULT_IPV6_AUTOCONFIG_FLAGS (0)
#endif
#define ESP_NETIF_INHERENT_DEFAULT_WIFI_STA() \
{ \
.flags = (esp_netif_flags_t)(ESP_NETIF_IPV4_ONLY_FLAGS(ESP_NETIF_DHCP_CLIENT) | ESP_NETIF_DEFAULT_ARP_FLAGS | ESP_NETIF_DEFAULT_MLDV6_REPORT_FLAGS | ESP_NETIF_FLAG_EVENT_IP_MODIFIED), \
.flags = (esp_netif_flags_t)(ESP_NETIF_IPV4_ONLY_FLAGS(ESP_NETIF_DHCP_CLIENT) | ESP_NETIF_DEFAULT_ARP_FLAGS | ESP_NETIF_DEFAULT_MLDV6_REPORT_FLAGS | ESP_NETIF_FLAG_EVENT_IP_MODIFIED | ESP_NETIF_DEFAULT_IPV6_AUTOCONFIG_FLAGS), \
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(mac) \
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(ip_info) \
.get_ip_event = IP_EVENT_STA_GOT_IP, \
@ -78,7 +84,7 @@ extern "C" {
#define ESP_NETIF_INHERENT_DEFAULT_ETH() \
{ \
.flags = (esp_netif_flags_t)(ESP_NETIF_IPV4_ONLY_FLAGS(ESP_NETIF_DHCP_CLIENT) | ESP_NETIF_DEFAULT_ARP_FLAGS | ESP_NETIF_FLAG_EVENT_IP_MODIFIED), \
.flags = (esp_netif_flags_t)(ESP_NETIF_IPV4_ONLY_FLAGS(ESP_NETIF_DHCP_CLIENT) | ESP_NETIF_DEFAULT_ARP_FLAGS | ESP_NETIF_FLAG_EVENT_IP_MODIFIED | ESP_NETIF_DEFAULT_IPV6_AUTOCONFIG_FLAGS), \
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(mac) \
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(ip_info) \
.get_ip_event = IP_EVENT_ETH_GOT_IP, \
@ -92,7 +98,7 @@ extern "C" {
#ifdef CONFIG_PPP_SUPPORT
#define ESP_NETIF_INHERENT_DEFAULT_PPP() \
{ \
.flags = ESP_NETIF_FLAG_IS_PPP, \
.flags = (esp_netif_flags_t)(ESP_NETIF_FLAG_IS_PPP | ESP_NETIF_DEFAULT_IPV6_AUTOCONFIG_FLAGS), \
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(mac) \
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(ip_info) \
.get_ip_event = IP_EVENT_PPP_GOT_IP, \

View File

@ -178,6 +178,7 @@ typedef enum esp_netif_flags {
ESP_NETIF_FLAG_IS_PPP = 1 << 5,
ESP_NETIF_FLAG_IS_BRIDGE = 1 << 6,
ESP_NETIF_FLAG_MLDV6_REPORT = 1 << 7,
ESP_NETIF_FLAG_IPV6_AUTOCONFIG_ENABLED = 1 << 8,
} esp_netif_flags_t;
typedef enum esp_netif_ip_event_type {

View File

@ -1105,7 +1105,7 @@ static esp_err_t esp_netif_start_api(esp_netif_api_msg_t *msg)
ESP_ERROR_CHECK(esp_netif_lwip_add(esp_netif));
#if ESP_IPV6_AUTOCONFIG
esp_netif->lwip_netif->ip6_autoconfig_enabled = 1;
esp_netif->lwip_netif->ip6_autoconfig_enabled = (esp_netif->flags & ESP_NETIF_FLAG_IPV6_AUTOCONFIG_ENABLED) ? 1 : 0;
#endif
if (esp_netif->flags&ESP_NETIF_FLAG_GARP) {
#if ESP_GRATUITOUS_ARP

View File

@ -271,7 +271,7 @@ esp_err_t esp_netif_start_ppp(esp_netif_t *esp_netif)
#endif // CONFIG_LWIP_PPP_SERVER_SUPPORT
#if ESP_IPV6_AUTOCONFIG
ppp_ctx->ppp->netif->ip6_autoconfig_enabled = 1;
ppp_ctx->ppp->netif->ip6_autoconfig_enabled = (esp_netif->flags & ESP_NETIF_FLAG_IPV6_AUTOCONFIG_ENABLED) ? 1 : 0;
#endif
ESP_LOGD(TAG, "%s: Starting PPP connection: %p", __func__, ppp_ctx->ppp);