main.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 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. void connection_stop_reading(connection_t *conn);
  34. void connection_start_reading(connection_t *conn);
  35. int connection_is_writing(connection_t *conn);
  36. void connection_stop_writing(connection_t *conn);
  37. 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. #ifdef MAIN_PRIVATE
  54. int do_main_loop(void);
  55. int do_list_fingerprint(void);
  56. void do_hash_password(void);
  57. int tor_init(int argc, char **argv);
  58. #endif
  59. #endif