From 4c4040f67d18fc46753d633761f1ac04e8eab2b7 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Tue, 21 May 2024 15:15:48 +0200 Subject: [PATCH] openbsd fixes --- iroh-net/src/net/interfaces/bsd.rs | 6 +++--- iroh-net/src/net/interfaces/bsd/openbsd.rs | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/iroh-net/src/net/interfaces/bsd.rs b/iroh-net/src/net/interfaces/bsd.rs index 18d203eabb8..e7959da8c7e 100644 --- a/iroh-net/src/net/interfaces/bsd.rs +++ b/iroh-net/src/net/interfaces/bsd.rs @@ -214,7 +214,7 @@ const fn is_valid_rib_type(typ: RIBType) -> bool { } #[cfg(target_os = "openbsd")] -const fn is_valid_rib_type(_typ: RIBType) -> bool { +const fn is_valid_rib_type(typ: RIBType) -> bool { if typ == NET_RT_STATS || typ == NET_RT_TABLE { return false; } @@ -309,8 +309,8 @@ impl WireFormat { if data.len() < l as usize { return Err(RouteError::InvalidMessage); } - let ll = u16_from_ne_range(data, 4..6)?; - if data.len() < ll as usize { + let ll = u16_from_ne_range(data, 4..6)? as usize; + if data.len() < ll { return Err(RouteError::InvalidMessage); } diff --git a/iroh-net/src/net/interfaces/bsd/openbsd.rs b/iroh-net/src/net/interfaces/bsd/openbsd.rs index 75877e94739..04721e0df44 100644 --- a/iroh-net/src/net/interfaces/bsd/openbsd.rs +++ b/iroh-net/src/net/interfaces/bsd/openbsd.rs @@ -43,6 +43,14 @@ pub const SHUT_RD: c_int = 0; pub const SHUT_WR: c_int = 1; pub const SHUT_RDWR: c_int = 2; +// socket.h +pub const NET_RT_STATS: c_int = 5; +pub const NET_RT_TABLE: c_int = 5; + +pub const SIZEOF_SOCKADDR_STORAGE: usize = 0x80; +pub const SIZEOF_SOCKADDR_INET: usize = 0x10; +pub const SIZEOF_SOCKADDR_INET6: usize = 0x1c; + // Hardcoded based on the generated values here: https://cs.opensource.google/go/x/net/+/master:route/sys_openbsd.go pub(super) fn probe_routing_stack() -> RoutingStack {