control.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* Copyright (c) 2001 Matej Pfajfar.
  2. * Copyright (c) 2001-2004, Roger Dingledine.
  3. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  4. * Copyright (c) 2007-2019, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. /**
  7. * \file control.h
  8. * \brief Header file for control.c.
  9. **/
  10. #ifndef TOR_CONTROL_H
  11. #define TOR_CONTROL_H
  12. control_connection_t *TO_CONTROL_CONN(connection_t *);
  13. #define CONTROL_CONN_STATE_MIN_ 1
  14. /** State for a control connection: Authenticated and accepting v1 commands. */
  15. #define CONTROL_CONN_STATE_OPEN 1
  16. /** State for a control connection: Waiting for authentication; speaking
  17. * protocol v1. */
  18. #define CONTROL_CONN_STATE_NEEDAUTH 2
  19. #define CONTROL_CONN_STATE_MAX_ 2
  20. void control_ports_write_to_file(void);
  21. /** Log information about the connection <b>conn</b>, protecting it as with
  22. * CONN_LOG_PROTECT. Example:
  23. *
  24. * LOG_FN_CONN(conn, (LOG_DEBUG, "Socket %d wants to write", conn->s));
  25. **/
  26. #define LOG_FN_CONN(conn, args) \
  27. CONN_LOG_PROTECT(conn, log_fn args)
  28. #define CC_LOCAL_FD_IS_OWNER (1u<<0)
  29. #define CC_LOCAL_FD_IS_AUTHENTICATED (1u<<1)
  30. int control_connection_add_local_fd(tor_socket_t sock, unsigned flags);
  31. int connection_control_finished_flushing(control_connection_t *conn);
  32. int connection_control_reached_eof(control_connection_t *conn);
  33. void connection_control_closed(control_connection_t *conn);
  34. int connection_control_process_inbuf(control_connection_t *conn);
  35. void disable_control_logging(void);
  36. void enable_control_logging(void);
  37. void monitor_owning_controller_process(const char *process_spec);
  38. const char *rend_auth_type_to_string(rend_auth_type_t auth_type);
  39. void control_free_all(void);
  40. #ifdef CONTROL_MODULE_PRIVATE
  41. struct signal_name_t {
  42. int sig;
  43. const char *signal_name;
  44. };
  45. extern const struct signal_name_t signal_table[];
  46. int get_cached_network_liveness(void);
  47. void set_cached_network_liveness(int liveness);
  48. #endif /* defined(CONTROL_MODULE_PRIVATE) */
  49. #ifdef CONTROL_PRIVATE
  50. STATIC char *control_split_incoming_command(char *incoming_cmd,
  51. size_t *data_len,
  52. char **current_cmd_out);
  53. #endif
  54. #endif /* !defined(TOR_CONTROL_H) */