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-2016, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
9 * \brief Header file for hibernate.c.
12 #ifndef TOR_HIBERNATE_H
13 #define TOR_HIBERNATE_H
15 #include "testsupport.h"
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
));
19 int accounting_get_interval_length(void);
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 void consider_hibernation(time_t now
);
29 int getinfo_helper_accounting(control_connection_t
*conn
,
30 const char *question
, char **answer
,
32 uint64_t get_accounting_max_total(void);
34 #ifdef HIBERNATE_PRIVATE
35 /** Possible values of hibernate_state */
37 /** We are running normally. */
38 HIBERNATE_STATE_LIVE
=1,
39 /** We're trying to shut down cleanly, and we'll kill all active connections
40 * at shutdown_time. */
41 HIBERNATE_STATE_EXITING
=2,
42 /** We're running low on allocated bandwidth for this period, so we won't
43 * accept any new connections. */
44 HIBERNATE_STATE_LOWBANDWIDTH
=3,
45 /** We are hibernating, and we won't wake up till there's more bandwidth to
47 HIBERNATE_STATE_DORMANT
=4,
48 /** We start out in state default, which means we havent decided which state
50 HIBERNATE_STATE_INITIAL
=5
54 void hibernate_set_state_for_testing_(hibernate_state_t newstate
);