[border-agent] manage mDNS MeshCoP service registrations (#11455)

This commit updates `BorderAgent` modules to directly manage the
registration of mDNS MeshCoP services. Previously, this was the
responsibility of the platform or higher-level code. This behavior is
enabled using `OPENTHREAD_CONFIG_BORDER_AGENT_MESHCOP_SERVICE_ENABLE`
configuration option.

When enabled, the `BorderAgent` module itself will register the
`_meshcop._udp` service name with properly formatted TXT data. As the
state changes, the service registration is updated accordingly.

If the ephemeral key feature is enabled and used, the `BorderAgent`
will also manage the registration of the `_meshcop-e._udp` service.

The implementation allows the service instance name to be configured
in different ways. The Thread specification recommends using a
user-friendly name, such as "<VendorName> <ProductName>". The
name can be set using a newly added configuration option, or
alternatively, using a newly added public API for projects where the
name needs to be set at run-time after device initialization.

This commit also updates `test_border_agent`, validating all the
newly added behaviors related to MeshCoP service registrations.
This commit is contained in:
Abtin Keshavarzian
2025-05-08 20:39:54 -07:00
committed by GitHub
parent 65098ebcc1
commit 293b41c808
15 changed files with 634 additions and 10 deletions
+8
View File
@@ -1849,6 +1849,14 @@ Core *InitTest(void)
VerifyOrQuit(sInstance != nullptr);
#if OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE
// Disable the Border Agent to prevent its attempt to
// register the `_meshcop._udp` service from
// interfering with this test.
sInstance->Get<MeshCoP::BorderAgent>().SetEnabled(false);
#endif
return &sInstance->Get<Core>();
}