Go to the documentation of this file.
40 #define TRACE_LEVEL DNS_SD_TRACE_LEVEL
50 #if (DNS_SD_RESPONDER_SUPPORT == ENABLED)
97 if(context == NULL || settings == NULL)
108 interface = settings->interface;
114 context->interface = settings->
interface;
116 context->services = settings->
services;
118 context->ttl = settings->
ttl;
122 context->running =
FALSE;
125 for(i = 0; i < context->numServices; i++)
128 service = &context->services[i];
134 service->context = context;
140 interface->dnsSdResponderContext = context;
168 context->running =
TRUE;
171 for(i = 0; i < context->numServices; i++)
206 context->running =
FALSE;
209 for(i = 0; i < context->numServices; i++)
250 if(context == NULL || instanceName == NULL || serviceName == NULL ||
257 if(index >= context->numServices)
272 service = &context->services[index];
275 if(service->instanceName[0] !=
'\0' &&
276 service->serviceName[0] !=
'\0')
283 osStrcpy(service->instanceName, instanceName);
285 osStrcpy(service->serviceName, serviceName);
292 service->port =
port;
295 service->metadataLen = 0;
308 if(metadata[i] ==
'\0' || metadata[i] ==
';')
311 n =
MIN(i - j, UINT8_MAX);
318 service->metadata[k] =
n;
320 osMemcpy(service->metadata + k + 1, metadata + j,
n);
328 service->metadataLen +=
n + 1;
331 if(metadata[i] ==
'\0')
340 if(service->metadataLen == 0)
343 service->metadata[0] = 0;
344 service->metadataLen = 1;
375 if(index >= context->numServices)
382 service = &context->services[index];
385 if(service->instanceName[0] !=
'\0' &&
386 service->serviceName[0] !=
'\0')
393 service->instanceName[0] =
'\0';
394 service->serviceName[0] =
'\0';
419 for(i = 0; i < context->numServices; i++)
452 interface = context->interface;
458 for(i = 0; i < context->numServices; i++)
461 service = &context->services[i];
464 if(service->instanceName[0] !=
'\0' &&
465 service->serviceName[0] !=
'\0')
471 if(context->running && interface->mdnsResponderContext != NULL)
488 if(service->conflict && service->retransmitCount > 0)
498 else if(service->tieBreakLost && service->retransmitCount > 0)
514 if(service->retransmitCount == 0)
518 service->conflict =
FALSE;
519 service->tieBreakLost =
FALSE;
526 service->timestamp =
time;
530 service->retransmitCount++;
537 if(context->numAnnouncements > 0)
554 if(service->conflict)
569 service->timestamp =
time;
571 service->retransmitCount++;
574 if(service->retransmitCount == 1)
587 service->timeout *= 2;
591 if(service->retransmitCount >= context->numAnnouncements)
605 if(service->conflict)
631 for(i = 0; i < context->numServices; i++)
error_t dnsSdResponderSendGoodbye(DnsSdResponderService *service)
Send goodbye packet.
error_t dnsSdResponderStop(DnsSdResponderContext *context)
Stop DNS-SD responder.
NetInterface * interface
Underlying network interface.
error_t dnsSdResponderInit(DnsSdResponderContext *context, const DnsSdResponderSettings *settings)
DNS-DS initialization.
#define DNS_SD_MAX_METADATA_LEN
#define DNS_SD_DEFAULT_RR_TTL
systime_t dnsSdResponderTickCounter
error_t dnsSdResponderSendAnnouncement(DnsSdResponderService *service)
Send announcement packet.
DnsSdStateChangeCallback stateChangeEvent
FSM state change event.
#define MDNS_PROBE_DEFER_DELAY
uint32_t ttl
TTL resource record.
error_t dnsSdResponderStart(DnsSdResponderContext *context)
Start DNS-SD responder.
uint_t numServices
Maximum number of DNS-SD services that can be registered.
#define timeCompare(t1, t2)
error_t dnsSdResponderStartProbing(DnsSdResponderContext *context)
Restart probing process.
#define MDNS_RAND_DELAY_MIN
void dnsSdResponderTick(DnsSdResponderContext *context)
DNS-SD responder timer handler.
#define MDNS_RAND_DELAY_MAX
@ ERROR_INVALID_PARAMETER
Invalid parameter.
#define osMemcpy(dest, src, length)
uint32_t netGenerateRandRange(uint32_t min, uint32_t max)
Generate a random value in the specified range.
void dnsSdResponderChangeInstanceName(DnsSdResponderService *service)
Programmatically change the service instance name.
DNS-SD responder (DNS-Based Service Discovery)
NetInterface * netGetDefaultInterface(void)
Get default network interface.
#define DnsSdResponderContext
#define DnsSdResponderService
#define DNS_SD_MAX_INSTANCE_NAME_LEN
error_t dnsSdResponderSendProbe(DnsSdResponderService *service)
Send probe packet.
DNS-SD responder settings.
uint32_t systime_t
System time.
void dnsSdResponderChangeState(DnsSdResponderService *service, MdnsState newState, systime_t delay)
Update FSM state.
Helper functions for DNS-SD responder.
void osAcquireMutex(OsMutex *mutex)
Acquire ownership of the specified mutex object.
void osReleaseMutex(OsMutex *mutex)
Release ownership of the specified mutex object.
#define MDNS_PROBE_CONFLICT_DELAY
#define MDNS_ANNOUNCE_DELAY
uint_t numAnnouncements
Number of announcement packets.
error_t dnsSdResponderRegisterService(DnsSdResponderContext *context, uint_t index, const char_t *instanceName, const char_t *serviceName, uint16_t priority, uint16_t weight, uint16_t port, const char_t *metadata)
Register a DNS-SD service.
error_t dnsSdResponderUnregisterService(DnsSdResponderContext *context, uint_t index)
Unregister a DNS-SD service.
#define DNS_SD_MAX_SERVICE_NAME_LEN
#define osMemset(p, value, length)
DnsSdResponderService * services
DNS-SD services.
#define MDNS_ANNOUNCE_NUM
void dnsSdResponderGetDefaultSettings(DnsSdResponderSettings *settings)
Initialize settings with default values.
void dnsSdResponderLinkChangeEvent(DnsSdResponderContext *context)
Callback function for link change event.
mDNS responder (Multicast DNS)
systime_t osGetSystemTime(void)
Retrieve system time.