Tor 0.4.9.1-alpha-dev
Data Structures | Macros | Typedefs | Enumerations | Functions
channel.h File Reference

Header file for channel.c. More...

#include "core/or/or.h"
#include "core/or/circuitmux.h"
#include "lib/container/handles.h"
#include "lib/crypt_ops/crypto_ed25519.h"
#include "ext/ht.h"
#include "tor_queue.h"

Go to the source code of this file.

Data Structures

struct  channel_t
 
struct  channel_listener_t
 

Macros

#define tor_timer_t   timeout
 
#define circ_id_type_bitfield_t   ENUM_BF(circ_id_type_t)
 
#define CHANNEL_IS_CLOSED(chan)
 
#define CHANNEL_IS_OPENING(chan)
 
#define CHANNEL_IS_OPEN(chan)
 
#define CHANNEL_IS_MAINT(chan)
 
#define CHANNEL_IS_CLOSING(chan)
 
#define CHANNEL_IS_ERROR(chan)
 
#define CHANNEL_FINISHED(chan)
 
#define CHANNEL_CONDEMNED(chan)
 
#define CHANNEL_CAN_HANDLE_CELLS(chan)
 
#define channel_handle_free(h)    FREE_AND_NULL(channel_handle_t, channel_handle_free_, (h))
 

Typedefs

typedef void(* channel_listener_fn_ptr) (channel_listener_t *, channel_t *)
 
typedef void(* channel_cell_handler_fn_ptr) (channel_t *, cell_t *)
 

Enumerations

enum  channel_usage_info_t { CHANNEL_USED_NOT_USED_FOR_FULL_CIRCS = 0 , CHANNEL_USED_FOR_FULL_CIRCS , CHANNEL_USED_FOR_USER_TRAFFIC }
 
enum  circ_id_type_t { CIRC_ID_TYPE_LOWER =0 , CIRC_ID_TYPE_HIGHER =1 , CIRC_ID_TYPE_NEITHER =2 }
 
enum  channel_state_t {
  CHANNEL_STATE_CLOSED = 0 , CHANNEL_STATE_OPENING , CHANNEL_STATE_OPEN , CHANNEL_STATE_MAINT ,
  CHANNEL_STATE_CLOSING , CHANNEL_STATE_ERROR , CHANNEL_STATE_LAST
}
 
enum  channel_listener_state_t {
  CHANNEL_LISTENER_STATE_CLOSED = 0 , CHANNEL_LISTENER_STATE_LISTENING , CHANNEL_LISTENER_STATE_CLOSING , CHANNEL_LISTENER_STATE_ERROR ,
  CHANNEL_LISTENER_STATE_LAST
}
 

Functions

int channel_state_is_valid (channel_state_t state)
 
int channel_listener_state_is_valid (channel_listener_state_t state)
 
int channel_state_can_transition (channel_state_t from, channel_state_t to)
 
int channel_listener_state_can_transition (channel_listener_state_t from, channel_listener_state_t to)
 
const char * channel_state_to_string (channel_state_t state)
 
const char * channel_listener_state_to_string (channel_listener_state_t state)
 
void channel_mark_for_close (channel_t *chan)
 
int channel_write_packed_cell (channel_t *chan, packed_cell_t *cell)
 
void channel_listener_mark_for_close (channel_listener_t *chan_l)
 
void channel_mark_as_used_for_origin_circuit (channel_t *chan)
 
void channel_listener_set_listener_fn (channel_listener_t *chan, channel_listener_fn_ptr listener)
 
channel_cell_handler_fn_ptr channel_get_cell_handler (channel_t *chan)
 
void channel_set_cell_handlers (channel_t *chan, channel_cell_handler_fn_ptr cell_handler)
 
void channel_run_cleanup (void)
 
void channel_listener_run_cleanup (void)
 
void channel_free_all (void)
 
void channel_dumpstats (int severity)
 
void channel_listener_dumpstats (int severity)
 
int channel_send_destroy (circid_t circ_id, channel_t *chan, int reason)
 
channel_tchannel_connect (const tor_addr_t *addr, uint16_t port, const char *rsa_id_digest, const struct ed25519_public_key_t *ed_id)
 
