mdns_responder.c File Reference

mDNS responder (Multicast DNS) More...

#include <stdlib.h>
#include <ctype.h>
#include "core/net.h"
#include "mdns/mdns_responder.h"
#include "mdns/mdns_common.h"
#include "dns/dns_debug.h"
#include "dns_sd/dns_sd.h"
#include "str.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   MDNS_TRACE_LEVEL
 

Functions

void mdnsResponderGetDefaultSettings (MdnsResponderSettings *settings)
 Initialize settings with default values. More...
 
error_t mdnsResponderInit (MdnsResponderContext *context, const MdnsResponderSettings *settings)
 mDNS responder initialization More...
 
error_t mdnsResponderStart (MdnsResponderContext *context)
 Start mDNS responder. More...
 
error_t mdnsResponderStop (MdnsResponderContext *context)
 Stop mDNS responder. More...
 
MdnsState mdnsResponderGetState (MdnsResponderContext *context)
 Retrieve current state. More...
 
error_t mdnsResponderSetHostname (MdnsResponderContext *context, const char_t *hostname)
 Set hostname. More...
 
error_t mdnsResponderSetIpv4ReverseName (MdnsResponderContext *context)
 Generate domain name for reverse DNS lookup (IPv4) More...
 
error_t mdnsResponderSetIpv6ReverseName (MdnsResponderContext *context)
 Generate domain name for reverse DNS lookup (IPv6) More...
 
error_t mdnsResponderStartProbing (MdnsResponderContext *context)
 Restart probing process. More...
 
void mdnsResponderTick (MdnsResponderContext *context)
 mDNS responder timer handler More...
 
void mdnsResponderLinkChangeEvent (MdnsResponderContext *context)
 Callback function for link change event. More...
 
void mdnsResponderChangeState (MdnsResponderContext *context, MdnsState newState, systime_t delay)
 Update FSM state. More...
 
void mdnsResponderChangeHostname (MdnsResponderContext *context)
 Programmatically change the host name. More...
 
error_t mdnsResponderSendProbe (MdnsResponderContext *context)
 Send probe packet. More...
 
error_t mdnsResponderSendAnnouncement (MdnsResponderContext *context)
 Send announcement packet. More...
 
error_t mdnsResponderSendGoodbye (MdnsResponderContext *context)
 Send goodbye packet. More...
 
void mdnsResponderProcessQuery (NetInterface *interface, MdnsMessage *query)
 Process mDNS query message. More...
 
error_t mdnsResponderParseQuestion (NetInterface *interface, const MdnsMessage *query, size_t offset, const DnsQuestion *question, MdnsMessage *response)
 Parse a question. More...
 
void mdnsResponderParseKnownAnRecord (NetInterface *interface, const MdnsMessage *query, size_t queryOffset, const DnsResourceRecord *queryRecord, MdnsMessage *response)
 Parse a resource record from the Known-Answer Section. More...
 
void mdnsResponderParseNsRecord (NetInterface *interface, const MdnsMessage *query, size_t offset, const DnsResourceRecord *record)
 Parse a resource record from the Authority Section. More...
 
void mdnsResponderParseAnRecord (NetInterface *interface, const MdnsMessage *response, size_t offset, const DnsResourceRecord *record)
 Parse a resource record from the Answer Section. More...
 
void mdnsResponderGenerateAdditionalRecords (NetInterface *interface, MdnsMessage *response, bool_t legacyUnicast)
 Additional record generation. More...
 
error_t mdnsResponderAddIpv4AddrRecord (NetInterface *interface, MdnsMessage *message, bool_t cacheFlush, uint32_t ttl)
 Add A record to a mDNS message. More...
 
error_t mdnsResponderAddIpv6AddrRecord (NetInterface *interface, MdnsMessage *message, bool_t cacheFlush, uint32_t ttl)
 Add AAAA record to a mDNS message. More...
 
error_t mdnsResponderAddIpv4ReversePtrRecord (NetInterface *interface, MdnsMessage *message, bool_t cacheFlush, uint32_t ttl)
 Add reverse address mapping PTR record (IPv4) More...
 
error_t mdnsResponderAddIpv6ReversePtrRecord (NetInterface *interface, MdnsMessage *message, bool_t cacheFlush, uint32_t ttl)
 Add reverse address mapping PTR record (IPv6) More...
 
