Back to index

tor  0.2.3.19-rc
policies.h
Go to the documentation of this file.
00001 /* Copyright (c) 2001 Matej Pfajfar.
00002  * Copyright (c) 2001-2004, Roger Dingledine.
00003  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
00004  * Copyright (c) 2007-2012, The Tor Project, Inc. */
00005 /* See LICENSE for licensing information */
00006 
00012 #ifndef _TOR_POLICIES_H
00013 #define _TOR_POLICIES_H
00014 
00015 /* (length of "accept 255.255.255.255/255.255.255.255:65535-65535\n" plus a
00016  * NUL.)
00017  */
00018 #define POLICY_BUF_LEN 52
00019 
00020 int firewall_is_fascist_or(void);
00021 int fascist_firewall_allows_address_or(const tor_addr_t *addr, uint16_t port);
00022 int fascist_firewall_allows_or(const routerinfo_t *ri);
00023 int fascist_firewall_allows_node(const node_t *node);
00024 int fascist_firewall_allows_address_dir(const tor_addr_t *addr, uint16_t port);
00025 int dir_policy_permits_address(const tor_addr_t *addr);
00026 int socks_policy_permits_address(const tor_addr_t *addr);
00027 int authdir_policy_permits_address(uint32_t addr, uint16_t port);
00028 int authdir_policy_valid_address(uint32_t addr, uint16_t port);
00029 int authdir_policy_baddir_address(uint32_t addr, uint16_t port);
00030 int authdir_policy_badexit_address(uint32_t addr, uint16_t port);
00031 
00032 int validate_addr_policies(const or_options_t *options, char **msg);
00033 void policy_expand_private(smartlist_t **policy);
00034 int policies_parse_from_options(const or_options_t *options);
00035 
00036 addr_policy_t *addr_policy_get_canonical_entry(addr_policy_t *ent);
00037 int cmp_addr_policies(smartlist_t *a, smartlist_t *b);
00038 addr_policy_result_t compare_tor_addr_to_addr_policy(const tor_addr_t *addr,
00039                               uint16_t port, const smartlist_t *policy);
00040 
00041 addr_policy_result_t compare_tor_addr_to_node_policy(const tor_addr_t *addr,
00042                               uint16_t port, const node_t *node);
00043 
00044 int policies_parse_exit_policy(config_line_t *cfg, smartlist_t **dest,
00045                                int rejectprivate, const char *local_address,
00046                                int add_default_policy);
00047 void policies_exit_policy_append_reject_star(smartlist_t **dest);
00048 void policies_set_node_exitpolicy_to_reject_all(node_t *exitrouter);
00049 int exit_policy_is_general_exit(smartlist_t *policy);
00050 int policy_is_reject_star(const smartlist_t *policy);
00051 int getinfo_helper_policies(control_connection_t *conn,
00052                             const char *question, char **answer,
00053                             const char **errmsg);
00054 int policy_write_item(char *buf, size_t buflen, addr_policy_t *item,
00055                       int format_for_desc);
00056 
00057 void addr_policy_list_free(smartlist_t *p);
00058 void addr_policy_free(addr_policy_t *p);
00059 void policies_free_all(void);
00060 
00061 char *policy_summarize(smartlist_t *policy);
00062 
00063 short_policy_t *parse_short_policy(const char *summary);
00064 void short_policy_free(short_policy_t *policy);
00065 int short_policy_is_reject_star(const short_policy_t *policy);
00066 addr_policy_result_t compare_tor_addr_to_short_policy(
00067                           const tor_addr_t *addr, uint16_t port,
00068                           const short_policy_t *policy);
00069 
00070 #endif
00071