mirror of
https://github.com/espressif/openthread.git
synced 2026-06-05 21:14:49 +00:00
[nexus] remove mSrpHostAddresses from Node class (#12850)
This commit removes the `mSrpHostAddresses` array from the `Node` class in the Nexus platform. The array was specific to SRP client testing and was occupying unnecessary memory for every simulated node instance. Instead of keeping this state inside the `Node` abstraction, a local `hostAddrs` array is now declared within the `Test_1_3_SRP_TC_1()` test function. This local array safely persists for the duration of the test, allowing `Srp::Client::SetHostAddresses()` to use the provided pointer without relying on a global or node-level member.
This commit is contained in:
committed by
GitHub
parent
bb31558fac
commit
d2aba43057
@@ -161,8 +161,6 @@ public:
|
||||
|
||||
Node *mNext;
|
||||
|
||||
Ip6::Address mSrpHostAddresses[OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_MAX_HOST_ADDRESSES];
|
||||
|
||||
private:
|
||||
Node(void)
|
||||
: Platform(static_cast<Instance &>(*this))
|
||||
|
||||
@@ -83,8 +83,6 @@ static constexpr uint16_t kSrpUpdatedPort = 55556;
|
||||
|
||||
void Test_1_3_SRP_TC_1(const char *aJsonFileName)
|
||||
{
|
||||
Srp::Client::Service service;
|
||||
|
||||
/**
|
||||
* 2.1. [1.3] [CERT] Register Single Service
|
||||
*
|
||||
@@ -110,6 +108,9 @@ void Test_1_3_SRP_TC_1(const char *aJsonFileName)
|
||||
Node &ed1 = nexus.CreateNode();
|
||||
Node ð1 = nexus.CreateNode();
|
||||
|
||||
Srp::Client::Service service;
|
||||
Ip6::Address hostAddrs[2];
|
||||
|
||||
br1.SetName("BR_1");
|
||||
ed1.SetName("ED_1");
|
||||
eth1.SetName("Eth_1");
|
||||
@@ -188,17 +189,15 @@ void Test_1_3_SRP_TC_1(const char *aJsonFileName)
|
||||
|
||||
SuccessOrQuit(ed1.Get<Srp::Client>().SetHostName(kSrpHostName));
|
||||
|
||||
uint8_t addrsCount = 0;
|
||||
|
||||
ed1.mSrpHostAddresses[addrsCount++] = ed1.Get<Mle::Mle>().GetMeshLocalEid();
|
||||
hostAddrs[0] = ed1.Get<Mle::Mle>().GetMeshLocalEid();
|
||||
|
||||
{
|
||||
Ip6::Prefix omrPrefix;
|
||||
SuccessOrQuit(br1.Get<BorderRouter::RoutingManager>().GetOmrPrefix(omrPrefix));
|
||||
ed1.mSrpHostAddresses[addrsCount++] = ed1.FindMatchingAddress(omrPrefix.ToString().AsCString());
|
||||
hostAddrs[1] = ed1.FindMatchingAddress(omrPrefix.ToString().AsCString());
|
||||
}
|
||||
|
||||
SuccessOrQuit(ed1.Get<Srp::Client>().SetHostAddresses(ed1.mSrpHostAddresses, addrsCount));
|
||||
SuccessOrQuit(ed1.Get<Srp::Client>().SetHostAddresses(hostAddrs, 2));
|
||||
|
||||
ClearAllBytes(service);
|
||||
service.mName = kSrpServiceType;
|
||||
@@ -374,8 +373,8 @@ void Test_1_3_SRP_TC_1(const char *aJsonFileName)
|
||||
ed1.Get<Srp::Client>().ClearHostAndServices();
|
||||
SuccessOrQuit(ed1.Get<Srp::Client>().SetHostName(kSrpHostName));
|
||||
|
||||
ed1.mSrpHostAddresses[0] = ed1.Get<Mle::Mle>().GetMeshLocalEid();
|
||||
SuccessOrQuit(ed1.Get<Srp::Client>().SetHostAddresses(ed1.mSrpHostAddresses, 1));
|
||||
hostAddrs[0] = ed1.Get<Mle::Mle>().GetMeshLocalEid();
|
||||
SuccessOrQuit(ed1.Get<Srp::Client>().SetHostAddresses(hostAddrs, 1));
|
||||
|
||||
// Update existing service
|
||||
ClearAllBytes(service);
|
||||
|
||||
Reference in New Issue
Block a user