tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

circuitbuild_relay.h (2984B)


      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"
     17 #include "core/or/relay_msg_st.h"
     18 #include "core/crypto/relay_crypto.h"
     19 
     20 #include "app/config/config.h"
     21 
     22 struct cell_t;
     23 struct created_cell_t;
     24 
     25 struct circuit_t;
     26 struct or_circuit_t;
     27 struct extend_cell_t;
     28 
     29 /* Log a protocol warning about getting an extend cell on a client. */
     30 static inline void
     31 circuitbuild_warn_client_extend(void)
     32 {
     33  log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
     34         "Got an extend cell, but running as a client. Closing.");
     35 }
     36 
     37 #ifdef HAVE_MODULE_RELAY
     38 
     39 int circuit_extend(const relay_msg_t *msg, struct circuit_t *circ);
     40 
     41 int onionskin_answer(struct or_circuit_t *circ,
     42                     const struct created_cell_t *created_cell,
     43                     relay_crypto_alg_t crypto_alg,
     44                     const char *keys, size_t keys_len,
     45                     const uint8_t *rend_circ_nonce);
     46 
     47 #else /* !defined(HAVE_MODULE_RELAY) */
     48 
     49 static inline int
     50 circuit_extend(const relay_msg_t *msg, struct circuit_t *circ)
     51 {
     52  (void)msg;
     53  (void)circ;
     54  circuitbuild_warn_client_extend();
     55  return -1;
     56 }
     57 
     58 static inline int
     59 onionskin_answer(struct or_circuit_t *circ,
     60                 const struct created_cell_t *created_cell,
     61                 relay_crypto_alg_t crypto_alg,
     62                 const char *keys, size_t keys_len,
     63                 const uint8_t *rend_circ_nonce)
     64 {
     65  (void)circ;
     66  (void)created_cell;
     67  (void)crypto_alg;
     68  (void)keys;
     69  (void)keys_len;
     70  (void)rend_circ_nonce;
     71  tor_assert_nonfatal_unreached();
     72  return -1;
     73 }
     74 
     75 #endif /* defined(HAVE_MODULE_RELAY) */
     76 
     77 #ifdef TOR_UNIT_TESTS
     78 
     79 STATIC int circuit_extend_state_valid_helper(const struct circuit_t *circ);
     80 STATIC int circuit_extend_add_ed25519_helper(struct extend_cell_t *ec);
     81 STATIC int circuit_extend_add_ipv4_helper(struct extend_cell_t *ec);
     82 STATIC int circuit_extend_add_ipv6_helper(struct extend_cell_t *ec);
     83 STATIC int circuit_extend_lspec_valid_helper(const struct extend_cell_t *ec,
     84                                             const struct circuit_t *circ);
     85 STATIC const tor_addr_port_t * circuit_choose_ip_ap_for_extend(
     86                                             const tor_addr_port_t *ipv4_ap,
     87                                             const tor_addr_port_t *ipv6_ap);
     88 STATIC void circuit_open_connection_for_extend(const struct extend_cell_t *ec,
     89                                               struct circuit_t *circ,
     90                                               int should_launch);
     91 
     92 #endif /* defined(TOR_UNIT_TESTS) */
     93 
     94 #endif /* !defined(TOR_FEATURE_RELAY_CIRCUITBUILD_RELAY_H) */