main.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 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. typedef enum watchable_events {
  25. /* Yes, it is intentional that these match Libevent's EV_READ and EV_WRITE */
  26. READ_EVENT=0x02,
  27. WRITE_EVENT=0x04
  28. } watchable_events_t;
  29. void connection_watch_events(connection_t *conn, watchable_events_t events);
  30. int connection_is_reading(connection_t *conn);
  31. void connection_stop_reading(connection_t *conn);
  32. void connection_start_reading(connection_t *conn);
  33. int connection_is_writing(connection_t *conn);
  34. void connection_stop_writing(connection_t *conn);
  35. void connection_start_writing(connection_t *conn);
  36. void connection_stop_reading_from_linked_conn(connection_t *conn);
  37. void directory_all_unreachable(time_t now);
  38. void directory_info_has_arrived(time_t now, int from_cache);
  39. void ip_address_changed(int at_interface);
  40. void dns_servers_relaunch_checks(void);
  41. long get_uptime(void);
  42. void get_traffic_stats(uint64_t *in, uint64_t *out);
  43. void control_signal_act(int the_signal);
  44. void handle_signals(int is_parent);
  45. int try_locking(or_options_t *options, int err_if_locked);
  46. int have_lockfile(void);
  47. void release_lockfile(void);
  48. void tor_cleanup(void);
  49. void tor_free_all(int postfork);
  50. int tor_main(int argc, char *argv[]);
  51. #ifdef MAIN_PRIVATE
  52. int do_main_loop(void);
  53. int do_list_fingerprint(void);
  54. void do_hash_password(void);
  55. int tor_init(int argc, char **argv);
  56. #endif
  57. #endif