12 #ifndef TOR_POLICIES_H
13 #define TOR_POLICIES_H
19 #define POLICY_BUF_LEN 72
21 #define EXIT_POLICY_IPV6_ENABLED (1 << 0)
22 #define EXIT_POLICY_REJECT_PRIVATE (1 << 1)
23 #define EXIT_POLICY_ADD_DEFAULT (1 << 2)
24 #define EXIT_POLICY_REJECT_LOCAL_INTERFACES (1 << 3)
25 #define EXIT_POLICY_ADD_REDUCED (1 << 4)
26 #define EXIT_POLICY_OPTION_MAX EXIT_POLICY_ADD_REDUCED
28 #define EXIT_POLICY_OPTION_ALL ((EXIT_POLICY_OPTION_MAX << 1) - 1)
30 typedef enum firewall_connection_t {
31 FIREWALL_OR_CONNECTION = 0,
32 FIREWALL_DIR_CONNECTION = 1
33 } firewall_connection_t;
35 typedef int exit_policy_parser_cfg_t;
53 uint16_t min_port, max_port;
78 firewall_connection_t fw_connection,
79 int pref_only,
int pref_ipv6);
82 firewall_connection_t fw_connection,
85 firewall_connection_t fw_connection,
88 firewall_connection_t fw_connection,
92 firewall_connection_t fw_connection,
97 firewall_connection_t fw_connection,
100 firewall_connection_t fw_connection,
120 uint16_t port,
const node_t *node);
129 exit_policy_parser_cfg_t options,
135 int reject_interface_addresses,
136 int reject_configured_port_addresses);
145 int reject_by_default);
150 const char *question,
char **answer,
151 const char **errmsg);
153 int format_for_desc);
156 #define addr_policy_list_free(lst) \
157 FREE_AND_NULL(smartlist_t, addr_policy_list_free_, (lst))
159 #define addr_policy_free(p) \
160 FREE_AND_NULL(addr_policy_t, addr_policy_free_, (p))
168 #define short_policy_free(p) \
169 FREE_AND_NULL(short_policy_t, short_policy_free_, (p))
175 #ifdef POLICIES_PRIVATE
180 int pref_only,
int pref_ipv6);
185 firewall_connection_t fw_connection,
186 int pref_only,
int pref_ipv6);
STATIC int reachable_addr_allows(const tor_addr_t *addr, uint16_t port, smartlist_t *firewall_policy, int pref_only, int pref_ipv6)
STATIC void append_exit_policy_string(smartlist_t **policy, const char *more)
STATIC const tor_addr_port_t * reachable_addr_choose(const tor_addr_port_t *a, const tor_addr_port_t *b, int want_a, firewall_connection_t fw_connection, int pref_only, int pref_ipv6)
void addr_policy_append_reject_addr(smartlist_t **dest, const tor_addr_t *addr)
void policies_set_node_exitpolicy_to_reject_all(node_t *exitrouter)
void addr_policy_free_(addr_policy_t *p)
int addr_policies_eq(const smartlist_t *a, const smartlist_t *b)
int reachable_addr_prefer_ipv6_dirport(const or_options_t *options)
int policies_parse_exit_policy_from_options(const or_options_t *or_options, const tor_addr_t *ipv4_local_address, const tor_addr_t *ipv6_local_address, smartlist_t **result)
int policies_parse_exit_policy(struct config_line_t *cfg, smartlist_t **dest, exit_policy_parser_cfg_t options, const smartlist_t *configured_addresses)
int reachable_addr_prefer_ipv6_orport(const or_options_t *options)
void policy_expand_private(smartlist_t **policy)
int reachable_addr_allows_rs(const routerstatus_t *rs, firewall_connection_t fw_connection, int pref_only)
int firewall_is_fascist_or(void)
int metrics_policy_permits_address(const tor_addr_t *addr)
void policies_parse_exit_policy_reject_private(smartlist_t **dest, int ipv6_exit, const smartlist_t *configured_addresses, int reject_interface_addresses, int reject_configured_port_addresses)
short_policy_t * parse_short_policy(const char *summary)
void addr_policy_append_reject_addr_list(smartlist_t **dest, const smartlist_t *addrs)
int reachable_addr_allows_addr(const tor_addr_t *addr, uint16_t port, firewall_connection_t fw_connection, int pref_only, int pref_ipv6)
void reachable_addr_choose_from_node(const node_t *node, firewall_connection_t fw_connection, int pref_only, tor_addr_port_t *ap)
void reachable_addr_choose_from_dir_server(const dir_server_t *ds, firewall_connection_t fw_connection, int pref_only, tor_addr_port_t *ap)
char * policy_dump_to_string(const smartlist_t *policy_list, int include_ipv4, int include_ipv6)
int reachable_addr_allows_node(const node_t *node, firewall_connection_t fw_connection, int pref_only)
void addr_policy_list_free_(smartlist_t *p)
int getinfo_helper_policies(control_connection_t *conn, const char *question, char **answer, const char **errmsg)
void reachable_addr_choose_from_ls(const smartlist_t *lspecs, int pref_only, tor_addr_port_t *ap)
void reachable_addr_choose_from_rs(const routerstatus_t *rs, firewall_connection_t fw_connection, int pref_only, tor_addr_port_t *ap)
int policies_parse_from_options(const or_options_t *options)
int authdir_policy_badexit_address(const tor_addr_t *addr, uint16_t port)
int reachable_addr_allows_dir_server(const dir_server_t *ds, firewall_connection_t fw_connection, int pref_only)
int policy_write_item(char *buf, size_t buflen, const addr_policy_t *item, int format_for_desc)
addr_policy_result_t compare_tor_addr_to_addr_policy(const tor_addr_t *addr, uint16_t port, const smartlist_t *policy)
char * write_short_policy(const short_policy_t *policy)
int reachable_addr_use_ipv6(const or_options_t *options)
addr_policy_result_t compare_tor_addr_to_short_policy(const tor_addr_t *addr, uint16_t port, const short_policy_t *policy)
int policy_is_reject_star(const smartlist_t *policy, sa_family_t family, int reject_by_default)
int firewall_is_fascist_dir(void)
int dir_policy_permits_address(const tor_addr_t *addr)
void policy_expand_unspec(smartlist_t **policy)
int authdir_policy_permits_address(const tor_addr_t *addr, uint16_t port)
@ ADDR_POLICY_PROBABLY_ACCEPTED
@ ADDR_POLICY_PROBABLY_REJECTED
void policies_free_all(void)
void short_policy_free_(short_policy_t *policy)
int validate_addr_policies(const or_options_t *options, char **msg)
addr_policy_t * addr_policy_get_canonical_entry(addr_policy_t *ent)
int socks_policy_permits_address(const tor_addr_t *addr)
addr_policy_result_t compare_tor_addr_to_node_policy(const tor_addr_t *addr, uint16_t port, const node_t *node)
int authdir_policy_valid_address(const tor_addr_t *addr, uint16_t port)
int short_policy_is_reject_star(const short_policy_t *policy)
int exit_policy_is_general_exit(smartlist_t *policy)
char * policy_summarize(smartlist_t *policy, sa_family_t family)
void policies_exit_policy_append_reject_star(smartlist_t **dest)
short_policy_entry_t entries[FLEXIBLE_ARRAY_MEMBER]
#define MOCK_DECL(rv, funcname, arglist)