1 /* Copyright (c) 2023, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
6 * \brief Header file for conflux_util.c.
9 #ifndef TOR_CONFLUX_UTIL_H
10 #define TOR_CONFLUX_UTIL_H
13 typedef struct edge_connection_t edge_connection_t
;
14 typedef struct crypt_path_t crypt_path_t
;
15 typedef struct origin_circuit_t origin_circuit_t
;
16 typedef struct conflux_t conflux_t
;
18 /* True iff the given circuit_t circ is conflux related. */
20 CIRCUIT_IS_CONFLUX(const circuit_t
*circ
)
22 if (circ
->conflux_pending_nonce
) {
23 if (CIRCUIT_IS_ORIGIN(circ
))
24 tor_assert_nonfatal(circ
->purpose
== CIRCUIT_PURPOSE_CONFLUX_UNLINKED
);
26 } else if (circ
->conflux
) {
27 if (CIRCUIT_IS_ORIGIN(circ
))
28 tor_assert_nonfatal(circ
->purpose
== CIRCUIT_PURPOSE_CONFLUX_LINKED
);
31 tor_assert_nonfatal(circ
->purpose
!= CIRCUIT_PURPOSE_CONFLUX_LINKED
);
32 tor_assert_nonfatal(circ
->purpose
!= CIRCUIT_PURPOSE_CONFLUX_UNLINKED
);
37 int circuit_get_package_window(circuit_t
*circ
,
38 const crypt_path_t
*cpath
);
39 bool conflux_can_send(conflux_t
*cfx
);
41 bool edge_uses_cpath(const edge_connection_t
*conn
,
42 const crypt_path_t
*cpath
);
43 crypt_path_t
*conflux_get_destination_hop(circuit_t
*circ
);
44 bool conflux_validate_source_hop(circuit_t
*in_circ
,
45 crypt_path_t
*layer_hint
);
46 uint64_t edge_get_max_rtt(const edge_connection_t
*stream
);
47 bool relay_crypt_from_last_hop(const origin_circuit_t
*circ
,
48 const crypt_path_t
*layer_hint
);
50 void conflux_update_p_streams(origin_circuit_t
*, edge_connection_t
*);
51 void conflux_update_half_streams(origin_circuit_t
*, smartlist_t
*);
52 void conflux_update_n_streams(or_circuit_t
*, edge_connection_t
*);
53 void conflux_update_resolving_streams(or_circuit_t
*, edge_connection_t
*);
54 void conflux_sync_circ_fields(conflux_t
*cfx
, origin_circuit_t
*ref_circ
);
55 void conflux_validate_stream_lists(const conflux_t
*cfx
);
56 void conflux_validate_legs(const conflux_t
*cfx
);
58 #endif /* TOR_CONFLUX_UTIL_H */