dns_client.h
Go to the documentation of this file.
1 /**
2  * @file dns_client.h
3  * @brief DNS client (Domain Name System)
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2019 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 1.9.6
29  **/
30 
31 #ifndef _DNS_CLIENT_H
32 #define _DNS_CLIENT_H
33 
34 //Dependencies
35 #include "core/net.h"
36 #include "core/socket.h"
37 #include "core/udp.h"
38 #include "dns/dns_cache.h"
39 
40 //DNS client support
41 #ifndef DNS_CLIENT_SUPPORT
42  #define DNS_CLIENT_SUPPORT ENABLED
43 #elif (DNS_CLIENT_SUPPORT != ENABLED && DNS_CLIENT_SUPPORT != DISABLED)
44  #error DNS_CLIENT_SUPPORT parameter is not valid
45 #endif
46 
47 //Maximum number of retransmissions of DNS queries
48 #ifndef DNS_CLIENT_MAX_RETRIES
49  #define DNS_CLIENT_MAX_RETRIES 3
50 #elif (DNS_CLIENT_MAX_RETRIES < 1)
51  #error DNS_CLIENT_MAX_RETRIES parameter is not valid
52 #endif
53 
54 //Initial retransmission timeout
55 #ifndef DNS_CLIENT_INIT_TIMEOUT
56  #define DNS_CLIENT_INIT_TIMEOUT 1000
57 #elif (DNS_CLIENT_INIT_TIMEOUT < 1000)
58  #error DNS_CLIENT_INIT_TIMEOUT parameter is not valid
59 #endif
60 
61 //Maximum retransmission timeout
62 #ifndef DNS_CLIENT_MAX_TIMEOUT
63  #define DNS_CLIENT_MAX_TIMEOUT 5000
64 #elif (DNS_CLIENT_MAX_TIMEOUT < 1000)
65  #error DNS_CLIENT_MAX_TIMEOUT parameter is not valid
66 #endif
67 
68 //Minimum cache lifetime for DNS entries
69 #ifndef DNS_MIN_LIFETIME
70  #define DNS_MIN_LIFETIME 1000
71 #elif (DNS_MIN_LIFETIME < 0)
72  #error DNS_MIN_LIFETIME parameter is not valid
73 #endif
74 
75 //Maximum cache lifetime for DNS entries
76 #ifndef DNS_MAX_LIFETIME
77  #define DNS_MAX_LIFETIME 3600000
78 #elif (DNS_MAX_LIFETIME < 1000 || DNS_MAX_LIFETIME < DNS_MIN_LIFETIME)
79  #error DNS_MAX_LIFETIME parameter is not valid
80 #endif
81 
82 //C++ guard
83 #ifdef __cplusplus
84 extern "C" {
85 #endif
86 
87 //DNS related functions
88 error_t dnsResolve(NetInterface *interface, const char_t *name,
90 
92 
93 void dnsProcessResponse(NetInterface *interface, const IpPseudoHeader *pseudoHeader,
94  const UdpHeader *udpHeader, const NetBuffer *buffer, size_t offset, void *param);
95 
96 //C++ guard
97 #ifdef __cplusplus
98 }
99 #endif
100 
101 #endif
HostType
Host types.
Definition: socket.h:171
void dnsProcessResponse(NetInterface *interface, const IpPseudoHeader *pseudoHeader, const UdpHeader *udpHeader, const NetBuffer *buffer, size_t offset, void *param)
Process incoming DNS response message.
Definition: dns_client.c:361
error_t dnsResolve(NetInterface *interface, const char_t *name, HostType type, IpAddr *ipAddr)
Resolve a host name using DNS.
Definition: dns_client.c:54
IP network address.
Definition: ip.h:71
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:88
char_t name[]
IP pseudo header.
Definition: ip.h:90
char_t type
error_t
Error codes.
Definition: error.h:42
#define NetInterface
Definition: net.h:36
DNS cache entry.
Definition: dns_cache.h:96
__start_packed struct @122 UdpHeader
UDP header.
char char_t
Definition: compiler_port.h:43
DNS cache management.
UDP (User Datagram Protocol)
Socket API.
error_t dnsSendQuery(DnsCacheEntry *entry)
Send a DNS query message.
Definition: dns_client.c:217
TCP/IP stack core.
uint8_t ipAddr[4]
Definition: mib_common.h:187