Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

MDNS

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

Modules

 Options

Functions

err_t mdns_resp_add_netif (struct netif *netif, const char *hostname, u32_t dns_ttl)
 Activate MDNS responder for a network interface.
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_rename_netif (struct netif *netif, const char *hostname)
 Update MDNS hostname for a network interface.
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_data)
 Add a service to the selected network interface.
err_t mdns_resp_del_service (struct netif *netif, s8_t slot)
 Delete a service on the selected network interface.
err_t mdns_resp_rename_service (struct netif *netif, s8_t slot, const char *name)
 Update name for an MDNS service.
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.
void mdns_resp_announce (struct netif *netif)
 Send unsolicited answer containing all our known data.
void mdns_resp_restart (struct netif *netif)
 Restart mdns responder.
void mdns_resp_init (void)
 Initiate MDNS responder.

Detailed Description

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

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

  • Tiebreaking for simultaneous probing
  • 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
  • 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.

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 2060 of file lwip_mdns.c.

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_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:
service_id if the service was added to the netif, an err_t otherwise

Definition at line 2192 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 2302 of file lwip_mdns.c.

void mdns_resp_announce ( struct netif netif )

Send unsolicited answer containing all our known data.

Parameters:
netifThe network interface to send on

Definition at line 2317 of file lwip_mdns.c.

err_t mdns_resp_del_service ( struct netif netif,
s8_t  slot 
)

Delete a service on the selected network interface.

Parameters:
netifThe network interface on which service should be removed
slotThe service slot number returned by mdns_resp_add_service
Returns:
ERR_OK if the service was removed from the netif, an err_t otherwise

Definition at line 2242 of file lwip_mdns.c.

void mdns_resp_init ( void   )

Initiate MDNS responder.

Will open UDP sockets on port 5353

Definition at line 2381 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 2112 of file lwip_mdns.c.

err_t mdns_resp_rename_netif ( struct netif netif,
const char *  hostname 
)

Update MDNS hostname for a network interface.

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.
Returns:
ERR_OK if name could be set on netif, an err_t otherwise

Definition at line 2156 of file lwip_mdns.c.

err_t mdns_resp_rename_service ( struct netif netif,
s8_t  slot,
const char *  name 
)

Update name for an MDNS service.

Parameters:
netifThe network interface to activate.
slotThe service slot number returned by mdns_resp_add_service
nameThe new name for the service
Returns:
ERR_OK if name could be set on service, an err_t otherwise

Definition at line 2267 of file lwip_mdns.c.

void mdns_resp_restart ( struct netif netif )

Restart mdns responder.

Call this when cable is connected after being disconnected or administrative interface is set up after being down

Parameters:
netifThe network interface to send on

Definition at line 2356 of file lwip_mdns.c.