Extract networkstatus_t and ..sr_info_t into their own headers

This commit is contained in:
Nick Mathewson 2018-06-15 13:45:15 -04:00
parent 89aefb0319
commit 50369f8981
43 changed files with 168 additions and 93 deletions

View File

@ -23,6 +23,7 @@
#include "routerparse.h"
#include "workqueue.h"
#include "networkstatus_st.h"
#include "networkstatus_voter_info_st.h"
/**

View File

@ -84,6 +84,7 @@
#include "control_connection_st.h"
#include "cpath_build_state_st.h"
#include "entry_connection_st.h"
#include "networkstatus_st.h"
#include "node_st.h"
#include "or_connection_st.h"
#include "or_circuit_st.h"

View File

@ -25,6 +25,7 @@
#include "dircollate.h"
#include "dirvote.h"
#include "networkstatus_st.h"
#include "vote_routerstatus_st.h"
static void dircollator_collate_by_ed25519(dircollator_t *dc);

View File

@ -30,6 +30,7 @@
#include "dir_server_st.h"
#include "document_signature_st.h"
#include "networkstatus_st.h"
#include "networkstatus_voter_info_st.h"
#include "node_st.h"
#include "vote_microdesc_hash_st.h"

View File

@ -105,6 +105,8 @@
#include "dirauth/dirvote.h"
#include "dirauth/mode.h"
#include "networkstatus_st.h"
/* String prefix of shared random values in votes/consensuses. */
static const char previous_srv_str[] = "shared-rand-previous-value";
static const char current_srv_str[] = "shared-rand-current-value";

View File

@ -57,6 +57,7 @@
#include "dir_connection_st.h"
#include "dir_server_st.h"
#include "entry_connection_st.h"
#include "networkstatus_st.h"
#include "node_st.h"
#include "rend_service_descriptor_st.h"

View File

@ -21,6 +21,8 @@
#include "hs_cache.h"
#include "networkstatus_st.h"
static int cached_client_descriptor_has_expired(time_t now,
const hs_cache_client_descriptor_t *cached_desc);

View File

@ -34,6 +34,7 @@
#include "dirauth/shared_random_state.h"
#include "edge_connection_st.h"
#include "networkstatus_st.h"
#include "node_st.h"
#include "origin_circuit_st.h"

View File

@ -41,6 +41,7 @@
#include "dir_connection_st.h"
#include "edge_connection_st.h"
#include "networkstatus_st.h"
#include "node_st.h"
#include "origin_circuit_st.h"

View File

@ -248,6 +248,8 @@ ORHEADERS = \
src/or/main.h \
src/or/microdesc.h \
src/or/networkstatus.h \
src/or/networkstatus_st.h \
src/or/networkstatus_sr_info_st.h \
src/or/networkstatus_voter_info_st.h \
src/or/nodelist.h \
src/or/node_st.h \

View File

@ -123,6 +123,7 @@
#include "dirauth/shared_random.h"
#include "entry_connection_st.h"
#include "networkstatus_st.h"
#include "or_connection_st.h"
#include "port_cfg_st.h"
#include "socks_request_st.h"

View File

@ -22,6 +22,7 @@
#include "routerlist.h"
#include "routerparse.h"
#include "networkstatus_st.h"
#include "node_st.h"
/** A data structure to hold a bunch of cached microdescriptors. There are

View File

@ -77,6 +77,7 @@
#include "dir_connection_st.h"
#include "dir_server_st.h"
#include "document_signature_st.h"
#include "networkstatus_st.h"
#include "networkstatus_voter_info_st.h"
#include "node_st.h"
#include "vote_microdesc_hash_st.h"

View File

@ -0,0 +1,23 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
* Copyright (c) 2007-2017, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#ifndef NETWORKSTATUS_SR_INFO_ST_H
#define NETWORKSTATUS_SR_INFO_ST_H
struct networkstatus_sr_info_t {
/* Indicate if the dirauth partitipates in the SR protocol with its vote.
* This is tied to the SR flag in the vote. */
unsigned int participate:1;
/* Both vote and consensus: Current and previous SRV. If list is empty,
* this means none were found in either the consensus or vote. */
struct sr_srv_t *previous_srv;
struct sr_srv_t *current_srv;
/* Vote only: List of commitments. */
smartlist_t *commits;
};
#endif

95
src/or/networkstatus_st.h Normal file
View File

