mirror of
https://github.com/espressif/openthread.git
synced 2026-08-02 17:17:45 +00:00
[srp-server] update how/where the host addresses are checked (#6927)
This commit changes the check for the number of host addresses in a newly received SRP update message such that if we have a non-zero lease, we ensure that there is at least one valid address. It also moves this check from `ProcessHostDescriptionInstruction()` to after the Lease Option in the Additional Section is parsed (in `ProcessAdditionalSection()`) so that we check after we determine the host lease interval and whether the host is being removed or registered.
This commit is contained in:
committed by
Jonathan Hui
parent
6895edda59
commit
da629d63ff
@@ -693,14 +693,10 @@ Error Server::ProcessHostDescriptionInstruction(Host & aHost,
|
||||
|
||||
VerifyOrExit(aHost.GetFullName() != nullptr, error = kErrorFailed);
|
||||
VerifyOrExit(aHost.GetKey() != nullptr, error = kErrorFailed);
|
||||
{
|
||||
uint8_t hostAddressesNum;
|
||||
|
||||
aHost.GetAddresses(hostAddressesNum);
|
||||
|
||||
// There MUST be at least one valid address if we have nonzero lease.
|
||||
VerifyOrExit(aHost.GetLease() > 0 || hostAddressesNum > 0, error = kErrorFailed);
|
||||
}
|
||||
// We check the number of host addresses after processing of the
|
||||
// Lease Option in the Addition Section and determining whether
|
||||
// the host is being removed or registered.
|
||||
|
||||
exit:
|
||||
return error;
|
||||
@@ -906,6 +902,16 @@ Error Server::ProcessAdditionalSection(Host * aHost,
|
||||
aHost->SetLease(leaseOption.GetLeaseInterval());
|
||||
aHost->SetKeyLease(leaseOption.GetKeyLeaseInterval());
|
||||
|
||||
if (aHost->GetLease() > 0)
|
||||
{
|
||||
uint8_t hostAddressesNum;
|
||||
|
||||
aHost->GetAddresses(hostAddressesNum);
|
||||
|
||||
// There MUST be at least one valid address if we have nonzero lease.
|
||||
VerifyOrExit(hostAddressesNum > 0, error = kErrorFailed);
|
||||
}
|
||||
|
||||
// SIG(0).
|
||||
|
||||
sigOffset = aOffset;
|
||||
|
||||
Reference in New Issue
Block a user