tor  0.4.2.0-alpha-dev
node_select.h
Go to the documentation of this file.
1 /* Copyright (c) 2001-2004, Roger Dingledine.
2  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
3  * Copyright (c) 2007-2019, The Tor Project, Inc. */
4 /* See LICENSE for licensing information */
5 
11 #ifndef TOR_NODE_SELECT_H
12 #define TOR_NODE_SELECT_H
13 
16 typedef enum router_crn_flags_t {
17  CRN_NEED_UPTIME = 1<<0,
18  CRN_NEED_CAPACITY = 1<<1,
19  CRN_NEED_GUARD = 1<<2,
20  /* XXXX not used, apparently. */
21  CRN_WEIGHT_AS_EXIT = 1<<5,
22  CRN_NEED_DESC = 1<<6,
23  /* On clients, only provide nodes that satisfy ClientPreferIPv6OR */
24  CRN_PREF_ADDR = 1<<7,
25  /* On clients, only provide nodes that we can connect to directly, based on
26  * our firewall rules */
27  CRN_DIRECT_CONN = 1<<8,
28  /* On clients, only provide nodes with HSRend >= 2 protocol version which
29  * is required for hidden service version >= 3. */
30  CRN_RENDEZVOUS_V3 = 1<<9,
32 
36  NO_WEIGHTING, WEIGHT_FOR_EXIT, WEIGHT_FOR_MID, WEIGHT_FOR_GUARD,
37  WEIGHT_FOR_DIR
39 
40 /* Flags for pick_directory_server() and pick_trusteddirserver(). */
44 #define PDS_ALLOW_SELF (1<<0)
45 
48 #define PDS_RETRY_IF_NO_SERVERS (1<<1)
49 
54 #define PDS_IGNORE_FASCISTFIREWALL (1<<2)
55 
61 #define PDS_NO_EXISTING_SERVERDESC_FETCH (1<<3)
62 
67 #define PDS_NO_EXISTING_MICRODESC_FETCH (1<<4)
68 
70  int flags);
71 
72 int router_get_my_share_of_directory_requests(double *v3_share_out);
73 
78  int for_direct_conn);
79 const node_t *router_choose_random_node(smartlist_t *excludedsmartlist,
80  struct routerset_t *excludedset,
81  router_crn_flags_t flags);
82 
84  int flags);
86  int flags);
87 
88 #ifdef NODE_SELECT_PRIVATE
89 STATIC int choose_array_element_by_weight(const uint64_t *entries,
90  int n_entries);
91 STATIC void scale_array_elements_to_u64(uint64_t *entries_out,
92  const double *entries_in,
93  int n_entries,
94  uint64_t *total_out);
96  dirinfo_type_t auth, int flags,
97  int *n_busy_out);
98 STATIC int router_is_already_dir_fetching(const tor_addr_port_t *ap,
99  int serverdesc, int microdesc);
100 #endif /* defined(NODE_SELECT_PRIVATE) */
101 
102 #endif /* !defined(TOR_NODE_SELECT_H) */
const routerstatus_t * router_pick_trusteddirserver(dirinfo_type_t type, int flags)
Definition: node_select.c:995
const routerstatus_t * router_pick_fallback_dirserver(dirinfo_type_t type, int flags)
Definition: node_select.c:1006
Definition: node_st.h:28
const routerstatus_t * router_pick_directory_server(dirinfo_type_t type, int flags)
Definition: node_select.c:71
dirinfo_type_t
Definition: or.h:891
STATIC const routerstatus_t * router_pick_directory_server_impl(dirinfo_type_t type, int flags, int *n_busy_out)
Definition: node_select.c:294
STATIC void scale_array_elements_to_u64(uint64_t *entries_out, const double *entries_in, int n_entries, uint64_t *total_out)
Definition: node_select.c:424
double frac_nodes_with_descriptors(const smartlist_t *sl, bandwidth_weight_rule_t rule, int for_direct_conn)
Definition: node_select.c:768
const node_t * router_choose_random_node(smartlist_t *excludedsmartlist, struct routerset_t *excludedset, router_crn_flags_t flags)
Definition: node_select.c:903
router_crn_flags_t
Definition: node_select.h:16
const node_t * node_sl_choose_by_bandwidth(const smartlist_t *sl, bandwidth_weight_rule_t rule)
Definition: node_select.c:803
bandwidth_weight_rule_t
Definition: node_select.h:35
STATIC int choose_array_element_by_weight(const uint64_t *entries, int n_entries)
Definition: node_select.c:453