From 2a574d11ac8747996dcb979b04e38b16c5a0a9de Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 14 Jun 2018 16:58:01 -0400 Subject: Move dir_server_t into its own header. --- src/or/routerlist.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/or/routerlist.c') diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 8788dc0190..015b1012a8 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -125,6 +125,8 @@ #include "dirauth/dirvote.h" #include "dirauth/mode.h" +#include "dir_server_st.h" + // #define DEBUG_ROUTERLIST /****************************************************************************/ -- cgit v1.2.3-54-g00ecf From 1416f54d1eb2651e6b82ccbe35585ce71378de8a Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 15 Jun 2018 10:31:21 -0400 Subject: Split dir_connection_t into its own header --- src/or/circuitlist.c | 2 ++ src/or/circuituse.c | 2 ++ src/or/connection.c | 8 ++++++ src/or/connection.h | 11 ++------ src/or/connection_edge.c | 1 + src/or/dir_connection_st.h | 64 ++++++++++++++++++++++++++++++++++++++++++ src/or/directory.c | 10 +++++++ src/or/directory.h | 1 + src/or/dirserv.c | 2 ++ src/or/hs_client.c | 1 + src/or/hs_service.c | 1 + src/or/include.am | 1 + src/or/networkstatus.c | 1 + src/or/or.h | 62 +--------------------------------------- src/or/relay.c | 2 ++ src/or/rendclient.c | 1 + src/or/router.c | 1 + src/or/routerlist.c | 1 + src/test/fuzz/fuzz_http.c | 2 ++ src/test/test_connection.c | 1 + src/test/test_dir_handle_get.c | 1 + src/test/test_entrynodes.c | 2 ++ src/test/test_hs_cache.c | 2 ++ src/test/test_hs_client.c | 1 + src/test/test_oos.c | 2 ++ src/test/test_routerlist.c | 3 ++ 26 files changed, 116 insertions(+), 70 deletions(-) create mode 100644 src/or/dir_connection_st.h (limited to 'src/or/routerlist.c') diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c index e0ee284283..1a3f3a2290 100644 --- a/src/or/circuitlist.c +++ b/src/or/circuitlist.c @@ -67,6 +67,7 @@ #include "control.h" #include "crypto_rand.h" #include "crypto_util.h" +#include "directory.h" #include "entrynodes.h" #include "main.h" #include "hs_circuit.h" @@ -91,6 +92,7 @@ #include "ht.h" +#include "dir_connection_st.h" #include "edge_connection_st.h" /********* START VARIABLES **********/ diff --git a/src/or/circuituse.c b/src/or/circuituse.c index 5494bf94ef..45eeff4332 100644 --- a/src/or/circuituse.c +++ b/src/or/circuituse.c @@ -40,6 +40,7 @@ #include "connection.h" #include "connection_edge.h" #include "control.h" +#include "directory.h" #include "entrynodes.h" #include "hs_common.h" #include "hs_client.h" @@ -56,6 +57,7 @@ #include "router.h" #include "routerlist.h" +#include "dir_connection_st.h" #include "entry_connection_st.h" static void circuit_expire_old_circuits_clientside(void); diff --git a/src/or/connection.c b/src/or/connection.c index 0042d3e0d0..8c7341992d 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -113,6 +113,7 @@ #include #endif +#include "dir_connection_st.h" #include "control_connection_st.h" #include "entry_connection_st.h" #include "port_cfg_st.h" @@ -4112,6 +4113,13 @@ connection_write_to_buf_impl_,(const char *string, size_t len, connection_write_to_buf_commit(conn, written); } +void +connection_buf_add_compress(const char *string, size_t len, + dir_connection_t *conn, int done) +{ + connection_write_to_buf_impl_(string, len, TO_CONN(conn), done ? -1 : 1); +} + /** * Add all bytes from buf to conn's outbuf, draining them * from buf. (If the connection is marked and will soon be closed, diff --git a/src/or/connection.h b/src/or/connection.h index ad3129c9d8..59720ce3b8 100644 --- a/src/or/connection.h +++ b/src/or/connection.h @@ -150,20 +150,13 @@ MOCK_DECL(void, connection_write_to_buf_impl_, /* DOCDOC connection_write_to_buf */ static void connection_buf_add(const char *string, size_t len, connection_t *conn); -/* DOCDOC connection_write_to_buf_compress */ -static void connection_buf_add_compress(const char *string, size_t len, - dir_connection_t *conn, int done); static inline void connection_buf_add(const char *string, size_t len, connection_t *conn) { connection_write_to_buf_impl_(string, len, conn, 0); } -static inline void -connection_buf_add_compress(const char *string, size_t len, - dir_connection_t *conn, int done) -{ - connection_write_to_buf_impl_(string, len, TO_CONN(conn), done ? -1 : 1); -} +void connection_buf_add_compress(const char *string, size_t len, + dir_connection_t *conn, int done); void connection_buf_add_buf(connection_t *conn, buf_t *buf); /* DOCDOC connection_get_inbuf_len */ diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index 4bd50398bc..1ba61609bc 100644 --- a/src/or/connection_edge.c +++ b/src/or/connection_edge.c @@ -97,6 +97,7 @@ #include "routerset.h" #include "circuitbuild.h" +#include "dir_connection_st.h" #include "entry_connection_st.h" #ifdef HAVE_LINUX_TYPES_H diff --git a/src/or/dir_connection_st.h b/src/or/dir_connection_st.h new file mode 100644 index 0000000000..df1e9b5519 --- /dev/null +++ b/src/or/dir_connection_st.h @@ -0,0 +1,64 @@ +/* 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 DIR_CONNECTION_ST_H +#define DIR_CONNECTION_ST_H + +/** Subtype of connection_t for an "directory connection" -- that is, an HTTP + * connection to retrieve or serve directory material. */ +struct dir_connection_t { + connection_t base_; + + /** Which 'resource' did we ask the directory for? This is typically the part + * of the URL string that defines, relative to the directory conn purpose, + * what thing we want. For example, in router descriptor downloads by + * descriptor digest, it contains "d/", then one or more +-separated + * fingerprints. + **/ + char *requested_resource; + unsigned int dirconn_direct:1; /**< Is this dirconn direct, or via Tor? */ + + /** If we're fetching descriptors, what router purpose shall we assign + * to them? */ + uint8_t router_purpose; + + /** List of spooled_resource_t for objects that we're spooling. We use + * it from back to front. */ + smartlist_t *spool; + /** The compression object doing on-the-fly compression for spooled data. */ + tor_compress_state_t *compress_state; + + /** What rendezvous service are we querying for? */ + rend_data_t *rend_data; + + /* Hidden service connection identifier for dir connections: Used by HS + client-side code to fetch HS descriptors, and by the service-side code to + upload descriptors. */ + struct hs_ident_dir_conn_t *hs_ident; + + /** If this is a one-hop connection, tracks the state of the directory guard + * for this connection (if any). */ + struct circuit_guard_state_t *guard_state; + + char identity_digest[DIGEST_LEN]; /**< Hash of the public RSA key for + * the directory server's signing key. */ + + /** Unique ID for directory requests; this used to be in connection_t, but + * that's going away and being used on channels instead. The dirserver still + * needs this for the incoming side, so it's moved here. */ + uint64_t dirreq_id; + +#ifdef MEASUREMENTS_21206 + /** Number of RELAY_DATA cells received. */ + uint32_t data_cells_received; + + /** Number of RELAY_DATA cells sent. */ + uint32_t data_cells_sent; +#endif /* defined(MEASUREMENTS_21206) */ +}; + +#endif + diff --git a/src/or/directory.c b/src/or/directory.c index 7321a97fcc..65aaaa38a6 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -53,6 +53,7 @@ #include "dirauth/mode.h" #include "dirauth/shared_random.h" +#include "dir_connection_st.h" #include "dir_server_st.h" #include "entry_connection_st.h" @@ -154,6 +155,15 @@ static void connection_dir_close_consensus_fetches( /********* END VARIABLES ************/ +/** Convert a connection_t* to a dir_connection_t*; assert if the cast is + * invalid. */ +dir_connection_t * +TO_DIR_CONN(connection_t *c) +{ + tor_assert(c->magic == DIR_CONNECTION_MAGIC); + return DOWNCAST(dir_connection_t, c); +} + /** Return false if the directory purpose dir_purpose * does not require an anonymous (three-hop) connection. * diff --git a/src/or/directory.h b/src/or/directory.h index 5f5ff7eca6..e94c02b6c5 100644 --- a/src/or/directory.h +++ b/src/or/directory.h @@ -14,6 +14,7 @@ #include "hs_ident.h" +dir_connection_t *TO_DIR_CONN(connection_t *c); int directories_have_accepted_server_descriptor(void); void directory_post_to_dirservers(uint8_t dir_purpose, uint8_t router_purpose, dirinfo_type_t type, const char *payload, diff --git a/src/or/dirserv.c b/src/or/dirserv.c index c01234e0b9..f2597aeaed 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -36,6 +36,8 @@ #include "dirauth/dirvote.h" +#include "dir_connection_st.h" + /** * \file dirserv.c * \brief Directory server core implementation. Manages directory diff --git a/src/or/hs_client.c b/src/or/hs_client.c index 8c04026a7a..ff84296d04 100644 --- a/src/or/hs_client.c +++ b/src/or/hs_client.c @@ -35,6 +35,7 @@ #include "router.h" #include "routerset.h" +#include "dir_connection_st.h" #include "entry_connection_st.h" /* Return a human-readable string for the client fetch status code. */ diff --git a/src/or/hs_service.c b/src/or/hs_service.c index 44ee7bb660..9f12484ebe 100644 --- a/src/or/hs_service.c +++ b/src/or/hs_service.c @@ -39,6 +39,7 @@ #include "hs_service.h" #include "hs_stats.h" +#include "dir_connection_st.h" #include "edge_connection_st.h" /* Trunnel */ diff --git a/src/or/include.am b/src/or/include.am index cff38d0b60..5249f683dd 100644 --- a/src/or/include.am +++ b/src/or/include.am @@ -207,6 +207,7 @@ ORHEADERS = \ src/or/cpuworker.h \ src/or/directory.h \ src/or/dirserv.h \ + src/or/dir_connection_st.h \ src/or/dir_server_st.h \ src/or/dns.h \ src/or/dns_structs.h \ diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index 3ed6e3d6c9..3694da49dd 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -74,6 +74,7 @@ #include "dirauth/mode.h" #include "dirauth/shared_random.h" +#include "dir_connection_st.h" #include "dir_server_st.h" /** Most recently received and validated v3 "ns"-flavored consensus network diff --git a/src/or/or.h b/src/or/or.h index 138c5a18d7..d9e074d4c3 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -1640,62 +1640,10 @@ typedef struct or_connection_t { } or_connection_t; typedef struct control_connection_t control_connection_t; +typedef struct dir_connection_t dir_connection_t; typedef struct edge_connection_t edge_connection_t; typedef struct entry_connection_t entry_connection_t; -/** Subtype of connection_t for an "directory connection" -- that is, an HTTP - * connection to retrieve or serve directory material. */ -typedef struct dir_connection_t { - connection_t base_; - - /** Which 'resource' did we ask the directory for? This is typically the part - * of the URL string that defines, relative to the directory conn purpose, - * what thing we want. For example, in router descriptor downloads by - * descriptor digest, it contains "d/", then one or more +-separated - * fingerprints. - **/ - char *requested_resource; - unsigned int dirconn_direct:1; /**< Is this dirconn direct, or via Tor? */ - - /** If we're fetching descriptors, what router purpose shall we assign - * to them? */ - uint8_t router_purpose; - - /** List of spooled_resource_t for objects that we're spooling. We use - * it from back to front. */ - smartlist_t *spool; - /** The compression object doing on-the-fly compression for spooled data. */ - tor_compress_state_t *compress_state; - - /** What rendezvous service are we querying for? */ - rend_data_t *rend_data; - - /* Hidden service connection identifier for dir connections: Used by HS - client-side code to fetch HS descriptors, and by the service-side code to - upload descriptors. */ - struct hs_ident_dir_conn_t *hs_ident; - - /** If this is a one-hop connection, tracks the state of the directory guard - * for this connection (if any). */ - struct circuit_guard_state_t *guard_state; - - char identity_digest[DIGEST_LEN]; /**< Hash of the public RSA key for - * the directory server's signing key. */ - - /** Unique ID for directory requests; this used to be in connection_t, but - * that's going away and being used on channels instead. The dirserver still - * needs this for the incoming side, so it's moved here. */ - uint64_t dirreq_id; - -#ifdef MEASUREMENTS_21206 - /** Number of RELAY_DATA cells received. */ - uint32_t data_cells_received; - - /** Number of RELAY_DATA cells sent. */ - uint32_t data_cells_sent; -#endif /* defined(MEASUREMENTS_21206) */ -} dir_connection_t; - /** Cast a connection_t subtype pointer to a connection_t **/ #define TO_CONN(c) (&(((c)->base_))) @@ -1705,9 +1653,6 @@ typedef struct dir_connection_t { /** Convert a connection_t* to an or_connection_t*; assert if the cast is * invalid. */ static or_connection_t *TO_OR_CONN(connection_t *); -/** Convert a connection_t* to a dir_connection_t*; assert if the cast is - * invalid. */ -static dir_connection_t *TO_DIR_CONN(connection_t *); /** Convert a connection_t* to an listener_connection_t*; assert if the cast is * invalid. */ static listener_connection_t *TO_LISTENER_CONN(connection_t *); @@ -1717,11 +1662,6 @@ static inline or_connection_t *TO_OR_CONN(connection_t *c) tor_assert(c->magic == OR_CONNECTION_MAGIC); return DOWNCAST(or_connection_t, c); } -static inline dir_connection_t *TO_DIR_CONN(connection_t *c) -{ - tor_assert(c->magic == DIR_CONNECTION_MAGIC); - return DOWNCAST(dir_connection_t, c); -} static inline listener_connection_t *TO_LISTENER_CONN(connection_t *c) { tor_assert(c->magic == LISTENER_CONNECTION_MAGIC); diff --git a/src/or/relay.c b/src/or/relay.c index 757613e9db..dca31498f1 100644 --- a/src/or/relay.c +++ b/src/or/relay.c @@ -63,6 +63,7 @@ #include "control.h" #include "crypto_rand.h" #include "crypto_util.h" +#include "directory.h" #include "geoip.h" #include "hs_cache.h" #include "main.h" @@ -81,6 +82,7 @@ #include "scheduler.h" #include "rephist.h" +#include "dir_connection_st.h" #include "entry_connection_st.h" static edge_connection_t *relay_lookup_conn(circuit_t *circ, cell_t *cell, diff --git a/src/or/rendclient.c b/src/or/rendclient.c index c153862e65..c46b8c5656 100644 --- a/src/or/rendclient.c +++ b/src/or/rendclient.c @@ -33,6 +33,7 @@ #include "routerlist.h" #include "routerset.h" +#include "dir_connection_st.h" #include "entry_connection_st.h" static extend_info_t *rend_client_get_random_intro_impl( diff --git a/src/or/router.c b/src/or/router.c index c361e21a5f..f1fff6be21 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -39,6 +39,7 @@ #include "dirauth/mode.h" +#include "dir_connection_st.h" #include "dir_server_st.h" #include "port_cfg_st.h" diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 015b1012a8..970eac8d3f 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -125,6 +125,7 @@ #include "dirauth/dirvote.h" #include "dirauth/mode.h" +#include "dir_connection_st.h" #include "dir_server_st.h" // #define DEBUG_ROUTERLIST diff --git a/src/test/fuzz/fuzz_http.c b/src/test/fuzz/fuzz_http.c index 2ffeb60244..e93204ea3e 100644 --- a/src/test/fuzz/fuzz_http.c +++ b/src/test/fuzz/fuzz_http.c @@ -14,6 +14,8 @@ #include "directory.h" #include "torlog.h" +#include "dir_connection_st.h" + #include "fuzzing.h" static void diff --git a/src/test/test_connection.c b/src/test/test_connection.c index 05c4bb7f1f..79c5e2dd8f 100644 --- a/src/test/test_connection.c +++ b/src/test/test_connection.c @@ -24,6 +24,7 @@ #include "test_connection.h" #include "test_helpers.h" +#include "dir_connection_st.h" #include "entry_connection_st.h" static void * test_conn_get_basic_setup(const struct testcase_t *tc); diff --git a/src/test/test_dir_handle_get.c b/src/test/test_dir_handle_get.c index 4338bba657..188735a542 100644 --- a/src/test/test_dir_handle_get.c +++ b/src/test/test_dir_handle_get.c @@ -34,6 +34,7 @@ #include "log_test_helpers.h" #include "voting_schedule.h" +#include "dir_connection_st.h" #include "dir_server_st.h" #ifdef _WIN32 diff --git a/src/test/test_entrynodes.c b/src/test/test_entrynodes.c index cfcb88a66e..d4939355d1 100644 --- a/src/test/test_entrynodes.c +++ b/src/test/test_entrynodes.c @@ -30,6 +30,8 @@ #include "statefile.h" #include "util.h" +#include "dir_connection_st.h" + #include "test_helpers.h" #include "log_test_helpers.h" diff --git a/src/test/test_hs_cache.c b/src/test/test_hs_cache.c index 458ce1a92e..b2f892c7f2 100644 --- a/src/test/test_hs_cache.c +++ b/src/test/test_hs_cache.c @@ -18,6 +18,8 @@ #include "connection.h" #include "proto_http.h" +#include "dir_connection_st.h" + #include "hs_test_helpers.h" #include "test_helpers.h" #include "test.h" diff --git a/src/test/test_hs_client.c b/src/test/test_hs_client.c index 0828364e83..0420f70f84 100644 --- a/src/test/test_hs_client.c +++ b/src/test/test_hs_client.c @@ -37,6 +37,7 @@ #include "connection_edge.h" #include "networkstatus.h" +#include "dir_connection_st.h" #include "entry_connection_st.h" static int diff --git a/src/test/test_oos.c b/src/test/test_oos.c index e72fcf5de9..ddad5a08d0 100644 --- a/src/test/test_oos.c +++ b/src/test/test_oos.c @@ -12,6 +12,8 @@ #include "main.h" #include "test.h" +#include "dir_connection_st.h" + static or_options_t mock_options; static void diff --git a/src/test/test_routerlist.c b/src/test/test_routerlist.c index 701227c1c7..d66f8933de 100644 --- a/src/test/test_routerlist.c +++ b/src/test/test_routerlist.c @@ -33,6 +33,9 @@ #include "routerparse.h" #include "dirauth/shared_random.h" #include "statefile.h" + +#include "dir_connection_st.h" + #include "test.h" #include "test_dir_common.h" #include "log_test_helpers.h" -- cgit v1.2.3-54-g00ecf From d2942d127da454a1ffb69da176582b5d74918bb1 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 15 Jun 2018 13:13:33 -0400 Subject: Extract node_t into its own header. --- src/or/bridges.c | 2 + src/or/circuitbuild.c | 1 + src/or/connection_edge.c | 1 + src/or/control.c | 1 + src/or/dirauth/dirvote.c | 1 + src/or/directory.c | 1 + src/or/dirserv.c | 1 + src/or/entrynodes.c | 1 + src/or/hs_circuit.c | 1 + src/or/hs_common.c | 1 + src/or/hs_control.c | 2 + src/or/hs_service.c | 1 + src/or/include.am | 1 + src/or/microdesc.c | 2 + src/or/networkstatus.c | 1 + src/or/node_st.h | 100 +++++++++++++++++++++++++++++++++++++++++++++ src/or/nodelist.c | 9 ++++ src/or/nodelist.h | 1 + src/or/or.h | 97 +------------------------------------------ src/or/policies.c | 1 + src/or/router.c | 1 + src/or/routerlist.c | 1 + src/or/routerset.c | 2 + src/test/test_connection.c | 1 + src/test/test_entrynodes.c | 1 + src/test/test_helpers.c | 1 + src/test/test_hs.c | 1 + src/test/test_hs_common.c | 2 + src/test/test_hs_control.c | 11 ++--- src/test/test_hs_service.c | 1 + src/test/test_nodelist.c | 3 ++ src/test/test_policy.c | 1 + src/test/test_routerlist.c | 1 + src/test/test_routerset.c | 3 ++ 34 files changed, 152 insertions(+), 104 deletions(-) create mode 100644 src/or/node_st.h (limited to 'src/or/routerlist.c') diff --git a/src/or/bridges.c b/src/or/bridges.c index 699e030e6c..d5a9d05b49 100644 --- a/src/or/bridges.c +++ b/src/or/bridges.c @@ -27,6 +27,8 @@ #include "routerset.h" #include "transports.h" +#include "node_st.h" + /** Information about a configured bridge. Currently this just matches the * ones in the torrc file, but one day we may be able to learn about new * bridges on our own, and remember them in the state file. */ diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index 0df616a5ac..42ce1cfdaa 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -67,6 +67,7 @@ #include "cpath_build_state_st.h" #include "entry_connection_st.h" +#include "node_st.h" #include "or_circuit_st.h" #include "origin_circuit_st.h" diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index ce018e8742..e177b0ee2d 100644 --- a/src/or/connection_edge.c +++ b/src/or/connection_edge.c @@ -100,6 +100,7 @@ #include "cpath_build_state_st.h" #include "dir_connection_st.h" #include "entry_connection_st.h" +#include "node_st.h" #include "or_circuit_st.h" #include "origin_circuit_st.h" #include "socks_request_st.h" diff --git a/src/or/control.c b/src/or/control.c index 20da122596..ee79dfcd52 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -84,6 +84,7 @@ #include "control_connection_st.h" #include "cpath_build_state_st.h" #include "entry_connection_st.h" +#include "node_st.h" #include "or_connection_st.h" #include "or_circuit_st.h" #include "origin_circuit_st.h" diff --git a/src/or/dirauth/dirvote.c b/src/or/dirauth/dirvote.c index ae2de57a84..41acc21d67 100644 --- a/src/or/dirauth/dirvote.c +++ b/src/or/dirauth/dirvote.c @@ -29,6 +29,7 @@ #include "dirauth/shared_random_state.h" #include "dir_server_st.h" +#include "node_st.h" #include "vote_timing_st.h" /** diff --git a/src/or/directory.c b/src/or/directory.c index 00605c054a..8392dd81f2 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -57,6 +57,7 @@ #include "dir_connection_st.h" #include "dir_server_st.h" #include "entry_connection_st.h" +#include "node_st.h" #include "rend_service_descriptor_st.h" /** diff --git a/src/or/dirserv.c b/src/or/dirserv.c index 038b47e01a..3af057c6ce 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -37,6 +37,7 @@ #include "dirauth/dirvote.h" #include "dir_connection_st.h" +#include "node_st.h" #include "tor_version_st.h" /** diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c index 8aac07451c..62a65f2494 100644 --- a/src/or/entrynodes.c +++ b/src/or/entrynodes.c @@ -139,6 +139,7 @@ #include "transports.h" #include "statefile.h" +#include "node_st.h" #include "origin_circuit_st.h" /** A list of existing guard selection contexts. */ diff --git a/src/or/hs_circuit.c b/src/or/hs_circuit.c index b5ac7184a0..761edd6210 100644 --- a/src/or/hs_circuit.c +++ b/src/or/hs_circuit.c @@ -35,6 +35,7 @@ #include "cpath_build_state_st.h" #include "crypt_path_st.h" +#include "node_st.h" #include "origin_circuit_st.h" /* A circuit is about to become an e2e rendezvous circuit. Check diff --git a/src/or/hs_common.c b/src/or/hs_common.c index afe80467aa..c5f59059e4 100644 --- a/src/or/hs_common.c +++ b/src/or/hs_common.c @@ -34,6 +34,7 @@ #include "dirauth/shared_random_state.h" #include "edge_connection_st.h" +#include "node_st.h" #include "origin_circuit_st.h" /* Trunnel */ diff --git a/src/or/hs_control.c b/src/or/hs_control.c index 6b9b95c6d8..4f3dd62c61 100644 --- a/src/or/hs_control.c +++ b/src/or/hs_control.c @@ -15,6 +15,8 @@ #include "hs_service.h" #include "nodelist.h" +#include "node_st.h" + /* Send on the control port the "HS_DESC REQUESTED [...]" event. * * The onion_pk is the onion service public key, base64_blinded_pk is the diff --git a/src/or/hs_service.c b/src/or/hs_service.c index 6c2c167347..90e607225b 100644 --- a/src/or/hs_service.c +++ b/src/or/hs_service.c @@ -41,6 +41,7 @@ #include "dir_connection_st.h" #include "edge_connection_st.h" +#include "node_st.h" #include "origin_circuit_st.h" /* Trunnel */ diff --git a/src/or/include.am b/src/or/include.am index 4e0e1e9a4e..ee1ee562c6 100644 --- a/src/or/include.am +++ b/src/or/include.am @@ -248,6 +248,7 @@ ORHEADERS = \ src/or/microdesc.h \ src/or/networkstatus.h \ src/or/nodelist.h \ + src/or/node_st.h \ src/or/ntmain.h \ src/or/onion.h \ src/or/onion_fast.h \ diff --git a/src/or/microdesc.c b/src/or/microdesc.c index b4a934e095..f06c4bd2ae 100644 --- a/src/or/microdesc.c +++ b/src/or/microdesc.c @@ -22,6 +22,8 @@ #include "routerlist.h" #include "routerparse.h" +#include "node_st.h" + /** A data structure to hold a bunch of cached microdescriptors. There are * two active files in the cache: a "cache file" that we mmap, and a "journal * file" that we append to. Periodically, we rebuild the cache file to hold diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index 3694da49dd..4ac2034cdf 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -76,6 +76,7 @@ #include "dir_connection_st.h" #include "dir_server_st.h" +#include "node_st.h" /** Most recently received and validated v3 "ns"-flavored consensus network * status. */ diff --git a/src/or/node_st.h b/src/or/node_st.h new file mode 100644 index 0000000000..511e23ad17 --- /dev/null +++ b/src/or/node_st.h @@ -0,0 +1,100 @@ +/* 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 NODE_ST_H +#define NODE_ST_H + +/** A node_t represents a Tor router. + * + * Specifically, a node_t is a Tor router as we are using it: a router that + * we are considering for circuits, connections, and so on. A node_t is a + * thin wrapper around the routerstatus, routerinfo, and microdesc for a + * single router, and provides a consistent interface for all of them. + * + * Also, a node_t has mutable state. While a routerinfo, a routerstatus, + * and a microdesc have[*] only the information read from a router + * descriptor, a consensus entry, and a microdescriptor (respectively)... + * a node_t has flags based on *our own current opinion* of the node. + * + * [*] Actually, there is some leftover information in each that is mutable. + * We should try to excise that. + */ +struct node_t { + /* Indexing information */ + + /** Used to look up the node_t by its identity digest. */ + HT_ENTRY(node_t) ht_ent; + /** Used to look up the node_t by its ed25519 identity digest. */ + HT_ENTRY(node_t) ed_ht_ent; + /** Position of the node within the list of nodes */ + int nodelist_idx; + + /** The identity digest of this node_t. No more than one node_t per + * identity may exist at a time. */ + char identity[DIGEST_LEN]; + + /** The ed25519 identity of this node_t. This field is nonzero iff we + * currently have an ed25519 identity for this node in either md or ri, + * _and_ this node has been inserted to the ed25519-to-node map in the + * nodelist. + */ + ed25519_public_key_t ed25519_id; + + microdesc_t *md; + routerinfo_t *ri; + routerstatus_t *rs; + + /* local info: copied from routerstatus, then possibly frobbed based + * on experience. Authorities set this stuff directly. Note that + * these reflect knowledge of the primary (IPv4) OR port only. */ + + unsigned int is_running:1; /**< As far as we know, is this OR currently + * running? */ + unsigned int is_valid:1; /**< Has a trusted dirserver validated this OR? + * (For Authdir: Have we validated this OR?) */ + unsigned int is_fast:1; /** Do we think this is a fast OR? */ + unsigned int is_stable:1; /** Do we think this is a stable OR? */ + unsigned int is_possible_guard:1; /**< Do we think this is an OK guard? */ + unsigned int is_exit:1; /**< Do we think this is an OK exit? */ + unsigned int is_bad_exit:1; /**< Do we think this exit is censored, borked, + * or otherwise nasty? */ + unsigned int is_hs_dir:1; /**< True iff this router is a hidden service + * directory according to the authorities. */ + + /* Local info: warning state. */ + + unsigned int name_lookup_warned:1; /**< Have we warned the user for referring + * to this (unnamed) router by nickname? + */ + + /** Local info: we treat this node as if it rejects everything */ + unsigned int rejects_all:1; + + /* Local info: derived. */ + + /** True if the IPv6 OR port is preferred over the IPv4 OR port. + * XX/teor - can this become out of date if the torrc changes? */ + unsigned int ipv6_preferred:1; + + /** According to the geoip db what country is this router in? */ + /* XXXprop186 what is this suppose to mean with multiple OR ports? */ + country_t country; + + /* The below items are used only by authdirservers for + * reachability testing. */ + + /** When was the last time we could reach this OR? */ + time_t last_reachable; /* IPv4. */ + time_t last_reachable6; /* IPv6. */ + + /* Hidden service directory index data. This is used by a service or client + * in order to know what's the hs directory index for this node at the time + * the consensus is set. */ + struct hsdir_index_t hsdir_index; +}; + +#endif + diff --git a/src/or/nodelist.c b/src/or/nodelist.c index 4d67904c81..2c78c35ab5 100644 --- a/src/or/nodelist.c +++ b/src/or/nodelist.c @@ -69,6 +69,7 @@ #include "dirauth/mode.h" #include "dir_server_st.h" +#include "node_st.h" static void nodelist_drop_node(node_t *node, int remove_from_ht); #define node_free(val) \ @@ -634,6 +635,14 @@ nodelist_set_consensus(networkstatus_t *ns) } } +/** Return 1 iff node has Exit flag and no BadExit flag. + * Otherwise, return 0. + */ +int node_is_good_exit(const node_t *node) +{ + return node->is_exit && ! node->is_bad_exit; +} + /** Helper: return true iff a node has a usable amount of information*/ static inline int node_is_usable(const node_t *node) diff --git a/src/or/nodelist.h b/src/or/nodelist.h index 1ffba2e8df..fd91a26832 100644 --- a/src/or/nodelist.h +++ b/src/or/nodelist.h @@ -46,6 +46,7 @@ void node_get_verbose_nickname(const node_t *node, void node_get_verbose_nickname_by_id(const char *id_digest, char *verbose_name_out); int node_is_dir(const node_t *node); +int node_is_good_exit(const node_t *node); int node_has_any_descriptor(const node_t *node); int node_has_preferred_descriptor(const node_t *node, int for_direct_connect); diff --git a/src/or/or.h b/src/or/or.h index 19d0bb2ab6..f2de729ece 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -1857,94 +1857,7 @@ typedef struct microdesc_t { } microdesc_t; -/** A node_t represents a Tor router. - * - * Specifically, a node_t is a Tor router as we are using it: a router that - * we are considering for circuits, connections, and so on. A node_t is a - * thin wrapper around the routerstatus, routerinfo, and microdesc for a - * single router, and provides a consistent interface for all of them. - * - * Also, a node_t has mutable state. While a routerinfo, a routerstatus, - * and a microdesc have[*] only the information read from a router - * descriptor, a consensus entry, and a microdescriptor (respectively)... - * a node_t has flags based on *our own current opinion* of the node. - * - * [*] Actually, there is some leftover information in each that is mutable. - * We should try to excise that. - */ -typedef struct node_t { - /* Indexing information */ - - /** Used to look up the node_t by its identity digest. */ - HT_ENTRY(node_t) ht_ent; - /** Used to look up the node_t by its ed25519 identity digest. */ - HT_ENTRY(node_t) ed_ht_ent; - /** Position of the node within the list of nodes */ - int nodelist_idx; - - /** The identity digest of this node_t. No more than one node_t per - * identity may exist at a time. */ - char identity[DIGEST_LEN]; - - /** The ed25519 identity of this node_t. This field is nonzero iff we - * currently have an ed25519 identity for this node in either md or ri, - * _and_ this node has been inserted to the ed25519-to-node map in the - * nodelist. - */ - ed25519_public_key_t ed25519_id; - - microdesc_t *md; - routerinfo_t *ri; - routerstatus_t *rs; - - /* local info: copied from routerstatus, then possibly frobbed based - * on experience. Authorities set this stuff directly. Note that - * these reflect knowledge of the primary (IPv4) OR port only. */ - - unsigned int is_running:1; /**< As far as we know, is this OR currently - * running? */ - unsigned int is_valid:1; /**< Has a trusted dirserver validated this OR? - * (For Authdir: Have we validated this OR?) */ - unsigned int is_fast:1; /** Do we think this is a fast OR? */ - unsigned int is_stable:1; /** Do we think this is a stable OR? */ - unsigned int is_possible_guard:1; /**< Do we think this is an OK guard? */ - unsigned int is_exit:1; /**< Do we think this is an OK exit? */ - unsigned int is_bad_exit:1; /**< Do we think this exit is censored, borked, - * or otherwise nasty? */ - unsigned int is_hs_dir:1; /**< True iff this router is a hidden service - * directory according to the authorities. */ - - /* Local info: warning state. */ - - unsigned int name_lookup_warned:1; /**< Have we warned the user for referring - * to this (unnamed) router by nickname? - */ - - /** Local info: we treat this node as if it rejects everything */ - unsigned int rejects_all:1; - - /* Local info: derived. */ - - /** True if the IPv6 OR port is preferred over the IPv4 OR port. - * XX/teor - can this become out of date if the torrc changes? */ - unsigned int ipv6_preferred:1; - - /** According to the geoip db what country is this router in? */ - /* XXXprop186 what is this suppose to mean with multiple OR ports? */ - country_t country; - - /* The below items are used only by authdirservers for - * reachability testing. */ - - /** When was the last time we could reach this OR? */ - time_t last_reachable; /* IPv4. */ - time_t last_reachable6; /* IPv6. */ - - /* Hidden service directory index data. This is used by a service or client - * in order to know what's the hs directory index for this node at the time - * the consensus is set. */ - struct hsdir_index_t hsdir_index; -} node_t; +typedef struct node_t node_t; /** Linked list of microdesc hash lines for a single router in a directory * vote. @@ -2385,14 +2298,6 @@ typedef enum { /** Convert a circuit subtype to a circuit_t. */ #define TO_CIRCUIT(x) (&((x)->base_)) -/** Return 1 iff node has Exit flag and no BadExit flag. - * Otherwise, return 0. - */ -static inline int node_is_good_exit(const node_t *node) -{ - return node->is_exit && ! node->is_bad_exit; -} - /* limits for TCP send and recv buffer size used for constrained sockets */ #define MIN_CONSTRAINED_TCP_BUFFER 2048 #define MAX_CONSTRAINED_TCP_BUFFER 262144 /* 256k */ diff --git a/src/or/policies.c b/src/or/policies.c index 51dc83827e..78cbcd5cd2 100644 --- a/src/or/policies.c +++ b/src/or/policies.c @@ -31,6 +31,7 @@ #include "ht.h" #include "dir_server_st.h" +#include "node_st.h" #include "port_cfg_st.h" /** Policy that addresses for incoming SOCKS connections must match. */ diff --git a/src/or/router.c b/src/or/router.c index 2d03058893..6d8f61d716 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -42,6 +42,7 @@ #include "crypt_path_st.h" #include "dir_connection_st.h" #include "dir_server_st.h" +#include "node_st.h" #include "origin_circuit_st.h" #include "port_cfg_st.h" diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 970eac8d3f..313685784a 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -127,6 +127,7 @@ #include "dir_connection_st.h" #include "dir_server_st.h" +#include "node_st.h" // #define DEBUG_ROUTERLIST diff --git a/src/or/routerset.c b/src/or/routerset.c index a2599b316c..8a6ff3b582 100644 --- a/src/or/routerset.c +++ b/src/or/routerset.c @@ -36,6 +36,8 @@ #include "routerparse.h" #include "routerset.h" +#include "node_st.h" + /** Return a new empty routerset. */ routerset_t * routerset_new(void) diff --git a/src/test/test_connection.c b/src/test/test_connection.c index 93d5dc8469..6f9c2706c2 100644 --- a/src/test/test_connection.c +++ b/src/test/test_connection.c @@ -26,6 +26,7 @@ #include "dir_connection_st.h" #include "entry_connection_st.h" +#include "node_st.h" #include "or_connection_st.h" #include "socks_request_st.h" diff --git a/src/test/test_entrynodes.c b/src/test/test_entrynodes.c index bff6a40bd3..cf9da232ca 100644 --- a/src/test/test_entrynodes.c +++ b/src/test/test_entrynodes.c @@ -33,6 +33,7 @@ #include "cpath_build_state_st.h" #include "crypt_path_st.h" #include "dir_connection_st.h" +#include "node_st.h" #include "origin_circuit_st.h" #include "test_helpers.h" diff --git a/src/test/test_helpers.c b/src/test/test_helpers.c index 91cc7d4d2e..78d10b261f 100644 --- a/src/test/test_helpers.c +++ b/src/test/test_helpers.c @@ -25,6 +25,7 @@ #include "routerlist.h" #include "connection_st.h" +#include "node_st.h" #include "origin_circuit_st.h" #include "test.h" diff --git a/src/test/test_hs.c b/src/test/test_hs.c index 9343d131f2..c546af2fe9 100644 --- a/src/test/test_hs.c +++ b/src/test/test_hs.c @@ -22,6 +22,7 @@ #include "routerset.h" #include "circuitbuild.h" +#include "node_st.h" #include "rend_encoded_v2_service_descriptor_st.h" #include "rend_intro_point_st.h" diff --git a/src/test/test_hs_common.c b/src/test/test_hs_common.c index 8bcb2c7e46..21a109d2bc 100644 --- a/src/test/test_hs_common.c +++ b/src/test/test_hs_common.c @@ -33,6 +33,8 @@ #include "util.h" #include "voting_schedule.h" +#include "node_st.h" + /** Test the validation of HS v3 addresses */ static void test_validate_address(void *arg) diff --git a/src/test/test_hs_control.c b/src/test/test_hs_control.c index 308843e9b8..1fcea44f4b 100644 --- a/src/test/test_hs_control.c +++ b/src/test/test_hs_control.c @@ -7,10 +7,6 @@ **/ #define CONTROL_PRIVATE -#define CIRCUITBUILD_PRIVATE -#define RENDCOMMON_PRIVATE -#define RENDSERVICE_PRIVATE -#define HS_SERVICE_PRIVATE #include "or.h" #include "test.h" @@ -19,10 +15,9 @@ #include "hs_common.h" #include "hs_control.h" #include "nodelist.h" -//#include "rendcommon.h" -//#include "rendservice.h" -//#include "routerset.h" -//#include "circuitbuild.h" + +#include "node_st.h" + #include "test_helpers.h" /* mock ID digest and longname for node that's in nodelist */ diff --git a/src/test/test_hs_service.c b/src/test/test_hs_service.c index 3487785500..83a9d3cb59 100644 --- a/src/test/test_hs_service.c +++ b/src/test/test_hs_service.c @@ -55,6 +55,7 @@ #include "cpath_build_state_st.h" #include "crypt_path_st.h" +#include "node_st.h" #include "origin_circuit_st.h" /* Trunnel */ diff --git a/src/test/test_nodelist.c b/src/test/test_nodelist.c index 9499fd0380..a3f2de29f0 100644 --- a/src/test/test_nodelist.c +++ b/src/test/test_nodelist.c @@ -11,6 +11,9 @@ #include "networkstatus.h" #include "nodelist.h" #include "torcert.h" + +#include "node_st.h" + #include "test.h" /** Test the case when node_get_by_id() returns NULL, diff --git a/src/test/test_policy.c b/src/test/test_policy.c index e55452d3e4..673336eaeb 100644 --- a/src/test/test_policy.c +++ b/src/test/test_policy.c @@ -10,6 +10,7 @@ #include "policies.h" #include "test.h" +#include "node_st.h" #include "port_cfg_st.h" /* Helper: assert that short_policy parses and writes back out as itself, diff --git a/src/test/test_routerlist.c b/src/test/test_routerlist.c index d66f8933de..bf97499eee 100644 --- a/src/test/test_routerlist.c +++ b/src/test/test_routerlist.c @@ -35,6 +35,7 @@ #include "statefile.h" #include "dir_connection_st.h" +#include "node_st.h" #include "test.h" #include "test_dir_common.h" diff --git a/src/test/test_routerset.c b/src/test/test_routerset.c index c541324674..0e1ad3fdfa 100644 --- a/src/test/test_routerset.c +++ b/src/test/test_routerset.c @@ -9,6 +9,9 @@ #include "routerparse.h" #include "policies.h" #include "nodelist.h" + +#include "node_st.h" + #include "test.h" #define NS_MODULE routerset -- cgit v1.2.3-54-g00ecf From 72d2fd83d898c2a7151c7fdbbffbc4c25fe34894 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 15 Jun 2018 13:23:02 -0400 Subject: 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(-) create mode 100644 src/or/vote_microdesc_hash_st.h create mode 100644 src/or/vote_routerstatus_st.h (limited to 'src/or/routerlist.c') diff --git a/src/or/dirauth/dircollate.c b/src/or/dirauth/dircollate.c index dec6f75154..388885fe0b 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 41acc21d67..c702ca6974 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 3af057c6ce..c4edb94af3 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 ee1ee562c6..d9eeb15f3c 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 4ac2034cdf..3f90fea4e1 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 f2de729ece..23f565857b 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 313685784a..4d02c42a4a 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 e75dc2ee97..b7d50a1da1 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 diff --git a/src/or/vote_microdesc_hash_st.h b/src/or/vote_microdesc_hash_st.h new file mode 100644 index 0000000000..a7cbf5acdc --- /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 0000000000..71c204fad3 --- /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 baf0610a0b..7225fd5456 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 43fc5c5fb4..963d97a325 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 230410f7fa..4b36025b54 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 51ca8f08ec..24bf58f942 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" -- cgit v1.2.3-54-g00ecf From 80c9e1e58511de04eeffdc47d3801697b4952e6d Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 15 Jun 2018 13:27:11 -0400 Subject: Move document_signature_t into its own header. --- src/or/dirauth/dirvote.c | 1 + src/or/document_signature_st.h | 29 +++++++++++++++++++++++++++++ src/or/include.am | 1 + src/or/networkstatus.c | 1 + src/or/or.h | 19 +------------------ src/or/routerlist.c | 1 + src/or/routerparse.c | 1 + src/test/test_dir.c | 1 + 8 files changed, 36 insertions(+), 18 deletions(-) create mode 100644 src/or/document_signature_st.h (limited to 'src/or/routerlist.c') diff --git a/src/or/dirauth/dirvote.c b/src/or/dirauth/dirvote.c index c702ca6974..12ab5f3289 100644 --- a/src/or/dirauth/dirvote.c +++ b/src/or/dirauth/dirvote.c @@ -29,6 +29,7 @@ #include "dirauth/shared_random_state.h" #include "dir_server_st.h" +#include "document_signature_st.h" #include "node_st.h" #include "vote_microdesc_hash_st.h" #include "vote_routerstatus_st.h" diff --git a/src/or/document_signature_st.h b/src/or/document_signature_st.h new file mode 100644 index 0000000000..ec0b1ba1b0 --- /dev/null +++ b/src/or/document_signature_st.h @@ -0,0 +1,29 @@ +/* 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 DOCUMENT_SIGNATURE_ST_H +#define DOCUMENT_SIGNATURE_ST_H + +/** A signature of some document by an authority. */ +struct document_signature_t { + /** Declared SHA-1 digest of this voter's identity key */ + char identity_digest[DIGEST_LEN]; + /** Declared SHA-1 digest of signing key used by this voter. */ + char signing_key_digest[DIGEST_LEN]; + /** Algorithm used to compute the digest of the document. */ + digest_algorithm_t alg; + /** Signature of the signed thing. */ + char *signature; + /** Length of signature */ + int signature_len; + unsigned int bad_signature : 1; /**< Set to true if we've tried to verify + * the sig, and we know it's bad. */ + unsigned int good_signature : 1; /**< Set to true if we've verified the sig + * as good. */ +}; + +#endif + diff --git a/src/or/include.am b/src/or/include.am index d9eeb15f3c..611b1adbce 100644 --- a/src/or/include.am +++ b/src/or/include.am @@ -214,6 +214,7 @@ ORHEADERS = \ src/or/dirserv.h \ src/or/dir_connection_st.h \ src/or/dir_server_st.h \ + src/or/document_signature_st.h \ src/or/dns.h \ src/or/dns_structs.h \ src/or/dnsserv.h \ diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index 3f90fea4e1..1bea0d774d 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -76,6 +76,7 @@ #include "dir_connection_st.h" #include "dir_server_st.h" +#include "document_signature_st.h" #include "node_st.h" #include "vote_microdesc_hash_st.h" #include "vote_routerstatus_st.h" diff --git a/src/or/or.h b/src/or/or.h index 23f565857b..ab1ae5742b 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -1860,24 +1860,7 @@ typedef struct microdesc_t { typedef struct node_t node_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 { - /** Declared SHA-1 digest of this voter's identity key */ - char identity_digest[DIGEST_LEN]; - /** Declared SHA-1 digest of signing key used by this voter. */ - char signing_key_digest[DIGEST_LEN]; - /** Algorithm used to compute the digest of the document. */ - digest_algorithm_t alg; - /** Signature of the signed thing. */ - char *signature; - /** Length of signature */ - int signature_len; - unsigned int bad_signature : 1; /**< Set to true if we've tried to verify - * the sig, and we know it's bad. */ - unsigned int good_signature : 1; /**< Set to true if we've verified the sig - * as good. */ -} document_signature_t; +typedef struct document_signature_t document_signature_t; /** Information about a single voter in a vote or a consensus. */ typedef struct networkstatus_voter_info_t { diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 4d02c42a4a..68def1c85e 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -127,6 +127,7 @@ #include "dir_connection_st.h" #include "dir_server_st.h" +#include "document_signature_st.h" #include "node_st.h" #include "vote_routerstatus_st.h" diff --git a/src/or/routerparse.c b/src/or/routerparse.c index b7d50a1da1..2ae005569c 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -81,6 +81,7 @@ #include "dirauth/dirvote.h" +#include "document_signature_st.h" #include "rend_authorized_client_st.h" #include "rend_intro_point_st.h" #include "rend_service_descriptor_st.h" diff --git a/src/test/test_dir.c b/src/test/test_dir.c index 963d97a325..c3d00a81f9 100644 --- a/src/test/test_dir.c +++ b/src/test/test_dir.c @@ -45,6 +45,7 @@ #include "log_test_helpers.h" #include "voting_schedule.h" +#include "document_signature_st.h" #include "port_cfg_st.h" #include "tor_version_st.h" #include "vote_microdesc_hash_st.h" -- cgit v1.2.3-54-g00ecf From 89aefb0319778af419abed11707a7bf84648288c Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 15 Jun 2018 13:31:47 -0400 Subject: Extract networkstatus_vote_info_t into its own header. --- src/or/consdiffmgr.c | 2 ++ src/or/dirauth/dirvote.c | 1 + src/or/include.am | 1 + src/or/networkstatus.c | 1 + src/or/networkstatus_voter_info_st.h | 31 +++++++++++++++++++++++++++++++ src/or/or.h | 21 +-------------------- src/or/routerlist.c | 1 + src/or/routerparse.c | 1 + src/test/test_dir.c | 1 + src/test/test_dir_common.c | 1 + 10 files changed, 41 insertions(+), 20 deletions(-) create mode 100644 src/or/networkstatus_voter_info_st.h (limited to 'src/or/routerlist.c') diff --git a/src/or/consdiffmgr.c b/src/or/consdiffmgr.c index 323f4f9ca0..b90660e6c7 100644 --- a/src/or/consdiffmgr.c +++ b/src/or/consdiffmgr.c @@ -23,6 +23,8 @@ #include "routerparse.h" #include "workqueue.h" +#include "networkstatus_voter_info_st.h" + /** * Labels to apply to items in the conscache object. * diff --git a/src/or/dirauth/dirvote.c b/src/or/dirauth/dirvote.c index 12ab5f3289..5dee8a8797 100644 --- a/src/or/dirauth/dirvote.c +++ b/src/or/dirauth/dirvote.c @@ -30,6 +30,7 @@ #include "dir_server_st.h" #include "document_signature_st.h" +#include "networkstatus_voter_info_st.h" #include "node_st.h" #include "vote_microdesc_hash_st.h" #include "vote_routerstatus_st.h" diff --git a/src/or/include.am b/src/or/include.am index 611b1adbce..6ced3e1558 100644 --- a/src/or/include.am +++ b/src/or/include.am @@ -248,6 +248,7 @@ ORHEADERS = \ src/or/main.h \ src/or/microdesc.h \ src/or/networkstatus.h \ + src/or/networkstatus_voter_info_st.h \ src/or/nodelist.h \ src/or/node_st.h \ src/or/ntmain.h \ diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index 1bea0d774d..11021a7ead 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -77,6 +77,7 @@ #include "dir_connection_st.h" #include "dir_server_st.h" #include "document_signature_st.h" +#include "networkstatus_voter_info_st.h" #include "node_st.h" #include "vote_microdesc_hash_st.h" #include "vote_routerstatus_st.h" diff --git a/src/or/networkstatus_voter_info_st.h b/src/or/networkstatus_voter_info_st.h new file mode 100644 index 0000000000..32ea597bd8 --- /dev/null +++ b/src/or/networkstatus_voter_info_st.h @@ -0,0 +1,31 @@ +/* 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_VOTER_INFO_ST_H +#define NETWORKSTATUS_VOTER_INFO_ST_H + +/** Information about a single voter in a vote or a consensus. */ +typedef struct networkstatus_voter_info_t { + /** Declared SHA-1 digest of this voter's identity key */ + char identity_digest[DIGEST_LEN]; + char *nickname; /**< Nickname of this voter */ + /** Digest of this voter's "legacy" identity key, if any. In vote only; for + * consensuses, we treat legacy keys as additional signers. */ + char legacy_id_digest[DIGEST_LEN]; + char *address; /**< Address of this voter, in string format. */ + uint32_t addr; /**< Address of this voter, in IPv4, in host order. */ + uint16_t dir_port; /**< Directory port of this voter */ + uint16_t or_port; /**< OR port of this voter */ + char *contact; /**< Contact information for this voter. */ + char vote_digest[DIGEST_LEN]; /**< Digest of this voter's vote, as signed. */ + + /* Nothing from here on is signed. */ + /** The signature of the document and the signature's status. */ + smartlist_t *sigs; +} networkstatus_voter_info_t; + +#endif + diff --git a/src/or/or.h b/src/or/or.h index ab1ae5742b..1069e30d0a 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -1861,26 +1861,7 @@ typedef struct node_t node_t; 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; - -/** Information about a single voter in a vote or a consensus. */ -typedef struct networkstatus_voter_info_t { - /** Declared SHA-1 digest of this voter's identity key */ - char identity_digest[DIGEST_LEN]; - char *nickname; /**< Nickname of this voter */ - /** Digest of this voter's "legacy" identity key, if any. In vote only; for - * consensuses, we treat legacy keys as additional signers. */ - char legacy_id_digest[DIGEST_LEN]; - char *address; /**< Address of this voter, in string format. */ - uint32_t addr; /**< Address of this voter, in IPv4, in host order. */ - uint16_t dir_port; /**< Directory port of this voter */ - uint16_t or_port; /**< OR port of this voter */ - char *contact; /**< Contact information for this voter. */ - char vote_digest[DIGEST_LEN]; /**< Digest of this voter's vote, as signed. */ - - /* Nothing from here on is signed. */ - /** The signature of the document and the signature's status. */ - smartlist_t *sigs; -} networkstatus_voter_info_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. diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 68def1c85e..5a8d19f6f4 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 "document_signature_st.h" +#include "networkstatus_voter_info_st.h" #include "node_st.h" #include "vote_routerstatus_st.h" diff --git a/src/or/routerparse.c b/src/or/routerparse.c index 2ae005569c..73721bf236 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -82,6 +82,7 @@ #include "dirauth/dirvote.h" #include "document_signature_st.h" +#include "networkstatus_voter_info_st.h" #include "rend_authorized_client_st.h" #include "rend_intro_point_st.h" #include "rend_service_descriptor_st.h" diff --git a/src/test/test_dir.c b/src/test/test_dir.c index c3d00a81f9..f5a3b6f65c 100644 --- a/src/test/test_dir.c +++ b/src/test/test_dir.c @@ -46,6 +46,7 @@ #include "voting_schedule.h" #include "document_signature_st.h" +#include "networkstatus_voter_info_st.h" #include "port_cfg_st.h" #include "tor_version_st.h" #include "vote_microdesc_hash_st.h" diff --git a/src/test/test_dir_common.c b/src/test/test_dir_common.c index 4b36025b54..fca132c9f7 100644 --- a/src/test/test_dir_common.c +++ b/src/test/test_dir_common.c @@ -14,6 +14,7 @@ #include "test_dir_common.h" #include "voting_schedule.h" +#include "networkstatus_voter_info_st.h" #include "vote_microdesc_hash_st.h" #include "vote_routerstatus_st.h" -- cgit v1.2.3-54-g00ecf From 50369f8981e8ce0894753daeea3dc28ab01f2667 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 15 Jun 2018 13:45:15 -0400 Subject: Extract networkstatus_t and ..sr_info_t into their own headers --- src/or/consdiffmgr.c | 1 + src/or/control.c | 1 + src/or/dirauth/dircollate.c | 1 + src/or/dirauth/dirvote.c | 1 + src/or/dirauth/shared_random.c | 2 + src/or/directory.c | 1 + src/or/hs_cache.c | 2 + src/or/hs_common.c | 1 + src/or/hs_service.c | 1 + src/or/include.am | 2 + src/or/main.c | 1 + src/or/microdesc.c | 1 + src/or/networkstatus.c | 1 + src/or/networkstatus_sr_info_st.h | 23 ++++++++++ src/or/networkstatus_st.h | 95 +++++++++++++++++++++++++++++++++++++++ src/or/nodelist.c | 1 + src/or/or.h | 95 +-------------------------------------- src/or/rendcommon.c | 1 + src/or/rendservice.c | 1 + src/or/rephist.c | 1 + src/or/routerlist.c | 1 + src/or/routerparse.c | 1 + src/or/shared_random_client.c | 2 + src/or/voting_schedule.c | 2 + src/test/fuzz/fuzz_vrs.c | 1 + src/test/test_address_set.c | 2 + src/test/test_channel.c | 1 + src/test/test_channelpadding.c | 1 + src/test/test_consdiffmgr.c | 2 + src/test/test_dir.c | 1 + src/test/test_dir_common.c | 1 + src/test/test_dir_handle_get.c | 1 + src/test/test_dos.c | 1 + src/test/test_entrynodes.c | 1 + src/test/test_guardfraction.c | 1 + src/test/test_hs_cache.c | 1 + src/test/test_hs_client.c | 1 + src/test/test_hs_common.c | 1 + src/test/test_hs_service.c | 1 + src/test/test_microdesc.c | 2 + src/test/test_nodelist.c | 1 + src/test/test_routerlist.c | 1 + src/test/test_shared_random.c | 1 + 43 files changed, 168 insertions(+), 93 deletions(-) create mode 100644 src/or/networkstatus_sr_info_st.h create mode 100644 src/or/networkstatus_st.h (limited to 'src/or/routerlist.c') diff --git a/src/or/consdiffmgr.c b/src/or/consdiffmgr.c index b90660e6c7..f1b7601ca6 100644 --- a/src/or/consdiffmgr.c +++ b/src/or/consdiffmgr.c @@ -23,6 +23,7 @@ #include "routerparse.h" #include "workqueue.h" +#include "networkstatus_st.h" #include "networkstatus_voter_info_st.h" /** diff --git a/src/or/control.c b/src/or/control.c index ee79dfcd52..0afd6cf973 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -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" diff --git a/src/or/dirauth/dircollate.c b/src/or/dirauth/dircollate.c index 388885fe0b..81f0bf31eb 100644 --- a/src/or/dirauth/dircollate.c +++ b/src/or/dirauth/dircollate.c @@ -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); diff --git a/src/or/dirauth/dirvote.c b/src/or/dirauth/dirvote.c index 5dee8a8797..aa30a11f5c 100644 --- a/src/or/dirauth/dirvote.c +++ b/src/or/dirauth/dirvote.c @@ -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" diff --git a/src/or/dirauth/shared_random.c b/src/or/dirauth/shared_random.c index 6dd1f330e0..137f695dbe 100644 --- a/src/or/dirauth/shared_random.c +++ b/src/or/dirauth/shared_random.c @@ -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"; diff --git a/src/or/directory.c b/src/or/directory.c index 8392dd81f2..b5a07f6b3e 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -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" diff --git a/src/or/hs_cache.c b/src/or/hs_cache.c index ecc845d17f..092d944b86 100644 --- a/src/or/hs_cache.c +++ b/src/or/hs_cache.c @@ -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); diff --git a/src/or/hs_common.c b/src/or/hs_common.c index c5f59059e4..e5d15a1b1c 100644 --- a/src/or/hs_common.c +++ b/src/or/hs_common.c @@ -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" diff --git a/src/or/hs_service.c b/src/or/hs_service.c index 90e607225b..007c84cafc 100644 --- a/src/or/hs_service.c +++ b/src/or/hs_service.c @@ -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" diff --git a/src/or/include.am b/src/or/include.am index 6ced3e1558..e6f23e916d 100644 --- a/src/or/include.am +++ b/src/or/include.am @@ -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 \ diff --git a/src/or/main.c b/src/or/main.c index 0daebfc4fd..73c23ee980 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -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" diff --git a/src/or/microdesc.c b/src/or/microdesc.c index f06c4bd2ae..208f35b1cc 100644 --- a/src/or/microdesc.c +++ b/src/or/microdesc.c @@ -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 diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index 11021a7ead..8ad1bb25b7 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -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" diff --git a/src/or/networkstatus_sr_info_st.h b/src/or/networkstatus_sr_info_st.h new file mode 100644 index 0000000000..3b2690f0ae --- /dev/null +++ b/src/or/networkstatus_sr_info_st.h @@ -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 + diff --git a/src/or/networkstatus_st.h b/src/or/networkstatus_st.h new file mode 100644 index 0000000000..81965395a2 --- /dev/null +++ b/src/or/networkstatus_st.h @@ -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 + diff --git a/src/or/nodelist.c b/src/or/nodelist.c index 72eada57cd..45a63388f2 100644 --- a/src/or/nodelist.c +++ b/src/or/nodelist.c @@ -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); diff --git a/src/or/or.h b/src/or/or.h index 1069e30d0a..43fe09f23b 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -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. */ diff --git a/src/or/rendcommon.c b/src/or/rendcommon.c index 0ab42fb426..694b52db1f 100644 --- a/src/or/rendcommon.c +++ b/src/or/rendcommon.c @@ -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" diff --git a/src/or/rendservice.c b/src/or/rendservice.c index 4a8b7a0e15..8552fedd31 100644 --- a/src/or/rendservice.c +++ b/src/or/rendservice.c @@ -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" diff --git a/src/or/rephist.c b/src/or/rephist.c index 909cd043b8..efc338c5e0 100644 --- a/src/or/rephist.c +++ b/src/or/rephist.c @@ -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); diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 5a8d19f6f4..0f93181533 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 "document_signature_st.h" +#include "networkstatus_st.h" #include "networkstatus_voter_info_st.h" #include "node_st.h" #include "vote_routerstatus_st.h" diff --git a/src/or/routerparse.c b/src/or/routerparse.c index 73721bf236..ab64b1c825 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -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" diff --git a/src/or/shared_random_client.c b/src/or/shared_random_client.c index 3aef83cef4..14997b21ba 100644 --- a/src/or/shared_random_client.c +++ b/src/or/shared_random_client.c @@ -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 * diff --git a/src/or/voting_schedule.c b/src/or/voting_schedule.c index 1d66b5e225..983cabbbf3 100644 --- a/src/or/voting_schedule.c +++ b/src/or/voting_schedule.c @@ -15,6 +15,8 @@ #include "config.h" #include "networkstatus.h" +#include "networkstatus_st.h" + /* ===== * Vote scheduling * ===== */ diff --git a/src/test/fuzz/fuzz_vrs.c b/src/test/fuzz/fuzz_vrs.c index 7225fd5456..a597674940 100644 --- a/src/test/fuzz/fuzz_vrs.c +++ b/src/test/fuzz/fuzz_vrs.c @@ -8,6 +8,7 @@ #include "microdesc.h" #include "networkstatus.h" +#include "networkstatus_st.h" #include "vote_routerstatus_st.h" #include "fuzzing.h" diff --git a/src/test/test_address_set.c b/src/test/test_address_set.c index f7441a6491..441d14927d 100644 --- a/src/test/test_address_set.c +++ b/src/test/test_address_set.c @@ -10,6 +10,8 @@ #include "routerlist.h" #include "torcert.h" +#include "networkstatus_st.h" + #include "test.h" static networkstatus_t *dummy_ns = NULL; diff --git a/src/test/test_channel.c b/src/test/test_channel.c index c41afff5d0..8177f92a1a 100644 --- a/src/test/test_channel.c +++ b/src/test/test_channel.c @@ -20,6 +20,7 @@ #include "scheduler.h" #include "networkstatus.h" +#include "networkstatus_st.h" #include "origin_circuit_st.h" /* Test suite stuff */ diff --git a/src/test/test_channelpadding.c b/src/test/test_channelpadding.c index b8e3492eaa..2b4ff59a32 100644 --- a/src/test/test_channelpadding.c +++ b/src/test/test_channelpadding.c @@ -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); diff --git a/src/test/test_consdiffmgr.c b/src/test/test_consdiffmgr.c index 3b91baca39..dc223274b9 100644 --- a/src/test/test_consdiffmgr.c +++ b/src/test/test_consdiffmgr.c @@ -14,6 +14,8 @@ #include "routerparse.h" #include "workqueue.h" +#include "networkstatus_st.h" + #include "test.h" #include "log_test_helpers.h" diff --git a/src/test/test_dir.c b/src/test/test_dir.c index f5a3b6f65c..10169a70cf 100644 --- a/src/test/test_dir.c +++ b/src/test/test_dir.c @@ -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" diff --git a/src/test/test_dir_common.c b/src/test/test_dir_common.c index fca132c9f7..3fad1c3af0 100644 --- a/src/test/test_dir_common.c +++ b/src/test/test_dir_common.c @@ -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" diff --git a/src/test/test_dir_handle_get.c b/src/test/test_dir_handle_get.c index ff9740b911..2e9eb3b748 100644 --- a/src/test/test_dir_handle_get.c +++ b/src/test/test_dir_handle_get.c @@ -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 diff --git a/src/test/test_dos.c b/src/test/test_dos.c index fcc537499a..7145339084 100644 --- a/src/test/test_dos.c +++ b/src/test/test_dos.c @@ -16,6 +16,7 @@ #include "nodelist.h" #include "routerlist.h" +#include "networkstatus_st.h" #include "or_connection_st.h" #include "test.h" diff --git a/src/test/test_entrynodes.c b/src/test/test_entrynodes.c index cf9da232ca..5722637735 100644 --- a/src/test/test_entrynodes.c +++ b/src/test/test_entrynodes.c @@ -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" diff --git a/src/test/test_guardfraction.c b/src/test/test_guardfraction.c index 24bf58f942..38f237c5dd 100644 --- a/src/test/test_guardfraction.c +++ b/src/test/test_guardfraction.c @@ -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" diff --git a/src/test/test_hs_cache.c b/src/test/test_hs_cache.c index b2f892c7f2..415f6f30ee 100644 --- a/src/test/test_hs_cache.c +++ b/src/test/test_hs_cache.c @@ -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" diff --git a/src/test/test_hs_client.c b/src/test/test_hs_client.c index b75e743d3c..ca87d5e92d 100644 --- a/src/test/test_hs_client.c +++ b/src/test/test_hs_client.c @@ -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" diff --git a/src/test/test_hs_common.c b/src/test/test_hs_common.c index 21a109d2bc..1cfa4a2409 100644 --- a/src/test/test_hs_common.c +++ b/src/test/test_hs_common.c @@ -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 */ diff --git a/src/test/test_hs_service.c b/src/test/test_hs_service.c index 83a9d3cb59..ab27b4dc4e 100644 --- a/src/test/test_hs_service.c +++ b/src/test/test_hs_service.c @@ -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" diff --git a/src/test/test_microdesc.c b/src/test/test_microdesc.c index 4b168f49ed..27fdf4a9d0 100644 --- a/src/test/test_microdesc.c +++ b/src/test/test_microdesc.c @@ -13,6 +13,8 @@ #include "routerparse.h" #include "torcert.h" +#include "networkstatus_st.h" + #include "test.h" #ifdef _WIN32 diff --git a/src/test/test_nodelist.c b/src/test/test_nodelist.c index a3f2de29f0..4a876f3557 100644 --- a/src/test/test_nodelist.c +++ b/src/test/test_nodelist.c @@ -12,6 +12,7 @@ #include "nodelist.h" #include "torcert.h" +#include "networkstatus_st.h" #include "node_st.h" #include "test.h" diff --git a/src/test/test_routerlist.c b/src/test/test_routerlist.c index bf97499eee..45d63a8061 100644 --- a/src/test/test_routerlist.c +++ b/src/test/test_routerlist.c @@ -35,6 +35,7 @@ #include "statefile.h" #include "dir_connection_st.h" +#include "networkstatus_st.h" #include "node_st.h" #include "test.h" diff --git a/src/test/test_shared_random.c b/src/test/test_shared_random.c index baafb9813b..a1b4d60a2c 100644 --- a/src/test/test_shared_random.c +++ b/src/test/test_shared_random.c @@ -23,6 +23,7 @@ #include "voting_schedule.h" #include "dir_server_st.h" +#include "networkstatus_st.h" static authority_cert_t *mock_cert; -- cgit v1.2.3-54-g00ecf From b8ae4111e38bc9cf6ac395b78601c150f710936f Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 15 Jun 2018 14:07:17 -0400 Subject: Extract desc_store_t and routerlist_t into their own headers. --- src/or/control.c | 1 + src/or/desc_store_st.h | 34 ++++++++++++++++++++++++++++ src/or/dirauth/dirvote.c | 1 + src/or/dirserv.c | 1 + src/or/include.am | 2 ++ src/or/networkstatus.c | 1 + src/or/nodelist.c | 1 + src/or/or.h | 51 ++---------------------------------------- src/or/routerlist.c | 1 + src/or/routerlist_st.h | 40 +++++++++++++++++++++++++++++++++ src/or/routerparse.c | 1 + src/or/routerparse.h | 1 + src/test/test_dir.c | 1 + src/test/test_dir_handle_get.c | 1 + src/test/test_helpers.c | 1 + 15 files changed, 89 insertions(+), 49 deletions(-) create mode 100644 src/or/desc_store_st.h create mode 100644 src/or/routerlist_st.h (limited to 'src/or/routerlist.c') diff --git a/src/or/control.c b/src/or/control.c index 0afd6cf973..55670e65e0 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -92,6 +92,7 @@ #include "rend_authorized_client_st.h" #include "rend_encoded_v2_service_descriptor_st.h" #include "rend_service_descriptor_st.h" +#include "routerlist_st.h" #include "socks_request_st.h" #ifndef _WIN32 diff --git a/src/or/desc_store_st.h b/src/or/desc_store_st.h new file mode 100644 index 0000000000..40238f4ce1 --- /dev/null +++ b/src/or/desc_store_st.h @@ -0,0 +1,34 @@ +/* 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 DESC_STORE_ST_H +#define DESC_STORE_ST_H + +/** A 'store' is a set of descriptors saved on disk, with accompanying + * journal, mmaped as needed, rebuilt as needed. */ +struct desc_store_t { + /** Filename (within DataDir) for the store. We append .tmp to this + * filename for a temporary file when rebuilding the store, and .new to this + * filename for the journal. */ + const char *fname_base; + /** Human-readable description of what this store contains. */ + const char *description; + + tor_mmap_t *mmap; /**< A mmap for the main file in the store. */ + + store_type_t type; /**< What's stored in this store? */ + + /** The size of the router log, in bytes. */ + size_t journal_len; + /** The size of the router store, in bytes. */ + size_t store_len; + /** Total bytes dropped since last rebuild: this is space currently + * used in the cache and the journal that could be freed by a rebuild. */ + size_t bytes_dropped; +}; + +#endif + diff --git a/src/or/dirauth/dirvote.c b/src/or/dirauth/dirvote.c index c402bcb799..1f95b985c0 100644 --- a/src/or/dirauth/dirvote.c +++ b/src/or/dirauth/dirvote.c @@ -34,6 +34,7 @@ #include "networkstatus_voter_info_st.h" #include "node_st.h" #include "ns_detached_signatures_st.h" +#include "routerlist_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 c4edb94af3..d92bc8e1f7 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -38,6 +38,7 @@ #include "dir_connection_st.h" #include "node_st.h" +#include "routerlist_st.h" #include "tor_version_st.h" #include "vote_routerstatus_st.h" diff --git a/src/or/include.am b/src/or/include.am index 7dcb725731..396cfea5ab 100644 --- a/src/or/include.am +++ b/src/or/include.am @@ -210,6 +210,7 @@ ORHEADERS = \ src/or/crypt_path_st.h \ src/or/crypt_path_reference_st.h \ src/or/cpuworker.h \ + src/or/desc_store_st.h \ src/or/directory.h \ src/or/dirserv.h \ src/or/dir_connection_st.h \ @@ -294,6 +295,7 @@ ORHEADERS = \ src/or/router.h \ src/or/routerkeys.h \ src/or/routerlist.h \ + src/or/routerlist_st.h \ src/or/routerkeys.h \ src/or/routerset.h \ src/or/routerparse.h \ diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index 0c351f0e40..6f7223b60a 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -81,6 +81,7 @@ #include "networkstatus_voter_info_st.h" #include "ns_detached_signatures_st.h" #include "node_st.h" +#include "routerlist_st.h" #include "vote_microdesc_hash_st.h" #include "vote_routerstatus_st.h" diff --git a/src/or/nodelist.c b/src/or/nodelist.c index 45a63388f2..26b1788a30 100644 --- a/src/or/nodelist.c +++ b/src/or/nodelist.c @@ -71,6 +71,7 @@ #include "dir_server_st.h" #include "networkstatus_st.h" #include "node_st.h" +#include "routerlist_st.h" static void nodelist_drop_node(node_t *node, int remove_from_ht); #define node_free(val) \ diff --git a/src/or/or.h b/src/or/or.h index d6a42bd9da..a8ddcd2406 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -1891,55 +1891,8 @@ typedef enum store_type_t { EXTRAINFO_STORE = 1 } store_type_t; -/** A 'store' is a set of descriptors saved on disk, with accompanying - * journal, mmaped as needed, rebuilt as needed. */ -typedef struct desc_store_t { - /** Filename (within DataDir) for the store. We append .tmp to this - * filename for a temporary file when rebuilding the store, and .new to this - * filename for the journal. */ - const char *fname_base; - /** Human-readable description of what this store contains. */ - const char *description; - - tor_mmap_t *mmap; /**< A mmap for the main file in the store. */ - - store_type_t type; /**< What's stored in this store? */ - - /** The size of the router log, in bytes. */ - size_t journal_len; - /** The size of the router store, in bytes. */ - size_t store_len; - /** Total bytes dropped since last rebuild: this is space currently - * used in the cache and the journal that could be freed by a rebuild. */ - size_t bytes_dropped; -} desc_store_t; - -/** Contents of a directory of onion routers. */ -typedef struct { - /** Map from server identity digest to a member of routers. */ - struct digest_ri_map_t *identity_map; - /** Map from server descriptor digest to a signed_descriptor_t from - * routers or old_routers. */ - struct digest_sd_map_t *desc_digest_map; - /** Map from extra-info digest to an extrainfo_t. Only exists for - * routers in routers or old_routers. */ - struct digest_ei_map_t *extra_info_map; - /** Map from extra-info digests to a signed_descriptor_t for a router - * descriptor having that extra-info digest. Only exists for - * routers in routers or old_routers. */ - struct digest_sd_map_t *desc_by_eid_map; - /** List of routerinfo_t for all currently live routers we know. */ - smartlist_t *routers; - /** List of signed_descriptor_t for older router descriptors we're - * caching. */ - smartlist_t *old_routers; - /** Store holding server descriptors. If present, any router whose - * cache_info.saved_location == SAVED_IN_CACHE is stored in this file - * starting at cache_info.saved_offset */ - desc_store_t desc_store; - /** Store holding extra-info documents. */ - desc_store_t extrainfo_store; -} routerlist_t; +typedef struct desc_store_t desc_store_t; +typedef struct routerlist_t routerlist_t; /** Information on router used when extending a circuit. We don't need a * full routerinfo_t to extend: we only need addr:port:keyid to build an OR diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 0f93181533..102f3125a4 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -131,6 +131,7 @@ #include "networkstatus_st.h" #include "networkstatus_voter_info_st.h" #include "node_st.h" +#include "routerlist_st.h" #include "vote_routerstatus_st.h" // #define DEBUG_ROUTERLIST diff --git a/src/or/routerlist_st.h b/src/or/routerlist_st.h new file mode 100644 index 0000000000..6dfecf4d8a --- /dev/null +++ b/src/or/routerlist_st.h @@ -0,0 +1,40 @@ +/* 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 ROUTERLIST_ST_H +#define ROUTERLIST_ST_H + +#include "desc_store_st.h" + +/** Contents of a directory of onion routers. */ +struct routerlist_t { + /** Map from server identity digest to a member of routers. */ + struct digest_ri_map_t *identity_map; + /** Map from server descriptor digest to a signed_descriptor_t from + * routers or old_routers. */ + struct digest_sd_map_t *desc_digest_map; + /** Map from extra-info digest to an extrainfo_t. Only exists for + * routers in routers or old_routers. */ + struct digest_ei_map_t *extra_info_map; + /** Map from extra-info digests to a signed_descriptor_t for a router + * descriptor having that extra-info digest. Only exists for + * routers in routers or old_routers. */ + struct digest_sd_map_t *desc_by_eid_map; + /** List of routerinfo_t for all currently live routers we know. */ + smartlist_t *routers; + /** List of signed_descriptor_t for older router descriptors we're + * caching. */ + smartlist_t *old_routers; + /** Store holding server descriptors. If present, any router whose + * cache_info.saved_location == SAVED_IN_CACHE is stored in this file + * starting at cache_info.saved_offset */ + desc_store_t desc_store; + /** Store holding extra-info documents. */ + desc_store_t extrainfo_store; +}; + +#endif + diff --git a/src/or/routerparse.c b/src/or/routerparse.c index be6ed00e25..ea1320de78 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -88,6 +88,7 @@ #include "rend_authorized_client_st.h" #include "rend_intro_point_st.h" #include "rend_service_descriptor_st.h" +#include "routerlist_st.h" #include "tor_version_st.h" #include "vote_microdesc_hash_st.h" #include "vote_routerstatus_st.h" diff --git a/src/or/routerparse.h b/src/or/routerparse.h index 418fd3acdb..663c80fb81 100644 --- a/src/or/routerparse.h +++ b/src/or/routerparse.h @@ -43,6 +43,7 @@ routerinfo_t *router_parse_entry_from_string(const char *s, const char *end, int allow_annotations, const char *prepend_annotations, int *can_dl_again_out); +struct digest_ri_map_t; extrainfo_t *extrainfo_parse_entry_from_string(const char *s, const char *end, int cache_copy, struct digest_ri_map_t *routermap, int *can_dl_again_out); diff --git a/src/test/test_dir.c b/src/test/test_dir.c index 76f3b13f6e..9412f879dd 100644 --- a/src/test/test_dir.c +++ b/src/test/test_dir.c @@ -50,6 +50,7 @@ #include "networkstatus_voter_info_st.h" #include "ns_detached_signatures_st.h" #include "port_cfg_st.h" +#include "routerlist_st.h" #include "tor_version_st.h" #include "vote_microdesc_hash_st.h" #include "vote_routerstatus_st.h" diff --git a/src/test/test_dir_handle_get.c b/src/test/test_dir_handle_get.c index 2e9eb3b748..c8704505e9 100644 --- a/src/test/test_dir_handle_get.c +++ b/src/test/test_dir_handle_get.c @@ -38,6 +38,7 @@ #include "dir_server_st.h" #include "networkstatus_st.h" #include "rend_encoded_v2_service_descriptor_st.h" +#include "routerlist_st.h" #ifdef _WIN32 /* For mkdir() */ diff --git a/src/test/test_helpers.c b/src/test/test_helpers.c index 78d10b261f..fc32665a18 100644 --- a/src/test/test_helpers.c +++ b/src/test/test_helpers.c @@ -27,6 +27,7 @@ #include "connection_st.h" #include "node_st.h" #include "origin_circuit_st.h" +#include "routerlist_st.h" #include "test.h" #include "test_helpers.h" -- cgit v1.2.3-54-g00ecf From 1e4e9db8157e8691327fe9ee9de5df6fe9891040 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 15 Jun 2018 14:14:11 -0400 Subject: Extract authority_cert_t into its own header --- src/or/authority_cert_st.h | 30 ++++++++++++++++++++++++++++++ src/or/dirauth/dirvote.c | 1 + src/or/dirauth/shared_random.c | 1 + src/or/directory.c | 1 + src/or/include.am | 1 + src/or/networkstatus.c | 1 + src/or/or.h | 19 +------------------ src/or/router.c | 1 + src/or/routerlist.c | 1 + src/or/routerparse.c | 1 + src/test/test_dir.c | 1 + src/test/test_dir_common.c | 1 + src/test/test_routerlist.c | 1 + 13 files changed, 42 insertions(+), 18 deletions(-) create mode 100644 src/or/authority_cert_st.h (limited to 'src/or/routerlist.c') diff --git a/src/or/authority_cert_st.h b/src/or/authority_cert_st.h new file mode 100644 index 0000000000..b1dbcddbef --- /dev/null +++ b/src/or/authority_cert_st.h @@ -0,0 +1,30 @@ +/* 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 AUTHORITY_CERT_ST_H +#define AUTHORITY_CERT_ST_H + +/** Certificate for v3 directory protocol: binds long-term authority identity + * keys to medium-term authority signing keys. */ +struct authority_cert_t { + /** Information relating to caching this cert on disk and looking it up. */ + signed_descriptor_t cache_info; + /** This authority's long-term authority identity key. */ + crypto_pk_t *identity_key; + /** This authority's medium-term signing key. */ + crypto_pk_t *signing_key; + /** The digest of signing_key */ + char signing_key_digest[DIGEST_LEN]; + /** The listed expiration time of this certificate. */ + time_t expires; + /** This authority's IPv4 address, in host order. */ + uint32_t addr; + /** This authority's directory port. */ + uint16_t dir_port; +}; + +#endif + diff --git a/src/or/dirauth/dirvote.c b/src/or/dirauth/dirvote.c index 1f95b985c0..29134868c8 100644 --- a/src/or/dirauth/dirvote.c +++ b/src/or/dirauth/dirvote.c @@ -28,6 +28,7 @@ #include "dirauth/mode.h" #include "dirauth/shared_random_state.h" +#include "authority_cert_st.h" #include "dir_server_st.h" #include "document_signature_st.h" #include "networkstatus_st.h" diff --git a/src/or/dirauth/shared_random.c b/src/or/dirauth/shared_random.c index 137f695dbe..c042acda1b 100644 --- a/src/or/dirauth/shared_random.c +++ b/src/or/dirauth/shared_random.c @@ -105,6 +105,7 @@ #include "dirauth/dirvote.h" #include "dirauth/mode.h" +#include "authority_cert_st.h" #include "networkstatus_st.h" /* String prefix of shared random values in votes/consensuses. */ diff --git a/src/or/directory.c b/src/or/directory.c index b5a07f6b3e..f3080bc1f1 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -54,6 +54,7 @@ #include "dirauth/mode.h" #include "dirauth/shared_random.h" +#include "authority_cert_st.h" #include "dir_connection_st.h" #include "dir_server_st.h" #include "entry_connection_st.h" diff --git a/src/or/include.am b/src/or/include.am index 396cfea5ab..e73432d3cf 100644 --- a/src/or/include.am +++ b/src/or/include.am @@ -181,6 +181,7 @@ endif ORHEADERS = \ src/or/addressmap.h \ + src/or/authority_cert_st.h \ src/or/auth_dirs.inc \ src/or/bridges.h \ src/or/channel.h \ diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index 6f7223b60a..1951414a8a 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -74,6 +74,7 @@ #include "dirauth/mode.h" #include "dirauth/shared_random.h" +#include "authority_cert_st.h" #include "dir_connection_st.h" #include "dir_server_st.h" #include "document_signature_st.h" diff --git a/src/or/or.h b/src/or/or.h index a8ddcd2406..1f7c4be507 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -1911,24 +1911,7 @@ typedef struct extend_info_t { curve25519_public_key_t curve25519_onion_key; } extend_info_t; -/** Certificate for v3 directory protocol: binds long-term authority identity - * keys to medium-term authority signing keys. */ -typedef struct authority_cert_t { - /** Information relating to caching this cert on disk and looking it up. */ - signed_descriptor_t cache_info; - /** This authority's long-term authority identity key. */ - crypto_pk_t *identity_key; - /** This authority's medium-term signing key. */ - crypto_pk_t *signing_key; - /** The digest of signing_key */ - char signing_key_digest[DIGEST_LEN]; - /** The listed expiration time of this certificate. */ - time_t expires; - /** This authority's IPv4 address, in host order. */ - uint32_t addr; - /** This authority's directory port. */ - uint16_t dir_port; -} authority_cert_t; +typedef struct authority_cert_t authority_cert_t; /** Bitfield enum type listing types of information that directory authorities * can be authoritative about, and that directory caches may or may not cache. diff --git a/src/or/router.c b/src/or/router.c index 6d8f61d716..961fab1290 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -39,6 +39,7 @@ #include "dirauth/mode.h" +#include "authority_cert_st.h" #include "crypt_path_st.h" #include "dir_connection_st.h" #include "dir_server_st.h" diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 102f3125a4..3170ce6017 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -125,6 +125,7 @@ #include "dirauth/dirvote.h" #include "dirauth/mode.h" +#include "authority_cert_st.h" #include "dir_connection_st.h" #include "dir_server_st.h" #include "document_signature_st.h" diff --git a/src/or/routerparse.c b/src/or/routerparse.c index ea1320de78..34c851a1b5 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -81,6 +81,7 @@ #include "dirauth/dirvote.h" +#include "authority_cert_st.h" #include "document_signature_st.h" #include "networkstatus_st.h" #include "networkstatus_voter_info_st.h" diff --git a/src/test/test_dir.c b/src/test/test_dir.c index 9412f879dd..ecce489423 100644 --- a/src/test/test_dir.c +++ b/src/test/test_dir.c @@ -45,6 +45,7 @@ #include "log_test_helpers.h" #include "voting_schedule.h" +#include "authority_cert_st.h" #include "document_signature_st.h" #include "networkstatus_st.h" #include "networkstatus_voter_info_st.h" diff --git a/src/test/test_dir_common.c b/src/test/test_dir_common.c index 3fad1c3af0..c23282ba85 100644 --- a/src/test/test_dir_common.c +++ b/src/test/test_dir_common.c @@ -14,6 +14,7 @@ #include "test_dir_common.h" #include "voting_schedule.h" +#include "authority_cert_st.h" #include "networkstatus_st.h" #include "networkstatus_voter_info_st.h" #include "vote_microdesc_hash_st.h" diff --git a/src/test/test_routerlist.c b/src/test/test_routerlist.c index 45d63a8061..1c2ba9d673 100644 --- a/src/test/test_routerlist.c +++ b/src/test/test_routerlist.c @@ -34,6 +34,7 @@ #include "dirauth/shared_random.h" #include "statefile.h" +#include "authority_cert_st.h" #include "dir_connection_st.h" #include "networkstatus_st.h" #include "node_st.h" -- cgit v1.2.3-54-g00ecf From 00f1d1653e4ff703cfbcf82060b229ca8a39030d Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 15 Jun 2018 14:21:25 -0400 Subject: Extract extrainfo_t into its own header --- src/or/control.c | 1 + src/or/dirserv.c | 1 + src/or/extrainfo_st.h | 28 ++++++++++++++++++++++++++++ src/or/include.am | 1 + src/or/or.h | 17 +---------------- src/or/router.c | 1 + src/or/routerlist.c | 1 + src/or/routerparse.c | 1 + src/test/test_dir.c | 1 + 9 files changed, 36 insertions(+), 16 deletions(-) create mode 100644 src/or/extrainfo_st.h (limited to 'src/or/routerlist.c') diff --git a/src/or/control.c b/src/or/control.c index 55670e65e0..c1d14b7a45 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -84,6 +84,7 @@ #include "control_connection_st.h" #include "cpath_build_state_st.h" #include "entry_connection_st.h" +#include "extrainfo_st.h" #include "networkstatus_st.h" #include "node_st.h" #include "or_connection_st.h" diff --git a/src/or/dirserv.c b/src/or/dirserv.c index d92bc8e1f7..b76fa25d6d 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -37,6 +37,7 @@ #include "dirauth/dirvote.h" #include "dir_connection_st.h" +#include "extrainfo_st.h" #include "node_st.h" #include "routerlist_st.h" #include "tor_version_st.h" diff --git a/src/or/extrainfo_st.h b/src/or/extrainfo_st.h new file mode 100644 index 0000000000..d653978490 --- /dev/null +++ b/src/or/extrainfo_st.h @@ -0,0 +1,28 @@ +/* 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 EXTRAINFO_ST_H +#define EXTRAINFO_ST_H + +/** Information needed to keep and cache a signed extra-info document. */ +struct extrainfo_t { + signed_descriptor_t cache_info; + /** SHA256 digest of this document */ + uint8_t digest256[DIGEST256_LEN]; + /** The router's nickname. */ + char nickname[MAX_NICKNAME_LEN+1]; + /** True iff we found the right key for this extra-info, verified the + * signature, and found it to be bad. */ + unsigned int bad_sig : 1; + /** If present, we didn't have the right key to verify this extra-info, + * so this is a copy of the signature in the document. */ + char *pending_sig; + /** Length of pending_sig. */ + size_t pending_sig_len; +}; + +#endif + diff --git a/src/or/include.am b/src/or/include.am index e73432d3cf..afacd7772f 100644 --- a/src/or/include.am +++ b/src/or/include.am @@ -225,6 +225,7 @@ ORHEADERS = \ src/or/entry_connection_st.h \ src/or/entry_port_cfg_st.h \ src/or/ext_orport.h \ + src/or/extrainfo_st.h \ src/or/fallback_dirs.inc \ src/or/fp_pair.h \ src/or/geoip.h \ diff --git a/src/or/or.h b/src/or/or.h index 1f7c4be507..d07e594d77 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -1693,22 +1693,7 @@ typedef struct { uint8_t purpose; } routerinfo_t; -/** Information needed to keep and cache a signed extra-info document. */ -typedef struct extrainfo_t { - signed_descriptor_t cache_info; - /** SHA256 digest of this document */ - uint8_t digest256[DIGEST256_LEN]; - /** The router's nickname. */ - char nickname[MAX_NICKNAME_LEN+1]; - /** True iff we found the right key for this extra-info, verified the - * signature, and found it to be bad. */ - unsigned int bad_sig : 1; - /** If present, we didn't have the right key to verify this extra-info, - * so this is a copy of the signature in the document. */ - char *pending_sig; - /** Length of pending_sig. */ - size_t pending_sig_len; -} extrainfo_t; +typedef struct extrainfo_t extrainfo_t; /** Contents of a single router entry in a network status object. */ diff --git a/src/or/router.c b/src/or/router.c index 961fab1290..28dd360d35 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -43,6 +43,7 @@ #include "crypt_path_st.h" #include "dir_connection_st.h" #include "dir_server_st.h" +#include "extrainfo_st.h" #include "node_st.h" #include "origin_circuit_st.h" #include "port_cfg_st.h" diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 3170ce6017..425ad8273f 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -129,6 +129,7 @@ #include "dir_connection_st.h" #include "dir_server_st.h" #include "document_signature_st.h" +#include "extrainfo_st.h" #include "networkstatus_st.h" #include "networkstatus_voter_info_st.h" #include "node_st.h" diff --git a/src/or/routerparse.c b/src/or/routerparse.c index 34c851a1b5..7a19460dff 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -83,6 +83,7 @@ #include "authority_cert_st.h" #include "document_signature_st.h" +#include "extrainfo_st.h" #include "networkstatus_st.h" #include "networkstatus_voter_info_st.h" #include "ns_detached_signatures_st.h" diff --git a/src/test/test_dir.c b/src/test/test_dir.c index ecce489423..c25665d3e3 100644 --- a/src/test/test_dir.c +++ b/src/test/test_dir.c @@ -47,6 +47,7 @@ #include "authority_cert_st.h" #include "document_signature_st.h" +#include "extrainfo_st.h" #include "networkstatus_st.h" #include "networkstatus_voter_info_st.h" #include "ns_detached_signatures_st.h" -- cgit v1.2.3-54-g00ecf From ed0731c7ded26d84975411f4a0e35f2500f3eb2a Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 15 Jun 2018 14:49:15 -0400 Subject: Extract routerinfo_t into its own header. I was expecting this to be much worse. --- src/or/bridges.c | 1 + src/or/channeltls.c | 1 + src/or/circuitbuild.c | 1 + src/or/connection.c | 1 + src/or/connection_or.c | 1 + src/or/control.c | 1 + src/or/dirauth/dirvote.c | 1 + src/or/directory.c | 1 + src/or/dirserv.c | 1 + src/or/include.am | 1 + src/or/main.c | 1 + src/or/networkstatus.c | 1 + src/or/nodelist.c | 1 + src/or/or.h | 95 +------------------------------------ src/or/policies.c | 1 + src/or/relay.c | 1 + src/or/router.c | 1 + src/or/routerinfo_st.h | 105 +++++++++++++++++++++++++++++++++++++++++ src/or/routerlist.c | 1 + src/or/routerparse.c | 1 + src/or/routerset.c | 1 + src/or/status.c | 2 + src/test/test_address_set.c | 1 + src/test/test_config.c | 1 + src/test/test_connection.c | 1 + src/test/test_dir.c | 1 + src/test/test_dir_common.c | 1 + src/test/test_dir_handle_get.c | 1 + src/test/test_entrynodes.c | 1 + src/test/test_hs.c | 1 + src/test/test_hs_common.c | 1 + src/test/test_hs_service.c | 1 + src/test/test_microdesc.c | 1 + src/test/test_nodelist.c | 1 + src/test/test_policy.c | 1 + src/test/test_rendcache.c | 1 + src/test/test_router.c | 2 + src/test/test_routerset.c | 1 + src/test/test_status.c | 1 + 39 files changed, 145 insertions(+), 94 deletions(-) create mode 100644 src/or/routerinfo_st.h (limited to 'src/or/routerlist.c') diff --git a/src/or/bridges.c b/src/or/bridges.c index 3108e14951..013c45cd53 100644 --- a/src/or/bridges.c +++ b/src/or/bridges.c @@ -28,6 +28,7 @@ #include "transports.h" #include "node_st.h" +#include "routerinfo_st.h" #include "routerstatus_st.h" /** Information about a configured bridge. Currently this just matches the diff --git a/src/or/channeltls.c b/src/or/channeltls.c index 4d56778210..dd0c1628c4 100644 --- a/src/or/channeltls.c +++ b/src/or/channeltls.c @@ -63,6 +63,7 @@ #include "or_connection_st.h" #include "or_handshake_certs_st.h" #include "or_handshake_state_st.h" +#include "routerinfo_st.h" /** How many CELL_PADDING cells have we received, ever? */ uint64_t stats_n_padding_cells_processed = 0; diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index b871bd10c7..103dd6eb9b 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -71,6 +71,7 @@ #include "or_circuit_st.h" #include "origin_circuit_st.h" #include "microdesc_st.h" +#include "routerinfo_st.h" #include "routerstatus_st.h" static channel_t * channel_connect_for_circuit(const tor_addr_t *addr, diff --git a/src/or/connection.c b/src/or/connection.c index 283f096528..6e133f8d4d 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -119,6 +119,7 @@ #include "listener_connection_st.h" #include "or_connection_st.h" #include "port_cfg_st.h" +#include "routerinfo_st.h" #include "socks_request_st.h" static connection_t *connection_listener_new( diff --git a/src/or/connection_or.c b/src/or/connection_or.c index 070253dce6..1810c39546 100644 --- a/src/or/connection_or.c +++ b/src/or/connection_or.c @@ -64,6 +64,7 @@ #include "or_connection_st.h" #include "or_handshake_certs_st.h" #include "or_handshake_state_st.h" +#include "routerinfo_st.h" static int connection_tls_finish_handshake(or_connection_t *conn); static int connection_or_launch_v3_or_handshake(or_connection_t *conn); diff --git a/src/or/control.c b/src/or/control.c index 642d387745..520b6178f7 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -94,6 +94,7 @@ #include "rend_authorized_client_st.h" #include "rend_encoded_v2_service_descriptor_st.h" #include "rend_service_descriptor_st.h" +#include "routerinfo_st.h" #include "routerlist_st.h" #include "socks_request_st.h" diff --git a/src/or/dirauth/dirvote.c b/src/or/dirauth/dirvote.c index 73fa07bfe3..94a6139f57 100644 --- a/src/or/dirauth/dirvote.c +++ b/src/or/dirauth/dirvote.c @@ -36,6 +36,7 @@ #include "networkstatus_voter_info_st.h" #include "node_st.h" #include "ns_detached_signatures_st.h" +#include "routerinfo_st.h" #include "routerlist_st.h" #include "vote_microdesc_hash_st.h" #include "vote_routerstatus_st.h" diff --git a/src/or/directory.c b/src/or/directory.c index f3080bc1f1..4e2e968867 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -61,6 +61,7 @@ #include "networkstatus_st.h" #include "node_st.h" #include "rend_service_descriptor_st.h" +#include "routerinfo_st.h" /** * \file directory.c diff --git a/src/or/dirserv.c b/src/or/dirserv.c index 8cfccda61e..e54782d196 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -40,6 +40,7 @@ #include "extrainfo_st.h" #include "microdesc_st.h" #include "node_st.h" +#include "routerinfo_st.h" #include "routerlist_st.h" #include "tor_version_st.h" #include "vote_routerstatus_st.h" diff --git a/src/or/include.am b/src/or/include.am index 564af4ba48..468b231f7b 100644 --- a/src/or/include.am +++ b/src/or/include.am @@ -296,6 +296,7 @@ ORHEADERS = \ src/or/rephist.h \ src/or/replaycache.h \ src/or/router.h \ + src/or/routerinfo_st.h \ src/or/routerkeys.h \ src/or/routerlist.h \ src/or/routerlist_st.h \ diff --git a/src/or/main.c b/src/or/main.c index 73c23ee980..664105046b 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -126,6 +126,7 @@ #include "networkstatus_st.h" #include "or_connection_st.h" #include "port_cfg_st.h" +#include "routerinfo_st.h" #include "socks_request_st.h" #ifdef HAVE_SYSTEMD diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index 1951414a8a..dd994f0852 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -82,6 +82,7 @@ #include "networkstatus_voter_info_st.h" #include "ns_detached_signatures_st.h" #include "node_st.h" +#include "routerinfo_st.h" #include "routerlist_st.h" #include "vote_microdesc_hash_st.h" #include "vote_routerstatus_st.h" diff --git a/src/or/nodelist.c b/src/or/nodelist.c index 91d1003368..5e575e9a83 100644 --- a/src/or/nodelist.c +++ b/src/or/nodelist.c @@ -72,6 +72,7 @@ #include "microdesc_st.h" #include "networkstatus_st.h" #include "node_st.h" +#include "routerinfo_st.h" #include "routerlist_st.h" #include "routerstatus_st.h" diff --git a/src/or/or.h b/src/or/or.h index 40d7dfee31..208ec6d33e 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -1599,100 +1599,7 @@ typedef struct protover_summary_flags_t { unsigned int supports_v3_rendezvous_point: 1; } protover_summary_flags_t; -/** Information about another onion router in the network. */ -typedef struct { - signed_descriptor_t cache_info; - char *nickname; /**< Human-readable OR name. */ - - uint32_t addr; /**< IPv4 address of OR, in host order. */ - uint16_t or_port; /**< Port for TLS connections. */ - uint16_t dir_port; /**< Port for HTTP directory connections. */ - - /** A router's IPv6 address, if it has one. */ - /* XXXXX187 Actually these should probably be part of a list of addresses, - * not just a special case. Use abstractions to access these; don't do it - * directly. */ - tor_addr_t ipv6_addr; - uint16_t ipv6_orport; - - crypto_pk_t *onion_pkey; /**< Public RSA key for onions. */ - crypto_pk_t *identity_pkey; /**< Public RSA key for signing. */ - /** Public curve25519 key for onions */ - curve25519_public_key_t *onion_curve25519_pkey; - /** What's the earliest expiration time on all the certs in this - * routerinfo? */ - time_t cert_expiration_time; - - char *platform; /**< What software/operating system is this OR using? */ - - char *protocol_list; /**< Encoded list of subprotocol versions supported - * by this OR */ - - /* link info */ - uint32_t bandwidthrate; /**< How many bytes does this OR add to its token - * bucket per second? */ - uint32_t bandwidthburst; /**< How large is this OR's token bucket? */ - /** How many bytes/s is this router known to handle? */ - uint32_t bandwidthcapacity; - smartlist_t *exit_policy; /**< What streams will this OR permit - * to exit on IPv4? NULL for 'reject *:*'. */ - /** What streams will this OR permit to exit on IPv6? - * NULL for 'reject *:*' */ - struct short_policy_t *ipv6_exit_policy; - long uptime; /**< How many seconds the router claims to have been up */ - smartlist_t *declared_family; /**< Nicknames of router which this router - * claims are its family. */ - char *contact_info; /**< Declared contact info for this router. */ - unsigned int is_hibernating:1; /**< Whether the router claims to be - * hibernating */ - unsigned int caches_extra_info:1; /**< Whether the router says it caches and - * serves extrainfo documents. */ - unsigned int allow_single_hop_exits:1; /**< Whether the router says - * it allows single hop exits. */ - - unsigned int wants_to_be_hs_dir:1; /**< True iff this router claims to be - * a hidden service directory. */ - unsigned int policy_is_reject_star:1; /**< True iff the exit policy for this - * router rejects everything. */ - /** True if, after we have added this router, we should re-launch - * tests for it. */ - unsigned int needs_retest_if_added:1; - - /** True iff this router included "tunnelled-dir-server" in its descriptor, - * implying it accepts tunnelled directory requests, or it advertised - * dir_port > 0. */ - unsigned int supports_tunnelled_dir_requests:1; - - /** Used during voting to indicate that we should not include an entry for - * this routerinfo. Used only during voting. */ - unsigned int omit_from_vote:1; - - /** Flags to summarize the protocol versions for this routerinfo_t. */ - protover_summary_flags_t pv; - -/** Tor can use this router for general positions in circuits; we got it - * from a directory server as usual, or we're an authority and a server - * uploaded it. */ -#define ROUTER_PURPOSE_GENERAL 0 -/** Tor should avoid using this router for circuit-building: we got it - * from a controller. If the controller wants to use it, it'll have to - * ask for it by identity. */ -#define ROUTER_PURPOSE_CONTROLLER 1 -/** Tor should use this router only for bridge positions in circuits: we got - * it via a directory request from the bridge itself, or a bridge - * authority. */ -#define ROUTER_PURPOSE_BRIDGE 2 -/** Tor should not use this router; it was marked in cached-descriptors with - * a purpose we didn't recognize. */ -#define ROUTER_PURPOSE_UNKNOWN 255 - - /** In what way did we find out about this router? One of ROUTER_PURPOSE_*. - * Routers of different purposes are kept segregated and used for different - * things; see notes on ROUTER_PURPOSE_* macros above. - */ - uint8_t purpose; -} routerinfo_t; - +typedef struct routerinfo_t routerinfo_t; typedef struct extrainfo_t extrainfo_t; typedef struct routerstatus_t routerstatus_t; diff --git a/src/or/policies.c b/src/or/policies.c index 07cf12387f..bc4a9a920c 100644 --- a/src/or/policies.c +++ b/src/or/policies.c @@ -34,6 +34,7 @@ #include "microdesc_st.h" #include "node_st.h" #include "port_cfg_st.h" +#include "routerinfo_st.h" #include "routerstatus_st.h" /** Policy that addresses for incoming SOCKS connections must match. */ diff --git a/src/or/relay.c b/src/or/relay.c index 1eaf6f7dba..ff97b52664 100644 --- a/src/or/relay.c +++ b/src/or/relay.c @@ -87,6 +87,7 @@ #include "entry_connection_st.h" #include "or_circuit_st.h" #include "origin_circuit_st.h" +#include "routerinfo_st.h" #include "socks_request_st.h" static edge_connection_t *relay_lookup_conn(circuit_t *circ, cell_t *cell, diff --git a/src/or/router.c b/src/or/router.c index 28dd360d35..ddbfb03135 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -47,6 +47,7 @@ #include "node_st.h" #include "origin_circuit_st.h" #include "port_cfg_st.h" +#include "routerinfo_st.h" /** * \file router.c diff --git a/src/or/routerinfo_st.h b/src/or/routerinfo_st.h new file mode 100644 index 0000000000..800a8cbe3d --- /dev/null +++ b/src/or/routerinfo_st.h @@ -0,0 +1,105 @@ +/* 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 ROUTERINFO_ST_H +#define ROUTERINFO_ST_H + +/** Information about another onion router in the network. */ +struct routerinfo_t { + signed_descriptor_t cache_info; + char *nickname; /**< Human-readable OR name. */ + + uint32_t addr; /**< IPv4 address of OR, in host order. */ + uint16_t or_port; /**< Port for TLS connections. */ + uint16_t dir_port; /**< Port for HTTP directory connections. */ + + /** A router's IPv6 address, if it has one. */ + /* XXXXX187 Actually these should probably be part of a list of addresses, + * not just a special case. Use abstractions to access these; don't do it + * directly. */ + tor_addr_t ipv6_addr; + uint16_t ipv6_orport; + + crypto_pk_t *onion_pkey; /**< Public RSA key for onions. */ + crypto_pk_t *identity_pkey; /**< Public RSA key for signing. */ + /** Public curve25519 key for onions */ + curve25519_public_key_t *onion_curve25519_pkey; + /** What's the earliest expiration time on all the certs in this + * routerinfo? */ + time_t cert_expiration_time; + + char *platform; /**< What software/operating system is this OR using? */ + + char *protocol_list; /**< Encoded list of subprotocol versions supported + * by this OR */ + + /* link info */ + uint32_t bandwidthrate; /**< How many bytes does this OR add to its token + * bucket per second? */ + uint32_t bandwidthburst; /**< How large is this OR's token bucket? */ + /** How many bytes/s is this router known to handle? */ + uint32_t bandwidthcapacity; + smartlist_t *exit_policy; /**< What streams will this OR permit + * to exit on IPv4? NULL for 'reject *:*'. */ + /** What streams will this OR permit to exit on IPv6? + * NULL for 'reject *:*' */ + struct short_policy_t *ipv6_exit_policy; + long uptime; /**< How many seconds the router claims to have been up */ + smartlist_t *declared_family; /**< Nicknames of router which this router + * claims are its family. */ + char *contact_info; /**< Declared contact info for this router. */ + unsigned int is_hibernating:1; /**< Whether the router claims to be + * hibernating */ + unsigned int caches_extra_info:1; /**< Whether the router says it caches and + * serves extrainfo documents. */ + unsigned int allow_single_hop_exits:1; /**< Whether the router says + * it allows single hop exits. */ + + unsigned int wants_to_be_hs_dir:1; /**< True iff this router claims to be + * a hidden service directory. */ + unsigned int policy_is_reject_star:1; /**< True iff the exit policy for this + * router rejects everything. */ + /** True if, after we have added this router, we should re-launch + * tests for it. */ + unsigned int needs_retest_if_added:1; + + /** True iff this router included "tunnelled-dir-server" in its descriptor, + * implying it accepts tunnelled directory requests, or it advertised + * dir_port > 0. */ + unsigned int supports_tunnelled_dir_requests:1; + + /** Used during voting to indicate that we should not include an entry for + * this routerinfo. Used only during voting. */ + unsigned int omit_from_vote:1; + + /** Flags to summarize the protocol versions for this routerinfo_t. */ + protover_summary_flags_t pv; + +/** Tor can use this router for general positions in circuits; we got it + * from a directory server as usual, or we're an authority and a server + * uploaded it. */ +#define ROUTER_PURPOSE_GENERAL 0 +/** Tor should avoid using this router for circuit-building: we got it + * from a controller. If the controller wants to use it, it'll have to + * ask for it by identity. */ +#define ROUTER_PURPOSE_CONTROLLER 1 +/** Tor should use this router only for bridge positions in circuits: we got + * it via a directory request from the bridge itself, or a bridge + * authority. */ +#define ROUTER_PURPOSE_BRIDGE 2 +/** Tor should not use this router; it was marked in cached-descriptors with + * a purpose we didn't recognize. */ +#define ROUTER_PURPOSE_UNKNOWN 255 + + /** In what way did we find out about this router? One of ROUTER_PURPOSE_*. + * Routers of different purposes are kept segregated and used for different + * things; see notes on ROUTER_PURPOSE_* macros above. + */ + uint8_t purpose; +}; + +#endif + diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 425ad8273f..ad7e4102c2 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -133,6 +133,7 @@ #include "networkstatus_st.h" #include "networkstatus_voter_info_st.h" #include "node_st.h" +#include "routerinfo_st.h" #include "routerlist_st.h" #include "vote_routerstatus_st.h" diff --git a/src/or/routerparse.c b/src/or/routerparse.c index dee4220b6e..040745f651 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -91,6 +91,7 @@ #include "rend_authorized_client_st.h" #include "rend_intro_point_st.h" #include "rend_service_descriptor_st.h" +#include "routerinfo_st.h" #include "routerlist_st.h" #include "tor_version_st.h" #include "vote_microdesc_hash_st.h" diff --git a/src/or/routerset.c b/src/or/routerset.c index 1033702f39..415fa0ce7c 100644 --- a/src/or/routerset.c +++ b/src/or/routerset.c @@ -37,6 +37,7 @@ #include "routerset.h" #include "node_st.h" +#include "routerinfo_st.h" #include "routerstatus_st.h" /** Return a new empty routerset. */ diff --git a/src/or/status.c b/src/or/status.c index 4b8033d114..2cfc436794 100644 --- a/src/or/status.c +++ b/src/or/status.c @@ -30,6 +30,8 @@ #include "hs_service.h" #include "dos.h" +#include "routerinfo_st.h" + static void log_accounting(const time_t now, const or_options_t *options); #include "geoip.h" diff --git a/src/test/test_address_set.c b/src/test/test_address_set.c index efc4d4e8ab..93469573ff 100644 --- a/src/test/test_address_set.c +++ b/src/test/test_address_set.c @@ -12,6 +12,7 @@ #include "microdesc_st.h" #include "networkstatus_st.h" +#include "routerinfo_st.h" #include "routerstatus_st.h" #include "test.h" diff --git a/src/test/test_config.c b/src/test/test_config.c index 2b761d2bae..ea0f45f22e 100644 --- a/src/test/test_config.c +++ b/src/test/test_config.c @@ -46,6 +46,7 @@ #include "dir_server_st.h" #include "port_cfg_st.h" +#include "routerinfo_st.h" static void test_config_addressmap(void *arg) diff --git a/src/test/test_connection.c b/src/test/test_connection.c index 6f9c2706c2..5d2aa65c80 100644 --- a/src/test/test_connection.c +++ b/src/test/test_connection.c @@ -28,6 +28,7 @@ #include "entry_connection_st.h" #include "node_st.h" #include "or_connection_st.h" +#include "routerinfo_st.h" #include "socks_request_st.h" static void * test_conn_get_basic_setup(const struct testcase_t *tc); diff --git a/src/test/test_dir.c b/src/test/test_dir.c index c25665d3e3..ac5b3bd7c2 100644 --- a/src/test/test_dir.c +++ b/src/test/test_dir.c @@ -52,6 +52,7 @@ #include "networkstatus_voter_info_st.h" #include "ns_detached_signatures_st.h" #include "port_cfg_st.h" +#include "routerinfo_st.h" #include "routerlist_st.h" #include "tor_version_st.h" #include "vote_microdesc_hash_st.h" diff --git a/src/test/test_dir_common.c b/src/test/test_dir_common.c index c23282ba85..3ec9fd6910 100644 --- a/src/test/test_dir_common.c +++ b/src/test/test_dir_common.c @@ -17,6 +17,7 @@ #include "authority_cert_st.h" #include "networkstatus_st.h" #include "networkstatus_voter_info_st.h" +#include "routerinfo_st.h" #include "vote_microdesc_hash_st.h" #include "vote_routerstatus_st.h" diff --git a/src/test/test_dir_handle_get.c b/src/test/test_dir_handle_get.c index c8704505e9..3babffb9ee 100644 --- a/src/test/test_dir_handle_get.c +++ b/src/test/test_dir_handle_get.c @@ -38,6 +38,7 @@ #include "dir_server_st.h" #include "networkstatus_st.h" #include "rend_encoded_v2_service_descriptor_st.h" +#include "routerinfo_st.h" #include "routerlist_st.h" #ifdef _WIN32 diff --git a/src/test/test_entrynodes.c b/src/test/test_entrynodes.c index 6a93921f90..bc075e91ab 100644 --- a/src/test/test_entrynodes.c +++ b/src/test/test_entrynodes.c @@ -37,6 +37,7 @@ #include "networkstatus_st.h" #include "node_st.h" #include "origin_circuit_st.h" +#include "routerinfo_st.h" #include "routerstatus_st.h" #include "test_helpers.h" diff --git a/src/test/test_hs.c b/src/test/test_hs.c index c546af2fe9..f2c520aeec 100644 --- a/src/test/test_hs.c +++ b/src/test/test_hs.c @@ -25,6 +25,7 @@ #include "node_st.h" #include "rend_encoded_v2_service_descriptor_st.h" #include "rend_intro_point_st.h" +#include "routerinfo_st.h" #include "test_helpers.h" diff --git a/src/test/test_hs_common.c b/src/test/test_hs_common.c index 342626bcc1..b4969fa7b0 100644 --- a/src/test/test_hs_common.c +++ b/src/test/test_hs_common.c @@ -36,6 +36,7 @@ #include "microdesc_st.h" #include "networkstatus_st.h" #include "node_st.h" +#include "routerinfo_st.h" #include "routerstatus_st.h" /** Test the validation of HS v3 addresses */ diff --git a/src/test/test_hs_service.c b/src/test/test_hs_service.c index ab27b4dc4e..a4a1449b4d 100644 --- a/src/test/test_hs_service.c +++ b/src/test/test_hs_service.c @@ -58,6 +58,7 @@ #include "networkstatus_st.h" #include "node_st.h" #include "origin_circuit_st.h" +#include "routerinfo_st.h" /* Trunnel */ #include "hs/cell_establish_intro.h" diff --git a/src/test/test_microdesc.c b/src/test/test_microdesc.c index 5930893353..28d3494663 100644 --- a/src/test/test_microdesc.c +++ b/src/test/test_microdesc.c @@ -15,6 +15,7 @@ #include "microdesc_st.h" #include "networkstatus_st.h" +#include "routerinfo_st.h" #include "routerstatus_st.h" #include "test.h" diff --git a/src/test/test_nodelist.c b/src/test/test_nodelist.c index e41557ed35..df69466fbb 100644 --- a/src/test/test_nodelist.c +++ b/src/test/test_nodelist.c @@ -15,6 +15,7 @@ #include "microdesc_st.h" #include "networkstatus_st.h" #include "node_st.h" +#include "routerinfo_st.h" #include "routerstatus_st.h" #include "test.h" diff --git a/src/test/test_policy.c b/src/test/test_policy.c index 71c6230702..61ebd27dc9 100644 --- a/src/test/test_policy.c +++ b/src/test/test_policy.c @@ -12,6 +12,7 @@ #include "node_st.h" #include "port_cfg_st.h" +#include "routerinfo_st.h" #include "routerstatus_st.h" /* Helper: assert that short_policy parses and writes back out as itself, diff --git a/src/test/test_rendcache.c b/src/test/test_rendcache.c index e5d5316179..22af3473ba 100644 --- a/src/test/test_rendcache.c +++ b/src/test/test_rendcache.c @@ -15,6 +15,7 @@ #include "rend_encoded_v2_service_descriptor_st.h" #include "rend_intro_point_st.h" #include "rend_service_descriptor_st.h" +#include "routerinfo_st.h" #include "rend_test_helpers.h" #include "log_test_helpers.h" diff --git a/src/test/test_router.c b/src/test/test_router.c index 4e96e24534..d560a1aecf 100644 --- a/src/test/test_router.c +++ b/src/test/test_router.c @@ -14,6 +14,8 @@ #include "router.h" #include "routerlist.h" +#include "routerinfo_st.h" + /* Test suite stuff */ #include "test.h" diff --git a/src/test/test_routerset.c b/src/test/test_routerset.c index 21db9bb3ba..004b88ac83 100644 --- a/src/test/test_routerset.c +++ b/src/test/test_routerset.c @@ -11,6 +11,7 @@ #include "nodelist.h" #include "node_st.h" +#include "routerinfo_st.h" #include "routerstatus_st.h" #include "test.h" diff --git a/src/test/test_status.c b/src/test/test_status.c index 062a28f730..cedce16765 100644 --- a/src/test/test_status.c +++ b/src/test/test_status.c @@ -26,6 +26,7 @@ #include "statefile.h" #include "origin_circuit_st.h" +#include "routerinfo_st.h" #include "test.h" -- cgit v1.2.3-54-g00ecf