Rtos API example

Embed: (wiki syntax)

« Back to documentation index

MDNS

RFC 6762 - Multicast DNS
RFC 6763 - DNS-Based Service Discovery
. More...

Modules

 Options

Functions

void mdns_resp_init (void)
 Initiate MDNS responder.
void mdns_resp_netif_settings_changed (struct netif *netif)
 Announce IP settings have changed on netif.
err_t mdns_resp_add_netif (struct netif *netif, const char *hostname, u32_t dns_ttl)
 Activate MDNS responder for a network interface and send announce packets.
err_t mdns_resp_remove_netif (struct netif *netif)
 Stop responding to MDNS queries on this interface, leave multicast groups, and free the helper structure and any of its services.
err_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_data)
 Add a service to the selected network interface.
err_t mdns_resp_add_service_txtitem (struct mdns_service *service, const char *txt, u8_t txt_len)
 Call this function from inside the service_get_txt_fn_t callback to add text data.

Detailed Description

RFC 6762 - Multicast DNS
RFC 6763 - DNS-Based Service Discovery
.

Things left to implement: -------------------------

  • Probing/conflict resolution
  • Sending goodbye messages (zero ttl) - shutdown, DHCP lease about to expire, DHCP turned off...
  • Checking that source address of unicast requests are on the same network
  • Limiting multicast responses to 1 per second per resource record
  • Fragmenting replies if required
  • Subscribe to netif address/link change events and act on them (currently needs to be done manually)
  • Handling multi-packet known answers
  • Individual known answer detection for all local IPv6 addresses
  • Dynamic size of outgoing packet

Function Documentation

err_t mdns_resp_add_netif ( struct netif netif,
const char *  hostname,
u32_t  dns_ttl 
)

Activate MDNS responder for a network interface and send announce packets.

Parameters:
netifThe network interface to activate.
hostnameName to use. Queries for <hostname>.local will be answered with the IP addresses of the netif. The hostname will be copied, the given pointer can be on the stack.
dns_ttlValidity time in seconds to send out for IP address data in DNS replies
Returns:
ERR_OK if netif was added, an err_t otherwise

Definition at line 1867 of file lwip_mdns.c.

err_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_data 
)

Add a service to the selected network interface.

Parameters:
netifThe network interface to publish this service on
nameThe name of the service
serviceThe service type, like "_http"
protoThe service protocol, DNSSD_PROTO_TCP for TCP ("_tcp") and DNSSD_PROTO_UDP for others ("_udp")
portThe port the service listens to
dns_ttlValidity time in seconds to send out for service data in DNS replies
txt_fnCallback to get TXT data. Will be called each time a TXT reply is created to allow dynamic replies.
txt_dataUserdata pointer for txt_fn
Returns:
ERR_OK if the service was added to the netif, an err_t otherwise

Definition at line 1961 of file lwip_mdns.c.

err_t mdns_resp_add_service_txtitem ( struct mdns_service *  service,
const char *  txt,
u8_t  txt_len 
)

Call this function from inside the service_get_txt_fn_t callback to add text data.

Buffer for TXT data is 256 bytes, and each field is prefixed with a length byte.

Parameters:
serviceThe service provided to the get_txt callback
txtString to add to the TXT field.
txt_lenLength of string
Returns:
ERR_OK if the string was added to the reply, an err_t otherwise

Definition at line 2020 of file lwip_mdns.c.

void mdns_resp_init ( void   )

Initiate MDNS responder.

Will open UDP sockets on port 5353

Definition at line 1811 of file lwip_mdns.c.

void mdns_resp_netif_settings_changed ( struct netif netif )

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.

Parameters:
netifThe network interface where settings have changed.

Definition at line 1839 of file lwip_mdns.c.

err_t mdns_resp_remove_netif ( struct netif netif )

Stop responding to MDNS queries on this interface, leave multicast groups, and free the helper structure and any of its services.

Parameters:
netifThe network interface to remove.
Returns:
ERR_OK if netif was removed, an err_t otherwise

Definition at line 1916 of file lwip_mdns.c.