diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index a70effe40a..b78845fdd6 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -25,6 +25,7 @@ #include "networkstatus.h" #include "onion.h" #include "policies.h" +#include "relay.h" #include "router.h" #include "routerlist.h" #include "crypto.h" diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c index 044cdb9c34..df4aec727b 100644 --- a/src/or/circuitlist.c +++ b/src/or/circuitlist.c @@ -20,6 +20,7 @@ #include "control.h" #include "networkstatus.h" #include "onion.h" +#include "relay.h" #include "rendclient.h" #include "rendcommon.h" #include "routerlist.h" diff --git a/src/or/command.c b/src/or/command.c index b3b7c2d374..0460e25c25 100644 --- a/src/or/command.c +++ b/src/or/command.c @@ -26,6 +26,7 @@ #include "cpuworker.h" #include "hibernate.h" #include "onion.h" +#include "relay.h" #include "router.h" #include "routerlist.h" diff --git a/src/or/config.c b/src/or/config.c index 02d20129f0..4fdf32e0ad 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -27,6 +27,7 @@ #include "main.h" #include "networkstatus.h" #include "policies.h" +#include "relay.h" #include "rendclient.h" #include "rendservice.h" #include "router.h" diff --git a/src/or/connection.c b/src/or/connection.c index c58eb9c9e9..d9aa1cf782 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -29,6 +29,7 @@ #include "main.h" #include "policies.h" #include "reasons.h" +#include "relay.h" #include "rendclient.h" #include "rendcommon.h" #include "router.h" diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index bf0fe7b948..83ba230588 100644 --- a/src/or/connection_edge.c +++ b/src/or/connection_edge.c @@ -25,6 +25,7 @@ #include "main.h" #include "policies.h" #include "reasons.h" +#include "relay.h" #include "rendclient.h" #include "rendcommon.h" #include "rendservice.h" diff --git a/src/or/connection_or.c b/src/or/connection_or.c index c4db543427..bf19503d5f 100644 --- a/src/or/connection_or.c +++ b/src/or/connection_or.c @@ -23,6 +23,7 @@ #include "main.h" #include "networkstatus.h" #include "reasons.h" +#include "relay.h" #include "router.h" #include "routerlist.h" diff --git a/src/or/dns.c b/src/or/dns.c index f2d3d435db..4e319b7d83 100644 --- a/src/or/dns.c +++ b/src/or/dns.c @@ -21,6 +21,7 @@ #include "dns.h" #include "main.h" #include "policies.h" +#include "relay.h" #include "router.h" #include "ht.h" #ifdef HAVE_EVENT2_DNS_H diff --git a/src/or/main.c b/src/or/main.c index 60bea49006..e202a109d5 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -36,6 +36,7 @@ #include "ntmain.h" #include "onion.h" #include "policies.h" +#include "relay.h" #include "rendclient.h" #include "rendcommon.h" #include "rendservice.h" diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index bd986609ff..c763e23a87 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -19,6 +19,7 @@ #include "dirserv.h" #include "dirvote.h" #include "networkstatus.h" +#include "relay.h" #include "router.h" #include "routerlist.h" diff --git a/src/or/or.h b/src/or/or.h index 3823e31415..d3539c756e 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -3309,57 +3309,6 @@ typedef enum { ADDR_POLICY_PROBABLY_REJECTED=2 } addr_policy_result_t; -/********************************* relay.c ***************************/ - -extern uint64_t stats_n_relay_cells_relayed; -extern uint64_t stats_n_relay_cells_delivered; - -int circuit_receive_relay_cell(cell_t *cell, circuit_t *circ, - cell_direction_t cell_direction); - -void relay_header_pack(char *dest, const relay_header_t *src); -void relay_header_unpack(relay_header_t *dest, const char *src); -int relay_send_command_from_edge(streamid_t stream_id, circuit_t *circ, - uint8_t relay_command, const char *payload, - size_t payload_len, crypt_path_t *cpath_layer); -int connection_edge_send_command(edge_connection_t *fromconn, - uint8_t relay_command, const char *payload, - size_t payload_len); -int connection_edge_package_raw_inbuf(edge_connection_t *conn, - int package_partial); -void connection_edge_consider_sending_sendme(edge_connection_t *conn); - -extern uint64_t stats_n_data_cells_packaged; -extern uint64_t stats_n_data_bytes_packaged; -extern uint64_t stats_n_data_cells_received; -extern uint64_t stats_n_data_bytes_received; - -void init_cell_pool(void); -void free_cell_pool(void); -void clean_cell_pool(void); -void dump_cell_pool_usage(int severity); - -void cell_queue_clear(cell_queue_t *queue); -void cell_queue_append(cell_queue_t *queue, packed_cell_t *cell); -void cell_queue_append_packed_copy(cell_queue_t *queue, const cell_t *cell); - -void append_cell_to_circuit_queue(circuit_t *circ, or_connection_t *orconn, - cell_t *cell, cell_direction_t direction); -void connection_or_unlink_all_active_circs(or_connection_t *conn); -int connection_or_flush_from_first_active_circuit(or_connection_t *conn, - int max, time_t now); -void assert_active_circuits_ok(or_connection_t *orconn); -void make_circuit_inactive_on_conn(circuit_t *circ, or_connection_t *conn); -void make_circuit_active_on_conn(circuit_t *circ, or_connection_t *conn); - -int append_address_to_payload(char *payload_out, const tor_addr_t *addr); -const char *decode_address_from_payload(tor_addr_t *addr_out, - const char *payload, - int payload_len); -unsigned cell_ewma_get_tick(void); -void cell_ewma_set_scale_factor(or_options_t *options, - networkstatus_t *consensus); - /********************************* rephist.c ***************************/ void rep_hist_init(void); diff --git a/src/or/relay.c b/src/or/relay.c index 9fd75736bb..a40013ab47 100644 --- a/src/or/relay.c +++ b/src/or/relay.c @@ -26,6 +26,7 @@ #include "networkstatus.h" #include "policies.h" #include "reasons.h" +#include "relay.h" #include "rendcommon.h" #include "routerlist.h" diff --git a/src/or/relay.h b/src/or/relay.h new file mode 100644 index 0000000000..73855a52bf --- /dev/null +++ b/src/or/relay.h @@ -0,0 +1,65 @@ +/* Copyright (c) 2001 Matej Pfajfar. + * Copyright (c) 2001-2004, Roger Dingledine. + * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. + * Copyright (c) 2007-2010, The Tor Project, Inc. */ +/* See LICENSE for licensing information */ + +/** + * \file relay.h + * \brief Header file for relay.c. + **/ + +#ifndef _TOR_RELAY_H +#define _TOR_RELAY_H + +extern uint64_t stats_n_relay_cells_relayed; +extern uint64_t stats_n_relay_cells_delivered; + +int circuit_receive_relay_cell(cell_t *cell, circuit_t *circ, + cell_direction_t cell_direction); + +void relay_header_pack(char *dest, const relay_header_t *src); +void relay_header_unpack(relay_header_t *dest, const char *src); +int relay_send_command_from_edge(streamid_t stream_id, circuit_t *circ, + uint8_t relay_command, const char *payload, + size_t payload_len, crypt_path_t *cpath_layer); +int connection_edge_send_command(edge_connection_t *fromconn, + uint8_t relay_command, const char *payload, + size_t payload_len); +int connection_edge_package_raw_inbuf(edge_connection_t *conn, + int package_partial); +void connection_edge_consider_sending_sendme(edge_connection_t *conn); + +extern uint64_t stats_n_data_cells_packaged; +extern uint64_t stats_n_data_bytes_packaged; +extern uint64_t stats_n_data_cells_received; +extern uint64_t stats_n_data_bytes_received; + +void init_cell_pool(void); +void free_cell_pool(void); +void clean_cell_pool(void); +void dump_cell_pool_usage(int severity); + +void cell_queue_clear(cell_queue_t *queue); +void cell_queue_append(cell_queue_t *queue, packed_cell_t *cell); +void cell_queue_append_packed_copy(cell_queue_t *queue, const cell_t *cell); + +void append_cell_to_circuit_queue(circuit_t *circ, or_connection_t *orconn, + cell_t *cell, cell_direction_t direction); +void connection_or_unlink_all_active_circs(or_connection_t *conn); +int connection_or_flush_from_first_active_circuit(or_connection_t *conn, + int max, time_t now); +void assert_active_circuits_ok(or_connection_t *orconn); +void make_circuit_inactive_on_conn(circuit_t *circ, or_connection_t *conn); +void make_circuit_active_on_conn(circuit_t *circ, or_connection_t *conn); + +int append_address_to_payload(char *payload_out, const tor_addr_t *addr); +const char *decode_address_from_payload(tor_addr_t *addr_out, + const char *payload, + int payload_len); +unsigned cell_ewma_get_tick(void); +void cell_ewma_set_scale_factor(or_options_t *options, + networkstatus_t *consensus); + +#endif + diff --git a/src/or/rendclient.c b/src/or/rendclient.c index 7f5fcefb52..166d38da89 100644 --- a/src/or/rendclient.c +++ b/src/or/rendclient.c @@ -16,6 +16,7 @@ #include "connection_edge.h" #include "directory.h" #include "main.h" +#include "relay.h" #include "rendclient.h" #include "rendcommon.h" #include "routerlist.h" diff --git a/src/or/rendmid.c b/src/or/rendmid.c index f99654372a..393347b6db 100644 --- a/src/or/rendmid.c +++ b/src/or/rendmid.c @@ -10,6 +10,7 @@ #include "or.h" #include "circuitlist.h" #include "config.h" +#include "relay.h" /** Respond to an ESTABLISH_INTRO cell by checking the signed data and * setting the circuit's purpose and service pk digest. diff --git a/src/or/rendservice.c b/src/or/rendservice.c index 0324102d92..2c1c8cfde4 100644 --- a/src/or/rendservice.c +++ b/src/or/rendservice.c @@ -18,6 +18,7 @@ #include "rendcommon.h" #include "rendservice.h" #include "router.h" +#include "relay.h" #include "routerlist.h" static origin_circuit_t *find_intro_circuit(rend_intro_point_t *intro, diff --git a/src/or/router.c b/src/or/router.c index 4a18916990..bf42566779 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -19,6 +19,7 @@ #include "hibernate.h" #include "main.h" #include "policies.h" +#include "relay.h" #include "router.h" #include "routerlist.h"