4.4 KiB
Discovery
This discovery module is an implementation of the mDNS and DNS-SD protocols as defined in RFC 6762 and RFC 6763. The protocols have been fully implemented, with the exceptions called out below.
Other modules in Open Screen use this module to advertise and discover presentation displays. If you wish to provide your own implementation of DNS-SD, implement the DNS-SD public interfaces and updating the linker rules. In this case, the public discovery layer will continue to function as described below.
Note that this DNS-SD implementation is fully generic and can be used for advertisement and discovery of any RFC 6763 compliant services.
How To Use This Module
In order to use the discovery module, embedders should only need to reference the public and common directories. The DNS-SD and mDNS layers should not be accessed. In order to encourage this behavior, DEPS rules have been defined.
The config directory provides parameters needed to configure the discovery module. Specifically:
- The openscreen::discovery::Config struct provides the required data to publish or discover service instances, such as a list of valid network interfaces or constants used to configure the underlying stack.
- The openscreen::discovery::ReportingClient provides a way for embedders to receive callbacks for errors which occur inside the discovery implementation.
The public directory provides wrappers around the DNS-SD protocol to simplify interacting with the internals of this module:
- The openscreen::discovery::DnsSdServicePublisher provides a simple interface for registering, updating, and de-registering DNS-SD service instances.
- The openscreen::discovery::DnsSdServiceWatcher provides an interface to begin and end querying for service types, providing callbacks for the embedder to be notified whenever an instance is discovered, changed, or deleted.
For an example use case of this module, see the standalone sender and standalone receiver code.
Limitations
This implementation has been created to fulfill the role of discovery for the CastV2 protocol. For this reason, some details or optimizations called out in the RFC documents had cost or additional required complexity that outweighed the added benefit they provided. As such, the following have not been fully implemented:
- Selective Instance Enumeration is not supported.
- Multiple SRV records for a single service instance are not supported.
- Multiple TXT records for a single service instance are not supported.
- Hosts which publish no TXT record are treated as invalid. However, hosts which publish an empty TXT record are valid.
- Duplicate Question Suppression has not been implemented.
Additionally, the following limitations should be noted:
- If network interface information is changed, the discovery stack must be re-initialized.
- If a fatal error occurs, the discovery stack must be re-initialized.