openthread: support 1.3 border routing features

- Support ICMPv6 auto config
- Support SRP service delegation
- Publish _meshcop._mdns service
This commit is contained in:
Jiacheng Guo
2021-06-17 15:44:19 +08:00
parent a7b6ec85b8
commit a74bbde9c5
12 changed files with 179 additions and 26 deletions
@@ -40,7 +40,7 @@ int __weak lwip_hook_netconn_external_resolve(const char *name, ip_addr_t *addr,
#endif
#ifdef CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT
const ip6_addr_t *lwip_hook_nd6_get_gw(struct netif *netif, const ip6_addr_t *dest)
const ip6_addr_t *__weak lwip_hook_nd6_get_gw(struct netif *netif, const ip6_addr_t *dest)
{
LWIP_UNUSED_ARG(netif);
LWIP_UNUSED_ARG(dest);
+15 -16
View File
@@ -11,23 +11,20 @@
// See the License for the specific language governing permissions and
// limitations under the License
#include <string.h>
#include "esp_netif.h"
#include "esp_netif_net_stack.h"
#include "lwip/netif.h"
#include "lwip/pbuf.h"
#include "netif/openthreadif.h"
#include "openthread/error.h"
#include "openthread/ip6.h"
#include "openthread/link.h"
#include "openthread/message.h"
#define OPENTHREAD_IP6_MTU 1280
static void openthread_free_rx_buf_l2(struct netif *netif, void *buf)
{
free(buf);
}
static err_t openthread_output_ip6(struct netif *netif, struct pbuf *p, const struct ip6_addr *peer_addr)
{
struct pbuf *q = p;
@@ -69,24 +66,26 @@ void openthread_netif_input(void *h, void *buffer, size_t len, void *eb)
{
struct netif *netif = h;
struct pbuf *p;
otMessage *message = (otMessage *)buffer;
if (unlikely(buffer == NULL || !netif_is_up(netif))) {
if (buffer) {
openthread_free_rx_buf_l2(netif, buffer);
}
return;
}
/* acquire new pbuf, type: PBUF_REF */
p = pbuf_alloc(PBUF_RAW, len, PBUF_REF);
/* Allocate LINK buffer in case it's forwarded to WiFi/ETH */
p = pbuf_alloc(PBUF_LINK, len, PBUF_POOL);
if (p == NULL) {
openthread_free_rx_buf_l2(netif, buffer);
LWIP_DEBUGF(NETIF_DEBUG, ("Failed to allocate input pbuf for OpenThread netif\n"));
return;
}
p->payload = buffer;
if (unlikely(otMessageRead(message, 0, p->payload, len) != OT_ERROR_NONE)) {
LWIP_DEBUGF(NETIF_DEBUG, ("Failed to read OpenThread message\n"));
}
#if ESP_LWIP
p->l2_owner = netif;
p->l2_buf = buffer;
p->l2_owner = NULL;
p->l2_buf = NULL;
#endif
/* full packet send to tcpip_thread to process */
if (unlikely(netif->input(p, netif) != ERR_OK)) {
@@ -106,7 +105,7 @@ err_t openthread_netif_init(struct netif *netif)
netif->flags = NETIF_FLAG_BROADCAST;
netif->output = NULL;
netif->output_ip6 = openthread_output_ip6;
netif->l2_buffer_free_notify = openthread_free_rx_buf_l2;
netif->l2_buffer_free_notify = NULL;
netif_set_link_up(netif);
return ERR_OK;
+5 -2
View File
@@ -4,7 +4,6 @@ if(CONFIG_OPENTHREAD_ENABLED)
"openthread/include")
set(private_include_dirs
"openthread/include/openthread"
"openthread/src"
"openthread/src/core"
"openthread/src/lib/hdlc"
@@ -38,11 +37,15 @@ if(CONFIG_OPENTHREAD_ENABLED)
endif()
set(exclude_srcs
"openthread/examples/apps/cli/main.cpp"
"openthread/examples/apps/cli/main.c"
"openthread/examples/platforms/utils/logging_rtt.c"
"openthread/examples/platforms/utils/soft_source_match_table.c"
"openthread/src/core/common/extension_example.cpp")
set_source_files_properties("openthread/src/core/net/srp_server.cpp"
PROPERTIES COMPILE_FLAGS
-Wno-maybe-uninitialized)
if(CONFIG_OPENTHREAD_FTD)
set(device_type "OPENTHREAD_FTD=1")
elseif(CONFIG_OPENTHREAD_MTD)
+6 -1
View File
@@ -34,6 +34,10 @@ COMPONENT_SRCDIRS := \
openthread/src/lib/spinel \
port
ifdef CONFIG_OPENTHREAD_BORDER_ROUTER
COMPONENT_SRCDIRS += openthread/src/core/border_router
endif
COMPONENT_OBJEXCLUDE := \
openthread/examples/apps/cli/main.o \
openthread/src/core/common/extension_example.o \
@@ -54,7 +58,8 @@ OPENTHREAD_PACKAGE_VERSION := $(IDF_VERSION_FOR_OPENTHREAD_PACKAGE)-$(OPENTHREAD
COMMON_FLAGS := \
-DOPENTHREAD_CONFIG_FILE=\<openthread-core-esp32x-config.h\> \
-DPACKAGE_VERSION=\"OPENTHREAD_PACKAGE_VERSION\"
-DPACKAGE_VERSION=\"OPENTHREAD_PACKAGE_VERSION\" \
-Wno-maybe-uninitialized
ifdef CONFIG_OPENTHREAD_FTD
COMMON_FLAGS += -DOPENTHREAD_FTD=1
@@ -17,6 +17,7 @@
#include "esp_netif.h"
#include "esp_netif_types.h"
#include "esp_openthread.h"
#include "openthread/instance.h"
#ifdef __cplusplus
extern "C" {
@@ -33,10 +34,23 @@ extern "C" {
* @return
* - ESP_OK on success
* - ESP_ERR_NOT_SUPPORTED if feature not supported
* - ESP_ERR_INVALID_STATE if already initialized
* - ESP_FIAL on other failures
*
*/
esp_err_t esp_openthread_border_router_init(esp_netif_t *backbone_netif);
/**
* @brief Deinitializes the border router features of OpenThread.
*
* @return
* - ESP_OK on success
* - ESP_ERR_INVALID_STATE if not initialized
* - ESP_FIAL on other failures
*
*/
esp_err_t esp_openthread_border_router_deinit(void);
/**
* @brief Gets the backbone interface of OpenThread border router.
*
@@ -105,6 +105,7 @@
*/
#define OPENTHREAD_CONFIG_COAP_API_ENABLE 1
/**
* @def OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE
*
@@ -115,6 +116,16 @@
#define OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE 1
#endif
/**
* @def OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE
*
* Enable the external heap.
*
*/
#ifndef OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE
#define OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE 1
#endif
#if CONFIG_OPENTHREAD_BORDER_ROUTER
/**
@@ -137,6 +148,16 @@
#define OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE 1
#endif
/**
* @def OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
*
* Define to 1 to enable Border Routing support.
*
*/
#ifndef OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
#define OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE 1
#endif
/**
* @def OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE
*
@@ -147,6 +168,26 @@
#define OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE 1
#endif
/**
* @def OPENTHREAD_CONFIG_ECDSA_ENABLE
*
* Define to 1 to enable ECDSA support.
*
*/
#ifndef OPENTHREAD_CONFIG_ECDSA_ENABLE
#define OPENTHREAD_CONFIG_ECDSA_ENABLE 1
#endif
/**
* @def OPENTHREAD_CONFIG_SRP_SERVER_ENABLE
*
* Define to 1 to enable SRP Server support.
*
*/
#ifndef OPENTHREAD_CONFIG_SRP_SERVER_ENABLE
#define OPENTHREAD_CONFIG_SRP_SERVER_ENABLE 1
#endif
#endif // CONFIG_OPENTHREAD_BORDER_ROUTER
/**