mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2025-08-05 05:54:37 +08:00
MDNS: Add callback to be called manually when IP has changed to announce new IP
This commit is contained in:
parent
fa6a2d48cc
commit
a262a2f252
@ -18,7 +18,7 @@
|
|||||||
* - Checking that source address of unicast requests are on the same network
|
* - Checking that source address of unicast requests are on the same network
|
||||||
* - Limiting multicast responses to 1 per second per resource record
|
* - Limiting multicast responses to 1 per second per resource record
|
||||||
* - Fragmenting replies if required
|
* - Fragmenting replies if required
|
||||||
* - Subscribe to netif address/link change events and act on them
|
* - Subscribe to netif address/link change events and act on them (currently needs to be done manually)
|
||||||
* - Handling multi-packet known answers
|
* - Handling multi-packet known answers
|
||||||
* - Individual known answer detection for all local IPv6 addresses
|
* - Individual known answer detection for all local IPv6 addresses
|
||||||
* - Dynamic size of outgoing packet
|
* - Dynamic size of outgoing packet
|
||||||
@ -1510,7 +1510,7 @@ mdns_announce(struct netif *netif, const ip_addr_t *destination)
|
|||||||
}
|
}
|
||||||
|
|
||||||
announce.dest_port = MDNS_PORT;
|
announce.dest_port = MDNS_PORT;
|
||||||
memcpy(&announce.dest_addr, destination, sizeof(ip_addr_t));
|
memcpy(&announce.dest_addr, destination, sizeof(announce.dest_addr));
|
||||||
mdns_send_outpacket(&announce);
|
mdns_send_outpacket(&announce);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1858,6 +1858,32 @@ mdns_resp_init(void)
|
|||||||
mdns_netif_client_id = netif_alloc_client_data_id();
|
mdns_netif_client_id = netif_alloc_client_data_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup mdns
|
||||||
|
* Announce IP settings have changed on netif.
|
||||||
|
* Call this in your callback registered by netif_set_status_callback().
|
||||||
|
* This function may go away in the future when netif supports registering
|
||||||
|
* multiple callback functions.
|
||||||
|
* @param netif The network interface where settings have changed.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
mdns_resp_netif_settings_changed(struct netif *netif)
|
||||||
|
{
|
||||||
|
LWIP_ERROR("mdns_resp_netif_ip_changed: netif != NULL", (netif != NULL), return);
|
||||||
|
|
||||||
|
if (netif->client_data[mdns_netif_client_id] == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Announce on IPv6 and IPv4 */
|
||||||
|
#if LWIP_IPV6
|
||||||
|
mdns_announce(netif, IP6_ADDR_ANY);
|
||||||
|
#endif
|
||||||
|
#if LWIP_IPV4
|
||||||
|
mdns_announce(netif, IP_ADDR_ANY);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup mdns
|
* @ingroup mdns
|
||||||
* Activate MDNS responder for a network interface and send announce packets.
|
* Activate MDNS responder for a network interface and send announce packets.
|
||||||
@ -1901,14 +1927,7 @@ mdns_resp_add_netif(struct netif *netif, const char *hostname, u32_t dns_ttl)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Announce on IPv6 and IPv4 */
|
mdns_resp_netif_settings_changed(netif);
|
||||||
#if LWIP_IPV6
|
|
||||||
mdns_announce(netif, IP6_ADDR_ANY);
|
|
||||||
#endif
|
|
||||||
#if LWIP_IPV4
|
|
||||||
mdns_announce(netif, IP_ADDR_ANY);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
@ -58,6 +58,7 @@ err_t mdns_resp_remove_netif(struct netif *netif);
|
|||||||
typedef void (*service_get_txt_fn_t)(struct mdns_service *service, void *txt_userdata);
|
typedef void (*service_get_txt_fn_t)(struct mdns_service *service, void *txt_userdata);
|
||||||
err_t mdns_resp_add_service(struct netif *netif, const char *name, const char *service, u16_t proto, u16_t port, u32_t dns_ttl, service_get_txt_fn_t txt_fn, void *txt_userdata);
|
err_t mdns_resp_add_service(struct netif *netif, const char *name, const char *service, u16_t proto, u16_t port, u32_t dns_ttl, service_get_txt_fn_t txt_fn, void *txt_userdata);
|
||||||
err_t mdns_resp_add_service_txtitem(struct mdns_service *service, const char *txt, u8_t txt_len);
|
err_t mdns_resp_add_service_txtitem(struct mdns_service *service, const char *txt, u8_t txt_len);
|
||||||
|
void mdns_resp_netif_settings_changed(struct netif *netif);
|
||||||
|
|
||||||
|
|
||||||
/* Domain struct and methods - visible for unit tests */
|
/* Domain struct and methods - visible for unit tests */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user