Create relay.h
[tor/rransom.git] / src / or / relay.h
blob73855a52bf3fa928a16c84f6295b4c2074f7b4a8
1 /* Copyright (c) 2001 Matej Pfajfar.
2 * Copyright (c) 2001-2004, Roger Dingledine.
3 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4 * Copyright (c) 2007-2010, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
7 /**
8 * \file relay.h
9 * \brief Header file for relay.c.
10 **/
12 #ifndef _TOR_RELAY_H
13 #define _TOR_RELAY_H
15 extern uint64_t stats_n_relay_cells_relayed;
16 extern uint64_t stats_n_relay_cells_delivered;
18 int circuit_receive_relay_cell(cell_t *cell, circuit_t *circ,
19 cell_direction_t cell_direction);
21 void relay_header_pack(char *dest, const relay_header_t *src);
22 void relay_header_unpack(relay_header_t *dest, const char *src);
23 int relay_send_command_from_edge(streamid_t stream_id, circuit_t *circ,
24 uint8_t relay_command, const char *payload,
25 size_t payload_len, crypt_path_t *cpath_layer);
26 int connection_edge_send_command(edge_connection_t *fromconn,
27 uint8_t relay_command, const char *payload,
28 size_t payload_len);
29 int connection_edge_package_raw_inbuf(edge_connection_t *conn,
30 int package_partial);
31 void connection_edge_consider_sending_sendme(edge_connection_t *conn);
33 extern uint64_t stats_n_data_cells_packaged;
34 extern uint64_t stats_n_data_bytes_packaged;
35 extern uint64_t stats_n_data_cells_received;
36 extern uint64_t stats_n_data_bytes_received;
38 void init_cell_pool(void);
39 void free_cell_pool(void);
40 void clean_cell_pool(void);
41 void dump_cell_pool_usage(int severity);
43 void cell_queue_clear(cell_queue_t *queue);
44 void cell_queue_append(cell_queue_t *queue, packed_cell_t *cell);
45 void cell_queue_append_packed_copy(cell_queue_t *queue, const cell_t *cell);
47 void append_cell_to_circuit_queue(circuit_t *circ, or_connection_t *orconn,
48 cell_t *cell, cell_direction_t direction);
49 void connection_or_unlink_all_active_circs(or_connection_t *conn);
50 int connection_or_flush_from_first_active_circuit(or_connection_t *conn,
51 int max, time_t now);
52 void assert_active_circuits_ok(or_connection_t *orconn);
53 void make_circuit_inactive_on_conn(circuit_t *circ, or_connection_t *conn);
54 void make_circuit_active_on_conn(circuit_t *circ, or_connection_t *conn);
56 int append_address_to_payload(char *payload_out, const tor_addr_t *addr);
57 const char *decode_address_from_payload(tor_addr_t *addr_out,
58 const char *payload,
59 int payload_len);
60 unsigned cell_ewma_get_tick(void);
61 void cell_ewma_set_scale_factor(or_options_t *options,
62 networkstatus_t *consensus);
64 #endif