Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gnrc_ipv6_ext_frag: Initial import of IPv6 fragmentation #11623

Merged
merged 3 commits into from
Sep 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions sys/include/net/gnrc/ipv6/ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ extern "C" {
* @ingroup config
* @{
*/
/**
* @brief IPv6 fragmentation send buffer size
*
* This limits the total amount of datagrams that can be fragmented at the same time.
*
* @note Only applicable with [gnrc_ipv6_ext_frag](@ref net_gnrc_ipv6_ext_frag) module
*/
#ifndef GNRC_IPV6_EXT_FRAG_SEND_SIZE
#define GNRC_IPV6_EXT_FRAG_SEND_SIZE (1U)
#endif

/**
* @brief IPv6 fragmentation reassembly buffer size
*
Expand Down Expand Up @@ -76,6 +87,7 @@ extern "C" {
#ifndef GNRC_IPV6_EXT_FRAG_RBUF_TIMEOUT_US
#define GNRC_IPV6_EXT_FRAG_RBUF_TIMEOUT_US (10U * US_PER_SEC)
#endif

/** @} **/

/**
Expand Down
50 changes: 49 additions & 1 deletion sys/include/net/gnrc/ipv6/ext/frag.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#ifndef NET_GNRC_IPV6_EXT_FRAG_H
#define NET_GNRC_IPV6_EXT_FRAG_H

#include <stdbool.h>
#include <stdint.h>

#include "clist.h"
Expand All @@ -34,7 +35,22 @@ extern "C" {
/**
* @brief Message type to time reassembly buffer garbage collection
*/
#define GNRC_IPV6_EXT_FRAG_RBUF_GC (0xfe00U)
#define GNRC_IPV6_EXT_FRAG_RBUF_GC (0xfe00U)

/**
* @brief Message type to continue fragmenting a datagram from a given
* fragmentation send buffer
*
* Expected type: @ref gnrc_ipv6_ext_frag_send_t
*/
#define GNRC_IPV6_EXT_FRAG_CONTINUE (0xfe01U)

/**
* @brief Message type to send a fragment of an IPv6 datagram.
*
* Expected type: @ref gnrc_pktsnip_t
*/
#define GNRC_IPV6_EXT_FRAG_SEND (0xfe02U)

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

/**
* @brief Fragmentation send buffer type
*/
typedef struct {
gnrc_pktsnip_t *pkt; /**< the IPv6 packet to fragment */
gnrc_pktsnip_t *per_frag; /**< per fragment headers */
uint32_t id; /**< the identification for the fragment header */
uint16_t path_mtu; /**< path MTU to destination of
* gnrc_ipv6_ext_frag_send_t::pkt */
uint16_t offset; /**< current fragmentation offset */
} gnrc_ipv6_ext_frag_send_t;

/**
* @brief A reassembly buffer entry
*/
Expand All @@ -71,6 +99,26 @@ typedef struct {
*/
void gnrc_ipv6_ext_frag_init(void);

/**
* @brief Send an IPv6 packet fragmented
*
* @param[in] pkt The IPv6 packet. The packet must have an already
* prepared @ref GNRC_NETTYPE_NETIF snip as its first
* snip. The packet must contain at least an IPv6 header
* and any number of IPv6 extension headers after that.
* @param[in] path_mtu Path MTU to destination of IPv6 packet.
*/
void gnrc_ipv6_ext_frag_send_pkt(gnrc_pktsnip_t *pkt, unsigned path_mtu);

/**
* @brief (Continue to) fragment packet already in fragmentation send buffer
*
* @pre `snd_buf != NULL`
*
* @param[in,out] snd_buf A fragmentation send buffer entry. May not be NULL.
*/
void gnrc_ipv6_ext_frag_send(gnrc_ipv6_ext_frag_send_t *snd_buf);

/**
* @brief Reassemble fragmented IPv6 packet
*
Expand Down
Loading