Skip to content

Commit

Permalink
[ncp] integrate SRP Server and Advertising Proxy for NCP
Browse files Browse the repository at this point in the history
  • Loading branch information
Irving-cl committed Nov 27, 2024
1 parent 17c2b1a commit d6eafef
Show file tree
Hide file tree
Showing 11 changed files with 429 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ncp_mode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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_MDNS
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_MDNS
mPublisher->Stop();
#endif
}

} // namespace otbr
1 change: 1 addition & 0 deletions src/ncp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ add_library(otbr-ncp

target_link_libraries(otbr-ncp PRIVATE
otbr-common
otbr-mdns
otbr-posix
$<$<BOOL:${OTBR_FEATURE_FLAGS}>:otbr-proto>
$<$<BOOL:${OTBR_TELEMETRY_DATA_API}>:otbr-proto>
Expand Down
20 changes: 20 additions & 0 deletions src/ncp/ncp_host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,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 +265,15 @@ void NcpHost::Update(MainloopContext &aMainloop)
mNetif.UpdateFdSet(&aMainloop);
}

void NcpHost::SetMdnsPublisher(otbr::Mdns::Publisher *aPublisher)
{
mNcpSpinel.SetMdnsPublisher(aPublisher);
}

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

} // namespace Ncp
} // namespace otbr
7 changes: 6 additions & 1 deletion src/ncp/ncp_host.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "lib/spinel/spinel_driver.hpp"

#include "common/mainloop.hpp"
#include "mdns/mdns.hpp"
#include "ncp/ncp_spinel.hpp"
#include "ncp/thread_host.hpp"
#include "posix/netif.hpp"
Expand Down Expand Up @@ -72,7 +73,7 @@ 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, public Mdns::StateObserver
{
public:
/**
Expand Down Expand Up @@ -119,7 +120,11 @@ class NcpHost : public MainloopProcessor, public ThreadHost, public NcpNetworkPr
void Update(MainloopContext &aMainloop) override;
void Process(const MainloopContext &aMainloop) override;

void SetMdnsPublisher(otbr::Mdns::Publisher *aPublisher);

private:
void HandleMdnsState(otbr::Mdns::Publisher::State aState) override;

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

0 comments on commit d6eafef

Please sign in to comment.