consdiffmgr.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* Copyright (c) 2017, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. #ifndef TOR_CONSDIFFMGR_H
  4. #define TOR_CONSDIFFMGR_H
  5. /**
  6. * Possible outcomes from trying to look up a given consensus diff.
  7. */
  8. typedef enum consdiff_status_t {
  9. CONSDIFF_AVAILABLE,
  10. CONSDIFF_NOT_FOUND,
  11. CONSDIFF_IN_PROGRESS,
  12. } consdiff_status_t;
  13. typedef struct consdiff_cfg_t {
  14. int32_t cache_max_age_hours;
  15. int32_t cache_max_num;
  16. } consdiff_cfg_t;
  17. struct consensus_cache_entry_t; // from conscache.h
  18. int consdiffmgr_add_consensus(const char *consensus,
  19. const networkstatus_t *as_parsed);
  20. consdiff_status_t consdiffmgr_find_consensus(
  21. struct consensus_cache_entry_t **entry_out,
  22. consensus_flavor_t flavor,
  23. compress_method_t method);
  24. consdiff_status_t consdiffmgr_find_diff_from(
  25. struct consensus_cache_entry_t **entry_out,
  26. consensus_flavor_t flavor,
  27. int digest_type,
  28. const uint8_t *digest,
  29. size_t digestlen,
  30. compress_method_t method);
  31. void consdiffmgr_rescan(void);
  32. int consdiffmgr_cleanup(void);
  33. void consdiffmgr_enable_background_compression(void);
  34. void consdiffmgr_configure(const consdiff_cfg_t *cfg);
  35. struct sandbox_cfg_elem;
  36. int consdiffmgr_register_with_sandbox(struct sandbox_cfg_elem **cfg);
  37. void consdiffmgr_free_all(void);
  38. int consdiffmgr_validate(void);
  39. #ifdef CONSDIFFMGR_PRIVATE
  40. STATIC unsigned n_diff_compression_methods(void);
  41. STATIC unsigned n_consensus_compression_methods(void);
  42. STATIC consensus_cache_t *cdm_cache_get(void);
  43. STATIC consensus_cache_entry_t *cdm_cache_lookup_consensus(
  44. consensus_flavor_t flavor, time_t valid_after);
  45. STATIC int cdm_entry_get_sha3_value(uint8_t *digest_out,
  46. consensus_cache_entry_t *ent,
  47. const char *label);
  48. STATIC int uncompress_or_copy(char **out, size_t *outlen,
  49. consensus_cache_entry_t *ent);
  50. #endif
  51. #endif