Webserver+3d print

Dependents:   Nucleo

Embed: (wiki syntax)

« Back to documentation index

dns_sd.c File Reference

dns_sd.c File Reference

DNS-SD (DNS-Based Service Discovery) More...

Go to the source code of this file.

Functions

void dnsSdGetDefaultSettings (DnsSdSettings *settings)
 Initialize settings with default values.
error_t dnsSdInit (DnsSdContext *context, const DnsSdSettings *settings)
 DNS-DS initialization.
error_t dnsSdStart (DnsSdContext *context)
 Start mDNS responder.
error_t dnsSdStop (DnsSdContext *context)
 Stop mDNS responder.
MdnsState dnsSdGetState (DnsSdContext *context)
 Retrieve current state.
error_t dnsSdSetInstanceName (DnsSdContext *context, const char_t *instanceName)
 Set service instance name.
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.
error_t dnsSdUnregisterService (DnsSdContext *context, const char_t *serviceName)
 Unregister a DNS-SD service.
uint_t dnsSdGetNumServices (DnsSdContext *context)
 Get the number of registered services.
error_t dnsSdStartProbing (DnsSdContext *context)
 Restart probing process.
void dnsSdTick (DnsSdContext *context)
 DNS-SD responder timer handler.
void dnsSdLinkChangeEvent (DnsSdContext *context)
 Callback function for link change event.
void dnsSdChangeState (DnsSdContext *context, MdnsState newState, systime_t delay)
 Update FSM state.
void dnsSdChangeInstanceName (DnsSdContext *context)
 Programmatically change the service instance name.
error_t dnsSdSendProbe (DnsSdContext *context)
 Send probe packet.
error_t dnsSdSendAnnouncement (DnsSdContext *context)
 Send announcement packet.
error_t dnsSdSendGoodbye (DnsSdContext *context, const DnsSdService *service)
 Send goodbye packet.
error_t dnsSdParseQuestion (NetInterface *interface, const MdnsMessage *query, size_t offset, const DnsQuestion *question, MdnsMessage *response)
 Parse a question.
void dnsSdParseNsRecord (NetInterface *interface, const MdnsMessage *query, size_t offset, const DnsResourceRecord *record)
 Parse a resource record from the Authority Section.
void dnsSdParseAnRecord (NetInterface *interface, const MdnsMessage *response, size_t offset, const DnsResourceRecord *record)
 Parse a resource record from the Answer Section.
void dnsSdGenerateAdditionalRecords (NetInterface *interface, MdnsMessage *response, bool_t legacyUnicast)
 Additional record generation.
error_t dnsSdAddServiceEnumPtrRecord (NetInterface *interface, MdnsMessage *message, const DnsSdService *service, uint32_t ttl)
 Add PTR record to a mDNS message (in response to a meta-query)
error_t dnsSdAddPtrRecord (NetInterface *interface, MdnsMessage *message, const DnsSdService *service, uint32_t ttl)
 Add PTR record to a mDNS message.
error_t dnsSdAddSrvRecord (NetInterface *interface, MdnsMessage *message, const DnsSdService *service, bool_t cacheFlush, uint32_t ttl)
 Add SRV record to a mDNS message.
error_t dnsSdAddTxtRecord (NetInterface *interface, MdnsMessage *message, const DnsSdService *service, bool_t cacheFlush, uint32_t ttl)
 Add TXT record to a mDNS message.
error_t dnsSdAddNsecRecord (NetInterface *interface, MdnsMessage *message, const DnsSdService *service, bool_t cacheFlush, uint32_t ttl)
 Add NSEC record to a mDNS message.

Detailed Description

DNS-SD (DNS-Based Service Discovery)

License

Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneTCP Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Description

DNS-SD allows clients to discover a list of named instances of that desired service, using standard DNS queries. Refer to the following RFCs for complete details:

  • RFC 6763: DNS-Based Service Discovery
  • RFC 2782: A DNS RR for specifying the location of services (DNS SRV)
Author:
Oryx Embedded SARL (www.oryx-embedded.com)
Version:
1.7.6

Definition in file dns_sd.c.


Function Documentation

error_t dnsSdAddNsecRecord ( NetInterface *  interface,
MdnsMessage message,
const DnsSdService service,
bool_t  cacheFlush,
uint32_t  ttl 
)

