Loading...
Searching...
No Matches
cache.h File Reference

DNS cache definitions. More...

Detailed Description

DNS cache definitions.

This implements a simple DNS cache for A and AAAA entries.

The cache eviction strategy is based on the remaining time to live of the cache entries, so the first entry to expire will be evicted.

This is fine if there are only few cache entries and cache eviction is unlikely. If there is communication to many different hosts, the addition of a least-recently used counter could likely improve the behavior.

Author
Benjamin Valentin benja.nosp@m.min..nosp@m.valen.nosp@m.tin@.nosp@m.ml-pa.nosp@m..com

Definition in file cache.h.

#include <stdint.h>
#include "modules.h"
+ Include dependency graph for cache.h:

Go to the source code of this file.

Macros

#define CONFIG_DNS_CACHE_SIZE   4
 Maximum number of DNS cache entries.
 
#define CONFIG_DNS_CACHE_A   IS_USED(MODULE_IPV4)
 Handle to cache A records.
 
#define CONFIG_DNS_CACHE_AAAA   IS_USED(MODULE_IPV6)
 Handle to cache AAAA records.
 

Functions

int dns_cache_query (const char *domain_name, void *addr_out, int family)
 Get IP address for a DNS name from the DNS cache.
 
void dns_cache_add (const char *domain_name, const void *addr, int addr_len, uint32_t ttl)
 Add an IP address for a DNS name to the DNS cache.