[tor-commits] [tor/master] Extract routerstatus_t into its own header.

nickm at torproject.org nickm at torproject.org
Mon Jun 18 18:18:43 UTC 2018


commit def1f20e1f9e4544eaf2c0e387b240ec52958a9e
Author: Nick Mathewson <nickm at torproject.org>
Date:   Fri Jun 15 14:33:03 2018 -0400

    Extract routerstatus_t into its own header.
---
 src/or/bridges.c               |  1 +
 src/or/circuitbuild.c          |  1 +
 src/or/dir_server_st.h         |  1 +
 src/or/hs_common.c             |  1 +
 src/or/hs_control.c            |  1 +
 src/or/hs_service.c            |  1 +
 src/or/include.am              |  1 +
 src/or/microdesc.c             |  1 +
 src/or/nodelist.c              |  1 +
 src/or/or.h                    | 68 +-----------------------------------
 src/or/policies.c              |  1 +
 src/or/rendclient.c            |  1 +
 src/or/rendcommon.c            |  1 +
 src/or/rendservice.c           |  1 +
 src/or/routerset.c             |  1 +
 src/or/routerstatus_st.h       | 78 ++++++++++++++++++++++++++++++++++++++++++
 src/or/vote_routerstatus_st.h  |  2 ++
 src/test/test_address_set.c    |  1 +
 src/test/test_channel.c        |  1 +
 src/test/test_channelpadding.c |  1 +
 src/test/test_dos.c            |  1 +
 src/test/test_entrynodes.c     |  1 +
 src/test/test_hs_common.c      |  1 +
 src/test/test_hs_control.c     |  1 +
 src/test/test_microdesc.c      |  1 +
 src/test/test_nodelist.c       |  1 +
 src/test/test_policy.c         |  1 +
 src/test/test_routerlist.c     |  1 +
 src/test/test_routerset.c      |  1 +
 29 files changed, 107 insertions(+), 67 deletions(-)

diff --git a/src/or/bridges.c b/src/or/bridges.c
index d5a9d05b4..3108e1495 100644
--- a/src/or/bridges.c
+++ b/src/or/bridges.c
@@ -28,6 +28,7 @@
 #include "transports.h"
 
 #include "node_st.h"
+#include "routerstatus_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
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 42ce1cfda..4944a70ce 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -70,6 +70,7 @@
 #include "node_st.h"
 #include "or_circuit_st.h"
 #include "origin_circuit_st.h"
+#include "routerstatus_st.h"
 
 static channel_t * channel_connect_for_circuit(const tor_addr_t *addr,
                                             uint16_t port,
diff --git a/src/or/dir_server_st.h b/src/or/dir_server_st.h
index d2222c26f..b9d3f1c55 100644
--- a/src/or/dir_server_st.h
+++ b/src/or/dir_server_st.h
@@ -9,6 +9,7 @@
 
 #include "torint.h"
 #include "or.h"
+#include "routerstatus_st.h"
 
 /** Represents information about a single trusted or fallback directory
  * server. */
diff --git a/src/or/hs_common.c b/src/or/hs_common.c
index e5d15a1b1..c63d4330d 100644
--- a/src/or/hs_common.c
+++ b/src/or/hs_common.c
@@ -37,6 +37,7 @@
 #include "networkstatus_st.h"
 #include "node_st.h"
 #include "origin_circuit_st.h"
+#include "routerstatus_st.h"
 
 /* Trunnel */
 #include "ed25519_cert.h"
diff --git a/src/or/hs_control.c b/src/or/hs_control.c
index 4f3dd62c6..3ad7fb151 100644
--- a/src/or/hs_control.c
+++ b/src/or/hs_control.c
@@ -16,6 +16,7 @@
 #include "nodelist.h"
 
 #include "node_st.h"
+#include "routerstatus_st.h"
 
 /* Send on the control port the "HS_DESC REQUESTED [...]" event.
  *
diff --git a/src/or/hs_service.c b/src/or/hs_service.c
index 007c84caf..ef809a69f 100644
--- a/src/or/hs_service.c
+++ b/src/or/hs_service.c
@@ -44,6 +44,7 @@
 #include "networkstatus_st.h"
 #include "node_st.h"
 #include "origin_circuit_st.h"
+#include "routerstatus_st.h"
 
 /* Trunnel */
 #include "ed25519_cert.h"
diff --git a/src/or/include.am b/src/or/include.am
index afacd7772..602b811be 100644
--- a/src/or/include.am
+++ b/src/or/include.am
@@ -301,6 +301,7 @@ ORHEADERS = \
 	src/or/routerkeys.h				\
 	src/or/routerset.h				\
 	src/or/routerparse.h				\
+	src/or/routerstatus_st.h			\
 	src/or/scheduler.h				\
 	src/or/server_port_cfg_st.h			\
 	src/or/shared_random_client.h			\
diff --git a/src/or/microdesc.c b/src/or/microdesc.c
index 208f35b1c..f125cf405 100644
--- a/src/or/microdesc.c
+++ b/src/or/microdesc.c
@@ -24,6 +24,7 @@
 
 #include "networkstatus_st.h"
 #include "node_st.h"
+#include "routerstatus_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
diff --git a/src/or/nodelist.c b/src/or/nodelist.c
index 26b1788a3..b542fd516 100644
--- a/src/or/nodelist.c
+++ b/src/or/nodelist.c
@@ -72,6 +72,7 @@
 #include "networkstatus_st.h"
 #include "node_st.h"
 #include "routerlist_st.h"
+#include "routerstatus_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 d07e594d7..0d564b1e2 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -1694,73 +1694,7 @@ typedef struct {
 } routerinfo_t;
 
 typedef struct extrainfo_t extrainfo_t;
