22#ifndef NET_SIXLOWPAN_SFR_H
23#define NET_SIXLOWPAN_SFR_H
46#define SIXLOWPAN_SFR_GEN_DISP_MASK (0xfc)
47#define SIXLOWPAN_SFR_GEN_DISP (0xe8)
48#define SIXLOWPAN_SFR_ECN (0x01U)
49#define SIXLOWPAN_SFR_ACK_REQ (0x80U)
50#define SIXLOWPAN_SFR_SEQ_MASK (0x7cU)
51#define SIXLOWPAN_SFR_SEQ_POS (2U)
52#define SIXLOWPAN_SFR_SEQ_MAX (0x1fU)
53#define SIXLOWPAN_SFR_FRAG_SIZE_MASK (0x03ffU)
54#define SIXLOWPAN_SFR_FRAG_SIZE_MAX (0x03ffU)
55#define SIXLOWPAN_SFR_ACK_BITMAP_SIZE (32U)
62typedef struct __attribute__((packed)) {
96typedef struct __attribute__((packed)) {
140typedef struct __attribute__((packed)) {
181 hdr->
disp_ecn &= ~SIXLOWPAN_SFR_ECN;
207 hdr->
disp_ecn &= ~SIXLOWPAN_SFR_DISP_MASK;
354 hdr->
disp_ecn &= ~SIXLOWPAN_SFR_DISP_MASK;
POSIX.1-2008 compliant version of the assert macro.
#define assert(cond)
abort the program if assertion is false
bitfields operations on bitfields of arbitrary length
Functions to work with different byte orders.
static network_uint16_t byteorder_htons(uint16_t v)
Convert from host byte order to network byte order, 16 bit.
static uint16_t byteorder_ntohs(network_uint16_t v)
Convert from network byte order to host byte order, 16 bit.
static uint16_t htons(uint16_t v)
Convert from host byte order to network byte order, 16 bit.
#define SIXLOWPAN_SFR_FRAG_SIZE_MAX
Maximum value for fragment size.
#define SIXLOWPAN_SFR_SEQ_MASK
Sequence number mask (for 8 MSB)
static bool sixlowpan_sfr_ack_is(const sixlowpan_sfr_t *hdr)
Check if given header is a 6LoWPAN RFRAG acknowledgment header.
static void sixlowpan_sfr_rfrag_set_offset(sixlowpan_sfr_rfrag_t *hdr, uint16_t offset)
Set fragment offset in a 6LoWPAN recoverable fragment header.
#define SIXLOWPAN_SFR_ACK_REQ
Acknowledgment request flag (for 8 MSB)
static uint16_t sixlowpan_sfr_rfrag_get_offset(const sixlowpan_sfr_rfrag_t *hdr)
Get fragment offset from a 6LoWPAN recoverable fragment header.
static bool sixlowpan_sfr_rfrag_ack_req(sixlowpan_sfr_rfrag_t *hdr)
Check if the Acknowledgment request flag in a 6LoWPAN recoverable fragment header is set.
static void sixlowpan_sfr_set_ecn(sixlowpan_sfr_t *hdr)
Set the ECN flag in a 6LoWPAN selective fragment recovery header.
static void sixlowpan_sfr_rfrag_set_ack_req(sixlowpan_sfr_rfrag_t *hdr)
Set the Acknowledgment request flag in a 6LoWPAN recoverable fragment header.
static void sixlowpan_sfr_ack_set_disp(sixlowpan_sfr_t *hdr)
Initialize 6LoWPAN RFRAG acknowledgment dispatch.
#define SIXLOWPAN_SFR_ACK_BITMAP_SIZE
Acknowledgment bitmap size in bits.
static bool sixlowpan_sfr_ecn(const sixlowpan_sfr_t *hdr)
Check if the ECN flag in a 6LoWPAN recoverable fragment header is set.
static void sixlowpan_sfr_rfrag_set_frag_size(sixlowpan_sfr_rfrag_t *hdr, uint16_t frag_size)
Set fragment size in a 6LoWPAN recoverable fragment header.
static void sixlowpan_sfr_rfrag_set_seq(sixlowpan_sfr_rfrag_t *hdr, uint8_t seq)
Set sequence number in a 6LoWPAN recoverable fragment header.
static uint16_t sixlowpan_sfr_rfrag_get_frag_size(const sixlowpan_sfr_rfrag_t *hdr)
Get fragment size from a 6LoWPAN recoverable fragment header.
#define SIXLOWPAN_SFR_FRAG_SIZE_MASK
Fragment size mask.
static void sixlowpan_sfr_rfrag_set_disp(sixlowpan_sfr_t *hdr)
Initialize 6LoWPAN recoverable fragment dispatch.
static uint8_t sixlowpan_sfr_rfrag_get_seq(const sixlowpan_sfr_rfrag_t *hdr)
Get sequence number from a 6LoWPAN recoverable fragment header.
#define SIXLOWPAN_SFR_GEN_DISP
generic dispatch for both SFR headers
static bool sixlowpan_sfr_rfrag_is(const sixlowpan_sfr_t *hdr)
Check if given header is a 6LoWPAN recoverable fragment header.
#define SIXLOWPAN_SFR_SEQ_POS
Sequence number position (for 8 MSB)
#define SIXLOWPAN_SFR_GEN_DISP_MASK
Mask for generic dispatch of both selective fragment recovery headers.
#define SIXLOWPAN_SFR_ECN
explicit congestion notification flag
static void sixlowpan_sfr_clear_ecn(sixlowpan_sfr_t *hdr)
Clear the ECN flag in a 6LoWPAN recoverable fragment header.
static bool sixlowpan_sfr_is(sixlowpan_sfr_t *hdr)
Check if given header is a 6LoWPAN selective fragment recovery header (either RFRAG or RFRAG ACK)
#define SIXLOWPAN_SFR_SEQ_MAX
Maximum value for sequence number.
static void sixlowpan_sfr_rfrag_clear_ack_req(sixlowpan_sfr_rfrag_t *hdr)
Clear the Acknowledgment request flag in a 6LoWPAN recoverable fragment header.
#define SIXLOWPAN_SFR_DISP_MASK
Dispatch mask for 6LoWPAN selective fragment recovery.
#define SIXLOWPAN_SFR_RFRAG_DISP
Dispatch for 6LoWPAN recoverable fragment.
#define SIXLOWPAN_SFR_ACK_DISP
Dispatch for 6LoWPAN recoverable fragment acknowledgment.
6LoWPAN dispatch type and helper function definitions.
Recoverable fragment (RFRAG) acknowledgment header.
sixlowpan_sfr_t base
generic part
BITFIELD(bitmap, SIXLOWPAN_SFR_ACK_BITMAP_SIZE)
RFRAG acknowledgment bitmap.
Recoverable fragment header.
network_uint16_t offset
Fragment offset.
sixlowpan_sfr_t base
generic part
network_uint16_t ar_seq_fs
Acknowledgment request flag, sequence number, and fragment size.
Generic type for selective fragment recovery headers.
uint8_t disp_ecn
Dispatch and explicit congestion notification (ECN) flag.
A 16 bit integer in big endian aka network byte order.
uint8_t u8[2]
8 bit representation
uint16_t u16
16 bit representation