mikroSDK Reference Manual
dns_cache.h
Go to the documentation of this file.
1
31#ifndef _DNS_CACHE_H
32#define _DNS_CACHE_H
33
34//Dependencies
35#include "core/net.h"
36#include "core/socket.h"
37
38//DNS tick interval
39#ifndef DNS_TICK_INTERVAL
40 #define DNS_TICK_INTERVAL 200
41#elif (DNS_TICK_INTERVAL < 10)
42 #error DNS_TICK_INTERVAL parameter is not valid
43#endif
44
45//Size of DNS cache
46#ifndef DNS_CACHE_SIZE
47 #define DNS_CACHE_SIZE 8
48#elif (DNS_CACHE_SIZE < 1)
49 #error DNS_CACHE_SIZE parameter is not valid
50#endif
51
52//Maximum length of domain names
53#ifndef DNS_MAX_NAME_LEN
54 #define DNS_MAX_NAME_LEN 63
55#elif (DNS_MAX_NAME_LEN < 1)
56 #error DNS_MAX_NAME_LEN parameter is not valid
57#endif
58
59//Initial polling interval
60#ifndef DNS_CACHE_INIT_POLLING_INTERVAL
61 #define DNS_CACHE_INIT_POLLING_INTERVAL 10
62#elif (DNS_CACHE_INIT_POLLING_INTERVAL < 1)
63 #error DNS_CACHE_INIT_POLLING_INTERVAL parameter is not valid
64#endif
65
66//Maximum polling interval
67#ifndef DNS_CACHE_MAX_POLLING_INTERVAL
68 #define DNS_CACHE_MAX_POLLING_INTERVAL 1000
69#elif (DNS_CACHE_MAX_POLLING_INTERVAL < 10)
70 #error DNS_CACHE_MAX_POLLING_INTERVAL parameter is not valid
71#endif
72
73//C++ guard
74#ifdef __cplusplus
75extern "C" {
76#endif
77
78
83typedef enum
84{
85 DNS_STATE_NONE = 0,
86 DNS_STATE_IN_PROGRESS = 1,
87 DNS_STATE_RESOLVED = 2,
88 DNS_STATE_PERMANENT = 3
89} DnsState;
90
91
112
113
114//Global variables
115extern systime_t dnsTickCounter;
116extern DnsCacheEntry dnsCache[DNS_CACHE_SIZE];
117
118//DNS related functions
119error_t dnsInit(void);
120
121void dnsFlushCache(NetInterface *interface);
122
123DnsCacheEntry *dnsCreateEntry(void);
124void dnsDeleteEntry(DnsCacheEntry *entry);
125
126DnsCacheEntry *dnsFindEntry(NetInterface *interface,
127 const char_t *name, HostType type, HostnameResolver protocol);
128
129void dnsTick(void);
130
131//C++ guard
132#ifdef __cplusplus
133}
134#endif
135
136#endif
DnsState
DNS cache entry states.
Definition dns_cache.h:84
error_t
Error codes.
Definition error.h:43
TCP/IP stack core.
uint32_t systime_t
System time.
Definition os_port_none.h:90
Socket API.
HostType
Host types.
Definition socket.h:202
HostnameResolver
Name resolution protocols.
Definition socket.h:214
DNS cache entry.
Definition dns_cache.h:97
uint_t dnsServerIndex
This parameter selects between the primary and secondary DNS server.
Definition dns_cache.h:102
systime_t maxTimeout
Maximum retransmission timeout.
Definition dns_cache.h:109
HostType type
IPv4 or IPv6 host?
Definition dns_cache.h:99
systime_t timeout
Retransmission timeout.
Definition dns_cache.h:108
uint16_t port
Port number used by the resolver.
Definition dns_cache.h:103
uint_t retransmitCount
Retransmission counter.
Definition dns_cache.h:110
IpAddr ipAddr
IP address.
Definition dns_cache.h:106
uint16_t id
Identifier used to match queries and responses.
Definition dns_cache.h:104
DnsState state
Entry state.
Definition dns_cache.h:98
NetInterface * interface
Underlying network interface.
Definition dns_cache.h:101
systime_t timestamp
Time stamp to manage entry lifetime.
Definition dns_cache.h:107
HostnameResolver protocol
Name resolution protocol.
Definition dns_cache.h:100
IP network address.
Definition ip.h:72