tor  0.4.2.0-alpha-dev
protover.h
Go to the documentation of this file.
1 /* Copyright (c) 2016-2019, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
3 
9 #ifndef TOR_PROTOVER_H
10 #define TOR_PROTOVER_H
11 
12 #include <stdbool.h>
13 #include "lib/cc/torint.h"
15 struct smartlist_t;
16 
20 /* This is a guess. */
23 #define FIRST_TOR_VERSION_TO_ADVERTISE_PROTOCOLS "0.2.9.3-alpha"
24 
26 #define PROTOVER_HSDIR_V3 2
27 
28 #define PROTOVER_HS_INTRO_V3 4
29 
30 #define PROTOVER_HS_RENDEZVOUS_POINT_V3 2
31 
33 typedef enum protocol_type_t {
36  PRT_LINK = 0,
37  PRT_LINKAUTH = 1,
38  PRT_RELAY = 2,
39  PRT_DIRCACHE = 3,
40  PRT_HSDIR = 4,
41  PRT_HSINTRO = 5,
42  PRT_HSREND = 6,
43  PRT_DESC = 7,
44  PRT_MICRODESC = 8,
45  PRT_CONS = 9,
46  PRT_PADDING = 10,
47  PRT_FLOWCTRL = 11,
49 
50 bool protover_contains_long_protocol_names(const char *s);
51 int protover_all_supported(const char *s, char **missing);
52 int protover_is_supported_here(protocol_type_t pr, uint32_t ver);
53 const char *protover_get_supported_protocols(void);
54 
55 char *protover_compute_vote(const struct smartlist_t *list_of_proto_strings,
56  int threshold);
57 const char *protover_compute_for_old_tor(const char *version);
59  uint32_t version);
61  protocol_type_t tp,
62  uint32_t version);
63 
64 void protover_free_all(void);
65 
66 #ifdef PROTOVER_PRIVATE
67 
69 typedef struct proto_range_t {
70  uint32_t low;
71  uint32_t high;
72 } proto_range_t;
73 
75 typedef struct proto_entry_t {
81  char *name;
83  struct smartlist_t *ranges;
84 } proto_entry_t;
85 
86 #if !defined(HAVE_RUST) && defined(TOR_UNIT_TESTS)
87 STATIC struct smartlist_t *parse_protocol_list(const char *s);
88 STATIC char *encode_protocol_list(const struct smartlist_t *sl);
89 STATIC const char *protocol_type_to_str(protocol_type_t pr);
90 STATIC int str_to_protocol_type(const char *s, protocol_type_t *pr_out);
91 STATIC void proto_entry_free_(proto_entry_t *entry);
92 #endif /* !defined(HAVE_RUST) && defined(TOR_UNIT_TESTS) */
93 
94 #define proto_entry_free(entry) \
95  FREE_AND_NULL(proto_entry_t, proto_entry_free_, (entry))
96 
97 #endif /* defined(PROTOVER_PRIVATE) */
98 
99 #endif /* !defined(TOR_PROTOVER_H) */
int protover_all_supported(const char *s, char **missing)
Definition: protover.c:748
STATIC smartlist_t * parse_protocol_list(const char *s)
Definition: protover.c:269
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:902
void protover_free_all(void)
Definition: protover.c:940
void ** list
Integer definitions used throughout Tor.
int protocol_list_supports_protocol_or_later(const char *list, protocol_type_t tp, uint32_t version)
Definition: protover.c:353
protocol_type_t
Definition: protover.h:35
int protover_is_supported_here(protocol_type_t pr, uint32_t ver)
Definition: protover.c:320
const char * protover_get_supported_protocols(void)
C_RUST_COUPLED: src/rust/protover/protover.rs SUPPORTED_PROTOCOLS
Definition: protover.c:388
STATIC int str_to_protocol_type(const char *s, protocol_type_t *pr_out)
Definition: protover.c:90
STATIC void proto_entry_free_(proto_entry_t *entry)
Definition: protover.c:110
STATIC const char * protocol_type_to_str(protocol_type_t pr)
Definition: protover.c:72
Macros to implement mocking and selective exposure for the test code.
int protocol_list_supports_protocol(const char *list, protocol_type_t tp, uint32_t version)
Definition: protover.c:331
bool protover_contains_long_protocol_names(const char *s)
Definition: protover.c:305
char * protover_compute_vote(const smartlist_t *list_of_proto_strings, int threshold)
Definition: protover.c:671
STATIC char * encode_protocol_list(const smartlist_t *sl)
Definition: protover.c:454