mirror of
https://github.com/espressif/openthread.git
synced 2026-08-20 01:19:51 +00:00
[srp-server] log the content of processed SRP update message (#8131)
This commit updates the `Srp::Server` to log the processed info in a received SRP Update message, such as host name, lease times, host addresses, all services (and sub-types) being added or removed. The info is logged before invoking the "update handler" and/or committing the info into existing data. This change can help with debugging issues.
This commit is contained in:
@@ -1296,6 +1296,48 @@ exit:
|
||||
|
||||
void Server::InformUpdateHandlerOrCommit(Error aError, Host &aHost, const MessageMetadata &aMetadata)
|
||||
{
|
||||
#if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_INFO)
|
||||
if (aError == kErrorNone)
|
||||
{
|
||||
uint8_t numAddrs;
|
||||
const Ip6::Address *addrs;
|
||||
|
||||
LogInfo("Processed DNS update info");
|
||||
LogInfo(" Host:%s", aHost.GetFullName());
|
||||
LogInfo(" Lease:%u, key-lease:%u, ttl:%u", aHost.GetLease(), aHost.GetKeyLease(), aHost.GetTtl());
|
||||
|
||||
addrs = aHost.GetAddresses(numAddrs);
|
||||
|
||||
if (numAddrs == 0)
|
||||
{
|
||||
LogInfo(" No host address");
|
||||
}
|
||||
else
|
||||
{
|
||||
LogInfo(" %d host address(es):", numAddrs);
|
||||
|
||||
for (; numAddrs > 0; addrs++, numAddrs--)
|
||||
{
|
||||
LogInfo(" %s", addrs->ToString().AsCString());
|
||||
}
|
||||
}
|
||||
|
||||
for (const Service &service : aHost.GetServices())
|
||||
{
|
||||
char subLabel[Dns::Name::kMaxLabelSize];
|
||||
|
||||
IgnoreError(service.GetServiceSubTypeLabel(subLabel, sizeof(subLabel)));
|
||||
|
||||
LogInfo(" %s service '%s'%s%s", service.IsDeleted() ? "Deleting" : "Adding", service.GetInstanceName(),
|
||||
service.IsSubType() ? " subtype:" : "", subLabel);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LogInfo("Error %s processing received DNS update", ErrorToString(aError));
|
||||
}
|
||||
#endif // OT_SHOULD_LOG_AT(OT_LOG_LEVEL_INFO)
|
||||
|
||||
if ((aError == kErrorNone) && (mServiceUpdateHandler != nullptr))
|
||||
{
|
||||
UpdateMetadata *update = UpdateMetadata::Allocate(GetInstance(), aHost, aMetadata);
|
||||
@@ -1740,7 +1782,7 @@ void Server::Service::Log(Action aAction) const
|
||||
"Update existing", // (1) kUpdateExisting
|
||||
"Remove but retain name of", // (2) kRemoveButRetainName
|
||||
"Fully remove", // (3) kFullyRemove
|
||||
"LEASE expired for ", // (4) kLeaseExpired
|
||||
"LEASE expired for", // (4) kLeaseExpired
|
||||
"KEY LEASE expired for", // (5) kKeyLeaseExpired
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user