control.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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-2013, 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. void control_update_global_event_mask(void);
  13. void control_adjust_event_log_severity(void);
  14. void control_ports_write_to_file(void);
  15. /** Log information about the connection <b>conn</b>, protecting it as with
  16. * CONN_LOG_PROTECT. Example:
  17. *
  18. * LOG_FN_CONN(conn, (LOG_DEBUG, "Socket %d wants to write", conn->s));
  19. **/
  20. #define LOG_FN_CONN(conn, args) \
  21. CONN_LOG_PROTECT(conn, log_fn args)
  22. int connection_control_finished_flushing(control_connection_t *conn);
  23. int connection_control_reached_eof(control_connection_t *conn);
  24. void connection_control_closed(control_connection_t *conn);
  25. int connection_control_process_inbuf(control_connection_t *conn);
  26. #define EVENT_AUTHDIR_NEWDESCS 0x000D
  27. #define EVENT_NS 0x000F
  28. int control_event_is_interesting(int event);
  29. int control_event_circuit_status(origin_circuit_t *circ,
  30. circuit_status_event_t e, int reason);
  31. int control_event_circuit_purpose_changed(origin_circuit_t *circ,
  32. int old_purpose);
  33. int control_event_circuit_cannibalized(origin_circuit_t *circ,
  34. int old_purpose,
  35. const struct timeval *old_tv_created);
  36. int control_event_stream_status(entry_connection_t *conn,
  37. stream_status_event_t e,
  38. int reason);
  39. int control_event_or_conn_status(or_connection_t *conn,
  40. or_conn_status_event_t e, int reason);
  41. int control_event_bandwidth_used(uint32_t n_read, uint32_t n_written);
  42. int control_event_stream_bandwidth(edge_connection_t *edge_conn);
  43. int control_event_stream_bandwidth_used(void);
  44. int control_event_circ_bandwidth_used(void);
  45. int control_event_conn_bandwidth(connection_t *conn);
  46. int control_event_conn_bandwidth_used(void);
  47. int control_event_circuit_cell_stats(void);
  48. int control_event_tb_empty(const char *bucket, uint32_t read_empty_time,
  49. uint32_t write_empty_time,
  50. int milliseconds_elapsed);
  51. void control_event_logmsg(int severity, uint32_t domain, const char *msg);
  52. int control_event_descriptors_changed(smartlist_t *routers);
  53. int control_event_address_mapped(const char *from, const char *to,
  54. time_t expires, const char *error,
  55. const int cached);
  56. int control_event_or_authdir_new_descriptor(const char *action,
  57. const char *desc,
  58. size_t desclen,
  59. const char *msg);
  60. int control_event_my_descriptor_changed(void);
  61. int control_event_networkstatus_changed(smartlist_t *statuses);
  62. int control_event_newconsensus(const networkstatus_t *consensus);
  63. int control_event_networkstatus_changed_single(const routerstatus_t *rs);
  64. int control_event_general_status(int severity, const char *format, ...)
  65. CHECK_PRINTF(2,3);
  66. int control_event_client_status(int severity, const char *format, ...)
  67. CHECK_PRINTF(2,3);
  68. int control_event_server_status(int severity, const char *format, ...)
  69. CHECK_PRINTF(2,3);
  70. int control_event_guard(const char *nickname, const char *digest,
  71. const char *status);
  72. int control_event_conf_changed(const smartlist_t *elements);
  73. int control_event_buildtimeout_set(const circuit_build_times_t *cbt,
  74. buildtimeout_set_event_t type);
  75. int control_event_signal(uintptr_t signal);
  76. int init_cookie_authentication(int enabled);
  77. smartlist_t *decode_hashed_passwords(config_line_t *passwords);
  78. void disable_control_logging(void);
  79. void enable_control_logging(void);
  80. void monitor_owning_controller_process(const char *process_spec);
  81. void control_event_bootstrap(bootstrap_status_t status, int progress);
  82. void control_event_bootstrap_problem(const char *warn, int reason);
  83. void control_event_clients_seen(const char *controller_str);
  84. #ifdef CONTROL_PRIVATE
  85. /* Used only by control.c and test*.c */
  86. size_t write_escaped_data(const char *data, size_t len, char **out);
  87. size_t read_escaped_data(const char *data, size_t len, char **out);
  88. /** Helper structure: temporarily stores cell statistics for a circuit. */
  89. typedef struct cell_stats_t {
  90. /** Number of cells added in app-ward direction by command. */
  91. uint64_t added_cells_appward[CELL_COMMAND_MAX_ + 1];
  92. /** Number of cells added in exit-ward direction by command. */
  93. uint64_t added_cells_exitward[CELL_COMMAND_MAX_ + 1];
  94. /** Number of cells removed in app-ward direction by command. */
  95. uint64_t removed_cells_appward[CELL_COMMAND_MAX_ + 1];
  96. /** Number of cells removed in exit-ward direction by command. */
  97. uint64_t removed_cells_exitward[CELL_COMMAND_MAX_ + 1];
  98. /** Total waiting time of cells in app-ward direction by command. */
  99. uint64_t total_time_appward[CELL_COMMAND_MAX_ + 1];
  100. /** Total waiting time of cells in exit-ward direction by command. */
  101. uint64_t total_time_exitward[CELL_COMMAND_MAX_ + 1];
  102. } cell_stats_t;
  103. void sum_up_cell_stats_by_command(circuit_t *circ,
  104. cell_stats_t *cell_stats);
  105. void append_cell_stats_by_command(smartlist_t *event_parts,
  106. const char *key,
  107. uint64_t *include_if_non_zero,
  108. uint64_t *number_to_include);
  109. void format_cell_stats(char **event_string, circuit_t *circ,
  110. cell_stats_t *cell_stats);
  111. #endif
  112. #endif