hibernate.h 1.7 KB

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