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>
impl<'a> TxState<'a>
Sourcepub fn new(sixlowpan: &'a dyn SixlowpanState<'a>) -> TxState<'a>
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.
Sourcepub fn init(
&self,
src_mac_addr: MacAddress,
dst_mac_addr: MacAddress,
radio_pan: u16,
security: Option<(SecurityLevel, KeyId)>,
) -> Result<(), ErrorCode>
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)
Sourcepub 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])>
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