tor  0.4.1.0-alpha-dev
Data Structures | Macros | Typedefs | Functions
onion.h File Reference
#include "lib/crypt_ops/crypto_ed25519.h"

Go to the source code of this file.

Data Structures

struct  create_cell_t
 
struct  created_cell_t
 
struct  extend_cell_t
 
struct  extended_cell_t
 

Macros

#define MAX_ONIONSKIN_CHALLENGE_LEN   255
 
#define MAX_ONIONSKIN_REPLY_LEN   255
 

Typedefs

typedef struct create_cell_t create_cell_t
 
typedef struct created_cell_t created_cell_t
 
typedef struct extend_cell_t extend_cell_t
 
typedef struct extended_cell_t extended_cell_t
 

Functions

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)
 
int create_cell_parse (create_cell_t *cell_out, const cell_t *cell_in)
 
int created_cell_parse (created_cell_t *cell_out, const cell_t *cell_in)
 
int extend_cell_parse (extend_cell_t *cell_out, const uint8_t command, const uint8_t *payload_in, size_t payload_len)
 
int extended_cell_parse (extended_cell_t *cell_out, const uint8_t command, const uint8_t *payload_in, size_t payload_len)
 
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)
 
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)
 

Detailed Description

Header file for onion.c.

Definition in file onion.h.

Typedef Documentation

◆ create_cell_t

typedef struct create_cell_t create_cell_t

A parsed CREATE, CREATE_FAST, or CREATE2 cell.

◆ created_cell_t

A parsed CREATED, CREATED_FAST, or CREATED2 cell.

◆ extend_cell_t

typedef struct extend_cell_t extend_cell_t

A parsed RELAY_EXTEND or RELAY_EXTEND2 cell

◆ extended_cell_t

A parsed RELAY_EXTEND or RELAY_EXTEND2 cell

Function Documentation

◆ create_cell_init()

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 103 of file onion.c.

References create_cell_t::cell_type, create_cell_t::handshake_len, create_cell_t::handshake_type, and create_cell_t::onionskin.

◆ create_cell_parse()

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 155 of file onion.c.

References cell_t::command.

◆ created_cell_format()

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 546 of file onion.c.

References created_cell_t::cell_type, check_created_cell(), cell_t::command, and cell_t::payload.

◆ created_cell_parse()

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 209 of file onion.c.

References cell_t::command.

◆ extend_cell_format()

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 bytes available. Return 0 on success, -1 on failure.

Definition at line 591 of file onion.c.

References extend_cell_t::cell_type, check_extend_cell(), and RELAY_PAYLOAD_SIZE.

◆ extend_cell_parse()

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 378 of file onion.c.

References RELAY_PAYLOAD_SIZE, and tor_assert().

◆ extended_cell_format()

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 bytes available. Return 0 on success, -1 on failure.

Definition at line 685 of file onion.c.

References extended_cell_t::cell_type, check_extended_cell(), and RELAY_PAYLOAD_SIZE.

◆ extended_cell_parse()

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_length bytes of payload into cell_out. Return 0 on success, -1 on failure.

Definition at line 448 of file onion.c.

References RELAY_PAYLOAD_SIZE, and tor_assert().