#ifndef TOR_NODE_SELECT_H
#define TOR_NODE_SELECT_H
typedef enum router_crn_flags_t {
CRN_NEED_UPTIME = 1<<0,
CRN_NEED_CAPACITY = 1<<1,
CRN_NEED_DESC = 1<<2,
CRN_NEED_GUARD = 1<<3,
CRN_DIRECT_CONN = 1<<4,
CRN_PREF_ADDR = 1<<5,
CRN_RENDEZVOUS_V3 = 1<<6,
CRN_INITIATE_IPV6_EXTEND = 1<<7,
} router_crn_flags_t;
typedef enum bandwidth_weight_rule_t {
NO_WEIGHTING, WEIGHT_FOR_EXIT, WEIGHT_FOR_MID, WEIGHT_FOR_GUARD,
WEIGHT_FOR_DIR
} bandwidth_weight_rule_t;
#define PDS_ALLOW_SELF (1<<0)
#define PDS_RETRY_IF_NO_SERVERS (1<<1)
#define PDS_IGNORE_FASCISTFIREWALL (1<<2)
#define PDS_NO_EXISTING_SERVERDESC_FETCH (1<<3)
#define PDS_NO_EXISTING_MICRODESC_FETCH (1<<4)
const routerstatus_t *router_pick_directory_server(dirinfo_type_t type,
int flags);
int router_get_my_share_of_directory_requests(double *v3_share_out);
const node_t *node_sl_choose_by_bandwidth(const smartlist_t *sl,
bandwidth_weight_rule_t rule);
double frac_nodes_with_descriptors(const smartlist_t *sl,
bandwidth_weight_rule_t rule,
int for_direct_conn);
const node_t *router_choose_random_node(smartlist_t *excludedsmartlist,
struct routerset_t *excludedset,
router_crn_flags_t flags);
const routerstatus_t *router_pick_trusteddirserver(dirinfo_type_t type,
int flags);
const routerstatus_t *router_pick_fallback_dirserver(dirinfo_type_t type,
int flags);
#ifdef NODE_SELECT_PRIVATE
STATIC int choose_array_element_by_weight(const uint64_t *entries,
int n_entries);
STATIC void scale_array_elements_to_u64(uint64_t *entries_out,
const double *entries_in,
int n_entries,
uint64_t *total_out);
STATIC const routerstatus_t *router_pick_directory_server_impl(
dirinfo_type_t auth, int flags,
int *n_busy_out);
STATIC int router_is_already_dir_fetching(const tor_addr_port_t *ap,
int serverdesc, int microdesc);
#endif
#endif