rendcommon.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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-2015, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. /**
  7. * \file rendcommon.h
  8. * \brief Header file for rendcommon.c.
  9. **/
  10. #ifndef TOR_RENDCOMMON_H
  11. #define TOR_RENDCOMMON_H
  12. /** Free all storage associated with <b>data</b> */
  13. static INLINE void
  14. rend_data_free(rend_data_t *data)
  15. {
  16. tor_free(data);
  17. }
  18. int rend_cmp_service_ids(const char *one, const char *two);
  19. void rend_process_relay_cell(circuit_t *circ, const crypt_path_t *layer_hint,
  20. int command, size_t length,
  21. const uint8_t *payload);
  22. void rend_service_descriptor_free(rend_service_descriptor_t *desc);
  23. int rend_get_service_id(crypto_pk_t *pk, char *out);
  24. void rend_encoded_v2_service_descriptor_free(
  25. rend_encoded_v2_service_descriptor_t *desc);
  26. void rend_intro_point_free(rend_intro_point_t *intro);
  27. void rend_cache_init(void);
  28. void rend_cache_clean(time_t now);
  29. void rend_cache_clean_v2_descs_as_dir(time_t now, size_t min_to_remove);
  30. void rend_cache_purge(void);
  31. void rend_cache_free_all(void);
  32. int rend_valid_service_id(const char *query);
  33. int rend_valid_descriptor_id(const char *query);
  34. int rend_cache_lookup_entry(const char *query, int version,
  35. rend_cache_entry_t **entry_out);
  36. int rend_cache_lookup_v2_desc_as_dir(const char *query, const char **desc);
  37. /** Return value from rend_cache_store_v2_desc_as_{dir,client}. */
  38. typedef enum {
  39. RCS_NOTDIR = -2, /**< We're not a directory */
  40. RCS_BADDESC = -1, /**< This descriptor is no good. */
  41. RCS_OKAY = 0 /**< All worked as expected */
  42. } rend_cache_store_status_t;
  43. rend_cache_store_status_t rend_cache_store_v2_desc_as_dir(const char *desc);
  44. rend_cache_store_status_t rend_cache_store_v2_desc_as_client(const char *desc,
  45. const char *desc_id_base32,
  46. const rend_data_t *rend_query,
  47. rend_cache_entry_t **entry);
  48. int rend_encode_v2_descriptors(smartlist_t *descs_out,
  49. rend_service_descriptor_t *desc, time_t now,
  50. uint8_t period, rend_auth_type_t auth_type,
  51. crypto_pk_t *client_key,
  52. smartlist_t *client_cookies);
  53. int rend_compute_v2_desc_id(char *desc_id_out, const char *service_id,
  54. const char *descriptor_cookie,
  55. time_t now, uint8_t replica);
  56. int rend_id_is_in_interval(const char *a, const char *b, const char *c);
  57. void rend_get_descriptor_id_bytes(char *descriptor_id_out,
  58. const char *service_id,
  59. const char *secret_id_part);
  60. size_t rend_cache_get_total_allocation(void);
  61. rend_data_t *rend_data_client_create(const char *onion_address,
  62. const char *desc_id,
  63. const char *cookie,
  64. rend_auth_type_t auth_type);
  65. rend_data_t *rend_data_service_create(const char *onion_address,
  66. const char *pk_digest,
  67. const uint8_t *cookie,
  68. rend_auth_type_t auth_type);
  69. #endif