Loading...
Searching...
No Matches
cache.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 ML!PA Consulting GmbH
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
33#ifndef NET_DNS_CACHE_H
34#define NET_DNS_CACHE_H
35
36#include <stdint.h>
37
38#include "modules.h"
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
47#ifndef CONFIG_DNS_CACHE_SIZE
48#define CONFIG_DNS_CACHE_SIZE 4
49#endif
50
54#ifndef CONFIG_DNS_CACHE_A
55#define CONFIG_DNS_CACHE_A IS_USED(MODULE_IPV4)
56#endif
57
61#ifndef CONFIG_DNS_CACHE_AAAA
62#define CONFIG_DNS_CACHE_AAAA IS_USED(MODULE_IPV6)
63#endif
64
65#if IS_USED(MODULE_DNS_CACHE) || DOXYGEN
76int dns_cache_query(const char *domain_name, void *addr_out, int family);
77
86void dns_cache_add(const char *domain_name, const void *addr, int addr_len, uint32_t ttl);
87#else
88static inline int dns_cache_query(const char *domain_name, void *addr_out, int family)
89{
90 (void)domain_name;
91 (void)addr_out;
92 (void)family;
93 return 0;
94}
95
96static inline void dns_cache_add(const char *domain_name, const void *addr,
97 int addr_len, uint32_t ttl)
98{
99 (void)domain_name;
100 (void)addr;
101 (void)addr_len;
102 (void)ttl;
103}
104#endif
105
106#ifdef __cplusplus
107}
108#endif
109
110#endif /* NET_DNS_CACHE_H */
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.
Common macros and compiler attributes/pragmas configuration.