Data Structures | Macros | Enumerations | Functions
dirserv.h File Reference

Header file for dirserv.c. More...

#include "lib/testsupport/testsupport.h"

Go to the source code of this file.

Data Structures

struct  spooled_resource_t


#define dir_spool_source_bitfield_t   ENUM_BF(dir_spool_source_t)
#define have_module_dircache()   (0)
#define directory_caches_unknown_auth_certs(opt)    ((void)(opt), 0)
#define directory_caches_dir_info(opt)    ((void)(opt), 0)
#define directory_permits_begindir_requests(opt)    ((void)(opt), 0)
#define dirserv_get_consensus(flav)    ((void)(flav), NULL)
#define dirserv_set_cached_consensus_networkstatus(a, b, c, d, e, f)
#define spooled_resource_free(sp)    FREE_AND_NULL(spooled_resource_t, spooled_resource_free_, (sp))


enum  dir_spool_source_t {


int connection_dirserv_flushed_some (dir_connection_t *conn)
int dir_split_resource_into_spoolable (const char *resource, enum dir_spool_source_t source, smartlist_t *spool_out, int *compressed_out, int flags)
void dirserv_clear_old_networkstatuses (time_t cutoff)
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)
void dirserv_free_all (void)
void cached_dir_decref (cached_dir_t *d)
cached_dir_tnew_cached_dir (char *s, time_t published)
spooled_resource_tspooled_resource_new (dir_spool_source_t source, const uint8_t *digest, size_t digestlen)
spooled_resource_tspooled_resource_new_from_cache_entry (struct consensus_cache_entry_t *entry)
void spooled_resource_free_ (spooled_resource_t *spooled)
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)
void dirserv_spool_sort (dir_connection_t *conn)
void dir_conn_clear_spool (dir_connection_t *conn)

Detailed Description

Header file for dirserv.c.

Definition in file dirserv.h.

Macro Definition Documentation

◆ dir_spool_source_bitfield_t

#define dir_spool_source_bitfield_t   ENUM_BF(dir_spool_source_t)

Definition at line 27 of file dirserv.h.

◆ directory_caches_dir_info

#define directory_caches_dir_info (   opt)     ((void)(opt), 0)

Definition at line 100 of file dirserv.h.

◆ directory_caches_unknown_auth_certs

#define directory_caches_unknown_auth_certs (   opt)     ((void)(opt), 0)

Definition at line 98 of file dirserv.h.

◆ directory_permits_begindir_requests

#define directory_permits_begindir_requests (   opt)     ((void)(opt), 0)

Definition at line 102 of file dirserv.h.

◆ dirserv_get_consensus

#define dirserv_get_consensus (   flav)     ((void)(flav), NULL)

Definition at line 104 of file dirserv.h.

◆ dirserv_set_cached_consensus_networkstatus

#define dirserv_set_cached_consensus_networkstatus (   a,
(void)(a); \
(void)(b); \
(void)(c); \
(void)(d); \
(void)(e); \
(void)(f); \

Definition at line 106 of file dirserv.h.

◆ have_module_dircache

#define have_module_dircache ( )    (0)

Definition at line 97 of file dirserv.h.

◆ spooled_resource_free

#define spooled_resource_free (   sp)     FREE_AND_NULL(spooled_resource_t, spooled_resource_free_, (sp))

Definition at line 133 of file dirserv.h.

Enumeration Type Documentation

◆ dir_spool_source_t

Ways to convert a spoolable_resource_t to a bunch of bytes.

Definition at line 20 of file dirserv.h.

Function Documentation

◆ cached_dir_decref()

void cached_dir_decref ( cached_dir_t d)

Decrement the reference count on d, and free it if it no longer has any references.

Definition at line 124 of file dirserv.c.

Referenced by free_cached_dir_(), and spooled_resource_free_().

◆ connection_dirserv_flushed_some()

int connection_dirserv_flushed_some ( dir_connection_t conn)

Called whenever we have flushed some directory data in state SERVER_WRITING, or whenever we want to fill the buffer with initial directory data (so that subsequent writes will occur, and trigger this function again.)

Return 0 on success, and -1 on failure.

Definition at line 27 of file dircache_stub.c.

◆ dir_conn_clear_spool()

void dir_conn_clear_spool ( dir_connection_t conn)

Remove every element from conn's outgoing spool, and delete the spool.

Definition at line 36 of file dircache_stub.c.

◆ dir_split_resource_into_spoolable()

int dir_split_resource_into_spoolable ( const char *  resource,
dir_spool_source_t  source,
smartlist_t spool_out,
int *  compressed_out,
int  flags 

As dir_split_resource_into_fingerprints, but instead fills spool_out with a list of spoolable_resource_t for the resource identified through source.

Definition at line 212 of file dirserv.c.

Referenced by handle_get_microdesc().

◆ dirserv_free_all()

void dirserv_free_all ( void  )

Release all storage used by the directory server.

Definition at line 78 of file dircache_stub.c.

◆ dirserv_get_routerdesc_spool()

int dirserv_get_routerdesc_spool ( smartlist_t spool_out,
const char *  key,
dir_spool_source_t  source,
int  conn_is_encrypted,
const char **  msg_out 

As dirserv_get_routerdescs(), but instead of getting signed_descriptor_t pointers, adds copies of digests to fps_out, and doesn't use the /tor/server/ prefix. For a /d/ request, adds descriptor digests; for other requests, adds identity digests.

Definition at line 245 of file dirserv.c.

◆ dirserv_spool_remove_missing_and_guess_size()

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 

Try to guess the number of bytes that will be needed to send the spooled objects for conn's outgoing spool. In the process, remove every element of the spool that refers to an absent object, or which was published earlier than cutoff. Set *size_out to the number of bytes, and *n_expired_out to the number of objects removed for being too old.

Definition at line 644 of file dirserv.c.

◆ dirserv_spool_sort()

void dirserv_spool_sort ( dir_connection_t conn)

Sort all the entries in conn by digest.

Definition at line 697 of file dirserv.c.

◆ new_cached_dir()

cached_dir_t * new_cached_dir ( char *  s,
time_t  published 

Allocate and return a new cached_dir_t containing the string s, published at published.

Definition at line 135 of file dirserv.c.

Referenced by dirserv_set_cached_consensus_networkstatus().

◆ spooled_resource_free_()

void spooled_resource_free_ ( spooled_resource_t spooled)

Release all storage held by spooled.

Definition at line 366 of file dirserv.c.

◆ spooled_resource_new()

spooled_resource_t * spooled_resource_new ( dir_spool_source_t  source,
const uint8_t *  digest,
size_t  digestlen 

Definition at line 310 of file dirserv.c.

◆ spooled_resource_new_from_cache_entry()

spooled_resource_t * spooled_resource_new_from_cache_entry ( consensus_cache_entry_t entry)

Create a new spooled_resource_t to spool the contents of entry to the user. Return the spooled object on success, or NULL on failure (which is probably caused by a failure to map the body of the item from disk).

Adds a reference to entry's reference counter.

Definition at line 345 of file dirserv.c.