aboutsummaryrefslogtreecommitdiff
path: root/src/core/or/conflux_cell.h
blob: afaecae6f5b61de9734477562d91108da1def8bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* Copyright (c) 2023, The Tor Project, Inc. */
/* See LICENSE for licensing information */

/**
 * \file conflux_cell.h
 * \brief Header file for conflux_cell.c.
 **/

#ifndef TOR_CONFLUX_CELL_H
#define TOR_CONFLUX_CELL_H

#include "core/or/or.h"

typedef struct conflux_cell_link_t {
  uint8_t version;
  uint8_t desired_ux;
  uint8_t nonce[DIGEST256_LEN];

  uint64_t last_seqno_sent;
  uint64_t last_seqno_recv;
} conflux_cell_link_t;

conflux_cell_link_t *conflux_cell_new_link(const uint8_t *nonce,
                                           uint64_t last_sent,
                                           uint64_t last_recv,
                                           bool is_client);

conflux_cell_link_t *conflux_cell_parse_link(const cell_t *cell,
                                             const uint16_t cell_len);
conflux_cell_link_t *conflux_cell_parse_linked(const cell_t *cell,
                                               const uint16_t cell_le);
uint32_t conflux_cell_parse_switch(const cell_t *cell,
                                   const uint16_t rh_len);

bool conflux_cell_send_link(const conflux_cell_link_t *link,
                            origin_circuit_t *circ);
bool conflux_cell_send_linked(const conflux_cell_link_t *link,
                              or_circuit_t *circ);
bool conflux_cell_send_linked_ack(origin_circuit_t *circ);
bool conflux_send_switch_command(circuit_t *send_circ, uint64_t relative_seq);

#ifdef TOR_UNIT_TESTS

STATIC ssize_t
build_link_cell(const conflux_cell_link_t *link, uint8_t *cell_out);

#endif /* TOR_UNIT_TESTS */

#endif /* TOR_CONFLUX_CELL_H */