]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Split dir_connection_t into its own header
authorNick Mathewson <nickm@torproject.org>
Fri, 15 Jun 2018 14:31:21 +0000 (10:31 -0400)
committerNick Mathewson <nickm@torproject.org>
Fri, 15 Jun 2018 14:31:21 +0000 (10:31 -0400)
26 files changed:
src/or/circuitlist.c
src/or/circuituse.c
src/or/connection.c
src/or/connection.h
src/or/connection_edge.c
src/or/dir_connection_st.h [new file with mode: 0644]
src/or/directory.c
src/or/directory.h
src/or/dirserv.c
src/or/hs_client.c
src/or/hs_service.c
src/or/include.am
src/or/networkstatus.c
src/or/or.h
src/or/relay.c
src/or/rendclient.c
src/or/router.c
src/or/routerlist.c
src/test/fuzz/fuzz_http.c
src/test/test_connection.c
src/test/test_dir_handle_get.c
src/test/test_entrynodes.c
src/test/test_hs_cache.c
src/test/test_hs_client.c
src/test/test_oos.c
src/test/test_routerlist.c

index e0ee284283099572472ee168ff4a87ce7f8b6671..1a3f3a2290b4d3379864fcbdcc065a3f22a9ad82 100644 (file)
@@ -67,6 +67,7 @@
 #include "control.h"
 #include "crypto_rand.h"
 #include "crypto_util.h"
+#include "directory.h"
 #include "entrynodes.h"
 #include "main.h"
 #include "hs_circuit.h"
@@ -91,6 +92,7 @@
 
 #include "ht.h"
 
+#include "dir_connection_st.h"
 #include "edge_connection_st.h"
 
 /********* START VARIABLES **********/
index 5494bf94efbcc8e7b9a0d97bb73d660968854983..45eeff433260b9b36f24afc8a0d6f5044e91e887 100644 (file)
@@ -40,6 +40,7 @@
 #include "connection.h"
 #include "connection_edge.h"
 #include "control.h"
+#include "directory.h"
 #include "entrynodes.h"
 #include "hs_common.h"
 #include "hs_client.h"
@@ -56,6 +57,7 @@
 #include "router.h"
 #include "routerlist.h"
 
+#include "dir_connection_st.h"
 #include "entry_connection_st.h"
 
 static void circuit_expire_old_circuits_clientside(void);
index 0042d3e0d0573973f018b38e6412605f396c05e4..8c7341992dc4812d7f4316ece36a5356d98975f3 100644 (file)
 #include <sys/un.h>
 #endif
 
+#include "dir_connection_st.h"
 #include "control_connection_st.h"
 #include "entry_connection_st.h"
 #include "port_cfg_st.h"
@@ -4112,6 +4113,13 @@ connection_write_to_buf_impl_,(const char *string, size_t len,
   connection_write_to_buf_commit(conn, written);
 }
 
+void
+connection_buf_add_compress(const char *string, size_t len,
+                            dir_connection_t *conn, int done)
+{
+  connection_write_to_buf_impl_(string, len, TO_CONN(conn), done ? -1 : 1);
+}
+
 /**
  * Add all bytes from <b>buf</b> to <b>conn</b>'s outbuf, draining them
  * from <b>buf</b>. (If the connection is marked and will soon be closed,
index ad3129c9d8887bb4c0a91eace2abce38666e1a3f..59720ce3b869dedd5bf9c972518860c8dff390c2 100644 (file)
@@ -150,20 +150,13 @@ MOCK_DECL(void, connection_write_to_buf_impl_,
 /* DOCDOC connection_write_to_buf */
 static void connection_buf_add(const char *string, size_t len,
                                     connection_t *conn);
-/* DOCDOC connection_write_to_buf_compress */
-static void connection_buf_add_compress(const char *string, size_t len,
-                                             dir_connection_t *conn, int done);
 static inline void
 connection_buf_add(const char *string, size_t len, connection_t *conn)
 {
   connection_write_to_buf_impl_(string, len, conn, 0);
 }
