policies.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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-2011, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. /**
  7. * \file policies.h
  8. * \brief Header file for policies.c.
  9. **/
  10. #ifndef _TOR_POLICIES_H
  11. #define _TOR_POLICIES_H
  12. /* (length of "accept 255.255.255.255/255.255.255.255:65535-65535\n" plus a
  13. * NUL.)
  14. */
  15. #define POLICY_BUF_LEN 52
  16. int firewall_is_fascist_or(void);
  17. int fascist_firewall_allows_address_or(const tor_addr_t *addr, uint16_t port);
  18. int fascist_firewall_allows_or(routerinfo_t *ri);
  19. int fascist_firewall_allows_address_dir(const tor_addr_t *addr, uint16_t port);
  20. int dir_policy_permits_address(const tor_addr_t *addr);
  21. int socks_policy_permits_address(const tor_addr_t *addr);
  22. int authdir_policy_permits_address(uint32_t addr, uint16_t port);
  23. int authdir_policy_valid_address(uint32_t addr, uint16_t port);
  24. int authdir_policy_baddir_address(uint32_t addr, uint16_t port);
  25. int authdir_policy_badexit_address(uint32_t addr, uint16_t port);
  26. int validate_addr_policies(or_options_t *options, char **msg);
  27. void policy_expand_private(smartlist_t **policy);
  28. int policies_parse_from_options(or_options_t *options);
  29. addr_policy_t *addr_policy_get_canonical_entry(addr_policy_t *ent);
  30. int cmp_addr_policies(smartlist_t *a, smartlist_t *b);
  31. addr_policy_result_t compare_tor_addr_to_addr_policy(const tor_addr_t *addr,
  32. uint16_t port, const smartlist_t *policy);
  33. addr_policy_result_t compare_addr_to_addr_policy(uint32_t addr,
  34. uint16_t port, const smartlist_t *policy);
  35. int policies_parse_exit_policy(config_line_t *cfg, smartlist_t **dest,
  36. int rejectprivate, const char *local_address,
  37. int add_default_policy);
  38. void policies_exit_policy_append_reject_star(smartlist_t **dest);
  39. void policies_set_router_exitpolicy_to_reject_all(routerinfo_t *exitrouter);
  40. int exit_policy_is_general_exit(smartlist_t *policy);
  41. int policy_is_reject_star(const smartlist_t *policy);
  42. int getinfo_helper_policies(control_connection_t *conn,
  43. const char *question, char **answer,
  44. const char **errmsg);
  45. int policy_write_item(char *buf, size_t buflen, addr_policy_t *item,
  46. int format_for_desc);
  47. void addr_policy_list_free(smartlist_t *p);
  48. void addr_policy_free(addr_policy_t *p);
  49. void policies_free_all(void);
  50. char *policy_summarize(smartlist_t *policy);
  51. #endif