[tor-commits] [tor/master] Extract desc_store_t and routerlist_t into their own headers.

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


commit b8ae4111e38bc9cf6ac395b78601c150f710936f
Author: Nick Mathewson <nickm at torproject.org>
Date:   Fri Jun 15 14:07:17 2018 -0400

    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(-)

diff --git a/src/or/control.c b/src/or/control.c
index 0afd6cf97..55670e65e 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 000000000..40238f4ce
--- /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 c402bcb79..1f95b985c 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 c4edb94af..d92bc8e1f 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 7dcb72573..396cfea5a 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 0c351f0e4..6f7223b60 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 45a63388f..26b1788a3 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 d6a42bd9d..a8ddcd240 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 0f9318153..102f3125a 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 000000000..6dfecf4d8
--- /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 be6ed00e2..ea1320de7 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 418fd3acd..663c80fb8 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 76f3b13f6..9412f879d 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 2e9eb3b74..c8704505e 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 78d10b261..fc32665a1 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"





More information about the tor-commits mailing list