2014-11-12 20:29:05 +01:00
|
|
|
/* Copyright (c) 2001 Matej Pfajfar.
|
|
|
|
* Copyright (c) 2001-2004, Roger Dingledine.
|
|
|
|
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
2017-03-15 21:13:17 +01:00
|
|
|
* Copyright (c) 2007-2017, The Tor Project, Inc. */
|
2014-11-12 20:29:05 +01:00
|
|
|
/* See LICENSE for licensing information */
|
|
|
|
|
|
|
|
/**
|
2016-02-22 16:39:42 +01:00
|
|
|
* \file dircollate.h
|
|
|
|
* \brief Header file for dircollate.c.
|
2014-11-12 20:29:05 +01:00
|
|
|
**/
|
|
|
|
|
|
|
|
#ifndef TOR_DIRCOLLATE_H
|
|
|
|
#define TOR_DIRCOLLATE_H
|
|
|
|
|
|
|
|
#include "testsupport.h"
|
|
|
|
#include "or.h"
|
|
|
|
|
|
|
|
typedef struct dircollator_s dircollator_t;
|
|
|
|
|
|
|
|
dircollator_t *dircollator_new(int n_votes, int n_authorities);
|
|
|
|
void dircollator_free(dircollator_t *obj);
|
|
|
|
void dircollator_add_vote(dircollator_t *dc, networkstatus_t *v);
|
|
|
|
|
2014-11-13 16:03:55 +01:00
|
|
|
void dircollator_collate(dircollator_t *dc, int consensus_method);
|
2014-11-12 20:29:05 +01:00
|
|
|
|
|
|
|
int dircollator_n_routers(dircollator_t *dc);
|
|
|
|
vote_routerstatus_t **dircollator_get_votes_for_router(dircollator_t *dc,
|
|
|
|
int idx);
|
|
|
|
|
|
|
|
#ifdef DIRCOLLATE_PRIVATE
|
2014-11-13 16:03:55 +01:00
|
|
|
struct ddmap_entry_s;
|
|
|
|
typedef HT_HEAD(double_digest_map, ddmap_entry_s) double_digest_map_t;
|
2016-02-22 16:39:42 +01:00
|
|
|
/** A dircollator keeps track of all the routerstatus entries in a
|
|
|
|
* set of networkstatus votes, and matches them by an appropriate rule. */
|
2014-11-12 20:29:05 +01:00
|
|
|
struct dircollator_s {
|
2016-02-22 16:39:42 +01:00
|
|
|
/** True iff we have run the collation algorithm. */
|
2014-11-12 20:29:05 +01:00
|
|
|
int is_collated;
|
2016-02-22 16:39:42 +01:00
|
|
|
/** The total number of votes that we received. */
|
2014-11-12 20:29:05 +01:00
|
|
|
int n_votes;
|
2016-02-22 16:39:42 +01:00
|
|
|
/** The total number of authorities we acknowledge. */
|
2014-11-12 20:29:05 +01:00
|
|
|
int n_authorities;
|
|
|
|
|
2016-02-22 16:39:42 +01:00
|
|
|
/** The index which the next vote to be added to this collator should
|
|
|
|
* receive. */
|
2014-11-12 20:29:05 +01:00
|
|
|
int next_vote_num;
|
2016-02-22 16:39:42 +01:00
|
|
|
/** Map from RSA-SHA1 identity digest to an array of <b>n_votes</b>
|
|
|
|
* vote_routerstatus_t* pointers, such that the i'th member of the
|
|
|
|
* array is the i'th vote's entry for that RSA-SHA1 ID.*/
|
2014-11-12 20:29:05 +01:00
|
|
|
digestmap_t *by_rsa_sha1;
|
2016-02-22 16:39:42 +01:00
|
|
|
/** Map from <ed, RSA-SHA1> pair to an array similar to that used in
|
|
|
|
* by_rsa_sha1 above. We include <NULL,RSA-SHA1> entries for votes that
|
|
|
|
* say that there is no Ed key. */
|
2014-11-13 16:03:55 +01:00
|
|
|
struct double_digest_map by_both_ids;
|
|
|
|
|
2016-02-22 16:39:42 +01:00
|
|
|
/** One of two outputs created by collation: a map from RSA-SHA1
|
|
|
|
* identity digest to an array of the vote_routerstatus_t objects. Entries
|
|
|
|
* only exist in this map for identities that we should include in the
|
|
|
|
* consensus. */
|
2014-11-13 16:03:55 +01:00
|
|
|
digestmap_t *by_collated_rsa_sha1;
|
2014-11-12 20:29:05 +01:00
|
|
|
|
2016-02-22 16:39:42 +01:00
|
|
|
/** One of two outputs created by collation: a sorted array of RSA-SHA1
|
|
|
|
* identity digests .*/
|
2014-11-12 20:29:05 +01:00
|
|
|
smartlist_t *all_rsa_sha1_lst;
|
|
|
|
};
|
2017-09-15 22:24:44 +02:00
|
|
|
#endif /* defined(DIRCOLLATE_PRIVATE) */
|
2014-11-12 20:29:05 +01:00
|
|
|
|
2017-09-15 22:24:44 +02:00
|
|
|
#endif /* !defined(TOR_DIRCOLLATE_H) */
|
2015-06-01 14:59:14 +02:00
|
|
|
|