pub fn decompress(
ctx_store: &dyn ContextStore,
buf: &[u8],
src_mac_addr: MacAddress,
dst_mac_addr: MacAddress,
out_buf: &mut [u8],
dgram_size: u16,
is_fragment: bool,
) -> Result<(usize, usize), ()>Expand description
Decompresses a 6loWPAN header into a full IPv6 header
This function decompresses the header found in buf and writes it
out_buf. It does not, though, copy payload bytes or a non-compressed next
header. As a result, the caller should copy the buf.len - consumed
remaining bytes from buf to out_buf.
Note that in the case of fragmentation, the total length of the IPv6 packet cannot be inferred from a single frame, and is instead provided by the dgram_size field in the fragmentation header. Thus, if we are decompressing a fragment, we rely on the dgram_size field; otherwise, we infer the length from the size of buf.
§Arguments
-
ctx_store- ??? -
buf- A slice containing the 6LowPAN packet along with its payload. -
src_mac_addr- the 16-bit MAC address of the frame sender. -
dst_mac_addr- the 16-bit MAC address of the frame receiver. -
out_buf- A buffer to write the output to. Must be at least large enough to store an IPv6 header (XX bytes). -
dgram_size- Ifis_fragmentistrue, this is used as the IPv6 packets total payload size. Otherwise, this is ignored. -
is_fragment- ???
§Returns
Ok((consumed, written)) if decompression is successful.
-
consumedis the number of header bytes consumed from the 6LoWPAN header -
writtenis the number of uncompressed header bytes written intoout_buf.