main.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. /**
  7. * \file main.h
  8. * \brief Header file for main.c.
  9. **/
  10. #ifndef TOR_MAIN_H
  11. #define TOR_MAIN_H
  12. int have_completed_a_circuit(void);
  13. void note_that_we_completed_a_circuit(void);
  14. void note_that_we_maybe_cant_complete_circuits(void);
  15. int connection_add_impl(connection_t *conn, int is_connecting);
  16. #define connection_add(conn) connection_add_impl((conn), 0)
  17. #define connection_add_connecting(conn) connection_add_impl((conn), 1)
  18. int connection_remove(connection_t *conn);
  19. void connection_unregister_events(connection_t *conn);
  20. int connection_in_array(connection_t *conn);
  21. void add_connection_to_closeable_list(connection_t *conn);
  22. int connection_is_on_closeable_list(connection_t *conn);
  23. MOCK_DECL(smartlist_t *, get_connection_array, (void));
  24. MOCK_DECL(uint64_t,get_bytes_read,(void));
  25. MOCK_DECL(uint64_t,get_bytes_written,(void));
  26. /** Bitmask for events that we can turn on and off with
  27. * connection_watch_events. */
  28. typedef enum watchable_events {
  29. /* Yes, it is intentional that these match Libevent's EV_READ and EV_WRITE */
  30. READ_EVENT=0x02, /**< We want to know when a connection is readable */
  31. WRITE_EVENT=0x04 /**< We want to know when a connection is writable */
  32. } watchable_events_t;
  33. void connection_watch_events(connection_t *conn, watchable_events_t events);
  34. int connection_is_reading(connection_t *conn);
  35. MOCK_DECL(void,connection_stop_reading,(connection_t *conn));
  36. MOCK_DECL(void,connection_start_reading,(connection_t *conn));
  37. int connection_is_writing(connection_t *conn);
  38. MOCK_DECL(void,connection_stop_writing,(connection_t *conn));
  39. MOCK_DECL(void,connection_start_writing,(connection_t *conn));
  40. void tell_event_loop_to_finish(void);
  41. void connection_stop_reading_from_linked_conn(connection_t *conn);
  42. MOCK_DECL(int, connection_count_moribund, (void));
  43. void directory_all_unreachable(time_t now);
  44. void directory_info_has_arrived(time_t now, int from_cache, int suppress_logs);
  45. void ip_address_changed(int at_interface);
  46. void dns_servers_relaunch_checks(void);
  47. void reset_all_main_loop_timers(void);
  48. void reschedule_descriptor_update_check(void);
  49. void reschedule_directory_downloads(void);
  50. MOCK_DECL(long,get_uptime,(void));
  51. unsigned get_signewnym_epoch(void);
  52. void handle_signals(int is_parent);
  53. void activate_signal(int signal_num);
  54. int try_locking(const or_options_t *options, int err_if_locked);
  55. int have_lockfile(void);
  56. void release_lockfile(void);
  57. void tor_cleanup(void);
  58. void tor_free_all(int postfork);
  59. int tor_main(int argc, char *argv[]);
  60. int do_main_loop(void);
  61. int tor_init(int argc, char **argv);
  62. extern time_t time_of_process_start;
  63. extern long stats_n_seconds_working;
  64. extern int quiet_level;
  65. extern int global_read_bucket;
  66. extern int global_write_bucket;
  67. extern int global_relayed_read_bucket;
  68. extern int global_relayed_write_bucket;
  69. #ifdef MAIN_PRIVATE
  70. STATIC void init_connection_lists(void);
  71. STATIC void close_closeable_connections(void);
  72. STATIC void initialize_periodic_events(void);
  73. STATIC void teardown_periodic_events(void);
  74. #endif
  75. #endif