tor  master
Macros | Functions | Variables
command.c File Reference

Functions for processing incoming cells. More...

#include "or.h"
#include "channel.h"
#include "circuitbuild.h"
#include "circuitlist.h"
#include "command.h"
#include "connection.h"
#include "connection_or.h"
#include "config.h"
#include "control.h"
#include "cpuworker.h"
#include "crypto_util.h"
#include "dos.h"
#include "hibernate.h"
#include "nodelist.h"
#include "onion.h"
#include "rephist.h"
#include "relay.h"
#include "router.h"
#include "routerlist.h"
Include dependency graph for command.c:

Macros

#define PROCESS_CELL(tp, cl, cn)   command_process_ ## tp ## _cell(cl, cn)
 

Functions

const char * cell_command_to_string (uint8_t command)
 
void command_process_cell (channel_t *chan, cell_t *cell)
 
void command_process_var_cell (channel_t *chan, var_cell_t *var_cell)
 
void command_setup_channel (channel_t *chan)
 
void command_setup_listener (channel_listener_t *listener)
 

Variables

uint64_t stats_n_create_cells_processed = 0
 
uint64_t stats_n_created_cells_processed = 0
 
uint64_t stats_n_relay_cells_processed = 0
 
uint64_t stats_n_destroy_cells_processed = 0
 

Detailed Description

Functions for processing incoming cells.

When we receive a cell from a client or a relay, it arrives on some channel, and tells us what to do with it. In this module, we dispatch based on the cell type using the functions command_process_cell() and command_process_var_cell(), and deal with the cell accordingly. (These handlers are installed on a channel with the command_setup_channel() function.)

Channels have a chance to handle some cell types on their own before they are ever passed here — typically, they do this for cells that are specific to a given channel type. For example, in channeltls.c, the cells for the initial connection handshake are handled before we get here. (Of course, the fact that there is only one channel type for now means that we may have gotten the factoring wrong here.)

Handling other cell types is mainly farmed off to other modules, after initial sanity-checking. CREATE* cells are handled ultimately in onion.c, CREATED* cells trigger circuit creation in circuitbuild.c, DESTROY cells are handled here (since they're simple), and RELAY cells, in all their complexity, are passed off to relay.c.

Function Documentation

◆ cell_command_to_string()

const char* cell_command_to_string ( uint8_t  command)

Convert the cell command into a lower-case, human-readable string.

◆ command_process_cell()

void command_process_cell ( channel_t chan,
cell_t cell 
)

Process a cell that was just received on chan. 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.

Here is the caller graph for this function:

◆ command_process_var_cell()

void command_process_var_cell ( channel_t chan,
var_cell_t var_cell 
)

Process an incoming var_cell from a channel; in the current protocol all the var_cells are handshake-related and handled below the channel layer, so this just logs a warning and drops the cell.

Here is the caller graph for this function:

◆ command_setup_channel()

void command_setup_channel ( channel_t chan)

Given a channel, install the right handlers to process incoming cells on it.

Here is the call graph for this function:

◆ command_setup_listener()

void command_setup_listener ( channel_listener_t listener)

Given a listener, install the right handler to process incoming channels on it.

Here is the caller graph for this function:

Variable Documentation

◆ stats_n_create_cells_processed

uint64_t stats_n_create_cells_processed = 0

How many CELL_CREATE cells have we received, ever?

◆ stats_n_created_cells_processed

uint64_t stats_n_created_cells_processed = 0

How many CELL_CREATED cells have we received, ever?

◆ stats_n_destroy_cells_processed

uint64_t stats_n_destroy_cells_processed = 0

How many CELL_DESTROY cells have we received, ever?

◆ stats_n_relay_cells_processed

uint64_t stats_n_relay_cells_processed = 0

How many CELL_RELAY cells have we received, ever?