From d5fdc0d9502de06e2a30e21c9b540acac5f63a95 Mon Sep 17 00:00:00 2001 From: Song GUO Date: Wed, 28 Jun 2023 05:15:28 +0800 Subject: [PATCH] [dhcp6pd] add basic DHCPv6-PD support (#1917) This commit includes changes for build flags and feature flags. --- etc/cmake/options.cmake | 7 +++++++ src/ncp/ncp_openthread.cpp | 7 +++++++ src/proto/capabilities.proto | 1 + src/proto/feature_flag.proto | 2 ++ third_party/openthread/CMakeLists.txt | 1 + 5 files changed, 18 insertions(+) diff --git a/etc/cmake/options.cmake b/etc/cmake/options.cmake index d8a65915242..9060bbb415d 100644 --- a/etc/cmake/options.cmake +++ b/etc/cmake/options.cmake @@ -139,3 +139,10 @@ option(OTBR_PUBLISH_MESHCOP_BA_ID "Publish the MeshCoP mDNS 'id' TXT entry, enab if (OTBR_PUBLISH_MESHCOP_BA_ID) target_compile_definitions(otbr-config INTERFACE OTBR_ENABLE_PUBLISH_MESHCOP_BA_ID=1) endif() + +option(OTBR_DHCP6_PD "Prefix delegation support" OFF) +if (OTBR_DHCP6_PD) + target_compile_definitions(otbr-config INTERFACE OTBR_ENABLE_DHCP6_PD=1) +else() + target_compile_definitions(otbr-config INTERFACE OTBR_ENABLE_DHCP6_PD=0) +endif() diff --git a/src/ncp/ncp_openthread.cpp b/src/ncp/ncp_openthread.cpp index 0f4302c28d0..ef1627e6971 100644 --- a/src/ncp/ncp_openthread.cpp +++ b/src/ncp/ncp_openthread.cpp @@ -35,6 +35,7 @@ #include #include +#include #include #include #include @@ -243,6 +244,9 @@ void ControllerOpenThread::Init(void) #if OTBR_ENABLE_DNS_UPSTREAM_QUERY otDnssdUpstreamQuerySetEnabled(mInstance, /* aEnabled */ true); #endif +#if OTBR_ENABLE_DHCP6_PD + otBorderRoutingDhcp6PdSetEnabled(mInstance, /* aEnabled */ true); +#endif #endif // OTBR_ENABLE_FEATURE_FLAGS mThreadHelper = std::unique_ptr(new otbr::agent::ThreadHelper(mInstance, this)); @@ -277,6 +281,9 @@ otError ControllerOpenThread::ApplyFeatureFlagList(const FeatureFlagList &aFeatu #if OTBR_ENABLE_DNS_UPSTREAM_QUERY otDnssdUpstreamQuerySetEnabled(mInstance, aFeatureFlagList.enable_dns_upstream_query()); #endif +#if OTBR_ENABLE_DHCP6_PD + otBorderRoutingDhcp6PdSetEnabled(mInstance, aFeatureFlagList.enable_dhcp6_pd()); +#endif return error; } diff --git a/src/proto/capabilities.proto b/src/proto/capabilities.proto index d040d538653..f49864ac096 100644 --- a/src/proto/capabilities.proto +++ b/src/proto/capabilities.proto @@ -10,4 +10,5 @@ message Capabilities { // When some macro is deleted, the corresponding value should be marked as "reserved". // It is suggested to assign a new field number to a macro when its scope has significantly changed. optional bool nat64 = 1; // OTBR_ENABLE_NAT64 + optional bool dhcp6_pd = 2; // OTBR_ENABLE_DHCP6_PD } diff --git a/src/proto/feature_flag.proto b/src/proto/feature_flag.proto index 1b1cf01b5c6..2b82b89660e 100644 --- a/src/proto/feature_flag.proto +++ b/src/proto/feature_flag.proto @@ -62,4 +62,6 @@ message FeatureFlagList { optional bool enable_trel = 4 [default = false]; // Whether to enable upstream DNS forwarding. optional bool enable_dns_upstream_query = 5 [default = false]; + // Whether to enable prefix delegation. + optional bool enable_dhcp6_pd = 6 [default = false]; } diff --git a/third_party/openthread/CMakeLists.txt b/third_party/openthread/CMakeLists.txt index af8ddf49a80..03ad863352d 100644 --- a/third_party/openthread/CMakeLists.txt +++ b/third_party/openthread/CMakeLists.txt @@ -35,6 +35,7 @@ set(OT_BORDER_AGENT_ID ON CACHE STRING "enable border agent ID" FORCE) set(OT_BORDER_ROUTER ON CACHE STRING "enable border router feature" FORCE) set(OT_BORDER_ROUTING ${OTBR_BORDER_ROUTING} CACHE STRING "enable border routing feature" FORCE) set(OT_BORDER_ROUTING_COUNTERS ${OTBR_BORDER_ROUTING_COUNTERS} CACHE STRING "enable border routing counters feature" FORCE) +set(OT_BORDER_ROUTING_DHCP6_PD ${OTBR_DHCP6_PD} CACHE STRING "enable dhcpv6 pd support in border routing" FORCE) set(OT_BUILD_EXECUTABLES OFF CACHE STRING "disable building executables" FORCE) set(OT_BUILTIN_MBEDTLS_MANAGEMENT OFF CACHE STRING "diable mbedTLS management" FORCE) set(OT_CHILD_SUPERVISION ON CACHE STRING "enable child supervision" FORCE)