[tor-commits] [tor/master] Move dir_server_t into its own header.

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


commit 2a574d11ac8747996dcb979b04e38b16c5a0a9de
Author: Nick Mathewson <nickm at torproject.org>
Date:   Thu Jun 14 16:58:01 2018 -0400

    Move dir_server_t into its own header.
---
 src/or/dir_server_st.h         | 54 ++++++++++++++++++++++++++++++++++++++++++
 src/or/dirauth/dirvote.c       |  2 ++
 src/or/directory.c             |  2 ++
 src/or/include.am              |  1 +
 src/or/networkstatus.c         |  2 ++
 src/or/nodelist.c              |  2 ++
 src/or/or.h                    | 40 +------------------------------
 src/or/policies.c              |  1 +
 src/or/router.c                |  1 +
 src/or/routerlist.c            |  2 ++
 src/test/test_config.c         |  2 ++
 src/test/test_dir_handle_get.c |  2 ++
 src/test/test_shared_random.c  |  2 ++
 13 files changed, 74 insertions(+), 39 deletions(-)

diff --git a/src/or/dir_server_st.h b/src/or/dir_server_st.h
new file mode 100644
index 000000000..d2222c26f
--- /dev/null
+++ b/src/or/dir_server_st.h
@@ -0,0 +1,54 @@
+/* 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_SERVER_ST_H
+#define DIR_SERVER_ST_H
+
+#include "torint.h"
+#include "or.h"
+
+/** Represents information about a single trusted or fallback directory
+ * server. */
+typedef struct dir_server_t {
+  char *description;
+  char *nickname;
+  char *address; /**< Hostname. */
+  /* XX/teor - why do we duplicate the address and port fields here and in
+   *           fake_status? Surely we could just use fake_status (#17867). */
+  tor_addr_t ipv6_addr; /**< IPv6 address if present; AF_UNSPEC if not */
+  uint32_t addr; /**< IPv4 address. */
+  uint16_t dir_port; /**< Directory port. */
+  uint16_t or_port; /**< OR port: Used for tunneling connections. */
+  uint16_t ipv6_orport; /**< OR port corresponding to ipv6_addr. */
+  double weight; /** Weight used when selecting this node at random */
+  char digest[DIGEST_LEN]; /**< Digest of identity key. */
+  char v3_identity_digest[DIGEST_LEN]; /**< Digest of v3 (authority only,
+                                        * high-security) identity key. */
+
+  unsigned int is_running:1; /**< True iff we think this server is running. */
+  unsigned int is_authority:1; /**< True iff this is a directory authority
+                                * of some kind. */
+
+  /** True iff this server has accepted the most recent server descriptor
+   * we tried to upload to it. */
+  unsigned int has_accepted_serverdesc:1;
+
+  /** What kind of authority is this? (Bitfield.) */
+  dirinfo_type_t type;
+
+  time_t addr_current_at; /**< When was the document that we derived the
+                           * address information from published? */
+
+  routerstatus_t fake_status; /**< Used when we need to pass this trusted
+                               * dir_server_t to
+                               * directory_request_set_routerstatus.
+                               * as a routerstatus_t.  Not updated by the
+                               * router-status management code!
+                               **/
+} dir_server_t;
+
+#endif
+
diff --git a/src/or/dirauth/dirvote.c b/src/or/dirauth/dirvote.c
index b097b10cf..3a2df5ee6 100644
--- a/src/or/dirauth/dirvote.c
+++ b/src/or/dirauth/dirvote.c
@@ -28,6 +28,8 @@
 #include "dirauth/mode.h"
 #include "dirauth/shared_random_state.h"
 
+#include "dir_server_st.h"
+
 /**
  * \file dirvote.c
  * \brief Functions to compute directory consensus, and schedule voting.
diff --git a/src/or/directory.c b/src/or/directory.c
index c7da80490..a65f1fb14 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -53,6 +53,8 @@
 #include "dirauth/mode.h"
 #include "dirauth/shared_random.h"
 
+#include "dir_server_st.h"
+
 /**
  * \file directory.c
  * \brief Code to send and fetch information from directory authorities and
diff --git a/src/or/include.am b/src/or/include.am
index 1dc6c79ca..b6e8e6daf 100644
--- a/src/or/include.am
+++ b/src/or/include.am
@@ -206,6 +206,7 @@ ORHEADERS = \
 	src/or/cpuworker.h				\
 	src/or/directory.h				\
 	src/or/dirserv.h				\
+	src/or/dir_server_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 998eaf74e..3ed6e3d6c 100644
--- a/src/or/networkstatus.c
+++ b/src/or/networkstatus.c
@@ -74,6 +74,8 @@
 #include "dirauth/mode.h"
 #include "dirauth/shared_random.h"
 
+#include "dir_server_st.h"
+
 /** Most recently received and validated v3 "ns"-flavored consensus network
  * status. */
 STATIC networkstatus_t *current_ns_consensus = NULL;
