2010-07-23 19:58:06 +02:00
|
|
|
/* Copyright (c) 2001 Matej Pfajfar.
|
|
|
|
* Copyright (c) 2001-2004, Roger Dingledine.
|
|
|
|
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
2015-01-02 20:27:39 +01:00
|
|
|
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
2010-07-23 19:58:06 +02:00
|
|
|
/* See LICENSE for licensing information */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \file main.h
|
|
|
|
* \brief Header file for main.c.
|
|
|
|
**/
|
|
|
|
|
2012-10-12 18:13:10 +02:00
|
|
|
#ifndef TOR_MAIN_H
|
|
|
|
#define TOR_MAIN_H
|
2010-07-23 19:58:06 +02:00
|
|
|
|
2014-11-20 18:03:46 +01:00
|
|
|
int have_completed_a_circuit(void);
|
|
|
|
void note_that_we_completed_a_circuit(void);
|
|
|
|
void note_that_we_maybe_cant_complete_circuits(void);
|
2010-07-23 19:58:06 +02:00
|
|
|
|
2009-08-11 21:03:43 +02:00
|
|
|
int connection_add_impl(connection_t *conn, int is_connecting);
|
|
|
|
#define connection_add(conn) connection_add_impl((conn), 0)
|
|
|
|
#define connection_add_connecting(conn) connection_add_impl((conn), 1)
|
2010-07-23 19:58:06 +02:00
|
|
|
int connection_remove(connection_t *conn);
|
|
|
|
void connection_unregister_events(connection_t *conn);
|
|
|
|
int connection_in_array(connection_t *conn);
|
|
|
|
void add_connection_to_closeable_list(connection_t *conn);
|
|
|
|
int connection_is_on_closeable_list(connection_t *conn);
|
|
|
|
|
|
|
|
smartlist_t *get_connection_array(void);
|
2014-04-15 14:20:34 +02:00
|
|
|
MOCK_DECL(uint64_t,get_bytes_read,(void));
|
|
|
|
MOCK_DECL(uint64_t,get_bytes_written,(void));
|
2010-07-23 19:58:06 +02:00
|
|
|
|
2011-03-16 22:05:37 +01:00
|
|
|
/** Bitmask for events that we can turn on and off with
|
|
|
|
* connection_watch_events. */
|
2010-07-23 19:58:06 +02:00
|
|
|
typedef enum watchable_events {
|
2009-07-31 17:11:45 +02:00
|
|
|
/* Yes, it is intentional that these match Libevent's EV_READ and EV_WRITE */
|
2011-03-16 22:05:37 +01:00
|
|
|
READ_EVENT=0x02, /**< We want to know when a connection is readable */
|
|
|
|
WRITE_EVENT=0x04 /**< We want to know when a connection is writable */
|
2010-07-23 19:58:06 +02:00
|
|
|
} watchable_events_t;
|
|
|
|
void connection_watch_events(connection_t *conn, watchable_events_t events);
|
|
|
|
int connection_is_reading(connection_t *conn);
|
2013-08-01 23:29:10 +02:00
|
|
|
MOCK_DECL(void,connection_stop_reading,(connection_t *conn));
|
|
|
|
MOCK_DECL(void,connection_start_reading,(connection_t *conn));
|
2010-07-23 19:58:06 +02:00
|
|
|
|
|
|
|
int connection_is_writing(connection_t *conn);
|
2013-08-01 23:29:10 +02:00
|
|
|
MOCK_DECL(void,connection_stop_writing,(connection_t *conn));
|
|
|
|
MOCK_DECL(void,connection_start_writing,(connection_t *conn));
|
2010-07-23 19:58:06 +02:00
|
|
|
|
|
|
|
void connection_stop_reading_from_linked_conn(connection_t *conn);
|
|
|
|
|
|
|
|
void directory_all_unreachable(time_t now);
|
|
|
|
void directory_info_has_arrived(time_t now, int from_cache);
|
|
|
|
|
|
|
|
void ip_address_changed(int at_interface);
|
|
|
|
void dns_servers_relaunch_checks(void);
|
2015-02-09 07:05:31 +01:00
|
|
|
void reset_all_main_loop_timers(void);
|
2014-04-01 23:30:20 +02:00
|
|
|
void reschedule_descriptor_update_check(void);
|
2010-07-23 19:58:06 +02:00
|
|
|
|
2014-04-15 14:20:34 +02:00
|
|
|
MOCK_DECL(long,get_uptime,(void));
|
|
|
|
|
2011-07-06 22:39:54 +02:00
|
|
|
unsigned get_signewnym_epoch(void);
|
2010-12-01 02:32:42 +01:00
|
|
|
|
2010-07-23 19:58:06 +02:00
|
|
|
void handle_signals(int is_parent);
|
2011-04-26 21:20:08 +02:00
|
|
|
void process_signal(uintptr_t sig);
|
2010-07-23 19:58:06 +02:00
|
|
|
|
2011-06-14 19:01:38 +02:00
|
|
|
int try_locking(const or_options_t *options, int err_if_locked);
|
2010-07-23 19:58:06 +02:00
|
|
|
int have_lockfile(void);
|
|
|
|
void release_lockfile(void);
|
|
|
|
|
|
|
|
void tor_cleanup(void);
|
|
|
|
void tor_free_all(int postfork);
|
|
|
|
|
|
|
|
int tor_main(int argc, char *argv[]);
|
|
|
|
|
|
|
|
int do_main_loop(void);
|
|
|
|
int tor_init(int argc, char **argv);
|
|
|
|
|
2013-08-01 19:15:58 +02:00
|
|
|
#ifdef MAIN_PRIVATE
|
|
|
|
STATIC void init_connection_lists(void);
|
|
|
|
STATIC void close_closeable_connections(void);
|
|
|
|
#endif
|
|
|
|
|
2010-07-23 19:58:06 +02:00
|
|
|
#endif
|
|
|
|
|