tor  0.4.1.0-alpha-dev
dirserv.h
Go to the documentation of this file.
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-2019, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6 
12 #ifndef TOR_DIRSERV_H
13 #define TOR_DIRSERV_H
14 
16 
18 
20 typedef enum dir_spool_source_t {
21  DIR_SPOOL_SERVER_BY_DIGEST=1, DIR_SPOOL_SERVER_BY_FP,
22  DIR_SPOOL_EXTRA_BY_DIGEST, DIR_SPOOL_EXTRA_BY_FP,
23  DIR_SPOOL_MICRODESC,
24  DIR_SPOOL_NETWORKSTATUS,
25  DIR_SPOOL_CONSENSUS_CACHE_ENTRY,
27 #define dir_spool_source_bitfield_t ENUM_BF(dir_spool_source_t)
28 
42 typedef struct spooled_resource_t {
47  unsigned spool_eagerly : 1;
51  dir_spool_source_bitfield_t spool_source : 7;
66  const uint8_t *cce_body;
67  size_t cce_len;
73 
75 
80 int directory_caches_dir_info(const or_options_t *options);
83  time_t now);
84 
85 cached_dir_t *dirserv_get_consensus(const char *flavor_name);
86 void dirserv_set_cached_consensus_networkstatus(const char *consensus,
87  size_t consensus_len,
88  const char *flavor_name,
89  const common_digests_t *digests,
90  const uint8_t *sha3_as_signed,
91  time_t published);
92 void dirserv_clear_old_networkstatuses(time_t cutoff);
93 int dirserv_get_routerdesc_spool(smartlist_t *spools_out, const char *key,
94  dir_spool_source_t source,
95  int conn_is_encrypted,
96  const char **msg_out);
97 int dirserv_get_routerdescs(smartlist_t *descs_out, const char *key,
98  const char **msg);
99 
100 void dirserv_free_all(void);
102 cached_dir_t *new_cached_dir(char *s, time_t published);
103 
104 spooled_resource_t *spooled_resource_new(dir_spool_source_t source,
105  const uint8_t *digest,
106  size_t digestlen);
108  struct consensus_cache_entry_t *entry);
110 #define spooled_resource_free(sp) \
111  FREE_AND_NULL(spooled_resource_t, spooled_resource_free_, (sp))
113  time_t cutoff,
114  int compression,
115  size_t *size_out,
116  int *n_expired_out);
119 
120 #endif /* !defined(TOR_DIRSERV_H) */
int dirserv_get_routerdesc_spool(smartlist_t *spools_out, const char *key, dir_spool_source_t source, int conn_is_encrypted, const char **msg_out)
Definition: dirserv.c:276
dir_spool_source_bitfield_t spool_source
Definition: dirserv.h:51
void cached_dir_decref(cached_dir_t *d)
Definition: dirserv.c:186
int directory_too_idle_to_fetch_descriptors(const or_options_t *options, time_t now)
Definition: dirserv.c:169
int directory_fetches_dir_info_early(const or_options_t *options)
Definition: dirserv.c:105
struct spooled_resource_t spooled_resource_t
int connection_dirserv_flushed_some(dir_connection_t *conn)
Definition: dirserv.c:854
void dirserv_set_cached_consensus_networkstatus(const char *consensus, size_t consensus_len, const char *flavor_name, const common_digests_t *digests, const uint8_t *sha3_as_signed, time_t published)
Definition: dirserv.c:236
void spooled_resource_free_(spooled_resource_t *spooled)
Definition: dirserv.c:478
int directory_fetches_from_authorities(const or_options_t *options)
Definition: dirserv.c:77
int directory_caches_unknown_auth_certs(const or_options_t *options)
Definition: dirserv.c:128
struct cached_dir_t * cached_dir_ref
Definition: dirserv.h:60
unsigned spool_eagerly
Definition: dirserv.h:47
uint8_t digest[DIGEST256_LEN]
Definition: dirserv.h:55
int directory_caches_dir_info(const or_options_t *options)
Definition: dirserv.c:143
off_t cached_dir_offset
Definition: dirserv.h:71
cached_dir_t * new_cached_dir(char *s, time_t published)
Definition: dirserv.c:197
struct consensus_cache_entry_t * consensus_cache_entry
Definition: dirserv.h:65
Definition: conscache.c:27
int dirserv_get_routerdescs(smartlist_t *descs_out, const char *key, const char **msg)
Definition: dirserv.c:355
#define DIGEST256_LEN
Definition: digest_sizes.h:23
int directory_fetches_dir_info_later(const or_options_t *options)
Definition: dirserv.c:117
dir_spool_source_t
Definition: dirserv.h:20
int directory_permits_begindir_requests(const or_options_t *options)
Definition: dirserv.c:159
void dirserv_spool_sort(dir_connection_t *conn)
Definition: dirserv.c:809
void dirserv_free_all(void)
Definition: dirserv.c:911
Macros to implement mocking and selective exposure for the test code.
spooled_resource_t * spooled_resource_new_from_cache_entry(struct consensus_cache_entry_t *entry)
Definition: dirserv.c:457
void dir_conn_clear_spool(dir_connection_t *conn)
Definition: dirserv.c:899
cached_dir_t * dirserv_get_consensus(const char *flavor_name)
Definition: dirserv.c:263
void dirserv_spool_remove_missing_and_guess_size(dir_connection_t *conn, time_t cutoff, int compression, size_t *size_out, int *n_expired_out)
Definition: dirserv.c:756