Electroneum
Loading...
Searching...
No Matches
infra.h
Go to the documentation of this file.
1/*
2 * services/cache/infra.h - infrastructure cache, server rtt and capabilities
3 *
4 * Copyright (c) 2007, NLnet Labs. All rights reserved.
5 *
6 * This software is open source.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 *
15 * Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 *
19 * Neither the name of the NLNET LABS nor the names of its contributors may
20 * be used to endorse or promote products derived from this software without
21 * specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
44
45#ifndef SERVICES_CACHE_INFRA_H
46#define SERVICES_CACHE_INFRA_H
49#include "util/rtt.h"
50#include "util/netevent.h"
51#include "util/data/msgreply.h"
52struct slabhash;
53struct config_file;
54
70
108
124
126extern int infra_dp_ratelimit;
127
139
151
153extern int infra_ip_ratelimit;
154
164 socklen_t addrlen;
165};
166
168#define RATE_WINDOW 2
169
184
185#define ip_rate_data rate_data
186
188#define INFRA_HOST_STARTSIZE 32
190#define INFRA_BYTES_NAME 14
191
198
203void infra_delete(struct infra_cache* infra);
204
213struct infra_cache* infra_adjust(struct infra_cache* infra,
214 struct config_file* cfg);
215
227 struct sockaddr_storage* addr, socklen_t addrlen, uint8_t* name,
228 size_t namelen, int wr);
229
248int infra_host(struct infra_cache* infra, struct sockaddr_storage* addr,
249 socklen_t addrlen, uint8_t* name, size_t namelen,
250 time_t timenow, int* edns_vs, uint8_t* edns_lame_known, int* to);
251
267int infra_set_lame(struct infra_cache* infra,
268 struct sockaddr_storage* addr, socklen_t addrlen,
269 uint8_t* name, size_t namelen, time_t timenow, int dnsseclame,
270 int reclame, uint16_t qtype);
271
287int infra_rtt_update(struct infra_cache* infra, struct sockaddr_storage* addr,
288 socklen_t addrlen, uint8_t* name, size_t namelen, int qtype,
289 int roundtrip, int orig_rtt, time_t timenow);
290
300 struct sockaddr_storage* addr, socklen_t addrlen,
301 uint8_t* name, size_t namelen);
302
316 struct sockaddr_storage* addr, socklen_t addrlen,
317 uint8_t* name, size_t namelen, int edns_version, time_t timenow);
318
338 struct sockaddr_storage* addr, socklen_t addrlen,
339 uint8_t* name, size_t namelen, uint16_t qtype,
340 int* lame, int* dnsseclame, int* reclame, int* rtt, time_t timenow);
341
358long long infra_get_host_rto(struct infra_cache* infra,
359 struct sockaddr_storage* addr, socklen_t addrlen, uint8_t* name,
360 size_t namelen, struct rtt_info* rtt, int* delay, time_t timenow,
361 int* tA, int* tAAAA, int* tother);
362
373int infra_ratelimit_inc(struct infra_cache* infra, uint8_t* name,
374 size_t namelen, time_t timenow);
375
386void infra_ratelimit_dec(struct infra_cache* infra, uint8_t* name,
387 size_t namelen, time_t timenow);
388
399 size_t namelen, time_t timenow);
400
402int infra_rate_max(void* data, time_t now);
403
405int infra_find_ratelimit(struct infra_cache* infra, uint8_t* name,
406 size_t namelen);
407
416 struct comm_reply* repinfo, time_t timenow);
417
423size_t infra_get_mem(struct infra_cache* infra);
424
427size_t infra_sizefunc(void* k, void* d);
428
430int infra_compfunc(void* key1, void* key2);
431
433void infra_delkeyfunc(void* k, void* arg);
434
436void infra_deldatafunc(void* d, void* arg);
437
439size_t rate_sizefunc(void* k, void* d);
440
442int rate_compfunc(void* key1, void* key2);
443
445void rate_delkeyfunc(void* k, void* arg);
446
448void rate_deldatafunc(void* d, void* arg);
449
450/* calculate size for the client ip hashtable */
451size_t ip_rate_sizefunc(void* k, void* d);
452
453/* compare two addresses */
454int ip_rate_compfunc(void* key1, void* key2);
455
456/* delete key, and destroy the lock */
457void ip_rate_delkeyfunc(void* d, void* arg);
458
459/* delete data */
460#define ip_rate_deldatafunc rate_deldatafunc
461
462#endif /* SERVICES_CACHE_INFRA_H */
int infra_rtt_update(struct infra_cache *infra, struct sockaddr_storage *addr, socklen_t addrlen, uint8_t *name, size_t namelen, int qtype, int roundtrip, int orig_rtt, time_t timenow)
int infra_edns_update(struct infra_cache *infra, struct sockaddr_storage *addr, socklen_t addrlen, uint8_t *name, size_t namelen, int edns_version, time_t timenow)
size_t infra_get_mem(struct infra_cache *infra)
size_t rate_sizefunc(void *k, void *d)
void infra_delete(struct infra_cache *infra)
size_t ip_rate_sizefunc(void *k, void *d)
#define RATE_WINDOW
Definition infra.h:168
void infra_ratelimit_dec(struct infra_cache *infra, uint8_t *name, size_t namelen, time_t timenow)
int infra_rate_max(void *data, time_t now)
int infra_compfunc(void *key1, void *key2)
void ip_rate_delkeyfunc(void *d, void *arg)
void rate_delkeyfunc(void *k, void *arg)
int infra_get_lame_rtt(struct infra_cache *infra, struct sockaddr_storage *addr, socklen_t addrlen, uint8_t *name, size_t namelen, uint16_t qtype, int *lame, int *dnsseclame, int *reclame, int *rtt, time_t timenow)
int infra_ratelimit_inc(struct infra_cache *infra, uint8_t *name, size_t namelen, time_t timenow)
void infra_delkeyfunc(void *k, void *arg)
int infra_find_ratelimit(struct infra_cache *infra, uint8_t *name, size_t namelen)
struct infra_cache * infra_adjust(struct infra_cache *infra, struct config_file *cfg)
void rate_deldatafunc(void *d, void *arg)
int rate_compfunc(void *key1, void *key2)
int ip_rate_compfunc(void *key1, void *key2)
int infra_ip_ratelimit
int infra_ip_ratelimit_inc(struct infra_cache *infra, struct comm_reply *repinfo, time_t timenow)
long long infra_get_host_rto(struct infra_cache *infra, struct sockaddr_storage *addr, socklen_t addrlen, uint8_t *name, size_t namelen, struct rtt_info *rtt, int *delay, time_t timenow, int *tA, int *tAAAA, int *tother)
int infra_ratelimit_exceeded(struct infra_cache *infra, uint8_t *name, size_t namelen, time_t timenow)
int infra_set_lame(struct infra_cache *infra, struct sockaddr_storage *addr, socklen_t addrlen, uint8_t *name, size_t namelen, time_t timenow, int dnsseclame, int reclame, uint16_t qtype)
int infra_host(struct infra_cache *infra, struct sockaddr_storage *addr, socklen_t addrlen, uint8_t *name, size_t namelen, time_t timenow, int *edns_vs, uint8_t *edns_lame_known, int *to)
struct lruhash_entry * infra_lookup_nottl(struct infra_cache *infra, struct sockaddr_storage *addr, socklen_t addrlen, uint8_t *name, size_t namelen, int wr)
size_t infra_sizefunc(void *k, void *d)
void infra_update_tcp_works(struct infra_cache *infra, struct sockaddr_storage *addr, socklen_t addrlen, uint8_t *name, size_t namelen)
int infra_dp_ratelimit
void infra_deldatafunc(void *d, void *arg)
struct infra_cache * infra_create(struct config_file *cfg)
unsigned short uint16_t
Definition stdint.h:125
unsigned char uint8_t
Definition stdint.h:124
struct name_tree_node node
Definition infra.h:133
rbtree_type domain_limits
Definition infra.h:120
int host_ttl
Definition infra.h:116
struct slabhash * hosts
Definition infra.h:114
struct slabhash * client_ip_rates
Definition infra.h:122
struct slabhash * domain_rates
Definition infra.h:118
uint8_t lame_other
Definition infra.h:99
uint8_t edns_lame_known
Definition infra.h:89
uint8_t timeout_AAAA
Definition infra.h:104
struct rtt_info rtt
Definition infra.h:82
uint8_t timeout_other
Definition infra.h:106
uint8_t timeout_A
Definition infra.h:102
int edns_version
Definition infra.h:85
uint8_t rec_lame
Definition infra.h:95
uint8_t lame_type_A
Definition infra.h:97
uint8_t isdnsseclame
Definition infra.h:93
time_t probedelay
Definition infra.h:80
time_t ttl
Definition infra.h:77
size_t namelen
Definition infra.h:66
struct lruhash_entry entry
Definition infra.h:68
struct sockaddr_storage addr
Definition infra.h:60
socklen_t addrlen
Definition infra.h:62
uint8_t * zonename
Definition infra.h:64
struct sockaddr_storage addr
Definition infra.h:162
struct lruhash_entry entry
Definition infra.h:160
socklen_t addrlen
Definition infra.h:164
Definition lruhash.h:203
void * data
Definition lruhash.h:222
int qps[RATE_WINDOW]
Definition infra.h:179
time_t timestamp[RATE_WINDOW]
Definition infra.h:182
struct lruhash_entry entry
Definition infra.h:145
size_t namelen
Definition infra.h:149
uint8_t * name
Definition infra.h:147
Definition rtt.h:49