From 51353c41d544d37ead7a8ff67936c61cdac289e2 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Wed, 8 Apr 2026 23:40:23 -0700 Subject: [PATCH] [border-agent] add support for `vo` key in TXT data parser (#12858) This commit adds support for the Vendor OUI (`vo`) key in the Border Agent MeshCoP service TXT data parser. The `otBorderAgentTxtDataInfo` structure and its internal counterpart `TxtData::Info` are updated to include a boolean flag `mHasVendorOui` and a 3-byte array `mVendorOui` to store the 24-bit vendor OUI. The parsing logic in `TxtData::Info::ProcessTxtEntry()` is updated to recognize the `vo` key and extract its value. Additionally, the CLI `Interpreter` is updated to output the vendor OUI in hexadecimal format when it is present in the parsed information. --- include/openthread/border_agent_txt_data.h | 3 +++ include/openthread/instance.h | 2 +- src/cli/cli.cpp | 6 ++++++ src/core/meshcop/border_agent_txt_data.cpp | 5 +++++ src/core/meshcop/border_agent_txt_data.hpp | 1 + 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/openthread/border_agent_txt_data.h b/include/openthread/border_agent_txt_data.h index babae40cb..a8552df55 100644 --- a/include/openthread/border_agent_txt_data.h +++ b/include/openthread/border_agent_txt_data.h @@ -61,6 +61,7 @@ extern "C" { #define OT_BORDER_AGENT_THREAD_VERSION_SIZE (16) ///< Max size of Thread Version string in `otBorderAgentTxtDataInfo`. #define OT_BORDER_AGENT_VENDOR_NAME_SIZE (32) ///< Max size of Vendor Name string in `otBorderAgentTxtDataInfo`. #define OT_BORDER_AGENT_MODEL_NAME_SIZE (32) ///< Max size of Model Name string in `otBorderAgentTxtDataInfo`. +#define OT_BORDER_AGENT_VENDOR_OUI_SIZE (3) ///< Size of Vendor OUI (in bytes) in `otBorderAgentTxtDataInfo`. /** * Represents the Connection Mode in a Border Agent State Bitmap. @@ -152,6 +153,7 @@ typedef struct otBorderAgentTxtDataInfo bool mHasExtAddress : 1; ///< Indicates whether Extended Address is present. bool mHasVendorName : 1; ///< Indicates whether Vendor Name is present. bool mHasModelName : 1; ///< Indicates whether Model Name is present. + bool mHasVendorOui : 1; ///< Indicates whether Vendor OUI is present. char mRecordVersion[OT_BORDER_AGENT_RECORD_VERSION_SIZE]; ///< Record Version string. otBorderAgentId mAgentId; ///< Agent ID. char mThreadVersion[OT_BORDER_AGENT_THREAD_VERSION_SIZE]; ///< Thread Version string. @@ -167,6 +169,7 @@ typedef struct otBorderAgentTxtDataInfo otExtAddress mExtAddress; ///< Extended Address. char mVendorName[OT_BORDER_AGENT_VENDOR_NAME_SIZE]; ///< Vendor Name string. char mModelName[OT_BORDER_AGENT_MODEL_NAME_SIZE]; ///< Model Name string. + uint8_t mVendorOui[OT_BORDER_AGENT_VENDOR_OUI_SIZE]; ///< Vendor OUI (24-bit). } otBorderAgentTxtDataInfo; /** diff --git a/include/openthread/instance.h b/include/openthread/instance.h index d32aaed89..c12e297a9 100644 --- a/include/openthread/instance.h +++ b/include/openthread/instance.h @@ -52,7 +52,7 @@ extern "C" { * * @note This number versions both OpenThread platform and user APIs. */ -#define OPENTHREAD_API_VERSION (589) +#define OPENTHREAD_API_VERSION (590) /** * @addtogroup api-instance diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index fa44003c7..9c5b9e9dc 100644 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -740,6 +740,12 @@ void Interpreter::OutputBorderAgentTxtDataInfo(uint8_t aIndentSize, const otBord OutputLine(aIndentSize, "ModelName: %s", aInfo.mModelName); } + if (aInfo.mHasVendorOui) + { + OutputLine(aIndentSize, "VendorOui: %02X-%02X-%02X", aInfo.mVendorOui[0], aInfo.mVendorOui[1], + aInfo.mVendorOui[2]); + } + if (aInfo.mHasStateBitmap) { uint8_t indent = aIndentSize + kIndentSize; diff --git a/src/core/meshcop/border_agent_txt_data.cpp b/src/core/meshcop/border_agent_txt_data.cpp index c57416d69..5e379b6a0 100644 --- a/src/core/meshcop/border_agent_txt_data.cpp +++ b/src/core/meshcop/border_agent_txt_data.cpp @@ -59,6 +59,7 @@ const char TxtData::Key::kOmrPrefix[] = "omr"; const char TxtData::Key::kExtAddress[] = "xa"; const char TxtData::Key::kVendorName[] = "vn"; const char TxtData::Key::kModelName[] = "mn"; +const char TxtData::Key::kVendorOui[] = "vo"; TxtData::TxtData(Instance &aInstance) : InstanceLocator(aInstance) @@ -478,6 +479,10 @@ void TxtData::Info::ProcessTxtEntry(const Dns::TxtEntry &aEntry) ReadStringValue(aEntry, mModelName); mHasModelName = true; } + else if (aEntry.MatchesKey(Key::kVendorOui)) + { + mHasVendorOui = ReadValue(aEntry, mVendorOui); + } } bool TxtData::Info::ReadValue(const Dns::TxtEntry &aEntry, void *aBuffer, uint16_t aSize) diff --git a/src/core/meshcop/border_agent_txt_data.hpp b/src/core/meshcop/border_agent_txt_data.hpp index 8794ae37f..b672ef41d 100644 --- a/src/core/meshcop/border_agent_txt_data.hpp +++ b/src/core/meshcop/border_agent_txt_data.hpp @@ -300,6 +300,7 @@ private: static const char kExtAddress[]; static const char kVendorName[]; static const char kModelName[]; + static const char kVendorOui[]; }; struct StateBitmap