Struct Nic

Source
pub struct Nic {
    pub interface: NetworkInterface,
    /* private fields */
}
Expand description

NIC Structure that supports Packetvisor

Fields§

§interface: NetworkInterface

Attached network interface information. (ex. interface name, L2-3 address, etc.)

Implementations§

Source§

impl Nic

Source

pub fn new( if_name: &str, chunk_size: usize, chunk_count: usize, fq_size: usize, cq_size: usize, tx_size: usize, rx_size: usize, ) -> Result<Nic, String>

§Description

Attaching pv::Nic to network interface

§Arguments

if_name - network interface name
chunk_size - total size of packet payload
chunk_count - total count of chunk
fq_size - filling ring size
cq_size - completion ring size
tx_size - tx ring size
rx_size - rx ring size \

§Returns

On success, returns pv::Nic bound to the network interface.
On failure, returns an error string.

Source

pub fn alloc_packet(&self) -> Option<Packet>

§Description

Allocate packet using Pool

§Returns

On success, returns pv::Packet with empty payload.
On failure, returns None.

Source

pub fn send(&mut self, packets: &mut Vec<Packet>) -> usize

§Description

Send packets
*Sent packets are removed from the vector.

§Arguments

packets - Packets to send

§Returns

Number of packets sent

Source

pub fn receive(&mut self, len: usize) -> Vec<Packet>

§Description

Receive packets

§Arguments

len - Number of packets to receive

§Returns

Received packets

Trait Implementations§

Source§

impl Debug for Nic

Source§

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

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

impl Drop for Nic

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Nic

§

impl RefUnwindSafe for Nic

§

impl !Send for Nic

§

impl !Sync for Nic

§

impl Unpin for Nic

§

impl UnwindSafe for Nic

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 = Infallible

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.