Go to the documentation of this file.
40 #define TRACE_LEVEL DNS_SD_TRACE_LEVEL
51 #if (DNS_SD_SUPPORT == ENABLED)
91 if(context == NULL || settings == NULL)
99 interface = settings->interface;
104 context->settings = *settings;
107 context->running =
FALSE;
112 interface->dnsSdContext = context;
138 context->running =
TRUE;
169 context->running =
FALSE;
194 state = context->state;
216 if(context == NULL || instanceName == NULL)
227 interface = context->settings.interface;
233 if(interface->linkState)
241 osStrcpy(context->instanceName, instanceName);
279 if(context == NULL || serviceName == NULL || metadata == NULL)
290 firstFreeEntry = NULL;
296 entry = &context->serviceList[i];
308 if(firstFreeEntry == NULL)
310 firstFreeEntry = entry;
318 entry = firstFreeEntry;
347 if(metadata[i] ==
'\0' || metadata[i] ==
';')
350 n =
MIN(i - j, UINT8_MAX);
370 if(metadata[i] ==
'\0')
420 if(context == NULL || serviceName == NULL)
430 entry = &context->serviceList[i];
468 if(context->instanceName[0] !=
'\0')
474 if(context->serviceList[i].serviceName[0] !=
'\0')
525 interface = context->settings.interface;
534 if(context->running && interface->mdnsResponderContext != NULL)
555 if(context->conflict && context->retransmitCount > 0)
563 else if(context->tieBreakLost && context->retransmitCount > 0)
578 if(context->retransmitCount == 0)
582 context->conflict =
FALSE;
583 context->tieBreakLost =
FALSE;
590 context->timestamp =
time;
594 context->retransmitCount++;
601 if(context->settings.numAnnouncements > 0)
618 if(context->conflict)
632 context->timestamp =
time;
634 context->retransmitCount++;
637 if(context->retransmitCount == 1)
649 context->timeout *= 2;
653 if(context->retransmitCount >= context->settings.numAnnouncements)
666 if(context->conflict)
uint_t dnsSdGetNumServices(DnsSdContext *context)
Get the number of registered services.
MdnsState dnsSdGetState(DnsSdContext *context)
Retrieve current state.
DNS-SD service descriptor.
error_t dnsSdSendGoodbye(DnsSdContext *context, const DnsSdService *service)
Send goodbye packet.
#define DNS_SD_DEFAULT_RR_TTL
uint16_t weight
Server selection mechanism.
error_t dnsSdUnregisterService(DnsSdContext *context, const char_t *serviceName)
Unregister a DNS-SD service.
#define MDNS_PROBE_DEFER_DELAY
error_t dnsSdInit(DnsSdContext *context, const DnsSdSettings *settings)
DNS-DS initialization.
#define timeCompare(t1, t2)
MdnsState
mDNS responder states
#define MDNS_RAND_DELAY_MIN
uint_t numAnnouncements
Number of announcement packets.
DNS-SD (DNS-Based Service Discovery)
error_t dnsSdStartProbing(DnsSdContext *context)
Restart probing process.
#define MDNS_RAND_DELAY_MAX
#define DNS_SD_MAX_SERVICE_NAME_LEN
@ 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.
char_t serviceName[DNS_SD_MAX_SERVICE_NAME_LEN+1]
Service name.
void dnsSdGetDefaultSettings(DnsSdSettings *settings)
Initialize settings with default values.
error_t dnsSdStart(DnsSdContext *context)
Start mDNS responder.
@ ERROR_FAILURE
Generic error code.
error_t dnsSdSendAnnouncement(DnsSdContext *context)
Send announcement packet.
void dnsSdTick(DnsSdContext *context)
DNS-SD responder timer handler.
Helper functions for DNS-SD.
NetInterface * netGetDefaultInterface(void)
Get default network interface.
error_t dnsSdStop(DnsSdContext *context)
Stop mDNS responder.
#define osStrcasecmp(s1, s2)
#define DNS_SD_MAX_METADATA_LEN
void dnsSdChangeInstanceName(DnsSdContext *context)
Programmatically change the service instance name.
size_t metadataLength
Length of the metadata.
#define DNS_SD_SERVICE_LIST_SIZE
NetInterface * interface
Underlying network interface.
uint32_t systime_t
System time.
systime_t dnsSdTickCounter
#define DNS_SD_MAX_INSTANCE_NAME_LEN
DnsSdStateChangeCallback stateChangeEvent
FSM state change event.
error_t dnsSdRegisterService(DnsSdContext *context, const char_t *serviceName, uint16_t priority, uint16_t weight, uint16_t port, const char_t *metadata)
Register a DNS-SD service.
void osAcquireMutex(OsMutex *mutex)
Acquire ownership of the specified mutex object.
error_t dnsSdSetInstanceName(DnsSdContext *context, const char_t *instanceName)
Set service instance name.
void osReleaseMutex(OsMutex *mutex)
Release ownership of the specified mutex object.
#define MDNS_PROBE_CONFLICT_DELAY
#define MDNS_ANNOUNCE_DELAY
error_t dnsSdSendProbe(DnsSdContext *context)
Send probe packet.
void dnsSdChangeState(DnsSdContext *context, MdnsState newState, systime_t delay)
Update FSM state.
uint32_t ttl
TTL resource record.
uint16_t port
Port on the target host of this service.
void dnsSdLinkChangeEvent(DnsSdContext *context)
Callback function for link change event.
uint8_t metadata[DNS_SD_MAX_METADATA_LEN]
Discovery-time metadata (TXT record)
#define osMemset(p, value, length)
uint16_t priority
Priority of the target host.
#define MDNS_ANNOUNCE_NUM
mDNS responder (Multicast DNS)
systime_t osGetSystemTime(void)
Retrieve system time.