1 /* Copyright (c) 2019-2021, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
6 * \brief Public APIs for conflux multipath support
12 #include "core/or/circuit_st.h"
13 #include "core/or/conflux_st.h"
15 typedef struct conflux_t conflux_t
;
16 typedef struct conflux_leg_t conflux_leg_t
;
18 /** Helpers to iterate over legs with better semantic. */
19 #define CONFLUX_FOR_EACH_LEG_BEGIN(cfx, var) \
20 SMARTLIST_FOREACH_BEGIN(cfx->legs, conflux_leg_t *, var)
21 #define CONFLUX_FOR_EACH_LEG_END(var) \
22 SMARTLIST_FOREACH_END(var)
24 /** Helper: Return the number of legs a conflux object has. */
25 #define CONFLUX_NUM_LEGS(cfx) (smartlist_len(cfx->legs))
27 /** A cell for the out-of-order queue.
28 * XXX: Consider trying to use packed_cell_t instead here? */
31 * Absolute sequence number of this cell, computed from the
32 * relative sequence number of the conflux cell. */
36 * Heap index of this cell, for use in in the conflux_t ooo_q heap.
40 /** The cell here is always guaranteed to have removed its
41 * extra conflux sequence number, for ease of processing */
45 size_t conflux_handle_oom(size_t bytes_to_remove
);
46 uint64_t conflux_get_total_bytes_allocation(void);
47 uint64_t conflux_get_circ_bytes_allocation(const circuit_t
*circ
);
49 void conflux_update_rtt(conflux_t
*cfx
, circuit_t
*circ
, uint64_t rtt_usec
);
51 circuit_t
*conflux_decide_circ_for_send(conflux_t
*cfx
,
53 uint8_t relay_command
);
54 circuit_t
*conflux_decide_next_circ(conflux_t
*cfx
);
56 int conflux_process_switch_command(circuit_t
*in_circ
,
57 crypt_path_t
*layer_hint
, cell_t
*cell
,
59 bool conflux_should_multiplex(int relay_command
);
60 bool conflux_process_cell(conflux_t
*cfx
, circuit_t
*in_circ
,
61 crypt_path_t
*layer_hint
,
63 conflux_cell_t
*conflux_dequeue_cell(conflux_t
*cfx
);
64 void conflux_note_cell_sent(conflux_t
*cfx
, circuit_t
*circ
,
65 uint8_t relay_command
);
67 /* Private section starts. */
68 #ifdef TOR_CONFLUX_PRIVATE
70 const struct congestion_control_t
*circuit_ccontrol(const circuit_t
*);
71 conflux_leg_t
*conflux_get_leg(conflux_t
*cfx
, const circuit_t
*circ
);
72 uint64_t conflux_get_max_seq_recv(const conflux_t
*cfx
);
73 uint64_t conflux_get_max_seq_sent(const conflux_t
*cfx
);
76 * Unit tests declaractions.
80 #endif /* defined(TOR_UNIT_TESTS) */
82 #endif /* defined(TOR_CONFLUX_PRIVATE) */
84 #endif /* !defined(TOR_CONFLUX_H) */