tor  master
protover.h
Go to the documentation of this file.
1 /* Copyright (c) 2016-2017, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
3 
9 #ifndef TOR_PROTOVER_H
10 #define TOR_PROTOVER_H
11 
12 #include "container.h"
13 
17 /* This is a guess. */
20 #define FIRST_TOR_VERSION_TO_ADVERTISE_PROTOCOLS "0.2.9.3-alpha"
21 
23 #define PROTOVER_HSDIR_V3 2
24 
25 #define PROTOVER_HS_INTRO_V3 4
26 
27 #define PROTOVER_HS_RENDEZVOUS_POINT_V3 2
28 
30 typedef enum protocol_type_t {
33  PRT_LINK,
34  PRT_LINKAUTH,
35  PRT_RELAY,
36  PRT_DIRCACHE,
37  PRT_HSDIR,
38  PRT_HSINTRO,
39  PRT_HSREND,
40  PRT_DESC,
41  PRT_MICRODESC,
42  PRT_CONS,
44 
45 bool protover_contains_long_protocol_names(const char *s);
46 int protover_all_supported(const char *s, char **missing);
47 int protover_is_supported_here(protocol_type_t pr, uint32_t ver);
48 const char *protover_get_supported_protocols(void);
49 
50 char *protover_compute_vote(const smartlist_t *list_of_proto_strings,
51  int threshold);
52 const char *protover_compute_for_old_tor(const char *version);
53 int protocol_list_supports_protocol(const char *list, protocol_type_t tp,
54  uint32_t version);
55 int protocol_list_supports_protocol_or_later(const char *list,
56  protocol_type_t tp,
57  uint32_t version);
58 
59 void protover_free_all(void);
60 
61 #ifdef PROTOVER_PRIVATE
62 
64 typedef struct proto_range_t {
65  uint32_t low;
66  uint32_t high;
67 } proto_range_t;
68 
70 typedef struct proto_entry_t {
76  char *name;
78  smartlist_t *ranges;
79 } proto_entry_t;
80 
81 #if !defined(HAVE_RUST) && defined(TOR_UNIT_TESTS)
82 STATIC smartlist_t *parse_protocol_list(const char *s);
83 STATIC char *encode_protocol_list(const smartlist_t *sl);
84 STATIC const char *protocol_type_to_str(protocol_type_t pr);
85 STATIC int str_to_protocol_type(const char *s, protocol_type_t *pr_out);
86 STATIC void proto_entry_free_(proto_entry_t *entry);
87 #endif /* !defined(HAVE_RUST) && defined(TOR_UNIT_TESTS) */
88 
89 #define proto_entry_free(entry) \
90  FREE_AND_NULL(proto_entry_t, proto_entry_free_, (entry))
91 
92 #endif /* defined(PROTOVER_PRIVATE) */
93 
94 #endif /* !defined(TOR_PROTOVER_H) */
95 
int protover_all_supported(const char *s, char **missing)
Definition: protover.c:705
STATIC smartlist_t * parse_protocol_list(const char *s)
Definition: protover.c:248
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:858
void protover_free_all(void)
Definition: protover.c:896
Definition: container.h:18
int protocol_list_supports_protocol_or_later(const char *list, protocol_type_t tp, uint32_t version)
Definition: protover.c:329
protocol_type_t
Definition: protover.h:32
int protover_is_supported_here(protocol_type_t pr, uint32_t ver)
Definition: protover.c:296
const char * protover_get_supported_protocols(void)
C_RUST_COUPLED: src/rust/protover/protover.rs SUPPORTED_PROTOCOLS
Definition: protover.c:364
STATIC int str_to_protocol_type(const char *s, protocol_type_t *pr_out)
Definition: protover.c:84
STATIC void proto_entry_free_(proto_entry_t *entry)
Definition: protover.c:104
char * protover_compute_vote(const smartlist_t *list_of_proto_strings, int threshold)
Definition: protover.c:637
STATIC const char * protocol_type_to_str(protocol_type_t pr)
Definition: protover.c:66
int protocol_list_supports_protocol(const char *list, protocol_type_t tp, uint32_t version)
Definition: protover.c:307
bool protover_contains_long_protocol_names(const char *s)
Definition: protover.c:284
STATIC char * encode_protocol_list(const smartlist_t *sl)
Definition: protover.c:424