From 53f33b15ba681f7536a3c1ad9f34b80dcacc6db3 Mon Sep 17 00:00:00 2001 From: Erik Hollensbe Date: Wed, 29 Jun 2022 12:34:56 -0700 Subject: [PATCH] correct warnings and compile errors on linux Signed-off-by: Erik Hollensbe --- zerotier-network-hypervisor/src/vl1/inetaddress.rs | 4 ++-- zerotier-network-hypervisor/src/vl1/node.rs | 1 + zerotier-network-hypervisor/src/vl1/protocol.rs | 4 ++-- zerotier-system-service/src/cli/rootset.rs | 4 ++-- zerotier-system-service/src/ipv6.rs | 6 ++++++ zerotier-system-service/src/udp.rs | 12 ++++++------ 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/zerotier-network-hypervisor/src/vl1/inetaddress.rs b/zerotier-network-hypervisor/src/vl1/inetaddress.rs index e67110642..65d6ff756 100644 --- a/zerotier-network-hypervisor/src/vl1/inetaddress.rs +++ b/zerotier-network-hypervisor/src/vl1/inetaddress.rs @@ -478,8 +478,8 @@ impl InetAddress { /// Get the address family of this InetAddress: AF_INET, AF_INET6, or 0 if uninitialized. #[inline(always)] - pub fn family(&self) -> u8 { - unsafe { self.sa.sa_family as u8 } + pub fn family(&self) -> AddressFamilyType { + unsafe { self.sa.sa_family as AddressFamilyType } } /// Get a pointer to the C "sockaddr" structure and the size of the returned structure in bytes. diff --git a/zerotier-network-hypervisor/src/vl1/node.rs b/zerotier-network-hypervisor/src/vl1/node.rs index d9cc9871b..187a5bcad 100644 --- a/zerotier-network-hypervisor/src/vl1/node.rs +++ b/zerotier-network-hypervisor/src/vl1/node.rs @@ -650,6 +650,7 @@ impl Node { self.roots.read().my_root_sets.clone() } + #[allow(unused)] pub(crate) fn this_node_is_root(&self) -> bool { self.roots.read().my_root_sets.is_some() } diff --git a/zerotier-network-hypervisor/src/vl1/protocol.rs b/zerotier-network-hypervisor/src/vl1/protocol.rs index 7581cec38..67b3f893a 100644 --- a/zerotier-network-hypervisor/src/vl1/protocol.rs +++ b/zerotier-network-hypervisor/src/vl1/protocol.rs @@ -491,8 +491,8 @@ mod tests { #[test] fn representation() { - assert_eq!(size_of::(), 9); - assert_eq!(size_of::(), 10); + assert_eq!(size_of::(), 10); + assert_eq!(size_of::(), 11); assert_eq!(size_of::(), packet_constants::HEADER_SIZE); assert_eq!(size_of::(), packet_constants::FRAGMENT_HEADER_SIZE); diff --git a/zerotier-system-service/src/cli/rootset.rs b/zerotier-system-service/src/cli/rootset.rs index 7da5281c4..1dcc9248d 100644 --- a/zerotier-system-service/src/cli/rootset.rs +++ b/zerotier-system-service/src/cli/rootset.rs @@ -11,9 +11,9 @@ use zerotier_network_hypervisor::vl1::RootSet; pub async fn cmd(_: Flags, cmd_args: &ArgMatches) -> i32 { match cmd_args.subcommand() { - Some(("add", sc_args)) => todo!(), + Some(("add", _sc_args)) => todo!(), - Some(("remove", sc_args)) => todo!(), + Some(("remove", _sc_args)) => todo!(), Some(("list", _)) => todo!(), diff --git a/zerotier-system-service/src/ipv6.rs b/zerotier-system-service/src/ipv6.rs index ef0a1c808..bbeb4d65f 100644 --- a/zerotier-system-service/src/ipv6.rs +++ b/zerotier-system-service/src/ipv6.rs @@ -68,3 +68,9 @@ mod freebsd_like { #[cfg(any(target_os = "macos", target_os = "ios", target_os = "freebsd", target_os = "darwin"))] pub use freebsd_like::is_ipv6_temporary; + +use zerotier_network_hypervisor::vl1::InetAddress; +#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "freebsd", target_os = "darwin")))] +pub fn is_ipv6_temporary(_device_name: &str, _address: &InetAddress) -> bool { + false +} diff --git a/zerotier-system-service/src/udp.rs b/zerotier-system-service/src/udp.rs index 305750b97..fadd3e819 100644 --- a/zerotier-system-service/src/udp.rs +++ b/zerotier-system-service/src/udp.rs @@ -201,8 +201,8 @@ impl BoundUdpPort { #[cfg(unix)] unsafe fn bind_udp_to_device(device_name: &str, address: &InetAddress) -> Result { let (af, sa_len) = match address.family() { - AF_INET => (libc::AF_INET, std::mem::size_of::().as_()), - AF_INET6 => (libc::AF_INET6, std::mem::size_of::().as_()), + AF_INET => (AF_INET, std::mem::size_of::().as_()), + AF_INET6 => (AF_INET6, std::mem::size_of::().as_()), _ => { return Err("unrecognized address family"); } @@ -226,7 +226,7 @@ unsafe fn bind_udp_to_device(device_name: &str, address: &InetAddress) -> Result fl = 1; setsockopt_results |= libc::setsockopt(s, libc::SOL_SOCKET.as_(), libc::SO_BROADCAST.as_(), (&mut fl as *mut libc::c_int).cast(), std::mem::size_of::().as_()); debug_assert!(setsockopt_results == 0); - if af == libc::AF_INET6 { + if af == AF_INET6 { fl = 1; setsockopt_results |= libc::setsockopt(s, libc::IPPROTO_IPV6.as_(), libc::IPV6_V6ONLY.as_(), (&mut fl as *mut libc::c_int).cast(), std::mem::size_of::().as_()); debug_assert!(setsockopt_results == 0); @@ -247,7 +247,7 @@ unsafe fn bind_udp_to_device(device_name: &str, address: &InetAddress) -> Result return Err("setsockopt() failed"); } - if af == libc::AF_INET { + if af == AF_INET { #[cfg(not(target_os = "linux"))] { fl = 0; @@ -255,12 +255,12 @@ unsafe fn bind_udp_to_device(device_name: &str, address: &InetAddress) -> Result } #[cfg(target_os = "linux")] { - fl = libc::IP_PMTUDISC_DONT as c_int; + fl = libc::IP_PMTUDISC_DONT as libc::c_int; libc::setsockopt(s, libc::IPPROTO_IP.as_(), libc::IP_MTU_DISCOVER.as_(), (&mut fl as *mut libc::c_int).cast(), std::mem::size_of::().as_()); } } - if af == libc::AF_INET6 { + if af == AF_INET6 { fl = 0; libc::setsockopt(s, libc::IPPROTO_IPV6.as_(), libc::IPV6_DONTFRAG.as_(), (&mut fl as *mut libc::c_int).cast(), std::mem::size_of::().as_()); }