Common DNS routines. More...
#include "core/net.h"
#include "dns/dns_client.h"
#include "dns/dns_common.h"
#include "mdns/mdns_client.h"
#include "mdns/mdns_responder.h"
#include "mdns/mdns_common.h"
#include "llmnr/llmnr_client.h"
#include "llmnr/llmnr_responder.h"
#include "debug.h"
Go to the source code of this file.
Macros | |
#define | TRACE_LEVEL DNS_TRACE_LEVEL |
Functions | |
size_t | dnsEncodeName (const char_t *src, uint8_t *dest) |
Encode a domain name using the DNS name notation. More... | |
size_t | dnsParseName (const DnsHeader *message, size_t length, size_t pos, char_t *dest, uint_t level) |
Decode a domain name that uses the DNS name encoding. More... | |
int_t | dnsCompareName (const DnsHeader *message, size_t length, size_t pos, const char_t *name, uint_t level) |
Compare domain names. More... | |
int_t | dnsCompareEncodedName (const DnsHeader *message1, size_t length1, size_t pos1, const DnsHeader *message2, size_t length2, size_t pos2, uint_t level) |
Compare domain names encoded with DNS notation. More... | |
void | dnsGenerateIpv4ReverseName (Ipv4Addr ipv4Addr, char_t *buffer) |
Generate domain name for reverse DNS lookup (IPv4) More... | |
void | dnsGenerateIpv6ReverseName (const Ipv6Addr *ipv6Addr, char_t *buffer) |
Generate domain name for reverse DNS lookup (IPv6) More... | |
Detailed Description
Common DNS routines.
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 dns_common.c.
Macro Definition Documentation
◆ TRACE_LEVEL
#define TRACE_LEVEL DNS_TRACE_LEVEL |
Definition at line 32 of file dns_common.c.
Function Documentation
◆ dnsCompareEncodedName()
int_t dnsCompareEncodedName | ( | const DnsHeader * | message1, |
size_t | length1, | ||
size_t | pos1, | ||
const DnsHeader * | message2, | ||
size_t | length2, | ||
size_t | pos2, | ||
uint_t | level | ||
) |
Compare domain names encoded with DNS notation.
- Parameters
-
[in] message1 Pointer to the first DNS message [in] length1 Length of the first DNS message [in] pos1 Offset of the encoded domain name within the first message [in] message2 Pointer to the second DNS message [in] length2 Length of the second DNS message [in] pos2 Offset of the encoded domain name within the second message [in] level Current level of recursion
- Returns
- The function returns 0 if the domain names match, -1 if the first domain name lexicographically precedes the second name, or 1 if the second domain name lexicographically precedes the first name
Definition at line 341 of file dns_common.c.
◆ dnsCompareName()
int_t dnsCompareName | ( | const DnsHeader * | message, |
size_t | length, | ||
size_t | pos, | ||
const char_t * | name, | ||
uint_t | level | ||
) |
Compare domain names.
- Parameters
-
[in] message Pointer to the DNS message [in] length Length of the DNS message [in] pos Offset of the encoded domain name [in] name NULL-terminated string that holds a domain name [in] level Current level of recursion
- Returns
- The function returns 0 if the domain names match, -1 if the first domain name lexicographically precedes the second name, or 1 if the second domain name lexicographically precedes the first name
Definition at line 242 of file dns_common.c.
◆ dnsEncodeName()
size_t dnsEncodeName | ( | const char_t * | src, |
uint8_t * | dest | ||
) |
Encode a domain name using the DNS name notation.
- Parameters
-
[in] src Pointer to the domain name to encode [out] dest Pointer to the encoded domain name (optional parameter)
- Returns
- Length of the encoded domain name
Definition at line 58 of file dns_common.c.
◆ dnsGenerateIpv4ReverseName()
Generate domain name for reverse DNS lookup (IPv4)
- Parameters
-
[in] ipv4Addr IPv4 address [out] buffer Output buffer where to store the resulting domain name
Definition at line 479 of file dns_common.c.
◆ dnsGenerateIpv6ReverseName()
Generate domain name for reverse DNS lookup (IPv6)
- Parameters
-
[in] ipv6Addr IPv6 address [out] buffer Output buffer where to store the resulting domain name
Definition at line 498 of file dns_common.c.
◆ dnsParseName()
size_t dnsParseName | ( | const DnsHeader * | message, |
size_t | length, | ||
size_t | pos, | ||
char_t * | dest, | ||
uint_t | level | ||
) |
Decode a domain name that uses the DNS name encoding.
- Parameters
-
[in] message Pointer to the DNS message [in] length Length of the DNS message [in] pos Offset of the name to decode [out] dest Pointer to the decoded name (optional) [in] level Current level of recursion
- Returns
- The position of the resource record that immediately follows the domain name
Definition at line 132 of file dns_common.c.