Tor 0.5.0.0-alpha-dev
Loading...
Searching...
No Matches
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-2021, The Tor Project, Inc. */
5/* See LICENSE for licensing information */
6
7/**
8 * \file hibernate.h
9 * \brief Header file for hibernate.c.
10 **/
11
12#ifndef TOR_HIBERNATE_H
13#define TOR_HIBERNATE_H
14
16
17int accounting_parse_options(const or_options_t *options, int validate_only);
18MOCK_DECL(int, accounting_is_enabled, (const or_options_t *options));
20MOCK_DECL(time_t, accounting_get_end_time, (void));
21void configure_accounting(time_t now);
22uint64_t get_accounting_bytes(void);
23void accounting_run_housekeeping(time_t now);
24void accounting_add_bytes(size_t n_read, size_t n_written, int seconds);
25int accounting_record_bandwidth_usage(time_t now, or_state_t *state);
28MOCK_DECL(int, we_are_hibernating, (void));
30void consider_hibernation(time_t now);
32 const char *question, char **answer,
33 const char **errmsg);
34uint64_t get_accounting_max_total(void);
35void accounting_free_all(void);
36bool accounting_tor_is_dormant(void);
37
38#ifdef HIBERNATE_PRIVATE
39/** Possible values of hibernate_state */
40typedef enum {
41 /** We are running normally. */
42 HIBERNATE_STATE_LIVE=1,
43 /** We're trying to shut down cleanly, and we'll kill all active connections
44 * at shutdown_time. */
45 HIBERNATE_STATE_EXITING=2,
46 /** We're running low on allocated bandwidth for this period, so we won't
47 * accept any new connections. */
48 HIBERNATE_STATE_LOWBANDWIDTH=3,
49 /** We are hibernating, and we won't wake up till there's more bandwidth to
50 * use. */
51 HIBERNATE_STATE_DORMANT=4,
52 /** We start out in state default, which means we haven't decided which state
53 * we're in. */
54 HIBERNATE_STATE_INITIAL=5
55} hibernate_state_t;
56
57#ifdef TOR_UNIT_TESTS
58void hibernate_set_state_for_testing_(hibernate_state_t newstate);
59#endif
60#endif /* defined(HIBERNATE_PRIVATE) */
61
62#endif /* !defined(TOR_HIBERNATE_H) */
63
time_t accounting_get_end_time(void)
Definition hibernate.c:322
int accounting_parse_options(const or_options_t *options, int validate_only)
Definition hibernate.c:190
int getinfo_helper_accounting(control_connection_t *conn, const char *question, char **answer, const char **errmsg)
Definition hibernate.c:1179
int accounting_record_bandwidth_usage(time_t now, or_state_t *state)
Definition hibernate.c:705
void accounting_add_bytes(size_t n_read, size_t n_written, int seconds)
Definition hibernate.c:331
void consider_hibernation(time_t now)
Definition hibernate.c:1107
int we_are_fully_hibernating(void)
Definition hibernate.c:956
void configure_accounting(time_t now)
Definition hibernate.c:430
int accounting_is_enabled(const or_options_t *options)
Definition hibernate.c:305
int we_are_shutting_down(void)
Definition hibernate.c:936
void accounting_free_all(void)
Definition hibernate.c:1263
void accounting_run_housekeeping(time_t now)
Definition hibernate.c:585
int we_are_hibernating(void)
Definition hibernate.c:946
void hibernate_begin_shutdown(void)
Definition hibernate.c:927
uint64_t get_accounting_bytes(void)
Definition hibernate.c:478
int accounting_get_interval_length(void)
Definition hibernate.c:315
Macros to implement mocking and selective exposure for the test code.
#define MOCK_DECL(rv, funcname, arglist)