|
Tor 0.5.0.0-alpha-dev
|
Functions to queue create cells, and parse and create the CREATE cell and its allies. More...
#include "core/or/or.h"#include "app/config/config.h"#include "core/crypto/onion_crypto.h"#include "core/crypto/onion_fast.h"#include "core/crypto/onion_ntor.h"#include "core/or/onion.h"#include "feature/nodelist/networkstatus.h"#include "core/or/cell_st.h"#include "trunnel/ed25519_cert.h"Go to the source code of this file.
Macros | |
| #define | NTOR_CREATE_MAGIC "ntorNTORntorNTOR" |
Functions | |
| static int | check_create_cell (const create_cell_t *cell, int unknown_ok) |
| void | create_cell_init (create_cell_t *cell_out, uint8_t cell_type, uint16_t handshake_type, uint16_t handshake_len, const uint8_t *onionskin) |
| static int | parse_create2_payload (create_cell_t *cell_out, const uint8_t *p, size_t p_len) |
| int | create_cell_parse (create_cell_t *cell_out, const cell_t *cell_in) |
| static int | check_created_cell (const created_cell_t *cell) |
| int | created_cell_parse (created_cell_t *cell_out, const cell_t *cell_in) |
| static int | check_extend_cell (const extend_cell_t *cell) |
| static int | create_cell_from_create2_cell_body (create_cell_t *cell_out, const create2_cell_body_t *cell) |
| static int | extend_cell_from_extend2_cell_body (extend_cell_t *cell_out, const extend2_cell_body_t *cell) |
| int | extend_cell_parse (extend_cell_t *cell_out, const uint8_t command, const uint8_t *payload, size_t payload_length) |
| static int | check_extended_cell (const extended_cell_t *cell) |
| int | extended_cell_parse (extended_cell_t *cell_out, const uint8_t command, const uint8_t *payload, size_t payload_len) |
| static int | create_cell_format_impl (cell_t *cell_out, const create_cell_t *cell_in, int relayed) |
| int | create_cell_format (cell_t *cell_out, const create_cell_t *cell_in) |
| int | create_cell_format_relayed (cell_t *cell_out, const create_cell_t *cell_in) |
| int | created_cell_format (cell_t *cell_out, const created_cell_t *cell_in) |
| static int | should_include_ed25519_id_extend_cells (const networkstatus_t *ns, const or_options_t *options) |
| int | extend_cell_format (uint8_t *command_out, uint16_t *len_out, uint8_t *payload_out, const extend_cell_t *cell_in) |
| int | extended_cell_format (uint8_t *command_out, uint16_t *len_out, uint8_t *payload_out, const extended_cell_t *cell_in) |
Functions to queue create cells, and parse and create the CREATE cell and its allies.
This module has a few functions, all related to the CREATE/CREATED handshake that we use on links in order to create a circuit, and the related EXTEND/EXTENDED handshake that we use over circuits in order to extend them an additional hop.
Clients invoke these functions when creating or extending a circuit, from circuitbuild.c.
Relays invoke these functions when they receive a CREATE or EXTEND cell in command.c or relay.c, in order to queue the pending request. They also invoke them from cpuworker.c, which handles dispatching onionskin requests to different worker threads.
This module also handles:
Definition in file onion.c.
| #define NTOR_CREATE_MAGIC "ntorNTORntorNTOR" |
Magic string which, in a CREATE or EXTEND cell, indicates that a seeming TAP payload is really an ntor payload. We'd do away with this if every relay supported EXTEND2, but we want to be able to extend from A to B with ntor even when A doesn't understand EXTEND2 and so can't generate a CREATE2 cell.
|
static |
Helper: return 0 if cell appears valid, -1 otherwise. If unknown_ok is true, allow cells with handshake types we don't recognize.
Definition at line 59 of file onion.c.
Referenced by check_extend_cell(), create_cell_format_impl(), and create_cell_parse().
|
static |
Helper: return 0 if cell appears valid, -1 otherwise.
Definition at line 176 of file onion.c.
Referenced by check_extended_cell(), created_cell_format(), and created_cell_parse().
|
static |
Helper: return 0 if cell appears valid, -1 otherwise.
Definition at line 226 of file onion.c.
Referenced by extend_cell_format(), and extend_cell_parse().
|
static |
Helper: return 0 if cell appears valid, -1 otherwise.
Definition at line 387 of file onion.c.
Referenced by extended_cell_format(), and extended_cell_parse().
| int create_cell_format | ( | cell_t * | cell_out, |
| const create_cell_t * | cell_in | ||
| ) |
|
static |
| int create_cell_format_relayed | ( | cell_t * | cell_out, |
| const create_cell_t * | cell_in | ||
| ) |
|
static |
| void create_cell_init | ( | create_cell_t * | cell_out, |
| uint8_t | cell_type, | ||
| uint16_t | handshake_type, | ||
| uint16_t | handshake_len, | ||
| const uint8_t * | onionskin | ||
| ) |
Write the various parameters into the create cell. Separate from create_cell_parse() to make unit testing easier.
Definition at line 101 of file onion.c.
Referenced by create_cell_parse(), and parse_create2_payload().
| int create_cell_parse | ( | create_cell_t * | cell_out, |
| const cell_t * | cell_in | ||
| ) |
Parse a CREATE, CREATE_FAST, or CREATE2 cell from cell_in into cell_out. Return 0 on success, -1 on failure. (We reject some syntactically valid CREATE2 cells that we can't generate or react to.)
Definition at line 153 of file onion.c.
Referenced by command_process_create_cell().
| int created_cell_format | ( | cell_t * | cell_out, |
| const created_cell_t * | cell_in | ||
| ) |
Fill cell_out with a correctly formatted version of the CREATED{,_FAST,2} cell in cell_in. Return 0 on success, -1 on failure.
Definition at line 508 of file onion.c.
Referenced by onionskin_answer().
| int created_cell_parse | ( | created_cell_t * | cell_out, |
| const cell_t * | cell_in | ||
| ) |
Parse a CREATED, CREATED_FAST, or CREATED2 cell from cell_in into cell_out. Return 0 on success, -1 on failure.
Definition at line 197 of file onion.c.
Referenced by command_process_created_cell().
| int extend_cell_format | ( | uint8_t * | command_out, |
| uint16_t * | len_out, | ||
| uint8_t * | payload_out, | ||
| const extend_cell_t * | cell_in | ||
| ) |
Format the EXTEND{,2} cell in cell_in, storing its relay payload in payload_out, the number of bytes used in *len_out, and the relay command in *command_out. The payload_out must have RELAY_PAYLOAD_SIZE_MAX bytes available.
Return 0 on success, -1 on failure.
Definition at line 555 of file onion.c.
Referenced by circuit_send_intermediate_onion_skin().
|
static |
| int extend_cell_parse | ( | extend_cell_t * | cell_out, |
| const uint8_t | command, | ||
| const uint8_t * | payload, | ||
| size_t | payload_length | ||
| ) |
Parse an EXTEND or EXTEND2 cell (according to command) from the payload_length bytes of payload into cell_out. Return 0 on success, -1 on failure.
Definition at line 350 of file onion.c.
Referenced by circuit_extend().
| int extended_cell_format | ( | uint8_t * | command_out, |
| uint16_t * | len_out, | ||
| uint8_t * | payload_out, | ||
| const extended_cell_t * | cell_in | ||
| ) |
Format the EXTENDED{,2} cell in cell_in, storing its relay payload in payload_out, the number of bytes used in *len_out, and the relay command in *command_out. The payload_out must have RELAY_PAYLOAD_SIZE_MAX bytes available.
Return 0 on success, -1 on failure.
Definition at line 649 of file onion.c.
Referenced by command_process_created_cell().
| int extended_cell_parse | ( | extended_cell_t * | cell_out, |
| const uint8_t | command, | ||
| const uint8_t * | payload, | ||
| size_t | payload_len | ||
| ) |
Parse an EXTENDED or EXTENDED2 cell (according to command) from the payload_len bytes of payload into cell_out. Return 0 on success, -1 on failure.
Definition at line 407 of file onion.c.
Referenced by handle_relay_msg().
|
static |
Helper: parse the CREATE2 payload at p, which could be up to p_len bytes long, and use it to fill the fields of cell_out. Return 0 on success and -1 on failure.
Note that part of the body of an EXTEND2 cell is a CREATE2 payload, so this function is also used for parsing those.
Definition at line 121 of file onion.c.
Referenced by create_cell_parse().
|
static |
Return true iff we are configured (by torrc or by the networkstatus parameters) to use Ed25519 identities in our Extend2 cells.
Definition at line 536 of file onion.c.
Referenced by extend_cell_format().