Skip to content

Commit

Permalink
Merge branch 'feat/lwip_netif_more_opts' into 'master'
Browse files Browse the repository at this point in the history
fix(lwip/esp_netif): Adds more configs: IPv6 autoconfig per netif, IPv6-only for PPP

Closes IDF-1394

See merge request espressif/esp-idf!31410
  • Loading branch information
david-cermak committed Jul 18, 2024
2 parents 8f3f860 + 95169eb commit 463b41f
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 22 deletions.
14 changes: 10 additions & 4 deletions components/esp_netif/include/esp_netif_defaults.h
Original file line number Diff line number Diff line change
@@ -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
*/
Expand Down Expand Up @@ -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, \
Expand Down Expand Up @@ -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, \
Expand All @@ -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, \
Expand Down
1 change: 1 addition & 0 deletions components/esp_netif/include/esp_netif_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion components/esp_netif/lwip/esp_netif_lwip.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion components/esp_netif/lwip/esp_netif_lwip_ppp.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@ netif_related_data_t * esp_netif_new_ppp(esp_netif_t *esp_netif, const esp_netif
#if PPP_NOTIFY_PHASE
ppp_set_notify_phase_callback(ppp_obj->ppp, on_ppp_notify_phase);
#endif
#if PPP_IPV4_SUPPORT
ppp_set_usepeerdns(ppp_obj->ppp, 1);
#endif

return (netif_related_data_t *)ppp_obj;
}
Expand Down Expand Up @@ -269,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);
Expand Down
40 changes: 24 additions & 16 deletions components/lwip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -882,13 +882,37 @@ menu "LWIP"
default 0x0 if LWIP_TCPIP_TASK_AFFINITY_CPU0
default 0x1 if LWIP_TCPIP_TASK_AFFINITY_CPU1

config LWIP_IPV6_MEMP_NUM_ND6_QUEUE
int "Max number of IPv6 packets to queue during MAC resolution"
depends on LWIP_IPV6
range 3 20
default 3
help
Config max number of IPv6 packets to queue during MAC resolution.

config LWIP_IPV6_ND6_NUM_NEIGHBORS
int "Max number of entries in IPv6 neighbor cache"
depends on LWIP_IPV6
range 3 10
default 5
help
Config max number of entries in IPv6 neighbor cache

menuconfig LWIP_PPP_SUPPORT
bool "Enable PPP support"
default n
help
Enable PPP stack. Now only PPP over serial is possible.

config LWIP_PPP_ENABLE_IPV4
bool "Enable IPV4 support for PPP connections (IPCP)"
depends on LWIP_PPP_SUPPORT && LWIP_IPV4
default y
help
Enable IPCP protocol in PPP negotiations, which assigns IPv4 addresses to the PPP client,
as well as IPv4 DNS servers.
You can disable this if your modem supports IPv6 only.

config LWIP_PPP_ENABLE_IPV6
bool "Enable IPV6 support for PPP connections (IPV6CP)"
depends on LWIP_PPP_SUPPORT && LWIP_IPV6
Expand All @@ -900,22 +924,6 @@ menu "LWIP"
This would in turn fail the configuration for the whole link.
If your modem is not responding correctly to PPP Phase Network, try to disable IPV6 support.

config LWIP_IPV6_MEMP_NUM_ND6_QUEUE
int "Max number of IPv6 packets to queue during MAC resolution"
depends on LWIP_IPV6
range 3 20
default 3
help
Config max number of IPv6 packets to queue during MAC resolution.

config LWIP_IPV6_ND6_NUM_NEIGHBORS
int "Max number of entries in IPv6 neighbor cache"
depends on LWIP_IPV6
range 3 10
default 5
help
Config max number of entries in IPv6 neighbor cache

config LWIP_PPP_NOTIFY_PHASE_SUPPORT
bool "Enable Notify Phase Callback"
depends on LWIP_PPP_SUPPORT
Expand Down
5 changes: 5 additions & 0 deletions components/lwip/port/include/lwipopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,11 @@ static inline uint32_t timeout_from_offered(uint32_t lease, uint32_t min)
*/
#define PPP_IPV6_SUPPORT CONFIG_LWIP_PPP_ENABLE_IPV6

/**
* PPP_IPV4_SUPPORT==1: Enable PPP IPv4 support
*/
#define PPP_IPV4_SUPPORT CONFIG_LWIP_PPP_ENABLE_IPV4

/**
* PPP_NOTIFY_PHASE==1: Support PPP notify phase.
*/
Expand Down

0 comments on commit 463b41f

Please sign in to comment.