addr_policy_st.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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-2019, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. #ifndef TOR_ADDR_POLICY_ST_H
  7. #define TOR_ADDR_POLICY_ST_H
  8. #include "lib/cc/torint.h"
  9. #include "lib/net/address.h"
  10. /** What action type does an address policy indicate: accept or reject? */
  11. typedef enum {
  12. ADDR_POLICY_ACCEPT=1,
  13. ADDR_POLICY_REJECT=2,
  14. } addr_policy_action_t;
  15. #define addr_policy_action_bitfield_t ENUM_BF(addr_policy_action_t)
  16. /** A reference-counted address policy rule. */
  17. struct addr_policy_t {
  18. int refcnt; /**< Reference count */
  19. /** What to do when the policy matches.*/
  20. addr_policy_action_bitfield_t policy_type:2;
  21. unsigned int is_private:1; /**< True iff this is the pseudo-address,
  22. * "private". */
  23. unsigned int is_canonical:1; /**< True iff this policy is the canonical
  24. * copy (stored in a hash table to avoid
  25. * duplication of common policies) */
  26. maskbits_t maskbits; /**< Accept/reject all addresses <b>a</b> such that the
  27. * first <b>maskbits</b> bits of <b>a</b> match
  28. * <b>addr</b>. */
  29. /** Base address to accept or reject.
  30. *
  31. * Note that wildcards are treated
  32. * differntly depending on address family. An AF_UNSPEC address means
  33. * "All addresses, IPv4 or IPv6." An AF_INET address with maskbits==0 means
  34. * "All IPv4 addresses" and an AF_INET6 address with maskbits == 0 means
  35. * "All IPv6 addresses".
  36. **/
  37. tor_addr_t addr;
  38. uint16_t prt_min; /**< Lowest port number to accept/reject. */
  39. uint16_t prt_max; /**< Highest port number to accept/reject. */
  40. };
  41. #endif