Tor  0.4.7.0-alpha-dev
consdiffmgr.h
Go to the documentation of this file.
1 /* Copyright (c) 2017-2021, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
3 
4 /**
5  * @file consdiffmgr.h
6  * @brief Header for consdiffmgr.c
7  **/
8 
9 #ifndef TOR_CONSDIFFMGR_H
10 #define TOR_CONSDIFFMGR_H
11 
13 
14 /**
15  * Possible outcomes from trying to look up a given consensus diff.
16  */
17 typedef enum consdiff_status_t {
18  CONSDIFF_AVAILABLE,
19  CONSDIFF_NOT_FOUND,
20  CONSDIFF_IN_PROGRESS,
22 
23 typedef struct consdiff_cfg_t {
24  int32_t cache_max_num;
26 
27 struct consensus_cache_entry_t; // from conscache.h
28 
29 int consdiffmgr_add_consensus(const char *consensus,
30  size_t consensus_len,
31  const networkstatus_t *as_parsed);
32 
34  struct consensus_cache_entry_t **entry_out,
35  consensus_flavor_t flavor,
36  enum compress_method_t method);
37 
39  struct consensus_cache_entry_t **entry_out,
40  consensus_flavor_t flavor,
41  int digest_type,
42  const uint8_t *digest,
43  size_t digestlen,
44  enum compress_method_t method);
45 
47  const struct consensus_cache_entry_t *ent,
48  smartlist_t *out);
50  const struct consensus_cache_entry_t *ent,
51  time_t *out);
53  const struct consensus_cache_entry_t *ent,
54  time_t *out);
56  const struct consensus_cache_entry_t *ent,
57  time_t *out);
58 
59 void consdiffmgr_rescan(void);
60 int consdiffmgr_cleanup(void);
62 void consdiffmgr_configure(const consdiff_cfg_t *cfg);
63 struct sandbox_cfg_elem_t;
64 int consdiffmgr_register_with_sandbox(struct sandbox_cfg_elem_t **cfg);
65 void consdiffmgr_free_all(void);
66 int consdiffmgr_validate(void);
67 
68 #ifdef CONSDIFFMGR_PRIVATE
69 struct consensus_cache_t;
71 STATIC unsigned n_diff_compression_methods(void);
75  consensus_flavor_t flavor, time_t valid_after);
76 STATIC int cdm_entry_get_sha3_value(uint8_t *digest_out,
77  struct consensus_cache_entry_t *ent,
78  const char *label);
79 STATIC int uncompress_or_set_ptr(const char **out, size_t *outlen,
80  char **owned_out,
81  struct consensus_cache_entry_t *ent);
82 #endif /* defined(CONSDIFFMGR_PRIVATE) */
83 
84 #ifdef TOR_UNIT_TESTS
85 int consdiffmgr_add_consensus_nulterm(const char *consensus,
86  const networkstatus_t *as_parsed);
87 #endif
88 
89 #endif /* !defined(TOR_CONSDIFFMGR_H) */
compress_method_t
Definition: compress.h:21
int consensus_cache_entry_get_valid_until(const consensus_cache_entry_t *ent, time_t *out)
Definition: consdiffmgr.c:1960
int consensus_cache_entry_get_fresh_until(const consensus_cache_entry_t *ent, time_t *out)
Definition: consdiffmgr.c:1944
STATIC consensus_cache_t * cdm_cache_get(void)
Definition: consdiffmgr.c:411
STATIC int cdm_entry_get_sha3_value(uint8_t *digest_out, consensus_cache_entry_t *ent, const char *label)
Definition: consdiffmgr.c:445
STATIC int uncompress_or_set_ptr(const char **out, size_t *outlen, char **owned_out, consensus_cache_entry_t *ent)
Definition: consdiffmgr.c:1425
STATIC unsigned n_consensus_compression_methods(void)
Definition: consdiffmgr.c:136
int consensus_cache_entry_get_voter_id_digests(const consensus_cache_entry_t *ent, smartlist_t *out)
Definition: consdiffmgr.c:1928
STATIC consensus_cache_entry_t * cdm_cache_lookup_consensus(consensus_flavor_t flavor, time_t valid_after)
Definition: consdiffmgr.c:469
STATIC unsigned n_diff_compression_methods(void)
Definition: consdiffmgr.c:118
int consensus_cache_entry_get_valid_after(const consensus_cache_entry_t *ent, time_t *out)
Definition: consdiffmgr.c:1977
void consdiffmgr_enable_background_compression(void)
Definition: consdiffmgr.c:1918
void consdiffmgr_configure(const consdiff_cfg_t *cfg)
Definition: consdiffmgr.c:844
int consdiffmgr_validate(void)
Definition: consdiffmgr.c:868
consdiff_status_t consdiffmgr_find_diff_from(struct consensus_cache_entry_t **entry_out, consensus_flavor_t flavor, int digest_type, const uint8_t *digest, size_t digestlen, enum compress_method_t method)
Definition: consdiffmgr.c:660
consdiff_status_t
Definition: consdiffmgr.h:17
int consdiffmgr_cleanup(void)
Definition: consdiffmgr.c:722
consdiff_status_t consdiffmgr_find_consensus(struct consensus_cache_entry_t **entry_out, consensus_flavor_t flavor, enum compress_method_t method)
Definition: consdiffmgr.c:629
int consdiffmgr_add_consensus(const char *consensus, size_t consensus_len, const networkstatus_t *as_parsed)
Definition: consdiffmgr.c:549
void consdiffmgr_rescan(void)
Definition: consdiffmgr.c:1121
void consdiffmgr_free_all(void)
Definition: consdiffmgr.c:1267
int consdiffmgr_register_with_sandbox(struct sandbox_cfg_elem_t **cfg)
Definition: consdiffmgr.c:857
consensus_flavor_t
Definition: or.h:761
Definition: conscache.c:32
#define STATIC
Definition: testsupport.h:32