2015-03-07 21:46:57 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Martine Lenders <mlenders@inf.fu-berlin.de>
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser General
|
|
|
|
* Public License v2.1. See the file LICENSE in the top level directory for
|
|
|
|
* more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2015-08-17 15:41:29 +02:00
|
|
|
* @defgroup net_gnrc_ipv6_ext IPv6 extension headers.
|
|
|
|
* @ingroup net_gnrc_ipv6
|
2015-03-07 21:46:57 +01:00
|
|
|
* @brief Implementation of IPv6 extension headers
|
2018-04-10 15:38:05 +02:00
|
|
|
* @see [RFC 8200, section 4](https://tools.ietf.org/html/rfc8200#section-4)
|
2015-03-07 21:46:57 +01:00
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @brief Definititions for IPv6 extension headers
|
|
|
|
*
|
|
|
|
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2017-05-23 18:19:52 +02:00
|
|
|
#ifndef NET_GNRC_IPV6_EXT_H
|
|
|
|
#define NET_GNRC_IPV6_EXT_H
|
2015-03-07 21:46:57 +01:00
|
|
|
|
|
|
|
#include <stdbool.h>
|
2015-08-09 23:53:40 +02:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdlib.h>
|
2015-03-07 21:46:57 +01:00
|
|
|
|
2015-08-17 15:41:29 +02:00
|
|
|
#include "net/gnrc/pkt.h"
|
2015-08-09 23:53:40 +02:00
|
|
|
#include "net/ipv6/ext.h"
|
2019-05-23 16:29:19 +02:00
|
|
|
#include "timex.h"
|
2015-04-30 21:16:38 +02:00
|
|
|
|
2018-10-23 19:34:46 +02:00
|
|
|
#ifdef MODULE_GNRC_IPV6_EXT_RH
|
|
|
|
#include "net/gnrc/ipv6/ext/rh.h"
|
|
|
|
#endif
|
|
|
|
|
2015-03-07 21:46:57 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2019-05-23 16:29:19 +02:00
|
|
|
/**
|
|
|
|
* @defgroup net_gnrc_ipv6_ext_conf IPv6 extension header compile configurations
|
|
|
|
* @ingroup net_gnrc_ipv6_ext
|
|
|
|
* @ingroup config
|
|
|
|
* @{
|
|
|
|
*/
|
2019-05-23 21:12:11 +02:00
|
|
|
/**
|
|
|
|
* @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
|
|
|
|
|
2019-05-23 16:29:19 +02:00
|
|
|
/**
|
|
|
|
* @brief IPv6 fragmentation reassembly buffer size
|
|
|
|
*
|
|
|
|
* This limits the total amount of datagrams that can be reassembled at the same time.
|
|
|
|
*
|
|
|
|
* @note Only applicable with [gnrc_ipv6_ext_frag](@ref net_gnrc_ipv6_ext_frag) module
|
|
|
|
*/
|
|
|
|
#ifndef GNRC_IPV6_EXT_FRAG_RBUF_SIZE
|
|
|
|
#define GNRC_IPV6_EXT_FRAG_RBUF_SIZE (1U)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The number of total allocatable @ref gnrc_ipv6_ext_frag_limits_t objects
|
|
|
|
*
|
|
|
|
* This is the maximum number of receivable fragments, shared between all
|
|
|
|
* fragmented datagrams
|
|
|
|
*
|
|
|
|
* @note Only applicable with [gnrc_ipv6_ext_frag](@ref net_gnrc_ipv6_ext_frag) module
|
|
|
|
*/
|
|
|
|
#ifndef GNRC_IPV6_EXT_FRAG_LIMITS_POOL_SIZE
|
|
|
|
#define GNRC_IPV6_EXT_FRAG_LIMITS_POOL_SIZE (GNRC_IPV6_EXT_FRAG_RBUF_SIZE * 2U)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Timeout for IPv6 fragmentation reassembly buffer entries in microseconds
|
|
|
|
*
|
|
|
|
* @note Only applicable with [gnrc_ipv6_ext_frag](@ref net_gnrc_ipv6_ext_frag) module
|
|
|
|
*/
|
|
|
|
#ifndef GNRC_IPV6_EXT_FRAG_RBUF_TIMEOUT_US
|
|
|
|
#define GNRC_IPV6_EXT_FRAG_RBUF_TIMEOUT_US (10U * US_PER_SEC)
|
|
|
|
#endif
|
2019-05-23 21:12:11 +02:00
|
|
|
|
2019-05-23 16:29:19 +02:00
|
|
|
/** @} **/
|
|
|
|
|
2015-03-07 21:46:57 +01:00
|
|
|
/**
|
|
|
|
* @brief Builds an extension header for sending.
|
|
|
|
*
|
|
|
|
* @param[in] ipv6 The IPv6 header. Can be NULL.
|
|
|
|
* @param[in] next The next header. Must be a successor to @p ipv6 if it is
|
|
|
|
* not NULL.
|
2015-08-07 15:08:53 +02:00
|
|
|
* @param[in] nh @ref net_protnum of the next header.
|
2015-03-07 21:46:57 +01:00
|
|
|
* @param[in] size Size of the extension header.
|
|
|
|
*
|
|
|
|
* @return The extension header on success.
|
|
|
|
* @return NULL, on error.
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
gnrc_pktsnip_t *gnrc_ipv6_ext_build(gnrc_pktsnip_t *ipv6, gnrc_pktsnip_t *next,
|
|
|
|
uint8_t nh, size_t size);
|
2015-03-07 21:46:57 +01:00
|
|
|
|
2018-10-24 17:46:39 +02:00
|
|
|
#if defined(MODULE_GNRC_IPV6_EXT) || defined(DOXYGEN)
|
|
|
|
/**
|
2018-11-23 12:18:33 +01:00
|
|
|
* @brief Processes a packet's payload as hop-by-hop option if @p protnum is
|
2018-10-24 17:48:45 +02:00
|
|
|
* pointing to a value equal to @ref PROTNUM_IPV6_EXT_HOPOPT.
|
|
|
|
*
|
|
|
|
* @note Should be called by @ref net_gnrc_ipv6 before any further processing
|
|
|
|
* (even forwarding-related) is done to @p pkt.
|
|
|
|
*
|
2018-11-23 12:18:33 +01:00
|
|
|
* @param[in] pkt An IPv6 packet in receive order. It assumed that
|
|
|
|
* gnrc_pktsnip_t::data points to a hop-by-hop option
|
|
|
|
* when @p protnum points to value equal to
|
|
|
|
* @ref PROTNUM_IPV6_EXT_HOPOPT.
|
|
|
|
* @param[in,out] protnum **In:** The @ref net_protnum of gnrc_pktsnip_t::data
|
|
|
|
* of @p pkt. <br />
|
|
|
|
* **Out:** If @p protnum was
|
|
|
|
* @ref PROTNUM_IPV6_EXT_HOPOPT on in and the return
|
|
|
|
* value is not NULL it points to the value of the next
|
|
|
|
* header field of the processed hop-by-hop option
|
|
|
|
* header. Since the hop-by-hop option header is now
|
|
|
|
* marked, gnrc_pktsnip_t::data of @p pkt will then be
|
|
|
|
* identified by @p protnum. <br />
|
|
|
|
* If @p protnum was @ref PROTNUM_IPV6_EXT_HOPOPT on in
|
|
|
|
* and the return value is NULL the value @p protnum is
|
|
|
|
* pointing to is undefined. <br />
|
|
|
|
* If @p protnum unequal to
|
|
|
|
* @ref PROTNUM_IPV6_EXT_HOPOPT on in the value
|
|
|
|
* @p protnum is pointing to remains unchanged.
|
2018-10-24 17:48:45 +02:00
|
|
|
*
|
|
|
|
* @return @p pkt with the hop-by-hop option marked on success.
|
|
|
|
* @return NULL, if the packet was consumed by the option handling.
|
|
|
|
* @return NULL, on error. @p pkt is released with EINVAL in that case.
|
|
|
|
*/
|
|
|
|
gnrc_pktsnip_t *gnrc_ipv6_ext_process_hopopt(gnrc_pktsnip_t *pkt,
|
2018-11-23 12:18:33 +01:00
|
|
|
uint8_t *protnum);
|
2018-10-24 17:48:45 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Processes a packet's extension headers after a potential initial
|
|
|
|
* hop-by-hop header.
|
|
|
|
*
|
|
|
|
* @note Should be called by @ref net_gnrc_ipv6 after @ref
|
|
|
|
* gnrc_ipv6_ext_process_hopopt(), i.e. the (first) hop-by-hop option
|
|
|
|
* should already be marked in @p pkt. If a hop-by-hop option is found
|
|
|
|
* in gnrc_pktsnip_t::data of @p pkt, the function will return an
|
|
|
|
* error.
|
2018-10-24 17:46:39 +02:00
|
|
|
*
|
2018-11-23 12:18:33 +01:00
|
|
|
* @param[in] pkt An IPv6 packet in receive order.
|
|
|
|
* @param[in,out] protnum **In:** The @ref net_protnum of gnrc_pktsnip_t::data
|
|
|
|
* of @p pkt (i.e. the first extension header to be
|
|
|
|
* processed). <br />
|
|
|
|
* **Out:** The @ref net_protnum of header in
|
|
|
|
* gnrc_pktsnip_t::data of @p pkt. The extension
|
|
|
|
* headers are now marked, so their data can be found
|
|
|
|
* in gnrc_pktsnip_t::next of @p pkt and the following.
|
|
|
|
* <br />
|
|
|
|
* If the return value is NULL, the value of @p protnum
|
|
|
|
* is undefined.
|
2018-10-24 17:46:39 +02:00
|
|
|
*
|
|
|
|
* @return @p pkt with all extension headers marked until the first
|
|
|
|
* non-extension header.
|
|
|
|
* @return NULL, if packet was consumed by the extension header handling.
|
2018-10-24 17:48:45 +02:00
|
|
|
* @return NULL, on error (including if one of the extension headers was a
|
|
|
|
* hop-by-hop option). @p pkt is released with EINVAL in that case.
|
2018-10-24 17:46:39 +02:00
|
|
|
*/
|
|
|
|
gnrc_pktsnip_t *gnrc_ipv6_ext_process_all(gnrc_pktsnip_t *pkt,
|
2018-11-23 12:18:33 +01:00
|
|
|
uint8_t *protnum);
|
2018-10-24 17:46:39 +02:00
|
|
|
#else /* defined(MODULE_GNRC_IPV6_EXT) || defined(DOXYGEN) */
|
|
|
|
/* NOPs to make the usage code more readable */
|
2018-11-23 12:18:33 +01:00
|
|
|
#define gnrc_ipv6_ext_process_hopopt(pkt, protnum) (pkt)
|
|
|
|
#define gnrc_ipv6_ext_process_all(pkt, protnum) (pkt)
|
2018-10-24 17:46:39 +02:00
|
|
|
#endif /* defined(MODULE_GNRC_IPV6_EXT) || defined(DOXYGEN) */
|
|
|
|
|
2015-03-07 21:46:57 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-05-23 18:19:52 +02:00
|
|
|
#endif /* NET_GNRC_IPV6_EXT_H */
|
2015-03-07 21:46:57 +01:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|