mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-04-25 08:27:39 +02:00
Merge branch 'master' of github.com:zerotier/tetanus
This commit is contained in:
commit
845751cea0
6 changed files with 19 additions and 12 deletions
|
@ -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.
|
||||
|
|
|
@ -650,6 +650,7 @@ impl<SI: SystemInterface> Node<SI> {
|
|||
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()
|
||||
}
|
||||
|
|
|
@ -491,8 +491,8 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn representation() {
|
||||
assert_eq!(size_of::<message_component_structs::OkHeader>(), 9);
|
||||
assert_eq!(size_of::<message_component_structs::ErrorHeader>(), 10);
|
||||
assert_eq!(size_of::<message_component_structs::OkHeader>(), 10);
|
||||
assert_eq!(size_of::<message_component_structs::ErrorHeader>(), 11);
|
||||
assert_eq!(size_of::<PacketHeader>(), packet_constants::HEADER_SIZE);
|
||||
assert_eq!(size_of::<FragmentHeader>(), packet_constants::FRAGMENT_HEADER_SIZE);
|
||||
|
||||
|
|
|
@ -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!(),
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -201,8 +201,8 @@ impl BoundUdpPort {
|
|||
#[cfg(unix)]
|
||||
unsafe fn bind_udp_to_device(device_name: &str, address: &InetAddress) -> Result<RawFd, &'static str> {
|
||||
let (af, sa_len) = match address.family() {
|
||||
AF_INET => (libc::AF_INET, std::mem::size_of::<libc::sockaddr_in>().as_()),
|
||||
AF_INET6 => (libc::AF_INET6, std::mem::size_of::<libc::sockaddr_in6>().as_()),
|
||||
AF_INET => (AF_INET, std::mem::size_of::<libc::sockaddr_in>().as_()),
|
||||
AF_INET6 => (AF_INET6, std::mem::size_of::<libc::sockaddr_in6>().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::<libc::c_int>().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::<libc::c_int>().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::<libc::c_int>().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::<libc::c_int>().as_());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue