rb.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2019 Freie Universität Berlin
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
20 #include <stdint.h>
21 #include <stdbool.h>
22 #include <stdalign.h>
23 
24 #include "architecture.h"
25 #include "net/gnrc/netif/hdr.h"
26 #include "net/gnrc/pkt.h"
27 #ifdef MODULE_GNRC_SIXLOWPAN_FRAG_SFR
28 #include "net/sixlowpan/sfr.h"
29 #endif /* MODULE_GNRC_SIXLOWPAN_FRAG_SFR */
30 
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
39 #define GNRC_SIXLOWPAN_FRAG_RB_GC_MSG (0x0226)
40 
56  uint16_t start;
57  uint16_t end;
59 
73 typedef struct {
77  uint8_t src_len;
78  uint8_t dst_len;
79  uint16_t tag;
80  uint16_t datagram_size;
84  uint16_t current_size;
85  uint32_t arrival;
88 
95 typedef struct {
101 #if IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR) || defined(DOXYGEN)
110  int8_t offset_diff;
112 #endif /* IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR) */
114 
132  gnrc_pktsnip_t *frag,
133  size_t offset, unsigned page);
134 
155  const gnrc_netif_hdr_t *netif_hdr,
156  uint16_t tag);
157 
177  uint16_t tag);
178 
195  uint16_t tag);
196 
206  const gnrc_sixlowpan_frag_rb_t *rbuf) {
207  return (rbuf->pkt == NULL);
208 }
209 
210 #if defined(TEST_SUITES) || defined(DOXYGEN)
217 
228 #endif
229 
236 
241 
260  gnrc_netif_hdr_t *netif);
261 
262 #if defined(MODULE_GNRC_SIXLOWPAN_FRAG_RB) || defined(DOXYGEN)
276 {
277  assert(rbuf != NULL);
279  rbuf->pkt = NULL;
280 }
281 #else
282 /* NOPs to be used with gnrc_sixlowpan_iphc if gnrc_sixlowpan_frag_rb is not
283  * compiled in */
285 {
286  (void)rbuf;
287  return;
288 }
289 #endif
290 
291 #if defined(TEST_SUITES) || defined(DOXYGEN)
302 #else /* defined(TEST_SUITES) || defined(DOXYGEN) */
303 /* always true without TEST_SUITES defined to optimize out when not testing,
304  * as checking the status of the fragment interval pool is unnecessary in
305  * production */
306 static inline bool gnrc_sixlowpan_frag_rb_ints_empty(void)
307 {
308  return true;
309 }
310 #endif /* defined(TEST_SUITES) || defined(DOXYGEN) */
311 
312 #ifdef __cplusplus
313 }
314 #endif
315 
Platform-independent access to architecture details.
#define assert(cond)
abort the program if assertion is false
Definition: assert.h:143
gnrc_sixlowpan_frag_rb_t * gnrc_sixlowpan_frag_rb_add(gnrc_netif_hdr_t *netif_hdr, gnrc_pktsnip_t *frag, size_t offset, unsigned page)
Adds a new fragment to the reassembly buffer.
void gnrc_sixlowpan_frag_rb_reset(void)
Resets the packet buffer to a clean state.
static bool gnrc_sixlowpan_frag_rb_entry_empty(const gnrc_sixlowpan_frag_rb_t *rbuf)
Checks if a reassembly buffer entry is unset.
Definition: rb.h:205
int gnrc_sixlowpan_frag_rb_dispatch_when_complete(gnrc_sixlowpan_frag_rb_t *rbuf, gnrc_netif_hdr_t *netif)
Checks if a reassembly buffer entry is complete and dispatches it to the next layer if that is the ca...
bool gnrc_sixlowpan_frag_rb_ints_empty(void)
Check if pool of fragment intervals is empty.
static void gnrc_sixlowpan_frag_rb_remove(gnrc_sixlowpan_frag_rb_t *rbuf)
Unsets a reassembly buffer entry (but does not free rbuf_t::super::pkt)
Definition: rb.h:275
const gnrc_sixlowpan_frag_rb_t * gnrc_sixlowpan_frag_rb_array(void)
Returns a pointer to the array representing the reassembly buffer.
void gnrc_sixlowpan_frag_rb_gc(void)
Garbage collect reassembly buffer.
void gnrc_sixlowpan_frag_rb_rm_by_datagram(const gnrc_netif_hdr_t *netif_hdr, uint16_t tag)
Removes a reassembly buffer entry with a given link-layer address pair and tag.
bool gnrc_sixlowpan_frag_rb_exists(const gnrc_netif_hdr_t *netif_hdr, uint16_t tag)
Checks if a reassembly buffer entry with a given link-layer address pair and tag exists.
void gnrc_sixlowpan_frag_rb_base_rm(gnrc_sixlowpan_frag_rb_base_t *entry)
Remove base entry.
struct gnrc_sixlowpan_frag_rb_int gnrc_sixlowpan_frag_rb_int_t
Fragment intervals to identify limits of fragments and duplicates.
gnrc_sixlowpan_frag_rb_t * gnrc_sixlowpan_frag_rb_get_by_datagram(const gnrc_netif_hdr_t *netif_hdr, uint16_t tag)
Gets a reassembly buffer entry with a given link-layer address pair and tag.
#define IEEE802154_LONG_ADDRESS_LEN
long address (EUI-64)
Definition: ieee802154.h:42
#define SIXLOWPAN_SFR_ACK_BITMAP_SIZE
Acknowledgment bitmap size in bits.
Definition: sfr.h:52
Generic network interface header.
General definitions for network packets and their helper functions.
6LoWPAN selective fragment recovery dispatch type and helper function definitions.
Generic network interface header.
Definition: hdr.h:122
Type to represent parts (either headers or payload) of a packet, called snips.
Definition: pkt.h:105
Base class for both reassembly buffer and virtual reassembly buffer.
Definition: rb.h:73
gnrc_sixlowpan_frag_rb_int_t * ints
intervals of already received fragments
Definition: rb.h:74
uint16_t datagram_size
the datagram's size
Definition: rb.h:80
uint16_t tag
the datagram's tag
Definition: rb.h:79
uint8_t src_len
length of gnrc_sixlowpan_frag_rb_t::src
Definition: rb.h:77
uint32_t arrival
time in microseconds of arrival of last received fragment
Definition: rb.h:85
uint8_t dst_len
length of gnrc_sixlowpan_frag_rb_t::dst
Definition: rb.h:78
uint16_t current_size
The number of bytes currently received of the complete datagram.
Definition: rb.h:84
Fragment intervals to identify limits of fragments and duplicates.
Definition: rb.h:51
struct gnrc_sixlowpan_frag_rb_int * next
next element in fragment interval list
Definition: rb.h:55
uint16_t start
start byte of the fragment interval
Definition: rb.h:56
uint16_t end
end byte of the fragment interval
Definition: rb.h:57
An entry in the 6LoWPAN reassembly buffer.
Definition: rb.h:95
gnrc_sixlowpan_frag_rb_base_t super
base class
Definition: rb.h:96
gnrc_pktsnip_t * pkt
The reassembled packet in the packet buffer.
Definition: rb.h:100
int8_t offset_diff
offset change due to recompression
Definition: rb.h:110
BITFIELD(received, SIXLOWPAN_SFR_ACK_BITMAP_SIZE)
Bitmap for received fragments.
Configuration macros for 6LoWPAN.
Bitmap type to simplify comparisons.
Definition: sfr_types.h:35