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

[ncp] integrate SRP Server and Advertising Proxy for NCP #2624

Merged
merged 1 commit into from
Dec 5, 2024
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/ncp_mode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
OTBR_MDNS: ${{ matrix.mdns }}
OTBR_COVERAGE: 1
OTBR_VERBOSE: 1
OTBR_OPTIONS: "-DCMAKE_BUILD_TYPE=Debug -DOT_THREAD_VERSION=1.4 -DOTBR_COVERAGE=ON -DOTBR_DBUS=ON -DOTBR_FEATURE_FLAGS=ON -DOTBR_TELEMETRY_DATA_API=ON -DOTBR_UNSECURE_JOIN=ON -DOTBR_TREL=ON -DBUILD_TESTING=OFF"
OTBR_OPTIONS: "-DCMAKE_BUILD_TYPE=Debug -DOT_THREAD_VERSION=1.4 -DOTBR_COVERAGE=ON -DOTBR_DBUS=ON -DOTBR_FEATURE_FLAGS=ON -DOTBR_TELEMETRY_DATA_API=ON -DOTBR_UNSECURE_JOIN=ON -DOTBR_TREL=ON -DOTBR_SRP_ADVERTISING_PROXY=ON -DBUILD_TESTING=OFF"
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -76,6 +76,6 @@ jobs:
--build-arg OTBR_OPTIONS="${OTBR_OPTIONS}"
- name: Run
run: |
top_builddir="./build/temp" tests/scripts/ncp_mode build_ot_sim expect
top_builddir="./build/temp" tests/scripts/ncp_mode build_ot_sim expect
- name: Codecov
uses: codecov/codecov-action@v5
10 changes: 9 additions & 1 deletion src/agent/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,22 @@ void Application::DeinitRcpMode(void)

void Application::InitNcpMode(void)
{
#if OTBR_ENABLE_SRP_ADVERTISING_PROXY
otbr::Ncp::NcpHost &ncpHost = static_cast<otbr::Ncp::NcpHost &>(mHost);
ncpHost.SetMdnsPublisher(mPublisher.get());
mMdnsStateSubject.AddObserver(ncpHost);
mPublisher->Start();
#endif
#if OTBR_ENABLE_DBUS_SERVER
mDBusAgent->Init(*mBorderAgent);
#endif
}

void Application::DeinitNcpMode(void)
{
/* empty */
#if OTBR_ENABLE_SRP_ADVERTISING_PROXY
mPublisher->Stop();
#endif
}

} // namespace otbr
1 change: 1 addition & 0 deletions src/agent/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#if OTBR_ENABLE_BORDER_AGENT
#include "border_agent/border_agent.hpp"
#endif
#include "ncp/ncp_host.hpp"
#include "ncp/rcp_host.hpp"
#if OTBR_ENABLE_BACKBONE_ROUTER
#include "backbone_router/backbone_agent.hpp"
Expand Down
23 changes: 22 additions & 1 deletion src/ncp/ncp_host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include <openthread/openthread-system.h>

#include "lib/spinel/spinel_driver.hpp"

#include "ncp/async_task.hpp"

namespace otbr {
Expand Down Expand Up @@ -134,6 +133,16 @@ void NcpHost::Init(void)
{
mInfraIf.SetInfraIf(mConfig.mBackboneInterfaceName);
}

#if OTBR_ENABLE_SRP_ADVERTISING_PROXY
#if OTBR_ENABLE_SRP_SERVER_AUTO_ENABLE_MODE
// Let SRP server use auto-enable mode. The auto-enable mode delegates the control of SRP server to the Border
// Routing Manager. SRP server automatically starts when bi-directional connectivity is ready.
mNcpSpinel.SrpServerSetAutoEnableMode(/* aEnabled */ true);
#else
mNcpSpinel.SrpServerSetEnabled(/* aEnabled */ true);
#endif
#endif
}

void NcpHost::Deinit(void)
Expand Down Expand Up @@ -255,5 +264,17 @@ void NcpHost::Update(MainloopContext &aMainloop)
mNetif.UpdateFdSet(&aMainloop);
}

#if OTBR_ENABLE_SRP_ADVERTISING_PROXY
void NcpHost::SetMdnsPublisher(Mdns::Publisher *aPublisher)
{
mNcpSpinel.SetMdnsPublisher(aPublisher);
}

void NcpHost::HandleMdnsState(Mdns::Publisher::State aState)
{
mNcpSpinel.DnssdSetState(aState);
}
#endif

} // namespace Ncp
} // namespace otbr
16 changes: 15 additions & 1 deletion src/ncp/ncp_host.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@ class NcpNetworkProperties : virtual public NetworkProperties, public PropsObser
otOperationalDatasetTlvs mDatasetActiveTlvs;
};

class NcpHost : public MainloopProcessor, public ThreadHost, public NcpNetworkProperties
class NcpHost : public MainloopProcessor,
public ThreadHost,
public NcpNetworkProperties
#if OTBR_ENABLE_SRP_ADVERTISING_PROXY
,
public Mdns::StateObserver
#endif
{
public:
/**
Expand Down Expand Up @@ -119,7 +125,15 @@ class NcpHost : public MainloopProcessor, public ThreadHost, public NcpNetworkPr
void Update(MainloopContext &aMainloop) override;
void Process(const MainloopContext &aMainloop) override;

#if OTBR_ENABLE_SRP_ADVERTISING_PROXY
void SetMdnsPublisher(Mdns::Publisher *aPublisher);
#endif

private:
#if OTBR_ENABLE_SRP_ADVERTISING_PROXY
void HandleMdnsState(Mdns::Publisher::State aState) override;
#endif

ot::Spinel::SpinelDriver &mSpinelDriver;
otPlatformConfig mConfig;
NcpSpinel mNcpSpinel;
Expand Down
Loading
Loading