xarxa

Crates

git

Versions

default

Flavors

Skip to main content

RawSocketDriver

Struct RawSocketDriver 

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

A driver over a packet socket bound to a host interface, sending and receiving whole frames.

Ethernet interfaces carry Ethernet frames (Medium::Ethernet), wpan interfaces carry IEEE 802.15.4 frames (Medium::Ieee802154). Linux and Android only.

Implementations§

Source§

impl RawSocketDriver

Source

pub fn new( name: &str, hardware_addr: HardwareAddress, ) -> Result<RawSocketDriver>

Open a packet socket bound to the interface called name.

hardware_addr is the address the interface reports to the stack, and picks the medium: an Ethernet address for an Ethernet interface, an IEEE 802.15.4 one for a wpan interface. It must match the address the host interface is configured with.

This requires superuser privileges or a corresponding capability bit set on the executable.

Errors:

  • the OS error if the socket cannot be opened or bound, or the interface does not exist.
  • Unsupported for HardwareAddress::Ip, and for an IEEE 802.15.4 address that is not an extended address.

Trait Implementations§

Source§

impl AsRawFd for RawSocketDriver

Source§

fn as_raw_fd(&self) -> RawFd

Extracts the raw file descriptor. Read more
Source§

impl Debug for RawSocketDriver

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Driver for RawSocketDriver

Source§

fn capabilities(&self) -> Capabilities

Get a description of the device’s capabilities.
Source§

fn hardware_address(&self) -> HardwareAddress

Get the device’s hardware address. Read more
Source§

fn receive(&mut self) -> Option<PacketBuf>

Poll for a received frame. Read more
Source§

fn transmit(&mut self, buf: PacketBuf) -> Result<(), PacketBuf>

Queue a frame for transmission, transferring ownership of the buffer to the driver. Read more
Source§

fn can_transmit(&mut self) -> bool

Whether the device can transmit one frame right now. Read more
Get the link state. Read more
Source§

fn poll_tx_timestamp(&mut self) -> Option<TxTimestamp>

Poll for the timestamp of an already-transmitted packet. Read more
Source§

impl Drop for RawSocketDriver

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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, <T as TryFrom<U>>::Error>

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.