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

[tor-commits] [tor/master] Hiding crypt_path_t: Move init functions to crypt_path.c.



commit f74a80dc3b2ada940e72cd174af5779cac3c3948
Author: George Kadianakis <desnacked@xxxxxxxxxx>
Date:   Mon Apr 8 13:01:18 2019 +0300

    Hiding crypt_path_t: Move init functions to crypt_path.c.
    
    This commit only moves code.
---
 src/core/or/circuitbuild.c     | 41 +----------------------------------------
 src/core/or/circuitbuild.h     |  1 -
 src/core/or/crypt_path.c       | 41 +++++++++++++++++++++++++++++++++++++++++
 src/core/or/crypt_path.h       |  6 ++++++
 src/feature/hs/hs_circuit.c    |  1 +
 src/feature/rend/rendservice.c |  1 +
 src/test/test_circuitpadding.c |  1 +
 src/test/test_relaycrypt.c     |  2 +-
 8 files changed, 52 insertions(+), 42 deletions(-)

diff --git a/src/core/or/circuitbuild.c b/src/core/or/circuitbuild.c
index cfe0a97bc..7216b813b 100644
--- a/src/core/or/circuitbuild.c
+++ b/src/core/or/circuitbuild.c
@@ -51,6 +51,7 @@
 #include "core/or/ocirc_event.h"
 #include "core/or/policies.h"
 #include "core/or/relay.h"
+#include "core/or/crypt_path.h"
 #include "feature/client/bridges.h"
 #include "feature/client/circpathbias.h"
 #include "feature/client/entrynodes.h"
@@ -91,7 +92,6 @@ static int circuit_deliver_create_cell(circuit_t *circ,
                                        const create_cell_t *create_cell,
                                        int relayed);
 static crypt_path_t *onion_next_hop_in_cpath(crypt_path_t *cpath);
-STATIC int onion_append_hop(crypt_path_t **head_ptr, extend_info_t *choice);
 static int circuit_send_first_onion_skin(origin_circuit_t *circ);
 static int circuit_build_no_more_hops(origin_circuit_t *circ);
 static int circuit_send_intermediate_onion_skin(origin_circuit_t *circ,
@@ -2373,23 +2373,6 @@ count_acceptable_nodes, (const smartlist_t *nodes, int direct))
   return num;
 }
 
-/** Add <b>new_hop</b> to the end of the doubly-linked-list <b>head_ptr</b>.
- * This function is used to extend cpath by another hop.
- */
-void
-onion_append_to_cpath(crypt_path_t **head_ptr, crypt_path_t *new_hop)
-{
-  if (*head_ptr) {
-    new_hop->next = (*head_ptr);
-    new_hop->prev = (*head_ptr)->prev;
-    (*head_ptr)->prev->next = new_hop;
-    (*head_ptr)->prev = new_hop;
-  } else {
-    *head_ptr = new_hop;
-    new_hop->prev = new_hop->next = new_hop;
-  }
-}
-
 #ifdef TOR_UNIT_TESTS
 
 /** Unittest helper function: Count number of hops in cpath linked list. */
@@ -2763,28 +2746,6 @@ onion_extend_cpath(origin_circuit_t *circ)
   return 0;
 }
 
