networkstatus.c File Reference

Functions and structures for handling network status documents as a client or cache. More...

#include "or.h"

Data Structures

struct  consensus_waiting_for_certs_t

Defines

#define NETWORKSTATUS_ALLOW_SKEW   (24*60*60)
#define V2_NETWORKSTATUS_ROUTER_LIFETIME   (3*60*60)
#define AUTHORITY_NS_CACHE_INTERVAL   (10*60)
#define NONAUTHORITY_NS_CACHE_INTERVAL   (60*60)
#define CONSENSUS_NETWORKSTATUS_MAX_DL_TRIES   8
#define DELAY_WHILE_FETCHING_CERTS   (20*60)
#define CONSENSUS_MIN_SECONDS_BEFORE_CACHING   120
#define REASONABLY_LIVE_TIME   (24*60*60)

Functions

static void download_status_map_update_from_v2_networkstatus (void)
static void routerstatus_list_update_named_server_map (void)
void networkstatus_reset_warnings (void)
void networkstatus_reset_download_failures (void)
int router_reload_v2_networkstatus (void)
int router_reload_consensus_networkstatus (void)
static void vote_routerstatus_free (vote_routerstatus_t *rs)
void routerstatus_free (routerstatus_t *rs)
void networkstatus_v2_free (networkstatus_v2_t *ns)
void document_signature_free (document_signature_t *sig)
document_signature_tdocument_signature_dup (const document_signature_t *sig)
void networkstatus_vote_free (networkstatus_t *ns)
networkstatus_voter_info_tnetworkstatus_get_voter_by_id (networkstatus_t *vote, const char *identity)
int networkstatus_check_document_signature (const networkstatus_t *consensus, document_signature_t *sig, const authority_cert_t *cert)
int networkstatus_check_consensus_signature (networkstatus_t *consensus, int warn)
char * networkstatus_get_cache_filename (const char *identity_digest)
static int _compare_networkstatus_v2_published_on (const void **_a, const void **_b)
static int add_networkstatus_to_cache (const char *s, v2_networkstatus_source_t source, networkstatus_v2_t *ns)
int router_set_networkstatus_v2 (const char *s, time_t arrived_at, v2_networkstatus_source_t source, smartlist_t *requested_fingerprints)
void networkstatus_v2_list_clean (time_t now)
int compare_digest_to_routerstatus_entry (const void *_key, const void **_member)
routerstatus_tnetworkstatus_v2_find_entry (networkstatus_v2_t *ns, const char *digest)
routerstatus_tnetworkstatus_vote_find_entry (networkstatus_t *ns, const char *digest)
int networkstatus_vote_find_entry_idx (networkstatus_t *ns, const char *digest, int *found_out)
const smartlist_tnetworkstatus_get_v2_list (void)
routerstatus_trouter_get_consensus_status_by_descriptor_digest (const char *digest)
download_status_trouter_get_dl_status_by_descriptor_digest (const char *d)
routerstatus_trouter_get_consensus_status_by_id (const char *digest)
routerstatus_trouter_get_consensus_status_by_nickname (const char *nickname, int warn_if_unnamed)
const char * networkstatus_get_router_digest_by_nickname (const char *nickname)
int networkstatus_nickname_is_unnamed (const char *nickname)
static void update_v2_networkstatus_cache_downloads (time_t now)
static void update_consensus_networkstatus_downloads (time_t now)
void networkstatus_consensus_download_failed (int status_code)
void update_consensus_networkstatus_fetch_time (time_t now)
int should_delay_dir_fetches (or_options_t *options)
void update_networkstatus_downloads (time_t now)
void update_certificate_downloads (time_t now)
int consensus_is_waiting_for_certs (void)
networkstatus_v2_tnetworkstatus_v2_get_by_digest (const char *digest)
networkstatus_tnetworkstatus_get_latest_consensus (void)
networkstatus_tnetworkstatus_get_live_consensus (time_t now)
networkstatus_tnetworkstatus_get_reasonably_live_consensus (time_t now)
static int routerstatus_has_changed (const routerstatus_t *a, const routerstatus_t *b)
static void notify_control_networkstatus_changed (const networkstatus_t *old_c, const networkstatus_t *new_c)
static void networkstatus_copy_old_consensus_info (networkstatus_t *new_c, const networkstatus_t *old_c)
int networkstatus_set_current_consensus (const char *consensus, const char *flavor, unsigned flags)
void networkstatus_note_certs_arrived (void)
void routers_update_all_from_networkstatus (time_t now, int dir_version)
void routers_update_status_from_consensus_networkstatus (smartlist_t *routers, int reset_failures)
void signed_descs_update_status_from_consensus_networkstatus (smartlist_t *descs)
char * networkstatus_getinfo_helper_single (routerstatus_t *rs)
char * networkstatus_getinfo_by_purpose (const char *purpose_string, time_t now)
void networkstatus_dump_bridge_status_to_file (time_t now)
int32_t get_net_param_from_list (smartlist_t *net_params, const char *param_name, int default_val)
int32_t networkstatus_get_param (networkstatus_t *ns, const char *param_name, int32_t default_val)
int32_t networkstatus_get_bw_weight (networkstatus_t *ns, const char *weight_name, int32_t default_val)
const char * networkstatus_get_flavor_name (consensus_flavor_t flav)
int networkstatus_parse_flavor_name (const char *flavname)
int getinfo_helper_networkstatus (control_connection_t *conn, const char *question, char **answer)
void networkstatus_free_all (void)

