tor  0.4.1.0-alpha-dev
dns.h
Go to the documentation of this file.
1 /* Copyright (c) 2001 Matej Pfajfar.
2  * Copyright (c) 2001-2004, Roger Dingledine.
3  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4  * Copyright (c) 2007-2019, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6 
12 #ifndef TOR_DNS_H
13 #define TOR_DNS_H
14 
16 #define MIN_DNS_TTL_AT_EXIT (5*60)
17 
18 #define MAX_DNS_TTL_AT_EXIT (60*60)
19 
22 #define MAX_DNS_ENTRY_AGE (3*60*60)
23 
25 #define DEFAULT_DNS_TTL (30*60)
26 
27 int dns_init(void);
28 int has_dns_init_failed(void);
29 void dns_free_all(void);
30 uint32_t dns_clip_ttl(uint32_t ttl);
31 int dns_reset(void);
35 MOCK_DECL(void,dns_cancel_pending_resolve,(const char *question));
36 int dns_resolve(edge_connection_t *exitconn);
38 int dns_seems_to_be_broken(void);
41 size_t dns_cache_total_allocation(void);
42 void dump_dns_mem_usage(int severity);
43 size_t dns_cache_handle_oom(time_t now, size_t min_remove_bytes);
44 
45 #ifdef DNS_PRIVATE
47 
49 #ifdef HAVE_EVDNS_BASE_GET_NAMESERVER_ADDR
50 tor_addr_t *configured_nameserver_address(const size_t idx);
51 #endif
52 
53 MOCK_DECL(STATIC int,dns_resolve_impl,(edge_connection_t *exitconn,
54 int is_resolve,or_circuit_t *oncirc, char **hostname_out,
55 int *made_connection_pending_out, cached_resolve_t **resolve_out));
56 
57 MOCK_DECL(STATIC void,send_resolved_cell,(edge_connection_t *conn,
58 uint8_t answer_type,const cached_resolve_t *resolved));
59 
60 MOCK_DECL(STATIC void,send_resolved_hostname_cell,(edge_connection_t *conn,
61 const char *hostname));
62 
63 cached_resolve_t *dns_get_cache_entry(cached_resolve_t *query);
64 void dns_insert_cache_entry(cached_resolve_t *new_entry);
65 
66 MOCK_DECL(STATIC int,
67 set_exitconn_info_from_resolve,(edge_connection_t *exitconn,
68  const cached_resolve_t *resolve,
69  char **hostname_out));
70 
71 MOCK_DECL(STATIC int,
72 launch_resolve,(cached_resolve_t *resolve));
73 
74 #endif /* defined(DNS_PRIVATE) */
75 
76 #endif /* !defined(TOR_DNS_H) */
77 
void dns_launch_correctness_checks(void)
Definition: dns.c:2044
int dns_reset(void)
Definition: dns.c:238
Structures used in dns.c. Exposed to dns.c, and to the unit tests that declare DNS_PRIVATE.
int dns_init(void)
Definition: dns.c:224
void connection_dns_remove(edge_connection_t *conn)
Definition: dns.c:1012
int dns_seems_to_be_broken_for_ipv6(void)
Definition: dns.c:2073
void dump_dns_mem_usage(int severity)
Definition: dns.c:2152
size_t number_of_configured_nameservers(void)
Definition: dns.c:1367
void dns_free_all(void)
Definition: dns.c:400
void dns_reset_correctness_checks(void)
Definition: dns.c:2080
int dns_resolve(edge_connection_t *exitconn)
Definition: dns.c:634
uint32_t dns_clip_ttl(uint32_t ttl)
Definition: dns.c:275
#define MOCK_DECL(rv, funcname, arglist)
Definition: testsupport.h:94
int dns_seems_to_be_broken(void)
Definition: dns.c:2066
void assert_connection_edge_not_dns_pending(edge_connection_t *conn)
Definition: dns.c:966
int has_dns_init_failed(void)
Definition: dns.c:266
void assert_all_pending_dns_resolves_ok(void)
Definition: dns.c:993