37 #define BIDI_THRESHOLD 20480
42 #define BIDI_FACTOR 10
46 #define BIDI_INTERVAL 10
95 return a->conn_id == b->conn_id;
102 return (
unsigned) entry->conn_id;
115 for (ptr = HT_START(bidimap, &bidi_map); ptr; ptr = next) {
117 next = HT_NEXT_RMV(bidimap, &bidi_map, ptr);
120 HT_CLEAR(bidimap, &bidi_map);
166 for (ptr = HT_START(bidimap, &bidi_map); ptr; ptr = next) {
171 next = HT_NEXT_RMV(bidimap, &bidi_map, ptr);
174 log_info(
LD_GENERAL,
"%d below threshold, %d mostly read, "
175 "%d mostly written, %d both read and written.",
186 size_t num_written, time_t when,
201 if (num_read > 0 || num_written > 0) {
203 lookup.conn_id = conn_id;
204 entry = HT_FIND(bidimap, &bidi_map, &lookup);
206 entry->written += num_written;
207 entry->read += num_read;
208 entry->is_ipv6 |= is_ipv6;
211 entry->conn_id = conn_id;
212 entry->written = num_written;
213 entry->read = num_read;
214 entry->is_ipv6 = is_ipv6;
215 HT_INSERT(bidimap, &bidi_map, entry);
226 char *result, written_at[ISO_TIME_LEN+1];
235 "conn-bi-direct %s (%d s) "
236 "%"PRIu32
",%"PRIu32
",%"PRIu32
",%"PRIu32
"\n"
237 "ipv6-conn-bi-direct %s (%d s) "
238 "%"PRIu32
",%"PRIu32
",%"PRIu32
",%"PRIu32
"\n",
int check_or_create_data_subdir(const char *subdir)
int write_to_data_subdir(const char *subdir, const char *fname, const char *str, const char *descr)
Header file for config.c.
time_t conn_stats_save(time_t now)
static void collect_period_statistics(void)
void conn_stats_reset(time_t now)
static conn_counts_t counts
void conn_stats_terminate(void)
static void add_entry_to_count(conn_counts_t *cnt, const bidi_map_entry_t *ent)
static time_t start_of_conn_stats_interval
void conn_stats_note_or_conn_bytes(uint64_t conn_id, size_t num_read, size_t num_written, time_t when, bool is_ipv6)
static HT_HEAD(bidimap, bidi_map_entry_t)
static conn_counts_t counts_ipv6
void conn_stats_free_all(void)
static time_t bidi_next_interval
char * conn_stats_format(time_t now)
static unsigned bidi_map_ent_hash(const bidi_map_entry_t *entry)
void conn_stats_init(time_t now)
Header for feature/stats/connstats.c.
HT_PROTOTYPE(hs_circuitmap_ht, circuit_t, hs_circuitmap_node, hs_circuit_hash_token, hs_circuits_have_same_token)
void tor_free_(void *mem)
void * tor_reallocarray_(void *ptr, size_t sz1, size_t sz2)
Master header file for Tor-specific functionality.
int tor_asprintf(char **strp, const char *fmt,...)
uint32_t both_read_and_written
void format_iso_time(char *buf, time_t t)