relay.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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-2012, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. /**
  7. * \file relay.h
  8. * \brief Header file for relay.c.
  9. **/
  10. #ifndef _TOR_RELAY_H
  11. #define _TOR_RELAY_H
  12. extern uint64_t stats_n_relay_cells_relayed;
  13. extern uint64_t stats_n_relay_cells_delivered;
  14. int circuit_receive_relay_cell(cell_t *cell, circuit_t *circ,
  15. cell_direction_t cell_direction);
  16. void relay_header_pack(uint8_t *dest, const relay_header_t *src);
  17. void relay_header_unpack(relay_header_t *dest, const uint8_t *src);
  18. int relay_send_command_from_edge(streamid_t stream_id, circuit_t *circ,
  19. uint8_t relay_command, const char *payload,
  20. size_t payload_len, crypt_path_t *cpath_layer);
  21. int connection_edge_send_command(edge_connection_t *fromconn,
  22. uint8_t relay_command, const char *payload,
  23. size_t payload_len);
  24. int connection_edge_package_raw_inbuf(edge_connection_t *conn,
  25. int package_partial,
  26. int *max_cells);
  27. void connection_edge_consider_sending_sendme(edge_connection_t *conn);
  28. extern uint64_t stats_n_data_cells_packaged;
  29. extern uint64_t stats_n_data_bytes_packaged;
  30. extern uint64_t stats_n_data_cells_received;
  31. extern uint64_t stats_n_data_bytes_received;
  32. void init_cell_pool(void);
  33. void free_cell_pool(void);
  34. void clean_cell_pool(void);
  35. void dump_cell_pool_usage(int severity);
  36. void cell_queue_clear(cell_queue_t *queue);
  37. void cell_queue_append(cell_queue_t *queue, packed_cell_t *cell);
  38. void cell_queue_append_packed_copy(cell_queue_t *queue, const cell_t *cell);
  39. void append_cell_to_circuit_queue(circuit_t *circ, or_connection_t *orconn,
  40. cell_t *cell, cell_direction_t direction,
  41. streamid_t fromstream);
  42. void connection_or_unlink_all_active_circs(or_connection_t *conn);
  43. int connection_or_flush_from_first_active_circuit(or_connection_t *conn,
  44. int max, time_t now);
  45. void assert_active_circuits_ok(or_connection_t *orconn);
  46. void make_circuit_inactive_on_conn(circuit_t *circ, or_connection_t *conn);
  47. void make_circuit_active_on_conn(circuit_t *circ, or_connection_t *conn);
  48. int append_address_to_payload(uint8_t *payload_out, const tor_addr_t *addr);
  49. const uint8_t *decode_address_from_payload(tor_addr_t *addr_out,
  50. const uint8_t *payload,
  51. int payload_len);
  52. unsigned cell_ewma_get_tick(void);
  53. void cell_ewma_set_scale_factor(const or_options_t *options,
  54. const networkstatus_t *consensus);
  55. void circuit_clear_cell_queue(circuit_t *circ, or_connection_t *orconn);
  56. void tor_gettimeofday_cache_clear(void);
  57. #ifdef RELAY_PRIVATE
  58. int relay_crypt(circuit_t *circ, cell_t *cell, cell_direction_t cell_direction,
  59. crypt_path_t **layer_hint, char *recognized);
  60. #endif
  61. #endif