-static inline void
-connection_buf_add_compress(const char *string, size_t len,
-                                 dir_connection_t *conn, int done)
-{
-  connection_write_to_buf_impl_(string, len, TO_CONN(conn), done ? -1 : 1);
-}
+void connection_buf_add_compress(const char *string, size_t len,
+                                 dir_connection_t *conn, int done);
 void connection_buf_add_buf(connection_t *conn, buf_t *buf);
 
 /* DOCDOC connection_get_inbuf_len */
index 4bd50398bc115d2e022057dc221f6e4996c26313..1ba61609bc2e66f1738a1d9690e6a38dff7647af 100644 (file)
@@ -97,6 +97,7 @@
 #include "routerset.h"
 #include "circuitbuild.h"
 
+#include "dir_connection_st.h"
 #include "entry_connection_st.h"
 
 #ifdef HAVE_LINUX_TYPES_H
diff --git a/src/or/dir_connection_st.h b/src/or/dir_connection_st.h
new file mode 100644 (file)
index 0000000..df1e9b5
--- /dev/null
@@ -0,0 +1,64 @@
+/* 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_CONNECTION_ST_H
+#define DIR_CONNECTION_ST_H
+
+/** Subtype of connection_t for an "directory connection" -- that is, an HTTP
+ * connection to retrieve or serve directory material. */
+struct dir_connection_t {
+  connection_t base_;
+
+ /** Which 'resource' did we ask the directory for? This is typically the part
+  * of the URL string that defines, relative to the directory conn purpose,
+  * what thing we want.  For example, in router descriptor downloads by
+  * descriptor digest, it contains "d/", then one or more +-separated
+  * fingerprints.
+  **/
+  char *requested_resource;
+  unsigned int dirconn_direct:1; /**< Is this dirconn direct, or via Tor? */
+
+  /** If we're fetching descriptors, what router purpose shall we assign
+   * to them? */
+  uint8_t router_purpose;
+
+  /** List of spooled_resource_t for objects that we're spooling. We use
+   * it from back to front. */
+  smartlist_t *spool;
+  /** The compression object doing on-the-fly compression for spooled data. */
+  tor_compress_state_t *compress_state;
+
+  /** What rendezvous service are we querying for? */
+  rend_data_t *rend_data;
+
+  /* Hidden service connection identifier for dir connections: Used by HS
+     client-side code to fetch HS descriptors, and by the service-side code to
+     upload descriptors. */
+  struct hs_ident_dir_conn_t *hs_ident;
+
+  /** If this is a one-hop connection, tracks the state of the directory guard
+   * for this connection (if any). */
+  struct circuit_guard_state_t *guard_state;
+
+  char identity_digest[DIGEST_LEN]; /**< Hash of the public RSA key for
+                                     * the directory server's signing key. */
+
+  /** Unique ID for directory requests; this used to be in connection_t, but
+   * that's going away and being used on channels instead.  The dirserver still
+   * needs this for the incoming side, so it's moved here. */
+  uint64_t dirreq_id;
+
+#ifdef MEASUREMENTS_21206
+  /** Number of RELAY_DATA cells received. */
+  uint32_t data_cells_received;
+
+  /** Number of RELAY_DATA cells sent. */
+  uint32_t data_cells_sent;
+#endif /* defined(MEASUREMENTS_21206) */
+};
+
+#endif
+
index 7321a97fcce27cfca8acc28860f6ba6b8c47aa02..65aaaa38a6deeeec107cc3e1332eeacfc70d66b5 100644 (file)
@@ -53,6 +53,7 @@
 #include "dirauth/mode.h"
 #include "dirauth/shared_random.h"
 
+#include "dir_connection_st.h"
 #include "dir_server_st.h"
 #include "entry_connection_st.h"
 
