[][src]Struct jnet::ether::Frame

pub struct Frame<BUFFER> where
    BUFFER: AsSlice<Element = u8>, 
{ /* fields omitted */ }

Layer 2 Ethernet frame

Structure

(*) This frame representation does NOT include the frame check sequence nor (zero) pads the payload to the minimum size of 46 bytes.

Methods

impl<B> Frame<B> where
    B: AsSlice<Element = u8>, 
[src]

pub fn new(buffer: B) -> Self[src]

Creates a new Ethernet frame from the given buffer

pub fn parse(bytes: B) -> Result<Self, B>[src]

Parses bytes into an Ethernet frame

pub fn get_destination(&self) -> Addr[src]

Returns the Destination field of the header

pub fn get_source(&self) -> Addr[src]

Returns the Source field of the header

pub fn get_type(&self) -> Type[src]

Returns the Type field of the header

pub fn payload(&self) -> &[u8][src]

View into the payload

pub fn as_bytes(&self) -> &[u8][src]

Returns the byte representation of this frame

pub fn free(self) -> B[src]

Frees the underlying buffer

pub fn len(&self) -> u16[src]

Returns the length (header + data) of this frame

impl<B> Frame<B> where
    B: AsSlice<Element = u8> + AsMutSlice<Element = u8>, 
[src]

pub fn set_destination(&mut self, addr: Addr)[src]

Sets the destination field of the header

pub fn set_source(&mut self, addr: Addr)[src]

Sets the source field of the header

pub fn set_type(&mut self, type_: Type)[src]

Sets the type field of the header

pub fn payload_mut(&mut self) -> &mut [u8][src]

Mutable view into the payload

impl<B> Frame<B> where
    B: AsSlice<Element = u8> + IntoSliceFrom<u8>, 
[src]

pub fn into_payload(self) -> B::SliceFrom[src]

Returns the payload of this frame

impl<B> Frame<B> where
    B: AsSlice<Element = u8> + AsMutSlice<Element = u8> + Truncate<u8>, 
[src]

pub fn arp<F>(&mut self, f: F) where
    F: FnOnce(&mut Packet<&mut [u8]>), 
[src]

Fills the payload with an ARP packet

This method sets the Type field of this frame to ARP, and truncates the length of the frame to fit the ARP packet.

The ARP packet will have its SHA set to the Ethernet frame Source address

impl<B> Frame<B> where
    B: AsSlice<Element = u8> + AsMutSlice<Element = u8> + Truncate<u16>, 
[src]

pub fn ipv4<F>(&mut self, f: F) where
    F: FnOnce(&mut Packet<&mut [u8], Invalid>), 
[src]

Fills the payload with an IPv4 packet

This method sets the Type field of this frame to IPv4, recomputes and updates the header checksum of the IPv4 payload, and truncates the length of the frame to fit the IPv4 packet.

pub fn ipv6<F>(&mut self, f: F) where
    F: FnOnce(&mut Packet<&mut [u8]>), 
[src]

Fills the payload with an IPv6 packet

Trait Implementations

impl<B> Debug for Frame<B> where
    B: AsSlice<Element = u8>, 
[src]

NOTE excludes the payload

impl<BUFFER: Copy> Copy for Frame<BUFFER> where
    BUFFER: AsSlice<Element = u8>, 
[src]

impl<BUFFER: Clone> Clone for Frame<BUFFER> where
    BUFFER: AsSlice<Element = u8>, 
[src]

Auto Trait Implementations

impl<BUFFER> Unpin for Frame<BUFFER> where
    BUFFER: Unpin

impl<BUFFER> Send for Frame<BUFFER> where
    BUFFER: Send

impl<BUFFER> Sync for Frame<BUFFER> where
    BUFFER: Sync

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T[src]

type Output = T

Should always be Self