capsules_extra::net::sixlowpan::sixlowpan_state

Struct TxState

Source
pub struct TxState<'a> {
    pub dst_pan: Cell<PanID>,
    /* private fields */
}
Expand description

Tracks the compression state for a single IPv6 packet.

When an upper layer is interested in sending a packet using Sixlowpan, they must first call TxState.init, which initializes the compression state for a new packet. The upper layer then repeatedly calls TxState.next_fragment until there are no more frames to compress. Note that the upper layer is responsible for sending the compressed frames; the TxState struct simply produces compressed MAC frames.

Fields§

§dst_pan: Cell<PanID>

State for the current transmission

Implementations§

Source§

impl<'a> TxState<'a>

Source

pub fn new(sixlowpan: &'a dyn SixlowpanState<'a>) -> TxState<'a>

Creates a new TxState

§Arguments

sixlowpan - A reference to a SixlowpanState object, which contains global state for the entire Sixlowpan layer.

Source

pub fn init( &self, src_mac_addr: MacAddress, dst_mac_addr: MacAddress, radio_pan: u16, security: Option<(SecurityLevel, KeyId)>, ) -> Result<(), ErrorCode>

Initializes TxState for a new packet

§Arguments

src_mac_addr - The MAC address the frame will be sent from dst_mac_addr - The MAC address the frame will be sent to radio_pan - The PAN ID held by the radio underlying this stack security - Any security options (necessary since the size of the produced MAC frame is dependent on the security options)

§Return Value

This function returns a Result<(), ErrorCode>, which indicates success or failure. Note that if init has already been called and we are currently sending a packet, this function will return Err(ErrorCode::BUSY)

Source

pub fn next_fragment<'b>( &self, ip6_packet: &'b IP6Packet<'b>, frag_buf: &'static mut [u8], radio: &dyn MacDevice<'_>, ) -> Result<(bool, Frame), (Result<(), ErrorCode>, &'static mut [u8])>

Gets the next 6LoWPAN Fragment (as a MAC frame) to be sent. Note that this layer does not send the frame, and assumes that init has already been called.

§Arguments

ip6_packet - A reference to the IPv6 packet to be compressed frag_buf - The buffer to write the MAC frame to radio - A reference to a MacDevice, which is used to prepare the MAC frame

§Return Value

This function returns a Result type: Ok(bool, frame) - If Ok, then bool indicates whether the transmission is complete, and Frame is the filled out next MAC frame Err(Result<(), ErrorCode>, &'static mut [u8]) - If Err, then Result<(), ErrorCode> is the reason for the error, and the return buffer is the (non-consumed) frag_buf passed in as an argument

Auto Trait Implementations§

§

impl<'a> !Freeze for TxState<'a>

§

impl<'a> !RefUnwindSafe for TxState<'a>

§

impl<'a> !Send for TxState<'a>

§

impl<'a> !Sync for TxState<'a>

§

impl<'a> Unpin for TxState<'a>

§

impl<'a> !UnwindSafe for TxState<'a>

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.