Tor
0.4.7.0-alpha-dev
|
Functions for processing incoming cells. More...
#include "core/or/or.h"
#include "app/config/config.h"
#include "core/crypto/onion_crypto.h"
#include "core/mainloop/connection.h"
#include "core/mainloop/cpuworker.h"
#include "core/or/channel.h"
#include "core/or/circuitbuild.h"
#include "core/or/circuitlist.h"
#include "core/or/command.h"
#include "core/or/connection_or.h"
#include "core/or/dos.h"
#include "core/or/onion.h"
#include "core/or/relay.h"
#include "feature/control/control_events.h"
#include "feature/hibernate/hibernate.h"
#include "feature/nodelist/describe.h"
#include "feature/nodelist/nodelist.h"
#include "feature/nodelist/routerlist.h"
#include "feature/relay/circuitbuild_relay.h"
#include "feature/relay/routermode.h"
#include "feature/stats/rephist.h"
#include "lib/crypt_ops/crypto_util.h"
#include "core/or/cell_st.h"
#include "core/or/or_circuit_st.h"
#include "core/or/origin_circuit_st.h"
#include "core/or/var_cell_st.h"
Go to the source code of this file.
Macros | |
#define | PROCESS_CELL(tp, cl, cn) command_process_ ## tp ## _cell(cl, cn) |
Functions | |
static void | command_handle_incoming_channel (channel_listener_t *listener, channel_t *chan) |
static void | command_process_create_cell (cell_t *cell, channel_t *chan) |
static void | command_process_created_cell (cell_t *cell, channel_t *chan) |
static void | command_process_relay_cell (cell_t *cell, channel_t *chan) |
static void | command_process_destroy_cell (cell_t *cell, channel_t *chan) |
const char * | cell_command_to_string (uint8_t command) |
void | command_process_cell (channel_t *chan, cell_t *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 |
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.
Definition in file command.c.
const char* cell_command_to_string | ( | uint8_t | command | ) |
|
static |
Callback to handle a new channel; call command_setup_channel() to give it the right cell handlers.
Definition at line 677 of file command.c.
Referenced by command_setup_listener().
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.
Definition at line 149 of file command.c.
Referenced by command_setup_channel().
Process a 'create' cell that just arrived from chan. Make a new circuit with the p_circ_id specified in cell. Put the circuit in state onionskin_pending, and pass the onionskin to the cpuworker. Circ will get picked up again when the cpuworker finishes decrypting it.
Process a 'created' cell that just arrived from chan. Find the circuit that it's intended for. If we're not the origin of the circuit, package the 'created' cell in an 'extended' relay cell and pass it back. If we are the origin of the circuit, send it to circuit_finish_handshake() to finish processing keys, and then call circuit_send_next_onion_skin() to extend to the next hop in the circuit if necessary.
Process a 'destroy' cell that just arrived from chan. Find the circ that it refers to (if any).
If the circ is in state onionskin_pending, then call onion_pending_remove() to remove it from the pending onion list (note that if it's already being processed by the cpuworker, it won't be in the list anymore; but when the cpuworker returns it, the circuit will be gone, and the cpuworker response will be dropped).
Then mark the circuit for close (which marks all edges for close, and passes the destroy cell onward if necessary).
Process a 'relay' or 'relay_early' cell that just arrived from conn. Make sure it came in with a recognized circ_id. Pass it on to circuit_receive_relay_cell() for actual processing.
We need to figure out of this is a v2 or v3 RP circuit to count it appropriately. v2 services always use the TAP legacy handshake to connect to the RP; we use this feature to distinguish between v2/v3.
void command_setup_channel | ( | channel_t * | chan | ) |
Given a channel, install the right handlers to process incoming cells on it.
Definition at line 690 of file command.c.
Referenced by channel_connect_for_circuit(), and command_handle_incoming_channel().
void command_setup_listener | ( | channel_listener_t * | listener | ) |
Given a listener, install the right handler to process incoming channels on it.
Definition at line 703 of file command.c.
Referenced by connection_tls_start_handshake().
uint64_t stats_n_create_cells_processed = 0 |
uint64_t stats_n_created_cells_processed = 0 |
uint64_t stats_n_destroy_cells_processed = 0 |