Tor  0.4.7.0-alpha-dev
Macros | Functions | Variables
channeltls.h File Reference

Header file for channeltls.c. More...

#include "core/or/or.h"
#include "core/or/channel.h"

Go to the source code of this file.

Macros

#define TLS_PER_CELL_OVERHEAD   29
 
#define BASE_CHAN_TO_TLS(c)   (channel_tls_from_base((c)))
 
#define TLS_CHAN_TO_BASE(c)   (channel_tls_to_base((c)))
 
#define CONST_BASE_CHAN_TO_TLS(c)   (channel_tls_from_base_const((c)))
 
#define CONST_TLS_CHAN_TO_BASE(c)   (channel_tls_to_base_const((c)))
 
#define TLS_CHAN_MAGIC   0x8a192427U
 

Functions

channel_tchannel_tls_connect (const tor_addr_t *addr, uint16_t port, const char *id_digest, const struct ed25519_public_key_t *ed_id)
 
channel_listener_tchannel_tls_get_listener (void)
 
channel_listener_tchannel_tls_start_listener (void)
 
channel_tchannel_tls_handle_incoming (or_connection_t *orconn)
 
channel_tchannel_tls_to_base (channel_tls_t *tlschan)
 
channel_tls_t * channel_tls_from_base (channel_t *chan)
 
const channel_tchannel_tls_to_base_const (const channel_tls_t *tlschan)
 
const channel_tls_t * channel_tls_from_base_const (const channel_t *chan)
 
void channel_tls_handle_cell (cell_t *cell, or_connection_t *conn)
 
void channel_tls_handle_state_change_on_orconn (channel_tls_t *chan, or_connection_t *conn, uint8_t state)
 
void channel_tls_handle_var_cell (var_cell_t *var_cell, or_connection_t *conn)
 
void channel_tls_update_marks (or_connection_t *conn)
 
void channel_tls_free_all (void)
 

Variables

uint64_t stats_n_authorize_cells_processed
 
uint64_t stats_n_authenticate_cells_processed
 
uint64_t stats_n_versions_cells_processed
 
uint64_t stats_n_netinfo_cells_processed
 
uint64_t stats_n_vpadding_cells_processed
 
uint64_t stats_n_certs_cells_processed
 
uint64_t stats_n_auth_challenge_cells_processed
 

Detailed Description

Header file for channeltls.c.

Definition in file channeltls.h.

Function Documentation

◆ channel_tls_free_all()

void channel_tls_free_all ( void  )

Free everything on shutdown.

Not much to do here, since channel_free_all() takes care of a lot, but let's get rid of the listener.

Definition at line 297 of file channeltls.c.

◆ channel_tls_from_base()

channel_tls_t* channel_tls_from_base ( channel_t chan)

Cast a channel_t to a channel_tls_t, with appropriate type-checking asserts.

Definition at line 408 of file channeltls.c.

Referenced by channel_tls_from_base_const().

◆ channel_tls_from_base_const()

const channel_tls_t* channel_tls_from_base_const ( const channel_t chan)

Cast a const channel_t to a const channel_tls_t, with appropriate type-checking asserts.

Definition at line 431 of file channeltls.c.

◆ channel_tls_get_listener()

channel_listener_t* channel_tls_get_listener ( void  )

Return the current channel_tls_t listener.

Returns the current channel listener for incoming TLS connections, or NULL if none has been established

Definition at line 254 of file channeltls.c.

Referenced by connection_tls_start_handshake().

◆ channel_tls_handle_cell()

void channel_tls_handle_cell ( cell_t cell,
or_connection_t conn 
)

Handle an incoming cell on a channel_tls_t.

This is called from connection_or.c to handle an arriving cell; it checks for cell types specific to the handshake for this transport protocol and handles them, and queues all other cells to the channel_t layer, which eventually will hand them off to command.c.

The channel layer itself decides whether the cell should be queued or can be handed off immediately to the upper-layer code. It is responsible for copying in the case that it queues; we merely pass pointers through which we get from connection_or_process_cells_from_inbuf().

Definition at line 1066 of file channeltls.c.

◆ channel_tls_handle_incoming()

