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"