Tor  0.4.7.0-alpha-dev
dircollate.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-2021, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6 
7 /**
8  * \file dircollate.h
9  * \brief Header file for dircollate.c.
10  **/
11 
12 #ifndef TOR_DIRCOLLATE_H
13 #define TOR_DIRCOLLATE_H
14 
16 #include "core/or/or.h"
17 
18 typedef struct dircollator_t dircollator_t;
19 
20 dircollator_t *dircollator_new(int n_votes, int n_authorities);
21 void dircollator_free_(dircollator_t *obj);
22 #define dircollator_free(c) \
23  FREE_AND_NULL(dircollator_t, dircollator_free_, (c))
24 void dircollator_add_vote(dircollator_t *dc, networkstatus_t *v);
25 
26 void dircollator_collate(dircollator_t *dc, int consensus_method);
27 
28 int dircollator_n_routers(dircollator_t *dc);
30  int idx);
31 
32 #ifdef DIRCOLLATE_PRIVATE
33 struct ddmap_entry_t;
34 typedef HT_HEAD(double_digest_map, ddmap_entry_t) double_digest_map_t;
35 /** A dircollator keeps track of all the routerstatus entries in a
36  * set of networkstatus votes, and matches them by an appropriate rule. */
37 struct dircollator_t {
38  /** True iff we have run the collation algorithm. */
39  int is_collated;
40  /** The total number of votes that we received. */
41  int n_votes;
42  /** The total number of authorities we acknowledge. */
43  int n_authorities;
44 
45  /** The index which the next vote to be added to this collator should
46  * receive. */
47  int next_vote_num;
48  /** Map from RSA-SHA1 identity digest to an array of <b>n_votes</b>
49  * vote_routerstatus_t* pointers, such that the i'th member of the
50  * array is the i'th vote's entry for that RSA-SHA1 ID.*/
51  digestmap_t *by_rsa_sha1;
52  /** Map from <ed, RSA-SHA1> pair to an array similar to that used in
53  * by_rsa_sha1 above. We include <NULL,RSA-SHA1> entries for votes that
54  * say that there is no Ed key. */
55  struct double_digest_map by_both_ids;
56 
57  /** One of two outputs created by collation: a map from RSA-SHA1
58  * identity digest to an array of the vote_routerstatus_t objects. Entries
59  * only exist in this map for identities that we should include in the
60  * consensus. */
61  digestmap_t *by_collated_rsa_sha1;
62 
63  /** One of two outputs created by collation: a sorted array of RSA-SHA1
64  * identity digests .*/
65  smartlist_t *all_rsa_sha1_lst;
66 };
67 #endif /* defined(DIRCOLLATE_PRIVATE) */
68 
69 #endif /* !defined(TOR_DIRCOLLATE_H) */
70 
void dircollator_free_(dircollator_t *obj)
Definition: dircollate.c:166
int dircollator_n_routers(dircollator_t *dc)
Definition: dircollate.c:305
void dircollator_collate(dircollator_t *dc, int consensus_method)
Definition: dircollate.c:211
void dircollator_add_vote(dircollator_t *dc, networkstatus_t *v)
Definition: dircollate.c:194
dircollator_t * dircollator_new(int n_votes, int n_authorities)
Definition: dircollate.c:149
vote_routerstatus_t ** dircollator_get_votes_for_router(dircollator_t *dc, int idx)
Definition: dircollate.c:320
typedef HT_HEAD(hs_service_ht, hs_service_t) hs_service_ht
Master header file for Tor-specific functionality.
Definition: dircollate.c:35
Macros to implement mocking and selective exposure for the test code.