mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 04:13:28 +01:00
Hiding crypt_path_t: Move assert functions in crypt_path.c.
This commit only moves code, and makes one function public.
This commit is contained in:
parent
c3a5e6b436
commit
9584798e57
@ -39,6 +39,7 @@ LIBTOR_APP_A_SOURCES = \
|
||||
src/core/or/circuitpadding.c \
|
||||
src/core/or/circuitstats.c \
|
||||
src/core/or/circuituse.c \
|
||||
src/core/or/crypt_path.c \
|
||||
src/core/or/command.c \
|
||||
src/core/or/connection_edge.c \
|
||||
src/core/or/connection_or.c \
|
||||
@ -247,6 +248,7 @@ noinst_HEADERS += \
|
||||
src/core/or/connection_edge.h \
|
||||
src/core/or/connection_or.h \
|
||||
src/core/or/connection_st.h \
|
||||
src/core/or/crypt_path.h \
|
||||
src/core/or/cpath_build_state_st.h \
|
||||
src/core/or/crypt_path_reference_st.h \
|
||||
src/core/or/crypt_path_st.h \
|
||||
|
@ -82,6 +82,7 @@
|
||||
#include "core/or/policies.h"
|
||||
#include "core/or/reasons.h"
|
||||
#include "core/or/relay.h"
|
||||
#include "core/or/crypt_path.h"
|
||||
#include "core/proto/proto_http.h"
|
||||
#include "core/proto/proto_socks.h"
|
||||
#include "feature/client/dnsserv.h"
|
||||
|
@ -63,6 +63,7 @@
|
||||
#include "core/or/circuituse.h"
|
||||
#include "core/or/circuitstats.h"
|
||||
#include "core/or/circuitpadding.h"
|
||||
#include "core/or/crypt_path.h"
|
||||
#include "core/mainloop/connection.h"
|
||||
#include "app/config/config.h"
|
||||
#include "core/or/connection_edge.h"
|
||||
@ -2785,59 +2786,6 @@ circuits_handle_oom(size_t current_allocation)
|
||||
n_dirconns_killed);
|
||||
}
|
||||
|
||||
/** Verify that cpath layer <b>cp</b> has all of its invariants
|
||||
* correct. Trigger an assert if anything is invalid.
|
||||
*/
|
||||
void
|
||||
assert_cpath_layer_ok(const crypt_path_t *cp)
|
||||
{
|
||||
// tor_assert(cp->addr); /* these are zero for rendezvous extra-hops */
|
||||
// tor_assert(cp->port);
|
||||
tor_assert(cp);
|
||||
tor_assert(cp->magic == CRYPT_PATH_MAGIC);
|
||||
switch (cp->state)
|
||||
{
|
||||
case CPATH_STATE_OPEN:
|
||||
relay_crypto_assert_ok(&cp->crypto);
|
||||
/* fall through */
|
||||
case CPATH_STATE_CLOSED:
|
||||
/*XXXX Assert that there's no handshake_state either. */
|
||||
tor_assert(!cp->rend_dh_handshake_state);
|
||||
break;
|
||||
case CPATH_STATE_AWAITING_KEYS:
|
||||
/* tor_assert(cp->dh_handshake_state); */
|
||||
break;
|
||||
default:
|
||||
log_fn(LOG_ERR, LD_BUG, "Unexpected state %d", cp->state);
|
||||
tor_assert(0);
|
||||
}
|
||||
tor_assert(cp->package_window >= 0);
|
||||
tor_assert(cp->deliver_window >= 0);
|
||||
}
|
||||
|
||||
/** Verify that cpath <b>cp</b> has all of its invariants
|
||||
* correct. Trigger an assert if anything is invalid.
|
||||
*/
|
||||
static void
|
||||
assert_cpath_ok(const crypt_path_t *cp)
|
||||
{
|
||||
const crypt_path_t *start = cp;
|
||||
|
||||
do {
|
||||
assert_cpath_layer_ok(cp);
|
||||
/* layers must be in sequence of: "open* awaiting? closed*" */
|
||||
if (cp != start) {
|
||||
if (cp->state == CPATH_STATE_AWAITING_KEYS) {
|
||||
tor_assert(cp->prev->state == CPATH_STATE_OPEN);
|
||||
} else if (cp->state == CPATH_STATE_OPEN) {
|
||||
tor_assert(cp->prev->state == CPATH_STATE_OPEN);
|
||||
}
|
||||
}
|
||||
cp = cp->next;
|
||||
tor_assert(cp);
|
||||
} while (cp != start);
|
||||
}
|
||||
|
||||
/** Verify that circuit <b>c</b> has all of its invariants
|
||||
* correct. Trigger an assert if anything is invalid.
|
||||
*/
|
||||
|
@ -228,7 +228,6 @@ int circuit_count_pending_on_channel(channel_t *chan);
|
||||
#define circuit_mark_for_close(c, reason) \
|
||||
circuit_mark_for_close_((c), (reason), __LINE__, SHORT_FILE__)
|
||||
|
||||
void assert_cpath_layer_ok(const crypt_path_t *cp);
|
||||
MOCK_DECL(void, assert_circuit_ok,(const circuit_t *c));
|
||||
void circuit_free_all(void);
|
||||
void circuits_handle_oom(size_t current_allocation);
|
||||
|
74
src/core/or/crypt_path.c
Normal file
74
src/core/or/crypt_path.c
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2019, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
* \file crypt_path.c
|
||||
*
|
||||
* \brief Functions dealing with layered circuit encryption. This file aims to
|
||||
* provide an API around the crypt_path_t structure which holds crypto
|
||||
* information about a specific hop of a circuit.
|
||||
**/
|
||||
|
||||
#define CRYPT_PATH_PRIVATE
|
||||
|
||||
#include "core/or/or.h"
|
||||
#include "core/or/crypt_path.h"
|
||||
|
||||
#include "core/crypto/relay_crypto.h"
|
||||
|
||||
#include "core/or/crypt_path_st.h"
|
||||
|
||||
/** Verify that cpath <b>cp</b> has all of its invariants
|
||||
* correct. Trigger an assert if anything is invalid.
|
||||
*/
|
||||
void
|
||||
assert_cpath_ok(const crypt_path_t *cp)
|
||||
{
|
||||
const crypt_path_t *start = cp;
|
||||
|
||||
do {
|
||||
assert_cpath_layer_ok(cp);
|
||||
/* layers must be in sequence of: "open* awaiting? closed*" */
|
||||
if (cp != start) {
|
||||
if (cp->state == CPATH_STATE_AWAITING_KEYS) {
|
||||
tor_assert(cp->prev->state == CPATH_STATE_OPEN);
|
||||
} else if (cp->state == CPATH_STATE_OPEN) {
|
||||
tor_assert(cp->prev->state == CPATH_STATE_OPEN);
|
||||
}
|
||||
}
|
||||
cp = cp->next;
|
||||
tor_assert(cp);
|
||||
} while (cp != start);
|
||||
}
|
||||
|
||||
/** Verify that cpath layer <b>cp</b> has all of its invariants
|
||||
* correct. Trigger an assert if anything is invalid.
|
||||
*/
|
||||
void
|
||||
assert_cpath_layer_ok(const crypt_path_t *cp)
|
||||
{
|
||||
// tor_assert(cp->addr); /* these are zero for rendezvous extra-hops */
|
||||
// tor_assert(cp->port);
|
||||
tor_assert(cp);
|
||||
tor_assert(cp->magic == CRYPT_PATH_MAGIC);
|
||||
switch (cp->state)
|
||||
{
|
||||
case CPATH_STATE_OPEN:
|
||||
relay_crypto_assert_ok(&cp->crypto);
|
||||
/* fall through */
|
||||
case CPATH_STATE_CLOSED:
|
||||
/*XXXX Assert that there's no handshake_state either. */
|
||||
tor_assert(!cp->rend_dh_handshake_state);
|
||||
break;
|
||||
case CPATH_STATE_AWAITING_KEYS:
|
||||
/* tor_assert(cp->dh_handshake_state); */
|
||||
break;
|
||||
default:
|
||||
log_fn(LOG_ERR, LD_BUG, "Unexpected state %d", cp->state);
|
||||
tor_assert(0);
|
||||
}
|
||||
tor_assert(cp->package_window >= 0);
|
||||
tor_assert(cp->deliver_window >= 0);
|
||||
}
|
||||
|
11
src/core/or/crypt_path.h
Normal file
11
src/core/or/crypt_path.h
Normal file
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* \file crypt_path.h
|
||||
* \brief Header file for crypt_path.c.
|
||||
**/
|
||||
|
||||
/* rename */
|
||||
void assert_cpath_layer_ok(const crypt_path_t *cp);
|
||||
|
||||
/* rename */
|
||||
void assert_cpath_ok(const crypt_path_t *cp);
|
||||
|
Loading…
Reference in New Issue
Block a user