Tor 0.4.9.0-alpha-dev
resolve_addr.h
Go to the documentation of this file.
1/* Copyright (c) 2020-2021, The Tor Project, Inc. */
2/* See LICENSE for licensing information */
3
4/**
5 * \file resolve_addr.h
6 * \brief Header file for resolve_addr.c.
7 **/
8
9#ifndef TOR_CONFIG_RESOLVE_ADDR_H
10#define TOR_CONFIG_RESOLVE_ADDR_H
11
12#include "app/config/config.h"
14
16
17/** Method used to resolved an address. In other words, how was the address
18 * discovered by tor. */
19typedef enum {
20 /* Default value. Indicate that no method found the address. */
21 RESOLVED_ADDR_NONE = 0,
22 /* Found from the "Address" configuration option. */
23 RESOLVED_ADDR_CONFIGURED = 1,
24 /* Found from the "ORPort" configuration option. */
25 RESOLVED_ADDR_CONFIGURED_ORPORT = 2,
26 /* Found by resolving the local hostname. */
27 RESOLVED_ADDR_GETHOSTNAME = 3,
28 /* Found by querying the local interface(s). */
29 RESOLVED_ADDR_INTERFACE = 4,
30 /* Found by resolving the hostname from the Address configuration option. */
31 RESOLVED_ADDR_RESOLVED = 5,
33
35
36#define get_orport_addr(family) \
37 (portconf_get_first_advertised_addr(CONN_TYPE_OR_LISTENER, family))
38
39bool find_my_address(const or_options_t *options, int family,
40 int warn_severity, tor_addr_t *addr_out,
41 resolved_addr_method_t *method_out, char **hostname_out);
42
43void resolved_addr_get_last(int family, tor_addr_t *addr_out);
44void resolved_addr_reset_last(int family);
45void resolved_addr_set_last(const tor_addr_t *addr,
46 const resolved_addr_method_t method_used,
47 const char *hostname_used);
48
49void resolved_addr_get_suggested(int family, tor_addr_t *addr_out);
51
52bool resolved_addr_is_configured(int family);
53
55
56#ifdef RESOLVE_ADDR_PRIVATE
57
58#ifdef TOR_UNIT_TESTS
59
60void resolve_addr_reset_suggested(int family);
61
62#endif /* TOR_UNIT_TESTS */
63
64#endif /* defined(RESOLVE_ADDR_PRIVATE) */
65
66#endif /* !defined(TOR_CONFIG_RESOLVE_ADDR_H) */
67
Header file for config.c.
Header file for connection.c.
The or_options_t structure, which represents Tor's configuration.
bool is_local_to_resolve_addr(const tor_addr_t *addr)
: Return true iff the given addr is judged to be local to our resolved address.
Definition: resolve_addr.c:819
void resolved_addr_set_suggested(const tor_addr_t *addr)
Definition: resolve_addr.c:127
resolved_addr_method_t
Definition: resolve_addr.h:19
void resolved_addr_reset_last(int family)
Definition: resolve_addr.c:159
bool find_my_address(const or_options_t *options, int family, int warn_severity, tor_addr_t *addr_out, resolved_addr_method_t *method_out, char **hostname_out)
Attempt to find our IP address that can be used as our external reachable address.
Definition: resolve_addr.c:727
void resolved_addr_get_suggested(int family, tor_addr_t *addr_out)
Definition: resolve_addr.c:119
bool resolved_addr_is_configured(int family)
Definition: resolve_addr.c:109
void resolved_addr_set_last(const tor_addr_t *addr, const resolved_addr_method_t method_used, const char *hostname_used)
Set the last resolved address cache using the given address.
Definition: resolve_addr.c:561
void resolved_addr_get_last(int family, tor_addr_t *addr_out)
Definition: resolve_addr.c:150
const char * resolved_addr_method_to_str(const resolved_addr_method_t method)
Definition: resolve_addr.c:81
#define MOCK_DECL(rv, funcname, arglist)
Definition: testsupport.h:127