frag.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 <stdbool.h>
21 #include <stdint.h>
22 
23 #include "clist.h"
24 #include "net/gnrc/pkt.h"
25 #include "net/gnrc/pktbuf.h"
26 #include "net/ipv6/hdr.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
35 #define GNRC_IPV6_EXT_FRAG_RBUF_GC (0xfe00U)
36 
43 #define GNRC_IPV6_EXT_FRAG_CONTINUE (0xfe01U)
44 
50 #define GNRC_IPV6_EXT_FRAG_SEND (0xfe02U)
51 
56 typedef struct gnrc_ipv6_ext_frag_limits {
58  uint16_t start;
59  uint16_t end;
62 
66 typedef struct {
69  uint32_t id;
70  uint16_t path_mtu;
72  uint16_t offset;
74 
78 typedef struct {
87  uint32_t id;
88  uint32_t arrival;
89  uint16_t pkt_len;
90  uint8_t last;
92 
96 typedef struct {
97  unsigned rbuf_full;
99  unsigned frag_full;
101  unsigned datagrams;
102  unsigned fragments;
104 
110 
120 void gnrc_ipv6_ext_frag_send_pkt(gnrc_pktsnip_t *pkt, unsigned path_mtu);
121 
130 
142 
163  uint32_t id);
164 
172 
183 {
184  gnrc_pktbuf_release(rbuf->pkt);
185  rbuf->pkt = NULL;
187 }
188 
206 
207 #ifdef __cplusplus
208 }
209 #endif
210 
Circular linked list.
void gnrc_ipv6_ext_frag_send(gnrc_ipv6_ext_frag_send_t *snd_buf)
(Continue to) fragment packet already in fragmentation send buffer
gnrc_ipv6_ext_frag_rbuf_t * gnrc_ipv6_ext_frag_rbuf_get(ipv6_hdr_t *ipv6, uint32_t id)
Get a reassembly buffer by the identifying parameters.
void gnrc_ipv6_ext_frag_init(void)
Initializes IPv6 fragmentation and reassembly.
gnrc_ipv6_ext_frag_stats_t * gnrc_ipv6_ext_frag_stats(void)
Get the current statistics on reassembly and fragmentation.
void gnrc_ipv6_ext_frag_send_pkt(gnrc_pktsnip_t *pkt, unsigned path_mtu)
Send an IPv6 packet fragmented.
void gnrc_ipv6_ext_frag_rbuf_free(gnrc_ipv6_ext_frag_rbuf_t *rbuf)
Frees a reassembly buffer entry (but does not release its gnrc_ipv6_ext_frag_rbuf_t::pkt)
static void gnrc_ipv6_ext_frag_rbuf_del(gnrc_ipv6_ext_frag_rbuf_t *rbuf)
Delete a reassembly buffer entry (and release its gnrc_ipv6_ext_frag_rbuf_t::pkt)
Definition: frag.h:182
gnrc_pktsnip_t * gnrc_ipv6_ext_frag_reass(gnrc_pktsnip_t *pkt)
Reassemble fragmented IPv6 packet.
struct gnrc_ipv6_ext_frag_limits gnrc_ipv6_ext_frag_limits_t
Data type to describe limits of a single fragment in the reassembly buffer.
void gnrc_ipv6_ext_frag_rbuf_gc(void)
Garbage-collect reassembly buffer.
static void gnrc_pktbuf_release(gnrc_pktsnip_t *pkt)
Decreases gnrc_pktsnip_t::users of pkt atomically and removes it if it reaches 0 and reports GNRC_NET...
Definition: pktbuf.h:193
General definitions for network packets and their helper functions.
IPv6 header type and helper function definitions.
Interface definition for the global network buffer.
Data type to describe limits of a single fragment in the reassembly buffer.
Definition: frag.h:56
uint16_t end
the exclusive end (= offset + length) of the fragment
Definition: frag.h:59
struct gnrc_ipv6_ext_frag_limits * next
limits of next fragment
Definition: frag.h:57
uint16_t start
the start (= offset) of the fragment
Definition: frag.h:58
A reassembly buffer entry.
Definition: frag.h:78
gnrc_pktsnip_t * pkt
the (partly) reassembled packet
Definition: frag.h:79
uint32_t id
the identification from the fragment headers
Definition: frag.h:87
ipv6_hdr_t * ipv6
the IPv6 header of gnrc_ipv6_ext_frag_rbuf_t::pkt
Definition: frag.h:80
clist_node_t limits
The limits of the fragments in the reassembled packet.
Definition: frag.h:86
uint32_t arrival
arrival time of last received fragment
Definition: frag.h:88
uint16_t pkt_len
length of gnrc_ipv6_ext_frag_rbuf_t::pkt
Definition: frag.h:89
uint8_t last
received last fragment
Definition: frag.h:90
Fragmentation send buffer type.
Definition: frag.h:66
gnrc_pktsnip_t * pkt
the IPv6 packet to fragment
Definition: frag.h:67
gnrc_pktsnip_t * per_frag
per fragment headers
Definition: frag.h:68
uint16_t path_mtu
path MTU to destination of gnrc_ipv6_ext_frag_send_t::pkt
Definition: frag.h:70
uint32_t id
the identification for the fragment header
Definition: frag.h:69
uint16_t offset
current fragmentation offset
Definition: frag.h:72
Statistics on reassembly and reassembly.
Definition: frag.h:96
unsigned rbuf_full
counts the number of events where the reassembly buffer is full
Definition: frag.h:97
unsigned fragments
total fragments of reassembled fragments
Definition: frag.h:102
unsigned datagrams
reassembled datagrams
Definition: frag.h:101
unsigned frag_full
counts the number of events that there where no gnrc_sixlowpan_frag_fb_t available
Definition: frag.h:99
Type to represent parts (either headers or payload) of a packet, called snips.
Definition: pkt.h:105
Data type to represent an IPv6 packet header.
Definition: hdr.h:63
List node structure.
Definition: list.h:36