rb.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Freie Universität Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
20 #ifndef NET_GNRC_SIXLOWPAN_FRAG_RB_H
21 #define NET_GNRC_SIXLOWPAN_FRAG_RB_H
22 
23 #include <stdint.h>
24 #include <stdbool.h>
25 
26 #include "net/gnrc/netif/hdr.h"
27 #include "net/gnrc/pkt.h"
28 
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
37 #define GNRC_SIXLOWPAN_FRAG_RB_GC_MSG (0x0226)
38 
54  uint16_t start;
55  uint16_t end;
57 
71 typedef struct {
75  uint8_t src_len;
76  uint8_t dst_len;
77  uint16_t tag;
78  uint16_t datagram_size;
82  uint16_t current_size;
83  uint32_t arrival;
86 
93 typedef struct {
100 
118  gnrc_pktsnip_t *frag,
119  size_t offset, unsigned page);
120 
139 bool gnrc_sixlowpan_frag_rb_exists(const gnrc_netif_hdr_t *netif_hdr,
140  uint16_t tag);
141 
158  uint16_t tag);
159 
169  const gnrc_sixlowpan_frag_rb_t *rbuf) {
170  return (rbuf->pkt == NULL);
171 }
172 
173 #if defined(TEST_SUITES) || defined(DOXYGEN)
174 
180 
191 #endif
192 
199 
203 void gnrc_sixlowpan_frag_rb_gc(void);
204 
223  gnrc_netif_hdr_t *netif);
224 
225 #if defined(MODULE_GNRC_SIXLOWPAN_FRAG_RB) || defined(DOXYGEN)
226 
239 {
240  assert(rbuf != NULL);
242  rbuf->pkt = NULL;
243 }
244 #else
245 /* NOPs to be used with gnrc_sixlowpan_iphc if gnrc_sixlowpan_frag_rb is not
246  * compiled in */
248 {
249  (void)rbuf;
250  return;
251 }
252 #endif
253 
254 #ifdef __cplusplus
255 }
256 #endif
257 
258 #endif /* NET_GNRC_SIXLOWPAN_FRAG_RB_H */
259 
gnrc_sixlowpan_frag_rb_array
const gnrc_sixlowpan_frag_rb_t * gnrc_sixlowpan_frag_rb_array(void)
Returns a pointer to the array representing the reassembly buffer.
gnrc_sixlowpan_frag_rb_gc
void gnrc_sixlowpan_frag_rb_gc(void)
Garbage collect reassembly buffer.
gnrc_sixlowpan_frag_rb_int::next
struct gnrc_sixlowpan_frag_rb_int * next
next element in fragment interval list
Definition: rb.h:53
gnrc_sixlowpan_frag_rb_t::pkt
gnrc_pktsnip_t * pkt
The reassembled packet in the packet buffer.
Definition: rb.h:98
gnrc_netif_hdr_t
Generic network interface header.
Definition: hdr.h:101
gnrc_sixlowpan_frag_rb_base_t::dst_len
uint8_t dst_len
length of gnrc_sixlowpan_frag_rb_t::dst
Definition: rb.h:76
assert
#define assert(cond)
abort the program if assertion is false
Definition: assert.h:104
gnrc_sixlowpan_frag_rb_int::start
uint16_t start
start byte of the fragment interval
Definition: rb.h:54
gnrc_sixlowpan_frag_rb_base_t::datagram_size
uint16_t datagram_size
the datagram's size
Definition: rb.h:78
gnrc_sixlowpan_frag_rb_int
Fragment intervals to identify limits of fragments and duplicates.
Definition: rb.h:49
gnrc_sixlowpan_frag_rb_reset
void gnrc_sixlowpan_frag_rb_reset(void)
Resets the packet buffer to a clean state.
gnrc_sixlowpan_frag_rb_dispatch_when_complete
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...
gnrc_sixlowpan_frag_rb_t::super
gnrc_sixlowpan_frag_rb_base_t super
base class
Definition: rb.h:94
gnrc_sixlowpan_frag_rb_exists
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.
gnrc_sixlowpan_frag_rb_int_t
struct gnrc_sixlowpan_frag_rb_int gnrc_sixlowpan_frag_rb_int_t
Fragment intervals to identify limits of fragments and duplicates.
config.h
Configuration macros for 6LoWPAN.
gnrc_sixlowpan_frag_rb_base_t::tag
uint16_t tag
the datagram's tag
Definition: rb.h:77
gnrc_sixlowpan_frag_rb_base_t::src_len
uint8_t src_len
length of gnrc_sixlowpan_frag_rb_t::src
Definition: rb.h:75
gnrc_sixlowpan_frag_rb_t
An entry in the 6LoWPAN reassembly buffer.
Definition: rb.h:93
gnrc_sixlowpan_frag_rb_remove
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:238
gnrc_sixlowpan_frag_rb_base_rm
void gnrc_sixlowpan_frag_rb_base_rm(gnrc_sixlowpan_frag_rb_base_t *entry)
Remove base entry.
gnrc_sixlowpan_frag_rb_base_t::arrival
uint32_t arrival
time in microseconds of arrival of last received fragment
Definition: rb.h:83
pkt.h
General definitions for network packets and their helper functions.
gnrc_sixlowpan_frag_rb_base_t::current_size
uint16_t current_size
The number of bytes currently received of the complete datagram.
Definition: rb.h:82
gnrc_sixlowpan_frag_rb_base_t
Base class for both reassembly buffer and virtual reassembly buffer.
Definition: rb.h:71
gnrc_sixlowpan_frag_rb_base_t::ints
gnrc_sixlowpan_frag_rb_int_t * ints
intervals of already received fragments
Definition: rb.h:72
IEEE802154_LONG_ADDRESS_LEN
#define IEEE802154_LONG_ADDRESS_LEN
long address (EUI-64)
Definition: ieee802154.h:44
gnrc_sixlowpan_frag_rb_entry_empty
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:168
gnrc_sixlowpan_frag_rb_int::end
uint16_t end
end byte of the fragment interval
Definition: rb.h:55
gnrc_sixlowpan_frag_rb_rm_by_datagram
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.
hdr.h
Generic network interface header.
gnrc_sixlowpan_frag_rb_add
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.
gnrc_pktsnip
Type to represent parts (either headers or payload) of a packet, called snips.
Definition: pkt.h:108