In routerlist_assert_ok(), check r2 before taking &(r2->cache_info)
[tor.git] / src / or / main.h
bloba3bce3486f5c7b986d39ee29c71bd90779f2f2aa
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 */
7 /**
8 * \file main.h
9 * \brief Header file for main.c.
10 **/
12 #ifndef TOR_MAIN_H
13 #define TOR_MAIN_H
15 extern int can_complete_circuit;
17 int connection_add_impl(connection_t *conn, int is_connecting);
18 #define connection_add(conn) connection_add_impl((conn), 0)
19 #define connection_add_connecting(conn) connection_add_impl((conn), 1)
20 int connection_remove(connection_t *conn);
21 void connection_unregister_events(connection_t *conn);
22 int connection_in_array(connection_t *conn);
23 void add_connection_to_closeable_list(connection_t *conn);
24 int connection_is_on_closeable_list(connection_t *conn);
26 smartlist_t *get_connection_array(void);
27 MOCK_DECL(uint64_t,get_bytes_read,(void));
28 MOCK_DECL(uint64_t,get_bytes_written,(void));
30 /** Bitmask for events that we can turn on and off with
31 * connection_watch_events. */
32 typedef enum watchable_events {
33 /* Yes, it is intentional that these match Libevent's EV_READ and EV_WRITE */
34 READ_EVENT=0x02, /**< We want to know when a connection is readable */
35 WRITE_EVENT=0x04 /**< We want to know when a connection is writable */
36 } watchable_events_t;
37 void connection_watch_events(connection_t *conn, watchable_events_t events);
38 int connection_is_reading(connection_t *conn);
39 MOCK_DECL(void,connection_stop_reading,(connection_t *conn));
40 MOCK_DECL(void,connection_start_reading,(connection_t *conn));
42 int connection_is_writing(connection_t *conn);
43 MOCK_DECL(void,connection_stop_writing,(connection_t *conn));
44 MOCK_DECL(void,connection_start_writing,(connection_t *conn));
46 void connection_stop_reading_from_linked_conn(connection_t *conn);
48 void directory_all_unreachable(time_t now);
49 void directory_info_has_arrived(time_t now, int from_cache);
51 void ip_address_changed(int at_interface);
52 void dns_servers_relaunch_checks(void);
53 void reschedule_descriptor_update_check(void);
55 MOCK_DECL(long,get_uptime,(void));
57 unsigned get_signewnym_epoch(void);
59 void handle_signals(int is_parent);
60 void process_signal(uintptr_t sig);
62 int try_locking(const or_options_t *options, int err_if_locked);
63 int have_lockfile(void);
64 void release_lockfile(void);
66 void tor_cleanup(void);
67 void tor_free_all(int postfork);
69 int tor_main(int argc, char *argv[]);
71 int do_main_loop(void);
72 int tor_init(int argc, char **argv);
74 #ifdef MAIN_PRIVATE
75 STATIC void init_connection_lists(void);
76 STATIC void close_closeable_connections(void);
77 #endif
79 #endif