transports.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 */
  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, /* broke during the protocol */
  31. PT_PROTO_FAILED_LAUNCH /* failed while launching */
  32. };
  33. /** Structure containing information of a managed proxy. */
  34. typedef struct {
  35. enum pt_proto_state conf_state; /* the current configuration state */
  36. char **argv; /* the cli arguments of this proxy */
  37. int conf_protocol; /* the configuration protocol version used */
  38. int is_server; /* is it a server proxy? */
  39. /* A pointer to the process handle of this managed proxy. */
  40. process_handle_t *process_handle;
  41. int pid; /* The Process ID this managed proxy is using. */
  42. /** Boolean: We are re-parsing our config, and we are going to
  43. * remove this managed proxy if we don't find it any transport
  44. * plugins that use it. */
  45. unsigned int marked_for_removal : 1;
  46. /** Boolean: We got a SIGHUP while this proxy was running. We use
  47. * this flag to signify that this proxy might need to be restarted
  48. * so that it can listen for other transports according to the new
  49. * torrc. */
  50. unsigned int got_hup : 1;
  51. /* transports to-be-launched by this proxy */
  52. smartlist_t *transports_to_launch;
  53. /* The 'transports' list contains all the transports this proxy has
  54. launched.
  55. Before a managed_proxy_t reaches the PT_PROTO_COMPLETED phase,
  56. this smartlist contains a 'transport_t' for every transport it
  57. has launched.
  58. When the managed_proxy_t reaches the PT_PROTO_COMPLETED phase, it
  59. registers all its transports to the circuitbuild.c subsystem. At
  60. that point the 'transport_t's are owned by the circuitbuild.c
  61. subsystem.
  62. To avoid carrying dangling 'transport_t's in this smartlist,
  63. right before the managed_proxy_t reaches the PT_PROTO_COMPLETED
  64. phase we replace all 'transport_t's with strings of their
  65. transport names.
  66. So, tl;dr:
  67. When (conf_state != PT_PROTO_COMPLETED) this list carries
  68. (transport_t *).
  69. When (conf_state == PT_PROTO_COMPLETED) this list carries
  70. (char *).
  71. */
  72. smartlist_t *transports;
  73. } managed_proxy_t;
  74. int parse_cmethod_line(const char *line, managed_proxy_t *mp);
  75. int parse_smethod_line(const char *line, managed_proxy_t *mp);
  76. int parse_version(const char *line, managed_proxy_t *mp);
  77. void parse_env_error(const char *line);
  78. void handle_proxy_line(const char *line, managed_proxy_t *mp);
  79. #endif
  80. #endif