libc 1.0.0-alpha.5

Raw FFI bindings to platform libraries like libc.
Documentation
//! Header: `sys/socket.h`
//!
//! * Headers: <https://git.musl-libc.org/cgit/musl/blob/arch/include/sys/socket.h> (official)
//! * Headers: <https://github.com/kraj/musl/blob/kraj/master/include/sys/socket.h> (mirror)

use crate::prelude::*;

s! {
    pub struct msghdr {
        pub msg_name: *mut c_void,
        pub msg_namelen: crate::socklen_t,
        pub msg_iov: *mut crate::iovec,
        #[cfg(all(target_pointer_width = "64", target_endian = "big"))]
        __pad1: Padding<c_int>,
        pub msg_iovlen: c_int,
        #[cfg(all(target_pointer_width = "64", target_endian = "little"))]
        __pad1: Padding<c_int>,
        pub msg_control: *mut c_void,
        #[cfg(all(target_pointer_width = "64", target_endian = "big"))]
        __pad2: Padding<c_int>,
        pub msg_controllen: crate::socklen_t,
        #[cfg(all(target_pointer_width = "64", target_endian = "little"))]
        __pad2: Padding<c_int>,
        pub msg_flags: c_int,
    }

    pub struct cmsghdr {
        #[cfg(all(target_pointer_width = "64", target_endian = "big"))]
        __pad1: Padding<c_int>,
        pub cmsg_len: crate::socklen_t,
        #[cfg(all(target_pointer_width = "64", target_endian = "little"))]
        __pad1: Padding<c_int>,
        pub cmsg_level: c_int,
        pub cmsg_type: c_int,
    }

    pub struct mmsghdr {
        pub msg_hdr: crate::msghdr,
        pub msg_len: c_uint,
    }
}

extern "C" {
    pub fn sendmmsg(
        sockfd: c_int,
        msgvec: *mut crate::mmsghdr,
        vlen: c_uint,
        flags: c_uint,
    ) -> c_int;
    #[cfg_attr(musl_redir_time64, link_name = "__recvmmsg_time64")]
    pub fn recvmmsg(
        sockfd: c_int,
        msgvec: *mut crate::mmsghdr,
        vlen: c_uint,
        flags: c_uint,
        timeout: *mut crate::timespec,
    ) -> c_int;
}

pub const SHUT_RD: c_int = 0;
pub const SHUT_WR: c_int = 1;
pub const SHUT_RDWR: c_int = 2;

cfg_if! {
    if #[cfg(any(target_arch = "mips", target_arch = "mips64"))] {
        pub use crate::bits::socket::{
            SOCK_DGRAM,
            SOCK_STREAM,
        };
    } else {
        pub const SOCK_STREAM: c_int = 1;
        pub const SOCK_DGRAM: c_int = 2;
    }
}

pub const SOCK_RAW: c_int = 3;
pub const SOCK_RDM: c_int = 4;
pub const SOCK_SEQPACKET: c_int = 5;
pub const SOCK_DCCP: c_int = 6;
#[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")]
pub const SOCK_PACKET: c_int = 10;

cfg_if! {
    if #[cfg(any(target_arch = "mips", target_arch = "mips64"))] {
        pub use crate::bits::socket::{
            SOCK_CLOEXEC,
            SOCK_NONBLOCK,
        };
    } else {
        pub const SOCK_CLOEXEC: c_int = 0o2000000;
        pub const SOCK_NONBLOCK: c_int = 0o4000;
    }
}

pub const PF_IB: c_int = 27;
pub const PF_MPLS: c_int = 28;

pub const PF_NFC: c_int = 39;
pub const PF_VSOCK: c_int = 40;

pub const PF_XDP: c_int = 44;

pub const AF_IB: c_int = PF_IB;
pub const AF_MPLS: c_int = PF_MPLS;
pub const AF_NFC: c_int = PF_NFC;
pub const AF_VSOCK: c_int = PF_VSOCK;
pub const AF_XDP: c_int = PF_XDP;