@@ -154,6 +155,15 @@ static void connection_dir_close_consensus_fetches(
 
 /********* END VARIABLES ************/
 
+/** Convert a connection_t* to a dir_connection_t*; assert if the cast is
+ * invalid. */
+dir_connection_t *
+TO_DIR_CONN(connection_t *c)
+{
+  tor_assert(c->magic == DIR_CONNECTION_MAGIC);
+  return DOWNCAST(dir_connection_t, c);
+}
+
 /** Return false if the directory purpose <b>dir_purpose</b>
  * does not require an anonymous (three-hop) connection.
  *
index 5f5ff7eca64f556f5c3c91d1c14dc228fa64c048..e94c02b6c5088b0e883dbf2ccd86442ba084033b 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "hs_ident.h"
 
+dir_connection_t *TO_DIR_CONN(connection_t *c);
 int directories_have_accepted_server_descriptor(void);
 void directory_post_to_dirservers(uint8_t dir_purpose, uint8_t router_purpose,
                                   dirinfo_type_t type, const char *payload,
index c01234e0b93b96f2975b7186bb52987c4302ae35..f2597aeaede56ea9bbfb9439b89a19649fb1e910 100644 (file)
@@ -36,6 +36,8 @@
 
 #include "dirauth/dirvote.h"
 
+#include "dir_connection_st.h"
+
 /**
  * \file dirserv.c
  * \brief Directory server core implementation. Manages directory
index 8c04026a7a1d945e24de7631caf52e040bb4048c..ff84296d04e84bde85ded7b9bcfc2dd18b5baa07 100644 (file)
@@ -35,6 +35,7 @@
 #include "router.h"
 #include "routerset.h"
 
+#include "dir_connection_st.h"
 #include "entry_connection_st.h"
 
 /* Return a human-readable string for the client fetch status code. */
index 44ee7bb6605983ad98cd2e3e38efaa3c5b56f629..9f12484ebee54b1435a9507e83999b2504813950 100644 (file)
@@ -39,6 +39,7 @@
 #include "hs_service.h"
 #include "hs_stats.h"
 
+#include "dir_connection_st.h"
 #include "edge_connection_st.h"
 
 /* Trunnel */
index cff38d0b60daeacb9c1959143791c8d7074f82e2..5249f683dd49aa16b6a63480d69788d4f994aeed 100644 (file)
@@ -207,6 +207,7 @@ ORHEADERS = \
        src/or/cpuworker.h                              \
        src/or/directory.h                              \
        src/or/dirserv.h                                \
+       src/or/dir_connection_st.h                      \
        src/or/dir_server_st.h                          \
        src/or/dns.h                                    \
        src/or/dns_structs.h                            \
index 3ed6e3d6c9cf394ecebe3092c40bc48c9b96725b..3694da49ddce29471fcb86e85948a7e0f46f3bea 100644 (file)
@@ -74,6 +74,7 @@
 #include "dirauth/mode.h"
 #include "dirauth/shared_random.h"
 
+#include "dir_connection_st.h"
 #include "dir_server_st.h"
 
 /** Most recently received and validated v3 "ns"-flavored consensus network
index 138c5a18d75f997075b23c9b57aadf11e8cc142d..d9e074d4c35e86b33107bca05f8fee18f6dcba5a 100644 (file)
@@ -1640,62 +1640,10 @@ typedef struct or_connection_t {
 } or_connection_t;
 
 typedef struct control_connection_t control_connection_t;
+typedef struct dir_connection_t dir_connection_t;
 typedef struct edge_connection_t edge_connection_t;
 typedef struct entry_connection_t entry_connection_t;
 
-/** Subtype of connection_t for an "directory connection" -- that is, an HTTP
- * connection to retrieve or serve directory material. */
-typedef struct dir_connection_t {
-  connection_t base_;
-
- /** Which 'resource' did we ask the directory for? This is typically the part
-  * of the URL string that defines, relative to the directory conn purpose,
-  * what thing we want.  For example, in router descriptor downloads by
-  * descriptor digest, it contains "d/", then one or more +-separated
-  * fingerprints.
-  **/
-  char *requested_resource;
-  unsigned int dirconn_direct:1; /**< Is this dirconn direct, or via Tor? */
-
-  /** If we're fetching descriptors, what router purpose shall we assign
-   * to them? */
-  uint8_t router_purpose;
-
-  /** List of spooled_resource_t for objects that we're spooling. We use
-   * it from back to front. */
-  smartlist_t *spool;
-  /** The compression object doing on-the-fly compression for spooled data. */
-  tor_compress_state_t *compress_state;
-
-  /** What rendezvous service are we querying for? */
-  rend_data_t *rend_data;
-
-  /* Hidden service connection identifier for dir connections: Used by HS
-     client-side code to fetch HS descriptors, and by the service-side code to
-     upload descriptors. */
-  struct hs_ident_dir_conn_t *hs_ident;
-
-  /** If this is a one-hop connection, tracks the state of the directory guard
-   * for this connection (if any). */
-  struct circuit_guard_state_t *guard_state;
-
-  char identity_digest[DIGEST_LEN]; /**< Hash of the public RSA key for
-                                     * the directory server's signing key. */
-
-  /** Unique ID for directory requests; this used to be in connection_t, but
-   * that's going away and being used on channels instead.  The dirserver still
-   * needs this for the incoming side, so it's moved here. */
-  uint64_t dirreq_id;
-
-#ifdef MEASUREMENTS_21206
-  /** Number of RELAY_DATA cells received. */
-  uint32_t data_cells_received;
-
-  /** Number of RELAY_DATA cells sent. */
-  uint32_t data_cells_sent;
-#endif /* defined(MEASUREMENTS_21206) */
-} dir_connection_t;
-
 /** Cast a connection_t subtype pointer to a connection_t **/
 #define TO_CONN(c) (&(((c)->base_)))
 
@@ -1705,9 +1653,6 @@ typedef struct dir_connection_t {
 /** Convert a connection_t* to an or_connection_t*; assert if the cast is
  * invalid. */
 static or_connection_t *TO_OR_CONN(connection_t *);
-/** Convert a connection_t* to a dir_connection_t*; assert if the cast is
- * invalid. */
-static dir_connection_t *TO_DIR_CONN(connection_t *);
 /** Convert a connection_t* to an listener_connection_t*; assert if the cast is
  * invalid. */
 static listener_connection_t *TO_LISTENER_CONN(connection_t *);
@@ -1717,11 +1662,6 @@ static inline or_connection_t *TO_OR_CONN(connection_t *c)
   tor_assert(c->magic == OR_CONNECTION_MAGIC);
   return DOWNCAST(or_connection_t, c);
 }
-static inline dir_connection_t *TO_DIR_CONN(connection_t *c)
-{
-  tor_assert(c->magic == DIR_CONNECTION_MAGIC);
-  return DOWNCAST(dir_connection_t, c);
-}
 static inline listener_connection_t *TO_LISTENER_CONN(connection_t *c)
 {
   tor_assert(c->magic == LISTENER_CONNECTION_MAGIC);
index 757613e9db40ddf5360bcdade519e7c3c37592a2..dca31498f1f2ddeac00866c5d47b240d24c05512 100644 (file)
@@ -63,6 +63,7 @@
 #include "control.h"
 #include "crypto_rand.h"
 #include "crypto_util.h"
+#include "directory.h"
 #include "geoip.h"
 #include "hs_cache.h"
 #include "main.h"
@@ -81,6 +82,7 @@
 #include "scheduler.h"
 #include "rephist.h"
 
+#include "dir_connection_st.h"
 #include "entry_connection_st.h"
 
 static edge_connection_t *relay_lookup_conn(circuit_t *circ, cell_t *cell,
index c153862e658c91c9b060442be3197724d305515b..c46b8c5656a237de7871a58e1f6fc40e83a2407f 100644 (file)
@@ -33,6 +33,7 @@
 #include "routerlist.h"
 #include "routerset.h"
 
+#include "dir_connection_st.h"
 #include "entry_connection_st.h"
 
 static extend_info_t *rend_client_get_random_intro_impl(
index c361e21a5fc761cf0e0f16a68476745e7da799d7..f1fff6be21851b2f38e8a7b6c968f038f771e7d3 100644 (file)
@@ -39,6 +39,7 @@
 
 #include "dirauth/mode.h"
 
+#include "dir_connection_st.h"
 #include "dir_server_st.h"
 #include "port_cfg_st.h"
 
index 015b1012a80d9dab6f2efdf2aca210b5ffa1660d..970eac8d3f7eb0dcc169f63e06b017be96b5e317 100644 (file)
 #include "dirauth/dirvote.h"
 #include "dirauth/mode.h"
 
+#include "dir_connection_st.h"
 #include "dir_server_st.h"
 
 // #define DEBUG_ROUTERLIST
index 2ffeb60244b2ef4e40cc7f25396d99391f360b86..e93204ea3ed7254cd6511a351c30601b7e3521cb 100644 (file)
@@ -14,6 +14,8 @@
 #include "directory.h"
 #include "torlog.h"
 
+#include "dir_connection_st.h"
+
 #include "fuzzing.h"
 
 static void
index 05c4bb7f1f1f23a96fb194e480b79b26241d8cde..79c5e2dd8f13d95667e8eccfe655e8b1b1d05d92 100644 (file)
@@ -24,6 +24,7 @@
 #include "test_connection.h"
 #include "test_helpers.h"
 
+#include "dir_connection_st.h"
 #include "entry_connection_st.h"
 
 static void * test_conn_get_basic_setup(const struct testcase_t *tc);
index 4338bba657241918ff26a1ba8bb35044e3091b22..188735a5420817c9c1e5ca37fa378f27cc1f40de 100644 (file)
@@ -34,6 +34,7 @@
 #include "log_test_helpers.h"
 #include "voting_schedule.h"
 
+#include "dir_connection_st.h"
 #include "dir_server_st.h"
 
 #ifdef _WIN32
index cfcb88a66e66c696b430a6a4c87ff0ddf4f76929..d4939355d12e191803e7c86a847bf591cfece971 100644 (file)
@@ -30,6 +30,8 @@
 #include "statefile.h"
 #include "util.h"
 
+#include "dir_connection_st.h"
+
 #include "test_helpers.h"
 #include "log_test_helpers.h"
 
index 458ce1a92e87dea20544d2fa572e4d001474df10..b2f892c7f2130bfe3a4410a7c3e7ebb3e89c09ca 100644 (file)
@@ -18,6 +18,8 @@
 #include "connection.h"
 #include "proto_http.h"
 
+#include "dir_connection_st.h"
+
 #include "hs_test_helpers.h"
 #include "test_helpers.h"
 #include "test.h"
index 0828364e83478cd9c49f3a28cd571f78e6a5a52b..0420f70f8420e6a2ed256bfee4baa0ae6e420f91 100644 (file)
@@ -37,6 +37,7 @@
 #include "connection_edge.h"
 #include "networkstatus.h"
 
+#include "dir_connection_st.h"
 #include "entry_connection_st.h"
 
 static int
index e72fcf5de9841068d9e0f3fe9c313af1e604f372..ddad5a08d0cbd0f35943a3ea32339739adfdbbea 100644 (file)
@@ -12,6 +12,8 @@
 #include "main.h"
 #include "test.h"
 
+#include "dir_connection_st.h"
+
 static or_options_t mock_options;
 
 static void
index 701227c1c705c902fe5307f97688e437351aeeec..d66f8933dedce890f67c9e93a49e809b1ecb789e 100644 (file)
@@ -33,6 +33,9 @@
 #include "routerparse.h"
 #include "dirauth/shared_random.h"
 #include "statefile.h"
+
+#include "dir_connection_st.h"
+
 #include "test.h"
 #include "test_dir_common.h"
 #include "log_test_helpers.h"