Browse Source

Move dir_server_t into its own header.

Nick Mathewson 5 years ago
parent
commit
2a574d11ac

+ 54 - 0
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
+

+ 2 - 0
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.

+ 2 - 0
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

+ 1 - 0
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				\

+ 2 - 0
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;

+ 2 - 0
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))

+ 1 - 39
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)

+ 1 - 0
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. */

+ 1 - 0
src/or/router.c

@@ -39,6 +39,7 @@
 
 #include "dirauth/mode.h"
 
+#include "dir_server_st.h"
 #include "port_cfg_st.h"
 
 /**

+ 2 - 0
src/or/routerlist.c

@@ -125,6 +125,8 @@
 #include "dirauth/dirvote.h"
 #include "dirauth/mode.h"
 
+#include "dir_server_st.h"
+
 // #define DEBUG_ROUTERLIST
 
 /****************************************************************************/

+ 2 - 0
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

+ 2 - 0
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>

+ 2 - 0
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 *