mdns_responder_misc.c File Reference

Helper functions for mDNS responder. More...

Go to the source code of this file.

Macros

#define TRACE_LEVEL   MDNS_TRACE_LEVEL
 

Functions

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 mdnsResponderParseAnRecord (NetInterface *interface, const MdnsMessage *response, size_t offset, const DnsResourceRecord *record)
 Parse a resource record from the Answer Section. More...
 
void mdnsResponderParseNsRecords (MdnsResponderContext *context, const MdnsMessage *query, size_t offset)
 Parse the Authority Section. More...
 
void mdnsResponderGenerateAdditionalRecords (MdnsResponderContext *context, MdnsMessage *response, bool_t legacyUnicast)
 Generate additional records. More...
 
error_t mdnsResponderGenerateIpv4AddrRecords (MdnsResponderContext *context, MdnsMessage *message, bool_t cacheFlush, uint32_t ttl)
 Generate A resource records. More...
 
error_t mdnsResponderGenerateIpv6AddrRecords (MdnsResponderContext *context, MdnsMessage *message, bool_t cacheFlush, uint32_t ttl)
 Generate AAAA resource records. More...
 
error_t mdnsResponderGenerateIpv4PtrRecords (MdnsResponderContext *context, MdnsMessage *message, bool_t cacheFlush, uint32_t ttl)
 Generate reverse address mapping PTR resource record (IPv4) More...
 
error_t mdnsResponderGenerateIpv6PtrRecords (MdnsResponderContext *context, MdnsMessage *message, bool_t cacheFlush, uint32_t ttl)
 Generate reverse address mapping PTR resource record (IPv6) More...
 
error_t mdnsResponderFormatIpv4AddrRecord (MdnsResponderContext *context, MdnsMessage *message, const uint8_t *ipv4Addr, bool_t cacheFlush, uint32_t ttl)
 Format A resource record. More...
 
error_t mdnsResponderFormatIpv6AddrRecord (MdnsResponderContext *context, MdnsMessage *message, const uint8_t *ipv6Addr, bool_t cacheFlush, uint32_t ttl)
 Format AAAA resource record. More...
 
error_t mdnsResponderFormatIpv4PtrRecord (MdnsResponderContext *context, MdnsMessage *message, const char_t *reverseName, bool_t cacheFlush, uint32_t ttl)
 Format reverse address mapping PTR resource record (IPv4) More...
 
error_t mdnsResponderFormatIpv6PtrRecord (MdnsResponderContext *context, MdnsMessage *message, const char_t *reverseName, bool_t cacheFlush, uint32_t ttl)
 Format reverse address mapping PTR resource record (IPv6) More...
 
error_t mdnsResponderFormatNsecRecord (MdnsResponderContext *context, MdnsMessage *message, bool_t cacheFlush, uint32_t ttl)
 Format NSEC resource record. More...
 
DnsResourceRecordmdnsResponderGetNextHostRecord (MdnsResponderContext *context, DnsResourceRecord *record)
 Sort the host records in lexicographical order. More...
 
DnsResourceRecordmdnsResponderGetNextTiebreakerRecord (MdnsResponderContext *context, const MdnsMessage *query, size_t offset, DnsResourceRecord *record)
 Sort the tiebreaker records in lexicographical order. More...
 

Detailed Description

Helper functions for mDNS responder.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2024 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
2.4.4

Definition in file mdns_responder_misc.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   MDNS_TRACE_LEVEL

Definition at line 32 of file mdns_responder_misc.c.

Function Documentation

◆ mdnsResponderChangeHostname()

void mdnsResponderChangeHostname ( MdnsResponderContext context)

Programmatically change the host name.

Parameters
[in]contextPointer to the mDNS responder context

Definition at line 88 of file mdns_responder_misc.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 53 of file mdns_responder_misc.c.

◆ mdnsResponderFormatIpv4AddrRecord()

error_t mdnsResponderFormatIpv4AddrRecord ( MdnsResponderContext context,
MdnsMessage message,
const uint8_t *  ipv4Addr,
bool_t  cacheFlush,
uint32_t  ttl 
)

Format A resource record.

Parameters
[in]contextPointer to the mDNS responder context
[in,out]messagePointer to the mDNS message
[in]ipv4AddrPointer to the IPv4 address
[in]cacheFlushCache-flush bit
[in]ttlResource record TTL (cache lifetime)
Returns
Error code

Definition at line 1581 of file mdns_responder_misc.c.

◆ mdnsResponderFormatIpv4PtrRecord()

error_t mdnsResponderFormatIpv4PtrRecord ( MdnsResponderContext context,
MdnsMessage message,
const char_t reverseName,
bool_t  cacheFlush,
uint32_t  ttl 
)

Format reverse address mapping PTR resource record (IPv4)

Parameters
[in]contextPointer to the mDNS responder context
[in,out]messagePointer to the mDNS message
[in]reverseNameDomain name for reverse DNS lookup
[in]cacheFlushCache-flush bit
[in]ttlResource record TTL (cache lifetime)
Returns
Error code

Definition at line 1737 of file mdns_responder_misc.c.

◆ mdnsResponderFormatIpv6AddrRecord()

error_t mdnsResponderFormatIpv6AddrRecord ( MdnsResponderContext context,
MdnsMessage message,
const uint8_t *  ipv6Addr,
bool_t  cacheFlush,
uint32_t  ttl 
)

Format AAAA resource record.

