54 #define CHANNEL_OBJECT_PRIVATE
57 #define CHANNEL_FILE_PRIVATE
63 #include "core/or/channelpadding.h"
70 #include "core/or/dos.h"
122 channel_id_hash, channel_id_eq);
123 HT_GENERATE2(channel_gid_map,
channel_t, gidmap_node,
124 channel_id_hash, channel_id_eq,
130 static uint64_t n_channels_allocated = 0;
140 static
HT_HEAD(channel_idmap, channel_idmap_entry_t) channel_identity_map =
143 typedef struct channel_idmap_entry_t {
144 HT_ENTRY(channel_idmap_entry_t) node;
146 TOR_LIST_HEAD(channel_list_t,
channel_t) channel_list;
147 } channel_idmap_entry_t;
149 static inline unsigned
150 channel_idmap_hash(
const channel_idmap_entry_t *ent)
152 return (
unsigned) siphash24g(ent->digest,
DIGEST_LEN);
156 channel_idmap_eq(
const channel_idmap_entry_t *a,
157 const channel_idmap_entry_t *b)
162 HT_PROTOTYPE(channel_idmap, channel_idmap_entry_t, node, channel_idmap_hash,
164 HT_GENERATE2(channel_idmap, channel_idmap_entry_t, node, channel_idmap_hash,
327 descr =
"channel error";
330 descr =
"temporarily suspended for maintenance";
340 descr =
"unknown or invalid channel state";
362 descr =
"channel listener error";
369 descr =
"unknown or invalid channel listener state";
395 "Registering channel %p (ID %"PRIu64
") "
396 "in state %s (%d) with digest %s",
404 channel_t *oldval = HT_REPLACE(channel_gid_map, &channel_gid_map, chan);
408 if (CHANNEL_FINISHED(chan)) {
418 if (!CHANNEL_IS_CLOSING(chan)) {
425 "Channel %p (global ID %"PRIu64
") "
426 "in state %s (%d) registered with no identity digest",
452 if (CHANNEL_FINISHED(chan)) {
462 channel_t *oldval = HT_REMOVE(channel_gid_map, &channel_gid_map, chan);
470 !(CHANNEL_CONDEMNED(chan))) {
491 "Registering channel listener %p (ID %"PRIu64
") "
505 if (!finished_listeners) finished_listeners =
smartlist_new();
562 channel_idmap_entry_t *ent, search;
573 ent = HT_FIND(channel_idmap, &channel_identity_map, &search);
575 ent = tor_malloc(
sizeof(channel_idmap_entry_t));
577 TOR_LIST_INIT(&ent->channel_list);
578 HT_INSERT(channel_idmap, &channel_identity_map, ent);
580 TOR_LIST_INSERT_HEAD(&ent->channel_list, chan, next_with_same_id);
583 "Added channel %p (global ID %"PRIu64
") "
584 "to identity map in state %s (%d) with digest %s",
599 channel_idmap_entry_t *ent, search;
607 TOR_LIST_REMOVE(chan, next_with_same_id);
610 ent = HT_FIND(channel_idmap, &channel_identity_map, &search);
616 if (TOR_LIST_EMPTY(&ent->channel_list)) {
617 HT_REMOVE(channel_idmap, &channel_identity_map, ent);
622 "Removed channel %p (global ID %"PRIu64
") from "
623 "identity map in state %s (%d) with digest %s",
630 "Trying to remove channel %p (global ID %"PRIu64
") with "
631 "digest %s from identity map, but couldn't find any with "
656 rv = HT_FIND(channel_gid_map, &channel_gid_map, &lookup);
668 const char *rsa_id_digest,
701 channel_idmap_entry_t *ent, search;
712 memcpy(search.digest, rsa_id_digest,
DIGEST_LEN);
713 ent = HT_FIND(channel_idmap, &channel_identity_map, &search);
715 rv = TOR_LIST_FIRST(&ent->channel_list);
735 return TOR_LIST_NEXT(chan, next_with_same_id);
750 channel_idmap_entry_t **iter;
752 int total_dirauth_connections = 0, total_dirauths = 0;
753 int total_relay_connections = 0, total_relays = 0, total_canonical = 0;
754 int total_half_canonical = 0;
755 int total_gt_one_connection = 0, total_gt_two_connections = 0;
756 int total_gt_four_connections = 0;
758 HT_FOREACH(iter, channel_idmap, &channel_identity_map) {
759 int connections_to_relay = 0;
760 const char *id_digest = (
char *) (*iter)->digest;
768 const bool is_dirauth = router_digest_is_trusted_dir(id_digest);
772 for (chan = TOR_LIST_FIRST(&(*iter)->channel_list); chan;
775 if (CHANNEL_CONDEMNED(chan) || !CHANNEL_IS_OPEN(chan))
778 connections_to_relay++;
779 total_relay_connections++;
781 total_dirauth_connections++;
786 total_half_canonical++;
790 if (connections_to_relay > 1) total_gt_one_connection++;
791 if (connections_to_relay > 2) total_gt_two_connections++;
792 if (connections_to_relay > 4) total_gt_four_connections++;
798 #define MIN_RELAY_CONNECTIONS_TO_WARN 25
802 #define MAX_AVG_RELAY_CONNECTIONS 1.5
806 #define MAX_AVG_DIRAUTH_CONNECTIONS 4
810 const int max_tolerable_connections = (int)(
811 (total_relays-total_dirauths) * MAX_AVG_RELAY_CONNECTIONS +
812 total_dirauths * MAX_AVG_DIRAUTH_CONNECTIONS);
815 if (total_relays > MIN_RELAY_CONNECTIONS_TO_WARN &&
816 total_relay_connections > max_tolerable_connections) {
818 "Your relay has a very large number of connections to other relays. "
819 "Is your outbound address the same as your relay address? "
820 "Found %d connections to %d relays. Found %d current canonical "
821 "connections, in %d of which we were a non-canonical peer. "
822 "%d relays had more than 1 connection, %d had more than 2, and "
823 "%d had more than 4 connections.",
824 total_relay_connections, total_relays, total_canonical,
825 total_half_canonical, total_gt_one_connection,
826 total_gt_two_connections, total_gt_four_connections);
828 log_info(
LD_OR,
"Performed connection pruning. "
829 "Found %d connections to %d relays. Found %d current canonical "
830 "connections, in %d of which we were a non-canonical peer. "
831 "%d relays had more than 1 connection, %d had more than 2, and "
832 "%d had more than 4 connections.",
833 total_relay_connections, total_relays, total_canonical,
834 total_half_canonical, total_gt_one_connection,
835 total_gt_two_connections, total_gt_four_connections);
861 memset(&chan->next_with_same_id, 0,
sizeof(chan->next_with_same_id));
913 "Freeing channel %"PRIu64
" at %p",
917 scheduler_release_channel(chan);
930 channel_handles_clear(chan);
941 circuitmux_free(chan->
cmux);
959 "Freeing channel_listener_t %"PRIu64
" at %p",
986 "Force-freeing channel %"PRIu64
" at %p",
990 scheduler_release_channel(chan);
1003 channel_handles_clear(chan);
1012 circuitmux_free(chan->
cmux);
1030 "Force-freeing channel_listener_t %"PRIu64
" at %p",
1046 } SMARTLIST_FOREACH_END(qchan);
1063 channel_listener_fn_ptr listener)
1069 "Setting listener callback for channel listener %p "
1070 "(global ID %"PRIu64
") to %p",
1084 channel_cell_handler_fn_ptr
1089 if (CHANNEL_CAN_HANDLE_CELLS(chan))
1103 channel_cell_handler_fn_ptr cell_handler)
1109 "Setting cell_handler callback for channel %p to %p",
1110 chan, cell_handler);
1143 if (CHANNEL_CONDEMNED(chan))
1147 "Closing channel %p (global ID %"PRIu64
") "
1187 "Closing channel listener %p (global ID %"PRIu64
") "
1198 chan_l->
close(chan_l);
1221 if (CHANNEL_CONDEMNED(chan))
1225 "Closing channel %p (global ID %"PRIu64
") "
1226 "due to lower-layer event",
1249 if (CHANNEL_CONDEMNED(chan))
1253 "Closing channel %p due to lower-layer error",
1277 if (CHANNEL_FINISHED(chan))
1304 int state_not_in_map;
1309 "Clearing remote endpoint digest on channel %p with "
1310 "global ID %"PRIu64,
1313 state_not_in_map = CHANNEL_CONDEMNED(chan);
1332 const char *identity_digest,
1335 int was_in_digest_map, should_be_in_digest_map, state_not_in_map;
1340 "Setting remote endpoint digest on channel %p with "
1341 "global ID %"PRIu64
" to digest %s",
1346 state_not_in_map = CHANNEL_CONDEMNED(chan);
1349 !state_not_in_map &&
1352 should_be_in_digest_map =
1353 !state_not_in_map &&
1358 if (was_in_digest_map)
1364 if (identity_digest) {
1379 if (should_be_in_digest_map)
1392 int state_not_in_map;
1397 "Clearing remote endpoint identity on channel %p with "
1398 "global ID %"PRIu64,
1401 state_not_in_map = CHANNEL_CONDEMNED(chan);
1440 cell_bytes = get_cell_network_size(chan->wide_circ_ids);
1443 if (!CHANNEL_IS_OPEN(chan)) {
1455 chan->n_bytes_xmitted += cell_bytes;
1491 if (CHANNEL_IS_CLOSING(chan)) {
1492 log_debug(
LD_CHANNEL,
"Discarding %p on closing channel %p with "
1493 "global ID %"PRIu64, cell, chan,
1498 "Writing %p to channel %p with global ID "
1507 packed_cell_free(cell);
1522 unsigned char was_active, is_active;
1523 unsigned char was_in_id_map, is_in_id_map;
1526 from_state = chan->
state;
1533 if (from_state == to_state) {
1535 "Got no-op transition from \"%s\" to itself on channel %p"
1536 "(global ID %"PRIu64
")",
1550 "Changing state of channel %p (global ID %"PRIu64
1551 ") from \"%s\" to \"%s\"",
1557 chan->
state = to_state;
1567 if (was_active && !is_active) {
1569 if (!finished_channels) finished_channels =
smartlist_new();
1574 else if (!was_active && is_active) {
1590 else if (was_in_id_map && !is_in_id_map)
1602 scheduler_release_channel(chan);
1643 unsigned char was_active, is_active;
1646 from_state = chan_l->
state;
1653 if (from_state == to_state) {
1655 "Got no-op transition from \"%s\" to itself on channel "
1656 "listener %p (global ID %"PRIu64
")",
1670 "Changing state of channel listener %p (global ID %"PRIu64
1671 "from \"%s\" to \"%s\"",
1676 chan_l->
state = to_state;
1686 if (was_active && !is_active) {
1688 if (!finished_listeners) finished_listeners =
smartlist_new();
1693 else if (!was_active && is_active) {
1709 #define MAX_CELLS_TO_GET_FROM_CIRCUITS_FOR_UNLIMITED 256
1732 unsigned int unlimited = 0;
1733 ssize_t flushed = 0;
1734 int clamped_num_cells;
1738 if (num_cells < 0) unlimited = 1;
1739 if (!unlimited && num_cells <= flushed)
goto done;
1742 if (CHANNEL_IS_OPEN(chan)) {
1746 clamped_num_cells = MAX_CELLS_TO_GET_FROM_CIRCUITS_FOR_UNLIMITED;
1748 if (num_cells - flushed >
1749 MAX_CELLS_TO_GET_FROM_CIRCUITS_FOR_UNLIMITED) {
1750 clamped_num_cells = MAX_CELLS_TO_GET_FROM_CIRCUITS_FOR_UNLIMITED;
1752 clamped_num_cells = (int)(num_cells - flushed);
1758 chan, clamped_num_cells);
1820 "Processing queue of incoming connections for channel "
1821 "listener %p (global ID %"PRIu64
")",
1831 "Handling incoming channel %p (%"PRIu64
") "
1832 "for listener %p (%"PRIu64
")",
1839 listener->
listener(listener, chan);
1840 } SMARTLIST_FOREACH_END(chan);
1863 time_t now = time(NULL);
1864 int close_origin_circuits = 0;
1877 char *transport_name = NULL;
1878 channel_tls_t *tlschan = BASE_CHAN_TO_TLS(chan);
1879 if (chan->get_transport_name(chan, &transport_name) < 0)
1880 transport_name = NULL;
1883 &remote_addr, transport_name,
1886 if (tlschan && tlschan->conn) {
1887 dos_new_client_conn(tlschan->conn, transport_name);
1900 }
else if (hs_service_allow_non_anonymous_connection(
get_options()) &&
1902 CHANNELPADDING_SOS_PARAM,
1903 CHANNELPADDING_SOS_DEFAULT, 0, 1)) {
1907 }
else if (
get_options()->ReducedConnectionPadding) {
1928 int need_to_queue = 0;
1935 "Queueing incoming channel %p (global ID %"PRIu64
") on "
1936 "channel listener %p (global ID %"PRIu64
")",
1941 if (!(listener->
listener)) need_to_queue = 1;
1957 if (!need_to_queue) {
1959 listener->
listener(listener, incoming);
1979 tor_assert(CHANNEL_IS_CLOSING(chan) || CHANNEL_IS_MAINT(chan) ||
1980 CHANNEL_IS_OPEN(chan));
1991 chan->n_bytes_recved += get_cell_network_size(chan->wide_circ_ids);
1994 "Processing incoming cell_t %p for channel %p (global ID "
1995 "%"PRIu64
")", cell, chan,
2009 if (chan->wide_circ_ids) {
2010 if (packed_cell->
body[4] == CELL_DESTROY) {
2015 if (packed_cell->
body[2] == CELL_DESTROY) {
2035 log_warn(
LD_BUG,
"Attempted to send a destroy cell for circID 0 "
2036 "on a channel %"PRIu64
" at %p in state %s (%d)",
2044 if (!CHANNEL_CONDEMNED(chan) && chan->
cmux) {
2046 circuitmux_append_destroy_cell(chan, chan->
cmux, circ_id, reason);
2048 "Sending destroy (circID %u) on channel %p "
2049 "(global ID %"PRIu64
")",
2050 (
unsigned)circ_id, chan,
2054 "Someone called channel_send_destroy() for circID %u "
2055 "on a channel %"PRIu64
" at %p in state %s (%d)",
2073 if (all_channels && smartlist_len(all_channels) > 0) {
2075 "Dumping statistics about %d channels:",
2076 smartlist_len(all_channels));
2078 "%d are active, and %d are done and waiting for cleanup",
2079 (active_channels != NULL) ?
2080 smartlist_len(active_channels) : 0,
2081 (finished_channels != NULL) ?
2082 smartlist_len(finished_channels) : 0);
2088 "Done spamming about channels now");
2091 "No channels to dump");
2104 if (all_listeners && smartlist_len(all_listeners) > 0) {
2106 "Dumping statistics about %d channel listeners:",
2107 smartlist_len(all_listeners));
2109 "%d are active and %d are done and waiting for cleanup",
2110 (active_listeners != NULL) ?
2111 smartlist_len(active_listeners) : 0,
2112 (finished_listeners != NULL) ?
2113 smartlist_len(finished_listeners) : 0);
2119 "Done spamming about channel listeners now");
2122 "No channel listeners to dump");
2138 if (!finished_channels || smartlist_len(finished_channels) == 0)
return;
2149 } SMARTLIST_FOREACH_END(curr);
2164 if (!finished_listeners || smartlist_len(finished_listeners) == 0)
return;
2174 channel_listener_free(tmp);
2175 } SMARTLIST_FOREACH_END(curr);
2184 if (!channels)
return;
2190 "Cleaning up channel %p (global ID %"PRIu64
") "
2192 curr, (curr->global_identifier),
2200 if (mark_for_close) {
2201 if (!CHANNEL_CONDEMNED(curr)) {
2205 }
else channel_free(curr);
2206 } SMARTLIST_FOREACH_END(curr);
2215 if (!listeners)
return;
2221 "Cleaning up channel listener %p (global ID %"PRIu64
") "
2223 curr, (curr->global_identifier),
2226 if (mark_for_close) {
2233 }
else channel_listener_free(curr);
2234 } SMARTLIST_FOREACH_END(curr);
2249 "Shutting down channels...");
2252 if (finished_channels) {
2254 smartlist_free(finished_channels);
2255 finished_channels = NULL;
2259 if (finished_listeners) {
2261 smartlist_free(finished_listeners);
2262 finished_listeners = NULL;
2266 if (active_channels) {
2268 smartlist_free(active_channels);
2269 active_channels = NULL;
2273 if (active_listeners) {
2275 smartlist_free(active_listeners);
2276 active_listeners = NULL;
2282 smartlist_free(all_channels);
2283 all_channels = NULL;
2287 if (all_listeners) {
2289 smartlist_free(all_listeners);
2290 all_listeners = NULL;
2295 "Freeing channel_identity_map");
2297 HT_CLEAR(channel_idmap, &channel_identity_map);
2301 "Freeing channel_gid_map");
2302 HT_CLEAR(channel_gid_map, &channel_gid_map);
2305 "Done cleaning up after channels");
2320 const char *id_digest,
2339 int a_is_canonical, b_is_canonical;
2355 if (a_is_canonical && !b_is_canonical)
return 1;
2356 if (!a_is_canonical && b_is_canonical)
return 0;
2407 bool for_origin_circ,
2408 const char **msg_out,
2412 int n_inprogress_goodaddr = 0, n_old = 0;
2413 int n_noncanonical = 0;
2425 if (CHANNEL_CONDEMNED(chan))
2439 const bool matches_target =
2444 if (!CHANNEL_IS_OPEN(chan)) {
2447 if (matches_target) {
2448 ++n_inprogress_goodaddr;
2449 if (for_origin_circ) {
2482 *msg_out =
"Connection is fine; using it.";
2485 }
else if (n_inprogress_goodaddr) {
2486 *msg_out =
"Connection in progress; waiting.";
2489 }
else if (n_old || n_noncanonical) {
2490 *msg_out =
"Connections all too old, or too non-canonical. "
2491 " Launching a new one.";
2495 *msg_out =
"Not connected. Connecting.";
2539 double avg, interval, age;
2540 time_t now = time(NULL);
2542 int have_remote_addr;
2543 char *remote_addr_str;
2550 "Channel %"PRIu64
" (at %p) with transport %s is in state "
2556 " * Channel %"PRIu64
" was created at %"PRIu64
2557 " (%"PRIu64
" seconds ago) "
2558 "and last active at %"PRIu64
" (%"PRIu64
" seconds ago)",
2562 (uint64_t)(chan->timestamp_active),
2563 (uint64_t)(now - chan->timestamp_active));
2568 " * Channel %"PRIu64
" says it is connected "
2569 "to an OR with digest %s",
2574 " * Channel %"PRIu64
" does not know the digest"
2575 " of the OR it is connected to",
2581 if (have_remote_addr) {
2585 " * Channel %"PRIu64
" says its remote address"
2586 " is %s, and gives a canonical description of \"%s\" and an "
2587 "actual description of \"%s\"",
2589 safe_str(remote_addr_str),
2597 " * Channel %"PRIu64
" does not know its remote "
2598 "address, but gives a canonical description of \"%s\" and an "
2599 "actual description of \"%s\"",
2608 " * Channel %"PRIu64
" has these marks: %s %s %s %s %s",
2611 "bad_for_new_circs" :
"!bad_for_new_circs",
2613 "canonical" :
"!canonical",
2615 "client" :
"!client",
2619 "incoming" :
"outgoing");
2623 " * Channel %"PRIu64
" has %d active circuits out of"
2626 (chan->
cmux != NULL) ?
2628 (chan->
cmux != NULL) ?
2633 " * Channel %"PRIu64
" was last used by a "
2634 "client at %"PRIu64
" (%"PRIu64
" seconds ago)",
2639 " * Channel %"PRIu64
" last received a cell "
2640 "at %"PRIu64
" (%"PRIu64
" seconds ago)",
2645 " * Channel %"PRIu64
" last transmitted a cell "
2646 "at %"PRIu64
" (%"PRIu64
" seconds ago)",
2653 " * Channel %"PRIu64
" has received "
2654 "%"PRIu64
" bytes in %"PRIu64
" cells and transmitted "
2655 "%"PRIu64
" bytes in %"PRIu64
" cells",
2657 (chan->n_bytes_recved),
2659 (chan->n_bytes_xmitted),
2663 if (chan->n_bytes_recved > 0) {
2664 avg = (double)(chan->n_bytes_recved) / age;
2666 " * Channel %"PRIu64
" has averaged %f "
2667 "bytes received per second",
2674 " * Channel %"PRIu64
" has averaged %f "
2675 "cells received per second",
2677 }
else if (avg >= 0.0) {
2678 interval = 1.0 / avg;
2680 " * Channel %"PRIu64
" has averaged %f "
2681 "seconds between received cells",
2685 if (chan->n_bytes_xmitted > 0) {
2686 avg = (double)(chan->n_bytes_xmitted) / age;
2688 " * Channel %"PRIu64
" has averaged %f "
2689 "bytes transmitted per second",
2696 " * Channel %"PRIu64
" has averaged %f "
2697 "cells transmitted per second",
2699 }
else if (avg >= 0.0) {
2700 interval = 1.0 / avg;
2702 " * Channel %"PRIu64
" has averaged %f "
2703 "seconds between transmitted cells",
2721 double avg, interval, age;
2722 time_t now = time(NULL);
2729 "Channel listener %"PRIu64
" (at %p) with transport %s is in "
2735 " * Channel listener %"PRIu64
" was created at %"PRIu64
2736 " (%"PRIu64
" seconds ago) "
2737 "and last active at %"PRIu64
" (%"PRIu64
" seconds ago)",
2741 (uint64_t)(chan_l->timestamp_active),
2742 (uint64_t)(now - chan_l->timestamp_active));
2745 " * Channel listener %"PRIu64
" last accepted an incoming "
2746 "channel at %"PRIu64
" (%"PRIu64
" seconds ago) "
2747 "and has accepted %"PRIu64
" channels in total",
2763 " * Channel listener %"PRIu64
" has averaged %f incoming "
2764 "channels per second",
2766 }
else if (avg >= 0.0) {
2767 interval = 1.0 / avg;
2769 " * Channel listener %"PRIu64
" has averaged %f seconds "
2770 "between incoming channels",
2841 return chan->get_remote_addr(chan, addr_out);
3065 result = chan->num_cells_writeable(chan);
3066 if (result < 0) result = 0;
3088 time_t now = time(NULL);
3104 time_t now = time(NULL);
3124 time_t now = time(NULL);
3129 chan->timestamp_active = now;
3141 time_t now = time(NULL);
3145 chan_l->timestamp_active = now;
3158 time_t now = time(NULL);
3162 chan_l->timestamp_active = now;
3175 time_t now = time(NULL);
3191 time_t now = time(NULL);
3195 chan->timestamp_active = now;
3211 time_t now = time(NULL);
3216 chan->timestamp_active = now;
3297 IF_BUG_ONCE(!target_ipv4_addr && !target_ipv6_addr)
3300 if (target_ipv4_addr && chan->
matches_target(chan, target_ipv4_addr))
3303 if (target_ipv6_addr && chan->
matches_target(chan, target_ipv6_addr))
3321 chan->num_p_circuits;
3333 int consider_identity))
3342 if (! consider_identity) {
3350 our_identity = started_here ?
3353 if (identity_rcvd) {
3365 channel_sort_by_ed25519_identity(
const void **a_,
const void **b_)
3370 &b->ed25519_identity.pubkey,
3388 if (PREDICT_LIKELY(!TOR_LIST_NEXT(chan, next_with_same_id))) {
3390 time(NULL), BASE_CHAN_TO_TLS(chan)->conn, force);
3396 TOR_LIST_FOREACH(chan, lst, next_with_same_id) {
3397 if (BASE_CHAN_TO_TLS(chan)->conn) {
3410 if (!common_ed25519_identity)
3411 common_ed25519_identity = &channel->ed25519_identity;
3414 common_ed25519_identity)) {
3417 common_ed25519_identity = &channel->ed25519_identity;
3421 } SMARTLIST_FOREACH_END(channel);
3428 smartlist_free(or_conns);
3429 smartlist_free(channels);
3441 channel_idmap_entry_t *ent;
3442 channel_idmap_entry_t search;
3443 memset(&search, 0,
sizeof(search));
3445 ent = HT_FIND(channel_idmap, &channel_identity_map, &search);
3453 channel_idmap_entry_t **iter;
3454 HT_FOREACH(iter, channel_idmap, &channel_identity_map) {
void tor_addr_make_unspec(tor_addr_t *a)
char * tor_addr_to_str_dup(const tor_addr_t *addr)
const char * hex_str(const char *from, size_t fromlen)
static uint16_t get_uint16(const void *cp)
static uint32_t get_uint32(const void *cp)
const char * channel_listener_describe_transport(channel_listener_t *chan_l)
int channel_has_queued_writes(channel_t *chan)
channel_t * channel_find_by_global_id(uint64_t global_identifier)
channel_t * channel_find_by_remote_identity(const char *rsa_id_digest, const ed25519_public_key_t *ed_id)
void channel_timestamp_active(channel_t *chan)
void channel_set_circid_type(channel_t *chan, crypto_pk_t *identity_rcvd, int consider_identity)
int channel_is_better(channel_t *a, channel_t *b)
int channel_is_bad_for_new_circs(channel_t *chan)
static void channel_remove_from_digest_map(channel_t *chan)
int channel_is_outgoing(channel_t *chan)
const char * channel_describe_transport(channel_t *chan)
void channel_listener_process_incoming(channel_listener_t *listener)
channel_t * channel_next_with_rsa_identity(channel_t *chan)
void channel_timestamp_recv(channel_t *chan)
void channel_run_cleanup(void)
void channel_update_bad_for_new_circs(const char *digest, int force)
void channel_dumpstats(int severity)
void channel_timestamp_client(channel_t *chan)
void channel_set_identity_digest(channel_t *chan, const char *identity_digest, const ed25519_public_key_t *ed_identity)
void channel_listener_unregister(channel_listener_t *chan_l)
channel_t * channel_connect(const tor_addr_t *addr, uint16_t port, const char *id_digest, const ed25519_public_key_t *ed_id)
void channel_listener_dump_statistics(channel_listener_t *chan_l, int severity)
void channel_mark_local(channel_t *chan)
void channel_set_cell_handlers(channel_t *chan, channel_cell_handler_fn_ptr cell_handler)
void channel_mark_client(channel_t *chan)
time_t channel_when_last_xmit(channel_t *chan)
void channel_listener_run_cleanup(void)
static void channel_force_xfree(channel_t *chan)
void channel_mark_incoming(channel_t *chan)
void channel_closed(channel_t *chan)
void channel_init_listener(channel_listener_t *chan_l)
int channel_listener_state_can_transition(channel_listener_state_t from, channel_listener_state_t to)
STATIC void channel_add_to_digest_map(channel_t *chan)
int channel_state_is_valid(channel_state_t state)
void channel_do_open_actions(channel_t *chan)
void channel_listener_mark_for_close(channel_listener_t *chan_l)
void channel_close_from_lower_layer(channel_t *chan)
void channel_check_for_duplicates(void)
void channel_process_cell(channel_t *chan, cell_t *cell)
void channel_change_state_open(channel_t *chan)
void channel_listener_queue_incoming(channel_listener_t *listener, channel_t *incoming)
int channel_is_canonical(channel_t *chan)
int channel_listener_state_is_valid(channel_listener_state_t state)
void channel_timestamp_created(channel_t *chan)
static void channel_free_list(smartlist_t *channels, int mark_for_close)
int channel_matches_extend_info(channel_t *chan, extend_info_t *extend_info)
int channel_state_can_transition(channel_state_t from, channel_state_t to)
int channel_remote_identity_matches(const channel_t *chan, const char *rsa_id_digest, const ed25519_public_key_t *ed_id)
void channel_listener_set_listener_fn(channel_listener_t *chan_l, channel_listener_fn_ptr listener)
void channel_register(channel_t *chan)
time_t channel_when_last_client(channel_t *chan)
void channel_listener_timestamp_created(channel_listener_t *chan_l)
void channel_listener_timestamp_active(channel_listener_t *chan_l)
void channel_listener_register(channel_listener_t *chan_l)
void channel_listener_dump_transport_statistics(channel_listener_t *chan_l, int severity)
static void channel_change_state_(channel_t *chan, channel_state_t to_state)
static HT_HEAD(channel_gid_map, channel_t)
int channel_send_destroy(circid_t circ_id, channel_t *chan, int reason)
void channel_mark_bad_for_new_circs(channel_t *chan)
int channel_is_incoming(channel_t *chan)
int channel_is_client(const channel_t *chan)
void channel_mark_remote(channel_t *chan)
void channel_unregister(channel_t *chan)
static void channel_rsa_id_group_set_badness(struct channel_list_t *lst, int force)
channel_cell_handler_fn_ptr channel_get_cell_handler(channel_t *chan)
ssize_t channel_flush_some_cells(channel_t *chan, ssize_t num_cells)
static void channel_listener_free_list(smartlist_t *channels, int mark_for_close)
int packed_cell_is_destroy(channel_t *chan, const packed_cell_t *packed_cell, circid_t *circid_out)
STATIC bool channel_matches_target_addr_for_extend(channel_t *chan, const tor_addr_t *target_ipv4_addr, const tor_addr_t *target_ipv6_addr)
void channel_close_for_error(channel_t *chan)
void channel_listener_free_(channel_listener_t *chan_l)
void channel_listener_dumpstats(int severity)
static int write_packed_cell(channel_t *chan, packed_cell_t *cell)
int channel_is_local(channel_t *chan)
void channel_listener_timestamp_accepted(channel_listener_t *chan_l)
void channel_notify_flushed(channel_t *chan)
int channel_num_cells_writeable(channel_t *chan)
void channel_timestamp_xmit(channel_t *chan)
int channel_get_addr_if_possible(const channel_t *chan, tor_addr_t *addr_out)
const char * channel_state_to_string(channel_state_t state)
void channel_mark_for_close(channel_t *chan)
void channel_clear_identity_digest(channel_t *chan)
void channel_clear_remote_end(channel_t *chan)
void channel_listener_change_state(channel_listener_t *chan_l, channel_listener_state_t to_state)
void channel_mark_outgoing(channel_t *chan)
const char * channel_describe_peer(channel_t *chan)
static void channel_listener_force_xfree(channel_listener_t *chan_l)
void channel_dump_statistics(channel_t *chan, int severity)
void channel_free_all(void)
channel_t * channel_get_for_extend(const char *rsa_id_digest, const ed25519_public_key_t *ed_id, const tor_addr_t *target_ipv4_addr, const tor_addr_t *target_ipv6_addr, bool for_origin_circ, const char **msg_out, int *launch_out)
int channel_more_to_flush(channel_t *chan)
void channel_dump_transport_statistics(channel_t *chan, int severity)
unsigned int channel_num_circuits(channel_t *chan)
void channel_clear_client(channel_t *chan)
int channel_write_packed_cell(channel_t *chan, packed_cell_t *cell)
const char * channel_listener_state_to_string(channel_listener_state_t state)
time_t channel_when_created(channel_t *chan)
void channel_init(channel_t *chan)
void channel_free_(channel_t *chan)
void channel_change_state(channel_t *chan, channel_state_t to_state)
Header file for channel.c.
void channel_mark_as_used_for_origin_circuit(channel_t *chan)
@ CHANNEL_LISTENER_STATE_ERROR
@ CHANNEL_LISTENER_STATE_LAST
@ CHANNEL_LISTENER_STATE_LISTENING
@ CHANNEL_LISTENER_STATE_CLOSING
@ CHANNEL_LISTENER_STATE_CLOSED
void channelpadding_disable_padding_on_channel(channel_t *chan)
void channelpadding_reduce_padding_on_channel(channel_t *chan)
channel_t * channel_tls_connect(const tor_addr_t *addr, uint16_t port, const char *id_digest, const ed25519_public_key_t *ed_id)
Header file for channeltls.c.
void circuit_n_chan_done(channel_t *chan, int status, int close_origin_circuits)
Header file for circuitbuild.c.
void channel_note_destroy_pending(channel_t *chan, circid_t id)
void channel_note_destroy_not_pending(channel_t *chan, circid_t id)
void circuit_unlink_all_from_channel(channel_t *chan, int reason)
Header file for circuitlist.c.
void circuitmux_mark_destroyed_circids_usable(circuitmux_t *cmux, channel_t *chan)
void circuitmux_detach_all_circuits(circuitmux_t *cmux, smartlist_t *detached_out)
void circuitmux_set_policy(circuitmux_t *cmux, const circuitmux_policy_t *pol)
unsigned int circuitmux_num_active_circuits(circuitmux_t *cmux)
unsigned int circuitmux_num_circuits(circuitmux_t *cmux)
unsigned int circuitmux_num_cells(circuitmux_t *cmux)
Header file for circuitmux.c.
void circuit_build_times_network_is_live(circuit_build_times_t *cbt)
circuit_build_times_t * get_circuit_build_times_mutable(void)
Header file for circuitstats.c.
Functions and types for monotonic times.
const or_options_t * get_options(void)
tor_cmdline_mode_t command
Header file for config.c.
int connection_or_single_set_badness_(time_t now, or_connection_t *or_conn, int force)
int connection_or_digest_is_known_relay(const char *id_digest)
void connection_or_group_set_badness_(smartlist_t *group, int force)
Header file for connection_or.c.
int ed25519_public_key_is_zero(const ed25519_public_key_t *pubkey)
int ed25519_pubkey_eq(const ed25519_public_key_t *key1, const ed25519_public_key_t *key2)
int crypto_pk_cmp_keys(const crypto_pk_t *a, const crypto_pk_t *b)
int tor_memeq(const void *a, const void *b, size_t sz)
#define fast_memcmp(a, b, c)
#define tor_memneq(a, b, sz)
Header file for dirlist.c.
Header file for circuitbuild.c.
Header file for geoip_stats.c.
@ DIRREQ_CHANNEL_BUFFER_FLUSHED
void geoip_change_dirreq_state(uint64_t dirreq_id, dirreq_type_t type, dirreq_state_t new_state)
void geoip_note_client_seen(geoip_client_action_t action, const tor_addr_t *addr, const char *transport_name, time_t now)
HT_PROTOTYPE(hs_circuitmap_ht, circuit_t, hs_circuitmap_node, hs_circuit_hash_token, hs_circuits_have_same_token)
Header file containing service data for the HS subsystem.
void tor_log(int severity, log_domain_mask_t domain, const char *format,...)
void mainloop_schedule_postloop_cleanup(void)
Header file for mainloop.c.
void tor_free_(void *mem)
void * tor_reallocarray_(void *ptr, size_t sz1, size_t sz2)
int32_t networkstatus_get_param(const networkstatus_t *ns, const char *param_name, int32_t default_val, int32_t min_val, int32_t max_val)
Header file for networkstatus.c.
void router_set_status(const char *digest, int up)
Header file for nodelist.c.
Master header file for Tor-specific functionality.
int channel_flush_from_first_active_circuit(channel_t *chan, int max)
uint8_t packed_cell_get_command(const packed_cell_t *cell, int wide_circ_ids)
void rep_hist_padding_count_write(padding_type_t type)
Header file for rephist.c.
@ PADDING_TYPE_ENABLED_CELL
@ PADDING_TYPE_ENABLED_TOTAL
crypto_pk_t * get_tlsclient_identity_key(void)
Header file for router.c.
Header file for routerlist.c.
void scheduler_channel_doesnt_want_writes(channel_t *chan)
Header file for scheduler*.c.
void smartlist_sort(smartlist_t *sl, int(*compare)(const void **a, const void **b))
smartlist_t * smartlist_new(void)
void smartlist_add(smartlist_t *sl, void *element)
void smartlist_clear(smartlist_t *sl)
void smartlist_remove(smartlist_t *sl, const void *element)
#define SMARTLIST_FOREACH_BEGIN(sl, type, var)
#define SMARTLIST_FOREACH(sl, type, var, cmd)
#define SMARTLIST_DEL_CURRENT(sl, var)
channel_listener_state_t state
enum channel_listener_t::@10 reason_for_closing
void(* dumpstats)(channel_listener_t *, int)
uint64_t global_identifier
void(* free_fn)(channel_listener_t *)
smartlist_t * incoming_list
const char *(* describe_transport)(channel_listener_t *)
channel_listener_fn_ptr listener
time_t timestamp_accepted
void(* close)(channel_listener_t *)
void(* free_fn)(channel_t *)
int(* is_canonical)(channel_t *)
void(* close)(channel_t *)
monotime_coarse_t next_padding_time
void(* dumpstats)(channel_t *, int)
time_t timestamp_last_had_circuits
unsigned int num_n_circuits
int(* matches_extend_info)(channel_t *, extend_info_t *)
enum channel_t::@9 scheduler_state
circ_id_type_bitfield_t circ_id_type
unsigned int padding_enabled
char identity_digest[DIGEST_LEN]
uint64_t global_identifier
int(* write_packed_cell)(channel_t *, packed_cell_t *)
struct channel_handle_t * timer_handle
const char *(* describe_peer)(const channel_t *)
tor_addr_t addr_according_to_peer
channel_cell_handler_fn_ptr cell_handler
int(* matches_target)(channel_t *, const tor_addr_t *)
struct ed25519_public_key_t ed25519_identity
unsigned int has_been_open
monotime_coarse_t timestamp_xfer
unsigned int is_bad_for_new_circs
unsigned int is_canonical_to_peer
const char *(* describe_transport)(channel_t *)
struct tor_timer_t * padding_timer
ratelim_t last_warned_circ_ids_exhausted
int(* has_queued_writes)(channel_t *)
enum channel_t::@8 reason_for_closing
char body[CELL_MAX_NETWORK_SIZE]
#define MOCK_IMPL(rv, funcname, arglist)
#define IF_BUG_ONCE(cond)
int tor_digest_is_zero(const char *digest)
#define ED25519_PUBKEY_LEN