[dns-client] add const to address pointer (#4399)

- Also change CLI implementation to avoid reference binding to null pointer.
This commit is contained in:
Jonathan Hui
2019-12-13 17:19:34 -08:00
committed by GitHub
parent 1ea4ed3eab
commit dff1694fe1
5 changed files with 25 additions and 22 deletions
+12 -9
View File
@@ -1078,23 +1078,26 @@ exit:
}
}
void Interpreter::HandleDnsResponse(void * aContext,
const char * aHostname,
otIp6Address *aAddress,
uint32_t aTtl,
otError aResult)
void Interpreter::HandleDnsResponse(void * aContext,
const char * aHostname,
const otIp6Address *aAddress,
uint32_t aTtl,
otError aResult)
{
static_cast<Interpreter *>(aContext)->HandleDnsResponse(aHostname, *static_cast<Ip6::Address *>(aAddress), aTtl,
aResult);
static_cast<Interpreter *>(aContext)->HandleDnsResponse(aHostname, static_cast<const Ip6::Address *>(aAddress),
aTtl, aResult);
}
void Interpreter::HandleDnsResponse(const char *aHostname, Ip6::Address &aAddress, uint32_t aTtl, otError aResult)
void Interpreter::HandleDnsResponse(const char *aHostname, const Ip6::Address *aAddress, uint32_t aTtl, otError aResult)
{
mServer->OutputFormat("DNS response for %s - ", aHostname);
if (aResult == OT_ERROR_NONE)
{
OutputIp6Address(aAddress);
if (aAddress != NULL)
{
OutputIp6Address(*aAddress);
}
mServer->OutputFormat(" TTL: %d\r\n", aTtl);
}
else