Back to index

tor  0.2.3.19-rc
relay.h
Go to the documentation of this file.
00001 /* Copyright (c) 2001 Matej Pfajfar.
00002  * Copyright (c) 2001-2004, Roger Dingledine.
00003  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
00004  * Copyright (c) 2007-2012, The Tor Project, Inc. */
00005 /* See LICENSE for licensing information */
00006 
00012 #ifndef _TOR_RELAY_H
00013 #define _TOR_RELAY_H
00014 
00015 extern uint64_t stats_n_relay_cells_relayed;
00016 extern uint64_t stats_n_relay_cells_delivered;
00017 
00018 int circuit_receive_relay_cell(cell_t *cell, circuit_t *circ,
00019                                cell_direction_t cell_direction);
00020 
00021 void relay_header_pack(uint8_t *dest, const relay_header_t *src);
00022 void relay_header_unpack(relay_header_t *dest, const uint8_t *src);
00023 int relay_send_command_from_edge(streamid_t stream_id, circuit_t *circ,
00024                                uint8_t relay_command, const char *payload,
00025                                size_t payload_len, crypt_path_t *cpath_layer);
00026 int connection_edge_send_command(edge_connection_t *fromconn,
00027                                  uint8_t relay_command, const char *payload,
00028                                  size_t payload_len);
00029 int connection_edge_package_raw_inbuf(edge_connection_t *conn,
00030                                       int package_partial,
00031                                       int *max_cells);
00032 void connection_edge_consider_sending_sendme(edge_connection_t *conn);
00033 
00034 extern uint64_t stats_n_data_cells_packaged;
00035 extern uint64_t stats_n_data_bytes_packaged;
00036 extern uint64_t stats_n_data_cells_received;
00037 extern uint64_t stats_n_data_bytes_received;
00038 
00039 void init_cell_pool(void);
00040 void free_cell_pool(void);
00041 void clean_cell_pool(void);
00042 void dump_cell_pool_usage(int severity);
00043 
00044 void cell_queue_clear(cell_queue_t *queue);
00045 void cell_queue_append(cell_queue_t *queue, packed_cell_t *cell);
00046 void cell_queue_append_packed_copy(cell_queue_t *queue, const cell_t *cell);
00047 
00048 void append_cell_to_circuit_queue(circuit_t *circ, or_connection_t *orconn,
00049                                   cell_t *cell, cell_direction_t direction,
00050                                   streamid_t fromstream);
00051 void connection_or_unlink_all_active_circs(or_connection_t *conn);
00052 int connection_or_flush_from_first_active_circuit(or_connection_t *conn,
00053                                                   int max, time_t now);
00054 void assert_active_circuits_ok(or_connection_t *orconn);
00055 void make_circuit_inactive_on_conn(circuit_t *circ, or_connection_t *conn);
00056 void make_circuit_active_on_conn(circuit_t *circ, or_connection_t *conn);
00057 
00058 int append_address_to_payload(uint8_t *payload_out, const tor_addr_t *addr);
00059 const uint8_t *decode_address_from_payload(tor_addr_t *addr_out,
00060                                         const uint8_t *payload,
00061                                         int payload_len);
00062 unsigned cell_ewma_get_tick(void);
00063 void cell_ewma_set_scale_factor(const or_options_t *options,
00064                                 const networkstatus_t *consensus);
00065 void circuit_clear_cell_queue(circuit_t *circ, or_connection_t *orconn);
00066 
00067 #ifdef RELAY_PRIVATE
00068 int relay_crypt(circuit_t *circ, cell_t *cell, cell_direction_t cell_direction,
00069                 crypt_path_t **layer_hint, char *recognized);
00070 #endif
00071 
00072 #endif
00073