diff options
author | Sebastian Hahn <sebastian@torproject.org> | 2010-07-23 20:51:25 +0200 |
---|---|---|
committer | Sebastian Hahn <sebastian@torproject.org> | 2010-07-27 10:00:45 +0200 |
commit | 7bd8dee46371063cd1e62661cd65ce9a35e776e5 (patch) | |
tree | c1e66c6bfaebfb28ebe4ba885235eff6d5515ae3 /src | |
parent | f6852fe031e066f46337ea936a40e3e2720bc5ad (diff) | |
download | tor-7bd8dee46371063cd1e62661cd65ce9a35e776e5.tar.gz tor-7bd8dee46371063cd1e62661cd65ce9a35e776e5.zip |
Create policies.h
Diffstat (limited to 'src')
-rw-r--r-- | src/or/circuitbuild.c | 1 | ||||
-rw-r--r-- | src/or/circuituse.c | 1 | ||||
-rw-r--r-- | src/or/config.c | 1 | ||||
-rw-r--r-- | src/or/connection.c | 1 | ||||
-rw-r--r-- | src/or/connection_edge.c | 1 | ||||
-rw-r--r-- | src/or/control.c | 1 | ||||
-rw-r--r-- | src/or/directory.c | 1 | ||||
-rw-r--r-- | src/or/dirserv.c | 1 | ||||
-rw-r--r-- | src/or/dirvote.c | 1 | ||||
-rw-r--r-- | src/or/dns.c | 1 | ||||
-rw-r--r-- | src/or/dnsserv.c | 1 | ||||
-rw-r--r-- | src/or/main.c | 1 | ||||
-rw-r--r-- | src/or/or.h | 44 | ||||
-rw-r--r-- | src/or/policies.c | 1 | ||||
-rw-r--r-- | src/or/policies.h | 60 | ||||
-rw-r--r-- | src/or/relay.c | 1 | ||||
-rw-r--r-- | src/or/router.c | 1 | ||||
-rw-r--r-- | src/or/routerlist.c | 1 | ||||
-rw-r--r-- | src/or/routerparse.c | 1 | ||||
-rw-r--r-- | src/test/test.c | 1 |
20 files changed, 78 insertions, 44 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index 00c9026faa..a70effe40a 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -24,6 +24,7 @@ #include "main.h" #include "networkstatus.h" #include "onion.h" +#include "policies.h" #include "router.h" #include "routerlist.h" #include "crypto.h" diff --git a/src/or/circuituse.c b/src/or/circuituse.c index 07e3d0bc4b..b13e558d07 100644 --- a/src/or/circuituse.c +++ b/src/or/circuituse.c @@ -17,6 +17,7 @@ #include "connection.h" #include "connection_edge.h" #include "control.h" +#include "policies.h" #include "rendclient.h" #include "rendcommon.h" #include "rendservice.h" diff --git a/src/or/config.c b/src/or/config.c index bfec2f41b4..02d20129f0 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -26,6 +26,7 @@ #include "hibernate.h" #include "main.h" #include "networkstatus.h" +#include "policies.h" #include "rendclient.h" #include "rendservice.h" #include "router.h" diff --git a/src/or/connection.c b/src/or/connection.c index 854a53aafa..e4d158afb3 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -27,6 +27,7 @@ #include "dnsserv.h" #include "geoip.h" #include "main.h" +#include "policies.h" #include "rendclient.h" #include "rendcommon.h" #include "router.h" diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index 5dff47958f..ebc9ec5842 100644 --- a/src/or/connection_edge.c +++ b/src/or/connection_edge.c @@ -23,6 +23,7 @@ #include "dirserv.h" #include "hibernate.h" #include "main.h" +#include "policies.h" #include "rendclient.h" #include "rendcommon.h" #include "rendservice.h" diff --git a/src/or/control.c b/src/or/control.c index 5f5e45fd88..1853048132 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -26,6 +26,7 @@ #include "hibernate.h" #include "main.h" #include "networkstatus.h" +#include "policies.h" #include "router.h" #include "routerlist.h" diff --git a/src/or/directory.c b/src/or/directory.c index 057961da86..1c13cbd3df 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -16,6 +16,7 @@ #include "geoip.h" #include "main.h" #include "networkstatus.h" +#include "policies.h" #include "rendclient.h" #include "rendcommon.h" #include "router.h" diff --git a/src/or/dirserv.c b/src/or/dirserv.c index d23542cf60..38fc8f161a 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -16,6 +16,7 @@ #include "hibernate.h" #include "microdesc.h" #include "networkstatus.h" +#include "policies.h" #include "router.h" #include "routerlist.h" diff --git a/src/or/dirvote.c b/src/or/dirvote.c index 5b53267ba5..7873e49e7a 100644 --- a/src/or/dirvote.c +++ b/src/or/dirvote.c @@ -11,6 +11,7 @@ #include "dirvote.h" #include "microdesc.h" #include "networkstatus.h" +#include "policies.h" #include "router.h" #include "routerlist.h" diff --git a/src/or/dns.c b/src/or/dns.c index 7bb2d8ea34..f2d3d435db 100644 --- a/src/or/dns.c +++ b/src/or/dns.c @@ -20,6 +20,7 @@ #include "control.h" #include "dns.h" #include "main.h" +#include "policies.h" #include "router.h" #include "ht.h" #ifdef HAVE_EVENT2_DNS_H diff --git a/src/or/dnsserv.c b/src/or/dnsserv.c index 7f9029424d..e231b655f4 100644 --- a/src/or/dnsserv.c +++ b/src/or/dnsserv.c @@ -15,6 +15,7 @@ #include "connection_edge.h" #include "control.h" #include "main.h" +#include "policies.h" #ifdef HAVE_EVENT2_DNS_H #include <event2/dns.h> #include <event2/dns_compat.h> diff --git a/src/or/main.c b/src/or/main.c index b30a77eddd..60bea49006 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -35,6 +35,7 @@ #include "networkstatus.h" #include "ntmain.h" #include "onion.h" +#include "policies.h" #include "rendclient.h" #include "rendcommon.h" #include "rendservice.h" diff --git a/src/or/or.h b/src/or/or.h index 8322cf3d47..2f2c3002b0 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -3295,11 +3295,6 @@ typedef enum version_status_t { /********************************* policies.c ************************/ -/* (length of "accept 255.255.255.255/255.255.255.255:65535-65535\n" plus a - * NUL.) - */ -#define POLICY_BUF_LEN 52 - /** Outcome of applying an address policy to an address. */ typedef enum { /** The address was accepted */ @@ -3314,45 +3309,6 @@ typedef enum { ADDR_POLICY_PROBABLY_REJECTED=2 } addr_policy_result_t; -int firewall_is_fascist_or(void); -int fascist_firewall_allows_address_or(const tor_addr_t *addr, uint16_t port); -int fascist_firewall_allows_or(routerinfo_t *ri); -int fascist_firewall_allows_address_dir(const tor_addr_t *addr, uint16_t port); -int dir_policy_permits_address(const tor_addr_t *addr); -int socks_policy_permits_address(const tor_addr_t *addr); -int authdir_policy_permits_address(uint32_t addr, uint16_t port); -int authdir_policy_valid_address(uint32_t addr, uint16_t port); -int authdir_policy_baddir_address(uint32_t addr, uint16_t port); -int authdir_policy_badexit_address(uint32_t addr, uint16_t port); - -int validate_addr_policies(or_options_t *options, char **msg); -void policy_expand_private(smartlist_t **policy); -int policies_parse_from_options(or_options_t *options); - -addr_policy_t *addr_policy_get_canonical_entry(addr_policy_t *ent); -int cmp_addr_policies(smartlist_t *a, smartlist_t *b); -addr_policy_result_t compare_tor_addr_to_addr_policy(const tor_addr_t *addr, - uint16_t port, const smartlist_t *policy); -addr_policy_result_t compare_addr_to_addr_policy(uint32_t addr, - uint16_t port, const smartlist_t *policy); -int policies_parse_exit_policy(config_line_t *cfg, smartlist_t **dest, - int rejectprivate, const char *local_address, - int add_default_policy); -void policies_set_router_exitpolicy_to_reject_all(routerinfo_t *exitrouter); -int exit_policy_is_general_exit(smartlist_t *policy); -int policy_is_reject_star(const smartlist_t *policy); -int getinfo_helper_policies(control_connection_t *conn, - const char *question, char **answer, - const char **errmsg); -int policy_write_item(char *buf, size_t buflen, addr_policy_t *item, - int format_for_desc); - -void addr_policy_list_free(smartlist_t *p); -void addr_policy_free(addr_policy_t *p); -void policies_free_all(void); - -char *policy_summarize(smartlist_t *policy); - /********************************* reasons.c ***************************/ const char *stream_end_reason_to_control_string(int reason); diff --git a/src/or/policies.c b/src/or/policies.c index 72eb168478..cd6307daa6 100644 --- a/src/or/policies.c +++ b/src/or/policies.c @@ -11,6 +11,7 @@ #include "or.h" #include "config.h" #include "dirserv.h" +#include "policies.h" #include "ht.h" /** Policy that addresses for incoming SOCKS connections must match. */ diff --git a/src/or/policies.h b/src/or/policies.h new file mode 100644 index 0000000000..b99ee797f7 --- /dev/null +++ b/src/or/policies.h @@ -0,0 +1,60 @@ +/* Copyright (c) 2001 Matej Pfajfar. + * Copyright (c) 2001-2004, Roger Dingledine. + * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. + * Copyright (c) 2007-2010, The Tor Project, Inc. */ +/* See LICENSE for licensing information */ + +/** + * \file policies.h + * \brief Header file for policy.c. + **/ + +#ifndef _TOR_POLICIES_H +#define _TOR_POLICIES_H + +/* (length of "accept 255.255.255.255/255.255.255.255:65535-65535\n" plus a + * NUL.) + */ +#define POLICY_BUF_LEN 52 + +int firewall_is_fascist_or(void); +int fascist_firewall_allows_address_or(const tor_addr_t *addr, uint16_t port); +int fascist_firewall_allows_or(routerinfo_t *ri); +int fascist_firewall_allows_address_dir(const tor_addr_t *addr, uint16_t port); +int dir_policy_permits_address(const tor_addr_t *addr); +int socks_policy_permits_address(const tor_addr_t *addr); +int authdir_policy_permits_address(uint32_t addr, uint16_t port); +int authdir_policy_valid_address(uint32_t addr, uint16_t port); +int authdir_policy_baddir_address(uint32_t addr, uint16_t port); +int authdir_policy_badexit_address(uint32_t addr, uint16_t port); + +int validate_addr_policies(or_options_t *options, char **msg); +void policy_expand_private(smartlist_t **policy); +int policies_parse_from_options(or_options_t *options); + +addr_policy_t *addr_policy_get_canonical_entry(addr_policy_t *ent); +int cmp_addr_policies(smartlist_t *a, smartlist_t *b); +addr_policy_result_t compare_tor_addr_to_addr_policy(const tor_addr_t *addr, + uint16_t port, const smartlist_t *policy); +addr_policy_result_t compare_addr_to_addr_policy(uint32_t addr, + uint16_t port, const smartlist_t *policy); +int policies_parse_exit_policy(config_line_t *cfg, smartlist_t **dest, + int rejectprivate, const char *local_address, + int add_default_policy); +void policies_set_router_exitpolicy_to_reject_all(routerinfo_t *exitrouter); +int exit_policy_is_general_exit(smartlist_t *policy); +int policy_is_reject_star(const smartlist_t *policy); +int getinfo_helper_policies(control_connection_t *conn, + const char *question, char **answer, + const char **errmsg); +int policy_write_item(char *buf, size_t buflen, addr_policy_t *item, + int format_for_desc); + +void addr_policy_list_free(smartlist_t *p); +void addr_policy_free(addr_policy_t *p); +void policies_free_all(void); + +char *policy_summarize(smartlist_t *policy); + +#endif + diff --git a/src/or/relay.c b/src/or/relay.c index 83f875428e..f0801bf811 100644 --- a/src/or/relay.c +++ b/src/or/relay.c @@ -24,6 +24,7 @@ #include "main.h" #include "mempool.h" #include "networkstatus.h" +#include "policies.h" #include "rendcommon.h" #include "routerlist.h" diff --git a/src/or/router.c b/src/or/router.c index c9501d04ef..4a18916990 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -18,6 +18,7 @@ #include "geoip.h" #include "hibernate.h" #include "main.h" +#include "policies.h" #include "router.h" #include "routerlist.h" diff --git a/src/or/routerlist.c b/src/or/routerlist.c index f189943a16..1fb3dbc404 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -23,6 +23,7 @@ #include "hibernate.h" #include "main.h" #include "networkstatus.h" +#include "policies.h" #include "rendcommon.h" #include "rendservice.h" #include "router.h" diff --git a/src/or/routerparse.c b/src/or/routerparse.c index a7df1f5e05..0662fd3a18 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -13,6 +13,7 @@ #include "config.h" #include "dirserv.h" #include "dirvote.h" +#include "policies.h" #include "rendcommon.h" #include "router.h" #include "routerlist.h" diff --git a/src/test/test.c b/src/test/test.c index a1e2868196..b5c908a215 100644 --- a/src/test/test.c +++ b/src/test/test.c @@ -54,6 +54,7 @@ double fabs(double x); #include "mempool.h" #include "memarea.h" #include "onion.h" +#include "policies.h" #ifdef USE_DMALLOC #include <dmalloc.h> |