Loading...
Searching...
No Matches
cache.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2022 ML!PA Consulting GmbH
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
31
32#include <stdint.h>
33
34#include "modules.h"
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
43#ifndef CONFIG_DNS_CACHE_SIZE
44#define CONFIG_DNS_CACHE_SIZE 4
45#endif
46
50#ifndef CONFIG_DNS_CACHE_A
51#define CONFIG_DNS_CACHE_A IS_USED(MODULE_IPV4)
52#endif
53
57#ifndef CONFIG_DNS_CACHE_AAAA
58#define CONFIG_DNS_CACHE_AAAA IS_USED(MODULE_IPV6)
59#endif
60
61#if IS_USED(MODULE_DNS_CACHE) || DOXYGEN
72int dns_cache_query(const char *domain_name, void *addr_out, int family);
73
82void dns_cache_add(const char *domain_name, const void *addr, int addr_len, uint32_t ttl);
83#else
84static inline int dns_cache_query(const char *domain_name, void *addr_out, int family)
85{
86 (void)domain_name;
87 (void)addr_out;
88 (void)family;
89 return 0;
90}
91
92static inline void dns_cache_add(const char *domain_name, const void *addr,
93 int addr_len, uint32_t ttl)
94{
95 (void)domain_name;
96 (void)addr;
97 (void)addr_len;
98 (void)ttl;
99}
100#endif
101
102#ifdef __cplusplus
103}
104#endif
105
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.