Add NSEC record to a mDNS message.

Parameters:
[in]interfaceUnderlying network interface
[in,out]messagePointer to the mDNS message
[in]servicePointer to a DNS-SD service
[in]cacheFlushCache-flush bit
[in]ttlResource record TTL (cache lifetime)
Returns:
Error code

Definition at line 1896 of file dns_sd.c.

error_t dnsSdAddPtrRecord ( NetInterface *  interface,
MdnsMessage message,
const DnsSdService service,
uint32_t  ttl 
)

Add PTR record to a mDNS message.

Parameters:
[in]interfaceUnderlying network interface
[in,out]messagePointer to the mDNS message
[in]servicePointer to a DNS-SD service
[in]ttlResource record TTL (cache lifetime)
Returns:
Error code

Definition at line 1630 of file dns_sd.c.

error_t dnsSdAddServiceEnumPtrRecord ( NetInterface *  interface,
MdnsMessage message,
const DnsSdService service,
uint32_t  ttl 
)

Add PTR record to a mDNS message (in response to a meta-query)

Parameters:
[in]interfaceUnderlying network interface
[in,out]messagePointer to the mDNS message
[in]servicePointer to a DNS-SD service
[in]ttlResource record TTL (cache lifetime)
Returns:
Error code

Definition at line 1561 of file dns_sd.c.

error_t dnsSdAddSrvRecord ( NetInterface *  interface,
MdnsMessage message,
const DnsSdService service,
bool_t  cacheFlush,
uint32_t  ttl 
)

Add SRV record to a mDNS message.

Parameters:
[in]interfaceUnderlying network interface
[in,out]messagePointer to the mDNS message
[in]servicePointer to a DNS-SD service
[in]cacheFlushCache-flush bit
[in]ttlResource record TTL (cache lifetime)
Returns:
Error code

Definition at line 1715 of file dns_sd.c.

error_t dnsSdAddTxtRecord ( NetInterface *  interface,
MdnsMessage message,
const DnsSdService service,
bool_t  cacheFlush,
uint32_t  ttl 
)

Add TXT record to a mDNS message.

Parameters:
[in]interfaceUnderlying network interface
[in,out]messagePointer to the mDNS message
[in]servicePointer to a DNS-SD service
[in]cacheFlushCache-flush bit
[in]ttlResource record TTL (cache lifetime)
Returns:
Error code

Definition at line 1813 of file dns_sd.c.

void dnsSdChangeInstanceName ( DnsSdContext *  context )

Programmatically change the service instance name.

Parameters:
[in]contextPointer to the DNS-SD context

Definition at line 723 of file dns_sd.c.

void dnsSdChangeState ( DnsSdContext *  context,
MdnsState  newState,
systime_t  delay 
)

Update FSM state.

Parameters:
[in]contextPointer to the DNS-SD context
[in]newStateNew state to switch to
[in]delayInitial delay

Definition at line 688 of file dns_sd.c.

void dnsSdGenerateAdditionalRecords ( NetInterface *  interface,
MdnsMessage response,
bool_t  legacyUnicast 
)

Additional record generation.

Parameters:
[in]interfaceUnderlying network interface
[in,out]responsemDNS response message
[in]legacyUnicastThis flag is set for legacy unicast responses

Definition at line 1407 of file dns_sd.c.

void dnsSdGetDefaultSettings ( DnsSdSettings settings )

Initialize settings with default values.

Parameters:
[out]settingsStructure that contains DNS-SD settings

Definition at line 63 of file dns_sd.c.

uint_t dnsSdGetNumServices ( DnsSdContext *  context )

Get the number of registered services.

Parameters:
[in]contextPointer to the DNS-SD context
Returns:
Number of registered services

Definition at line 448 of file dns_sd.c.

MdnsState dnsSdGetState ( DnsSdContext *  context )

Retrieve current state.

Parameters:
[in]contextPointer to the DNS-SD context
Returns:
Current DNS-SD state

Definition at line 188 of file dns_sd.c.

error_t dnsSdInit ( DnsSdContext *  context,
const DnsSdSettings settings 
)

DNS-DS initialization.

Parameters:
[in]contextPointer to the DNS-SD context
[in]settingsDNS-SD specific settings
Returns:
Error code

Definition at line 84 of file dns_sd.c.

