channeltls.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* * Copyright (c) 2012-2018, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. /**
  4. * \file channeltls.h
  5. * \brief Header file for channeltls.c
  6. **/
  7. #ifndef TOR_CHANNELTLS_H
  8. #define TOR_CHANNELTLS_H
  9. #include "or/or.h"
  10. #include "or/channel.h"
  11. #define BASE_CHAN_TO_TLS(c) (channel_tls_from_base((c)))
  12. #define TLS_CHAN_TO_BASE(c) (channel_tls_to_base((c)))
  13. #define TLS_CHAN_MAGIC 0x8a192427U
  14. #ifdef TOR_CHANNEL_INTERNAL_
  15. struct channel_tls_s {
  16. /* Base channel_t struct */
  17. channel_t base_;
  18. /* or_connection_t pointer */
  19. or_connection_t *conn;
  20. };
  21. #endif /* defined(TOR_CHANNEL_INTERNAL_) */
  22. channel_t * channel_tls_connect(const tor_addr_t *addr, uint16_t port,
  23. const char *id_digest,
  24. const ed25519_public_key_t *ed_id);
  25. channel_listener_t * channel_tls_get_listener(void);
  26. channel_listener_t * channel_tls_start_listener(void);
  27. channel_t * channel_tls_handle_incoming(or_connection_t *orconn);
  28. /* Casts */
  29. channel_t * channel_tls_to_base(channel_tls_t *tlschan);
  30. channel_tls_t * channel_tls_from_base(channel_t *chan);
  31. /* Things for connection_or.c to call back into */
  32. void channel_tls_handle_cell(cell_t *cell, or_connection_t *conn);
  33. void channel_tls_handle_state_change_on_orconn(channel_tls_t *chan,
  34. or_connection_t *conn,
  35. uint8_t old_state,
  36. uint8_t state);
  37. void channel_tls_handle_var_cell(var_cell_t *var_cell,
  38. or_connection_t *conn);
  39. void channel_tls_update_marks(or_connection_t *conn);
  40. /* Cleanup at shutdown */
  41. void channel_tls_free_all(void);
  42. extern uint64_t stats_n_authorize_cells_processed;
  43. extern uint64_t stats_n_authenticate_cells_processed;
  44. extern uint64_t stats_n_versions_cells_processed;
  45. extern uint64_t stats_n_netinfo_cells_processed;
  46. extern uint64_t stats_n_vpadding_cells_processed;
  47. extern uint64_t stats_n_certs_cells_processed;
  48. extern uint64_t stats_n_auth_challenge_cells_processed;
  49. #ifdef CHANNELTLS_PRIVATE
  50. STATIC void channel_tls_process_certs_cell(var_cell_t *cell,
  51. channel_tls_t *tlschan);
  52. STATIC void channel_tls_process_auth_challenge_cell(var_cell_t *cell,
  53. channel_tls_t *tlschan);
  54. STATIC void channel_tls_common_init(channel_tls_t *tlschan);
  55. STATIC void channel_tls_process_authenticate_cell(var_cell_t *cell,
  56. channel_tls_t *tlschan);
  57. #endif /* defined(CHANNELTLS_PRIVATE) */
  58. #endif /* !defined(TOR_CHANNELTLS_H) */