error_t mdnsResponderAddNsecRecord (NetInterface *interface, MdnsMessage *message, bool_t cacheFlush, uint32_t ttl)
 Add NSEC record to a mDNS message. More...
 

Variables

systime_t mdnsResponderTickCounter
 

Detailed Description

mDNS responder (Multicast DNS)

License

Copyright (C) 2010-2018 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.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
1.9.0

Definition in file mdns_responder.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   MDNS_TRACE_LEVEL

Definition at line 30 of file mdns_responder.c.

Function Documentation

◆ mdnsResponderAddIpv4AddrRecord()

error_t mdnsResponderAddIpv4AddrRecord ( NetInterface interface,
MdnsMessage message,
bool_t  cacheFlush,
uint32_t  ttl 
)

Add A record to a mDNS message.

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

Definition at line 1884 of file mdns_responder.c.

◆ mdnsResponderAddIpv4ReversePtrRecord()

error_t mdnsResponderAddIpv4ReversePtrRecord ( NetInterface interface,
MdnsMessage message,
bool_t  cacheFlush,
uint32_t  ttl 
)

Add reverse address mapping PTR record (IPv4)

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

Definition at line 2052 of file mdns_responder.c.

◆ mdnsResponderAddIpv6AddrRecord()

error_t mdnsResponderAddIpv6AddrRecord ( NetInterface interface,
MdnsMessage message,
bool_t  cacheFlush,
uint32_t  ttl 
)

Add AAAA record to a mDNS message.

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

Definition at line 1968 of file mdns_responder.c.

◆ mdnsResponderAddIpv6ReversePtrRecord()

error_t mdnsResponderAddIpv6ReversePtrRecord ( NetInterface interface,
MdnsMessage message,
bool_t  cacheFlush,
uint32_t  ttl 
)

Add reverse address mapping PTR record (IPv6)

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

Definition at line 2148 of file mdns_responder.c.

◆ mdnsResponderAddNsecRecord()

error_t mdnsResponderAddNsecRecord ( NetInterface interface,
MdnsMessage message,
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]cacheFlushCache-flush bit
[in]ttlResource record TTL (cache lifetime)
Returns
Error code

Definition at line 2244 of file mdns_responder.c.

◆ mdnsResponderChangeHostname()

void mdnsResponderChangeHostname ( MdnsResponderContext context)

Programmatically change the host name.

Parameters
[in]contextPointer to the mDNS responder context

Definition at line 713 of file mdns_responder.c.

◆ mdnsResponderChangeState()

void mdnsResponderChangeState ( MdnsResponderContext context,
MdnsState  newState,
systime_t  delay 
)

Update FSM state.

Parameters
[in]contextPointer to the mDNS responder context
[in]newStateNew state to switch to
[in]delayInitial delay

Definition at line 678 of file mdns_responder.c.

◆ mdnsResponderGenerateAdditionalRecords()

