tor  master
Macros | Functions
protover.c File Reference

Versioning information for different pieces of the Tor protocol. More...

#include "or.h"
#include "protover.h"
#include "routerparse.h"
Include dependency graph for protover.c:

Macros

#define PROTOVER_PRIVATE
 
#define N_PROTOCOL_NAMES   ARRAY_LENGTH(PROTOCOL_NAMES)
 
#define MAX_PROTOCOL_VERSION   (UINT32_MAX-1)
 

Functions

STATIC const char * protocol_type_to_str (protocol_type_t pr)
 
STATIC int str_to_protocol_type (const char *s, protocol_type_t *pr_out)
 
STATIC void proto_entry_free_ (proto_entry_t *entry)
 
STATIC smartlist_tparse_protocol_list (const char *s)
 
bool protover_contains_long_protocol_names (const char *s)
 
int protover_is_supported_here (protocol_type_t pr, uint32_t ver)
 
int protocol_list_supports_protocol (const char *list, protocol_type_t tp, uint32_t version)
 
int protocol_list_supports_protocol_or_later (const char *list, protocol_type_t tp, uint32_t version)
 
const char * protover_get_supported_protocols (void)
 C_RUST_COUPLED: src/rust/protover/protover.rs SUPPORTED_PROTOCOLS More...
 
STATIC char * encode_protocol_list (const smartlist_t *sl)
 
char * protover_compute_vote (const smartlist_t *list_of_proto_strings, int threshold)
 
int protover_all_supported (const char *s, char **missing_out)
 
const char * protover_compute_for_old_tor (const char *version)
 C_RUST_COUPLED: src/rust/protover/protover.rs compute_for_old_tor More...
 
void protover_free_all (void)
 

Detailed Description

Versioning information for different pieces of the Tor protocol.

Starting in version 0.2.9.3-alpha, Tor places separate version numbers on each of the different components of its protocol. Relays use these numbers to advertise what versions of the protocols they can support, and clients use them to find what they can ask a given relay to do. Authorities vote on the supported protocol versions for each relay, and also vote on the which protocols you should have to support in order to be on the Tor network. All Tor instances use these required/recommended protocol versions to tell what level of support for recent protocols each relay has, and to decide whether they should be running given their current protocols.

The main advantage of these protocol versions numbers over using Tor version numbers is that they allow different implementations of the Tor protocols to develop independently, without having to claim compatibility with specific versions of Tor.

Macro Definition Documentation

◆ MAX_PROTOCOL_VERSION

#define MAX_PROTOCOL_VERSION   (UINT32_MAX-1)

The largest possible protocol version.

Function Documentation

◆ encode_protocol_list()

STATIC char* encode_protocol_list ( const smartlist_t sl)

Given a list of space-separated proto_entry_t items, encode it into a newly allocated space-separated string.

Here is the call graph for this function:

◆ parse_protocol_list()

STATIC smartlist_t* parse_protocol_list ( const char *  s)

Parse the protocol list from s and return it as a smartlist of proto_entry_t

Here is the caller graph for this function:

◆ proto_entry_free_()

STATIC void proto_entry_free_ ( proto_entry_t *  entry)

Release all space held by a single proto_entry_t structure

◆ protocol_list_supports_protocol()

int protocol_list_supports_protocol ( const char *  list,
protocol_type_t  tp,
uint32_t  version 
)

Return true iff "list" encodes a protocol list that includes support for the indicated protocol and version.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ protocol_list_supports_protocol_or_later()

int protocol_list_supports_protocol_or_later ( const char *  list,
protocol_type_t  tp,
uint32_t  version 
)

Return true iff "list" encodes a protocol list that includes support for the indicated protocol and version, or some later version.

Here is the call graph for this function:

◆ protocol_type_to_str()

STATIC const char* protocol_type_to_str ( protocol_type_t  pr)

Given a protocol_type_t, return the corresponding string used in descriptors.

Here is the caller graph for this function:

◆ protover_all_supported()

int protover_all_supported ( const char *  s,
char **  missing_out 
)

Return true if every protocol version described in the string s is one that we support, and false otherwise. If missing_out is provided, set it to the list of protocols we do not support.

NOTE: This is quadratic, but we don't do it much: only a few times per consensus. Checking signatures should be way more expensive than this ever would be.

Here is the call graph for this function:

◆ protover_compute_for_old_tor()

const char* protover_compute_for_old_tor ( const char *  version)

C_RUST_COUPLED: src/rust/protover/protover.rs compute_for_old_tor

Return a string describing the protocols supported by tor version version, or an empty string if we cannot tell.

Note that this is only used to infer protocols for Tor versions that can't declare their own.

Here is the call graph for this function:

◆ protover_compute_vote()

char* protover_compute_vote ( const smartlist_t list_of_proto_strings,
int  threshold 
)

Protocol voting implementation.

Given a list of strings describing protocol versions, return a newly allocated string encoding all of the protocols that are listed by at least threshold of the inputs.

The string is minimal and sorted according to the rules of contract_protocol_list above.

Here is the call graph for this function:

◆ protover_contains_long_protocol_names()

bool protover_contains_long_protocol_names ( const char *  s)

Return true if the unparsed protover in s would contain a protocol name longer than MAX_PROTOCOL_NAME_LENGTH, and false otherwise.

Here is the call graph for this function:

◆ protover_free_all()

void protover_free_all ( void  )

Release all storage held by static fields in protover.c

◆ protover_get_supported_protocols()

const char* protover_get_supported_protocols ( void  )

C_RUST_COUPLED: src/rust/protover/protover.rs SUPPORTED_PROTOCOLS

Return the canonical string containing the list of protocols that we support.

◆ protover_is_supported_here()

int protover_is_supported_here ( protocol_type_t  pr,
uint32_t  ver 
)

Given a protocol type and version number, return true iff we know how to speak that protocol.

◆ str_to_protocol_type()

STATIC int str_to_protocol_type ( const char *  s,
protocol_type_t pr_out 
)

Given a string, find the corresponding protocol type and store it in pr_out. Return 0 on success, -1 on failure.