diff --git a/sys/include/net/icmpv6.h b/sys/include/net/icmpv6.h new file mode 100644 index 0000000000000000000000000000000000000000..3cd9e2b564e36ff3f11d5ec3f13def3db5f58e5e --- /dev/null +++ b/sys/include/net/icmpv6.h @@ -0,0 +1,223 @@ +/* + * 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_icmpv6 ICMPV6 + * @ingroup net_ipv6 + * @brief Provides types related to ICMPv6 + * @see <a href="https://tools.ietf.org/html/rfc4443"> + * RFC 4443 + * </a> + * @{ + * + * @file + * @brief ICMPv6 type and function definitions + * + * @author Martine Lenders <mlenders@inf.fu-berlin.de> + */ +#ifndef ICMPV6_H_ +#define ICMPV6_H_ + +#include <stdint.h> + +#include "byteorder.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @{ + * @name Error message types + * @see <a href="http://www.iana.org/assignments/icmpv6-parameters/icmpv6-parameters.xhtml#icmpv6-parameters-2"> + * IANA, ICMPv6 "type" Numbers + * </a> + */ +#define ICMPV6_DEST_UNR (1) /**< Destination unreachable message */ +#define ICMPV6_PKT_TOO_BIG (2) /**< Packet Too Big message */ +#define ICMPV6_TIME_EXC (3) /**< Time Exceeded message */ +#define ICMPV6_PARAM_PROB (4) /**< Parameter Problem message */ +#define ICMPV6_ERR_EXP1 (100) /**< message type for private experimentation */ +#define ICMPV6_ERR_EXP2 (101) /**< message type for private experimentation */ +/** + * @} + */ + +/** + * @{ + * @name Informational message types + * @see <a href="http://www.iana.org/assignments/icmpv6-parameters/icmpv6-parameters.xhtml#icmpv6-parameters-2"> + * IANA, ICMPv6 "type" Numbers + * </a> + */ +#define ICMPV6_ECHO_REQ (128) /**< Echo request message (ping) */ +#define ICMPV6_ECHO_REP (129) /**< Echo reply message (pong) */ +#define ICMPV6_RTR_SOL (133) /**< NDP router solicitation message */ +#define ICMPV6_RTR_ADV (134) /**< NDP router advertisement message */ +#define ICMPV6_NBR_SOL (135) /**< NDP neighbor solicitation message */ +#define ICMPV6_NBR_ADV (136) /**< NDP neighbor advertisement message */ +#define ICMPV6_REDIRECT (137) /**< NDP redirect message */ +#define ICMPV6_RPL_CTRL (155) /**< RPL control message */ +#define ICMPV6_INF_EXP1 (200) /**< message type for private experimentation */ +#define ICMPV6_INF_EXP2 (201) /**< message type for private experimentation */ +/** + * @} + */ + +/** + * @{ + * @name Codes for destination unreachable messages + * + * @see <a href="https://tools.ietf.org/html/rfc4443#section-3.1"> + * RFC 4443, section 3.1 + * </a> + */ +#define ICMPV6_ERROR_DST_UNR_NO_ROUTE (0) /**< no route to destination */ +#define ICMPV6_ERROR_DST_UNR_PROHIB (1) /**< communictation with + * destination administratively + * prohibited */ +#define ICMPV6_ERROR_DST_UNR_SCOPE (2) /**< beyond scope of source address */ +#define ICMPV6_ERROR_DST_UNR_ADDR (3) /**< address unreachable */ +#define ICMPV6_ERROR_DST_UNR_PORT (4) /**< port unreachable */ +#define ICMPV6_ERROR_DST_UNR_POLICY (5) /**< source address failed ingress/egress + * policy */ +#define ICMPV6_ERROR_DST_UNR_REJECT (6) /**< reject route to destination */ +/** + * @} + */ + +/** + * @{ + * @name Codes for time exceeded messages + * + * @see <a href="https://tools.ietf.org/html/rfc4443#section-3.3"> + * RFC 4443, section 3.3 + * </a> + */ +#define ICMPV6_ERROR_TIME_EXC_HL (0) /**< hop limit exceeded in transit */ +#define ICMPV6_ERROR_TIME_EXC_FRAG (1) /**< fragment reassembly time exceeded */ +/** + * @} + */ + +/** + * @{ + * @name Codes for parameter problem messages + * + * @see <a href="https://tools.ietf.org/html/rfc4443#section-3.4"> + * RFC 4443, section 3.4 + * </a> + */ +#define ICMPV6_ERROR_PARAM_PROB_HDR_FIELD (0) /**< errorneous header field + * encountered */ +#define ICMPV6_ERROR_PARAM_PROB_NH (1) /**< unrecognized next header + * field encountered */ +#define ICMPV6_ERROR_PARAM_PROB_OPT (2) /**< unrecognized IPv6 option + * field encountered */ +/** + * @} + */ + +/** + * @brief General ICMPv6 message format. + * + * @see <a href="https://tools.ietf.org/html/rfc4443#section-2.1"> + * RFC 4443, section 2.1 + * </a> + */ +typedef struct __attribute__((packed)) { + uint8_t type; /**< message type */ + uint8_t code; /**< message code */ + network_uint16_t csum; /**< checksum */ +} icmpv6_hdr_t; + +/** + * @brief Destination unreachable message format. + * @extends icmpv6_hdr_t + * + * @see <a href="https://tools.ietf.org/html/rfc4443#section-3.1"> + * RFC 4443, section 3.1 + * </a> + */ +typedef struct __attribute__((packed)) { + uint8_t type; /**< message type */ + uint8_t code; /**< message code */ + network_uint16_t csum; /**< checksum */ + network_uint32_t unused; /**< unused field */ +} icmpv6_error_dst_unr_t; + +/** + * @brief Packet too big message format. + * @extends icmpv6_hdr_t + * + * @see <a href="https://tools.ietf.org/html/rfc4443#section-3.2"> + * RFC 4443, section 3.2 + * </a> + */ +typedef struct __attribute__((packed)) { + uint8_t type; /**< message type */ + uint8_t code; /**< message code */ + network_uint16_t csum; /**< checksum */ + network_uint32_t mtu; /**< MTU */ +} icmpv6_error_pkt_too_big_t; + +/** + * @brief Time exceeded message format. + * @extends icmpv6_hdr_t + * + * @see <a href="https://tools.ietf.org/html/rfc4443#section-3.3"> + * RFC 4443, section 3.3 + * </a> + */ +typedef struct __attribute__((packed)) { + uint8_t type; /**< message type */ + uint8_t code; /**< message code */ + network_uint16_t csum; /**< checksum */ + network_uint32_t unused; /**< unused field */ +} icmpv6_error_time_exc_t; + +/** + * @brief Parameter problem message format. + * @extends icmpv6_hdr_t + * + * @see <a href="https://tools.ietf.org/html/rfc4443#section-3.4"> + * RFC 4443, section 3.3 + * </a> + */ +typedef struct __attribute__((packed)) { + uint8_t type; /**< message type */ + uint8_t code; /**< message code */ + network_uint16_t csum; /**< checksum */ + network_uint32_t ptr; /**< pointer */ +} icmpv6_error_param_prob_t; + +/** + * @brief Echo request and response message format. + * @extends icmpv6_hdr_t + * + * @see <a href="https://tools.ietf.org/html/rfc4443#section-4.1"> + * RFC 4443, section 4.1 + * </a> + * @see <a href="https://tools.ietf.org/html/rfc4443#section-4.2"> + * RFC 4443, section 4.2 + * </a> + */ +typedef struct __attribute__((packed)) { + uint8_t type; /**< message type */ + uint8_t code; /**< message code */ + network_uint16_t csum; /**< checksum */ + network_uint16_t id; /**< identifier */ + network_uint16_t seq; /**< Sequence number */ +} icmpv6_echo_t; + +#ifdef __cplusplus +} +#endif + +#endif /* ICMPV6_H_ */ +/** @} */ diff --git a/sys/include/net/ng_icmpv6.h b/sys/include/net/ng_icmpv6.h index 3410c98474e987241c1a00fe6ab95b3f0ef46c5c..035848ecb4fd63b497a945ca887bf4e290ced168 100644 --- a/sys/include/net/ng_icmpv6.h +++ b/sys/include/net/ng_icmpv6.h @@ -27,34 +27,17 @@ #ifndef NG_ICMPV6_H_ #define NG_ICMPV6_H_ -#include <inttypes.h> - -#include "byteorder.h" #include "kernel_types.h" -#include "net/ng_nettype.h" +#include "net/icmpv6.h" #include "net/ng_pkt.h" #include "net/ng_icmpv6/echo.h" #include "net/ng_icmpv6/error.h" -#include "net/ng_icmpv6/types.h" #ifdef __cplusplus extern "C" { #endif -/** - * @brief General ICMPv6 message format. - * - * @see <a href="https://tools.ietf.org/html/rfc4443#section-2.1"> - * RFC 4443, section 2.1 - * </a> - */ -typedef struct __attribute__((packed)) { - uint8_t type; /**< message type */ - uint8_t code; /**< message code */ - network_uint16_t csum; /**< checksum */ -} ng_icmpv6_hdr_t; - /** * @brief Demultiplexes a received ICMPv6 packet according to its type field. * @@ -70,7 +53,7 @@ void ng_icmpv6_demux(kernel_pid_t iface, ng_pktsnip_t *pkt); * @param[in] type Type for the ICMPv6 message. * @param[in] code Code for the ICMPv6 message. * @param[in] size Size of the ICMPv6 message (needs do be > - * `sizeof(ng_icmpv6_hdr_t)`). + * `sizeof(icmpv6_hdr_t)`). * * @return The ICMPv6 message on success * @return NULL, on failure diff --git a/sys/include/net/ng_icmpv6/echo.h b/sys/include/net/ng_icmpv6/echo.h index 4539ad6dba070d2c744ae17bb2877933a494c1e7..fa55fa90439528f34f5f46845f71066574bcb763 100644 --- a/sys/include/net/ng_icmpv6/echo.h +++ b/sys/include/net/ng_icmpv6/echo.h @@ -25,36 +25,16 @@ #include "byteorder.h" #include "kernel_types.h" #include "net/ipv6/hdr.h" -#include "net/ng_icmpv6/types.h" #ifdef __cplusplus extern "C" { #endif -/** - * @brief Echo request and response message format. - * @extends ng_icmpv6_hdr_t - * - * @see <a href="https://tools.ietf.org/html/rfc4443#section-4.1"> - * RFC 4443, section 4.1 - * </a> - * @see <a href="https://tools.ietf.org/html/rfc4443#section-4.2"> - * RFC 4443, section 4.2 - * </a> - */ -typedef struct __attribute__((packed)) { - uint8_t type; /**< message type */ - uint8_t code; /**< message code */ - network_uint16_t csum; /**< checksum */ - network_uint16_t id; /**< identifier */ - network_uint16_t seq; /**< Sequence number */ -} ng_icmpv6_echo_t; - /** * @brief Builds an ICMPv6 echo message of type @p type for sending. * * @param[in] type Type of the echo message. Expected to be either - * NG_ICMPV6_ECHO_REQ or NG_ICMPV6_ECHO_REP. + * ICMPV6_ECHO_REQ or ICMPV6_ECHO_REP. * @param[in] id ID for the echo message in host byte-order * @param[in] seq Sequence number for the echo message in host byte-order * @param[in] data Payload for the echo message @@ -84,7 +64,7 @@ ng_pktsnip_t *ng_icmpv6_echo_build(uint8_t type, uint16_t id, uint16_t seq, static inline ng_pktsnip_t *ng_icmpv6_echo_req_build(uint16_t id, uint16_t seq, uint8_t *data, size_t data_len) { - return ng_icmpv6_echo_build(NG_ICMPV6_ECHO_REQ, id, seq, data, data_len); + return ng_icmpv6_echo_build(ICMPV6_ECHO_REQ, id, seq, data, data_len); } /** @@ -105,7 +85,7 @@ static inline ng_pktsnip_t *ng_icmpv6_echo_req_build(uint16_t id, uint16_t seq, static inline ng_pktsnip_t *ng_icmpv6_echo_rep_build(uint16_t id, uint16_t seq, uint8_t *data, size_t data_len) { - return ng_icmpv6_echo_build(NG_ICMPV6_ECHO_REP, id, seq, data, data_len); + return ng_icmpv6_echo_build(ICMPV6_ECHO_REP, id, seq, data, data_len); } @@ -119,7 +99,7 @@ static inline ng_pktsnip_t *ng_icmpv6_echo_rep_build(uint16_t id, uint16_t seq, * of @p ipv6_hdr minus length of extension headers). */ void ng_icmpv6_echo_req_handle(kernel_pid_t iface, ipv6_hdr_t *ipv6_hdr, - ng_icmpv6_echo_t *echo, uint16_t len); + icmpv6_echo_t *echo, uint16_t len); #ifdef __cplusplus } diff --git a/sys/include/net/ng_icmpv6/error.h b/sys/include/net/ng_icmpv6/error.h index cc9015c9cea0b8d54252d838bde4a44406280311..8a749cfd4f2b26342696ed4f36a053fe5a4f2c9b 100644 --- a/sys/include/net/ng_icmpv6/error.h +++ b/sys/include/net/ng_icmpv6/error.h @@ -22,131 +22,10 @@ #ifndef NG_ICMPV6_ERROR_H_ #define NG_ICMPV6_ERROR_H_ -#include <inttypes.h> - -#include "byteorder.h" -#include "kernel_types.h" -#include "net/ng_icmpv6/types.h" - #ifdef __cplusplus extern "C" { #endif - -/** - * @{ - * @name Codes for destination unreachable messages - * - * @see <a href="https://tools.ietf.org/html/rfc4443#section-3.1"> - * RFC 4443, section 3.1 - * </a> - */ -#define NG_ICMPV6_ERROR_DEST_UNR_NO_ROUTE (0) /**< no route to destination */ -#define NG_ICMPV6_ERROR_DEST_UNR_PROHIB (1) /**< communictation with - * destination administratively - * prohibited */ -#define NG_ICMPV6_ERROR_DEST_UNR_SCOPE (2) /**< beyond scope of source address */ -#define NG_ICMPV6_ERROR_DEST_UNR_ADDR (3) /**< address unreachable */ -#define NG_ICMPV6_ERROR_DEST_UNR_PORT (4) /**< port unreachable */ -#define NG_ICMPV6_ERROR_DEST_UNR_POLICY (5) /**< source address failed ingress/egress - * policy */ -#define NG_ICMPV6_ERROR_DEST_UNR_REJECT (6) /**< reject route to destination */ -/** - * @} - */ - -/** - * @{ - * @name Codes for time exceeded messages - * - * @see <a href="https://tools.ietf.org/html/rfc4443#section-3.3"> - * RFC 4443, section 3.3 - * </a> - */ -#define NG_ICMPV6_ERROR_TIME_EXC_HL (0) /**< hop limit exceeded in transit */ -#define NG_ICMPV6_ERROR_TIME_EXC_FRAG (1) /**< fragment reassembly time exceeded */ -/** - * @} - */ - -/** - * @{ - * @name Codes for parameter problem messages - * - * @see <a href="https://tools.ietf.org/html/rfc4443#section-3.4"> - * RFC 4443, section 3.4 - * </a> - */ -#define NG_ICMPV6_ERROR_PARAM_PROB_HDR_FIELD (0) /**< errorneous header field - * encountered */ -#define NG_ICMPV6_ERROR_PARAM_PROB_NH (1) /**< unrecognized next header - * field encountered */ -#define NG_ICMPV6_ERROR_PARAM_PROB_OPT (2) /**< unrecognized IPv6 option - * field encountered */ -/** - * @} - */ - -/** - * @brief Destination unreachable message format. - * @extends ng_icmpv6_hdr_t - * - * @see <a href="https://tools.ietf.org/html/rfc4443#section-3.1"> - * RFC 4443, section 3.1 - * </a> - */ -typedef struct __attribute__((packed)) { - uint8_t type; /**< message type */ - uint8_t code; /**< message code */ - network_uint16_t csum; /**< checksum */ - network_uint32_t unused; /**< unused field */ -} ng_icmpv6_error_dst_unr_t; - -/** - * @brief Packet too big message format. - * @extends ng_icmpv6_hdr_t - * - * @see <a href="https://tools.ietf.org/html/rfc4443#section-3.2"> - * RFC 4443, section 3.2 - * </a> - */ -typedef struct __attribute__((packed)) { - uint8_t type; /**< message type */ - uint8_t code; /**< message code */ - network_uint16_t csum; /**< checksum */ - network_uint32_t mtu; /**< MTU */ -} ng_icmpv6_error_pkt_too_big_t; - -/** - * @brief Time exceeded message format. - * @extends ng_icmpv6_hdr_t - * - * @see <a href="https://tools.ietf.org/html/rfc4443#section-3.3"> - * RFC 4443, section 3.3 - * </a> - */ -typedef struct __attribute__((packed)) { - uint8_t type; /**< message type */ - uint8_t code; /**< message code */ - network_uint16_t csum; /**< checksum */ - network_uint32_t unused; /**< unused field */ -} ng_icmpv6_error_time_exc_t; - -/** - * @brief Parameter problem message format. - * @extends ng_icmpv6_hdr_t - * - * @see <a href="https://tools.ietf.org/html/rfc4443#section-3.4"> - * RFC 4443, section 3.3 - * </a> - */ -typedef struct __attribute__((packed)) { - uint8_t type; /**< message type */ - uint8_t code; /**< message code */ - network_uint16_t csum; /**< checksum */ - network_uint32_t ptr; /**< pointer */ -} ng_icmpv6_error_param_prob_t; - #ifdef __cplusplus } #endif diff --git a/sys/include/net/ng_icmpv6/types.h b/sys/include/net/ng_icmpv6/types.h deleted file mode 100644 index fddac3d4f6ead7b23dc84556e80cc37b1c7e5f8e..0000000000000000000000000000000000000000 --- a/sys/include/net/ng_icmpv6/types.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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_ng_icmpv6_types ICMPv6 message type definitions - * @ingroup net_ng_icmpv6 - * @brief Type numbers for the corresponding field in ICMPv6 messages. - * @{ - * - * @file - * @brief Macro definitions for ICMPv6 type fields - * - * @author Martine Lenders <mlenders@inf.fu-berlin.de> - */ -#ifndef NG_ICMPV6_TYPES_H_ -#define NG_ICMPV6_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @{ - * @name Error message types - * @see <a href="http://www.iana.org/assignments/icmpv6-parameters/icmpv6-parameters.xhtml#icmpv6-parameters-2"> - * IANA, ICMPv6 "type" Numbers - * </a> - */ -#define NG_ICMPV6_DEST_UNR (1) /**< Destination unreachable message */ -#define NG_ICMPV6_PKT_TOO_BIG (2) /**< Packet Too Big message */ -#define NG_ICMPV6_TIME_EXC (3) /**< Time Exceeded message */ -#define NG_ICMPV6_PARAM_PROB (4) /**< Parameter Problem message */ -#define NG_ICMPV6_ERR_EXP1 (100) /**< message type for private experimentation */ -#define NG_ICMPV6_ERR_EXP2 (101) /**< message type for private experimentation */ -/** - * @} - */ - -/** - * @{ - * @name Informational message types - * @see <a href="http://www.iana.org/assignments/icmpv6-parameters/icmpv6-parameters.xhtml#icmpv6-parameters-2"> - * IANA, ICMPv6 "type" Numbers - * </a> - */ -#define NG_ICMPV6_ECHO_REQ (128) /**< Echo request message (ping) */ -#define NG_ICMPV6_ECHO_REP (129) /**< Echo reply message (pong) */ -#define NG_ICMPV6_RTR_SOL (133) /**< NDP router solicitation message */ -#define NG_ICMPV6_RTR_ADV (134) /**< NDP router advertisement message */ -#define NG_ICMPV6_NBR_SOL (135) /**< NDP neighbor solicitation message */ -#define NG_ICMPV6_NBR_ADV (136) /**< NDP neighbor advertisement message */ -#define NG_ICMPV6_REDIRECT (137) /**< NDP redirect message */ -#define NG_ICMPV6_RPL_CTRL (155) /**< RPL control message */ -#define NG_ICMPV6_INF_EXP1 (200) /**< message type for private experimentation */ -#define NG_ICMPV6_INF_EXP2 (201) /**< message type for private experimentation */ -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* NG_ICMPV6_TYPES_H_ */ -/** @} */ diff --git a/sys/include/net/ng_ndp/types.h b/sys/include/net/ng_ndp/types.h index 026a9af3dc84d6b49eb60b0f5aaaf94d4e2cfc00..2e4cf9809dde47071de0bed85dad5995c4306f53 100644 --- a/sys/include/net/ng_ndp/types.h +++ b/sys/include/net/ng_ndp/types.h @@ -97,7 +97,7 @@ extern "C" { /** * @brief Router solicitation message format. - * @extends ng_icmpv6_hdr_t + * @extends icmpv6_hdr_t * * @see <a href="https://tools.ietf.org/html/rfc4861#section-4.1"> * RFC 4861, section 4.1 @@ -112,7 +112,7 @@ typedef struct __attribute__((packed)) { /** * @brief Router advertisement message format. - * @extends ng_icmpv6_hdr_t + * @extends icmpv6_hdr_t * * @see <a href="https://tools.ietf.org/html/rfc4861#section-4.2"> * RFC 4861, section 4.2 @@ -131,7 +131,7 @@ typedef struct __attribute__((packed)) { /** * @brief Neighbor solicitation message format. - * @extends ng_icmpv6_hdr_t + * @extends icmpv6_hdr_t * * @see <a href="https://tools.ietf.org/html/rfc4861#section-4.3"> * RFC 4861, section 4.3 @@ -147,7 +147,7 @@ typedef struct __attribute__((packed)) { /** * @brief Neighbor advertisement message format. - * @extends ng_icmpv6_hdr_t + * @extends icmpv6_hdr_t * * @see <a href="https://tools.ietf.org/html/rfc4861#section-4.4"> * RFC 4861, section 4.4 @@ -164,7 +164,7 @@ typedef struct __attribute__((packed)) { /** * @brief Neighbor advertisement message format. - * @extends ng_icmpv6_hdr_t + * @extends icmpv6_hdr_t * * @see <a href="https://tools.ietf.org/html/rfc4861#section-4.5"> * RFC 4861, section 4.5 diff --git a/sys/include/net/ng_rpl.h b/sys/include/net/ng_rpl.h index 67717a1ab6c94a1fb9e2fd31e36521379cdc68fe..f24e5131a69076c72738ed8979fdcc60b43dffc3 100644 --- a/sys/include/net/ng_rpl.h +++ b/sys/include/net/ng_rpl.h @@ -31,7 +31,6 @@ #include <string.h> #include <stdint.h> #include "net/ng_ipv6.h" -#include "net/ng_icmpv6.h" #include "net/ng_nettype.h" #include "net/ng_rpl/structs.h" #include "net/ng_rpl/dodag.h" diff --git a/sys/net/network_layer/ng_icmpv6/echo/ng_icmpv6_echo.c b/sys/net/network_layer/ng_icmpv6/echo/ng_icmpv6_echo.c index b005ad66f79855301f0f64a7be7373239fa87610..fd0bc2afc329d91f3c7df296f5274ff25f51492a 100644 --- a/sys/net/network_layer/ng_icmpv6/echo/ng_icmpv6_echo.c +++ b/sys/net/network_layer/ng_icmpv6/echo/ng_icmpv6_echo.c @@ -32,15 +32,15 @@ ng_pktsnip_t *ng_icmpv6_echo_build(uint8_t type, uint16_t id, uint16_t seq, uint8_t *data, size_t data_len) { ng_pktsnip_t *pkt; - ng_icmpv6_echo_t *echo; + icmpv6_echo_t *echo; - if ((pkt = ng_icmpv6_build(NULL, type, 0, data_len + sizeof(ng_icmpv6_echo_t))) == NULL) { + if ((pkt = ng_icmpv6_build(NULL, type, 0, data_len + sizeof(icmpv6_echo_t))) == NULL) { return NULL; } DEBUG("icmpv6_echo: Building echo message with type=%" PRIu8 "id=%" PRIu16 ", seq=%" PRIu16, type, id, seq); - echo = (ng_icmpv6_echo_t *)pkt->data; + echo = (icmpv6_echo_t *)pkt->data; echo->id = byteorder_htons(id); echo->seq = byteorder_htons(seq); @@ -62,21 +62,21 @@ ng_pktsnip_t *ng_icmpv6_echo_build(uint8_t type, uint16_t id, uint16_t seq, } void ng_icmpv6_echo_req_handle(kernel_pid_t iface, ipv6_hdr_t *ipv6_hdr, - ng_icmpv6_echo_t *echo, uint16_t len) + icmpv6_echo_t *echo, uint16_t len) { - uint8_t *payload = ((uint8_t *)echo) + sizeof(ng_icmpv6_echo_t); + uint8_t *payload = ((uint8_t *)echo) + sizeof(icmpv6_echo_t); ng_pktsnip_t *hdr, *pkt; ng_netreg_entry_t *sendto = NULL; - if ((echo == NULL) || (len < sizeof(ng_icmpv6_echo_t))) { + if ((echo == NULL) || (len < sizeof(icmpv6_echo_t))) { DEBUG("icmpv6_echo: echo was NULL or len (%" PRIu16 - ") was < sizeof(ng_icmpv6_echo_t)\n", len); + ") was < sizeof(icmpv6_echo_t)\n", len); return; } - pkt = ng_icmpv6_echo_build(NG_ICMPV6_ECHO_REP, byteorder_ntohs(echo->id), + pkt = ng_icmpv6_echo_build(ICMPV6_ECHO_REP, byteorder_ntohs(echo->id), byteorder_ntohs(echo->seq), payload, - len - sizeof(ng_icmpv6_echo_t)); + len - sizeof(icmpv6_echo_t)); if (pkt == NULL) { DEBUG("icmpv6_echo: no space left in packet buffer\n"); diff --git a/sys/net/network_layer/ng_icmpv6/ng_icmpv6.c b/sys/net/network_layer/ng_icmpv6/ng_icmpv6.c index a7b736ddc0b6bae85aae9ec77d9e21226ece9f85..f49d8240083d24b5d86b17b36cf24a63ba57f081 100644 --- a/sys/net/network_layer/ng_icmpv6/ng_icmpv6.c +++ b/sys/net/network_layer/ng_icmpv6/ng_icmpv6.c @@ -56,7 +56,7 @@ static inline uint16_t _calc_csum(ng_pktsnip_t *hdr, void ng_icmpv6_demux(kernel_pid_t iface, ng_pktsnip_t *pkt) { ng_pktsnip_t *icmpv6, *ipv6; - ng_icmpv6_hdr_t *hdr; + icmpv6_hdr_t *hdr; ng_netreg_entry_t *sendto; LL_SEARCH_SCALAR(pkt, icmpv6, type, NG_NETTYPE_ICMPV6); @@ -69,7 +69,7 @@ void ng_icmpv6_demux(kernel_pid_t iface, ng_pktsnip_t *pkt) assert(ipv6 != NULL); - hdr = (ng_icmpv6_hdr_t *)icmpv6->data; + hdr = (icmpv6_hdr_t *)icmpv6->data; if (_calc_csum(icmpv6, ipv6, pkt)) { DEBUG("icmpv6: wrong checksum.\n"); @@ -80,36 +80,36 @@ void ng_icmpv6_demux(kernel_pid_t iface, ng_pktsnip_t *pkt) switch (hdr->type) { /* TODO: handle ICMPv6 errors */ #ifdef MODULE_NG_ICMPV6_ECHO - case NG_ICMPV6_ECHO_REQ: + case ICMPV6_ECHO_REQ: DEBUG("icmpv6: handle echo request.\n"); ng_icmpv6_echo_req_handle(iface, (ipv6_hdr_t *)ipv6->data, - (ng_icmpv6_echo_t *)hdr, icmpv6->size); + (icmpv6_echo_t *)hdr, icmpv6->size); break; #endif - case NG_ICMPV6_RTR_SOL: + case ICMPV6_RTR_SOL: DEBUG("icmpv6: router solicitation received\n"); /* TODO */ break; - case NG_ICMPV6_RTR_ADV: + case ICMPV6_RTR_ADV: DEBUG("icmpv6: router advertisement received\n"); /* TODO */ break; - case NG_ICMPV6_NBR_SOL: + case ICMPV6_NBR_SOL: DEBUG("icmpv6: neighbor solicitation received\n"); ng_ndp_nbr_sol_handle(iface, pkt, ipv6->data, (ng_ndp_nbr_sol_t *)hdr, icmpv6->size); break; - case NG_ICMPV6_NBR_ADV: + case ICMPV6_NBR_ADV: DEBUG("icmpv6: neighbor advertisement received\n"); ng_ndp_nbr_adv_handle(iface, pkt, ipv6->data, (ng_ndp_nbr_adv_t *)hdr, icmpv6->size); break; - case NG_ICMPV6_REDIRECT: + case ICMPV6_REDIRECT: DEBUG("icmpv6: redirect message received\n"); /* TODO */ break; @@ -143,7 +143,7 @@ ng_pktsnip_t *ng_icmpv6_build(ng_pktsnip_t *next, uint8_t type, uint8_t code, size_t size) { ng_pktsnip_t *pkt; - ng_icmpv6_hdr_t *icmpv6; + icmpv6_hdr_t *icmpv6; pkt = ng_pktbuf_add(next, NULL, size, NG_NETTYPE_ICMPV6); @@ -154,7 +154,7 @@ ng_pktsnip_t *ng_icmpv6_build(ng_pktsnip_t *next, uint8_t type, uint8_t code, DEBUG("icmpv6: Building ICMPv6 message with type=%" PRIu8 ", code=%" PRIu8 "\n", type, code); - icmpv6 = (ng_icmpv6_hdr_t *)pkt->data; + icmpv6 = (icmpv6_hdr_t *)pkt->data; icmpv6->type = type; icmpv6->code = code; icmpv6->csum.u16 = 0; @@ -179,7 +179,7 @@ int ng_icmpv6_calc_csum(ng_pktsnip_t *hdr, ng_pktsnip_t *pseudo_hdr) return -ENOENT; } - ((ng_icmpv6_hdr_t *)hdr->data)->csum = byteorder_htons(csum); + ((icmpv6_hdr_t *)hdr->data)->csum = byteorder_htons(csum); return 0; } diff --git a/sys/net/network_layer/ng_ndp/internal/ng_ndp_internal.c b/sys/net/network_layer/ng_ndp/internal/ng_ndp_internal.c index bb52b177a096bfd3fd2f710d785866143a4d5d61..de81ec638fec51d362b9f9377ec8edddc2f22532 100644 --- a/sys/net/network_layer/ng_ndp/internal/ng_ndp_internal.c +++ b/sys/net/network_layer/ng_ndp/internal/ng_ndp_internal.c @@ -344,7 +344,7 @@ bool ng_ndp_internal_sl2a_opt_handle(kernel_pid_t iface, ng_pktsnip_t *pkt, ng_netif_addr_to_str(addr_str, sizeof(addr_str), sl2a, sl2a_len)); switch (icmpv6_type) { - case NG_ICMPV6_NBR_SOL: + case ICMPV6_NBR_SOL: nc_entry = ng_ipv6_nc_get(iface, &ipv6->src); if (nc_entry != NULL) { @@ -384,7 +384,7 @@ int ng_ndp_internal_tl2a_opt_handle(ng_pktsnip_t *pkt, ipv6_hdr_t *ipv6, } switch (icmpv6_type) { - case NG_ICMPV6_NBR_ADV: + case ICMPV6_NBR_ADV: while (pkt) { if (pkt->type == NG_NETTYPE_NETIF) { ng_netif_hdr_t *hdr = pkt->data; diff --git a/sys/net/network_layer/ng_ndp/ng_ndp.c b/sys/net/network_layer/ng_ndp/ng_ndp.c index 45ba40bee6b023ac6241c36c8778a540063d6467..d92fb9621434b8a98fcc12ca1a7ecde412249e74 100644 --- a/sys/net/network_layer/ng_ndp/ng_ndp.c +++ b/sys/net/network_layer/ng_ndp/ng_ndp.c @@ -365,7 +365,7 @@ ng_pktsnip_t *ng_ndp_nbr_sol_build(ipv6_addr_t *tgt, ng_pktsnip_t *options) return NULL; } - pkt = ng_icmpv6_build(options, NG_ICMPV6_NBR_SOL, 0, sizeof(ng_ndp_nbr_sol_t)); + pkt = ng_icmpv6_build(options, ICMPV6_NBR_SOL, 0, sizeof(ng_ndp_nbr_sol_t)); if (pkt != NULL) { ng_ndp_nbr_sol_t *nbr_sol = pkt->data; @@ -389,7 +389,7 @@ ng_pktsnip_t *ng_ndp_nbr_adv_build(uint8_t flags, ipv6_addr_t *tgt, return NULL; } - pkt = ng_icmpv6_build(options, NG_ICMPV6_NBR_ADV, 0, sizeof(ng_ndp_nbr_adv_t)); + pkt = ng_icmpv6_build(options, ICMPV6_NBR_ADV, 0, sizeof(ng_ndp_nbr_adv_t)); if (pkt != NULL) { ng_ndp_nbr_adv_t *nbr_adv = pkt->data; diff --git a/sys/net/routing/ng_rpl/ng_rpl.c b/sys/net/routing/ng_rpl/ng_rpl.c index 2f8e1c798b7b075357fa4e5a6e2072ed82979cf0..b09418fca87e9b9a44091eeb164ce9597313432f 100644 --- a/sys/net/routing/ng_rpl/ng_rpl.c +++ b/sys/net/routing/ng_rpl/ng_rpl.c @@ -13,6 +13,7 @@ * * @author Cenk Gündoğan <cnkgndgn@gmail.com> */ +#include "net/icmpv6.h" #include "net/ng_rpl.h" #define ENABLE_DEBUG (0) @@ -52,7 +53,7 @@ kernel_pid_t ng_rpl_init(kernel_pid_t if_pid) return KERNEL_PID_UNDEF; } - _me_reg.demux_ctx = NG_ICMPV6_RPL_CTRL; + _me_reg.demux_ctx = ICMPV6_RPL_CTRL; _me_reg.pid = ng_rpl_pid; /* register interest in all ICMPv6 packets */ ng_netreg_register(NG_NETTYPE_ICMPV6, &_me_reg); @@ -147,12 +148,12 @@ static void _receive(ng_pktsnip_t *icmpv6) { ng_pktsnip_t *ipv6 = NULL; ipv6_hdr_t *ipv6_hdr = NULL; - ng_icmpv6_hdr_t *icmpv6_hdr = NULL; + icmpv6_hdr_t *icmpv6_hdr = NULL; LL_SEARCH_SCALAR(icmpv6, ipv6, type, NG_NETTYPE_IPV6); ipv6_hdr = (ipv6_hdr_t *)ipv6->data; - icmpv6_hdr = (ng_icmpv6_hdr_t *)icmpv6->data; + icmpv6_hdr = (icmpv6_hdr_t *)icmpv6->data; switch (icmpv6_hdr->code) { case NG_RPL_ICMPV6_CODE_DIS: DEBUG("RPL: DIS received\n"); diff --git a/sys/net/routing/ng_rpl/ng_rpl_control_messages.c b/sys/net/routing/ng_rpl/ng_rpl_control_messages.c index e98cd6ee5c9b8ef8ef5e92391600ee9f84781b36..cf06c96f49f86b14e292ebc5204bbd540220d3c4 100644 --- a/sys/net/routing/ng_rpl/ng_rpl_control_messages.c +++ b/sys/net/routing/ng_rpl/ng_rpl_control_messages.c @@ -15,6 +15,8 @@ * @author Cenk Gündoğan <cnkgndgn@gmail.com> */ +#include "net/icmpv6.h" +#include "net/ng_icmpv6.h" #include "net/ng_rpl.h" #include "inet_ntop.h" @@ -91,21 +93,21 @@ void ng_rpl_send_DIO(ng_rpl_dodag_t *dodag, ipv6_addr_t *destination) } ng_pktsnip_t *pkt; - ng_icmpv6_hdr_t *icmp; + icmpv6_hdr_t *icmp; ng_rpl_dio_t *dio; uint8_t *pos; - int size = sizeof(ng_icmpv6_hdr_t) + sizeof(ng_rpl_dio_t); + int size = sizeof(icmpv6_hdr_t) + sizeof(ng_rpl_dio_t); if ((dodag->dodag_conf_counter % 3) == 0) { size += sizeof(ng_rpl_opt_dodag_conf_t); } - if ((pkt = ng_icmpv6_build(NULL, NG_ICMPV6_RPL_CTRL, NG_RPL_ICMPV6_CODE_DIO, size)) == NULL) { + if ((pkt = ng_icmpv6_build(NULL, ICMPV6_RPL_CTRL, NG_RPL_ICMPV6_CODE_DIO, size)) == NULL) { DEBUG("RPL: Send DIO - no space left in packet buffer\n"); return; } - icmp = (ng_icmpv6_hdr_t *)pkt->data; + icmp = (icmpv6_hdr_t *)pkt->data; dio = (ng_rpl_dio_t *)(icmp + 1); pos = (uint8_t *) dio; dio->instance_id = dodag->instance->id; @@ -146,19 +148,19 @@ void ng_rpl_send_DIS(ng_rpl_dodag_t *dodag, ipv6_addr_t *destination) { (void) dodag; ng_pktsnip_t *pkt; - ng_icmpv6_hdr_t *icmp; + icmpv6_hdr_t *icmp; ng_rpl_dis_t *dis; /* TODO: Currently the DIS is too small so that wireshark complains about an incorrect * ethernet frame check sequence. In order to prevent this, 4 PAD1 options are added. * This will be addressed in follow-up PRs */ - int size = sizeof(ng_icmpv6_hdr_t) + sizeof(ng_rpl_dis_t) + 4; + int size = sizeof(icmpv6_hdr_t) + sizeof(ng_rpl_dis_t) + 4; - if ((pkt = ng_icmpv6_build(NULL, NG_ICMPV6_RPL_CTRL, NG_RPL_ICMPV6_CODE_DIS, size)) == NULL) { + if ((pkt = ng_icmpv6_build(NULL, ICMPV6_RPL_CTRL, NG_RPL_ICMPV6_CODE_DIS, size)) == NULL) { DEBUG("RPL: Send DIS - no space left in packet buffer\n"); return; } - icmp = (ng_icmpv6_hdr_t *)pkt->data; + icmp = (icmpv6_hdr_t *)pkt->data; dis = (ng_rpl_dis_t *)(icmp + 1); dis->flags = 0; dis->reserved = 0; @@ -301,7 +303,7 @@ void ng_rpl_recv_DIO(ng_rpl_dio_t *dio, ipv6_addr_t *src, uint16_t len) ng_rpl_instance_t *inst = NULL; ng_rpl_dodag_t *dodag = NULL; - len -= (sizeof(ng_rpl_dio_t) + sizeof(ng_icmpv6_hdr_t)); + len -= (sizeof(ng_rpl_dio_t) + sizeof(icmpv6_hdr_t)); if (ng_rpl_instance_add(dio->instance_id, &inst)) { inst->mop = (dio->g_mop_prf >> NG_RPL_MOP_SHIFT) & NG_RPL_SHIFTED_MOP_MASK; @@ -451,7 +453,7 @@ void ng_rpl_send_DAO(ng_rpl_dodag_t *dodag, ipv6_addr_t *destination, uint8_t li } ng_pktsnip_t *pkt; - ng_icmpv6_hdr_t *icmp; + icmpv6_hdr_t *icmp; ng_rpl_dao_t *dao; ng_rpl_opt_target_t *target; ng_rpl_opt_transit_t *transit; @@ -476,15 +478,15 @@ void ng_rpl_send_DAO(ng_rpl_dodag_t *dodag, ipv6_addr_t *destination, uint8_t li ipv6_addr_init_prefix(&prefix, me, me_netif->prefix_len); fib_get_destination_set(prefix.u8, sizeof(ipv6_addr_t), fib_dest_set, &dst_size); - int size = sizeof(ng_icmpv6_hdr_t) + sizeof(ng_rpl_dao_t) + + int size = sizeof(icmpv6_hdr_t) + sizeof(ng_rpl_dao_t) + (sizeof(ng_rpl_opt_target_t) * (dst_size + 1)) + sizeof(ng_rpl_opt_transit_t); - if ((pkt = ng_icmpv6_build(NULL, NG_ICMPV6_RPL_CTRL, NG_RPL_ICMPV6_CODE_DAO, size)) == NULL) { + if ((pkt = ng_icmpv6_build(NULL, ICMPV6_RPL_CTRL, NG_RPL_ICMPV6_CODE_DAO, size)) == NULL) { DEBUG("RPL: Send DAO - no space left in packet buffer\n"); return; } - icmp = (ng_icmpv6_hdr_t *)pkt->data; + icmp = (icmpv6_hdr_t *)pkt->data; dao = (ng_rpl_dao_t *)(icmp + 1); dao->instance_id = dodag->instance->id; @@ -526,16 +528,16 @@ void ng_rpl_send_DAO_ACK(ng_rpl_dodag_t *dodag, ipv6_addr_t *destination, uint8_ } ng_pktsnip_t *pkt; - ng_icmpv6_hdr_t *icmp; + icmpv6_hdr_t *icmp; ng_rpl_dao_ack_t *dao_ack; - int size = sizeof(ng_icmpv6_hdr_t) + sizeof(ng_rpl_dao_ack_t); + int size = sizeof(icmpv6_hdr_t) + sizeof(ng_rpl_dao_ack_t); - if ((pkt = ng_icmpv6_build(NULL, NG_ICMPV6_RPL_CTRL, NG_RPL_ICMPV6_CODE_DAO_ACK, size)) == NULL) { + if ((pkt = ng_icmpv6_build(NULL, ICMPV6_RPL_CTRL, NG_RPL_ICMPV6_CODE_DAO_ACK, size)) == NULL) { DEBUG("RPL: Send DAOACK - no space left in packet buffer\n"); return; } - icmp = (ng_icmpv6_hdr_t *)pkt->data; + icmp = (icmpv6_hdr_t *)pkt->data; dao_ack = (ng_rpl_dao_ack_t *)(icmp + 1); dao_ack->instance_id = dodag->instance->id; @@ -569,7 +571,7 @@ void ng_rpl_recv_DAO(ng_rpl_dao_t *dao, ipv6_addr_t *src, uint16_t len) return; } - len -= (sizeof(ng_rpl_dao_t) + sizeof(ng_icmpv6_hdr_t)); + len -= (sizeof(ng_rpl_dao_t) + sizeof(icmpv6_hdr_t)); if(!_parse_options(NG_RPL_ICMPV6_CODE_DAO, dodag, (ng_rpl_opt_t *) (dao + 1), len, src)) { ng_rpl_dodag_remove(dodag); return; diff --git a/sys/shell/commands/sc_icmpv6_echo.c b/sys/shell/commands/sc_icmpv6_echo.c index c307b1970cf6fe23480304395d1cfafe8b1f818e..e87bc032e76d8a726d53a1a95cdc353095bb175e 100644 --- a/sys/shell/commands/sc_icmpv6_echo.c +++ b/sys/shell/commands/sc_icmpv6_echo.c @@ -45,7 +45,7 @@ static void usage(char **argv) puts(" delay = 1000"); } -void _set_payload(ng_icmpv6_echo_t *hdr, size_t payload_len) +void _set_payload(icmpv6_echo_t *hdr, size_t payload_len) { size_t i = 0; uint8_t *payload = (uint8_t *)(hdr + 1); @@ -81,7 +81,7 @@ int _handle_reply(ng_pktsnip_t *pkt, uint64_t time) { ng_pktsnip_t *ipv6, *icmpv6; ipv6_hdr_t *ipv6_hdr; - ng_icmpv6_echo_t *icmpv6_hdr; + icmpv6_echo_t *icmpv6_hdr; uint16_t seq; LL_SEARCH_SCALAR(pkt, ipv6, type, NG_NETTYPE_IPV6); @@ -136,7 +136,7 @@ int _icmpv6_ping(int argc, char **argv) timex_t delay = { 1, 0 }; char *addr_str; ipv6_addr_t addr; - ng_netreg_entry_t *ipv6_entry, my_entry = { NULL, NG_ICMPV6_ECHO_REP, + ng_netreg_entry_t *ipv6_entry, my_entry = { NULL, ICMPV6_ECHO_REP, thread_getpid() }; timex_t min_rtt = { UINT32_MAX, UINT32_MAX }, max_rtt = { 0, 0 };