Skip to content

Commit

Permalink
openbsd fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed May 21, 2024
1 parent 76bf133 commit 4c4040f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions iroh-net/src/net/interfaces/bsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}

Expand Down
8 changes: 8 additions & 0 deletions iroh-net/src/net/interfaces/bsd/openbsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 4c4040f

Please sign in to comment.