Variables

static digestmap_t * v2_download_status_map = NULL
static smartlist_tnetworkstatus_v2_list = NULL
static int networkstatus_v2_list_has_changed = 0
static strmap_t * named_server_map = NULL
static strmap_t * unnamed_server_map = NULL
static networkstatus_tcurrent_consensus = NULL
static
consensus_waiting_for_certs_t 
consensus_waiting_for_certs [N_CONSENSUS_FLAVORS]
static time_t last_networkstatus_download_attempted = 0
static time_t time_to_download_next_consensus = 0
static download_status_t consensus_dl_status [N_CONSENSUS_FLAVORS]
static int have_warned_about_old_version = 0
static int have_warned_about_new_version = 0


Detailed Description

Functions and structures for handling network status documents as a client or cache.


Define Documentation

#define AUTHORITY_NS_CACHE_INTERVAL   (10*60)

How frequently do directory authorities re-download fresh networkstatus documents?

Referenced by update_v2_networkstatus_cache_downloads().

#define CONSENSUS_MIN_SECONDS_BEFORE_CACHING   120

How long do we (as a cache) wait after a consensus becomes non-fresh before trying to fetch another?

Referenced by update_consensus_networkstatus_fetch_time().

#define CONSENSUS_NETWORKSTATUS_MAX_DL_TRIES   8

How many times will we try to fetch a consensus before we give up?

Referenced by update_consensus_networkstatus_downloads().

#define DELAY_WHILE_FETCHING_CERTS   (20*60)

How long will we hang onto a possibly live consensus for which we're fetching certs before we check whether there is a better one?

Referenced by update_consensus_networkstatus_downloads().

#define NETWORKSTATUS_ALLOW_SKEW   (24*60*60)

How far in the future do we allow a network-status to get before removing it? (seconds)

Referenced by router_set_networkstatus_v2().

#define NONAUTHORITY_NS_CACHE_INTERVAL   (60*60)

How frequently do non-authority directory caches re-download fresh networkstatus documents?

Referenced by update_v2_networkstatus_cache_downloads().


Function Documentation

static int _compare_networkstatus_v2_published_on ( const void **  _a,
const void **  _b 
) [static]

Helper for smartlist_sort: Compare two networkstatus objects by publication date.

References networkstatus_v2_t::published_on.

static int add_networkstatus_to_cache ( const char *  s,
v2_networkstatus_source_t  source,
networkstatus_v2_t ns 
) [static]

Add the parsed v2 networkstatus in ns (with original document in s) to the disk cache (and the in-memory directory server cache) as appropriate.

