Chapter 192. API
Table of Contents
- 192.1. API
- cyg_mdns_init — Initialise mDNS Responder
- cyg_mdns_terminate — Terminate mDNS Responder
- cyg_mdns_enable — Enable mDNS
- cyg_mdns_disable — Disable mDNS
- cyg_mdns_service_register — Register set of services
- cyg_mdns_service_unregister — Remove registered services
- cyg_mdns_sethostname — Set base hostname
- cyg_mdns_hostname_callback_register — Register hostname generation callback
- cyg_mdns_gethostname — Get current hostname value
- cyg_mdns_setservicelabel — Set service label
- cyg_mdns_getservicelabel — Get current service label value
- cyg_mdns_servicelabel_callback_register — Register service label generation callback
- cyg_mdns_hinfo_register — Register HINFO record data
- cyg_mdns_discovery_callback_register — Register DNS-SD response callback
- cyg_mdns_discovery_callback_unregister — Unregister DNS-SD response callback
- cyg_mdns_discovery_callback_flags — Read/Modify DNS-SD response callback control flags
- cyg_mdns_discovery_query — Issue a DNS-SD query
- 192.2. Example Responder
- 192.3. Example DNS-SD Queries
The main mDNS API provides a serialisation layer between the low-level (lwIP) networking based operations and client application threads.
192.1. API
- cyg_mdns_init — Initialise mDNS Responder
- cyg_mdns_terminate — Terminate mDNS Responder
- cyg_mdns_enable — Enable mDNS
- cyg_mdns_disable — Disable mDNS
- cyg_mdns_service_register — Register set of services
- cyg_mdns_service_unregister — Remove registered services
- cyg_mdns_sethostname — Set base hostname
- cyg_mdns_hostname_callback_register — Register hostname generation callback
- cyg_mdns_gethostname — Get current hostname value
- cyg_mdns_setservicelabel — Set service label
- cyg_mdns_getservicelabel — Get current service label value
- cyg_mdns_servicelabel_callback_register — Register service label generation callback
- cyg_mdns_hinfo_register — Register HINFO record data
- cyg_mdns_discovery_callback_register — Register DNS-SD response callback
- cyg_mdns_discovery_callback_unregister — Unregister DNS-SD response callback
- cyg_mdns_discovery_callback_flags — Read/Modify DNS-SD response callback control flags
- cyg_mdns_discovery_query — Issue a DNS-SD query
192.2. Example Responder
The tests/mdns_example.c
source file included in
the package provides a complete, simple, real-world example of the
mDNS Responder usage. It registers two services, a dummy (port 9)
service _workstation._tcp.local
and a HTTP daemon
using service _http._tcp.local
on port 80.
Normally the first task after the lwIP networking has been initialised is to call the C function:
cyg_bool cyg_mdns_init(
void)
;
The following is a very simple example of declaring
a <hostname>._http._tcp.local
service for
the <hostname>.local
address, where
<hostname>
is the default as configured by
the CYGDAT_NET_MDNS_HOSTNAME
CDL option.
static const cyg_uint8 label_http[] = { 0x05,'_','h','t','t','p' }; static const cyg_mdns_service_identity httpd80 = { .service = label_http, .proto = cyg_mdns_label_tcp, .port = 80 }; static const struct cyg_mdns_service httpd80_service = { .id = &httpd80, .txt_vector = NULL, .txt_count = 0, }; … if (cyg_mdns_init()) { if (cyg_mdns_service_register(1,(struct mdns_service *)&httpd80_service)) { if (cyg_mdns_enable()) { // other application processing as needed ... } else { (void)cyg_mdns_service_unregister(1,(struct mdns_service *)&httpd80_service); // report error } } else { cyg_mdns_terminate(); // report error } } else { // report error }
192.3. Example DNS-SD Queries
The tests/dnssd_example.c
source file included in
the package provides a complete, simple, real-world example of the
DNS-SD API usage. See Section 195.2.6, “DNS-SD Example” for more
detail.
2024-12-10 | eCosPro Non-Commercial Public License |