mdns implementation notes

This commit is contained in:
2026-01-12 17:58:08 +00:00
parent c393353ece
commit 9be9d167c3
+67
View File
@@ -1,3 +1,70 @@
// MDNS responder, mostly but not entirely standards-compliant
// ** Probe and Announce at startup
// at startup it does Probe and Announce for "all those resource
// records that a Multicast DNS responder desires to be unique on the
// local link". "Probe" means send packets as QU (unicast response)
// containing ANY requests for each name: 3 packets with 250ms between
// them; "Announce" means send 2 <= n <= 8 packets one second apart,
// containing all the records we know
// ** additional data in responses
// * for SRV, we send all the A and AAAA it names
// * for PTR "Service Instance Enumeration or Selective Instance
// Enumeration (subtype)": i.e. when the record data names an
// instance of the service, we sent the SRV and TXT records for the
// instance _and_ all the A/AAAA named by the SRV
// I haven't investigated what happens if the packet gets too
// large. There may be bugs
// ** don't answer queries if the answers in the query already include what we'd send
// This is unimplemented for now. mdns is so fricking noisy already I
// don't know if this is worth the extra effort
// ** set the CACHE_FLUSH bit on unique records
// "all the records with that name, rrtype, and rrclass are conceptually
// under the control or ownership of a single responder"
// ** NSEC?
// not done
// ** unicast response requested (QU)
// - top bit in the class field of a DNS question is the unicast-response bit
// - send response unicast, unless the record has not been sent recently
// ("within one quarter of its TTL")
// - also for queries received fom unicast
// - but verify the source is local lan
// - and the port is 5353 (otherwise see "legacy")
// [ mostly done; we don't check "has been sent recently" and as we
// didn't open a unicast socket then we can't receive queries from
// unicast ]
// ** Legacy Unicast Responses
// if source port != 5353
// - respond via unicast to source
// - query id and question
// - don't set cache-flush bit
// - ttl <= 10s
// This is implemented but has not really been tested
// ** response compression
// Unimplemented
use alloc::vec::Vec;
use alloc::string::String;
use alloc::collections::BTreeSet;