Tor 0.4.9.2-alpha-dev
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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#define MAX_CREATE_LEN (CELL_PAYLOAD_SIZE - 4)
24#define MAX_CREATED_LEN (CELL_PAYLOAD_SIZE - 2)
25
26/** A parsed CREATE, CREATE_FAST, or CREATE2 cell. */
27typedef struct create_cell_t {
28 /** The cell command. One of CREATE{,_FAST,2} */
29 uint8_t cell_type;
30 /** One of the ONION_HANDSHAKE_TYPE_* values */
32 /** The number of bytes used in <b>onionskin</b>. */
33 uint16_t handshake_len;
34 /** The client-side message for the circuit creation handshake. */
35 uint8_t onionskin[MAX_CREATE_LEN];
37
38/** A parsed CREATED, CREATED_FAST, or CREATED2 cell. */
39typedef struct created_cell_t {
40 /** The cell command. One of CREATED{,_FAST,2} */
41 uint8_t cell_type;
42 /** The number of bytes used in <b>reply</b>. */
43 uint16_t handshake_len;
44 /** The server-side message for the circuit creation handshake. */
45 uint8_t reply[MAX_CREATED_LEN];
47
48/** A parsed RELAY_EXTEND or RELAY_EXTEND2 cell */
49typedef struct extend_cell_t {
50 /** One of RELAY_EXTEND or RELAY_EXTEND2 */
51 uint8_t cell_type;
52 /** An IPv4 address and port for the node we're connecting to. */
54 /** An IPv6 address and port for the node we're connecting to. */
56 /** Identity fingerprint of the node we're connecting to.*/
58 /** Ed25519 public identity key. Zero if not set. */
60 /** The "create cell" embedded in this extend cell. Note that unlike the
61 * create cells we generate ourselves, this create cell can have a handshake
62 * type we don't recognize. */
65
66/** A parsed RELAY_EXTEND or RELAY_EXTEND2 cell */
67typedef struct extended_cell_t {
68 /** One of RELAY_EXTENDED or RELAY_EXTENDED2. */
69 uint8_t cell_type;
70 /** The "created cell" embedded in this extended cell. */
73
74void create_cell_init(create_cell_t *cell_out, uint8_t cell_type,
75 uint16_t handshake_type, uint16_t handshake_len,
76 const uint8_t *onionskin);
77int create_cell_parse(create_cell_t *cell_out, const cell_t *cell_in);
78int created_cell_parse(created_cell_t *cell_out, const cell_t *cell_in);
80 const uint8_t command,
81 const uint8_t *payload_in,
82 size_t payload_len));
83int extended_cell_parse(extended_cell_t *cell_out, const uint8_t command,
84 const uint8_t *payload_in, size_t payload_len);
85
86int create_cell_format(cell_t *cell_out, const create_cell_t *cell_in);
87int create_cell_format_relayed(cell_t *cell_out, const create_cell_t *cell_in);
88int created_cell_format(cell_t *cell_out, const created_cell_t *cell_in);
89int extend_cell_format(uint8_t *command_out, uint16_t *len_out,
90 uint8_t *payload_out, const extend_cell_t *cell_in);
91int extended_cell_format(uint8_t *command_out, uint16_t *len_out,
92 uint8_t *payload_out, const extended_cell_t *cell_in);
93
94#endif /* !defined(TOR_ONION_H) */
tor_cmdline_mode_t command
Definition: config.c:2477
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:197
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:101
int create_cell_parse(create_cell_t *cell_out, const cell_t *cell_in)
Definition: onion.c:153
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:350
int created_cell_format(cell_t *cell_out, const created_cell_t *cell_in)
Definition: onion.c:504
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:407
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:645
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:551
Definition: cell_st.h:17
uint16_t handshake_len
Definition: onion.h:33
uint16_t handshake_type
Definition: onion.h:31
uint8_t onionskin[MAX_CREATE_LEN]
Definition: onion.h:35
uint8_t cell_type
Definition: onion.h:29
uint16_t handshake_len
Definition: onion.h:43
uint8_t reply[MAX_CREATED_LEN]
Definition: onion.h:45
uint8_t cell_type
Definition: onion.h:41
tor_addr_port_t orport_ipv4
Definition: onion.h:53
create_cell_t create_cell
Definition: onion.h:63
struct ed25519_public_key_t ed_pubkey
Definition: onion.h:59
uint8_t node_id[DIGEST_LEN]
Definition: onion.h:57
tor_addr_port_t orport_ipv6
Definition: onion.h:55
uint8_t cell_type
Definition: onion.h:51
created_cell_t created_cell
Definition: onion.h:71
uint8_t cell_type
Definition: onion.h:69
#define MOCK_DECL(rv, funcname, arglist)
Definition: testsupport.h:127