2010-07-23 22:57:20 +02:00
|
|
|
/* Copyright (c) 2001 Matej Pfajfar.
|
|
|
|
* Copyright (c) 2001-2004, Roger Dingledine.
|
|
|
|
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
2017-03-15 21:13:17 +01:00
|
|
|
* Copyright (c) 2007-2017, The Tor Project, Inc. */
|
2010-07-23 22:57:20 +02:00
|
|
|
/* See LICENSE for licensing information */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \file rephist.h
|
2010-07-28 17:42:33 +02:00
|
|
|
* \brief Header file for rephist.c.
|
2010-07-23 22:57:20 +02:00
|
|
|
**/
|
|
|
|
|
2012-10-12 18:13:10 +02:00
|
|
|
#ifndef TOR_REPHIST_H
|
|
|
|
#define TOR_REPHIST_H
|
2010-07-23 22:57:20 +02:00
|
|
|
|
|
|
|
void rep_hist_init(void);
|
|
|
|
void rep_hist_note_connect_failed(const char* nickname, time_t when);
|
|
|
|
void rep_hist_note_connect_succeeded(const char* nickname, time_t when);
|
|
|
|
void rep_hist_note_disconnect(const char* nickname, time_t when);
|
|
|
|
void rep_hist_note_connection_died(const char* nickname, time_t when);
|
|
|
|
void rep_hist_note_extend_succeeded(const char *from_name,
|
|
|
|
const char *to_name);
|
|
|
|
void rep_hist_note_extend_failed(const char *from_name, const char *to_name);
|
|
|
|
void rep_hist_dump_stats(time_t now, int severity);
|
|
|
|
void rep_hist_note_bytes_read(size_t num_bytes, time_t when);
|
|
|
|
void rep_hist_note_bytes_written(size_t num_bytes, time_t when);
|
2010-08-18 16:06:14 +02:00
|
|
|
|
2013-02-04 17:11:54 +01:00
|
|
|
void rep_hist_make_router_pessimal(const char *id, time_t when);
|
|
|
|
|
2010-07-07 14:55:42 +02:00
|
|
|
void rep_hist_note_dir_bytes_read(size_t num_bytes, time_t when);
|
|
|
|
void rep_hist_note_dir_bytes_written(size_t num_bytes, time_t when);
|
2010-08-18 16:06:14 +02:00
|
|
|
|
2010-07-23 22:57:20 +02:00
|
|
|
int rep_hist_bandwidth_assess(void);
|
2010-11-13 22:25:19 +01:00
|
|
|
char *rep_hist_get_bandwidth_lines(void);
|
2010-07-23 22:57:20 +02:00
|
|
|
void rep_hist_update_state(or_state_t *state);
|
|
|
|
int rep_hist_load_state(or_state_t *state, char **err);
|
|
|
|
void rep_history_clean(time_t before);
|
|
|
|
|
2010-11-22 18:30:33 +01:00
|
|
|
void rep_hist_note_router_reachable(const char *id, const tor_addr_t *at_addr,
|
2012-05-14 19:05:00 +02:00
|
|
|
const uint16_t at_port, time_t when);
|
2010-07-23 22:57:20 +02:00
|
|
|
void rep_hist_note_router_unreachable(const char *id, time_t when);
|
|
|
|
int rep_hist_record_mtbf_data(time_t now, int missing_means_down);
|
|
|
|
int rep_hist_load_mtbf_data(time_t now);
|
|
|
|
|
|
|
|
time_t rep_hist_downrate_old_runs(time_t now);
|
2011-03-09 11:34:04 +01:00
|
|
|
long rep_hist_get_uptime(const char *id, time_t when);
|
2010-07-23 22:57:20 +02:00
|
|
|
double rep_hist_get_stability(const char *id, time_t when);
|
|
|
|
double rep_hist_get_weighted_fractional_uptime(const char *id, time_t when);
|
|
|
|
long rep_hist_get_weighted_time_known(const char *id, time_t when);
|
|
|
|
int rep_hist_have_measured_enough_stability(void);
|
|
|
|
|
2017-02-22 03:28:00 +01:00
|
|
|
void predicted_ports_init(void);
|
2010-07-23 22:57:20 +02:00
|
|
|
void rep_hist_note_used_port(time_t now, uint16_t port);
|
|
|
|
smartlist_t *rep_hist_get_predicted_ports(time_t now);
|
2012-05-11 18:52:21 +02:00
|
|
|
void rep_hist_remove_predicted_ports(const smartlist_t *rmv_ports);
|
2010-07-23 22:57:20 +02:00
|
|
|
void rep_hist_note_used_resolve(time_t now);
|
|
|
|
void rep_hist_note_used_internal(time_t now, int need_uptime,
|
|
|
|
int need_capacity);
|
|
|
|
int rep_hist_get_predicted_internal(time_t now, int *need_uptime,
|
|
|
|
int *need_capacity);
|
|
|
|
|
|
|
|
int any_predicted_circuits(time_t now);
|
|
|
|
int rep_hist_circbuilding_dormant(time_t now);
|
2017-02-22 03:28:00 +01:00
|
|
|
int predicted_ports_prediction_time_remaining(time_t now);
|
2010-07-23 22:57:20 +02:00
|
|
|
|
|
|
|
void note_crypto_pk_op(pk_op_t operation);
|
|
|
|
void dump_pk_ops(int severity);
|
|
|
|
|
2010-08-11 14:13:08 +02:00
|
|
|
void rep_hist_exit_stats_init(time_t now);
|
|
|
|
void rep_hist_reset_exit_stats(time_t now);
|
|
|
|
void rep_hist_exit_stats_term(void);
|
2010-08-15 14:15:58 +02:00
|
|
|
char *rep_hist_format_exit_stats(time_t now);
|
2010-08-11 14:13:08 +02:00
|
|
|
time_t rep_hist_exit_stats_write(time_t now);
|
|
|
|
void rep_hist_note_exit_bytes(uint16_t port, size_t num_written,
|
|
|
|
size_t num_read);
|
|
|
|
void rep_hist_note_exit_stream_opened(uint16_t port);
|
|
|
|
|
2010-07-23 22:57:20 +02:00
|
|
|
void rep_hist_buffer_stats_init(time_t now);
|
|
|
|
void rep_hist_buffer_stats_add_circ(circuit_t *circ,
|
|
|
|
time_t end_of_interval);
|
2010-06-21 18:52:46 +02:00
|
|
|
time_t rep_hist_buffer_stats_write(time_t now);
|
|
|
|
void rep_hist_buffer_stats_term(void);
|
2011-08-03 13:29:03 +02:00
|
|
|
void rep_hist_add_buffer_stats(double mean_num_cells_in_queue,
|
|
|
|
double mean_time_cells_in_queue, uint32_t processed_cells);
|
2011-08-03 13:26:49 +02:00
|
|
|
char *rep_hist_format_buffer_stats(time_t now);
|
|
|
|
void rep_hist_reset_buffer_stats(time_t now);
|
2010-07-23 22:57:20 +02:00
|
|
|
|
2011-10-07 02:39:48 +02:00
|
|
|
void rep_hist_desc_stats_init(time_t now);
|
|
|
|
void rep_hist_note_desc_served(const char * desc);
|
|
|
|
void rep_hist_desc_stats_term(void);
|
|
|
|
time_t rep_hist_desc_stats_write(time_t now);
|
|
|
|
|
2010-08-02 15:06:14 +02:00
|
|
|
void rep_hist_conn_stats_init(time_t now);
|
|
|
|
void rep_hist_note_or_conn_bytes(uint64_t conn_id, size_t num_read,
|
|
|
|
size_t num_written, time_t when);
|
2010-08-18 15:44:02 +02:00
|
|
|
void rep_hist_reset_conn_stats(time_t now);
|
|
|
|
char *rep_hist_format_conn_stats(time_t now);
|
2010-08-02 15:06:14 +02:00
|
|
|
time_t rep_hist_conn_stats_write(time_t now);
|
|
|
|
void rep_hist_conn_stats_term(void);
|
|
|
|
|
2013-09-04 23:43:15 +02:00
|
|
|
void rep_hist_note_circuit_handshake_requested(uint16_t type);
|
2014-03-28 03:57:53 +01:00
|
|
|
void rep_hist_note_circuit_handshake_assigned(uint16_t type);
|
2013-09-04 23:43:15 +02:00
|
|
|
void rep_hist_log_circuit_handshake_stats(time_t now);
|
|
|
|
|
2014-12-02 13:20:35 +01:00
|
|
|
void rep_hist_hs_stats_init(time_t now);
|
|
|
|
void rep_hist_hs_stats_term(void);
|
|
|
|
time_t rep_hist_hs_stats_write(time_t now);
|
|
|
|
char *rep_hist_get_hs_stats_string(void);
|
|
|
|
void rep_hist_seen_new_rp_cell(void);
|
|
|
|
void rep_hist_stored_maybe_new_hs(const crypto_pk_t *pubkey);
|
|
|
|
|
2013-09-04 23:43:15 +02:00
|
|
|
void rep_hist_free_all(void);
|
|
|
|
|
2015-03-10 15:07:41 +01:00
|
|
|
void rep_hist_note_negotiated_link_proto(unsigned link_proto,
|
|
|
|
int started_here);
|
|
|
|
void rep_hist_log_link_protocol_counts(void);
|
|
|
|
|
2016-06-02 15:46:12 +02:00
|
|
|
extern uint64_t rephist_total_alloc;
|
|
|
|
extern uint32_t rephist_total_num;
|
|
|
|
#ifdef TOR_UNIT_TESTS
|
|
|
|
extern int onion_handshakes_requested[MAX_ONION_HANDSHAKE_TYPE+1];
|
|
|
|
extern int onion_handshakes_assigned[MAX_ONION_HANDSHAKE_TYPE+1];
|
|
|
|
#endif
|
|
|
|
|
2016-09-06 20:35:53 +02:00
|
|
|
/**
|
|
|
|
* Represents the type of a cell for padding accounting
|
|
|
|
*/
|
|
|
|
typedef enum padding_type_t {
|
|
|
|
/** A RELAY_DROP cell */
|
|
|
|
PADDING_TYPE_DROP,
|
|
|
|
/** A CELL_PADDING cell */
|
|
|
|
PADDING_TYPE_CELL,
|
|
|
|
/** Total counts of padding and non-padding together */
|
|
|
|
PADDING_TYPE_TOTAL,
|
|
|
|
/** Total cell counts for all padding-enabled channels */
|
|
|
|
PADDING_TYPE_ENABLED_TOTAL,
|
|
|
|
/** CELL_PADDING counts for all padding-enabled channels */
|
|
|
|
PADDING_TYPE_ENABLED_CELL
|
|
|
|
} padding_type_t;
|
|
|
|
|
|
|
|
/** The amount of time over which the padding cell counts were counted */
|
|
|
|
#define REPHIST_CELL_PADDING_COUNTS_INTERVAL (24*60*60)
|
|
|
|
void rep_hist_padding_count_read(padding_type_t type);
|
|
|
|
void rep_hist_padding_count_write(padding_type_t type);
|
|
|
|
char *rep_hist_get_padding_count_lines(void);
|
|
|
|
void rep_hist_reset_padding_counts(void);
|
|
|
|
void rep_hist_prep_published_padding_counts(time_t now);
|
|
|
|
void rep_hist_padding_count_timers(uint64_t num_timers);
|
|
|
|
|
2010-07-23 22:57:20 +02:00
|
|
|
#endif
|
|
|
|
|