tor  0.4.1.0-alpha-dev
channel.h
Go to the documentation of this file.
1 /* * Copyright (c) 2012-2019, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
3 
9 #ifndef TOR_CHANNEL_H
10 #define TOR_CHANNEL_H
11 
12 #include "core/or/or.h"
13 #include "core/or/circuitmux.h"
14 #include "lib/container/handles.h"
16 
17 #include "tor_queue.h"
18 
19 #define tor_timer_t timeout
20 struct tor_timer_t;
21 
22 /* Channel handler function pointer typedefs */
23 typedef void (*channel_listener_fn_ptr)(channel_listener_t *, channel_t *);
24 typedef void (*channel_cell_handler_fn_ptr)(channel_t *, cell_t *);
25 typedef void (*channel_var_cell_handler_fn_ptr)(channel_t *, var_cell_t *);
26 
32 typedef enum {
33  CHANNEL_USED_NOT_USED_FOR_FULL_CIRCS = 0,
34  CHANNEL_USED_FOR_FULL_CIRCS,
35  CHANNEL_USED_FOR_USER_TRAFFIC,
37 
39 typedef enum {
46 #define circ_id_type_bitfield_t ENUM_BF(circ_id_type_t)
47 
48 /* channel states for channel_t */
49 
50 typedef enum {
51  /*
52  * Closed state - channel is inactive
53  *
54  * Permitted transitions from:
55  * - CHANNEL_STATE_CLOSING
56  * Permitted transitions to:
57  * - CHANNEL_STATE_OPENING
58  */
59  CHANNEL_STATE_CLOSED = 0,
60  /*
61  * Opening state - channel is trying to connect
62  *
63  * Permitted transitions from:
64  * - CHANNEL_STATE_CLOSED
65  * Permitted transitions to:
66  * - CHANNEL_STATE_CLOSING
67  * - CHANNEL_STATE_ERROR
68  * - CHANNEL_STATE_OPEN
69  */
70  CHANNEL_STATE_OPENING,
71  /*
72  * Open state - channel is active and ready for use
73  *
74  * Permitted transitions from:
75  * - CHANNEL_STATE_MAINT
76  * - CHANNEL_STATE_OPENING
77  * Permitted transitions to:
78  * - CHANNEL_STATE_CLOSING
79  * - CHANNEL_STATE_ERROR
80  * - CHANNEL_STATE_MAINT
81  */
82  CHANNEL_STATE_OPEN,
83  /*
84  * Maintenance state - channel is temporarily offline for subclass specific
85  * maintenance activities such as TLS renegotiation.
86  *
87  * Permitted transitions from:
88  * - CHANNEL_STATE_OPEN
89  * Permitted transitions to:
90  * - CHANNEL_STATE_CLOSING
91  * - CHANNEL_STATE_ERROR
92  * - CHANNEL_STATE_OPEN
93  */
94  CHANNEL_STATE_MAINT,
95  /*
96  * Closing state - channel is shutting down
97  *
98  * Permitted transitions from:
99  * - CHANNEL_STATE_MAINT
100  * - CHANNEL_STATE_OPEN
101  * Permitted transitions to:
102  * - CHANNEL_STATE_CLOSED,
103  * - CHANNEL_STATE_ERROR
104  */
105  CHANNEL_STATE_CLOSING,
106  /*
107  * Error state - channel has experienced a permanent error
108  *
109  * Permitted transitions from:
110  * - CHANNEL_STATE_CLOSING
111  * - CHANNEL_STATE_MAINT
112  * - CHANNEL_STATE_OPENING
113  * - CHANNEL_STATE_OPEN
114  * Permitted transitions to:
115  * - None
116  */
117  CHANNEL_STATE_ERROR,
118  /*
119  * Placeholder for maximum state value
120  */
121  CHANNEL_STATE_LAST
122 } channel_state_t;
123 
124 /* channel listener states for channel_listener_t */
125 
126 typedef enum {
127  /*
128  * Closed state - channel listener is inactive
129  *
130  * Permitted transitions from:
131  * - CHANNEL_LISTENER_STATE_CLOSING
132  * Permitted transitions to:
133  * - CHANNEL_LISTENER_STATE_LISTENING
134  */
135  CHANNEL_LISTENER_STATE_CLOSED = 0,
136  /*
137  * Listening state - channel listener is listening for incoming
138  * connections
139  *
140  * Permitted transitions from:
141  * - CHANNEL_LISTENER_STATE_CLOSED
142  * Permitted transitions to:
143  * - CHANNEL_LISTENER_STATE_CLOSING
144  * - CHANNEL_LISTENER_STATE_ERROR
145  */
146  CHANNEL_LISTENER_STATE_LISTENING,
147  /*
148  * Closing state - channel listener is shutting down
149  *
150  * Permitted transitions from:
151  * - CHANNEL_LISTENER_STATE_LISTENING
152  * Permitted transitions to:
153  * - CHANNEL_LISTENER_STATE_CLOSED,
154  * - CHANNEL_LISTENER_STATE_ERROR
155  */
156  CHANNEL_LISTENER_STATE_CLOSING,
157  /*
158  * Error state - channel listener has experienced a permanent error
159  *
160  * Permitted transitions from:
161  * - CHANNEL_STATE_CLOSING
162  * - CHANNEL_STATE_LISTENING
163  * Permitted transitions to:
164  * - None
165  */
166  CHANNEL_LISTENER_STATE_ERROR,
167  /*
168  * Placeholder for maximum state value
169  */
170  CHANNEL_LISTENER_STATE_LAST
171 } channel_listener_state_t;
172 
181 struct channel_s {
183  uint32_t magic;
184 
186  HT_ENTRY(channel_s) gidmap_node;
187 
189  HANDLE_ENTRY(channel, channel_s);
190 
192  channel_state_t state;
193 
198 
200  unsigned char registered:1;
201 
203  unsigned int has_been_open:1;
204 
214  unsigned int padding_enabled:1;
215 
218  unsigned int currently_padding:1;
219 
221  unsigned int pending_padding_callback:1;
222 
224  unsigned int is_canonical_to_peer:1;
225 
229 
232  monotime_coarse_t next_padding_time;
233 
235  struct tor_timer_t *padding_timer;
237  struct channel_handle_t *timer_handle;
238 
257  uint16_t padding_timeout_high_ms;
258 
261  enum {
262  CHANNEL_NOT_CLOSING = 0,
263  CHANNEL_CLOSE_REQUESTED,
264  CHANNEL_CLOSE_FROM_BELOW,
265  CHANNEL_CLOSE_FOR_ERROR
267 
269  enum {
270  /*
271  * The channel is not open, or it has a full output buffer but no queued
272  * cells.
273  */
274  SCHED_CHAN_IDLE = 0,
275  /*
276  * The channel has space on its output buffer to write, but no queued
277  * cells.
278  */
279  SCHED_CHAN_WAITING_FOR_CELLS,
280  /*
281  * The scheduler has queued cells but no output buffer space to write.
282  */
283  SCHED_CHAN_WAITING_TO_WRITE,
284  /*
285  * The scheduler has both queued cells and output buffer space, and is
286  * eligible for the scheduler loop.
287  */
288  SCHED_CHAN_PENDING
289  } scheduler_state;
290 
293 
295  time_t timestamp_created; /* Channel created */
296  time_t timestamp_active; /* Any activity */
297 
308  monotime_coarse_t timestamp_xfer;
309 
310  /* Methods implemented by the lower layer */
311 
313  void (*free_fn)(channel_t *);
315  void (*close)(channel_t *);
317  const char * (*describe_transport)(channel_t *);
319  void (*dumpstats)(channel_t *, int);
320 
322  channel_cell_handler_fn_ptr cell_handler;
323  channel_var_cell_handler_fn_ptr var_cell_handler;
324 
325  /* Methods implemented by the lower layer */
326 
332  /*
333  * Ask the underlying transport what the remote endpoint address is, in
334  * a tor_addr_t. This is optional and subclasses may leave this NULL.
335  * If they implement it, they should write the address out to the
336  * provided tor_addr_t *, and return 1 if successful or 0 if no address
337  * available.
338  */
339  int (*get_remote_addr)(channel_t *, tor_addr_t *);
340  int (*get_transport_name)(channel_t *chan, char **transport_out);
341 
342 #define GRD_FLAG_ORIGINAL 1
343 #define GRD_FLAG_ADDR_ONLY 2
344 
350  const char * (*get_remote_descr)(channel_t *, int);
359  int (*is_canonical)(channel_t *, int);
363  int (*matches_target)(channel_t *, const tor_addr_t *);
364  /* Ask the lower layer how many bytes it has queued but not yet sent */
365  size_t (*num_bytes_queued)(channel_t *);
366  /* Ask the lower layer how many cells can be written */
367  int (*num_cells_writeable)(channel_t *);
368  /* Write a cell to an open channel */
369  int (*write_cell)(channel_t *, cell_t *);
374 
395 
400  TOR_LIST_ENTRY(channel_s) next_with_same_id;
401 
404 
411  circ_id_type_bitfield_t circ_id_type:2;
412  /* DOCDOC */
413  unsigned wide_circ_ids:1;
414 
416  unsigned int num_n_circuits, num_p_circuits;
417 
425  unsigned int is_bad_for_new_circs:1;
426 
430  unsigned int is_client:1;
431 
433  unsigned int is_incoming:1;
434 
440  unsigned int is_local:1;
441 
445 
447  time_t timestamp_client; /* Client used this, according to relay.c */
448  time_t timestamp_recv; /* Cell received from lower layer */
449  time_t timestamp_xmit; /* Cell sent to lower layer */
450 
455 
459  uint64_t dirreq_id;
460 
462  uint64_t n_cells_recved, n_bytes_recved;
463  uint64_t n_cells_xmitted, n_bytes_xmitted;
464 };
465 
467  /* Current channel listener state */
468  channel_listener_state_t state;
469 
470  /* Globally unique ID number for a channel over the lifetime of a Tor
471  * process.
472  */
473  uint64_t global_identifier;
474 
476  unsigned char registered:1;
477 
480  enum {
481  CHANNEL_LISTENER_NOT_CLOSING = 0,
482  CHANNEL_LISTENER_CLOSE_REQUESTED,
483  CHANNEL_LISTENER_CLOSE_FROM_BELOW,
484  CHANNEL_LISTENER_CLOSE_FOR_ERROR
486 
488  time_t timestamp_created; /* Channel created */
489  time_t timestamp_active; /* Any activity */
490 
491  /* Methods implemented by the lower layer */
492 
498  const char * (*describe_transport)(channel_listener_t *);
500  void (*dumpstats)(channel_listener_t *, int);
501 
503  channel_listener_fn_ptr listener;
504 
507 
510 
512  uint64_t n_accepted;
513 };
514 
515 /* Channel state manipulations */
516 
517 int channel_state_is_valid(channel_state_t state);
518 int channel_listener_state_is_valid(channel_listener_state_t state);
519 
520 int channel_state_can_transition(channel_state_t from, channel_state_t to);
521 int channel_listener_state_can_transition(channel_listener_state_t from,
522  channel_listener_state_t to);
523 
524 const char * channel_state_to_string(channel_state_t state);
525 const char *
526 channel_listener_state_to_string(channel_listener_state_t state);
527 
528 /* Abstract channel operations */
529 
532 
534 
535 /* Channel callback registrations */
536 
537 /* Listener callback */
539  channel_listener_fn_ptr listener);
540 
541 /* Incoming cell callbacks */
542 channel_cell_handler_fn_ptr channel_get_cell_handler(channel_t *chan);
543 
544 channel_var_cell_handler_fn_ptr
546 
548  channel_cell_handler_fn_ptr cell_handler,
549  channel_var_cell_handler_fn_ptr
550  var_cell_handler);
551 
552 /* Clean up closed channels and channel listeners periodically; these are
553  * called from run_scheduled_events() in main.c.
554  */
555 void channel_run_cleanup(void);
557 
558 /* Close all channels and deallocate everything */
559 void channel_free_all(void);
560 
561 /* Dump some statistics in the log */
562 void channel_dumpstats(int severity);
563 void channel_listener_dumpstats(int severity);
564 
565 #ifdef TOR_CHANNEL_INTERNAL_
566 
567 #ifdef CHANNEL_PRIVATE_
568 
569 STATIC void channel_add_to_digest_map(channel_t *chan);
570 
571 #endif /* defined(CHANNEL_PRIVATE_) */
572 
573 /* Channel operations for subclasses and internal use only */
574 
575 /* Initialize a newly allocated channel - do this first in subclass
576  * constructors.
577  */
578 
579 void channel_init(channel_t *chan);
581 
582 /* Channel registration/unregistration */
583 void channel_register(channel_t *chan);
584 void channel_unregister(channel_t *chan);
585 
586 /* Channel listener registration/unregistration */
589 
590 /* Close from below */
593 void channel_closed(channel_t *chan);
594 
595 /* Free a channel */
596 void channel_free_(channel_t *chan);
597 #define channel_free(chan) FREE_AND_NULL(channel_t, channel_free_, (chan))
599 #define channel_listener_free(chan_l) \
600  FREE_AND_NULL(channel_listener_t, channel_listener_free_, (chan_l))
601 
602 /* State/metadata setters */
603 
604 void channel_change_state(channel_t *chan, channel_state_t to_state);
608 void channel_mark_local(channel_t *chan);
609 void channel_mark_incoming(channel_t *chan);
610 void channel_mark_outgoing(channel_t *chan);
611 void channel_mark_remote(channel_t *chan);
613  const char *identity_digest,
614  const struct ed25519_public_key_t *ed_identity);
615 
617  channel_listener_state_t to_state);
618 
619 /* Timestamp updates */
624 
628 
629 /* Incoming channel handling */
632  channel_t *incoming);
633 
634 /* Incoming cell handling */
635 void channel_process_cell(channel_t *chan, cell_t *cell);
636 
637 /* Request from lower layer for more cells if available */
638 MOCK_DECL(ssize_t, channel_flush_some_cells,
639  (channel_t *chan, ssize_t num_cells));
640 
641 /* Query if data available on this channel */
642 MOCK_DECL(int, channel_more_to_flush, (channel_t *chan));
643 
644 /* Notify flushed outgoing for dirreq handling */
646 
647 /* Handle stuff we need to do on open like notifying circuits */
649 
650 #endif /* defined(TOR_CHANNEL_INTERNAL_) */
651 
652 /* Helper functions to perform operations on channels */
653 
654 int channel_send_destroy(circid_t circ_id, channel_t *chan,
655  int reason);
656 
657 /*
658  * Outside abstract interfaces that should eventually get turned into
659  * something transport/address format independent.
660  */
661 
662 channel_t * channel_connect(const tor_addr_t *addr, uint16_t port,
663  const char *rsa_id_digest,
664  const struct ed25519_public_key_t *ed_id);
665 
666 channel_t * channel_get_for_extend(const char *rsa_id_digest,
667  const struct ed25519_public_key_t *ed_id,
668  const tor_addr_t *target_addr,
669  const char **msg_out,
670  int *launch_out);
671 
672 /* Ask which of two channels is better for circuit-extension purposes */
674 
678 channel_t * channel_find_by_global_id(uint64_t global_identifier);
679 channel_t * channel_find_by_remote_identity(const char *rsa_id_digest,
680  const struct ed25519_public_key_t *ed_id);
681 
686 
687 /*
688  * Helper macros to lookup state of given channel.
689  */
690 
691 #define CHANNEL_IS_CLOSED(chan) (channel_is_in_state((chan), \
692  CHANNEL_STATE_CLOSED))
693 #define CHANNEL_IS_OPENING(chan) (channel_is_in_state((chan), \
694  CHANNEL_STATE_OPENING))
695 #define CHANNEL_IS_OPEN(chan) (channel_is_in_state((chan), \
696  CHANNEL_STATE_OPEN))
697 #define CHANNEL_IS_MAINT(chan) (channel_is_in_state((chan), \
698  CHANNEL_STATE_MAINT))
699 #define CHANNEL_IS_CLOSING(chan) (channel_is_in_state((chan), \
700  CHANNEL_STATE_CLOSING))
701 #define CHANNEL_IS_ERROR(chan) (channel_is_in_state((chan), \
702  CHANNEL_STATE_ERROR))
703 
704 #define CHANNEL_FINISHED(chan) (CHANNEL_IS_CLOSED(chan) || \
705  CHANNEL_IS_ERROR(chan))
706 
707 #define CHANNEL_CONDEMNED(chan) (CHANNEL_IS_CLOSING(chan) || \
708  CHANNEL_FINISHED(chan))
709 
710 #define CHANNEL_CAN_HANDLE_CELLS(chan) (CHANNEL_IS_OPENING(chan) || \
711  CHANNEL_IS_OPEN(chan) || \
712  CHANNEL_IS_MAINT(chan))
713 
714 static inline int
715 channel_is_in_state(channel_t *chan, channel_state_t state)
716 {
717  return chan->state == state;
718 }
719 
720 /*
721  * Metadata queries/updates
722  */
723 
724 const char * channel_describe_transport(channel_t *chan);
725 MOCK_DECL(void, channel_dump_statistics, (channel_t *chan, int severity));
726 void channel_dump_transport_statistics(channel_t *chan, int severity);
727 const char * channel_get_actual_remote_descr(channel_t *chan);
728 const char * channel_get_actual_remote_address(channel_t *chan);
729 MOCK_DECL(int, channel_get_addr_if_possible, (channel_t *chan,
730  tor_addr_t *addr_out));
737 int channel_is_client(const channel_t *chan);
738 int channel_is_local(channel_t *chan);
739 int channel_is_incoming(channel_t *chan);
740 int channel_is_outgoing(channel_t *chan);
741 void channel_mark_client(channel_t *chan);
742 void channel_clear_client(channel_t *chan);
743 int channel_matches_extend_info(channel_t *chan, extend_info_t *extend_info);
745  const tor_addr_t *target);
746 unsigned int channel_num_circuits(channel_t *chan);
747 MOCK_DECL(void,channel_set_circid_type,(channel_t *chan,
748  crypto_pk_t *identity_rcvd,
749  int consider_identity));
751 
754  int severity);
756  int severity);
758 
759 void channel_update_bad_for_new_circs(const char *digest, int force);
760 
761 /* Flow control queries */
763 
764 /* Timestamp queries */
765 time_t channel_when_created(channel_t *chan);
766 time_t channel_when_last_client(channel_t *chan);
767 time_t channel_when_last_xmit(channel_t *chan);
768 
769 /* Counter queries */
771  const packed_cell_t *packed_cell,
772  circid_t *circid_out);
773 
774 /* Declare the handle helpers */
775 HANDLE_DECL(channel, channel_s,)
776 #define channel_handle_free(h) \
777  FREE_AND_NULL(channel_handle_t, channel_handle_free_, (h))
778 #undef tor_timer_t
779 
780 #endif /* !defined(TOR_CHANNEL_H) */
channel_state_t state
Definition: channel.h:192
void(* close)(channel_t *)
Definition: channel.h:315
void channel_timestamp_recv(channel_t *chan)
Definition: channel.c:3224
int channel_listener_state_can_transition(channel_listener_state_t from, channel_listener_state_t to)
Definition: channel.c:283
circ_id_type_bitfield_t circ_id_type
Definition: channel.h:411
enum channel_s::@8 reason_for_closing
int channel_write_packed_cell(channel_t *chan, packed_cell_t *cell)
Definition: channel.c:1470
int(* has_queued_writes)(channel_t *)
Definition: channel.h:352
uint64_t n_cells_recved
Definition: channel.h:462
void channel_change_state(channel_t *chan, channel_state_t to_state)
Definition: channel.c:1598
const char * channel_listener_describe_transport(channel_listener_t *chan_l)
Definition: channel.c:2505
void channel_mark_client(channel_t *chan)
Definition: channel.c:2926
channel_t * channel_get_for_extend(const char *rsa_id_digest, const ed25519_public_key_t *ed_id, const tor_addr_t *target_addr, const char **msg_out, int *launch_out)
Definition: channel.c:2383
void channel_update_bad_for_new_circs(const char *digest, int force)
Definition: channel.c:3457
void channel_timestamp_active(channel_t *chan)
Definition: channel.c:3157
void channel_listener_dumpstats(int severity)
Definition: channel.c:2088
void channel_change_state_open(channel_t *chan)
Definition: channel.c:1608
void channel_close_for_error(channel_t *chan)
Definition: channel.c:1241
HANDLE_ENTRY(channel, channel_s)
const char * channel_state_to_string(channel_state_t state)
Definition: channel.c:315
int channel_is_incoming(channel_t *chan)
Definition: channel.c:2983
Definition: cell_st.h:12
void channel_set_cell_handlers(channel_t *chan, channel_cell_handler_fn_ptr cell_handler, channel_var_cell_handler_fn_ptr var_cell_handler)
Definition: channel.c:1093
time_t timestamp_created
Definition: channel.h:295
struct channel_handle_t * timer_handle
Definition: channel.h:237
TOR_LIST_ENTRY(channel_s) next_with_same_id
unsigned int channel_num_circuits(channel_t *chan)
Definition: channel.c:3335
channel_t * channel_next_with_rsa_identity(channel_t *chan)
Definition: channel.c:731
int channel_send_destroy(circid_t circ_id, channel_t *chan, int reason)
Definition: channel.c:2017
uint64_t n_accepted
Definition: channel.h:512
time_t channel_when_last_xmit(channel_t *chan)
Definition: channel.c:3288
void channel_timestamp_client(channel_t *chan)
Definition: channel.c:3208
void channel_listener_timestamp_active(channel_listener_t *chan_l)
Definition: channel.c:3174
void(* dumpstats)(channel_listener_t *, int)
Definition: channel.h:500
void channel_close_from_lower_layer(channel_t *chan)
Definition: channel.c:1213
void channel_dump_transport_statistics(channel_t *chan, int severity)
Definition: channel.c:2771
Macros for C weak-handle implementation.
int(* write_packed_cell)(channel_t *, packed_cell_t *)
Definition: channel.h:371
unsigned int is_local
Definition: channel.h:440
void channel_check_for_duplicates(void)
Definition: channel.c:748
unsigned int num_n_circuits
Definition: channel.h:416
channel_usage_info_t channel_usage
Definition: channel.h:228
void channel_free_(channel_t *chan)
Definition: channel.c:876
int channel_matches_target_addr_for_extend(channel_t *chan, const tor_addr_t *target)
Definition: channel.c:3318
int(* matches_extend_info)(channel_t *, extend_info_t *)
Definition: channel.h:361
time_t timestamp_accepted
Definition: channel.h:509
void(* dumpstats)(channel_t *, int)
Definition: channel.h:319
circuitmux_t * cmux
Definition: channel.h:403
time_t channel_when_last_client(channel_t *chan)
Definition: channel.c:3277
void channel_listener_timestamp_created(channel_listener_t *chan_l)
Definition: channel.c:3137
int packed_cell_is_destroy(channel_t *chan, const packed_cell_t *packed_cell, circid_t *circid_out)
Definition: channel.c:1991
unsigned char registered
Definition: channel.h:200
struct tor_timer_t * padding_timer
Definition: channel.h:235
unsigned int is_canonical_to_peer
Definition: channel.h:224
channel_usage_info_t
Definition: channel.h:32
time_t timestamp_created
Definition: channel.h:488
unsigned int is_incoming
Definition: channel.h:433
struct ed25519_public_key_t ed25519_identity
Definition: channel.h:394
int sched_heap_idx
Definition: channel.h:292
void channel_listener_mark_for_close(channel_listener_t *chan_l)
Definition: channel.c:1173
channel_var_cell_handler_fn_ptr channel_get_var_cell_handler(channel_t *chan)
Definition: channel.c:1076
const char * channel_get_actual_remote_address(channel_t *chan)
Definition: channel.c:2819
void channel_process_cell(channel_t *chan, cell_t *cell)
Definition: channel.c:1962
void(* free_fn)(channel_listener_t *)
Definition: channel.h:494
int channel_is_local(channel_t *chan)
Definition: channel.c:3014
void channel_listener_run_cleanup(void)
Definition: channel.c:2145
void channel_mark_for_close(channel_t *chan)
Definition: channel.c:1134
void channel_listener_dump_statistics(channel_listener_t *chan_l, int severity)
Definition: channel.c:2705
void channel_mark_incoming(channel_t *chan)
Definition: channel.c:2997
int channel_is_better(channel_t *a, channel_t *b)
Definition: channel.c:2323
channel_t * channel_find_by_remote_identity(const char *rsa_id_digest, const ed25519_public_key_t *ed_id)
Definition: channel.c:697
uint16_t padding_timeout_low_ms
Definition: channel.h:256
uint32_t magic
Definition: channel.h:183
unsigned int padding_enabled
Definition: channel.h:214
int channel_is_outgoing(channel_t *chan)
Definition: channel.c:3060
void channel_mark_bad_for_new_circs(channel_t *chan)
Definition: channel.c:2898
int channel_is_canonical(channel_t *chan)
Definition: channel.c:2953
STATIC void channel_add_to_digest_map(channel_t *chan)
Definition: channel.c:560
enum channel_listener_s::@10 reason_for_closing
#define DIGEST_LEN
Definition: digest_sizes.h:20
channel_t * channel_find_by_global_id(uint64_t global_identifier)
Definition: channel.c:650
void channel_listener_queue_incoming(channel_listener_t *listener, channel_t *incoming)
Definition: channel.c:1911
Master header file for Tor-specific functionality.
circ_id_type_t
Definition: channel.h:39
void channel_listener_free_(channel_listener_t *chan_l)
Definition: channel.c:928
unsigned int currently_padding
Definition: channel.h:218
const char * channel_listener_state_to_string(channel_listener_state_t state)
Definition: channel.c:350
unsigned int is_bad_for_new_circs
Definition: channel.h:425
void channel_mark_remote(channel_t *chan)
Definition: channel.c:3045
Header for crypto_ed25519.c.
void channel_listener_change_state(channel_listener_t *chan_l, channel_listener_state_t to_state)
Definition: channel.c:1625
time_t channel_when_created(channel_t *chan)
Definition: channel.c:3266
void channel_listener_timestamp_accepted(channel_listener_t *chan_l)
Definition: channel.c:3191
int channel_is_bad_for_new_circs(channel_t *chan)
Definition: channel.c:2885
time_t timestamp_client
Definition: channel.h:447
time_t timestamp_last_had_circuits
Definition: channel.h:454
const char * channel_describe_transport(channel_t *chan)
Definition: channel.c:2490
void channel_clear_identity_digest(channel_t *chan)
Definition: channel.c:1299
unsigned int has_been_open
Definition: channel.h:203
void channel_listener_process_incoming(channel_listener_t *listener)
Definition: channel.c:1793
void channel_clear_remote_end(channel_t *chan)
Definition: channel.c:1387
void channel_do_open_actions(channel_t *chan)
Definition: channel.c:1845
void channel_init_listener(channel_listener_t *chan_l)
Definition: channel.c:860
void channel_notify_flushed(channel_t *chan)
Definition: channel.c:1776
void channel_register(channel_t *chan)
Definition: channel.c:386
void channel_mark_local(channel_t *chan)
Definition: channel.c:3029
int channel_matches_extend_info(channel_t *chan, extend_info_t *extend_info)
Definition: channel.c:3302
HT_ENTRY(channel_s) gidmap_node
monotime_coarse_t next_padding_time
Definition: channel.h:232
double(* get_overhead_estimate)(channel_t *)
Definition: channel.h:331
int channel_listener_state_is_valid(channel_listener_state_t state)
Definition: channel.c:210
int(* is_canonical)(channel_t *, int)
Definition: channel.h:359
void channel_init(channel_t *chan)
Definition: channel.c:823
void channel_mark_outgoing(channel_t *chan)
Definition: channel.c:3074
int(* write_var_cell)(channel_t *, var_cell_t *)
Definition: channel.h:373
Header file for circuitmux.c.
enum channel_s::@9 scheduler_state
void channel_listener_dump_transport_statistics(channel_listener_t *chan_l, int severity)
Definition: channel.c:2784
unsigned int pending_padding_callback
Definition: channel.h:221
void channel_listener_set_listener_fn(channel_listener_t *chan, channel_listener_fn_ptr listener)
Definition: channel.c:1036
uint64_t dirreq_id
Definition: channel.h:459
smartlist_t * incoming_list
Definition: channel.h:506
void channel_listener_unregister(channel_listener_t *chan_l)
Definition: channel.c:524
uint32_t circid_t
Definition: or.h:608
channel_cell_handler_fn_ptr channel_get_cell_handler(channel_t *chan)
Definition: channel.c:1059
void channel_dumpstats(int severity)
Definition: channel.c:2057
ratelim_t last_warned_circ_ids_exhausted
Definition: channel.h:444
monotime_coarse_t timestamp_xfer
Definition: channel.h:308
int(* matches_target)(channel_t *, const tor_addr_t *)
Definition: channel.h:363
const char * channel_get_actual_remote_descr(channel_t *chan)
Definition: channel.c:2803
void channel_free_all(void)
Definition: channel.c:2232
channel_t * channel_connect(const tor_addr_t *addr, uint16_t port, const char *id_digest, const ed25519_public_key_t *ed_id)
Definition: channel.c:2305
int channel_is_canonical_is_reliable(channel_t *chan)
Definition: channel.c:2968
unsigned char registered
Definition: channel.h:476
int channel_has_queued_writes(channel_t *chan)
Definition: channel.c:2869
#define MOCK_DECL(rv, funcname, arglist)
Definition: testsupport.h:94
void(* free_fn)(channel_t *)
Definition: channel.h:313
int channel_state_can_transition(channel_state_t from, channel_state_t to)
Definition: channel.c:237
unsigned int is_client
Definition: channel.h:430
void channel_unregister(channel_t *chan)
Definition: channel.c:444
void channel_timestamp_created(channel_t *chan)
Definition: channel.c:3121
void channel_timestamp_xmit(channel_t *chan)
Definition: channel.c:3244
char identity_digest[DIGEST_LEN]
Definition: channel.h:384
void channel_run_cleanup(void)
Definition: channel.c:2119
void channel_set_identity_digest(channel_t *chan, const char *identity_digest, const ed25519_public_key_t *ed_identity)
Definition: channel.c:1328
void channel_clear_client(channel_t *chan)
Definition: channel.c:2939
const char * channel_get_canonical_remote_descr(channel_t *chan)
Definition: channel.c:2836
channel_listener_fn_ptr listener
Definition: channel.h:503
void channel_closed(channel_t *chan)
Definition: channel.c:1268
void(* close)(channel_listener_t *)
Definition: channel.h:496
int channel_num_cells_writeable(channel_t *chan)
Definition: channel.c:3091
int channel_is_client(const channel_t *chan)
Definition: channel.c:2913
channel_cell_handler_fn_ptr cell_handler
Definition: channel.h:322
uint64_t global_identifier
Definition: channel.h:197
void channel_listener_register(channel_listener_t *chan_l)
Definition: channel.c:483