diff options
Diffstat (limited to 'src/sys/socket/mod.rs')
-rw-r--r-- | src/sys/socket/mod.rs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index 6909c154..b972835f 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -717,6 +717,25 @@ pub enum ControlMessage<'a> { /// following one by one, and the last, possibly smaller one. #[cfg(target_os = "linux")] UdpGsoSegments(&'a u16), + + /// Configure the sending addressing and interface for v4 + /// + /// For further information, please refer to the + /// [`ip(7)`](http://man7.org/linux/man-pages/man7/ip.7.html) man page. + #[cfg(any(target_os = "linux", + target_os = "macos", + target_os = "netbsd"))] + Ipv4PacketInfo(&'a libc::in_pktinfo), + + /// Configure the sending addressing and interface for v6 + /// + /// For further information, please refer to the + /// [`ipv6(7)`](http://man7.org/linux/man-pages/man7/ipv6.7.html) man page. + #[cfg(any(target_os = "linux", + target_os = "macos", + target_os = "netbsd", + target_os = "freebsd"))] + Ipv6PacketInfo(&'a libc::in6_pktinfo), } // An opaque structure used to prevent cmsghdr from being a public type @@ -798,6 +817,12 @@ impl<'a> ControlMessage<'a> { ControlMessage::UdpGsoSegments(gso_size) => { gso_size as *const _ as *const u8 }, + #[cfg(any(target_os = "linux", target_os = "macos", + target_os = "netbsd"))] + ControlMessage::Ipv4PacketInfo(info) => info as *const _ as *const u8, + #[cfg(any(target_os = "linux", target_os = "macos", + target_os = "netbsd", target_os = "freebsd"))] + ControlMessage::Ipv6PacketInfo(info) => info as *const _ as *const u8, }; unsafe { ptr::copy_nonoverlapping( @@ -838,6 +863,12 @@ impl<'a> ControlMessage<'a> { ControlMessage::UdpGsoSegments(gso_size) => { mem::size_of_val(gso_size) }, + #[cfg(any(target_os = "linux", target_os = "macos", + target_os = "netbsd"))] + ControlMessage::Ipv4PacketInfo(info) => mem::size_of_val(info), + #[cfg(any(target_os = "linux", target_os = "macos", + target_os = "netbsd", target_os = "freebsd"))] + ControlMessage::Ipv6PacketInfo(info) => mem::size_of_val(info), } } @@ -854,6 +885,12 @@ impl<'a> ControlMessage<'a> { ControlMessage::AlgSetAeadAssoclen(_) => libc::SOL_ALG, #[cfg(target_os = "linux")] ControlMessage::UdpGsoSegments(_) => libc::SOL_UDP, + #[cfg(any(target_os = "linux", target_os = "macos", + target_os = "netbsd"))] + ControlMessage::Ipv4PacketInfo(_) => libc::IPPROTO_IP, + #[cfg(any(target_os = "linux", target_os = "macos", + target_os = "netbsd", target_os = "freebsd"))] + ControlMessage::Ipv6PacketInfo(_) => libc::IPPROTO_IPV6, } } @@ -881,6 +918,12 @@ impl<'a> ControlMessage<'a> { ControlMessage::UdpGsoSegments(_) => { libc::UDP_SEGMENT }, + #[cfg(any(target_os = "linux", target_os = "macos", + target_os = "netbsd"))] + ControlMessage::Ipv4PacketInfo(_) => libc::IP_PKTINFO, + #[cfg(any(target_os = "linux", target_os = "macos", + target_os = "netbsd", target_os = "freebsd"))] + ControlMessage::Ipv6PacketInfo(_) => libc::IPV6_PKTINFO, } } |