-/** Create a new hop, annotate it with information about its
- * corresponding router <b>choice</b>, and append it to the
- * end of the cpath <b>head_ptr</b>. */
-STATIC int
-onion_append_hop(crypt_path_t **head_ptr, extend_info_t *choice)
-{
-  crypt_path_t *hop = tor_malloc_zero(sizeof(crypt_path_t));
-
-  /* link hop into the cpath, at the end. */
-  onion_append_to_cpath(head_ptr, hop);
-
-  hop->magic = CRYPT_PATH_MAGIC;
-  hop->state = CPATH_STATE_CLOSED;
-
-  hop->extend_info = extend_info_dup(choice);
-
-  hop->package_window = circuit_initial_package_window();
-  hop->deliver_window = CIRCWINDOW_START;
-
-  return 0;
-}
-
 /** Allocate a new extend_info object based on the various arguments. */
 extend_info_t *
 extend_info_new(const char *nickname,
diff --git a/src/core/or/circuitbuild.h b/src/core/or/circuitbuild.h
index b45bc816a..e6f4f4b49 100644
--- a/src/core/or/circuitbuild.h
+++ b/src/core/or/circuitbuild.h
@@ -51,7 +51,6 @@ MOCK_DECL(int, circuit_all_predicted_ports_handled, (time_t now,
 
 int circuit_append_new_exit(origin_circuit_t *circ, extend_info_t *info);
 int circuit_extend_to_new_exit(origin_circuit_t *circ, extend_info_t *info);
-void onion_append_to_cpath(crypt_path_t **head_ptr, crypt_path_t *new_hop);
 extend_info_t *extend_info_new(const char *nickname,
                                const char *rsa_id_digest,
                                const struct ed25519_public_key_t *ed_id,
diff --git a/src/core/or/crypt_path.c b/src/core/or/crypt_path.c
index d4fc59630..ad1255c86 100644
--- a/src/core/or/crypt_path.c
+++ b/src/core/or/crypt_path.c
@@ -16,9 +16,50 @@
 #include "core/or/crypt_path.h"
 
 #include "core/crypto/relay_crypto.h"
+#include "core/or/circuitbuild.h"
+#include "core/or/circuitlist.h"
 
 #include "core/or/crypt_path_st.h"
 
+/** Add <b>new_hop</b> to the end of the doubly-linked-list <b>head_ptr</b>.
+ * This function is used to extend cpath by another hop.
+ */
+void
+onion_append_to_cpath(crypt_path_t **head_ptr, crypt_path_t *new_hop)
+{
+  if (*head_ptr) {
+    new_hop->next = (*head_ptr);
+    new_hop->prev = (*head_ptr)->prev;
+    (*head_ptr)->prev->next = new_hop;
+    (*head_ptr)->prev = new_hop;
+  } else {
+    *head_ptr = new_hop;
+    new_hop->prev = new_hop->next = new_hop;
+  }
+}
+
+/** Create a new hop, annotate it with information about its
+ * corresponding router <b>choice</b>, and append it to the
+ * end of the cpath <b>head_ptr</b>. */
+int
+onion_append_hop(crypt_path_t **head_ptr, extend_info_t *choice)
+{
+  crypt_path_t *hop = tor_malloc_zero(sizeof(crypt_path_t));
+
+  /* link hop into the cpath, at the end. */
+  onion_append_to_cpath(head_ptr, hop);
+
+  hop->magic = CRYPT_PATH_MAGIC;
+  hop->state = CPATH_STATE_CLOSED;
+
+  hop->extend_info = extend_info_dup(choice);
+
+  hop->package_window = circuit_initial_package_window();
+  hop->deliver_window = CIRCWINDOW_START;
+
+  return 0;
+}
+
 /** Verify that cpath <b>cp</b> has all of its invariants
  * correct. Trigger an assert if anything is invalid.
  */
diff --git a/src/core/or/crypt_path.h b/src/core/or/crypt_path.h
index a9b9aae43..7614aaff2 100644
--- a/src/core/or/crypt_path.h
+++ b/src/core/or/crypt_path.h
@@ -9,3 +9,9 @@ void assert_cpath_layer_ok(const crypt_path_t *cp);
 /* rename */
 void assert_cpath_ok(const crypt_path_t *cp);
 
+/* rename */
+int onion_append_hop(crypt_path_t **head_ptr, extend_info_t *choice);
+
+/* rename */
+void onion_append_to_cpath(crypt_path_t **head_ptr, crypt_path_t *new_hop);
+
diff --git a/src/feature/hs/hs_circuit.c b/src/feature/hs/hs_circuit.c
index 253c24d64..a42228d36 100644
--- a/src/feature/hs/hs_circuit.c
+++ b/src/feature/hs/hs_circuit.c
@@ -15,6 +15,7 @@
 #include "core/or/circuituse.h"
 #include "core/or/policies.h"
 #include "core/or/relay.h"
+#include "core/or/crypt_path.h"
 #include "feature/client/circpathbias.h"
 #include "feature/hs/hs_cell.h"
 #include "feature/hs/hs_circuit.h"
diff --git a/src/feature/rend/rendservice.c b/src/feature/rend/rendservice.c
index 996e7b9a2..5c267f8e3 100644
--- a/src/feature/rend/rendservice.c
+++ b/src/feature/rend/rendservice.c
@@ -18,6 +18,7 @@
 #include "core/or/circuituse.h"
 #include "core/or/policies.h"
 #include "core/or/relay.h"
+#include "core/or/crypt_path.h"
 #include "feature/client/circpathbias.h"
 #include "feature/control/control_events.h"
 #include "feature/dirclient/dirclient.h"
diff --git a/src/test/test_circuitpadding.c b/src/test/test_circuitpadding.c
index 3289c866c..e24506d9b 100644
--- a/src/test/test_circuitpadding.c
+++ b/src/test/test_circuitpadding.c
@@ -9,6 +9,7 @@
 #include "core/or/connection_or.h"
 #include "core/or/channel.h"
 #include "core/or/channeltls.h"
+#include "core/or/crypt_path.h"
 #include <event.h>
 #include "lib/evloop/compat_libevent.h"
 #include "lib/time/compat_time.h"
diff --git a/src/test/test_relaycrypt.c b/src/test/test_relaycrypt.c
index fe6889e52..cd58094b1 100644
--- a/src/test/test_relaycrypt.c
+++ b/src/test/test_relaycrypt.c
@@ -10,7 +10,7 @@
 #include "lib/crypt_ops/crypto_rand.h"
 #include "core/or/relay.h"
 #include "core/crypto/relay_crypto.h"
-
+#include "core/or/crypt_path.h"
 #include "core/or/cell_st.h"
 #include "core/or/or_circuit_st.h"
 #include "core/or/origin_circuit_st.h"



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