tor  0.4.1.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,
48 
49 bool protover_contains_long_protocol_names(const char *s);
50 int protover_all_supported(const char *s, char **missing);
51 int protover_is_supported_here(protocol_type_t pr, uint32_t ver);
52 const char *protover_get_supported_protocols(void);
53 
54 char *protover_compute_vote(const struct smartlist_t *list_of_proto_strings,
55  int threshold);
56 const char *protover_compute_for_old_tor(const char *version);
58  uint32_t version);
60  protocol_type_t tp,
61  uint32_t version);
62 
63 void protover_free_all(void);
64 
65 #ifdef PROTOVER_PRIVATE
66 
68 typedef struct proto_range_t {
69  uint32_t low;
70  uint32_t high;
71 } proto_range_t;
72 
74 typedef struct proto_entry_t {
80  char *name;
82  struct smartlist_t *ranges;
83 } proto_entry_t;
84 
85 #if !defined(HAVE_RUST) && defined(TOR_UNIT_TESTS)
86 STATIC struct smartlist_t *parse_protocol_list(const char *s);
87 STATIC char *encode_protocol_list(const struct smartlist_t *sl);
88 STATIC const char *protocol_type_to_str(protocol_type_t pr);
89 STATIC int str_to_protocol_type(const char *s, protocol_type_t *pr_out);
90 STATIC void proto_entry_free_(proto_entry_t *entry);
91 #endif /* !defined(HAVE_RUST) && defined(TOR_UNIT_TESTS) */
92 
93 #define proto_entry_free(entry) \
94  FREE_AND_NULL(proto_entry_t, proto_entry_free_, (entry))
95 
96 #endif /* defined(PROTOVER_PRIVATE) */
97 
98 #endif /* !defined(TOR_PROTOVER_H) */
int protover_all_supported(const char *s, char **missing)
Definition: protover.c:746
STATIC smartlist_t * parse_protocol_list(const char *s)
Definition: protover.c:268
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:899
void protover_free_all(void)
Definition: protover.c:937
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:352
protocol_type_t
Definition: protover.h:35
int protover_is_supported_here(protocol_type_t pr, uint32_t ver)
Definition: protover.c:319
const char * protover_get_supported_protocols(void)
C_RUST_COUPLED: src/rust/protover/protover.rs SUPPORTED_PROTOCOLS
Definition: protover.c:387
STATIC int str_to_protocol_type(const char *s, protocol_type_t *pr_out)
Definition: protover.c:89
STATIC void proto_entry_free_(proto_entry_t *entry)
Definition: protover.c:109
STATIC const char * protocol_type_to_str(protocol_type_t pr)
Definition: protover.c:71
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:330
bool protover_contains_long_protocol_names(const char *s)
Definition: protover.c:304
char * protover_compute_vote(const smartlist_t *list_of_proto_strings, int threshold)
Definition: protover.c:669
STATIC char * encode_protocol_list(const smartlist_t *sl)
Definition: protover.c:452