connection_edge.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 connection_edge.h
  8. * \brief Header file for connection_edge.c.
  9. **/
  10. #ifndef TOR_CONNECTION_EDGE_H
  11. #define TOR_CONNECTION_EDGE_H
  12. #define connection_mark_unattached_ap(conn, endreason) \
  13. connection_mark_unattached_ap_((conn), (endreason), __LINE__, SHORT_FILE__)
  14. void connection_mark_unattached_ap_(entry_connection_t *conn, int endreason,
  15. int line, const char *file);
  16. int connection_edge_reached_eof(edge_connection_t *conn);
  17. int connection_edge_process_inbuf(edge_connection_t *conn,
  18. int package_partial);
  19. int connection_edge_destroy(circid_t circ_id, edge_connection_t *conn);
  20. int connection_edge_end(edge_connection_t *conn, uint8_t reason);
  21. int connection_edge_end_errno(edge_connection_t *conn);
  22. int connection_edge_flushed_some(edge_connection_t *conn);
  23. int connection_edge_finished_flushing(edge_connection_t *conn);
  24. int connection_edge_finished_connecting(edge_connection_t *conn);
  25. void connection_ap_about_to_close(entry_connection_t *edge_conn);
  26. void connection_exit_about_to_close(edge_connection_t *edge_conn);
  27. int connection_ap_handshake_send_begin(entry_connection_t *ap_conn);
  28. int connection_ap_handshake_send_resolve(entry_connection_t *ap_conn);
  29. entry_connection_t *connection_ap_make_link(connection_t *partner,
  30. char *address, uint16_t port,
  31. const char *digest,
  32. int session_group,
  33. int isolation_flags,
  34. int use_begindir, int want_onehop);
  35. void connection_ap_handshake_socks_reply(entry_connection_t *conn, char *reply,
  36. size_t replylen,
  37. int endreason);
  38. void connection_ap_handshake_socks_resolved(entry_connection_t *conn,
  39. int answer_type,
  40. size_t answer_len,
  41. const uint8_t *answer,
  42. int ttl,
  43. time_t expires);
  44. int connection_exit_begin_conn(cell_t *cell, circuit_t *circ);
  45. int connection_exit_begin_resolve(cell_t *cell, or_circuit_t *circ);
  46. void connection_exit_connect(edge_connection_t *conn);
  47. int connection_edge_is_rendezvous_stream(edge_connection_t *conn);
  48. int connection_ap_can_use_exit(const entry_connection_t *conn,
  49. const node_t *exit);
  50. void connection_ap_expire_beginning(void);
  51. void connection_ap_attach_pending(void);
  52. void connection_ap_fail_onehop(const char *failed_digest,
  53. cpath_build_state_t *build_state);
  54. void circuit_discard_optional_exit_enclaves(extend_info_t *info);
  55. int connection_ap_detach_retriable(entry_connection_t *conn,
  56. origin_circuit_t *circ,
  57. int reason);
  58. int connection_ap_process_transparent(entry_connection_t *conn);
  59. int address_is_invalid_destination(const char *address, int client);
  60. int connection_ap_rewrite_and_attach_if_allowed(entry_connection_t *conn,
  61. origin_circuit_t *circ,
  62. crypt_path_t *cpath);
  63. int connection_ap_handshake_rewrite_and_attach(entry_connection_t *conn,
  64. origin_circuit_t *circ,
  65. crypt_path_t *cpath);
  66. /** Possible return values for parse_extended_hostname. */
  67. typedef enum hostname_type_t {
  68. NORMAL_HOSTNAME, ONION_HOSTNAME, EXIT_HOSTNAME, BAD_HOSTNAME
  69. } hostname_type_t;
  70. hostname_type_t parse_extended_hostname(char *address);
  71. #if defined(HAVE_NET_IF_H) && defined(HAVE_NET_PFVAR_H)
  72. int get_pf_socket(void);
  73. #endif
  74. int connection_edge_compatible_with_circuit(const entry_connection_t *conn,
  75. const origin_circuit_t *circ);
  76. int connection_edge_update_circuit_isolation(const entry_connection_t *conn,
  77. origin_circuit_t *circ,
  78. int dry_run);
  79. void circuit_clear_isolation(origin_circuit_t *circ);
  80. /* DOCDOC*/
  81. #define BEGIN_FLAG_IPV6_OK (1u<<0)
  82. #define BEGIN_FLAG_IPV4_NOT_OK (1u<<1)
  83. #define BEGIN_FLAG_IPV6_PREFERRED (1u<<2)
  84. #ifdef CONNECTION_EDGE_PRIVATE
  85. /*DOCDOC*/
  86. typedef struct begin_cell_t {
  87. char *address;
  88. uint32_t flags;
  89. uint16_t port;
  90. uint16_t stream_id;
  91. unsigned is_begindir : 1;
  92. } begin_cell_t;
  93. int begin_cell_parse(const cell_t *cell, begin_cell_t *bcell,
  94. uint8_t *end_reason_out);
  95. int connected_cell_format_payload(uint8_t *payload_out,
  96. const tor_addr_t *addr,
  97. uint32_t ttl);
  98. #endif
  99. #endif