mirage/ocaml-dns — pull request #35 by infidel (2014-12-31 07:51:49+00:00)
Title: mDNS changes to Trie (no SOA) and Query (multi-question, etc.)

This is part of #28

The changes are:

1. mDNS doesn't use SOA nor delegation (RFC 6762 section 12), so some minor changes to Trie are required to handle this.

2. mDNS doesn't echo the questions in the response (RFC 6762 section 6), except in legacy mode, so a bool argument was added to Query.response_of_answer. Perhaps there are more elegant solutions?

3. Query.answer still exists but now Query.answer_multiple is also available for answering multiple questions in one query to produce a single answer (RFC 6762 section 5.3). One caveat is that responses may exceed the maximum message length, but that is not really specific to mDNS. Also, in theory multiple questions might require multiple separate response messages in unusual cases, but that is complicated so I am not dealing with it yet.

4. Query.answer_multiple takes an optional function to allow the caller to control the cache-flush bit. This bit is only set for records that have been "confirmed as unique". Using a callback requires minimal changes here but puts the burden of maintaining uniqueness state elsewhere. Do you think that it would be preferable to move such information into the dnsnode, even though it is mDNS-specific?

5. Query.answer_multiple takes an optional function to filter the answer, in order to support "known answer suppression" (RFC 6762 section 7.1). Again, using a callback requires minimal change to the core, but later on the mDNS-specific known answer suppression logic could move into the Query module if that turns out to be simpler.

6. A query for PTR returns additional records for SRV and TXT, to support efficient service discovery.

7. Trie.iter was added to support mDNS announcements.

8. Unit tests were added for some of the changes above. Let me know if you can see any specific gaps that need to be addressed for this PR.