Tor 0.4.9.0-alpha-dev
onion.h
Go to the documentation of this file.
1/* Copyright (c) 2001 Matej Pfajfar.
2 * Copyright (c) 2001-2004, Roger Dingledine.
3 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4 * Copyright (c) 2007-2021, The Tor Project, Inc. */
5/* See LICENSE for licensing information */
6
7/**
8 * \file onion.h
9 * \brief Header file for onion.c.
10 **/
11
12#ifndef TOR_ONION_H
13#define TOR_ONION_H
14
15struct create_cell_t;
19
20#define MAX_ONIONSKIN_CHALLENGE_LEN 255
21#define MAX_ONIONSKIN_REPLY_LEN 255
22
23/** A parsed CREATE, CREATE_FAST, or CREATE2 cell. */
24typedef struct create_cell_t {
25 /** The cell command. One of CREATE{,_FAST,2} */
26 uint8_t cell_type;
27 /** One of the ONION_HANDSHAKE_TYPE_* values */
29 /** The number of bytes used in <b>onionskin</b>. */
30 uint16_t handshake_len;
31 /** The client-side message for the circuit creation handshake. */
34
35/** A parsed CREATED, CREATED_FAST, or CREATED2 cell. */
36typedef struct created_cell_t {
37 /** The cell command. One of CREATED{,_FAST,2} */
38 uint8_t cell_type;
39 /** The number of bytes used in <b>reply</b>. */
40 uint16_t handshake_len;
41 /** The server-side message for the circuit creation handshake. */
44
45/** A parsed RELAY_EXTEND or RELAY_EXTEND2 cell */
46typedef struct extend_cell_t {
47 /** One of RELAY_EXTEND or RELAY_EXTEND2 */
48 uint8_t cell_type;
49 /** An IPv4 address and port for the node we're connecting to. */
51 /** An IPv6 address and port for the node we're connecting to. */
53 /** Identity fingerprint of the node we're connecting to.*/
55 /** Ed25519 public identity key. Zero if not set. */
57 /** The "create cell" embedded in this extend cell. Note that unlike the
58 * create cells we generate ourselves, this create cell can have a handshake
59 * type we don't recognize. */
62
63/** A parsed RELAY_EXTEND or RELAY_EXTEND2 cell */
64typedef struct extended_cell_t {
65 /** One of RELAY_EXTENDED or RELAY_EXTENDED2. */
66 uint8_t cell_type;
67 /** The "created cell" embedded in this extended cell. */
70
71void create_cell_init(create_cell_t *cell_out, uint8_t cell_type,
72 uint16_t handshake_type, uint16_t handshake_len,
73 const uint8_t *onionskin);
74int create_cell_parse(create_cell_t *cell_out, const cell_t *cell_in);
75int created_cell_parse(created_cell_t *cell_out, const cell_t *cell_in);
77 const uint8_t command,
78 const uint8_t *payload_in,
79 size_t payload_len));
80int extended_cell_parse(extended_cell_t *cell_out, const uint8_t command,
81 const uint8_t *payload_in, size_t payload_len);
82
83int create_cell_format(cell_t *cell_out, const create_cell_t *cell_in);
84int create_cell_format_relayed(cell_t *cell_out, const create_cell_t *cell_in);
85int created_cell_format(cell_t *cell_out, const created_cell_t *cell_in);
86int extend_cell_format(uint8_t *command_out, uint16_t *len_out,
87 uint8_t *payload_out, const extend_cell_t *cell_in);
88int extended_cell_format(uint8_t *command_out, uint16_t *len_out,
89 uint8_t *payload_out, const extended_cell_t *cell_in);
90
91#endif /* !defined(TOR_ONION_H) */
tor_cmdline_mode_t command
Definition: config.c:2468
Header for crypto_ed25519.c.
#define DIGEST_LEN
Definition: digest_sizes.h:20
int created_cell_parse(created_cell_t *cell_out, const cell_t *cell_in)
Definition: onion.c:213
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)
Definition: onion.c:107
int create_cell_parse(create_cell_t *cell_out, const cell_t *cell_in)
Definition: onion.c:159
int extend_cell_parse(extend_cell_t *cell_out, const uint8_t command, const uint8_t *payload_in, size_t payload_len)
Definition: onion.c:400
int created_cell_format(cell_t *cell_out, const created_cell_t *cell_in)
Definition: onion.c:572
int extended_cell_parse(extended_cell_t *cell_out, const uint8_t command, const uint8_t *payload_in, size_t payload_len)
Definition: onion.c:469
int extended_cell_format(uint8_t *command_out, uint16_t *len_out, uint8_t *payload_out, const extended_cell_t *cell_in)
Definition: onion.c:728
int extend_cell_format(uint8_t *command_out, uint16_t *len_out, uint8_t *payload_out, const extend_cell_t *cell_in)
Definition: onion.c:617
#define CELL_PAYLOAD_SIZE
Definition: or.h:465
Definition: cell_st.h:17
uint16_t handshake_len
Definition: onion.h:30
uint16_t handshake_type
Definition: onion.h:28
uint8_t onionskin[CELL_PAYLOAD_SIZE - 4]
Definition: onion.h:32
uint8_t cell_type
Definition: onion.h:26
uint16_t handshake_len
Definition: onion.h:40
uint8_t reply[CELL_PAYLOAD_SIZE - 2]
Definition: onion.h:42
uint8_t cell_type
Definition: onion.h:38
tor_addr_port_t orport_ipv4
Definition: onion.h:50
create_cell_t create_cell
Definition: onion.h:60
struct ed25519_public_key_t ed_pubkey
Definition: onion.h:56
uint8_t node_id[DIGEST_LEN]
Definition: onion.h:54
tor_addr_port_t orport_ipv6
Definition: onion.h:52
uint8_t cell_type
Definition: onion.h:48
created_cell_t created_cell
Definition: onion.h:68
uint8_t cell_type
Definition: onion.h:66
#define MOCK_DECL(rv, funcname, arglist)
Definition: testsupport.h:127