channel_t* channel_tls_handle_incoming ( or_connection_t orconn)

Create a new channel around an incoming or_connection_t.

Definition at line 329 of file channeltls.c.

Referenced by connection_tls_start_handshake().

◆ channel_tls_handle_state_change_on_orconn()

void channel_tls_handle_state_change_on_orconn ( channel_tls_t *  chan,
or_connection_t conn,
uint8_t  state 
)

Handle an orconn state change.

This function will be called by connection_or.c when the or_connection_t associated with this channel_tls_t changes state.

Definition at line 963 of file channeltls.c.

Referenced by connection_or_change_state().

◆ channel_tls_handle_var_cell()

void channel_tls_handle_var_cell ( var_cell_t var_cell,
or_connection_t conn 
)

Handle an incoming variable-length cell on a channel_tls_t.

Process a var_cell that was just received on conn. Keep internal statistics about how many of each cell we've processed so far this second, and the total number of microseconds it took to process each type of cell. All the var_cell commands are handshake- related and live below the channel_t layer, so no variable-length cells ever get delivered in the current implementation, but I've left the mechanism in place for future use.

If we were handing them off to the upper layer, the channel_t queueing code would be responsible for memory management, and we'd just be passing pointers through from connection_or_process_cells_from_inbuf(). That caller always frees them after this function returns, so this function should never free var_cell.

Definition at line 1182 of file channeltls.c.

◆ channel_tls_start_listener()

channel_listener_t* channel_tls_start_listener ( void  )

Start a channel_tls_t listener if necessary.

Return the current channel_tls_t listener, or start one if we haven't yet, and return that.

Definition at line 266 of file channeltls.c.

Referenced by connection_tls_start_handshake().

◆ channel_tls_to_base()

channel_t* channel_tls_to_base ( channel_tls_t *  tlschan)

Cast a channel_tls_t to a channel_t.

Definition at line 396 of file channeltls.c.

Referenced by channel_tls_to_base_const(), and connection_or_client_learned_peer_id().

◆ channel_tls_to_base_const()

const channel_t* channel_tls_to_base_const ( const channel_tls_t *  tlschan)

Cast a const channel_tls_t to a const channel_t.

Definition at line 421 of file channeltls.c.

◆ channel_tls_update_marks()

void channel_tls_update_marks ( or_connection_t conn)

Update channel marks after connection_or.c has changed an address.

This is called from connection_or_init_conn_from_address() after the connection's _base.addr or real_addr fields have potentially been changed so we can recalculate the local mark. Notably, this happens when incoming connections are reverse-proxied and we only learn the real address of the remote router by looking it up in the consensus after we finish the handshake and know an authenticated identity digest.

Definition at line 1356 of file channeltls.c.

Variable Documentation

◆ stats_n_auth_challenge_cells_processed

uint64_t stats_n_auth_challenge_cells_processed
extern

How many CELL_AUTH_CHALLENGE cells have we received, ever?

Definition at line 91 of file channeltls.c.

◆ stats_n_authenticate_cells_processed

uint64_t stats_n_authenticate_cells_processed
extern

How many CELL_AUTHENTICATE cells have we received, ever?

Definition at line 93 of file channeltls.c.

◆ stats_n_authorize_cells_processed

uint64_t stats_n_authorize_cells_processed
extern

How many CELL_AUTHORIZE cells have we received, ever?

Definition at line 95 of file channeltls.c.

◆ stats_n_certs_cells_processed

uint64_t stats_n_certs_cells_processed
extern

How many CELL_CERTS cells have we received, ever?

Definition at line 89 of file channeltls.c.

◆ stats_n_netinfo_cells_processed

uint64_t stats_n_netinfo_cells_processed
extern

How many CELL_NETINFO cells have we received, ever?

Definition at line 85 of file channeltls.c.

◆ stats_n_versions_cells_processed

uint64_t stats_n_versions_cells_processed
extern

How many CELL_VERSIONS cells have we received, ever?

Definition at line 83 of file channeltls.c.

◆ stats_n_vpadding_cells_processed

uint64_t stats_n_vpadding_cells_processed
extern

How many CELL_VPADDING cells have we received, ever?

Definition at line 87 of file channeltls.c.