diff --git a/rust-zerotier-core/src/fingerprint.rs b/rust-zerotier-core/src/fingerprint.rs index 18f8de4b4..05c517a7f 100644 --- a/rust-zerotier-core/src/fingerprint.rs +++ b/rust-zerotier-core/src/fingerprint.rs @@ -25,7 +25,7 @@ pub struct Fingerprint { } impl Fingerprint { - #[inline] + #[inline(always)] pub(crate) fn new_from_capi(fp: &ztcore::ZT_Fingerprint) -> Fingerprint { Fingerprint{ address: Address(fp.address), diff --git a/rust-zerotier-core/src/identity.rs b/rust-zerotier-core/src/identity.rs index 94fbbbf23..c9d238aed 100644 --- a/rust-zerotier-core/src/identity.rs +++ b/rust-zerotier-core/src/identity.rs @@ -94,23 +94,15 @@ impl Identity { } /// Validate this identity, which can be slightly time consuming in some cases (20-40ms). + #[inline(always)] pub fn validate(&self) -> bool { - unsafe { - if ztcore::ZT_Identity_validate(self.capi) != 0 { - return true; - } - } - false + unsafe { ztcore::ZT_Identity_validate(self.capi) != 0 } } /// Returns true if this Identity includes its corresponding private key. + #[inline(always)] pub fn has_private(&self) -> bool { - unsafe { - if ztcore::ZT_Identity_hasPrivate(self.capi) != 0 { - return true; - } - } - false + unsafe { ztcore::ZT_Identity_hasPrivate(self.capi) != 0 } } /// Obtain the full fingerprint of this identity, which includes a SHA384 hash of the public key. @@ -138,16 +130,9 @@ impl Identity { } /// Verify a signature by this identity. + #[inline(always)] pub fn verify(&self, data: &[u8], signature: &[u8]) -> bool { - if signature.len() == 0 { - return false; - } - unsafe { - if ztcore::ZT_Identity_verify(self.capi, data.as_ptr() as *const c_void, data.len() as c_uint, signature.as_ptr() as *const c_void, signature.len() as c_uint) != 0 { - return true; - } - } - false + unsafe { signature.len() > 0 && ztcore::ZT_Identity_verify(self.capi, data.as_ptr() as *const c_void, data.len() as c_uint, signature.as_ptr() as *const c_void, signature.len() as c_uint) != 0 } } } diff --git a/rust-zerotier-core/src/inetaddress.rs b/rust-zerotier-core/src/inetaddress.rs index 5319e34e3..e7a165b56 100644 --- a/rust-zerotier-core/src/inetaddress.rs +++ b/rust-zerotier-core/src/inetaddress.rs @@ -95,6 +95,7 @@ impl InetAddress { /// Unsafely transmute a raw sockaddr_storage structure into an InetAddress. /// The type S MUST have a size equal to the size of this type and the /// OS's sockaddr_storage. If not, this may crash. + #[inline(always)] pub unsafe fn transmute_raw_sockaddr_storage(ss: &S) -> &InetAddress { transmute(ss) } @@ -149,12 +150,14 @@ impl InetAddress { } } + #[inline(always)] pub fn port(&self) -> u16 { unsafe { ztcore::ZT_InetAddress_port(self.as_capi_ptr()) as u16 } } + #[inline(always)] pub fn set_port(&mut self, port: u16) { unsafe { ztcore::ZT_InetAddress_setPort(self.as_capi_mut_ptr(), port as c_uint); @@ -162,6 +165,7 @@ impl InetAddress { } /// Get the network scope of the IP in this object. + #[inline(always)] pub fn ip_scope(&self) -> IpScope { unsafe { IpScope::from_i32(ztcore::ZT_InetAddress_ipScope(self.as_capi_ptr()) as i32).unwrap_or(IpScope::None) diff --git a/rust-zerotier-core/src/locator.rs b/rust-zerotier-core/src/locator.rs index 912d2279e..1661fd1eb 100644 --- a/rust-zerotier-core/src/locator.rs +++ b/rust-zerotier-core/src/locator.rs @@ -23,7 +23,7 @@ pub struct Locator { } impl Locator { - #[inline] + #[inline(always)] pub(crate) fn new_from_capi(l: *const ztcore::ZT_Locator, requires_delete: bool) -> Locator { Locator{ capi: l, @@ -46,6 +46,7 @@ impl Locator { } } + #[inline(always)] pub fn timestamp(&self) -> i64 { unsafe { return ztcore::ZT_Locator_timestamp(self.capi) as i64; diff --git a/rust-zerotier-core/src/mac.rs b/rust-zerotier-core/src/mac.rs index e712db1bb..833cf0cdf 100644 --- a/rust-zerotier-core/src/mac.rs +++ b/rust-zerotier-core/src/mac.rs @@ -47,6 +47,13 @@ impl PartialEq for MAC { impl Eq for MAC {} +impl Clone for MAC { + #[inline(always)] + fn clone(&self) -> Self { + MAC(self.0) + } +} + struct AddressVisitor; impl<'de> serde::de::Visitor<'de> for AddressVisitor { diff --git a/rust-zerotier-core/src/networkid.rs b/rust-zerotier-core/src/networkid.rs index 06e5cf14b..c05f3d8cd 100644 --- a/rust-zerotier-core/src/networkid.rs +++ b/rust-zerotier-core/src/networkid.rs @@ -23,7 +23,6 @@ impl NetworkId { } impl ToString for NetworkId { - #[inline(always)] fn to_string(&self) -> String { format!("{:0>16x}", self.0) } diff --git a/rust-zerotier-core/src/node.rs b/rust-zerotier-core/src/node.rs index 19ded2938..0b96f79e8 100644 --- a/rust-zerotier-core/src/node.rs +++ b/rust-zerotier-core/src/node.rs @@ -11,7 +11,6 @@ */ /****/ -use std::any::Any; use std::cell::Cell; use std::collections::hash_map::HashMap; use std::ffi::CStr; @@ -67,12 +66,12 @@ pub struct NodeStatus { /// An event handler that receives events, frames, and packets from the core. /// Note that these handlers can be called concurrently from any thread and /// must be thread safe. -pub trait NodeEventHandler { +pub trait NodeEventHandler { /// Called when a configuration change or update should be applied to a network. - fn virtual_network_config(&self, network_id: NetworkId, network_obj: &Arc, config_op: VirtualNetworkConfigOperation, config: Option<&VirtualNetworkConfig>); + fn virtual_network_config(&self, network_id: NetworkId, network_obj: &Arc, config_op: VirtualNetworkConfigOperation, config: Option<&VirtualNetworkConfig>); /// Called when a frame should be injected into the virtual network (physical -> virtual). - fn virtual_network_frame(&self, network_id: NetworkId, network_obj: &Arc, source_mac: MAC, dest_mac: MAC, ethertype: u16, vlan_id: u16, data: &[u8]); + fn virtual_network_frame(&self, network_id: NetworkId, network_obj: &Arc, source_mac: MAC, dest_mac: MAC, ethertype: u16, vlan_id: u16, data: &[u8]); /// Called when a core ZeroTier event occurs. fn event(&self, event: Event, event_data: &[u8]); @@ -96,13 +95,13 @@ pub trait NodeEventHandler { /// An instance of the ZeroTier core. /// This is templated on the actual implementation of NodeEventHandler for performance reasons, /// as it avoids an extra indirect function call. -pub struct Node { +pub struct Node + 'static, N: 'static> { event_handler: Arc, capi: Cell<*mut ztcore::ZT_Node>, background_thread: Cell>>, background_thread_run: Arc, now: PortableAtomicI64, - networks_by_id: Mutex>> // pointer to an Arc<> is a raw value created from Box> + networks_by_id: Mutex>> // pointer to an Arc<> is a raw value created from Box> } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -110,14 +109,14 @@ pub struct Node { macro_rules! node_from_raw_ptr { ($uptr:ident) => { unsafe { - let ntmp: *const Node = $uptr.cast::>(); - let ntmp: &Node = &*ntmp; + let ntmp: *const Node = $uptr.cast::>(); + let ntmp: &Node = &*ntmp; ntmp } } } -extern "C" fn zt_virtual_network_config_function( +extern "C" fn zt_virtual_network_config_function + 'static, N: 'static>( _: *mut ztcore::ZT_Node, uptr: *mut c_void, _: *mut c_void, @@ -130,7 +129,7 @@ extern "C" fn zt_virtual_network_config_function( if op2.is_some() { let op2 = op2.unwrap(); let n = node_from_raw_ptr!(uptr); - let network_obj: &Arc = unsafe { &*((*nptr).cast::>()) }; + let network_obj = unsafe { &*((*nptr).cast::>()) }; if conf.is_null() { n.event_handler.virtual_network_config(NetworkId(nwid), network_obj, op2, None); } else { @@ -140,7 +139,7 @@ extern "C" fn zt_virtual_network_config_function( } } -extern "C" fn zt_virtual_network_frame_function( +extern "C" fn zt_virtual_network_frame_function + 'static, N: 'static>( _: *mut ztcore::ZT_Node, uptr: *mut c_void, _: *mut c_void, @@ -157,7 +156,7 @@ extern "C" fn zt_virtual_network_frame_function( let n = node_from_raw_ptr!(uptr); n.event_handler.virtual_network_frame( NetworkId(nwid), - unsafe { &*((*nptr).cast::>()) }, + unsafe { &*((*nptr).cast::>()) }, MAC(source_mac), MAC(dest_mac), ethertype as u16, @@ -166,7 +165,7 @@ extern "C" fn zt_virtual_network_frame_function( } } -extern "C" fn zt_event_callback( +extern "C" fn zt_event_callback + 'static, N: 'static>( _: *mut ztcore::ZT_Node, uptr: *mut c_void, _: *mut c_void, @@ -187,7 +186,7 @@ extern "C" fn zt_event_callback( } } -extern "C" fn zt_state_put_function( +extern "C" fn zt_state_put_function + 'static, N: 'static>( _: *mut ztcore::ZT_Node, uptr: *mut c_void, _: *mut c_void, @@ -207,7 +206,7 @@ extern "C" fn zt_state_put_function( } } -extern "C" fn zt_state_get_function( +extern "C" fn zt_state_get_function + 'static, N: 'static>( _: *mut ztcore::ZT_Node, uptr: *mut c_void, _: *mut c_void, @@ -249,7 +248,7 @@ extern "C" fn zt_state_get_function( return -1; } -extern "C" fn zt_wire_packet_send_function( +extern "C" fn zt_wire_packet_send_function + 'static, N: 'static>( _: *mut ztcore::ZT_Node, uptr: *mut c_void, _: *mut c_void, @@ -263,7 +262,7 @@ extern "C" fn zt_wire_packet_send_function( return n.event_handler.wire_packet_send(local_socket, InetAddress::transmute_capi(unsafe { &*sock_addr }), unsafe { &*slice_from_raw_parts(data.cast::(), data_size as usize) }, packet_ttl as u32) as c_int; } -extern "C" fn zt_path_check_function( +extern "C" fn zt_path_check_function + 'static, N: 'static>( _: *mut ztcore::ZT_Node, uptr: *mut c_void, _: *mut c_void, @@ -280,7 +279,7 @@ extern "C" fn zt_path_check_function( return 0; } -extern "C" fn zt_path_lookup_function( +extern "C" fn zt_path_lookup_function + 'static, N: 'static>( _: *mut ztcore::ZT_Node, uptr: *mut c_void, _: *mut c_void, @@ -319,9 +318,9 @@ extern "C" fn zt_path_lookup_function( ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -impl Node { +impl + 'static, N: 'static> Node { /// Create a new Node with a given event handler. - pub fn new(event_handler: Arc) -> Result>, ResultCode> { + pub fn new(event_handler: Arc) -> Result>, ResultCode> { let now = now(); let n = Arc::new(Node { @@ -336,14 +335,14 @@ impl Node { let mut capi: *mut ztcore::ZT_Node = null_mut(); unsafe { let callbacks = ztcore::ZT_Node_Callbacks { - statePutFunction: transmute(zt_state_put_function:: as *const ()), - stateGetFunction: transmute(zt_state_get_function:: as *const ()), - wirePacketSendFunction: transmute(zt_wire_packet_send_function:: as *const ()), - virtualNetworkFrameFunction: transmute(zt_virtual_network_frame_function:: as *const ()), - virtualNetworkConfigFunction: transmute(zt_virtual_network_config_function:: as *const ()), - eventCallback: transmute(zt_event_callback:: as *const ()), - pathCheckFunction: transmute(zt_path_check_function:: as *const ()), - pathLookupFunction: transmute(zt_path_lookup_function:: as *const ()), + statePutFunction: transmute(zt_state_put_function:: as *const ()), + stateGetFunction: transmute(zt_state_get_function:: as *const ()), + wirePacketSendFunction: transmute(zt_wire_packet_send_function:: as *const ()), + virtualNetworkFrameFunction: transmute(zt_virtual_network_frame_function:: as *const ()), + virtualNetworkConfigFunction: transmute(zt_virtual_network_config_function:: as *const ()), + eventCallback: transmute(zt_event_callback:: as *const ()), + pathCheckFunction: transmute(zt_path_check_function:: as *const ()), + pathLookupFunction: transmute(zt_path_lookup_function:: as *const ()), }; let rc = ztcore::ZT_Node_new(&mut capi as *mut *mut ztcore::ZT_Node, transmute(Arc::as_ptr(&n)), null_mut(), &callbacks as *const ztcore::ZT_Node_Callbacks, now); @@ -396,7 +395,7 @@ impl Node { next_delay } - pub fn join(&self, nwid: NetworkId, controller_fingerprint: Option, network_obj: &Arc) -> ResultCode { + pub fn join(&self, nwid: NetworkId, controller_fingerprint: Option, network_obj: &Arc) -> ResultCode { let mut cfp: MaybeUninit = MaybeUninit::uninit(); let mut cfpp: *mut ztcore::ZT_Fingerprint = null_mut(); if controller_fingerprint.is_some() { @@ -458,12 +457,14 @@ impl Node { rc } + #[inline(always)] pub fn multicast_subscribe(&self, nwid: &NetworkId, multicast_group: &MAC, multicast_adi: u32) -> ResultCode { unsafe { return ResultCode::from_i32(ztcore::ZT_Node_multicastSubscribe(self.capi.get(), null_mut(), nwid.0, multicast_group.0, multicast_adi as c_ulong) as i32).unwrap_or(ResultCode::ErrorInternalNonFatal); } } + #[inline(always)] pub fn multicast_unsubscribe(&self, nwid: &NetworkId, multicast_group: &MAC, multicast_adi: u32) -> ResultCode { unsafe { return ResultCode::from_i32(ztcore::ZT_Node_multicastUnsubscribe(self.capi.get(), nwid.0, multicast_group.0, multicast_adi as c_ulong) as i32).unwrap_or(ResultCode::ErrorInternalNonFatal); @@ -471,6 +472,7 @@ impl Node { } /// Get a copy of this node's identity. + #[inline(always)] pub fn identity(&self) -> Identity { unsafe { self.identity_fast().clone() } } @@ -550,11 +552,11 @@ impl Node { } } -unsafe impl Sync for Node {} +unsafe impl + 'static, N: 'static> Sync for Node {} -unsafe impl Send for Node {} +unsafe impl + 'static, N: 'static> Send for Node {} -impl Drop for Node { +impl + 'static,N: 'static> Drop for Node { fn drop(&mut self) { self.background_thread_run.store(false, Ordering::Relaxed); let bt = self.background_thread.replace(None); diff --git a/rust-zerotier-core/src/path.rs b/rust-zerotier-core/src/path.rs index abf08ebcd..24a160d30 100644 --- a/rust-zerotier-core/src/path.rs +++ b/rust-zerotier-core/src/path.rs @@ -13,8 +13,8 @@ use serde::{Deserialize, Serialize}; -use crate::*; use crate::bindings::capi as ztcore; +use crate::Endpoint; #[derive(Serialize, Deserialize)] pub struct Path { diff --git a/rust-zerotier-core/src/virtualnetworkconfig.rs b/rust-zerotier-core/src/virtualnetworkconfig.rs index 348369ad3..28bf2eeec 100644 --- a/rust-zerotier-core/src/virtualnetworkconfig.rs +++ b/rust-zerotier-core/src/virtualnetworkconfig.rs @@ -20,7 +20,7 @@ use crate::bindings::capi as ztcore; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#[derive(FromPrimitive,ToPrimitive, PartialEq, Eq)] +#[derive(FromPrimitive,ToPrimitive, PartialEq, Eq, Clone)] pub enum VirtualNetworkType { Private = ztcore::ZT_VirtualNetworkType_ZT_NETWORK_TYPE_PRIVATE as isize, Public = ztcore::ZT_VirtualNetworkType_ZT_NETWORK_TYPE_PUBLIC as isize @@ -81,7 +81,7 @@ impl<'de> serde::Deserialize<'de> for VirtualNetworkType { ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#[derive(FromPrimitive,ToPrimitive, PartialEq, Eq)] +#[derive(FromPrimitive,ToPrimitive, PartialEq, Eq, Clone)] pub enum VirtualNetworkRuleType { ActionDrop = ztcore::ZT_VirtualNetworkRuleType_ZT_NETWORK_RULE_ACTION_DROP as isize, ActionAccept = ztcore::ZT_VirtualNetworkRuleType_ZT_NETWORK_RULE_ACTION_ACCEPT as isize, @@ -122,7 +122,7 @@ pub enum VirtualNetworkRuleType { ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#[derive(FromPrimitive,ToPrimitive, PartialEq, Eq)] +#[derive(FromPrimitive,ToPrimitive, PartialEq, Eq, Clone)] pub enum VirtualNetworkConfigOperation { Up = ztcore::ZT_VirtualNetworkConfigOperation_ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_UP as isize, ConfigUpdate = ztcore::ZT_VirtualNetworkConfigOperation_ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE as isize, @@ -132,7 +132,7 @@ pub enum VirtualNetworkConfigOperation { ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#[derive(FromPrimitive,ToPrimitive, PartialEq, Eq)] +#[derive(FromPrimitive,ToPrimitive, PartialEq, Eq, Clone)] pub enum VirtualNetworkStatus { RequestingConfiguration = ztcore::ZT_VirtualNetworkStatus_ZT_NETWORK_STATUS_REQUESTING_CONFIGURATION as isize, Ok = ztcore::ZT_VirtualNetworkStatus_ZT_NETWORK_STATUS_OK as isize, @@ -198,7 +198,7 @@ impl<'de> serde::Deserialize<'de> for VirtualNetworkStatus { ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#[derive(Serialize, Deserialize, PartialEq, Eq)] +#[derive(Serialize, Deserialize, PartialEq, Eq, Clone)] pub struct VirtualNetworkRoute { pub target: Option, pub via: Option, @@ -208,7 +208,7 @@ pub struct VirtualNetworkRoute { ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#[derive(Serialize, Deserialize, PartialEq, Eq)] +#[derive(Serialize, Deserialize, PartialEq, Eq, Clone)] pub struct VirtualNetworkConfig { pub nwid: NetworkId, pub mac: MAC, diff --git a/rust-zerotier-service/src/fastudpsocket.rs b/rust-zerotier-service/src/fastudpsocket.rs index b91e29e59..13e603e4d 100644 --- a/rust-zerotier-service/src/fastudpsocket.rs +++ b/rust-zerotier-service/src/fastudpsocket.rs @@ -1,3 +1,16 @@ +/* + * Copyright (c)2013-2020 ZeroTier, Inc. + * + * Use of this software is governed by the Business Source License included + * in the LICENSE.TXT file in the project's root directory. + * + * Change Date: 2025-01-01 + * + * On the date above, in accordance with the Business Source License, use + * of this software will be governed by version 2.0 of the Apache License. + */ +/****/ + use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; use zerotier_core::{Buffer, InetAddress, InetAddressFamily}; @@ -264,7 +277,7 @@ impl Drop for FastUDPSock #[cfg(test)] mod tests { - use crate::fastudp::*; + use crate::fastudpsocket::*; use zerotier_core::{InetAddress, Buffer}; use std::sync::Arc; use std::sync::atomic::{AtomicU32, Ordering}; diff --git a/rust-zerotier-service/src/localconfig.rs b/rust-zerotier-service/src/localconfig.rs index fe01c3fdf..6e29e32a4 100644 --- a/rust-zerotier-service/src/localconfig.rs +++ b/rust-zerotier-service/src/localconfig.rs @@ -1,3 +1,16 @@ +/* + * Copyright (c)2013-2020 ZeroTier, Inc. + * + * Use of this software is governed by the Business Source License included + * in the LICENSE.TXT file in the project's root directory. + * + * Change Date: 2025-01-01 + * + * On the date above, in accordance with the Business Source License, use + * of this software will be governed by version 2.0 of the Apache License. + */ +/****/ + use std::collections::BTreeMap; use zerotier_core::{InetAddress, Address, NetworkId}; use serde::{Deserialize, Serialize}; diff --git a/rust-zerotier-service/src/log.rs b/rust-zerotier-service/src/log.rs index 0ca661849..7fffc3c7c 100644 --- a/rust-zerotier-service/src/log.rs +++ b/rust-zerotier-service/src/log.rs @@ -1,3 +1,16 @@ +/* + * Copyright (c)2013-2020 ZeroTier, Inc. + * + * Use of this software is governed by the Business Source License included + * in the LICENSE.TXT file in the project's root directory. + * + * Change Date: 2025-01-01 + * + * On the date above, in accordance with the Business Source License, use + * of this software will be governed by version 2.0 of the Apache License. + */ +/****/ + use std::fs::{File, OpenOptions}; use std::sync::Mutex; use std::sync::atomic::{AtomicUsize, Ordering}; diff --git a/rust-zerotier-service/src/main.rs b/rust-zerotier-service/src/main.rs index a6d7f58dc..b3ebe514b 100644 --- a/rust-zerotier-service/src/main.rs +++ b/rust-zerotier-service/src/main.rs @@ -1,10 +1,23 @@ +/* + * Copyright (c)2013-2020 ZeroTier, Inc. + * + * Use of this software is governed by the Business Source License included + * in the LICENSE.TXT file in the project's root directory. + * + * Change Date: 2025-01-01 + * + * On the date above, in accordance with the Business Source License, use + * of this software will be governed by version 2.0 of the Apache License. + */ +/****/ + mod fastudpsocket; mod localconfig; mod physicallink; mod log; mod store; +mod network; -use std::any::Any; use std::cell::Cell; use std::collections::BTreeMap; use std::net::IpAddr; @@ -16,26 +29,28 @@ use std::time::Duration; use warp::Filter; -use zerotier_core::{Address, Buffer, Event, Identity, InetAddress, InetAddressFamily, MAC, NetworkId, Node, NodeEventHandler, StateObjectType, VirtualNetworkConfig, VirtualNetworkConfigOperation}; +use zerotier_core::*; use crate::fastudpsocket::*; use crate::localconfig::*; -use crate::physicallink::PhysicalLink; use crate::log::Log; - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +use crate::physicallink::PhysicalLink; +use crate::network::Network; pub struct ServiceEventHandler {} impl FastUDPSocketPacketHandler for ServiceEventHandler { - fn incoming_udp_packet(&self, raw_socket: &FastUDPRawOsSocket, from_adddress: &InetAddress, data: Buffer) {} + #[inline(always)] + fn incoming_udp_packet(&self, raw_socket: &FastUDPRawOsSocket, from_adddress: &InetAddress, data: Buffer) { + } } -impl NodeEventHandler for ServiceEventHandler { - fn virtual_network_config(&self, network_id: NetworkId, network_obj: &Arc, config_op: VirtualNetworkConfigOperation, config: Option<&VirtualNetworkConfig>) { +impl NodeEventHandler for ServiceEventHandler { + fn virtual_network_config(&self, network_id: NetworkId, network_obj: &Arc, config_op: VirtualNetworkConfigOperation, config: Option<&VirtualNetworkConfig>) { } - fn virtual_network_frame(&self, network_id: NetworkId, network_obj: &Arc, source_mac: MAC, dest_mac: MAC, ethertype: u16, vlan_id: u16, data: &[u8]) { + #[inline(always)] + fn virtual_network_frame(&self, network_id: NetworkId, network_obj: &Arc, source_mac: MAC, dest_mac: MAC, ethertype: u16, vlan_id: u16, data: &[u8]) { } fn event(&self, event: Event, event_data: &[u8]) { @@ -48,6 +63,7 @@ impl NodeEventHandler for ServiceEventHandler { None } + #[inline(always)] fn wire_packet_send(&self, local_socket: i64, sock_addr: &InetAddress, data: &[u8], packet_ttl: u32) -> i32 { 0 } @@ -61,8 +77,6 @@ impl NodeEventHandler for ServiceEventHandler { } } -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - fn main() { tokio::runtime::Builder::new_multi_thread().thread_stack_size(zerotier_core::RECOMMENDED_THREAD_STACK_SIZE).build().unwrap().block_on(async { let inaddr_v6_any = IpAddr::from_str("::0").unwrap(); diff --git a/rust-zerotier-service/src/network.rs b/rust-zerotier-service/src/network.rs new file mode 100644 index 000000000..d625df7d6 --- /dev/null +++ b/rust-zerotier-service/src/network.rs @@ -0,0 +1,4 @@ +pub struct Network {} + +impl Network { +} diff --git a/rust-zerotier-service/src/physicallink.rs b/rust-zerotier-service/src/physicallink.rs index 7a4700f58..0a0108bd3 100644 --- a/rust-zerotier-service/src/physicallink.rs +++ b/rust-zerotier-service/src/physicallink.rs @@ -1,3 +1,16 @@ +/* + * Copyright (c)2013-2020 ZeroTier, Inc. + * + * Use of this software is governed by the Business Source License included + * in the LICENSE.TXT file in the project's root directory. + * + * Change Date: 2025-01-01 + * + * On the date above, in accordance with the Business Source License, use + * of this software will be governed by version 2.0 of the Apache License. + */ +/****/ + use zerotier_core::InetAddress; use std::ffi::CStr; use std::ptr::{null_mut, copy_nonoverlapping}; diff --git a/rust-zerotier-service/src/store.rs b/rust-zerotier-service/src/store.rs index d8f5dafc8..780ee7d34 100644 --- a/rust-zerotier-service/src/store.rs +++ b/rust-zerotier-service/src/store.rs @@ -1,3 +1,16 @@ +/* + * Copyright (c)2013-2020 ZeroTier, Inc. + * + * Use of this software is governed by the Business Source License included + * in the LICENSE.TXT file in the project's root directory. + * + * Change Date: 2025-01-01 + * + * On the date above, in accordance with the Business Source License, use + * of this software will be governed by version 2.0 of the Apache License. + */ +/****/ + use std::error::Error; use std::path::{Path, PathBuf}; use zerotier_core::StateObjectType;