Tor  0.4.7.0-alpha-dev
networkstatus.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-2021, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6 
7 /**
8  * \file networkstatus.h
9  * \brief Header file for networkstatus.c.
10  **/
11 
12 #ifndef TOR_NETWORKSTATUS_H
13 #define TOR_NETWORKSTATUS_H
14 
16 
20  const char *flavorname,
21  int unverified_consensus));
22 tor_mmap_t *networkstatus_map_cached_consensus(const char *flavorname);
25 #define routerstatus_free(rs) \
26  FREE_AND_NULL(routerstatus_t, routerstatus_free_, (rs))
28 #define networkstatus_vote_free(ns) \
29  FREE_AND_NULL(networkstatus_t, networkstatus_vote_free_, (ns))
31  networkstatus_t *vote,
32  const char *identity);
34  const networkstatus_voter_info_t *voter,
35  digest_algorithm_t alg);
36 
38  int warn);
41  const authority_cert_t *cert);
42 int compare_digest_to_routerstatus_entry(const void *_key,
43  const void **_member);
45  const void **_member);
47  networkstatus_t *ns,
48  const char *digest));
50  const char *digest);
52  const char *digest, int *found_out);
53 
56  (consensus_flavor_t flavor));
59  (consensus_flavor_t flavor));
62  (consensus_flavor_t flavor));
63 
66  (const char *d));
67 
68 const routerstatus_t *router_get_consensus_status_by_id(const char *digest);
70  const char *digest);
72  networkstatus_t *consensus,
73  const char *digest);
76  (networkstatus_t *consensus, const char *digest));
77 int we_want_to_fetch_flavor(const or_options_t *options, int flavor);
79 void networkstatus_consensus_download_failed(int status_code,
80  const char *flavname);
82 int should_delay_dir_fetches(const or_options_t *options,const char **msg_out);
83 void update_networkstatus_downloads(time_t now);
84 void update_certificate_downloads(time_t now);
86 int client_would_use_router(const routerstatus_t *rs, time_t now);
89  (consensus_flavor_t f));
91 int networkstatus_is_live(const networkstatus_t *ns, time_t now);
93  time_t now);
95  time_t now);
97  time_t now);
99  (time_t now,
100  int flavor));
103  const or_options_t *options);
105  const or_options_t *options));
106 int networkstatus_consensus_is_already_downloading(const char *resource);
107 
108 #define NSSET_FROM_CACHE 1
109 #define NSSET_WAS_WAITING_FOR_CERTS 2
110 #define NSSET_DONT_DOWNLOAD_CERTS 4
111 #define NSSET_ACCEPT_OBSOLETE 8
112 #define NSSET_REQUIRE_FLAVOR 16
113 int networkstatus_set_current_consensus(const char *consensus,
114  size_t consensus_len,
115  const char *flavor,
116  unsigned flags,
117  const char *source_dir);
118 void networkstatus_note_certs_arrived(const char *source_dir);
119 void routers_update_all_from_networkstatus(time_t now, int dir_version);
121  int reset_failures);
123  smartlist_t *descs);
124 
126 char *networkstatus_getinfo_by_purpose(const char *purpose_string, time_t now);
128  (const networkstatus_t *ns, const char *param_name,
129  int32_t default_val, int32_t min_val, int32_t max_val));
131  int32_t torrc_value,
132  const char *param_name,
133  int32_t default_val,
134  int32_t min_val, int32_t max_val);
136  const char *question, char **answer,
137  const char **errmsg);
138 int32_t networkstatus_get_bw_weight(networkstatus_t *ns, const char *weight,
139  int32_t default_val);
141 int networkstatus_parse_flavor_name(const char *flavname);
143 #define document_signature_free(sig) \
144  FREE_AND_NULL(document_signature_t, document_signature_free_, (sig))
146 void networkstatus_free_all(void);
148 
150 #define vote_routerstatus_free(rs) \
151  FREE_AND_NULL(vote_routerstatus_t, vote_routerstatus_free_, (rs))
152 
154  const node_t *node,
155  const routerinfo_t *ri);
157  int interval,
158  int offset);
159 
160 #ifdef NETWORKSTATUS_PRIVATE
161 #ifdef TOR_UNIT_TESTS
162 STATIC int networkstatus_set_current_consensus_from_ns(networkstatus_t *c,
163  const char *flavor);
164 STATIC void warn_early_consensus(const networkstatus_t *c, const char *flavor,
165  time_t now);
168 #endif /* defined(TOR_UNIT_TESTS) */
170  const routerstatus_t *b);
171 #endif /* defined(NETWORKSTATUS_PRIVATE) */
172 
173 #endif /* !defined(TOR_NETWORKSTATUS_H) */
digest_algorithm_t
Definition: crypto_digest.h:44
STATIC networkstatus_t * current_md_consensus
STATIC int routerstatus_has_visibly_changed(const routerstatus_t *a, const routerstatus_t *b)
STATIC networkstatus_t * current_ns_consensus
STATIC void warn_early_consensus(const networkstatus_t *c, const char *flavor, time_t now)
routerstatus_t * networkstatus_vote_find_mutable_entry(networkstatus_t *ns, const char *digest)
char * networkstatus_getinfo_helper_single(const routerstatus_t *rs)
int networkstatus_valid_after_is_reasonably_live(time_t valid_after, time_t now)
void update_networkstatus_downloads(time_t now)
int networkstatus_consensus_can_use_multiple_directories(const or_options_t *options)
int getinfo_helper_networkstatus(control_connection_t *conn, const char *question, char **answer, const char **errmsg)
int networkstatus_check_document_signature(const networkstatus_t *consensus, document_signature_t *sig, const authority_cert_t *cert)
networkstatus_t * networkstatus_get_latest_consensus_by_flavor(consensus_flavor_t f)
void routers_update_all_from_networkstatus(time_t now, int dir_version)
int networkstatus_parse_flavor_name(const char *flavname)
download_status_t * networkstatus_get_dl_status_by_flavor_bootstrap(consensus_flavor_t flavor)
int networkstatus_set_current_consensus(const char *consensus, size_t consensus_len, const char *flavor, unsigned flags, const char *source_dir)
int compare_digest_to_vote_routerstatus_entry(const void *_key, const void **_member)
void signed_descs_update_status_from_consensus_networkstatus(smartlist_t *descs)
smartlist_t * router_get_descriptor_digests(void)
int networkstatus_consensus_reasonably_live(const networkstatus_t *consensus, time_t now)
const char * networkstatus_get_flavor_name(consensus_flavor_t flav)
int we_want_to_fetch_flavor(const or_options_t *options, int flavor)
int32_t networkstatus_get_overridable_param(const networkstatus_t *ns, int32_t torrc_value, const char *param_name, int32_t default_val, int32_t min_val, int32_t max_val)
time_t voting_sched_get_start_of_interval_after(time_t now, int interval, int offset)
int client_would_use_router(const routerstatus_t *rs, time_t now)
networkstatus_t * networkstatus_get_reasonably_live_consensus(time_t now, int flavor)
networkstatus_voter_info_t * networkstatus_get_voter_by_id(networkstatus_t *vote, const char *identity)
download_status_t * networkstatus_get_dl_status_by_flavor(consensus_flavor_t flavor)
int networkstatus_vote_find_entry_idx(networkstatus_t *ns, const char *digest, int *found_out)
void document_signature_free_(document_signature_t *sig)
char * networkstatus_getinfo_by_purpose(const char *purpose_string, time_t now)
void networkstatus_free_all(void)
networkstatus_t * networkstatus_get_latest_consensus(void)
download_status_t * router_get_dl_status_by_descriptor_digest(const char *d)
void networkstatus_note_certs_arrived(const char *source_dir)
int networkstatus_consensus_is_bootstrapping(time_t now)
int networkstatus_check_consensus_signature(networkstatus_t *consensus, int warn)
const routerstatus_t * router_get_consensus_status_by_id(const char *digest)
download_status_t * networkstatus_get_dl_status_by_flavor_running(consensus_flavor_t flavor)
int networkstatus_valid_until_is_reasonably_live(time_t valid_until, time_t now)
int networkstatus_is_live(const networkstatus_t *ns, time_t now)
int compare_digest_to_routerstatus_entry(const void *_key, const void **_member)
void vote_routerstatus_free_(vote_routerstatus_t *rs)
document_signature_t * document_signature_dup(const document_signature_t *sig)
int should_delay_dir_fetches(const or_options_t *options, const char **msg_out)
int router_reload_consensus_networkstatus(void)
void update_certificate_downloads(time_t now)
int networkstatus_consensus_can_use_extra_fallbacks(const or_options_t *options)
const routerstatus_t * networkstatus_vote_find_entry(networkstatus_t *ns, const char *digest)
tor_mmap_t * networkstatus_map_cached_consensus(const char *flavorname)
document_signature_t * networkstatus_get_voter_sig_by_alg(const networkstatus_voter_info_t *voter, digest_algorithm_t alg)
int32_t networkstatus_get_param(const networkstatus_t *ns, const char *param_name, int32_t default_val, int32_t min_val, int32_t max_val)
void set_routerstatus_from_routerinfo(routerstatus_t *rs, const node_t *node, const routerinfo_t *ri)
routerstatus_t * router_get_mutable_consensus_status_by_id(const char *digest)
routerstatus_t * router_get_mutable_consensus_status_by_descriptor_digest(networkstatus_t *consensus, const char *digest)
void networkstatus_vote_free_(networkstatus_t *ns)
int32_t networkstatus_get_bw_weight(networkstatus_t *ns, const char *weight, int32_t default_val)
void update_consensus_networkstatus_fetch_time(time_t now)
void networkstatus_reset_download_failures(void)
void networkstatus_reset_warnings(void)
char * networkstatus_get_cache_fname(int flav, const char *flavorname, int unverified_consensus)
const routerstatus_t * router_get_consensus_status_by_descriptor_digest(networkstatus_t *consensus, const char *digest)
int we_want_to_fetch_unknown_auth_certs(const or_options_t *options)
networkstatus_t * networkstatus_get_live_consensus(time_t now)
int consensus_is_waiting_for_certs(void)
void routerstatus_free_(routerstatus_t *rs)
void networkstatus_consensus_download_failed(int status_code, const char *flavname)
void routers_update_status_from_consensus_networkstatus(smartlist_t *routers, int reset_failures)
int networkstatus_get_weight_scale_param(networkstatus_t *ns)
consensus_flavor_t
Definition: or.h:761
Definition: node_st.h:34
Macros to implement mocking and selective exposure for the test code.
#define STATIC
Definition: testsupport.h:32
#define MOCK_DECL(rv, funcname, arglist)
Definition: testsupport.h:127