mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-25 18:14:53 +00:00
mdns: add mdns_resp_restart_delay to allow re-probe delay selection
Called with `MDNS_INITIAL_PROBE_DELAY_MS` or `MDNS_PROBE_DELAY_MS` according to needs. When `mdns_resp_restart_delay()` called by `mdns_resp_rename_(netif|service)()` functions, it is assumed this is because a conflict. So we should not use `MDNS_INITIAL_PROBE_DELAY_MS` because the Bonjour Conformance Test will complain like this: ``` START (PROBING) NOTICE 16:40:09.501911: conflicting probe: smarTrEMotE-f8d0a4.Local. ERROR 16:40:09.607288: Device did not provide a sufficient time gap between receiving a conflicting probe and reprobing. ERROR 16:40:09.607333: expected_time_gap=237,actual_time_gap=105 ``` Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
This commit is contained in:
parent
cd278c426d
commit
710b7fc158
@ -1976,9 +1976,7 @@ mdns_handle_response(struct mdns_packet *pkt, struct netif *netif)
|
||||
if (conflict != 0) {
|
||||
/* Reset host to probing to reconfirm uniqueness */
|
||||
LWIP_DEBUGF(MDNS_DEBUG, ("mDNS: Conflict resolution -> reset to probing state\n"));
|
||||
mdns->state = MDNS_STATE_PROBE_WAIT;
|
||||
mdns->sent_num = 0;
|
||||
sys_timeout(MDNS_INITIAL_PROBE_DELAY_MS, mdns_probe_and_announce, netif);
|
||||
mdns_resp_restart(netif);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2360,7 +2358,7 @@ mdns_resp_rename_netif(struct netif *netif, const char *hostname)
|
||||
MEMCPY(&mdns->name, hostname, LWIP_MIN(MDNS_LABEL_MAXLEN, len));
|
||||
mdns->name[len] = '\0'; /* null termination in case new name is shorter than previous */
|
||||
|
||||
mdns_resp_restart(netif);
|
||||
mdns_resp_restart_delay(netif, MDNS_PROBE_DELAY_MS);
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
@ -2472,7 +2470,7 @@ mdns_resp_rename_service(struct netif *netif, u8_t slot, const char *name)
|
||||
MEMCPY(&srv->name, name, LWIP_MIN(MDNS_LABEL_MAXLEN, len));
|
||||
srv->name[len] = '\0'; /* null termination in case new name is shorter than previous */
|
||||
|
||||
mdns_resp_restart(netif);
|
||||
mdns_resp_restart_delay(netif, MDNS_PROBE_DELAY_MS);
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
@ -2620,12 +2618,13 @@ mdns_resp_register_name_result_cb(mdns_name_result_cb_t cb)
|
||||
|
||||
/**
|
||||
* @ingroup mdns
|
||||
* Restart mdns responder. Call this when cable is connected after being disconnected or
|
||||
* administrative interface is set up after being down
|
||||
* Restart mdns responder after a specified delay. Call this when cable is connected
|
||||
* after being disconnected or administrative interface is set up after being down
|
||||
* @param netif The network interface to send on
|
||||
* @param delay The delay to use before sending probe
|
||||
*/
|
||||
void
|
||||
mdns_resp_restart(struct netif *netif)
|
||||
mdns_resp_restart_delay(struct netif *netif, uint32_t delay)
|
||||
{
|
||||
struct mdns_host* mdns;
|
||||
LWIP_ASSERT_CORE_LOCKED();
|
||||
@ -2649,10 +2648,23 @@ mdns_resp_restart(struct netif *netif)
|
||||
sys_timeout(MDNS_PROBE_MAX_CONFLICTS_TIMEOUT, mdns_probe_and_announce, netif);
|
||||
}
|
||||
else {
|
||||
sys_timeout(MDNS_INITIAL_PROBE_DELAY_MS, mdns_probe_and_announce, netif);
|
||||
/* Adjust probe delay according sent probe count. */
|
||||
sys_timeout(delay, mdns_probe_and_announce, netif);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup mdns
|
||||
* Restart mdns responder. Call this when cable is connected after being disconnected or
|
||||
* administrative interface is set up after being down
|
||||
* @param netif The network interface to send on
|
||||
*/
|
||||
void
|
||||
mdns_resp_restart(struct netif *netif)
|
||||
{
|
||||
mdns_resp_restart_delay(netif, MDNS_INITIAL_PROBE_DELAY_MS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup mdns
|
||||
* Initiate MDNS responder. Will open UDP sockets on port 5353
|
||||
|
@ -117,6 +117,7 @@ err_t mdns_resp_rename_service(struct netif *netif, u8_t slot, const char *name)
|
||||
|
||||
err_t mdns_resp_add_service_txtitem(struct mdns_service *service, const char *txt, u8_t txt_len);
|
||||
|
||||
void mdns_resp_restart_delay(struct netif *netif, uint32_t delay);
|
||||
void mdns_resp_restart(struct netif *netif);
|
||||
void mdns_resp_announce(struct netif *netif);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user