2020-03-17 08:18:40 +01:00
|
|
|
/* Copyright (c) 2001 Matej Pfajfar.
|
|
|
|
* Copyright (c) 2001-2004, Roger Dingledine.
|
|
|
|
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
2021-03-12 17:39:23 +01:00
|
|
|
* Copyright (c) 2007-2021, The Tor Project, Inc. */
|
2020-03-17 08:18:40 +01:00
|
|
|
/* See LICENSE for licensing information */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file circuitbuild_relay.h
|
|
|
|
* @brief Header for feature/relay/circuitbuild_relay.c
|
|
|
|
**/
|
|
|
|
|
|
|
|
#ifndef TOR_FEATURE_RELAY_CIRCUITBUILD_RELAY_H
|
|
|
|
#define TOR_FEATURE_RELAY_CIRCUITBUILD_RELAY_H
|
|
|
|
|
|
|
|
#include "lib/cc/torint.h"
|
2020-03-18 09:07:14 +01:00
|
|
|
#include "lib/log/log.h"
|
|
|
|
|
|
|
|
#include "app/config/config.h"
|
2020-03-17 08:18:40 +01:00
|
|
|
|
|
|
|
struct cell_t;
|
|
|
|
struct created_cell_t;
|
|
|
|
|
|
|
|
struct circuit_t;
|
|
|
|
struct or_circuit_t;
|
2020-04-01 13:37:47 +02:00
|
|
|
struct extend_cell_t;
|
2020-03-17 08:18:40 +01:00
|
|
|
|
2020-03-18 09:07:14 +01:00
|
|
|
/* Log a protocol warning about getting an extend cell on a client. */
|
|
|
|
static inline void
|
|
|
|
circuitbuild_warn_client_extend(void)
|
|
|
|
{
|
|
|
|
log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
|
|
|
|
"Got an extend cell, but running as a client. Closing.");
|
|
|
|
}
|
|
|
|
|
2020-03-17 08:18:40 +01:00
|
|
|
#ifdef HAVE_MODULE_RELAY
|
|
|
|
|
|
|
|
int circuit_extend(struct cell_t *cell, struct circuit_t *circ);
|
|
|
|
|
|
|
|
int onionskin_answer(struct or_circuit_t *circ,
|
|
|
|
const struct created_cell_t *created_cell,
|
|
|
|
const char *keys, size_t keys_len,
|
|
|
|
const uint8_t *rend_circ_nonce);
|
|
|
|
|
2020-03-17 08:43:02 +01:00
|
|
|
#else /* !defined(HAVE_MODULE_RELAY) */
|
2020-03-17 08:18:40 +01:00
|
|
|
|
|
|
|
static inline int
|
|
|
|
circuit_extend(struct cell_t *cell, struct circuit_t *circ)
|
|
|
|
{
|
|
|
|
(void)cell;
|
|
|
|
(void)circ;
|
2020-03-18 09:07:14 +01:00
|
|
|
circuitbuild_warn_client_extend();
|
2020-03-17 08:18:40 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
onionskin_answer(struct or_circuit_t *circ,
|
|
|
|
const struct created_cell_t *created_cell,
|
|
|
|
const char *keys, size_t keys_len,
|
|
|
|
const uint8_t *rend_circ_nonce)
|
|
|
|
{
|
|
|
|
(void)circ;
|
|
|
|
(void)created_cell;
|
|
|
|
(void)keys;
|
|
|
|
(void)keys_len;
|
|
|
|
(void)rend_circ_nonce;
|
|
|
|
tor_assert_nonfatal_unreached();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2020-03-17 08:43:02 +01:00
|
|
|
#endif /* defined(HAVE_MODULE_RELAY) */
|
2020-03-17 08:18:40 +01:00
|
|
|
|
2020-04-01 13:37:47 +02:00
|
|
|
#ifdef TOR_UNIT_TESTS
|
|
|
|
|
|
|
|
STATIC int circuit_extend_state_valid_helper(const struct circuit_t *circ);
|
|
|
|
STATIC int circuit_extend_add_ed25519_helper(struct extend_cell_t *ec);
|
2020-06-10 06:36:54 +02:00
|
|
|
STATIC int circuit_extend_add_ipv4_helper(struct extend_cell_t *ec);
|
|
|
|
STATIC int circuit_extend_add_ipv6_helper(struct extend_cell_t *ec);
|
2020-04-01 13:37:47 +02:00
|
|
|
STATIC int circuit_extend_lspec_valid_helper(const struct extend_cell_t *ec,
|
|
|
|
const struct circuit_t *circ);
|
2020-04-29 12:29:15 +02:00
|
|
|
STATIC const tor_addr_port_t * circuit_choose_ip_ap_for_extend(
|
|
|
|
const tor_addr_port_t *ipv4_ap,
|
|
|
|
const tor_addr_port_t *ipv6_ap);
|
2020-04-01 13:37:47 +02:00
|
|
|
STATIC void circuit_open_connection_for_extend(const struct extend_cell_t *ec,
|
|
|
|
struct circuit_t *circ,
|
|
|
|
int should_launch);
|
|
|
|
|
2020-03-17 08:43:02 +01:00
|
|
|
#endif /* defined(TOR_UNIT_TESTS) */
|
2020-04-01 13:37:47 +02:00
|
|
|
|
2020-03-17 08:18:40 +01:00
|
|
|
#endif /* !defined(TOR_FEATURE_RELAY_CIRCUITBUILD_RELAY_H) */
|