mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Hiding crypt_path_t: Move init functions to crypt_path.c.
This commit only moves code.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user