Tor  0.4.6.0-alpha-dev
addr_policy_st.h
Go to the documentation of this file.
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-2020, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6 
7 /**
8  * @file addr_policy_st.h
9  * @brief Address policy structures.
10  **/
11 
12 #ifndef TOR_ADDR_POLICY_ST_H
13 #define TOR_ADDR_POLICY_ST_H
14 
15 #include "lib/cc/torint.h"
16 #include "lib/net/address.h"
17 
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,
23 #define addr_policy_action_bitfield_t ENUM_BF(addr_policy_action_t)
24 
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.
39  *
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  **/
47  uint16_t prt_min; /**< Lowest port number to accept/reject. */
48  uint16_t prt_max; /**< Highest port number to accept/reject. */
49 };
50 
51 #endif /* !defined(TOR_ADDR_POLICY_ST_H) */
tor_addr_t
Definition: address.h:69
addr_policy_t::prt_min
uint16_t prt_min
Definition: addr_policy_st.h:47
addr_policy_action_t
addr_policy_action_t
Definition: addr_policy_st.h:19
addr_policy_t::refcnt
int refcnt
Definition: addr_policy_st.h:27
torint.h
Integer definitions used throughout Tor.
addr_policy_t::is_private
unsigned int is_private
Definition: addr_policy_st.h:30
addr_policy_t
Definition: addr_policy_st.h:26
addr_policy_t::policy_type
addr_policy_action_bitfield_t policy_type
Definition: addr_policy_st.h:29
address.h
Headers for address.h.
maskbits_t
uint8_t maskbits_t
Definition: address.h:62
addr_policy_t::maskbits
maskbits_t maskbits
Definition: addr_policy_st.h:35
addr_policy_t::addr
tor_addr_t addr
Definition: addr_policy_st.h:46
addr_policy_t::prt_max
uint16_t prt_max
Definition: addr_policy_st.h:48
addr_policy_t::is_canonical
unsigned int is_canonical
Definition: addr_policy_st.h:32