Skip to main content

StampedSocket

Struct StampedSocket 

Source
pub struct StampedSocket { /* private fields */ }
Expand description

Sends and receives the payloads of Ethernet frames of one ethertype on one interface, with hardware time stamps.

Implementations§

Source§

impl StampedSocket

Source

pub fn open(interface: &str, ethertype: u16) -> Result<Self>

Opens interface for frames of ethertype, stamping each frame received. On Linux this needs CAP_NET_RAW.

Source

pub fn join_multicast(&self, group: MacAddress) -> Result<()>

Receives frames sent to group as well.

Source

pub fn send(&self, destination: MacAddress, payload: &[u8]) -> Result<()>

Sends payload to destination, unstamped.

Source

pub fn send_stamped( &self, destination: MacAddress, payload: &[u8], ) -> Result<()>

Sends payload to destination and has the interface stamp it; when it has gone out, transmit_time gives the time. Times of frames sent before that came too late for transmit_time are dropped first, so the next it gives is this frame’s.

Source

pub fn transmit_time(&self, timeout: Duration) -> Result<Option<Duration>>

The time the last frame sent with send_stamped went out, by the interface’s hardware clock, waiting up to timeout for the interface to say. None when it did not say in time. Where the kernel numbers the times sent (SOF_TIMESTAMPING_OPT_ID), one come too late for an earlier frame is dropped, never taken for this one.

Source

pub fn receive( &self, buffer: &mut [u8], timeout: Option<Duration>, ) -> Result<Option<Received>>

Writes the next frame’s payload to buffer, waiting up to timeout (forever when None) for one.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.