Skip to content

Commit

Permalink
ipv6: move non-GNRC types and functions in their own modules
Browse files Browse the repository at this point in the history
  • Loading branch information
miri64 committed Aug 14, 2015
1 parent f65f721 commit 4f650b3
Show file tree
Hide file tree
Showing 33 changed files with 526 additions and 448 deletions.
13 changes: 9 additions & 4 deletions Makefile.dep
Expand Up @@ -108,19 +108,24 @@ ifneq (,$(filter ng_icmpv6,$(USEMODULE)))
endif

ifneq (,$(filter ng_ipv6_hdr,$(USEMODULE)))
USEMODULE += inet_csum
USEMODULE += ipv6_hdr
USEMODULE += ng_pktbuf
endif

ifneq (,$(filter ipv6_hdr,$(USEMODULE)))
USEMODULE += inet_csum
endif

ifneq (,$(filter ng_rpl_srh,$(USEMODULE)))
USEMODULE += ng_ipv6_ext_rh
USEMODULE += ipv6_ext_rh
endif

ifneq (,$(filter ng_ipv6_ext_rh,$(USEMODULE)))
USEMODULE += ng_ipv6_ext
ifneq (,$(filter ipv6_ext_rh,$(USEMODULE)))
USEMODULE += ipv6_ext
endif

ifneq (,$(filter ng_ipv6_ext,$(USEMODULE)))
USEMODULE += ipv6_ext
USEMODULE += ng_ipv6
endif

Expand Down
18 changes: 12 additions & 6 deletions sys/Makefile
Expand Up @@ -16,6 +16,18 @@ endif
ifneq (,$(filter oneway_malloc,$(USEMODULE)))
DIRS += oneway-malloc
endif
ifneq (,$(filter ipv6_addr,$(USEMODULE)))
DIRS += net/network_layer/ipv6/addr
endif
ifneq (,$(filter ipv6_ext_rh,$(USEMODULE)))
DIRS += net/network_layer/ipv6/ext/rh
endif
ifneq (,$(filter ipv6_ext,$(USEMODULE)))
DIRS += net/network_layer/ipv6/ext
endif
ifneq (,$(filter ipv6_hdr,$(USEMODULE)))
DIRS += net/network_layer/ipv6/hdr
endif
ifneq (,$(filter ng_icmpv6,$(USEMODULE)))
DIRS += net/network_layer/ng_icmpv6
endif
Expand All @@ -25,15 +37,9 @@ endif
ifneq (,$(filter ng_ipv6,$(USEMODULE)))
DIRS += net/network_layer/ng_ipv6
endif
ifneq (,$(filter ipv6_addr,$(USEMODULE)))
DIRS += net/network_layer/ipv6/addr
endif
ifneq (,$(filter ng_ipv6_ext,$(USEMODULE)))
DIRS += net/network_layer/ng_ipv6/ext
endif
ifneq (,$(filter ng_ipv6_ext_rh,$(USEMODULE)))
DIRS += net/network_layer/ng_ipv6/ext/rh
endif
ifneq (,$(filter ng_ipv6_hdr,$(USEMODULE)))
DIRS += net/network_layer/ng_ipv6/hdr
endif
Expand Down
2 changes: 2 additions & 0 deletions sys/include/net/ipv6.h
Expand Up @@ -25,6 +25,8 @@
#define IPV6_H_

#include "ipv6/addr.h"
#include "ipv6/ext.h"
#include "ipv6/hdr.h"

#ifdef __cplusplus
extern "C" {
Expand Down
64 changes: 64 additions & 0 deletions sys/include/net/ipv6/ext.h
@@ -0,0 +1,64 @@
/*
* 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.
*/

/**
* @defgroup net_ipv6_ext IPv6 extension headers
* @ingroup net_ipv6
* @brief Provides IPv6 extension header definitions and helper functions.
* @{
*
* @file
* @brief IPv6 extension header definitions.
*
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
*/
#ifndef IPV6_EXT_H_
#define IPV6_EXT_H_

#include <stdint.h>

#include "net/ipv6/ext/rh.h"

#ifdef __cplusplus
extern "C" {
#endif

#define IPV6_EXT_LEN_UNIT (8U) /**< Unit in byte for the extension header's
* length field */

/**
* @brief IPv6 extension headers.
*
* @see <a href="https://tools.ietf.org/html/rfc2460#section-4">
* RFC 2460, section 4.1
* </a>
*/
typedef struct __attribute__((packed)) {
uint8_t nh; /**< next header */
uint8_t len; /**< length in 8 octets without first octet */
} ipv6_ext_t;

/**
* @brief Gets the next extension header in a packet.
*
* @param[in] ext The current extension header.
*
* @return The next extension header.
*/
static inline ipv6_ext_t *ipv6_ext_get_next(ipv6_ext_t *ext)
{
return (ipv6_ext_t *)((uint8_t *)(ext) + (ext->len * IPV6_EXT_LEN_UNIT) +
IPV6_EXT_LEN_UNIT);
}

#ifdef __cplusplus
}
#endif

#endif /* IPV6_EXT_H_ */
/** @} */
20 changes: 11 additions & 9 deletions sys/include/net/ng_ipv6/ext/rh.h → sys/include/net/ipv6/ext/rh.h
Expand Up @@ -7,8 +7,8 @@
*/

/**
* @defgroup net_ng_ipv6_ext_rh IPv6 routing header extension
* @ingroup net_ng_ipv6_ext
* @defgroup net_ipv6_ext_rh IPv6 routing header extension
* @ingroup net_ipv6_ext
* @brief Implementation of IPv6 routing header extension.
* @{
*
Expand All @@ -17,11 +17,13 @@
*
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
*/
#ifndef NG_IPV6_EXT_RH_H_
#define NG_IPV6_EXT_RH_H_
#ifndef IPV6_EXT_RH_H_
#define IPV6_EXT_RH_H_

#include <stdint.h>

#include "net/ipv6/addr.h"
#include "net/ng_ipv6/hdr.h"
#include "net/ipv6/hdr.h"

#ifdef __cplusplus
extern "C" {
Expand All @@ -34,14 +36,14 @@ extern "C" {
* RFC 2460, section 4.4
* </a>
*
* @extends ng_ipv6_ext_t
* @extends ipv6_ext_t
*/
typedef struct __attribute__((packed)) {
uint8_t nh; /**< next header */
uint8_t len; /**< length in 8 octets without first octet */
uint8_t type; /**< identifier of a particular routing header type */
uint8_t seg_left; /**< number of route segments remaining */
} ng_ipv6_ext_rh_t;
} ipv6_ext_rh_t;

/**
* @brief Extract next hop from the routing header of an IPv6 packet.
Expand All @@ -51,11 +53,11 @@ typedef struct __attribute__((packed)) {
* @return next hop on success, on success
* @return NULL, if not found.
*/
ipv6_addr_t *ng_ipv6_ext_rh_next_hop(ng_ipv6_hdr_t *ipv6);
ipv6_addr_t *ipv6_ext_rh_next_hop(ipv6_hdr_t *ipv6);

#ifdef __cplusplus
}
#endif

#endif /* NG_IPV6_EXT_RH_H_ */
#endif /* IPV6_EXT_RH_H_ */
/** @} */

0 comments on commit 4f650b3

Please sign in to comment.