Struct capsules::net::sixlowpan::Sixlowpan
[−]
[src]
pub struct Sixlowpan<'a, A: Alarm + 'a, C: ContextStore> { pub radio: &'a MacDevice<'a>, ctx_store: C, clock: &'a A, client: Cell<Option<&'a SixlowpanClient>>, tx_state: TxState, rx_states: List<'a, RxState<'a>>, }
Sends a receives IPv6 packets via 6loWPAN compression and fragmentation.
Initialization
The new
method creates an instance of Sixlowpan
that can send packets.
To receive packets, Sixlowpan
needs one or more
RxStates which can be added with add_rx_state
. More
RxStates allow the Sixlowpan
to receive more
packets concurrently.
Finally, set_client
controls the client that will receive transmission
completion and reception callbacks.
Fields
radio: &'a MacDevice<'a>
ctx_store: C
clock: &'a A
client: Cell<Option<&'a SixlowpanClient>>
tx_state: TxState
rx_states: List<'a, RxState<'a>>
Methods
impl<'a, A: Alarm, C: ContextStore> Sixlowpan<'a, A, C>
[src]
pub fn new(
radio: &'a MacDevice<'a>,
ctx_store: C,
tx_buf: &'static mut [u8],
clock: &'a A
) -> Sixlowpan<'a, A, C>
[src]
radio: &'a MacDevice<'a>,
ctx_store: C,
tx_buf: &'static mut [u8],
clock: &'a A
) -> Sixlowpan<'a, A, C>
Creates a new Sixlowpan
Arguments
radio
- An implementation of theMacDevice
trait that manages the timing and frequency of sending a receiving 802.15.4 framesctx_store
- Stores IPv6 address nextwork context mappingstx_buf
- A buffer used for storing individual fragments of a packet in transmission. This buffer must be at least the length of an 802.15.4 frame.clock
- A implementation ofAlarm
used for tracking the timing of frame arrival. The clock should be continue running during sleep and have an accuracy of at least 60 seconds.
pub fn add_rx_state(&self, rx_state: &'a RxState<'a>)
[src]
Adds an additional RxState
for reassembling IPv6 packets
Each RxState struct allows an additional IPv6 packet to be reassembled concurrently.
pub fn set_client(&'a self, client: &'a SixlowpanClient)
[src]
Sets the SixlowpanClient that will receive transmission completion and new packet reception callbacks.
pub fn transmit_packet(
&self,
src_mac_addr: MacAddress,
dst_mac_addr: MacAddress,
ip6_packet: &'static mut [u8],
ip6_packet_len: usize,
security: Option<(SecurityLevel, KeyId)>
) -> Result<(), (ReturnCode, &'static mut [u8])>
[src]
&self,
src_mac_addr: MacAddress,
dst_mac_addr: MacAddress,
ip6_packet: &'static mut [u8],
ip6_packet_len: usize,
security: Option<(SecurityLevel, KeyId)>
) -> Result<(), (ReturnCode, &'static mut [u8])>
Transmits the supplied IPv6 packet.
Transmitted IPv6 packets will be optionally secured via the security
argument.
Only one transmission is allowed at a time. Calling this method while before a previous tranismission has completed will return an error.
Arguments
src_mac_addr
- Why is the argument specified?dst_mac_addr
- Why is the argument specified?ip6_packet
- A buffer containing the IPv6 packet to transmit. This buffer will be passed back in the send_done callback.ip6_packet_len
- The length of the packet, in case theip6_packet
buffer is larger than the actual packet. Must be at mostip6_packet.len()
security
- An optional tuple specifying the security level (encryption, MIC, or both) and key identifier to use. If elided, no security is used.
This function exposes the primary packet transmission fuctionality. The
source and destination mac address arguments specify the link-layer
addresses of the packet, while the security
option specifies the
security level (if any). This option is exposed to upper layers, as
upper level protocols may want to set or manage the link-layer security
options.
The ip6_packet
argument contains a pointer to a buffer containing a valid
IPv6 packet, while the ip6_packet_len
argument specifies the number of
bytes to send. Note that ip6_packet.len() > ip6_packet_len
, but we check
the invariant that ip6_packet_len <= ip6_packet.len()
.
fn start_packet_transmit(&self)
[src]
fn receive_frame(
&self,
packet: &[u8],
packet_len: usize,
src_mac_addr: MacAddress,
dst_mac_addr: MacAddress
) -> (Option<&RxState<'a>>, ReturnCode)
[src]
&self,
packet: &[u8],
packet_len: usize,
src_mac_addr: MacAddress,
dst_mac_addr: MacAddress
) -> (Option<&RxState<'a>>, ReturnCode)
fn receive_single_packet(
&self,
payload: &[u8],
payload_len: usize,
src_mac_addr: MacAddress,
dst_mac_addr: MacAddress
) -> (Option<&RxState<'a>>, ReturnCode)
[src]
&self,
payload: &[u8],
payload_len: usize,
src_mac_addr: MacAddress,
dst_mac_addr: MacAddress
) -> (Option<&RxState<'a>>, ReturnCode)
fn receive_fragment(
&self,
frag_payload: &[u8],
payload_len: usize,
src_mac_addr: MacAddress,
dst_mac_addr: MacAddress,
dgram_size: u16,
dgram_tag: u16,
dgram_offset: usize
) -> (Option<&RxState<'a>>, ReturnCode)
[src]
&self,
frag_payload: &[u8],
payload_len: usize,
src_mac_addr: MacAddress,
dst_mac_addr: MacAddress,
dgram_size: u16,
dgram_tag: u16,
dgram_offset: usize
) -> (Option<&RxState<'a>>, ReturnCode)
fn discard_all_state(&self)
[src]
Trait Implementations
impl<'a, A: Alarm, C: ContextStore> TxClient for Sixlowpan<'a, A, C>
[src]
fn send_done(&self, tx_buf: &'static mut [u8], acked: bool, result: ReturnCode)
[src]
When transmission is complete or fails, return the buffer used for transmission to the client. result
indicates whether or not the transmission was successful. Read more
impl<'a, A: Alarm, C: ContextStore> RxClient for Sixlowpan<'a, A, C>
[src]
fn receive<'b>(
&self,
buf: &'b [u8],
header: Header<'b>,
data_offset: usize,
data_len: usize
)
[src]
&self,
buf: &'b [u8],
header: Header<'b>,
data_offset: usize,
data_len: usize
)
When a frame is received, this callback is triggered. The client only receives an immutable borrow of the buffer. Only completely valid, unsecured frames that have passed the incoming security procedure are exposed to the client. Read more