[dns-client] add ServiceMode to control service resolution (#8772)

This commit updates DNS client to add `otDnsServiceMode` to the
`otDnsQueryConfig`. This new config property determines which records
to query and allow the API user to control the behavior during
service resolution: We can query for SRV record only or TXT record
only, or query for both SRV and TXT records in the same message, or
in parallel in different messages, or an "optimized" mode where
client will first try to query for both records together in the same
message but if server responds with an error, it then retries using
two parallel separate queries.

This gives flexibility and control to the API user. It also helps
address situations where the server (DNS resolver) may not accept
queries with more than one questions.

To support this new feature, this commit updates and enhances the
internal design of the `Dns::Client`. A new mechanism is added to
allow multiple `Query` instances to be associated with each other
under a main `Query` and responses for the related queries are saved
until all are received and validated before finalizing the main
`Query` and invoking the callback and allowing caller to retrieve the
info.

This commit also adds a detailed unit test `test_dns_client` which
covers DNS client browse and service resolution validating behavior
under all service modes. In order to test `Client` functionality,
this commit also adds a `TestMode` in `Dns::ServiceDiscovery::Server`
allowing us to change server behavior, e.g., reject messages with
more than one question in query.
This commit is contained in:
Abtin Keshavarzian
2023-04-05 15:49:08 -07:00
committed by GitHub
parent e587d43e4b
commit 3ffe8516f7
13 changed files with 1515 additions and 283 deletions
@@ -39,7 +39,7 @@ switch_node 1
set addr_1 [get_ipaddr mleid]
switch_node 2
send "dns resolve ipv6.google.com $addr_1 2000 6000 4 1 tcp\n"
send "dns resolve ipv6.google.com $addr_1 2000 6000 4 1 def tcp\n"
expect "DNS response for ipv6.google.com"
expect_line "Done"