@ -0,0 +1,95 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
* Copyright (c) 2007-2017, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#ifndef NETWORKSTATUS_ST_H
#define NETWORKSTATUS_ST_H
#include "networkstatus_sr_info_st.h"
/** A common structure to hold a v3 network status vote, or a v3 network
* status consensus. */
struct networkstatus_t {
networkstatus_type_t type; /**< Vote, consensus, or opinion? */
consensus_flavor_t flavor; /**< If a consensus, what kind? */
unsigned int has_measured_bws : 1;/**< True iff this networkstatus contains
* measured= bandwidth values. */
time_t published; /**< Vote only: Time when vote was written. */
time_t valid_after; /**< Time after which this vote or consensus applies. */
time_t fresh_until; /**< Time before which this is the most recent vote or
* consensus. */
time_t valid_until; /**< Time after which this vote or consensus should not
* be used. */
/** Consensus only: what method was used to produce this consensus? */
int consensus_method;
/** Vote only: what methods is this voter willing to use? */
smartlist_t *supported_methods;
/** List of 'package' lines describing hashes of downloadable packages */
smartlist_t *package_lines;
/** How long does this vote/consensus claim that authorities take to
* distribute their votes to one another? */
int vote_seconds;
/** How long does this vote/consensus claim that authorities take to
* distribute their consensus signatures to one another? */
int dist_seconds;
/** Comma-separated list of recommended client software, or NULL if this
* voter has no opinion. */
char *client_versions;
char *server_versions;
/** Lists of subprotocol versions which are _recommended_ for relays and
* clients, or which are _require_ for relays and clients. Tor shouldn't
* make any more network connections if a required protocol is missing.
*/
char *recommended_relay_protocols;
char *recommended_client_protocols;
char *required_relay_protocols;
char *required_client_protocols;
/** List of flags that this vote/consensus applies to routers. If a flag is
* not listed here, the voter has no opinion on what its value should be. */
smartlist_t *known_flags;
/** List of key=value strings for the parameters in this vote or
* consensus, sorted by key. */
smartlist_t *net_params;
/** List of key=value strings for the bw weight parameters in the
* consensus. */
smartlist_t *weight_params;
/** List of networkstatus_voter_info_t. For a vote, only one element
* is included. For a consensus, one element is included for every voter
* whose vote contributed to the consensus. */
smartlist_t *voters;
struct authority_cert_t *cert; /**< Vote only: the voter's certificate. */
/** Digests of this document, as signed. */
common_digests_t digests;
/** A SHA3-256 digest of the document, not including signatures: used for
* consensus diffs */
uint8_t digest_sha3_as_signed[DIGEST256_LEN];
/** List of router statuses, sorted by identity digest. For a vote,
* the elements are vote_routerstatus_t; for a consensus, the elements
* are routerstatus_t. */
smartlist_t *routerstatus_list;
/** If present, a map from descriptor digest to elements of
* routerstatus_list. */
digestmap_t *desc_digest_map;
/** Contains the shared random protocol data from a vote or consensus. */
networkstatus_sr_info_t sr_info;
};
#endif

View File

@ -69,6 +69,7 @@
#include "dirauth/mode.h"
#include "dir_server_st.h"
#include "networkstatus_st.h"
#include "node_st.h"
static void nodelist_drop_node(node_t *node, int remove_from_ht);

View File