References directory_caches_v2_dir_info(), dirserv_set_cached_networkstatus_v2(), get_options(), networkstatus_v2_t::identity_digest, LD_FS, networkstatus_get_cache_filename(), networkstatus_v2_t::published_on, tor_free, and write_str_to_file().

Referenced by router_set_networkstatus_v2().

int compare_digest_to_routerstatus_entry ( const void *  _key,
const void **  _member 
)

Helper for bsearching a list of routerstatus_t pointers: compare a digest in the key to the identity digest of a routerstatus_t.

References DIGEST_LEN, and routerstatus_t::identity_digest.

Referenced by measured_bw_line_apply(), networkstatus_v2_find_entry(), networkstatus_vote_find_entry(), networkstatus_vote_find_entry_idx(), and router_get_consensus_status_by_id().

int consensus_is_waiting_for_certs ( void   ) 

Return 1 if we have a consensus but we don't have enough certificates to start using it yet.

References consensus_waiting_for_certs_t::consensus, and USABLE_CONSENSUS_FLAVOR.

Referenced by connection_edge_process_relay_cell_not_open().

document_signature_t* document_signature_dup ( const document_signature_t sig  ) 

Return a newly allocated copy of sig

References document_signature_t::signature, and document_signature_t::signature_len.

Referenced by networkstatus_add_detached_signatures().

void document_signature_free ( document_signature_t sig  ) 

static void download_status_map_update_from_v2_networkstatus ( void   )  [static]

Update v2_download_status_map to contain an entry for every router descriptor listed in the v2 networkstatuses.

References _tor_free(), digestmap_free(), digestmap_get(), digestmap_new(), digestmap_remove(), digestmap_set(), networkstatus_v2_list_has_changed, and v2_download_status_map.

Referenced by routers_update_all_from_networkstatus().

int getinfo_helper_networkstatus ( control_connection_t conn,
const char *  question,
char **  answer 
)

If question is a string beginning with "ns/" in a format the control interface expects for a GETINFO question, set *answer to a newly-allocated string containing networkstatus lines for the appropriate ORs. Return 0 on success, -1 on unrecognized question format.

References networkstatus_getinfo_helper_single(), networkstatus_t::routerstatus_list, smartlist_add(), smartlist_create(), smartlist_free(), smartlist_join_strings(), and tor_free.

int networkstatus_check_consensus_signature ( networkstatus_t consensus,
int  warn 
)

Given a v3 networkstatus consensus in consensus, check every as-yet-unchecked signature on consensus. Return 1 if there is a signature from every recognized authority on it, 0 if there are enough good signatures from recognized authorities on it, -1 if we might get enough good signatures by fetching missing certificates, and -2 otherwise. Log messages at INFO or WARN: if warn is over 1, warn about every problem; if warn is at least 1, warn only if we can't get enough signatures; if warn is negative, log nothing at all.

References authority_cert_get_by_digests(), DIGEST_LEN, authority_cert_t::expires, get_n_authorities(), hex_str(), LD_DIR, networkstatus_check_document_signature(), networkstatus_get_voter_by_id(), router_get_trusted_dir_servers(), smartlist_add(), smartlist_create(), smartlist_free(), tor_assert, trusteddirserver_get_by_v3_auth_digest(), networkstatus_t::type, V3_AUTHORITY, and networkstatus_t::voters.

Referenced by dirvote_compute_consensuses(), dirvote_fetch_missing_signatures(), dirvote_publish_consensus(), networkstatus_note_certs_arrived(), and networkstatus_set_current_consensus().

int networkstatus_check_document_signature ( const networkstatus_t consensus,
document_signature_t sig,
const authority_cert_t cert 
)

void networkstatus_consensus_download_failed ( int  status_code  ) 

Called when an attempt to download a consensus fails: note that the failure occurred, and possibly retry.

References download_status_failed, and update_consensus_networkstatus_downloads().

Referenced by connection_dir_client_reached_eof(), and connection_dir_request_failed().

