[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Extract cpath_build_state into its own header.



commit d51de7731107ee6911c0c849260705ba9b1c3673
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Fri Jun 15 12:07:20 2018 -0400

    Extract cpath_build_state into its own header.
    
    More modules use this than I had expected!
---
 src/or/circpathbias.c         |  1 +
 src/or/circuitbuild.c         |  1 +
 src/or/circuitlist.c          |  1 +
 src/or/circuituse.c           |  1 +
 src/or/connection_edge.c      |  1 +
 src/or/control.c              |  1 +
 src/or/cpath_build_state_st.h | 38 ++++++++++++++++++++++++++++++++++++++
 src/or/hs_circuit.c           |  1 +
 src/or/hs_client.c            |  1 +
 src/or/include.am             |  1 +
 src/or/or.h                   | 27 +--------------------------
 src/or/relay.c                |  1 +
 src/or/rendclient.c           |  1 +
 src/or/rendcommon.c           |  1 +
 src/or/rendservice.c          |  1 +
 src/test/test_circuitstats.c  |  1 +
 src/test/test_circuituse.c    |  1 +
 src/test/test_entrynodes.c    |  1 +
 src/test/test_hs_client.c     |  1 +
 src/test/test_hs_service.c    |  1 +
 20 files changed, 57 insertions(+), 26 deletions(-)

diff --git a/src/or/circpathbias.c b/src/or/circpathbias.c
index d1bdaedc3..9ca45df27 100644
--- a/src/or/circpathbias.c
+++ b/src/or/circpathbias.c
@@ -35,6 +35,7 @@
 #include "networkstatus.h"
 #include "relay.h"
 
+#include "cpath_build_state_st.h"
 #include "crypt_path_st.h"
 #include "origin_circuit_st.h"
 
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index c5d1c65f5..0df616a5a 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -65,6 +65,7 @@
 #include "routerset.h"
 #include "transports.h"
 
+#include "cpath_build_state_st.h"
 #include "entry_connection_st.h"
 #include "or_circuit_st.h"
 #include "origin_circuit_st.h"
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index 3f03ae2f4..46974aea4 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -92,6 +92,7 @@
 
 #include "ht.h"
 
+#include "cpath_build_state_st.h"
 #include "crypt_path_reference_st.h"
 #include "dir_connection_st.h"
 #include "edge_connection_st.h"
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index 3a18c3403..626aff7bb 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -57,6 +57,7 @@
 #include "router.h"
 #include "routerlist.h"
 
+#include "cpath_build_state_st.h"
 #include "dir_connection_st.h"
 #include "entry_connection_st.h"
 #include "or_circuit_st.h"
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index b972724a8..27ee0ea27 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -97,6 +97,7 @@
 #include "routerset.h"
 #include "circuitbuild.h"
 
+#include "cpath_build_state_st.h"
 #include "dir_connection_st.h"
 #include "entry_connection_st.h"
 #include "or_circuit_st.h"
diff --git a/src/or/control.c b/src/or/control.c
index 183778801..972462e38 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -82,6 +82,7 @@
 #include "shared_random_client.h"
 
 #include "control_connection_st.h"
+#include "cpath_build_state_st.h"
 #include "entry_connection_st.h"
 #include "or_connection_st.h"
 #include "or_circuit_st.h"
diff --git a/src/or/cpath_build_state_st.h b/src/or/cpath_build_state_st.h
new file mode 100644
index 000000000..504f638db
--- /dev/null
+++ b/src/or/cpath_build_state_st.h
@@ -0,0 +1,38 @@
+/* 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 CIRCUIT_BUILD_STATE_ST_ST_H
+#define CIRCUIT_BUILD_STATE_ST_ST_H
+
+/** Information used to build a circuit. */
+struct cpath_build_state_t {
+  /** Intended length of the final circuit. */
+  int desired_path_len;
+  /** How to extend to the planned exit node. */
+  extend_info_t *chosen_exit;
+  /** Whether every node in the circ must have adequate uptime. */
+  unsigned int need_uptime : 1;
+  /** Whether every node in the circ must have adequate capacity. */
+  unsigned int need_capacity : 1;
+  /** Whether the last hop was picked with exiting in mind. */
+  unsigned int is_internal : 1;
+  /** Did we pick this as a one-hop tunnel (not safe for other streams)?
+   * These are for encrypted dir conns that exit to this router, not
+   * for arbitrary exits from the circuit. */
+  unsigned int onehop_tunnel : 1;
+  /** The crypt_path_t to append after rendezvous: used for rendezvous. */
+  crypt_path_t *pending_final_cpath;
+  /** A ref-counted reference to the crypt_path_t to append after
+   * rendezvous; used on the service side. */
+  crypt_path_reference_t *service_pending_final_cpath_ref;
+  /** How many times has building a circuit for this task failed? */
+  int failure_count;
+  /** At what time should we give up on this task? */
+  time_t expiry_time;
+};
+
+#endif
+
diff --git a/src/or/hs_circuit.c b/src/or/hs_circuit.c
index 56ae4a152..b5ac7184a 100644
--- a/src/or/hs_circuit.c
+++ b/src/or/hs_circuit.c
@@ -33,6 +33,7 @@
 #include "hs/cell_common.h"
 #include "hs/cell_establish_intro.h"
 
+#include "cpath_build_state_st.h"
 #include "crypt_path_st.h"
 #include "origin_circuit_st.h"
 
diff --git a/src/or/hs_client.c b/src/or/hs_client.c
index c4db60e52..18276bfb8 100644
--- a/src/or/hs_client.c
+++ b/src/or/hs_client.c
@@ -35,6 +35,7 @@
 #include "router.h"
 #include "routerset.h"
 
+#include "cpath_build_state_st.h"
 #include "dir_connection_st.h"
 #include "entry_connection_st.h"
 #include "origin_circuit_st.h"
diff --git a/src/or/include.am b/src/or/include.am
index e15b58c38..e38013f02 100644
--- a/src/or/include.am
+++ b/src/or/include.am
@@ -206,6 +206,7 @@ ORHEADERS = \
 	src/or/consdiffmgr.h				\
 	src/or/control_connection_st.h			\
 	src/or/control.h				\
+	src/or/cpath_build_state_st.h			\
 	src/or/crypt_path_st.h				\
 	src/or/crypt_path_reference_st.h		\
 	src/or/cpuworker.h				\
diff --git a/src/or/or.h b/src/or/or.h
index 5c8267cf5..4403aae83 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -2286,32 +2286,7 @@ typedef struct crypt_path_reference_t crypt_path_reference_t;
 
 #define DH_KEY_LEN DH_BYTES
 
-/** Information used to build a circuit. */
-typedef struct {
-  /** Intended length of the final circuit. */
-  int desired_path_len;
-  /** How to extend to the planned exit node. */
-  extend_info_t *chosen_exit;
-  /** Whether every node in the circ must have adequate uptime. */
-  unsigned int need_uptime : 1;
-  /** Whether every node in the circ must have adequate capacity. */
-  unsigned int need_capacity : 1;
-  /** Whether the last hop was picked with exiting in mind. */
-  unsigned int is_internal : 1;
-  /** Did we pick this as a one-hop tunnel (not safe for other streams)?
-   * These are for encrypted dir conns that exit to this router, not
-   * for arbitrary exits from the circuit. */
-  unsigned int onehop_tunnel : 1;
-  /** The crypt_path_t to append after rendezvous: used for rendezvous. */
-  crypt_path_t *pending_final_cpath;
-  /** A ref-counted reference to the crypt_path_t to append after
-   * rendezvous; used on the service side. */
-  crypt_path_reference_t *service_pending_final_cpath_ref;
-  /** How many times has building a circuit for this task failed? */
-  int failure_count;
-  /** At what time should we give up on this task? */
-  time_t expiry_time;
-} cpath_build_state_t;
+typedef struct cpath_build_state_t cpath_build_state_t;
 
 /** "magic" value for an origin_circuit_t */
 #define ORIGIN_CIRCUIT_MAGIC 0x35315243u
diff --git a/src/or/relay.c b/src/or/relay.c
index 55c2abd12..127609a2b 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -82,6 +82,7 @@
 #include "scheduler.h"
 #include "rephist.h"
 
+#include "cpath_build_state_st.h"
 #include "dir_connection_st.h"
 #include "entry_connection_st.h"
 #include "or_circuit_st.h"
diff --git a/src/or/rendclient.c b/src/or/rendclient.c
index 8e621562a..c55f63c33 100644
--- a/src/or/rendclient.c
+++ b/src/or/rendclient.c
@@ -33,6 +33,7 @@
 #include "routerlist.h"
 #include "routerset.h"
 
+#include "cpath_build_state_st.h"
 #include "crypt_path_st.h"
 #include "dir_connection_st.h"
 #include "entry_connection_st.h"
diff --git a/src/or/rendcommon.c b/src/or/rendcommon.c
index 116ca730f..719a1537c 100644
--- a/src/or/rendcommon.c
+++ b/src/or/rendcommon.c
@@ -31,6 +31,7 @@
 #include "routerlist.h"
 #include "routerparse.h"
 
+#include "cpath_build_state_st.h"
 #include "crypt_path_st.h"
 #include "origin_circuit_st.h"
 
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index 20a4288af..ef46ff6ce 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -36,6 +36,7 @@
 #include "routerparse.h"
 #include "routerset.h"
 
+#include "cpath_build_state_st.h"
 #include "crypt_path_st.h"
 #include "crypt_path_reference_st.h"
 #include "edge_connection_st.h"
diff --git a/src/test/test_circuitstats.c b/src/test/test_circuitstats.c
index 8efde6f84..9f6f4626d 100644
--- a/src/test/test_circuitstats.c
+++ b/src/test/test_circuitstats.c
@@ -17,6 +17,7 @@
 #include "circuituse.h"
 #include "channel.h"
 
+#include "cpath_build_state_st.h"
 #include "crypt_path_st.h"
 #include "origin_circuit_st.h"
 
diff --git a/src/test/test_circuituse.c b/src/test/test_circuituse.c
index 7d1b1d9b0..16ae84380 100644
--- a/src/test/test_circuituse.c
+++ b/src/test/test_circuituse.c
@@ -14,6 +14,7 @@
 #include "circuitbuild.h"
 #include "nodelist.h"
 
+#include "cpath_build_state_st.h"
 #include "origin_circuit_st.h"
 
 static void
diff --git a/src/test/test_entrynodes.c b/src/test/test_entrynodes.c
index 83a3ecbfc..bff6a40bd 100644
--- a/src/test/test_entrynodes.c
+++ b/src/test/test_entrynodes.c
@@ -30,6 +30,7 @@
 #include "statefile.h"
 #include "util.h"
 
+#include "cpath_build_state_st.h"
 #include "crypt_path_st.h"
 #include "dir_connection_st.h"
 #include "origin_circuit_st.h"
diff --git a/src/test/test_hs_client.c b/src/test/test_hs_client.c
index 4443bd922..98e95be09 100644
--- a/src/test/test_hs_client.c
+++ b/src/test/test_hs_client.c
@@ -37,6 +37,7 @@
 #include "connection_edge.h"
 #include "networkstatus.h"
 
+#include "cpath_build_state_st.h"
 #include "crypt_path_st.h"
 #include "dir_connection_st.h"
 #include "entry_connection_st.h"
diff --git a/src/test/test_hs_service.c b/src/test/test_hs_service.c
index 947243e67..348778550 100644
--- a/src/test/test_hs_service.c
+++ b/src/test/test_hs_service.c
@@ -53,6 +53,7 @@
 #include "dirauth/shared_random_state.h"
 #include "voting_schedule.h"
 
+#include "cpath_build_state_st.h"
 #include "crypt_path_st.h"
 #include "origin_circuit_st.h"
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits