Merge branch 'maint-0.4.8'
[tor.git] / src / core / or / congestion_control_flow.h
blob05e25c44d0e3ae0f116b3b7d95f34cf5cc56c092
1 /* Copyright (c) 2019-2021, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
4 /**
5 * \file congestion_control_flow.h
6 * \brief APIs for stream flow control on congestion controlled circuits.
7 **/
9 #ifndef TOR_CONGESTION_CONTROL_FLOW_H
10 #define TOR_CONGESTION_CONTROL_FLOW_H
12 #include "core/or/crypt_path_st.h"
13 #include "core/or/circuit_st.h"
14 #include "core/or/edge_connection_st.h"
16 void flow_control_new_consensus_params(const struct networkstatus_t *);
18 bool circuit_process_stream_xoff(edge_connection_t *conn,
19 const crypt_path_t *layer_hint,
20 const cell_t *cell);
21 bool circuit_process_stream_xon(edge_connection_t *conn,
22 const crypt_path_t *layer_hint,
23 const cell_t *cell);
25 int flow_control_decide_xoff(edge_connection_t *stream);
26 void flow_control_decide_xon(edge_connection_t *stream, size_t n_written);
28 void flow_control_note_sent_data(edge_connection_t *stream, size_t len);
30 bool edge_uses_flow_control(const edge_connection_t *stream);
32 bool conn_uses_flow_control(connection_t *stream);
34 /** Metricsport externs */
35 extern uint64_t cc_stats_flow_num_xoff_sent;
36 extern uint64_t cc_stats_flow_num_xon_sent;
37 extern double cc_stats_flow_xoff_outbuf_ma;
38 extern double cc_stats_flow_xon_outbuf_ma;
40 /* Private section starts. */
41 #ifdef TOR_CONGESTION_CONTROL_FLOW_PRIVATE
44 * Unit tests declaractions.
46 #ifdef TOR_UNIT_TESTS
48 #endif /* defined(TOR_UNIT_TESTS) */
50 #endif /* defined(TOR_CONGESTION_CONTROL_FLOW_PRIVATE) */
52 #endif /* !defined(TOR_CONGESTION_CONTROL_FLOW_H) */