void dnsSdLinkChangeEvent ( DnsSdContext *  context )

Callback function for link change event.

Parameters:
[in]contextPointer to the DNS-SD context

Definition at line 669 of file dns_sd.c.

void dnsSdParseAnRecord ( NetInterface *  interface,
const MdnsMessage response,
size_t  offset,
const DnsResourceRecord *  record 
)

Parse a resource record from the Answer Section.

Parameters:
[in]interfaceUnderlying network interface
[in]responseIncoming mDNS response message
[in]offsetOffset to first byte of the resource record to be checked
[in]recordPointer to the resource record

Definition at line 1337 of file dns_sd.c.

void dnsSdParseNsRecord ( NetInterface *  interface,
const MdnsMessage query,
size_t  offset,
const DnsResourceRecord *  record 
)

Parse a resource record from the Authority Section.

Parameters:
[in]interfaceUnderlying network interface
[in]queryIncoming mDNS query message
[in]offsetOffset to first byte of the resource record
[in]recordPointer to the resource record

Definition at line 1242 of file dns_sd.c.

error_t dnsSdParseQuestion ( NetInterface *  interface,
const MdnsMessage query,
size_t  offset,
const DnsQuestion *  question,
MdnsMessage response 
)

Parse a question.

Parameters:
[in]interfaceUnderlying network interface
[in]queryIncoming mDNS query message
[in]offsetOffset to first byte of the question
[in]questionPointer to the question
[in,out]responsemDNS response message
Returns:
Error code

Definition at line 1083 of file dns_sd.c.

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.

Parameters:
[in]contextPointer to the DNS-SD context
[in]serviceNameNULL-terminated string that contains the name of the service to be registered
[in]priorityPriority field
[in]weightWeight field
[in]portPort number
[in]metadataNULL-terminated string that contains the discovery-time metadata (TXT record)
Returns:
Error code

Definition at line 265 of file dns_sd.c.

error_t dnsSdSendAnnouncement ( DnsSdContext *  context )

Send announcement packet.

Parameters:
[in]contextPointer to the DNS-SD context
Returns:
Error code

Definition at line 914 of file dns_sd.c.

error_t dnsSdSendGoodbye ( DnsSdContext *  context,
const DnsSdService service 
)

Send goodbye packet.

Parameters:
[in]contextPointer to the DNS-SD context
[in]servicePointer to a DNS-SD service
Returns:
Error code

Definition at line 1003 of file dns_sd.c.

error_t dnsSdSendProbe ( DnsSdContext *  context )

Send probe packet.

Parameters:
[in]contextPointer to the DNS-SD context
Returns:
Error code

Definition at line 798 of file dns_sd.c.

error_t dnsSdSetInstanceName ( DnsSdContext *  context,
const char_t *  instanceName 
)

Set service instance name.

Parameters:
[in]contextPointer to the DNS-SD context
[in]instanceNameNULL-terminated string that contains the service instance name
Returns:
Error code

Definition at line 212 of file dns_sd.c.

error_t dnsSdStart ( DnsSdContext *  context )

Start mDNS responder.

Parameters:
[in]contextPointer to the DNS-SD context
Returns:
Error code

Definition at line 126 of file dns_sd.c.

error_t dnsSdStartProbing ( DnsSdContext *  context )

Restart probing process.

Parameters:
[in]contextPointer to the DNS-SD context
Returns:
Error code

Definition at line 483 of file dns_sd.c.

error_t dnsSdStop ( DnsSdContext *  context )

Stop mDNS responder.

Parameters:
[in]contextPointer to the DNS-SD context
Returns:
Error code

Definition at line 157 of file dns_sd.c.

void dnsSdTick ( DnsSdContext *  context )

DNS-SD responder timer handler.

This routine must be periodically called by the TCP/IP stack to manage DNS-SD operation

Parameters:
[in]contextPointer to the DNS-SD context

Definition at line 506 of file dns_sd.c.

error_t dnsSdUnregisterService ( DnsSdContext *  context,
const char_t *  serviceName 
)

Unregister a DNS-SD service.

Parameters:
[in]contextPointer to the DNS-SD context
[in]serviceNameNULL-terminated string that contains the name of the service to be unregistered
Returns:
Error code

Definition at line 406 of file dns_sd.c.