@ -1862,18 +1862,7 @@ typedef struct vote_microdesc_hash_t vote_microdesc_hash_t;
typedef struct vote_routerstatus_t vote_routerstatus_t;
typedef struct document_signature_t document_signature_t;
typedef struct networkstatus_voter_info_t networkstatus_voter_info_t;
typedef struct networkstatus_sr_info_t {
/* Indicate if the dirauth partitipates in the SR protocol with its vote.
* This is tied to the SR flag in the vote. */
unsigned int participate:1;
/* Both vote and consensus: Current and previous SRV. If list is empty,
* this means none were found in either the consensus or vote. */
struct sr_srv_t *previous_srv;
struct sr_srv_t *current_srv;
/* Vote only: List of commitments. */
smartlist_t *commits;
} networkstatus_sr_info_t;
typedef struct networkstatus_sr_info_t networkstatus_sr_info_t;
/** Enumerates the possible seriousness values of a networkstatus document. */
typedef enum {
@ -1893,87 +1882,7 @@ typedef enum {
/** How many different consensus flavors are there? */
#define N_CONSENSUS_FLAVORS ((int)(FLAV_MICRODESC)+1)
/** A common structure to hold a v3 network status vote, or a v3 network
* status consensus. */
typedef struct networkstatus_t {
networkstatus_type_t type; /**< Vote, consensus, or opinion? */
consensus_flavor_t flavor; /**< If a consensus, what kind? */
unsigned int has_measured_bws : 1;/**< True iff this networkstatus contains
* measured= bandwidth values. */
time_t published; /**< Vote only: Time when vote was written. */
time_t valid_after; /**< Time after which this vote or consensus applies. */
time_t fresh_until; /**< Time before which this is the most recent vote or
* consensus. */
time_t valid_until; /**< Time after which this vote or consensus should not
* be used. */
/** Consensus only: what method was used to produce this consensus? */
int consensus_method;
/** Vote only: what methods is this voter willing to use? */
smartlist_t *supported_methods;
/** List of 'package' lines describing hashes of downloadable packages */
smartlist_t *package_lines;
/** How long does this vote/consensus claim that authorities take to
* distribute their votes to one another? */
int vote_seconds;
/** How long does this vote/consensus claim that authorities take to
* distribute their consensus signatures to one another? */
int dist_seconds;
/** Comma-separated list of recommended client software, or NULL if this
* voter has no opinion. */
char *client_versions;
char *server_versions;
/** Lists of subprotocol versions which are _recommended_ for relays and
* clients, or which are _require_ for relays and clients. Tor shouldn't
* make any more network connections if a required protocol is missing.
*/
char *recommended_relay_protocols;
char *recommended_client_protocols;
char *required_relay_protocols;
char *required_client_protocols;
/** List of flags that this vote/consensus applies to routers. If a flag is
* not listed here, the voter has no opinion on what its value should be. */
smartlist_t *known_flags;
/** List of key=value strings for the parameters in this vote or
* consensus, sorted by key. */
smartlist_t *net_params;
/** List of key=value strings for the bw weight parameters in the
* consensus. */
smartlist_t *weight_params;
/** List of networkstatus_voter_info_t. For a vote, only one element
* is included. For a consensus, one element is included for every voter
* whose vote contributed to the consensus. */
smartlist_t *voters;
struct authority_cert_t *cert; /**< Vote only: the voter's certificate. */
/** Digests of this document, as signed. */
common_digests_t digests;
/** A SHA3-256 digest of the document, not including signatures: used for
* consensus diffs */
uint8_t digest_sha3_as_signed[DIGEST256_LEN];
/** List of router statuses, sorted by identity digest. For a vote,
* the elements are vote_routerstatus_t; for a consensus, the elements
* are routerstatus_t. */
smartlist_t *routerstatus_list;
/** If present, a map from descriptor digest to elements of
* routerstatus_list. */
digestmap_t *desc_digest_map;
/** Contains the shared random protocol data from a vote or consensus. */
networkstatus_sr_info_t sr_info;
} networkstatus_t;
typedef struct networkstatus_t networkstatus_t;
/** A set of signatures for a networkstatus consensus. Unless otherwise
* noted, all fields are as for networkstatus_t. */

View File

@ -33,6 +33,7 @@
#include "cpath_build_state_st.h"
#include "crypt_path_st.h"
#include "networkstatus_st.h"
#include "origin_circuit_st.h"
#include "rend_encoded_v2_service_descriptor_st.h"
#include "rend_intro_point_st.h"

View File

@ -40,6 +40,7 @@
#include "crypt_path_st.h"
#include "crypt_path_reference_st.h"
#include "edge_connection_st.h"
#include "networkstatus_st.h"
#include "origin_circuit_st.h"
#include "rend_authorized_client_st.h"
#include "rend_encoded_v2_service_descriptor_st.h"

View File

@ -89,6 +89,7 @@
#include "connection_or.h"
#include "statefile.h"
#include "networkstatus_st.h"
#include "or_circuit_st.h"
static void bw_arrays_init(void);

View File

@ -128,6 +128,7 @@
#include "dir_connection_st.h"
#include "dir_server_st.h"
#include "document_signature_st.h"
#include "networkstatus_st.h"
#include "networkstatus_voter_info_st.h"
#include "node_st.h"
#include "vote_routerstatus_st.h"

View File

@ -82,6 +82,7 @@
#include "dirauth/dirvote.h"
#include "document_signature_st.h"
#include "networkstatus_st.h"
#include "networkstatus_voter_info_st.h"
#include "rend_authorized_client_st.h"
#include "rend_intro_point_st.h"

View File

@ -17,6 +17,8 @@
#include "util.h"
#include "util_format.h"
#include "networkstatus_st.h"
/* Convert a given srv object to a string for the control port. This doesn't
* fail and the srv object MUST be valid. */
static char *

View File

@ -15,6 +15,8 @@
#include "config.h"
#include "networkstatus.h"
#include "networkstatus_st.h"
/* =====
* Vote scheduling
* ===== */

View File

@ -8,6 +8,7 @@
#include "microdesc.h"
#include "networkstatus.h"
#include "networkstatus_st.h"
#include "vote_routerstatus_st.h"
#include "fuzzing.h"

View File

@ -10,6 +10,8 @@
#include "routerlist.h"
#include "torcert.h"
#include "networkstatus_st.h"
#include "test.h"
static networkstatus_t *dummy_ns = NULL;

View File

@ -20,6 +20,7 @@
#include "scheduler.h"
#include "networkstatus.h"
#include "networkstatus_st.h"
#include "origin_circuit_st.h"
/* Test suite stuff */

View File

@ -20,6 +20,7 @@
#include "networkstatus.h"
#include "log_test_helpers.h"
#include "networkstatus_st.h"
#include "or_connection_st.h"
int channelpadding_get_netflow_inactive_timeout_ms(channel_t *chan);

View File

@ -14,6 +14,8 @@
#include "routerparse.h"
#include "workqueue.h"
#include "networkstatus_st.h"
#include "test.h"
#include "log_test_helpers.h"

View File

@ -46,6 +46,7 @@
#include "voting_schedule.h"
#include "document_signature_st.h"
#include "networkstatus_st.h"
#include "networkstatus_voter_info_st.h"
#include "port_cfg_st.h"
#include "tor_version_st.h"

View File

@ -14,6 +14,7 @@
#include "test_dir_common.h"
#include "voting_schedule.h"
#include "networkstatus_st.h"
#include "networkstatus_voter_info_st.h"
#include "vote_microdesc_hash_st.h"
#include "vote_routerstatus_st.h"

View File

@ -36,6 +36,7 @@
#include "dir_connection_st.h"
#include "dir_server_st.h"
#include "networkstatus_st.h"
#include "rend_encoded_v2_service_descriptor_st.h"
#ifdef _WIN32

View File

@ -16,6 +16,7 @@
#include "nodelist.h"
#include "routerlist.h"
#include "networkstatus_st.h"
#include "or_connection_st.h"
#include "test.h"

View File

@ -33,6 +33,7 @@
#include "cpath_build_state_st.h"
#include "crypt_path_st.h"
#include "dir_connection_st.h"
#include "networkstatus_st.h"
#include "node_st.h"
#include "origin_circuit_st.h"

View File

@ -15,6 +15,7 @@
#include "routerparse.h"
#include "networkstatus.h"
#include "networkstatus_st.h"
#include "vote_microdesc_hash_st.h"
#include "vote_routerstatus_st.h"

View File

@ -19,6 +19,7 @@
#include "proto_http.h"
#include "dir_connection_st.h"
#include "networkstatus_st.h"
#include "hs_test_helpers.h"
#include "test_helpers.h"

View File

@ -41,6 +41,7 @@
#include "crypt_path_st.h"
#include "dir_connection_st.h"
#include "entry_connection_st.h"
#include "networkstatus_st.h"
#include "origin_circuit_st.h"
#include "socks_request_st.h"

View File

@ -33,6 +33,7 @@
#include "util.h"
#include "voting_schedule.h"
#include "networkstatus_st.h"
#include "node_st.h"
/** Test the validation of HS v3 addresses */

View File

@ -55,6 +55,7 @@
#include "cpath_build_state_st.h"
#include "crypt_path_st.h"
#include "networkstatus_st.h"
#include "node_st.h"
#include "origin_circuit_st.h"

View File

@ -13,6 +13,8 @@
#include "routerparse.h"
#include "torcert.h"
#include "networkstatus_st.h"
#include "test.h"
#ifdef _WIN32

View File

@ -12,6 +12,7 @@
#include "nodelist.h"
#include "torcert.h"
#include "networkstatus_st.h"
#include "node_st.h"
#include "test.h"

View File

@ -35,6 +35,7 @@
#include "statefile.h"
#include "dir_connection_st.h"
#include "networkstatus_st.h"
#include "node_st.h"
#include "test.h"

View File

@ -23,6 +23,7 @@
#include "voting_schedule.h"
#include "dir_server_st.h"
#include "networkstatus_st.h"
static authority_cert_t *mock_cert;