From cd8ecf76b35db56a6ad61c0bf0ebd7fafaeb7d62 Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Tue, 16 Jul 2024 14:18:54 +0000 Subject: [PATCH 1/4] IDF release/v5.1 dc859c1e67 --- package/package_esp32_index.template.json | 68 +++++++++++------------ 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/package/package_esp32_index.template.json b/package/package_esp32_index.template.json index 81b7f43d451..f601e334cb1 100644 --- a/package/package_esp32_index.template.json +++ b/package/package_esp32_index.template.json @@ -42,7 +42,7 @@ { "packager": "esp32", "name": "esp32-arduino-libs", - "version": "idf-release_v5.1-bd2b9390ef" + "version": "idf-release_v5.1-dc859c1e67" }, { "packager": "esp32", @@ -105,63 +105,63 @@ "tools": [ { "name": "esp32-arduino-libs", - "version": "idf-release_v5.1-bd2b9390ef", + "version": "idf-release_v5.1-dc859c1e67", "systems": [ { "host": "i686-mingw32", - "url": "https://codeload.github.com/espressif/esp32-arduino-libs/zip/c4ae7a78eafc339c71efcc7a75d5caa525c92f58", - "archiveFileName": "esp32-arduino-libs-c4ae7a78eafc339c71efcc7a75d5caa525c92f58.zip", - "checksum": "SHA-256:bd9d095d468b517e9836355246cff536223b456aa67ffdb176e167c368ddfd1f", - "size": "307841384" + "url": "https://codeload.github.com/espressif/esp32-arduino-libs/zip/da253aa56255b29a76ac5038db350cd9e4ebde1b", + "archiveFileName": "esp32-arduino-libs-da253aa56255b29a76ac5038db350cd9e4ebde1b.zip", + "checksum": "SHA-256:a3ce1e1aebe518d6be26006798b44b6c1a0bc8977a8da4d066ed9d9af1378c9e", + "size": "307528289" }, { "host": "x86_64-mingw32", - "url": "https://codeload.github.com/espressif/esp32-arduino-libs/zip/c4ae7a78eafc339c71efcc7a75d5caa525c92f58", - "archiveFileName": "esp32-arduino-libs-c4ae7a78eafc339c71efcc7a75d5caa525c92f58.zip", - "checksum": "SHA-256:bd9d095d468b517e9836355246cff536223b456aa67ffdb176e167c368ddfd1f", - "size": "307841384" + "url": "https://codeload.github.com/espressif/esp32-arduino-libs/zip/da253aa56255b29a76ac5038db350cd9e4ebde1b", + "archiveFileName": "esp32-arduino-libs-da253aa56255b29a76ac5038db350cd9e4ebde1b.zip", + "checksum": "SHA-256:a3ce1e1aebe518d6be26006798b44b6c1a0bc8977a8da4d066ed9d9af1378c9e", + "size": "307528289" }, { "host": "arm64-apple-darwin", - "url": "https://codeload.github.com/espressif/esp32-arduino-libs/zip/c4ae7a78eafc339c71efcc7a75d5caa525c92f58", - "archiveFileName": "esp32-arduino-libs-c4ae7a78eafc339c71efcc7a75d5caa525c92f58.zip", - "checksum": "SHA-256:bd9d095d468b517e9836355246cff536223b456aa67ffdb176e167c368ddfd1f", - "size": "307841384" + "url": "https://codeload.github.com/espressif/esp32-arduino-libs/zip/da253aa56255b29a76ac5038db350cd9e4ebde1b", + "archiveFileName": "esp32-arduino-libs-da253aa56255b29a76ac5038db350cd9e4ebde1b.zip", + "checksum": "SHA-256:a3ce1e1aebe518d6be26006798b44b6c1a0bc8977a8da4d066ed9d9af1378c9e", + "size": "307528289" }, { "host": "x86_64-apple-darwin", - "url": "https://codeload.github.com/espressif/esp32-arduino-libs/zip/c4ae7a78eafc339c71efcc7a75d5caa525c92f58", - "archiveFileName": "esp32-arduino-libs-c4ae7a78eafc339c71efcc7a75d5caa525c92f58.zip", - "checksum": "SHA-256:bd9d095d468b517e9836355246cff536223b456aa67ffdb176e167c368ddfd1f", - "size": "307841384" + "url": "https://codeload.github.com/espressif/esp32-arduino-libs/zip/da253aa56255b29a76ac5038db350cd9e4ebde1b", + "archiveFileName": "esp32-arduino-libs-da253aa56255b29a76ac5038db350cd9e4ebde1b.zip", + "checksum": "SHA-256:a3ce1e1aebe518d6be26006798b44b6c1a0bc8977a8da4d066ed9d9af1378c9e", + "size": "307528289" }, { "host": "x86_64-pc-linux-gnu", - "url": "https://codeload.github.com/espressif/esp32-arduino-libs/zip/c4ae7a78eafc339c71efcc7a75d5caa525c92f58", - "archiveFileName": "esp32-arduino-libs-c4ae7a78eafc339c71efcc7a75d5caa525c92f58.zip", - "checksum": "SHA-256:bd9d095d468b517e9836355246cff536223b456aa67ffdb176e167c368ddfd1f", - "size": "307841384" + "url": "https://codeload.github.com/espressif/esp32-arduino-libs/zip/da253aa56255b29a76ac5038db350cd9e4ebde1b", + "archiveFileName": "esp32-arduino-libs-da253aa56255b29a76ac5038db350cd9e4ebde1b.zip", + "checksum": "SHA-256:a3ce1e1aebe518d6be26006798b44b6c1a0bc8977a8da4d066ed9d9af1378c9e", + "size": "307528289" }, { "host": "i686-pc-linux-gnu", - "url": "https://codeload.github.com/espressif/esp32-arduino-libs/zip/c4ae7a78eafc339c71efcc7a75d5caa525c92f58", - "archiveFileName": "esp32-arduino-libs-c4ae7a78eafc339c71efcc7a75d5caa525c92f58.zip", - "checksum": "SHA-256:bd9d095d468b517e9836355246cff536223b456aa67ffdb176e167c368ddfd1f", - "size": "307841384" + "url": "https://codeload.github.com/espressif/esp32-arduino-libs/zip/da253aa56255b29a76ac5038db350cd9e4ebde1b", + "archiveFileName": "esp32-arduino-libs-da253aa56255b29a76ac5038db350cd9e4ebde1b.zip", + "checksum": "SHA-256:a3ce1e1aebe518d6be26006798b44b6c1a0bc8977a8da4d066ed9d9af1378c9e", + "size": "307528289" }, { "host": "aarch64-linux-gnu", - "url": "https://codeload.github.com/espressif/esp32-arduino-libs/zip/c4ae7a78eafc339c71efcc7a75d5caa525c92f58", - "archiveFileName": "esp32-arduino-libs-c4ae7a78eafc339c71efcc7a75d5caa525c92f58.zip", - "checksum": "SHA-256:bd9d095d468b517e9836355246cff536223b456aa67ffdb176e167c368ddfd1f", - "size": "307841384" + "url": "https://codeload.github.com/espressif/esp32-arduino-libs/zip/da253aa56255b29a76ac5038db350cd9e4ebde1b", + "archiveFileName": "esp32-arduino-libs-da253aa56255b29a76ac5038db350cd9e4ebde1b.zip", + "checksum": "SHA-256:a3ce1e1aebe518d6be26006798b44b6c1a0bc8977a8da4d066ed9d9af1378c9e", + "size": "307528289" }, { "host": "arm-linux-gnueabihf", - "url": "https://codeload.github.com/espressif/esp32-arduino-libs/zip/c4ae7a78eafc339c71efcc7a75d5caa525c92f58", - "archiveFileName": "esp32-arduino-libs-c4ae7a78eafc339c71efcc7a75d5caa525c92f58.zip", - "checksum": "SHA-256:bd9d095d468b517e9836355246cff536223b456aa67ffdb176e167c368ddfd1f", - "size": "307841384" + "url": "https://codeload.github.com/espressif/esp32-arduino-libs/zip/da253aa56255b29a76ac5038db350cd9e4ebde1b", + "archiveFileName": "esp32-arduino-libs-da253aa56255b29a76ac5038db350cd9e4ebde1b.zip", + "checksum": "SHA-256:a3ce1e1aebe518d6be26006798b44b6c1a0bc8977a8da4d066ed9d9af1378c9e", + "size": "307528289" } ] }, From 98da733f41f08256bfdfaa0c478a2f7c9f6bcff1 Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Tue, 16 Jul 2024 15:05:12 +0300 Subject: [PATCH 2/4] fix(lwip): Filter out V6 packets if V6 is not enabled the ESP might accept and act on some IPv6 packets, even though IPv6 is not enabled for the interface in Arduino. This change makes the ESP ignore all IPv6 packets if IPv6 address is not available. --- libraries/Network/src/NetworkInterface.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libraries/Network/src/NetworkInterface.cpp b/libraries/Network/src/NetworkInterface.cpp index d7813611b65..d8ba922fc85 100644 --- a/libraries/Network/src/NetworkInterface.cpp +++ b/libraries/Network/src/NetworkInterface.cpp @@ -11,6 +11,7 @@ #include "lwip/ip_addr.h" #include "lwip/err.h" #include "lwip/netif.h" +#include "lwip/dns.h" #include "dhcpserver/dhcpserver.h" #include "dhcpserver/dhcpserver_options.h" #include "esp32-hal-log.h" @@ -34,6 +35,17 @@ NetworkInterface *getNetifByID(Network_Interface_ID id) { return NULL; } +#if CONFIG_LWIP_HOOK_IP6_INPUT_CUSTOM +extern "C" int lwip_hook_ip6_input(struct pbuf *p, struct netif *inp) { + if (ip6_addr_isany_val(inp->ip6_addr[0].u_addr.ip6)) { + // We don't have an LL address -> eat this packet here, so it won't get accepted on input netif + pbuf_free(p); + return 1; + } + return 0; +} +#endif + static void _ip_event_cb(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data) { if (event_base == IP_EVENT) { NetworkInterface *netif = NULL; From f3d3150fe60a7230c6c7360f481066bd151ce68f Mon Sep 17 00:00:00 2001 From: Me No Dev Date: Tue, 16 Jul 2024 15:32:20 +0300 Subject: [PATCH 3/4] fix(lwip): DNS header is not required --- libraries/Network/src/NetworkInterface.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/Network/src/NetworkInterface.cpp b/libraries/Network/src/NetworkInterface.cpp index d8ba922fc85..4eb2ea03e94 100644 --- a/libraries/Network/src/NetworkInterface.cpp +++ b/libraries/Network/src/NetworkInterface.cpp @@ -11,7 +11,6 @@ #include "lwip/ip_addr.h" #include "lwip/err.h" #include "lwip/netif.h" -#include "lwip/dns.h" #include "dhcpserver/dhcpserver.h" #include "dhcpserver/dhcpserver_options.h" #include "esp32-hal-log.h" From 8cba086e1485a4f2c97ce196b81f4f95d0245144 Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Tue, 16 Jul 2024 18:17:23 +0300 Subject: [PATCH 4/4] fix(ot): Add LWIP_HOOK_IP6_INPUT_CUSTOM support --- libraries/Network/src/NetworkInterface.cpp | 1 + libraries/OpenThread/src/OThreadCLI.cpp | 33 ++++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/libraries/Network/src/NetworkInterface.cpp b/libraries/Network/src/NetworkInterface.cpp index 4eb2ea03e94..f4bb1d48392 100644 --- a/libraries/Network/src/NetworkInterface.cpp +++ b/libraries/Network/src/NetworkInterface.cpp @@ -35,6 +35,7 @@ NetworkInterface *getNetifByID(Network_Interface_ID id) { } #if CONFIG_LWIP_HOOK_IP6_INPUT_CUSTOM +extern "C" int lwip_hook_ip6_input(struct pbuf *p, struct netif *inp) __attribute__((weak)); extern "C" int lwip_hook_ip6_input(struct pbuf *p, struct netif *inp) { if (ip6_addr_isany_val(inp->ip6_addr[0].u_addr.ip6)) { // We don't have an LL address -> eat this packet here, so it won't get accepted on input netif diff --git a/libraries/OpenThread/src/OThreadCLI.cpp b/libraries/OpenThread/src/OThreadCLI.cpp index 53432b13fbb..cb29584c17b 100644 --- a/libraries/OpenThread/src/OThreadCLI.cpp +++ b/libraries/OpenThread/src/OThreadCLI.cpp @@ -16,8 +16,8 @@ #include "freertos/semphr.h" #include "freertos/queue.h" -#include "esp_netif.h" -#include "esp_netif_types.h" +#include "esp_netif_net_stack.h" +#include "lwip/netif.h" static TaskHandle_t s_cli_task = NULL; static TaskHandle_t s_console_cli_task = NULL; @@ -27,6 +27,9 @@ static xQueueHandle tx_queue = NULL; static esp_openthread_platform_config_t ot_native_config; static TaskHandle_t s_ot_task = NULL; static esp_netif_t *openthread_netif = NULL; +#if CONFIG_LWIP_HOOK_IP6_INPUT_CUSTOM +static struct netif *ot_lwip_netif = NULL; +#endif #define OT_CLI_MAX_LINE_LENGTH 512 @@ -38,6 +41,20 @@ typedef struct { } ot_cli_console_t; static ot_cli_console_t otConsole = {NULL, false, (const char *)NULL, NULL}; +#if CONFIG_LWIP_HOOK_IP6_INPUT_CUSTOM +extern "C" int lwip_hook_ip6_input(struct pbuf *p, struct netif *inp) { + if (ot_lwip_netif && ot_lwip_netif == inp) { + return 0; + } + if (ip6_addr_isany_val(inp->ip6_addr[0].u_addr.ip6)) { + // We don't have an LL address -> eat this packet here, so it won't get accepted on input netif + pbuf_free(p); + return 1; + } + return 0; +} +#endif + // process the CLI commands sent to the OpenThread stack static void ot_cli_loop(void *context) { String sTxString(""); @@ -258,6 +275,15 @@ static void ot_task_worker(void *aContext) { // Initialize the esp_netif bindings esp_netif_config_t cfg = ESP_NETIF_DEFAULT_OPENTHREAD(); openthread_netif = esp_netif_new(&cfg); +#if CONFIG_LWIP_HOOK_IP6_INPUT_CUSTOM + // Get LwIP Netif + if (openthread_netif != NULL) { + ot_lwip_netif = (struct netif *)esp_netif_get_netif_impl(openthread_netif); + if (ot_lwip_netif == NULL) { + log_e("Failed to get OpenThread LwIP netif"); + } + } +#endif } if (!err && openthread_netif == NULL) { log_e("Failed to create OpenThread esp_netif"); @@ -335,6 +361,9 @@ void OpenThreadCLI::end() { // Clean up esp_openthread_deinit(); esp_openthread_netif_glue_deinit(); +#if CONFIG_LWIP_HOOK_IP6_INPUT_CUSTOM + ot_lwip_netif = NULL; +#endif esp_netif_destroy(openthread_netif); esp_vfs_eventfd_unregister(); }