extendinfo.c File Reference

Functions for creating and using extend_info_t objects. More...

#include "core/or/or.h"
#include "core/or/extendinfo.h"
#include "app/config/config.h"
#include "core/or/policies.h"
#include "feature/nodelist/describe.h"
#include "feature/nodelist/nodelist.h"
#include "feature/relay/router.h"
#include "feature/relay/routermode.h"
#include "lib/crypt_ops/crypto_rand.h"
#include "core/or/extend_info_st.h"
#include "feature/nodelist/node_st.h"
#include "feature/nodelist/routerinfo_st.h"
#include "feature/nodelist/routerstatus_st.h"

Go to the source code of this file.


extend_info_textend_info_new (const char *nickname, const char *rsa_id_digest, const ed25519_public_key_t *ed_id, crypto_pk_t *onion_key, const curve25519_public_key_t *ntor_key, const tor_addr_t *addr, uint16_t port)
int extend_info_add_orport (extend_info_t *ei, const tor_addr_t *addr, uint16_t port)
extend_info_textend_info_from_node (const node_t *node, int for_direct_connect)
void extend_info_free_ (extend_info_t *info)
extend_info_textend_info_dup (extend_info_t *info)
int extend_info_supports_tap (const extend_info_t *ei)
int extend_info_supports_ntor (const extend_info_t *ei)
int extend_info_has_preferred_onion_key (const extend_info_t *ei)
int extend_info_addr_is_allowed (const tor_addr_t *addr)
bool extend_info_has_orport (const extend_info_t *ei, const tor_addr_t *addr, uint16_t port)
const tor_addr_port_textend_info_get_orport (const extend_info_t *ei, int family)
const tor_addr_port_textend_info_pick_orport (const extend_info_t *ei)
bool extend_info_any_orport_addr_is_internal (const extend_info_t *ei)

Detailed Description

Functions for creating and using extend_info_t objects.

An extend_info_t is the information we hold about a relay in order to extend a circuit to it.

Definition in file extendinfo.c.

Function Documentation

◆ extend_info_add_orport()

int extend_info_add_orport ( extend_info_t ei,
const tor_addr_t addr,
uint16_t  port 

Add another address:port pair to a given extend_info_t, if there is room. Return 0 on success, -1 on failure.

Definition at line 67 of file extendinfo.c.

◆ extend_info_addr_is_allowed()

int extend_info_addr_is_allowed ( const tor_addr_t addr)

Return true iff the given address can be used to extend to.

Definition at line 224 of file extendinfo.c.

◆ extend_info_any_orport_addr_is_internal()

bool extend_info_any_orport_addr_is_internal ( const extend_info_t ei)

Return true if any orport address in ei is an internal address.

Definition at line 318 of file extendinfo.c.

Referenced by circuit_handle_first_hop().

◆ extend_info_dup()

extend_info_t* extend_info_dup ( extend_info_t info)

Allocate and return a new extend_info_t with the same contents as info.

Definition at line 180 of file extendinfo.c.

◆ extend_info_free_()

void extend_info_free_ ( extend_info_t info)

Release storage held by an extend_info_t struct.

Definition at line 169 of file extendinfo.c.

◆ extend_info_from_node()

extend_info_t* extend_info_from_node ( const node_t node,
int  for_direct_connect 

Allocate and return a new extend_info that can be used to build a circuit to or through the node node. Use the primary address of the node (i.e. its IPv4 address) unless for_direct_connect is true, in which case the preferred address is used instead. May return NULL if there is not enough info about node to extend to it–for example, if the preferred routerinfo_t or microdesc_t is missing, or if for_direct_connect is true and none of the node's addresses is allowed by tor's firewall and IP version config.

Definition at line 92 of file extendinfo.c.

Referenced by get_extend_info_from_intro_point().

◆ extend_info_get_orport()

const tor_addr_port_t* extend_info_get_orport ( const extend_info_t ei,
int  family 

If the extend_info ei has an orport of the chosen family, then return that orport. Otherwise, return NULL.

Definition at line 263 of file extendinfo.c.

Referenced by extend_info_describe(), and router_do_orport_reachability_checks().

◆ extend_info_has_orport()

bool extend_info_has_orport ( const extend_info_t ei,
const tor_addr_t addr,
uint16_t  port 

Return true if addr : port is a listed ORPort in ei.

Definition at line 243 of file extendinfo.c.

Referenced by connection_ap_fail_onehop().

◆ extend_info_new()

extend_info_t* extend_info_new ( const char *  nickname,
const char *  rsa_id_digest,
const ed25519_public_key_t ed_id,
crypto_pk_t onion_key,
const curve25519_public_key_t ntor_key,
const tor_addr_t addr,
uint16_t  port 

Allocate a new extend_info object based on the various arguments.

Definition at line 33 of file extendinfo.c.

◆ extend_info_pick_orport()

const tor_addr_port_t* extend_info_pick_orport ( const extend_info_t ei)

Chose an addr_port_t within ei to connect to.

Definition at line 278 of file extendinfo.c.

Referenced by channel_connect_for_circuit().