Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
superwhd committed Feb 7, 2025
1 parent e851c2a commit d42b3c2
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 4 deletions.
20 changes: 19 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,22 @@ jobs:
otbr_mdns: "avahi"
cert_scripts: ./tests/scripts/thread-cert/border_router/*.py
packet_verification: 2

- name: "Border Router with OT Core Advertising Proxy (avahi)"
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: "Border Router with OT Core Advertising Proxy (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=ON -DOTBR_DNS_UPSTREAM_QUERY=ON"
border_routing: 1
internet: 0
otbr_mdns: "mDNSResponder"
dnssd_plat: 1
cert_scripts: ./tests/scripts/thread-cert/border_router/*.py
packet_verification: 1

name: ${{ matrix.name }}
env:
Expand All @@ -120,6 +136,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 +170,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
1 change: 1 addition & 0 deletions script/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ install_packages_apt()
# Avahi should be included for reference device builds.
if [[ ${OTBR_MDNS} == "avahi" || ${OT_BACKBONE_CI} == 1 || ${REFERENCE_DEVICE} == 1 ]]; then
sudo apt-get install --no-install-recommends -y avahi-daemon
sudo sed -i 's/^#objects-per-client-max=[0-9]\+/objects-per-client-max=30000/' /etc/avahi/avahi-daemon.conf
fi

(MDNS_RESPONDER_SOURCE_NAME=mDNSResponder-1790.80.10 \
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
5 changes: 4 additions & 1 deletion src/host/posix/dnssd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ static otbr::DnssdPlatform::RegisterCallback MakeRegisterCallback(otInstance
otPlatDnssdRegisterCallback aCallback)
{
return [aInstance, aCallback](otPlatDnssdRequestId aRequestId, otError aError) {
aCallback(aInstance, aRequestId, aError);
if (aCallback)
{
aCallback(aInstance, aRequestId, aError);
}
};
}

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

0 comments on commit d42b3c2

Please sign in to comment.