Tor 0.4.9.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-2021, The Tor Project, Inc. */
5/* See LICENSE for licensing information */
6
7/**
8 * \file dns.h
9 * \brief Header file for dns.c.
10 **/
11
12#ifndef TOR_DNS_H
13#define TOR_DNS_H
14
15#ifdef HAVE_MODULE_RELAY
16
17int dns_init(void);
18int has_dns_init_failed(void);
19int dns_reset(void);
22int dns_resolve(edge_connection_t *exitconn);
23void dns_send_resolved_error_cell(edge_connection_t *conn,
24 uint8_t answer_type);
28size_t dns_cache_total_allocation(void);
29void dump_dns_mem_usage(int severity);
30size_t dns_cache_handle_oom(time_t now, size_t min_remove_bytes);
32
33/* These functions are only used within the feature/relay module, and don't
34 * need stubs. */
35void dns_free_all(void);
37
38#else /* !defined(HAVE_MODULE_RELAY) */
39
40#define dns_init() (0)
41#define dns_send_resolved_error_cell(conn, answer_type) \
42 ((void)(conn), (void)(answer_type))
43#define dns_seems_to_be_broken() (0)
44#define has_dns_init_failed() (0)
45#define dns_cache_total_allocation() (0)
46
47#define dns_reset_correctness_checks() STMT_NIL
48
49#define assert_connection_edge_not_dns_pending(conn) \
50 ((void)(conn))
51#define dump_dns_mem_usage(severity)\
52 ((void)(severity))
53#define dns_cache_handle_oom(now, bytes) \
54 ((void)(now), (void)(bytes), 0)
55#define dns_new_consensus_params(ns) \
56 ((void) ns)
57
58#define connection_dns_remove(conn) \
59 STMT_BEGIN \
60 (void)(conn); \
61 tor_assert_nonfatal_unreached(); \
62 STMT_END
63
64static inline int
65dns_reset(void)
66{
67 return 0;
68}
69static inline int
71{
72 (void)exitconn;
74 return -1;
75}
76
77#endif /* defined(HAVE_MODULE_RELAY) */
78
79#ifdef DNS_PRIVATE
81
83#ifdef HAVE_EVDNS_BASE_GET_NAMESERVER_ADDR
84tor_addr_t *configured_nameserver_address(const size_t idx);
85#endif
86
87MOCK_DECL(STATIC void,dns_cancel_pending_resolve,(const char *question));
89int is_resolve,or_circuit_t *oncirc, char **hostname_out,
90int *made_connection_pending_out, cached_resolve_t **resolve_out));
91
93uint8_t answer_type,const cached_resolve_t *resolved));
94
96const char *hostname));
97
98cached_resolve_t *dns_get_cache_entry(cached_resolve_t *query);
99void dns_insert_cache_entry(cached_resolve_t *new_entry);
100
101MOCK_DECL(STATIC int,
103 const cached_resolve_t *resolve,
104 char **hostname_out));
105
106MOCK_DECL(STATIC int,
108
109#endif /* defined(DNS_PRIVATE) */
110
111#endif /* !defined(TOR_DNS_H) */
STATIC int set_exitconn_info_from_resolve(edge_connection_t *exitconn, const cached_resolve_t *resolve, char **hostname_out)
Definition: dns.c:871
int dns_init(void)
Definition: dns.c:233
void dns_new_consensus_params(const networkstatus_t *ns)
Definition: dns.c:220
int dns_seems_to_be_broken(void)
Definition: dns.c:2139
STATIC void send_resolved_cell(edge_connection_t *conn, uint8_t answer_type, const cached_resolve_t *resolved)
Definition: dns.c:509
void dns_reset_correctness_checks(void)
Definition: dns.c:2153
STATIC void send_resolved_hostname_cell(edge_connection_t *conn, const char *hostname)
Definition: dns.c:582
STATIC void dns_cancel_pending_resolve(const char *address)
Definition: dns.c:1048
size_t number_of_configured_nameservers(void)
Definition: dns.c:1349
void connection_dns_remove(edge_connection_t *conn)
Definition: dns.c:993
int has_dns_init_failed(void)
Definition: dns.c:274
void dump_dns_mem_usage(int severity)
Definition: dns.c:2225
void dns_free_all(void)
Definition: dns.c:392
STATIC int dns_resolve_impl(edge_connection_t *exitconn, int is_resolve, or_circuit_t *oncirc, char **hostname_out, int *made_connection_pending_out, cached_resolve_t **resolve_out)
Definition: dns.c:719
STATIC int launch_resolve(cached_resolve_t *resolve)
Definition: dns.c:1806
int dns_seems_to_be_broken_for_ipv6(void)
Definition: dns.c:2146
int dns_resolve(edge_connection_t *exitconn)
Definition: dns.c:632
int dns_reset(void)
Definition: dns.c:246
void dns_launch_correctness_checks(void)
Definition: dns.c:2117
void assert_connection_edge_not_dns_pending(edge_connection_t *conn)
Definition: dns.c:966
Structures used in dns.c. Exposed to dns.c, and to the unit tests that declare DNS_PRIVATE.
#define STATIC
Definition: testsupport.h:32
#define MOCK_DECL(rv, funcname, arglist)
Definition: testsupport.h:127
#define tor_assert_nonfatal_unreached()
Definition: util_bug.h:177