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 */
7 /**
8  * @file addressmap.h
9  * @brief Header for addressmap.c
10  **/
17 void addressmap_init(void);
20 void addressmap_clean(time_t now);
23 void addressmap_free_all(void);
24 #define AMR_FLAG_USE_IPV4_DNS (1u<<0)
25 #define AMR_FLAG_USE_IPV6_DNS (1u<<1)
26 #define AMR_FLAG_USE_MAPADDRESS (1u<<2)
27 #define AMR_FLAG_USE_AUTOMAP (1u<<3)
28 #define AMR_FLAG_USE_TRACKEXIT (1u<<4)
29 int addressmap_rewrite(char *address, size_t maxlen, unsigned flags,
30  time_t *expires_out,
31  addressmap_entry_source_t *exit_source_out);
32 int addressmap_rewrite_reverse(char *address, size_t maxlen, unsigned flags,
33  time_t *expires_out);
34 int addressmap_have_mapping(const char *address, int update_timeout);
36 void addressmap_register(const char *address, char *new_address,
37  time_t expires, addressmap_entry_source_t source,
38  const int address_wildcard,
39  const int new_address_wildcard, uint64_t stream_id);
40 int parse_virtual_addr_network(const char *val,
41  sa_family_t family, int validate_only,
42  char **msg);
43 int client_dns_incr_failures(const char *address);
44 void client_dns_clear_failures(const char *address);
46  const char *address, const tor_addr_t *val,
47  const char *exitname, int ttl);
48 const char *addressmap_register_virtual_address(int type, char *new_address);
49 void addressmap_get_mappings(smartlist_t *sl, time_t min_expires,
50  time_t max_expires, int want_expiry);
51 int address_is_in_virtual_range(const char *addr);
52 void clear_trackexithost_mappings(const char *exitname);
54  const char *address, const char *v,
55  const char *exitname, int ttl);
56 int addressmap_address_should_automap(const char *address,
57  const or_options_t *options);
60 typedef struct virtual_addr_conf_t {
61  tor_addr_t addr;
62  maskbits_t bits;
63 } virtual_addr_conf_t;
65 STATIC void get_random_virtual_addr(const virtual_addr_conf_t *conf,
66  tor_addr_t *addr_out);
67 #endif /* defined(ADDRESSMAP_PRIVATE) */
69 #endif /* !defined(TOR_ADDRESSMAP_H) */
uint8_t maskbits_t
Definition: address.h:62
STATIC void get_random_virtual_addr(const virtual_addr_conf_t *conf, tor_addr_t *addr_out)
Definition: addressmap.c:879
void addressmap_init(void)
Definition: addressmap.c:90
int address_is_in_virtual_range(const char *addr)
Definition: addressmap.c:860
void client_dns_set_reverse_addressmap(entry_connection_t *for_conn, const char *address, const char *v, const char *exitname, int ttl)
Definition: addressmap.c:767
void clear_trackexithost_mappings(const char *exitname)
Definition: addressmap.c:174
void addressmap_register(const char *address, char *new_address, time_t expires, addressmap_entry_source_t source, const int address_wildcard, const int new_address_wildcard, uint64_t stream_id)
Definition: addressmap.c:576
void addressmap_get_mappings(smartlist_t *sl, time_t min_expires, time_t max_expires, int want_expiry)
Definition: addressmap.c:1119
void addressmap_clear_invalid_automaps(const or_options_t *options)
Definition: addressmap.c:271
int addressmap_have_mapping(const char *address, int update_timeout)
Definition: addressmap.c:544
void addressmap_clean(time_t now)
Definition: addressmap.c:320
int client_dns_incr_failures(const char *address)
Definition: addressmap.c:638
void client_dns_set_addressmap(entry_connection_t *for_conn, const char *address, const tor_addr_t *val, const char *exitname, int ttl)
Definition: addressmap.c:728
int addressmap_rewrite(char *address, size_t maxlen, unsigned flags, time_t *expires_out, addressmap_entry_source_t *exit_source_out)
Definition: addressmap.c:383
void addressmap_free_all(void)
Definition: addressmap.c:328
int addressmap_address_should_automap(const char *address, const or_options_t *options)
Definition: addressmap.c:249
void client_dns_clear_failures(const char *address)
Definition: addressmap.c:660
const char * addressmap_register_virtual_address(int type, char *new_address)
Definition: addressmap.c:1000
void addressmap_clear_configured(void)
Definition: addressmap.c:304
void addressmap_clear_transient(void)
Definition: addressmap.c:311
void addressmap_clear_excluded_trackexithosts(const or_options_t *options)
Definition: addressmap.c:197
int parse_virtual_addr_network(const char *val, sa_family_t family, int validate_only, char **msg)
Definition: addressmap.c:802
int addressmap_rewrite_reverse(char *address, size_t maxlen, unsigned flags, time_t *expires_out)
Definition: addressmap.c:503
uint16_t sa_family_t
Definition: inaddr_st.h:77
Definition: or.h:906
Macros to implement mocking and selective exposure for the test code.
#define STATIC
Definition: testsupport.h:32