Tor 0.4.9.0-alpha-dev
sendme.h
Go to the documentation of this file.
1/* Copyright (c) 2019-2021, The Tor Project, Inc. */
2/* See LICENSE for licensing information */
3
4/**
5 * \file sendme.h
6 * \brief Header file for sendme.c.
7 **/
8
9#ifndef TOR_SENDME_H
10#define TOR_SENDME_H
11
14#include "core/or/circuit_st.h"
15
16/* Sending SENDME cell. */
19 crypt_path_t *layer_hint);
20
21/* Processing SENDME cell. */
22int sendme_process_circuit_level(crypt_path_t *layer_hint,
23 circuit_t *circ, const uint8_t *cell_payload,
24 uint16_t cell_payload_len);
26int sendme_process_stream_level(edge_connection_t *conn, circuit_t *circ,
27 uint16_t cell_body_len);
28
29/* Update deliver window functions. */
30int sendme_stream_data_received(edge_connection_t *conn);
31int sendme_circuit_data_received(circuit_t *circ, crypt_path_t *layer_hint);
32
33/* Update package window functions. */
34int sendme_note_circuit_data_packaged(circuit_t *circ,
35 crypt_path_t *layer_hint);
36int sendme_note_stream_data_packaged(edge_connection_t *conn, size_t len);
37
38/* Record cell digest on circuit. */
39void sendme_record_cell_digest_on_circ(circuit_t *circ, crypt_path_t *cpath);
40/* Record cell digest as the SENDME digest. */
41void sendme_record_received_cell_digest(circuit_t *circ, crypt_path_t *cpath);
42void sendme_record_sending_cell_digest(circuit_t *circ, crypt_path_t *cpath);
43
44/* Private section starts. */
45#ifdef SENDME_PRIVATE
46
47/* The maximum supported version. Above that value, the cell can't be
48 * recognized as a valid SENDME. */
49#define SENDME_MAX_SUPPORTED_VERSION 1
50
51/* The cell version constants for when emitting a cell. */
52#define SENDME_EMIT_MIN_VERSION_DEFAULT 1
53#define SENDME_EMIT_MIN_VERSION_MIN 0
54#define SENDME_EMIT_MIN_VERSION_MAX UINT8_MAX
55
56/* The cell version constants for when accepting a cell. */
57#define SENDME_ACCEPT_MIN_VERSION_DEFAULT 0
58#define SENDME_ACCEPT_MIN_VERSION_MIN 0
59#define SENDME_ACCEPT_MIN_VERSION_MAX UINT8_MAX
60
61/*
62 * Unit tests declaractions.
63 */
64#ifdef TOR_UNIT_TESTS
65
66STATIC int get_emit_min_version(void);
67STATIC int get_accept_min_version(void);
68
69STATIC bool cell_version_can_be_handled(uint8_t cell_version);
70
71STATIC ssize_t build_cell_payload_v1(const uint8_t *cell_digest,
72 uint8_t *payload);
73STATIC bool sendme_is_valid(const circuit_t *circ,
74 const uint8_t *cell_payload,
75 size_t cell_payload_len);
76STATIC bool circuit_sendme_cell_is_next(int deliver_window,
77 int sendme_inc);
78
79#endif /* defined(TOR_UNIT_TESTS) */
80
81#endif /* defined(SENDME_PRIVATE) */
82
83#endif /* !defined(TOR_SENDME_H) */
Base circuit structure.
Path structures for origin circuits.
Edge-connection structure.
STATIC bool circuit_sendme_cell_is_next(int deliver_window, int sendme_inc)
Definition: sendme.c:342
void sendme_circuit_consider_sending(circuit_t *circ, crypt_path_t *layer_hint)
Definition: sendme.c:420
int sendme_process_circuit_level_impl(crypt_path_t *, circuit_t *)
Definition: sendme.c:505
void sendme_connection_edge_consider_sending(edge_connection_t *edge_conn)
Definition: sendme.c:373
#define STATIC
Definition: testsupport.h:32