Parameters
[in]contextPointer to the mDNS responder context
[in,out]messagePointer to the mDNS message
[in]ipv6AddrPointer to the IPv6 address
[in]cacheFlushCache-flush bit
[in]ttlResource record TTL (cache lifetime)
Returns
Error code

Definition at line 1659 of file mdns_responder_misc.c.

◆ mdnsResponderFormatIpv6PtrRecord()

error_t mdnsResponderFormatIpv6PtrRecord ( MdnsResponderContext context,
MdnsMessage message,
const char_t reverseName,
bool_t  cacheFlush,
uint32_t  ttl 
)

Format reverse address mapping PTR resource record (IPv6)

Parameters
[in]contextPointer to the mDNS responder context
[in,out]messagePointer to the mDNS message
[in]reverseNameDomain name for reverse DNS lookup
[in]cacheFlushCache-flush bit
[in]ttlResource record TTL (cache lifetime)
Returns
Error code

Definition at line 1827 of file mdns_responder_misc.c.

◆ mdnsResponderFormatNsecRecord()

error_t mdnsResponderFormatNsecRecord ( MdnsResponderContext context,
MdnsMessage message,
bool_t  cacheFlush,
uint32_t  ttl 
)

Format NSEC resource record.

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

Definition at line 1916 of file mdns_responder_misc.c.

◆ mdnsResponderGenerateAdditionalRecords()

void mdnsResponderGenerateAdditionalRecords ( MdnsResponderContext context,
MdnsMessage response,
bool_t  legacyUnicast 
)

Generate additional records.

Parameters
[in]contextPointer to the mDNS responder context
[in,out]responsemDNS response message
[in]legacyUnicastThis flag is set for legacy unicast responses

Definition at line 1245 of file mdns_responder_misc.c.

◆ mdnsResponderGenerateIpv4AddrRecords()

error_t mdnsResponderGenerateIpv4AddrRecords ( MdnsResponderContext context,
MdnsMessage message,
bool_t  cacheFlush,
uint32_t  ttl 
)

Generate A resource records.

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

Definition at line 1420 of file mdns_responder_misc.c.

◆ mdnsResponderGenerateIpv4PtrRecords()

error_t mdnsResponderGenerateIpv4PtrRecords ( MdnsResponderContext context,
MdnsMessage message,
bool_t  cacheFlush,
uint32_t  ttl 
)

Generate reverse address mapping PTR resource record (IPv4)

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

Definition at line 1500 of file mdns_responder_misc.c.

◆ mdnsResponderGenerateIpv6AddrRecords()

error_t mdnsResponderGenerateIpv6AddrRecords ( MdnsResponderContext context,
MdnsMessage message,
bool_t  cacheFlush,
uint32_t  ttl 
)

Generate AAAA resource records.

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

Definition at line 1460 of file mdns_responder_misc.c.

◆ mdnsResponderGenerateIpv6PtrRecords()

error_t mdnsResponderGenerateIpv6PtrRecords ( MdnsResponderContext context,
MdnsMessage message,
bool_t  cacheFlush,
uint32_t  ttl 
)

Generate reverse address mapping PTR resource record (IPv6)

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

Definition at line 1540 of file mdns_responder_misc.c.

◆ mdnsResponderGetNextHostRecord()

DnsResourceRecord* mdnsResponderGetNextHostRecord ( MdnsResponderContext context,
DnsResourceRecord record 
)

Sort the host records in lexicographical order.

Parameters
[in]contextPointer to the mDNS responder context
[in]recordPointer to the current record
Returns
Pointer to the next record, if any

Definition at line 2031 of file mdns_responder_misc.c.

◆ mdnsResponderGetNextTiebreakerRecord()

DnsResourceRecord* mdnsResponderGetNextTiebreakerRecord ( MdnsResponderContext context,
const MdnsMessage query,
size_t  offset,
DnsResourceRecord record 
)

Sort the tiebreaker records in lexicographical order.

Parameters
[in]contextPointer to the mDNS responder context
[in]queryIncoming mDNS query message
[in]offsetOffset to first byte of the Authority Section
[in]recordPointer to the current record
Returns
Pointer to the next record, if any

Definition at line 2128 of file mdns_responder_misc.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 940 of file mdns_responder_misc.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 849 of file mdns_responder_misc.c.

◆ mdnsResponderParseNsRecords()

void mdnsResponderParseNsRecords ( MdnsResponderContext context,
const MdnsMessage query,
size_t  offset 
)

Parse the Authority Section.

Parameters
[in]contextPointer to the mDNS responder context
[in]queryIncoming mDNS query message
[in]offsetOffset to first byte of the Authority Section

Definition at line 1160 of file mdns_responder_misc.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 642 of file mdns_responder_misc.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 353 of file mdns_responder_misc.c.

◆ mdnsResponderSendAnnouncement()

error_t mdnsResponderSendAnnouncement ( MdnsResponderContext context)

Send announcement packet.

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

Definition at line 225 of file mdns_responder_misc.c.

◆ mdnsResponderSendGoodbye()

error_t mdnsResponderSendGoodbye ( MdnsResponderContext context)

Send goodbye packet.

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

Definition at line 291 of file mdns_responder_misc.c.

◆ mdnsResponderSendProbe()

error_t mdnsResponderSendProbe ( MdnsResponderContext context)

Send probe packet.

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

Definition at line 150 of file mdns_responder_misc.c.