Address Nick's comments.
[tor.git] / src / or / transports.h
blob3fd97f8c2a0a84c4f5365e27b825eb36535aae58
1 /* Copyright (c) 2003-2004, Roger Dingledine
2 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
3 * Copyright (c) 2007-2012, 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 #ifdef PT_PRIVATE
58 /** State of the managed proxy configuration protocol. */
59 enum pt_proto_state {
60 PT_PROTO_INFANT, /* was just born */
61 PT_PROTO_LAUNCHED, /* was just launched */
62 PT_PROTO_ACCEPTING_METHODS, /* accepting methods */
63 PT_PROTO_CONFIGURED, /* configured successfully */
64 PT_PROTO_COMPLETED, /* configure and registered its transports */
65 PT_PROTO_BROKEN, /* broke during the protocol */
66 PT_PROTO_FAILED_LAUNCH /* failed while launching */
69 /** Structure containing information of a managed proxy. */
70 typedef struct {
71 enum pt_proto_state conf_state; /* the current configuration state */
72 char **argv; /* the cli arguments of this proxy */
73 int conf_protocol; /* the configuration protocol version used */
75 int is_server; /* is it a server proxy? */
77 /* A pointer to the process handle of this managed proxy. */
78 process_handle_t *process_handle;
80 int pid; /* The Process ID this managed proxy is using. */
82 /** Boolean: We are re-parsing our config, and we are going to
83 * remove this managed proxy if we don't find it any transport
84 * plugins that use it. */
85 unsigned int marked_for_removal : 1;
87 /** Boolean: We got a SIGHUP while this proxy was running. We use
88 * this flag to signify that this proxy might need to be restarted
89 * so that it can listen for other transports according to the new
90 * torrc. */
91 unsigned int got_hup : 1;
93 /* transports to-be-launched by this proxy */
94 smartlist_t *transports_to_launch;
96 /* The 'transports' list contains all the transports this proxy has
97 launched. */
98 smartlist_t *transports;
99 } managed_proxy_t;
101 int parse_cmethod_line(const char *line, managed_proxy_t *mp);
102 int parse_smethod_line(const char *line, managed_proxy_t *mp);
104 int parse_version(const char *line, managed_proxy_t *mp);
105 void parse_env_error(const char *line);
106 void handle_proxy_line(const char *line, managed_proxy_t *mp);
108 #endif
110 #endif