[dnssd] echo all questions in the response on NameError (#11510)

This commit updates the DNSSD server/resolver to ensure it includes
the questions in the response message when the returned RCODE is
`NameError` (NXDOMAIN). It also clears the question count and any
partially appended content if there is a failure to append all
questions (when `kResponseServerFailure` (SERVFAIL) is returned).

It also adds a test case in `test_dns_client` to resolve a
non-existent name and validate the included questions.
This commit is contained in:
Abtin Keshavarzian
2025-05-19 12:09:12 -07:00
committed by GitHub
parent 55d657187b
commit ca3df1f057
2 changed files with 27 additions and 8 deletions
+13 -2
View File
@@ -238,8 +238,9 @@ void FinalizeTest(void)
//---------------------------------------------------------------------------------------------------------------------
static const char kHostName[] = "elden";
static const char kHostFullName[] = "elden.default.service.arpa.";
static const char kHostName[] = "elden";
static const char kHostFullName[] = "elden.default.service.arpa.";
static const char kNonExistingName[] = "noname.nodomain.";
static const char kService1Name[] = "_srv._udp";
static const char kService1FullName[] = "_srv._udp.default.service.arpa.";
@@ -804,6 +805,16 @@ void TestDnsClient(void)
VerifyOrQuit(addresses.Contains(sAddressInfo.mHostAddresses[index]));
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Validate DNS Client `ResolveAddress()` for an invalid (non-existing) name
sAddressInfo.Reset();
Log("ResolveAddress(%s)", kNonExistingName);
SuccessOrQuit(dnsClient->ResolveAddress(kNonExistingName, AddressCallback, sInstance));
AdvanceTime(100);
VerifyOrQuit(sAddressInfo.mCallbackCount == 1);
VerifyOrQuit(sAddressInfo.mError == kErrorNotFound);
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Validate DNS Client `ResolveIp4Address()`