diff options
author | Chelsea Holland Komlo <me@chelseakomlo.com> | 2017-11-11 22:26:22 -0500 |
---|---|---|
committer | Chelsea Holland Komlo <me@chelseakomlo.com> | 2017-11-11 23:19:34 -0500 |
commit | 1c50331b9af28a691cb48e632ab71d9af83916ba (patch) | |
tree | e8716f521e6a1d5237a8bedbb877b9359a69a7ff /src/rust | |
parent | 11eaf208c0aaa7c252ead6343ea65a3576227d69 (diff) | |
download | tor-1c50331b9af28a691cb48e632ab71d9af83916ba.tar.gz tor-1c50331b9af28a691cb48e632ab71d9af83916ba.zip |
annotate where C and Rust need to stay in sync
Diffstat (limited to 'src/rust')
-rw-r--r-- | src/rust/protover/ffi.rs | 3 | ||||
-rw-r--r-- | src/rust/protover/protover.rs | 12 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/rust/protover/ffi.rs b/src/rust/protover/ffi.rs index cebf9e12fa..3eb22c933e 100644 --- a/src/rust/protover/ffi.rs +++ b/src/rust/protover/ffi.rs @@ -15,7 +15,8 @@ use tor_allocate::allocate_and_copy_string; /// Translate C enums to Rust Proto enums, using the integer value of the C /// enum to map to its associated Rust enum -/// This is dependant on the associated C enum preserving ordering. +/// +/// C_RUST_COUPLED: src/or/protover.h `protocol_type_t` fn translate_to_rust(c_proto: uint32_t) -> Result<Proto, &'static str> { match c_proto { 0 => Ok(Proto::Link), diff --git a/src/rust/protover/protover.rs b/src/rust/protover/protover.rs index b8bf280d4c..7d5947ca2f 100644 --- a/src/rust/protover/protover.rs +++ b/src/rust/protover/protover.rs @@ -10,13 +10,20 @@ use std::string::String; /// The first version of Tor that included "proto" entries in its descriptors. /// Authorities should use this to decide whether to guess proto lines. +/// +/// C_RUST_COUPLED: +/// src/or/protover.h `FIRST_TOR_VERSION_TO_ADVERTISE_PROTOCOLS` const FIRST_TOR_VERSION_TO_ADVERTISE_PROTOCOLS: &'static str = "0.2.9.3-alpha"; /// The maximum number of subprotocol version numbers we will attempt to expand /// before concluding that someone is trying to DoS us +/// +/// C_RUST_COUPLED: src/or/protover.c `MAX_PROTOCOLS_TO_EXPAND` const MAX_PROTOCOLS_TO_EXPAND: u32 = 500; /// Currently supported protocols and their versions +/// +/// C_RUST_COUPLED: src/or/protover.c `protover_get_supported_protocols` const SUPPORTED_PROTOCOLS: &'static [&'static str] = &[ "Cons=1-2", "Desc=1-2", @@ -31,6 +38,8 @@ const SUPPORTED_PROTOCOLS: &'static [&'static str] = &[ ]; /// Known subprotocols in Tor. Indicates which subprotocol a relay supports. +/// +/// C_RUST_COUPLED: src/or/protover.h `protocol_type_t` #[derive(Hash, Eq, PartialEq, Debug)] pub enum Proto { Cons, @@ -53,6 +62,8 @@ impl fmt::Display for Proto { /// Translates a string representation of a protocol into a Proto type. /// Error if the string is an unrecognized protocol name. +/// +/// C_RUST_COUPLED: src/or/protover.c `PROTOCOL_NAMES` impl FromStr for Proto { type Err = &'static str; @@ -712,6 +723,7 @@ pub fn is_supported_here(proto: Proto, vers: u32) -> bool { /// This function returns the protocols that are supported by the version input, /// only for tor versions older than FIRST_TOR_VERSION_TO_ADVERTISE_PROTOCOLS. /// +/// C_RUST_COUPLED: src/rust/protover.c `compute_for_old_tor` pub fn compute_for_old_tor(version: &str) -> String { if c_tor_version_as_new_as( version, |