static void networkstatus_copy_old_consensus_info ( networkstatus_t new_c,
const networkstatus_t old_c 
) [static]

Copy all the ancillary information (like router download status and so on) from old_c to new_c.

References DIGEST_LEN, and networkstatus_t::routerstatus_list.

Referenced by networkstatus_set_current_consensus().

void networkstatus_dump_bridge_status_to_file ( time_t  now  ) 

Write out router status entries for all our bridge descriptors.

References or_options_t::DataDirectory, get_options(), networkstatus_getinfo_by_purpose(), tor_free, tor_snprintf(), and write_str_to_file().

Referenced by run_scheduled_events().

void networkstatus_free_all ( void   ) 

int32_t networkstatus_get_bw_weight ( networkstatus_t ns,
const char *  weight_name,
int32_t  default_val 
)

Return the value of a integer bw weight parameter from the networkstatus ns whose name is weight_name. If ns is NULL, try loading the latest consensus ourselves. Return default_val if no latest consensus, or if it has no parameter called param_name.

References networkstatus_get_latest_consensus(), and networkstatus_t::weight_params.

Referenced by networkstatus_verify_bw_weights(), and smartlist_choose_by_bandwidth_weights().

char* networkstatus_get_cache_filename ( const char *  identity_digest  ) 

Helper: return a newly allocated string containing the name of the filename where we plan to cache the network status with the given identity digest.

References base16_encode(), DIGEST_LEN, get_datadir_fname2, and HEX_DIGEST_LEN.

Referenced by add_networkstatus_to_cache(), dirserv_clear_old_networkstatuses(), networkstatus_v2_list_clean(), and router_set_networkstatus_v2().

const char* networkstatus_get_flavor_name ( consensus_flavor_t  flav  ) 

networkstatus_t* networkstatus_get_latest_consensus ( void   ) 

networkstatus_t* networkstatus_get_live_consensus ( time_t  now  ) 

Return the most recent consensus that we have downloaded, or NULL if it is no longer live.

References networkstatus_t::valid_after.

Referenced by dirvote_recalculate_timing(), routers_update_all_from_networkstatus(), update_consensus_networkstatus_downloads(), and update_consensus_networkstatus_fetch_time().

int32_t networkstatus_get_param ( networkstatus_t ns,
const char *  param_name,
int32_t  default_val 
)

Return the value of a integer parameter from the networkstatus ns whose name is param_name. If ns is NULL, try loading the latest consensus ourselves. Return default_val if no latest consensus, or if it has no parameter called param_name.

References networkstatus_t::net_params, and networkstatus_get_latest_consensus().

Referenced by cell_ewma_set_scale_factor(), circuit_build_times_new_consensus_params(), circuit_initial_package_window(), connection_or_init_conn_from_address(), networkstatus_verify_bw_weights(), and smartlist_choose_by_bandwidth_weights().

networkstatus_t* networkstatus_get_reasonably_live_consensus ( time_t  now  ) 

const char* networkstatus_get_router_digest_by_nickname ( const char *  nickname  ) 

Return the identity digest that's mapped to officially by nickname.

References named_server_map, and strmap_get_lc().

Referenced by router_get_by_nickname().

const smartlist_t* networkstatus_get_v2_list ( void   ) 

networkstatus_voter_info_t* networkstatus_get_voter_by_id ( networkstatus_t vote,
const char *  identity 
)

Return the voter info from vote for the voter whose identity digest is identity, or NULL if no such voter is associated with vote.

References DIGEST_LEN, and networkstatus_t::voters.

Referenced by networkstatus_add_detached_signatures(), networkstatus_check_consensus_signature(), and networkstatus_parse_vote_from_string().

char* networkstatus_getinfo_by_purpose ( const char *  purpose_string,
time_t  now 
)

Alloc and return a string describing routerstatuses for the most recent info of each router we know about that is of purpose purpose_string. Return NULL if unrecognized purpose.

