mDNS: respond to probe via multicast added

The host only responded to a probe query via unicast because
according to the RFC, a probe should have the QU bit on.
This is a should and not a must so we need to be careful.
We added multicast probe answering support with the needed timouts.
Avahi for example probes with the QM queries. With this commit the
conflict is resolved.
This commit is contained in:
Jasper Verschueren
2018-11-14 15:38:36 +01:00
committed by Dirk Ziegelmeier
parent 530a4ccdce
commit 861ce296b9
4 changed files with 180 additions and 50 deletions

View File

@@ -83,6 +83,14 @@ extern "C" {
*/
#define MDNS_MULTICAST_TIMEOUT 1000
/* RFC6762 section 6:
* In this special case only, when responding via multicast to a probe, a
* Multicast DNS responder is only required to delay its transmission as
* necessary to ensure an interval of at least 250 ms since the last time the
* record was multicast on that interface.
*/
#define MDNS_MULTICAST_PROBE_TIMEOUT 250
/* RFC6762 section 5.4:
* When receiving a question with the unicast-response bit set, a responder
* SHOULD usually respond with a unicast packet directed back to the querier.
@@ -100,15 +108,19 @@ void mdns_set_timeout(struct netif *netif, u32_t msecs,
sys_timeout_handler handler, u8_t *busy_flag);
#if LWIP_IPV4
void mdns_multicast_timeout_reset_ipv4(void *arg);
void mdns_multicast_probe_timeout_reset_ipv4(void *arg);
void mdns_multicast_timeout_25ttl_reset_ipv4(void *arg);
void mdns_send_multicast_msg_delayed_ipv4(void *arg);
void mdns_send_unicast_msg_delayed_ipv4(void *arg);
void mdns_start_multicast_timeouts_ipv4(struct netif *netif);
#endif
#if LWIP_IPV6
void mdns_multicast_timeout_reset_ipv6(void *arg);
void mdns_multicast_probe_timeout_reset_ipv6(void *arg);
void mdns_multicast_timeout_25ttl_reset_ipv6(void *arg);
void mdns_send_multicast_msg_delayed_ipv6(void *arg);
void mdns_send_unicast_msg_delayed_ipv6(void *arg);
void mdns_start_multicast_timeouts_ipv6(struct netif *netif);
#endif
void mdns_prepare_txtdata(struct mdns_service *service);

View File

@@ -145,10 +145,12 @@ struct mdns_outmsg {
/** Delayed msg info */
struct mdns_delayed_msg {
/** Timer state multicast */
/** Signals if a multicast msg needs to be send out */
u8_t multicast_msg_waiting;
/** Multicast timeout on */
/** Multicast timeout for all multicast traffic except probe answers */
u8_t multicast_timeout;
/** Multicast timeout only for probe answers */
u8_t multicast_probe_timeout;
/** Output msg used for delayed multicast responses */
struct mdns_outmsg delayed_msg_multicast;
/** Prefer multicast over unicast timeout -> 25% of TTL = we take 30s as