Skip to content

Commit 5631b69

Browse files
authored
Merge pull request #11623 from miri64/gnrc_ipv6_ext/feat/ipv6-frag
gnrc_ipv6_ext_frag: Initial import of IPv6 fragmentation
2 parents e214dcb + e62bb9c commit 5631b69

7 files changed

Lines changed: 837 additions & 19 deletions

File tree

sys/include/net/gnrc/ipv6/ext.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ extern "C" {
4545
* @ingroup config
4646
* @{
4747
*/
48+
/**
49+
* @brief IPv6 fragmentation send buffer size
50+
*
51+
* This limits the total amount of datagrams that can be fragmented at the same time.
52+
*
53+
* @note Only applicable with [gnrc_ipv6_ext_frag](@ref net_gnrc_ipv6_ext_frag) module
54+
*/
55+
#ifndef GNRC_IPV6_EXT_FRAG_SEND_SIZE
56+
#define GNRC_IPV6_EXT_FRAG_SEND_SIZE (1U)
57+
#endif
58+
4859
/**
4960
* @brief IPv6 fragmentation reassembly buffer size
5061
*
@@ -76,6 +87,7 @@ extern "C" {
7687
#ifndef GNRC_IPV6_EXT_FRAG_RBUF_TIMEOUT_US
7788
#define GNRC_IPV6_EXT_FRAG_RBUF_TIMEOUT_US (10U * US_PER_SEC)
7889
#endif
90+
7991
/** @} **/
8092

8193
/**

sys/include/net/gnrc/ipv6/ext/frag.h

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#ifndef NET_GNRC_IPV6_EXT_FRAG_H
2121
#define NET_GNRC_IPV6_EXT_FRAG_H
2222

23+
#include <stdbool.h>
2324
#include <stdint.h>
2425

2526
#include "clist.h"
@@ -34,7 +35,22 @@ extern "C" {
3435
/**
3536
* @brief Message type to time reassembly buffer garbage collection
3637
*/
37-
#define GNRC_IPV6_EXT_FRAG_RBUF_GC (0xfe00U)
38+
#define GNRC_IPV6_EXT_FRAG_RBUF_GC (0xfe00U)
39+
40+
/**
41+
* @brief Message type to continue fragmenting a datagram from a given
42+
* fragmentation send buffer
43+
*
44+
* Expected type: @ref gnrc_ipv6_ext_frag_send_t
45+
*/
46+
#define GNRC_IPV6_EXT_FRAG_CONTINUE (0xfe01U)
47+
48+
/**
49+
* @brief Message type to send a fragment of an IPv6 datagram.
50+
*
51+
* Expected type: @ref gnrc_pktsnip_t
52+
*/
53+
#define GNRC_IPV6_EXT_FRAG_SEND (0xfe02U)
3854

3955
/**
4056
* @brief Data type to describe limits of a single fragment in the reassembly
@@ -47,6 +63,18 @@ typedef struct gnrc_ipv6_ext_frag_limits {
4763
* fragment */
4864
} gnrc_ipv6_ext_frag_limits_t;
4965

66+
/**
67+
* @brief Fragmentation send buffer type
68+
*/
69+
typedef struct {
70+
gnrc_pktsnip_t *pkt; /**< the IPv6 packet to fragment */
71+
gnrc_pktsnip_t *per_frag; /**< per fragment headers */
72+
uint32_t id; /**< the identification for the fragment header */
73+
uint16_t path_mtu; /**< path MTU to destination of
74+
* gnrc_ipv6_ext_frag_send_t::pkt */
75+
uint16_t offset; /**< current fragmentation offset */
76+
} gnrc_ipv6_ext_frag_send_t;
77+
5078
/**
5179
* @brief A reassembly buffer entry
5280
*/
@@ -71,6 +99,26 @@ typedef struct {
7199
*/
72100
void gnrc_ipv6_ext_frag_init(void);
73101

102+
/**
103+
* @brief Send an IPv6 packet fragmented
104+
*
105+
* @param[in] pkt The IPv6 packet. The packet must have an already
106+
* prepared @ref GNRC_NETTYPE_NETIF snip as its first
107+
* snip. The packet must contain at least an IPv6 header
108+
* and any number of IPv6 extension headers after that.
109+
* @param[in] path_mtu Path MTU to destination of IPv6 packet.
110+
*/
111+
void gnrc_ipv6_ext_frag_send_pkt(gnrc_pktsnip_t *pkt, unsigned path_mtu);
112+
113+
/**
114+
* @brief (Continue to) fragment packet already in fragmentation send buffer
115+
*
116+
* @pre `snd_buf != NULL`
117+
*
118+
* @param[in,out] snd_buf A fragmentation send buffer entry. May not be NULL.
119+
*/
120+
void gnrc_ipv6_ext_frag_send(gnrc_ipv6_ext_frag_send_t *snd_buf);
121+
74122
/**
75123
* @brief Reassemble fragmented IPv6 packet
76124
*

0 commit comments

Comments
 (0)