Comand.c: 包含处理incoming cell的函数。
void command_process_cell(channel_t *chan, cell_t *cell);
command_process_cell()函数根据cell->command的类型,分别调用4中不同的函数。
switch (cell->command) {
case CELL_CREATE:
case CELL_CREATE_FAST:
case CELL_CREATE2:
++stats_n_create_cells_processed;
PROCESS_CELL(create, cell, chan);
break;
case CELL_CREATED:
case CELL_CREATED_FAST:
case CELL_CREATED2:
++stats_n_created_cells_processed;
PROCESS_CELL(created, cell, chan);
break;
case CELL_RELAY:
case CELL_RELAY_EARLY:
++stats_n_relay_cells_processed;
PROCESS_CELL(relay, cell, chan);
break;
case CELL_DESTROY:
++stats_n_destroy_cells_processed;
PROCESS_CELL(destroy, cell, chan);
break;
default:
log_fn(LOG_INFO, LD_PROTOCOL,
"Cell of unknown or unexpected type (%d) received. "
"Dropping.",
cell->command);
break;
}
当收到的cell->command为CELL_RELAY 或者 CELL_RELAY_EARLY是调用下面的内部函数。
static void
command_process_relay_cell(cell_t *cell, channel_t *chan)
command_process_relay_cell函数调用/src/core/or/relay.c模块的circuit_receive_relay_cell()函数(circuit层函数)。
if ((reason = circuit_receive_relay_cell(cell, circ, direction)) < 0) {
...
...
...
}