From 7d2eb94259a945f60f88cf0613b9b2ac46bc3170 Mon Sep 17 00:00:00 2001 From: Petr Sumbera Date: Wed, 22 May 2024 17:38:11 +0200 Subject: [PATCH] Add missing networking support for Solaris --- libc-test/semver/solarish.txt | 13 +++++++++++++ src/unix/mod.rs | 30 ++++++++++++++++++++++++------ src/unix/solarish/mod.rs | 26 ++++++++++++++++++++++---- 3 files changed, 59 insertions(+), 10 deletions(-) diff --git a/libc-test/semver/solarish.txt b/libc-test/semver/solarish.txt index 069508925c8ef..8f51b3ceca6fa 100644 --- a/libc-test/semver/solarish.txt +++ b/libc-test/semver/solarish.txt @@ -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 diff --git a/src/unix/mod.rs b/src/unix/mod.rs index b67b5a93e3541..bc65d21615a92 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -590,7 +590,10 @@ 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")))] @@ -598,7 +601,10 @@ extern "C" { 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( @@ -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, @@ -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, @@ -1137,7 +1149,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, @@ -1156,7 +1171,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, diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index ab8070dd3f077..27f3bf920c116 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -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, @@ -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! { @@ -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; @@ -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,