commit 22e9c647387509b44ff75e232aede360e3f87070 Author: Nick Mathewson nickm@torproject.org Date: Fri Jun 15 12:18:17 2018 -0400
Extract rend_service_descriptor_t into its own header. --- src/or/control.c | 1 + src/or/directory.c | 1 + src/or/include.am | 1 + src/or/or.h | 23 +---------------------- src/or/rend_service_descriptor_st.h | 34 ++++++++++++++++++++++++++++++++++ src/or/rendcache.c | 2 ++ src/or/rendclient.c | 1 + src/or/rendcommon.c | 1 + src/or/rendservice.c | 1 + src/or/routerparse.c | 7 ++++--- src/test/fuzz/fuzz_iptsv2.c | 3 +++ src/test/rend_test_helpers.c | 2 ++ src/test/test.c | 1 + src/test/test_rendcache.c | 3 +++ 14 files changed, 56 insertions(+), 25 deletions(-)
diff --git a/src/or/control.c b/src/or/control.c index 972462e38..401135ca8 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -87,6 +87,7 @@ #include "or_connection_st.h" #include "or_circuit_st.h" #include "origin_circuit_st.h" +#include "rend_service_descriptor_st.h"
#ifndef _WIN32 #include <pwd.h> diff --git a/src/or/directory.c b/src/or/directory.c index 65aaaa38a..720ef975b 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -56,6 +56,7 @@ #include "dir_connection_st.h" #include "dir_server_st.h" #include "entry_connection_st.h" +#include "rend_service_descriptor_st.h"
/** * \file directory.c diff --git a/src/or/include.am b/src/or/include.am index 618ffacd0..883366fc1 100644 --- a/src/or/include.am +++ b/src/or/include.am @@ -279,6 +279,7 @@ ORHEADERS = \ src/or/rendcommon.h \ src/or/rendmid.h \ src/or/rendservice.h \ + src/or/rend_service_descriptor_st.h \ src/or/rephist.h \ src/or/replaycache.h \ src/or/router.h \ diff --git a/src/or/or.h b/src/or/or.h index b67896d2a..e66bad5ab 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -4145,28 +4145,7 @@ typedef struct rend_intro_point_t { unsigned int circuit_established:1; } rend_intro_point_t;
-#define REND_PROTOCOL_VERSION_BITMASK_WIDTH 16 - -/** Information used to connect to a hidden service. Used on both the - * service side and the client side. */ -typedef struct rend_service_descriptor_t { - crypto_pk_t *pk; /**< This service's public key. */ - int version; /**< Version of the descriptor format: 0 or 2. */ - time_t timestamp; /**< Time when the descriptor was generated. */ - /** Bitmask: which introduce/rendezvous protocols are supported? - * (We allow bits '0', '1', '2' and '3' to be set.) */ - unsigned protocols : REND_PROTOCOL_VERSION_BITMASK_WIDTH; - /** List of the service's introduction points. Elements are removed if - * introduction attempts fail. */ - smartlist_t *intro_nodes; - /** Has descriptor been uploaded to all hidden service directories? */ - int all_uploads_performed; - /** List of hidden service directories to which an upload request for - * this descriptor could be sent. Smartlist exists only when at least one - * of the previous upload requests failed (otherwise it's not important - * to know which uploads succeeded and which not). */ - smartlist_t *successful_uploads; -} rend_service_descriptor_t; +typedef struct rend_service_descriptor_t rend_service_descriptor_t;
/********************************* routerlist.c ***************************/
diff --git a/src/or/rend_service_descriptor_st.h b/src/or/rend_service_descriptor_st.h new file mode 100644 index 000000000..bd6d55b6a --- /dev/null +++ b/src/or/rend_service_descriptor_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 REND_SERVICE_DESCRIPTOR_ST_H +#define REND_SERVICE_DESCRIPTOR_ST_H + +#define REND_PROTOCOL_VERSION_BITMASK_WIDTH 16 + +/** Information used to connect to a hidden service. Used on both the + * service side and the client side. */ +struct rend_service_descriptor_t { + crypto_pk_t *pk; /**< This service's public key. */ + int version; /**< Version of the descriptor format: 0 or 2. */ + time_t timestamp; /**< Time when the descriptor was generated. */ + /** Bitmask: which introduce/rendezvous protocols are supported? + * (We allow bits '0', '1', '2' and '3' to be set.) */ + unsigned protocols : REND_PROTOCOL_VERSION_BITMASK_WIDTH; + /** List of the service's introduction points. Elements are removed if + * introduction attempts fail. */ + smartlist_t *intro_nodes; + /** Has descriptor been uploaded to all hidden service directories? */ + int all_uploads_performed; + /** List of hidden service directories to which an upload request for + * this descriptor could be sent. Smartlist exists only when at least one + * of the previous upload requests failed (otherwise it's not important + * to know which uploads succeeded and which not). */ + smartlist_t *successful_uploads; +}; + +#endif + diff --git a/src/or/rendcache.c b/src/or/rendcache.c index d27e1c293..6dd49ee9c 100644 --- a/src/or/rendcache.c +++ b/src/or/rendcache.c @@ -15,6 +15,8 @@ #include "routerparse.h" #include "rendcommon.h"
+#include "rend_service_descriptor_st.h" + /** Map from service id (as generated by rend_get_service_id) to * rend_cache_entry_t. */ STATIC strmap_t *rend_cache = NULL; diff --git a/src/or/rendclient.c b/src/or/rendclient.c index c55f63c33..1d12e1829 100644 --- a/src/or/rendclient.c +++ b/src/or/rendclient.c @@ -38,6 +38,7 @@ #include "dir_connection_st.h" #include "entry_connection_st.h" #include "origin_circuit_st.h" +#include "rend_service_descriptor_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 719a1537c..b2d4b0949 100644 --- a/src/or/rendcommon.c +++ b/src/or/rendcommon.c @@ -34,6 +34,7 @@ #include "cpath_build_state_st.h" #include "crypt_path_st.h" #include "origin_circuit_st.h" +#include "rend_service_descriptor_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 ef46ff6ce..e27e8c4fb 100644 --- a/src/or/rendservice.c +++ b/src/or/rendservice.c @@ -41,6 +41,7 @@ #include "crypt_path_reference_st.h" #include "edge_connection_st.h" #include "origin_circuit_st.h" +#include "rend_service_descriptor_st.h"
struct rend_service_t; static origin_circuit_t *find_intro_circuit(rend_intro_point_t *intro, diff --git a/src/or/routerparse.c b/src/or/routerparse.c index 06a37904d..af11bc3d5 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -79,13 +79,14 @@ #include "torcert.h" #include "voting_schedule.h"
-#undef log -#include <math.h> - #include "dirauth/dirvote.h"
+#include "rend_service_descriptor_st.h" #include "tor_version_st.h"
+#undef log +#include <math.h> + /****************************************************************************/
/** List of tokens recognized in router descriptors */ diff --git a/src/test/fuzz/fuzz_iptsv2.c b/src/test/fuzz/fuzz_iptsv2.c index 4abde0c16..db99f62dc 100644 --- a/src/test/fuzz/fuzz_iptsv2.c +++ b/src/test/fuzz/fuzz_iptsv2.c @@ -4,6 +4,9 @@ #include "or.h" #include "routerparse.h" #include "rendcommon.h" + +#include "rend_service_descriptor_st.h" + #include "fuzzing.h"
static void diff --git a/src/test/rend_test_helpers.c b/src/test/rend_test_helpers.c index 9ac3894b0..177935edf 100644 --- a/src/test/rend_test_helpers.c +++ b/src/test/rend_test_helpers.c @@ -7,6 +7,8 @@ #include "rendcommon.h" #include "rend_test_helpers.h"
+#include "rend_service_descriptor_st.h" + void generate_desc(int time_diff, rend_encoded_v2_service_descriptor_t **desc, char **service_id, int intro_points) diff --git a/src/test/test.c b/src/test/test.c index b92dd3c8a..040861560 100644 --- a/src/test/test.c +++ b/src/test/test.c @@ -63,6 +63,7 @@ double fabs(double x); #include "crypto_curve25519.h"
#include "or_circuit_st.h" +#include "rend_service_descriptor_st.h"
/** Run unit tests for the onion handshake code. */ static void diff --git a/src/test/test_rendcache.c b/src/test/test_rendcache.c index 9f6cfc4a2..f1e94eb02 100644 --- a/src/test/test_rendcache.c +++ b/src/test/test_rendcache.c @@ -11,6 +11,9 @@ #include "routerlist.h" #include "config.h" #include "hs_common.h" + +#include "rend_service_descriptor_st.h" + #include "rend_test_helpers.h" #include "log_test_helpers.h"