Macros | Functions
bwauth.h File Reference

Go to the source code of this file.


#define BW_FILE_HEADERS_TERMINATOR   "=====\n"


int dirserv_read_measured_bandwidths (const char *from_file, smartlist_t *routerstatuses, smartlist_t *bw_file_headers, uint8_t *digest_out)
int dirserv_query_measured_bw_cache_kb (const char *node_id, long *bw_out, time_t *as_of_out)
void dirserv_clear_measured_bw_cache (void)
int dirserv_has_measured_bw (const char *node_id)
int dirserv_get_measured_bw_cache_size (void)
void dirserv_count_measured_bws (const smartlist_t *routers)
int dirserv_get_last_n_measured_bws (void)
uint32_t dirserv_get_credible_bandwidth_kb (const routerinfo_t *ri)

Detailed Description

Header file for bwauth.c.

Definition in file bwauth.h.

Macro Definition Documentation


#define BW_FILE_HEADERS_TERMINATOR   "=====\n"

Terminatore that separates bandwidth file headers from bandwidth file relay lines

Definition at line 20 of file bwauth.h.



Maximum allowable length of bandwidth headers in a bandwidth file

Definition at line 16 of file bwauth.h.

Function Documentation

◆ dirserv_clear_measured_bw_cache()

void dirserv_clear_measured_bw_cache ( void  )

Clear and free the measured bandwidth cache

Definition at line 101 of file bwauth.c.

References mbw_cache.

◆ dirserv_count_measured_bws()

void dirserv_count_measured_bws ( const smartlist_t routers)

Look through the routerlist, and using the measured bandwidth cache count how many measured bandwidths we know. This is used to decide whether we ever trust advertised bandwidths for purposes of assigning flags.

Definition at line 37 of file bwauth.c.

References dirserv_has_measured_bw(), routers_with_measured_bw, and SMARTLIST_FOREACH_BEGIN.

◆ dirserv_get_credible_bandwidth_kb()

uint32_t dirserv_get_credible_bandwidth_kb ( const routerinfo_t ri)

Return the bandwidth we believe for assigning flags; prefer measured over advertised, and if we have above a threshold quantity of measured bandwidths, we don't want to ever give flags to unmeasured routers, so return 0.

Definition at line 175 of file bwauth.c.

References dirserv_query_measured_bw_cache_kb(), signed_descriptor_t::identity_digest, router_get_advertised_bandwidth_capped(), routers_with_measured_bw, and tor_assert().

Referenced by dirserv_thinks_router_is_unreliable(), router_counts_toward_thresholds(), and set_routerstatus_from_routerinfo().

◆ dirserv_get_last_n_measured_bws()

int dirserv_get_last_n_measured_bws ( void  )

Return the last-computed result from dirserv_count_mesured_bws().

Definition at line 53 of file bwauth.c.

References routers_with_measured_bw.

Referenced by dirserv_compute_performance_thresholds(), and dirserv_get_flag_thresholds_line().

◆ dirserv_get_measured_bw_cache_size()

int dirserv_get_measured_bw_cache_size ( void  )

Get the current size of the measured bandwidth cache

Definition at line 164 of file bwauth.c.

References mbw_cache.

◆ dirserv_has_measured_bw()

int dirserv_has_measured_bw ( const char *  node_id)

Predicate wrapper for dirserv_query_measured_bw_cache()

Definition at line 157 of file bwauth.c.

References dirserv_query_measured_bw_cache_kb().

Referenced by dirserv_count_measured_bws(), and router_counts_toward_thresholds().

◆ dirserv_query_measured_bw_cache_kb()

int dirserv_query_measured_bw_cache_kb ( const char *  node_id,
long *  bw_kb_out,
time_t *  as_of_out 

Query the cache by identity digest, return value indicates whether we found it. The bw_out and as_of_out pointers receive the cached bandwidth value and the time it was cached if not NULL.

Definition at line 136 of file bwauth.c.

References mbw_cache.

Referenced by dirserv_get_bandwidth_for_router_kb(), dirserv_get_credible_bandwidth_kb(), and dirserv_has_measured_bw().

◆ dirserv_read_measured_bandwidths()

int dirserv_read_measured_bandwidths ( const char *  from_file,
smartlist_t routerstatuses,
smartlist_t bw_file_headers,
uint8_t *  digest_out 

Read the measured bandwidth list file, apply it to the list of vote_routerstatus_t and store all the headers in bw_file_headers. Returns -1 on error, 0 otherwise.

Definition at line 207 of file bwauth.c.

References crypto_digest256_new(), and tor_fopen_cloexec().