-
Notifications
You must be signed in to change notification settings - Fork 291
[dbus] add dbus API to set border agent Id #3136
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -800,6 +800,17 @@ class ThreadApiDBus | |
| */ | ||
| ClientError SetBorderAgentEnabled(bool aEnabled); | ||
|
|
||
| /** | ||
| * This method sets the 16 byte Border Agent Id. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pls add notes as https://github.com/openthread/openthread/blob/main/include/openthread/border_agent.h#L340 and highlight this API should be used with awareness and caution. |
||
| * | ||
| * @param[in] aBorderAgentId The Border Agent Id. | ||
| * | ||
| * @retval ERROR_NONE Successfully performed the dbus function call | ||
| * @retval ERROR_DBUS dbus encode/decode error | ||
| * @retval ... OpenThread defined error value otherwise | ||
| */ | ||
| ClientError SetBorderAgentId(const std::vector<uint8_t> &aBorderAgentId); | ||
|
|
||
| /** | ||
| * This method sets multiple vendor-specific entries for the TXT record of the MeshCoP service. | ||
| * | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -187,6 +187,10 @@ otbrError DBusThreadObjectRcp::Init(void) | |
| std::bind(&DBusThreadObjectRcp::SetDnsUpstreamQueryState, this, _1)); | ||
| RegisterSetPropertyHandler(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_PROPERTY_NAT64_CIDR, | ||
| std::bind(&DBusThreadObjectRcp::SetNat64Cidr, this, _1)); | ||
| #if OTBR_ENABLE_BORDER_AGENT_ID | ||
| RegisterSetPropertyHandler(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_PROPERTY_BORDER_AGENT_ID, | ||
| std::bind(&DBusThreadObjectRcp::SetBorderAgentIdHandler, this, _1)); | ||
| #endif | ||
| #if OTBR_ENABLE_EPSKC | ||
| RegisterSetPropertyHandler(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_PROPERTY_EPHEMERAL_KEY_ENABLED, | ||
| std::bind(&DBusThreadObjectRcp::SetEphemeralKeyEnabled, this, _1)); | ||
|
|
@@ -223,8 +227,10 @@ otbrError DBusThreadObjectRcp::Init(void) | |
| std::bind(&DBusThreadObjectRcp::GetRloc16Handler, this, _1)); | ||
| RegisterGetPropertyHandler(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_PROPERTY_EXTENDED_ADDRESS, | ||
| std::bind(&DBusThreadObjectRcp::GetExtendedAddressHandler, this, _1)); | ||
| #if OTBR_ENABLE_BORDER_AGENT_ID | ||
| RegisterGetPropertyHandler(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_PROPERTY_BORDER_AGENT_ID, | ||
| std::bind(&DBusThreadObjectRcp::GetBorderAgentIdHandler, this, _1)); | ||
| #endif | ||
| RegisterGetPropertyHandler(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_PROPERTY_ROUTER_ID, | ||
| std::bind(&DBusThreadObjectRcp::GetRouterIdHandler, this, _1)); | ||
| RegisterGetPropertyHandler(OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_PROPERTY_LEADER_DATA, | ||
|
|
@@ -1308,6 +1314,23 @@ otError DBusThreadObjectRcp::SetRadioRegionHandler(DBusMessageIter &aIter) | |
| return error; | ||
| } | ||
|
|
||
| #if OTBR_ENABLE_BORDER_AGENT_ID | ||
| otError DBusThreadObjectRcp::SetBorderAgentIdHandler(DBusMessageIter &aIter) | ||
| { | ||
| otError error = OT_ERROR_NONE; | ||
| std::array<uint8_t, OT_BORDER_AGENT_ID_LENGTH> data; | ||
| otBorderAgentId borderAgentId; | ||
|
|
||
| VerifyOrExit(DBusMessageExtractFromVariant(&aIter, data) == OTBR_ERROR_NONE, error = OT_ERROR_INVALID_ARGS); | ||
| std::copy(data.begin(), data.end(), borderAgentId.mId); | ||
|
|
||
| error = otBorderAgentSetId(mHost.GetInstance(), &borderAgentId); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this conflict with the #3132?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't sync code so didn't see #3132 yesterday. #3132 can work but it seems a little unnatural to me to set it in So I prefer having a dedicated API to set border agent Id. This PR will ONLY conflict with #3132 when both APIs are called to set the border agent Id. If we:
So we can have both PRs.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on the description of the function otBorderAgentSetVendorTxtData(), the vendor-specific Key-Value TXT data pairs use TXT keys starting with
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure about it. As from spec Overall it's fine to add a separate dbus API but it should be well documented as in OT, people should be aware of the requirement of
|
||
|
|
||
| exit: | ||
| return error; | ||
| } | ||
| #endif | ||
|
|
||
| #if OTBR_ENABLE_BORDER_AGENT | ||
| void DBusThreadObjectRcp::SetBorderAgentEnabledHandler(DBusRequest &aRequest) | ||
| { | ||
|
|
@@ -1664,6 +1687,7 @@ otError DBusThreadObjectRcp::GetEui64Handler(DBusMessageIter &aIter) | |
| return error; | ||
| } | ||
|
|
||
| #if OTBR_ENABLE_BORDER_AGENT_ID | ||
| otError DBusThreadObjectRcp::GetBorderAgentIdHandler(DBusMessageIter &aIter) | ||
| { | ||
| otBorderAgentId id; | ||
|
|
@@ -1679,6 +1703,7 @@ otError DBusThreadObjectRcp::GetBorderAgentIdHandler(DBusMessageIter &aIter) | |
| exit: | ||
| return error; | ||
| } | ||
| #endif | ||
|
|
||
| otError DBusThreadObjectRcp::GetOtRcpVersionHandler(DBusMessageIter &aIter) | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since openthread has an option
OT_BORDER_AGENT_IDto turn on/off Border Agent Id, I think it's necessary to add an option in ot-br-posix as well to avoid the case whereOT_BORDER_AGENT_IDis OFF.BTW, I'm thinking if border agent id is a MUST, why not removing the macro in openthread as well. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's indeed
MUSTrequirement per specification,But the spec doesn't define who is to maintain it. OT core provides the option to help generate/set/store it and when OT is responsible for meshcop service, OPENTHREAD_CONFIG_BORDER_AGENT_MESHCOP_SERVICE_ENABLE, it will report error if it's not ON.
https://github.com/openthread/openthread/blob/main/src/core/meshcop/border_agent.hpp#L80
For BR, application can specify it via UpdateMeshCop UpdateMeshCopTxt or use this new dbus API you are introducing if it want to manage the
id