Helper functions for mDNS responder. More...
#include "core/net.h"
#include "mdns/mdns_responder.h"
#include "mdns/mdns_responder_misc.h"
#include "dns_sd/dns_sd_responder.h"
#include "dns_sd/dns_sd_responder_misc.h"
#include "debug.h"
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... | |
DnsResourceRecord * | mdnsResponderGetNextHostRecord (MdnsResponderContext *context, DnsResourceRecord *record) |
Sort the host records in lexicographical order. More... | |
DnsResourceRecord * | mdnsResponderGetNextTiebreakerRecord (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.
- 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] context Pointer 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] context Pointer to the mDNS responder context [in] newState New state to switch to [in] delay Initial 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] context Pointer to the mDNS responder context [in,out] message Pointer to the mDNS message [in] ipv4Addr Pointer to the IPv4 address [in] cacheFlush Cache-flush bit [in] ttl Resource 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] context Pointer to the mDNS responder context [in,out] message Pointer to the mDNS message [in] reverseName Domain name for reverse DNS lookup [in] cacheFlush Cache-flush bit [in] ttl Resource 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] context Pointer to the mDNS responder context [in,out] message Pointer to the mDNS message [in] ipv6Addr Pointer to the IPv6 address [in] cacheFlush Cache-flush bit [in] ttl Resource 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] context Pointer to the mDNS responder context [in,out] message Pointer to the mDNS message [in] reverseName Domain name for reverse DNS lookup [in] cacheFlush Cache-flush bit [in] ttl Resource 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] context Pointer to the mDNS responder context [in,out] message Pointer to the mDNS message [in] cacheFlush Cache-flush bit [in] ttl Resource 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] context Pointer to the mDNS responder context [in,out] response mDNS response message [in] legacyUnicast This 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] context Pointer to the mDNS responder context [in,out] message Pointer to the mDNS message [in] cacheFlush Cache-flush bit [in] ttl Resource 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] context Pointer to the mDNS responder context [in,out] message Pointer to the mDNS message [in] cacheFlush Cache-flush bit [in] ttl Resource 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] context Pointer to the mDNS responder context [in,out] message Pointer to the mDNS message [in] cacheFlush Cache-flush bit [in] ttl Resource 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] context Pointer to the mDNS responder context [in,out] message Pointer to the mDNS message [in] cacheFlush Cache-flush bit [in] ttl Resource 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] context Pointer to the mDNS responder context [in] record Pointer 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] context Pointer to the mDNS responder context [in] query Incoming mDNS query message [in] offset Offset to first byte of the Authority Section [in] record Pointer 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] interface Underlying network interface [in] response Incoming mDNS response message [in] offset Offset to first byte of the resource record to be checked [in] record Pointer 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] interface Underlying network interface [in] query Incoming mDNS query message [in] queryOffset Offset to first byte of the resource record [in] queryRecord Pointer to the resource record [in,out] response mDNS 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] context Pointer to the mDNS responder context [in] query Incoming mDNS query message [in] offset Offset 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] interface Underlying network interface [in] query Incoming mDNS query message [in] offset Offset to first byte of the question [in] question Pointer to the question [in,out] response mDNS 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] interface Underlying network interface [in] query Incoming mDNS query message
Definition at line 353 of file mdns_responder_misc.c.
◆ mdnsResponderSendAnnouncement()
error_t mdnsResponderSendAnnouncement | ( | MdnsResponderContext * | context | ) |
Send announcement packet.
- Parameters
-
[in] context Pointer 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] context Pointer 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] context Pointer to the mDNS responder context
- Returns
- Error code
Definition at line 150 of file mdns_responder_misc.c.