Tor  0.4.7.0-alpha-dev
bwauth.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 bwauth.h
9  * \brief Header file for bwauth.c
10  **/
11 
12 #ifndef TOR_BWAUTH_H
13 #define TOR_BWAUTH_H
14 
15 /** Maximum allowable length of bandwidth headers in a bandwidth file */
16 #define MAX_BW_FILE_HEADER_COUNT_IN_VOTE 50
17 
18 /** Terminatore that separates bandwidth file headers from bandwidth file
19  * relay lines */
20 #define BW_FILE_HEADERS_TERMINATOR "=====\n"
21 
22 int dirserv_read_measured_bandwidths(const char *from_file,
23  smartlist_t *routerstatuses,
24  smartlist_t *bw_file_headers,
25  uint8_t *digest_out);
26 int dirserv_query_measured_bw_cache_kb(const char *node_id,
27  long *bw_out,
28  time_t *as_of_out);
30 int dirserv_has_measured_bw(const char *node_id);
32 void dirserv_count_measured_bws(const smartlist_t *routers);
34 
36 
37 #ifdef BWAUTH_PRIVATE
38 typedef struct measured_bw_line_t {
39  char node_id[DIGEST_LEN];
40  char node_hex[MAX_HEX_NICKNAME_LEN+1];
41  long int bw_kb;
42 } measured_bw_line_t;
43 
44 /* Put the MAX_MEASUREMENT_AGE #define here so unit tests can see it */
45 #define MAX_MEASUREMENT_AGE (3*24*60*60) /* 3 days */
46 
47 STATIC int measured_bw_line_parse(measured_bw_line_t *out, const char *line,
48  int line_is_after_headers);
49 
50 STATIC int measured_bw_line_apply(measured_bw_line_t *parsed_line,
51  smartlist_t *routerstatuses);
52 
53 STATIC void dirserv_cache_measured_bw(const measured_bw_line_t *parsed_line,
54  time_t as_of);
56 #endif /* defined(BWAUTH_PRIVATE) */
57 
58 #endif /* !defined(TOR_BWAUTH_H) */
STATIC int measured_bw_line_apply(measured_bw_line_t *parsed_line, smartlist_t *routerstatuses)
Definition: bwauth.c:483
STATIC void dirserv_expire_measured_bw_cache(time_t now)
Definition: bwauth.c:114
STATIC void dirserv_cache_measured_bw(const measured_bw_line_t *parsed_line, time_t as_of)
Definition: bwauth.c:73
STATIC int measured_bw_line_parse(measured_bw_line_t *out, const char *orig_line, int line_is_after_headers)
Definition: bwauth.c:375
uint32_t dirserv_get_credible_bandwidth_kb(const routerinfo_t *ri)
Definition: bwauth.c:177
int dirserv_get_measured_bw_cache_size(void)
Definition: bwauth.c:166
int dirserv_read_measured_bandwidths(const char *from_file, smartlist_t *routerstatuses, smartlist_t *bw_file_headers, uint8_t *digest_out)
Definition: bwauth.c:232
void dirserv_count_measured_bws(const smartlist_t *routers)
Definition: bwauth.c:39
int dirserv_get_last_n_measured_bws(void)
Definition: bwauth.c:55
int dirserv_has_measured_bw(const char *node_id)
Definition: bwauth.c:159
int dirserv_query_measured_bw_cache_kb(const char *node_id, long *bw_out, time_t *as_of_out)
Definition: bwauth.c:138
void dirserv_clear_measured_bw_cache(void)
Definition: bwauth.c:103
#define DIGEST_LEN
Definition: digest_sizes.h:20
#define MAX_HEX_NICKNAME_LEN
Definition: or.h:115
#define STATIC
Definition: testsupport.h:32