diff --git a/PROTOCOL.md b/PROTOCOL.md index aed05d856..521d49dc0 100644 --- a/PROTOCOL.md +++ b/PROTOCOL.md @@ -90,7 +90,7 @@ OK(HELLO) response payload, which must be sent if the HELLO receipient wishes to | [2] u16 | Responding node revision (0 if unspecified) | | Endpoint | Physical endpoint where OK(HELLO) was sent | | [2] u16 | *(reserved)* (set to zero for legacy reasons) | -| [2] u16 | Length of encrypted Dictionary in bytes | +| [2] u16 | Length of Dictionary in bytes | | Dictionary | Key/value dictionary containing additional fields | The unencrypted dictionary is not currently used. The encrypted dictionary can contain the following fields in both HELLO and OK(HELLO): diff --git a/zerotier-network-hypervisor/src/networkhypervisor.rs b/zerotier-network-hypervisor/src/networkhypervisor.rs index 3eb1565cc..080e6592c 100644 --- a/zerotier-network-hypervisor/src/networkhypervisor.rs +++ b/zerotier-network-hypervisor/src/networkhypervisor.rs @@ -7,13 +7,12 @@ */ use std::num::NonZeroI64; -use std::sync::Arc; use std::time::Duration; use crate::error::InvalidParameterError; use crate::vl1::{Address, Identity, Endpoint, SystemInterface, Node}; use crate::vl2::{Switch, SwitchInterface}; -use crate::{PacketBuffer, PacketBufferPool}; +use crate::PacketBuffer; pub trait Interface: SystemInterface + SwitchInterface {} diff --git a/zerotier-network-hypervisor/src/vl1/ephemeral.rs b/zerotier-network-hypervisor/src/vl1/ephemeral.rs index 0ee7855f5..d8fe502dd 100644 --- a/zerotier-network-hypervisor/src/vl1/ephemeral.rs +++ b/zerotier-network-hypervisor/src/vl1/ephemeral.rs @@ -10,11 +10,9 @@ use std::fmt::{Debug, Display}; use std::error::Error; use std::sync::atomic::{AtomicU32, Ordering}; use std::io::Write; -use std::convert::TryInto; use zerotier_core_crypto::c25519::{C25519KeyPair, C25519_PUBLIC_KEY_SIZE}; use zerotier_core_crypto::hash::{SHA384_HASH_SIZE, SHA384}; -use zerotier_core_crypto::kbkdf::zt_kbkdf_hmac_sha384; use zerotier_core_crypto::p521::{P521KeyPair, P521_PUBLIC_KEY_SIZE, P521PublicKey}; use zerotier_core_crypto::random::SecureRandom; use zerotier_core_crypto::secret::Secret; @@ -219,81 +217,71 @@ impl EphemeralKeyPairSet { } let key_len = key_len.unwrap().0 as usize; - match cipher { - - ALGORITHM_C25519 => { - if other_public_bytes.len() < C25519_PUBLIC_KEY_SIZE || key_len != C25519_PUBLIC_KEY_SIZE { - return Err(EphemeralKeyAgreementError::InvalidData); - } - - let c25519_secret = self.c25519.agree(&other_public_bytes[0..C25519_PUBLIC_KEY_SIZE]); - other_public_bytes = &other_public_bytes[C25519_PUBLIC_KEY_SIZE..]; - - key.0 = SHA384::hmac(&key.0, &c25519_secret.0); - it_happened = true; - fips_compliant_exchange = false; - c25519_ratchet_count += 1; - }, - - ALGORITHM_SIDHP751 => { - if other_public_bytes.len() < (SIDH_P751_PUBLIC_KEY_SIZE + 1) || key_len != (SIDH_P751_PUBLIC_KEY_SIZE + 1) { - return Err(EphemeralKeyAgreementError::InvalidData); - } - - let _ = match self.sidhp751.as_ref() { - Some(SIDHEphemeralKeyPair::Alice(_, seck)) => { - if other_public_bytes[0] != 0 { // Alice can't agree with Alice - Some(Secret(seck.shared_secret(&SIDHPublicKeyBob::from_bytes(&other_public_bytes[1..(SIDH_P751_PUBLIC_KEY_SIZE + 1)])))) - } else { - None - } - }, - Some(SIDHEphemeralKeyPair::Bob(_, seck)) => { - if other_public_bytes[0] != 1 { // Bob can't agree with Bob - Some(Secret(seck.shared_secret(&SIDHPublicKeyAlice::from_bytes(&other_public_bytes[1..(SIDH_P751_PUBLIC_KEY_SIZE + 1)])))) - } else { - None - } - }, - None => None, - }.map(|sidh_secret| { - key.0 = SHA384::hmac(&key.0, &sidh_secret.0); - it_happened = true; - fips_compliant_exchange = false; - sidhp751_ratchet_count += 1; - }); - other_public_bytes = &other_public_bytes[(SIDH_P751_PUBLIC_KEY_SIZE + 1)..]; - }, - - ALGORITHM_NISTP751ECDH => { - if other_public_bytes.len() < P521_PUBLIC_KEY_SIZE || key_len != P521_PUBLIC_KEY_SIZE { - return Err(EphemeralKeyAgreementError::InvalidData); - } - - let p521_public = P521PublicKey::from_bytes(&other_public_bytes[0..P521_PUBLIC_KEY_SIZE]); - other_public_bytes = &other_public_bytes[P521_PUBLIC_KEY_SIZE..]; - if p521_public.is_none() { - return Err(EphemeralKeyAgreementError::InvalidData); - } - - let p521_key = self.p521.agree(p521_public.as_ref().unwrap()); - if p521_key.is_none() { - return Err(EphemeralKeyAgreementError::InvalidData); - } - - key.0 = SHA384::hmac(&key.0, &p521_key.unwrap().0); - it_happened = true; - fips_compliant_exchange = true; - nistp521_ratchet_count += 1; - }, - - _ => { - if other_public_bytes.len() < key_len { - return Err(EphemeralKeyAgreementError::InvalidData); - } - other_public_bytes = &other_public_bytes[key_len..]; + if cipher == ALGORITHM_C25519 { + if other_public_bytes.len() < C25519_PUBLIC_KEY_SIZE || key_len != C25519_PUBLIC_KEY_SIZE { + return Err(EphemeralKeyAgreementError::InvalidData); } + let c25519_secret = self.c25519.agree(&other_public_bytes[0..C25519_PUBLIC_KEY_SIZE]); + other_public_bytes = &other_public_bytes[C25519_PUBLIC_KEY_SIZE..]; + + key.0 = SHA384::hmac(&key.0, &c25519_secret.0); + it_happened = true; + fips_compliant_exchange = false; + c25519_ratchet_count += 1; + } else if cipher == ALGORITHM_SIDHP751 { + if other_public_bytes.len() < (SIDH_P751_PUBLIC_KEY_SIZE + 1) || key_len != (SIDH_P751_PUBLIC_KEY_SIZE + 1) { + return Err(EphemeralKeyAgreementError::InvalidData); + } + + let _ = match self.sidhp751.as_ref() { + Some(SIDHEphemeralKeyPair::Alice(_, seck)) => { + if other_public_bytes[0] != 0 { // Alice can't agree with Alice + Some(Secret(seck.shared_secret(&SIDHPublicKeyBob::from_bytes(&other_public_bytes[1..(SIDH_P751_PUBLIC_KEY_SIZE + 1)])))) + } else { + None + } + }, + Some(SIDHEphemeralKeyPair::Bob(_, seck)) => { + if other_public_bytes[0] != 1 { // Bob can't agree with Bob + Some(Secret(seck.shared_secret(&SIDHPublicKeyAlice::from_bytes(&other_public_bytes[1..(SIDH_P751_PUBLIC_KEY_SIZE + 1)])))) + } else { + None + } + }, + None => None, + }.map(|sidh_secret| { + key.0 = SHA384::hmac(&key.0, &sidh_secret.0); + it_happened = true; + fips_compliant_exchange = false; + sidhp751_ratchet_count += 1; + }); + other_public_bytes = &other_public_bytes[(SIDH_P751_PUBLIC_KEY_SIZE + 1)..]; + } else if cipher == ALGORITHM_NISTP521ECDH { + if other_public_bytes.len() < P521_PUBLIC_KEY_SIZE || key_len != P521_PUBLIC_KEY_SIZE { + return Err(EphemeralKeyAgreementError::InvalidData); + } + + let p521_public = P521PublicKey::from_bytes(&other_public_bytes[0..P521_PUBLIC_KEY_SIZE]); + other_public_bytes = &other_public_bytes[P521_PUBLIC_KEY_SIZE..]; + if p521_public.is_none() { + return Err(EphemeralKeyAgreementError::InvalidData); + } + + let p521_key = self.p521.agree(p521_public.as_ref().unwrap()); + if p521_key.is_none() { + return Err(EphemeralKeyAgreementError::InvalidData); + } + + key.0 = SHA384::hmac(&key.0, &p521_key.unwrap().0); + it_happened = true; + fips_compliant_exchange = true; + nistp521_ratchet_count += 1; + } else { + if other_public_bytes.len() < key_len { + return Err(EphemeralKeyAgreementError::InvalidData); + } + other_public_bytes = &other_public_bytes[key_len..]; } } diff --git a/zerotier-network-hypervisor/src/vl1/node.rs b/zerotier-network-hypervisor/src/vl1/node.rs index 7ca25f242..a7a7aa5f2 100644 --- a/zerotier-network-hypervisor/src/vl1/node.rs +++ b/zerotier-network-hypervisor/src/vl1/node.rs @@ -18,7 +18,6 @@ use crate::{PacketBuffer, PacketBufferFactory, PacketBufferPool}; use crate::error::InvalidParameterError; use crate::util::buffer::Buffer; use crate::util::gate::IntervalGate; -use crate::util::pool::{Pool, Pooled}; use crate::vl1::{Address, Endpoint, Identity}; use crate::vl1::path::Path; use crate::vl1::peer::Peer; @@ -145,15 +144,15 @@ pub struct Node { impl Node { /// Create a new Node. - pub fn new(ci: &I, auto_generate_identity: bool) -> Result { + pub fn new(si: &SI, auto_generate_identity: bool) -> Result { let id = { - let id_str = ci.load_node_identity(); + let id_str = si.load_node_identity(); if id_str.is_none() { if !auto_generate_identity { return Err(InvalidParameterError("no identity found and auto-generate not enabled")); } else { let id = Identity::generate(); - ci.save_node_identity(&id, id.to_string().as_bytes(), id.to_secret_string().as_bytes()); + si.save_node_identity(&id, id.to_string().as_bytes(), id.to_secret_string().as_bytes()); id } } else { @@ -200,14 +199,14 @@ impl Node { /// /// This should only be called periodically from a single thread, but that thread can be /// different each time. Calling it concurrently won't crash but won't accomplish anything. - pub fn do_background_tasks(&self, ci: &I) -> Duration { + pub fn do_background_tasks(&self, si: &SI) -> Duration { let mut intervals = self.intervals.lock(); - let tt = ci.time_ticks(); + let tt = si.time_ticks(); if intervals.paths.gate(tt) { self.paths.retain(|_, path| { path.upgrade().map_or(false, |p| { - p.call_every_interval(ci, tt); + p.call_every_interval(si, tt); true }) }); @@ -215,24 +214,24 @@ impl Node { if intervals.peers.gate(tt) { self.peers.retain(|_, peer| { - peer.call_every_interval(ci, tt); + peer.call_every_interval(si, tt); todo!(); true }); } if intervals.whois.gate(tt) { - self.whois.call_every_interval(self, ci, tt); + self.whois.call_every_interval(self, si, tt); } Duration::from_millis(WhoisQueue::INTERVAL.min(Path::CALL_EVERY_INTERVAL_MS).min(Peer::CALL_EVERY_INTERVAL_MS) as u64 / 4) } /// Called when a packet is received on the physical wire. - pub fn wire_receive(&self, ci: &I, ph: &PH, source_endpoint: &Endpoint, source_local_socket: Option, source_local_interface: Option, mut data: PacketBuffer) { + pub fn wire_receive(&self, si: &SI, ph: &PH, source_endpoint: &Endpoint, source_local_socket: Option, source_local_interface: Option, mut data: PacketBuffer) { if let Ok(fragment_header) = data.struct_mut_at::(0) { if let Some(dest) = Address::from_bytes(&fragment_header.dest) { - let time_ticks = ci.time_ticks(); + let time_ticks = si.time_ticks(); if dest == self.identity.address { // Handle packets addressed to this node. @@ -248,9 +247,9 @@ impl Node { let packet_header = packet_header.unwrap(); if let Some(source) = Address::from_bytes(&packet_header.src) { if let Some(peer) = self.peer(source) { - peer.receive(self, ci, ph, time_ticks, source_endpoint, &path, &packet_header, frag0, &assembled_packet.frags[1..(assembled_packet.have as usize)]); + peer.receive(self, si, ph, time_ticks, source_endpoint, &path, &packet_header, frag0, &assembled_packet.frags[1..(assembled_packet.have as usize)]); } else { - self.whois.query(self, ci, source, Some(QueuedPacket::Fragmented(assembled_packet))); + self.whois.query(self, si, source, Some(QueuedPacket::Fragmented(assembled_packet))); } } } @@ -262,9 +261,9 @@ impl Node { if let Ok(packet_header) = data.struct_at::(0) { if let Some(source) = Address::from_bytes(&packet_header.src) { if let Some(peer) = self.peer(source) { - peer.receive(self, ci, ph, time_ticks, source_endpoint, &path, &packet_header, data.as_ref(), &[]); + peer.receive(self, si, ph, time_ticks, source_endpoint, &path, &packet_header, data.as_ref(), &[]); } else { - self.whois.query(self, ci, source, Some(QueuedPacket::Unfragmented(data))); + self.whois.query(self, si, source, Some(QueuedPacket::Unfragmented(data))); } } } @@ -289,7 +288,7 @@ impl Node { } } if let Some(peer) = self.peer(dest) { - peer.forward(ci, time_ticks, data.as_ref()); + peer.forward(si, time_ticks, data.as_ref()); } } }; diff --git a/zerotier-network-hypervisor/src/vl1/path.rs b/zerotier-network-hypervisor/src/vl1/path.rs index 8e5a5b700..78666e2ee 100644 --- a/zerotier-network-hypervisor/src/vl1/path.rs +++ b/zerotier-network-hypervisor/src/vl1/path.rs @@ -172,7 +172,7 @@ impl Path { pub(crate) const CALL_EVERY_INTERVAL_MS: i64 = PATH_KEEPALIVE_INTERVAL; #[inline(always)] - pub(crate) fn call_every_interval(&self, ct: &CI, time_ticks: i64) { + pub(crate) fn call_every_interval(&self, _si: &SI, time_ticks: i64) { self.fragmented_packets.lock().retain(|_, frag| (time_ticks - frag.ts_ticks) < PACKET_FRAGMENT_EXPIRATION); } } diff --git a/zerotier-network-hypervisor/src/vl1/peer.rs b/zerotier-network-hypervisor/src/vl1/peer.rs index cd47eb5e9..3768666f5 100644 --- a/zerotier-network-hypervisor/src/vl1/peer.rs +++ b/zerotier-network-hypervisor/src/vl1/peer.rs @@ -25,7 +25,7 @@ use zerotier_core_crypto::secret::Secret; use crate::{PacketBuffer, VERSION_MAJOR, VERSION_MINOR, VERSION_PROTO, VERSION_REVISION}; use crate::util::{array_range, u64_as_bytes}; use crate::util::buffer::Buffer; -use crate::vl1::{Endpoint, Identity, InetAddress, Path, ephemeral}; +use crate::vl1::{Endpoint, Identity, InetAddress, Path}; use crate::vl1::ephemeral::EphemeralSymmetricSecret; use crate::vl1::identity::{IDENTITY_ALGORITHM_ALL, IDENTITY_ALGORITHM_X25519}; use crate::vl1::node::*; @@ -209,7 +209,7 @@ impl Peer { /// Receive, decrypt, authenticate, and process an incoming packet from this peer. /// If the packet comes in multiple fragments, the fragments slice should contain all /// those fragments after the main packet header and first chunk. - pub(crate) fn receive(&self, node: &Node, ci: &CI, ph: &PH, time_ticks: i64, source_endpoint: &Endpoint, source_path: &Arc, header: &PacketHeader, packet: &Buffer<{ PACKET_SIZE_MAX }>, fragments: &[Option]) { + pub(crate) fn receive(&self, node: &Node, si: &SI, ph: &PH, time_ticks: i64, source_endpoint: &Endpoint, source_path: &Arc, header: &PacketHeader, packet: &Buffer<{ PACKET_SIZE_MAX }>, fragments: &[Option]) { let _ = packet.as_bytes_starting_at(PACKET_VERB_INDEX).map(|packet_frag0_payload_bytes| { let mut payload: Buffer = unsafe { Buffer::new_without_memzero() }; @@ -278,14 +278,14 @@ impl Peer { if !ph.handle_packet(self, source_path, forward_secrecy, extended_authentication, verb, &payload) { match verb { //VERB_VL1_NOP => {} - VERB_VL1_HELLO => self.receive_hello(ci, node, time_ticks, source_path, &payload), - VERB_VL1_ERROR => self.receive_error(ci, ph, node, time_ticks, source_path, forward_secrecy, extended_authentication, &payload), - VERB_VL1_OK => self.receive_ok(ci, ph, node, time_ticks, source_path, forward_secrecy, extended_authentication, &payload), - VERB_VL1_WHOIS => self.receive_whois(ci, node, time_ticks, source_path, &payload), - VERB_VL1_RENDEZVOUS => self.receive_rendezvous(ci, node, time_ticks, source_path, &payload), - VERB_VL1_ECHO => self.receive_echo(ci, node, time_ticks, source_path, &payload), - VERB_VL1_PUSH_DIRECT_PATHS => self.receive_push_direct_paths(ci, node, time_ticks, source_path, &payload), - VERB_VL1_USER_MESSAGE => self.receive_user_message(ci, node, time_ticks, source_path, &payload), + VERB_VL1_HELLO => self.receive_hello(si, node, time_ticks, source_path, &payload), + VERB_VL1_ERROR => self.receive_error(si, ph, node, time_ticks, source_path, forward_secrecy, extended_authentication, &payload), + VERB_VL1_OK => self.receive_ok(si, ph, node, time_ticks, source_path, forward_secrecy, extended_authentication, &payload), + VERB_VL1_WHOIS => self.receive_whois(si, node, time_ticks, source_path, &payload), + VERB_VL1_RENDEZVOUS => self.receive_rendezvous(si, node, time_ticks, source_path, &payload), + VERB_VL1_ECHO => self.receive_echo(si, node, time_ticks, source_path, &payload), + VERB_VL1_PUSH_DIRECT_PATHS => self.receive_push_direct_paths(si, node, time_ticks, source_path, &payload), + VERB_VL1_USER_MESSAGE => self.receive_user_message(si, node, time_ticks, source_path, &payload), _ => {} } } else { @@ -301,7 +301,7 @@ impl Peer { }); } - fn send_to_endpoint(&self, ci: &CI, endpoint: &Endpoint, local_socket: Option, local_interface: Option, packet: &Buffer<{ PACKET_SIZE_MAX }>) -> bool { + fn send_to_endpoint(&self, si: &SI, endpoint: &Endpoint, local_socket: Option, local_interface: Option, packet: &Buffer<{ PACKET_SIZE_MAX }>) -> bool { debug_assert!(packet.len() <= PACKET_SIZE_MAX); debug_assert!(packet.len() >= PACKET_SIZE_MIN); match endpoint { @@ -309,7 +309,7 @@ impl Peer { let packet_size = packet.len(); if packet_size > UDP_DEFAULT_MTU { let bytes = packet.as_bytes(); - if !ci.wire_send(endpoint, local_socket, local_interface, &[&bytes[0..UDP_DEFAULT_MTU]], 0) { + if !si.wire_send(endpoint, local_socket, local_interface, &[&bytes[0..UDP_DEFAULT_MTU]], 0) { return false; } @@ -331,7 +331,7 @@ impl Peer { loop { header.total_and_fragment_no += 1; let next_pos = pos + chunk_size; - if !ci.wire_send(endpoint, local_socket, local_interface, &[header.as_bytes(), &bytes[pos..next_pos]], 0) { + if !si.wire_send(endpoint, local_socket, local_interface, &[header.as_bytes(), &bytes[pos..next_pos]], 0) { return false; } pos = next_pos; @@ -342,11 +342,11 @@ impl Peer { } } } else { - return ci.wire_send(endpoint, local_socket, local_interface, &[packet.as_bytes()], 0); + return si.wire_send(endpoint, local_socket, local_interface, &[packet.as_bytes()], 0); } } _ => { - return ci.wire_send(endpoint, local_socket, local_interface, &[packet.as_bytes()], 0); + return si.wire_send(endpoint, local_socket, local_interface, &[packet.as_bytes()], 0); } } } @@ -355,9 +355,9 @@ impl Peer { /// /// This will go directly if there is an active path, or otherwise indirectly /// via a root or some other route. - pub(crate) fn send(&self, ci: &CI, node: &Node, time_ticks: i64, packet: &Buffer<{ PACKET_SIZE_MAX }>) -> bool { + pub(crate) fn send(&self, si: &SI, node: &Node, time_ticks: i64, packet: &Buffer<{ PACKET_SIZE_MAX }>) -> bool { self.path(node).map_or(false, |path| { - if self.send_to_endpoint(ci, path.endpoint().as_ref(), path.local_socket(), path.local_interface(), packet) { + if self.send_to_endpoint(si, path.endpoint().as_ref(), path.local_socket(), path.local_interface(), packet) { self.last_send_time_ticks.store(time_ticks, Ordering::Relaxed); self.total_bytes_sent.fetch_add(packet.len() as u64, Ordering::Relaxed); true @@ -374,9 +374,9 @@ impl Peer { /// /// This doesn't fragment large packets since fragments are forwarded individually. /// Intermediates don't need to adjust fragmentation. - pub(crate) fn forward(&self, ci: &CI, time_ticks: i64, packet: &Buffer<{ PACKET_SIZE_MAX }>) -> bool { + pub(crate) fn forward(&self, si: &SI, time_ticks: i64, packet: &Buffer<{ PACKET_SIZE_MAX }>) -> bool { self.direct_path().map_or(false, |path| { - if ci.wire_send(path.endpoint().as_ref(), path.local_socket(), path.local_interface(), &[packet.as_bytes()], 0) { + if si.wire_send(path.endpoint().as_ref(), path.local_socket(), path.local_interface(), &[packet.as_bytes()], 0) { self.last_forward_time_ticks.store(time_ticks, Ordering::Relaxed); self.total_bytes_forwarded.fetch_add(packet.len() as u64, Ordering::Relaxed); true @@ -390,9 +390,9 @@ impl Peer { /// /// If explicit_endpoint is not None the packet will be sent directly to this endpoint. /// Otherwise it will be sent via the best direct or indirect path known. - pub(crate) fn send_hello(&self, ci: &CI, node: &Node, explicit_endpoint: Option<&Endpoint>) -> bool { + pub(crate) fn send_hello(&self, si: &SI, node: &Node, explicit_endpoint: Option<&Endpoint>) -> bool { let mut packet: Buffer<{ PACKET_SIZE_MAX }> = Buffer::new(); - let time_ticks = ci.time_ticks(); + let time_ticks = si.time_ticks(); let message_id = self.next_message_id(); { @@ -451,10 +451,10 @@ impl Peer { explicit_endpoint.map_or_else(|| { self.path(node).map_or(false, |path| { path.log_send_anything(time_ticks); - self.send_to_endpoint(ci, path.endpoint().as_ref(), path.local_socket(), path.local_interface(), &packet) + self.send_to_endpoint(si, path.endpoint().as_ref(), path.local_socket(), path.local_interface(), &packet) }) }, |endpoint| { - self.send_to_endpoint(ci, endpoint, None, None, &packet) + self.send_to_endpoint(si, endpoint, None, None, &packet) }) } @@ -462,13 +462,13 @@ impl Peer { /// Called every INTERVAL during background tasks. #[inline(always)] - pub(crate) fn call_every_interval(&self, ct: &CI, time_ticks: i64) {} + pub(crate) fn call_every_interval(&self, si: &SI, time_ticks: i64) {} #[inline(always)] - fn receive_hello(&self, ci: &CI, node: &Node, time_ticks: i64, source_path: &Arc, payload: &Buffer<{ PACKET_SIZE_MAX }>) {} + fn receive_hello(&self, si: &SI, node: &Node, time_ticks: i64, source_path: &Arc, payload: &Buffer<{ PACKET_SIZE_MAX }>) {} #[inline(always)] - fn receive_error(&self, ci: &CI, ph: &PH, node: &Node, time_ticks: i64, source_path: &Arc, forward_secrecy: bool, extended_authentication: bool, payload: &Buffer<{ PACKET_SIZE_MAX }>) { + fn receive_error(&self, si: &SI, ph: &PH, node: &Node, time_ticks: i64, source_path: &Arc, forward_secrecy: bool, extended_authentication: bool, payload: &Buffer<{ PACKET_SIZE_MAX }>) { let mut cursor: usize = 0; let _ = payload.read_struct::(&mut cursor).map(|error_header| { let in_re_message_id = u64::from_ne_bytes(error_header.in_re_message_id); @@ -484,7 +484,7 @@ impl Peer { } #[inline(always)] - fn receive_ok(&self, ci: &CI, ph: &PH, node: &Node, time_ticks: i64, source_path: &Arc, forward_secrecy: bool, extended_authentication: bool, payload: &Buffer<{ PACKET_SIZE_MAX }>) { + fn receive_ok(&self, si: &SI, ph: &PH, node: &Node, time_ticks: i64, source_path: &Arc, forward_secrecy: bool, extended_authentication: bool, payload: &Buffer<{ PACKET_SIZE_MAX }>) { let mut cursor: usize = 0; let _ = payload.read_struct::(&mut cursor).map(|ok_header| { let in_re_message_id = u64::from_ne_bytes(ok_header.in_re_message_id); @@ -504,19 +504,19 @@ impl Peer { } #[inline(always)] - fn receive_whois(&self, ci: &CI, node: &Node, time_ticks: i64, source_path: &Arc, payload: &Buffer<{ PACKET_SIZE_MAX }>) {} + fn receive_whois(&self, si: &SI, node: &Node, time_ticks: i64, source_path: &Arc, payload: &Buffer<{ PACKET_SIZE_MAX }>) {} #[inline(always)] - fn receive_rendezvous(&self, ci: &CI, node: &Node, time_ticks: i64, source_path: &Arc, payload: &Buffer<{ PACKET_SIZE_MAX }>) {} + fn receive_rendezvous(&self, si: &SI, node: &Node, time_ticks: i64, source_path: &Arc, payload: &Buffer<{ PACKET_SIZE_MAX }>) {} #[inline(always)] - fn receive_echo(&self, ci: &CI, node: &Node, time_ticks: i64, source_path: &Arc, payload: &Buffer<{ PACKET_SIZE_MAX }>) {} + fn receive_echo(&self, si: &SI, node: &Node, time_ticks: i64, source_path: &Arc, payload: &Buffer<{ PACKET_SIZE_MAX }>) {} #[inline(always)] - fn receive_push_direct_paths(&self, ci: &CI, node: &Node, time_ticks: i64, source_path: &Arc, payload: &Buffer<{ PACKET_SIZE_MAX }>) {} + fn receive_push_direct_paths(&self, si: &SI, node: &Node, time_ticks: i64, source_path: &Arc, payload: &Buffer<{ PACKET_SIZE_MAX }>) {} #[inline(always)] - fn receive_user_message(&self, ci: &CI, node: &Node, time_ticks: i64, source_path: &Arc, payload: &Buffer<{ PACKET_SIZE_MAX }>) {} + fn receive_user_message(&self, si: &SI, node: &Node, time_ticks: i64, source_path: &Arc, payload: &Buffer<{ PACKET_SIZE_MAX }>) {} /// Get current best path or None if there are no direct paths to this peer. #[inline(always)] diff --git a/zerotier-network-hypervisor/src/vl1/whoisqueue.rs b/zerotier-network-hypervisor/src/vl1/whoisqueue.rs index 671113038..3f3afcd08 100644 --- a/zerotier-network-hypervisor/src/vl1/whoisqueue.rs +++ b/zerotier-network-hypervisor/src/vl1/whoisqueue.rs @@ -36,7 +36,7 @@ impl WhoisQueue { pub fn new() -> Self { Self(Mutex::new(HashMap::new())) } /// Launch or renew a WHOIS query and enqueue a packet to be processed when (if) it is received. - pub fn query(&self, node: &Node, ci: &CI, target: Address, packet: Option) { + pub fn query(&self, node: &Node, si: &SI, target: Address, packet: Option) { let mut q = self.0.lock(); let qi = q.entry(target).or_insert_with(|| WhoisQueueItem { @@ -45,7 +45,7 @@ impl WhoisQueue { retry_count: 0, }); - if qi.retry_gate.gate(ci.time_ticks()) { + if qi.retry_gate.gate(si.time_ticks()) { qi.retry_count += 1; if packet.is_some() { while qi.packet_queue.len() >= WHOIS_MAX_WAITING_PACKETS { @@ -53,7 +53,7 @@ impl WhoisQueue { } qi.packet_queue.push_back(packet.unwrap()); } - self.send_whois(node, ci, &[target]); + self.send_whois(node, si, &[target]); } } @@ -64,7 +64,7 @@ impl WhoisQueue { } /// Called every INTERVAL during background tasks. - pub fn call_every_interval(&self, node: &Node, ci: &CI, time_ticks: i64) { + pub fn call_every_interval(&self, node: &Node, si: &SI, time_ticks: i64) { let mut targets: Vec
= Vec::new(); self.0.lock().retain(|target, qi| { if qi.retry_count < WHOIS_RETRY_MAX { @@ -78,11 +78,11 @@ impl WhoisQueue { } }); if !targets.is_empty() { - self.send_whois(node, ci, targets.as_slice()); + self.send_whois(node, si, targets.as_slice()); } } - fn send_whois(&self, node: &Node, ci: &CI, targets: &[Address]) { + fn send_whois(&self, node: &Node, si: &SI, targets: &[Address]) { todo!() } }