Back to index

tor  0.2.3.19-rc
transports.h
Go to the documentation of this file.
00001 /* Copyright (c) 2003-2004, Roger Dingledine
00002  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
00003  * Copyright (c) 2007-2012, The Tor Project, Inc. */
00004 /* See LICENSE for licensing information */
00005 
00011 #ifndef TOR_TRANSPORTS_H
00012 #define TOR_TRANSPORTS_H
00013 
00014 void pt_kickstart_proxy(const smartlist_t *transport_list, char **proxy_argv,
00015                         int is_server);
00016 
00017 #define pt_kickstart_client_proxy(tl, pa)  \
00018   pt_kickstart_proxy(tl, pa, 0)
00019 #define pt_kickstart_server_proxy(tl, pa) \
00020   pt_kickstart_proxy(tl, pa, 1)
00021 
00022 void pt_configure_remaining_proxies(void);
00023 
00024 int pt_proxies_configuration_pending(void);
00025 
00026 void pt_free_all(void);
00027 
00028 void pt_prepare_proxy_list_for_config_read(void);
00029 void sweep_proxy_list(void);
00030 
00031 #ifdef PT_PRIVATE
00032 
00033 enum pt_proto_state {
00034   PT_PROTO_INFANT, /* was just born */
00035   PT_PROTO_LAUNCHED, /* was just launched */
00036   PT_PROTO_ACCEPTING_METHODS, /* accepting methods */
00037   PT_PROTO_CONFIGURED, /* configured successfully */
00038   PT_PROTO_COMPLETED, /* configure and registered its transports */
00039   PT_PROTO_BROKEN, /* broke during the protocol */
00040   PT_PROTO_FAILED_LAUNCH /* failed while launching */
00041 };
00042 
00044 typedef struct {
00045   enum pt_proto_state conf_state; /* the current configuration state */
00046   char **argv; /* the cli arguments of this proxy */
00047   int conf_protocol; /* the configuration protocol version used */
00048 
00049   int is_server; /* is it a server proxy? */
00050 
00051   /* A pointer to the process handle of this managed proxy. */
00052   process_handle_t *process_handle;
00053 
00054   int pid; /* The Process ID this managed proxy is using. */
00055 
00059   unsigned int marked_for_removal : 1;
00060 
00065   unsigned int got_hup : 1;
00066 
00067   /* transports to-be-launched by this proxy */
00068   smartlist_t *transports_to_launch;
00069 
00070   /* The 'transports' list contains all the transports this proxy has
00071      launched.
00072 
00073      Before a managed_proxy_t reaches the PT_PROTO_COMPLETED phase,
00074      this smartlist contains a 'transport_t' for every transport it
00075      has launched.
00076 
00077      When the managed_proxy_t reaches the PT_PROTO_COMPLETED phase, it
00078      registers all its transports to the circuitbuild.c subsystem. At
00079      that point the 'transport_t's are owned by the circuitbuild.c
00080      subsystem.
00081 
00082      To avoid carrying dangling 'transport_t's in this smartlist,
00083      right before the managed_proxy_t reaches the PT_PROTO_COMPLETED
00084      phase we replace all 'transport_t's with strings of their
00085      transport names.
00086 
00087      So, tl;dr:
00088      When (conf_state != PT_PROTO_COMPLETED) this list carries
00089      (transport_t *).
00090      When (conf_state == PT_PROTO_COMPLETED) this list carries
00091      (char *).
00092    */
00093   smartlist_t *transports;
00094 } managed_proxy_t;
00095 
00096 int parse_cmethod_line(const char *line, managed_proxy_t *mp);
00097 int parse_smethod_line(const char *line, managed_proxy_t *mp);
00098 
00099 int parse_version(const char *line, managed_proxy_t *mp);
00100 void parse_env_error(const char *line);
00101 void handle_proxy_line(const char *line, managed_proxy_t *mp);
00102 
00103 #endif
00104 
00105 #endif
00106