-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrb_dns_cache.h
61 lines (47 loc) · 1.78 KB
/
rb_dns_cache.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
Copyright (C) 2016 Eneo Tecnologia S.L.
Author: Eugenio Perez <eupm90@gmail.com>
Based on Luca Deri nprobe 6.22 collector
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#ifdef HAVE_UDNS
#include <udns.h>
#include <librd/rdavl.h>
#include <librd/rdsysqueue.h>
#include <librd/rdmem.h>
#include <stdint.h>
#include <stdint.h>
#ifndef NDEBUG
#define RB_DNS_MAGIC 0xBA1CBA1CBA1CBA1CL
#define RB_DNS_OPAQUE 0xB0A3B0A3B0A3B0A3L
#endif
struct dns_cache_elm {
uint8_t addr[16];
size_t name_len;
const char *name;
};
struct dns_cache;
struct dns_cache *dns_cache_new(size_t maxmem_m, time_t timeout_s);
void dns_cache_done(struct dns_cache *cache);
/// Get an element from cache. If success (return not null), must do a dns_cache_decref_elm at the end.
struct dns_cache_elm *dns_cache_get_elm(struct dns_cache *cache,const uint8_t *addr,time_t now);
void dns_cache_decref_elm(struct dns_cache_elm *);
struct dns_cache_elm *dns_cache_save_elm(struct dns_cache *cache,const uint8_t *addr,const char *name,size_t name_len,time_t now);
struct rb_dns_info {
#ifdef RB_DNS_MAGIC
uint64_t magic;
#endif
struct dns_ctx *dns_ctx;
};
void *udns_pool_routine(void *);
#endif /* HAVE_UDNS */