tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

sendme.h (2772B)


      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 
     12 #include "core/or/edge_connection_st.h"
     13 #include "core/or/crypt_path_st.h"
     14 #include "core/or/circuit_st.h"
     15 
     16 /* Sending SENDME cell. */
     17 void sendme_connection_edge_consider_sending(edge_connection_t *edge_conn);
     18 void sendme_circuit_consider_sending(circuit_t *circ,
     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_circuit_level_impl(crypt_path_t *, circuit_t *);
     26 int sendme_process_stream_level(edge_connection_t *conn, circuit_t *circ,
     27                                uint16_t cell_body_len);
     28 
     29 /* Update deliver window functions. */
     30 int sendme_stream_data_received(edge_connection_t *conn);
     31 int sendme_circuit_data_received(circuit_t *circ, crypt_path_t *layer_hint);
     32 
     33 /* Update package window functions. */
     34 int sendme_note_circuit_data_packaged(circuit_t *circ,
     35                                      crypt_path_t *layer_hint);
     36 int sendme_note_stream_data_packaged(edge_connection_t *conn, size_t len);
     37 
     38 /* Record cell digest on circuit. */
     39 void sendme_record_cell_digest_on_circ(circuit_t *circ, crypt_path_t *cpath);
     40 
     41 /* Private section starts. */
     42 #ifdef SENDME_PRIVATE
     43 
     44 /* The maximum supported version. Above that value, the cell can't be
     45 * recognized as a valid SENDME. */
     46 #define SENDME_MAX_SUPPORTED_VERSION 1
     47 
     48 /* The cell version constants for when emitting a cell. */
     49 #define SENDME_EMIT_MIN_VERSION_DEFAULT 1
     50 #define SENDME_EMIT_MIN_VERSION_MIN 0
     51 #define SENDME_EMIT_MIN_VERSION_MAX UINT8_MAX
     52 
     53 /* The cell version constants for when accepting a cell. */
     54 #define SENDME_ACCEPT_MIN_VERSION_DEFAULT 0
     55 #define SENDME_ACCEPT_MIN_VERSION_MIN 0
     56 #define SENDME_ACCEPT_MIN_VERSION_MAX UINT8_MAX
     57 
     58 /*
     59 * Unit tests declaractions.
     60 */
     61 #ifdef TOR_UNIT_TESTS
     62 
     63 STATIC int get_emit_min_version(void);
     64 STATIC int get_accept_min_version(void);
     65 
     66 STATIC bool cell_version_can_be_handled(uint8_t cell_version);
     67 
     68 STATIC ssize_t build_cell_payload_v1(const uint8_t *cell_tag,
     69                                     size_t tag_len,
     70                                     uint8_t *payload);
     71 STATIC bool sendme_is_valid(circuit_t *circ,
     72                            const crypt_path_t *layer_hint,
     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) */