transports.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /* Copyright (c) 2003-2004, Roger Dingledine
  2. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  3. * Copyright (c) 2007-2011, The Tor Project, Inc. */
  4. /* See LICENSE for licensing information */
  5. /**
  6. * \file transports.h
  7. * \brief Headers for transports.c
  8. **/
  9. #ifndef TOR_TRANSPORTS_H
  10. #define TOR_TRANSPORTS_H
  11. void pt_kickstart_proxy(const smartlist_t *transport_list, char **proxy_argv,
  12. int is_server);
  13. #define pt_kickstart_client_proxy(tl, pa) \
  14. pt_kickstart_proxy(tl, pa, 0)
  15. #define pt_kickstart_server_proxy(tl, pa) \
  16. pt_kickstart_proxy(tl, pa, 1)
  17. void pt_configure_remaining_proxies(void);
  18. int pt_proxies_configuration_pending(void);
  19. void pt_free_all(void);
  20. void pt_prepare_proxy_list_for_config_read(void);
  21. void sweep_proxy_list(void);
  22. #ifdef PT_PRIVATE
  23. /** State of the managed proxy configuration protocol. */
  24. enum pt_proto_state {
  25. PT_PROTO_INFANT, /* was just born */
  26. PT_PROTO_LAUNCHED, /* was just launched */
  27. PT_PROTO_ACCEPTING_METHODS, /* accepting methods */
  28. PT_PROTO_CONFIGURED, /* configured successfully */
  29. PT_PROTO_COMPLETED, /* configure and registered its transports */
  30. PT_PROTO_BROKEN
  31. };
  32. /** Structure containing information of a managed proxy. */
  33. typedef struct {
  34. enum pt_proto_state conf_state; /* the current configuration state */
  35. char **argv; /* the cli arguments of this proxy */
  36. int conf_protocol; /* the configuration protocol version used */
  37. int is_server; /* is it a server proxy? */
  38. FILE *stdout; /* a stream to its stdout
  39. (closed in managed_proxy_destroy()) */
  40. int pid; /* The Process ID this managed proxy is using. */
  41. /** Boolean: We are re-parsing our config, and we are going to
  42. * remove this managed proxy if we don't find it any transport
  43. * plugins that use it. */
  44. unsigned int marked_for_removal : 1;
  45. /** Boolean: We got a SIGHUP while this proxy was running. We use
  46. * this flag to signify that this proxy might need to be restarted
  47. * so that it can listen for other transports according to the new
  48. * torrc. */
  49. unsigned int got_hup : 1;
  50. /* transports to-be-launched by this proxy */
  51. smartlist_t *transports_to_launch;
  52. /* The 'transports' list contains all the transports this proxy has
  53. launched.
  54. Before a managed_proxy_t reaches the PT_PROTO_COMPLETED phase,
  55. this smartlist contains a 'transport_t' for every transport it
  56. has launched.
  57. When the managed_proxy_t reaches the PT_PROTO_COMPLETED phase, it
  58. registers all its transports to the circuitbuild.c subsystem. At
  59. that point the 'transport_t's are owned by the circuitbuild.c
  60. subsystem.
  61. To avoid carrying dangling 'transport_t's in this smartlist,
  62. right before the managed_proxy_t reaches the PT_PROTO_COMPLETED
  63. phase we replace all 'transport_t's with strings of their
  64. transport names.
  65. So, tl;dr:
  66. When (conf_state != PT_PROTO_COMPLETED) this list carries
  67. (transport_t *).
  68. When (conf_state == PT_PROTO_COMPLETED) this list carries
  69. (char *).
  70. */
  71. smartlist_t *transports;
  72. } managed_proxy_t;
  73. int parse_cmethod_line(const char *line, managed_proxy_t *mp);
  74. int parse_smethod_line(const char *line, managed_proxy_t *mp);
  75. int parse_version(const char *line, managed_proxy_t *mp);
  76. void parse_env_error(const char *line);
  77. void handle_proxy_line(const char *line, managed_proxy_t *mp);
  78. #endif
  79. #endif