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