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

[agent] add application integration for VendorServer instead of NCP #2017

Merged
merged 10 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from 9 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
5 changes: 5 additions & 0 deletions etc/cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,8 @@ if (OTBR_DHCP6_PD)
else()
target_compile_definitions(otbr-config INTERFACE OTBR_ENABLE_DHCP6_PD=0)
endif()

option(OTBR_VENDOR_SERVER "Enable vendor server" OFF)
if (OTBR_VENDOR_SERVER)
target_compile_definitions(otbr-config INTERFACE OTBR_ENABLE_VENDOR_SERVER=1)
endif()
2 changes: 1 addition & 1 deletion src/agent/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Application::Application(const std::string &aInterfaceName,
, mDBusAgent(mNcp, mBorderAgent.GetPublisher())
#endif
#if OTBR_ENABLE_VENDOR_SERVER
, mVendorServer(vendor::VendorServer::newInstance(mNcp))
, mVendorServer(vendor::VendorServer::newInstance(*this))
#endif
{
OTBR_UNUSED_VARIABLE(aRestListenAddress);
Expand Down
75 changes: 75 additions & 0 deletions src/agent/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@

namespace otbr {

#if OTBR_ENABLE_VENDOR_SERVER
namespace vendor {

class VendorServer;
superwhd marked this conversation as resolved.
Show resolved Hide resolved

}
#endif

/**
* @addtogroup border-router-agent
*
Expand Down Expand Up @@ -119,6 +127,73 @@ class Application : private NonCopyable
*/
otbrError Run(void);

/**
* Get the OpenThread controller object the application is using.
*
* @returns The OpenThread controller object.
*/
Ncp::ControllerOpenThread &GetNcp(void) { return mNcp; }

#if OTBR_ENABLE_BORDER_AGENT
/**
* Get the border agent the application is using.
*
* @returns The border agent.
*/
BorderAgent &GetBorderAgent(void)
{
return mBorderAgent;
}
#endif

#if OTBR_ENABLE_BACKBONE_ROUTER
/**
* Get the backbone agent the application is using.
*
* @returns The backbone agent.
*/
BackboneRouter::BackboneAgent &GetBackboneAgent(void)
{
return mBackboneAgent;
}
#endif

#if OTBR_ENABLE_OPENWRT
/**
* Get the UBus agent the application is using.
*
* @returns The UBus agent.
*/
ubus::UBusAgent &GetUBusAgent(void)
{
return mUbusAgent;
}
#endif

#if OTBR_ENABLE_REST_SERVER
/**
* Get the rest web server the application is using.
*
* @returns The rest web server.
*/
rest::RestWebServer &GetRestWebServer(void)
{
return mRestWebServer;
}
#endif

#if OTBR_ENABLE_DBUS_SERVER
/**
* Get the DBus agent the application is using.
*
* @returns The DBus agent.
*/
DBus::DBusAgent &GetDBusAgent(void)
{
return mDBusAgent;
}
#endif

private:
// Default poll timeout.
static const struct timeval kPollTimeout;
Expand Down
9 changes: 6 additions & 3 deletions src/agent/vendor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@

#include "openthread-br/config.h"

#include "ncp/ncp_openthread.hpp"
#include "agent/application.hpp"

namespace otbr {

class Application;
superwhd marked this conversation as resolved.
Show resolved Hide resolved

namespace vendor {

/**
Expand All @@ -54,11 +57,11 @@ class VendorServer
*
* Custom vendor servers should implement this method to return an object of the derived class.
*
* @param[in] aNcp The OpenThread controller object.
* @param[in] application The OTBR application.
jwhui marked this conversation as resolved.
Show resolved Hide resolved
*
* @returns New derived VendorServer instance.
*/
static std::shared_ptr<VendorServer> newInstance(otbr::Ncp::ControllerOpenThread &aNcp);
static std::shared_ptr<VendorServer> newInstance(Application &application);
morningboata marked this conversation as resolved.
Show resolved Hide resolved

/**
* Initializes the vendor server.
Expand Down