Bug 6572: Use timestamp_created for liveness sanity checks.
[tor.git] / src / or / transports.h
blob6ee82f4556919cbbc5038c0a99ddc7dc92389070
1 /* Copyright (c) 2003-2004, Roger Dingledine
2 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
3 * Copyright (c) 2007-2013, The Tor Project, Inc. */
4 /* See LICENSE for licensing information */
6 /**
7 * \file transports.h
8 * \brief Headers for transports.c
9 **/
11 #ifndef TOR_TRANSPORTS_H
12 #define TOR_TRANSPORTS_H
14 /** Represents a pluggable transport used by a bridge. */
15 typedef struct transport_t {
16 /** SOCKS version: One of PROXY_SOCKS4, PROXY_SOCKS5. */
17 int socks_version;
18 /** Name of pluggable transport protocol */
19 char *name;
20 /** The IP address where the transport bound and is waiting for
21 * connections. */
22 tor_addr_t addr;
23 /** Port of proxy */
24 uint16_t port;
25 /** Boolean: We are re-parsing our transport list, and we are going to remove
26 * this one if we don't find it in the list of configured transports. */
27 unsigned marked_for_removal : 1;
28 } transport_t;
30 void mark_transport_list(void);
31 void sweep_transport_list(void);
32 int transport_add_from_config(const tor_addr_t *addr, uint16_t port,
33 const char *name, int socks_ver);
34 void transport_free(transport_t *transport);
36 transport_t *transport_get_by_name(const char *name);
38 void pt_kickstart_proxy(const smartlist_t *transport_list, char **proxy_argv,
39 int is_server);
41 #define pt_kickstart_client_proxy(tl, pa) \
42 pt_kickstart_proxy(tl, pa, 0)
43 #define pt_kickstart_server_proxy(tl, pa) \
44 pt_kickstart_proxy(tl, pa, 1)
46 void pt_configure_remaining_proxies(void);
48 int pt_proxies_configuration_pending(void);
50 char *pt_get_extra_info_descriptor_string(void);
52 void pt_free_all(void);
54 void pt_prepare_proxy_list_for_config_read(void);
55 void sweep_proxy_list(void);
57 smartlist_t *get_transport_proxy_ports(void);
59 #ifdef PT_PRIVATE
60 /** State of the managed proxy configuration protocol. */
61 enum pt_proto_state {
62 PT_PROTO_INFANT, /* was just born */
63 PT_PROTO_LAUNCHED, /* was just launched */
64 PT_PROTO_ACCEPTING_METHODS, /* accepting methods */
65 PT_PROTO_CONFIGURED, /* configured successfully */
66 PT_PROTO_COMPLETED, /* configure and registered its transports */
67 PT_PROTO_BROKEN, /* broke during the protocol */
68 PT_PROTO_FAILED_LAUNCH /* failed while launching */
71 /** Structure containing information of a managed proxy. */
72 typedef struct {
73 enum pt_proto_state conf_state; /* the current configuration state */
74 char **argv; /* the cli arguments of this proxy */
75 int conf_protocol; /* the configuration protocol version used */
77 int is_server; /* is it a server proxy? */
79 /* A pointer to the process handle of this managed proxy. */
80 process_handle_t *process_handle;
82 int pid; /* The Process ID this managed proxy is using. */
84 /** Boolean: We are re-parsing our config, and we are going to
85 * remove this managed proxy if we don't find it any transport
86 * plugins that use it. */
87 unsigned int marked_for_removal : 1;
89 /** Boolean: We got a SIGHUP while this proxy was running. We use
90 * this flag to signify that this proxy might need to be restarted
91 * so that it can listen for other transports according to the new
92 * torrc. */
93 unsigned int got_hup : 1;
95 /* transports to-be-launched by this proxy */
96 smartlist_t *transports_to_launch;
98 /* The 'transports' list contains all the transports this proxy has
99 launched. */
100 smartlist_t *transports;
101 } managed_proxy_t;
103 int parse_cmethod_line(const char *line, managed_proxy_t *mp);
104 int parse_smethod_line(const char *line, managed_proxy_t *mp);
106 int parse_version(const char *line, managed_proxy_t *mp);
107 void parse_env_error(const char *line);
108 void handle_proxy_line(const char *line, managed_proxy_t *mp);
110 #endif
112 #endif