frag.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_IPV6_EXT_FRAG_H
21 #define NET_GNRC_IPV6_EXT_FRAG_H
22 
23 #include <stdbool.h>
24 #include <stdint.h>
25 
26 #include "clist.h"
27 #include "net/gnrc/pkt.h"
28 #include "net/gnrc/pktbuf.h"
29 #include "net/ipv6/hdr.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
38 #define GNRC_IPV6_EXT_FRAG_RBUF_GC (0xfe00U)
39 
46 #define GNRC_IPV6_EXT_FRAG_CONTINUE (0xfe01U)
47 
53 #define GNRC_IPV6_EXT_FRAG_SEND (0xfe02U)
54 
59 typedef struct gnrc_ipv6_ext_frag_limits {
61  uint16_t start;
62  uint16_t end;
65 
69 typedef struct {
72  uint32_t id;
73  uint16_t path_mtu;
75  uint16_t offset;
77 
81 typedef struct {
90  uint32_t id;
91  uint32_t arrival;
92  uint16_t pkt_len;
93  uint8_t last;
95 
99 typedef struct {
100  unsigned rbuf_full;
102  unsigned frag_full;
104  unsigned datagrams;
105  unsigned fragments;
107 
112 void gnrc_ipv6_ext_frag_init(void);
113 
123 void gnrc_ipv6_ext_frag_send_pkt(gnrc_pktsnip_t *pkt, unsigned path_mtu);
124 
133 
145 
166  uint32_t id);
167 
175 
186 {
187  gnrc_pktbuf_release(rbuf->pkt);
188  rbuf->pkt = NULL;
190 }
191 
199 void gnrc_ipv6_ext_frag_rbuf_gc(void);
209 
210 #ifdef __cplusplus
211 }
212 #endif
213 
214 #endif /* NET_GNRC_IPV6_EXT_FRAG_H */
215 
gnrc_pktbuf_release
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:178
hdr.h
IPv6 header type and helper function definitions.
gnrc_ipv6_ext_frag_send_t::offset
uint16_t offset
current fragmentation offset
Definition: frag.h:75
gnrc_ipv6_ext_frag_init
void gnrc_ipv6_ext_frag_init(void)
Initializes IPv6 fragmentation and reassembly.
gnrc_ipv6_ext_frag_stats
gnrc_ipv6_ext_frag_stats_t * gnrc_ipv6_ext_frag_stats(void)
Get the current statistics on reassembly and fragmentation.
gnrc_ipv6_ext_frag_send_t
Fragmentation send buffer type.
Definition: frag.h:69
gnrc_ipv6_ext_frag_rbuf_del
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:185
gnrc_ipv6_ext_frag_reass
gnrc_pktsnip_t * gnrc_ipv6_ext_frag_reass(gnrc_pktsnip_t *pkt)
Reassemble fragmented IPv6 packet.
gnrc_ipv6_ext_frag_rbuf_t::limits
clist_node_t limits
The limits of the fragments in the reassembled packet.
Definition: frag.h:89
gnrc_ipv6_ext_frag_send_t::path_mtu
uint16_t path_mtu
path MTU to destination of gnrc_ipv6_ext_frag_send_t::pkt
Definition: frag.h:73
gnrc_ipv6_ext_frag_rbuf_t::arrival
uint32_t arrival
arrival time of last received fragment
Definition: frag.h:91
gnrc_ipv6_ext_frag_rbuf_t::last
uint8_t last
received last fragment
Definition: frag.h:93
gnrc_ipv6_ext_frag_rbuf_t::pkt
gnrc_pktsnip_t * pkt
the (partly) reassembled packet
Definition: frag.h:82
gnrc_ipv6_ext_frag_send_t::pkt
gnrc_pktsnip_t * pkt
the IPv6 packet to fragment
Definition: frag.h:70
gnrc_ipv6_ext_frag_rbuf_t::ipv6
ipv6_hdr_t * ipv6
the IPv6 header of gnrc_ipv6_ext_frag_rbuf_t::pkt
Definition: frag.h:83
gnrc_ipv6_ext_frag_stats_t::fragments
unsigned fragments
total fragments of reassembled fragments
Definition: frag.h:105
gnrc_ipv6_ext_frag_send_pkt
void gnrc_ipv6_ext_frag_send_pkt(gnrc_pktsnip_t *pkt, unsigned path_mtu)
Send an IPv6 packet fragmented.
gnrc_ipv6_ext_frag_send
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_limits::start
uint16_t start
the start (= offset) of the fragment
Definition: frag.h:61
gnrc_ipv6_ext_frag_send_t::id
uint32_t id
the identification for the fragment header
Definition: frag.h:72
gnrc_ipv6_ext_frag_rbuf_t::id
uint32_t id
the identification from the fragment headers
Definition: frag.h:90
pkt.h
General definitions for network packets and their helper functions.
gnrc_ipv6_ext_frag_limits_t
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.
gnrc_ipv6_ext_frag_stats_t::frag_full
unsigned frag_full
counts the number of events that there where no gnrc_sixlowpan_frag_fb_t available
Definition: frag.h:102
clist.h
Circular linked list.
pktbuf.h
Interface definition for the global network buffer. Network devices and layers can allocate space for...
gnrc_ipv6_ext_frag_stats_t::datagrams
unsigned datagrams
reassembled datagrams
Definition: frag.h:104
gnrc_ipv6_ext_frag_send_t::per_frag
gnrc_pktsnip_t * per_frag
per fragment headers
Definition: frag.h:71
gnrc_ipv6_ext_frag_limits::next
struct gnrc_ipv6_ext_frag_limits * next
limits of next fragment
Definition: frag.h:60
list_node
List node structure.
Definition: list.h:40
gnrc_ipv6_ext_frag_limits
Data type to describe limits of a single fragment in the reassembly buffer.
Definition: frag.h:59
gnrc_ipv6_ext_frag_rbuf_t::pkt_len
uint16_t pkt_len
length of gnrc_ipv6_ext_frag_rbuf_t::pkt
Definition: frag.h:92
gnrc_ipv6_ext_frag_stats_t
Statistics on reassembly and reassembly.
Definition: frag.h:99
ipv6_hdr_t
Data type to represent an IPv6 packet header.
Definition: hdr.h:66
gnrc_ipv6_ext_frag_rbuf_get
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.
gnrc_ipv6_ext_frag_stats_t::rbuf_full
unsigned rbuf_full
counts the number of events where the reassembly buffer is full
Definition: frag.h:100
gnrc_pktsnip
Type to represent parts (either headers or payload) of a packet, called snips.
Definition: pkt.h:108
gnrc_ipv6_ext_frag_rbuf_gc
void gnrc_ipv6_ext_frag_rbuf_gc(void)
Garbage-collect reassembly buffer.
gnrc_ipv6_ext_frag_rbuf_free
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)
gnrc_ipv6_ext_frag_limits::end
uint16_t end
the exclusive end (= offset + length) of the fragment
Definition: frag.h:62
gnrc_ipv6_ext_frag_rbuf_t
A reassembly buffer entry.
Definition: frag.h:81