Tor  0.4.6.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-2020, 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(REPHIST_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) */
or_state_t
Definition: or_state_st.h:21
find_largest_max
STATIC uint64_t find_largest_max(bw_array_t *b)
Definition: bwhist.c:214
bwhist_init
void bwhist_init(void)
Definition: bwhist.c:139
bw_array_free_
STATIC void bw_array_free_(bw_array_t *b)
Definition: bwhist.c:112
bwhist_note_dir_bytes_written
void bwhist_note_dir_bytes_written(uint64_t num_bytes, time_t when)
Definition: bwhist.c:195
bwhist_get_bandwidth_lines
char * bwhist_get_bandwidth_lines(void)
Definition: bwhist.c:323
add_obs
STATIC void add_obs(bw_array_t *b, time_t when, uint64_t n)
Definition: bwhist.c:78
MOCK_DECL
#define MOCK_DECL(rv, funcname, arglist)
Definition: testsupport.h:127
bw_array_t
Definition: bw_array_st.h:28
bwhist_note_dir_bytes_read
void bwhist_note_dir_bytes_read(uint64_t num_bytes, time_t when)
Definition: bwhist.c:204
bwhist_update_state
void bwhist_update_state(struct or_state_t *state)
Definition: bwhist.c:402
write_array
STATIC bw_array_t * write_array
Definition: bwhist.c:126
bw_array_new
STATIC bw_array_t * bw_array_new(void)
Definition: bwhist.c:99
commit_max
STATIC void commit_max(bw_array_t *b)
Definition: bwhist.c:32
bwhist_load_state
int bwhist_load_state(struct or_state_t *state, char **err)
Definition: bwhist.c:504
bwhist_note_bytes_read
void bwhist_note_bytes_read(uint64_t num_bytes, time_t when, bool ipv6)
Definition: bwhist.c:183
advance_obs
STATIC void advance_obs(bw_array_t *b)
Definition: bwhist.c:52
bwhist_note_bytes_written
void bwhist_note_bytes_written(uint64_t num_bytes, time_t when, bool ipv6)
Definition: bwhist.c:164
STATIC
#define STATIC
Definition: testsupport.h:32
bwhist_bandwidth_assess
int bwhist_bandwidth_assess(void)
Definition: bwhist.c:233
bwhist_fill_bandwidth_history
STATIC size_t bwhist_fill_bandwidth_history(char *buf, size_t len, const bw_array_t *b)
Definition: bwhist.c:251