hs_client.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* Copyright (c) 2017, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. /**
  4. * \file hs_client.h
  5. * \brief Header file containing client data for the HS subsytem.
  6. **/
  7. #ifndef TOR_HS_CLIENT_H
  8. #define TOR_HS_CLIENT_H
  9. #include "crypto_ed25519.h"
  10. #include "hs_descriptor.h"
  11. #include "hs_ident.h"
  12. /* Status code of a descriptor fetch request. */
  13. typedef enum {
  14. /* Something internally went wrong. */
  15. HS_CLIENT_FETCH_ERROR = -1,
  16. /* The fetch request has been launched successfully. */
  17. HS_CLIENT_FETCH_LAUNCHED = 0,
  18. /* We already have a usable descriptor. No fetch. */
  19. HS_CLIENT_FETCH_HAVE_DESC = 1,
  20. /* No more HSDir available to query. */
  21. HS_CLIENT_FETCH_NO_HSDIRS = 2,
  22. /* The fetch request is not allowed. */
  23. HS_CLIENT_FETCH_NOT_ALLOWED = 3,
  24. /* We are missing information to be able to launch a request. */
  25. HS_CLIENT_FETCH_MISSING_INFO = 4,
  26. /* There is a pending fetch for the requested service. */
  27. HS_CLIENT_FETCH_PENDING = 5,
  28. } hs_client_fetch_status_t;
  29. void hs_client_note_connection_attempt_succeeded(
  30. const edge_connection_t *conn);
  31. int hs_client_decode_descriptor(
  32. const char *desc_str,
  33. const ed25519_public_key_t *service_identity_pk,
  34. hs_descriptor_t **desc);
  35. int hs_client_any_intro_points_usable(const ed25519_public_key_t *service_pk,
  36. const hs_descriptor_t *desc);
  37. int hs_client_refetch_hsdesc(const ed25519_public_key_t *identity_pk);
  38. void hs_client_dir_info_changed(void);
  39. int hs_client_send_introduce1(origin_circuit_t *intro_circ,
  40. origin_circuit_t *rend_circ);
  41. void hs_client_circuit_has_opened(origin_circuit_t *circ);
  42. int hs_client_receive_rendezvous_acked(origin_circuit_t *circ,
  43. const uint8_t *payload,
  44. size_t payload_len);
  45. int hs_client_receive_introduce_ack(origin_circuit_t *circ,
  46. const uint8_t *payload,
  47. size_t payload_len);
  48. int hs_client_receive_rendezvous2(origin_circuit_t *circ,
  49. const uint8_t *payload,
  50. size_t payload_len);
  51. void hs_client_desc_has_arrived(const hs_ident_dir_conn_t *ident);
  52. extend_info_t *hs_client_get_random_intro_from_edge(
  53. const edge_connection_t *edge_conn);
  54. int hs_client_reextend_intro_circuit(origin_circuit_t *circ);
  55. void hs_client_purge_state(void);
  56. void hs_client_free_all(void);
  57. #ifdef HS_CLIENT_PRIVATE
  58. STATIC routerstatus_t *
  59. pick_hsdir_v3(const ed25519_public_key_t *onion_identity_pk);
  60. STATIC extend_info_t *
  61. client_get_random_intro(const ed25519_public_key_t *service_pk);
  62. STATIC extend_info_t *
  63. desc_intro_point_to_extend_info(const hs_desc_intro_point_t *ip);
  64. STATIC int handle_rendezvous2(origin_circuit_t *circ, const uint8_t *payload,
  65. size_t payload_len);
  66. MOCK_DECL(STATIC hs_client_fetch_status_t,
  67. fetch_v3_desc, (const ed25519_public_key_t *onion_identity_pk));
  68. #endif /* defined(HS_CLIENT_PRIVATE) */
  69. #endif /* !defined(TOR_HS_CLIENT_H) */