Skip to content

Commit

Permalink
Add support for QNX Neutrino
Browse files Browse the repository at this point in the history
  • Loading branch information
flba-eb committed Jun 14, 2023
1 parent 2c0abd4 commit 604d0d3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ include = [
winapi = { version = "0.3", features = ["handleapi", "winsock2", "ws2def", "ws2ipdef", "ws2tcpip"] }

[target.'cfg(any(unix, target_os="wasi"))'.dependencies]
libc = "0.2.54"
libc = "0.2.139"

[dependencies]
cfg-if = "0.1"
Expand Down
16 changes: 15 additions & 1 deletion src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ impl<T: AsRawSocket> AsSock for T {
}

cfg_if! {
if #[cfg(any(target_os = "macos", target_os = "ios"))] {
if #[cfg(any(target_os = "macos", target_os = "ios", target_os = "nto"))] {
use libc::TCP_KEEPALIVE as KEEPALIVE_OPTION;
} else if #[cfg(any(target_os = "haiku", target_os = "netbsd", target_os = "openbsd"))] {
use libc::SO_KEEPALIVE as KEEPALIVE_OPTION;
Expand Down Expand Up @@ -1073,6 +1073,7 @@ impl UdpSocketExt for UdpSocket {
set_opt(self.as_sock(), IPPROTO_IP, IP_ADD_MEMBERSHIP, mreq)
}

#[cfg(not(target_os = "nto"))]
fn join_multicast_v6(&self, multiaddr: &Ipv6Addr, interface: u32)
-> io::Result<()> {
let mreq = ipv6_mreq {
Expand All @@ -1083,6 +1084,12 @@ impl UdpSocketExt for UdpSocket {
mreq)
}

#[cfg(target_os = "nto")]
fn join_multicast_v6(&self, _: &Ipv6Addr, _: u32)
-> io::Result<()> {
Err(io::Error::new(io::ErrorKind::Unsupported, "not supported by platform"))
}

fn leave_multicast_v4(&self, multiaddr: &Ipv4Addr, interface: &Ipv4Addr)
-> io::Result<()> {
let mreq = ip_mreq {
Expand All @@ -1092,6 +1099,7 @@ impl UdpSocketExt for UdpSocket {
set_opt(self.as_sock(), IPPROTO_IP, IP_DROP_MEMBERSHIP, mreq)
}

#[cfg(not(target_os = "nto"))]
fn leave_multicast_v6(&self, multiaddr: &Ipv6Addr, interface: u32)
-> io::Result<()> {
let mreq = ipv6_mreq {
Expand All @@ -1102,6 +1110,12 @@ impl UdpSocketExt for UdpSocket {
mreq)
}

#[cfg(target_os = "nto")]
fn leave_multicast_v6(&self, _: &Ipv6Addr, _: u32)
-> io::Result<()> {
Err(io::Error::new(io::ErrorKind::Unsupported, "not supported by platform"))
}

fn set_read_timeout_ms(&self, dur: Option<u32>) -> io::Result<()> {
set_opt(self.as_sock(), SOL_SOCKET, SO_RCVTIMEO,
ms2timeout(dur))
Expand Down
2 changes: 2 additions & 0 deletions src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ fn addr2raw_v4(addr: &SocketAddrV4) -> (SocketAddrCRepr, c::socklen_t) {
target_os = "netbsd",
target_os = "openbsd",
target_os = "haiku",
target_os = "nto",
))]
sin_len: 0,
},
Expand Down Expand Up @@ -179,6 +180,7 @@ fn addr2raw_v6(addr: &SocketAddrV6) -> (SocketAddrCRepr, c::socklen_t) {
target_os = "netbsd",
target_os = "openbsd",
target_os = "haiku",
target_os = "nto",
))]
sin6_len: 0,
#[cfg(any(target_os = "solaris", target_os = "illumos"))]
Expand Down

0 comments on commit 604d0d3

Please sign in to comment.