[−][src]Enum nix::sys::socket::ControlMessageOwned
A type-safe wrapper around a single control message, as used with
recvmsg
.
Variants
Received version of
[ControlMessage::ScmRights
][#enum.ControlMessage.html#variant.ScmRights]
ScmCredentials(UnixCredentials)
Received version of
[ControlMessage::ScmCredentials
][#enum.ControlMessage.html#variant.ScmCredentials]
ScmTimestamp(TimeVal)
A message of type SCM_TIMESTAMP
, containing the time the
packet was received by the kernel.
See the kernel's explanation in "SO_TIMESTAMP" of networking/timestamping.
Examples
// Set up let message = "Ohayō!".as_bytes(); let in_socket = socket( AddressFamily::Inet, SockType::Datagram, SockFlag::empty(), None).unwrap(); setsockopt(in_socket, sockopt::ReceiveTimestamp, &true).unwrap(); let localhost = InetAddr::new(IpAddr::new_v4(127, 0, 0, 1), 0); bind(in_socket, &SockAddr::new_inet(localhost)).unwrap(); let address = getsockname(in_socket).unwrap(); // Get initial time let time0 = SystemTime::now(); // Send the message let iov = [IoVec::from_slice(message)]; let flags = MsgFlags::empty(); let l = sendmsg(in_socket, &iov, &[], flags, Some(&address)).unwrap(); assert_eq!(message.len(), l); // Receive the message let mut buffer = vec![0u8; message.len()]; let mut cmsgspace = cmsg_space!(TimeVal); let iov = [IoVec::from_mut_slice(&mut buffer)]; let r = recvmsg(in_socket, &iov, Some(&mut cmsgspace), flags).unwrap(); let rtime = match r.cmsgs().next() { Some(ControlMessageOwned::ScmTimestamp(rtime)) => rtime, Some(_) => panic!("Unexpected control message"), None => panic!("No control message") }; // Check the final time let time1 = SystemTime::now(); // the packet's received timestamp should lie in-between the two system // times, unless the system clock was adjusted in the meantime. let rduration = Duration::new(rtime.tv_sec() as u64, rtime.tv_usec() as u32 * 1000); assert!(time0.duration_since(UNIX_EPOCH).unwrap() <= rduration); assert!(rduration <= time1.duration_since(UNIX_EPOCH).unwrap()); // Close socket nix::unistd::close(in_socket).unwrap();
Ipv4PacketInfo(in_pktinfo)
Ipv6PacketInfo(in6_pktinfo)
UdpGroSegments(u16)
UDP Generic Receive Offload (GRO) allows receiving multiple UDP packets from a single sender. Fixed-size payloads are following one by one in a receive buffer. This Control Message indicates the size of all smaller packets, except, maybe, the last one.
UdpGroSegment
socket option should be enabled on a socket
to allow receiving GRO packets.
Trait Implementations
impl Clone for ControlMessageOwned
[src]
fn clone(&self) -> ControlMessageOwned
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for ControlMessageOwned
[src]
impl Eq for ControlMessageOwned
[src]
impl PartialEq<ControlMessageOwned> for ControlMessageOwned
[src]
fn eq(&self, other: &ControlMessageOwned) -> bool
[src]
fn ne(&self, other: &ControlMessageOwned) -> bool
[src]
impl StructuralEq for ControlMessageOwned
[src]
impl StructuralPartialEq for ControlMessageOwned
[src]
Auto Trait Implementations
impl RefUnwindSafe for ControlMessageOwned
impl Send for ControlMessageOwned
impl Sync for ControlMessageOwned
impl Unpin for ControlMessageOwned
impl UnwindSafe for ControlMessageOwned
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,