diff --git a/src/or/nodelist.c b/src/or/nodelist.c
index bc9a79940..4d67904c8 100644
--- a/src/or/nodelist.c
+++ b/src/or/nodelist.c
@@ -68,6 +68,8 @@
 
 #include "dirauth/mode.h"
 
+#include "dir_server_st.h"
+
 static void nodelist_drop_node(node_t *node, int remove_from_ht);
 #define node_free(val) \
   FREE_AND_NULL(node_t, node_free_, (val))
diff --git a/src/or/or.h b/src/or/or.h
index 6c54c2752..bf2efd147 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -5314,45 +5314,7 @@ typedef struct rend_service_descriptor_t {
 
 /********************************* routerlist.c ***************************/
 
-/** Represents information about a single trusted or fallback directory
- * server. */
-typedef struct dir_server_t {
-  char *description;
-  char *nickname;
-  char *address; /**< Hostname. */
-  /* XX/teor - why do we duplicate the address and port fields here and in
-   *           fake_status? Surely we could just use fake_status (#17867). */
-  tor_addr_t ipv6_addr; /**< IPv6 address if present; AF_UNSPEC if not */
-  uint32_t addr; /**< IPv4 address. */
-  uint16_t dir_port; /**< Directory port. */
-  uint16_t or_port; /**< OR port: Used for tunneling connections. */
-  uint16_t ipv6_orport; /**< OR port corresponding to ipv6_addr. */
-  double weight; /** Weight used when selecting this node at random */
-  char digest[DIGEST_LEN]; /**< Digest of identity key. */
-  char v3_identity_digest[DIGEST_LEN]; /**< Digest of v3 (authority only,
-                                        * high-security) identity key. */
-
-  unsigned int is_running:1; /**< True iff we think this server is running. */
-  unsigned int is_authority:1; /**< True iff this is a directory authority
-                                * of some kind. */
-
-  /** True iff this server has accepted the most recent server descriptor
-   * we tried to upload to it. */
-  unsigned int has_accepted_serverdesc:1;
-
-  /** What kind of authority is this? (Bitfield.) */
-  dirinfo_type_t type;
-
-  time_t addr_current_at; /**< When was the document that we derived the
-                           * address information from published? */
-
-  routerstatus_t fake_status; /**< Used when we need to pass this trusted
-                               * dir_server_t to
-                               * directory_request_set_routerstatus.
-                               * as a routerstatus_t.  Not updated by the
-                               * router-status management code!
-                               **/
-} dir_server_t;
+typedef struct dir_server_t dir_server_t;
 
 #define RELAY_REQUIRED_MIN_BANDWIDTH (75*1024)
 #define BRIDGE_REQUIRED_MIN_BANDWIDTH (50*1024)
diff --git a/src/or/policies.c b/src/or/policies.c
index a78e8a1c8..51dc83827 100644
--- a/src/or/policies.c
+++ b/src/or/policies.c
@@ -30,6 +30,7 @@
 #include "geoip.h"
 #include "ht.h"
 
+#include "dir_server_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 9eaef4460..c361e21a5 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -39,6 +39,7 @@
 
 #include "dirauth/mode.h"
 
+#include "dir_server_st.h"
 #include "port_cfg_st.h"
 
 /**
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 8788dc019..015b1012a 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
 
 /****************************************************************************/
diff --git a/src/test/test_config.c b/src/test/test_config.c
index e8bfe9e12..2b761d2ba 100644
--- a/src/test/test_config.c
+++ b/src/test/test_config.c
@@ -43,6 +43,8 @@
 #include "statefile.h"
 
 #include "test_helpers.h"
+
+#include "dir_server_st.h"
 #include "port_cfg_st.h"
 
 static void
diff --git a/src/test/test_dir_handle_get.c b/src/test/test_dir_handle_get.c
index 688d26bdc..4338bba65 100644
--- a/src/test/test_dir_handle_get.c
+++ b/src/test/test_dir_handle_get.c
@@ -34,6 +34,8 @@
 #include "log_test_helpers.h"
 #include "voting_schedule.h"
 
+#include "dir_server_st.h"
+
 #ifdef _WIN32
 /* For mkdir() */
 #include <direct.h>
diff --git a/src/test/test_shared_random.c b/src/test/test_shared_random.c
index f6ab0dfab..baafb9813 100644
--- a/src/test/test_shared_random.c
+++ b/src/test/test_shared_random.c
@@ -22,6 +22,8 @@
 #include "shared_random_client.h"
 #include "voting_schedule.h"
 
+#include "dir_server_st.h"
+
 static authority_cert_t *mock_cert;
 
 static authority_cert_t *





More information about the tor-commits mailing list