In routerlist_assert_ok(), check r2 before taking &(r2->cache_info)
[tor.git] / src / or / policies.h
blob91ac427492d3bdf02fb176d95f5d32cb6d6bbe5b
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-2013, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
7 /**
8 * \file policies.h
9 * \brief Header file for policies.c.
10 **/
12 #ifndef TOR_POLICIES_H
13 #define TOR_POLICIES_H
15 /* (length of
16 * "accept6 [ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff]/128:65535-65535\n"
17 * plus a terminating NUL, rounded up to a nice number.)
19 #define POLICY_BUF_LEN 72
21 int firewall_is_fascist_or(void);
22 int fascist_firewall_allows_address_or(const tor_addr_t *addr, uint16_t port);
23 int fascist_firewall_allows_or(const routerinfo_t *ri);
24 int fascist_firewall_allows_node(const node_t *node);
25 int fascist_firewall_allows_address_dir(const tor_addr_t *addr, uint16_t port);
26 int dir_policy_permits_address(const tor_addr_t *addr);
27 int socks_policy_permits_address(const tor_addr_t *addr);
28 int authdir_policy_permits_address(uint32_t addr, uint16_t port);
29 int authdir_policy_valid_address(uint32_t addr, uint16_t port);
30 int authdir_policy_baddir_address(uint32_t addr, uint16_t port);
31 int authdir_policy_badexit_address(uint32_t addr, uint16_t port);
33 int validate_addr_policies(const or_options_t *options, char **msg);
34 void policy_expand_private(smartlist_t **policy);
35 void policy_expand_unspec(smartlist_t **policy);
36 int policies_parse_from_options(const or_options_t *options);
38 addr_policy_t *addr_policy_get_canonical_entry(addr_policy_t *ent);
39 int cmp_addr_policies(smartlist_t *a, smartlist_t *b);
40 addr_policy_result_t compare_tor_addr_to_addr_policy(const tor_addr_t *addr,
41 uint16_t port, const smartlist_t *policy);
43 addr_policy_result_t compare_tor_addr_to_node_policy(const tor_addr_t *addr,
44 uint16_t port, const node_t *node);
46 int policies_parse_exit_policy(config_line_t *cfg, smartlist_t **dest,
47 int ipv6exit,
48 int rejectprivate, uint32_t local_address,
49 int add_default_policy);
50 void policies_exit_policy_append_reject_star(smartlist_t **dest);
51 void addr_policy_append_reject_addr(smartlist_t **dest,
52 const tor_addr_t *addr);
53 void policies_set_node_exitpolicy_to_reject_all(node_t *exitrouter);
54 int exit_policy_is_general_exit(smartlist_t *policy);
55 int policy_is_reject_star(const smartlist_t *policy, sa_family_t family);
56 int getinfo_helper_policies(control_connection_t *conn,
57 const char *question, char **answer,
58 const char **errmsg);
59 int policy_write_item(char *buf, size_t buflen, addr_policy_t *item,
60 int format_for_desc);
62 void addr_policy_list_free(smartlist_t *p);
63 void addr_policy_free(addr_policy_t *p);
64 void policies_free_all(void);
66 char *policy_summarize(smartlist_t *policy, sa_family_t family);
68 short_policy_t *parse_short_policy(const char *summary);
69 char *write_short_policy(const short_policy_t *policy);
70 void short_policy_free(short_policy_t *policy);
71 int short_policy_is_reject_star(const short_policy_t *policy);
72 addr_policy_result_t compare_tor_addr_to_short_policy(
73 const tor_addr_t *addr, uint16_t port,
74 const short_policy_t *policy);
76 #endif