commit 72d2fd83d898c2a7151c7fdbbffbc4c25fe34894 Author: Nick Mathewson nickm@torproject.org Date: Fri Jun 15 13:23:02 2018 -0400
Split vote_{microdesc_hash,routerstatus}_t into their own headers --- src/or/dirauth/dircollate.c | 2 ++ src/or/dirauth/dirvote.c | 2 ++ src/or/dirserv.c | 1 + src/or/include.am | 2 ++ src/or/networkstatus.c | 2 ++ src/or/or.h | 41 ++--------------------------------------- src/or/routerlist.c | 1 + src/or/routerparse.c | 2 ++ src/or/vote_microdesc_hash_st.h | 22 ++++++++++++++++++++++ src/or/vote_routerstatus_st.h | 39 +++++++++++++++++++++++++++++++++++++++ src/test/fuzz/fuzz_vrs.c | 3 +++ src/test/test_dir.c | 2 ++ src/test/test_dir_common.c | 3 +++ src/test/test_guardfraction.c | 3 +++ 14 files changed, 86 insertions(+), 39 deletions(-)
diff --git a/src/or/dirauth/dircollate.c b/src/or/dirauth/dircollate.c index dec6f7515..388885fe0 100644 --- a/src/or/dirauth/dircollate.c +++ b/src/or/dirauth/dircollate.c @@ -25,6 +25,8 @@ #include "dircollate.h" #include "dirvote.h"
+#include "vote_routerstatus_st.h" + static void dircollator_collate_by_ed25519(dircollator_t *dc);
/** Hashtable entry mapping a pair of digests (actually an ed25519 key and an diff --git a/src/or/dirauth/dirvote.c b/src/or/dirauth/dirvote.c index 41acc21d6..c702ca697 100644 --- a/src/or/dirauth/dirvote.c +++ b/src/or/dirauth/dirvote.c @@ -30,6 +30,8 @@
#include "dir_server_st.h" #include "node_st.h" +#include "vote_microdesc_hash_st.h" +#include "vote_routerstatus_st.h" #include "vote_timing_st.h"
/** diff --git a/src/or/dirserv.c b/src/or/dirserv.c index 3af057c6c..c4edb94af 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -39,6 +39,7 @@ #include "dir_connection_st.h" #include "node_st.h" #include "tor_version_st.h" +#include "vote_routerstatus_st.h"
/** * \file dirserv.c diff --git a/src/or/include.am b/src/or/include.am index ee1ee562c..d9eeb15f3 100644 --- a/src/or/include.am +++ b/src/or/include.am @@ -301,6 +301,8 @@ ORHEADERS = \ src/or/torcert.h \ src/or/tor_api_internal.h \ src/or/tor_version_st.h \ + src/or/vote_microdesc_hash_st.h \ + src/or/vote_routerstatus_st.h \ src/or/vote_timing_st.h \ src/or/voting_schedule.h
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index 4ac2034cd..3f90fea4e 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -77,6 +77,8 @@ #include "dir_connection_st.h" #include "dir_server_st.h" #include "node_st.h" +#include "vote_microdesc_hash_st.h" +#include "vote_routerstatus_st.h"
/** Most recently received and validated v3 "ns"-flavored consensus network * status. */ diff --git a/src/or/or.h b/src/or/or.h index f2de729ec..23f565857 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -1858,45 +1858,8 @@ typedef struct microdesc_t { } microdesc_t;
typedef struct node_t node_t; - -/** Linked list of microdesc hash lines for a single router in a directory - * vote. - */ -typedef struct vote_microdesc_hash_t { - /** Next element in the list, or NULL. */ - struct vote_microdesc_hash_t *next; - /** The raw contents of the microdesc hash line, from the "m" through the - * newline. */ - char *microdesc_hash_line; -} vote_microdesc_hash_t; - -/** The claim about a single router, made in a vote. */ -typedef struct vote_routerstatus_t { - routerstatus_t status; /**< Underlying 'status' object for this router. - * Flags are redundant. */ - /** How many known-flags are allowed in a vote? This is the width of - * the flags field of vote_routerstatus_t */ -#define MAX_KNOWN_FLAGS_IN_VOTE 64 - uint64_t flags; /**< Bit-field for all recognized flags; index into - * networkstatus_t.known_flags. */ - char *version; /**< The version that the authority says this router is - * running. */ - char *protocols; /**< The protocols that this authority says this router - * provides. */ - unsigned int has_measured_bw:1; /**< The vote had a measured bw */ - /** True iff the vote included an entry for ed25519 ID, or included - * "id ed25519 none" to indicate that there was no ed25519 ID. */ - unsigned int has_ed25519_listing:1; - /** True if the Ed25519 listing here is the consensus-opinion for the - * Ed25519 listing; false if there was no consensus on Ed25519 key status, - * or if this VRS doesn't reflect it. */ - unsigned int ed25519_reflects_consensus:1; - uint32_t measured_bw_kb; /**< Measured bandwidth (capacity) of the router */ - /** The hash or hashes that the authority claims this microdesc has. */ - vote_microdesc_hash_t *microdesc; - /** Ed25519 identity for this router, or zero if it has none. */ - uint8_t ed25519_id[ED25519_PUBKEY_LEN]; -} vote_routerstatus_t; +typedef struct vote_microdesc_hash_t vote_microdesc_hash_t; +typedef struct vote_routerstatus_t vote_routerstatus_t;
/** A signature of some document by an authority. */ typedef struct document_signature_t { diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 313685784..4d02c42a4 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -128,6 +128,7 @@ #include "dir_connection_st.h" #include "dir_server_st.h" #include "node_st.h" +#include "vote_routerstatus_st.h"
// #define DEBUG_ROUTERLIST
diff --git a/src/or/routerparse.c b/src/or/routerparse.c index e75dc2ee9..b7d50a1da 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -85,6 +85,8 @@ #include "rend_intro_point_st.h" #include "rend_service_descriptor_st.h" #include "tor_version_st.h" +#include "vote_microdesc_hash_st.h" +#include "vote_routerstatus_st.h"
#undef log #include <math.h> diff --git a/src/or/vote_microdesc_hash_st.h b/src/or/vote_microdesc_hash_st.h new file mode 100644 index 000000000..a7cbf5acd --- /dev/null +++ b/src/or/vote_microdesc_hash_st.h @@ -0,0 +1,22 @@ +/* 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 VOTE_MICRODESC_HASH_ST_H +#define VOTE_MICRODESC_HASH_ST_H + +/** Linked list of microdesc hash lines for a single router in a directory + * vote. + */ +struct vote_microdesc_hash_t { + /** Next element in the list, or NULL. */ + struct vote_microdesc_hash_t *next; + /** The raw contents of the microdesc hash line, from the "m" through the + * newline. */ + char *microdesc_hash_line; +}; + +#endif + diff --git a/src/or/vote_routerstatus_st.h b/src/or/vote_routerstatus_st.h new file mode 100644 index 000000000..71c204fad --- /dev/null +++ b/src/or/vote_routerstatus_st.h @@ -0,0 +1,39 @@ +/* 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 VOTE_ROUTERSTATUS_ST_H +#define VOTE_ROUTERSTATUS_ST_H + +/** The claim about a single router, made in a vote. */ +struct vote_routerstatus_t { + routerstatus_t status; /**< Underlying 'status' object for this router. + * Flags are redundant. */ + /** How many known-flags are allowed in a vote? This is the width of + * the flags field of vote_routerstatus_t */ +#define MAX_KNOWN_FLAGS_IN_VOTE 64 + uint64_t flags; /**< Bit-field for all recognized flags; index into + * networkstatus_t.known_flags. */ + char *version; /**< The version that the authority says this router is + * running. */ + char *protocols; /**< The protocols that this authority says this router + * provides. */ + unsigned int has_measured_bw:1; /**< The vote had a measured bw */ + /** True iff the vote included an entry for ed25519 ID, or included + * "id ed25519 none" to indicate that there was no ed25519 ID. */ + unsigned int has_ed25519_listing:1; + /** True if the Ed25519 listing here is the consensus-opinion for the + * Ed25519 listing; false if there was no consensus on Ed25519 key status, + * or if this VRS doesn't reflect it. */ + unsigned int ed25519_reflects_consensus:1; + uint32_t measured_bw_kb; /**< Measured bandwidth (capacity) of the router */ + /** The hash or hashes that the authority claims this microdesc has. */ + vote_microdesc_hash_t *microdesc; + /** Ed25519 identity for this router, or zero if it has none. */ + uint8_t ed25519_id[ED25519_PUBKEY_LEN]; +}; + +#endif + diff --git a/src/test/fuzz/fuzz_vrs.c b/src/test/fuzz/fuzz_vrs.c index baf0610a0..7225fd545 100644 --- a/src/test/fuzz/fuzz_vrs.c +++ b/src/test/fuzz/fuzz_vrs.c @@ -7,6 +7,9 @@ #include "memarea.h" #include "microdesc.h" #include "networkstatus.h" + +#include "vote_routerstatus_st.h" + #include "fuzzing.h"
static void diff --git a/src/test/test_dir.c b/src/test/test_dir.c index 43fc5c5fb..963d97a32 100644 --- a/src/test/test_dir.c +++ b/src/test/test_dir.c @@ -47,6 +47,8 @@
#include "port_cfg_st.h" #include "tor_version_st.h" +#include "vote_microdesc_hash_st.h" +#include "vote_routerstatus_st.h"
#define NS_MODULE dir
diff --git a/src/test/test_dir_common.c b/src/test/test_dir_common.c index 230410f7f..4b36025b5 100644 --- a/src/test/test_dir_common.c +++ b/src/test/test_dir_common.c @@ -14,6 +14,9 @@ #include "test_dir_common.h" #include "voting_schedule.h"
+#include "vote_microdesc_hash_st.h" +#include "vote_routerstatus_st.h" + void dir_common_setup_vote(networkstatus_t **vote, time_t now); networkstatus_t * dir_common_add_rs_and_parse(networkstatus_t *vote, networkstatus_t **vote_out, diff --git a/src/test/test_guardfraction.c b/src/test/test_guardfraction.c index 51ca8f08e..24bf58f94 100644 --- a/src/test/test_guardfraction.c +++ b/src/test/test_guardfraction.c @@ -15,6 +15,9 @@ #include "routerparse.h" #include "networkstatus.h"
+#include "vote_microdesc_hash_st.h" +#include "vote_routerstatus_st.h" + #include "test.h" #include "test_helpers.h" #include "log_test_helpers.h"