tor  master
hibernate.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-2017, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6 
12 #ifndef TOR_HIBERNATE_H
13 #define TOR_HIBERNATE_H
14 
15 #include "testsupport.h"
16 
17 int accounting_parse_options(const or_options_t *options, int validate_only);
18 MOCK_DECL(int, accounting_is_enabled, (const or_options_t *options));
20 MOCK_DECL(time_t, accounting_get_end_time, (void));
21 void configure_accounting(time_t now);
22 uint64_t get_accounting_bytes(void);
23 void accounting_run_housekeeping(time_t now);
24 void accounting_add_bytes(size_t n_read, size_t n_written, int seconds);
25 int accounting_record_bandwidth_usage(time_t now, or_state_t *state);
26 void hibernate_begin_shutdown(void);
27 MOCK_DECL(int, we_are_hibernating, (void));
28 MOCK_DECL(int, we_are_fully_hibernating,(void));
29 void consider_hibernation(time_t now);
31  const char *question, char **answer,
32  const char **errmsg);
33 uint64_t get_accounting_max_total(void);
34 void accounting_free_all(void);
35 
36 #ifdef HIBERNATE_PRIVATE
37 
38 typedef enum {
40  HIBERNATE_STATE_LIVE=1,
43  HIBERNATE_STATE_EXITING=2,
46  HIBERNATE_STATE_LOWBANDWIDTH=3,
49  HIBERNATE_STATE_DORMANT=4,
52  HIBERNATE_STATE_INITIAL=5
53 } hibernate_state_t;
54 
55 #ifdef TOR_UNIT_TESTS
56 void hibernate_set_state_for_testing_(hibernate_state_t newstate);
57 #endif
58 #endif /* defined(HIBERNATE_PRIVATE) */
59 
60 #endif /* !defined(TOR_HIBERNATE_H) */
61 
Definition: or.h:3657
int accounting_get_interval_length(void)
Definition: hibernate.c:295
void accounting_free_all(void)
Definition: hibernate.c:1209
int getinfo_helper_accounting(control_connection_t *conn, const char *question, char **answer, const char **errmsg)
Definition: hibernate.c:1123
MOCK_DECL(int, router_have_minimum_dir_info,(void))
uint64_t get_accounting_bytes(void)
Definition: hibernate.c:458
void accounting_add_bytes(size_t n_read, size_t n_written, int seconds)
Definition: hibernate.c:311
void hibernate_begin_shutdown(void)
Definition: hibernate.c:881
Definition: or.h:4708
int accounting_parse_options(const or_options_t *options, int validate_only)
Definition: hibernate.c:170
void consider_hibernation(time_t now)
Definition: hibernate.c:1052
Definition: or.h:1885
int accounting_record_bandwidth_usage(time_t now, or_state_t *state)
Definition: hibernate.c:685
void configure_accounting(time_t now)
Definition: hibernate.c:410
void accounting_run_housekeeping(time_t now)
Definition: hibernate.c:565