Right now this function is oriented toward listing bridges (you shouldn't use this for general-purpose routers, since those should be listed from the consensus, not from the routers list).

References authdir_mode_bridge(), dirserv_set_router_is_running(), get_options(), LD_DIR, networkstatus_getinfo_helper_single(), router_get_routerlist(), ROUTER_MAX_AGE_TO_PUBLISH, ROUTER_PURPOSE_BRIDGE, router_purpose_from_string(), ROUTER_PURPOSE_UNKNOWN, routerlist_t::routers, set_routerstatus_from_routerinfo(), smartlist_add(), and smartlist_create().

Referenced by directory_handle_command_get(), and networkstatus_dump_bridge_status_to_file().

char* networkstatus_getinfo_helper_single ( routerstatus_t rs  ) 

Generate networkstatus lines for a single routerstatus_t object, and return the result in a newly allocated string. Used only by controller interface (for now.)

References routerstatus_format_entry(), and RS_ENTRY_LEN.

Referenced by control_event_networkstatus_changed_helper(), getinfo_helper_networkstatus(), and networkstatus_getinfo_by_purpose().

int networkstatus_nickname_is_unnamed ( const char *  nickname  ) 

Return true iff nickname is disallowed from being the nickname of any server.

References strmap_get_lc(), and unnamed_server_map.

Referenced by router_get_by_nickname().

void networkstatus_note_certs_arrived ( void   ) 

int networkstatus_parse_flavor_name ( const char *  flavname  ) 

Return the consensus_flavor_t value for the flavor called flavname, or -1 if the flavor is not recognized.

Referenced by networkstatus_parse_vote_from_string(), and networkstatus_set_current_consensus().

void networkstatus_reset_download_failures ( void   ) 

Reset the descriptor download failure count on all networkstatus docs, so that we can retry any long-failed documents immediately.

References networkstatus_get_v2_list(), and router_get_by_descriptor_digest().

Referenced by router_reset_descriptor_download_failures().

void networkstatus_reset_warnings ( void   ) 

Forget that we've warned about anything networkstatus-related, so we will give fresh warnings if the same behavior happens again.

References have_warned_about_new_version, have_warned_about_old_version, and networkstatus_t::routerstatus_list.

Referenced by routerlist_reset_warnings().

int networkstatus_set_current_consensus ( const char *  consensus,
const char *  flavor,
unsigned  flags 
)

Try to replace the current cached v3 networkstatus with the one in consensus. If we don't have enough certificates to validate it, store it in consensus_waiting_for_certs and launch a certificate fetch.

If flags & NSSET_FROM_CACHE, this networkstatus has come from the disk cache. If flags & NSSET_WAS_WAITING_FOR_CERTS, this networkstatus was already received, but we were waiting for certificates on it. If flags & NSSET_DONT_DOWNLOAD_CERTS, do not launch certificate downloads as needed. If flags & NSSET_ACCEPT_OBSOLETE, then we should be willing to take this consensus, even if it comes from many days in the past.

Return 0 on success, <0 on failure. On failure, caller should increment the failure count as appropriate.

We return -1 for mild failures that don't need to be reported to the user, and -2 for more serious problems.

References authority_certs_fetch_missing(), consensus_waiting_for_certs_t::body, cell_ewma_set_scale_factor(), circ_times, circuit_build_times_new_consensus_params(), consensus_waiting_for_certs_t::consensus, control_event_client_status(), control_event_general_status(), cached_dir_t::digests, networkstatus_t::digests, directory_caches_dir_info(), dirserv_get_consensus(), dirserv_set_cached_consensus_networkstatus(), dirvote_recalculate_timing(), consensus_waiting_for_certs_t::dl_failed, download_status_failed, download_status_reset(), networkstatus_t::flavor, format_iso_time(), format_time_interval(), ftime_definitely_before(), get_datadir_fname, get_options(), LD_BUG, LD_DIR, LD_GENERAL, networkstatus_check_consensus_signature(), networkstatus_copy_old_consensus_info(), networkstatus_get_flavor_name(), networkstatus_parse_flavor_name(), networkstatus_parse_vote_from_string(), networkstatus_vote_free(), notify_control_networkstatus_changed(), OLD_ROUTER_DESC_MAX_AGE, cached_dir_t::published, router_dir_info_changed(), routerstatus_list_update_named_server_map(), consensus_waiting_for_certs_t::set_at, tor_free, tor_snprintf(), update_consensus_networkstatus_fetch_time(), USABLE_CONSENSUS_FLAVOR, networkstatus_t::valid_after, networkstatus_t::valid_until, and write_str_to_file().

Referenced by connection_dir_client_reached_eof(), dirvote_publish_consensus(), networkstatus_note_certs_arrived(), and router_reload_consensus_networkstatus().

routerstatus_t* networkstatus_v2_find_entry ( networkstatus_v2_t ns,
const char *  digest 
)

Return the entry in ns for the identity digest digest, or NULL if none was found.

References compare_digest_to_routerstatus_entry(), networkstatus_v2_t::entries, and smartlist_bsearch().

Referenced by router_add_to_routerlist(), and signed_desc_digest_is_recognized().

void networkstatus_v2_free ( networkstatus_v2_t ns  ) 

networkstatus_v2_t* networkstatus_v2_get_by_digest ( const char *  digest  ) 

Return the network status with a given identity digest.

References DIGEST_LEN.

void networkstatus_v2_list_clean ( time_t  now  ) 

routerstatus_t* networkstatus_vote_find_entry ( networkstatus_t ns,
const char *  digest 
)

int networkstatus_vote_find_entry_idx ( networkstatus_t ns,
const char *  digest,
int *  found_out 
)

Search the routerstatuses in ns for one whose identity digest is digest. Return value and set *found_out as for smartlist_bsearch_idx().

References compare_digest_to_routerstatus_entry(), networkstatus_t::routerstatus_list, and smartlist_bsearch_idx().

Referenced by hid_serv_get_responsible_directories().

void networkstatus_vote_free ( networkstatus_t ns  ) 

static void notify_control_networkstatus_changed ( const networkstatus_t old_c,
const networkstatus_t new_c 
) [static]

routerstatus_t* router_get_consensus_status_by_descriptor_digest ( const char *  digest  ) 

Return the consensus view of the status of the router whose current descriptor digest is digest, or NULL if no such router is known.

References networkstatus_t::desc_digest_map, digestmap_new(), digestmap_set(), and networkstatus_t::routerstatus_list.

Referenced by router_get_dl_status_by_descriptor_digest(), and signed_descs_update_status_from_consensus_networkstatus().

routerstatus_t* router_get_consensus_status_by_id ( const char *  digest  ) 

routerstatus_t* router_get_consensus_status_by_nickname ( const char *  nickname,
int  warn_if_unnamed 
)

Given a nickname (possibly verbose, possibly a hexadecimal digest), return the corresponding routerstatus_t, or NULL if none exists. Warn the user if warn_if_unnamed is set, and they have specified a router by nickname, but the Named flag isn't set for that router.

References base16_decode(), DIGEST_LEN, escaped(), HEX_DIGEST_LEN, LD_GENERAL, named_server_map, networkstatus_vote_find_entry(), networkstatus_t::routerstatus_list, smartlist_create(), smartlist_free(), strmap_get_lc(), tor_fragile_assert, and unnamed_server_map.

Referenced by add_nickname_list_to_smartlist().

download_status_t* router_get_dl_status_by_descriptor_digest ( const char *  d  ) 

Given the digest of a router descriptor, return its current download status, or NULL if the digest is unrecognized.

References digestmap_get(), routerstatus_t::dl_status, router_get_consensus_status_by_descriptor_digest(), and v2_download_status_map.

Referenced by dir_routerdesc_download_failed(), and router_load_routers_from_string().

int router_reload_consensus_networkstatus ( void   ) 

int router_reload_v2_networkstatus ( void   ) 

int router_set_networkstatus_v2 ( const char *  s,
time_t  arrived_at,
v2_networkstatus_source_t  source,
smartlist_t requested_fingerprints 
)

Given a string s containing a network status that we received at arrived_at from source, try to parse it, see if we want to store it, and put it into our cache as necessary.

If source is NS_FROM_DIR or NS_FROM_CACHE, do not replace our own networkstatus_t (if we're an authoritative directory server).

If source is NS_FROM_CACHE, do not write our networkstatus_t to the cache.

If requested_fingerprints is provided, it must contain a list of uppercased identity fingerprints. Do not update any networkstatus whose fingerprint is not on the list; after updating a networkstatus, remove its fingerprint from the list.

Return 0 on success, -1 on failure.

Callers should make sure that routers_update_all_from_networkstatus() is invoked after this function succeeds.

Retain any routerinfo mentioned in a V2 networkstatus for at least this long.

References add_networkstatus_to_cache(), base16_encode(), control_event_general_status(), trusted_dir_server_t::description, DIGEST_LEN, directory_caches_v2_dir_info(), download_status_failed, download_status_reset(), networkstatus_v2_t::entries, format_iso_time(), format_time_interval(), get_options(), HEX_DIGEST_LEN, networkstatus_v2_t::identity_digest, signed_descriptor_t::last_listed_as_valid_until, LD_DIR, LD_GENERAL, NETWORKSTATUS_ALLOW_SKEW, networkstatus_v2_t::networkstatus_digest, networkstatus_get_cache_filename(), networkstatus_v2_free(), networkstatus_v2_parse_from_string(), networkstatus_v2_t::published_on, networkstatus_v2_t::received_on, router_digest_is_me(), router_get_by_descriptor_digest(), router_get_trusteddirserver_by_digest(), smartlist_add(), smartlist_create(), smartlist_join_strings(), smartlist_string_isin(), smartlist_string_remove(), networkstatus_v2_t::source_address, networkstatus_v2_t::source_dirport, tor_assert, tor_free, touch_file(), trusted_dir_server_t::type, V2_AUTHORITY, and trusted_dir_server_t::v2_ns_dl_status.

Referenced by connection_dir_client_reached_eof(), and router_reload_v2_networkstatus().

void routers_update_all_from_networkstatus ( time_t  now,
int  dir_version 
)

void routers_update_status_from_consensus_networkstatus ( smartlist_t routers,
int  reset_failures 
)

void routerstatus_free ( routerstatus_t rs  ) 

static int routerstatus_has_changed ( const routerstatus_t a,
const routerstatus_t b 
) [static]

static void routerstatus_list_update_named_server_map ( void   )  [static]

Update our view of the list of named servers from the most recently retrieved networkstatus consensus.

References _tor_free(), DIGEST_LEN, named_server_map, networkstatus_t::routerstatus_list, strmap_free(), strmap_set_lc(), and unnamed_server_map.

Referenced by networkstatus_set_current_consensus().

int should_delay_dir_fetches ( or_options_t options  ) 

Return 1 if there's a reason we shouldn't try any directory fetches yet (e.g. we demand bridges and none are yet known). Else return 0.

References any_bridge_descriptors_known(), LD_DIR, and or_options_t::UseBridges.

Referenced by authority_certs_fetch_missing(), update_extrainfo_downloads(), update_networkstatus_downloads(), update_router_descriptor_downloads(), and update_router_have_minimum_dir_info().

void signed_descs_update_status_from_consensus_networkstatus ( smartlist_t descs  ) 

Given a list of signed_descriptor_t, update their fields (mainly, when they were last listed) from the most recent consensus.

References networkstatus_t::desc_digest_map, DIGEST_LEN, digestmap_get(), router_get_consensus_status_by_descriptor_digest(), and networkstatus_t::valid_until.

Referenced by routers_update_all_from_networkstatus().

void update_certificate_downloads ( time_t  now  ) 

Launch requests as appropriate for missing directory authority certificates.

References authority_certs_fetch_missing().

Referenced by connection_dir_download_cert_failed(), router_reload_consensus_networkstatus(), and update_networkstatus_downloads().

static void update_consensus_networkstatus_downloads ( time_t  now  )  [static]

void update_consensus_networkstatus_fetch_time ( time_t  now  ) 

void update_networkstatus_downloads ( time_t  now  ) 

static void update_v2_networkstatus_cache_downloads ( time_t  now  )  [static]

We are a directory server, and so cache network_status documents. Initiate downloads as needed to update them. For v2 authorities, this means asking each trusted directory for its network-status. For caches, this means asking a random v2 authority for all network-statuses.

References tor_addr_t::addr, authdir_mode_v2(), AUTHORITY_NS_CACHE_INTERVAL, base16_encode(), CONN_TYPE_DIR, connection_get_by_type_addr_port_purpose(), connection_get_by_type_purpose(), DIGEST_LEN, DIR_PURPOSE_FETCH_V2_NETWORKSTATUS, directory_get_from_dirserver(), directory_initiate_command_routerstatus(), get_options(), HEX_DIGEST_LEN, last_networkstatus_download_attempted, NONAUTHORITY_NS_CACHE_INTERVAL, PDS_RETRY_IF_NO_SERVERS, router_digest_is_me(), router_get_trusted_dir_servers(), ROUTER_PURPOSE_GENERAL, tor_addr_from_ipv4h, trusted_dir_servers, and V2_AUTHORITY.

Referenced by update_networkstatus_downloads().

static void vote_routerstatus_free ( vote_routerstatus_t rs  )  [static]

Free all storage held by the vote_routerstatus object rs.

References routerstatus_t::exitsummary, vote_routerstatus_t::microdesc, vote_routerstatus_t::status, tor_free, and vote_routerstatus_t::version.

Referenced by networkstatus_vote_free().


Variable Documentation

download_status_t consensus_dl_status[N_CONSENSUS_FLAVORS] [static]

Download status for the current consensus networkstatus.

Most recently received and validated v3 consensus network status.

True iff we have logged a warning about this OR's version being newer than listed by the authorities.

Referenced by networkstatus_reset_warnings(), and routers_update_all_from_networkstatus().

True iff we have logged a warning about this OR's version being older than listed by the authorities.

Referenced by networkstatus_reset_warnings(), and routers_update_all_from_networkstatus().

The last time we tried to download a networkstatus, or 0 for "never". We use this to rate-limit download attempts for directory caches (including mirrors). Clients don't use this now.

Referenced by update_v2_networkstatus_cache_downloads().

strmap_t* named_server_map = NULL [static]

Global list of all of the current v2 network_status documents that we know about. This list is kept sorted by published_on.

Referenced by router_add_to_routerlist(), routerlist_remove_old_routers(), signed_desc_digest_is_recognized(), and update_router_descriptor_cache_downloads_v2().

True iff any member of networkstatus_v2_list has changed since the last time we called download_status_map_update_from_v2_networkstatus()

Referenced by download_status_map_update_from_v2_networkstatus(), and routers_update_all_from_networkstatus().

time_t time_to_download_next_consensus = 0 [static]

A time before which we shouldn't try to replace the current consensus: this will be at some point after the next consensus becomes valid, but before the current consensus becomes invalid.

Referenced by update_consensus_networkstatus_downloads(), and update_consensus_networkstatus_fetch_time().

strmap_t* unnamed_server_map = NULL [static]

Map from lowercase nickname to (void*)1 for all names that are listed as unnamed for some server in the consensus.

Referenced by networkstatus_free_all(), networkstatus_nickname_is_unnamed(), router_get_consensus_status_by_nickname(), router_reload_consensus_networkstatus(), and routerstatus_list_update_named_server_map().

digestmap_t* v2_download_status_map = NULL [static]

Map from descriptor digest of routers listed in the v2 networkstatus documents to download_status_t*

Referenced by download_status_map_update_from_v2_networkstatus(), networkstatus_free_all(), and router_get_dl_status_by_descriptor_digest().


Generated on Tue May 25 00:30:45 2010 for tor by  doxygen 1.5.6