mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-05-13 11:47:00 +08:00
mDNS fix TTL bug
MDNS_TTL changed to MDNS_IP_TTL for clarity. The mDNS RR ttl does not need to be settalbe, this is against the RFC. RFC6762 states that for rr's with the hostname in them somewhere, the ttl should be 120s. If it's not in their it should be 75 minutes and if the answer is send to a legacy dns querier, it should be no more then 10s. This patch corrects the ttl behavior to the RFC.
This commit is contained in:
committed by
Dirk Ziegelmeier
parent
c4321330d0
commit
62fb2fd749
@@ -73,11 +73,11 @@ void mdns_resp_init(void);
|
||||
|
||||
void mdns_resp_register_name_result_cb(mdns_name_result_cb_t cb);
|
||||
|
||||
err_t mdns_resp_add_netif(struct netif *netif, const char *hostname, u32_t dns_ttl);
|
||||
err_t mdns_resp_add_netif(struct netif *netif, const char *hostname);
|
||||
err_t mdns_resp_remove_netif(struct netif *netif);
|
||||
err_t mdns_resp_rename_netif(struct netif *netif, const char *hostname);
|
||||
|
||||
s8_t mdns_resp_add_service(struct netif *netif, const char *name, const char *service, enum mdns_sd_proto proto, u16_t port, u32_t dns_ttl, service_get_txt_fn_t txt_fn, void *txt_userdata);
|
||||
s8_t mdns_resp_add_service(struct netif *netif, const char *name, const char *service, enum mdns_sd_proto proto, u16_t port, service_get_txt_fn_t txt_fn, void *txt_userdata);
|
||||
err_t mdns_resp_del_service(struct netif *netif, s8_t slot);
|
||||
err_t mdns_resp_rename_service(struct netif *netif, s8_t slot, const char *name);
|
||||
|
||||
|
||||
@@ -54,6 +54,15 @@ extern "C" {
|
||||
#define SRV_PRIORITY 0
|
||||
#define SRV_WEIGHT 0
|
||||
|
||||
/* mDNS TTL: (RFC6762 section 10)
|
||||
* - 120 seconds if the hostname appears somewhere in the RR
|
||||
* - 75 minutes if not (4500 seconds)
|
||||
* - 10 seconds if responding to a legacy query
|
||||
*/
|
||||
#define MDNS_TTL_10 10
|
||||
#define MDNS_TTL_120 120
|
||||
#define MDNS_TTL_4500 4500
|
||||
|
||||
/* Domain structs - also visible for unit tests */
|
||||
|
||||
struct mdns_domain {
|
||||
@@ -77,8 +86,6 @@ struct mdns_service {
|
||||
* to update txtdata buffer */
|
||||
service_get_txt_fn_t txt_fn;
|
||||
void *txt_userdata;
|
||||
/** TTL in seconds of SRV/TXT replies */
|
||||
u32_t dns_ttl;
|
||||
/** Protocol, TCP or UDP */
|
||||
u16_t proto;
|
||||
/** Port of the service */
|
||||
@@ -91,8 +98,6 @@ struct mdns_host {
|
||||
char name[MDNS_LABEL_MAXLEN + 1];
|
||||
/** Pointer to services */
|
||||
struct mdns_service *services[MDNS_MAX_SERVICES];
|
||||
/** TTL in seconds of A/AAAA/PTR replies */
|
||||
u32_t dns_ttl;
|
||||
/** Number of probes sent for the current name */
|
||||
u8_t probes_sent;
|
||||
/** State in probing sequence */
|
||||
|
||||
Reference in New Issue
Block a user