Tor 0.4.9.2-alpha-dev
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
circuitbuild_relay.h
Go to the documentation of this file.
1/* Copyright (c) 2001 Matej Pfajfar.
2 * Copyright (c) 2001-2004, Roger Dingledine.
3 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4 * Copyright (c) 2007-2021, The Tor Project, Inc. */
5/* See LICENSE for licensing information */
6
7/**
8 * @file circuitbuild_relay.h
9 * @brief Header for feature/relay/circuitbuild_relay.c
10 **/
11
12#ifndef TOR_FEATURE_RELAY_CIRCUITBUILD_RELAY_H
13#define TOR_FEATURE_RELAY_CIRCUITBUILD_RELAY_H
14
15#include "lib/cc/torint.h"
16#include "lib/log/log.h"
18
19#include "app/config/config.h"
20
21struct cell_t;
22struct created_cell_t;
23
24struct circuit_t;
25struct or_circuit_t;
26struct extend_cell_t;
27
28/* Log a protocol warning about getting an extend cell on a client. */
29static inline void
30circuitbuild_warn_client_extend(void)
31{
32 log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
33 "Got an extend cell, but running as a client. Closing.");
34}
35
36#ifdef HAVE_MODULE_RELAY
37
38int circuit_extend(const relay_msg_t *msg, struct circuit_t *circ);
39
40int onionskin_answer(struct or_circuit_t *circ,
41 const struct created_cell_t *created_cell,
42 const char *keys, size_t keys_len,
43 const uint8_t *rend_circ_nonce);
44
45#else /* !defined(HAVE_MODULE_RELAY) */
46
47static inline int
48circuit_extend(const relay_msg_t *msg, struct circuit_t *circ)
49{
50 (void)msg;
51 (void)circ;
52 circuitbuild_warn_client_extend();
53 return -1;
54}
55
56static inline int
58 const struct created_cell_t *created_cell,
59 const char *keys, size_t keys_len,
60 const uint8_t *rend_circ_nonce)
61{
62 (void)circ;
63 (void)created_cell;
64 (void)keys;
65 (void)keys_len;
66 (void)rend_circ_nonce;
68 return -1;
69}
70
71#endif /* defined(HAVE_MODULE_RELAY) */
72
73#ifdef TOR_UNIT_TESTS
74
75STATIC int circuit_extend_state_valid_helper(const struct circuit_t *circ);
76STATIC int circuit_extend_add_ed25519_helper(struct extend_cell_t *ec);
77STATIC int circuit_extend_add_ipv4_helper(struct extend_cell_t *ec);
78STATIC int circuit_extend_add_ipv6_helper(struct extend_cell_t *ec);
79STATIC int circuit_extend_lspec_valid_helper(const struct extend_cell_t *ec,
80 const struct circuit_t *circ);
81STATIC const tor_addr_port_t * circuit_choose_ip_ap_for_extend(
82 const tor_addr_port_t *ipv4_ap,
83 const tor_addr_port_t *ipv6_ap);
84STATIC void circuit_open_connection_for_extend(const struct extend_cell_t *ec,
85 struct circuit_t *circ,
86 int should_launch);
87
88#endif /* defined(TOR_UNIT_TESTS) */
89
90#endif /* !defined(TOR_FEATURE_RELAY_CIRCUITBUILD_RELAY_H) */
int circuit_extend(const relay_msg_t *rmsg, struct circuit_t *circ)
int onionskin_answer(struct or_circuit_t *circ, const created_cell_t *created_cell, const char *keys, size_t keys_len, const uint8_t *rend_circ_nonce)
Header file for config.c.
Headers for log.c.
#define log_fn(severity, domain, args,...)
Definition: log.h:283
#define LD_PROTOCOL
Definition: log.h:72
A relay message which contains a relay command and parameters, if any, that is from a relay cell.
Definition: cell_st.h:17
#define STATIC
Definition: testsupport.h:32
Integer definitions used throughout Tor.
#define tor_assert_nonfatal_unreached()
Definition: util_bug.h:177