main.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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-2013, 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. extern int can_complete_circuit;
  13. int connection_add_impl(connection_t *conn, int is_connecting);
  14. #define connection_add(conn) connection_add_impl((conn), 0)
  15. #define connection_add_connecting(conn) connection_add_impl((conn), 1)
  16. int connection_remove(connection_t *conn);
  17. void connection_unregister_events(connection_t *conn);
  18. int connection_in_array(connection_t *conn);
  19. void add_connection_to_closeable_list(connection_t *conn);
  20. int connection_is_on_closeable_list(connection_t *conn);
  21. smartlist_t *get_connection_array(void);
  22. uint64_t get_bytes_read(void);
  23. uint64_t get_bytes_written(void);
  24. /** Bitmask for events that we can turn on and off with
  25. * connection_watch_events. */
  26. typedef enum watchable_events {
  27. /* Yes, it is intentional that these match Libevent's EV_READ and EV_WRITE */
  28. READ_EVENT=0x02, /**< We want to know when a connection is readable */
  29. WRITE_EVENT=0x04 /**< We want to know when a connection is writable */
  30. } watchable_events_t;
  31. void connection_watch_events(connection_t *conn, watchable_events_t events);
  32. int connection_is_reading(connection_t *conn);
  33. MOCK_DECL(void,connection_stop_reading,(connection_t *conn));
  34. MOCK_DECL(void,connection_start_reading,(connection_t *conn));
  35. int connection_is_writing(connection_t *conn);
  36. MOCK_DECL(void,connection_stop_writing,(connection_t *conn));
  37. MOCK_DECL(void,connection_start_writing,(connection_t *conn));
  38. void connection_stop_reading_from_linked_conn(connection_t *conn);
  39. void directory_all_unreachable(time_t now);
  40. void directory_info_has_arrived(time_t now, int from_cache);
  41. void ip_address_changed(int at_interface);
  42. void dns_servers_relaunch_checks(void);
  43. long get_uptime(void);
  44. unsigned get_signewnym_epoch(void);
  45. void handle_signals(int is_parent);
  46. void process_signal(uintptr_t sig);
  47. int try_locking(const or_options_t *options, int err_if_locked);
  48. int have_lockfile(void);
  49. void release_lockfile(void);
  50. void tor_cleanup(void);
  51. void tor_free_all(int postfork);
  52. int tor_main(int argc, char *argv[]);
  53. int do_main_loop(void);
  54. int tor_init(int argc, char **argv);
  55. #ifdef MAIN_PRIVATE
  56. STATIC void init_connection_lists(void);
  57. STATIC void close_closeable_connections(void);
  58. #endif
  59. #endif