hibernate.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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-2012, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. /**
  7. * \file hibernate.h
  8. * \brief Header file for hibernate.c.
  9. **/
  10. #ifndef _TOR_HIBERNATE_H
  11. #define _TOR_HIBERNATE_H
  12. int accounting_parse_options(const or_options_t *options, int validate_only);
  13. int accounting_is_enabled(const or_options_t *options);
  14. int accounting_get_interval_length(void);
  15. void configure_accounting(time_t now);
  16. void accounting_run_housekeeping(time_t now);
  17. void accounting_add_bytes(size_t n_read, size_t n_written, int seconds);
  18. int accounting_record_bandwidth_usage(time_t now, or_state_t *state);
  19. void hibernate_begin_shutdown(void);
  20. int we_are_hibernating(void);
  21. void consider_hibernation(time_t now);
  22. int getinfo_helper_accounting(control_connection_t *conn,
  23. const char *question, char **answer,
  24. const char **errmsg);
  25. #ifdef HIBERNATE_PRIVATE
  26. /** Possible values of hibernate_state */
  27. typedef enum {
  28. /** We are running normally. */
  29. HIBERNATE_STATE_LIVE=1,
  30. /** We're trying to shut down cleanly, and we'll kill all active connections
  31. * at shutdown_time. */
  32. HIBERNATE_STATE_EXITING=2,
  33. /** We're running low on allocated bandwidth for this period, so we won't
  34. * accept any new connections. */
  35. HIBERNATE_STATE_LOWBANDWIDTH=3,
  36. /** We are hibernating, and we won't wake up till there's more bandwidth to
  37. * use. */
  38. HIBERNATE_STATE_DORMANT=4,
  39. /** We start out in state default, which means we havent decided which state
  40. * we're in. */
  41. HIBERNATE_STATE_INITIAL=5
  42. } hibernate_state_t;
  43. void hibernate_set_state_for_testing_(hibernate_state_t newstate);
  44. #endif
  45. #endif