tor
master
|
Header file for channel.c. More...
Go to the source code of this file.
Data Structures | |
struct | channel_s |
struct | channel_listener_s |
Typedefs | |
typedef void(* | channel_listener_fn_ptr) (channel_listener_t *, channel_t *) |
typedef void(* | channel_cell_handler_fn_ptr) (channel_t *, cell_t *) |
typedef void(* | channel_var_cell_handler_fn_ptr) (channel_t *, var_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 } |
Header file for channel.c.
#define CHANNEL_CAN_HANDLE_CELLS | ( | chan | ) |
#define CHANNEL_CONDEMNED | ( | chan | ) |
#define CHANNEL_FINISHED | ( | chan | ) |
#define CHANNEL_IS_CLOSED | ( | chan | ) |
#define CHANNEL_IS_CLOSING | ( | chan | ) |
#define CHANNEL_IS_ERROR | ( | chan | ) |
#define CHANNEL_IS_MAINT | ( | chan | ) |
#define CHANNEL_IS_OPEN | ( | chan | ) |
#define CHANNEL_IS_OPENING | ( | chan | ) |
enum 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().
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.
void channel_clear_client | ( | channel_t * | chan | ) |
Clear the client flag.
Mark a channel as being not from a client.
channel_t* channel_connect | ( | const tor_addr_t * | addr, |
uint16_t | port, | ||
const char * | id_digest, | ||
const ed25519_public_key_t * | ed_id | ||
) |
Connect to a given addr/port/digest.
This sets up a new outgoing channel; in the future if multiple channel_t subclasses are available, this is where the selection policy should go. It may also be desirable to fold port into tor_addr_t or make a new type including a tor_addr_t and port, so we have a single abstract object encapsulating all the protocol details of how to contact an OR.
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.
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.
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.
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.
channel_t* channel_find_by_remote_identity | ( | const char * | rsa_id_digest, |
const ed25519_public_key_t * | ed_id | ||
) |
Find channel by RSA/Ed25519 identity of of the remote endpoint.
This function looks up a channel by the digest of its remote endpoint's RSA identity key. If ed_id is provided and nonzero, only a channel matching the ed_id will be returned.
It's possible that more than one channel to a given endpoint exists. Use channel_next_with_rsa_identity() to walk the list of channels; make sure to test for Ed25519 identity match too (as appropriate)
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.
const char* channel_get_actual_remote_address | ( | channel_t * | chan | ) |
Return the text address of the remote endpoint.
Subsequent calls to channel_get_{actual,canonical}_remote_{address,descr} may invalidate the return value from this function.
const char* channel_get_actual_remote_descr | ( | channel_t * | chan | ) |
Return text description of the remote endpoint.
This function return a test provided by the lower layer of the remote endpoint for this channel; it should specify the actual address connected to/from.
Subsequent calls to channel_get_{actual,canonical}_remote_{address,descr} may invalidate the return value from this function.
const char* channel_get_canonical_remote_descr | ( | channel_t * | chan | ) |
Return text description of the remote endpoint canonical address.
This function return a test provided by the lower layer of the remote endpoint for this channel; it should use the known canonical address for this OR's identity digest if possible.
Subsequent calls to channel_get_{actual,canonical}_remote_{address,descr} may invalidate the return value from this function.
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.
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 | ||
) |
Get a channel to extend a circuit.
Pick a suitable channel to extend a circuit to given the desired digest the address we believe is correct for that digest; this tries to see if we already have one for the requested endpoint, but if there is no good channel, set *msg_out to a message describing the channel's state and our next action, and set *launch_out to a boolean indicated whether the caller should try to launch a new channel with channel_connect().
channel_var_cell_handler_fn_ptr channel_get_var_cell_handler | ( | channel_t * | chan | ) |
Return the variable-length cell handler for a channel.
This function gets the handler for incoming variable-length cells installed on a channel.
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.
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.
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
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.
int channel_is_canonical_is_reliable | ( | channel_t * | chan | ) |
Test if the canonical flag is reliable.
This function asks if the lower layer thinks it's safe to trust the result of channel_is_canonical().
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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).
int channel_listener_state_is_valid | ( | channel_listener_state_t | state | ) |
Indicate whether a given channel listener state is valid.
const char* channel_listener_state_to_string | ( | channel_listener_state_t | state | ) |
Return a human-readable description for a channel listener state.
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.
void channel_mark_client | ( | channel_t * | chan | ) |
Set the client flag.
Mark a channel as being from a client.
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.
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.
int channel_matches_target_addr_for_extend | ( | channel_t * | chan, |
const tor_addr_t * | target | ||
) |
Check if a channel matches a given target address; return true iff we do.
This function calls into the lower layer and asks if this channel thinks it matches a given target address for circuit extension purposes.
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.
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.
unsigned int channel_num_circuits | ( | channel_t * | chan | ) |
Return the total number of circuits used by a channel.
chan | Channel to query |
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.
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.
void channel_set_cell_handlers | ( | channel_t * | chan, |
channel_cell_handler_fn_ptr | cell_handler, | ||
channel_var_cell_handler_fn_ptr | var_cell_handler | ||
) |
Set both cell handlers for a channel.
This function sets both the fixed-length and variable length cell handlers for a channel.
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).
const char* channel_state_to_string | ( | channel_state_t | state | ) |
Return a human-readable description for a channel state.
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.
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).
time_t channel_when_created | ( | channel_t * | chan | ) |
Query created timestamp for a channel.
time_t channel_when_last_client | ( | channel_t * | chan | ) |
Query client timestamp.
time_t channel_when_last_xmit | ( | channel_t * | chan | ) |
Query xmit timestamp.
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.
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.