2017-03-15 16:13:17 -04:00
|
|
|
/* Copyright (c) 2016-2017, The Tor Project, Inc. */
|
2016-10-14 20:08:51 -04:00
|
|
|
/* See LICENSE for licensing information */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \file protover.h
|
|
|
|
* \brief Headers and type declarations for protover.c
|
|
|
|
**/
|
2016-08-09 19:11:47 -04:00
|
|
|
|
|
|
|
#ifndef TOR_PROTOVER_H
|
|
|
|
#define TOR_PROTOVER_H
|
|
|
|
|
|
|
|
#include "container.h"
|
|
|
|
|
2016-08-26 13:09:26 -04:00
|
|
|
/** The first version of Tor that included "proto" entries in its
|
|
|
|
* descriptors. Authorities should use this to decide whether to
|
|
|
|
* guess proto lines. */
|
2016-08-25 11:18:05 -04:00
|
|
|
/* This is a guess. */
|
2017-11-13 10:03:46 -05:00
|
|
|
/// C_RUST_COUPLED: src/rust/protover/protover.rs
|
|
|
|
/// `FIRST_TOR_VERSION_TO_ADVERTISE_PROTOCOLS`
|
2016-08-25 11:18:05 -04:00
|
|
|
#define FIRST_TOR_VERSION_TO_ADVERTISE_PROTOCOLS "0.2.9.3-alpha"
|
|
|
|
|
2017-06-28 17:22:59 +03:00
|
|
|
/** The protover version number that signifies HSDir support for HSv3 */
|
|
|
|
#define PROTOVER_HSDIR_V3 2
|
|
|
|
/** The protover version number that signifies HSv3 intro point support */
|
|
|
|
#define PROTOVER_HS_INTRO_V3 4
|
2017-08-30 10:13:22 -04:00
|
|
|
/** The protover version number that signifies HSv3 rendezvous point support */
|
|
|
|
#define PROTOVER_HS_RENDEZVOUS_POINT_V3 2
|
2017-06-28 17:22:59 +03:00
|
|
|
|
2016-08-26 13:09:26 -04:00
|
|
|
/** List of recognized subprotocols. */
|
2017-11-13 10:03:46 -05:00
|
|
|
/// C_RUST_COUPLED: src/rust/protover/ffi.rs `translate_to_rust`
|
|
|
|
/// C_RUST_COUPLED: src/rust/protover/protover.rs `Proto`
|
2016-08-09 19:11:47 -04:00
|
|
|
typedef enum protocol_type_t {
|
|
|
|
PRT_LINK,
|
|
|
|
PRT_LINKAUTH,
|
|
|
|
PRT_RELAY,
|
|
|
|
PRT_DIRCACHE,
|
|
|
|
PRT_HSDIR,
|
2016-09-14 10:31:56 -04:00
|
|
|
PRT_HSINTRO,
|
|
|
|
PRT_HSREND,
|
2016-08-09 19:11:47 -04:00
|
|
|
PRT_DESC,
|
|
|
|
PRT_MICRODESC,
|
|
|
|
PRT_CONS,
|
|
|
|
} protocol_type_t;
|
|
|
|
|
|
|
|
int protover_all_supported(const char *s, char **missing);
|
|
|
|
int protover_is_supported_here(protocol_type_t pr, uint32_t ver);
|
2016-09-12 14:18:43 -04:00
|
|
|
const char *protover_get_supported_protocols(void);
|
2016-08-09 19:11:47 -04:00
|
|
|
|
2016-09-12 14:11:44 -04:00
|
|
|
char *protover_compute_vote(const smartlist_t *list_of_proto_strings,
|
2016-08-26 13:09:26 -04:00
|
|
|
int threshold);
|
2016-08-25 11:18:05 -04:00
|
|
|
const char *protover_compute_for_old_tor(const char *version);
|
2016-08-26 12:49:00 -04:00
|
|
|
int protocol_list_supports_protocol(const char *list, protocol_type_t tp,
|
|
|
|
uint32_t version);
|
2017-09-11 09:50:31 -04:00
|
|
|
int protocol_list_supports_protocol_or_later(const char *list,
|
|
|
|
protocol_type_t tp,
|
|
|
|
uint32_t version);
|
2016-08-19 18:04:02 -04:00
|
|
|
|
2016-08-09 19:11:47 -04:00
|
|
|
void protover_free_all(void);
|
|
|
|
|
|
|
|
#ifdef PROTOVER_PRIVATE
|
2016-08-26 13:09:26 -04:00
|
|
|
/** Represents a range of subprotocols of a given type. All subprotocols
|
|
|
|
* between <b>low</b> and <b>high</b> inclusive are included. */
|
2016-08-09 19:11:47 -04:00
|
|
|
typedef struct proto_range_t {
|
|
|
|
uint32_t low;
|
|
|
|
uint32_t high;
|
|
|
|
} proto_range_t;
|
|
|
|
|
2016-08-26 13:09:26 -04:00
|
|
|
/** Represents a set of ranges of subprotocols of a given type. */
|
2016-08-09 19:11:47 -04:00
|
|
|
typedef struct proto_entry_t {
|
2016-08-26 13:09:26 -04:00
|
|
|
/** The name of the protocol.
|
|
|
|
*
|
|
|
|
* (This needs to handle voting on protocols which
|
|
|
|
* we don't recognize yet, so it's a char* rather than a protocol_type_t.)
|
|
|
|
*/
|
2016-08-09 19:11:47 -04:00
|
|
|
char *name;
|
2016-08-26 13:09:26 -04:00
|
|
|
/** Smartlist of proto_range_t */
|
2016-08-09 19:11:47 -04:00
|
|
|
smartlist_t *ranges;
|
|
|
|
} proto_entry_t;
|
|
|
|
|
2017-09-27 19:48:07 +00:00
|
|
|
#if !defined(HAVE_RUST) && defined(TOR_UNIT_TESTS)
|
2016-08-09 19:11:47 -04:00
|
|
|
STATIC smartlist_t *parse_protocol_list(const char *s);
|
|
|
|
STATIC char *encode_protocol_list(const smartlist_t *sl);
|
|
|
|
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);
|
2017-11-21 09:37:47 -05:00
|
|
|
STATIC void proto_entry_free_(proto_entry_t *entry);
|
2017-12-07 10:52:55 -05:00
|
|
|
#define proto_entry_free(entry) \
|
|
|
|
FREE_AND_NULL(proto_entry_t, proto_entry_free_, (entry))
|
2017-09-27 19:48:07 +00:00
|
|
|
|
2017-11-21 14:07:43 -05:00
|
|
|
#endif /* !defined(HAVE_RUST) && defined(TOR_UNIT_TESTS) */
|
2017-09-27 19:48:07 +00:00
|
|
|
|
2017-09-15 16:24:44 -04:00
|
|
|
#endif /* defined(PROTOVER_PRIVATE) */
|
2016-08-09 19:11:47 -04:00
|
|
|
|
2017-09-15 16:24:44 -04:00
|
|
|
#endif /* !defined(TOR_PROTOVER_H) */
|
2016-08-26 13:09:26 -04:00
|
|
|
|