[srp-server] introduce "fast start mode" feature (#11305)

This commit adds "Fast Start Mode" feature for SRP server. This
feature is designed for scenarios where a device, often a mobile
device, needs to act as a provisional SRP server (e.g., functioning
as a temporary Border Router). The SRP server function is enabled
only if no other Border Routers are already providing the SRP
service within the Thread network. A common use case is a mobile
device joining a Thread network where it may be the first, or only,
BR. Importantly, Fast Start Mode allows the device to quickly start
its SRP server functionality upon joining the network, allowing other
Thread devices to quickly connect and register their services without
the typical delays associated with standard Border Router
initialization and SRP server startup (using NetData Publisher).
This commit is contained in:
Abtin Keshavarzian
2025-02-28 13:49:30 -08:00
committed by GitHub
parent 31f2897951
commit babbccd4c6
15 changed files with 428 additions and 8 deletions
+1
View File
@@ -250,6 +250,7 @@ ot_option(OT_SNTP_CLIENT OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE "SNTP client")
ot_option(OT_SRP_ADV_PROXY OPENTHREAD_CONFIG_SRP_SERVER_ADVERTISING_PROXY_ENABLE "SRP advertising proxy")
ot_option(OT_SRP_CLIENT OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE "SRP client")
ot_option(OT_SRP_SERVER OPENTHREAD_CONFIG_SRP_SERVER_ENABLE "SRP server")
ot_option(OT_SRP_SERVER_FAST_START_MDOE OPENTHREAD_CONFIG_SRP_SERVER_FAST_START_MODE_ENABLE "SRP server fast start")
ot_option(OT_TCP OPENTHREAD_CONFIG_TCP_ENABLE "TCP")
ot_option(OT_TIME_SYNC OPENTHREAD_CONFIG_TIME_SYNC_ENABLE "time synchronization service")
ot_option(OT_TREL OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE "TREL radio link for Thread over Infrastructure feature")
+1 -1
View File
@@ -52,7 +52,7 @@ extern "C" {
*
* @note This number versions both OpenThread platform and user APIs.
*/
#define OPENTHREAD_API_VERSION (480)
#define OPENTHREAD_API_VERSION (481)
/**
* @addtogroup api-instance
+51
View File
@@ -272,6 +272,57 @@ void otSrpServerSetAutoEnableMode(otInstance *aInstance, bool aEnabled);
*/
bool otSrpServerIsAutoEnableMode(otInstance *aInstance);
/**
* Enables the "Fast Start Mode" on the SRP server.
*
* Requires the `OPENTHREAD_CONFIG_SRP_SERVER_FAST_START_MODE_ENABLE` feature to be enabled.
*
* The Fast Start Mode is designed for scenarios where a device, often a mobile device, needs to act as a provisional
* SRP server (e.g., functioning as a temporary Border Router). The SRP server function is enabled only if no other
* Border Routers (BRs) are already providing the SRP service within the Thread network. A common use case is a mobile
* device joining a Thread network where it may be the first, or only, BR. Importantly, Fast Start Mode allows the
* device to quickly start its SRP server functionality upon joining the network, allowing other Thread devices to
* quickly connect and register their services without the typical delays associated with standard Border Router
* initialization (and SRP server startup).
*
* When Fast Start Mode is enabled, the SRP server manages when to start or stop based on the presence of other BRs,
* following this process:
* - Upon initial attachment to the Thread network, the device immediately inspects the received Network Data for any
* existing "SRP/DNS" entries. These entries indicate the presence of other active BRs providing SRP server service:
* - If no "SRP/DNS" entries from other BRs are found, the device immediately enables its own SRP server. This
* activation uses `OT_SRP_SERVER_ADDRESS_MODE_UNICAST_FORCE_ADD`, which bypasses the usual delay associated with
* the standard Network Data publisher, directly adding its own "SRP/DNS unicast" entry to the Network Data.
* - If "SRP/DNS" entries from other BRs are detected, the device will not enable its SRP server, deferring to the
* existing ones.
* - After starting its SRP server in Fast Start Mode, the device continuously monitors the Network Data. If, at any
* point, new "SRP/DNS" entries appear (indicating that another BR has become active), the device automatically
* disables its own SRP server functionality, relinquishing the role to the newly available BR.
*
* The Fast Start Mode can be enabled when the device is in the detached or disabled state, the SRP server is currently
* disabled, and "auto-enable mode" is not in use (i.e., `otSrpServerIsAutoEnableMode()` returns `false`).
*
* After successfully enabling Fast Start Mode, it can be disabled by a direct call to `otSrpServerSetEnabled()`,
* explicitly enabling or disabling the SRP server function.
*
* @param[in] aInstance A pointer to the OpenThread instance.
*
* @retval OT_ERROR_NONE Fast Start Mode was successfully enabled.
* @retval OT_ERROR_INVALID_STATE Cannot enable Fast Start Mode (e.g., already attached or server already enabled).
*/
otError otSrpServerEnableFastStartMode(otInstance *aInstance);
/**
* Indicates whether the Fast Start Mode is enabled or disabled.
*
* Requires `OPENTHREAD_CONFIG_SRP_SERVER_FAST_START_MODE_ENABLE` feature to be enabled.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
* @retval TRUE The fast-start mode is enabled.
* @retval FALSE The fast-start mode is disabled.
*/
bool otSrpServerIsFastStartmodeEnabled(otInstance *aInstance);
/**
* Returns SRP server TTL configuration.
*
+1
View File
@@ -80,6 +80,7 @@ OT_BUILD_OPTIONS=(
"-DOT_SRP_ADV_PROXY=ON"
"-DOT_SRP_CLIENT=ON"
"-DOT_SRP_SERVER=ON"
"-DOT_SRP_SERVER_FAST_START_MDOE=ON"
"-DOT_UPTIME=ON"
"-DOT_VENDOR_NAME=OpenThread"
"-DOT_VENDOR_MODEL=Scan-build"
+1
View File
@@ -110,6 +110,7 @@ OT_POSIX_SIM_COMMON_OPTIONS=(
"-DOT_SNTP_CLIENT=ON"
"-DOT_SRP_CLIENT=ON"
"-DOT_SRP_SERVER=ON"
"-DOT_SRP_SERVER_FAST_START_MDOE=ON"
"-DOT_UPTIME=ON"
)
readonly OT_POSIX_SIM_COMMON_OPTIONS
+1
View File
@@ -109,6 +109,7 @@ build_simulation()
"-DOT_SERVICE=ON"
"-DOT_SRP_CLIENT=ON"
"-DOT_SRP_SERVER=ON"
"-DOT_SRP_SERVER_FAST_START_MDOE=ON"
"-DOT_UPTIME=ON"
"-DOT_THREAD_VERSION=${version}"
)
+24
View File
@@ -33,6 +33,7 @@ auto
disable
domain
enable
faststart
help
host
lease
@@ -129,6 +130,29 @@ Enable the SRP server.
Done
```
### faststart
Usage: `srp server faststart [enable]`
This command requires that `OPENTHREAD_CONFIG_SRP_SERVER_FAST_START_MODE_ENABLE` be enabled.
Enables the "Fast Start Mode" on the SRP server.
The Fast Start Mode is designed for scenarios where a device, often a mobile device, needs to act as a provisional SRP server (e.g., functioning as a temporary Border Router). The SRP server function is enabled only if no other Border Routers (BRs) are already providing the SRP service within the Thread network. Importantly, Fast Start Mode allows the device to quickly start its SRP server functionality upon joining the network, allowing other Thread devices to quickly connect and register their services without the typical delays associated with standard Border Router initialization (and SRP server startup).
The Fast Start Mode can be enabled when the device is in the detached or disabled state, the SRP server is currently disabled, and "auto-enable mode" is not in use.
After successfully enabling Fast Start Mode, it can be disabled by a direct command to enable/disable the SRP server, using `srp server [enable/disable]`.
```bash
> srp server faststart enable
Done
> srp server faststart
Enabled
Done
```
### host
Usage: `srp server host`
+59
View File
@@ -166,6 +166,62 @@ template <> otError SrpServer::Process<Cmd("domain")>(Arg aArgs[])
return error;
}
#if OPENTHREAD_CONFIG_SRP_SERVER_FAST_START_MODE_ENABLE
/**
* @cli srp server faststart (enable)
* @code
* srp server faststart enable
* Done
* @endcode
* @code
* srp server faststart
* Enabled
* Done
* @endcode
* @cparam srp server faststart [@ca{enable}]
* @par
* Enables the "Fast Start Mode" on the SRP server.
* @par
* The Fast Start Mode is designed for scenarios where a device, often a mobile device, needs to act as a provisional
* SRP server (e.g., functioning as a temporary Border Router). The SRP server function is enabled only if no other
* Border Routers (BRs) are already providing the SRP service within the Thread network. Importantly, Fast Start Mode
* allows the device to quickly start its SRP server functionality upon joining the network, allowing other Thread
* devices to quickly connect and register their services without the typical delays associated with standard Border
* Router initialization (and SRP server startup).
* @par
* The Fast Start Mode can be enabled when the device is in the detached or disabled state, the SRP server is currently
* disabled, and "auto-enable mode" is not in use.
* @par
* After successfully enabling Fast Start Mode, it can be disabled by a direct command to enable/disable the SRP
* server, using `srp server [enable/disable]`.
* @par
* This command requires that `OPENTHREAD_CONFIG_SRP_SERVER_FAST_START_MODE_ENABLE` be enabled.
* @moreinfo{@srp}.
* @sa otSrpServerIsFastStartmodeEnabled
* @sa otSrpServerEnableFastStartMode
*/
template <> otError SrpServer::Process<Cmd("faststart")>(Arg aArgs[])
{
otError error = OT_ERROR_NONE;
if (aArgs[0].IsEmpty())
{
OutputEnabledDisabledStatus(otSrpServerIsFastStartmodeEnabled(GetInstancePtr()));
}
else if (aArgs[0] == "enable")
{
error = otSrpServerEnableFastStartMode(GetInstancePtr());
}
else
{
error = OT_ERROR_INVALID_ARGS;
}
return error;
}
#endif // OPENTHREAD_CONFIG_SRP_SERVER_FAST_START_MODE_ENABLE
/**
* @cli srp server state
* @code
@@ -552,6 +608,9 @@ otError SrpServer::Process(Arg aArgs[])
CmdEntry("disable"),
CmdEntry("domain"),
CmdEntry("enable"),
#if OPENTHREAD_CONFIG_SRP_SERVER_FAST_START_MODE_ENABLE
CmdEntry("faststart"),
#endif
CmdEntry("host"),
CmdEntry("lease"),
CmdEntry("seqnum"),
+12
View File
@@ -90,6 +90,18 @@ bool otSrpServerIsAutoEnableMode(otInstance *aInstance)
}
#endif
#if OPENTHREAD_CONFIG_SRP_SERVER_FAST_START_MODE_ENABLE
otError otSrpServerEnableFastStartMode(otInstance *aInstance)
{
return AsCoreType(aInstance).Get<Srp::Server>().EnableFastStartMode();
}
bool otSrpServerIsFastStartmodeEnabled(otInstance *aInstance)
{
return AsCoreType(aInstance).Get<Srp::Server>().IsFastStartModeEnabled();
}
#endif
void otSrpServerGetTtlConfig(otInstance *aInstance, otSrpServerTtlConfig *aTtlConfig)
{
AsCoreType(aInstance).Get<Srp::Server>().GetTtlConfig(AsCoreType(aTtlConfig));
+4
View File
@@ -151,6 +151,10 @@ void Notifier::EmitEvents(void)
#if OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE
Get<Srp::Client>().HandleNotifierEvents(events);
#endif
#if OPENTHREAD_CONFIG_SRP_SERVER_ENABLE && OPENTHREAD_CONFIG_SRP_SERVER_FAST_START_MODE_ENABLE
Get<Srp::Server>().HandleNotifierEvents(events);
#endif
#if OPENTHREAD_CONFIG_NETDATA_PUBLISHER_ENABLE
// The `NetworkData::Publisher` is notified last (e.g., after SRP
// client) to allow other modules to request changes to what is
+18
View File
@@ -120,6 +120,24 @@
#define OPENTHREAD_CONFIG_SRP_SERVER_ADVERTISING_PROXY_ENABLE 0
#endif
/**
* @def OPENTHREAD_CONFIG_SRP_SERVER_FAST_START_MODE_ENABLE
*
* The Fast Start Mode is designed for scenarios where a device, often a mobile device, needs to act as a provisional
* SRP server (e.g., functioning as a temporary Border Router). The SRP server function is enabled only if no other
* Border Routers (BRs) are already providing the SRP service within the Thread network. A common use case is a mobile
* device joining a Thread network where it may be the first, or only, BR. Importantly, Fast Start Mode allows the
* device to quickly start its SRP server functionality upon joining the network, allowing other Thread devices to
* quickly connect and register their services without the typical delays associated with standard Border Router
* initialization (and SRP server startup).
*
* The Fast Start Mode can be enabled using `otSrpServerEnableFastStartMode()`. More details about behavior and
* restrictions are provided in the documentation of this API.
*/
#ifndef OPENTHREAD_CONFIG_SRP_SERVER_FAST_START_MODE_ENABLE
#define OPENTHREAD_CONFIG_SRP_SERVER_FAST_START_MODE_ENABLE 0
#endif
/**
* @}
*/
+101
View File
@@ -89,6 +89,9 @@ Server::Server(Instance &aInstance)
#if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
, mAutoEnable(false)
#endif
#if OPENTHREAD_CONFIG_SRP_SERVER_FAST_START_MODE_ENABLE
, mFastStartMode(false)
#endif
{
IgnoreError(SetDomain(kDefaultDomain));
}
@@ -124,6 +127,9 @@ void Server::SetEnabled(bool aEnabled)
#if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
mAutoEnable = false;
#endif
#if OPENTHREAD_CONFIG_SRP_SERVER_FAST_START_MODE_ENABLE
mFastStartMode = false;
#endif
if (aEnabled)
{
@@ -210,6 +216,101 @@ exit:
}
#endif
#if OPENTHREAD_CONFIG_SRP_SERVER_FAST_START_MODE_ENABLE
Error Server::EnableFastStartMode(void)
{
Error error = kErrorNone;
VerifyOrExit(!mFastStartMode);
VerifyOrExit(!Get<Mle::Mle>().IsAttached(), error = kErrorInvalidState);
VerifyOrExit(mState == kStateDisabled, error = kErrorInvalidState);
#if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
VerifyOrExit(!mAutoEnable, error = kErrorInvalidState);
#endif
mFastStartMode = true;
LogInfo("FastStartMode enabled");
exit:
return error;
}
void Server::HandleNotifierEvents(Events aEvents)
{
VerifyOrExit(mFastStartMode);
if (mState == kStateDisabled)
{
VerifyOrExit(aEvents.ContainsAny(kEventThreadRoleChanged | kEventThreadNetdataChanged));
VerifyOrExit(Get<Mle::Mle>().IsAttached());
if (!NetDataContainsOtherSrpServers())
{
LogInfo("FastStartMode - No SRP server in NetData");
mPrevAddressMode = mAddressMode;
IgnoreError(SetAddressMode(kAddressModeUnicastForceAdd));
Enable();
}
}
else
{
VerifyOrExit(aEvents.Contains(kEventThreadNetdataChanged));
if (NetDataContainsOtherSrpServers())
{
LogInfo("FastStartMode - New SRP server entry in NetData");
Disable();
IgnoreError(SetAddressMode(mPrevAddressMode));
}
}
exit:
return;
}
bool Server::NetDataContainsOtherSrpServers(void) const
{
bool contains = false;
NetworkData::Service::DnsSrpAnycastInfo anycastInfo;
NetworkData::Service::DnsSrpUnicastInfo unicastInfo;
NetworkData::Service::Manager::Iterator iterator;
if (Get<NetworkData::Service::Manager>().FindPreferredDnsSrpAnycastInfo(anycastInfo) == kErrorNone)
{
contains = true;
ExitNow();
}
iterator.Reset();
if (Get<NetworkData::Service::Manager>().GetNextDnsSrpUnicastInfo(
iterator, NetworkData::Service::kAddrInServiceData, unicastInfo) == kErrorNone)
{
contains = true;
ExitNow();
}
iterator.Reset();
while (Get<NetworkData::Service::Manager>().GetNextDnsSrpUnicastInfo(
iterator, NetworkData::Service::kAddrInServerData, unicastInfo) == kErrorNone)
{
if (!Get<Mle::Mle>().HasRloc16(unicastInfo.mRloc16))
{
contains = true;
ExitNow();
}
}
exit:
return contains;
}
#endif // OPENTHREAD_CONFIG_SRP_SERVER_FAST_START_MODE_ENABLE
Server::TtlConfig::TtlConfig(void)
{
mMinTtl = kDefaultMinTtl;
+39
View File
@@ -109,6 +109,7 @@ class AdvertisingProxy;
*/
class Server : public InstanceLocator, private NonCopyable
{
friend class ot::Notifier;
friend class NetworkData::Publisher;
friend class UpdateMetadata;
friend class Service;
@@ -762,6 +763,34 @@ public:
bool IsAutoEnableMode(void) const { return mAutoEnable; }
#endif
#if OPENTHREAD_CONFIG_SRP_SERVER_FAST_START_MODE_ENABLE
/**
* Enables the "Fast Start Mode" on the SRP server.
*
* The Fast Start Mode is designed for scenarios where a device, often a mobile device, needs to act as a
* provisional SRP server (e.g., functioning as a temporary Border Router). The SRP server function is enabled only
* if no other Border Routers (BRs) are already providing the SRP service within the Thread network. A common use
* case is a mobile device joining a Thread network where it may be the first, or only, BR. Importantly, Fast
* Start Mode allows the device to quickly start its SRP server functionality upon joining the network, allowing
* other Thread devices to quickly connect and register their services without the typical delays associated with
* standard Border Router initialization (and SRP server startup).
*
* Please refer to `otSrpServerEnableFastStartMode()` for more details.
*
* @retval kErrorNone Fast Start Mode was successfully enabled.
* @retval kErrorInvalidState Cannot enable Fast Start Mode (e.g., already attached or server already enabled).
*/
Error EnableFastStartMode(void);
/**
* Indicates whether the Fast Start Mode is enabled or disabled.
*
* @retval TRUE The fast-start mode is enabled.
* @retval FALSE The fast-start mode is disabled.
*/
bool IsFastStartModeEnabled(void) const { return mFastStartMode; }
#endif
/**
* Returns the TTL configuration.
*
@@ -919,6 +948,11 @@ private:
Error HandleDnssdServerUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
#endif
#if OPENTHREAD_CONFIG_SRP_SERVER_FAST_START_MODE_ENABLE
void HandleNotifierEvents(Events aEvents);
bool NetDataContainsOtherSrpServers(void) const;
#endif
void HandleNetDataPublisherEvent(NetworkData::Publisher::Event aEvent);
ServiceUpdateId AllocateServiceUpdateId(void) { return mServiceUpdateId++; }
@@ -1014,6 +1048,11 @@ private:
bool mAutoEnable : 1;
#endif
#if OPENTHREAD_CONFIG_SRP_SERVER_FAST_START_MODE_ENABLE
bool mFastStartMode : 1;
AddressMode mPrevAddressMode;
#endif
otSrpServerResponseCounters mResponseCounters;
};
@@ -43,6 +43,8 @@
#define OPENTHREAD_CONFIG_PLATFORM_INFO "SIMULATION-toranj"
#endif
#define OPENTHREAD_CONFIG_SRP_SERVER_FAST_START_MODE_ENABLE 1
#define OPENTHREAD_CONFIG_COAP_API_ENABLE 1
#define OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE 1
+113 -7
View File
@@ -185,7 +185,7 @@ void AdvanceTime(uint32_t aDuration)
sNow = time;
}
void InitTest(void)
void InitTest(bool aStartThread = true)
{
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Initialize OT instance.
@@ -208,15 +208,18 @@ void InitTest(void)
otDatasetConvertToTlvs(&dataset, &datasetTlvs);
SuccessOrQuit(otDatasetSetActiveTlvs(sInstance, &datasetTlvs));
SuccessOrQuit(otIp6SetEnabled(sInstance, true));
SuccessOrQuit(otThreadSetEnabled(sInstance, true));
if (aStartThread)
{
SuccessOrQuit(otIp6SetEnabled(sInstance, true));
SuccessOrQuit(otThreadSetEnabled(sInstance, true));
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Ensure device starts as leader.
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Ensure device starts as leader.
AdvanceTime(10000);
AdvanceTime(10000);
VerifyOrQuit(otThreadGetDeviceRole(sInstance) == OT_DEVICE_ROLE_LEADER);
VerifyOrQuit(otThreadGetDeviceRole(sInstance) == OT_DEVICE_ROLE_LEADER);
}
}
void FinalizeTest(void)
@@ -1275,6 +1278,106 @@ void TestSrpServerAddressModeForceAdd(void)
Log("End of TestSrpServerAddressModeForceAdd");
}
#if OPENTHREAD_CONFIG_SRP_SERVER_FAST_START_MODE_ENABLE
void TestSrpServerFastStartMode(void)
{
Srp::Server *srpServer;
otExternalRouteConfig route;
Ip6::Address address;
Log("--------------------------------------------------------------------------------------------");
Log("TestSrpServerFastStartMode");
InitTest(/* aStartThread */ false);
srpServer = &sInstance->Get<Srp::Server>();
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Configure SRP server to use the "Fast Start Mode"/
SuccessOrQuit(srpServer->EnableFastStartMode());
VerifyOrQuit(srpServer->IsFastStartModeEnabled());
VerifyOrQuit(srpServer->GetState() == Srp::Server::kStateDisabled);
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Bring the IPv6 interface up and start Thread operation.
SuccessOrQuit(otIp6SetEnabled(sInstance, true));
SuccessOrQuit(otThreadSetEnabled(sInstance, true));
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Ensure that as soon as device attaches, the SRP server is started.
while (otThreadGetDeviceRole(sInstance) == OT_DEVICE_ROLE_DETACHED)
{
AdvanceTime(100);
}
VerifyOrQuit(otThreadGetDeviceRole(sInstance) == OT_DEVICE_ROLE_LEADER);
VerifyOrQuit(srpServer->GetState() == Srp::Server::kStateRunning);
VerifyOrQuit(srpServer->GetAddressMode() == Srp::Server::kAddressModeUnicastForceAdd);
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Add new entries in Network Data to trigger an "NetDataChanged" event
// and ensure that the SRP server continues to run.
AdvanceTime(10 * 1000);
VerifyOrQuit(srpServer->GetState() == Srp::Server::kStateRunning);
ClearAllBytes(route);
route.mStable = true;
SuccessOrQuit(otBorderRouterAddRoute(sInstance, &route));
SuccessOrQuit(otBorderRouterRegister(sInstance));
AdvanceTime(1 * 1000);
VerifyOrQuit(srpServer->GetState() == Srp::Server::kStateRunning);
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Publish an "DNS/SRP" entry in Network Data and ensure that this is
// correctly detected by the "Fast Start Mode" and triggers SRP server to be
// disabled.
SuccessOrQuit(address.FromString("fd00::1"));
otNetDataPublishDnsSrpServiceUnicast(sInstance, &address, /* aPort */ 1234, 0);
AdvanceTime(10 * 1000);
VerifyOrQuit(otNetDataIsDnsSrpServiceAdded(sInstance));
VerifyOrQuit(srpServer->IsFastStartModeEnabled());
VerifyOrQuit(srpServer->GetState() == Srp::Server::kStateDisabled);
// Ensure the original AddressMode is restored on SRP server
VerifyOrQuit(srpServer->GetAddressMode() == Srp::Server::kAddressModeUnicast);
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Unpublish the "DNS/SRP" entry in Network Data and check that
// the "Fast Start Mode" causes the SRP server to start again.
otNetDataUnpublishDnsSrpService(sInstance);
AdvanceTime(25 * 1000);
VerifyOrQuit(!otNetDataIsDnsSrpServiceAdded(sInstance));
VerifyOrQuit(srpServer->IsFastStartModeEnabled());
VerifyOrQuit(srpServer->GetState() == Srp::Server::kStateRunning);
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Finalize OT instance and validate all heap allocations are freed.
Log("Finalizing OT instance");
FinalizeTest();
Log("End of TestSrpServerFastStartMode");
}
#endif // OPENTHREAD_CONFIG_SRP_SERVER_FAST_START_MODE_ENABLE
#endif // ENABLE_SRP_TEST
} // namespace ot
@@ -1292,6 +1395,9 @@ int main(void)
ot::TestSrpClientDelayedResponse();
#endif
ot::TestSrpServerAddressModeForceAdd();
#if OPENTHREAD_CONFIG_SRP_SERVER_FAST_START_MODE_ENABLE
ot::TestSrpServerFastStartMode();
#endif
printf("All tests passed\n");
#else