Skip to content

Commit

Permalink
[NCP] Implement OTBR Daemon for POSIX system
Browse files Browse the repository at this point in the history
  • Loading branch information
yangsong-cnyn committed Jan 20, 2025
1 parent 047b3a8 commit a34aa8a
Show file tree
Hide file tree
Showing 7 changed files with 472 additions and 5 deletions.
7 changes: 7 additions & 0 deletions src/ncp/ncp_host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ NcpHost::NcpHost(const char *aInterfaceName, const char *aBackboneInterfaceName,
: mSpinelDriver(*static_cast<ot::Spinel::SpinelDriver *>(otSysGetSpinelDriver()))
, mNetif(mNcpSpinel)
, mInfraIf(mNcpSpinel)
, mDaemon()
{
memset(&mConfig, 0, sizeof(mConfig));
mConfig.mInterfaceName = aInterfaceName;
Expand All @@ -116,6 +117,7 @@ void NcpHost::Init(void)
mNcpSpinel.Init(mSpinelDriver, *this);
mNetif.Init(mConfig.mInterfaceName);
mInfraIf.Init();
mDaemon.Init(mNetif.GetNetifName());

mNcpSpinel.Ip6SetAddressCallback(
[this](const std::vector<Ip6AddressInfo> &aAddrInfos) { mNetif.UpdateIp6UnicastAddresses(aAddrInfos); });
Expand Down Expand Up @@ -149,6 +151,7 @@ void NcpHost::Deinit(void)
{
mNcpSpinel.Deinit();
mNetif.Deinit();
mDaemon.Deinit();
otSysDeinit();
}

Expand Down Expand Up @@ -258,6 +261,8 @@ void NcpHost::Process(const MainloopContext &aMainloop)
mSpinelDriver.Process(&aMainloop);

mNetif.Process(&aMainloop);

mDaemon.Process(aMainloop);
}

void NcpHost::Update(MainloopContext &aMainloop)
Expand All @@ -271,6 +276,8 @@ void NcpHost::Update(MainloopContext &aMainloop)
}

mNetif.UpdateFdSet(&aMainloop);

mDaemon.UpdateFdSet(aMainloop);
}

#if OTBR_ENABLE_SRP_ADVERTISING_PROXY
Expand Down
2 changes: 2 additions & 0 deletions src/ncp/ncp_host.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "common/mainloop.hpp"
#include "ncp/ncp_spinel.hpp"
#include "ncp/thread_host.hpp"
#include "posix/daemon.hpp"
#include "posix/netif.hpp"

namespace otbr {
Expand Down Expand Up @@ -140,6 +141,7 @@ class NcpHost : public MainloopProcessor,
TaskRunner mTaskRunner;
Netif mNetif;
InfraIf mInfraIf;
Daemon mDaemon;
};

} // namespace Ncp
Expand Down
2 changes: 2 additions & 0 deletions src/ncp/posix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#

add_library(otbr-posix
daemon.hpp
daemon.cpp
infra_if.hpp
infra_if.cpp
netif.cpp
Expand Down
Loading

0 comments on commit a34aa8a

Please sign in to comment.