mirror of
https://github.com/espressif/openthread.git
synced 2026-09-03 15:50:06 +00:00
[netdiag] require 'RD:' prefix for vendor name on reference devices (#12233)
When `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` is active, this change mandates that the vendor name string MUST begin with the "RD:" prefix. This ensures that reference devices are clearly and consistently identifiable through network diagnostic queries. The enforcement is applied at two levels: - A compile-time `static_assert` is added to validate the default `OPENTHREAD_CONFIG_NET_DIAG_VENDOR_NAME` at build time. This uses a new `constexpr` helper utility `CheckConstStringPrefix()`. - A runtime check is added to `otThreadSetVendorName()`, which will now return `OT_ERROR_INVALID_ARGS` if an invalid name is provided on a reference device build. All related test configurations (`scan-build`, `toranj`, `nexus`) and CLI tests are updated to reflect this new requirement and validate it.
This commit is contained in:
@@ -466,6 +466,15 @@ static_assert(!ot::AreStringsInOrder("z", "abcd"), "AreStringsInOrder() failed")
|
||||
static_assert(!ot::AreStringsInOrder("0", ""), "AreStringsInOrder() failed");
|
||||
#endif
|
||||
|
||||
static_assert(ot::CheckConstStringPrefix("abc", "a"), "CheckConstStringPrefix() failed");
|
||||
static_assert(ot::CheckConstStringPrefix("abc", "ab"), "CheckConstStringPrefix() failed");
|
||||
static_assert(ot::CheckConstStringPrefix("abc", "abc"), "CheckConstStringPrefix() failed");
|
||||
static_assert(ot::CheckConstStringPrefix("abc", ""), "CheckConstStringPrefix() failed");
|
||||
|
||||
static_assert(!ot::CheckConstStringPrefix("abc", "b"), "CheckConstStringPrefix() failed");
|
||||
static_assert(!ot::CheckConstStringPrefix("abc", "abcd"), "CheckConstStringPrefix() failed");
|
||||
static_assert(!ot::CheckConstStringPrefix("", "a"), "CheckConstStringPrefix() failed");
|
||||
|
||||
} // namespace ot
|
||||
|
||||
int main(void)
|
||||
|
||||
Reference in New Issue
Block a user