Tor 0.4.9.2-alpha-dev
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
protover.h
Go to the documentation of this file.
1/* Copyright (c) 2016-2021, The Tor Project, Inc. */
2/* See LICENSE for licensing information */
3
4/**
5 * \file protover.h
6 * \brief Headers and type declarations for protover.c
7 **/
8
9#ifndef TOR_PROTOVER_H
10#define TOR_PROTOVER_H
11
12#include <stdbool.h>
13#include "lib/cc/torint.h"
15struct smartlist_t;
16
17/** The first version of Tor that included "proto" entries in its
18 * descriptors. Authorities should use this to decide whether to
19 * guess proto lines. */
20/* This is a guess. */
21/// C_RUST_COUPLED: src/rust/protover/protover.rs
22/// `FIRST_TOR_VERSION_TO_ADVERTISE_PROTOCOLS`
23#define FIRST_TOR_VERSION_TO_ADVERTISE_PROTOCOLS "0.2.9.3-alpha"
24
25/** The protover version number that signifies ed25519 link handshake support
26 */
27#define PROTOVER_LINKAUTH_ED25519_HANDSHAKE 3
28
29/** The protover version number that signifies extend2 cell support */
30#define PROTOVER_RELAY_EXTEND2 2
31/** The protover version number where relays can accept IPv6 connections */
32#define PROTOVER_RELAY_ACCEPT_IPV6 2
33/** The protover version number where relays can initiate IPv6 extends */
34#define PROTOVER_RELAY_EXTEND_IPV6 3
35/** The protover version number where relays can consider IPv6 connections
36 * canonical */
37#define PROTOVER_RELAY_CANONICAL_IPV6 3
38/** The protover version number where relays can accept ntorv3 */
39#define PROTOVER_RELAY_NTOR_V3 4
40/** The protover that signals conflux support. */
41#define PROTOVER_CONFLUX_V1 1
42
43/** The protover version number that signifies HSv3 intro point support */
44#define PROTOVER_HS_INTRO_V3 4
45/** The protover version number where intro points support denial of service
46 * resistance */
47#define PROTOVER_HS_INTRO_DOS 5
48
49/** The protover version number that signifies HSv3 rendezvous point support */
50#define PROTOVER_HS_RENDEZVOUS_POINT_V3 2
51
52/** The protover version number that signifies HSDir support for HSv3 */
53#define PROTOVER_HSDIR_V3 2
54
55/** The protover that signals support for HS circuit setup padding machines */
56#define PROTOVER_HS_SETUP_PADDING 2
57
58/** The protover that signals support for congestion control */
59#define PROTOVER_FLOWCTRL_CC 2
60
61/** The protover required for negotiating protovers as part of the circuit
62 * extension handshake. */
63#define PROTOVER_RELAY_NEGOTIATE_SUBPROTO 5
64
65/** The protover required for negotiating protovers as part of the circuit
66 * extension handshake. */
67#define PROTOVER_RELAY_CRYPT_CGO 6
68
69/** List of recognized subprotocols. */
70/// C_RUST_COUPLED: src/rust/protover/ffi.rs `translate_to_rust`
71/// C_RUST_COUPLED: src/rust/protover/protover.rs `Proto`
72typedef enum protocol_type_t {
73 PRT_LINK = 0,
74 PRT_LINKAUTH = 1,
75 PRT_RELAY = 2,
76 PRT_DIRCACHE = 3,
77 PRT_HSDIR = 4,
78 PRT_HSINTRO = 5,
79 PRT_HSREND = 6,
80 PRT_DESC = 7,
81 PRT_MICRODESC = 8,
82 PRT_CONS = 9,
83 PRT_PADDING = 10,
84 PRT_FLOWCTRL = 11,
85 PRT_CONFLUX = 12,
87
88bool protover_list_is_invalid(const char *s);
89const char *protover_get_supported(const protocol_type_t type);
90int protover_all_supported(const char *s, char **missing);
92const char *protover_get_supported_protocols(void);
97
98char *protover_compute_vote(const struct smartlist_t *list_of_proto_strings,
99 int threshold);
100const char *protover_compute_for_old_tor(const char *version);
102 uint32_t version);
105 uint32_t version);
106
107void protover_free_all(void);
108
109#ifdef PROTOVER_PRIVATE
110/** Represents a set of ranges of subprotocols of a given type. */
111typedef struct proto_entry_t {
112 /** The name of the protocol.
113 *
114 * (This needs to handle voting on protocols which
115 * we don't recognize yet, so it's a char* rather than a protocol_type_t.)
116 */
117 char *name;
118 /** Bitmask of supported protocols. Version 'x' is included in this
119 * entry if and only if bit '1<<x' is set here. */
120 uint64_t bitmask;
121} proto_entry_t;
122
123#if defined(TOR_UNIT_TESTS)
124STATIC struct smartlist_t *parse_protocol_list(const char *s);
125STATIC char *encode_protocol_list(const struct smartlist_t *sl);
127STATIC int str_to_protocol_type(const char *s, protocol_type_t *pr_out);
128STATIC void proto_entry_free_(proto_entry_t *entry);
129#endif /* defined(TOR_UNIT_TESTS) */
130
131#define proto_entry_free(entry) \
132 FREE_AND_NULL(proto_entry_t, proto_entry_free_, (entry))
133
134#endif /* defined(PROTOVER_PRIVATE) */
135
136#endif /* !defined(TOR_PROTOVER_H) */
const char * name
Definition: config.c:2471
STATIC char * encode_protocol_list(const smartlist_t *sl)
Definition: protover.c:626
STATIC void proto_entry_free_(proto_entry_t *entry)
Definition: protover.c:90
STATIC const char * protocol_type_to_str(protocol_type_t pr)
Definition: protover.c:73
char * protover_compute_vote(const smartlist_t *list_of_proto_strings, int threshold)
Definition: protover.c:657
STATIC smartlist_t * parse_protocol_list(const char *s)
Definition: protover.c:264
bool protover_list_is_invalid(const char *s)
Definition: protover.c:301
const char * protover_get_recommended_relay_protocols(void)
Definition: protover.c:527
const char * protover_get_required_relay_protocols(void)
Definition: protover.c:544
const char * protover_get_required_client_protocols(void)
Definition: protover.c:536
void protover_free_all(void)
Definition: protover.c:883
int protover_all_supported(const char *s, char **missing)
Definition: protover.c:746
int protover_is_supported_here(protocol_type_t pr, uint32_t ver)
Definition: protover.c:316
const char * protover_get_recommended_client_protocols(void)
Definition: protover.c:518
int protocol_list_supports_protocol(const char *list, protocol_type_t tp, uint32_t version)
Definition: protover.c:330
protocol_type_t
Definition: protover.h:72
int protocol_list_supports_protocol_or_later(const char *list, protocol_type_t tp, uint32_t version)
Definition: protover.c:355
const char * protover_get_supported_protocols(void)
C_RUST_COUPLED: src/rust/protover/protover.rs SUPPORTED_PROTOCOLS
Definition: protover.c:433
const char * protover_compute_for_old_tor(const char *version)
C_RUST_COUPLED: src/rust/protover/protover.rs compute_for_old_tor
Definition: protover.c:845
const char * protover_get_supported(const protocol_type_t type)
Definition: protover.c:407
void ** list
Macros to implement mocking and selective exposure for the test code.
#define STATIC
Definition: testsupport.h:32
Integer definitions used throughout Tor.