Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Don't review] [dnssd-plat] integrate DnssdPlatform into Application #2677

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .github/workflows/border_router.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
strategy:
fail-fast: false
matrix:
dnssd_plat: [0]
include:
- name: "Border Router (mDNSResponder)"
otbr_options: "-DOT_DUA=ON -DOT_ECDSA=ON -DOT_MLR=ON -DOT_SERVICE=ON -DOT_SRP_SERVER=ON -DOTBR_COVERAGE=ON -DOTBR_DUA_ROUTING=ON -DOTBR_TREL=OFF -DOTBR_DNS_UPSTREAM_QUERY=ON"
Expand Down Expand Up @@ -105,7 +106,14 @@ jobs:
otbr_mdns: "avahi"
cert_scripts: ./tests/scripts/thread-cert/border_router/*.py
packet_verification: 2

- name: "Border Router with OT Core Advertising Proxy"
otbr_options: "-DOT_DUA=ON -DOT_ECDSA=ON -DOT_MLR=ON -DOT_SERVICE=ON -DOT_SRP_SERVER=ON -DOTBR_COVERAGE=ON -DOTBR_DUA_ROUTING=ON -DOTBR_TREL=ON -DOTBR_DNS_UPSTREAM_QUERY=ON"
border_routing: 1
internet: 0
otbr_mdns: "avahi"
dnssd_plat: 1
cert_scripts: ./tests/scripts/thread-cert/border_router/*.py
packet_verification: 1

name: ${{ matrix.name }}
env:
Expand All @@ -120,6 +128,7 @@ jobs:
INTER_OP_BBR: 0
BORDER_ROUTING: ${{ matrix.border_routing }}
NAT64: ${{ matrix.internet }}
DNSSD_PLAT: ${{ matrix.dnssd_plat }}
MAX_JOBS: 3
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -153,6 +162,7 @@ jobs:
--build-arg NAT64_SERVICE=openthread \
--build-arg DNS64="${{ matrix.internet }}" \
--build-arg MDNS="${{ matrix.otbr_mdns }}" \
--build-arg DNSSD_PLAT="${{ matrix.dnssd_plat }}" \
--build-arg OTBR_OPTIONS="${otbr_options} -DCMAKE_CXX_FLAGS='-DOPENTHREAD_CONFIG_DNSSD_SERVER_BIND_UNSPECIFIED_NETIF=1'"
- name: Bootstrap OpenThread Test
if: ${{ success() && steps.check_cache_result.outputs.cache-hit != 'true' }}
Expand Down
7 changes: 7 additions & 0 deletions etc/cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,10 @@ if (OTBR_POWER_CALIBRATION)
else()
target_compile_definitions(otbr-config INTERFACE OTBR_ENABLE_POWER_CALIBRATION=0)
endif()

option(OTBR_DNSSD_PLAT "Enable OTBR DNS-SD platform implementation" OFF)
if (OTBR_DNSSD_PLAT)
target_compile_definitions(otbr-config INTERFACE OTBR_ENABLE_DNSSD_PLAT=1)
else()
target_compile_definitions(otbr-config INTERFACE OTBR_ENABLE_DNSSD_PLAT=0)
endif()
2 changes: 2 additions & 0 deletions etc/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ ARG REST_API
ARG WEB_GUI
ARG MDNS
ARG FIREWALL
ARG DNSSD_PLAT

ENV INFRA_IF_NAME=${INFRA_IF_NAME:-eth0}
ENV BORDER_ROUTING=${BORDER_ROUTING:-1}
Expand All @@ -61,6 +62,7 @@ ENV DNS64=${DNS64:-0}
ENV WEB_GUI=${WEB_GUI:-1}
ENV REST_API=${REST_API:-1}
ENV FIREWALL=${FIREWALL:-1}
ENV DNSSD_PLAT=${DNSSD_PLAT:-0}
ENV DOCKER 1

RUN env
Expand Down
11 changes: 10 additions & 1 deletion script/_otbr
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ otbr_install()
"-DCMAKE_INSTALL_PREFIX=/usr"
"-DOTBR_DBUS=ON"
"-DOTBR_DNSSD_DISCOVERY_PROXY=ON"
"-DOTBR_SRP_ADVERTISING_PROXY=ON"
"-DOTBR_INFRA_IF_NAME=${INFRA_IF_NAME}"
"-DOTBR_MDNS=${OTBR_MDNS:=mDNSResponder}"
# Force re-evaluation of version strings
Expand All @@ -81,6 +80,16 @@ otbr_install()
"${otbr_options[@]}"
)

if with DNSSD_PLAT; then
otbr_options+=(
"-DOTBR_DNSSD_PLAT=ON"
)
else
otbr_options+=(
"-DOTBR_SRP_ADVERTISING_PROXY=ON"
)
fi

if with WEB_GUI; then
otbr_options+=("-DOTBR_WEB=ON")
fi
Expand Down
20 changes: 20 additions & 0 deletions src/agent/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "agent/application.hpp"
#include "common/code_utils.hpp"
#include "common/mainloop_manager.hpp"
#include "host/posix/dnssd.hpp"
#include "utils/infra_link_selector.hpp"

namespace otbr {
Expand All @@ -63,6 +64,9 @@ Application::Application(Host::ThreadHost &aHost,
, mPublisher(
Mdns::Publisher::Create([this](Mdns::Publisher::State aState) { mMdnsStateSubject.UpdateState(aState); }))
#endif
#if OTBR_ENABLE_DNSSD_PLAT
, mDnssdPlatform(*mPublisher)
#endif
#if OTBR_ENABLE_DBUS_SERVER && OTBR_ENABLE_BORDER_AGENT
, mDBusAgent(MakeUnique<DBus::DBusAgent>(mHost, *mPublisher))
#endif
Expand Down Expand Up @@ -221,6 +225,9 @@ void Application::CreateRcpMode(const std::string &aRestListenAddress, int aRest

void Application::InitRcpMode(void)
{
Host::RcpHost &rcpHost = static_cast<otbr::Host::RcpHost &>(mHost);
OTBR_UNUSED_VARIABLE(rcpHost);

#if OTBR_ENABLE_BORDER_AGENT
mMdnsStateSubject.AddObserver(*mBorderAgent);
#endif
Expand All @@ -233,6 +240,13 @@ void Application::InitRcpMode(void)
#if OTBR_ENABLE_TREL
mMdnsStateSubject.AddObserver(*mTrelDnssd);
#endif
#if OTBR_ENABLE_DNSSD_PLAT
mMdnsStateSubject.AddObserver(mDnssdPlatform);
mDnssdPlatform.SetDnssdStateChangedCallback(([&rcpHost](otPlatDnssdState aState) {
OTBR_UNUSED_VARIABLE(aState);
otPlatDnssdStateHandleStateChange(rcpHost.GetInstance());
}));
#endif

#if OTBR_ENABLE_MDNS
mPublisher->Start();
Expand Down Expand Up @@ -267,10 +281,16 @@ void Application::InitRcpMode(void)
#if OTBR_ENABLE_VENDOR_SERVER
mVendorServer->Init();
#endif
#if OTBR_ENABLE_DNSSD_PLAT
mDnssdPlatform.Start();
#endif
}

void Application::DeinitRcpMode(void)
{
#if OTBR_ENABLE_DNSSD_PLAT
mDnssdPlatform.Stop();
#endif
#if OTBR_ENABLE_SRP_ADVERTISING_PROXY
mAdvertisingProxy->SetEnabled(false);
#endif
Expand Down
6 changes: 6 additions & 0 deletions src/agent/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
#if OTBR_ENABLE_VENDOR_SERVER
#include "agent/vendor.hpp"
#endif
#if OTBR_ENABLE_DNSSD_PLAT
#include "host/posix/dnssd.hpp"
#endif
#include "utils/infra_link_selector.hpp"

namespace otbr {
Expand Down Expand Up @@ -268,6 +271,9 @@ class Application : private NonCopyable
Mdns::StateSubject mMdnsStateSubject;
std::unique_ptr<Mdns::Publisher> mPublisher;
#endif
#if OTBR_ENABLE_DNSSD_PLAT
DnssdPlatform mDnssdPlatform;
#endif
#if OTBR_ENABLE_BORDER_AGENT
std::unique_ptr<BorderAgent> mBorderAgent;
#endif
Expand Down
4 changes: 4 additions & 0 deletions src/sdp_proxy/advertising_proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@

#if OTBR_ENABLE_SRP_ADVERTISING_PROXY

#if OPENTHREAD_CONFIG_SRP_SERVER_ADVERTISING_PROXY_ENABLE
#error "The Advertising Proxy is already enabled in OpenThread"
#endif

#if !OTBR_ENABLE_MDNS_AVAHI && !OTBR_ENABLE_MDNS_MDNSSD && !OTBR_ENABLE_MDNS_MOJO
#error "The Advertising Proxy requires OTBR_ENABLE_MDNS_AVAHI, OTBR_ENABLE_MDNS_MDNSSD or OTBR_ENABLE_MDNS_MOJO"
#endif
Expand Down
8 changes: 7 additions & 1 deletion third_party/openthread/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,28 @@ set(OT_NAT64_TRANSLATOR ${OTBR_NAT64} CACHE STRING "enable NAT64 translator" FOR
set(OT_NETDATA_PUBLISHER ON CACHE STRING "enable netdata publisher" FORCE)
set(OT_NETDIAG_CLIENT ON CACHE STRING "enable Network Diagnostic client" FORCE)
set(OT_PLATFORM "posix" CACHE STRING "use posix platform" FORCE)
set(OT_PLATFORM_DNSSD ${OTBR_DNSSD_PLAT} CACHE STRING "enable platform DNSSD" FORCE)
set(OT_PLATFORM_NETIF ON CACHE STRING "enable platform netif" FORCE)
set(OT_PLATFORM_UDP ON CACHE STRING "enable platform UDP" FORCE)
set(OT_SERVICE ON CACHE STRING "enable service" FORCE)
set(OT_SLAAC ON CACHE STRING "enable SLAAC" FORCE)
set(OT_SRP_CLIENT ON CACHE STRING "enable SRP client" FORCE)
set(OT_SRP_ADV_PROXY ${OTBR_DNSSD_PLAT} CACHE STRING "enable SRP Advertising Proxy" FORCE)
set(OT_TARGET_OPENWRT ${OTBR_OPENWRT} CACHE STRING "target on OpenWRT" FORCE)
set(OT_TCP OFF CACHE STRING "disable TCP")
set(OT_TREL ${OTBR_TREL} CACHE STRING "enable TREL" FORCE)
set(OT_UDP_FORWARD OFF CACHE STRING "disable udp forward" FORCE)
set(OT_UPTIME ON CACHE STRING "enable uptime" FORCE)

if (OTBR_SRP_ADVERTISING_PROXY)
if (OTBR_DNSSD_PLAT OR OTBR_SRP_ADVERTISING_PROXY)
set(OT_SRP_SERVER ON CACHE STRING "enable SRP server" FORCE)
set(OT_EXTERNAL_HEAP ON CACHE STRING "enable external heap" FORCE)
endif()

if (OT_SRP_ADV_PROXY AND OTBR_SRP_ADVERTISING_PROXY)
message(FATAL_ERROR "Only one Advertising Proxy can be enabled. ${OTBR_DNSSD_PLAT} ")
endif()

if (NOT OT_THREAD_VERSION STREQUAL "1.1")
if (OT_REFERENCE_DEVICE)
set(OT_DUA ON CACHE STRING "Enable Thread 1.2 DUA for reference devices")
Expand Down
Loading