-
-/** Contents of a single router entry in a network status object.
- */
-typedef struct routerstatus_t {
-  time_t published_on; /**< When was this router published? */
-  char nickname[MAX_NICKNAME_LEN+1]; /**< The nickname this router says it
-                                      * has. */
-  char identity_digest[DIGEST_LEN]; /**< Digest of the router's identity
-                                     * key. */
-  /** Digest of the router's most recent descriptor or microdescriptor.
-   * If it's a descriptor, we only use the first DIGEST_LEN bytes. */
-  char descriptor_digest[DIGEST256_LEN];
-  uint32_t addr; /**< IPv4 address for this router, in host order. */
-  uint16_t or_port; /**< IPv4 OR port for this router. */
-  uint16_t dir_port; /**< Directory port for this router. */
-  tor_addr_t ipv6_addr; /**< IPv6 address for this router. */
-  uint16_t ipv6_orport; /**< IPv6 OR port for this router. */
-  unsigned int is_authority:1; /**< True iff this router is an authority. */
-  unsigned int is_exit:1; /**< True iff this router is a good exit. */
-  unsigned int is_stable:1; /**< True iff this router stays up a long time. */
-  unsigned int is_fast:1; /**< True iff this router has good bandwidth. */
-  /** True iff this router is called 'running' in the consensus. We give it
-   * this funny name so that we don't accidentally use this bit as a view of
-   * whether we think the router is *currently* running.  If that's what you
-   * want to know, look at is_running in node_t. */
-  unsigned int is_flagged_running:1;
-  unsigned int is_named:1; /**< True iff "nickname" belongs to this router. */
-  unsigned int is_unnamed:1; /**< True iff "nickname" belongs to another
-                              * router. */
-  unsigned int is_valid:1; /**< True iff this router isn't invalid. */
-  unsigned int is_possible_guard:1; /**< True iff this router would be a good
-                                     * choice as an entry guard. */
-  unsigned int is_bad_exit:1; /**< True iff this node is a bad choice for
-                               * an exit node. */
-  unsigned int is_hs_dir:1; /**< True iff this router is a v2-or-later hidden
-                             * service directory. */
-  unsigned int is_v2_dir:1; /** True iff this router publishes an open DirPort
-                             * or it claims to accept tunnelled dir requests.
-                             */
-
-  unsigned int has_bandwidth:1; /**< The vote/consensus had bw info */
-  unsigned int has_exitsummary:1; /**< The vote/consensus had exit summaries */
-  unsigned int bw_is_unmeasured:1; /**< This is a consensus entry, with
-                                    * the Unmeasured flag set. */
-
-  /** Flags to summarize the protocol versions for this routerstatus_t. */
-  protover_summary_flags_t pv;
-
-  uint32_t bandwidth_kb; /**< Bandwidth (capacity) of the router as reported in
-                       * the vote/consensus, in kilobytes/sec. */
-
-  /** The consensus has guardfraction information for this router. */
-  unsigned int has_guardfraction:1;
-  /** The guardfraction value of this router. */
-  uint32_t guardfraction_percentage;
-
-  char *exitsummary; /**< exit policy summary -
-                      * XXX weasel: this probably should not stay a string. */
-
-  /* ---- The fields below aren't derived from the networkstatus; they
-   * hold local information only. */
-
-  time_t last_dir_503_at; /**< When did this router last tell us that it
-                           * was too busy to serve directory info? */
-  download_status_t dl_status;
-
-} routerstatus_t;
+typedef struct routerstatus_t routerstatus_t;
 
 /** A single entry in a parsed policy summary, describing a range of ports. */
 typedef struct short_policy_entry_t {
diff --git a/src/or/policies.c b/src/or/policies.c
index 78cbcd5cd..0c1e3497e 100644
--- a/src/or/policies.c
+++ b/src/or/policies.c
@@ -33,6 +33,7 @@
 #include "dir_server_st.h"
 #include "node_st.h"
 #include "port_cfg_st.h"
+#include "routerstatus_st.h"
 
 /** Policy that addresses for incoming SOCKS connections must match. */
 static smartlist_t *socks_policy = NULL;
diff --git a/src/or/rendclient.c b/src/or/rendclient.c
index a48f83fa9..323612785 100644
--- a/src/or/rendclient.c
+++ b/src/or/rendclient.c
@@ -40,6 +40,7 @@
 #include "origin_circuit_st.h"
 #include "rend_intro_point_st.h"
 #include "rend_service_descriptor_st.h"
+#include "routerstatus_st.h"
 
 static extend_info_t *rend_client_get_random_intro_impl(
                           const rend_cache_entry_t *rend_query,
diff --git a/src/or/rendcommon.c b/src/or/rendcommon.c
index 694b52db1..904969946 100644
--- a/src/or/rendcommon.c
+++ b/src/or/rendcommon.c
@@ -38,6 +38,7 @@
 #include "rend_encoded_v2_service_descriptor_st.h"
 #include "rend_intro_point_st.h"
 #include "rend_service_descriptor_st.h"
+#include "routerstatus_st.h"
 
 /** Return 0 if one and two are the same service ids, else -1 or 1 */
 int
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index 8552fedd3..170d78147 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -46,6 +46,7 @@
 #include "rend_encoded_v2_service_descriptor_st.h"
 #include "rend_intro_point_st.h"
 #include "rend_service_descriptor_st.h"
+#include "routerstatus_st.h"
 
 struct rend_service_t;
 static origin_circuit_t *find_intro_circuit(rend_intro_point_t *intro,
diff --git a/src/or/routerset.c b/src/or/routerset.c
index 8a6ff3b58..1033702f3 100644
--- a/src/or/routerset.c
+++ b/src/or/routerset.c
@@ -37,6 +37,7 @@
 #include "routerset.h"
 
 #include "node_st.h"
+#include "routerstatus_st.h"
 
 /** Return a new empty routerset. */
 routerset_t *
diff --git a/src/or/routerstatus_st.h b/src/or/routerstatus_st.h
new file mode 100644
index 000000000..9c25e88b6
--- /dev/null
+++ b/src/or/routerstatus_st.h
@@ -0,0 +1,78 @@
+/* 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 ROUTERSTATUS_ST_H
+#define ROUTERSTATUS_ST_H
+
+/** Contents of a single router entry in a network status object.
+ */
+struct routerstatus_t {
+  time_t published_on; /**< When was this router published? */
+  char nickname[MAX_NICKNAME_LEN+1]; /**< The nickname this router says it
+                                      * has. */
+  char identity_digest[DIGEST_LEN]; /**< Digest of the router's identity
+                                     * key. */
+  /** Digest of the router's most recent descriptor or microdescriptor.
+   * If it's a descriptor, we only use the first DIGEST_LEN bytes. */
+  char descriptor_digest[DIGEST256_LEN];
+  uint32_t addr; /**< IPv4 address for this router, in host order. */
+  uint16_t or_port; /**< IPv4 OR port for this router. */
+  uint16_t dir_port; /**< Directory port for this router. */
+  tor_addr_t ipv6_addr; /**< IPv6 address for this router. */
+  uint16_t ipv6_orport; /**< IPv6 OR port for this router. */
+  unsigned int is_authority:1; /**< True iff this router is an authority. */
+  unsigned int is_exit:1; /**< True iff this router is a good exit. */
+  unsigned int is_stable:1; /**< True iff this router stays up a long time. */
+  unsigned int is_fast:1; /**< True iff this router has good bandwidth. */
+  /** True iff this router is called 'running' in the consensus. We give it
+   * this funny name so that we don't accidentally use this bit as a view of
+   * whether we think the router is *currently* running.  If that's what you
+   * want to know, look at is_running in node_t. */
+  unsigned int is_flagged_running:1;
+  unsigned int is_named:1; /**< True iff "nickname" belongs to this router. */
+  unsigned int is_unnamed:1; /**< True iff "nickname" belongs to another
+                              * router. */
+  unsigned int is_valid:1; /**< True iff this router isn't invalid. */
+  unsigned int is_possible_guard:1; /**< True iff this router would be a good
+                                     * choice as an entry guard. */
+  unsigned int is_bad_exit:1; /**< True iff this node is a bad choice for
+                               * an exit node. */
+  unsigned int is_hs_dir:1; /**< True iff this router is a v2-or-later hidden
+                             * service directory. */
+  unsigned int is_v2_dir:1; /** True iff this router publishes an open DirPort
+                             * or it claims to accept tunnelled dir requests.
+                             */
+
+  unsigned int has_bandwidth:1; /**< The vote/consensus had bw info */
+  unsigned int has_exitsummary:1; /**< The vote/consensus had exit summaries */
+  unsigned int bw_is_unmeasured:1; /**< This is a consensus entry, with
+                                    * the Unmeasured flag set. */
+
+  /** Flags to summarize the protocol versions for this routerstatus_t. */
+  protover_summary_flags_t pv;
+
+  uint32_t bandwidth_kb; /**< Bandwidth (capacity) of the router as reported in
+                       * the vote/consensus, in kilobytes/sec. */
+
+  /** The consensus has guardfraction information for this router. */
+  unsigned int has_guardfraction:1;
+  /** The guardfraction value of this router. */
+  uint32_t guardfraction_percentage;
+
+  char *exitsummary; /**< exit policy summary -
+                      * XXX weasel: this probably should not stay a string. */
+
+  /* ---- The fields below aren't derived from the networkstatus; they
+   * hold local information only. */
+
+  time_t last_dir_503_at; /**< When did this router last tell us that it
+                           * was too busy to serve directory info? */
+  download_status_t dl_status;
+
+};
+
+#endif
+
diff --git a/src/or/vote_routerstatus_st.h b/src/or/vote_routerstatus_st.h
index 71c204fad..7ac9a6003 100644
--- a/src/or/vote_routerstatus_st.h
+++ b/src/or/vote_routerstatus_st.h
@@ -7,6 +7,8 @@
 #ifndef VOTE_ROUTERSTATUS_ST_H
 #define VOTE_ROUTERSTATUS_ST_H
 
+#include "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.
diff --git a/src/test/test_address_set.c b/src/test/test_address_set.c
index 441d14927..a704e6fb3 100644
--- a/src/test/test_address_set.c
+++ b/src/test/test_address_set.c
@@ -11,6 +11,7 @@
 #include "torcert.h"
 
 #include "networkstatus_st.h"
+#include "routerstatus_st.h"
 
 #include "test.h"
 
diff --git a/src/test/test_channel.c b/src/test/test_channel.c
index 8177f92a1..fbc964ecc 100644
--- a/src/test/test_channel.c
+++ b/src/test/test_channel.c
@@ -22,6 +22,7 @@
 
 #include "networkstatus_st.h"
 #include "origin_circuit_st.h"
+#include "routerstatus_st.h"
 
 /* Test suite stuff */
 #include "log_test_helpers.h"
diff --git a/src/test/test_channelpadding.c b/src/test/test_channelpadding.c
index 2b4ff59a3..206b57ad1 100644
--- a/src/test/test_channelpadding.c
+++ b/src/test/test_channelpadding.c
@@ -22,6 +22,7 @@
 
 #include "networkstatus_st.h"
 #include "or_connection_st.h"
+#include "routerstatus_st.h"
 
 int channelpadding_get_netflow_inactive_timeout_ms(channel_t *chan);
 int64_t channelpadding_compute_time_until_pad_for_netflow(channel_t *chan);
diff --git a/src/test/test_dos.c b/src/test/test_dos.c
index 714533908..bc77bd8cd 100644
--- a/src/test/test_dos.c
+++ b/src/test/test_dos.c
@@ -18,6 +18,7 @@
 
 #include "networkstatus_st.h"
 #include "or_connection_st.h"
+#include "routerstatus_st.h"
 
 #include "test.h"
 #include "log_test_helpers.h"
diff --git a/src/test/test_entrynodes.c b/src/test/test_entrynodes.c
index 572263773..d16af591d 100644
--- a/src/test/test_entrynodes.c
+++ b/src/test/test_entrynodes.c
@@ -36,6 +36,7 @@
 #include "networkstatus_st.h"
 #include "node_st.h"
 #include "origin_circuit_st.h"
+#include "routerstatus_st.h"
 
 #include "test_helpers.h"
 #include "log_test_helpers.h"
diff --git a/src/test/test_hs_common.c b/src/test/test_hs_common.c
index 1cfa4a240..ea5fb4979 100644
--- a/src/test/test_hs_common.c
+++ b/src/test/test_hs_common.c
@@ -35,6 +35,7 @@
 
 #include "networkstatus_st.h"
 #include "node_st.h"
+#include "routerstatus_st.h"
 
 /** Test the validation of HS v3 addresses */
 static void
diff --git a/src/test/test_hs_control.c b/src/test/test_hs_control.c
index 1fcea44f4..f72037337 100644
--- a/src/test/test_hs_control.c
+++ b/src/test/test_hs_control.c
@@ -17,6 +17,7 @@
 #include "nodelist.h"
 
 #include "node_st.h"
+#include "routerstatus_st.h"
 
 #include "test_helpers.h"
 
diff --git a/src/test/test_microdesc.c b/src/test/test_microdesc.c
index 27fdf4a9d..1fdac0924 100644
--- a/src/test/test_microdesc.c
+++ b/src/test/test_microdesc.c
@@ -14,6 +14,7 @@
 #include "torcert.h"
 
 #include "networkstatus_st.h"
+#include "routerstatus_st.h"
 
 #include "test.h"
 
diff --git a/src/test/test_nodelist.c b/src/test/test_nodelist.c
index 4a876f355..018f109e5 100644
--- a/src/test/test_nodelist.c
+++ b/src/test/test_nodelist.c
@@ -14,6 +14,7 @@
 
 #include "networkstatus_st.h"
 #include "node_st.h"
+#include "routerstatus_st.h"
 
 #include "test.h"
 
diff --git a/src/test/test_policy.c b/src/test/test_policy.c
index 673336eae..71c623070 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 "routerstatus_st.h"
 
 /* Helper: assert that short_policy parses and writes back out as itself,
    or as <b>expected</b> if that's provided. */
diff --git a/src/test/test_routerlist.c b/src/test/test_routerlist.c
index 1c2ba9d67..41f7c09bd 100644
--- a/src/test/test_routerlist.c
+++ b/src/test/test_routerlist.c
@@ -38,6 +38,7 @@
 #include "dir_connection_st.h"
 #include "networkstatus_st.h"
 #include "node_st.h"
+#include "routerstatus_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 0e1ad3fdf..21db9bb3b 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 "routerstatus_st.h"
 
 #include "test.h"
 





More information about the tor-commits mailing list