tor  0.4.0.0-alpha-dev
consdiffmgr.h
1 /* Copyright (c) 2017-2018, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
3 
4 #ifndef TOR_CONSDIFFMGR_H
5 #define TOR_CONSDIFFMGR_H
6 
8 
12 typedef enum consdiff_status_t {
13  CONSDIFF_AVAILABLE,
14  CONSDIFF_NOT_FOUND,
15  CONSDIFF_IN_PROGRESS,
16 } consdiff_status_t;
17 
18 typedef struct consdiff_cfg_t {
19  int32_t cache_max_num;
21 
22 struct consensus_cache_entry_t; // from conscache.h
23 
24 int consdiffmgr_add_consensus(const char *consensus,
25  size_t consensus_len,
26  const networkstatus_t *as_parsed);
27 
28 consdiff_status_t consdiffmgr_find_consensus(
29  struct consensus_cache_entry_t **entry_out,
30  consensus_flavor_t flavor,
31  enum compress_method_t method);
32 
33 consdiff_status_t consdiffmgr_find_diff_from(
34  struct consensus_cache_entry_t **entry_out,
35  consensus_flavor_t flavor,
36  int digest_type,
37  const uint8_t *digest,
38  size_t digestlen,
39  enum compress_method_t method);
40 
41 int consensus_cache_entry_get_voter_id_digests(
42  const struct consensus_cache_entry_t *ent,
43  smartlist_t *out);
44 int consensus_cache_entry_get_fresh_until(
45  const struct consensus_cache_entry_t *ent,
46  time_t *out);
47 int consensus_cache_entry_get_valid_until(
48  const struct consensus_cache_entry_t *ent,
49  time_t *out);
50 int consensus_cache_entry_get_valid_after(
51  const struct consensus_cache_entry_t *ent,
52  time_t *out);
53 
54 void consdiffmgr_rescan(void);
55 int consdiffmgr_cleanup(void);
56 void consdiffmgr_enable_background_compression(void);
57 void consdiffmgr_configure(const consdiff_cfg_t *cfg);
58 struct sandbox_cfg_elem;
59 int consdiffmgr_register_with_sandbox(struct sandbox_cfg_elem **cfg);
60 void consdiffmgr_free_all(void);
61 int consdiffmgr_validate(void);
62 
63 #ifdef CONSDIFFMGR_PRIVATE
64 STATIC unsigned n_diff_compression_methods(void);
65 STATIC unsigned n_consensus_compression_methods(void);
66 STATIC consensus_cache_t *cdm_cache_get(void);
67 STATIC consensus_cache_entry_t *cdm_cache_lookup_consensus(
68  consensus_flavor_t flavor, time_t valid_after);
69 STATIC int cdm_entry_get_sha3_value(uint8_t *digest_out,
71  const char *label);
72 STATIC int uncompress_or_set_ptr(const char **out, size_t *outlen,
73  char **owned_out,
75 #endif /* defined(CONSDIFFMGR_PRIVATE) */
76 
77 #ifdef TOR_UNIT_TESTS
78 int consdiffmgr_add_consensus_nulterm(const char *consensus,
79  const networkstatus_t *as_parsed);
80 #endif
81 
82 #endif /* !defined(TOR_CONSDIFFMGR_H) */
Definition: conscache.c:27
consensus_flavor_t
Definition: or.h:863
compress_method_t
Definition: compress.h:21