channel_tchannel_get_for_extend (const char *rsa_id_digest, const struct 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_is_better (channel_t *a, channel_t *b)
 
channel_tchannel_find_by_global_id (uint64_t global_identifier)
 
channel_tchannel_find_by_remote_identity (const char *rsa_id_digest, const struct ed25519_public_key_t *ed_id)
 
channel_tchannel_next_with_rsa_identity (channel_t *chan)
 
static int channel_is_in_state (channel_t *chan, channel_state_t state)
 
const char * channel_describe_transport (channel_t *chan)
 
void channel_dump_statistics (channel_t *chan, int severity)
 
void channel_dump_transport_statistics (channel_t *chan, int severity)
 
int channel_get_addr_if_possible (const channel_t *chan, tor_addr_t *addr_out)
 
const char * channel_describe_peer (channel_t *chan)
 
int channel_has_queued_writes (channel_t *chan)
 
int channel_is_bad_for_new_circs (channel_t *chan)
 
void channel_mark_bad_for_new_circs (channel_t *chan)
 
int channel_is_canonical (channel_t *chan)
 
int channel_is_client (const channel_t *chan)
 
int channel_is_local (channel_t *chan)
 
int channel_is_incoming (channel_t *chan)
 
int channel_is_outgoing (channel_t *chan)
 
void channel_mark_client (channel_t *chan)
 
void channel_clear_client (channel_t *chan)
 
int channel_matches_extend_info (channel_t *chan, extend_info_t *extend_info)
 
int channel_remote_identity_matches (const channel_t *chan, const char *rsa_id_digest, const ed25519_public_key_t *ed_id)
 
unsigned int channel_num_circuits (channel_t *chan)
 
void channel_set_circid_type (channel_t *chan, crypto_pk_t *identity_rcvd, int consider_identity)
 
void channel_timestamp_client (channel_t *chan)
 
const char * channel_listener_describe_transport (channel_listener_t *chan_l)
 
void channel_listener_dump_statistics (channel_listener_t *chan_l, int severity)
 
void channel_listener_dump_transport_statistics (channel_listener_t *chan_l, int severity)
 
void channel_check_for_duplicates (void)
 
void channel_update_bad_for_new_circs (const char *digest, int force)
 
int channel_num_cells_writeable (channel_t *chan)
 
time_t channel_when_created (channel_t *chan)
 
time_t channel_when_last_client (channel_t *chan)
 
time_t channel_when_last_xmit (channel_t *chan)
 
int packed_cell_is_destroy (channel_t *chan, const packed_cell_t *packed_cell, circid_t *circid_out)
 

Detailed Description

Header file for channel.c.

Definition in file channel.h.

Macro Definition Documentation

◆ CHANNEL_CAN_HANDLE_CELLS

#define CHANNEL_CAN_HANDLE_CELLS (   chan)
Value:
(CHANNEL_IS_OPENING(chan) || \
CHANNEL_IS_OPEN(chan) || \
CHANNEL_IS_MAINT(chan))

Definition at line 707 of file channel.h.

◆ CHANNEL_CONDEMNED

#define CHANNEL_CONDEMNED (   chan)
Value:
(CHANNEL_IS_CLOSING(chan) || \
CHANNEL_FINISHED(chan))

Definition at line 704 of file channel.h.

◆ CHANNEL_FINISHED

#define CHANNEL_FINISHED (   chan)
Value:
(CHANNEL_IS_CLOSED(chan) || \
CHANNEL_IS_ERROR(chan))

Definition at line 701 of file channel.h.

◆ channel_handle_free

#define channel_handle_free (   h)     FREE_AND_NULL(channel_handle_t, channel_handle_free_, (h))

Definition at line 771 of file channel.h.

◆ CHANNEL_IS_CLOSED

#define CHANNEL_IS_CLOSED (   chan)
Value:
(channel_is_in_state((chan), \
@ CHANNEL_STATE_CLOSED
Definition: channel.h:59

Definition at line 688 of file channel.h.

◆ CHANNEL_IS_CLOSING

#define CHANNEL_IS_CLOSING (   chan)
Value:
(channel_is_in_state((chan), \
@ CHANNEL_STATE_CLOSING
Definition: channel.h:105

Definition at line 696 of file channel.h.

◆ CHANNEL_IS_ERROR

#define CHANNEL_IS_ERROR (   chan)
Value:
(channel_is_in_state((chan), \
@ CHANNEL_STATE_ERROR
Definition: channel.h:117

Definition at line 698 of file channel.h.

◆ CHANNEL_IS_MAINT

#define CHANNEL_IS_MAINT (   chan)
Value:
(channel_is_in_state((chan), \
@ CHANNEL_STATE_MAINT
Definition: channel.h:94

Definition at line 694 of file channel.h.

◆ CHANNEL_IS_OPEN

#define CHANNEL_IS_OPEN (   chan)
Value:
(channel_is_in_state((chan), \
@ CHANNEL_STATE_OPEN
Definition: channel.h:82

Definition at line 692 of file channel.h.

◆ CHANNEL_IS_OPENING

#define CHANNEL_IS_OPENING (   chan)
Value:
(channel_is_in_state((chan), \
@ CHANNEL_STATE_OPENING
Definition: channel.h:70

Definition at line 690 of file channel.h.

◆ circ_id_type_bitfield_t

#define circ_id_type_bitfield_t   ENUM_BF(circ_id_type_t)

Definition at line 46 of file channel.h.

◆ tor_timer_t

typedef struct timeout tor_timer_t   timeout

Definition at line 20 of file channel.h.

Typedef Documentation

◆ channel_cell_handler_fn_ptr

typedef void(* channel_cell_handler_fn_ptr) (channel_t *, cell_t *)

Definition at line 25 of file channel.h.

◆ channel_listener_fn_ptr

typedef void(* channel_listener_fn_ptr) (channel_listener_t *, channel_t *)

Definition at line 24 of file channel.h.

Enumeration Type Documentation

◆ channel_listener_state_t

Enumerator
CHANNEL_LISTENER_STATE_CLOSED 

Closed state - channel listener is inactive

Permitted transitions from:

  • CHANNEL_LISTENER_STATE_CLOSING Permitted transitions to:
  • CHANNEL_LISTENER_STATE_LISTENING
CHANNEL_LISTENER_STATE_LISTENING 

Listening state - channel listener is listening for incoming connections

Permitted transitions from:

  • CHANNEL_LISTENER_STATE_CLOSED Permitted transitions to:
  • CHANNEL_LISTENER_STATE_CLOSING
  • CHANNEL_LISTENER_STATE_ERROR
CHANNEL_LISTENER_STATE_CLOSING 

Closing state - channel listener is shutting down

Permitted transitions from:

  • CHANNEL_LISTENER_STATE_LISTENING Permitted transitions to:
  • CHANNEL_LISTENER_STATE_CLOSED,
  • CHANNEL_LISTENER_STATE_ERROR
CHANNEL_LISTENER_STATE_ERROR 

Error state - channel listener has experienced a permanent error

Permitted transitions from:

  • CHANNEL_STATE_CLOSING
  • CHANNEL_STATE_LISTENING Permitted transitions to:
  • None
CHANNEL_LISTENER_STATE_LAST 

Placeholder for maximum state value

Definition at line 126 of file channel.h.

◆ channel_state_t

Enumerator
CHANNEL_STATE_CLOSED 

Closed state - channel is inactive

Permitted transitions from:

  • CHANNEL_STATE_CLOSING Permitted transitions to:
  • CHANNEL_STATE_OPENING
CHANNEL_STATE_OPENING 

Opening state - channel is trying to connect

Permitted transitions from:

  • CHANNEL_STATE_CLOSED Permitted transitions to:
  • CHANNEL_STATE_CLOSING
  • CHANNEL_STATE_ERROR
  • CHANNEL_STATE_OPEN
CHANNEL_STATE_OPEN 

Open state - channel is active and ready for use

Permitted transitions from:

  • CHANNEL_STATE_MAINT
  • CHANNEL_STATE_OPENING Permitted transitions to:
  • CHANNEL_STATE_CLOSING
  • CHANNEL_STATE_ERROR
  • CHANNEL_STATE_MAINT
CHANNEL_STATE_MAINT 

Maintenance state - channel is temporarily offline for subclass specific maintenance activities such as TLS renegotiation.

Permitted transitions from:

  • CHANNEL_STATE_OPEN Permitted transitions to:
  • CHANNEL_STATE_CLOSING
  • CHANNEL_STATE_ERROR
  • CHANNEL_STATE_OPEN
CHANNEL_STATE_CLOSING 

Closing state - channel is shutting down

Permitted transitions from:

  • CHANNEL_STATE_MAINT
  • CHANNEL_STATE_OPEN Permitted transitions to:
  • CHANNEL_STATE_CLOSED,
  • CHANNEL_STATE_ERROR
CHANNEL_STATE_ERROR 

Error state - channel has experienced a permanent error

Permitted transitions from:

  • CHANNEL_STATE_CLOSING
  • CHANNEL_STATE_MAINT
  • CHANNEL_STATE_OPENING
  • CHANNEL_STATE_OPEN Permitted transitions to:
  • None
CHANNEL_STATE_LAST 

Placeholder for maximum state value

Definition at line 50 of file channel.h.

◆ channel_usage_info_t

This enum is used by channelpadding to decide when to pad channels. Don't add values to it without updating the checks in channelpadding_decide_to_pad_channel().

Definition at line 32 of file channel.h.

◆ circ_id_type_t

Possible rules for generating circuit IDs on an OR connection.

Enumerator
CIRC_ID_TYPE_LOWER 

Pick from 0..1<<15-1.

CIRC_ID_TYPE_HIGHER 

Pick from 1<<15..1<<16-1.

CIRC_ID_TYPE_NEITHER 

The other side of a connection is an OP: never create circuits to it, and let it use any circuit ID it wants.

Definition at line 39 of file channel.h.

Function Documentation

◆ channel_check_for_duplicates()

void channel_check_for_duplicates ( void  )

Relays run this once an hour to look over our list of channels to other relays. It prints out some statistics if there are multiple connections to many relays.

This function is similar to connection_or_set_bad_connections(), and probably could be adapted to replace it, if it was modified to actually take action on any of these connections.

Definition at line 749 of file channel.c.

◆ channel_clear_client()

void channel_clear_client ( channel_t chan)

Clear the client flag.

Mark a channel as being not from a client.

Definition at line 2944 of file channel.c.

◆ channel_describe_peer()

const char * channel_describe_peer ( channel_t chan)

Return text description of the remote endpoint canonical address.

This function returns a human-readable string for logging; nothing should parse it or rely on a particular format.

Subsequent calls to this function may invalidate its return value.

Definition at line 2840 of file channel.c.

◆ channel_describe_transport()

const char * channel_describe_transport ( channel_t chan)

Describe the transport subclass for a channel.

Invoke a method to get a string description of the lower-layer transport for this channel.

Definition at line 2515 of file channel.c.

Referenced by channel_dump_statistics().

◆ channel_dump_statistics()

void channel_dump_statistics ( channel_t chan,
int  severity 
)

Dump channel statistics.

Dump statistics for one channel to the log.

Definition at line 2544 of file channel.c.

◆ channel_dump_transport_statistics()

void channel_dump_transport_statistics ( channel_t chan,
int  severity 
)

Invoke transport-specific stats dump for channel.

If there is a lower-layer statistics dump method, invoke it.

Definition at line 2810 of file channel.c.

◆ channel_dumpstats()

void channel_dumpstats ( int  severity)

Dump channel statistics to the log.

This is called from dumpstats() in main.c and spams the log with statistics on channels.

Definition at line 2078 of file channel.c.

◆ channel_find_by_global_id()

channel_t * channel_find_by_global_id ( uint64_t  global_identifier)

Channel lookups

Find channel by global ID.

This function searches for a channel by the global_identifier assigned at initialization time. This identifier is unique for the lifetime of the Tor process.

Definition at line 651 of file channel.c.

Referenced by circuitmux_set_policy().

◆ channel_free_all()

void channel_free_all ( void  )

Close all channels and free everything.

This gets called from tor_free_all() in main.c to clean up on exit. It will close all registered channels and free associated storage, then free the all_channels, active_channels, listening_channels and finished_channels lists and also channel_identity_map.

Definition at line 2253 of file channel.c.

◆ channel_get_addr_if_possible()

int channel_get_addr_if_possible ( const channel_t chan,
tor_addr_t addr_out 
)

Get the remote address for this channel, if possible.

Write the remote address out to a tor_addr_t if the underlying transport supports this operation, and return 1. Return 0 if the underlying transport doesn't let us do this.

Always returns the "real" address of the peer – the one we're connected to on the internet.

Definition at line 2860 of file channel.c.

Referenced by channel_do_open_actions(), and channel_dump_statistics().

◆ channel_get_cell_handler()

channel_cell_handler_fn_ptr channel_get_cell_handler ( channel_t chan)

Return the fixed-length cell handler for a channel.

This function gets the handler for incoming fixed-length cells installed on a channel.

Definition at line 1090 of file channel.c.

◆ channel_has_queued_writes()

int channel_has_queued_writes ( channel_t chan)

Return true iff the channel has any cells on the connection outbuf waiting to be sent onto the network.

Definition at line 2874 of file channel.c.

◆ channel_is_bad_for_new_circs()

int channel_is_bad_for_new_circs ( channel_t chan)

Check the is_bad_for_new_circs flag.

This function returns the is_bad_for_new_circs flag of the specified channel.

Definition at line 2890 of file channel.c.

Referenced by channel_is_better(), and connection_or_is_bad_for_new_circs().

◆ channel_is_better()

int channel_is_better ( channel_t a,
channel_t b 
)

Decide which of two channels to prefer for extending a circuit.

This function is called while extending a circuit and returns true iff a is 'better' than b. The most important criterion here is that a canonical channel is always better than a non-canonical one, but the number of circuits and the age are used as tie-breakers.

This is based on the former connection_or_is_better() of connection_or.c

Definition at line 2344 of file channel.c.

◆ channel_is_canonical()

int channel_is_canonical ( channel_t chan)

Get the canonical flag for a channel.

This returns the is_canonical for a channel; this flag is determined by the lower layer and can't be set in a transport-independent way.

Definition at line 2958 of file channel.c.

Referenced by channel_is_better().

◆ channel_is_client()

int channel_is_client ( const channel_t chan)

Get the client flag.

This returns the client flag of a channel, which will be set if command_process_create_cell() in command.c thinks this is a connection from a client.

Definition at line 2918 of file channel.c.

Referenced by channel_do_open_actions(), and circuit_expire_old_circuits_serverside().

◆ channel_is_in_state()

static int channel_is_in_state ( channel_t chan,
channel_state_t  state 
)
inlinestatic

Definition at line 712 of file channel.h.

◆ channel_is_incoming()

int channel_is_incoming ( channel_t chan)

Test incoming flag.

This function gets the incoming flag; this is set when a listener spawns a channel. If this returns true the channel was remotely initiated.

Definition at line 2973 of file channel.c.

◆ channel_is_local()

int channel_is_local ( channel_t chan)

Test local flag.

This function gets the local flag; the lower layer should set this when setting up the channel if is_local_addr() is true for all of the destinations it will communicate with on behalf of this channel. It's used to decide whether to declare the network reachable when seeing incoming traffic on the channel.

Definition at line 3004 of file channel.c.

◆ channel_is_outgoing()

int channel_is_outgoing ( channel_t chan)

Test outgoing flag.

This function gets the outgoing flag; this is the inverse of the incoming bit set when a listener spawns a channel. If this returns true the channel was locally initiated.

Definition at line 3050 of file channel.c.

Referenced by channel_do_open_actions(), and channel_set_circid_type().

◆ channel_listener_describe_transport()

const char * channel_listener_describe_transport ( channel_listener_t chan_l)

Describe the transport subclass for a channel listener.

Invoke a method to get a string description of the lower-layer transport for this channel listener.

Definition at line 2530 of file channel.c.

Referenced by channel_listener_dump_statistics().

◆ channel_listener_dump_statistics()

void channel_listener_dump_statistics ( channel_listener_t chan_l,
int  severity 
)

Dump channel listener statistics.

Dump statistics for one channel listener to the log.

Definition at line 2744 of file channel.c.

◆ channel_listener_dump_transport_statistics()

void channel_listener_dump_transport_statistics ( channel_listener_t chan_l,
int  severity 
)

Invoke transport-specific stats dump for channel listener.

If there is a lower-layer statistics dump method, invoke it.

Definition at line 2823 of file channel.c.

Referenced by channel_listener_dump_statistics().

◆ channel_listener_dumpstats()

void channel_listener_dumpstats ( int  severity)

Dump channel listener statistics to the log.

This is called from dumpstats() in main.c and spams the log with statistics on channel listeners.

Definition at line 2109 of file channel.c.

◆ channel_listener_mark_for_close()

void channel_listener_mark_for_close ( channel_listener_t chan_l)

Mark a channel listener for closure.

This function tries to close a channel_listener_t; it will go into the CLOSING state, and eventually the lower layer should put it into the CLOSED or ERROR state. Then, channel_run_cleanup() will eventually free it.

Definition at line 1181 of file channel.c.

◆ channel_listener_run_cleanup()

void channel_listener_run_cleanup ( void  )

Clean up channel listeners.

This gets called periodically from run_scheduled_events() in main.c; it cleans up after closed channel listeners.

Definition at line 2166 of file channel.c.

Referenced by postloop_cleanup_cb().

◆ channel_listener_set_listener_fn()

void channel_listener_set_listener_fn ( channel_listener_t chan_l,
channel_listener_fn_ptr  listener 
)

Set the listener for a channel listener.

This function sets the handler for new incoming channels on a channel listener.

Definition at line 1067 of file channel.c.

Referenced by command_setup_listener().

◆ channel_listener_state_can_transition()

int channel_listener_state_can_transition ( channel_listener_state_t  from,
channel_listener_state_t  to 
)

Indicate whether a channel listener state transition is valid.

This function takes two channel listener states and indicates whether a transition between them is permitted (see the state definitions and transition table in or.h at the channel_listener_state_t typedef).

Definition at line 284 of file channel.c.

Referenced by channel_listener_change_state().

◆ channel_listener_state_is_valid()

int channel_listener_state_is_valid ( channel_listener_state_t  state)

Indicate whether a given channel listener state is valid.

Definition at line 211 of file channel.c.

Referenced by channel_listener_change_state().

◆ channel_listener_state_to_string()

const char * channel_listener_state_to_string ( channel_listener_state_t  state)

Return a human-readable description for a channel listener state.

Definition at line 351 of file channel.c.

Referenced by channel_listener_dump_statistics().

◆ channel_mark_as_used_for_origin_circuit()

void channel_mark_as_used_for_origin_circuit ( channel_t chan)

Set the potentially_used_for_bootstrapping flag on the or_connection_t corresponding to the provided channel.

This flag indicates that if the connection fails, it might be interesting to the bootstrapping subsystem. (The bootstrapping system only cares about channels that we have tried to use for our own circuits. Other channels may have been launched in response to EXTEND cells from somebody else, and if they fail, it won't necessarily indicate a bootstrapping problem.)

Definition at line 391 of file channeltls.c.

◆ channel_mark_bad_for_new_circs()

void channel_mark_bad_for_new_circs ( channel_t chan)

Mark a channel as bad for new circuits.

Set the is_bad_for_new_circs_flag on chan.

Definition at line 2903 of file channel.c.

◆ channel_mark_client()

void channel_mark_client ( channel_t chan)

Set the client flag.

Mark a channel as being from a client.

Definition at line 2931 of file channel.c.

◆ channel_mark_for_close()

void channel_mark_for_close ( channel_t chan)

Mark a channel for closure.

This function tries to close a channel_t; it will go into the CLOSING state, and eventually the lower layer should put it into the CLOSED or ERROR state. Then, channel_run_cleanup() will eventually free it.

Definition at line 1142 of file channel.c.

Referenced by channel_flush_from_first_active_circuit(), and channel_tls_listener_close_method().

◆ channel_matches_extend_info()

int channel_matches_extend_info ( channel_t chan,
extend_info_t extend_info 
)

Check if a channel matches an extend_info_t.

This function calls the lower layer and asks if this channel matches a given extend_info_t.

NOTE that this function only checks for an address/port match, and should be used only when no identity is available.

Definition at line 3295 of file channel.c.

Referenced by circuit_get_all_pending_on_channel().

◆ channel_next_with_rsa_identity()

channel_t * channel_next_with_rsa_identity ( channel_t chan)

For things returned by channel_find_by_remote_digest(), walk the list. The RSA key will match for all returned elements; the Ed25519 key might not.

Get next channel with digest.

This function takes a channel and finds the next channel in the list with the same digest.

Definition at line 732 of file channel.c.

Referenced by channel_get_for_extend().

◆ channel_num_cells_writeable()

int channel_num_cells_writeable ( channel_t chan)

Estimate the number of writeable cells.

Ask the lower layer for an estimate of how many cells it can accept.

Definition at line 3081 of file channel.c.

◆ channel_num_circuits()

unsigned int channel_num_circuits ( channel_t chan)

Return the total number of circuits used by a channel.

Parameters
chanChannel to query
Returns
Number of circuits using this as n_chan or p_chan

Definition at line 3341 of file channel.c.

Referenced by channel_is_better(), and connection_or_get_num_circuits().

◆ channel_remote_identity_matches()

int channel_remote_identity_matches ( const channel_t chan,
const char *  rsa_id_digest,
const ed25519_public_key_t ed_id 
)

Return true iff chan matches rsa_id_digest and ed_id. as its identity keys. If either is NULL, do not check for a match.

Definition at line 668 of file channel.c.

◆ channel_run_cleanup()

void channel_run_cleanup ( void  )

Clean up channels.

This gets called periodically from run_scheduled_events() in main.c; it cleans up after closed channels.

Definition at line 2140 of file channel.c.

Referenced by postloop_cleanup_cb().

◆ channel_send_destroy()

int channel_send_destroy ( circid_t  circ_id,
channel_t chan,
int  reason 
)

Send destroy cell on a channel.

Write a destroy cell with circ ID circ_id and reason reason onto channel chan. Don't perform range-checking on reason: we may want to propagate reasons from other cells.

Definition at line 2038 of file channel.c.

◆ channel_set_cell_handlers()

void channel_set_cell_handlers ( channel_t chan,
channel_cell_handler_fn_ptr  cell_handler 
)

Set both cell handlers for a channel.

This function sets both the fixed-length and variable length cell handlers for a channel.

Definition at line 1107 of file channel.c.

Referenced by command_setup_channel().

◆ channel_set_circid_type()

void channel_set_circid_type ( channel_t chan,
crypto_pk_t identity_rcvd,
int  consider_identity 
)

Set up circuit ID generation.

This is called when setting up a channel and replaces the old connection_or_set_circid_type().

Definition at line 3358 of file channel.c.

◆ channel_state_can_transition()

int channel_state_can_transition ( channel_state_t  from,
channel_state_t  to 
)

Indicate whether a channel state transition is valid.

This function takes two channel states and indicates whether a transition between them is permitted (see the state definitions and transition table in or.h at the channel_state_t typedef).

Definition at line 238 of file channel.c.

Referenced by channel_change_state_().

◆ channel_state_is_valid()

int channel_state_is_valid ( channel_state_t  state)

Indicate whether a given channel state is valid.

Definition at line 186 of file channel.c.

Referenced by channel_change_state_().

◆ channel_state_to_string()

const char * channel_state_to_string ( channel_state_t  state)

Return a human-readable description for a channel state.

Definition at line 316 of file channel.c.

Referenced by channel_dump_statistics().

◆ channel_timestamp_client()

void channel_timestamp_client ( channel_t chan)

Update client timestamp.

This function is called by relay.c to timestamp a channel that appears to be used as a client.

Definition at line 3198 of file channel.c.

◆ channel_update_bad_for_new_circs()

void channel_update_bad_for_new_circs ( const char *  digest,
int  force 
)

Go through all the channels (or if digest is non-NULL, just the OR connections with that digest), and set the is_bad_for_new_circs flag based on the rules in connection_or_group_set_badness() (or just always set it if force is true).

Definition at line 3463 of file channel.c.

Referenced by second_elapsed_callback().

◆ channel_when_created()

time_t channel_when_created ( channel_t chan)

Query created timestamp for a channel.

Definition at line 3256 of file channel.c.

Referenced by channel_is_better().

◆ channel_when_last_client()

time_t channel_when_last_client ( channel_t chan)

Query client timestamp.

Definition at line 3267 of file channel.c.

Referenced by connection_or_client_used().

◆ channel_when_last_xmit()

time_t channel_when_last_xmit ( channel_t chan)

Query xmit timestamp.

Definition at line 3278 of file channel.c.

Referenced by circuit_expire_old_circuits_serverside().

◆ channel_write_packed_cell()

int channel_write_packed_cell ( channel_t chan,
packed_cell_t cell 
)

Write a packed cell to a channel.

Write a packed cell to a channel using the write_cell() method. This is called by the transport-independent code to deliver a packed cell to a channel for transmission.

Return 0 on success else a negative value. In both cases, the caller should not access the cell anymore, it is freed both on success and error.

Definition at line 1489 of file channel.c.

Referenced by channel_flush_from_first_active_circuit().

◆ packed_cell_is_destroy()

int packed_cell_is_destroy ( channel_t chan,
const packed_cell_t packed_cell,
circid_t circid_out 
)

If packed_cell on chan is a destroy cell, then set *circid_out to its circuit ID, and return true. Otherwise, return false.

Definition at line 2012 of file channel.c.