Tor  0.4.7.0-alpha-dev
bwhist.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 bwhist.h
9  * @brief Header for feature/stats/bwhist.c
10  **/
11 
12 #ifndef TOR_FEATURE_STATS_BWHIST_H
13 #define TOR_FEATURE_STATS_BWHIST_H
14 
15 void bwhist_init(void);
16 void bwhist_free_all(void);
17 
18 void bwhist_note_bytes_read(uint64_t num_bytes, time_t when, bool ipv6);
19 void bwhist_note_bytes_written(uint64_t num_bytes, time_t when, bool ipv6);
20 void bwhist_note_dir_bytes_read(uint64_t num_bytes, time_t when);
21 void bwhist_note_dir_bytes_written(uint64_t num_bytes, time_t when);
22 
24 char *bwhist_get_bandwidth_lines(void);
25 struct or_state_t;
26 void bwhist_update_state(struct or_state_t *state);
27 int bwhist_load_state(struct or_state_t *state, char **err);
28 
29 #ifdef BWHIST_PRIVATE
30 typedef struct bw_array_t bw_array_t;
35 STATIC void add_obs(bw_array_t *b, time_t when, uint64_t n);
36 #define bw_array_free(val) \
37  FREE_AND_NULL(bw_array_t, bw_array_free_, (val))
39 STATIC size_t bwhist_fill_bandwidth_history(char *buf, size_t len,
40  const bw_array_t *b);
41 #endif /* defined(BWHIST_PRIVATE) */
42 
43 #ifdef TOR_UNIT_TESTS
44 extern struct bw_array_t *write_array;
45 #endif
46 
47 #endif /* !defined(TOR_FEATURE_STATS_BWHIST_H) */
STATIC void commit_max(bw_array_t *b)
Definition: bwhist.c:32
STATIC void bw_array_free_(bw_array_t *b)
Definition: bwhist.c:112
STATIC bw_array_t * write_array
Definition: bwhist.c:126
STATIC size_t bwhist_fill_bandwidth_history(char *buf, size_t len, const bw_array_t *b)
Definition: bwhist.c:251
STATIC void advance_obs(bw_array_t *b)
Definition: bwhist.c:52
STATIC uint64_t find_largest_max(bw_array_t *b)
Definition: bwhist.c:214
STATIC void add_obs(bw_array_t *b, time_t when, uint64_t n)
Definition: bwhist.c:78
STATIC bw_array_t * bw_array_new(void)
Definition: bwhist.c:99
void bwhist_note_dir_bytes_written(uint64_t num_bytes, time_t when)
Definition: bwhist.c:195
char * bwhist_get_bandwidth_lines(void)
Definition: bwhist.c:323
void bwhist_update_state(struct or_state_t *state)
Definition: bwhist.c:402
int bwhist_load_state(struct or_state_t *state, char **err)
Definition: bwhist.c:504
void bwhist_init(void)
Definition: bwhist.c:139
void bwhist_note_bytes_read(uint64_t num_bytes, time_t when, bool ipv6)
Definition: bwhist.c:183
void bwhist_note_dir_bytes_read(uint64_t num_bytes, time_t when)
Definition: bwhist.c:204
void bwhist_note_bytes_written(uint64_t num_bytes, time_t when, bool ipv6)
Definition: bwhist.c:164
int bwhist_bandwidth_assess(void)
Definition: bwhist.c:233
#define STATIC
Definition: testsupport.h:32
#define MOCK_DECL(rv, funcname, arglist)
Definition: testsupport.h:127