Skip to content

Commit

Permalink
Merge pull request #3717 from psumbera/quinn
Browse files Browse the repository at this point in the history
Add missing networking support for Illumos/Solaris as used in quinn
  • Loading branch information
tgross35 authored Aug 13, 2024
2 parents 07509d7 + 7d2eb94 commit b496aac
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 10 deletions.
13 changes: 13 additions & 0 deletions libc-test/semver/solarish.txt
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
IPV6_DONTFRAG
IPV6_PKTINFO
IPV6_RECVTCLASS
IPV6_TCLASS
IP_DONTFRAG
IP_PKTINFO
IP_TOS
IP_TTL
PIPE_BUF
bind
in6_pktinfo
in_pktinfo
recvmsg
sendmsg
30 changes: 24 additions & 6 deletions src/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,15 +590,21 @@ extern "C" {

#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
#[cfg_attr(target_os = "netbsd", link_name = "__socket30")]
#[cfg_attr(target_os = "illumos", link_name = "__xnet_socket")]
#[cfg_attr(
any(target_os = "illumos", target_os = "solaris"),
link_name = "__xnet_socket"
)]
#[cfg_attr(target_os = "espidf", link_name = "lwip_socket")]
pub fn socket(domain: ::c_int, ty: ::c_int, protocol: ::c_int) -> ::c_int;
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
#[cfg_attr(
all(target_os = "macos", target_arch = "x86"),
link_name = "connect$UNIX2003"
)]
#[cfg_attr(target_os = "illumos", link_name = "__xnet_connect")]
#[cfg_attr(
any(target_os = "illumos", target_os = "solaris"),
link_name = "__xnet_connect"
)]
#[cfg_attr(target_os = "espidf", link_name = "lwip_connect")]
pub fn connect(socket: ::c_int, address: *const sockaddr, len: socklen_t) -> ::c_int;
#[cfg_attr(
Expand Down Expand Up @@ -648,7 +654,10 @@ extern "C" {
all(target_os = "macos", target_arch = "x86"),
link_name = "socketpair$UNIX2003"
)]
#[cfg_attr(target_os = "illumos", link_name = "__xnet_socketpair")]
#[cfg_attr(
any(target_os = "illumos", target_os = "solaris"),
link_name = "__xnet_socketpair"
)]
pub fn socketpair(
domain: ::c_int,
type_: ::c_int,
Expand All @@ -660,7 +669,10 @@ extern "C" {
all(target_os = "macos", target_arch = "x86"),
link_name = "sendto$UNIX2003"
)]
#[cfg_attr(target_os = "illumos", link_name = "__xnet_sendto")]
#[cfg_attr(
any(target_os = "illumos", target_os = "solaris"),
link_name = "__xnet_sendto"
)]
#[cfg_attr(target_os = "espidf", link_name = "lwip_sendto")]
pub fn sendto(
socket: ::c_int,
Expand Down Expand Up @@ -1138,7 +1150,10 @@ extern "C" {
pub fn pthread_rwlockattr_init(attr: *mut pthread_rwlockattr_t) -> ::c_int;
pub fn pthread_rwlockattr_destroy(attr: *mut pthread_rwlockattr_t) -> ::c_int;

#[cfg_attr(target_os = "illumos", link_name = "__xnet_getsockopt")]
#[cfg_attr(
any(target_os = "illumos", target_os = "solaris"),
link_name = "__xnet_getsockopt"
)]
#[cfg_attr(target_os = "espidf", link_name = "lwip_getsockopt")]
pub fn getsockopt(
sockfd: ::c_int,
Expand All @@ -1157,7 +1172,10 @@ extern "C" {
pub fn dlclose(handle: *mut ::c_void) -> ::c_int;

#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
#[cfg_attr(target_os = "illumos", link_name = "__xnet_getaddrinfo")]
#[cfg_attr(
any(target_os = "illumos", target_os = "solaris"),
link_name = "__xnet_getaddrinfo"
)]
#[cfg_attr(target_os = "espidf", link_name = "lwip_getaddrinfo")]
pub fn getaddrinfo(
node: *const c_char,
Expand Down
26 changes: 22 additions & 4 deletions src/unix/solarish/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,17 @@ s! {
pub __sin6_src_id: u32
}

pub struct in_pktinfo {
pub ipi_ifindex: ::c_uint,
pub ipi_spec_dst: ::in_addr,
pub ipi_addr: ::in_addr,
}

pub struct in6_pktinfo {
pub ipi6_addr: ::in6_addr,
pub ipi6_ifindex: ::c_uint,
}

pub struct passwd {
pub pw_name: *mut ::c_char,
pub pw_passwd: *mut ::c_char,
Expand Down Expand Up @@ -1224,14 +1235,20 @@ pub const CLD_STOPPED: ::c_int = 5;
pub const CLD_CONTINUED: ::c_int = 6;

pub const IP_RECVDSTADDR: ::c_int = 0x7;
pub const IP_PKTINFO: ::c_int = 0x1a;
pub const IP_DONTFRAG: ::c_int = 0x1b;
pub const IP_SEC_OPT: ::c_int = 0x22;

pub const IPV6_UNICAST_HOPS: ::c_int = 0x5;
pub const IPV6_MULTICAST_IF: ::c_int = 0x6;
pub const IPV6_MULTICAST_HOPS: ::c_int = 0x7;
pub const IPV6_MULTICAST_LOOP: ::c_int = 0x8;
pub const IPV6_PKTINFO: ::c_int = 0xb;
pub const IPV6_RECVPKTINFO: ::c_int = 0x12;
pub const IPV6_RECVTCLASS: ::c_int = 0x19;
pub const IPV6_DONTFRAG: ::c_int = 0x21;
pub const IPV6_SEC_OPT: ::c_int = 0x22;
pub const IPV6_TCLASS: ::c_int = 0x26;
pub const IPV6_V6ONLY: ::c_int = 0x27;

cfg_if! {
Expand Down Expand Up @@ -1761,8 +1778,9 @@ pub const SOCK_SEQPACKET: ::c_int = 6;
pub const IP_MULTICAST_IF: ::c_int = 16;
pub const IP_MULTICAST_TTL: ::c_int = 17;
pub const IP_MULTICAST_LOOP: ::c_int = 18;
pub const IP_TTL: ::c_int = 4;
pub const IP_HDRINCL: ::c_int = 2;
pub const IP_TOS: ::c_int = 3;
pub const IP_TTL: ::c_int = 4;
pub const IP_ADD_MEMBERSHIP: ::c_int = 19;
pub const IP_DROP_MEMBERSHIP: ::c_int = 20;
pub const IPV6_JOIN_GROUP: ::c_int = 9;
Expand Down Expand Up @@ -2855,15 +2873,15 @@ extern "C" {
) -> ::c_int;
pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char;

#[cfg_attr(target_os = "illumos", link_name = "__xnet_bind")]
#[link_name = "__xnet_bind"]
pub fn bind(socket: ::c_int, address: *const ::sockaddr, address_len: ::socklen_t) -> ::c_int;

pub fn writev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t;
pub fn readv(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t;

#[cfg_attr(target_os = "illumos", link_name = "__xnet_sendmsg")]
#[link_name = "__xnet_sendmsg"]
pub fn sendmsg(fd: ::c_int, msg: *const ::msghdr, flags: ::c_int) -> ::ssize_t;
#[cfg_attr(target_os = "illumos", link_name = "__xnet_recvmsg")]
#[link_name = "__xnet_recvmsg"]
pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::ssize_t;
pub fn accept4(
fd: ::c_int,
Expand Down

0 comments on commit b496aac

Please sign in to comment.