void mdnsResponderGenerateAdditionalRecords ( 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 1713 of file mdns_responder.c.

◆ mdnsResponderGetDefaultSettings()

void mdnsResponderGetDefaultSettings ( MdnsResponderSettings settings)

Initialize settings with default values.

Parameters
[out]settingsStructure that contains mDNS responder settings

Definition at line 55 of file mdns_responder.c.

◆ mdnsResponderGetState()

MdnsState mdnsResponderGetState ( MdnsResponderContext context)

Retrieve current state.

Parameters
[in]contextPointer to the mDNS responder context
Returns
Current mDNS responder state

Definition at line 181 of file mdns_responder.c.

◆ mdnsResponderInit()

error_t mdnsResponderInit ( MdnsResponderContext context,
const MdnsResponderSettings settings 
)

mDNS responder initialization

Parameters
[in]contextPointer to the mDNS responder context
[in]settingsmDNS responder specific settings
Returns
Error code

Definition at line 76 of file mdns_responder.c.

◆ mdnsResponderLinkChangeEvent()

void mdnsResponderLinkChangeEvent ( MdnsResponderContext context)

Callback function for link change event.

Parameters
[in]contextPointer to the mDNS responder context

Definition at line 649 of file mdns_responder.c.

◆ mdnsResponderParseAnRecord()

void mdnsResponderParseAnRecord ( 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 1615 of file mdns_responder.c.

◆ mdnsResponderParseKnownAnRecord()

void mdnsResponderParseKnownAnRecord ( NetInterface interface,
const MdnsMessage query,
size_t  queryOffset,
const DnsResourceRecord queryRecord,
MdnsMessage response 
)

Parse a resource record from the Known-Answer Section.

Parameters
[in]interfaceUnderlying network interface
[in]queryIncoming mDNS query message
[in]queryOffsetOffset to first byte of the resource record
[in]queryRecordPointer to the resource record
[in,out]responsemDNS response message

Definition at line 1428 of file mdns_responder.c.

◆ mdnsResponderParseNsRecord()

void mdnsResponderParseNsRecord ( 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 1511 of file mdns_responder.c.

◆ mdnsResponderParseQuestion()

error_t mdnsResponderParseQuestion ( 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 1261 of file mdns_responder.c.

◆ mdnsResponderProcessQuery()

void mdnsResponderProcessQuery ( NetInterface interface,
MdnsMessage query 
)

Process mDNS query message.

Parameters
[in]interfaceUnderlying network interface
[in]queryIncoming mDNS query message

Definition at line 976 of file mdns_responder.c.

◆ mdnsResponderSendAnnouncement()

error_t mdnsResponderSendAnnouncement ( MdnsResponderContext context)

Send announcement packet.

Parameters
[in]contextPointer to the mDNS responder context
Returns
Error code

Definition at line 848 of file mdns_responder.c.

◆ mdnsResponderSendGoodbye()

error_t mdnsResponderSendGoodbye ( MdnsResponderContext context)

Send goodbye packet.

Parameters
[in]contextPointer to the mDNS responder context
Returns
Error code

Definition at line 914 of file mdns_responder.c.

◆ mdnsResponderSendProbe()

error_t mdnsResponderSendProbe ( MdnsResponderContext context)

Send probe packet.

Parameters
[in]contextPointer to the mDNS responder context
Returns
Error code

Definition at line 773 of file mdns_responder.c.

◆ mdnsResponderSetHostname()

error_t mdnsResponderSetHostname ( MdnsResponderContext context,
const char_t hostname 
)

Set hostname.

Parameters
[in]contextPointer to the mDNS responder context
[in]hostnameNULL-terminated string that contains the hostname
Returns
Error code

Definition at line 204 of file mdns_responder.c.

◆ mdnsResponderSetIpv4ReverseName()

error_t mdnsResponderSetIpv4ReverseName ( MdnsResponderContext context)

Generate domain name for reverse DNS lookup (IPv4)

Parameters
[in]contextPointer to the mDNS responder context
Returns
Error code

Definition at line 256 of file mdns_responder.c.

◆ mdnsResponderSetIpv6ReverseName()

error_t mdnsResponderSetIpv6ReverseName ( MdnsResponderContext context)

Generate domain name for reverse DNS lookup (IPv6)

Parameters
[in]contextPointer to the mDNS responder context
Returns
Error code

Definition at line 297 of file mdns_responder.c.

◆ mdnsResponderStart()

error_t mdnsResponderStart ( MdnsResponderContext context)

Start mDNS responder.

Parameters
[in]contextPointer to the mDNS responder context
Returns
Error code

Definition at line 119 of file mdns_responder.c.

◆ mdnsResponderStartProbing()

error_t mdnsResponderStartProbing ( MdnsResponderContext context)

Restart probing process.

Parameters
[in]contextPointer to the mDNS responder context
Returns
Error code

Definition at line 356 of file mdns_responder.c.

◆ mdnsResponderStop()

error_t mdnsResponderStop ( MdnsResponderContext context)

Stop mDNS responder.

Parameters
[in]contextPointer to the mDNS responder context
Returns
Error code

Definition at line 150 of file mdns_responder.c.

◆ mdnsResponderTick()

void mdnsResponderTick ( MdnsResponderContext context)

mDNS responder timer handler

This routine must be periodically called by the TCP/IP stack to manage mDNS operation

Parameters
[in]contextPointer to the mDNS responder context

Definition at line 383 of file mdns_responder.c.

Variable Documentation

◆ mdnsResponderTickCounter

systime_t mdnsResponderTickCounter

Definition at line 47 of file mdns_responder.c.