Tor  0.4.7.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 
13 #include "core/or/crypt_path_st.h"
14 #include "core/or/circuit_st.h"
15 
16 /* Sending SENDME cell. */
19  crypt_path_t *layer_hint);
20 
21 /* Processing SENDME cell. */
22 int sendme_process_circuit_level(crypt_path_t *layer_hint,
23  circuit_t *circ, const uint8_t *cell_payload,
24  uint16_t cell_payload_len);
25 int sendme_process_stream_level(edge_connection_t *conn, circuit_t *circ,
26  uint16_t cell_body_len);
27 
28 /* Update deliver window functions. */
29 int sendme_stream_data_received(edge_connection_t *conn);
30 int sendme_circuit_data_received(circuit_t *circ, crypt_path_t *layer_hint);
31 
32 /* Update package window functions. */
33 int sendme_note_circuit_data_packaged(circuit_t *circ,
34  crypt_path_t *layer_hint);
35 int sendme_note_stream_data_packaged(edge_connection_t *conn);
36 
37 /* Record cell digest on circuit. */
38 void sendme_record_cell_digest_on_circ(circuit_t *circ, crypt_path_t *cpath);
39 /* Record cell digest as the SENDME digest. */
40 void sendme_record_received_cell_digest(circuit_t *circ, crypt_path_t *cpath);
41 void sendme_record_sending_cell_digest(circuit_t *circ, crypt_path_t *cpath);
42 
43 /* Private section starts. */
44 #ifdef SENDME_PRIVATE
45 
46 /* The maximum supported version. Above that value, the cell can't be
47  * recognized as a valid SENDME. */
48 #define SENDME_MAX_SUPPORTED_VERSION 1
49 
50 /* The cell version constants for when emitting a cell. */
51 #define SENDME_EMIT_MIN_VERSION_DEFAULT 1
52 #define SENDME_EMIT_MIN_VERSION_MIN 0
53 #define SENDME_EMIT_MIN_VERSION_MAX UINT8_MAX
54 
55 /* The cell version constants for when accepting a cell. */
56 #define SENDME_ACCEPT_MIN_VERSION_DEFAULT 0
57 #define SENDME_ACCEPT_MIN_VERSION_MIN 0
58 #define SENDME_ACCEPT_MIN_VERSION_MAX UINT8_MAX
59 
60 /*
61  * Unit tests declaractions.
62  */
63 #ifdef TOR_UNIT_TESTS
64 
65 STATIC int get_emit_min_version(void);
66 STATIC int get_accept_min_version(void);
67 
68 STATIC bool cell_version_can_be_handled(uint8_t cell_version);
69 
70 STATIC ssize_t build_cell_payload_v1(const uint8_t *cell_digest,
71  uint8_t *payload);
72 STATIC bool sendme_is_valid(const circuit_t *circ,
73  const uint8_t *cell_payload,
74  size_t cell_payload_len);
75 
76 #endif /* defined(TOR_UNIT_TESTS) */
77 
78 #endif /* defined(SENDME_PRIVATE) */
79 
80 #endif /* !defined(TOR_SENDME_H) */
Base circuit structure.
Path structures for origin circuits.
Edge-connection structure.
void sendme_circuit_consider_sending(circuit_t *circ, crypt_path_t *layer_hint)
Definition: sendme.c:418
void sendme_connection_edge_consider_sending(edge_connection_t *edge_conn)
Definition: sendme.c:375
#define STATIC
Definition: testsupport.h:32